42 solidBodyFvGeometryScheme,
48 bool Foam::solidBodyFvGeometryScheme::markChanges
52 bitSet& isChangedPoint,
53 bitSet& isChangedFace,
57 isChangedPoint.setSize(oldPoints.size());
60 forAll(isChangedPoint, pointi)
62 isChangedPoint.set(pointi, oldPoints[pointi] != currPoints[pointi]);
66 <<
"SBM --- Changed points:" 77 isChangedFace =
false;
80 isChangedCell =
false;
87 for (
const label pointi : isChangedPoint)
89 for (
const auto facei : pointFaces[pointi])
91 isChangedFace.
set(facei);
93 isChangedCell.set(own[facei]);
96 isChangedCell.set(nbr[facei]);
102 <<
"SBM --- Changed cells:" 110 void Foam::solidBodyFvGeometryScheme::setMeshMotionData()
112 if (!cacheInitialised_ || !cacheMotion_)
116 changedFaceIDs_.clear();
117 changedPatchIDs_.clear();
118 changedCellIDs_.clear();
120 const pointField& oldPoints = mesh_.oldPoints();
121 const pointField& currPoints = mesh_.points();
123 if (oldPoints.size() != currPoints.size())
126 <<
"Old and current points sizes must be the same. " 127 <<
"Old points:" << oldPoints.size()
128 <<
" Current points:" << currPoints.size()
184 bitSet isChangedPoint;
185 bitSet isChangedFace;
186 bitSet isChangedCell;
187 const bool changed = markChanges
202 changedCellIDs_ = isChangedCell.toc();
207 DynamicList<label> changedFaceIDs(isChangedFace.count());
208 DynamicList<label> changedPatchIDs(changedFaceIDs.capacity());
209 for (label facei = 0; facei < mesh_.nInternalFaces(); ++facei)
211 if (isChangedFace[facei])
213 changedFaceIDs.append(facei);
214 changedPatchIDs.append(-1);
218 const auto&
pbm = mesh_.boundaryMesh();
219 for (label patchi = 0; patchi <
pbm.
size(); ++patchi)
221 const polyPatch&
pp =
pbm[patchi];
223 for (
const label meshFacei :
pp.range())
225 if (isChangedFace[meshFacei])
227 changedFaceIDs.
append(meshFacei);
228 changedPatchIDs.append(patchi);
233 changedFaceIDs_.transfer(changedFaceIDs);
234 changedPatchIDs_.transfer(changedPatchIDs);
237 cacheInitialised_ =
true;
243 Foam::solidBodyFvGeometryScheme::solidBodyFvGeometryScheme
250 partialUpdate_(
dict.getOrDefault<bool>(
"partialUpdate", true)),
251 cacheMotion_(
dict.getOrDefault<bool>(
"cacheMotion", true)),
252 cacheInitialised_(
false),
258 <<
"partialUpdate:" << partialUpdate_
259 <<
" cacheMotion:" << cacheMotion_
272 mesh_.hasCellCentres()
273 && mesh_.hasFaceCentres()
274 && mesh_.hasCellVolumes()
275 && mesh_.hasFaceAreas();
280 <<
"Creating initial geometry using primitiveMesh::updateGeom" 293 const pointField& oldPoints = mesh_.oldPoints();
294 const pointField& currPoints = mesh_.points();
296 if (oldPoints.size() != currPoints.size())
299 <<
"Old and current points sizes must be the same. " 300 <<
"Old points:" << oldPoints.size()
301 <<
" Current points:" << currPoints.size()
305 const polyBoundaryMesh&
pbm = mesh_.boundaryMesh();
306 const faceList& faces = mesh_.faces();
308 auto tmeshPhi(const_cast<fvMesh&>(mesh_).setPhi());
311 const scalar rdt = 1.0/mesh_.time().deltaTValue();
314 auto&
meshPhi = tmeshPhi.ref();
315 auto& meshPhii =
meshPhi.primitiveFieldRef();
316 auto& meshPhiBf =
meshPhi.boundaryFieldRef();
322 forAll(changedFaceIDs_, i)
324 const face&
f = faces[changedFaceIDs_[i]];
326 if (changedPatchIDs_[i] == -1)
328 const label facei = changedFaceIDs_[i];
329 meshPhii[facei] =
f.sweptVol(oldPoints, currPoints)*rdt;
333 const label patchi = changedPatchIDs_[i];
334 const polyPatch&
pp =
pbm[patchi];
336 if (isA<emptyPolyPatch>(
pp))
341 const label patchFacei = changedFaceIDs_[i] -
pp.start();
343 meshPhiBf[patchi][patchFacei] =
344 f.sweptVol(oldPoints, currPoints)*rdt;
349 if (partialUpdate_ && haveGeometry)
384 std::move(faceCentres),
385 std::move(faceAreas),
386 std::move(cellCentres),
387 std::move(cellVolumes)
392 for (
const auto&
p : mesh_.boundaryMesh())
395 <<
" sum(Sf)=" <<
sum(
p.faceAreas())
396 <<
" sum(mag(Sf))=" <<
sum(
mag(
p.faceAreas()))
404 <<
"Performing complete geometry clear and update" <<
endl;
426 cacheInitialised_ =
false;
442 (faceCentres.
size() != mesh_.nFaces())
443 || (faceAreas.
size() != mesh_.nFaces())
444 || (cellCentres.
size() != mesh_.nCells())
445 || (cellVolumes.
size() != mesh_.nCells())
465 bitSet isChangedPoint;
466 bitSet isChangedFace;
467 bitSet isChangedCell;
468 const bool changed = markChanges
const polyBoundaryMesh & pbm
void size(const label n)
Older name for setAddressableSize.
const fvMesh & mesh_
Hold reference to mesh.
virtual bool updateGeom(const pointField &points, const refPtr< pointField > &oldPoints, pointField &faceCentres, vectorField &faceAreas, pointField &cellCentres, scalarField &cellVolumes) const
Calculate geometry quantities using mesh topology and provided points. If oldPoints provided only doe...
virtual void movePoints()
Do what is necessary if the mesh has moved.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual const labelList & faceNeighbour() const
Return face neighbour.
const word & name() const noexcept
Return the object name.
Ostream & endl(Ostream &os)
Add newline and flush stream.
label nFaces() const noexcept
Number of mesh faces.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1, const label comm)
A class for managing references or pointers (no reference counting)
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Macros for easy insertion into run-time selection tables.
Default geometry calculation scheme. Slight stabilisation for bad meshes.
#define forAll(list, i)
Loop across all elements in list.
List< face > faceList
List of faces.
void resetGeometry(pointField &&faceCentres, pointField &&faceAreas, pointField &&cellCentres, scalarField &&cellVolumes)
Reset the local geometry.
vectorField pointField
pointField is a vectorField.
void clearGeom()
Clear geometry.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
#define DebugInFunction
Report an information message using Foam::Info.
bool returnReduceAnd(const bool value, const int communicator=UPstream::worldComm)
Perform logical (and) MPI Allreduce on a copy. Uses UPstream::reduceAnd.
label size() const noexcept
The number of entries in the list.
virtual const labelList & faceOwner() const
Return face owner.
virtual void updateGeom()
Update all geometric data.
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.
label nInternalFaces() const noexcept
Number of internal faces.
errorManip< error > abort(error &err)
#define DebugInfo
Report an information message using Foam::Info.
int debug
Static debugging option.
defineTypeNameAndDebug(combustionModel, 0)
void append(autoPtr< T > &ptr)
Move append an element to the end of the list.
decomposeUsingBbs false
Use bounding boxes (default) or unique decomposition of triangles (i.e. do not duplicate triangles) ...
virtual bool updateGeom(const pointField &points, const refPtr< pointField > &oldPoints, pointField &faceCentres, vectorField &faceAreas, pointField &cellCentres, scalarField &cellVolumes) const
Calculate geometry quantities using mesh topology and provided points. If oldPoints provided only doe...
bool set(const label i, bool val=true)
A bitSet::set() method for a list of bool.
label nCells() const noexcept
Number of mesh cells.
Mesh data needed to do the Finite Volume discretisation.
tmp< surfaceScalarField > meshPhi(const volVectorField &U)
const labelListList & pointFaces() const
Field< vector > vectorField
Specialisation of Field<T> for vector.
virtual void updateMesh(const mapPolyMesh &mpm)
Update mesh for topology changes.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)
static constexpr const zero Zero
Global zero (0)