36 namespace pointSmoothers
42 geometricElementTransformPointSmoother,
52 Foam::pointSmoothers::geometricElementTransformPointSmoother::cellQuality
56 const cellPointConnectivity& connectivity,
70 const label pointi(cPoints[cPointi]);
71 const point& pt = currentPoints[pointi];
74 connectivity.cellPointPoints()[celli][cPointi]
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)
179 cFaces.labels(
mesh().faces())
183 cFaces.edges(
mesh().faces())
189 const label pointI(cPoints[cPointI]);
191 if (counts[pointI] == -1)
continue;
201 const label nPPoints(pPoints.size());
204 vector dualAverage(vector::zero);
208 currentPoints[pPoints[pPointI]]
209 + faceCentres[
pFaces[pPointI]];
211 dualAverage /= 2*nPPoints;
214 vector dualNormal(vector::zero);
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));
250 vector sumAc(vector::zero);
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);
453 Foam::pointSmoothers::geometricElementTransformPointSmoother::cellQuality
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
void size(const label n)
Older name for setAddressableSize.
Class calculates cell quality measures.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
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...
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.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
static FOAM_NO_DANGLING_REFERENCE const Type & New(const Mesh &mesh, Args &&... args)
Get existing or create MeshObject registered with typeName.
const dimensionedScalar c2
Second radiation constant: default SI units: [m.K].
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
const cellList & cells() const
dimensionedScalar det(const dimensionedSphericalTensor &dt)
dimensionedScalar sigma("sigma", dimMass/sqr(dimTime), transportProperties)
Macros for easy insertion into run-time selection tables.
#define forAll(list, i)
Loop across all elements in list.
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &f1, const label comm)
vectorField pointField
pointField is a vectorField.
const polyMesh & mesh() const noexcept
Access the mesh.
addToRunTimeSelectionTable(pointSmoother, equipotentialPointSmoother, dictionary)
const labelListListList & cellPointFaces() const
Access the point-face connections.
dimensionedScalar cbrt(const dimensionedScalar &ds)
This class provides ordered connectivity for each point of each cell. Lists are available of the poin...
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]
virtual const faceList & faces() const
Return raw faces.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
vector point
Point is a vector.
#define WarningInFunction
Report a warning using Foam::Warning.
limits reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL))
const dimensionedScalar c1
First radiation constant: default SI units: [W/m2].
Mesh consisting of general polyhedral cells.
List< label > labelList
A List of labels.
A class for managing temporary objects.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
defineTypeNameAndDebug(equipotentialPointSmoother, 0)
const labelListListList & cellPointPoints() const
Access the point-point connections.