Go to the documentation of this file.
48 { outputFormatType::PLAIN,
"plain" },
49 { outputFormatType::DICTIONARY,
"dictionary" },
59 { scalingType::LENGTH,
"length" },
60 { scalingType::FORCE,
"force" },
61 { scalingType::MOMENT,
"moment" },
76 static inline Ostream& putPlain(Ostream& os,
const vector&
val)
78 os <<
val.x() <<
' ' <<
val.y() <<
' ' <<
val.z();
85 static inline Ostream& putTime(Ostream& os,
const Time& t)
87 os <<
"Time index=" << t.timeIndex()
88 <<
" value=" << t.timeOutputValue();
98 static void writeList(Ostream& os,
const string& header,
const UList<T>& list)
100 const label len = list.size();
103 os << header.c_str() <<
nl;
109 for (
label i=0; i < len; ++i)
124 void Foam::lumpedPointMovement::calcThresholds()
const
130 for (
label i=1; i < thresh.size(); ++i)
135 + (division_ * (locations_[i] - locations_[i-1]))
141 Foam::label Foam::lumpedPointMovement::threshold(scalar
pos)
const
144 const label n = thresh.size();
151 for (
label i=0; i <
n; ++i)
179 inputName_(
"positions.in"),
180 outputName_(
"forces.out"),
181 logName_(
"movement.log"),
207 "interpolationScheme",
208 linearInterpolationWeights::typeName
217 inputName_(
"positions.in"),
218 outputName_(
"forces.out"),
219 logName_(
"movement.log"),
255 else if (division_ > 1)
267 interpolatorPtr_.clear();
280 coupler_.readDict(commDict);
284 commDict.
readEntry(
"inputName", inputName_);
285 commDict.
readEntry(
"outputName", outputName_);
299 if ((scaleDict = commDict.
findDict(
"scaleInput")))
301 for (
int i=0; i < scaleInput_.size(); ++i)
308 && scaleInput_[i] > 0
311 Info<<
"Using input " << key <<
" multiplier: "
312 << scaleInput_[i] <<
nl;
317 if ((scaleDict = commDict.
findDict(
"scaleOutput")))
319 for (
int i=0; i < scaleOutput_.size(); ++i)
326 && scaleOutput_[i] > 0
329 Info<<
"Using output " << key <<
" multiplier: "
330 << scaleOutput_[i] <<
nl;
356 centre_ = boundBox_.centre();
357 centre_ -= (centre_ & axis_) * axis_;
360 Pout<<
"autoCentre on " << centre_
361 <<
" boundBox: " << boundBox_ <<
endl;
369 Pout<<
"centre on " << centre_
370 <<
" boundBox: " << boundBox_ <<
endl;
409 faceToZoneID[meshFaceI - firstFace] = zoneId;
418 Pout<<
"faces per zone:" << nFaces <<
endl;
421 faceZones_.setSize(nFaces.size());
423 label nZonedFaces = 0;
431 forAll(faceToZoneID, faceI)
433 if (faceToZoneID[faceI] == zonei)
436 label meshFaceI = faceI + firstFace;
448 Pout<<
"Created faceZone[" << zonei <<
"] "
450 << thresholds()[zonei] <<
" threshold" <<
nl;
463 forces.
setSize(faceZones_.size());
464 moments.
setSize(faceZones_.size());
466 if (faceZones_.empty())
469 <<
"Attempted to calculate forces without setMapping()"
486 const word pName(forcesDict_.lookupOrDefault<
word>(
"p",
"p"));
487 scalar pRef = forcesDict_.lookupOrDefault<scalar>(
"pRef", 0.0);
488 scalar rhoRef = forcesDict_.lookupOrDefault<scalar>(
"rhoRef", 1.0);
497 if (isA<fvMesh>(pmesh) && pPtr)
499 const fvMesh&
mesh = dynamicCast<const fvMesh>(pmesh);
503 const surfaceVectorField::Boundary& patchCf =
507 const surfaceVectorField::Boundary& patchSf =
511 const volScalarField::Boundary& patchPress =
515 rhoRef = (
p.dimensions() ==
dimPressure ? 1.0 : rhoRef);
526 const label meshFaceI = zn[localFaceI];
539 if (!forceOnPatches.found(patchI))
549 * patchSf[patchI] * (patchPress[patchI] - pRef)
554 const vectorField& forceOnPatch = *forceOnPatches[patchI];
557 forces[zonei] += forceOnPatch[patchFaceI];
564 patchCf[patchI][patchFaceI] - centre_
565 - lumpedCentres[zonei]
569 moments[zonei] += lever ^ forceOnPatch[patchFaceI];
590 static inline T interpolatedValue
597 T result = weights[0] * input[indices[0]];
600 result += weights[i] * input[indices[i]];
649 scalar where =
p0 & axis_;
653 vector origin = interpolatedValue(lumpedCentres, indices, weights);
654 tensor rotTensor = interpolatedValue(localToGlobal, indices, weights);
656 if (indices.size() == 1)
659 where = locations_[indices[0]];
665 const vector local = (
p0 - (where * axis_)) - centre_;
671 disp[ptI] = (rotTensor & local) + origin + centre_ -
p0;
694 coupler().resolveFile(inputName_)
697 state_.scalePoints(scaleInput_[scalingType::LENGTH]);
699 state_.relax(relax_, prev);
714 const bool writeMoments = (moments.
size() == forces.
size());
716 if (fmt == outputFormatType::PLAIN)
718 os <<
"########" <<
nl;
722 putTime(os, *timeinfo) <<
nl;
724 os <<
"# size=" << this->size() <<
nl
725 <<
"# columns (points) (forces)";
735 scalar scaleLength = scaleOutput_[scalingType::LENGTH];
736 scalar scaleForce = scaleOutput_[scalingType::FORCE];
737 scalar scaleMoment = scaleOutput_[scalingType::MOMENT];
771 os <<
"# scaling points=" << scaleLength
772 <<
" forces=" << scaleForce;
776 os <<
" moments=" << scaleMoment;
782 os <<
"########" <<
nl;
786 const vector pos = scaleLength * (locations_[i] * axis_);
788 putPlain(os,
pos) <<
' ';
790 if (i < forces.
size())
792 const vector val(scaleForce * forces[i]);
803 if (i < moments.
size())
805 const vector val(scaleMoment * moments[i]);
823 os <<
"////////" <<
nl;
827 putTime(os, *timeinfo) <<
nl;
831 writeList(os,
"points", (locations_*axis_)());
858 const fileName output(coupler().resolveFile(outputName_));
861 writeData(os, forces, moments, outputFormat_, timeinfo);
866 const fileName output(coupler().resolveFile(logName_));
877 writeData(os, forces, moments, outputFormatType::PLAIN, timeinfo);
887 if (!interpolatorPtr_.valid())
891 interpolationScheme_,
896 return *interpolatorPtr_;
int debug
Static debugging option.
dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find and return a sub-dictionary pointer if present.
vectorField pointField
pointField is a vectorField.
const dimensionSet dimPressure
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
label ListType::const_reference val
void writeDict(Ostream &os) const
Write axis, locations, division as a dictionary.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A class for handling words, derived from Foam::string.
A class for handling file names.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
bool forcesAndMoments(const polyMesh &pmesh, List< vector > &forces, List< vector > &moments) const
The forces and moments acting on each pressure-zone.
static const Enum< scalingType > scalingNames
Names for the scaling types.
void readDict(const dictionary &dict)
Update settings from dictionary.
A class for managing temporary objects.
static constexpr const zero Zero
Global zero.
label nInternalFaces() const
Number of internal faces.
Template functions to aid in the implementation of demand driven data.
label nFaces() const
Number of mesh faces.
static const boundBox invertedBox
A large inverted boundBox: min/max == +/- ROOTVGREAT.
static const versionNumber currentVersion
The current version number.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
const pointField & points() const
The points corresponding to mass centres.
Ostream & endl(Ostream &os)
Add newline and flush stream.
scalingType
Output format types.
T lookupOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
prefixOSstream Pout
An Ostream wrapper for parallel output to std::cout.
EnumType get(const word &enumName) const
The enumeration corresponding to the given name.
label start() const
The start label of the boundary faces in the polyMesh face list.
Mesh consisting of general polyhedral cells.
#define forAll(list, i)
Loop across all elements in list.
void deleteDemandDrivenData(DataPtr &dataPtr)
The state of lumped points corresponds to positions and rotations.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
static const Enum< inputFormatType > formatNames
Names for the input format types.
messageStream Info
Information stream (uses stdout - output is on the master only)
A patch is a list of labels that address the faces in the global face list.
void setMapping(const polyMesh &mesh, const labelUList &patchIds, const pointField &points0)
Define the pressure-zones mapping for faces in the specified.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
void writeList(vtk::formatter &fmt, const UList< uint8_t > &values)
Write a list of uint8_t values.
bool readData(Istream &is)
Read input as dictionary content.
tmp< pointField > displacePoints(const pointField &points0, const labelList &pointLabels) const
Displace points according to the current state.
bool writeData(Ostream &os, const UList< vector > &forces, const UList< vector > &moments, const outputFormatType fmt=outputFormatType::PLAIN, const Time *timeinfo=nullptr) const
Write points, forces, moments. Only call from the master process.
static void writeData(Ostream &os, const Type &val)
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
static const word canonicalName
The canonical name ("lumpedPointMovement") for the dictionary.
Abstract base class for interpolating in 1D.
static const Enum< outputFormatType > formatNames
Names for the output format types.
bool readState()
Read state from file, applying relaxation as requested.
Mesh data needed to do the Finite Volume discretisation.
void setBoundBox(const polyMesh &mesh, const labelUList &patchIds, const pointField &points0)
Define the bounding-box required to enclose the specified patches.
Vector< scalar > vector
A scalar version of the templated Vector.
label start() const
Return start label of this patch in the polyMesh face list.
Inter-processor communication reduction functions.
dictionary subOrEmptyDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX, const bool mandatory=false) const
Output to file stream, using an OSstream.
static bool master(const label communicator=0)
Am I the master process.
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
const interpolationWeights & interpolator() const
Interpolation weights.
pointField points0(pointIOField(IOobject("points", mesh.time().constant(), polyMesh::meshSubDir, mesh, IOobject::MUST_READ, IOobject::NO_WRITE, false)))
virtual const faceList & faces() const
Return raw faces.
const Type * findObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
static autoPtr< interpolationWeights > New(const word &type, const scalarField &samples)
Return a reference to the selected interpolationWeights.
Input/output from file streams.
outputFormatType
Output format types.
virtual bool valueWeights(const scalar t, labelList &indices, scalarField &weights) const =0
Calculate weights and indices to calculate t from samples.
lumpedPointMovement()
Construct null.
const tensorField & rotations() const
The local-to-global transformation for each point.
const polyBoundaryMesh & patches
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
void size(const label n) noexcept
Override size to be inconsistent with allocated storage.
static const Vector< scalar > zero
virtual ~lumpedPointMovement()
Destructor.
A face is a list of labels corresponding to mesh vertices.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
const volScalarField & p0
static void listCombineScatter(const List< commsStruct > &comms, List< T > &Value, const int tag, const label comm)
Scatter data. Reverse of combineGather.
void setSize(const label newSize)
Alias for resize(const label)
Begin list [isseparator].
const surfaceVectorField & Cf() const
Return face centres as surfaceVectorField.
#define WarningInFunction
Report a warning using Foam::Warning.
labelList pointLabels(nPoints, -1)
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
const Boundary & boundaryField() const
Return const-reference to the boundary field.
A HashTable of pointers to objects of type <T> with a label key.
dimensionedScalar pos(const dimensionedScalar &ds)
const surfaceVectorField & Sf() const
Return cell face area vectors.