implementations.problem_classes.VorticityVelocity_2D_FEniCS_periodic module

class fenics_vortex_2d(c_nvars=None, family='CG', order=4, refinements=None, nu=0.01, rho=50, delta=0.05)[source]

Bases: ptype

This class implements the vorticity-velocity problem in two dimensions with periodic boundary conditions in \([0, 1]^2\)

\[\frac{\partial w}{\partial t} = \nu \Delta w\]

for some parameter \(\nu\). In this class the problem is implemented that the spatial part is solved using FEniCS [1]_. Hence, the problem is reformulated to the weak formulation

\[\int_\Omega w_t v\,dx = - \nu \int_\Omega \nabla w \nabla v\,dx\]

This problem class treats the PDE in an IMEX way, with diffusion being the implicit part and everything else the explicit one. The mass matrix needs inversion for this type of problem class, see the derived one for the mass-matrix version without inversion.

Parameters:
  • c_nvars (List of int tuple, optional) – Spatial resolution, i.e., numbers of degrees of freedom in space, e.g. c_nvars=[(128, 128)].

  • family (str, optional) – Indicates the family of elements used to create the function space for the trail and test functions. The default is 'CG', which are the class of Continuous Galerkin, a synonym for the Lagrange family of elements, see [2]_.

  • order (int, optional) – Defines the order of the elements in the function space.

  • refinements (int, optional) – Denotes the refinement of the mesh. refinements=2 refines the mesh by factor \(2\).

  • nu (float, optional) – Diffusion coefficient \(\nu\).

  • rho (int, optional) – Problem parameter.

  • delta (float, optional) – Problem parameter.

V

Defines the function space of the trial and test functions.

Type:

FunctionSpace

M

Mass matrix for FENiCS.

Type:

scalar, vector, matrix or higher rank tensor

K

Stiffness matrix including diffusion coefficient (and correct sign).

Type:

scalar, vector, matrix or higher rank tensor

References

apply_mass_matrix(u)[source]

Routine to apply mass matrix.

Parameters u : dtype_u

Current values of the numerical solution.

Returns:

me – The product :math:` Mvec{u}`.

Return type:

dtype_u

dtype_f

alias of rhs_fenics_mesh

dtype_u

alias of fenics_mesh

eval_f(u, t)[source]

Routine to evaluate both parts of the right-hand side.

Parameters:
  • u (dtype_u) – Current values of the numerical solution.

  • t (float) – Current time at which the numerical solution is computed.

Returns:

f – The right-hand side divided into two parts.

Return type:

dtype_f

solve_system(rhs, factor, u0, t)[source]

Dolfin’s linear solver for \((M - factor \cdot A)\vec{u} = \vec{rhs}\).

Parameters:
  • rhs (dtype_f) – Right-hand side for the nonlinear system.

  • factor (float) – Abbrev. for the node-to-node stepsize (or any other factor required).

  • u0 (dtype_u) – Initial guess for the iterative solver (not used here so far).

  • t (float) – Current time.

Returns:

u – The solution as mesh.

Return type:

dtype_u

u_exact(t)[source]

Routine to compute the exact solution at time \(t\).

Parameters:

t (float) – Time of the exact solution.

Returns:

me – The exact solution.

Return type:

dtype_u

class fenics_vortex_2d_mass(c_nvars=None, family='CG', order=4, refinements=None, nu=0.01, rho=50, delta=0.05)[source]

Bases: fenics_vortex_2d

This class implements the vorticity-velocity problem in two dimensions with periodic boundary conditions in \([0, 1]^2\)

\[\frac{\partial w}{\partial t} = \nu \Delta w\]

for some parameter \(\nu\). In this class the problem is implemented that the spatial part is solved using FEniCS [1]_. Hence, the problem is reformulated to the weak formulation

\[\int_\Omega w_t v\,dx = - \nu \int_\Omega \nabla w \nabla v\,dx\]

This problem class treats the PDE in an IMEX way, with diffusion being the implicit part and everything else the explicit one. No mass matrix inversion is needed here, i.e. using this problem class requires the imex_1st_order_mass sweeper.

Parameters:
  • c_nvars (List of int tuple, optional) – Spatial resolution, i.e., numbers of degrees of freedom in space, e.g. c_nvars=[(128, 128)].

  • family (str, optional) – Indicates the family of elements used to create the function space for the trail and test functions. The default is 'CG', which are the class of Continuous Galerkin, a synonym for the Lagrange family of elements, see [2]_.

  • order (int, optional) – Defines the order of the elements in the function space.

  • refinements (int, optional) – Denotes the refinement of the mesh. refinements=2 refines the mesh by factor \(2\).

  • nu (float, optional) – Diffusion coefficient \(\nu\).

  • rho (int, optional) – Problem parameter.

  • delta (float, optional) – Problem parameter.

V

Defines the function space of the trial and test functions.

Type:

FunctionSpace

M

Mass matrix for FENiCS.

Type:

scalar, vector, matrix or higher rank tensor

K

Stiffness matrix including diffusion coefficient (and correct sign).

Type:

scalar, vector, matrix or higher rank tensor

References

eval_f(u, t)[source]

Routine to evaluate both parts of the right-hand side.

Note: Need to add this here, because otherwise the parent class will call the “local” functions __eval_* and not the ones of the child class.

Parameters:
  • u (dtype_u) – Current values of the numerical solution.

  • t (float) – Current time at which the numerical solution is computed.

Returns:

f – The right-hand side divided into two parts.

Return type:

dtype_f

solve_system(rhs, factor, u0, t)[source]

Dolfin’s linear solver for \((M - factor \cdot A)\vec{u} = \vec{rhs}\).

Parameters:
  • rhs (dtype_f) – Right-hand side for the nonlinear system.

  • factor (float) – Abbrev. for the node-to-node stepsize (or any other factor required).

  • u0 (dtype_u) – Initial guess for the iterative solver (not used here so far).

  • t (float) – Current time.

Returns:

u – The solution as mesh.

Return type:

dtype_u