Commit ac084b84 authored by Andrew Heather's avatar Andrew Heather
Browse files
parents 9eaaff14 3d126aca
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......
......@@ -52,27 +52,47 @@ int main(int argc, char *argv[])
list1 = -1;
list1.print(Info);
Info<< "\ntest zero\n";
list1 = 0;
list1.print(Info);
Info<< "\ntest set() with default argument (max_value)\n";
list1.set(3);
list1.print(Info);
Info<< "\ntest assign between references\n";
list1[2] = 3;
list1[4] = list1[2];
list1.print(Info);
Info<< "\ntest assign between references, with chaining\n";
list1[4] = list1[2] = 1;
list1[0] = list1[4] = 1;
list1.print(Info);
Info<< "\ntest assign between references, with chaining and auto-vivify\n";
list1[1] = list1[8] = list1[10] = list1[14] = 2;
list1.print(Info);
{
const PackedList<3>& constLst = list1;
Info<< "\ntest operator[] const with out-of-range index\n";
constLst.print(Info);
if (!constLst[20])
if (constLst[20])
{
Info<< "[20] is true (unexpected)\n";
}
else
{
Info<< "[20] is false (expected) list size should be unchanged (const)\n";
}
constLst.print(Info);
Info<< "\ntest operator[] non-const with out-of-range index\n";
if (!list1[20])
if (list1[20])
{
Info<< "[20] is true (unexpected)\n";
}
else
{
Info<< "[20] is false (expected) but list was resized?? (non-const)\n";
}
......@@ -91,6 +111,14 @@ int main(int argc, char *argv[])
list1.resize(8, list1.max_value());
list1.print(Info);
Info<< "\ntest flip() function\n";
list1.flip();
list1.print(Info);
Info<< "\nre-flip()\n";
list1.flip();
list1.print(Info);
Info<< "\ntest set() function\n";
list1.set(1, 5);
list1.print(Info);
......@@ -188,15 +216,23 @@ int main(int argc, char *argv[])
{
Info<< "\ntest assignment of iterator\n";
list1.print(Info);
PackedList<3>::iterator cit = list1[25];
cit.print(Info);
Info<< "cend()\n";
list1.end().print(Info);
PackedList<3>::iterator cit = list1[100];
Info<< "out-of-range: ";
cit.print(Info);
cit = list1[15];
Info<< "in-range: ";
cit.print(Info);
Info<< "out-of-range: ";
cit = list1[1000];
cit.print(Info);
}
for
(
PackedList<3>::iterator cit = list1[5];
PackedList<3>::iterator cit = list1[30];
cit != list1.end();
++cit
)
......@@ -204,14 +240,19 @@ int main(int argc, char *argv[])
cit.print(Info);
}
// Info<< "\ntest operator[] auto-vivify\n";
// const unsigned int val = list1[45];
//
// Info<< "list[45]:" << val << "\n";
// list1[45] = list1.max_value();
// Info<< "list[45]:" << list1[45] << "\n";
// list1[49] = list1.max_value();
// list1.print(Info);
Info<< "\ntest operator[] auto-vivify\n";
Info<< "size:" << list1.size() << "\n";
const unsigned int val = list1[45];
Info<< "list[45]:" << val << "\n";
Info<< "size after read:" << list1.size() << "\n";
list1[45] = list1.max_value();
Info<< "size after write:" << list1.size() << "\n";
Info<< "list[45]:" << list1[45] << "\n";
list1[49] = list1[100];
list1.print(Info);
Info<< "\ntest copy constructor + append\n";
......@@ -235,6 +276,23 @@ int main(int argc, char *argv[])
Info<< "removed final value: " << list3.remove() << endl;
list3.print(Info);
List<bool> list4(4, true);
{
const List<bool>& constLst = list4;
Info<< "\ntest operator[] const with out-of-range index\n";
Info<< constLst << endl;
if (constLst[20])
{
Info<< "[20] is true (unexpected)\n";
}
else
{
Info<< "[20] is false (expected) list size should be unchanged (const)\n";
}
Info<< constLst << endl;
}
Info<< "\n\nDone.\n";
return 0;
......
......@@ -32,6 +32,7 @@ Description
#include "fileName.H"
#include "SubList.H"
#include "IOobject.H"
#include "IOstreams.H"
#include "OSspecific.H"
......@@ -61,7 +62,8 @@ int main()
<< endl;
// try with different combination
for (label start = 0; start < wrdList.size(); ++start)
// The final one should emit warnings
for (label start = 0; start <= wrdList.size(); ++start)
{
fileName instance, local;
word name;
......@@ -69,26 +71,28 @@ int main()
fileName path(SubList<word>(wrdList, wrdList.size()-start, start));
fileName path2 = "." / path;
path.IOobjectComponents
IOobject::fileNameComponents
(
path,
instance,
local,
name
);
Info<< "IOobjectComponents for " << path << nl
Info<< "IOobject::fileNameComponents for " << path << nl
<< " instance = " << instance << nl
<< " local = " << local << nl
<< " name = " << name << endl;
path2.IOobjectComponents
IOobject::fileNameComponents
(
path2,
instance,
local,
name
);
Info<< "IOobjectComponents for " << path2 << nl
Info<< "IOobject::fileNameComponents for " << path2 << nl
<< " instance = " << instance << nl
<< " local = " << local << nl
<< " name = " << name << endl;
......
......@@ -69,7 +69,7 @@ void checkFaceEdges
forAll(f, fp)
{
label fp1 = (fp + 1) % f.size();
label fp1 = f.fcIndex(fp);
if (edges[myEdges[fp]] != edge(f[fp], f[fp1]))
{
......
testSHA1.C
EXE = $(FOAM_USER_APPBIN)/testSHA1
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
testSHA1
Description
\*---------------------------------------------------------------------------*/
#include "OSHA1stream.H"
#include "IStringStream.H"
#include "dictionary.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char * argv[])
{
SHA1 sha;
SHA1Digest shaDig;
std::string str("The quick brown fox jumps over the lazy dog");
Info<< shaDig << nl;
Info<< SHA1("The quick brown fox jumps over the lazy dog") << nl;
sha.append("The quick brown fox jumps over the lazy dog");
Info<< sha << nl;
sha.clear();
sha.append("The quick brown fox jumps over the lazy dog");
shaDig = sha;
sha.append("\n");
Info<< sha << nl;
Info<< shaDig << nl;
if (sha == shaDig)
{
Info<<"SHA1 digests are identical\n";
}
else
{
Info<<"SHA1 digests are different\n";
}
Info<<"lhs:" << sha << " rhs:" << shaDig << endl;
// start over:
sha.clear();
sha.append(str);
SHA1Digest shaDig_A = sha;
SHA1 sha_A = sha;
sha.append("\n");
Info<< "digest1: " << sha_A << nl;
Info<< "digest2: " << sha << nl;
// start over:
sha.clear();
sha.append("\"");
sha.append(str);
sha.append("\"");
Info<< "digest3: " << sha << nl;
// try the output buffer interface
{
OSHA1stream os;
os << str;
Info<< os.digest() << endl;
os << str;
Info<< os.digest() << endl;
os.rewind();
os << "The quick brown fox jumps over the lazy dog";
Info<< os.digest() << endl;
}
{
dictionary dict
(
IStringStream
(
"parent { Default_Boundary_Region { type zeroGradient; } }"
"inlet_1 { value inlet_1; }"
"inlet_2 { value inlet_2; }"
"inlet_3 { value inlet_3; }"
"\"inlet_.*\" { value XXX; }"
) ()
);
Info<< "dict:" << endl;
dict.write(Info, false);
dictionary dict2(dict);
OSHA1stream os;
dict.write(os, false);
Info<< os.digest() << endl;
Info<< dict2.digest() << endl;
}
return 0;
}
......@@ -74,20 +74,17 @@ labelList getSortedEdges
const edge& e = edges[edgeI];
label fp = findIndex(f, e[0]);
label fp1 = (fp+1) % f.size();
label fp1 = f.fcIndex(fp);
if (f[fp1] == e[1])
{
// Edgei in fp-fp1 order
// EdgeI between fp -> fp1
faceEdges[fp] = edgeI;
}
else
{
// Edgei between fp-1 and fp
label fpMin1 = (fp == 0 ? f.size()-1 : fp-1);
faceEdges[fpMin1] = edgeI;
// EdgeI between fp-1 -> fp
faceEdges[f.rcIndex(fp)] = edgeI;
}
}
......
......@@ -211,7 +211,7 @@ void Foam::cellSplitter::setRefinement
// Add other pyramids
for (label i = 1; i < cFaces.size(); i++)
{
{
label addedCellI =
meshMod.setAction
(
......@@ -277,7 +277,7 @@ void Foam::cellSplitter::setRefinement
label index = findIndex(f0, e[0]);
bool edgeInFaceOrder = (f0[(index+1) % f0.size()] == e[1]);
bool edgeInFaceOrder = (f0[f0.fcIndex(index)] == e[1]);
// Check if cellI is the face owner
......@@ -323,7 +323,7 @@ void Foam::cellSplitter::setRefinement
label index = findIndex(f1, e[0]);
bool edgeInFaceOrder = (f1[(index+1) % f1.size()] == e[1]);
bool edgeInFaceOrder = (f1[f1.fcIndex(index)] == e[1]);
// Check if cellI is the face owner
......@@ -362,7 +362,7 @@ void Foam::cellSplitter::setRefinement
}
}
}
//
// Update all existing faces for split owner or neighbour.
......@@ -441,7 +441,7 @@ void Foam::cellSplitter::setRefinement
label patchID, zoneID, zoneFlip;
getFaceInfo(faceI, patchID, zoneID, zoneFlip);
meshMod.setAction
(
polyModifyFace
......@@ -458,7 +458,7 @@ void Foam::cellSplitter::setRefinement
)
);
}
faceUpToDate[faceI] = true;
}
}
......
......@@ -615,7 +615,7 @@ int main(int argc, char *argv[])
{
fileName ccmFile(args.additionalArgs()[0]);
if (!exists(ccmFile))
if (!isFile(ccmFile))
{
FatalErrorIn(args.executable())
<< "Cannot read file " << ccmFile
......
......@@ -129,14 +129,14 @@ int main(int argc, char *argv[])
Info<< "Reading .face file for boundary information" << nl << endl;
}
if (!exists(nodeFile) || !exists(eleFile))
if (!isFile(nodeFile) || !isFile(eleFile))
{
FatalErrorIn(args.executable())
<< "Cannot read " << nodeFile << " or " << eleFile
<< exit(FatalError);
}
if (readFaceFile && !exists(faceFile))
if (readFaceFile && !isFile(faceFile))
{
FatalErrorIn(args.executable())
<< "Cannot read " << faceFile << endl
......
......@@ -108,7 +108,11 @@ int main(int argc, char *argv[])
(
new IOobject
(
( dictPath.isDir() ? dictPath/dictName : dictPath ),
(
isDir(dictPath)
? dictPath/dictName
: dictPath
),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
......
......@@ -746,7 +746,8 @@ int main(int argc, char *argv[])
Pout<< "Reading commands from file " << batchFile << endl;
if (!exists(batchFile))
// we also cannot handle .gz files
if (!isFile(batchFile, false))
{
FatalErrorIn(args.executable())
<< "Cannot open file " << batchFile << exit(FatalError);
......
......@@ -627,7 +627,7 @@ autoPtr<mapPolyMesh> createRegionMesh
Info<< "Testing:" << io.objectPath() << endl;
if (!io.headerOk())
//if (!exists(io.objectPath()))
// if (!exists(io.objectPath()))
{
Info<< "Writing dummy " << regionName/io.name() << endl;
dictionary dummyDict;
......
......@@ -105,7 +105,7 @@ int main(int argc, char *argv[])
// determine the existing processor count directly
label nProcs = 0;
while (dir(runTime.path()/(word("processor") + name(nProcs))))
while (isDir(runTime.path()/(word("processor") + name(nProcs))))
{
++nProcs;
}
......@@ -480,7 +480,7 @@ int main(int argc, char *argv[])
// Any uniform data to copy/link?
fileName uniformDir("uniform");
if (dir(runTime.timePath()/uniformDir))
if (isDir(runTime.timePath()/uniformDir))
{
Info<< "Detected additional non-decomposed files in "
<< runTime.timePath()/uniformDir
......
......@@ -59,7 +59,7 @@ manualCoeffs
}
//// Is the case distributred
//// Is the case distributed
//distributed yes;
//// Per slave (so nProcs-1 entries) the directory above the case.
//roots
......
......@@ -63,7 +63,7 @@ int main(int argc, char *argv[])
// determine the processor count directly
label nProcs = 0;
while (dir(args.path()/(word("processor") + name(nProcs))))
while (isDir(args.path()/(word("processor") + name(nProcs))))
{
++nProcs;
}
......@@ -383,7 +383,7 @@ int main(int argc, char *argv[])
// the master processor.
fileName uniformDir0 = databases[0].timePath()/"uniform";
if (dir(uniformDir0))
if (isDir(uniformDir0))
{
cp(uniformDir0, runTime.timePath());
}
......
......@@ -355,7 +355,7 @@ int main(int argc, char *argv[])
while
(
exists
isDir
(
args.rootPath()
/ args.caseName()
......
......@@ -503,7 +503,7 @@ int main(int argc, char *argv[])
# include "setRootCase.H"
// Create processor directory if non-existing
if (!Pstream::master() && !dir(args.path()))
if (!Pstream::master() && !isDir(args.path()))
{
Pout<< "Creating case directory " << args.path() << endl;
mkDir(args.path());
......@@ -525,7 +525,7 @@ int main(int argc, char *argv[])
const fileName meshDir = runTime.path()/masterInstDir/polyMesh::meshSubDir;
boolList haveMesh(Pstream::nProcs(), false);
haveMesh[Pstream::myProcNo()] = dir(meshDir);
haveMesh[Pstream::myProcNo()] = isDir(meshDir);
Pstream::gatherList(haveMesh);
Pstream::scatterList(haveMesh);
Info<< "Per processor mesh availability : " << haveMesh << endl;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment