ENH: lagrangian/intermediate extended base sub-model functionality

This commit is contained in:
andy
2012-05-31 14:03:38 +01:00
parent 93a3083daa
commit b851d15651
2 changed files with 138 additions and 23 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -25,6 +25,15 @@ License
#include "SubModelBase.H"
// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
template<class CloudType>
bool Foam::SubModelBase<CloudType>::SubModelBase::inLine() const
{
return (modelName_ != word::null);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class CloudType>
@ -32,8 +41,9 @@ Foam::SubModelBase<CloudType>::SubModelBase(CloudType& owner)
:
owner_(owner),
dict_(dictionary::null),
baseName_("none"),
name_("none"),
baseName_(word::null),
modelType_(word::null),
modelName_(word::null),
coeffDict_(dictionary::null)
{}
@ -44,15 +54,35 @@ Foam::SubModelBase<CloudType>::SubModelBase
CloudType& owner,
const dictionary& dict,
const word& baseName,
const word& name,
const word& modelType,
const word& dictExt
)
:
owner_(owner),
dict_(dict),
baseName_(baseName),
name_(name),
coeffDict_(dict.subDict(name + dictExt))
modelType_(modelType),
modelName_(word::null),
coeffDict_(dict.subDict(modelType + dictExt))
{}
template<class CloudType>
Foam::SubModelBase<CloudType>::SubModelBase
(
const word& modelName,
CloudType& owner,
const dictionary& dict,
const word& baseName,
const word& modelType
)
:
owner_(owner),
dict_(dict),
baseName_(baseName),
modelType_(modelType),
modelName_(modelName),
coeffDict_(dict)
{}
@ -62,7 +92,8 @@ Foam::SubModelBase<CloudType>::SubModelBase(const SubModelBase<CloudType>& smb)
owner_(smb.owner_),
dict_(smb.dict_),
baseName_(smb.baseName_),
name_(smb.name_),
modelType_(smb.modelType_),
modelName_(smb.modelName_),
coeffDict_(smb.coeffDict_)
{}
@ -90,6 +121,13 @@ const Foam::dictionary& Foam::SubModelBase<CloudType>::dict() const
}
template<class CloudType>
const Foam::word& Foam::SubModelBase<CloudType>::modelType() const
{
return modelType_;
}
template<class CloudType>
const Foam::word& Foam::SubModelBase<CloudType>::baseName() const
{
@ -98,9 +136,9 @@ const Foam::word& Foam::SubModelBase<CloudType>::baseName() const
template<class CloudType>
const Foam::word& Foam::SubModelBase<CloudType>::name() const
const Foam::word& Foam::SubModelBase<CloudType>::modelName() const
{
return name_;
return modelName_;
}
@ -147,6 +185,16 @@ void Foam::SubModelBase<CloudType>::cacheFields(const bool)
}
template<class CloudType>
bool Foam::SubModelBase<CloudType>::outputTime() const
{
return
active()
&& owner_.solution().transient()
&& owner_.db().time().outputTime();
}
template<class CloudType>
template<class Type>
Type Foam::SubModelBase<CloudType>::getBaseProperty
@ -206,9 +254,13 @@ Type Foam::SubModelBase<CloudType>::getModelProperty
{
const dictionary& baseDict = properties.subDict(baseName_);
if (baseDict.found(name_))
if (inLine() && baseDict.found(modelName_))
{
baseDict.subDict(name_).readIfPresent(entryName, result);
baseDict.subDict(modelName_).readIfPresent(entryName, result);
}
else if (baseDict.found(modelType_))
{
baseDict.subDict(modelType_).readIfPresent(entryName, result);
}
}
@ -230,9 +282,13 @@ void Foam::SubModelBase<CloudType>::getModelProperty
{
const dictionary& baseDict = properties.subDict(baseName_);
if (baseDict.found(name_))
if (inLine() && baseDict.found(modelName_))
{
baseDict.subDict(name_).readIfPresent(entryName, value);
baseDict.subDict(modelName_).readIfPresent(entryName, value);
}
else if (baseDict.found(modelType_))
{
baseDict.subDict(modelType_).readIfPresent(entryName, value);
}
}
}
@ -251,21 +307,54 @@ void Foam::SubModelBase<CloudType>::setModelProperty
if (properties.found(baseName_))
{
dictionary& baseDict = properties.subDict(baseName_);
if (baseDict.found(name_))
if (inLine())
{
baseDict.subDict(name_).add(entryName, value, true);
if (baseDict.found(modelName_))
{
baseDict.subDict(modelName_).add(entryName, value, true);
}
else
{
baseDict.add(modelName_, dictionary());
baseDict.subDict(modelName_).add(entryName, value, true);
}
}
else
{
baseDict.add(name_, dictionary());
baseDict.subDict(name_).add(entryName, value, true);
if (baseDict.found(modelType_))
{
baseDict.subDict(modelType_).add(entryName, value, true);
}
else
{
baseDict.add(modelType_, dictionary());
baseDict.subDict(modelType_).add(entryName, value, true);
}
}
}
else
{
properties.add(baseName_, dictionary());
properties.subDict(baseName_).add(name_, dictionary());
properties.subDict(baseName_).subDict(name_).add(entryName, value);
if (inLine())
{
properties.subDict(baseName_).add(modelName_, dictionary());
properties.subDict(baseName_).subDict(modelName_).add
(
entryName,
value
);
}
else
{
properties.subDict(baseName_).add(modelType_, dictionary());
properties.subDict(baseName_).subDict(modelType_).add
(
entryName,
value
);
}
}
}
@ -273,7 +362,8 @@ void Foam::SubModelBase<CloudType>::setModelProperty
template<class CloudType>
void Foam::SubModelBase<CloudType>::write(Ostream& os) const
{
os.writeKeyword("owner") << owner_.name() << token::END_STATEMENT << nl;
os.writeKeyword("owner") << owner_.name() << token::END_STATEMENT
<< nl;
// not writing complete cloud dictionary, only coeffs
// os << dict_;

View File

@ -66,13 +66,22 @@ protected:
//- Name of the sub-model base class
const word baseName_;
//- Type of the sub-model
const word modelType_;
//- Name of the sub-model
const word name_;
const word modelName_;
//- Coefficients dictionary
const dictionary& coeffDict_;
// Protected Member Functions
//- Flag to indicate whether data is/was read in-line
bool inLine() const;
public:
// Constructors
@ -86,10 +95,20 @@ public:
CloudType& owner,
const dictionary& dict,
const word& baseName,
const word& name,
const word& modelType,
const word& dictExt = "Coeffs"
);
//- Construct from owner cloud, dictionary, and model type name
SubModelBase
(
const word& modelName,
CloudType& owner,
const dictionary& dict,
const word& baseName,
const word& modelType
);
//- Construct as copy
SubModelBase(const SubModelBase<CloudType>& smb);
@ -111,11 +130,14 @@ public:
//- Return const access to the cloud dictionary
const dictionary& dict() const;
//- Return const access to the sub-model type
const word& modelType() const;
//- Return const access to the base name of the sub-model
const word& baseName() const;
//- Return const access to the name of the sub-model
const word& name() const;
const word& modelName() const;
//- Return const access to the coefficients dictionary
const dictionary& coeffDict() const;
@ -132,6 +154,9 @@ public:
//- Cache dependant sub-model fields
virtual void cacheFields(const bool store);
//- Flag to indicate when to write a property
bool outputTime() const;
// Edit