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