Questions tagged [fenics]

Questions about the finite element method software FEniCS and its subpackages (Dolfin, UFL, FFC).

Filter by
Sorted by
Tagged with
14
votes
2answers
2k views

FeniCS: Visualizing high order elements

I've just started messing around with FEniCS. I am solving Poisson with 3rd order elements and would like to visualize the results. However, when I use plot(u), the visualization is just a linear ...
11
votes
3answers
3k views

Poisson equation: Impose full gradient as boundary condition via Lagrange multipliers

I have a physical problem governed by the Poisson equation in two dimensions $$ -\nabla^2 u = f(x,y), \; in \; \Omega $$ I have measurements of the two gradient components $\partial{u}/\partial{x}$ ...
10
votes
2answers
3k views

Discontinuous Galerkin / Poisson / Fenics

I am trying to solve the 2D Poisson equation using the Discontinuous Galerkin method (DG) and the following discretization (I have a png file but I am not allowed to upload it, sorry): Equation : $$\...
9
votes
3answers
1k views

Are there any “light-weight” FEM packages around?

Basically, FEM seems to be a problem that is pretty much "solved". There are numerous powerful frameworks existing, like Trilinos, PETSc, FEniCS, Libmesh or MOOSE. One thing they have in common: They ...
8
votes
0answers
409 views

Simple turbulence model appropriate for buoyancy-driven cavity like problem

Which turbulence model is suitable for resolving incompressible buoyancy-driven flow of a fluid within an cylindrical ampoule? I prefer turbulence model which is sufficiently simple so that fully ...
7
votes
3answers
4k views

Tutorial for flow around a cylinder in FEniCS

I am continuing my dive into computational fluid dynamics. I would like to build a simple test case for modelling the flow around a cylinder in FEniCS and then continue to model turbulence in order to ...
7
votes
2answers
291 views

Comparing various implementations/software packages for large-scale finite element simulations

I currently use FEniCS and Deal.II to solve various FEM problems. I am also writing my own implementation of these problems by directly implementing the data structures, routines, and solvers within ...
7
votes
2answers
2k views

FEniCS: boundary conditions for electrostatic problems with dielectrics

I carefully read all circa 70 pages of FEniCS tutorial and I still do not understand how to solve electrostatic problems when I have materials with different dielectric constant. The self contained ...
7
votes
1answer
225 views

Spectral Element vs Finite Element

I am trying to understand the difference between SEM and FEM. If I go by this paper, spectral element methods are a subset of FEM methods and the only difference lies in the choice of basis functions. ...
6
votes
1answer
764 views

FEniCS: how to access coordinates when writing an equation for a trial function

I need to solve the following equation in FEniCS: $$ \boldsymbol{\nabla} \cdot \begin{pmatrix} f(y)\frac{\partial u}{\partial x} - g(x,y)\frac{\partial u}{\partial y} \\ - g(x,y)\frac{\partial u}{\...
6
votes
1answer
3k views

FEniCS: separate boundary conditions in normal and tangential direction of mesh boundary

Given a vector-valued PDE, I'd like to enforce the boundary conditions $$ \vec{n}\cdot u = g\\ \vec{n}\cdot \nabla (\vec{t}\cdot u) = 0 $$ on the solution $\vec{u}$. If the boundary happens to align ...
6
votes
1answer
1k views

FEniCS CFD work-flow for complex geometries

I have COMSOL and the CFD package therein available, which provides me with an all-in-one solution for solving CFD problems. I have modeled and solved the geometry shown in the pictures below, which ...
6
votes
1answer
4k views

FEniCS: how to specify boundary conditions on a circle inside 2D mesh

I would like to numerically find a mutual capacitance of two stripes of metal on the opposites sides of a cylinder. The problem is obviously a 2D Laplace equation. I would like to find the potential ...
6
votes
0answers
606 views

Stochastic Galerkin projection approach for using generalized polynomial chaos expansion (GPCE) in solving PDE

I want to know if there is any way to define the test and trial function in the way that I want instead of using the default functions. So if I want define the polynomial and basis and coefficient, ...
5
votes
1answer
787 views

Compute lengths of the longest edge of each cell

Having mesh = UnitSquareMesh(2, 2) Q = FunctionSpace(mesh, 'DG', 0) this works as expected ...
4
votes
4answers
5k views

Fenics: msh to xml conversion

I generated a mesh file in gambit and wanted to convert it to xml format. I tried the code below, but there is no output. ...
4
votes
2answers
437 views

Poiseuille flow

I have probably a very stupid problem. I can't solve a simple Poiseuille flow in a straight 2-D channel driven by a pressure drop. Results are complete nonsense. (Setting zero pressure on the outflow ...
4
votes
1answer
3k views

Fenics: Meshfunction usage

I am confused most of the time with the application of boundary conditions in Fenics. Suppose I have an xml mesh for a rectangular beam and want to apply Dirichlet BC ($u =0$) on the left side of the ...
4
votes
1answer
2k views

Fenics, initialize vector of degrees of freedom for function

With the move away from launchpad I hope this is the right place for this question. Is there a way to initialize the DOFs for a function? generated by u = Function(V) When I run a code which I ...
4
votes
1answer
138 views

Assembling FE tensors using different quadrature degrees

Assume we have few terms contributing to element tensor and each requires different quadrature degree to be integrated exactly. Does it generally worth using different quadrature degrees for each term ...
4
votes
4answers
1k views

FEniCS : How to interpolate data at vertices of (3D) cells?

I am trying to get an interpolation function $f$ (in 3D) at all vertices of cells. I extract all vertices of cells and then I assign the value to each vertex: if it's in a sphere of radius $R$, then I ...
4
votes
2answers
2k views

FEniCS: importing mesh along with material and boundary data

Which is the preferred way to import into a FEniCS (python) program a mesh which was generated in an external generator which provides sub-domain and boundary markers? I was using MeshData->...
4
votes
2answers
881 views

FEniCS: custom quadrature rule

For the numerical integration of reaction terms in my PDE on a 2D triangular mesh, I would like to use the scheme $$ \int_T \Phi(x) \approx \frac{|T|}{3} (\Phi(x_0) + \Phi(x_1) + \Phi(x_2)) $$ where ...
4
votes
2answers
1k views

CFD: multiphase flow modeling of a laminar flow reactor

I am planning to model the laminar flow reactor shown in the picture below using computational fluid dynamics (CFD). The laminar flow reactor is used to study a multiphase flow: a layer of sheath air ...
4
votes
1answer
144 views

compute max(||u||) for vector field

Given a vector-valued Dolfin function u from the function space V*V with ...
4
votes
0answers
1k views

Poisson equation with pure Neumann boundary conditions (using FEM)

I am trying to derive the correct variational form for the Poisson equation with pure Neumann boundary conditions, and an additional contraint $\int_{\Omega} u \, {\rm d} x = 0$, as described in this ...
4
votes
0answers
499 views

Fenics: Result of Steady state dynamic linear elastic doesn't match with actual values

I solved the steady state dynamic linear elastic model in a solid. My equation is a function of frequency and the strong form is: $$\operatorname{div}(\operatorname{stress}(\vec x, w)) + w^2 \rho u( \...
3
votes
2answers
829 views

FEniCS: extracting points from a cell

I'd like to loop over all edges of a simplex (in a mesh). To this end: How can I extract the the points from a cell? This is for the eval method of a C++ ...
3
votes
2answers
567 views

Integrating an Ordinary Differential Equation over a domain in Finite Element Methods

I'm trying to get a deeper understanding of the Finite Element Method (FEM) to better understand what I do in COMSOL and FEniCS. The sketch below shows the problem that I want to solve in FEM. The ...
3
votes
2answers
849 views

Flux across a non-boundary line segment in FEniCS

I am solving an elliptic boundary value problem on a subset of the rectangle [-1,1]x[-1,1]. The domain contains the line segment x=0, however this does not need to be a part of the boundary, so it is ...
3
votes
2answers
1k views

Developing a C++ solid mechanics program

I am a beginner in computational science and programming. I am doing research in non linear solid mechanics analysis and using C++ for coding. I have been exploring various finite element open source ...
3
votes
1answer
427 views

Fenics: time-independent Sine-Gordon equation

Is there a code for the equation $$ \frac{\partial^2u}{\partial x^2}+\frac{\partial^2u}{\partial y^2} = \sin(u) $$ or for the sine gordon equation in two dimensions because I want to change some ...
3
votes
1answer
264 views

Fast function evaluation on a grid

I am trying to calculate a 3D Function f on a large set of points, say a uniform cubic grid. Besides, the cubic grid points do not coincide with the mesh vertices where the Function f is defined. For ...
3
votes
1answer
425 views

Recommendations on FEM software for implementing Nitsche's method on interfaces between matching meshes?

Suppose: I have two domains, $\Omega_{1} = [0, 1/2] \times [0, 1]$ and $\Omega_{2} = [1/2, 1] \times [0, 1]$. The domains share an interface $\Gamma = \{1/2\} \times [0, 1] = \partial\Omega_{1} \cap \...
3
votes
1answer
1k views

weak formulation of coupled pdes for fenics

I am trying to implement the following system of time-dependent, coupled nonlinear pdes in FEniCS: $$\partial_{t}\rho+2\left(\nabla\rho\nabla\phi+\rho\nabla^{2}\phi\right)+2\sigma\rho\left(\rho-1\...
3
votes
2answers
104 views

Quantification of non-stationarity of PDE solution

Suppose I have a time-dependent PDE discretized by the Rothe method and FEM, like $$ \int_{\Omega} k^{n+1/2}(u^{n+1}-u^{n}) v \;\mathrm{d}x = F^{n+1/2}(u^{n+1},u^n)[v] \quad \forall v\in V_h^n. $$ ...
3
votes
2answers
1k views

Subdomain Integrals in Fenics

I'd like to compute $u(y) = \int f(x,y) dx$, but don't see a really efficient way to do this in FEniCS. My first thought was to just assemble(f*v*dx) for two different meshes. (try1, below), but it ...
3
votes
1answer
460 views

Implementation of a contraction force in Fenics

Is there any way to implement an element wise contraction force (i.e., a force which causes the FEs themselves to contract onto themselves)? For example this would happen when something dehydrates. ...
3
votes
2answers
170 views

Electromagnetism FEM (FEniCS) interpolation - leakage effect

As for the background of what is going on: I'm using FEniCS that is dedicated FEM solver The problem I'm solving is magnetostatic problem where the governing PDE is $$ \bf{\nabla} \times \frac{1}{\mu}...
3
votes
0answers
125 views

Petrov-Galerkin enrichment method for Darcy equation

I was reading about Petrov-Galerkin Enrichment Method for Darcy equations. Here are a couple papers that discuss this in detail: A Petrov–Galerkin enriched method: A mass conservative finite element ...
3
votes
0answers
389 views

A Question About Weak Forms in Fenics

Is it possible to use test and trial functions from two different function spaces (defined over two different meshes) in a single weak form? Under what conditions can I do this (eg., each term in the ...
2
votes
4answers
1k views

Simple FEniCS problem shape mismatch

EDIT: THE ORIGINAL POST DID NOT MAKE MUCH SENSE, SO I ADJUSTED IT Ok, so I have thought about it, googled it and put some more thought into it. This presentation by the Imperial College in London has ...
2
votes
2answers
419 views

FEniCS: check if function is globally greater than 0

Given a Dolfin Function u on a mesh, I'd like to check if it is greater than 0 throughout the mesh. I noticed that the ...
2
votes
1answer
362 views

Mixed FEM vector indices of pressure and velocity in FEniCS

Looking at the stokes-iterative demo of FEniCS, after solving the linear system using U = Function(W) solver.solve(U.vector(), bb) the solution ...
2
votes
4answers
371 views

2d-mini element-can't use sub(0),but bubble element is ok

My program (in Python, using FEniCS): ...
2
votes
1answer
590 views

Basic Finite Element Method (FEM) question: assembly and re-assembly

I'm reading up on the Finite Element Method (Zienkiewicz's Book), so I understand better what I'm doing in FEniCS and COMSOL. Currently, I'm wondering about this: Using FEM to solve fluid flow ...
2
votes
1answer
1k views

time-dependent nonlinear pde in fenics

I am interesting in solving the following nonlinear, time-dependent pde in 2 spatial dimensions (complex Gross-Pitaevskii eq): $$i \frac{\partial \psi}{\partial t} = \left[ -\nabla^2 + (1-i \sigma)(|\...
2
votes
1answer
815 views

Fenics : Elementwise stress computation

In a elastodynamics problem, I define the stress as def sigma(v): return 2.0*mu*sym(grad(v)) + lmbda*tr(sym(grad(v)))*Identity(v.cell().d) I have computed ...
2
votes
2answers
606 views

Schrödinger equation with time dependent Hamiltonian

I need to solve the Schrödinger equation with a time dependent Hamiltonian $$i\hbar \frac{\partial}{\partial t} \Psi = \left[-\frac{\hbar^2}{2m}\nabla^2 +\frac{1}{2} k(t)(x^2+y^2) + V(r)\right]\Psi $...
2
votes
1answer
445 views

PETSc Krylov Subspace and nullspace

How is the nullspace correction implemented in the PETSc conjugate gradient solver? I searched the source code and documentation, but could not find references on the actual implementation. For ...