Merge branch 'master' into molecularDynamics

This commit is contained in:
graham
2008-06-17 15:41:04 +01:00
6 changed files with 50 additions and 80 deletions

View File

@ -30,9 +30,9 @@ Description
of values (e.g. words and numbers).
The dictionary class is the base class for IOdictionary.
It serves the purpose of a bootstrap dictionary for the objectRegistry
data dictionaries, since unlike the IOdictionary class, it does not use
a objectRegistry itself to work.
It also serves as a bootstrap dictionary for the objectRegistry data
dictionaries since, unlike the IOdictionary class, it does not use an
objectRegistry itself to work.
ToDo
A merge() member function with a non-const dictionary parameter.
@ -199,25 +199,31 @@ public:
//- Find and return a T, if not found return the given default value
// If recursive search parent dictionaries
template<class T>
T lookupOrDefault(const word&, const T&, bool recursive=false) const;
T lookupOrDefault
(
const word&,
const T&,
bool recursive=false
) const;
//- Find and return a T, if not found return the given default value,
// and add to dictionary. If recusive search parent dictionaries
// and add to dictionary. If recursive search parent dictionaries
template<class T>
T lookupOrAddDefault
(
const word&,
const T&,
bool recusive=false
bool recursive=false
);
//- Find an entry if present, and assign to T
// Returns true if the entry was found
template<class T>
void readIfPresent
bool readIfPresent
(
const word&,
T&,
bool recusive=false
bool recursive=false
) const;
//- Check if entry is a sub-dictionary

View File

@ -54,40 +54,42 @@ template<class T>
T Foam::dictionary::lookupOrAddDefault
(
const word& keyword,
const T& deft,
bool recusive
const T& deflt,
bool recursive
)
{
const entry* ePtr = lookupEntryPtr(keyword, recusive);
const entry* entryPtr = lookupEntryPtr(keyword, recursive);
if (ePtr == NULL)
if (entryPtr == NULL)
{
entry* defPtr = new primitiveEntry(keyword, deft);
append(defPtr);
hashedEntries_.insert(defPtr->keyword(), defPtr);
return deft;
add(new primitiveEntry(keyword, deflt));
return deflt;
}
else
{
return pTraits<T>(ePtr->stream());
return pTraits<T>(entryPtr->stream());
}
}
template<class T>
void Foam::dictionary::readIfPresent
bool Foam::dictionary::readIfPresent
(
const word& keyword,
T& deft,
bool recusive
const word& k,
T& val,
bool recursive
) const
{
const entry* ePtr = lookupEntryPtr(keyword, recusive);
const entry* entryPtr = lookupEntryPtr(k, recursive);
if (ePtr != NULL)
if (entryPtr == NULL)
{
ePtr->stream() >> deft;
return false;
}
else
{
entryPtr->stream() >> val;
return true;
}
}

View File

@ -61,7 +61,7 @@ Foam::IPstream::IPstream
MPI_Status status;
// If the buffer size is not specified probe the incomming message
// If the buffer size is not specified, probe the incomming message
// and set it
if (!bufSize)
{
@ -181,8 +181,7 @@ Foam::label Foam::IPstream::read
(
"IPstream::read"
"(const int fromProcNo, char* buf, std::streamsize bufSize)"
) << "Unsupported communications type "
<< Pstream::commsTypeNames[commsType]
) << "Unsupported communications type " << commsType
<< Foam::abort(FatalError);
return 0;

View File

@ -119,8 +119,7 @@ bool Foam::OPstream::write
(
"OPstream::write"
"(const int fromProcNo, char* buf, std::streamsize bufSize)"
) << "Unsupported communications type "
<< Pstream::commsTypeNames[commsType]
) << "Unsupported communications type " << commsType
<< Foam::abort(FatalError);
}

View File

@ -123,9 +123,9 @@ tmp<scalarField> turbulenceModel::yPlus(const label patchNo) const
if (typeid(curPatch) == typeid(wallFvPatch))
{
dimensionedScalar Cmu(turbulenceModelCoeffs_.lookup("Cmu"));
scalar Cmu(turbulenceModelCoeffs_.lookup("Cmu"));
Yp = pow(Cmu.value(), 0.25)
Yp = pow(Cmu, 0.25)
*y_[patchNo]
*sqrt(k()().boundaryField()[patchNo].patchInternalField())
/(
@ -164,32 +164,14 @@ bool turbulenceModel::read()
lookup("turbulence") >> turbulence_;
turbulenceModelCoeffs_ = subDict(type() + "Coeffs");
kappa_ = dimensionedScalar
(
subDict("wallFunctionCoeffs").lookup("kappa")
).value();
E_ = dimensionedScalar
(
subDict("wallFunctionCoeffs").lookup("E")
).value();
subDict("wallFunctionCoeffs").lookup("kappa") >> kappa_;
subDict("wallFunctionCoeffs").lookup("E") >> E_;
yPlusLam_ = yPlusLam(kappa_, E_);
if (found("k0"))
{
lookup("k0") >> k0_;
}
if (found("epsilon0"))
{
lookup("epsilon0") >> epsilon0_;
}
if (found("epsilonSmall"))
{
lookup("epsilonSmall") >> epsilonSmall_;
}
readIfPresent("k0", k0_);
readIfPresent("epsilon0", epsilon0_);
readIfPresent("epsilonSmall", epsilonSmall_);
return true;
}

View File

@ -123,9 +123,9 @@ tmp<scalarField> turbulenceModel::yPlus(const label patchNo) const
if (typeid(curPatch) == typeid(wallFvPatch))
{
dimensionedScalar Cmu(turbulenceModelCoeffs_.lookup("Cmu"));
scalar Cmu(turbulenceModelCoeffs_.lookup("Cmu"));
Yp = pow(Cmu.value(), 0.25)*y_[patchNo]
Yp = pow(Cmu, 0.25)*y_[patchNo]
*sqrt(k()().boundaryField()[patchNo].patchInternalField())
/nu().boundaryField()[patchNo];
}
@ -161,32 +161,14 @@ bool turbulenceModel::read()
lookup("turbulence") >> turbulence_;
turbulenceModelCoeffs_ = subDict(type() + "Coeffs");
kappa_ = dimensionedScalar
(
subDict("wallFunctionCoeffs").lookup("kappa")
).value();
E_ = dimensionedScalar
(
subDict("wallFunctionCoeffs").lookup("E")
).value();
subDict("wallFunctionCoeffs").lookup("kappa") >> kappa_;
subDict("wallFunctionCoeffs").lookup("E") >> E_;
yPlusLam_ = yPlusLam(kappa_, E_);
if (found("k0"))
{
lookup("k0") >> k0_;
}
if (found("epsilon0"))
{
lookup("epsilon0") >> epsilon0_;
}
if (found("epsilonSmall"))
{
lookup("epsilonSmall") >> epsilonSmall_;
}
readIfPresent("k0", k0_);
readIfPresent("epsilon0", epsilon0_);
readIfPresent("epsilonSmall", epsilonSmall_);
return true;
}