From be09967acf0ac1343e5b35fd5fa46e1acfb2f58d Mon Sep 17 00:00:00 2001 From: sergio <s.ferraris@opencfd.co.uk> Date: Tue, 13 Jul 2021 12:14:13 +0100 Subject: [PATCH] ENH: regionFaModel: various updates --- .../regionFaModel/regionFaModel.C | 60 ++++++++++++++----- .../regionFaModel/regionFaModel.H | 39 ++++++++---- .../regionFaModel/regionFaModelI.H | 28 ++++++++- 3 files changed, 99 insertions(+), 28 deletions(-) diff --git a/src/regionFaModels/regionFaModel/regionFaModel.C b/src/regionFaModels/regionFaModel/regionFaModel.C index 9a7078e036c..27bd759b637 100644 --- a/src/regionFaModels/regionFaModel/regionFaModel.C +++ b/src/regionFaModels/regionFaModel/regionFaModel.C @@ -41,6 +41,9 @@ namespace regionModels } } +const Foam::word +Foam::regionModels::regionFaModel::regionFaModelName("regionFaModel"); + // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // void Foam::regionModels::regionFaModel::constructMeshObjects() @@ -60,12 +63,31 @@ void Foam::regionModels::regionFaModel::initialise() } vsmPtr_.reset(new volSurfaceMapping(regionMeshPtr_())); -} + if (!outputPropertiesPtr_) + { + const fileName uniformPath(word("uniform")/regionFaModelName); + + outputPropertiesPtr_.reset + ( + new IOdictionary + ( + IOobject + ( + regionName_ + "OutputProperties", + time_.timeName(), + uniformPath/regionName_, + primaryMesh_, + IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE + ) + ) + ); + } +} -// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -bool Foam::regionModels::regionFaModel::read(const dictionary& dict) +bool Foam::regionModels::regionFaModel::init(const dictionary& dict) { if (active_) { @@ -102,6 +124,17 @@ Foam::regionModels::regionFaModel::regionFaModel bool readFields ) : + IOdictionary + ( + IOobject + ( + IOobject::groupName(regionFaModelName, patch.name()), + patch.boundaryMesh().mesh().time().constant(), + patch.boundaryMesh().mesh().time(), + IOobject::NO_READ, + IOobject::NO_WRITE + ) + ), primaryMesh_(patch.boundaryMesh().mesh()), patch_(patch), time_(patch.boundaryMesh().mesh().time()), @@ -110,19 +143,17 @@ Foam::regionModels::regionFaModel::regionFaModel modelName_(modelName), regionMeshPtr_(nullptr), coeffs_(dict.subOrEmptyDict(modelName + "Coeffs")), + outputPropertiesPtr_(nullptr), vsmPtr_(nullptr), patchID_(patch.index()), regionName_(dict.lookup("region")) { - if (active_) - { - constructMeshObjects(); - initialise(); + constructMeshObjects(); + initialise(); - if (readFields) - { - read(dict); - } + if (readFields) + { + init(dict); } } @@ -165,8 +196,9 @@ void Foam::regionModels::regionFaModel::postEvolveRegion() {} -void Foam::regionModels::regionFaModel::info() -{} - +Foam::scalar Foam::regionModels::regionFaModel::CourantNumber() const +{ + return 0; +} // ************************************************************************* // diff --git a/src/regionFaModels/regionFaModel/regionFaModel.H b/src/regionFaModels/regionFaModel/regionFaModel.H index 48cb985339b..bc2246c111e 100644 --- a/src/regionFaModels/regionFaModel/regionFaModel.H +++ b/src/regionFaModels/regionFaModel/regionFaModel.H @@ -88,6 +88,8 @@ namespace regionModels \*---------------------------------------------------------------------------*/ class regionFaModel +: + public IOdictionary { // Private Member Functions @@ -97,6 +99,9 @@ class regionFaModel //- Initialise the region void initialise(); + //- Read control parameters from dictionary + bool init(const dictionary& dict); + protected: @@ -126,6 +131,9 @@ protected: //- Model coefficients dictionary dictionary coeffs_; + //- Dictionary of output properties + autoPtr<IOdictionary> outputPropertiesPtr_; + //-Volume-to surface mapping autoPtr<volSurfaceMapping> vsmPtr_; @@ -140,18 +148,15 @@ protected: word regionName_; - // Protected Member Functions - - //- Read control parameters from dictionary - virtual bool read(const dictionary& dict); - - public: //- Runtime type information TypeName("regionFaModel"); + //- Default name regionFaModel + static const word regionFaModelName; + // Constructors //- Construct from mesh and name and dict @@ -203,18 +208,23 @@ public: //- Return the model coefficients dictionary inline const dictionary& coeffs() const; + //- Return const access to the output properties dictionary + inline const IOdictionary& outputProperties() const; + + //- Return output properties dictionary + inline IOdictionary& outputProperties(); + //- Return the solution dictionary inline const dictionary& solution() const; - //- Return volSurfaceMapping - const volSurfaceMapping& vsm() const; + //- Return patch ID + inline label patchID() const; - // Addressing + // Help Functions - //- Return the list of patch IDs on the primary region coupled - //- to this region - inline label patchID(); + //- Return mapping between surface and volume fields + const volSurfaceMapping& vsm() const; // Evolution @@ -231,11 +241,14 @@ public: //- Post-evolve region virtual void postEvolveRegion(); + //- Courant number of the region + virtual scalar CourantNumber() const; + // IO //- Provide some feedback - virtual void info(); + virtual void info() = 0; }; diff --git a/src/regionFaModels/regionFaModel/regionFaModelI.H b/src/regionFaModels/regionFaModel/regionFaModelI.H index 35fe64d4997..7f45fa6ec47 100644 --- a/src/regionFaModels/regionFaModel/regionFaModelI.H +++ b/src/regionFaModels/regionFaModel/regionFaModelI.H @@ -101,6 +101,32 @@ inline const Foam::dictionary& Foam::regionModels::regionFaModel::coeffs() const return coeffs_; } +inline const Foam::IOdictionary& +Foam::regionModels::regionFaModel::outputProperties() const +{ + if (!outputPropertiesPtr_) + { + FatalErrorInFunction + << "outputProperties dictionary not available" + << abort(FatalError); + } + return *outputPropertiesPtr_; +} + + +inline Foam::IOdictionary& +Foam::regionModels::regionFaModel::outputProperties() +{ + if (!outputPropertiesPtr_) + { + FatalErrorInFunction + << "outputProperties dictionary not available" + << abort(FatalError); + } + + return *outputPropertiesPtr_; +} + inline const Foam::dictionary& Foam::regionModels::regionFaModel::solution() const @@ -109,7 +135,7 @@ Foam::regionModels::regionFaModel::solution() const } -inline Foam::label Foam::regionModels::regionFaModel::patchID() +inline Foam::label Foam::regionModels::regionFaModel::patchID() const { return patchID_; } -- GitLab