resolving merge conflict

This commit is contained in:
andy
2008-06-17 12:09:22 +01:00
55 changed files with 858 additions and 871 deletions

View File

@ -1,10 +1,13 @@
#!/bin/sh
set -x
# run from this directory only
cd ${0%/*} || exit 1
# wmake is required for subsequent targets
(cd wmake/src && make)
(cd $WM_PROJECT_INST_DIR/ThirdParty && ./Allwmake)
(cd $WM_THIRD_PARTY_DIR && ./Allwmake)
(cd src && ./Allwmake)

63
README
View File

@ -29,8 +29,8 @@
2. System requirements
~~~~~~~~~~~~~~~~~~~~~~
OpenFOAM is developed and tested on Linux, but should work with other
Unix style system. To check your system setup, execute the foamSystemCheck
script in the bin directory of the OpenFOAM installation. If no problems
Unix style systems. To check your system setup, execute the foamSystemCheck
script in the bin/ directory of the OpenFOAM installation. If no problems
are reported, proceed to "3. Installation"; otherwise contact your
system administrator.
@ -40,7 +40,6 @@
3. Installation
~~~~~~~~~~~~~~~
Download and unpack the files in the $HOME/OpenFOAM directory as described
in: http://www.OpenFOAM.org/download.html
@ -77,10 +76,9 @@
3.1. Installation in alternative locations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
OpenFOAM may also be installed in an alternative location.
However, the installation directory must be network available
(eg, NFS) if parallel calculations are planned.
OpenFOAM may also be installed in alternative locations. However, the
installation directory should be network available (e.g., NFS) if
parallel calculations are planned.
The environment variable 'FOAM_INST_DIR' can be used to find and source
the appropriate resource file. Here is a bash/ksh/sh example:
@ -89,7 +87,7 @@
foamDotFile=$FOAM_INST_DIR/OpenFOAM-<VERSION>/etc/bashrc
[ -f $foamDotFile ] && . $foamDotFile
and a csh example:
and a csh/tcsh example:
setenv FOAM_INST_DIR /data/app/OpenFOAM
foamDotFile=$FOAM_INST_DIR/OpenFOAM-<VERSION>/etc/bashrc
@ -102,9 +100,8 @@
4. Building from Sources (Optional)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you cannot find an appropriate binary pack for your platform, you can
build the complete OpenFOAM from the source-pack. First you will need to
build the complete OpenFOAM from the source-pack. You will first need to
compile or obtain a recent version of gcc (we recomend gcc-4.2.?) for
your platform, which may be obtained from http://gcc.gnu.org/.
@ -114,29 +111,27 @@
$WM_PROJECT_DIR/etc/settings.csh appropriately and finally update the
environment variables as in section 3.
Now go to the top-level source directory $WM_PROJECT_DIR and type
./Allwmake, which is the name of the top-level build script for building
the whole of OpenFOAM. In principle this will build everything, but
sometimes problems occur with the build order and it is necessary to
update the environment variables and re-execute Allwmake. If you
experience difficulties with building the source-pack or your platform is
not currently supported please contact <enquiries@OpenCFD.co.uk> to
negotiate a support contract and we will do the port and maintain it in
Now go to the top-level source directory $WM_PROJECT_DIR and execute the
top-level build script './Allwmake'. In principle this will build
everything, but if problems occur with the build order it may be necessary
to update the environment variables and re-execute 'Allwmake'. If you
experience difficulties with building the source-pack, or your platform is
not currently supported, please contact <enquiries@OpenCFD.co.uk> to
negotiate a support contract and we will do the port and maintain it for
future releases.
5. Testing the installation
~~~~~~~~~~~~~~~~~~~~~~~~~~~
To check your installation setup, execute the 'foamInstallationTest'
script (in the bin directory of the OpenFOAM installation). If no problems
are reported, proceed to getting started with OpenFOAM; otherwise, go back
and check you have installed the software correctly and/or contact your
system administrator.
script (in the bin/ directory of the OpenFOAM installation). If no
problems are reported, proceed to getting started with OpenFOAM;
otherwise, go back and check you have installed the software correctly
and/or contact your system administrator.
6. Getting Started
~~~~~~~~~~~~~~~~~~
Create a project directory within the $HOME/OpenFOAM directory named
<USER>-<VERSION> (e.g. 'chris-1.5' for user chris and OpenFOAM version 1.5)
and create a directory named 'run' within it, e.g. by typing:
@ -144,7 +139,7 @@
mkdir -p $HOME/OpenFOAM/${USER}-${WM_PROJECT_VERSION}/run
Copy the 'tutorial' examples directory in the OpenFOAM distribution to the
'run' directory. If OpenFOAM environment variables are set correctly,
'run' directory. If the OpenFOAM environment variables are set correctly,
then the following command will be correct:
cp -r $WM_PROJECT_DIR/tutorials $HOME/OpenFOAM/${USER}-${WM_PROJECT_VERSION}/run
@ -158,27 +153,27 @@
7. Documentation
~~~~~~~~~~~~~~~~
http://www.OpenFOAM.org/doc
http://www.OpenFOAM.org/doc
8. Help
~~~~~~~
http://www.OpenFOAM.org
http://www.OpenFOAM.org/discussion.html
http://www.OpenFOAM.org
http://www.OpenFOAM.org/discussion.html
9. Reporting Bugs in OpenFOAM
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
http://www.OpenFOAM.org/bugs.html
http://www.OpenFOAM.org/bugs.html
A. Running OpenFOAM in 32-bit mode on 64-bit machines
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Those users with an installation of Linux on a 64-bit machine may install
either or both of the 32-bit version of OpenFOAM (linux) or the 64-bit
version of FOAM (linux64) with 64-bit being the default mode. In order to
set up the user to run in 32-bit mode, the user must set the environment
variable $WM_32 (to anything, e.g. "on") before sourcing the etc/bashrc
(or etc/cshrc) file. Unsetting $WM_32 and sourcing the bashrc file will
Linux users with a 64-bit machine may install either the OpenFOAM 32-bit
version (linux) or the OpenFOAM 64-bit version (linux64), or both.
The 64-bit is the default mode on a 64-bit machine. To use an installed
32-bit version, the user must set the environment variable $WM_32 (to
anything, e.g. "on") before sourcing the etc/bashrc (or etc/cshrc) file.
Unsetting WM_32 and re-sourcing the etc/bashrc (or etc/cshrc) file will
set up the user to run in 64-bit mode.

View File

@ -42,24 +42,17 @@ namespace functionEntries
(
functionEntry,
calcEntry,
insert,
execute,
primitiveEntryIstream
);
addToMemberFunctionSelectionTable
(
functionEntry,
calcEntry,
insert,
dictionaryIstream
);
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionEntries::calcEntry::insert
bool Foam::functionEntries::calcEntry::execute
(
const dictionary& parentDict,
primitiveEntry& entry,
@ -75,14 +68,4 @@ bool Foam::functionEntries::calcEntry::insert
}
bool Foam::functionEntries::calcEntry::insert
(
dictionary& parentDict,
Istream& is
)
{
return true;
}
// ************************************************************************* //

View File

@ -69,18 +69,13 @@ public:
// Member Functions
static bool insert
static bool execute
(
const dictionary& parentDict,
primitiveEntry& entry,
Istream& is
);
static bool insert
(
dictionary& parentDict,
Istream& is
);
};

View File

@ -1,17 +1,19 @@
/*-------------------------------*- C++ -*---------------------------------*\
| ========= |
| \\ / OpenFOAM |
| \\ / |
| \\ / The Open Source CFD Toolbox |
| \\/ http://www.OpenFOAM.org |
\*-------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
root "";
case "";
instance "";
local "";
class dictionary;
object testDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#inputMode merge
dimensions [ 0 2 -2 0 0 0 0 ];
internalField uniform 1;
@ -29,7 +31,6 @@ inactive
type zeroGradient;
}
boundaryField
{
Default_Boundary_Region
@ -40,6 +41,12 @@ boundaryField
inlet_1 { $active }
inlet_2 { $inactive }
inlet_3 { $inactive }
inlet_4 { $inactive }
inlet_5 "a primitiveEntry is squashed by a directory entry";
inlet_5 { $inactive }
inlet_6 { $inactive }
inlet_7 { $inactive }
inlet_8 { $inactive }
#include "testDictInc"
@ -48,8 +55,44 @@ boundaryField
type inletOutlet;
inletValue $internalField;
value #include "value";
// error #remove self;
x 5;
y 6;
another #calc{x $x; y $y;};
}
// this should have no effect
#remove inactive
inlet_7 { $active }
#inputMode overwrite
inlet_8 { $active }
}
// NB: the inputMode has a global scope
#inputMode merge
#include "testDict2"
foo
{
$active
}
bar
{
$active
}
baz
{
$active
}
// this should work
#remove active
// this should work too
#remove ( bar baz )
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -0,0 +1,30 @@
/*-------------------------------*- C++ -*---------------------------------*\
| ========= |
| \\ / OpenFOAM |
| \\ / |
| \\ / The Open Source CFD Toolbox |
| \\/ http://www.OpenFOAM.org |
\*-------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object testDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
boundaryField
{
Default_Boundary_Region
{
value $internalField;
note "actually a noslip wall";
}
inlet_3 "a primitiveEntry squashes directory entry";
}
#inputMode overwrite
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -1 +1,2 @@
uniform 2
// the trailing ';' shouldn't actually be there, but shouldn't cause problems
uniform 2;

View File

@ -2,6 +2,9 @@
# Build optional components (eg, may depend on third-party libraries)
set -x
# run from this directory only
cd ${0%/*} || exit 1
# build libccmio if required
if [ ! -e $FOAM_LIBBIN/libccmio.so ]
then

View File

@ -90,17 +90,15 @@ if [ "$spawn" -ne 1 -a "$spawn" -ne 2 ]; then
exit 1
fi
# check ~/.OpenFOAM-VERSION
# check <site>/etc
# check <site>/.OpenFOAM-VERSION
# check ~/.$WM_PROJECT/$WM_PROJECT_VERSION/
# check ~/.$WM_PROJECT/
# check <installedProject>/etc/
if [ "$WM_PROJECT" ]; then
: ${FOAM_DOT_DIR:=.$WM_PROJECT-$WM_PROJECT_VERSION}
for i in \
$HOME/$FOAM_DOT_DIR \
$HOME/.WM_PROJECT/$WM_PROJECT_VERSION \
$HOME/.WM_PROJECT \
$WM_PROJECT_DIR/etc \
$WM_PROJECT_DIR/$FOAM_DOT_DIR \
;
do
if [ -f "$i/bashrc" ]; then
@ -112,7 +110,12 @@ fi
# Construct test string for remote execution.
# Source OpenFOAM settings if OpenFOAM environment not set.
sourceFoam='[ "$WM_PROJECT" ] || . '"$sourceFoam"
# attempt to preserve the installation directory 'FOAM_INST_DIR'
if [ "$FOAM_INST_DIR" ]; then
sourceFoam='[ "$WM_PROJECT" ] || '"FOAM_INST_DIR=$FOAM_INST_DIR . $sourceFoam"
else
sourceFoam='[ "$WM_PROJECT" ] || '". $sourceFoam"
fi
echo "**sourceFoam:$sourceFoam"

View File

@ -1,5 +1,4 @@
#!/bin/sh
#------------------------------------------------------------------------------
#---------------------------------*- sh -*-------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |

View File

@ -1,5 +1,4 @@
#!/bin/sh
#------------------------------------------------------------------------------
#---------------------------------*- sh -*-------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |

View File

@ -1,5 +1,4 @@
#!/bin/sh
#------------------------------------------------------------------------------
#---------------------------------*- sh -*-------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
@ -48,6 +47,7 @@ initialiseVariables ()
if [ "$VERBOSE" = ON ]; then
addCMakeVariable "CMAKE_VERBOSE_MAKEFILE=TRUE"
fi
addCMakeVariable "VTK_USE_TK=FALSE"
}

View File

@ -1,5 +1,4 @@
#!/bin/sh
#------------------------------------------------------------------------------
#---------------------------------*- sh -*-------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |

View File

@ -38,6 +38,12 @@ alias wm32 'setenv WM_ARCH_OPTION 32; source $WM_PROJECT_DIR/etc/cshrc'
alias wmSP 'setenv WM_PRECISION_OPTION SP; source $WM_PROJECT_DIR/etc/cshrc'
alias wmDP 'setenv WM_PRECISION_OPTION DP; source $WM_PROJECT_DIR/etc/cshrc'
# Toggle wmakeScheduler on/off
# - also need to set WM_HOSTS
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias wmSchedON 'setenv WM_SCHEDULER $WM_PROJECT_DIR/wmake/wmakeScheduler'
alias wmSchedOFF 'unsetenv WM_SCHEDULER'
# Change directory aliases
# ~~~~~~~~~~~~~~~~~~~~~~~~
alias src 'cd $FOAM_SRC'

View File

@ -38,6 +38,12 @@ alias wm32='export WM_ARCH_OPTION=32; . $WM_PROJECT_DIR/etc/bashrc'
alias wmSP='export WM_PRECISION_OPTION=SP; . $WM_PROJECT_DIR/etc/bashrc'
alias wmDP='export WM_PRECISION_OPTION=DP; . $WM_PROJECT_DIR/etc/bashrc'
# Toggle wmakeScheduler on/off
# - also need to set WM_HOSTS
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias wmSchedON='export WM_SCHEDULER=$WM_PROJECT_DIR/wmake/wmakeScheduler'
alias wmSchedOFF='unset WM_SCHEDULER'
# Change directory aliases
# ~~~~~~~~~~~~~~~~~~~~~~~~
alias src='cd $FOAM_SRC'

View File

@ -213,25 +213,13 @@ bool Foam::chDir(const fileName& dir)
Foam::fileName Foam::dotFoam(const fileName& name)
{
// Search for file 'name' in:
// 1) ~/.OpenFOAM-VERSION/, ~/.OpenFOAM/VERSION/ or ~/.OpenFOAM/
// 2) $WM_PROJECT_INST_DIR/site/VERSION or $WM_PROJECT_INST_DIR/site/
// 3) $WM_PROJECT_DIR/etc/
// Search user files:
// ~~~~~~~~~~~~~~~~~~
// Check for user file in ~/.OpenFOAM-VERSION/
fileName fullName = home()/(word(".OpenFOAM-") + FOAMversion)/name;
if (exists(fullName))
{
return fullName;
}
fileName searchDir = home()/".OpenFOAM";
if (dir(searchDir))
{
// Check for user file in ~/.OpenFOAM/VERSION
fullName = searchDir/FOAMversion/name;
fileName fullName = searchDir/FOAMversion/name;
if (exists(fullName))
{
return fullName;
@ -252,7 +240,7 @@ Foam::fileName Foam::dotFoam(const fileName& name)
if (dir(searchDir))
{
// Check for site file in $WM_PROJECT_INST_DIR/site/VERSION
fullName = searchDir/"site"/FOAMversion/name;
fileName fullName = searchDir/"site"/FOAMversion/name;
if (exists(fullName))
{
return fullName;
@ -272,14 +260,14 @@ Foam::fileName Foam::dotFoam(const fileName& name)
if (dir(searchDir))
{
// Check for shipped OpenFOAM file in $WM_PROJECT_DIR/etc
fullName = searchDir/"etc"/name;
fileName fullName = searchDir/"etc"/name;
if (exists(fullName))
{
return fullName;
}
}
// Nothing found
// Not found
return fileName::null;
}

View File

@ -122,6 +122,7 @@ functionEntries = $(dictionary)/functionEntries
$(functionEntries)/functionEntry/functionEntry.C
$(functionEntries)/includeEntry/includeEntry.C
$(functionEntries)/inputModeEntry/inputModeEntry.C
$(functionEntries)/removeEntry/removeEntry.C
IOdictionary = db/IOobjects/IOdictionary
$(IOdictionary)/IOdictionary.C

View File

@ -1,5 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/zlib-1.2.3
-I$(WM_THIRD_PARTY_DIR)/zlib-1.2.3
LIB_LIBS = \
$(FOAM_LIBBIN)/libOSspecific.o \

View File

@ -329,12 +329,9 @@ public:
// Writing
//- Write the standard OpenFOAM file/dictionary banner
// Optionally without -*- C++ -*- editor hint (eg, for logs)
template<class Stream>
static inline void writeBanner(Stream& os);
//- Write the standard OpenFOAM log banner
template<class Stream>
static inline void writeLogBanner(Stream& os);
static inline void writeBanner(Stream& os, bool noHint=false);
//- Write the standard file section divider
template<class Stream>

View File

@ -29,48 +29,34 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Stream>
inline void Foam::IOobject::writeBanner(Stream& os)
inline void Foam::IOobject::writeBanner(Stream& os, bool noHint)
{
static bool spacesSet = false;
static char spaces[80];
static char spaces[40];
if (!spacesSet)
{
memset(spaces, ' ', 80);
memset(spaces, ' ', 40);
spaces[38 - strlen(Foam::FOAMversion)] = '\0';
spacesSet = true;
}
os <<
"/*--------------------------------*- C++ -*----------------------------------*\\\n"
"| ========= | |\n"
"| \\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox |\n"
"| \\\\ / O peration | Version: " << FOAMversion << spaces << "|\n"
"| \\\\ / A nd | Web: http://www.openfoam.org |\n"
"| \\\\/ M anipulation | |\n"
"\\*---------------------------------------------------------------------------*/\n";
}
template<class Stream>
inline void Foam::IOobject::writeLogBanner(Stream& os)
{
static bool spacesSet = false;
static char spaces[80];
if (!spacesSet)
if (noHint)
{
memset(spaces, ' ', 80);
spaces[38 - strlen(Foam::FOAMversion)] = '\0';
spacesSet = true;
os <<
"/*---------------------------------------------------------------------------*\\\n";
}
else
{
os <<
"/*--------------------------------*- C++ -*----------------------------------*\\\n";
}
os <<
"/*---------------------------------------------------------------------------*\\\n"
"| ========= | |\n"
"| \\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox |\n"
"| \\\\ / O peration | Version: " << FOAMversion << spaces << "|\n"
"| \\\\ / A nd | Web: http://www.openfoam.org |\n"
"| \\\\ / A nd | Web: http://www.OpenFOAM.org |\n"
"| \\\\/ M anipulation | |\n"
"\\*---------------------------------------------------------------------------*/\n";
}

View File

@ -37,8 +37,8 @@ bool Foam::IOobject::writeHeader(Ostream& os) const
if (!os.good())
{
Info<< "IOobject::writeHeader(Ostream&) : "
<< "no stream open for write"
<< endl << os.info() << endl;
<< "no stream open for write" << nl
<< os.info() << endl;
return false;
}
@ -49,16 +49,14 @@ bool Foam::IOobject::writeHeader(Ostream& os) const
<< " format " << os.format() << ";\n"
<< " class " << type() << ";\n";
// outdent for visibility and more space
if (note().size())
{
os << " note " << note() << ";\n";
os << " note " << note() << ";\n";
}
// writing without quotes would look nicer
os << " object " << name() << ";\n"
//<< " instance " << instance()/local() << ";\n"
//<< " local " << local() << ";\n"
<< " location " << instance()/local() << ";\n"
os << " location " << instance()/local() << ";\n"
<< " object " << name() << ";\n"
<< "}" << nl;
writeDivider(os);

View File

@ -34,74 +34,6 @@ defineTypeNameAndDebug(Foam::dictionary, 0);
const Foam::dictionary Foam::dictionary::null;
#define DICTIONARY_INPLACE_MERGE
// * * * * * * * * * * * * * Private member functions * * * * * * * * * * * //
bool Foam::dictionary::add(entry* ePtr, bool mergeEntry)
{
HashTable<entry*>::iterator iter = hashedEntries_.find(ePtr->keyword());
if (mergeEntry && iter != hashedEntries_.end())
{
// merge dictionary with dictionary
if (iter()->isDict() && ePtr->isDict())
{
iter()->dict().merge(ePtr->dict());
delete ePtr;
return true;
}
else
{
// replace existing dictionary with entry or vice versa
#ifdef DICTIONARY_INPLACE_MERGE
IDLList<entry>::replace(iter(), ePtr);
delete iter();
hashedEntries_.erase(iter);
if (hashedEntries_.insert(ePtr->keyword(), ePtr))
{
ePtr->name() = name_ + "::" + ePtr->keyword();
return true;
}
else
{
IOWarningIn("dictionary::add(entry* ePtr)", (*this))
<< "problem replacing entry "<< ePtr->keyword()
<< " in dictionary " << name()
<< endl;
IDLList<entry>::remove(ePtr);
delete ePtr;
return false;
}
#else
remove(ePtr->keyword());
#endif
}
}
if (hashedEntries_.insert(ePtr->keyword(), ePtr))
{
ePtr->name() = name_ + "::" + ePtr->keyword();
IDLList<entry>::append(ePtr);
return true;
}
else
{
IOWarningIn("dictionary::add(entry* ePtr)", (*this))
<< "attempt to add entry "<< ePtr->keyword()
<< " which already exists in dictionary " << name()
<< endl;
delete ePtr;
return false;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::dictionary::dictionary()
@ -195,15 +127,15 @@ Foam::label Foam::dictionary::endLineNumber() const
}
bool Foam::dictionary::found(const word& keyword, bool recusive) const
bool Foam::dictionary::found(const word& keyword, bool recursive) const
{
if (hashedEntries_.found(keyword))
{
return true;
}
else if (recusive && &parent_ != &dictionary::null)
else if (recursive && &parent_ != &dictionary::null)
{
return parent_.found(keyword, recusive);
return parent_.found(keyword, recursive);
}
else
{
@ -215,16 +147,16 @@ bool Foam::dictionary::found(const word& keyword, bool recusive) const
const Foam::entry* Foam::dictionary::lookupEntryPtr
(
const word& keyword,
bool recusive
bool recursive
) const
{
HashTable<entry*>::const_iterator iter = hashedEntries_.find(keyword);
if (iter == hashedEntries_.end())
{
if (recusive && &parent_ != &dictionary::null)
if (recursive && &parent_ != &dictionary::null)
{
return parent_.lookupEntryPtr(keyword, recusive);
return parent_.lookupEntryPtr(keyword, recursive);
}
else
{
@ -239,19 +171,19 @@ const Foam::entry* Foam::dictionary::lookupEntryPtr
Foam::entry* Foam::dictionary::lookupEntryPtr
(
const word& keyword,
bool recusive
bool recursive
)
{
HashTable<entry*>::iterator iter = hashedEntries_.find(keyword);
if (iter == hashedEntries_.end())
{
if (recusive && &parent_ != &dictionary::null)
if (recursive && &parent_ != &dictionary::null)
{
return const_cast<dictionary&>(parent_).lookupEntryPtr
(
keyword,
recusive
recursive
);
}
else
@ -267,14 +199,13 @@ Foam::entry* Foam::dictionary::lookupEntryPtr
const Foam::entry& Foam::dictionary::lookupEntry
(
const word& keyword,
bool recusive
bool recursive
) const
{
const entry* ePtr = lookupEntryPtr(keyword, recusive);
const entry* entryPtr = lookupEntryPtr(keyword, recursive);
if (ePtr == NULL)
if (entryPtr == NULL)
{
// If keyword not found print error message ...
FatalIOErrorIn
(
"dictionary::lookupEntry(const word& keyword) const",
@ -284,23 +215,25 @@ const Foam::entry& Foam::dictionary::lookupEntry
<< exit(FatalIOError);
}
return *ePtr;
return *entryPtr;
}
Foam::ITstream& Foam::dictionary::lookup
(
const word& keyword,
bool recusive
bool recursive
) const
{
return lookupEntry(keyword, recusive).stream();
return lookupEntry(keyword, recursive).stream();
}
bool Foam::dictionary::isDict(const word& keyword) const
{
if (const entry* entryPtr = lookupEntryPtr(keyword))
const entry* entryPtr = lookupEntryPtr(keyword);
if (entryPtr)
{
return entryPtr->isDict();
}
@ -313,7 +246,9 @@ bool Foam::dictionary::isDict(const word& keyword) const
const Foam::dictionary* Foam::dictionary::subDictPtr(const word& keyword) const
{
if (const entry* entryPtr = lookupEntryPtr(keyword))
const entry* entryPtr = lookupEntryPtr(keyword);
if (entryPtr)
{
return &entryPtr->dict();
}
@ -326,13 +261,9 @@ const Foam::dictionary* Foam::dictionary::subDictPtr(const word& keyword) const
const Foam::dictionary& Foam::dictionary::subDict(const word& keyword) const
{
if (const entry* entryPtr = lookupEntryPtr(keyword))
const entry* entryPtr = lookupEntryPtr(keyword);
if (entryPtr == NULL)
{
return entryPtr->dict();
}
else
{
// If keyword not found print error message ...
FatalIOErrorIn
(
"dictionary::subDict(const word& keyword) const",
@ -340,37 +271,31 @@ const Foam::dictionary& Foam::dictionary::subDict(const word& keyword) const
) << " keyword " << keyword << " is undefined in dictionary "
<< name()
<< exit(FatalIOError);
return entryPtr->dict();
}
return entryPtr->dict();
}
Foam::dictionary& Foam::dictionary::subDict(const word& keyword)
{
if (entry* entryPtr = lookupEntryPtr(keyword))
entry* entryPtr = lookupEntryPtr(keyword);
if (entryPtr == NULL)
{
return entryPtr->dict();
}
else
{
// If keyword not found print error message ...
FatalIOErrorIn
(
"dictionary::subDict(const word& keyword) const",
"dictionary::subDict(const word& keyword)",
*this
) << " keyword " << keyword << " is undefined in dictionary "
<< name()
<< exit(FatalIOError);
return entryPtr->dict();
}
return entryPtr->dict();
}
Foam::wordList Foam::dictionary::toc() const
{
wordList keywords(size());
wordList keys(size());
label i = 0;
for
@ -380,56 +305,124 @@ Foam::wordList Foam::dictionary::toc() const
++iter
)
{
keywords[i++] = iter().keyword();
keys[i++] = iter().keyword();
}
return keywords;
return keys;
}
void Foam::dictionary::add(const entry& e)
bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
{
add(e.clone(*this).ptr());
HashTable<entry*>::iterator iter = hashedEntries_.find(entryPtr->keyword());
if (mergeEntry && iter != hashedEntries_.end())
{
// merge dictionary with dictionary
if (iter()->isDict() && entryPtr->isDict())
{
iter()->dict().merge(entryPtr->dict());
delete entryPtr;
return true;
}
else
{
// replace existing dictionary with entry or vice versa
IDLList<entry>::replace(iter(), entryPtr);
delete iter();
hashedEntries_.erase(iter);
if (hashedEntries_.insert(entryPtr->keyword(), entryPtr))
{
entryPtr->name() = name_ + "::" + entryPtr->keyword();
return true;
}
else
{
IOWarningIn("dictionary::add(entry*)", (*this))
<< "problem replacing entry "<< entryPtr->keyword()
<< " in dictionary " << name() << endl;
IDLList<entry>::remove(entryPtr);
delete entryPtr;
return false;
}
}
}
if (hashedEntries_.insert(entryPtr->keyword(), entryPtr))
{
entryPtr->name() = name_ + "::" + entryPtr->keyword();
IDLList<entry>::append(entryPtr);
return true;
}
else
{
IOWarningIn("dictionary::add(entry* entryPtr)", (*this))
<< "attempt to add entry "<< entryPtr->keyword()
<< " which already exists in dictionary " << name()
<< endl;
delete entryPtr;
return false;
}
}
void Foam::dictionary::add(const word& keyword, const token& t)
void Foam::dictionary::add(const entry& e, bool mergeEntry)
{
add(new primitiveEntry(keyword, t));
add(e.clone(*this).ptr(), mergeEntry);
}
void Foam::dictionary::add(const word& keyword, const word& w)
void Foam::dictionary::add(const word& k, const word& w, bool overwrite)
{
add(new primitiveEntry(keyword, token(w)));
add(new primitiveEntry(k, token(w)), overwrite);
}
void Foam::dictionary::add(const word& keyword, const Foam::string& s)
void Foam::dictionary::add(const word& k, const Foam::string& s, bool overwrite)
{
add(new primitiveEntry(keyword, token(s)));
add(new primitiveEntry(k, token(s)), overwrite);
}
void Foam::dictionary::add(const word& keyword, const label l)
void Foam::dictionary::add(const word& k, const label l, bool overwrite)
{
add(new primitiveEntry(keyword, token(l)));
add(new primitiveEntry(k, token(l)), overwrite);
}
void Foam::dictionary::add(const word& keyword, const scalar s)
void Foam::dictionary::add(const word& k, const scalar s, bool overwrite)
{
add(new primitiveEntry(keyword, token(s)));
add(new primitiveEntry(k, token(s)), overwrite);
}
void Foam::dictionary::add(const word& keyword, const ITstream& tokens)
void Foam::dictionary::add(const word& k, const dictionary& d, bool mergeEntry)
{
add(new primitiveEntry(keyword, tokens));
add(new dictionaryEntry(k, *this, d), mergeEntry);
}
void Foam::dictionary::add(const word& keyword, const tokenList& tokens)
void Foam::dictionary::set(entry* entryPtr)
{
add(new primitiveEntry(keyword, tokens));
entry* existingPtr = lookupEntryPtr(entryPtr->keyword());
// clear dictionary so merge acts like overwrite
if (existingPtr && existingPtr->isDict())
{
existingPtr->dict().clear();
}
add(entryPtr, true);
}
void Foam::dictionary::add(const word& keyword, const dictionary& dict)
void Foam::dictionary::set(const entry& e)
{
add(new dictionaryEntry(keyword, *this, dict));
set(e.clone(*this).ptr());
}
void Foam::dictionary::set(const word& k, const dictionary& d)
{
set(new dictionaryEntry(k, *this, d));
}
@ -486,7 +479,10 @@ bool Foam::dictionary::changeKeyword
}
else
{
// could issue warning if desired
WarningIn("dictionary::changeKeyword(const word& old, const word& new)")
<< "cannot rename keyword "<< oldKeyword
<< " to existing keyword " << newKeyword
<< " in dictionary " << name() << endl;
return false;
}
}
@ -527,34 +523,24 @@ bool Foam::dictionary::merge(const dictionary& dict)
if (iter2 != hashedEntries_.end())
{
// Recursively merge sub-dictionaries
// TODO: merge without copying
if (iter2()->isDict() && iter().isDict())
{
// without copying and without remove/add?
// this certainly looks ugly and doesn't necessarily
// retain the original sort order (perhaps nice to have)
if
(
iter2()->dict().merge(iter().dict())
)
if (iter2()->dict().merge(iter().dict()))
{
changed = true;
}
}
else
{
#ifdef DICTIONARY_INPLACE_MERGE
add(iter().clone(*this).ptr(), true);
#else
remove(keyword);
add(iter().clone(*this)());
#endif
changed = true;
}
}
else
{
// not found - just add
add(iter().clone(*this)());
add(iter().clone(*this).ptr());
changed = true;
}
}
@ -588,8 +574,8 @@ void Foam::dictionary::operator=(const dictionary& dict)
<< abort(FatalError);
}
// Clear the current entries
IDLList<entry>::clear();
name_ = dict.name();
clear();
// Create clones of the entries in the given dictionary
// resetting the parentDict to this dictionary
@ -603,10 +589,6 @@ void Foam::dictionary::operator=(const dictionary& dict)
IDLList<entry>::append(iter().clone(*this).ptr());
}
name_ = dict.name();
hashedEntries_.clear();
for
(
IDLList<entry>::iterator iter = begin();
@ -636,7 +618,7 @@ void Foam::dictionary::operator+=(const dictionary& dict)
++iter
)
{
add(iter().clone(*this)());
add(iter().clone(*this).ptr());
}
}
@ -660,7 +642,7 @@ void Foam::dictionary::operator|=(const dictionary& dict)
{
if (!found(iter().keyword()))
{
add(iter().clone(*this)());
add(iter().clone(*this).ptr());
}
}
}
@ -683,8 +665,7 @@ void Foam::dictionary::operator<<=(const dictionary& dict)
++iter
)
{
remove(iter().keyword());
add(iter().clone(*this)());
set(iter().clone(*this).ptr());
}
}

View File

@ -31,8 +31,12 @@ Description
The dictionary class is the base class for IOdictionary.
It serves the purpose of a bootstrap dictionary for the objectRegistry
data dictionaries, since unlike the IOdictionary class, it does not use a
objectRegistry itself to work.
data dictionaries, since unlike the IOdictionary class, it does not use
a objectRegistry itself to work.
ToDo
A merge() member function with a non-const dictionary parameter.
This would avoid unnecessary cloning in the add(entry*,bool) method
SourceFiles
dictionary.C
@ -171,31 +175,31 @@ public:
// Search and lookup
//- Search dictionary for given keyword
// If recusive search parent dictionaries
bool found(const word& keyword, bool recusive=false) const;
// If recursive search parent dictionaries
bool found(const word& keyword, bool recursive=false) const;
//- Find and return an entry data stream pointer if present
// otherwise return NULL.
// If recusive search parent dictionaries
const entry* lookupEntryPtr(const word&, bool recusive=false) const;
// If recursive search parent dictionaries
const entry* lookupEntryPtr(const word&, bool recursive=false) const;
//- Find and return an entry data stream pointer for manipulation
// if present otherwise return NULL.
// If recusive search parent dictionaries
entry* lookupEntryPtr(const word&, bool recusive=false);
// If recursive search parent dictionaries
entry* lookupEntryPtr(const word&, bool recursive=false);
//- Find and return an entry data stream if present otherwise error.
// If recusive search parent dictionaries
const entry& lookupEntry(const word&, bool recusive=false) const;
// If recursive search parent dictionaries
const entry& lookupEntry(const word&, bool recursive=false) const;
//- Find and return an entry data stream
// If recusive search parent dictionaries
ITstream& lookup(const word&, bool recusive=false) const;
// If recursive search parent dictionaries
ITstream& lookup(const word&, bool recursive=false) const;
//- Find and return a T, if not found return the given default value
// If recusive search parent dictionaries
// If recursive search parent dictionaries
template<class T>
T lookupOrDefault(const word&, const T&, bool recusive=false) const;
T lookupOrDefault(const word&, const T&, bool recursive=false) const;
//- Find and return a T, if not found return the given default value,
// and add to dictionary. If recusive search parent dictionaries
@ -236,38 +240,57 @@ public:
// Editing
//- Add a new entry
bool add(entry*, bool mergeEntry = false);
// With the merge option, dictionaries are interwoven and
// primitive entries are overwritten
bool add(entry*, bool mergeEntry=false);
//- Add an entry
void add(const entry&);
//- Add a token entry
void add(const word& keyword, const token&);
// With the merge option, dictionaries are interwoven and
// primitive entries are overwritten
void add(const entry&, bool mergeEntry=false);
//- Add a word entry
void add(const word& keyword, const word&);
// optionally overwrite an existing entry
void add(const word& keyword, const word&, bool overwrite=false);
//- Add a string entry
void add(const word& keyword, const string&);
// optionally overwrite an existing entry
void add(const word& keyword, const string&, bool overwrite=false);
//- Add a label entry
void add(const word& keyword, const label);
// optionally overwrite an existing entry
void add(const word& keyword, const label, bool overwrite=false);
//- Add a scalar entry
void add(const word& keyword, const scalar);
//- Add an entry constructed from a ITstream
void add(const word& keyword, const ITstream&);
//- Add an entry constructed from a tokenList
void add(const word& keyword, const tokenList& tokens);
//- Add a T entry
template<class T>
void add(const word& keyword, const T&);
// optionally overwrite an existing entry
void add (const word& keyword, const scalar, bool overwrite=false);
//- Add a dictionary entry
void add(const word& keyword, const dictionary&);
// optionally merge with an existing sub-dictionary
void add
(
const word& keyword,
const dictionary&,
bool mergeEntry=false
);
//- Add a T entry
// optionally overwrite an existing entry
template<class T>
void add(const word& keyword, const T&, bool overwrite=false);
//- Assign a new entry, overwrite any existing entry
void set(entry*);
//- Assign a new entry, overwrite any existing entry
void set(const entry&);
//- Assign a dictionary entry, overwrite any existing entry
void set(const word& keyword, const dictionary&);
//- Assign a T entry, overwrite any existing entry
template<class T>
void set(const word& keyword, const T&);
//- Remove an entry specified by keyword
bool remove(const word& keyword);
@ -326,14 +349,12 @@ public:
// Global Operators
// Combine dictionaries starting from the entries in dict one and then including
// those from dict2.
// Warn, but do not overwrite the entries from dict1.
//- Combine dictionaries starting from the entries in dict1 and then including those from dict2.
// Warn, but do not overwrite the entries from dict1.
dictionary operator+(const dictionary& dict1, const dictionary& dict2);
// Combine dictionaries starting from the entries in dict one and then including
// those from dict2.
// Do not overwrite the entries from dict1.
//- Combine dictionaries starting from the entries in dict1 and then including those from dict2.
// Do not overwrite the entries from dict1.
dictionary operator|(const dictionary& dict1, const dictionary& dict2);

View File

@ -33,19 +33,19 @@ template<class T>
T Foam::dictionary::lookupOrDefault
(
const word& keyword,
const T& deft,
bool recusive
const T& deflt,
bool recursive
) const
{
const entry* ePtr = lookupEntryPtr(keyword, recusive);
const entry* entryPtr = lookupEntryPtr(keyword, recursive);
if (ePtr == NULL)
if (entryPtr == NULL)
{
return deft;
return deflt;
}
else
{
return pTraits<T>(ePtr->stream());
return pTraits<T>(entryPtr->stream());
}
}
@ -93,12 +93,16 @@ void Foam::dictionary::readIfPresent
template<class T>
void Foam::dictionary::add(const word& keyword, const T& t)
void Foam::dictionary::add(const word& k, const T& t, bool overwrite)
{
entry* ePtr = new primitiveEntry(keyword, t);
append(ePtr);
hashedEntries_.insert(ePtr->keyword(), ePtr);
add(new primitiveEntry(k, t), overwrite);
}
template<class T>
void Foam::dictionary::set(const word& k, const T& t)
{
set(new primitiveEntry(k, t));
}
// ************************************************************************* //

View File

@ -96,7 +96,7 @@ bool Foam::entry::New(dictionary& parentDict, Istream& is)
if (keyword[0] == '#') // ... Function entry
{
word functionName = keyword(1, keyword.size()-1);
return functionEntry::insert(functionName, parentDict, is);
return functionEntry::execute(functionName, parentDict, is);
}
else if (keyword[0] == '$') // ... Substitution entry
{
@ -105,7 +105,7 @@ bool Foam::entry::New(dictionary& parentDict, Istream& is)
}
else if (keyword == "include") // ... For backward compatibility
{
return functionEntries::includeEntry::insert(parentDict, is);
return functionEntries::includeEntry::execute(parentDict, is);
}
else // ... Data entries
{
@ -114,12 +114,18 @@ bool Foam::entry::New(dictionary& parentDict, Istream& is)
// Deal with duplicate entries
bool mergeEntry = false;
if (parentDict.found(keyword))
entry* existingPtr = parentDict.lookupEntryPtr(keyword);
if (existingPtr)
{
if (functionEntries::inputModeEntry::overwrite())
{
// silently drop previous entries
parentDict.remove(keyword);
// clear dictionary so merge acts like overwrite
if (existingPtr->isDict())
{
existingPtr->dict().clear();
}
mergeEntry = true;
}
else if (functionEntries::inputModeEntry::merge())
{

View File

@ -33,22 +33,66 @@ namespace Foam
defineMemberFunctionSelectionTable
(
functionEntry,
insert,
primitiveEntryIstream
execute,
dictionaryIstream
);
defineMemberFunctionSelectionTable
(
functionEntry,
insert,
dictionaryIstream
execute,
primitiveEntryIstream
);
}
// * * * * * * * * * * * * Member Function Selectors * * * * * * * * * * * * //
bool Foam::functionEntry::insert
bool Foam::functionEntry::execute
(
const word& functionName,
dictionary& parentDict,
Istream& is
)
{
is.fatalCheck
(
"functionEntry::execute"
"(const word& functionName, dictionary& parentDict, Istream& is)"
);
if (!executedictionaryIstreamMemberFunctionTablePtr_)
{
cerr<<"functionEntry::execute"
<< "(const word&, dictionary&, Istream&)"
<< " not yet initialized, function = "
<< functionName.c_str() << std::endl;
// Return true to keep reading
return true;
}
executedictionaryIstreamMemberFunctionTable::iterator mfIter =
executedictionaryIstreamMemberFunctionTablePtr_->find(functionName);
if (mfIter == executedictionaryIstreamMemberFunctionTablePtr_->end())
{
FatalErrorIn
(
"functionEntry::execute"
"(const word& functionName, dictionary& parentDict, Istream&)"
) << "Unknown functionEntry " << functionName
<< endl << endl
<< "Valid functionEntries are :" << endl
<< executedictionaryIstreamMemberFunctionTablePtr_->toc()
<< exit(FatalError);
}
return mfIter()(parentDict, is);
}
bool Foam::functionEntry::execute
(
const word& functionName,
const dictionary& parentDict,
@ -58,14 +102,14 @@ bool Foam::functionEntry::insert
{
is.fatalCheck
(
"functionEntry::insert"
"functionEntry::execute"
"(const word& functionName, const dictionary& parentDict, "
"primitiveEntry& entry, Istream& is)"
"primitiveEntry&, Istream&)"
);
if (!insertprimitiveEntryIstreamMemberFunctionTablePtr_)
if (!executeprimitiveEntryIstreamMemberFunctionTablePtr_)
{
cerr<<"functionEntry::insert"
cerr<<"functionEntry::execute"
<< "(const word&, dictionary&, primitiveEntry&, Istream&)"
<< " not yet initialized, function = "
<< functionName.c_str() << std::endl;
@ -74,69 +118,24 @@ bool Foam::functionEntry::insert
return true;
}
insertprimitiveEntryIstreamMemberFunctionTable::iterator mfIter =
insertprimitiveEntryIstreamMemberFunctionTablePtr_->find(functionName);
executeprimitiveEntryIstreamMemberFunctionTable::iterator mfIter =
executeprimitiveEntryIstreamMemberFunctionTablePtr_->find(functionName);
if (mfIter == insertprimitiveEntryIstreamMemberFunctionTablePtr_->end())
if (mfIter == executeprimitiveEntryIstreamMemberFunctionTablePtr_->end())
{
FatalErrorIn
(
"functionEntry::insert"
"functionEntry::execute"
"(const word& functionName, const dictionary& parentDict, "
"primitiveEntry& entry, Istream& is)"
"primitiveEntry&, Istream&)"
) << "Unknown functionEntry " << functionName
<< endl << endl
<< "Valid functionEntries are :" << endl
<< insertprimitiveEntryIstreamMemberFunctionTablePtr_->toc()
<< executeprimitiveEntryIstreamMemberFunctionTablePtr_->toc()
<< exit(FatalError);
}
return mfIter()(parentDict, entry, is);
}
bool Foam::functionEntry::insert
(
const word& functionName,
dictionary& parentDict,
Istream& is
)
{
is.fatalCheck
(
"functionEntry::insert"
"(const word& functionName, dictionary& parentDict, Istream& is)"
);
if (!insertdictionaryIstreamMemberFunctionTablePtr_)
{
cerr<<"functionEntry::insert"
<< "(const word&, dictionary&, Istream&)"
<< " not yet initialized, function = "
<< functionName.c_str() << std::endl;
// Return true to keep reading
return true;
}
insertdictionaryIstreamMemberFunctionTable::iterator mfIter =
insertdictionaryIstreamMemberFunctionTablePtr_->find(functionName);
if (mfIter == insertdictionaryIstreamMemberFunctionTablePtr_->end())
{
FatalErrorIn
(
"functionEntry::insert"
"(const word& functionName, dictionary& parentDict, Istream& is)"
) << "Unknown functionEntry " << functionName
<< endl << endl
<< "Valid functionEntries are :" << endl
<< insertdictionaryIstreamMemberFunctionTablePtr_->toc()
<< exit(FatalError);
}
return mfIter()(parentDict, is);
}
// ************************************************************************* //

View File

@ -33,13 +33,10 @@ Class
Foam::functionEntry
Description
A function entry causes entries to be added/manipulated on the specified
A functionEntry causes entries to be added/manipulated on the specified
dictionary given an input stream.
In dictionaries, a @c \# sigil is typically used for a functionEntry.
See Also
functionEntries::includeEntry and functionEntries::inputModeEntry
In dictionaries, a @c '\#' sigil is typically used for a functionEntry.
SourceFiles
functionEntry.C
@ -84,7 +81,28 @@ public:
(
bool,
functionEntry,
insert,
execute,
dictionaryIstream,
(
dictionary& parentDict,
Istream& is
),
(parentDict, is)
);
//- Execute the functionEntry in a sub-dict context
static bool execute
(
const word& functionName,
dictionary& parentDict,
Istream& is
);
declareMemberFunctionSelectionTable
(
bool,
functionEntry,
execute,
primitiveEntryIstream,
(
const dictionary& parentDict,
@ -94,7 +112,8 @@ public:
(parentDict, entry, is)
);
static bool insert
//- Execute the functionEntry in a primitiveEntry context
static bool execute
(
const word& functionName,
const dictionary& parentDict,
@ -103,25 +122,6 @@ public:
);
declareMemberFunctionSelectionTable
(
bool,
functionEntry,
insert,
dictionaryIstream,
(
dictionary& parentDict,
Istream& is
),
(parentDict, is)
);
static bool insert
(
const word& functionName,
dictionary& parentDict,
Istream& is
);
};

View File

@ -48,16 +48,16 @@ namespace functionEntries
(
functionEntry,
includeEntry,
insert,
primitiveEntryIstream
execute,
dictionaryIstream
);
addToMemberFunctionSelectionTable
(
functionEntry,
includeEntry,
insert,
dictionaryIstream
execute,
primitiveEntryIstream
);
}
}
@ -82,7 +82,35 @@ Foam::fileName Foam::functionEntries::includeEntry::includeFileName
}
bool Foam::functionEntries::includeEntry::insert
bool Foam::functionEntries::includeEntry::execute
(
dictionary& parentDict,
Istream& is
)
{
IFstream fileStream(includeFileName(is));
if (fileStream)
{
parentDict.read(fileStream);
return true;
}
else
{
FatalIOErrorIn
(
"functionEntries::includeEntry::includeEntry"
"(dictionary& parentDict,Istream& is)",
is
) << "Cannot open include file " << fileStream.name()
<< " while reading dictionary " << parentDict.name()
<< exit(FatalIOError);
return false;
}
}
bool Foam::functionEntries::includeEntry::execute
(
const dictionary& parentDict,
primitiveEntry& entry,
@ -111,34 +139,4 @@ bool Foam::functionEntries::includeEntry::insert
}
}
bool Foam::functionEntries::includeEntry::insert
(
dictionary& parentDict,
Istream& is
)
{
IFstream fileStream(includeFileName(is));
if (fileStream)
{
parentDict.read(fileStream);
return true;
}
else
{
FatalIOErrorIn
(
"functionEntries::includeEntry::includeEntry"
"(dictionary& parentDict,Istream& is)",
is
) << "Cannot open include file " << fileStream.name()
<< " while reading dictionary " << parentDict.name()
<< exit(FatalIOError);
return false;
}
}
// ************************************************************************* //

View File

@ -29,9 +29,9 @@ Description
Specify an include file when reading dictionaries, expects a
single string to follow.
An example of @c \#include directive:
An example of the @c \#include directive:
@verbatim
\#include "includefile"
#include "includeFile"
@endverbatim
The usual expansion of environment variables and other constructs (eg,
@ -85,18 +85,21 @@ public:
// Member Functions
static bool insert
//- Execute the functionEntry in a sub-dict context
static bool execute
(
dictionary& parentDict,
Istream& is
);
//- Execute the functionEntry in a primitiveEntry context
static bool execute
(
const dictionary& parentDict,
primitiveEntry& entry,
Istream& is
);
static bool insert
(
dictionary& parentDict,
Istream& is
);
};

View File

@ -47,15 +47,7 @@ namespace functionEntries
(
functionEntry,
inputModeEntry,
insert,
primitiveEntryIstream
);
addToMemberFunctionSelectionTable
(
functionEntry,
inputModeEntry,
insert,
execute,
dictionaryIstream
);
}
@ -63,10 +55,11 @@ namespace functionEntries
// * * * * * * * * * * * * * * * * Private Data * * * * * * * * * * * * * * //
Foam::label Foam::functionEntries::inputModeEntry::inputMode_ = imError;
Foam::label Foam::functionEntries::inputModeEntry::mode_ = imError;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// we could combine this into execute() directly, but leave it here for now
void Foam::functionEntries::inputModeEntry::setMode(Istream& is)
{
clear();
@ -74,15 +67,15 @@ void Foam::functionEntries::inputModeEntry::setMode(Istream& is)
word mode(is);
if (mode == "merge")
{
inputMode_ = imMerge;
mode_ = imMerge;
}
else if (mode == "overwrite")
{
inputMode_ = imOverwrite;
mode_ = imOverwrite;
}
else if (mode == "error" || mode == "default")
{
inputMode_ = imError;
mode_ = imError;
}
else
{
@ -95,19 +88,7 @@ void Foam::functionEntries::inputModeEntry::setMode(Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionEntries::inputModeEntry::insert
(
const dictionary& parentDict,
primitiveEntry& entry,
Istream& is
)
{
setMode(is);
return true;
}
bool Foam::functionEntries::inputModeEntry::insert
bool Foam::functionEntries::inputModeEntry::execute
(
dictionary& parentDict,
Istream& is
@ -120,13 +101,13 @@ bool Foam::functionEntries::inputModeEntry::insert
void Foam::functionEntries::inputModeEntry::clear()
{
inputMode_ = imError;
mode_ = imError;
}
bool Foam::functionEntries::inputModeEntry::merge()
{
if (inputMode_ & imMerge)
if (mode_ & imMerge)
{
return true;
}
@ -139,7 +120,7 @@ bool Foam::functionEntries::inputModeEntry::merge()
bool Foam::functionEntries::inputModeEntry::overwrite()
{
if (inputMode_ & imOverwrite)
if (mode_ & imOverwrite)
{
return true;
}

View File

@ -74,11 +74,12 @@ class inputModeEntry
};
//- current input mode
static label inputMode_;
static label mode_;
// Private Member Functions
//- Read the mode as a word and set enum appropriately
static void setMode(Istream&);
//- Disallow default bitwise copy construct
@ -96,23 +97,20 @@ public:
// Member Functions
static bool insert
(
const dictionary& parentDict,
primitiveEntry&,
Istream&
);
static bool insert
//- Execute the functionEntry in a sub-dict context
static bool execute
(
dictionary& parentDict,
Istream&
);
//- Reset the inputMode to 'default'
static void clear();
//- Return true if the inputMode is 'merge'
static bool merge();
//- Return true if the inputMode is 'overwrite'
static bool overwrite();
};

View File

@ -0,0 +1,88 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "removeEntry.H"
#include "dictionary.H"
#include "IStringStream.H"
#include "OStringStream.H"
#include "addToMemberFunctionSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const Foam::word Foam::functionEntries::removeEntry::typeName
(
Foam::functionEntries::removeEntry::typeName_()
);
// Don't lookup the debug switch here as the debug switch dictionary
// might include removeEntry
int Foam::functionEntries::removeEntry::debug(0);
namespace Foam
{
namespace functionEntries
{
addToMemberFunctionSelectionTable
(
functionEntry,
removeEntry,
execute,
dictionaryIstream
);
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionEntries::removeEntry::execute
(
dictionary& parentDict,
Istream& is
)
{
token currToken(is);
is.putBack(currToken);
if (currToken == token::BEGIN_LIST)
{
wordList keys(is);
forAll(keys, keyI)
{
parentDict.remove(keys[keyI]);
}
}
else
{
word key(is);
parentDict.remove(key);
}
return true;
}
// ************************************************************************* //

View File

@ -0,0 +1,100 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::functionEntries::removeEntry
Description
Remove a dictionary entry.
The @c \#remove directive takes a word or a list of words. For example,
@verbatim
#remove entry0
#remove ( entry1 entry2 entry3 )
@endverbatim
The removable only occurs in the current context.
Removing sub-entries or parent entries is not supported.
SourceFiles
removeEntry.C
\*---------------------------------------------------------------------------*/
#ifndef removeEntry_H
#define removeEntry_H
#include "functionEntry.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace functionEntries
{
/*---------------------------------------------------------------------------*\
Class removeEntry Declaration
\*---------------------------------------------------------------------------*/
class removeEntry
:
public functionEntry
{
// Private Member Functions
//- Disallow default bitwise copy construct
removeEntry(const removeEntry&);
//- Disallow default bitwise assignment
void operator=(const removeEntry&);
public:
//- Runtime type information
TypeName("remove");
// Member Functions
//- Execute the functionEntry in a sub-dict context
static bool execute
(
dictionary& parentDict,
Istream& is
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionEntries
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -115,7 +115,7 @@ bool Foam::primitiveEntry::expandFunction
)
{
word functionName = keyword(1, keyword.size()-1);
return functionEntry::insert(functionName, parentDict, *this, is);
return functionEntry::execute(functionName, parentDict, *this, is);
}

View File

@ -186,7 +186,7 @@ Foam::argList::argList
// Print the banner once only for parallel runs
if (Pstream::master())
{
IOobject::writeLogBanner(Info);
IOobject::writeBanner(Info, true);
}
// convert argv -> args_ and capture ( ... ) lists
@ -252,19 +252,30 @@ Foam::argList::argList
args_.setSize(nArgs);
// Help options:
// -doc display the documentation in browser
// -help print the usage
if (options_.found("doc") || options_.found("help"))
// Help/documentation options:
// -help print the usage
// -doc display application documentation in browser
// -srcDoc display source code in browser
if
(
options_.found("help")
|| options_.found("doc")
|| options_.found("srcDoc")
)
{
if (options_.found("help"))
{
printUsage();
}
if (options_.found("doc"))
// only display one or the other
if (options_.found("srcDoc"))
{
displayDoc();
displayDoc(true);
}
else if (options_.found("doc"))
{
displayDoc(false);
}
::exit(0);
@ -578,12 +589,9 @@ void Foam::argList::printUsage() const
++iter
)
{
Info<< ' ' << '<' << iter().c_str() << '>';
Info<< " <" << iter().c_str() << '>';
}
// place -doc and -help up front
Info<< " [-doc] [-help]";
for
(
HashTable<string>::iterator iter = validOptions.begin();
@ -601,16 +609,27 @@ void Foam::argList::printUsage() const
Info<< ']';
}
Info<< endl;
// place help/doc options of the way at the end,
// but with an extra space to separate it a little
Info<< " [-help] [-doc] [-srcDoc]" << endl;
}
void Foam::argList::displayDoc() const
void Foam::argList::displayDoc(bool source) const
{
const dictionary& docDict = debug::controlDict().subDict("Documentation");
List<fileName> docDirs(docDict.lookup("doxyDocDirs"));
List<fileName> docExts(docDict.lookup("doxySourceFileExts"));
// for source code: change foo_8C.html to foo_8C-source.html
if (source)
{
forAll(docExts, extI)
{
docExts[extI].replace(".", "-source.");
}
}
fileName docFile;
bool found = false;
@ -618,7 +637,7 @@ void Foam::argList::displayDoc() const
{
forAll(docExts, extI)
{
docFile = docDirs[dirI]/executable() + docExts[extI];
docFile = docDirs[dirI]/executable_ + docExts[extI];
docFile.expand();
if (exists(docFile))

View File

@ -27,18 +27,18 @@ Class
Description
Extract command arguments and options from the supplied
@a argc and @a argv.
@a argc and @a argv parameters.
Sequences with "(" ... ")" are transformed into a stringList.
For example,
@verbatim
program -listFiles \( *.txt \)
@endverbatim
in which the backslash-escaping has been used to avoid shell expansions,
would create a stringList:
@verbatim
( "file1.txt" "file2.txt" ... "fileN.txt" )
@endverbatim
The backslash-escaping has been used to avoid shell expansions.
@par Default command-line options
@param -case \<dir\> \n
@ -47,6 +47,8 @@ Description
specify case as a parallel job
@param -doc \n
display the documentation in browser
@param -srcDoc \n
display the source documentation in browser
@param -help \n
print the usage
@ -130,14 +132,14 @@ public:
//- A list of valid parallel options
static HashTable<string> validParOptions;
//! @cond ignore documentation for this class
//! @cond ignoreDocumentation
class initValidTables
{
public:
initValidTables();
};
//! @endcond
//! @endcond ignoreDocumentation
// Constructors
@ -148,8 +150,8 @@ public:
(
int& argc,
char**& argv,
bool checkArgs = true,
bool checkOpts = true
bool checkArgs=true,
bool checkOpts=true
);
@ -196,8 +198,7 @@ public:
return globalCase_;
}
//- Return case name for parallel run
// or the global case for a serial run
//- Return case name for parallel run or the global case for a serial run
const fileName& caseName() const
{
return case_;
@ -222,13 +223,14 @@ public:
void printUsage() const;
//- Display documentation in browser
void displayDoc() const;
// Optionally display the application source code
void displayDoc(bool source=false) const;
// Check
//- Check argument list
bool check(bool checkArgs = true, bool checkOpts = true) const;
bool check(bool checkArgs=true, bool checkOpts=true) const;
//- Check root path and case path
bool checkRootCase() const;

View File

@ -89,8 +89,6 @@ bool chDir(const fileName& dir);
//- Search for @em name in the following hierarchy:
// -# personal settings:
// - ~/.OpenFOAM-\<VERSION\>
// <em>(old style)</em>
// - ~/.OpenFOAM/\<VERSION\>/
// <em>for version-specific files</em>
// - ~/.OpenFOAM/

View File

@ -73,8 +73,7 @@ void Foam::processorLduInterface::send
else
{
FatalErrorIn("processorLduInterface::send")
<< "Unsuported communications type "
<< Pstream::commsTypeNames[commsType]
<< "Unsupported communications type " << commsType
<< exit(FatalError);
}
}
@ -104,8 +103,7 @@ void Foam::processorLduInterface::receive
else
{
FatalErrorIn("processorLduInterface::receive")
<< "Unsuported communications type "
<< Pstream::commsTypeNames[commsType]
<< "Unsupported communications type " << commsType
<< exit(FatalError);
}
}
@ -184,8 +182,7 @@ void Foam::processorLduInterface::compressedSend
else
{
FatalErrorIn("processorLduInterface::compressedSend")
<< "Unsuported communications type "
<< Pstream::commsTypeNames[commsType]
<< "Unsupported communications type " << commsType
<< exit(FatalError);
}
}
@ -225,8 +222,7 @@ void Foam::processorLduInterface::compressedReceive
else if (commsType != Pstream::nonBlocking)
{
FatalErrorIn("processorLduInterface::compressedReceive")
<< "Unsuported communications type "
<< Pstream::commsTypeNames[commsType]
<< "Unsupported communications type " << commsType
<< exit(FatalError);
}

View File

@ -6,6 +6,10 @@ wmake libso dummy
case "$WM_MPLIB" in
LAM | OPENMPI | MPI | MPICH | MPICH-GM | MPIGAMMA )
export WM_OPTIONS=${WM_OPTIONS}$WM_MPLIB
set +x
echo
echo "Note: ignore spurious warnings about missing mpicxx.h headers"
set -x
wmake libso mpi
;;

View File

@ -32,12 +32,9 @@ Description
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
IPstream::IPstream
Foam::IPstream::IPstream
(
const commsTypes commsType,
const int fromProcNo,
@ -53,13 +50,12 @@ IPstream::IPstream
{
notImplemented
(
"IPstream::IPstream"
"IPsream::IPstream"
"("
"const commsTypes commsType,"
"const commsTypes,"
"const int fromProcNo,"
"const label bufSize,"
"streamFormat format,"
"versionNumber version"
"streamFormat, versionNumber"
")"
);
}
@ -67,7 +63,7 @@ IPstream::IPstream
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
int IPstream::read
int Foam::IPstream::read
(
const commsTypes commsType,
const int fromProcNo,
@ -75,33 +71,32 @@ int IPstream::read
const std::streamsize bufSize
)
{
notImplemented
(
"IPstream::read"
"("
"const commsTypes commsType,"
"const int fromProcNo,"
"char* buf,"
"const label bufSize"
")"
notImplemented
(
"IPstream::read"
"("
"const commsTypes,"
"const int fromProcNo,"
"char* buf,"
"const label bufSize"
")"
);
return 0;
}
void IPstream::waitRequests()
void Foam::IPstream::waitRequests()
{}
bool IPstream::finishedRequest(const label)
bool Foam::IPstream::finishedRequest(const label)
{
notImplemented("IPstream::finishedRequest()");
notImplemented("IPstream::finishedRequest()");
return false;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -32,12 +32,9 @@ Description
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
OPstream::~OPstream()
Foam::OPstream::~OPstream()
{
notImplemented("OPstream::~OPstream()");
}
@ -45,7 +42,7 @@ OPstream::~OPstream()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool OPstream::write
bool Foam::OPstream::write
(
const commsTypes commsType,
const int toProcNo,
@ -68,11 +65,11 @@ bool OPstream::write
}
void OPstream::waitRequests()
void Foam::OPstream::waitRequests()
{}
bool OPstream::finishedRequest(const label)
bool Foam::OPstream::finishedRequest(const label)
{
notImplemented("OPstream::finishedRequest()");
return false;
@ -81,6 +78,4 @@ bool OPstream::finishedRequest(const label)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -29,16 +29,13 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void Pstream::addValidParOptions(HashTable<string>& validParOptions)
void Foam::Pstream::addValidParOptions(HashTable<string>& validParOptions)
{}
bool Pstream::init(int& argc, char**& argv)
bool Foam::Pstream::init(int& argc, char**& argv)
{
FatalErrorIn("Pstream::init(int& argc, char**& argv)")
<< "Trying to use the dummy Pstream library." << nl
@ -49,24 +46,21 @@ bool Pstream::init(int& argc, char**& argv)
}
void Pstream::exit(int errnum)
void Foam::Pstream::exit(int errnum)
{
notImplemented("Pstream::exit(int errnum)");
}
void Pstream::abort()
void Foam::Pstream::abort()
{
notImplemented("Pstream::abort()");
}
void reduce(scalar&, const sumOp<scalar>&)
void Foam::reduce(scalar&, const sumOp<scalar>&)
{}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Write primitive and binary block from OPstream
Write primitive and binary block from OPstream gamma-mpi
\*---------------------------------------------------------------------------*/
@ -46,8 +46,10 @@ namespace Foam
// Largest message sent so far. This tracks the size of the receive
// buffer on the receiving end. Done so we only send out resize messages
// if nessecary
// if necessary
//! @cond fileScope
labelList maxSendSize;
//! @endcond fileScope
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

View File

@ -26,7 +26,8 @@ Namespace
Foam::PstreamGlobals
Description
Global functions and variables for working with parallel streams.
Global functions and variables for working with parallel streams,
but principally for gamma/mpi
SourceFiles
PstreamGlobals.C

View File

@ -33,18 +33,16 @@ Description
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// Outstanding non-blocking operations.
DynamicList<MPI_Request> IPstream_outstandingRequests_;
//! @cond fileScope
Foam::DynamicList<MPI_Request> IPstream_outstandingRequests_;
//! @endcond fileScope
// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
IPstream::IPstream
Foam::IPstream::IPstream
(
const commsTypes commsType,
const int fromProcNo,
@ -89,7 +87,7 @@ IPstream::IPstream
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
label IPstream::read
Foam::label Foam::IPstream::read
(
const commsTypes commsType,
const int fromProcNo,
@ -192,7 +190,7 @@ label IPstream::read
}
void IPstream::waitRequests()
void Foam::IPstream::waitRequests()
{
if (IPstream_outstandingRequests_.size() > 0)
{
@ -219,7 +217,7 @@ void IPstream::waitRequests()
}
bool IPstream::finishedRequest(const label i)
bool Foam::IPstream::finishedRequest(const label i)
{
if (i >= IPstream_outstandingRequests_.size())
{
@ -244,6 +242,4 @@ bool IPstream::finishedRequest(const label i)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -31,20 +31,16 @@ Description
#include "OPstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// Outstanding non-blocking operations.
DynamicList<MPI_Request> OPstream_outstandingRequests_;
//! @cond fileScope
Foam::DynamicList<MPI_Request> OPstream_outstandingRequests_;
//! @endcond fileScope
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
OPstream::~OPstream()
Foam::OPstream::~OPstream()
{
if
(
@ -66,7 +62,7 @@ OPstream::~OPstream()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool OPstream::write
bool Foam::OPstream::write
(
const commsTypes commsType,
const int toProcNo,
@ -80,7 +76,7 @@ bool OPstream::write
{
transferFailed = MPI_Bsend
(
(char*)buf,
const_cast<char*>(buf),
bufSize,
MPI_PACKED,
procID(toProcNo),
@ -92,7 +88,7 @@ bool OPstream::write
{
transferFailed = MPI_Send
(
(char*)buf,
const_cast<char*>(buf),
bufSize,
MPI_PACKED,
procID(toProcNo),
@ -106,7 +102,7 @@ bool OPstream::write
transferFailed = MPI_Isend
(
(char*)buf,
const_cast<char*>(buf),
bufSize,
MPI_PACKED,
procID(toProcNo),
@ -132,7 +128,7 @@ bool OPstream::write
}
void OPstream::waitRequests()
void Foam::OPstream::waitRequests()
{
if (OPstream_outstandingRequests_.size() > 0)
{
@ -159,7 +155,7 @@ void OPstream::waitRequests()
}
bool OPstream::finishedRequest(const label i)
bool Foam::OPstream::finishedRequest(const label i)
{
if (i >= OPstream_outstandingRequests_.size())
{
@ -184,6 +180,4 @@ bool OPstream::finishedRequest(const label i)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -42,12 +42,14 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void Pstream::addValidParOptions(HashTable<string>& validParOptions)
// NOTE:
// valid parallel options vary between implementations, but flag common ones.
// if they are not removed by MPI_Init(), the subsequent argument processing
// will notice that they are wrong
void Foam::Pstream::addValidParOptions(HashTable<string>& validParOptions)
{
validParOptions.insert("np", "");
validParOptions.insert("p4pg", "PI file");
@ -59,7 +61,7 @@ void Pstream::addValidParOptions(HashTable<string>& validParOptions)
}
bool Pstream::init(int& argc, char**& argv)
bool Foam::Pstream::init(int& argc, char**& argv)
{
MPI_Init(&argc, &argv);
@ -119,7 +121,7 @@ bool Pstream::init(int& argc, char**& argv)
}
void Pstream::exit(int errnum)
void Foam::Pstream::exit(int errnum)
{
# ifndef SGIMPI
int size;
@ -140,13 +142,13 @@ void Pstream::exit(int errnum)
}
void Pstream::abort()
void Foam::Pstream::abort()
{
MPI_Abort(MPI_COMM_WORLD, 1);
}
void reduce(scalar& Value, const sumOp<scalar>& bop)
void Foam::reduce(scalar& Value, const sumOp<scalar>& bop)
{
if (!Pstream::parRun())
{
@ -426,6 +428,4 @@ void reduce(scalar& Value, const sumOp<scalar>& bop)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -653,7 +653,7 @@ void Foam::meshCutAndRemove::setRefinement
const edge& e = mesh().edges()[edgeI];
// Check if there is any cell using this edge.
if (debug & findCutCell(cuts, mesh().edgeCells()[edgeI]) == -1)
if (debug && findCutCell(cuts, mesh().edgeCells()[edgeI]) == -1)
{
FatalErrorIn
(

View File

@ -601,7 +601,7 @@ void Foam::meshCutter::setRefinement
const edge& e = mesh().edges()[edgeI];
// Check if there is any cell using this edge.
if (debug & findCutCell(cuts, mesh().edgeCells()[edgeI]) == -1)
if (debug && findCutCell(cuts, mesh().edgeCells()[edgeI]) == -1)
{
FatalErrorIn
(

View File

@ -140,7 +140,7 @@ Foam::sampledPatch::sampledPatch
patchFaceLabels_(0)
{
// default: non-triangulated
triangulate() = getBool(dict, "triangulate", false);
triangulate() = dict.lookupOrDefault("triangulate", false);
createGeometry();
}

View File

@ -151,25 +151,6 @@ Foam::sampledSurface::New
);
}
bool Foam::sampledSurface::getBool
(
const dictionary& dict,
const word& key,
const bool defaultVal
)
{
if (dict.found(key))
{
return readBool(dict.lookup(key));
}
else
{
return defaultVal;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sampledSurface::sampledSurface
@ -200,8 +181,8 @@ Foam::sampledSurface::sampledSurface
:
name_(name),
mesh_(mesh),
triangulate_(getBool(dict, "triangulate", true)),
interpolate_(getBool(dict, "interpolate", false)),
triangulate_(dict.lookupOrDefault("triangulate", true)),
interpolate_(dict.lookupOrDefault("interpolate", false)),
SfPtr_(NULL),
magSfPtr_(NULL),
CfPtr_(NULL),

View File

@ -128,11 +128,6 @@ class sampledSurface
protected:
// Protected static functions
//- Read bool from dictionary. Return provided value if not found
static bool getBool(const dictionary&, const word&, const bool);
// Protected Member functions
virtual void clearGeom() const;

View File

@ -89,9 +89,16 @@ done
make="make"
# set WM_NCOMPPROCS automatically when both WM_HOSTS and WM_SCHEDULER are set
if [ -z "$WM_NCOMPPROCS" -a -n "$WM_HOSTS" -a -n "$WM_SCHEDULER" ]
then
WM_NCOMPPROCS=$(wmakeScheduler -count)
[ $? -eq 0 ] || unset WM_NCOMPPROCS
fi
if [ "$WM_NCOMPPROCS" ]
then
if [ "$WM_NCOMPPROCS" -ne 1 -a ! "$MAKEFLAGS" ]
if [ "$WM_NCOMPPROCS" -gt 1 -a ! "$MAKEFLAGS" ]
then
lockDir=$HOME/.wmakeScheduler

View File

@ -1,201 +0,0 @@
#!/bin/bash
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# Script
# wmakeScheduler
#
# Description
# Scheduler for network distributed compilations using wmake.
# - WM_HOSTS contains a list of hosts and number of concurrent processes
# eg,
# export WM_HOSTS="hostA:1 hostB:2 hostC:1"
# - WM_COLOURS contains a list of colours to cycle through
# export WM_COLOURS="black blue green cyan red magenta yellow"
#
# Sources the relevant cshrc/bashrc if not set.
#
# WM_PROJECT_DIR, WM_PROJECT and WM_PROJECT_VERSION will have been set
# before calling this routine
#
# Usage
# wmakeScheduler COMMAND
# run 'COMMAND' on one of the slots listed in WM_HOSTS
#
# wmakeScheduler -count
# count the total number of slots available in WM_HOSTS
# eg, WM_NCOMPPROCS=$(wmakeScheduler -count)
#
#-------------------------------------------------------------------------------
lockDir=$HOME/.wmakeScheduler
# fallback - 1 core on current host
: ${WM_HOSTS:=$HOST:1}
# count the total number of slots available and exit
if [ "$1" = "-count" ]
then
expr $(
for slotGroup in $WM_HOSTS
do
n=${slotGroup##*:}
if [ "$n" = "${slotGroup%%:*}" ]; then n=1; fi # missing ':'
echo "+ ${n:-1}"
done)
exit 0
fi
# where to source WM_PROJECT settings in a remote shell
# This code tries to figure out which cshrc or bashrc to execute.
# !! Assumes remote computer running same shell and startup files
# in same location
sourceFoam=false # fallback command
case $SHELL in
*/csh | */tcsh ) # [t]csh vs bash|ksh|sh
shellRc=cshrc
;;
*)
shellRc=bashrc
;;
esac
# check ~/.$WM_PROJECT-$WM_PROJECT_VERSION/
# check ~/.$WM_PROJECT/$WM_PROJECT_VERSION/
# check ~/.$WM_PROJECT/
# check <installedProject>/etc/
# check <installedProject/.$WM_PROJECT-$WM_PROJECT_VERSION/
if [ "$WM_PROJECT" ]; then
: ${FOAM_DOT_DIR:=.$WM_PROJECT-$WM_PROJECT_VERSION}
for i in \
$HOME/$FOAM_DOT_DIR \
$HOME/.$WM_PROJECT/$WM_PROJECT_VERSION \
$HOME/.$WM_PROJECT \
$WM_PROJECT_DIR/etc \
$WM_PROJECT_DIR/$FOAM_DOT_DIR \
;
do
if [ -f "$i/$shellRc" ]; then
sourceFoam="$i/$shellRc"
break
fi
done
fi
# Construct test string for remote execution.
# Source WM_PROJECT settings if WM_PROJECT environment not set.
case $sourceFoam in
*/cshrc) sourceFoam='if ( ! $?WM_PROJECT ) source '"$sourceFoam";;
*/bashrc) sourceFoam='[ "$WM_PROJECT" ] || . '"$sourceFoam";;
esac
# quote double-quotes for remote command line
rcmd=$(echo $* | sed -e s/\"/\'\"\'/g)
## the same, without forking (not ksh, maybe not /bin/sh either)
# rcmd=$(while [ "$#" -gt 0 ]; do echo "${1//\"/'\"'}"; shift; done)
# Convert WM_COLOURS into an array
declare colours
nColours=0
for col in $WM_COLOURS
do
colours[$nColours]=$col
((nColours = $nColours + 1))
done
# Bashism: make pipe fail early. This make sure return value of compilation
# is returned and not of colouring pipe.
set -o pipefail
# Define function to colour output by argument 1
colourPipe(){
if [ "$1" ]; then
(while read line; do setterm -foreground $1; echo "$line" ; done; setterm -foreground default)
else
cat
fi
}
colourIndex=0
while :
do
for slotGroup in $WM_HOSTS
do
# split 'host:N', but catch 'host:' and 'host' too
host=${slotGroup%%:*}
n=${slotGroup##*:}
if [ "$n" = "$host" ]; then n=1; fi # missing ':'
: ${n:=1}
i=0
while [ "$i" -lt "$n" ]
do
lockFile="$lockDir/$host:$i"
if lockfile -r0 "$lockFile" 2>/dev/null; then
# Set colour
colour=${colours[$colourIndex]}
#echo "** host=$host colourIndex=$colourIndex colour=$colour"
if [ "$host" = "$HOST" ]; then
if [ "$colour" ]; then
eval $* 2>&1 | colourPipe $colour
else
eval $*
fi
elif [ -n "$JOB_ID" ]; then
qrsh -inherit -v PWD $host "$rcmd"
else
if [ "$colour" ]; then
ssh $host "$sourceFoam 2>/dev/null; cd $PWD && $rcmd" 2>&1 | colourPipe $colour
else
ssh $host "$sourceFoam 2>/dev/null; cd $PWD && $rcmd"
fi
fi
retval=$?
# Release lock
rm -f "$lockFile" 2>/dev/null
exit $retval
fi
i=$(expr $i + 1)
# Cycle through colours
colourIndex=$(expr $colourIndex + 1)
if (( $colourIndex >= $nColours )); then
colourIndex=0
fi
done
done
done
if [ "$WM_COLOURS" ]; then
setterm -foreground default
fi
#------------------------------------------------------------------------------

View File

@ -37,7 +37,8 @@
# Sources the relevant cshrc/bashrc if not set.
#
# WM_PROJECT_DIR, WM_PROJECT and WM_PROJECT_VERSION will have been set
# before calling this routine
# before calling this routine.
# FOAM_INST_DIR may possibly have been set (to find installation)
#
# Usage
# wmakeScheduler COMMAND
@ -45,7 +46,7 @@
#
# wmakeScheduler -count
# count the total number of slots available in WM_HOSTS
# eg, WM_NCOMPPROCS=$(wmakeScheduler -count)
# eg, export WM_NCOMPPROCS=$(wmakeScheduler -count)
#
#-------------------------------------------------------------------------------
lockDir=$HOME/.wmakeScheduler
@ -81,21 +82,15 @@ case $SHELL in
;;
esac
# check ~/.$WM_PROJECT-$WM_PROJECT_VERSION/
# check ~/.$WM_PROJECT/$WM_PROJECT_VERSION/
# check ~/.$WM_PROJECT/
# check <installedProject>/etc/
# check <installedProject/.$WM_PROJECT-$WM_PROJECT_VERSION/
if [ "$WM_PROJECT" ]; then
: ${FOAM_DOT_DIR:=.$WM_PROJECT-$WM_PROJECT_VERSION}
for i in \
$HOME/$FOAM_DOT_DIR \
$HOME/.$WM_PROJECT/$WM_PROJECT_VERSION \
$HOME/.$WM_PROJECT \
$WM_PROJECT_DIR/etc \
$WM_PROJECT_DIR/$FOAM_DOT_DIR \
;
do
if [ -f "$i/$shellRc" ]; then
@ -203,7 +198,7 @@ do
fi
done
done
# Not found any free slots. Rest a bit.
# Did not find any free slots. Rest a bit.
sleep 1
done