mFES - molecular Finite Element Solver  0.4
Classes | Defines | Typedefs | Enumerations | Functions
nglib.h File Reference

Library interface to the netgen meshing kernel. More...

Go to the source code of this file.

Classes

class  Ng_Meshing_Parameters
 Netgen Meshing Parameters class. More...

Defines

#define DLL_HEADER
#define NG_VOLUME_ELEMENT_MAXPOINTS   10
#define NG_SURFACE_ELEMENT_MAXPOINTS   8
#define DLL_HEADER
#define NG_VOLUME_ELEMENT_MAXPOINTS   10
 Maximum allowed number of nodes per volume element.
#define NG_SURFACE_ELEMENT_MAXPOINTS   8
 Maximum allowed number of nodes per surface element.

Typedefs

typedef void * Ng_Mesh
 Data type for NETGEN mesh.
typedef void * Ng_CSG_Geometry
 Data type for NETGEN CSG geometry.
typedef void * Ng_Geometry_2D
 Data type for NETGEN 2D geometry.
typedef void * Ng_STL_Geometry
 Data type for NETGEN STL geometry.

Enumerations

enum  Ng_Surface_Element_Type {
  NG_TRIG = 1, NG_QUAD = 2, NG_TRIG6 = 3, NG_QUAD6 = 4,
  NG_QUAD8 = 5
}
 Currently implemented surface element types. More...
enum  Ng_Volume_Element_Type { NG_TET = 1, NG_PYRAMID = 2, NG_PRISM = 3, NG_TET10 = 4 }
 Currently implemented volume element types. More...
enum  Ng_Result {
  NG_ERROR = -1, NG_OK = 0, NG_SURFACE_INPUT_ERROR = 1, NG_VOLUME_FAILURE = 2,
  NG_STL_INPUT_ERROR = 3, NG_SURFACE_FAILURE = 4, NG_FILE_NOT_FOUND = 5
}
 Values returned by Netgen functions. More...

Functions

DLL_HEADER void Ng_Init ()
 Initialise the Netgen library and prepare for use.
DLL_HEADER void Ng_Exit ()
 Exit the Netgen meshing kernel in a clean manner.
DLL_HEADER Ng_MeshNg_NewMesh ()
 Create a new (and empty) Netgen Mesh Structure.
DLL_HEADER void Ng_DeleteMesh (Ng_Mesh *mesh)
 Delete an existing Netgen Mesh Structure.
DLL_HEADER void Ng_SaveMesh (Ng_Mesh *mesh, const char *filename)
 Save a Netgen Mesh to disk.
DLL_HEADER Ng_MeshNg_LoadMesh (const char *filename)
 Load a Netgen VOL Mesh from disk into memory.
DLL_HEADER Ng_MeshNg_SetProperties (Ng_Mesh *m, int surfnr, int bcnr, int domin, int domout)
 Set element options.
DLL_HEADER Ng_Result Ng_MergeMesh (Ng_Mesh *mesh, const char *filename)
 Merge a Netgen VOL Mesh from disk into an existing mesh in memory.
DLL_HEADER Ng_Result Ng_MergeMesh (Ng_Mesh *mesh1, Ng_Mesh *mesh2)
 Merge one Netgen Mesh into another Netgen Mesh in the case when both are already in memory.
DLL_HEADER void Ng_AddPoint (Ng_Mesh *mesh, double *x)
 Add a point to a given Netgen Mesh Structure.
DLL_HEADER void Ng_AddSurfaceElement (Ng_Mesh *mesh, Ng_Surface_Element_Type et, int *pi)
 Add a surface element to a given Netgen Mesh Structure.
DLL_HEADER void Ng_AddVolumeElement (Ng_Mesh *mesh, Ng_Volume_Element_Type et, int *pi)
 Add a volume element to a given Netgen Mesh Structure.
DLL_HEADER void Ng_RestrictMeshSizeGlobal (Ng_Mesh *mesh, double h)
 Apply a global restriction on mesh element size.
DLL_HEADER void Ng_RestrictMeshSizePoint (Ng_Mesh *mesh, double *p, double h)
 Locally restrict the mesh element size at the given point.
DLL_HEADER void Ng_RestrictMeshSizeBox (Ng_Mesh *mesh, double *pmin, double *pmax, double h)
 Locally restrict the mesh element size within a specified box.
DLL_HEADER Ng_Result Ng_GenerateVolumeMesh (Ng_Mesh *mesh, Ng_Meshing_Parameters *mp)
 Create a 3D Volume Mesh given a Surface Mesh.
DLL_HEADER int Ng_GetNP (Ng_Mesh *mesh)
 Returns the Number of Points present in the specified Mesh.
DLL_HEADER int Ng_GetNSE (Ng_Mesh *mesh)
 Returns the Number of Surface Elements present in the specified Mesh.
DLL_HEADER int Ng_GetNE (Ng_Mesh *mesh)
 Returns the Number of Volume Elements present in the specified Mesh.
DLL_HEADER void Ng_GetPoint (Ng_Mesh *mesh, int num, double *x)
DLL_HEADER Ng_Surface_Element_Type Ng_GetSurfaceElement (Ng_Mesh *mesh, int num, int *pi)
DLL_HEADER Ng_Volume_Element_Type Ng_GetVolumeElement (Ng_Mesh *mesh, int num, int *pi)
DLL_HEADER void Ng_AddPoint_2D (Ng_Mesh *mesh, double *x)
DLL_HEADER void Ng_AddBoundarySeg_2D (Ng_Mesh *mesh, int pi1, int pi2)
DLL_HEADER int Ng_GetNP_2D (Ng_Mesh *mesh)
DLL_HEADER int Ng_GetNE_2D (Ng_Mesh *mesh)
DLL_HEADER int Ng_GetNSeg_2D (Ng_Mesh *mesh)
DLL_HEADER void Ng_GetPoint_2D (Ng_Mesh *mesh, int num, double *x)
DLL_HEADER Ng_Surface_Element_Type Ng_GetElement_2D (Ng_Mesh *mesh, int num, int *pi, int *matnum=NULL)
DLL_HEADER void Ng_GetSegment_2D (Ng_Mesh *mesh, int num, int *pi, int *matnum=NULL)
DLL_HEADER Ng_Geometry_2DNg_LoadGeometry_2D (const char *filename)
DLL_HEADER Ng_Result Ng_GenerateMesh_2D (Ng_Geometry_2D *geom, Ng_Mesh **mesh, Ng_Meshing_Parameters *mp)
DLL_HEADER void Ng_HP_Refinement (Ng_Geometry_2D *geom, Ng_Mesh *mesh, int levels)
DLL_HEADER Ng_STL_GeometryNg_STL_LoadGeometry (const char *filename, int binary=0)
DLL_HEADER Ng_STL_GeometryNg_STL_NewGeometry ()
DLL_HEADER void Ng_STL_AddTriangle (Ng_STL_Geometry *geom, double *p1, double *p2, double *p3, double *nv=NULL)
DLL_HEADER void Ng_STL_AddEdge (Ng_STL_Geometry *geom, double *p1, double *p2)
DLL_HEADER Ng_Result Ng_STL_InitSTLGeometry (Ng_STL_Geometry *geom)
DLL_HEADER Ng_Result Ng_STL_MakeEdges (Ng_STL_Geometry *geom, Ng_Mesh *mesh, Ng_Meshing_Parameters *mp)
DLL_HEADER Ng_Result Ng_STL_GenerateSurfaceMesh (Ng_STL_Geometry *geom, Ng_Mesh *mesh, Ng_Meshing_Parameters *mp)
DLL_HEADER void Ng_Uniform_Refinement (Ng_Mesh *mesh)
DLL_HEADER void Ng_2D_Uniform_Refinement (Ng_Geometry_2D *geom, Ng_Mesh *mesh)
DLL_HEADER void Ng_STL_Uniform_Refinement (Ng_STL_Geometry *geom, Ng_Mesh *mesh)
DLL_HEADER void Ng_CSG_Uniform_Refinement (Ng_CSG_Geometry *geom, Ng_Mesh *mesh)
DLL_HEADER void Ng_Generate_SecondOrder (Ng_Mesh *mesh)
DLL_HEADER void Ng_2D_Generate_SecondOrder (Ng_Geometry_2D *geom, Ng_Mesh *mesh)
DLL_HEADER void Ng_STL_Generate_SecondOrder (Ng_STL_Geometry *geom, Ng_Mesh *mesh)
DLL_HEADER void Ng_CSG_Generate_SecondOrder (Ng_CSG_Geometry *geom, Ng_Mesh *mesh)

Detailed Description

Library interface to the netgen meshing kernel.

Author:
Joachim Schoeberl
Date:
7. May 2000

This header file provides access to the core functionality of the Netgen Mesher via a library interface, without an interactive User Interface.

The intention of providing these set of functions is to allow system developers to integrate Netgen into top-level code, to act as the low level mesh generation / optimisation kernel.


Define Documentation

#define DLL_HEADER
#define DLL_HEADER

Maximum allowed number of nodes per surface element.

#define NG_VOLUME_ELEMENT_MAXPOINTS   10
#define NG_VOLUME_ELEMENT_MAXPOINTS   10

Maximum allowed number of nodes per volume element.


Typedef Documentation

typedef void* Ng_CSG_Geometry

Data type for NETGEN CSG geometry.

typedef void* Ng_Geometry_2D

Data type for NETGEN 2D geometry.

typedef void* Ng_Mesh

Data type for NETGEN mesh.

typedef void* Ng_STL_Geometry

Data type for NETGEN STL geometry.


Enumeration Type Documentation

enum Ng_Result

Values returned by Netgen functions.

Enumerator:
NG_ERROR 
NG_OK 
NG_SURFACE_INPUT_ERROR 
NG_VOLUME_FAILURE 
NG_STL_INPUT_ERROR 
NG_SURFACE_FAILURE 
NG_FILE_NOT_FOUND 

Currently implemented surface element types.

Enumerator:
NG_TRIG 
NG_QUAD 
NG_TRIG6 
NG_QUAD6 
NG_QUAD8 

Currently implemented volume element types.

Enumerator:
NG_TET 
NG_PYRAMID 
NG_PRISM 
NG_TET10 

Function Documentation

DLL_HEADER void Ng_AddBoundarySeg_2D ( Ng_Mesh mesh,
int  pi1,
int  pi2 
)
DLL_HEADER void Ng_AddPoint ( Ng_Mesh mesh,
double *  x 
)

Add a point to a given Netgen Mesh Structure.

This function allows points to be directly added to a Netgen mesh structure by providing the co-ordinates.

Each call to the function allows only one point to be added.

Parameters:
meshPointer to an existing Netgen Mesh structure of type Ng_Mesh
xPointer to an array of type double containing the co-ordinates of the point to be added in the form:
  • x[0] = X co-ordinate
  • x[1] = Y co-ordinate
  • x[2] = Z co-ordinate
DLL_HEADER void Ng_AddPoint_2D ( Ng_Mesh mesh,
double *  x 
)
DLL_HEADER void Ng_AddSurfaceElement ( Ng_Mesh mesh,
Ng_Surface_Element_Type  et,
int *  pi 
)

Add a surface element to a given Netgen Mesh Structure.

This function allows the top-level code to directly add individual Surface Elements to a Netgen Mesh Structure by providing the type of element to be added and the indices of the points which constitute the element.

Note:

  • The points referred to by the surface elements must have been added prior to calling this function.
  • Currently only triangular elements are supported, and the Surface Element Type argument is not used.
Parameters:
meshPointer to an existing Netgen Mesh structure of type Ng_Mesh
etSurface Element type provided via the enumerated type Ng_Surface_Element_Type
piPointer to an array of integers containing the indices of the points which constitute the surface element being added
DLL_HEADER void Ng_AddVolumeElement ( Ng_Mesh mesh,
Ng_Volume_Element_Type  et,
int *  pi 
)

Add a volume element to a given Netgen Mesh Structure.

This function allows the top-level code to directly add individual Volume Elements to a Netgen Mesh Structure by providing the type of element to be added and the indices of the points which constitute the element.

Note:

  • The points referred to by the volume elements must have been added prior to calling this function.
  • Currently only tetrahedral elements are supported, and the Volume Element Type argument is not used.
Parameters:
meshPointer to an existing Netgen Mesh structure of type Ng_Mesh
etVolume Element type provided via the enumerated type Ng_Volume_Element_Type
piPointer to an array of integers containing the indices of the points which constitute the volume element being added
DLL_HEADER void Ng_DeleteMesh ( Ng_Mesh mesh)

Delete an existing Netgen Mesh Structure.

Use this function to delete an existing Netgen mesh structure and release the used memory.

Parameters:
meshPointer to an existing Netgen Mesh structure of type Ng_Mesh
DLL_HEADER void Ng_Exit ( )

Exit the Netgen meshing kernel in a clean manner.

Use this function to exit the meshing sub-system in a clean and orderly manner.

Create a 3D Volume Mesh given a Surface Mesh.

After creating a surface mesh, this function can be utilised to automatically generate the corresponding 3D Volume Mesh.

Mesh generation parameters (such as grading, maximum element size, etc.) are specified via the meshing parameters class which also needs to be passed to this function.

Note: Currently, Netgen generates pure tetrahedral volume meshes.

Parameters:
meshPointer to an existing Netgen Mesh structure of type Ng_Mesh
mpPointer to a copy of the Meshing Parameters class (Ng_Meshing_Parameters), filled up with the required values
Returns:
Ng_Result Status of the Mesh Generation routine. More details regarding the return value can be found in the description of Ng_Result
DLL_HEADER Ng_Surface_Element_Type Ng_GetElement_2D ( Ng_Mesh mesh,
int  num,
int *  pi,
int *  matnum = NULL 
)
DLL_HEADER int Ng_GetNE ( Ng_Mesh mesh)

Returns the Number of Volume Elements present in the specified Mesh.

Given an already existent Netgen Mesh Structure, this function returns the number of volume elements currently present within the Mesh.

Parameters:
meshPointer to an existing Netgen Mesh structure of type Ng_Mesh
Returns:
Integer Data-type with the number of volume elements in the Mesh
DLL_HEADER int Ng_GetNE_2D ( Ng_Mesh mesh)
DLL_HEADER int Ng_GetNP ( Ng_Mesh mesh)

Returns the Number of Points present in the specified Mesh.

Given an already existent Netgen Mesh Structure, this function returns the number of points currently present within the Mesh.

Parameters:
meshPointer to an existing Netgen Mesh structure of type Ng_Mesh
Returns:
Integer Data-type with the number of points in the Mesh
DLL_HEADER int Ng_GetNP_2D ( Ng_Mesh mesh)
DLL_HEADER int Ng_GetNSE ( Ng_Mesh mesh)

Returns the Number of Surface Elements present in the specified Mesh.

Given an already existent Netgen Mesh Structure, this function returns the number of surface elements currently present within the Mesh.

Parameters:
meshPointer to an existing Netgen Mesh structure of type Ng_Mesh
Returns:
Integer Data-type with the number of surface elements in the Mesh
DLL_HEADER int Ng_GetNSeg_2D ( Ng_Mesh mesh)
DLL_HEADER void Ng_GetPoint ( Ng_Mesh mesh,
int  num,
double *  x 
)
DLL_HEADER void Ng_GetPoint_2D ( Ng_Mesh mesh,
int  num,
double *  x 
)
DLL_HEADER void Ng_GetSegment_2D ( Ng_Mesh mesh,
int  num,
int *  pi,
int *  matnum = NULL 
)
DLL_HEADER Ng_Surface_Element_Type Ng_GetSurfaceElement ( Ng_Mesh mesh,
int  num,
int *  pi 
)
DLL_HEADER Ng_Volume_Element_Type Ng_GetVolumeElement ( Ng_Mesh mesh,
int  num,
int *  pi 
)
DLL_HEADER void Ng_HP_Refinement ( Ng_Geometry_2D geom,
Ng_Mesh mesh,
int  levels 
)
DLL_HEADER void Ng_Init ( )

Initialise the Netgen library and prepare for use.

This function needs to be called by the third-party program before beginning to use the other Netgen specific functions.

DLL_HEADER Ng_Geometry_2D* Ng_LoadGeometry_2D ( const char *  filename)
DLL_HEADER Ng_Mesh* Ng_LoadMesh ( const char *  filename)

Load a Netgen VOL Mesh from disk into memory.

A Netgen mesh saved in the internal VOL format can be loaded into a Netgen Mesh structure using this function.

Parameters:
filenamePointer to a character array containing the name of the file to load
Returns:
Ng_Mesh Pointer to a Netgen Mesh type Ng_Mesh containing the mesh loaded from disk
DLL_HEADER Ng_Result Ng_MergeMesh ( Ng_Mesh mesh,
const char *  filename 
)

Merge a Netgen VOL Mesh from disk into an existing mesh in memory.

A Netgen mesh saved in the internal VOL format can be merged into an existing Netgen Mesh structure using this function.

Parameters:
meshName of the Mesh structure already existent in memory
filenamePointer to a character array containing the name of the file to load
Returns:
Ng_Result Status of the merge operation
DLL_HEADER Ng_Result Ng_MergeMesh ( Ng_Mesh mesh1,
Ng_Mesh mesh2 
)

Merge one Netgen Mesh into another Netgen Mesh in the case when both are already in memory.

(NOTE: First version implemented, Sakalli)

This function can be used to merge two Netgen meshes already present in memory.

Parameters:
mesh1Parent Mesh structure into which the second mesh will be merged
mesh2Child mesh structure which will get merged into the parent mesh
Returns:
Ng_Result Status of the merge operation

Create a new (and empty) Netgen Mesh Structure.

This function creates a new Netgen Mesh, initialises it, and returns a pointer to the created mesh structure.

Use the returned pointer for subsequent operations which involve mesh operations.

Returns:
Ng_Mesh Pointer to a Netgen Mesh type Ng_Mesh
DLL_HEADER void Ng_RestrictMeshSizeBox ( Ng_Mesh mesh,
double *  pmin,
double *  pmax,
double  h 
)

Locally restrict the mesh element size within a specified box.

Similar to the function Ng_RestrictMeshSizePoint, this function allows the size of elements within a mesh to be locally limited.

However, rather than limit the mesh size at a single point, this utility restricts the local mesh size within a 3D Box region, specified via the co-ordinates of the two diagonally opposite points of a cuboid.

Note: This function only limits the Maximum size of the elements within the specified region.

Parameters:
meshPointer to an existing Netgen Mesh structure of type Ng_Mesh
pminPointer to an Array of type double, containing the three co-ordinates of the first point of the cuboid:
  • pmin[0] = X co-ordinate
  • pmin[1] = Y co-ordinate
  • pmin[2] = Z co-ordinate
pmaxPointer to an Array of type double, containing the three co-ordinates of the opposite point of the cuboid:
  • pmax[0] = X co-ordinate
  • pmax[1] = Y co-ordinate
  • pmax[2] = Z co-ordinate
hVariable of type double, specifying the maximum allowable mesh size at that point
DLL_HEADER void Ng_RestrictMeshSizeGlobal ( Ng_Mesh mesh,
double  h 
)

Apply a global restriction on mesh element size.

This utility allows the user to apply a global mesh element size limitation.

During mesh creation, in the absence of an explicit local size restriction around the neighbourhood of a point within the meshing domain, this global size restriction will be utilised.

Note: This function only limits the Maximum size of an element within the mesh.

Parameters:
meshPointer to an existing Netgen Mesh structure of type Ng_Mesh
hVariable of type double, specifying the maximum allowable mesh size
DLL_HEADER void Ng_RestrictMeshSizePoint ( Ng_Mesh mesh,
double *  p,
double  h 
)

Locally restrict the mesh element size at the given point.

Unlike the function Ng_RestrictMeshSizeGlobal, this function allows the user to locally restrict the maximum allowable mesh size at a given point.

The point is specified via its three cartesian co-ordinates.

Note: This function only limits the Maximum size of the elements around the specified point.

Parameters:
meshPointer to an existing Netgen Mesh structure of type Ng_Mesh
pPointer to an Array of type double, containing the three co-ordinates of the point in the form:
  • p[0] = X co-ordinate
  • p[1] = Y co-ordinate
  • p[2] = Z co-ordinate
hVariable of type double, specifying the maximum allowable mesh size at that point
DLL_HEADER void Ng_SaveMesh ( Ng_Mesh mesh,
const char *  filename 
)

Save a Netgen Mesh to disk.

This function allows a generated mesh structure to be saved to disk.

A Mesh saved using this function, will be written to disk in the Netgen VOL file format.

Parameters:
meshPointer to an existing Netgen Mesh structure of type Ng_Mesh
filenamePointer to a character array containing the name of the file to which the mesh should be saved
DLL_HEADER Ng_Mesh* Ng_SetProperties ( Ng_Mesh m,
int  surfnr,
int  bcnr,
int  domin,
int  domout 
)

Set element options.

Changes the element options of a Netgen mesh in VOL format . (Sakalli)

Parameters:
meshName of the Mesh structure already existent in memory
surfnrSet surface number
bcnrSet boundary number
dominSet domain in
domoutSet domain out
Returns:
Ng_Result Status of the boundary operation
DLL_HEADER void Ng_STL_AddEdge ( Ng_STL_Geometry geom,
double *  p1,
double *  p2 
)
DLL_HEADER void Ng_STL_AddTriangle ( Ng_STL_Geometry geom,
double *  p1,
double *  p2,
double *  p3,
double *  nv = NULL 
)
DLL_HEADER Ng_STL_Geometry* Ng_STL_LoadGeometry ( const char *  filename,
int  binary = 0 
)