Commit 368eec5a authored by henry's avatar henry
Browse files
parents d9b9d7f2 cd7cff1e
......@@ -49,6 +49,9 @@ doc/[Dd]oxygen/man
*.tar.gz
*.tgz
# ignore the persistent .build tag in the main directory
/.build
# ignore .timeStamp in the main directory
/.timeStamp
......
......@@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
Description
\*---------------------------------------------------------------------------*/
......@@ -48,7 +48,6 @@ int main(int argc, char *argv[])
}
myList.append(100.3);
myList.append(500.3);
Info<< nl << "And again using STL iterator: " << nl << endl;
......@@ -120,7 +119,18 @@ int main(int argc, char *argv[])
Info<< "element:" << *iter << endl;
}
Info<< nl << "Bye." << endl;
Info<< nl << "Testing transfer: " << nl << endl;
Info<< "original: " << myList << endl;
DLList<scalar> newList;
newList.transfer(myList);
Info<< nl << "source: " << myList << nl
<< nl << "target: " << newList << endl;
Info<< nl << "Done." << endl;
return 0;
}
......
......@@ -23,15 +23,18 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
Description
\*---------------------------------------------------------------------------*/
#include "OSspecific.H"
#include "scalar.H"
#include "IOstreams.H"
#include "Dictionary.H"
#include "PtrDictionary.H"
using namespace Foam;
......@@ -63,6 +66,36 @@ public:
};
class Scalar
{
scalar data_;
public:
Scalar()
:
data_(0)
{}
Scalar(scalar val)
:
data_(val)
{}
~Scalar()
{
Info <<"delete Scalar: " << data_ << endl;
}
friend Ostream& operator<<(Ostream& os, const Scalar& val)
{
os << val.data_;
return os;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
......@@ -92,12 +125,11 @@ int main(int argc, char *argv[])
Info<< "element : " << *iter;
}
Info<< dict.toc() << endl;
Info<< "keys: " << dict.toc() << endl;
delete dictPtr;
dictPtr = new Dictionary<ent>;
Dictionary<ent>& dict2 = *dictPtr;
Dictionary<ent> dict2;
for (int i = 0; i<10; i++)
{
......@@ -106,9 +138,79 @@ int main(int argc, char *argv[])
dict2.swapUp(ePtr);
}
Info<< dict2 << endl;
Info<< "dict:\n" << dict2 << endl;
Info<< nl << "Testing transfer: " << nl << endl;
Info<< "original: " << dict2 << endl;
Dictionary<ent> newDict;
newDict.transfer(dict2);
Info<< nl << "source: " << dict2 << nl
<< "keys: " << dict2.toc() << nl
<< "target: " << newDict << nl
<< "keys: " << newDict.toc() << endl;
PtrDictionary<Scalar> scalarDict;
for (int i = 0; i<10; i++)
{
word key("ent" + name(i));
scalarDict.insert(key, new Scalar(1.3*i));
}
Info<< nl << "scalarDict1: " << endl;
for
(
PtrDictionary<Scalar>::const_iterator iter = scalarDict.begin();
iter != scalarDict.end();
++iter
)
{
Info<< " = " << iter() << endl;
}
PtrDictionary<Scalar> scalarDict2;
for (int i = 8; i<15; i++)
{
word key("ent" + name(i));
scalarDict2.insert(key, new Scalar(1.3*i));
}
Info<< nl << "scalarDict2: " << endl;
for
(
PtrDictionary<Scalar>::const_iterator iter = scalarDict2.begin();
iter != scalarDict2.end();
++iter
)
{
Info<< "elem = " << *iter << endl;
}
scalarDict.transfer(scalarDict2);
Scalar* p = scalarDict.lookupPtr("ent8");
// This does not (yet) work
// Scalar* q = scalarDict.remove("ent10");
if (p)
{
Info << "found: " << *p << endl;
}
else
{
Info << "no p: " << endl;
}
scalarDict.clear();
// Info<< " = " << *iter << endl;
Info<< nl << "Bye." << endl;
Info<< nl << "Done." << endl;
return 0;
}
......
......@@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
Description
\*---------------------------------------------------------------------------*/
......@@ -52,6 +52,13 @@ public:
:
data_(s)
{}
friend Ostream& operator<<(Ostream& os, const Scalar& s)
{
os << s.data_;
return os;
}
};
......@@ -68,10 +75,8 @@ int main(int argc, char *argv[])
}
myList.append(new Scalar(100.3));
myList.append(new Scalar(500.3));
Info<< nl << "And again using STL iterator: " << nl << endl;
for
......@@ -99,6 +104,15 @@ int main(int argc, char *argv[])
}
Info<< nl << "Testing transfer: " << nl << endl;
Info<< "original: " << myList << endl;
ISLList<Scalar> newList;
newList.transfer(myList);
Info<< nl << "source: " << myList << nl
<< nl << "target: " << newList << endl;
Info<< nl << "Bye." << endl;
return 0;
}
......
PtrListTest.C
EXE = $(FOAM_USER_APPBIN)/PtrListTest
......@@ -23,27 +23,88 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
Description
\*---------------------------------------------------------------------------*/
#include "OSspecific.H"
#include "scalar.H"
#include "IOstreams.H"
#include "IFstream.H"
#include "dictionary.H"
#include "PtrList.H"
using namespace Foam;
class Scalar
{
scalar data_;
public:
Scalar()
:
data_(0)
{}
Scalar(scalar val)
:
data_(val)
{}
~Scalar()
{
Info <<"delete Scalar: " << data_ << endl;
}
friend Ostream& operator<<(Ostream& os, const Scalar& val)
{
os << val.data_;
return os;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
IFstream dictStream("testDict");
dictionary testDict(dictStream);
PtrList<Scalar> list1(10);
PtrList<Scalar> list2(15);
forAll(list1, i)
{
list1.set(i, new Scalar(1.3*i));
}
forAll(list2, i)
{
list2.set(i, new Scalar(10 + 1.3*i));
}
Info<<"list1: " << list1 << endl;
Info<<"list2: " << list2 << endl;
Info<<"indirectly delete some items via set(.., 0) :" << endl;
for (label i = 0; i < 3; i++)
{
list1.set(i, 0);
}
Info<<"transfer list2 -> list1:" << endl;
list1.transfer(list2);
Info<<"list1: " << list1 << endl;
Info<<"list2: " << list2 << endl;
Info<<"indirectly delete some items via setSize :" << endl;
list1.setSize(4);
Info<< testDict << endl;
Info<<"list1: " << list1 << endl;
Info<< nl << "Done." << endl;
return 0;
}
......
......@@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
Description
\*---------------------------------------------------------------------------*/
......@@ -48,10 +48,8 @@ int main(int argc, char *argv[])
}
myList.append(100.3);
myList.append(500.3);
Info<< nl << "And again using STL iterator: " << nl << endl;
for
......@@ -99,7 +97,27 @@ int main(int argc, char *argv[])
Info<< "element:" << *iter2 << endl;
}
Info<< nl << "Bye." << endl;
for (int i = 0; i<10; i++)
{
myList.append(1.3*i);
}
myList.append(100.3);
myList.append(500.3);
Info<< nl << "Testing transfer: " << nl << endl;
Info<< "original: " << myList << endl;
SLList<scalar> newList;
newList.transfer(myList);
Info<< nl << "source: " << myList << nl
<< nl << "target: " << newList << endl;
Info<< nl << "Done." << endl;
return 0;
}
......
......@@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
Description
\*---------------------------------------------------------------------------*/
......@@ -113,7 +113,20 @@ int main(int argc, char *argv[])
Info<< dict2 << endl;
Info<< nl << "Bye." << endl;
Info<< nl << "Testing transfer: " << nl << endl;
Info<< "original: " << dict2 << endl;
UDictionary<ent> newDict;
newDict.transfer(dict2);
Info<< nl << "source: " << dict2 << nl
<< "keys: " << dict2.toc() << nl
<< "target: " << newDict << nl
<< "keys: " << newDict.toc() << endl;
Info<< nl << "Done." << endl;
return 0;
}
......
......@@ -41,34 +41,44 @@ using namespace Foam;
int main(int argc, char *argv[])
{
Info<< dictionary(IFstream("testDict")()) << endl;
{
dictionary dict(IFstream("testDict")());
Info<< "dict: " << dict << nl
<< "toc: " << dict.toc() << nl
<< "keys: " << dict.keys() << nl
<< "patterns: " << dict.keys(true) << endl;
}
IOobject::writeDivider(Info);
{
dictionary dict(IFstream("testDictRegex")());
dict.add(keyType("fooba[rz]", true), "anything");
Info<< "dict:" << dict << endl;
Info<< "dict:" << dict << nl
<< "toc: " << dict.toc() << nl
<< "keys: " << dict.keys() << nl
<< "patterns: " << dict.keys(true) << endl;
// Wildcard find.
Info<< "Wildcard find \"abc\" in top directory : "
Info<< "Pattern find \"abc\" in top directory : "
<< dict.lookup("abc") << endl;
Info<< "Wildcard find \"abc\" in sub directory : "
Info<< "Pattern find \"abc\" in sub directory : "
<< dict.subDict("someDict").lookup("abc")
<< endl;
Info<< "Recursive wildcard find \"def\" in sub directory : "
Info<< "Recursive pattern find \"def\" in sub directory : "
<< dict.subDict("someDict").lookup("def", true)
<< endl;
Info<< "Recursive wildcard find \"foo\" in sub directory : "
Info<< "Recursive pattern find \"foo\" in sub directory : "
<< dict.subDict("someDict").lookup("foo", true)
<< endl;
Info<< "Recursive wildcard find \"fooz\" in sub directory : "
Info<< "Recursive pattern find \"fooz\" in sub directory : "
<< dict.subDict("someDict").lookup("fooz", true)
<< endl;
Info<< "Recursive wildcard find \"bar\" in sub directory : "
Info<< "Recursive pattern find \"bar\" in sub directory : "
<< dict.subDict("someDict").lookup("bar", true)
<< endl;
Info<< "Recursive wildcard find \"xxx\" in sub directory : "
Info<< "Recursive pattern find \"xxx\" in sub directory : "
<< dict.subDict("someDict").lookup("xxx", true)
<< endl;
}
......
......@@ -18,8 +18,10 @@ FoamFile
".*" parentValue1;
"[n-z].*" parentValue2;
"f.*" parentValue3;
keyX parentValue4;
keyY parentValue5;
someDict
"(.*)Dict"
{
foo subdictValue0;
bar $f.*; // should this really match 'foo'?
......@@ -28,7 +30,7 @@ someDict
"a.*c" subdictValue3;
"ab.*" subdictValue2;
"a.*" subdictValue1;
abcd subdictValue4;
abcd \1;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -32,6 +32,7 @@ Description
#include "fileName.H"
#include "IOstreams.H"
#include "OSspecific.H"
using namespace Foam;
......@@ -57,7 +58,16 @@ int main()
Info<< "pathName.components() = " << pathName.components() << endl;
Info<< "pathName.component(2) = " << pathName.component(2) << endl;
Info<< "end" << endl;
// test findEtcFile
Info<< "\n\nfindEtcFile tests:" << nl
<< " controlDict => " << findEtcFile("controlDict") << nl
<< " badName => " << findEtcFile("badName") << endl;
Info<< "This should emit a fatal error:" << endl;
Info<< " badName(die) => " << findEtcFile("badName", true) << nl
<< endl;
Info<< "\nEnd" << endl;
return 0;
}
......
getRoots.C
EXE = $(FOAM_USER_APPBIN)/getRoots
/* EXE_INC = -I$(LIB_SRC)/finiteVolume/lnInclude */
/* EXE_LIBS = -lfiniteVolume */
#include "dictionary.H"
#include "fileNameList.H"
#include "IFstream.H"
#include "OSspecific.H"
using namespace Foam;
int main()
{
Info << "\nReading Roots" << endl;
IFstream rootsFile(home()/".foam/apps/openDX/roots");
fileNameList rootsList(dictionary(rootsFile).lookup("roots"));
char** rootsStrings = new char*[rootsList.size() + 1];
rootsStrings[rootsList.size()] = 0;
if (rootsList.size())
{
for (int i=0; i<rootsList.size(); i++)
{
rootsStrings[i] = new char[rootsList[i].size() + 1];
strcpy(rootsStrings[i], rootsList[i].c_str());
Info<< rootsStrings[i] << endl;
}
}
return 0;
}
calcEntry/calcEntry.C
dictionaryTest.C
EXE = $(FOAM_USER_APPBIN)/dictionaryTest
FoamFile
{
version 2.0;
format ascii;
root "";
case "";
instance "";
local "";
class dictionary;
object testDict;
}
dimensions [ 0 2 -2 0 0 0 0 ];
internalField uniform 1;
active
{
type turbulentIntensityKineticEnergyInlet;
intensity 0.1;
value $internalField;
}
inactive
{
type zeroGradient;
}
boundaryField
{
Default_Boundary_Region
{
type zeroGradient;
}