本文整理汇总了C++中Mesh::AddSurfaceElement方法的典型用法代码示例。如果您正苦于以下问题:C++ Mesh::AddSurfaceElement方法的具体用法?C++ Mesh::AddSurfaceElement怎么用?C++ Mesh::AddSurfaceElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mesh
的用法示例。
在下文中一共展示了Mesh::AddSurfaceElement方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Ng_AddSurfaceElement
// 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,
int * pi)
{
Mesh * m = (Mesh*)mesh;
Element2d el (3);
el.SetIndex (1);
el.PNum(1) = pi[0];
el.PNum(2) = pi[1];
el.PNum(3) = pi[2];
m->AddSurfaceElement (el);
}
示例2: GenerateBoundaryLayer
//.........这里部分代码省略.........
double surfangle = Angle(growthvectors.Elem(segpair_p1),surfelem_vect);
dbg << "V1= " << surfelem_vect1
<< " : V2= " << surfelem_vect1
<< " : V= " << surfelem_vect
<< " : GV= " << growthvectors.Elem(segpair_p1)
<< " : Angle= " << surfangle * 180 / 3.141592;
// remap the segments to the new points
mesh.LineSegment(i)[0] = mapto.Get(seg_p1);
mesh.LineSegment(i)[1] = mapto.Get(seg_p2);
mesh.LineSegment(j)[1] = mapto.Get(seg_p1);
mesh.LineSegment(j)[0] = mapto.Get(seg_p2);
if((surfangle < (90 + angleThreshold) * 3.141592 / 180.0)
&& (surfangle > (90 - angleThreshold) * 3.141592 / 180.0))
{
dbg << " : quad\n";
// Since the surface is lower than the threshold, change the effective
// prism growth vector to match with the surface vector, so that
// the Quad which is created lies on the original surface
//growthvectors.Elem(segpair_p1) = surfelem_vect;
// Add a quad element to account for the prism volume
// element which is going to be added
Element2d sel(QUAD);
sel.PNum(4) = mapto.Get(seg_p1);
sel.PNum(3) = mapto.Get(seg_p2);
sel.PNum(2) = segpair_p2;
sel.PNum(1) = segpair_p1;
sel.SetIndex(mesh.LineSegment(j).si);
mesh.AddSurfaceElement(sel);
numquads++;
}
else
{
dbg << "\n";
for (int k = 1; k <= pnt1_elems.Size(); k++)
{
Element2d & pnt_sel = mesh.SurfaceElement(pnt1_elems.Elem(k));
if(pnt_sel.GetIndex() == mesh.LineSegment(j).si)
{
for(int l = 1; l <= pnt_sel.GetNP(); l++)
{
if(pnt_sel.PNum(l) == segpair_p1)
{
pnt_sel.PNum(l) = mapto.Get(seg_p1);
}
else if(pnt_sel.PNum(l) == segpair_p2)
{
pnt_sel.PNum(l) = mapto.Get(seg_p2);
}
}
}
}
for (int k = 1; k <= pnt2_elems.Size(); k++)
{
Element2d & pnt_sel = mesh.SurfaceElement(pnt2_elems.Elem(k));
if(pnt_sel.GetIndex() == mesh.LineSegment(j).si)
{
for(int l = 1; l <= pnt_sel.GetNP(); l++)
{
if(pnt_sel.PNum(l) == segpair_p1)
示例3: RefinePrisms
//.........这里部分代码省略.........
nel2.PNum(j+3) = el.PNum(j+3);
}
nel1.SetIndex (el.GetIndex());
nel2.SetIndex (el.GetIndex());
mesh.VolumeElement (i) = nel1;
mesh.AddVolumeElement (nel2);
}
}
PrintMessage (5, "Elements done, NE = ", mesh.GetNE());
// do surface elements
int oldnse = mesh.GetNSE();
// cout << "oldnse = " << oldnse << endl;
for (i = 1; i <= oldnse; i++)
{
Element2d & el = mesh.SurfaceElement (i);
if (el.GetType() != QUAD)
continue;
int index = el.GetIndex();
int npi[2];
for (j = 1; j <= 2; j++)
{
int pi1, pi2;
if (j == 1)
{
pi1 = el.PNum(1);
pi2 = el.PNum(4);
}
else
{
pi1 = el.PNum(2);
pi2 = el.PNum(3);
}
if (pi1 == pi2)
npi[j-1] = pi1;
else
{
INDEX_2 edge(pi1, pi2);
edge.Sort();
if (refedges.Used (edge))
npi[j-1] = refedges.Get(edge);
else
{
npi[j-1] = 0;
}
}
}
if (npi[0])
{
Element2d nel1(QUAD), nel2(QUAD);
for (j = 1; j <= 4; j++)
{
nel1.PNum(j) = el.PNum(j);
nel2.PNum(j) = el.PNum(j);
}
nel1.PNum(3) = npi[1];
nel1.PNum(4) = npi[0];
nel2.PNum(1) = npi[0];
nel2.PNum(2) = npi[1];
/*
for (j = 1; j <= 2; j++)
{
nel1.PNum(j) = el.PNum(j);
nel1.PNum(j+2) = npi[j-1];
nel2.PNum(j) = npi[j-1];
nel2.PNum(j+2) = el.PNum(j+2);
}
*/
nel1.SetIndex (el.GetIndex());
nel2.SetIndex (el.GetIndex());
mesh.SurfaceElement (i) = nel1;
mesh.AddSurfaceElement (nel2);
int si = mesh.GetFaceDescriptor (index).SurfNr();
Point<3> hp = mesh.Point(npi[0]);
geom->GetSurface(si)->Project (hp);
mesh.Point (npi[0]).SetPoint (hp);
hp = mesh.Point(npi[1]);
geom->GetSurface(si)->Project (hp);
mesh.Point (npi[1]).SetPoint (hp);
// geom->GetSurface(si)->Project (mesh.Point(npi[0]));
// geom->GetSurface(si)->Project (mesh.Point(npi[1]));
}
}
PrintMessage (5, "Surface elements done, NSE = ", mesh.GetNSE());
}
}
示例4: nel
//.........这里部分代码省略.........
}
if (possible) break;
}
if (!possible)
{
ok = 0;
break;
}
elmap[i] = neighbours[elmap[i]];
}
for(int i=0; ok && i<rule.deledges.Size(); i++)
{
ok = !mesh.IsSegment(pmap.Elem(rule.deledges[i].I1()),
pmap.Elem(rule.deledges[i].I2()));
}
if (!ok) continue;
mapped[ri]++;
olddef = 0;
for (int j = 1; j <= pmap.Size(); j++)
olddef += sqr (nelonnode[pmap.Get(j)]);
olddef += rule.bonus;
newdef = 0;
for (int j = 1; j <= pmap.Size(); j++)
if (rule.reused.Get(j))
newdef += sqr (nelonnode[pmap.Get(j)] +
rule.incelsonnode.Get(j));
if (newdef > olddef)
continue;
// calc metric badness
double bad1 = 0, bad2 = 0;
Vec<3> n;
SelectSurfaceOfPoint (mesh.Point(pmap.Get(1)), pgi.Get(1));
GetNormalVector (surfnr, mesh.Point(pmap.Get(1)), pgi.Elem(1), n);
for (int j = 1; j <= rule.oldels.Size(); j++)
bad1 += mesh.SurfaceElement(elmap.Get(j)).CalcJacobianBadness (mesh.Points(), n);
// check new element:
for (int j = 1; j <= rule.newels.Size(); j++)
{
const Element2d & rnel = rule.newels.Get(j);
Element2d nel(rnel.GetNP());
for (int k = 1; k <= rnel.GetNP(); k++)
nel.PNum(k) = pmap.Get(rnel.PNum(k));
bad2 += nel.CalcJacobianBadness (mesh.Points(), n);
}
if (bad2 > 1e3) continue;
if (newdef == olddef && bad2 > bad1) continue;
// generate new element:
for (int j = 1; j <= rule.newels.Size(); j++)
{
const Element2d & rnel = rule.newels.Get(j);
Element2d nel(rnel.GetNP());
nel.SetIndex (faceindex);
for (int k = 1; k <= rnel.GetNP(); k++)
{
nel.PNum(k) = pmap.Get(rnel.PNum(k));
nel.GeomInfoPi(k) = pgi.Get(rnel.PNum(k));
}
mesh.AddSurfaceElement(nel);
}
for (int j = 0; j < rule.oldels.Size(); j++)
mesh.DeleteSurfaceElement ( elmap[j] );
for (int j = 1; j <= pmap.Size(); j++)
nelonnode[pmap.Get(j)] += rule.incelsonnode.Get(j);
used[ri]++;
}
}
}
mesh.Compress();
for (int ri = 0; ri < rules.Size(); ri++)
{
PrintMessage (5, "rule ", ri+1, " ",
mapped[ri], "/", used[ri], " mapped/used");
}
}