Merge branch 'master' into cvm

This commit is contained in:
graham
2011-03-28 12:06:56 +01:00
461 changed files with 2470073 additions and 1261 deletions

View File

@ -37,6 +37,7 @@ Description
#include "fileStat.H"
#include "timer.H"
#include "IFstream.H"
#include "DynamicList.H"
#include <fstream>
#include <cstdlib>
@ -52,6 +53,7 @@ Description
#include <sys/socket.h>
#include <netdb.h>
#include <dlfcn.h>
#include <link.h>
#include <netinet/in.h>
@ -1107,10 +1109,20 @@ void* Foam::dlOpen(const fileName& lib)
{
if (POSIX::debug)
{
Info<< "dlOpen(const fileName&)"
<< " : dlopen of " << lib << endl;
std::cout<< "dlOpen(const fileName&)"
<< " : dlopen of " << lib << std::endl;
}
return ::dlopen(lib.c_str(), RTLD_LAZY|RTLD_GLOBAL);
void* handle = ::dlopen(lib.c_str(), RTLD_LAZY|RTLD_GLOBAL);
if (POSIX::debug)
{
std::cout
<< "dlOpen(const fileName&)"
<< " : dlopen of " << lib
<< " handle " << handle << std::endl;
}
return handle;
}
@ -1118,8 +1130,9 @@ bool Foam::dlClose(void* handle)
{
if (POSIX::debug)
{
Info<< "dlClose(void*)"
<< " : dlclose" << endl;
std::cout
<< "dlClose(void*)"
<< " : dlclose of handle " << handle << std::endl;
}
return ::dlclose(handle) == 0;
}
@ -1129,8 +1142,9 @@ void* Foam::dlSym(void* handle, const std::string& symbol)
{
if (POSIX::debug)
{
Info<< "dlSym(void*, const std::string&)"
<< " : dlsym of " << symbol << endl;
std::cout
<< "dlSym(void*, const std::string&)"
<< " : dlsym of " << symbol << std::endl;
}
// clear any old errors - see manpage dlopen
(void) ::dlerror();
@ -1158,8 +1172,9 @@ bool Foam::dlSymFound(void* handle, const std::string& symbol)
{
if (POSIX::debug)
{
Info<< "dlSymFound(void*, const std::string&)"
<< " : dlsym of " << symbol << endl;
std::cout
<< "dlSymFound(void*, const std::string&)"
<< " : dlsym of " << symbol << std::endl;
}
// clear any old errors - see manpage dlopen
@ -1178,4 +1193,32 @@ bool Foam::dlSymFound(void* handle, const std::string& symbol)
}
static int collectLibsCallback
(
struct dl_phdr_info *info,
size_t size,
void *data
)
{
Foam::DynamicList<Foam::fileName>* ptr =
reinterpret_cast<Foam::DynamicList<Foam::fileName>*>(data);
ptr->append(info->dlpi_name);
return 0;
}
Foam::fileNameList Foam::dlLoaded()
{
DynamicList<fileName> libs;
dl_iterate_phdr(collectLibsCallback, &libs);
if (POSIX::debug)
{
std::cout
<< "dlLoaded()"
<< " : determined loaded libraries :" << libs.size() << std::endl;
}
return libs;
}
// ************************************************************************* //

View File

@ -136,7 +136,9 @@ bool Foam::functionEntries::codeStream::execute
(
"EXE_INC = -g \\\n"
+ context.options()
+ "\n\nLIB_LIBS ="
+ "\n\nLIB_LIBS = \\\n"
+ " -lOpenFOAM \\\n"
+ context.libs()
);
if (!dynCode.copyOrCreateFiles(true))
@ -172,6 +174,8 @@ bool Foam::functionEntries::codeStream::execute
"functionEntries::codeStream::execute(..)",
parentDict
) << "Failed loading library " << libPath << nl
<< "Did you add all libraries to the 'libs' entry"
<< " in system/controlDict?"
<< exit(FatalIOError);
}

View File

@ -31,8 +31,6 @@ License
#include "OFstream.H"
#include "OSspecific.H"
#include "dictionary.H"
#include "dlLibraryTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -524,7 +522,7 @@ bool Foam::dynamicCode::copyOrCreateFiles(const bool verbose) const
bool Foam::dynamicCode::wmakeLibso() const
{
const Foam::string wmakeCmd("wmake -s libso " + this->codeRelPath());
const Foam::string wmakeCmd("wmake -s libso " + this->codePath());
Info<< "Invoking " << wmakeCmd << endl;
if (Foam::system(wmakeCmd))
@ -557,22 +555,4 @@ bool Foam::dynamicCode::upToDate(const dynamicCodeContext& context) const
}
// bool Foam::dynamicCode::openLibrary() const
// {
// return dlLibraryTable::openLibrary(this->libPath(), false);
// }
//
//
// bool Foam::dynamicCode::closeLibrary() const
// {
// return dlLibraryTable::closeLibrary(this->libPath(), false);
// }
//
//
// void* Foam::dynamicCode::findLibrary() const
// {
// return dlLibraryTable::findLibrary(this->libPath());
// }
// ************************************************************************* //

View File

@ -37,10 +37,8 @@ SourceFiles
#define dynamicCode_H
#include "Tuple2.H"
#include "SHA1Digest.H"
#include "HashTable.H"
#include "DynamicList.H"
#include "dlLibraryTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -51,6 +49,7 @@ namespace Foam
class dynamicCodeContext;
class ISstream;
class OSstream;
class SHA1Digest;
/*---------------------------------------------------------------------------*\
Class dynamicCode Declaration
@ -283,16 +282,6 @@ public:
//- Compile a libso
bool wmakeLibso() const;
// //- Open the libPath() library
// bool openLibrary() const;
//
// //- Close the libPath() library
// bool closeLibrary() const;
//
// //- Find the handle of the libPath() library
// void* findLibrary() const;
};

View File

@ -34,44 +34,78 @@ License
Foam::dynamicCodeContext::dynamicCodeContext(const dictionary& dict)
:
dict_(dict),
code_(stringOps::trim(dict["code"])),
code_(),
localCode_(),
include_(),
options_()
options_(),
libs_()
{
// expand dictionary entries
stringOps::inplaceExpand(code_, dict);
{
const entry& codeEntry = dict.lookupEntry("code", false, false);
code_ = stringOps::trim(codeEntry.stream());
stringOps::inplaceExpand(code_, dict);
addLineDirective(code_, codeEntry.startLineNumber(), dict.name());
}
// note: removes any leading/trailing whitespace
// - necessary for compilation options, convenient for includes
// and body.
// optional
if (dict.found("localCode"))
const entry* includePtr = dict.lookupEntryPtr
(
"codeInclude",
false,
false
);
if (includePtr)
{
localCode_ = stringOps::trim(dict["localCode"]);
stringOps::inplaceExpand(localCode_, dict);
}
// optional
if (dict.found("codeInclude"))
{
include_ = stringOps::trim(dict["codeInclude"]);
include_ = stringOps::trim(includePtr->stream());
stringOps::inplaceExpand(include_, dict);
addLineDirective(include_, includePtr->startLineNumber(), dict.name());
}
// optional
if (dict.found("codeOptions"))
const entry* optionsPtr = dict.lookupEntryPtr
(
"codeOptions",
false,
false
);
if (optionsPtr)
{
options_ = stringOps::trim(dict["codeOptions"]);
options_ = stringOps::trim(optionsPtr->stream());
stringOps::inplaceExpand(options_, dict);
}
// optional
const entry* libsPtr = dict.lookupEntryPtr("codeLibs", false, false);
if (libsPtr)
{
libs_ = stringOps::trim(libsPtr->stream());
stringOps::inplaceExpand(libs_, dict);
}
// calculate SHA1 digest from include, options, localCode, code
OSHA1stream os;
os << include_ << options_ << localCode_ << code_;
os << include_ << options_ << libs_ << localCode_ << code_;
sha1_ = os.digest();
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::dynamicCodeContext::addLineDirective
(
string& code,
const label lineNum,
const fileName& name
)
{
code = "#line " + Foam::name(lineNum) + " \"" + name + "\"\n" + code;
}
// ************************************************************************* //

View File

@ -51,6 +51,7 @@ namespace Foam
class dynamicCodeContext
{
// Private data
//- The parent dictionary context
const dictionary& dict_;
@ -66,6 +67,9 @@ class dynamicCodeContext
//- Optional "codeOptions" entry
string options_;
//- Optional "codeLib" entry
string libs_;
//- Calculated SHA1Digest
SHA1Digest sha1_;
@ -96,6 +100,12 @@ public:
return options_;
}
//- Return the code-libs
const string& libs() const
{
return libs_;
}
//- Return the code
const string& code() const
{
@ -114,6 +124,13 @@ public:
return sha1_;
}
//- Helper: add #line directive
static void addLineDirective
(
string&,
const label lineNum,
const fileName& name
);
};

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
@ -39,6 +39,7 @@ void Foam::OutputFilterFunctionObject<OutputFilter>::readDict()
dict_.readIfPresent("storeFilter", storeFilter_);
}
template<class OutputFilter>
void Foam::OutputFilterFunctionObject<OutputFilter>::allocateFilter()
{
@ -68,12 +69,14 @@ void Foam::OutputFilterFunctionObject<OutputFilter>::allocateFilter()
}
}
template<class OutputFilter>
void Foam::OutputFilterFunctionObject<OutputFilter>::destroyFilter()
{
ptr_.reset();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class OutputFilter>

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
@ -51,7 +51,7 @@ void Foam::DimensionedField<Type, GeoMesh>::readIfPresent
{
if
(
(this->headerOk() && this->readOpt() == IOobject::READ_IF_PRESENT)
(this->readOpt() == IOobject::READ_IF_PRESENT && this->headerOk())
|| this->readOpt() == IOobject::MUST_READ
|| this->readOpt() == IOobject::MUST_READ_IF_MODIFIED
)

View File

@ -196,6 +196,9 @@ void* dlSym(void* handle, const std::string& symbol);
//- Report if symbol in a dlopened library could be found
bool dlSymFound(void* handle, const std::string& symbol);
//- Return all loaded libraries
fileNameList dlLoaded();
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -31,6 +31,45 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//! \cond fileScope
// Find the type/position of the ":-" or ":+" alternative values
//
static inline int findParameterAlternative
(
const std::string& s,
std::string::size_type& pos,
std::string::size_type endPos
)
{
while (pos != std::string::npos)
{
pos = s.find(':', pos);
if (pos != std::string::npos)
{
if (pos < endPos)
{
// in-range: check for '+' or '-' following the ':'
const int altType = s[pos+1];
if (altType == '+' || altType == '-')
{
return altType;
}
++pos; // unknown/unsupported - continue at next position
}
else
{
// out-of-range: abort
pos = std::string::npos;
}
}
}
return 0;
}
//! \endcond
Foam::string Foam::stringOps::expand
(
const string& original,
@ -66,7 +105,8 @@ Foam::string& Foam::stringOps::inplaceExpand
string::size_type endVar = begVar;
string::size_type delim = 0;
// The position of the ":-" default value
// The type/position of the ":-" or ":+" alternative values
int altType = 0;
string::size_type altPos = string::npos;
if (s[begVar+1] == '{')
@ -74,14 +114,11 @@ Foam::string& Foam::stringOps::inplaceExpand
endVar = s.find('}', begVar);
delim = 1;
// looks like ${parameter:-word}
// check for ${parameter:-word} or ${parameter:+word}
if (endVar != string::npos)
{
altPos = s.find(":-", begVar);
if (altPos != string::npos && altPos > endVar)
{
altPos = string::npos;
}
altPos = begVar;
altType = findParameterAlternative(s, altPos, endVar);
}
}
else
@ -134,7 +171,7 @@ Foam::string& Foam::stringOps::inplaceExpand
std::string altValue;
if (altPos != string::npos)
{
// had ":-" default value
// had ":-" or ":+" alternative value
altValue = s.substr
(
altPos + 2,
@ -148,17 +185,32 @@ Foam::string& Foam::stringOps::inplaceExpand
if (fnd != HashTable<string, word, string::hash>::end())
{
s.std::string::replace
(
begVar,
endVar - begVar + 1,
*fnd
);
begVar += (*fnd).size();
if (altPos != string::npos && altType == '+')
{
// was found, use ":+" alternative
s.std::string::replace
(
begVar,
endVar - begVar + 1,
altValue
);
begVar += altValue.size();
}
else
{
// was found, use value
s.std::string::replace
(
begVar,
endVar - begVar + 1,
*fnd
);
begVar += (*fnd).size();
}
}
else if (altPos != string::npos)
else if (altPos != string::npos && altType == '-')
{
// use alternative provided
// was not found, use ":-" alternative
s.std::string::replace
(
begVar,
@ -169,12 +221,8 @@ Foam::string& Foam::stringOps::inplaceExpand
}
else
{
s.std::string::replace
(
begVar,
endVar - begVar + 1,
""
);
// substitute with nothing, also for ":+" alternative
s.std::string::erase(begVar, endVar - begVar + 1);
}
}
}
@ -351,7 +399,8 @@ Foam::string& Foam::stringOps::inplaceExpand
string::size_type endVar = begVar;
string::size_type delim = 0;
// The position of the ":-" default value
// The type/position of the ":-" or ":+" alternative values
int altType = 0;
string::size_type altPos = string::npos;
if (s[begVar+1] == '{')
@ -359,14 +408,11 @@ Foam::string& Foam::stringOps::inplaceExpand
endVar = s.find('}', begVar);
delim = 1;
// looks like ${parameter:-word}
// check for ${parameter:-word} or ${parameter:+word}
if (endVar != string::npos)
{
altPos = s.find(":-", begVar);
if (altPos != string::npos && altPos > endVar)
{
altPos = string::npos;
}
altPos = begVar;
altType = findParameterAlternative(s, altPos, endVar);
}
}
else
@ -413,7 +459,7 @@ Foam::string& Foam::stringOps::inplaceExpand
std::string altValue;
if (altPos != string::npos)
{
// had ":-" default value
// had ":-" or ":+" alternative value
altValue = s.substr
(
altPos + 2,
@ -424,34 +470,53 @@ Foam::string& Foam::stringOps::inplaceExpand
const string varValue = getEnv(varName);
if (varValue.size())
{
// direct replacement
s.std::string::replace
(
begVar,
endVar - begVar + 1,
varValue
);
begVar += varValue.size();
if (altPos != string::npos && altType == '+')
{
// was found, use ":+" alternative
s.std::string::replace
(
begVar,
endVar - begVar + 1,
altValue
);
begVar += altValue.size();
}
else
{
// was found, use value
s.std::string::replace
(
begVar,
endVar - begVar + 1,
varValue
);
begVar += varValue.size();
}
}
else if (altPos != string::npos)
{
// use alternative provided
s.std::string::replace
(
begVar,
endVar - begVar + 1,
altValue
);
begVar += altValue.size();
// use ":-" or ":+" alternative values
if (altType == '-')
{
// was not found, use ":-" alternative
s.std::string::replace
(
begVar,
endVar - begVar + 1,
altValue
);
begVar += altValue.size();
}
else
{
// was not found, ":+" alternative implies
// substitute with nothing
s.std::string::erase(begVar, endVar - begVar + 1);
}
}
else if (allowEmpty)
{
s.std::string::replace
(
begVar,
endVar - begVar + 1,
""
);
s.std::string::erase(begVar, endVar - begVar + 1);
}
else
{
@ -459,7 +524,7 @@ Foam::string& Foam::stringOps::inplaceExpand
(
"stringOps::inplaceExpand(string&, const bool)"
)
<< "Unknown variable name " << varName << '.'
<< "Unknown variable name '" << varName << "'"
<< exit(FatalError);
}
}

View File

@ -62,6 +62,13 @@ namespace stringOps
// If parameter is unset or null, the \c defValue is substituted.
// Otherwise, the value of parameter is substituted.
//
// Supports alternative values as per the Bourne/Korn shell.
// \code
// "${parameter:+altValue}"
// \endcode
// If parameter is unset or null, nothing is substituted.
// Otherwise the \c altValue is substituted.
//
// Any unknown entries are removed silently.
//
// Malformed entries (eg, brace mismatch, sigil followed by bad character)
@ -89,6 +96,13 @@ namespace stringOps
// If parameter is unset or null, the \c defValue is substituted.
// Otherwise, the value of parameter is substituted.
//
// Supports alternative values as per the Bourne/Korn shell.
// \code
// "${parameter:+altValue}"
// \endcode
// If parameter is unset or null, nothing is substituted.
// Otherwise the \c altValue is substituted.
//
// Any unknown entries are removed silently.
//
// Malformed entries (eg, brace mismatch, sigil followed by bad character)
@ -155,6 +169,13 @@ namespace stringOps
// If parameter is unset or null, the \c defValue is substituted.
// Otherwise, the value of parameter is substituted.
//
// Supports alternative values as per the Bourne/Korn shell.
// \code
// "${parameter:+altValue}"
// \endcode
// If parameter is unset or null, nothing is substituted.
// Otherwise the \c altValue is substituted.
//
// Any unknown entries are removed silently, if allowEmpty is true.
//
// Malformed entries (eg, brace mismatch, sigil followed by bad character)
@ -187,6 +208,13 @@ namespace stringOps
// If parameter is unset or null, the \c defValue is substituted.
// Otherwise, the value of parameter is substituted.
//
// Supports alternative values as per the Bourne/Korn shell.
// \code
// "${parameter:+altValue}"
// \endcode
// If parameter is unset or null, nothing is substituted.
// Otherwise the \c altValue is substituted.
//
// Any unknown entries are removed silently, if allowEmpty is true.
//
// Malformed entries (eg, brace mismatch, sigil followed by bad character)

View File

@ -0,0 +1,128 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::pimpleLoop
Description
PIMPLE loop class to formalise the iteration and automate the handling
of the "finalIteration" mesh data entry.
\*---------------------------------------------------------------------------*/
#ifndef pimpleLoop_H
#define pimpleLoop_H
#include "fvMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class pimpleLoop Declaration
\*---------------------------------------------------------------------------*/
class pimpleLoop
{
// Private data
//- Reference to the mesh
fvMesh& mesh_;
//- Number of PIMPLE correctors
const int nCorr_;
//- Current PIMPLE corrector
int corr_;
// Private Member Functions
//- Disallow default bitwise copy construct
pimpleLoop(const pimpleLoop&);
//- Disallow default bitwise assignment
void operator=(const pimpleLoop&);
public:
// Constructors
//- Construct from components
pimpleLoop(fvMesh& mesh, const int nCorr)
:
mesh_(mesh),
nCorr_(nCorr),
corr_(0)
{}
//- Destructor
~pimpleLoop()
{}
// Member Functions
bool loop()
{
if (finalIter())
{
mesh_.data::add("finalIteration", true);
}
return corr_ < nCorr_;
}
bool finalIter() const
{
return corr_ == nCorr_-1;
}
// Member Operators
void operator++(int)
{
if (finalIter())
{
mesh_.data::remove("finalIteration");
}
corr_++;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -37,6 +37,9 @@ License
#include "stringOps.H"
#include "IOdictionary.H"
#include <dlfcn.h>
#include <link.h>
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<class Type>
@ -238,10 +241,6 @@ void Foam::codedFixedValueFvPatchField<Type>::createLibrary
// Write files for new library
if (!dynCode.upToDate(context))
{
Info<< "Using dynamicCode for patch " << this->patch().name()
<< " on field " << this->dimensionedInternalField().name()
<< endl;
// filter with this context
dynCode.reset(context);
@ -268,9 +267,12 @@ void Foam::codedFixedValueFvPatchField<Type>::createLibrary
dynCode.setMakeOptions
(
"EXE_INC = -g \\\n"
"-I$(LIB_SRC)/finiteVolume/lnInclude\\\n"
"-I$(LIB_SRC)/finiteVolume/lnInclude \\\n"
+ context.options()
+ "\n\nLIB_LIBS = "
+ "\n\nLIB_LIBS = \\\n"
+ " -lOpenFOAM \\\n"
+ " -lfiniteVolume \\\n"
+ context.libs()
);
if (!dynCode.copyOrCreateFiles(true))
@ -337,6 +339,12 @@ void Foam::codedFixedValueFvPatchField<Type>::updateLibrary() const
return;
}
Info<< "Using dynamicCode for patch " << this->patch().name()
<< " on field " << this->dimensionedInternalField().name() << nl
<< "at line " << codeDict.startLineNumber()
<< " in " << codeDict.name() << endl;
// remove instantiation of fvPatchField provided by library
redirectPatchFieldPtr_.clear();

View File

@ -80,6 +80,9 @@ SourceFiles
#include "fixedValueFvPatchFields.H"
#include <dlfcn.h>
#include <link.h>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
@ -119,6 +122,13 @@ class codedFixedValueFvPatchField
//- Global loader/unloader function type
typedef void (*loaderFunctionType)(bool);
static int collectLibsCallback
(
struct dl_phdr_info *info,
size_t size,
void *data
);
//- Load specified library and execute globalFuncName(true)
static void* loadLibrary
(

View File

@ -29,8 +29,8 @@ License
#include "triSurface.H"
#include "vector2D.H"
#include "OFstream.H"
#include "long.H"
#include "AverageIOField.H"
#include "Random.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -50,6 +50,7 @@ timeVaryingMappedFixedValueFvPatchField
fixedValueFvPatchField<Type>(p, iF),
fieldTableName_(iF.name()),
setAverage_(false),
perturb_(0),
referenceCS_(NULL),
nearestVertex_(0),
nearestVertexWeight_(0),
@ -76,6 +77,7 @@ timeVaryingMappedFixedValueFvPatchField
fixedValueFvPatchField<Type>(ptf, p, iF, mapper),
fieldTableName_(ptf.fieldTableName_),
setAverage_(ptf.setAverage_),
perturb_(ptf.perturb_),
referenceCS_(NULL),
nearestVertex_(0),
nearestVertexWeight_(0),
@ -101,6 +103,7 @@ timeVaryingMappedFixedValueFvPatchField
fixedValueFvPatchField<Type>(p, iF),
fieldTableName_(iF.name()),
setAverage_(readBool(dict.lookup("setAverage"))),
perturb_(dict.lookupOrDefault("perturb", 1E-5)),
referenceCS_(NULL),
nearestVertex_(0),
nearestVertexWeight_(0),
@ -135,6 +138,7 @@ timeVaryingMappedFixedValueFvPatchField
fixedValueFvPatchField<Type>(ptf),
fieldTableName_(ptf.fieldTableName_),
setAverage_(ptf.setAverage_),
perturb_(ptf.perturb_),
referenceCS_(ptf.referenceCS_),
nearestVertex_(ptf.nearestVertex_),
nearestVertexWeight_(ptf.nearestVertexWeight_),
@ -160,6 +164,7 @@ timeVaryingMappedFixedValueFvPatchField
fixedValueFvPatchField<Type>(ptf, iF),
fieldTableName_(ptf.fieldTableName_),
setAverage_(ptf.setAverage_),
perturb_(ptf.perturb_),
referenceCS_(ptf.referenceCS_),
nearestVertex_(ptf.nearestVertex_),
nearestVertexWeight_(ptf.nearestVertexWeight_),
@ -332,7 +337,27 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::readSamplePoints()
(
referenceCS().localPosition(samplePoints)
);
const vectorField& localVertices = tlocalVertices();
vectorField& localVertices = tlocalVertices();
const boundBox bb(localVertices, true);
const point bbMid(bb.midpoint());
if (debug)
{
Info<< "timeVaryingMappedFixedValueFvPatchField :"
<< " Perturbing points with " << perturb_
<< " fraction of a random position inside " << bb
<< " to break any ties on regular meshes."
<< nl << endl;
}
Random rndGen(123456);
forAll(localVertices, i)
{
localVertices[i] +=
perturb_
*(rndGen.position(bb.min(), bb.max())-bbMid);
}
// Determine triangulation
List<vector2D> localVertices2D(localVertices.size());
@ -342,33 +367,16 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::readSamplePoints()
localVertices2D[i][1] = localVertices[i][1];
}
tmp<pointField> localFaceCentres
triSurface s(triSurfaceTools::delaunay2D(localVertices2D));
tmp<pointField> tlocalFaceCentres
(
referenceCS().localPosition
(
this->patch().patch().faceCentres()
)
);
if (debug)
{
OFstream str
(
this->db().time().path()/this->patch().name()
+ "_localFaceCentres.obj"
);
Pout<< "readSamplePoints :"
<< " Dumping face centres to " << str.name() << endl;
forAll(localFaceCentres(), i)
{
const point& p = localFaceCentres()[i];
str<< "v " << p.x() << ' ' << p.y() << ' ' << p.z() << nl;
}
}
triSurface s(triSurfaceTools::delaunay2D(localVertices2D));
const pointField& localFaceCentres = tlocalFaceCentres();
if (debug)
{
@ -380,9 +388,9 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::readSamplePoints()
Pout<< "readSamplePoints :"
<< " Dumping face centres to " << str.name() << endl;
forAll(localFaceCentres(), i)
forAll(localFaceCentres, i)
{
const point& p = localFaceCentres()[i];
const point& p = localFaceCentres[i];
str<< "v " << p.x() << ' ' << p.y() << ' ' << p.z() << nl;
}
}
@ -760,6 +768,7 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::write(Ostream& os) const
{
fvPatchField<Type>::write(os);
os.writeKeyword("setAverage") << setAverage_ << token::END_STATEMENT << nl;
os.writeKeyword("peturb") << perturb_ << token::END_STATEMENT << nl;
if (fieldTableName_ != this->dimensionedInternalField().name())
{

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
@ -27,6 +27,36 @@ Class
Description
Foam::timeVaryingMappedFixedValueFvPatchField
Interpolates from a set of supplied points in space and time. Supplied
data in constant/boundaryData/<patchname>:
- points : pointField with locations
- ddd : supplied values at time ddd
Points need to be more or less on a plane since get triangulated in 2D.
At startup this bc does the triangulation and determines linear
interpolation (triangle it is in and weights to the 3 vertices)
for every face centre. Interpolates linearly inbetween times.
@verbatim
inlet
{
type timeVaryingMappedFixedValue;
// Maintain average to that of the supplied values
setAverage false;
// Optional: change perturbation (default 1E-5) to avoid any ties
// in triangulating regular geometries.
//perturb 0.0;
// Optional: use name instead of patchname for location of data
//fieldTableName samples;
}
@endverbatim
Switch on debug flag to have it dump the triangulation (in transformed
space) and transform face centres.
SourceFiles
timeVaryingMappedFixedValueFvPatchField.C
@ -62,6 +92,9 @@ class timeVaryingMappedFixedValueFvPatchField
//- If true adjust the mapped field to maintain average value
bool setAverage_;
//- Fraction of perturbation (fraction of bounding box) to add
scalar perturb_;
//- Coordinate system
autoPtr<coordinateSystem> referenceCS_;

View File

@ -50,27 +50,23 @@ License
namespace Foam
{
typedef coalCloud::cloudType coalCloud_R;
typedef coalCloud_R::cloudType coalCloud_T;
typedef coalCloud_T::cloudType coalCloud_K;
// Kinematic sub-models
makeThermoParcelForces(coalCloud_K);
makeParcelDispersionModels(coalCloud_K);
makeReactingMultiphaseParcelInjectionModels(coalCloud_K);
makeParcelPatchInteractionModels(coalCloud_K);
makeParcelPostProcessingModels(coalCloud_K);
makeThermoParcelForces(coalCloud);
makeParcelDispersionModels(coalCloud);
makeReactingMultiphaseParcelInjectionModels(coalCloud);
makeParcelPatchInteractionModels(coalCloud);
makeParcelPostProcessingModels(coalCloud);
// Thermo sub-models
makeParcelHeatTransferModels(coalCloud_T);
makeParcelHeatTransferModels(coalCloud);
// Reacting sub-models
makeReactingMultiphaseParcelCompositionModels(coalCloud_R);
makeReactingParcelPhaseChangeModels(coalCloud_R);
makeReactingMultiphaseParcelCompositionModels(coalCloud);
makeReactingParcelPhaseChangeModels(coalCloud);
// Reacting multiphase sub-models
makeReactingMultiphaseParcelDevolatilisationModels(coalCloud);
makeReactingParcelSurfaceFilmModels(coalCloud_K);
makeReactingParcelSurfaceFilmModels(coalCloud);
makeCoalParcelSurfaceReactionModels(coalCloud);
}

View File

@ -157,12 +157,15 @@ Foam::scalar Foam::COxidationDiffusionLimitedRate<CloudType>::calculate
dMassSRCarrier[O2GlobalId_] -= dmO2;
dMassSRCarrier[CO2GlobalId_] += dmCO2;
const scalar HC = thermo.solids().properties()[CsLocalId_].H(T);
const scalar HsC = thermo.solids().properties()[CsLocalId_].Hs(T);
const scalar HCO2 = thermo.carrier().H(CO2GlobalId_, T);
const scalar HO2 = thermo.carrier().H(O2GlobalId_, T);
// carrier enthalpy transfer handled by change in composition
// const scalar HsO2 = thermo.carrier().Hs(O2GlobalId_, T);
// dhsTrans -= dmO2*HsO2;
// Heat of reaction [J]
return dmC*HC + dmO2*HO2 - dmCO2*HCO2;
return dmC*HsC - dmCO2*HCO2;
}

View File

@ -160,12 +160,15 @@ Foam::scalar Foam::COxidationKineticDiffusionLimitedRate<CloudType>::calculate
dMassSRCarrier[O2GlobalId_] -= dmO2;
dMassSRCarrier[CO2GlobalId_] += dmCO2;
const scalar HC = thermo.solids().properties()[CsLocalId_].H(T);
const scalar HsC = thermo.solids().properties()[CsLocalId_].Hs(T);
const scalar HCO2 = thermo.carrier().H(CO2GlobalId_, T);
const scalar HO2 = thermo.carrier().H(O2GlobalId_, T);
// carrier enthalpy transfer handled by change in composition
// const scalar HsO2 = thermo.carrier().Hs(O2GlobalId_, T);
// dhsTrans -= dmO2*HsO2;
// Heat of reaction [J]
return dmC*HC + dmO2*HO2 - dmCO2*HCO2;
return dmC*HsC - dmCO2*HCO2;
}

View File

@ -220,12 +220,15 @@ Foam::scalar Foam::COxidationMurphyShaddix<CloudType>::calculate
// Add to particle mass transfer
dMassSolid[CsLocalId_] += dOmega*WC_;
const scalar HC = thermo.solids().properties()[CsLocalId_].H(T);
const scalar HsC = thermo.solids().properties()[CsLocalId_].Hs(T);
const scalar HCO2 = thermo.carrier().H(CO2GlobalId_, T);
const scalar HO2 = thermo.carrier().H(O2GlobalId_, T);
// carrier enthalpy transfer handled by change in composition
// const scalar HsO2 = thermo.carrier().Hs(O2GlobalId_, T);
// dhsTrans -= dmO2*HsO2;
// Heat of reaction
return dOmega*(WC_*HC + WO2_*HO2 - (WC_ + WO2_)*HCO2);
return dOmega*(WC_*HsC - (WC_ + WO2_)*HCO2);
}

View File

@ -165,6 +165,11 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::calc
const label cellI
)
{
typedef typename TrackData::cloudType::reactingCloudType reactingCloudType;
const CompositionModel<reactingCloudType>& composition =
td.cloud().composition();
// Define local properties at beginning of timestep
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const scalar np0 = this->nParticle_;
@ -178,9 +183,9 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::calc
const scalar pc = this->pc_;
const scalarField& YMix = this->Y_;
const label idG = td.cloud().composition().idGas();
const label idL = td.cloud().composition().idLiquid();
const label idS = td.cloud().composition().idSolid();
const label idG = composition.idGas();
const label idL = composition.idLiquid();
const label idS = composition.idSolid();
// Calc surface values
@ -221,7 +226,7 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::calc
scalar NCpW = 0.0;
// Surface concentrations of emitted species
scalarField Cs(td.cloud().composition().carrier().species().size(), 0.0);
scalarField Cs(composition.carrier().species().size(), 0.0);
// Calc mass and enthalpy transfer due to phase change
this->calcPhaseChange
@ -271,10 +276,6 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::calc
Cs
);
// Correct surface values due to emitted species
this->correctSurfaceValues(td, cellI, Ts, Cs, rhos, mus, Prs, kappas);
Res = this->Re(U0, d0, rhos, mus);
// Surface reactions
// ~~~~~~~~~~~~~~~~~
@ -283,13 +284,9 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::calc
scalarField dMassSRGas(YGas_.size(), 0.0);
scalarField dMassSRLiquid(YLiquid_.size(), 0.0);
scalarField dMassSRSolid(YSolid_.size(), 0.0);
scalarField dMassSRCarrier
(
td.cloud().composition().carrier().species().size(),
0.0
);
scalarField dMassSRCarrier(composition.carrier().species().size(), 0.0);
// Clac mass and enthalpy transfer due to surface reactions
// Calc mass and enthalpy transfer due to surface reactions
calcSurfaceReactions
(
td,
@ -313,6 +310,11 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::calc
);
// Correct surface values due to emitted species
this->correctSurfaceValues(td, cellI, Ts, Cs, rhos, mus, Prs, kappas);
Res = this->Re(U0, d0, rhos, mus);
// Update component mass fractions
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -324,11 +326,13 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::calc
updateMassFractions(mass0, dMassGas, dMassLiquid, dMassSolid);
// Heat transfer
// ~~~~~~~~~~~~~
// Calculate new particle temperature
scalar Cuh = 0.0;
scalar Sph = 0.0;
scalar T1 =
this->calcHeatTransfer
(
@ -345,7 +349,7 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::calc
NCpW,
Sh,
dhsTrans,
Cuh
Sph
);
@ -380,25 +384,33 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::calc
// Transfer mass lost from particle to carrier mass source
forAll(YGas_, i)
{
label gid = td.cloud().composition().localToGlobalCarrierId(GAS, i);
label gid = composition.localToGlobalCarrierId(GAS, i);
td.cloud().rhoTrans(gid)[cellI] += np0*dMassGas[i];
// td.cloud().hsTrans()[cellI] +=
// np0*dMassGas[i]*composition.carrier().Hs(gid, T0);
}
forAll(YLiquid_, i)
{
label gid = td.cloud().composition().localToGlobalCarrierId(LIQ, i);
label gid = composition.localToGlobalCarrierId(LIQ, i);
td.cloud().rhoTrans(gid)[cellI] += np0*dMassLiquid[i];
// td.cloud().hsTrans()[cellI] +=
// np0*dMassLiquid[i]*composition.carrier().Hs(gid, T0);
}
/*
// No mapping between solid components and carrier phase
forAll(YSolid_, i)
{
label gid = td.cloud().composition().localToGlobalCarrierId(SLD, i);
label gid = composition.localToGlobalCarrierId(SLD, i);
td.cloud().rhoTrans(gid)[cellI] += np0*dMassSolid[i];
// td.cloud().hsTrans()[cellI] +=
// np0*dMassSolid[i]*composition.carrier().Hs(gid, T0);
}
*/
forAll(dMassSRCarrier, i)
{
td.cloud().rhoTrans(i)[cellI] += np0*dMassSRCarrier[i];
// td.cloud().hsTrans()[cellI] +=
// np0*dMassSRCarrier[i]*composition.carrier().Hs(i, T0);
}
// Update momentum transfer
@ -411,7 +423,7 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::calc
td.cloud().hsTrans()[cellI] += np0*dhsTrans;
// Update sensible enthalpy coefficient
td.cloud().hsCoeff()[cellI] += np0*Cuh*this->areaS();
td.cloud().hsCoeff()[cellI] += np0*Sph;
}
@ -427,14 +439,12 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::calc
// Absorb parcel into carrier phase
forAll(YGas_, i)
{
label gid =
td.cloud().composition().localToGlobalCarrierId(GAS, i);
label gid = composition.localToGlobalCarrierId(GAS, i);
td.cloud().rhoTrans(gid)[cellI] += np0*mass1*YMix[GAS]*YGas_[i];
}
forAll(YLiquid_, i)
{
label gid =
td.cloud().composition().localToGlobalCarrierId(LIQ, i);
label gid = composition.localToGlobalCarrierId(LIQ, i);
td.cloud().rhoTrans(gid)[cellI] +=
np0*mass1*YMix[LIQ]*YLiquid_[i];
}
@ -442,8 +452,7 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::calc
// No mapping between solid components and carrier phase
forAll(YSolid_, i)
{
label gid =
td.cloud().composition().localToGlobalCarrierId(SLD, i);
label gid = composition.localToGlobalCarrierId(SLD, i);
td.cloud().rhoTrans(gid)[cellI] +=
np0*mass1*YMix[SLD]*YSolid_[i];
}
@ -508,6 +517,11 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::calcDevolatilisation
return;
}
typedef typename TrackData::cloudType::reactingCloudType reactingCloudType;
const CompositionModel<reactingCloudType>& composition =
td.cloud().composition();
// Total mass of volatiles evolved
td.cloud().devolatilisation().calculate
(
@ -535,10 +549,9 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::calcDevolatilisation
// Note: hardcoded gaseous diffusivities for now
// TODO: add to carrier thermo
const scalar beta = sqr(cbrt(15.0) + cbrt(15.0));
const label id =
td.cloud().composition().localToGlobalCarrierId(GAS, i);
const scalar Cp = td.cloud().composition().carrier().Cp(id, Ts);
const scalar W = td.cloud().composition().carrier().W(id);
const label id = composition.localToGlobalCarrierId(GAS, i);
const scalar Cp = composition.carrier().Cp(id, Ts);
const scalar W = composition.carrier().W(id);
const scalar Ni = dMassDV[i]/(this->areaS(d)*dt*W);
// Dab calc'd using API vapour mass diffusivity function

View File

@ -252,6 +252,11 @@ void Foam::ReactingParcel<ParcelType>::calc
const label cellI
)
{
typedef typename TrackData::cloudType::reactingCloudType reactingCloudType;
const CompositionModel<reactingCloudType>& composition =
td.cloud().composition();
// Define local properties at beginning of time step
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const scalar np0 = this->nParticle_;
@ -301,7 +306,7 @@ void Foam::ReactingParcel<ParcelType>::calc
scalar NCpW = 0.0;
// Surface concentrations of emitted species
scalarField Cs(td.cloud().composition().carrier().species().size(), 0.0);
scalarField Cs(composition.carrier().species().size(), 0.0);
// Calc mass and enthalpy transfer due to phase change
calcPhaseChange
@ -337,7 +342,7 @@ void Foam::ReactingParcel<ParcelType>::calc
// ~~~~~~~~~~~~~
// Calculate new particle temperature
scalar Cuh = 0.0;
scalar Sph = 0.0;
scalar T1 =
this->calcHeatTransfer
(
@ -354,7 +359,7 @@ void Foam::ReactingParcel<ParcelType>::calc
NCpW,
Sh,
dhsTrans,
Cuh
Sph
);
@ -389,8 +394,10 @@ void Foam::ReactingParcel<ParcelType>::calc
// Transfer mass lost from particle to carrier mass source
forAll(dMassPC, i)
{
label gid = td.cloud().composition().localToGlobalCarrierId(0, i);
label gid = composition.localToGlobalCarrierId(0, i);
td.cloud().rhoTrans(gid)[cellI] += np0*dMassPC[i];
// td.cloud().hsTrans()[cellI] +=
// np0*dMassPC[i]*composition.carrier().Hs(gid, T0);
}
// Update momentum transfer
@ -403,7 +410,7 @@ void Foam::ReactingParcel<ParcelType>::calc
td.cloud().hsTrans()[cellI] += np0*dhsTrans;
// Update sensible enthalpy coefficient
td.cloud().hsCoeff()[cellI] += np0*Cuh*this->areaS();
td.cloud().hsCoeff()[cellI] += np0*Sph;
}
@ -418,13 +425,12 @@ void Foam::ReactingParcel<ParcelType>::calc
// Absorb parcel into carrier phase
forAll(Y_, i)
{
label gid =
td.cloud().composition().localToGlobalCarrierId(0, i);
label gid = composition.localToGlobalCarrierId(0, i);
td.cloud().rhoTrans(gid)[cellI] += np0*mass1*Y_[i];
}
td.cloud().UTrans()[cellI] += np0*mass1*U1;
td.cloud().hsTrans()[cellI] +=
np0*mass1*td.cloud().composition().H(0, Y_, pc_, T1);
np0*mass1*composition.H(0, Y_, pc_, T1);
}
}
@ -434,7 +440,7 @@ void Foam::ReactingParcel<ParcelType>::calc
else
{
this->Cp_ = td.cloud().composition().Cp(0, Y_, pc_, T1);
this->Cp_ = composition.Cp(0, Y_, pc_, T1);
this->T_ = T1;
this->U_ = U1;
@ -484,6 +490,11 @@ void Foam::ReactingParcel<ParcelType>::calcPhaseChange
return;
}
typedef typename TrackData::cloudType::reactingCloudType reactingCloudType;
const CompositionModel<reactingCloudType>& composition =
td.cloud().composition();
// Calculate mass transfer due to phase change
td.cloud().phaseChange().calculate
(
@ -511,19 +522,18 @@ void Foam::ReactingParcel<ParcelType>::calcPhaseChange
forAll(YComponents, i)
{
const label idc =
td.cloud().composition().localToGlobalCarrierId(idPhase, i);
const label idl = td.cloud().composition().globalIds(idPhase)[i];
const label idc = composition.localToGlobalCarrierId(idPhase, i);
const label idl = composition.globalIds(idPhase)[i];
const scalar dh = td.cloud().phaseChange().dh(idc, idl, pc_, T);
Sh -= dMassPC[i]*dh/dt;
// Update particle surface thermo properties
const scalar Dab =
td.cloud().composition().liquids().properties()[idl].D(pc_, Ts, Wc);
composition.liquids().properties()[idl].D(pc_, Ts, Wc);
const scalar Cp = td.cloud().composition().carrier().Cp(idc, Ts);
const scalar W = td.cloud().composition().carrier().W(idc);
const scalar Cp = composition.carrier().Cp(idc, Ts);
const scalar W = composition.carrier().W(idc);
const scalar Ni = dMassPC[i]/(this->areaS(d)*dt*W);
// Molar flux of species coming from the particle (kmol/m^2/s)

View File

@ -30,7 +30,7 @@ License
template<class ParcelType>
Foam::string Foam::ReactingParcel<ParcelType>::propHeader =
ThermoParcel<ParcelType>::propHeader
ParcelType::propHeader
+ " mass0"
+ " nPhases(Y1..YN)";

View File

@ -208,8 +208,8 @@ void Foam::ThermoParcel<ParcelType>::calc
// Sum Ni*Cpi*Wi of emission species
scalar NCpW = 0.0;
// Calculate new particle velocity
scalar Cuh = 0.0;
// Calculate new particle temperature
scalar Sph = 0.0;
scalar T1 =
this->calcHeatTransfer
(
@ -226,7 +226,7 @@ void Foam::ThermoParcel<ParcelType>::calc
NCpW,
Sh,
dhsTrans,
Cuh
Sph
);
@ -267,7 +267,7 @@ void Foam::ThermoParcel<ParcelType>::calc
td.cloud().hsTrans()[cellI] += np0*dhsTrans;
// Update sensible enthalpy coefficient
td.cloud().hsCoeff()[cellI] += np0*Cuh*this->areaS();
td.cloud().hsCoeff()[cellI] += np0*Sph;
}
// Set new particle properties
@ -294,7 +294,7 @@ Foam::scalar Foam::ThermoParcel<ParcelType>::calcHeatTransfer
const scalar NCpW,
const scalar Sh,
scalar& dhsTrans,
scalar& Cuh
scalar& Sph
)
{
if (!td.cloud().heatTransfer().active())
@ -317,6 +317,7 @@ Foam::scalar Foam::ThermoParcel<ParcelType>::calcHeatTransfer
htc = max(htc, ROOTVSMALL);
const scalar As = this->areaS(d);
scalar ap = Tc_ + Sh/As/htc;
scalar bp = 6.0*(Sh/As + htc*(Tc_ - T));
if (td.cloud().radiation())
@ -337,9 +338,9 @@ Foam::scalar Foam::ThermoParcel<ParcelType>::calcHeatTransfer
scalar Tnew = max(Tres.value(), td.cloud().constProps().TMin());
dhsTrans += dt*htc*As*(0.5*(T + Tnew) - Tc_);
Sph = dt*htc*As;
Cuh = dt*bp;
dhsTrans += Sph*(0.5*(T + Tnew) - Tc_);
return Tnew;
}

View File

@ -243,7 +243,7 @@ protected:
const scalar NCpW, // Sum of N*Cp*W of emission species
const scalar Sh, // explicit particle enthalpy source
scalar& dhsTrans, // sensible enthalpy transfer to carrier
scalar& Cuh // linearised heat transfer coefficient
scalar& Sph // linearised heat transfer coefficient
);

View File

@ -39,16 +39,13 @@ License
namespace Foam
{
// Kinematic sub-models
typedef basicKinematicCollidingCloud::cloudType
basicKinematicCollidingCloud_K;
makeParcelForces(basicKinematicCollidingCloud_K);
makeParcelDispersionModels(basicKinematicCollidingCloud_K);
makeParcelInjectionModels(basicKinematicCollidingCloud_K);
makeParcelForces(basicKinematicCollidingCloud);
makeParcelDispersionModels(basicKinematicCollidingCloud);
makeParcelInjectionModels(basicKinematicCollidingCloud);
makeParcelCollisionModels(basicKinematicCollidingCloud);
makeParcelPatchInteractionModels(basicKinematicCollidingCloud_K);
makeParcelPostProcessingModels(basicKinematicCollidingCloud_K);
makeParcelSurfaceFilmModels(basicKinematicCollidingCloud_K);
makeParcelPatchInteractionModels(basicKinematicCollidingCloud);
makeParcelPostProcessingModels(basicKinematicCollidingCloud);
makeParcelSurfaceFilmModels(basicKinematicCollidingCloud);
}

View File

@ -48,29 +48,22 @@ License
namespace Foam
{
typedef basicReactingMultiphaseCloud::cloudType
basicReactingMultiphaseCloud_R;
typedef basicReactingMultiphaseCloud_R::cloudType
basicReactingMultiphaseCloud_T;
typedef basicReactingMultiphaseCloud_T::cloudType
basicReactingMultiphaseCloud_K;
// Kinematic sub-models
makeThermoParcelForces(basicReactingMultiphaseCloud_K);
makeParcelDispersionModels(basicReactingMultiphaseCloud_K);
makeReactingMultiphaseParcelInjectionModels(basicReactingMultiphaseCloud_K);
makeParcelPatchInteractionModels(basicReactingMultiphaseCloud_K);
makeParcelPostProcessingModels(basicReactingMultiphaseCloud_K);
makeThermoParcelForces(basicReactingMultiphaseCloud);
makeParcelDispersionModels(basicReactingMultiphaseCloud);
makeReactingMultiphaseParcelInjectionModels(basicReactingMultiphaseCloud);
makeParcelPatchInteractionModels(basicReactingMultiphaseCloud);
makeParcelPostProcessingModels(basicReactingMultiphaseCloud);
// Thermo sub-models
makeParcelHeatTransferModels(basicReactingMultiphaseCloud_T);
makeParcelHeatTransferModels(basicReactingMultiphaseCloud);
// Reacting sub-models
makeReactingMultiphaseParcelCompositionModels
(
basicReactingMultiphaseCloud_R
basicReactingMultiphaseCloud
);
makeReactingParcelPhaseChangeModels(basicReactingMultiphaseCloud_R);
makeReactingParcelPhaseChangeModels(basicReactingMultiphaseCloud);
// Reacting multiphase sub-models
makeReactingMultiphaseParcelDevolatilisationModels
@ -79,7 +72,7 @@ namespace Foam
);
makeReactingParcelSurfaceFilmModels
(
basicReactingMultiphaseCloud_K
basicReactingMultiphaseCloud
);
makeReactingMultiphaseParcelSurfaceReactionModels
(

View File

@ -44,23 +44,23 @@ License
namespace Foam
{
typedef basicReactingCloud::cloudType basicReactingCloud_T;
typedef basicReactingCloud_T::cloudType basicReactingCloud_K;
typedef basicReactingCloud::thermoCloudType thermoCloudType2;
typedef basicReactingCloud::kinematicCloudType kinematicCloudType2;
// Kinematic sub-models
makeThermoParcelForces(basicReactingCloud_K);
makeParcelDispersionModels(basicReactingCloud_K);
makeReactingParcelInjectionModels(basicReactingCloud_K);
makeParcelPatchInteractionModels(basicReactingCloud_K);
makeParcelPostProcessingModels(basicReactingCloud_K);
makeThermoParcelForces(basicReactingCloud);
makeParcelDispersionModels(basicReactingCloud);
makeReactingParcelInjectionModels(basicReactingCloud);
makeParcelPatchInteractionModels(basicReactingCloud);
makeParcelPostProcessingModels(basicReactingCloud);
// Thermo sub-models
makeParcelHeatTransferModels(basicReactingCloud_T);
makeParcelHeatTransferModels(basicReactingCloud);
// Reacting sub-models
makeReactingParcelCompositionModels(basicReactingCloud);
makeReactingParcelPhaseChangeModels(basicReactingCloud);
makeReactingParcelSurfaceFilmModels(basicReactingCloud_K);
makeReactingParcelSurfaceFilmModels(basicReactingCloud);
}

View File

@ -41,18 +41,15 @@ License
namespace Foam
{
// Kinematic sub-models
typedef basicThermoCloud::cloudType basicThermoCloud_K;
// Kinematic sub-models
makeThermoParcelForces(basicThermoCloud_K);
makeParcelDispersionModels(basicThermoCloud_K);
makeParcelInjectionModels(basicThermoCloud_K);
makeParcelPatchInteractionModels(basicThermoCloud_K);
makeParcelPostProcessingModels(basicThermoCloud_K);
makeThermoParcelForces(basicThermoCloud);
makeParcelDispersionModels(basicThermoCloud);
makeParcelInjectionModels(basicThermoCloud);
makeParcelPatchInteractionModels(basicThermoCloud);
makeParcelPostProcessingModels(basicThermoCloud);
// Thermo sub-models
makeParcelHeatTransferModels(basicThermoCloud);
makeParcelSurfaceFilmModels(basicThermoCloud_K);
makeParcelSurfaceFilmModels(basicThermoCloud);
}

View File

@ -38,7 +38,12 @@ License
\
makeDispersionModel(CloudType); \
\
defineNamedTemplateTypeNameAndDebug(DispersionRASModel<CloudType>, 0); \
typedef CloudType::kinematicCloudType kinematicCloudType; \
defineNamedTemplateTypeNameAndDebug \
( \
DispersionRASModel<kinematicCloudType>, \
0 \
); \
\
makeDispersionModelType(NoDispersion, CloudType); \
makeDispersionModelType(GradientDispersionRAS, CloudType); \

View File

@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "ParticleForceList.H"
#include "entry.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -57,26 +58,46 @@ Foam::ParticleForceList<CloudType>::ParticleForceList
{
if (readFields)
{
const wordList activeForces(dict.lookup("activeForces"));
wordHashSet models;
models.insert(activeForces);
wordList modelNames(dict.toc());
Info<< "Constructing particle forces" << endl;
if (models.size() > 0)
if (modelNames.size() > 0)
{
this->setSize(models.size());
this->setSize(modelNames.size());
label i = 0;
forAllConstIter(wordHashSet, models, iter)
forAllConstIter(IDLList<entry>, dict, iter)
{
const word& model = iter.key();
this->set
(
i,
ParticleForce<CloudType>::New(owner, mesh, dict, model)
);
i++;
const word& model = iter().keyword();
if (iter().isDict())
{
this->set
(
i++,
ParticleForce<CloudType>::New
(
owner,
mesh,
iter().dict(),
model
)
);
}
else
{
this->set
(
i++,
ParticleForce<CloudType>::New
(
owner,
mesh,
dict,
model
)
);
}
}
}
else

View File

@ -141,18 +141,27 @@ public:
#define makeCollisionModel(CloudType) \
\
defineNamedTemplateTypeNameAndDebug(CollisionModel<CloudType>, 0); \
\
defineTemplateRunTimeSelectionTable(CollisionModel<CloudType>, dictionary);
typedef CloudType::collidingCloudType collidingCloudType; \
defineNamedTemplateTypeNameAndDebug \
( \
CollisionModel<collidingCloudType>, \
0 \
); \
defineTemplateRunTimeSelectionTable \
( \
CollisionModel<collidingCloudType>, \
dictionary \
);
#define makeCollisionModelType(SS, CloudType) \
\
defineNamedTemplateTypeNameAndDebug(SS<CloudType>, 0); \
typedef CloudType::collidingCloudType collidingCloudType; \
defineNamedTemplateTypeNameAndDebug(SS<collidingCloudType>, 0); \
\
CollisionModel<CloudType>:: \
adddictionaryConstructorToTable<SS<CloudType> > \
add##SS##CloudType##ConstructorToTable_;
CollisionModel<collidingCloudType>:: \
adddictionaryConstructorToTable<SS<collidingCloudType> > \
add##SS##CloudType##collidingCloudType##ConstructorToTable_;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -132,22 +132,23 @@ public:
#define makeDispersionModel(CloudType) \
\
defineTemplateTypeNameAndDebug(DispersionModel<CloudType>, 0); \
\
typedef CloudType::kinematicCloudType kinematicCloudType; \
defineTemplateTypeNameAndDebug(DispersionModel<kinematicCloudType>, 0); \
defineTemplateRunTimeSelectionTable \
( \
DispersionModel<CloudType>, \
DispersionModel<kinematicCloudType>, \
dictionary \
);
#define makeDispersionModelType(SS, CloudType) \
\
defineNamedTemplateTypeNameAndDebug(SS<CloudType>, 0); \
typedef CloudType::kinematicCloudType kinematicCloudType; \
defineNamedTemplateTypeNameAndDebug(SS<kinematicCloudType>, 0); \
\
DispersionModel<CloudType>:: \
adddictionaryConstructorToTable<SS<CloudType> > \
add##SS##CloudType##ConstructorToTable_;
DispersionModel<kinematicCloudType>:: \
adddictionaryConstructorToTable<SS<kinematicCloudType> > \
add##SS##CloudType##kinematicCloudType##ConstructorToTable_;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -328,17 +328,27 @@ public:
#define makeInjectionModel(CloudType) \
\
defineNamedTemplateTypeNameAndDebug(InjectionModel<CloudType>, 0); \
\
defineTemplateRunTimeSelectionTable(InjectionModel<CloudType>, dictionary);
typedef CloudType::kinematicCloudType kinematicCloudType; \
defineNamedTemplateTypeNameAndDebug \
( \
InjectionModel<kinematicCloudType>, \
0 \
); \
defineTemplateRunTimeSelectionTable \
( \
InjectionModel<kinematicCloudType>, \
dictionary \
);
#define makeInjectionModelType(SS, CloudType) \
\
defineNamedTemplateTypeNameAndDebug(SS<CloudType>, 0); \
typedef CloudType::kinematicCloudType kinematicCloudType; \
defineNamedTemplateTypeNameAndDebug(SS<kinematicCloudType>, 0); \
\
InjectionModel<CloudType>::adddictionaryConstructorToTable<SS<CloudType> >\
add##SS##CloudType##ConstructorToTable_;
InjectionModel<kinematicCloudType>:: \
adddictionaryConstructorToTable<SS<kinematicCloudType> > \
add##SS##CloudType##kinematicCloudType##ConstructorToTable_;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -41,11 +41,10 @@ Foam::NonSphereDragForce<CloudType>::NonSphereDragForce
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
)
:
ParticleForce<CloudType>(owner, mesh, dict, forceType),
ParticleForce<CloudType>(owner, mesh, dict, typeName, true),
phi_(readScalar(this->coeffs().lookup("phi"))),
a_(exp(2.3288 - 6.4581*phi_ + 2.4486*sqr(phi_))),
b_(0.0964 + 0.5565*phi_),

View File

@ -114,8 +114,7 @@ public:
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
);
//- Construct copy

View File

@ -48,11 +48,10 @@ Foam::SphereDragForce<CloudType>::SphereDragForce
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
)
:
ParticleForce<CloudType>(owner, mesh, dict)
ParticleForce<CloudType>(owner, mesh, dict, typeName, false)
{}

View File

@ -66,8 +66,7 @@ public:
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
);
//- Construct copy

View File

@ -32,11 +32,10 @@ Foam::GravityForce<CloudType>::GravityForce
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
)
:
ParticleForce<CloudType>(owner, mesh, dict),
ParticleForce<CloudType>(owner, mesh, dict, typeName, false),
g_(owner.g().value())
{}

View File

@ -73,8 +73,7 @@ public:
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
);
//- Construct copy

View File

@ -33,11 +33,10 @@ Foam::NonInertialFrameForce<CloudType>::NonInertialFrameForce
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
)
:
ParticleForce<CloudType>(owner, mesh, dict),
ParticleForce<CloudType>(owner, mesh, dict, typeName, true),
WName_
(
this->coeffs().template lookupOrDefault<word>

View File

@ -94,8 +94,7 @@ public:
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
);
//- Construct copy

View File

@ -34,11 +34,10 @@ Foam::ParamagneticForce<CloudType>::ParamagneticForce
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
)
:
ParticleForce<CloudType>(owner, mesh, dict, forceType),
ParticleForce<CloudType>(owner, mesh, dict, typeName, true),
HdotGradHName_
(
this->coeffs().template lookupOrDefault<word>("HdotGradH", "HdotGradH")

View File

@ -80,8 +80,7 @@ public:
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
);
//- Construct copy

View File

@ -27,20 +27,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class CloudType>
Foam::ParticleForce<CloudType>::ParticleForce
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict
)
:
owner_(owner),
mesh_(mesh),
dict_(dict),
coeffs_(dictionary::null)
{}
template<class CloudType>
Foam::ParticleForce<CloudType>::ParticleForce
@ -48,14 +34,31 @@ Foam::ParticleForce<CloudType>::ParticleForce
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const word& forceType,
const bool readCoeffs
)
:
owner_(owner),
mesh_(mesh),
dict_(dict),
coeffs_(dict.subOrEmptyDict(forceType + "Coeffs"))
{}
coeffs_(readCoeffs ? dict : dictionary::null)
{
if (readCoeffs && (coeffs_.dictName() != forceType))
{
FatalIOErrorIn
(
"Foam::ParticleForce<CloudType>::ParticleForce"
"("
"CloudType&, "
"const fvMesh&, "
"const dictionary&, "
"const word&, "
"const bool"
")",
dict
) << "Force " << forceType << " must be specified as a dictionary"
<< exit(FatalIOError);
}
}
template<class CloudType>
@ -63,7 +66,6 @@ Foam::ParticleForce<CloudType>::ParticleForce(const ParticleForce& pf)
:
owner_(pf.owner_),
mesh_(pf.mesh_),
dict_(pf.dict_),
coeffs_(pf.coeffs_)
{}

View File

@ -61,9 +61,6 @@ class ParticleForce
//- Reference to the mesh database
const fvMesh& mesh_;
//- Forces dictionary
const dictionary dict_;
//- Force coefficients dictaionary
const dictionary coeffs_;
@ -82,10 +79,9 @@ public:
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
),
(owner, mesh, dict, forceType)
(owner, mesh, dict)
);
@ -95,21 +91,14 @@ public:
// Constructors
//- Construct null
ParticleForce
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict
);
//- Construct from mesh
ParticleForce
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const word& forceType,
const bool readCoeffs
);
//- Construct copy
@ -152,9 +141,6 @@ public:
//- Return the mesh database
inline const fvMesh& mesh() const;
//- Return the forces dictionary
inline const dictionary& dict() const;
//- Return the force coefficients dictionary
inline const dictionary& coeffs() const;
@ -202,16 +188,23 @@ public:
#define makeParticleForceModel(CloudType) \
\
defineNamedTemplateTypeNameAndDebug(ParticleForce<CloudType>, 0); \
defineTemplateRunTimeSelectionTable(ParticleForce<CloudType>, dictionary);
typedef CloudType::kinematicCloudType kinematicCloudType; \
defineNamedTemplateTypeNameAndDebug(ParticleForce<kinematicCloudType>, 0);\
defineTemplateRunTimeSelectionTable \
( \
ParticleForce<kinematicCloudType>, \
dictionary \
);
#define makeParticleForceModelType(SS, CloudType) \
\
defineNamedTemplateTypeNameAndDebug(SS<CloudType>, 0); \
typedef CloudType::kinematicCloudType kinematicCloudType; \
defineNamedTemplateTypeNameAndDebug(SS<kinematicCloudType>, 0); \
\
ParticleForce<CloudType>::adddictionaryConstructorToTable<SS<CloudType> > \
add##SS##CloudType##ConstructorToTable_;
ParticleForce<kinematicCloudType>:: \
adddictionaryConstructorToTable<SS<kinematicCloudType> > \
add##SS##CloudType##kinematicCloudType##ConstructorToTable_;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -46,13 +46,6 @@ inline const Foam::fvMesh& Foam::ParticleForce<CloudType>::mesh() const
}
template<class CloudType>
inline const Foam::dictionary& Foam::ParticleForce<CloudType>::dict() const
{
return dict_;
}
template<class CloudType>
inline const Foam::dictionary& Foam::ParticleForce<CloudType>::coeffs() const
{

View File

@ -50,8 +50,7 @@ Foam::ParticleForce<CloudType>::New
"("
"CloudType&, "
"const fvMesh&, "
"const dictionary&, "
"const word&"
"const dictionary&"
")"
) << "Unknown particle force type "
<< forceType
@ -67,8 +66,7 @@ Foam::ParticleForce<CloudType>::New
(
owner,
mesh,
dict,
forceType
dict
)
);

View File

@ -33,11 +33,10 @@ Foam::PressureGradientForce<CloudType>::PressureGradientForce
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
)
:
ParticleForce<CloudType>(owner, mesh, dict, forceType),
ParticleForce<CloudType>(owner, mesh, dict, typeName, true),
UName_(this->coeffs().lookup("U")),
gradUPtr_(NULL)
{}

View File

@ -75,8 +75,7 @@ public:
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
);
//- Construct copy

View File

@ -32,11 +32,10 @@ Foam::SRFForce<CloudType>::SRFForce
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
)
:
ParticleForce<CloudType>(owner, mesh, dict),
ParticleForce<CloudType>(owner, mesh, dict, typeName, false),
srfPtr_(NULL)
{}

View File

@ -73,8 +73,7 @@ public:
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
);
//- Construct copy

View File

@ -192,22 +192,27 @@ public:
#define makePatchInteractionModel(CloudType) \
\
defineNamedTemplateTypeNameAndDebug(PatchInteractionModel<CloudType>, 0); \
\
typedef CloudType::kinematicCloudType kinematicCloudType; \
defineNamedTemplateTypeNameAndDebug \
( \
PatchInteractionModel<kinematicCloudType>, \
0 \
); \
defineTemplateRunTimeSelectionTable \
( \
PatchInteractionModel<CloudType>, \
PatchInteractionModel<kinematicCloudType>, \
dictionary \
);
#define makePatchInteractionModelType(SS, CloudType) \
\
defineNamedTemplateTypeNameAndDebug(SS<CloudType>, 0); \
typedef CloudType::kinematicCloudType kinematicCloudType; \
defineNamedTemplateTypeNameAndDebug(SS<kinematicCloudType>, 0); \
\
PatchInteractionModel<CloudType>:: \
adddictionaryConstructorToTable<SS<CloudType> > \
add##SS##CloudType##ConstructorToTable_;
PatchInteractionModel<kinematicCloudType>:: \
adddictionaryConstructorToTable<SS<kinematicCloudType> > \
add##SS##CloudType##kinematicCloudType##ConstructorToTable_;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -102,7 +102,8 @@ void Foam::PatchPostProcessing<CloudType>::write()
);
sort(globalData);
patchOutFile<< "# Time currentProc " + parcelType::propHeader << nl;
string header("# Time currentProc " + parcelType::propHeader);
patchOutFile<< header.c_str() << nl;
forAll(globalData, dataI)
{
@ -125,7 +126,7 @@ Foam::PatchPostProcessing<CloudType>::PatchPostProcessing
)
:
PostProcessingModel<CloudType>(dict, owner, typeName),
maxStoredParcels_(readLabel(this->coeffDict().lookup("maxStoredParcels"))),
maxStoredParcels_(readScalar(this->coeffDict().lookup("maxStoredParcels"))),
patchIDs_(),
patchData_()
{

View File

@ -55,8 +55,8 @@ class PatchPostProcessing
typedef typename CloudType::particleType parcelType;
//- Maximum number of parcels to store
label maxStoredParcels_;
//- Maximum number of parcels to store - set as a scalar for I/O
scalar maxStoredParcels_;
//- List of patch indices to post-process
labelList patchIDs_;

View File

@ -145,22 +145,27 @@ public:
#define makePostProcessingModel(CloudType) \
\
defineNamedTemplateTypeNameAndDebug(PostProcessingModel<CloudType>, 0); \
\
typedef CloudType::kinematicCloudType kinematicCloudType; \
defineNamedTemplateTypeNameAndDebug \
( \
PostProcessingModel<kinematicCloudType>, \
0 \
); \
defineTemplateRunTimeSelectionTable \
( \
PostProcessingModel<CloudType>, \
PostProcessingModel<kinematicCloudType>, \
dictionary \
);
#define makePostProcessingModelType(SS, CloudType) \
\
defineNamedTemplateTypeNameAndDebug(SS<CloudType>, 0); \
typedef CloudType::kinematicCloudType kinematicCloudType; \
defineNamedTemplateTypeNameAndDebug(SS<kinematicCloudType>, 0); \
\
PostProcessingModel<CloudType>:: \
adddictionaryConstructorToTable<SS<CloudType> > \
add##SS##CloudType##ConstructorToTable_;
PostProcessingModel<kinematicCloudType>:: \
adddictionaryConstructorToTable<SS<kinematicCloudType> > \
add##SS##CloudType##kinematicCloudType##ConstructorToTable_;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -243,22 +243,27 @@ public:
#define makeSurfaceFilmModel(CloudType) \
\
defineNamedTemplateTypeNameAndDebug(SurfaceFilmModel<CloudType>, 0); \
\
typedef CloudType::kinematicCloudType kinematicCloudType; \
defineNamedTemplateTypeNameAndDebug \
( \
SurfaceFilmModel<kinematicCloudType>, \
0 \
); \
defineTemplateRunTimeSelectionTable \
( \
SurfaceFilmModel<CloudType>, \
SurfaceFilmModel<kinematicCloudType>, \
dictionary \
);
#define makeSurfaceFilmModelType(SS, CloudType) \
\
defineNamedTemplateTypeNameAndDebug(SS<CloudType>, 0); \
typedef CloudType::kinematicCloudType kinematicCloudType; \
defineNamedTemplateTypeNameAndDebug(SS<kinematicCloudType>, 0); \
\
SurfaceFilmModel<CloudType>:: \
adddictionaryConstructorToTable<SS<CloudType> > \
add##SS##CloudType##ConstructorToTable_;
SurfaceFilmModel<kinematicCloudType>:: \
adddictionaryConstructorToTable<SS<kinematicCloudType> > \
add##SS##CloudType##kinematicCloudType##ConstructorToTable_;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -267,26 +267,27 @@ public:
#define makeCompositionModel(CloudType) \
\
typedef CloudType::reactingCloudType reactingCloudType; \
defineNamedTemplateTypeNameAndDebug \
( \
CompositionModel<CloudType>, \
CompositionModel<reactingCloudType>, \
0 \
); \
\
defineTemplateRunTimeSelectionTable \
( \
CompositionModel<CloudType>, \
CompositionModel<reactingCloudType>, \
dictionary \
);
#define makeCompositionModelType(SS, CloudType) \
\
defineNamedTemplateTypeNameAndDebug(SS<CloudType>, 0); \
typedef CloudType::reactingCloudType reactingCloudType; \
defineNamedTemplateTypeNameAndDebug(SS<reactingCloudType>, 0); \
\
CompositionModel<CloudType>:: \
adddictionaryConstructorToTable<SS<CloudType> > \
add##SS##CloudType##ConstructorToTable_;
CompositionModel<reactingCloudType>:: \
adddictionaryConstructorToTable<SS<reactingCloudType> > \
add##SS##CloudType##reactingCloudType##ConstructorToTable_;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -185,22 +185,27 @@ public:
#define makePhaseChangeModel(CloudType) \
\
defineNamedTemplateTypeNameAndDebug(PhaseChangeModel<CloudType>, 0); \
\
typedef CloudType::reactingCloudType reactingCloudType; \
defineNamedTemplateTypeNameAndDebug \
( \
PhaseChangeModel<reactingCloudType>, \
0 \
); \
defineTemplateRunTimeSelectionTable \
( \
PhaseChangeModel<CloudType>, \
PhaseChangeModel<reactingCloudType>, \
dictionary \
);
#define makePhaseChangeModelType(SS, CloudType) \
\
defineNamedTemplateTypeNameAndDebug(SS<CloudType>, 0); \
typedef CloudType::reactingCloudType reactingCloudType; \
defineNamedTemplateTypeNameAndDebug(SS<reactingCloudType>, 0); \
\
PhaseChangeModel<CloudType>:: \
adddictionaryConstructorToTable<SS<CloudType> > \
add##SS##CloudType##ConstructorToTable_;
PhaseChangeModel<reactingCloudType>:: \
adddictionaryConstructorToTable<SS<reactingCloudType> > \
add##SS##CloudType##reactingCloudType##ConstructorToTable_;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -136,22 +136,29 @@ public:
#define makeDevolatilisationModel(CloudType) \
\
defineNamedTemplateTypeNameAndDebug(DevolatilisationModel<CloudType>, 0); \
\
typedef CloudType::reactingMultiphaseCloudType \
reactingMultiphaseCloudType; \
defineNamedTemplateTypeNameAndDebug \
( \
DevolatilisationModel<reactingMultiphaseCloudType>, \
0 \
); \
defineTemplateRunTimeSelectionTable \
( \
DevolatilisationModel<CloudType>, \
DevolatilisationModel<reactingMultiphaseCloudType>, \
dictionary \
);
#define makeDevolatilisationModelType(SS, CloudType) \
\
defineNamedTemplateTypeNameAndDebug(SS<CloudType>, 0); \
typedef CloudType::reactingMultiphaseCloudType \
reactingMultiphaseCloudType; \
defineNamedTemplateTypeNameAndDebug(SS<reactingMultiphaseCloudType>, 0); \
\
DevolatilisationModel<CloudType>:: \
adddictionaryConstructorToTable<SS<CloudType> > \
add##SS##CloudType##ConstructorToTable_;
DevolatilisationModel<reactingMultiphaseCloudType>:: \
adddictionaryConstructorToTable<SS<reactingMultiphaseCloudType> > \
add##SS##CloudType##reactingMultiphaseCloudType##ConstructorToTable_;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -149,22 +149,29 @@ public:
#define makeSurfaceReactionModel(CloudType) \
\
defineNamedTemplateTypeNameAndDebug(SurfaceReactionModel<CloudType>, 0); \
\
typedef CloudType::reactingMultiphaseCloudType \
reactingMultiphaseCloudType; \
defineNamedTemplateTypeNameAndDebug \
( \
SurfaceReactionModel<reactingMultiphaseCloudType>, \
0 \
); \
defineTemplateRunTimeSelectionTable \
( \
SurfaceReactionModel<CloudType>, \
SurfaceReactionModel<reactingMultiphaseCloudType>, \
dictionary \
);
#define makeSurfaceReactionModelType(SS, CloudType) \
\
defineNamedTemplateTypeNameAndDebug(SS<CloudType>, 0); \
typedef CloudType::reactingMultiphaseCloudType \
reactingMultiphaseCloudType; \
defineNamedTemplateTypeNameAndDebug(SS<reactingMultiphaseCloudType>, 0); \
\
SurfaceReactionModel<CloudType>:: \
adddictionaryConstructorToTable<SS<CloudType> > \
add##SS##CloudType##ConstructorToTable_;
SurfaceReactionModel<reactingMultiphaseCloudType>:: \
adddictionaryConstructorToTable<SS<reactingMultiphaseCloudType> > \
add##SS##CloudType##reactingMultiphaseCloudType##ConstructorToTable_;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -155,22 +155,27 @@ public:
#define makeHeatTransferModel(CloudType) \
\
defineNamedTemplateTypeNameAndDebug(HeatTransferModel<CloudType>, 0); \
\
typedef CloudType::thermoCloudType thermoCloudType; \
defineNamedTemplateTypeNameAndDebug \
( \
HeatTransferModel<thermoCloudType>, \
0 \
); \
defineTemplateRunTimeSelectionTable \
( \
HeatTransferModel<CloudType>, \
HeatTransferModel<thermoCloudType>, \
dictionary \
);
#define makeHeatTransferModelType(SS, CloudType) \
\
defineNamedTemplateTypeNameAndDebug(SS<CloudType>, 0); \
typedef CloudType::thermoCloudType thermoCloudType; \
defineNamedTemplateTypeNameAndDebug(SS<thermoCloudType>, 0); \
\
HeatTransferModel<CloudType>:: \
adddictionaryConstructorToTable<SS<CloudType> > \
add##SS##CloudType##ConstructorToTable_;
HeatTransferModel<thermoCloudType>:: \
adddictionaryConstructorToTable<SS<thermoCloudType> > \
add##SS##CloudType##thermoCloudType##ConstructorToTable_;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -57,11 +57,10 @@ Foam::BrownianMotionForce<CloudType>::BrownianMotionForce
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
)
:
ParticleForce<CloudType>(owner, mesh, dict, forceType),
ParticleForce<CloudType>(owner, mesh, dict, typeName, true),
rndGen_(owner.rndGen()),
lambda_(readScalar(this->coeffs().lookup("lambda"))),
turbulence_(readBool(this->coeffs().lookup("turbulence"))),

View File

@ -94,8 +94,7 @@ public:
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
const dictionary& dict
);
//- Construct copy

View File

@ -213,6 +213,14 @@ void Foam::meshRefinement::updateIntersections(const labelList& changedFaces)
}
}
// Extend segments a bit
{
const vectorField smallVec(Foam::sqrt(SMALL)*(end-start));
start += smallVec;
end -= smallVec;
}
// Do tests in one go
labelList surfaceHit;
{
@ -316,6 +324,14 @@ void Foam::meshRefinement::checkData()
}
}
// Extend segments a bit
{
const vectorField smallVec(Foam::sqrt(SMALL)*(end-start));
start += smallVec;
end -= smallVec;
}
// Do tests in one go
labelList surfaceHit;
{
@ -2247,6 +2263,14 @@ void Foam::meshRefinement::dumpIntersections(const fileName& prefix) const
}
}
// Extend segments a bit
{
const vectorField smallVec(Foam::sqrt(SMALL)*(end-start));
start += smallVec;
end -= smallVec;
}
// Do tests in one go
labelList surfaceHit;
List<pointIndexHit> surfaceHitInfo;

View File

@ -283,6 +283,13 @@ void Foam::meshRefinement::getBafflePatches
}
}
// Extend segments a bit
{
const vectorField smallVec(Foam::sqrt(SMALL)*(end-start));
start += smallVec;
end -= smallVec;
}
// Do test for intersections
// ~~~~~~~~~~~~~~~~~~~~~~~~~
@ -2447,6 +2454,13 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::zonify
}
}
// Extend segments a bit
{
const vectorField smallVec(Foam::sqrt(SMALL)*(end-start));
start += smallVec;
end -= smallVec;
}
// Do test for intersections
// ~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -626,6 +626,13 @@ Foam::label Foam::meshRefinement::markSurfaceRefinement
}
}
// Extend segments a bit
{
const vectorField smallVec(Foam::sqrt(SMALL)*(end-start));
start += smallVec;
end -= smallVec;
}
// Do test for higher intersections
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -835,6 +842,14 @@ Foam::label Foam::meshRefinement::markSurfaceCurvatureRefinement
}
}
// Extend segments a bit
{
const vectorField smallVec(Foam::sqrt(SMALL)*(end-start));
start += smallVec;
end -= smallVec;
}
// Test for all intersections (with surfaces of higher max level than
// minLevel) and cache per cell the max surface level and the local normal
// on that surface.

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
@ -91,7 +91,24 @@ Foam::pointIndexHit Foam::searchableCylinder::findNearest
// distance to cylinder wall: magV-radius_
// Nearest cylinder point
point cylPt = sample + (radius_-magV)*v;
point cylPt;
if (magV < ROOTVSMALL)
{
// Point exactly on centre line. Take any point on wall.
vector e1 = point(1,0,0) ^ unitDir_;
scalar magE1 = mag(e1);
if (magE1 < SMALL)
{
e1 = point(0,1,0) ^ unitDir_;
magE1 = mag(e1);
}
e1 /= magE1;
cylPt = sample + radius_*e1;
}
else
{
cylPt = sample + (radius_-magV)*v;
}
if (parallel < 0.5*magDir_)
{

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
@ -72,14 +72,14 @@ Foam::Pair<Foam::vector> Foam::searchableSurfaceWithGaps::offsetVecs
}
offsets[0][minCmpt] = 1.0;
// Orthogonalise
// Orthonormalise
offsets[0] -= n[minCmpt]*n;
// Scale
offsets[0] *= gap_/mag(offsets[0]);
offsets[0] /= mag(offsets[0]);
// Do second offset vector perp to original edge and first offset vector
offsets[1] = n ^ offsets[0];
// Scale
offsets[0] *= gap_;
offsets[1] *= gap_;
}
@ -240,7 +240,7 @@ void Foam::searchableSurfaceWithGaps::findLine
// test in pairs: only if both perturbations hit something
// do we accept the hit.
const vectorField smallVec(SMALL*(compactEnd-compactStart));
const vectorField smallVec(1E-6*(compactEnd-compactStart));
List<pointIndexHit> plusInfo;
surface().findLine
@ -294,7 +294,7 @@ void Foam::searchableSurfaceWithGaps::findLine
offset0.setSize(plusMissMap.size());
offset1.setSize(plusMissMap.size());
const vectorField smallVec(SMALL*(compactEnd-compactStart));
const vectorField smallVec(1E-6*(compactEnd-compactStart));
surface().findLine
(

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
@ -588,6 +588,9 @@ const Foam::indexedOctree<Foam::treeDataEdge>&
bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
scalar oldTol = indexedOctree<treeDataTriSurface>::perturbTol();
indexedOctree<treeDataEdge>::perturbTol() = tolerance_;
edgeTree_.reset
(
new indexedOctree<treeDataEdge>
@ -605,6 +608,8 @@ const Foam::indexedOctree<Foam::treeDataEdge>&
3.0 // duplicity
)
);
indexedOctree<treeDataEdge>::perturbTol() = oldTol;
}
return edgeTree_();
}

View File

@ -1,3 +1,5 @@
codedFunctionObject/codedFunctionObject.C
staticPressure/staticPressure.C
staticPressure/staticPressureFunctionObject.C

View File

@ -0,0 +1,439 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "codedFunctionObject.H"
#include "volFields.H"
#include "dictionary.H"
#include "Time.H"
#include "SHA1Digest.H"
#include "dynamicCode.H"
#include "dynamicCodeContext.H"
#include "stringOps.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(codedFunctionObject, 0);
addToRunTimeSelectionTable
(
functionObject,
codedFunctionObject,
dictionary
);
}
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
void* Foam::codedFunctionObject::loadLibrary
(
const fileName& libPath,
const string& globalFuncName,
const dictionary& contextDict
)
{
void* lib = 0;
// avoid compilation by loading an existing library
if (!libPath.empty() && dlLibraryTable::open(libPath, false))
{
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>
(
dlSym(lib, globalFuncName)
);
if (function)
{
(*function)(true); // force load
}
else
{
FatalIOErrorIn
(
"codedFunctionObject::updateLibrary()",
contextDict
) << "Failed looking up symbol " << globalFuncName << nl
<< "from " << libPath << exit(FatalIOError);
}
}
else
{
FatalIOErrorIn
(
"codedFunctionObject::loadLibrary()",
contextDict
) << "Failed looking up symbol " << globalFuncName << nl
<< "from " << libPath << exit(FatalIOError);
lib = 0;
if (!dlLibraryTable::close(libPath, false))
{
FatalIOErrorIn
(
"codedFunctionObject::loadLibrary()",
contextDict
) << "Failed unloading library "
<< libPath
<< exit(FatalIOError);
}
}
}
}
return lib;
}
void Foam::codedFunctionObject::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
(
"codedFunctionObject::unloadLibrary()",
contextDict
) << "Failed looking up symbol " << globalFuncName << nl
<< "from " << libPath << exit(FatalIOError);
}
}
if (!dlLibraryTable::close(libPath, false))
{
FatalIOErrorIn
(
"codedFunctionObject::"
"updateLibrary()",
contextDict
) << "Failed unloading library " << libPath
<< exit(FatalIOError);
}
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::codedFunctionObject::createLibrary
(
dynamicCode& dynCode,
const dynamicCodeContext& context
) const
{
bool create = Pstream::master();
if (create)
{
// Write files for new library
if (!dynCode.upToDate(context))
{
// filter with this context
dynCode.reset(context);
// Set additional rewrite rules
dynCode.setFilterVariable("typeName", redirectType_);
dynCode.setFilterVariable("codeRead", codeRead_);
dynCode.setFilterVariable("codeExecute", codeExecute_);
dynCode.setFilterVariable("codeEnd", codeEnd_);
//dynCode.setFilterVariable("codeWrite", codeWrite_);
// compile filtered C template
dynCode.addCompileFile("functionObjectTemplate.C");
dynCode.addCompileFile("FilterFunctionObjectTemplate.C");
// copy filtered H template
dynCode.addCopyFile("FilterFunctionObjectTemplate.H");
dynCode.addCopyFile("functionObjectTemplate.H");
dynCode.addCopyFile("IOfunctionObjectTemplate.H");
// debugging: make BC verbose
// dynCode.setFilterVariable("verbose", "true");
// Info<<"compile " << redirectType_ << " sha1: "
// << context.sha1() << endl;
// define Make/options
dynCode.setMakeOptions
(
"EXE_INC = -g \\\n"
"-I$(LIB_SRC)/finiteVolume/lnInclude \\\n"
+ context.options()
+ "\n\nLIB_LIBS = \\\n"
+ " -lOpenFOAM \\\n"
+ " -lfiniteVolume \\\n"
+ context.libs()
);
if (!dynCode.copyOrCreateFiles(true))
{
FatalIOErrorIn
(
"codedFunctionObject::createLibrary(..)",
context.dict()
) << "Failed writing files for" << nl
<< dynCode.libRelPath() << nl
<< exit(FatalIOError);
}
}
if (!dynCode.wmakeLibso())
{
FatalIOErrorIn
(
"codedFunctionObject::createLibrary(..)",
context.dict()
) << "Failed wmake " << dynCode.libRelPath() << nl
<< exit(FatalIOError);
}
}
// all processes must wait for compile to finish
reduce(create, orOp<bool>());
}
void Foam::codedFunctionObject::updateLibrary() const
{
dynamicCode::checkSecurity
(
"codedFunctionObject::updateLibrary()",
dict_
);
dynamicCodeContext context(dict_);
// codeName: redirectType + _<sha1>
// codeDir : redirectType
dynamicCode dynCode
(
redirectType_ + context.sha1().str(true),
redirectType_
);
const fileName libPath = dynCode.libPath();
// the correct library was already loaded => we are done
if (dlLibraryTable::findLibrary(libPath))
{
return;
}
Info<< "Using dynamicCode for functionObject " << name()
<< " at line " << dict_.startLineNumber()
<< " in " << dict_.name() << endl;
// remove instantiation of fvPatchField provided by library
redirectFunctionObjectPtr_.clear();
// may need to unload old library
unloadLibrary
(
oldLibPath_,
dynamicCode::libraryBaseName(oldLibPath_),
context.dict()
);
// try loading an existing library (avoid compilation when possible)
if (!loadLibrary(libPath, dynCode.codeName(), context.dict()))
{
createLibrary(dynCode, context);
loadLibrary(libPath, dynCode.codeName(), context.dict());
}
// retain for future reference
oldLibPath_ = libPath;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::codedFunctionObject::codedFunctionObject
(
const word& name,
const Time& time,
const dictionary& dict
)
:
functionObject(name),
time_(time),
dict_(dict)
{
read(dict_);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::codedFunctionObject::~codedFunctionObject()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::functionObject&
Foam::codedFunctionObject::redirectFunctionObject() const
{
if (!redirectFunctionObjectPtr_.valid())
{
dictionary constructDict(dict_);
constructDict.set("type", redirectType_);
redirectFunctionObjectPtr_ = functionObject::New
(
redirectType_,
time_,
constructDict
);
}
return redirectFunctionObjectPtr_();
}
bool Foam::codedFunctionObject::start()
{
updateLibrary();
return redirectFunctionObject().start();
}
bool Foam::codedFunctionObject::execute(const bool forceWrite)
{
updateLibrary();
return redirectFunctionObject().execute(forceWrite);
}
bool Foam::codedFunctionObject::end()
{
updateLibrary();
return redirectFunctionObject().end();
}
bool Foam::codedFunctionObject::read(const dictionary& dict)
{
dict.lookup("redirectType") >> redirectType_;
const entry* readPtr = dict.lookupEntryPtr
(
"codeRead",
false,
false
);
if (readPtr)
{
codeRead_ = stringOps::trim(readPtr->stream());
stringOps::inplaceExpand(codeRead_, dict);
dynamicCodeContext::addLineDirective
(
codeRead_,
readPtr->startLineNumber(),
dict.name()
);
}
const entry* execPtr = dict.lookupEntryPtr
(
"codeExecute",
false,
false
);
if (execPtr)
{
codeExecute_ = stringOps::trim(execPtr->stream());
stringOps::inplaceExpand(codeExecute_, dict);
dynamicCodeContext::addLineDirective
(
codeExecute_,
execPtr->startLineNumber(),
dict.name()
);
}
const entry* endPtr = dict.lookupEntryPtr
(
"codeEnd",
false,
false
);
if (execPtr)
{
codeEnd_ = stringOps::trim(endPtr->stream());
stringOps::inplaceExpand(codeEnd_, dict);
dynamicCodeContext::addLineDirective
(
codeEnd_,
endPtr->startLineNumber(),
dict.name()
);
}
updateLibrary();
return redirectFunctionObject().read(dict);
}
// ************************************************************************* //

View File

@ -0,0 +1,174 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::codedFunctionObject
Description
functionObject using dynamic code compilation.
SourceFiles
codedFunctionObject.C
\*---------------------------------------------------------------------------*/
#ifndef codedFunctionObject_H
#define codedFunctionObject_H
#include "pointFieldFwd.H"
#include "functionObject.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class objectRegistry;
class dictionary;
class mapPolyMesh;
class dynamicCode;
class dynamicCodeContext;
class IOdictionary;
/*---------------------------------------------------------------------------*\
Class codedFunctionObject Declaration
\*---------------------------------------------------------------------------*/
class codedFunctionObject
:
public functionObject
{
protected:
// Protected data
//- Reference to the time database
const Time& time_;
//- Input dictionary
dictionary dict_;
word redirectType_;
string codeRead_;
string codeExecute_;
string codeEnd_;
//- Previously loaded library
mutable fileName oldLibPath_;
//- Underlying functionObject
mutable autoPtr<functionObject> redirectFunctionObjectPtr_;
// Private Member Functions
//- Global loader/unloader function type
typedef void (*loaderFunctionType)(bool);
//- Load specified library and execute globalFuncName(true)
static void* loadLibrary
(
const fileName& libPath,
const string& globalFuncName,
const dictionary& contextDict
);
//- Execute globalFuncName(false) and unload specified library
static void unloadLibrary
(
const fileName& libPath,
const string& globalFuncName,
const dictionary& contextDict
);
//- Create library based on the dynamicCodeContext
void createLibrary(dynamicCode&, const dynamicCodeContext&) const;
//- Update library as required
void updateLibrary() const;
//- Read relevant dictionary entries
void readDict();
//- Disallow default bitwise copy construct
codedFunctionObject(const codedFunctionObject&);
//- Disallow default bitwise assignment
void operator=(const codedFunctionObject&);
public:
//- Runtime type information
TypeName("coded");
// Constructors
//- Construct for given objectRegistry and dictionary.
// Allow the possibility to load fields from files
codedFunctionObject
(
const word& name,
const Time& time,
const dictionary& dict
);
//- Destructor
virtual ~codedFunctionObject();
// Member Functions
//- Dynamically compiled functionObject
functionObject& redirectFunctionObject() const;
//- Called at the start of the time-loop
virtual bool start();
//- Called at each ++ or += of the time-loop. forceWrite overrides the
// outputControl behaviour.
virtual bool execute(const bool forceWrite);
//- Called when Time::run() determines that the time-loop exits.
// By default it simply calls execute().
virtual bool end();
//- Read and set the function object if its data have changed
virtual bool read(const dictionary&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -277,6 +277,8 @@ void Foam::sampledSurfaces::read(const dictionary& dict)
void Foam::sampledSurfaces::updateMesh(const mapPolyMesh&)
{
expire();
// pointMesh and interpolation will have been reset in mesh.update
}
@ -327,10 +329,6 @@ bool Foam::sampledSurfaces::expire()
}
}
// reset interpolation
pointMesh::Delete(mesh_);
volPointInterpolation::Delete(mesh_);
// true if any surfaces just expired
return justExpired;
}