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