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

This commit is contained in:
andy
2008-12-19 10:27:39 +00:00
310 changed files with 5886 additions and 3058 deletions

3
.gitignore vendored
View File

@ -49,6 +49,9 @@ doc/[Dd]oxygen/man
*.tar.gz *.tar.gz
*.tgz *.tgz
# ignore the persistent .build tag in the main directory
/.build
# ignore .timeStamp in the main directory # ignore .timeStamp in the main directory
/.timeStamp /.timeStamp

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
basicSubGrid Foam::XiEqModels::basicSubGrid
Description Description
Basic sub-grid obstacle flame-wrinking enhancement factor model. Basic sub-grid obstacle flame-wrinking enhancement factor model.

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
basicSubGrid Foam::XiGModel::basicSubGrid
Description Description

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
PDRDragModel Foam::PDRDragModel
Description Description
Base-class for sub-grid obstacle drag models. Base-class for sub-grid obstacle drag models.

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
basic Foam::PDRDragModels::basic
Description Description
Basic sub-grid obstacle drag model. Basic sub-grid obstacle drag model.

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
PDRkEpsilon Foam::compressible::RASModels::PDRkEpsilon
Description Description
Standard k-epsilon turbulence model with additional source terms Standard k-epsilon turbulence model with additional source terms

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
Gulder Foam::XiEqModels::Gulder
Description Description
Simple Gulder model for XiEq based on Gulders correlation Simple Gulder model for XiEq based on Gulders correlation

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
SCOPEBlend Foam::XiEqModels::SCOPEBlend
Description Description

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
SCOPEXiEq Foam::XiEqModel::SCOPEXiEq
Description Description
Simple SCOPEXiEq model for XiEq based on SCOPEXiEqs correlation Simple SCOPEXiEq model for XiEq based on SCOPEXiEqs correlation

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
XiEqModel Foam::XiEqModel
Description Description
Base-class for all XiEq models used by the b-XiEq combustion model. Base-class for all XiEq models used by the b-XiEq combustion model.

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
instability Foam::XiEqModels::instability
Description Description

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
KTS Foam::XiGModels::KTS
Description Description
Simple Kolmogorov time-scale model for the flame-wrinling generation rate. Simple Kolmogorov time-scale model for the flame-wrinling generation rate.

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
XiGModel Foam::XiGModel
Description Description
Base-class for all Xi generation models used by the b-Xi combustion model. Base-class for all Xi generation models used by the b-Xi combustion model.

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
instabilityG Foam::XiGModels::instabilityG
Description Description
Flame-surface instabilityG flame-wrinking generation rate coefficient model. Flame-surface instabilityG flame-wrinking generation rate coefficient model.

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
XiModel Foam::XiModel
Description Description
Base-class for all Xi models used by the b-Xi combustion model. Base-class for all Xi models used by the b-Xi combustion model.
@ -102,8 +102,6 @@ namespace Foam
Class XiModel Declaration Class XiModel Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class XiModel class XiModel
{ {

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
algebraic Foam::XiModels::algebraic
Description Description
Simple algebraic model for Xi based on Gulders correlation Simple algebraic model for Xi based on Gulders correlation

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
fixed Foam::XiModels::fixed
Description Description
Fixed value model for Xi. Fixed value model for Xi.

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
transport Foam::XiModels::transport
Description Description
Simple transport model for Xi based on Gulders correlation Simple transport model for Xi based on Gulders correlation

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
SCOPE Foam::laminarFlameSpeedModels::SCOPE
Description Description
Laminar flame speed obtained from the SCOPE correlation. Laminar flame speed obtained from the SCOPE correlation.

View File

@ -74,24 +74,26 @@ int main(int argc, char *argv[])
Info<< "Time = " << runTime.timeName() << nl << endl; Info<< "Time = " << runTime.timeName() << nl << endl;
scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();
// Do any mesh changes
mesh.update();
if (mesh.changing())
{ {
Info<< "Execution time for mesh.update() = " // Store divU from the previous mesh for the correctPhi
<< runTime.elapsedCpuTime() - timeBeforeMeshUpdate volScalarField divU = fvc::div(phi);
<< " s" << endl;
gh = g & mesh.C(); scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();
ghf = g & mesh.Cf();
}
if (mesh.changing() && correctPhi) // Do any mesh changes
{ mesh.update();
//***HGW#include "correctPhi.H"
if (mesh.changing())
{
Info<< "Execution time for mesh.update() = "
<< runTime.elapsedCpuTime() - timeBeforeMeshUpdate
<< " s" << endl;
}
if (mesh.changing() && correctPhi)
{
#include "correctPhi.H"
}
} }
// Make the fluxes relative to the mesh motion // Make the fluxes relative to the mesh motion
@ -102,6 +104,12 @@ int main(int argc, char *argv[])
#include "meshCourantNo.H" #include "meshCourantNo.H"
} }
if (mesh.changing())
{
gh = g & mesh.C();
ghf = g & mesh.Cf();
}
turbulence->correct(); turbulence->correct();
// --- Outer-corrector loop // --- Outer-corrector loop

View File

@ -0,0 +1,39 @@
{
#include "continuityErrs.H"
volScalarField pcorr
(
IOobject
(
"pcorr",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("pcorr", pd.dimensions(), 0.0),
pcorrTypes
);
dimensionedScalar rAUf("(1|A(U))", dimTime/rho.dimensions(), 1.0);
adjustPhi(phi, U, pcorr);
for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
fvScalarMatrix pcorrEqn
(
fvm::laplacian(rAUf, pcorr) == fvc::div(phi) - divU
);
pcorrEqn.solve();
if (nonOrth == nNonOrthCorr)
{
phi -= pcorrEqn.flux();
}
}
#include "continuityErrs.H"
}

View File

@ -150,3 +150,14 @@
( (
incompressible::turbulenceModel::New(U, phi, twoPhaseProperties) incompressible::turbulenceModel::New(U, phi, twoPhaseProperties)
); );
wordList pcorrTypes(pd.boundaryField().types());
for (label i=0; i<pd.boundaryField().size(); i++)
{
if (pd.boundaryField()[i].fixesValue())
{
pcorrTypes[i] = fixedValueFvPatchScalarField::typeName;
}
}

View File

@ -21,7 +21,7 @@
surfaceScalarField phiU surfaceScalarField phiU
( (
"phiU", "phiU",
(fvc::interpolate(U) & mesh.Sf()) + fvc::ddtPhiCorr(rUA, rho, U, phi) (fvc::interpolate(U) & mesh.Sf())
); );
phi = phiU + phi = phiU +

View File

@ -48,7 +48,6 @@ int main(int argc, char *argv[])
} }
myList.append(100.3); myList.append(100.3);
myList.append(500.3); myList.append(500.3);
Info<< nl << "And again using STL iterator: " << nl << endl; Info<< nl << "And again using STL iterator: " << nl << endl;
@ -120,7 +119,18 @@ int main(int argc, char *argv[])
Info<< "element:" << *iter << endl; Info<< "element:" << *iter << endl;
} }
Info<< nl << "Bye." << endl;
Info<< nl << "Testing transfer: " << nl << endl;
Info<< "original: " << myList << endl;
DLList<scalar> newList;
newList.transfer(myList);
Info<< nl << "source: " << myList << nl
<< nl << "target: " << newList << endl;
Info<< nl << "Done." << endl;
return 0; return 0;
} }

View File

@ -30,8 +30,11 @@ Description
#include "OSspecific.H" #include "OSspecific.H"
#include "scalar.H"
#include "IOstreams.H" #include "IOstreams.H"
#include "Dictionary.H" #include "Dictionary.H"
#include "PtrDictionary.H"
using namespace Foam; using namespace Foam;
@ -63,6 +66,36 @@ public:
}; };
class Scalar
{
scalar data_;
public:
Scalar()
:
data_(0)
{}
Scalar(scalar val)
:
data_(val)
{}
~Scalar()
{
Info <<"delete Scalar: " << data_ << endl;
}
friend Ostream& operator<<(Ostream& os, const Scalar& val)
{
os << val.data_;
return os;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program: // Main program:
@ -92,12 +125,11 @@ int main(int argc, char *argv[])
Info<< "element : " << *iter; Info<< "element : " << *iter;
} }
Info<< dict.toc() << endl; Info<< "keys: " << dict.toc() << endl;
delete dictPtr; delete dictPtr;
dictPtr = new Dictionary<ent>; Dictionary<ent> dict2;
Dictionary<ent>& dict2 = *dictPtr;
for (int i = 0; i<10; i++) for (int i = 0; i<10; i++)
{ {
@ -106,9 +138,79 @@ int main(int argc, char *argv[])
dict2.swapUp(ePtr); dict2.swapUp(ePtr);
} }
Info<< dict2 << endl; Info<< "dict:\n" << dict2 << endl;
Info<< nl << "Bye." << endl; Info<< nl << "Testing transfer: " << nl << endl;
Info<< "original: " << dict2 << endl;
Dictionary<ent> newDict;
newDict.transfer(dict2);
Info<< nl << "source: " << dict2 << nl
<< "keys: " << dict2.toc() << nl
<< "target: " << newDict << nl
<< "keys: " << newDict.toc() << endl;
PtrDictionary<Scalar> scalarDict;
for (int i = 0; i<10; i++)
{
word key("ent" + name(i));
scalarDict.insert(key, new Scalar(1.3*i));
}
Info<< nl << "scalarDict1: " << endl;
for
(
PtrDictionary<Scalar>::const_iterator iter = scalarDict.begin();
iter != scalarDict.end();
++iter
)
{
Info<< " = " << iter() << endl;
}
PtrDictionary<Scalar> scalarDict2;
for (int i = 8; i<15; i++)
{
word key("ent" + name(i));
scalarDict2.insert(key, new Scalar(1.3*i));
}
Info<< nl << "scalarDict2: " << endl;
for
(
PtrDictionary<Scalar>::const_iterator iter = scalarDict2.begin();
iter != scalarDict2.end();
++iter
)
{
Info<< "elem = " << *iter << endl;
}
scalarDict.transfer(scalarDict2);
Scalar* p = scalarDict.lookupPtr("ent8");
// This does not (yet) work
// Scalar* q = scalarDict.remove("ent10");
if (p)
{
Info << "found: " << *p << endl;
}
else
{
Info << "no p: " << endl;
}
scalarDict.clear();
// Info<< " = " << *iter << endl;
Info<< nl << "Done." << endl;
return 0; return 0;
} }

View File

@ -52,6 +52,13 @@ public:
: :
data_(s) data_(s)
{} {}
friend Ostream& operator<<(Ostream& os, const Scalar& s)
{
os << s.data_;
return os;
}
}; };
@ -68,10 +75,8 @@ int main(int argc, char *argv[])
} }
myList.append(new Scalar(100.3)); myList.append(new Scalar(100.3));
myList.append(new Scalar(500.3)); myList.append(new Scalar(500.3));
Info<< nl << "And again using STL iterator: " << nl << endl; Info<< nl << "And again using STL iterator: " << nl << endl;
for for
@ -99,6 +104,15 @@ int main(int argc, char *argv[])
} }
Info<< nl << "Testing transfer: " << nl << endl;
Info<< "original: " << myList << endl;
ISLList<Scalar> newList;
newList.transfer(myList);
Info<< nl << "source: " << myList << nl
<< nl << "target: " << newList << endl;
Info<< nl << "Bye." << endl; Info<< nl << "Bye." << endl;
return 0; return 0;
} }

View File

@ -1,4 +1,3 @@
namedEnumTest.C namedEnumTest.C
EXE = $(FOAM_APPBIN)/NamedEnum EXE = $(FOAM_USER_APPBIN)/NamedEnum

View File

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

View File

@ -0,0 +1,112 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 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
Application
Description
\*---------------------------------------------------------------------------*/
#include "OSspecific.H"
#include "scalar.H"
#include "IOstreams.H"
#include "PtrList.H"
using namespace Foam;
class Scalar
{
scalar data_;
public:
Scalar()
:
data_(0)
{}
Scalar(scalar val)
:
data_(val)
{}
~Scalar()
{
Info <<"delete Scalar: " << data_ << endl;
}
friend Ostream& operator<<(Ostream& os, const Scalar& val)
{
os << val.data_;
return os;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
PtrList<Scalar> list1(10);
PtrList<Scalar> list2(15);
forAll(list1, i)
{
list1.set(i, new Scalar(1.3*i));
}
forAll(list2, i)
{
list2.set(i, new Scalar(10 + 1.3*i));
}
Info<<"list1: " << list1 << endl;
Info<<"list2: " << list2 << endl;
Info<<"indirectly delete some items via set(.., 0) :" << endl;
for (label i = 0; i < 3; i++)
{
list1.set(i, 0);
}
Info<<"transfer list2 -> list1:" << endl;
list1.transfer(list2);
Info<<"list1: " << list1 << endl;
Info<<"list2: " << list2 << endl;
Info<<"indirectly delete some items via setSize :" << endl;
list1.setSize(4);
Info<<"list1: " << list1 << endl;
Info<< nl << "Done." << endl;
return 0;
}
// ************************************************************************* //

View File

@ -48,10 +48,8 @@ int main(int argc, char *argv[])
} }
myList.append(100.3); myList.append(100.3);
myList.append(500.3); myList.append(500.3);
Info<< nl << "And again using STL iterator: " << nl << endl; Info<< nl << "And again using STL iterator: " << nl << endl;
for for
@ -99,7 +97,27 @@ int main(int argc, char *argv[])
Info<< "element:" << *iter2 << endl; Info<< "element:" << *iter2 << endl;
} }
Info<< nl << "Bye." << endl;
for (int i = 0; i<10; i++)
{
myList.append(1.3*i);
}
myList.append(100.3);
myList.append(500.3);
Info<< nl << "Testing transfer: " << nl << endl;
Info<< "original: " << myList << endl;
SLList<scalar> newList;
newList.transfer(myList);
Info<< nl << "source: " << myList << nl
<< nl << "target: " << newList << endl;
Info<< nl << "Done." << endl;
return 0; return 0;
} }

View File

@ -113,7 +113,20 @@ int main(int argc, char *argv[])
Info<< dict2 << endl; Info<< dict2 << endl;
Info<< nl << "Bye." << endl;
Info<< nl << "Testing transfer: " << nl << endl;
Info<< "original: " << dict2 << endl;
UDictionary<ent> newDict;
newDict.transfer(dict2);
Info<< nl << "source: " << dict2 << nl
<< "keys: " << dict2.toc() << nl
<< "target: " << newDict << nl
<< "keys: " << newDict.toc() << endl;
Info<< nl << "Done." << endl;
return 0; return 0;
} }

View File

@ -1,3 +1,3 @@
callbackTest.C callbackTest.C
EXE = $(FOAM_APPBIN)/callbackTest EXE = $(FOAM_USER_APPBIN)/callbackTest

View File

@ -1,3 +1,3 @@
testDataEntry.C testDataEntry.C
EXE = $(FOAM_APPBIN)/testDataEntry EXE = $(FOAM_USER_APPBIN)/testDataEntry

View File

@ -30,6 +30,7 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "IOstreams.H" #include "IOstreams.H"
#include "IOobject.H"
#include "IFstream.H" #include "IFstream.H"
#include "dictionary.H" #include "dictionary.H"
@ -40,30 +41,46 @@ using namespace Foam;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
IFstream dictStream("testDict"); {
dictionary testDict(dictStream); dictionary dict(IFstream("testDict")());
Info<< "dict: " << dict << nl
<< "toc: " << dict.toc() << nl
<< "keys: " << dict.keys() << nl
<< "patterns: " << dict.keys(true) << endl;
}
Info<< testDict << endl;
IOobject::writeDivider(Info);
{ {
dictionary someDict; dictionary dict(IFstream("testDictRegex")());
someDict.add(keyType("a.*", true), "subdictValue"); dict.add(keyType("fooba[rz]", true), "anything");
dictionary dict; Info<< "dict:" << dict << nl
dict.add("someDict", someDict); << "toc: " << dict.toc() << nl
dict.add(keyType(".*", true), "parentValue"); << "keys: " << dict.keys() << nl
<< "patterns: " << dict.keys(true) << endl;
Info<< "dict:" << dict << endl; Info<< "Pattern find \"abc\" in top directory : "
// Wildcard find.
Info<< "Wildcard find \"abc\" in top directory : "
<< dict.lookup("abc") << endl; << dict.lookup("abc") << endl;
Info<< "Wildcard find \"abc\" in sub directory : " Info<< "Pattern find \"abc\" in sub directory : "
<< dict.subDict("someDict").lookup("abc") << dict.subDict("someDict").lookup("abc")
<< endl; << endl;
Info<< "Recursive wildcard find \"def\" in sub directory : " Info<< "Recursive pattern find \"def\" in sub directory : "
<< dict.subDict("someDict").lookup("def", true) << dict.subDict("someDict").lookup("def", true)
<< endl; << endl;
Info<< "Recursive pattern find \"foo\" in sub directory : "
<< dict.subDict("someDict").lookup("foo", true)
<< endl;
Info<< "Recursive pattern find \"fooz\" in sub directory : "
<< dict.subDict("someDict").lookup("fooz", true)
<< endl;
Info<< "Recursive pattern find \"bar\" in sub directory : "
<< dict.subDict("someDict").lookup("bar", true)
<< endl;
Info<< "Recursive pattern find \"xxx\" in sub directory : "
<< dict.subDict("someDict").lookup("xxx", true)
<< endl;
} }
return 0; return 0;

View File

@ -0,0 +1,36 @@
/*-------------------------------*- C++ -*---------------------------------*\
| ========= |
| \\ / OpenFOAM |
| \\ / |
| \\ / The Open Source CFD Toolbox |
| \\/ http://www.OpenFOAM.org |
\*-------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object testDictRegex;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#inputMode merge
".*" parentValue1;
"[n-z].*" parentValue2;
"f.*" parentValue3;
keyX parentValue4;
keyY parentValue5;
"(.*)Dict"
{
foo subdictValue0;
bar $f.*; // should this really match 'foo'?
// result is dependent on insert order!
"a.*c" subdictValue3;
"ab.*" subdictValue2;
"a.*" subdictValue1;
abcd \1;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -32,6 +32,7 @@ Description
#include "fileName.H" #include "fileName.H"
#include "IOstreams.H" #include "IOstreams.H"
#include "OSspecific.H"
using namespace Foam; using namespace Foam;
@ -57,7 +58,16 @@ int main()
Info<< "pathName.components() = " << pathName.components() << endl; Info<< "pathName.components() = " << pathName.components() << endl;
Info<< "pathName.component(2) = " << pathName.component(2) << endl; Info<< "pathName.component(2) = " << pathName.component(2) << endl;
Info<< "end" << endl;
// test findEtcFile
Info<< "\n\nfindEtcFile tests:" << nl
<< " controlDict => " << findEtcFile("controlDict") << nl
<< " badName => " << findEtcFile("badName") << endl;
Info<< "This should emit a fatal error:" << endl;
Info<< " badName(die) => " << findEtcFile("badName", true) << nl
<< endl;
Info<< "\nEnd" << endl;
return 0; return 0;
} }

View File

@ -28,6 +28,7 @@ Description
#include "argList.H" #include "argList.H"
#include "Time.H" #include "Time.H"
#include "timeSelector.H"
using namespace Foam; using namespace Foam;
@ -36,13 +37,19 @@ using namespace Foam;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::noParallel();
// timeSelector::addOptions();
timeSelector::addOptions(true, true);
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"
Info<< runTime.times() << endl; Info<< "Times found:" << runTime.times() << endl;
Info << "End\n" << endl; instantList timeDirs = timeSelector::select0(runTime, args);
Info<< "Times selected:" << timeDirs << endl;
Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -1,2 +0,0 @@
getRoots.C
EXE = $(FOAM_USER_APPBIN)/getRoots

View File

@ -1,2 +0,0 @@
/* EXE_INC = -I$(LIB_SRC)/finiteVolume/lnInclude */
/* EXE_LIBS = -lfiniteVolume */

View File

@ -1,30 +0,0 @@
#include "dictionary.H"
#include "fileNameList.H"
#include "IFstream.H"
#include "OSspecific.H"
using namespace Foam;
int main()
{
Info << "\nReading Roots" << endl;
IFstream rootsFile(home()/".foam/apps/openDX/roots");
fileNameList rootsList(dictionary(rootsFile).lookup("roots"));
char** rootsStrings = new char*[rootsList.size() + 1];
rootsStrings[rootsList.size()] = 0;
if (rootsList.size())
{
for (int i=0; i<rootsList.size(); i++)
{
rootsStrings[i] = new char[rootsList[i].size() + 1];
strcpy(rootsStrings[i], rootsList[i].c_str());
Info<< rootsStrings[i] << endl;
}
}
return 0;
}

View File

@ -1,4 +0,0 @@
calcEntry/calcEntry.C
dictionaryTest.C
EXE = $(FOAM_USER_APPBIN)/dictionaryTest

View File

@ -1,55 +0,0 @@
FoamFile
{
version 2.0;
format ascii;
root "";
case "";
instance "";
local "";
class dictionary;
object testDict;
}
dimensions [ 0 2 -2 0 0 0 0 ];
internalField uniform 1;
active
{
type turbulentIntensityKineticEnergyInlet;
intensity 0.1;
value $internalField;
}
inactive
{
type zeroGradient;
}
boundaryField
{
Default_Boundary_Region
{
type zeroGradient;
}
inlet_1 { $active }
inlet_2 { $inactive }
inlet_3 { $inactive }
#include "testDictInc"
outlet
{
type inletOutlet;
inletValue $internalField;
value #include "value";
x 5;
y 6;
another #calc{x $x; y $y;};
}
}

View File

@ -1,6 +0,0 @@
inlet_4
{
type inletOutlet;
inletValue $internalField;
value $internalField;
}

View File

@ -1 +0,0 @@
uniform 2

View File

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

View File

@ -0,0 +1,115 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 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
Description
\*---------------------------------------------------------------------------*/
#include "IOstreams.H"
#include "IOobject.H"
#include "IFstream.H"
#include "regExp.H"
#include "List.H"
#include "Tuple2.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
List<Tuple2<string, string> > rawList(IFstream("testRegexps")());
Info<< "input list:" << rawList << endl;
IOobject::writeDivider(Info);
Info<< endl;
List<string> groups;
// report matches:
forAll(rawList, elemI)
{
const string& pat = rawList[elemI].first();
const string& str = rawList[elemI].second();
regExp re(pat);
Info<< str << " =~ m/" << pat.c_str() << "/ == ";
if (re.match(str, groups))
{
Info<< "true";
if (re.ngroups())
{
Info<< groups;
}
}
else
{
Info<< "false";
if (re.match(str, true))
{
Info<< " partial match";
}
}
Info << endl;
}
Info<<"test regExp(const char*) ..." << endl;
string me("Mark");
if (regExp("[Mm]ar[ck]").match(me))
{
Info<< "matched: " << me << endl;
}
else
{
Info<< "no match" << endl;
}
if (regExp("").match(me))
{
Info<< "matched: " << me << endl;
}
else
{
Info<< "no match" << endl;
}
if (regExp(NULL).match(me))
{
Info<< "matched: " << me << endl;
}
else
{
Info<< "no match" << endl;
}
Info<< endl;
return 0;
}
// ************************************************************************* //

View File

@ -0,0 +1,20 @@
/*-------------------------------*- C++ -*---------------------------------*\
| ========= |
| \\ / OpenFOAM |
| \\ / |
| \\ / The Open Source CFD Toolbox |
| \\/ http://www.OpenFOAM.org |
\*-------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// pattern, string
(
( "a.*" "abc" )
( "a.*" "bac" )
( "a.*" "abcd" )
( "a.*" "def" )
( "d(.*)f" "def" )
)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -59,23 +59,24 @@ Gather<T0>::Gather(const T0& localData, const bool redistribute)
// Receive data // Receive data
for for
( (
int slave=Pstream::firstSlave(), procIndex = 1; int slave = Pstream::firstSlave(), procIndex = 1;
slave<=Pstream::lastSlave(); slave <= Pstream::lastSlave();
slave++, procIndex++ slave++, procIndex++
) )
{ {
IPstream fromSlave(slave); IPstream fromSlave(Pstream::scheduled, slave);
fromSlave >> this->operator[](procIndex); fromSlave >> this->operator[](procIndex);
} }
// Send data // Send data
for for
( (
int slave=Pstream::firstSlave(), procIndex = 1; int slave = Pstream::firstSlave(), procIndex = 1;
slave<=Pstream::lastSlave(); slave <= Pstream::lastSlave();
slave++, procIndex++ slave++, procIndex++
) )
{ {
OPstream toSlave(slave); OPstream toSlave(Pstream::scheduled, slave);
if (redistribute) if (redistribute)
{ {
@ -92,12 +93,13 @@ Gather<T0>::Gather(const T0& localData, const bool redistribute)
{ {
// Slave: send my local data to master // Slave: send my local data to master
{ {
OPstream toMaster(Pstream::masterNo()); OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster << localData; toMaster << localData;
} }
// Receive data from master // Receive data from master
{ {
IPstream fromMaster(Pstream::masterNo()); IPstream fromMaster(Pstream::scheduled, Pstream::masterNo());
if (redistribute) if (redistribute)
{ {
fromMaster >> *this; fromMaster >> *this;

View File

@ -26,7 +26,7 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "stringList.H" #include "stringListOps.H"
#include "IOstreams.H" #include "IOstreams.H"
using namespace Foam; using namespace Foam;

View File

@ -1,4 +1,3 @@
xferListTest.C xferListTest.C
/* EXE = $(FOAM_USER_APPBIN)/xferListTest */ EXE = $(FOAM_USER_APPBIN)/xferListTest
EXE = ./xferListTest

View File

@ -289,9 +289,7 @@ int main(int argc, char *argv[])
<< patchNames[patchI] << "\t\t" << patchNames[patchI] << "\t\t"
<< allPatchFaces[patchI].size() << endl; << allPatchFaces[patchI].size() << endl;
allPatchFaces[patchI].shrink();
patchFaces[patchI].transfer(allPatchFaces[patchI]); patchFaces[patchI].transfer(allPatchFaces[patchI]);
allPatchFaces[patchI].clear();
} }
Info<< endl; Info<< endl;

View File

@ -515,7 +515,7 @@ int main(int argc, char *argv[])
Info<< " " << patchNames[patchI] << " : " Info<< " " << patchNames[patchI] << " : "
<< allPatchFaces[patchI].size() << endl; << allPatchFaces[patchI].size() << endl;
patchFaces[patchI].transfer(allPatchFaces[patchI].shrink()); patchFaces[patchI].transfer(allPatchFaces[patchI]);
} }
Info<< endl; Info<< endl;
@ -548,7 +548,6 @@ int main(int argc, char *argv[])
meshPtr().write(); meshPtr().write();
Info<< "End\n" << endl; Info<< "End\n" << endl;
return 0; return 0;

View File

@ -292,6 +292,7 @@ meshQualityControls
minFlatness 0.5; minFlatness 0.5;
//- Minimum pyramid volume. Is absolute volume of cell pyramid. //- Minimum pyramid volume. Is absolute volume of cell pyramid.
// Set to a sensible fraction of the smallest cell volume expected.
// Set to very negative number (e.g. -1E30) to disable. // Set to very negative number (e.g. -1E30) to disable.
minVol 1e-13; minVol 1e-13;

View File

@ -45,8 +45,10 @@ Description
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
// enable -constant ... if someone really wants it
// enable -zeroTime to prevent accidentally trashing the initial fields
timeSelector::addOptions(true, true);
argList::noParallel(); argList::noParallel();
timeSelector::addOptions();
# include "addRegionOption.H" # include "addRegionOption.H"
argList::validOptions.insert("fields", "\"(list of fields)\""); argList::validOptions.insert("fields", "\"(list of fields)\"");

View File

@ -74,7 +74,9 @@ using namespace Foam;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
// with -constant and -zeroTime // enable -constant
// probably don't need -zeroTime though, since the fields are vetted
// afterwards anyhow
timeSelector::addOptions(true, false); timeSelector::addOptions(true, false);
argList::noParallel(); argList::noParallel();
argList::validOptions.insert("ascii", ""); argList::validOptions.insert("ascii", "");

View File

@ -7,6 +7,8 @@
# the pqReader.xml file contains xml defining readers with their # the pqReader.xml file contains xml defining readers with their
# file extensions and descriptions. # file extensions and descriptions.
cmake_minimum_required(VERSION 2.4)
FIND_PACKAGE(ParaView REQUIRED) FIND_PACKAGE(ParaView REQUIRED)
INCLUDE(${PARAVIEW_USE_FILE}) INCLUDE(${PARAVIEW_USE_FILE})

View File

@ -74,10 +74,7 @@ void Foam::readerDatabase::getPolyHedra()
} }
} }
polys.shrink();
Info<< "Found " << polys.size() << " polyhedral cells " << endl; Info<< "Found " << polys.size() << " polyhedral cells " << endl;
polys_.transfer(polys); polys_.transfer(polys);
} }

View File

@ -0,0 +1,3 @@
foamUpgradeFvSolution.C
EXE = $(FOAM_APPBIN)/foamUpgradeFvSolution

View File

@ -0,0 +1,109 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 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
Application
foamUpgradeFvSolution
Description
Simple tool to upgrade the syntax of system/fvSolution::solvers
Usage
- foamUpgradeFvSolution [OPTION]
@param -test \n
Suppress writing the updated fvSolution file
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "IOdictionary.H"
#include "solution.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::noParallel();
argList::validOptions.insert("test", "");
# include "setRootCase.H"
# include "createTime.H"
IOdictionary solutionDict
(
IOobject
(
"fvSolution",
runTime.system(),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
label nChanged = 0;
entry* e = solutionDict.lookupEntryPtr("solvers", false, false);
if (e && e->isDict())
{
nChanged = solution::upgradeSolverDict(e->dict(), true);
}
Info<< nChanged << " solver settings changed" << nl << endl;
if (nChanged)
{
if (args.options().found("test"))
{
Info<< "-test option: no changes made" << nl << endl;
}
else
{
mv
(
solutionDict.objectPath(),
solutionDict.objectPath() + ".old"
);
solutionDict.writeObject
(
IOstream::ASCII,
IOstream::currentVersion,
IOstream::UNCOMPRESSED
);
Info<< "Backup to " << (solutionDict.objectPath() + ".old") << nl
<< "Write to " << solutionDict.objectPath() << nl << endl;
}
}
return 0;
}
// ************************************************************************* //

View File

@ -78,7 +78,7 @@ int main(int argc, char *argv[])
Info<< nl << "Reading Burcat data dictionary" << endl; Info<< nl << "Reading Burcat data dictionary" << endl;
fileName BurcatCpDataFileName(dotFoam("thermoData/BurcatCpData")); fileName BurcatCpDataFileName(findEtcFile("thermoData/BurcatCpData"));
// Construct control dictionary // Construct control dictionary
IFstream BurcatCpDataFile(BurcatCpDataFileName); IFstream BurcatCpDataFile(BurcatCpDataFileName);

View File

@ -79,7 +79,7 @@ int main(int argc, char *argv[])
Info<< nl << "Reading Burcat data dictionary" << endl; Info<< nl << "Reading Burcat data dictionary" << endl;
fileName BurcatCpDataFileName(dotFoam("thermoData/BurcatCpData")); fileName BurcatCpDataFileName(findEtcFile("thermoData/BurcatCpData"));
// Construct control dictionary // Construct control dictionary
IFstream BurcatCpDataFile(BurcatCpDataFileName); IFstream BurcatCpDataFile(BurcatCpDataFileName);

View File

@ -77,7 +77,7 @@ int main(int argc, char *argv[])
Info<< nl << "Reading Burcat data dictionary" << endl; Info<< nl << "Reading Burcat data dictionary" << endl;
fileName BurcatCpDataFileName(dotFoam("thermoData/BurcatCpData")); fileName BurcatCpDataFileName(findEtcFile("thermoData/BurcatCpData"));
// Construct control dictionary // Construct control dictionary
IFstream BurcatCpDataFile(BurcatCpDataFileName); IFstream BurcatCpDataFile(BurcatCpDataFileName);

View File

@ -1 +0,0 @@
buildParaView3.3-cvs

192
bin/buildParaView3.5-cvs Executable file
View File

@ -0,0 +1,192 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 1991-2008 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
# buildParaView3.5-cvs
#
# Description
# Build and install ParaView
# - run from folder above ParaView source folder or place the
# ParaView source under $WM_THIRD_PARTY_DIR
#
#------------------------------------------------------------------------------
. $WM_PROJECT_DIR/bin/tools/buildParaViewFunctions
PARAVIEW_SRC=paraview-3.5-cvs
PARAVIEW_MAJOR_VERSION=3.5
# User options:
# ~~~~~~~~~~~~~
# MPI support:
WITH_MPI=OFF
MPI_MAX_PROCS=32
# Python support:
# note: script will try to determine the appropriate python library.
# If it fails, specify the path using the PYTHON_LIBRARY variable
WITH_PYTHON=OFF
PYTHON_LIBRARY=""
# PYTHON_LIBRARY="/usr/lib64/libpython2.5.so.1.0"
# MESA graphics support:
WITH_MESA=OFF
#
# No further editing below this line
#------------------------------------------------------------------------------
Script=${0##*/}
usage() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
usage: ${0##*/} [OPTION]
options:
-fast for repeated builds (-make -install) *use with caution*
-mpi with mpi (if not already enabled)
-python with python (if not already enabled)
-mesa with mesa (if not already enabled)
-verbose verbose output in Makefiles
-help
For finer control, the build stages can be also selected individually
(mutually exclusive)
-config
-make
-makedoc
-install
[-envpath] alter absolute paths in CMake files to use env variables
Build and install $PARAVIEW_SRC
- run from folder above the ParaView source folder or place the
ParaView source under \$WM_THIRD_PARTY_DIR
USAGE
exit 1
}
# add options based on script name:
case "$Script" in *-mpi*) WITH_MPI=ON;; esac
case "$Script" in *-python*) WITH_PYTHON=ON;; esac
case "$Script" in *-mesa*) WITH_MESA=ON;; esac
runCONFIG=true
runMAKE=true
runMAKEDOC=true
runINSTALL=true
runENVPATH=false
# parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help)
usage
;;
-config) # stage 1: config only
runCONFIG=true
runMAKE=false
runMAKEDOC=false
runINSTALL=false
shift
;;
-make) # stage 2: make only
runCONFIG=false
runMAKE=true
runMAKEDOC=false
runINSTALL=false
shift
;;
-makedoc) # stage 3: generate html documentation
runCONFIG=false
runMAKE=false
runMAKEDOC=true
runINSTALL=false
shift
;;
-install) # stage 4: install only
runCONFIG=false
runMAKE=false
runMAKEDOC=false
runINSTALL=true
shift
;;
-envpath) # optional: change cmake files to use env variables
runCONFIG=false
runMAKE=false
runMAKEDOC=false
runINSTALL=false
runENVPATH=true
shift
;;
-fast) # shortcut for rebuild
runCONFIG=false
runMAKE=true
runMAKEDOC=false
runINSTALL=true
shift
;;
-mpi)
WITH_MPI=ON
shift
;;
-python)
WITH_PYTHON=ON
shift
;;
-mesa)
WITH_MESA=ON
shift
;;
-verbose)
VERBOSE=ON
shift
;;
*)
usage "unknown option/argument: '$*'"
;;
esac
done
# Set configure options
#~~~~~~~~~~~~~~~~~~~~~~
addVerbosity # verbose makefiles
addMpiSupport # set MPI-specific options
addPythonSupport # set Python-specific options
addMesaSupport # set MESA-specific options
getPaths # discover where things are or should be put
# Build and install
# ~~~~~~~~~~~~~~~~~
[ $runCONFIG = true ] && configParaView
[ $runMAKE = true ] && makeParaView
[ $runMAKEDOC = true ] && makeDocs
[ $runINSTALL = true ] && installParaView
[ $runENVPATH = true ] && fixCMakeFiles
echo "done"
#------------------------------------------------------------------------------

View File

@ -0,0 +1 @@
buildParaView3.5-cvs

View File

@ -45,8 +45,8 @@ options:
-h help -h help
Updates the header of application files and removes consecutive blank lines. Updates the header of application files and removes consecutive blank lines.
By default, writes current version in the header. By default, writes current OpenFOAM version in the header.
An alternative version can be specified with -v option. An alternative version can be specified with the -v option.
USAGE USAGE
exit 1 exit 1
@ -59,8 +59,8 @@ printHeader() {
| ========= | | | ========= | |
| \\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\\\ / O peration | Version: ${foamVersion} | | \\\\ / O peration | Version: ${foamVersion} |
| \\\\ / A nd | Web: http://www.OpenFOAM.org | | \\\\ / A nd | |
| \\\\/ M anipulation | | | \\\\/ M anipulation | www.OpenFOAM.org |
\\*---------------------------------------------------------------------------*/ \\*---------------------------------------------------------------------------*/
FoamFile FoamFile
{ {
@ -84,13 +84,13 @@ FoamFileAttribute() {
# #
# OPTIONS # OPTIONS
# #
OPTS=`getopt hv: $*` opts=$(getopt hv: $*)
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "Aborting due to invalid option" echo "Aborting due to invalid option"
usage usage
fi fi
eval set -- '$OPTS' eval set -- '$opts'
while [ "$1" != "--" ] while [ "$1" != "--" ]
do do
case $1 in case $1 in
@ -110,11 +110,13 @@ shift
# constant width for version # constant width for version
foamVersion=`printf %-36s $foamVersion` foamVersion=$(printf %-36s $foamVersion)
# #
# MAIN # MAIN
# #
unset NOTE
for caseFile for caseFile
do do
if grep FoamFile $caseFile >/dev/null 2>&1 if grep FoamFile $caseFile >/dev/null 2>&1
@ -122,16 +124,17 @@ do
echo "Updating case file: $caseFile" echo "Updating case file: $caseFile"
sed -n '/FoamFile/,/}/p' $caseFile > FoamFile.tmp sed -n '/FoamFile/,/}/p' $caseFile > FoamFile.tmp
CLASS=`FoamFileAttribute class FoamFile.tmp` FORMAT=$(FoamFileAttribute format FoamFile.tmp)
OBJECT=`FoamFileAttribute object FoamFile.tmp` CLASS=$(FoamFileAttribute class FoamFile.tmp)
FORMAT=`FoamFileAttribute format FoamFile.tmp` OBJECT=$(FoamFileAttribute object FoamFile.tmp)
# extract NOTE?
printHeader $FORMAT $CLASS $OBJECT $NOTE > FoamFile.tmp printHeader $FORMAT $CLASS $OBJECT $NOTE > FoamFile.tmp
sed '1,/}/d' $caseFile | sed '/./,/^$/!d' >> FoamFile.tmp sed '1,/}/d' $caseFile | sed '/./,/^$/!d' >> FoamFile.tmp
# use cat to avoid removing/replace soft-links # use cat to avoid removing/replace soft-links
[ -s FoamFile.tmp ] && cat FoamFile.tmp >| $caseFile [ -s FoamFile.tmp ] && cat FoamFile.tmp >| $caseFile
rm FoamFile.tmp rm -f FoamFile.tmp 2>/dev/null
else else
echo " Invalid case file: $caseFile" 1>&2 echo " Invalid case file: $caseFile" 1>&2
fi fi

View File

@ -31,19 +31,19 @@
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
usage() { usage() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE cat<<USAGE
usage: ${0##*/} [OPTION] usage: ${0##*/} [OPTION]
options: options:
-case dir specify alternative case directory -case dir specify alternative case directory
-region name specify mesh region name -region name specify mesh region name
-touch create the .OpenFOAM file only and exit -touch only create the .OpenFOAM file
* start paraview $ParaView_VERSION with the OpenFOAM libraries * start paraview $ParaView_VERSION with the OpenFOAM libraries
USAGE USAGE
exit 1 exit 1
} }
unset regionName touchOnly unset regionName touchOnly
@ -51,81 +51,83 @@ unset regionName touchOnly
# parse options # parse options
while [ "$#" -gt 0 ] while [ "$#" -gt 0 ]
do do
case "$1" in case "$1" in
-h | -help) -h | -help)
usage usage
;; ;;
-case) -case)
[ "$#" -ge 2 ] || usage "'-case' option requires an argument" [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
caseDir=$2 cd "$2" 2>/dev/null || usage "directory does not exist: '$2'"
shift 2 shift 2
cd "$caseDir" 2>/dev/null || usage "directory does not exist: '$caseDir'" ;;
;; -region)
-region) [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
[ "$#" -ge 2 ] || usage "'-region' option requires an argument" regionName=$2
regionName=$2 shift 2
shift 2 ;;
;; -touch)
-touch) touchOnly=true
touchOnly=1 shift
shift ;;
;; *)
*) usage "unknown option/argument: '$*'"
usage "unknown option/argument: '$*'" ;;
;; esac
esac
done done
# get a sensible caseName # get a sensible caseName
caseName=${PWD##*/} caseName=${PWD##*/}
caseFile="$caseName.OpenFOAM" caseFile="$caseName.OpenFOAM"
fvControls="system"
if [ -n "$regionName" ] if [ -n "$regionName" ]
then then
caseFile="$caseName{$regionName}.OpenFOAM" caseFile="$caseName{$regionName}.OpenFOAM"
fvControls="$fvControls/$regionName"
fi fi
if [ -n "$touchOnly" ]; if [ -n "$touchOnly" ]
then then
touch "$caseFile" touch "$caseFile"
echo "created '$caseFile'" echo "created '$caseFile'"
exit 0 exit 0
fi fi
# parent directory for normal or parallel results # parent directory for normal or parallel results
case "$caseName" in case "$caseName" in
processor*) parentDir=".." ;; processor*) parentDir=".." ;;
*) parentDir="." ;; *) parentDir="." ;;
esac esac
# check existence of essential files # check existence of essential files
for check in system/controlDict system/fvSchemes system/fvSolution for check in system/controlDict $fvControls/fvSchemes $fvControls/fvSolution
do do
[ -s "$parentDir/$check" ] || usage "file does not exist: '$parentDir/$check'" [ -s "$parentDir/$check" ] || usage "file does not exist: '$parentDir/$check'"
done done
case "$ParaView_VERSION" in case "$ParaView_VERSION" in
2*) 2*)
trap "rm -f paraFoam.pvs $caseFile 2>/dev/null; exit 0" EXIT TERM INT trap "rm -f paraFoam.pvs $caseFile 2>/dev/null; exit 0" EXIT TERM INT
touch $caseFile touch "$caseFile"
# since we are now in the cwd, %CASE% is '$PWD/$caseFile' # since we are now in the cwd, %CASE% is '$PWD/$caseFile'
sed -e s@%CASE%@$PWD/$caseFile@g \ sed -e s@%CASE%@$PWD/$caseFile@g \
$WM_PROJECT_DIR/bin/paraFoam.pvs > paraFoam.pvs $WM_PROJECT_DIR/bin/tools/paraFoam.pvs > paraFoam.pvs
paraview paraFoam.pvs paraview paraFoam.pvs
;; ;;
*) *)
# only create/remove caseFile if it doesn't exist # only create/remove caseFile if it didn't already exist
[ -e $caseFile ] || { [ -e $caseFile ] || {
trap "rm -f $caseFile 2>/dev/null; exit 0" EXIT TERM INT trap "rm -f $caseFile 2>/dev/null; exit 0" EXIT TERM INT
touch "$caseFile" touch "$caseFile"
echo "created temporary '$caseFile'" echo "created temporary '$caseFile'"
} }
paraview --data="$caseFile" paraview --data="$caseFile"
;; ;;
esac esac
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -1,2 +1,2 @@
Misc. tools for building applications, etc that are useful to have Misc. tools, scripts, templates that are useful (eg, for building applications)
but which don't really need to be in the PATH. but don't need to be in the PATH.

View File

@ -34,8 +34,8 @@
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
. $WM_PROJECT_DIR/bin/tools/buildParaViewFunctions . $WM_PROJECT_DIR/bin/tools/buildParaViewFunctions
PARAVIEW_SRC="ParaView3.3-cvs" PARAVIEW_SRC=paraview-3.4
PARAVIEW_MAJOR_VERSION="3.3" PARAVIEW_MAJOR_VERSION=3.4
# User options: # User options:
# ~~~~~~~~~~~~~ # ~~~~~~~~~~~~~
@ -45,7 +45,7 @@ WITH_MPI=OFF
MPI_MAX_PROCS=32 MPI_MAX_PROCS=32
# Python support: # Python support:
# note: script will try to determine python library. # note: script will try to determine the appropriate python library.
# If it fails, specify the path using the PYTHON_LIBRARY variable # If it fails, specify the path using the PYTHON_LIBRARY variable
WITH_PYTHON=OFF WITH_PYTHON=OFF
PYTHON_LIBRARY="" PYTHON_LIBRARY=""
@ -60,18 +60,26 @@ WITH_MESA=OFF
Script=${0##*/} Script=${0##*/}
usage() { usage() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE cat<<USAGE
usage: ${0##*/} [OPTION] usage: ${0##*/} [OPTION]
options: options:
-fast skip cmake for repeated builds - use with caution -fast for repeated builds (-make -install) *use with caution*
-mpi with mpi (if not already enabled) -mpi with mpi (if not already enabled)
-python with python (if not already enabled) -python with python (if not already enabled)
-mesa with mesa (if not already enabled) -mesa with mesa (if not already enabled)
-verbose verbose cmake output -verbose verbose output in Makefiles
-help -help
For finer control, the build stages can be also selected individually
(mutually exclusive)
-config
-make
-makedoc
-install
[-envpath] alter absolute paths in CMake files to use env variables
Build and install $PARAVIEW_SRC Build and install $PARAVIEW_SRC
- run from folder above the ParaView source folder or place the - run from folder above the ParaView source folder or place the
ParaView source under \$WM_THIRD_PARTY_DIR ParaView source under \$WM_THIRD_PARTY_DIR
@ -80,57 +88,105 @@ USAGE
exit 1 exit 1
} }
# options based on the script name: # add options based on script name:
case "$Script" in *-fast*) CMAKE_SKIP=ON;; esac
case "$Script" in *-mpi*) WITH_MPI=ON;; esac case "$Script" in *-mpi*) WITH_MPI=ON;; esac
case "$Script" in *-python*) WITH_PYTHON=ON;; esac case "$Script" in *-python*) WITH_PYTHON=ON;; esac
case "$Script" in *-mesa*) WITH_MESA=ON;; esac case "$Script" in *-mesa*) WITH_MESA=ON;; esac
runCONFIG=true
runMAKE=true
runMAKEDOC=true
runINSTALL=true
runENVPATH=false
# parse options # parse options
while [ "$#" -gt 0 ] while [ "$#" -gt 0 ]
do do
case "$1" in case "$1" in
-h | -help) -h | -help)
usage usage
;; ;;
-fast) -config) # stage 1: config only
CMAKE_SKIP=YES runCONFIG=true
shift runMAKE=false
;; runMAKEDOC=false
-mpi) runINSTALL=false
WITH_MPI=ON shift
shift ;;
;; -make) # stage 2: make only
-python) runCONFIG=false
WITH_PYTHON=ON runMAKE=true
shift runMAKEDOC=false
;; runINSTALL=false
-mesa) shift
WITH_MESA=ON ;;
shift -makedoc) # stage 3: generate html documentation
;; runCONFIG=false
-verbose) runMAKE=false
VERBOSE=ON runMAKEDOC=true
shift runINSTALL=false
;; shift
*) ;;
usage "unknown option/argument: '$*'" -install) # stage 4: install only
;; runCONFIG=false
esac runMAKE=false
runMAKEDOC=false
runINSTALL=true
shift
;;
-envpath) # optional: change cmake files to use env variables
runCONFIG=false
runMAKE=false
runMAKEDOC=false
runINSTALL=false
runENVPATH=true
shift
;;
-fast) # shortcut for rebuild
runCONFIG=false
runMAKE=true
runMAKEDOC=false
runINSTALL=true
shift
;;
-mpi)
WITH_MPI=ON
shift
;;
-python)
WITH_PYTHON=ON
shift
;;
-mesa)
WITH_MESA=ON
shift
;;
-verbose)
VERBOSE=ON
shift
;;
*)
usage "unknown option/argument: '$*'"
;;
esac
done done
# Set configure options # Set configure options
#~~~~~~~~~~~~~~~~~~~~~~ #~~~~~~~~~~~~~~~~~~~~~~
addVerbosity # set CMake verbosity addVerbosity # verbose makefiles
addMpiSupport # set MPI-specific options addMpiSupport # set MPI-specific options
addPythonSupport # set Python-specific options addPythonSupport # set Python-specific options
addMesaSupport # set MESA-specific options addMesaSupport # set MESA-specific options
getPaths # discover where things are or should be put
# Build and install # Build and install
# ~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~
buildParaView [ $runCONFIG = true ] && configParaView
installParaView [ $runMAKE = true ] && makeParaView
[ $runENVPATH = true ] && fixCMakeFiles
[ $runMAKEDOC = true ] && makeDocs
[ $runINSTALL = true ] && installParaView
echo "done" echo "done"
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -31,299 +31,366 @@
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# ParaView_INST_DIR : location of the original sources # ParaView_INST_DIR : location of the original sources
# ParaView_DIR : location of the compiled output # ParaView_DIR : location of the build (for the ParaViewConfig.cmake)
# and the installed program
#
# set CMake cache variables
#
addCMakeVariable() addCMakeVariable()
{ {
while [ -n "$1" ] while [ -n "$1" ]
do do
CMAKE_VARIABLES="$CMAKE_VARIABLES -D$1" CMAKE_VARIABLES="$CMAKE_VARIABLES -D$1"
shift shift
done done
} }
#
# verbose makefiles
#
addVerbosity() addVerbosity()
{ {
[ "$VERBOSE" = ON ] && addCMakeVariable CMAKE_VERBOSE_MAKEFILE=TRUE [ "$VERBOSE" = ON ] && addCMakeVariable CMAKE_VERBOSE_MAKEFILE=TRUE
} }
#
# define options for mpi support
#
addMpiSupport() addMpiSupport()
{ {
[ "$WITH_MPI" = ON ] || return [ "$WITH_MPI" = ON ] || return
OBJ_ADD="$OBJ_ADD-mpi" OBJ_ADD="$OBJ_ADD-mpi"
addCMakeVariable PARAVIEW_USE_MPI=ON addCMakeVariable PARAVIEW_USE_MPI=ON VTK_USE_MPI=ON
addCMakeVariable VTK_USE_MPI=ON addCMakeVariable MPI_INCLUDE_PATH=$MPI_ARCH_PATH/include
addCMakeVariable MPI_INCLUDE_PATH=$MPI_ARCH_PATH/include addCMakeVariable MPI_LIBRARY=$MPI_ARCH_PATH/lib/libmpi.so
addCMakeVariable MPI_LIBRARY=$MPI_ARCH_PATH/lib/libmpi.so addCMakeVariable VTK_MPIRUN_EXE=$MPI_ARCH_PATH/bin/mpirun
addCMakeVariable VTK_MPIRUN_EXE=$MPI_ARCH_PATH/bin/mpirun addCMakeVariable VTK_MPI_MAX_NUMPROCS=$MPI_MAX_PROCS
addCMakeVariable VTK_MPI_MAX_NUMPROCS=$MPI_MAX_PROCS
} }
#
# define options for python support
#
addPythonSupport() addPythonSupport()
{ {
[ "$WITH_PYTHON" = ON ] || return [ "$WITH_PYTHON" = ON ] || return
OBJ_ADD="$OBJ_ADD-py" OBJ_ADD="$OBJ_ADD-py"
if pythonBin=$(which python 2>/dev/null) if pythonBin=$(which python 2>/dev/null)
then then
if [ -n "$PYTHON_LIBRARY" ] if [ -n "$PYTHON_LIBRARY" ]
then then
# check $PYTHON_LIBRARY if it has been set # check $PYTHON_LIBRARY if it has been set
if [ ! -e "$PYTHON_LIBRARY" ] if [ ! -e "$PYTHON_LIBRARY" ]
then then
echo "*** Error: libpython not found at location specified " \ echo "*** Error: libpython not found at location specified " \
"by PYTHON_LIBRARY=$PYTHON_LIBRARY" "by PYTHON_LIBRARY=$PYTHON_LIBRARY"
fi fi
else else
# Try to get $PYTHON_LIBRARY from dynamically linked binary # Try to get $PYTHON_LIBRARY from dynamically linked binary
PYTHON_LIBRARY=$(ldd $pythonBin | \ PYTHON_LIBRARY=$(ldd $pythonBin | \
sed -ne '/libpython/s/.* => \(.*\) (.*/\1/p') sed -ne '/libpython/s/.* => \(.*\) (.*/\1/p')
if [ ! -e "$PYTHON_LIBRARY" ] if [ ! -e "$PYTHON_LIBRARY" ]
then then
echo "*** Error: Unable to determine path to python library." echo "*** Error: Unable to determine path to python library."
fi fi
fi fi
[ -e "$PYTHON_LIBRARY" ] || { [ -e "$PYTHON_LIBRARY" ] || {
echo " Please set the variable PYTHON_LIBRARY to the full" echo " Please set the variable PYTHON_LIBRARY to the full"
echo " path to (and including) libpython, or deactivate" echo " path to (and including) libpython, or deactivate"
echo " python support by setting WITH_PYTHON=OFF" echo " python support by setting WITH_PYTHON=OFF"
exit 1 exit 1
} }
pythonMajor=$(echo $PYTHON_LIBRARY | sed 's/.*libpython\(.*\)\.so.*/\1/') pythonMajor=$(echo $PYTHON_LIBRARY | sed 's/.*libpython\(.*\)\.so.*/\1/')
pythonInclude=/usr/include/python$pythonMajor pythonInclude=/usr/include/python$pythonMajor
[ -e "$PYTHON_LIBRARY" ] || { [ -e "$PYTHON_LIBRARY" ] || {
echo " Please set the variable PYTHON_LIBRARY to the full" echo " Please set the variable PYTHON_LIBRARY to the full"
echo " path to (and including) libpython, or deactivate" echo " path to (and including) libpython, or deactivate"
echo " python support by setting WITH_PYTHON=OFF" echo " python support by setting WITH_PYTHON=OFF"
exit 1 exit 1
} }
# note - we could also allow for a PYTHON_INCLUDE variable ... # note - we could also allow for a PYTHON_INCLUDE variable ...
[ -e "$pythonInclude" ] || { [ -e "$pythonInclude" ] || {
echo " No python include headers found" echo " No python include headers found"
echo " Please install python headers or deactivate " echo " Please install python headers or deactivate "
echo " python support by setting WITH_PYTHON=OFF" echo " python support by setting WITH_PYTHON=OFF"
exit 1 exit 1
} }
addCMakeVariable PARAVIEW_ENABLE_PYTHON=ON addCMakeVariable PARAVIEW_ENABLE_PYTHON=ON
addCMakeVariable PYTHON_INCLUDE_PATH=$pythonInclude addCMakeVariable PYTHON_INCLUDE_PATH=$pythonInclude
addCMakeVariable PYTHON_LIBRARY=$PYTHON_LIBRARY addCMakeVariable PYTHON_LIBRARY=$PYTHON_LIBRARY
echo "----" echo "----"
echo "Python information:" echo "Python information:"
echo " executable : $pythonBin" echo " executable : $pythonBin"
echo " version : $pythonMajor" echo " version : $pythonMajor"
echo " include path : $pythonInclude" echo " include path : $pythonInclude"
echo " library : $PYTHON_LIBRARY" echo " library : $PYTHON_LIBRARY"
unset pythonBin pythonInclude pythonMajor unset pythonBin pythonInclude pythonMajor
else else
echo "*** Error: python not installed" echo "*** Error: python not installed"
echo "*** Deactivate python support by setting WITH_PYTHON=OFF" echo "*** Deactivate python support by setting WITH_PYTHON=OFF"
exit 1 exit 1
fi fi
} }
#
# define options for mesa support
#
addMesaSupport() addMesaSupport()
{ {
[ "$WITH_MESA" = ON ] || return [ "$WITH_MESA" = ON ] || return
MESA_INCLUDE_DIR=/usr/include/GL MESA_INCLUDE_DIR=/usr/include/GL
MESA_LIBRARY=/usr/lib$WM_COMPILER_LIB_ARCH/libOSMesa.so MESA_LIBRARY=/usr/lib$WM_COMPILER_LIB_ARCH/libOSMesa.so
if [ -d "$MESA_INCLUDE_DIR" -a -f "$MESA_LIBRARY" ] if [ -d "$MESA_INCLUDE_DIR" -a -f "$MESA_LIBRARY" ]
then then
OBJ_ADD="$OBJ_ADD-mesa" OBJ_ADD="$OBJ_ADD-mesa"
addCMakeVariable VTK_OPENGL_HAS_OSMESA=ON addCMakeVariable VTK_OPENGL_HAS_OSMESA=ON
addCMakeVariable OSMESA_INCLUDE_DIR=$MESA_INCLUDE_DIR addCMakeVariable OSMESA_INCLUDE_DIR=$MESA_INCLUDE_DIR
addCMakeVariable OSMESA_LIBRARY=$MESA_LIBRARY addCMakeVariable OSMESA_LIBRARY=$MESA_LIBRARY
else else
echo "*** Error: no MESA information found" echo "*** Error: no MESA information found"
exit 1 exit 1
fi fi
} }
buildParaView() #
# discover where things are or should be put
#
getPaths()
{ {
# set paraview environment # set paraview environment
for i in $PWD $WM_THIRD_PARTY_DIR for i in $PWD $WM_THIRD_PARTY_DIR
do do
ParaView_INST_DIR=$i/$PARAVIEW_SRC ParaView_INST_DIR=$i/$PARAVIEW_SRC
[ -d $ParaView_INST_DIR ] && break [ -d $ParaView_INST_DIR ] && break
done done
if [ ! -d "$ParaView_INST_DIR" ] if [ ! -d "$ParaView_INST_DIR" ]
then then
# last chance: maybe already in the paraview directory # last chance: maybe already in the paraview directory
[ "${PWD##*/}" = $PARAVIEW_SRC ] && ParaView_INST_DIR=$PWD [ "${PWD##*/}" = $PARAVIEW_SRC ] && ParaView_INST_DIR=$PWD
[ -d "$ParaView_INST_DIR" ] || { [ -d "$ParaView_INST_DIR" ] || {
echo "did not find $PARAVIEW_SRC in these directories:" echo "did not find $PARAVIEW_SRC in these directories:"
echo " PWD=$PWD" echo " PWD=$PWD"
echo " WM_THIRD_PARTY_DIR=$WM_THIRD_PARTY_DIR" echo " WM_THIRD_PARTY_DIR=$WM_THIRD_PARTY_DIR"
echo "abort build" echo "abort build"
exit 1 exit 1
} }
fi fi
# ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER$OBJ_ADD
# ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER$OBJ_ADD ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER
ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER echo "ParaView_DIR=$ParaView_DIR"
# shortcut for repeated builds - use with caution
if [ "$CMAKE_SKIP" = YES ]
then
# change to build/install folder
cd $ParaView_DIR || exit 1
else
# remove any existing build folder and recreate
rm -rf $ParaView_DIR
mkdir -p $ParaView_DIR
cd $ParaView_DIR
echo "----"
echo "Building $PARAVIEW_SRC"
echo " MPI support : $WITH_MPI"
echo " Python support : $WITH_PYTHON"
echo " MESA support : $WITH_MESA"
echo " Source : $ParaView_INST_DIR"
echo " Target : $ParaView_DIR"
echo "----"
# make paraview
cmake \
-DCMAKE_INSTALL_PREFIX=$PARAVIEW_APP_DIR \
$CMAKE_VARIABLES \
$ParaView_INST_DIR
fi
# change to build folder
echo " Starting make"
if [ -r /proc/cpuinfo ]
then
WM_NCOMPPROCS=$(egrep "^processor" /proc/cpuinfo | wc -l)
if [ $WM_NCOMPPROCS -gt 8 ]
then
WM_NCOMPPROCS=8
fi
make -j $WM_NCOMPPROCS
else
make
fi
} }
# adjust hard-links #
# configure via cmake, but don't actually build anything
#
configParaView()
{
# remove any existing build folder and recreate
if [ -d $ParaView_DIR ]
then
echo "removing old build/install directory"
rm -rf $ParaView_DIR
fi
mkdir -p $ParaView_DIR
cd $ParaView_DIR
echo "----"
echo "Configuring $PARAVIEW_SRC"
echo " MPI support : $WITH_MPI"
echo " Python support : $WITH_PYTHON"
echo " MESA support : $WITH_MESA"
echo " Source : $ParaView_INST_DIR"
echo " Target : $ParaView_DIR"
echo "----"
echo
echo cmake \
-DCMAKE_INSTALL_PREFIX:PATH=$ParaView_DIR \
$CMAKE_VARIABLES \
../..
echo
echo "----"
echo
# run cmake to create Makefiles
cmake \
-DCMAKE_INSTALL_PREFIX:PATH=$ParaView_DIR \
$CMAKE_VARIABLES \
../..
}
#
# invoke make
# also link bin/ to lib/paraview-* for development without installation
#
makeParaView()
{
cd $ParaView_DIR || exit 1 # change to build folder
echo " Starting make"
if [ -r /proc/cpuinfo ]
then
WM_NCOMPPROCS=$(egrep "^processor" /proc/cpuinfo | wc -l)
[ $WM_NCOMPPROCS -le 8 ] || WM_NCOMPPROCS=8
time make -j $WM_NCOMPPROCS
else
time make
fi
echo " Done make"
echo " For quicker development, linking lib/paraview-$PARAVIEW_MAJOR_VERSION/ -> bin/"
rm -rf lib/paraview-$PARAVIEW_MAJOR_VERSION
mkdir lib 2>/dev/null
( cd lib && ln -s ../bin paraview-$PARAVIEW_MAJOR_VERSION )
}
#
# adjust hard-links (internal function)
# Note: use loop with grep to avoid touching too many files # Note: use loop with grep to avoid touching too many files
fixCMakeHardLinks() #
fixHardLinks()
{ {
fileSpec=$1 envName=$1
string=$2 string=$2
envName=$3 shift 2
echo -n " for \$$envName " echo "-- Replacing path hard links for \$$envName"
for i in $(find . -type f -iname "$fileSpec")
do for fileSpec
if grep -q "$string" $i do
then echo -n " $fileSpec: "
echo -n "#" for i in $(find . -type f -iname "$fileSpec")
sed -i "s,$string,\$ENV{$envName},g" $i do
fi if grep -q "$string" $i
done then
echo echo -n "#"
sed -i "s,$string,\$ENV{$envName},g" $i
fi
done
echo
done
} }
#
# replace absolute paths with environment variables
# This triggers a partial (or even a full) rebuild, but might let us
# find our files later if we relocate the build
#
fixCMakeFiles()
{
cd $ParaView_DIR || exit 1 # change to build folder
# Replace path with env variable: ParaView_DIR
fixHardLinks ParaView_DIR "$ParaView_DIR" '*.cmake'
# Replace path with env variable: ParaView_INST_DIR
fixHardLinks ParaView_INST_DIR "$ParaView_INST_DIR" '*.cmake'
# Replace path with env variable: MPI_ARCH_PATH
if [ "$WITH_MPI" = ON ]
then
fixHardLinks MPI_ARCH_PATH "$MPI_ARCH_PATH" '*.cmake'
fi
# Replace path with env variable: CMAKE_HOME
if [ -r "$CMAKE_HOME" ]
then
fixHardLinks CMAKE_HOME "$CMAKE_HOME" '*cmake*'
fi
# Replace path with env variable: WM_COMPILER_DIR
# (include cmake.check_cache)
# This triggers a complete rebuild (with cmake-2.6.2), but is likely
# needed when redistributing files
fixHardLinks WM_COMPILER_DIR "$WM_COMPILER_DIR" '*cmake*'
}
#
# make html documentation (mostly just for the readers/writers)
#
makeDocs()
{
cd $ParaView_DIR || exit 1 # change to build folder
echo " Creating html documentation"
make HTMLDocumentation
}
#
# actually install the program
#
installParaView() installParaView()
{ {
if [ ! -e "$ParaView_DIR/bin/paraview" ] cd $ParaView_DIR || exit 1 # change to build folder
then echo " Installing ParaView to $ParaView_DIR"
echo " Cannot install - no paraview binary found"
return
fi
echo " Build complete"
cd $ParaView_DIR echo "disabled 'make install' for now, just use links"
echo " Replacing path hard links" # about.txt may be missing
paraviewLibDir="$ParaView_DIR/lib/paraview-$PARAVIEW_MAJOR_VERSION"
if [ -d "$paraviewLibDir" -a ! -e "$paraviewLibDir/about.txt" ]
then
echo "paraview-$PARAVIEW_MAJOR_VERSION installed - $(date)" > $paraviewLibDir/about.txt
fi
# Replace local ParaView_INST_DIR path with ParaView_INST_DIR cat<< INFO
# environment variable ---
fixCMakeHardLinks '*.cmake' "$ParaView_INST_DIR" ParaView_INST_DIR Installation complete
Set environment variables:
# Replace local MPI_ARCH_PATH path with MPI_ARCH_PATH export ParaView_INST_DIR=$ParaView_INST_DIR
# environment variable export ParaView_DIR=$ParaView_DIR
if [ "$WITH_MPI" = ON ] export PV_PLUGIN_PATH=$FOAM_LIBBIN
then export PATH=\$ParaView_DIR/bin:\$PATH
fixCMakeHardLinks '*.cmake' "$MPI_ARCH_PATH" MPI_ARCH_PATH ---
fi INFO
# Replace local CMAKE_HOME path with CMAKE_HOME
# environment variable
if [ -r "$CMAKE_HOME" ]
then
fixCMakeHardLinks '*cmake*' "$CMAKE_HOME" CMAKE_HOME
fi
# Replace local WM_COMPILER_DIR path with WM_COMPILER_DIR
# environment variable
fixCMakeHardLinks '*cmake*' "$WM_COMPILER_DIR" WM_COMPILER_DIR
# create a softlink to the $ParaView_DIR/bin folder
# - workaround for chosen install location
echo " Creating lib/paraview-$PARAVIEW_MAJOR_VERSION soft link to 'bin'"
rm -rf lib/paraview-$PARAVIEW_MAJOR_VERSION
[ -d lib ] || mkdir lib
( cd lib && ln -s ../bin paraview-$PARAVIEW_MAJOR_VERSION )
# info on symlinks to screen
echo ""
echo " ---"
echo " Installation complete"
echo " Set environment variables:"
echo " - ParaView_INST_DIR to $ParaView_INST_DIR"
echo " - ParaView_DIR to $ParaView_DIR"
echo " - PV_PLUGIN_PATH to $FOAM_LIBBIN"
echo " Add $ParaView_DIR/bin to PATH"
# echo " Add $ParaView_INST_DIR/lib to LD_LIBRARY_PATH"
echo " ---"
} }
# clear all the variables used before using any of the functions # clear all the variables used before using any of the functions
unset VERBOSE unset VERBOSE
unset WITH_MPI unset WITH_MPI WITH_MESA
unset WITH_MESA unset WITH_PYTHON PYTHON_LIBRARY
unset WITH_PYTHON
unset PYTHON_LIBRARY
unset CMAKE_VARIABLES unset CMAKE_VARIABLES
unset CMAKE_SKIP
unset OBJ_ADD unset OBJ_ADD
# start with these general settings # start with these general settings
addCMakeVariable VTK_USE_TK=FALSE addCMakeVariable VTK_USE_TK=FALSE
addCMakeVariable BUILD_SHARED_LIBS:BOOL=ON addCMakeVariable BUILD_SHARED_LIBS:BOOL=ON VTK_USE_RPATH:BOOL=OFF
addCMakeVariable VTK_USE_RPATH:BOOL=OFF
addCMakeVariable CMAKE_BUILD_TYPE:STRING=Release addCMakeVariable CMAKE_BUILD_TYPE:STRING=Release
# include development files in "make install"
addCMakeVariable PARAVIEW_INSTALL_DEVELOPMENT:BOOL=ON
# ----------------------------------------------------------------- end-of-file # ----------------------------------------------------------------- end-of-file

View File

@ -26,38 +26,49 @@
# paraview3/bashrc # paraview3/bashrc
# #
# Description # Description
# Setup file for ParaView3. # Setup file for paraview-3.x
# Sourced from OpenFOAM-?.?/etc/bashrc # Sourced from OpenFOAM-?.?/etc/bashrc
# #
# Note
# The env. variable 'ParaView_DIR' is required for building plugins
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
export CMAKE_HOME=$WM_THIRD_PARTY_DIR/cmake-2.4.6/platforms/$WM_ARCH # determine the cmake to be used
unset CMAKE_HOME
for cmake in cmake-2.6.2 cmake-2.4.6
do
cmake=$WM_THIRD_PARTY_DIR/$cmake/platforms/$WM_ARCH
if [ -r $cmake ]
then
export CMAKE_HOME=$cmake
export PATH=$CMAKE_HOME/bin:$PATH
break
fi
done
if [ -r $CMAKE_HOME ] paraviewMajor=paraview-3.5
then export ParaView_VERSION=3.5-cvs
export PATH=$CMAKE_HOME/bin:$PATH
else
unset CMAKE_HOME
fi
export ParaView_VERSION="3.3-cvs" export ParaView_INST_DIR=$WM_THIRD_PARTY_DIR/paraview-$ParaView_VERSION
export ParaView_INST_DIR=$WM_THIRD_PARTY_DIR/ParaView$ParaView_VERSION
export ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER export ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER
if [ "$PYTHONPATH" ] # add in python libraries if required
paraviewPython=$ParaView_DIR/Utilities/VTKPythonWrapping
if [ -r $paraviewPython ]
then then
export PYTHONPATH=$PYTHONPATH:$ParaView_DIR/Utilities/VTKPythonWrapping:$ParaView_DIR/lib/paraview-3.3 if [ "$PYTHONPATH" ]
else then
export PYTHONPATH=$ParaView_DIR/Utilities/VTKPythonWrapping:$ParaView_DIR/lib/paraview-3.3 export PYTHONPATH=$PYTHONPATH:$paraviewPython:$ParaView_DIR/lib/$paraviewMajor
else
export PYTHONPATH=$paraviewPython:$ParaView_DIR/lib/$paraviewMajor
fi
fi fi
if [ -r $ParaView_DIR ] if [ -r $ParaView_DIR ]
then then
export PATH=$ParaView_DIR/bin:$PATH export PATH=$ParaView_DIR/bin:$PATH
export LD_LIBRARY_PATH=$ParaView_DIR/bin:$LD_LIBRARY_PATH
export PV_PLUGIN_PATH=$FOAM_LIBBIN export PV_PLUGIN_PATH=$FOAM_LIBBIN
fi fi
unset cmake paraviewMajor paraviewPython
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------

View File

@ -26,34 +26,44 @@
# paraview3/cshrc # paraview3/cshrc
# #
# Description # Description
# Startup File for Paraview3 # Startup File for paraview-3.x
# Sourced from OpenFOAM-?.?/etc/cshrc # Sourced from OpenFOAM-?.?/etc/cshrc
# #
# Note
# The env. variable 'ParaView_DIR' is required for building plugins
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
setenv CMAKE_HOME $WM_THIRD_PARTY_DIR/cmake-2.4.6/platforms/$WM_ARCH # determine the cmake to be used
unsetenv CMAKE_HOME
foreach cmake ( cmake-2.6.2 cmake-2.4.6 )
set cmake=$WM_THIRD_PARTY_DIR/$cmake/platforms/$WM_ARCH
if ( -r $cmake ) then
setenv CMAKE_HOME $cmake
set path=($CMAKE_HOME/bin $path)
break
endif
end
if ( -r $CMAKE_HOME ) then set paraviewMajor=paraview-3.5
set path=($CMAKE_HOME/bin $path) setenv ParaView_VERSION 3.5-cvs
else
unsetenv CMAKE_HOME
endif
setenv ParaView_VERSION 3.3-cvs setenv ParaView_INST_DIR $WM_THIRD_PARTY_DIR/paraview-$ParaView_VERSION
setenv ParaView_INST_DIR $WM_THIRD_PARTY_DIR/ParaView$ParaView_VERSION
setenv ParaView_DIR $ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER setenv ParaView_DIR $ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER
if ($?PYTHONPATH) then # add in python libraries if required
setenv PYTHONPATH ${PYTHONPATH}:$ParaView_DIR/Utilities/VTKPythonWrapping:$ParaView_DIR/lib/paraview-3.3 set paraviewPython=$ParaView_DIR/Utilities/VTKPythonWrapping
else if ( -r $paraviewPython ) then
setenv PYTHONPATH $ParaView_DIR/Utilities/VTKPythonWrapping:$ParaView_DIR/lib/paraview-3.3 if ($?PYTHONPATH) then
setenv PYTHONPATH ${PYTHONPATH}:$paraviewPython:$ParaView_DIR/lib/${paraviewMajor}
else
setenv PYTHONPATH $paraviewPython:$ParaView_DIR/lib/${paraviewMajor}
endif
endif endif
if ( -r $ParaView_INST_DIR ) then if ( -r $ParaView_INST_DIR ) then
set path=($ParaView_DIR/bin $path) set path=($ParaView_DIR/bin $path)
setenv LD_LIBRARY_PATH $ParaView_DIR/bin:$LD_LIBRARY_PATH
setenv PV_PLUGIN_PATH $FOAM_LIBBIN setenv PV_PLUGIN_PATH $FOAM_LIBBIN
endif endif
unset cmake paraviewMajor paraviewPython
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------

View File

@ -91,7 +91,7 @@ export WM_COMPILER_LIB_ARCH=
# WM_JAVAC_OPTION = Opt | Debug # WM_JAVAC_OPTION = Opt | Debug
: ${WM_JAVAC_OPTION:=Opt}; export WM_JAVAC_OPTION : ${WM_JAVAC_OPTION:=Opt}; export WM_JAVAC_OPTION
# WM_MPLIB = | OPENMPI| LAM | MPICH | MPICH-GM | HPMPI | GAMMA | MPI # WM_MPLIB = | OPENMPI | LAM | MPICH | MPICH-GM | HPMPI | GAMMA | MPI
: ${WM_MPLIB:=OPENMPI}; export WM_MPLIB : ${WM_MPLIB:=OPENMPI}; export WM_MPLIB

View File

@ -2,6 +2,9 @@
cd ${0%/*} || exit 1 # run from this directory cd ${0%/*} || exit 1 # run from this directory
set -x set -x
# force update of Foam::FOAMversion string (git tag or $WM_PROJECT_VERSION)
/bin/rm -f OpenFOAM/Make/$WM_OPTIONS/global.? 2>/dev/null
wmakeLnInclude -f OpenFOAM wmakeLnInclude -f OpenFOAM
wmakeLnInclude -f OSspecific/$WM_OS wmakeLnInclude -f OSspecific/$WM_OS
Pstream/Allwmake Pstream/Allwmake

View File

@ -2,6 +2,7 @@ signals/sigFpe.C
signals/sigSegv.C signals/sigSegv.C
signals/sigInt.C signals/sigInt.C
signals/sigQuit.C signals/sigQuit.C
regExp.C
timer.C timer.C
fileStat.C fileStat.C
Unix.C Unix.C

View File

@ -211,7 +211,7 @@ bool Foam::chDir(const fileName& dir)
} }
Foam::fileName Foam::dotFoam(const fileName& name) Foam::fileName Foam::findEtcFile(const fileName& name, bool mandatory)
{ {
// Search user files: // Search user files:
// ~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~
@ -268,6 +268,15 @@ Foam::fileName Foam::dotFoam(const fileName& name)
} }
// Not found // Not found
// abort if the file is mandatory, otherwise return null
if (mandatory)
{
cerr<< "--> FOAM FATAL ERROR in Foam::findEtcFile() :"
" could not find mandatory file\n '"
<< name.c_str() << "'\n\n" << std::endl;
::exit(1);
}
return fileName::null; return fileName::null;
} }

View File

@ -0,0 +1,208 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 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 <sys/types.h>
#include "regExp.H"
#include "label.H"
#include "string.H"
#include "List.H"
#include "IOstreams.H"
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
void Foam::regExp::compile(const char* pat) const
{
clear();
// avoid NULL and zero-length patterns
if (pat && *pat)
{
preg_ = new regex_t;
if (regcomp(preg_, pat, REG_EXTENDED) != 0)
{
FatalErrorIn
(
"regExp::compile(const char*)"
) << "Failed to compile regular expression '" << pat << "'"
<< exit(FatalError);
}
}
}
void Foam::regExp::clear() const
{
if (preg_)
{
regfree(preg_);
delete preg_;
preg_ = 0;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::regExp::regExp()
:
preg_(0)
{}
Foam::regExp::regExp(const string& pat)
:
preg_(0)
{
compile(pat.c_str());
}
Foam::regExp::regExp(const char* pat)
:
preg_(0)
{
compile(pat);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::regExp::~regExp()
{
clear();
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
int Foam::regExp::ngroups() const
{
return preg_ ? preg_->re_nsub : 0;
}
bool Foam::regExp::match
(
const string& str,
bool partialMatch
) const
{
if (preg_ && str.size())
{
size_t nmatch = 1;
regmatch_t pmatch[1];
// match and also verify that the entire string was matched
// pmatch[0] is the entire match
if
(
regexec(preg_, str.c_str(), nmatch, pmatch, 0) == 0
&&
(
partialMatch
|| (pmatch[0].rm_so == 0 && pmatch[0].rm_eo == label(str.size()))
)
)
{
return true;
}
}
return false;
}
bool Foam::regExp::match
(
const string& str,
List<string>& groups,
bool partialMatch
) const
{
if (preg_ && str.size())
{
size_t nmatch = ngroups() + 1;
regmatch_t pmatch[nmatch];
// match and also verify that the entire string was matched
// pmatch[0] is the entire match
// pmatch[1..] are the (...) sub-groups
if
(
regexec(preg_, str.c_str(), nmatch, pmatch, 0) == 0
&&
(
partialMatch
|| (pmatch[0].rm_so == 0 && pmatch[0].rm_eo == label(str.size()))
)
)
{
groups.setSize(ngroups());
label groupI = 0;
for (size_t matchI = 1; matchI < nmatch; matchI++)
{
if (pmatch[matchI].rm_so != -1 && pmatch[matchI].rm_eo != -1)
{
groups[groupI] = str.substr
(
pmatch[matchI].rm_so,
pmatch[matchI].rm_eo - pmatch[matchI].rm_so
);
}
else
{
groups[groupI].clear();
}
groupI++;
}
return true;
}
}
groups.clear();
return false;
}
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
void Foam::regExp::operator=(const string& pat)
{
compile(pat.c_str());
}
void Foam::regExp::operator=(const char* pat)
{
compile(pat);
}
// ************************************************************************* //

View File

@ -23,94 +23,108 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
Foam::regularExpression Foam::regExp
Description Description
Wrapper around regular expressions. Wrapper around POSIX extended regular expressions.
The beginning-of-line (^) and the end-of-line ($) anchors are implicit
by default.
SeeAlso
The manpage regex(7) for more information about POSIX regular expressions.
These differ somewhat from @c Perl and @c sed regular expressions.
SourceFiles SourceFiles
regExp.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef regularExpression_H #ifndef regExp_H
#define regularExpression_H #define regExp_H
#include <sys/types.h>
#include <regex.h> #include <regex.h>
#include "string.H"
#include "IOstreams.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
// Forward declaration of classes
class string;
template<class T> class List;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class regularExpression Declaration Class regExp Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class regularExpression class regExp
{ {
// Private data // Private data
//- Precompiled regular expression //- Precompiled regular expression
regex_t* preg_; mutable regex_t* preg_;
// Private member functions // Private member functions
//- release allocated space
void clear() const;
//- compile into a regular expression
void compile(const char*) const;
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
regularExpression(const regularExpression&); regExp(const regExp&);
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const regularExpression&); void operator=(const regExp&);
public: public:
// Constructors // Constructors
//- Construct null
regExp();
//- Construct from string //- Construct from string
inline regularExpression(const string& s) regExp(const string&);
{
preg_ = new regex_t;
if (regcomp(preg_, s.c_str(), REG_EXTENDED) != 0)
{
FatalErrorIn
(
"regularExpression::regularExpression(const char*)"
) << "Failed to compile regular expression " << s
<< exit(FatalError);
}
}
//- Construct from character array
regExp(const char*);
// Destructor // Destructor
//- Construct from string ~regExp();
inline ~regularExpression()
{
if (preg_)
{
regfree(preg_);
delete preg_;
}
}
// Member functions // Member functions
//- Matches? //- Return the number of (groups)
inline bool matches(const string& s) const int ngroups() const;
{
size_t nmatch = 1;
regmatch_t pmatch[1];
int errVal = regexec(preg_, s.c_str(), nmatch, pmatch, 0); //- Return true if it matches, partial matches are optional
bool match
(
const string&,
bool partialMatch=false
) const;
//- Return true if it matches and sets the sub-groups matched,
// partial matches are optional
bool match
(
const string&,
List<string>& groups,
bool partialMatch=false
) const;
// Member Operators
//- Assign from a string
void operator=(const string&);
//- Assign from a character array
void operator=(const char*);
return (errVal == 0 && pmatch[0].rm_eo == label(s.size()));
}
}; };

View File

@ -289,7 +289,6 @@ $(tetCell)/tetCell.C
cellModeller = $(meshShapes)/cellModeller cellModeller = $(meshShapes)/cellModeller
$(cellModeller)/cellModeller.C $(cellModeller)/cellModeller.C
$(cellModeller)/cellModellerIO.C
cellModel = $(meshShapes)/cellModel cellModel = $(meshShapes)/cellModel
$(cellModel)/cellModel.C $(cellModel)/cellModel.C

View File

@ -28,22 +28,15 @@ Description
#include "Dictionary.H" #include "Dictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Null constructor
template<class T> template<class T>
Dictionary<T>::Dictionary() Foam::Dictionary<T>::Dictionary()
{} {}
// Copy constructor
template<class T> template<class T>
Dictionary<T>::Dictionary(const Dictionary& dict) Foam::Dictionary<T>::Dictionary(const Dictionary& dict)
: :
DictionaryBase<IDLList<T>, T>(dict) DictionaryBase<IDLList<T>, T>(dict)
{} {}
@ -52,10 +45,10 @@ Dictionary<T>::Dictionary(const Dictionary& dict)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T> template<class T>
bool Dictionary<T>::erase(const word& Keyword) bool Foam::Dictionary<T>::erase(const word& keyword)
{ {
T* tPtr; T* tPtr;
if ((tPtr = this->remove(Keyword))) if (tPtr = this->remove(keyword))
{ {
delete tPtr; delete tPtr;
return true; return true;
@ -69,6 +62,4 @@ bool Dictionary<T>::erase(const word& Keyword)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -27,8 +27,10 @@ Class
Description Description
Gerneral purpose template dictionary class which manages the storage Gerneral purpose template dictionary class which manages the storage
associated with it. It is derived from DictionaryBase instantiated on associated with it.
a memory managed form of intrusive doubly-linked list of \<T\>.
It is derived from DictionaryBase instantiated on a memory managed form
of intrusive doubly-linked list of \<T\>.
SourceFiles SourceFiles
Dictionary.C Dictionary.C
@ -47,7 +49,7 @@ namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class Dictionary Declaration Class Dictionary Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class T> template<class T>
@ -69,11 +71,9 @@ public:
// Member functions // Member functions
// Editing //- Remove an entry specified by keyword and delete the pointer.
// Returns true if the keyword was found
//- Remove an entry specified by keyword from the dictionary bool erase(const word& keyword);
// and delete it
bool erase(const word& keyword);
}; };

View File

@ -26,15 +26,10 @@ License
#include "DictionaryBase.H" #include "DictionaryBase.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class IDLListType, class T> template<class IDLListType, class T>
void DictionaryBase<IDLListType, T>::addEntries() void Foam::DictionaryBase<IDLListType, T>::addEntries()
{ {
for for
( (
@ -51,12 +46,15 @@ void DictionaryBase<IDLListType, T>::addEntries()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class IDLListType, class T> template<class IDLListType, class T>
DictionaryBase<IDLListType, T>::DictionaryBase() Foam::DictionaryBase<IDLListType, T>::DictionaryBase()
{} {}
template<class IDLListType, class T> template<class IDLListType, class T>
DictionaryBase<IDLListType, T>::DictionaryBase(const DictionaryBase& dict) Foam::DictionaryBase<IDLListType, T>::DictionaryBase
(
const DictionaryBase& dict
)
: :
IDLListType(dict) IDLListType(dict)
{ {
@ -66,17 +64,20 @@ DictionaryBase<IDLListType, T>::DictionaryBase(const DictionaryBase& dict)
template<class IDLListType, class T> template<class IDLListType, class T>
template<class INew> template<class INew>
DictionaryBase<IDLListType, T>::DictionaryBase(Istream& is, const INew& inewt) Foam::DictionaryBase<IDLListType, T>::DictionaryBase
(
Istream& is,
const INew& iNew
)
: :
IDLListType(is, inewt) IDLListType(is, iNew)
{ {
addEntries(); addEntries();
} }
// Istream constructor
template<class IDLListType, class T> template<class IDLListType, class T>
DictionaryBase<IDLListType, T>::DictionaryBase(Istream& is) Foam::DictionaryBase<IDLListType, T>::DictionaryBase(Istream& is)
: :
IDLListType(is) IDLListType(is)
{ {
@ -88,25 +89,60 @@ DictionaryBase<IDLListType, T>::DictionaryBase(Istream& is)
// Find and return T // Find and return T
template<class IDLListType, class T> template<class IDLListType, class T>
bool DictionaryBase<IDLListType, T>::found(const word& keyword) const bool Foam::DictionaryBase<IDLListType, T>::found(const word& keyword) const
{ {
return hashedTs_.found(keyword); return hashedTs_.found(keyword);
} }
// Find and return T* // Find and return T*, return NULL if not found
template<class IDLListType, class T> template<class IDLListType, class T>
const T* DictionaryBase<IDLListType, T>::lookup(const word& keyword) const const T* Foam::DictionaryBase<IDLListType, T>::lookupPtr
(
const word& keyword
) const
{
typename HashTable<T*>::const_iterator iter = hashedTs_.find(keyword);
if (iter != hashedTs_.end())
{
return *iter;
}
else
{
return NULL;
}
}
// Find and return T*, return NULL if not found
template<class IDLListType, class T>
T* Foam::DictionaryBase<IDLListType, T>::lookupPtr(const word& keyword)
{
typename HashTable<T*>::iterator iter = hashedTs_.find(keyword);
if (iter != hashedTs_.end())
{
return *iter;
}
else
{
return NULL;
}
}
// Find and return T*, FatalError if keyword not found
template<class IDLListType, class T>
const T* Foam::DictionaryBase<IDLListType, T>::lookup(const word& keyword) const
{ {
typename HashTable<T*>::const_iterator iter = hashedTs_.find(keyword); typename HashTable<T*>::const_iterator iter = hashedTs_.find(keyword);
if (iter == hashedTs_.end()) if (iter == hashedTs_.end())
{ {
// If keyword not found print error message ...
FatalErrorIn FatalErrorIn
( (
"DictionaryBase<IDLListType, T>::" "DictionaryBase<IDLListType, T>::lookup(const word&) const"
"lookup(const word& keyword) const"
) << keyword << " is undefined" ) << keyword << " is undefined"
<< exit(FatalError); << exit(FatalError);
} }
@ -115,18 +151,17 @@ const T* DictionaryBase<IDLListType, T>::lookup(const word& keyword) const
} }
// Find and return T* // Find and return T*, FatalError if keyword not found
template<class IDLListType, class T> template<class IDLListType, class T>
T* DictionaryBase<IDLListType, T>::lookup(const word& keyword) T* Foam::DictionaryBase<IDLListType, T>::lookup(const word& keyword)
{ {
typename HashTable<T*>::iterator iter = hashedTs_.find(keyword); typename HashTable<T*>::iterator iter = hashedTs_.find(keyword);
if (iter == hashedTs_.end()) if (iter == hashedTs_.end())
{ {
// If keyword not found print error message ...
FatalErrorIn FatalErrorIn
( (
"DictionaryBase<IDLListType, T>::lookup(const word& keyword)" "DictionaryBase<IDLListType, T>::lookup(const word&)"
) << keyword << " is undefined" ) << keyword << " is undefined"
<< exit(FatalError); << exit(FatalError);
} }
@ -137,7 +172,7 @@ T* DictionaryBase<IDLListType, T>::lookup(const word& keyword)
// Return the table of contents // Return the table of contents
template<class IDLListType, class T> template<class IDLListType, class T>
wordList DictionaryBase<IDLListType, T>::toc() const Foam::wordList Foam::DictionaryBase<IDLListType, T>::toc() const
{ {
wordList keywords(this->size()); wordList keywords(this->size());
@ -158,26 +193,28 @@ wordList DictionaryBase<IDLListType, T>::toc() const
// Add at head of dictionary // Add at head of dictionary
template<class IDLListType, class T> template<class IDLListType, class T>
void DictionaryBase<IDLListType, T>::insert(const word& keyword, T* tPtr) void Foam::DictionaryBase<IDLListType, T>::insert(const word& keyword, T* tPtr)
{ {
IDLListType::insert(tPtr); // NOTE: we should probably check that HashTable::insert actually worked
hashedTs_.insert(keyword, tPtr); hashedTs_.insert(keyword, tPtr);
IDLListType::insert(tPtr);
} }
// Add at tail of dictionary // Add at tail of dictionary
template<class IDLListType, class T> template<class IDLListType, class T>
void DictionaryBase<IDLListType, T>::append(const word& keyword, T* tPtr) void Foam::DictionaryBase<IDLListType, T>::append(const word& keyword, T* tPtr)
{ {
IDLListType::append(tPtr); // NOTE: we should probably check that HashTable::insert actually worked
hashedTs_.insert(keyword, tPtr); hashedTs_.insert(keyword, tPtr);
IDLListType::append(tPtr);
} }
template<class IDLListType, class T> template<class IDLListType, class T>
T* DictionaryBase<IDLListType, T>::remove(const word& Keyword) T* Foam::DictionaryBase<IDLListType, T>::remove(const word& keyword)
{ {
typename HashTable<T*>::iterator iter = hashedTs_.find(Keyword); typename HashTable<T*>::iterator iter = hashedTs_.find(keyword);
if (iter != hashedTs_.end()) if (iter != hashedTs_.end())
{ {
@ -192,19 +229,29 @@ T* DictionaryBase<IDLListType, T>::remove(const word& Keyword)
} }
//- Clear the dictionary
template<class IDLListType, class T> template<class IDLListType, class T>
void DictionaryBase<IDLListType, T>::clear() void Foam::DictionaryBase<IDLListType, T>::clear()
{ {
IDLListType::clear(); IDLListType::clear();
hashedTs_.clear(); hashedTs_.clear();
} }
template<class IDLListType, class T>
void Foam::DictionaryBase<IDLListType, T>::transfer
(
DictionaryBase<IDLListType, T>& dict
)
{
IDLListType::transfer(dict);
hashedTs_.transfer(dict.hashedTs_);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class IDLListType, class T> template<class IDLListType, class T>
void DictionaryBase<IDLListType, T>::operator= void Foam::DictionaryBase<IDLListType, T>::operator=
( (
const DictionaryBase<IDLListType, T>& dict const DictionaryBase<IDLListType, T>& dict
) )
@ -218,25 +265,11 @@ void DictionaryBase<IDLListType, T>::operator=
} }
IDLListType::operator=(dict); IDLListType::operator=(dict);
this->hashedTs_.clear(); this->hashedTs_.clear();
this->addEntries();
for
(
typename IDLListType::iterator iter = this->begin();
iter != this->end();
++iter
)
{
this->hashedTs_.insert((*iter).keyword(), &(*iter));
}
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "DictionaryBaseIO.C" #include "DictionaryBaseIO.C"

View File

@ -29,12 +29,12 @@ Description
Base dictionary class templated on both the form of doubly-linked list Base dictionary class templated on both the form of doubly-linked list
it uses as well as the type it holds. it uses as well as the type it holds.
The double templating allows for the instantiation of forms with and The double templating allows for the instantiation of forms with or
without storage management. without storage management.
Note Note
The IDLListType parameter should itself be a template but this confused The IDLListType parameter should itself be a template but this confused
gcc 2.95.2 so it has to be instantiated for T when an intantiation of gcc 2.95.2 so it has to be instantiated for T when an instantiation of
DictionaryBase is requested DictionaryBase is requested
See Also See Also
@ -67,7 +67,7 @@ Ostream& operator<<(Ostream&, const DictionaryBase<IDLListType, T>&);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class DictionaryBase Declaration Class DictionaryBase Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class IDLListType, class T> template<class IDLListType, class T>
@ -77,7 +77,7 @@ class DictionaryBase
{ {
// Private data // Private data
//- HashTable of the enries held on the DL-list for quick lookup //- HashTable of the entries held on the IDLListType for quick lookup
HashTable<T*> hashedTs_; HashTable<T*> hashedTs_;
@ -99,10 +99,10 @@ public:
//- Construct from Istream using given Istream constructor class //- Construct from Istream using given Istream constructor class
template<class INew> template<class INew>
DictionaryBase(Istream& is, const INew& inewt); DictionaryBase(Istream&, const INew&);
//- Construct from Istream //- Construct from Istream using default Istream constructor class
DictionaryBase(Istream& is); DictionaryBase(Istream&);
// Member functions // Member functions
@ -110,7 +110,13 @@ public:
// Search and lookup // Search and lookup
//- Search DictionaryBase for given keyword //- Search DictionaryBase for given keyword
bool found(const word& keyword) const; bool found(const word&) const;
//- Find and return an entry if present, otherwise return NULL
const T* lookupPtr(const word&) const;
//- Find and return an entry if present, otherwise return NULL
T* lookupPtr(const word&);
//- Find and return entry //- Find and return entry
const T* lookup(const word&) const; const T* lookup(const word&) const;
@ -125,17 +131,21 @@ public:
// Editing // Editing
//- Add at head of dictionary //- Add at head of dictionary
void insert(const word& keyword, T*); void insert(const word&, T*);
//- Add at tail of dictionary //- Add at tail of dictionary
void append(const word& keyword, T*); void append(const word&, T*);
//- Remove and return entry specified by keyword //- Remove and return entry specified by keyword.
T* remove(const word& keyword); // Return NULL if the keyword was not found.
T* remove(const word&);
//- Clear the dictionary //- Clear the dictionary
void clear(); void clear();
//- Transfer the contents of the argument into this DictionaryBase
// and annull the argument.
void transfer(DictionaryBase<IDLListType, T>&);
// Member operators // Member operators

View File

@ -30,15 +30,13 @@ Description
#include "DictionaryBase.H" #include "DictionaryBase.H"
#include "IOstreams.H" #include "IOstreams.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * * //
template<class IDLListType, class T> template<class IDLListType, class T>
Ostream& operator<<(Ostream& os, const DictionaryBase<IDLListType, T>& dict) Foam::Ostream& Foam::operator<<
(
Ostream& os,
const DictionaryBase<IDLListType, T>& dict)
{ {
for for
( (
@ -53,7 +51,7 @@ Ostream& operator<<(Ostream& os, const DictionaryBase<IDLListType, T>& dict)
if (!os.good()) if (!os.good())
{ {
Info Info
<< "operator<<(Ostream& os, const DictionaryBase&) : " << "operator<<(Ostream&, const DictionaryBase&) : "
<< "Can't write entry for DictionaryBase" << "Can't write entry for DictionaryBase"
<< endl; << endl;
@ -67,6 +65,4 @@ Ostream& operator<<(Ostream& os, const DictionaryBase<IDLListType, T>& dict)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -26,20 +26,15 @@ License
#include "PtrDictionary.H" #include "PtrDictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class T> template<class T>
PtrDictionary<T>::PtrDictionary() Foam::PtrDictionary<T>::PtrDictionary()
{} {}
template<class T> template<class T>
PtrDictionary<T>::PtrDictionary(const PtrDictionary& dict) Foam::PtrDictionary<T>::PtrDictionary(const PtrDictionary& dict)
: :
DictionaryBase<DLPtrList<T>, T>(dict) DictionaryBase<DLPtrList<T>, T>(dict)
{} {}
@ -47,14 +42,14 @@ PtrDictionary<T>::PtrDictionary(const PtrDictionary& dict)
template<class T> template<class T>
template<class INew> template<class INew>
PtrDictionary<T>::PtrDictionary(Istream& is, const INew& iNew) Foam::PtrDictionary<T>::PtrDictionary(Istream& is, const INew& iNew)
: :
DictionaryBase<DLPtrList<T>, T>(is, iNew) DictionaryBase<DLPtrList<T>, T>(is, iNew)
{} {}
template<class T> template<class T>
PtrDictionary<T>::PtrDictionary(Istream& is) Foam::PtrDictionary<T>::PtrDictionary(Istream& is)
: :
DictionaryBase<DLPtrList<T>, T>(is) DictionaryBase<DLPtrList<T>, T>(is)
{} {}
@ -62,6 +57,4 @@ PtrDictionary<T>::PtrDictionary(Istream& is)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -27,8 +27,10 @@ Class
Description Description
Template dictionary class which does not manages the storage Template dictionary class which does not manages the storage
associated with it. It is derived from DictionaryBase instantiated on associated with it.
a non-memory managed form of intrusive doubly-linked list of T.
It is derived from DictionaryBase instantiated on a non-memory managed
form of intrusive doubly-linked list of T.
SourceFiles SourceFiles
PtrDictionary.C PtrDictionary.C
@ -47,7 +49,7 @@ namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class PtrDictionary Declaration Class PtrDictionary Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class T> template<class T>

View File

@ -26,22 +26,15 @@ License
#include "UDictionary.H" #include "UDictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Null constructor
template<class T> template<class T>
UDictionary<T>::UDictionary() Foam::UDictionary<T>::UDictionary()
{} {}
// Copy constructor
template<class T> template<class T>
UDictionary<T>::UDictionary(const UDictionary& dict) Foam::UDictionary<T>::UDictionary(const UDictionary& dict)
: :
DictionaryBase<UIDLList<T>, T>(dict) DictionaryBase<UIDLList<T>, T>(dict)
{} {}
@ -49,6 +42,4 @@ UDictionary<T>::UDictionary(const UDictionary& dict)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -49,7 +49,7 @@ namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class UDictionary Declaration Class UDictionary Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class T> template<class T>

View File

@ -26,22 +26,15 @@ License
#include "UPtrDictionary.H" #include "UPtrDictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Null constructor
template<class T> template<class T>
UPtrDictionary<T>::UPtrDictionary() Foam::UPtrDictionary<T>::UPtrDictionary()
{} {}
// Copy constructor
template<class T> template<class T>
UPtrDictionary<T>::UPtrDictionary(const UPtrDictionary& dict) Foam::UPtrDictionary<T>::UPtrDictionary(const UPtrDictionary& dict)
: :
DictionaryBase<DLList<T*>, T>(dict) DictionaryBase<DLList<T*>, T>(dict)
{} {}
@ -49,6 +42,4 @@ UPtrDictionary<T>::UPtrDictionary(const UPtrDictionary& dict)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -27,8 +27,10 @@ Class
Description Description
Template dictionary class which does not manages the storage Template dictionary class which does not manages the storage
associated with it. It is derived from DictionaryBase instantiated on associated with it.
a non-memory managed form of intrusive doubly-linked list of \<T\>.
It is derived from DictionaryBase instantiated on a non-memory managed
form of intrusive doubly-linked list of \<T\>.
SourceFiles SourceFiles
UPtrDictionary.C UPtrDictionary.C
@ -47,7 +49,7 @@ namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class UPtrDictionary Declaration Class UPtrDictionary Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class T> template<class T>

View File

@ -456,6 +456,14 @@ void HashTable<T, Key, Hash>::clear()
} }
template<class T, class Key, class Hash>
void HashTable<T, Key, Hash>::clearStorage()
{
clear();
resize(0);
}
template<class T, class Key, class Hash> template<class T, class Key, class Hash>
void HashTable<T, Key, Hash>::transfer(HashTable<T, Key, Hash>& ht) void HashTable<T, Key, Hash>::transfer(HashTable<T, Key, Hash>& ht)
{ {

View File

@ -54,6 +54,7 @@ template<class T>
class List; class List;
template<class T, class Key, class Hash> class HashTable; template<class T, class Key, class Hash> class HashTable;
template<class T, class Key, class Hash> class HashPtrTable;
template<class T, class Key, class Hash> Istream& operator>> template<class T, class Key, class Hash> Istream& operator>>
( (
@ -102,7 +103,7 @@ class HashTable
//- Construct given key, next pointer and object //- Construct given key, next pointer and object
inline hashedEntry inline hashedEntry
( (
const Key& key, const Key&,
hashedEntry* next, hashedEntry* next,
const T& newEntry const T& newEntry
); );
@ -127,7 +128,7 @@ class HashTable
// Private Member Functions // Private Member Functions
//- Assign a new hashedEntry to a possibly already existing key //- Assign a new hashedEntry to a possibly already existing key
bool set(const Key& key, const T& newElmt, bool protect); bool set(const Key&, const T& newElmt, bool protect);
public: public:
@ -173,15 +174,15 @@ public:
inline label size() const; inline label size() const;
//- Return true if hashedEntry is found in table //- Return true if hashedEntry is found in table
bool found(const Key& key) const; bool found(const Key&) const;
//- Find and return an iterator set at the hashedEntry //- Find and return an iterator set at the hashedEntry
// If not found iterator = end() // If not found iterator = end()
iterator find(const Key& key); iterator find(const Key&);
//- Find and return an const_iterator set at the hashedEntry //- Find and return an const_iterator set at the hashedEntry
// If not found iterator = end() // If not found iterator = end()
const_iterator find(const Key& key) const; const_iterator find(const Key&) const;
//- Return the table of contents //- Return the table of contents
List<Key> toc() const; List<Key> toc() const;
@ -190,16 +191,16 @@ public:
// Edit // Edit
//- Insert a new hashedEntry //- Insert a new hashedEntry
inline bool insert(const Key& key, const T& newElmt); inline bool insert(const Key&, const T& newElmt);
//- Assign a new hashedEntry, overwriting existing entries //- Assign a new hashedEntry, overwriting existing entries
inline bool set(const Key& key, const T& newElmt); inline bool set(const Key&, const T& newElmt);
//- Erase an hashedEntry specified by given iterator //- Erase an hashedEntry specified by given iterator
bool erase(const iterator& it); bool erase(const iterator&);
//- Erase an hashedEntry specified by given key if in table //- Erase an hashedEntry specified by given key if in table
bool erase(const Key& key); bool erase(const Key&);
//- Resize the hash table for efficiency //- Resize the hash table for efficiency
void resize(const label newSize); void resize(const label newSize);
@ -207,6 +208,10 @@ public:
//- Clear all entries from table //- Clear all entries from table
void clear(); void clear();
//- Clear the table entries and the table itself.
// Equivalent to clear() followed by resize(0)
void clearStorage();
//- Transfer the contents of the argument table into this table //- Transfer the contents of the argument table into this table
// and annull the argument table. // and annull the argument table.
void transfer(HashTable<T, Key, Hash>&); void transfer(HashTable<T, Key, Hash>&);
@ -215,14 +220,14 @@ public:
// Member Operators // Member Operators
//- Find and return an hashedEntry //- Find and return an hashedEntry
inline T& operator[](const Key& key); inline T& operator[](const Key&);
//- Find and return an hashedEntry //- Find and return an hashedEntry
inline const T& operator[](const Key& key) const; inline const T& operator[](const Key&) const;
//- Find and return an hashedEntry and //- Find and return an hashedEntry and
// if it is not present create it null. // if it is not present create it null.
inline T& operator()(const Key& key); inline T& operator()(const Key&);
//- Assignment //- Assignment
void operator=(const HashTable<T, Key, Hash>&); void operator=(const HashTable<T, Key, Hash>&);
@ -290,13 +295,13 @@ public:
// Member operators // Member operators
inline void operator=(const iterator& iter); inline void operator=(const iterator&);
inline bool operator==(const iterator& iter) const; inline bool operator==(const iterator&) const;
inline bool operator!=(const iterator& iter) const; inline bool operator!=(const iterator&) const;
inline bool operator==(const const_iterator& iter) const; inline bool operator==(const const_iterator&) const;
inline bool operator!=(const const_iterator& iter) const; inline bool operator!=(const const_iterator&) const;
inline T& operator*(); inline T& operator*();
inline T& operator()(); inline T& operator()();
@ -352,13 +357,13 @@ public:
// Member operators // Member operators
inline void operator=(const const_iterator& iter); inline void operator=(const const_iterator&);
inline bool operator==(const const_iterator& iter) const; inline bool operator==(const const_iterator&) const;
inline bool operator!=(const const_iterator& iter) const; inline bool operator!=(const const_iterator&) const;
inline bool operator==(const iterator& iter) const; inline bool operator==(const iterator&) const;
inline bool operator!=(const iterator& iter) const; inline bool operator!=(const iterator&) const;
inline const T& operator*(); inline const T& operator*();
inline const T& operator()(); inline const T& operator()();

View File

@ -26,22 +26,17 @@ License
#include "ILList.H" #include "ILList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class LListBase, class T> template<class LListBase, class T>
ILList<LListBase, T>::ILList(const ILList<LListBase, T>& slpl) Foam::ILList<LListBase, T>::ILList(const ILList<LListBase, T>& lst)
: :
UILList<LListBase, T>() UILList<LListBase, T>()
{ {
for for
( (
typename UILList<LListBase, T>::const_iterator iter = slpl.begin(); typename UILList<LListBase, T>::const_iterator iter = lst.begin();
iter != slpl.end(); iter != lst.end();
++iter ++iter
) )
{ {
@ -53,9 +48,9 @@ ILList<LListBase, T>::ILList(const ILList<LListBase, T>& slpl)
#ifndef __INTEL_COMPILER #ifndef __INTEL_COMPILER
template<class LListBase, class T> template<class LListBase, class T>
template<class CloneArg> template<class CloneArg>
ILList<LListBase, T>::ILList Foam::ILList<LListBase, T>::ILList
( (
const ILList<LListBase, T>& slpl, const ILList<LListBase, T>& lst,
const CloneArg& cloneArg const CloneArg& cloneArg
) )
: :
@ -63,8 +58,8 @@ ILList<LListBase, T>::ILList
{ {
for for
( (
typename UILList<LListBase, T>::const_iterator iter = slpl.begin(); typename UILList<LListBase, T>::const_iterator iter = lst.begin();
iter != slpl.end(); iter != lst.end();
++iter ++iter
) )
{ {
@ -77,7 +72,7 @@ ILList<LListBase, T>::ILList
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
template<class LListBase, class T> template<class LListBase, class T>
ILList<LListBase, T>::~ILList() Foam::ILList<LListBase, T>::~ILList()
{ {
this->clear(); this->clear();
} }
@ -85,9 +80,8 @@ ILList<LListBase, T>::~ILList()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
//- Return and remove head
template<class LListBase, class T> template<class LListBase, class T>
bool ILList<LListBase, T>::eraseHead() bool Foam::ILList<LListBase, T>::eraseHead()
{ {
T* tPtr; T* tPtr;
if ((tPtr = this->removeHead())) if ((tPtr = this->removeHead()))
@ -101,9 +95,8 @@ bool ILList<LListBase, T>::eraseHead()
} }
} }
//- Return and remove element
template<class LListBase, class T> template<class LListBase, class T>
bool ILList<LListBase, T>::erase(T* p) bool Foam::ILList<LListBase, T>::erase(T* p)
{ {
T* tPtr; T* tPtr;
if ((tPtr = remove(p))) if ((tPtr = remove(p)))
@ -119,7 +112,7 @@ bool ILList<LListBase, T>::erase(T* p)
template<class LListBase, class T> template<class LListBase, class T>
void ILList<LListBase, T>::clear() void Foam::ILList<LListBase, T>::clear()
{ {
label oldSize = this->size(); label oldSize = this->size();
for (label i=0; i<oldSize; i++) for (label i=0; i<oldSize; i++)
@ -131,17 +124,25 @@ void ILList<LListBase, T>::clear()
} }
template<class LListBase, class T>
void Foam::ILList<LListBase, T>::transfer(ILList<LListBase, T>& lst)
{
clear();
LListBase::transfer(lst);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class LListBase, class T> template<class LListBase, class T>
void ILList<LListBase, T>::operator=(const ILList<LListBase, T>& slpl) void Foam::ILList<LListBase, T>::operator=(const ILList<LListBase, T>& lst)
{ {
this->clear(); this->clear();
for for
( (
typename UILList<LListBase, T>::const_iterator iter = slpl.begin(); typename UILList<LListBase, T>::const_iterator iter = lst.begin();
iter != slpl.end(); iter != lst.end();
++iter ++iter
) )
{ {
@ -149,11 +150,6 @@ void ILList<LListBase, T>::operator=(const ILList<LListBase, T>& slpl)
} }
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
#include "ILListIO.C" #include "ILListIO.C"

View File

@ -71,7 +71,7 @@ class ILList
//- Read from Istream using given Istream constructor class //- Read from Istream using given Istream constructor class
template<class INew> template<class INew>
void read(Istream&, const INew& inewt); void read(Istream&, const INew&);
public: public:
@ -96,7 +96,7 @@ public:
//- Copy constructor with additional argument for clone //- Copy constructor with additional argument for clone
template<class CloneArg> template<class CloneArg>
ILList(const ILList<LListBase, T>& slpl, const CloneArg& cloneArg) ILList(const ILList<LListBase, T>& lst, const CloneArg& cloneArg)
#ifdef __INTEL_COMPILER #ifdef __INTEL_COMPILER
: :
UILList<LListBase, T>() UILList<LListBase, T>()
@ -104,8 +104,8 @@ public:
for for
( (
typename UILList<LListBase, T>::const_iterator iter = typename UILList<LListBase, T>::const_iterator iter =
slpl.begin(); lst.begin();
iter != slpl.end(); iter != lst.end();
++iter ++iter
) )
{ {
@ -118,7 +118,7 @@ public:
//- Construct from Istream using given Istream constructor class //- Construct from Istream using given Istream constructor class
template<class INew> template<class INew>
ILList(Istream&, const INew& inewt); ILList(Istream&, const INew&);
// Destructor // Destructor
@ -139,6 +139,10 @@ public:
//- Clear the contents of the list //- Clear the contents of the list
void clear(); void clear();
//- Transfer the contents of the argument into this List
// and annull the argument list.
void transfer(ILList<LListBase, T>&);
// Member operators // Member operators

View File

@ -30,24 +30,19 @@ Description
#include "Istream.H" #include "Istream.H"
#include "INew.H" #include "INew.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class LListBase, class T> template<class LListBase, class T>
template<class INew> template<class INew>
void ILList<LListBase, T>::read(Istream& is, const INew& inewt) void Foam::ILList<LListBase, T>::read(Istream& is, const INew& iNew)
{ {
is.fatalCheck("operator>>(Istream& is, ILList<LListBase, T>& L)"); is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)");
token firstToken(is); token firstToken(is);
is.fatalCheck is.fatalCheck
( (
"operator>>(Istream& is, ILList<LListBase, T>& L) : reading first token" "operator>>(Istream&, ILList<LListBase, T>&) : reading first token"
); );
if (firstToken.isLabel()) if (firstToken.isLabel())
@ -63,23 +58,23 @@ void ILList<LListBase, T>::read(Istream& is, const INew& inewt)
{ {
for (label i=0; i<s; i++) for (label i=0; i<s; i++)
{ {
append(inewt(is).ptr()); append(iNew(is).ptr());
is.fatalCheck is.fatalCheck
( (
"operator>>(Istream& is, ILList<LListBase, T>& L) : " "operator>>(Istream&, ILList<LListBase, T>&) : "
"reading entry" "reading entry"
); );
} }
} }
else else
{ {
T* tPtr = inewt(is).ptr(); T* tPtr = iNew(is).ptr();
append(tPtr); append(tPtr);
is.fatalCheck is.fatalCheck
( (
"operator>>(Istream& is, ILList<LListBase, T>& L) : " "operator>>(Istream&, ILList<LListBase, T>&) : "
"reading entry" "reading entry"
); );
@ -99,14 +94,14 @@ void ILList<LListBase, T>::read(Istream& is, const INew& inewt)
{ {
FatalIOErrorIn FatalIOErrorIn
( (
"operator>>(Istream& is, ILList<LListBase, T>& L)", "operator>>(Istream&, ILList<LListBase, T>&)",
is is
) << "incorrect first token, '(', found " << firstToken.info() ) << "incorrect first token, '(', found " << firstToken.info()
<< exit(FatalIOError); << exit(FatalIOError);
} }
token lastToken(is); token lastToken(is);
is.fatalCheck("operator>>(Istream& is, ILList<LListBase, T>& L)"); is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)");
while while
( (
@ -117,36 +112,34 @@ void ILList<LListBase, T>::read(Istream& is, const INew& inewt)
) )
{ {
is.putBack(lastToken); is.putBack(lastToken);
append(inewt(is).ptr()); append(iNew(is).ptr());
is >> lastToken; is >> lastToken;
is.fatalCheck("operator>>(Istream& is, ILList<LListBase, T>& L)"); is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)");
} }
} }
else else
{ {
FatalIOErrorIn("operator>>(Istream& is, ILList<LListBase, T>& L)", is) FatalIOErrorIn("operator>>(Istream&, ILList<LListBase, T>&)", is)
<< "incorrect first token, expected <int> or '(', found " << "incorrect first token, expected <int> or '(', found "
<< firstToken.info() << firstToken.info()
<< exit(FatalIOError); << exit(FatalIOError);
} }
is.fatalCheck("operator>>(Istream& is, ILList<LListBase, T>& L)"); is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)");
} }
//- Construct from Istream using given Istream constructor class
template<class LListBase, class T> template<class LListBase, class T>
template<class INew> template<class INew>
ILList<LListBase, T>::ILList(Istream& is, const INew& inewt) Foam::ILList<LListBase, T>::ILList(Istream& is, const INew& iNew)
{ {
read(is, inewt); read(is, iNew);
} }
// Construct from Istream
template<class LListBase, class T> template<class LListBase, class T>
ILList<LListBase, T>::ILList(Istream& is) Foam::ILList<LListBase, T>::ILList(Istream& is)
{ {
read(is, INew<T>()); read(is, INew<T>());
} }
@ -155,7 +148,7 @@ ILList<LListBase, T>::ILList(Istream& is)
// * * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * //
template<class LListBase, class T> template<class LListBase, class T>
Istream& operator>>(Istream& is, ILList<LListBase, T>& L) Foam::Istream& Foam::operator>>(Istream& is, ILList<LListBase, T>& L)
{ {
L.clear(); L.clear();
L.read(is, INew<T>()); L.read(is, INew<T>());
@ -166,6 +159,4 @@ Istream& operator>>(Istream& is, ILList<LListBase, T>& L)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -27,22 +27,16 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "error.H" #include "error.H"
#include "LList.H" #include "LList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class LListBase, class T> template<class LListBase, class T>
LList<LListBase, T>::LList(const LList<LListBase, T>& slpl) Foam::LList<LListBase, T>::LList(const LList<LListBase, T>& lst)
: :
LListBase() LListBase()
{ {
for (const_iterator iter = slpl.begin(); iter != slpl.end(); ++iter) for (const_iterator iter = lst.begin(); iter != lst.end(); ++iter)
{ {
append(iter()); append(iter());
} }
@ -50,7 +44,7 @@ LList<LListBase, T>::LList(const LList<LListBase, T>& slpl)
template<class LListBase, class T> template<class LListBase, class T>
LList<LListBase, T>::~LList() Foam::LList<LListBase, T>::~LList()
{ {
this->clear(); this->clear();
} }
@ -59,7 +53,7 @@ LList<LListBase, T>::~LList()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class LListBase, class T> template<class LListBase, class T>
void LList<LListBase, T>::clear() void Foam::LList<LListBase, T>::clear()
{ {
label oldSize = this->size(); label oldSize = this->size();
for (label i=0; i<oldSize; i++) for (label i=0; i<oldSize; i++)
@ -71,24 +65,28 @@ void LList<LListBase, T>::clear()
} }
template<class LListBase, class T>
void Foam::LList<LListBase, T>::transfer(LList<LListBase, T>& lst)
{
clear();
LListBase::transfer(lst);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class LListBase, class T> template<class LListBase, class T>
void LList<LListBase, T>::operator=(const LList<LListBase, T>& slpl) void Foam::LList<LListBase, T>::operator=(const LList<LListBase, T>& lst)
{ {
this->clear(); this->clear();
for (const_iterator iter = slpl.begin(); iter != slpl.end(); ++iter) for (const_iterator iter = lst.begin(); iter != lst.end(); ++iter)
{ {
append(iter()); append(iter());
} }
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
#include "LListIO.C" #include "LListIO.C"

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