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),
fieldName_(coeffs_.lookup("fieldName")),
diskDir_(coeffs_.lookup("diskDir")),
Cp_(readScalar(coeffs_.lookup("Cp"))),
Ct_(readScalar(coeffs_.lookup("Ct"))),
@ -155,7 +156,7 @@ void Foam::actuationDiskSource::addSup
void Foam::actuationDiskSource::writeData(Ostream& os) const
{
os << indent << name_ << endl;
coeffs_.write(os);
dict_.write(os);
}

View File

@ -26,16 +26,30 @@ Class
Foam::actuationDiskSource
Description
Actuation disk zone definition.
Actuation disk source
Constant values for momentum source for actuation disk
T = 2*rho*A*sqr(Uo)*a*(1-a)
U1 = (1 -a)Uo
T = 2*rho*A*sqr(Uo)*a*(1-a)
U1 = (1 -a)Uo
where:
A: disk area
Uo: upstream velocity
a: 1 - Cp/Ct
U1: velocity at the disk
A: disk area
Uo: upstream velocity
a: 1 - Cp/Ct
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
actuationDiskSource.C
@ -46,14 +60,6 @@ SourceFiles
#ifndef 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"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

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

View File

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

View File

@ -25,52 +25,14 @@ Class
Foam::basicSource
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
active on; // on/off switch
timeStart 0.0; // start time
duration 1000.0; // duration
selectionMode cellSet; // cellSet // points //cellZone
source1
{
type actuationDiskSource; // explicitSource
active on; // on/off switch
timeStart 0.0; // start time
duration 1000.0; // duration
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
basicSource.C
@ -81,10 +43,8 @@ SourceFiles
#ifndef basicSource_H
#define basicSource_H
#include "fvMatrices.H"
#include "fvMatricesFwd.H"
#include "cellSet.H"
#include "volFieldsFwd.H"
#include "DimensionedField.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
@ -96,7 +56,7 @@ namespace Foam
class fvMesh;
/*---------------------------------------------------------------------------*\
Class basicSource Declaration
Class basicSource Declaration
\*---------------------------------------------------------------------------*/
class basicSource
@ -128,7 +88,10 @@ protected:
//- Reference to the mesh database
const fvMesh& mesh_;
//- Dictionary containing the data of the source
//- Top level source dictionary
dictionary dict_;
//- Dictionary containing source coefficients
dictionary coeffs_;
//- Source active flag

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -25,32 +25,24 @@ Class
Foam::ExplicitSource
Description
Time activated explicit source.
Explicit source
Sources described by:
{
active true; // on/off switch
timeStart 0.2; // start time
duration 2.0; // duration
selectionMode points; // cellSet/cellZone/all
volumeMode absolute; // specific
<Type>ExplicitSourceCoeffs
{
volumeMode absolute; // specific
fieldData
{
k 30.7;
epsilon 1.5;
}
}
fieldData // field data - usage for multiple fields
(
(H2O 0.005)
);
If volumeMode =
- absolute: values are given as <quantity>
- specific: values are given as <quantity>/m3
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
}
SourceFiles
ExplicitSource.C
@ -61,8 +53,6 @@ SourceFiles
#define ExplicitSource_H
#include "Tuple2.H"
#include "volFieldsFwd.H"
#include "DimensionedField.H"
#include "basicSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -87,7 +77,7 @@ Ostream& operator<<
);
/*---------------------------------------------------------------------------*\
Class ExplicitSource Declaration
Class ExplicitSource Declaration
\*---------------------------------------------------------------------------*/
template<class Type>

View File

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

View File

@ -22,20 +22,31 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::pressureGradientExplicitSourceNew
Foam::pressureGradientExplicitSource
Description
Creates a cell set pressure gradient source
Creates a pressure gradient source
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
pressureGradientExplicitSourceNew.C
pressureGradientExplicitSource.C
\*---------------------------------------------------------------------------*/
#ifndef pressureGradientExplicitSourceNew_H
#define pressureGradientExplicitSourceNew_H
#ifndef pressureGradientExplicitSource_H
#define pressureGradientExplicitSource_H
#include "autoPtr.H"
#include "topoSetSource.H"
@ -50,10 +61,10 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class pressureGradientExplicitSourceNew Declaration
Class pressureGradientExplicitSource Declaration
\*---------------------------------------------------------------------------*/
class pressureGradientExplicitSourceNew
class pressureGradientExplicitSource
:
public basicSource
{
@ -84,10 +95,10 @@ class pressureGradientExplicitSourceNew
void update();
//- Disallow default bitwise copy construct
pressureGradientExplicitSourceNew(const pressureGradientExplicitSourceNew&);
pressureGradientExplicitSource(const pressureGradientExplicitSource&);
//- Disallow default bitwise assignment
void operator=(const pressureGradientExplicitSourceNew&);
void operator=(const pressureGradientExplicitSource&);
public:
@ -99,7 +110,7 @@ public:
// Constructors
//- Construct from explicit source name and mesh
pressureGradientExplicitSourceNew
pressureGradientExplicitSource
(
const word& sourceName,
const word& modelType,

View File

@ -27,11 +27,11 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::pressureGradientExplicitSourceNew::writeData(Ostream& os) const
void Foam::pressureGradientExplicitSource::writeData(Ostream& os) const
{
notImplemented
(
"void Foam::pressureGradientExplicitSourceNew::writeData"
"void Foam::pressureGradientExplicitSource::writeData"
"("
"Ostream&"
") 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
(
"bool Foam::pressureGradientExplicitSourceNew::read"
"bool Foam::pressureGradientExplicitSource::read"
"("
"const dictionary&"
") const"

View File

@ -29,17 +29,31 @@ Description
Actuation disk zone definition.
Constant values for momentum source for actuation disk
T = 2*rho*A*sqr(Uo)*a*(1-a)
U1 = (1 -a)Uo
T = 2*rho*A*sqr(Uo)*a*(1-a)
U1 = (1 -a)Uo
where:
A: disk area
Uo: upstream velocity
a: 1 - Cp/Ct
U1: velocity at the disk
A: disk area
Uo: upstream velocity
a: 1 - Cp/Ct
U1: velocity at the disk
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
@ -51,10 +65,8 @@ SourceFiles
#ifndef radialActuationDiskSource_H
#define radialActuationDiskSource_H
#include "DimensionedField.H"
#include "volFieldsFwd.H"
#include "FixedList.H"
#include "actuationDiskSource.H"
#include "FixedList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

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

View File

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

View File

@ -25,11 +25,61 @@ Class
Foam::rotorDiskSource
Description
Cell-zone based momemtum source
Cell based momemtum source
Source approximates the mean effects of rotor forces on a cylindrical
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
rotorDiskSource.C
rotorDiskSourceTemplates.C
@ -44,6 +94,8 @@ SourceFiles
#include "NamedEnum.H"
#include "bladeModel.H"
#include "profileModelList.H"
#include "volFieldsFwd.H"
#include "dimensionSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

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