52Foam::pointSmoothers::geometricElementTransformPointSmoother::cellQuality
60 const cell& cFaces =
mesh.cells()[celli];
70 const label pointi(cPoints[cPointi]);
71 const point& pt = currentPoints[pointi];
76 if (pPoints.size() != 3)
79 <<
" point:" << pointi
80 <<
" connected points:" << pPoints <<
endl;
84 const Tensor<scalar> mA
86 currentPoints[pPoints[0]] - pt,
87 currentPoints[pPoints[1]] - pt,
88 currentPoints[pPoints[2]] - pt
92 if (
sigma < ROOTVSMALL)
119 transformationParameter_
121 dict.get<scalar>(
"transformationParameter")
151 reset(facesToMove, counts, pointDisplacement);
155 forAll(facesToMove, faceToMoveI)
157 const label faceI(facesToMove[faceToMoveI]);
159 cellsToMove.insert(
mesh().faceOwner()[faceI]);
161 if (
mesh().isInternalFace(faceI))
163 cellsToMove.insert(
mesh().faceNeighbour()[faceI]);
171 for (
const label cellI : cellsToMove)
189 const label pointI(cPoints[cPointI]);
191 if (counts[pointI] == -1)
continue;
201 const label nPPoints(pPoints.size());
208 currentPoints[pPoints[pPointI]]
209 + faceCentres[
pFaces[pPointI]];
211 dualAverage /= 2*nPPoints;
217 const label nextPPointI((pPointI + 1) % nPPoints);
223 currentPoints[pPoints[pPointI]]
224 + currentPoints[pointI]
229 faceCentres[
pFaces[nextPPointI]]
235 currentPoints[pPoints[nextPPointI]]
236 + currentPoints[pointI]
241 (nextFaceCentre - edgeCentre)
242 ^(edgeCentre - dualAverage);
244 (nextEdgeCentre - nextFaceCentre)
245 ^(nextFaceCentre - dualAverage);
247 vector dualNormalHat(dualNormal/
max(
mag(dualNormal), ROOTVSMALL));
253 const label nextPPointI((pPointI + 1) % nPPoints);
259 currentPoints[pPoints[pPointI]]
260 + currentPoints[pointI]
265 faceCentres[
pFaces[nextPPointI]]
271 currentPoints[pPoints[nextPPointI]]
272 + currentPoints[pointI]
276 vector c1 = edgeCentre + nextFaceCentre + dualAverage;
277 vector c2 = nextFaceCentre + nextEdgeCentre + dualAverage;
280 (nextFaceCentre - edgeCentre)
281 ^(edgeCentre - dualAverage);
283 (nextEdgeCentre - nextFaceCentre)
284 ^(nextFaceCentre - dualAverage);
286 scalar a1 = n1 & dualNormalHat;
287 scalar a2 = n2 & dualNormalHat;
290 sumAc += a1*
c1 + a2*
c2;
293 const vector dualCentre(sumAc/
max(sumA, ROOTVSMALL)/3);
296 transformedPoints[pointI] =
298 + transformationParameter_
299 *dualNormal/
sqrt(
max(
mag(dualNormal), ROOTVSMALL));
303 scalar lengthScale(0), transformedLengthScale(0);
307 cEdges[cEdgeI].mag(currentPoints);
308 transformedLengthScale +=
309 cEdges[cEdgeI].mag(transformedPoints);
311 lengthScale /= cEdges.size();
312 transformedLengthScale /= cEdges.size();
314 const scalar lengthScaleRatio =
316 (transformedLengthScale > SMALL)
317 ? lengthScale/transformedLengthScale
324 const label pointI(cPoints[cPointI]);
326 if (counts[pointI] == -1)
continue;
333 transformedPoints[pointI]
340 pointDisplacement[pointI] += newPoint - oldPoints[pointI];
345 reset(facesToMove, counts, pointDisplacement,
false);
348 forAll(facesToMove, faceToMoveI)
350 const label faceI(facesToMove[faceToMoveI]);
352 if (!isInternalOrProcessorFace(faceI))
357 vector faceNormalHat(faceAreas[faceI]);
358 faceNormalHat /=
max(SMALL,
mag(faceNormalHat));
363 const label pointI(fPoints[fPointI]);
365 const label fPointIPrev
367 (fPointI - 1 + fPoints.size()) % fPoints.size()
369 const label fPointINext
371 (fPointI + 1) % fPoints.size()
376 currentPoints[pointI]/2
378 currentPoints[fPoints[fPointINext]]
379 + currentPoints[fPoints[fPointIPrev]]
385 currentPoints[fPoints[fPointINext]]
386 - currentPoints[fPoints[fPointIPrev]]
391 transformedPoints[pointI] =
393 + transformationParameter_
394 *dualNormal/
sqrt(
max(
mag(dualNormal), ROOTVSMALL));
398 scalar lengthScale(0), transformedLengthScale(0);
401 const label fPointINext((fPointI + 1)%fPoints.size());
403 const label pointI(fPoints[fPointI]);
404 const label pointINext(fPoints[fPointINext]);
408 currentPoints[pointINext] - currentPoints[pointI]
410 transformedLengthScale +=
mag
412 transformedPoints[pointINext] - transformedPoints[pointI]
415 lengthScale /= fPoints.size();
416 transformedLengthScale /= fPoints.size();
418 const scalar lengthScaleRatio
420 (transformedLengthScale > SMALL)
421 ? lengthScale/transformedLengthScale
428 const label pointI(fPoints[fPointI]);
435 transformedPoints[pointI]
442 pointDisplacement[pointI] += newPoint - oldPoints[pointI];
448 average(facesToMove, counts, pointDisplacement);
453Foam::pointSmoothers::geometricElementTransformPointSmoother::cellQuality
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
static FOAM_NO_DANGLING_REFERENCE const Type & New(const Mesh &mesh, Args &&... args)
Get existing or create MeshObject registered with typeName.
void size(const label n)
Older name for setAddressableSize.
This class provides ordered connectivity for each point of each cell. Lists are available of the poin...
const labelListListList & cellPointFaces() const
Access the point-face connections.
const labelListListList & cellPointPoints() const
Access the point-point connections.
Class calculates cell quality measures.
A cell is defined as a list of faces with extra functionality.
labelList labels(const faceUList &meshFaces) const
Return unordered list of cell vertices given the list of faces.
edgeList edges(const faceUList &meshFaces) const
Return cell edges.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Abstract base class for point smoothing methods. Handles parallel communication via reset and average...
bool isInternalOrProcessorFace(const label faceI) const
Test if the given face is internal or on a processor boundary.
const polyMesh & mesh() const noexcept
Access the mesh.
Mesh consisting of general polyhedral cells.
A class for managing temporary objects.
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 Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
limits reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL))
#define WarningInFunction
Report a warning using Foam::Warning.
const dimensionedScalar c2
Second radiation constant: default SI units: [m.K].
const dimensionedScalar c1
First radiation constant: default SI units: [W/m2].
List< edge > edgeList
List of edge.
dimensionedScalar det(const dimensionedSphericalTensor &dt)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
List< label > labelList
A List of labels.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Field< vector > vectorField
Specialisation of Field<T> for vector.
Field< label > labelField
Specialisation of Field<T> for label.
vector point
Point is a vector.
dimensionedScalar cbrt(const dimensionedScalar &ds)
vectorField pointField
pointField is a vectorField.
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &f1, const label comm)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
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]
dimensionedScalar sigma("sigma", dimMass/sqr(dimTime), transportProperties)
#define forAll(list, i)
Loop across all elements in list.