mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'merge-foundation' of develop.openfoam.com:Development/OpenFOAM-plus into merge-foundation
This commit is contained in:
@ -48,14 +48,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
{
|
||||
dictionary dict;
|
||||
dict.add("aaOPENMPIcc", 1);
|
||||
dict.add(word("aa" + getEnv("WM_MPLIB") + "cc"), 16);
|
||||
|
||||
string s("DDD${aa${WM_MPLIB}cc}EEE");
|
||||
stringOps::inplaceExpand(s, dict, true, false);
|
||||
Info<< "variable expansion:" << s << endl;
|
||||
}
|
||||
|
||||
|
||||
Info<< nl
|
||||
<< "FOAM_CASE=" << getEnv("FOAM_CASE") << nl
|
||||
<< "FOAM_CASENAME=" << getEnv("FOAM_CASENAME") << nl
|
||||
@ -65,7 +64,9 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
{
|
||||
dictionary dict1(IFstream("testDict")());
|
||||
Info<< "dict1: " << dict1 << nl
|
||||
dict1.writeEntry("dict1", Info);
|
||||
|
||||
Info<< nl
|
||||
<< "toc: " << dict1.toc() << nl
|
||||
<< "keys: " << dict1.keys() << nl
|
||||
<< "patterns: " << dict1.keys(true) << endl;
|
||||
@ -89,14 +90,14 @@ int main(int argc, char *argv[])
|
||||
<< "no = " << dict4.name() << " " << dict4.toc() << endl;
|
||||
}
|
||||
|
||||
|
||||
IOobject::writeDivider(Info);
|
||||
|
||||
{
|
||||
dictionary dict(IFstream("testDictRegex")());
|
||||
dict.add(keyType("fooba[rz]", true), "anything");
|
||||
|
||||
Info<< "dict:" << dict << nl
|
||||
dict.writeEntry("testDictRegex", Info);
|
||||
Info<< nl
|
||||
<< "toc: " << dict.toc() << nl
|
||||
<< "keys: " << dict.keys() << nl
|
||||
<< "patterns: " << dict.keys(true) << endl;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -31,6 +31,10 @@ Description
|
||||
#include "dictionary.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
#include "int.H"
|
||||
#include "uint.H"
|
||||
#include "scalar.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -118,6 +122,8 @@ int main(int argc, char *argv[])
|
||||
Info<< "after replace: " << test2 << endl;
|
||||
}
|
||||
|
||||
cout<< "\nEnter some string to test:\n";
|
||||
|
||||
string s;
|
||||
Sin.getLine(s);
|
||||
|
||||
@ -126,7 +132,39 @@ int main(int argc, char *argv[])
|
||||
cout<< "output string with " << s2.length() << " characters\n";
|
||||
cout<< "ostream<< >" << s2 << "<\n";
|
||||
Info<< "Ostream<< >" << s2 << "<\n";
|
||||
Info<< "hash:" << hex << string::hash()(s2) << endl;
|
||||
Info<< "hash:" << hex << string::hash()(s2) << dec << endl;
|
||||
|
||||
cout<< "\ntest Foam::name()\n";
|
||||
|
||||
Info<< "hash: = " << Foam::name("0x%012X", string::hash()(s2)) << endl;
|
||||
|
||||
// test formatting on int
|
||||
{
|
||||
label val = 25;
|
||||
Info<<"val: " << val << "\n";
|
||||
|
||||
Info<< "int " << val << " as word >"
|
||||
<< Foam::name(val) << "< or "
|
||||
<< Foam::name("formatted >%08d<", val) << "\n";
|
||||
}
|
||||
|
||||
// test formatting on scalar
|
||||
{
|
||||
scalar val = 3.1415926535897931;
|
||||
Info<< "scalar " << val << " as word >"
|
||||
<< Foam::name(val) << "< or "
|
||||
<< Foam::name("formatted >%.9f<", val) << "\n";
|
||||
}
|
||||
|
||||
// test formatting on uint
|
||||
{
|
||||
uint64_t val = 25000000ul;
|
||||
Info<<"val: " << val << "\n";
|
||||
|
||||
Info<< "uint64 " << val << " as word >"
|
||||
<< Foam::name(val) << "< or "
|
||||
<< Foam::name("formatted >%08d<", val) << "\n";
|
||||
}
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
return 0;
|
||||
|
||||
@ -31,7 +31,7 @@ Description
|
||||
Converts a Star-CD (v4) pro-STAR mesh into OpenFOAM format.
|
||||
|
||||
Usage
|
||||
\b star4ToFoam [OPTION] ccmMesh
|
||||
\b star4ToFoam [OPTION] prostarMesh
|
||||
|
||||
Options:
|
||||
- \par -ascii
|
||||
|
||||
@ -39,34 +39,34 @@ Usage
|
||||
Write the cell distribution as a labelList, for use with 'manual'
|
||||
decomposition method or as a volScalarField for post-processing.
|
||||
|
||||
- \par -region \<regionName\> \n
|
||||
- \par -region \<regionName\>
|
||||
Decompose named region. Does not check for existence of processor*.
|
||||
|
||||
- \par -allRegions \n
|
||||
- \par -allRegions
|
||||
Decompose all regions in regionProperties. Does not check for
|
||||
existence of processor*.
|
||||
|
||||
- \par -copyUniform \n
|
||||
- \par -copyUniform
|
||||
Copy any \a uniform directories too.
|
||||
|
||||
- \par -constant
|
||||
|
||||
- \par -time xxx:yyy \n
|
||||
- \par -time xxx:yyy
|
||||
Override controlDict settings and decompose selected times. Does not
|
||||
re-decompose the mesh i.e. does not handle moving mesh or changing
|
||||
mesh cases.
|
||||
|
||||
- \par -fields \n
|
||||
- \par -fields
|
||||
Use existing geometry decomposition and convert fields only.
|
||||
|
||||
- \par -noSets \n
|
||||
- \par -noSets
|
||||
Skip decomposing cellSets, faceSets, pointSets.
|
||||
|
||||
- \par -force \n
|
||||
- \par -force
|
||||
Remove any existing \a processor subdirectories before decomposing the
|
||||
geometry.
|
||||
|
||||
- \par -ifRequired \n
|
||||
- \par -ifRequired
|
||||
Only decompose the geometry if the number of domains has changed from a
|
||||
previous decomposition. No \a processor subdirectories will be removed
|
||||
unless the \a -force option is also specified. This option can be used
|
||||
|
||||
@ -34,7 +34,6 @@ Description
|
||||
|
||||
Usage
|
||||
\b foamToEnsight [OPTION]
|
||||
Translates OpenFOAM data to EnSight format
|
||||
|
||||
Options:
|
||||
- \par -ascii
|
||||
@ -43,29 +42,28 @@ Usage
|
||||
- \par -noZero
|
||||
Exclude the often incomplete initial conditions.
|
||||
|
||||
- \par -noLagrangian \n
|
||||
- \par -noLagrangian
|
||||
Suppress writing lagrangian positions and fields.
|
||||
|
||||
- \par -noPatches
|
||||
Suppress writing any patches.
|
||||
|
||||
- \par -patches patchList \n
|
||||
- \par -patches patchList
|
||||
Specify particular patches to write.
|
||||
Specifying an empty list suppresses writing the internalMesh.
|
||||
|
||||
- \par -faceZones zoneList \n
|
||||
- \par -faceZones zoneList
|
||||
Specify faceZones to write, with wildcards
|
||||
|
||||
- \par -cellZone zoneName
|
||||
Specify single cellZone to write (not lagrangian)
|
||||
|
||||
- \par -width \<n\>\n
|
||||
- \par -width \<n\>
|
||||
Width of EnSight data subdir (default: 8)
|
||||
|
||||
Note
|
||||
Parallel support for cloud data is not supported
|
||||
- writes to \a EnSight directory to avoid collisions with
|
||||
foamToEnsightParts
|
||||
Writes to \a EnSight directory to avoid collisions with
|
||||
foamToEnsightParts
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
@ -48,10 +48,10 @@ Usage
|
||||
Ignore the time index contained in the time file and use a
|
||||
simple indexing when creating the \c Ensight/data/######## files.
|
||||
|
||||
- \par -noLagrangian \n
|
||||
- \par -noLagrangian
|
||||
Suppress writing lagrangian positions and fields.
|
||||
|
||||
- \par -index \<start\>\n
|
||||
- \par -index \<start\>
|
||||
Ignore the time index contained in the time file and use a
|
||||
simple indexing when creating the \c Ensight/data/######## files.
|
||||
|
||||
|
||||
@ -72,10 +72,10 @@ Usage
|
||||
- \par -noInternal
|
||||
Do not generate file for mesh, only for patches
|
||||
|
||||
- \par -noLagrangian \n
|
||||
- \par -noLagrangian
|
||||
Suppress writing lagrangian positions and fields.
|
||||
|
||||
- \par -noPointValues \n
|
||||
- \par -noPointValues
|
||||
No pointFields
|
||||
|
||||
- \par -noFaceZones
|
||||
|
||||
@ -36,25 +36,25 @@ Usage
|
||||
\b surfaceMeshImport inputFile [OPTION]
|
||||
|
||||
Options:
|
||||
- \par -clean \n
|
||||
- \par -clean
|
||||
Perform some surface checking/cleanup on the input surface.
|
||||
|
||||
- \par -name \<name\> \n
|
||||
- \par -name \<name\>
|
||||
Specify an alternative surface name when writing.
|
||||
|
||||
- \par -scaleIn \<scale\> \n
|
||||
- \par -scaleIn \<scale\>
|
||||
Specify a scaling factor when reading files.
|
||||
|
||||
- \par -scaleOut \<scale\> \n
|
||||
- \par -scaleOut \<scale\>
|
||||
Specify a scaling factor when writing files.
|
||||
|
||||
- \par -dict \<dictionary\> \n
|
||||
- \par -dict \<dictionary\>
|
||||
Specify an alternative dictionary for constant/coordinateSystems.
|
||||
|
||||
- \par -from \<coordinateSystem\> \n
|
||||
- \par -from \<coordinateSystem\>
|
||||
Specify a coordinate system when reading files.
|
||||
|
||||
- \par -to \<coordinateSystem\> \n
|
||||
- \par -to \<coordinateSystem\>
|
||||
Specify a coordinate system when writing files.
|
||||
|
||||
Note
|
||||
|
||||
@ -42,13 +42,13 @@ Foam::Istream& Foam::operator>>(Istream& is, CompactListList<T, Container>& lst)
|
||||
{
|
||||
is >> lst.offsets_ >> lst.m_;
|
||||
// Note: empty list gets output as two empty lists
|
||||
if (lst.offsets_.size() == 0)
|
||||
if (lst.offsets_.size())
|
||||
{
|
||||
lst.size_ = 0;
|
||||
lst.size_ = lst.offsets_.size()-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
lst.size_ = lst.offsets_.size()-1;
|
||||
lst.size_ = 0;
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
@ -118,6 +118,8 @@ Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList<T, Size>& L)
|
||||
}
|
||||
else
|
||||
{
|
||||
// contents are binary and contiguous
|
||||
|
||||
is.read(reinterpret_cast<char*>(L.data()), Size*sizeof(T));
|
||||
|
||||
is.fatalCheck
|
||||
@ -136,12 +138,10 @@ Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList<T, Size>& L)
|
||||
template<class T, unsigned Size>
|
||||
void Foam::FixedList<T, Size>::writeEntry(Ostream& os) const
|
||||
{
|
||||
if
|
||||
(
|
||||
token::compound::isCompound("List<" + word(pTraits<T>::typeName) + '>')
|
||||
)
|
||||
const word tag = "List<" + word(pTraits<T>::typeName) + '>';
|
||||
if (token::compound::isCompound(tag))
|
||||
{
|
||||
os << word("List<" + word(pTraits<T>::typeName) + '>') << " ";
|
||||
os << tag << " ";
|
||||
}
|
||||
|
||||
os << *this;
|
||||
@ -167,12 +167,10 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const FixedList<T, Size>& L)
|
||||
// Write list contents depending on data format
|
||||
if (os.format() == IOstream::ASCII || !contiguous<T>())
|
||||
{
|
||||
bool uniform = false;
|
||||
|
||||
if (Size > 1 && contiguous<T>())
|
||||
// Can the contents be considered 'uniform' (ie, identical)?
|
||||
bool uniform = (Size > 1 && contiguous<T>());
|
||||
if (uniform)
|
||||
{
|
||||
uniform = true;
|
||||
|
||||
forAll(L, i)
|
||||
{
|
||||
if (L[i] != L[0])
|
||||
@ -194,7 +192,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const FixedList<T, Size>& L)
|
||||
// Write end delimiter
|
||||
os << token::END_BLOCK;
|
||||
}
|
||||
else if (Size <= 1 ||(Size < 11 && contiguous<T>()))
|
||||
else if (Size <= 1 || (Size < 11 && contiguous<T>()))
|
||||
{
|
||||
// Write start delimiter
|
||||
os << token::BEGIN_LIST;
|
||||
@ -202,7 +200,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const FixedList<T, Size>& L)
|
||||
// Write contents
|
||||
forAll(L, i)
|
||||
{
|
||||
if (i > 0) os << token::SPACE;
|
||||
if (i) os << token::SPACE;
|
||||
os << L[i];
|
||||
}
|
||||
|
||||
@ -226,6 +224,9 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const FixedList<T, Size>& L)
|
||||
}
|
||||
else
|
||||
{
|
||||
// Contents are binary and contiguous
|
||||
|
||||
// write(...) includes surrounding start/end delimiters
|
||||
os.write(reinterpret_cast<const char*>(L.cdata()), Size*sizeof(T));
|
||||
}
|
||||
|
||||
|
||||
@ -92,6 +92,8 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& L)
|
||||
}
|
||||
else
|
||||
{
|
||||
// uniform content (delimiter == token::BEGIN_BLOCK)
|
||||
|
||||
T element;
|
||||
is >> element;
|
||||
|
||||
@ -113,6 +115,8 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& L)
|
||||
}
|
||||
else
|
||||
{
|
||||
// contents are binary and contiguous
|
||||
|
||||
if (s)
|
||||
{
|
||||
is.read(reinterpret_cast<char*>(L.data()), s*sizeof(T));
|
||||
|
||||
@ -407,12 +407,10 @@ Foam::Ostream& Foam::PackedList<nBits>::write
|
||||
// Write list contents depending on data format
|
||||
if (os.format() == IOstream::ASCII)
|
||||
{
|
||||
bool uniform = false;
|
||||
|
||||
if (sz > 1 && !indexedOutput)
|
||||
// Can the contents be considered 'uniform' (ie, identical)?
|
||||
bool uniform = (sz > 1 && !indexedOutput);
|
||||
if (uniform)
|
||||
{
|
||||
uniform = true;
|
||||
|
||||
forAll(lst, i)
|
||||
{
|
||||
if (lst[i] != lst[0])
|
||||
@ -475,9 +473,12 @@ Foam::Ostream& Foam::PackedList<nBits>::write
|
||||
}
|
||||
else
|
||||
{
|
||||
// Contents are binary and contiguous
|
||||
|
||||
os << nl << sz << nl;
|
||||
if (sz)
|
||||
{
|
||||
// write(...) includes surrounding start/end delimiters
|
||||
os.write
|
||||
(
|
||||
reinterpret_cast<const char*>(lst.storage().cdata()),
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -40,12 +40,10 @@ Foam::Ostream& Foam::operator<<
|
||||
// Write list contents depending on data format
|
||||
if (os.format() == IOstream::ASCII || !contiguous<T>())
|
||||
{
|
||||
bool uniform = false;
|
||||
|
||||
if (L.size() > 1 && contiguous<T>())
|
||||
// Can the contents be considered 'uniform' (ie, identical)?
|
||||
bool uniform = (L.size() > 1 && contiguous<T>());
|
||||
if (uniform)
|
||||
{
|
||||
uniform = true;
|
||||
|
||||
forAll(L, i)
|
||||
{
|
||||
if (L[i] != L[0])
|
||||
@ -99,14 +97,15 @@ Foam::Ostream& Foam::operator<<
|
||||
}
|
||||
else
|
||||
{
|
||||
// this is annoying, and wasteful, but there's currently no alternative
|
||||
|
||||
// Contents are binary and contiguous
|
||||
os << nl << L.size() << nl;
|
||||
|
||||
if (L.size())
|
||||
{
|
||||
// This is annoying, and wasteful, but currently no alternative
|
||||
List<T> lst = L();
|
||||
|
||||
// write(...) includes surrounding start/end delimiters
|
||||
os.write
|
||||
(
|
||||
reinterpret_cast<const char*>(lst.cdata()),
|
||||
|
||||
@ -219,7 +219,7 @@ public:
|
||||
//- Copy elements of the given UList
|
||||
void deepCopy(const UList<T>&);
|
||||
|
||||
//- Write the UList as a dictionary entry
|
||||
//- Write the UList with its compound type
|
||||
void writeEntry(Ostream&) const;
|
||||
|
||||
//- Write the UList as a dictionary entry with keyword
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -34,19 +34,25 @@ License
|
||||
template<class T>
|
||||
void Foam::UList<T>::writeEntry(Ostream& os) const
|
||||
{
|
||||
if
|
||||
(
|
||||
size()
|
||||
&& token::compound::isCompound
|
||||
(
|
||||
"List<" + word(pTraits<T>::typeName) + '>'
|
||||
)
|
||||
)
|
||||
if (size())
|
||||
{
|
||||
os << word("List<" + word(pTraits<T>::typeName) + '>') << " ";
|
||||
const word tag = "List<" + word(pTraits<T>::typeName) + '>';
|
||||
if (token::compound::isCompound(tag))
|
||||
{
|
||||
os << tag << ' ';
|
||||
}
|
||||
os << *this;
|
||||
}
|
||||
else if (os.format() == IOstream::ASCII)
|
||||
{
|
||||
// Zero-sized ASCII - Write size and delimiters
|
||||
os << 0 << token::BEGIN_LIST << token::END_LIST;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Zero-sized binary - Write size only
|
||||
os << 0;
|
||||
}
|
||||
|
||||
os << *this;
|
||||
}
|
||||
|
||||
|
||||
@ -65,12 +71,10 @@ Foam::Ostream& Foam::operator<<(Foam::Ostream& os, const Foam::UList<T>& L)
|
||||
// Write list contents depending on data format
|
||||
if (os.format() == IOstream::ASCII || !contiguous<T>())
|
||||
{
|
||||
bool uniform = false;
|
||||
|
||||
if (L.size() > 1 && contiguous<T>())
|
||||
// Can the contents be considered 'uniform' (ie, identical)?
|
||||
bool uniform = (L.size() > 1 && contiguous<T>());
|
||||
if (uniform)
|
||||
{
|
||||
uniform = true;
|
||||
|
||||
forAll(L, i)
|
||||
{
|
||||
if (L[i] != L[0])
|
||||
@ -100,7 +104,7 @@ Foam::Ostream& Foam::operator<<(Foam::Ostream& os, const Foam::UList<T>& L)
|
||||
// Write contents
|
||||
forAll(L, i)
|
||||
{
|
||||
if (i > 0) os << token::SPACE;
|
||||
if (i) os << token::SPACE;
|
||||
os << L[i];
|
||||
}
|
||||
|
||||
@ -124,10 +128,13 @@ Foam::Ostream& Foam::operator<<(Foam::Ostream& os, const Foam::UList<T>& L)
|
||||
}
|
||||
else
|
||||
{
|
||||
// Contents are binary and contiguous
|
||||
os << nl << L.size() << nl;
|
||||
|
||||
if (L.size())
|
||||
{
|
||||
os.write(reinterpret_cast<const char*>(L.v_), L.byteSize());
|
||||
// write(...) includes surrounding start/end delimiters
|
||||
os.write(reinterpret_cast<const char*>(L.cdata()), L.byteSize());
|
||||
}
|
||||
}
|
||||
|
||||
@ -208,6 +215,8 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& L)
|
||||
}
|
||||
else
|
||||
{
|
||||
// uniform content (delimiter == token::BEGIN_BLOCK)
|
||||
|
||||
T element;
|
||||
is >> element;
|
||||
|
||||
@ -229,6 +238,8 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& L)
|
||||
}
|
||||
else
|
||||
{
|
||||
// contents are binary and contiguous
|
||||
|
||||
if (s)
|
||||
{
|
||||
is.read(reinterpret_cast<char*>(L.data()), s*sizeof(T));
|
||||
|
||||
@ -79,11 +79,9 @@ Foam::Ostream& Foam::Ostream::writeKeyword(const keyType& kw)
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::Ostream::beginBlock(const word& keyword)
|
||||
Foam::Ostream& Foam::Ostream::beginBlock(const keyType& keyword)
|
||||
{
|
||||
indent();
|
||||
write(keyword);
|
||||
endl();
|
||||
indent(); write(keyword); write('\n');
|
||||
beginBlock();
|
||||
|
||||
return *this;
|
||||
@ -92,8 +90,7 @@ Foam::Ostream& Foam::Ostream::beginBlock(const word& keyword)
|
||||
|
||||
Foam::Ostream& Foam::Ostream::beginBlock()
|
||||
{
|
||||
indent();
|
||||
write(char(token::BEGIN_BLOCK));
|
||||
indent(); write(char(token::BEGIN_BLOCK)); write('\n');
|
||||
incrIndent();
|
||||
|
||||
return *this;
|
||||
@ -103,8 +100,15 @@ Foam::Ostream& Foam::Ostream::beginBlock()
|
||||
Foam::Ostream& Foam::Ostream::endBlock()
|
||||
{
|
||||
decrIndent();
|
||||
indent();
|
||||
write(char(token::END_BLOCK));
|
||||
indent(); write(char(token::END_BLOCK)); write('\n');
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::Ostream::endEntry()
|
||||
{
|
||||
write(char(token::END_STATEMENT)); write('\n');
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -154,33 +154,47 @@ public:
|
||||
return indentLevel_;
|
||||
}
|
||||
|
||||
//- Incrememt the indent level
|
||||
//- Increment the indent level
|
||||
void incrIndent()
|
||||
{
|
||||
++indentLevel_;
|
||||
}
|
||||
|
||||
//- Decrememt the indent level
|
||||
//- Decrement the indent level
|
||||
void decrIndent();
|
||||
|
||||
//- Write the keyword followed by an appropriate indentation
|
||||
virtual Ostream& writeKeyword(const keyType&);
|
||||
|
||||
//- Write begin block group with the given name
|
||||
// Uses the appropriate indentation,
|
||||
// does not include a trailing newline.
|
||||
virtual Ostream& beginBlock(const word&);
|
||||
// Increments indentation, adds newline.
|
||||
virtual Ostream& beginBlock(const keyType&);
|
||||
|
||||
//- Write begin block group without a name
|
||||
// Uses the appropriate indentation,
|
||||
// does not include a trailing newline.
|
||||
// Increments indentation, adds newline.
|
||||
virtual Ostream& beginBlock();
|
||||
|
||||
//- Write end block group
|
||||
// Uses the appropriate indentation,
|
||||
// does not include a trailing newline.
|
||||
// Decrements indentation, adds newline.
|
||||
virtual Ostream& endBlock();
|
||||
|
||||
//- Write end entry (';') followed by newline.
|
||||
virtual Ostream& endEntry();
|
||||
|
||||
//- Write a keyword/value entry.
|
||||
// The following two are functionally equivalent:
|
||||
// \code
|
||||
// os.writeEntry(key, value);
|
||||
//
|
||||
// os.writeKeyword(key) << value << endEntry;
|
||||
// \endcode
|
||||
template<class T>
|
||||
Ostream& writeEntry(const keyType& key, const T& value)
|
||||
{
|
||||
writeKeyword(key) << value;
|
||||
return endEntry();
|
||||
}
|
||||
|
||||
|
||||
// Stream state functions
|
||||
|
||||
@ -273,6 +287,32 @@ inline Ostream& endl(Ostream& os)
|
||||
}
|
||||
|
||||
|
||||
//- Write begin block group without a name
|
||||
// Increments indentation, adds newline.
|
||||
inline Ostream& beginBlock(Ostream& os)
|
||||
{
|
||||
os.beginBlock();
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
//- Write end block group
|
||||
// Decrements indentation, adds newline.
|
||||
inline Ostream& endBlock(Ostream& os)
|
||||
{
|
||||
os.endBlock();
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
//- Write end entry (';') followed by newline.
|
||||
inline Ostream& endEntry(Ostream& os)
|
||||
{
|
||||
os.endEntry();
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// Useful aliases for tab and newline characters
|
||||
static const char tab = '\t';
|
||||
static const char nl = '\n';
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -503,6 +503,14 @@ public:
|
||||
|
||||
// Write
|
||||
|
||||
//- Write sub-dictionary with the keyword as its header
|
||||
void writeEntry(const keyType& keyword, Ostream&) const;
|
||||
|
||||
//- Write dictionary entries.
|
||||
// Optionally with extra new line between entries for
|
||||
// "top-level" dictionaries
|
||||
void writeEntries(Ostream&, const bool extraNewLine=false) const;
|
||||
|
||||
//- Write dictionary, normally with sub-dictionary formatting
|
||||
void write(Ostream&, const bool subDict=true) const;
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -68,10 +68,7 @@ Foam::dictionaryEntry::dictionaryEntry
|
||||
|
||||
void Foam::dictionaryEntry::write(Ostream& os) const
|
||||
{
|
||||
// write keyword with indent but without trailing spaces
|
||||
os.indent();
|
||||
os.write(keyword());
|
||||
dictionary::write(os);
|
||||
dictionary::writeEntry(keyword(), os);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -170,14 +170,16 @@ Foam::Istream& Foam::operator>>(Istream& is, dictionary& dict)
|
||||
|
||||
// * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::dictionary::write(Ostream& os, bool subDict) const
|
||||
void Foam::dictionary::writeEntry(const keyType& kw, Ostream& os) const
|
||||
{
|
||||
if (subDict)
|
||||
{
|
||||
os << nl;
|
||||
os.beginBlock() << nl;
|
||||
}
|
||||
os.beginBlock(kw);
|
||||
writeEntries(os);
|
||||
os.endBlock() << flush;
|
||||
}
|
||||
|
||||
|
||||
void Foam::dictionary::writeEntries(Ostream& os, const bool extraNewLine) const
|
||||
{
|
||||
forAllConstIter(IDLList<entry>, *this, iter)
|
||||
{
|
||||
const entry& e = *iter;
|
||||
@ -185,8 +187,9 @@ void Foam::dictionary::write(Ostream& os, bool subDict) const
|
||||
// Write entry
|
||||
os << e;
|
||||
|
||||
// Add extra new line between entries for "top-level" dictionaries
|
||||
if (!subDict && parent() == dictionary::null && e != *last())
|
||||
// Add extra new line between entries for "top-level" dictionaries,
|
||||
// but not after the last entry (looks ugly).
|
||||
if (extraNewLine && parent() == dictionary::null && e != *last())
|
||||
{
|
||||
os << nl;
|
||||
}
|
||||
@ -200,10 +203,22 @@ void Foam::dictionary::write(Ostream& os, bool subDict) const
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::dictionary::write(Ostream& os, const bool subDict) const
|
||||
{
|
||||
if (subDict)
|
||||
{
|
||||
os << nl;
|
||||
os.beginBlock();
|
||||
}
|
||||
|
||||
writeEntries(os, !subDict);
|
||||
|
||||
if (subDict)
|
||||
{
|
||||
os.endBlock() << endl;
|
||||
os.endBlock() << flush;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -727,12 +727,10 @@ void Foam::Field<Type>::writeEntry(const word& keyword, Ostream& os) const
|
||||
{
|
||||
os.writeKeyword(keyword);
|
||||
|
||||
bool uniform = false;
|
||||
|
||||
if (this->size() && contiguous<Type>())
|
||||
// Can the contents be considered 'uniform' (ie, identical)?
|
||||
bool uniform = (this->size() && contiguous<Type>());
|
||||
if (uniform)
|
||||
{
|
||||
uniform = true;
|
||||
|
||||
forAll(*this, i)
|
||||
{
|
||||
if (this->operator[](i) != this->operator[](0))
|
||||
|
||||
@ -569,16 +569,16 @@ template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
void Foam::GeometricField<Type, PatchField, GeoMesh>::Boundary::
|
||||
writeEntry(const word& keyword, Ostream& os) const
|
||||
{
|
||||
os.beginBlock(keyword) << nl;
|
||||
os.beginBlock(keyword);
|
||||
|
||||
forAll(*this, patchi)
|
||||
{
|
||||
os.beginBlock(this->operator[](patchi).patch().name()) << nl;
|
||||
os.beginBlock(this->operator[](patchi).patch().name());
|
||||
os << this->operator[](patchi);
|
||||
os.endBlock() << endl;
|
||||
os.endBlock();
|
||||
}
|
||||
|
||||
os.endBlock() << endl;
|
||||
os.endBlock() << flush;
|
||||
|
||||
// Check state of IOstream
|
||||
os.check
|
||||
|
||||
@ -41,17 +41,6 @@ Foam::label Foam::profiling::Information::nextId_(0);
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
// file-scope function
|
||||
template<class T>
|
||||
inline static void writeEntry
|
||||
(
|
||||
Foam::Ostream& os, const Foam::word& key, const T& value
|
||||
)
|
||||
{
|
||||
os.writeKeyword(key) << value << Foam::token::END_STATEMENT << '\n';
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::profiling::Information::getNextId()
|
||||
{
|
||||
return nextId_++;
|
||||
@ -369,7 +358,7 @@ void Foam::profiling::Information::update(const scalar& elapsed)
|
||||
|
||||
bool Foam::profiling::writeData(Ostream& os) const
|
||||
{
|
||||
os.beginBlock("profiling") << nl; // FUTURE: without nl
|
||||
os.beginBlock("profiling");
|
||||
|
||||
// Add extra new line between entries
|
||||
label nTrigger = 0;
|
||||
@ -420,22 +409,22 @@ bool Foam::profiling::writeData(Ostream& os) const
|
||||
}
|
||||
}
|
||||
|
||||
os.endBlock() << nl; // FUTURE: without nl
|
||||
os.endBlock();
|
||||
|
||||
if (sysInfo_)
|
||||
{
|
||||
os << nl;
|
||||
os.beginBlock("sysInfo") << nl; // FUTURE: without nl
|
||||
os.beginBlock("sysInfo");
|
||||
sysInfo_->write(os);
|
||||
os.endBlock() << nl; // FUTURE: without nl
|
||||
os.endBlock();
|
||||
}
|
||||
|
||||
if (cpuInfo_)
|
||||
{
|
||||
os << nl;
|
||||
os.beginBlock("cpuInfo") << nl; // FUTURE: without nl
|
||||
os.beginBlock("cpuInfo");
|
||||
cpuInfo_->write(os);
|
||||
os.endBlock() << nl; // FUTURE: without nl
|
||||
os.endBlock();
|
||||
}
|
||||
|
||||
if (memInfo_)
|
||||
@ -443,10 +432,10 @@ bool Foam::profiling::writeData(Ostream& os) const
|
||||
memInfo_->update();
|
||||
|
||||
os << nl;
|
||||
os.beginBlock("memInfo") << nl; // FUTURE: without nl
|
||||
os.beginBlock("memInfo");
|
||||
memInfo_->write(os);
|
||||
writeEntry(os, "units", "kB");
|
||||
os.endBlock() << nl; // FUTURE: without nl
|
||||
os.writeEntry("units", "kB");
|
||||
os.endBlock();
|
||||
}
|
||||
|
||||
return os;
|
||||
@ -536,26 +525,24 @@ Foam::Ostream& Foam::profiling::Information::write
|
||||
{
|
||||
// write in dictionary format
|
||||
|
||||
os.beginBlock("trigger" + Foam::name(id_)) << nl; // FUTURE: without nl
|
||||
os.beginBlock(word("trigger" + Foam::name(id_)));
|
||||
|
||||
// FUTURE: os.writeEntry(key, value);
|
||||
|
||||
writeEntry(os, "id", id_);
|
||||
os.writeEntry("id", id_);
|
||||
if (id_ != parent().id())
|
||||
{
|
||||
writeEntry(os, "parentId", parent().id());
|
||||
os.writeEntry("parentId", parent().id());
|
||||
}
|
||||
writeEntry(os, "description", description());
|
||||
writeEntry(os, "calls", calls() + (offset ? 1 : 0));
|
||||
writeEntry(os, "totalTime", totalTime() + elapsedTime);
|
||||
writeEntry(os, "childTime", childTime() + childTimes);
|
||||
os.writeEntry("description", description());
|
||||
os.writeEntry("calls", calls() + (offset ? 1 : 0));
|
||||
os.writeEntry("totalTime", totalTime() + elapsedTime);
|
||||
os.writeEntry("childTime", childTime() + childTimes);
|
||||
if (maxMem_)
|
||||
{
|
||||
writeEntry(os, "maxMem", maxMem_);
|
||||
os.writeEntry("maxMem", maxMem_);
|
||||
}
|
||||
writeEntry(os, "onStack", Switch(onStack()));
|
||||
os.writeEntry("onStack", Switch(onStack()));
|
||||
|
||||
os.endBlock() << nl; // FUTURE: without nl
|
||||
os.endBlock();
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
@ -29,17 +29,6 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
// file-scope function
|
||||
template<class T>
|
||||
inline static void writeEntry
|
||||
(
|
||||
Foam::Ostream& os, const Foam::word& key, const T& value
|
||||
)
|
||||
{
|
||||
os.writeKeyword(key) << value << Foam::token::END_STATEMENT << '\n';
|
||||
}
|
||||
|
||||
|
||||
// file-scope function
|
||||
inline static void printEnv
|
||||
(
|
||||
@ -49,7 +38,7 @@ inline static void printEnv
|
||||
const std::string value = getEnv(envName);
|
||||
if (!value.empty())
|
||||
{
|
||||
writeEntry(os, key, value);
|
||||
os.writeEntry(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,12 +63,12 @@ Foam::Ostream& Foam::profiling::sysInfo::write
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
writeEntry(os, "host", hostName(false)); // short name
|
||||
writeEntry(os, "date", clock::dateTime());
|
||||
os.writeEntry("host", hostName(false)); // short name
|
||||
os.writeEntry("date", clock::dateTime());
|
||||
|
||||
// compile-time information
|
||||
writeEntry(os, "version", std::string(FOAMversion));
|
||||
writeEntry(os, "build", std::string(FOAMbuild));
|
||||
os.writeEntry("version", std::string(FOAMversion));
|
||||
os.writeEntry("build", std::string(FOAMbuild));
|
||||
|
||||
printEnv(os, "arch", "WM_ARCH");
|
||||
printEnv(os, "compilerType", "WM_COMPILER_TYPE");
|
||||
|
||||
@ -51,12 +51,6 @@ class Ostream;
|
||||
|
||||
class profiling::sysInfo
|
||||
{
|
||||
// Private Static Data Members
|
||||
|
||||
|
||||
// Private Data Members
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
@ -72,9 +66,6 @@ protected:
|
||||
|
||||
friend class profiling;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
public:
|
||||
|
||||
|
||||
@ -90,11 +81,6 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
//- Update it with a new timing information
|
||||
void update();
|
||||
|
||||
|
||||
@ -160,15 +160,13 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const Matrix<Form, Type>& M)
|
||||
{
|
||||
if (mn)
|
||||
{
|
||||
bool uniform = false;
|
||||
|
||||
const Type* v = M.v_;
|
||||
|
||||
if (mn > 1 && contiguous<Type>())
|
||||
// can the contents be considered 'uniform' (ie, identical)
|
||||
bool uniform = (mn > 1 && contiguous<Type>());
|
||||
if (uniform)
|
||||
{
|
||||
uniform = true;
|
||||
|
||||
for (label i=0; i<mn; i++)
|
||||
for (label i=0; i<mn; ++i)
|
||||
{
|
||||
if (v[i] != v[0])
|
||||
{
|
||||
@ -180,18 +178,18 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const Matrix<Form, Type>& M)
|
||||
|
||||
if (uniform)
|
||||
{
|
||||
// Write size of list and start contents delimiter
|
||||
// Write start delimiter
|
||||
os << token::BEGIN_BLOCK;
|
||||
|
||||
// Write list contents
|
||||
// Write contents
|
||||
os << v[0];
|
||||
|
||||
// Write end of contents delimiter
|
||||
// Write end delimiter
|
||||
os << token::END_BLOCK;
|
||||
}
|
||||
else if (mn < 10 && contiguous<Type>())
|
||||
{
|
||||
// Write size of list and start contents delimiter
|
||||
// Write start contents delimiter
|
||||
os << token::BEGIN_LIST;
|
||||
|
||||
label k = 0;
|
||||
@ -204,7 +202,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const Matrix<Form, Type>& M)
|
||||
// Write row
|
||||
for (label j=0; j< M.n(); j++)
|
||||
{
|
||||
if (j > 0) os << token::SPACE;
|
||||
if (j) os << token::SPACE;
|
||||
os << v[k++];
|
||||
}
|
||||
|
||||
@ -216,7 +214,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const Matrix<Form, Type>& M)
|
||||
}
|
||||
else
|
||||
{
|
||||
// Write size of list and start contents delimiter
|
||||
// Write start contents delimiter
|
||||
os << nl << token::BEGIN_LIST;
|
||||
|
||||
label k = 0;
|
||||
|
||||
@ -1120,9 +1120,9 @@ bool Foam::polyBoundaryMesh::writeData(Ostream& os) const
|
||||
|
||||
forAll(patches, patchi)
|
||||
{
|
||||
os.beginBlock(patches[patchi].name()) << nl;
|
||||
os.beginBlock(patches[patchi].name());
|
||||
os << patches[patchi];
|
||||
os.endBlock() << endl;
|
||||
os.endBlock();
|
||||
}
|
||||
|
||||
os << decrIndent << token::END_LIST;
|
||||
|
||||
@ -449,15 +449,14 @@ Foam::point Foam::plane::mirror(const point& p) const
|
||||
|
||||
void Foam::plane::writeDict(Ostream& os) const
|
||||
{
|
||||
os.writeKeyword("planeType") << "pointAndNormal"
|
||||
<< token::END_STATEMENT << nl;
|
||||
os.writeEntry("planeType", "pointAndNormal");
|
||||
|
||||
os.beginBlock("pointAndNormalDict") << nl;
|
||||
os.beginBlock("pointAndNormalDict");
|
||||
|
||||
os.writeKeyword("point") << point_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("normal") << normal_ << token::END_STATEMENT << nl;
|
||||
os.writeEntry("point", point_);
|
||||
os.writeEntry("normal", normal_);
|
||||
|
||||
os.endBlock() << endl;
|
||||
os.endBlock() << flush;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -23,6 +23,8 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "stringOps.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
@ -62,6 +64,18 @@ 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);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
Scalar readScalar(Istream& is)
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -109,6 +109,16 @@ public:
|
||||
word name(const Scalar);
|
||||
|
||||
|
||||
//- 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);
|
||||
|
||||
|
||||
//- 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);
|
||||
|
||||
|
||||
// Standard C++ transcendental functions
|
||||
transFunc(sqrt)
|
||||
|
||||
|
||||
@ -263,41 +263,28 @@ template<class Type>
|
||||
void Foam::Function1Types::CSV<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
Function1<Type>::writeData(os);
|
||||
os << token::END_STATEMENT << nl;
|
||||
os.endEntry();
|
||||
|
||||
os.beginBlock(word(this->name() + "Coeffs")) << nl;
|
||||
os.beginBlock(word(this->name() + "Coeffs"));
|
||||
|
||||
// Note: for TableBase write the dictionary entries it needs but not
|
||||
// the values themselves
|
||||
TableBase<Type>::writeEntries(os);
|
||||
|
||||
os.writeKeyword("nHeaderLine") << nHeaderLine_
|
||||
<< token::END_STATEMENT << nl;
|
||||
os.writeKeyword("refColumn") << refColumn_
|
||||
<< token::END_STATEMENT << nl;
|
||||
os.writeEntry("nHeaderLine", nHeaderLine_);
|
||||
os.writeEntry("refColumn", refColumn_);
|
||||
|
||||
// Force writing labelList in ascii
|
||||
os.writeKeyword("componentColumns");
|
||||
if (os.format() == IOstream::BINARY)
|
||||
{
|
||||
os.format(IOstream::ASCII);
|
||||
os << componentColumns_;
|
||||
os.format(IOstream::BINARY);
|
||||
}
|
||||
else
|
||||
{
|
||||
os << componentColumns_;
|
||||
}
|
||||
os << token::END_STATEMENT << nl;
|
||||
const enum IOstream::streamFormat fmt = os.format();
|
||||
os.format(IOstream::ASCII);
|
||||
os.writeEntry("componentColumns", componentColumns_);
|
||||
os.format(fmt);
|
||||
|
||||
os.writeKeyword("separator") << string(separator_)
|
||||
<< token::END_STATEMENT << nl;
|
||||
os.writeKeyword("mergeSeparators") << mergeSeparators_
|
||||
<< token::END_STATEMENT << nl;
|
||||
os.writeKeyword("fileName") << fName_
|
||||
<< token::END_STATEMENT << nl;
|
||||
os.writeEntry("separator", string(separator_));
|
||||
os.writeEntry("mergeSeparators", mergeSeparators_);
|
||||
os.writeEntry("fileName", fName_);
|
||||
|
||||
os.endBlock() << endl;
|
||||
os.endBlock() << flush;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -89,17 +89,17 @@ template<class Type>
|
||||
void Foam::Function1Types::Sine<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
Function1<Type>::writeData(os);
|
||||
os << token::END_STATEMENT << nl;
|
||||
os.endEntry();
|
||||
|
||||
os.beginBlock(word(this->name() + "Coeffs")) << nl;
|
||||
os.beginBlock(word(this->name() + "Coeffs"));
|
||||
|
||||
os.writeKeyword("t0") << t0_ << token::END_STATEMENT << nl;
|
||||
os.writeEntry("t0", t0_);
|
||||
amplitude_->writeData(os);
|
||||
frequency_->writeData(os);
|
||||
scale_->writeData(os);
|
||||
level_->writeData(os);
|
||||
|
||||
os.endBlock() << endl;
|
||||
os.endBlock() << flush;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -102,18 +102,18 @@ template<class Type>
|
||||
void Foam::Function1Types::Square<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
Function1<Type>::writeData(os);
|
||||
os << token::END_STATEMENT << nl;
|
||||
os.endEntry();
|
||||
|
||||
os.beginBlock(word(this->name() + "Coeffs")) << nl;
|
||||
os.beginBlock(word(this->name() + "Coeffs"));
|
||||
|
||||
os.writeKeyword("t0") << t0_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("markSpace") << markSpace_ << token::END_STATEMENT << nl;
|
||||
os.writeEntry("t0", t0_);
|
||||
os.writeEntry("markSpace", markSpace_);
|
||||
amplitude_->writeData(os);
|
||||
frequency_->writeData(os);
|
||||
scale_->writeData(os);
|
||||
level_->writeData(os);
|
||||
|
||||
os.endBlock() << endl;
|
||||
os.endBlock() << flush;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -78,16 +78,17 @@ template<class Type>
|
||||
void Foam::Function1Types::TableFile<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
Function1<Type>::writeData(os);
|
||||
os << token::END_STATEMENT << nl;
|
||||
os.endEntry();
|
||||
|
||||
os.beginBlock(word(this->name() + "Coeffs")) << nl;
|
||||
os.beginBlock(word(this->name() + "Coeffs"));
|
||||
|
||||
// Note: for TableBase write the dictionary entries it needs but not
|
||||
// the values themselves
|
||||
TableBase<Type>::writeEntries(os);
|
||||
os.writeKeyword("fileName")<< fName_ << token::END_STATEMENT << nl;
|
||||
|
||||
os.endBlock() << endl;
|
||||
os.writeEntry("fileName", fName_);
|
||||
|
||||
os.endBlock() << flush;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -56,7 +56,22 @@ class Ostream;
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Return a word representation of an int32
|
||||
word name(const int32_t);
|
||||
inline word name(const int32_t val)
|
||||
{
|
||||
// no stripping required
|
||||
return word(std::to_string(val), false);
|
||||
}
|
||||
|
||||
|
||||
//- 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);
|
||||
|
||||
|
||||
//- 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&, const int32_t);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -24,6 +24,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "int32.H"
|
||||
#include "stringOps.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
#include <inttypes.h>
|
||||
@ -32,11 +33,15 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::word Foam::name(const int32_t val)
|
||||
Foam::word Foam::name(const char* fmt, const int32_t val)
|
||||
{
|
||||
std::ostringstream buf;
|
||||
buf << val;
|
||||
return buf.str();
|
||||
return stringOps::name(fmt, val);
|
||||
}
|
||||
|
||||
|
||||
Foam::word Foam::name(const std::string& fmt, const int32_t val)
|
||||
{
|
||||
return stringOps::name(fmt, val);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -45,9 +45,6 @@ SourceFiles
|
||||
#include "pTraits.H"
|
||||
#include "direction.H"
|
||||
|
||||
#ifndef UINT64_MIN
|
||||
#define UINT64_MIN 0
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -60,7 +57,22 @@ class Ostream;
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Return a word representation of an int64
|
||||
word name(const int64_t);
|
||||
inline word name(const int64_t val)
|
||||
{
|
||||
// no stripping required
|
||||
return word(std::to_string(val), false);
|
||||
}
|
||||
|
||||
|
||||
//- 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 * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -24,6 +24,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "int64.H"
|
||||
#include "stringOps.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
#include <inttypes.h>
|
||||
@ -32,11 +33,15 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::word Foam::name(const int64_t val)
|
||||
Foam::word Foam::name(const char* fmt, const int64_t val)
|
||||
{
|
||||
std::ostringstream buf;
|
||||
buf << val;
|
||||
return buf.str();
|
||||
return stringOps::name(fmt, val);
|
||||
}
|
||||
|
||||
|
||||
Foam::word Foam::name(const std::string& fmt, const int64_t val)
|
||||
{
|
||||
return stringOps::name(fmt, val);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -55,8 +55,23 @@ class Ostream;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Return a word representation of an uint32
|
||||
word name(const uint32_t);
|
||||
//- Return a word representation of a uint32
|
||||
inline word name(const uint32_t val)
|
||||
{
|
||||
// no stripping required
|
||||
return word(std::to_string(val), false);
|
||||
}
|
||||
|
||||
|
||||
//- 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 * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -24,17 +24,22 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "uint32.H"
|
||||
#include "stringOps.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::word Foam::name(const uint32_t val)
|
||||
Foam::word Foam::name(const char* fmt, const uint32_t val)
|
||||
{
|
||||
std::ostringstream buf;
|
||||
buf << val;
|
||||
return buf.str();
|
||||
return stringOps::name(fmt, val);
|
||||
}
|
||||
|
||||
|
||||
Foam::word Foam::name(const std::string& fmt, const uint32_t val)
|
||||
{
|
||||
return stringOps::name(fmt, val);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -45,9 +45,6 @@ SourceFiles
|
||||
#include "pTraits.H"
|
||||
#include "direction.H"
|
||||
|
||||
#ifndef UINT64_MIN
|
||||
#define UINT64_MIN 0
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -59,8 +56,23 @@ class Ostream;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Return a word representation of an uint64
|
||||
word name(const uint64_t);
|
||||
//- Return a word representation of a uint64
|
||||
inline word name(const uint64_t val)
|
||||
{
|
||||
// no stripping required
|
||||
return word(std::to_string(val), false);
|
||||
}
|
||||
|
||||
|
||||
//- 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 * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -24,17 +24,22 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "uint64.H"
|
||||
#include "stringOps.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::word Foam::name(const uint64_t val)
|
||||
Foam::word Foam::name(const char* fmt, const uint64_t val)
|
||||
{
|
||||
std::ostringstream buf;
|
||||
buf << val;
|
||||
return buf.str();
|
||||
return stringOps::name(fmt, val);
|
||||
}
|
||||
|
||||
|
||||
Foam::word Foam::name(const std::string& fmt, const uint64_t val)
|
||||
{
|
||||
return stringOps::name(fmt, val);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -36,6 +36,7 @@ SourceFiles
|
||||
#define stringOps_H
|
||||
|
||||
#include "string.H"
|
||||
#include "word.H"
|
||||
#include "dictionary.H"
|
||||
#include "HashTable.H"
|
||||
|
||||
@ -292,6 +293,21 @@ namespace stringOps
|
||||
string& inplaceTrim(string&);
|
||||
|
||||
|
||||
//- Return a word representation of the primitive,
|
||||
// using printf-style formatter.
|
||||
// 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);
|
||||
|
||||
//- Return a word representation of the primitive,
|
||||
// using printf-style formatter.
|
||||
// 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);
|
||||
|
||||
|
||||
} // End namespace stringOps
|
||||
|
||||
|
||||
@ -299,6 +315,13 @@ namespace stringOps
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "stringOpsTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
@ -0,0 +1,69 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 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>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// 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
|
||||
)
|
||||
{
|
||||
// same concept as GNU/BSD asprintf()
|
||||
// use snprintf with zero to determine the number of characters required
|
||||
|
||||
int n = ::snprintf(0, 0, fmt, val);
|
||||
if (n > 0)
|
||||
{
|
||||
char buf[n+1];
|
||||
::snprintf(buf, n+1, fmt, val);
|
||||
buf[n] = 0;
|
||||
|
||||
// no stripping desired
|
||||
return word(buf, false);
|
||||
}
|
||||
|
||||
return word::null;
|
||||
}
|
||||
|
||||
|
||||
template<class PrimitiveType>
|
||||
Foam::word Foam::stringOps::name
|
||||
(
|
||||
const std::string& fmt,
|
||||
const PrimitiveType& val
|
||||
)
|
||||
{
|
||||
return stringOps::name(fmt.c_str(), val);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user