Merge branch 'master' of ssh://noisy/home/noisy3/OpenFOAM/OpenFOAM-dev

This commit is contained in:
sergio
2011-02-24 09:39:20 +00:00
91 changed files with 1544 additions and 225806 deletions

View File

@ -278,3 +278,7 @@
+ multipleBoxes, hotBoxes, panel, evaporationTest
+ =interDyMFoam= tutorials:
+ testTubeMixer: showcases =solidBodyMotionFunction=
* Other
+ compilable with =clang=
In your prefs.sh set the WM_COMPILER to Clang

View File

@ -44,7 +44,7 @@ Description
Note:
Only the pair h, Ta or q can be specified in the dictionary.
SourceFiles
externalWallHeatFluxTemperatureFvPatchScalarField.C

View File

@ -172,7 +172,7 @@
i,
radiation::radiationModel::New(thermoFluid[i].T())
);
initialMassFluid[i] = fvc::domainIntegrate(rhoFluid[i]).value();
Info<< " Adding to DpDtFluid\n" << endl;

View File

@ -13,9 +13,9 @@
hEqn.solve(mesh.solver(h.select(finalIter)));
thermo.correct();
rad.correct();
Info<< "Min/max T:" << min(thermo.T()).value() << ' '
<< max(thermo.T()).value() << endl;
}

View File

@ -18,7 +18,7 @@
const surfaceScalarField& ghf = ghfFluid[i];
radiation::radiationModel& rad = radiation[i];
const dimensionedScalar initialMass
(
"initialMass",

View File

@ -0,0 +1,3 @@
Test-codeStream.C
EXE = $(FOAM_USER_APPBIN)/Test-codeStream

View File

@ -0,0 +1 @@
EXE_INC =

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) 2011-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -21,60 +21,55 @@ License
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
Application
Test-codeStream
Description
Contains global functions and classes for the calcEntry.
SourceFiles
calcEntryInternal.C
\*---------------------------------------------------------------------------*/
#ifndef calcEntryInternal_H
#define calcEntryInternal_H
#include "argList.H"
#include "IOstreams.H"
#include "IOobject.H"
#include "IFstream.H"
#include "dictionary.H"
#include "error.H"
#include "scalar.H"
#include "DynamicList.H"
#include "globalFunctionSelectionTables.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
namespace Foam
{
namespace functionEntries
{
namespace calcEntryInternal
int main(int argc, char *argv[])
{
argList::noParallel();
argList::validArgs.insert("dict .. dictN");
argList args(argc, argv, false, true);
// Global Function Selectors
Info<< nl
<< "FOAM_CASE=" << getEnv("FOAM_CASE") << nl
<< "FOAM_CASENAME=" << getEnv("FOAM_CASENAME") << nl
<< endl;
declareGlobalFunctionSelectionTable
(
scalar,
dispatch,
ParamList,
(
const UList<scalar>& param
),
(param)
);
if (args.size() <= 1)
{
Info<<"specify dictionaries to test\n";
}
else
{
IOobject::writeDivider(Info);
for (label argI=1; argI < args.size(); ++argI)
{
const string& dictFile = args[argI];
IFstream is(dictFile);
dictionary dict(is);
//- Dispatch calculation to the named function
scalar dispatch(const word&, const UList<scalar>&);
Info<< dict << endl;
}
}
return 0;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace calcEntryInternal
} // End namespace functionEntries
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,43 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: Any |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object testDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// #include "codeStreamDefaults"
writeInterval #codeStream
{
codeInclude
#{
#include "fvCFD.H"
#};
codeOptions
#{
-I$(LIB_SRC)/finiteVolume/lnInclude
#};
code
#{
scalar start = 0;
scalar end = 100;
label nDumps = 5;
label interval = end - start;
Info<<"on-the-fly: " << ((interval)/nDumps) << endl;
os << ((interval)/nDumps);
#};
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

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
@ -26,6 +26,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "string.H"
#include "stringOps.H"
#include "IOstreams.H"
using namespace Foam;
@ -35,11 +36,19 @@ using namespace Foam;
int main(int argc, char *argv[])
{
string test("$HOME kjhkjhkjh \" \\$HOME/tyetyery ${FOAM_RUN} \n ; hkjh ;$");
string test
(
" $HOME kjhkjhkjh \" \\$HOME/tyetyery ${FOAM_RUN} \n ; hkjh ;$ "
);
Info<< "string:" << test << nl << "hash:"
<< unsigned(string::hash()(test)) << endl;
Info<<"trimLeft: " << stringOps::trimLeft(test) << endl;
Info<<"trimRight: " << stringOps::trimRight(test) << endl;
Info<<"trim: " << stringOps::trim(test) << endl;
// test sub-strings via iterators
string::const_iterator iter = test.end();
string::const_iterator iter2 = test.end();

View File

@ -499,7 +499,7 @@ int main(int argc, char *argv[])
// Layers per point
labelList nPointLayers(extrudePatch.nPoints(), model().nLayers());
// Displacement for first layer
vectorField firstLayerDisp = displacement*model().sumThickness(1);
vectorField firstLayerDisp(displacement*model().sumThickness(1));
// Expansion ratio not used.
scalarField ratio(extrudePatch.nPoints(), 1.0);

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
@ -45,6 +45,7 @@ Description
#include "IOPtrList.H"
#include "polyTopoChange.H"
#include "polyModifyFace.H"
#include "wordReList.H"
using namespace Foam;
@ -669,7 +670,13 @@ int main(int argc, char *argv[])
if (sourceType == "patches")
{
labelHashSet patchSources(patches.patchSet(dict.lookup("patches")));
labelHashSet patchSources
(
patches.patchSet
(
wordReList(dict.lookup("patches"))
)
);
// Repatch faces of the patches.
forAllConstIter(labelHashSet, patchSources, iter)

View File

@ -18,7 +18,6 @@ LINK_DIRECTORIES(
)
INCLUDE_DIRECTORIES(
$ENV{WM_PROJECT_DIR}/src/OSspecific/$ENV{WM_OSTYPE}
$ENV{WM_PROJECT_DIR}/src/OpenFOAM/lnInclude
$ENV{WM_PROJECT_DIR}/src/finiteVolume/lnInclude
${PROJECT_SOURCE_DIR}/../vtkPV3Foam

View File

@ -60,6 +60,8 @@ Usage
\param -literalRE \n
Do not interpret regular expressions; treat them as any other keyword.
\param -enableFunctionEntries \n
By default all dictionary preprocessing of fields is disabled
\*---------------------------------------------------------------------------*/
@ -255,6 +257,11 @@ int main(int argc, char *argv[])
"literalRE",
"treat regular expressions literally (ie, as a keyword)"
);
argList::addBoolOption
(
"enableFunctionEntries",
"enable expansion of dictionary directives - #include, #codeStream etc"
);
#include "addRegionOption.H"
#include "setRootCase.H"
@ -271,6 +278,20 @@ int main(int argc, char *argv[])
<< " not present." << endl;
}
const bool enableEntries = args.optionFound("enableFunctionEntries");
if (enableEntries)
{
Info<< "Allowing dictionary preprocessing ('#include', '#codeStream')."
<< endl;
}
int oldFlag = entry::disableFunctionEntries;
if (!enableEntries)
{
// By default disable dictionary expansion for fields
entry::disableFunctionEntries = 1;
}
fileName regionPrefix = "";
if (regionName != fvMesh::defaultRegion)
@ -410,6 +431,7 @@ int main(int argc, char *argv[])
false
)
);
const_cast<word&>(IOdictionary::typeName) = oldTypeName;
// Fake type back to what was in field
const_cast<word&>(fieldDict.type()) = fieldDict.headerClassName();
@ -429,6 +451,8 @@ int main(int argc, char *argv[])
}
}
entry::disableFunctionEntries = oldFlag;
Info<< endl;
Info<< "End\n" << endl;

View File

@ -34,6 +34,9 @@ Usage
\param -test \n
Suppress writing the updated files with split cyclics
\param -enableFunctionEntries \n
By default all dictionary preprocessing of fields is disabled
\*---------------------------------------------------------------------------*/
#include "argList.H"
@ -391,7 +394,12 @@ int main(int argc, char *argv[])
{
timeSelector::addOptions();
argList::addBoolOption("test");
argList::addBoolOption("test", "test only; do not change any files");
argList::addBoolOption
(
"enableFunctionEntries",
"enable expansion of dictionary directives - #include, #codeStream etc"
);
# include "addRegionOption.H"
# include "setRootCase.H"
@ -404,6 +412,7 @@ int main(int argc, char *argv[])
{
Info<< "-test option: no changes made" << nl << endl;
}
const bool enableEntries = args.optionFound("enableFunctionEntries");
Foam::word regionName = polyMesh::defaultRegion;
@ -482,6 +491,13 @@ int main(int argc, char *argv[])
IOobjectList objects(runTime, runTime.timeName());
int oldFlag = entry::disableFunctionEntries;
if (!enableEntries)
{
// By default disable dictionary expansion for fields
entry::disableFunctionEntries = 1;
}
// volFields
// ~~~~~~~~~
@ -615,6 +631,8 @@ int main(int argc, char *argv[])
thisNames,
nbrNames
);
entry::disableFunctionEntries = oldFlag;
}
return 0;

View File

@ -13,4 +13,3 @@ EXE_LIBS = \
-ltriSurface \
-ldistributed \
-lradiationModels

View File

@ -34,9 +34,11 @@
# - elements whose start matches a wildcard
# - inaccessible directories (with the -strip (at your option)
#
# Note:
# - this routine will fail when directories have embedded spaces
# - false matches possible if a wildcard contains '.' (sed regex)
# Note
# - this routine will fail when directories have embedded spaces
# - false matches possible if a wildcard contains '.' (sed regex)
# - the wildcards can themselves can be written together and separated
# by colons or whitespace
#------------------------------------------------------------------------------
usage() {
cat <<USAGE 1>&2
@ -81,11 +83,12 @@ shift
##DEBUG echo "input>$dirList<" 1>&2
# preserve current IFS and split on whitespace
# preserve current IFS and split on colon or whitespace
oldIFS="$IFS"
IFS=' '
IFS=': '
# "wildcard1 ... wildcardN" may have been passed as a single parameter
# or may contain ':' separators
set -- $*
# strip out wildcards via sed
@ -94,7 +97,10 @@ do
wildcard=$1
shift
##DEBUG echo "remove>$wildcard<" 1>&2
dirList=$(echo "$dirList:" | sed -e "s@${wildcard}[^:]*:@@g")
if [ -n "$wildcard" ]
then
dirList=$(echo "$dirList:" | sed -e "s@${wildcard}[^:]*:@@g")
fi
done
# split on ':' (and on space as well to avoid any surprises)

View File

@ -32,7 +32,7 @@
# Not normally called directly by the user
#------------------------------------------------------------------------------
tmpFile=${TMPDIR:-/tmp}/foamPackFiles.$$
toolsDir="${0%/*}" # this script is already located in the tools/ directory
toolsDir="${0%/*}/tools" # this script is located in the tools/ parent dir
[ $# -eq 2 ] || {
cat <<USAGE 1>&2

View File

@ -30,15 +30,14 @@
#cleanTimeDirectories()
#{
# echo "Cleaning $case case of $application application"
# TIME_DIRS=`foamInfoExec . $1 -times | sed '1,/constant/d'`
# for T in $TIME_DIRS
# echo "Cleaning $PWD case"
# for time in $(foamInfoExec -times)
# do
# if [ $T != "0" ]
# then
# echo "Deleting directory $T"
# rm -rf ${T} > /dev/null 2>&1
# fi
# # keep 0 and constant directories
# [ "$time" = "0" -o "$time" = constant ] || {
# echo "Deleting directory $time"
# rm -rf $time > /dev/null 2>&1
# }
# done
# rm -rf {log,log.*,log-*,logSummary.*,.fxLock,*.xml,ParaView*,paraFoam*,*.OpenFOAM} > /dev/null 2>&1
#}
@ -56,15 +55,32 @@ cleanTimeDirectories()
rm -rf ./[1-9]* ./-[1-9]* ./log ./log.* ./log-* ./logSummary.* ./.fxLock ./*.xml ./ParaView* ./paraFoam* ./*.OpenFOAM > /dev/null 2>&1
}
#
# Remove codeStream subdirectory if it looks appropriate
#
cleanCodeStream()
{
if [ -d system -a -d codeStream ]
then
rm -rf codeStream > /dev/null 2>&1
fi
}
cleanCase()
{
cleanTimeDirectories
cleanCodeStream
rm -rf processor* > /dev/null 2>&1
rm -rf probes* > /dev/null 2>&1
rm -rf forces* > /dev/null 2>&1
rm -rf sets > /dev/null 2>&1
rm -rf system/machines > /dev/null 2>&1
if [ -d "constant/polyMesh" ]; then
if [ -d constant/polyMesh ]
then
(cd constant/polyMesh && \
rm -rf \
allOwner* cell* face* meshModifiers* \
@ -94,7 +110,7 @@ cleanCase()
removeCase()
{
echo "Removing $case case"
echo "Removing ${1:-unknown} case"
rm -rf $1
}

View File

@ -47,7 +47,7 @@
=code=, =codeInclude=, =codeOptions= sections (these are just strings) and
calculates the SHA1 checksum of the contents.
- it copies a template file
=($FOAM_CODESTREAM_TEMPLATE_DIR/codeStreamTemplate.C)=, substituting all
=($FOAM_CODESTREAM_TEMPLATES/codeStreamTemplate.C)=, substituting all
occurences of =code=, =codeInclude=, =codeOptions=.
- it writes library source files to =constant/codeStream/<sha1>= and compiles
it using =wmake libso=.
@ -76,6 +76,21 @@
It by default always includes =fvCFD.H= and adds the =finiteVolume= library to
the include search path.
A special form is where the code is not supplied in-line but instead comes
from the =codeDict= dictionary in the =system= directory. It should contain
a =fixedValue10= entry:
#+BEGIN_SRC c++
fixedValue10
{
code
#{
operator==(min(10, 0.1*this->db().time().value()));
#};
}
#+END_SRC
The advantage of using this indirect way is that it supports
runTimeModifiable so any change of the code will be picked up next iteration.
* Security
Allowing the case to execute C++ code does introduce security risks. A
third-party case might have a =#codeStream{#code system("rm -rf .");};= hidden
@ -121,7 +136,8 @@
- =foamFormatConvert=
- =changeDictionaryDict=
- =foamUpgradeCyclics=
- =fieldToCell=
These applications will usually switch off all '#' processing.
Note: above field initialisation has the problem that the boundary conditions
are not evaluated so e.g. processor boundaries will not hold the opposite cell

View File

@ -21,9 +21,18 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Template for use with codeStream.
\*---------------------------------------------------------------------------*/
#include "dictionary.H"
#include "Ostream.H"
#include "Pstream.H"
//{{{ begin codeInclude
${codeInclude}
//}}} end codeInclude
using namespace Foam;
@ -39,7 +48,9 @@ void ${typeName}
Ostream& os
)
{
//{{{ begin code
${code};
//}}} end code
}
}

View File

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

View File

@ -38,7 +38,7 @@
## Specify system compiler
## ~~~~~~~~~~~~~~~~~~~~~~~
#set foamCompiler=system
#set foamCompiler=OpenFOAM
## Specify system openmpi
## ~~~~~~~~~~~~~~~~~~~~~~

View File

@ -38,7 +38,7 @@
# Specify system compiler
# ~~~~~~~~~~~~~~~~~~~~~~~
foamCompiler=system
foamCompiler=OpenFOAM
# Specify system openmpi
# ~~~~~~~~~~~~~~~~~~~~~~

View File

@ -102,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
)
{
@ -1066,7 +1066,7 @@ 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());
}
@ -1084,14 +1084,14 @@ bool Foam::dlClose(void* handle)
}
void* Foam::dlSym(void* handle, const string& symbol)
void* Foam::dlSym(void* handle, const std::string& symbol)
{
void* fun = dlsym(handle, symbol.c_str());
char *error;
if ((error = dlerror()) != NULL)
{
WarningIn("dlSym(void*, const string&)")
WarningIn("dlSym(void*, const std::string&)")
<< "Cannot lookup symbol " << symbol << " : " << error
<< endl;
}

View File

@ -78,6 +78,7 @@ $(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
@ -160,24 +161,12 @@ $(dictionaryEntry)/dictionaryEntryIO.C
functionEntries = $(dictionary)/functionEntries
$(functionEntries)/codeStream/codeStream.C
$(functionEntries)/codeStream/codeStreamTools.C
$(functionEntries)/functionEntry/functionEntry.C
$(functionEntries)/includeEntry/includeEntry.C
$(functionEntries)/includeIfPresentEntry/includeIfPresentEntry.C
$(functionEntries)/inputModeEntry/inputModeEntry.C
$(functionEntries)/removeEntry/removeEntry.C
/*
* Requires customized coco-cpp
* could be dropped or activated in the future
*/
/*
calcEntry = $(functionEntries)/calcEntry
$(calcEntry)/calcEntryParser.atg
$(calcEntry)/calcEntryInternal.C
$(calcEntry)/calcEntry.C
*/
IOdictionary = db/IOobjects/IOdictionary
$(IOdictionary)/IOdictionary.C
$(IOdictionary)/IOdictionaryIO.C
@ -198,7 +187,10 @@ $(regIOobject)/regIOobjectWrite.C
db/IOobjectList/IOobjectList.C
db/objectRegistry/objectRegistry.C
db/CallbackRegistry/CallbackRegistryName.C
db/dlLibraryTable/dlLibraryTable.C
dll = db/dynamicLibrary
$(dll)/codeStream/codeStreamTools.C
$(dll)/dlLibraryTable/dlLibraryTable.C
db/functionObjects/functionObject/functionObject.C
db/functionObjects/functionObjectList/functionObjectList.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
@ -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

@ -203,7 +203,7 @@ Foam::Istream& Foam::ISstream::read(token& t)
return *this;
}
// Verbatim string
// Possible verbatim string or dictionary functionEntry
case token::HASH :
{
char nextC;
@ -226,6 +226,7 @@ Foam::Istream& Foam::ISstream::read(token& t)
else
{
t = sPtr;
t.type() = token::VERBATIMSTRING;
}
return *this;

View File

@ -78,6 +78,7 @@ public:
PUNCTUATION,
WORD,
STRING,
VERBATIMSTRING,
LABEL,
FLOAT_SCALAR,
DOUBLE_SCALAR,
@ -318,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
@ -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,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

@ -31,10 +31,12 @@ License
#include "SHA1Digest.H"
#include "OSHA1stream.H"
#include "codeStreamTools.H"
#include "stringOps.H"
#include "dlLibraryTable.H"
#include "OSspecific.H"
#include "Time.H"
#include "Pstream.H"
#include "PstreamReduceOps.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -56,6 +58,10 @@ namespace functionEntries
}
const Foam::word Foam::functionEntries::codeStream::codeTemplateC
= "codeStreamTemplate.C";
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionEntries::codeStream::execute
@ -79,119 +85,121 @@ bool Foam::functionEntries::codeStream::execute
}
// Read three sections of code. Remove any leading empty lines
// (necessary for compilation options, just visually pleasing for includes
// and body).
// Read three sections of code.
// Remove any leading whitespace - necessary for compilation options,
// convenience for includes and body.
dictionary codeDict(is);
string codeInclude = "";
// "codeInclude" is optional
string codeInclude;
if (codeDict.found("codeInclude"))
{
codeInclude = codeStreamTools::stripLeading(codeDict["codeInclude"]);
codeInclude = stringOps::trim(codeDict["codeInclude"]);
}
string code = codeStreamTools::stripLeading(codeDict["code"]);
string codeOptions = "";
// "codeOptions" is optional
string codeOptions;
if (codeDict.found("codeOptions"))
{
codeOptions = codeStreamTools::stripLeading(codeDict["codeOptions"]);
codeOptions = stringOps::trim(codeDict["codeOptions"]);
}
// "code" is mandatory
string code = stringOps::trim(codeDict["code"]);
// Create name out of contents
// Create SHA1 digest from the contents
SHA1Digest sha;
{
OSHA1stream os;
os << codeInclude << code << codeOptions;
os << codeInclude << codeOptions << code;
sha = os.digest();
}
fileName name;
{
OStringStream str;
str << sha;
name = "codeStream" + str.str();
}
fileName dir;
if (isA<IOdictionary>(parentDict))
{
const IOdictionary& d = static_cast<const IOdictionary&>(parentDict);
dir = d.db().time().constantPath()/"codeStream"/name;
}
else
{
dir = "codeStream"/name;
}
fileName libPath
(
Foam::getEnv("FOAM_USER_LIBBIN")
/ "lib"
+ name
+ ".so"
);
// codeName = prefix + sha1
const fileName codeName = "codeStream_" + sha.str();
// write code into _SHA1 subdir
const fileName codePath = codeStreamTools::codePath("_" + sha.str());
// write library into platforms/$WM_OPTIONS/lib subdir
const fileName libPath = codeStreamTools::libPath(codeName);
void* lib = dlLibraryTable::findLibrary(libPath);
// try to load if not already loaded
if (!lib && dlLibraryTable::open(libPath, false))
{
lib = dlLibraryTable::findLibrary(libPath);
}
// did not load - need to compile it
if (!lib)
{
if (Pstream::master())
{
if (!codeStreamTools::upToDate(dir, sha))
if (!codeStreamTools::upToDate(codePath, sha))
{
Info<< "Creating new library in " << libPath << endl;
fileName templates
const fileName fileCsrc
(
Foam::getEnv("FOAM_CODESTREAM_TEMPLATE_DIR")
codeStreamTools::findTemplate
(
codeTemplateC
)
);
if (!templates.size())
// not found!
if (fileCsrc.empty())
{
FatalIOErrorIn
(
"functionEntries::codeStream::execute(..)",
parentDict
) << "Please set environment variable"
" FOAM_CODESTREAM_TEMPLATE_DIR"
<< " to point to the location of codeStreamTemplate.C"
) << "Could not find the code template: "
<< codeTemplateC << nl
<< codeStreamTools::searchedLocations()
<< exit(FatalIOError);
}
List<fileAndVars> copyFiles(1);
copyFiles[0].first() = templates/"codeStreamTemplate.C";
stringPairList bodyVars(2);
bodyVars[0] = Pair<string>("codeInclude", codeInclude);
bodyVars[1] = Pair<string>("code", code);
copyFiles[0].second() = bodyVars;
List<fileAndContent> filesContents(2);
List<codeStreamTools::fileAndVars> copyFiles(1);
copyFiles[0].file() = fileCsrc;
copyFiles[0].set("codeInclude", codeInclude);
copyFiles[0].set("code", code);
List<codeStreamTools::fileAndContent> filesContents(2);
// Write Make/files
filesContents[0].first() = "Make/files";
filesContents[0].second() =
"codeStreamTemplate.C \n\
LIB = $(FOAM_USER_LIBBIN)/lib" + name;
codeTemplateC + "\n\n"
+ codeStreamTools::libTarget(codeName);
// Write Make/options
filesContents[1].first() = "Make/options";
filesContents[1].second() =
"EXE_INC = -g\\\n" + codeOptions + "\n\nLIB_LIBS = ";
"EXE_INC = -g \\\n"
+ codeOptions
+ "\n\nLIB_LIBS =";
codeStreamTools writer(name, copyFiles, filesContents);
if (!writer.copyFilesContents(dir))
codeStreamTools writer(codeName, copyFiles, filesContents);
if (!writer.copyFilesContents(codePath))
{
FatalIOErrorIn
(
"functionEntries::codeStream::execute(..)",
parentDict
) << "Failed writing " << endl
) << "Failed writing " <<nl
<< copyFiles << endl
<< filesContents
<< exit(FatalIOError);
}
}
Foam::string wmakeCmd("wmake libso " + dir);
const Foam::string wmakeCmd("wmake libso " + codePath);
Info<< "Invoking " << wmakeCmd << endl;
if (Foam::system(wmakeCmd))
{
@ -199,17 +207,22 @@ bool Foam::functionEntries::codeStream::execute
(
"functionEntries::codeStream::execute(..)",
parentDict
) << "Failed " << wmakeCmd << exit(FatalIOError);
) << "Failed " << wmakeCmd
<< exit(FatalIOError);
}
}
if (!dlLibraryTable::open(libPath))
bool dummy = true;
reduce(dummy, orOp<bool>());
if (!dlLibraryTable::open(libPath, false))
{
FatalIOErrorIn
(
"functionEntries::codeStream::execute(..)",
parentDict
) << "Failed loading library " << libPath << exit(FatalIOError);
) << "Failed loading library " << libPath
<< exit(FatalIOError);
}
lib = dlLibraryTable::findLibrary(libPath);
@ -224,7 +237,7 @@ bool Foam::functionEntries::codeStream::execute
void (*function)(const dictionary&, Ostream&);
function = reinterpret_cast<void(*)(const dictionary&, Ostream&)>
(
dlSym(lib, name)
dlSym(lib, codeName)
);
if (!function)
@ -233,11 +246,11 @@ bool Foam::functionEntries::codeStream::execute
(
"functionEntries::codeStream::execute(..)",
parentDict
) << "Failed looking up symbol " << name
) << "Failed looking up symbol " << codeName
<< " in library " << lib << exit(FatalIOError);
}
OStringStream os;
OStringStream os(is.format());
(*function)(parentDict, os);
IStringStream resultStream(os.str());
entry.read(parentDict, resultStream);

View File

@ -29,11 +29,12 @@ Description
generate the entry itself. So
- codeStream reads three entries: 'code', 'codeInclude' (optional),
'codeOptions' (optional)
and uses those to generate library sources inside constant/codeStream/
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
const dictionary& dict,
Ostream& os
\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.
@ -41,6 +42,7 @@ Description
E.g. to set the internal field of a field:
\verbatim
internalField #codeStream
{
code
@ -56,19 +58,31 @@ Description
#{
#include "fvCFD.H"
#};
//- Optional:
codeOptions
#{
-I$(LIB_SRC)/finiteVolume/lnInclude
#};
};
\endverbatim
Note the #{ #} syntax which is just a way of inputting strings with embedded
newlines.
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 $, ~)
- 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
@ -84,13 +98,11 @@ SourceFiles
namespace Foam
{
class ISstream;
namespace functionEntries
{
/*---------------------------------------------------------------------------*\
Class codeStream Declaration
Class codeStream Declaration
\*---------------------------------------------------------------------------*/
class codeStream
@ -108,6 +120,12 @@ class codeStream
public:
// Static data members
//- Name of the C code template to be used
static const word codeTemplateC;
//- Runtime type information
ClassName("codeStream");

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))
@ -215,7 +216,17 @@ void Foam::primitiveEntry::write(Ostream& os) const
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)
{

View File

@ -25,6 +25,7 @@ License
\*---------------------------------------------------------------------------*/
#include "codeStreamTools.H"
#include "stringOps.H"
#include "IFstream.H"
#include "OFstream.H"
#include "OSspecific.H"
@ -39,42 +40,134 @@ int Foam::codeStreamTools::allowSystemOperations
);
const Foam::word Foam::codeStreamTools::codeTemplateEnvName
= "FOAM_CODESTREAM_TEMPLATES";
const Foam::fileName Foam::codeStreamTools::codeTemplateDirName
= "codeTemplates/codeStream";
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
Foam::fileName Foam::codeStreamTools::baseDir()
{
return stringOps::expandEnv("$FOAM_CASE/codeStream");
}
Foam::fileName Foam::codeStreamTools::libSubDir()
{
return stringOps::expandEnv("platforms/$WM_OPTIONS/lib");
}
Foam::fileName Foam::codeStreamTools::codePath(const word& subDirName)
{
return stringOps::expandEnv
(
"$FOAM_CASE/codeStream/" + subDirName
);
}
Foam::fileName Foam::codeStreamTools::libPath(const word& codeName)
{
return stringOps::expandEnv
(
"$FOAM_CASE/codeStream/platforms/$WM_OPTIONS/lib/lib"
+ codeName + ".so"
);
}
Foam::string Foam::codeStreamTools::libTarget(const word& codeName)
{
return "LIB = $(PWD)/../platforms/$(WM_OPTIONS)/lib/lib" + codeName;
}
Foam::fileName Foam::codeStreamTools::findTemplate(const word& templateFile)
{
// try to get template from FOAM_CODESTREAM_TEMPLATES
fileName templateDir(Foam::getEnv(codeTemplateEnvName));
fileName file;
if (!templateDir.empty() && isDir(templateDir))
{
file = templateDir/templateFile;
if (!isFile(file, false))
{
file.clear();
}
}
// not found - fallback to ~OpenFOAM expansion
if (file.empty())
{
file = findEtcFile(codeTemplateDirName/templateFile);
}
return file;
}
Foam::string Foam::codeStreamTools::searchedLocations()
{
return
(
"Under the $"
+ codeTemplateDirName
+ " directory or via via the ~OpenFOAM/"
+ codeTemplateDirName
+ " expansion"
);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::codeStreamTools::copyAndExpand
(
ISstream& sourceStr,
OSstream& destStr
ISstream& is,
OSstream& os,
const HashTable<string>& mapping
) const
{
if (!sourceStr.good())
if (!is.good())
{
FatalErrorIn
(
"codeStreamTools::copyAndExpand()"
" const"
) << "Failed opening for reading " << sourceStr.name()
) << "Failed opening for reading " << is.name()
<< exit(FatalError);
}
if (!destStr.good())
if (!os.good())
{
FatalErrorIn
(
"codeStreamTools::copyAndExpand()"
" const"
) << "Failed writing " << destStr.name() << exit(FatalError);
) << "Failed writing " << os.name()
<< exit(FatalError);
}
// Copy file whilst rewriting environment vars
// Copy file while rewriting $VARS and ${VARS}
string line;
do
{
sourceStr.getLine(line);
line.expand(true, true); // replace any envvars inside substitutions
destStr<< line.c_str() << nl;
is.getLine(line);
// normal expansion according to mapping
stringOps::inplaceExpand(line, mapping);
// expand according to env variables
stringOps::inplaceExpandEnv(line, true, true);
os << line.c_str() << nl;
}
while (sourceStr.good());
while (is.good());
}
@ -109,11 +202,11 @@ Foam::codeStreamTools::codeStreamTools
{}
Foam::codeStreamTools::codeStreamTools(const codeStreamTools& otf)
Foam::codeStreamTools::codeStreamTools(const codeStreamTools& tools)
:
name_(otf.name_),
copyFiles_(otf.copyFiles_),
filesContents_(otf.filesContents_)
name_(tools.name_),
copyFiles_(tools.copyFiles_),
filesContents_(tools.filesContents_)
{}
@ -127,21 +220,16 @@ bool Foam::codeStreamTools::copyFilesContents(const fileName& dir) const
(
"codeStreamTools::copyFilesContents(const fileName&) const"
) << "Loading a shared library using case-supplied code is not"
<< " enabled by default" << endl
<< " enabled by default" << nl
<< "because of security issues. If you trust the code you can"
<< " enable this" << endl
<< " enable this" << nl
<< "facility be adding to the InfoSwitches setting in the system"
<< " controlDict:" << endl
<< endl
<< " allowSystemOperations 1" << endl
<< endl
<< "The system controlDict is either" << endl
<< endl
<< " ~/.OpenFOAM/$WM_PROJECT_VERSION/controlDict" << endl
<< endl
<< "or" << endl
<< endl
<< " $WM_PROJECT_DIR/etc/controlDict" << endl
<< " 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);
}
@ -149,98 +237,84 @@ bool Foam::codeStreamTools::copyFilesContents(const fileName& dir) const
// Create dir
mkDir(dir);
//Info<< "Setting envvar typeName=" << name_ << endl;
setEnv("typeName", name_, true);
// Info<< "set mapping typeName=" << name_ << endl;
// Copy any template files
forAll(copyFiles_, i)
{
const List<Pair<string> >& rules = copyFiles_[i].second();
forAll(rules, j)
{
//Info<< "Setting envvar " << rules[j].first() << endl;
setEnv(rules[j].first(), rules[j].second(), true);
}
const fileName sourceFile(fileName(copyFiles_[i].file()).expand());
const fileName destFile(dir/sourceFile.name());
const fileName sourceFile = fileName(copyFiles_[i].first()).expand();
const fileName destFile = dir/sourceFile.name();
IFstream sourceStr(sourceFile);
//Info<< "Reading from " << sourceStr.name() << endl;
if (!sourceStr.good())
IFstream is(sourceFile);
//Info<< "Reading from " << is.name() << endl;
if (!is.good())
{
FatalErrorIn
(
"codeStreamTools::copyFilesContents()"
"codeStreamTools::copyFilesContents(const fileName&)"
" const"
) << "Failed opening " << sourceFile << exit(FatalError);
}
OFstream destStr(destFile);
OFstream os(destFile);
//Info<< "Writing to " << destFile.name() << endl;
if (!destStr.good())
if (!os.good())
{
FatalErrorIn
(
"codeStreamTools::copyFilesContents()"
"codeStreamTools::copyFilesContents(const fileName&)"
" const"
) << "Failed writing " << destFile << exit(FatalError);
}
copyAndExpand(sourceStr, destStr);
// variables mapping
HashTable<string> mapping(copyFiles_[i]);
mapping.set("typeName", name_);
copyAndExpand(is, os, mapping);
}
// Files that are always written:
forAll(filesContents_, i)
{
fileName f = fileName(dir/filesContents_[i].first()).expand();
const fileName dstFile
(
fileName(dir/filesContents_[i].first()).expand()
);
mkDir(f.path());
OFstream str(f);
mkDir(dstFile.path());
OFstream os(dstFile);
//Info<< "Writing to " << filesContents_[i].first() << endl;
if (!str.good())
if (!os.good())
{
FatalErrorIn
(
"codeStreamTools::copyFilesContents()"
" const"
) << "Failed writing " << f << exit(FatalError);
) << "Failed writing " << dstFile << exit(FatalError);
}
str << filesContents_[i].second().c_str() << endl;
os << filesContents_[i].second().c_str() << endl;
}
return true;
}
Foam::string Foam::codeStreamTools::stripLeading(const string& s)
{
label sz = s.size();
if (sz > 0 && s[0] == '\n')
{
return s(1, sz-1);
}
else
{
return s;
}
}
bool Foam::codeStreamTools::writeDigest
(
const fileName& dir,
const SHA1Digest& sha1
)
{
OFstream str(dir/"SHA1Digest");
str << sha1;
return str.good();
OFstream os(dir/"SHA1Digest");
os << sha1;
return os.good();
}
Foam::SHA1Digest Foam::codeStreamTools::readDigest(const fileName& dir)
{
IFstream str(dir/"SHA1Digest");
return SHA1Digest(str);
IFstream is(dir/"SHA1Digest");
return SHA1Digest(is);
}

View File

@ -39,20 +39,16 @@ SourceFiles
#include "Tuple2.H"
#include "Pair.H"
#include "SHA1Digest.H"
#include "HashTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef List<Pair<string> > stringPairList;
typedef Tuple2<fileName, List<Pair<string> > > fileAndVars;
typedef Tuple2<fileName, string> fileAndContent;
class OSstream;
// Forward declaration of classes
class ISstream;
class OSstream;
/*---------------------------------------------------------------------------*\
Class codeStreamTools Declaration
@ -60,24 +56,72 @@ class ISstream;
class codeStreamTools
{
public:
typedef Tuple2<fileName, string> fileAndContent;
//- Helper class for managing file and variables
class fileAndVars
:
public HashTable<string>
{
// Private data
fileName file_;
public:
//- Construct null
fileAndVars()
{}
//- Return the file name
const fileName& file() const
{
return file_;
}
//- Return the file name
fileName& file()
{
return file_;
}
};
private:
// Private data
//- Name for underlying set
word name_;
//- Files to copy
List<fileAndVars> copyFiles_;
List<codeStreamTools::fileAndVars> copyFiles_;
//- Direct contents for files
List<fileAndContent> filesContents_;
protected:
void copyAndExpand(ISstream&, OSstream&) const;
void copyAndExpand
(
ISstream&,
OSstream&,
const HashTable<string>& mapping
) const;
public:
static int allowSystemOperations;
// 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;
static int allowSystemOperations;
// Constructors
@ -96,12 +140,46 @@ public:
);
//- Construct copy
codeStreamTools(const codeStreamTools& otf);
codeStreamTools(const codeStreamTools&);
// Member functions
const List<Tuple2<fileName, List<Pair<string> > > >& copyFiles() const
//- Directory for compile/link (case-specific)
// Expanded from \$FOAM_CASE/codeStream
static fileName baseDir();
//- Subdirectory name for library
// Expanded from platforms/\$WM_OPTIONS/lib
static fileName libSubDir();
//- Local path for specified code name
// Expanded from \$FOAM_CASE/codeStream
static fileName codePath(const word& subDirName);
//- Local library path for specified code name
// Expanded from \$FOAM_CASE/platforms/\$WM_OPTIONS/lib
static fileName libPath(const word& codeName);
//- The library target path for Make/files
static string libTarget(const word& codeName);
//- Find a code-template via the codeTemplateEnvName
// alternatively in the codeTemplateDirName via Foam::findEtcFile
static fileName findTemplate(const word& templateName);
//- List searched locations in a format suitable for display an error
static string searchedLocations();
const word& name() const
{
return name_;
}
const List<fileAndVars>& copyFiles() const
{
return copyFiles_;
}
@ -111,16 +189,10 @@ public:
return filesContents_;
}
const word& name() const
{
return name_;
}
bool copyFilesContents(const fileName& dir) const;
static void* findLibrary(const fileName& libPath);
static string stripLeading(const string&);
static void* findLibrary(const fileName& libPath);
static bool writeDigest(const fileName& dir, const SHA1Digest& sha1);
static SHA1Digest readDigest(const fileName& dir);

View File

@ -62,7 +62,11 @@ Foam::dlLibraryTable::~dlLibraryTable()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::dlLibraryTable::open(const fileName& functionLibName)
bool Foam::dlLibraryTable::open
(
const fileName& functionLibName,
const bool verbose
)
{
if (functionLibName.size())
{
@ -70,11 +74,14 @@ bool Foam::dlLibraryTable::open(const fileName& functionLibName)
if (!functionLibPtr)
{
WarningIn
(
"dlLibraryTable::open(const fileName& functionLibName)"
) << "could not load " << functionLibName
<< endl;
if (verbose)
{
WarningIn
(
"dlLibraryTable::open(const fileName&)"
) << "could not load " << functionLibName
<< endl;
}
return false;
}
@ -97,7 +104,11 @@ bool Foam::dlLibraryTable::open(const fileName& functionLibName)
}
bool Foam::dlLibraryTable::close(const fileName& functionLibName)
bool Foam::dlLibraryTable::close
(
const fileName& functionLibName,
const bool verbose
)
{
void* libPtr = findLibrary(functionLibName);
if (libPtr)
@ -106,11 +117,14 @@ bool Foam::dlLibraryTable::close(const fileName& functionLibName)
if (!dlClose(libPtr))
{
WarningIn
(
"dlLibraryTable::close(const fileName& functionLibName)"
) << "could not close " << functionLibName
<< endl;
if (verbose)
{
WarningIn
(
"dlLibraryTable::close(const fileName&)"
) << "could not close " << functionLibName
<< endl;
}
return false;
}
@ -144,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

@ -94,11 +94,11 @@ 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
static bool close(const fileName& name);
//- 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);
@ -109,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

@ -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

@ -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)
@ -182,7 +182,7 @@ 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);
@ -191,7 +191,7 @@ void* dlOpen(const fileName& lib);
bool dlClose(void*);
//- Lookup a symbol in a dlopened library using handle
void* dlSym(void* handle, const string& symbol);
void* dlSym(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,7 +25,7 @@ Class
Foam::lduPrimitiveMesh
Description
Simplest contrete lduMesh which stores the addressing needed bu lduMatrix.
Simplest contrete lduMesh which stores the addressing needed by lduMatrix.
\*---------------------------------------------------------------------------*/

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
@ -26,11 +26,6 @@ License
#include "processorCyclicPointPatch.H"
#include "pointBoundaryMesh.H"
#include "addToRunTimeSelectionTable.H"
//#include "pointMesh.H"
//#include "globalPointPatch.H"
//#include "faceList.H"
//#include "primitiveFacePatch.H"
//#include "emptyPolyPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -49,344 +44,6 @@ addToRunTimeSelectionTable
);
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
//void Foam::processorCyclicPointPatch::initGeometry(PstreamBuffers& pBufs)
//{
// // Algorithm:
// // Depending on whether the patch is a master or a slave, get the
// // primitive patch points and filter away the points from the
// // global patch.
//
// if (isMaster())
// {
// meshPoints_ = procPolyPatch_.meshPoints();
// }
// else
// {
// // Slave side. Create the reversed patch and pick up its points
// // so that the order is correct
// const polyPatch& pp = patch();
//
// faceList masterFaces(pp.size());
//
// forAll(pp, faceI)
// {
// masterFaces[faceI] = pp[faceI].reverseFace();
// }
//
// meshPoints_ = primitiveFacePatch
// (
// masterFaces,
// pp.points()
// ).meshPoints();
// }
//
// if (Pstream::parRun())
// {
// initPatchPatchPoints(pBufs);
// }
//}
//
//
//void Foam::processorCyclicPointPatch::calcGeometry(PstreamBuffers& pBufs)
//{
// if (Pstream::parRun())
// {
// calcPatchPatchPoints(pBufs);
// }
//
// // If it is not runing parallel or there are no global points
// // create a 1->1 map
// if
// (
// !Pstream::parRun()
// || !boundaryMesh().mesh().globalData().nGlobalPoints()
// )
// {
// nonGlobalPatchPoints_.setSize(meshPoints_.size());
// forAll(nonGlobalPatchPoints_, i)
// {
// nonGlobalPatchPoints_[i] = i;
// }
// }
// else
// {
// // Get reference to shared points
// const labelList& sharedPoints =
// boundaryMesh().globalPatch().meshPoints();
//
// nonGlobalPatchPoints_.setSize(meshPoints_.size());
//
// label noFiltPoints = 0;
//
// forAll(meshPoints_, pointI)
// {
// label curP = meshPoints_[pointI];
//
// bool found = false;
//
// forAll(sharedPoints, sharedI)
// {
// if (sharedPoints[sharedI] == curP)
// {
// found = true;
// break;
// }
// }
//
// if (!found)
// {
// nonGlobalPatchPoints_[noFiltPoints] = pointI;
// meshPoints_[noFiltPoints] = curP;
// noFiltPoints++;
// }
// }
//
// nonGlobalPatchPoints_.setSize(noFiltPoints);
// meshPoints_.setSize(noFiltPoints);
// }
//}
//
//
//void processorCyclicPointPatch::initPatchPatchPoints(PstreamBuffers& pBufs)
//{
// if (debug)
// {
// Info<< "processorCyclicPointPatch::"
// << "initPatchPatchPoints(PstreamBuffers&) : "
// << "constructing patch-patch points"
// << endl;
// }
//
// const polyBoundaryMesh& bm = boundaryMesh().mesh()().boundaryMesh();
//
// // Get the mesh points for this patch corresponding to the faces
// const labelList& ppmp = meshPoints();
//
// // Create a HashSet of the point labels for this patch
// Map<label> patchPointSet(2*ppmp.size());
//
// forAll(ppmp, ppi)
// {
// patchPointSet.insert(ppmp[ppi], ppi);
// }
//
//
// // Create the lists of patch-patch points
// labelListList patchPatchPoints(bm.size());
//
// // Create the lists of patch-patch point normals
// List<List<vector> > patchPatchPointNormals(bm.size());
//
// // Loop over all patches looking for other patches that share points
// forAll(bm, patchi)
// {
// if
// (
// patchi != index() // Ignore self-self
// && !isA<emptyPolyPatch>(bm[patchi]) // Ignore empty
// && !bm[patchi].coupled() // Ignore other couples
// )
// {
// // Get the meshPoints for the other patch
// const labelList& meshPoints = bm[patchi].meshPoints();
//
// // Get the normals for the other patch
// const vectorField& normals = bm[patchi].pointNormals();
//
// label pppi = 0;
// forAll(meshPoints, pointi)
// {
// label ppp = meshPoints[pointi];
//
// // Check to see if the point of the other patch is shared with
// // this patch
// Map<label>::iterator iter = patchPointSet.find(ppp);
//
// if (iter != patchPointSet.end())
// {
// // If it is shared initialise the patchPatchPoints for
// // this patch
// if (!patchPatchPoints[patchi].size())
// {
// patchPatchPoints[patchi].setSize(ppmp.size());
// patchPatchPointNormals[patchi].setSize(ppmp.size());
// }
//
// // and add the entry
// patchPatchPoints[patchi][pppi] = iter();
// patchPatchPointNormals[patchi][pppi] = normals[pointi];
// pppi++;
// }
// }
//
// // Resise the list of shared points and normals for the patch
// // being considerd
// patchPatchPoints[patchi].setSize(pppi);
// patchPatchPointNormals[patchi].setSize(pppi);
// }
// }
//
// // Send the patchPatchPoints to the neighbouring processor
//
// UOPstream toNeighbProc(neighbProcNo(), pBufs);
//
// toNeighbProc
// << ppmp.size() // number of points for checking
// << patchPatchPoints
// << patchPatchPointNormals;
//
// if (debug)
// {
// Info<< "processorCyclicPointPatch::initPatchPatchPoints() : "
// << "constructed patch-patch points"
// << endl;
// }
//}
//
//
//void Foam::processorCyclicPointPatch::calcPatchPatchPoints
//(
// PstreamBuffers& pBufs
//)
//{
// // Get the patchPatchPoints from the neighbouring processor
// UIPstream fromNeighbProc(neighbProcNo(), pBufs);
//
// label nbrNPoints(readLabel(fromNeighbProc));
// labelListList patchPatchPoints(fromNeighbProc);
// List<List<vector> > patchPatchPointNormals(fromNeighbProc);
//
// pointBoundaryMesh& pbm = const_cast<pointBoundaryMesh&>(boundaryMesh());
// const labelList& ppmp = meshPoints();
//
// // Simple check for the very rare situation when not the same number
// // of points on both sides. This can happen with decomposed cyclics.
// // If on one side the cyclic shares a point with proc faces coming from
// // internal faces it will have a different number of points from
// // the situation where the cyclic and the 'normal' proc faces are fully
// // separate.
// if (nbrNPoints != ppmp.size())
// {
// WarningIn
// (
// "processorCyclicPointPatch::calcPatchPatchPoints(PstreamBuffers&)"
// )
// << "Processor patch " << name()
// << " has " << ppmp.size() << " points; coupled patch has "
// << nbrNPoints << " points." << endl
// << " (usually due to decomposed cyclics)."
// << " This might give problems" << endl
// << " when using point fields (interpolation, mesh motion)."
// << endl;
// }
//
//
//
// // Loop over the patches looking for other patches that share points
// forAll(patchPatchPoints, patchi)
// {
// const labelList& patchPoints = patchPatchPoints[patchi];
// const List<vector>& patchPointNormals =
// patchPatchPointNormals[patchi];
//
// // If there are potentially shared points for the patch being
// // considered
// if (patchPoints.size())
// {
// // Get the current meshPoints list for the patch
// facePointPatch& fpp = refCast<facePointPatch>(pbm[patchi]);
// const labelList& fmp = fpp.meshPoints();
// labelList& mp = fpp.meshPoints_;
//
// const vectorField& fnormals = fpp.pointNormals();
// vectorField& normals = fpp.pointNormals_;
//
// // Create a HashSet of the point labels for the patch
// Map<label> patchPointSet(2*fmp.size());
//
// forAll(fmp, ppi)
// {
// patchPointSet.insert(fmp[ppi], ppi);
// }
//
// label nPoints = mp.size();
// label lpi = 0;
// bool resized = false;
//
// // For each potentially shared point...
// forAll(patchPoints, ppi)
// {
// // Check if it is not already in the patch,
// // i.e. not part of a face of the patch
// if (!patchPointSet.found(ppmp[patchPoints[ppi]]))
// {
// // If it isn't already in the patch check if the local
// // meshPoints is already set and if not initialise the
// // meshPoints_ and pointNormals_
// if (!resized)
// {
// if (!mp.size() && fmp.size())
// {
// mp = fmp;
// normals = fnormals;
//
// nPoints = mp.size();
// }
//
// mp.setSize(nPoints + patchPoints.size());
// loneMeshPoints_.setSize(patchPoints.size());
// normals.setSize(nPoints + patchPoints.size());
// resized = true;
// }
//
// // Add the new point to the patch
// mp[nPoints] = ppmp[patchPoints[ppi]];
// loneMeshPoints_[lpi++] = ppmp[patchPoints[ppi]];
// normals[nPoints++] = patchPointNormals[ppi];
// }
// }
//
// // If the lists have been resized points have been added.
// // Shrink the lists to the current size.
// if (resized)
// {
// mp.setSize(nPoints);
// loneMeshPoints_.setSize(lpi);
// normals.setSize(nPoints);
// }
// }
// }
//}
//void processorCyclicPointPatch::initMovePoints
//(
// PstreamBuffers&,
// const pointField&
//)
//{}
//
//
//void processorCyclicPointPatch::movePoints(PstreamBuffers&, const pointField&)
//{}
//
//
//void processorCyclicPointPatch::initUpdateMesh(PstreamBuffers& pBufs)
//{
// facePointPatch::initUpdateMesh(pBufs);
// processorCyclicPointPatch::initGeometry(pBufs);
//}
//
//
//void processorCyclicPointPatch::updateMesh(PstreamBuffers& pBufs)
//{
// facePointPatch::updateMesh(pBufs);
// processorCyclicPointPatch::calcGeometry(pBufs);
//}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
processorCyclicPointPatch::processorCyclicPointPatch

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
@ -99,43 +99,6 @@ public:
return procCycPolyPatch_.tag();
}
// //- Return true if running parallel
// virtual bool coupled() const
// {
// if (Pstream::parRun())
// {
// return true;
// }
// else
// {
// return false;
// }
// }
//
// //- Return processor number
// int myProcNo() const
// {
// return procPolyPatch_.myProcNo();
// }
//
// //- Return neigbour processor number
// int neighbProcNo() const
// {
// return procPolyPatch_.neighbProcNo();
// }
//
// //- Is this a master patch
// bool isMaster() const
// {
// return myProcNo() < neighbProcNo();
// }
//
// //- Is this a slave patch
// bool isSlave() const
// {
// return !isMaster();
// }
//
//- Return the underlying processorCyclicPolyPatch
const processorCyclicPolyPatch& procCyclicPolyPatch() const
{

View File

@ -550,7 +550,7 @@ Foam::label Foam::polyBoundaryMesh::whichPatch(const label faceIndex) const
Foam::labelHashSet Foam::polyBoundaryMesh::patchSet
(
const wordReList& patchNames,
const UList<wordRe>& patchNames,
const bool warnNotFound
) const
{

View File

@ -38,7 +38,6 @@ SourceFiles
#include "polyPatchList.H"
#include "regIOobject.H"
#include "labelPair.H"
#include "wordReList.H"
#include "HashSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -46,7 +45,9 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
class polyMesh;
class wordRe;
// Forward declaration of friend functions and operators
@ -171,7 +172,7 @@ public:
// By default warns if given names are not found.
labelHashSet patchSet
(
const wordReList& patchNames,
const UList<wordRe>& patchNames,
const bool warnNotFound = true
) const;

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
@ -73,19 +73,6 @@ protected:
//- Initialise the calculation of the patch geometry
void initGeometry(PstreamBuffers&);
// //- Initialise the calculation of the patch geometry with externally
// // provided geometry
// virtual void initGeometry
// (
// const primitivePatch& referPatch,
// UList<point>&,
// UList<point>&,
// UList<point>&
// )
// {
// notImplemented("processorCyclicPolyPatch::initGeometry(..)");
// }
//- Calculate the patch geometry
void calcGeometry(PstreamBuffers&);
@ -286,36 +273,6 @@ public:
return referPatch().owner();
}
// //- Transform a patch-based field from other side to this side.
// virtual bool doTransform() const
// {
// return referPatch().doTransform();
// }
// virtual void transform(scalarField& l) const
// {
// referPatch().transform(l);
// }
// virtual void transform(vectorField& l) const
// {
// referPatch().transform(l);
// }
// virtual void transform(sphericalTensorField& l) const
// {
// referPatch().transform(l);
// }
// virtual void transform(diagTensorField& l) const
// {
// referPatch().transform(l);
// }
// virtual void transform(symmTensorField& l) const
// {
// referPatch().transform(l);
// }
// virtual void transform(tensorField& l) const
// {
// referPatch().transform(l);
// }
//- Transform a patch-based position from other side to this side
virtual void transformPosition(pointField& l) const
{

View File

@ -101,6 +101,22 @@ bool Foam::SHA1Digest::empty() const
}
std::string Foam::SHA1Digest::str() const
{
std::string buf;
buf.resize(length*2);
unsigned nChar = 0;
for (unsigned i = 0; i < length; ++i)
{
buf[nChar++] = hexChars[((v_[i] >> 4) & 0xF)];
buf[nChar++] = hexChars[(v_[i] & 0xF)];
}
return buf;
}
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
bool Foam::SHA1Digest::operator==(const SHA1Digest& rhs) const

View File

@ -80,6 +80,9 @@ public:
//- Return true if the digest is empty (ie, all zero).
bool empty() const;
//- Return string representation
std::string str() const;
//- Equality operator
bool operator==(const SHA1Digest&) const;

View File

@ -96,75 +96,79 @@ Foam::string& Foam::string::replaceAll
// Expand all occurences of environment variables and initial tilde sequences
Foam::string& Foam::string::expand(const bool recurse, const bool allowEmptyVar)
{
size_type startEnvar = 0;
size_type begVar = 0;
// Expand $VARS
// Repeat until nothing more is found
while
(
(startEnvar = find('$', startEnvar)) != npos
&& startEnvar < size()-1
(begVar = find('$', begVar)) != npos
&& begVar < size()-1
)
{
if (startEnvar == 0 || operator[](startEnvar-1) != '\\')
if (begVar == 0 || operator[](begVar-1) != '\\')
{
// Find end of first occurrence
size_type endEnvar = startEnvar;
size_type nd = 0;
size_type endVar = begVar;
size_type delim = 0;
if (operator[](startEnvar+1) == '{')
if (operator[](begVar+1) == '{')
{
endEnvar = find('}', startEnvar);
nd = 1;
endVar = find('}', begVar);
delim = 1;
}
else
{
iterator iter = begin() + startEnvar + 1;
iterator iter = begin() + begVar + 1;
while (iter != end() && (isalnum(*iter) || *iter == '_'))
while
(
iter != end()
&& (isalnum(*iter) || *iter == '_')
)
{
++iter;
++endEnvar;
++endVar;
}
}
if (endEnvar != npos && endEnvar != startEnvar)
if (endVar != npos && endVar != begVar)
{
string enVar = substr
string varName = substr
(
startEnvar + 1 + nd,
endEnvar - startEnvar - 2*nd
begVar + 1 + delim,
endVar - begVar - 2*delim
);
string enVarString = getEnv(enVar);
string varValue = getEnv(varName);
if (enVarString.size())
if (varValue.size())
{
if (recurse)
{
enVarString.expand(recurse, allowEmptyVar);
varValue.expand(recurse, allowEmptyVar);
}
std::string::replace
(
startEnvar,
endEnvar - startEnvar + 1,
enVarString
begVar,
endVar - begVar + 1,
varValue
);
startEnvar += enVarString.size();
begVar += varValue.size();
}
else if (allowEmptyVar)
{
std::string::replace
(
startEnvar,
endEnvar - startEnvar + 1,
begVar,
endVar - begVar + 1,
""
);
}
else
{
FatalErrorIn("string::expand(const bool, const bool)")
<< "Unknown variable name " << enVar << '.'
<< "Unknown variable name " << varName << '.'
<< exit(FatalError);
}
}
@ -175,7 +179,7 @@ Foam::string& Foam::string::expand(const bool recurse, const bool allowEmptyVar)
}
else
{
startEnvar++;
++begVar;
}
}
@ -191,10 +195,10 @@ Foam::string& Foam::string::expand(const bool recurse, const bool allowEmptyVar)
word user;
fileName file;
if ((startEnvar = find('/')) != npos)
if ((begVar = find('/')) != npos)
{
user = substr(1, startEnvar - 1);
file = substr(startEnvar + 1);
user = substr(1, begVar - 1);
file = substr(begVar + 1);
}
else
{
@ -215,7 +219,7 @@ Foam::string& Foam::string::expand(const bool recurse, const bool allowEmptyVar)
}
else if (operator[](0) == '.')
{
// Expand initial '.' and './' into cwd
// Expand a lone '.' and an initial './' into cwd
if (size() == 1)
{
*this = cwd();

View File

@ -0,0 +1,383 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "stringOps.H"
#include "OSspecific.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::string Foam::stringOps::expand
(
const string& original,
const HashTable<string, word, string::hash>& mapping,
const char sigil
)
{
string s(original);
return inplaceExpand(s, mapping);
}
Foam::string& Foam::stringOps::inplaceExpand
(
string& s,
const HashTable<string, word, string::hash>& mapping,
const char sigil
)
{
string::size_type begVar = 0;
// Expand $VAR or ${VAR}
// Repeat until nothing more is found
while
(
(begVar = s.find(sigil, begVar)) != string::npos
&& begVar < s.size()-1
)
{
if (begVar == 0 || s[begVar-1] != '\\')
{
// Find end of first occurrence
string::size_type endVar = begVar;
string::size_type delim = 0;
if (s[begVar+1] == '{')
{
endVar = s.find('}', begVar);
delim = 1;
}
else
{
string::iterator iter = s.begin() + begVar + 1;
while
(
iter != s.end()
&& (isalnum(*iter) || *iter == '_')
)
{
++iter;
++endVar;
}
}
if (endVar != string::npos && endVar != begVar)
{
string varName = s.substr
(
begVar + 1 + delim,
endVar - begVar - 2*delim
);
HashTable<string, word, string::hash>::const_iterator fnd =
mapping.find(varName);
if (fnd != HashTable<string, word, string::hash>::end())
{
s.std::string::replace
(
begVar,
endVar - begVar + 1,
*fnd
);
begVar += (*fnd).size();
}
else
{
s.std::string::replace
(
begVar,
endVar - begVar + 1,
""
);
}
}
else
{
break;
}
}
else
{
++begVar;
}
}
return s;
}
Foam::string Foam::stringOps::expandEnv
(
const string& original,
const bool recurse,
const bool allowEmptyVar
)
{
string s(original);
return inplaceExpandEnv(s, recurse, allowEmptyVar);
}
// Expand all occurences of environment variables and initial tilde sequences
Foam::string& Foam::stringOps::inplaceExpandEnv
(
string& s,
const bool recurse,
const bool allowEmptyVar
)
{
string::size_type begVar = 0;
// Expand $VARS
// Repeat until nothing more is found
while
(
(begVar = s.find('$', begVar)) != string::npos
&& begVar < s.size()-1
)
{
if (begVar == 0 || s[begVar-1] != '\\')
{
// Find end of first occurrence
string::size_type endVar = begVar;
string::size_type delim = 0;
if (s[begVar+1] == '{')
{
endVar = s.find('}', begVar);
delim = 1;
}
else
{
string::iterator iter = s.begin() + begVar + 1;
while
(
iter != s.end()
&& (isalnum(*iter) || *iter == '_')
)
{
++iter;
++endVar;
}
}
if (endVar != string::npos && endVar != begVar)
{
string varName = s.substr
(
begVar + 1 + delim,
endVar - begVar - 2*delim
);
string varValue = getEnv(varName);
if (varValue.size())
{
if (recurse)
{
varValue.expand(recurse, allowEmptyVar);
}
s.std::string::replace
(
begVar,
endVar - begVar + 1,
varValue
);
begVar += varValue.size();
}
else if (allowEmptyVar)
{
s.std::string::replace
(
begVar,
endVar - begVar + 1,
""
);
}
else
{
FatalErrorIn("string::expand(const bool, const bool)")
<< "Unknown variable name " << varName << '.'
<< exit(FatalError);
}
}
else
{
break;
}
}
else
{
++begVar;
}
}
if (!s.empty())
{
if (s[0] == '~')
{
// Expand initial ~
// ~/ => home directory
// ~OpenFOAM => site/user OpenFOAM configuration directory
// ~user => home directory for specified user
word user;
fileName file;
if ((begVar = s.find('/')) != string::npos)
{
user = s.substr(1, begVar - 1);
file = s.substr(begVar + 1);
}
else
{
user = s.substr(1);
}
// NB: be a bit lazy and expand ~unknownUser as an
// empty string rather than leaving it untouched.
// otherwise add extra test
if (user == "OpenFOAM")
{
s = findEtcFile(file);
}
else
{
s = home(user)/file;
}
}
else if (s[0] == '.')
{
// Expand a lone '.' and an initial './' into cwd
if (s.size() == 1)
{
s = cwd();
}
else if (s[1] == '/')
{
s.std::string::replace(0, 1, cwd());
}
}
}
return s;
}
Foam::string Foam::stringOps::trimLeft(const string& s)
{
if (!s.empty())
{
string::size_type beg = 0;
while (isspace(s[beg]))
{
++beg;
}
if (beg)
{
return s.substr(beg);
}
}
return s;
}
Foam::string& Foam::stringOps::inplaceTrimLeft(string& s)
{
if (!s.empty())
{
string::size_type beg = 0;
while (isspace(s[beg]))
{
++beg;
}
if (beg)
{
s.erase(0, beg);
}
}
return s;
}
Foam::string Foam::stringOps::trimRight(const string& s)
{
if (!s.empty())
{
string::size_type sz = s.size();
while (sz && isspace(s[sz-1]))
{
--sz;
}
if (sz < s.size())
{
return s.substr(0, sz);
}
}
return s;
}
Foam::string& Foam::stringOps::inplaceTrimRight(string& s)
{
if (!s.empty())
{
string::size_type sz = s.size();
while (sz && isspace(s[sz-1]))
{
--sz;
}
s.resize(sz);
}
return s;
}
Foam::string Foam::stringOps::trim(const string& original)
{
return trimLeft(trimRight(original));
}
Foam::string& Foam::stringOps::inplaceTrim(string& s)
{
inplaceTrimRight(s);
inplaceTrimLeft(s);
return s;
}
// ************************************************************************* //

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/>.
Namespace
Foam::stringOps
Description
Collection of static functions to do various simple string-related
operations
SourceFiles
stringOps.C
\*---------------------------------------------------------------------------*/
#ifndef stringOps_H
#define stringOps_H
#include "string.H"
#include "HashTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Namespace stringOps Declaration
\*---------------------------------------------------------------------------*/
namespace stringOps
{
//- Expand occurences of variables according to the mapping
// Expansion includes:
// -# variables
// - "$VAR", "${VAR}"
//
// \note the leading sigil can be changed to avoid conflicts with other
// string expansions
string expand
(
const string&,
const HashTable<string, word, string::hash>& mapping,
const char sigil = '$'
);
//- Inplace expand occurences of variables according to the mapping
// Expansion includes:
// -# variables
// - "$VAR", "${VAR}"
//
// \note the leading sigil can be changed to avoid conflicts with other
// string expansions
string& inplaceExpand
(
string&,
const HashTable<string, word, string::hash>& mapping,
const char sigil = '$'
);
//- Expand initial tildes and all occurences of environment variables
// Expansion includes:
// -# environment variables
// - "$VAR", "${VAR}"
// -# current directory
// - leading "./" : the current directory
// -# tilde expansion
// - leading "~/" : home directory
// - leading "~user" : home directory for specified user
// - leading "~OpenFOAM" : site/user OpenFOAM configuration directory
//
// \sa
// Foam::findEtcFile
string expandEnv
(
const string&,
const bool recurse=false,
const bool allowEmptyVar = false
);
//- Expand initial tildes and all occurences of environment variables
// Expansion includes:
// -# environment variables
// - "$VAR", "${VAR}"
// -# current directory
// - leading "./" : the current directory
// -# tilde expansion
// - leading "~/" : home directory
// - leading "~user" : home directory for specified user
// - leading "~OpenFOAM" : site/user OpenFOAM configuration directory
//
// \sa
// Foam::findEtcFile
string& inplaceExpandEnv
(
string&,
const bool recurse=false,
const bool allowEmptyVar = false
);
//- Return string trimmed of leading whitespace
string trimLeft(const string&);
//- Trim leading whitespace inplace
string& inplaceTrimLeft(string&);
//- Return string trimmed of trailing whitespace
// NOT IMPLEMENTED
string trimRight(const string&);
//- Trim trailing whitespace inplace
// NOT IMPLEMENTED
string& inplaceTrimRight(string&);
//- Return string trimmed of leading and trailing whitespace
// NOT IMPLEMENTED
string trim(const string&);
//- Trim leading and trailing whitespace inplace
// NOT IMPLEMENTED
string& inplaceTrim(string&);
} // End namespace stringOps
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#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
@ -35,8 +35,6 @@ SourceFiles
#ifndef processorCyclicFvPatchField_H
#define processorCyclicFvPatchField_H
//#include "coupledFvPatchField.H"
//#include "processorLduInterfaceField.H"
#include "processorCyclicFvPatch.H"
#include "processorFvPatchField.H"
@ -52,8 +50,6 @@ namespace Foam
template<class Type>
class processorCyclicFvPatchField
:
// public processorLduInterfaceField,
// public coupledFvPatchField<Type>
public processorFvPatchField<Type>
{
// Private data
@ -61,14 +57,6 @@ class processorCyclicFvPatchField
//- Local reference cast into the processor patch
const processorCyclicFvPatch& procPatch_;
// Private Member Functions
// //- Get other patchfield
// const coupledFvPatchField<Type>& patchField
// (
// const label patchID
// ) const;
public:
//- Runtime type information
@ -151,70 +139,6 @@ public:
// Access
// //- Return true if running parallel
// virtual bool coupled() const
// {
// if (Pstream::parRun())
// {
// return true;
// }
// else
// {
// return false;
// }
// }
//
// //- Return neighbour field given internal field
// tmp<Field<Type> > patchNeighbourField() const;
//
//
// // Evaluation functions
//
// //- Initialise the evaluation of the patch field
// virtual void initEvaluate(const Pstream::commsTypes commsType);
//
// //- Evaluate the patch field
// virtual void evaluate(const Pstream::commsTypes commsType);
//
// //- Return patch-normal gradient
// virtual tmp<Field<Type> > snGrad() const;
//
// //- Initialise neighbour matrix update
// virtual void initInterfaceMatrixUpdate
// (
// const scalarField& psiInternal,
// scalarField& result,
// const lduMatrix& m,
// const scalarField& coeffs,
// const direction cmpt,
// const Pstream::commsTypes commsType
// ) const;
//
// //- Update result field based on interface functionality
// virtual void updateInterfaceMatrix
// (
// const scalarField& psiInternal,
// scalarField& result,
// const lduMatrix& m,
// const scalarField& coeffs,
// const direction cmpt,
// const Pstream::commsTypes commsType
// ) const;
//
// //- Processor coupled interface functions
//
// //- Return processor number
// virtual int myProcNo() const
// {
// return procPatch_.myProcNo();
// }
//
// //- Return neigbour processor number
// virtual int neighbProcNo() const
// {
// return procPatch_.neighbProcNo();
// }
//- Does the patch field perform the transfromation
virtual bool doTransform() const
{
@ -227,103 +151,6 @@ public:
return procPatch_.forwardT();
}
// //- Return rank of component for transform
// virtual int rank() const
// {
// return pTraits<Type>::rank;
// }
// //- Transform given patch component field
// void transformCoupleField
// (
// scalarField& f,
// const direction cmpt
// ) const;
// // Referred-patch functionality. Get called with a slice (size, start)
// // of a patch that supplies fields and geometry/topology.
//
// //- Get patch-normal gradient
// virtual void snGrad
// (
// Field<Type>& exchangeBuf,
// const Field<Type>& subFld,
// const coupledFvPatch& referringPatch,
// const label size,
// const label start
// ) const
// {
// notImplemented("processorCyclicFvPatchField::snGrad(..)");
// }
//
// //- Initialise the evaluation of the patch field.
// virtual void initEvaluate
// (
// Field<Type>& exchangeBuf,
// const coupledFvPatch& referringPatch,
// const label size,
// const label start
// ) const
// {
// notImplemented
// (
// "processorCyclicFvPatchField::initEvaluate(..)"
// );
// }
//
// //- Evaluate the patch field.
// virtual void evaluate
// (
// Field<Type>& exchangeBuf,
// const coupledFvPatch& referringPatch,
// const label size,
// const label start
// ) const
// {
// notImplemented("processorCyclicFvPatchField::evaluate(..)");
// }
//
// //- Initialise neighbour matrix update
// virtual void initInterfaceMatrixUpdate
// (
// const scalarField& psiInternal,
// scalarField& result,
// const lduMatrix& m,
// const scalarField& coeffs,
// const direction cmpt,
// const coupledFvPatch& referringPatch,
// const label size,
// const label start,
// scalarField& exchangeBuf
// ) const
// {
// notImplemented
// (
// "processorCyclicFvPatchField::"
// "initInterfaceMatrixUpdate(..)"
// );
// }
//
// //- Update result field based on interface functionality
// virtual void updateInterfaceMatrix
// (
// const scalarField& psiInternal,
// scalarField& result,
// const lduMatrix&,
// const scalarField& coeffs,
// const direction,
// const coupledFvPatch& referringPatch,
// const label size,
// const label start,
// scalarField& exchangeBuf
// ) const
// {
// notImplemented
// (
// "processorCyclicFvPatchField::updateInterfaceMatrix(..)"
// );
// }
};

View File

@ -44,7 +44,7 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class codeProperties Declaration
Class codeProperties Declaration
\*---------------------------------------------------------------------------*/
class codeProperties
@ -79,7 +79,7 @@ public:
modified_ = false;
}
//- Read the solution dictionary
//- Read the dictionary
virtual bool read();
};

View File

@ -32,8 +32,20 @@ License
#include "dlLibraryTable.H"
#include "IFstream.H"
#include "OFstream.H"
#include "SHA1Digest.H"
#include "OSHA1stream.H"
#include "codeStreamTools.H"
#include "codeProperties.H"
#include "stringOps.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const Foam::word Foam::codedFixedValueFvPatchScalarField::codeTemplateC
= "fixedValueFvPatchScalarFieldTemplate.C";
const Foam::word Foam::codedFixedValueFvPatchScalarField::codeTemplateH
= "fixedValueFvPatchScalarFieldTemplate.H";
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -68,81 +80,103 @@ Foam::codedFixedValueFvPatchScalarField::dict() const
void Foam::codedFixedValueFvPatchScalarField::writeLibrary
(
const fileName dir,
const fileName libPath,
const fileName& codePath,
const fileName& libPath,
const dictionary& dict
)
{
Info<< "Creating new library in " << libPath << endl;
// Write files for new library
if (Pstream::master())
if (!Pstream::master())
{
fileName templates(Foam::getEnv("FOAM_CODESTREAM_TEMPLATE_DIR"));
if (!templates.size())
return;
}
// "codeInclude" is optional
string codeInclude;
if (dict.found("codeInclude"))
{
codeInclude = stringOps::trim(dict["codeInclude"]);
}
// "codeOptions" is optional
string codeOptions;
if (dict.found("codeOptions"))
{
codeOptions = stringOps::trim(dict["codeOptions"]);
}
// "code" is mandatory
string code = stringOps::trim(dict["code"]);
// Create SHA1 digest from the contents
SHA1Digest sha;
{
OSHA1stream os;
os << codeInclude << codeOptions << code;
sha = os.digest();
}
// Info<<"old SHA1: " << sha1_ << nl
// <<"new SHA1: " << sha << endl;
// (void) codeStreamTools::upToDate(codePath, sha)
// TODO: compile on-demand
if (true)
{
Info<< "Creating new library in " << libPath << endl;
const fileName fileCsrc(codeStreamTools::findTemplate(codeTemplateC));
const fileName fileHsrc(codeStreamTools::findTemplate(codeTemplateH));
// not found!
if (fileCsrc.empty() || fileHsrc.empty())
{
FatalIOErrorIn
(
"codedFixedValueFvPatchScalarField::writeLibrary(..)",
dict
) << "Please set environment variable"
<< " FOAM_CODESTREAM_TEMPLATE_DIR"
<< " to point to the location of "
<< "fixedValueFvPatchScalarFieldTemplate.C"
) << "Could not find one or both code templates: "
<< codeTemplateC << ", " << codeTemplateH << nl
<< codeStreamTools::searchedLocations()
<< exit(FatalIOError);
}
// Extract sections of code
string codeInclude = "";
if (dict.found("codeInclude"))
{
codeInclude = codeStreamTools::stripLeading(dict["codeInclude"]);
}
string code = codeStreamTools::stripLeading(dict["code"]);
string codeOptions = "";
if (dict.found("codeOptions"))
{
codeOptions = codeStreamTools::stripLeading(dict["codeOptions"]);
}
List<codeStreamTools::fileAndVars> copyFiles(2);
copyFiles[0].file() = fileCsrc;
copyFiles[0].set("codeInclude", codeInclude);
copyFiles[0].set("code", code);
copyFiles[1].file() = fileHsrc;
List<fileAndVars> copyFiles(2);
copyFiles[0].first() =
templates/"fixedValueFvPatchScalarFieldTemplate.C";
List<codeStreamTools::fileAndContent> filesContents(2);
copyFiles[0].second().setSize(2);
copyFiles[0].second()[0] = Pair<string>("codeInclude", codeInclude);
copyFiles[0].second()[1] = Pair<string>("code", code);
copyFiles[1].first() =
templates/"fixedValueFvPatchScalarFieldTemplate.H";
List<fileAndContent> filesContents(2);
// Write Make/files
filesContents[0].first() = "Make/files";
filesContents[0].second() =
"fixedValueFvPatchScalarFieldTemplate.C \n\n"
"LIB = $(FOAM_USER_LIBBIN)/lib" + redirectType_;
codeTemplateC + "\n\n"
+ codeStreamTools::libTarget(redirectType_);
// Write Make/options
filesContents[1].first() = "Make/options";
filesContents[1].second() =
"EXE_INC = -g\\\n -I$(LIB_SRC)/finiteVolume/lnInclude\\\n"
"EXE_INC = -g \\\n"
"-I$(LIB_SRC)/finiteVolume/lnInclude\\\n"
+ codeOptions
+ "\n\nLIB_LIBS = ";
codeStreamTools writer(redirectType_, copyFiles, filesContents);
if (!writer.copyFilesContents(dir))
if (!writer.copyFilesContents(codePath))
{
FatalIOErrorIn
(
"codedFixedValueFvPatchScalarField::writeLibrary(..)",
dict
) << "Failed writing " << endl
<< copyFiles << endl
) << "Failed writing " << nl
<< copyFiles << nl
<< filesContents
<< exit(FatalIOError);
}
@ -165,18 +199,20 @@ void Foam::codedFixedValueFvPatchScalarField::updateLibrary()
<< exit(FatalIOError);
}
const fileName dir =
db().time().constantPath()/"codeStream"/redirectType_;
//Info<< "dir:" << dir << endl;
// write code into redirectType_ subdir
const fileName codePath = codeStreamTools::codePath(redirectType_);
const fileName libPath
(
Foam::getEnv("FOAM_USER_LIBBIN")
/ "lib"
+ redirectType_
+ ".so"
);
//Info<< "libPath:" << libPath << endl;
// const fileName oldLibPath = codeStreamTools::libPath
// (
// redirectType_ + "_" + sha1_
// );
// write library into platforms/$WM_OPTIONS/lib subdir
const fileName libPath = codeStreamTools::libPath(redirectType_);
//Info<< "codePath:" << codePath << nl
// << "libPath:" << libPath << endl;
void* lib = dlLibraryTable::findLibrary(libPath);
@ -184,7 +220,7 @@ void Foam::codedFixedValueFvPatchScalarField::updateLibrary()
{
if (!lib)
{
writeLibrary(dir, libPath, dict_);
writeLibrary(codePath, libPath, dict_);
}
}
else
@ -213,7 +249,7 @@ void Foam::codedFixedValueFvPatchScalarField::updateLibrary()
}
const dictionary& codeDict = onTheFlyDict.subDict(redirectType_);
writeLibrary(dir, libPath, codeDict);
writeLibrary(codePath, libPath, codeDict);
}
}
@ -221,7 +257,7 @@ void Foam::codedFixedValueFvPatchScalarField::updateLibrary()
{
if (Pstream::master())
{
Foam::string wmakeCmd("wmake libso " + dir);
const Foam::string wmakeCmd("wmake libso " + codePath);
Info<< "Invoking " << wmakeCmd << endl;
if (Foam::system(wmakeCmd))
{
@ -229,7 +265,8 @@ void Foam::codedFixedValueFvPatchScalarField::updateLibrary()
(
"codedFixedValueFvPatchScalarField::updateLibrary()",
dict_
) << "Failed " << wmakeCmd << exit(FatalIOError);
) << "Failed " << wmakeCmd
<< exit(FatalIOError);
}
}
@ -242,7 +279,8 @@ void Foam::codedFixedValueFvPatchScalarField::updateLibrary()
(
"codedFixedValueFvPatchScalarField::updateLibrary()",
dict_
) << "Failed loading library " << libPath << exit(FatalIOError);
) << "Failed loading library " << libPath
<< exit(FatalIOError);
}
}
}

View File

@ -32,7 +32,7 @@ Description
See also codeStream.
Example:
\verbatim
movingWall
{
type codedFixedValue<scalar>;
@ -53,13 +53,14 @@ Description
//#{
// -I$(LIB_SRC)/finiteVolume/lnInclude
//#};
}
\endverbatim
A special form is if the 'code' section is not supplied. In this case
the code gets read from a (runTimeModifiable!) dictionary system/codeDict
which would have an entry
which would have a corresponding entry
\verbatim
rampedFixedValue
{
code
@ -67,6 +68,10 @@ Description
operator==(min(10, 0.1*this->db().time().value()));
#};
}
\endverbatim
SeeAlso
Foam::codeStreamTools for constant paths used
SourceFiles
codedFixedValueFvPatchScalarField.C
@ -77,6 +82,7 @@ SourceFiles
#define codedFixedValueFvPatchScalarField_H
#include "fixedValueFvPatchFields.H"
#include "SHA1Digest.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -86,7 +92,7 @@ namespace Foam
class codeProperties;
/*---------------------------------------------------------------------------*\
Class codedFixedValueFvPatchScalarField Declaration
Class codedFixedValueFvPatchScalarField Declaration
\*---------------------------------------------------------------------------*/
class codedFixedValueFvPatchScalarField
@ -95,8 +101,13 @@ class codedFixedValueFvPatchScalarField
{
// Private data
//- Dictionary contents for the boundary condition
mutable dictionary dict_;
//- SHA1Digest of the Dictionary contents
// Currently unused, but useful for reloading?
mutable SHA1Digest sha1_;
const word redirectType_;
mutable autoPtr<fvPatchScalarField> redirectPatchFieldPtr_;
@ -108,8 +119,8 @@ class codedFixedValueFvPatchScalarField
void writeLibrary
(
const fileName dir,
const fileName libPath,
const fileName& dir,
const fileName& libPath,
const dictionary& dict
);
@ -117,6 +128,15 @@ class codedFixedValueFvPatchScalarField
public:
// Static data members
//- Name of the C code template to be used
const static word codeTemplateC;
//- Name of the H code template to be used
const static word codeTemplateH;
//- Runtime type information
TypeName("codedFixedValue<scalar>");

View File

@ -7,4 +7,3 @@ LIB_LIBS = \
-lfiniteVolume \
-lOpenFOAM \
-lmeshTools

View File

@ -71,7 +71,11 @@ Foam::ParticleForceList<CloudType>::ParticleForceList
forAllConstIter(wordHashSet, models, iter)
{
const word& model = iter.key();
set(i, ParticleForce<CloudType>::New(owner, mesh, dict, model));
this->set
(
i,
ParticleForce<CloudType>::New(owner, mesh, dict, model)
);
i++;
}
}

View File

@ -41,7 +41,7 @@ const
"const"
) << "gradU field not allocated" << abort(FatalError);
return reinterpret_cast<const volTensorField>(0);
return *reinterpret_cast<const volTensorField*>(0);
}
}

View File

@ -72,7 +72,7 @@ Foam::BrownianMotionForce<CloudType>::BrownianMotionForce
if (turbulence_)
{
HashTable<const compressible::turbulenceModel*> models =
this->mesh().objectRegistry::lookupClass
this->mesh().objectRegistry::template lookupClass
<
compressible::turbulenceModel
>();

View File

@ -24,16 +24,14 @@ License
\*---------------------------------------------------------------------------*/
#include "nearWallFields.H"
#include "wordReList.H"
//#include "volFields.H"
//#include "selfContainedDirectMappedFixedValueFvPatchFields.H"
//#include "interpolationCellPoint.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(nearWallFields, 0);
}
defineTypeNameAndDebug(Foam::nearWallFields, 0);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -87,7 +85,10 @@ void Foam::nearWallFields::read(const dictionary& dict)
const fvMesh& mesh = refCast<const fvMesh>(obr_);
dict.lookup("fields") >> fieldSet_;
patchSet_ = mesh.boundaryMesh().patchSet(dict.lookup("patches"));
patchSet_ = mesh.boundaryMesh().patchSet
(
wordReList(dict.lookup("patches"))
);
distance_ = readScalar(dict.lookup("distance"));

View File

@ -27,6 +27,7 @@ License
#include "volFields.H"
#include "dictionary.H"
#include "Time.H"
#include "wordReList.H"
#include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H"
#include "incompressible/RAS/RASModel/RASModel.H"
@ -229,7 +230,10 @@ void Foam::forces::read(const dictionary& dict)
const fvMesh& mesh = refCast<const fvMesh>(obr_);
patchSet_ = mesh.boundaryMesh().patchSet(dict.lookup("patches"));
patchSet_ = mesh.boundaryMesh().patchSet
(
wordReList(dict.lookup("patches"))
);
if (directForceDensity_)
{

View File

@ -34,4 +34,3 @@ derivedFvPatchFields/radiationCoupledBase/radiationCoupledBase.C
derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.C
LIB = $(FOAM_LIBBIN)/libradiationModels

View File

@ -23,5 +23,3 @@ LIB_LIBS = \
-lliquidMixtureProperties \
-lsolidProperties \
-lliquidProperties

View File

@ -139,17 +139,17 @@ greyMeanAbsorptionEmissionCoeffs
{
Tcommon 300;
invTemp false;
Tlow 200;
Tlow 200;
Thigh 2500;
loTcoeffs
(
0.01
0
0
0
0
0
0
0
0
0
0
);
hiTcoeffs
(
@ -172,14 +172,14 @@ greyMeanAbsorptionEmissionCoeffs
loTcoeffs
(
0.01
0
0
0
0
0
0.01
0
0
0
0
0
);
hiTcoeffs
hiTcoeffs
(
0.01
0

View File

@ -135,22 +135,22 @@ greyMeanAbsorptionEmissionCoeffs
0
);
}
N2
{
Tcommon 300;
invTemp false;
Tlow 200;
Tlow 200;
Thigh 2500;
loTcoeffs
(
0.01
0
0
0
0
0
0
0
0
0
0
);
hiTcoeffs
(
@ -173,14 +173,14 @@ greyMeanAbsorptionEmissionCoeffs
loTcoeffs
(
0.01
0
0
0
0
0
0.01
0
0
0
0
0
);
hiTcoeffs
hiTcoeffs
(
0.01
0

View File

@ -18,23 +18,23 @@ done
## remove solid fields from fluid regions (important for post-processing)
for i in bottomAir topAir
do
rm -f 0*/$i/{Ypmma,Ychar}
rm -f 0*/$i/{Ypmma,Ychar}
done
for i in bottomAir topAir heater leftSolid rightSolid
do
changeDictionary -region $i > log.changeDictionary.$i 2>&1
changeDictionary -region $i > log.changeDictionary.$i 2>&1
done
for i in bottomAir topAir
for i in bottomAir topAir
do
faceAgglomerate -region $i > log.faceAgglomerate.$i 2>&1
faceAgglomerate -region $i > log.faceAgglomerate.$i 2>&1
done
for i in bottomAir topAir
for i in bottomAir topAir
do
viewFactorsGen -region $i > log.viewFactorsGen.$i 2>&1
viewFactorsGen -region $i > log.viewFactorsGen.$i 2>&1
done
@ -63,7 +63,7 @@ echo "creating files for paraview post-processing"
echo
for i in bottomAir topAir heater leftSolid rightSolid
do
paraFoam -touch -region $i
paraFoam -touch -region $i
done
# ----------------------------------------------------------------- end-of-file

View File

@ -65,3 +65,5 @@ maxZ
featureAngle 10;
}
// ************************************************************************* //

View File

@ -67,3 +67,5 @@ maxZ
featureAngle 10;
}
// ************************************************************************* //

View File

@ -1,3 +1,2 @@
fvSolution is used for outer correctors specification.
fvSchemes is only so that pre-processing activities can proceed

View File

@ -163,7 +163,7 @@ dictionaryReplacement
}
}
}
IDefault
{
internalField uniform 0;

View File

@ -45,7 +45,7 @@ solvers
tolerance 1e-7;
relTol 0.1;
}
G
{
$p_rgh;

View File

@ -43,7 +43,7 @@ dictionaryReplacement
type zeroGradient;
value uniform 300;
}
heater_to_topAir
{
type compressible::turbulentTemperatureRadCoupledMixed;
@ -51,10 +51,10 @@ dictionaryReplacement
K solidThermo;
QrNbr Qr;
Qr none;
KName none;
KName none;
value uniform 300;
}
heater_to_bottomAir
{
type compressible::turbulentTemperatureRadCoupledMixed;
@ -62,10 +62,10 @@ dictionaryReplacement
K solidThermo;
QrNbr Qr;
Qr none;
KName none;
KName none;
value uniform 300;
}
"heater_to_.*"
{
type compressible::turbulentTemperatureCoupledBaffleMixed;

View File

@ -39,7 +39,7 @@ dictionaryReplacement
type zeroGradient;
value uniform 300;
}
leftSolid_to_topAir
{
type compressible::turbulentTemperatureRadCoupledMixed;
@ -47,10 +47,10 @@ dictionaryReplacement
K solidThermo;
QrNbr Qr;
Qr none;
KName none;
KName none;
value uniform 300;
}
leftSolid_to_bottomAir
{
type compressible::turbulentTemperatureRadCoupledMixed;
@ -58,10 +58,10 @@ dictionaryReplacement
K solidThermo;
QrNbr Qr;
Qr none;
KName none;
KName none;
value uniform 300;
}
"leftSolid_to_.*"
{
type compressible::turbulentTemperatureCoupledBaffleMixed;

View File

@ -39,7 +39,7 @@ dictionaryReplacement
type zeroGradient;
value uniform 300;
}
rightSolid_to_topAir
{
type compressible::turbulentTemperatureRadCoupledMixed;
@ -47,10 +47,10 @@ dictionaryReplacement
K solidThermo;
QrNbr Qr;
Qr none;
KName none;
KName none;
value uniform 300;
}
rightSolid_to_bottomAir
{
type compressible::turbulentTemperatureRadCoupledMixed;
@ -58,10 +58,10 @@ dictionaryReplacement
K solidThermo;
QrNbr Qr;
Qr none;
KName none;
KName none;
value uniform 300;
}
"rightSolid_to_.*"
{
type compressible::turbulentTemperatureCoupledBaffleMixed;

View File

@ -69,7 +69,7 @@ dictionaryReplacement
K basicThermo;
QrNbr none;
Qr Qr;
KName none;
KName none;
value uniform 300;
}
}
@ -162,7 +162,7 @@ dictionaryReplacement
}
}
}
Qr
{
internalField uniform 0;
@ -176,7 +176,7 @@ dictionaryReplacement
emissivity uniform 1.0;
value uniform 0;
}
"topAir_to_.*"
{
type greyDiffusiveRadiationViewFactor;
@ -186,7 +186,7 @@ dictionaryReplacement
}
}
}
G
{
internalField uniform 0;
@ -200,7 +200,7 @@ dictionaryReplacement
emissivity uniform 1.0;
value uniform 0;
}
"topAir_to_.*"
{
type MarshakRadiation;
@ -210,7 +210,7 @@ dictionaryReplacement
}
}
}
IDefault
{
internalField uniform 0;

View File

@ -47,7 +47,7 @@ solvers
tolerance 1e-7;
relTol 0.1;
}
G
{
$p_rgh;

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / O peration | Version: dev.olesenm |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -45,5 +45,36 @@ timePrecision 6;
runTimeModifiable true;
functions
{
systemCall1
{
type systemCall;
functionObjectLibs ("libsystemCall.so");
enabled true;
outputControl outputTime;
// called every time step
executeCalls
(
"echo execute"
);
// called at the end of the run
endCalls
(
"echo \*\*\* writing .bashrc \*\*\*"
"cat ~/.bashrc"
"echo \*\*\* done \*\*\*"
);
// called every ouput time
writeCalls
(
"echo \*\*\* writing data \*\*\*"
);
}
}
// ************************************************************************* //

View File

@ -25,8 +25,7 @@ boundaryField
{
type MarshakRadiation;
T T;
emissivityMode lookup;
emissivity uniform 1.0;
emissivity 1;
value uniform 0;
refValue uniform 0;
refGradient uniform 0;
@ -36,8 +35,7 @@ boundaryField
{
type MarshakRadiation;
T T;
emissivityMode lookup;
emissivity uniform 1.0;
emissivity 1;
value uniform 0;
refValue uniform 0;
refGradient uniform 0;

View File

@ -1,6 +1,7 @@
.SUFFIXES: .C .cxx .cc .cpp
c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor
# -Woverloaded-virtual may produce spurious warnings, disable for now
c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -Wno-overloaded-virtual
CC = clang++ -m64

View File

@ -1,6 +1,7 @@
.SUFFIXES: .C .cxx .cc .cpp
c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast
# -Woverloaded-virtual may produce spurious warnings, disable for now
c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -Wno-overloaded-virtual
CC = clang++ -m32