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

View File

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

View File

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

View File

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

View File

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