GIT: Resolve conflict

This commit is contained in:
andy
2011-11-02 12:50:27 +00:00
77 changed files with 1262 additions and 2878 deletions

View File

@ -35,7 +35,12 @@ License
namespace Foam
{
defineTypeNameAndDebug(actuationDiskSource, 0);
addToRunTimeSelectionTable(basicSource, actuationDiskSource, dictionary);
addToRunTimeSelectionTable
(
basicSource,
actuationDiskSource,
dictionary
);
}
@ -75,7 +80,7 @@ Foam::actuationDiskSource::actuationDiskSource
)
:
basicSource(name, modelType, dict, mesh),
coeffs_(dict.subDict(modelType + "Coeffs")),
fieldName_(coeffs_.lookup("fieldName")),
diskDir_(coeffs_.lookup("diskDir")),
Cp_(readScalar(coeffs_.lookup("Cp"))),
Ct_(readScalar(coeffs_.lookup("Ct"))),
@ -90,17 +95,35 @@ Foam::actuationDiskSource::actuationDiskSource
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::actuationDiskSource::addSu(fvMatrix<vector>& UEqn)
Foam::label Foam::actuationDiskSource::applyToField
(
const word& fieldName
) const
{
if (fieldName == fieldName_)
{
return 0;
}
return -1;
}
void Foam::actuationDiskSource::addSup
(
fvMatrix<vector>& eqn,
const label
)
{
bool compressible = false;
if (UEqn.dimensions() == dimensionSet(1, 1, -2, 0, 0))
if (eqn.dimensions() == dimForce)
{
compressible = true;
}
const scalarField& cellsV = this->mesh().V();
vectorField& Usource = UEqn.source();
const vectorField& U = UEqn.psi();
const scalarField& cellsV = mesh_.V();
vectorField& Usource = eqn.source();
const vectorField& U = eqn.psi();
if (V() > VSMALL)
{
@ -111,7 +134,7 @@ void Foam::actuationDiskSource::addSu(fvMatrix<vector>& UEqn)
Usource,
cells_,
cellsV,
this->mesh().lookupObject<volScalarField>("rho"),
mesh_.lookupObject<volScalarField>("rho"),
U
);
}
@ -141,7 +164,6 @@ bool Foam::actuationDiskSource::read(const dictionary& dict)
{
if (basicSource::read(dict))
{
coeffs_ = dict.subDict(typeName + "Coeffs");
coeffs_.readIfPresent("diskDir", diskDir_);
coeffs_.readIfPresent("Cp", Cp_);
coeffs_.readIfPresent("Ct", Ct_);

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"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -74,8 +80,8 @@ protected:
// Protected data
//- Coefficients dictionary
dictionary coeffs_;
//- Name of field to apply source upon
word fieldName_;
//- Disk area normal
vector diskDir_;
@ -140,6 +146,12 @@ public:
// Member Functions
// Check
//- Return index of field name if found in fieldNames list
virtual label applyToField(const word& fieldName) const;
// Access
//- Return Cp
@ -169,11 +181,8 @@ public:
// Public Functions
//-Source term to fvMatrix<vector>
virtual void addSu(fvMatrix<vector>& UEqn);
//-Source term to fvMatrix<scalar>
virtual void addSu(fvMatrix<scalar>& UEqn){}
//- Source term to fvMatrix<vector>
virtual void addSup(fvMatrix<vector>& eqn, const label fieldI);
// I-O

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,
@ -120,12 +117,9 @@ void Foam::basicSource::setCellSet()
label globalCellI = returnReduce(cellI, maxOp<label>());
if (globalCellI < 0)
{
WarningIn
(
"TimeActivatedExplicitSource<Type>::setCellIds()"
)
<< "Unable to find owner cell for point " << points_[i]
<< endl;
WarningIn("basicSource::setCellIds()")
<< "Unable to find owner cell for point " << points_[i]
<< endl;
}
@ -152,7 +146,7 @@ void Foam::basicSource::setCellSet()
label zoneID = mesh_.cellZones().findZoneID(cellSetName_);
if (zoneID == -1)
{
FatalErrorIn("basicSource<Type>::setCellIds()")
FatalErrorIn("basicSource::setCellIds()")
<< "Cannot find cellZone " << cellSetName_ << endl
<< "Valid cellZones are " << mesh_.cellZones().names()
<< exit(FatalError);
@ -170,7 +164,7 @@ void Foam::basicSource::setCellSet()
}
default:
{
FatalErrorIn("basicSource<Type>::setCellIds()")
FatalErrorIn("basicSource::setCellIds()")
<< "Unknown selectionMode "
<< selectionModeTypeNames_[selectionMode_]
<< ". Valid selectionMode types are" << selectionModeTypeNames_
@ -205,6 +199,7 @@ Foam::basicSource::basicSource
name_(name),
mesh_(mesh),
dict_(dict),
coeffs_(dict.subDict(modelType + "Coeffs")),
active_(readBool(dict_.lookup("active"))),
timeStart_(readScalar(dict_.lookup("timeStart"))),
duration_(readScalar(dict_.lookup("duration"))),
@ -226,11 +221,11 @@ Foam::basicSource::basicSource
Foam::autoPtr<Foam::basicSource> Foam::basicSource::New
(
const word& name,
const dictionary& dict,
const dictionary& coeffs,
const fvMesh& mesh
)
{
word modelType(dict.lookup("type"));
word modelType(coeffs.lookup("type"));
Info<< "Selecting model type " << modelType << endl;
@ -241,16 +236,16 @@ Foam::autoPtr<Foam::basicSource> Foam::basicSource::New
{
FatalErrorIn
(
"basicSource::New(const volVectorField&, "
"const surfaceScalarField&, transportModel&)"
"basicSource::New"
"(const name&, const dictionary&, const fvMesh&)"
) << "Unknown Model type " << modelType
<< nl << nl
<< "Valid model types are :" << nl
<< "Valid model types are:" << nl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<basicSource>(cstrIter()(name, modelType, dict, mesh));
return autoPtr<basicSource>(cstrIter()(name, modelType, coeffs, mesh));
}
@ -279,21 +274,75 @@ bool Foam::basicSource::isActive()
}
void Foam::basicSource::addSu(Foam::fvMatrix<vector>& Eqn)
void Foam::basicSource::addSup(fvMatrix<scalar>& eqn, const label fieldI)
{
notImplemented("Foam::basicSource addSu(Foam::fvMatrix<vector>& Eqn)");
// do nothing
}
void Foam::basicSource::addSu(Foam::fvMatrix<scalar>& Eqn)
void Foam::basicSource::addSup(fvMatrix<vector>& eqn, const label fieldI)
{
notImplemented("Foam::basicSource addSu(Foam::fvMatrix<scalar>& Eqn)");
// do nothing
}
void Foam::basicSource::setValue(Foam::fvMatrix<scalar>& Eqn)
void Foam::basicSource::addSup
(
fvMatrix<sphericalTensor>& eqn,
const label fieldI
)
{
notImplemented("Foam::basicSource setValue(Foam::fvMatrix<scalar>& Eqn)");
// do nothing
}
void Foam::basicSource::addSup(fvMatrix<symmTensor>& eqn, const label fieldI)
{
// do nothing
}
void Foam::basicSource::addSup(fvMatrix<tensor>& eqn, const label fieldI)
{
// do nothing
}
void Foam::basicSource::setValue(fvMatrix<scalar>& eqn, const label fieldI)
{
// do nothing
}
void Foam::basicSource::setValue(fvMatrix<vector>& eqn, const label fieldI)
{
// do nothing
}
void Foam::basicSource::setValue
(
fvMatrix<sphericalTensor>& eqn,
const label fieldI
)
{
// do nothing
}
void Foam::basicSource::setValue
(
fvMatrix<symmTensor>& eqn,
const label fieldI
)
{
// do nothing
}
void Foam::basicSource::setValue(fvMatrix<tensor>& eqn, const label fieldI)
{
// do nothing
}

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,12 +88,18 @@ protected:
//- Reference to the mesh database
const fvMesh& mesh_;
//- Dictionary containing the data of the source
const dictionary& dict_;
//- Top level source dictionary
dictionary dict_;
//- Dictionary containing source coefficients
dictionary coeffs_;
//- Source active flag
bool active_;
//- Flag to indicate whether or not the source has been applied
// bool applied_; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//- Time start
scalar timeStart_;
@ -271,7 +237,7 @@ public:
inline const fvMesh& mesh() const;
//- Return dictionary
inline const dictionary& dictCoeffs() const;
inline const dictionary& coeffs() const;
//- Return const access to the source active flag
inline bool active() const;
@ -316,18 +282,86 @@ public:
//- Is the source active?
bool isActive();
//- Return index of field name if found in fieldNames list
virtual label applyToField(const word& fieldName) const = 0;
// Evaluation
//- Add source term to vector fvMatrix
virtual void addSu(fvMatrix<vector>& Eqn);
// Add explicit and implicit contributions
//- Add source term to scalar fvMatrix
virtual void addSu(fvMatrix<scalar>& Eqn);
//- Scalar
virtual void addSup
(
fvMatrix<scalar>& eqn,
const label fieldI
);
//- Set constant value on field
virtual void setValue(fvMatrix<scalar>& Eq);
//- Vector
virtual void addSup
(
fvMatrix<vector>& eqn,
const label fieldI
);
//- Spherical tensor
virtual void addSup
(
fvMatrix<symmTensor>& eqn,
const label fieldI
);
//- Symmetric tensor
virtual void addSup
(
fvMatrix<sphericalTensor>& eqn,
const label fieldI
);
//- Tensor
virtual void addSup
(
fvMatrix<tensor>& eqn,
const label fieldI
);
// Set values directly
//- Scalar
virtual void setValue
(
fvMatrix<scalar>& eqn,
const label fieldI
);
//- Vector
virtual void setValue
(
fvMatrix<vector>& eqn,
const label fieldI
);
//- Spherical tensor
virtual void setValue
(
fvMatrix<sphericalTensor>& eqn,
const label fieldI
);
//- Symmetric tensor
virtual void setValue
(
fvMatrix<symmTensor>& eqn,
const label fieldI
);
//- Tensor
virtual void setValue
(
fvMatrix<tensor>& eqn,
const label fieldI
);
// I-O

View File

@ -38,11 +38,13 @@ inline const Foam::fvMesh& Foam::basicSource::mesh() const
return mesh_;
}
inline const Foam::dictionary& Foam::basicSource::dictCoeffs() const
inline const Foam::dictionary& Foam::basicSource::coeffs() const
{
return dict_;
return coeffs_;
}
inline bool Foam::basicSource::active() const
{
return active_;

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

@ -24,6 +24,14 @@ License
\*---------------------------------------------------------------------------*/
#include "basicSourceList.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(basicSourceList, 0);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -50,59 +58,23 @@ Foam::basicSourceList::basicSourceList
label i = 0;
forAllConstIter(dictionary, dict, iter)
{
const word& name = iter().keyword();
const dictionary& sourceDict = iter().dict();
if (iter().isDict())
{
const word& name = iter().keyword();
const dictionary& sourceDict = iter().dict();
this->set
(
i++,
basicSource::New(name, sourceDict, mesh)
);
this->set
(
i++,
basicSource::New(name, sourceDict, mesh)
);
}
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::basicSourceList::addSu(fvMatrix<scalar>& Eqn)
{
forAll(*this, i)
{
if (this->operator[](i).isActive())
{
this->operator[](i).addSu(Eqn);
}
}
}
void Foam::basicSourceList::addSu(fvMatrix<vector>& Eqn)
{
forAll(*this, i)
{
if (this->operator[](i).isActive())
{
this->operator[](i).addSu(Eqn);
}
}
}
void Foam::basicSourceList::setValue(fvMatrix<scalar>& Eqn)
{
forAll(*this, i)
{
if (this->operator[](i).isActive())
{
this->operator[](i).setValue(Eqn);
}
}
}
bool Foam::basicSourceList::read(const dictionary& dict)
{
bool allOk = true;

View File

@ -71,6 +71,10 @@ private:
public:
//- Runtime type information
TypeName("basicSourceList");
// Constructors
//- Construct from components with list of field names
@ -86,14 +90,8 @@ public:
// Evaluation
//- Add source terms to scalar fvMatrix
void addSu(fvMatrix<scalar>& Eq);
//- Add source terms to vector fvMatrix
void addSu(fvMatrix<vector>& Eq);
//- Set constant value on field
void setValue(fvMatrix<scalar>& Eq);
template<class Type>
void apply(fvMatrix<Type>& eqn);
// I-O
@ -119,6 +117,12 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "basicSourceListTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -23,38 +23,31 @@ License
\*---------------------------------------------------------------------------*/
#include "explicitSetValue.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::explicitSetValue::writeData(Ostream& os) const
template<class Type>
void Foam::basicSourceList::apply(fvMatrix<Type>& eqn)
{
os << indent << name_ << endl;
dict_.write(os);
}
const word& fieldName = eqn.psi().name();
bool Foam::explicitSetValue::read(const dictionary& dict)
{
if (basicSource::read(dict))
forAll(*this, i)
{
coeffs_ = dict.subDict(typeName + "Coeffs");
setFieldData(coeffs_.subDict("fieldData"));
return true;
basicSource& source = this->operator[](i);
label fieldI = source.applyToField(fieldName);
if (source.isActive() && (fieldI != -1))
{
if (debug)
{
Info<< "Applying source " << source.name() << " to field "
<< fieldName << endl;
}
source.addSup(eqn, fieldI);
source.setValue(eqn, fieldI);
}
}
else
{
return false;
}
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const explicitSetValue& source)
{
source.writeData(os);
return os;
}

View File

@ -0,0 +1,51 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#ifndef makeBasicSource_H
#define makeBasicSource_H
#include "basicSource.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#define makeBasicSource(Source, Type) \
\
defineTemplateTypeNameAndDebugWithName \
( \
Source<Type>, \
#Type#Source, \
0 \
); \
\
basicSource::adddictionaryConstructorToTable<Source<Type> > \
add##Source##Type##dictionary##ConstructorTobasicSourceTable_
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,130 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "ExplicitSetValue.H"
#include "fvMesh.H"
#include "fvMatrices.H"
#include "DimensionedField.H"
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::ExplicitSetValue<Type>::setFieldData(const dictionary& dict)
{
fieldData_.setSize(dict.toc().size());
label i = 0;
forAllConstIter(dictionary, dict, iter)
{
fieldData_[i].first() = iter().keyword();
dict.lookup(iter().keyword()) >> fieldData_[i].second();
i++;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::ExplicitSetValue<Type>::ExplicitSetValue
(
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
)
:
basicSource(name, modelType, dict, mesh),
fieldData_()
{
setFieldData(coeffs_.subDict("fieldData"));
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::label Foam::ExplicitSetValue<Type>::applyToField
(
const word& fieldName
) const
{
forAll(fieldData_, i)
{
if (fieldData_[i].first() == fieldName)
{
return i;
}
}
return -1;
}
template<class Type>
void Foam::ExplicitSetValue<Type>::setValue
(
fvMatrix<Type>& eqn,
const label fieldI
)
{
if (debug)
{
Info<< "ExplicitSetValue<"<< pTraits<Type>::typeName
<< ">::setValue for source " << name_ << endl;
}
DimensionedField<Type, volMesh> rhs
(
IOobject
(
name_ + fieldData_[fieldI].first() + "rhs",
eqn.psi().mesh().time().timeName(),
eqn.psi().mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
eqn.psi().mesh(),
dimensioned<Type>
(
"zero",
dimless,
pTraits<Type>::zero
)
);
List<Type> values(cells_.size());
forAll(values, i)
{
values[i] = fieldData_[fieldI].second();
}
eqn.setValues(cells_, values);
}
// ************************************************************************* //

View File

@ -29,27 +29,26 @@ 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
\*---------------------------------------------------------------------------*/
#ifndef explicitSetValue_H
#define explicitSetValue_H
#ifndef ExplicitSetValue_H
#define ExplicitSetValue_H
#include "cellSet.H"
#include "volFieldsFwd.H"
#include "DimensionedField.H"
#include "basicSource.H"
#include "Tuple2.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -60,37 +59,20 @@ namespace Foam
Class explicitSetValue Declaration
\*---------------------------------------------------------------------------*/
class explicitSetValue
template<class Type>
class ExplicitSetValue
:
public basicSource
{
// Private data
//- List of field types
HashTable<scalar> scalarFields_;
HashTable<vector> vectorFields_;
//- Set value to field
template<class Type>
void setFieldValue(fvMatrix<Type>&, const Type&) const;
//- Add field names and values to field table for types.
template<class Type>
void addField
(
HashTable<Type>& fields,
const wordList& fieldTypes,
const wordList& fieldNames,
const dictionary& dict
);
protected:
// Protected data
//- Coefficients dictionary
dictionary coeffs_;
typedef Tuple2<word, Type> fieldNameValuePair;
//- Source value per field
List<fieldNameValuePair> fieldData_;
// Protected functions
@ -108,7 +90,7 @@ public:
// Constructors
//- Construct from components
explicitSetValue
ExplicitSetValue
(
const word& name,
const word& modelType,
@ -116,30 +98,19 @@ public:
const fvMesh& mesh
);
//- Return clone
autoPtr<explicitSetValue> clone() const
{
notImplemented("autoPtr<explicitSetValue> clone() const");
return autoPtr<explicitSetValue>(NULL);
}
// Member Functions
// Check
// Edit
//- Return points
inline const List<point>& points() const;
//- Return index of field name if found in fieldNames list
virtual label applyToField(const word& fieldName) const;
// Evaluation
//- Set value on vector field
virtual void setValue(fvMatrix<vector>& UEqn);
//- Set value on scalar field
virtual void setValue(fvMatrix<scalar>& UEqn);
virtual void setValue(fvMatrix<Type>& eqn, const label fieldI);
// I-O
@ -147,15 +118,8 @@ public:
//- Write the source properties
virtual void writeData(Ostream&) const;
//- Read fieldData in sub-dictionary
//- Read source dictionary
virtual bool read(const dictionary& dict);
//- Ostream operator
friend Ostream& operator<<
(
Ostream& os,
const explicitSetValue& source
);
};
@ -165,13 +129,9 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "explicitSetValueIO.C"
#include "explicitSetValueI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "explicitSetValueTemplates.C"
# include "ExplicitSetValue.C"
# include "ExplicitSetValueIO.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -23,22 +23,23 @@ License
\*---------------------------------------------------------------------------*/
#include "explicitSource.H"
#include "ExplicitSetValue.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::explicitSource::writeData(Ostream& os) const
template<class Type>
void Foam::ExplicitSetValue<Type>::writeData(Ostream& os) const
{
os << indent << name_ << endl;
dict_.write(os);
}
bool Foam::explicitSource::read(const dictionary& dict)
template<class Type>
bool Foam::ExplicitSetValue<Type>::read(const dictionary& dict)
{
if (basicSource::read(dict))
{
coeffs_ = dict.subDict(typeName + "Coeffs");
setFieldData(coeffs_.subDict("fieldData"));
return true;
}
@ -49,13 +50,4 @@ bool Foam::explicitSource::read(const dictionary& dict)
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const explicitSource& source)
{
source.writeData(os);
return os;
}
// ************************************************************************* //

View File

@ -23,92 +23,18 @@ License
\*---------------------------------------------------------------------------*/
#include "explicitSetValue.H"
#include "fvMesh.H"
#include "volFields.H"
#include "addToRunTimeSelectionTable.H"
#include "HashSet.H"
#include "makeBasicSource.H"
#include "ExplicitSetValue.H"
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(explicitSetValue, 0);
addToRunTimeSelectionTable
(
basicSource,
explicitSetValue,
dictionary
);
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::explicitSetValue::setFieldData(const dictionary& dict)
{
scalarFields_.clear();
vectorFields_.clear();
wordList fieldTypes(dict.toc().size());
wordList fieldNames(dict.toc().size());
forAll(dict.toc(), i)
{
const word& fieldName = dict.toc()[i];
IOobject io
(
fieldName,
this->mesh().time().timeName(),
this->mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
);
if (io.headerOk())
{
fieldTypes[i] = io.headerClassName();
fieldNames[i] = dict.toc()[i];
}
else
{
FatalErrorIn("explicitSetValue::setFieldData")
<< "header not OK for field " << io.name()
<< abort(FatalError);
}
}
addField(scalarFields_, fieldTypes, fieldNames, dict);
addField(vectorFields_, fieldTypes, fieldNames, dict);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::explicitSetValue::explicitSetValue
(
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
)
:
basicSource(name, modelType, dict, mesh),
coeffs_(dict.subDict(modelType + "Coeffs"))
{
setFieldData(coeffs_.subDict("fieldData"));
}
void Foam::explicitSetValue::setValue(fvMatrix<scalar>& Eqn)
{
setFieldValue(Eqn, scalarFields_[Eqn.psi().name()]);
}
void Foam::explicitSetValue::setValue(fvMatrix<vector>& Eqn)
{
setFieldValue(Eqn, vectorFields_[Eqn.psi().name()]);
makeBasicSource(ExplicitSetValue, scalar);
makeBasicSource(ExplicitSetValue, vector);
makeBasicSource(ExplicitSetValue, sphericalTensor);
makeBasicSource(ExplicitSetValue, symmTensor);
makeBasicSource(ExplicitSetValue, tensor);
}

View File

@ -1,105 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
template <class Type>
void Foam::explicitSetValue::setFieldValue
(
fvMatrix<Type>& Eqn,
const Type& value
) const
{
Type data = value;
DimensionedField<Type, volMesh> rhs
(
IOobject
(
"rhs",
Eqn.psi().mesh().time().timeName(),
Eqn.psi().mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
Eqn.psi().mesh(),
dimensioned<Type>
(
"zero",
dimless,
pTraits<Type>::zero
)
);
List<Type> values(this->cells().size());
forAll (values, i)
{
values[i] = data;
}
Eqn.setValues(this->cells(), values);
}
template <class Type>
void Foam::explicitSetValue::addField
(
HashTable<Type>& fields,
const wordList& fieldTypes,
const wordList& fieldNames,
const dictionary& fieldDataDict
)
{
typedef GeometricField<Type, fvPatchField, volMesh> geometricField;
forAll (fieldTypes, fieldI)
{
word fieldName = fieldNames[fieldI];
word fieldType = fieldTypes[fieldI];
if
(
(
fieldType
== GeometricField<Type, fvPatchField, volMesh>::typeName
) &&
(
this->mesh().foundObject<geometricField>(fieldName)
)
)
{
Type fieldValue = fieldDataDict.lookupOrDefault<Type>
(
fieldName,
pTraits<Type>::zero
);
fields.insert(fieldName, fieldValue);
}
}
}
// ************************************************************************* //

View File

@ -0,0 +1,190 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "ExplicitSource.H"
#include "fvMesh.H"
#include "fvMatrices.H"
#include "DimensionedField.H"
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
template<class Type>
const Foam::wordList Foam::ExplicitSource<Type>::
volumeModeTypeNames_
(
IStringStream("(absolute specific)")()
);
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class Type>
typename Foam::ExplicitSource<Type>::volumeModeType
Foam::ExplicitSource<Type>::wordToVolumeModeType
(
const word& vmtName
) const
{
forAll(volumeModeTypeNames_, i)
{
if (vmtName == volumeModeTypeNames_[i])
{
return volumeModeType(i);
}
}
FatalErrorIn
(
"ExplicitSource<Type>::volumeModeType"
"ExplicitSource<Type>::wordToVolumeModeType(const word&)"
) << "Unknown volumeMode type " << vmtName
<< ". Valid volumeMode types are:" << nl << volumeModeTypeNames_
<< exit(FatalError);
return volumeModeType(0);
}
template<class Type>
Foam::word Foam::ExplicitSource<Type>::volumeModeTypeToWord
(
const volumeModeType& vmtType
) const
{
if (vmtType > volumeModeTypeNames_.size())
{
return "UNKNOWN";
}
else
{
return volumeModeTypeNames_[vmtType];
}
}
template<class Type>
void Foam::ExplicitSource<Type>::setFieldData(const dictionary& dict)
{
fieldData_.setSize(dict.toc().size());
label i = 0;
forAllConstIter(dictionary, dict, iter)
{
fieldData_[i].first() = iter().keyword();
dict.lookup(iter().keyword()) >> fieldData_[i].second();
i++;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::ExplicitSource<Type>::ExplicitSource
(
const word& name,
const word& modelType,
const dictionary& coeffs,
const fvMesh& mesh
)
:
basicSource(name, modelType, coeffs, mesh),
volumeMode_(wordToVolumeModeType(coeffs_.lookup("volumeMode"))),
VDash_(1.0),
fieldData_()
{
setFieldData(coeffs_.subDict("fieldData"));
// Set volume normalisation
if (volumeMode_ == vmAbsolute)
{
VDash_ = V_;
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::label Foam::ExplicitSource<Type>::applyToField
(
const word& fieldName
) const
{
forAll(fieldData_, i)
{
if (fieldData_[i].first() == fieldName)
{
return i;
}
}
return -1;
}
template<class Type>
void Foam::ExplicitSource<Type>::addSup
(
fvMatrix<Type>& eqn,
const label fieldI
)
{
if (debug)
{
Info<< "ExplicitSource<"<< pTraits<Type>::typeName
<< ">::addSup for source " << name_ << endl;
}
DimensionedField<Type, volMesh> Su
(
IOobject
(
name_ + fieldData_[fieldI].first() + "Sup",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensioned<Type>
(
"zero",
eqn.dimensions()/dimVolume,
pTraits<Type>::zero
),
false
);
forAll(cells_, i)
{
Su[cells_[i]] = fieldData_[fieldI].second()/VDash_;
}
eqn -= Su;
}
// ************************************************************************* //

View File

@ -22,39 +22,37 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::explicitSource
Foam::ExplicitSource
Description
Explicit source.
Explicit source
Sources described by:
explicitSourceCoeffs
{
points // list of points when selectionMode = points
(
(-0.088 0.007 -0.02)
(-0.028 0.007 -0.02)
);
volumeMode specific; //absolute
fieldData // field data - usage for multiple fields
<Type>ExplicitSourceCoeffs
{
k 30.7;
epsilon 1.5;
volumeMode absolute; // specific
fieldData
{
k 30.7;
epsilon 1.5;
}
}
}
If volumeMode =
- absolute: values are given as <quantity>
- specific: values are given as <quantity>/m3
SourceFiles
explicitSource.C
ExplicitSource.C
\*---------------------------------------------------------------------------*/
#ifndef explicitSource_H
#define explicitSource_H
#ifndef ExplicitSource_H
#define ExplicitSource_H
#include "cellSet.H"
#include "volFieldsFwd.H"
#include "DimensionedField.H"
#include "Tuple2.H"
#include "basicSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -62,35 +60,31 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
class fvMesh;
template<class Type>
class ExplicitSource;
// Forward declaration of friend functions
template<class Type>
Ostream& operator<<
(
Ostream&,
const ExplicitSource<Type>&
);
/*---------------------------------------------------------------------------*\
Class explicitSource Declaration
Class ExplicitSource Declaration
\*---------------------------------------------------------------------------*/
class explicitSource
template<class Type>
class ExplicitSource
:
public basicSource
{
// Private data
//- List of field types
HashTable<scalar> scalarFields_;
HashTable<vector> vectorFields_;
//- Add source to matrix
template<class Type>
void addSource(fvMatrix<Type>&, const Type&) const;
//- Add field names and values to field table for types.
template<class Type>
void addField
(
HashTable<Type>& fields,
const wordList& fieldTypes,
const wordList& fieldNames,
const dictionary& dict
);
public:
// Public data
@ -103,22 +97,33 @@ public:
};
//- Word list of volume mode type names
static const NamedEnum<volumeModeType, 2> volumeModeTypeNames_;
static const wordList volumeModeTypeNames_;
protected:
// Protected data
//- Coefficients dictionary
dictionary coeffs_;
typedef Tuple2<word, Type> fieldNameValuePair;
//- Volume mode
volumeModeType volumeMode_;
//- Volume normalisation
scalar VDash_;
//- Source value per field
List<fieldNameValuePair> fieldData_;
// Protected functions
//- Helper function to convert from a word to a volumeModeType
volumeModeType wordToVolumeModeType(const word& vtName) const;
//- Helper function to convert from a volumeModeType to a word
word volumeModeTypeToWord(const volumeModeType& vtType) const;
//- Set the local field data
void setFieldData(const dictionary& dict);
@ -126,13 +131,13 @@ protected:
public:
//- Runtime type information
TypeName("explicitSource");
TypeName("ExplicitSource");
// Constructors
//- Construct from components
explicitSource
ExplicitSource
(
const word& name,
const word& modelType,
@ -140,42 +145,37 @@ public:
const fvMesh& mesh
);
//- Return clone
autoPtr<explicitSource> clone() const
{
notImplemented
(
"autoPtr<explicitSource> clone() const"
);
return autoPtr<explicitSource>(NULL);
}
// Member Functions
// Check
//- Return index of field name if found in fieldNames list
virtual label applyToField(const word& fieldName) const;
// Access
//- Return const access to the volume mode
inline const volumeModeType& volumeMode() const;
//- Return const access to the source field value
inline const Type& fieldData() const;
// Edit
//- Return access to the volume mode
inline volumeModeType& volumeMode();
//- Return points
inline const List<point>& points() const;
//- Return access to the source field value
inline Type& fieldData();
// Evaluation
//-Source term to fvMatrix<vector>
virtual void addSu(fvMatrix<vector>& UEqn);
//-Source term to fvMatrix<scalar>
virtual void addSu(fvMatrix<scalar>& UEqn);
//- Add explicit contribution to equation
virtual void addSup(fvMatrix<Type>& eqn, const label fieldI);
// I-O
@ -183,15 +183,8 @@ public:
//- Write the source properties
virtual void writeData(Ostream&) const;
//- Read fieldData in sub-dictionary
//- Read source dictionary
virtual bool read(const dictionary& dict);
//- Ostream operator
friend Ostream& operator<<
(
Ostream& os,
const explicitSource& source
);
};
@ -201,14 +194,14 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "explicitSourceIO.C"
#include "explicitSourceI.H"
#ifdef NoRepository
# include "ExplicitSource.C"
# include "ExplicitSourceIO.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "explicitSourceTemplates.C"
#endif
#include "ExplicitSourceI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -23,14 +23,37 @@ License
\*---------------------------------------------------------------------------*/
#include "explicitSetValue.H"
#include "ExplicitSource.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::List<Foam::point>&
Foam::explicitSetValue::points() const
template<class Type>
inline const typename Foam::ExplicitSource<Type>::volumeModeType&
Foam::ExplicitSource<Type>::volumeMode() const
{
return points_;
return volumeMode_;
}
template<class Type>
inline const Type& Foam::ExplicitSource<Type>::fieldData() const
{
return fieldData_;
}
template<class Type>
inline typename Foam::ExplicitSource<Type>::volumeModeType&
Foam::ExplicitSource<Type>::volumeMode()
{
return volumeMode_;
}
template<class Type>
inline Type& Foam::ExplicitSource<Type>::fieldData()
{
return fieldData_;
}

View File

@ -23,28 +23,29 @@ License
\*---------------------------------------------------------------------------*/
#include "explicitSource.H"
#include "ExplicitSource.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::explicitSource::volumeModeType&
Foam::explicitSource::volumeMode() const
template<class Type>
void Foam::ExplicitSource<Type>::writeData(Ostream& os) const
{
return volumeMode_;
notImplemented
(
"void Foam::ExplicitSource<Type>::read(Ostream&) const"
);
}
inline Foam::explicitSource::volumeModeType&
Foam::explicitSource::volumeMode()
template<class Type>
bool Foam::ExplicitSource<Type>::read(const dictionary& dict)
{
return volumeMode_;
}
notImplemented
(
"bool Foam::ExplicitSource<Type>::read(const dictionary&)"
);
inline const Foam::List<Foam::point>&
Foam::explicitSource::points() const
{
return points_;
return false;
}

View File

@ -23,111 +23,18 @@ License
\*---------------------------------------------------------------------------*/
#include "explicitSource.H"
#include "fvMesh.H"
#include "volFields.H"
#include "addToRunTimeSelectionTable.H"
#include "HashSet.H"
#include "makeBasicSource.H"
#include "ExplicitSource.H"
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(explicitSource, 0);
addToRunTimeSelectionTable
(
basicSource,
explicitSource,
dictionary
);
// * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
template<> const char* NamedEnum
<
explicitSource::volumeModeType,
2
>::names[] =
{
"absolute",
"specific"
};
const NamedEnum<explicitSource::volumeModeType, 2>
explicitSource::volumeModeTypeNames_;
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::explicitSource::setFieldData(const dictionary& dict)
{
scalarFields_.clear();
vectorFields_.clear();
wordList fieldTypes(dict.toc().size());
wordList fieldNames(dict.toc().size());
forAll(dict.toc(), i)
{
const word& fieldName = dict.toc()[i];
IOobject io
(
fieldName,
this->mesh().time().timeName(),
this->mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
);
if (io.headerOk())
{
fieldTypes[i] = io.headerClassName();
fieldNames[i] = dict.toc()[i];
}
else
{
FatalErrorIn
(
"explicitSource::setFieldData"
) << "header not OK " << io.name()
<< exit(FatalError);
}
}
addField(scalarFields_, fieldTypes, fieldNames, dict);
addField(vectorFields_, fieldTypes, fieldNames, dict);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::explicitSource::explicitSource
(
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
)
:
basicSource(name, modelType, dict, mesh),
coeffs_(dict.subDict(modelType + "Coeffs")),
volumeMode_(volumeModeTypeNames_.read(coeffs_.lookup("volumeMode")))
{
setFieldData(dict_.subDict("fieldData"));
}
void Foam::explicitSource::addSu(fvMatrix<scalar>& Eqn)
{
addSource(Eqn, scalarFields_[Eqn.psi().name()]);
}
void Foam::explicitSource::addSu(fvMatrix<vector>& Eqn)
{
addSource(Eqn, vectorFields_[Eqn.psi().name()]);
makeBasicSource(ExplicitSource, scalar);
makeBasicSource(ExplicitSource, vector);
makeBasicSource(ExplicitSource, sphericalTensor);
makeBasicSource(ExplicitSource, symmTensor);
makeBasicSource(ExplicitSource, tensor);
}

View File

@ -1,104 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
template <class Type>
void Foam::explicitSource::addSource
(
fvMatrix<Type>& Eqn,
const Type& sourceData
) const
{
Type data = sourceData;
if (volumeMode_ == vmAbsolute)
{
// Convert to specific quantity
data /= V_;
}
DimensionedField<Type, volMesh> rhs
(
IOobject
(
"rhs",
Eqn.psi().mesh().time().timeName(),
Eqn.psi().mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
Eqn.psi().mesh(),
dimensioned<Type>
(
"zero",
Eqn.dimensions()/dimVolume,
pTraits<Type>::zero
)
);
UIndirectList<Type>(rhs, this->cells()) = data;
Eqn -= rhs;
}
template <class Type>
void Foam::explicitSource::addField
(
HashTable<Type>& fields,
const wordList& fieldTypes,
const wordList& fieldNames,
const dictionary& fieldDataDict
)
{
typedef GeometricField<Type, fvPatchField, volMesh> geometricField;
forAll (fieldTypes, fieldI)
{
word fieldName = fieldNames[fieldI];
word fieldType = fieldTypes[fieldI];
if
(
(
fieldType
== GeometricField<Type, fvPatchField, volMesh>::typeName
) &&
(
this->mesh().foundObject<geometricField>(fieldName)
)
)
{
Type fieldValue = fieldDataDict.lookupOrDefault<Type>
(
fieldName,
pTraits<Type>::zero
);
fields.insert(fieldName, fieldValue);
}
}
}
// ************************************************************************* //

View File

@ -0,0 +1,202 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "pressureGradientExplicitSource.H"
#include "fvMatrices.H"
#include "DimensionedField.H"
#include "IFstream.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(pressureGradientExplicitSource, 0);
addToRunTimeSelectionTable
(
basicSource,
pressureGradientExplicitSource,
dictionary
);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::pressureGradientExplicitSource::writeGradP() const
{
// Only write on output time
if (mesh_.time().outputTime())
{
IOdictionary propsDict
(
IOobject
(
name_ + "Properties",
mesh_.time().timeName(),
"uniform",
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
)
);
propsDict.add("gradient", gradP_);
propsDict.regIOobject::write();
}
}
void Foam::pressureGradientExplicitSource::update()
{
volVectorField& U = const_cast<volVectorField&>
(
mesh_.lookupObject<volVectorField>(UName_)
);
const volScalarField& rAU =
mesh_.lookupObject<volScalarField>("(1|A(" + UName_ + "))");
// Integrate flow variables over cell set
scalar magUbarAve = 0.0;
scalar rAUave = 0.0;
const scalarField& cv = mesh_.V();
forAll(cells_, i)
{
label cellI = cells_[i];
scalar volCell = cv[cellI];
magUbarAve += (flowDir_ & U[cellI])*volCell;
rAUave += rAU[cellI]*volCell;
}
// Collect across all processors
reduce(magUbarAve, sumOp<scalar>());
// Volume averages
magUbarAve /= V_;
rAUave /= V_;
// Calculate the pressure gradient increment needed to adjust the average
// flow-rate to the desired value
scalar gradPplus = (mag(Ubar_) - magUbarAve)/rAUave;
// Apply correction to velocity field
forAll(cells_, i)
{
label cellI = cells_[i];
U[cellI] += flowDir_*rAU[cellI]*gradPplus;
}
// Update pressure gradient
gradP_.value() += gradPplus;
Info<< "Uncorrected Ubar = " << magUbarAve << tab
<< "Pressure gradient = " << gradP_.value() << endl;
writeGradP();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::pressureGradientExplicitSource::pressureGradientExplicitSource
(
const word& sourceName,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
)
:
basicSource(sourceName, modelType, dict, mesh),
UName_(coeffs_.lookupOrDefault<word>("UName", "U")),
Ubar_(coeffs_.lookup("Ubar")),
gradPini_(coeffs_.lookup("gradPini")),
gradP_(gradPini_),
flowDir_(Ubar_/mag(Ubar_))
{
// Read the initial pressure gradient from file if it exists
IFstream propsFile
(
mesh_.time().timeName()/"uniform"/(name_ + "Properties")
);
if (propsFile.good())
{
Info<< " Reading pressure gradient from file" << endl;
dictionary propsDict(dictionary::null, propsFile);
propsDict.lookup("gradient") >> gradP_;
}
Info<< " Initial pressure gradient = " << gradP_ << nl << endl;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::label Foam::pressureGradientExplicitSource::applyToField
(
const word& fieldName
) const
{
if (fieldName == UName_)
{
return 0;
}
else
{
return -1;
}
}
void Foam::pressureGradientExplicitSource::addSup
(
fvMatrix<vector>& eqn,
const label
)
{
update();
DimensionedField<vector, volMesh> Su
(
IOobject
(
name_ + UName_ + "Sup",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedVector("zero", gradP_.dimensions(), vector::zero)
);
UIndirectList<vector>(Su, cells_) = flowDir_*gradP_.value();
eqn -= Su;
}
// ************************************************************************* //

View File

@ -0,0 +1,154 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::pressureGradientExplicitSource
Description
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] 0; // initial pressure gradient
flowDir (1 0 0); // flow direction
}
SourceFiles
pressureGradientExplicitSource.C
\*---------------------------------------------------------------------------*/
#ifndef pressureGradientExplicitSource_H
#define pressureGradientExplicitSource_H
#include "autoPtr.H"
#include "topoSetSource.H"
#include "cellSet.H"
#include "fvMesh.H"
#include "volFields.H"
#include "basicSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class pressureGradientExplicitSource Declaration
\*---------------------------------------------------------------------------*/
class pressureGradientExplicitSource
:
public basicSource
{
// Private data
//- Velocity field name
word UName_;
//- Average velocity
vector Ubar_;
//- Initial pressure gradient
dimensionedScalar gradPini_;
//- Pressure gradient
dimensionedScalar gradP_;
//- Flow direction
vector flowDir_;
// Private Member Functions
//- Write the pressure gradient to file (for restarts etc)
void writeGradP() const;
//- Correct driving force for a constant mass flow rate
void update();
//- Disallow default bitwise copy construct
pressureGradientExplicitSource(const pressureGradientExplicitSource&);
//- Disallow default bitwise assignment
void operator=(const pressureGradientExplicitSource&);
public:
//- Runtime type information
TypeName("pressureGradientExplicitSource");
// Constructors
//- Construct from explicit source name and mesh
pressureGradientExplicitSource
(
const word& sourceName,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
);
// Member Functions
// Checks
//- Return index of field name if found in fieldNames list
virtual label applyToField(const word& fieldName) const;
// Access
//- Add explicit contribution to equation
virtual void addSup(fvMatrix<vector>& eqn, const label fieldI);
// I-O
//- Write the source properties
virtual void writeData(Ostream&) const;
//- Read source dictionary
virtual bool read(const dictionary& dict);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,56 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "pressureGradientExplicitSource.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::pressureGradientExplicitSource::writeData(Ostream& os) const
{
notImplemented
(
"void Foam::pressureGradientExplicitSource::writeData"
"("
"Ostream&"
") const"
);
}
bool Foam::pressureGradientExplicitSource::read(const dictionary& dict)
{
notImplemented
(
"bool Foam::pressureGradientExplicitSource::read"
"("
"const dictionary&"
") const"
);
return false;
}
// ************************************************************************* //

View File

@ -53,30 +53,31 @@ Foam::radialActuationDiskSource::radialActuationDiskSource
)
:
actuationDiskSource(name, modelType, dict, mesh),
coeffsDict_(dict.subDict(modelType + "Coeffs")),
coeffs_()
radialCoeffs_(coeffs_.lookup("coeffs"))
{
coeffsDict_.lookup("coeffs") >> coeffs_;
Info<< " - creating radial actuation disk zone: "
<< this->name() << endl;
Info<< " - creating radial actuation disk zone: " << name_ << endl;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::radialActuationDiskSource::addSu(fvMatrix<vector>& UEqn)
void Foam::radialActuationDiskSource::addSup
(
fvMatrix<vector>& eqn,
const label
)
{
bool compressible = false;
if (UEqn.dimensions() == dimensionSet(1, 1, -2, 0, 0))
if (eqn.dimensions() == dimForce)
{
compressible = true;
}
const scalarField& cellsV = this->mesh().V();
vectorField& Usource = UEqn.source();
const vectorField& U = UEqn.psi();
const scalarField& cellsV = mesh_.V();
vectorField& Usource = eqn.source();
const vectorField& U = eqn.psi();
if (V() > VSMALL)
if (V_ > VSMALL)
{
if (compressible)
{
@ -85,7 +86,7 @@ void Foam::radialActuationDiskSource::addSu(fvMatrix<vector>& UEqn)
Usource,
cells_,
cellsV,
this->mesh().lookupObject<volScalarField>("rho"),
mesh_.lookupObject<volScalarField>("rho"),
U
);
}
@ -114,12 +115,11 @@ bool Foam::radialActuationDiskSource::read(const dictionary& dict)
{
if (basicSource::read(dict))
{
const dictionary& coeffsDict_ = dict.subDict(typeName + "Coeffs");
coeffsDict_.readIfPresent("diskDir", diskDir_);
coeffsDict_.readIfPresent("Cp", Cp_);
coeffsDict_.readIfPresent("Ct", Ct_);
coeffsDict_.readIfPresent("diskArea", diskArea_);
coeffsDict_.lookup("coeffs") >> coeffs_;
coeffs_.readIfPresent("diskDir", diskDir_);
coeffs_.readIfPresent("Cp", Cp_);
coeffs_.readIfPresent("Ct", Ct_);
coeffs_.readIfPresent("diskArea", diskArea_);
coeffs_.lookup("coeffs") >> radialCoeffs_;
return true;
}
else

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"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -71,11 +83,8 @@ class radialActuationDiskSource
{
// Private data
//- Coefficients dictionary
dictionary coeffsDict_;
//- Coeffcients for the radial distribution
FixedList<scalar, 3> coeffs_;
FixedList<scalar, 3> radialCoeffs_;
// Private Member Functions
@ -124,7 +133,7 @@ public:
// Public Functions
//- Source term to fvMatrix<vector>
virtual void addSu(fvMatrix<vector>& UEqn);
virtual void addSup(fvMatrix<vector>& eqn, const label fieldI);
// I-O

View File

@ -61,24 +61,25 @@ addRadialActuationDiskAxialInertialResistance
const scalar maxR = gMax(mag(zoneCellCentres - avgCentre));
scalar intCoeffs =
coeffs_[0]
+ coeffs_[1]*sqr(maxR)/2.0
+ coeffs_[2]*pow4(maxR)/3.0;
radialCoeffs_[0]
+ radialCoeffs_[1]*sqr(maxR)/2.0
+ radialCoeffs_[2]*pow4(maxR)/3.0;
forAll(cells, i)
{
T[i] = 2.0*rho[cells[i]]*diskArea_*mag(U[cells[i]])*a/(1.0 - a);
scalar r = mag(mesh().cellCentres()[cells[i]] - avgCentre);
scalar r2 = magSqr(mesh().cellCentres()[cells[i]] - avgCentre);
Tr[i] =
T[i]*(coeffs_[0] + coeffs_[1]*sqr(r) + coeffs_[2]*pow4(r))
T[i]
*(radialCoeffs_[0] + radialCoeffs_[1]*r2 + radialCoeffs_[2]*sqr(r2))
/intCoeffs;
}
forAll(cells, i)
{
Usource[cells[i]] += ((Vcells[cells[i]]/V())*Tr[i]*E) & U[cells[i]];
Usource[cells[i]] += ((Vcells[cells[i]]/V_)*Tr[i]*E) & U[cells[i]];
}
if (debug)

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;
@ -262,10 +263,8 @@ void Foam::rotorDiskSource::createCoordinateSystem()
}
default:
{
FatalErrorIn
(
"rotorDiskSource::createCoordinateSystem(const geometryMode&);"
) << "Unknown geometryMode " << geometryModeTypeNames_[gm]
FatalErrorIn("rotorDiskSource::createCoordinateSystem()")
<< "Unknown geometryMode " << geometryModeTypeNames_[gm]
<< ". Available geometry modes include "
<< geometryModeTypeNames_ << exit(FatalError);
}
@ -369,7 +368,7 @@ Foam::rotorDiskSource::rotorDiskSource
)
:
basicSource(name, modelType, dict, mesh),
coeffs_(dict_.subDict(type() + "Coeffs")),
fieldName_(coeffs_.lookup("fieldName")),
rhoName_("none"),
omega_(0.0),
nBlades_(0),
@ -399,20 +398,33 @@ Foam::rotorDiskSource::~rotorDiskSource()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::rotorDiskSource::addSu(fvMatrix<vector>& UEqn)
Foam::label Foam::rotorDiskSource::applyToField(const word& fieldName) const
{
if (fieldName == fieldName_)
{
return 0;
}
else
{
return -1;
}
}
void Foam::rotorDiskSource::addSup(fvMatrix<vector>& eqn)
{
// add source to lhs of eqn
const volVectorField& U = UEqn.psi();
const volVectorField& U = eqn.psi();
if (UEqn.dimensions() == dimForce)
if (eqn.dimensions() == dimForce)
{
coeffs_.lookup("rhoName") >> rhoName_;
const volScalarField& rho =
mesh_.lookupObject<volScalarField>(rhoName_);
UEqn += calculateForces
eqn += calculateForces
(
rho.internalField(),
inflowVelocity(U),
@ -421,7 +433,7 @@ void Foam::rotorDiskSource::addSu(fvMatrix<vector>& UEqn)
}
else
{
UEqn += calculateForces
eqn += calculateForces
(
oneField(),
inflowVelocity(U),
@ -431,12 +443,6 @@ void Foam::rotorDiskSource::addSu(fvMatrix<vector>& UEqn)
}
void Foam::rotorDiskSource::addSu(fvMatrix<scalar>& UEqn)
{
// do nothing
}
void Foam::rotorDiskSource::writeData(Ostream& os) const
{
os << indent << name_ << endl;
@ -448,8 +454,6 @@ bool Foam::rotorDiskSource::read(const dictionary& dict)
{
if (basicSource::read(dict))
{
coeffs_ = dict.subDict(type() + "Coeffs");
scalar rpm(readScalar(coeffs_.lookup("rpm")));
omega_ = rpm/60.0*mathematical::twoPi;

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"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -97,8 +149,8 @@ protected:
// Protected data
//- Coefficients dictionary
dictionary coeffs_;
//- Name of field on which to apply the source
word fieldName_;
//- Name of density field
word rhoName_;
@ -212,13 +264,16 @@ public:
// Member Functions
// Checks
//- Return index of field name if found in fieldNames list
virtual label applyToField(const word& fieldName) const;
// Source term addition
//- Source term to fvMatrix<vector>
virtual void addSu(fvMatrix<vector>& UEqn);
//- Source term to fvMatrix<scalar>
virtual void addSu(fvMatrix<scalar>& UEqn);
virtual void addSup(fvMatrix<vector>& eqn);
// I-O

View File

@ -27,6 +27,7 @@ License
#include "addToRunTimeSelectionTable.H"
#include "mathematicalConstants.H"
#include "unitConversion.H"
#include "volFields.H"
using namespace Foam::constant;
@ -175,9 +176,9 @@ Foam::tmp<Foam::volVectorField> Foam::rotorDiskSource::calculateForces
}
// calculate forces
scalar pDyn = 0.5*rho[cellI]*sqr(magUc);
scalar f = pDyn*chord*nBlades_*area_[i]/(mathematical::twoPi);
vector localForce = vector(0.0, f*Cd, tipFactor*f*Cl);
const scalar pDyn = 0.5*rho[cellI]*sqr(magUc);
const scalar f = pDyn*chord*nBlades_*area_[i]/(mathematical::twoPi);
const vector localForce(0.0, f*Cd, tipFactor*f*Cl);
// accumulate forces
dragEff += localForce.y();