ENH: field source re-factoring

This commit is contained in:
andy
2011-11-02 10:47:51 +00:00
parent b3cf36ee71
commit 2592fe8999
19 changed files with 199 additions and 156 deletions

View File

@ -80,6 +80,7 @@ Foam::actuationDiskSource::actuationDiskSource
) )
: :
basicSource(name, modelType, dict, mesh), basicSource(name, modelType, dict, mesh),
fieldName_(coeffs_.lookup("fieldName")),
diskDir_(coeffs_.lookup("diskDir")), diskDir_(coeffs_.lookup("diskDir")),
Cp_(readScalar(coeffs_.lookup("Cp"))), Cp_(readScalar(coeffs_.lookup("Cp"))),
Ct_(readScalar(coeffs_.lookup("Ct"))), Ct_(readScalar(coeffs_.lookup("Ct"))),
@ -155,7 +156,7 @@ void Foam::actuationDiskSource::addSup
void Foam::actuationDiskSource::writeData(Ostream& os) const void Foam::actuationDiskSource::writeData(Ostream& os) const
{ {
os << indent << name_ << endl; os << indent << name_ << endl;
coeffs_.write(os); dict_.write(os);
} }

View File

@ -26,17 +26,31 @@ Class
Foam::actuationDiskSource Foam::actuationDiskSource
Description Description
Actuation disk zone definition. Actuation disk source
Constant values for momentum source for actuation disk Constant values for momentum source for actuation disk
T = 2*rho*A*sqr(Uo)*a*(1-a) T = 2*rho*A*sqr(Uo)*a*(1-a)
U1 = (1 -a)Uo U1 = (1 -a)Uo
where: where:
A: disk area A: disk area
Uo: upstream velocity Uo: upstream velocity
a: 1 - Cp/Ct a: 1 - Cp/Ct
U1: velocity at the disk U1: velocity at the disk
Sources described by:
actuationDiskSourceCoeffs
{
fieldName U; // name of field to apply source
diskDir (-1 0 0); // disk direction
Cp 0.1; // power coefficient
Ct 0.5; // thrust coefficient
diskArea 5.0; // disk area
}
SourceFiles SourceFiles
actuationDiskSource.C actuationDiskSource.C
actuationDiskSourceTemplates.C actuationDiskSourceTemplates.C
@ -46,14 +60,6 @@ SourceFiles
#ifndef actuationDiskSource_H #ifndef actuationDiskSource_H
#define actuationDiskSource_H #define actuationDiskSource_H
#include "IOdictionary.H"
#include "coordinateSystem.H"
#include "coordinateSystems.H"
#include "wordList.H"
#include "labelList.H"
#include "DimensionedField.H"
#include "volFieldsFwd.H"
#include "fvMatricesFwd.H"
#include "basicSource.H" #include "basicSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -24,6 +24,8 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "IObasicSourceList.H" #include "IObasicSourceList.H"
#include "fvMesh.H"
#include "Time.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

View File

@ -25,19 +25,16 @@ License
#include "basicSource.H" #include "basicSource.H"
#include "fvMesh.H" #include "fvMesh.H"
#include "volFields.H" #include "fvMatrices.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(basicSource, 0); defineTypeNameAndDebug(basicSource, 0);
defineRunTimeSelectionTable(basicSource, dictionary); defineRunTimeSelectionTable(basicSource, dictionary);
// * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
template<> const char* NamedEnum template<> const char* NamedEnum
< <
basicSource::selectionModeType, basicSource::selectionModeType,
@ -116,10 +113,7 @@ void Foam::basicSource::setCellSet()
label globalCellI = returnReduce(cellI, maxOp<label>()); label globalCellI = returnReduce(cellI, maxOp<label>());
if (globalCellI < 0) if (globalCellI < 0)
{ {
WarningIn WarningIn("basicSource::setCellIds()")
(
"basicSource::setCellIds()"
)
<< "Unable to find owner cell for point " << points_[i] << "Unable to find owner cell for point " << points_[i]
<< endl; << endl;
@ -194,24 +188,25 @@ Foam::basicSource::basicSource
( (
const word& name, const word& name,
const word& modelType, const word& modelType,
const dictionary& coeffs, const dictionary& dict,
const fvMesh& mesh const fvMesh& mesh
) )
: :
name_(name), name_(name),
mesh_(mesh), mesh_(mesh),
coeffs_(coeffs), dict_(dict),
active_(readBool(coeffs_.lookup("active"))), coeffs_(dict.subDict(modelType + "Coeffs")),
timeStart_(readScalar(coeffs_.lookup("timeStart"))), active_(readBool(dict_.lookup("active"))),
duration_(readScalar(coeffs_.lookup("duration"))), timeStart_(readScalar(dict_.lookup("timeStart"))),
duration_(readScalar(dict_.lookup("duration"))),
selectionMode_ selectionMode_
( (
selectionModeTypeNames_.read(coeffs_.lookup("selectionMode")) selectionModeTypeNames_.read(dict_.lookup("selectionMode"))
), ),
cellSetName_("none"), cellSetName_("none"),
V_(0.0) V_(0.0)
{ {
setSelection(coeffs_); setSelection(dict_);
setCellSet(); setCellSet();
} }

View File

@ -25,52 +25,14 @@ Class
Foam::basicSource Foam::basicSource
Description Description
Basic source abtract class Field source abtract base class. Provides a base set of controls, e.g.
Sources described by: type scalarExplicitSource // source type
source1
{
type actuationDiskSource; // explicitSource
active on; // on/off switch active on; // on/off switch
timeStart 0.0; // start time timeStart 0.0; // start time
duration 1000.0; // duration duration 1000.0; // duration
selectionMode cellSet; // cellSet // points //cellZone selectionMode cellSet; // cellSet // points //cellZone
cellSet c0; // cellSet name
actuationDiskSourceCoeffs
{
diskDir (-1 0 0); // orientation of the disk
Cp 0.53; // Cp
Ct 0.58; // Ct
diskArea 40; // disk area
}
}
source2
{
type explicitSource;
active on;
timeStart 0.0;
duration 1000.0;
selectionMode points;
cellSet c0;
points // list of points when selectionMode = points
(
(-0.088 0.007 -0.02)
(-0.028 0.007 -0.02)
);
explicitSourceCoeffs
{
volumeMode specific; //absolute
fieldData //field data
{
k 30.7;
epsilon 1.5;
}
}
}
SourceFiles SourceFiles
basicSource.C basicSource.C
@ -81,10 +43,8 @@ SourceFiles
#ifndef basicSource_H #ifndef basicSource_H
#define basicSource_H #define basicSource_H
#include "fvMatrices.H" #include "fvMatricesFwd.H"
#include "cellSet.H" #include "cellSet.H"
#include "volFieldsFwd.H"
#include "DimensionedField.H"
#include "autoPtr.H" #include "autoPtr.H"
#include "runTimeSelectionTables.H" #include "runTimeSelectionTables.H"
@ -128,7 +88,10 @@ protected:
//- Reference to the mesh database //- Reference to the mesh database
const fvMesh& mesh_; const fvMesh& mesh_;
//- Dictionary containing the data of the source //- Top level source dictionary
dictionary dict_;
//- Dictionary containing source coefficients
dictionary coeffs_; dictionary coeffs_;
//- Source active flag //- Source active flag

View File

@ -80,6 +80,9 @@ bool Foam::basicSource::read(const dictionary& dict)
active_ = readBool(dict.lookup("active")); active_ = readBool(dict.lookup("active"));
timeStart_ = readScalar(dict.lookup("timeStart")); timeStart_ = readScalar(dict.lookup("timeStart"));
duration_ = readScalar(dict.lookup("duration")); duration_ = readScalar(dict.lookup("duration"));
coeffs_ = dict.subDict(type() + "Coeffs");
return true; return true;
} }

View File

@ -25,7 +25,8 @@ License
#include "ExplicitSetValue.H" #include "ExplicitSetValue.H"
#include "fvMesh.H" #include "fvMesh.H"
#include "volFields.H" #include "fvMatrices.H"
#include "DimensionedField.H"
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //

View File

@ -29,15 +29,16 @@ Description
Sources described by: Sources described by:
explicitSetValueCoeffs <Type>ExplicitSetValueCoeffs
{ {
fieldData // field data - usage for multiple fields fieldData
{ {
k 30.7; k 30.7;
epsilon 1.5; epsilon 1.5;
} }
} }
SourceFiles SourceFiles
explicitSetValue.C explicitSetValue.C

View File

@ -31,7 +31,7 @@ template<class Type>
void Foam::ExplicitSetValue<Type>::writeData(Ostream& os) const void Foam::ExplicitSetValue<Type>::writeData(Ostream& os) const
{ {
os << indent << name_ << endl; os << indent << name_ << endl;
coeffs_.write(os); dict_.write(os);
} }

View File

@ -25,8 +25,8 @@ License
#include "ExplicitSource.H" #include "ExplicitSource.H"
#include "fvMesh.H" #include "fvMesh.H"
#include "volFields.H" #include "fvMatrices.H"
#include "dimensionedType.H" #include "DimensionedField.H"
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //

View File

@ -25,32 +25,24 @@ Class
Foam::ExplicitSource Foam::ExplicitSource
Description Description
Time activated explicit source. Explicit source
Sources described by: Sources described by:
<Type>ExplicitSourceCoeffs
{ {
active true; // on/off switch
timeStart 0.2; // start time
duration 2.0; // duration
selectionMode points; // cellSet/cellZone/all
volumeMode absolute; // specific volumeMode absolute; // specific
fieldData
fieldData // field data - usage for multiple fields {
( k 30.7;
(H2O 0.005) epsilon 1.5;
);
fieldData 0.005; // field data - usage for single field
points // list of points when selectionMode = points
(
(2.75 0.5 0)
);
cellSet c0; // cellSet name when selectionMode=cellSet
cellZone c0; // cellZone name when selectionMode=cellZone
} }
}
If volumeMode =
- absolute: values are given as <quantity>
- specific: values are given as <quantity>/m3
SourceFiles SourceFiles
ExplicitSource.C ExplicitSource.C
@ -61,8 +53,6 @@ SourceFiles
#define ExplicitSource_H #define ExplicitSource_H
#include "Tuple2.H" #include "Tuple2.H"
#include "volFieldsFwd.H"
#include "DimensionedField.H"
#include "basicSource.H" #include "basicSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -24,25 +24,29 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "pressureGradientExplicitSource.H" #include "pressureGradientExplicitSource.H"
#include "volFields.H" #include "fvMatrices.H"
#include "DimensionedField.H"
#include "IFstream.H" #include "IFstream.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(pressureGradientExplicitSourceNew, 0); defineTypeNameAndDebug(pressureGradientExplicitSource, 0);
addToRunTimeSelectionTable addToRunTimeSelectionTable
( (
basicSource, basicSource,
pressureGradientExplicitSourceNew, pressureGradientExplicitSource,
dictionary dictionary
); );
} }
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::pressureGradientExplicitSourceNew::writeGradP() const void Foam::pressureGradientExplicitSource::writeGradP() const
{ {
// Only write on output time // Only write on output time
if (mesh_.time().outputTime()) if (mesh_.time().outputTime())
@ -65,7 +69,7 @@ void Foam::pressureGradientExplicitSourceNew::writeGradP() const
} }
void Foam::pressureGradientExplicitSourceNew::update() void Foam::pressureGradientExplicitSource::update()
{ {
volVectorField& U = const_cast<volVectorField&> volVectorField& U = const_cast<volVectorField&>
( (
@ -117,7 +121,7 @@ void Foam::pressureGradientExplicitSourceNew::update()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::pressureGradientExplicitSourceNew::pressureGradientExplicitSourceNew Foam::pressureGradientExplicitSource::pressureGradientExplicitSource
( (
const word& sourceName, const word& sourceName,
const word& modelType, const word& modelType,
@ -151,7 +155,7 @@ Foam::pressureGradientExplicitSourceNew::pressureGradientExplicitSourceNew
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::label Foam::pressureGradientExplicitSourceNew::applyToField Foam::label Foam::pressureGradientExplicitSource::applyToField
( (
const word& fieldName const word& fieldName
) const ) const
@ -167,7 +171,7 @@ Foam::label Foam::pressureGradientExplicitSourceNew::applyToField
} }
void Foam::pressureGradientExplicitSourceNew::addSup void Foam::pressureGradientExplicitSource::addSup
( (
fvMatrix<vector>& eqn, fvMatrix<vector>& eqn,
const label const label

View File

@ -22,20 +22,31 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::pressureGradientExplicitSourceNew Foam::pressureGradientExplicitSource
Description Description
Creates a cell set pressure gradient source Creates a pressure gradient source
Note: Currently only handles kinematic pressure Note: Currently only handles kinematic pressure
Sources described by:
pressureGradientExplicitSourceCoeffs
{
UName U; // Name of velocity field
Ubar (10.0 0 0); // Desired average velocity
gradPini gradPini [0 2 -2 0 0]; // initial pressure gradient
flowDir (1 0 0); // flow direction
}
SourceFiles SourceFiles
pressureGradientExplicitSourceNew.C pressureGradientExplicitSource.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef pressureGradientExplicitSourceNew_H #ifndef pressureGradientExplicitSource_H
#define pressureGradientExplicitSourceNew_H #define pressureGradientExplicitSource_H
#include "autoPtr.H" #include "autoPtr.H"
#include "topoSetSource.H" #include "topoSetSource.H"
@ -50,10 +61,10 @@ namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class pressureGradientExplicitSourceNew Declaration Class pressureGradientExplicitSource Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class pressureGradientExplicitSourceNew class pressureGradientExplicitSource
: :
public basicSource public basicSource
{ {
@ -84,10 +95,10 @@ class pressureGradientExplicitSourceNew
void update(); void update();
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
pressureGradientExplicitSourceNew(const pressureGradientExplicitSourceNew&); pressureGradientExplicitSource(const pressureGradientExplicitSource&);
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const pressureGradientExplicitSourceNew&); void operator=(const pressureGradientExplicitSource&);
public: public:
@ -99,7 +110,7 @@ public:
// Constructors // Constructors
//- Construct from explicit source name and mesh //- Construct from explicit source name and mesh
pressureGradientExplicitSourceNew pressureGradientExplicitSource
( (
const word& sourceName, const word& sourceName,
const word& modelType, const word& modelType,

View File

@ -27,11 +27,11 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::pressureGradientExplicitSourceNew::writeData(Ostream& os) const void Foam::pressureGradientExplicitSource::writeData(Ostream& os) const
{ {
notImplemented notImplemented
( (
"void Foam::pressureGradientExplicitSourceNew::writeData" "void Foam::pressureGradientExplicitSource::writeData"
"(" "("
"Ostream&" "Ostream&"
") const" ") const"
@ -39,11 +39,11 @@ void Foam::pressureGradientExplicitSourceNew::writeData(Ostream& os) const
} }
bool Foam::pressureGradientExplicitSourceNew::read(const dictionary& dict) bool Foam::pressureGradientExplicitSource::read(const dictionary& dict)
{ {
notImplemented notImplemented
( (
"bool Foam::pressureGradientExplicitSourceNew::read" "bool Foam::pressureGradientExplicitSource::read"
"(" "("
"const dictionary&" "const dictionary&"
") const" ") const"

View File

@ -31,6 +31,7 @@ Description
T = 2*rho*A*sqr(Uo)*a*(1-a) T = 2*rho*A*sqr(Uo)*a*(1-a)
U1 = (1 -a)Uo U1 = (1 -a)Uo
where: where:
A: disk area A: disk area
Uo: upstream velocity Uo: upstream velocity
@ -39,8 +40,21 @@ Description
The thrust is distributed by a radial function: The thrust is distributed by a radial function:
thrust(r) = T*(C0 + C1*r^2 + C2*r^4) thrust(r) = T*(C0 + C1*r^2 + C2*r^4)
Sources described by:
actuationDiskSourceCoeffs
{
fieldName U; // name of field to apply source
diskDir (-1 0 0); // disk direction
Cp 0.1; // power coefficient
Ct 0.5; // thrust coefficient
diskArea 5.0; // disk area
coeffs (0.1 0.5 0.01); // radial distribution coefficients
}
SourceFiles SourceFiles
radialActuationDiskSource.C radialActuationDiskSource.C
@ -51,10 +65,8 @@ SourceFiles
#ifndef radialActuationDiskSource_H #ifndef radialActuationDiskSource_H
#define radialActuationDiskSource_H #define radialActuationDiskSource_H
#include "DimensionedField.H"
#include "volFieldsFwd.H"
#include "FixedList.H"
#include "actuationDiskSource.H" #include "actuationDiskSource.H"
#include "FixedList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -28,7 +28,7 @@ Description
Base class for profile models Base class for profile models
SourceFiles SourceFiles
profileModel.C profileModelList.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/

View File

@ -28,6 +28,7 @@ License
#include "mathematicalConstants.H" #include "mathematicalConstants.H"
#include "unitConversion.H" #include "unitConversion.H"
#include "geometricOneField.H" #include "geometricOneField.H"
#include "fvMatrices.H"
using namespace Foam::constant; using namespace Foam::constant;
@ -361,13 +362,13 @@ Foam::rotorDiskSource::rotorDiskSource
( (
const word& name, const word& name,
const word& modelType, const word& modelType,
const dictionary& coeffs, const dictionary& dict,
const fvMesh& mesh const fvMesh& mesh
) )
: :
basicSource(name, modelType, coeffs, mesh), basicSource(name, modelType, dict, mesh),
fieldName_(coeffs.lookup("fieldName")), fieldName_(coeffs_.lookup("fieldName")),
rhoName_("none"), rhoName_("none"),
omega_(0.0), omega_(0.0),
nBlades_(0), nBlades_(0),
@ -385,7 +386,7 @@ Foam::rotorDiskSource::rotorDiskSource
coordSys_(false), coordSys_(false),
rMax_(0.0) rMax_(0.0)
{ {
read(coeffs); read(dict);
} }
@ -445,7 +446,7 @@ void Foam::rotorDiskSource::addSup(fvMatrix<vector>& eqn)
void Foam::rotorDiskSource::writeData(Ostream& os) const void Foam::rotorDiskSource::writeData(Ostream& os) const
{ {
os << indent << name_ << endl; os << indent << name_ << endl;
coeffs_.write(os); dict_.write(os);
} }

View File

@ -25,11 +25,61 @@ Class
Foam::rotorDiskSource Foam::rotorDiskSource
Description Description
Cell-zone based momemtum source Cell based momemtum source
Source approximates the mean effects of rotor forces on a cylindrical Source approximates the mean effects of rotor forces on a cylindrical
region within the domain region within the domain
Sources described by:
rotorDiskSourceCoeffs
{
fieldName U; // name of field on which to apply source
rhoName rho; // density field if compressible case
nBlades 3; // number of blades
tip effect 0.96; // normalised radius above which lift = 0
inletFlowType local; // inlet flow type specification
geometryMode auto; // geometry specification
refDirection (-1 0 0); // reference direction
flapCoeffs
{
beta0 0; // coning angle [deg]
beta1 0; // lateral flapping coeff
beta2 0; // longitudinal flapping coeff
}
trimCoeffs
{
alphac 15; // collective pitch angle [deg]
A 0; // lateral cyclic coeff
B 0; // longitudinal cyclic coeff
}
blade
{
...
}
profiles
{
...
}
}
Where:
geometryMode =
auto : determine rototor co-ord system from cells
specified : specified co-ord system
inletFlowType =
fixed : specified velocity
surfaceNormal : specified normal velocity (positive towards rotor)
local : use local flow conditions
SourceFiles SourceFiles
rotorDiskSource.C rotorDiskSource.C
rotorDiskSourceTemplates.C rotorDiskSourceTemplates.C
@ -44,6 +94,8 @@ SourceFiles
#include "NamedEnum.H" #include "NamedEnum.H"
#include "bladeModel.H" #include "bladeModel.H"
#include "profileModelList.H" #include "profileModelList.H"
#include "volFieldsFwd.H"
#include "dimensionSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -27,6 +27,7 @@ License
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "mathematicalConstants.H" #include "mathematicalConstants.H"
#include "unitConversion.H" #include "unitConversion.H"
#include "volFields.H"
using namespace Foam::constant; using namespace Foam::constant;