fvModels, fvConstraints: Update as a result of mesh motion

This commit is contained in:
Will Bainbridge
2021-08-12 13:26:53 +01:00
parent 737d91ec72
commit 19bdfa969f
38 changed files with 261 additions and 30 deletions

View File

@ -191,6 +191,13 @@ void Foam::fv::VoFSolidificationMeltingSource::updateMesh
} }
bool Foam::fv::VoFSolidificationMeltingSource::movePoints()
{
set_.movePoints();
return true;
}
void Foam::fv::VoFSolidificationMeltingSource::correct() void Foam::fv::VoFSolidificationMeltingSource::correct()
{ {
if (debug) if (debug)

View File

@ -193,6 +193,9 @@ public:
//- Update for mesh changes //- Update for mesh changes
virtual void updateMesh(const mapPolyMesh&); virtual void updateMesh(const mapPolyMesh&);
//- Update for mesh motion
virtual bool movePoints();
//- Correct the model //- Correct the model
virtual void correct(); virtual void correct();

View File

@ -179,6 +179,18 @@ void ${typeName}FvModel${SourceType}::addSup
} }
void ${typeName}FvModel${SourceType}::updateMesh(const mapPolyMesh& mpm)
{
set_.updateMesh(mpm);
}
bool ${typeName}FvModel${SourceType}::movePoints()
{
set_.movePoints();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam } // End namespace Foam

View File

@ -110,6 +110,15 @@ public:
fvMatrix<${TemplateType}>& eqn, fvMatrix<${TemplateType}>& eqn,
const word& fieldName const word& fieldName
) const; ) const;
// Mesh motion
//- Update for mesh changes
virtual void updateMesh(const mapPolyMesh&);
//- Update for mesh motion
virtual bool movePoints();
}; };

View File

@ -49,7 +49,7 @@ namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::fvCellSet::setCellSet() void Foam::fvCellSet::setCells()
{ {
Info<< incrIndent; Info<< incrIndent;
@ -119,7 +119,14 @@ void Foam::fvCellSet::setCellSet()
} }
} }
// Set volume information Info<< decrIndent;
}
void Foam::fvCellSet::setV()
{
Info<< incrIndent;
V_ = 0; V_ = 0;
forAll(cells_, i) forAll(cells_, i)
{ {
@ -162,7 +169,18 @@ Foam::fvCellSet::~fvCellSet()
void Foam::fvCellSet::updateMesh(const mapPolyMesh&) void Foam::fvCellSet::updateMesh(const mapPolyMesh&)
{ {
setCellSet(); setCells();
setV();
}
void Foam::fvCellSet::movePoints()
{
if (selectionMode_ == selectionModeType::points)
{
setCells();
}
setV();
} }
@ -202,7 +220,8 @@ bool Foam::fvCellSet::read(const dictionary& dict)
} }
} }
setCellSet(); setCells();
setV();
return true; return true;
} }

View File

@ -122,8 +122,11 @@ private:
//- Read the coefficients from the given dictionary //- Read the coefficients from the given dictionary
void readCoeffs(const dictionary& dict); void readCoeffs(const dictionary& dict);
//- Set the cell set based on the user input selection mode //- Set the cells
void setCellSet(); void setCells();
//- Set the sum of scalar volumes
void setV();
public: public:
@ -165,6 +168,9 @@ public:
//- Update for mesh changes //- Update for mesh changes
void updateMesh(const mapPolyMesh&); void updateMesh(const mapPolyMesh&);
//- Update for mesh motion
void movePoints();
// IO // IO

View File

@ -162,6 +162,13 @@ void Foam::fv::fixedTemperatureConstraint::updateMesh(const mapPolyMesh& mpm)
} }
bool Foam::fv::fixedTemperatureConstraint::movePoints()
{
set_.movePoints();
return true;
}
bool Foam::fv::fixedTemperatureConstraint::read(const dictionary& dict) bool Foam::fv::fixedTemperatureConstraint::read(const dictionary& dict)
{ {
if (fvConstraint::read(dict)) if (fvConstraint::read(dict))

View File

@ -158,6 +158,9 @@ public:
//- Update for mesh changes //- Update for mesh changes
virtual void updateMesh(const mapPolyMesh&); virtual void updateMesh(const mapPolyMesh&);
//- Update for mesh motion
virtual bool movePoints();
//- Read dictionary //- Read dictionary
virtual bool read(const dictionary& dict); virtual bool read(const dictionary& dict);

View File

@ -126,6 +126,13 @@ void Foam::fv::fixedValueConstraint::updateMesh(const mapPolyMesh& mpm)
} }
bool Foam::fv::fixedValueConstraint::movePoints()
{
set_.movePoints();
return true;
}
bool Foam::fv::fixedValueConstraint::read(const dictionary& dict) bool Foam::fv::fixedValueConstraint::read(const dictionary& dict)
{ {
if (fvConstraint::read(dict)) if (fvConstraint::read(dict))

View File

@ -121,6 +121,9 @@ public:
//- Update for mesh changes //- Update for mesh changes
virtual void updateMesh(const mapPolyMesh&); virtual void updateMesh(const mapPolyMesh&);
//- Update for mesh motion
virtual bool movePoints();
//- Read source dictionary //- Read source dictionary
virtual bool read(const dictionary& dict); virtual bool read(const dictionary& dict);
}; };

View File

@ -148,6 +148,13 @@ void Foam::fv::limitTemperature::updateMesh(const mapPolyMesh& mpm)
} }
bool Foam::fv::limitTemperature::movePoints()
{
set_.movePoints();
return true;
}
bool Foam::fv::limitTemperature::read(const dictionary& dict) bool Foam::fv::limitTemperature::read(const dictionary& dict)
{ {
if (fvConstraint::read(dict)) if (fvConstraint::read(dict))

View File

@ -127,6 +127,9 @@ public:
//- Update for mesh changes //- Update for mesh changes
virtual void updateMesh(const mapPolyMesh&); virtual void updateMesh(const mapPolyMesh&);
//- Update for mesh motion
virtual bool movePoints();
//- Read dictionary //- Read dictionary
virtual bool read(const dictionary& dict); virtual bool read(const dictionary& dict);

View File

@ -134,6 +134,13 @@ void Foam::fv::limitVelocity::updateMesh(const mapPolyMesh& mpm)
} }
bool Foam::fv::limitVelocity::movePoints()
{
set_.movePoints();
return true;
}
bool Foam::fv::limitVelocity::read(const dictionary& dict) bool Foam::fv::limitVelocity::read(const dictionary& dict)
{ {
if (fvConstraint::read(dict)) if (fvConstraint::read(dict))

View File

@ -121,6 +121,9 @@ public:
//- Update for mesh changes //- Update for mesh changes
virtual void updateMesh(const mapPolyMesh&); virtual void updateMesh(const mapPolyMesh&);
//- Update for mesh motion
virtual bool movePoints();
//- Read dictionary //- Read dictionary
virtual bool read(const dictionary& dict); virtual bool read(const dictionary& dict);

View File

@ -254,6 +254,13 @@ void Foam::fv::meanVelocityForce::updateMesh(const mapPolyMesh& mpm)
} }
bool Foam::fv::meanVelocityForce::movePoints()
{
set_.movePoints();
return true;
}
bool Foam::fv::meanVelocityForce::read(const dictionary& dict) bool Foam::fv::meanVelocityForce::read(const dictionary& dict)
{ {
if (fvConstraint::read(dict)) if (fvConstraint::read(dict))

View File

@ -158,6 +158,9 @@ public:
//- Update for mesh changes //- Update for mesh changes
virtual void updateMesh(const mapPolyMesh&); virtual void updateMesh(const mapPolyMesh&);
//- Update for mesh motion
virtual bool movePoints();
//- Read source dictionary //- Read source dictionary
virtual bool read(const dictionary& dict); virtual bool read(const dictionary& dict);

View File

@ -117,6 +117,13 @@ void Foam::fv::accelerationSource::updateMesh(const mapPolyMesh& mpm)
} }
bool Foam::fv::accelerationSource::movePoints()
{
set_.movePoints();
return true;
}
bool Foam::fv::accelerationSource::read(const dictionary& dict) bool Foam::fv::accelerationSource::read(const dictionary& dict)
{ {
if (fvModel::read(dict)) if (fvModel::read(dict))

View File

@ -168,6 +168,9 @@ public:
//- Update for mesh changes //- Update for mesh changes
virtual void updateMesh(const mapPolyMesh&); virtual void updateMesh(const mapPolyMesh&);
//- Update for mesh motion
virtual bool movePoints();
// IO // IO

View File

@ -175,6 +175,13 @@ void Foam::fv::actuationDiskSource::updateMesh(const mapPolyMesh& mpm)
} }
bool Foam::fv::actuationDiskSource::movePoints()
{
set_.movePoints();
return true;
}
bool Foam::fv::actuationDiskSource::read(const dictionary& dict) bool Foam::fv::actuationDiskSource::read(const dictionary& dict)
{ {
if (fvModel::read(dict)) if (fvModel::read(dict))

View File

@ -198,6 +198,9 @@ public:
//- Update for mesh changes //- Update for mesh changes
virtual void updateMesh(const mapPolyMesh&); virtual void updateMesh(const mapPolyMesh&);
//- Update for mesh motion
virtual bool movePoints();
// IO // IO

View File

@ -320,6 +320,13 @@ void Foam::fv::effectivenessHeatExchangerSource::updateMesh
} }
bool Foam::fv::effectivenessHeatExchangerSource::movePoints()
{
set_.movePoints();
return true;
}
bool Foam::fv::effectivenessHeatExchangerSource::read(const dictionary& dict) bool Foam::fv::effectivenessHeatExchangerSource::read(const dictionary& dict)
{ {
if (fvModel::read(dict)) if (fvModel::read(dict))

View File

@ -220,6 +220,9 @@ public:
//- Update for mesh changes //- Update for mesh changes
virtual void updateMesh(const mapPolyMesh&); virtual void updateMesh(const mapPolyMesh&);
//- Update for mesh motion
virtual bool movePoints();
//- Read dictionary //- Read dictionary
virtual bool read(const dictionary& dict); virtual bool read(const dictionary& dict);

View File

@ -145,6 +145,13 @@ void Foam::fv::explicitPorositySource::updateMesh(const mapPolyMesh& mpm)
} }
bool Foam::fv::explicitPorositySource::movePoints()
{
set_.movePoints();
return true;
}
bool Foam::fv::explicitPorositySource::read(const dictionary& dict) bool Foam::fv::explicitPorositySource::read(const dictionary& dict)
{ {
if (fvModel::read(dict)) if (fvModel::read(dict))

View File

@ -181,6 +181,9 @@ public:
//- Update for mesh changes //- Update for mesh changes
virtual void updateMesh(const mapPolyMesh&); virtual void updateMesh(const mapPolyMesh&);
//- Update for mesh motion
virtual bool movePoints();
// IO // IO

View File

@ -150,6 +150,19 @@ void Foam::fv::heatSource::addSup
} }
void Foam::fv::heatSource::updateMesh(const mapPolyMesh& mpm)
{
set_.updateMesh(mpm);
}
bool Foam::fv::heatSource::movePoints()
{
set_.movePoints();
return true;
}
bool Foam::fv::heatSource::read(const dictionary& dict) bool Foam::fv::heatSource::read(const dictionary& dict)
{ {
if (fvModel::read(dict)) if (fvModel::read(dict))

View File

@ -130,6 +130,15 @@ public:
) const; ) const;
// Mesh motion
//- Update for mesh changes
virtual void updateMesh(const mapPolyMesh&);
//- Update for mesh motion
virtual bool movePoints();
// IO // IO
//- Read dictionary //- Read dictionary

View File

@ -159,6 +159,19 @@ void Foam::fv::heatTransfer::correct()
} }
void Foam::fv::heatTransfer::updateMesh(const mapPolyMesh& mpm)
{
set_.updateMesh(mpm);
}
bool Foam::fv::heatTransfer::movePoints()
{
set_.movePoints();
return true;
}
bool Foam::fv::heatTransfer::read(const dictionary& dict) bool Foam::fv::heatTransfer::read(const dictionary& dict)
{ {
if (fvModel::read(dict)) if (fvModel::read(dict))

View File

@ -173,6 +173,15 @@ public:
virtual void correct(); virtual void correct();
// Mesh motion
//- Update for mesh changes
virtual void updateMesh(const mapPolyMesh&);
//- Update for mesh motion
virtual bool movePoints();
// IO // IO
//- Read dictionary //- Read dictionary

View File

@ -300,6 +300,13 @@ void Foam::fv::massSource::updateMesh(const mapPolyMesh& mpm)
} }
bool Foam::fv::massSource::movePoints()
{
set_.movePoints();
return true;
}
bool Foam::fv::massSource::read(const dictionary& dict) bool Foam::fv::massSource::read(const dictionary& dict)
{ {
if (fvModel::read(dict)) if (fvModel::read(dict))

View File

@ -214,6 +214,9 @@ public:
//- Update for mesh changes //- Update for mesh changes
virtual void updateMesh(const mapPolyMesh&); virtual void updateMesh(const mapPolyMesh&);
//- Update for mesh motion
virtual bool movePoints();
// IO // IO

View File

@ -636,6 +636,13 @@ void Foam::fv::rotorDiskSource::updateMesh(const mapPolyMesh& mpm)
} }
bool Foam::fv::rotorDiskSource::movePoints()
{
set_.movePoints();
return true;
}
bool Foam::fv::rotorDiskSource::read(const dictionary& dict) bool Foam::fv::rotorDiskSource::read(const dictionary& dict)
{ {
if (fvModel::read(dict)) if (fvModel::read(dict))

View File

@ -341,6 +341,9 @@ public:
//- Update for mesh changes //- Update for mesh changes
virtual void updateMesh(const mapPolyMesh&); virtual void updateMesh(const mapPolyMesh&);
//- Update for mesh motion
virtual bool movePoints();
// IO // IO

View File

@ -362,6 +362,13 @@ void Foam::fv::solidificationMeltingSource::updateMesh(const mapPolyMesh& mpm)
} }
bool Foam::fv::solidificationMeltingSource::movePoints()
{
set_.movePoints();
return true;
}
bool Foam::fv::solidificationMeltingSource::read(const dictionary& dict) bool Foam::fv::solidificationMeltingSource::read(const dictionary& dict)
{ {
if (fvModel::read(dict)) if (fvModel::read(dict))

View File

@ -307,6 +307,9 @@ public:
//- Update for mesh changes //- Update for mesh changes
virtual void updateMesh(const mapPolyMesh&); virtual void updateMesh(const mapPolyMesh&);
//- Update for mesh motion
virtual bool movePoints();
// IO // IO

View File

@ -233,7 +233,6 @@ Foam::fv::codedFvModel::codedFvModel
) )
: :
fvModel(name, modelType, dict, mesh), fvModel(name, modelType, dict, mesh),
set_(coeffs(), mesh),
fieldName_(word::null) fieldName_(word::null)
{ {
readCoeffs(); readCoeffs();
@ -259,7 +258,13 @@ FOR_ALL_FIELD_TYPES(IMPLEMENT_FV_MODEL_ADD_ALPHA_RHO_SUP, fv::codedFvModel);
void Foam::fv::codedFvModel::updateMesh(const mapPolyMesh& mpm) void Foam::fv::codedFvModel::updateMesh(const mapPolyMesh& mpm)
{ {
set_.updateMesh(mpm); redirectFvModel().updateMesh(mpm);
}
bool Foam::fv::codedFvModel::movePoints()
{
return redirectFvModel().movePoints();
} }
@ -267,7 +272,6 @@ bool Foam::fv::codedFvModel::read(const dictionary& dict)
{ {
if (fvModel::read(dict)) if (fvModel::read(dict))
{ {
set_.read(coeffs());
readCoeffs(); readCoeffs();
return true; return true;
} }

View File

@ -94,9 +94,6 @@ class codedFvModel
{ {
// Private data // Private data
//- The set of cells the fvConstraint applies to
fvCellSet set_;
//- The name of the field that this fvModel applies to //- The name of the field that this fvModel applies to
word fieldName_; word fieldName_;
@ -208,6 +205,9 @@ public:
//- Update for mesh changes //- Update for mesh changes
virtual void updateMesh(const mapPolyMesh&); virtual void updateMesh(const mapPolyMesh&);
//- Update for mesh motion
virtual bool movePoints();
// IO // IO

View File

@ -64,17 +64,6 @@ void Foam::fv::semiImplicitSource::readCoeffs()
// Get the volume mode // Get the volume mode
volumeMode_ = volumeModeNames_.read(coeffs().lookup("volumeMode")); volumeMode_ = volumeModeNames_.read(coeffs().lookup("volumeMode"));
// Set volume normalisation
switch (volumeMode_)
{
case volumeMode::absolute:
VDash_ = set_.V();
break;
case volumeMode::specific:
VDash_ = 1;
break;
}
// Set field source terms // Set field source terms
fieldSp_.clear(); fieldSp_.clear();
fieldSu_.clear(); fieldSu_.clear();
@ -142,9 +131,21 @@ void Foam::fv::semiImplicitSource::addSupType
false false
); );
// Set volume normalisation
scalar VDash = NaN;
switch (volumeMode_)
{
case volumeMode::absolute:
VDash = set_.V();
break;
case volumeMode::specific:
VDash = 1;
break;
}
// Explicit source function for the field // Explicit source function for the field
UIndirectList<Type>(Su, set_.cells()) = UIndirectList<Type>(Su, set_.cells()) =
fieldSu_[fieldName]->value<Type>(t)/VDash_; fieldSu_[fieldName]->value<Type>(t)/VDash;
volScalarField::Internal Sp volScalarField::Internal Sp
( (
@ -168,7 +169,7 @@ void Foam::fv::semiImplicitSource::addSupType
// Implicit source function for the field // Implicit source function for the field
UIndirectList<scalar>(Sp, set_.cells()) = UIndirectList<scalar>(Sp, set_.cells()) =
fieldSp_[fieldName]->value(t)/VDash_; fieldSp_[fieldName]->value(t)/VDash;
eqn += Su + fvm::SuSp(Sp, psi); eqn += Su + fvm::SuSp(Sp, psi);
} }
@ -211,8 +212,7 @@ Foam::fv::semiImplicitSource::semiImplicitSource
: :
fvModel(name, modelType, dict, mesh), fvModel(name, modelType, dict, mesh),
set_(coeffs(), mesh), set_(coeffs(), mesh),
volumeMode_(volumeMode::absolute), volumeMode_(volumeMode::absolute)
VDash_(1)
{ {
readCoeffs(); readCoeffs();
} }
@ -251,6 +251,13 @@ void Foam::fv::semiImplicitSource::updateMesh(const mapPolyMesh& mpm)
} }
bool Foam::fv::semiImplicitSource::movePoints()
{
set_.movePoints();
return true;
}
bool Foam::fv::semiImplicitSource::read(const dictionary& dict) bool Foam::fv::semiImplicitSource::read(const dictionary& dict)
{ {
if (fvModel::read(dict)) if (fvModel::read(dict))

View File

@ -137,9 +137,6 @@ private:
//- Volume mode //- Volume mode
volumeMode volumeMode_; volumeMode volumeMode_;
//- Volume normalisation
scalar VDash_;
//- Explicit parts of the sources //- Explicit parts of the sources
HashPtrTable<objectFunction1> fieldSu_; HashPtrTable<objectFunction1> fieldSu_;
@ -226,6 +223,9 @@ public:
//- Update for mesh changes //- Update for mesh changes
virtual void updateMesh(const mapPolyMesh&); virtual void updateMesh(const mapPolyMesh&);
//- Update for mesh motion
virtual bool movePoints();
// IO // IO