48 displacementSmartPointSmoothingMotionSolver,
54 displacementMotionSolver,
55 displacementSmartPointSmoothingMotionSolver,
71 for (
const label facei : changedFaces)
73 affectedPoints.set(
mesh().faces()[facei]);
80 orEqOp<unsigned int>(),
84 for (
const label pointi : affectedPoints)
86 for (
const label celli :
mesh().pointCells()[pointi])
98 relaxationFactors_.empty()
99 || (relaxationFactors_.size() == 1 && relaxationFactors_[0] == 1.0)
107 const pointField oldRelaxedPoints(relaxedPoints_);
115 for (
const label facei : affectedFaces)
117 for (
const label pointi :
mesh().faces()[facei])
119 relaxationLevel[pointi] = 0;
132 bool complete(
false);
140 forAll(relaxationLevel, pointI)
142 if (relaxationLevel[pointI] >= 0)
146 relaxationFactors_[relaxationLevel[pointI]]
149 relaxedPoints_[pointI] =
150 (1 -
x)*oldRelaxedPoints[pointI]
151 +
x*(
points0()[pointI] + pointDisplacement()[pointI]);
157 markAffectedFaces(affectedFaces, markedFaces);
158 labelList markedFacesList(markedFaces.toc());
161 meshGeometry_.correct(relaxedPoints_, markedFacesList);
179 affectedFaces.clear();
180 markAffectedFaces(markedFaces, affectedFaces);
185 tmp<scalarField> tfaceQ
187 pointUntangler_->faceQuality
190 meshGeometry_.faceCentres(),
191 meshGeometry_.faceAreas(),
192 meshGeometry_.cellCentres(),
193 meshGeometry_.cellVolumes()
210 if (tfaceQ()[order[i]] > untangleQ_)
217 affectedFaces =
labelList(SubList<label>(order, nUntangle));
223 for (
const label facei : affectedFaces)
225 pointsToRelax.set(
mesh().faces()[facei]);
228 for (
const label pointI : pointsToRelax)
230 if (relaxationLevel[pointI] < relaxationFactors_.size() - 1)
232 ++ relaxationLevel[pointI];
252 bool converged(
true);
255 for (
const label pointi :
mesh().faces()[facei])
257 if (relaxationLevel[pointi] > 0)
259 facesToMove_.insert(facei);
291 facesToMove_.resize(2*
mesh().nFaces());
294 facesToMove_.insert(faceI);
299 facesToMove_.resize(2*(
mesh().nBoundaryFaces()));
302 label faceI =
mesh().nInternalFaces();
307 facesToMove_.insert(faceI);
320 auto&
fld = pointDisplacement.primitiveFieldRef();
321 for (
const auto& ppf : pointDisplacement.boundaryField())
323 if (isA<emptyPointPatchVectorField>(ppf))
325 const auto&
mp = ppf.patch().meshPoints();
329 ppf.patch().applyConstraint(i, pc);
330 fld[
mp[i]] = pc.constrainDisplacement(
fld[
mp[i]]);
336 twoDCorrectPoints(wantedPoints);
356 coeffDict().
get<
word>(
"untangler"),
361 untangleQ_(coeffDict().
get<scalar>(
"untangleQ")),
362 minQ_(coeffDict().
get<scalar>(
"minQ")),
366 coeffDict().
get<label>(
"nPointSmootherIter")
381 const polyMesh&
mesh,
382 const IOdictionary&
dict,
387 displacementMotionSolver(
mesh,
dict, pointDisplacement,
points0, typeName),
393 coeffDict().
get<word>(
"untangler"),
398 untangleQ_(coeffDict().
get<scalar>(
"untangleQ")),
399 minQ_(coeffDict().
get<scalar>(
"minQ")),
410 coeffDict().
get<label>(
"nPointSmootherIter")
429 return relaxedPoints_;
435 movePoints(curPoints());
439 pointDisplacement().boundaryFieldRef().updateCoeffs();
452 + pointDisplacement().internalField()
454 const auto&
pbm = pointDisplacement().
mesh().boundary();
455 for (
const auto& ppp :
pbm)
457 if (!isA<emptyPointPatch>(ppp))
459 const auto&
mp = ppp.meshPoints();
460 for (
const label pointi :
mp)
480 markAffectedFaces(facesToMove_, affectedFaces);
483 for (label nIter = 0; nIter < nPointSmootherIter_; ++nIter)
488 + pointDisplacement().internalField()
491 meshGeometry_.correct
538 tmp<scalarField> tfaceQ
540 pointUntangler_->faceQuality
543 meshGeometry_.faceCentres(),
544 meshGeometry_.faceAreas(),
545 meshGeometry_.cellCentres(),
546 meshGeometry_.cellVolumes()
564 if (tfaceQ()[order[i]] > untangleQ_)
573 if (tfaceQ()[order[i]] > minQ_)
593 labelList lowQFaces(SubList<label>(order, nUntangle));
610 pointUntangler_->update
623 emptyCorrectPoints(pointDisplacement());
627 OBJstream
os(debugDir/
"untangle_" +
Foam::name(nIter) +
".obj");
632 + pointDisplacement().internalField()
634 forAll(wantedPoints, pointi)
651 labelList lowQFaces(SubList<label>(order, nLow));
669 pointSmoother_->update
678 emptyCorrectPoints(pointDisplacement());
691 twoDCorrectPoints(relaxedPoints_);
695 pointDisplacement().primitiveFieldRef() = relaxedPoints_-
points0();
699 const pointConstraints& pcs =
701 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.
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.
const Internal & internalField() const noexcept
Return a const-reference to the dimensioned internal field.
static FOAM_NO_DANGLING_REFERENCE const pointConstraints & New(const pointMesh &mesh, Args &&... args)
Get existing or create MeshObject registered with typeName.
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.
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.
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
label nVertices() const noexcept
Return the number of vertices written.
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.
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)
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.
static void reduceAnd(bool &value, const int communicator=worldComm)
Logical (and) reduction (MPI_AllReduce)
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.
const dimensionedScalar mp
Proton mass.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)