more PointNd to Point<N>

This commit is contained in:
Christopher Lackner 2019-09-30 10:36:42 +02:00
parent 030d8c8523
commit 60223b2a86
5 changed files with 71 additions and 76 deletions

View File

@ -409,7 +409,7 @@ namespace netgen
}
void Element2d ::
GetIntegrationPoint (int ip, Point2d & p, double & weight) const
GetIntegrationPoint (int ip, Point<2> & p, double & weight) const
{
static double eltriqp[1][3] =
{
@ -433,8 +433,8 @@ namespace netgen
PrintSysError ("Element2d::GetIntegrationPoint, illegal type ", int(typ));
}
p.X() = pp[0];
p.Y() = pp[1];
p[0] = pp[0];
p[1] = pp[1];
weight = pp[2];
}
@ -447,7 +447,7 @@ namespace netgen
pmat.SetSize (2, np);
dshape.SetSize (2, np);
Point2d p;
Point<2> p;
double w;
GetPointMatrix (points, pmat);
@ -492,7 +492,7 @@ namespace netgen
}
void Element2d :: GetShape (const Point2d & p, Vector & shape) const
void Element2d :: GetShape (const Point<2> & p, Vector & shape) const
{
if (shape.Size() != GetNP())
{
@ -503,15 +503,15 @@ namespace netgen
switch (typ)
{
case TRIG:
shape(0) = 1 - p.X() - p.Y();
shape(1) = p.X();
shape(2) = p.Y();
shape(0) = 1 - p[0] - p[1];
shape(1) = p[0];
shape(2) = p[1];
break;
case QUAD:
shape(0) = (1-p.X()) * (1-p.Y());
shape(1) = p.X() * (1-p.Y());
shape(2) = p.X() * p.Y();
shape(3) = (1-p.X()) * p.Y();
shape(0) = (1-p[0]) * (1-p[1]);
shape(1) = p[0] * (1-p[1]);
shape(2) = p[0] * p[1];
shape(3) = (1-p[0]) * p[1];
break;
default:
PrintSysError ("Element2d::GetShape, illegal type ", int(typ));
@ -581,7 +581,7 @@ namespace netgen
void Element2d ::
GetDShape (const Point2d & p, DenseMatrix & dshape) const
GetDShape (const Point<2> & p, DenseMatrix & dshape) const
{
#ifdef DEBUG
if (dshape.Height() != 2 || dshape.Width() != np)
@ -602,14 +602,14 @@ namespace netgen
dshape.Elem(2, 3) = 1;
break;
case QUAD:
dshape.Elem(1, 1) = -(1-p.Y());
dshape.Elem(1, 2) = (1-p.Y());
dshape.Elem(1, 3) = p.Y();
dshape.Elem(1, 4) = -p.Y();
dshape.Elem(2, 1) = -(1-p.X());
dshape.Elem(2, 2) = -p.X();
dshape.Elem(2, 3) = p.X();
dshape.Elem(2, 4) = (1-p.X());
dshape.Elem(1, 1) = -(1-p[1]);
dshape.Elem(1, 2) = (1-p[1]);
dshape.Elem(1, 3) = p[1];
dshape.Elem(1, 4) = -p[1];
dshape.Elem(2, 1) = -(1-p[0]);
dshape.Elem(2, 2) = -p[0];
dshape.Elem(2, 3) = p[0];
dshape.Elem(2, 4) = (1-p[0]);
break;
default:
@ -728,7 +728,7 @@ namespace netgen
double Element2d ::
CalcJacobianBadnessDirDeriv (const NgArray<Point<2>> & points,
int pi, Vec2d & dir, double & dd) const
int pi, Vec<2> & dir, double & dd) const
{
if (typ == QUAD)
{
@ -737,14 +737,14 @@ namespace netgen
for (int j = 0; j < 4; j++)
{
const Point2d & p = points.Get( (*this)[j] );
pmat(0, j) = p.X();
pmat(1, j) = p.Y();
const auto& p = points.Get( (*this)[j] );
pmat(0, j) = p[0];
pmat(1, j) = p[1];
}
vmat = 0.0;
vmat(0, pi-1) = dir.X();
vmat(1, pi-1) = dir.Y();
vmat(0, pi-1) = dir[0];
vmat(1, pi-1) = dir[1];
double err = 0;
dd = 0;
@ -814,8 +814,8 @@ namespace netgen
GetPointMatrix (points, pmat);
vmat = 0.0;
vmat.Elem(1, pi) = dir.X();
vmat.Elem(2, pi) = dir.Y();
vmat.Elem(1, pi) = dir[0];
vmat.Elem(2, pi) = dir[1];
double err = 0;
@ -879,9 +879,9 @@ namespace netgen
for (i = 1; i <= GetNP(); i++)
{
Point3d p = points[PNum(i)];
pmat.Elem(1, i) = p.X() * t1(0) + p.Y() * t1(1) + p.Z() * t1(2);
pmat.Elem(2, i) = p.X() * t2(0) + p.Y() * t2(1) + p.Z() * t2(2);
const auto& p = points[PNum(i)];
pmat.Elem(1, i) = p[0] * t1(0) + p[1] * t1(1) + p[2] * t1(2);
pmat.Elem(2, i) = p[0] * t2(0) + p[1] * t2(1) + p[2] * t2(2);
}
double err = 0;
@ -921,10 +921,10 @@ namespace netgen
for (int i = 1; i <= GetNIP(); i++)
{
IntegrationPointData * ipd = new IntegrationPointData;
Point2d hp;
Point<2> hp;
GetIntegrationPoint (i, hp, ipd->weight);
ipd->p(0) = hp.X();
ipd->p(1) = hp.Y();
ipd->p(0) = hp[0];
ipd->p(1) = hp[1];
ipd->p(2) = 0;
ipd->shape.SetSize(GetNP());
@ -1828,8 +1828,6 @@ namespace netgen
void Element :: GetShape (const Point<3> & hp, Vector & shape) const
{
Point3d p = hp;
if (shape.Size() != GetNP())
{
cerr << "Element::GetShape: Length not fitting" << endl;
@ -1840,18 +1838,18 @@ namespace netgen
{
case TET:
{
shape(0) = 1 - p.X() - p.Y() - p.Z();
shape(1) = p.X();
shape(2) = p.Y();
shape(3) = p.Z();
shape(0) = 1 - hp[0] - hp[1] - hp[2];
shape(1) = hp[0];
shape(2) = hp[1];
shape(3) = hp[2];
break;
}
case TET10:
{
double lam1 = 1 - p.X() - p.Y() - p.Z();
double lam2 = p.X();
double lam3 = p.Y();
double lam4 = p.Z();
double lam1 = 1 - hp[0] - hp[1] - hp[2];
double lam2 = hp[0];
double lam3 = hp[1];
double lam4 = hp[2];
shape(4) = 4 * lam1 * lam2;
shape(5) = 4 * lam1 * lam3;
@ -1869,7 +1867,6 @@ namespace netgen
case PRISM:
{
Point<3> hp = p;
shape(0) = hp(0) * (1-hp(2));
shape(1) = hp(1) * (1-hp(2));
shape(2) = (1-hp(0)-hp(1)) * (1-hp(2));
@ -1880,7 +1877,6 @@ namespace netgen
}
case HEX:
{
Point<3> hp = p;
shape(0) = (1-hp(0))*(1-hp(1))*(1-hp(2));
shape(1) = ( hp(0))*(1-hp(1))*(1-hp(2));
shape(2) = ( hp(0))*( hp(1))*(1-hp(2));
@ -2179,10 +2175,10 @@ namespace netgen
int np = GetNP();
for (int i = 1; i <= np; i++)
{
const Point3d & p = points[PNum(i)];
pmat.Elem(1, i) = p.X();
pmat.Elem(2, i) = p.Y();
pmat.Elem(3, i) = p.Z();
const auto& p = points[PNum(i)];
pmat.Elem(1, i) = p[0];
pmat.Elem(2, i) = p[1];
pmat.Elem(3, i) = p[2];
}
}
@ -2513,8 +2509,7 @@ namespace netgen
void FaceDescriptor :: DoArchive (Archive & ar)
{
ar & surfnr & domin & domout & tlosurf & bcprop
& surfcolour.X() & surfcolour.Y() & surfcolour.Z()
& bcname
& surfcolour & bcname
& domin_singular & domout_singular ;
// don't need: firstelement
}

View File

@ -578,19 +578,19 @@ namespace netgen
/// get number of 'integration points'
int GetNIP () const;
void GetIntegrationPoint (int ip, Point2d & p, double & weight) const;
void GetIntegrationPoint (int ip, Point<2> & p, double & weight) const;
void GetTransformation (int ip, const NgArray<Point<2>> & points,
class DenseMatrix & trans) const;
void GetTransformation (int ip, class DenseMatrix & pmat,
class DenseMatrix & trans) const;
void GetShape (const Point2d & p, class Vector & shape) const;
void GetShape (const Point<2> & p, class Vector & shape) const;
void GetShapeNew (const Point<2> & p, class FlatVector & shape) const;
template <typename T>
void GetShapeNew (const Point<2,T> & p, TFlatVector<T> shape) const;
/// matrix 2 * np
void GetDShape (const Point2d & p, class DenseMatrix & dshape) const;
void GetDShape (const Point<2> & p, class DenseMatrix & dshape) const;
template <typename T>
void GetDShapeNew (const Point<2,T> & p, class MatrixFixWidth<2,T> & dshape) const;
@ -605,7 +605,7 @@ namespace netgen
double CalcJacobianBadness (const T_POINTS & points,
const Vec<3> & n) const;
double CalcJacobianBadnessDirDeriv (const NgArray<Point<2>> & points,
int pi, Vec2d & dir, double & dd) const;
int pi, Vec<2> & dir, double & dd) const;
@ -1128,7 +1128,7 @@ namespace netgen
// Add capability to store surface colours along with
// other face data
/// surface colour (Default: R=0.0 ; G=1.0 ; B=0.0)
Vec3d surfcolour;
Vec<3> surfcolour;
///
static string default_bcname;

View File

@ -42,7 +42,7 @@ void netrule :: LoadRule (istream & ist)
{
char buf[256];
char ch;
Point2d p;
Point<2> p;
INDEX_2 lin;
int i, j;
DenseMatrix tempoldutonewu(20, 20), tempoldutofreearea(20, 20),
@ -85,9 +85,9 @@ void netrule :: LoadRule (istream & ist)
while (ch == '(')
{
ist >> p.X();
ist >> p[0];
ist >> ch; // ','
ist >> p.Y();
ist >> p[1];
ist >> ch; // ')'
points.Append (p);
@ -188,9 +188,9 @@ void netrule :: LoadRule (istream & ist)
while (ch == '(')
{
ist >> p.X();
ist >> p[0];
ist >> ch; // ','
ist >> p.Y();
ist >> p[1];
ist >> ch; // ')'
points.Append (p);
@ -249,9 +249,9 @@ void netrule :: LoadRule (istream & ist)
while (ch == '(')
{
ist >> p.X();
ist >> p[0];
ist >> ch; // ','
ist >> p.Y();
ist >> p[1];
ist >> ch; // ')'
freezone.Append (p);
@ -294,9 +294,9 @@ void netrule :: LoadRule (istream & ist)
{
freepi++;
ist >> p.X();
ist >> p[0];
ist >> ch; // ','
ist >> p.Y();
ist >> p[1];
ist >> ch; // ')'
freezonelimit.Elem(freepi) = p;

View File

@ -592,9 +592,9 @@ namespace netgen
int oldnp = rule->GetNOldP();
for (int i = oldnp + 1; i <= rule->GetNP(); i++)
{
Point2d np = rule->GetPoint(i);
np.X() += newu (2 * (i-oldnp) - 2);
np.Y() += newu (2 * (i-oldnp) - 1);
auto np = rule->GetPoint(i);
np[0] += newu (2 * (i-oldnp) - 2);
np[1] += newu (2 * (i-oldnp) - 1);
lpoints.Append (np);
pmap.Elem(i) = lpoints.Size();

View File

@ -571,7 +571,7 @@ namespace netgen
int lpi, gpi;
Vec<3> n, vgrad;
Point<3> pp1;
Vec2d g1, vdir;
Vec<2> g1, vdir;
double badness, hbad, hderiv;
vgrad = 0;
@ -603,15 +603,15 @@ namespace netgen
pts2d.Elem(pi) = Point2d (ld.t1 * (mesh.Point(pi) - ld.sp1),
ld.t2 * (mesh.Point(pi) - ld.sp1));
}
pts2d.Elem(gpi) = Point2d (x(0), x(1));
pts2d.Elem(gpi) = { x(0), x(1) };
for (int k = 1; k <= 2; k++)
{
if (k == 1)
vdir = Vec2d (1, 0);
vdir = {1., 0.};
else
vdir = Vec2d (0, 1);
vdir = {0., 1.};
hbad = bel.
CalcJacobianBadnessDirDeriv (pts2d, lpi, vdir, hderiv);
@ -643,7 +643,7 @@ namespace netgen
int j, k, lpi, gpi;
Vec<3> n, vgrad;
Point<3> pp1;
Vec2d g1, vdir;
Vec<2> g1, vdir;
double badness, hbad, hderiv;
vgrad = 0;
@ -677,7 +677,7 @@ namespace netgen
pts2d.Elem(gpi) = Point2d (x(0), x(1));
vdir = Vec2d (dir(0), dir(1));
vdir = { dir(0), dir(1) };
hbad = bel.
CalcJacobianBadnessDirDeriv (pts2d, lpi, vdir, hderiv);