55Foam::rigidBodyMeshMotion::bodyMesh::bodyMesh
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",
86Foam::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());
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 auto& transformedPts = ttransformedPts.ref();
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);
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++)
289 const label nIter(coeffDict().getOrDefault<label>(
"nIter", 1));
291 for (label i=0; i<nIter; i++)
297 const label bodyID = bodyMeshes_[bi].bodyID_;
300 forcesDict.
add(
"type", functionObjects::forces::typeName);
301 forcesDict.add(
"patches", bodyMeshes_[bi].patches_);
302 forcesDict.add(
"rhoInf", rhoInf_);
303 forcesDict.add(
"rho", rhoName_);
307 f.calcForcesMoments();
321 if (cOfGdisplacement_ !=
"none")
323 if (bodyIdCofG_ != -1)
327 db().time().foundObject<uniformDimensionedVectorField>
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_,
376 bodyIDs[bi] = bodyMeshes_[bi].bodyID_;
377 weights[bi] = &bodyMeshes_[bi].weight_;
380 pointDisplacement_.primitiveFieldRef() =
395 const bool writeOnProc
405 "rigidBodyMotionState",
415 model_.state().write(
dict);
416 return dict.regIOobject::writeObject(streamOpt, writeOnProc);
424 model_.read(coeffDict());
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
label size() const noexcept
The number of elements in list.
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field values.
const Internal::FieldType & primitiveField() const noexcept
Return a const-reference to the internal field values.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
@ NO_REGISTER
Do not request registration (bool: false).
@ NO_READ
Nothing to be read.
@ READ_IF_PRESENT
Reading is optional [identical to LAZY_READ].
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const Time & time() const noexcept
Return Time associated with the objectRegistry.
bool typeHeaderOk(const bool checkType=true, const bool search=true, const bool verbose=true)
Read header (respects is_globalIOobject trait) and check its info. A void type suppresses trait and t...
const objectRegistry & db() const noexcept
Return the local objectRegistry.
A simple container for options an IOstream can normally have.
streamFormat format() const noexcept
Get the current stream format.
@ ASCII
"ascii" (normal default)
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
static FOAM_NO_DANGLING_REFERENCE const pointMesh & New(const polyMesh &mesh, Args &&... args)
label bodyID(const word &name) const
Return the ID of the body with the given name.
scalar deltaTValue() const noexcept
Return time step value.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A List with indirect addressing. Like IndirectList but does not store addressing.
void size(const label n)
Older name for setAddressableSize.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static Form uniform(const Cmpt &s)
Return a VectorSpace with all elements = s.
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.
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,...
dictionary()
Default construct, a top-level empty dictionary.
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...
friend class entry
Declare friendship with the entry class for IO.
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
const Type & value() const noexcept
Return const reference to value.
Virtual base class for displacement motion solver.
displacementMotionSolver(const displacementMotionSolver &)=delete
No copy construct.
pointVectorField pointDisplacement_
Point motion field.
static autoPtr< displacementMotionSolver > New(const word &solverTypeName, const polyMesh &, const IOdictionary &, const pointVectorField &pointDisplacement, const pointIOField &points0)
Select constructed from polyMesh, dictionary and components.
A keyword and a list of tokens is an 'entry'.
Computes forces and moments over a given list of patches by integrating pressure and viscous forces a...
const Time & time() const
Return the top-level database.
A class for handling keywords in dictionaries.
Virtual base class for mesh motion solver.
const polyMesh & mesh() const
Return reference to mesh.
virtual tmp< pointField > newPoints()
Provide new points for motion. Solves for motion.
const dictionary & coeffDict() const
Const access to the coefficients dictionary.
virtual bool read()
Read dynamicMeshDict dictionary.
bool foundObject(const word &name, const bool recursive=false) const
Contains the named Type?
const Type & lookupObject(const word &name, const bool recursive=false) const
Lookup and return const reference to the object of the given Type. Fatal if not found or the wrong ty...
void constrain(GeometricField< Type, pointPatchField, pointMesh > &pf, const bool overrideValue=false) const
Apply boundary conditions (single-patch constraints) and.
void constrainDisplacement(pointVectorField &displacement, const bool overrideValue=false) const
Apply boundary conditions (single-patch constraints),.
Mesh representing a set of points created from polyMesh.
Calculation of distance to nearest patch for all points.
pointField & points0() noexcept
Return reference to the reference ('0') pointField.
Mesh consisting of general polyhedral cells.
label nPoints() const noexcept
Number of mesh points.
Rigid-body mesh motion solver for fvMesh.
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc) const
Write state using stream options.
virtual tmp< pointField > curPoints() const
Return point location obtained from the current motion field.
virtual void solve()
Solve for motion.
virtual bool read()
Read dynamicMeshDict dictionary.
A class for managing temporary objects.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
A class for handling words, derived from Foam::string.
const labelList & pointIDs() const noexcept
The point ids (for cell set/zone subset).
bool moveAllCells() const noexcept
Move all cells?
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
constexpr scalar pi(M_PI)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
const dimensionSet dimless
Dimensionless.
SpatialVector< scalar > spatialVector
SpatialVector of scalars.
GeometricField< scalar, pointPatchField, pointMesh > pointScalarField
List< label > labelList
A List of labels.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
UniformDimensionedField< vector > uniformDimensionedVectorField
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
vectorField pointField
pointField is a vectorField.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensionedScalar cos(const dimensionedScalar &ds)
#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)))