Commit 792fbf1a authored by andy's avatar andy
Browse files

ENH: Refactored basicSource to become fv::option

parent 0813d3a5
......@@ -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()
// ************************************************************************* //
......@@ -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
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -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
......
......@@ -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
(