GIT: conflict resolution

This commit is contained in:
andy
2011-03-11 14:34:17 +00:00
1621 changed files with 107144 additions and 321537 deletions

View File

@ -1,5 +1,6 @@
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
makeType=${1:-libso}
wmakeCheckPwd "$WM_PROJECT_DIR/src" || {
echo "Error: Current directory is not \$WM_PROJECT_DIR/src"
@ -17,57 +18,56 @@ wmakeCheckPwd "$WM_PROJECT_DIR/src" || {
set -x
# update OpenFOAM version strings if required
wmakePrintBuild -check || /bin/rm -f OpenFOAM/Make/$WM_OPTIONS/global.? 2>/dev/null
wmakePrintBuild -check || /bin/rm -f OpenFOAM/Make/*/global.? 2>/dev/null
wmakeLnInclude OpenFOAM
wmakeLnInclude OSspecific/$WM_OSTYPE
Pstream/Allwmake
wmakeLnInclude OSspecific/${WM_OSTYPE:-POSIX}
Pstream/Allwmake $*
OSspecific/$WM_OSTYPE/Allwmake
wmake libso OpenFOAM
OSspecific/${WM_OSTYPE:-POSIX}/Allwmake
wmake $makeType OpenFOAM
wmake libso fileFormats
wmake libso triSurface
wmake libso meshTools
wmake libso edgeMesh
wmake libso surfMesh
wmake $makeType fileFormats
wmake $makeType triSurface
wmake $makeType meshTools
wmake $makeType edgeMesh
wmake $makeType surfMesh
# Decomposition methods needed by dummyThirdParty
parallel/decompose/AllwmakeLnInclude
# dummyThirdParty (dummy metisDecomp, scotchDecomp etc) needed by e.g. meshTools
dummyThirdParty/Allwmake
dummyThirdParty/Allwmake $*
wmake libso lagrangian/basic
wmake libso finiteVolume
wmake libso genericPatchFields
wmake $makeType finiteVolume
wmake $makeType lagrangian/basic
wmake $makeType lagrangian/distributionModels
wmake $makeType genericPatchFields
# Build the proper scotchDecomp, metisDecomp etc.
parallel/Allwmake
parallel/Allwmake $*
wmake libso conversion
wmake $makeType conversion
wmake libso sampling
wmake $makeType sampling
wmake libso dynamicMesh
wmake libso dynamicFvMesh
wmake libso topoChangerFvMesh
wmake $makeType dynamicMesh
wmake $makeType dynamicFvMesh
wmake $makeType topoChangerFvMesh
wmake libso ODE
wmake libso randomProcesses
wmake $makeType ODE
wmake $makeType randomProcesses
thermophysicalModels/Allwmake
transportModels/Allwmake
turbulenceModels/Allwmake
regionModels/Allwmake
lagrangian/Allwmake
postProcessing/Allwmake
mesh/Allwmake
thermophysicalModels/Allwmake $*
transportModels/Allwmake $*
turbulenceModels/Allwmake $*
regionModels/Allwmake $*
lagrangian/Allwmake $*
postProcessing/Allwmake $*
mesh/Allwmake $*
wmake libso errorEstimation
fvAgglomerationMethods/Allwmake $*
fvAgglomerationMethods/Allwmake
wmake libso fvMotionSolver
wmake libso engine
wmake $makeType fvMotionSolver
wmake $makeType engine
# ----------------------------------------------------------------- end-of-file

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,6 +51,7 @@ Description
#include <sys/stat.h>
#include <sys/socket.h>
#include <netdb.h>
#include <dlfcn.h>
#include <netinet/in.h>
@ -62,28 +63,28 @@ defineTypeNameAndDebug(Foam::POSIX, 0);
pid_t Foam::pid()
{
return getpid();
return ::getpid();
}
pid_t Foam::ppid()
{
return getppid();
return ::getppid();
}
pid_t Foam::pgid()
{
return getpgrp();
return ::getpgrp();
}
bool Foam::env(const word& envName)
{
return getenv(envName.c_str()) != NULL;
return ::getenv(envName.c_str()) != NULL;
}
Foam::string Foam::getEnv(const word& envName)
{
char* env = getenv(envName.c_str());
char* env = ::getenv(envName.c_str());
if (env)
{
@ -101,7 +102,7 @@ Foam::string Foam::getEnv(const word& envName)
bool Foam::setEnv
(
const word& envName,
const string& value,
const std::string& value,
const bool overwrite
)
{
@ -112,12 +113,12 @@ bool Foam::setEnv
Foam::word Foam::hostName(bool full)
{
char buf[128];
gethostname(buf, sizeof(buf));
::gethostname(buf, sizeof(buf));
// implementation as per hostname from net-tools
if (full)
{
struct hostent *hp = gethostbyname(buf);
struct hostent *hp = ::gethostbyname(buf);
if (hp)
{
return hp->h_name;
@ -131,13 +132,13 @@ Foam::word Foam::hostName(bool full)
Foam::word Foam::domainName()
{
char buf[128];
gethostname(buf, sizeof(buf));
::gethostname(buf, sizeof(buf));
// implementation as per hostname from net-tools
struct hostent *hp = gethostbyname(buf);
struct hostent *hp = ::gethostbyname(buf);
if (hp)
{
char *p = strchr(hp->h_name, '.');
char *p = ::strchr(hp->h_name, '.');
if (p)
{
++p;
@ -151,7 +152,7 @@ Foam::word Foam::domainName()
Foam::word Foam::userName()
{
struct passwd* pw = getpwuid(getuid());
struct passwd* pw = ::getpwuid(::getuid());
if (pw != NULL)
{
@ -164,10 +165,16 @@ Foam::word Foam::userName()
}
bool Foam::isAdministrator()
{
return (::geteuid() == 0);
}
// use $HOME environment variable or passwd info
Foam::fileName Foam::home()
{
char* env = getenv("HOME");
char* env = ::getenv("HOME");
if (env != NULL)
{
@ -175,7 +182,7 @@ Foam::fileName Foam::home()
}
else
{
struct passwd* pw = getpwuid(getuid());
struct passwd* pw = ::getpwuid(getuid());
if (pw != NULL)
{
@ -195,18 +202,18 @@ Foam::fileName Foam::home(const word& userName)
if (userName.size())
{
pw = getpwnam(userName.c_str());
pw = ::getpwnam(userName.c_str());
}
else
{
char* env = getenv("HOME");
char* env = ::getenv("HOME");
if (env != NULL)
{
return fileName(env);
}
pw = getpwuid(getuid());
pw = ::getpwuid(::getuid());
}
if (pw != NULL)
@ -223,7 +230,7 @@ Foam::fileName Foam::home(const word& userName)
Foam::fileName Foam::cwd()
{
char buf[256];
if (getcwd(buf, sizeof(buf)))
if (::getcwd(buf, sizeof(buf)))
{
return buf;
}
@ -240,7 +247,7 @@ Foam::fileName Foam::cwd()
bool Foam::chDir(const fileName& dir)
{
return chdir(dir.c_str()) != 0;
return ::chdir(dir.c_str()) == 0;
}
@ -304,7 +311,7 @@ Foam::fileName Foam::findEtcFile(const fileName& name, bool mandatory)
// abort if the file is mandatory, otherwise return null
if (mandatory)
{
cerr<< "--> FOAM FATAL ERROR in Foam::findEtcFile() :"
std::cerr<< "--> FOAM FATAL ERROR in Foam::findEtcFile() :"
" could not find mandatory file\n '"
<< name.c_str() << "'\n\n" << std::endl;
::exit(1);
@ -584,7 +591,7 @@ Foam::fileNameList Foam::readDir
label nEntries = 0;
// Attempt to open directory and set the structure pointer
if ((source = opendir(directory.c_str())) == NULL)
if ((source = ::opendir(directory.c_str())) == NULL)
{
dirEntries.setSize(0);
@ -598,7 +605,7 @@ Foam::fileNameList Foam::readDir
else
{
// Read and parse all the entries in the directory
while ((list = readdir(source)) != NULL)
while ((list = ::readdir(source)) != NULL)
{
fileName fName(list->d_name);
@ -644,7 +651,7 @@ Foam::fileNameList Foam::readDir
// Reset the length of the entries list
dirEntries.setSize(nEntries);
closedir(source);
::closedir(source);
}
return dirEntries;
@ -774,7 +781,7 @@ bool Foam::ln(const fileName& src, const fileName& dst)
return false;
}
if (symlink(src.c_str(), dst.c_str()) == 0)
if (::symlink(src.c_str(), dst.c_str()) == 0)
{
return true;
}
@ -803,11 +810,11 @@ bool Foam::mv(const fileName& src, const fileName& dst)
{
const fileName dstName(dst/src.name());
return rename(src.c_str(), dstName.c_str()) == 0;
return ::rename(src.c_str(), dstName.c_str()) == 0;
}
else
{
return rename(src.c_str(), dst.c_str()) == 0;
return ::rename(src.c_str(), dst.c_str()) == 0;
}
}
@ -839,7 +846,7 @@ bool Foam::mvBak(const fileName& src, const std::string& ext)
// possible index where we have no choice
if (!exists(dstName, false) || n == maxIndex)
{
return rename(src.c_str(), dstName.c_str()) == 0;
return ::rename(src.c_str(), dstName.c_str()) == 0;
}
}
@ -866,7 +873,7 @@ bool Foam::rm(const fileName& file)
}
else
{
return remove(string(file + ".gz").c_str()) == 0;
return ::remove(string(file + ".gz").c_str()) == 0;
}
}
@ -885,7 +892,7 @@ bool Foam::rmDir(const fileName& directory)
struct dirent *list;
// Attempt to open directory and set the structure pointer
if ((source = opendir(directory.c_str())) == NULL)
if ((source = ::opendir(directory.c_str())) == NULL)
{
WarningIn("rmDir(const fileName&)")
<< "cannot open directory " << directory << endl;
@ -895,7 +902,7 @@ bool Foam::rmDir(const fileName& directory)
else
{
// Read and parse all the entries in the directory
while ((list = readdir(source)) != NULL)
while ((list = ::readdir(source)) != NULL)
{
fileName fName(list->d_name);
@ -912,7 +919,7 @@ bool Foam::rmDir(const fileName& directory)
<< " while removing directory " << directory
<< endl;
closedir(source);
::closedir(source);
return false;
}
@ -926,7 +933,7 @@ bool Foam::rmDir(const fileName& directory)
<< " while removing directory " << directory
<< endl;
closedir(source);
::closedir(source);
return false;
}
@ -940,12 +947,12 @@ bool Foam::rmDir(const fileName& directory)
WarningIn("rmDir(const fileName&)")
<< "failed to remove directory " << directory << endl;
closedir(source);
::closedir(source);
return false;
}
closedir(source);
::closedir(source);
return true;
}
@ -983,7 +990,7 @@ bool Foam::ping
struct sockaddr_in destAddr; // will hold the destination addr
u_int addr;
if ((hostPtr = gethostbyname(destName.c_str())) == NULL)
if ((hostPtr = ::gethostbyname(destName.c_str())) == NULL)
{
FatalErrorIn
(
@ -996,7 +1003,7 @@ bool Foam::ping
addr = (reinterpret_cast<struct in_addr*>(*(hostPtr->h_addr_list)))->s_addr;
// Allocate socket
sockfd = socket(AF_INET, SOCK_STREAM, 0);
sockfd = ::socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0)
{
FatalErrorIn
@ -1024,7 +1031,7 @@ bool Foam::ping
if
(
connect
::connect
(
sockfd,
reinterpret_cast<struct sockaddr*>(&destAddr),
@ -1059,10 +1066,85 @@ bool Foam::ping(const word& hostname, const label timeOut)
}
int Foam::system(const string& command)
int Foam::system(const std::string& command)
{
return ::system(command.c_str());
}
void* Foam::dlOpen(const fileName& lib)
{
if (POSIX::debug)
{
Info<< "dlOpen(const fileName&)"
<< " : dlopen of " << lib << endl;
}
return ::dlopen(lib.c_str(), RTLD_LAZY|RTLD_GLOBAL);
}
bool Foam::dlClose(void* handle)
{
if (POSIX::debug)
{
Info<< "dlClose(void*)"
<< " : dlclose" << endl;
}
return ::dlclose(handle) == 0;
}
void* Foam::dlSym(void* handle, const std::string& symbol)
{
if (POSIX::debug)
{
Info<< "dlSym(void*, const std::string&)"
<< " : dlsym of " << symbol << endl;
}
// clear any old errors - see manpage dlopen
(void) ::dlerror();
// get address of symbol
void* fun = ::dlsym(handle, symbol.c_str());
// find error (if any)
char *error = ::dlerror();
if (error)
{
WarningIn("dlSym(void*, const std::string&)")
<< "Cannot lookup symbol " << symbol << " : " << error
<< endl;
}
return fun;
}
bool Foam::dlSymFound(void* handle, const std::string& symbol)
{
if (handle && !symbol.empty())
{
if (POSIX::debug)
{
Info<< "dlSymFound(void*, const std::string&)"
<< " : dlsym of " << symbol << endl;
}
// clear any old errors - see manpage dlopen
(void) ::dlerror();
// get address of symbol
(void) ::dlsym(handle, symbol.c_str());
// symbol can be found if there was no error
return !::dlerror();
}
else
{
return false;
}
}
// ************************************************************************* //

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
@ -109,8 +109,7 @@ namespace Foam
//! @cond internalClass
//- Internal tracking via stat(3p) or inotify(7)
//- Internal tracking via stat(3p) or inotify(7)
class fileMonitorWatcher
{
public:
@ -140,7 +139,7 @@ namespace Foam
{
if (useInotify_)
{
#ifdef FOAM_USE_INOTIFY
#ifdef FOAM_USE_INOTIFY
inotifyFd_ = inotify_init();
dirWatches_.setCapacity(sz);
dirFiles_.setCapacity(sz);
@ -167,13 +166,13 @@ namespace Foam
<< endl;
}
}
#else
#else
FatalErrorIn("fileMonitorWatcher(const bool, const label)")
<< "You selected inotify but this file was compiled"
<< " without FOAM_USE_INOTIFY"
<< "Please select another fileModification test method"
<< exit(FatalError);
#endif
#endif
}
else
{
@ -184,7 +183,7 @@ namespace Foam
//- remove all watches
inline ~fileMonitorWatcher()
{
#ifdef FOAM_USE_INOTIFY
#ifdef FOAM_USE_INOTIFY
if (useInotify_ && inotifyFd_ >= 0)
{
forAll(dirWatches_, i)
@ -200,7 +199,7 @@ namespace Foam
}
}
}
#endif
#endif
}
inline bool addWatch(const label watchFd, const fileName& fName)
@ -212,7 +211,7 @@ namespace Foam
return false;
}
#ifdef FOAM_USE_INOTIFY
#ifdef FOAM_USE_INOTIFY
// Add/retrieve watch on directory containing file.
// Note that fName might be non-existing in special situations
// (master-only reading for IODictionaries)
@ -250,7 +249,7 @@ namespace Foam
dirWatches_(watchFd) = dirWatchID;
dirFiles_(watchFd) = fName.name();
#endif
#endif
}
else
{
@ -288,7 +287,6 @@ namespace Foam
}
};
//! @endcond
}
@ -298,7 +296,7 @@ void Foam::fileMonitor::checkFiles() const
{
if (useInotify_)
{
#ifdef FOAM_USE_INOTIFY
#ifdef FOAM_USE_INOTIFY
// Large buffer for lots of events
char buffer[EVENT_BUF_LEN];
@ -392,7 +390,7 @@ void Foam::fileMonitor::checkFiles() const
return;
}
}
#endif
#endif
}
else
{

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
@ -29,7 +29,7 @@ Description
SeeAlso
The manpage regex(7) for more information about POSIX regular expressions.
These differ somewhat from @c Perl and @c sed regular expressions.
These differ somewhat from \c Perl and \c sed regular expressions.
SourceFiles
regExp.C

View File

@ -28,9 +28,9 @@ Description
Set up trapping for floating point exceptions (signal FPE).
Controlled by two env vars:
@param FOAM_SIGFPE \n
\param FOAM_SIGFPE \n
exception trapping
@param FOAM_SETNAN \n
\param FOAM_SETNAN \n
initialization of all malloced memory to NaN. If FOAM_SIGFPE
also set, this will cause usage of uninitialized scalars to trigger
an abort.

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
@ -28,7 +28,7 @@ Description
Implements a timeout mechanism via sigalarm.
Example usage:
@code
\code
timer myTimer(5); // 5 sec
..
if (timedOut(myTimer))
@ -39,7 +39,7 @@ Description
{
// do something possible blocking
}
@endcode
\endcode
Constructor set signal handler on sigalarm and alarm(). Destructor
clears these.

View File

@ -9,6 +9,7 @@ $(bools)/bool/bool.C
$(bools)/bool/boolIO.C
$(bools)/Switch/Switch.C
$(bools)/Switch/SwitchIO.C
$(bools)/lists/boolList.C
chars = primitives/chars
$(chars)/char/charIO.C
@ -22,10 +23,16 @@ $(ints)/longLong/longLongIO.C
$(ints)/ulong/ulongIO.C
$(ints)/label/label.C
$(ints)/uLabel/uLabel.C
$(ints)/lists/labelIOList.C
$(ints)/lists/labelListIOList.C
primitives/Scalar/doubleScalar/doubleScalar.C
primitives/Scalar/floatScalar/floatScalar.C
primitives/Scalar/scalar/scalar.C
primitives/Scalar/lists/scalarList.C
primitives/Scalar/lists/scalarIOList.C
primitives/Scalar/lists/scalarListIOList.C
primitives/DiagTensor/diagTensor/diagTensor.C
primitives/SphericalTensor/sphericalTensor/sphericalTensor.C
primitives/SphericalTensor/labelSphericalTensor/labelSphericalTensor.C
@ -33,9 +40,16 @@ primitives/SymmTensor/labelSymmTensor/labelSymmTensor.C
primitives/SymmTensor/symmTensor/symmTensor.C
primitives/Tensor/labelTensor/labelTensor.C
primitives/Tensor/tensor/tensor.C
primitives/Tensor/lists/sphericalTensorList.C
primitives/Tensor/lists/symmTensorList.C
primitives/Tensor/lists/tensorList.C
primitives/Vector/complexVector/complexVector.C
primitives/Vector/labelVector/labelVector.C
primitives/Vector/vector/vector.C
primitives/Vector/lists/vectorList.C
primitives/Vector/lists/vectorIOList.C
primitives/Vector/lists/vectorListIOList.C
primitives/Tensor2D/tensor2D/tensor2D.C
primitives/SphericalTensor2D/sphericalTensor2D/sphericalTensor2D.C
@ -47,6 +61,13 @@ primitives/globalIndexAndTransform/vectorTensorTransform/vectorTensorTransform.C
primitives/quaternion/quaternion.C
primitives/septernion/septernion.C
/* functions, data entries */
primitives/functions/DataEntry/makeDataEntries.C
primitives/functions/DataEntry/polynomial/polynomial.C
primitives/functions/DataEntry/polynomial/polynomialIO.C
primitives/functions/Polynomial/polynomialFunction.C
strings = primitives/strings
$(strings)/string/string.C
$(strings)/string/stringIO.C
@ -56,6 +77,8 @@ $(strings)/fileName/fileName.C
$(strings)/fileName/fileNameIO.C
$(strings)/keyType/keyType.C
$(strings)/wordRe/wordRe.C
$(strings)/lists/hashedWordList.C
$(strings)/stringOps/stringOps.C
primitives/hashes/Hasher/Hasher.C
@ -82,21 +105,6 @@ containers/Lists/ListOps/ListOps.C
containers/LinkedLists/linkTypes/SLListBase/SLListBase.C
containers/LinkedLists/linkTypes/DLListBase/DLListBase.C
primitiveLists = primitives/Lists
$(primitiveLists)/boolList.C
$(primitiveLists)/labelIOList.C
$(primitiveLists)/labelListIOList.C
$(primitiveLists)/scalarList.C
$(primitiveLists)/scalarIOList.C
$(primitiveLists)/scalarListIOList.C
$(primitiveLists)/vectorList.C
$(primitiveLists)/vectorIOList.C
$(primitiveLists)/vectorListIOList.C
$(primitiveLists)/sphericalTensorList.C
$(primitiveLists)/symmTensorList.C
$(primitiveLists)/tensorList.C
$(primitiveLists)/hashedWordList.C
Streams = db/IOstreams
$(Streams)/token/tokenIO.C
@ -152,18 +160,13 @@ $(dictionaryEntry)/dictionaryEntry.C
$(dictionaryEntry)/dictionaryEntryIO.C
functionEntries = $(dictionary)/functionEntries
$(functionEntries)/codeStream/codeStream.C
$(functionEntries)/functionEntry/functionEntry.C
$(functionEntries)/includeEntry/includeEntry.C
$(functionEntries)/includeIfPresentEntry/includeIfPresentEntry.C
$(functionEntries)/inputModeEntry/inputModeEntry.C
$(functionEntries)/removeEntry/removeEntry.C
calcEntry = $(functionEntries)/calcEntry
$(calcEntry)/calcEntryParser.atg
$(calcEntry)/calcEntryInternal.C
$(calcEntry)/calcEntry.C
IOdictionary = db/IOobjects/IOdictionary
$(IOdictionary)/IOdictionary.C
$(IOdictionary)/IOdictionaryIO.C
@ -184,7 +187,11 @@ $(regIOobject)/regIOobjectWrite.C
db/IOobjectList/IOobjectList.C
db/objectRegistry/objectRegistry.C
db/CallbackRegistry/CallbackRegistryName.C
db/dlLibraryTable/dlLibraryTable.C
dll = db/dynamicLibrary
$(dll)/dlLibraryTable/dlLibraryTable.C
$(dll)/dynamicCode/dynamicCode.C
$(dll)/dynamicCode/dynamicCodeContext.C
db/functionObjects/functionObject/functionObject.C
db/functionObjects/functionObjectList/functionObjectList.C
@ -488,6 +495,8 @@ $(pointBoundaryMesh)/pointBoundaryMesh.C
meshes/boundBox/boundBox.C
meshes/treeBoundBox/treeBoundBox.C
meshTools = meshes/meshTools
$(meshTools)/matchPoints.C
$(meshTools)/mergePoints.C
@ -565,6 +574,11 @@ $(interpolations)/patchToPatchInterpolation/PatchToPatchInterpolationName.C
algorithms/MeshWave/MeshWaveName.C
algorithms/MeshWave/FaceCellWaveName.C
algorithms/indexedOctree/indexedOctreeName.C
algorithms/indexedOctree/treeDataCell.C
graph/curve/curve.C
graph/graph.C

View File

@ -25,8 +25,8 @@ License
#include "indexedOctree.H"
#include "linePointRef.H"
#include "meshTools.H"
#include "OFstream.H"
#include "ListOps.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -1730,26 +1730,6 @@ void Foam::indexedOctree<Type>::traverseNode
point perturbedEnd(pushPoint(octantBb, end, false));
//if (debug)
{
// Dump octantBb to obj
writeOBJ(nodeI, octant);
// Dump ray to obj as well
{
OFstream str("ray.obj");
meshTools::writeOBJ(str, start);
meshTools::writeOBJ(str, end);
str << "l 1 2" << nl;
}
WarningIn("indexedOctree<Type>::traverseNode(..)")
<< "Did not intersect ray from endpoint:" << end
<< " to startpoint:" << start
<< " with bounding box:" << octantBb << nl
<< "Re-intersecting with perturbed endpoint:" << perturbedEnd
<< endl;
}
traverseNode
(
findAny,
@ -2316,12 +2296,6 @@ void Foam::indexedOctree<Type>::writeOBJ
pointField bbPoints(subBb.points());
label pointVertI = vertI;
forAll(bbPoints, i)
{
meshTools::writeOBJ(str, bbPoints[i]);
vertI++;
}
forAll(treeBoundBox::edges, i)
{
const edge& e = treeBoundBox::edges[i];

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
@ -511,7 +511,8 @@ public:
// Queries
//- Calculate nearest point on nearest shape. Returns
//- Calculate nearest point on nearest shape.
// Returns
// - bool : any point found nearer than nearestDistSqr
// - label: index in shapes
// - point: actual nearest point found
@ -532,7 +533,8 @@ public:
point& nearestPoint
) const;
//- Find nearest to line. Returns
//- Find nearest to line.
// Returns
// - bool : any point found?
// - label: index in shapes
// - point: actual nearest point found
@ -621,10 +623,10 @@ public:
bool write(Ostream& os) const;
// IOstream Operators
friend Ostream& operator<< <Type>(Ostream&, const indexedOctree<Type>&);
};

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

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

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
@ -139,7 +139,6 @@ Foam::pointField Foam::treeDataCell::points() const
}
// Check if any point on shape is inside cubeBb.
bool Foam::treeDataCell::overlaps
(
const label index,
@ -167,8 +166,6 @@ bool Foam::treeDataCell::contains
}
// Calculate nearest point to sample. Updates (if any) nearestDistSqr, minIndex,
// nearestPoint.
void Foam::treeDataCell::findNearest
(
const labelUList& indices,

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

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
@ -97,16 +97,18 @@ struct HashTableCore
{}
};
static const iteratorEnd endIter;
//- iteratorEnd set to beyond the end of any HashTable
inline static iteratorEnd cend()
inline static const iteratorEnd& cend()
{
return iteratorEnd();
return endIter;
}
//- iteratorEnd set to beyond the end of any HashTable
inline static iteratorEnd end()
inline static const iteratorEnd& end()
{
return iteratorEnd();
return endIter;
}
};

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
@ -37,6 +37,9 @@ const Foam::label Foam::HashTableCore::maxTableSize
)
);
const Foam::HashTableCore::iteratorEnd Foam::HashTableCore::endIter;
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::label Foam::HashTableCore::canonicalSize(const label size)

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
@ -236,10 +236,10 @@ public:
//- Read a bracket-delimited list, or handle a single value as list of size 1.
// For example,
// @code
// \code
// wList = readList<word>(IStringStream("(patch1 patch2 patch3)")());
// wList = readList<word>(IStringStream("patch0")());
// @endcode
// \endcode
// Mostly useful for handling command-line arguments.
template<class T>
List<T> readList(Istream&);

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
@ -37,7 +37,7 @@ Description
in one go, minimizing communication, and then picked apart and recombined.
Example:
@code
\code
// Assuming myContainer defined which holds all the data I want to
// transfer (say a pointField and a faceList). myContainer also defines
// access operators to
@ -76,7 +76,7 @@ Description
gatheredData, sizes, myContainerFaces(), offsetOp<face>()
)
);
@endcode
\endcode
SourceFiles
ListListOps.C

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
@ -54,7 +54,7 @@ namespace Foam
// Forward declaration
class PackedBoolList;
//- @typedef A List of PackedBoolList
//- \typedef A List of PackedBoolList
typedef List<PackedBoolList> PackedBoolListList;
/*---------------------------------------------------------------------------*\

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
@ -42,11 +42,11 @@ Note
Using the iteratorBase as a proxy allows assignment of values
between list elements. Thus the following bit of code works as expected:
@code
\code
list[1] = list[5]; // value assignment, not iterator position
list[2] = list[5] = 4; // propagates value
list[1] = list[5] = list[6]; // propagates value
@endcode
\endcode
Using get() or the '[]' operator are similarly fast. Looping and reading
via an iterator is approx. 15% slower, but can be more flexible.
@ -56,21 +56,21 @@ Note
advantage of also returning a bool if the value changed. This can be
useful for branching on changed values.
@code
\code
list[5] = 4;
changed = list.set(5, 8);
if (changed) ...
@endcode
\endcode
The lazy evaluation used means that reading an out-of-range element
returns zero, but does not affect the list size. Even in a non-const
context, only the assigment itself causes the element to be created.
For example,
@code
\code
list.resize(4);
Info<< list[10] << "\n"; // print zero, but doesn't adjust list
list[8] = 1;
@endcode
\endcode
Also note that all unused internal storage elements are guaranteed to
always be bit-wise zero. This property must not be violated by any
@ -79,14 +79,14 @@ Note
In addition to the normal output format, PackedList also supports a
compact ASCII format that may be convenient for user input in some
situations. The general format is a group of index/value pairs:
@verbatim
\verbatim
{ (index1 value1) (index2 value2) (index3 value3) }
@endverbatim
\endverbatim
The bool specialization just uses the indices corresponding to
non-zero entries instead of a index/value pair:
@verbatim
\verbatim
{ index1 index2 index3 }
@endverbatim
\endverbatim
In both cases, the supplied indices can be randomly ordered.
SeeAlso
@ -356,14 +356,14 @@ public:
//
// The indexed output may be convenient in some situations.
// The general format is a group of index/value pairs:
// @verbatim
// \verbatim
// { (index1 value1) (index2 value2) (index3 value3) }
// @endverbatim
// \endverbatim
// The bool specialization just uses the indices corresponding to
// non-zero entries instead of a index/value pair:
// @verbatim
// \verbatim
// { index1 index2 index3 }
// @endverbatim
// \endverbatim
//
// Note the indexed output is only supported for ASCII streams.
Ostream& write

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
@ -367,28 +367,28 @@ inline void reverse(UList<T>&);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
/**
* @def forAll(list, i)
* Loop across all elements in @a list
* @par Usage
* @code
* \def forAll(list, i)
* Loop across all elements in \a list
* \par Usage
* \code
* forAll(anyList, i)
* {
* statements;
* }
* @endcode
* @sa forAllReverse
* \endcode
* \sa forAllReverse
*/
/**
* @def forAllReverse(list, i)
* Reverse loop across all elements in @a list
* @par Usage
* @code
* \def forAllReverse(list, i)
* Reverse loop across all elements in \a list
* \par Usage
* \code
* forAllReverse(anyList, i)
* {
* statements;
* }
* @endcode
* @sa forAll
* \endcode
* \sa forAll
*/
#define forAll(list, i) \
for (Foam::label i=0; i<(list).size(); i++)
@ -397,17 +397,17 @@ inline void reverse(UList<T>&);
for (Foam::label i=(list).size()-1; i>=0; i--)
/**
* @def forAllIter(Container, container, iter)
* Iterate across all elements in the @a container object of type
* @a Container.
* @par Usage
* @code
* \def forAllIter(Container, container, iter)
* Iterate across all elements in the \a container object of type
* \a Container.
* \par Usage
* \code
* forAll(ContainerType, container, iter)
* {
* statements;
* }
* @endcode
* @sa forAllConstIter
* \endcode
* \sa forAllConstIter
*/
#define forAllIter(Container,container,iter) \
for \
@ -418,17 +418,17 @@ inline void reverse(UList<T>&);
)
/**
* @def forAllConstIter(Container, container, iter)
* Iterate across all elements in the @a container object of type
* @a Container with const access.
* @par Usage
* @code
* \def forAllConstIter(Container, container, iter)
* Iterate across all elements in the \a container object of type
* \a Container with const access.
* \par Usage
* \code
* forAllConstIter(ContainerType, container, iter)
* {
* statements;
* }
* @endcode
* @sa forAllIter
* \endcode
* \sa forAllIter
*/
#define forAllConstIter(Container,container,iter) \
for \

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
@ -33,32 +33,32 @@ Description
path, a reference to a objectRegistry, and parameters determining its
storage status.
@par Read options
\par Read options
Define what is done on object construction and explicit reads:
@param MUST_READ
\param MUST_READ
Object must be read from Istream on construction. \n
Error if Istream does not exist or can't be read.
Does not check timestamp or re-read.
@param MUST_READ_IF_MODIFIED
\param MUST_READ_IF_MODIFIED
Object must be read from Istream on construction. \n
Error if Istream does not exist or can't be read. If object is
registered its timestamp will be checked every timestep and possibly
re-read.
@param READ_IF_PRESENT
\param READ_IF_PRESENT
Read object from Istream if Istream exists, otherwise don't. \n
Error only if Istream exists but can't be read.
Does not check timestamp or re-read.
@param NO_READ
\param NO_READ
Don't read
@par Write options
\par Write options
Define what is done on object destruction and explicit writes:
@param AUTO_WRITE
\param AUTO_WRITE
Object is written automatically when requested to by the
objectRegistry.
@param NO_WRITE
\param NO_WRITE
No automatic write on destruction but can be written explicitly
SourceFiles

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
@ -137,7 +137,7 @@ Foam::IOdictionary::IOdictionary(const IOobject& io)
}
// Everyone check or just master
bool masterOnly =
bool masterOnly =
regIOobject::fileModificationChecking == timeStampMaster
|| regIOobject::fileModificationChecking == inotifyMaster;
@ -195,7 +195,7 @@ Foam::IOdictionary::IOdictionary(const IOobject& io, const dictionary& dict)
}
// Everyone check or just master
bool masterOnly =
bool masterOnly =
regIOobject::fileModificationChecking == timeStampMaster
|| regIOobject::fileModificationChecking == inotifyMaster;
@ -239,6 +239,18 @@ Foam::IOdictionary::IOdictionary(const IOobject& io, const dictionary& dict)
}
Foam::IOdictionary::IOdictionary(const IOobject& io, Istream& is)
:
regIOobject(io)
{
dictionary::name() = IOobject::objectPath();
// Note that we do construct the dictionary null and read in afterwards
// so that if there is some fancy massaging due to a functionEntry in
// the dictionary at least the type information is already complete.
is >> *this;
}
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
Foam::IOdictionary::~IOdictionary()

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
@ -75,6 +75,9 @@ public:
//- Construct given an IOobject and dictionary
IOdictionary(const IOobject&, const dictionary&);
//- Construct given an IOobject and Istream
IOdictionary(const IOobject&, Istream&);
//- Destructor
virtual ~IOdictionary();

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
@ -162,11 +162,16 @@ Foam::Istream& Foam::UIPstream::read(token& t)
// String
case token::STRING :
case token::VERBATIMSTRING :
{
string* pval = new string;
if (read(*pval))
{
t = pval;
if (c == token::VERBATIMSTRING)
{
t.type() = token::VERBATIMSTRING;
}
}
else
{

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,7 @@ License
#include "int.H"
#include "token.H"
#include <cctype>
#include "IOstreams.H"
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
@ -109,6 +110,27 @@ char Foam::ISstream::nextValid()
}
void Foam::ISstream::readWordToken(token& t)
{
word* wPtr = new word;
if (read(*wPtr).bad())
{
delete wPtr;
t.setBad();
}
else if (token::compound::isCompound(*wPtr))
{
t = token::compound::New(*wPtr, *this).ptr();
delete wPtr;
}
else
{
t = wPtr;
}
}
Foam::Istream& Foam::ISstream::read(token& t)
{
static const int maxLen = 128;
@ -181,7 +203,45 @@ Foam::Istream& Foam::ISstream::read(token& t)
return *this;
}
// Possible verbatim string or dictionary functionEntry
case token::HASH :
{
char nextC;
if (read(nextC).bad())
{
// Return hash as word
t = token(word(c));
return *this;
}
else if (nextC == token::BEGIN_BLOCK)
{
// Verbatim string
string* sPtr = new string;
if (readVerbatim(*sPtr).bad())
{
delete sPtr;
t.setBad();
}
else
{
t = sPtr;
t.type() = token::VERBATIMSTRING;
}
return *this;
}
else
{
// Word beginning with #
putback(nextC);
putback(c);
readWordToken(t);
return *this;
}
}
// Number: integer or floating point
//
@ -302,22 +362,7 @@ Foam::Istream& Foam::ISstream::read(token& t)
default:
{
putback(c);
word* wPtr = new word;
if (read(*wPtr).bad())
{
delete wPtr;
t.setBad();
}
else if (token::compound::isCompound(*wPtr))
{
t = token::compound::New(*wPtr, *this).ptr();
delete wPtr;
}
else
{
t = wPtr;
}
readWordToken(t);
return *this;
}
@ -504,6 +549,60 @@ Foam::Istream& Foam::ISstream::read(string& str)
}
Foam::Istream& Foam::ISstream::readVerbatim(string& str)
{
static const int maxLen = 8000;
static const int errLen = 80; // truncate error message for readability
static char buf[maxLen];
char c;
register int nChar = 0;
while (get(c))
{
if (c == token::HASH)
{
char nextC;
get(nextC);
if (nextC == token::END_BLOCK)
{
buf[nChar] = '\0';
str = buf;
return *this;
}
else
{
putback(nextC);
}
}
buf[nChar++] = c;
if (nChar == maxLen)
{
buf[errLen] = '\0';
FatalIOErrorIn("ISstream::readVerbatim(string&)", *this)
<< "string \"" << buf << "...\"\n"
<< " is too long (max. " << maxLen << " characters)"
<< exit(FatalIOError);
return *this;
}
}
// don't worry about a dangling backslash if string terminated prematurely
buf[errLen] = buf[nChar] = '\0';
FatalIOErrorIn("ISstream::readVerbatim(string&)", *this)
<< "problem while reading string \"" << buf << "...\""
<< exit(FatalIOError);
return *this;
}
Foam::Istream& Foam::ISstream::read(label& val)
{
is_ >> val;

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
@ -64,9 +64,15 @@ class ISstream
char nextValid();
void readWordToken(token&);
// Private Member Functions
//- Read a verbatim string (excluding block delimiters).
Istream& readVerbatim(string&);
//- Disallow default bitwise assignment
void operator=(const ISstream&);

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
@ -78,6 +78,7 @@ public:
PUNCTUATION,
WORD,
STRING,
VERBATIMSTRING,
LABEL,
FLOAT_SCALAR,
DOUBLE_SCALAR,
@ -104,6 +105,7 @@ public:
END_BLOCK = '}',
COLON = ':',
COMMA = ',',
HASH = '#',
BEGIN_STRING = '"',
END_STRING = BEGIN_STRING,
@ -317,6 +319,7 @@ public:
// Access
inline tokenType type() const;
inline tokenType& type();
inline bool good() const;
inline bool undefined() 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
@ -39,7 +39,7 @@ inline void token::clear()
{
delete wordTokenPtr_;
}
else if (type_ == STRING)
else if (type_ == STRING || type_ == VERBATIMSTRING)
{
delete stringTokenPtr_;
}
@ -88,6 +88,7 @@ inline token::token(const token& t)
break;
case STRING:
case VERBATIMSTRING:
stringTokenPtr_ = new string(*t.stringTokenPtr_);
break;
@ -178,6 +179,11 @@ inline token::tokenType token::type() const
return type_;
}
inline token::tokenType& token::type()
{
return type_;
}
inline bool token::good() const
{
return (type_ != ERROR && type_ != UNDEFINED);
@ -231,12 +237,12 @@ inline const word& token::wordToken() const
inline bool token::isString() const
{
return (type_ == STRING);
return (type_ == STRING || type_ == VERBATIMSTRING);
}
inline const string& token::stringToken() const
{
if (type_ == STRING)
if (type_ == STRING || type_ == VERBATIMSTRING)
{
return *stringTokenPtr_;
}
@ -405,6 +411,7 @@ inline void token::operator=(const token& t)
break;
case STRING:
case VERBATIMSTRING:
stringTokenPtr_ = new string(*t.stringTokenPtr_);
break;
@ -511,6 +518,7 @@ inline bool token::operator==(const token& t) const
return *wordTokenPtr_ == *t.wordTokenPtr_;
case STRING:
case VERBATIMSTRING:
return *stringTokenPtr_ == *t.stringTokenPtr_;
case LABEL:
@ -544,7 +552,7 @@ inline bool token::operator==(const word& w) const
inline bool token::operator==(const string& s) const
{
return (type_ == STRING && stringToken() == s);
return ((type_ == STRING || type_ == VERBATIMSTRING) && stringToken() == s);
}
inline bool token::operator==(const label l) 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
@ -70,6 +70,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const token& t)
break;
case token::STRING:
case token::VERBATIMSTRING:
os << *t.stringTokenPtr_;
break;
@ -156,6 +157,10 @@ ostream& Foam::operator<<(ostream& os, const InfoProxy<token>& ip)
os << " the string " << t.stringToken();
break;
case token::VERBATIMSTRING:
os << " the verbatim string " << t.stringToken();
break;
case token::LABEL:
os << " the label " << t.labelToken();
break;
@ -226,6 +231,10 @@ Ostream& operator<<(Ostream& os, const InfoProxy<token>& ip)
os << " the string " << t.stringToken();
break;
case token::VERBATIMSTRING:
os << " the verbatim string " << t.stringToken();
break;
case token::LABEL:
os << " the label " << t.labelToken();
break;

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
@ -86,18 +86,25 @@ void Foam::Time::adjustDeltaT()
(outputTimeIndex_ + 1)*writeInterval_ - (value() - startTime_)
);
label nStepsToNextWrite = label(timeToNextWrite/deltaT_ - SMALL) + 1;
scalar newDeltaT = timeToNextWrite/nStepsToNextWrite;
scalar nSteps = timeToNextWrite/deltaT_ - SMALL;
// Control the increase of the time step to within a factor of 2
// and the decrease within a factor of 5.
if (newDeltaT >= deltaT_)
// For tiny deltaT the label can overflow!
if (nSteps < labelMax)
{
deltaT_ = min(newDeltaT, 2.0*deltaT_);
}
else
{
deltaT_ = max(newDeltaT, 0.2*deltaT_);
label nStepsToNextWrite = label(nSteps) + 1;
scalar newDeltaT = timeToNextWrite/nStepsToNextWrite;
// Control the increase of the time step to within a factor of 2
// and the decrease within a factor of 5.
if (newDeltaT >= deltaT_)
{
deltaT_ = min(newDeltaT, 2.0*deltaT_);
}
else
{
deltaT_ = max(newDeltaT, 0.2*deltaT_);
}
}
}
}

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
@ -393,39 +393,39 @@ public:
//- Return true if run should continue,
// also invokes the functionObjectList::end() method
// when the time goes out of range
// @note
// \note
// For correct behaviour, the following style of time-loop
// is recommended:
// @code
// \code
// while (runTime.run())
// {
// runTime++;
// solve;
// runTime.write();
// }
// @endcode
// \endcode
virtual bool run() const;
//- Return true if run should continue and if so increment time
// also invokes the functionObjectList::end() method
// when the time goes out of range
// @note
// \note
// For correct behaviour, the following style of time-loop
// is recommended:
// @code
// \code
// while (runTime.loop())
// {
// solve;
// runTime.write();
// }
// @endcode
// \endcode
virtual bool loop();
//- Return true if end of run,
// does not invoke any functionObject methods
// @note
// \note
// The rounding heuristics near endTime mean that
// @code run() @endcode and @code !end() @endcode may
// \code run() \endcode and \code !end() \endcode may
// not yield the same result
virtual bool end() 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
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "Time.H"
#include "PstreamReduceOps.H"
#include "Pstream.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

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
@ -30,7 +30,7 @@ Description
The timeSelector provides a convenient means of selecting multiple
times. A typical use would be the following:
@verbatim
\verbatim
timeSelector::addOptions();
// add other options
#include "setRootCase.H"
@ -41,27 +41,27 @@ Description
{
...
}
@endverbatim
\endverbatim
The result program would receive @b -time, @b -latestTime, @b -constant
and @b -noZero options. The @b -constant option explicitly includes the
@c constant/ directory in the time list and the @b -noZero option
explicitly excludes the @c 0/ directory from the time list.
The result program would receive \b -time, @b -latestTime, @b -constant
and \b -noZero options. The @b -constant option explicitly includes the
\c constant/ directory in the time list and the \b -noZero option
explicitly excludes the \c 0/ directory from the time list.
There may however also be many cases in which neither the @c constant/
directory nor the @c 0/ directory contain particularly relevant
There may however also be many cases in which neither the \c constant/
directory nor the \c 0/ directory contain particularly relevant
information. This might occur, for example, when post-processing
results. In this case, addOptions is called with optional boolean
arguments.
@verbatim
\verbatim
timeSelector::addOptions(false, true);
@endverbatim
\endverbatim
The first argument avoids adding the @b -constant option. The second
argument adds an additional @b -zeroTime option and also prevents the
@c 0/ directory from being included in the default time range and in the
@b -latestTime selection.
The first argument avoids adding the \b -constant option. The second
argument adds an additional \b -zeroTime option and also prevents the
\c 0/ directory from being included in the default time range and in the
\b -latestTime selection.
SourceFiles
timeSelector.C
@ -119,15 +119,15 @@ public:
//- Add the options handled by timeSelector to argList::validOptions
//
// @param constant
// Add the @b -constant option to include the @c constant/ directory
// \param constant
// Add the \b -constant option to include the \c constant/ directory
//
// @param zeroTime
// Enable the @b -zeroTime option and alter the normal time selection
// behaviour (and @b -latestTime behaviour) to exclude the @c 0/
// directory. The @c 0/ directory will only be included when
// @b -zeroTime is specified.
// The @b -noZero option has precedence over the @b -zeroTime option.
// \param zeroTime
// Enable the \b -zeroTime option and alter the normal time selection
// behaviour (and \b -latestTime behaviour) to exclude the \c 0/
// directory. The \c 0/ directory will only be included when
// \b -zeroTime is specified.
// The \b -noZero option has precedence over the @b -zeroTime option.
static void addOptions
(
const bool constant=true,

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
@ -260,7 +260,12 @@ Foam::SHA1Digest Foam::dictionary::digest() const
}
bool Foam::dictionary::found(const word& keyword, bool recursive) const
bool Foam::dictionary::found
(
const word& keyword,
bool recursive,
bool patternMatch
) const
{
if (hashedEntries_.found(keyword))
{
@ -268,7 +273,7 @@ bool Foam::dictionary::found(const word& keyword, bool recursive) const
}
else
{
if (patternEntries_.size())
if (patternMatch && patternEntries_.size())
{
DLList<entry*>::const_iterator wcLink =
patternEntries_.begin();
@ -276,7 +281,7 @@ bool Foam::dictionary::found(const word& keyword, bool recursive) const
patternRegexps_.begin();
// Find in patterns using regular expressions only
if (findInPatterns(true, keyword, wcLink, reLink))
if (findInPatterns(patternMatch, keyword, wcLink, reLink))
{
return true;
}
@ -284,7 +289,7 @@ bool Foam::dictionary::found(const word& keyword, bool recursive) const
if (recursive && &parent_ != &dictionary::null)
{
return parent_.found(keyword, recursive);
return parent_.found(keyword, recursive, patternMatch);
}
else
{
@ -481,14 +486,29 @@ Foam::dictionary& Foam::dictionary::subDict(const word& keyword)
Foam::dictionary Foam::dictionary::subOrEmptyDict
(
const word& keyword
const word& keyword,
const bool mustRead
) const
{
const entry* entryPtr = lookupEntryPtr(keyword, false, true);
if (entryPtr == NULL)
{
return dictionary(*this, dictionary(name() + "::" + keyword));
if (mustRead)
{
FatalIOErrorIn
(
"dictionary::subOrEmptyDict(const word& keyword, const bool)",
*this
) << "keyword " << keyword << " is undefined in dictionary "
<< name()
<< exit(FatalIOError);
return entryPtr->dict();
}
else
{
return dictionary(*this, dictionary(name() + "::" + keyword));
}
}
else
{
@ -736,13 +756,14 @@ bool Foam::dictionary::changeKeyword
if (iter()->keyword().isPattern())
{
FatalErrorIn
FatalIOErrorIn
(
"dictionary::changeKeyword(const word&, const word&, bool)"
"dictionary::changeKeyword(const word&, const word&, bool)",
*this
) << "Old keyword "<< oldKeyword
<< " is a pattern."
<< "Pattern replacement not yet implemented."
<< exit(FatalError);
<< exit(FatalIOError);
}
@ -776,9 +797,10 @@ bool Foam::dictionary::changeKeyword
}
else
{
WarningIn
IOWarningIn
(
"dictionary::changeKeyword(const word&, const word&, bool)"
"dictionary::changeKeyword(const word&, const word&, bool)",
*this
) << "cannot rename keyword "<< oldKeyword
<< " to existing keyword " << newKeyword
<< " in dictionary " << name() << endl;
@ -810,9 +832,9 @@ bool Foam::dictionary::merge(const dictionary& dict)
// Check for assignment to self
if (this == &dict)
{
FatalErrorIn("dictionary::merge(const dictionary&)")
FatalIOErrorIn("dictionary::merge(const dictionary&)", *this)
<< "attempted merge to self for dictionary " << name()
<< abort(FatalError);
<< abort(FatalIOError);
}
bool changed = false;
@ -891,9 +913,9 @@ void Foam::dictionary::operator=(const dictionary& rhs)
// Check for assignment to self
if (this == &rhs)
{
FatalErrorIn("dictionary::operator=(const dictionary&)")
FatalIOErrorIn("dictionary::operator=(const dictionary&)", *this)
<< "attempted assignment to self for dictionary " << name()
<< abort(FatalError);
<< abort(FatalIOError);
}
name() = rhs.name();
@ -914,9 +936,9 @@ void Foam::dictionary::operator+=(const dictionary& rhs)
// Check for assignment to self
if (this == &rhs)
{
FatalErrorIn("dictionary::operator+=(const dictionary&)")
FatalIOErrorIn("dictionary::operator+=(const dictionary&)", *this)
<< "attempted addition assignment to self for dictionary " << name()
<< abort(FatalError);
<< abort(FatalIOError);
}
forAllConstIter(IDLList<entry>, rhs, iter)
@ -931,9 +953,9 @@ void Foam::dictionary::operator|=(const dictionary& rhs)
// Check for assignment to self
if (this == &rhs)
{
FatalErrorIn("dictionary::operator|=(const dictionary&)")
FatalIOErrorIn("dictionary::operator|=(const dictionary&)", *this)
<< "attempted assignment to self for dictionary " << name()
<< abort(FatalError);
<< abort(FatalIOError);
}
forAllConstIter(IDLList<entry>, rhs, iter)
@ -951,9 +973,9 @@ void Foam::dictionary::operator<<=(const dictionary& rhs)
// Check for assignment to self
if (this == &rhs)
{
FatalErrorIn("dictionary::operator<<=(const dictionary&)")
FatalIOErrorIn("dictionary::operator<<=(const dictionary&)", *this)
<< "attempted assignment to self for dictionary " << name()
<< abort(FatalError);
<< abort(FatalIOError);
}
forAllConstIter(IDLList<entry>, rhs, iter)

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
@ -239,7 +239,7 @@ public:
//- Destructor
~dictionary();
virtual ~dictionary();
// Member functions
@ -264,7 +264,13 @@ public:
//- Search dictionary for given keyword
// If recursive, search parent dictionaries
bool found(const word&, bool recursive=false) const;
// If patternMatch, use regular expressions
bool found
(
const word&,
bool recursive=false,
bool patternMatch = true
) const;
//- Find and return an entry data stream pointer if present
// otherwise return NULL.
@ -362,7 +368,11 @@ public:
//- Find and return a sub-dictionary as a copy, or
// return an empty dictionary if the sub-dictionary does not exist
dictionary subOrEmptyDict(const word&) const;
dictionary subOrEmptyDict
(
const word&,
const bool mustRead = false
) const;
//- Return the table of contents
wordList toc() const;
@ -467,7 +477,8 @@ public:
// Write
void write(Ostream&, bool subDict=true) const;
//- Write dictionary, normally with sub-dictionary formatting
void write(Ostream&, const bool subDict=true) const;
// Member Operators

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
@ -146,7 +146,7 @@ public:
//- Return non-const access to dictionary
dictionary& dict();
// Write
//- Write
void write(Ostream&) const;
//- Return info proxy.

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

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,14 @@ License
#include "dictionary.H"
#include "OStringStream.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
int Foam::entry::disableFunctionEntries
(
Foam::debug::infoSwitch("disableFunctionEntries", 0)
);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::entry::entry(const keyType& keyword)

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
@ -81,6 +81,9 @@ class entry
public:
static int disableFunctionEntries;
// Constructors
//- Construct from keyword

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
@ -98,21 +98,32 @@ bool Foam::entry::New(dictionary& parentDict, Istream& is)
}
else // Keyword starts entry ...
{
if (keyword[0] == '#') // ... Function entry
if
(
!disableFunctionEntries
&& keyword[0] == '#'
) // ... Function entry
{
word functionName = keyword(1, keyword.size()-1);
return functionEntry::execute(functionName, parentDict, is);
}
else if (keyword[0] == '$') // ... Substitution entry
else if
(
!disableFunctionEntries
&& keyword[0] == '$') // ... Substitution entry
{
parentDict.substituteKeyword(keyword);
return true;
}
else if (keyword == "include") // ... For backward compatibility
else if
(
!disableFunctionEntries
&& keyword == "include"
) // ... For backward compatibility
{
return functionEntries::includeEntry::execute(parentDict, is);
}
else // ... Data entries
else // ... Data entries
{
token nextToken(is);
is.putBack(nextToken);

View File

@ -1,97 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2010 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 "calcEntry.H"
#include "dictionary.H"
#include "addToMemberFunctionSelectionTable.H"
#include "ISstream.H"
#include "CocoParserErrors.H"
#include "calcEntryParser.h"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace functionEntries
{
defineTypeNameAndDebug(calcEntry, 0);
addToMemberFunctionSelectionTable
(
functionEntry,
calcEntry,
execute,
primitiveEntryIstream
);
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionEntries::calcEntry::execute
(
const dictionary& parentDict,
primitiveEntry& entry,
Istream& is
)
{
std::istream& iss = dynamicCast<ISstream>(is).stdStream();
// define parser error handler
CocoParserErrors<calcEntryInternal::Errors>
myErrorHandler("calcEntryInternal::Parser");
calcEntryInternal::Scanner scanner(iss);
// set the starting line
scanner.Line(is.lineNumber());
calcEntryInternal::Parser parser(&scanner, &myErrorHandler);
// Attach dictionary context
parser.dict(parentDict);
parser.Parse();
// mostly have an extra newline in the lookahead token
// so subtract 1 to keep things vaguely in sync
// (this is still far from perfect)
is.lineNumber() = scanner.Line() - 1;
// a small input list to contain the answer
tokenList tokens(2);
tokens[0] = parser.Result();
tokens[1] = token::END_STATEMENT;
entry.read(parentDict, ITstream("ParserResult", tokens)());
return true;
}
// ************************************************************************* //

View File

@ -1,91 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2010 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::functionEntries::calcEntry
Description
This dictionary function entry may or may not do anything particularly
useful - depending upon what is currently being used to test.
SourceFiles
calcEntry.C
\*---------------------------------------------------------------------------*/
#ifndef calcEntry_H
#define calcEntry_H
#include "functionEntry.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace functionEntries
{
/*---------------------------------------------------------------------------*\
Class calcEntry Declaration
\*---------------------------------------------------------------------------*/
class calcEntry
:
public functionEntry
{
// Private Member Functions
//- Disallow default bitwise copy construct
calcEntry(const calcEntry&);
//- Disallow default bitwise assignment
void operator=(const calcEntry&);
public:
//- Runtime type information
ClassName("calc");
// Member Functions
static bool execute
(
const dictionary& parentDict,
primitiveEntry& entry,
Istream& is
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionEntries
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,128 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2010-2010 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 "calcEntryInternal.H"
#include "addToGlobalFunctionSelectionTable.H"
#include "unitConversion.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace functionEntries
{
namespace calcEntryInternal
{
defineGlobalFunctionSelectionTable(dispatch,ParamList);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#define globalConstant0(Name, Constant)\
scalar Name##_0(const UList<scalar>& param) \
{ \
return Constant; \
} \
addNamedToGlobalFunctionSelectionTable(dispatch,ParamList,Name##_0,&Name##_0)
#define globalFunction0(Name, Function)\
scalar Name##_0(const UList<scalar>& param) \
{ \
return Function(); \
} \
addNamedToGlobalFunctionSelectionTable(dispatch,ParamList,Name##_0,&Name##_0)
#define globalFunction1(Name, Function)\
scalar Name##_1(const UList<scalar>& param) \
{ \
return Function(param[0]); \
} \
addNamedToGlobalFunctionSelectionTable(dispatch,ParamList,Name##_1,&Name##_1)
#define globalFunction2(Name, Function)\
scalar Name##_2(const UList<scalar>& param) \
{ \
return Function(param[0], param[1]); \
} \
addNamedToGlobalFunctionSelectionTable(dispatch,ParamList,Name##_2,&Name##_2)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
globalConstant0(pi, constant::mathematical::pi);
globalFunction1(degToRad, degToRad);
globalFunction1(radToDeg, radToDeg);
globalFunction1(asin, Foam::asin);
globalFunction1(acos, Foam::acos);
globalFunction1(atan, Foam::atan);
globalFunction1(sin, Foam::sin);
globalFunction1(cos, Foam::cos);
globalFunction1(tan, Foam::tan);
globalFunction1(log, Foam::log);
globalFunction1(log10, Foam::log10);
globalFunction1(mag, Foam::mag);
globalFunction2(atan2, Foam::atan2);
globalFunction2(pow, Foam::pow);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
scalar dispatch(const word& name, const UList<scalar>& param)
{
// create lookup name with parameter count
const word lookupName = name + '_' + Foam::name(param.size());
dispatchParamListMemberFunctionTable::iterator mfIter =
dispatchParamListMemberFunctionTablePtr_->find(lookupName);
if (mfIter == dispatchParamListMemberFunctionTablePtr_->end())
{
FatalErrorIn
(
"calcEntryInternal::scalarFunctions::dispatch"
"(const word&, const UList<scalar>&) : "
) << "Unknown function " << name << nl << nl
<< "Valid types are :" << endl
<< dispatchParamListMemberFunctionTablePtr_->sortedToc()
<< exit(FatalError);
}
return mfIter()(param);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace calcEntryInternal
} // End namespace functionEntries
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,80 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2010-2010 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/>.
Namespace
Foam::functionEntries::calcEntryInternal
Description
Contains global functions and classes for the calcEntry.
SourceFiles
calcEntryInternal.C
\*---------------------------------------------------------------------------*/
#ifndef calcEntryInternal_H
#define calcEntryInternal_H
#include "error.H"
#include "scalar.H"
#include "DynamicList.H"
#include "globalFunctionSelectionTables.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace functionEntries
{
namespace calcEntryInternal
{
// Global Function Selectors
declareGlobalFunctionSelectionTable
(
scalar,
dispatch,
ParamList,
(
const UList<scalar>& param
),
(param)
);
//- Dispatch calculation to the named function
scalar dispatch(const word&, const UList<scalar>&);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace calcEntryInternal
} // End namespace functionEntries
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,257 +0,0 @@
/*---------------------------------------------------------------------------*\
Attributed Grammar for Coco/R (-*- C++ -*- version)
compile with:
coco-cpp calcEntryParser.atg
\*---------------------------------------------------------------------------*/
[copy]
/*---------------------------------*- C++ -*---------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2010-2010 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/>.
@file calcEntryParser.atg
Description
An attributed Coco/R grammar to parse simple arithmetic expressions
Includes support for dictionary $variables and some scalar functions
(eg, sin, pow, ...)
SourceFiles
generated
\*---------------------------------------------------------------------------*/
[/copy]
#include "dictionary.H"
#include "wchar.H"
#include "calcEntryInternal.H"
COMPILER calcEntry
// grammar pragmas:
$prefix=calcEntry
$namespace=Foam::functionEntries::calcEntryInternal
$define=EXPLICIT_EOF // grammar handles eof itself
$define=STREAMS_ONLY // only use STL streams
$define=NO_UTF8 // disable UTF8 on input
private:
//- The parent dictionary
dictionary* dict_;
//- The calculation result
scalar val;
//- lookup dictionary entry
scalar getDictLookup(const word&) const;
public:
//- attach a dictionary
void dict(const dictionary& dict)
{
dict_ = const_cast<dictionary*>(&dict);
}
//- Return the calculated result
scalar Result() const
{
return val;
}
/*---------------------------------------------------------------------------*/
[initialize] // add to Parser constructor
dict_ = 0;
val = 0;
[/initialize]
/*---------------------------------------------------------------------------*/
[code]
Foam::scalar Parser::getDictLookup(const word& keyword) const
{
if (!dict_)
{
FatalErrorIn
(
"calcEntry::getDictEntry(const word&) const"
) << "No dictionary attached!"
<< exit(FatalError);
return 0;
}
scalar dictValue = 0;
entry* entryPtr = dict_->lookupEntryPtr(keyword, true, false);
if (entryPtr && !entryPtr->isDict())
{
if (entryPtr->stream().size() != 1)
{
FatalErrorIn
(
"calcEntry::getDictEntry(const word&) const"
) << "keyword " << keyword << " has "
<< entryPtr->stream().size() << " values in dictionary "
<< exit(FatalError);
}
entryPtr->stream() >> dictValue;
}
else
{
FatalErrorIn
(
"calcEntry::getDictEntry(const word&) const"
) << "keyword " << keyword << " is undefined in dictionary "
<< exit(FatalError);
}
return dictValue;
}
[/code]
/*---------------------------------------------------------------------------*/
CHARACTERS
letter = 'A'..'Z' + 'a'..'z' + '_'.
digit = "0123456789".
alphanum = letter + digit.
sign = '+' + '-'.
cr = '\r'.
lf = '\n'.
tab = '\t'.
stringCh = ANY - '"' - '\\' - cr - lf.
printable = '\u0020' .. '\u007e'.
// * * * * * * * * * * * * * * * * TOKENS * * * * * * * * * * * * * * * * * //
TOKENS
// identifier
ident =
letter { alphanum }.
// string
string =
'"' { stringCh | '\\' printable } '"'.
// dictionary lookup identifier
// starts with '$' and otherwise limited to a normal identifier
variable =
'$' letter { alphanum }.
// floating point and integer numbers
number =
[sign] ('.' digit { digit } ) | ( digit { digit } [ '.' { digit } ])
[ ('E' | 'e') [sign] digit { digit } ].
// * * * * * * * * * * * PRAGMAS / COMMENTS / IGNORE * * * * * * * * * * * //
COMMENTS FROM "/*" TO "*/" NESTED
COMMENTS FROM "//" TO lf
IGNORE cr + lf + tab
// * * * * * * * * * * * * * * * PRODUCTIONS * * * * * * * * * * * * * * * //
PRODUCTIONS
calcEntry (. val = 0; .)
=
'{' Expr<val> '}' (. // reposition to immediately after the closing '}'
scanner->buffer->SetPos(t->pos + 1);
.)
| ( Expr<val> EOF )
.
/*---------------------------------------------------------------------------*/
Expr<scalar& val> (. scalar val2 = 0; .)
=
Term<val>
{
'+' Term<val2> (. val += val2; .)
| '-' Term<val2> (. val -= val2; .)
}
.
/*---------------------------------------------------------------------------*/
Term<scalar& val> (. scalar val2 = 0; .)
=
Factor<val>
{
'*' Factor<val2> (. val *= val2; .)
| '/' Factor<val2> (. val /= val2; .)
}
.
/*---------------------------------------------------------------------------*/
// Note the treatment of the leading signs is fairly generous
// eg, "10 + - 10" is treated like "10 + -10"
//
Factor<scalar& val> (. bool negative = false; .)
=
['+' | '-' (. negative = true; .)
]
(
Func<val> | '(' Expr<val> ')'
| variable (.
// skip leading '$' for the keyword
val = getDictLookup(t->toString(1, t->length()-1));
.)
| number (. val = coco_string_toDouble(t->val); .)
) (. if (negative) { val = -val; } .)
.
/*---------------------------------------------------------------------------*/
// functions like sin(x) or pow(x, y) etc.
Func<scalar& val>
=
ident (.
word funcName(t->toString());
DynamicList<scalar> stack(4);
.)
'('
[ (. scalar x; .)
Expr<x> (. stack.append(x); .)
{ ',' Expr<x> (. stack.append(x); .)
}
]
')' (. val = dispatch(funcName, stack); .)
.
/*---------------------------------------------------------------------------*/
END calcEntry.
// ************************************************************************* //

View File

@ -0,0 +1,209 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "codeStream.H"
#include "addToMemberFunctionSelectionTable.H"
#include "IStringStream.H"
#include "OStringStream.H"
#include "IOstreams.H"
#include "stringOps.H"
#include "dynamicCode.H"
#include "dynamicCodeContext.H"
#include "dlLibraryTable.H"
#include "OSspecific.H"
#include "Time.H"
#include "PstreamReduceOps.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace functionEntries
{
defineTypeNameAndDebug(codeStream, 0);
addToMemberFunctionSelectionTable
(
functionEntry,
codeStream,
execute,
primitiveEntryIstream
);
}
}
const Foam::word Foam::functionEntries::codeStream::codeTemplateC
= "codeStreamTemplate.C";
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionEntries::codeStream::execute
(
const dictionary& parentDict,
primitiveEntry& entry,
Istream& is
)
{
dynamicCode::checkSecurity
(
"functionEntries::codeStream::execute(..)",
parentDict
);
// get code dictionary
// must reference parent for stringOps::expand to work nicely
dictionary codeDict("#codeStream", parentDict, is);
// get code, codeInclude, codeOptions
dynamicCodeContext context(codeDict);
// codeName: codeStream + _<sha1>
// codeDir : _<sha1>
dynamicCode dynCode
(
"codeStream" + context.sha1().str(true),
context.sha1().str(true)
);
// Load library if not already loaded
// Version information is encoded in the libPath (encoded with the SHA1)
const fileName libPath = dynCode.libPath();
// see if library is loaded
void* lib = dlLibraryTable::findLibrary(libPath);
if (!lib)
{
Info<< "Using #codeStream with " << libPath << endl;
}
// nothing loaded
// avoid compilation if possible by loading an existing library
if (!lib && dlLibraryTable::open(libPath, false))
{
lib = dlLibraryTable::findLibrary(libPath);
}
// create library if required
if (!lib)
{
bool create = Pstream::master();
if (create)
{
if (!dynCode.upToDate(context))
{
// filter with this context
dynCode.reset(context);
// compile filtered C template
dynCode.addCompileFile(codeTemplateC);
// define Make/options
dynCode.setMakeOptions
(
"EXE_INC = -g \\\n"
+ context.options()
+ "\n\nLIB_LIBS ="
);
if (!dynCode.copyOrCreateFiles(true))
{
FatalIOErrorIn
(
"functionEntries::codeStream::execute(..)",
parentDict
) << "Failed writing files for" << nl
<< dynCode.libRelPath() << nl
<< exit(FatalIOError);
}
}
if (!dynCode.wmakeLibso())
{
FatalIOErrorIn
(
"functionEntries::codeStream::execute(..)",
parentDict
) << "Failed wmake " << dynCode.libRelPath() << nl
<< exit(FatalIOError);
}
}
// all processes must wait for compile to finish
reduce(create, orOp<bool>());
if (!dlLibraryTable::open(libPath, false))
{
FatalIOErrorIn
(
"functionEntries::codeStream::execute(..)",
parentDict
) << "Failed loading library " << libPath << nl
<< exit(FatalIOError);
}
lib = dlLibraryTable::findLibrary(libPath);
}
// Find the function handle in the library
streamingFunctionType function =
reinterpret_cast<streamingFunctionType>
(
dlSym(lib, dynCode.codeName())
);
if (!function)
{
FatalIOErrorIn
(
"functionEntries::codeStream::execute(..)",
parentDict
) << "Failed looking up symbol " << dynCode.codeName()
<< " in library " << lib << exit(FatalIOError);
}
// use function to write stream
OStringStream os(is.format());
(*function)(os, parentDict);
// get the entry from this stream
IStringStream resultStream(os.str());
entry.read(parentDict, resultStream);
return true;
}
// ************************************************************************* //

View File

@ -0,0 +1,159 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::functionEntries::codeStream
Description
Dictionary entry that contains C++ OpenFOAM code that is compiled to
generate the entry itself. So
- codeStream reads three entries: 'code', 'codeInclude' (optional),
'codeOptions' (optional)
and uses those to generate library sources inside \f codeStream/
- these get compiled using 'wmake libso'
- the resulting library is loaded in executed with as arguments
\code
(const dictionary& dict, Ostream& os)
\endcode
where the dictionary is the current dictionary.
- the code has to write into Ostream which is then used to construct
the actual dictionary entry.
E.g. to set the internal field of a field:
\verbatim
internalField #codeStream
{
code
#{
const IOdictionary& d = static_cast<const IOdictionary&>(dict);
const fvMesh& mesh = refCast<const fvMesh>(d.db());
scalarField fld(mesh.nCells(), 12.34);
fld.writeEntry("", os);
#};
//- Optional:
codeInclude
#{
#include "fvCFD.H"
#};
//- Optional:
codeOptions
#{
-I$(LIB_SRC)/finiteVolume/lnInclude
#};
};
\endverbatim
Note the \c \#{ ... \c \#} syntax is a 'verbatim' input mode that allows
inputting strings with embedded newlines.
Limitations:
- '~' symbol not allowed inside the code sections.
- probably some other limitations (uses string::expand which expands
\c \$ and \c ~ sequences)
Note
The code to be compiled is stored under the local \f codeStream directory
with a subdirectory name corresponding to the SHA1 of the contents.
The corresponding library code is located under the local
\f codeStream/platforms/$WM_OPTIONS/lib directory in a library
\f libcodeStream_SHA1.so
SourceFiles
codeStream.C
\*---------------------------------------------------------------------------*/
#ifndef codeStream_H
#define codeStream_H
#include "functionEntry.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace functionEntries
{
/*---------------------------------------------------------------------------*\
Class codeStream Declaration
\*---------------------------------------------------------------------------*/
class codeStream
:
public functionEntry
{
//- Interpreter function type
typedef void (*streamingFunctionType)(Ostream&, const dictionary&);
// Private Member Functions
//- Disallow default bitwise copy construct
codeStream(const codeStream&);
//- Disallow default bitwise assignment
void operator=(const codeStream&);
public:
// Static data members
//- Name of the C code template to be used
static const word codeTemplateC;
//- Runtime type information
ClassName("codeStream");
// Member Functions
static bool execute
(
const dictionary& parentDict,
primitiveEntry&,
Istream&
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionEntries
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

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
@ -35,7 +35,7 @@ Description
A functionEntry causes entries to be added/manipulated on the specified
dictionary given an input stream.
In dictionaries, a @c '\#' sigil is typically used for a functionEntry.
In dictionaries, a \c '\#' sigil is typically used for a functionEntry.
SourceFiles
functionEntry.C

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
@ -28,13 +28,13 @@ Description
Specify an include file when reading dictionaries, expects a
single string to follow.
An example of the @c \#include directive:
@verbatim
An example of the \c \#include directive:
\verbatim
#include "includeFile"
@endverbatim
\endverbatim
The usual expansion of environment variables and other constructs
(eg, the @c ~OpenFOAM/ expansion) is retained.
(eg, the \c ~OpenFOAM/ expansion) is retained.
See Also
fileName, string::expand()

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,7 +27,7 @@ Class
Description
Specify a file to include if it exists. Expects a single string to follow.
The @c \#includeIfPresent directive is similar to the @c \#include
The \c \#includeIfPresent directive is similar to the \c \#include
directive, but does not generate an error if the file does not exist.
See Also

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
@ -28,18 +28,18 @@ Description
Specify the input mode when reading dictionaries, expects
a single word to follow.
An example of @c \#inputMode directive:
@verbatim
An example of \c \#inputMode directive:
\verbatim
#inputMode merge
@endverbatim
\endverbatim
The possible input modes:
@param merge merge sub-dictionaries when possible
@param overwrite keep last entry and silently remove previous ones
@param protect keep initial entry and silently ignore subsequent ones
@param warn keep initial entry and warn about subsequent ones
@param error issue a FatalError for duplicate entries
@param default currently identical to merge
\param merge merge sub-dictionaries when possible
\param overwrite keep last entry and silently remove previous ones
\param protect keep initial entry and silently ignore subsequent ones
\param warn keep initial entry and warn about subsequent ones
\param error issue a FatalError for duplicate entries
\param default currently identical to merge
SourceFiles
inputModeEntry.C

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,14 +27,14 @@ Class
Description
Remove a dictionary entry.
The @c \#remove directive takes a list or a single wordRe.
The \c \#remove directive takes a list or a single wordRe.
For example,
@verbatim
\verbatim
#remove entry0
#remove ( entry1 entry2 entry3 otherEntry )
#remove "entry[1-3]"
#remove ( "entry[1-3]" otherEntry )
@endverbatim
\endverbatim
The removal only occurs in the current context.
Removing sub-entries or parent entries is not supported.

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
@ -168,6 +168,9 @@ public:
//- Write
void write(Ostream&) const;
//- Write, optionally with contents only (no keyword, etc)
void write(Ostream&, const bool contentsOnly) const;
//- Return info proxy.
// Used to print token information to a stream
InfoProxy<primitiveEntry> info() 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
@ -44,7 +44,8 @@ void Foam::primitiveEntry::append
if
(
w.size() == 1
disableFunctionEntries
|| w.size() == 1
|| (
!(w[0] == '$' && expandVariable(w, dict))
&& !(w[0] == '#' && expandFunction(w, dict, is))
@ -209,21 +210,43 @@ Foam::primitiveEntry::primitiveEntry(const keyType& key, Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::primitiveEntry::write(Ostream& os) const
void Foam::primitiveEntry::write(Ostream& os, const bool contentsOnly) const
{
os.writeKeyword(keyword());
if (!contentsOnly)
{
os.writeKeyword(keyword());
}
for (label i=0; i<size(); ++i)
{
os << operator[](i);
const token& t = operator[](i);
if (t.type() == token::VERBATIMSTRING)
{
os << token::HASH << token::BEGIN_BLOCK;
os.writeQuoted(t.stringToken(), false);
os << token::HASH << token::END_BLOCK;
}
else
{
os << t;
}
if (i < size()-1)
{
os << token::SPACE;
os << token::SPACE;
}
}
os << token::END_STATEMENT << endl;
if (!contentsOnly)
{
os << token::END_STATEMENT << endl;
}
}
void Foam::primitiveEntry::write(Ostream& os) const
{
this->write(os, false);
}

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
@ -24,8 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "dlLibraryTable.H"
#include <dlfcn.h>
#include "OSspecific.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -56,27 +55,33 @@ Foam::dlLibraryTable::~dlLibraryTable()
{
forAllConstIter(dlLibraryTable, *this, iter)
{
dlclose(iter.key());
dlClose(iter.key());
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::dlLibraryTable::open(const fileName& functionLibName)
bool Foam::dlLibraryTable::open
(
const fileName& functionLibName,
const bool verbose
)
{
if (functionLibName.size())
{
void* functionLibPtr =
dlopen(functionLibName.c_str(), RTLD_LAZY|RTLD_GLOBAL);
void* functionLibPtr = dlOpen(functionLibName);
if (!functionLibPtr)
{
WarningIn
(
"dlLibraryTable::open(const fileName& functionLibName)"
) << "could not load " << dlerror()
<< endl;
if (verbose)
{
WarningIn
(
"dlLibraryTable::open(const fileName&)"
) << "could not load " << functionLibName
<< endl;
}
return false;
}
@ -99,6 +104,50 @@ bool Foam::dlLibraryTable::open(const fileName& functionLibName)
}
bool Foam::dlLibraryTable::close
(
const fileName& functionLibName,
const bool verbose
)
{
void* libPtr = findLibrary(functionLibName);
if (libPtr)
{
loadedLibraries.erase(libPtr);
if (!dlClose(libPtr))
{
if (verbose)
{
WarningIn
(
"dlLibraryTable::close(const fileName&)"
) << "could not close " << functionLibName
<< endl;
}
return false;
}
return true;
}
return false;
}
void* Foam::dlLibraryTable::findLibrary(const fileName& functionLibName)
{
forAllConstIter(dlLibraryTable, loadedLibraries, iter)
{
if (iter() == functionLibName)
{
return iter.key();
}
}
return NULL;
}
bool Foam::dlLibraryTable::open
(
const dictionary& dict,
@ -109,7 +158,7 @@ bool Foam::dlLibraryTable::open
{
fileNameList libNames(dict.lookup(libsEntry));
bool allOpened = (libNames.size() > 0);
bool allOpened = !libNames.empty();
forAll(libNames, i)
{

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
@ -94,8 +94,14 @@ public:
// Member Functions
//- Open the named library
static bool open(const fileName& name);
//- Open the named library, optionally with warnings if problems occur
static bool open(const fileName& name, const bool verbose = true);
//- Close the named library, optionally with warnings if problems occur
static bool close(const fileName& name, const bool verbose = true);
//- Find the handle of the named library
static void* findLibrary(const fileName& name);
//- Open all the libraries listed in the 'libsEntry' entry in the
// given dictionary if present
@ -103,7 +109,7 @@ public:
//- Open all the libraries listed in the 'libsEntry' entry in the
// given dictionary if present and check the additions
// to the give constructor table
// to the given constructor table
template<class TablePtr>
static bool open
(

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

View File

@ -0,0 +1,578 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "dynamicCode.H"
#include "dynamicCodeContext.H"
#include "stringOps.H"
#include "IFstream.H"
#include "OFstream.H"
#include "OSspecific.H"
#include "dictionary.H"
#include "dlLibraryTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
int Foam::dynamicCode::allowSystemOperations
(
Foam::debug::infoSwitch("allowSystemOperations", 0)
);
const Foam::word Foam::dynamicCode::codeTemplateEnvName
= "FOAM_CODE_TEMPLATES";
const Foam::fileName Foam::dynamicCode::codeTemplateDirName
= "codeTemplates/dynamicCode";
const char* Foam::dynamicCode::libTargetRoot =
"LIB = $(PWD)/../platforms/$(WM_OPTIONS)/lib/lib";
const char* Foam::dynamicCode::topDirName = "dynamicCode";
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
void Foam::dynamicCode::checkSecurity
(
const char* title,
const dictionary& dict
)
{
if (isAdministrator())
{
FatalIOErrorIn
(
title,
dict
) << "This code should not be executed by someone with administrator"
<< " rights due to security reasons." << nl
<< "(it writes a shared library which then gets loaded "
<< "using dlopen)"
<< exit(FatalIOError);
}
}
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
(
ISstream& is,
OSstream& os,
const HashTable<string>& mapping
)
{
if (!is.good())
{
FatalErrorIn
(
"dynamicCode::copyAndFilter()"
" const"
) << "Failed opening for reading " << is.name()
<< exit(FatalError);
}
if (!os.good())
{
FatalErrorIn
(
"dynamicCode::copyAndFilter()"
" const"
) << "Failed writing " << os.name()
<< exit(FatalError);
}
// Copy file while rewriting $VARS and ${VARS}
string line;
do
{
is.getLine(line);
// expand according to mapping
// expanding according to env variables might cause too many
// surprises
stringOps::inplaceExpand(line, mapping);
os.writeQuoted(line, false) << nl;
}
while (is.good());
}
bool Foam::dynamicCode::resolveTemplates
(
const UList<fileName>& templateNames,
DynamicList<fileName>& resolvedFiles,
DynamicList<fileName>& badFiles
)
{
// try to get template from FOAM_CODESTREAM_TEMPLATES
const fileName templateDir(Foam::getEnv(codeTemplateEnvName));
bool allOkay = true;
forAll(templateNames, fileI)
{
const fileName& templateName = templateNames[fileI];
fileName file;
if (!templateDir.empty() && isDir(templateDir))
{
file = templateDir/templateName;
if (!isFile(file, false))
{
file.clear();
}
}
// not found - fallback to ~OpenFOAM expansion
if (file.empty())
{
file = findEtcFile(codeTemplateDirName/templateName);
}
if (file.empty())
{
badFiles.append(templateName);
allOkay = false;
}
else
{
resolvedFiles.append(file);
}
}
return allOkay;
}
bool Foam::dynamicCode::writeCommentSHA1(Ostream& os) const
{
const bool hasSHA1 = filterVars_.found("SHA1sum");
if (hasSHA1)
{
os << "/* dynamicCode:\n * SHA1 = ";
os.writeQuoted(filterVars_["SHA1sum"], false) << "\n */\n";
}
return hasSHA1;
}
bool Foam::dynamicCode::createMakeFiles() const
{
// Create Make/files
if (compileFiles_.empty())
{
return false;
}
const fileName dstFile(this->codePath()/"Make/files");
// Create dir
mkDir(dstFile.path());
OFstream os(dstFile);
//Info<< "Writing to " << dstFile << endl;
if (!os.good())
{
FatalErrorIn
(
"dynamicCode::createMakeFiles()"
" const"
) << "Failed writing " << dstFile
<< exit(FatalError);
}
writeCommentSHA1(os);
// Write compile files
forAll(compileFiles_, fileI)
{
os.writeQuoted(compileFiles_[fileI], false) << nl;
}
os << nl
<< libTargetRoot << codeName_.c_str() << nl;
return true;
}
bool Foam::dynamicCode::createMakeOptions() const
{
// Create Make/options
if (compileFiles_.empty() || makeOptions_.empty())
{
return false;
}
const fileName dstFile(this->codePath()/"Make/options");
// Create dir
mkDir(dstFile.path());
OFstream os(dstFile);
//Info<< "Writing to " << dstFile << endl;
if (!os.good())
{
FatalErrorIn
(
"dynamicCode::createMakeOptions()"
" const"
) << "Failed writing " << dstFile
<< exit(FatalError);
}
writeCommentSHA1(os);
os.writeQuoted(makeOptions_, false) << nl;
return true;
}
bool Foam::dynamicCode::writeDigest(const SHA1Digest& sha1) const
{
const fileName file = digestFile();
mkDir(file.path());
OFstream os(file);
sha1.write(os, true) << nl;
return os.good();
}
bool Foam::dynamicCode::writeDigest(const std::string& sha1) const
{
const fileName file = digestFile();
mkDir(file.path());
OFstream os(file);
os << '_';
os.writeQuoted(sha1, false) << nl;
return os.good();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::dynamicCode::dynamicCode(const word& codeName, const word& codeDirName)
:
codeRoot_(stringOps::expand("$FOAM_CASE")/topDirName),
libSubDir_(stringOps::expand("platforms/$WM_OPTIONS/lib")),
codeName_(codeName),
codeDirName_(codeDirName)
{
if (codeDirName_.empty())
{
codeDirName_ = codeName_;
}
clear();
}
// * * * * * * * * * * * * * * * 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();
copyFiles_.clear();
createFiles_.clear();
filterVars_.clear();
filterVars_.set("typeName", codeName_);
filterVars_.set("SHA1sum", SHA1Digest().str());
// provide default Make/options
makeOptions_ =
"EXE_INC = -g\n"
"\n\nLIB_LIBS = ";
}
void Foam::dynamicCode::reset
(
const dynamicCodeContext& context
)
{
clear();
setFilterContext(context);
}
void Foam::dynamicCode::addCompileFile(const fileName& name)
{
compileFiles_.append(name);
}
void Foam::dynamicCode::addCopyFile(const fileName& name)
{
copyFiles_.append(name);
}
void Foam::dynamicCode::addCreateFile
(
const fileName& name,
const string& contents
)
{
createFiles_.append(fileAndContent(name, contents));
}
void Foam::dynamicCode::setFilterContext
(
const dynamicCodeContext& context
)
{
filterVars_.set("localCode", context.localCode());
filterVars_.set("code", context.code());
filterVars_.set("codeInclude", context.include());
filterVars_.set("SHA1sum", context.sha1().str());
}
void Foam::dynamicCode::setFilterVariable
(
const word& key,
const std::string& value
)
{
filterVars_.set(key, value);
}
void Foam::dynamicCode::setMakeOptions(const std::string& content)
{
makeOptions_ = content;
}
bool Foam::dynamicCode::copyOrCreateFiles(const bool verbose) const
{
if (verbose)
{
Info<< "Creating new library in " << this->libRelPath() << endl;
}
if (!allowSystemOperations)
{
FatalErrorIn
(
"dynamicCode::copyOrCreateFiles() const"
) << "Loading a shared library using case-supplied code is not"
<< " enabled by default" << nl
<< "because of security issues. If you trust the code you can"
<< " enable this" << nl
<< "facility be adding to the InfoSwitches setting in the system"
<< " controlDict:" << nl << nl
<< " allowSystemOperations 1" << nl << nl
<< "The system controlDict is either" << nl << nl
<< " ~/.OpenFOAM/$WM_PROJECT_VERSION/controlDict" << nl << nl
<< "or" << nl << nl
<< " $WM_PROJECT_DIR/etc/controlDict" << nl
<< endl
<< exit(FatalError);
}
const label nFiles = compileFiles_.size() + copyFiles_.size();
DynamicList<fileName> resolvedFiles(nFiles);
DynamicList<fileName> badFiles(nFiles);
// resolve template, or add to bad-files
resolveTemplates(compileFiles_, resolvedFiles, badFiles);
resolveTemplates(copyFiles_, resolvedFiles, badFiles);
if (!badFiles.empty())
{
FatalErrorIn
(
"dynamicCode::copyFilesContents(..)"
) << "Could not find the code template(s): "
<< badFiles << nl
<< "Under the $" << codeTemplateEnvName
<< " directory or via via the ~OpenFOAM/"
<< codeTemplateDirName << " expansion"
<< exit(FatalError);
}
// Create dir
const fileName outputDir = this->codePath();
// Create dir
mkDir(outputDir);
// Copy/filter files
forAll(resolvedFiles, fileI)
{
const fileName& srcFile = resolvedFiles[fileI];
const fileName dstFile(outputDir/srcFile.name());
IFstream is(srcFile);
//Info<< "Reading from " << is.name() << endl;
if (!is.good())
{
FatalErrorIn
(
"dynamicCode::copyFilesContents(const fileName&)"
" const"
) << "Failed opening " << srcFile
<< exit(FatalError);
}
OFstream os(dstFile);
//Info<< "Writing to " << dstFile.name() << endl;
if (!os.good())
{
FatalErrorIn
(
"dynamicCode::copyFilesContents(const fileName&)"
" const"
) << "Failed writing " << dstFile
<< exit(FatalError);
}
// Copy lines while expanding variables
copyAndFilter(is, os, filterVars_);
}
// Create files:
forAll(createFiles_, fileI)
{
const fileName dstFile
(
outputDir/stringOps::expand(createFiles_[fileI].first())
);
mkDir(dstFile.path());
OFstream os(dstFile);
//Info<< "Writing to " << createFiles_[fileI].first() << endl;
if (!os.good())
{
FatalErrorIn
(
"dynamicCode::copyOrCreateFiles()"
" const"
) << "Failed writing " << dstFile
<< exit(FatalError);
}
os.writeQuoted(createFiles_[fileI].second(), false) << nl;
}
// Create Make/files + Make/options
createMakeFiles();
createMakeOptions();
writeDigest(filterVars_["SHA1sum"]);
return true;
}
bool Foam::dynamicCode::wmakeLibso() const
{
const Foam::string wmakeCmd("wmake -s libso " + this->codeRelPath());
Info<< "Invoking " << wmakeCmd << endl;
if (Foam::system(wmakeCmd))
{
return false;
}
else
{
return true;
}
}
bool Foam::dynamicCode::upToDate(const SHA1Digest& sha1) const
{
const fileName file = digestFile();
if (!exists(file, false) || SHA1Digest(IFstream(file)()) != sha1)
{
return false;
}
return true;
}
bool Foam::dynamicCode::upToDate(const dynamicCodeContext& context) const
{
return upToDate(context.sha1());
}
// 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

@ -0,0 +1,307 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::dynamicCode
Description
Tools for handling dynamic code compilation
SourceFiles
dynamicCode.C
\*---------------------------------------------------------------------------*/
#ifndef dynamicCode_H
#define dynamicCode_H
#include "Tuple2.H"
#include "SHA1Digest.H"
#include "HashTable.H"
#include "DynamicList.H"
#include "dlLibraryTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class dynamicCodeContext;
class ISstream;
class OSstream;
/*---------------------------------------------------------------------------*\
Class dynamicCode Declaration
\*---------------------------------------------------------------------------*/
class dynamicCode
{
public:
typedef Tuple2<fileName, string> fileAndContent;
private:
// Private data
//- Root for dynamic code compilation
fileName codeRoot_;
//- Subdirectory name for loading libraries
const fileName libSubDir_;
//- Name for code
word codeName_;
//- Name for code subdirectory
word codeDirName_;
//- Files to copy and filter
DynamicList<fileName> compileFiles_;
//- Files to copy and filter
DynamicList<fileName> copyFiles_;
//- Direct contents for files
DynamicList<fileAndContent> createFiles_;
//- Variables to use during filtering
HashTable<string> filterVars_;
//- Contents for Make/options
std::string makeOptions_;
// Private Member Functions
//- Disallow default bitwise copy construct
dynamicCode(const dynamicCode&);
//- Disallow default bitwise assignment
void operator=(const dynamicCode&);
protected:
// Static data members
//- 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
//- Copy lines while expanding variables
static void copyAndFilter
(
ISstream&,
OSstream&,
const HashTable<string>& mapping
);
//- Resolve code-templates via the codeTemplateEnvName
// alternatively in the codeTemplateDirName via Foam::findEtcFile
static bool resolveTemplates
(
const UList<fileName>& templateNames,
DynamicList<fileName>& resolvedFiles,
DynamicList<fileName>& badFiles
);
//- Write SHA1 value as C-comment
bool writeCommentSHA1(Ostream&) const;
//- Copy/create Make/files prior to compilation
bool createMakeFiles() const;
//- Copy/create Make/options prior to compilation
bool createMakeOptions() const;
//- Write digest to Make/SHA1Digest
bool writeDigest(const SHA1Digest&) const;
//- Write digest to Make/SHA1Digest
bool writeDigest(const std::string&) const;
public:
// Static data members
//- Name of the code template environment variable
// Used to located the codeTemplateName
static const word codeTemplateEnvName;
//- Name of the code template sub-directory
// Used when locating the codeTemplateName via Foam::findEtcFile
static const fileName codeTemplateDirName;
//- Flag if system operations are allowed
static int allowSystemOperations;
// Static Member functions
//- 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
//- Construct for a specified code name and code directory name
// Defaults to using the code name for the code directory name
dynamicCode
(
const word& codeName,
const word& codeDirName = ""
);
// Member functions
//- Return the code-name
const word& codeName() const
{
return codeName_;
}
//- Return the code-dirname
const word& codeDirName() const
{
return codeDirName_;
}
//- Root for dynamic code compilation
// Expanded from \$FOAM_CASE/dynamicCode
const fileName& codeRoot() const
{
return codeRoot_;
}
//- Subdirectory name for loading libraries
// Expanded from platforms/\$WM_OPTIONS/lib
fileName libSubDir() const
{
return libSubDir_;
}
//- Path for specified code name
// Corresponds to codeRoot()/codeDirName()
fileName codePath() const
{
return codeRoot_/codeDirName_;
}
//- Library path for specified code name
// Corresponds to codeRoot()/libSubDir()/lib\<codeName\>.so
fileName libPath() const
{
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
{
return codeRoot_/codeDirName_/"Make/SHA1Digest";
}
//- Clear files and variables
void clear();
//- Clear files and reset variables to specified context
void reset(const dynamicCodeContext&);
//- Add a file template name, which will be found and filtered
void addCompileFile(const fileName& name);
//- Add a file template name, which will be found and filtered
void addCopyFile(const fileName& name);
//- Add a file to create with its contents. Will not be filtered
void addCreateFile(const fileName& name, const string& contents);
//- Define filter variables for code, codeInclude, SHA1sum
void setFilterContext(const dynamicCodeContext&);
//- Define a filter variable
void setFilterVariable(const word& key, const std::string& value);
//- Define contents for Make/options
void setMakeOptions(const std::string& content);
//- Verify if the copied code is up-to-date, based on Make/SHA1Digest
bool upToDate(const dynamicCodeContext& context) const;
//- Verify if the copied code is up-to-date, based on Make/SHA1Digest
bool upToDate(const SHA1Digest& sha1) const;
//- Copy/create files prior to compilation
bool copyOrCreateFiles(const bool verbose = false) const;
//- 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;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,77 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "dynamicCodeContext.H"
#include "stringOps.H"
#include "OSHA1stream.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::dynamicCodeContext::dynamicCodeContext(const dictionary& dict)
:
dict_(dict),
code_(stringOps::trim(dict["code"])),
localCode_(),
include_(),
options_()
{
// expand dictionary entries
stringOps::inplaceExpand(code_, dict);
// note: removes any leading/trailing whitespace
// - necessary for compilation options, convenient for includes
// and body.
// optional
if (dict.found("localCode"))
{
localCode_ = stringOps::trim(dict["localCode"]);
stringOps::inplaceExpand(localCode_, dict);
}
// optional
if (dict.found("codeInclude"))
{
include_ = stringOps::trim(dict["codeInclude"]);
stringOps::inplaceExpand(include_, dict);
}
// optional
if (dict.found("codeOptions"))
{
options_ = stringOps::trim(dict["codeOptions"]);
stringOps::inplaceExpand(options_, dict);
}
// calculate SHA1 digest from include, options, localCode, code
OSHA1stream os;
os << include_ << options_ << localCode_ << code_;
sha1_ = os.digest();
}
// ************************************************************************* //

View File

@ -0,0 +1,129 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::dynamicCodeContext
Description
Encapsulation of dynamic code dictionaries
SourceFiles
dynamicCodeContext.C
\*---------------------------------------------------------------------------*/
#ifndef dynamicCodeContext_H
#define dynamicCodeContext_H
#include "dictionary.H"
#include "SHA1Digest.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class dynamicCodeContext Declaration
\*---------------------------------------------------------------------------*/
class dynamicCodeContext
{
// Private data
//- The parent dictionary context
const dictionary& dict_;
//- Mandatory "code" entry
string code_;
//- Optional "localCode" entry
string localCode_;
//- Optional "codeInclude" entry
string include_;
//- Optional "codeOptions" entry
string options_;
//- Calculated SHA1Digest
SHA1Digest sha1_;
public:
// Constructors
//- Construct from a dictionary
dynamicCodeContext(const dictionary&);
// Member functions
//- Return the parent dictionary context
const dictionary& dict() const
{
return dict_;
}
//- Return the code-includes
const string& include() const
{
return include_;
}
//- Return the code-options
const string& options() const
{
return options_;
}
//- Return the code
const string& code() const
{
return code_;
}
//- Return the local (file-scope) code
const string& localCode() const
{
return localCode_;
}
//- Return SHA1 digest calculated from include, options, code
const SHA1Digest& sha1() const
{
return sha1_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -72,7 +72,7 @@ class StaticAssertionTest {};
// external use:
// ~~~~~~~~~~~~~
/**
* @def StaticAssert(Test)
* \def StaticAssert(Test)
* Assert that some test is true at compile-time
*/
#define StaticAssert(Test) \

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
@ -35,10 +35,10 @@ Description
handling has beed switched on (off by default).
Usage
@code
\code
error << "message1" << "message2" << FoamDataType << exit(errNo);
error << "message1" << "message2" << FoamDataType << abort();
@endcode
\endcode
SourceFiles
error.C
@ -296,7 +296,7 @@ extern IOerror FatalIOError;
// Convenience macros to add the file name and line number to the function name
/**
* @def FatalErrorIn(functionName)
* \def FatalErrorIn(functionName)
* Report an error message using Foam::FatalError for functionName in
* file __FILE__ at line __LINE__
*/
@ -304,7 +304,7 @@ extern IOerror FatalIOError;
::Foam::FatalError((fn), __FILE__, __LINE__)
/**
* @def FatalIOErrorIn(functionName, ios)
* \def FatalIOErrorIn(functionName, ios)
* Report an error message using Foam::FatalIOError for functionName in
* file __FILE__ at line __LINE__
* for a particular IOstream
@ -313,12 +313,12 @@ extern IOerror FatalIOError;
::Foam::FatalIOError((fn), __FILE__, __LINE__, (ios))
/**
* @def notImplemented(functionName)
* \def notImplemented(functionName)
* Issue a FatalErrorIn for the functionName.
* This is used for functions that are not currently implemented.
* The functionName is printed and then abort is called.
*
* @note
* \note
* This macro can be particularly useful when methods must be defined to
* complete the interface of a derived class even if they should never be
* called for this derived class.

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
@ -30,10 +30,10 @@ Description
handling has been switched on (off by default).
Usage
@code
\code
error << "message1" << "message2" << FoamDataType << exit(error, errNo);
error << "message1" << "message2" << FoamDataType << abort(error);
@endcode
\endcode
\*---------------------------------------------------------------------------*/

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
@ -34,10 +34,10 @@ Description
the messageStream class in the standard manner.
Usage
@code
\code
messageStream
<< "message1" << "message2" << FoamDataType << endl;
@endcode
\endcode
SourceFiles
messageStream.C
@ -214,7 +214,7 @@ extern messageStream Info;
// Convenience macros to add the file name and line number to the function name
/**
* @def SeriousErrorIn(functionName)
* \def SeriousErrorIn(functionName)
* Report an error message using Foam::SeriousError for functionName in
* file __FILE__ at line __LINE__
*/
@ -222,7 +222,7 @@ extern messageStream Info;
::Foam::SeriousError((fn), __FILE__, __LINE__)
/**
* @def SeriousIOErrorIn(functionName, ios)
* \def SeriousIOErrorIn(functionName, ios)
* Report an IO error message using Foam::SeriousError for functionName in
* file __FILE__ at line __LINE__
* for a particular IOstream
@ -231,7 +231,7 @@ extern messageStream Info;
::Foam::SeriousError((fn), __FILE__, __LINE__, ios)
/**
* @def WarningIn(functionName)
* \def WarningIn(functionName)
* Report a warning using Foam::Warning for functionName in
* file __FILE__ at line __LINE__
*/
@ -239,7 +239,7 @@ extern messageStream Info;
::Foam::Warning((fn), __FILE__, __LINE__)
/**
* @def IOWarningIn(functionName, ios)
* \def IOWarningIn(functionName, ios)
* Report an IO warning using Foam::Warning for functionName in
* file __FILE__ at line __LINE__
* for a particular IOstream
@ -248,7 +248,7 @@ extern messageStream Info;
::Foam::Warning((fn), __FILE__, __LINE__, (ios))
/**
* @def InfoIn(functionName)
* \def InfoIn(functionName)
* Report a information message using Foam::Info for functionName in
* file __FILE__ at line __LINE__
*/
@ -256,7 +256,7 @@ extern messageStream Info;
::Foam::Info((fn), __FILE__, __LINE__)
/**
* @def IOInfoIn(functionName, ios)
* \def IOInfoIn(functionName, ios)
* Report an IO information message using Foam::Info for functionName in
* file __FILE__ at line __LINE__
* for a particular IOstream

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
@ -30,9 +30,9 @@ Description
Note
Since the timeIndex is used directly from Foam::Time, it is unaffected
by user-time conversions. For example, Foam::engineTime might cause @a
by user-time conversions. For example, Foam::engineTime might cause \a
writeInterval to be degrees crank angle, but the functionObject
execution @a interval would still be in timestep.
execution \a interval would still be in timestep.
SourceFiles
OutputFilterFunctionObject.C

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
@ -108,7 +108,7 @@ public:
//- Construct from Time, a dictionary with "functions" entry
// and the execution setting.
// @param[in] parentDict - the parent dictionary containing
// \param[in] parentDict - the parent dictionary containing
// a "functions" entry, which can either be a list or a dictionary
// of functionObject specifications.
functionObjectList

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
@ -74,7 +74,7 @@ private:
//- Type of output
outputControls outputControl_;
//- The execution interval (in time steps) when using @c timeStep mode,
//- The execution interval (in time steps) when using \c timeStep mode,
// a value <= 1 means execute at every time step
label outputInterval_;

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
@ -21,9 +21,6 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
InClass
Foam::runTimeSelectionTables
Description
Macros for easy insertion into run-time selection tables
@ -53,6 +50,26 @@ Description
add_##lookup##_##thisType##argNames##ConstructorTo##baseType##Table_ \
(#lookup)
// add to hash-table of functions with typename as the key
#define addRemovableToRunTimeSelectionTable\
(baseType,thisType,argNames) \
\
/* Add the thisType constructor function to the table */ \
baseType::addRemovable##argNames##ConstructorToTable< thisType > \
addRemovable##thisType##argNames##ConstructorTo##baseType##Table_
// add to hash-table of functions with 'lookup' as the key
#define addRemovableNamedToRunTimeSelectionTable\
(baseType,thisType,argNames,lookup) \
\
/* Add the thisType constructor function to the table, find by lookup */ \
baseType::addRemovable##argNames##ConstructorToTable< thisType > \
addRemovable_##lookup##_##thisType##argNames##ConstructorTo \
##baseType##Table_(#lookup)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

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
@ -21,11 +21,8 @@ License
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::runTimeSelectionTables
Description
Macros to enable the easy declaration of run-time selection tables.
Macros to ease declaration of run-time selection tables.
declareRunTimeSelectionTable is used to create a run-time selection table
for a base-class which holds constructor pointers on the table.
@ -62,6 +59,12 @@ Description
/* Construct from argList function pointer table pointer */ \
static argNames##ConstructorTable* argNames##ConstructorTablePtr_; \
\
/* Table constructor called from the table add function */ \
static void construct##argNames##ConstructorTables(); \
\
/* Table destructor called from the table add function destructor */ \
static void destroy##argNames##ConstructorTables(); \
\
/* Class to add constructor from argList to table */ \
template< class baseType##Type > \
class add##argNames##ConstructorToTable \
@ -88,11 +91,41 @@ Description
} \
}; \
\
/* Table constructor called from the table add function */ \
static void construct##argNames##ConstructorTables(); \
/* Class to add constructor from argList to table */ \
/* Remove only the entry (not the table) upon destruction */ \
template< class baseType##Type > \
class addRemovable##argNames##ConstructorToTable \
{ \
/* retain lookup name for later removal */ \
const word& lookup_; \
\
/* Table destructor called from the table add function destructor */ \
static void destroy##argNames##ConstructorTables()
public: \
\
static autoPtr< baseType > New argList \
{ \
return autoPtr< baseType >(new baseType##Type parList); \
} \
\
addRemovable##argNames##ConstructorToTable \
( \
const word& lookup = baseType##Type::typeName \
) \
: \
lookup_(lookup) \
{ \
construct##argNames##ConstructorTables(); \
argNames##ConstructorTablePtr_->set(lookup, New); \
} \
\
~addRemovable##argNames##ConstructorToTable() \
{ \
if (argNames##ConstructorTablePtr_) \
{ \
argNames##ConstructorTablePtr_->erase(lookup_); \
} \
} \
};
// external use:
@ -111,6 +144,12 @@ Description
/* Construct from argList function pointer table pointer */ \
static argNames##ConstructorTable* argNames##ConstructorTablePtr_; \
\
/* Table constructor called from the table add function */ \
static void construct##argNames##ConstructorTables(); \
\
/* Table destructor called from the table add function destructor */ \
static void destroy##argNames##ConstructorTables(); \
\
/* Class to add constructor from argList to table */ \
template< class baseType##Type > \
class add##argNames##ConstructorToTable \
@ -141,11 +180,43 @@ Description
} \
}; \
\
/* Table constructor called from the table add function */ \
static void construct##argNames##ConstructorTables(); \
/* Class to add constructor from argList to table */ \
template< class baseType##Type > \
class addRemovable##argNames##ConstructorToTable \
{ \
/* retain lookup name for later removal */ \
const word& lookup_; \
\
/* Table destructor called from the table add function destructor */ \
static void destroy##argNames##ConstructorTables()
public: \
\
static autoPtr< baseType > New##baseType argList \
{ \
return autoPtr< baseType >(baseType##Type::New parList.ptr()); \
} \
\
addRemovable##argNames##ConstructorToTable \
( \
const word& lookup = baseType##Type::typeName \
) \
: \
lookup_(lookup) \
{ \
construct##argNames##ConstructorTables(); \
argNames##ConstructorTablePtr_->set \
( \
lookup, \
New##baseType \
); \
} \
\
~addRemovable##argNames##ConstructorToTable() \
{ \
if (argNames##ConstructorTablePtr_) \
{ \
argNames##ConstructorTablePtr_->erase(lookup_); \
} \
} \
};
// internal use:
@ -157,13 +228,11 @@ Description
void baseType::construct##argNames##ConstructorTables() \
{ \
static bool constructed = false; \
\
if (!constructed) \
{ \
constructed = true; \
baseType::argNames##ConstructorTablePtr_ \
= new baseType::argNames##ConstructorTable; \
\
constructed = true; \
} \
}
@ -244,13 +313,11 @@ Description
void baseType< Targ >::construct##argNames##ConstructorTables() \
{ \
static bool constructed = false; \
\
if (!constructed) \
{ \
constructed = true; \
baseType< Targ >::argNames##ConstructorTablePtr_ \
= new baseType< Targ >::argNames##ConstructorTable; \
\
constructed = true; \
} \
}

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
@ -21,7 +21,8 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
@file Foam::addToGlobalFunctionSelectionTable
Global
Foam::addToGlobalFunctionSelectionTable
Description
Macros for easy insertion into global function selection tables
@ -33,20 +34,18 @@ Description
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// add to hash-table of functions with 'lookup' as the key
#define addNamedToGlobalFunctionSelectionTable\
(memberFunction,argNames,lookup,functionPtr) \
\
/* Add to the table, find by lookup name */ \
add##memberFunction##argNames##GlobalMemberFunctionToTable \
add_##lookup##_##memberFunction##argNames##GlobalMemberFunctionTo##Table_\
add_##lookup##_##memberFunction##argNames##GlobalMemberFunctionTo##Table_ \
(#lookup, functionPtr)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

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
@ -21,7 +21,8 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
@file Foam::globalFunctionSelectionTables
Global
Foam::globalFunctionSelectionTables
Description
Macros to enable the easy declaration of global function selection tables.
@ -35,7 +36,6 @@ Description
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// external use:
// ~~~~~~~~~~~~~
// declare a run-time selection:
@ -85,13 +85,14 @@ Description
} \
}
// internal use:
// constructor/destructor aid
#define defineGlobalFunctionSelectionTableConstructDestruct\
(memberFunction,argNames) \
\
/* Table constructor called from the table add function */ \
void construct##memberFunction##argNames##MemberFunctionTables()\
void construct##memberFunction##argNames##MemberFunctionTables() \
{ \
static bool constructed = false; \
if (!constructed) \
@ -103,7 +104,7 @@ Description
} \
\
/* Table destructor called from the table add function destructor */ \
void destroy##memberFunction##argNames##MemberFunctionTables()\
void destroy##memberFunction##argNames##MemberFunctionTables() \
{ \
if (memberFunction##argNames##MemberFunctionTablePtr_) \
{ \
@ -138,7 +139,6 @@ Description
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

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
@ -98,13 +98,11 @@ Description
void baseType::construct##memberFunction##argNames##MemberFunctionTables()\
{ \
static bool constructed = false; \
\
if (!constructed) \
{ \
constructed = true; \
baseType::memberFunction##argNames##MemberFunctionTablePtr_ \
= new baseType::memberFunction##argNames##MemberFunctionTable;\
\
constructed = true; \
} \
}
@ -191,14 +189,12 @@ Description
MemberFunctionTables() \
{ \
static bool constructed = false; \
\
if (!constructed) \
{ \
constructed = true; \
baseType<Targ>::memberFunction##argNames##MemberFunctionTablePtr_ \
= new baseType<Targ>::memberFunction##argNames## \
MemberFunctionTable; \
\
constructed = true; \
} \
}
@ -254,6 +250,7 @@ Description
defineTemplatedMemberFunctionSelectionTableDestructor \
(baseType,memberFunction,argNames,Targ)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif

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
@ -21,7 +21,8 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
@file Foam::addToStaticMemberFunctionSelectionTable
Global
Foam::addToStaticMemberFunctionSelectionTable
Description
Macros for easy insertion into member function selection tables
@ -47,7 +48,6 @@ Description
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

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
@ -21,7 +21,8 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
@file Foam::staticMemberFunctionSelectionTables
Global
Foam::staticMemberFunctionSelectionTables
Description
Macros to enable the easy declaration of member function selection tables.
@ -35,7 +36,6 @@ Description
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// external use:
// ~~~~~~~~~~~~~
// declare a run-time selection:
@ -140,7 +140,6 @@ Description
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

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,19 +39,19 @@ Description
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//- Add typeName information from argument @a TypeNameString to a class.
//- Add typeName information from argument \a TypeNameString to a class.
// Without debug information
#define ClassNameNoDebug(TypeNameString) \
static const char* typeName_() { return TypeNameString; } \
static const ::Foam::word typeName
//- Add typeName information from argument @a TypeNameString to a namespace.
//- Add typeName information from argument \a TypeNameString to a namespace.
// Without debug information.
#define NamespaceNameNoDebug(TypeNameString) \
inline const char* typeName_() { return TypeNameString; } \
extern const ::Foam::word typeName
//- Add typeName information from argument @a TemplateNameString to a
//- Add typeName information from argument \a TemplateNameString to a
// template class. Without debug information.
#define TemplateNameNoDebug(TemplateNameString) \
class TemplateNameString##Name \
@ -68,19 +68,19 @@ public: \
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//- Add typeName information from argument @a TypeNameString to a class.
//- Add typeName information from argument \a TypeNameString to a class.
// Also declares debug information.
#define ClassName(TypeNameString) \
ClassNameNoDebug(TypeNameString); \
static int debug
//- Add typeName information from argument @a TypeNameString to a namespace.
//- Add typeName information from argument \a TypeNameString to a namespace.
// Also declares debug information.
#define NamespaceName(TypeNameString) \
NamespaceNameNoDebug(TypeNameString); \
extern int debug
//- Add typeName information from argument @a TypeNameString to a
//- Add typeName information from argument \a TypeNameString to a
// template class. Also declares debug information.
#define TemplateName(TemplateNameString) \
class TemplateNameString##Name \
@ -97,7 +97,7 @@ public: \
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//- Define the typeName, with alternative lookup as @a Name
//- Define the typeName, with alternative lookup as \a Name
#define defineTypeNameWithName(Type, Name) \
const ::Foam::word Type::typeName(Name)
@ -106,18 +106,18 @@ public: \
defineTypeNameWithName(Type, Type::typeName_())
#ifdef __INTEL_COMPILER
//- Define the typeName as @a Name for template classes
//- Define the typeName as \a Name for template classes
# define defineTemplateTypeNameWithName(Type, Name) \
defineTypeNameWithName(Type, Name)
//- Define the typeName as @a Name for template sub-classes
//- Define the typeName as \a Name for template sub-classes
# define defineTemplate2TypeNameWithName(Type, Name) \
defineTypeNameWithName(Type, Name)
#else
//- Define the typeName as @a Name for template classes
//- Define the typeName as \a Name for template classes
# define defineTemplateTypeNameWithName(Type, Name) \
template<> \
defineTypeNameWithName(Type, Name)
//- Define the typeName as @a Name for template sub-classes
//- Define the typeName as \a Name for template sub-classes
# define defineTemplate2TypeNameWithName(Type, Name) \
template<> \
template<> \
@ -139,7 +139,7 @@ public: \
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//- Define the debug information, lookup as @a Name
//- Define the debug information, lookup as \a Name
#define defineDebugSwitchWithName(Type, Name, DebugSwitch) \
int Type::debug(::Foam::debug::debugSwitch(Name, DebugSwitch))
@ -148,18 +148,18 @@ public: \
defineDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch)
#ifdef __INTEL_COMPILER
//- Define the debug information for templates, lookup as @a Name
//- Define the debug information for templates, lookup as \a Name
# define defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch) \
defineDebugSwitchWithName(Type, Name, DebugSwitch)
//- Define the debug information for templates sub-classes, lookup as @a Name
//- Define the debug information for templates sub-classes, lookup as \a Name
# define defineTemplate2DebugSwitchWithName(Type, Name, DebugSwitch) \
defineDebugSwitchWithName(Type, Name, DebugSwitch)
#else
//- Define the debug information for templates, lookup as @a Name
//- Define the debug information for templates, lookup as \a Name
# define defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch) \
template<> \
defineDebugSwitchWithName(Type, Name, DebugSwitch)
//- Define the debug information for templates sub-classes, lookup as @a Name
//- Define the debug information for templates sub-classes, lookup as \a Name
# define defineTemplate2DebugSwitchWithName(Type, Name, DebugSwitch) \
template<> \
template<> \
@ -199,7 +199,7 @@ public: \
defineTypeName(Type); \
defineDebugSwitch(Type, DebugSwitch)
//- Define the typeName and debug information, lookup as @a Name
//- Define the typeName and debug information, lookup as \a Name
#define defineTemplateTypeNameAndDebugWithName(Type, Name, DebugSwitch) \
defineTemplateTypeNameWithName(Type, Name); \
defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch)
@ -216,7 +216,7 @@ public: \
// for templated sub-classes
//- Define the typeName and debug information, lookup as @a Name
//- Define the typeName and debug information, lookup as \a Name
#define defineTemplate2TypeNameAndDebugWithName(Type, Name, DebugSwitch) \
defineTemplate2TypeNameWithName(Type, Name); \
defineTemplate2DebugSwitchWithName(Type, Name, DebugSwitch)

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
@ -29,22 +29,22 @@ Description
Used to enhance the standard RTTI to cover I/O.
The user can get the type's type name using the type info access function
@code
\code
type()
@endcode
\endcode
The reference type cast template function:
@code
\code
refCast<T>(r)
@endcode
\endcode
wraps dynamic_cast to handle the bad_cast exception and generate a
FatalError.
The isA function:
@code
\code
isA<T>(r)
@endcode
\endcode
returns true if r is of type T or derived from type T.

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
@ -46,11 +46,11 @@ UNARY_FUNCTION(tensor, tensor, dev2, transform)
UNARY_FUNCTION(scalar, tensor, det, transform)
UNARY_FUNCTION(tensor, tensor, cof, cof)
UNARY_FUNCTION(tensor, tensor, inv, inv)
UNARY_FUNCTION(vector, tensor, eigenValues, sign)
UNARY_FUNCTION(tensor, tensor, eigenVectors, transform)
UNARY_FUNCTION(vector, tensor, eigenValues, transform)
UNARY_FUNCTION(tensor, tensor, eigenVectors, sign)
UNARY_FUNCTION(vector, symmTensor, eigenValues, sign)
UNARY_FUNCTION(symmTensor, symmTensor, eigenVectors, transform)
UNARY_FUNCTION(vector, symmTensor, eigenValues, transform)
UNARY_FUNCTION(symmTensor, symmTensor, eigenVectors, sign)
// * * * * * * * * * * * * * * * global operators * * * * * * * * * * * * * //

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
@ -59,11 +59,11 @@ UNARY_FUNCTION(tensor, tensor, dev2, transform)
UNARY_FUNCTION(scalar, tensor, det, transform)
UNARY_FUNCTION(tensor, tensor, cof, cof)
UNARY_FUNCTION(tensor, tensor, inv, inv)
UNARY_FUNCTION(vector, tensor, eigenValues, sign)
UNARY_FUNCTION(tensor, tensor, eigenVectors, transform)
UNARY_FUNCTION(vector, tensor, eigenValues, transform)
UNARY_FUNCTION(tensor, tensor, eigenVectors, sign)
UNARY_FUNCTION(vector, symmTensor, eigenValues, sign)
UNARY_FUNCTION(symmTensor, symmTensor, eigenVectors, transform)
UNARY_FUNCTION(vector, symmTensor, eigenValues, transform)
UNARY_FUNCTION(symmTensor, symmTensor, eigenVectors, sign)
// * * * * * * * * * * * * * * * global operators * * * * * * * * * * * * * //

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
@ -46,11 +46,17 @@ Foam::List<T> Foam::transform
template <class T>
void Foam::transformList
(
const tensorField& rotTensor,
UList<T>& field
)
void Foam::transformList(const tensor& rotTensor, UList<T>& field)
{
forAll(field, i)
{
field[i] = transform(rotTensor, field[i]);
}
}
template <class T>
void Foam::transformList(const tensorField& rotTensor, UList<T>& field)
{
if (rotTensor.size() == 1)
{
@ -79,11 +85,17 @@ void Foam::transformList
template <class T>
void Foam::transformList
(
const tensorField& rotTensor,
Map<T>& field
)
void Foam::transformList(const tensor& rotTensor, Map<T>& field)
{
forAllIter(typename Map<T>, field, iter)
{
iter() = transform(rotTensor[0], iter());
}
}
template <class T>
void Foam::transformList(const tensorField& rotTensor, Map<T>& field)
{
if (rotTensor.size() == 1)
{
@ -105,11 +117,17 @@ void Foam::transformList
template <class T>
void Foam::transformList
(
const tensorField& rotTensor,
EdgeMap<T>& field
)
void Foam::transformList(const tensor& rotTensor, EdgeMap<T>& field)
{
forAllIter(typename EdgeMap<T>, field, iter)
{
iter() = transform(rotTensor[0], iter());
}
}
template <class T>
void Foam::transformList(const tensorField& rotTensor, EdgeMap<T>& field)
{
if (rotTensor.size() == 1)
{

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
@ -60,33 +60,57 @@ List<T> transform
//- Apply transformation to list. Either single transformation tensor
// or one tensor per element.
template<class T>
void transformList(const tensor&, UList<T>&);
template<class T>
void transformList(const tensorField&, UList<T>&);
template<class T>
void transformList(const tensor&, Map<T>&);
template<class T>
void transformList(const tensorField&, Map<T>&);
template<class T>
void transformList(const tensor&, EdgeMap<T>&);
template<class T>
void transformList(const tensorField&, EdgeMap<T>&);
template<>
inline void transformList(const tensor&, labelUList&)
{}
template<>
inline void transformList(const tensorField&, labelUList&)
{}
template<>
inline void transformList(const tensor&, Map<label>&)
{}
template<>
inline void transformList(const tensorField&, Map<label>&)
{}
template<>
inline void transformList(const tensor&, EdgeMap<label>&)
{}
template<>
inline void transformList(const tensorField&, EdgeMap<label>&)
{}
template<>
inline void transformList(const tensor&, UList<scalar>&)
{}
template<>
inline void transformList(const tensorField&, UList<scalar>&)
{}
template<>
inline void transformList(const tensor&, Map<scalar>&)
{}
template<>
inline void transformList(const tensorField&, Map<scalar>&)
{}
template<>
inline void transformList(const tensor&, EdgeMap<scalar>&)
{}
template<>
inline void transformList(const tensorField&, EdgeMap<scalar>&)
{}

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
@ -95,17 +95,22 @@ Foam::tmp
>
Foam::GeometricField<Type, PatchField, GeoMesh>::readField(Istream& is)
{
if (is.version() < 2.0)
{
FatalIOErrorIn
return readField
(
IOdictionary
(
"GeometricField<Type, PatchField, GeoMesh>::readField(Istream&)",
IOobject
(
this->name(),
this->time().timeName(),
this->db(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
is
) << "IO versions < 2.0 are not supported."
<< exit(FatalIOError);
}
return readField(dictionary(is));
)
);
}
@ -384,45 +389,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
}
template<class Type, template<class> class PatchField, class GeoMesh>
Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
(
const IOobject& io,
const Mesh& mesh,
Istream& is
)
:
DimensionedField<Type, GeoMesh>(io, mesh, dimless, false),
timeIndex_(this->time().timeIndex()),
field0Ptr_(NULL),
fieldPrevIterPtr_(NULL),
boundaryField_(*this, readField(is))
{
// Check compatibility between field and mesh
if (this->size() != GeoMesh::size(this->mesh()))
{
FatalIOErrorIn
(
"GeometricField<Type, PatchField, GeoMesh>::GeometricField"
"(const IOobject&, const Mesh&, Istream&)",
is
) << " number of field elements = " << this->size()
<< " number of mesh elements = " << GeoMesh::size(this->mesh())
<< exit(FatalIOError);
}
readOldTimeIfPresent();
if (debug)
{
Info<< "Finishing read-construct of "
"GeometricField<Type, PatchField, GeoMesh>"
<< endl << this->info() << endl;
}
}
template<class Type, template<class> class PatchField, class GeoMesh>
Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
(

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
@ -325,14 +325,6 @@ public:
const Mesh&
);
//- Construct and read from given stream
GeometricField
(
const IOobject&,
const Mesh&,
Istream&
);
//- Construct from dictionary
GeometricField
(

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
@ -47,11 +47,11 @@ UNARY_FUNCTION(tensor, tensor, dev2, transform)
UNARY_FUNCTION(scalar, tensor, det, transform)
UNARY_FUNCTION(tensor, tensor, cof, cof)
UNARY_FUNCTION(tensor, tensor, inv, inv)
UNARY_FUNCTION(vector, tensor, eigenValues, sign)
UNARY_FUNCTION(tensor, tensor, eigenVectors, transform)
UNARY_FUNCTION(vector, tensor, eigenValues, transform)
UNARY_FUNCTION(tensor, tensor, eigenVectors, sign)
UNARY_FUNCTION(vector, symmTensor, eigenValues, sign)
UNARY_FUNCTION(symmTensor, symmTensor, eigenVectors, transform)
UNARY_FUNCTION(vector, symmTensor, eigenValues, transform)
UNARY_FUNCTION(symmTensor, symmTensor, eigenVectors, sign)
// * * * * * * * * * * * * * * * global operators * * * * * * * * * * * * * //

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
@ -60,11 +60,11 @@ UNARY_FUNCTION(tensor, tensor, dev2, transform)
UNARY_FUNCTION(scalar, tensor, det, transform)
UNARY_FUNCTION(tensor, tensor, cof, cof)
UNARY_FUNCTION(tensor, tensor, inv, inv)
UNARY_FUNCTION(vector, tensor, eigenValues, sign)
UNARY_FUNCTION(tensor, tensor, eigenVectors, transform)
UNARY_FUNCTION(vector, tensor, eigenValues, transform)
UNARY_FUNCTION(tensor, tensor, eigenVectors, sign)
UNARY_FUNCTION(vector, symmTensor, eigenValues, sign)
UNARY_FUNCTION(symmTensor, symmTensor, eigenVectors, transform)
UNARY_FUNCTION(vector, symmTensor, eigenValues, transform)
UNARY_FUNCTION(symmTensor, symmTensor, eigenVectors, sign)
// * * * * * * * * * * * * * * * global operators * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -61,7 +61,7 @@ Foam::UniformDimensionedField<Type>::UniformDimensionedField
{
dictionary dict(readStream(typeName));
this->dimensions().reset(dict.lookup("dimensions"));
this->value() = dict.lookup("value");
dict.lookup("value") >> this->value();
}

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
@ -41,7 +41,7 @@ Foam::cloud::cloud(const objectRegistry& obr, const word& cloudName)
(
IOobject
(
( cloudName.size() ? cloudName : defaultName ),
(cloudName.size() ? cloudName : defaultName),
obr.time().timeName(),
prefix,
obr,
@ -58,4 +58,12 @@ Foam::cloud::~cloud()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::cloud::autoMap(const mapPolyMesh&)
{
notImplemented("cloud::autoMap(const mapPolyMesh&)");
}
// ************************************************************************* //

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,7 @@ public:
//- Remap the cells of particles corresponding to the
// mesh topology change
virtual void autoMap(const mapPolyMesh&) = 0;
virtual void autoMap(const mapPolyMesh&);
};

View File

@ -32,6 +32,7 @@ License
#include "JobInfo.H"
#include "labelList.H"
#include "regIOobject.H"
#include "dynamicCode.H"
#include <cctype>
@ -507,13 +508,23 @@ Foam::argList::argList
jobInfo.add("startTime", timeString);
jobInfo.add("userName", userName());
jobInfo.add("foamVersion", word(FOAMversion));
jobInfo.add("foamBuild", Foam::FOAMbuild);
jobInfo.add("code", executable_);
jobInfo.add("argList", argListString);
jobInfo.add("currentDir", cwd());
jobInfo.add("PPID", ppid());
jobInfo.add("PGID", pgid());
// add build information - only use the first word
{
std::string build(Foam::FOAMbuild);
std::string::size_type found = build.find(' ');
if (found != std::string::npos)
{
build.resize(found);
}
jobInfo.add("foamBuild", build);
}
// Case is a single processor run unless it is running parallel
int nProcs = 1;
@ -777,6 +788,16 @@ Foam::argList::argList
regIOobject::fileModificationChecking
]
<< endl;
Info<< "allowSystemOperations : ";
if (dynamicCode::allowSystemOperations)
{
Info<< "Allowing user-supplied system call operations" << endl;
}
else
{
Info<< "Disallowing user-supplied system call operations" << endl;
}
}
if (Pstream::master() && bannerEnabled)
@ -883,9 +904,10 @@ void Foam::argList::printUsage() const
printNotes();
Info<< nl
<<"Using OpenFOAM-" << Foam::FOAMversion
<<" (build: " << Foam::FOAMbuild << ") - see www.OpenFOAM.com"
<< nl << endl;
<<"Using: OpenFOAM-" << Foam::FOAMversion
<< " (see www.OpenFOAM.com)" << nl
<<"Build: " << Foam::FOAMbuild << nl
<< endl;
}

View File

@ -26,38 +26,38 @@ Class
Description
Extract command arguments and options from the supplied
@a argc and @a argv parameters.
\a argc and @a argv parameters.
Sequences with "(" ... ")" are transformed into a stringList.
For example,
@verbatim
\verbatim
program -listFiles \( *.txt \)
@endverbatim
\endverbatim
would create a stringList:
@verbatim
\verbatim
( "file1.txt" "file2.txt" ... "fileN.txt" )
@endverbatim
\endverbatim
The backslash-escaping is required to avoid interpretation by the shell.
@par Default command-line options
@param -case \<dir\> \n
\par Default command-line options
\param -case \<dir\> \n
select an case directory instead of the current working directory
@param -parallel \n
\param -parallel \n
specify case as a parallel job
@param -doc \n
\param -doc \n
display the documentation in browser
@param -srcDoc \n
\param -srcDoc \n
display the source documentation in browser
@param -help \n
\param -help \n
print the usage
The environment variable @b FOAM_CASE is set to the path of the
The environment variable \b FOAM_CASE is set to the path of the
global case (same for serial and parallel jobs).
The environment variable @b FOAM_CASENAME is set to the name of the
The environment variable \b FOAM_CASENAME is set to the name of the
global case.
Note
- The document browser used is defined by the @b FOAM_DOC_BROWSER
- The document browser used is defined by the \b FOAM_DOC_BROWSER
environment variable or the <tt>Documentation/docBrowser</tt> entry
in the <tt>~OpenFOAM/controlDict</tt> file.
The \%f token is used as a placeholder for the file name.
@ -168,14 +168,14 @@ public:
//- Max screen width for displaying usage (default: 80)
static string::size_type usageMax;
//! @cond internalClass
//! \cond internalClass
class initValidTables
{
public:
initValidTables();
};
//! @endcond
//! \endcond
// Constructors
@ -230,7 +230,7 @@ public:
inline T argRead(const label index) const;
//- Return arguments that are additional to the executable
// @deprecated use operator[] directly (deprecated Feb 2010)
// \deprecated use operator[] directly (deprecated Feb 2010)
stringList::subList additionalArgs() const
{
return stringList::subList(args_, args_.size()-1, 1);
@ -292,7 +292,7 @@ public:
inline const string& operator[](const label index) const;
//- Return the argument string associated with the named option
// @sa option()
// \sa option()
inline const string& operator[](const word& opt) const;
// Edit

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
@ -38,7 +38,7 @@ namespace Foam
namespace debug
{
//! @cond ignoreDocumentation - local scope
//! \cond ignoreDocumentation - local scope
dictionary* controlDictPtr_(NULL);
dictionary* debugSwitchesPtr_(NULL);
dictionary* infoSwitchesPtr_(NULL);
@ -63,7 +63,7 @@ public:
};
deleteControlDictPtr deleteControlDictPtr_;
//! @endcond
//! \endcond
} // End namespace debug

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
@ -49,7 +49,7 @@ namespace debug
{
//- The central control dictionary.
// Located in ~/.OpenFOAM/VERSION or $WM_PROJECT_DIR/etc
// @sa Foam::findEtcFile()
// \sa Foam::findEtcFile()
dictionary& controlDict();
//- The DebugSwitches sub-dictionary in the central controlDict.

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
@ -21,9 +21,9 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
@mainpage OpenFOAM&reg;: open source CFD
\mainpage OpenFOAM&reg;: open source CFD
@section about About OpenFOAM
\section about About OpenFOAM
OpenFOAM is a free, open source CFD software package produced by
a commercial company,
@ -35,7 +35,7 @@ License
heat transfer, to solid dynamics and electromagnetics.
<a href="http://www.openfoam.com/features">More ...</a>
@section users Our commitment to the users
\section users Our commitment to the users
OpenFOAM comes with full commercial support from OpenCFD, including
<a href="http://www.openfoam.com/support/software.php">
@ -48,7 +48,7 @@ License
These activities fund the development, maintenance and release of
OpenFOAM to make it an extremely viable commercial open source product.
@section opensource Our commitment to open source
\section opensource Our commitment to open source
OpenCFD is committed to open source software, continually developing and
maintaining OpenFOAM under the

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -53,6 +53,18 @@ inline scalar radToDeg(const scalar rad)
return (rad * 180.0/constant::mathematical::pi);
}
//- Conversion from atm to Pa
inline scalar atmToPa(const scalar atm)
{
return (atm * 101035.0);
}
//- Conversion from atm to Pa
inline scalar paToAtm(const scalar pa)
{
return (pa / 101035.0);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

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
@ -25,7 +25,7 @@ Class
Foam::xmgrGraph
Description
Output and @b agr file for @em xmgrace
Output and \b agr file for \em xmgrace
(http://plasma-gate.weizmann.ac.il/Grace/)
SourceFiles

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
@ -65,7 +65,7 @@ bool env(const word&);
string getEnv(const word&);
//- Set an environment variable
bool setEnv(const word& name, const string& value, const bool overwrite);
bool setEnv(const word& name, const std::string& value, const bool overwrite);
//- Return the system's host name, as per hostname(1)
// Optionally with the full name (as per the '-f' option)
@ -77,6 +77,9 @@ word domainName();
//- Return the user's login name
word userName();
//- Is user administrator
bool isAdministrator();
//- Return home directory path name for the current user
fileName home();
@ -90,7 +93,8 @@ fileName cwd();
// else return false
bool chDir(const fileName& dir);
//- Search for @em name in the following hierarchy:
//- Search for \em name
// in the following hierarchy:
// -# personal settings:
// - ~/.OpenFOAM/\<VERSION\>/
// <em>for version-specific files</em>
@ -104,7 +108,7 @@ bool chDir(const fileName& dir);
// -# shipped settings:
// - $WM_PROJECT_DIR/etc/
//
// @return the full path name or fileName() if the name cannot be found
// \return the full path name or fileName() if the name cannot be found
// Optionally abort if the file cannot be found
fileName findEtcFile(const fileName&, bool mandatory=false);
@ -178,7 +182,20 @@ bool ping(const word&, const label port, const label timeOut);
bool ping(const word&, const label timeOut=10);
//- Execute the specified command
int system(const string& command);
int system(const std::string& command);
//- open a shared library. Return handle to library
void* dlOpen(const fileName& lib);
//- Close a dlopened library using handle. Return true if successful
bool dlClose(void*);
//- Lookup a symbol in a dlopened library using handle to library
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);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

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
@ -25,13 +25,13 @@ Class
Foam::interpolationTable
Description
An interpolation/look-up table of scalar vs <Type> values.
An interpolation/look-up table of scalar vs \<Type\> values.
The reference scalar values must be monotonically increasing.
The handling of out-of-bounds values depends on the current setting
of @a outOfBounds.
of \a outOfBounds.
If @a REPEAT is chosen for the out-of-bounds handling, the final time
If \a REPEAT is chosen for the out-of-bounds handling, the final time
value is treated as being equivalent to time=0 for the following periods.
Note

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -30,7 +30,7 @@ Description
Example usage (scalar): values specified within a dictionary:
@verbatim
\verbatim
{
x0 0; // lower limit
dx 0.2; // fixed interval
@ -43,7 +43,7 @@ Description
7870 // value at x0 + n*dx
);
}
@endverbatim
\endverbatim
SourceFiles
uniformInterpolationTable.C

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,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::DiagonalMatrix<Type>
Foam::DiagonalMatrix
Description
DiagonalMatrix<Type> is a 2D diagonal matrix of objects

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
@ -260,6 +260,11 @@ void Foam::LUscalarMatrix::convert
}
else if (interface.myProcNo_ < interface.neighbProcNo_)
{
// Interface to neighbour proc. Find on neighbour proc the
// corresponding interface. The problem is that there can
// be multiple interfaces between two processors (from
// processorCyclics) so also compare the communication tag
const PtrList<procLduInterface>& neiInterfaces =
lduMatrices[interface.neighbProcNo_].interfaces_;
@ -269,8 +274,11 @@ void Foam::LUscalarMatrix::convert
{
if
(
neiInterfaces[ninti].neighbProcNo_
== interface.myProcNo_
(
neiInterfaces[ninti].neighbProcNo_
== interface.myProcNo_
)
&& (neiInterfaces[ninti].tag_ == interface.tag_)
)
{
neiInterfacei = ninti;

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