42 solidBodyFvGeometryScheme,
48 void Foam::solidBodyFvGeometryScheme::setMeshMotionData()
50 if (!cacheInitialised_ || !cacheMotion_)
54 changedFaceIDs_.
clear();
55 changedPatchIDs_.
clear();
56 changedCellIDs_.
clear();
61 if (oldPoints.size() != currPoints.size())
64 <<
"Old and current points sizes must be the same. " 65 <<
"Old points:" << oldPoints.size()
66 <<
" Current points:" << currPoints.size()
70 bitSet changedPoints(oldPoints.size());
73 forAll(changedPoints, pointi)
75 changedPoints.set(pointi, oldPoints[pointi] != currPoints[pointi]);
79 <<
"SBM --- Changed points:" 97 for (
const label pointi : changedPoints)
99 for (
const auto facei : pointFaces[pointi])
111 changedCellIDs_ =
cellIDs.toc();
114 <<
"SBM --- Changed cells:" 121 const auto changedFaceFlag = faceIDs.values();
123 DynamicList<label> changedFaceIDs(faceIDs.count());
124 DynamicList<label> changedPatchIDs(faceIDs.count());
127 if (changedFaceFlag[facei])
129 changedFaceIDs.append(facei);
130 changedPatchIDs.append(-1);
135 for (label patchi = 0; patchi <
pbm.size(); ++patchi)
137 const polyPatch&
pp =
pbm[patchi];
139 for (
const label meshFacei :
pp.range())
141 if (changedFaceFlag[meshFacei])
143 changedFaceIDs.append(meshFacei);
144 changedPatchIDs.append(patchi);
149 changedFaceIDs_.
transfer(changedFaceIDs);
150 changedPatchIDs_.
transfer(changedPatchIDs);
153 cacheInitialised_ =
true;
159 Foam::solidBodyFvGeometryScheme::solidBodyFvGeometryScheme
166 partialUpdate_(
dict.getOrDefault<bool>(
"partialUpdate", true)),
167 cacheMotion_(
dict.getOrDefault<bool>(
"cacheMotion", true)),
168 cacheInitialised_(false),
174 <<
"partialUpdate:" << partialUpdate_
175 <<
" cacheMotion:" << cacheMotion_
188 mesh_.hasCellCentres()
189 && mesh_.hasFaceCentres()
190 && mesh_.hasCellVolumes()
191 && mesh_.hasFaceAreas();
196 <<
"Creating initial geometry using primitiveMesh::updateGeom" 209 const pointField& oldPoints = mesh_.oldPoints();
210 const pointField& currPoints = mesh_.points();
212 if (oldPoints.size() != currPoints.size())
215 <<
"Old and current points sizes must be the same. " 216 <<
"Old points:" << oldPoints.size()
217 <<
" Current points:" << currPoints.size()
221 const polyBoundaryMesh&
pbm = mesh_.boundaryMesh();
222 const faceList& faces = mesh_.faces();
224 auto tmeshPhi(const_cast<fvMesh&>(mesh_).setPhi());
227 const scalar rdt = 1.0/mesh_.time().deltaTValue();
230 auto&
meshPhi = tmeshPhi.ref();
231 auto& meshPhii =
meshPhi.primitiveFieldRef();
232 auto& meshPhiBf =
meshPhi.boundaryFieldRef();
238 forAll(changedFaceIDs_, i)
240 const face&
f = faces[changedFaceIDs_[i]];
242 if (changedPatchIDs_[i] == -1)
244 const label facei = changedFaceIDs_[i];
245 meshPhii[facei] =
f.sweptVol(oldPoints, currPoints)*rdt;
249 const label patchi = changedPatchIDs_[i];
250 const polyPatch&
pp =
pbm[patchi];
252 if (isA<emptyPolyPatch>(
pp))
257 const label patchFacei = changedFaceIDs_[i] -
pp.start();
259 meshPhiBf[patchi][patchFacei] =
260 f.sweptVol(oldPoints, currPoints)*rdt;
265 if (partialUpdate_ && haveGeometry)
300 std::move(faceCentres),
301 std::move(faceAreas),
302 std::move(cellCentres),
303 std::move(cellVolumes)
308 for (
const auto&
p : mesh_.boundaryMesh())
311 <<
" sum(Sf)=" <<
sum(
p.faceAreas())
312 <<
" sum(mag(Sf))=" <<
sum(
mag(
p.faceAreas()))
320 <<
"Performing complete geometry clear and update" <<
endl;
342 cacheInitialised_ =
false;
const polyBoundaryMesh & pbm
void size(const label n)
Older name for setAddressableSize.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1)
const fvMesh & mesh_
Hold reference to mesh.
virtual void movePoints()
Do what is necessary if the mesh has moved.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
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.
std::enable_if< std::is_same< bool, TypeT >::value, bool >::type set(const label i, bool val=true)
A bitSet::set() method for a list of bool.
Ostream & endl(Ostream &os)
Add newline and flush stream.
label nFaces() const noexcept
Number of mesh faces.
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.
Macros for easy insertion into run-time selection tables.
Default geometry calculation scheme. Slight stabilisation for bad meshes.
virtual const pointField & points() const
Return raw points.
#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.
bool returnReduceAnd(const bool value, const label comm=UPstream::worldComm)
Perform logical (and) MPI Allreduce on a copy. Uses UPstream::reduceAnd.
vectorField pointField
pointField is a vectorField.
void clearGeom()
Clear geometry.
void clear()
Clear the list, i.e. set size to zero.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
#define DebugInFunction
Report an information message using Foam::Info.
virtual const pointField & oldPoints() const
Return old points (mesh motion)
virtual const labelList & faceOwner() const
Return face owner.
virtual void updateGeom()
Update all geometric data.
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)
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
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())
static constexpr const zero Zero
Global zero (0)