pyoomph.meshes package
Submodules
- pyoomph.meshes.PFEM module
- pyoomph.meshes.bcs module
- pyoomph.meshes.curved_entities module
- pyoomph.meshes.droplet_meshes module
- pyoomph.meshes.gmsh module
GmshTemplateGmshTemplate.GmshFakeEntryGmshTemplate.circle_arc()GmshTemplate.create_lines()GmshTemplate.default_resolutionGmshTemplate.define_geometry()GmshTemplate.extrude()GmshTemplate.extrude_generated_meshGmshTemplate.line()GmshTemplate.mesh_modeGmshTemplate.mesh_size_factorGmshTemplate.mirror_meshGmshTemplate.orderGmshTemplate.plane_surface()GmshTemplate.point()GmshTemplate.spline()GmshTemplate.use_macro_elements
- pyoomph.meshes.interpolator module
- pyoomph.meshes.mesh module
MeshTemplateMeshTemplate.add_facet_to_curve_entity()MeshTemplate.add_node()MeshTemplate.add_node_unique()MeshTemplate.add_nodes_to_boundary()MeshTemplate.add_periodic_node_pair()MeshTemplate.available_domains()MeshTemplate.create_curved_entity()MeshTemplate.define_geometry()MeshTemplate.get_domain()MeshTemplate.get_node_position()MeshTemplate.has_domain()MeshTemplate.max_permitted_errorMeshTemplate.max_refinement_levelMeshTemplate.min_permitted_errorMeshTemplate.min_refinement_levelMeshTemplate.new_bulk_element_collection()MeshTemplate.new_domain()MeshTemplate.nondim_size()MeshTemplate.remesher
ODEStorageMeshODEStorageMesh.activate_duarte_debug()ODEStorageMesh.adapt_by_elemental_errors()ODEStorageMesh.add_boundary_node()ODEStorageMesh.add_interpolated_nodes_at()ODEStorageMesh.add_node_to_mesh()ODEStorageMesh.as_pyoomph_mesh()ODEStorageMesh.boundary_coordinate_bool()ODEStorageMesh.boundary_element_pt()ODEStorageMesh.boundary_node_pt()ODEStorageMesh.check_integrity()ODEStorageMesh.describe_global_dofs()ODEStorageMesh.describe_my_dofs()ODEStorageMesh.element_pt()ODEStorageMesh.ensure_external_data()ODEStorageMesh.ensure_halos_for_periodic_boundaries()ODEStorageMesh.evaluate_local_expression_at_nodes()ODEStorageMesh.face_index_at_boundary()ODEStorageMesh.fill_dof_types()ODEStorageMesh.fill_node_index_to_node_map()ODEStorageMesh.flush_element_storage()ODEStorageMesh.generate_interface_elements()ODEStorageMesh.get_boundary_index()ODEStorageMesh.get_boundary_names()ODEStorageMesh.get_element_dimension()ODEStorageMesh.get_elemental_errors()ODEStorageMesh.get_field_information()ODEStorageMesh.get_node_reordering()ODEStorageMesh.get_output_scale()ODEStorageMesh.get_refinement_pattern()ODEStorageMesh.get_value()ODEStorageMesh.get_values_at_zetas()ODEStorageMesh.has_interface_dof_id()ODEStorageMesh.invalidate_lagrangian_kdtree()ODEStorageMesh.is_boundary_coordinate_defined()ODEStorageMesh.is_mesh_distributed()ODEStorageMesh.list_integral_functions()ODEStorageMesh.list_local_expressions()ODEStorageMesh.nboundary()ODEStorageMesh.nboundary_element()ODEStorageMesh.nboundary_node()ODEStorageMesh.nelement()ODEStorageMesh.nnode()ODEStorageMesh.nodal_interpolate_along_boundary()ODEStorageMesh.nodal_interpolate_from()ODEStorageMesh.node_pt()ODEStorageMesh.nrefined()ODEStorageMesh.nunrefined()ODEStorageMesh.output_paraview()ODEStorageMesh.prepare_interpolation()ODEStorageMesh.prepare_zeta_interpolation()ODEStorageMesh.prune_dead_nodes()ODEStorageMesh.refine_base_mesh()ODEStorageMesh.remove_boundary_nodes()ODEStorageMesh.remove_boundary_nodes_of_bound()ODEStorageMesh.reorder_nodes()ODEStorageMesh.resolve_copy_master_node()ODEStorageMesh.set_initial_condition()ODEStorageMesh.set_lagrangian_nodal_coordinates()ODEStorageMesh.set_output_scale()ODEStorageMesh.set_spatial_error_estimator_pt()ODEStorageMesh.set_value()ODEStorageMesh.setup_Dirichlet_conditions()ODEStorageMesh.setup_initial_conditions()ODEStorageMesh.setup_interior_boundary_elements()ODEStorageMesh.to_numpy()
- pyoomph.meshes.meshdatacache module
- pyoomph.meshes.remesher module
- pyoomph.meshes.simplemeshes module
- pyoomph.meshes.zeta module
Module contents
- class pyoomph.meshes.AxisymmetryBC(verbose=True, recurse=True)[source]
Bases:
InterfaceEquationsAdd 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 viadefine_scalar_field()ordefine_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.DirichletBC(*, prefer_weak_for_DG=True, **kwargs)[source]
Bases:
BaseEquationsClass 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.EnforcedBC(*, only_for_stationary_solve=False, set_zero_on_normal_mode_eigensolve=False, **constraints)[source]
Bases:
InterfaceEquationsEnforce 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.EnforcedDirichlet(*, only_for_stationary_solve=False, set_zero_on_normal_mode_eigensolve=False, **constraints)[source]
Bases:
EnforcedBCEnforces 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.InactiveDirichletBC(**kwargs)[source]
Bases:
DirichletBCSame 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.InteriorBoundaryOrientation(indicator)[source]
Bases:
InterfaceEquationsNamed 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. addInteriorBoundaryOrientation(dot(var("coordinate"),var("normal)))@"circle"to only add interface elements with an outward pointing normal.- Parameters:
InterfaceEquations (_type_) – _description_
- class pyoomph.meshes.LineMesh(N=10, size=1.0, minimum=0.0, name='domain', left_name='left', right_name='right', nodal_dimension=None, periodic=False)[source]
Bases:
MeshTemplateA class representing a line mesh.
- Parameters:
N (
int) – The number of elements in the mesh.size (
Union[Expression,int,float]) – The size of the mesh, i.e. the length of the line.minimum (
Union[Expression,int,float]) – The position of the left boundary, i.e. the line ranges fromminimumtominimum + size.name (
Union[str,Callable[[float],str]]) – The name of the domain or a function that returns the name based on the center of each element. This allows to create multiple domains in the same mesh, where the interfaces in between are automatically created and named based on the domain names separated with an underscore.left_name (
str) – The name of the left boundary.right_name (
str) – The name of the right boundary.nodal_dimension (
Optional[int]) – The nodal dimension of the mesh, can be used to curve the mesh later on.periodic (
bool) – Whether the mesh is periodic.
- class pyoomph.meshes.MeshTemplate[source]
Bases:
MeshTemplateA class to construct meshes by defining nodes with the
add_node()oradd_node_unique()method. Elements must be specified by first creating one or multiple domains with thenew_domain()method and adding elements on each domain. Nodes can be also marked to be on particular boundaries with theadd_node_on_boundary()method.- available_domains()[source]
Returns a list of all available domains constructed with
new_domain().- Return type:
Set[str]
- create_curved_entity(typ, *args, **kwargs)[source]
Creates a curved entity on the mesh. Currently only the type
"circle_arc"is supported, which requires the start and end point as positional arguments and either thecenterorthrough_pointas keyword argument.- Parameters:
- Return type:
- Returns:
The created curved entity to be used in
add_facet_to_curve_entity().
- define_geometry()[source]
This method must be specialized in a derived class to define the geometry, i.e. the nodes, domains and elements of the mesh.
- Return type:
None
- get_domain(name)[source]
Get a domain by name constructed with the method
new_domain()before.- Return type:
- has_domain(name)[source]
Test if a domain with the given name is available, i.e. constructed with
new_domain()before.- Return type:
bool
- max_permitted_error
The maximum permitted error for the spatial error estimator. If
None, we use the value from theProblemobject.
- max_refinement_level
The maximum refinement level for spatial adaptivity. If
None, we use the value from theProblemobject.
- min_permitted_error
The minimum permitted error for the spatial error estimator. If
None, we use the value from theProblemobject.
- min_refinement_level
The minimum refinement level for spatial adaptivity. If
None, we use the value from theProblemobject.
- new_domain(name, nodal_dimension=None)[source]
Create a new domain with the given name. With the help of this domain, elements can be added to the mesh.
- Return type:
- nondim_size(a)[source]
Nondimensionalize a coordinate or a length scale by dividing by the spatial scale of the problem.
- Parameters:
a (
Union[Expression,int,float,List[Union[Expression,int,float]]]) – The coordinate or length scale to nondimensionalize.- Return type:
Union[float,List[float]]- Returns:
The arguments divided by the spatial scale of the problem.
-
remesher:
Optional[RemesherBase] Must be set to allow for remeshing.
- class pyoomph.meshes.NeumannBC(**fluxes)[source]
Bases:
InterfaceEquationsClass 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.PeriodicBC(other_interface, offset=None)[source]
Bases:
InterfaceEquationsIntroduces 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]]
- class pyoomph.meshes.RectangularQuadMesh(*, name='domain', size=1.0, N=10, lower_left=[0, 0], periodic=False, split_in_tris=False, split_scott_vogelius=False, boundary_names={}, nodal_dimension=None)[source]
Bases:
MeshTemplateA class representing a rectangular mesh consisting of quadrilateral elements by default.
- Parameters:
name (
Union[str,Callable[[float,float],str]]) – The name of the domain or a function that returns the name based on the center coordinates of each element. The interfaces in between are automatically generated and named based on the domain names separated with an underscore.size (
Union[Expression,int,float,List[Union[Expression,int,float]]]) – The size of the mesh, either by a single value (for both directions) or by two values (for x and y directions).N (
Union[int,List[int]]) – The number of elements in each dimension.. Can be a single value or a list of two values for x and y dimensions respectively.lower_left (
Union[Expression,int,float,List[Union[Expression,int,float]]]) – The coordinates of the lower-left corner of the mesh, i.e. the mesh ranges fromlower_left[0]tolower_left[0] + size[0]in x-direction andlower_left[1]tolower_left[1] + size[1]]in y-direction.periodic (
Union[bool,List[bool]]) – Whether the mesh is periodic, either in both directions or in x and y directions separately.split_in_tris (
Literal[False,'alternate_left','alternate_right','left','right','crossed']) – Split the quadrilateral elements into triangles.split_scott_vogelius (
bool) – Whether to use splitting into Scott-Vogelius elements.boundary_names (
Dict[str,Union[str,Callable[[float],str]]]) – A dictionary mapping boundary names"left","right","top","bottom"to their corresponding names. Alternatively a function, which also takes the center coordinates of each element as input, can be used to define the boundary names.nodal_dimension (
Optional[int]) – The nodal dimension of the mesh, can be used to curve the mesh later on.