Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
792fbf1a
Commit
792fbf1a
authored
Jan 08, 2013
by
andy
Browse files
ENH: Refactored basicSource to become fv::option
parent
0813d3a5
Changes
11
Hide whitespace changes
Inline
Side-by-side
src/fieldSources/
basicSource/IObasicSource
List.C
→
src/fieldSources/
fvOptions/fvIOoption
List.C
View file @
792fbf1a
...
...
@@ -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 "
IObasicSource
List.H"
#include "
fvIOoption
List.H"
#include "fvMesh.H"
#include "Time.H"
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
Foam
::
IOobject
Foam
::
IObasicSource
List
::
createIOobject
Foam
::
IOobject
Foam
::
fv
::
IOoption
List
::
createIOobject
(
const
fvMesh
&
mesh
)
const
{
IOobject
io
(
"
sourcesPropertie
s"
,
mesh
.
time
().
constant
(),
"
fvOption
s"
,
mesh
.
time
().
system
(),
mesh
,
IOobject
::
MUST_READ
,
IOobject
::
NO_WRITE
...
...
@@ -62,21 +62,21 @@ Foam::IOobject Foam::IObasicSourceList::createIOobject
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam
::
IObasicSourceList
::
IObasicSource
List
Foam
::
fv
::
IOoptionList
::
IOoption
List
(
const
fvMesh
&
mesh
)
:
IOdictionary
(
createIOobject
(
mesh
)),
basicSource
List
(
mesh
,
*
this
)
option
List
(
mesh
,
*
this
)
{}
bool
Foam
::
IObasicSource
List
::
read
()
bool
Foam
::
fv
::
IOoption
List
::
read
()
{
if
(
regIOobject
::
read
())
{
basicSource
List
::
read
(
*
this
);
option
List
::
read
(
*
this
);
return
true
;
}
else
...
...
@@ -87,4 +87,3 @@ bool Foam::IObasicSourceList::read()
// ************************************************************************* //
src/fieldSources/
basicSource/IObasicSource
List.H
→
src/fieldSources/
fvOptions/fvIOoption
List.H
View file @
792fbf1a
...
...
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-201
2
OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-201
3
OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
...
...
@@ -22,20 +22,20 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::
IObasicSource
List
Foam::
fv::IOoption
List
Description
IO
basicSource
List
IO
option
List
SourceFiles
IO
basicSource
List.C
IO
option
List.C
\*---------------------------------------------------------------------------*/
#ifndef IO
basicSource
List_H
#define IO
basicSource
List_H
#ifndef IO
option
List_H
#define IO
option
List_H
#include "
basicSource
List.H"
#include "
fvOption
List.H"
#include "IOdictionary.H"
#include "autoPtr.H"
...
...
@@ -43,15 +43,17 @@ SourceFiles
namespace
Foam
{
namespace
fv
{
/*---------------------------------------------------------------------------*\
Class IO
basicSource
List Declaration
Class IO
option
List Declaration
\*---------------------------------------------------------------------------*/
class
IO
basicSource
List
class
IO
option
List
:
public
IOdictionary
,
public
basicSource
List
public
option
List
{
private:
...
...
@@ -61,10 +63,10 @@ private:
IOobject
createIOobject
(
const
fvMesh
&
mesh
)
const
;
//- Disallow default bitwise copy construct
IO
basicSource
List
(
const
IO
basicSource
List
&
);
IO
option
List
(
const
IO
option
List
&
);
//- Disallow default bitwise assignment
void
operator
=
(
const
IO
basicSource
List
&
);
void
operator
=
(
const
IO
option
List
&
);
public:
...
...
@@ -72,11 +74,11 @@ public:
// Constructors
//- Construct from components with list of field names
IO
basicSource
List
(
const
fvMesh
&
mesh
);
IO
option
List
(
const
fvMesh
&
mesh
);
//- Destructor
virtual
~
IO
basicSource
List
()
virtual
~
IO
option
List
()
{}
...
...
@@ -89,6 +91,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
}
// End namespace fv
}
// End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...
...
src/fieldSources/
basicSource/basicSource
.C
→
src/fieldSources/
fvOptions/fvOption
.C
View file @
792fbf1a
...
...
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-201
2
OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-201
3
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
...
...
src/fieldSources/
basicSource/basicSource
.H
→
src/fieldSources/
fvOptions/fvOption
.H
View file @
792fbf1a
...
...
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-201
2
OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-201
3
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
basicSource
IO.C
fvOption
.C
fvOption
IO.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
(