Merge branch 'master' of /home/noisy3/OpenFOAM/OpenFOAM-dev

This commit is contained in:
mattijs
2010-05-12 16:00:41 +01:00
4 changed files with 97 additions and 27 deletions

View File

@ -49,7 +49,10 @@ sixDoFRigidBodyDisplacementPointPatchVectorField
fixedValuePointPatchField<vector>(p, iF), fixedValuePointPatchField<vector>(p, iF),
motion_(), motion_(),
initialPoints_(p.localPoints()), initialPoints_(p.localPoints()),
rhoInf_(1.0) rhoInf_(1.0),
rhoName_("rho"),
lookupGravity_(-1),
g_(vector::zero)
{} {}
@ -63,8 +66,23 @@ sixDoFRigidBodyDisplacementPointPatchVectorField
: :
fixedValuePointPatchField<vector>(p, iF, dict), fixedValuePointPatchField<vector>(p, iF, dict),
motion_(dict), motion_(dict),
rhoInf_(readScalar(dict.lookup("rhoInf"))) rhoInf_(1.0),
rhoName_(dict.lookupOrDefault<word>("rhoName", "rho")),
lookupGravity_(-1),
g_(vector::zero)
{ {
if (rhoName_ == "rhoInf")
{
rhoInf_ = readScalar(dict.lookup("rhoInf"));
}
if (dict.found("g"))
{
lookupGravity_ = -2;
g_ = dict.lookup("g");
}
if (!dict.found("value")) if (!dict.found("value"))
{ {
updateCoeffs(); updateCoeffs();
@ -93,7 +111,10 @@ sixDoFRigidBodyDisplacementPointPatchVectorField
fixedValuePointPatchField<vector>(ptf, p, iF, mapper), fixedValuePointPatchField<vector>(ptf, p, iF, mapper),
motion_(ptf.motion_), motion_(ptf.motion_),
initialPoints_(ptf.initialPoints_, mapper), initialPoints_(ptf.initialPoints_, mapper),
rhoInf_(ptf.rhoInf_) rhoInf_(ptf.rhoInf_),
rhoName_(ptf.rhoName_),
lookupGravity_(ptf.lookupGravity_),
g_(ptf.g_)
{} {}
@ -107,7 +128,10 @@ sixDoFRigidBodyDisplacementPointPatchVectorField
fixedValuePointPatchField<vector>(ptf, iF), fixedValuePointPatchField<vector>(ptf, iF),
motion_(ptf.motion_), motion_(ptf.motion_),
initialPoints_(ptf.initialPoints_), initialPoints_(ptf.initialPoints_),
rhoInf_(ptf.rhoInf_) rhoInf_(ptf.rhoInf_),
rhoName_(ptf.rhoName_),
lookupGravity_(ptf.lookupGravity_),
g_(ptf.g_)
{} {}
@ -146,6 +170,33 @@ void sixDoFRigidBodyDisplacementPointPatchVectorField::updateCoeffs()
return; return;
} }
if (lookupGravity_ < 0)
{
if (db().foundObject<uniformDimensionedVectorField>("g"))
{
if (lookupGravity_ == -2)
{
FatalErrorIn
(
"void sixDoFRigidBodyDisplacementPointPatchVectorField"
"::updateCoeffs()"
)
<< "Specifying the value of g in this boundary condition "
<< "when g is available from the database is considered "
<< "a fatal error to avoid the possibility of inconsistency"
<< exit(FatalError);
}
else
{
lookupGravity_ = 1;
}
}
else
{
lookupGravity_ = 0;
}
}
const polyMesh& mesh = this->dimensionedInternalField().mesh()(); const polyMesh& mesh = this->dimensionedInternalField().mesh()();
const Time& t = mesh.time(); const Time& t = mesh.time();
const pointPatch& ptPatch = this->patch(); const pointPatch& ptPatch = this->patch();
@ -160,6 +211,7 @@ void sixDoFRigidBodyDisplacementPointPatchVectorField::updateCoeffs()
forcesDict.add("patches", wordList(1, ptPatch.name())); forcesDict.add("patches", wordList(1, ptPatch.name()));
forcesDict.add("rhoInf", rhoInf_); forcesDict.add("rhoInf", rhoInf_);
forcesDict.add("rhoName", rhoName_);
forcesDict.add("CofR", motion_.centreOfMass()); forcesDict.add("CofR", motion_.centreOfMass());
forces f("forces", db(), forcesDict); forces f("forces", db(), forcesDict);
@ -168,19 +220,17 @@ void sixDoFRigidBodyDisplacementPointPatchVectorField::updateCoeffs()
// Get the forces on the patch faces at the current positions // Get the forces on the patch faces at the current positions
vector gravity = vector::zero; if (lookupGravity_ == 1)
if (db().foundObject<uniformDimensionedVectorField>("g"))
{ {
uniformDimensionedVectorField g = uniformDimensionedVectorField g =
db().lookupObject<uniformDimensionedVectorField>("g"); db().lookupObject<uniformDimensionedVectorField>("g");
gravity = g.value(); g_ = g.value();
} }
motion_.updateForce motion_.updateForce
( (
fm.first().first() + fm.first().second() + gravity*motion_.mass(), fm.first().first() + fm.first().second() + g_*motion_.mass(),
fm.second().first() + fm.second().second(), fm.second().first() + fm.second().second(),
t.deltaTValue() t.deltaTValue()
); );
@ -197,10 +247,20 @@ void sixDoFRigidBodyDisplacementPointPatchVectorField::updateCoeffs()
void sixDoFRigidBodyDisplacementPointPatchVectorField::write(Ostream& os) const void sixDoFRigidBodyDisplacementPointPatchVectorField::write(Ostream& os) const
{ {
pointPatchField<vector>::write(os); pointPatchField<vector>::write(os);
os.writeKeyword("rhoInf") << rhoInf_ << token::END_STATEMENT << nl;
os.writeKeyword("rhoName") << rhoName_ << token::END_STATEMENT << nl;
if (lookupGravity_ == 0 || lookupGravity_ == -2)
{
os.writeKeyword("g") << g_ << token::END_STATEMENT << nl;
}
motion_.write(os); motion_.write(os);
os.writeKeyword("rhoInf")
<< rhoInf_ << token::END_STATEMENT << nl;
initialPoints_.writeEntry("initialPoints", os); initialPoints_.writeEntry("initialPoints", os);
writeEntry("value", os); writeEntry("value", os);
} }

View File

@ -60,9 +60,30 @@ class sixDoFRigidBodyDisplacementPointPatchVectorField
pointField initialPoints_; pointField initialPoints_;
//- Reference density required by the forces object for //- Reference density required by the forces object for
// incompressible calculations // incompressible calculations, required if rhoName == rhoInf
scalar rhoInf_; scalar rhoInf_;
//- Name of density field, optional unless used for an
// incompressible simulation, when this needs to be specified
// as rhoInf
word rhoName_;
//- State of gravity lookup:
// -1 = not determined yet, as the BC may be instantiated before g has
// been read into the db yet. Determination deferred until first
// call to updateCoeffs. A g keyword was not supplied to the
// dictionary.
// -2 = as for -1, but a gravity value was specified in the dictionary,
// specifying a value in the dictionary is considered a fatal
// error if g is available from the db.
// 0 = Use this boundary condition's own value of gravity, as not
// available from the db.
// 1 = Lookup gravity from db.
label lookupGravity_;
//- Gravity vector to store when not available from the db
vector g_;
public: public:

View File

@ -47,8 +47,7 @@ uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
: :
fixedValuePointPatchField<vector>(p, iF), fixedValuePointPatchField<vector>(p, iF),
motion_(), motion_(),
initialPoints_(p.localPoints()), initialPoints_(p.localPoints())
rhoInf_(1.0)
{} {}
@ -61,8 +60,7 @@ uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
) )
: :
fixedValuePointPatchField<vector>(p, iF, dict), fixedValuePointPatchField<vector>(p, iF, dict),
motion_(dict), motion_(dict)
rhoInf_(readScalar(dict.lookup("rhoInf")))
{ {
if (!dict.found("value")) if (!dict.found("value"))
{ {
@ -91,8 +89,7 @@ uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
: :
fixedValuePointPatchField<vector>(ptf, p, iF, mapper), fixedValuePointPatchField<vector>(ptf, p, iF, mapper),
motion_(ptf.motion_), motion_(ptf.motion_),
initialPoints_(ptf.initialPoints_, mapper), initialPoints_(ptf.initialPoints_, mapper)
rhoInf_(ptf.rhoInf_)
{} {}
@ -105,8 +102,7 @@ uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
: :
fixedValuePointPatchField<vector>(ptf, iF), fixedValuePointPatchField<vector>(ptf, iF),
motion_(ptf.motion_), motion_(ptf.motion_),
initialPoints_(ptf.initialPoints_), initialPoints_(ptf.initialPoints_)
rhoInf_(ptf.rhoInf_)
{} {}
@ -182,8 +178,6 @@ void uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::write
{ {
pointPatchField<vector>::write(os); pointPatchField<vector>::write(os);
motion_.write(os); motion_.write(os);
os.writeKeyword("rhoInf")
<< rhoInf_ << token::END_STATEMENT << nl;
initialPoints_.writeEntry("initialPoints", os); initialPoints_.writeEntry("initialPoints", os);
writeEntry("value", os); writeEntry("value", os);
} }

View File

@ -59,11 +59,6 @@ class uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
//- Initial positions of points on the patch //- Initial positions of points on the patch
pointField initialPoints_; pointField initialPoints_;
//- Reference density required by the forces object for
// incompressible calculations. Retained here to give
// dictionary compatibility with other sixDoF patches.
scalar rhoInf_;
public: public: