53 hexMeshSmootherMotionSolver,
59 displacementMotionSolver,
60 hexMeshSmootherMotionSolver,
76 const auto&
pbm =
mesh.boundaryMesh();
79 for (
const auto&
pp :
pbm)
81 if (!polyPatch::constraintType(
pp.type()))
91 Foam::hexMeshSmootherMotionSolver::makePatch
100 bitSet isPatchFace(
mesh.nFaces());
105 const polyPatch&
pp =
mesh.boundaryMesh()[patchi];
106 isPatchFace.set(
pp.range());
109 const auto& fzs =
mesh.faceZones();
110 for (
const label zonei :
zoneIDs)
112 isPatchFace.set(fzs[zonei]);
115 syncTools::syncFaceList(
mesh, isPatchFace, orEqOp<unsigned int>());
117 const labelList patchFaces(isPatchFace.sortedToc());
121 IndirectList<face>(
mesh.faces(), patchFaces),
127 void Foam::hexMeshSmootherMotionSolver::checkMesh
143 markedPoints =
false;
187 tmp<scalarField> tfaceQ
189 pointSmoother_->faceQuality
198 const auto& faceQ = tfaceQ();
203 if (faceQ[facei] < VSMALL)
205 markedFaces.insert(facei);
206 markedPoints.set(
mesh().faces()[facei]);
211 syncTools::syncPointList
215 orEqOp<unsigned int>(),
221 bitSet isMarkedFace(
mesh().nFaces());
222 isMarkedFace.set(markedFaces.toc());
223 syncTools::syncFaceList
227 orEqOp<unsigned int>()
229 markedFaces.insert(isMarkedFace.toc());
255 const bitSet& pointsToRelax,
265 relaxedPoints = wantedPoints;
275 reinterpret_cast<const fvMesh&
>(
mesh()).geometry();
302 Pout<<
"** hexMeshSmootherMotionSolver::relax : errorfaces:" 303 << markedFaces.size()
304 <<
" errorpoints:" << markedPoints.count() <<
endl;
313 relaxationLevel = -1;
314 for (
const label pointi : pointsToRelax)
316 relaxationLevel[pointi] = 0;
319 syncTools::syncPointList
333 bool complete(
false);
341 forAll(relaxationLevel, pointi)
343 if (relaxationLevel[pointi] >= 0)
347 relaxationFactors[relaxationLevel[pointi]]
350 relaxedPoints[pointi] =
351 (1 -
x)*initialPoints[pointi]
352 +
x*wantedPoints[pointi];
364 reinterpret_cast<const fvMesh&
>(
mesh()).geometry();
393 for (
const label pointi : markedPoints)
395 if (relaxationLevel[pointi] < relaxationFactors.size() - 1)
397 ++relaxationLevel[pointi];
408 UPstream::reduceAnd(complete);
411 syncTools::syncPointList
421 const label
count(countPos(relaxationLevel));
422 const bool converged(
count == 0);
435 Foam::label Foam::hexMeshSmootherMotionSolver::countPos
441 for (
const label elem : elems)
459 for (
const label elem : elems)
467 Pstream::listReduce(
n, sumOp<label>());
479 isVal.
set(lst.size());
483 isVal[i] = (lst[i] == val);
488 void Foam::hexMeshSmootherMotionSolver::laplaceSmooth
495 if (initialPoints.size() !=
mesh().nPoints())
501 newPoints.setSize(initialPoints.size());
505 DynamicList<label> storage;
506 forAll(pointTypes_, pointi)
508 if (pointTypes_[pointi] == INTERIOR)
510 const labelList& pPoints =
mesh().pointPoints(pointi, storage);
511 for (
const label otherPointi : pPoints)
513 if (isMasterPoint_[otherPointi])
515 newPoints[pointi] += initialPoints[otherPointi];
526 syncTools::syncPointList
533 syncTools::syncPointList
545 newPoints[pointi] = initialPoints[pointi];
550 newPoints[pointi] /=
n[pointi];
556 void Foam::hexMeshSmootherMotionSolver::featLaplaceSmooth
563 if (initialPoints.size() !=
pp.nPoints())
569 newPoints.setSize(
pp.nPoints());
577 forAll(pointEdges, pointi)
579 const label myConstraint = pointTypes_[meshPoints[pointi]];
580 if (myConstraint != INTERIOR)
582 const labelList& pEdges = pointEdges[pointi];
586 for (
const label edgei : pEdges)
588 const label otherPointi = edges[edgei].otherVertex(pointi);
589 const label otherMeshPointi = meshPoints[otherPointi];
590 const label otherConstraint = pointTypes_[otherMeshPointi];
594 (otherConstraint != INTERIOR)
595 && (myConstraint <= otherConstraint)
596 && isMasterPoint_[otherMeshPointi]
602 newPoints[pointi] += initialPoints[otherPointi];
610 syncTools::syncPointList
618 syncTools::syncPointList
633 newPoints[pointi] = initialPoints[pointi];
638 newPoints[pointi] /=
n[pointi];
645 void Foam::hexMeshSmootherMotionSolver::snapBoundaryPoints
652 if (initialPoints.size() != pointDisplacement_.mesh().size())
655 <<
"mesh.nPoints():" << pointDisplacement_.mesh().size()
667 pointDisplacement_.primitiveFieldRef() = initialPoints-
points0();
669 pointDisplacement_.correctBoundaryConditions();
672 newPoints =
points0() + pointDisplacement().internalField();
681 UIndirectList<point>(newPoints,
mp) = d;
714 void Foam::hexMeshSmootherMotionSolver::emptyCorrectPoints
721 auto&
fld = pointDisplacement.primitiveFieldRef();
722 for (
const auto& ppf : pointDisplacement.boundaryField())
724 if (isA<emptyPointPatchVectorField>(ppf))
726 const auto&
mp = ppf.patch().meshPoints();
730 ppf.patch().applyConstraint(i, pc);
731 fld[
mp[i]] = pc.constrainDisplacement(
fld[
mp[i]]);
737 twoDCorrectPoints(wantedPoints);
744 Foam::hexMeshSmootherMotionSolver::
745 hexMeshSmootherMotionSolver
747 const polyMesh&
mesh,
748 const IOdictionary&
dict 751 displacementMotionSolver(
mesh,
dict, typeName),
752 pointSmoother_(pointSmoother::
New(
mesh, coeffDict())),
755 coeffDict().
get<label>(
"nPointSmootherIter")
757 relaxationFactors_(coeffDict().
get<
scalarList>(
"relaxationFactors")),
776 snapScale_(Function1<scalar>::
New(
"snapScale", coeffDict())),
777 isMasterPoint_(syncTools::getMasterPoints(
mesh)),
785 nonConstraintPatches(
mesh),
812 pointTypes_.setSize(pMesh.size());
813 pointTypes_ = INTERIOR;
815 for (
const auto&
pp : pMesh.boundary())
817 if (!isA<meshPointPatch>(
pp))
819 const auto&
mp =
pp.meshPoints();
820 UIndirectList<label>(pointTypes_,
mp) = pointType::SURFACE;
825 for (
const auto&
pp : pMesh.boundary())
827 const auto* meshPointPtr = isA<meshPointPatch>(
pp);
830 const auto& constraints = meshPointPtr->constraints();
831 const auto&
mp = meshPointPtr->meshPoints();
835 pointTypes_[
mp[i]] = pointType(constraints[i].
first());
850 select(pointTypes_, POINT, isVal);
851 const label nFeatPoint =
returnReduce(isVal.count(), sumOp<label>());
852 select(pointTypes_, EDGE, isVal);
853 const label nFeatEdge =
returnReduce(isVal.count(), sumOp<label>());
854 select(pointTypes_, SURFACE, isVal);
855 const label nSurface =
returnReduce(isVal.count(), sumOp<label>());
856 select(pointTypes_, INTERIOR, isVal);
857 const label nInternal =
returnReduce(isVal.count(), sumOp<label>());
858 Info<<
"Attraction:" <<
nl 859 <<
" feature point:" << nFeatPoint <<
nl 860 <<
" feature edge :" << nFeatEdge <<
nl 861 <<
" surface :" << nSurface <<
nl 862 <<
" none :" << nInternal
867 Foam::hexMeshSmootherMotionSolver::
868 hexMeshSmootherMotionSolver
870 const polyMesh&
mesh,
871 const IOdictionary&
dict,
876 displacementMotionSolver(
mesh,
dict, pointDisplacement,
points0, typeName),
877 pointSmoother_(pointSmoother::
New(
mesh, coeffDict())),
888 coeffDict().
get<label>(
"nPointSmootherIter")
890 relaxationFactors_(coeffDict().
get<
scalarList>(
"relaxationFactors")),
909 snapScale_(Function1<scalar>::
New(
"snapScale", coeffDict())),
910 isMasterPoint_(syncTools::getMasterPoints(
mesh)),
918 nonConstraintPatches(
mesh),
943 pointTypes_ = INTERIOR;
945 for (
const auto&
pp : pMesh.boundary())
947 if (!isA<meshPointPatch>(
pp) && !
pp.coupled())
949 const auto&
mp =
pp.meshPoints();
950 UIndirectList<label>(pointTypes_,
mp) = pointType::SURFACE;
955 for (
const auto&
pp : pMesh.boundary())
957 const auto* meshPointPtr = isA<meshPointPatch>(
pp);
960 const auto& constraints = meshPointPtr->constraints();
961 const auto&
mp = meshPointPtr->meshPoints();
965 pointTypes_[
mp[i]] = pointType(constraints[i].
first());
980 select(pointTypes_, POINT, isVal);
981 const label nFeatPoint =
returnReduce(isVal.count(), sumOp<label>());
982 select(pointTypes_, EDGE, isVal);
983 const label nFeatEdge =
returnReduce(isVal.count(), sumOp<label>());
984 select(pointTypes_, SURFACE, isVal);
985 const label nSurface =
returnReduce(isVal.count(), sumOp<label>());
986 select(pointTypes_, INTERIOR, isVal);
987 const label nInternal =
returnReduce(isVal.count(), sumOp<label>());
988 Info<<
"Attraction:" <<
nl 989 <<
" feature point:" << nFeatPoint <<
nl 990 <<
" feature edge :" << nFeatEdge <<
nl 991 <<
" surface :" << nSurface <<
nl 992 <<
" none :" << nInternal
999 Foam::hexMeshSmootherMotionSolver::
1000 ~hexMeshSmootherMotionSolver()
1007 Foam::hexMeshSmootherMotionSolver::curPoints()
const 1010 return relaxedPoints_;
1031 bitSet isInternalPoint;
1032 select(pointTypes_, INTERIOR, isInternalPoint);
1045 const label nRelaxed = countPos(relaxationLevel_);
1062 laplaceSmooth(INTERIOR, initialPoints, movedPoints);
1089 const scalar scale = snapScale_->value(
mesh().time().
timeIndex());
1093 snapBoundaryPoints(scale, initialPoints, movedPoints);
1125 UIndirectList<point>(movedPoints,
mp) = bndMovedPoints;
1164 UIndirectList<point>(movedPoints,
mp) = bndMovedPoints;
1196 const scalar scale = snapScale_->value(
mesh().time().
timeIndex());
1200 snapBoundaryPoints(scale, relaxedPoints_, movedPoints);
1223 movedPoints = relaxedPoints_;
1225 for(label i = 0; i < nPointSmootherIter_; i ++)
1231 reinterpret_cast<const fvMesh&
>(
mesh()).geometry();
1244 pointSmoother_->update
1256 emptyCorrectPoints(pointDisplacement());
1259 movedPoints =
points0() + pointDisplacement().internalField();
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
List< scalar > scalarList
List of scalar.
const labelList patchIDs(pbm.indices(polyPatchNames, true))
const polyBoundaryMesh & pbm
const labelIOList & zoneIDs
errorManipArg< error, int > exit(error &err, const int errNo=1)
label nPoints() const noexcept
Number of mesh points.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
List< edge > edgeList
List of edge.
vectorIOField pointIOField
pointIOField is a vectorIOField.
Unit conversion functions.
static FOAM_NO_DANGLING_REFERENCE const pointMesh & New(const polyMesh &mesh, Args &&... args)
Get existing or create MeshObject registered with typeName.
List< bool > select(const label n, const labelUList &locations)
Construct a selection list of bools (all false) with the given pre-size, subsequently add specified l...
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
GeometricField< vector, pointPatchField, pointMesh > pointVectorField
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
A PrimitivePatch with an IndirectList for the faces, const reference for the point field...
List< labelList > labelListList
List of labelList.
Macros for easy insertion into run-time selection tables.
UList< label > labelUList
A UList of labels.
virtual const pointField & points() const
Return raw points.
#define forAll(list, i)
Loop across all elements in list.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
vectorField pointField
pointField is a vectorField.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Reading is optional [identical to LAZY_READ].
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
int debug
Static debugging option.
defineTypeNameAndDebug(combustionModel, 0)
const scalarField & cellVols
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))
pointField points0(pointIOField(IOobject("points", mesh.time().constant(), polyMesh::meshSubDir, mesh, IOobject::MUST_READ, IOobject::NO_WRITE, IOobject::NO_REGISTER)))
return returnReduce(nRefine-oldNRefine, sumOp< label >())
messageStream Info
Information stream (stdout output on master, null elsewhere)
Field< vector > vectorField
Specialisation of Field<T> for vector.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
std::enable_if_t< std::is_same_v< bool, TypeT >, bool > set(const label i, bool val=true)
A bitSet::set() method for a list of bool.
List< label > labelList
A List of labels.
const polyMesh & mesh() const
Return reference to mesh.
A class for managing temporary objects.
T * first()
The first entry in the list.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
const dimensionedScalar mp
Proton mass.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)
static constexpr const zero Zero
Global zero (0)