pyoomph.meshes.bcs module

class pyoomph.meshes.bcs.AxisymmetryBC(verbose=True, recurse=True)[source]

Bases: InterfaceEquations

Add this to the axis of symmetry to automatically enforce the boundary condition required by symmetry. Also automatically sets the correct boundary conditions for azimuthal eigenvalue problems.

For normal solving, it sets radial (and azimuthal) components of vector fields (also mesh_x) to zero. For azimuthal eigenvalue problems, it depends on the azimuthal mode m:

\(m=0\): As for normal solving. \(|m|=1\): scalar fields and axial vector components are set to zero, radial and azimuthal components are not. \(|m|\geq 2\): scalar fields and all vector components are set to zero

If you write an equation, where you want to change this behavior, you can manually change the conditions by obtaining the (writeable) field information via get_azimuthal_r0_info() after the definition via define_scalar_field() or define_vector_field().

Notes

Must be also added to intersections of other boundaries with the axis of symmetry, when the other boundaries define additional fields, e.g.

bulk=NavierStokesEquations(…) bulk+=AxisymmetryBC()@”axis” bulk+=NavierStokesFreeSurface()@”interface” bulk+=AxisymmetryBC()@”interface/axis” # This is important, since the free surface introduces new fields at the interface

This is, however, done automatically if the recurse flag is set to True.

class pyoomph.meshes.bcs.DirichletBC(*, prefer_weak_for_DG=True, **kwargs)[source]

Bases: BaseEquations

Class to impose one or more Dirichlet boundary condition.

Parameters:
  • prefer_weak_for_DG (bool, optional) – Flag indicating whether to prefer weak contributions for Discontinuous Galerkin (DG) methods. If set and the bulk equations provide a specific implementation of get_weak_dirichlet_terms_for_DG, these terms are used to enforce the condition in a weak sense. Otherwise, just stronly. Defaults to True.

  • **kwargs (ExpressionOrNum) – Keyword arguments representing the Dirichlet conditions, where the keys are the variable names and the values are the corresponding expressions or numbers. Expressions for strong DirichletBCs may not depend on unknowns.

class pyoomph.meshes.bcs.EnforcedBC(*, only_for_stationary_solve=False, set_zero_on_normal_mode_eigensolve=False, **constraints)[source]

Bases: InterfaceEquations

Enforce rather arbitrary boundary conditions by a field of Lagrange multipliers. As an example,

EnforcedBC(u=var(“u”)-var(“v”)) @ “boundary”

will set u=v on the boundary by adjusting u. The rhs must be a constraint in residual formulation, here u-v=0.

Parameters:
  • only_for_stationary_solve (bool, optional) – Flag indicating if the enforced boundary conditions should only be applied during stationary solves. Defaults to False.

  • set_zero_on_normal_mode_eigensolve (bool, optional) – Flag indicating if the enforced boundary conditions should be set to zero during azimuthal eigensolves. Defaults to False.

  • **constraints (Expression) – Keyword arguments representing the enforced boundary conditions as pair of variable name to adjust and constraint expression to fulfill in residual form.

class pyoomph.meshes.bcs.EnforcedDirichlet(*, only_for_stationary_solve=False, set_zero_on_normal_mode_eigensolve=False, **constraints)[source]

Bases: EnforcedBC

Enforces a DirichletBC by Lagrange multipliers. As an example,

EnforcedDirichlet(u=var("v")) @ "boundary"

will just be the same as EnforcedBC (u=var("u")-var("v")) @ "boundary"

Parameters:
  • only_for_stationary_solve (bool, optional) – Flag indicating if the enforced boundary conditions should only be applied during stationary solves. Defaults to False.

  • set_zero_on_normal_mode_eigensolve (bool, optional) – Flag indicating if the enforced boundary conditions should be set to zero during azimuthal eigensolves. Defaults to False.

  • **constraints (Expression) – Keyword arguments representing the enforced boundary conditions as pair of variable name to adjust and constraint expression to fulfill in residual form.

class pyoomph.meshes.bcs.InactiveDirichletBC(**kwargs)[source]

Bases: DirichletBC

Same as ‘DirichletBC’, but it starts deactivated, i.e. the Neumann term will be active by default.

To activate the Dirichlet condition, you must call the set_dirichlet_active(…) method of the Mesh class, which you can obtain by problem.get_mesh(…). Afterwards, it is important to call Problem.reapply_boundary_conditions(), e.g.

problem.get_mesh(“domain/interface”).set_dirichlet_active(u=True) # activate the BC problem.reapply_boundary_conditions() # Renumber the equations and apply BCs problem.solve() # solve with active DirichletBC

class pyoomph.meshes.bcs.InteriorBoundaryOrientation(indicator)[source]

Bases: InterfaceEquations

Named interior boundaries within a domain are by default double-layered, i.e. interface elements are added from both sides. This can usually cause problems. In order to avoid this, we have to specify the orientation of the boundary, i.e. only interface elements are added from one side, namely where the indicator function is positive. For a unit circle "circle" embedded in a domain, you could e.g. add InteriorBoundaryOrientation(dot(var("coordinate"),var("normal)))@"circle" to only add interface elements with an outward pointing normal.

Parameters:

InterfaceEquations (_type_) – _description_

class pyoomph.meshes.bcs.NeumannBC(**fluxes)[source]

Bases: InterfaceEquations

Class to impose Neumann boundary condition. The particular meaning of the Neumann flux depends on the bulk equations, i.e. how the integration by parts was performed for the weak formulation of the bulk equations. For a Poisson equation implemented by the residual weak(grad(u),grad(utest)), the Neumann condition

NeumannBC(u=1) @ "boundary"

does not neither mean setting u=1, but rather dot(grad(u),var(“normal”))=-1, where normal vector is pointing outward the domain at the boundary.

Parameters:

**fluxes (Union[Expression, int, float]) – Dictionary of fluxes, where the keys are the names of the fluxes and the values are expressions or numbers.

class pyoomph.meshes.bcs.PeriodicBC(other_interface, offset=None)[source]

Bases: InterfaceEquations

Introduces a periodic boundary condition between two interfaces. It will hold for all continuous fields! The mesh must be generated that way that for each node on this interface, there is a corresponding node on the other interface when adding offset to the position.

other_interface

The name of the other interface to which this boundary is periodic.

Type:

str

offset

The offset to find the corresponding nodes on the other interface.

Type:

Optional[List[ExpressionOrNum]]