46 template<
class Type,
class Op>
60 if (!sortedPointis_.set(axis))
70 return points_[a][axis] < points_[
b][axis];
78 label sortedPointi = 0, sectioni = 0;
82 sortedPointi < sortedPoints.
size()
83 && sortedPoints[sortedPointi][axis] < distances[0]
86 for (; sortedPointi < sortedPoints.
size(); ++ sortedPointi)
90 sectioni < result.
size()
91 && sortedPoints[sortedPointi][axis] > distances[sectioni + 1]
94 if (sectioni >= result.
size())
break;
97 op(sortedPoints[sortedPointi])*sortedMasses[sortedPointi];
115 dict.isDict(
"pointMasses")
120 dict.subDict(
"pointMasses")
134 dict.subDict(
"pointMasses")
144 forAll(pointsAndMasses, i)
146 points_[i] = pointsAndMasses[i].
first();
147 masses_[i] = pointsAndMasses[i].second();
150 if (points_.
size() < 4)
153 <<
"A " <<
typeName <<
" body requires at least four point masses"
159 const scalar
m =
sum(masses_);
163 const scalar detIc =
det(
Ic);
165 if (detIc < rootVSmall || detIc < rootSmall*
pow3(
mag(
Ic)))
168 <<
"The inertia tensor of the " <<
typeName <<
" body '" <<
name
169 <<
"' is singular. Ensure the point masses are not co-planar or"
180 reader_(pm.reader_, false),
228 [](
const point&
p) {
return p; }
240 sectionMuNs<symmTensor>
255 forAll(pointsAndMasses, i)
257 pointsAndMasses[i].
first() = points_[i];
258 pointsAndMasses[i].second() = masses_[i];
#define forAll(list, i)
Loop across all elements in list.
Macros for easy insertion into run-time selection tables.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void resize(const label)
Alias for setSize(const label)
void size(const label)
Override size to be inconsistent with allocated storage.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
virtual Ostream & write(const token &)
Write token.
Specialisation of rigidBody to construct a pointMasses given the mass and lengths of the sides.
virtual tmp< vectorField > sectionMu1s(const direction axis, const scalarField &distances) const
Return the first moments of the sections of the body between.
virtual void write(Ostream &) const
Write.
virtual tmp< symmTensorField > sectionMu2s(const direction axis, const scalarField &distances) const
Return the second moments of the sections of the body between.
virtual autoPtr< rigidBody > clone() const
Return clone of this pointMasses.
pointMasses(const word &name, const dictionary &dict)
Construct from dictionary.
virtual tmp< scalarField > sectionMu0s(const direction axis, const scalarField &distances) const
Return the zeroth moments of the sections of the body between.
virtual ~pointMasses()
Destructor.
This class represents the linear and angular inertia of a rigid body by the mass, centre of mass and ...
const vector & c() const
Return the centre of mass of the rigid-body.
rigidBodyInertia()
Null constructor, initialises to zero.
scalar m() const
Return the mass of the rigid-body.
const symmTensor & Ic() const
Return the inertia tensor of the rigid-body about the centre of mass.
const word & name() const
Return name.
static const SymmTensor I
Base class to read table data for tables.
Reads an interpolation table from the values entry in OpenFOAM-format.
virtual List< Tuple2< Coordinate, Value > > read(const Function1s::unitSets &units, const dictionary &dict, const word &valuesKeyword="values") const
Read values.
virtual void write(Ostream &os, const Function1s::unitSets &units, const List< Tuple2< Coordinate, Value >> &table, const word &valuesKeyword="values") const
Write settings and values.
A List with indirect addressing.
label size() const
Return the number of elements in the list.
T & first()
Return the first element of the list.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
A class representing the concept of 1 (scalar(1)) used to avoid unnecessary manipulations for objects...
Traits class for primitives.
A class for managing temporary objects.
T & ref() const
Return non-const reference or generate a fatal error.
Template function which returns the un-mangled name of a given type. Useful for types which do not ha...
A class for handling words, derived from string.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
addToRunTimeSelectionTable(rigidBody, cuboid, dictionary)
defineTypeNameAndDebug(cuboid, 0)
errorManipArg< error, int > exit(error &err, const int errNo=1)
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const dimensionSet & dimMass
Ostream & endl(Ostream &os)
Add newline and flush stream.
const dimensionSet & dimLength
SymmTensor< scalar > symmTensor
SymmTensor of scalars.
vectorField pointField
pointField is a vectorField.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
vector point
Point is a vector.
tmp< DimensionedField< typename outerProduct< Type, Type >::type, GeoMesh, Field >> sqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
void pow3(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
void det(pointPatchField< scalar > &, const pointPatchField< tensor > &)
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
void sortedOrder(const UList< T > &, labelList &order)
Generate the (stable) sort order for the list.
Ostream & indent(Ostream &os)
Indent stream.
tmp< DimensionedField< TypeR, GeoMesh, Field > > New(const tmp< DimensionedField< TypeR, GeoMesh, Field >> &tdf1, const word &name, const dimensionSet &dimensions)
void writeEntry(Ostream &os, const word &key, const DimensionedFieldFunction< DimensionedFieldType > &f)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.