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)
102 relaxedPoints_ =
points0() + pointDisplacement().internalField();
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);
187 pointUntangler_->faceQuality
190 meshGeometry_.faceCentres(),
191 meshGeometry_.faceAreas(),
192 meshGeometry_.cellCentres(),
193 meshGeometry_.cellVolumes()
210 if (tfaceQ()[order[i]] > untangleQ_)
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);
289 if (
dict.getOrDefault<
bool>(
"moveInternalFaces",
true))
291 facesToMove_.resize(2*
mesh().nFaces());
294 facesToMove_.insert(faceI);
299 facesToMove_.resize(2*(
mesh().nBoundaryFaces()));
302 label faceI =
mesh().nInternalFaces();
320 auto&
fld = pointDisplacement.primitiveFieldRef();
321 for (
const auto& ppf : pointDisplacement.boundaryField())
325 const auto&
mp = ppf.patch().meshPoints();
330 fld[
mp[i]] = pc.constrainDisplacement(
fld[mp[i]]);
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,
393 coeffDict().get<word>(
"untangler"),
398 untangleQ_(coeffDict().get<scalar>(
"untangleQ")),
399 minQ_(coeffDict().get<scalar>(
"minQ")),
410 coeffDict().get<label>(
"nPointSmootherIter")
435 movePoints(curPoints());
439 pointDisplacement().boundaryFieldRef().updateCoeffs();
452 + pointDisplacement().internalField()
454 const auto&
pbm = pointDisplacement().mesh().boundary();
455 for (
const auto& ppp :
pbm)
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
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_)
610 pointUntangler_->update
623 emptyCorrectPoints(pointDisplacement());
632 + pointDisplacement().internalField()
634 forAll(wantedPoints, pointi)
669 pointSmoother_->update
678 emptyCorrectPoints(pointDisplacement());
691 twoDCorrectPoints(relaxedPoints_);
695 pointDisplacement().primitiveFieldRef() = relaxedPoints_-
points0();
701 pcs.constrainDisplacement(pointDisplacement(),
false);
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
propsDict readIfPresent("fields", acceptFields)
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
const polyBoundaryMesh & pbm
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
List< Key > toc() const
The table of contents (the keys) in unsorted order.
void clear()
Remove all entries from table.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
static FOAM_NO_DANGLING_REFERENCE const pointConstraints & New(const pointMesh &mesh, Args &&... args)
A min/max value pair with additional methods. In addition to conveniently storing values,...
An OFstream that keeps track of vertices and provides convenience output methods for OBJ files.
label nVertices() const noexcept
Return the number of vertices written.
virtual Ostream & write(const char c) override
Write character.
virtual const fileName & name() const override
Read/write access to the name of the stream.
A non-owning sub-view of a List (allocated or unallocated storage).
fileName timePath() const
Return current time path = path/timeName.
static void reduceAnd(bool &value, const int communicator=worldComm)
Logical (and) reduction (MPI_AllReduce).
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
void set(const bitSet &bitset)
Set specified bits from another bitset.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Virtual base class for displacement motion solver.
pointVectorField & pointDisplacement() noexcept
Return reference to the point motion displacement field.
displacementMotionSolver(const displacementMotionSolver &)=delete
No copy construct.
static autoPtr< displacementMotionSolver > New(const word &solverTypeName, const polyMesh &, const IOdictionary &, const pointVectorField &pointDisplacement, const pointIOField &points0)
Select constructed from polyMesh, dictionary and components.
Quality-based under-relaxation for run-time selectable point smoothing. WIP.
autoPtr< pointSmoother > pointSmoother_
Point smoothing method.
virtual tmp< pointField > curPoints() const
Return point location obtained from the current motion field.
labelHashSet facesToMove_
Set of the faces which are to be moved.
polyMeshGeometry meshGeometry_
Part-updatable mesh geometry.
autoPtr< pointSmoother > pointUntangler_
Point untangler method.
pointField relaxedPoints_
Relaxed point field.
bool relax()
Relax the points.
const scalar untangleQ_
Minimum allowed quality.
scalarList relaxationFactors_
Relaxation factors to use in each iteration.
void markAffectedFaces(const labelHashSet &changedFaces, labelHashSet &affectedFaces)
Mark affected faces.
dictionary meshQualityDict_
Mesh quality dictionary.
const label nPointSmootherIter_
Number of point smoother iterations per timestep.
const scalar minQ_
Minimum allowed quality.
void emptyCorrectPoints(pointVectorField &pointDisplacement)
Handle 2D & empty bcs. Assume in both cases the starting mesh.
virtual void setFacesToMove(const dictionary &)
Set all the faces to be moved.
displacementSmartPointSmoothingMotionSolver(const polyMesh &, const IOdictionary &)
Construct from a polyMesh and an IOdictionary.
virtual void solve()
Solve for motion.
A class for handling file names.
const Time & time() const
Return the top-level database.
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.
Virtual base class for mesh motion solver.
const polyMesh & mesh() const
Return reference to mesh.
virtual void twoDCorrectPoints(pointField &) const
const dictionary & coeffDict() const
Const access to the coefficients dictionary.
Smooth ATC in cells having a point to a set of patches supplied by type.
Accumulates point constraints through successive applications of the applyConstraint function.
void applyConstraint(const vector &cd)
Apply and accumulate the effect of the given constraint direction.
vector constrainDisplacement(const vector &disp) const
Constrain a displacement.
Application of (multi-)patch point constraints.
void constrainDisplacement(pointVectorField &displacement, const bool overrideValue=false) const
Apply boundary conditions (single-patch constraints),.
Abstract base class for point smoothing methods. Handles parallel communication via reset and average...
pointField & points0() noexcept
Return reference to the reference ('0') pointField.
virtual void movePoints(const pointField &)
Update local data for geometry changes.
Mesh consisting of general polyhedral cells.
label nFaces() const noexcept
Number of mesh faces.
A class for managing temporary objects.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
OBJstream os(runTime.globalPath()/outputName)
const dimensionedScalar mp
Proton mass.
Namespace for handling debugging switches.
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.
List< label > labelList
A List of labels.
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
GeometricField< vector, pointPatchField, pointMesh > pointVectorField
vectorIOField pointIOField
pointIOField is a vectorIOField.
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.
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
labelList sortedOrder(const UList< T > &input)
Return the (stable) sort order for the list.
line< point, const point & > linePointRef
A line using referred points.
MinMax< Type > gMinMax(const FieldField< Field, Type > &f)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
vectorField pointField
pointField is a vectorField.
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.
pointField points0(pointIOField(IOobject("points", mesh.time().constant(), polyMesh::meshSubDir, mesh, IOobject::MUST_READ, IOobject::NO_WRITE, IOobject::NO_REGISTER)))