ENH: Refactored basicSource to become fv::option

This commit is contained in:
andy
2013-01-08 09:11:18 +00:00
parent 0813d3a5b6
commit 792fbf1af3
11 changed files with 207 additions and 202 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-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,21 +23,21 @@ License
\*---------------------------------------------------------------------------*/
#include "IObasicSourceList.H"
#include "fvIOoptionList.H"
#include "fvMesh.H"
#include "Time.H"
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
Foam::IOobject Foam::IObasicSourceList::createIOobject
Foam::IOobject Foam::fv::IOoptionList::createIOobject
(
const fvMesh& mesh
) const
{
IOobject io
(
"sourcesProperties",
mesh.time().constant(),
"fvOptions",
mesh.time().system(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
@ -62,21 +62,21 @@ Foam::IOobject Foam::IObasicSourceList::createIOobject
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::IObasicSourceList::IObasicSourceList
Foam::fv::IOoptionList::IOoptionList
(
const fvMesh& mesh
)
:
IOdictionary(createIOobject(mesh)),
basicSourceList(mesh, *this)
optionList(mesh, *this)
{}
bool Foam::IObasicSourceList::read()
bool Foam::fv::IOoptionList::read()
{
if (regIOobject::read())
{
basicSourceList::read(*this);
optionList::read(*this);
return true;
}
else
@ -87,4 +87,3 @@ bool Foam::IObasicSourceList::read()
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -22,20 +22,20 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::IObasicSourceList
Foam::fv::IOoptionList
Description
IObasicSourceList
IOoptionList
SourceFiles
IObasicSourceList.C
IOoptionList.C
\*---------------------------------------------------------------------------*/
#ifndef IObasicSourceList_H
#define IObasicSourceList_H
#ifndef IOoptionList_H
#define IOoptionList_H
#include "basicSourceList.H"
#include "fvOptionList.H"
#include "IOdictionary.H"
#include "autoPtr.H"
@ -43,15 +43,17 @@ SourceFiles
namespace Foam
{
namespace fv
{
/*---------------------------------------------------------------------------*\
Class IObasicSourceList Declaration
Class IOoptionList Declaration
\*---------------------------------------------------------------------------*/
class IObasicSourceList
class IOoptionList
:
public IOdictionary,
public basicSourceList
public optionList
{
private:
@ -61,10 +63,10 @@ private:
IOobject createIOobject(const fvMesh& mesh) const;
//- Disallow default bitwise copy construct
IObasicSourceList(const IObasicSourceList&);
IOoptionList(const IOoptionList&);
//- Disallow default bitwise assignment
void operator=(const IObasicSourceList&);
void operator=(const IOoptionList&);
public:
@ -72,11 +74,11 @@ public:
// Constructors
//- Construct from components with list of field names
IObasicSourceList(const fvMesh& mesh);
IOoptionList(const fvMesh& mesh);
//- Destructor
virtual ~IObasicSourceList()
virtual ~IOoptionList()
{}
@ -89,6 +91,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fv
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,7 +23,7 @@ License
\*---------------------------------------------------------------------------*/
#include "basicSource.H"
#include "fvOption.H"
#include "fvMesh.H"
#include "fvMatrices.H"
#include "volFields.H"
@ -33,12 +33,15 @@ License
namespace Foam
{
defineTypeNameAndDebug(basicSource, 0);
defineRunTimeSelectionTable(basicSource, dictionary);
namespace fv
{
defineTypeNameAndDebug(option, 0);
defineRunTimeSelectionTable(option, dictionary);
}
template<> const char* NamedEnum
<
basicSource::selectionModeType,
fv::option::selectionModeType,
5
>::names[] =
{
@ -49,20 +52,20 @@ namespace Foam
"all"
};
const NamedEnum<basicSource::selectionModeType, 5>
basicSource::selectionModeTypeNames_;
const NamedEnum<fv::option::selectionModeType, 5>
fv::option::selectionModeTypeNames_;
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
bool Foam::basicSource::alwaysApply() const
bool Foam::fv::option::alwaysApply() const
{
return false;
}
void Foam::basicSource::setSelection(const dictionary& dict)
void Foam::fv::option::setSelection(const dictionary& dict)
{
switch (selectionMode_)
{
@ -94,10 +97,8 @@ void Foam::basicSource::setSelection(const dictionary& dict)
}
default:
{
FatalErrorIn
(
"basicSource::setSelection(const dictionary&)"
) << "Unknown selectionMode "
FatalErrorIn("option::setSelection(const dictionary&)")
<< "Unknown selectionMode "
<< selectionModeTypeNames_[selectionMode_]
<< ". Valid selectionMode types are" << selectionModeTypeNames_
<< exit(FatalError);
@ -106,7 +107,7 @@ void Foam::basicSource::setSelection(const dictionary& dict)
}
void Foam::basicSource::setCellSet()
void Foam::fv::option::setCellSet()
{
switch (selectionMode_)
{
@ -127,7 +128,7 @@ void Foam::basicSource::setCellSet()
label globalCellI = returnReduce(cellI, maxOp<label>());
if (globalCellI < 0)
{
WarningIn("basicSource::setCellIds()")
WarningIn("option::setCellIds()")
<< "Unable to find owner cell for point " << points_[i]
<< endl;
@ -156,7 +157,7 @@ void Foam::basicSource::setCellSet()
label zoneID = mesh_.cellZones().findZoneID(cellSetName_);
if (zoneID == -1)
{
FatalErrorIn("basicSource::setCellIds()")
FatalErrorIn("option::setCellIds()")
<< "Cannot find cellZone " << cellSetName_ << endl
<< "Valid cellZones are " << mesh_.cellZones().names()
<< exit(FatalError);
@ -195,10 +196,8 @@ void Foam::basicSource::setCellSet()
}
else
{
FatalErrorIn
(
"Foam::basicSource::setCellSet()"
) << "regions dont overlap "
FatalErrorIn("option::setCellSet()")
<< "regions dont overlap "
<< secondaryMesh.name()
<< " in region " << mesh_.name()
<< nl
@ -216,7 +215,7 @@ void Foam::basicSource::setCellSet()
}
default:
{
FatalErrorIn("basicSource::setCellIds()")
FatalErrorIn("option::setCellIds()")
<< "Unknown selectionMode "
<< selectionModeTypeNames_[selectionMode_]
<< ". Valid selectionMode types are" << selectionModeTypeNames_
@ -243,7 +242,7 @@ void Foam::basicSource::setCellSet()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::basicSource::basicSource
Foam::fv::option::option
(
const word& name,
const word& modelType,
@ -282,7 +281,7 @@ Foam::basicSource::basicSource
}
else
{
Info<< indent<< "-applying source for all time" << endl;
Info<< indent<< "- applying source for all time" << endl;
}
setSelection(dict_);
@ -295,7 +294,7 @@ Foam::basicSource::basicSource
// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::basicSource> Foam::basicSource::New
Foam::autoPtr<Foam::fv::option> Foam::fv::option::New
(
const word& name,
const dictionary& coeffs,
@ -313,8 +312,7 @@ Foam::autoPtr<Foam::basicSource> Foam::basicSource::New
{
FatalErrorIn
(
"basicSource::New"
"(const name&, const dictionary&, const fvMesh&)"
"option::New(const name&, const dictionary&, const fvMesh&)"
) << "Unknown Model type " << modelType
<< nl << nl
<< "Valid model types are:" << nl
@ -322,11 +320,11 @@ Foam::autoPtr<Foam::basicSource> Foam::basicSource::New
<< exit(FatalError);
}
return autoPtr<basicSource>(cstrIter()(name, modelType, coeffs, mesh));
return autoPtr<option>(cstrIter()(name, modelType, coeffs, mesh));
}
Foam::basicSource::~basicSource()
Foam::fv::option::~option()
{
if (!secondaryToPrimaryInterpPtr_.empty())
{
@ -337,7 +335,7 @@ Foam::basicSource::~basicSource()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::basicSource::isActive()
bool Foam::fv::option::isActive()
{
if (active_ && inTimeLimits(mesh_.time().value()))
{
@ -355,7 +353,7 @@ bool Foam::basicSource::isActive()
}
Foam::label Foam::basicSource::applyToField(const word& fieldName) const
Foam::label Foam::fv::option::applyToField(const word& fieldName) const
{
if (alwaysApply())
{
@ -374,13 +372,13 @@ Foam::label Foam::basicSource::applyToField(const word& fieldName) const
}
void Foam::basicSource::checkApplied() const
void Foam::fv::option::checkApplied() const
{
forAll(applied_, i)
{
if (!applied_[i])
{
WarningIn("void Foam::basicSource::checkApplied() const")
WarningIn("void option::checkApplied() const")
<< "Source " << name_ << " defined for field "
<< fieldNames_[i] << " but never used" << endl;
}
@ -388,49 +386,49 @@ void Foam::basicSource::checkApplied() const
}
void Foam::basicSource::correct(volScalarField& fld)
void Foam::fv::option::correct(volScalarField& fld)
{
// do nothing
}
void Foam::basicSource::correct(volVectorField& fld)
void Foam::fv::option::correct(volVectorField& fld)
{
// do nothing
}
void Foam::basicSource::correct(volSphericalTensorField& fld)
void Foam::fv::option::correct(volSphericalTensorField& fld)
{
// do nothing
}
void Foam::basicSource::correct(volSymmTensorField& fld)
void Foam::fv::option::correct(volSymmTensorField& fld)
{
// do nothing
}
void Foam::basicSource::correct(volTensorField& fld)
void Foam::fv::option::correct(volTensorField& fld)
{
// do nothing
}
void Foam::basicSource::addSup(fvMatrix<scalar>& eqn, const label fieldI)
void Foam::fv::option::addSup(fvMatrix<scalar>& eqn, const label fieldI)
{
// do nothing
}
void Foam::basicSource::addSup(fvMatrix<vector>& eqn, const label fieldI)
void Foam::fv::option::addSup(fvMatrix<vector>& eqn, const label fieldI)
{
// do nothing
}
void Foam::basicSource::addSup
void Foam::fv::option::addSup
(
fvMatrix<sphericalTensor>& eqn,
const label fieldI
@ -440,31 +438,31 @@ void Foam::basicSource::addSup
}
void Foam::basicSource::addSup(fvMatrix<symmTensor>& eqn, const label fieldI)
void Foam::fv::option::addSup(fvMatrix<symmTensor>& eqn, const label fieldI)
{
// do nothing
}
void Foam::basicSource::addSup(fvMatrix<tensor>& eqn, const label fieldI)
void Foam::fv::option::addSup(fvMatrix<tensor>& eqn, const label fieldI)
{
// do nothing
}
void Foam::basicSource::setValue(fvMatrix<scalar>& eqn, const label fieldI)
void Foam::fv::option::setValue(fvMatrix<scalar>& eqn, const label fieldI)
{
// do nothing
}
void Foam::basicSource::setValue(fvMatrix<vector>& eqn, const label fieldI)
void Foam::fv::option::setValue(fvMatrix<vector>& eqn, const label fieldI)
{
// do nothing
}
void Foam::basicSource::setValue
void Foam::fv::option::setValue
(
fvMatrix<sphericalTensor>& eqn,
const label fieldI
@ -474,7 +472,7 @@ void Foam::basicSource::setValue
}
void Foam::basicSource::setValue
void Foam::fv::option::setValue
(
fvMatrix<symmTensor>& eqn,
const label fieldI
@ -484,19 +482,19 @@ void Foam::basicSource::setValue
}
void Foam::basicSource::setValue(fvMatrix<tensor>& eqn, const label fieldI)
void Foam::fv::option::setValue(fvMatrix<tensor>& eqn, const label fieldI)
{
// do nothing
}
void Foam::basicSource::relativeFlux(surfaceScalarField& phi) const
void Foam::fv::option::relativeFlux(surfaceScalarField& phi) const
{
// do nothing
}
void Foam::basicSource::relativeFlux
void Foam::fv::option::relativeFlux
(
const surfaceScalarField& rho,
surfaceScalarField& phi
@ -506,13 +504,13 @@ void Foam::basicSource::relativeFlux
}
void Foam::basicSource::absoluteFlux(surfaceScalarField& phi) const
void Foam::fv::option::absoluteFlux(surfaceScalarField& phi) const
{
// do nothing
}
void Foam::basicSource::absoluteFlux
void Foam::fv::option::absoluteFlux
(
const surfaceScalarField& rho,
surfaceScalarField& phi

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -22,10 +22,11 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::basicSource
Foam::fv::option
Description
Field source abtract base class. Provides a base set of controls, e.g.
Finite volume options abtract base class. Provides a base set of controls,
e.g.
type scalarExplicitSource // source type
active on; // on/off switch
@ -33,18 +34,17 @@ Description
duration 1000.0; // duration
selectionMode cellSet; // cellSet // points //cellZone
// mapRegion
Note:
On evaluation, source expects to be added to the rhs of the equation
SourceFiles
basicSource.C
basicSourceIO.C
fvOption.C
fvOptionIO.C
\*---------------------------------------------------------------------------*/
#ifndef basicSource_H
#define basicSource_H
#ifndef fvOption_H
#define fvOption_H
#include "fvMatricesFwd.H"
#include "volFieldsFwd.H"
@ -61,11 +61,14 @@ namespace Foam
class fvMesh;
namespace fv
{
/*---------------------------------------------------------------------------*\
Class basicSource Declaration
Class option Declaration
\*---------------------------------------------------------------------------*/
class basicSource
class option
{
public:
@ -163,7 +166,7 @@ protected:
public:
//- Runtime type information
TypeName("basicSource");
TypeName("option");
// Declare run-time constructor selection table
@ -171,7 +174,7 @@ public:
declareRunTimeSelectionTable
(
autoPtr,
basicSource,
option,
dictionary,
(
const word& name,
@ -186,7 +189,7 @@ public:
// Constructors
//- Construct from components
basicSource
option
(
const word& name,
const word& modelType,
@ -195,13 +198,13 @@ public:
);
//- Return clone
autoPtr<basicSource> clone() const
autoPtr<option> clone() const
{
notImplemented("autoPtr<basicSource> clone() const");
return autoPtr<basicSource>(NULL);
notImplemented("autoPtr<option> clone() const");
return autoPtr<option>(NULL);
}
//- Return pointer to new basicSource object created
//- Return pointer to new fvOption object created
// on the freestore from an Istream
class iNew
{
@ -221,19 +224,14 @@ public:
name_(name)
{}
autoPtr<basicSource> operator()(Istream& is) const
autoPtr<option> operator()(Istream& is) const
{
//const word name(is);
const dictionary dict(is);
return autoPtr<basicSource>
return autoPtr<option>
(
basicSource::New
(
name_,
dict,
mesh_
)
option::New(name_, dict, mesh_)
);
}
};
@ -241,8 +239,8 @@ public:
// Selectors
//- Return a reference to the selected basicSource model
static autoPtr<basicSource> New
//- Return a reference to the selected fvOption model
static autoPtr<option> New
(
const word& name,
const dictionary& dict,
@ -251,7 +249,7 @@ public:
//- Destructor
virtual ~basicSource();
virtual ~option();
@ -468,11 +466,12 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fv
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "basicSourceI.H"
#include "fvOptionI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,47 +23,47 @@ License
\*---------------------------------------------------------------------------*/
#include "basicSource.H"
#include "fvMesh.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::word& Foam::basicSource::name() const
inline const Foam::word& Foam::fv::option::name() const
{
return name_;
}
inline const Foam::fvMesh& Foam::basicSource::mesh() const
inline const Foam::fvMesh& Foam::fv::option::mesh() const
{
return mesh_;
}
inline const Foam::dictionary& Foam::basicSource::coeffs() const
inline const Foam::dictionary& Foam::fv::option::coeffs() const
{
return coeffs_;
}
inline bool Foam::basicSource::active() const
inline bool Foam::fv::option::active() const
{
return active_;
}
inline Foam::scalar Foam::basicSource::timeStart() const
inline Foam::scalar Foam::fv::option::timeStart() const
{
return timeStart_;
}
inline Foam::scalar Foam::basicSource::duration() const
inline Foam::scalar Foam::fv::option::duration() const
{
return duration_;
}
inline bool Foam::basicSource::inTimeLimits(const scalar time) const
inline bool Foam::fv::option::inTimeLimits(const scalar time) const
{
return
(
@ -77,68 +77,69 @@ inline bool Foam::basicSource::inTimeLimits(const scalar time) const
}
inline const Foam::basicSource::selectionModeType&
Foam::basicSource::selectionMode() const
inline const Foam::fv::option::selectionModeType&
Foam::fv::option::selectionMode() const
{
return selectionMode_;
}
inline const Foam::word& Foam::basicSource::cellSetName() const
inline const Foam::word& Foam::fv::option::cellSetName() const
{
return cellSetName_;
}
inline Foam::scalar Foam::basicSource::V() const
inline Foam::scalar Foam::fv::option::V() const
{
return V_;
}
inline const Foam::labelList& Foam::basicSource::cells() const
inline const Foam::labelList& Foam::fv::option::cells() const
{
return cells_;
}
inline void Foam::basicSource::setApplied(const label fieldI)
inline void Foam::fv::option::setApplied(const label fieldI)
{
applied_[fieldI] = true;
}
inline bool& Foam::basicSource::active()
inline bool& Foam::fv::option::active()
{
return active_;
}
inline Foam::scalar& Foam::basicSource::timeStart()
inline Foam::scalar& Foam::fv::option::timeStart()
{
return timeStart_;
}
inline Foam::scalar& Foam::basicSource::duration()
inline Foam::scalar& Foam::fv::option::duration()
{
return duration_;
}
inline const Foam::word Foam::basicSource::secondarySourceName() const
inline const Foam::word Foam::fv::option::secondarySourceName() const
{
return secondarySourceName_;
}
inline const Foam::autoPtr<Foam::meshToMesh> Foam::basicSource::
secondaryToPrimaryInterpPtr() const
inline const Foam::autoPtr<Foam::meshToMesh>
Foam::fv::option::secondaryToPrimaryInterpPtr() const
{
return secondaryToPrimaryInterpPtr_;
}
inline const Foam::word Foam::basicSource::mapRegionName() const
inline const Foam::word Foam::fv::option::mapRegionName() const
{
return mapRegionName_;
}

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-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,24 +23,24 @@ License
\*---------------------------------------------------------------------------*/
#include "basicSource.H"
#include "fvOption.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::basicSource::writeHeader(Ostream& os) const
void Foam::fv::option::writeHeader(Ostream& os) const
{
os << indent << name_ << nl
<< indent << token::BEGIN_BLOCK << incrIndent << nl;
}
void Foam::basicSource::writeFooter(Ostream& os) const
void Foam::fv::option::writeFooter(Ostream& os) const
{
os << decrIndent << indent << token::END_BLOCK << endl;
}
void Foam::basicSource::writeData(Ostream& os) const
void Foam::fv::option::writeData(Ostream& os) const
{
os.writeKeyword("active") << active_ << token::END_STATEMENT << nl;
os.writeKeyword("timeStart") << timeStart_ << token::END_STATEMENT << nl;
@ -78,7 +78,7 @@ void Foam::basicSource::writeData(Ostream& os) const
}
default:
{
FatalErrorIn("basicSource::writeData(Ostream&) const")
FatalErrorIn("option::writeData(Ostream&) const")
<< "Unknown selectionMode "
<< selectionMode_
<< abort(FatalError);
@ -87,7 +87,7 @@ void Foam::basicSource::writeData(Ostream& os) const
}
bool Foam::basicSource::read(const dictionary& dict)
bool Foam::fv::option::read(const dictionary& dict)
{
active_ = readBool(dict.lookup("active"));
timeStart_ = readScalar(dict.lookup("timeStart"));

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,7 +23,7 @@ License
\*---------------------------------------------------------------------------*/
#include "basicSourceList.H"
#include "fvOptionList.H"
#include "addToRunTimeSelectionTable.H"
#include "fvMesh.H"
#include "Time.H"
@ -32,19 +32,22 @@ License
namespace Foam
{
defineTypeNameAndDebug(basicSourceList, 0);
namespace fv
{
defineTypeNameAndDebug(optionList, 0);
}
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::basicSourceList::checkApplied() const
void Foam::fv::optionList::checkApplied() const
{
if (mesh_.time().timeIndex() == checkTimeIndex_)
{
forAll(*this, i)
{
const basicSource& bs = this->operator[](i);
const option& bs = this->operator[](i);
bs.checkApplied();
}
}
@ -53,13 +56,9 @@ void Foam::basicSourceList::checkApplied() const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::basicSourceList::basicSourceList
(
const fvMesh& mesh,
const dictionary& dict
)
Foam::fv::optionList::optionList(const fvMesh& mesh, const dictionary& dict)
:
PtrList<basicSource>(),
PtrList<option>(),
mesh_(mesh),
checkTimeIndex_(mesh_.time().startTimeIndex() + 2)
{
@ -67,9 +66,9 @@ Foam::basicSourceList::basicSourceList
}
Foam::basicSourceList::basicSourceList(const fvMesh& mesh)
Foam::fv::optionList::optionList(const fvMesh& mesh)
:
PtrList<basicSource>(),
PtrList<option>(),
mesh_(mesh),
checkTimeIndex_(mesh_.time().startTimeIndex() + 2)
{}
@ -77,7 +76,7 @@ Foam::basicSourceList::basicSourceList(const fvMesh& mesh)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::basicSourceList::reset(const dictionary& dict)
void Foam::fv::optionList::reset(const dictionary& dict)
{
label count = 0;
forAllConstIter(dictionary, dict, iter)
@ -101,14 +100,14 @@ void Foam::basicSourceList::reset(const dictionary& dict)
this->set
(
i++,
basicSource::New(name, sourceDict, mesh_)
option::New(name, sourceDict, mesh_)
);
}
}
}
void Foam::basicSourceList::relativeFlux(surfaceScalarField& phi) const
void Foam::fv::optionList::relativeFlux(surfaceScalarField& phi) const
{
forAll(*this, i)
{
@ -117,7 +116,7 @@ void Foam::basicSourceList::relativeFlux(surfaceScalarField& phi) const
}
void Foam::basicSourceList::relativeFlux
void Foam::fv::optionList::relativeFlux
(
const surfaceScalarField& rho,
surfaceScalarField& phi
@ -130,7 +129,7 @@ void Foam::basicSourceList::relativeFlux
}
void Foam::basicSourceList::absoluteFlux(surfaceScalarField& phi) const
void Foam::fv::optionList::absoluteFlux(surfaceScalarField& phi) const
{
forAll(*this, i)
{
@ -139,7 +138,7 @@ void Foam::basicSourceList::absoluteFlux(surfaceScalarField& phi) const
}
void Foam::basicSourceList::absoluteFlux
void Foam::fv::optionList::absoluteFlux
(
const surfaceScalarField& rho,
surfaceScalarField& phi
@ -152,14 +151,14 @@ void Foam::basicSourceList::absoluteFlux
}
bool Foam::basicSourceList::read(const dictionary& dict)
bool Foam::fv::optionList::read(const dictionary& dict)
{
checkTimeIndex_ = mesh_.time().timeIndex() + 2;
bool allOk = true;
forAll(*this, i)
{
basicSource& bs = this->operator[](i);
option& bs = this->operator[](i);
bool ok = bs.read(dict.subDict(bs.name()));
allOk = (allOk && ok);
}
@ -167,7 +166,7 @@ bool Foam::basicSourceList::read(const dictionary& dict)
}
bool Foam::basicSourceList::writeData(Ostream& os) const
bool Foam::fv::optionList::writeData(Ostream& os) const
{
// Write list contents
forAll(*this, i)
@ -183,14 +182,17 @@ bool Foam::basicSourceList::writeData(Ostream& os) const
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const basicSourceList& sources
)
namespace Foam
{
sources.writeData(os);
return os;
Ostream& operator<<
(
Ostream& os,
const fv::optionList& options
)
{
options.writeData(os);
return os;
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -22,36 +22,38 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::basicSourceList
Foam::fv::optionList
Description
List of explict sources
List of finite volume options
SourceFile
basicSourceList.C
optionList.C
\*---------------------------------------------------------------------------*/
#ifndef basicSourceList_H
#define basicSourceList_H
#ifndef optionList_H
#define optionList_H
#include "PtrList.H"
#include "GeometricField.H"
#include "fvPatchField.H"
#include "basicSource.H"
#include "fvOption.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace fv
{
/*---------------------------------------------------------------------------*\
Class basicSourceList Declaration
Class optionList Declaration
\*---------------------------------------------------------------------------*/
class basicSourceList
class optionList
:
public PtrList<basicSource>
public PtrList<option>
{
protected:
@ -70,29 +72,29 @@ protected:
void checkApplied() const;
//- Disallow default bitwise copy construct
basicSourceList(const basicSourceList&);
optionList(const optionList&);
//- Disallow default bitwise assignment
void operator=(const basicSourceList&);
void operator=(const optionList&);
public:
//- Runtime type information
TypeName("basicSourceList");
TypeName("optionList");
// Constructors
//- Construct null
basicSourceList(const fvMesh& mesh);
optionList(const fvMesh& mesh);
//- Construct from mesh and dictionary
basicSourceList(const fvMesh& mesh, const dictionary& dict);
optionList(const fvMesh& mesh, const dictionary& dict);
//- Destructor
virtual ~basicSourceList()
virtual ~optionList()
{}
@ -187,18 +189,19 @@ public:
friend Ostream& operator<<
(
Ostream& os,
const basicSourceList& sources
const optionList& options
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fv
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "basicSourceListTemplates.C"
#include "fvOptionListTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -26,7 +26,7 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::basicSourceList::correct
void Foam::fv::optionList::correct
(
GeometricField<Type, fvPatchField, volMesh>& fld
)
@ -35,7 +35,7 @@ void Foam::basicSourceList::correct
forAll(*this, i)
{
basicSource& source = this->operator[](i);
option& source = this->operator[](i);
label fieldI = source.applyToField(fieldName);
@ -59,7 +59,7 @@ void Foam::basicSourceList::correct
template<class Type>
Foam::tmp<Foam::fvMatrix<Type> > Foam::basicSourceList::operator()
Foam::tmp<Foam::fvMatrix<Type> > Foam::fv::optionList::operator()
(
GeometricField<Type, fvPatchField, volMesh>& fld
)
@ -69,7 +69,7 @@ Foam::tmp<Foam::fvMatrix<Type> > Foam::basicSourceList::operator()
template<class Type>
Foam::tmp<Foam::fvMatrix<Type> > Foam::basicSourceList::operator()
Foam::tmp<Foam::fvMatrix<Type> > Foam::fv::optionList::operator()
(
GeometricField<Type, fvPatchField, volMesh>& fld,
const word& fieldName
@ -86,7 +86,7 @@ Foam::tmp<Foam::fvMatrix<Type> > Foam::basicSourceList::operator()
forAll(*this, i)
{
basicSource& source = this->operator[](i);
option& source = this->operator[](i);
label fieldI = source.applyToField(fieldName);
@ -112,7 +112,7 @@ Foam::tmp<Foam::fvMatrix<Type> > Foam::basicSourceList::operator()
template<class Type, class RhoType>
Foam::tmp<Foam::fvMatrix<Type> > Foam::basicSourceList::operator()
Foam::tmp<Foam::fvMatrix<Type> > Foam::fv::optionList::operator()
(
const RhoType& rho,
GeometricField<Type, fvPatchField, volMesh>& fld
@ -123,7 +123,7 @@ Foam::tmp<Foam::fvMatrix<Type> > Foam::basicSourceList::operator()
template<class Type, class RhoType>
Foam::tmp<Foam::fvMatrix<Type> > Foam::basicSourceList::operator()
Foam::tmp<Foam::fvMatrix<Type> > Foam::fv::optionList::operator()
(
const RhoType& rho,
GeometricField<Type, fvPatchField, volMesh>& fld,
@ -141,7 +141,7 @@ Foam::tmp<Foam::fvMatrix<Type> > Foam::basicSourceList::operator()
forAll(*this, i)
{
basicSource& source = this->operator[](i);
option& source = this->operator[](i);
label fieldI = source.applyToField(fieldName);
@ -167,14 +167,14 @@ Foam::tmp<Foam::fvMatrix<Type> > Foam::basicSourceList::operator()
template<class Type>
void Foam::basicSourceList::constrain(fvMatrix<Type>& eqn)
void Foam::fv::optionList::constrain(fvMatrix<Type>& eqn)
{
constrain(eqn, eqn.psi().name());
}
template<class Type>
void Foam::basicSourceList::constrain
void Foam::fv::optionList::constrain
(
fvMatrix<Type>& eqn,
const word& fieldName
@ -184,7 +184,7 @@ void Foam::basicSourceList::constrain
forAll(*this, i)
{
basicSource& source = this->operator[](i);
option& source = this->operator[](i);
label fieldI = source.applyToField(fieldName);

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-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,25 +23,25 @@ License
\*---------------------------------------------------------------------------*/
#ifndef makeBasicSource_H
#define makeBasicSource_H
#ifndef makeFvOption_H
#define makeFvOption_H
#include "basicSource.H"
#include "fvOption.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#define makeBasicSource(Source, Type) \
#define makeFvOption(Option, Type) \
\
defineTemplateTypeNameAndDebugWithName \
( \
Source<Type>, \
#Type#Source, \
Option<Type>, \
#Type#Option, \
0 \
); \
\
basicSource::adddictionaryConstructorToTable<Source<Type> > \
add##Source##Type##dictionary##ConstructorTobasicSourceTable_
option::adddictionaryConstructorToTable<Option<Type> > \
add##Option##Type##dictionary##ConstructorTooptionTable_
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //