mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-26 22:00:33 +05:00
* Added the capability of generating Quad dominated 2D Meshes in Nglib
* Added the capability of generating Second Order 2D / 3D Meshes in Nglib * More Meshing Parameters now taken into account in Nglib * Streamlined the process of transferring the locally defined meshing parameters to the internal meshing parameters structure using a single function called "Transfer_Parameters" * Formatting changes to make the gaps between function definitions consistent
This commit is contained in:
parent
a249e8a42e
commit
c412992519
232
nglib/nglib.cpp
232
nglib/nglib.cpp
@ -9,8 +9,6 @@
|
|||||||
Interface to the netgen meshing kernel
|
Interface to the netgen meshing kernel
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <mystdlib.h>
|
#include <mystdlib.h>
|
||||||
#include <myadt.hpp>
|
#include <myadt.hpp>
|
||||||
|
|
||||||
@ -76,6 +74,7 @@ namespace nglib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Clean-up functions before ending usage of nglib
|
// Clean-up functions before ending usage of nglib
|
||||||
DLL_HEADER void Ng_Exit ()
|
DLL_HEADER void Ng_Exit ()
|
||||||
{
|
{
|
||||||
@ -84,6 +83,7 @@ namespace nglib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Create a new netgen mesh object
|
// Create a new netgen mesh object
|
||||||
DLL_HEADER Ng_Mesh * Ng_NewMesh ()
|
DLL_HEADER Ng_Mesh * Ng_NewMesh ()
|
||||||
{
|
{
|
||||||
@ -94,6 +94,7 @@ namespace nglib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Delete an existing netgen mesh object
|
// Delete an existing netgen mesh object
|
||||||
DLL_HEADER void Ng_DeleteMesh (Ng_Mesh * mesh)
|
DLL_HEADER void Ng_DeleteMesh (Ng_Mesh * mesh)
|
||||||
{
|
{
|
||||||
@ -112,6 +113,7 @@ namespace nglib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Save a netgen mesh in the native VOL format
|
// Save a netgen mesh in the native VOL format
|
||||||
DLL_HEADER void Ng_SaveMesh(Ng_Mesh * mesh, const char* filename)
|
DLL_HEADER void Ng_SaveMesh(Ng_Mesh * mesh, const char* filename)
|
||||||
{
|
{
|
||||||
@ -120,6 +122,7 @@ namespace nglib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Load a netgen native VOL mesh from a given file
|
// Load a netgen native VOL mesh from a given file
|
||||||
DLL_HEADER Ng_Mesh * Ng_LoadMesh(const char* filename)
|
DLL_HEADER Ng_Mesh * Ng_LoadMesh(const char* filename)
|
||||||
{
|
{
|
||||||
@ -130,6 +133,7 @@ namespace nglib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Manually add a point to an existing mesh object
|
// Manually add a point to an existing mesh object
|
||||||
DLL_HEADER void Ng_AddPoint (Ng_Mesh * mesh, double * x)
|
DLL_HEADER void Ng_AddPoint (Ng_Mesh * mesh, double * x)
|
||||||
{
|
{
|
||||||
@ -139,6 +143,7 @@ namespace nglib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Manually add a surface element of a given type to an existing mesh object
|
// Manually add a surface element of a given type to an existing mesh object
|
||||||
DLL_HEADER void Ng_AddSurfaceElement (Ng_Mesh * mesh, Ng_Surface_Element_Type et,
|
DLL_HEADER void Ng_AddSurfaceElement (Ng_Mesh * mesh, Ng_Surface_Element_Type et,
|
||||||
int * pi)
|
int * pi)
|
||||||
@ -154,6 +159,7 @@ namespace nglib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Manually add a volume element of a given type to an existing mesh object
|
// Manually add a volume element of a given type to an existing mesh object
|
||||||
DLL_HEADER void Ng_AddVolumeElement (Ng_Mesh * mesh, Ng_Volume_Element_Type et,
|
DLL_HEADER void Ng_AddVolumeElement (Ng_Mesh * mesh, Ng_Volume_Element_Type et,
|
||||||
int * pi)
|
int * pi)
|
||||||
@ -170,6 +176,7 @@ namespace nglib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Obtain the number of points in the mesh
|
// Obtain the number of points in the mesh
|
||||||
DLL_HEADER int Ng_GetNP (Ng_Mesh * mesh)
|
DLL_HEADER int Ng_GetNP (Ng_Mesh * mesh)
|
||||||
{
|
{
|
||||||
@ -178,6 +185,7 @@ namespace nglib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Obtain the number of surface elements in the mesh
|
// Obtain the number of surface elements in the mesh
|
||||||
DLL_HEADER int Ng_GetNSE (Ng_Mesh * mesh)
|
DLL_HEADER int Ng_GetNSE (Ng_Mesh * mesh)
|
||||||
{
|
{
|
||||||
@ -186,6 +194,7 @@ namespace nglib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Obtain the number of volume elements in the mesh
|
// Obtain the number of volume elements in the mesh
|
||||||
DLL_HEADER int Ng_GetNE (Ng_Mesh * mesh)
|
DLL_HEADER int Ng_GetNE (Ng_Mesh * mesh)
|
||||||
{
|
{
|
||||||
@ -194,6 +203,7 @@ namespace nglib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Return point coordinates of a given point index in the mesh
|
// Return point coordinates of a given point index in the mesh
|
||||||
DLL_HEADER void Ng_GetPoint (Ng_Mesh * mesh, int num, double * x)
|
DLL_HEADER void Ng_GetPoint (Ng_Mesh * mesh, int num, double * x)
|
||||||
{
|
{
|
||||||
@ -205,6 +215,7 @@ namespace nglib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Return the surface element at a given index "pi"
|
// Return the surface element at a given index "pi"
|
||||||
DLL_HEADER Ng_Surface_Element_Type
|
DLL_HEADER Ng_Surface_Element_Type
|
||||||
Ng_GetSurfaceElement (Ng_Mesh * mesh, int num, int * pi)
|
Ng_GetSurfaceElement (Ng_Mesh * mesh, int num, int * pi)
|
||||||
@ -226,6 +237,7 @@ namespace nglib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Return the volume element at a given index "pi"
|
// Return the volume element at a given index "pi"
|
||||||
DLL_HEADER Ng_Volume_Element_Type
|
DLL_HEADER Ng_Volume_Element_Type
|
||||||
Ng_GetVolumeElement (Ng_Mesh * mesh, int num, int * pi)
|
Ng_GetVolumeElement (Ng_Mesh * mesh, int num, int * pi)
|
||||||
@ -248,6 +260,7 @@ namespace nglib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Set a global limit on the maximum mesh size allowed
|
// Set a global limit on the maximum mesh size allowed
|
||||||
DLL_HEADER void Ng_RestrictMeshSizeGlobal (Ng_Mesh * mesh, double h)
|
DLL_HEADER void Ng_RestrictMeshSizeGlobal (Ng_Mesh * mesh, double h)
|
||||||
{
|
{
|
||||||
@ -256,6 +269,7 @@ namespace nglib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Set a local limit on the maximum mesh size allowed around the given point
|
// Set a local limit on the maximum mesh size allowed around the given point
|
||||||
DLL_HEADER void Ng_RestrictMeshSizePoint (Ng_Mesh * mesh, double * p, double h)
|
DLL_HEADER void Ng_RestrictMeshSizePoint (Ng_Mesh * mesh, double * p, double h)
|
||||||
{
|
{
|
||||||
@ -264,6 +278,7 @@ namespace nglib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Set a local limit on the maximum mesh size allowed within a given box region
|
// Set a local limit on the maximum mesh size allowed within a given box region
|
||||||
DLL_HEADER void Ng_RestrictMeshSizeBox (Ng_Mesh * mesh, double * pmin, double * pmax, double h)
|
DLL_HEADER void Ng_RestrictMeshSizeBox (Ng_Mesh * mesh, double * pmin, double * pmax, double h)
|
||||||
{
|
{
|
||||||
@ -275,6 +290,7 @@ namespace nglib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Generates volume mesh from an existing surface mesh
|
// Generates volume mesh from an existing surface mesh
|
||||||
DLL_HEADER Ng_Result Ng_GenerateVolumeMesh (Ng_Mesh * mesh, Ng_Meshing_Parameters * mp)
|
DLL_HEADER Ng_Result Ng_GenerateVolumeMesh (Ng_Mesh * mesh, Ng_Meshing_Parameters * mp)
|
||||||
{
|
{
|
||||||
@ -284,12 +300,7 @@ namespace nglib
|
|||||||
// Do not locally re-define "mparam" here... "mparam" is a global
|
// Do not locally re-define "mparam" here... "mparam" is a global
|
||||||
// object
|
// object
|
||||||
//MeshingParameters mparam;
|
//MeshingParameters mparam;
|
||||||
mparam.maxh = mp->maxh;
|
mp->Transfer_Parameters();
|
||||||
mparam.meshsizefilename = mp->meshsize_filename;
|
|
||||||
|
|
||||||
double fineness = min(1., max(0., mp->fineness));
|
|
||||||
mparam.curvaturesafety = 0.3 + 5 * fineness;
|
|
||||||
mparam.segmentsperedge = 0.3 + 5 * fineness;
|
|
||||||
|
|
||||||
m->CalcLocalH();
|
m->CalcLocalH();
|
||||||
|
|
||||||
@ -302,10 +313,8 @@ namespace nglib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ------------------ 2D Meshing Functions ------------------------- */
|
/* ------------------ 2D Meshing Functions ------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DLL_HEADER void Ng_AddPoint_2D (Ng_Mesh * mesh, double * x)
|
DLL_HEADER void Ng_AddPoint_2D (Ng_Mesh * mesh, double * x)
|
||||||
{
|
{
|
||||||
Mesh * m = (Mesh*)mesh;
|
Mesh * m = (Mesh*)mesh;
|
||||||
@ -313,6 +322,9 @@ namespace nglib
|
|||||||
m->AddPoint (Point3d (x[0], x[1], 0));
|
m->AddPoint (Point3d (x[0], x[1], 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DLL_HEADER void Ng_AddBoundarySeg_2D (Ng_Mesh * mesh, int pi1, int pi2)
|
DLL_HEADER void Ng_AddBoundarySeg_2D (Ng_Mesh * mesh, int pi1, int pi2)
|
||||||
{
|
{
|
||||||
Mesh * m = (Mesh*)mesh;
|
Mesh * m = (Mesh*)mesh;
|
||||||
@ -324,24 +336,35 @@ namespace nglib
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DLL_HEADER int Ng_GetNP_2D (Ng_Mesh * mesh)
|
DLL_HEADER int Ng_GetNP_2D (Ng_Mesh * mesh)
|
||||||
{
|
{
|
||||||
Mesh * m = (Mesh*)mesh;
|
Mesh * m = (Mesh*)mesh;
|
||||||
return m->GetNP();
|
return m->GetNP();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DLL_HEADER int Ng_GetNE_2D (Ng_Mesh * mesh)
|
DLL_HEADER int Ng_GetNE_2D (Ng_Mesh * mesh)
|
||||||
{
|
{
|
||||||
Mesh * m = (Mesh*)mesh;
|
Mesh * m = (Mesh*)mesh;
|
||||||
return m->GetNSE();
|
return m->GetNSE();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DLL_HEADER int Ng_GetNSeg_2D (Ng_Mesh * mesh)
|
DLL_HEADER int Ng_GetNSeg_2D (Ng_Mesh * mesh)
|
||||||
{
|
{
|
||||||
Mesh * m = (Mesh*)mesh;
|
Mesh * m = (Mesh*)mesh;
|
||||||
return m->GetNSeg();
|
return m->GetNSeg();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DLL_HEADER void Ng_GetPoint_2D (Ng_Mesh * mesh, int num, double * x)
|
DLL_HEADER void Ng_GetPoint_2D (Ng_Mesh * mesh, int num, double * x)
|
||||||
{
|
{
|
||||||
Mesh * m = (Mesh*)mesh;
|
Mesh * m = (Mesh*)mesh;
|
||||||
@ -351,6 +374,9 @@ namespace nglib
|
|||||||
x[1] = p(1);
|
x[1] = p(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DLL_HEADER void Ng_GetElement_2D (Ng_Mesh * mesh, int num, int * pi, int * matnum)
|
DLL_HEADER void Ng_GetElement_2D (Ng_Mesh * mesh, int num, int * pi, int * matnum)
|
||||||
{
|
{
|
||||||
const Element2d & el = ((Mesh*)mesh)->SurfaceElement(num);
|
const Element2d & el = ((Mesh*)mesh)->SurfaceElement(num);
|
||||||
@ -361,6 +387,8 @@ namespace nglib
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DLL_HEADER void Ng_GetSegment_2D (Ng_Mesh * mesh, int num, int * pi, int * matnum)
|
DLL_HEADER void Ng_GetSegment_2D (Ng_Mesh * mesh, int num, int * pi, int * matnum)
|
||||||
{
|
{
|
||||||
const Segment & seg = ((Mesh*)mesh)->LineSegment(num);
|
const Segment & seg = ((Mesh*)mesh)->LineSegment(num);
|
||||||
@ -390,9 +418,7 @@ namespace nglib
|
|||||||
{
|
{
|
||||||
// use global variable mparam
|
// use global variable mparam
|
||||||
// MeshingParameters mparam;
|
// MeshingParameters mparam;
|
||||||
mparam.maxh = mp->maxh;
|
mp->Transfer_Parameters();
|
||||||
mparam.meshsizefilename = mp->meshsize_filename;
|
|
||||||
mparam.quad = mp->quad_dominated;
|
|
||||||
|
|
||||||
Mesh * m;
|
Mesh * m;
|
||||||
MeshFromSpline2D (*(SplineGeometry2d*)geom, m, mparam);
|
MeshFromSpline2D (*(SplineGeometry2d*)geom, m, mparam);
|
||||||
@ -428,10 +454,6 @@ namespace nglib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Array<STLReadTriangle> readtrias; //only before initstlgeometry
|
Array<STLReadTriangle> readtrias; //only before initstlgeometry
|
||||||
Array<Point<3> > readedges; //only before init stlgeometry
|
Array<Point<3> > readedges; //only before init stlgeometry
|
||||||
|
|
||||||
@ -484,6 +506,7 @@ namespace nglib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// generate new STL Geometry
|
// generate new STL Geometry
|
||||||
DLL_HEADER Ng_STL_Geometry * Ng_STL_NewGeometry ()
|
DLL_HEADER Ng_STL_Geometry * Ng_STL_NewGeometry ()
|
||||||
{
|
{
|
||||||
@ -492,6 +515,7 @@ namespace nglib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// after adding triangles (and edges) initialize
|
// after adding triangles (and edges) initialize
|
||||||
DLL_HEADER Ng_Result Ng_STL_InitSTLGeometry (Ng_STL_Geometry * geom)
|
DLL_HEADER Ng_Result Ng_STL_InitSTLGeometry (Ng_STL_Geometry * geom)
|
||||||
{
|
{
|
||||||
@ -516,6 +540,7 @@ namespace nglib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// automatically generates edges:
|
// automatically generates edges:
|
||||||
DLL_HEADER Ng_Result Ng_STL_MakeEdges (Ng_STL_Geometry * geom,
|
DLL_HEADER Ng_Result Ng_STL_MakeEdges (Ng_STL_Geometry * geom,
|
||||||
Ng_Mesh* mesh,
|
Ng_Mesh* mesh,
|
||||||
@ -528,9 +553,7 @@ namespace nglib
|
|||||||
// Do not locally re-define "mparam" here... "mparam" is a global
|
// Do not locally re-define "mparam" here... "mparam" is a global
|
||||||
// object
|
// object
|
||||||
//MeshingParameters mparam;
|
//MeshingParameters mparam;
|
||||||
|
mp->Transfer_Parameters();
|
||||||
mparam.maxh = mp->maxh;
|
|
||||||
mparam.meshsizefilename = mp->meshsize_filename;
|
|
||||||
|
|
||||||
me -> SetGlobalH (mparam.maxh);
|
me -> SetGlobalH (mparam.maxh);
|
||||||
me -> SetLocalH (stlgeometry->GetBoundingBox().PMin() - Vec3d(10, 10, 10),
|
me -> SetLocalH (stlgeometry->GetBoundingBox().PMin() - Vec3d(10, 10, 10),
|
||||||
@ -558,6 +581,8 @@ namespace nglib
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// generates mesh, empty mesh be already created.
|
// generates mesh, empty mesh be already created.
|
||||||
DLL_HEADER Ng_Result Ng_STL_GenerateSurfaceMesh (Ng_STL_Geometry * geom,
|
DLL_HEADER Ng_Result Ng_STL_GenerateSurfaceMesh (Ng_STL_Geometry * geom,
|
||||||
Ng_Mesh* mesh,
|
Ng_Mesh* mesh,
|
||||||
@ -570,9 +595,8 @@ namespace nglib
|
|||||||
// Do not locally re-define "mparam" here... "mparam" is a global
|
// Do not locally re-define "mparam" here... "mparam" is a global
|
||||||
// object
|
// object
|
||||||
//MeshingParameters mparam;
|
//MeshingParameters mparam;
|
||||||
|
mp->Transfer_Parameters();
|
||||||
|
|
||||||
mparam.maxh = mp->maxh;
|
|
||||||
mparam.meshsizefilename = mp->meshsize_filename;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
me -> SetGlobalH (mparam.maxh);
|
me -> SetGlobalH (mparam.maxh);
|
||||||
@ -616,6 +640,8 @@ namespace nglib
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// fills STL Geometry
|
// fills STL Geometry
|
||||||
// positive orientation
|
// positive orientation
|
||||||
// normal vector may be null-pointer
|
// normal vector may be null-pointer
|
||||||
@ -648,10 +674,8 @@ namespace nglib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef OCCGEOMETRY
|
#ifdef OCCGEOMETRY
|
||||||
// --------------------- OCC Geometry / Meshing Utility Functions -------------------
|
// --------------------- OCC Geometry / Meshing Utility Functions -------------------
|
||||||
|
|
||||||
// Create new OCC Geometry Object
|
// Create new OCC Geometry Object
|
||||||
DLL_HEADER Ng_OCC_Geometry * Ng_OCC_NewGeometry ()
|
DLL_HEADER Ng_OCC_Geometry * Ng_OCC_NewGeometry ()
|
||||||
{
|
{
|
||||||
@ -660,6 +684,7 @@ namespace nglib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Delete the OCC Geometry Object
|
// Delete the OCC Geometry Object
|
||||||
DLL_HEADER Ng_Result Ng_OCC_DeleteGeometry(Ng_OCC_Geometry * geom)
|
DLL_HEADER Ng_Result Ng_OCC_DeleteGeometry(Ng_OCC_Geometry * geom)
|
||||||
{
|
{
|
||||||
@ -675,6 +700,7 @@ namespace nglib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Loads geometry from STEP File
|
// Loads geometry from STEP File
|
||||||
DLL_HEADER Ng_OCC_Geometry * Ng_OCC_Load_STEP (const char * filename)
|
DLL_HEADER Ng_OCC_Geometry * Ng_OCC_Load_STEP (const char * filename)
|
||||||
{
|
{
|
||||||
@ -687,6 +713,7 @@ namespace nglib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Loads geometry from IGES File
|
// Loads geometry from IGES File
|
||||||
DLL_HEADER Ng_OCC_Geometry * Ng_OCC_Load_IGES (const char * filename)
|
DLL_HEADER Ng_OCC_Geometry * Ng_OCC_Load_IGES (const char * filename)
|
||||||
{
|
{
|
||||||
@ -699,6 +726,7 @@ namespace nglib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Loads geometry from BREP File
|
// Loads geometry from BREP File
|
||||||
DLL_HEADER Ng_OCC_Geometry * Ng_OCC_Load_BREP (const char * filename)
|
DLL_HEADER Ng_OCC_Geometry * Ng_OCC_Load_BREP (const char * filename)
|
||||||
{
|
{
|
||||||
@ -711,6 +739,7 @@ namespace nglib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Locally limit the size of the mesh to be generated at various points
|
// Locally limit the size of the mesh to be generated at various points
|
||||||
// based on the topology of the geometry
|
// based on the topology of the geometry
|
||||||
DLL_HEADER Ng_Result Ng_OCC_SetLocalMeshSize (Ng_OCC_Geometry * geom,
|
DLL_HEADER Ng_Result Ng_OCC_SetLocalMeshSize (Ng_OCC_Geometry * geom,
|
||||||
@ -722,16 +751,7 @@ namespace nglib
|
|||||||
|
|
||||||
me->geomtype = Mesh::GEOM_OCC;
|
me->geomtype = Mesh::GEOM_OCC;
|
||||||
|
|
||||||
mparam.uselocalh = mp->uselocalh;
|
mp->Transfer_Parameters();
|
||||||
|
|
||||||
mparam.maxh = mp->maxh;
|
|
||||||
mparam.minh = mp->minh;
|
|
||||||
|
|
||||||
mparam.segmentsperedge = mp->elementsperedge;
|
|
||||||
mparam.curvaturesafety = mp->elementspercurve;
|
|
||||||
|
|
||||||
mparam.grading = mp->grading;
|
|
||||||
mparam.meshsizefilename = mp->meshsize_filename;
|
|
||||||
|
|
||||||
occparam.resthcloseedgeenable = mp->closeedgeenable;
|
occparam.resthcloseedgeenable = mp->closeedgeenable;
|
||||||
occparam.resthcloseedgefac = mp->closeedgefact;
|
occparam.resthcloseedgefac = mp->closeedgefact;
|
||||||
@ -747,6 +767,7 @@ namespace nglib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Mesh the edges and add Face descriptors to prepare for surface meshing
|
// Mesh the edges and add Face descriptors to prepare for surface meshing
|
||||||
DLL_HEADER Ng_Result Ng_OCC_GenerateEdgeMesh (Ng_OCC_Geometry * geom,
|
DLL_HEADER Ng_Result Ng_OCC_GenerateEdgeMesh (Ng_OCC_Geometry * geom,
|
||||||
Ng_Mesh * mesh,
|
Ng_Mesh * mesh,
|
||||||
@ -755,7 +776,7 @@ namespace nglib
|
|||||||
OCCGeometry * occgeom = (OCCGeometry*)geom;
|
OCCGeometry * occgeom = (OCCGeometry*)geom;
|
||||||
Mesh * me = (Mesh*)mesh;
|
Mesh * me = (Mesh*)mesh;
|
||||||
|
|
||||||
mparam.uselocalh = mp->uselocalh;
|
mp->Transfer_Parameters();
|
||||||
|
|
||||||
OCCFindEdges(*occgeom, *me);
|
OCCFindEdges(*occgeom, *me);
|
||||||
|
|
||||||
@ -782,7 +803,10 @@ namespace nglib
|
|||||||
OCCGeometry * occgeom = (OCCGeometry*)geom;
|
OCCGeometry * occgeom = (OCCGeometry*)geom;
|
||||||
Mesh * me = (Mesh*)mesh;
|
Mesh * me = (Mesh*)mesh;
|
||||||
|
|
||||||
mparam.uselocalh = mp->uselocalh;
|
// Set the internal meshing parameters structure from the nglib meshing
|
||||||
|
// parameters structure
|
||||||
|
mp->Transfer_Parameters();
|
||||||
|
|
||||||
|
|
||||||
// Only go into surface meshing if the face descriptors have already been added
|
// Only go into surface meshing if the face descriptors have already been added
|
||||||
if(!me->GetNFD())
|
if(!me->GetNFD())
|
||||||
@ -813,6 +837,8 @@ namespace nglib
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Extract the face map from the OCC geometry
|
// Extract the face map from the OCC geometry
|
||||||
// The face map basically gives an index to each face in the geometry,
|
// The face map basically gives an index to each face in the geometry,
|
||||||
// which can be used to access a specific face
|
// which can be used to access a specific face
|
||||||
@ -841,8 +867,8 @@ namespace nglib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ------------------ Begin - Meshing Parameters related functions ------------------
|
||||||
|
// Constructor for the local nglib meshing parameters class
|
||||||
DLL_HEADER Ng_Meshing_Parameters :: Ng_Meshing_Parameters()
|
DLL_HEADER Ng_Meshing_Parameters :: Ng_Meshing_Parameters()
|
||||||
{
|
{
|
||||||
uselocalh = 1;
|
uselocalh = 1;
|
||||||
@ -859,7 +885,7 @@ namespace nglib
|
|||||||
closeedgeenable = 0;
|
closeedgeenable = 0;
|
||||||
closeedgefact = 2.0;
|
closeedgefact = 2.0;
|
||||||
|
|
||||||
secondorder = 0;
|
second_order = 0;
|
||||||
quad_dominated = 0;
|
quad_dominated = 0;
|
||||||
|
|
||||||
meshsize_filename = 0;
|
meshsize_filename = 0;
|
||||||
@ -869,10 +895,18 @@ namespace nglib
|
|||||||
|
|
||||||
optsteps_2d = 3;
|
optsteps_2d = 3;
|
||||||
optsteps_3d = 3;
|
optsteps_3d = 3;
|
||||||
|
|
||||||
|
invert_tets = 0;
|
||||||
|
invert_trigs = 0;
|
||||||
|
|
||||||
|
check_overlap = 1;
|
||||||
|
check_overlapping_boundary = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Reset the local meshing parameters to the default values
|
||||||
DLL_HEADER void Ng_Meshing_Parameters :: Reset_Parameters()
|
DLL_HEADER void Ng_Meshing_Parameters :: Reset_Parameters()
|
||||||
{
|
{
|
||||||
uselocalh = 1;
|
uselocalh = 1;
|
||||||
@ -889,7 +923,7 @@ namespace nglib
|
|||||||
closeedgeenable = 0;
|
closeedgeenable = 0;
|
||||||
closeedgefact = 2.0;
|
closeedgefact = 2.0;
|
||||||
|
|
||||||
secondorder = 0;
|
second_order = 0;
|
||||||
quad_dominated = 0;
|
quad_dominated = 0;
|
||||||
|
|
||||||
meshsize_filename = 0;
|
meshsize_filename = 0;
|
||||||
@ -899,37 +933,125 @@ namespace nglib
|
|||||||
|
|
||||||
optsteps_2d = 3;
|
optsteps_2d = 3;
|
||||||
optsteps_3d = 3;
|
optsteps_3d = 3;
|
||||||
|
|
||||||
|
invert_tets = 0;
|
||||||
|
invert_trigs = 0;
|
||||||
|
|
||||||
|
check_overlap = 1;
|
||||||
|
check_overlapping_boundary = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
DLL_HEADER void Ng_Meshing_Parameters :: Transfer_Parameters()
|
||||||
|
{
|
||||||
|
mparam.uselocalh = uselocalh;
|
||||||
|
|
||||||
|
mparam.maxh = maxh;
|
||||||
|
mparam.minh = minh;
|
||||||
|
|
||||||
|
mparam.grading = grading;
|
||||||
|
mparam.curvaturesafety = elementspercurve;
|
||||||
|
mparam.segmentsperedge = elementsperedge;
|
||||||
|
|
||||||
|
mparam.secondorder = second_order;
|
||||||
|
mparam.quad = quad_dominated;
|
||||||
|
|
||||||
|
mparam.meshsizefilename = meshsize_filename;
|
||||||
|
|
||||||
|
mparam.optsteps2d = optsteps_2d;
|
||||||
|
mparam.optsteps3d = optsteps_3d;
|
||||||
|
|
||||||
|
mparam.inverttets = invert_tets;
|
||||||
|
mparam.inverttrigs = invert_trigs;
|
||||||
|
|
||||||
|
mparam.checkoverlap = check_overlap;
|
||||||
|
mparam.checkoverlappingboundary = check_overlapping_boundary;
|
||||||
|
}
|
||||||
|
// ------------------ End - Meshing Parameters related functions --------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ------------------ Begin - Second Order Mesh generation functions ----------------
|
||||||
|
DLL_HEADER void Ng_Generate_SecondOrder(Ng_Mesh * mesh)
|
||||||
|
{
|
||||||
|
Refinement ref;
|
||||||
|
ref.MakeSecondOrder(*(Mesh*) mesh);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
DLL_HEADER void Ng_2D_Generate_SecondOrder(Ng_Geometry_2D * geom,
|
||||||
|
Ng_Mesh * mesh)
|
||||||
|
{
|
||||||
|
( (SplineGeometry2d*)geom ) -> GetRefinement().MakeSecondOrder( * (Mesh*) mesh );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
DLL_HEADER void Ng_STL_Generate_SecondOrder(Ng_STL_Geometry * geom,
|
||||||
|
Ng_Mesh * mesh)
|
||||||
|
{
|
||||||
|
((STLGeometry*)geom)->GetRefinement().MakeSecondOrder(*(Mesh*) mesh);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
DLL_HEADER void Ng_CSG_Generate_SecondOrder (Ng_CSG_Geometry * geom,
|
||||||
|
Ng_Mesh * mesh)
|
||||||
|
{
|
||||||
|
((CSGeometry*)geom)->GetRefinement().MakeSecondOrder(*(Mesh*) mesh);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef OCCGEOMETRY
|
||||||
|
DLL_HEADER void Ng_OCC_Generate_SecondOrder (Ng_OCC_Geometry * geom,
|
||||||
|
Ng_Mesh * mesh)
|
||||||
|
{
|
||||||
|
((OCCGeometry*)geom )->GetRefinement().MakeSecondOrder(*(Mesh*) mesh);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
// ------------------ End - Second Order Mesh generation functions ------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ------------------ Begin - Uniform Mesh Refinement functions ---------------------
|
||||||
DLL_HEADER void Ng_Uniform_Refinement (Ng_Mesh * mesh)
|
DLL_HEADER void Ng_Uniform_Refinement (Ng_Mesh * mesh)
|
||||||
{
|
{
|
||||||
Refinement ref;
|
Refinement ref;
|
||||||
ref.Refine ( * (Mesh*) mesh );
|
ref.Refine ( * (Mesh*) mesh );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DLL_HEADER void Ng_2D_Uniform_Refinement (Ng_Geometry_2D * geom,
|
DLL_HEADER void Ng_2D_Uniform_Refinement (Ng_Geometry_2D * geom,
|
||||||
Ng_Mesh * mesh)
|
Ng_Mesh * mesh)
|
||||||
{
|
{
|
||||||
( (SplineGeometry2d*)geom ) -> GetRefinement().Refine ( * (Mesh*) mesh );
|
( (SplineGeometry2d*)geom ) -> GetRefinement().Refine ( * (Mesh*) mesh );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DLL_HEADER void Ng_STL_Uniform_Refinement (Ng_STL_Geometry * geom,
|
DLL_HEADER void Ng_STL_Uniform_Refinement (Ng_STL_Geometry * geom,
|
||||||
Ng_Mesh * mesh)
|
Ng_Mesh * mesh)
|
||||||
{
|
{
|
||||||
( (STLGeometry*)geom ) -> GetRefinement().Refine ( * (Mesh*) mesh );
|
( (STLGeometry*)geom ) -> GetRefinement().Refine ( * (Mesh*) mesh );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DLL_HEADER void Ng_CSG_Uniform_Refinement (Ng_CSG_Geometry * geom,
|
DLL_HEADER void Ng_CSG_Uniform_Refinement (Ng_CSG_Geometry * geom,
|
||||||
Ng_Mesh * mesh)
|
Ng_Mesh * mesh)
|
||||||
{
|
{
|
||||||
@ -937,6 +1059,8 @@ namespace nglib
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef OCCGEOMETRY
|
#ifdef OCCGEOMETRY
|
||||||
DLL_HEADER void Ng_OCC_Uniform_Refinement (Ng_OCC_Geometry * geom,
|
DLL_HEADER void Ng_OCC_Uniform_Refinement (Ng_OCC_Geometry * geom,
|
||||||
Ng_Mesh * mesh)
|
Ng_Mesh * mesh)
|
||||||
@ -944,23 +1068,15 @@ namespace nglib
|
|||||||
( (OCCGeometry*)geom ) -> GetRefinement().Refine ( * (Mesh*) mesh );
|
( (OCCGeometry*)geom ) -> GetRefinement().Refine ( * (Mesh*) mesh );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
// ------------------ End - Uniform Mesh Refinement functions -----------------------
|
||||||
|
|
||||||
|
|
||||||
} // End of namespace nglib
|
} // End of namespace nglib
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// compatibility functions:
|
// compatibility functions:
|
||||||
|
|
||||||
namespace netgen
|
namespace netgen
|
||||||
{
|
{
|
||||||
|
|
||||||
char geomfilename[255];
|
char geomfilename[255];
|
||||||
|
|
||||||
DLL_HEADER void MyError (const char * ch)
|
DLL_HEADER void MyError (const char * ch)
|
||||||
@ -968,31 +1084,45 @@ namespace netgen
|
|||||||
cerr << ch;
|
cerr << ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Destination for messages, errors, ...
|
//Destination for messages, errors, ...
|
||||||
DLL_HEADER void Ng_PrintDest(const char * s)
|
DLL_HEADER void Ng_PrintDest(const char * s)
|
||||||
{
|
{
|
||||||
(*mycout) << s << flush;
|
(*mycout) << s << flush;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DLL_HEADER double GetTime ()
|
DLL_HEADER double GetTime ()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ResetTime ()
|
void ResetTime ()
|
||||||
{
|
{
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void MyBeep (int i)
|
void MyBeep (int i)
|
||||||
{
|
{
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Render()
|
void Render()
|
||||||
{
|
{
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End of namespace netgen
|
} // End of namespace netgen
|
||||||
|
|
||||||
|
@ -104,9 +104,9 @@ public:
|
|||||||
double elementspercurve; //!< Elements to generate per curvature radius
|
double elementspercurve; //!< Elements to generate per curvature radius
|
||||||
|
|
||||||
int closeedgeenable; //!< Enable / Disable mesh refinement at close edges
|
int closeedgeenable; //!< Enable / Disable mesh refinement at close edges
|
||||||
double closeedgefact; //!< Factor to use for refinement at close edges (STL: larger => finer ; OCC: larger => coarser)
|
double closeedgefact; //!< Factor to use for refinement at close edges (larger => finer)
|
||||||
|
|
||||||
int secondorder; //!< Generate second-order surface and volume elements
|
int second_order; //!< Generate second-order surface and volume elements
|
||||||
int quad_dominated; //!< Creates a Quad-dominated mesh
|
int quad_dominated; //!< Creates a Quad-dominated mesh
|
||||||
|
|
||||||
char * meshsize_filename; //!< Optional external mesh size file
|
char * meshsize_filename; //!< Optional external mesh size file
|
||||||
@ -117,6 +117,15 @@ public:
|
|||||||
int optsteps_3d; //!< Number of optimize steps to use for 3-D mesh optimization
|
int optsteps_3d; //!< Number of optimize steps to use for 3-D mesh optimization
|
||||||
int optsteps_2d; //!< Number of optimize steps to use for 2-D mesh optimization
|
int optsteps_2d; //!< Number of optimize steps to use for 2-D mesh optimization
|
||||||
|
|
||||||
|
// Philippose - 13/09/2010
|
||||||
|
// Added a couple more parameters into the meshing parameters list
|
||||||
|
// from Netgen into Nglib
|
||||||
|
int invert_tets; //!< Invert all the volume elements
|
||||||
|
int invert_trigs; //!< Invert all the surface triangle elements
|
||||||
|
|
||||||
|
int check_overlap; //!< Check for overlapping surfaces during Surface meshing
|
||||||
|
int check_overlapping_boundary; //!< Check for overlapping surface elements before volume meshing
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Default constructor for the Mesh Parameters class
|
Default constructor for the Mesh Parameters class
|
||||||
@ -131,13 +140,17 @@ public:
|
|||||||
- #elementspercurve: 2.0
|
- #elementspercurve: 2.0
|
||||||
- #closeedgeenable: 0
|
- #closeedgeenable: 0
|
||||||
- #closeedgefact: 2.0
|
- #closeedgefact: 2.0
|
||||||
- #secondorder: 0.0
|
- #secondorder: 0
|
||||||
- #meshsize_filename: null
|
- #meshsize_filename: null
|
||||||
- #quad_dominated: 0
|
- #quad_dominated: 0
|
||||||
- #optsurfmeshenable: 1
|
- #optsurfmeshenable: 1
|
||||||
- #optvolmeshenable: 1
|
- #optvolmeshenable: 1
|
||||||
- #optsteps_2d: 3
|
- #optsteps_2d: 3
|
||||||
- #optsteps_3d: 3
|
- #optsteps_3d: 3
|
||||||
|
- #invert_tets: 0
|
||||||
|
- #invert_trigs:0
|
||||||
|
- #check_overlap: 1
|
||||||
|
- #check_overlapping_boundary: 1
|
||||||
*/
|
*/
|
||||||
DLL_HEADER Ng_Meshing_Parameters();
|
DLL_HEADER Ng_Meshing_Parameters();
|
||||||
|
|
||||||
@ -150,6 +163,17 @@ public:
|
|||||||
of the object to the default values
|
of the object to the default values
|
||||||
*/
|
*/
|
||||||
DLL_HEADER void Reset_Parameters();
|
DLL_HEADER void Reset_Parameters();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Transfer local meshing parameters to internal meshing parameters
|
||||||
|
|
||||||
|
This member function transfers all the meshing parameters
|
||||||
|
defined in the local meshing parameters structure of nglib into
|
||||||
|
the internal meshing parameters structure used by the Netgen core
|
||||||
|
*/
|
||||||
|
DLL_HEADER void Transfer_Parameters();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -636,14 +660,10 @@ DLL_HEADER Ng_Result Ng_OCC_GetFMap(Ng_OCC_Geometry * geom,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// **********************************************************
|
// **********************************************************
|
||||||
// ** Mesh refinement algorithms **
|
// ** Mesh refinement algorithms **
|
||||||
// **********************************************************
|
// **********************************************************
|
||||||
|
|
||||||
|
|
||||||
// uniform mesh refinement
|
// uniform mesh refinement
|
||||||
DLL_HEADER void Ng_Uniform_Refinement (Ng_Mesh * mesh);
|
DLL_HEADER void Ng_Uniform_Refinement (Ng_Mesh * mesh);
|
||||||
|
|
||||||
@ -666,4 +686,29 @@ DLL_HEADER void Ng_OCC_Uniform_Refinement (Ng_OCC_Geometry * geom,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// **********************************************************
|
||||||
|
// ** Second Order mesh algorithms **
|
||||||
|
// **********************************************************
|
||||||
|
|
||||||
|
// convert mesh to second order
|
||||||
|
DLL_HEADER void Ng_Generate_SecondOrder (Ng_Mesh * mesh);
|
||||||
|
|
||||||
|
|
||||||
|
// convert mesh to second order with geometry adaption:
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
#ifdef OCCGEOMETRY
|
||||||
|
DLL_HEADER void Ng_OCC_Generate_SecondOrder (Ng_OCC_Geometry * geom,
|
||||||
|
Ng_Mesh * mesh);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif // NGLIB
|
#endif // NGLIB
|
||||||
|
Loading…
Reference in New Issue
Block a user