STYLE: avoid unrestricted dictionary lookup in lumpedPointMotion (issue #762)

- improve doxygen for lumpedPointMotion
This commit is contained in:
Mark Olesen
2018-07-23 21:06:14 +02:00
parent 9f0a80a655
commit 9f52213f63
9 changed files with 109 additions and 59 deletions

View File

@ -25,10 +25,6 @@ Class
Foam::lumpedPointDisplacementPointPatchVectorField Foam::lumpedPointDisplacementPointPatchVectorField
Description Description
Interpolates pre-specified motion with motion specified as
pointVectorFields.
This is the point-patch responsible for managing the force This is the point-patch responsible for managing the force
integration on a 'lumped-point' basis, waiting for the external integration on a 'lumped-point' basis, waiting for the external
application, reading back the response from the external program application, reading back the response from the external program
@ -38,24 +34,15 @@ Description
The internal patch type name is 'lumpedPointDisplacement'. The internal patch type name is 'lumpedPointDisplacement'.
\heading Patch usage \heading Patch usage
Example: Example:
\verbatim \verbatim
walls walls
{ {
type lumpedPointDisplacement; type lumpedPointDisplacement;
value uniform (0 0 0); value uniform (0 0 0);
fieldName wantedDisplacement;
interpolationScheme linear;
} }
\endverbatim \endverbatim
This will scan the case for \a wantedDisplacement pointVectorFields
and interpolate those in time (using \c linear interpolation) to
obtain the current displacement.
The advantage of specifying displacement in this way is that it
automatically works through decomposePar.
SourceFiles SourceFiles
lumpedPointDisplacementPointPatchVectorField.C lumpedPointDisplacementPointPatchVectorField.C
@ -78,6 +65,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward declarations
class interpolationWeights; class interpolationWeights;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
@ -94,15 +82,16 @@ class lumpedPointDisplacementPointPatchVectorField
typedef lumpedPointDisplacementPointPatchVectorField patchType; typedef lumpedPointDisplacementPointPatchVectorField patchType;
typedef DimensionedField<vector, pointMesh> fieldType; typedef DimensionedField<vector, pointMesh> fieldType;
// Private Member Functions
protected: protected:
//- The starting locations (obtained from the motionSolver). // Protected Member Functions
const pointField& points0() const;
//- The auto-vivifying singleton for movement. //- The starting locations (obtained from the motionSolver).
const lumpedPointMovement& movement() const; const pointField& points0() const;
//- The auto-vivifying singleton for movement.
const lumpedPointMovement& movement() const;
public: public:
@ -172,7 +161,7 @@ public:
); );
} }
//- Destructor //- Destructor. De-register movement if in use and managed by this patch
virtual ~lumpedPointDisplacementPointPatchVectorField(); virtual ~lumpedPointDisplacementPointPatchVectorField();
@ -185,7 +174,7 @@ public:
virtual void updateCoeffs(); virtual void updateCoeffs();
//- Write //- Write
virtual void write(Ostream&) const; virtual void write(Ostream& os) const;
}; };

View File

@ -99,15 +99,8 @@ Foam::lumpedPointIOMovement::lumpedPointIOMovement
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::lumpedPointIOMovement::~lumpedPointIOMovement()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::lumpedPointIOMovement::readData(Istream& is) bool Foam::lumpedPointIOMovement::readData(Istream& is)
{ {
dictionary dict(is); dictionary dict(is);

View File

@ -100,7 +100,7 @@ public:
//- Destructor //- Destructor
~lumpedPointIOMovement(); ~lumpedPointIOMovement() = default;
// Member Functions // Member Functions

View File

@ -54,7 +54,7 @@ const Foam::Enum
> >
Foam::lumpedPointMovement::scalingNames Foam::lumpedPointMovement::scalingNames
{ {
{ scalingType::LENGTH, "plain" }, { scalingType::LENGTH, "length" },
{ scalingType::FORCE, "force" }, { scalingType::FORCE, "force" },
{ scalingType::MOMENT, "moment" } { scalingType::MOMENT, "moment" }
}; };
@ -266,7 +266,7 @@ void Foam::lumpedPointMovement::readDict(const dictionary& dict)
// assume the worst // assume the worst
deleteDemandDrivenData(thresholdPtr_); deleteDemandDrivenData(thresholdPtr_);
dict.lookup("axis") >> axis_; dict.read("axis", axis_);
division_ = 0; division_ = 0;
if (dict.readIfPresent("division", division_)) if (dict.readIfPresent("division", division_))
@ -283,7 +283,7 @@ void Foam::lumpedPointMovement::readDict(const dictionary& dict)
dict.readIfPresent("relax", relax_); dict.readIfPresent("relax", relax_);
dict.lookup("locations") >> locations_; dict.read("locations", locations_);
if (dict.readIfPresent("interpolationScheme", interpolationScheme_)) if (dict.readIfPresent("interpolationScheme", interpolationScheme_))
{ {
@ -304,8 +304,8 @@ void Foam::lumpedPointMovement::readDict(const dictionary& dict)
// TODO: calcFrequency_ = dict.lookupOrDefault("calcFrequency", 1); // TODO: calcFrequency_ = dict.lookupOrDefault("calcFrequency", 1);
commDict.lookup("inputName") >> inputName_; commDict.read("inputName", inputName_);
commDict.lookup("outputName") >> outputName_; commDict.read("outputName", outputName_);
commDict.readIfPresent("logName", logName_); commDict.readIfPresent("logName", logName_);
inputFormat_ = lumpedPointState::formatNames.lookup inputFormat_ = lumpedPointState::formatNames.lookup
@ -512,8 +512,7 @@ bool Foam::lumpedPointMovement::forcesAndMoments
const polyBoundaryMesh& patches = pmesh.boundaryMesh(); const polyBoundaryMesh& patches = pmesh.boundaryMesh();
const word pName = forcesDict_.lookupOrDefault<word>("p", "p"); const word pName(forcesDict_.lookupOrDefault<word>("p", "p"));
scalar pRef = forcesDict_.lookupOrDefault<scalar>("pRef", 0.0); scalar pRef = forcesDict_.lookupOrDefault<scalar>("pRef", 0.0);
scalar rhoRef = forcesDict_.lookupOrDefault<scalar>("rhoRef", 1.0); scalar rhoRef = forcesDict_.lookupOrDefault<scalar>("rhoRef", 1.0);

View File

@ -25,11 +25,63 @@ Class
Foam::lumpedPointMovement Foam::lumpedPointMovement
Description Description
The movement 'driver' that describes initial point locations, the The movement \a driver that describes initial point locations, the
segmentation for pressure integration, the current state of the segmentation for pressure integration, the current state of the
points/rotations, and forwarding to the communication points/rotations, and forwarding to the externalFileCoupler
coordinator. The 'lumpedPointIOMovement' class is simply a communication coordinator.
registered version of the same.
The lumpedPointIOMovement class is simply a registered version of
the same.
See externalFileCoupler for more information about some of
the communication parameters and setup.
\heading Dictionary parameters
\table
Property | Description | Required | Default
axis | Reference axis for the locations | yes |
locations | List of lumped point locations | yes |
centre | Offset of patch points to locations | no | automatic
division | Division (0-1) for pressure forces | no | 0
relax | Relaxation/scaling for updating positions | no |
interpolationScheme | The interpolation scheme | yes |
forces | Optional forces dictionary | no |
communication | Required communication dictionary | yes |
\endtable
\heading Parameters for communication dictionary
\table
Property | Description | Required | Default
inputName | Name of positions input file | yes |
outputName | Name of forces output file | yes |
logName | Name of log file | no | movement.log
inputFormat | Input format: dictionary/plain | yes |
outputFormat | Output format: dictionary/plain | yes |
scaleInput | Input scaling parameter dictionary | no |
scaleOutput | Output scaling parameter dictionary | no |
\endtable
\heading Parameters for optional communication/scaleInput dictionary
\table
Property | Description | Required | Default
length | Scaling for input positions | no | 1
\endtable
\heading Parameters for optional communication/scaleOutput dictionary
\table
Property | Description | Required | Default
length | Scaling for output positions | no | 1
force | Scaling for force | no | 1
moment | Scaling for moment | no | 1
\endtable
\heading Parameters for optional forces dictionary
\table
Property | Description | Required | Default
p | Name of the pressure field | no | p
pRef | Reference pressure in Pa | no | 0
rhoRef | Reference density for incompressible | no | 1
\endtable
SourceFiles SourceFiles
lumpedPointMovement.C lumpedPointMovement.C
@ -76,16 +128,16 @@ public:
//- Output format types //- Output format types
enum class outputFormatType enum class outputFormatType
{ {
PLAIN, PLAIN, //!< "plain" is a simple ASCII format
DICTIONARY DICTIONARY //!< "dictionary" is the OpenFOAM dictionary format
}; };
//- Output format types //- Output format types
enum scalingType enum scalingType
{ {
LENGTH = 0, LENGTH = 0, //!< The "length" scaling
FORCE, FORCE, //!< The "force" scaling
MOMENT MOMENT //!< The "moment" scaling
}; };
// Static data // Static data

View File

@ -72,9 +72,6 @@ communication
inputFormat dictionary; inputFormat dictionary;
outputFormat dictionary; outputFormat dictionary;
debugTable "$FOAM_CASE/output.txt";
// Scaling applied to values read from 'inputName' // Scaling applied to values read from 'inputName'
scaleInput scaleInput
{ {

View File

@ -83,8 +83,8 @@ void Foam::lumpedPointState::calcRotations() const
void Foam::lumpedPointState::readDict(const dictionary& dict) void Foam::lumpedPointState::readDict(const dictionary& dict)
{ {
dict.lookup("points") >> points_; dict.read("points", points_);
dict.lookup("angles") >> angles_; dict.read("angles", angles_);
degrees_ = dict.lookupOrDefault("degrees", false); degrees_ = dict.lookupOrDefault("degrees", false);
deleteDemandDrivenData(rotationPtr_); deleteDemandDrivenData(rotationPtr_);
} }
@ -228,8 +228,8 @@ bool Foam::lumpedPointState::readPlain(Istream& is)
points_.setSize(count); points_.setSize(count);
angles_.setSize(count); angles_.setSize(count);
degrees_ = false; degrees_ = false;
deleteDemandDrivenData(rotationPtr_); deleteDemandDrivenData(rotationPtr_);
return count; return count;

View File

@ -25,10 +25,31 @@ Class
Foam::lumpedPointState Foam::lumpedPointState
Description Description
The 'state' of lumped points corresponds to positions and rotations. The \a state of lumped points corresponds to positions and rotations.
Encapsulates the response from the external application. This class encapsulates the response from the external application and
Entry place for applying relaxation and sub-stepping etc. serves as the entry point for applying relaxation, sub-stepping etc.
\heading Dictionary input format
\table
Property | Description | Required | Default
points | List of points | yes |
angles | List of Euler rotation angles | yes |
degrees | Rotation angles in degrees | no | false
\endtable
\heading Plain input format.
Blank and comment lines starting with a '#' character are ignored.
The angles are always in radians.
\verbatim
NumPoints
x0 y0 z0 eulerz0 eulerx'0 eulerz''0
x1 y1 z1 eulerz1 eulerx'1 eulerz''1
...
\endverbatim
SeeAlso
EulerCoordinateRotation
SourceFiles SourceFiles
lumpedPointState.C lumpedPointState.C
@ -58,7 +79,6 @@ class Ostream;
Class lumpedPointState Declaration Class lumpedPointState Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
//- Bundling of position/rotation
class lumpedPointState class lumpedPointState
{ {
public: public:
@ -66,8 +86,8 @@ public:
//- Input format types //- Input format types
enum class inputFormatType enum class inputFormatType
{ {
PLAIN, PLAIN, //!< "plain" is a simple ASCII format
DICTIONARY DICTIONARY //!< "dictionary" is the OpenFOAM dictionary format
}; };
// Static data // Static data

View File

@ -83,7 +83,7 @@ Foam::lumpedPointTools::lumpedPointStates(Istream& is)
( (
lumpedPointStateTuple lumpedPointStateTuple
( (
readScalar(dict.lookup("time")), dict.get<scalar>("time"),
lumpedPointState(dict) lumpedPointState(dict)
) )
); );