50 const label index =
f.find(pI);
73 Info<<
"Calculating vertex normals" <<
endl;
76 auto& pointNormals = tpointNormals.ref();
86 for (
const label facei :
pFaces)
92 const scalar weight = vertexNormalWeight
100 pointNormals[pI] += weight * areaNorm;
103 pointNormals[pI].normalise();
106 return tpointNormals;
113 const triSurface& surf,
118 const Map<label>& meshPointMap = surf.meshPointMap();
121 auto& pointTriads = tpointTriads.ref();
126 const vector& normal = pointNormals[meshPointMap[pI]];
128 if (
mag(normal) < SMALL)
140 pointTriads[meshPointMap[pI]] =
triad(dir1, dir2, normal);
150 const triSurface& surf,
155 Info<<
"Calculating face curvature" <<
endl;
158 const labelList& meshPoints = surf.meshPoints();
159 const Map<label>& meshPointMap = surf.meshPointMap();
161 List<symmTensor2D> pointFundamentalTensors
180 const edge&
e = fEdges[feI];
182 edgeVectors[feI] =
e.vec(
points);
183 normalDifferences[feI] =
184 pointNormals[meshPointMap[
e[0]]]
185 - pointNormals[meshPointMap[
e[1]]];
189 const vector& e0 = edgeVectors[0];
191 const vector e1 = (e0 ^ eN);
193 if (
magSqr(eN) < ROOTVSMALL)
198 triad faceCoordSys(e0, e1, eN);
199 faceCoordSys.normalize();
206 for (label i = 0; i < 3; ++i)
208 scalar
x = edgeVectors[i] & faceCoordSys[0];
209 scalar
y = edgeVectors[i] & faceCoordSys[1];
217 scalar dndx = normalDifferences[i] & faceCoordSys[0];
218 scalar dndy = normalDifferences[i] & faceCoordSys[1];
221 Z[1] += dndx*
y + dndy*
x;
234 const label patchPointIndex = meshPointMap[
f[fpI]];
236 const triad& ptCoordSys = pointTriads[patchPointIndex];
238 if (!ptCoordSys.set())
245 triad rotatedFaceCoordSys = rotTensor &
tensor(faceCoordSys);
251 ptCoordSys[0] & rotatedFaceCoordSys[0],
252 ptCoordSys[0] & rotatedFaceCoordSys[1]
256 ptCoordSys[1] & rotatedFaceCoordSys[0],
257 ptCoordSys[1] & rotatedFaceCoordSys[1]
268 projTensor.x() & (secondFundamentalTensor & projTensor.x()),
269 projTensor.x() & (secondFundamentalTensor & projTensor.y()),
270 projTensor.y() & (secondFundamentalTensor & projTensor.y())
278 meshPoints[patchPointIndex],
284 pointFundamentalTensors[patchPointIndex] +=
285 weight*projectedFundamentalTensor;
287 accumulatedWeights[patchPointIndex] += weight;
295 Info<<
"edgeVecs = " << edgeVectors[0] <<
" "
296 << edgeVectors[1] <<
" "
297 << edgeVectors[2] <<
endl;
298 Info<<
"normDiff = " << normalDifferences[0] <<
" "
299 << normalDifferences[1] <<
" "
300 << normalDifferences[2] <<
endl;
301 Info<<
"faceCoordSys = " << faceCoordSys <<
endl;
308 scalarField& curvatureAtPoints = tcurvatureAtPoints.ref();
310 forAll(curvatureAtPoints, pI)
312 pointFundamentalTensors[pI] /= (accumulatedWeights[pI] + SMALL);
318 scalar curvature =
max
320 mag(principalCurvatures[0]),
321 mag(principalCurvatures[1])
325 curvatureAtPoints[meshPoints[pI]] = curvature;
328 return tcurvatureAtPoints;
335 const triSurface& surf
341 tmp<scalarField> curv = curvatures(surf, norms(), triads());
353 const word& basename,
357 Info<<
"Extracting curvature of surface at the points." <<
endl;
366 basename +
".curvature",
378 outputField.
swap(curv);
380 outputField.
swap(curv);
void swap(List< T > &other)
Swap with plain List content. Implies shrink_to_fit().
@ NO_READ
Nothing to be read.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A HashTable to objects of type <T> with a label key.
label nPoints() const
Number of points supporting patch faces.
const Map< label > & meshPointMap() const
Mesh point map.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
const Field< point_type > & points() const noexcept
Return reference to global points.
const labelListList & pointFaces() const
Return point-face addressing.
Vector2D< Cmpt > y() const
Extract vector for row 1.
Vector2D< Cmpt > x() const
Extract vector for row 0.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void size(const label n)
Older name for setAddressableSize.
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
Geometric class that creates a 3D plane and can return the intersection point between a line and the ...
virtual bool write(const bool writeOnProc=true) const
Write using setting from DB.
A class for managing temporary objects.
void clear() const noexcept
If object pointer points to valid object: delete object and set pointer to nullptr.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
A triangular face using a FixedList of labels corresponding to mesh vertices.
Triangulated surface description with patch information.
Representation of a 3D Cartesian coordinate system as a Vector of row vectors.
bool set(const direction d) const
Is the vector in the direction d set.
void normalize()
Same as normalise.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
A class for handling words, derived from Foam::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
List< edge > edgeList
List of edge.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
quaternion normalised(const quaternion &q)
Return the normalised (unit) quaternion of the given quaternion.
Vector2D< scalar > vector2D
A 2D vector of scalars obtained from the generic Vector2D.
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
dimensionedVector eigenValues(const dimensionedSymmTensor &dt)
tensor rotationTensor(const vector &n1, const vector &n2)
Rotational transformation tensor from vector n1 to n2.
SymmTensor2D< scalar > symmTensor2D
SymmTensor2D of scalars, i.e. SymmTensor2D<scalar>.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Tensor2D< scalar > tensor2D
Tensor2D of scalars, i.e. Tensor2D<scalar>.
Ostream & endl(Ostream &os)
Add newline and flush stream.
SymmetricSquareMatrix< scalar > scalarSymmetricSquareMatrix
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
errorManip< error > abort(error &err)
Field< vector > vectorField
Specialisation of Field<T> for vector.
vector point
Point is a vector.
DiagonalMatrix< scalar > scalarDiagonalMatrix
static constexpr const zero Zero
Global zero (0).
Field< triad > triadField
Specialisation of Field<T> for triad.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
void LUsolve(scalarSquareMatrix &matrix, List< Type > &source)
Solve the matrix using LU decomposition with pivoting returning the LU form of the matrix and the sol...
vectorField pointField
pointField is a vectorField.
List< scalar > scalarList
List of scalar.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
DimensionedField< scalar, triSurfacePointGeoMesh > triSurfacePointScalarField
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints, -1);const cellModel &hex=cellModel::ref(cellModel::HEX);labelList hexLabels(8);label activeCells=0;labelList pointMap(nPoints);forAll(pointMap, i){ pointMap[i]=i;}for(label i=0;i< nPoints;i++){ if(f[i] > 0.0) { hexLabels[0]=i;hexLabels[1]=i1tab[i];hexLabels[2]=i3tab[i1tab[i]];hexLabels[3]=i3tab[i];hexLabels[4]=i8tab[i];hexLabels[5]=i1tab[i8tab[i]];hexLabels[6]=i3tab[i1tab[i8tab[i]]];hexLabels[7]=i3tab[i8tab[i]];cellShapes[activeCells].reset(hex, hexLabels);edgeList edges=cellShapes[activeCells].edges();forAll(edges, ei) { if(edges[ei].mag(points)< SMALL) { label start=pointMap[edges[ei].start()];while(start !=pointMap[start]) { start=pointMap[start];} label end=pointMap[edges[ei].end()];while(end !=pointMap[end]) { end=pointMap[end];} pointMap[start]=pointMap[end]=Foam::min(start, end);} } cellZoning[activeCells]=idreg[i];activeCells++;}}cellShapes.setSize(activeCells);cellZoning.setSize(activeCells);forAll(cellShapes, celli){ cellShape &cs=cellShapes[celli];forAll(cs, i) { cs[i]=pointMap[cs[i]];} cs.collapse();}label bcIDs[11]={-1, 0, 2, 4, -1, 5, -1, 6, 7, 8, 9};constexpr label nBCs=12;const word *kivaPatchTypes[nBCs]={ &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &symmetryPolyPatch::typeName, &wedgePolyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &symmetryPolyPatch::typeName, &oldCyclicPolyPatch::typeName};enum patchTypeNames{ PISTON, VALVE, LINER, CYLINDERHEAD, AXIS, WEDGE, INFLOW, OUTFLOW, PRESIN, PRESOUT, SYMMETRYPLANE, CYCLIC};const char *kivaPatchNames[nBCs]={ "piston", "valve", "liner", "cylinderHead", "axis", "wedge", "inflow", "outflow", "presin", "presout", "symmetryPlane", "cyclic"};List< DynamicList< face > > pFaces[nBCs]
#define forAll(list, i)
Loop across all elements in list.