mirror of
https://github.com/NGSolve/netgen.git
synced 2024-11-11 16:49:16 +05:00
thread-safe CSG crosspoints and edges
This commit is contained in:
parent
b51df253fd
commit
30d708f487
@ -10,15 +10,19 @@
|
|||||||
|
|
||||||
namespace netgen
|
namespace netgen
|
||||||
{
|
{
|
||||||
NgArray<SpecialPoint> specpoints;
|
|
||||||
static NgArray<MeshPoint> spoints;
|
NgArray<SpecialPoint> global_specpoints; // for visualization
|
||||||
|
//static NgArray<MeshPoint> spoints;
|
||||||
|
|
||||||
#define TCL_OK 0
|
#define TCL_OK 0
|
||||||
#define TCL_ERROR 1
|
#define TCL_ERROR 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void FindPoints (CSGeometry & geom, Mesh & mesh)
|
static void FindPoints (CSGeometry & geom,
|
||||||
|
NgArray<SpecialPoint> & specpoints,
|
||||||
|
NgArray<MeshPoint> & spoints,
|
||||||
|
Mesh & mesh)
|
||||||
{
|
{
|
||||||
PrintMessage (1, "Start Findpoints");
|
PrintMessage (1, "Start Findpoints");
|
||||||
|
|
||||||
@ -49,6 +53,12 @@ namespace netgen
|
|||||||
PrintMessage (2, "Analyze spec points");
|
PrintMessage (2, "Analyze spec points");
|
||||||
spc.AnalyzeSpecialPoints (geom, spoints, specpoints);
|
spc.AnalyzeSpecialPoints (geom, spoints, specpoints);
|
||||||
|
|
||||||
|
{
|
||||||
|
static mutex mut;
|
||||||
|
lock_guard<mutex> guard(mut);
|
||||||
|
global_specpoints = specpoints;
|
||||||
|
}
|
||||||
|
|
||||||
PrintMessage (5, "done");
|
PrintMessage (5, "done");
|
||||||
|
|
||||||
(*testout) << specpoints.Size() << " special points:" << endl;
|
(*testout) << specpoints.Size() << " special points:" << endl;
|
||||||
@ -67,7 +77,10 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void FindEdges (CSGeometry & geom, Mesh & mesh, MeshingParameters & mparam,
|
static void FindEdges (CSGeometry & geom, Mesh & mesh,
|
||||||
|
NgArray<SpecialPoint> & specpoints,
|
||||||
|
NgArray<MeshPoint> & spoints,
|
||||||
|
MeshingParameters & mparam,
|
||||||
const bool setmeshsize = false)
|
const bool setmeshsize = false)
|
||||||
{
|
{
|
||||||
EdgeCalculation ec (geom, specpoints, mparam);
|
EdgeCalculation ec (geom, specpoints, mparam);
|
||||||
@ -669,6 +682,10 @@ namespace netgen
|
|||||||
int CSGGenerateMesh (CSGeometry & geom,
|
int CSGGenerateMesh (CSGeometry & geom,
|
||||||
shared_ptr<Mesh> & mesh, MeshingParameters & mparam)
|
shared_ptr<Mesh> & mesh, MeshingParameters & mparam)
|
||||||
{
|
{
|
||||||
|
NgArray<SpecialPoint> specpoints;
|
||||||
|
NgArray<MeshPoint> spoints;
|
||||||
|
|
||||||
|
|
||||||
if (mesh && mesh->GetNSE() &&
|
if (mesh && mesh->GetNSE() &&
|
||||||
!geom.GetNSolids())
|
!geom.GetNSolids())
|
||||||
{
|
{
|
||||||
@ -705,7 +722,7 @@ namespace netgen
|
|||||||
}
|
}
|
||||||
|
|
||||||
spoints.SetSize(0);
|
spoints.SetSize(0);
|
||||||
FindPoints (geom, *mesh);
|
FindPoints (geom, specpoints, spoints, *mesh);
|
||||||
|
|
||||||
PrintMessage (5, "find points done");
|
PrintMessage (5, "find points done");
|
||||||
|
|
||||||
@ -723,7 +740,7 @@ namespace netgen
|
|||||||
|
|
||||||
if (mparam.perfstepsstart <= MESHCONST_MESHEDGES)
|
if (mparam.perfstepsstart <= MESHCONST_MESHEDGES)
|
||||||
{
|
{
|
||||||
FindEdges (geom, *mesh, mparam, true);
|
FindEdges (geom, *mesh, specpoints, spoints, mparam, true);
|
||||||
if (multithread.terminate) return TCL_OK;
|
if (multithread.terminate) return TCL_OK;
|
||||||
#ifdef LOG_STREAM
|
#ifdef LOG_STREAM
|
||||||
(*logout) << "Edges meshed" << endl
|
(*logout) << "Edges meshed" << endl
|
||||||
@ -740,16 +757,16 @@ namespace netgen
|
|||||||
mesh->CalcLocalH(mparam.grading);
|
mesh->CalcLocalH(mparam.grading);
|
||||||
mesh->DeleteMesh();
|
mesh->DeleteMesh();
|
||||||
|
|
||||||
FindPoints (geom, *mesh);
|
FindPoints (geom, specpoints, spoints, *mesh);
|
||||||
if (multithread.terminate) return TCL_OK;
|
if (multithread.terminate) return TCL_OK;
|
||||||
FindEdges (geom, *mesh, mparam, true);
|
FindEdges (geom, *mesh, specpoints, spoints, mparam, true);
|
||||||
if (multithread.terminate) return TCL_OK;
|
if (multithread.terminate) return TCL_OK;
|
||||||
|
|
||||||
mesh->DeleteMesh();
|
mesh->DeleteMesh();
|
||||||
|
|
||||||
FindPoints (geom, *mesh);
|
FindPoints (geom, specpoints, spoints, *mesh);
|
||||||
if (multithread.terminate) return TCL_OK;
|
if (multithread.terminate) return TCL_OK;
|
||||||
FindEdges (geom, *mesh, mparam);
|
FindEdges (geom, *mesh, specpoints, spoints, mparam);
|
||||||
if (multithread.terminate) return TCL_OK;
|
if (multithread.terminate) return TCL_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
namespace netgen
|
namespace netgen
|
||||||
{
|
{
|
||||||
NgArray<Box<3> > boxes;
|
NgArray<Box<3> > boxes; // for visualizaton
|
||||||
|
|
||||||
|
|
||||||
void ProjectToEdge (const Surface * f1, const Surface * f2, Point<3> & hp);
|
void ProjectToEdge (const Surface * f1, const Surface * f2, Point<3> & hp);
|
||||||
@ -64,7 +64,7 @@ namespace netgen
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static NgArray<int> numprim_hist;
|
// static NgArray<int> numprim_hist;
|
||||||
|
|
||||||
SpecialPointCalculation :: SpecialPointCalculation ()
|
SpecialPointCalculation :: SpecialPointCalculation ()
|
||||||
{
|
{
|
||||||
@ -75,8 +75,8 @@ namespace netgen
|
|||||||
CalcSpecialPoints (const CSGeometry & ageometry,
|
CalcSpecialPoints (const CSGeometry & ageometry,
|
||||||
NgArray<MeshPoint> & apoints)
|
NgArray<MeshPoint> & apoints)
|
||||||
{
|
{
|
||||||
static int timer = NgProfiler::CreateTimer ("CSG: find special points");
|
// static int timer = NgProfiler::CreateTimer ("CSG: find special points");
|
||||||
NgProfiler::RegionTimer reg (timer);
|
// NgProfiler::RegionTimer reg (timer);
|
||||||
|
|
||||||
|
|
||||||
geometry = &ageometry;
|
geometry = &ageometry;
|
||||||
@ -100,8 +100,8 @@ namespace netgen
|
|||||||
box.CalcDiamCenter();
|
box.CalcDiamCenter();
|
||||||
PrintMessage (3, "main-solids: ", geometry->GetNTopLevelObjects());
|
PrintMessage (3, "main-solids: ", geometry->GetNTopLevelObjects());
|
||||||
|
|
||||||
numprim_hist.SetSize (geometry->GetNSurf()+1);
|
// numprim_hist.SetSize (geometry->GetNSurf()+1);
|
||||||
numprim_hist = 0;
|
// numprim_hist = 0;
|
||||||
|
|
||||||
for (int i = 0; i < geometry->GetNTopLevelObjects(); i++)
|
for (int i = 0; i < geometry->GetNTopLevelObjects(); i++)
|
||||||
{
|
{
|
||||||
@ -161,10 +161,12 @@ namespace netgen
|
|||||||
|
|
||||||
PrintMessage (3, "Found points ", apoints.Size());
|
PrintMessage (3, "Found points ", apoints.Size());
|
||||||
|
|
||||||
|
/*
|
||||||
for (int i = 0; i < boxesinlevel.Size(); i++)
|
for (int i = 0; i < boxesinlevel.Size(); i++)
|
||||||
(*testout) << "level " << i << " has "
|
(*testout) << "level " << i << " has "
|
||||||
<< boxesinlevel[i] << " boxes" << endl;
|
<< boxesinlevel[i] << " boxes" << endl;
|
||||||
(*testout) << "numprim_histogramm = " << endl << numprim_hist << endl;
|
(*testout) << "numprim_histogramm = " << endl << numprim_hist << endl;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -184,8 +186,8 @@ namespace netgen
|
|||||||
|
|
||||||
if (multithread.terminate)
|
if (multithread.terminate)
|
||||||
{
|
{
|
||||||
*testout << "boxes = " << boxes << endl;
|
// *testout << "boxes = " << boxes << endl;
|
||||||
*testout << "boxesinlevel = " << boxesinlevel << endl;
|
// *testout << "boxesinlevel = " << boxesinlevel << endl;
|
||||||
throw NgException ("Meshing stopped");
|
throw NgException ("Meshing stopped");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,11 +217,12 @@ namespace netgen
|
|||||||
|
|
||||||
// static int cntbox = 0;
|
// static int cntbox = 0;
|
||||||
// cntbox++;
|
// cntbox++;
|
||||||
|
/*
|
||||||
if (level <= boxesinlevel.Size())
|
if (level <= boxesinlevel.Size())
|
||||||
boxesinlevel.Elem(level)++;
|
boxesinlevel.Elem(level)++;
|
||||||
else
|
else
|
||||||
boxesinlevel.Append (1);
|
boxesinlevel.Append (1);
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
numprim = sol -> NumPrimitives();
|
numprim = sol -> NumPrimitives();
|
||||||
@ -233,7 +236,7 @@ namespace netgen
|
|||||||
(*testout) << "numprim = " << numprim << endl;
|
(*testout) << "numprim = " << numprim << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
numprim_hist[numprim]++;
|
// numprim_hist[numprim]++;
|
||||||
|
|
||||||
Point<3> p = box.Center();
|
Point<3> p = box.Center();
|
||||||
|
|
||||||
|
@ -18,7 +18,9 @@ namespace netgen
|
|||||||
/* *********************** Draw Geometry **************** */
|
/* *********************** Draw Geometry **************** */
|
||||||
|
|
||||||
extern shared_ptr<Mesh> mesh;
|
extern shared_ptr<Mesh> mesh;
|
||||||
extern NgArray<SpecialPoint> specpoints;
|
extern NgArray<SpecialPoint> global_specpoints;
|
||||||
|
NgArray<SpecialPoint> & specpoints = global_specpoints;
|
||||||
|
|
||||||
extern NgArray<Box<3> > boxes;
|
extern NgArray<Box<3> > boxes;
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ namespace netgen
|
|||||||
|
|
||||||
BlockAllocator :: ~BlockAllocator ()
|
BlockAllocator :: ~BlockAllocator ()
|
||||||
{
|
{
|
||||||
|
lock_guard<mutex> guard(block_allocator_mutex);
|
||||||
// cout << "****************** delete BlockAllocator " << endl;
|
// cout << "****************** delete BlockAllocator " << endl;
|
||||||
for (int i = 0; i < bablocks.Size(); i++)
|
for (int i = 0; i < bablocks.Size(); i++)
|
||||||
delete [] bablocks[i];
|
delete [] bablocks[i];
|
||||||
|
@ -400,23 +400,23 @@ namespace netgen
|
|||||||
const float * bmax,
|
const float * bmax,
|
||||||
NgArray<int> & pis) const
|
NgArray<int> & pis) const
|
||||||
{
|
{
|
||||||
static NgArray<ADTreeNode3*> stack(1000);
|
ArrayMem<ADTreeNode3*, 1000> stack(1000);
|
||||||
static NgArray<int> stackdir(1000);
|
ArrayMem<int, 1000> stackdir(1000);
|
||||||
ADTreeNode3 * node;
|
ADTreeNode3 * node;
|
||||||
int dir, stacks;
|
int dir, stacks;
|
||||||
|
|
||||||
stack.SetSize (1000);
|
// stack.SetSize (1000);
|
||||||
stackdir.SetSize(1000);
|
// stackdir.SetSize(1000);
|
||||||
pis.SetSize(0);
|
pis.SetSize(0);
|
||||||
|
|
||||||
stack.Elem(1) = root;
|
stack[0] = root;
|
||||||
stackdir.Elem(1) = 0;
|
stackdir[0] = 0;
|
||||||
stacks = 1;
|
stacks = 0;
|
||||||
|
|
||||||
while (stacks)
|
while (stacks >= 0)
|
||||||
{
|
{
|
||||||
node = stack.Get(stacks);
|
node = stack[stacks];
|
||||||
dir = stackdir.Get(stacks);
|
dir = stackdir[stacks];
|
||||||
stacks--;
|
stacks--;
|
||||||
|
|
||||||
if (node->pi != -1)
|
if (node->pi != -1)
|
||||||
@ -436,14 +436,14 @@ namespace netgen
|
|||||||
if (node->left && bmin[dir] <= node->sep)
|
if (node->left && bmin[dir] <= node->sep)
|
||||||
{
|
{
|
||||||
stacks++;
|
stacks++;
|
||||||
stack.Elem(stacks) = node->left;
|
stack[stacks] = node->left;
|
||||||
stackdir.Elem(stacks) = ndir;
|
stackdir[stacks] = ndir;
|
||||||
}
|
}
|
||||||
if (node->right && bmax[dir] >= node->sep)
|
if (node->right && bmax[dir] >= node->sep)
|
||||||
{
|
{
|
||||||
stacks++;
|
stacks++;
|
||||||
stack.Elem(stacks) = node->right;
|
stack[stacks] = node->right;
|
||||||
stackdir.Elem(stacks) = ndir;
|
stackdir[stacks] = ndir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,10 @@ namespace netgen
|
|||||||
static Timer t("Mesing2::Meshing2"); RegionTimer r(t);
|
static Timer t("Mesing2::Meshing2"); RegionTimer r(t);
|
||||||
|
|
||||||
auto & globalrules = mp.quad ? global_quad_rules : global_trig_rules;
|
auto & globalrules = mp.quad ? global_quad_rules : global_trig_rules;
|
||||||
|
|
||||||
|
{
|
||||||
|
static mutex mut;
|
||||||
|
lock_guard<mutex> guard(mut);
|
||||||
if (!globalrules.Size())
|
if (!globalrules.Size())
|
||||||
{
|
{
|
||||||
LoadRules (NULL, mp.quad);
|
LoadRules (NULL, mp.quad);
|
||||||
@ -57,6 +61,7 @@ namespace netgen
|
|||||||
for (auto i : globalrules.Range())
|
for (auto i : globalrules.Range())
|
||||||
rules.Append (globalrules[i].get());
|
rules.Append (globalrules[i].get());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// LoadRules ("rules/quad.rls");
|
// LoadRules ("rules/quad.rls");
|
||||||
// LoadRules ("rules/triangle.rls");
|
// LoadRules ("rules/triangle.rls");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user