48 displacementSmartPointSmoothingMotionSolver,
54 displacementMotionSolver,
55 displacementSmartPointSmoothingMotionSolver,
73 const label faceI(iter.key());
75 const face& fPoints(
mesh().faces()[faceI]);
79 const label pointI(fPoints[fPointI]);
81 affectedPoints[pointI] =
true;
89 orEqOp<unsigned int>(),
93 forAll(affectedPoints, pointI)
95 if (affectedPoints[pointI])
101 const label cellI(pCells[pointCellI]);
116 (relaxationFactors_.size() == 0)
117 || (relaxationFactors_.size() == 1 && relaxationFactors_[0] == 1.0)
125 const pointField oldRelaxedPoints(relaxedPoints_);
135 const label faceI(iter.key());
137 const face& fPoints(
mesh().faces()[faceI]);
141 const label pointI(fPoints[fPointI]);
143 relaxationLevel[pointI] = 0;
156 bool complete(
false);
164 forAll(relaxationLevel, pointI)
166 if (relaxationLevel[pointI] >= 0)
170 relaxationFactors_[relaxationLevel[pointI]]
173 relaxedPoints_[pointI] =
174 (1 -
x)*oldRelaxedPoints[pointI]
175 +
x*(
points0()[pointI] + pointDisplacement()[pointI]);
181 markAffectedFaces(affectedFaces, markedFaces);
182 labelList markedFacesList(markedFaces.toc());
185 meshGeometry_.correct(relaxedPoints_, markedFacesList);
203 affectedFaces.
clear();
204 markAffectedFaces(markedFaces, affectedFaces);
209 tmp<scalarField> tfaceQ
211 pointUntangler_->faceQuality
214 meshGeometry_.faceCentres(),
215 meshGeometry_.faceAreas(),
216 meshGeometry_.cellCentres(),
217 meshGeometry_.cellVolumes()
234 if (tfaceQ()[order[i]] > untangleQ_)
241 affectedFaces =
labelList(SubList<label>(order, nUntangle));
249 const label faceI(iter.key());
251 const face& fPoints(
mesh().faces()[faceI]);
255 const label pointI(fPoints[fPointI]);
257 pointsToRelax[pointI] =
true;
261 forAll(pointsToRelax, pointI)
265 pointsToRelax[pointI]
266 && (relaxationLevel[pointI] < relaxationFactors_.size() - 1)
269 ++ relaxationLevel[pointI];
285 reduce(complete, andOp<bool>());
289 bool converged(
true);
292 const face& fPoints(
mesh().faces()[faceI]);
296 const label pointI(fPoints[fPointI]);
298 if (relaxationLevel[pointI] > 0)
300 facesToMove_.insert(faceI);
310 reduce(converged, andOp<bool>());
332 facesToMove_.resize(2*
mesh().nFaces());
335 facesToMove_.insert(faceI);
340 facesToMove_.resize(2*(
mesh().nBoundaryFaces()));
343 label faceI =
mesh().nInternalFaces();
348 facesToMove_.insert(faceI);
361 auto&
fld = pointDisplacement.primitiveFieldRef();
362 for (
const auto& ppf : pointDisplacement.boundaryField())
364 if (isA<emptyPointPatchVectorField>(ppf))
366 const auto&
mp = ppf.patch().meshPoints();
370 ppf.patch().applyConstraint(i, pc);
371 fld[
mp[i]] = pc.constrainDisplacement(
fld[
mp[i]]);
377 twoDCorrectPoints(wantedPoints);
397 coeffDict().
get<
word>(
"untangler"),
402 untangleQ_(coeffDict().
get<scalar>(
"untangleQ")),
403 minQ_(coeffDict().
get<scalar>(
"minQ")),
422 const polyMesh&
mesh,
423 const IOdictionary&
dict,
428 displacementMotionSolver(
mesh,
dict, pointDisplacement,
points0, typeName),
434 coeffDict().
get<word>(
"untangler"),
439 untangleQ_(coeffDict().
get<scalar>(
"untangleQ")),
440 minQ_(coeffDict().
get<scalar>(
"minQ")),
451 readLabel(coeffDict().lookup(
"nPointSmootherIter"))
470 return relaxedPoints_;
476 movePoints(curPoints());
480 pointDisplacement().boundaryFieldRef().updateCoeffs();
493 + pointDisplacement().internalField()
495 const auto&
pbm = pointDisplacement().
mesh().boundary();
496 for (
const auto& ppp :
pbm)
498 if (!isA<emptyPointPatch>(ppp))
500 const auto&
mp = ppp.meshPoints();
501 for (
const label pointi :
mp)
521 markAffectedFaces(facesToMove_, affectedFaces);
524 for(label i = 0; i < nPointSmootherIter_; i ++)
529 + pointDisplacement().internalField()
532 meshGeometry_.correct
579 tmp<scalarField> tfaceQ
581 pointUntangler_->faceQuality
584 meshGeometry_.faceCentres(),
585 meshGeometry_.faceAreas(),
586 meshGeometry_.cellCentres(),
587 meshGeometry_.cellVolumes()
605 if (tfaceQ()[order[i]] > untangleQ_)
614 if (tfaceQ()[order[i]] > minQ_)
634 labelList lowQFaces(SubList<label>(order, nUntangle));
651 pointUntangler_->update
664 emptyCorrectPoints(pointDisplacement());
668 OBJstream
os(debugDir/
"untangle_" +
Foam::name(i) +
".obj");
673 + pointDisplacement().internalField()
675 forAll(wantedPoints, pointi)
692 labelList lowQFaces(SubList<label>(order, nLow));
710 pointSmoother_->update
719 emptyCorrectPoints(pointDisplacement());
732 twoDCorrectPoints(relaxedPoints_);
736 pointDisplacement().primitiveFieldRef() = relaxedPoints_-
points0();
740 const pointConstraints& pcs =
742 pcs.constrainDisplacement(pointDisplacement(),
false);
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
static bool checkMesh(const bool report, const polyMesh &mesh, const dictionary &dict, labelHashSet &wrongFaces, const bool dryRun=false)
Check mesh with mesh settings in dict. Collects incorrect faces.
const polyBoundaryMesh & pbm
virtual tmp< pointField > curPoints() const
Return point location obtained from the current motion field.
Virtual base class for displacement motion solver.
A class for handling file names.
A face is a list of labels corresponding to mesh vertices.
virtual Ostream & write(const char c) override
Write character.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
fileName timePath() const
Return current time path = path/timeName.
Abstract base class for point smoothing methods. Handles parallel communication via reset and average...
labelList sortedOrder(const UList< T > &input)
Return the (stable) sort order for the list.
virtual const fileName & name() const override
Read/write access to the name of the stream.
vectorIOField pointIOField
pointIOField is a vectorIOField.
static const pointConstraints & New(const pointMesh &mesh, Args &&... args)
Get existing or create MeshObject registered with typeName.
const Internal & internalField() const noexcept
Return a const-reference to the dimensioned internal field.
constexpr char nl
The newline '\n' character (0x0a)
dictionary meshQualityDict_
Mesh quality dictionary.
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.
label readLabel(const char *buf)
Parse entire buffer as a label, skipping leading/trailing whitespace.
GeometricField< vector, pointPatchField, pointMesh > pointVectorField
virtual void setFacesToMove(const dictionary &)
Set all the faces to be moved.
const dictionary & coeffDict() const
Const access to the coefficients dictionary.
const Time & time() const
Return the top-level database.
label nFaces() const noexcept
Number of mesh faces.
Lookup type of boundary radiation properties.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object.
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
label nVertices() const noexcept
Return the number of vertices written.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Macros for easy insertion into run-time selection tables.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
#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.
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
line< point, const point & > linePointRef
A line using referred points.
const polyMesh & mesh() const noexcept
Return the mesh reference.
void clear()
Clear the list, i.e. set size to zero.
A class for handling words, derived from Foam::string.
void clear()
Remove all entries from table.
virtual void solve()
Solve for motion.
void emptyCorrectPoints(pointVectorField &pointDisplacement)
Handle 2D & empty bcs. Assume in both cases the starting mesh.
MinMax< Type > gMinMax(const FieldField< Field, Type > &f)
bool relax()
Relax the points.
An OFstream that keeps track of vertices and provides convenience output methods for OBJ files...
int debug
Static debugging option.
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry if present, and assign to T val. FatalIOError if it is found and the number of tokens i...
void markAffectedFaces(const labelHashSet &changedFaces, labelHashSet &affectedFaces)
Mark affected faces.
OBJstream os(runTime.globalPath()/outputName)
defineTypeNameAndDebug(combustionModel, 0)
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)))
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
displacementSmartPointSmoothingMotionSolver(const polyMesh &, const IOdictionary &)
Construct from a polyMesh and an IOdictionary.
Mesh consisting of general polyhedral cells.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
List< label > labelList
A List of labels.
const polyMesh & mesh() const
Return reference to mesh.
A class for managing temporary objects.
scalarList relaxationFactors_
Relaxation factors to use in each iteration.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
void reduce(T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) using linear/tree communication schedule.
const dimensionedScalar mp
Proton mass.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)