Compare commits
1 Commits
OpenFOAM-v
...
lumpedPoin
| Author | SHA1 | Date | |
|---|---|---|---|
| d3f7f91f6c |
@ -1157,7 +1157,7 @@ bool Foam::lumpedPointMovement::writeData
|
||||
const UList<vector>& forces,
|
||||
const UList<vector>& moments,
|
||||
const outputFormatType fmt,
|
||||
const Time* timeinfo
|
||||
const Tuple2<scalar, scalar>* timesWritten
|
||||
) const
|
||||
{
|
||||
const bool writeMoments = (moments.size() == forces.size());
|
||||
@ -1165,15 +1165,13 @@ bool Foam::lumpedPointMovement::writeData
|
||||
if (fmt == outputFormatType::PLAIN)
|
||||
{
|
||||
os <<"########" << nl;
|
||||
if (timeinfo)
|
||||
if (timesWritten)
|
||||
{
|
||||
const Time& t = *timeinfo;
|
||||
|
||||
os <<"# Time index=" << t.timeIndex() << nl
|
||||
<<"# Time value=" << t.timeOutputValue() << nl;
|
||||
os << "# Time value=" << timesWritten->first() << nl
|
||||
<< "# Time prev=" << timesWritten->second() << nl;
|
||||
}
|
||||
os <<"# size=" << this->size() << nl
|
||||
<<"# columns (points) (forces)";
|
||||
os << "# size=" << this->size() << nl
|
||||
<< "# columns (points) (forces)";
|
||||
|
||||
if (writeMoments)
|
||||
{
|
||||
@ -1272,12 +1270,10 @@ bool Foam::lumpedPointMovement::writeData
|
||||
// - ensure lists have consistent format
|
||||
|
||||
os <<"////////" << nl;
|
||||
if (timeinfo)
|
||||
if (timesWritten)
|
||||
{
|
||||
const Time& t = *timeinfo;
|
||||
|
||||
os <<"// Time index=" << t.timeIndex() << nl;
|
||||
os.writeEntry("time", t.timeOutputValue());
|
||||
os.writeEntry("time", timesWritten->first());
|
||||
os.writeEntry("prevTime", timesWritten->second());
|
||||
}
|
||||
os << nl;
|
||||
|
||||
@ -1298,7 +1294,7 @@ bool Foam::lumpedPointMovement::writeData
|
||||
(
|
||||
const UList<vector>& forces,
|
||||
const UList<vector>& moments,
|
||||
const Time* timeinfo
|
||||
const Tuple2<scalar, scalar>* timesWritten
|
||||
) const
|
||||
{
|
||||
if (!Pstream::master())
|
||||
@ -1308,26 +1304,24 @@ bool Foam::lumpedPointMovement::writeData
|
||||
|
||||
// Regular output
|
||||
{
|
||||
const fileName output(coupler().resolveFile(outputName_));
|
||||
OFstream os(output, IOstream::ASCII);
|
||||
OFstream os
|
||||
(
|
||||
coupler().resolveFile(outputName_)
|
||||
);
|
||||
|
||||
writeData(os, forces, moments, outputFormat_, timeinfo);
|
||||
writeData(os, forces, moments, outputFormat_, timesWritten);
|
||||
}
|
||||
|
||||
// Log output
|
||||
{
|
||||
const fileName output(coupler().resolveFile(logName_));
|
||||
|
||||
OFstream os
|
||||
(
|
||||
output,
|
||||
IOstream::ASCII,
|
||||
IOstream::currentVersion,
|
||||
IOstream::UNCOMPRESSED,
|
||||
true // append mode
|
||||
coupler().resolveFile(logName_),
|
||||
IOstreamOption(),
|
||||
true // append
|
||||
);
|
||||
|
||||
writeData(os, forces, moments, outputFormatType::PLAIN, timeinfo);
|
||||
writeData(os, forces, moments, outputFormatType::PLAIN, timesWritten);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@ -100,6 +100,7 @@ SourceFiles
|
||||
#include "primitiveFields.H"
|
||||
#include "IOobject.H"
|
||||
#include "tmp.H"
|
||||
#include "Tuple2.H"
|
||||
#include "HashPtrTable.H"
|
||||
#include "externalFileCoupler.H"
|
||||
#include "lumpedPointController.H"
|
||||
@ -116,7 +117,6 @@ namespace Foam
|
||||
class polyMesh;
|
||||
class polyPatch;
|
||||
class pointPatch;
|
||||
class Time;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class lumpedPointMovement Declaration
|
||||
@ -423,7 +423,7 @@ public:
|
||||
const UList<vector>& forces,
|
||||
const UList<vector>& moments,
|
||||
const outputFormatType fmt = outputFormatType::PLAIN,
|
||||
const Time* timeinfo = nullptr
|
||||
const Tuple2<scalar, scalar>* timesWritten = nullptr
|
||||
) const;
|
||||
|
||||
//- Write points, forces, moments
|
||||
@ -431,7 +431,7 @@ public:
|
||||
(
|
||||
const UList<vector>& forces,
|
||||
const UList<vector>& moments = List<vector>(),
|
||||
const Time* timeinfo = nullptr
|
||||
const Tuple2<scalar, scalar>* timesWritten = nullptr
|
||||
) const;
|
||||
|
||||
//- Read state from file, applying relaxation as requested
|
||||
|
||||
@ -208,7 +208,9 @@ lumpedPointDisplacementPointPatchVectorField
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<vector>(p, iF),
|
||||
controllers_()
|
||||
controllers_(),
|
||||
dataWritten_(0, 0),
|
||||
points0Ptr_(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
@ -221,10 +223,14 @@ lumpedPointDisplacementPointPatchVectorField
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<vector>(p, iF, dict),
|
||||
controllers_()
|
||||
controllers_(),
|
||||
dataWritten_(0, 0),
|
||||
points0Ptr_(nullptr)
|
||||
{
|
||||
dict.readIfPresent("controllers", controllers_);
|
||||
|
||||
dict.readIfPresent("dataWritten", dataWritten_);
|
||||
|
||||
if (controllers_.empty())
|
||||
{
|
||||
WarningInFunction
|
||||
@ -239,26 +245,30 @@ lumpedPointDisplacementPointPatchVectorField
|
||||
Foam::lumpedPointDisplacementPointPatchVectorField::
|
||||
lumpedPointDisplacementPointPatchVectorField
|
||||
(
|
||||
const lumpedPointDisplacementPointPatchVectorField& pf,
|
||||
const lumpedPointDisplacementPointPatchVectorField& rhs,
|
||||
const pointPatch& p,
|
||||
const DimensionedField<vector, pointMesh>& iF,
|
||||
const pointPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<vector>(pf, p, iF, mapper),
|
||||
controllers_(pf.controllers_)
|
||||
fixedValuePointPatchField<vector>(rhs, p, iF, mapper),
|
||||
controllers_(rhs.controllers_),
|
||||
dataWritten_(rhs.dataWritten_),
|
||||
points0Ptr_(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
Foam::lumpedPointDisplacementPointPatchVectorField::
|
||||
lumpedPointDisplacementPointPatchVectorField
|
||||
(
|
||||
const lumpedPointDisplacementPointPatchVectorField& pf,
|
||||
const lumpedPointDisplacementPointPatchVectorField& rhs,
|
||||
const DimensionedField<vector, pointMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<vector>(pf, iF),
|
||||
controllers_(pf.controllers_)
|
||||
fixedValuePointPatchField<vector>(rhs, iF),
|
||||
controllers_(rhs.controllers_),
|
||||
dataWritten_(rhs.dataWritten_),
|
||||
points0Ptr_(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
@ -336,7 +346,7 @@ void Foam::lumpedPointDisplacementPointPatchVectorField::updateCoeffs()
|
||||
}
|
||||
else if (movement().couplingPending(timeIndex))
|
||||
{
|
||||
// Trigger is pending, or coupling not yet not initialized
|
||||
// Trigger is pending, or coupling not yet initialized
|
||||
triggered = 1;
|
||||
}
|
||||
|
||||
@ -351,21 +361,24 @@ void Foam::lumpedPointDisplacementPointPatchVectorField::updateCoeffs()
|
||||
Pout<<"gatherForces: " << forces << " called from patch "
|
||||
<< this->patch().index() << endl;
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
Pout<<"output forces to file: called from patch "
|
||||
<< this->patch().index() << nl
|
||||
<<"# " << forces.size() << " force entries" << nl
|
||||
<<"# fx fy fz" << nl
|
||||
<<"output forces to file: "
|
||||
<< forces << " called from patch "
|
||||
<< this->patch().index() << endl;
|
||||
}
|
||||
Info<< "output forces to file: called from patch "
|
||||
<< this->patch().index() << nl
|
||||
<< "# " << forces.size() << " force entries" << nl
|
||||
<< "# fx fy fz" << nl
|
||||
<< "output forces to file: "
|
||||
<< forces << " called from patch "
|
||||
<< this->patch().index() << endl;
|
||||
}
|
||||
|
||||
// Update times when data (forces) were written
|
||||
// With first=time, second=prevTime
|
||||
|
||||
dataWritten_.second() = dataWritten_.first();
|
||||
dataWritten_.first() = this->db().time().timeOutputValue();
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
movement().writeData(forces, moments, &(this->db().time()));
|
||||
movement().writeData(forces, moments, &dataWritten_);
|
||||
|
||||
// Signal external source to execute
|
||||
movement().coupler().useSlave();
|
||||
@ -427,6 +440,12 @@ const
|
||||
os.writeEntry("controllers", controllers_);
|
||||
}
|
||||
|
||||
// Times when data were written is only meaningful on the owner patch
|
||||
if (movement().ownerId() == this->patch().index())
|
||||
{
|
||||
os.writeEntry("dataWritten", dataWritten_);
|
||||
}
|
||||
|
||||
writeEntry("value", os);
|
||||
}
|
||||
|
||||
|
||||
@ -56,10 +56,7 @@ SourceFiles
|
||||
|
||||
#include "fixedValuePointPatchField.H"
|
||||
#include "lumpedPointMovement.H"
|
||||
#include "lumpedPointState.H"
|
||||
#include "lumpedPointIOMovement.H"
|
||||
#include "labelList.H"
|
||||
#include "tmp.H"
|
||||
#include "pointField.H"
|
||||
#include "pointFieldsFwd.H"
|
||||
|
||||
@ -84,13 +81,18 @@ class lumpedPointDisplacementPointPatchVectorField
|
||||
//- Names of the movement controller(s) in use
|
||||
wordList controllers_;
|
||||
|
||||
//- Times when data (forces) were written
|
||||
// With first=time, second=prevTime
|
||||
Tuple2<scalar, scalar> dataWritten_;
|
||||
|
||||
//- Backup method for getting "points0" without a motion solver
|
||||
mutable autoPtr<pointIOField> points0Ptr_;
|
||||
|
||||
|
||||
//- Convenience typedefs
|
||||
typedef lumpedPointDisplacementPointPatchVectorField patchType;
|
||||
typedef DimensionedField<vector, pointMesh> fieldType;
|
||||
// Convenience typedefs
|
||||
|
||||
typedef lumpedPointDisplacementPointPatchVectorField patchType;
|
||||
typedef DimensionedField<vector, pointMesh> fieldType;
|
||||
|
||||
|
||||
protected:
|
||||
@ -130,7 +132,7 @@ public:
|
||||
//- Construct by mapping given patchField<vector> onto a new patch
|
||||
lumpedPointDisplacementPointPatchVectorField
|
||||
(
|
||||
const lumpedPointDisplacementPointPatchVectorField& pf,
|
||||
const lumpedPointDisplacementPointPatchVectorField& rhs,
|
||||
const pointPatch& p,
|
||||
const DimensionedField<vector, pointMesh>& iF,
|
||||
const pointPatchFieldMapper& mapper
|
||||
@ -151,7 +153,7 @@ public:
|
||||
//- Construct as copy setting internal field reference
|
||||
lumpedPointDisplacementPointPatchVectorField
|
||||
(
|
||||
const lumpedPointDisplacementPointPatchVectorField& pf,
|
||||
const lumpedPointDisplacementPointPatchVectorField& rhs,
|
||||
const DimensionedField<vector, pointMesh>& iF
|
||||
);
|
||||
|
||||
@ -171,6 +173,7 @@ public:
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Destructor. De-register movement if in use and managed by this patch
|
||||
virtual ~lumpedPointDisplacementPointPatchVectorField();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user