Using DynamicField for points. Revert to non-templated versions of geometric functions for now.

This commit is contained in:
Sandeep Menon 2010-10-21 13:00:16 -04:00
parent 8926bf1bc0
commit 59df49e7b8
11 changed files with 50 additions and 254 deletions

View file

@ -996,10 +996,10 @@ scalar dynamicTopoFvMesh::testProximity
if (twoDMesh_) if (twoDMesh_)
{ {
// Obtain the face-normal. // Obtain the face-normal.
meshOps::faceNormal(faces_[index], points_, gNormal); gNormal = faces_[index].normal(points_);
// Obtain the face centre. // Obtain the face centre.
meshOps::faceCentre(faces_[index], points_, gCentre); gCentre = faces_[index].centre(points_);
// Fetch the edge // Fetch the edge
const edge& edgeToCheck = edges_[getTriBoundaryEdge(index)]; const edge& edgeToCheck = edges_[getTriBoundaryEdge(index)];
@ -1034,16 +1034,7 @@ scalar dynamicTopoFvMesh::testProximity
if (neighbour_[eFaces[faceI]] == -1) if (neighbour_[eFaces[faceI]] == -1)
{ {
// Obtain the normal. // Obtain the normal.
vector gTmp; gNormal += faces_[eFaces[faceI]].normal(points_);
meshOps::faceNormal
(
faces_[eFaces[faceI]],
points_,
gTmp
);
gNormal += gTmp;
} }
} }
@ -2190,8 +2181,7 @@ const changeMap dynamicTopoFvMesh::identifySliverType
} }
// Obtain the unit normal. // Obtain the unit normal.
vector testNormal; vector testNormal = testFace.normal(points_);
meshOps::faceNormal(testFace, points_, testNormal);
testNormal /= (mag(testNormal) + VSMALL); testNormal /= (mag(testNormal) + VSMALL);
@ -2213,8 +2203,7 @@ const changeMap dynamicTopoFvMesh::identifySliverType
} }
// Obtain the face-normal. // Obtain the face-normal.
vector refArea; vector refArea = tFace.normal(points_);
meshOps::faceNormal(tFace, points_, refArea);
// Normalize it. // Normalize it.
vector n = refArea/mag(refArea); vector n = refArea/mag(refArea);

View file

@ -50,6 +50,7 @@ SourceFiles
#include "Switch.H" #include "Switch.H"
#include "tetMetric.H" #include "tetMetric.H"
#include "DynamicField.H"
#include "threadHandler.H" #include "threadHandler.H"
#include "dynamicFvMesh.H" #include "dynamicFvMesh.H"
@ -124,7 +125,14 @@ class dynamicTopoFvMesh
typedef DynamicList<T, 0, 11, 10> Type; typedef DynamicList<T, 0, 11, 10> Type;
}; };
resizableList<point>::Type oldPoints_, points_; template <class T>
class resizableField
{
public:
typedef DynamicField<T> Type;
};
resizableField<point>::Type oldPoints_, points_;
resizableList<face>::Type faces_; resizableList<face>::Type faces_;
resizableList<label>::Type owner_, neighbour_; resizableList<label>::Type owner_, neighbour_;
resizableList<cell>::Type cells_; resizableList<cell>::Type cells_;

View file

@ -276,12 +276,7 @@ bool dynamicTopoFvMesh::checkBoundingCurve(const label eIndex) const
if ((fPatch = whichPatch(edgeFaces[faceI])) > -1) if ((fPatch = whichPatch(edgeFaces[faceI])) > -1)
{ {
// Obtain the normal. // Obtain the normal.
meshOps::faceNormal fNorm[count] = faces_[edgeFaces[faceI]].normal(points_);
(
faces_[edgeFaces[faceI]],
points_,
fNorm[count]
);
// Normalize it. // Normalize it.
fNorm[count] /= mag(fNorm[count]) + VSMALL; fNorm[count] /= mag(fNorm[count]) + VSMALL;

View file

@ -407,12 +407,7 @@ inline scalar dynamicTopoFvMesh::edgeLengthScale
if (neighbour_[eFaces[faceI]] == -1) if (neighbour_[eFaces[faceI]] == -1)
{ {
// Obtain the normal. // Obtain the normal.
meshOps::faceNormal fNorm[count] = faces_[eFaces[faceI]].normal(points_);
(
faces_[eFaces[faceI]],
points_,
fNorm[count]
);
// Normalize it. // Normalize it.
fNorm[count] /= mag(fNorm[count]); fNorm[count] /= mag(fNorm[count]);

View file

@ -319,7 +319,7 @@ void dynamicTopoFvMesh::computeParents
{ {
offset = boundaryMesh()[whichPatch(index)].start(); offset = boundaryMesh()[whichPatch(index)].start();
meshOps::faceCentre(faces_[index], oldPoints_, centre); centre = faces_[index].centre(oldPoints_);
} }
else else
if (dimension == 3) if (dimension == 3)

View file

@ -1615,26 +1615,9 @@ const changeMap dynamicTopoFvMesh::bisectQuadFace
// Fetch face-normals // Fetch face-normals
vector tfNorm, f0Norm, f1Norm; vector tfNorm, f0Norm, f1Norm;
meshOps::faceNormal tfNorm = faces_[newFaceIndex[faceI]].normal(oldPoints_);
( f0Norm = faces_[c0BdyIndex[0]].normal(oldPoints_);
faces_[newFaceIndex[faceI]], f1Norm = faces_[c0BdyIndex[1]].normal(oldPoints_);
oldPoints_,
tfNorm
);
meshOps::faceNormal
(
faces_[c0BdyIndex[0]],
oldPoints_,
f0Norm
);
meshOps::faceNormal
(
faces_[c0BdyIndex[1]],
oldPoints_,
f1Norm
);
// Tri-face on boundary. Perform normal checks // Tri-face on boundary. Perform normal checks
// also, because of empty patches. // also, because of empty patches.
@ -4232,7 +4215,7 @@ scalar dynamicTopoFvMesh::computeTrisectionQuality
point midPoint; point midPoint;
// Fetch the midPoint // Fetch the midPoint
meshOps::faceCentre(faces_[fIndex], points_, midPoint); midPoint = faces_[fIndex].centre(points_);
FixedList<label,2> apexPoint(-1); FixedList<label,2> apexPoint(-1);

View file

@ -400,20 +400,20 @@ const changeMap dynamicTopoFvMesh::collapseQuadFace
// Compute face position / normal // Compute face position / normal
if (c0BdyFace[0].which(original[0]) > -1) if (c0BdyFace[0].which(original[0]) > -1)
{ {
meshOps::faceCentre(c0BdyFace[0], oldPoints_, xf[0]); xf[0] = c0BdyFace[0].centre(oldPoints_);
meshOps::faceNormal(c0BdyFace[0], oldPoints_, nf[0]); nf[0] = c0BdyFace[0].normal(oldPoints_);
meshOps::faceCentre(c0BdyFace[1], oldPoints_, xf[1]); xf[1] = c0BdyFace[1].centre(oldPoints_);
meshOps::faceNormal(c0BdyFace[1], oldPoints_, nf[1]); nf[1] = c0BdyFace[1].normal(oldPoints_);
} }
else else
if (c0BdyFace[1].which(original[0]) > -1) if (c0BdyFace[1].which(original[0]) > -1)
{ {
meshOps::faceCentre(c0BdyFace[1], oldPoints_, xf[0]); xf[0] = c0BdyFace[1].centre(oldPoints_);
meshOps::faceNormal(c0BdyFace[1], oldPoints_, nf[0]); nf[0] = c0BdyFace[1].normal(oldPoints_);
meshOps::faceCentre(c0BdyFace[0], oldPoints_, xf[1]); xf[1] = c0BdyFace[0].centre(oldPoints_);
meshOps::faceNormal(c0BdyFace[0], oldPoints_, nf[1]); nf[1] = c0BdyFace[0].normal(oldPoints_);
} }
else else
{ {

View file

@ -370,19 +370,8 @@ const changeMap dynamicTopoFvMesh::swapQuadFace
// Assume that centre-plane passes through the origin. // Assume that centre-plane passes through the origin.
vector xf, nf; vector xf, nf;
meshOps::faceCentre xf = triFaceOldPoints[faceI].centre(oldPoints_);
( nf = triFaceOldPoints[faceI].normal(oldPoints_);
triFaceOldPoints[faceI],
oldPoints_,
xf
);
meshOps::faceNormal
(
triFaceOldPoints[faceI],
oldPoints_,
nf
);
if ((((xf & n) * n) & nf) < 0.0) if ((((xf & n) * n) & nf) < 0.0)
{ {

View file

@ -67,22 +67,6 @@ class polyMesh;
namespace meshOps namespace meshOps
{ {
// Compute the centre for a given face, using UList
inline void faceCentre
(
const face& faceToCheck,
const UList<vector>& points,
vector& centre
);
// Compute the normal for a given face, using UList
inline void faceNormal
(
const face& faceToCheck,
const UList<vector>& points,
vector& normal
);
// Method to find the common-edge between two faces. // Method to find the common-edge between two faces.
inline bool findCommonEdge inline bool findCommonEdge
( (
@ -168,16 +152,15 @@ namespace meshOps
); );
// Given a cell index, find the centroid / volume of a cell. // Given a cell index, find the centroid / volume of a cell.
template <class T1, class T2>
inline bool cellCentreAndVolume inline bool cellCentreAndVolume
( (
const label cIndex, const label cIndex,
const UList<Vector<T1> >& points, const vectorField& points,
const UList<face>& faces, const UList<face>& faces,
const UList<cell>& cells, const UList<cell>& cells,
const UList<label>& owner, const UList<label>& owner,
Vector<T2>& centre, vector& centre,
T2& volume, scalar& volume,
bool checkClosed = false bool checkClosed = false
); );

View file

@ -47,127 +47,6 @@ namespace Foam
namespace meshOps namespace meshOps
{ {
// Compute the centroid for a given face, using UList
inline void faceCentre
(
const face& faceToCheck,
const UList<vector>& points,
vector& centre
)
{
// Reset to zero
centre = vector::zero;
vector a(vector::zero);
vector b(vector::zero);
vector c(vector::zero);
// If the face is a triangle, do a direct calculation
// to avoid round-off error-related problems
if (faceToCheck.size() == 3)
{
a = points[faceToCheck[0]];
b = points[faceToCheck[1]];
c = points[faceToCheck[2]];
centre = ((1.0 / 3.0) * (a + b + c));
return;
}
label nPoints = faceToCheck.size();
register label pI;
// Store the centre point in c
for (pI = 0; pI < nPoints; pI++)
{
c += points[faceToCheck[pI]];
}
c /= nPoints;
scalar ta = 0.0;
scalar sumA = 0.0;
vector ttc = vector::zero;
vector sumAc = vector::zero;
for (pI = 0; pI < nPoints; pI++)
{
a = points[faceToCheck[pI]];
b = points[faceToCheck[(pI + 1) % nPoints]];
// Calculate 3*triangle centre
ttc = (a + b + c);
// Calculate 2*triangle area
ta = mag((a - c)^(b - c));
sumA += ta;
sumAc += ta*ttc;
}
if (sumA > VSMALL)
{
centre = (sumAc/(3.0 * sumA));
}
else
{
centre = c;
}
}
// Compute the normal for a given face, using UList
inline void faceNormal
(
const face& faceToCheck,
const UList<vector>& points,
vector& normal
)
{
// Reset to zero
normal = vector::zero;
vector a(vector::zero);
vector b(vector::zero);
vector c(vector::zero);
// If the face is a triangle, do a direct calculation
// to avoid round-off error-related problems
if (faceToCheck.size() == 3)
{
a = points[faceToCheck[0]];
b = points[faceToCheck[1]];
c = points[faceToCheck[2]];
normal = (0.5 * ((b - a)^(c - a)));
return;
}
label nPoints = faceToCheck.size();
register label pI;
// Store the centre point in c
for (pI = 0; pI < nPoints; pI++)
{
c += points[faceToCheck[pI]];
}
c /= nPoints;
for (pI = 0; pI < nPoints; pI++)
{
a = points[faceToCheck[pI]];
b = points[faceToCheck[(pI + 1) % nPoints]];
normal += (0.5 * ((b - a)^(c - a)));
}
}
// Utility method to find the common edge between two faces. // Utility method to find the common edge between two faces.
inline bool findCommonEdge inline bool findCommonEdge
( (
@ -393,35 +272,27 @@ inline label tetApexPoint
// Given a cell index, find the centroid / volume of a cell. // Given a cell index, find the centroid / volume of a cell.
// - If checking is enabled, return whether the cell is closed // - If checking is enabled, return whether the cell is closed
template <class T1, class T2>
inline bool cellCentreAndVolume inline bool cellCentreAndVolume
( (
const label cIndex, const label cIndex,
const UList<Vector<T1> >& points, const vectorField& points,
const UList<face>& faces, const UList<face>& faces,
const UList<cell>& cells, const UList<cell>& cells,
const UList<label>& owner, const UList<label>& owner,
Vector<T2>& centre, vector& centre,
T2& volume, scalar& volume,
bool checkClosed bool checkClosed
) )
{ {
// Reset inputs // Reset inputs
volume = pTraits<T2>::zero; volume = 0.0;
centre = Vector<T2>::zero; centre = vector::zero;
const cell& cellToCheck = cells[cIndex]; const cell& cellToCheck = cells[cIndex];
// Average face-centres to get an estimate centroid // Average face-centres to get an estimate centroid
Vector<T2> cEst(Vector<T2>::zero); vector cEst(vector::zero), fCentre(vector::zero), fArea(vector::zero);
Vector<T2> fCentre(Vector<T2>::zero); vector sumClosed(vector::zero), sumMagClosed(vector::zero);
Vector<T2> fArea(Vector<T2>::zero);
Vector<T2> sumClosed(Vector<T2>::zero), sumMagClosed(Vector<T2>::zero);
const T2 three(3.0), four(4.0);
const T2 oneThird = (pTraits<T2>::one / three);
const T2 oneFourth = (pTraits<T2>::one / four);
const T2 threeFourths = (three / four);
forAll(cellToCheck, faceI) forAll(cellToCheck, faceI)
{ {
@ -432,17 +303,10 @@ inline bool cellCentreAndVolume
continue; continue;
} }
meshOps::faceCentre cEst += checkFace.centre(points);
(
checkFace,
points,
fCentre
);
cEst += fCentre;
} }
cEst /= T2(cellToCheck.size()); cEst /= cellToCheck.size();
forAll(cellToCheck, faceI) forAll(cellToCheck, faceI)
{ {
@ -453,19 +317,8 @@ inline bool cellCentreAndVolume
continue; continue;
} }
meshOps::faceNormal fArea = checkFace.normal(points);
( fCentre = checkFace.centre(points);
checkFace,
points,
fArea
);
meshOps::faceCentre
(
checkFace,
points,
fCentre
);
// Flip if necessary // Flip if necessary
if (owner[cellToCheck[faceI]] != cIndex) if (owner[cellToCheck[faceI]] != cIndex)
@ -474,10 +327,10 @@ inline bool cellCentreAndVolume
} }
// Calculate 3*face-pyramid volume // Calculate 3*face-pyramid volume
T2 pyr3Vol = fArea & (fCentre - cEst); scalar pyr3Vol = fArea & (fCentre - cEst);
// Calculate face-pyramid centre // Calculate face-pyramid centre
Vector<T2> pc = (threeFourths*fCentre) + (oneFourth*cEst); vector pc = ((3.0 / 4.0) * fCentre) + ((1.0 / 4.0) * cEst);
// Accumulate volume-weighted face-pyramid centre // Accumulate volume-weighted face-pyramid centre
centre += pyr3Vol*pc; centre += pyr3Vol*pc;
@ -494,12 +347,12 @@ inline bool cellCentreAndVolume
} }
centre /= volume + VSMALL; centre /= volume + VSMALL;
volume *= oneThird; volume *= (1.0 / 3.0);
if (checkClosed) if (checkClosed)
{ {
// Check the sum across components // Check the sum across components
T2 closed = pTraits<T2>::zero; scalar closed = 0.0;
for (direction cmpt = 0; cmpt < vector::nComponents; cmpt++) for (direction cmpt = 0; cmpt < vector::nComponents; cmpt++)
{ {

View file

@ -1,5 +1,6 @@
EXE_INC = \ EXE_INC = \
-I$(LIB_SRC)/dynamicMesh/dynamicMesh/lnInclude \ -I$(LIB_SRC)/dynamicMesh/dynamicMesh/lnInclude \
-I$(LIB_SRC)/dynamicMesh/meshMotion/RBFMotionSolver/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude -I$(LIB_SRC)/triSurface/lnInclude