ENH: Re-worked I/O for particle forces

This commit is contained in:
andy
2011-03-23 18:18:03 +00:00
parent 11556949d1
commit 5df29dffd0
21 changed files with 86 additions and 102 deletions

View File

@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "ParticleForceList.H"
#include "entry.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -57,26 +58,46 @@ Foam::ParticleForceList<CloudType>::ParticleForceList
{
if (readFields)
{
const wordList activeForces(dict.lookup("activeForces"));
wordHashSet models;
models.insert(activeForces);
wordList modelNames(dict.toc());
Info<< "Constructing particle forces" << endl;
if (models.size() > 0)
if (modelNames.size() > 0)
{
this->setSize(models.size());
this->setSize(modelNames.size());
label i = 0;
forAllConstIter(wordHashSet, models, iter)
forAllConstIter(IDLList<entry>, dict, iter)
{
const word& model = iter.key();
this->set
(
i,
ParticleForce<CloudType>::New(owner, mesh, dict, model)
);
i++;
const word& model = iter().keyword();
if (iter().isDict())
{
this->set
(
i++,
ParticleForce<CloudType>::New
(
owner,
mesh,
iter().dict(),
model
)
);
}
else
{
this->set
(
i++,
ParticleForce<CloudType>::New
(
owner,
mesh,
dict,
model
)
);
}
}
}
else

View File

@ -41,11 +41,10 @@ Foam::NonSphereDragForce<CloudType>::NonSphereDragForce
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
)
:
ParticleForce<CloudType>(owner, mesh, dict, forceType),
ParticleForce<CloudType>(owner, mesh, dict, typeName, true),
phi_(readScalar(this->coeffs().lookup("phi"))),
a_(exp(2.3288 - 6.4581*phi_ + 2.4486*sqr(phi_))),
b_(0.0964 + 0.5565*phi_),

View File

@ -114,8 +114,7 @@ public:
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
);
//- Construct copy

View File

@ -48,11 +48,10 @@ Foam::SphereDragForce<CloudType>::SphereDragForce
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
)
:
ParticleForce<CloudType>(owner, mesh, dict)
ParticleForce<CloudType>(owner, mesh, dict, typeName, false)
{}

View File

@ -66,8 +66,7 @@ public:
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
);
//- Construct copy

View File

@ -32,11 +32,10 @@ Foam::GravityForce<CloudType>::GravityForce
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
)
:
ParticleForce<CloudType>(owner, mesh, dict),
ParticleForce<CloudType>(owner, mesh, dict, typeName, false),
g_(owner.g().value())
{}

View File

@ -73,8 +73,7 @@ public:
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
);
//- Construct copy

View File

@ -33,11 +33,10 @@ Foam::NonInertialFrameForce<CloudType>::NonInertialFrameForce
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
)
:
ParticleForce<CloudType>(owner, mesh, dict),
ParticleForce<CloudType>(owner, mesh, dict, typeName, true),
WName_
(
this->coeffs().template lookupOrDefault<word>

View File

@ -94,8 +94,7 @@ public:
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
);
//- Construct copy

View File

@ -34,11 +34,10 @@ Foam::ParamagneticForce<CloudType>::ParamagneticForce
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
)
:
ParticleForce<CloudType>(owner, mesh, dict, forceType),
ParticleForce<CloudType>(owner, mesh, dict, typeName, true),
HdotGradHName_
(
this->coeffs().template lookupOrDefault<word>("HdotGradH", "HdotGradH")

View File

@ -80,8 +80,7 @@ public:
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
);
//- Construct copy

View File

@ -27,20 +27,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class CloudType>
Foam::ParticleForce<CloudType>::ParticleForce
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict
)
:
owner_(owner),
mesh_(mesh),
dict_(dict),
coeffs_(dictionary::null)
{}
template<class CloudType>
Foam::ParticleForce<CloudType>::ParticleForce
@ -48,14 +34,31 @@ Foam::ParticleForce<CloudType>::ParticleForce
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const word& forceType,
const bool readCoeffs
)
:
owner_(owner),
mesh_(mesh),
dict_(dict),
coeffs_(dict.subOrEmptyDict(forceType + "Coeffs"))
{}
coeffs_(readCoeffs ? dict : dictionary::null)
{
if (readCoeffs && (coeffs_.dictName() != forceType))
{
FatalIOErrorIn
(
"Foam::ParticleForce<CloudType>::ParticleForce"
"("
"CloudType&, "
"const fvMesh&, "
"const dictionary&, "
"const word&, "
"const bool"
")",
dict
) << "Force " << forceType << " must be specified as a dictionary"
<< exit(FatalIOError);
}
}
template<class CloudType>
@ -63,7 +66,6 @@ Foam::ParticleForce<CloudType>::ParticleForce(const ParticleForce& pf)
:
owner_(pf.owner_),
mesh_(pf.mesh_),
dict_(pf.dict_),
coeffs_(pf.coeffs_)
{}

View File

@ -61,9 +61,6 @@ class ParticleForce
//- Reference to the mesh database
const fvMesh& mesh_;
//- Forces dictionary
const dictionary dict_;
//- Force coefficients dictaionary
const dictionary coeffs_;
@ -82,10 +79,9 @@ public:
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
),
(owner, mesh, dict, forceType)
(owner, mesh, dict)
);
@ -95,21 +91,14 @@ public:
// Constructors
//- Construct null
ParticleForce
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict
);
//- Construct from mesh
ParticleForce
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const word& forceType,
const bool readCoeffs
);
//- Construct copy
@ -152,9 +141,6 @@ public:
//- Return the mesh database
inline const fvMesh& mesh() const;
//- Return the forces dictionary
inline const dictionary& dict() const;
//- Return the force coefficients dictionary
inline const dictionary& coeffs() const;

View File

@ -46,13 +46,6 @@ inline const Foam::fvMesh& Foam::ParticleForce<CloudType>::mesh() const
}
template<class CloudType>
inline const Foam::dictionary& Foam::ParticleForce<CloudType>::dict() const
{
return dict_;
}
template<class CloudType>
inline const Foam::dictionary& Foam::ParticleForce<CloudType>::coeffs() const
{

View File

@ -50,8 +50,7 @@ Foam::ParticleForce<CloudType>::New
"("
"CloudType&, "
"const fvMesh&, "
"const dictionary&, "
"const word&"
"const dictionary&"
")"
) << "Unknown particle force type "
<< forceType
@ -67,8 +66,7 @@ Foam::ParticleForce<CloudType>::New
(
owner,
mesh,
dict,
forceType
dict
)
);

View File

@ -33,11 +33,10 @@ Foam::PressureGradientForce<CloudType>::PressureGradientForce
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
)
:
ParticleForce<CloudType>(owner, mesh, dict, forceType),
ParticleForce<CloudType>(owner, mesh, dict, typeName, true),
UName_(this->coeffs().lookup("U")),
gradUPtr_(NULL)
{}

View File

@ -75,8 +75,7 @@ public:
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
);
//- Construct copy

View File

@ -32,11 +32,10 @@ Foam::SRFForce<CloudType>::SRFForce
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
)
:
ParticleForce<CloudType>(owner, mesh, dict),
ParticleForce<CloudType>(owner, mesh, dict, typeName, false),
srfPtr_(NULL)
{}

View File

@ -73,8 +73,7 @@ public:
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
);
//- Construct copy

View File

@ -57,11 +57,10 @@ Foam::BrownianMotionForce<CloudType>::BrownianMotionForce
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
)
:
ParticleForce<CloudType>(owner, mesh, dict, forceType),
ParticleForce<CloudType>(owner, mesh, dict, typeName, true),
rndGen_(owner.rndGen()),
lambda_(readScalar(this->coeffs().lookup("lambda"))),
turbulence_(readBool(this->coeffs().lookup("turbulence"))),

View File

@ -94,8 +94,7 @@ public:
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
);
//- Construct copy