Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-plus into develop

This commit is contained in:
mattijs
2018-02-14 10:17:32 +00:00
100 changed files with 1572 additions and 819 deletions

View File

@ -62,15 +62,8 @@ public:
{ {
public: public:
class hash struct hash
:
public Hash<interfacePair>
{ {
public:
hash()
{}
label operator()(const interfacePair& key) const label operator()(const interfacePair& key) const
{ {
return word::hash()(key.first()) + word::hash()(key.second()); return word::hash()(key.first()) + word::hash()(key.second());
@ -80,8 +73,7 @@ public:
// Constructors // Constructors
interfacePair() interfacePair() {} // = default
{}
interfacePair(const word& alpha1Name, const word& alpha2Name) interfacePair(const word& alpha1Name, const word& alpha2Name)
: :

View File

@ -74,30 +74,16 @@ public:
{ {
public: public:
class symmHash struct symmHash
:
public Hash<interfacePair>
{ {
public:
symmHash()
{}
label operator()(const interfacePair& key) const label operator()(const interfacePair& key) const
{ {
return word::hash()(key.first()) + word::hash()(key.second()); return word::hash()(key.first()) + word::hash()(key.second());
} }
}; };
class hash struct hash
:
public Hash<interfacePair>
{ {
public:
hash()
{}
label operator()(const interfacePair& key) const label operator()(const interfacePair& key) const
{ {
return word::hash()(key.first(), word::hash()(key.second())); return word::hash()(key.first(), word::hash()(key.second()));
@ -107,8 +93,7 @@ public:
// Constructors // Constructors
interfacePair() interfacePair() {} // = default
{}
interfacePair(const word& alpha1Name, const word& alpha2Name) interfacePair(const word& alpha1Name, const word& alpha2Name)
: :
@ -233,8 +218,7 @@ public:
//- Destructor //- Destructor
virtual ~multiphaseSystem() virtual ~multiphaseSystem() = default;
{}
// Member Functions // Member Functions

View File

@ -71,15 +71,8 @@ public:
{ {
public: public:
class hash struct hash
:
public Hash<interfacePair>
{ {
public:
hash()
{}
label operator()(const interfacePair& key) const label operator()(const interfacePair& key) const
{ {
return word::hash()(key.first()) + word::hash()(key.second()); return word::hash()(key.first()) + word::hash()(key.second());
@ -89,8 +82,7 @@ public:
// Constructors // Constructors
interfacePair() interfacePair() {} // = default
{}
interfacePair(const word& alpha1Name, const word& alpha2Name) interfacePair(const word& alpha1Name, const word& alpha2Name)
: :
@ -196,8 +188,7 @@ public:
//- Destructor //- Destructor
virtual ~multiphaseMixture() virtual ~multiphaseMixture() = default;
{}
// Member Functions // Member Functions

View File

@ -27,14 +27,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::phasePairKey::hash::hash()
{}
Foam::phasePairKey::phasePairKey()
{}
Foam::phasePairKey::phasePairKey Foam::phasePairKey::phasePairKey
( (
const word& name1, const word& name1,
@ -47,12 +39,6 @@ Foam::phasePairKey::phasePairKey
{} {}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::phasePairKey::~phasePairKey()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
bool Foam::phasePairKey::ordered() const bool Foam::phasePairKey::ordered() const
@ -94,13 +80,13 @@ bool Foam::operator==
const phasePairKey& b const phasePairKey& b
) )
{ {
const label c = Pair<word>::compare(a,b); const label cmp = Pair<word>::compare(a,b);
return return
(a.ordered_ == b.ordered_) (a.ordered_ == b.ordered_)
&& ( && (
(a.ordered_ && (c == 1)) (a.ordered_ && (cmp == 1))
|| (!a.ordered_ && (c != 0)) || (!a.ordered_ && (cmp != 0))
); );
} }
@ -127,7 +113,7 @@ Foam::Istream& Foam::operator>>(Istream& is, phasePairKey& key)
{ {
key.ordered_ = false; key.ordered_ = false;
} }
else if(temp[1] == "in") else if (temp[1] == "in")
{ {
key.ordered_ = true; key.ordered_ = true;
} }

View File

@ -40,7 +40,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward declaration of friend functions and operators // Forward declarations
class phasePairKey; class phasePairKey;
@ -59,41 +59,24 @@ class phasePairKey
: :
public Pair<word> public Pair<word>
{ {
public:
class hash
:
public Hash<phasePairKey>
{
public:
// Constructors
// Construct null
hash();
// Member operators
// Generate a hash from a phase pair key
label operator()(const phasePairKey& key) const;
};
private:
// Private data // Private data
//- Flag to indicate whether ordering is important //- Flag to indicate whether ordering is important
bool ordered_; bool ordered_;
public: public:
struct hash
{
// Generate a hash from a phase pair key
label operator()(const phasePairKey& key) const;
};
// Constructors // Constructors
//- Construct null //- Construct null
phasePairKey(); phasePairKey() {} // = default
//- Construct from names and the ordering flag //- Construct from names and the ordering flag
phasePairKey phasePairKey
@ -105,7 +88,7 @@ public:
// Destructor // Destructor
virtual ~phasePairKey(); virtual ~phasePairKey() = default;
// Access // Access

View File

@ -27,14 +27,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::phasePairKey::hash::hash()
{}
Foam::phasePairKey::phasePairKey()
{}
Foam::phasePairKey::phasePairKey Foam::phasePairKey::phasePairKey
( (
const word& name1, const word& name1,
@ -47,12 +39,6 @@ Foam::phasePairKey::phasePairKey
{} {}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::phasePairKey::~phasePairKey()
{}
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
Foam::label Foam::phasePairKey::hash::operator() Foam::label Foam::phasePairKey::hash::operator()
@ -86,13 +72,13 @@ bool Foam::operator==
const phasePairKey& b const phasePairKey& b
) )
{ {
const label c = Pair<word>::compare(a,b); const label cmp = Pair<word>::compare(a,b);
return return
(a.ordered_ == b.ordered_) (a.ordered_ == b.ordered_)
&& ( && (
(a.ordered_ && (c == 1)) (a.ordered_ && (cmp == 1))
|| (!a.ordered_ && (c != 0)) || (!a.ordered_ && (cmp != 0))
); );
} }
@ -119,7 +105,7 @@ Foam::Istream& Foam::operator>>(Istream& is, phasePairKey& key)
{ {
key.ordered_ = false; key.ordered_ = false;
} }
else if(temp[1] == "in") else if (temp[1] == "in")
{ {
key.ordered_ = true; key.ordered_ = true;
} }

View File

@ -40,7 +40,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward declaration of friend functions and operators // Forward declarations
class phasePairKey; class phasePairKey;
@ -59,48 +59,36 @@ class phasePairKey
: :
public Pair<word> public Pair<word>
{ {
public:
class hash
:
public Hash<phasePairKey>
{
public:
// Constructors
// Construct null
hash();
// Member operators
// Generate a hash from a phase pair key
label operator()(const phasePairKey& key) const;
};
private:
// Private data // Private data
//- Flag to indicate whether ordering is important //- Flag to indicate whether ordering is important
bool ordered_; bool ordered_;
public: public:
struct hash
{
// Generate a hash from a phase pair key
label operator()(const phasePairKey& key) const;
};
// Constructors // Constructors
//- Construct null //- Construct null
phasePairKey(); phasePairKey() {} // = default
//- Construct from names and the ordering flag //- Construct from names and the ordering flag
phasePairKey(const word& name1, const word& name2, const bool ordered); phasePairKey
(
const word& name1,
const word& name2,
const bool ordered
);
// Destructor // Destructor
virtual ~phasePairKey(); virtual ~phasePairKey() = default;
// Friend Operators // Friend Operators

View File

@ -56,7 +56,7 @@ int main(int argc, char *argv[])
setA = { "kjhk", "kjhk2", "abced" }; setA = { "kjhk", "kjhk2", "abced" };
HashTable<label, word> tableA HashTable<label> tableA
{ {
{ "value1", 1 }, { "value1", 1 },
{ "value2", 2 }, { "value2", 2 },

View File

@ -48,6 +48,23 @@ See also
#include <list> #include <list>
#include <numeric> #include <numeric>
#include <functional>
namespace Foam
{
// Verify inheritance
class MyStrings
:
public List<string>
{
public:
using List<string>::List;
};
} // end namespace Foam
using namespace Foam; using namespace Foam;
@ -66,6 +83,14 @@ void testFind(const T& val, const ListType& lst)
} }
void printMyString(const UList<string>& lst)
{
MyStrings slist2(lst);
Info<<slist2 << nl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program: // Main program:
@ -76,6 +101,7 @@ int main(int argc, char *argv[])
argList::addOption("wordList", "wordList"); argList::addOption("wordList", "wordList");
argList::addOption("stringList", "stringList"); argList::addOption("stringList", "stringList");
argList::addOption("float", "xx"); argList::addOption("float", "xx");
argList::addBoolOption("transform", "Test List::createList functionality");
argList::addBoolOption("flag"); argList::addBoolOption("flag");
#include "setRootCase.H" #include "setRootCase.H"
@ -336,6 +362,85 @@ int main(int argc, char *argv[])
Info<<"-flag:" << args["flag"] << endl; Info<<"-flag:" << args["flag"] << endl;
} }
if (args.found("transform"))
{
Info<< nl << "Test List::createList functionality" << nl;
const auto labels = identity(15);
Info<< "labels: " << flatOutput(labels) << endl;
{
auto scalars = List<scalar>::createList
(
labels,
[](const label& val){ return scalar(1.5*val); }
);
Info<< "scalars: " << flatOutput(scalars) << endl;
}
{
auto vectors = List<vector>::createList
(
labels,
[](const label& val){ return vector(1.2*val, -1.2*val, 0); }
);
Info<< "vectors: " << flatOutput(vectors) << endl;
}
{
auto longs = List<long>::createList
(
labels,
[](const label& val){ return val; }
);
Info<< "longs: " << flatOutput(longs) << endl;
}
{
auto negs = List<label>::createList
(
labels,
std::negate<label>()
);
Info<< "negs: " << flatOutput(negs) << endl;
}
{
auto scalars = List<scalar>::createList
(
labelRange::null.cbegin(),
labelRange::identity(15).cend(),
[](const label& val){ return scalar(-1.125*val); }
);
Info<< "scalars: " << flatOutput(scalars) << endl;
}
#if WM_LABEL_SIZE == 32
{
List<int64_t> input(10);
std::iota(input.begin(), input.end(), 0);
auto output = List<label>::createList
(
input,
toLabel<int64_t>()
);
Info<< "label (from int64): " << flatOutput(output) << endl;
}
#elif WM_LABEL_SIZE == 64
{
List<int32_t> input(10);
std::iota(input.begin(), input.end(), 0);
auto output = List<label>::createList
(
input,
toLabel<int32_t>()
);
Info<< "label (from int32): " << flatOutput(output) << endl;
}
#endif
}
if (args.readIfPresent<scalar>("float", xxx)) if (args.readIfPresent<scalar>("float", xxx))
{ {
Info<<"read float " << xxx << endl; Info<<"read float " << xxx << endl;
@ -354,6 +459,8 @@ int main(int argc, char *argv[])
if (args.found("stringList")) if (args.found("stringList"))
{ {
sLst = args.readList<string>("stringList"); sLst = args.readList<string>("stringList");
printMyString(sLst);
} }
Info<< nl Info<< nl

View File

@ -67,7 +67,7 @@ int main(int argc, char *argv[])
{ {
entry* e = dict1.add entry* e = dict1.add
( (
Foam::name("entry%d", i), word::printf("entry%d", i),
string("entry" + Foam::name(i)) string("entry" + Foam::name(i))
); );
entryInfo(e); entryInfo(e);
@ -76,7 +76,7 @@ int main(int argc, char *argv[])
{ {
entry* e = tmpdict.add entry* e = tmpdict.add
( (
Foam::name("subentry%d", i), word::printf("subentry%d", i),
string("subentry" + Foam::name(i)) string("subentry" + Foam::name(i))
); );
entryInfo(e); entryInfo(e);
@ -85,7 +85,7 @@ int main(int argc, char *argv[])
{ {
entry* e = dict1.add entry* e = dict1.add
( (
Foam::name("dict%d", i), word::printf("dict%d", i),
tmpdict tmpdict
); );
entryInfo(e); entryInfo(e);

View File

@ -64,14 +64,14 @@ int main(int argc, char *argv[])
// Test Foam::name with formatting string // Test Foam::name with formatting string
{ {
word formatted = Foam::name("formatted=<%X>", 0xdeadbeef); word formatted = word::printf("formatted=<%X>", 0xdeadbeef);
Info<<"formatted: " << formatted << nl; Info<<"formatted: " << formatted << nl;
} }
Info<<"formatted: " Info<<"formatted: "
<< Foam::name("formatted not checked for validity=<%X>", 0xdeadbeef) << word::printf("formatted not checked for validity=<%X>", 0xdeadbeef)
<< nl << nl
<< endl << endl;
Info<< "string:" << test << nl << "hash:" Info<< "string:" << test << nl << "hash:"
@ -227,7 +227,7 @@ int main(int argc, char *argv[])
cout<< "\ntest Foam::name()\n"; cout<< "\ntest Foam::name()\n";
Info<< "hash: = " << Foam::name("0x%012X", string::hash()(s2)) << endl; Info<< "hash: = " << word::printf("0x%012X", string::hash()(s2)) << endl;
// test formatting on int // test formatting on int
{ {
@ -236,7 +236,7 @@ int main(int argc, char *argv[])
Info<< "int " << val << " as word >" Info<< "int " << val << " as word >"
<< Foam::name(val) << "< or " << Foam::name(val) << "< or "
<< Foam::name("formatted >%08d<", val) << "\n"; << word::printf("formatted >%08d<", val) << "\n";
} }
// test formatting on scalar // test formatting on scalar
@ -244,7 +244,7 @@ int main(int argc, char *argv[])
scalar val = 3.1415926535897931; scalar val = 3.1415926535897931;
Info<< "scalar " << val << " as word >" Info<< "scalar " << val << " as word >"
<< Foam::name(val) << "< or " << Foam::name(val) << "< or "
<< Foam::name("formatted >%.9f<", val) << "\n"; << word::printf("formatted >%.9f<", val) << "\n";
} }
// test formatting on uint // test formatting on uint
@ -254,7 +254,7 @@ int main(int argc, char *argv[])
Info<< "uint64 " << val << " as word >" Info<< "uint64 " << val << " as word >"
<< Foam::name(val) << "< or " << Foam::name(val) << "< or "
<< Foam::name("formatted >%08d<", val) << "\n"; << word::printf("formatted >%08d<", val) << "\n";
} }
// test startsWith, endsWith methods // test startsWith, endsWith methods

View File

@ -853,7 +853,7 @@ int main(int argc, char *argv[])
labelList own(boundaryFaces.size(), -1); labelList own(boundaryFaces.size(), -1);
labelList nei(boundaryFaces.size(), -1); labelList nei(boundaryFaces.size(), -1);
HashTable<label, label> faceToCell[2]; Map<label> faceToCell[2];
{ {
HashTable<label, face, Hash<face>> faceToFaceID(boundaryFaces.size()); HashTable<label, face, Hash<face>> faceToFaceID(boundaryFaces.size());

View File

@ -54,13 +54,6 @@ Foam::PrintTable<KeyType, DataType>::PrintTable
{} {}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class KeyType, class DataType>
Foam::PrintTable<KeyType, DataType>::~PrintTable()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
template<class KeyType, class DataType> template<class KeyType, class DataType>
@ -71,7 +64,7 @@ void Foam::PrintTable<KeyType, DataType>::print
const bool printAverage const bool printAverage
) const ) const
{ {
HashTable<HashTable<DataType, label>, KeyType> combinedTable; HashTable<Map<DataType>, KeyType> combinedTable;
List<HashTableData> procData(Pstream::nProcs(), HashTableData()); List<HashTableData> procData(Pstream::nProcs(), HashTableData());
@ -90,36 +83,25 @@ void Foam::PrintTable<KeyType, DataType>::print
{ {
const HashTableData& procIData = procData[proci]; const HashTableData& procIData = procData[proci];
for forAllConstIters(procIData, iter)
(
typename HashTableData::const_iterator iter = procIData.begin();
iter != procIData.end();
++iter
)
{ {
if (!combinedTable.found(iter.key())) if (!combinedTable.found(iter.key()))
{ {
combinedTable.insert combinedTable.insert
( (
iter.key(), iter.key(),
HashTable<DataType, label>() Map<DataType>()
); );
} }
HashTable<DataType, label>& key = combinedTable[iter.key()]; Map<DataType>& key = combinedTable[iter.key()];
key.insert(proci, iter()); key.insert(proci, iter.object());
for forAllConstIters(key, dataIter)
(
typename HashTable<DataType, label>
::const_iterator dataIter = key.begin();
dataIter != key.end();
++dataIter
)
{ {
std::ostringstream buf; std::ostringstream buf;
buf << dataIter(); buf << dataIter.object();
largestDataLength = max largestDataLength = max
( (
@ -172,7 +154,7 @@ void Foam::PrintTable<KeyType, DataType>::print
forAll(sortedTable, keyI) forAll(sortedTable, keyI)
{ {
const HashTable<DataType, label>& procDataList const Map<DataType>& procDataList
= combinedTable[sortedTable[keyI]]; = combinedTable[sortedTable[keyI]];
os.width(largestKeyLength); os.width(largestKeyLength);

View File

@ -101,7 +101,7 @@ public:
//- Destructor //- Destructor
~PrintTable(); ~PrintTable() = default;
// Member Functions // Member Functions

View File

@ -33,18 +33,12 @@ Foam::pointFeatureEdgesTypes::pointFeatureEdgesTypes
const label pointLabel const label pointLabel
) )
: :
HashTable<label, extendedFeatureEdgeMesh::edgeStatus>(), HashTable<label, extendedFeatureEdgeMesh::edgeStatus, Hash<label>>(),
feMesh_(feMesh), feMesh_(feMesh),
pointLabel_(pointLabel) pointLabel_(pointLabel)
{} {}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::pointFeatureEdgesTypes::~pointFeatureEdgesTypes()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::List<Foam::extendedFeatureEdgeMesh::edgeStatus> Foam::List<Foam::extendedFeatureEdgeMesh::edgeStatus>
@ -79,18 +73,12 @@ Foam::Ostream& Foam::operator<<
{ {
os << "Point = " << p.pointLabel_ << endl; os << "Point = " << p.pointLabel_ << endl;
for forAllConstIters(p, iter)
(
HashTable<label, extendedFeatureEdgeMesh::edgeStatus>
::const_iterator iter = p.cbegin();
iter != p.cend();
++iter
)
{ {
os << " " os << " "
<< extendedFeatureEdgeMesh::edgeStatusNames_[iter.key()] << extendedFeatureEdgeMesh::edgeStatusNames_[iter.key()]
<< " = " << " = "
<< iter() << iter.object()
<< endl; << endl;
} }

View File

@ -58,7 +58,7 @@ Ostream& operator<<(Ostream&, const pointFeatureEdgesTypes&);
//- Hold the types of feature edges attached to the point. //- Hold the types of feature edges attached to the point.
class pointFeatureEdgesTypes class pointFeatureEdgesTypes
: :
public HashTable<label, extendedFeatureEdgeMesh::edgeStatus> public HashTable<label, extendedFeatureEdgeMesh::edgeStatus, Hash<label>>
{ {
// Private data // Private data
@ -82,7 +82,7 @@ public:
//- Destructor //- Destructor
~pointFeatureEdgesTypes(); ~pointFeatureEdgesTypes() = default;
// Member Functions // Member Functions

View File

@ -1007,7 +1007,11 @@ Foam::label Foam::checkGeometry
globalFaces().gather globalFaces().gather
( (
UPstream::worldComm, UPstream::worldComm,
labelList(UPstream::procID(UPstream::worldComm)), labelList::createList
(
UPstream::procID(UPstream::worldComm),
toLabel<int>() // int -> label
),
ami.srcWeightsSum(), ami.srcWeightsSum(),
mergedWeights mergedWeights
); );
@ -1057,7 +1061,11 @@ Foam::label Foam::checkGeometry
globalFaces().gather globalFaces().gather
( (
UPstream::worldComm, UPstream::worldComm,
labelList(UPstream::procID(UPstream::worldComm)), labelList::createList
(
UPstream::procID(UPstream::worldComm),
toLabel<int>() // int -> label
),
ami.tgtWeightsSum(), ami.tgtWeightsSum(),
mergedWeights mergedWeights
); );

View File

@ -84,7 +84,11 @@ void writeWeights
globalFaces().gather globalFaces().gather
( (
UPstream::worldComm, UPstream::worldComm,
labelList(UPstream::procID(UPstream::worldComm)), labelList::createList
(
UPstream::procID(UPstream::worldComm),
toLabel<int>() // int -> label
),
wghtSum, wghtSum,
mergedWeights mergedWeights
); );

View File

@ -162,13 +162,13 @@ bool writeZones(const word& name, const fileName& meshDir, Time& runTime)
} }
// Reduction for non-empty strings // Reduction for non-empty strings.
class uniqueEqOp template<class StringType>
struct uniqueEqOp
{ {
public: void operator()(List<StringType>& x, const List<StringType>& y) const
void operator()(stringList& x, const stringList& y) const
{ {
stringList newX(x.size()+y.size()); List<StringType> newX(x.size()+y.size());
label n = 0; label n = 0;
forAll(x, i) forAll(x, i)
{ {
@ -215,8 +215,8 @@ bool writeOptionalMeshObject
bool haveFile = io.typeHeaderOk<IOField<label>>(false); bool haveFile = io.typeHeaderOk<IOField<label>>(false);
// Make sure all know if there is a valid class name // Make sure all know if there is a valid class name
stringList classNames(1, io.headerClassName()); wordList classNames(1, io.headerClassName());
combineReduce(classNames, uniqueEqOp()); combineReduce(classNames, uniqueEqOp<word>());
// Check for correct type // Check for correct type
if (classNames[0] == T::typeName) if (classNames[0] == T::typeName)
@ -395,7 +395,7 @@ int main(int argc, char *argv[])
// Check for lagrangian // Check for lagrangian
stringList lagrangianDirs fileNameList lagrangianDirs
( (
1, 1,
fileHandler().filePath fileHandler().filePath
@ -406,7 +406,7 @@ int main(int argc, char *argv[])
) )
); );
combineReduce(lagrangianDirs, uniqueEqOp()); combineReduce(lagrangianDirs, uniqueEqOp<fileName>());
if (!lagrangianDirs.empty()) if (!lagrangianDirs.empty())
{ {
@ -434,7 +434,7 @@ int main(int argc, char *argv[])
); );
} }
stringList cloudDirs fileNameList cloudDirs
( (
fileHandler().readDir fileHandler().readDir
( (
@ -443,7 +443,7 @@ int main(int argc, char *argv[])
) )
); );
combineReduce(cloudDirs, uniqueEqOp()); combineReduce(cloudDirs, uniqueEqOp<fileName>());
forAll(cloudDirs, i) forAll(cloudDirs, i)
{ {
@ -464,13 +464,11 @@ int main(int argc, char *argv[])
IOobjectList sprayObjs(runTime, runTime.timeName(), dir); IOobjectList sprayObjs(runTime, runTime.timeName(), dir);
// Combine with all other cloud objects // Combine with all other cloud objects
stringList sprayFields(sprayObjs.sortedToc()); wordList sprayFields(sprayObjs.sortedToc());
combineReduce(sprayFields, uniqueEqOp()); combineReduce(sprayFields, uniqueEqOp<word>());
forAll(sprayFields, fieldi) for (const word& name : sprayFields)
{ {
const word& name = sprayFields[fieldi];
// Note: try the various field types. Make sure to // Note: try the various field types. Make sure to
// exit once sucessful conversion to avoid re-read // exit once sucessful conversion to avoid re-read
// converted file. // converted file.

View File

@ -1,14 +1,8 @@
#!/bin/sh #!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory cd ${0%/*} || exit 1 # Run from this directory
export WM_CONTINUE_ON_ERROR=true # Optional unit
# Optional unit: continue-on-error . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments # Parse arguments
export WM_CONTINUE_ON_ERROR=true . $WM_PROJECT_DIR/wmake/scripts/cmakeFunctions # The CMake functions
# Parse arguments for library compilation
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
# Source CMake functions
. $WM_PROJECT_DIR/wmake/scripts/cmakeFunctions
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------

View File

@ -155,7 +155,7 @@ int main(int argc, char *argv[])
if (withVTK && Pstream::master()) if (withVTK && Pstream::master())
{ {
const word outputName = const word outputName =
Foam::name("forces_%06d.vtp", runTime.timeIndex()); word::printf("forces_%06d.vtp", runTime.timeIndex());
Info<<" " << outputName << endl; Info<<" " << outputName << endl;

View File

@ -226,14 +226,16 @@ int main(int argc, char *argv[])
// State/response = what comes back from FEM // State/response = what comes back from FEM
{ {
const word outputName = Foam::name("state_%06d.vtp", index); const word outputName = word::printf("state_%06d.vtp", index);
Info<<" " << outputName << endl; Info<<" " << outputName << endl;
state.writeVTP(outputName, movement().axis()); state.writeVTP(outputName, movement().axis());
} }
{ {
const word outputName = Foam::name("geom_%06d.vtp", index); const word outputName = word::printf("geom_%06d.vtp", index);
Info<<" " << outputName << endl; Info<<" " << outputName << endl;
movement().writeVTP(outputName, state, mesh, patchLst, points0); movement().writeVTP(outputName, state, mesh, patchLst, points0);

View File

@ -46,21 +46,34 @@ then
exit 1 exit 1
fi fi
for cmd in etags ctags-exuberant unset etags
for cmd in ctags-exuberant etags
do do
type $cmd >/dev/null 2>&1 || { command -v $cmd >/dev/null 2>&1 && { etags=$cmd; break; }
echo "${0##*/} cannot build tag files: '$cmd' command not found"
exit 1
}
done done
[ -n "$etags" ] || {
exec 1>&2
echo "${0##*/} cannot build tag files: no suitable command found"
echo " No ctags-exuberant"
echo " No etags"
exit 1
}
case "$etags" in
ctags-exuberant)
etags="$etags -e --extra=+fq --file-scope=no --c-kinds=+p -o .tags/etags -L -"
;;
etags)
etags="$etags --declarations -l c++ -o .tags/etags -"
;;
esac
cd $WM_PROJECT_DIR || exit 1 cd $WM_PROJECT_DIR || exit 1
mkdir .tags 2>/dev/null mkdir .tags 2>/dev/null
#etagsCmd="etags --declarations -l c++ -o .tags/etags -" echo "building tags..." 1>&2
etagsCmd="ctags-exuberant -e --extra=+fq --file-scope=no --c-kinds=+p -o .tags/etags -L -" find -H $WM_PROJECT_DIR \( -name "*.[HC]" -o -name lnInclude -prune -o -name Doxygen -prune \) | $etags
find -H $WM_PROJECT_DIR \( -name "*.[HC]" -o -name lnInclude -prune -o -name Doxygen -prune \) | $etagsCmd
#gtags -i --gtagsconf bin/tools/gtagsrc .tags #gtags -i --gtagsconf bin/tools/gtagsrc .tags

View File

@ -133,7 +133,7 @@ void printSourceFileAndLine
else else
{ {
string cwdLine(line.replaceAll(cwd() + '/', "")); string cwdLine(line.replaceAll(cwd() + '/', ""));
string homeLine(cwdLine.replaceAll(home(), '~')); string homeLine(cwdLine.replaceAll(home(), "~"));
os << " at " << homeLine.c_str(); os << " at " << homeLine.c_str();
} }

View File

@ -122,10 +122,7 @@ Foam::HashSet<Key, Hash>::HashSet
: :
parent_type(tbl.capacity()) parent_type(tbl.capacity())
{ {
using other_iter = for (auto iter = tbl.cbegin(); iter != tbl.cend(); ++iter)
typename HashTable<AnyType, Key, AnyHash>::const_iterator;
for (other_iter iter = tbl.cbegin(); iter != tbl.cend(); ++iter)
{ {
this->insert(iter.key()); this->insert(iter.key());
} }

View File

@ -38,7 +38,7 @@ Note
The HashSet iterator dereferences to the key, so the following The HashSet iterator dereferences to the key, so the following
range-for works as expected: range-for works as expected:
\code \code
HashSet<label> someLabels{10, 20, 30, 40, ...}; labelHashSet someLabels{10, 20, 30, 40, ...};
for (const label i : someLabels) for (const label i : someLabels)
{ {
Info<< "val:" << i << nl; Info<< "val:" << i << nl;
@ -55,7 +55,7 @@ Typedef
Foam::labelHashSet Foam::labelHashSet
Description Description
A HashSet with label keys. A HashSet with label keys and label hasher.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -162,18 +162,6 @@ public:
parent_type(std::move(hs)) parent_type(std::move(hs))
{} {}
//- Construct by transferring the parameter contents
HashSet(const Xfer<this_type>& hs)
:
parent_type(hs)
{}
//- Construct by transferring the parameter contents
HashSet(const Xfer<parent_type>& hs)
:
parent_type(hs)
{}
//- Construct from the keys of another HashTable, //- Construct from the keys of another HashTable,
//- the type of values held is arbitrary. //- the type of values held is arbitrary.
template<class AnyType, class AnyHash> template<class AnyType, class AnyHash>
@ -427,7 +415,7 @@ HashSet<Key,Hash> operator^
//- A HashSet with word keys. //- A HashSet with word keys.
typedef HashSet<> wordHashSet; typedef HashSet<> wordHashSet;
//- A HashSet with label keys. //- A HashSet with label keys and label hasher.
typedef HashSet<label, Hash<label>> labelHashSet; typedef HashSet<label, Hash<label>> labelHashSet;

View File

@ -108,18 +108,6 @@ Foam::HashTable<T, Key, Hash>::HashTable(HashTable<T, Key, Hash>&& ht)
} }
template<class T, class Key, class Hash>
Foam::HashTable<T, Key, Hash>::HashTable
(
const Xfer<HashTable<T, Key, Hash>>& ht
)
:
HashTable<T, Key, Hash>(0)
{
transfer(ht());
}
template<class T, class Key, class Hash> template<class T, class Key, class Hash>
Foam::HashTable<T, Key, Hash>::HashTable Foam::HashTable<T, Key, Hash>::HashTable
( (

View File

@ -83,7 +83,6 @@ SourceFiles
#include "word.H" #include "word.H"
#include "zero.H" #include "zero.H"
#include "Xfer.H"
#include "Hash.H" #include "Hash.H"
#include "HashTableCore.H" #include "HashTableCore.H"
@ -343,9 +342,6 @@ public:
//- Move construct //- Move construct
HashTable(this_type&& ht); HashTable(this_type&& ht);
//- Construct by transferring the parameter contents
HashTable(const Xfer<this_type>& ht);
//- Construct from an initializer list //- Construct from an initializer list
HashTable(std::initializer_list<std::pair<Key, T>> lst); HashTable(std::initializer_list<std::pair<Key, T>> lst);
@ -602,9 +598,6 @@ public:
// and annul the argument table. // and annul the argument table.
void transfer(HashTable<T, Key, Hash>& ht); void transfer(HashTable<T, Key, Hash>& ht);
//- Transfer contents to the Xfer container
inline Xfer<HashTable<T, Key, Hash>> xfer();
// Member Operators // Member Operators
@ -622,9 +615,6 @@ public:
//- Return existing entry or insert a new entry. //- Return existing entry or insert a new entry.
inline T& operator()(const Key& key, const T& deflt); inline T& operator()(const Key& key, const T& deflt);
//- Return hashed entry if it exists, or return the given default
inline const T& operator()(const Key& key, const T& deflt) const;
//- Assignment //- Assignment
void operator=(const HashTable<T, Key, Hash>& rhs); void operator=(const HashTable<T, Key, Hash>& rhs);

View File

@ -136,14 +136,6 @@ inline bool Foam::HashTable<T, Key, Hash>::set
} }
template<class T, class Key, class Hash>
inline Foam::Xfer<Foam::HashTable<T, Key, Hash>>
Foam::HashTable<T, Key, Hash>::xfer()
{
return xferMove(*this);
}
template<class T, class Key, class Hash> template<class T, class Key, class Hash>
inline const T& Foam::HashTable<T, Key, Hash>::lookup inline const T& Foam::HashTable<T, Key, Hash>::lookup
( (
@ -226,17 +218,6 @@ inline T& Foam::HashTable<T, Key, Hash>::operator()
} }
template<class T, class Key, class Hash>
inline const T& Foam::HashTable<T, Key, Hash>::operator()
(
const Key& key,
const T& deflt
) const
{
return this->lookup(key, deflt);
}
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
template<class T, class Key, class Hash> template<class T, class Key, class Hash>

View File

@ -100,18 +100,6 @@ public:
parent_type(std::move(map)) parent_type(std::move(map))
{} {}
//- Construct by transferring the parameter contents
Map(const Xfer<this_type>& map)
:
parent_type(map)
{}
//- Construct by transferring the parameter contents
Map(const Xfer<parent_type>& map)
:
parent_type(map)
{}
//- Construct from an initializer list //- Construct from an initializer list
Map(std::initializer_list<std::pair<label, T>> map) Map(std::initializer_list<std::pair<label, T>> map)
: :

View File

@ -101,12 +101,8 @@ public:
//- Hashing function class. //- Hashing function class.
// Use Hasher directly for contiguous data. Otherwise hash incrementally. // Use Hasher directly for contiguous data. Otherwise hash incrementally.
template<class HashT=Hash<T>> template<class HashT=Hash<T>>
class Hash struct Hash
{ {
public:
Hash()
{}
inline unsigned operator() inline unsigned operator()
( (
const FixedList<T, Size>&, const FixedList<T, Size>&,

View File

@ -546,8 +546,7 @@ inline unsigned Foam::FixedList<T, Size>::Hash<HashT>::operator()
// Hash directly // Hash directly
return Hasher(lst.v_, sizeof(lst.v_), seed); return Hasher(lst.v_, sizeof(lst.v_), seed);
} }
else
{
// Hash incrementally // Hash incrementally
unsigned val = seed; unsigned val = seed;
@ -557,7 +556,6 @@ inline unsigned Foam::FixedList<T, Size>::Hash<HashT>::operator()
} }
return val; return val;
}
} }

View File

@ -3,7 +3,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) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -35,17 +35,76 @@ License
#include <utility> #include <utility>
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class T>
template<class T2, class UnaryOperation>
Foam::List<T> Foam::List<T>::createList
(
const UList<T2>& input,
const UnaryOperation& op
)
{
const label len = input.size();
List<T> output(len);
if (len)
{
List_ACCESS(T, output, out);
List_CONST_ACCESS(T2, input, in);
for (label i = 0; i < len; ++i)
{
out[i] = op(in[i]);
}
}
return output;
}
template<class T>
template<class InputIterator, class UnaryOperation>
Foam::List<T> Foam::List<T>::createList
(
InputIterator begIter,
InputIterator endIter,
const UnaryOperation& op
)
{
const label len = std::distance(begIter, endIter);
List<T> output(len);
if (len)
{
List_ACCESS(T, output, out);
InputIterator iter = begIter;
for (label i = 0; i < len; ++i)
{
out[i] = op(*iter);
++iter;
}
}
return output;
}
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
template<class T> template<class T>
Foam::List<T>::List(const label s) Foam::List<T>::List(const label len)
: :
UList<T>(nullptr, s) UList<T>(nullptr, len)
{ {
if (this->size_ < 0) if (len < 0)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "bad size " << this->size_ << "bad size " << len
<< abort(FatalError); << abort(FatalError);
} }
@ -54,23 +113,23 @@ Foam::List<T>::List(const label s)
template<class T> template<class T>
Foam::List<T>::List(const label s, const T& val) Foam::List<T>::List(const label len, const T& val)
: :
UList<T>(nullptr, s) UList<T>(nullptr, len)
{ {
if (this->size_ < 0) if (len < 0)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "bad size " << this->size_ << "bad size " << len
<< abort(FatalError); << abort(FatalError);
} }
if (len)
{
alloc(); alloc();
if (this->size_)
{
List_ACCESS(T, (*this), vp); List_ACCESS(T, (*this), vp);
List_FOR_ALL((*this), i) for (label i=0; i < len; ++i)
{ {
vp[i] = val; vp[i] = val;
} }
@ -79,23 +138,23 @@ Foam::List<T>::List(const label s, const T& val)
template<class T> template<class T>
Foam::List<T>::List(const label s, const zero) Foam::List<T>::List(const label len, const zero)
: :
UList<T>(nullptr, s) UList<T>(nullptr, len)
{ {
if (this->size_ < 0) if (len < 0)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "bad size " << this->size_ << "bad size " << len
<< abort(FatalError); << abort(FatalError);
} }
if (len)
{
alloc(); alloc();
if (this->size_)
{
List_ACCESS(T, (*this), vp); List_ACCESS(T, (*this), vp);
List_FOR_ALL((*this), i) for (label i=0; i < len; ++i)
{ {
vp[i] = Zero; vp[i] = Zero;
} }
@ -103,6 +162,34 @@ Foam::List<T>::List(const label s, const zero)
} }
template<class T>
Foam::List<T>::List(const UList<T>& a)
:
UList<T>(nullptr, a.size_)
{
if (this->size_)
{
alloc();
#ifdef USEMEMCPY
if (contiguous<T>())
{
memcpy(this->v_, a.v_, this->byteSize());
}
else
#endif
{
List_ACCESS(T, (*this), vp);
List_CONST_ACCESS(T, a, ap);
List_FOR_ALL((*this), i)
{
vp[i] = ap[i];
}
}
}
}
template<class T> template<class T>
Foam::List<T>::List(const List<T>& a) Foam::List<T>::List(const List<T>& a)
: :
@ -131,26 +218,6 @@ Foam::List<T>::List(const List<T>& a)
} }
template<class T>
template<class T2>
Foam::List<T>::List(const List<T2>& a)
:
UList<T>(nullptr, a.size())
{
if (this->size_)
{
alloc();
List_ACCESS(T, (*this), vp);
List_CONST_ACCESS(T2, a, ap);
List_FOR_ALL((*this), i)
{
vp[i] = T(ap[i]);
}
}
}
template<class T> template<class T>
Foam::List<T>::List(List<T>& a, bool reuse) Foam::List<T>::List(List<T>& a, bool reuse)
: :
@ -191,13 +258,14 @@ Foam::List<T>::List(const UList<T>& lst, const labelUList& mapAddressing)
: :
UList<T>(nullptr, mapAddressing.size()) UList<T>(nullptr, mapAddressing.size())
{ {
if (this->size_) const label len = mapAddressing.size();
if (len)
{ {
alloc(); alloc();
List_ACCESS(T, (*this), vp); List_ACCESS(T, (*this), vp);
const label len = (*this).size();
for (label i=0; i < len; ++i) for (label i=0; i < len; ++i)
{ {
vp[i] = lst[mapAddressing[i]]; vp[i] = lst[mapAddressing[i]];
@ -220,7 +288,8 @@ Foam::List<T>::List(const FixedList<T, Size>& lst)
: :
UList<T>(nullptr, Size) UList<T>(nullptr, Size)
{ {
allocCopyList(lst); alloc();
copyList(lst);
} }
@ -229,7 +298,8 @@ Foam::List<T>::List(const PtrList<T>& lst)
: :
UList<T>(nullptr, lst.size()) UList<T>(nullptr, lst.size())
{ {
allocCopyList(lst); alloc();
copyList(lst);
} }
@ -245,7 +315,8 @@ Foam::List<T>::List(const UIndirectList<T>& lst)
: :
UList<T>(nullptr, lst.size()) UList<T>(nullptr, lst.size())
{ {
allocCopyList(lst); alloc();
copyList(lst);
} }
@ -254,7 +325,8 @@ Foam::List<T>::List(const BiIndirectList<T>& lst)
: :
UList<T>(nullptr, lst.size()) UList<T>(nullptr, lst.size())
{ {
allocCopyList(lst); alloc();
copyList(lst);
} }
@ -329,7 +401,7 @@ void Foam::List<T>::setSize(const label newSize)
{ {
if (newSize > 0) if (newSize > 0)
{ {
T* nv = new T[label(newSize)]; T* nv = new T[newSize];
const label overlap = min(this->size_, newSize); const label overlap = min(this->size_, newSize);
@ -367,7 +439,7 @@ void Foam::List<T>::setSize(const label newSize)
template<class T> template<class T>
void Foam::List<T>::setSize(const label newSize, const T& val) void Foam::List<T>::setSize(const label newSize, const T& val)
{ {
const label oldSize = label(this->size_); const label oldSize = this->size_;
this->setSize(newSize); this->setSize(newSize);
List_ACCESS(T, *this, vp); List_ACCESS(T, *this, vp);
@ -474,28 +546,58 @@ void Foam::List<T>::operator=(const SLList<T>& lst)
template<class T> template<class T>
void Foam::List<T>::operator=(const UIndirectList<T>& lst) void Foam::List<T>::operator=(const UIndirectList<T>& lst)
{ {
reAlloc(lst.size()); const label len = lst.size();
copyList(lst);
reAlloc(len);
if (len)
{
List_ACCESS(T, (*this), vp);
for (label i=0; i<len; ++i)
{
vp[i] = lst[i];
}
}
} }
template<class T> template<class T>
void Foam::List<T>::operator=(const BiIndirectList<T>& lst) void Foam::List<T>::operator=(const BiIndirectList<T>& lst)
{ {
reAlloc(lst.size()); const label len = lst.size();
copyList(lst);
reAlloc(len);
if (len)
{
List_ACCESS(T, (*this), vp);
for (label i=0; i<len; ++i)
{
vp[i] = lst[i];
}
}
} }
template<class T> template<class T>
void Foam::List<T>::operator=(std::initializer_list<T> lst) void Foam::List<T>::operator=(std::initializer_list<T> lst)
{ {
reAlloc(lst.size()); const label len = lst.size();
reAlloc(len);
if (len)
{
List_ACCESS(T, (*this), vp);
label i = 0; label i = 0;
for (const auto& val : lst) for (const auto& val : lst)
{ {
this->operator[](i++) = val; vp[i] = val;
++i;
}
} }
} }

View File

@ -3,7 +3,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) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -50,16 +50,12 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward declaration of classes // Forward declarations
class Istream; class Istream;
class Ostream; class Ostream;
// Forward declaration of friend functions and operators
template<class T> class List; template<class T> class List;
template<class T> Istream& operator>>(Istream& is, List<T>& L);
template<class T, unsigned Size> class FixedList; template<class T, unsigned Size> class FixedList;
template<class T> class PtrList; template<class T> class PtrList;
@ -75,8 +71,11 @@ template<class T> class IndirectList;
template<class T> class UIndirectList; template<class T> class UIndirectList;
template<class T> class BiIndirectList; template<class T> class BiIndirectList;
template<class T> Istream& operator>>(Istream& is, List<T>& L);
typedef List<char> charList; typedef List<char> charList;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class List Declaration Class List Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -92,16 +91,12 @@ class List
inline void alloc(); inline void alloc();
//- Reallocate list storage to the given size //- Reallocate list storage to the given size
inline void reAlloc(const label s); inline void reAlloc(const label len);
//- Copy list of given type //- Copy list of given type.
template<class List2> template<class List2>
inline void copyList(const List2& lst); inline void copyList(const List2& lst);
//- Allocate storage and copy list of given type
template<class List2>
inline void allocCopyList(const List2& lst);
//- Construct given begin/end iterators and number of elements //- Construct given begin/end iterators and number of elements
// Since the size is provided, the end iterator is actually ignored. // Since the size is provided, the end iterator is actually ignored.
template<class InputIterator> template<class InputIterator>
@ -109,7 +104,7 @@ class List
( (
InputIterator begIter, InputIterator begIter,
InputIterator endIter, InputIterator endIter,
const label s const label len
); );
@ -120,6 +115,44 @@ public:
//- Return a null List //- Return a null List
inline static const List<T>& null(); inline static const List<T>& null();
//- Create from a list of a dissimilar type.
// Eg, convert a list of ints to floats, vectors etc.
// For example,
// \code
// auto vectors = List<vector>::createList
// (
// ints,
// [](const int& val){ return vector(1.5*val, 0, 0); }
// );
//
// auto neg = labelList::createList
// (
// ints,
// std::negate<label>()
// );
// auto labels = labelList::createList
// (
// ints,
// toLabel<int>()
// );
// \endcode
template<class T2, class UnaryOperation>
static List<T> createList
(
const UList<T2>& input,
const UnaryOperation& op
);
//- Create from an iterator range (uses std::distance for the size).
// The unary operation can be used to convert to other types.
template<class InputIterator, class UnaryOperation>
static List<T> createList
(
InputIterator begIter,
InputIterator endIter,
const UnaryOperation& op
);
// Constructors // Constructors
@ -127,22 +160,19 @@ public:
inline List(); inline List();
//- Construct with given size //- Construct with given size
explicit List(const label s); explicit List(const label len);
//- Construct with given size and value for all elements //- Construct with given size and value for all elements
List(const label s, const T& val); List(const label len, const T& val);
//- Construct with given size initializing all elements to zero //- Construct with given size initializing all elements to zero
List(const label s, const zero); List(const label len, const zero);
//- Copy constructor from list //- Copy construct from list
List(const List<T>& a); List(const List<T>& a);
//- Copy constructor from list containing another type. //- Copy construct contents from list
// This is primarily useful to convert a list of ints into floats, explicit List(const UList<T>& a);
// for example.
template<class T2>
explicit List(const List<T2>& a);
//- Construct as copy or re-use as specified //- Construct as copy or re-use as specified
List(List<T>& a, bool reuse); List(List<T>& a, bool reuse);
@ -151,7 +181,7 @@ public:
List(const UList<T>& lst, const labelUList& mapAddressing); List(const UList<T>& lst, const labelUList& mapAddressing);
//- Construct given begin/end iterators. //- Construct given begin/end iterators.
// Uses std::distance to determine the size. // Uses std::distance for the size.
template<class InputIterator> template<class InputIterator>
List(InputIterator begIter, InputIterator endIter); List(InputIterator begIter, InputIterator endIter);

View File

@ -36,12 +36,12 @@ inline void Foam::List<T>::alloc()
template<class T> template<class T>
inline void Foam::List<T>::reAlloc(const label s) inline void Foam::List<T>::reAlloc(const label len)
{ {
if (this->size_ != s) if (this->size_ != len)
{ {
clear(); clear();
this->size_ = s; this->size_ = len;
alloc(); alloc();
} }
} }
@ -51,25 +51,12 @@ template<class T>
template<class List2> template<class List2>
inline void Foam::List<T>::copyList(const List2& lst) inline void Foam::List<T>::copyList(const List2& lst)
{ {
if (this->size_) const label len = this->size_;
{
forAll(*this, i) for (label i=0; i<len; ++i)
{ {
this->operator[](i) = lst[i]; this->operator[](i) = lst[i];
} }
}
}
template<class T>
template<class List2>
inline void Foam::List<T>::allocCopyList(const List2& lst)
{
if (this->size_)
{
alloc();
copyList(lst);
}
} }
@ -79,17 +66,17 @@ inline Foam::List<T>::List
( (
InputIterator begIter, InputIterator begIter,
InputIterator endIter, InputIterator endIter,
const label s const label len
) )
: :
UList<T>(nullptr, s) UList<T>(nullptr, len)
{ {
if (this->size_) if (this->size_)
{ {
alloc(); alloc();
InputIterator iter = begIter; InputIterator iter = begIter;
for (label i = 0; i < s; ++i) for (label i = 0; i < len; ++i)
{ {
this->operator[](i) = *iter; this->operator[](i) = *iter;
++iter; ++iter;
@ -135,16 +122,16 @@ inline void Foam::List<T>::clear()
template<class T> template<class T>
inline void Foam::List<T>::resize(const label newSize) inline void Foam::List<T>::resize(const label len)
{ {
this->setSize(newSize); this->setSize(len);
} }
template<class T> template<class T>
inline void Foam::List<T>::resize(const label newSize, const T& val) inline void Foam::List<T>::resize(const label len, const T& val)
{ {
this->setSize(newSize, val); this->setSize(len, val);
} }

View File

@ -25,7 +25,6 @@ License
#include "ListOps.H" #include "ListOps.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const Foam::labelList Foam::emptyLabelList; const Foam::labelList Foam::emptyLabelList;

View File

@ -33,6 +33,14 @@ License
namespace Foam namespace Foam
{ {
// Convert a single character to a word with length 1
inline static Foam::word charToWord(char c)
{
return Foam::word(std::string(1, c), false);
}
// Adjust stream format based on the flagMask // Adjust stream format based on the flagMask
inline static void processFlags(Istream& is, int flagMask) inline static void processFlags(Istream& is, int flagMask)
{ {
@ -45,7 +53,8 @@ inline static void processFlags(Istream& is, int flagMask)
is.format(IOstream::BINARY); is.format(IOstream::BINARY);
} }
} }
}
} // End anonymous namespace
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -315,7 +324,7 @@ Foam::Istream& Foam::UIPstream::read(token& t)
{ {
if (isalpha(c)) if (isalpha(c))
{ {
t = word(c); t = charToWord(c);
return *this; return *this;
} }

View File

@ -33,6 +33,19 @@ License
// Truncate error message for readability // Truncate error message for readability
static const unsigned errLen = 80; static const unsigned errLen = 80;
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
namespace
{
// Convert a single character to a word with length 1
inline static Foam::word charToWord(char c)
{
return Foam::word(std::string(1, c), false);
}
} // End anonymous namespace
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
@ -210,7 +223,7 @@ Foam::Istream& Foam::ISstream::read(token& t)
if (read(nextC).bad()) if (read(nextC).bad())
{ {
// Return lone '#' as word // Return lone '#' as word
t = token(word(c)); t = charToWord(c);
} }
else if (nextC == token::BEGIN_BLOCK) else if (nextC == token::BEGIN_BLOCK)
{ {
@ -246,7 +259,7 @@ Foam::Istream& Foam::ISstream::read(token& t)
if (read(nextC).bad()) if (read(nextC).bad())
{ {
// Return lone '$' as word // Return lone '$' as word
t = token(word(c)); t = charToWord(c);
} }
else if (nextC == token::BEGIN_BLOCK) else if (nextC == token::BEGIN_BLOCK)
{ {

View File

@ -141,10 +141,10 @@ void Foam::Time::readDict()
) )
{ {
// Remove the old watches since destroying the file // Remove the old watches since destroying the file
fileNameList oldWatchedFiles(controlDict_.watchIndices()); fileNameList oldWatchedFiles(controlDict_.watchIndices().size());
forAllReverse(controlDict_.watchIndices(), i) forAllReverse(controlDict_.watchIndices(), i)
{ {
label watchi = controlDict_.watchIndices()[i]; const label watchi = controlDict_.watchIndices()[i];
oldWatchedFiles[i] = fileHandler().getFile(watchi); oldWatchedFiles[i] = fileHandler().getFile(watchi);
fileHandler().removeWatch(watchi); fileHandler().removeWatch(watchi);
} }

View File

@ -191,7 +191,7 @@ Foam::error::operator Foam::dictionary() const
dictionary errDict; dictionary errDict;
string oneLineMessage(message()); string oneLineMessage(message());
oneLineMessage.replaceAll('\n', ' '); oneLineMessage.replaceAll("\n", " ");
errDict.add("type", word("Foam::error")); errDict.add("type", word("Foam::error"));
errDict.add("message", oneLineMessage); errDict.add("message", oneLineMessage);

View File

@ -45,9 +45,9 @@ namespace Foam
Foam::word Foam::graph::wordify(const Foam::string& sname) Foam::word Foam::graph::wordify(const Foam::string& sname)
{ {
string wname = sname; string wname = sname;
wname.replace(' ', '_'); wname.replace(" ", "_");
wname.replace('(', '_'); wname.replace("(", "_");
wname.replace(')', ""); wname.replace(")", "");
return word(wname); return word(wname);
} }

View File

@ -730,7 +730,7 @@ void Foam::globalPoints::remove
// those points where the equivalence list is only me and my (face)neighbour // those points where the equivalence list is only me and my (face)neighbour
// Save old ones. // Save old ones.
Map<label> oldMeshToProcPoint(meshToProcPoint_.xfer()); Map<label> oldMeshToProcPoint(std::move(meshToProcPoint_));
meshToProcPoint_.resize(oldMeshToProcPoint.size()); meshToProcPoint_.resize(oldMeshToProcPoint.size());
DynamicList<labelPairList> oldProcPoints(procPoints_.xfer()); DynamicList<labelPairList> oldProcPoints(procPoints_.xfer());
procPoints_.setCapacity(oldProcPoints.size()); procPoints_.setCapacity(oldProcPoints.size());

View File

@ -23,8 +23,6 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "stringOps.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
@ -64,18 +62,6 @@ word name(const Scalar val)
} }
word name(const char* fmt, const Scalar val)
{
return stringOps::name(fmt, val);
}
word name(const std::string& fmt, const Scalar val)
{
return stringOps::name(fmt, val);
}
Scalar ScalarRead(const char* buf) Scalar ScalarRead(const char* buf)
{ {
char* endptr = nullptr; char* endptr = nullptr;

View File

@ -105,17 +105,10 @@ public:
// * * * * * * * * * * * * * * * IO/Conversion * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * IO/Conversion * * * * * * * * * * * * * * * //
//- Return a string representation of a Scalar //- Return a word representation of a Scalar.
// Uses stringstream instead of std::to_string for more consistent formatting.
word name(const Scalar val); word name(const Scalar val);
//- Return a word representation of a Scalar, using printf-style formatter.
// The representation is not checked for valid word characters.
word name(const char* fmt, const Scalar val);
//- Return a word representation of a Scalar, using printf-style formatter.
// The representation is not checked for valid word characters.
word name(const std::string& fmt, const Scalar val);
//- Parse entire buffer as a float/double, skipping leading/trailing whitespace. //- Parse entire buffer as a float/double, skipping leading/trailing whitespace.
// \return Parsed value or FatalIOError on any problem // \return Parsed value or FatalIOError on any problem
Scalar ScalarRead(const char* buf); Scalar ScalarRead(const char* buf);

View File

@ -44,21 +44,16 @@ Description
namespace Foam namespace Foam
{ {
//template<class Type> class Hash; //template<class Type> struct Hash;
//template<> class Hash<label>; //template<> struct Hash<label>;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class Hash Declaration Class Hash Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class PrimitiveType> template<class PrimitiveType>
class Hash struct Hash
{ {
public:
Hash()
{}
unsigned operator()(const PrimitiveType& p, unsigned seed) const unsigned operator()(const PrimitiveType& p, unsigned seed) const
{ {
return Hasher(&p, sizeof(p), seed); return Hasher(&p, sizeof(p), seed);
@ -76,13 +71,8 @@ public:
//- Hash specialization for hashing labels //- Hash specialization for hashing labels
template<> template<>
class Hash<Foam::label> struct Hash<Foam::label>
{ {
public:
Hash()
{}
//- Incrementally hash a label. //- Incrementally hash a label.
// This will necessarily return a different value than the // This will necessarily return a different value than the
// non-incremental version. // non-incremental version.
@ -103,13 +93,8 @@ public:
//- Hash specialization for hashing strings //- Hash specialization for hashing strings
template<> template<>
class Hash<Foam::string> struct Hash<Foam::string>
{ {
public:
Hash()
{}
unsigned operator()(const string& p, unsigned seed) const unsigned operator()(const string& p, unsigned seed) const
{ {
return string::hash()(p, seed); return string::hash()(p, seed);
@ -123,13 +108,8 @@ public:
//- Hash specialization for hashing words //- Hash specialization for hashing words
template<> template<>
class Hash<Foam::word> struct Hash<Foam::word>
{ {
public:
Hash()
{}
unsigned operator()(const word& p, unsigned seed) const unsigned operator()(const word& p, unsigned seed) const
{ {
return word::hash()(p, seed); return word::hash()(p, seed);
@ -143,13 +123,8 @@ public:
//- Hash specialization for hashing fileNames //- Hash specialization for hashing fileNames
template<> template<>
class Hash<Foam::fileName> struct Hash<Foam::fileName>
{ {
public:
Hash()
{}
unsigned operator()(const fileName& p, unsigned seed) const unsigned operator()(const fileName& p, unsigned seed) const
{ {
return fileName::hash()(p, seed); return fileName::hash()(p, seed);
@ -163,13 +138,8 @@ public:
//- Hash specialization for hashing wordRes //- Hash specialization for hashing wordRes
template<> template<>
class Hash<Foam::wordRe> struct Hash<Foam::wordRe>
{ {
public:
Hash()
{}
unsigned operator()(const wordRe& p, unsigned seed) const unsigned operator()(const wordRe& p, unsigned seed) const
{ {
return wordRe::hash()(p, seed); return wordRe::hash()(p, seed);
@ -183,13 +153,8 @@ public:
//- Hash specialization for hashing keyTypes //- Hash specialization for hashing keyTypes
template<> template<>
class Hash<Foam::keyType> struct Hash<Foam::keyType>
{ {
public:
Hash()
{}
unsigned operator()(const keyType& p, unsigned seed) const unsigned operator()(const keyType& p, unsigned seed) const
{ {
return keyType::hash()(p, seed); return keyType::hash()(p, seed);
@ -201,18 +166,12 @@ public:
}; };
//- Hash specialization for hashing pointer addresses. //- Hash specialization for hashing pointer addresses.
// Treat a pointer like a long. // Treat a pointer like a long.
// This should work for both 32-bit and 64-bit pointers. // This should work for both 32-bit and 64-bit pointers.
template<> template<>
class Hash<void*> struct Hash<void*>
{ {
public:
Hash()
{}
unsigned operator()(const void* const& p, unsigned seed) const unsigned operator()(const void* const& p, unsigned seed) const
{ {
return Hash<long>()(long(p), seed); return Hash<long>()(long(p), seed);

View File

@ -3,7 +3,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) 2014-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -24,21 +24,6 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "int32.H" #include "int32.H"
#include "stringOps.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::word Foam::name(const char* fmt, const int32_t val)
{
return stringOps::name(fmt, val);
}
Foam::word Foam::name(const std::string& fmt, const int32_t val)
{
return stringOps::name(fmt, val);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -62,16 +62,6 @@ inline word name(const int32_t val)
} }
//- Return a word representation of an int32, using printf-style formatter.
// The representation is not checked for valid word characters.
word name(const char* fmt, const int32_t val);
//- Return a word representation of an int32, using printf-style formatter.
// The representation is not checked for valid word characters.
word name(const std::string& fmt, const int32_t val);
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
//- Read int32_t from stream //- Read int32_t from stream

View File

@ -3,7 +3,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) 2014-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -24,21 +24,6 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "int64.H" #include "int64.H"
#include "stringOps.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::word Foam::name(const char* fmt, const int64_t val)
{
return stringOps::name(fmt, val);
}
Foam::word Foam::name(const std::string& fmt, const int64_t val)
{
return stringOps::name(fmt, val);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -63,16 +63,6 @@ inline word name(const int64_t val)
} }
//- Return a word representation of an int64, using printf-style formatter.
// The representation is not checked for valid word characters.
word name(const char* fmt, const int64_t);
//- Return a word representation of an int64, using printf-style formatter.
// The representation is not checked for valid word characters.
word name(const std::string& fmt, const int64_t);
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
//- Read int64_t from stream //- Read int64_t from stream

View File

@ -3,7 +3,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) 2011-2014 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -120,6 +120,40 @@ inline label component(const label l, const direction)
return l; return l;
} }
/*---------------------------------------------------------------------------*\
Struct toLabel Declaration
\*---------------------------------------------------------------------------*/
//- Conversion to label structure
template<class Type> struct toLabel {};
//- Convert (likely promote) from int32_t to label
template<>
struct toLabel<int32_t>
{
constexpr label operator()(const int32_t& val) const noexcept
{
return val;
}
};
//- Convert (possibly truncate) from int64_t to label
template<>
struct toLabel<int64_t>
{
constexpr label operator()(const int64_t& val) const noexcept
{
#if WM_LABEL_SIZE == 32
return label(val);
#elif WM_LABEL_SIZE == 64
return val;
#endif
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam } // End namespace Foam

View File

@ -24,21 +24,6 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "uint32.H" #include "uint32.H"
#include "stringOps.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::word Foam::name(const char* fmt, const uint32_t val)
{
return stringOps::name(fmt, val);
}
Foam::word Foam::name(const std::string& fmt, const uint32_t val)
{
return stringOps::name(fmt, val);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -62,16 +62,6 @@ inline word name(const uint32_t val)
} }
//- Return a word representation of a uint32, using printf-style formatter.
// The representation is not checked for valid word characters.
word name(const char* fmt, const uint32_t);
//- Return a word representation of a uint32, using printf-style formatter.
// The representation is not checked for valid word characters.
word name(const std::string& fmt, const uint32_t);
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
//- Read uint32_t from stream //- Read uint32_t from stream

View File

@ -24,21 +24,6 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "uint64.H" #include "uint64.H"
#include "stringOps.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::word Foam::name(const char* fmt, const uint64_t val)
{
return stringOps::name(fmt, val);
}
Foam::word Foam::name(const std::string& fmt, const uint64_t val)
{
return stringOps::name(fmt, val);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -62,16 +62,6 @@ inline word name(const uint64_t val)
} }
//- Return a word representation of a uint64_t, using printf-style formatter.
// The representation is not checked for valid word characters.
word name(const char* fmt, const uint64_t);
//- Return a word representation of a uint64_t, using printf-style formatter.
// The representation is not checked for valid word characters.
word name(const std::string& fmt, const uint64_t);
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
//- Read uint64_t from stream. //- Read uint64_t from stream.

View File

@ -42,8 +42,7 @@ inline void Foam::hashedWordList::rehash(const bool unique)
inline Foam::hashedWordList::hashedWordList() inline Foam::hashedWordList::hashedWordList()
: :
List<word>(), List<word>()
indices_()
{} {}

View File

@ -3,7 +3,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) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -39,6 +39,7 @@ See also
SourceFiles SourceFiles
string.C string.C
stringIO.C stringIO.C
stringTemplates.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -90,6 +91,24 @@ protected:
// A wrapped version of find_last_of("./") with additional logic. // A wrapped version of find_last_of("./") with additional logic.
inline std::string::size_type find_ext() const; inline std::string::size_type find_ext() const;
//- A printf-style formatter for a primitive.
template<class PrimitiveType>
static std::string::size_type string_printf
(
std::string& output,
const char* fmt,
const PrimitiveType& val
);
//- A printf-style formatter for a primitive.
template<class PrimitiveType>
static std::string::size_type string_printf
(
std::string& output,
const std::string& fmt,
const PrimitiveType& val
);
//- Return file name extension (part after last .) //- Return file name extension (part after last .)
word ext() const; word ext() const;
@ -124,16 +143,14 @@ public:
static const string null; static const string null;
//- Hashing function class, shared by all the derived classes //- Hashing function for string and derived string classes
class hash struct hash
{ {
public: inline unsigned operator()
hash() (
{} const std::string& str,
unsigned seed = 0
//- Hash for string. ) const;
// Uses Foam::string instead of std::string for automatic conversions.
inline unsigned operator()(const string& str, unsigned seed = 0) const;
}; };
@ -152,9 +169,9 @@ public:
inline string(const char* str, const size_type len); inline string(const char* str, const size_type len);
//- Construct from a single character //- Construct from a single character
inline string(const char c); inline explicit string(const char c);
//- Construct from copies of a single character //- Construct fill copies of a single character
inline string(const size_type len, const char c); inline string(const size_type len, const char c);
//- Move construct from std::string //- Move construct from std::string
@ -292,6 +309,10 @@ public:
#include "stringI.H" #include "stringI.H"
#ifdef NoRepository
#include "stringTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif

View File

@ -23,7 +23,6 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
inline std::string::size_type Foam::string::find_ext(const std::string& str) inline std::string::size_type Foam::string::find_ext(const std::string& str)
@ -68,6 +67,8 @@ inline bool Foam::string::removeExt()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::string::string() inline Foam::string::string()
:
std::string()
{} {}
@ -253,7 +254,7 @@ inline bool Foam::string::operator()(const std::string& text) const
inline unsigned Foam::string::hash::operator() inline unsigned Foam::string::hash::operator()
( (
const string& str, const std::string& str,
unsigned seed unsigned seed
) const ) const
{ {

View File

@ -0,0 +1,72 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include <cstdio>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Could also consider generalizing with C++11 variadic templates
template<class PrimitiveType>
std::string::size_type Foam::string::string_printf
(
std::string& output,
const char* fmt,
const PrimitiveType& val
)
{
// Use snprintf with zero to establish the size (without '\0') required
int n = ::snprintf(nullptr, 0, fmt, val);
if (n > 0)
{
output.resize(n+1);
char* buf = &(output[0]);
// Print directly into buffer, no stripping desired
n = ::snprintf(buf, n+1, fmt, val);
output.resize(n);
}
else
{
output.clear();
}
return output.size();
}
template<class PrimitiveType>
std::string::size_type Foam::string::string_printf
(
std::string& output,
const std::string& fmt,
const PrimitiveType& val
)
{
return string_printf(output, fmt.c_str(), val);
}
// ************************************************************************* //

View File

@ -457,7 +457,7 @@ Foam::string Foam::stringOps::expand
} }
else else
{ {
out.append(string(s[index])); out.append(1, s[index]); // append char
} }
++index; ++index;
} }

View File

@ -3,7 +3,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) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -321,19 +321,6 @@ namespace stringOps
void inplaceUpper(std::string& s); void inplaceUpper(std::string& s);
//- Using printf-formatter for a word representation of the primitive.
// The representation is not checked for valid word characters -
// it is assumed that the caller knows what they are doing
template<class PrimitiveType>
Foam::word name(const char* fmt, const PrimitiveType& val);
//- Using printf-formatter for a word representation of the primitive.
// The representation is not checked for valid word characters -
// it is assumed that the caller knows what they are doing
template<class PrimitiveType>
Foam::word name(const std::string& fmt, const PrimitiveType& val);
//- Split string into sub-strings at the delimiter character. //- Split string into sub-strings at the delimiter character.
// Empty sub-strings are normally suppressed. // Empty sub-strings are normally suppressed.
// Behaviour is ill-defined if delim is a NUL character. // Behaviour is ill-defined if delim is a NUL character.

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) 2016-2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -23,49 +23,8 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include <cstdio>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// NOTE: with C++11 could consider variadic templates for a more general
// sprintf implementation
template<class PrimitiveType>
Foam::word Foam::stringOps::name
(
const char* fmt,
const PrimitiveType& val
)
{
word output;
// snprintf with zero to find size (without '\0') required
int n = ::snprintf(nullptr, 0, fmt, val);
if (n > 0)
{
output.resize(n+1);
char* buf = &(output[0]);
// Print directly into buffer, no stripping desired
n = ::snprintf(buf, n+1, fmt, val);
output.resize(n);
}
return output;
}
template<class PrimitiveType>
Foam::word Foam::stringOps::name
(
const std::string& fmt,
const PrimitiveType& val
)
{
return stringOps::name(fmt.c_str(), val);
}
template<class StringType> template<class StringType>
Foam::SubStrings<StringType> Foam::stringOps::split Foam::SubStrings<StringType> Foam::stringOps::split
( (

View File

@ -3,7 +3,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) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -117,7 +117,28 @@ public:
word(Istream& is); word(Istream& is);
// Member functions // Member Functions
//- Use a printf-style formatter for a primitive.
// The representation is not checked for valid characters -
// it is assumed that the caller knows what they are doing
template<class PrimitiveType>
inline static word printf
(
const char* fmt,
const PrimitiveType& val
);
//- Use a printf-style formatter for a primitive.
// The representation is not checked for valid characters -
// it is assumed that the caller knows what they are doing
template<class PrimitiveType>
inline static word printf
(
const std::string& fmt,
const PrimitiveType& val
);
//- Is this character valid for a word? //- Is this character valid for a word?
inline static bool valid(char c); inline static bool valid(char c);
@ -128,7 +149,7 @@ public:
static word validate(const std::string& s, const bool prefix=false); static word validate(const std::string& s, const bool prefix=false);
// File-like functions // File-like Functions
//- Return word without extension (part before last .) //- Return word without extension (part before last .)
word lessExt() const; word lessExt() const;

View File

@ -3,7 +3,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) 2011-2017 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -26,6 +26,34 @@ License
#include <cctype> #include <cctype>
#include <iostream> // for std::cerr #include <iostream> // for std::cerr
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class PrimitiveType>
inline Foam::word Foam::word::printf
(
const char* fmt,
const PrimitiveType& val
)
{
word output;
string_printf(output, fmt, val);
return output;
}
template<class PrimitiveType>
inline Foam::word Foam::word::printf
(
const std::string& fmt,
const PrimitiveType& val
)
{
word output;
string_printf(output, fmt, val);
return output;
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
inline void Foam::word::stripInvalid() inline void Foam::word::stripInvalid()

View File

@ -60,7 +60,7 @@ diffusionMulticomponent<CombThermoType, ThermoType>::init()
( (
IOobject IOobject
( (
"Rijk" + name(k), "Rijk" + Foam::name(k),
this->mesh_.time().timeName(), this->mesh_.time().timeName(),
this->mesh_, this->mesh_,
IOobject::NO_READ, IOobject::NO_READ,
@ -160,14 +160,6 @@ diffusionMulticomponent
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class CombThermoType, class ThermoType>
Foam::combustionModels::diffusionMulticomponent<CombThermoType, ThermoType>::
~diffusionMulticomponent()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
template<class CombThermoType, class ThermoType> template<class CombThermoType, class ThermoType>
@ -200,7 +192,7 @@ diffusionMulticomponent<CombThermoType, ThermoType>::correct()
( (
IOobject IOobject
( (
"Rijl" + word(k), "Rijl" + Foam::name(k),
this->mesh_.time().timeName(), this->mesh_.time().timeName(),
this->mesh_, this->mesh_,
IOobject::NO_READ, IOobject::NO_READ,
@ -258,7 +250,7 @@ diffusionMulticomponent<CombThermoType, ThermoType>::correct()
const volScalarField ft const volScalarField ft
( (
"ft" + name(k), "ft" + Foam::name(k),
( (
s_[k]*Yfuel - (Yox - YoxStream_[k]) s_[k]*Yfuel - (Yox - YoxStream_[k])
) )
@ -279,7 +271,7 @@ diffusionMulticomponent<CombThermoType, ThermoType>::correct()
const volScalarField preExp const volScalarField preExp
( (
"preExp" + name(k), "preExp" + Foam::name(k),
1.0 + sqr(OAvailScaled) 1.0 + sqr(OAvailScaled)
); );
@ -291,7 +283,7 @@ diffusionMulticomponent<CombThermoType, ThermoType>::correct()
const volScalarField topHatFilter(pos(filter - 1e-3)); const volScalarField topHatFilter(pos(filter - 1e-3));
const volScalarField prob("prob" + name(k), preExp*filter); const volScalarField prob("prob" + Foam::name(k), preExp*filter);
const volScalarField RijkDiff const volScalarField RijkDiff
( (
@ -438,10 +430,8 @@ diffusionMulticomponent<CombThermoType, ThermoType>::read()
this->coeffs().readIfPresent("laminarIgn", laminarIgn_); this->coeffs().readIfPresent("laminarIgn", laminarIgn_);
return true; return true;
} }
else
{
return false; return false;
}
} }

View File

@ -177,7 +177,7 @@ public:
//- Destructor //- Destructor
virtual ~diffusionMulticomponent(); virtual ~diffusionMulticomponent() = default;
// Member Functions // Member Functions

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) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -25,7 +25,7 @@ License
#include "FIREMeshWriter.H" #include "FIREMeshWriter.H"
#include "Time.H" #include "Time.H"
#include "HashTable.H" #include "Map.H"
#include "OFstream.H" #include "OFstream.H"
#include "processorPolyPatch.H" #include "processorPolyPatch.H"
@ -117,8 +117,8 @@ bool Foam::fileFormats::FIREMeshWriter::writeSelections(OSstream& os) const
// remap name between patches and cell-zones conflicts! // remap name between patches and cell-zones conflicts!
HashTable<word, label> patchNames; Map<word> patchNames;
HashTable<word, label> zoneNames; Map<word> zoneNames;
wordHashSet usedPatchNames; wordHashSet usedPatchNames;
wordHashSet usedZoneNames; wordHashSet usedZoneNames;
@ -245,12 +245,6 @@ Foam::fileFormats::FIREMeshWriter::FIREMeshWriter
{} {}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::fileFormats::FIREMeshWriter::~FIREMeshWriter()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::fileFormats::FIREMeshWriter::write(const fileName& meshName) const bool Foam::fileFormats::FIREMeshWriter::write(const fileName& meshName) const

View File

@ -103,7 +103,7 @@ public:
//- Destructor //- Destructor
virtual ~FIREMeshWriter(); virtual ~FIREMeshWriter() = default;
// Member Functions // Member Functions

View File

@ -59,12 +59,6 @@ Foam::vtk::vtuSizing::vtuSizing()
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::vtk::vtuSizing::~vtuSizing()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::vtk::vtuSizing::reset void Foam::vtk::vtuSizing::reset
@ -83,7 +77,7 @@ void Foam::vtk::vtuSizing::reset
const cellShapeList& shapes = mesh.cellShapes(); const cellShapeList& shapes = mesh.cellShapes();
// Unique vertex labels per polyhedral // Unique vertex labels per polyhedral
HashSet<label> hashUniqId(2*256); labelHashSet hashUniqId(2*256);
decompose_ = decompose; decompose_ = decompose;
nCells_ = mesh.nCells(); nCells_ = mesh.nCells();

View File

@ -203,7 +203,7 @@ public:
//- Destructor //- Destructor
~vtuSizing(); ~vtuSizing() = default;
// Member Functions // Member Functions

View File

@ -224,7 +224,7 @@ void Foam::vtk::vtuSizing::populateArrays
const labelList& owner = mesh.faceOwner(); const labelList& owner = mesh.faceOwner();
// Unique vertex labels per polyhedral // Unique vertex labels per polyhedral
HashSet<label> hashUniqId(2*256); labelHashSet hashUniqId(2*256);
// Index into vertLabels, faceLabels for normal cells // Index into vertLabels, faceLabels for normal cells
label nVertLabels = 0; label nVertLabels = 0;

View File

@ -535,7 +535,7 @@ void Foam::ensightCase::write() const
{ {
// moving // moving
*os_ *os_
<< Foam::name("model: %-9d", tsGeom) // width 16 << word::printf("model: %-9d", tsGeom) // width 16 (no quotes)
<< (dataMask/geometryName).c_str() << (dataMask/geometryName).c_str()
<< nl; << nl;
} }
@ -554,7 +554,7 @@ void Foam::ensightCase::write() const
); );
*os_ *os_
<< Foam::name("measured: %-6d", tsCloud) // width 16 << word::printf("measured: %-6d", tsCloud) // width 16 (no quotes)
<< (masked/"positions").c_str() << (masked/"positions").c_str()
<< nl; << nl;
} }
@ -617,7 +617,7 @@ void Foam::ensightCase::write() const
// prefix variables with 'c' (cloud) and cloud index // prefix variables with 'c' (cloud) and cloud index
*os_ *os_
<< ensType.c_str() << " per " << ensType.c_str() << " per "
<< Foam::name("measured node: %-5d", tsCloud) // width 20 << word::printf("measured node: %-5d", tsCloud) // width 20
<< setw(15) << setw(15)
<< ("c" + Foam::name(cloudNo) + varName).c_str() << ' ' << ("c" + Foam::name(cloudNo) + varName).c_str() << ' '
<< (masked/varName).c_str() << (masked/varName).c_str()

View File

@ -48,6 +48,7 @@ Foam::IOstream::streamFormat Foam::ensightCase::options::format() const
return format_; return format_;
} }
const Foam::word& Foam::ensightCase::options::mask() const const Foam::word& Foam::ensightCase::options::mask() const
{ {
return mask_; return mask_;
@ -56,7 +57,7 @@ const Foam::word& Foam::ensightCase::options::mask() const
Foam::word Foam::ensightCase::options::padded(const label i) const Foam::word Foam::ensightCase::options::padded(const label i) const
{ {
// As per Foam::name, but with fixed length // As per word::printf(), but with fixed length
char buf[32]; char buf[32];
::snprintf(buf, 32, printf_.c_str(), static_cast<int>(i)); ::snprintf(buf, 32, printf_.c_str(), static_cast<int>(i));
@ -85,7 +86,7 @@ void Foam::ensightCase::options::width(const label n)
mask_.resize(n, '*'); mask_.resize(n, '*');
// appropriate printf format // appropriate printf format
printf_ = "%0" + Foam::name(n) + "d"; printf_ = "%0" + std::to_string(n) + "d";
} }

View File

@ -1100,9 +1100,9 @@ void Foam::isoAdvection::writeIsoFaces
mesh_.time().path()/".."/"isoFaces" mesh_.time().path()/".."/"isoFaces"
: mesh_.time().path()/"isoFaces" : mesh_.time().path()/"isoFaces"
); );
const string fName const word fName
( (
"isoFaces_" + Foam::name("%012d", mesh_.time().timeIndex()) word::printf("isoFaces_%012d", mesh_.time().timeIndex())
); );
if (Pstream::parRun()) if (Pstream::parRun())

View File

@ -146,7 +146,7 @@ bool Foam::functionObjects::particleDistribution::write()
// Tag field present - generate distribution per tag // Tag field present - generate distribution per tag
const IOField<label>& tag = const IOField<label>& tag =
cloudObr.lookupObject<IOField<label>>(tagFieldName_); cloudObr.lookupObject<IOField<label>>(tagFieldName_);
const HashSet<label> tagMap(tag); const labelHashSet tagMap(tag);
const label tagMax = tagMap.size(); const label tagMax = tagMap.size();
List<DynamicList<label>> tagAddr(tagMax); List<DynamicList<label>> tagAddr(tagMax);

View File

@ -1,8 +1,6 @@
#!/bin/sh #!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/wmake/scripts/cmakeFunctions # The CMake functions
# Source CMake functions
. $WM_PROJECT_DIR/wmake/scripts/cmakeFunctions
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
@ -23,7 +21,7 @@ if [ -n "$depend" ]
then then
if [ "$targetType" != objects ] if [ "$targetType" != objects ]
then then
if type cmake > /dev/null 2>&1 if command -v cmake > /dev/null 2>&1
then then
cmakeVersioned "$depend" $PWD || { cmakeVersioned "$depend" $PWD || {
echo echo

View File

@ -3,7 +3,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) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -46,6 +46,36 @@ namespace functionObjects
} }
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
Foam::label Foam::functionObjects::systemCall::dispatch(const stringList& calls)
{
if (calls.empty())
{
return 0;
}
label nCalls = 0;
if (!masterOnly_ || Pstream::master())
{
for (const string& call : calls)
{
Foam::system(call); // Handles empty command as a successful no-op.
++nCalls;
}
}
// MPI barrier
if (masterOnly_)
{
Pstream::scatter(nCalls);
}
return nCalls;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::systemCall::systemCall Foam::functionObjects::systemCall::systemCall
@ -58,27 +88,27 @@ Foam::functionObjects::systemCall::systemCall
functionObject(name), functionObject(name),
executeCalls_(), executeCalls_(),
endCalls_(), endCalls_(),
writeCalls_() writeCalls_(),
masterOnly_(false)
{ {
read(dict); read(dict);
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObjects::systemCall::~systemCall()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::systemCall::read(const dictionary& dict) bool Foam::functionObjects::systemCall::read(const dictionary& dict)
{ {
functionObject::read(dict); functionObject::read(dict);
executeCalls_.clear();
writeCalls_.clear();
endCalls_.clear();
dict.readIfPresent("executeCalls", executeCalls_); dict.readIfPresent("executeCalls", executeCalls_);
dict.readIfPresent("endCalls", endCalls_);
dict.readIfPresent("writeCalls", writeCalls_); dict.readIfPresent("writeCalls", writeCalls_);
dict.readIfPresent("endCalls", endCalls_);
masterOnly_ = dict.lookupOrDefault("master", false);
if (executeCalls_.empty() && endCalls_.empty() && writeCalls_.empty()) if (executeCalls_.empty() && endCalls_.empty() && writeCalls_.empty())
{ {
@ -89,8 +119,8 @@ bool Foam::functionObjects::systemCall::read(const dictionary& dict)
else if (!dynamicCode::allowSystemOperations) else if (!dynamicCode::allowSystemOperations)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Executing user-supplied system calls is not enabled by " << "Executing user-supplied system calls may not be enabled by "
<< "default because of " << nl << "default due to potential " << nl
<< "security issues. If you trust the case you can enable this " << "security issues. If you trust the case you can enable this "
<< "facility by " << nl << "facility by " << nl
<< "adding to the InfoSwitches setting in the system controlDict:" << "adding to the InfoSwitches setting in the system controlDict:"
@ -109,33 +139,21 @@ bool Foam::functionObjects::systemCall::read(const dictionary& dict)
bool Foam::functionObjects::systemCall::execute() bool Foam::functionObjects::systemCall::execute()
{ {
forAll(executeCalls_, calli) dispatch(executeCalls_);
{
Foam::system(executeCalls_[calli]);
}
return true;
}
bool Foam::functionObjects::systemCall::end()
{
forAll(endCalls_, calli)
{
Foam::system(endCalls_[calli]);
}
return true; return true;
} }
bool Foam::functionObjects::systemCall::write() bool Foam::functionObjects::systemCall::write()
{ {
forAll(writeCalls_, calli) dispatch(writeCalls_);
{ return true;
Foam::system(writeCalls_[calli]); }
}
bool Foam::functionObjects::systemCall::end()
{
dispatch(endCalls_);
return true; return true;
} }

View File

@ -28,7 +28,7 @@ Group
grpUtilitiesFunctionObjects grpUtilitiesFunctionObjects
Description Description
Executes system calls, entered in the form of a string lists. Executes system calls, entered in the form of string lists.
Calls can be made at the following points in the calculation: Calls can be made at the following points in the calculation:
- every time step - every time step
@ -36,7 +36,7 @@ Description
- end of the calculation - end of the calculation
Usage Usage
Example of function object specification: Example of the function object specification:
\verbatim \verbatim
systemCall1 systemCall1
{ {
@ -49,11 +49,11 @@ Usage
); );
writeCalls writeCalls
( (
"echo \*\*\* writing data \*\*\*" "echo === writing data ==="
); );
endCalls endCalls
( (
"echo \*\*\* writing .bashrc \*\*\*" "echo === echoing .bashrc ==="
"cat ~/.bashrc" "cat ~/.bashrc"
"echo \*\*\* done \*\*\*" "echo \*\*\* done \*\*\*"
); );
@ -67,6 +67,7 @@ Usage
executeCalls | list of calls on execute | yes | executeCalls | list of calls on execute | yes |
writeCalls | list of calls on write | yes | writeCalls | list of calls on write | yes |
endCalls | list of calls on end | yes | endCalls | list of calls on end | yes |
master | execute on master only | no | false
\endtable \endtable
Note Note
@ -75,6 +76,9 @@ Note
\c allowSystemOperations must be set to '1'; otherwise, system calls will \c allowSystemOperations must be set to '1'; otherwise, system calls will
not be allowed. not be allowed.
Additionally, since the system commands are normally sent via the shell,
special shell character may require backslash escaping.
See also See also
Foam::functionObject Foam::functionObject
Foam::functionObjects::timeControl Foam::functionObjects::timeControl
@ -118,16 +122,20 @@ protected:
//- List of calls to execute - write steps //- List of calls to execute - write steps
stringList writeCalls_; stringList writeCalls_;
//- Perform system calls on the master only
bool masterOnly_;
private:
// Private member functions // Protected Member Functions
//- Dispatch specified calls
label dispatch(const stringList& calls);
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
systemCall(const systemCall&); systemCall(const systemCall&) = delete;
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const systemCall&); void operator=(const systemCall&) = delete;
public: public:
@ -148,22 +156,22 @@ public:
//- Destructor //- Destructor
virtual ~systemCall(); virtual ~systemCall() = default;
// Member Functions // Member Functions
//- Read the system calls //- Read the system calls
virtual bool read(const dictionary&); virtual bool read(const dictionary& dict);
//- Execute the "executeCalls" at each time-step //- Execute the "executeCalls" at each time-step
virtual bool execute(); virtual bool execute();
//- Execute the "endCalls" at the final time-loop
virtual bool end();
//- Write, execute the "writeCalls" //- Write, execute the "writeCalls"
virtual bool write(); virtual bool write();
//- Execute the "endCalls" at the final time-loop
virtual bool end();
}; };

View File

@ -451,8 +451,8 @@ void Foam::triSurfaceTools::getMergedEdges
const triSurface& surf, const triSurface& surf,
const label edgeI, const label edgeI,
const labelHashSet& collapsedFaces, const labelHashSet& collapsedFaces,
HashTable<label, label, Hash<label>>& edgeToEdge, Map<label>& edgeToEdge,
HashTable<label, label, Hash<label>>& edgeToFace Map<label>& edgeToFace
) )
{ {
const edge& e = surf.edges()[edgeI]; const edge& e = surf.edges()[edgeI];
@ -534,8 +534,8 @@ Foam::scalar Foam::triSurfaceTools::edgeCosAngle
const label v1, const label v1,
const point& pt, const point& pt,
const labelHashSet& collapsedFaces, const labelHashSet& collapsedFaces,
const HashTable<label, label, Hash<label>>& edgeToEdge, const Map<label>& edgeToEdge,
const HashTable<label, label, Hash<label>>& edgeToFace, const Map<label>& edgeToFace,
const label facei, const label facei,
const label edgeI const label edgeI
) )
@ -630,8 +630,8 @@ Foam::scalar Foam::triSurfaceTools::collapseMinCosAngle
const label v1, const label v1,
const point& pt, const point& pt,
const labelHashSet& collapsedFaces, const labelHashSet& collapsedFaces,
const HashTable<label, label, Hash<label>>& edgeToEdge, const Map<label>& edgeToEdge,
const HashTable<label, label, Hash<label>>& edgeToFace const Map<label>& edgeToFace
) )
{ {
const labelList& v1Faces = surf.pointFaces()[v1]; const labelList& v1Faces = surf.pointFaces()[v1];
@ -684,8 +684,8 @@ bool Foam::triSurfaceTools::collapseCreatesFold
const label v1, const label v1,
const point& pt, const point& pt,
const labelHashSet& collapsedFaces, const labelHashSet& collapsedFaces,
const HashTable<label, label, Hash<label>>& edgeToEdge, const Map<label>& edgeToEdge,
const HashTable<label, label, Hash<label>>& edgeToFace, const Map<label>& edgeToFace,
const scalar minCos const scalar minCos
) )
{ {
@ -749,7 +749,7 @@ bool Foam::triSurfaceTools::collapseCreatesFold
// // neighbours actually contains the // // neighbours actually contains the
// // edge with which triangle connects to collapsedFaces. // // edge with which triangle connects to collapsedFaces.
// //
// HashTable<label, label, Hash<label>> neighbours; // Map<label> neighbours;
// //
// labelList collapsed = collapsedFaces.toc(); // labelList collapsed = collapsedFaces.toc();
// //

View File

@ -54,6 +54,7 @@ SourceFiles
#include "triadFieldFwd.H" #include "triadFieldFwd.H"
#include "DynamicList.H" #include "DynamicList.H"
#include "HashSet.H" #include "HashSet.H"
#include "Map.H"
#include "FixedList.H" #include "FixedList.H"
#include "Pair.H" #include "Pair.H"
#include "vector2D.H" #include "vector2D.H"
@ -159,8 +160,8 @@ class triSurfaceTools
const triSurface& surf, const triSurface& surf,
const label edgeI, const label edgeI,
const labelHashSet& collapsedFaces, const labelHashSet& collapsedFaces,
HashTable<label, label, Hash<label>>& edgeToEdge, Map<label>& edgeToEdge,
HashTable<label, label, Hash<label>>& edgeToFace Map<label>& edgeToFace
); );
//- Calculates (cos of) angle across edgeI of facei, //- Calculates (cos of) angle across edgeI of facei,
@ -172,8 +173,8 @@ class triSurfaceTools
const label v1, const label v1,
const point& pt, const point& pt,
const labelHashSet& collapsedFaces, const labelHashSet& collapsedFaces,
const HashTable<label, label, Hash<label>>& edgeToEdge, const Map<label>& edgeToEdge,
const HashTable<label, label, Hash<label>>& edgeToFace, const Map<label>& edgeToFace,
const label facei, const label facei,
const label edgeI const label edgeI
); );
@ -188,8 +189,8 @@ class triSurfaceTools
const label v1, const label v1,
const point& pt, const point& pt,
const labelHashSet& collapsedFaces, const labelHashSet& collapsedFaces,
const HashTable<label, label, Hash<label>>& edgeToEdge, const Map<label>& edgeToEdge,
const HashTable<label, label, Hash<label>>& edgeToFace const Map<label>& edgeToFace
); );
//- Like collapseMinCosAngle but return true for value < minCos //- Like collapseMinCosAngle but return true for value < minCos
@ -199,8 +200,8 @@ class triSurfaceTools
const label v1, const label v1,
const point& pt, const point& pt,
const labelHashSet& collapsedFaces, const labelHashSet& collapsedFaces,
const HashTable<label, label, Hash<label>>& edgeToEdge, const Map<label>& edgeToEdge,
const HashTable<label, label, Hash<label>>& edgeToFace, const Map<label>& edgeToFace,
const scalar minCos const scalar minCos
); );
@ -210,7 +211,7 @@ class triSurfaceTools
//( //(
// const triSurface& surf, // const triSurface& surf,
// const label edgeI, // const label edgeI,
// const HashTable<bool, label, Hash<label>>& collapsedFaces // const Map<bool>& collapsedFaces
//); //);
// Tracking // Tracking

View File

@ -312,7 +312,7 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
patchi, patchi,
( (
patches[patchi].name().empty() patches[patchi].name().empty()
? Foam::name("patch%d", patchi) ? word::printf("patch%d", patchi)
: patches[patchi].name() : patches[patchi].name()
) )
); );
@ -345,7 +345,7 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
zoneNames.set zoneNames.set
( (
regionid, regionid,
Foam::name("patch%d", regionid) word::printf("patch%d", regionid)
); );
} }
@ -393,7 +393,7 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
} }
if (name.empty()) if (name.empty())
{ {
name = ::Foam::name("patch%d", regionid); name = word::printf("patch%d", regionid);
} }
zoneLst[zoneI] = surfZone zoneLst[zoneI] = surfZone

View File

@ -306,7 +306,7 @@ bool Foam::discreteSurface::update(const meshSearch& meshSearcher)
patchi, patchi,
( (
patches[patchi].name().empty() patches[patchi].name().empty()
? Foam::name("patch%d", patchi) ? word::printf("patch%d", patchi)
: patches[patchi].name() : patches[patchi].name()
) )
); );
@ -339,7 +339,7 @@ bool Foam::discreteSurface::update(const meshSearch& meshSearcher)
zoneNames.set zoneNames.set
( (
regionid, regionid,
Foam::name("patch%d", regionid) word::printf("patch%d", regionid)
); );
} }
@ -387,7 +387,7 @@ bool Foam::discreteSurface::update(const meshSearch& meshSearcher)
} }
if (name.empty()) if (name.empty())
{ {
name = ::Foam::name("patch%d", regionid); name = word::printf("patch%d", regionid);
} }
zoneLst[zoneI] = surfZone zoneLst[zoneI] = surfZone

View File

@ -220,7 +220,7 @@ private:
} }
else if (elementName[0] == 'E') else if (elementName[0] == 'E')
{ {
elementName = 'e'; elementName = "e";
} }
} }
@ -314,8 +314,7 @@ public:
//- Destructor //- Destructor
virtual ~chemkinReader() virtual ~chemkinReader() = default;
{}
// Member functions // Member functions

View File

@ -0,0 +1,52 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "0";
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "include/initialConditions"
dimensions [0 1 -1 0 0 0 0];
internalField uniform $flowVelocity;
boundaryField
{
#includeEtc "caseDicts/setConstraintTypes"
#include "include/fixedInlet"
outlet
{
type inletOutlet;
inletValue uniform (0 0 0);
value $internalField;
}
lowerWall
{
type fixedValue;
value $internalField;
}
motorBikeGroup
{
type noSlip;
}
#include "include/frontBackUpperPatches"
}
// ************************************************************************* //

View File

@ -0,0 +1,15 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
inlet
{
type fixedValue;
value $internalField;
}
// ************************************************************************* //

View File

@ -0,0 +1,19 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
upperWall
{
type slip;
}
frontAndBack
{
type slip;
}
// ************************************************************************* //

View File

@ -0,0 +1,14 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
flowVelocity (20 0 0);
pressure 0;
turbulentKE 0.24;
turbulentOmega 1.78;
// ************************************************************************* //

View File

@ -0,0 +1,53 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object k;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "include/initialConditions"
dimensions [0 2 -2 0 0 0 0];
internalField uniform $turbulentKE;
boundaryField
{
#includeEtc "caseDicts/setConstraintTypes"
//- Define inlet conditions
#include "include/fixedInlet"
outlet
{
type inletOutlet;
inletValue $internalField;
value $internalField;
}
lowerWall
{
type kqRWallFunction;
value $internalField;
}
motorBikeGroup
{
type kqRWallFunction;
value $internalField;
}
#include "include/frontBackUpperPatches"
}
// ************************************************************************* //

View File

@ -0,0 +1,64 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object nut;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -1 0 0 0 0];
internalField uniform 0;
boundaryField
{
#includeEtc "caseDicts/setConstraintTypes"
frontAndBack
{
type calculated;
value uniform 0;
}
inlet
{
type calculated;
value uniform 0;
}
outlet
{
type calculated;
value uniform 0;
}
lowerWall
{
type nutkWallFunction;
value uniform 0;
}
upperWall
{
type calculated;
value uniform 0;
}
motorBikeGroup
{
type nutkWallFunction;
value uniform 0;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,52 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object omega;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "include/initialConditions"
dimensions [0 0 -1 0 0 0 0];
internalField uniform $turbulentOmega;
boundaryField
{
#includeEtc "caseDicts/setConstraintTypes"
#include "include/fixedInlet"
outlet
{
type inletOutlet;
inletValue $internalField;
value $internalField;
}
lowerWall
{
type omegaWallFunction;
value $internalField;
}
motorBikeGroup
{
type omegaWallFunction;
value $internalField;
}
#include "include/frontBackUpperPatches"
}
// ************************************************************************* //

View File

@ -0,0 +1,51 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "include/initialConditions"
dimensions [0 2 -2 0 0 0 0];
internalField uniform $pressure;
boundaryField
{
#includeEtc "caseDicts/setConstraintTypes"
inlet
{
type zeroGradient;
}
outlet
{
type fixedValue;
value $internalField;
}
lowerWall
{
type zeroGradient;
}
motorBikeGroup
{
type zeroGradient;
}
#include "include/frontBackUpperPatches"
}
// ************************************************************************* //

13
tutorials/IO/systemCall/Allrun Executable file
View File

@ -0,0 +1,13 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions
runApplication blockMesh
runApplication decomposePar
#- For parallel running: set the initial fields
restore0Dir -processor
runParallel $(getApplication)
#------------------------------------------------------------------------------

View File

@ -0,0 +1,21 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
transportModel Newtonian;
nu 1.5e-05;
// ************************************************************************* //

View File

@ -0,0 +1,28 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object turbulenceProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
simulationType RAS;
RAS
{
RASModel kOmegaSST;
turbulence on;
printCoeffs on;
}
// ************************************************************************* //

View File

@ -0,0 +1,86 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
scale 1;
vertices
(
(-5 -4 0)
(15 -4 0)
(15 4 0)
(-5 4 0)
(-5 -4 8)
(15 -4 8)
(15 4 8)
(-5 4 8)
);
blocks
(
hex (0 1 2 3 4 5 6 7) (20 8 8) simpleGrading (1 1 1)
);
edges
(
);
boundary
(
frontAndBack
{
type patch;
faces
(
(3 7 6 2)
(1 5 4 0)
);
}
inlet
{
type patch;
faces
(
(0 4 7 3)
);
}
outlet
{
type patch;
faces
(
(2 6 5 1)
);
}
lowerWall
{
type wall;
faces
(
(0 3 2 1)
);
}
upperWall
{
type patch;
faces
(
(4 5 6 7)
);
}
);
// ************************************************************************* //

View File

@ -0,0 +1,53 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application simpleFoam;
startFrom latestTime;
startTime 0;
stopAt endTime;
endTime 4;
deltaT 1;
writeControl timeStep;
writeInterval 100;
purgeWrite 0;
writeFormat binary;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
functions
{
#include "systemCall"
}
// ************************************************************************* //

View File

@ -0,0 +1,26 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object decomposeParDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
numberOfSubdomains 6;
method hierarchical;
coeffs
{
n (3 2 1);
}
// ************************************************************************* //

View File

@ -0,0 +1,58 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default steadyState;
}
gradSchemes
{
default Gauss linear;
grad(U) cellLimited Gauss linear 1;
}
divSchemes
{
default none;
div(phi,U) bounded Gauss linearUpwindV grad(U);
div(phi,k) bounded Gauss upwind;
div(phi,omega) bounded Gauss upwind;
div((nuEff*dev2(T(grad(U))))) Gauss linear;
}
laplacianSchemes
{
default Gauss linear corrected;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default corrected;
}
wallDist
{
method meshWave;
}
// ************************************************************************* //

View File

@ -0,0 +1,86 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solvers
{
p
{
solver GAMG;
smoother GaussSeidel;
tolerance 1e-7;
relTol 0.01;
}
Phi
{
$p;
}
U
{
solver smoothSolver;
smoother GaussSeidel;
tolerance 1e-8;
relTol 0.1;
nSweeps 1;
}
k
{
solver smoothSolver;
smoother GaussSeidel;
tolerance 1e-8;
relTol 0.1;
nSweeps 1;
}
omega
{
solver smoothSolver;
smoother GaussSeidel;
tolerance 1e-8;
relTol 0.1;
nSweeps 1;
}
}
SIMPLE
{
nNonOrthogonalCorrectors 0;
consistent yes;
}
potentialFlow
{
nNonOrthogonalCorrectors 10;
}
relaxationFactors
{
equations
{
U 0.9;
k 0.7;
omega 0.7;
}
}
cache
{
grad(U);
}
// ************************************************************************* //

View File

@ -0,0 +1,29 @@
// -*- C++ -*-
// An example of using systemCall
system
{
type systemCall;
libs ("libutilityFunctionObjects.so");
// Execute on the master process only
master true;
executeCalls
(
"echo execute: shell $$"
);
writeCalls
(
"echo \*\*\* writing data \*\*\*"
);
endCalls
(
"echo \*\*\* end of run \*\*\*"
"grep application system/controlDict"
"echo \*\*\* done \*\*\*"
);
}
// ************************************************************************* //

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) 2017 OpenCFD Ltd. # \\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# License # License
@ -100,11 +100,9 @@ cmakeVersioned()
sentinel=$(sameDependency "$depend" "$sourceDir") || \ sentinel=$(sameDependency "$depend" "$sourceDir") || \
rm -rf "$objectsDir" > /dev/null 2>&1 rm -rf "$objectsDir" > /dev/null 2>&1
mkdir -p $objectsDir && \ mkdir -p $objectsDir \
( && (cd $objectsDir && _cmake $sourceDir && make) \
cd $objectsDir && _cmake $sourceDir && make \ && echo "$depend" >| "${sentinel:-/dev/null}"
&& echo "$depend" > ${sentinel:-/dev/null}
)
} }