Merge branch 'master' of ssh://dm/home/dm4/OpenFOAM/OpenFOAM-dev

This commit is contained in:
Henry
2013-01-09 14:44:28 +00:00
566 changed files with 4596 additions and 82792 deletions

View File

@ -74,7 +74,7 @@ fvAgglomerationMethods/Allwmake $*
wmake $makeType fvMotionSolver
wmake $makeType engine
wmake $makeType fieldSources
wmake $makeType fvOptions
wmake $makeType regionCoupled

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -28,7 +28,9 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class T>
Foam::Dictionary<T>::Dictionary()
Foam::Dictionary<T>::Dictionary(const label size)
:
DictionaryBase<IDLList<T>, T>(size)
{}
@ -44,8 +46,9 @@ Foam::Dictionary<T>::Dictionary(const Dictionary& dict)
template<class T>
bool Foam::Dictionary<T>::erase(const word& keyword)
{
T* tPtr;
if (tPtr = this->remove(keyword))
T* tPtr = this->remove(keyword);
if (tPtr)
{
delete tPtr;
return true;
@ -57,6 +60,4 @@ bool Foam::Dictionary<T>::erase(const word& keyword)
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -61,8 +61,8 @@ public:
// Constructors
//- Null constructor
Dictionary();
//- Construct given initial table size
Dictionary(const label size = 128);
//- Copy construct
Dictionary(const Dictionary&);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -45,7 +45,9 @@ void Foam::DictionaryBase<IDLListType, T>::addEntries()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class IDLListType, class T>
Foam::DictionaryBase<IDLListType, T>::DictionaryBase()
Foam::DictionaryBase<IDLListType, T>::DictionaryBase(const label size)
:
hashedTs_(size)
{}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -90,8 +90,8 @@ public:
// Constructors
//- Null constructor
DictionaryBase();
//- Construct given initial table size
DictionaryBase(const label size = 128);
//- Copy construct
DictionaryBase(const DictionaryBase&);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -28,7 +28,9 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class T>
Foam::PtrDictionary<T>::PtrDictionary()
Foam::PtrDictionary<T>::PtrDictionary(const label size)
:
DictionaryBase<DLPtrList<T>, T>(size)
{}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -61,8 +61,8 @@ public:
// Constructors
//- Null constructor
PtrDictionary();
//- Construct given initial table size
PtrDictionary(const label size = 128);
//- Copy construct
PtrDictionary(const PtrDictionary&);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -28,7 +28,9 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class T>
Foam::UPtrDictionary<T>::UPtrDictionary()
Foam::UPtrDictionary<T>::UPtrDictionary(const label size)
:
DictionaryBase<DLList<T*>, T>(size)
{}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -61,8 +61,8 @@ public:
// Constructors
//- Null constructor
UPtrDictionary();
//- Construct given initial table size
UPtrDictionary(const label size = 128);
//- Copy construct
UPtrDictionary(const UPtrDictionary&);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -26,6 +26,7 @@ License
#include "Time.H"
#include "Pstream.H"
#include "simpleObjectRegistry.H"
#include "dimensionedConstants.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -45,54 +46,50 @@ void Foam::Time::readDict()
// Debug switches
if (controlDict_.found("DebugSwitches"))
{
Info<< "Overriding DebugSwitches according to " << controlDict_.name()
<< endl;
simpleObjectRegistry& objects = debug::debugObjects();
const dictionary& localSettings = controlDict_.subDict("DebugSwitches");
forAllConstIter(dictionary, localSettings, iter)
{
const word& name = iter().keyword();
simpleObjectRegistry::iterator fnd = objects.find(name);
if (fnd != objects.end())
simpleObjectRegistryEntry* objPtr = objects.lookupPtr(name);
if (objPtr)
{
Info<< controlDict_.name() << " : overriding debug switch : "
<< iter() << endl;
Info<< " " << iter() << endl;
const List<simpleRegIOobject*>& objects = *objPtr;
if (iter().isDict())
{
OStringStream os(IOstream::ASCII);
os << iter().dict();
IStringStream is(os.str());
fnd()->readData(is);
forAll(objects, i)
{
OStringStream os(IOstream::ASCII);
os << iter().dict();
IStringStream is(os.str());
objects[i]->readData(is);
}
}
else
{
fnd()->readData(iter().stream());
forAll(objects, i)
{
objects[i]->readData(iter().stream());
}
}
}
}
}
// Dimension sets
if (controlDict_.found("DimensionSets"))
{
dictionary dict(Foam::dimensionSystems());
dict.merge(controlDict_.subDict("DimensionSets"));
simpleObjectRegistry& objects = debug::dimensionSetObjects();
simpleObjectRegistry::iterator fnd = objects.find("DimensionSets");
if (fnd != objects.end())
{
Info<< controlDict_.name() << " : overriding DimensionSets" << endl;
OStringStream os(IOstream::ASCII);
os << dict;
IStringStream is(os.str());
fnd()->readData(is);
}
}
// Optimisation Switches
if (controlDict_.found("OptimisationSwitches"))
{
Info<< "Overriding OptimisationSwitches according to "
<< controlDict_.name() << endl;
simpleObjectRegistry& objects = debug::optimisationObjects();
const dictionary& localSettings = controlDict_.subDict
(
@ -101,28 +98,210 @@ void Foam::Time::readDict()
forAllConstIter(dictionary, localSettings, iter)
{
const word& name = iter().keyword();
simpleObjectRegistry::iterator fnd = objects.find(name);
if (fnd != objects.end())
simpleObjectRegistryEntry* objPtr = objects.lookupPtr(name);
if (objPtr)
{
Info<< controlDict_.name()
<< " : overriding optimisation switch : " << iter() << endl;
Info<< " " << iter() << endl;
const List<simpleRegIOobject*>& objects = *objPtr;
if (iter().isDict())
{
OStringStream os(IOstream::ASCII);
os << iter().dict();
IStringStream is(os.str());
fnd()->readData(is);
forAll(objects, i)
{
OStringStream os(IOstream::ASCII);
os << iter().dict();
IStringStream is(os.str());
objects[i]->readData(is);
}
}
else
{
fnd()->readData(iter().stream());
forAll(objects, i)
{
objects[i]->readData(iter().stream());
}
}
}
}
}
// DimensionedConstants. Handled as a special case since both e.g.
// the 'unitSet' might be changed and the individual values
if (controlDict_.found("DimensionedConstants"))
{
Info<< "Overriding DimensionedConstants according to "
<< controlDict_.name() << endl;
// Change in-memory
dimensionedConstants().merge
(
controlDict_.subDict("DimensionedConstants")
);
simpleObjectRegistry& objects = debug::dimensionedConstantObjects();
IStringStream dummyIs("");
forAllConstIter(simpleObjectRegistry, objects, iter)
{
const List<simpleRegIOobject*>& objects = *iter;
forAll(objects, i)
{
objects[i]->readData(dummyIs);
Info<< " ";
objects[i]->writeData(Info);
Info<< endl;
}
}
}
//{
// // fundamentalConstants.C
// Info<< "constant::universal::hr:"
// << Foam::constant::universal::hr
// << endl;
// Info<< "constant::universal::c:"
// << Foam::constant::universal::c
// << endl;
// Info<< "constant::universal::G:"
// << Foam::constant::universal::G
// << endl;
// Info<< "constant::universal::h:"
// << Foam::constant::universal::h
// << endl;
// Info<< "constant::electromagnetic::e:"
// << Foam::constant::electromagnetic::e
// << endl;
// Info<< "constant::atomic::me:"
// << Foam::constant::atomic::me
// << endl;
// Info<< "constant::atomic::mp:"
// << Foam::constant::atomic::mp
// << endl;
// Info<< "constant::physicoChemical::mu:"
// << Foam::constant::physicoChemical::mu
// << endl;
// Info<< "constant::physicoChemical::NA:"
// << Foam::constant::physicoChemical::NA
// << endl;
// Info<< "constant::physicoChemical::k:"
// << Foam::constant::physicoChemical::k
// << endl;
// Info<< "constant::standard::Pstd:"
// << Foam::constant::standard::Pstd
// << endl;
// Info<< "constant::standard::Tstd:"
// << Foam::constant::standard::Tstd
// << endl;
//
// // universalConstants.C
// Info<< "constant::universal::hr:"
// << Foam::constant::universal::hr
// << endl;
//
// // electromagneticConstants.C
// Info<< "constant::electromagnetic::mu0:"
// << Foam::constant::electromagnetic::mu0
// << endl;
// Info<< "constant::electromagnetic::epsilon0:"
// << Foam::constant::electromagnetic::epsilon0
// << endl;
// Info<< "constant::electromagnetic::Z0:"
// << Foam::constant::electromagnetic::Z0
// << endl;
// Info<< "constant::electromagnetic::kappa:"
// << Foam::constant::electromagnetic::kappa
// << endl;
// Info<< "constant::electromagnetic::G0:"
// << Foam::constant::electromagnetic::G0
// << endl;
// Info<< "constant::electromagnetic::KJ:"
// << Foam::constant::electromagnetic::KJ
// << endl;
// Info<< "constant::electromagnetic::RK:"
// << Foam::constant::electromagnetic::RK
// << endl;
//
//
// // atomicConstants.C
// Info<< "constant::atomic::alpha:"
// << Foam::constant::atomic::alpha
// << endl;
// Info<< "constant::atomic::Rinf:"
// << Foam::constant::atomic::Rinf
// << endl;
// Info<< "constant::atomic::a0:"
// << Foam::constant::atomic::a0
// << endl;
// Info<< "constant::physiatomic::re:"
// << Foam::constant::atomic::re
// << endl;
// Info<< "constant::atomic::Eh:"
// << Foam::constant::atomic::Eh
// << endl;
//
//
// // physicoChemicalConstants.C
// Info<< "constant::physicoChemical::R:"
// << Foam::constant::physicoChemical::R
// << endl;
// Info<< "constant::physicoChemical::F:"
// << Foam::constant::physicoChemical::F
// << endl;
// Info<< "constant::physicoChemical::sigma:"
// << Foam::constant::physicoChemical::sigma
// << endl;
// Info<< "constant::physicoChemical::b:"
// << Foam::constant::physicoChemical::b
// << endl;
// Info<< "constant::physicoChemical::c1:"
// << Foam::constant::physicoChemical::c1
// << endl;
// Info<< "constant::physicoChemical::c2:"
// << Foam::constant::physicoChemical::c2
// << endl;
//}
// Dimension sets
if (controlDict_.found("DimensionSets"))
{
Info<< "Overriding DimensionSets according to "
<< controlDict_.name() << endl;
dictionary dict(Foam::dimensionSystems());
dict.merge(controlDict_.subDict("DimensionSets"));
simpleObjectRegistry& objects = debug::dimensionSetObjects();
simpleObjectRegistryEntry* objPtr = objects.lookupPtr("DimensionSets");
if (objPtr)
{
Info<< controlDict_.subDict("DimensionSets") << endl;
const List<simpleRegIOobject*>& objects = *objPtr;
forAll(objects, i)
{
OStringStream os(IOstream::ASCII);
os << dict;
IStringStream is(os.str());
objects[i]->readData(is);
}
}
}
if (!deltaTchanged_)
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -218,7 +218,7 @@ extern messageStream Info;
* Report an error message using Foam::SeriousError for functionName in
* file __FILE__ at line __LINE__
*/
#define SeriousErrorIn(fn) \
#define SeriousErrorIn(fn) \
::Foam::SeriousError((fn), __FILE__, __LINE__)
/**
@ -227,7 +227,7 @@ extern messageStream Info;
* file __FILE__ at line __LINE__
* for a particular IOstream
*/
#define SeriousIOErrorIn(fn, ios) \
#define SeriousIOErrorIn(fn, ios) \
::Foam::SeriousError((fn), __FILE__, __LINE__, ios)
/**
@ -235,7 +235,7 @@ extern messageStream Info;
* Report a warning using Foam::Warning for functionName in
* file __FILE__ at line __LINE__
*/
#define WarningIn(fn) \
#define WarningIn(fn) \
::Foam::Warning((fn), __FILE__, __LINE__)
/**
@ -244,7 +244,7 @@ extern messageStream Info;
* file __FILE__ at line __LINE__
* for a particular IOstream
*/
#define IOWarningIn(fn, ios) \
#define IOWarningIn(fn, ios) \
::Foam::Warning((fn), __FILE__, __LINE__, (ios))
/**
@ -252,7 +252,7 @@ extern messageStream Info;
* Report a information message using Foam::Info for functionName in
* file __FILE__ at line __LINE__
*/
#define InfoIn(fn) \
#define InfoIn(fn) \
::Foam::Info((fn), __FILE__, __LINE__)
/**
@ -261,9 +261,26 @@ extern messageStream Info;
* file __FILE__ at line __LINE__
* for a particular IOstream
*/
#define IOInfoIn(fn, ios) \
#define IOInfoIn(fn, ios) \
::Foam::Info((fn), __FILE__, __LINE__, (ios))
/**
* \def Debug(variable)
* Report a variable name and value using Foam::Pout in
* file __FILE__ at line __LINE__
*/
#define Debug(var) \
::Foam::Pout<< "["<< __FILE__ << ":" << __LINE__ << "] " \
<< #var " = " << var << ::Foam::endl
/**
* \def IInfo
* Indented Info
*/
#define IInfo \
::Foam::Info<< indent
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -194,6 +194,10 @@ private:
};
//- Reset exponents to nearest integer if close to it. Used to
// handle reading with insufficient precision.
void round(const scalar tol);
dimensionedScalar parse
(
const label lastPrior,

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -26,6 +26,7 @@ License
#include "dimensionSet.H"
#include "IOstreams.H"
#include "dimensionedScalar.H"
#include <limits>
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -142,7 +143,7 @@ void Foam::dimensionSet::tokeniser::splitWord(const word& w)
word subWord = w(start, i-start);
if (isdigit(subWord[0]) || subWord[0] == token::SUBTRACT)
{
push(token(readLabel(IStringStream(subWord)())));
push(token(readScalar(IStringStream(subWord)())));
}
else
{
@ -153,7 +154,7 @@ void Foam::dimensionSet::tokeniser::splitWord(const word& w)
{
if (isdigit(w[i]))
{
push(token(readLabel(IStringStream(w[i])())));
push(token(readScalar(IStringStream(w[i])())));
}
else
{
@ -168,7 +169,7 @@ void Foam::dimensionSet::tokeniser::splitWord(const word& w)
word subWord = w(start, w.size()-start);
if (isdigit(subWord[0]) || subWord[0] == token::SUBTRACT)
{
push(token(readLabel(IStringStream(subWord)())));
push(token(readScalar(IStringStream(subWord)())));
}
else
{
@ -213,6 +214,29 @@ void Foam::dimensionSet::tokeniser::putBack(const token& t)
}
void Foam::dimensionSet::round(const scalar tol)
{
for (int i=0; i < dimensionSet::nDimensions; ++i)
{
scalar integralPart;
scalar fractionalPart = std::modf(exponents_[i], &integralPart);
if (mag(fractionalPart-1.0) <= tol)
{
exponents_[i] = 1.0+integralPart;
}
else if (mag(fractionalPart+1.0) <= tol)
{
exponents_[i] = -1.0+integralPart;
}
else if (mag(fractionalPart) <= tol)
{
exponents_[i] = integralPart;
}
}
}
Foam::dimensionedScalar Foam::dimensionSet::parse
(
const label lastPrior,
@ -327,6 +351,8 @@ Foam::dimensionedScalar Foam::dimensionSet::parse
dimensionedScalar exp(parse(nextPrior, tis, readSet));
ds.dimensions().reset(pow(ds.dimensions(), exp.value()));
// Round to nearest integer if close to it
ds.dimensions().round(10*smallExponent);
ds.value() = Foam::pow(ds.value(), exp.value());
}
else
@ -535,6 +561,8 @@ Foam::Istream& Foam::dimensionSet::read
s.read(readSet[symbol], readSet);
symbolSet.reset(pow(s.dimensions(), exponent));
// Round to nearest integer if close to it
symbolSet.round(10*smallExponent);
multiplier *= Foam::pow(s.value(), exponent);
}
else
@ -634,6 +662,13 @@ Foam::Ostream& Foam::dimensionSet::write
writeUnits.coefficients(exponents);
bool hasPrinted = false;
// Set precision to lots
std::streamsize oldPrecision = os.precision
(
std::numeric_limits<scalar>::digits10
);
forAll(exponents, i)
{
if (mag(exponents[i]) > smallExponent)
@ -658,6 +693,9 @@ Foam::Ostream& Foam::dimensionSet::write
}
}
}
// Reset precision
os.precision(oldPrecision);
}
else
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -35,21 +35,16 @@ namespace Foam
/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
//- Since dimensionSystems() can be reread we actually store a copy of
// the controlDict subDict (v.s. a reference to the subDict for e.g.
// dimensionedConstants)
dictionary* dimensionSystemsPtr_(NULL);
HashTable<dimensionedScalar>* unitSetPtr_(NULL);
dimensionSets* writeUnitSetPtr_(NULL);
dictionary& dimensionSystems()
{
return debug::switchSet
(
"DimensionSets",
dimensionSystemsPtr_
);
}
autoPtr<HashTable<dimensionedScalar> > unitSetPtr_;
autoPtr<dimensionSets> writeUnitSetPtr_;
//- Helper class to
// - register re-reader
// - deallocate demand-driven data
class addDimensionSetsToDebug
:
public ::Foam::simpleRegIOobject
@ -60,12 +55,17 @@ public:
::Foam::simpleRegIOobject(Foam::debug::addDimensionSetObject, name)
{}
virtual ~addDimensionSetsToDebug()
{}
{
deleteDemandDrivenData(dimensionSystemsPtr_);
deleteDemandDrivenData(unitSetPtr_);
deleteDemandDrivenData(writeUnitSetPtr_);
}
virtual void readData(Foam::Istream& is)
{
deleteDemandDrivenData(dimensionSystemsPtr_);
unitSetPtr_.clear();
writeUnitSetPtr_.clear();
deleteDemandDrivenData(unitSetPtr_);
deleteDemandDrivenData(writeUnitSetPtr_);
dimensionSystemsPtr_ = new dictionary(is);
}
virtual void writeData(Foam::Ostream& os) const
@ -76,10 +76,27 @@ public:
addDimensionSetsToDebug addDimensionSetsToDebug_("DimensionSets");
dictionary& dimensionSystems()
{
if (!dimensionSystemsPtr_)
{
dictionary* cachedPtr = NULL;
dimensionSystemsPtr_ = new dictionary
(
debug::switchSet
(
"DimensionSets",
cachedPtr
)
);
}
return *dimensionSystemsPtr_;
}
const HashTable<dimensionedScalar>& unitSet()
{
if (!unitSetPtr_.valid())
if (!unitSetPtr_)
{
const dictionary& dict = dimensionSystems();
@ -101,10 +118,7 @@ const HashTable<dimensionedScalar>& unitSet()
const dictionary& unitDict = dict.subDict(unitSetCoeffs);
unitSetPtr_.reset
(
new HashTable<dimensionedScalar>(unitDict.size())
);
unitSetPtr_ = new HashTable<dimensionedScalar>(unitDict.size());
forAllConstIter(dictionary, unitDict, iter)
{
@ -132,14 +146,7 @@ const HashTable<dimensionedScalar>& unitSet()
)
);
writeUnitSetPtr_.reset
(
new dimensionSets
(
unitSetPtr_(),
writeUnitNames
)
);
writeUnitSetPtr_ = new dimensionSets(*unitSetPtr_, writeUnitNames);
if (writeUnitNames.size() != 0 && writeUnitNames.size() != 7)
{
@ -149,17 +156,17 @@ const HashTable<dimensionedScalar>& unitSet()
<< exit(FatalIOError);
}
}
return unitSetPtr_();
return *unitSetPtr_;
}
const dimensionSets& writeUnitSet()
{
if (!writeUnitSetPtr_.valid())
if (!writeUnitSetPtr_)
{
(void)unitSet();
}
return writeUnitSetPtr_();
return *writeUnitSetPtr_;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -32,100 +32,126 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
const char* const Foam::constant::atomic::group = "atomic";
namespace Foam
{
namespace constant
{
const char* const atomic::group = "atomic";
const Foam::dimensionedScalar Foam::constant::atomic::alpha
// Note: cannot use dimless etc. since not guaranteed to be constructed
defineDimensionedConstantWithDefault
(
dimensionedConstant
atomic::group,
atomic::alpha,
dimensionedScalar
(
group,
"alpha",
dimensionedScalar
(
"alpha",
sqr(constant::electromagnetic::e)
/(
dimensionedScalar("C", dimless, 2.0)
*constant::electromagnetic::epsilon0
*constant::universal::h
*constant::universal::c
)
sqr(electromagnetic::e)
/(
dimensionedScalar("C", dimensionSet(0, 0, 0, 0, 0), 2.0)
*electromagnetic::epsilon0
*universal::h
*universal::c
)
)
),
constantatomicalpha,
"alpha"
);
const Foam::dimensionedScalar Foam::constant::atomic::Rinf
defineDimensionedConstantWithDefault
(
dimensionedConstant
atomic::group,
atomic::Rinf,
dimensionedScalar
(
group,
"Rinf",
dimensionedScalar
(
"Rinf",
sqr(alpha)*me*constant::universal::c
/(dimensionedScalar("C", dimless, 2.0)*constant::universal::h)
)
)
);
const Foam::dimensionedScalar Foam::constant::atomic::a0
(
dimensionedConstant
(
group,
"a0",
dimensionedScalar
(
"a0",
alpha
/(
dimensionedScalar("C", dimless, 4.0*constant::mathematical::pi)
*Rinf
)
)
)
);
const Foam::dimensionedScalar Foam::constant::atomic::re
(
dimensionedConstant
(
group,
"re",
dimensionedScalar
(
"re",
sqr(constant::electromagnetic::e)
/(
dimensionedScalar("C", dimless, 4.0*constant::mathematical::pi)
*constant::electromagnetic::epsilon0
*me
*sqr(constant::universal::c)
sqr(atomic::alpha)
*atomic::me
*universal::c
/(
Foam::dimensionedScalar
(
"C",
dimensionSet(0, 0, 0, 0, 0),
2.0
)
*universal::h
)
)
),
constantatomicRinf,
"Rinf"
);
const Foam::dimensionedScalar Foam::constant::atomic::Eh
defineDimensionedConstantWithDefault
(
dimensionedConstant
atomic::group,
atomic::a0,
dimensionedScalar
(
group,
"Eh",
dimensionedScalar
(
"Eh",
dimensionedScalar("C", dimless, 2.0)
*Rinf*constant::universal::h*constant::universal::c
"a0",
atomic::alpha
/(
Foam::dimensionedScalar
(
"C",
dimensionSet(0, 0, 0, 0, 0),
4.0*mathematical::pi
)
*atomic::Rinf
)
)
),
constantatomica0,
"a0"
);
defineDimensionedConstantWithDefault
(
atomic::group,
atomic::re,
dimensionedScalar
(
"re",
Foam::sqr(electromagnetic::e)
/(
Foam::dimensionedScalar
(
"C",
dimensionSet(0, 0, 0, 0, 0),
4.0*mathematical::pi
)
*electromagnetic::epsilon0
*atomic::me
*Foam::sqr(universal::c)
)
),
constantatomicre,
"re"
);
defineDimensionedConstantWithDefault
(
atomic::group,
atomic::Eh,
dimensionedScalar
(
"Eh",
Foam::dimensionedScalar("C", dimensionSet(0, 0, 0, 0, 0), 2.0)
*atomic::Rinf*universal::h*universal::c
),
constantatomicEh,
"Eh"
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace constant
} // End namespace Foam
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -28,7 +28,7 @@ License
// Constants supplied in the main controlDict
#include "fundamentalConstants.C"
// Derived constants
// Derived constants. Note:order is important
#include "universalConstants.C"
#include "electromagneticConstants.C"
#include "atomicConstants.C"

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -92,6 +92,104 @@ T dimensionedConstant
}
//- Defined dimensioned constant , lookup as \a Name
#define defineDimensionedConstant(Group,Switch,Tag,Name) \
const Foam::dimensionedScalar Switch; \
class add##Tag##ToDimensionedConstant \
: \
public Foam::simpleRegIOobject \
{ \
public: \
add##Tag##ToDimensionedConstant(const char* name) \
: \
Foam::simpleRegIOobject \
(Foam::debug::addDimensionedConstantObject,name) \
{ \
Foam::dimensionedScalar ds \
( \
Foam::dimensionedConstant \
( \
Group, \
Name \
) \
); \
Foam::dimensionedScalar& s = const_cast<Foam::dimensionedScalar&> \
( \
Switch \
); \
s.dimensions().reset(ds.dimensions()); \
s = ds; \
} \
virtual ~add##Tag##ToDimensionedConstant() \
{} \
virtual void readData(Foam::Istream& is) \
{ \
const_cast<Foam::dimensionedScalar&>(Switch) = \
Foam::dimensionedConstant \
( \
Group, \
Name \
); \
} \
virtual void writeData(Foam::Ostream& os) const \
{ \
os << Switch; \
} \
}; \
add##Tag##ToDimensionedConstant add##Tag##ToDimensionedConstant_(Name)
//- Defined dimensioned constant with default , lookup as \a Name
#define defineDimensionedConstantWithDefault\
(Group,Switch,DefaultExpr,Tag,Name) \
const Foam::dimensionedScalar Switch; \
class add##Tag##ToDimensionedConstantWithDefault \
: \
public Foam::simpleRegIOobject \
{ \
public: \
add##Tag##ToDimensionedConstantWithDefault(const char* name) \
: \
Foam::simpleRegIOobject \
(Foam::debug::addDimensionedConstantObject,name) \
{ \
Foam::dimensionedScalar ds \
( \
Foam::dimensionedConstant \
( \
Group, \
Name, \
Foam::dimensionedScalar(Name,DefaultExpr) \
) \
); \
Foam::dimensionedScalar& s = const_cast<Foam::dimensionedScalar&> \
( \
Switch \
); \
s.dimensions().reset(ds.dimensions()); \
s = ds; \
} \
virtual ~add##Tag##ToDimensionedConstantWithDefault() \
{} \
virtual void readData(Foam::Istream& is) \
{ \
const_cast<Foam::dimensionedScalar&>(Switch) = \
Foam::dimensionedConstant \
( \
Group, \
Name, \
Foam::dimensionedScalar(Name,DefaultExpr) \
); \
} \
virtual void writeData(Foam::Ostream& os) const \
{ \
os << Switch; \
} \
}; \
add##Tag##ToDimensionedConstantWithDefault \
add##Tag##ToDimensionedConstantWithDefault_(Name)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -32,135 +32,154 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
const char* const Foam::constant::electromagnetic::group = "electromagnetic";
namespace Foam
{
namespace constant
{
const char* const electromagnetic::group = "electromagnetic";
const Foam::dimensionedScalar Foam::constant::electromagnetic::mu0
defineDimensionedConstantWithDefault
(
dimensionedConstant
electromagnetic::group,
electromagnetic::mu0,
dimensionedScalar
(
group,
"mu0",
dimensionedScalar
(
"mu0",
dimensionSet(1, 1, -2, 0, 0, -2, 0),
4.0*constant::mathematical::pi*1e-07
)
)
dimensionSet(1, 1, -2, 0, 0, -2, 0),
4.0*mathematical::pi*1e-07
),
constantelectromagneticmu0,
"mu0"
);
const Foam::dimensionedScalar Foam::constant::electromagnetic::epsilon0
// Note: cannot use dimless etc. since not guaranteed to be constructed
defineDimensionedConstantWithDefault
(
dimensionedConstant
electromagnetic::group,
electromagnetic::epsilon0,
dimensionedScalar
(
group,
"epsilon0",
dimensionedScalar
(
"epsilon0",
dimensionedScalar("C", dimless, 1.0)
/(mu0*sqr(constant::universal::c))
"C",
dimensionSet(0, 0, 0, 0, 0),
1.0
)
)
/(electromagnetic::mu0*sqr(universal::c))
),
constantelectromagneticepsilon0,
"epsilon0"
);
const Foam::dimensionedScalar Foam::constant::electromagnetic::Z0
defineDimensionedConstantWithDefault
(
dimensionedConstant
electromagnetic::group,
electromagnetic::Z0,
dimensionedScalar
(
group,
"Z0",
dimensionedScalar
(
"Z0",
mu0*constant::universal::c
)
)
electromagnetic::mu0*universal::c
),
constantelectromagneticZ0,
"Z0"
);
const Foam::dimensionedScalar Foam::constant::electromagnetic::kappa
defineDimensionedConstantWithDefault
(
dimensionedConstant
electromagnetic::group,
electromagnetic::kappa,
dimensionedScalar
(
group,
"kappa",
dimensionedScalar
(
"kappa",
dimensionedScalar
(
"C",
dimless,
1.0/(4.0*constant::mathematical::pi)
)
/epsilon0
"C",
dimensionSet(0, 0, 0, 0, 0),
1.0/(4.0*mathematical::pi)
)
)
/electromagnetic::epsilon0
),
constantelectromagnetickappa,
"kappa"
);
const Foam::dimensionedScalar Foam::constant::electromagnetic::G0
defineDimensionedConstantWithDefault
(
dimensionedConstant
electromagnetic::group,
electromagnetic::G0,
dimensionedScalar
(
group,
"G0",
dimensionedScalar
(
"G0",
dimensionedScalar("C", dimless, 2)*sqr(e)/constant::universal::h
)
)
dimensionedScalar("C", dimensionSet(0, 0, 0, 0, 0), 2)
*sqr(electromagnetic::e)
/universal::h
),
constantelectromagneticG0,
"G0"
);
const Foam::dimensionedScalar Foam::constant::electromagnetic::KJ
defineDimensionedConstantWithDefault
(
dimensionedConstant
electromagnetic::group,
electromagnetic::KJ,
dimensionedScalar
(
group,
"KJ",
dimensionedScalar
(
"KJ",
dimensionedScalar("C", dimless, 2)*e/constant::universal::h
)
)
dimensionedScalar("C", dimensionSet(0, 0, 0, 0, 0), 2)
*electromagnetic::e
/universal::h
),
constantelectromagneticKJ,
"KJ"
);
const Foam::dimensionedScalar Foam::constant::electromagnetic::phi0
defineDimensionedConstantWithDefault
(
dimensionedConstant
electromagnetic::group,
electromagnetic::phi0,
dimensionedScalar
(
group,
"phi0",
dimensionedScalar
(
"phi0",
constant::universal::h/(dimensionedScalar("C", dimless, 2)*e)
universal::h
/(
dimensionedScalar("C", dimensionSet(0, 0, 0, 0, 0), 2)
*electromagnetic::e
)
)
),
constantelectromagneticphi0,
"phi0"
);
const Foam::dimensionedScalar Foam::constant::electromagnetic::RK
defineDimensionedConstantWithDefault
(
dimensionedConstant
electromagnetic::group,
electromagnetic::RK,
dimensionedScalar
(
group,
"RK",
dimensionedScalar
(
"RK",
constant::universal::h/sqr(e)
)
)
universal::h/Foam::sqr(electromagnetic::e)
),
constantelectromagneticRK,
"RK"
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace constant
} // End namespace Foam
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -39,89 +39,128 @@ Description
// Universal constants
const Foam::dimensionedScalar Foam::constant::universal::c
namespace Foam
{
namespace constant
{
defineDimensionedConstant
(
dimensionedConstant(universal::group, "c")
universal::group,
universal::c,
constantuniversalc,
"c"
);
const Foam::dimensionedScalar Foam::constant::universal::G
defineDimensionedConstant
(
dimensionedConstant(universal::group, "G")
universal::group,
universal::G,
constantuniversalG,
"G"
);
const Foam::dimensionedScalar Foam::constant::universal::h
defineDimensionedConstant
(
dimensionedConstant(universal::group, "h")
universal::group,
universal::h,
constantuniversalh,
"h"
);
// Electromagnetic
const Foam::dimensionedScalar Foam::constant::electromagnetic::e
defineDimensionedConstant
(
dimensionedConstant(electromagnetic::group, "e")
electromagnetic::group,
electromagnetic::e,
constantelectromagnetice,
"e"
);
// Atomic
const Foam::dimensionedScalar Foam::constant::atomic::me
defineDimensionedConstant
(
dimensionedConstant(atomic::group, "me")
atomic::group,
atomic::me,
constantatomicme,
"me"
);
const Foam::dimensionedScalar Foam::constant::atomic::mp
defineDimensionedConstant
(
dimensionedConstant(atomic::group, "mp")
atomic::group,
atomic::mp,
constantatomicmp,
"mp"
);
// Physico-chemical
const Foam::dimensionedScalar Foam::constant::physicoChemical::mu
defineDimensionedConstant
(
dimensionedConstant(physicoChemical::group, "mu")
physicoChemical::group,
physicoChemical::mu,
constantphysicoChemicalmu,
"mu"
);
const Foam::dimensionedScalar Foam::constant::physicoChemical::NA
// Note: cannot use dimless etc since not guaranteed to be constructed
defineDimensionedConstantWithDefault
(
// dimensionedConstant(physicoChemical::group, "NA")
dimensionedConstant
physicoChemical::group,
physicoChemical::NA,
Foam::dimensionedScalar
(
physicoChemical::group,
"NA",
dimensionedScalar
(
"NA",
dimless/dimMoles,
6.0221417930e+23
)
)
dimensionSet(0, 0, 0, 0, -1), //Foam::dimless/Foam::dimMoles,
6.0221417930e+23
),
constantphysicoChemicalNA,
"NA"
);
const Foam::dimensionedScalar Foam::constant::physicoChemical::k
defineDimensionedConstant
(
dimensionedConstant(physicoChemical::group, "k")
physicoChemical::group,
physicoChemical::k,
constantphysicoChemicalk,
"k"
);
// Standard
const Foam::dimensionedScalar Foam::constant::standard::Pstd
defineDimensionedConstant
(
dimensionedConstant("standard", "Pstd")
"standard",
standard::Pstd,
constantstandardPstd,
"Pstd"
);
const Foam::dimensionedScalar Foam::constant::standard::Tstd
defineDimensionedConstant
(
dimensionedConstant("standard", "Tstd")
"standard",
standard::Tstd,
constantstandardTstd,
"Tstd"
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace constant
} // End namespace Foam
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -32,105 +32,120 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
const char* const Foam::constant::physicoChemical::group = "physicoChemical";
namespace Foam
{
namespace constant
{
const char* const physicoChemical::group = "physicoChemical";
const Foam::dimensionedScalar Foam::constant::physicoChemical::R
defineDimensionedConstantWithDefault
(
dimensionedConstant
physicoChemical::group,
physicoChemical::R,
dimensionedScalar
(
group,
"R",
dimensionedScalar
(
"R",
NA*k
)
)
physicoChemical::NA*physicoChemical::k
),
constantphysicoChemicalR,
"R"
);
const Foam::dimensionedScalar Foam::constant::physicoChemical::F
defineDimensionedConstantWithDefault
(
dimensionedConstant
physicoChemical::group,
physicoChemical::F,
dimensionedScalar
(
group,
"F",
dimensionedScalar
(
"F",
NA*constant::electromagnetic::e
)
)
physicoChemical::NA*electromagnetic::e
),
constantphysicoChemicalF,
"F"
);
const Foam::dimensionedScalar Foam::constant::physicoChemical::sigma
// Note: cannot use dimless etc. since not guaranteed to be constructed
defineDimensionedConstantWithDefault
(
dimensionedConstant
physicoChemical::group,
physicoChemical::sigma,
dimensionedScalar
(
group,
"sigma",
dimensionedScalar
Foam::dimensionedScalar
(
"sigma",
dimensionedScalar
(
"C",
dimless,
sqr(constant::mathematical::pi)/60.0
)
*pow4(k)/(pow3(constant::universal::hr)*sqr(constant::universal::c))
"C",
dimensionSet(0, 0, 0, 0, 0), //Foam::dimless,
Foam::sqr(mathematical::pi)/60.0
)
)
*Foam::pow4(physicoChemical::k)
/(pow3(universal::hr)*sqr(universal::c))
),
constantphysicoChemicalsigma,
"sigma"
);
const Foam::dimensionedScalar Foam::constant::physicoChemical::b
defineDimensionedConstantWithDefault
(
dimensionedConstant
physicoChemical::group,
physicoChemical::b,
dimensionedScalar
(
group,
"b",
dimensionedScalar
(universal::h*universal::c/physicoChemical::k)
/Foam::dimensionedScalar
(
"b",
(constant::universal::h*constant::universal::c/k)
/dimensionedScalar("C", dimless, 4.965114231)
"C",
dimensionSet(0, 0, 0, 0, 0), //Foam::dimless
4.965114231
)
)
),
constantphysicoChemicalb,
"b"
);
const Foam::dimensionedScalar Foam::constant::physicoChemical::c1
defineDimensionedConstantWithDefault
(
dimensionedConstant
physicoChemical::group,
physicoChemical::c1,
dimensionedScalar
(
group,
"c1",
dimensionedScalar
Foam::dimensionedScalar
(
"c1",
dimensionedScalar("C", dimless, constant::mathematical::twoPi)
*constant::universal::h*sqr(constant::universal::c)
"C",
dimensionSet(0, 0, 0, 0, 0), //Foam::dimless,
mathematical::twoPi
)
)
*universal::h*Foam::sqr(universal::c)
),
constantphysicoChemicalc1,
"c1"
);
const Foam::dimensionedScalar Foam::constant::physicoChemical::c2
defineDimensionedConstantWithDefault
(
dimensionedConstant
physicoChemical::group,
physicoChemical::c2,
dimensionedScalar
(
group,
"c2",
dimensionedScalar
(
"c2",
constant::universal::h*constant::universal::c/k
)
)
universal::h*universal::c/physicoChemical::k
),
constantphysicoChemicalc2,
"c2"
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace constant
} // End namespace Foam
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -30,22 +30,40 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
const char* const Foam::constant::universal::group = "universal";
namespace Foam
{
namespace constant
{
const char* const universal::group = "universal";
const Foam::dimensionedScalar Foam::constant::universal::hr
// Note: cannot use dimless etc. since not guaranteed to be constructed
defineDimensionedConstantWithDefault
(
dimensionedConstant
"universal",
universal::hr,
dimensionedScalar
(
group,
"hr",
dimensionedScalar
(
"hr",
h/(dimensionedScalar("C", dimless, constant::mathematical::twoPi))
universal::h
/(
dimensionedScalar
(
"C",
dimensionSet(0, 0, 0, 0, 0),//dimless
mathematical::twoPi
)
)
)
),
constantuniversalhr,
"hr"
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace constant
} // End namespace Foam
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -47,6 +47,14 @@ dictionary* debugSwitchesPtr_(NULL);
dictionary* infoSwitchesPtr_(NULL);
dictionary* optimisationSwitchesPtr_(NULL);
// Debug switch read and write callback tables.
simpleObjectRegistry* debugObjectsPtr_(NULL);
simpleObjectRegistry* infoObjectsPtr_(NULL);
simpleObjectRegistry* optimisationObjectsPtr_(NULL);
simpleObjectRegistry* dimensionSetObjectsPtr_(NULL);
simpleObjectRegistry* dimensionedConstantObjectsPtr_(NULL);
// to ensure controlDictPtr_ is deleted at the end of the run
class deleteControlDictPtr
{
@ -57,35 +65,20 @@ public:
~deleteControlDictPtr()
{
deleteDemandDrivenData(debugObjectsPtr_);
deleteDemandDrivenData(infoObjectsPtr_);
deleteDemandDrivenData(optimisationObjectsPtr_);
deleteDemandDrivenData(dimensionSetObjectsPtr_);
deleteDemandDrivenData(dimensionedConstantObjectsPtr_);
debugSwitchesPtr_ = NULL;
infoSwitchesPtr_ = NULL;
optimisationSwitchesPtr_ = NULL;
deleteDemandDrivenData(controlDictPtr_);
}
};
deleteControlDictPtr deleteControlDictPtr_;
// Debug switch read and write callback tables.
simpleObjectRegistry* debugObjectsPtr_(NULL);
simpleObjectRegistry* infoObjectsPtr_(NULL);
simpleObjectRegistry* optimisationObjectsPtr_(NULL);
simpleObjectRegistry* dimensionSetObjectsPtr_(NULL);
class deleteDebugSwitchPtr
{
public:
deleteDebugSwitchPtr()
{}
~deleteDebugSwitchPtr()
{
deleteDemandDrivenData(debugObjectsPtr_);
deleteDemandDrivenData(infoObjectsPtr_);
deleteDemandDrivenData(optimisationObjectsPtr_);
deleteDemandDrivenData(dimensionSetObjectsPtr_);
}
};
deleteDebugSwitchPtr deleteDebugSwitchPtr_;
//! \endcond
@ -190,24 +183,42 @@ int Foam::debug::optimisationSwitch(const char* name, const int defaultValue)
void Foam::debug::addDebugObject(const char* name, simpleRegIOobject* obj)
{
if (!debugObjects().insert(name, obj))
simpleObjectRegistryEntry* ptr = debugObjects().lookupPtr(name);
if (ptr)
{
//std::cerr<< "debug::addDebugObject : Duplicate entry " << name
// << " in runtime selection table"
// << std::endl;
//error::safePrintStack(std::cerr);
ptr->append(obj);
}
else
{
debugObjects().append
(
name,
new simpleObjectRegistryEntry
(
List<simpleRegIOobject*>(1, obj)
)
);
}
}
void Foam::debug::addInfoObject(const char* name, simpleRegIOobject* obj)
{
if (!infoObjects().insert(name, obj))
simpleObjectRegistryEntry* ptr = infoObjects().lookupPtr(name);
if (ptr)
{
//std::cerr<< "debug::addInfoObject : Duplicate entry " << name
// << " in runtime selection table"
// << std::endl;
//error::safePrintStack(std::cerr);
ptr->append(obj);
}
else
{
infoObjects().append
(
name,
new simpleObjectRegistryEntry
(
List<simpleRegIOobject*>(1, obj)
)
);
}
}
@ -218,12 +229,21 @@ void Foam::debug::addOptimisationObject
simpleRegIOobject* obj
)
{
if (!optimisationObjects().insert(name, obj))
simpleObjectRegistryEntry* ptr = optimisationObjects().lookupPtr(name);
if (ptr)
{
//std::cerr<< "debug::addOptimisationObject : Duplicate entry " << name
// << " in runtime selection table"
// << std::endl;
//error::safePrintStack(std::cerr);
ptr->append(obj);
}
else
{
optimisationObjects().append
(
name,
new simpleObjectRegistryEntry
(
List<simpleRegIOobject*>(1, obj)
)
);
}
}
@ -234,12 +254,49 @@ void Foam::debug::addDimensionSetObject
simpleRegIOobject* obj
)
{
if (!dimensionSetObjects().insert(name, obj))
simpleObjectRegistryEntry* ptr = dimensionSetObjects().lookupPtr(name);
if (ptr)
{
//std::cerr<< "debug::addDimensionSetObject : Duplicate entry " << name
// << " in runtime selection table"
// << std::endl;
//error::safePrintStack(std::cerr);
ptr->append(obj);
}
else
{
dimensionSetObjects().append
(
name,
new simpleObjectRegistryEntry
(
List<simpleRegIOobject*>(1, obj)
)
);
}
}
void Foam::debug::addDimensionedConstantObject
(
const char* name,
simpleRegIOobject* obj
)
{
simpleObjectRegistryEntry* ptr = dimensionedConstantObjects().lookupPtr
(
name
);
if (ptr)
{
ptr->append(obj);
}
else
{
dimensionedConstantObjects().append
(
name,
new simpleObjectRegistryEntry
(
List<simpleRegIOobject*>(1, obj)
)
);
}
}
@ -259,7 +316,7 @@ Foam::simpleObjectRegistry& Foam::debug::infoObjects()
{
if (!infoObjectsPtr_)
{
infoObjectsPtr_ = new simpleObjectRegistry(1000);
infoObjectsPtr_ = new simpleObjectRegistry(100);
}
return *infoObjectsPtr_;
@ -270,7 +327,7 @@ Foam::simpleObjectRegistry& Foam::debug::optimisationObjects()
{
if (!optimisationObjectsPtr_)
{
optimisationObjectsPtr_ = new simpleObjectRegistry(1000);
optimisationObjectsPtr_ = new simpleObjectRegistry(100);
}
return *optimisationObjectsPtr_;
@ -281,13 +338,24 @@ Foam::simpleObjectRegistry& Foam::debug::dimensionSetObjects()
{
if (!dimensionSetObjectsPtr_)
{
dimensionSetObjectsPtr_ = new simpleObjectRegistry(1000);
dimensionSetObjectsPtr_ = new simpleObjectRegistry(100);
}
return *dimensionSetObjectsPtr_;
}
Foam::simpleObjectRegistry& Foam::debug::dimensionedConstantObjects()
{
if (!dimensionedConstantObjectsPtr_)
{
dimensionedConstantObjectsPtr_ = new simpleObjectRegistry(100);
}
return *dimensionedConstantObjectsPtr_;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -93,6 +93,9 @@ namespace debug
//- Register DimensionSets read/write object
void addDimensionSetObject(const char* name, simpleRegIOobject* obj);
//- Register DimensionedConstant read/write object
void addDimensionedConstantObject(const char* name, simpleRegIOobject*);
//- Get access to registered debug switch objects
simpleObjectRegistry& debugObjects();
@ -106,6 +109,8 @@ namespace debug
//- Get access to registered dimensionSets switch objects
simpleObjectRegistry& dimensionSetObjects();
//- Get access to registered dimensionedConstant switch objects
simpleObjectRegistry& dimensionedConstantObjects();
} // End namespace debug

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -25,7 +25,7 @@ Class
Foam::simpleObjectRegistry
Description
Object registry for simpleRegIOobject
Object registry for simpleRegIOobject. Maintains ordering.
SourceFiles
@ -34,7 +34,8 @@ SourceFiles
#ifndef simpleObjectRegistry_H
#define simpleObjectRegistry_H
#include "HashTable.H"
//#include "UPtrDictionary.H"
#include "Dictionary.H"
#include "simpleRegIOobject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -43,21 +44,39 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class simpleObjectRegistry Declaration
Class simpleObjectRegistryEntry Declaration
\*---------------------------------------------------------------------------*/
class simpleObjectRegistryEntry
:
public Dictionary<simpleObjectRegistryEntry>::link,
public List<simpleRegIOobject*>
{
public:
simpleObjectRegistryEntry(const List<simpleRegIOobject*>& data)
:
List<simpleRegIOobject*>(data)
{}
};
/*---------------------------------------------------------------------------*\
Class simpleObjectRegistry Declaration
\*---------------------------------------------------------------------------*/
class simpleObjectRegistry
:
public HashTable<simpleRegIOobject*>
public Dictionary<simpleObjectRegistryEntry>
{
public:
// Constructors
//- Construct from initial estimate
//- Construct given initial table size
simpleObjectRegistry(const label nIoObjects = 128)
:
HashTable<simpleRegIOobject*>(nIoObjects)
Dictionary<simpleObjectRegistryEntry>(nIoObjects)
{}
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -46,8 +46,8 @@ void Foam::interpolation2DTable<Type>::readTable()
<< exit(FatalError);
}
// Check that the data are okay
check();
// Check that the data are in ascending order
checkOrder();
}
@ -127,8 +127,8 @@ Type Foam::interpolation2DTable<Type>::interpolateValue
{
label n = data.size();
scalar minLimit = data[0].first();
scalar maxLimit = data[n-1].first();
scalar minLimit = data.first().first();
scalar maxLimit = data.last().first();
if (lookupValue < minLimit)
{
@ -138,10 +138,13 @@ Type Foam::interpolation2DTable<Type>::interpolateValue
{
FatalErrorIn
(
"Foam::interpolation2DTable<Type>::interpolateValue("
"List<Tuple2<scalar, Type> > data,"
"const scalar lookupValue)"
) << "value (" << lookupValue << ") underflow" << nl
"Foam::interpolation2DTable<Type>::interpolateValue"
"("
"List<Tuple2<scalar, Type> >&, "
"const scalar"
")"
) << "value (" << lookupValue << ") less than lower "
<< "bound (" << minLimit << ")" << nl
<< exit(FatalError);
break;
}
@ -149,17 +152,20 @@ Type Foam::interpolation2DTable<Type>::interpolateValue
{
WarningIn
(
"Foam::interpolation2DTable<Type>::interpolateValue("
"List<Tuple2<scalar, Type> > data,"
"const scalar lookupValue)"
) << "value (" << lookupValue << ") underflow" << nl
"Foam::interpolation2DTable<Type>::interpolateValue"
"("
"List<Tuple2<scalar, Type> >&, "
"const scalar"
")"
) << "value (" << lookupValue << ") less than lower "
<< "bound (" << minLimit << ")" << nl
<< " Continuing with the first entry"
<< endl;
// fall-through to 'CLAMP'
}
case interpolation2DTable::CLAMP:
{
return data[0].second();
return data.first().second();
break;
}
}
@ -172,10 +178,13 @@ Type Foam::interpolation2DTable<Type>::interpolateValue
{
FatalErrorIn
(
"Foam::interpolation2DTable<Type>::interpolateValue("
"List<Tuple2<scalar, Type> > data,"
"const scalar lookupValue)"
) << "value (" << lookupValue << ") overflow" << nl
"Foam::interpolation2DTable<Type>::interpolateValue"
"("
"List<Tuple2<scalar, Type> >&, "
"const scalar"
")"
) << "value (" << lookupValue << ") greater than upper "
<< "bound (" << maxLimit << ")" << nl
<< exit(FatalError);
break;
}
@ -183,17 +192,20 @@ Type Foam::interpolation2DTable<Type>::interpolateValue
{
WarningIn
(
"Foam::interpolation2DTable<Type>::interpolateValue("
"List<Tuple2<scalar, Type> > data,"
"const scalar lookupValue)"
) << "value (" << lookupValue << ") overflow" << nl
"Foam::interpolation2DTable<Type>::interpolateValue"
"("
"List<Tuple2<scalar, Type> >&, "
"const scalar"
")"
) << "value (" << lookupValue << ") greater than upper "
<< "bound (" << maxLimit << ")" << nl
<< " Continuing with the last entry"
<< endl;
// fall-through to 'CLAMP'
}
case interpolation2DTable::CLAMP:
{
return data[n-1].second();
return data.last().second();
break;
}
}
@ -222,25 +234,167 @@ Type Foam::interpolation2DTable<Type>::interpolateValue
}
else
{
Type m =
(data[hi].second() - data[lo].second())
/(data[hi].first() - data[lo].first());
// normal interpolation
return
(
data[lo].second()
+ (
data[hi].second()
- data[lo].second()
)
*(
lookupValue
- data[lo].first()
)
/(
data[hi].first()
- data[lo].first()
)
);
return data[lo].second() + m*(lookupValue - data[lo].first());
}
}
template<class Type>
template<class BinaryOp>
Foam::label Foam::interpolation2DTable<Type>::Xi
(
const BinaryOp& bop,
const scalar valueX,
const bool reverse
) const
{
const table& t = *this;
label limitI = 0;
if (reverse)
{
limitI = t.size() - 1;
}
if (bop(valueX, t[limitI].first()))
{
switch (boundsHandling_)
{
case interpolation2DTable::ERROR:
{
FatalErrorIn
(
"Foam::label Foam::interpolation2DTable<Type>::Xi"
"("
"const BinaryOp&, "
"const scalar, "
"const bool"
") const"
) << "value (" << valueX << ") out of bounds"
<< exit(FatalError);
break;
}
case interpolation2DTable::WARN:
{
WarningIn
(
"Foam::label Foam::interpolation2DTable<Type>::Xi"
"("
"const BinaryOp&, "
"const scalar, "
"const bool"
) << "value (" << valueX << ") out of bounds"
<< endl;
// fall-through to 'CLAMP'
}
case interpolation2DTable::CLAMP:
{
return limitI;
}
default:
{
FatalErrorIn
(
"Foam::label Foam::interpolation2DTable<Type>::Xi"
"("
"const BinaryOp&, "
"const scalar, "
"const bool"
") const"
)
<< "Un-handled enumeration " << boundsHandling_
<< abort(FatalError);
}
}
}
label i = 0;
if (reverse)
{
label nX = t.size();
i = 0;
while ((i < nX) && (valueX > t[i].first()))
{
i++;
}
}
else
{
i = t.size() - 1;
while ((i > 0) && (valueX < t[i].first()))
{
i--;
}
}
return i;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Type>
Type Foam::interpolation2DTable<Type>::operator()
(
const scalar valueX,
const scalar valueY
) const
{
// Considers all of the list in Y being equal
label nX = this->size();
const table& t = *this;
if (nX == 0)
{
WarningIn
(
"Type Foam::interpolation2DTable<Type>::operator()"
"("
"const scalar, "
"const scalar"
") const"
)
<< "cannot interpolate a zero-sized table - returning zero" << endl;
return pTraits<Type>::zero;
}
else if (nX == 1)
{
// only 1 column (in X) - interpolate to find Y value
return interpolateValue(t.first().second(), valueY);
}
else
{
// have 2-D data, interpolate
// find low and high indices in the X range that bound valueX
label x0i = Xi(lessOp<scalar>(), valueX, false);
label x1i = Xi(greaterOp<scalar>(), valueX, true);
if (x0i == x1i)
{
return interpolateValue(t[x0i].second(), valueY);
}
else
{
Type y0(interpolateValue(t[x0i].second(), valueY));
Type y1(interpolateValue(t[x1i].second(), valueY));
// gradient in X
scalar x0 = t[x0i].first();
scalar x1 = t[x1i].first();
Type mX = (y1 - y0)/(x1 - x0);
// interpolate
return y0 + mX*(valueX - x0);
}
}
}
@ -323,22 +477,23 @@ Foam::interpolation2DTable<Type>::outOfBounds
template<class Type>
void Foam::interpolation2DTable<Type>::check() const
void Foam::interpolation2DTable<Type>::checkOrder() const
{
label n = this->size();
typedef List<Tuple2<scalar, List<Tuple2<scalar, Type> > > > matrix;
scalar prevValue = matrix::operator[](0).first();
const table& t = *this;
scalar prevValue = t[0].first();
for (label i=1; i<n; ++i)
{
const scalar currValue = matrix::operator[](i).first();
const scalar currValue = t[i].first();
// avoid duplicate values (divide-by-zero error)
if (currValue <= prevValue)
{
FatalErrorIn
(
"Foam::interpolation2DTable<Type>::check() const"
"Foam::interpolation2DTable<Type>::checkOrder() const"
) << "out-of-order value: "
<< currValue << " at index " << i << nl
<< exit(FatalError);
@ -356,348 +511,7 @@ void Foam::interpolation2DTable<Type>::write(Ostream& os) const
os.writeKeyword("outOfBounds")
<< boundsHandlingToWord(boundsHandling_) << token::END_STATEMENT << nl;
if (reader_.valid())
{
reader_->write(os);
}
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Type>
const Foam::List<Foam::Tuple2<Foam::scalar, Type> >&
Foam::interpolation2DTable<Type>::operator[](const label i) const
{
label ii = i;
label n = this->size();
if (n <= 1)
{
ii = 0;
}
else if (ii < 0)
{
switch (boundsHandling_)
{
case interpolation2DTable::ERROR:
{
FatalErrorIn
(
"Foam::interpolation2DTable<Type>::operator[]"
"(const label) const"
) << "index (" << ii << ") underflow" << nl
<< exit(FatalError);
break;
}
case interpolation2DTable::WARN:
{
WarningIn
(
"Foam::interpolation2DTable<Type>::operator[]"
"(const label) const"
) << "index (" << ii << ") underflow" << nl
<< " Continuing with the first entry"
<< endl;
// fall-through to 'CLAMP'
}
case interpolation2DTable::CLAMP:
{
ii = 0;
break;
}
}
}
else if (ii >= n)
{
switch (boundsHandling_)
{
case interpolation2DTable::ERROR:
{
FatalErrorIn
(
"Foam::interpolation2DTable<Type>::operator[]"
"(const label) const"
) << "index (" << ii << ") overflow" << nl
<< exit(FatalError);
break;
}
case interpolation2DTable::WARN:
{
WarningIn
(
"Foam::interpolation2DTable<Type>::operator[]"
"(const label) const"
) << "index (" << ii << ") overflow" << nl
<< " Continuing with the last entry"
<< endl;
// fall-through to 'CLAMP'
}
case interpolation2DTable::CLAMP:
{
ii = n - 1;
break;
}
}
}
return List<Tuple2<scalar, List<Tuple2<scalar, Type> > > >::operator[](ii);
}
template<class Type>
Type Foam::interpolation2DTable<Type>::operator()
(
const scalar valueX,
const scalar valueY
) const
{
typedef List<Tuple2<scalar, List<Tuple2<scalar, Type> > > > matrix;
label nX = this->size();
if (nX <= 1)
{
const List<Tuple2<scalar, Type> >& dataY =
matrix::operator[](0).second();
return interpolateValue(dataY, valueY);
}
scalar minLimit = matrix::operator[](0).first();
scalar maxLimit = matrix::operator[](nX-1).first();
scalar lookupValue = valueX;
if (lookupValue < minLimit)
{
switch (boundsHandling_)
{
case interpolation2DTable::ERROR:
{
FatalErrorIn
(
"Foam::interpolation2DTable<Type>::operator[]"
"(const scalar, const scalar) const"
) << "value (" << lookupValue << ") underflow" << nl
<< exit(FatalError);
break;
}
case interpolation2DTable::WARN:
{
WarningIn
(
"Foam::interpolation2DTable<Type>::operator[]"
"(const scalar, const scalar) const"
) << "value (" << lookupValue << ") underflow" << nl
<< " Continuing with the first entry"
<< endl;
// fall-through to 'CLAMP'
}
case interpolation2DTable::CLAMP:
{
return interpolateValue
(
matrix::operator[](0).second(), valueY
);
break;
}
}
}
else if (lookupValue >= maxLimit)
{
switch (boundsHandling_)
{
case interpolation2DTable::ERROR:
{
FatalErrorIn
(
"Foam::interpolation2DTable<Type>::operator[]"
"(const label, const scalar) const"
) << "value (" << lookupValue << ") overflow" << nl
<< exit(FatalError);
break;
}
case interpolation2DTable::WARN:
{
WarningIn
(
"Foam::interpolation2DTable<Type>::operator[]"
"(const label, const scalar) const"
) << "value (" << lookupValue << ") overflow" << nl
<< " Continuing with the last entry"
<< endl;
// fall-through to 'CLAMP'
}
case interpolation2DTable::CLAMP:
{
return interpolateValue
(
matrix::operator[](nX-1).second(), valueY
);
break;
}
}
}
label loX = 0;
label hiX = 0;
// look for the correct range in X
for (label i = 0; i < nX; ++i)
{
if (lookupValue >= matrix::operator[](i).first())
{
loX = hiX = i;
}
else
{
hiX = i;
break;
}
}
// look for the correct range in y
lookupValue = valueY;
label loY1 = 0;
label hiY1 = 0;
label nY = matrix::operator[](loX).second().size();
minLimit = matrix::operator[](loX).second()[0].first();
maxLimit = matrix::operator[](loX).second()[nY-1].first();
if (lookupValue < minLimit)
{
switch (boundsHandling_)
{
case interpolation2DTable::ERROR:
{
FatalErrorIn
(
"Foam::interpolation2DTable<Type>::operator[]"
"(const scalar, const scalar) const"
) << "value (" << lookupValue << ") underflow" << nl
<< exit(FatalError);
break;
}
case interpolation2DTable::WARN:
{
WarningIn
(
"Foam::interpolation2DTable<Type>::operator[]"
"(const scalar, const scalar) const"
) << "value (" << lookupValue << ") underflow" << nl
<< " Continuing with the first entry"
<< endl;
// fall-through to 'CLAMP'
}
case interpolation2DTable::CLAMP:
{
hiY1 = 0;
hiY1 = 1;
break;
}
}
}
else if (lookupValue >= maxLimit)
{
switch (boundsHandling_)
{
case interpolation2DTable::ERROR:
{
FatalErrorIn
(
"Foam::interpolation2DTable<Type>::operator[]"
"(const scalar, const scalar) const"
) << "value (" << lookupValue << ") overflow" << nl
<< exit(FatalError);
break;
}
case interpolation2DTable::WARN:
{
WarningIn
(
"Foam::interpolation2DTable<Type>::operator[]"
"(const scalar, const scalar) const"
) << "value (" << lookupValue << ") overflow" << nl
<< " Continuing with the last entry"
<< endl;
// fall-through to 'CLAMP'
}
case interpolation2DTable::CLAMP:
{
hiY1 = nY-1;
hiY1 = nY;
break;
}
}
}
else
{
// Finds the lo and hi of Y on the lowest x
for (label i = 0; i < nY; ++i)
{
if
(
lookupValue >= matrix::operator[](loX).second()[i].first()
)
{
loY1 = hiY1 = i;
}
else
{
hiY1 = i;
break;
}
}
}
if (loX == hiX)
{
// we are at the end of the table - or there is only a single entry
return (interpolateValue(matrix::operator[](hiX).second(), valueY));
}
else
{
Type loXData = matrix::operator[](loX).second()[loY1].second();
Type hiXData = matrix::operator[](hiX).second()[loY1].second();
Type hiYData = matrix::operator[](loX).second()[hiY1].second();
Type refValue = matrix::operator[](loX).second()[loY1].second();
// normal interpolation on x
refValue +=
(
hiXData
- loXData
)
*(
valueX
- matrix::operator[](loX).first()
)
/(
matrix::operator[](hiX).first()
- matrix::operator[](loX).first()
);
// normal interpolation on y
refValue +=
(
hiYData
- loXData
)
*(
valueY
- matrix::operator[](loX).second()[loY1].first()
)
/(
matrix::operator[](loX).second()[hiY1].first()
- matrix::operator[](loX).second()[loY1].first()
);
return refValue;
}
*this >> os;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -66,6 +66,9 @@ public:
CLAMP /*!< Clamp value to the start/end value */
};
//- Cconvenience typedef
typedef List<Tuple2<scalar, List<Tuple2<scalar, Type> > > > table;
private:
@ -93,6 +96,15 @@ private:
const scalar
) const;
//- Return an X index from the matrix
template<class BinaryOp>
label Xi
(
const BinaryOp& bop,
const scalar valueX,
const bool reverse
) const;
public:
@ -132,7 +144,7 @@ public:
//- Check that list is monotonically increasing
// Exit with a FatalError if there is a problem
void check() const;
void checkOrder() const;
//- Write
void write(Ostream& os) const;

View File

@ -255,7 +255,7 @@ Foam::SVD::SVD(const scalarRectangularMatrix& A, const scalar minCondition)
{
scalar c = 0.0;
s = 1.0;
for (label i = l-1; i < k+1; i++)
for (label i = l; i < k+1; i++)
{
scalar f = s*rv1[i];
rv1[i] = c*rv1[i];

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -367,7 +367,8 @@ public:
);
//- Construct from reverse addressing: per data item the send
// processor and the receive processor. All processors get same data.
// processor and the receive processor. (note: data is not stored
// sorted per processor so cannot use printLayout).
mapDistribute
(
const labelList& sendProcs,
@ -635,7 +636,8 @@ public:
template<class T>
void receive(PstreamBuffers&, List<T>&) const;
//- Debug: print layout
//- Debug: print layout. Can only be used on maps with sorted
// storage (local data first, then non-local data)
void printLayout(Ostream& os) const;
//- Correct for topo change.

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -176,6 +176,10 @@ public:
//- Find patch index given a name
label findPatchID(const word& patchName) const;
//- Find patch indices for a given polyPatch type
template<class Type>
labelHashSet findPatchIDs() const;
//- Return patch index for a given face label
label whichPatch(const label faceIndex) const;
@ -235,6 +239,7 @@ public:
IOstream::compressionType cmp
) const;
// Member Operators
//- Return const and non-const reference to polyPatch by index.
@ -259,6 +264,12 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "polyBoundaryMeshTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,46 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013 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/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::labelHashSet Foam::polyBoundaryMesh::findPatchIDs() const
{
const polyBoundaryMesh& bm = *this;
labelHashSet patchIDs(bm.size());
forAll(bm, patchI)
{
if (isA<Type>(bm[patchI]))
{
patchIDs.insert(patchI);
}
}
return patchIDs;
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -44,6 +44,14 @@ namespace Foam
class dummyTransform
{
public:
template<class T>
void operator()
(
const vectorTensorTransform& vt,
const bool forward,
List<T>& fld
) const
{};
template<class T>
void operator()(const coupledPolyPatch& cpp, Field<T>& fld) const
{}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -1086,6 +1086,106 @@ Foam::label Foam::polyMeshFilter::filterEdges
}
Foam::label Foam::polyMeshFilter::filterIndirectPatchFaces()
{
newMeshPtr_ = copyMesh(mesh_);
fvMesh& newMesh = newMeshPtr_();
label nIterations = 0;
label nBadFaces = 0;
while (true)
{
Info<< nl << indent << "Iteration = "
<< nIterations++ << nl << incrIndent << endl;
// Per edge collapse status
PackedBoolList collapseEdge(newMesh.nEdges());
Map<point> collapsePointToLocation(newMesh.nPoints());
labelList boundaryPoint(newMesh.nPoints());
edgeCollapser collapser(newMesh, collapseFacesCoeffDict_);
collapser.markIndirectPatchFaces
(
collapseEdge,
collapsePointToLocation
);
// Merge edge collapses into consistent collapse-network.
// Make sure no cells get collapsed.
List<pointEdgeCollapse> allPointInfo;
const globalIndex globalPoints(newMesh.nPoints());
collapser.consistentCollapse
(
globalPoints,
boundaryPoint,
collapsePointToLocation,
collapseEdge,
allPointInfo
);
label nLocalCollapse = collapseEdge.count();
reduce(nLocalCollapse, sumOp<label>());
Info<< nl << indent << "Collapsing " << nLocalCollapse
<< " edges after synchronisation and PointEdgeWave" << endl;
if (nLocalCollapse == 0)
{
break;
}
// Apply collapses to current mesh
polyTopoChange newMeshMod(newMesh);
// Insert mesh refinement into polyTopoChange.
collapser.setRefinement(allPointInfo, newMeshMod);
Info<< indent << "Apply changes to the current mesh"
<< decrIndent << endl;
// Apply changes to current mesh
autoPtr<mapPolyMesh> newMapPtr = newMeshMod.changeMesh
(
newMesh,
false
);
const mapPolyMesh& newMap = newMapPtr();
// Update fields
newMesh.updateMesh(newMap);
if (newMap.hasMotionPoints())
{
newMesh.movePoints(newMap.preMotionPoints());
}
// Mesh check
// ~~~~~~~~~~~~~~~~~~
// Do not allow collapses in regions of error.
// Updates minEdgeLen, nRelaxedEdges
PackedBoolList isErrorPoint(newMesh.nPoints());
nBadFaces = edgeCollapser::checkMeshQuality
(
newMesh,
meshQualityCoeffDict_,
isErrorPoint
);
Info<< nl << " Number of bad faces : " << nBadFaces << nl
<< " Number of marked points : "
<< returnReduce(isErrorPoint.count(), sumOp<unsigned int>())
<< endl;
}
return nBadFaces;
}
const Foam::autoPtr<Foam::fvMesh>& Foam::polyMeshFilter::filteredMesh() const
{
return newMeshPtr_;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -224,6 +224,8 @@ public:
//- Filter edges only.
label filterEdges(const label nOriginalBadFaces);
label filterIndirectPatchFaces();
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -803,11 +803,7 @@ void Foam::edgeCollapser::checkBoundaryPointMergeEdges
{
const pointField& points = mesh_.points();
if
(
pointPriority[pointI] == 0
&& pointPriority[otherPointI] < 0
)
if (pointPriority[pointI] >= 0 && pointPriority[otherPointI] < 0)
{
collapsePointToLocation.set
(
@ -1254,6 +1250,44 @@ bool Foam::edgeCollapser::setRefinement
const labelListList& pointFaces = mesh_.pointFaces();
const pointZoneMesh& pointZones = mesh_.pointZones();
// // Dump point collapses
// label count = 0;
// forAll(allPointInfo, ptI)
// {
// const pointEdgeCollapse& pec = allPointInfo[ptI];
//
// if (mesh_.points()[ptI] != pec.collapsePoint())
// {
// count++;
// }
// }
//
// OFstream str("collapses_" + name(count) + ".obj");
// // Dump point collapses
// forAll(allPointInfo, ptI)
// {
// const pointEdgeCollapse& pec = allPointInfo[ptI];
//
// if
// (
// mesh_.points()[ptI] != pec.collapsePoint()
// && pec.collapsePoint() != vector(GREAT, GREAT, GREAT)
// )
// {
// meshTools::writeOBJ
// (
// str,
// mesh_.points()[ptI],
// pec.collapsePoint()
// );
// }
// }
bool meshChanged = false;
PackedBoolList removedPoints(mesh_.nPoints());
@ -1301,6 +1335,29 @@ bool Foam::edgeCollapser::setRefinement
}
}
// OFstream str2("collapseStrings_" + name(count) + ".obj");
// // Dump point collapses
// forAllConstIter(Map<DynamicList<label> >, collapseStrings, iter)
// {
// const label masterPoint = iter.key();
// const DynamicList<label>& edgeCollapses = iter();
//
// forAll(edgeCollapses, eI)
// {
// meshTools::writeOBJ
// (
// str2,
// mesh_.points()[edgeCollapses[eI]],
// mesh_.points()[masterPoint]
// );
// }
// }
// Current faces (is also collapseStatus: f.size() < 3)
faceList newFaces(mesh_.faces());
@ -1346,7 +1403,6 @@ bool Foam::edgeCollapser::setRefinement
do
{
// Update face collapse from edge collapses
forAll(newFaces, faceI)
{
filterFace(collapseStrings, allPointInfo, newFaces[faceI]);
@ -1857,68 +1913,29 @@ Foam::label Foam::edgeCollapser::markMergeEdges
if (e0length <= e1length)
{
if (edges[e0].start() == pointI)
{
collapseEdge[e0] = true;
collapseEdge[e0] = true;
checkBoundaryPointMergeEdges
(
pointI,
edges[e0].end(),
pointPriority,
collapsePointToLocation
);
}
else
{
collapseEdge[e0] = true;
checkBoundaryPointMergeEdges
(
pointI,
edges[e0].start(),
pointPriority,
collapsePointToLocation
);
}
checkBoundaryPointMergeEdges
(
pointI,
edges[e0].otherVertex(pointI),
pointPriority,
collapsePointToLocation
);
}
else
{
if (edges[e1].start() == pointI)
{
collapseEdge[e1] = true;
collapseEdge[e1] = true;
checkBoundaryPointMergeEdges
(
pointI,
edges[e1].end(),
pointPriority,
collapsePointToLocation
);
}
else
{
collapseEdge[e1] = true;
checkBoundaryPointMergeEdges
(
pointI,
edges[e1].start(),
pointPriority,
collapsePointToLocation
);
}
checkBoundaryPointMergeEdges
(
pointI,
edges[e1].otherVertex(pointI),
pointPriority,
collapsePointToLocation
);
}
// if (boundaryPoint[leftV] == -1)
// {
// collapseEdge[e0] = findIndex(edges[e0], leftV);
// }
// else
// {
// collapseEdge[e1] = findIndex(edges[e1], rightV);
// }
nCollapsed++;
}
}
@ -1991,4 +2008,117 @@ Foam::labelPair Foam::edgeCollapser::markSmallSliverFaces
}
void Foam::edgeCollapser::markIndirectPatchFaces
(
PackedBoolList& collapseEdge,
Map<point>& collapsePointToLocation
) const
{
const faceZone& indirectFaceZone = mesh_.faceZones()["indirectPatchFaces"];
const edgeList& edges = mesh_.edges();
const pointField& points = mesh_.points();
const labelListList& edgeFaces = mesh_.edgeFaces();
const polyBoundaryMesh& bMesh = mesh_.boundaryMesh();
forAll(edges, eI)
{
const edge& e = edges[eI];
const labelList& eFaces = edgeFaces[eI];
bool keepEdge = false;
label nInternalFaces = 0;
label nPatchFaces = 0;
label nIndirectFaces = 0;
bool coupled = false;
forAll(eFaces, eFaceI)
{
const label eFaceIndex = eFaces[eFaceI];
if (mesh_.isInternalFace(eFaceIndex))
{
nInternalFaces++;
}
else
{
const label patchIndex = bMesh.whichPatch(eFaceIndex);
const polyPatch& pPatch = bMesh[patchIndex];
if (pPatch.coupled())
{
coupled = true;
nInternalFaces++;
}
else
{
// Keep the edge if an attached face is not in the face zone
if (indirectFaceZone.whichFace(eFaceIndex) == -1)
{
nPatchFaces++;
}
else
{
nIndirectFaces++;
}
}
}
}
if (eFaces.size() != nInternalFaces + nPatchFaces + nIndirectFaces)
{
Pout<< eFaces.size() << " ("
<< nInternalFaces << "/" << nPatchFaces << "/" << nIndirectFaces
<< ")" << endl;
}
if
(
eFaces.size() == nInternalFaces
|| nIndirectFaces < (coupled ? 1 : 2)
)
{
keepEdge = true;
}
if (!keepEdge)
{
collapseEdge[eI] = true;
const Foam::point collapsePoint =
0.5*(points[e.end()] + points[e.start()]);
collapsePointToLocation.insert(e.start(), collapsePoint);
collapsePointToLocation.insert(e.end(), collapsePoint);
}
}
// OFstream str
// (
// mesh_.time().path()
// /"markedEdges_" + name(collapseEdge.count()) + ".obj"
// );
// label count = 0;
//
// forAll(collapseEdge, eI)
// {
// if (collapseEdge[eI])
// {
// const edge& e = edges[eI];
//
// meshTools::writeOBJ
// (
// str,
// points[e.start()],
// points[e.end()],
// count
// );
// }
// }
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -331,6 +331,12 @@ public:
PackedBoolList& collapseEdge,
Map<point>& collapsePointToLocation
) const;
void markIndirectPatchFaces
(
PackedBoolList& collapseEdge,
Map<point>& collapsePointToLocation
) const;
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -75,8 +75,7 @@ inline bool Foam::pointEdgeCollapse::update
{
bool identicalPoint = samePoint(w2.collapsePoint_);
bool nearer = magSqr(w2.collapsePoint_)
< magSqr(collapsePoint_);
bool nearer = (magSqr(w2.collapsePoint_) < magSqr(collapsePoint_));
if (nearer)
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -579,9 +579,7 @@ void Foam::extendedFeatureEdgeMesh::allNearestFeaturePoints
label ptI = pointTree().shapes().pointLabels()[index];
const point& pt = points()[ptI];
pointIndexHit nearHit;
nearHit = pointIndexHit(true, pt, index);
pointIndexHit nearHit(true, pt, index);
dynPointHit.append(nearHit);
}
@ -631,16 +629,12 @@ void Foam::extendedFeatureEdgeMesh::allNearestFeatureEdges
label hitIndex = index + sliceStarts[i];
pointIndexHit nearHit;
if (!hitPoint.hit())
{
nearHit = pointIndexHit(false, hitPoint.missPoint(), hitIndex);
}
else
{
nearHit = pointIndexHit(true, hitPoint.hitPoint(), hitIndex);
}
pointIndexHit nearHit
(
hitPoint.hit(),
hitPoint.rawPoint(),
hitIndex
);
dynEdgeHit.append(nearHit);
}

View File

@ -1,2 +0,0 @@
Info<< "Creating sources" << endl;
IObasicSourceList sources(mesh);

View File

@ -1,270 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 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 "interRegionHeatTransferModel.H"
#include "fluidThermo.H"
#include "fvm.H"
#include "IObasicSourceList.H"
#include "zeroGradientFvPatchFields.H"
#include "fvcVolumeIntegrate.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(interRegionHeatTransferModel, 0);
};
// * * * * * * * * * * * * Private member functions * * * * * * * * * * * //
void Foam::interRegionHeatTransferModel::check()
{
const fvMesh& secondaryMesh =
mesh_.time().lookupObject<fvMesh>(mapRegionName_);
const basicSourceList& IObsl =
secondaryMesh.lookupObject<basicSourceList>
(
"sourcesProperties"
);
const PtrList<basicSource>& bsl = IObsl;
bool secSourceFound(false);
forAll(bsl, i)
{
if (bsl[i].name() == secondarySourceName_)
{
secIrht_ = &const_cast<interRegionHeatTransferModel&>
(
refCast<const interRegionHeatTransferModel>(bsl[i])
);
secSourceFound = true;
break;
}
}
if (!secSourceFound)
{
FatalErrorIn
(
"constantHeatTransfer::interRegionHeatTransferModel::check()"
) << "Secondary source name not found" << secondarySourceName_
<< " in region " << secondaryMesh.name()
<< nl
<< exit(FatalError);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::interRegionHeatTransferModel::interRegionHeatTransferModel
(
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
)
:
basicSource(name, modelType, dict, mesh),
secIrht_(),
firstIter_(true),
htc_
(
IOobject
(
"htc",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar
(
"htc",
dimEnergy/dimTime/dimTemperature/dimVolume,
0.0
),
zeroGradientFvPatchScalarField::typeName
)
{
coeffs_.lookup("fieldNames") >> fieldNames_;
applied_.setSize(fieldNames_.size(), false);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::interRegionHeatTransferModel::~interRegionHeatTransferModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::interRegionHeatTransferModel::addSup
(
fvMatrix<scalar>& eEqn,
const label fieldI
)
{
if (secondaryToPrimaryInterpPtr_.valid())
{
if (firstIter_)
{
check();
firstIter_ = false;
}
const volScalarField& h = eEqn.psi();
tmp<volScalarField> tTmapped
(
new volScalarField
(
IOobject
(
"Tmapped" + mesh_.name(),
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("T", dimTemperature, 0.0)
)
);
volScalarField& Tmapped = tTmapped();
const fvMesh& secondaryMesh =
mesh_.time().lookupObject<fvMesh>(mapRegionName_);
const volScalarField& Tsecondary =
secondaryMesh.lookupObject<volScalarField>("T");
secondaryToPrimaryInterpPtr_->interpolateInternalField
(
Tmapped,
Tsecondary,
meshToMesh::MAP,
eqOp<scalar>()
);
if (!master_)
{
secondaryToPrimaryInterpPtr_->interpolateInternalField
(
htc_,
secIrht_->calculateHtc(),
meshToMesh::CELL_VOLUME_WEIGHT,
eqOp<scalar>()
);
}
if (debug)
{
Info<< " Volumetric integral of htc : "
<< fvc::domainIntegrate(htc_).value()
<< endl;
}
if (debug && mesh_.time().outputTime())
{
Tmapped.write();
htc_.write();
}
if (h.dimensions() == dimEnergy/dimMass)
{
const fluidThermo& primaryThermo =
mesh_.lookupObject<fluidThermo>("thermophysicalProperties");
eEqn += htc_*Tmapped - fvm::Sp(htc_/primaryThermo.Cp(), h);
if (debug)
{
Info<< " Energy exchange from region " << secondaryMesh.name()
<< " To " << mesh_.name() << " : "
<< fvc::domainIntegrate
(
htc_*(h/primaryThermo.Cp() - Tmapped)
).value()
<< endl;
}
}
else if (h.dimensions() == dimTemperature)
{
eEqn += htc_*Tmapped - fvm::Sp(htc_, h);
if (debug)
{
Info<< " Enegy exchange from region " << secondaryMesh.name()
<< " To " << mesh_.name() << " : "
<< fvc::domainIntegrate(htc_*(h - Tmapped)).value()
<< endl;
}
}
}
}
void Foam::interRegionHeatTransferModel::writeData(Ostream& os) const
{
os.writeKeyword("name") << this->name() << token::END_STATEMENT << nl;
os.writeKeyword("mapRegionName") << mapRegionName_
<< token::END_STATEMENT << nl;
os.writeKeyword("secondarySourceName") << secondarySourceName_
<< token::END_STATEMENT << nl;
os.writeKeyword("master") << master_ << token::END_STATEMENT << nl;
if (dict_.found("note"))
{
os.writeKeyword("note") << string(dict_.lookup("note"))
<< token::END_STATEMENT << nl;
}
dict_.write(os);
}
bool Foam::interRegionHeatTransferModel::read(const dictionary& dict)
{
if (basicSource::read(dict))
{
return true;
}
else
{
return false;
}
}
// ************************************************************************* //

View File

@ -36,6 +36,7 @@ $(derivedFvPatches)/regionCoupled/regionCoupledWallFvPatch.C
wallDist = fvMesh/wallDist
$(wallDist)/patchDist.C
$(wallDist)/wallPointYPlus/wallPointYPlus.C
$(wallDist)/nearWallDistNoSearch.C
$(wallDist)/nearWallDist.C

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -37,27 +37,31 @@ void Foam::extendedCellToFaceStencil::collectData
)
{
// 1. Construct cell data in compact addressing
List<Type> compactFld(map.constructSize(), pTraits<Type>::zero);
List<Type> flatFld(map.constructSize(), pTraits<Type>::zero);
// Insert my internal values
forAll(fld, cellI)
{
compactFld[cellI] = fld[cellI];
flatFld[cellI] = fld[cellI];
}
// Insert my boundary values
label nCompact = fld.size();
forAll(fld.boundaryField(), patchI)
{
const fvPatchField<Type>& pfld = fld.boundaryField()[patchI];
label nCompact =
pfld.patch().start()
-fld.mesh().nInternalFaces()
+fld.mesh().nCells();
forAll(pfld, i)
{
compactFld[nCompact++] = pfld[i];
flatFld[nCompact++] = pfld[i];
}
}
// Do all swapping
map.distribute(compactFld);
map.distribute(flatFld);
// 2. Pull to stencil
stencilFld.setSize(stencil.size());
@ -70,7 +74,7 @@ void Foam::extendedCellToFaceStencil::collectData
forAll(compactCells, i)
{
stencilFld[faceI][i] = compactFld[compactCells[i]];
stencilFld[faceI][i] = flatFld[compactCells[i]];
}
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,8 +23,8 @@ License
\*---------------------------------------------------------------------------*/
#include "mapDistribute.H"
#include "extendedCentredFaceToCellStencil.H"
#include "mapDistribute.H"
#include "faceToCellStencil.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -37,27 +37,28 @@ void Foam::extendedFaceToCellStencil::collectData
)
{
// 1. Construct face data in compact addressing
List<Type> compactFld(map.constructSize(), pTraits<Type>::zero);
List<Type> flatFld(map.constructSize(), pTraits<Type>::zero);
// Insert my internal values
forAll(fld, cellI)
{
compactFld[cellI] = fld[cellI];
flatFld[cellI] = fld[cellI];
}
// Insert my boundary values
label nCompact = fld.size();
forAll(fld.boundaryField(), patchI)
{
const fvsPatchField<Type>& pfld = fld.boundaryField()[patchI];
label nCompact = pfld.patch().start();
forAll(pfld, i)
{
compactFld[nCompact++] = pfld[i];
flatFld[nCompact++] = pfld[i];
}
}
// Do all swapping
map.distribute(compactFld);
map.distribute(flatFld);
// 2. Pull to stencil
stencilFld.setSize(stencil.size());
@ -70,7 +71,7 @@ void Foam::extendedFaceToCellStencil::collectData
forAll(compactCells, i)
{
stencilFld[faceI][i] = compactFld[compactCells[i]];
stencilFld[faceI][i] = flatFld[compactCells[i]];
}
}
}

View File

@ -0,0 +1,91 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 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 "patchDist.H"
#include "patchWave.H"
#include "fvMesh.H"
#include "emptyFvPatchFields.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::patchDist::patchDist
(
const fvMesh& mesh,
const labelHashSet& patchIDs,
const bool correctWalls
)
:
volScalarField
(
IOobject
(
"y",
mesh.time().timeName(),
mesh
),
mesh,
dimensionedScalar("y", dimLength, GREAT)
),
patchIDs_(patchIDs),
correctWalls_(correctWalls),
nUnset_(0)
{
patchDist::correct();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::patchDist::~patchDist()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::patchDist::correct()
{
// Calculate distance starting from patch faces
patchWave wave(mesh(), patchIDs_, correctWalls_);
// Transfer cell values from wave into *this
transfer(wave.distance());
// Transfer values on patches into boundaryField of *this
forAll(boundaryField(), patchI)
{
if (!isA<emptyFvPatchScalarField>(boundaryField()[patchI]))
{
scalarField& waveFld = wave.patchDistance()[patchI];
boundaryField()[patchI].transfer(waveFld);
}
}
// Transfer number of unset values
nUnset_ = wave.nUnset();
}
// ************************************************************************* //

View File

@ -0,0 +1,150 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 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::patchDist
Description
Calculation of distance to nearest patch for all cells and boundary.
Uses meshWave to do actual calculation.
Distance correction:
if correctWalls = true:
For each cell with face on wall calculate the true nearest point
(by triangle decomposition) on that face and do the same for that face's
pointNeighbours. This will find the true nearest distance in almost all
cases. Only very skewed cells or cells close to another wall might be
missed.
For each cell with only one point on wall the same is done except now it
takes the pointFaces() of the wall point to look for the nearest point.
Note
correct() : for now does complete recalculation. (which usually is
ok since mesh is smoothed). However for topology change where geometry
in most of domain does not change you could think of starting from the
old cell values. Tried but not done since:
- meshWave would have to be called with old cellInfo.
This is List\<wallInfo\> of nCells.
- cannot construct from distance (y_) only since we don't know a value
for origin_. (origin_ = GREAT already used to denote illegal value.)
- so we would have to store a List\<wallInfo\> which unfortunately does
not get resized/mapped automatically upon mesh changes.
SourceFiles
patchDist.C
\*---------------------------------------------------------------------------*/
#ifndef patchDist_H
#define patchDist_H
#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class fvMesh;
/*---------------------------------------------------------------------------*\
Class patchDist Declaration
\*---------------------------------------------------------------------------*/
class patchDist
:
public volScalarField
{
private:
// Private Member Data
//- Set of patch IDs
labelHashSet patchIDs_;
//- Do accurate distance calculation for near-wall cells.
bool correctWalls_;
//- Number of unset cells and faces.
label nUnset_;
// Private Member Functions
//- Disallow default bitwise copy construct
patchDist(const patchDist&);
//- Disallow default bitwise assignment
void operator=(const patchDist&);
public:
// Constructors
//- Construct from mesh and flag whether or not to correct wall.
// Calculate for all cells. correctWalls : correct wall (face&point)
// cells for correct distance, searching neighbours.
patchDist
(
const fvMesh& mesh,
const labelHashSet& patchIDs,
const bool correctWalls = true
);
//- Destructor
virtual ~patchDist();
// Member Functions
const volScalarField& y() const
{
return *this;
}
label nUnset() const
{
return nUnset_;
}
//- Correct for mesh geom/topo changes
virtual void correct();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,34 +24,24 @@ License
\*---------------------------------------------------------------------------*/
#include "wallDist.H"
#include "patchWave.H"
#include "fvMesh.H"
#include "wallPolyPatch.H"
#include "fvPatchField.H"
#include "Field.H"
#include "emptyFvPatchFields.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::wallDist::wallDist(const fvMesh& mesh, const bool correctWalls)
Foam::wallDist::wallDist
(
const fvMesh& mesh,
const bool correctWalls
)
:
volScalarField
patchDist
(
IOobject
(
"y",
mesh.time().timeName(),
mesh
),
mesh,
dimensionedScalar("y", dimLength, GREAT)
),
cellDistFuncs(mesh),
correctWalls_(correctWalls),
nUnset_(0)
{
wallDist::correct();
}
mesh.boundaryMesh().findPatchIDs<wallPolyPatch>(),
correctWalls
)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -60,35 +50,4 @@ Foam::wallDist::~wallDist()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Correct for mesh geom/topo changes. Might be more intelligent in the
// future (if only small topology change)
void Foam::wallDist::correct()
{
// Get patchids of walls
labelHashSet wallPatchIDs(getPatchIDs<wallPolyPatch>());
// Calculate distance starting from wallPatch faces.
patchWave wave(cellDistFuncs::mesh(), wallPatchIDs, correctWalls_);
// Transfer cell values from wave into *this
transfer(wave.distance());
// Transfer values on patches into boundaryField of *this
forAll(boundaryField(), patchI)
{
if (!isA<emptyFvPatchScalarField>(boundaryField()[patchI]))
{
scalarField& waveFld = wave.patchDistance()[patchI];
boundaryField()[patchI].transfer(waveFld);
}
}
// Transfer number of unset values
nUnset_ = wave.nUnset();
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -25,33 +25,7 @@ Class
Foam::wallDist
Description
Calculation of distance to nearest wall for all cells and boundary.
Uses meshWave to do actual calculation.
Distance correction:
if correctWalls = true:
For each cell with face on wall calculate the true nearest point
(by triangle decomposition) on that face and do that same for that face's
pointNeighbours. This will find the true nearest distance in almost all
cases. Only very skewed cells or cells close to another wall might be
missed.
For each cell with only point on wall the same is done except now it takes
the pointFaces() of the wall point to look for the nearest point.
Note
correct() : for now does complete recalculation. (which usually is
ok since mesh is smoothed). However for topology change where geometry
in most of domain does not change you could think of starting from the
old cell values. Tried but not done since:
- meshWave would have to be called with old cellInfo.
This is List\<wallInfo\> of nCells.
- cannot construct from distance (y_) only since we don't know a value
for origin_. (origin_ = GREAT already used to denote illegal value.)
- so we would have to store a List\<wallInfo\> which unfortunately does
not get resized/mapped automatically upon mesh changes.
Specialisation of patchDist for wall distance calculation
SourceFiles
wallDist.C
@ -61,9 +35,7 @@ SourceFiles
#ifndef wallDist_H
#define wallDist_H
#include "volFields.H"
#include "cellDistFuncs.H"
#include "patchDist.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -73,27 +45,16 @@ namespace Foam
class fvMesh;
/*---------------------------------------------------------------------------*\
Class wallDist Declaration
Class wallDist Declaration
\*---------------------------------------------------------------------------*/
class wallDist
:
public volScalarField,
public cellDistFuncs
public patchDist
{
private:
// Private Member Data
//- Do accurate distance calculation for near-wall cells.
bool correctWalls_;
//- Number of unset cells and faces.
label nUnset_;
// Private Member Functions
//- Disallow default bitwise copy construct
@ -110,27 +71,15 @@ public:
//- Construct from mesh and flag whether or not to correct wall.
// Calculate for all cells. correctWalls : correct wall (face&point)
// cells for correct distance, searching neighbours.
wallDist(const fvMesh& mesh, bool correctWalls = true);
wallDist
(
const fvMesh& mesh,
const bool correctWalls = true
);
//- Destructor
virtual ~wallDist();
// Member Functions
const volScalarField& y() const
{
return *this;
}
label nUnset() const
{
return nUnset_;
}
//- Correct for mesh geom/topo changes
virtual void correct();
};

View File

@ -1,7 +1,7 @@
basicSource/basicSource.C
basicSource/basicSourceIO.C
basicSource/basicSourceList.C
basicSource/IObasicSourceList.C
fvOptions/fvOption.C
fvOptions/fvOptionIO.C
fvOptions/fvOptionList.C
fvOptions/fvIOoptionList.C
/* sources */
@ -45,4 +45,4 @@ $(derivedConstraints)/fixedTemperatureConstraint/fixedTemperatureConstraint.C
$(derivedConstraints)/temperatureLimitsConstraint/temperatureLimitsConstraint.C
LIB = $(FOAM_LIBBIN)/libfieldSources
LIB = $(FOAM_LIBBIN)/libfvOptions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -34,16 +34,19 @@ License
namespace Foam
{
defineTypeNameAndDebug(fixedTemperatureConstraint, 0);
addToRunTimeSelectionTable
(
basicSource,
fixedTemperatureConstraint,
dictionary
);
namespace fv
{
defineTypeNameAndDebug(fixedTemperatureConstraint, 0);
addToRunTimeSelectionTable
(
option,
fixedTemperatureConstraint,
dictionary
);
}
template<>
const char* NamedEnum<fixedTemperatureConstraint::temperatureMode, 2>::
const char* NamedEnum<fv::fixedTemperatureConstraint::temperatureMode, 2>::
names[] =
{
"uniform",
@ -51,13 +54,13 @@ namespace Foam
};
}
const Foam::NamedEnum<Foam::fixedTemperatureConstraint::temperatureMode, 2>
Foam::fixedTemperatureConstraint::temperatureModeNames_;
const Foam::NamedEnum<Foam::fv::fixedTemperatureConstraint::temperatureMode, 2>
Foam::fv::fixedTemperatureConstraint::temperatureModeNames_;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fixedTemperatureConstraint::fixedTemperatureConstraint
Foam::fv::fixedTemperatureConstraint::fixedTemperatureConstraint
(
const word& name,
const word& modelType,
@ -65,7 +68,7 @@ Foam::fixedTemperatureConstraint::fixedTemperatureConstraint
const fvMesh& mesh
)
:
basicSource(name, modelType, dict, mesh),
option(name, modelType, dict, mesh),
mode_(temperatureModeNames_.read(coeffs_.lookup("mode"))),
Tuniform_(NULL),
TName_("T")
@ -99,13 +102,13 @@ Foam::fixedTemperatureConstraint::fixedTemperatureConstraint
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::fixedTemperatureConstraint::alwaysApply() const
bool Foam::fv::fixedTemperatureConstraint::alwaysApply() const
{
return true;
}
void Foam::fixedTemperatureConstraint::setValue
void Foam::fv::fixedTemperatureConstraint::setValue
(
fvMatrix<scalar>& eqn,
const label
@ -146,16 +149,16 @@ void Foam::fixedTemperatureConstraint::setValue
}
void Foam::fixedTemperatureConstraint::writeData(Ostream& os) const
void Foam::fv::fixedTemperatureConstraint::writeData(Ostream& os) const
{
os << indent << name_ << endl;
dict_.write(os);
}
bool Foam::fixedTemperatureConstraint::read(const dictionary& dict)
bool Foam::fv::fixedTemperatureConstraint::read(const dictionary& dict)
{
if (basicSource::read(dict))
if (option::read(dict))
{
if (coeffs_.found(Tuniform_->name()))
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::fixedTemperatureConstraint
Foam::fv::fixedTemperatureConstraint
Description
Fixed temperature equation constraint
@ -46,14 +46,14 @@ Note:
by means of the DataEntry type.
SourceFiles
basicSource.C
fvOption.C
\*---------------------------------------------------------------------------*/
#ifndef fixedTemperatureConstraint_H
#define fixedTemperatureConstraint_H
#include "basicSource.H"
#include "fvOption.H"
#include "NamedEnum.H"
#include "DataEntry.H"
@ -61,6 +61,8 @@ SourceFiles
namespace Foam
{
namespace fv
{
/*---------------------------------------------------------------------------*\
Class fixedTemperatureConstraint Declaration
@ -68,7 +70,7 @@ namespace Foam
class fixedTemperatureConstraint
:
public basicSource
public option
{
public:
@ -156,6 +158,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fv
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -32,19 +32,22 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace fv
{
defineTypeNameAndDebug(temperatureLimitsConstraint, 0);
addToRunTimeSelectionTable
(
basicSource,
option,
temperatureLimitsConstraint,
dictionary
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::temperatureLimitsConstraint::temperatureLimitsConstraint
Foam::fv::temperatureLimitsConstraint::temperatureLimitsConstraint
(
const word& name,
const word& modelType,
@ -52,7 +55,7 @@ Foam::temperatureLimitsConstraint::temperatureLimitsConstraint
const fvMesh& mesh
)
:
basicSource(name, modelType, dict, mesh),
option(name, modelType, dict, mesh),
Tmin_(readScalar(coeffs_.lookup("Tmin"))),
Tmax_(readScalar(coeffs_.lookup("Tmax")))
{
@ -63,13 +66,13 @@ Foam::temperatureLimitsConstraint::temperatureLimitsConstraint
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::temperatureLimitsConstraint::alwaysApply() const
bool Foam::fv::temperatureLimitsConstraint::alwaysApply() const
{
return true;
}
void Foam::temperatureLimitsConstraint::correct(volScalarField& he)
void Foam::fv::temperatureLimitsConstraint::correct(volScalarField& he)
{
const basicThermo& thermo =
mesh_.lookupObject<basicThermo>("thermophysicalProperties");
@ -123,16 +126,16 @@ void Foam::temperatureLimitsConstraint::correct(volScalarField& he)
}
void Foam::temperatureLimitsConstraint::writeData(Ostream& os) const
void Foam::fv::temperatureLimitsConstraint::writeData(Ostream& os) const
{
os << indent << name_ << endl;
dict_.write(os);
}
bool Foam::temperatureLimitsConstraint::read(const dictionary& dict)
bool Foam::fv::temperatureLimitsConstraint::read(const dictionary& dict)
{
if (basicSource::read(dict))
if (option::read(dict))
{
coeffs_.readIfPresent("Tmin", Tmin_);
coeffs_.readIfPresent("Tmax", Tmax_);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::temperatureLimitsConstraint
Foam::fv::temperatureLimitsConstraint
Description
Constraint for temperature to apply limits between minimum and maximum
@ -39,19 +39,21 @@ Description
SourceFiles
basicSource.C
fvOption.C
\*---------------------------------------------------------------------------*/
#ifndef temperatureLimitsConstraint_H
#define temperatureLimitsConstraint_H
#include "basicSource.H"
#include "fvOption.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace fv
{
/*---------------------------------------------------------------------------*\
Class temperatureLimitsConstraint Declaration
@ -59,7 +61,7 @@ namespace Foam
class temperatureLimitsConstraint
:
public basicSource
public option
{
protected:
@ -130,6 +132,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fv
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -31,7 +31,7 @@ License
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::ExplicitSetValue<Type>::setFieldData(const dictionary& dict)
void Foam::fv::ExplicitSetValue<Type>::setFieldData(const dictionary& dict)
{
fieldNames_.setSize(dict.toc().size());
injectionRate_.setSize(fieldNames_.size());
@ -51,7 +51,7 @@ void Foam::ExplicitSetValue<Type>::setFieldData(const dictionary& dict)
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::ExplicitSetValue<Type>::ExplicitSetValue
Foam::fv::ExplicitSetValue<Type>::ExplicitSetValue
(
const word& name,
const word& modelType,
@ -59,7 +59,7 @@ Foam::ExplicitSetValue<Type>::ExplicitSetValue
const fvMesh& mesh
)
:
basicSource(name, modelType, dict, mesh),
option(name, modelType, dict, mesh),
injectionRate_()
{
read(dict);
@ -69,7 +69,7 @@ Foam::ExplicitSetValue<Type>::ExplicitSetValue
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::ExplicitSetValue<Type>::setValue
void Foam::fv::ExplicitSetValue<Type>::setValue
(
fvMatrix<Type>& eqn,
const label fieldI

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::explicitSetValue
Foam::fv::explicitSetValue
Description
Set values field values explicity.
@ -41,7 +41,7 @@ Description
\endverbatim
SeeAlso
Foam::basicSource
Foam::fvOption
SourceFiles
explicitSetValue.C
@ -51,13 +51,15 @@ SourceFiles
#ifndef ExplicitSetValue_H
#define ExplicitSetValue_H
#include "basicSource.H"
#include "fvOption.H"
#include "Tuple2.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace fv
{
/*---------------------------------------------------------------------------*\
Class explicitSetValue Declaration
@ -66,7 +68,7 @@ namespace Foam
template<class Type>
class ExplicitSetValue
:
public basicSource
public option
{
protected:
@ -121,6 +123,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fv
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -28,7 +28,7 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::ExplicitSetValue<Type>::writeData(Ostream& os) const
void Foam::fv::ExplicitSetValue<Type>::writeData(Ostream& os) const
{
os << indent << name_ << endl;
dict_.write(os);
@ -36,9 +36,9 @@ void Foam::ExplicitSetValue<Type>::writeData(Ostream& os) const
template<class Type>
bool Foam::ExplicitSetValue<Type>::read(const dictionary& dict)
bool Foam::fv::ExplicitSetValue<Type>::read(const dictionary& dict)
{
if (basicSource::read(dict))
if (option::read(dict))
{
setFieldData(coeffs_.subDict("injectionRate"));
return true;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,18 +23,21 @@ License
\*---------------------------------------------------------------------------*/
#include "makeBasicSource.H"
#include "makeFvOption.H"
#include "ExplicitSetValue.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makeBasicSource(ExplicitSetValue, scalar);
makeBasicSource(ExplicitSetValue, vector);
makeBasicSource(ExplicitSetValue, sphericalTensor);
makeBasicSource(ExplicitSetValue, symmTensor);
makeBasicSource(ExplicitSetValue, tensor);
namespace fv
{
makeFvOption(ExplicitSetValue, scalar);
makeFvOption(ExplicitSetValue, vector);
makeFvOption(ExplicitSetValue, sphericalTensor);
makeFvOption(ExplicitSetValue, symmTensor);
makeFvOption(ExplicitSetValue, tensor);
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,21 +23,21 @@ License
\*---------------------------------------------------------------------------*/
#include "IObasicSourceList.H"
#include "fvIOoptionList.H"
#include "fvMesh.H"
#include "Time.H"
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
Foam::IOobject Foam::IObasicSourceList::createIOobject
Foam::IOobject Foam::fv::IOoptionList::createIOobject
(
const fvMesh& mesh
) const
{
IOobject io
(
"sourcesProperties",
mesh.time().constant(),
"fvOptions",
mesh.time().system(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
@ -62,21 +62,21 @@ Foam::IOobject Foam::IObasicSourceList::createIOobject
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::IObasicSourceList::IObasicSourceList
Foam::fv::IOoptionList::IOoptionList
(
const fvMesh& mesh
)
:
IOdictionary(createIOobject(mesh)),
basicSourceList(mesh, *this)
optionList(mesh, *this)
{}
bool Foam::IObasicSourceList::read()
bool Foam::fv::IOoptionList::read()
{
if (regIOobject::read())
{
basicSourceList::read(*this);
optionList::read(*this);
return true;
}
else
@ -87,4 +87,3 @@ bool Foam::IObasicSourceList::read()
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -22,20 +22,20 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::IObasicSourceList
Foam::fv::IOoptionList
Description
IObasicSourceList
IOoptionList
SourceFiles
IObasicSourceList.C
IOoptionList.C
\*---------------------------------------------------------------------------*/
#ifndef IObasicSourceList_H
#define IObasicSourceList_H
#ifndef IOoptionList_H
#define IOoptionList_H
#include "basicSourceList.H"
#include "fvOptionList.H"
#include "IOdictionary.H"
#include "autoPtr.H"
@ -43,15 +43,17 @@ SourceFiles
namespace Foam
{
namespace fv
{
/*---------------------------------------------------------------------------*\
Class IObasicSourceList Declaration
Class IOoptionList Declaration
\*---------------------------------------------------------------------------*/
class IObasicSourceList
class IOoptionList
:
public IOdictionary,
public basicSourceList
public optionList
{
private:
@ -61,10 +63,10 @@ private:
IOobject createIOobject(const fvMesh& mesh) const;
//- Disallow default bitwise copy construct
IObasicSourceList(const IObasicSourceList&);
IOoptionList(const IOoptionList&);
//- Disallow default bitwise assignment
void operator=(const IObasicSourceList&);
void operator=(const IOoptionList&);
public:
@ -72,11 +74,11 @@ public:
// Constructors
//- Construct from components with list of field names
IObasicSourceList(const fvMesh& mesh);
IOoptionList(const fvMesh& mesh);
//- Destructor
virtual ~IObasicSourceList()
virtual ~IOoptionList()
{}
@ -89,6 +91,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fv
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,7 +23,7 @@ License
\*---------------------------------------------------------------------------*/
#include "basicSource.H"
#include "fvOption.H"
#include "fvMesh.H"
#include "fvMatrices.H"
#include "volFields.H"
@ -33,12 +33,15 @@ License
namespace Foam
{
defineTypeNameAndDebug(basicSource, 0);
defineRunTimeSelectionTable(basicSource, dictionary);
namespace fv
{
defineTypeNameAndDebug(option, 0);
defineRunTimeSelectionTable(option, dictionary);
}
template<> const char* NamedEnum
<
basicSource::selectionModeType,
fv::option::selectionModeType,
5
>::names[] =
{
@ -49,20 +52,20 @@ namespace Foam
"all"
};
const NamedEnum<basicSource::selectionModeType, 5>
basicSource::selectionModeTypeNames_;
const NamedEnum<fv::option::selectionModeType, 5>
fv::option::selectionModeTypeNames_;
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
bool Foam::basicSource::alwaysApply() const
bool Foam::fv::option::alwaysApply() const
{
return false;
}
void Foam::basicSource::setSelection(const dictionary& dict)
void Foam::fv::option::setSelection(const dictionary& dict)
{
switch (selectionMode_)
{
@ -83,8 +86,8 @@ void Foam::basicSource::setSelection(const dictionary& dict)
}
case smMapRegion:
{
dict_.lookup("secondarySourceName") >> secondarySourceName_;
dict_.lookup("mapRegionName") >> mapRegionName_;
dict_.lookup("nbrModelName") >> nbrModelName_;
dict_.lookup("nbrRegionName") >> nbrRegionName_;
master_ = readBool(dict_.lookup("master"));
break;
}
@ -94,10 +97,8 @@ void Foam::basicSource::setSelection(const dictionary& dict)
}
default:
{
FatalErrorIn
(
"basicSource::setSelection(const dictionary&)"
) << "Unknown selectionMode "
FatalErrorIn("option::setSelection(const dictionary&)")
<< "Unknown selectionMode "
<< selectionModeTypeNames_[selectionMode_]
<< ". Valid selectionMode types are" << selectionModeTypeNames_
<< exit(FatalError);
@ -106,14 +107,13 @@ void Foam::basicSource::setSelection(const dictionary& dict)
}
void Foam::basicSource::setCellSet()
void Foam::fv::option::setCellSet()
{
Info<< incrIndent << indent << "Source: " << name_ << endl;
switch (selectionMode_)
{
case smPoints:
{
Info<< indent << "- selecting cells using points" << endl;
IInfo<< "- selecting cells using points" << endl;
labelHashSet selectedCells;
@ -128,7 +128,7 @@ void Foam::basicSource::setCellSet()
label globalCellI = returnReduce(cellI, maxOp<label>());
if (globalCellI < 0)
{
WarningIn("basicSource::setCellIds()")
WarningIn("option::setCellSet()")
<< "Unable to find owner cell for point " << points_[i]
<< endl;
@ -142,8 +142,7 @@ void Foam::basicSource::setCellSet()
}
case smCellSet:
{
Info<< indent << "- selecting cells using cellSet "
<< cellSetName_ << endl;
IInfo<< "- selecting cells using cellSet " << cellSetName_ << endl;
cellSet selectedCells(mesh_, cellSetName_);
cells_ = selectedCells.toc();
@ -152,12 +151,12 @@ void Foam::basicSource::setCellSet()
}
case smCellZone:
{
Info<< indent << "- selecting cells using cellZone "
<< cellSetName_ << endl;
IInfo<< "- selecting cells using cellZone " << cellSetName_ << endl;
label zoneID = mesh_.cellZones().findZoneID(cellSetName_);
if (zoneID == -1)
{
FatalErrorIn("basicSource::setCellIds()")
FatalErrorIn("option::setCellIds()")
<< "Cannot find cellZone " << cellSetName_ << endl
<< "Valid cellZones are " << mesh_.cellZones().names()
<< exit(FatalError);
@ -170,14 +169,15 @@ void Foam::basicSource::setCellSet()
{
if (active_)
{
Info<< indent << "- selecting inter region mapping" << endl;
const fvMesh& secondaryMesh =
mesh_.time().lookupObject<fvMesh>(mapRegionName_);
IInfo<< "- selecting inter region mapping" << endl;
boundBox primaryBB(mesh_.points(), false);
boundBox secondaryBB(secondaryMesh.points(), false);
const fvMesh& nbrMesh =
mesh_.time().lookupObject<fvMesh>(nbrRegionName_);
if (secondaryBB.overlaps(primaryBB))
boundBox BB(mesh_.points(), false);
boundBox nbrBB(nbrMesh.points(), false);
if (nbrBB.overlaps(BB))
{
// Dummy patches
wordList cuttingPatches;
@ -187,7 +187,7 @@ void Foam::basicSource::setCellSet()
(
new meshToMesh
(
secondaryMesh,
nbrMesh,
mesh_,
patchMap,
cuttingPatches
@ -196,13 +196,9 @@ void Foam::basicSource::setCellSet()
}
else
{
FatalErrorIn
(
"Foam::basicSource::setCellSet()"
) << "regions dont overlap "
<< secondaryMesh.name()
<< " in region " << mesh_.name()
<< nl
FatalErrorIn("option::setCellSet()")
<< "regions do not overlap " << nbrMesh.name()
<< " in region " << mesh_.name() << nl
<< exit(FatalError);
}
}
@ -210,14 +206,14 @@ void Foam::basicSource::setCellSet()
}
case smAll:
{
Info<< indent << "- selecting all cells" << endl;
IInfo<< "- selecting all cells" << endl;
cells_ = identity(mesh_.nCells());
break;
}
default:
{
FatalErrorIn("basicSource::setCellIds()")
FatalErrorIn("option::setCellSet()")
<< "Unknown selectionMode "
<< selectionModeTypeNames_[selectionMode_]
<< ". Valid selectionMode types are" << selectionModeTypeNames_
@ -235,16 +231,15 @@ void Foam::basicSource::setCellSet()
}
reduce(V_, sumOp<scalar>());
Info<< indent << "- selected "
<< returnReduce(cells_.size(), sumOp<label>())
<< " cell(s) with volume " << V_ << nl << decrIndent << endl;
IInfo<< "- selected " << returnReduce(cells_.size(), sumOp<label>())
<< " cell(s) with volume " << V_ << nl << endl;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::basicSource::basicSource
Foam::fv::option::option
(
const word& name,
const word& modelType,
@ -257,31 +252,42 @@ Foam::basicSource::basicSource
dict_(dict),
coeffs_(dict.subDict(modelType + "Coeffs")),
active_(readBool(dict_.lookup("active"))),
timeStart_(readScalar(dict_.lookup("timeStart"))),
duration_(readScalar(dict_.lookup("duration"))),
selectionMode_
(
selectionModeTypeNames_.read(dict_.lookup("selectionMode"))
),
timeStart_(-1.0),
duration_(0.0),
selectionMode_(selectionModeTypeNames_.read(dict_.lookup("selectionMode"))),
cellSetName_("none"),
V_(0.0),
secondaryToPrimaryInterpPtr_(),
secondarySourceName_("none"),
mapRegionName_("none"),
nbrModelName_("none"),
nbrRegionName_("none"),
master_(false),
fieldNames_(),
applied_()
{
Info<< incrIndent << indent << "Source: " << name_ << endl;
if (dict_.readIfPresent("timeStart", timeStart_))
{
dict_.lookup("duration") >> duration_;
IInfo<< "- applying source at time " << timeStart_
<< " for duration " << duration_ << endl;
}
else
{
IInfo<< "- applying source for all time" << endl;
}
setSelection(dict_);
setCellSet();
Info<< decrIndent;
}
// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::basicSource> Foam::basicSource::New
Foam::autoPtr<Foam::fv::option> Foam::fv::option::New
(
const word& name,
const dictionary& coeffs,
@ -290,7 +296,7 @@ Foam::autoPtr<Foam::basicSource> Foam::basicSource::New
{
word modelType(coeffs.lookup("type"));
Info<< "Selecting source model type " << modelType << endl;
IInfo<< "Selecting source model type " << modelType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(modelType);
@ -299,20 +305,18 @@ Foam::autoPtr<Foam::basicSource> Foam::basicSource::New
{
FatalErrorIn
(
"basicSource::New"
"(const name&, const dictionary&, const fvMesh&)"
) << "Unknown Model type " << modelType
<< nl << nl
"option::New(const word&, const dictionary&, const fvMesh&)"
) << "Unknown Model type " << modelType << nl << nl
<< "Valid model types are:" << nl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<basicSource>(cstrIter()(name, modelType, coeffs, mesh));
return autoPtr<option>(cstrIter()(name, modelType, coeffs, mesh));
}
Foam::basicSource::~basicSource()
Foam::fv::option::~option()
{
if (!secondaryToPrimaryInterpPtr_.empty())
{
@ -323,14 +327,9 @@ Foam::basicSource::~basicSource()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::basicSource::isActive()
bool Foam::fv::option::isActive()
{
if
(
active_
&& (mesh_.time().value() >= timeStart_)
&& (mesh_.time().value() <= timeEnd())
)
if (active_ && inTimeLimits(mesh_.time().value()))
{
// Update the cell set if the mesh is changing
if (mesh_.changing())
@ -346,7 +345,7 @@ bool Foam::basicSource::isActive()
}
Foam::label Foam::basicSource::applyToField(const word& fieldName) const
Foam::label Foam::fv::option::applyToField(const word& fieldName) const
{
if (alwaysApply())
{
@ -365,13 +364,13 @@ Foam::label Foam::basicSource::applyToField(const word& fieldName) const
}
void Foam::basicSource::checkApplied() const
void Foam::fv::option::checkApplied() const
{
forAll(applied_, i)
{
if (!applied_[i])
{
WarningIn("void Foam::basicSource::checkApplied() const")
WarningIn("void option::checkApplied() const")
<< "Source " << name_ << " defined for field "
<< fieldNames_[i] << " but never used" << endl;
}
@ -379,49 +378,49 @@ void Foam::basicSource::checkApplied() const
}
void Foam::basicSource::correct(volScalarField& fld)
void Foam::fv::option::correct(volScalarField& fld)
{
// do nothing
}
void Foam::basicSource::correct(volVectorField& fld)
void Foam::fv::option::correct(volVectorField& fld)
{
// do nothing
}
void Foam::basicSource::correct(volSphericalTensorField& fld)
void Foam::fv::option::correct(volSphericalTensorField& fld)
{
// do nothing
}
void Foam::basicSource::correct(volSymmTensorField& fld)
void Foam::fv::option::correct(volSymmTensorField& fld)
{
// do nothing
}
void Foam::basicSource::correct(volTensorField& fld)
void Foam::fv::option::correct(volTensorField& fld)
{
// do nothing
}
void Foam::basicSource::addSup(fvMatrix<scalar>& eqn, const label fieldI)
void Foam::fv::option::addSup(fvMatrix<scalar>& eqn, const label fieldI)
{
// do nothing
}
void Foam::basicSource::addSup(fvMatrix<vector>& eqn, const label fieldI)
void Foam::fv::option::addSup(fvMatrix<vector>& eqn, const label fieldI)
{
// do nothing
}
void Foam::basicSource::addSup
void Foam::fv::option::addSup
(
fvMatrix<sphericalTensor>& eqn,
const label fieldI
@ -431,31 +430,31 @@ void Foam::basicSource::addSup
}
void Foam::basicSource::addSup(fvMatrix<symmTensor>& eqn, const label fieldI)
void Foam::fv::option::addSup(fvMatrix<symmTensor>& eqn, const label fieldI)
{
// do nothing
}
void Foam::basicSource::addSup(fvMatrix<tensor>& eqn, const label fieldI)
void Foam::fv::option::addSup(fvMatrix<tensor>& eqn, const label fieldI)
{
// do nothing
}
void Foam::basicSource::setValue(fvMatrix<scalar>& eqn, const label fieldI)
void Foam::fv::option::setValue(fvMatrix<scalar>& eqn, const label fieldI)
{
// do nothing
}
void Foam::basicSource::setValue(fvMatrix<vector>& eqn, const label fieldI)
void Foam::fv::option::setValue(fvMatrix<vector>& eqn, const label fieldI)
{
// do nothing
}
void Foam::basicSource::setValue
void Foam::fv::option::setValue
(
fvMatrix<sphericalTensor>& eqn,
const label fieldI
@ -465,7 +464,7 @@ void Foam::basicSource::setValue
}
void Foam::basicSource::setValue
void Foam::fv::option::setValue
(
fvMatrix<symmTensor>& eqn,
const label fieldI
@ -475,19 +474,19 @@ void Foam::basicSource::setValue
}
void Foam::basicSource::setValue(fvMatrix<tensor>& eqn, const label fieldI)
void Foam::fv::option::setValue(fvMatrix<tensor>& eqn, const label fieldI)
{
// do nothing
}
void Foam::basicSource::relativeFlux(surfaceScalarField& phi) const
void Foam::fv::option::relativeFlux(surfaceScalarField& phi) const
{
// do nothing
}
void Foam::basicSource::relativeFlux
void Foam::fv::option::relativeFlux
(
const surfaceScalarField& rho,
surfaceScalarField& phi
@ -497,13 +496,13 @@ void Foam::basicSource::relativeFlux
}
void Foam::basicSource::absoluteFlux(surfaceScalarField& phi) const
void Foam::fv::option::absoluteFlux(surfaceScalarField& phi) const
{
// do nothing
}
void Foam::basicSource::absoluteFlux
void Foam::fv::option::absoluteFlux
(
const surfaceScalarField& rho,
surfaceScalarField& phi

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -22,10 +22,11 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::basicSource
Foam::fv::option
Description
Field source abtract base class. Provides a base set of controls, e.g.
Finite volume options abtract base class. Provides a base set of controls,
e.g.
type scalarExplicitSource // source type
active on; // on/off switch
@ -33,18 +34,17 @@ Description
duration 1000.0; // duration
selectionMode cellSet; // cellSet // points //cellZone
// mapRegion
Note:
On evaluation, source expects to be added to the rhs of the equation
SourceFiles
basicSource.C
basicSourceIO.C
fvOption.C
fvOptionIO.C
\*---------------------------------------------------------------------------*/
#ifndef basicSource_H
#define basicSource_H
#ifndef fvOption_H
#define fvOption_H
#include "fvMatricesFwd.H"
#include "volFieldsFwd.H"
@ -61,11 +61,14 @@ namespace Foam
class fvMesh;
namespace fv
{
/*---------------------------------------------------------------------------*\
Class basicSource Declaration
Class option Declaration
\*---------------------------------------------------------------------------*/
class basicSource
class option
{
public:
@ -128,14 +131,14 @@ protected:
// Data for smMapRegion only
//- Mesh to mesh mapping for map optiom
//- Mesh to mesh mapping for map option
autoPtr<meshToMesh> secondaryToPrimaryInterpPtr_;
//- Name of the source in the secondary mesh
word secondarySourceName_;
//- Name of the model in the neighbour mesh
word nbrModelName_;
//- Name of the region to map
word mapRegionName_;
//- Name of the neighbour region to map
word nbrRegionName_;
//- Master or slave region
bool master_;
@ -163,7 +166,7 @@ protected:
public:
//- Runtime type information
TypeName("basicSource");
TypeName("option");
// Declare run-time constructor selection table
@ -171,7 +174,7 @@ public:
declareRunTimeSelectionTable
(
autoPtr,
basicSource,
option,
dictionary,
(
const word& name,
@ -186,7 +189,7 @@ public:
// Constructors
//- Construct from components
basicSource
option
(
const word& name,
const word& modelType,
@ -195,13 +198,13 @@ public:
);
//- Return clone
autoPtr<basicSource> clone() const
autoPtr<option> clone() const
{
notImplemented("autoPtr<basicSource> clone() const");
return autoPtr<basicSource>(NULL);
notImplemented("autoPtr<option> clone() const");
return autoPtr<option>(NULL);
}
//- Return pointer to new basicSource object created
//- Return pointer to new fvOption object created
// on the freestore from an Istream
class iNew
{
@ -221,19 +224,14 @@ public:
name_(name)
{}
autoPtr<basicSource> operator()(Istream& is) const
autoPtr<option> operator()(Istream& is) const
{
//const word name(is);
const dictionary dict(is);
return autoPtr<basicSource>
return autoPtr<option>
(
basicSource::New
(
name_,
dict,
mesh_
)
option::New(name_, dict, mesh_)
);
}
};
@ -241,8 +239,8 @@ public:
// Selectors
//- Return a reference to the selected basicSource model
static autoPtr<basicSource> New
//- Return a reference to the selected fvOption model
static autoPtr<option> New
(
const word& name,
const dictionary& dict,
@ -251,7 +249,7 @@ public:
//- Destructor
virtual ~basicSource();
virtual ~option();
@ -277,8 +275,8 @@ public:
//- Return const access to the duration
inline scalar duration() const;
//- Return const access to the time end
inline scalar timeEnd() const;
//- Return true if within time limits
inline bool inTimeLimits(const scalar time) const;
//- Return const access to the cell selection mode
inline const selectionModeType& selectionMode() const;
@ -290,16 +288,16 @@ public:
//- Return const access to the total cell volume
inline scalar V() const;
//- Return const access to the secondarySourceName
inline const word secondarySourceName() const;
//- Return const access to the neighbour model name
inline const word& nbrModelName() const;
//- Return const access to the neighbour region name
inline const word& nbrRegionName() const;
//- Return const access to the mapToMap Ptr
inline const autoPtr<meshToMesh>
secondaryToPrimaryInterpPtr() const;
//- Return const referenc to the mapRegion
inline const word mapRegionName() const;
//- Return const access to the cell set
inline const labelList& cells() const;
@ -468,11 +466,12 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fv
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "basicSourceI.H"
#include "fvOptionI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,117 +23,126 @@ License
\*---------------------------------------------------------------------------*/
#include "basicSource.H"
#include "fvMesh.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::word& Foam::basicSource::name() const
inline const Foam::word& Foam::fv::option::name() const
{
return name_;
}
inline const Foam::fvMesh& Foam::basicSource::mesh() const
inline const Foam::fvMesh& Foam::fv::option::mesh() const
{
return mesh_;
}
inline const Foam::dictionary& Foam::basicSource::coeffs() const
inline const Foam::dictionary& Foam::fv::option::coeffs() const
{
return coeffs_;
}
inline bool Foam::basicSource::active() const
inline bool Foam::fv::option::active() const
{
return active_;
}
inline Foam::scalar Foam::basicSource::timeStart() const
inline Foam::scalar Foam::fv::option::timeStart() const
{
return timeStart_;
}
inline Foam::scalar Foam::basicSource::duration() const
inline Foam::scalar Foam::fv::option::duration() const
{
return duration_;
}
inline Foam::scalar Foam::basicSource::timeEnd() const
inline bool Foam::fv::option::inTimeLimits(const scalar time) const
{
return timeStart_ + duration_;
return
(
(timeStart_ < 0)
||
(
(mesh_.time().value() >= timeStart_)
&& (mesh_.time().value() <= (timeStart_ + duration_))
)
);
}
inline const Foam::basicSource::selectionModeType&
Foam::basicSource::selectionMode() const
inline const Foam::fv::option::selectionModeType&
Foam::fv::option::selectionMode() const
{
return selectionMode_;
}
inline const Foam::word& Foam::basicSource::cellSetName() const
inline const Foam::word& Foam::fv::option::cellSetName() const
{
return cellSetName_;
}
inline Foam::scalar Foam::basicSource::V() const
inline Foam::scalar Foam::fv::option::V() const
{
return V_;
}
inline const Foam::labelList& Foam::basicSource::cells() const
inline const Foam::labelList& Foam::fv::option::cells() const
{
return cells_;
}
inline void Foam::basicSource::setApplied(const label fieldI)
inline void Foam::fv::option::setApplied(const label fieldI)
{
applied_[fieldI] = true;
}
inline bool& Foam::basicSource::active()
inline bool& Foam::fv::option::active()
{
return active_;
}
inline Foam::scalar& Foam::basicSource::timeStart()
inline Foam::scalar& Foam::fv::option::timeStart()
{
return timeStart_;
}
inline Foam::scalar& Foam::basicSource::duration()
inline Foam::scalar& Foam::fv::option::duration()
{
return duration_;
}
inline const Foam::word Foam::basicSource::secondarySourceName() const
inline const Foam::word& Foam::fv::option::nbrModelName() const
{
return secondarySourceName_;
return nbrModelName_;
}
inline const Foam::autoPtr<Foam::meshToMesh> Foam::basicSource::
secondaryToPrimaryInterpPtr() const
inline const Foam::word& Foam::fv::option::nbrRegionName() const
{
return nbrRegionName_;
}
inline const Foam::autoPtr<Foam::meshToMesh>
Foam::fv::option::secondaryToPrimaryInterpPtr() const
{
return secondaryToPrimaryInterpPtr_;
}
inline const Foam::word Foam::basicSource::mapRegionName() const
{
return mapRegionName_;
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,24 +23,24 @@ License
\*---------------------------------------------------------------------------*/
#include "basicSource.H"
#include "fvOption.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::basicSource::writeHeader(Ostream& os) const
void Foam::fv::option::writeHeader(Ostream& os) const
{
os << indent << name_ << nl
<< indent << token::BEGIN_BLOCK << incrIndent << nl;
}
void Foam::basicSource::writeFooter(Ostream& os) const
void Foam::fv::option::writeFooter(Ostream& os) const
{
os << decrIndent << indent << token::END_BLOCK << endl;
}
void Foam::basicSource::writeData(Ostream& os) const
void Foam::fv::option::writeData(Ostream& os) const
{
os.writeKeyword("active") << active_ << token::END_STATEMENT << nl;
os.writeKeyword("timeStart") << timeStart_ << token::END_STATEMENT << nl;
@ -78,7 +78,7 @@ void Foam::basicSource::writeData(Ostream& os) const
}
default:
{
FatalErrorIn("basicSource::writeData(Ostream&) const")
FatalErrorIn("option::writeData(Ostream&) const")
<< "Unknown selectionMode "
<< selectionMode_
<< abort(FatalError);
@ -87,7 +87,7 @@ void Foam::basicSource::writeData(Ostream& os) const
}
bool Foam::basicSource::read(const dictionary& dict)
bool Foam::fv::option::read(const dictionary& dict)
{
active_ = readBool(dict.lookup("active"));
timeStart_ = readScalar(dict.lookup("timeStart"));

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,7 +23,7 @@ License
\*---------------------------------------------------------------------------*/
#include "basicSourceList.H"
#include "fvOptionList.H"
#include "addToRunTimeSelectionTable.H"
#include "fvMesh.H"
#include "Time.H"
@ -32,19 +32,22 @@ License
namespace Foam
{
defineTypeNameAndDebug(basicSourceList, 0);
namespace fv
{
defineTypeNameAndDebug(optionList, 0);
}
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::basicSourceList::checkApplied() const
void Foam::fv::optionList::checkApplied() const
{
if (mesh_.time().timeIndex() == checkTimeIndex_)
{
forAll(*this, i)
{
const basicSource& bs = this->operator[](i);
const option& bs = this->operator[](i);
bs.checkApplied();
}
}
@ -53,13 +56,9 @@ void Foam::basicSourceList::checkApplied() const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::basicSourceList::basicSourceList
(
const fvMesh& mesh,
const dictionary& dict
)
Foam::fv::optionList::optionList(const fvMesh& mesh, const dictionary& dict)
:
PtrList<basicSource>(),
PtrList<option>(),
mesh_(mesh),
checkTimeIndex_(mesh_.time().startTimeIndex() + 2)
{
@ -67,9 +66,9 @@ Foam::basicSourceList::basicSourceList
}
Foam::basicSourceList::basicSourceList(const fvMesh& mesh)
Foam::fv::optionList::optionList(const fvMesh& mesh)
:
PtrList<basicSource>(),
PtrList<option>(),
mesh_(mesh),
checkTimeIndex_(mesh_.time().startTimeIndex() + 2)
{}
@ -77,7 +76,7 @@ Foam::basicSourceList::basicSourceList(const fvMesh& mesh)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::basicSourceList::reset(const dictionary& dict)
void Foam::fv::optionList::reset(const dictionary& dict)
{
label count = 0;
forAllConstIter(dictionary, dict, iter)
@ -101,14 +100,14 @@ void Foam::basicSourceList::reset(const dictionary& dict)
this->set
(
i++,
basicSource::New(name, sourceDict, mesh_)
option::New(name, sourceDict, mesh_)
);
}
}
}
void Foam::basicSourceList::relativeFlux(surfaceScalarField& phi) const
void Foam::fv::optionList::relativeFlux(surfaceScalarField& phi) const
{
forAll(*this, i)
{
@ -117,7 +116,7 @@ void Foam::basicSourceList::relativeFlux(surfaceScalarField& phi) const
}
void Foam::basicSourceList::relativeFlux
void Foam::fv::optionList::relativeFlux
(
const surfaceScalarField& rho,
surfaceScalarField& phi
@ -130,7 +129,7 @@ void Foam::basicSourceList::relativeFlux
}
void Foam::basicSourceList::absoluteFlux(surfaceScalarField& phi) const
void Foam::fv::optionList::absoluteFlux(surfaceScalarField& phi) const
{
forAll(*this, i)
{
@ -139,7 +138,7 @@ void Foam::basicSourceList::absoluteFlux(surfaceScalarField& phi) const
}
void Foam::basicSourceList::absoluteFlux
void Foam::fv::optionList::absoluteFlux
(
const surfaceScalarField& rho,
surfaceScalarField& phi
@ -152,14 +151,14 @@ void Foam::basicSourceList::absoluteFlux
}
bool Foam::basicSourceList::read(const dictionary& dict)
bool Foam::fv::optionList::read(const dictionary& dict)
{
checkTimeIndex_ = mesh_.time().timeIndex() + 2;
bool allOk = true;
forAll(*this, i)
{
basicSource& bs = this->operator[](i);
option& bs = this->operator[](i);
bool ok = bs.read(dict.subDict(bs.name()));
allOk = (allOk && ok);
}
@ -167,7 +166,7 @@ bool Foam::basicSourceList::read(const dictionary& dict)
}
bool Foam::basicSourceList::writeData(Ostream& os) const
bool Foam::fv::optionList::writeData(Ostream& os) const
{
// Write list contents
forAll(*this, i)
@ -183,14 +182,17 @@ bool Foam::basicSourceList::writeData(Ostream& os) const
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const basicSourceList& sources
)
namespace Foam
{
sources.writeData(os);
return os;
Ostream& operator<<
(
Ostream& os,
const fv::optionList& options
)
{
options.writeData(os);
return os;
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -22,36 +22,38 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::basicSourceList
Foam::fv::optionList
Description
List of explict sources
List of finite volume options
SourceFile
basicSourceList.C
optionList.C
\*---------------------------------------------------------------------------*/
#ifndef basicSourceList_H
#define basicSourceList_H
#ifndef optionList_H
#define optionList_H
#include "PtrList.H"
#include "GeometricField.H"
#include "fvPatchField.H"
#include "basicSource.H"
#include "fvOption.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace fv
{
/*---------------------------------------------------------------------------*\
Class basicSourceList Declaration
Class optionList Declaration
\*---------------------------------------------------------------------------*/
class basicSourceList
class optionList
:
public PtrList<basicSource>
public PtrList<option>
{
protected:
@ -70,29 +72,29 @@ protected:
void checkApplied() const;
//- Disallow default bitwise copy construct
basicSourceList(const basicSourceList&);
optionList(const optionList&);
//- Disallow default bitwise assignment
void operator=(const basicSourceList&);
void operator=(const optionList&);
public:
//- Runtime type information
TypeName("basicSourceList");
TypeName("optionList");
// Constructors
//- Construct null
basicSourceList(const fvMesh& mesh);
optionList(const fvMesh& mesh);
//- Construct from mesh and dictionary
basicSourceList(const fvMesh& mesh, const dictionary& dict);
optionList(const fvMesh& mesh, const dictionary& dict);
//- Destructor
virtual ~basicSourceList()
virtual ~optionList()
{}
@ -187,18 +189,19 @@ public:
friend Ostream& operator<<
(
Ostream& os,
const basicSourceList& sources
const optionList& options
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fv
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "basicSourceListTemplates.C"
#include "fvOptionListTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -26,7 +26,7 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::basicSourceList::correct
void Foam::fv::optionList::correct
(
GeometricField<Type, fvPatchField, volMesh>& fld
)
@ -35,7 +35,7 @@ void Foam::basicSourceList::correct
forAll(*this, i)
{
basicSource& source = this->operator[](i);
option& source = this->operator[](i);
label fieldI = source.applyToField(fieldName);
@ -59,7 +59,7 @@ void Foam::basicSourceList::correct
template<class Type>
Foam::tmp<Foam::fvMatrix<Type> > Foam::basicSourceList::operator()
Foam::tmp<Foam::fvMatrix<Type> > Foam::fv::optionList::operator()
(
GeometricField<Type, fvPatchField, volMesh>& fld
)
@ -69,7 +69,7 @@ Foam::tmp<Foam::fvMatrix<Type> > Foam::basicSourceList::operator()
template<class Type>
Foam::tmp<Foam::fvMatrix<Type> > Foam::basicSourceList::operator()
Foam::tmp<Foam::fvMatrix<Type> > Foam::fv::optionList::operator()
(
GeometricField<Type, fvPatchField, volMesh>& fld,
const word& fieldName
@ -86,7 +86,7 @@ Foam::tmp<Foam::fvMatrix<Type> > Foam::basicSourceList::operator()
forAll(*this, i)
{
basicSource& source = this->operator[](i);
option& source = this->operator[](i);
label fieldI = source.applyToField(fieldName);
@ -112,7 +112,7 @@ Foam::tmp<Foam::fvMatrix<Type> > Foam::basicSourceList::operator()
template<class Type, class RhoType>
Foam::tmp<Foam::fvMatrix<Type> > Foam::basicSourceList::operator()
Foam::tmp<Foam::fvMatrix<Type> > Foam::fv::optionList::operator()
(
const RhoType& rho,
GeometricField<Type, fvPatchField, volMesh>& fld
@ -123,7 +123,7 @@ Foam::tmp<Foam::fvMatrix<Type> > Foam::basicSourceList::operator()
template<class Type, class RhoType>
Foam::tmp<Foam::fvMatrix<Type> > Foam::basicSourceList::operator()
Foam::tmp<Foam::fvMatrix<Type> > Foam::fv::optionList::operator()
(
const RhoType& rho,
GeometricField<Type, fvPatchField, volMesh>& fld,
@ -141,7 +141,7 @@ Foam::tmp<Foam::fvMatrix<Type> > Foam::basicSourceList::operator()
forAll(*this, i)
{
basicSource& source = this->operator[](i);
option& source = this->operator[](i);
label fieldI = source.applyToField(fieldName);
@ -167,14 +167,14 @@ Foam::tmp<Foam::fvMatrix<Type> > Foam::basicSourceList::operator()
template<class Type>
void Foam::basicSourceList::constrain(fvMatrix<Type>& eqn)
void Foam::fv::optionList::constrain(fvMatrix<Type>& eqn)
{
constrain(eqn, eqn.psi().name());
}
template<class Type>
void Foam::basicSourceList::constrain
void Foam::fv::optionList::constrain
(
fvMatrix<Type>& eqn,
const word& fieldName
@ -184,7 +184,7 @@ void Foam::basicSourceList::constrain
forAll(*this, i)
{
basicSource& source = this->operator[](i);
option& source = this->operator[](i);
label fieldI = source.applyToField(fieldName);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,25 +23,25 @@ License
\*---------------------------------------------------------------------------*/
#ifndef makeBasicSource_H
#define makeBasicSource_H
#ifndef makeFvOption_H
#define makeFvOption_H
#include "basicSource.H"
#include "fvOption.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#define makeBasicSource(Source, Type) \
#define makeFvOption(Option, Type) \
\
defineTemplateTypeNameAndDebugWithName \
( \
Source<Type>, \
#Type#Source, \
Option<Type>, \
#Type#Option, \
0 \
); \
\
basicSource::adddictionaryConstructorToTable<Source<Type> > \
add##Source##Type##dictionary##ConstructorTobasicSourceTable_
option::adddictionaryConstructorToTable<Option<Type> > \
add##Option##Type##dictionary##ConstructorTooptionTable_
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -0,0 +1,2 @@
Info<< "Creating finite volume options" << endl;
fv::IOoptionList fvOptions(mesh);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -33,19 +33,22 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace fv
{
defineTypeNameAndDebug(MRFSource, 0);
addToRunTimeSelectionTable
(
basicSource,
option,
MRFSource,
dictionary
);
}
}
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
void Foam::MRFSource::initialise()
void Foam::fv::MRFSource::initialise()
{
if (selectionMode_ != smCellZone)
{
@ -77,7 +80,7 @@ void Foam::MRFSource::initialise()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::MRFSource::MRFSource
Foam::fv::MRFSource::MRFSource
(
const word& name,
const word& modelType,
@ -85,7 +88,7 @@ Foam::MRFSource::MRFSource
const fvMesh& mesh
)
:
basicSource(name, modelType, dict, mesh),
option(name, modelType, dict, mesh),
mrfPtr_(NULL),
UName_(coeffs_.lookupOrDefault<word>("UName", "U")),
rhoName_(coeffs_.lookupOrDefault<word>("rhoName", "rho"))
@ -96,7 +99,7 @@ Foam::MRFSource::MRFSource
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::MRFSource::addSup
void Foam::fv::MRFSource::addSup
(
fvMatrix<vector>& eqn,
const label fieldI
@ -118,13 +121,13 @@ void Foam::MRFSource::addSup
}
void Foam::MRFSource::relativeFlux(surfaceScalarField& phi) const
void Foam::fv::MRFSource::relativeFlux(surfaceScalarField& phi) const
{
mrfPtr_->relativeFlux(phi);
}
void Foam::MRFSource::relativeFlux
void Foam::fv::MRFSource::relativeFlux
(
const surfaceScalarField& rho,
surfaceScalarField& phi
@ -134,13 +137,13 @@ void Foam::MRFSource::relativeFlux
}
void Foam::MRFSource::absoluteFlux(surfaceScalarField& phi) const
void Foam::fv::MRFSource::absoluteFlux(surfaceScalarField& phi) const
{
mrfPtr_->absoluteFlux(phi);
}
void Foam::MRFSource::absoluteFlux
void Foam::fv::MRFSource::absoluteFlux
(
const surfaceScalarField& rho,
surfaceScalarField& phi
@ -150,16 +153,16 @@ void Foam::MRFSource::absoluteFlux
}
void Foam::MRFSource::writeData(Ostream& os) const
void Foam::fv::MRFSource::writeData(Ostream& os) const
{
os << indent << name_ << endl;
dict_.write(os);
}
bool Foam::MRFSource::read(const dictionary& dict)
bool Foam::fv::MRFSource::read(const dictionary& dict)
{
if (basicSource::read(dict))
if (option::read(dict))
{
coeffs_.readIfPresent("UName", UName_);
coeffs_.readIfPresent("rhoName", rhoName_);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::MRFSource
Foam::fv::MRFSource
Description
Multiple Reference Frame (MRF) source
@ -45,7 +45,7 @@ SourceFiles
#ifndef MRFSource_H
#define MRFSource_H
#include "basicSource.H"
#include "fvOption.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -54,13 +54,16 @@ namespace Foam
class MRFZone;
namespace fv
{
/*---------------------------------------------------------------------------*\
Class MRFSource Declaration
\*---------------------------------------------------------------------------*/
class MRFSource
:
public basicSource
public option
{
protected:
@ -164,6 +167,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fv
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -26,49 +26,52 @@ License
#include "actuationDiskSource.H"
#include "fvMesh.H"
#include "fvMatrices.H"
#include "fvMatrix.H"
#include "geometricOneField.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace fv
{
defineTypeNameAndDebug(actuationDiskSource, 0);
addToRunTimeSelectionTable
(
basicSource,
option,
actuationDiskSource,
dictionary
);
}
}
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::actuationDiskSource::checkData() const
void Foam::fv::actuationDiskSource::checkData() const
{
if (magSqr(diskArea_) <= VSMALL)
{
FatalErrorIn("Foam::actuationDiskSource::checkData()")
FatalErrorIn("Foam::fv::actuationDiskSource::checkData()")
<< "diskArea is approximately zero"
<< exit(FatalIOError);
}
if (Cp_ <= VSMALL || Ct_ <= VSMALL)
{
FatalErrorIn("Foam::actuationDiskSource::checkData()")
FatalErrorIn("Foam::fv::actuationDiskSource::checkData()")
<< "Cp and Ct must be greater than zero"
<< exit(FatalIOError);
}
if (mag(diskDir_) < VSMALL)
{
FatalErrorIn("Foam::actuationDiskSource::checkData()")
FatalErrorIn("Foam::fv::actuationDiskSource::checkData()")
<< "disk direction vector is approximately zero"
<< exit(FatalIOError);
}
if (returnReduce(upstreamCellId_, maxOp<label>()) == -1)
{
FatalErrorIn("Foam::actuationDiskSource::checkData()")
FatalErrorIn("Foam::fv::actuationDiskSource::checkData()")
<< "upstream location " << upstreamPoint_ << " not found in mesh"
<< exit(FatalIOError);
}
@ -77,7 +80,7 @@ void Foam::actuationDiskSource::checkData() const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::actuationDiskSource::actuationDiskSource
Foam::fv::actuationDiskSource::actuationDiskSource
(
const word& name,
const word& modelType,
@ -85,7 +88,7 @@ Foam::actuationDiskSource::actuationDiskSource
const fvMesh& mesh
)
:
basicSource(name, modelType, dict, mesh),
option(name, modelType, dict, mesh),
diskDir_(coeffs_.lookup("diskDir")),
Cp_(readScalar(coeffs_.lookup("Cp"))),
Ct_(readScalar(coeffs_.lookup("Ct"))),
@ -107,7 +110,7 @@ Foam::actuationDiskSource::actuationDiskSource
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::actuationDiskSource::addSup
void Foam::fv::actuationDiskSource::addSup
(
fvMatrix<vector>& eqn,
const label fieldI
@ -151,16 +154,16 @@ void Foam::actuationDiskSource::addSup
}
void Foam::actuationDiskSource::writeData(Ostream& os) const
void Foam::fv::actuationDiskSource::writeData(Ostream& os) const
{
os << indent << name_ << endl;
dict_.write(os);
}
bool Foam::actuationDiskSource::read(const dictionary& dict)
bool Foam::fv::actuationDiskSource::read(const dictionary& dict)
{
if (basicSource::read(dict))
if (option::read(dict))
{
coeffs_.readIfPresent("diskDir", diskDir_);
coeffs_.readIfPresent("Cp", Cp_);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::actuationDiskSource
Foam::fv::actuationDiskSource
Description
Actuation disk source
@ -61,12 +61,14 @@ SourceFiles
#ifndef actuationDiskSource_H
#define actuationDiskSource_H
#include "basicSource.H"
#include "fvOption.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace fv
{
/*---------------------------------------------------------------------------*\
Class actuationDiskSource Declaration
@ -74,7 +76,7 @@ namespace Foam
class actuationDiskSource
:
public basicSource
public option
{
protected:
@ -195,6 +197,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fv
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -26,13 +26,11 @@ License
#include "actuationDiskSource.H"
#include "volFields.H"
#include "fvMatrix.H"
#include "fvm.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class RhoFieldType>
void Foam::actuationDiskSource::addActuationDiskAxialInertialResistance
void Foam::fv::actuationDiskSource::addActuationDiskAxialInertialResistance
(
vectorField& Usource,
const labelList& cells,

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -33,23 +33,26 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace fv
{
defineTypeNameAndDebug(explicitPorositySource, 0);
addToRunTimeSelectionTable
(
basicSource,
option,
explicitPorositySource,
dictionary
);
}
}
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
void Foam::explicitPorositySource::initialise()
void Foam::fv::explicitPorositySource::initialise()
{
if (selectionMode_ != smCellZone)
{
FatalErrorIn("void Foam::explicitPorositySource::initialise()")
FatalErrorIn("void Foam::fv::explicitPorositySource::initialise()")
<< "The porosity region must be specified as a cellZone. Current "
<< "selection mode is " << selectionModeTypeNames_[selectionMode_]
<< exit(FatalError);
@ -73,7 +76,7 @@ void Foam::explicitPorositySource::initialise()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::explicitPorositySource::explicitPorositySource
Foam::fv::explicitPorositySource::explicitPorositySource
(
const word& name,
const word& modelType,
@ -81,7 +84,7 @@ Foam::explicitPorositySource::explicitPorositySource
const fvMesh& mesh
)
:
basicSource(name, modelType, dict, mesh),
option(name, modelType, dict, mesh),
porosityPtr_(NULL),
UName_(coeffs_.lookupOrDefault<word>("UName", "U")),
rhoName_(coeffs_.lookupOrDefault<word>("rhoName", "rho")),
@ -93,7 +96,7 @@ Foam::explicitPorositySource::explicitPorositySource
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::explicitPorositySource::addSup
void Foam::fv::explicitPorositySource::addSup
(
fvMatrix<vector>& eqn,
const label fieldI
@ -118,16 +121,16 @@ void Foam::explicitPorositySource::addSup
}
void Foam::explicitPorositySource::writeData(Ostream& os) const
void Foam::fv::explicitPorositySource::writeData(Ostream& os) const
{
os << indent << name_ << endl;
dict_.write(os);
}
bool Foam::explicitPorositySource::read(const dictionary& dict)
bool Foam::fv::explicitPorositySource::read(const dictionary& dict)
{
if (basicSource::read(dict))
if (option::read(dict))
{
coeffs_.readIfPresent("UName", UName_);
coeffs_.readIfPresent("rhoName", rhoName_);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::explicitPorositySource
Foam::fv::explicitPorositySource
Description
Explicit porosity source
@ -57,7 +57,7 @@ SourceFiles
#ifndef explicitPorositySource_H
#define explicitPorositySource_H
#include "basicSource.H"
#include "fvOption.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -66,13 +66,17 @@ namespace Foam
class porosityModel;
namespace fv
{
/*---------------------------------------------------------------------------*\
Class explicitPorositySource Declaration
\*---------------------------------------------------------------------------*/
class explicitPorositySource
:
public basicSource
public option
{
protected:
@ -157,6 +161,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fv
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,28 +24,28 @@ License
\*---------------------------------------------------------------------------*/
#include "constantHeatTransfer.H"
#include "fvm.H"
#include "IObasicSourceList.H"
#include "addToRunTimeSelectionTable.H"
#include "fvcVolumeIntegrate.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace fv
{
defineTypeNameAndDebug(constantHeatTransfer, 0);
addToRunTimeSelectionTable
(
basicSource,
option,
constantHeatTransfer,
dictionary
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::constantHeatTransfer::constantHeatTransfer
Foam::fv::constantHeatTransfer::constantHeatTransfer
(
const word& name,
const word& modelType,
@ -54,18 +54,18 @@ Foam::constantHeatTransfer::constantHeatTransfer
)
:
interRegionHeatTransferModel(name, modelType, dict, mesh),
htCoeffs_(),
area_()
htcConst_(),
AoV_()
{
if (master_)
{
htCoeffs_.reset
htcConst_.reset
(
new volScalarField
(
IOobject
(
"htCoeffs",
"htcConst",
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
@ -75,13 +75,13 @@ Foam::constantHeatTransfer::constantHeatTransfer
)
);
area_.reset
AoV_.reset
(
new volScalarField
(
IOobject
(
"area",
"AoV",
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
@ -91,7 +91,18 @@ Foam::constantHeatTransfer::constantHeatTransfer
)
);
htc_.internalField() = htCoeffs_()*area_()/mesh_.V();
const DimensionedField<scalar, volMesh>& htcConsti =
htcConst_().dimensionedInternalField();
const DimensionedField<scalar, volMesh>& AoVi =
AoV_().dimensionedInternalField();
dimensionedScalar interVol
(
"V",
dimVolume,
secondaryToPrimaryInterpPtr_->V()
);
htc_.dimensionedInternalField() = htcConsti*AoVi*interVol/mesh.V();
htc_.correctBoundaryConditions();
}
}
@ -99,35 +110,35 @@ Foam::constantHeatTransfer::constantHeatTransfer
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::constantHeatTransfer::~constantHeatTransfer()
Foam::fv::constantHeatTransfer::~constantHeatTransfer()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::tmp<Foam::volScalarField>Foam::constantHeatTransfer::
calculateHtc()
const Foam::tmp<Foam::volScalarField>
Foam::fv::constantHeatTransfer::calculateHtc()
{
return htc_;
}
void Foam::constantHeatTransfer::writeData(Ostream& os) const
void Foam::fv::constantHeatTransfer::writeData(Ostream& os) const
{
os << indent << token::BEGIN_BLOCK << incrIndent << nl;
interRegionHeatTransferModel::writeData(os);
os << indent << "constantHeatTransfer";
os << indent << type() + "Coeffs" << nl;
dict_.write(os);
coeffs_.write(os);
os << decrIndent << indent << token::END_BLOCK << endl;
}
bool Foam::constantHeatTransfer::read(const dictionary& dict)
bool Foam::fv::constantHeatTransfer::read(const dictionary& dict)
{
if (basicSource::read(dict))
if (option::read(dict))
{
return true;
}
@ -138,4 +149,4 @@ bool Foam::constantHeatTransfer::read(const dictionary& dict)
}
// ************************************************************************* //
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -22,11 +22,11 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::constantHeatTransfer
Foam::fv::constantHeatTransfer
Description
Constant heat transfer model. htCoeffs [W/m2/K] and area [m2] must be
provided.
Constant heat transfer model. htcConst [W/m2/K] and area/volume [1/m]
must be provided.
\*---------------------------------------------------------------------------*/
@ -40,8 +40,11 @@ Description
namespace Foam
{
namespace fv
{
/*---------------------------------------------------------------------------*\
Class constantHeatTransfer Declaration
Class constantHeatTransfer Declaration
\*---------------------------------------------------------------------------*/
class constantHeatTransfer
@ -52,17 +55,17 @@ private:
// Private data
//- Heat transfer coefficient
autoPtr<volScalarField> htCoeffs_;
//- Constant heat transfer coefficient [W/m2/K]
autoPtr<volScalarField> htcConst_;
//- Area of heat exchange
autoPtr<volScalarField> area_;
//- Area per unit volume of heat exchanger [1/m]
autoPtr<volScalarField> AoV_;
public:
//- Runtime type information
TypeName("constantHeatTransfer");
TypeName("constantHeatTransfer");
// Constructors
@ -93,18 +96,17 @@ public:
virtual void writeData(Ostream&) const;
//- Read dictionary
virtual bool read(const dictionary& dict) ;
virtual bool read(const dictionary& dict);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fv
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,267 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 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 "interRegionHeatTransferModel.H"
#include "fluidThermo.H"
#include "fvm.H"
#include "zeroGradientFvPatchFields.H"
#include "fvcVolumeIntegrate.H"
#include "fvOptionList.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace fv
{
defineTypeNameAndDebug(interRegionHeatTransferModel, 0);
}
}
// * * * * * * * * * * * * Private member functions * * * * * * * * * * * //
void Foam::fv::interRegionHeatTransferModel::check()
{
const fvMesh& nbrMesh = mesh_.time().lookupObject<fvMesh>(nbrRegionName_);
const optionList& fvOptions = nbrMesh.lookupObject<optionList>("fvOptions");
bool nbrModelFound = false;
forAll(fvOptions, i)
{
if (fvOptions[i].name() == nbrModelName_)
{
nbrModel_ = &const_cast<interRegionHeatTransferModel&>
(
refCast<const interRegionHeatTransferModel>(fvOptions[i])
);
nbrModelFound = true;
break;
}
}
if (!nbrModelFound)
{
FatalErrorIn("interRegionHeatTransferModel::check()")
<< "Secondary source name not found" << nbrModelName_
<< " in region " << nbrMesh.name() << nl
<< exit(FatalError);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fv::interRegionHeatTransferModel::interRegionHeatTransferModel
(
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
)
:
option(name, modelType, dict, mesh),
nbrModel_(),
firstIter_(true),
htc_
(
IOobject
(
type() + ".htc",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar
(
"htc",
dimEnergy/dimTime/dimTemperature/dimVolume,
0.0
),
zeroGradientFvPatchScalarField::typeName
),
semiImplicit_(false)
{
if (active())
{
coeffs_.lookup("fieldNames") >> fieldNames_;
applied_.setSize(fieldNames_.size(), false);
coeffs_.lookup("semiImplicit") >> semiImplicit_;
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::fv::interRegionHeatTransferModel::~interRegionHeatTransferModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::fv::interRegionHeatTransferModel::addSup
(
fvMatrix<scalar>& eqn,
const label fieldI
)
{
if (!secondaryToPrimaryInterpPtr_.valid())
{
return;
}
if (firstIter_)
{
check();
firstIter_ = false;
}
const volScalarField& h = eqn.psi();
tmp<volScalarField> tTmapped
(
new volScalarField
(
IOobject
(
type() + ".Tmapped",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("T", dimTemperature, 0.0)
)
);
volScalarField& Tmapped = tTmapped();
const fvMesh& nbrMesh = mesh_.time().lookupObject<fvMesh>(nbrRegionName_);
const volScalarField& Tnbr = nbrMesh.lookupObject<volScalarField>("T");
secondaryToPrimaryInterpPtr_->interpolateInternalField
(
Tmapped,
Tnbr,
meshToMesh::MAP,
eqOp<scalar>()
);
if (!master_)
{
secondaryToPrimaryInterpPtr_->interpolateInternalField
(
htc_,
nbrModel_->calculateHtc(),
meshToMesh::CELL_VOLUME_WEIGHT,
eqOp<scalar>()
);
}
if (debug)
{
Info<< "Volumetric integral of htc: "
<< fvc::domainIntegrate(htc_).value()
<< endl;
if (mesh_.time().outputTime())
{
Tmapped.write();
htc_.write();
}
}
if (semiImplicit_)
{
if (h.dimensions() == dimEnergy/dimMass)
{
const fluidThermo& thermo =
mesh_.lookupObject<fluidThermo>("thermophysicalProperties");
eqn += htc_*Tmapped - fvm::SuSp(htc_/thermo.Cp(), h);
if (debug)
{
const dimensionedScalar energy =
fvc::domainIntegrate(htc_*(h/thermo.Cp() - Tmapped));
Info<< "Energy exchange from region " << nbrMesh.name()
<< " To " << mesh_.name() << " : " << energy.value()
<< endl;
}
}
else if (h.dimensions() == dimTemperature)
{
eqn += htc_*Tmapped - fvm::SuSp(htc_, h);
}
}
else
{
const volScalarField& T = mesh_.lookupObject<volScalarField>("T");
eqn += htc_*(Tmapped - T);
}
}
void Foam::fv::interRegionHeatTransferModel::writeData(Ostream& os) const
{
os.writeKeyword("name") << this->name() << token::END_STATEMENT << nl;
os.writeKeyword("nbrRegionName") << nbrRegionName_
<< token::END_STATEMENT << nl;
os.writeKeyword("nbrModeleName") << nbrModelName_
<< token::END_STATEMENT << nl;
os.writeKeyword("master") << master_ << token::END_STATEMENT << nl;
os.writeKeyword("semiImplicit") << semiImplicit_ << token::END_STATEMENT
<< nl;
if (dict_.found("note"))
{
os.writeKeyword("note") << string(dict_.lookup("note"))
<< token::END_STATEMENT << nl;
}
}
bool Foam::fv::interRegionHeatTransferModel::read(const dictionary& dict)
{
if (option::read(dict))
{
return true;
}
else
{
return false;
}
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::interRegionHeatTransferModel
Foam::fv::interRegionHeatTransferModel
Description
Base class for inter region heat exchange. The derived classes must
@ -33,7 +33,7 @@ Description
#ifndef interRegionHeatTransferModel_H
#define interRegionHeatTransferModel_H
#include "basicSource.H"
#include "fvOption.H"
#include "volFields.H"
@ -41,6 +41,8 @@ Description
namespace Foam
{
namespace fv
{
/*---------------------------------------------------------------------------*\
Class interRegionHeatTransferModel Declaration
@ -48,15 +50,15 @@ namespace Foam
class interRegionHeatTransferModel
:
public basicSource
public option
{
private:
// Private data
//- Pointer to secondary interRegionHeatTransferModel
interRegionHeatTransferModel* secIrht_;
//- Pointer to neighbour interRegionHeatTransferModel
interRegionHeatTransferModel* nbrModel_;
//- First iteration
bool firstIter_;
@ -76,6 +78,9 @@ protected:
// registered on the master mesh
volScalarField htc_;
//- Flag to activate semi-implicit coupling
bool semiImplicit_;
public:
@ -111,7 +116,7 @@ public:
}
//-Source term to fvMatrix<scalar>
virtual void addSup(fvMatrix<scalar>& eEqn, const label fieldI);
virtual void addSup(fvMatrix<scalar>& eqn, const label fieldI);
//- Calculate heat transfer coefficient
virtual const tmp<volScalarField> calculateHtc() = 0;
@ -129,9 +134,9 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fv
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,55 +24,51 @@ License
\*---------------------------------------------------------------------------*/
#include "tabulatedHeatTransfer.H"
#include "turbulenceModel.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace fv
{
defineTypeNameAndDebug(tabulatedHeatTransfer, 0);
addToRunTimeSelectionTable
(
basicSource,
option,
tabulatedHeatTransfer,
dictionary
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::tabulatedHeatTransfer::tabulatedHeatTransfer
(
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
)
:
interRegionHeatTransferModel(name, modelType, dict, mesh),
hTable_(),
area_()
const Foam::interpolation2DTable<Foam::scalar>&
Foam::fv::tabulatedHeatTransfer::hTable()
{
if (master_)
if (!hTable_.valid())
{
hTable_.reset
(
new interpolation2DTable<scalar>
(
dict.subDict(typeName + "Coeffs")
)
);
area_.reset
hTable_.reset(new interpolation2DTable<scalar>(coeffs_));
}
return hTable_();
}
const Foam::volScalarField& Foam::fv::tabulatedHeatTransfer::AoV()
{
if (!AoV_.valid())
{
AoV_.reset
(
new volScalarField
(
IOobject
(
"area",
mesh_.time().timeName(),
"AoV",
startTimeName_,
mesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
@ -81,67 +77,85 @@ Foam::tabulatedHeatTransfer::tabulatedHeatTransfer
)
);
}
return AoV_();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fv::tabulatedHeatTransfer::tabulatedHeatTransfer
(
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
)
:
interRegionHeatTransferModel(name, modelType, dict, mesh),
UName_(coeffs_.lookupOrDefault<word>("UName", "U")),
hTable_(),
AoV_(),
startTimeName_(mesh.time().timeName())
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::tabulatedHeatTransfer::~tabulatedHeatTransfer()
Foam::fv::tabulatedHeatTransfer::~tabulatedHeatTransfer()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::tmp<Foam::volScalarField>Foam::tabulatedHeatTransfer::
calculateHtc()
const Foam::tmp<Foam::volScalarField>
Foam::fv::tabulatedHeatTransfer::calculateHtc()
{
const fvMesh& secondaryMesh =
mesh_.time().lookupObject<fvMesh>(mapRegionName());
const fvMesh& nbrMesh = mesh_.time().lookupObject<fvMesh>(nbrRegionName());
const volVectorField& Usecondary =
secondaryMesh.lookupObject<volVectorField>("U");
const volVectorField& UNbr = nbrMesh.lookupObject<volVectorField>(UName_);
scalarField UMagMapped(htc_.internalField().size(), 0.0);
scalarField UMagNbrMapped(htc_.internalField().size(), 0.0);
secondaryToPrimaryInterpPtr_->interpolateInternalField
(
UMagMapped,
mag(Usecondary),
UMagNbrMapped,
mag(UNbr),
meshToMesh::MAP,
eqOp<scalar>()
);
const volVectorField& U = mesh_.lookupObject<volVectorField>("U");
const volVectorField& U = mesh_.lookupObject<volVectorField>(UName_);
forAll (htc_.internalField(), i)
scalarField& htcc = htc_.internalField();
forAll(htcc, i)
{
htc_.internalField()[i] =
hTable_->operator()(mag(U[i]), UMagMapped[i]);
htcc[i] = hTable()(mag(U[i]), UMagNbrMapped[i]);
}
htc_.internalField() = htc_*area_/mesh_.V();
htcc = htcc*AoV()*secondaryToPrimaryInterpPtr_->V()/mesh_.V();
return htc_;
}
void Foam::tabulatedHeatTransfer::writeData(Ostream& os) const
void Foam::fv::tabulatedHeatTransfer::writeData(Ostream& os) const
{
os << indent << token::BEGIN_BLOCK << incrIndent << nl;
interRegionHeatTransferModel::writeData(os);
os << indent << "tabulatedHeatTransfer";
os << indent << type() + "Coeffs" << nl;
dict_.write(os);
coeffs_.write(os);
os << decrIndent << indent << token::END_BLOCK << endl;
}
bool Foam::tabulatedHeatTransfer::read(const dictionary& dict)
bool Foam::fv::tabulatedHeatTransfer::read(const dictionary& dict)
{
if (basicSource::read(dict))
if (option::read(dict))
{
return true;
}
@ -152,4 +166,4 @@ bool Foam::tabulatedHeatTransfer::read(const dictionary& dict)
}
// ************************************************************************* //
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -22,12 +22,12 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::tabulatedHeatTransfer
Foam::fv::tabulatedHeatTransfer
Description
Tabulated heat transfer model. The heat exchange area must be
provided. The 2D table look for heat transfer coefficients uses the
primary and secondary region velocities
Tabulated heat transfer model. The heat exchange area per unit volume
must be provided. The 2D table returns the heat transfer coefficient
by querying the local and neighbour region velocities
\*---------------------------------------------------------------------------*/
@ -42,6 +42,9 @@ Description
namespace Foam
{
namespace fv
{
/*---------------------------------------------------------------------------*\
Class tabulatedHeatTransfer Declaration
\*---------------------------------------------------------------------------*/
@ -54,11 +57,23 @@ private:
// Private data
//- Name of velocity field; default = U
word UName_;
//- 2D look up table
autoPtr<interpolation2DTable<scalar> > hTable_;
//- Area of heat exchange
autoPtr<volScalarField> area_;
//- Area per unit volume of heat exchanger
autoPtr<volScalarField> AoV_;
//- Heat transfer coefficient table
const interpolation2DTable<scalar>& hTable();
//- Field of area divided by volume
const volScalarField& AoV();
//- Start time name
const word startTimeName_;
public:
@ -95,13 +110,13 @@ public:
virtual void writeData(Ostream&) const;
//- Read dictionary
virtual bool read(const dictionary& dict) ;
virtual bool read(const dictionary& dict);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fv
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,27 +24,29 @@ License
\*---------------------------------------------------------------------------*/
#include "variableHeatTransfer.H"
#include "IObasicSourceList.H"
#include "turbulenceModel.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace fv
{
defineTypeNameAndDebug(variableHeatTransfer, 0);
addToRunTimeSelectionTable
(
basicSource,
option,
variableHeatTransfer,
dictionary
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::variableHeatTransfer::variableHeatTransfer
Foam::fv::variableHeatTransfer::variableHeatTransfer
(
const word& name,
const word& modelType,
@ -53,27 +55,28 @@ Foam::variableHeatTransfer::variableHeatTransfer
)
:
interRegionHeatTransferModel(name, modelType, dict, mesh),
UName_(coeffs_.lookupOrDefault<word>("UName", "U")),
a_(0),
b_(0),
c_(0),
ds_(0),
Pr_(0),
area_()
AoV_()
{
if (master_)
{
a_ = readScalar(dict_.lookup("a"));
b_ = readScalar(dict_.lookup("b"));
c_ = readScalar(dict_.lookup("c"));
ds_ = readScalar(dict_.lookup("ds"));
Pr_ = readScalar(dict_.lookup("Pr"));
area_.reset
a_ = readScalar(coeffs_.lookup("a"));
b_ = readScalar(coeffs_.lookup("b"));
c_ = readScalar(coeffs_.lookup("c"));
ds_ = readScalar(coeffs_.lookup("ds"));
Pr_ = readScalar(coeffs_.lookup("Pr"));
AoV_.reset
(
new volScalarField
(
IOobject
(
"area",
"AoV",
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
@ -88,90 +91,72 @@ Foam::variableHeatTransfer::variableHeatTransfer
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::variableHeatTransfer::~variableHeatTransfer()
Foam::fv::variableHeatTransfer::~variableHeatTransfer()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::tmp<Foam::volScalarField> Foam::variableHeatTransfer::
calculateHtc()
const Foam::tmp<Foam::volScalarField>
Foam::fv::variableHeatTransfer::calculateHtc()
{
const fvMesh& nbrMesh =
mesh_.time().lookupObject<fvMesh>(nbrRegionName());
const fvMesh& secondaryMesh =
mesh_.time().lookupObject<fvMesh>(mapRegionName());
const compressible::turbulenceModel& nbrTurb =
nbrMesh.lookupObject<compressible::turbulenceModel>("turbulenceModel");
const compressible::turbulenceModel& turb =
secondaryMesh.lookupObject<compressible::turbulenceModel>
(
"turbulenceModel"
);
const fluidThermo& nbrThermo =
nbrMesh.lookupObject<fluidThermo>("thermophysicalProperties");
const fluidThermo& secondaryThermo =
secondaryMesh.lookupObject<fluidThermo>
(
"thermophysicalProperties"
);
const volVectorField& U = nbrMesh.lookupObject<volVectorField>(UName_);
const volVectorField& U =
secondaryMesh.lookupObject<volVectorField>("U");
const volScalarField Re
(
mag(U)*ds_*secondaryThermo.rho()/turb.mut()
);
const volScalarField Re(mag(U)*ds_*nbrThermo.rho()/nbrTurb.mut());
const volScalarField Nu(a_*pow(Re, b_)*pow(Pr_, c_));
scalarField htcMapped(htc_.internalField().size(), 0.0);
scalarField htcNbrMapped(htc_.internalField().size(), 0.0);
secondaryToPrimaryInterpPtr_->interpolateInternalField
(
htcMapped,
Nu*turb.kappaEff()/ds_,
htcNbrMapped,
Nu*nbrTurb.kappaEff()/ds_,
meshToMesh::MAP,
eqOp<scalar>()
);
htc_.internalField() = htcMapped*area_/mesh_.V();
htc_.internalField() =
htcNbrMapped*AoV_*secondaryToPrimaryInterpPtr_->V()/mesh_.V();
return htc_;
}
void Foam::variableHeatTransfer::writeData(Ostream& os) const
void Foam::fv::variableHeatTransfer::writeData(Ostream& os) const
{
os << indent << token::BEGIN_BLOCK << incrIndent << nl;
interRegionHeatTransferModel::writeData(os);
os.writeKeyword("a") << a_ << token::END_STATEMENT << nl;
os.writeKeyword("b") << b_ << token::END_STATEMENT << nl;
os.writeKeyword("c") << c_ << token::END_STATEMENT << nl;
os.writeKeyword("ds") << ds_ << token::END_STATEMENT << nl;
os.writeKeyword("Pr") << Pr_ << token::END_STATEMENT << nl;
os << indent << type() + "Coeffs" << nl;
os << indent << "variableHeatTransfer";
dict_.write(os);
coeffs_.write(os);
os << decrIndent << indent << token::END_BLOCK << endl;
}
bool Foam::variableHeatTransfer::read(const dictionary& dict)
bool Foam::fv::variableHeatTransfer::read(const dictionary& dict)
{
if (basicSource::read(dict))
if (option::read(dict))
{
coeffs_.readIfPresent("UName", UName_);
const dictionary& sourceDict = dict.subDict(name());
const dictionary& subDictCoeffs =
sourceDict.subDict(typeName + "Coeffs");
subDictCoeffs.readIfPresent("a", a_);
subDictCoeffs.readIfPresent("b", b_);
subDictCoeffs.readIfPresent("c", c_);
subDictCoeffs.readIfPresent("ds", ds_);
subDictCoeffs.readIfPresent("Pr", Pr_);
coeffs_.readIfPresent("a", a_);
coeffs_.readIfPresent("b", b_);
coeffs_.readIfPresent("c", c_);
coeffs_.readIfPresent("ds", ds_);
coeffs_.readIfPresent("Pr", Pr_);
return true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::variableHeatTransfer
Foam::fv::variableHeatTransfer
Description
Variable heat transfer model depending on local values. The area of contact
@ -30,13 +30,13 @@ Description
Nu = a*pow(Re, b)*pow(Pr, c)
and the heat transfer coefficient as:
and the heat transfer coefficient as:
htc = Nu*K/ds
where:
K is the heat conduction
ds is the strut diameter
where:
K is the heat conduction
ds is the strut diameter
\*---------------------------------------------------------------------------*/
@ -50,8 +50,11 @@ Description
namespace Foam
{
namespace fv
{
/*---------------------------------------------------------------------------*\
Class variableHeatTransfer Declaration
Class variableHeatTransfer Declaration
\*---------------------------------------------------------------------------*/
class variableHeatTransfer
@ -62,6 +65,9 @@ private:
// Private data
//- Name of velocity field; default = U
word UName_;
//- Model constants
scalar a_;
scalar b_;
@ -73,14 +79,14 @@ private:
//- Fluid Prandt number
scalar Pr_;
//- Area of heat exchange
autoPtr<volScalarField> area_;
//- Area per unit volume of heat exchanger
autoPtr<volScalarField> AoV_;
public:
//- Runtime type information
TypeName("variableHeatTransfer");
TypeName("variableHeatTransfer");
// Constructors
@ -112,17 +118,16 @@ public:
//- Read dictionary
virtual bool read(const dictionary& dict) ;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fv
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -32,21 +32,27 @@ License
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
namespace Foam
{
namespace fv
{
defineTypeNameAndDebug(pressureGradientExplicitSource, 0);
addToRunTimeSelectionTable
(
basicSource,
option,
pressureGradientExplicitSource,
dictionary
);
}
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::pressureGradientExplicitSource::writeProps(const scalar gradP) const
void Foam::fv::pressureGradientExplicitSource::writeProps
(
const scalar gradP
) const
{
// Only write on output time
if (mesh_.time().outputTime())
@ -71,7 +77,7 @@ void Foam::pressureGradientExplicitSource::writeProps(const scalar gradP) const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::pressureGradientExplicitSource::pressureGradientExplicitSource
Foam::fv::pressureGradientExplicitSource::pressureGradientExplicitSource
(
const word& sourceName,
const word& modelType,
@ -79,7 +85,7 @@ Foam::pressureGradientExplicitSource::pressureGradientExplicitSource
const fvMesh& mesh
)
:
basicSource(sourceName, modelType, dict, mesh),
option(sourceName, modelType, dict, mesh),
Ubar_(coeffs_.lookup("Ubar")),
gradP0_(0.0),
dGradP_(0.0),
@ -92,7 +98,7 @@ Foam::pressureGradientExplicitSource::pressureGradientExplicitSource
{
FatalErrorIn
(
"Foam::pressureGradientExplicitSource::"
"Foam::fv::pressureGradientExplicitSource::"
"pressureGradientExplicitSource"
"("
"const word&, "
@ -125,7 +131,7 @@ Foam::pressureGradientExplicitSource::pressureGradientExplicitSource
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::pressureGradientExplicitSource::correct(volVectorField& U)
void Foam::fv::pressureGradientExplicitSource::correct(volVectorField& U)
{
const scalarField& rAU = invAPtr_().internalField();
@ -169,7 +175,7 @@ void Foam::pressureGradientExplicitSource::correct(volVectorField& U)
}
void Foam::pressureGradientExplicitSource::addSup
void Foam::fv::pressureGradientExplicitSource::addSup
(
fvMatrix<vector>& eqn,
const label fieldI
@ -197,7 +203,7 @@ void Foam::pressureGradientExplicitSource::addSup
}
void Foam::pressureGradientExplicitSource::setValue
void Foam::fv::pressureGradientExplicitSource::setValue
(
fvMatrix<vector>& eqn,
const label

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::pressureGradientExplicitSource
Foam::fv::pressureGradientExplicitSource
Description
Creates a pressure gradient source
@ -53,12 +53,14 @@ SourceFiles
#include "cellSet.H"
#include "fvMesh.H"
#include "volFields.H"
#include "basicSource.H"
#include "fvOption.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace fv
{
/*---------------------------------------------------------------------------*\
Class pressureGradientExplicitSource Declaration
@ -66,7 +68,7 @@ namespace Foam
class pressureGradientExplicitSource
:
public basicSource
public option
{
// Private data
@ -149,6 +151,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fv
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -27,11 +27,11 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::pressureGradientExplicitSource::writeData(Ostream& os) const
void Foam::fv::pressureGradientExplicitSource::writeData(Ostream& os) const
{
notImplemented
(
"void Foam::pressureGradientExplicitSource::writeData"
"void Foam::fv::pressureGradientExplicitSource::writeData"
"("
"Ostream&"
") const"
@ -39,11 +39,11 @@ void Foam::pressureGradientExplicitSource::writeData(Ostream& os) const
}
bool Foam::pressureGradientExplicitSource::read(const dictionary& dict)
bool Foam::fv::pressureGradientExplicitSource::read(const dictionary& dict)
{
notImplemented
(
"bool Foam::pressureGradientExplicitSource::read"
"bool Foam::fv::pressureGradientExplicitSource::read"
"("
"const dictionary&"
") const"

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -31,20 +31,22 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace fv
{
defineTypeNameAndDebug(radialActuationDiskSource, 0);
addToRunTimeSelectionTable
(
basicSource,
option,
radialActuationDiskSource,
dictionary
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::radialActuationDiskSource::radialActuationDiskSource
Foam::fv::radialActuationDiskSource::radialActuationDiskSource
(
const word& name,
const word& modelType,
@ -61,7 +63,7 @@ Foam::radialActuationDiskSource::radialActuationDiskSource
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::radialActuationDiskSource::addSup
void Foam::fv::radialActuationDiskSource::addSup
(
fvMatrix<vector>& eqn,
const label fieldI
@ -105,15 +107,15 @@ void Foam::radialActuationDiskSource::addSup
}
void Foam::radialActuationDiskSource::writeData(Ostream& os) const
void Foam::fv::radialActuationDiskSource::writeData(Ostream& os) const
{
actuationDiskSource::writeData(os);
}
bool Foam::radialActuationDiskSource::read(const dictionary& dict)
bool Foam::fv::radialActuationDiskSource::read(const dictionary& dict)
{
if (basicSource::read(dict))
if (option::read(dict))
{
coeffs_.readIfPresent("diskDir", diskDir_);
coeffs_.readIfPresent("Cp", Cp_);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::radialActuationDiskSource
Foam::fv::radialActuationDiskSource
Description
Actuation disk zone definition.
@ -73,6 +73,8 @@ SourceFiles
namespace Foam
{
namespace fv
{
/*---------------------------------------------------------------------------*\
Class radialActuationDiskSource Declaration
@ -131,24 +133,25 @@ public:
{}
// Public Functions
// Member Functions
//- Source term to fvMatrix<vector>
virtual void addSup(fvMatrix<vector>& eqn, const label fieldI);
//- Source term to fvMatrix<vector>
virtual void addSup(fvMatrix<vector>& eqn, const label fieldI);
// I-O
// I-O
//- Write data
virtual void writeData(Ostream&) const;
//- Write data
virtual void writeData(Ostream&) const;
//- Read dictionary
virtual bool read(const dictionary& dict);
//- Read dictionary
virtual bool read(const dictionary& dict);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fv
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -33,7 +33,7 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class RhoFieldType>
void Foam::radialActuationDiskSource::
void Foam::fv::radialActuationDiskSource::
addRadialActuationDiskAxialInertialResistance
(
vectorField& Usource,

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -93,7 +93,7 @@ public:
// Selectors
//- Return a reference to the selected basicSource model
//- Return a reference to the selected fvOption model
static autoPtr<profileModel> New(const dictionary& dict);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -37,20 +37,23 @@ using namespace Foam::constant;
namespace Foam
{
defineTypeNameAndDebug(rotorDiskSource, 0);
addToRunTimeSelectionTable(basicSource, rotorDiskSource, dictionary);
namespace fv
{
defineTypeNameAndDebug(rotorDiskSource, 0);
addToRunTimeSelectionTable(option, rotorDiskSource, dictionary);
}
template<> const char* NamedEnum<rotorDiskSource::geometryModeType, 2>::
template<> const char* NamedEnum<fv::rotorDiskSource::geometryModeType, 2>::
names[] =
{
"auto",
"specified"
};
const NamedEnum<rotorDiskSource::geometryModeType, 2>
rotorDiskSource::geometryModeTypeNames_;
const NamedEnum<fv::rotorDiskSource::geometryModeType, 2>
fv::rotorDiskSource::geometryModeTypeNames_;
template<> const char* NamedEnum<rotorDiskSource::inletFlowType, 3>::
template<> const char* NamedEnum<fv::rotorDiskSource::inletFlowType, 3>::
names[] =
{
"fixed",
@ -58,14 +61,14 @@ namespace Foam
"local"
};
const NamedEnum<rotorDiskSource::inletFlowType, 3>
rotorDiskSource::inletFlowTypeNames_;
const NamedEnum<fv::rotorDiskSource::inletFlowType, 3>
fv::rotorDiskSource::inletFlowTypeNames_;
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::rotorDiskSource::checkData()
void Foam::fv::rotorDiskSource::checkData()
{
// set inflow type
switch (selectionMode())
@ -122,7 +125,7 @@ void Foam::rotorDiskSource::checkData()
}
void Foam::rotorDiskSource::setFaceArea(vector& axis, const bool correct)
void Foam::fv::rotorDiskSource::setFaceArea(vector& axis, const bool correct)
{
area_ = 0.0;
@ -235,7 +238,7 @@ void Foam::rotorDiskSource::setFaceArea(vector& axis, const bool correct)
}
void Foam::rotorDiskSource::createCoordinateSystem()
void Foam::fv::rotorDiskSource::createCoordinateSystem()
{
// construct the local rotor co-prdinate system
vector origin(vector::zero);
@ -348,7 +351,7 @@ void Foam::rotorDiskSource::createCoordinateSystem()
}
void Foam::rotorDiskSource::constructGeometry()
void Foam::fv::rotorDiskSource::constructGeometry()
{
const vectorField& C = mesh_.C();
@ -382,7 +385,7 @@ void Foam::rotorDiskSource::constructGeometry()
}
Foam::tmp<Foam::vectorField> Foam::rotorDiskSource::inflowVelocity
Foam::tmp<Foam::vectorField> Foam::fv::rotorDiskSource::inflowVelocity
(
const volVectorField& U
) const
@ -410,7 +413,7 @@ Foam::tmp<Foam::vectorField> Foam::rotorDiskSource::inflowVelocity
FatalErrorIn
(
"Foam::tmp<Foam::vectorField> "
"Foam::rotorDiskSource::inflowVelocity"
"Foam::fv::rotorDiskSource::inflowVelocity"
"(const volVectorField&) const"
) << "Unknown inlet flow specification" << abort(FatalError);
}
@ -422,7 +425,7 @@ Foam::tmp<Foam::vectorField> Foam::rotorDiskSource::inflowVelocity
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
Foam::rotorDiskSource::rotorDiskSource
Foam::fv::rotorDiskSource::rotorDiskSource
(
const word& name,
const word& modelType,
@ -431,7 +434,7 @@ Foam::rotorDiskSource::rotorDiskSource
)
:
basicSource(name, modelType, dict, mesh),
option(name, modelType, dict, mesh),
rhoName_("none"),
rhoRef_(1.0),
omega_(0.0),
@ -456,13 +459,13 @@ Foam::rotorDiskSource::rotorDiskSource
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::rotorDiskSource::~rotorDiskSource()
Foam::fv::rotorDiskSource::~rotorDiskSource()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::rotorDiskSource::calculate
void Foam::fv::rotorDiskSource::calculate
(
const vectorField& U,
const scalarField& thetag,
@ -585,7 +588,11 @@ void Foam::rotorDiskSource::calculate
}
void Foam::rotorDiskSource::addSup(fvMatrix<vector>& eqn, const label fieldI)
void Foam::fv::rotorDiskSource::addSup
(
fvMatrix<vector>& eqn,
const label fieldI
)
{
dimensionSet dims = dimless;
if (eqn.dimensions() == dimForce)
@ -632,16 +639,16 @@ void Foam::rotorDiskSource::addSup(fvMatrix<vector>& eqn, const label fieldI)
}
void Foam::rotorDiskSource::writeData(Ostream& os) const
void Foam::fv::rotorDiskSource::writeData(Ostream& os) const
{
os << indent << name_ << endl;
dict_.write(os);
}
bool Foam::rotorDiskSource::read(const dictionary& dict)
bool Foam::fv::rotorDiskSource::read(const dictionary& dict)
{
if (basicSource::read(dict))
if (option::read(dict))
{
coeffs_.lookup("fieldNames") >> fieldNames_;
applied_.setSize(fieldNames_.size(), false);

Some files were not shown because too many files have changed in this diff Show More