56 const scalar minRatio,
69 for (label facei = 0; facei <
mesh_.
nFaces(); facei++)
74 const vector& fcCorr = faceCorrection[facei];
83 const point& fc = faceCentres[facei];
140 ownHeight.
setSize(mesh_.nFaces());
141 neiHeight.
setSize(mesh_.nInternalFaces());
143 const labelList& own = mesh_.faceOwner();
144 const labelList& nei = mesh_.faceNeighbour();
146 for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
153 ownHeight[facei] = ((fc-ownCc)&
n);
154 neiHeight[facei] = ((neiCc-fc)&
n);
157 for (label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); facei++)
163 ownHeight[facei] = ((fc-ownCc)&
n);
183 const labelList& own = mesh_.faceOwner();
184 const labelList& nei = mesh_.faceNeighbour();
187 for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
194 const point& fc = faceCentres[facei];
197 const label ownCelli = own[facei];
201 const scalar ownHeight = ((fc-ownCc)&
n);
202 if (ownHeight < minOwnHeight[facei])
214 const label neiCelli = nei[facei];
218 const scalar neiHeight = ((neiCc-fc)&
n);
219 if (neiHeight < minNeiHeight[facei])
232 for (label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); facei++)
239 const point& fc = faceCentres[facei];
242 const label ownCelli = own[facei];
246 const scalar ownHeight = ((fc-ownCc)&
n);
247 if (ownHeight < minOwnHeight[facei])
271 const labelList& own = mesh_.faceOwner();
272 const labelList& nei = mesh_.faceNeighbour();
281 for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
288 const point& ownCc = cellCentres[own[facei]];
289 const point& neiCc = cellCentres[nei[facei]];
303 const scalar w = 0.5*faceWeights[facei];
304 cc[own[facei]] +=
point(w*d);
305 cellWeights[own[facei]] += w;
307 cc[nei[facei]] -=
point(w*d);
308 cellWeights[nei[facei]] += w;
325 const label meshFacei = pp.start()+i;
326 const label bFacei = meshFacei-mesh_.nInternalFaces();
334 const point& ownCc = cellCentres[fc[i]];
335 const point& neiCc = neiCellCentres[bFacei];
348 const scalar w = 0.5*faceWeights[meshFacei];
349 cc[fc[i]] +=
point(w*d);
350 cellWeights[fc[i]] += w;
358 if (cellWeights[celli] > VSMALL)
360 cc[celli] = cellCentres[celli] + cc[celli]/cellWeights[celli];
364 cc[celli] = cellCentres[celli];
381 const labelList& own = mesh_.faceOwner();
382 const labelList& nei = mesh_.faceNeighbour();
389 for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
396 const point& oldFc = faceCentres[facei];
416 const solveScalar
f = (deltaFc&
n)/(deltaCc&
n);
428 newFc[facei] = oldFc + d;
446 const label facei = pp.start()+i;
447 const label bFacei = facei-mesh_.nInternalFaces();
454 const point& oldFc = faceCentres[facei];
464 const solveScalar
f = (deltaFc&
n)/(deltaCc&
n);
472 newFc[facei] = oldFc + d;
480 const label facei = pp.start()+i;
487 const point& oldFc = faceCentres[facei];
497 newFc[facei] = oldFc+d;
541 const scalar cosAngle = cosAngles[facei];
542 if (cosAngle < minCos)
544 faceWeights[facei] = 1.0;
546 else if (cosAngle > maxCos)
548 faceWeights[facei] = 0.0;
553 1.0-(cosAngle-minCos)/(maxCos-minCos);
571 dict.getCheckOrDefault<label>
575 [](label val) {
return val >= 0; }
583 [](scalar val) { return val > 0 && val <= 1; }
592 [](scalar val) { return val >= 0 && val <= 1; }
598 Pout<<
"averageNeighbourFvGeometryScheme :"
599 <<
" nIters:" << nIters_
600 <<
" relax:" << relax_
601 <<
" minRatio:" << minRatio_ <<
endl;
615 Pout<<
"averageNeighbourFvGeometryScheme::movePoints() : "
616 <<
"recalculating primitiveMesh centres" <<
endl;
641 calcAspectRatioWeights(cellWeight, faceWeight);
644 cellWeight *= relax_;
661 minOwnHeight *= minRatio_;
662 minNeiHeight *= minRatio_;
674 mesh_.time().timePath()
675 /
"cellCentre_correction.obj"
678 Pout<<
"averageNeighbourFvGeometryScheme::movePoints() :"
679 <<
" writing cell centre path to " << osPtr().name() <<
endl;
685 mesh_.time().globalPath()
687 / mesh_.pointsInstance()
697 writerPtr->useTimeDir(
true);
699 writerPtr->beginTime(mesh_.time());
705 (outputDir /
"cosAngle"),
709 writerPtr->endTime();
718 for (label iter = 0; iter < nIters_; iter++)
751 writerPtr->beginTime(
instant(scalar(iter)));
752 writerPtr->write(
"cosAngles", cosAngles);
753 writerPtr->endTime();
762 Pout<<
" face:" << facei
763 <<
" at:" << mesh_.faceCentres()[facei]
764 <<
" cosAngle:" << cosAngles[facei]
765 <<
" faceWeight:" << faceWeights[facei]
771 tcc = averageNeighbourCentres
785 const label nClipped = clipPyramids
801 forAll(cellCentres, celli)
803 const point& cc = cellCentres[celli];
828 Pout<<
" iter:" << iter
829 <<
" nClipped:" << nClipped
830 <<
" average displacement:" <<
gAverage(magCorrection)
831 <<
" non-ortho angle : average:" <<
gAverage(nonOrthoAngle)
832 <<
" max:" <<
gMax(nonOrthoAngle) <<
endl;
845 vectorField faceCorrection(faceWeight*(tfc-mesh_.faceCentres()));
855 vectorField faceCentres(mesh_.faceCentres() + faceCorrection);
859 Pout<<
"averageNeighbourFvGeometryScheme::movePoints() :"
860 <<
" averageNeighbour weight"
861 <<
" max:" <<
gMax(cellWeight) <<
" min:" <<
gMin(cellWeight)
865 const fileName tp(mesh_.time().timePath());
867 OBJstream str(tp/
"averageNeighbourCellCentres.obj");
868 Pout<<
"Writing lines from old to new cell centre to " << str.
name()
870 forAll(mesh_.cellCentres(), celli)
872 const point& oldCc = mesh_.cellCentres()[celli];
873 const point& newCc = cellCentres[celli];
880 const fileName tp(mesh_.time().timePath());
881 OBJstream str(tp/
"averageFaceCentres.obj");
882 Pout<<
"Writing lines from old to new face centre to " << str.
name()
884 forAll(mesh_.faceCentres(), facei)
886 const point& oldFc = mesh_.faceCentres()[facei];
887 const point& newFc = faceCentres[facei];
898 std::move(faceCentres),
899 std::move(faceAreas),
900 std::move(cellCentres),
901 std::move(cellVolumes)
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
void setSize(const label n)
Alias for resize()
OFstream that keeps track of vertices.
virtual Ostream & write(const char c)
Write character.
virtual const fileName & name() const
Read/write access to the name of the stream.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
const T & fcValue(const label i) const
Return forward circular value (ie, next value in the list)
void size(const label n)
Older name for setAddressableSize.
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
void reset(autoPtr< T > &&other) noexcept
Delete managed object and set to new given pointer.
Geometry calculation scheme to minimise non-orthogonality/.
label clipFaceTet(const scalar minRatio, const vectorField &faceCentres, const vectorField &faceNormals, vectorField &faceCorrection) const
tmp< pointField > averageCentres(const pointField &cellCentres, const pointField &faceCentres, const vectorField &faceNormals) const
virtual void movePoints()
Do what is necessary if the mesh has moved.
void makePyrHeights(const pointField &cellCentres, const vectorField &faceCentres, const vectorField &faceNormals, scalarField &ownHeight, scalarField &neiHeight) const
Calculate pyramid heights.
tmp< pointField > averageNeighbourCentres(const pointField &cellCentres, const vectorField &faceNormals, const scalarField &faceWeights) const
Average neighbouring cell centres to minimise non-ortho.
label clipPyramids(const pointField &cellCentres, const vectorField &faceCentres, const vectorField &faceNormals, const scalarField &minOwnHeight, const scalarField &minNeiHeight, vectorField &correction) const
void makeNonOrthoWeights(const pointField &cellCentres, const vectorField &faceNormals, scalarField &cosAngles, scalarField &faceWeights) const
Make weights based on non-orthogonality.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
T getCheck(const word &keyword, const Predicate &pred, enum keyType::option matchOpt=keyType::REGEX) const
T getCheckOrDefault(const word &keyword, const T &deflt, const Predicate &pred, enum keyType::option matchOpt=keyType::REGEX) const
A face is a list of labels corresponding to mesh vertices.
A class for handling file names.
static bool clean(std::string &str)
static word outputPrefix
Directory prefix.
Abstract base class for geometry calculation schemes.
const fvMesh & mesh_
Hold reference to mesh.
Mesh data needed to do the Finite Volume discretisation.
Geometry calculation scheme with automatic stabilisation for high-aspect ratio cells.
virtual void movePoints()
Do what is necessary if the mesh has moved.
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
virtual const faceList & faces() const
Return raw faces.
virtual const pointField & points() const
Return raw points.
A patch is a list of labels that address the faces in the global face list.
label nFaces() const noexcept
Number of mesh faces.
void resetGeometry(pointField &&faceCentres, pointField &&faceAreas, pointField &&cellCentres, scalarField &&cellVolumes)
Reset the local geometry.
A class for managing temporary objects.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
surfaceVectorField faceNormals(mesh.Sf()/mesh.magSf())
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
line< point, const point & > linePointRef
A line using referred points.
vectorField pointField
pointField is a vectorField.
vector point
Point is a vector.
Ostream & endl(Ostream &os)
Add newline and flush stream.
constexpr scalar degToRad() noexcept
Multiplication factor for degrees to radians conversion.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
constexpr scalar radToDeg() noexcept
Multiplication factor for radians to degrees conversion.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Type gAverage(const FieldField< Field, Type > &f)
static constexpr const zero Zero
Global zero (0)
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Type gMin(const FieldField< Field, Type > &f)
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Type gMax(const FieldField< Field, Type > &f)
dimensionedScalar cos(const dimensionedScalar &ds)
dimensionedScalar acos(const dimensionedScalar &ds)
#define forAll(list, i)
Loop across all elements in list.
A non-counting (dummy) refCount.
Unit conversion functions.