Merge branch 'master' into splitCyclic

Conflicts:
	applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C
	applications/utilities/parallelProcessing/decomposePar/domainDecomposition.H
	applications/utilities/parallelProcessing/decomposePar/domainDecompositionMesh.C
	src/OpenFOAM/algorithms/MeshWave/FaceCellWave.C
	src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/cyclicLduInterfaceField/cyclicLduInterfaceField.C
	src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C
	src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.H
	src/OpenFOAM/meshes/polyMesh/syncTools/dummyTransform.H
	src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.C
	src/edgeMesh/edgeFormats/vtk/VTKedgeFormat.H
	src/mesh/blockMesh/curvedEdges/spline.H
	src/meshTools/PointEdgeWave/PointEdgeWave.C
	src/meshTools/sets/topoSets/faceSet.C
This commit is contained in:
mattijs
2010-01-26 17:11:18 +00:00
1391 changed files with 507189 additions and 62865 deletions

2
.gitignore vendored
View File

@ -51,7 +51,9 @@ doc/[Dd]oxygen/latex
doc/[Dd]oxygen/man doc/[Dd]oxygen/man
# generated files in the main directory (e.g. ReleaseNotes-?.?.html) # generated files in the main directory (e.g. ReleaseNotes-?.?.html)
# and in the doc directory
/*.html /*.html
/doc/*.html
# source packages - anywhere # source packages - anywhere
*.tar.bz2 *.tar.bz2

11
README
View File

@ -2,7 +2,7 @@
# #
#+TITLE: OpenFOAM README for version 1.6 #+TITLE: OpenFOAM README for version 1.6
#+AUTHOR: OpenCFD Ltd. #+AUTHOR: OpenCFD Ltd.
#+DATE: July 2009 #+DATE: November 2009
#+LINK: http://www.opencfd.co.uk #+LINK: http://www.opencfd.co.uk
#+OPTIONS: author:nil ^:{} #+OPTIONS: author:nil ^:{}
@ -168,9 +168,9 @@
+ rm -rf paraview-3.6.1/platforms + rm -rf paraview-3.6.1/platforms
+ ./makeParaView + ./makeParaView
The PV3FoamReader module is an OpenFOAM utility that can be compiled in the The PV3blockMeshReader and the PV3FoamReader ParaView plugins are compiled
usual manner as follows: as usual for OpenFOAM utilities:
+ cd $FOAM_UTILITIES/postProcessing/graphics/PV3FoamReader + cd $FOAM_UTILITIES/postProcessing/graphics/PV3Readers/
+ ./Allwclean + ./Allwclean
+ ./Allwmake + ./Allwmake
@ -187,7 +187,8 @@
newly built qmake as an argument: newly built qmake as an argument:
+ ./makeParaView -qmake <path_to_qmake> + ./makeParaView -qmake <path_to_qmake>
The user must then recompile the PV3FoamReader module as normal (see above). The user must then recompile the PV3blockMeshReader and the
PV3FoamReader plugins as usual (see above).
* Documentation * Documentation
http://www.OpenFOAM.org/doc http://www.OpenFOAM.org/doc

View File

@ -38,11 +38,9 @@ Description
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::addBoolOption("writep", "write the final pressure field");
argList::validOptions.insert("writep", "");
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"
# include "createMesh.H" # include "createMesh.H"
# include "createFields.H" # include "createFields.H"

View File

@ -124,11 +124,6 @@ public:
// Member Functions // Member Functions
tmp<volScalarField> mut() const
{
return mut_;
}
//- Return the effective diffusivity for k //- Return the effective diffusivity for k
tmp<volScalarField> DkEff() const tmp<volScalarField> DkEff() const
{ {
@ -147,41 +142,44 @@ public:
); );
} }
//- Return the effective turbulent thermal diffusivity //- Return the turbulence viscosity
tmp<volScalarField> alphaEff() const virtual tmp<volScalarField> mut() const
{ {
return tmp<volScalarField> return mut_;
( }
new volScalarField("alphaEff", alphat_ + alpha())
); //- Return the turbulence thermal diffusivity
virtual tmp<volScalarField> alphat() const
{
return alphat_;
} }
//- Return the turbulence kinetic energy //- Return the turbulence kinetic energy
tmp<volScalarField> k() const virtual tmp<volScalarField> k() const
{ {
return k_; return k_;
} }
//- Return the turbulence kinetic energy dissipation rate //- Return the turbulence kinetic energy dissipation rate
tmp<volScalarField> epsilon() const virtual tmp<volScalarField> epsilon() const
{ {
return epsilon_; return epsilon_;
} }
//- Return the Reynolds stress tensor //- Return the Reynolds stress tensor
tmp<volSymmTensorField> R() const; virtual tmp<volSymmTensorField> R() const;
//- Return the effective stress tensor including the laminar stress //- Return the effective stress tensor including the laminar stress
tmp<volSymmTensorField> devRhoReff() const; virtual tmp<volSymmTensorField> devRhoReff() const;
//- Return the source term for the momentum equation //- Return the source term for the momentum equation
tmp<fvVectorMatrix> divDevRhoReff(volVectorField& U) const; virtual tmp<fvVectorMatrix> divDevRhoReff(volVectorField& U) const;
//- Solve the turbulence equations and correct the turbulence viscosity //- Solve the turbulence equations and correct the turbulence viscosity
void correct(); virtual void correct();
//- Read turbulenceProperties dictionary //- Read turbulenceProperties dictionary
bool read(); virtual bool read();
}; };

View File

@ -22,8 +22,6 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation, along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "maxwellSlipUFvPatchVectorField.H" #include "maxwellSlipUFvPatchVectorField.H"

View File

@ -22,8 +22,6 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation, along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "mixedFixedValueSlipFvPatchFields.H" #include "mixedFixedValueSlipFvPatchFields.H"

View File

@ -47,8 +47,10 @@
) )
); );
word kinematicCloudName("kinematicCloud"); const word kinematicCloudName
args.optionReadIfPresent("cloudName", kinematicCloudName); (
args.optionLookupOrDefault<word>("cloudName", "kinematicCloud")
);
Info<< "Constructing kinematicCloud " << kinematicCloudName << endl; Info<< "Constructing kinematicCloud " << kinematicCloudName << endl;
basicKinematicCloud kinematicCloud basicKinematicCloud kinematicCloud

View File

@ -42,7 +42,7 @@ Description
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::validOptions.insert("cloudName", "cloud name"); argList::addOption("cloudName", "cloud name");
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"

View File

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

View File

@ -1,69 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.6 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
(
// Upper body longitudinal splines.
(
(-0.22685 -0.01125166 0) // 7
(-0.21685 -0.01340204 0)
(-0.20685 -0.01529684 0)
(-0.19685 -0.01694748 0)
(-0.18685 -0.01836538 0)
(-0.17685 -0.01956197 0)
(-0.16685 -0.02054868 0)
(-0.15685 -0.02133693 0)
(-0.14685 -0.02193816 0)
(-0.13685 -0.02236377 0)
(-0.12685 -0.02262521 0)
(-0.11685 -0.02273389 0) // 2
)
(
(-0.22685 0 0.01125166) // 8
(-0.21685 0 0.01340204)
(-0.20685 0 0.01529684)
(-0.19685 0 0.01694748)
(-0.18685 0 0.01836538)
(-0.17685 0 0.01956197)
(-0.16685 0 0.02054868)
(-0.15685 0 0.02133693)
(-0.14685 0 0.02193816)
(-0.13685 0 0.02236377)
(-0.12685 0 0.02262521)
(-0.11685 0 0.02273389) // 3
)
(
(-0.22685 0.01125166 0) // 9
(-0.21685 0.01340204 0)
(-0.20685 0.01529684 0)
(-0.19685 0.01694748 0)
(-0.18685 0.01836538 0)
(-0.17685 0.01956197 0)
(-0.16685 0.02054868 0)
(-0.15685 0.02133693 0)
(-0.14685 0.02193816 0)
(-0.13685 0.02236377 0)
(-0.12685 0.02262521 0)
(-0.11685 0.02273389 0) // 4
)
(
(-0.22685 0 -0.01125166) // 6
(-0.21685 0 -0.01340204)
(-0.20685 0 -0.01529684)
(-0.19685 0 -0.01694748)
(-0.18685 0 -0.01836538)
(-0.17685 0 -0.01956197)
(-0.16685 0 -0.02054868)
(-0.15685 0 -0.02133693)
(-0.14685 0 -0.02193816)
(-0.13685 0 -0.02236377)
(-0.12685 0 -0.02262521)
(-0.11685 0 -0.02273389) // 1
)
);

View File

@ -92,6 +92,8 @@ int main(int argc, char *argv[])
labelHashSet setD(1); labelHashSet setD(1);
setD.insert(11); setD.insert(11);
setD.insert(100); setD.insert(100);
setD.insert(49);
setD.insert(36);
setD.insert(2008); setD.insert(2008);
Info<< "setD : " << setD << endl; Info<< "setD : " << setD << endl;
@ -138,6 +140,17 @@ int main(int argc, char *argv[])
// this doesn't work (yet?) // this doesn't work (yet?)
// setD[12] = true; // setD[12] = true;
List<label> someLst(10);
forAll(someLst, elemI)
{
someLst[elemI] = elemI*elemI;
}
label added = setD.set(someLst);
Info<< "added " << added << " from " << someLst.size() << endl;
Info<< "setD : " << setD << endl;
return 0; return 0;
} }

View File

@ -47,11 +47,11 @@ using namespace Foam;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::noParallel(); argList::noParallel();
argList::validOptions.insert("reList", "reList"); argList::addOption("reList", "reList");
argList::validOptions.insert("wordList", "wordList"); argList::addOption("wordList", "wordList");
argList::validOptions.insert("stringList", "stringList"); argList::addOption("stringList", "stringList");
argList::validOptions.insert("float", "xx"); argList::addOption("float", "xx");
argList::validOptions.insert("flag", ""); argList::addBoolOption("flag");
# include "setRootCase.H" # include "setRootCase.H"

View File

@ -82,9 +82,13 @@ int main(int argc, char *argv[])
argList::noParallel(); argList::noParallel();
argList::validArgs.insert("file .. fileN"); argList::validArgs.insert("file .. fileN");
argList::validOptions.insert("mask", ""); argList::addBoolOption("mask", "report information about the bit masks");
argList::validOptions.insert("count", ""); argList::addBoolOption("count", "test the count() method");
argList::validOptions.insert("info", ""); argList::addBoolOption
(
"info",
"print an ascii representation of the storage"
);
argList args(argc, argv, false, true); argList args(argc, argv, false, true);

View File

@ -58,9 +58,15 @@ int main(int argc, char *argv[])
list1.print(Info); list1.print(Info);
Info<< "\ntest set() with default argument (max_value)\n"; Info<< "\ntest set() with default argument (max_value)\n";
list1.set(1);
list1.set(3); list1.set(3);
list1.print(Info); list1.print(Info);
Info<< "\ntest unset() with in-range and out-of-range\n";
list1.unset(3);
list1.unset(100000);
list1.print(Info);
Info<< "\ntest assign between references\n"; Info<< "\ntest assign between references\n";
list1[2] = 3; list1[2] = 3;
list1[4] = list1[2]; list1[4] = list1[2];

View File

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

View File

@ -22,43 +22,51 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation, along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/ Application
#include "argList.H"
#include "vector.H" Description
#include "IFstream.H"
#include "BSpline.H" \*---------------------------------------------------------------------------*/
#include "argList.H"
#include "boolList.H"
#include "HashSet.H"
#include "StaticHashTable.H"
#include "cpuTime.H"
#include <vector>
#include "PackedList.H"
#include "PackedBoolList.H"
using namespace Foam; using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program: // Main program:
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::noParallel(); const label n = 100000000;
argList::validArgs.insert("file .. fileN"); const label nReport = 1000000;
argList args(argc, argv, false, true); cpuTime timer;
forAll(args.additionalArgs(), argI) // test inserts
// PackedBoolList
PackedBoolList packed;
for (label i = 0; i < n; i++)
{ {
const string& srcFile = args.additionalArgs()[argI]; if ((i % nReport) == 0 && i)
Info<< nl << "reading " << srcFile << nl;
IFstream ifs(srcFile);
List<pointField> splinePointFields(ifs);
forAll(splinePointFields, splineI)
{ {
Info<<"convert " << splinePointFields[splineI] << " to bspline" << endl; Info<< "i:" << i << " in " << timer.cpuTimeIncrement() << " s"
<<endl;
BSpline spl(splinePointFields[splineI], vector::zero, vector::zero);
Info<< "1/2 = " << spl.position(0.5) << endl;
} }
packed[i] = 1;
} }
Info<< "insert test: " << n << " elements in "
<< timer.cpuTimeIncrement() << " s\n\n";
Info << "\nEnd\n" << endl;
return 0; return 0;
} }

View File

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

View File

@ -0,0 +1,3 @@
EXE_INC = \
EXE_LIBS = \

View File

@ -0,0 +1,128 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2009 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
PolynomialTest
Description
Test application for the templated Polynomial class
\*---------------------------------------------------------------------------*/
#include "IFstream.H"
#include "Polynomial.H"
#include "Random.H"
using namespace Foam;
scalar polyValue(const scalar x)
{
// Hard-coded polynomial 8 coeff (7th order)
return
0.11
+ 0.45*x
- 0.94*sqr(x)
+ 1.58*pow3(x)
- 2.58*pow4(x)
+ 0.08*pow5(x)
+ 3.15*pow6(x)
- 4.78*x*pow6(x);
}
scalar intPolyValue(const scalar x)
{
// Hard-coded integrated form of above polynomial
return
0.11*x
+ 0.45/2.0*sqr(x)
- 0.94/3.0*pow3(x)
+ 1.58/4.0*pow4(x)
- 2.58/5.0*pow5(x)
+ 0.08/6.0*pow6(x)
+ 3.15/7.0*x*pow6(x)
- 4.78/8.0*x*x*pow6(x);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
IFstream is("polyTestInput");
Polynomial<8> poly("testPoly", is);
Polynomial<9> intPoly(poly.integrate(0.0));
Info<< "poly = " << poly << endl;
Info<< "intPoly = " << intPoly << nl << endl;
Info<< "2*poly = " << 2*poly << endl;
Info<< "poly+poly = " << poly + poly << nl << endl;
Info<< "3*poly = " << 3*poly << endl;
Info<< "poly+poly+poly = " << poly + poly + poly << nl << endl;
Info<< "3*poly - 2*poly = " << 3*poly - 2*poly << nl << endl;
Polynomial<8> polyCopy = poly;
Info<< "poly, polyCopy = " << poly << ", " << polyCopy << nl << endl;
polyCopy = 2.5*poly;
Info<< "2.5*polyCopy = " << polyCopy << nl << endl;
Random rnd(123456);
for (int i=0; i<10; i++)
{
scalar x = rnd.scalar01()*100;
scalar px = polyValue(x);
scalar ipx = intPolyValue(x);
scalar pxTest = poly.evaluate(x);
scalar ipxTest = intPoly.evaluate(x);
Info<<"\nx = " << x << endl;
Info<< " px, pxTest = " << px << ", " << pxTest << endl;
Info<< " ipx, ipxTest = " << ipx << ", " << ipxTest << endl;
if (mag(px - pxTest) > SMALL)
{
Info<< " *** WARNING: px != pxTest: " << px - pxTest << endl;
}
if (mag(ipx - ipxTest) > SMALL)
{
Info<< " *** WARNING: ipx != ipxTest: " << ipx - ipxTest << endl;
}
Info<< endl;
}
Info<< nl << "Done." << endl;
return 0;
}
// ************************************************************************* //

View File

@ -0,0 +1,11 @@
testPoly
(
0.11
0.45
-0.94
1.58
-2.58
0.08
3.15
-4.78
)

View File

@ -0,0 +1,15 @@
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
# this will have to do until we have a makefile rule
if type Coco > /dev/null 2>&1
then
Coco \
-frames $WM_THIRD_PARTY_DIR/coco-r \
calcEntry/calcEntry.atg
else
echo "Coco not installed"
fi
wmake

View File

@ -1,4 +1,7 @@
calcEntry/calcEntry.C
dictionaryTest.C dictionaryTest.C
calcEntry/calcEntry.C
calcEntry/calcEntryParser.cpp
calcEntry/calcEntryScanner.cpp
EXE = $(FOAM_USER_APPBIN)/dictionaryTest EXE = $(FOAM_USER_APPBIN)/dictionaryTest

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -26,10 +26,12 @@ License
#include "calcEntry.H" #include "calcEntry.H"
#include "dictionary.H" #include "dictionary.H"
#include "IStringStream.H"
#include "OStringStream.H"
#include "addToMemberFunctionSelectionTable.H" #include "addToMemberFunctionSelectionTable.H"
#include "ISstream.H"
#include "CocoParserErrors.H"
#include "calcEntryParser.h"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
@ -59,11 +61,30 @@ bool Foam::functionEntries::calcEntry::execute
Istream& is Istream& is
) )
{ {
dictionary args(parentDict, is); std::istream& iss = dynamicCast<ISstream>(is).stdStream();
OStringStream resultStream;
resultStream // define parser error handler
<< (args.lookup("x")[0].number() + args.lookup("y")[0].number()); CocoParserErrors<calcEntryInternal::Errors>
entry.read(parentDict, IStringStream(resultStream.str())()); myErrorHandler("calcEntryInternal::Parser");
calcEntryInternal::Scanner scanner(iss);
calcEntryInternal::Parser parser(&scanner, &myErrorHandler);
// Attach dictionary context
parser.dict(parentDict);
// Attach scalar functions
// parser.functions(parentDict);
parser.Parse();
// make a small input list to contain the answer
tokenList tokens(2);
tokens[0] = parser.Result();
tokens[1] = token::END_STATEMENT;
entry.read(parentDict, ITstream("ParserResult", tokens)());
return true; return true;
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -26,6 +26,8 @@ Class
Foam::functionEntries::calcEntry Foam::functionEntries::calcEntry
Description Description
This dictionary function entry may or may not do anything particularly
useful - depending upon what is currently being used to test.
SourceFiles SourceFiles
calcEntry.C calcEntry.C

View File

@ -0,0 +1,252 @@
/*-------------------------------------------------------------------------
compile with:
Coco \
-frames $WM_THIRD_PARTY_DIR/coco-r \
calcEntry.atg
-------------------------------------------------------------------------*/
#include "dictionary.H"
#include "scalar.H"
#include "error.H"
#include "wchar.H"
COMPILER calcEntry
$prefix=calcEntry
$namespace=Foam::functionEntries::calcEntryInternal
$eof=true // grammar handles eof itself
// Simple four function calculator for OpenFOAM dictionaries
//! with debug
static const int debug = 0;
//! The parent dictionary
mutable dictionary* dict_;
//! Track that parent dictionary was set
bool hasDict_;
//! The calculation result
scalar val;
//! token -> scalar
scalar getScalar() const
{
return coco_string_toDouble(t->val);
}
//! token -> string
std::string getString() const
{
char* str = coco_string_create_char(t->val);
std::string s(str);
coco_string_delete(str);
return s;
}
//! attach a dictionary
void dict(const dictionary& dict)
{
dict_ = const_cast<dictionary*>(&dict);
hasDict_ = true;
}
//! lookup dictionary entry
scalar getDictLookup() const
{
scalar dictValue = 0;
if (!hasDict_)
{
FatalErrorIn
(
"calcEntry::getDictEntry() const"
) << "No dictionary attached!"
<< exit(FatalError);
return 0;
}
char* chars = coco_string_create_char
(
t->val,
1,
(coco_string_length(t->val) - 1)
);
word keyword(chars);
coco_string_delete(chars);
if (debug)
{
Info<<"lookup: " << keyword << nl;
}
entry* entryPtr = dict_->lookupEntryPtr(keyword, true, false);
if (entryPtr && !entryPtr->isDict())
{
if (entryPtr->stream().size() != 1)
{
FatalErrorIn
(
"calcEntry::getDictEntry() const"
) << "keyword " << keyword << " has "
<< entryPtr->stream().size() << " values in dictionary "
<< exit(FatalError);
}
entryPtr->stream() >> dictValue;
}
else
{
FatalErrorIn
(
"calcEntry::getDictEntry() const"
) << "keyword " << keyword << " is undefined in dictionary "
<< exit(FatalError);
}
return dictValue;
}
scalar Result() const
{
return val;
}
/*---------------------------------------------------------------------------*/
CHARACTERS
letter = 'A'..'Z' + 'a'..'z'.
qualifier = '_' + ':'.
dollar = '$'.
digit = "0123456789".
sign = '+' + '-'.
cr = '\r'.
lf = '\n'.
tab = '\t'.
stringCh = ANY - '"' - '\\' - cr - lf.
printable = '\u0020' .. '\u007e'.
// * * * * * * * * * * * * * * * * TOKENS * * * * * * * * * * * * * * * * * //
TOKENS
// identifier
ident =
letter { letter | digit | qualifier }.
// string
string =
'"' { stringCh | '\\' printable } '"'.
// dictionary lookup identifier
// starts with '$' and otherwise limited to a normal indentifier
variable =
dollar letter { letter | digit | qualifier }.
// floating point and integer numbers
number =
[sign] ('.' digit { digit } ) | ( digit { digit } [ '.' { digit } ])
[ ('E' | 'e') [sign] digit { digit } ].
// * * * * * * * * * * * PRAGMAS / COMMENTS / IGNORE * * * * * * * * * * * //
COMMENTS FROM "/*" TO "*/" NESTED
COMMENTS FROM "//" TO lf
IGNORE cr + lf + tab
// * * * * * * * * * * * * * * * PRODUCTIONS * * * * * * * * * * * * * * * //
PRODUCTIONS
calcEntry (. val = 0;
if (debug){Info<<"start val pos:"<< t->pos << nl;}
.)
=
'{' Expr<val> '}' (.
if (debug){
Info<<"end {} at pos:"<< t->pos
<<" val:"<< t->val
<<" len:"<< coco_string_length(t->val)
<<" la pos:"<< la->pos << nl;
}
// reposition to immediately after the closing '}'
scanner->buffer->SetPos
(
t->pos + coco_string_length(t->val)
);
.)
| ( Expr<val> EOF )
.
/*---------------------------------------------------------------------------*/
Expr<scalar& val> (. scalar val2 = 0;
if (debug) {Info<<"Expr:"<< val<< " pos:"<< t->pos << nl;}
.)
=
Term<val>
{
"+" Term<val2> (. if (debug) {Info<<"+Term:"<<val2 << " pos:"<< t->pos << nl;}
val += val2;
if (debug) {Info<<"="<< val<< " pos:"<< t->pos << nl;}
.)
| "-" Term<val2> (. if (debug) {Info<<"-Term:"<<val2<< " pos:"<< t->pos << nl;}
val -= val2;
if (debug) {Info<<"="<< val<< " pos:"<< t->pos << nl;}
.)
}
.
/*---------------------------------------------------------------------------*/
Term<scalar& val> (. scalar val2 = 0;
if (debug) {Info<<"Term:"<< val<< " pos:"<< t->pos << nl;}
.)
=
Factor<val>
{
"*" Factor<val2> (. if (debug) {Info<<"*Factor:"<<val2<< " pos:"<< t->pos << nl;}
val *= val2;
if (debug) {Info<<"="<< val<< " pos:"<< t->pos << nl;}
.)
| "/" Factor<val2> (. if (debug) {Info<<"/Factor:"<<val2<< " pos:"<< t->pos << nl;}
val /= val2;
if (debug) {Info<<"="<< val<< " pos:"<< t->pos << nl;}
.)
}
.
/*---------------------------------------------------------------------------*/
Factor<scalar& val>
=
variable (. val = getDictLookup();
if (debug) {Info<<"lookup:"<<val<< " pos:"<< t->pos << nl;}
.)
| number (. val = getScalar();
if (debug) {Info<<"got num:"<<val<< " pos:"<< t->pos << nl;}
.)
| '-' '(' Expr<val> ')' (. val = -val;
if (debug) {Info<<"inv:"<<val<< " pos:"<< t->pos << nl;}
.)
| '(' Expr<val> ')' (. if (debug){Info<<"got Expr:"<<val<< " pos:"<< t->pos << nl;}
.)
.
/*---------------------------------------------------------------------------*/
END calcEntry.
// ************************************************************************* //

View File

@ -0,0 +1,339 @@
#include <wchar.h>
#include "calcEntryParser.h"
namespace Foam {
namespace functionEntries {
namespace calcEntryInternal {
// ----------------------------------------------------------------------------
// Parser Implementation
// ----------------------------------------------------------------------------
void Parser::SynErr(int n) {
if (errDist >= minErrDist) errors->SynErr(la->line, la->col, n);
errDist = 0;
}
void Parser::SemErr(const wchar_t* msg) {
if (errDist >= minErrDist) errors->Error(t->line, t->col, msg);
errDist = 0;
}
void Parser::Get() {
for (;;) {
t = la;
la = scanner->Scan();
if (la->kind <= maxT) {
++errDist;
break;
}
if (dummyToken != t) {
dummyToken->kind = t->kind;
dummyToken->pos = t->pos;
dummyToken->col = t->col;
dummyToken->line = t->line;
dummyToken->next = NULL;
coco_string_delete(dummyToken->val);
dummyToken->val = coco_string_create(t->val);
t = dummyToken;
}
la = t;
}
}
void Parser::Expect(int n) {
if (la->kind == n) {
Get();
}
else {
SynErr(n);
}
}
void Parser::ExpectWeak(int n, int follow) {
if (la->kind == n) {
Get();
}
else {
SynErr(n);
while (!StartOf(follow)) {
Get();
}
}
}
bool Parser::WeakSeparator(int n, int syFol, int repFol) {
if (la->kind == n) {
Get();
return true;
}
else if (StartOf(repFol)) {
return false;
}
else {
SynErr(n);
while (!(StartOf(syFol) || StartOf(repFol) || StartOf(0))) {
Get();
}
return StartOf(syFol);
}
}
void Parser::calcEntry() {
val = 0;
if (debug){Info<<"start val pos:"<< t->pos << nl;}
if (la->kind == 5) {
Get();
Expr(val);
Expect(6);
if (debug){
Info<<"end {} at pos:"<< t->pos
<<" val:"<< t->val
<<" len:"<< coco_string_length(t->val)
<<" la pos:"<< la->pos << nl;
}
// reposition to immediately after the closing '}'
scanner->buffer->SetPos
(
t->pos + coco_string_length(t->val)
);
} else if (StartOf(1)) {
Expr(val);
Expect(0);
} else SynErr(14);
}
void Parser::Expr(scalar& val) {
scalar val2 = 0;
if (debug) {Info<<"Expr:"<< val<< " pos:"<< t->pos << nl;}
Term(val);
while (la->kind == 7 || la->kind == 8) {
if (la->kind == 7) {
Get();
Term(val2);
if (debug) {Info<<"+Term:"<<val2 << " pos:"<< t->pos << nl;}
val += val2;
if (debug) {Info<<"="<< val<< " pos:"<< t->pos << nl;}
} else {
Get();
Term(val2);
if (debug) {Info<<"-Term:"<<val2<< " pos:"<< t->pos << nl;}
val -= val2;
if (debug) {Info<<"="<< val<< " pos:"<< t->pos << nl;}
}
}
}
void Parser::Term(scalar& val) {
scalar val2 = 0;
if (debug) {Info<<"Term:"<< val<< " pos:"<< t->pos << nl;}
Factor(val);
while (la->kind == 9 || la->kind == 10) {
if (la->kind == 9) {
Get();
Factor(val2);
if (debug) {Info<<"*Factor:"<<val2<< " pos:"<< t->pos << nl;}
val *= val2;
if (debug) {Info<<"="<< val<< " pos:"<< t->pos << nl;}
} else {
Get();
Factor(val2);
if (debug) {Info<<"/Factor:"<<val2<< " pos:"<< t->pos << nl;}
val /= val2;
if (debug) {Info<<"="<< val<< " pos:"<< t->pos << nl;}
}
}
}
void Parser::Factor(scalar& val) {
if (la->kind == 3) {
Get();
val = getDictLookup();
if (debug) {Info<<"lookup:"<<val<< " pos:"<< t->pos << nl;}
} else if (la->kind == 4) {
Get();
val = getScalar();
if (debug) {Info<<"got num:"<<val<< " pos:"<< t->pos << nl;}
} else if (la->kind == 8) {
Get();
Expect(11);
Expr(val);
Expect(12);
val = -val;
if (debug) {Info<<"inv:"<<val<< " pos:"<< t->pos << nl;}
} else if (la->kind == 11) {
Get();
Expr(val);
Expect(12);
if (debug){Info<<"got Expr:"<<val<< " pos:"<< t->pos << nl;}
} else SynErr(15);
}
void Parser::Parse() {
t = NULL;
if (dummyToken) { // safety: someone might call Parse() twice
delete dummyToken;
}
la = dummyToken = new Token();
la->val = coco_string_create(L"Dummy Token");
Get();
calcEntry();
// let grammar deal with end-of-file expectations
}
Parser::Parser(Scanner* scan, Errors* err)
:
dummyToken(NULL),
deleteErrorsDestruct_(!err),
errDist(minErrDist),
scanner(scan),
errors(err),
t(NULL),
la(NULL)
{
if (!errors) { // add in default error handling
errors = new Errors();
}
}
bool Parser::StartOf(int s) {
const bool T = true;
const bool x = false;
static bool set[2][15] = {
{T,x,x,x, x,x,x,x, x,x,x,x, x,x,x},
{x,x,x,T, T,x,x,x, T,x,x,T, x,x,x}
};
return set[s][la->kind];
}
Parser::~Parser() {
if (deleteErrorsDestruct_) { // delete default error handling
delete errors;
}
delete dummyToken;
}
// ----------------------------------------------------------------------------
// Errors Implementation
// ----------------------------------------------------------------------------
Errors::Errors()
:
count(0)
{}
Errors::~Errors()
{}
void Errors::clear() {
count = 0;
}
wchar_t* Errors::strerror(int n)
{
wchar_t* s;
switch (n) {
case 0: s = coco_string_create(L"EOF expected"); break;
case 1: s = coco_string_create(L"ident expected"); break;
case 2: s = coco_string_create(L"string expected"); break;
case 3: s = coco_string_create(L"variable expected"); break;
case 4: s = coco_string_create(L"number expected"); break;
case 5: s = coco_string_create(L"\"{\" expected"); break;
case 6: s = coco_string_create(L"\"}\" expected"); break;
case 7: s = coco_string_create(L"\"+\" expected"); break;
case 8: s = coco_string_create(L"\"-\" expected"); break;
case 9: s = coco_string_create(L"\"*\" expected"); break;
case 10: s = coco_string_create(L"\"/\" expected"); break;
case 11: s = coco_string_create(L"\"(\" expected"); break;
case 12: s = coco_string_create(L"\")\" expected"); break;
case 13: s = coco_string_create(L"??? expected"); break;
case 14: s = coco_string_create(L"invalid calcEntry"); break;
case 15: s = coco_string_create(L"invalid Factor"); break;
default:
{
wchar_t format[20];
coco_swprintf(format, 20, L"error %d", n);
s = coco_string_create(format);
}
break;
}
return s;
}
void Errors::Warning(const wchar_t* msg) {
wprintf(L"%ls\n", msg);
}
void Errors::Warning(int line, int col, const wchar_t* msg) {
wprintf(L"-- line %d col %d: %ls\n", line, col, msg);
}
void Errors::Error(int line, int col, const wchar_t* msg) {
wprintf(L"-- line %d col %d: %ls\n", line, col, msg);
count++;
}
void Errors::SynErr(int line, int col, int n) {
wchar_t* msg = this->strerror(n);
this->Error(line, col, msg);
coco_string_delete(msg);
}
void Errors::Exception(const wchar_t* msg) {
wprintf(L"%ls", msg);
::exit(1);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // namespace
} // namespace
} // namespace
// ************************************************************************* //

View File

@ -0,0 +1,206 @@
#ifndef COCO_calcEntryPARSER_H__
#define COCO_calcEntryPARSER_H__
#include "dictionary.H"
#include "scalar.H"
#include "error.H"
#include "wchar.H"
#include "calcEntryScanner.h"
namespace Foam {
namespace functionEntries {
namespace calcEntryInternal {
//! Parser error handing
class Errors {
public:
int count; //!< The number of errors detected
//! Allocate and return a string describing the given error code.
/** It is the responsibility of the caller to free this string,
* eg, with coco_string_delete()
*/
static wchar_t* strerror(int n);
Errors(); //!< Construct null - start with no errors
virtual ~Errors(); //!< Destructor
virtual void clear(); //!< Clear the error count
//! Handle a general warning 'msg'
virtual void Warning(const wchar_t* msg);
//! Handle a general warning 'msg'
virtual void Warning(int line, int col, const wchar_t* msg);
//! Handle general error 'msg' (eg, a semantic error)
virtual void Error(int line, int col, const wchar_t* msg);
//! Handle syntax error 'n', uses strerror for the message, calls Error()
virtual void SynErr(int line, int col, int n);
//! Handle a general exception 'msg'
virtual void Exception(const wchar_t* msg);
}; // Errors
//! A Coco/R Parser
class Parser {
private:
enum {
_EOF=0,
_ident=1,
_string=2,
_variable=3,
_number=4,
};
static const int maxT = 13;
static const int minErrDist = 2; //!< min. distance before reporting errors
Token *dummyToken;
bool deleteErrorsDestruct_; //!< delete the 'errors' member in destructor
int errDist;
void SynErr(int n); //!< Handle syntax error 'n'
void Get();
void Expect(int n);
bool StartOf(int s);
void ExpectWeak(int n, int follow);
bool WeakSeparator(int n, int syFol, int repFol);
public:
Scanner *scanner;
Errors *errors;
Token *t; //!< last recognized token
Token *la; //!< lookahead token
static const int debug = 0;
//! The parent dictionary
mutable dictionary* dict_;
//! Track that parent dictionary was set
bool hasDict_;
//! The calculation result
scalar val;
//! token -> scalar
scalar getScalar() const
{
return coco_string_toDouble(t->val);
}
//! token -> string
std::string getString() const
{
char* str = coco_string_create_char(t->val);
std::string s(str);
coco_string_delete(str);
return s;
}
//! attach a dictionary
void dict(const dictionary& dict)
{
dict_ = const_cast<dictionary*>(&dict);
hasDict_ = true;
}
//! lookup dictionary entry
scalar getDictLookup() const
{
scalar dictValue = 0;
if (!hasDict_)
{
FatalErrorIn
(
"calcEntry::getDictEntry() const"
) << "No dictionary attached!"
<< exit(FatalError);
return 0;
}
char* chars = coco_string_create_char
(
t->val,
1,
(coco_string_length(t->val) - 1)
);
word keyword(chars);
coco_string_delete(chars);
if (debug)
{
Info<<"lookup: " << keyword << nl;
}
entry* entryPtr = dict_->lookupEntryPtr(keyword, true, false);
if (entryPtr && !entryPtr->isDict())
{
if (entryPtr->stream().size() != 1)
{
FatalErrorIn
(
"calcEntry::getDictEntry() const"
) << "keyword " << keyword << " has "
<< entryPtr->stream().size() << " values in dictionary "
<< exit(FatalError);
}
entryPtr->stream() >> dictValue;
}
else
{
FatalErrorIn
(
"calcEntry::getDictEntry() const"
) << "keyword " << keyword << " is undefined in dictionary "
<< exit(FatalError);
}
return dictValue;
}
scalar Result() const
{
return val;
}
/*---------------------------------------------------------------------------*/
//! Construct for the specified scanner
/**
* Use the default error handling, or optionally provide an error
* handler, which will not be deleted upon destruction.
*/
Parser(Scanner* scan, Errors* err = 0);
~Parser(); //!< Destructor - cleanup errors and dummyToken
void SemErr(const wchar_t* msg); //!< Handle semantic error
void calcEntry();
void Expr(scalar& val);
void Term(scalar& val);
void Factor(scalar& val);
void Parse(); //!< Execute the parse operation
}; // end Parser
} // namespace
} // namespace
} // namespace
#endif // COCO_calcEntryPARSER_H__

View File

@ -0,0 +1,932 @@
#include <sstream>
#include "calcEntryScanner.h"
// values for the file stream buffering
#define MIN_BUFFER_LENGTH 1024 // 1KB
#define MAX_BUFFER_LENGTH (64*MIN_BUFFER_LENGTH) // 64KB
// value for the heap management
#define HEAP_BLOCK_SIZE (64*1024) // 64KB
namespace Foam {
namespace functionEntries {
namespace calcEntryInternal {
// * * * * * * * * * * Wide Character String Routines * * * * * * * * * * * //
// string handling, wide character
wchar_t* coco_string_create(const wchar_t* str) {
int len = coco_string_length(str);
wchar_t* dest = new wchar_t[len + 1];
if (len) {
wcsncpy(dest, str, len);
}
dest[len] = 0;
return dest;
}
wchar_t* coco_string_create(const wchar_t* str, int index, int length) {
int len = coco_string_length(str);
if (len) {
len = length;
}
wchar_t* dest = new wchar_t[len + 1];
if (len) {
wcsncpy(dest, &(str[index]), len);
}
dest[len] = 0;
return dest;
}
wchar_t* coco_string_create_lower(const wchar_t* str) {
if (!str) { return NULL; }
return coco_string_create_lower(str, 0, wcslen(str));
}
wchar_t* coco_string_create_lower(const wchar_t* str, int index, int len) {
if (!str) { return NULL; }
wchar_t* dest = new wchar_t[len + 1];
for (int i = 0; i < len; i++) {
const wchar_t ch = str[index + i];
if ((L'A' <= ch) && (ch <= L'Z')) {
dest[i] = ch - (L'A' - L'a');
}
else {
dest[i] = ch;
}
}
dest[len] = L'\0';
return dest;
}
wchar_t* coco_string_create_append(const wchar_t* str1, const wchar_t* str2) {
int str1Len = coco_string_length(str1);
int str2Len = coco_string_length(str2);
wchar_t* dest = new wchar_t[str1Len + str2Len + 1];
if (str1Len) { wcscpy(dest, str1); }
if (str2Len) { wcscpy(dest + str1Len, str2); }
dest[str1Len + str2Len] = 0;
return dest;
}
wchar_t* coco_string_create_append(const wchar_t* str1, const wchar_t ch) {
int len = coco_string_length(str1);
wchar_t* dest = new wchar_t[len + 2];
wcsncpy(dest, str1, len); // or use if (len) { wcscpy(dest, str1); }
dest[len] = ch;
dest[len + 1] = 0;
return dest;
}
void coco_string_delete(wchar_t* &str) {
delete [] str;
str = NULL;
}
int coco_string_length(const wchar_t* str) {
return str ? wcslen(str) : 0;
}
bool coco_string_endswith(const wchar_t* str, const wchar_t* endstr) {
int strLen = wcslen(str);
int endLen = wcslen(endstr);
return (endLen <= strLen) && (wcscmp(str + strLen - endLen, endstr) == 0);
}
int coco_string_indexof(const wchar_t* str, const wchar_t ch) {
const wchar_t* fnd = wcschr(str, ch);
return fnd ? (fnd - str) : -1;
}
int coco_string_lastindexof(const wchar_t* str, const wchar_t ch) {
const wchar_t* fnd = wcsrchr(str, ch);
return fnd ? (fnd - str) : -1;
}
void coco_string_merge(wchar_t* &dest, const wchar_t* str) {
if (!str) { return; }
wchar_t* newstr = coco_string_create_append(dest, str);
delete [] dest;
dest = newstr;
}
bool coco_string_equal(const wchar_t* str1, const wchar_t* str2) {
return wcscmp(str1, str2) == 0;
}
int coco_string_compareto(const wchar_t* str1, const wchar_t* str2) {
return wcscmp(str1, str2);
}
int coco_string_hash(const wchar_t* str) {
int h = 0;
if (!str) { return 0; }
while (*str != 0) {
h = (h * 7) ^ *str;
++str;
}
if (h < 0) { h = -h; }
return h;
}
double coco_string_toDouble(const wchar_t* str)
{
return str ? wcstod(str, NULL) : 0;
}
float coco_string_toFloat(const wchar_t* str)
{
return str ? wcstof(str, NULL) : 0;
}
//
// string handling, byte character
//
wchar_t* coco_string_create(const char* str) {
int len = str ? strlen(str) : 0;
wchar_t* dest = new wchar_t[len + 1];
for (int i = 0; i < len; ++i) {
dest[i] = wchar_t(str[i]);
}
dest[len] = 0;
return dest;
}
wchar_t* coco_string_create(const char* str, int index, int length) {
int len = str ? length : 0;
wchar_t* dest = new wchar_t[len + 1];
for (int i = 0; i < len; ++i) {
dest[i] = wchar_t(str[index + i]);
}
dest[len] = 0;
return dest;
}
char* coco_string_create_char(const wchar_t* str) {
int len = coco_string_length(str);
char *dest = new char[len + 1];
for (int i = 0; i < len; ++i)
{
dest[i] = char(str[i]);
}
dest[len] = 0;
return dest;
}
char* coco_string_create_char(const wchar_t* str, int index, int length) {
int len = coco_string_length(str);
if (len) {
len = length;
}
char *dest = new char[len + 1];
for (int i = 0; i < len; ++i) {
dest[i] = char(str[index + i]);
}
dest[len] = 0;
return dest;
}
void coco_string_delete(char* &str) {
delete [] str;
str = NULL;
}
double coco_string_toDouble(const char* str)
{
return str ? strtod(str, NULL) : 0;
}
float coco_string_toFloat(const char* str)
{
return str ? strtof(str, NULL) : 0;
}
// * * * * * * * * * End of Wide Character String Routines * * * * * * * * * //
Token::Token()
:
kind(0),
pos(0),
col(0),
line(0),
val(NULL),
next(NULL)
{}
// Note: this delete may not be correct if the token was actually
// allocated by the internal heap mechanism
Token::~Token() {
coco_string_delete(val);
}
// ----------------------------------------------------------------------------
// Buffer Implementation
// ----------------------------------------------------------------------------
Buffer::Buffer(Buffer* b)
:
buf(b->buf),
bufCapacity(b->bufCapacity),
bufLen(b->bufLen),
bufPos(b->bufPos),
bufStart(b->bufStart),
fileLen(b->fileLen),
cStream(b->cStream),
stdStream(b->stdStream),
isUserStream_(b->isUserStream_)
{
// avoid accidental deletion on any of these members
b->buf = NULL;
b->cStream = NULL;
b->stdStream = NULL;
}
Buffer::Buffer(FILE* istr, bool isUserStream)
:
buf(NULL),
bufCapacity(0),
bufLen(0),
bufPos(0),
bufStart(0),
fileLen(0),
cStream(istr),
stdStream(NULL),
isUserStream_(isUserStream)
{
// ensure binary read on windows
#if _MSC_VER >= 1300
_setmode(_fileno(cStream), _O_BINARY);
#endif
if (CanSeek()) {
fseek(cStream, 0, SEEK_END);
fileLen = ftell(cStream);
fseek(cStream, 0, SEEK_SET);
bufLen = (fileLen < MAX_BUFFER_LENGTH) ? fileLen : MAX_BUFFER_LENGTH;
bufStart = INT_MAX; // nothing in the buffer so far
}
bufCapacity = (bufLen > 0) ? bufLen : MIN_BUFFER_LENGTH;
buf = new unsigned char[bufCapacity];
if (fileLen > 0) SetPos(0); // setup buffer to position 0 (start)
else bufPos = 0; // index 0 is already after the file, thus Pos = 0 is invalid
if (bufLen == fileLen && CanSeek()) Close();
}
Buffer::Buffer(std::istream* istr, bool isUserStream)
:
buf(NULL),
bufCapacity(0),
bufLen(0),
bufPos(0),
bufStart(0),
fileLen(0),
cStream(NULL),
stdStream(istr),
isUserStream_(isUserStream)
{
// ensure binary read on windows
#if _MSC_VER >= 1300
// TODO
#endif
}
Buffer::Buffer(std::string& str)
:
buf(NULL),
bufCapacity(0),
bufLen(0),
bufPos(0),
bufStart(0),
fileLen(0),
cStream(NULL),
stdStream(new std::istringstream(str)),
isUserStream_(false)
{}
Buffer::Buffer(const unsigned char* chars, int len)
:
buf(new unsigned char[len]),
bufCapacity(len),
bufLen(len),
bufPos(0),
bufStart(0),
fileLen(len),
cStream(NULL),
stdStream(NULL),
isUserStream_(false)
{
memcpy(this->buf, chars, len*sizeof(char));
}
Buffer::Buffer(const char* chars, int len)
:
buf(new unsigned char[len]),
bufCapacity(len),
bufLen(len),
bufPos(0),
bufStart(0),
fileLen(len),
cStream(NULL),
stdStream(NULL),
isUserStream_(false)
{
memcpy(this->buf, chars, len*sizeof(char));
}
Buffer::~Buffer() {
Close();
if (buf) {
delete [] buf;
buf = NULL;
}
}
void Buffer::Close() {
if (!isUserStream_) {
if (cStream) {
fclose(cStream);
cStream = NULL;
}
else if (stdStream) {
delete stdStream;
stdStream = 0;
}
}
}
int Buffer::Read() {
if (stdStream)
{
int ch = stdStream->get();
if (stdStream->eof())
{
return EoF;
}
return ch;
}
if (bufPos < bufLen) {
return buf[bufPos++];
} else if (GetPos() < fileLen) {
SetPos(GetPos()); // shift buffer start to Pos
return buf[bufPos++];
} else if (cStream && !CanSeek() && (ReadNextStreamChunk() > 0)) {
return buf[bufPos++];
} else {
return EoF;
}
}
int UTF8Buffer::Read() {
int ch;
do {
ch = Buffer::Read();
// until we find a utf8 start (0xxxxxxx or 11xxxxxx)
} while ((ch >= 128) && ((ch & 0xC0) != 0xC0) && (ch != EoF));
if (ch < 128 || ch == EoF) {
// nothing to do, first 127 chars are the same in ascii and utf8
// 0xxxxxxx or end of file character
} else if ((ch & 0xF0) == 0xF0) {
// 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
int c1 = ch & 0x07; ch = Buffer::Read();
int c2 = ch & 0x3F; ch = Buffer::Read();
int c3 = ch & 0x3F; ch = Buffer::Read();
int c4 = ch & 0x3F;
ch = (((((c1 << 6) | c2) << 6) | c3) << 6) | c4;
} else if ((ch & 0xE0) == 0xE0) {
// 1110xxxx 10xxxxxx 10xxxxxx
int c1 = ch & 0x0F; ch = Buffer::Read();
int c2 = ch & 0x3F; ch = Buffer::Read();
int c3 = ch & 0x3F;
ch = (((c1 << 6) | c2) << 6) | c3;
} else if ((ch & 0xC0) == 0xC0) {
// 110xxxxx 10xxxxxx
int c1 = ch & 0x1F; ch = Buffer::Read();
int c2 = ch & 0x3F;
ch = (c1 << 6) | c2;
}
return ch;
}
int Buffer::Peek() {
int curPos = GetPos();
int ch = Read();
SetPos(curPos);
return ch;
}
int Buffer::GetPos() const {
if (stdStream)
{
return stdStream->tellg();
}
return bufPos + bufStart;
}
void Buffer::SetPos(int value) {
if (stdStream)
{
stdStream->seekg(value, std::ios::beg);
return;
}
if ((value >= fileLen) && cStream && !CanSeek()) {
// Wanted position is after buffer and the stream
// is not seek-able e.g. network or console,
// thus we have to read the stream manually till
// the wanted position is in sight.
while ((value >= fileLen) && (ReadNextStreamChunk() > 0))
{}
}
if ((value < 0) || (value > fileLen)) {
wprintf(L"--- buffer out of bounds access, position: %d\n", value);
::exit(1);
}
if ((value >= bufStart) && (value < (bufStart + bufLen))) { // already in buffer
bufPos = value - bufStart;
} else if (cStream) { // must be swapped in
fseek(cStream, value, SEEK_SET);
bufLen = fread(buf, sizeof(char), bufCapacity, cStream);
bufStart = value; bufPos = 0;
} else {
bufPos = fileLen - bufStart; // make Pos return fileLen
}
}
// Read the next chunk of bytes from the stream, increases the buffer
// if needed and updates the fields fileLen and bufLen.
// Returns the number of bytes read.
int Buffer::ReadNextStreamChunk() {
int freeLen = bufCapacity - bufLen;
if (freeLen == 0) {
// in the case of a growing input stream
// we can neither seek in the stream, nor can we
// foresee the maximum length, thus we must adapt
// the buffer size on demand.
bufCapacity = bufLen * 2;
unsigned char *newBuf = new unsigned char[bufCapacity];
memcpy(newBuf, buf, bufLen*sizeof(char));
delete [] buf;
buf = newBuf;
freeLen = bufLen;
}
int read = fread(buf + bufLen, sizeof(char), freeLen, cStream);
if (read > 0) {
fileLen = bufLen = (bufLen + read);
return read;
}
// end of stream reached
return 0;
}
bool Buffer::CanSeek() const {
return cStream && (ftell(cStream) != -1);
}
// ----------------------------------------------------------------------------
// Scanner Implementation
// ----------------------------------------------------------------------------
Scanner::Scanner(FILE* istr)
:
buffer(new Buffer(istr, true))
{
Init();
}
Scanner::Scanner(std::istream& istr)
:
buffer(new Buffer(&istr, true))
{
Init();
}
Scanner::Scanner(const wchar_t* fileName) {
char *chFileName = coco_string_create_char(fileName);
FILE* istr;
if ((istr = fopen(chFileName, "rb")) == NULL) {
wprintf(L"--- Cannot open file %ls\n", fileName);
::exit(1);
}
coco_string_delete(chFileName);
buffer = new Buffer(istr, false);
Init();
}
Scanner::Scanner(const unsigned char* buf, int len)
:
buffer(new Buffer(buf, len))
{
Init();
}
Scanner::Scanner(const char* buf, int len)
:
buffer(new Buffer(buf, len))
{
Init();
}
Scanner::~Scanner() {
char* cur = reinterpret_cast<char*>(firstHeap);
while (cur) {
cur = *(reinterpret_cast<char**>(cur + HEAP_BLOCK_SIZE));
free(firstHeap);
firstHeap = cur;
}
delete [] tval;
delete buffer;
}
void Scanner::Init() {
for (int i = 65; i <= 90; ++i) start.set(i, 1);
for (int i = 97; i <= 122; ++i) start.set(i, 1);
for (int i = 36; i <= 36; ++i) start.set(i, 5);
start.set(45, 20);
for (int i = 48; i <= 57; ++i) start.set(i, 9);
start.set(34, 2);
start.set(46, 7);
start.set(123, 14);
start.set(125, 15);
start.set(43, 21);
start.set(42, 16);
start.set(47, 17);
start.set(40, 18);
start.set(41, 19);
start.set(Buffer::EoF, -1);
tvalLength = 128;
tval = new wchar_t[tvalLength]; // text of current token
// HEAP_BLOCK_SIZE byte heap + pointer to next heap block
heap = malloc(HEAP_BLOCK_SIZE + sizeof(void*));
firstHeap = heap;
heapEnd =
reinterpret_cast<void**>
(reinterpret_cast<char*>(heap) + HEAP_BLOCK_SIZE);
*heapEnd = 0;
heapTop = heap;
if (sizeof(Token) > HEAP_BLOCK_SIZE) {
wprintf(L"--- Too small HEAP_BLOCK_SIZE\n");
::exit(1);
}
pos = -1; line = 1; col = 0;
oldEols = 0;
NextCh();
if (ch == 0xEF) { // check optional byte order mark for UTF-8
NextCh(); int ch1 = ch;
NextCh(); int ch2 = ch;
if (ch1 != 0xBB || ch2 != 0xBF) {
wprintf(L"Illegal byte order mark at start of file");
::exit(1);
}
Buffer *oldBuf = buffer;
buffer = new UTF8Buffer(buffer); col = 0;
delete oldBuf; oldBuf = NULL;
NextCh();
}
pt = tokens = CreateToken(); // first token is a dummy
}
void Scanner::NextCh() {
if (oldEols > 0) {
ch = EOL;
oldEols--;
}
else {
pos = buffer->GetPos();
ch = buffer->Read(); col++;
// replace isolated '\r' by '\n' in order to make
// eol handling uniform across Windows, Unix and Mac
if (ch == L'\r' && buffer->Peek() != L'\n') ch = EOL;
if (ch == EOL) { line++; col = 0; }
}
}
void Scanner::AddCh() {
if (tlen >= tvalLength) {
tvalLength *= 2;
wchar_t *newBuf = new wchar_t[tvalLength];
memcpy(newBuf, tval, tlen*sizeof(wchar_t));
delete [] tval;
tval = newBuf;
}
if (ch != Buffer::EoF) {
tval[tlen++] = ch;
NextCh();
}
}
bool Scanner::Comment0() {
int level = 1, pos0 = pos, line0 = line, col0 = col;
NextCh();
if (ch == L'/') {
NextCh();
for(;;) {
if (ch == 10) {
level--;
if (level == 0) { oldEols = line - line0; NextCh(); return true; }
NextCh();
} else if (ch == buffer->EoF) return false;
else NextCh();
}
} else {
buffer->SetPos(pos0); NextCh(); line = line0; col = col0;
}
return false;
}
bool Scanner::Comment1() {
int level = 1, pos0 = pos, line0 = line, col0 = col;
NextCh();
if (ch == L'*') {
NextCh();
for(;;) {
if (ch == L'*') {
NextCh();
if (ch == L'/') {
level--;
if (level == 0) { oldEols = line - line0; NextCh(); return true; }
NextCh();
}
} else if (ch == L'/') {
NextCh();
if (ch == L'*') {
level++; NextCh();
}
} else if (ch == buffer->EoF) return false;
else NextCh();
}
} else {
buffer->SetPos(pos0); NextCh(); line = line0; col = col0;
}
return false;
}
void Scanner::CreateHeapBlock() {
char* cur = reinterpret_cast<char*>(firstHeap);
// release unused blocks
while
(
(reinterpret_cast<char*>(tokens) < cur)
|| (reinterpret_cast<char*>(tokens) > (cur + HEAP_BLOCK_SIZE))
) {
cur = *(reinterpret_cast<char**>(cur + HEAP_BLOCK_SIZE));
free(firstHeap);
firstHeap = cur;
}
// HEAP_BLOCK_SIZE byte heap + pointer to next heap block
void* newHeap = malloc(HEAP_BLOCK_SIZE + sizeof(void*));
*heapEnd = newHeap;
heapEnd =
reinterpret_cast<void**>
(reinterpret_cast<char*>(newHeap) + HEAP_BLOCK_SIZE);
*heapEnd = 0;
heap = newHeap;
heapTop = heap;
}
Token* Scanner::CreateToken() {
const int reqMem = sizeof(Token);
if
(
(reinterpret_cast<char*>(heapTop) + reqMem)
>= reinterpret_cast<char*>(heapEnd)
) {
CreateHeapBlock();
}
// token 'occupies' heap starting at heapTop
Token* tok = reinterpret_cast<Token*>(heapTop);
// increment past this part of the heap, which is now used
heapTop =
reinterpret_cast<void*>
(reinterpret_cast<char*>(heapTop) + reqMem);
tok->val = NULL;
tok->next = NULL;
return tok;
}
void Scanner::AppendVal(Token* tok) {
const int reqMem = (tlen + 1) * sizeof(wchar_t);
if
(
(reinterpret_cast<char*>(heapTop) + reqMem)
>= reinterpret_cast<char*>(heapEnd)
) {
if (reqMem > HEAP_BLOCK_SIZE) {
wprintf(L"--- Too long token value\n");
::exit(1);
}
CreateHeapBlock();
}
// add text value from heap
tok->val = reinterpret_cast<wchar_t*>(heapTop);
// increment past this part of the heap, which is now used
heapTop =
reinterpret_cast<void*>
(reinterpret_cast<char*>(heapTop) + reqMem);
// copy the currently parsed tval into the token
wcsncpy(tok->val, tval, tlen);
tok->val[tlen] = L'\0';
}
Token* Scanner::NextToken() {
while (ch == ' ' ||
(ch >= 9 && ch <= 10) || ch == 13
) NextCh();
if ((ch == L'/' && Comment0()) || (ch == L'/' && Comment1())) return NextToken();
t = CreateToken();
t->pos = pos; t->col = col; t->line = line;
int state = start.state(ch);
tlen = 0; AddCh();
switch (state) {
case -1: { t->kind = eofSym; break; } // NextCh already done
case 0: { t->kind = noSym; break; } // NextCh already done
case 1:
case_1:
if ((ch >= L'0' && ch <= L':') || (ch >= L'A' && ch <= L'Z') || ch == L'_' || (ch >= L'a' && ch <= L'z')) {AddCh(); goto case_1;}
else {t->kind = 1; break;}
case 2:
case_2:
if (ch <= 9 || (ch >= 11 && ch <= 12) || (ch >= 14 && ch <= L'!') || (ch >= L'#' && ch <= L'[') || (ch >= L']' && ch <= 65535)) {AddCh(); goto case_2;}
else if (ch == L'"') {AddCh(); goto case_4;}
else if (ch == 92) {AddCh(); goto case_3;}
else {t->kind = noSym; break;}
case 3:
case_3:
if ((ch >= L' ' && ch <= L'~')) {AddCh(); goto case_2;}
else {t->kind = noSym; break;}
case 4:
case_4:
{t->kind = 2; break;}
case 5:
if ((ch >= L'A' && ch <= L'Z') || (ch >= L'a' && ch <= L'z')) {AddCh(); goto case_6;}
else {t->kind = noSym; break;}
case 6:
case_6:
if ((ch >= L'0' && ch <= L':') || (ch >= L'A' && ch <= L'Z') || ch == L'_' || (ch >= L'a' && ch <= L'z')) {AddCh(); goto case_6;}
else {t->kind = 3; break;}
case 7:
case_7:
if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_8;}
else {t->kind = noSym; break;}
case 8:
case_8:
if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_8;}
else {t->kind = 4; break;}
case 9:
case_9:
if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_9;}
else if (ch == L'E' || ch == L'e') {AddCh(); goto case_10;}
else if (ch == L'.') {AddCh(); goto case_13;}
else {t->kind = 4; break;}
case 10:
case_10:
if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_12;}
else if (ch == L'+' || ch == L'-') {AddCh(); goto case_11;}
else {t->kind = noSym; break;}
case 11:
case_11:
if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_12;}
else {t->kind = noSym; break;}
case 12:
case_12:
if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_12;}
else {t->kind = 4; break;}
case 13:
case_13:
if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_13;}
else if (ch == L'E' || ch == L'e') {AddCh(); goto case_10;}
else {t->kind = 4; break;}
case 14:
{t->kind = 5; break;}
case 15:
{t->kind = 6; break;}
case 16:
{t->kind = 9; break;}
case 17:
{t->kind = 10; break;}
case 18:
{t->kind = 11; break;}
case 19:
{t->kind = 12; break;}
case 20:
if (ch == L'.') {AddCh(); goto case_7;}
else {t->kind = 8; break;}
case 21:
if (ch == L'.') {AddCh(); goto case_7;}
else {t->kind = 7; break;}
}
AppendVal(t);
return t;
}
// get the next token (possibly a token already seen during peeking)
Token* Scanner::Scan() {
if (tokens->next == NULL) {
return pt = tokens = NextToken();
} else {
pt = tokens = tokens->next;
return tokens;
}
}
// peek for the next token, ignore pragmas
Token* Scanner::Peek() {
do {
if (pt->next == NULL) {
pt->next = NextToken();
}
pt = pt->next;
} while (pt->kind > maxT); // skip pragmas
return pt;
}
// make sure that peeking starts at the current scan position
void Scanner::ResetPeek() {
pt = tokens;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // namespace
} // namespace
} // namespace
// ************************************************************************* //

View File

@ -0,0 +1,398 @@
#ifndef COCO_calcEntrySCANNER_H__
#define COCO_calcEntrySCANNER_H__
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cwchar>
#include <string>
#include <fstream>
#include <iostream>
// io.h and fcntl are used to ensure binary read from streams on windows
#if _MSC_VER >= 1300
#include <io.h>
#include <fcntl.h>
#endif
#if _MSC_VER >= 1400
#define coco_swprintf swprintf_s
#elif _MSC_VER >= 1300
#define coco_swprintf _snwprintf
#else
// assume every other compiler knows swprintf
#define coco_swprintf swprintf
#endif
#define COCO_WCHAR_MAX 65535
namespace Foam {
namespace functionEntries {
namespace calcEntryInternal {
// * * * * * * * * * * Wide Character String Routines * * * * * * * * * * * //
//
// string handling, wide character
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//! Create by copying str
wchar_t* coco_string_create(const wchar_t* str);
//! Create a substring of str starting at index and length characters long
wchar_t* coco_string_create(const wchar_t* str, int index, int length);
//! Create a lowercase string from str
wchar_t* coco_string_create_lower(const wchar_t* str);
//! Create a lowercase substring from str starting at index and length characters long
wchar_t* coco_string_create_lower(const wchar_t* str, int index, int length);
//! Create a string by concatenating str1 and str2
wchar_t* coco_string_create_append(const wchar_t* str1, const wchar_t* str2);
//! Create a string by concatenating a character to the end of str
wchar_t* coco_string_create_append(const wchar_t* str, const wchar_t ch);
//! Free storage and nullify the argument
void coco_string_delete(wchar_t* &str);
//! The length of the str, or 0 if the str is NULL
int coco_string_length(const wchar_t* str);
//! Return true if the str ends with the endstr
bool coco_string_endswith(const wchar_t* str, const wchar_t* endstr);
//! Return the index of the first occurrence of ch.
// Return -1 if nothing is found.
int coco_string_indexof(const wchar_t* str, const wchar_t ch);
//! Return the index of the last occurrence of ch.
// Return -1 if nothing is found.
int coco_string_lastindexof(const wchar_t* str, const wchar_t ch);
//! Append str to dest
void coco_string_merge(wchar_t* &dest, const wchar_t* str);
//! Compare strings, return true if they are equal
bool coco_string_equal(const wchar_t* str1, const wchar_t* str2);
//! Compare strings, return 0 if they are equal
int coco_string_compareto(const wchar_t* str1, const wchar_t* str2);
//! Simple string hashing function
int coco_string_hash(const wchar_t* str);
//
// String conversions
// ~~~~~~~~~~~~~~~~~~
//! Convert wide string to double
double coco_string_toDouble(const wchar_t* str);
//! Convert wide string to float
float coco_string_toFloat(const wchar_t* str);
//
// String handling, byte character
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//! Create by copying byte str
wchar_t* coco_string_create(const char* str);
//! Create a substring of byte str starting at index and length characters long
wchar_t* coco_string_create(const char* str, int index, int length);
//! Create a byte string by copying str
char* coco_string_create_char(const wchar_t* str);
//! Create a byte substring of str starting at index and length characters long
char* coco_string_create_char(const wchar_t* str, int index, int length);
//! Free storage and nullify the argument
void coco_string_delete(char* &str);
//
// String conversions, byte character
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//! Convert byte string to double
double coco_string_toDouble(const char* str);
//! Convert byte string to float
float coco_string_toFloat(const char* str);
// * * * * * * * * * End of Wide Character String Routines * * * * * * * * * //
//! Scanner Token
class Token
{
public:
int kind; //!< token kind
int pos; //!< token position in the source text (starting at 0)
int col; //!< token column (starting at 1)
int line; //!< token line (starting at 1)
wchar_t* val; //!< token value
Token *next; //!< Peek tokens are kept in linked list
Token(); //!< Construct null
~Token(); //!< Destructor - cleanup allocated val??
};
//! Scanner Buffer
//
//! This Buffer supports the following cases:
//! -# seekable stream (file)
//! -# whole stream in buffer
//! -# part of stream in buffer
//! -# non seekable stream (network, console)
class Buffer {
private:
unsigned char *buf; //!< input buffer
int bufCapacity; //!< capacity of buf
int bufLen; //!< length of buffer
int bufPos; //!< current position in buffer
int bufStart; //!< position of first byte in buffer relative to input stream
int fileLen; //!< length of input stream (may change if the stream is no file)
FILE* cStream; //!< input stdio stream (normally seekable)
std::istream* stdStream; //!< STL std stream (seekable)
bool isUserStream_; //!< was the stream opened by the user?
int ReadNextStreamChunk();
bool CanSeek() const; //!< true if stream can be seeked otherwise false
protected:
Buffer(Buffer*); //!< for the UTF8Buffer
public:
static const int EoF = COCO_WCHAR_MAX + 1;
//! Attach buffer to a stdio stream.
//! User streams are not closed in the destructor
Buffer(FILE*, bool isUserStream = true);
//! Attach buffer to an STL std stream
//! User streams are not closed in the destructor
explicit Buffer(std::istream*, bool isUserStream = true);
//! Copy buffer contents from constant string
//! Handled internally as an istringstream
explicit Buffer(std::string&);
//! Copy buffer contents from constant character string
Buffer(const unsigned char* chars, int len);
//! Copy buffer contents from constant character string
Buffer(const char* chars, int len);
//! Close stream (but not user streams) and free buf (if any)
virtual ~Buffer();
virtual void Close(); //!< Close stream (but not user streams)
virtual int Read(); //!< Get character from stream or buffer
virtual int Peek(); //!< Peek character from stream or buffer
virtual int GetPos() const;
virtual void SetPos(int value);
};
//! A Scanner buffer that handles UTF-8 characters
class UTF8Buffer : public Buffer {
public:
UTF8Buffer(Buffer* b) : Buffer(b) {}
virtual int Read();
};
//------------------------------------------------------------------------------
// StartStates
//------------------------------------------------------------------------------
//! maps characters (integers) to start states of tokens
class StartStates {
private:
class Elem {
public:
int key, val;
Elem *next;
Elem(int k, int v) :
key(k), val(v), next(0)
{}
};
Elem **tab;
public:
StartStates() :
tab(new Elem*[128])
{
memset(tab, 0, 128 * sizeof(Elem*));
}
virtual ~StartStates() {
for (int i = 0; i < 128; ++i) {
Elem *e = tab[i];
while (e) {
Elem *next = e->next;
delete e;
e = next;
}
}
delete [] tab;
}
void set(int key, int val) {
Elem *e = new Elem(key, val);
int k = unsigned(key) % 128;
e->next = tab[k];
tab[k] = e;
}
int state(int key) {
Elem *e = tab[unsigned(key) % 128];
while (e && e->key != key) e = e->next;
return e ? e->val : 0;
}
};
//------------------------------------------------------------------------------
// KeywordMap
//------------------------------------------------------------------------------
//! maps strings to integers (identifiers to keyword kinds)
class KeywordMap {
private:
class Elem {
public:
wchar_t *key;
int val;
Elem *next;
Elem(const wchar_t *k, int v) :
key(coco_string_create(k)), val(v), next(0)
{}
virtual ~Elem() {
coco_string_delete(key);
}
};
Elem **tab;
public:
KeywordMap() :
tab(new Elem*[128])
{
memset(tab, 0, 128 * sizeof(Elem*));
}
virtual ~KeywordMap() {
for (int i = 0; i < 128; ++i) {
Elem *e = tab[i];
while (e) {
Elem *next = e->next;
delete e;
e = next;
}
}
delete [] tab;
}
void set(const wchar_t *key, int val) {
Elem *e = new Elem(key, val);
const int k = coco_string_hash(key) % 128;
e->next = tab[k];
tab[k] = e;
}
int get(const wchar_t *key, int defaultVal) {
Elem *e = tab[coco_string_hash(key) % 128];
while (e && !coco_string_equal(e->key, key)) e = e->next;
return e ? e->val : defaultVal;
}
};
//! A Coco/R Scanner
class Scanner {
private:
static const int maxT = 13;
static const int noSym = 13;
static const int eofSym = 0; //!< end-of-file token id
static const char EOL = '\n'; //!< end-of-line character
void *firstHeap; //!< the start of the heap management
void *heap; //!< the currently active block
void *heapTop; //!< the top of the heap
void **heapEnd; //!< the end of the last heap block
StartStates start; //!< A map of start states for particular characters
KeywordMap keywords; //!< A hash of keyword literals to token kind
Token *t; //!< current token
wchar_t *tval; //!< text of current token
int tvalLength; //!< maximum capacity (length) for tval
int tlen; //!< length of tval
Token *tokens; //!< list of tokens already peeked (first token is a dummy)
Token *pt; //!< current peek token
int ch; //!< current input character
int pos; //!< byte position of current character
int line; //!< line number of current character
int col; //!< column number of current character
int oldEols; //!< the number of EOLs that appeared in a comment
void CreateHeapBlock(); //!< add a heap block, freeing unused ones
Token* CreateToken(); //!< fit token on the heap
void AppendVal(Token* tok); //!< adjust tok->val to point to the heap and copy tval into it
void Init(); //!< complete the initialization for the constructors
void NextCh(); //!< get the next input character into ch
void AddCh(); //!< append the character ch to tval
bool Comment0();
bool Comment1();
Token* NextToken(); //!< get the next token
public:
//! The scanner buffer
Buffer *buffer;
//! Using an existing open file handle for the scanner
Scanner(FILE*);
//! Using an existing open STL std stream
explicit Scanner(std::istream&);
//! Open a file for reading and attach scanner
explicit Scanner(const wchar_t* fileName);
//! Attach scanner to an existing character buffer
Scanner(const unsigned char* chars, int len);
//! Attach scanner to an existing character buffer
Scanner(const char* chars, int len);
~Scanner(); //!< free heap and allocated memory
Token* Scan(); //!< get the next token (possibly a token already seen during peeking)
Token* Peek(); //!< peek for the next token, ignore pragmas
void ResetPeek(); //!< ensure that peeking starts at the current scan position
}; // end Scanner
} // namespace
} // namespace
} // namespace
#endif // COCO_calcEntrySCANNER_H__

View File

@ -43,14 +43,16 @@ using namespace Foam;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::noParallel(); argList::noParallel();
argList args(argc, argv); argList::validArgs.insert("dict .. dictN");
argList args(argc, argv, false, true);
Info<< nl Info<< nl
<< "FOAM_CASE=" << getEnv("FOAM_CASE") << nl << "FOAM_CASE=" << getEnv("FOAM_CASE") << nl
<< "FOAM_CASENAME=" << getEnv("FOAM_CASENAME") << nl << "FOAM_CASENAME=" << getEnv("FOAM_CASENAME") << nl
<< endl; << endl;
if (args.additionalArgs().empty())
{
{ {
dictionary dict1(IFstream("testDict")()); dictionary dict1(IFstream("testDict")());
Info<< "dict1: " << dict1 << nl Info<< "dict1: " << dict1 << nl
@ -108,6 +110,20 @@ int main(int argc, char *argv[])
<< dict.subDict("someDict").lookup("xxx", true) << dict.subDict("someDict").lookup("xxx", true)
<< endl; << endl;
} }
}
else
{
IOobject::writeDivider(Info);
forAll(args.additionalArgs(), argI)
{
const string& dictFile = args.additionalArgs()[argI];
IFstream is(dictFile);
dictionary dict(is);
Info<< dict << endl;
}
}
return 0; return 0;
} }

View File

@ -67,7 +67,6 @@ boundaryField
// error #remove self; // error #remove self;
x 5; x 5;
y 6; y 6;
another #calc{x $x; y $y;};
} }
// this should have no effect // this should have no effect

View File

@ -0,0 +1,46 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: Any |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object testDictTest;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
flowRatePerHour 720;
x 10;
y 20;
z t s v;
// z #test{ // this
// 123 - 456
// // comments // are
// /* stripped
// * 10
// * {}
// */
// + 1 /*100 */ 10
// };
p this calculation #calc{
1 + 2 + 10 * 15 +
$x - $y
// $x + $y
}
is done inplace;
flowRate #calc{ $flowRatePerHour / 3600};
xxx yyy;
foo 30;
bar 15;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -108,8 +108,7 @@ int main()
Info<< " badName(die) => " << findEtcFile("badName", true) << nl Info<< " badName(die) => " << findEtcFile("badName", true) << nl
<< endl; << endl;
Info<< "\nEnd" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -66,17 +66,18 @@ int main(int argc, char *argv[])
argList::noBanner(); argList::noBanner();
argList::noParallel(); argList::noParallel();
argList::validArgs.insert("fileName .. fileNameN"); argList::validArgs.insert("fileName .. fileNameN");
argList::addOption("istream", "fileName", "test Istream values");
argList args(argc, argv, false, true); argList args(argc, argv, false, true);
if (args.additionalArgs().empty()) if (args.additionalArgs().empty() && args.options().empty())
{ {
args.printUsage(); args.printUsage();
} }
if (args.optionFound("case")) fileName pathName;
if (args.optionReadIfPresent("case", pathName))
{ {
fileName pathName = args.option("case");
Info<< nl Info<< nl
<< "-case" << nl << "-case" << nl
<< "path = " << args.path() << nl << "path = " << args.path() << nl
@ -91,12 +92,27 @@ int main(int argc, char *argv[])
forAll(args.additionalArgs(), argI) forAll(args.additionalArgs(), argI)
{ {
fileName pathName = args.additionalArgs()[argI]; pathName = args.additionalArgs()[argI];
printCleaning(pathName); printCleaning(pathName);
} }
Info<< "\nEnd" << endl; if (args.optionFound("istream"))
{
args.optionLookup("istream")() >> pathName;
Info<< nl
<< "-case" << nl
<< "path = " << args.path() << nl
<< "root = " << args.rootPath() << nl
<< "case = " << args.caseName() << nl
<< "FOAM_CASE=" << getEnv("FOAM_CASE") << nl
<< "FOAM_CASENAME=" << getEnv("FOAM_CASENAME") << nl
<< endl;
printCleaning(pathName);
}
Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -98,8 +98,9 @@ bool checkDictionaryContent(const dictionary& dict1, const dictionary& dict2)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::noParallel(); argList::noParallel();
argList::validOptions.insert("rewrite", ""); argList::addBoolOption("rewrite");
argList::validOptions.insert("show", ""); argList::addBoolOption("show");
argList args(argc, argv); argList args(argc, argv);
Time runTime(args.rootPath(), args.caseName()); Time runTime(args.rootPath(), args.caseName());

View File

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

View File

@ -0,0 +1,3 @@
EXE_INC =
EXE_LIBS =

View File

@ -0,0 +1,221 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
globalMeshDataTest
Description
Test global point communication
\*---------------------------------------------------------------------------*/
#include "globalMeshData.H"
#include "argList.H"
#include "polyMesh.H"
#include "Time.H"
#include "mapDistribute.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
# include "createPolyMesh.H"
const globalMeshData& globalData = mesh.globalData();
const indirectPrimitivePatch& coupledPatch = globalData.coupledPatch();
// Test:print shared points
{
const labelListList& globalPointSlaves =
globalData.globalPointSlaves();
const mapDistribute& globalPointSlavesMap =
globalData.globalPointSlavesMap();
pointField coords(globalPointSlavesMap.constructSize());
SubList<point>(coords, coupledPatch.nPoints()).assign
(
coupledPatch.localPoints()
);
// Exchange data
globalPointSlavesMap.distribute(coords);
// Print
forAll(globalPointSlaves, pointI)
{
const labelList& slavePoints = globalPointSlaves[pointI];
if (slavePoints.size() > 0)
{
Pout<< "Master point:" << pointI
<< " coord:" << coords[pointI]
<< " connected to slave points:" << endl;
forAll(slavePoints, i)
{
Pout<< " " << coords[slavePoints[i]] << endl;
}
}
}
}
// Test: point to faces addressing
{
const labelListList& globalPointBoundaryFaces =
globalData.globalPointBoundaryFaces();
const mapDistribute& globalPointBoundaryFacesMap =
globalData.globalPointBoundaryFacesMap();
label nBnd = mesh.nFaces()-mesh.nInternalFaces();
pointField fc(globalPointBoundaryFacesMap.constructSize());
SubList<point>(fc, nBnd).assign
(
primitivePatch
(
SubList<face>
(
mesh.faces(),
nBnd,
mesh.nInternalFaces()
),
mesh.points()
).faceCentres()
);
// Exchange data
globalPointBoundaryFacesMap.distribute(fc);
// Print
forAll(globalPointBoundaryFaces, pointI)
{
const labelList& bFaces = globalPointBoundaryFaces[pointI];
Pout<< "Point:" << pointI
<< " at:" << coupledPatch.localPoints()[pointI]
<< " connected to faces:" << endl;
forAll(bFaces, i)
{
Pout<< " " << fc[bFaces[i]] << endl;
}
}
}
// Test:point to cells addressing
{
const labelList& boundaryCells = globalData.boundaryCells();
const labelListList& globalPointBoundaryCells =
globalData.globalPointBoundaryCells();
const mapDistribute& globalPointBoundaryCellsMap =
globalData.globalPointBoundaryCellsMap();
pointField cc(globalPointBoundaryCellsMap.constructSize());
forAll(boundaryCells, i)
{
cc[i] = mesh.cellCentres()[boundaryCells[i]];
}
// Exchange data
globalPointBoundaryCellsMap.distribute(cc);
// Print
forAll(globalPointBoundaryCells, pointI)
{
const labelList& bCells = globalPointBoundaryCells[pointI];
Pout<< "Point:" << pointI
<< " at:" << coupledPatch.localPoints()[pointI]
<< " connected to cells:" << endl;
forAll(bCells, i)
{
Pout<< " " << cc[bCells[i]] << endl;
}
}
}
// Test:print shared edges
{
const labelListList& globalEdgeSlaves =
globalData.globalEdgeSlaves();
const mapDistribute& globalEdgeSlavesMap =
globalData.globalEdgeSlavesMap();
// Test: distribute edge centres
pointField ec(globalEdgeSlavesMap.constructSize());
forAll(coupledPatch.edges(), edgeI)
{
ec[edgeI] = coupledPatch.edges()[edgeI].centre
(
coupledPatch.localPoints()
);
}
// Exchange data
globalEdgeSlavesMap.distribute(ec);
// Print
forAll(globalEdgeSlaves, edgeI)
{
const labelList& slaveEdges = globalEdgeSlaves[edgeI];
if (slaveEdges.size() > 0)
{
Pout<< "Master edge:" << edgeI
<< " centre:" << ec[edgeI]
<< " connected to slave edges:" << endl;
forAll(slaveEdges, i)
{
Pout<< " " << ec[slaveEdges[i]] << endl;
}
}
}
}
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

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

View File

@ -0,0 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lmeshTools

View File

@ -0,0 +1,357 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2009 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
momentOfInertiaTest
Description
Calculates the inertia tensor and principal axes and moments of a
test face and tetrahedron.
\*---------------------------------------------------------------------------*/
#include "ListOps.H"
#include "face.H"
#include "tetPointRef.H"
#include "triFaceList.H"
#include "OFstream.H"
#include "meshTools.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
using namespace Foam;
void massPropertiesSolid
(
const pointField& pts,
const triFaceList triFaces,
scalar density,
scalar& mass,
vector& cM,
tensor& J
)
{
// Reimplemented from: Wm4PolyhedralMassProperties.cpp
// File Version: 4.10.0 (2009/11/18)
// Geometric Tools, LC
// Copyright (c) 1998-2010
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
// http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
// Boost Software License - Version 1.0 - August 17th, 2003
// Permission is hereby granted, free of charge, to any person or
// organization obtaining a copy of the software and accompanying
// documentation covered by this license (the "Software") to use,
// reproduce, display, distribute, execute, and transmit the
// Software, and to prepare derivative works of the Software, and
// to permit third-parties to whom the Software is furnished to do
// so, all subject to the following:
// The copyright notices in the Software and this entire
// statement, including the above license grant, this restriction
// and the following disclaimer, must be included in all copies of
// the Software, in whole or in part, and all derivative works of
// the Software, unless such copies or derivative works are solely
// in the form of machine-executable object code generated by a
// source language processor.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
// NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
// ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR
// OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
const scalar r6 = 1.0/6.0;
const scalar r24 = 1.0/24.0;
const scalar r60 = 1.0/60.0;
const scalar r120 = 1.0/120.0;
// order: 1, x, y, z, x^2, y^2, z^2, xy, yz, zx
scalarField integrals(10, 0.0);
forAll(triFaces, i)
{
const triFace& tri(triFaces[i]);
// vertices of triangle i
vector v0 = pts[tri[0]];
vector v1 = pts[tri[1]];
vector v2 = pts[tri[2]];
// cross product of edges
vector eA = v1 - v0;
vector eB = v2 - v0;
vector n = eA ^ eB;
// compute integral terms
scalar tmp0, tmp1, tmp2;
scalar f1x, f2x, f3x, g0x, g1x, g2x;
tmp0 = v0.x() + v1.x();
f1x = tmp0 + v2.x();
tmp1 = v0.x()*v0.x();
tmp2 = tmp1 + v1.x()*tmp0;
f2x = tmp2 + v2.x()*f1x;
f3x = v0.x()*tmp1 + v1.x()*tmp2 + v2.x()*f2x;
g0x = f2x + v0.x()*(f1x + v0.x());
g1x = f2x + v1.x()*(f1x + v1.x());
g2x = f2x + v2.x()*(f1x + v2.x());
scalar f1y, f2y, f3y, g0y, g1y, g2y;
tmp0 = v0.y() + v1.y();
f1y = tmp0 + v2.y();
tmp1 = v0.y()*v0.y();
tmp2 = tmp1 + v1.y()*tmp0;
f2y = tmp2 + v2.y()*f1y;
f3y = v0.y()*tmp1 + v1.y()*tmp2 + v2.y()*f2y;
g0y = f2y + v0.y()*(f1y + v0.y());
g1y = f2y + v1.y()*(f1y + v1.y());
g2y = f2y + v2.y()*(f1y + v2.y());
scalar f1z, f2z, f3z, g0z, g1z, g2z;
tmp0 = v0.z() + v1.z();
f1z = tmp0 + v2.z();
tmp1 = v0.z()*v0.z();
tmp2 = tmp1 + v1.z()*tmp0;
f2z = tmp2 + v2.z()*f1z;
f3z = v0.z()*tmp1 + v1.z()*tmp2 + v2.z()*f2z;
g0z = f2z + v0.z()*(f1z + v0.z());
g1z = f2z + v1.z()*(f1z + v1.z());
g2z = f2z + v2.z()*(f1z + v2.z());
// update integrals
integrals[0] += n.x()*f1x;
integrals[1] += n.x()*f2x;
integrals[2] += n.y()*f2y;
integrals[3] += n.z()*f2z;
integrals[4] += n.x()*f3x;
integrals[5] += n.y()*f3y;
integrals[6] += n.z()*f3z;
integrals[7] += n.x()*(v0.y()*g0x + v1.y()*g1x + v2.y()*g2x);
integrals[8] += n.y()*(v0.z()*g0y + v1.z()*g1y + v2.z()*g2y);
integrals[9] += n.z()*(v0.x()*g0z + v1.x()*g1z + v2.x()*g2z);
}
integrals[0] *= r6;
integrals[1] *= r24;
integrals[2] *= r24;
integrals[3] *= r24;
integrals[4] *= r60;
integrals[5] *= r60;
integrals[6] *= r60;
integrals[7] *= r120;
integrals[8] *= r120;
integrals[9] *= r120;
// mass
mass = integrals[0];
// center of mass
cM = vector(integrals[1], integrals[2], integrals[3])/mass;
// inertia relative to origin
J.xx() = integrals[5] + integrals[6];
J.xy() = -integrals[7];
J.xz() = -integrals[9];
J.yx() = J.xy();
J.yy() = integrals[4] + integrals[6];
J.yz() = -integrals[8];
J.zx() = J.xz();
J.zy() = J.yz();
J.zz() = integrals[4] + integrals[5];
// inertia relative to center of mass
J -= mass*((cM & cM)*I - cM*cM);
// Apply density
mass *= density;
J *= density;
}
int main(int argc, char *argv[])
{
scalar density = 1.0;
{
label nPts = 6;
pointField pts(nPts);
pts[0] = point(4.495, 3.717, -4.112);
pts[1] = point(4.421, 3.932, -4.112);
pts[2] = point(4.379, 4.053, -4.112);
pts[3] = point(4.301, 4.026, -4.300);
pts[4] = point(4.294, 4.024, -4.317);
pts[5] = point(4.409, 3.687, -4.317);
face f(identity(nPts));
point Cf = f.centre(pts);
tensor J = tensor::zero;
J = f.inertia(pts, Cf, density);
vector eVal = eigenValues(J);
tensor eVec = eigenVectors(J);
Info<< nl << "Inertia tensor of test face " << J << nl
<< "eigenValues (principal moments) " << eVal << nl
<< "eigenVectors (principal axes) " << eVec
<< endl;
OFstream str("momentOfInertiaTestFace.obj");
Info<< nl << "Writing test face and scaled principal axes to "
<< str.name() << endl;
forAll(pts, ptI)
{
meshTools::writeOBJ(str, pts[ptI]);
}
str << "l";
forAll(f, fI)
{
str << ' ' << fI + 1;
}
str << " 1" << endl;
scalar scale = mag(Cf - pts[f[0]])/eVal.component(findMin(eVal));
meshTools::writeOBJ(str, Cf);
meshTools::writeOBJ(str, Cf + scale*eVal.x()*eVec.x());
meshTools::writeOBJ(str, Cf + scale*eVal.y()*eVec.y());
meshTools::writeOBJ(str, Cf + scale*eVal.z()*eVec.z());
for (label i = nPts + 1; i < nPts + 4; i++)
{
str << "l " << nPts + 1 << ' ' << i + 1 << endl;
}
}
{
label nPts = 4;
pointField pts(nPts);
pts[0] = point(0, 0, 0);
pts[1] = point(1, 0, 0);
pts[2] = point(0.5, 1, 0);
pts[3] = point(0.5, 0.5, 1);
tetPointRef tet(pts[0], pts[1], pts[2], pts[3]);
triFaceList tetFaces(4);
tetFaces[0] = triFace(0, 2, 1);
tetFaces[1] = triFace(1, 2, 3);
tetFaces[2] = triFace(0, 3, 2);
tetFaces[3] = triFace(0, 1, 3);
scalar m = 0.0;
vector cM = vector::zero;
tensor J = tensor::zero;
massPropertiesSolid
(
pts,
tetFaces,
density,
m,
cM,
J
);
vector eVal = eigenValues(J);
tensor eVec = eigenVectors(J);
Info<< nl
<< "Mass of tetrahedron " << m << nl
<< "Centre of mass of tetrahedron " << cM << nl
<< "Inertia tensor of tetrahedron " << J << nl
<< "eigenValues (principal moments) " << eVal << nl
<< "eigenVectors (principal axes) " << eVec
<< endl;
OFstream str("momentOfInertiaTestTet.obj");
Info<< nl << "Writing test tetrahedron and scaled principal axes to "
<< str.name() << endl;
forAll(pts, ptI)
{
meshTools::writeOBJ(str, pts[ptI]);
}
forAll(tetFaces, tFI)
{
const triFace& f = tetFaces[tFI];
str << "l";
forAll(f, fI)
{
str << ' ' << f[fI] + 1;
}
str << ' ' << f[0] + 1 << endl;
}
scalar scale = mag(cM - pts[0])/eVal.component(findMin(eVal));
meshTools::writeOBJ(str, cM);
meshTools::writeOBJ(str, cM + scale*eVal.x()*eVec.x());
meshTools::writeOBJ(str, cM + scale*eVal.y()*eVec.y());
meshTools::writeOBJ(str, cM + scale*eVal.z()*eVec.z());
for (label i = nPts + 1; i < nPts + 4; i++)
{
str << "l " << nPts + 1 << ' ' << i + 1 << endl;
}
}
Info<< nl << "End" << nl << endl;
return 0;
}
// ************************************************************************* //

View File

@ -39,8 +39,9 @@ int main(int argc, char *argv[])
argList::noBanner(); argList::noBanner();
argList::noParallel(); argList::noParallel();
argList::validArgs.insert("file .. fileN"); argList::validArgs.insert("file .. fileN");
argList::validOptions.erase("case");
argList::validOptions.insert("ext", "bak"); argList::removeOption("case");
argList::addOption("ext", "bak");
argList args(argc, argv, false, true); argList args(argc, argv, false, true);

View File

@ -38,7 +38,7 @@ int main(int argc, char *argv[])
{ {
argList::validArgs.clear(); argList::validArgs.clear();
argList::validArgs.append("CHEMKINIIIFile"); argList::validArgs.append("CHEMKINIIIFile");
argList::validOptions.insert("thermo", "fileName"); argList::addOption("thermo", "fileName");
argList args(argc, argv); argList args(argc, argv);
fileName thermoFileName = fileName::null; fileName thermoFileName = fileName::null;

View File

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

View File

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

View File

@ -0,0 +1,105 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2009 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
Test the sizeof various classes.
\*---------------------------------------------------------------------------*/
#include "bool.H"
#include "Switch.H"
#include "string.H"
#include "dictionary.H"
#include "nil.H"
#include "IOstreams.H"
#include "IStringStream.H"
namespace Foam
{
class hasBoolClass
{
public:
bool b_;
hasBoolClass(const bool val=false)
:
b_(false)
{}
};
}
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
cout<<"sizeof\n------\n";
{
nil x;
cout<<"nil:" << sizeof(x) << nl;
}
{
bool x(0);
cout<<"bool:" << sizeof(x) << nl;
}
{
hasBoolClass x(true);
cout<<"hasBoolClass:" << sizeof(x) << nl;
}
{
Switch x("n");
cout<<"Switch:" << sizeof(x) << nl;
cout<<"Switch::switchType=" << sizeof(Switch::switchType) << nl;
}
{
scalar x(0);
cout<<"scalar:" << sizeof(x) << nl;
}
{
label x(0);
cout<<"label:" << sizeof(x) << nl;
}
{
cout<<"int:" << sizeof(int) << nl;
cout<<"long:" << sizeof(long) << nl;
cout<<"float:" << sizeof(float) << nl;
cout<<"double:" << sizeof(double) << nl;
}
Info << "---\nEnd\n" << endl;
return 0;
}
// ************************************************************************* //

View File

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

View File

@ -0,0 +1,137 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2009 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 "argList.H"
#include "vector.H"
#include "IFstream.H"
#include "BSpline.H"
#include "CatmullRomSpline.H"
using namespace Foam;
inline Ostream& printPoint(Ostream& os, const point& p)
{
os << p.x() << ' ' << p.y() << ' ' << p.z() << nl;
return os;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::noParallel();
argList::validArgs.insert("file .. fileN");
argList::addBoolOption("B", "B-Spline implementation");
argList::addBoolOption("CMR", "catmull-rom spline (default)");
argList::addOption
(
"n",
"INT",
"number of segments for evaluation - default 20"
);
argList args(argc, argv, false, true);
if (args.additionalArgs().empty())
{
args.printUsage();
}
bool useBSpline = args.optionFound("B");
bool useCatmullRom = args.optionFound("CMR");
label nSeg = args.optionLookupOrDefault<label>("n", 20);
if (!useCatmullRom && !useBSpline)
{
Info<<"defaulting to Catmull-Rom spline" << endl;
useCatmullRom = true;
}
forAll(args.additionalArgs(), argI)
{
const string& srcFile = args.additionalArgs()[argI];
Info<< nl << "reading " << srcFile << nl;
IFstream ifs(srcFile);
List<pointField> pointFields(ifs);
forAll(pointFields, splineI)
{
Info<<"\n# points:" << endl;
forAll(pointFields[splineI], ptI)
{
printPoint(Info, pointFields[splineI][ptI]);
}
if (useBSpline)
{
BSpline spl(pointFields[splineI]);
Info<< nl << "# B-Spline" << endl;
for (label segI = 0; segI <= nSeg; ++segI)
{
scalar lambda = scalar(segI)/scalar(nSeg);
printPoint(Info, spl.position(lambda));
}
}
if (useCatmullRom)
{
CatmullRomSpline spl(pointFields[splineI]);
Info<< nl <<"# Catmull-Rom" << endl;
for (label segI = 0; segI <= nSeg; ++segI)
{
scalar lambda = scalar(segI)/scalar(nSeg);
printPoint(Info, spl.position(lambda));
}
}
{
polyLine pl(pointFields[splineI]);
Info<< nl <<"# polyList" << endl;
for (label segI = 0; segI <= nSeg; ++segI)
{
scalar lambda = scalar(segI)/scalar(nSeg);
printPoint(Info, pl.position(lambda));
}
}
}
}
return 0;
}
// ************************************************************************* //

View File

@ -0,0 +1,46 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.6 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
(
// Upper body longitudinal splines
(
(0.22685 0.01125166 0) // 7
(0.21685 0.01340204 0)
(0.20685 0.01529684 0)
(0.19685 0.01694748 0)
(0.18685 0.01836538 0)
(0.17685 0.01956197 0)
(0.16685 0.02054868 0)
(0.15685 0.02133693 0)
(0.14685 0.02193816 0)
(0.13685 0.02236377 0)
(0.12685 0.02262521 0)
(0.11685 0.02273389 0) // 2
)
// sine function
(
(0 0 0)
(45 0.70707 0)
(90 1 0)
(135 0.70707 0)
(180 0 0)
(225 -0.70707 0)
(270 -1 0)
(315 -0.70707 0)
(360 0 0)
)
// cosine function, but with extremely few points
(
(0 1 0)
(180 -1 0)
(360 1 0)
)
);

View File

@ -102,8 +102,7 @@ int main(int argc, char *argv[])
Info<< "Ostream<< >" << s2 << "<\n"; Info<< "Ostream<< >" << s2 << "<\n";
Info<< "hash:" << hex << string::hash()(s2) << endl; Info<< "hash:" << hex << string::hash()(s2) << endl;
Info << "End\n" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

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

View File

@ -0,0 +1 @@
EXE_INC =

View File

@ -0,0 +1,629 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
syncToolsTest
Description
Test some functionality in syncTools.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "polyMesh.H"
#include "Time.H"
#include "Random.H"
#include "PackedList.H"
#include "syncTools.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void testPackedList(const polyMesh& mesh, Random& rndGen)
{
Info<< nl << "Testing PackedList synchronisation." << endl;
{
PackedList<3> bits(mesh.nEdges());
forAll(bits, i)
{
bits.set(i, rndGen.integer(0,3));
}
labelList edgeValues(mesh.nEdges());
forAll(bits, i)
{
edgeValues[i] = bits.get(i);
}
PackedList<3> maxBits(bits);
labelList maxEdgeValues(edgeValues);
syncTools::syncEdgeList(mesh, bits, minEqOp<unsigned int>(), 0);
syncTools::syncEdgeList(mesh, edgeValues, minEqOp<label>(), 0, false);
syncTools::syncEdgeList(mesh, maxBits, maxEqOp<unsigned int>(), 0);
syncTools::syncEdgeList(mesh, maxEdgeValues, maxEqOp<label>(), 0, false);
forAll(bits, i)
{
if
(
edgeValues[i] != label(bits.get(i))
|| maxEdgeValues[i] != label(maxBits.get(i))
)
{
FatalErrorIn("testPackedList()")
<< "edge:" << i
<< " minlabel:" << edgeValues[i]
<< " minbits:" << bits.get(i)
<< " maxLabel:" << maxEdgeValues[i]
<< " maxBits:" << maxBits.get(i)
<< exit(FatalError);
}
}
}
{
PackedList<3> bits(mesh.nPoints());
forAll(bits, i)
{
bits.set(i, rndGen.integer(0,3));
}
labelList pointValues(mesh.nPoints());
forAll(bits, i)
{
pointValues[i] = bits.get(i);
}
PackedList<3> maxBits(bits);
labelList maxPointValues(pointValues);
syncTools::syncPointList(mesh, bits, minEqOp<unsigned int>(), 0);
syncTools::syncPointList(mesh, pointValues, minEqOp<label>(), 0, false);
syncTools::syncPointList(mesh, maxBits, maxEqOp<unsigned int>(), 0);
syncTools::syncPointList(mesh, maxPointValues, maxEqOp<label>(), 0, false);
forAll(bits, i)
{
if
(
pointValues[i] != label(bits.get(i))
|| maxPointValues[i] != label(maxBits.get(i))
)
{
FatalErrorIn("testPackedList()")
<< "point:" << i
<< " minlabel:" << pointValues[i]
<< " minbits:" << bits.get(i)
<< " maxLabel:" << maxPointValues[i]
<< " maxBits:" << maxBits.get(i)
<< exit(FatalError);
}
}
}
{
PackedList<3> bits(mesh.nFaces());
forAll(bits, faceI)
{
bits.set(faceI, rndGen.integer(0,3));
}
labelList faceValues(mesh.nFaces());
forAll(bits, faceI)
{
faceValues[faceI] = bits.get(faceI);
}
PackedList<3> maxBits(bits);
labelList maxFaceValues(faceValues);
syncTools::syncFaceList(mesh, bits, minEqOp<unsigned int>());
syncTools::syncFaceList(mesh, faceValues, minEqOp<label>(), false);
syncTools::syncFaceList(mesh, maxBits, maxEqOp<unsigned int>());
syncTools::syncFaceList(mesh, maxFaceValues, maxEqOp<label>(), false);
forAll(bits, faceI)
{
if
(
faceValues[faceI] != label(bits.get(faceI))
|| maxFaceValues[faceI] != label(maxBits.get(faceI))
)
{
FatalErrorIn("testPackedList()")
<< "face:" << faceI
<< " minlabel:" << faceValues[faceI]
<< " minbits:" << bits.get(faceI)
<< " maxLabel:" << maxFaceValues[faceI]
<< " maxBits:" << maxBits.get(faceI)
<< exit(FatalError);
}
}
}
}
void testSparseData(const polyMesh& mesh, Random& rndGen)
{
Info<< nl << "Testing Map synchronisation." << endl;
primitivePatch allBoundary
(
SubList<face>
(
mesh.faces(),
mesh.nFaces()-mesh.nInternalFaces(),
mesh.nInternalFaces()
),
mesh.points()
);
const pointField& localPoints = allBoundary.localPoints();
const point greatPoint(GREAT, GREAT, GREAT);
// Point data
// ~~~~~~~~~~
{
// Create some data. Use slightly perturbed positions.
Map<vector> sparseData;
pointField fullData(mesh.nPoints(), greatPoint);
forAll(localPoints, i)
{
const point pt = localPoints[i] + 1E-4*rndGen.vector01();
label meshPointI = allBoundary.meshPoints()[i];
sparseData.insert(meshPointI, pt);
fullData[meshPointI] = pt;
}
//Pout<< "sparseData:" << sparseData << endl;
syncTools::syncPointMap
(
mesh,
sparseData,
minEqOp<vector>(),
true // apply separation
);
syncTools::syncPointList
(
mesh,
fullData,
minEqOp<vector>(),
greatPoint,
true // apply separation
);
// Compare.
// 1. Is all fullData also present in sparseData and same value
forAll(fullData, meshPointI)
{
const point& fullPt = fullData[meshPointI];
if (fullPt != greatPoint)
{
const point& sparsePt = sparseData[meshPointI];
if (fullPt != sparsePt)
{
FatalErrorIn("testSparseData()")
<< "point:" << meshPointI
<< " full:" << fullPt
<< " sparse:" << sparsePt
<< exit(FatalError);
}
}
}
// 2. Does sparseData contain more?
forAllConstIter(Map<vector>, sparseData, iter)
{
const point& sparsePt = iter();
label meshPointI = iter.key();
const point& fullPt = fullData[meshPointI];
if (fullPt != sparsePt)
{
FatalErrorIn("testSparseData()")
<< "point:" << meshPointI
<< " full:" << fullPt
<< " sparse:" << sparsePt
<< exit(FatalError);
}
}
}
// Edge data
// ~~~~~~~~~
{
// Create some data. Use slightly perturbed positions.
EdgeMap<vector> sparseData;
pointField fullData(mesh.nEdges(), greatPoint);
const edgeList& edges = allBoundary.edges();
const labelList meshEdges = allBoundary.meshEdges
(
mesh.edges(),
mesh.pointEdges()
);
forAll(edges, i)
{
const edge& e = edges[i];
const point pt = e.centre(localPoints) + 1E-4*rndGen.vector01();
label meshEdgeI = meshEdges[i];
sparseData.insert(mesh.edges()[meshEdgeI], pt);
fullData[meshEdgeI] = pt;
}
//Pout<< "sparseData:" << sparseData << endl;
syncTools::syncEdgeMap
(
mesh,
sparseData,
minEqOp<vector>(),
true
);
syncTools::syncEdgeList
(
mesh,
fullData,
minEqOp<vector>(),
greatPoint,
true
);
// Compare.
// 1. Is all fullData also present in sparseData and same value
forAll(fullData, meshEdgeI)
{
const point& fullPt = fullData[meshEdgeI];
if (fullPt != greatPoint)
{
const point& sparsePt = sparseData[mesh.edges()[meshEdgeI]];
if (fullPt != sparsePt)
{
FatalErrorIn("testSparseData()")
<< "edge:" << meshEdgeI
<< " points:" << mesh.edges()[meshEdgeI]
<< " full:" << fullPt
<< " sparse:" << sparsePt
<< exit(FatalError);
}
}
}
// 2. Does sparseData contain more?
forAll(fullData, meshEdgeI)
{
const edge& e = mesh.edges()[meshEdgeI];
EdgeMap<vector>::const_iterator iter = sparseData.find(e);
if (iter != sparseData.end())
{
const point& sparsePt = iter();
const point& fullPt = fullData[meshEdgeI];
if (fullPt != sparsePt)
{
FatalErrorIn("testSparseData()")
<< "Extra edge:" << meshEdgeI
<< " points:" << mesh.edges()[meshEdgeI]
<< " full:" << fullPt
<< " sparse:" << sparsePt
<< exit(FatalError);
}
}
}
}
}
void testPointSync(const polyMesh& mesh, Random& rndGen)
{
Info<< nl << "Testing point-wise data synchronisation." << endl;
const point greatPoint(GREAT, GREAT, GREAT);
// Test position.
{
WarningIn("testPointSync()")
<< "Position test only correct for cases without cyclics"
<< " with shared points." << endl;
pointField syncedPoints(mesh.points());
syncTools::syncPointList
(
mesh,
syncedPoints,
minEqOp<point>(),
greatPoint,
true
);
forAll(syncedPoints, pointI)
{
if (mag(syncedPoints[pointI] - mesh.points()[pointI]) > SMALL)
{
FatalErrorIn("testPointSync()")
<< "Point " << pointI
<< " original location " << mesh.points()[pointI]
<< " synced location " << syncedPoints[pointI]
<< exit(FatalError);
}
}
}
// Test masterPoints
{
labelList nMasters(mesh.nPoints(), 0);
PackedBoolList isMasterPoint(syncTools::getMasterPoints(mesh));
forAll(isMasterPoint, pointI)
{
if (isMasterPoint[pointI])
{
nMasters[pointI] = 1;
}
}
syncTools::syncPointList
(
mesh,
nMasters,
plusEqOp<label>(),
0,
false
);
forAll(nMasters, pointI)
{
if (nMasters[pointI] != 1)
{
//FatalErrorIn("testPointSync()")
WarningIn("testPointSync()")
<< "Point " << pointI
<< " original location " << mesh.points()[pointI]
<< " has " << nMasters[pointI]
<< " masters."
//<< exit(FatalError);
<< endl;
}
}
}
}
void testEdgeSync(const polyMesh& mesh, Random& rndGen)
{
Info<< nl << "Testing edge-wise data synchronisation." << endl;
const edgeList& edges = mesh.edges();
const point greatPoint(GREAT, GREAT, GREAT);
// Test position.
{
WarningIn("testEdgeSync()")
<< "Position test only correct for cases without cyclics"
<< " with shared edges." << endl;
pointField syncedMids(edges.size());
forAll(syncedMids, edgeI)
{
syncedMids[edgeI] = edges[edgeI].centre(mesh.points());
}
syncTools::syncEdgeList
(
mesh,
syncedMids,
minEqOp<point>(),
greatPoint,
true
);
forAll(syncedMids, edgeI)
{
point eMid = edges[edgeI].centre(mesh.points());
if (mag(syncedMids[edgeI] - eMid) > SMALL)
{
FatalErrorIn("testEdgeSync()")
<< "Edge " << edgeI
<< " original midpoint " << eMid
<< " synced location " << syncedMids[edgeI]
<< exit(FatalError);
}
}
}
// Test masterEdges
{
labelList nMasters(edges.size(), 0);
PackedBoolList isMasterEdge(syncTools::getMasterEdges(mesh));
forAll(isMasterEdge, edgeI)
{
if (isMasterEdge[edgeI])
{
nMasters[edgeI] = 1;
}
}
syncTools::syncEdgeList
(
mesh,
nMasters,
plusEqOp<label>(),
0,
false
);
forAll(nMasters, edgeI)
{
if (nMasters[edgeI] != 1)
{
//FatalErrorIn("testEdgeSync()")
WarningIn("testEdgeSync()")
<< "Edge " << edgeI
<< " midpoint " << edges[edgeI].centre(mesh.points())
<< " has " << nMasters[edgeI]
<< " masters."
//<< exit(FatalError);
<< endl;
}
}
}
}
void testFaceSync(const polyMesh& mesh, Random& rndGen)
{
Info<< nl << "Testing face-wise data synchronisation." << endl;
// Test position.
{
pointField syncedFc(mesh.faceCentres());
syncTools::syncFaceList
(
mesh,
syncedFc,
maxEqOp<point>(),
true
);
forAll(syncedFc, faceI)
{
if (mag(syncedFc[faceI] - mesh.faceCentres()[faceI]) > SMALL)
{
FatalErrorIn("testFaceSync()")
<< "Face " << faceI
<< " original centre " << mesh.faceCentres()[faceI]
<< " synced centre " << syncedFc[faceI]
<< exit(FatalError);
}
}
}
// Test masterFaces
{
labelList nMasters(mesh.nFaces(), 0);
PackedBoolList isMasterFace(syncTools::getMasterFaces(mesh));
forAll(isMasterFace, faceI)
{
if (isMasterFace[faceI])
{
nMasters[faceI] = 1;
}
}
syncTools::syncFaceList
(
mesh,
nMasters,
plusEqOp<label>(),
false
);
forAll(nMasters, faceI)
{
if (nMasters[faceI] != 1)
{
FatalErrorIn("testFaceSync()")
<< "Face " << faceI
<< " centre " << mesh.faceCentres()[faceI]
<< " has " << nMasters[faceI]
<< " masters."
<< exit(FatalError);
}
}
}
}
// Main program:
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
# include "createPolyMesh.H"
Random rndGen(5341*(Pstream::myProcNo()+1));
// Face sync
testFaceSync(mesh, rndGen);
// Edge sync
testEdgeSync(mesh, rndGen);
// Point sync
testPointSync(mesh, rndGen);
// PackedList synchronisation
testPackedList(mesh, rndGen);
// Sparse synchronisation
testSparseData(mesh, rndGen);
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -131,8 +131,7 @@ int main(int argc, char *argv[])
psf.write(); psf.write();
Info << nl << "End" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -44,16 +44,14 @@ int main(int argc, char *argv[])
{ {
argList::noParallel(); argList::noParallel();
argList::validArgs.insert("string .. stringN"); argList::validArgs.insert("string .. stringN");
argList::validOptions.insert("file", "name"); argList::addOption("file", "name");
argList::validOptions.insert("repeat", "count"); argList::addOption("repeat", "count");
argList args(argc, argv, false, true); argList args(argc, argv, false, true);
label repeat = 1; const label repeat = args.optionLookupOrDefault<label>("repeat", 1);
args.optionReadIfPresent<label>("repeat", repeat);
cpuTime timer; cpuTime timer;
for (label count = 0; count < repeat; ++count) for (label count = 0; count < repeat; ++count)
{ {
forAll(args.additionalArgs(), argI) forAll(args.additionalArgs(), argI)
@ -69,9 +67,15 @@ int main(int argc, char *argv[])
while (is.good()) while (is.good())
{ {
token tok(is); token tok(is);
// char ch;
// is.get(ch);
// is.putback(ch);
int lookahead = is.peek();
if (count == 0) if (count == 0)
{ {
Info<< "token: " << tok.info() << endl; Info<< "token: " << tok.info();
Info<< " lookahead: '" << char(lookahead) << "'" << endl;
} }
} }

View File

@ -454,7 +454,7 @@ label simplifyFaces
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::noParallel(); argList::noParallel();
argList::validOptions.insert("overwrite", ""); argList::addBoolOption("overwrite");
argList::validArgs.append("edge length [m]"); argList::validArgs.append("edge length [m]");
argList::validArgs.append("merge angle (degrees)"); argList::validArgs.append("merge angle (degrees)");

View File

@ -59,10 +59,6 @@ using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Sin of angle between two consecutive edges on a face. If sin(angle) larger
// than this the face will be considered concave.
const scalar defaultConcaveAngle = 30;
// Same check as snapMesh // Same check as snapMesh
void checkSnapMesh void checkSnapMesh
@ -439,9 +435,9 @@ label mergeEdges(const scalar minCos, polyMesh& mesh)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::validArgs.append("feature angle [0..180]"); argList::validArgs.append("feature angle [0..180]");
argList::validOptions.insert("concaveAngle", "[0..180]"); argList::addOption("concaveAngle", "[0..180]");
argList::validOptions.insert("snapMesh", ""); argList::addBoolOption("snapMesh");
argList::validOptions.insert("overwrite", ""); argList::addBoolOption("overwrite");
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"
@ -453,8 +449,9 @@ int main(int argc, char *argv[])
scalar minCos = Foam::cos(degToRad(featureAngle)); scalar minCos = Foam::cos(degToRad(featureAngle));
scalar concaveAngle = defaultConcaveAngle; // Sin of angle between two consecutive edges on a face.
args.optionReadIfPresent("concaveAngle", concaveAngle); // If sin(angle) larger than this the face will be considered concave.
scalar concaveAngle = args.optionLookupOrDefault("concaveAngle", 30.0);
scalar concaveSin = Foam::sin(degToRad(concaveAngle)); scalar concaveSin = Foam::sin(degToRad(concaveAngle));
@ -489,8 +486,8 @@ int main(int argc, char *argv[])
// Merge points on straight edges and remove unused points // Merge points on straight edges and remove unused points
if (snapMeshDict) if (snapMeshDict)
{ {
Info<< "Merging all 'loose' points on surface edges" Info<< "Merging all 'loose' points on surface edges, "
<< ", regardless of the angle they make." << endl; << "regardless of the angle they make." << endl;
// Surface bnound to be used to extrude. Merge all loose points. // Surface bnound to be used to extrude. Merge all loose points.
nChanged += mergeEdges(-1, mesh); nChanged += mergeEdges(-1, mesh);
@ -516,7 +513,7 @@ int main(int argc, char *argv[])
Info<< "Mesh unchanged." << endl; Info<< "Mesh unchanged." << endl;
} }
Info << "End\n" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -1,215 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::Tuple
Description
A 2 Tuple. Differs from Tuple in that the two elements can be different
type.
\*---------------------------------------------------------------------------*/
#ifndef Tuple_H
#define Tuple_H
#include "Istream.H"
#include "Ostream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of friend functions and operators
template<class Type1, class Type2>
class Tuple;
template<class Type1, class Type2>
Istream& operator>>(Istream&, Tuple<Type1, Type2>&);
template<class Type1, class Type2>
Ostream& operator<<(Ostream&, const Tuple<Type1, Type2>&);
/*---------------------------------------------------------------------------*\
Class Tuple Declaration
\*---------------------------------------------------------------------------*/
template<class Type1, class Type2>
class Tuple
{
// Private data
Type1 first_;
Type2 second_;
public:
// Constructors
//- Null constructor for lists
inline Tuple()
{}
//- Construct from components
inline Tuple(const Type1& first, const Type2& second)
:
first_(first),
second_(second)
{}
//- Construct from Istream
inline Tuple(Istream& is)
{
// Read beginning of pair
is.readBegin("pair");
is >> first_ >> second_;
// Read end of pair
is.readEnd("pair");
// Check state of Istream
is.check("Tuple::Tuple(Istream&)");
}
// Member Functions
//- Return first
inline Type1 first() const
{
return first_;
}
//- Return first
inline Type1& first()
{
return first_;
}
//- Return second
inline Type2 second() const
{
return second_;
}
//- Return second
inline Type2& second()
{
return second_;
}
//- Return reverse pair
inline Tuple<Type1, Type2> reverseTuple() const
{
return Tuple<Type1, Type2>(second_, first_);
}
// Friend Operators
inline friend bool operator==
(
const Tuple<Type1, Type2>& a,
const Tuple<Type1, Type2>& b
)
{
return
(
(a.first_ == b.first_) && (a.second_ == b.second_)
);
}
inline friend bool operator!=
(
const Tuple<Type1, Type2>& a,
const Tuple<Type1, Type2>& b
)
{
return (!(a == b));
}
// IOstream Operators
friend Istream& operator>> <Type1, Type2>
(
Istream& is,
Tuple<Type1, Type2>& p
);
friend Ostream& operator<< <Type1, Type2>
(
Ostream& os,
const Tuple<Type1, Type2>& p
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type1, class Type2>
Istream& operator>>(Istream& is, Tuple<Type1, Type2>& p)
{
// Read beginning of Tuple<Type, Type>
is.readBegin("Tuple<Type, Type>");
is >> p.first_ >> p.second_;
// Read end of Tuple<Type, Type>
is.readEnd("Tuple<Type, Type>");
// Check state of Ostream
is.check("Istream& operator>>(Istream&, Tuple<Type, Type>&)");
return is;
}
template<class Type1, class Type2>
Ostream& operator<<(Ostream& os, const Tuple<Type1, Type2>& p)
{
os << token::BEGIN_LIST
<< p.first_ << token::SPACE
<< p.second_
<< token::END_LIST;
// Check state of Ostream
os.check("Ostream& operator<<(Ostream&, const Tuple<Type, Type>&)");
return os;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -37,12 +37,8 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam defineTypeNameAndDebug(Foam::cellSplitter, 0);
{
defineTypeNameAndDebug(cellSplitter, 0);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //

View File

@ -328,7 +328,7 @@ label findCell(const primitiveMesh& mesh, const point& nearPoint)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::validOptions.insert("overwrite", ""); argList::addBoolOption("overwrite");
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"
@ -375,7 +375,7 @@ int main(int argc, char *argv[])
bool cellsToSplit = cellsToPyramidise.size(); bool cellsToSplit = cellsToPyramidise.size();
//List<Tuple<pointField,point> > // List<Tuple2<pointField,point> >
// cellsToCreate(dict.lookup("cellsToCreate")); // cellsToCreate(dict.lookup("cellsToCreate"));
Info<< "Read from " << dict.name() << nl Info<< "Read from " << dict.name() << nl
@ -661,8 +661,7 @@ int main(int argc, char *argv[])
} }
Info << nl << "End" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -52,7 +52,7 @@ using namespace Foam;
// Main program: // Main program:
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::validOptions.insert("overwrite", ""); argList::addBoolOption("overwrite");
argList::validArgs.append("cellSet"); argList::validArgs.append("cellSet");
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"

View File

@ -47,11 +47,12 @@ using namespace Foam;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
Foam::argList::noParallel(); argList::noParallel();
Foam::argList::validArgs.append("patchName"); argList::validArgs.append("patchName");
Foam::argList::validArgs.append("edgeWeight"); argList::validArgs.append("edgeWeight");
Foam::argList::validOptions.insert("useSet", "cellSet");
Foam::argList::validOptions.insert("overwrite", ""); argList::addOption("useSet", "cellSet");
argList::addBoolOption("overwrite");
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"

View File

@ -97,7 +97,7 @@ bool limitRefinementLevel
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::validOptions.insert("readLevel", ""); argList::addBoolOption("readLevel");
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"
@ -126,41 +126,41 @@ int main(int argc, char *argv[])
// Create bin0. Have upperlimit as factor times lowerlimit. // Create bin0. Have upperlimit as factor times lowerlimit.
bins.append(DynamicList<label>()); bins.append(DynamicList<label>());
lowerLimits.append(sortedVols[0]); lowerLimits.append(sortedVols[0]);
upperLimits.append(1.1*lowerLimits[lowerLimits.size()-1]); upperLimits.append(1.1 * lowerLimits.last());
forAll(sortedVols, i) forAll(sortedVols, i)
{ {
if (sortedVols[i] > upperLimits[upperLimits.size()-1]) if (sortedVols[i] > upperLimits.last())
{ {
// New value outside of current bin // New value outside of current bin
// Shrink old bin. // Shrink old bin.
DynamicList<label>& bin = bins[bins.size()-1]; DynamicList<label>& bin = bins.last();
bin.shrink(); bin.shrink();
Info<< "Collected " << bin.size() << " elements in bin " Info<< "Collected " << bin.size() << " elements in bin "
<< lowerLimits[lowerLimits.size()-1] << " .. " << lowerLimits.last() << " .. "
<< upperLimits[upperLimits.size()-1] << endl; << upperLimits.last() << endl;
// Create new bin. // Create new bin.
bins.append(DynamicList<label>()); bins.append(DynamicList<label>());
lowerLimits.append(sortedVols[i]); lowerLimits.append(sortedVols[i]);
upperLimits.append(1.1*lowerLimits[lowerLimits.size()-1]); upperLimits.append(1.1 * lowerLimits.last());
Info<< "Creating new bin " << lowerLimits[lowerLimits.size()-1] Info<< "Creating new bin " << lowerLimits.last()
<< " .. " << upperLimits[upperLimits.size()-1] << " .. " << upperLimits.last()
<< endl; << endl;
} }
// Append to current bin. // Append to current bin.
DynamicList<label>& bin = bins[bins.size()-1]; DynamicList<label>& bin = bins.last();
bin.append(sortedVols.indices()[i]); bin.append(sortedVols.indices()[i]);
} }
Info<< endl; Info<< endl;
bins[bins.size()-1].shrink(); bins.last().shrink();
bins.shrink(); bins.shrink();
lowerLimits.shrink(); lowerLimits.shrink();
upperLimits.shrink(); upperLimits.shrink();
@ -355,8 +355,7 @@ int main(int argc, char *argv[])
<< nl << endl; << nl << endl;
} }
Info << nl << "End" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -48,8 +48,8 @@ using namespace Foam;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
Foam::argList::validOptions.insert("overwrite", ""); argList::addBoolOption("overwrite");
Foam::argList::validArgs.append("faceSet"); argList::validArgs.append("faceSet");
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"

View File

@ -525,10 +525,10 @@ void collectCuts
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::noParallel(); argList::noParallel();
argList::validOptions.insert("set", "cellSet name"); argList::addOption("set", "cellSet name");
argList::validOptions.insert("geometry", ""); argList::addBoolOption("geometry");
argList::validOptions.insert("tol", "edge snap tolerance"); argList::addOption("tol", "edge snap tolerance");
argList::validOptions.insert("overwrite", ""); argList::addBoolOption("overwrite");
argList::validArgs.append("edge angle [0..360]"); argList::validArgs.append("edge angle [0..360]");
# include "setRootCase.H" # include "setRootCase.H"
@ -546,8 +546,7 @@ int main(int argc, char *argv[])
bool geometry = args.optionFound("geometry"); bool geometry = args.optionFound("geometry");
bool overwrite = args.optionFound("overwrite"); bool overwrite = args.optionFound("overwrite");
scalar edgeTol = 0.2; scalar edgeTol = args.optionLookupOrDefault("tol", 0.2);
args.optionReadIfPresent("tol", edgeTol);
Info<< "Trying to split cells with internal angles > feature angle\n" << nl Info<< "Trying to split cells with internal angles > feature angle\n" << nl
<< "featureAngle : " << featureAngle << nl << "featureAngle : " << featureAngle << nl

View File

@ -198,8 +198,11 @@ void ReadVertices
int dims = 1; int dims = 1;
float scale; float scale;
CCMIOID mapID; CCMIOID mapID;
CCMIOReadVerticesf(&err, vertices, &dims, &scale, &mapID, verts.begin(), CCMIOReadVerticesf
offset, offsetPlusSize); (
&err, vertices, &dims, &scale, &mapID, verts.begin(),
offset, offsetPlusSize
);
CCMIOReadMap(&err, mapID, mapData.begin(), offset, offsetPlusSize); CCMIOReadMap(&err, mapID, mapData.begin(), offset, offsetPlusSize);
//CCMIOSize size; //CCMIOSize size;
@ -273,7 +276,6 @@ void ReadProblem
// ... walk through each region description and print it... // ... walk through each region description and print it...
CCMIOID boundary; CCMIOID boundary;
label regionI = 0; label regionI = 0;
int k = 0; int k = 0;

View File

@ -238,7 +238,7 @@ int main(int argc, char *argv[])
{ {
argList::noParallel(); argList::noParallel();
argList::validArgs.append("ANSYS input file"); argList::validArgs.append("ANSYS input file");
argList::validOptions.insert("scale", "scale factor"); argList::addOption("scale", "scale factor");
argList args(argc, argv); argList args(argc, argv);

View File

@ -22,13 +22,9 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation, along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "error.H" #include "error.H"
#include "block.H" #include "block.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -50,7 +50,7 @@ int main(int argc, char *argv[])
{ {
argList::noParallel(); argList::noParallel();
argList::validArgs.append("CFX geom file"); argList::validArgs.append("CFX geom file");
argList::validOptions.insert("scale", "scale factor"); argList::addOption("scale", "scale factor");
argList args(argc, argv); argList args(argc, argv);

View File

@ -22,8 +22,6 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation, along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "hexBlock.H" #include "hexBlock.H"

View File

@ -324,7 +324,7 @@ endOfSection {space}")"{space}
// point group type skipped // point group type skipped
strtol(endPtr, &endPtr, 16); strtol(endPtr, &endPtr, 16);
pointi = pointGroupStartIndex[pointGroupStartIndex.size()-1]; pointi = pointGroupStartIndex.last();
// reset number of components to default // reset number of components to default
pointGroupNumberOfComponents = 3; pointGroupNumberOfComponents = 3;
@ -336,11 +336,11 @@ endOfSection {space}")"{space}
} }
Info<< "PointGroup: " Info<< "PointGroup: "
<< pointGroupZoneID[pointGroupZoneID.size()-1] << pointGroupZoneID.last()
<< " start: " << " start: "
<< pointGroupStartIndex[pointGroupStartIndex.size()-1] << pointGroupStartIndex.last()
<< " end: " << " end: "
<< pointGroupEndIndex[pointGroupEndIndex.size()-1] << flush; << pointGroupEndIndex.last() << flush;
} }
<readNumberOfPoints,readPointGroupData>{endOfSection} { <readNumberOfPoints,readPointGroupData>{endOfSection} {
@ -387,14 +387,14 @@ endOfSection {space}")"{space}
Info<< "done." << endl; Info<< "done." << endl;
// check read of points // check read of points
if (pointi != pointGroupEndIndex[pointGroupEndIndex.size()-1]+1) if (pointi != pointGroupEndIndex.last()+1)
{ {
Warning Warning
<< "Problem with reading points: " << nl << "Problem with reading points: " << nl
<< " start index: " << " start index: "
<< pointGroupStartIndex[pointGroupStartIndex.size()-1] << pointGroupStartIndex.last()
<< " end index: " << " end index: "
<< pointGroupEndIndex[pointGroupEndIndex.size()-1] << pointGroupEndIndex.last()
<< " last points read: " << pointi << nl << " last points read: " << pointi << nl
<< " on line " << lineNo << endl; << " on line " << lineNo << endl;
} }
@ -440,14 +440,14 @@ endOfSection {space}")"{space}
faceGroupElementType = strtol(endPtr, &endPtr, 16); faceGroupElementType = strtol(endPtr, &endPtr, 16);
facei = faceGroupStartIndex[faceGroupStartIndex.size()-1]; facei = faceGroupStartIndex.last();
Info<< "FaceGroup: " Info<< "FaceGroup: "
<< faceGroupZoneID[faceGroupZoneID.size()-1] << faceGroupZoneID.last()
<< " start: " << " start: "
<< faceGroupStartIndex[faceGroupStartIndex.size()-1] << faceGroupStartIndex.last()
<< " end: " << " end: "
<< faceGroupEndIndex[faceGroupEndIndex.size()-1] << flush; << faceGroupEndIndex.last() << flush;
} }
<readNumberOfFaces,readFaceGroupData>{space}{endOfSection} { <readNumberOfFaces,readFaceGroupData>{space}{endOfSection} {
@ -507,14 +507,14 @@ endOfSection {space}")"{space}
Info<< "done." << endl; Info<< "done." << endl;
// check read of fluentFaces // check read of fluentFaces
if (facei != faceGroupEndIndex[faceGroupEndIndex.size()-1]+1) if (facei != faceGroupEndIndex.last()+1)
{ {
Warning Warning
<< "Problem with reading fluentFaces: " << nl << "Problem with reading fluentFaces: " << nl
<< " start index: " << " start index: "
<< faceGroupStartIndex[faceGroupStartIndex.size()-1] << faceGroupStartIndex.last()
<< " end index: " << " end index: "
<< faceGroupEndIndex[faceGroupEndIndex.size()-1] << faceGroupEndIndex.last()
<< " last fluentFaces read: " << facei << nl << " last fluentFaces read: " << facei << nl
<< " on line " << lineNo << endl; << " on line " << lineNo << endl;
} }
@ -560,13 +560,13 @@ endOfSection {space}")"{space}
cellGroupType.append(strtol(endPtr, &endPtr, 16)); cellGroupType.append(strtol(endPtr, &endPtr, 16));
Info<< "CellGroup: " Info<< "CellGroup: "
<< cellGroupZoneID[cellGroupZoneID.size()-1] << cellGroupZoneID.last()
<< " start: " << " start: "
<< cellGroupStartIndex[cellGroupStartIndex.size()-1] << cellGroupStartIndex.last()
<< " end: " << " end: "
<< cellGroupEndIndex[cellGroupEndIndex.size()-1] << cellGroupEndIndex.last()
<< " type: " << " type: "
<< cellGroupType[cellGroupType.size()-1] << cellGroupType.last()
<< endl; << endl;
} }
@ -587,13 +587,13 @@ endOfSection {space}")"{space}
strtol(endPtr, &endPtr, 16); strtol(endPtr, &endPtr, 16);
Info<< "CellGroup: " Info<< "CellGroup: "
<< cellGroupZoneID[cellGroupZoneID.size()-1] << cellGroupZoneID.last()
<< " start: " << " start: "
<< cellGroupStartIndex[cellGroupStartIndex.size()-1] << cellGroupStartIndex.last()
<< " end: " << " end: "
<< cellGroupEndIndex[cellGroupEndIndex.size()-1] << cellGroupEndIndex.last()
<< " type: " << " type: "
<< cellGroupType[cellGroupType.size()-1] << cellGroupType.last()
<< endl; << endl;
} }
@ -762,10 +762,10 @@ int main(int argc, char *argv[])
{ {
argList::noParallel(); argList::noParallel();
argList::validArgs.append("Fluent mesh file"); argList::validArgs.append("Fluent mesh file");
argList::validOptions.insert("scale", "scale factor"); argList::addOption("scale", "scale factor");
argList::validOptions.insert("ignoreCellGroups", "cell group names"); argList::addOption("ignoreCellGroups", "cell group names");
argList::validOptions.insert("ignoreFaceGroups", "face group names"); argList::addOption("ignoreFaceGroups", "face group names");
argList::validOptions.insert("cubit", ""); argList::addBoolOption("cubit");
argList args(argc, argv); argList args(argc, argv);
@ -776,17 +776,11 @@ int main(int argc, char *argv[])
args.optionReadIfPresent("scale", scaleFactor); args.optionReadIfPresent("scale", scaleFactor);
HashSet<word> ignoreCellGroups; wordHashSet ignoreCellGroups;
if (args.optionFound("ignoreCellGroups")) wordHashSet ignoreFaceGroups;
{
args.optionLookup("ignoreCellGroups")() >> ignoreCellGroups;
}
HashSet<word> ignoreFaceGroups; args.optionReadIfPresent("ignoreCellGroups", ignoreCellGroups);
if (args.optionFound("ignoreFaceGroups")) args.optionReadIfPresent("ignoreFaceGroups", ignoreFaceGroups);
{
args.optionLookup("ignoreFaceGroups")() >> ignoreFaceGroups;
}
cubitFile = args.options().found("cubit"); cubitFile = args.options().found("cubit");
@ -1360,7 +1354,7 @@ int main(int argc, char *argv[])
mesh.write(); mesh.write();
Info<< nl << "End" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -867,9 +867,9 @@ int main(int argc, char *argv[])
{ {
argList::noParallel(); argList::noParallel();
argList::validArgs.append("Fluent mesh file"); argList::validArgs.append("Fluent mesh file");
argList::validOptions.insert("scale", "scale factor"); argList::addOption("scale", "scale factor");
argList::validOptions.insert("writeSets", ""); argList::addBoolOption("writeSets");
argList::validOptions.insert("writeZones", ""); argList::addBoolOption("writeZones");
argList args(argc, argv); argList args(argc, argv);
@ -1404,7 +1404,11 @@ int main(int argc, char *argv[])
//it will be put in a default wall boundary //it will be put in a default wall boundary
//internal boundaries are simply ignored //internal boundaries are simply ignored
if(patchTypes[patchI] != "internal" && !pShapeMesh.isInternalFace(meshFaces[0])) if
(
patchTypes[patchI] != "internal"
&& !pShapeMesh.isInternalFace(meshFaces[0])
)
{ {
//first face is external and has valid non-internal type //first face is external and has valid non-internal type
@ -1729,7 +1733,7 @@ int main(int argc, char *argv[])
} }
} }
Info<< nl << "End" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -76,10 +76,27 @@ int main(int argc, char *argv[])
argList::noParallel(); argList::noParallel();
timeSelector::addOptions(); timeSelector::addOptions();
argList::validOptions.insert("scale", "scale"); argList::addOption
argList::validOptions.insert("noBnd", ""); (
argList::validOptions.insert("tri", ""); "scale",
argList::validOptions.insert("surface", ""); "factor",
"specify geometry scaling factor - default is 1000 ([m] to [mm])"
);
argList::addBoolOption
(
"noBnd",
"suppress writing the .bnd file"
);
argList::addBoolOption
(
"tri",
"Extract a triangulated surface. Implies -surface"
);
argList::addBoolOption
(
"surface",
"extract the surface of the volume mesh only"
);
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"

View File

@ -639,7 +639,7 @@ int main(int argc, char *argv[])
{ {
argList::noParallel(); argList::noParallel();
argList::validArgs.append("GAMBIT file"); argList::validArgs.append("GAMBIT file");
argList::validOptions.insert("scale", "scale factor"); argList::addOption("scale", "scale factor");
argList args(argc, argv); argList args(argc, argv);
@ -867,7 +867,7 @@ int main(int argc, char *argv[])
Info<< "Writing polyMesh" << endl; Info<< "Writing polyMesh" << endl;
pShapeMesh.write(); pShapeMesh.write();
Info<< nl << "End" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -717,7 +717,7 @@ int main(int argc, char *argv[])
{ {
argList::noParallel(); argList::noParallel();
argList::validArgs.append(".msh file"); argList::validArgs.append(".msh file");
argList::validOptions.insert("keepOrientation", ""); argList::addBoolOption("keepOrientation");
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"
@ -885,7 +885,7 @@ int main(int argc, char *argv[])
// Now use the patchFaces to patch up the outside faces of the mesh. // Now use the patchFaces to patch up the outside faces of the mesh.
// Get the patch for all the outside faces (= default patch added as last) // Get the patch for all the outside faces (= default patch added as last)
const polyPatch& pp = mesh.boundaryMesh()[mesh.boundaryMesh().size()-1]; const polyPatch& pp = mesh.boundaryMesh().last();
// Storage for faceZones. // Storage for faceZones.
List<DynamicList<label> > zoneFaces(patchFaces.size()); List<DynamicList<label> > zoneFaces(patchFaces.size());

View File

@ -324,13 +324,13 @@ void readCells
cellVerts.append(cellShape(tet, cVerts, true)); cellVerts.append(cellShape(tet, cVerts, true));
cellMaterial.append(physProp); cellMaterial.append(physProp);
if (cellVerts[cellVerts.size()-1].size() != cVerts.size()) if (cellVerts.last().size() != cVerts.size())
{ {
Pout<< "Line:" << is.lineNumber() Pout<< "Line:" << is.lineNumber()
<< " element:" << cellI << " element:" << cellI
<< " type:" << feID << " type:" << feID
<< " collapsed from " << cVerts << nl << " collapsed from " << cVerts << nl
<< " to:" << cellVerts[cellVerts.size()-1] << " to:" << cellVerts.last()
<< endl; << endl;
} }
} }
@ -347,13 +347,13 @@ void readCells
cellVerts.append(cellShape(prism, cVerts, true)); cellVerts.append(cellShape(prism, cVerts, true));
cellMaterial.append(physProp); cellMaterial.append(physProp);
if (cellVerts[cellVerts.size()-1].size() != cVerts.size()) if (cellVerts.last().size() != cVerts.size())
{ {
Pout<< "Line:" << is.lineNumber() Pout<< "Line:" << is.lineNumber()
<< " element:" << cellI << " element:" << cellI
<< " type:" << feID << " type:" << feID
<< " collapsed from " << cVerts << nl << " collapsed from " << cVerts << nl
<< " to:" << cellVerts[cellVerts.size()-1] << " to:" << cellVerts.last()
<< endl; << endl;
} }
} }
@ -371,13 +371,13 @@ void readCells
cellVerts.append(cellShape(hex, cVerts, true)); cellVerts.append(cellShape(hex, cVerts, true));
cellMaterial.append(physProp); cellMaterial.append(physProp);
if (cellVerts[cellVerts.size()-1].size() != cVerts.size()) if (cellVerts.last().size() != cVerts.size())
{ {
Pout<< "Line:" << is.lineNumber() Pout<< "Line:" << is.lineNumber()
<< " element:" << cellI << " element:" << cellI
<< " type:" << feID << " type:" << feID
<< " collapsed from " << cVerts << nl << " collapsed from " << cVerts << nl
<< " to:" << cellVerts[cellVerts.size()-1] << " to:" << cellVerts.last()
<< endl; << endl;
} }
} }
@ -511,7 +511,7 @@ void readDOFS
} }
Info<< "For DOF set " << group Info<< "For DOF set " << group
<< " named " << patchNames[patchNames.size()-1] << " named " << patchNames.last()
<< " trying to read vertex indices." << " trying to read vertex indices."
<< endl; << endl;
@ -534,7 +534,7 @@ void readDOFS
} }
Info<< "For DOF set " << group Info<< "For DOF set " << group
<< " named " << patchNames[patchNames.size()-1] << " named " << patchNames.last()
<< " read " << vertices.size() << " vertex indices." << endl; << " read " << vertices.size() << " vertex indices." << endl;
dofVertices.append(vertices.shrink()); dofVertices.append(vertices.shrink());
@ -579,7 +579,7 @@ int main(int argc, char *argv[])
{ {
argList::noParallel(); argList::noParallel();
argList::validArgs.append(".unv file"); argList::validArgs.append(".unv file");
argList::validOptions.insert("dump", ""); argList::addBoolOption("dump");
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"

View File

@ -60,9 +60,9 @@ enum kivaVersions
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::noParallel(); argList::noParallel();
argList::validOptions.insert("file", "fileName"); argList::addOption("file", "fileName");
argList::validOptions.insert("version", "[kiva3|kiva3v]"); argList::addOption("version", "[kiva3|kiva3v]");
argList::validOptions.insert("zHeadMin", "scalar"); argList::addOption("zHeadMin", "scalar");
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"

View File

@ -57,7 +57,7 @@ int main(int argc, char *argv[])
{ {
argList::noParallel(); argList::noParallel();
argList::validArgs.append(".msh file"); argList::validArgs.append(".msh file");
argList::validOptions.insert("hex", ""); argList::addBoolOption("hex");
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"

View File

@ -58,10 +58,10 @@ int main(int argc, char *argv[])
{ {
argList::noParallel(); argList::noParallel();
argList::validArgs.append("PLOT3D geom file"); argList::validArgs.append("PLOT3D geom file");
argList::validOptions.insert("scale", "scale factor"); argList::addOption("scale", "scale factor");
argList::validOptions.insert("noBlank", ""); argList::addBoolOption("noBlank");
argList::validOptions.insert("singleBlock", ""); argList::addBoolOption("singleBlock");
argList::validOptions.insert("2D", "thickness"); argList::addOption("2D", "thickness");
argList args(argc, argv); argList args(argc, argv);

View File

@ -357,10 +357,10 @@ int main(int argc, char *argv[])
timeSelector::addOptions(true, false); timeSelector::addOptions(true, false);
argList::validArgs.append("feature angle[0-180]"); argList::validArgs.append("feature angle[0-180]");
argList::validOptions.insert("splitAllFaces", ""); argList::addBoolOption("splitAllFaces");
argList::validOptions.insert("concaveMultiCells", ""); argList::addBoolOption("concaveMultiCells");
argList::validOptions.insert("doNotPreserveFaceZones", ""); argList::addBoolOption("doNotPreserveFaceZones");
argList::validOptions.insert("overwrite", ""); argList::addBoolOption("overwrite");
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"

View File

@ -22,12 +22,9 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation, along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "error.H" #include "error.H"
#include "sammMesh.H" #include "sammMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -41,7 +41,7 @@ int main(int argc, char *argv[])
{ {
argList::noParallel(); argList::noParallel();
argList::validArgs.append("SAMM mesh file prefix"); argList::validArgs.append("SAMM mesh file prefix");
argList::validOptions.insert("scale", "scale factor"); argList::addOption("scale", "scale factor");
argList args(argc, argv); argList args(argc, argv);
@ -50,8 +50,7 @@ int main(int argc, char *argv[])
FatalError.exit(); FatalError.exit();
} }
scalar scaleFactor = 1.0; scalar scaleFactor = args.optionLookupOrDefault("scale", 1.0);
args.optionReadIfPresent("scale", scaleFactor);
# include "createTime.H" # include "createTime.H"
@ -64,7 +63,7 @@ int main(int argc, char *argv[])
Info<< "Writing mesh" << endl; Info<< "Writing mesh" << endl;
makeMesh.writeMesh(); makeMesh.writeMesh();
Info<< nl << "End" << nl << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -62,28 +62,35 @@ int main(int argc, char *argv[])
{ {
argList::noParallel(); argList::noParallel();
argList::validArgs.append("pro-STAR prefix"); argList::validArgs.append("pro-STAR prefix");
argList::validOptions.insert("ascii", ""); argList::addBoolOption
argList::validOptions.insert("scale", "scale"); (
argList::validOptions.insert("solids", ""); "ascii",
"write in ASCII instead of binary format"
);
argList::addOption
(
"scale",
"scale",
"geometry scaling factor - default is 0.001 ([mm] to [m])"
);
argList::addBoolOption
(
"solids",
"retain solid cells and treat them like fluid cells"
);
argList args(argc, argv); argList args(argc, argv);
Time runTime(args.rootPath(), args.caseName()); Time runTime(args.rootPath(), args.caseName());
const stringList& params = args.additionalArgs(); const stringList& params = args.additionalArgs();
// default rescale from [mm] to [m] // default rescale from [mm] to [m]
scalar scaleFactor = 0.001; scalar scaleFactor = args.optionLookupOrDefault("scale", 0.001);
if (args.optionReadIfPresent("scale", scaleFactor))
{
if (scaleFactor <= 0) if (scaleFactor <= 0)
{ {
scaleFactor = 1; scaleFactor = 1;
} }
}
if (args.optionFound("solids")) meshReaders::STARCD::keepSolids = args.optionFound("solids");
{
meshReaders::STARCD::keepSolids = true;
}
// default to binary output, unless otherwise specified // default to binary output, unless otherwise specified
IOstream::streamFormat format = IOstream::BINARY; IOstream::streamFormat format = IOstream::BINARY;

View File

@ -41,7 +41,7 @@ int main(int argc, char *argv[])
{ {
argList::noParallel(); argList::noParallel();
argList::validArgs.append("STAR mesh file prefix"); argList::validArgs.append("STAR mesh file prefix");
argList::validOptions.insert("scale", "scale factor"); argList::addOption("scale", "scale factor");
argList args(argc, argv); argList args(argc, argv);
@ -50,8 +50,7 @@ int main(int argc, char *argv[])
FatalError.exit(); FatalError.exit();
} }
scalar scaleFactor = 1.0; scalar scaleFactor = args.optionLookupOrDefault("scale", 1.0);
args.optionReadIfPresent("scale", scaleFactor);
# include "createTime.H" # include "createTime.H"
@ -64,7 +63,7 @@ int main(int argc, char *argv[])
Info<< "Writing mesh" << endl; Info<< "Writing mesh" << endl;
makeMesh.writeMesh(); makeMesh.writeMesh();
Info<< nl << "End" << nl << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -30,7 +30,7 @@ Description
and run tetgen with -f option. and run tetgen with -f option.
Sample smesh file: Sample smesh file:
@verbatim
# cube.smesh -- A 10x10x10 cube # cube.smesh -- A 10x10x10 cube
8 3 8 3
1 0 0 0 1 0 0 0
@ -50,8 +50,9 @@ Description
4 2 6 7 3 65 4 2 6 7 3 65
0 0
0 0
@endverbatim
NOTE: Note
- for some reason boundary faces point inwards. I just reverse them - for some reason boundary faces point inwards. I just reverse them
always. Might use some geometric check instead. always. Might use some geometric check instead.
- marked faces might not actually be boundary faces of mesh. - marked faces might not actually be boundary faces of mesh.
@ -97,7 +98,7 @@ label findFace(const primitiveMesh& mesh, const face& f)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::validArgs.append("file prefix"); argList::validArgs.append("file prefix");
argList::validOptions.insert("noFaceFile", ""); argList::addBoolOption("noFaceFile");
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"

View File

@ -378,13 +378,13 @@ void writePointCells
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
timeSelector::addOptions(); timeSelector::addOptions();
argList::validOptions.insert("patchFaces", ""); argList::addBoolOption("patchFaces");
argList::validOptions.insert("patchEdges", ""); argList::addBoolOption("patchEdges");
argList::validOptions.insert("cell", "cellI"); argList::addOption("cell", "cellI");
argList::validOptions.insert("face", "faceI"); argList::addOption("face", "faceI");
argList::validOptions.insert("point", "pointI"); argList::addOption("point", "pointI");
argList::validOptions.insert("cellSet", "setName"); argList::addOption("cellSet", "setName");
argList::validOptions.insert("faceSet", "setName"); argList::addOption("faceSet", "setName");
# include "addRegionOption.H" # include "addRegionOption.H"
# include "setRootCase.H" # include "setRootCase.H"

View File

@ -42,7 +42,7 @@ Usage
@param -region \<name\> \n @param -region \<name\> \n
Specify an alternative mesh region. Specify an alternative mesh region.
@param -dict \<dictionary\> \n @param -dict \<filename\> \n
Specify an alternative dictionary for the block mesh description. Specify an alternative dictionary for the block mesh description.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -72,8 +72,18 @@ using namespace Foam;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::noParallel(); argList::noParallel();
argList::validOptions.insert("blockTopology", ""); argList::addBoolOption
argList::validOptions.insert("dict", "dictionary"); (
"blockTopology",
"write block edges and centres as .obj files"
);
argList::addOption
(
"dict",
"file",
"specify an alternative dictionary for the blockMesh description"
);
# include "addRegionOption.H" # include "addRegionOption.H"
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"
@ -83,10 +93,9 @@ int main(int argc, char *argv[])
word regionName; word regionName;
fileName polyMeshDir; fileName polyMeshDir;
if (args.optionFound("region")) if (args.optionReadIfPresent("region", regionName, polyMesh::defaultRegion))
{ {
// constant/<region>/polyMesh/blockMeshDict // constant/<region>/polyMesh/blockMeshDict
regionName = args.option("region");
polyMeshDir = regionName/polyMesh::meshSubDir; polyMeshDir = regionName/polyMesh::meshSubDir;
Info<< nl << "Generating mesh for region " << regionName << endl; Info<< nl << "Generating mesh for region " << regionName << endl;
@ -94,7 +103,6 @@ int main(int argc, char *argv[])
else else
{ {
// constant/polyMesh/blockMeshDict // constant/polyMesh/blockMeshDict
regionName = polyMesh::defaultRegion;
polyMeshDir = polyMesh::meshSubDir; polyMeshDir = polyMesh::meshSubDir;
} }
@ -363,7 +371,7 @@ int main(int argc, char *argv[])
} }
} }
Info<< nl << "End" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -58,7 +58,7 @@ using namespace Foam;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::validArgs.append("thickness"); argList::validArgs.append("thickness");
argList::validOptions.insert("overwrite", ""); argList::addBoolOption("overwrite");
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"
runTime.functionObjects().off(); runTime.functionObjects().off();
@ -89,7 +89,7 @@ int main(int argc, char *argv[])
// ~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~
scalar minRange = GREAT; scalar minRange = GREAT;
direction extrudeDir = -1; direction extrudeDir = 4; //illegal value.
for (direction dir = 0; dir < 3; dir++) for (direction dir = 0; dir < 3; dir++)
{ {

View File

@ -418,8 +418,8 @@ int main(int argc, char *argv[])
frontPatchFaces.setSize(layerFaces.size()); frontPatchFaces.setSize(layerFaces.size());
forAll(backPatchFaces, i) forAll(backPatchFaces, i)
{ {
backPatchFaces[i] = layerFaces[i][0]; backPatchFaces[i] = layerFaces[i].first();
frontPatchFaces[i] = layerFaces[i][layerFaces[i].size()-1]; frontPatchFaces[i] = layerFaces[i].last();
} }
// Create dummy fvSchemes, fvSolution // Create dummy fvSchemes, fvSolution

View File

@ -1,6 +1,6 @@
EXE_INC = \ EXE_INC = \
/* -g -DFULLDEBUG -O0 */ \ /* -g -DFULLDEBUG -O0 */ \
-I$(LIB_SRC)/decompositionMethods/decompositionMethods/lnInclude \ -I$(LIB_SRC)/parallel/decompositionMethods/lnInclude \
-I$(LIB_SRC)/mesh/autoMesh/lnInclude \ -I$(LIB_SRC)/mesh/autoMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \ -I$(LIB_SRC)/triSurface/lnInclude \

View File

@ -115,7 +115,7 @@ void writeMesh
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::validOptions.insert("overwrite", ""); argList::addBoolOption("overwrite");
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"
runTime.functionObjects().off(); runTime.functionObjects().off();

View File

@ -180,6 +180,12 @@ castellatedMeshControls
// NOTE: This point should never be on a face, always inside a cell, even // NOTE: This point should never be on a face, always inside a cell, even
// after refinement. // after refinement.
locationInMesh (5 0.28 0.43); locationInMesh (5 0.28 0.43);
// Whether any faceZones (as specified in the refinementSurfaces)
// are only on the boundary of corresponding cellZones or also allow
// free-standing zone faces. Not used if there are no faceZones.
allowFreeStandingZoneFaces true;
} }
@ -274,7 +280,8 @@ addLayersControls
maxThicknessToMedialRatio 0.3; maxThicknessToMedialRatio 0.3;
// Angle used to pick up medial axis points // Angle used to pick up medial axis points
minMedianAxisAngle 130; // Note: changed(corrected) w.r.t 16x! 90 degrees corresponds to 130 in 16x.
minMedianAxisAngle 90;
// Create buffer region for new layer terminations // Create buffer region for new layer terminations
nBufferCellsNoExtrude 0; nBufferCellsNoExtrude 0;

View File

@ -42,7 +42,7 @@ using namespace Foam;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::noParallel(); argList::noParallel();
argList::validOptions.insert("overwrite", ""); argList::addBoolOption("overwrite");
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"

View File

@ -71,7 +71,7 @@ int main(int argc, char *argv[])
{ {
argList::noParallel(); argList::noParallel();
argList::validArgs.append("feature angle[0-180]"); argList::validArgs.append("feature angle[0-180]");
argList::validOptions.insert("overwrite", ""); argList::addBoolOption("overwrite");
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"

View File

@ -189,7 +189,7 @@ int main(int argc, char *argv[])
currentSet.write(); currentSet.write();
} }
Info << nl << "End" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -49,9 +49,9 @@ int main(int argc, char *argv[])
{ {
timeSelector::addOptions(); timeSelector::addOptions();
# include "addRegionOption.H" # include "addRegionOption.H"
argList::validOptions.insert("noTopology", ""); argList::addBoolOption("noTopology");
argList::validOptions.insert("allGeometry", ""); argList::addBoolOption("allGeometry");
argList::validOptions.insert("allTopology", ""); argList::addBoolOption("allTopology");
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"

View File

@ -128,9 +128,9 @@ int main(int argc, char *argv[])
# include "addRegionOption.H" # include "addRegionOption.H"
argList::validArgs.append("faceZone"); argList::validArgs.append("faceZone");
argList::validArgs.append("patch"); argList::validArgs.append("patch");
argList::validOptions.insert("additionalPatches", "(patch2 .. patchN)"); argList::addOption("additionalPatches", "(patch2 .. patchN)");
argList::validOptions.insert("internalFacesOnly", ""); argList::addBoolOption("internalFacesOnly");
argList::validOptions.insert("overwrite", ""); argList::addBoolOption("overwrite");
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"
@ -186,7 +186,7 @@ int main(int argc, char *argv[])
{ {
newPatches.append(findPatchID(mesh, patchNames[i])); newPatches.append(findPatchID(mesh, patchNames[i]));
Info<< "Using additional patch " << patchNames[i] Info<< "Using additional patch " << patchNames[i]
<< " at index " << newPatches[newPatches.size()-1] << endl; << " at index " << newPatches.last() << endl;
} }
} }

View File

@ -517,7 +517,7 @@ void syncPoints
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
# include "addRegionOption.H" # include "addRegionOption.H"
argList::validOptions.insert("overwrite", ""); argList::addBoolOption("overwrite");
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"

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