mirror of
https://github.com/NGSolve/netgen.git
synced 2025-02-14 22:33:08 +05:00
more ngcore arrays
This commit is contained in:
parent
7afcaf3406
commit
fd0421d573
@ -300,7 +300,7 @@ namespace ngcore
|
||||
|
||||
|
||||
template <int N, typename TI>
|
||||
NETGEN_INLINE size_t HashValue2 (const IVec<N,TI> & ind, size_t mask)
|
||||
NETGEN_INLINE constexpr size_t HashValue2 (const IVec<N,TI> & ind, size_t mask)
|
||||
{
|
||||
IVec<N,size_t> lind = ind;
|
||||
size_t sum = 0;
|
||||
@ -311,14 +311,14 @@ namespace ngcore
|
||||
|
||||
/// hash value of 1 int
|
||||
template <typename TI>
|
||||
NETGEN_INLINE size_t HashValue2 (const IVec<1,TI> & ind, size_t mask)
|
||||
NETGEN_INLINE constexpr size_t HashValue2 (const IVec<1,TI> & ind, size_t mask)
|
||||
{
|
||||
return ind[0] & mask;
|
||||
}
|
||||
|
||||
/// hash value of 2 int
|
||||
template <typename TI>
|
||||
NETGEN_INLINE size_t HashValue2 (const IVec<2,TI> & ind, size_t mask)
|
||||
NETGEN_INLINE constexpr size_t HashValue2 (const IVec<2,TI> & ind, size_t mask)
|
||||
{
|
||||
IVec<2,size_t> lind = ind;
|
||||
return (113*lind[0]+lind[1]) & mask;
|
||||
@ -326,17 +326,17 @@ namespace ngcore
|
||||
|
||||
/// hash value of 3 int
|
||||
template <typename TI>
|
||||
NETGEN_INLINE size_t HashValue2 (const IVec<3,TI> & ind, size_t mask)
|
||||
NETGEN_INLINE constexpr size_t HashValue2 (const IVec<3,TI> & ind, size_t mask)
|
||||
{
|
||||
IVec<3,size_t> lind = ind;
|
||||
return (113*lind[0]+59*lind[1]+lind[2]) & mask;
|
||||
}
|
||||
|
||||
NETGEN_INLINE size_t HashValue2 (size_t ind, size_t mask)
|
||||
NETGEN_INLINE constexpr size_t HashValue2 (size_t ind, size_t mask)
|
||||
{
|
||||
return ind & mask;
|
||||
}
|
||||
NETGEN_INLINE size_t HashValue2 (int ind, size_t mask)
|
||||
NETGEN_INLINE constexpr size_t HashValue2 (int ind, size_t mask)
|
||||
{
|
||||
return size_t(ind) & mask;
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ Meshing3 :: Meshing3 (const string & rulefilename)
|
||||
canuse.SetSize (rules.Size());
|
||||
ruleused.SetSize (rules.Size());
|
||||
|
||||
/*
|
||||
for (int i = 1; i <= rules.Size(); i++)
|
||||
{
|
||||
problems.Elem(i) = new char[255];
|
||||
@ -38,6 +39,11 @@ Meshing3 :: Meshing3 (const string & rulefilename)
|
||||
canuse.Elem(i) = 0;
|
||||
ruleused.Elem(i) = 0;
|
||||
}
|
||||
*/
|
||||
|
||||
foundmap = 0;
|
||||
canuse = 0;
|
||||
ruleused = 0;
|
||||
}
|
||||
|
||||
|
||||
@ -53,6 +59,7 @@ Meshing3 :: Meshing3 (const char ** rulep)
|
||||
canuse.SetSize (rules.Size());
|
||||
ruleused.SetSize (rules.Size());
|
||||
|
||||
/*
|
||||
for (int i = 0; i < rules.Size(); i++)
|
||||
{
|
||||
problems[i] = new char[255];
|
||||
@ -60,16 +67,22 @@ Meshing3 :: Meshing3 (const char ** rulep)
|
||||
canuse[i] = 0;
|
||||
ruleused[i] = 0;
|
||||
}
|
||||
*/
|
||||
foundmap = 0;
|
||||
canuse = 0;
|
||||
ruleused = 0;
|
||||
}
|
||||
|
||||
Meshing3 :: ~Meshing3 ()
|
||||
{
|
||||
// delete adfront;
|
||||
/*
|
||||
for (int i = 0; i < rules.Size(); i++)
|
||||
{
|
||||
delete [] problems[i];
|
||||
delete rules[i];
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@ -184,12 +197,13 @@ GenerateMesh (Mesh & mesh, const MeshingParameters & mp)
|
||||
Array<Point3d, PointIndex> locpoints; // local points
|
||||
Array<MiniElement2d> locfaces; // local faces
|
||||
Array<PointIndex, PointIndex> pindex; // mapping from local to front point numbering
|
||||
Array<int, PointIndex> allowpoint; // point is allowed ?
|
||||
Array<int, PointIndex> allowpoint; // point is allowed (0/1/2) ?
|
||||
Array<INDEX> findex; // mapping from local to front face numbering
|
||||
//INDEX_2_HASHTABLE<int> connectedpairs(100); // connecgted pairs for prism meshing
|
||||
|
||||
Array<Point3d, PointIndex> plainpoints; // points in reference coordinates
|
||||
NgArray<int> delpoints, delfaces; // points and lines to be deleted
|
||||
// NgArray<int> delpoints; // points to be deleted
|
||||
NgArray<int> delfaces; // lines to be deleted
|
||||
NgArray<Element> locelements; // new generated elements
|
||||
|
||||
int j, oldnp, oldnf;
|
||||
@ -378,8 +392,8 @@ GenerateMesh (Mesh & mesh, const MeshingParameters & mp)
|
||||
{
|
||||
(*testout) << "inner point found" << endl;
|
||||
|
||||
for(int i = 1; i <= groupfaces.Size(); i++)
|
||||
adfront -> DeleteFace (groupfindex[i-1]);
|
||||
for(int i = 0; i < groupfaces.Size(); i++)
|
||||
adfront -> DeleteFace (groupfindex[i]);
|
||||
|
||||
for(int i = 1; i <= groupfaces.Size(); i++)
|
||||
for (j = 1; j <= locfaces.Size(); j++)
|
||||
@ -469,12 +483,12 @@ GenerateMesh (Mesh & mesh, const MeshingParameters & mp)
|
||||
if (stat.cnttrials % 100 == 0)
|
||||
{
|
||||
(*testout) << "\n";
|
||||
for(int i = 1; i <= canuse.Size(); i++)
|
||||
{
|
||||
(*testout) << foundmap.Get(i) << "/"
|
||||
<< canuse.Get(i) << "/"
|
||||
<< ruleused.Get(i) << " map/can/use rule " << rules.Get(i)->Name() << "\n";
|
||||
}
|
||||
for(int i : canuse.Range())
|
||||
{
|
||||
(*testout) << foundmap[i] << "/"
|
||||
<< canuse[i] << "/"
|
||||
<< ruleused[i] << " map/can/use rule " << rules[i]->Name() << "\n";
|
||||
}
|
||||
(*testout) << endl;
|
||||
}
|
||||
|
||||
@ -545,7 +559,7 @@ GenerateMesh (Mesh & mesh, const MeshingParameters & mp)
|
||||
|
||||
|
||||
if (found)
|
||||
ruleused.Elem(found)++;
|
||||
ruleused[found-1]++;
|
||||
|
||||
|
||||
// plotstat->Plot(stat);
|
||||
@ -710,7 +724,7 @@ GenerateMesh (Mesh & mesh, const MeshingParameters & mp)
|
||||
}
|
||||
|
||||
locelements.SetSize (0);
|
||||
delpoints.SetSize(0);
|
||||
// delpoints.SetSize(0);
|
||||
delfaces.SetSize(0);
|
||||
|
||||
if (stat.qualclass >= mp.giveuptol)
|
||||
@ -719,9 +733,9 @@ GenerateMesh (Mesh & mesh, const MeshingParameters & mp)
|
||||
|
||||
PrintMessage (5, ""); // line feed after statistics
|
||||
|
||||
for(int i = 1; i <= ruleused.Size(); i++)
|
||||
(*testout) << setw(4) << ruleused.Get(i)
|
||||
<< " times used rule " << rules.Get(i) -> Name() << endl;
|
||||
for(int i : ruleused.Range())
|
||||
(*testout) << setw(4) << ruleused[i]
|
||||
<< " times used rule " << rules[i] -> Name() << endl;
|
||||
|
||||
|
||||
if (!mp.baseelnp && adfront->Empty())
|
||||
|
@ -24,11 +24,11 @@ class Meshing3
|
||||
/// current state of front
|
||||
unique_ptr<AdFront3> adfront;
|
||||
/// 3d generation rules
|
||||
NgArray<vnetrule*> rules;
|
||||
Array<unique_ptr<vnetrule>> rules;
|
||||
/// counts how often a rule is used
|
||||
NgArray<int> ruleused, canuse, foundmap;
|
||||
Array<int> ruleused, canuse, foundmap;
|
||||
/// describes, why a rule is not applied
|
||||
NgArray<char*> problems;
|
||||
Array<string> problems;
|
||||
/// tolerance criterion
|
||||
double tolfak;
|
||||
public:
|
||||
|
@ -1014,14 +1014,15 @@ void Meshing3 :: LoadRules (const char * filename, const char ** prules)
|
||||
|
||||
if (strcmp (buf, "rule") == 0)
|
||||
{
|
||||
vnetrule * rule = new vnetrule;
|
||||
// vnetrule * rule = new vnetrule;
|
||||
auto rule = make_unique<vnetrule>();
|
||||
rule -> LoadRule(*ist);
|
||||
rules.Append (rule);
|
||||
if (!rule->TestOk())
|
||||
{
|
||||
PrintSysError ("Parser3d: Rule ", rules.Size(), " not ok");
|
||||
exit (1);
|
||||
}
|
||||
rules.Append (std::move(rule));
|
||||
}
|
||||
else if (strcmp (buf, "tolfak") == 0)
|
||||
{
|
||||
|
@ -226,16 +226,17 @@ int Meshing3 :: ApplyRules
|
||||
// check each rule:
|
||||
// tstart.Stop();
|
||||
// tloop.Start();
|
||||
for (int ri = 1; ri <= rules.Size(); ri++)
|
||||
for (int rim = 0; rim < rules.Size(); rim++)
|
||||
{
|
||||
int base = (lfaces[0].GetNP() == 3) ? 100 : 200;
|
||||
NgProfiler::RegionTimer regx1(base);
|
||||
NgProfiler::RegionTimer regx(base+ri);
|
||||
NgProfiler::RegionTimer regx(base+rim+1);
|
||||
|
||||
// sprintf (problems.Elem(ri), "");
|
||||
*problems.Elem(ri) = '\0';
|
||||
// *problems.Elem(ri) = '\0';
|
||||
problems[rim] = "";
|
||||
|
||||
vnetrule * rule = rules.Get(ri);
|
||||
vnetrule * rule = rules[rim].get();
|
||||
|
||||
if (rule->GetNP(1) != lfaces[0].GetNP())
|
||||
continue;
|
||||
@ -245,17 +246,17 @@ int Meshing3 :: ApplyRules
|
||||
if (rule->GetQuality() < 100) impossible = 0;
|
||||
|
||||
if (testmode)
|
||||
snprintf (problems.Elem(ri), 255, "Quality not ok");
|
||||
problems[rim] = "Quality not ok";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (testmode)
|
||||
snprintf (problems.Elem(ri), 255, "no mapping found");
|
||||
problems[rim] = "no mapping found";
|
||||
|
||||
loktestmode = testmode || rule->TestFlag ('t') || tolerance > 5;
|
||||
|
||||
if (loktestmode)
|
||||
(*testout) << "Rule " << ri << " = " << rule->Name() << endl;
|
||||
(*testout) << "Rule " << rim+1 << " = " << rule->Name() << endl;
|
||||
|
||||
pmap.SetSize (rule->GetNP());
|
||||
fmapi.SetSize (rule->GetNF());
|
||||
@ -287,7 +288,7 @@ int Meshing3 :: ApplyRules
|
||||
|
||||
int nfok = 2;
|
||||
NgProfiler::RegionTimer regfa(300);
|
||||
NgProfiler::RegionTimer regx2(base+50+ri);
|
||||
NgProfiler::RegionTimer regx2(base+50+rim+1);
|
||||
while (nfok >= 2)
|
||||
{
|
||||
|
||||
@ -419,7 +420,7 @@ int Meshing3 :: ApplyRules
|
||||
if (loktestmode)
|
||||
{
|
||||
(*testout) << "Faces Ok" << endl;
|
||||
snprintf (problems.Elem(ri), 255, "Faces Ok");
|
||||
problems[rim] = "Faces Ok";
|
||||
}
|
||||
|
||||
int npok = 1;
|
||||
@ -527,7 +528,7 @@ int Meshing3 :: ApplyRules
|
||||
for (auto pi : pmap)
|
||||
(*testout) << pi << " ";
|
||||
(*testout) << endl;
|
||||
snprintf (problems.Elem(ri), 255, "mapping found");
|
||||
problems[rim] = "mapping found";
|
||||
(*testout) << rule->GetNP(1) << " = " << lfaces[0].GetNP() << endl;
|
||||
}
|
||||
|
||||
@ -594,10 +595,7 @@ int Meshing3 :: ApplyRules
|
||||
|
||||
|
||||
if (ok)
|
||||
{
|
||||
foundmap.Elem(ri)++;
|
||||
}
|
||||
|
||||
foundmap[rim]++;
|
||||
|
||||
|
||||
|
||||
@ -642,7 +640,7 @@ int Meshing3 :: ApplyRules
|
||||
if (!rule->ConvexFreeZone())
|
||||
{
|
||||
ok = 0;
|
||||
snprintf (problems.Elem(ri), 255, "Freezone not convex");
|
||||
problems[rim] = "Freezone not convex";
|
||||
|
||||
if (loktestmode)
|
||||
(*testout) << "Freezone not convex" << endl;
|
||||
@ -674,8 +672,7 @@ int Meshing3 :: ApplyRules
|
||||
{
|
||||
(*testout) << "Point " << i
|
||||
<< " in Freezone" << endl;
|
||||
snprintf (problems.Elem(ri), 255,
|
||||
"locpoint %d in Freezone", int(i));
|
||||
problems[rim] = "locpoint " + ToString(i) + " in Freezone";
|
||||
}
|
||||
ok = 0;
|
||||
break;
|
||||
@ -788,10 +785,9 @@ int Meshing3 :: ApplyRules
|
||||
<< lpoints[lfacei.PNum(4)]
|
||||
<< endl;
|
||||
|
||||
snprintf (problems.Elem(ri), 255, "triangle (%d, %d, %d) in Freezone",
|
||||
int(lfaces[i-1].PNum(1)),
|
||||
int(lfaces[i-1].PNum(2)),
|
||||
int(lfaces[i-1].PNum(3)));
|
||||
problems[rim] = "triangle ("+ToString(lfaces[i-1].PNum(1))+", "
|
||||
+ ToString(lfaces[i-1].PNum(2)) + ", "
|
||||
+ ToString(lfaces[i-1].PNum(3)) + ") in Freezone";
|
||||
}
|
||||
|
||||
hc = 0;
|
||||
@ -817,7 +813,7 @@ int Meshing3 :: ApplyRules
|
||||
// << " - " << pmap.Get (rule->GetPointNr(k, 3)) << " ) "
|
||||
// << endl;
|
||||
|
||||
strcpy (problems.Elem(ri), "other");
|
||||
problems[rim] = "other";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -831,10 +827,17 @@ int Meshing3 :: ApplyRules
|
||||
<< lfaces[i-1].PNum(2) << " - "
|
||||
<< lfaces[i-1].PNum(3) << endl;
|
||||
|
||||
/*
|
||||
snprintf (problems.Elem(ri), 255, "triangle (%d, %d, %d) in Freezone",
|
||||
int (lfaces[i-1].PNum(1)),
|
||||
int (lfaces[i-1].PNum(2)),
|
||||
int (lfaces[i-1].PNum(3)));
|
||||
*/
|
||||
problems[rim] = "triangle ("
|
||||
+ ToString(lfaces[i-1].PNum(1))+", "
|
||||
+ ToString(lfaces[i-1].PNum(2)) + ", "
|
||||
+ ToString(lfaces[i-1].PNum(3)) + ") in Freezone";
|
||||
|
||||
}
|
||||
ok = 0;
|
||||
}
|
||||
@ -858,7 +861,7 @@ int Meshing3 :: ApplyRules
|
||||
if (loktestmode)
|
||||
{
|
||||
(*testout) << "Rule ok" << endl;
|
||||
snprintf (problems.Elem(ri), 255, "Rule ok, err = %f", err);
|
||||
problems[rim] = "Rule ok, err = "+ToString(err);
|
||||
}
|
||||
|
||||
|
||||
@ -923,7 +926,7 @@ int Meshing3 :: ApplyRules
|
||||
{
|
||||
if (loktestmode)
|
||||
{
|
||||
snprintf (problems.Elem(ri), 255, "Orientation wrong");
|
||||
problems[rim] = "Orientation wrong";
|
||||
(*testout) << "Orientation wrong ("<< n*v3 << ")" << endl;
|
||||
}
|
||||
ok = 0;
|
||||
@ -940,7 +943,7 @@ int Meshing3 :: ApplyRules
|
||||
{
|
||||
(*testout) << "Newpoint " << lpoints[pmap.Get(i)]
|
||||
<< " outside convex hull" << endl;
|
||||
snprintf (problems.Elem(ri), 255, "newpoint outside convex hull");
|
||||
problems[rim] = "newpoint outside convex hull";
|
||||
}
|
||||
ok = 0;
|
||||
|
||||
@ -1015,7 +1018,7 @@ int Meshing3 :: ApplyRules
|
||||
{
|
||||
ok = 0;
|
||||
if (loktestmode)
|
||||
snprintf (problems.Elem(ri), 255, "oldlen < newlen");
|
||||
problems[rim] = "oldlen < newlen";
|
||||
}
|
||||
}
|
||||
|
||||
@ -1028,7 +1031,7 @@ int Meshing3 :: ApplyRules
|
||||
|
||||
if (ok && teterr < tolerance)
|
||||
{
|
||||
canuse.Elem(ri) ++;
|
||||
canuse[rim] ++;
|
||||
/*
|
||||
(*testout) << "can use rule " << rule->Name()
|
||||
<< ", err = " << teterr << endl;
|
||||
@ -1037,7 +1040,7 @@ int Meshing3 :: ApplyRules
|
||||
(*testout) << endl;
|
||||
*/
|
||||
|
||||
if (strcmp (problems.Elem(ri), "other") == 0)
|
||||
if (problems[rim] == "other")
|
||||
{
|
||||
if (teterr < minother)
|
||||
minother = teterr;
|
||||
@ -1058,7 +1061,7 @@ int Meshing3 :: ApplyRules
|
||||
if (loktestmode)
|
||||
(*testout) << "use rule" << endl;
|
||||
|
||||
found = ri;
|
||||
found = rim+1;
|
||||
minteterr = teterr;
|
||||
|
||||
if (testmode)
|
||||
|
Loading…
Reference in New Issue
Block a user