cashocs.geometry.mesh_testing#

Testing of mesh quality.

Classes

APrioriMeshTester(mesh)

A class for testing the mesh before it is modified.

CollisionCounter()

Class for testing, whether a given mesh is a valid FEM mesh.

IntersectionTester(mesh)

A class for testing the mesh after it has been modified.

class cashocs.geometry.mesh_testing.APrioriMeshTester(mesh)[source]#

Bases: object

A class for testing the mesh before it is modified.

Initializes the mesh tester.

Parameters:

mesh (fenics.Mesh) – The mesh that is to be tested.

test(transformation, volume_change)[source]#

Check the quality of the transformation before the actual mesh is moved.

Checks the quality of the transformation. The criterion is that

\[\det(I + D \texttt{transformation})\]

should neither be too large nor too small in order to achieve the best transformations.

Parameters:
  • transformation (fenics.Function) – The transformation for the mesh.

  • volume_change (float) – The allowed factor that each element is allowed to change in volume.

Returns:

A boolean that indicates whether the desired transformation is feasible.

Return type:

bool

class cashocs.geometry.mesh_testing.CollisionCounter[source]#

Bases: object

Class for testing, whether a given mesh is a valid FEM mesh.

Initializes self.

classmethod compute_collisions(mesh)[source]#

Computes the cells which (potentially) contain self intersections.

Parameters:

mesh (fenics.Mesh) – A FEM mesh.

Returns:

An array of cell indices, where array[i] contains the indices of all cells that vertex i collides with.

Return type:

ndarray

class cashocs.geometry.mesh_testing.IntersectionTester(mesh)[source]#

Bases: object

A class for testing the mesh after it has been modified.

Initializes the posterior mesh tester.

Parameters:

mesh (fenics.Mesh) – The mesh that is to be tested.

test()[source]#

Checks the quality of the transformation after the actual mesh is moved.

Checks whether the mesh is a valid finite element mesh after it has been moved, i.e., if there are no overlapping or self intersecting elements.

Returns:

True if the test is successful, False otherwise.

Return type:

bool

Notes

fenics itself does not check whether the used mesh is a valid finite element mesh, so this check has to be done manually.