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 readScalar(
dict.
lookup(
"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]);
173 const label cellI(iter.key());
181 cFaces.labels(
mesh().faces())
185 cFaces.edges(
mesh().faces())
191 const label pointI(cPoints[cPointI]);
193 if (counts[pointI] == -1)
continue;
203 const label nPPoints(pPoints.size());
206 vector dualAverage(vector::zero);
210 currentPoints[pPoints[pPointI]]
211 + faceCentres[
pFaces[pPointI]];
213 dualAverage /= 2*nPPoints;
216 vector dualNormal(vector::zero);
219 const label nextPPointI((pPointI + 1) % nPPoints);
225 currentPoints[pPoints[pPointI]]
226 + currentPoints[pointI]
231 faceCentres[
pFaces[nextPPointI]]
237 currentPoints[pPoints[nextPPointI]]
238 + currentPoints[pointI]
243 (nextFaceCentre - edgeCentre)
244 ^(edgeCentre - dualAverage);
246 (nextEdgeCentre - nextFaceCentre)
247 ^(nextFaceCentre - dualAverage);
249 vector dualNormalHat(dualNormal/
max(
mag(dualNormal), ROOTVSMALL));
252 vector sumAc(vector::zero);
255 const label nextPPointI((pPointI + 1) % nPPoints);
261 currentPoints[pPoints[pPointI]]
262 + currentPoints[pointI]
267 faceCentres[
pFaces[nextPPointI]]
273 currentPoints[pPoints[nextPPointI]]
274 + currentPoints[pointI]
278 vector c1 = edgeCentre + nextFaceCentre + dualAverage;
279 vector c2 = nextFaceCentre + nextEdgeCentre + dualAverage;
282 (nextFaceCentre - edgeCentre)
283 ^(edgeCentre - dualAverage);
285 (nextEdgeCentre - nextFaceCentre)
286 ^(nextFaceCentre - dualAverage);
288 scalar a1 = n1 & dualNormalHat;
289 scalar a2 = n2 & dualNormalHat;
292 sumAc += a1*
c1 + a2*
c2;
295 const vector dualCentre(sumAc/
max(sumA, ROOTVSMALL)/3);
298 transformedPoints[pointI] =
300 + transformationParameter_
301 *dualNormal/
sqrt(
max(
mag(dualNormal), ROOTVSMALL));
305 scalar lengthScale(0), transformedLengthScale(0);
309 cEdges[cEdgeI].mag(currentPoints);
310 transformedLengthScale +=
311 cEdges[cEdgeI].mag(transformedPoints);
313 lengthScale /= cEdges.size();
314 transformedLengthScale /= cEdges.size();
316 const scalar lengthScaleRatio =
318 (transformedLengthScale > SMALL)
319 ? lengthScale/transformedLengthScale
326 const label pointI(cPoints[cPointI]);
328 if (counts[pointI] == -1)
continue;
335 transformedPoints[pointI]
342 pointDisplacement[pointI] += newPoint - oldPoints[pointI];
347 reset(facesToMove, counts, pointDisplacement,
false);
350 forAll(facesToMove, faceToMoveI)
352 const label faceI(facesToMove[faceToMoveI]);
354 if (!isInternalOrProcessorFace(faceI))
359 vector faceNormalHat(faceAreas[faceI]);
360 faceNormalHat /=
max(SMALL,
mag(faceNormalHat));
365 const label pointI(fPoints[fPointI]);
367 const label fPointIPrev
369 (fPointI - 1 + fPoints.size()) % fPoints.size()
371 const label fPointINext
373 (fPointI + 1) % fPoints.size()
378 currentPoints[pointI]/2
380 currentPoints[fPoints[fPointINext]]
381 + currentPoints[fPoints[fPointIPrev]]
387 currentPoints[fPoints[fPointINext]]
388 - currentPoints[fPoints[fPointIPrev]]
393 transformedPoints[pointI] =
395 + transformationParameter_
396 *dualNormal/
sqrt(
max(
mag(dualNormal), ROOTVSMALL));
400 scalar lengthScale(0), transformedLengthScale(0);
403 const label fPointINext((fPointI + 1)%fPoints.size());
405 const label pointI(fPoints[fPointI]);
406 const label pointINext(fPoints[fPointINext]);
410 currentPoints[pointINext] - currentPoints[pointI]
412 transformedLengthScale +=
mag 414 transformedPoints[pointINext] - transformedPoints[pointI]
417 lengthScale /= fPoints.size();
418 transformedLengthScale /= fPoints.size();
420 const scalar lengthScaleRatio
422 (transformedLengthScale > SMALL)
423 ? lengthScale/transformedLengthScale
430 const label pointI(fPoints[fPointI]);
437 transformedPoints[pointI]
444 pointDisplacement[pointI] += newPoint - oldPoints[pointI];
450 average(facesToMove, counts, pointDisplacement);
455 Foam::pointSmoothers::geometricElementTransformPointSmoother::cellQuality
const polyMesh & mesh() const
void size(const label n)
Older name for setAddressableSize.
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &f1)
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.
static const Type & New(const Mesh &mesh, Args &&... args)
Get existing or create MeshObject registered with typeName.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
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)
Lookup type of boundary radiation properties.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object.
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.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
vectorField pointField
pointField is a vectorField.
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...
virtual const faceList & faces() const
Return raw faces.
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];} label minLabel=min(start, end);pointMap[start]=pointMap[end]=minLabel;} } 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};const 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< SLList< face > > pFaces[nBCs]
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.
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.