Merge branch 'master' of /home/noisy3/OpenFOAM/OpenFOAM-dev

This commit is contained in:
mattijs
2011-03-03 18:32:02 +00:00
37 changed files with 731 additions and 664 deletions

View File

@ -24,12 +24,17 @@
fvc::interpolate(thermo.psi())*phiv
);
fvScalarMatrix pDDtEqn
(
fvc::ddt(rho) + fvc::div(phi)
+ correction(fvm::ddt(psi, p) + fvm::div(phid, p))
);
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
fvScalarMatrix pEqn
(
fvc::ddt(rho) + fvc::div(phi)
+ correction(fvm::ddt(psi, p) + fvm::div(phid, p))
pDDtEqn
- fvm::laplacian(rho*rAU, p)
);
@ -63,12 +68,17 @@
+ fvc::ddtPhiCorr(rAU, rho, U, phi)
);
fvScalarMatrix pDDtEqn
(
fvc::ddt(rho) + psi*correction(fvm::ddt(p))
+ fvc::div(phi)
);
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
fvScalarMatrix pEqn
(
fvc::ddt(rho) + psi*correction(fvm::ddt(p))
+ fvc::div(phi)
pDDtEqn
- fvm::laplacian(rho*rAU, p)
);

View File

@ -19,12 +19,17 @@
surfaceScalarField buoyancyPhi(-rhorAUf*ghf*fvc::snGrad(rho)*mesh.magSf());
phi += buoyancyPhi;
fvScalarMatrix p_rghDDtEqn
(
fvc::ddt(rho) + psi*correction(fvm::ddt(p_rgh))
+ fvc::div(phi)
);
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
fvScalarMatrix p_rghEqn
(
fvc::ddt(rho) + psi*correction(fvm::ddt(p_rgh))
+ fvc::div(phi)
p_rghDDtEqn
- fvm::laplacian(rhorAUf, p_rgh)
);

View File

@ -23,7 +23,7 @@
);
}
fvScalarMatrix DrhoDtEqn
fvScalarMatrix pDDtEqn
(
fvc::ddt(rho) + psi*correction(fvm::ddt(p))
+ fvc::div(phi)
@ -36,7 +36,7 @@
{
fvScalarMatrix pEqn
(
DrhoDtEqn
pDDtEqn
- fvm::laplacian(rho*rAU, p)
);

View File

@ -23,16 +23,21 @@
);
}
fvScalarMatrix pDDtEqn
(
fvc::ddt(rho) + psi*correction(fvm::ddt(p))
+ fvc::div(phi)
==
parcels.Srho()
+ massSource.SuTot()
);
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
fvScalarMatrix pEqn
(
fvc::ddt(rho) + psi*correction(fvm::ddt(p))
+ fvc::div(phi)
pDDtEqn
- fvm::laplacian(rho*rAU, p)
==
parcels.Srho()
+ massSource.SuTot()
);
if (corr == nCorr-1 && nonOrth == nNonOrthCorr)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -22,10 +22,10 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
fileName
Test-fileName
Description
Test some basic fileName functionality
\*---------------------------------------------------------------------------*/
@ -52,9 +52,10 @@ int main()
fileName pathName(wrdList);
Info<< "pathName = " << pathName << nl
<< "pathName.name() = " << pathName.name() << nl
<< "pathName.name() = >" << pathName.name() << "<\n"
<< "pathName.path() = " << pathName.path() << nl
<< "pathName.ext() = " << pathName.ext() << endl;
<< "pathName.ext() = >" << pathName.ext() << "<\n"
<< "pathName.name(true) = >" << pathName.name(true) << "<\n";
Info<< "pathName.components() = " << pathName.components() << nl
<< "pathName.component(2) = " << pathName.component(2) << nl

View File

@ -40,8 +40,9 @@ int main(int argc, char *argv[])
{
string test
(
" $HOME kjhkjhkjh \" \\$HOME/tyetyery ${FOAM_RUN} \n ; hkjh ;$ with "
" $(DONOTSUBST) some other ${USER} entries "
" $HOME kjhkjhkjh \" \\$HOME/tyetyery $; ${FOAM_RUN} \n $; hkjh;"
" $(DONOTSUBST) some other <${USER}> with '${__UNKNOWN:-some default}'"
" value "
);
dictionary dict;
@ -88,7 +89,7 @@ int main(int argc, char *argv[])
Info<< "expanded: " << string(test).expand() << endl;
Info<<"dictionary-based substitution: " << dict << endl;
Info<< "expandDict: " << stringOps::expandDict(test, dict) << endl;
Info<< "expand dict: " << stringOps::expand(test, dict) << endl;
string test2("~OpenFOAM/controlDict");
Info<< test2 << " => " << test2.expand() << endl;

View File

@ -67,5 +67,6 @@ alias foamSol 'cd $FOAM_SOLVERS'
alias foamTuts 'cd $FOAM_TUTORIALS'
alias foamUtils 'cd $FOAM_UTILITIES'
alias foam3rdParty 'cd $WM_THIRD_PARTY_DIR'
alias foamSite 'cd $WM_PROJECT_INST_DIR/site'
# -----------------------------------------------------------------------------

View File

@ -72,5 +72,6 @@ alias foamSol='cd $FOAM_SOLVERS'
alias foamTuts='cd $FOAM_TUTORIALS'
alias foamUtils='cd $FOAM_UTILITIES'
alias foam3rdParty='cd $WM_THIRD_PARTY_DIR'
alias foamSite='cd $WM_PROJECT_INST_DIR/site'
# -----------------------------------------------------------------------------

View File

@ -28,7 +28,10 @@ License
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "surfaceFields.H"
//{{{ begin codeInclude
${codeInclude}
//}}} end codeInclude
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -44,9 +47,16 @@ extern "C"
//
// unique function name that can be checked if the correct library version
// has been loaded
bool ${typeName}_${SHA1sum}()
void ${typeName}_${SHA1sum}(bool load)
{
return true;
if (load)
{
// code that can be explicitly executed after loading
}
else
{
// code that can be explicitly executed before unloading
}
}
}
@ -61,7 +71,13 @@ ${typeName}FixedValueFvPatchScalarField
)
:
fixedValueFvPatchScalarField(p, iF)
{}
{
if (${verbose:-false})
{
Info<<"construct ${typeName} sha1: ${SHA1sum}"
" from patch/DimensionedField\n";
}
}
${typeName}FixedValueFvPatchScalarField::
@ -74,7 +90,13 @@ ${typeName}FixedValueFvPatchScalarField
)
:
fixedValueFvPatchScalarField(ptf, p, iF, mapper)
{}
{
if (${verbose:-false})
{
Info<<"construct ${typeName} sha1: ${SHA1sum}"
" from patch/DimensionedField/mapper\n";
}
}
${typeName}FixedValueFvPatchScalarField::
@ -86,7 +108,13 @@ ${typeName}FixedValueFvPatchScalarField
)
:
fixedValueFvPatchScalarField(p, iF, dict)
{}
{
if (${verbose:-false})
{
Info<<"construct ${typeName} sha1: ${SHA1sum}"
" from patch/dictionary\n";
}
}
${typeName}FixedValueFvPatchScalarField::
@ -96,7 +124,13 @@ ${typeName}FixedValueFvPatchScalarField
)
:
fixedValueFvPatchScalarField(ptf)
{}
{
if (${verbose:-false})
{
Info<<"construct ${typeName} sha1: ${SHA1sum}"
" as copy\n";
}
}
${typeName}FixedValueFvPatchScalarField::
@ -107,14 +141,25 @@ ${typeName}FixedValueFvPatchScalarField
)
:
fixedValueFvPatchScalarField(ptf, iF)
{}
{
if (${verbose:-false})
{
Info<<"construct ${typeName} sha1: ${SHA1sum} "
"as copy/DimensionedField\n";
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
${typeName}FixedValueFvPatchScalarField::
~${typeName}FixedValueFvPatchScalarField()
{}
{
if (${verbose:-false})
{
Info<<"destroy ${typeName} sha1: ${SHA1sum}\n";
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -126,7 +171,15 @@ void ${typeName}FixedValueFvPatchScalarField::updateCoeffs()
return;
}
${code}
if (${verbose:-false})
{
Info<<"updateCoeffs ${typeName} sha1: ${SHA1sum}\n";
}
//{{{ begin code
${code};
//}}} end code
fixedValueFvPatchScalarField::updateCoeffs();
}

View File

@ -36,13 +36,13 @@
#
#------------------------------------------------------------------------------
## Specify system compiler
## ~~~~~~~~~~~~~~~~~~~~~~~
#set foamCompiler=OpenFOAM
## Specify OpenFOAM ThirdParty compiler
## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# set foamCompiler=ThirdParty
## Specify system openmpi
## ~~~~~~~~~~~~~~~~~~~~~~
#setenv WM_MPLIB SYSTEMOPENMPI
# setenv WM_MPLIB SYSTEMOPENMPI
# ----------------------------------------------------------------- end-of-file

View File

@ -36,13 +36,13 @@
#
#------------------------------------------------------------------------------
# Specify system compiler
# ~~~~~~~~~~~~~~~~~~~~~~~
foamCompiler=OpenFOAM
## Specify OpenFOAM ThirdParty compiler
## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# foamCompiler=ThirdParty
# Specify system openmpi
# ~~~~~~~~~~~~~~~~~~~~~~
export WM_MPLIB=SYSTEMOPENMPI
## Specify system openmpi
## ~~~~~~~~~~~~~~~~~~~~~~
# export WM_MPLIB=SYSTEMOPENMPI
# ----------------------------------------------------------------- end-of-file

View File

@ -98,21 +98,20 @@ bool Foam::functionEntries::codeStream::execute
// see if library is loaded
void* lib = dlLibraryTable::findLibrary(libPath);
bool reuseLib = false;
// nothing loaded
// avoid compilation if possible by loading an existing library
if (!lib && dlLibraryTable::open(libPath, false))
{
lib = dlLibraryTable::findLibrary(libPath);
reuseLib = true;
}
// create library if required
if (!lib)
{
if (Pstream::master())
bool create = Pstream::master();
if (create)
{
if (!dynCode.upToDate(context))
{
@ -137,7 +136,7 @@ bool Foam::functionEntries::codeStream::execute
"functionEntries::codeStream::execute(..)",
parentDict
) << "Failed writing files for" << nl
<< dynCode.libPath() << nl
<< dynCode.libRelPath() << nl
<< exit(FatalIOError);
}
}
@ -148,14 +147,13 @@ bool Foam::functionEntries::codeStream::execute
(
"functionEntries::codeStream::execute(..)",
parentDict
) << "Failed wmake " << libPath
) << "Failed wmake " << dynCode.libRelPath() << nl
<< exit(FatalIOError);
}
}
// all processes must wait for compile
bool waiting = true;
reduce(waiting, orOp<bool>());
// all processes must wait for compile to finish
reduce(create, orOp<bool>());
if (!dlLibraryTable::open(libPath, false))
{
@ -163,21 +161,17 @@ bool Foam::functionEntries::codeStream::execute
(
"functionEntries::codeStream::execute(..)",
parentDict
) << "Failed loading library " << libPath
) << "Failed loading library " << libPath << nl
<< exit(FatalIOError);
}
lib = dlLibraryTable::findLibrary(libPath);
}
else if (reuseLib)
{
Info<< "Reusing library in " << libPath << endl;
}
// Find the function handle in the library
void (*function)(Ostream&, const dictionary&);
function = reinterpret_cast<void(*)(Ostream&, const dictionary&)>
streamingFunctionType function =
reinterpret_cast<streamingFunctionType>
(
dlSym(lib, dynCode.codeName())
);

View File

@ -109,6 +109,11 @@ class codeStream
:
public functionEntry
{
//- Interpreter function type
typedef void (*streamingFunctionType)(Ostream&, const dictionary&);
// Private Member Functions
//- Disallow default bitwise copy construct

View File

@ -51,6 +51,8 @@ const Foam::fileName Foam::dynamicCode::codeTemplateDirName
const char* Foam::dynamicCode::libTargetRoot =
"LIB = $(PWD)/../platforms/$(WM_OPTIONS)/lib/lib";
const char* Foam::dynamicCode::topDirName = "dynamicCode";
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
@ -75,6 +77,15 @@ void Foam::dynamicCode::checkSecurity
}
Foam::word Foam::dynamicCode::libraryBaseName(const fileName& libPath)
{
word libName(libPath.name(true));
libName.erase(0, 3); // remove leading 'lib' from name
return libName;
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::dynamicCode::copyAndFilter
@ -281,7 +292,7 @@ bool Foam::dynamicCode::writeDigest(const std::string& sha1) const
Foam::dynamicCode::dynamicCode(const word& codeName, const word& codeDirName)
:
codeRoot_(stringOps::expand("$FOAM_CASE/dynamicCode")),
codeRoot_(stringOps::expand("$FOAM_CASE")/topDirName),
libSubDir_(stringOps::expand("platforms/$WM_OPTIONS/lib")),
codeName_(codeName),
codeDirName_(codeDirName)
@ -297,6 +308,18 @@ Foam::dynamicCode::dynamicCode(const word& codeName, const word& codeDirName)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::fileName Foam::dynamicCode::codeRelPath() const
{
return topDirName/codeDirName_;
}
Foam::fileName Foam::dynamicCode::libRelPath() const
{
return codeRelPath()/libSubDir_/"lib" + codeName_ + ".so";
}
void Foam::dynamicCode::clear()
{
compileFiles_.clear();
@ -376,7 +399,7 @@ bool Foam::dynamicCode::copyOrCreateFiles(const bool verbose) const
{
if (verbose)
{
Info<< "Creating new library in " << this->libPath() << endl;
Info<< "Creating new library in " << this->libRelPath() << endl;
}
if (!allowSystemOperations)
@ -500,7 +523,7 @@ bool Foam::dynamicCode::copyOrCreateFiles(const bool verbose) const
bool Foam::dynamicCode::wmakeLibso() const
{
const Foam::string wmakeCmd("wmake libso " + this->codePath());
const Foam::string wmakeCmd("wmake libso " + this->codeRelPath());
Info<< "Invoking " << wmakeCmd << endl;
if (Foam::system(wmakeCmd))

View File

@ -108,6 +108,9 @@ protected:
//- Root of the LIB target for Make/files
static const char* libTargetRoot;
//- Top-level directory name for copy/compiling
static const char* topDirName;
// Protected Member Functions
@ -166,6 +169,9 @@ public:
//- Check security for creating dynamic code
static void checkSecurity(const char* title, const dictionary&);
//- Return the library basename without leading 'lib' or trailing '.so'
static word libraryBaseName(const fileName& libPath);
// Constructors
@ -220,6 +226,17 @@ public:
return codeRoot_/libSubDir_/"lib" + codeName_ + ".so";
}
//- Path for specified code name relative to \$FOAM_CASE
// Corresponds to topDirName/codeDirName()
fileName codeRelPath() const;
//- Library path for specified code name relative to \$FOAM_CASE
// Corresponds to
// dynamicCode/codeDirName()/libSubDir()/lib\<codeName\>.so
fileName libRelPath() const;
//- Path for SHA1Digest
// Corresponds to codePath()/Make/SHA1Digest
fileName digestFile() const

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -204,6 +204,42 @@ Foam::word Foam::fileName::name() const
}
Foam::word Foam::fileName::name(const bool noExt) const
{
if (noExt)
{
size_type beg = rfind('/');
if (beg == npos)
{
beg = 0;
}
else
{
++beg;
}
size_type dot = rfind('.');
if (dot != npos && dot <= beg)
{
dot = npos;
}
if (dot == npos)
{
return substr(beg, npos);
}
else
{
return substr(beg, dot - beg);
}
}
else
{
return this->name();
}
}
// Return directory path name (part before last /)
//
// behaviour compared to /usr/bin/dirname:
@ -283,22 +319,22 @@ Foam::wordList Foam::fileName::components(const char delimiter) const
{
DynamicList<word> wrdList(20);
size_type start=0, end=0;
size_type beg=0, end=0;
while ((end = find(delimiter, start)) != npos)
while ((end = find(delimiter, beg)) != npos)
{
// avoid empty element (caused by doubled slashes)
if (start < end)
if (beg < end)
{
wrdList.append(substr(start, end-start));
wrdList.append(substr(beg, end-beg));
}
start = end + 1;
beg = end + 1;
}
// avoid empty trailing element
if (start < size())
if (beg < size())
{
wrdList.append(substr(start, npos));
wrdList.append(substr(beg, npos));
}
// transfer to wordList

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -153,6 +153,9 @@ public:
//- Return file name (part beyond last /)
word name() const;
//- Return file name, optionally without extension
word name(const bool noExt) const;
//- Return directory path name (part before last /)
fileName path() const;

View File

@ -24,14 +24,16 @@ License
\*---------------------------------------------------------------------------*/
#include "string.H"
#include "OSspecific.H"
#include "stringOps.H"
/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
const char* const Foam::string::typeName = "string";
int Foam::string::debug(debug::debugSwitch(string::typeName, 0));
int Foam::string::debug(Foam::debug::debugSwitch(string::typeName, 0));
const Foam::string Foam::string::null;
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Count and return the number of a given character in the string
@ -43,7 +45,7 @@ Foam::string::size_type Foam::string::count(const char c) const
{
if (*iter == c)
{
cCount++;
++cCount;
}
}
@ -95,136 +97,7 @@ Foam::string& Foam::string::replaceAll
Foam::string& Foam::string::expand(const bool allowEmpty)
{
size_type begVar = 0;
// Expand $VARS
// Repeat until nothing more is found
while
(
(begVar = find('$', begVar)) != npos
&& begVar < size()-1
)
{
if (begVar == 0 || operator[](begVar-1) != '\\')
{
// Find end of first occurrence
size_type endVar = begVar;
size_type delim = 0;
if (operator[](begVar+1) == '{')
{
endVar = find('}', begVar);
delim = 1;
}
else
{
iterator iter = begin() + begVar + 1;
while
(
iter != end()
&& (isalnum(*iter) || *iter == '_')
)
{
++iter;
++endVar;
}
}
if (endVar != npos && endVar != begVar)
{
const string varName = substr
(
begVar + 1 + delim,
endVar - begVar - 2*delim
);
const string varValue = getEnv(varName);
if (varValue.size())
{
std::string::replace
(
begVar,
endVar - begVar + 1,
varValue
);
begVar += varValue.size();
}
else if (allowEmpty)
{
std::string::replace
(
begVar,
endVar - begVar + 1,
""
);
}
else
{
FatalErrorIn("string::expand(const bool, const bool)")
<< "Unknown variable name " << varName << '.'
<< exit(FatalError);
}
}
else
{
break;
}
}
else
{
++begVar;
}
}
if (size())
{
if (operator[](0) == '~')
{
// Expand initial ~
// ~/ => home directory
// ~OpenFOAM => site/user OpenFOAM configuration directory
// ~user => home directory for specified user
word user;
fileName file;
if ((begVar = find('/')) != npos)
{
user = substr(1, begVar - 1);
file = substr(begVar + 1);
}
else
{
user = substr(1);
}
// NB: be a bit lazy and expand ~unknownUser as an
// empty string rather than leaving it untouched.
// otherwise add extra test
if (user == "OpenFOAM")
{
*this = findEtcFile(file);
}
else
{
*this = home(user)/file;
}
}
else if (operator[](0) == '.')
{
// Expand a lone '.' and an initial './' into cwd
if (size() == 1)
{
*this = cwd();
}
else if (operator[](1) == '/')
{
std::string::replace(0, 1, cwd());
}
}
}
stringOps::inplaceExpand(*this, allowEmpty);
return *this;
}

View File

@ -66,10 +66,23 @@ Foam::string& Foam::stringOps::inplaceExpand
string::size_type endVar = begVar;
string::size_type delim = 0;
// The position of the ":-" default value
string::size_type altPos = string::npos;
if (s[begVar+1] == '{')
{
endVar = s.find('}', begVar);
delim = 1;
// looks like ${parameter:-word}
if (endVar != string::npos)
{
altPos = s.find(":-", begVar);
if (altPos != string::npos && altPos > endVar)
{
altPos = string::npos;
}
}
}
else
{
@ -93,18 +106,43 @@ Foam::string& Foam::stringOps::inplaceExpand
}
}
if (endVar != string::npos && endVar != begVar)
if (endVar == string::npos)
{
// likely parsed '${...' without closing '}' - abort
break;
}
else if (endVar == begVar)
{
// parsed '${}' or $badChar - skip over
begVar = endVar + 1;
}
else
{
const word varName
(
s.substr
(
begVar + 1 + delim,
endVar - begVar - 2*delim
(
(altPos == string::npos ? endVar : altPos)
- begVar - 2*delim
)
),
false
);
std::string altValue;
if (altPos != string::npos)
{
// had ":-" default value
altValue = s.substr
(
altPos + 2,
endVar - altPos - 2*delim
);
}
HashTable<string, word, string::hash>::const_iterator fnd =
mapping.find(varName);
@ -118,6 +156,17 @@ Foam::string& Foam::stringOps::inplaceExpand
);
begVar += (*fnd).size();
}
else if (altPos != string::npos)
{
// use alternative provided
s.std::string::replace
(
begVar,
endVar - begVar + 1,
altValue
);
begVar += altValue.size();
}
else
{
s.std::string::replace
@ -128,10 +177,6 @@ Foam::string& Foam::stringOps::inplaceExpand
);
}
}
else
{
break;
}
}
else
{
@ -205,7 +250,17 @@ Foam::string& Foam::stringOps::inplaceExpand
}
}
if (endVar != string::npos && endVar != begVar)
if (endVar == string::npos)
{
// likely parsed '${...' without closing '}' - abort
break;
}
else if (endVar == begVar)
{
// parsed '${}' or $badChar - skip over
begVar = endVar + 1;
}
else
{
const word varName
(
@ -249,13 +304,9 @@ Foam::string& Foam::stringOps::inplaceExpand
else
{
// not defined - leave original string untouched
begVar = endVar;
begVar = endVar + 1;
}
}
else
{
break;
}
}
else
{
@ -300,10 +351,23 @@ Foam::string& Foam::stringOps::inplaceExpand
string::size_type endVar = begVar;
string::size_type delim = 0;
// The position of the ":-" default value
string::size_type altPos = string::npos;
if (s[begVar+1] == '{')
{
endVar = s.find('}', begVar);
delim = 1;
// looks like ${parameter:-word}
if (endVar != string::npos)
{
altPos = s.find(":-", begVar);
if (altPos != string::npos && altPos > endVar)
{
altPos = string::npos;
}
}
}
else
{
@ -320,21 +384,47 @@ Foam::string& Foam::stringOps::inplaceExpand
}
}
if (endVar != string::npos && endVar != begVar)
if (endVar == string::npos)
{
// likely parsed '${...' without closing '}' - abort
break;
}
else if (endVar == begVar)
{
// parsed '${}' or $badChar - skip over
begVar = endVar + 1;
}
else
{
const word varName
(
s.substr
(
begVar + 1 + delim,
endVar - begVar - 2*delim
(
(altPos == string::npos ? endVar : altPos)
- begVar - 2*delim
)
),
false
);
std::string altValue;
if (altPos != string::npos)
{
// had ":-" default value
altValue = s.substr
(
altPos + 2,
endVar - altPos - 2*delim
);
}
const string varValue = getEnv(varName);
if (varValue.size())
{
// direct replacement
s.std::string::replace
(
begVar,
@ -343,6 +433,17 @@ Foam::string& Foam::stringOps::inplaceExpand
);
begVar += varValue.size();
}
else if (altPos != string::npos)
{
// use alternative provided
s.std::string::replace
(
begVar,
endVar - begVar + 1,
altValue
);
begVar += altValue.size();
}
else if (allowEmpty)
{
s.std::string::replace
@ -362,10 +463,6 @@ Foam::string& Foam::stringOps::inplaceExpand
<< exit(FatalError);
}
}
else
{
break;
}
}
else
{

View File

@ -55,7 +55,17 @@ namespace stringOps
// -# variables
// - "$VAR", "${VAR}"
//
// Any unknown entries are removed
// Supports default values as per the Bourne/Korn shell.
// \code
// "${parameter:-defValue}"
// \endcode
// If parameter is unset or null, the \c defValue is substituted.
// Otherwise, the value of parameter is substituted.
//
// Any unknown entries are removed silently.
//
// Malformed entries (eg, brace mismatch, sigil followed by bad character)
// are left as is.
//
// \note the leading sigil can be changed to avoid conflicts with other
// string expansions
@ -72,7 +82,17 @@ namespace stringOps
// -# variables
// - "$VAR", "${VAR}"
//
// Any unknown entries are removed
// Supports default values as per the Bourne/Korn shell.
// \code
// "${parameter:-defValue}"
// \endcode
// If parameter is unset or null, the \c defValue is substituted.
// Otherwise, the value of parameter is substituted.
//
// Any unknown entries are removed silently.
//
// Malformed entries (eg, brace mismatch, sigil followed by bad character)
// are left as is.
//
// \note the leading sigil can be changed to avoid conflicts with other
// string expansions
@ -128,7 +148,18 @@ namespace stringOps
// - leading "~user" : home directory for specified user
// - leading "~OpenFOAM" : site/user OpenFOAM configuration directory
//
// Any unknown entries are removed silently if allowEmpty is true
// Supports default values as per the Bourne/Korn shell.
// \code
// "${parameter:-defValue}"
// \endcode
// If parameter is unset or null, the \c defValue is substituted.
// Otherwise, the value of parameter is substituted.
//
// Any unknown entries are removed silently, if allowEmpty is true.
//
// Malformed entries (eg, brace mismatch, sigil followed by bad character)
// are left as is.
//
// \sa
// Foam::findEtcFile
string expand
@ -149,7 +180,19 @@ namespace stringOps
// - leading "~user" : home directory for specified user
// - leading "~OpenFOAM" : site/user OpenFOAM configuration directory
//
// Any unknown entries are removed silently if allowEmpty is true
// Supports default values as per the Bourne/Korn shell.
// \code
// "${parameter:-defValue}"
// \endcode
// If parameter is unset or null, the \c defValue is substituted.
// Otherwise, the value of parameter is substituted.
//
// Any unknown entries are removed silently, if allowEmpty is true.
//
// Malformed entries (eg, brace mismatch, sigil followed by bad character)
// are left as is.
//
// Any unknown entries are removed silently if allowEmpty is true.
// \sa
// Foam::findEtcFile
string& inplaceExpand

View File

@ -115,7 +115,6 @@ $(derivedFvPatchFields)/activeBaffleVelocity/activeBaffleVelocityFvPatchVectorFi
$(derivedFvPatchFields)/advective/advectiveFvPatchFields.C
$(derivedFvPatchFields)/codedFixedValue/codedFixedValueFvPatchScalarField.C
$(derivedFvPatchFields)/codedFixedValue/codeProperties.C
$(derivedFvPatchFields)/directMappedFixedValue/directMappedFixedValueFvPatchFields.C
$(derivedFvPatchFields)/directMappedVelocityFluxFixedValue/directMappedVelocityFluxFixedValueFvPatchField.C
$(derivedFvPatchFields)/fan/fanFvPatchFields.C

View File

@ -1,73 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ 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 "codeProperties.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::codeProperties, 0);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::codeProperties::codeProperties(const IOobject& io)
:
IOdictionary(io),
modified_(true)
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
bool Foam::codeProperties::modified() const
{
modified_ = modified_ || regIOobject::modified();
return modified_;
}
void Foam::codeProperties::setUnmodified() const
{
modified_ = false;
}
bool Foam::codeProperties::read()
{
if (regIOobject::read())
{
modified_ = true;
return true;
}
else
{
return false;
}
}
// ************************************************************************* //

View File

@ -1,92 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ 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::codeProperties
Description
IOdictionary with an internal flag to explicitly track when a file changed.
SourceFiles
codeProperties.C
\*---------------------------------------------------------------------------*/
#ifndef codeProperties_H
#define codeProperties_H
#include "IOdictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class codeProperties Declaration
\*---------------------------------------------------------------------------*/
class codeProperties
:
public IOdictionary
{
// Private data
//- Monitor file change
mutable bool modified_;
public:
// Declare name of the class and its debug switch
ClassName("codeDict");
// Constructors
//- Construct from IOobject
codeProperties(const IOobject&);
// Member Functions
//- A sticky version of regIOobject::modified()
// Must explicitly clear with setUnmodified()
virtual bool modified() const;
//- Make modification unsticky
void setUnmodified() const;
//- Read the dictionary
virtual bool read();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -35,7 +35,6 @@ License
#include "SHA1Digest.H"
#include "dynamicCode.H"
#include "dynamicCodeContext.H"
#include "codeProperties.H"
#include "stringOps.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -46,34 +45,156 @@ const Foam::word Foam::codedFixedValueFvPatchScalarField::codeTemplateC
const Foam::word Foam::codedFixedValueFvPatchScalarField::codeTemplateH
= "fixedValueFvPatchScalarFieldTemplate.H";
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
const Foam::codeProperties&
Foam::codedFixedValueFvPatchScalarField::dict() const
void* Foam::codedFixedValueFvPatchScalarField::loadLibrary
(
const fileName& libPath,
const string& globalFuncName,
const dictionary& contextDict
)
{
if (db().foundObject<codeProperties>(codeProperties::typeName))
void* lib = 0;
// avoid compilation by loading an existing library
if (!libPath.empty() && dlLibraryTable::open(libPath, false))
{
return db().lookupObject<codeProperties>
lib = dlLibraryTable::findLibrary(libPath);
// verify the loaded version and unload if needed
if (lib)
{
// provision for manual execution of code after loading
if (dlSymFound(lib, globalFuncName))
{
loaderFunctionType function =
reinterpret_cast<loaderFunctionType>
(
codeProperties::typeName
dlSym(lib, globalFuncName)
);
if (function)
{
(*function)(true); // force load
}
else
{
codeProperties* props = new codeProperties
FatalIOErrorIn
(
"codedFixedValueFvPatchScalarField::updateLibrary()",
contextDict
) << "Failed looking up symbol " << globalFuncName << nl
<< "from " << libPath << exit(FatalIOError);
}
}
else
{
FatalIOErrorIn
(
"codedFixedValueFvPatchScalarField::loadLibrary()",
contextDict
) << "Failed looking up symbol " << globalFuncName << nl
<< "from " << libPath << exit(FatalIOError);
lib = 0;
if (!dlLibraryTable::close(libPath, false))
{
FatalIOErrorIn
(
"codedFixedValueFvPatchScalarField::loadLibrary()",
contextDict
) << "Failed unloading library "
<< libPath
<< exit(FatalIOError);
}
}
}
}
return lib;
}
void Foam::codedFixedValueFvPatchScalarField::unloadLibrary
(
const fileName& libPath,
const string& globalFuncName,
const dictionary& contextDict
)
{
void* lib = 0;
if (!libPath.empty())
{
lib = dlLibraryTable::findLibrary(libPath);
}
if (!lib)
{
return;
}
// provision for manual execution of code before unloading
if (dlSymFound(lib, globalFuncName))
{
loaderFunctionType function =
reinterpret_cast<loaderFunctionType>
(
dlSym(lib, globalFuncName)
);
if (function)
{
(*function)(false); // force unload
}
else
{
FatalIOErrorIn
(
"codedFixedValueFvPatchScalarField::unloadLibrary()",
contextDict
) << "Failed looking up symbol " << globalFuncName << nl
<< "from " << libPath << exit(FatalIOError);
}
}
if (!dlLibraryTable::close(libPath, false))
{
FatalIOErrorIn
(
"codedFixedValueFvPatchScalarField::"
"updateLibrary()",
contextDict
) << "Failed unloading library " << libPath
<< exit(FatalIOError);
}
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
const Foam::IOdictionary& Foam::codedFixedValueFvPatchScalarField::dict() const
{
if (db().foundObject<IOdictionary>("codeDict"))
{
return db().lookupObject<IOdictionary>("codeDict");
}
else
{
return db().store
(
new IOdictionary
(
IOobject
(
codeProperties::typeName,
"codeDict",
db().time().system(),
db(),
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
)
);
return db().store(props);
}
}
@ -84,8 +205,12 @@ void Foam::codedFixedValueFvPatchScalarField::createLibrary
const dynamicCodeContext& context
) const
{
bool create = Pstream::master();
if (create)
{
// Write files for new library
if (Pstream::master() && !dynCode.upToDate(context))
if (!dynCode.upToDate(context))
{
// filter with this context
dynCode.reset(context);
@ -96,6 +221,14 @@ void Foam::codedFixedValueFvPatchScalarField::createLibrary
// copy filtered H template
dynCode.addCopyFile(codeTemplateH);
// take no chances - typeName must be identical to redirectType_
dynCode.setFilterVariable("typeName", redirectType_);
// debugging: make BC verbose
// dynCode.setFilterVariable("verbose", "true");
// Info<<"compile " << redirectType_ << " sha1: "
// << context.sha1() << endl;
// define Make/options
dynCode.setMakeOptions
(
@ -109,20 +242,32 @@ void Foam::codedFixedValueFvPatchScalarField::createLibrary
{
FatalIOErrorIn
(
"codedFixedValueFvPatchScalarField::writeLibrary(..)",
"codedFixedValueFvPatchScalarField::createLibrary(..)",
context.dict()
) << "Failed writing files for" << nl
<< dynCode.libPath() << nl
<< dynCode.libRelPath() << nl
<< exit(FatalIOError);
}
}
if (!dynCode.wmakeLibso())
{
FatalIOErrorIn
(
"codedFixedValueFvPatchScalarField::createLibrary(..)",
context.dict()
) << "Failed wmake " << dynCode.libRelPath() << nl
<< exit(FatalIOError);
}
}
// all processes must wait for compile to finish
reduce(create, orOp<bool>());
}
void Foam::codedFixedValueFvPatchScalarField::updateLibrary
(
bool firstTime
) const
void Foam::codedFixedValueFvPatchScalarField::updateLibrary() const
{
dynamicCode::checkSecurity
(
@ -130,176 +275,53 @@ void Foam::codedFixedValueFvPatchScalarField::updateLibrary
dict_
);
// use codeProperties or in-line
const bool useCodeProps = !dict_.found("code");
// use system/codeDict or in-line
const dictionary& codeDict =
(
useCodeProps
? this->dict().subDict(redirectType_)
: dict_
dict_.found("code")
? dict_
: this->dict().subDict(redirectType_)
);
dynamicCodeContext context(codeDict);
autoPtr<dynamicCodeContext> contextPtr;
// write code into redirectType_ subdir as well
dynamicCode dynCode(redirectType_);
// codeName: redirectType + _<sha1>
// codeDir : redirectType
dynamicCode dynCode
(
redirectType_ + context.sha1().str(true),
redirectType_
);
const fileName libPath = dynCode.libPath();
// see if library is loaded
void* lib = dlLibraryTable::findLibrary(libPath);
bool reuseLib = false;
bool waiting = false;
if (useCodeProps)
{
// library may be loaded, but out-of-date
const codeProperties& codeProps = this->dict();
if (codeProps.modified())
{
codeProps.setUnmodified();
// Remove instantiation of fvPatchField provided by library
redirectPatchFieldPtr_.clear();
contextPtr.reset(new dynamicCodeContext(codeDict));
// unload code
if (lib)
{
firstTime = false;
reuseLib = false;
lib = 0;
if (!dlLibraryTable::close(libPath, false))
{
FatalIOErrorIn
(
"codedFixedValueFvPatchScalarField::"
"updateLibrary()",
contextPtr().dict()
) << "Failed unloading library "
<< libPath
<< exit(FatalIOError);
}
}
}
}
// library exists (and was not unloaded) - we can leave now
if (lib)
// the correct library was already loaded => we are done
if (dlLibraryTable::findLibrary(libPath))
{
return;
}
// Remove instantiation of fvPatchField provided by library
// remove instantiation of fvPatchField provided by library
redirectPatchFieldPtr_.clear();
if (contextPtr.empty())
{
contextPtr.reset(new dynamicCodeContext(codeDict));
}
// function name serving as version control - based on the SHA1
const string sentinelName
= dynCode.codeName() + contextPtr().sha1().str(true);
// avoid compilation (first time only) by loading an existing library
if (firstTime && dlLibraryTable::open(libPath, false))
{
lib = dlLibraryTable::findLibrary(libPath);
// verify the loaded version and unload if needed
if (lib)
{
reuseLib = dlSymFound(lib, sentinelName);
if (!reuseLib)
{
lib = 0;
if (!dlLibraryTable::close(libPath, false))
{
FatalIOErrorIn
// may need to unload old library
unloadLibrary
(
"codedFixedValueFvPatchScalarField::updateLibrary()",
contextPtr().dict()
) << "Failed unloading library "
<< libPath
<< exit(FatalIOError);
}
}
}
}
oldLibPath_,
dynamicCode::libraryBaseName(oldLibPath_),
context.dict()
);
// really do need to create library
if (!lib)
// try loading an existing library (avoid compilation when possible)
if (!loadLibrary(libPath, dynCode.codeName(), context.dict()))
{
if (Pstream::master())
{
createLibrary(dynCode, contextPtr());
createLibrary(dynCode, context);
if (!dynCode.wmakeLibso())
{
FatalIOErrorIn
(
"codedFixedValueFvPatchScalarField::updateLibrary()",
contextPtr().dict()
) << "Failed wmake " << libPath
<< exit(FatalIOError);
}
loadLibrary(libPath, dynCode.codeName(), context.dict());
}
// all processes must wait for compile
waiting = true;
reduce(waiting, orOp<bool>());
if (!dlLibraryTable::open(libPath, false))
{
FatalIOErrorIn
(
"codedFixedValueFvPatchScalarField::updateLibrary()",
contextPtr().dict()
) << "Failed loading library " << libPath
<< exit(FatalIOError);
}
lib = dlLibraryTable::findLibrary(libPath);
if (!lib)
{
FatalIOErrorIn
(
"codedFixedValueFvPatchScalarField::"
"updateLibrary()",
contextPtr().dict()
) << "Failed to load library " << libPath
<< exit(FatalIOError);
}
//#if 0
// Info<<"check " << libPath << " for " << sentinelName << nl;
// // paranoid - check that signature function is really there
// lib = dlLibraryTable::findLibrary(libPath);
// if (!lib || !dlSymFound(lib, sentinelName))
// {
// FatalIOErrorIn
// (
// "codedFixedValueFvPatchScalarField::"
// "updateLibrary()",
// contextPtr().dict()
// ) << "Failed to load library with correct signature "
// << libPath
// << exit(FatalIOError);
// }
//#endif
}
else if (reuseLib)
{
Info<< "Reusing library in " << libPath << nl;
}
// retain for future reference
oldLibPath_ = libPath;
}
@ -313,6 +335,7 @@ codedFixedValueFvPatchScalarField
)
:
fixedValueFvPatchField<scalar>(p, iF),
oldLibPath_(),
redirectPatchFieldPtr_()
{}
@ -329,6 +352,7 @@ codedFixedValueFvPatchScalarField
fixedValueFvPatchField<scalar>(ptf, p, iF, mapper),
dict_(ptf.dict_),
redirectType_(ptf.redirectType_),
oldLibPath_(),
redirectPatchFieldPtr_()
{}
@ -344,9 +368,10 @@ codedFixedValueFvPatchScalarField
fixedValueFvPatchField<scalar>(p, iF, dict),
dict_(dict),
redirectType_(dict.lookup("redirectType")),
oldLibPath_(),
redirectPatchFieldPtr_()
{
updateLibrary(true);
updateLibrary();
}
@ -359,6 +384,7 @@ codedFixedValueFvPatchScalarField
fixedValueFvPatchField<scalar>(ptf),
dict_(ptf.dict_),
redirectType_(ptf.redirectType_),
oldLibPath_(),
redirectPatchFieldPtr_()
{}
@ -373,6 +399,7 @@ codedFixedValueFvPatchScalarField
fixedValueFvPatchField<scalar>(ptf, iF),
dict_(ptf.dict_),
redirectType_(ptf.redirectType_),
oldLibPath_(),
redirectPatchFieldPtr_()
{}
@ -385,15 +412,15 @@ Foam::codedFixedValueFvPatchScalarField::redirectPatchField() const
if (!redirectPatchFieldPtr_.valid())
{
// Construct a patch
// Make sure to construct the patchfield with uptodate value.
OStringStream os;
os.writeKeyword("type") << redirectType_ << token::END_STATEMENT
<< nl;
static_cast<const scalarField&>(*this).writeEntry("value", os);
IStringStream is(os.str());
dictionary dict(is);
Info<< "constructing patchField from :" << dict << endl;
// Info<< "constructing patchField from :" << dict << endl;
// if (fvPatchScalarField::dictionaryConstructorTablePtr_)
// {
@ -460,15 +487,18 @@ void Foam::codedFixedValueFvPatchScalarField::evaluate
void Foam::codedFixedValueFvPatchScalarField::write(Ostream& os) const
{
//dict_.set("value", static_cast<const scalarField&>(*this));
//os << dict_ << token::END_STATEMENT << nl;
fixedValueFvPatchField<scalar>::write(os);
os.writeKeyword("redirectType") << redirectType_ << token::END_STATEMENT
<< nl;
os.writeKeyword("redirectType") << redirectType_
<< token::END_STATEMENT << nl;
if (dict_.found("code"))
{
os.writeKeyword("code") << string(dict_["code"]) << token::END_STATEMENT
<< nl;
os.writeKeyword("code")
<< token::HASH << token::BEGIN_BLOCK;
os.writeQuoted(string(dict_["code"]), false)
<< token::HASH << token::END_BLOCK
<< token::END_STATEMENT << nl;
}
}

View File

@ -87,9 +87,9 @@ namespace Foam
{
// Forward declaration of classes
class codeProperties;
class dynamicCode;
class dynamicCodeContext;
class IOdictionary;
/*---------------------------------------------------------------------------*\
Class codedFixedValueFvPatchScalarField Declaration
@ -106,18 +106,39 @@ class codedFixedValueFvPatchScalarField
const word redirectType_;
//- Previously loaded library
mutable fileName oldLibPath_;
mutable autoPtr<fvPatchScalarField> redirectPatchFieldPtr_;
// Private Member Functions
const codeProperties& dict() const;
const IOdictionary& dict() const;
//- Global loader/unloader function type
typedef void (*loaderFunctionType)(bool);
static void* loadLibrary
(
const fileName& libPath,
const string& globalFuncName,
const dictionary& contextDict
);
static void unloadLibrary
(
const fileName& libPath,
const string& globalFuncName,
const dictionary& contextDict
);
void createLibrary(dynamicCode&, const dynamicCodeContext&) const;
//- Update library as required
// Use 'firstTime' to alter behaviour
void updateLibrary(bool firstTime=false) const;
void updateLibrary() const;
public:

View File

@ -218,10 +218,10 @@ void Foam::KinematicCloud<CloudType>::evolveCloud(TrackData& td)
{
// this->surfaceFilm().injectSteadyState(td);
this->injection().injectSteadyState(td, solution_.deltaT());
this->injection().injectSteadyState(td, solution_.deltaTValue());
td.part() = TrackData::tpLinearTrack;
CloudType::move(td, solution_.deltaT());
CloudType::move(td, solution_.deltaTValue());
}
}
@ -353,7 +353,7 @@ Foam::KinematicCloud<CloudType>::KinematicCloud
IOobject::AUTO_WRITE
),
mesh_,
dimensionedScalar("zero", dimMass/dimTime, 0.0)
dimensionedScalar("zero", dimMass, 0.0)
)
)
{
@ -504,7 +504,7 @@ void Foam::KinematicCloud<CloudType>::checkParcelProperties
parcel.rho() = constProps_.rho0();
}
const scalar carrierDt = solution_.deltaT();
const scalar carrierDt = solution_.deltaTValue();
parcel.stepFraction() = (carrierDt - lagrangianDt)/carrierDt;
parcel.typeId() = constProps_.parcelTypeId();
}
@ -582,7 +582,7 @@ template<class TrackData>
void Foam::KinematicCloud<CloudType>::motion(TrackData& td)
{
td.part() = TrackData::tpLinearTrack;
CloudType::move(td, solution_.deltaT());
CloudType::move(td, solution_.deltaTValue());
updateCellOccupancy();
}

View File

@ -332,10 +332,10 @@ Foam::KinematicCloud<CloudType>::SU(volVectorField& U) const
{
if (solution_.semiImplicit("U"))
{
return
UTrans()/(mesh_.V()*this->db().time().deltaT())
- fvm::Sp(UCoeff()/mesh_.V(), U)
+ UCoeff()/mesh_.V()*U;
const DimensionedField<scalar, volMesh>
Vdt(mesh_.V()*this->db().time().deltaT());
return UTrans()/Vdt - fvm::Sp(UCoeff()/Vdt, U) + UCoeff()/Vdt*U;
}
else
{
@ -374,16 +374,38 @@ Foam::KinematicCloud<CloudType>::theta() const
)
);
scalarField& theta = ttheta().internalField();
volScalarField& theta = ttheta();
theta.boundaryField() == 0;
forAllConstIter(typename KinematicCloud<CloudType>, *this, iter)
{
const parcelType& p = iter();
const label cellI = p.cell();
if ((p.face() != -1))
{
const label patchI = p.patch(p.face());
if (patchI != -1)
{
scalarField& thetap = theta.boundaryField()[patchI];
const label faceI = p.patchFace(patchI, p.face());
thetap[faceI] += p.nParticle()*p.areaP();
}
}
theta[cellI] += p.nParticle()*p.volume();
}
theta /= mesh().V();
theta.internalField() /= mesh_.V();
forAll(theta.boundaryField(), patchI)
{
scalarField& thetap = theta.boundaryField()[patchI];
if (thetap.size() > 0)
{
thetap /= mesh_.magSf().boundaryField()[patchI];
}
}
return ttheta;
}
@ -420,7 +442,7 @@ Foam::KinematicCloud<CloudType>::alpha() const
alpha[cellI] += p.nParticle()*p.mass();
}
alpha /= (mesh().V()*rho_);
alpha /= (mesh_.V()*rho_);
return talpha;
}
@ -457,7 +479,7 @@ Foam::KinematicCloud<CloudType>::rhoEff() const
rhoEff[cellI] += p.nParticle()*p.mass();
}
rhoEff /= mesh().V();
rhoEff /= mesh_.V();
return trhoEff;
}

View File

@ -169,7 +169,10 @@ public:
inline label nextIter();
//- Return the time step
inline scalar deltaT() const;
inline scalar deltaTValue() const;
//- Return the time step
inline const dimensionedScalar deltaT() const;
//- Return const access to the coupled flag
inline const Switch coupled() const;

View File

@ -95,12 +95,18 @@ inline Foam::label Foam::cloudSolution::nextIter()
}
inline Foam::scalar Foam::cloudSolution::deltaT() const
inline Foam::scalar Foam::cloudSolution::deltaTValue() const
{
return deltaT_;
}
inline const Foam::dimensionedScalar Foam::cloudSolution::deltaT() const
{
return dimensionedScalar("cloudSolution::deltaT", dimTime, deltaT_);
}
inline const Foam::Switch Foam::cloudSolution::coupled() const
{
return coupled_;

View File

@ -114,7 +114,7 @@ inline Foam::tmp<Foam::fvScalarMatrix> Foam::ReactingCloud<CloudType>::SYi
volScalarField& sourceField = trhoTrans();
sourceField.internalField() =
rhoTrans_[i]/(this->db().time().deltaT()*this->mesh().V());
rhoTrans_[i]/(this->db().time().deltaTValue()*this->mesh().V());
const dimensionedScalar YiSMALL("YiSMALL", dimless, SMALL);
@ -127,7 +127,7 @@ inline Foam::tmp<Foam::fvScalarMatrix> Foam::ReactingCloud<CloudType>::SYi
tmp<fvScalarMatrix> tfvm(new fvScalarMatrix(Yi, dimMass/dimTime));
fvScalarMatrix& fvm = tfvm();
fvm.source() = -rhoTrans_[i]/this->db().time().deltaT();
fvm.source() = -rhoTrans_[i]/this->db().time().deltaTValue();
return tfvm;
}
@ -167,7 +167,7 @@ Foam::ReactingCloud<CloudType>::Srho(const label i) const
if (this->solution().coupled())
{
scalarField& rhoi = tRhoi();
rhoi = rhoTrans_[i]/(this->db().time().deltaT()*this->mesh().V());
rhoi = rhoTrans_[i]/(this->db().time().deltaTValue()*this->mesh().V());
}
return tRhoi;
@ -209,7 +209,7 @@ Foam::ReactingCloud<CloudType>::Srho() const
sourceField += rhoTrans_[i];
}
sourceField /= this->db().time().deltaT()*this->mesh().V();
sourceField /= this->db().time().deltaTValue()*this->mesh().V();
}
return trhoTrans;
@ -249,7 +249,7 @@ Foam::ReactingCloud<CloudType>::Srho(volScalarField& rho) const
{
sourceField += rhoTrans_[i];
}
sourceField /= this->db().time().deltaT()*this->mesh().V();
sourceField /= this->db().time().deltaTValue()*this->mesh().V();
return fvm::SuSp(trhoTrans()/rho, rho);
}

View File

@ -127,7 +127,7 @@ Foam::ThermoCloud<CloudType>::ThermoCloud
IOobject::AUTO_WRITE
),
this->mesh(),
dimensionedScalar("zero", dimEnergy/dimTime/dimTemperature, 0.0)
dimensionedScalar("zero", dimEnergy/dimTemperature, 0.0)
)
)

View File

@ -138,11 +138,13 @@ Foam::ThermoCloud<CloudType>::Sh(volScalarField& hs) const
if (this->solution().semiImplicit("hs"))
{
const volScalarField Cp(thermo_.thermo().Cp());
const DimensionedField<scalar, volMesh>
Vdt(this->mesh().V()*this->db().time().deltaT());
return
hsTrans()/(this->mesh().V()*this->db().time().deltaT())
- fvm::Sp(hsCoeff()/(Cp*this->mesh().V()), hs)
+ hsCoeff()/(Cp*this->mesh().V())*hs;
hsTrans()/Vdt
- fvm::Sp(hsCoeff()/(Cp*Vdt), hs)
+ hsCoeff()/(Cp*Vdt)*hs;
}
else
{

View File

@ -202,7 +202,7 @@ const Foam::vector Foam::KinematicParcel<ParcelType>::calcVelocity
const vector abp = (Feff.Sp()*Uc_ + (Feff.Su() + Su))/mass;
const scalar bp = Feff.Sp()/mass;
Spu = Feff.Sp()*dt/td.cloud().solution().deltaT();
Spu = dt*Feff.Sp();
IntegrationScheme<vector>::integrationResult Ures =
td.cloud().UIntegrator().integrate(U, dt, abp, bp);

View File

@ -339,7 +339,7 @@ Foam::scalar Foam::ThermoParcel<ParcelType>::calcHeatTransfer
dhsTrans += dt*htc*As*(0.5*(T + Tnew) - Tc_);
Cuh = bp*dt/td.cloud().solution().deltaT();
Cuh = dt*bp;
return Tnew;
}

View File

@ -520,7 +520,7 @@ void Foam::InjectionModel<CloudType>::inject(TrackData& td)
}
const scalar time = this->owner().db().time().value();
const scalar carrierDt = this->owner().solution().deltaT();
const scalar carrierDt = this->owner().solution().deltaTValue();
const polyMesh& mesh = this->owner().mesh();
// Prepare for next time step

View File

@ -290,7 +290,7 @@ void Foam::PatchInteractionModel<CloudType>::patchData
}
else
{
Up = (Cf - Cf00)/this->owner().solution().deltaT();
Up = (Cf - Cf00)/this->owner().time().deltaTValue();
}
if (mag(dn) > SMALL)
@ -314,7 +314,7 @@ void Foam::PatchInteractionModel<CloudType>::patchData
// angle/dt to give the correct angular velocity vector.
omega *=
Foam::asin(magOmega)
/(magOmega*this->owner().solution().deltaT());
/(magOmega*this->owner().time().deltaTValue());
// Project position onto face and calculate this position
// relative to the face centre.

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2010-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -53,13 +53,6 @@ void Foam::patchProbes::findElements(const fvMesh& mesh)
{
const vector& sample = operator[](probeI);
label faceI = meshSearchEngine.findNearestBoundaryFace(sample);
if (faceI == -1)
{
nearest[probeI].second().first() = Foam::sqr(GREAT);
nearest[probeI].second().second() = Pstream::myProcNo();
}
else
{
const point& fc = mesh.faceCentres()[faceI];
nearest[probeI].first() = pointIndexHit
(
@ -70,7 +63,6 @@ void Foam::patchProbes::findElements(const fvMesh& mesh)
nearest[probeI].second().first() = magSqr(fc-sample);
nearest[probeI].second().second() = Pstream::myProcNo();
}
}
// Find nearest.
@ -92,28 +84,17 @@ void Foam::patchProbes::findElements(const fvMesh& mesh)
}
}
// Check if all patchProbes have been found.
forAll(nearest, sampleI)
{
label localI = nearest[sampleI].first().index();
label localI = -1;
if (nearest[sampleI].second().second() == Pstream::myProcNo())
{
localI = nearest[sampleI].first().index();
}
if (localI == -1)
{
if (Pstream::master())
{
WarningIn("patchProbes::findElements()")
<< "Did not find location "
<< nearest[sampleI].second().first()
<< " in any cell. Skipping location." << endl;
}
}
else
{
elementList_[sampleI] = localI;
}
}
}