55 Foam::rigidBodyMeshMotion::bodyMesh::bodyMesh
60 const dictionary&
dict 65 patches_(
dict.
get<wordRes>(
"patches")),
66 patchSet_(
mesh.boundaryMesh().patchSet(patches_)),
67 di_(
dict.
get<scalar>(
"innerDistance")),
68 do_(
dict.
get<scalar>(
"outerDistance")),
73 name_ +
".motionScale",
86 Foam::rigidBodyMeshMotion::rigidBodyMeshMotion
99 "rigidBodyMotionState",
108 "rigidBodyMotionState",
119 test_(coeffDict().getOrDefault(
"test", false)),
121 rhoName_(coeffDict().getOrDefault<
word>(
"rho",
"rho")),
129 coeffDict().getOrDefault<
word>(
"cOfGdisplacement",
"none")
131 bodyIdCofG_(coeffDict().getOrDefault<label>(
"bodyIdCofG", -1))
133 if (rhoName_ ==
"rhoInf")
140 for (
const entry& dEntry : bodiesDict)
142 const keyType& bodyName = dEntry.keyword();
145 if (bodyDict.found(
"patches"))
147 const label bodyID = model_.
bodyID(bodyName);
152 <<
"Body " << bodyName
153 <<
" has been merged with another body" 154 " and cannot be assigned a set of patches" 176 pointPatchDist pDist(pMesh, bodyMeshes_[bi].patchSet_,
points0());
181 scale.primitiveFieldRef() =
186 (bodyMeshes_[bi].do_ - pDist.primitiveField())
187 /(bodyMeshes_[bi].do_ - bodyMeshes_[bi].di_),
194 scale.primitiveFieldRef() =
201 *
cos(scale.primitiveField()
219 tmp<pointField> newPoints(
points0() + pointDisplacement_.primitiveField());
228 pointField& transformedPts = ttransformedPts.ref();
230 UIndirectList<point>(transformedPts, pointIDs()) =
233 return ttransformedPts;
245 <<
"The number of points in the mesh seems to have changed." <<
endl 246 <<
"In constant/polyMesh there are " <<
points0().
size()
247 <<
" points; in the current mesh there are " <<
mesh().
nPoints()
252 if (curTimeIndex_ != this->db().time().
timeIndex())
255 curTimeIndex_ = this->db().time().timeIndex();
258 const scalar ramp = (ramp_ ? ramp_->value(t.value()) : 1.0);
266 vector oldPos(vector::uniform(GREAT));
267 if (bodyIdCofG_ != -1)
269 oldPos = model_.cCofR(bodyIdCofG_);
274 const label nIter(coeffDict().get<label>(
"nIter"));
276 for (label i=0; i<nIter; i++)
283 Field<spatialVector>(model_.nBodies(),
Zero)
289 const label nIter(coeffDict().getOrDefault<label>(
"nIter", 1));
291 for (label i=0; i<nIter; i++)
293 Field<spatialVector> fx(model_.nBodies(),
Zero);
297 const label bodyID = bodyMeshes_[bi].bodyID_;
299 dictionary forcesDict;
300 forcesDict.add(
"type", functionObjects::forces::typeName);
301 forcesDict.add(
"patches", bodyMeshes_[bi].patches_);
302 forcesDict.add(
"rhoInf", rhoInf_);
303 forcesDict.add(
"rho", rhoName_);
304 forcesDict.add(
"CofR", vector::zero);
306 functionObjects::forces
f(
"forces", db(), forcesDict);
307 f.calcForcesMoments();
321 if (cOfGdisplacement_ !=
"none")
323 if (bodyIdCofG_ != -1)
339 disp.
value() += model_.cCofR(bodyIdCofG_) - oldPos;
345 <<
"CofGdisplacement is different to none." <<
endl 346 <<
"The model needs the entry body reference Id: bodyIdCofG." 356 model_.status(bodyMeshes_[bi].bodyID_);
361 if (bodyMeshes_.size() == 1)
363 pointDisplacement_.primitiveFieldRef() = model_.transformPoints
365 bodyMeshes_[0].bodyID_,
366 bodyMeshes_[0].weight_,
373 List<const scalarField*> weights(bodyMeshes_.size());
376 bodyIDs[bi] = bodyMeshes_[bi].bodyID_;
377 weights[bi] = &bodyMeshes_[bi].weight_;
380 pointDisplacement_.primitiveFieldRef() =
387 pointDisplacement_.mesh()
388 ).constrainDisplacement(pointDisplacement_);
395 const bool writeOnProc
405 "rigidBodyMotionState",
415 model_.state().write(
dict);
416 return dict.regIOobject::writeObject(streamOpt, writeOnProc);
424 model_.read(coeffDict());
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
const Type & value() const noexcept
Return const reference to value.
void size(const label n)
Older name for setAddressableSize.
Virtual base class for displacement motion solver.
errorManipArg< error, int > exit(error &err, const int errNo=1)
UniformDimensionedField< vector > uniformDimensionedVectorField
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc) const
Write state using stream options.
label nPoints() const noexcept
Number of mesh points.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
static const pointMesh & New(const polyMesh &mesh, Args &&... args)
Get existing or create a new MeshObject. Registered with typeName.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
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.
A simple container for options an IOstream can normally have.
Ignore writing from objectRegistry::writeObject()
const dimensionSet dimless
Dimensionless.
const dictionary & coeffDict() const
Const access to the coefficients dictionary.
const Time & time() const
Return the top-level database.
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...
Mesh representing a set of points created from polyMesh.
#define forAll(list, i)
Loop across all elements in list.
virtual bool read()
Read dynamicMeshDict dictionary.
dictionary()
Default construct, a top-level empty dictionary.
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, IOobjectOption::readOption readOpt=IOobjectOption::MUST_READ) const
Find entry and assign to T val. FatalIOError if it is found and the number of tokens is incorrect...
vectorField pointField
pointField is a vectorField.
dimensionedScalar cos(const dimensionedScalar &ds)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
virtual void solve()
Solve for motion.
A class for handling words, derived from Foam::string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
virtual tmp< pointField > curPoints() const
Return point location obtained from the current motion field.
SpatialVector< scalar > spatialVector
SpatialVector of scalars.
constexpr scalar pi(M_PI)
GeometricField< scalar, pointPatchField, pointMesh > pointScalarField
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
virtual bool read()
Read dynamicMeshDict dictionary.
defineTypeNameAndDebug(combustionModel, 0)
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
void append(autoPtr< T > &ptr)
Move append an element to the end of the list.
pointField points0(pointIOField(IOobject("points", mesh.time().constant(), polyMesh::meshSubDir, mesh, IOobject::MUST_READ, IOobject::NO_WRITE, IOobject::NO_REGISTER)))
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
pointField & points0() noexcept
Return reference to the reference ('0') pointField.
label bodyID(const word &name) const
Return the ID of the body with the given name.
Mesh consisting of general polyhedral cells.
friend class entry
Declare friendship with the entry class for IO.
List< label > labelList
A List of labels.
const polyMesh & mesh() const
Return reference to mesh.
A class for managing temporary objects.
Defines the attributes of an object for which implicit objectRegistry management is supported...
void constrain(GeometricField< Type, pointPatchField, pointMesh > &pf, const bool overrideValue=false) const
Apply boundary conditions (single-patch constraints) and.
streamFormat format() const noexcept
Get the current stream format.
Do not request registration (bool: false)
static constexpr const zero Zero
Global zero (0)