mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' of ssh://dm/home/dm4/OpenFOAM/OpenFOAM-dev
This commit is contained in:
@ -26,6 +26,7 @@ License
|
||||
#include "zone.H"
|
||||
#include "IOstream.H"
|
||||
#include "demandDrivenData.H"
|
||||
#include "HashSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -192,6 +193,9 @@ bool Foam::zone::checkDefinition(const label maxSize, const bool report) const
|
||||
|
||||
bool hasError = false;
|
||||
|
||||
// To check for duplicate entries
|
||||
labelHashSet elems(size());
|
||||
|
||||
forAll(addr, i)
|
||||
{
|
||||
if (addr[i] < 0 || addr[i] >= maxSize)
|
||||
@ -215,6 +219,18 @@ bool Foam::zone::checkDefinition(const label maxSize, const bool report) const
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (!elems.insert(addr[i]))
|
||||
{
|
||||
if (report)
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"bool zone::checkDefinition("
|
||||
"const label maxSize, const bool report) const"
|
||||
) << "Zone " << name_
|
||||
<< " contains duplicate index label " << addr[i] << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return hasError;
|
||||
|
||||
@ -80,12 +80,14 @@ 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"))),
|
||||
diskArea_(readScalar(coeffs_.lookup("diskArea")))
|
||||
{
|
||||
coeffs_.lookup("fieldNames") >> fieldNames_;
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
|
||||
Info<< " - creating actuation disk zone: "
|
||||
<< this->name() << endl;
|
||||
|
||||
@ -95,20 +97,6 @@ Foam::actuationDiskSource::actuationDiskSource
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::label Foam::actuationDiskSource::applyToField
|
||||
(
|
||||
const word& fieldName
|
||||
) const
|
||||
{
|
||||
if (fieldName == fieldName_)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void Foam::actuationDiskSource::addSup
|
||||
(
|
||||
fvMatrix<vector>& eqn,
|
||||
@ -150,8 +138,6 @@ void Foam::actuationDiskSource::addSup
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
basicSource::addSup(eqn, fieldI);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@ Description
|
||||
|
||||
actuationDiskSourceCoeffs
|
||||
{
|
||||
fieldName U; // name of field to apply source
|
||||
fieldNames (U); // names of fields to apply source
|
||||
diskDir (-1 0 0); // disk direction
|
||||
Cp 0.1; // power coefficient
|
||||
Ct 0.5; // thrust coefficient
|
||||
@ -80,9 +80,6 @@ protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Name of field to apply source upon
|
||||
word fieldName_;
|
||||
|
||||
//- Disk area normal
|
||||
vector diskDir_;
|
||||
|
||||
@ -146,12 +143,6 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Check
|
||||
|
||||
//- Return index of field name if found in fieldNames list
|
||||
virtual label applyToField(const word& fieldName) const;
|
||||
|
||||
|
||||
// Access
|
||||
|
||||
//- Return Cp
|
||||
|
||||
@ -201,7 +201,6 @@ Foam::basicSource::basicSource
|
||||
dict_(dict),
|
||||
coeffs_(dict.subDict(modelType + "Coeffs")),
|
||||
active_(readBool(dict_.lookup("active"))),
|
||||
applied_(false),
|
||||
timeStart_(readScalar(dict_.lookup("timeStart"))),
|
||||
duration_(readScalar(dict_.lookup("duration"))),
|
||||
selectionMode_
|
||||
@ -209,7 +208,9 @@ Foam::basicSource::basicSource
|
||||
selectionModeTypeNames_.read(dict_.lookup("selectionMode"))
|
||||
),
|
||||
cellSetName_("none"),
|
||||
V_(0.0)
|
||||
V_(0.0),
|
||||
fieldNames_(),
|
||||
applied_()
|
||||
{
|
||||
setSelection(dict_);
|
||||
|
||||
@ -228,7 +229,7 @@ Foam::autoPtr<Foam::basicSource> Foam::basicSource::New
|
||||
{
|
||||
word modelType(coeffs.lookup("type"));
|
||||
|
||||
Info<< "Selecting model type " << modelType << endl;
|
||||
Info<< "Selecting source model type " << modelType << endl;
|
||||
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(modelType);
|
||||
@ -275,15 +276,43 @@ bool Foam::basicSource::isActive()
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::basicSource::applyToField(const word& fieldName) const
|
||||
{
|
||||
forAll(fieldNames_, i)
|
||||
{
|
||||
if (fieldNames_[i] == fieldName)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void Foam::basicSource::checkApplied() const
|
||||
{
|
||||
forAll(applied_, i)
|
||||
{
|
||||
if (!applied_[i])
|
||||
{
|
||||
WarningIn("void Foam::basicSource::checkApplied() const")
|
||||
<< "Source " << name_ << " defined for field "
|
||||
<< fieldNames_[i] << " but never used" << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::basicSource::addSup(fvMatrix<scalar>& eqn, const label fieldI)
|
||||
{
|
||||
applied_ = true;
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::basicSource::addSup(fvMatrix<vector>& eqn, const label fieldI)
|
||||
{
|
||||
applied_ = true;
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
@ -293,31 +322,31 @@ void Foam::basicSource::addSup
|
||||
const label fieldI
|
||||
)
|
||||
{
|
||||
applied_ = true;
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::basicSource::addSup(fvMatrix<symmTensor>& eqn, const label fieldI)
|
||||
{
|
||||
applied_ = true;
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::basicSource::addSup(fvMatrix<tensor>& eqn, const label fieldI)
|
||||
{
|
||||
applied_ = true;
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::basicSource::setValue(fvMatrix<scalar>& eqn, const label fieldI)
|
||||
{
|
||||
applied_ = true;
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::basicSource::setValue(fvMatrix<vector>& eqn, const label fieldI)
|
||||
{
|
||||
applied_ = true;
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
@ -327,7 +356,7 @@ void Foam::basicSource::setValue
|
||||
const label fieldI
|
||||
)
|
||||
{
|
||||
applied_ = true;
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
@ -337,13 +366,13 @@ void Foam::basicSource::setValue
|
||||
const label fieldI
|
||||
)
|
||||
{
|
||||
applied_ = true;
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::basicSource::setValue(fvMatrix<tensor>& eqn, const label fieldI)
|
||||
{
|
||||
applied_ = true;
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -97,9 +97,6 @@ protected:
|
||||
//- Source active flag
|
||||
bool active_;
|
||||
|
||||
//- Flag to indicate whether or not the source has been applied
|
||||
bool applied_;
|
||||
|
||||
//- Time start
|
||||
scalar timeStart_;
|
||||
|
||||
@ -121,6 +118,12 @@ protected:
|
||||
//- Sum of cell volumes
|
||||
scalar V_;
|
||||
|
||||
//- Field names to apply source to - populated by derived models
|
||||
wordList fieldNames_;
|
||||
|
||||
//- Applied flag list - corresponds to each fieldNames_ entry
|
||||
List<bool> applied_;
|
||||
|
||||
|
||||
// Protected functions
|
||||
|
||||
@ -242,9 +245,6 @@ public:
|
||||
//- Return const access to the source active flag
|
||||
inline bool active() const;
|
||||
|
||||
//- Return const access to the applied flag
|
||||
inline bool applied() const;
|
||||
|
||||
//- Return const access to the time start
|
||||
inline scalar timeStart() const;
|
||||
|
||||
@ -267,6 +267,9 @@ public:
|
||||
//- Return const access to the cell set
|
||||
inline const labelList& cells() const;
|
||||
|
||||
//- Set the applied flag to true for field index fieldI
|
||||
inline void setApplied(const label fieldI);
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
@ -283,10 +286,13 @@ public:
|
||||
// Checks
|
||||
|
||||
//- Is the source active?
|
||||
bool isActive();
|
||||
virtual bool isActive();
|
||||
|
||||
//- Return index of field name if found in fieldNames list
|
||||
virtual label applyToField(const word& fieldName) const = 0;
|
||||
virtual label applyToField(const word& fieldName) const;
|
||||
|
||||
//- Check that the source has been applied
|
||||
virtual void checkApplied() const;
|
||||
|
||||
|
||||
// Evaluation
|
||||
|
||||
@ -51,12 +51,6 @@ inline bool Foam::basicSource::active() const
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::basicSource::applied() const
|
||||
{
|
||||
return applied_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::basicSource::timeStart() const
|
||||
{
|
||||
return timeStart_;
|
||||
@ -100,6 +94,12 @@ inline const Foam::labelList& Foam::basicSource::cells() const
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::basicSource::setApplied(const label fieldI)
|
||||
{
|
||||
applied_[fieldI] = true;
|
||||
}
|
||||
|
||||
|
||||
inline bool& Foam::basicSource::active()
|
||||
{
|
||||
return active_;
|
||||
|
||||
@ -25,6 +25,8 @@ License
|
||||
|
||||
#include "basicSourceList.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "fvMesh.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -38,14 +40,12 @@ namespace Foam
|
||||
|
||||
void Foam::basicSourceList::checkApplied() const
|
||||
{
|
||||
forAll(*this, i)
|
||||
if (mesh_.time().timeIndex() == checkTimeIndex_)
|
||||
{
|
||||
const basicSource& bs = this->operator[](i);
|
||||
|
||||
if (!bs.applied())
|
||||
forAll(*this, i)
|
||||
{
|
||||
WarningIn("void Foam::basicSourceList::checkApplied() const")
|
||||
<< "Source " << bs.name() << " defined, but not used" << endl;
|
||||
const basicSource& bs = this->operator[](i);
|
||||
bs.checkApplied();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -60,7 +60,8 @@ Foam::basicSourceList::basicSourceList
|
||||
)
|
||||
:
|
||||
PtrList<basicSource>(),
|
||||
mesh_(mesh)
|
||||
mesh_(mesh),
|
||||
checkTimeIndex_(mesh_.time().startTimeIndex() + 2)
|
||||
{
|
||||
label count = 0;
|
||||
forAllConstIter(dictionary, dict, iter)
|
||||
@ -95,6 +96,8 @@ Foam::basicSourceList::basicSourceList
|
||||
|
||||
bool Foam::basicSourceList::read(const dictionary& dict)
|
||||
{
|
||||
checkTimeIndex_ = mesh_.time().timeIndex() + 2;
|
||||
|
||||
bool allOk = true;
|
||||
forAll(*this, i)
|
||||
{
|
||||
@ -111,7 +114,7 @@ bool Foam::basicSourceList::writeData(Ostream& os) const
|
||||
// Write list contents
|
||||
forAll(*this, i)
|
||||
{
|
||||
os << nl;
|
||||
os << nl;
|
||||
this->operator[](i).writeData(os);
|
||||
}
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class basicSourceList Declaration
|
||||
Class basicSourceList Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class basicSourceList
|
||||
@ -59,6 +59,9 @@ private:
|
||||
//- Reference to the mesh database
|
||||
const fvMesh& mesh_;
|
||||
|
||||
//- Time index to check that all defined sources have been applied
|
||||
label checkTimeIndex_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
|
||||
@ -23,18 +23,12 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvMesh.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::basicSourceList::apply(fvMatrix<Type>& eqn)
|
||||
{
|
||||
if (mesh_.time().timeIndex() == mesh_.time().startTimeIndex() + 2)
|
||||
{
|
||||
checkApplied();
|
||||
}
|
||||
checkApplied();
|
||||
|
||||
const word& fieldName = eqn.psi().name();
|
||||
|
||||
@ -44,16 +38,21 @@ void Foam::basicSourceList::apply(fvMatrix<Type>& eqn)
|
||||
|
||||
label fieldI = source.applyToField(fieldName);
|
||||
|
||||
if (source.isActive() && (fieldI != -1))
|
||||
if (fieldI != -1)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Applying source " << source.name() << " to field "
|
||||
<< fieldName << endl;
|
||||
}
|
||||
source.setApplied(fieldI);
|
||||
|
||||
source.addSup(eqn, fieldI);
|
||||
source.setValue(eqn, fieldI);
|
||||
if (source.isActive())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Applying source " << source.name() << " to field "
|
||||
<< fieldName << endl;
|
||||
}
|
||||
|
||||
source.addSup(eqn, fieldI);
|
||||
source.setValue(eqn, fieldI);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,13 +33,16 @@ License
|
||||
template<class Type>
|
||||
void Foam::ExplicitSetValue<Type>::setFieldData(const dictionary& dict)
|
||||
{
|
||||
fieldData_.setSize(dict.toc().size());
|
||||
fieldNames_.setSize(dict.toc().size());
|
||||
fieldData_.setSize(fieldNames_.size());
|
||||
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
|
||||
label i = 0;
|
||||
forAllConstIter(dictionary, dict, iter)
|
||||
{
|
||||
fieldData_[i].first() = iter().keyword();
|
||||
dict.lookup(iter().keyword()) >> fieldData_[i].second();
|
||||
fieldNames_[i] = iter().keyword();
|
||||
dict.lookup(iter().keyword()) >> fieldData_[i];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@ -65,24 +68,6 @@ Foam::ExplicitSetValue<Type>::ExplicitSetValue
|
||||
|
||||
// * * * * * * * * * * * * * * * 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
|
||||
(
|
||||
@ -100,7 +85,7 @@ void Foam::ExplicitSetValue<Type>::setValue
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name_ + fieldData_[fieldI].first() + "rhs",
|
||||
name_ + fieldNames_[fieldI] + "rhs",
|
||||
eqn.psi().mesh().time().timeName(),
|
||||
eqn.psi().mesh(),
|
||||
IOobject::NO_READ,
|
||||
@ -120,12 +105,10 @@ void Foam::ExplicitSetValue<Type>::setValue
|
||||
|
||||
forAll(values, i)
|
||||
{
|
||||
values[i] = fieldData_[fieldI].second();
|
||||
values[i] = fieldData_[fieldI];
|
||||
}
|
||||
|
||||
eqn.setValues(cells_, values);
|
||||
|
||||
basicSource::setValue(eqn, fieldI);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -69,10 +69,8 @@ protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
typedef Tuple2<word, Type> fieldNameValuePair;
|
||||
|
||||
//- Source value per field
|
||||
List<fieldNameValuePair> fieldData_;
|
||||
List<Type> fieldData_;
|
||||
|
||||
|
||||
// Protected functions
|
||||
@ -101,12 +99,6 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Check
|
||||
|
||||
//- Return index of field name if found in fieldNames list
|
||||
virtual label applyToField(const word& fieldName) const;
|
||||
|
||||
|
||||
// Evaluation
|
||||
|
||||
//- Set value on vector field
|
||||
|
||||
@ -87,13 +87,16 @@ Foam::word Foam::ExplicitSource<Type>::volumeModeTypeToWord
|
||||
template<class Type>
|
||||
void Foam::ExplicitSource<Type>::setFieldData(const dictionary& dict)
|
||||
{
|
||||
fieldData_.setSize(dict.toc().size());
|
||||
fieldNames_.setSize(dict.toc().size());
|
||||
fieldData_.setSize(fieldNames_.size());
|
||||
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
|
||||
label i = 0;
|
||||
forAllConstIter(dictionary, dict, iter)
|
||||
{
|
||||
fieldData_[i].first() = iter().keyword();
|
||||
dict.lookup(iter().keyword()) >> fieldData_[i].second();
|
||||
fieldNames_[i] = iter().keyword();
|
||||
dict.lookup(iter().keyword()) >> fieldData_[i];
|
||||
i++;
|
||||
}
|
||||
|
||||
@ -127,24 +130,6 @@ Foam::ExplicitSource<Type>::ExplicitSource
|
||||
|
||||
// * * * * * * * * * * * * * * * 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
|
||||
(
|
||||
@ -152,7 +137,7 @@ void Foam::ExplicitSource<Type>::addSup
|
||||
const label fieldI
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
// if (debug)
|
||||
{
|
||||
Info<< "ExplicitSource<"<< pTraits<Type>::typeName
|
||||
<< ">::addSup for source " << name_ << endl;
|
||||
@ -162,7 +147,7 @@ void Foam::ExplicitSource<Type>::addSup
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name_ + fieldData_[fieldI].first() + "Sup",
|
||||
name_ + fieldNames_[fieldI] + "Sup",
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
@ -180,12 +165,10 @@ void Foam::ExplicitSource<Type>::addSup
|
||||
|
||||
forAll(cells_, i)
|
||||
{
|
||||
Su[cells_[i]] = fieldData_[fieldI].second()/VDash_;
|
||||
Su[cells_[i]] = fieldData_[fieldI]/VDash_;
|
||||
}
|
||||
|
||||
eqn -= Su;
|
||||
|
||||
basicSource::addSup(eqn, fieldI);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -104,16 +104,14 @@ protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
typedef Tuple2<word, Type> fieldNameValuePair;
|
||||
|
||||
//- Volume mode
|
||||
volumeModeType volumeMode_;
|
||||
|
||||
//- Volume normalisation
|
||||
scalar VDash_;
|
||||
|
||||
//- Source value per field
|
||||
List<fieldNameValuePair> fieldData_;
|
||||
//- Source field values
|
||||
List<Type> fieldData_;
|
||||
|
||||
|
||||
// Protected functions
|
||||
@ -148,19 +146,13 @@ public:
|
||||
|
||||
// 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;
|
||||
//- Return const access to the source field values
|
||||
inline const List<Type>& fieldData() const;
|
||||
|
||||
|
||||
// Edit
|
||||
@ -168,8 +160,8 @@ public:
|
||||
//- Return access to the volume mode
|
||||
inline volumeModeType& volumeMode();
|
||||
|
||||
//- Return access to the source field value
|
||||
inline Type& fieldData();
|
||||
//- Return access to the source field values
|
||||
inline List<Type>& fieldData();
|
||||
|
||||
|
||||
// Evaluation
|
||||
|
||||
@ -36,7 +36,7 @@ Foam::ExplicitSource<Type>::volumeMode() const
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline const Type& Foam::ExplicitSource<Type>::fieldData() const
|
||||
inline const Foam::List<Type>& Foam::ExplicitSource<Type>::fieldData() const
|
||||
{
|
||||
return fieldData_;
|
||||
}
|
||||
@ -51,7 +51,7 @@ Foam::ExplicitSource<Type>::volumeMode()
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline Type& Foam::ExplicitSource<Type>::fieldData()
|
||||
inline Foam::List<Type>& Foam::ExplicitSource<Type>::fieldData()
|
||||
{
|
||||
return fieldData_;
|
||||
}
|
||||
|
||||
@ -69,15 +69,12 @@ void Foam::pressureGradientExplicitSource::writeGradP() const
|
||||
}
|
||||
|
||||
|
||||
void Foam::pressureGradientExplicitSource::update()
|
||||
void Foam::pressureGradientExplicitSource::update(fvMatrix<vector>& eqn)
|
||||
{
|
||||
volVectorField& U = const_cast<volVectorField&>
|
||||
(
|
||||
mesh_.lookupObject<volVectorField>(UName_)
|
||||
);
|
||||
volVectorField& U = const_cast<volVectorField&>(eqn.psi());
|
||||
|
||||
const volScalarField& rAU =
|
||||
mesh_.lookupObject<volScalarField>("(1|A(" + UName_ + "))");
|
||||
mesh_.lookupObject<volScalarField>("(1|A(" + U.name() + "))");
|
||||
|
||||
// Integrate flow variables over cell set
|
||||
scalar magUbarAve = 0.0;
|
||||
@ -130,12 +127,14 @@ Foam::pressureGradientExplicitSource::pressureGradientExplicitSource
|
||||
)
|
||||
:
|
||||
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_))
|
||||
{
|
||||
coeffs_.lookup("fieldNames") >> fieldNames_;
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
|
||||
// Read the initial pressure gradient from file if it exists
|
||||
IFstream propsFile
|
||||
(
|
||||
@ -155,35 +154,19 @@ Foam::pressureGradientExplicitSource::pressureGradientExplicitSource
|
||||
|
||||
// * * * * * * * * * * * * * * * 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
|
||||
const label fieldI
|
||||
)
|
||||
{
|
||||
update();
|
||||
update(eqn);
|
||||
|
||||
DimensionedField<vector, volMesh> Su
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name_ + UName_ + "Sup",
|
||||
name_ + fieldNames_[fieldI] + "Sup",
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
|
||||
@ -70,9 +70,6 @@ class pressureGradientExplicitSource
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Velocity field name
|
||||
word UName_;
|
||||
|
||||
//- Average velocity
|
||||
vector Ubar_;
|
||||
|
||||
@ -92,7 +89,7 @@ class pressureGradientExplicitSource
|
||||
void writeGradP() const;
|
||||
|
||||
//- Correct driving force for a constant mass flow rate
|
||||
void update();
|
||||
void update(fvMatrix<vector>& eqn);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
pressureGradientExplicitSource(const pressureGradientExplicitSource&);
|
||||
@ -121,12 +118,6 @@ public:
|
||||
|
||||
// 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
|
||||
|
||||
@ -102,8 +102,6 @@ void Foam::radialActuationDiskSource::addSup
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
basicSource::addSup(eqn, fieldI);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -368,7 +368,6 @@ Foam::rotorDiskSource::rotorDiskSource
|
||||
)
|
||||
:
|
||||
basicSource(name, modelType, dict, mesh),
|
||||
fieldName_(coeffs_.lookup("fieldName")),
|
||||
rhoName_("none"),
|
||||
omega_(0.0),
|
||||
nBlades_(0),
|
||||
@ -398,19 +397,6 @@ Foam::rotorDiskSource::~rotorDiskSource()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::label Foam::rotorDiskSource::applyToField(const word& fieldName) const
|
||||
{
|
||||
if (fieldName == fieldName_)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::rotorDiskSource::addSup(fvMatrix<vector>& eqn, const label fieldI)
|
||||
{
|
||||
// add source to lhs of eqn
|
||||
@ -440,8 +426,6 @@ void Foam::rotorDiskSource::addSup(fvMatrix<vector>& eqn, const label fieldI)
|
||||
dimForce/dimVolume/dimDensity
|
||||
);
|
||||
}
|
||||
|
||||
basicSource::addSup(eqn, fieldI);
|
||||
}
|
||||
|
||||
|
||||
@ -456,6 +440,9 @@ bool Foam::rotorDiskSource::read(const dictionary& dict)
|
||||
{
|
||||
if (basicSource::read(dict))
|
||||
{
|
||||
coeffs_.lookup("fieldNames") >> fieldNames_;
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
|
||||
scalar rpm(readScalar(coeffs_.lookup("rpm")));
|
||||
omega_ = rpm/60.0*mathematical::twoPi;
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ Description
|
||||
|
||||
rotorDiskSourceCoeffs
|
||||
{
|
||||
fieldName U; // name of field on which to apply source
|
||||
fieldNames (U); // names of fields 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
|
||||
@ -149,9 +149,6 @@ protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Name of field on which to apply the source
|
||||
word fieldName_;
|
||||
|
||||
//- Name of density field
|
||||
word rhoName_;
|
||||
|
||||
@ -263,13 +260,6 @@ 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>
|
||||
|
||||
@ -306,6 +306,7 @@ Foam::FacePostProcessing<CloudType>::FacePostProcessing
|
||||
DynamicList<label> zoneIDs;
|
||||
const faceZoneMesh& fzm = owner.mesh().faceZones();
|
||||
const surfaceScalarField& magSf = owner.mesh().magSf();
|
||||
const polyBoundaryMesh& pbm = owner.mesh().boundaryMesh();
|
||||
forAll(faceZoneNames, i)
|
||||
{
|
||||
const word& zoneName = faceZoneNames[i];
|
||||
@ -314,16 +315,38 @@ Foam::FacePostProcessing<CloudType>::FacePostProcessing
|
||||
{
|
||||
zoneIDs.append(zoneI);
|
||||
const faceZone& fz = fzm[zoneI];
|
||||
mass_[i].setSize(fz.size(), 0.0);
|
||||
massTotal_[i].setSize(fz.size(), 0.0);
|
||||
massFlux_[i].setSize(fz.size(), 0.0);
|
||||
|
||||
label nFaces = returnReduce(fz.size(), sumOp<label>());
|
||||
mass_[i].setSize(nFaces, 0.0);
|
||||
massTotal_[i].setSize(nFaces, 0.0);
|
||||
massFlux_[i].setSize(nFaces, 0.0);
|
||||
Info<< " " << zoneName << " faces: " << nFaces << nl;
|
||||
|
||||
scalar totArea = 0.0;
|
||||
forAll(fz, j)
|
||||
{
|
||||
totArea += magSf[fz[j]];
|
||||
label faceI = fz[j];
|
||||
label bFaceI = faceI - owner.mesh().nInternalFaces();
|
||||
label patchI = pbm.patchID()[bFaceI];
|
||||
|
||||
if (patchI == -1)
|
||||
{
|
||||
totArea += magSf[fz[j]];
|
||||
}
|
||||
else
|
||||
{
|
||||
const polyPatch& pp = pbm[patchI];
|
||||
|
||||
if
|
||||
(
|
||||
!pp.coupled()
|
||||
|| refCast<const coupledPolyPatch>(pp).owner()
|
||||
)
|
||||
{
|
||||
label localFaceI = pp.whichFace(faceI);
|
||||
totArea += magSf.boundaryField()[patchI][localFaceI];
|
||||
}
|
||||
}
|
||||
}
|
||||
totArea = returnReduce(totArea, sumOp<scalar>());
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T)
|
||||
"G",
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
@ -76,7 +76,7 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T)
|
||||
"Qr",
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
@ -102,8 +102,8 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T)
|
||||
"Qin",
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar("Qin", dimMass/pow3(dimTime), 0.0)
|
||||
@ -228,7 +228,6 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T)
|
||||
);
|
||||
i++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -277,7 +276,7 @@ bool Foam::radiation::fvDOM::read()
|
||||
{
|
||||
if (radiationModel::read())
|
||||
{
|
||||
// Only reading solution parameters - not changing ray geometry
|
||||
// Only reading solution parameters - not changing ray geometry
|
||||
|
||||
coeffs_.readIfPresent("convergence", convergence_);
|
||||
coeffs_.readIfPresent("maxIter", maxIter_);
|
||||
|
||||
@ -61,6 +61,7 @@ Foam::radiation::radiationModel::radiationModel(const volScalarField& T)
|
||||
radiation_(false),
|
||||
coeffs_(dictionary::null),
|
||||
solverFreq_(0),
|
||||
firstIter_(true),
|
||||
absorptionEmission_(NULL),
|
||||
scatter_(NULL)
|
||||
{}
|
||||
@ -89,6 +90,7 @@ Foam::radiation::radiationModel::radiationModel
|
||||
radiation_(lookup("radiation")),
|
||||
coeffs_(subDict(type + "Coeffs")),
|
||||
solverFreq_(readLabel(lookup("solverFreq"))),
|
||||
firstIter_(true),
|
||||
absorptionEmission_(absorptionEmissionModel::New(*this, mesh_)),
|
||||
scatter_(scatterModel::New(*this, mesh_))
|
||||
{
|
||||
@ -130,9 +132,10 @@ void Foam::radiation::radiationModel::correct()
|
||||
return;
|
||||
}
|
||||
|
||||
if (time_.timeIndex() % solverFreq_ == 0)
|
||||
if (firstIter_ || (time_.timeIndex() % solverFreq_ == 0))
|
||||
{
|
||||
calculate();
|
||||
firstIter_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -91,6 +91,9 @@ protected:
|
||||
// radiation solver iteration
|
||||
label solverFreq_;
|
||||
|
||||
//- Flag to enable radiation model to be evaluated on first iteration
|
||||
bool firstIter_;
|
||||
|
||||
|
||||
// References to the radiation sub-models
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ cloneParallelCase()
|
||||
# Do the Spalart-Allmaras steady-state case
|
||||
(cd motorBike && foamRunTutorials)
|
||||
|
||||
# Clone the steady-stae case to the LES case
|
||||
# Clone the steady-state case to the LES case
|
||||
cloneParallelCase motorBike motorBikeLES
|
||||
|
||||
# Do the LES case
|
||||
|
||||
@ -32,7 +32,9 @@ massSource1
|
||||
volumeMode absolute;
|
||||
fieldData
|
||||
{
|
||||
rho 1e-4; // kg/s
|
||||
H2O 1e-4; // kg/s
|
||||
p 1e-4; // kg/s
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user