Mmg
Simplicial remeshers (mesh adaptation, isovalue discretization, lagrangian movement)
Functions
mmg2.c File Reference
#include "mmgcommon_private.h"
#include "mmgexterns_private.h"
Include dependency graph for mmg2.c:

Go to the source code of this file.

Functions

static MMG5_int MMG5_InvMat_key (MMG5_pInvMat pim, int ref)
 
static int MMG5_InvMat_code (int k, int attr)
 
static int MMG5_InvMat_getIndex (MMG5_pInvMat pim, int ref)
 
static int MMG5_InvMat_getAttrib (MMG5_pInvMat pim, int ref)
 
static int MMG5_InvMat_check (MMG5_pInvMat pim, int key)
 
static void MMG5_InvMat_error (MMG5_pInvMat pim, int ref, int k)
 
static int MMG5_InvMat_set (MMG5_pMesh mesh, MMG5_pInvMat pim, int k)
 
static int MMG5_InvMat_getParent (MMG5_pMesh mesh, MMG5_pInvMat pim, MMG5_int ref, MMG5_int *pref)
 
int MMG5_getStartRef (MMG5_pMesh mesh, MMG5_int ref, MMG5_int *pref)
 
static void MMG5_InvMat_print (MMG5_pMesh mesh, MMG5_pInvMat pim)
 
int MMG5_MultiMat_init (MMG5_pMesh mesh)
 
int MMG5_isSplit (MMG5_pMesh mesh, MMG5_int ref, MMG5_int *refint, MMG5_int *refext)
 
int MMG5_isNotSplit (MMG5_pMesh mesh, MMG5_int ref)
 
int MMG5_isLevelSet (MMG5_pMesh mesh, MMG5_int ref0, MMG5_int ref1)
 
int MMG5_snpval_ls (MMG5_pMesh mesh, MMG5_pSol sol)
 
int MMG5_ismaniball (MMG5_pMesh mesh, MMG5_pSol sol, MMG5_int start, int8_t istart)
 
static double MMG5_voltri (MMG5_pMesh mesh, MMG5_int ip0, MMG5_int ip1, MMG5_int ip2)
 
static double MMG5_vfrac (MMG5_pMesh mesh, MMG5_pSol sol, MMG5_int k, int pm)
 
static int MMG5_isbr (MMG5_pMesh mesh, MMG5_int ref)
 
int MMG5_rmc (MMG5_pMesh mesh, MMG5_pSol sol)
 
int MMG5_resetRef_ls (MMG5_pMesh mesh)
 
int MMG5_setref_ls (MMG5_pMesh mesh, MMG5_pSol sol)
 
int MMG5_chkmaniball (MMG5_pMesh mesh, MMG5_int start, int8_t istart)
 
int MMG5_chkmanimesh (MMG5_pMesh mesh)
 

Function Documentation

◆ MMG5_chkmaniball()

int MMG5_chkmaniball ( MMG5_pMesh  mesh,
MMG5_int  start,
int8_t  istart 
)
Parameters
meshpointer toward the mesh structure.
startindex of starting tria.
istartlocal index of point that we check (in tria start)
Returns
1 if the ball is manifold, 0 otherwise.

Check whether the ball of vertex i in tria start is manifold;

Warning
inxt[i] is an edge belonging to the implicit boundary.

Step 1: Travel while another part of the implicit boundary is not met

Normal or multi-material mode: check for change in triangle references

Input reference preservation mode (mmgs –keep-ref option): Check if we cross an isoref edge

Step 2: Check why the loop has ended

a./ Case where a boundary is hit: travel in the other sense from start, and make sure that a boundary is hit too

Ball is manifold if tested point is connected to two external edges

b./ General case: go on travelling until another implicit boundary is met

Ball is non-manifold if at least 3 boundary segments meeting at p

Definition at line 1303 of file mmg2.c.

Here is the caller graph for this function:

◆ MMG5_chkmanimesh()

int MMG5_chkmanimesh ( MMG5_pMesh  mesh)
Parameters
meshpointer toward the mesh.
Returns
1 if the mesh is manifold, 0 otherwise.

Check whether the resulting two subdomains occupying mesh are manifold.

First check: check whether one triangle in the mesh has 3 boundary faces

Second check: check whether the configuration is manifold in the ball of each point; each vertex on the implicit boundary is caught in such a way that i1 inxt[i1] is one edge of the implicit boundary

Definition at line 1423 of file mmg2.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MMG5_getStartRef()

int MMG5_getStartRef ( MMG5_pMesh  mesh,
MMG5_int  ref,
MMG5_int *  pref 
)
Parameters
meshpointer toward the mesh
reffinal reference for which we are searching the initial one
prefpointer to the reference of the parent material.
Returns
1 if found, 0 otherwise.

Retrieve the starting domain reference (parent material) associated to the split reference ref. Allow the call in non-multimaterial mode.

Definition at line 213 of file mmg2.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MMG5_InvMat_check()

static int MMG5_InvMat_check ( MMG5_pInvMat  pim,
int  key 
)
static
Parameters
pimmultimaterials inverse data table.
keymaterial key in the inverse data table.
Returns
0 if an entry for the material already exists, 1 otherwise.

Check if a material reference already exists in the material lookup table.

Definition at line 98 of file mmg2.c.

Here is the caller graph for this function:

◆ MMG5_InvMat_code()

static int MMG5_InvMat_code ( int  k,
int  attr 
)
static
Parameters
kindex of the material.
attrthe attribute of the material (nosplit/split/plus/minus).
Returns
the code to be stored in the inverse data table entry.

Compute the material entry in the inverse data table, storing the index of the parent material and the attribute of the child material.

Definition at line 58 of file mmg2.c.

Here is the caller graph for this function:

◆ MMG5_InvMat_error()

static void MMG5_InvMat_error ( MMG5_pInvMat  pim,
int  ref,
int  k 
)
static
Parameters
pimmultimaterials inverse data table.
refreference of the material..
kindex of the material in the direct table.
Returns
0 if an entry for the material already exists, 1 otherwise.

Raise an error if trying to overwrite a reference entry in the material lookup table.

Definition at line 111 of file mmg2.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MMG5_InvMat_getAttrib()

static int MMG5_InvMat_getAttrib ( MMG5_pInvMat  pim,
int  ref 
)
static
Parameters
meshpointer toward the mesh structure.
pimmultimaterials inverse data table.
refmaterial reference.
Returns
the nosplit/split/plus/minus attribute of the material.

Get attribute of the child material (nosplit/split/plus/minus) from lookup table.

Definition at line 84 of file mmg2.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MMG5_InvMat_getIndex()

static int MMG5_InvMat_getIndex ( MMG5_pInvMat  pim,
int  ref 
)
static
Parameters
pimmultimaterials inverse data table.
refmaterial reference.
Returns
Index of the material.

Get index of the parent material from lookup table.

Definition at line 69 of file mmg2.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MMG5_InvMat_getParent()

static int MMG5_InvMat_getParent ( MMG5_pMesh  mesh,
MMG5_pInvMat  pim,
MMG5_int  ref,
MMG5_int *  pref 
)
static
Parameters
meshpointer toward the mesh structure.
pimmultimaterials inverse data table.
refmaterial reference.
prefpointer to the parent material reference.
Returns
1 if found, 0 if not found.

Get reference of the parent material in multimaterial mode.

Definition at line 177 of file mmg2.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MMG5_InvMat_key()

static MMG5_int MMG5_InvMat_key ( MMG5_pInvMat  pim,
int  ref 
)
static
Parameters
pimmultimaterials inverse data table.
refmaterial reference.
Returns
the key of the material in the lookup/hash table.

Compute key for the material in the hash table.

Definition at line 46 of file mmg2.c.

Here is the caller graph for this function:

◆ MMG5_InvMat_print()

static void MMG5_InvMat_print ( MMG5_pMesh  mesh,
MMG5_pInvMat  pim 
)
static
Parameters
meshpointer toward the mesh structure.
pimmultimaterials inverse data table.

Print materials lookup table.

Definition at line 238 of file mmg2.c.

Here is the call graph for this function:

◆ MMG5_InvMat_set()

static int MMG5_InvMat_set ( MMG5_pMesh  mesh,
MMG5_pInvMat  pim,
int  k 
)
static
Parameters
meshpointer toward the mesh structure.
pimmultimaterials inverse data table.
kindex of the material in the input table.

Set materials lookup table entry.

Store the dosplit attribute of the parent material

Store the child material sign with the parent material index (in the lookup table). 1) 0 is a legit material index, so store the parent as 4*(k+1). 2) If a child material has the same reference as the parent, this effectively overwrites the result of the previous instruction. 3) No different child materials are allowed to have the same reference, and this must have already been checked.

Definition at line 129 of file mmg2.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MMG5_isbr()

static int MMG5_isbr ( MMG5_pMesh  mesh,
MMG5_int  ref 
)
inlinestatic

Return 1 if reference ref is in the base reference table, 0 otherwise

Definition at line 892 of file mmg2.c.

Here is the caller graph for this function:

◆ MMG5_isLevelSet()

int MMG5_isLevelSet ( MMG5_pMesh  mesh,
MMG5_int  ref0,
MMG5_int  ref1 
)
Parameters
meshpointer toward the mesh structure.
ref0reference of the first tetrahedron sharing the face.
ref1reference of the second tetrahedron sharing the face..
Returns
1 if face is on the discrete level set, 0 if not.

Identify whether a face is on the discrete level set or not.

Definition at line 471 of file mmg2.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MMG5_ismaniball()

int MMG5_ismaniball ( MMG5_pMesh  mesh,
MMG5_pSol  sol,
MMG5_int  start,
int8_t  istart 
)
Parameters
meshpointer toward the mesh structure.
solpointer toward the level-set values.
startindex of the starting tria
istartlocal index (inside the tria start) of the vertex that we check.
Returns
1 if success, 0 if fail

Check whether snapping the value of vertex istart of start to 0 exactly leads to a non manifold situation.

Warning
: we assume that the triangle start has vertex istart with value 0 and the other two with changing values.

Definition at line 622 of file mmg2.c.

Here is the caller graph for this function:

◆ MMG5_isNotSplit()

int MMG5_isNotSplit ( MMG5_pMesh  mesh,
MMG5_int  ref 
)
Parameters
meshpointer toward the mesh structure.
refinitial reference.
Returns
1 if entity cannot be split, 0 if can be split.

Identify whether an entity with reference ref should not be split.

Definition at line 447 of file mmg2.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MMG5_isSplit()

int MMG5_isSplit ( MMG5_pMesh  mesh,
MMG5_int  ref,
MMG5_int *  refint,
MMG5_int *  refext 
)
Parameters
meshpointer toward the mesh structure.
refinitial reference.
refintinternal reference after ls discretization.
refextexternal reference after ls discretization.
Returns
1 if entity can be splitted, 0 if cannot be splitted.

Identify whether an entity with reference ref should be split, and the labels of the resulting entities.

Definition at line 411 of file mmg2.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MMG5_MultiMat_init()

int MMG5_MultiMat_init ( MMG5_pMesh  mesh)
Parameters
meshpointer toward the mesh structure.
Returns
1 if success, 0 if fail.

Initialize handling of multimaterial mode.

An indexed table of materials has been provided by the MMG5_Mat datatype in the form:

index | dospl | ref | rin | rex

0 | dospl_0 | ref_0 | rin_0 | rex_0 ... | ... | ... | ... | k | dospl_k | ref_k | rin_k | rex_k ... | ... | ... | ... | n-1 | dospl_{n-1} | ref_{n-1} | rin_{n-1} | rex_{n-1}

where dospl is the split/preserve attribute of the material, and rin,rex are its child materials (if dospl). Viceversa, ref is the parent material for rin,rex.

Here a lookup table for material references is built through trivial hashing for all references (both parent and child materials) with the key:

key = ref - ref_min, ref_min = min_{k = 0,n-1} (ref_k, rin_k, rex_k)

For all references, it is important to store

  • the index k of the row in the original table,
  • the characteristic attribute (parent-split, parent-preserve, child-interior, child-exterior) of the material.

Since dospl = 0 or 1, MG_PLUS = 2, and MG_MINUS = 3

we can store the attribute as dospl (for the parent material) or MG_MINUS/ MG_PLUS (for the child materials), with its value ranging between 0 and 3.

A convenient entry to store both the index and the attribute in the lookup table is thus:

entry = 4*(index+1) + attribute

leading to a lookup table in the form (the key ordering is only an example):

key | entry

... | ... ref_k | 4*(k+1)+dospl_k ... | ... rin_k | 4*(k+1)+MG_MINUS ... | ... rex_k | 4*(k+1)+MG_PLUS ... | ...

where the index and the attribute of the material can be retrieved as

index = entry / 4 -1 attribute = entry % 4

What if two materials have the same reference?

  • child references should be distinct (the entry in the lookup table would be overwritten),
  • a parent material can have itself as child (a positive attribute would say it should be split, the attribute value would say if it is interior or exterior). Thus, each of the maps parent->child_in and parent->child_ext is injective, but a fixed point is allowed.

Why child materials should be different?

  • because on failure it is necessary to recover the parent references and apply them on the tetrahedra to restore the starting materials distribution.

Definition at line 326 of file mmg2.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MMG5_resetRef_ls()

int MMG5_resetRef_ls ( MMG5_pMesh  mesh)
Parameters
meshpointer toward the mesh

Reset mesh->info.isoref vertex and edge references to 0.

Definition at line 1188 of file mmg2.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MMG5_rmc()

int MMG5_rmc ( MMG5_pMesh  mesh,
MMG5_pSol  sol 
)
Parameters
meshpointer toward the mesh
solpointer toward the level-set
Returns
1 if success, 0 otherwise

Removal of small parasitic components (bubbles of material, etc) with volume less than mesh->info.rmc * volume of the mesh.

Definition at line 911 of file mmg2.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MMG5_setref_ls()

int MMG5_setref_ls ( MMG5_pMesh  mesh,
MMG5_pSol  sol 
)
Parameters
meshpointer toward the mesh structure.
solpointer toward the level-set values.
Returns
1.

Set references to tris according to the sign of the level set function.

Definition at line 1224 of file mmg2.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MMG5_snpval_ls()

int MMG5_snpval_ls ( MMG5_pMesh  mesh,
MMG5_pSol  sol 
)
Parameters
meshpointer toward the mesh structure.
solpointer toward the level-set function.
Returns
1 if success, 0 if fail.

Snap values of the level set function very close to 0 to exactly 0, and prevent nonmanifold patterns from being generated.

Definition at line 502 of file mmg2.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MMG5_vfrac()

static double MMG5_vfrac ( MMG5_pMesh  mesh,
MMG5_pSol  sol,
MMG5_int  k,
int  pm 
)
inlinestatic
Parameters
meshpointer toward the mesh structure
solpointer toward the ls function
kindex of the triangle
pm1 for computation of positive subdomain, -1 for negative one
Returns
volfrac

Calculate the area of the positive (if pm == 1) or negative (if pm == -1) subdomain inside triangle k defined by the ls function in sol

Definition at line 774 of file mmg2.c.

Here is the caller graph for this function:

◆ MMG5_voltri()

static double MMG5_voltri ( MMG5_pMesh  mesh,
MMG5_int  ip0,
MMG5_int  ip1,
MMG5_int  ip2 
)
inlinestatic
Parameters
meshpointer toward the mesh structure.
ip0First vertex of the triangle
ip1Second vertex of the triangle
ip2Third vertex of the triangle
Returns
area of the triangle

Calculate the area of a triangle given by its vertices

Definition at line 747 of file mmg2.c.

Here is the caller graph for this function: