This pull request proposes a refactor of remesh.py, and adds an example as well as a new documentation entry regarding periodic remeshing. Some other refactoring has also been conducted on other modules, mainly to account for naming convention (snake_case) changes in mesh.py. It also moves is_periodic() from test_utils.py to Mesh class.
Description
The function remesh_keeping_periodicity_for_fem() now uses either a BoxMesh or a pyvista.UnstructuredGrid or a pyvista.PolyData as input, and outputs a pyvista.UnstructuredGrid. It also now calls mmg twice: once to prepare for remeshing by adding a -nofem parameter that ensures preservation of level sets, and another for the actual remeshing job.
An example has been added which compares a periodically meshed gyroid before and after periodic remeshing.
An entry has been added to documentation under Mesh section. New images generation has been added to generates_images.py.
is_periodic() was moved to Mesh as it seems more relevant now that both mesh_periodic() and remesh_keeping_periodicity_for_fem() check for mesh periodicity (output for the former, both input and output for the latter)
Additional details
For some reason, calling mmg only once could sometimes result in some nodes being displaced outside of the initial RVE, thus breaking mesh periodicity. A first run of mmg with the -nofem parameter seems to fix the issue.
Adding periodicity checks reassures the user on actual mesh periodicity, avoiding the need of manual checks. Also, an exception is now raised if something went wrong during remeshing that leads to a non periodic output.
Testing
Tests have been updated in test_remesh.py to reflect changes in input and output. test_is_periodic.py has also been changed to remove excessive use of unnecessary fixtures.
Context
This pull request proposes a refactor of
remesh.py
, and adds an example as well as a new documentation entry regarding periodic remeshing. Some other refactoring has also been conducted on other modules, mainly to account for naming convention (snake_case) changes inmesh.py
. It also movesis_periodic()
fromtest_utils.py
toMesh
class.Description
The function
remesh_keeping_periodicity_for_fem()
now uses either aBoxMesh
or apyvista.UnstructuredGrid
or apyvista.PolyData
as input, and outputs apyvista.UnstructuredGrid
. It also now calls mmg twice: once to prepare for remeshing by adding a-nofem
parameter that ensures preservation of level sets, and another for the actual remeshing job.An example has been added which compares a periodically meshed gyroid before and after periodic remeshing.
An entry has been added to documentation under Mesh section. New images generation has been added to
generates_images.py
.is_periodic()
was moved toMesh
as it seems more relevant now that bothmesh_periodic()
andremesh_keeping_periodicity_for_fem()
check for mesh periodicity (output for the former, both input and output for the latter)Additional details
For some reason, calling mmg only once could sometimes result in some nodes being displaced outside of the initial RVE, thus breaking mesh periodicity. A first run of mmg with the
-nofem
parameter seems to fix the issue.Adding periodicity checks reassures the user on actual mesh periodicity, avoiding the need of manual checks. Also, an exception is now raised if something went wrong during remeshing that leads to a non periodic output.
Testing
Tests have been updated in
test_remesh.py
to reflect changes in input and output.test_is_periodic.py
has also been changed to remove excessive use of unnecessary fixtures.