Compare commits
39 Commits
develop-fe
...
wip-issue2
| Author | SHA1 | Date | |
|---|---|---|---|
| 742d1dc604 | |||
| 1e02a4ae92 | |||
| f249022bfe | |||
| c418c28c66 | |||
| 5ea365a2be | |||
| 27c3d0c23b | |||
| 227727d413 | |||
| c08fc5ecd9 | |||
| 994addc543 | |||
| f2f71f6847 | |||
| c652af4b82 | |||
| bfef08a89f | |||
| 3b40ee8f6b | |||
| f5598706c5 | |||
| 457979a7b7 | |||
| 565c68f454 | |||
| b9507c21f9 | |||
| 88da2d5877 | |||
| 77ecc4c6e0 | |||
| 542fc0c1d1 | |||
| 9ccc2d8fd5 | |||
| c2cae92fc5 | |||
| 5894874920 | |||
| 6320bab2b5 | |||
| a4a8f77b7b | |||
| 64f4745277 | |||
| ac83b41aaf | |||
| 20f1afd9f7 | |||
| 873f7aac2d | |||
| 66ddf0a104 | |||
| 42150cf3fe | |||
| 5630db5493 | |||
| dfdbe7efd0 | |||
| b4612b4c04 | |||
| c4d18e97a3 | |||
| dea31e9b4a | |||
| 3d892ace29 | |||
| 8b1514c99b | |||
| 1afd27db6c |
@ -116,7 +116,7 @@ int main(int argc, char *argv[])
|
||||
"normalisedGradP",
|
||||
tmagGradP()/max(tmagGradP())
|
||||
);
|
||||
normalisedGradP.writeOpt() = IOobject::AUTO_WRITE;
|
||||
normalisedGradP.writeOpt(IOobject::AUTO_WRITE);
|
||||
tmagGradP.clear();
|
||||
|
||||
++runTime;
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -59,7 +59,7 @@ Foam::DTRMParticle::DTRMParticle
|
||||
{
|
||||
if (readFields)
|
||||
{
|
||||
if (is.format() == IOstream::ASCII)
|
||||
if (is.format() == IOstreamOption::ASCII)
|
||||
{
|
||||
is >> p0_ >> p1_ >> I0_ >> I_ >> dA_ >> transmissiveId_;
|
||||
}
|
||||
@ -115,7 +115,7 @@ void Foam::DTRMParticle::writeProperties
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const DTRMParticle& p)
|
||||
{
|
||||
if (os.format() == IOstream::ASCII)
|
||||
if (os.format() == IOstreamOption::ASCII)
|
||||
{
|
||||
os << static_cast<const particle&>(p)
|
||||
<< token::SPACE << p.p0_
|
||||
|
||||
@ -699,7 +699,7 @@ void Foam::radiation::laserDTRM::calculate()
|
||||
|
||||
for (label pointi = 0; pointi < lines.size(); pointi += 2)
|
||||
{
|
||||
os.write(linePointRef(lines[pointi], lines[pointi+1]));
|
||||
os.writeLine(lines[pointi], lines[pointi+1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -49,8 +49,8 @@ int main(int argc, char *argv[])
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
IOstream::streamFormat format = IOstream::BINARY;
|
||||
// IOstream::streamFormat format = IOstream::ASCII;
|
||||
IOstreamOption streamOpt(IOstreamOption::BINARY);
|
||||
// IOstreamOption streamOpt(IOstreamOption::ASCII);
|
||||
|
||||
const label size = 20000000;
|
||||
|
||||
@ -85,11 +85,7 @@ int main(int argc, char *argv[])
|
||||
<< runTime.cpuTimeIncrement() << " s" << nl << endl;
|
||||
|
||||
|
||||
faces2.writeObject
|
||||
(
|
||||
IOstreamOption(format),
|
||||
true
|
||||
);
|
||||
faces2.writeObject(streamOpt, true);
|
||||
|
||||
Info<< "Written old format faceList in = "
|
||||
<< runTime.cpuTimeIncrement() << " s" << nl << endl;
|
||||
@ -145,11 +141,7 @@ int main(int argc, char *argv[])
|
||||
<< runTime.cpuTimeIncrement() << " s" << nl << endl;
|
||||
|
||||
|
||||
faces2.writeObject
|
||||
(
|
||||
IOstreamOption(format),
|
||||
true
|
||||
);
|
||||
faces2.writeObject(streamOpt, true);
|
||||
|
||||
Info<< "Written new format faceList in = "
|
||||
<< runTime.cpuTimeIncrement() << " s" << nl << endl;
|
||||
|
||||
@ -146,7 +146,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
Info<<"Writing output to " << binaryOutput << endl;
|
||||
|
||||
OFstream os(binaryOutput, IOstream::BINARY);
|
||||
OFstream os(binaryOutput, IOstreamOption::BINARY);
|
||||
|
||||
os.writeEntry("idl1", idl1);
|
||||
os.writeEntry("idl2", idl2);
|
||||
|
||||
@ -28,15 +28,14 @@ Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
#include "floatScalar.H"
|
||||
#include "doubleScalar.H"
|
||||
#include "scalar.H"
|
||||
#include "complex.H"
|
||||
#include "Matrix.H"
|
||||
#include "Random.H"
|
||||
#include <chrono>
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Total number of unit tests
|
||||
|
||||
@ -78,8 +78,8 @@ int main(int argc, char *argv[])
|
||||
OFstream os
|
||||
(
|
||||
objPath,
|
||||
IOstream::BINARY,
|
||||
IOstream::currentVersion,
|
||||
IOstreamOption::BINARY,
|
||||
IOstreamOption::currentVersion,
|
||||
runTime.writeCompression()
|
||||
);
|
||||
if (!os.good())
|
||||
|
||||
@ -42,7 +42,7 @@ namespace Foam
|
||||
// Something like an internal state field. Probably only dimensionless
|
||||
typedef DimensionedField<uint8_t, volMesh> dimUint8Field;
|
||||
|
||||
defineTemplate2TypeNameAndDebug(dimUint8Field, 0);
|
||||
defineTemplateTypeNameAndDebug(dimUint8Field, 0);
|
||||
|
||||
} // End namespace Foam
|
||||
#endif
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -82,8 +82,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< nl << "hash-like functionality" << nl;
|
||||
|
||||
// doesn't work e4 = -1;
|
||||
e4.start() = e4.end() = -1;
|
||||
e4.clear();
|
||||
|
||||
printInfo(e4);
|
||||
for (label i : {2, -1, 2, 1, 4, 1, 2, 3})
|
||||
@ -93,24 +92,24 @@ int main(int argc, char *argv[])
|
||||
printInfo(e4);
|
||||
}
|
||||
|
||||
e4.start() = e4.end() = -1;
|
||||
e4.clear();
|
||||
Info<< "insert from list\n";
|
||||
labelHashSet newIndices({2, -1, 2, 1, 4, 1, 2, 3});
|
||||
e4.insert(newIndices.toc());
|
||||
printInfo(e4);
|
||||
|
||||
e4.start() = e4.end() = -1;
|
||||
e4.clear();
|
||||
Info<< "insert from list\n";
|
||||
e4.insert({0, 5, 2, -1, 2, 1, 4, 1, 2, 3});
|
||||
printInfo(e4);
|
||||
|
||||
FixedList<label, 8> otherIndices{12, 2, -1, 1, 4, 1, 2, 3};
|
||||
e4.start() = e4.end() = -1;
|
||||
e4.clear();
|
||||
Info<< "insert from list: " << otherIndices << nl;
|
||||
e4.insert(otherIndices);
|
||||
printInfo(e4);
|
||||
|
||||
e4.start() = e4.end();
|
||||
e4.a() = e4.b();
|
||||
Info<< "erase from list: " << otherIndices << nl;
|
||||
Info<< "removed " << e4.erase(otherIndices) << " values" << nl;
|
||||
printInfo(e4);
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -56,7 +56,7 @@ int main(int argc, char *argv[])
|
||||
// No. of Nodes = nCells
|
||||
// No. of Edges connecting Nodes = nInternalFaces
|
||||
|
||||
OFstream os(args.caseName() + ".graph", IOstream::ASCII);
|
||||
OFstream os(args.caseName() + ".graph", IOstreamOption::ASCII);
|
||||
|
||||
os << "%% metis graph file, of an OpenFOAM mesh %%" << nl
|
||||
<< "%% nCells=" << mesh.nCells()
|
||||
|
||||
@ -39,7 +39,7 @@ namespace Foam
|
||||
{
|
||||
typedef GeometricField<vector2D, fvPatchField, volMesh> volVector2DField;
|
||||
|
||||
defineTemplate2TypeNameAndDebug(volVector2DField::Internal, 0);
|
||||
defineTemplateTypeNameAndDebug(volVector2DField::Internal, 0);
|
||||
defineTemplateTypeNameAndDebug(volVector2DField, 0);
|
||||
|
||||
typedef fvPatchField<vector2D> fvPatchVector2DField;
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -30,11 +30,31 @@ Description
|
||||
|
||||
#include "argList.H"
|
||||
#include "instant.H"
|
||||
#include "Pair.H"
|
||||
#include "fileNameInstant.H"
|
||||
#include "DynamicList.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
template<class T>
|
||||
Ostream& printInstant(const UList<T>& times, const label i)
|
||||
{
|
||||
if (i >= 0 && i < times.size())
|
||||
{
|
||||
Info<< " (" << times[i] << ")";
|
||||
}
|
||||
return Info;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
Ostream& printInstant(const UList<T>& times, const Pair<label>& range)
|
||||
{
|
||||
printInstant(times, range.first());
|
||||
printInstant(times, range.second());
|
||||
return Info;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
@ -48,6 +68,7 @@ int main(int argc, char *argv[])
|
||||
times.append({300.456, "def"});
|
||||
times.append({454.456, "xyz"});
|
||||
times.append({10, "ten"});
|
||||
times.append({15, "fifteen"});
|
||||
|
||||
{
|
||||
word timeName("twenty");
|
||||
@ -61,6 +82,19 @@ int main(int argc, char *argv[])
|
||||
sort(times);
|
||||
Info<< "Sorted:" << times << nl;
|
||||
|
||||
for (const scalar val : { -0.5, 5.0, 18.0, 25.0, 450.0, 480.0 })
|
||||
{
|
||||
label start = instant::findStart(times, val);
|
||||
Pair<label> range = instant::findRange(times, val);
|
||||
|
||||
Info<< nl
|
||||
<< "time:" << val << nl;
|
||||
Info<< " start:" << start;
|
||||
printInstant(times, start) << nl;
|
||||
|
||||
Info<< " range:" << range;
|
||||
printInstant(times, range) << nl;
|
||||
}
|
||||
|
||||
DynamicList<fileNameInstant> files;
|
||||
files.append(fileNameInstant{});
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -24,10 +24,11 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Print max limits.
|
||||
Print some numerical limits.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
#include "int.H"
|
||||
#include "uint.H"
|
||||
@ -37,21 +38,63 @@ Description
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
std::ostream& print(const char* tag, float val)
|
||||
{
|
||||
std::cout
|
||||
<< tag << val
|
||||
<< " 0x" << std::hex << *reinterpret_cast<const uint32_t*>(&val);
|
||||
return std::cout;
|
||||
}
|
||||
|
||||
|
||||
std::ostream& print(const char* tag, double val)
|
||||
{
|
||||
std::cout
|
||||
<< tag << val
|
||||
<< " 0x" << std::hex << *reinterpret_cast<const uint64_t*>(&val);
|
||||
return std::cout;
|
||||
}
|
||||
|
||||
|
||||
// Have (float|double)Scalar(GREAT|SMALL|..)
|
||||
|
||||
#define PrintFloatLimits(FloatType, NanFunction) \
|
||||
{ \
|
||||
print("max:", std::numeric_limits<FloatType>::max()); \
|
||||
print(" VGREAT:", FloatType##ScalarVGREAT); \
|
||||
print(" ROOTVGREAT:", FloatType##ScalarROOTVGREAT) << nl; \
|
||||
\
|
||||
print("min:", std::numeric_limits<FloatType>::min()); \
|
||||
print(" VSMALL:", FloatType##ScalarVSMALL); \
|
||||
print(" ROOTVSMALL:", FloatType##ScalarROOTVSMALL) << nl; \
|
||||
\
|
||||
print("epsilon:", std::numeric_limits<FloatType>::epsilon()); \
|
||||
print(" SMALL:", FloatType##ScalarSMALL); \
|
||||
print(" ROOTSMALL:", FloatType##ScalarROOTSMALL) << nl; \
|
||||
\
|
||||
print("1/epsilon:", 1/std::numeric_limits<FloatType>::epsilon()); \
|
||||
print(" GREAT:", FloatType##ScalarGREAT); \
|
||||
print(" ROOTGREAT:", FloatType##ScalarROOTGREAT) << nl; \
|
||||
\
|
||||
print("nan:", std::NanFunction("nan")) << nl; \
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
//NONE Info<<"int16:" << pTraits<int16_t>::max << nl;
|
||||
Info<< "=max=" << nl;
|
||||
Info<< "uint8:" << pTraits<uint8_t>::max << nl;
|
||||
Info<< "int16:" << std::numeric_limits<int16_t>::max() << nl;
|
||||
Info<< "int32:" << pTraits<int32_t>::max << nl;
|
||||
Info<< "uint32:" << pTraits<uint32_t>::max << nl;
|
||||
Info<< "int64:" << pTraits<int64_t>::max << nl;
|
||||
Info<< "uint64:" << pTraits<uint64_t>::max << nl;
|
||||
//NONE cout<<"int16:" << pTraits<int16_t>::max << nl;
|
||||
cout<< "=max=" << nl;
|
||||
cout<< "uint8:" << pTraits<uint8_t>::max << nl;
|
||||
cout<< "int16:" << std::numeric_limits<int16_t>::max() << nl;
|
||||
cout<< "int32:" << pTraits<int32_t>::max << nl;
|
||||
cout<< "uint32:" << pTraits<uint32_t>::max << nl;
|
||||
cout<< "int64:" << pTraits<int64_t>::max << nl;
|
||||
cout<< "uint64:" << pTraits<uint64_t>::max << nl;
|
||||
|
||||
Info<< nl;
|
||||
cout<< nl;
|
||||
|
||||
cout<< "int16:" << std::numeric_limits<int16_t>::max() << nl;
|
||||
cout<< "int32:" << pTraits<int32_t>::max << nl;
|
||||
@ -59,7 +102,7 @@ int main(int argc, char *argv[])
|
||||
cout<< "int64:" << pTraits<int64_t>::max << nl;
|
||||
cout<< "uint64:" << pTraits<uint64_t>::max << nl;
|
||||
|
||||
Info<< nl << "=digits=" << nl;
|
||||
cout<< nl << "=digits=" << nl;
|
||||
|
||||
cout<< "int16:" << std::numeric_limits<int16_t>::digits << nl;
|
||||
cout<< "int32:" << std::numeric_limits<int32_t>::digits << nl;
|
||||
@ -70,29 +113,15 @@ int main(int argc, char *argv[])
|
||||
cout<< "double:" << std::numeric_limits<double>::digits << nl;
|
||||
cout<< "long double:" << std::numeric_limits<long double>::digits << nl;
|
||||
|
||||
Info<< nl << "=float=" << nl;
|
||||
// std::nanl (long double)
|
||||
cout<< nl;
|
||||
cout<< nl << "=float=" << nl;
|
||||
PrintFloatLimits(float, nanf);
|
||||
|
||||
cout<< "max:" << std::numeric_limits<float>::max()
|
||||
<< " VGREAT:" << floatScalarVGREAT << nl;
|
||||
cout<< "min:" << std::numeric_limits<float>::min()
|
||||
<< " VSMALL:" << floatScalarVSMALL << nl;
|
||||
cout<< "epsilon:" << std::numeric_limits<float>::epsilon()
|
||||
<< " SMALL:" << floatScalarSMALL << nl;
|
||||
cout<< "1/epsilon:" << 1.0f/std::numeric_limits<float>::epsilon()
|
||||
<< " GREAT:" << floatScalarGREAT << nl;
|
||||
cout<< nl << "=double=" << nl;
|
||||
PrintFloatLimits(double, nan);
|
||||
|
||||
Info<< nl << "=double=" << nl;
|
||||
|
||||
cout<< "max:" << std::numeric_limits<double>::max()
|
||||
<< " VGREAT:" << doubleScalarVGREAT << nl;
|
||||
cout<< "min:" << std::numeric_limits<double>::min()
|
||||
<< " VSMALL:" << doubleScalarVSMALL << nl;
|
||||
cout<< "epsilon:" << std::numeric_limits<double>::epsilon()
|
||||
<< " SMALL:" << doubleScalarSMALL << nl;
|
||||
cout<< "1/epsilon:" << 1.0f/std::numeric_limits<double>::epsilon()
|
||||
<< " GREAT:" << doubleScalarGREAT << nl;
|
||||
|
||||
Info << "---\nEnd\n" << endl;
|
||||
cout<< "---\nEnd\n" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -38,8 +38,7 @@ Description
|
||||
|
||||
#include "DiagonalMatrix.H"
|
||||
#include "RectangularMatrix.H"
|
||||
#include "floatScalar.H"
|
||||
#include "doubleScalar.H"
|
||||
#include "scalar.H"
|
||||
#include "complex.H"
|
||||
#include "TestTools.H"
|
||||
|
||||
|
||||
@ -44,8 +44,7 @@ Note
|
||||
|
||||
#include "RectangularMatrix.H"
|
||||
#include "SquareMatrix.H"
|
||||
#include "floatScalar.H"
|
||||
#include "doubleScalar.H"
|
||||
#include "scalar.H"
|
||||
#include "complex.H"
|
||||
#include "IOmanip.H"
|
||||
#include "TestTools.H"
|
||||
|
||||
@ -45,8 +45,7 @@ Note
|
||||
#include "scalarMatrices.H"
|
||||
#include "RectangularMatrix.H"
|
||||
#include "SquareMatrix.H"
|
||||
#include "floatScalar.H"
|
||||
#include "doubleScalar.H"
|
||||
#include "scalar.H"
|
||||
#include "complex.H"
|
||||
#include "IOmanip.H"
|
||||
#include "TestTools.H"
|
||||
|
||||
@ -46,8 +46,7 @@ Note
|
||||
#include "RectangularMatrix.H"
|
||||
#include "SquareMatrix.H"
|
||||
#include "SymmetricSquareMatrix.H"
|
||||
#include "floatScalar.H"
|
||||
#include "doubleScalar.H"
|
||||
#include "scalar.H"
|
||||
#include "complex.H"
|
||||
#include "IOmanip.H"
|
||||
#include "Random.H"
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -334,7 +334,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
DynamicList<char> buf;
|
||||
|
||||
OListStream os(std::move(buf), IOstream::BINARY);
|
||||
OListStream os(std::move(buf), IOstreamOption::BINARY);
|
||||
os << srcList;
|
||||
|
||||
os.swap(buf); // Recover buffer
|
||||
@ -342,7 +342,7 @@ int main(int argc, char *argv[])
|
||||
// Read back
|
||||
List<scalar> dstList;
|
||||
|
||||
UIListStream is(buf, IOstream::BINARY);
|
||||
UIListStream is(buf, IOstreamOption::BINARY);
|
||||
is.setScalarByteSize(sizeof(otherType));
|
||||
|
||||
Info<< "Stream scalar-size ("
|
||||
|
||||
@ -42,7 +42,7 @@ namespace Foam
|
||||
// - still needs some basic boundary conditions!!
|
||||
typedef GeometricField<uint8_t, fvPatchField, volMesh> volUint8Field;
|
||||
|
||||
defineTemplate2TypeNameAndDebug(volUint8Field, 0);
|
||||
defineTemplateTypeNameAndDebug(volUint8Field, 0);
|
||||
|
||||
} // End namespace Foam
|
||||
#endif
|
||||
|
||||
@ -1397,26 +1397,20 @@ void extrudeGeometricProperties
|
||||
{
|
||||
Pout<< "Model :" << faceCentres[facei] << endl
|
||||
<< "regionMesh:" << regionMesh.faceCentres()[facei] << endl;
|
||||
faceStr.write
|
||||
faceStr.writeLine
|
||||
(
|
||||
linePointRef
|
||||
(
|
||||
faceCentres[facei],
|
||||
regionMesh.faceCentres()[facei]
|
||||
)
|
||||
faceCentres[facei],
|
||||
regionMesh.faceCentres()[facei]
|
||||
);
|
||||
}
|
||||
forAll(cellCentres, celli)
|
||||
{
|
||||
Pout<< "Model :" << cellCentres[celli] << endl
|
||||
<< "regionMesh:" << regionMesh.cellCentres()[celli] << endl;
|
||||
cellStr.write
|
||||
cellStr.writeLine
|
||||
(
|
||||
linePointRef
|
||||
(
|
||||
cellCentres[celli],
|
||||
regionMesh.cellCentres()[celli]
|
||||
)
|
||||
cellCentres[celli],
|
||||
regionMesh.cellCentres()[celli]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,7 +152,7 @@ void Foam::PrintTable<KeyType, DataType>::print
|
||||
|
||||
os << endl;
|
||||
|
||||
const List<KeyType>& sortedTable = combinedTable.sortedToc();
|
||||
const List<KeyType> sortedTable(combinedTable.sortedToc());
|
||||
|
||||
forAll(sortedTable, keyI)
|
||||
{
|
||||
|
||||
@ -1687,7 +1687,7 @@ void Foam::conformalVoronoiMesh::move()
|
||||
)
|
||||
)
|
||||
{
|
||||
multipleIntersections.write(linePointRef(ptA, ptB));
|
||||
multipleIntersections.writeLine(ptA, ptB);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
// Forward Declarations
|
||||
class initialPointsMethod;
|
||||
class relaxationModel;
|
||||
class faceAreaWeightModel;
|
||||
|
||||
@ -1433,18 +1433,15 @@ void Foam::conformalVoronoiMesh::indexDualVertices
|
||||
// && (mag(snapDir & norm[0]) > 0.5)
|
||||
// )
|
||||
// {
|
||||
// snapping1.write
|
||||
// snapping1.writeLine
|
||||
// (
|
||||
// linePointRef(dual, nearestPointOnTet)
|
||||
// dual,
|
||||
// nearestPointOnTet
|
||||
// );
|
||||
//
|
||||
// snapping2.write
|
||||
// snapping2.writeLine
|
||||
// (
|
||||
// linePointRef
|
||||
// (
|
||||
// nearestPointOnTet,
|
||||
// hitInfo.hitPoint()
|
||||
// )
|
||||
// nearestPointOnTet,
|
||||
// hitInfo.hitPoint()
|
||||
// );
|
||||
//
|
||||
// pts[cit->cellIndex()] = hitInfo.hitPoint();
|
||||
@ -1764,9 +1761,10 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
|
||||
|
||||
if ((*vcit)->real())
|
||||
{
|
||||
featurePointDualsStr.write
|
||||
featurePointDualsStr.writeLine
|
||||
(
|
||||
linePointRef(topoint(vit->point()), (*vcit)->dual())
|
||||
topoint(vit->point()),
|
||||
(*vcit)->dual()
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1867,7 +1865,7 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
|
||||
<< " " << vc2->dual()
|
||||
<< endl;
|
||||
|
||||
startCellStr.write(linePointRef(vc1->dual(), vc2->dual()));
|
||||
startCellStr.writeLine(vc1->dual(), vc2->dual());
|
||||
|
||||
// Get patch by getting face between cells and the two
|
||||
// points on the face that are not the feature vertex
|
||||
|
||||
@ -1395,10 +1395,7 @@ void Foam::conformalVoronoiMesh::writePointPairs
|
||||
|
||||
if (ptPairs_.isPointPair(vA, vB))
|
||||
{
|
||||
os.write
|
||||
(
|
||||
linePointRef(topoint(vA->point()), topoint(vB->point()))
|
||||
);
|
||||
os.writeLine(topoint(vA->point()), topoint(vB->point()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -73,7 +73,7 @@ scalar getMergeDistance
|
||||
Info<< "Merge tolerance : " << mergeTol << nl
|
||||
<< "Write tolerance : " << writeTol << endl;
|
||||
|
||||
if (runTime.writeFormat() == IOstream::ASCII && mergeTol < writeTol)
|
||||
if (runTime.writeFormat() == IOstreamOption::ASCII && mergeTol < writeTol)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Your current settings specify ASCII writing with "
|
||||
|
||||
@ -616,7 +616,7 @@ scalar getMergeDistance
|
||||
<< endl;
|
||||
|
||||
// check writing tolerance
|
||||
if (mesh.time().writeFormat() == IOstream::ASCII && !dryRun)
|
||||
if (mesh.time().writeFormat() == IOstreamOption::ASCII && !dryRun)
|
||||
{
|
||||
const scalar writeTol = std::pow
|
||||
(
|
||||
@ -1342,6 +1342,17 @@ int main(int argc, char *argv[])
|
||||
const snapParameters snapParams(snapDict, dryRun);
|
||||
|
||||
|
||||
Info<< "Setting refinement level of surface to be consistent"
|
||||
<< " with curvature." << endl;
|
||||
surfaces.setCurvatureMinLevelFields
|
||||
(
|
||||
refineParams.curvature(),
|
||||
meshRefiner.meshCutter().level0EdgeLength()
|
||||
);
|
||||
Info<< "Checked curvature refinement in = "
|
||||
<< mesh.time().cpuTimeIncrement() << " s" << nl << endl;
|
||||
|
||||
|
||||
|
||||
// Add all the cellZones and faceZones
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@ -43,7 +43,7 @@ Description
|
||||
static void usage();
|
||||
static void version();
|
||||
static std::string getLine(const std::string&, const std::string&);
|
||||
static std::string pOpen(const std::string&, int line=0);
|
||||
static std::string pipeOpen(const std::string& cmd, const int lineNum = 0);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -132,51 +132,50 @@ void version()
|
||||
}
|
||||
|
||||
|
||||
std::string pOpen(const std::string& cmd, int line)
|
||||
// Read up to and including lineNum from the piped command
|
||||
// Return the final line read
|
||||
std::string pipeOpen(const std::string& cmd, int lineNum)
|
||||
{
|
||||
std::string res;
|
||||
std::string str;
|
||||
|
||||
FILE* cmdPipe = popen(cmd.c_str(), "r");
|
||||
if (!cmdPipe) return res;
|
||||
FILE* handle = popen(cmd.c_str(), "r");
|
||||
if (!handle) return str;
|
||||
|
||||
char* buf = nullptr;
|
||||
size_t len = 0;
|
||||
ssize_t nread;
|
||||
|
||||
// Read line number of lines
|
||||
for (int cnt = 0; cnt <= line; ++cnt)
|
||||
// Read lineNum number of lines
|
||||
for
|
||||
(
|
||||
int cnt = 0;
|
||||
cnt <= lineNum && (nread = ::getline(&buf, &len, handle)) >= 0;
|
||||
++cnt
|
||||
)
|
||||
{
|
||||
size_t linecap = 0;
|
||||
ssize_t linelen = ::getline(&buf, &linecap, cmdPipe);
|
||||
|
||||
if (linelen < 0)
|
||||
if (cnt == lineNum)
|
||||
{
|
||||
break;
|
||||
}
|
||||
// Retain the last line, trimming trailing newline
|
||||
str.assign(buf);
|
||||
|
||||
if (cnt == line)
|
||||
{
|
||||
res = std::string(buf);
|
||||
|
||||
// Trim trailing newline
|
||||
if (res.size())
|
||||
if (str.size())
|
||||
{
|
||||
res.resize(res.size()-1);
|
||||
str.resize(str.size()-1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (buf) free(buf);
|
||||
free(buf);
|
||||
pclose(handle);
|
||||
|
||||
pclose(cmdPipe);
|
||||
|
||||
return res;
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
std::string getLine(const std::string& filename, const std::string& addr)
|
||||
{
|
||||
std::string line =
|
||||
pOpen
|
||||
pipeOpen
|
||||
(
|
||||
"echo 'image lookup -va " + addr
|
||||
+ "'"
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -160,7 +160,7 @@ bool writeZones
|
||||
// Force writing as ASCII
|
||||
writeOk = meshObject.regIOobject::writeObject
|
||||
(
|
||||
IOstreamOption(IOstream::ASCII, compression),
|
||||
IOstreamOption(IOstreamOption::ASCII, compression),
|
||||
true
|
||||
);
|
||||
}
|
||||
@ -355,7 +355,7 @@ int main(int argc, char *argv[])
|
||||
runTime
|
||||
);
|
||||
|
||||
if (runTime.writeFormat() == IOstream::ASCII)
|
||||
if (runTime.writeFormat() == IOstreamOption::ASCII)
|
||||
{
|
||||
// Only do zones when converting from binary to ascii
|
||||
// The other way gives problems since working on dictionary level.
|
||||
|
||||
@ -663,7 +663,11 @@ int main(int argc, char *argv[])
|
||||
Info<< "Merge tolerance : " << mergeTol << nl
|
||||
<< "Write tolerance : " << writeTol << endl;
|
||||
|
||||
if (runTime.writeFormat() == IOstream::ASCII && mergeTol < writeTol)
|
||||
if
|
||||
(
|
||||
runTime.writeFormat() == IOstreamOption::ASCII
|
||||
&& mergeTol < writeTol
|
||||
)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Your current settings specify ASCII writing with "
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -159,7 +159,7 @@ public:
|
||||
p.origProc = ppi.origProc();
|
||||
p.origId = ppi.origId();
|
||||
|
||||
if (os.format() == IOstream::ASCII)
|
||||
if (os.format() == IOstreamOption::ASCII)
|
||||
{
|
||||
os << p.position
|
||||
<< token::SPACE << p.celli
|
||||
|
||||
@ -232,13 +232,13 @@ vtk::outputOptions getOutputOptions(const argList& args)
|
||||
|
||||
if (!args.found("ascii"))
|
||||
{
|
||||
if (sizeof(floatScalar) != 4 || sizeof(label) != 4)
|
||||
if (sizeof(float) != 4 || sizeof(label) != 4)
|
||||
{
|
||||
opts.ascii(true);
|
||||
|
||||
WarningInFunction
|
||||
<< "Using ASCII rather than legacy binary VTK format since "
|
||||
<< "floatScalar and/or label are not 4 bytes in size."
|
||||
<< "float and/or label are not 4 bytes in size."
|
||||
<< nl << endl;
|
||||
}
|
||||
else
|
||||
|
||||
@ -390,7 +390,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
summary.writeHeader(os);
|
||||
summary.writeData(os);
|
||||
summary.writeEndDivider(os);
|
||||
IOobject::writeEndDivider(os);
|
||||
|
||||
Info<< "Wrote to " << outputName << nl << endl;
|
||||
}
|
||||
|
||||
@ -662,8 +662,8 @@ int main(int argc, char *argv[])
|
||||
// Read dictionary
|
||||
// Note: disable class type checking so we can load field
|
||||
Info<< "Loading dictionary " << fieldName << endl;
|
||||
const word oldTypeName = IOdictionary::typeName;
|
||||
const_cast<word&>(IOdictionary::typeName) = word::null;
|
||||
const word oldTypeName = localIOdictionary::typeName;
|
||||
const_cast<word&>(localIOdictionary::typeName) = word::null;
|
||||
|
||||
IOobject fieldHeader
|
||||
(
|
||||
@ -675,11 +675,15 @@ int main(int argc, char *argv[])
|
||||
false
|
||||
);
|
||||
|
||||
if (fieldHeader.typeHeaderOk<IOdictionary>(false))
|
||||
if (fieldHeader.typeHeaderOk<localIOdictionary>(false))
|
||||
{
|
||||
IOdictionary fieldDict(fieldHeader);
|
||||
//IOdictionary fieldDict(fieldHeader);
|
||||
//- dictionaries to-be-changed are either boundary
|
||||
// or field dictionary. Both are processor-local.
|
||||
localIOdictionary fieldDict(fieldHeader);
|
||||
|
||||
const_cast<word&>(IOdictionary::typeName) = oldTypeName;
|
||||
const_cast<word&>(localIOdictionary::typeName) =
|
||||
oldTypeName;
|
||||
|
||||
// Fake type back to what was in field
|
||||
const_cast<word&>(fieldDict.type()) =
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -199,7 +199,7 @@ void createFieldFiles
|
||||
|
||||
fieldOut.regIOobject::writeObject
|
||||
(
|
||||
IOstreamOption(IOstream::ASCII),
|
||||
IOstreamOption(IOstreamOption::ASCII),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2020,2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -96,7 +96,15 @@ int main(int argc, char *argv[])
|
||||
|
||||
label nCoarseFaces = 0;
|
||||
|
||||
for (const entry& dEntry : agglomDict)
|
||||
|
||||
const auto& patchesDict =
|
||||
agglomDict.optionalSubDict
|
||||
(
|
||||
"patchAgglomeration",
|
||||
keyType::LITERAL
|
||||
);
|
||||
|
||||
for (const entry& dEntry : patchesDict)
|
||||
{
|
||||
labelList patchids = boundary.indices(dEntry.keyword());
|
||||
|
||||
@ -112,7 +120,7 @@ int main(int argc, char *argv[])
|
||||
(
|
||||
pp.localFaces(),
|
||||
pp.localPoints(),
|
||||
agglomDict.subDict(pp.name())
|
||||
dEntry.dict()
|
||||
);
|
||||
|
||||
agglomObject.agglomerate();
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2007-2019 PCOpt/NTUA
|
||||
Copyright (C) 2013-2019 FOSS GP
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -95,7 +95,7 @@ int main(int argc, char *argv[])
|
||||
// Write modified dictionary
|
||||
optDict.regIOobject::writeObject
|
||||
(
|
||||
IOstreamOption(IOstream::ASCII),
|
||||
IOstreamOption(IOstreamOption::ASCII),
|
||||
true
|
||||
);
|
||||
|
||||
|
||||
@ -76,7 +76,7 @@ void isoFacesToFile
|
||||
{
|
||||
for (const List<point>& facePts : procFaces)
|
||||
{
|
||||
os.write(face(identity(facePts.size())), facePts);
|
||||
os.writeFace(facePts);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -87,7 +87,7 @@ void isoFacesToFile
|
||||
|
||||
for (const List<point>& facePts : faces)
|
||||
{
|
||||
os.write(face(identity(facePts.size())), facePts);
|
||||
os.writeFace(facePts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -133,7 +133,7 @@ int main(int argc, char *argv[])
|
||||
IOstreamOption streamOpt(runTime.writeFormat());
|
||||
if (args.found("ascii"))
|
||||
{
|
||||
streamOpt.format(IOstream::ASCII);
|
||||
streamOpt.format(IOstreamOption::ASCII);
|
||||
}
|
||||
|
||||
forAll(times, timei)
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -767,7 +767,7 @@ int main(int argc, char *argv[])
|
||||
ctrl.streamOpt.format(runTime.writeFormat());
|
||||
if (args.found("ascii"))
|
||||
{
|
||||
ctrl.streamOpt.format(IOstream::ASCII);
|
||||
ctrl.streamOpt.format(IOstreamOption::ASCII);
|
||||
}
|
||||
|
||||
expressions::exprString valueExpr_
|
||||
@ -838,7 +838,7 @@ int main(int argc, char *argv[])
|
||||
ctrl.streamOpt.format(runTime.writeFormat());
|
||||
if (args.found("ascii"))
|
||||
{
|
||||
ctrl.streamOpt.format(IOstream::ASCII);
|
||||
ctrl.streamOpt.format(IOstreamOption::ASCII);
|
||||
}
|
||||
|
||||
if (ctrl.createNew && ctrl.keepPatches)
|
||||
|
||||
19
applications/utilities/preProcessing/viewFactorsGen/Allwmake
Executable file
19
applications/utilities/preProcessing/viewFactorsGen/Allwmake
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
cd "${0%/*}" || exit # Run from this directory
|
||||
. ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments # (error catching)
|
||||
. ${WM_PROJECT_DIR:?}/wmake/scripts/have_cgal
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
unset COMP_FLAGS LINK_FLAGS
|
||||
|
||||
if have_cgal
|
||||
then
|
||||
echo " found CGAL -- enabling CGAL support."
|
||||
else
|
||||
echo " did not find CGAL -- disabling CGAL functionality"
|
||||
export COMP_FLAGS="-DNO_CGAL"
|
||||
fi
|
||||
|
||||
wmake $targetType
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@ -1,10 +1,18 @@
|
||||
include $(GENERAL_RULES)/cgal-header-only
|
||||
|
||||
EXE_INC = \
|
||||
-Wno-old-style-cast \
|
||||
$(COMP_FLAGS) \
|
||||
${CGAL_INC} \
|
||||
-DCGAL_HEADER_ONLY \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/surfMesh/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/parallel/distributed/lnInclude \
|
||||
-I$(LIB_SRC)/parallel/distributed/lnInclude
|
||||
|
||||
|
||||
EXE_LIBS = \
|
||||
/* ${CGAL_LIBS} */ \
|
||||
-lfiniteVolume \
|
||||
-lsurfMesh \
|
||||
-lmeshTools \
|
||||
|
||||
@ -0,0 +1,84 @@
|
||||
Random rndGen(653213);
|
||||
|
||||
// Determine mesh bounding boxes:
|
||||
List<treeBoundBox> meshBb
|
||||
(
|
||||
1,
|
||||
treeBoundBox
|
||||
(
|
||||
boundBox(coarseMesh.points(), false)
|
||||
).extend(rndGen, 1e-3)
|
||||
);
|
||||
|
||||
// Dummy bounds dictionary
|
||||
dictionary dict;
|
||||
dict.add("bounds", meshBb);
|
||||
dict.add
|
||||
(
|
||||
"distributionType",
|
||||
distributedTriSurfaceMesh::distributionTypeNames_
|
||||
[
|
||||
distributedTriSurfaceMesh::FROZEN
|
||||
]
|
||||
);
|
||||
dict.add("mergeDistance", SMALL);
|
||||
|
||||
labelList triSurfaceToAgglom(5*nFineFaces);
|
||||
|
||||
triSurface localSurface = triangulate
|
||||
(
|
||||
patches,
|
||||
includePatches,
|
||||
finalAgglom,
|
||||
triSurfaceToAgglom,
|
||||
globalNumbering,
|
||||
coarsePatches
|
||||
);
|
||||
|
||||
|
||||
// CGAL surface
|
||||
|
||||
distributedTriSurfaceMesh surfacesMesh
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"wallSurface.stl",
|
||||
runTime.constant(), // directory
|
||||
"triSurface", // instance
|
||||
runTime, // registry
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
localSurface,
|
||||
dict
|
||||
);
|
||||
|
||||
triSurfaceToAgglom.resize(surfacesMesh.size());
|
||||
|
||||
surfacesMesh.setField(triSurfaceToAgglom);
|
||||
|
||||
const pointField& pts = surfacesMesh.localPoints();
|
||||
|
||||
std::list<Triangle> triangles;
|
||||
|
||||
for (const auto& triLocal : surfacesMesh.localFaces())
|
||||
{
|
||||
point p1l = pts[triLocal[0]];
|
||||
point p2l = pts[triLocal[1]];
|
||||
point p3l = pts[triLocal[2]];
|
||||
|
||||
Point p1(p1l[0], p1l[1], p1l[2]);
|
||||
Point p2(p2l[0], p2l[1], p2l[2]);
|
||||
Point p3(p3l[0], p3l[1], p3l[2]);
|
||||
|
||||
Triangle tri(p1, p2, p3);
|
||||
|
||||
if (tri.is_degenerate())
|
||||
{
|
||||
std::cout << tri << std::endl;
|
||||
}
|
||||
triangles.push_back(tri);
|
||||
}
|
||||
|
||||
// constructs AABB tree
|
||||
Tree tree(triangles.begin(), triangles.end());
|
||||
@ -1,6 +1,15 @@
|
||||
// All rays expressed as start face (local) index end end face (global)
|
||||
// Pre-size by assuming a certain percentage is visible.
|
||||
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
Info<< "\nShooting rays using distributedTriSurfaceMesh (no CGAL support)"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Maximum length for dynamicList
|
||||
const label maxDynListLength
|
||||
(
|
||||
|
||||
@ -0,0 +1,131 @@
|
||||
// Maximum length for dynamicList
|
||||
const label maxDynListLength
|
||||
(
|
||||
viewFactorDict.getOrDefault<label>("maxDynListLength", 1000000000)
|
||||
);
|
||||
|
||||
for (const int proci : Pstream::allProcs())
|
||||
{
|
||||
std::vector<Point> start;
|
||||
start.reserve(coarseMesh.nFaces());
|
||||
|
||||
std::vector<Point> end(start.size());
|
||||
end.reserve(start.size());
|
||||
|
||||
DynamicList<label> startIndex(start.size());
|
||||
DynamicList<label> endIndex(start.size());
|
||||
|
||||
DynamicList<label> startAgg(start.size());
|
||||
DynamicList<label> endAgg(start.size());
|
||||
|
||||
const pointField& myFc = remoteCoarseCf[Pstream::myProcNo()];
|
||||
const vectorField& myArea = remoteCoarseSf[Pstream::myProcNo()];
|
||||
const labelField& myAgg = remoteCoarseAgg[Pstream::myProcNo()];
|
||||
|
||||
const pointField& remoteArea = remoteCoarseSf[proci];
|
||||
const pointField& remoteFc = remoteCoarseCf[proci];
|
||||
const labelField& remoteAgg = remoteCoarseAgg[proci];
|
||||
|
||||
label i = 0;
|
||||
label j = 0;
|
||||
do
|
||||
{
|
||||
for (; i < myFc.size(); i++)
|
||||
{
|
||||
const point& fc = myFc[i];
|
||||
const vector& fA = myArea[i];
|
||||
const label& fAgg = myAgg[i];
|
||||
|
||||
for (; j < remoteFc.size(); j++)
|
||||
{
|
||||
if (proci != Pstream::myProcNo() || i != j)
|
||||
{
|
||||
const point& remFc = remoteFc[j];
|
||||
const vector& remA = remoteArea[j];
|
||||
const label& remAgg = remoteAgg[j];
|
||||
|
||||
const vector d(remFc - fc);
|
||||
|
||||
|
||||
const vector nd = d/mag(d);
|
||||
const vector nfA = fA/mag(fA);
|
||||
const vector nremA = remA/mag(remA);
|
||||
|
||||
if (((nd & nfA) < 0) && ((nd & nremA) > 0))
|
||||
{
|
||||
vector direction(d[0], d[1], d[2]);
|
||||
vector s(fc[0], fc[1], fc[2]);
|
||||
vector rayEnd(s + (1-intTol)*direction);
|
||||
end.push_back(Point(rayEnd[0], rayEnd[1], rayEnd[2]));
|
||||
|
||||
s += vector(intTol*d[0], intTol*d[1], intTol*d[2]);
|
||||
|
||||
start.push_back(Point(s[0], s[1], s[2]));
|
||||
startIndex.append(i);
|
||||
if (useAgglomeration)
|
||||
{
|
||||
startAgg.append
|
||||
(
|
||||
globalNumbering.toGlobal(proci, fAgg)
|
||||
);
|
||||
endAgg.append
|
||||
(
|
||||
globalNumbering.toGlobal(proci, remAgg)
|
||||
);
|
||||
}
|
||||
|
||||
label globalI = globalNumbering.toGlobal(proci, j);
|
||||
endIndex.append(globalI);
|
||||
|
||||
if (startIndex.size() > maxDynListLength)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Dynamic list need from capacity."
|
||||
<< "Actual size maxDynListLength : "
|
||||
<< maxDynListLength
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (j == remoteFc.size())
|
||||
{
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
|
||||
} while (i < myFc.size());
|
||||
|
||||
label totalRays(startIndex.size());
|
||||
reduce(totalRays, sumOp<scalar>());
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "Number of rays :" << totalRays << endl;
|
||||
}
|
||||
|
||||
for (unsigned long rayI = 0; rayI < start.size(); ++rayI)
|
||||
{
|
||||
Segment ray(start[rayI], end[rayI]);
|
||||
Segment_intersection intersects = tree.any_intersection(ray);
|
||||
|
||||
if (!intersects)
|
||||
{
|
||||
rayStartFace.append(startIndex[rayI]);
|
||||
rayEndFace.append(endIndex[rayI]);
|
||||
}
|
||||
}
|
||||
start.clear();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout << "hits : " << rayStartFace.size()<< endl;
|
||||
}
|
||||
|
||||
startIndex.clear();
|
||||
end.clear();
|
||||
endIndex.clear();
|
||||
startAgg.clear();
|
||||
endAgg.clear();
|
||||
}
|
||||
@ -31,14 +31,34 @@ Group
|
||||
grpPreProcessingUtilities
|
||||
|
||||
Description
|
||||
View factors are calculated based on a face agglomeration array
|
||||
(finalAgglom generated by faceAgglomerate utility).
|
||||
This view factors generation application uses a combined approach of
|
||||
double area integral (2AI) and double linear integral (2LI). 2AI is used
|
||||
when the two surfaces are 'far' apart and 2LI when they are 'close'.
|
||||
2LI is integrated along edges using Gaussian quadrature.
|
||||
The distance between faces is calculating a ratio between averaged areas
|
||||
and the distance between face centres.
|
||||
|
||||
Each view factor between the agglomerated faces i and j (Fij) is calculated
|
||||
using a double integral of the sub-areas composing the agglomeration.
|
||||
The input from viewFactorsDict are:
|
||||
|
||||
The patches involved in the view factor calculation are taken from the
|
||||
boundary file and should be part on the group viewFactorWall. ie.:
|
||||
GaussQuadTol 0.1; // GaussQuad error
|
||||
distTol 8; // R/Average(rm)
|
||||
alpha 0.22; // Use for common edges for 2LI
|
||||
|
||||
|
||||
For debugging purposes, the following entries can be set in viewFactorsDict:
|
||||
|
||||
writeViewFactorMatrix true;
|
||||
writeFacesAgglomeration false;
|
||||
dumpRays false;
|
||||
|
||||
|
||||
writeViewFactorMatrix writes the sum of the VF on each face.
|
||||
writeFacesAgglomeration writes the agglomeration
|
||||
dumpRays dumps rays
|
||||
|
||||
|
||||
The participating patches in the VF calculation have to be in the
|
||||
'viewFactorWall' patch group (in the polyMesh/boundary file), e.g.
|
||||
|
||||
floor
|
||||
{
|
||||
@ -48,6 +68,9 @@ Description
|
||||
startFace 3100;
|
||||
}
|
||||
|
||||
Compile with -DNO_CGAL only if no CGAL present - CGAL AABB tree performs
|
||||
better than the built-in octree.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
@ -56,21 +79,52 @@ Description
|
||||
#include "surfaceFields.H"
|
||||
#include "distributedTriSurfaceMesh.H"
|
||||
#include "meshTools.H"
|
||||
#include "constants.H"
|
||||
|
||||
#include "indirectPrimitivePatch.H"
|
||||
#include "DynamicField.H"
|
||||
#include "unitConversion.H"
|
||||
|
||||
#include "scalarMatrices.H"
|
||||
#include "labelListIOList.H"
|
||||
#include "scalarListIOList.H"
|
||||
|
||||
#include "singleCellFvMesh.H"
|
||||
|
||||
#include "IOmapDistribute.H"
|
||||
|
||||
using namespace Foam;
|
||||
#ifndef NO_CGAL
|
||||
|
||||
// Silence boost bind deprecation warnings (before CGAL-5.2.1)
|
||||
#include "CGAL/version.h"
|
||||
#if defined(CGAL_VERSION_NR) && (CGAL_VERSION_NR < 1050211000)
|
||||
#define BOOST_BIND_GLOBAL_PLACEHOLDERS
|
||||
#endif
|
||||
|
||||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/AABB_tree.h>
|
||||
#include <CGAL/AABB_traits.h>
|
||||
#include <CGAL/AABB_triangle_primitive.h>
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
|
||||
typedef CGAL::Simple_cartesian<double> K;
|
||||
typedef K::Point_3 Point;
|
||||
typedef K::Direction_3 Vector3C;
|
||||
typedef K::Triangle_3 Triangle;
|
||||
typedef K::Segment_3 Segment;
|
||||
|
||||
typedef std::list<Triangle>::iterator Iterator;
|
||||
typedef CGAL::AABB_triangle_primitive<K, Iterator> Primitive;
|
||||
typedef CGAL::AABB_traits<K, Primitive> AABB_triangle_traits;
|
||||
typedef CGAL::AABB_tree<AABB_triangle_traits> Tree;
|
||||
typedef boost::optional
|
||||
<
|
||||
Tree::Intersection_and_primitive_id<Segment>::Type
|
||||
> Segment_intersection;
|
||||
|
||||
#endif // NO_CGAL
|
||||
|
||||
using namespace Foam;
|
||||
using namespace Foam::constant;
|
||||
using namespace Foam::constant::mathematical;
|
||||
|
||||
triSurface triangulate
|
||||
(
|
||||
@ -127,20 +181,56 @@ triSurface triangulate
|
||||
newPatchI++;
|
||||
}
|
||||
|
||||
//striSurfaceToAgglom.resize(localTriFaceI-1);
|
||||
//triSurfaceToAgglom.resize(localTriFaceI-1);
|
||||
|
||||
triangles.shrink();
|
||||
triSurface surface(triangles, mesh.points());
|
||||
surface.compactPoints();
|
||||
|
||||
// Create globally numbered tri surface
|
||||
triSurface rawSurface(triangles, mesh.points());
|
||||
|
||||
// Create locally numbered tri surface
|
||||
triSurface surface
|
||||
#ifndef NO_CGAL
|
||||
|
||||
// CGAL : every processor has whole surface
|
||||
|
||||
globalIndex globalFaceIdx(surface.size(), globalIndex::gatherOnly());
|
||||
globalIndex globalPointIdx
|
||||
(
|
||||
rawSurface.localFaces(),
|
||||
rawSurface.localPoints()
|
||||
surface.points().size(), globalIndex::gatherOnly()
|
||||
);
|
||||
|
||||
List<labelledTri> globalSurfaceTris(globalFaceIdx.gather(surface));
|
||||
pointField globalSurfacePoints(globalPointIdx.gather(surface.points()));
|
||||
|
||||
//label offset = 0;
|
||||
for (const label proci : globalPointIdx.allProcs())
|
||||
{
|
||||
const label offset = globalPointIdx.localStart(proci);
|
||||
|
||||
if (offset)
|
||||
{
|
||||
for
|
||||
(
|
||||
labelledTri& tri
|
||||
: globalSurfaceTris.slice(globalFaceIdx.range(proci))
|
||||
)
|
||||
{
|
||||
tri[0] += offset;
|
||||
tri[1] += offset;
|
||||
tri[2] += offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
surface =
|
||||
triSurface
|
||||
(
|
||||
std::move(globalSurfaceTris),
|
||||
std::move(globalSurfacePoints)
|
||||
);
|
||||
|
||||
Pstream::broadcast(surface);
|
||||
#endif
|
||||
|
||||
// Add patch names to surface
|
||||
surface.patches().setSize(newPatchI);
|
||||
|
||||
@ -193,7 +283,7 @@ void writeRays
|
||||
}
|
||||
|
||||
|
||||
scalar calculateViewFactorFij
|
||||
scalar calculateViewFactorFij2AI
|
||||
(
|
||||
const vector& i,
|
||||
const vector& j,
|
||||
@ -250,6 +340,74 @@ void insertMatrixElements
|
||||
}
|
||||
|
||||
|
||||
scalar GaussQuad
|
||||
(
|
||||
|
||||
const scalarList& w,
|
||||
const scalarList& p,
|
||||
const scalar& magSi,
|
||||
const scalar& magSj,
|
||||
const vector& di,
|
||||
const vector& dj,
|
||||
const vector& ci,
|
||||
const vector& cj,
|
||||
const scalar cosij,
|
||||
const scalar alpha,
|
||||
label gi
|
||||
)
|
||||
{
|
||||
scalar dIntFij = 0;
|
||||
if (gi == 0)
|
||||
{
|
||||
vector r(ci - cj);
|
||||
if (mag(r) < SMALL)
|
||||
{
|
||||
r = (alpha*magSi)*di;
|
||||
}
|
||||
dIntFij = max(cosij*Foam::log(r&r)*magSi*magSj, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
List<vector> pi(w.size());
|
||||
forAll (pi, i)
|
||||
{
|
||||
pi[i] = ci + p[i]*(magSi/2)*di;
|
||||
}
|
||||
|
||||
List<vector> pj(w.size());
|
||||
forAll (pj, i)
|
||||
{
|
||||
pj[i] = cj + p[i]*(magSj/2)*dj;
|
||||
}
|
||||
|
||||
forAll (w, i)
|
||||
{
|
||||
forAll (w, j)
|
||||
{
|
||||
vector r(pi[i] - pj[j]);
|
||||
|
||||
if (mag(r) < SMALL)
|
||||
{
|
||||
r = (alpha*magSi)*di;
|
||||
dIntFij +=
|
||||
cosij*w[i]*w[j]*Foam::log(r&r);
|
||||
}
|
||||
else
|
||||
{
|
||||
dIntFij +=
|
||||
cosij*w[i]*w[j]*Foam::log(r&r);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
dIntFij *= (magSi/2) * (magSj/2);
|
||||
|
||||
}
|
||||
return dIntFij;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@ -273,7 +431,7 @@ int main(int argc, char *argv[])
|
||||
"viewFactorsDict",
|
||||
runTime.constant(),
|
||||
mesh,
|
||||
IOobject::MUST_READ_IF_MODIFIED,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
@ -288,6 +446,23 @@ int main(int argc, char *argv[])
|
||||
|
||||
const label debug = viewFactorDict.getOrDefault<label>("debug", 0);
|
||||
|
||||
const scalar GaussQuadTol =
|
||||
viewFactorDict.getOrDefault<scalar>("GaussQuadTol", 0.01);
|
||||
|
||||
const scalar distTol =
|
||||
viewFactorDict.getOrDefault<scalar>("distTol", 8);
|
||||
|
||||
const scalar alpha =
|
||||
viewFactorDict.getOrDefault<scalar>("alpha", 0.21);
|
||||
|
||||
const scalar intTol =
|
||||
viewFactorDict.getOrDefault<scalar>("intTol", 1e-2);
|
||||
|
||||
bool useAgglomeration(true);
|
||||
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
const labelList viewFactorsPatches(patches.indices(viewFactorWall));
|
||||
|
||||
// Read agglomeration map
|
||||
labelListIOList finalAgglom
|
||||
(
|
||||
@ -296,12 +471,22 @@ int main(int argc, char *argv[])
|
||||
"finalAgglom",
|
||||
mesh.facesInstance(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
if (!finalAgglom.typeHeaderOk<labelListIOList>())
|
||||
{
|
||||
finalAgglom.setSize(patches.size());
|
||||
for (label patchi=0; patchi < patches.size(); patchi++)
|
||||
{
|
||||
finalAgglom[patchi] = identity(patches[patchi].size());
|
||||
}
|
||||
useAgglomeration = false;
|
||||
}
|
||||
|
||||
// Create the coarse mesh using agglomeration
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@ -336,10 +521,8 @@ int main(int argc, char *argv[])
|
||||
label nCoarseFaces = 0; //total number of coarse faces
|
||||
label nFineFaces = 0; //total number of fine faces
|
||||
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
const polyBoundaryMesh& coarsePatches = coarseMesh.boundaryMesh();
|
||||
|
||||
labelList viewFactorsPatches(patches.indices(viewFactorWall));
|
||||
for (const label patchi : viewFactorsPatches)
|
||||
{
|
||||
nCoarseFaces += coarsePatches[patchi].size();
|
||||
@ -465,7 +648,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Set up searching engine for obstacles
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#ifdef NO_CGAL
|
||||
// Using octree
|
||||
#include "searchingEngine.H"
|
||||
#else
|
||||
// Using CGAL aabbtree (faster, more robust)
|
||||
#include "searchingEngine_CGAL.H"
|
||||
#endif
|
||||
|
||||
// Determine rays between coarse face centres
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@ -473,11 +662,15 @@ int main(int argc, char *argv[])
|
||||
|
||||
DynamicList<label> rayEndFace(rayStartFace.size());
|
||||
|
||||
|
||||
// Return rayStartFace in local index and rayEndFace in global index
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
#ifdef NO_CGAL
|
||||
// Using octree, distributedTriSurfaceMesh
|
||||
#include "shootRays.H"
|
||||
#else
|
||||
// Using CGAL aabbtree (faster, more robust)
|
||||
#include "shootRays_CGAL.H"
|
||||
#endif
|
||||
|
||||
// Calculate number of visible faces from local index
|
||||
labelList nVisibleFaceFaces(nCoarseFaces, Zero);
|
||||
@ -518,9 +711,9 @@ int main(int argc, char *argv[])
|
||||
visibleFaceFaces[faceI][nVisibleFaceFaces[faceI]++] = compactI;
|
||||
}
|
||||
|
||||
|
||||
// Construct data in compact addressing
|
||||
// I need coarse Sf (Ai), fine Sf (dAi) and fine Cf(r) to calculate Fij
|
||||
// (2AA) need coarse (Ai), fine Sf (dAi) and fine Cf(r) to calculate Fij
|
||||
// (2LI) need edges (li)
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
pointField compactCoarseCf(map.constructSize(), Zero);
|
||||
@ -528,12 +721,16 @@ int main(int argc, char *argv[])
|
||||
List<List<point>> compactFineSf(map.constructSize());
|
||||
List<List<point>> compactFineCf(map.constructSize());
|
||||
|
||||
DynamicList<List<point>> compactPoints(map.constructSize());
|
||||
|
||||
DynamicList<label> compactPatchId(map.constructSize());
|
||||
|
||||
// Insert my coarse local values
|
||||
SubList<point>(compactCoarseSf, nCoarseFaces) = localCoarseSf;
|
||||
SubList<point>(compactCoarseCf, nCoarseFaces) = localCoarseCf;
|
||||
|
||||
const faceList& faces = mesh.faces();
|
||||
|
||||
// Insert my fine local values
|
||||
label compactI = 0;
|
||||
forAll(viewFactorsPatches, i)
|
||||
@ -548,11 +745,21 @@ int main(int argc, char *argv[])
|
||||
const labelList& coarsePatchFace =
|
||||
coarseMesh.patchFaceMap()[patchID];
|
||||
|
||||
const polyPatch& pp = patches[patchID];
|
||||
|
||||
forAll(coarseToFine, coarseI)
|
||||
{
|
||||
compactPatchId.append(patchID);
|
||||
List<point>& fineCf = compactFineCf[compactI];
|
||||
List<point>& fineSf = compactFineSf[compactI++];
|
||||
List<point>& fineSf = compactFineSf[compactI];
|
||||
|
||||
label startFace = pp.start();
|
||||
|
||||
const vectorField locPoints
|
||||
(
|
||||
mesh.points(),
|
||||
faces[coarseI + startFace]
|
||||
);
|
||||
|
||||
const label coarseFaceI = coarsePatchFace[coarseI];
|
||||
const labelList& fineFaces = coarseToFine[coarseFaceI];
|
||||
@ -560,6 +767,8 @@ int main(int argc, char *argv[])
|
||||
fineCf.setSize(fineFaces.size());
|
||||
fineSf.setSize(fineFaces.size());
|
||||
|
||||
compactPoints.append(locPoints);
|
||||
|
||||
fineCf = UIndirectList<point>
|
||||
(
|
||||
mesh.Cf().boundaryField()[patchID],
|
||||
@ -570,19 +779,25 @@ int main(int argc, char *argv[])
|
||||
mesh.Sf().boundaryField()[patchID],
|
||||
coarseToFine[coarseFaceI]
|
||||
);
|
||||
|
||||
compactI++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Pstream::master() && debug)
|
||||
{
|
||||
Info<< "map distribute..." << endl;
|
||||
}
|
||||
|
||||
// Do all swapping
|
||||
map.distribute(compactCoarseSf);
|
||||
map.distribute(compactCoarseCf);
|
||||
map.distribute(compactFineCf);
|
||||
map.distribute(compactFineSf);
|
||||
|
||||
map.distribute(compactPoints);
|
||||
map.distribute(compactPatchId);
|
||||
|
||||
|
||||
// Plot all rays between visible faces.
|
||||
if (dumpRays)
|
||||
{
|
||||
@ -598,8 +813,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Fill local view factor matrix
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
scalarListIOList F
|
||||
scalarListIOList F2LI
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
@ -630,6 +844,61 @@ int main(int argc, char *argv[])
|
||||
Info<< "\nCalculating view factors..." << endl;
|
||||
}
|
||||
|
||||
FixedList<scalarList, 5> GaussPoints;
|
||||
GaussPoints[0].setSize(1);
|
||||
GaussPoints[0] = 0;
|
||||
|
||||
GaussPoints[1].setSize(2);
|
||||
GaussPoints[1][0] = 1/std::sqrt(3);
|
||||
GaussPoints[1][1] = -1/std::sqrt(3);
|
||||
|
||||
GaussPoints[2].setSize(3);
|
||||
GaussPoints[2][0] = 0;
|
||||
GaussPoints[2][1] = std::sqrt(3.0/5.0);
|
||||
GaussPoints[2][2] = -std::sqrt(3.0/5.0);
|
||||
|
||||
GaussPoints[3].setSize(4);
|
||||
GaussPoints[3][0] = std::sqrt(3.0/7.0 - (2.0/7.0)*std::sqrt(6.0/5.0));
|
||||
GaussPoints[3][1] = -GaussPoints[3][0];
|
||||
GaussPoints[3][2] = std::sqrt(3.0/7.0 + (2.0/7.0)*std::sqrt(6.0/5.0));
|
||||
GaussPoints[3][3] = -GaussPoints[3][2];
|
||||
|
||||
GaussPoints[4].setSize(5);
|
||||
GaussPoints[4][0] = 0;
|
||||
GaussPoints[4][1] = (1.0/3.0)*std::sqrt(5.0 - 2.0*std::sqrt(10.0/7.0));
|
||||
GaussPoints[4][2] = -GaussPoints[4][1];
|
||||
GaussPoints[4][3] = (1.0/3.0)*std::sqrt(5.0 + 2.0*std::sqrt(10.0/7.0));
|
||||
GaussPoints[4][4] = -GaussPoints[4][3];
|
||||
|
||||
|
||||
List<scalarList> GaussWeights(5);
|
||||
GaussWeights[0].setSize(1);
|
||||
GaussWeights[0] = 2;
|
||||
|
||||
GaussWeights[1].setSize(2);
|
||||
GaussWeights[1][0] = 1;
|
||||
GaussWeights[1][1] = 1;
|
||||
|
||||
GaussWeights[2].setSize(3);
|
||||
GaussWeights[2][0] = 8.0/9.0;
|
||||
GaussWeights[2][1] = 5.0/9.0;
|
||||
GaussWeights[2][2] = 5.0/9.0;
|
||||
|
||||
GaussWeights[3].setSize(4);
|
||||
GaussWeights[3][0] = (18.0 + std::sqrt(30))/36.0;
|
||||
GaussWeights[3][1] = (18.0 + std::sqrt(30))/36.0;
|
||||
GaussWeights[3][2] = (18.0 - std::sqrt(30))/36.0;
|
||||
GaussWeights[3][3] = (18.0 - std::sqrt(30))/36.0;
|
||||
|
||||
GaussWeights[4].setSize(5);
|
||||
GaussWeights[4][0] = 128.0/225.0;
|
||||
GaussWeights[4][1] = (322.0 + 13.0*std::sqrt(70))/900.0;
|
||||
GaussWeights[4][2] = (322.0 + 13.0*std::sqrt(70))/900.0;
|
||||
GaussWeights[4][3] = (322.0 - 13.0*std::sqrt(70))/900.0;
|
||||
GaussWeights[4][4] = (322.0 - 13.0*std::sqrt(70))/900.0;
|
||||
|
||||
const label maxQuadOrder = 5;
|
||||
|
||||
if (mesh.nSolutionD() == 3)
|
||||
{
|
||||
forAll(localCoarseSf, coarseFaceI)
|
||||
@ -638,119 +907,207 @@ int main(int argc, char *argv[])
|
||||
const vector Ai = sum(localFineSf);
|
||||
const List<point>& localFineCf = compactFineCf[coarseFaceI];
|
||||
const label fromPatchId = compactPatchId[coarseFaceI];
|
||||
|
||||
const List<point>& lPoints = compactPoints[coarseFaceI];
|
||||
|
||||
patchArea[fromPatchId] += mag(Ai);
|
||||
|
||||
const labelList& visCoarseFaces = visibleFaceFaces[coarseFaceI];
|
||||
|
||||
forAll(visCoarseFaces, visCoarseFaceI)
|
||||
{
|
||||
F[coarseFaceI].setSize(visCoarseFaces.size());
|
||||
//F2AI[coarseFaceI].setSize(visCoarseFaces.size());
|
||||
F2LI[coarseFaceI].setSize(visCoarseFaces.size());
|
||||
label compactJ = visCoarseFaces[visCoarseFaceI];
|
||||
const List<point>& remoteFineSj = compactFineSf[compactJ];
|
||||
const List<point>& remoteFineCj = compactFineCf[compactJ];
|
||||
|
||||
const List<point>& rPointsCj = compactPoints[compactJ];
|
||||
|
||||
const label toPatchId = compactPatchId[compactJ];
|
||||
|
||||
scalar Fij = 0;
|
||||
bool far(false);
|
||||
// Relative distance
|
||||
forAll(localFineSf, i)
|
||||
{
|
||||
const vector& dAi = localFineSf[i];
|
||||
const scalar dAi =
|
||||
Foam::sqrt
|
||||
(
|
||||
mag(localFineSf[i])/constant::mathematical::pi
|
||||
);
|
||||
const vector& dCi = localFineCf[i];
|
||||
|
||||
forAll(remoteFineSj, j)
|
||||
{
|
||||
const vector& dAj = remoteFineSj[j];
|
||||
const scalar dAj =
|
||||
Foam::sqrt
|
||||
(
|
||||
mag(remoteFineSj[j])/constant::mathematical::pi
|
||||
);
|
||||
const vector& dCj = remoteFineCj[j];
|
||||
|
||||
scalar dIntFij = calculateViewFactorFij
|
||||
(
|
||||
dCi,
|
||||
dCj,
|
||||
dAi,
|
||||
dAj
|
||||
);
|
||||
const scalar dist = mag(dCi - dCj)/((dAi + dAj)/2);
|
||||
|
||||
Fij += dIntFij;
|
||||
if (dist > distTol)
|
||||
{
|
||||
far = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
F[coarseFaceI][visCoarseFaceI] = Fij/mag(Ai);
|
||||
sumViewFactorPatch[fromPatchId][toPatchId] += Fij;
|
||||
|
||||
if (far)
|
||||
{
|
||||
// 2AI method
|
||||
scalar F2AIij = 0;
|
||||
|
||||
forAll(localFineSf, i)
|
||||
{
|
||||
const vector& dAi = localFineSf[i];
|
||||
const vector& dCi = localFineCf[i];
|
||||
|
||||
forAll(remoteFineSj, j)
|
||||
{
|
||||
const vector& dAj = remoteFineSj[j];
|
||||
const vector& dCj = remoteFineCj[j];
|
||||
|
||||
scalar dIntFij = calculateViewFactorFij2AI
|
||||
(
|
||||
dCi,
|
||||
dCj,
|
||||
dAi,
|
||||
dAj
|
||||
);
|
||||
|
||||
F2AIij += dIntFij;
|
||||
}
|
||||
}
|
||||
F2LI[coarseFaceI][visCoarseFaceI] = F2AIij/mag(Ai);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 2LI method
|
||||
label nLocal = lPoints.size();
|
||||
label nRemote = rPointsCj.size();
|
||||
|
||||
// Using sub-divisions (quadrature)
|
||||
scalar oldEToeInt = 0;
|
||||
for (label gi=0; gi < maxQuadOrder; gi++)
|
||||
{
|
||||
scalar F2LIij = 0;
|
||||
for(label i=0; i<nLocal; i++)
|
||||
{
|
||||
vector si;
|
||||
vector ci;
|
||||
|
||||
vector sj;
|
||||
vector cj;
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
si = lPoints[i] - lPoints[nLocal-1];
|
||||
ci = (lPoints[i] + lPoints[nLocal-1])/2;
|
||||
}
|
||||
else
|
||||
{
|
||||
si = lPoints[i] - lPoints[i-1];
|
||||
ci = (lPoints[i] + lPoints[i-1])/2;
|
||||
}
|
||||
|
||||
for(label j=0; j<nRemote; j++)
|
||||
{
|
||||
if (j == 0)
|
||||
{
|
||||
sj = rPointsCj[j]-rPointsCj[nRemote-1];
|
||||
cj = (rPointsCj[j]+rPointsCj[nRemote-1])/2;
|
||||
}
|
||||
else
|
||||
{
|
||||
sj = rPointsCj[j] - rPointsCj[j-1];
|
||||
cj = (rPointsCj[j] + rPointsCj[j-1])/2;
|
||||
}
|
||||
|
||||
|
||||
scalar magSi = mag(si);
|
||||
scalar magSj = mag(sj);
|
||||
scalar cosij = (si & sj)/(magSi * magSj);
|
||||
|
||||
vector di = si/magSi;
|
||||
vector dj = sj/magSj;
|
||||
|
||||
label quadOrder = gi;
|
||||
const vector r(ci - cj);
|
||||
// Common edges use n = 0
|
||||
if (mag(r) < SMALL)
|
||||
{
|
||||
quadOrder = 0;
|
||||
}
|
||||
|
||||
scalar dIntFij =
|
||||
GaussQuad
|
||||
(
|
||||
GaussWeights[gi],
|
||||
GaussPoints[gi],
|
||||
magSi,
|
||||
magSj,
|
||||
di,
|
||||
dj,
|
||||
ci,
|
||||
cj,
|
||||
cosij,
|
||||
alpha,
|
||||
quadOrder
|
||||
);
|
||||
|
||||
F2LIij += dIntFij;
|
||||
}
|
||||
}
|
||||
|
||||
scalar err = (F2LIij-oldEToeInt)/F2LIij;
|
||||
|
||||
if
|
||||
(
|
||||
(mag(err) < GaussQuadTol && gi > 0)
|
||||
|| gi == maxQuadOrder-1
|
||||
)
|
||||
{
|
||||
F2LI[coarseFaceI][visCoarseFaceI] =
|
||||
F2LIij/mag(Ai)/4/constant::mathematical::pi;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
oldEToeInt = F2LIij;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sumViewFactorPatch[fromPatchId][toPatchId] +=
|
||||
F2LI[coarseFaceI][visCoarseFaceI]*mag(Ai);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (mesh.nSolutionD() == 2)
|
||||
else
|
||||
{
|
||||
const boundBox& box = mesh.bounds();
|
||||
const Vector<label>& dirs = mesh.geometricD();
|
||||
vector emptyDir = Zero;
|
||||
forAll(dirs, i)
|
||||
{
|
||||
if (dirs[i] == -1)
|
||||
{
|
||||
emptyDir[i] = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
scalar wideBy2 = (box.span() & emptyDir)*2.0;
|
||||
|
||||
forAll(localCoarseSf, coarseFaceI)
|
||||
{
|
||||
const vector& Ai = localCoarseSf[coarseFaceI];
|
||||
const vector& Ci = localCoarseCf[coarseFaceI];
|
||||
vector Ain = Ai/mag(Ai);
|
||||
vector R1i = Ci + (mag(Ai)/wideBy2)*(Ain ^ emptyDir);
|
||||
vector R2i = Ci - (mag(Ai)/wideBy2)*(Ain ^ emptyDir) ;
|
||||
|
||||
const label fromPatchId = compactPatchId[coarseFaceI];
|
||||
patchArea[fromPatchId] += mag(Ai);
|
||||
|
||||
const labelList& visCoarseFaces = visibleFaceFaces[coarseFaceI];
|
||||
forAll(visCoarseFaces, visCoarseFaceI)
|
||||
{
|
||||
F[coarseFaceI].setSize(visCoarseFaces.size());
|
||||
label compactJ = visCoarseFaces[visCoarseFaceI];
|
||||
const vector& Aj = compactCoarseSf[compactJ];
|
||||
const vector& Cj = compactCoarseCf[compactJ];
|
||||
|
||||
const label toPatchId = compactPatchId[compactJ];
|
||||
|
||||
vector Ajn = Aj/mag(Aj);
|
||||
vector R1j = Cj + (mag(Aj)/wideBy2)*(Ajn ^ emptyDir);
|
||||
vector R2j = Cj - (mag(Aj)/wideBy2)*(Ajn ^ emptyDir);
|
||||
|
||||
scalar d1 = mag(R1i - R2j);
|
||||
scalar d2 = mag(R2i - R1j);
|
||||
scalar s1 = mag(R1i - R1j);
|
||||
scalar s2 = mag(R2i - R2j);
|
||||
|
||||
scalar Fij = mag((d1 + d2) - (s1 + s2))/(4.0*mag(Ai)/wideBy2);
|
||||
|
||||
F[coarseFaceI][visCoarseFaceI] = Fij;
|
||||
sumViewFactorPatch[fromPatchId][toPatchId] += Fij*mag(Ai);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
Info << "Writing view factor matrix..." << endl;
|
||||
FatalErrorInFunction
|
||||
<< " View factors are not available in 2D "
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
// Write view factors matrix in listlist form
|
||||
F.write();
|
||||
F2LI.write();
|
||||
|
||||
reduce(sumViewFactorPatch, sumOp<scalarSquareMatrix>());
|
||||
reduce(patchArea, sumOp<scalarList>());
|
||||
|
||||
|
||||
if (Pstream::master() && debug)
|
||||
{
|
||||
forAll(viewFactorsPatches, i)
|
||||
{
|
||||
label patchI = viewFactorsPatches[i];
|
||||
forAll(viewFactorsPatches, i)
|
||||
for (label j=i; j<viewFactorsPatches.size(); j++)
|
||||
{
|
||||
label patchJ = viewFactorsPatches[i];
|
||||
label patchJ = viewFactorsPatches[j];
|
||||
|
||||
Info << "F" << patchI << patchJ << ": "
|
||||
<< sumViewFactorPatch[patchI][patchJ]/patchArea[patchI]
|
||||
<< endl;
|
||||
@ -758,9 +1115,13 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (writeViewFactors)
|
||||
{
|
||||
if (Pstream::master())
|
||||
{
|
||||
Info << "Writing view factor matrix..." << endl;
|
||||
}
|
||||
|
||||
volScalarField viewFactorField
|
||||
(
|
||||
IOobject
|
||||
@ -791,13 +1152,14 @@ int main(int argc, char *argv[])
|
||||
|
||||
forAll(coarseToFine, coarseI)
|
||||
{
|
||||
const scalar Fij = sum(F[compactI]);
|
||||
const scalar FiSum = sum(F2LI[compactI]);
|
||||
|
||||
const label coarseFaceID = coarsePatchFace[coarseI];
|
||||
const labelList& fineFaces = coarseToFine[coarseFaceID];
|
||||
forAll(fineFaces, fineId)
|
||||
{
|
||||
const label faceID = fineFaces[fineId];
|
||||
vfbf[patchID][faceID] = Fij;
|
||||
vfbf[patchID][faceID] = FiSum;
|
||||
}
|
||||
compactI++;
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@ if have_cgal
|
||||
then
|
||||
wmake $targetType PolyhedronReader
|
||||
export COMP_FLAGS='-IPolyhedronReader'
|
||||
export LINK_FLAGS='${CGAL_LIBS} -lPolyhedronReader'
|
||||
export LINK_FLAGS='-lPolyhedronReader'
|
||||
else
|
||||
export COMP_FLAGS="-DNO_CGAL"
|
||||
fi
|
||||
|
||||
@ -26,4 +26,5 @@ EXE_LIBS = \
|
||||
-lfileFormats \
|
||||
-lsurfMesh \
|
||||
-lmeshTools \
|
||||
${CGAL_LIBS} \
|
||||
$(LINK_FLAGS)
|
||||
|
||||
@ -81,7 +81,6 @@ Description
|
||||
#include "triSurfaceSearch.H"
|
||||
#include "triSurfaceMesh.H"
|
||||
#include "OFstream.H"
|
||||
#include "OBJstream.H"
|
||||
#include "booleanSurface.H"
|
||||
#include "edgeIntersections.H"
|
||||
#include "meshTools.H"
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -856,12 +856,10 @@ int main(int argc, char *argv[])
|
||||
if (debug)
|
||||
{
|
||||
OBJstream str(runTime.path()/"isScaledPoint.obj");
|
||||
forAll(isScaledPoint, pointI)
|
||||
|
||||
for (const label pointi : isScaledPoint)
|
||||
{
|
||||
if (isScaledPoint[pointI])
|
||||
{
|
||||
str.write(initialPoints[meshPoints[pointI]]);
|
||||
}
|
||||
str.write(initialPoints[meshPoints[pointi]]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -157,7 +157,7 @@ getNumberOfPatchFaces()
|
||||
'/^ *'"$patch"' *$/,/}/{s/^ *nFaces *\([0-9][0-9]*\) *;.*$/\1/p}' \
|
||||
"$file")
|
||||
|
||||
if [ -n "nFaces" ]
|
||||
if [ -n "$nFaces" ]
|
||||
then
|
||||
echo "$nFaces"
|
||||
else
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
# \\ / A nd | www.openfoam.com
|
||||
# \\/ M anipulation |
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||
# Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
@ -65,7 +65,7 @@ die()
|
||||
echo "Error encountered:"
|
||||
while [ "$#" -ge 1 ]; do echo " $1"; shift; done
|
||||
echo
|
||||
echo "See '${Script##*/} -help' for usage"
|
||||
echo "See '${0##*/} -help' for usage"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
@ -73,7 +73,7 @@ die()
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
optSyntax=sh
|
||||
optSyntax="sh"
|
||||
unset verboseOutput
|
||||
|
||||
# Parse options
|
||||
|
||||
@ -230,6 +230,21 @@ castellatedMeshControls
|
||||
// outside locations. Default is only after all refinement has
|
||||
// been done.
|
||||
//leakLevel 10;
|
||||
|
||||
// Additional refinement for regions of high curvature. Expressed
|
||||
// (bit similar to gapLevel) as:
|
||||
// - number of cells per radius of curvature. (usually 1 is
|
||||
// good enough)
|
||||
// - starting cell level? Not used at the moment.
|
||||
// - maximum cell level. This can be smaller or larger than the
|
||||
// max 'surface' level
|
||||
// - minumum curvature radius to ignore (expressed as a cell level).
|
||||
// This can be used to avoid detecting small sharp surface
|
||||
// features. Set to -1 to ignore.
|
||||
// (sometimes you want more refinement than sharp features since
|
||||
// these can be done with feature edge snapping (so can leave
|
||||
// level (0 0))
|
||||
//curvatureLevel (10 0 10 -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -40,8 +40,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef fileStat_H
|
||||
#define fileStat_H
|
||||
#ifndef Foam_fileStat_H
|
||||
#define Foam_fileStat_H
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
@ -54,7 +54,7 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declarations
|
||||
// Forward Declarations
|
||||
class fileStat;
|
||||
|
||||
Istream& operator>>(Istream& is, fileStat& fs);
|
||||
@ -67,7 +67,7 @@ Ostream& operator<<(Ostream& os, const fileStat& fs);
|
||||
|
||||
class fileStat
|
||||
{
|
||||
// Private data
|
||||
// Private Data
|
||||
|
||||
struct stat status_;
|
||||
|
||||
@ -78,7 +78,7 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Empty constructor
|
||||
//- Default construct
|
||||
fileStat();
|
||||
|
||||
//- Construct from components.
|
||||
@ -89,7 +89,7 @@ public:
|
||||
// \param maxTime The timeout value.
|
||||
//
|
||||
// \note An empty filename is a no-op.
|
||||
fileStat
|
||||
explicit fileStat
|
||||
(
|
||||
const char* fName,
|
||||
const bool followLink = true,
|
||||
@ -104,7 +104,7 @@ public:
|
||||
// \param maxTime The timeout value.
|
||||
//
|
||||
// \note An empty filename is a no-op.
|
||||
fileStat
|
||||
explicit fileStat
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool followLink = true,
|
||||
@ -119,27 +119,33 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
//- Raw status
|
||||
const struct stat& status() const
|
||||
{
|
||||
return status_;
|
||||
}
|
||||
|
||||
//- Was file-stat successful?
|
||||
bool valid() const
|
||||
//- True if file-stat was successful
|
||||
bool valid() const noexcept
|
||||
{
|
||||
return valid_;
|
||||
}
|
||||
|
||||
//- Size in bytes. Zero for an invalid file-stat.
|
||||
//- True if file-stat was successful
|
||||
explicit operator bool() const noexcept
|
||||
{
|
||||
return valid_;
|
||||
}
|
||||
|
||||
//- The raw status
|
||||
const struct stat& status() const noexcept
|
||||
{
|
||||
return status_;
|
||||
}
|
||||
|
||||
//- Size in bytes, 0 for an invalid file-stat.
|
||||
label size() const;
|
||||
|
||||
//- Return the modification time in seconds.
|
||||
// Zero for an invalid file-stat.
|
||||
//- The modification time in seconds,
|
||||
//- 0 for an invalid file-stat.
|
||||
time_t modTime() const;
|
||||
|
||||
//- Return the modification time in seconds (nanosecond resolution)
|
||||
// Zero for an invalid file-stat.
|
||||
//- The modification time in seconds (nanosecond resolution),
|
||||
//- 0 for an invalid file-stat.
|
||||
double dmodTime() const;
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -40,8 +40,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef fileStat_H
|
||||
#define fileStat_H
|
||||
#ifndef Foam_fileStat_H
|
||||
#define Foam_fileStat_H
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
@ -54,7 +54,7 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declarations
|
||||
// Forward Declarations
|
||||
class fileStat;
|
||||
|
||||
Istream& operator>>(Istream& is, fileStat& fs);
|
||||
@ -67,7 +67,7 @@ Ostream& operator<<(Ostream& os, const fileStat& fs);
|
||||
|
||||
class fileStat
|
||||
{
|
||||
// Private data
|
||||
// Private Data
|
||||
|
||||
struct stat status_;
|
||||
|
||||
@ -78,7 +78,7 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Empty constructor
|
||||
//- Default construct
|
||||
fileStat();
|
||||
|
||||
//- Construct from components.
|
||||
@ -89,7 +89,7 @@ public:
|
||||
// \param maxTime The timeout value.
|
||||
//
|
||||
// \note An empty filename is a no-op.
|
||||
fileStat
|
||||
explicit fileStat
|
||||
(
|
||||
const char* fName,
|
||||
const bool followLink = true,
|
||||
@ -104,7 +104,7 @@ public:
|
||||
// \param maxTime The timeout value.
|
||||
//
|
||||
// \note An empty filename is a no-op.
|
||||
fileStat
|
||||
explicit fileStat
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool followLink = true,
|
||||
@ -119,27 +119,33 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
//- Raw status
|
||||
const struct stat& status() const
|
||||
{
|
||||
return status_;
|
||||
}
|
||||
|
||||
//- Was file-stat successful?
|
||||
bool valid() const
|
||||
//- True if file-stat was successful
|
||||
bool valid() const noexcept
|
||||
{
|
||||
return valid_;
|
||||
}
|
||||
|
||||
//- Size in bytes. Zero for an invalid file-stat.
|
||||
//- True if file-stat was successful
|
||||
explicit operator bool() const noexcept
|
||||
{
|
||||
return valid_;
|
||||
}
|
||||
|
||||
//- The raw status
|
||||
const struct stat& status() const noexcept
|
||||
{
|
||||
return status_;
|
||||
}
|
||||
|
||||
//- Size in bytes, 0 for an invalid file-stat.
|
||||
label size() const;
|
||||
|
||||
//- Return the modification time in seconds.
|
||||
// Zero for an invalid file-stat.
|
||||
//- The modification time in seconds,
|
||||
//- 0 for an invalid file-stat.
|
||||
time_t modTime() const;
|
||||
|
||||
//- Return the modification time in seconds (nanosecond resolution)
|
||||
// Zero for an invalid file-stat.
|
||||
//- The modification time in seconds (nanosecond resolution),
|
||||
//- 0 for an invalid file-stat.
|
||||
double dmodTime() const;
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,95 +28,112 @@ License
|
||||
|
||||
#include "error.H"
|
||||
#include "OSspecific.H"
|
||||
#include "IFstream.H"
|
||||
#include "StringStream.H"
|
||||
|
||||
#include <cinttypes>
|
||||
#include <sstream>
|
||||
#include <cxxabi.h>
|
||||
#include <execinfo.h>
|
||||
#include <dlfcn.h>
|
||||
#include <execinfo.h>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
namespace
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
string pOpen(const string& cmd, label line=0)
|
||||
// Read up to and including lineNum from the piped command
|
||||
// Return the final line read
|
||||
std::string pipeOpen(const std::string& cmd, const int lineNum = 0)
|
||||
{
|
||||
string res;
|
||||
std::string str;
|
||||
|
||||
FILE *cmdPipe = popen(cmd.c_str(), "r");
|
||||
if (cmdPipe)
|
||||
FILE *handle = popen(cmd.c_str(), "r");
|
||||
if (!handle) return str;
|
||||
|
||||
char* buf = nullptr;
|
||||
size_t len = 0;
|
||||
ssize_t nread;
|
||||
|
||||
// Read lineNum number of lines
|
||||
for
|
||||
(
|
||||
int cnt = 0;
|
||||
cnt <= lineNum && (nread = ::getline(&buf, &len, handle)) >= 0;
|
||||
++cnt
|
||||
)
|
||||
{
|
||||
char *buf = nullptr;
|
||||
|
||||
// Read line number of lines
|
||||
for (label cnt = 0; cnt <= line; ++cnt)
|
||||
if (cnt == lineNum)
|
||||
{
|
||||
size_t linecap = 0;
|
||||
ssize_t linelen = ::getline(&buf, &linecap, cmdPipe);
|
||||
// Retain the last line, trimming trailing newline
|
||||
str.assign(buf);
|
||||
|
||||
if (linelen < 0)
|
||||
if (str.size())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (cnt == line)
|
||||
{
|
||||
res = string(buf);
|
||||
// Trim trailing newline
|
||||
if (res.size())
|
||||
{
|
||||
res.resize(res.size()-1);
|
||||
}
|
||||
break;
|
||||
str.resize(str.size()-1);
|
||||
}
|
||||
}
|
||||
|
||||
if (buf != nullptr)
|
||||
{
|
||||
free(buf);
|
||||
}
|
||||
|
||||
pclose(cmdPipe);
|
||||
}
|
||||
|
||||
return res;
|
||||
free(buf);
|
||||
pclose(handle);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
inline word addressToWord(const uintptr_t addr)
|
||||
inline std::string addressToWord(const uintptr_t addr)
|
||||
{
|
||||
OStringStream os;
|
||||
std::ostringstream buf;
|
||||
buf.setf(std::ios_base::hex, std::ios_base::basefield);
|
||||
|
||||
buf << "0x"; // Same as setf(std::ios::showbase)
|
||||
|
||||
#ifdef __APPLE__
|
||||
os << "0x" << hex << uint64_t(addr);
|
||||
buf << uint64_t(addr);
|
||||
#else
|
||||
os << "0x" << hex << addr;
|
||||
buf << addr;
|
||||
#endif
|
||||
return os.str();
|
||||
|
||||
return buf.str(); // Needs no stripping
|
||||
}
|
||||
|
||||
|
||||
inline string& shorterPath(string& s)
|
||||
// Note: demangle requires symbols only - without extra '(' etc.
|
||||
inline std::string demangleSymbol(const char* sn)
|
||||
{
|
||||
s.replace(cwd() + '/', "");
|
||||
s.replace(home(), "~");
|
||||
int st = 0;
|
||||
|
||||
char* cxx_sname = abi::__cxa_demangle(sn, nullptr, nullptr, &st);
|
||||
|
||||
if (st == 0 && cxx_sname)
|
||||
{
|
||||
std::string demangled(cxx_sname);
|
||||
free(cxx_sname);
|
||||
|
||||
return demangled;
|
||||
}
|
||||
|
||||
return sn;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::string& shorterPath(Foam::string& s)
|
||||
{
|
||||
s.replace(Foam::cwd() + '/', "");
|
||||
s.replace(Foam::home(), "~");
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
void printSourceFileAndLine
|
||||
(
|
||||
Ostream& os,
|
||||
const fileName& filename,
|
||||
Dl_info *info,
|
||||
Foam::Ostream& os,
|
||||
const Foam::fileName& filename,
|
||||
const Dl_info& info,
|
||||
void *addr
|
||||
)
|
||||
{
|
||||
uintptr_t address = uintptr_t(addr);
|
||||
word myAddress = addressToWord(address);
|
||||
std::string myAddress = addressToWord(address);
|
||||
|
||||
// Can use relative addresses for executables and libraries with the
|
||||
// Darwin addr2line implementation.
|
||||
@ -127,14 +144,14 @@ void printSourceFileAndLine
|
||||
#endif
|
||||
{
|
||||
// Convert address into offset into dynamic library
|
||||
uintptr_t offset = uintptr_t(info->dli_fbase);
|
||||
uintptr_t offset = uintptr_t(info.dli_fbase);
|
||||
intptr_t relativeAddress = address - offset;
|
||||
myAddress = addressToWord(relativeAddress);
|
||||
}
|
||||
|
||||
if (filename[0] == '/')
|
||||
{
|
||||
string line = pOpen
|
||||
Foam::string line = pipeOpen
|
||||
(
|
||||
"addr2line -f --demangle=auto --exe "
|
||||
+ filename
|
||||
@ -147,7 +164,7 @@ void printSourceFileAndLine
|
||||
{
|
||||
os << " addr2line failed";
|
||||
}
|
||||
else if (line == "??:0")
|
||||
else if (line == "??:0" || line == "??:?" )
|
||||
{
|
||||
line = filename;
|
||||
os << " in " << shorterPath(line).c_str();
|
||||
@ -160,113 +177,138 @@ void printSourceFileAndLine
|
||||
}
|
||||
|
||||
|
||||
fileName absolutePath(const char* fn)
|
||||
// Uses 'which' to find executable on PATH
|
||||
// - could also iterate through PATH directly
|
||||
inline Foam::fileName whichPath(const char* fn)
|
||||
{
|
||||
fileName fname(fn);
|
||||
Foam::fileName fname(fn);
|
||||
|
||||
if (fname[0] != '/' && fname[0] != '~')
|
||||
if (!fname.empty() && fname[0] != '/' && fname[0] != '~')
|
||||
{
|
||||
string tmp = pOpen("which " + fname);
|
||||
std::string s = pipeOpen("which " + fname);
|
||||
|
||||
if (tmp[0] == '/' || tmp[0] == '~')
|
||||
if (s[0] == '/' || s[0] == '~')
|
||||
{
|
||||
fname = tmp;
|
||||
fname = s;
|
||||
}
|
||||
}
|
||||
|
||||
return fname;
|
||||
}
|
||||
|
||||
|
||||
word demangleSymbol(const char* sn)
|
||||
{
|
||||
int st;
|
||||
char* cxx_sname = abi::__cxa_demangle
|
||||
(
|
||||
sn,
|
||||
nullptr,
|
||||
0,
|
||||
&st
|
||||
);
|
||||
|
||||
if (st == 0 && cxx_sname)
|
||||
{
|
||||
word demangled(cxx_sname);
|
||||
free(cxx_sname);
|
||||
|
||||
return demangled;
|
||||
}
|
||||
|
||||
return sn;
|
||||
}
|
||||
} // End anonymous namespace
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::error::safePrintStack(std::ostream& os)
|
||||
{
|
||||
// Get raw stack symbols
|
||||
void *array[100];
|
||||
size_t size = backtrace(array, 100);
|
||||
char **strings = backtrace_symbols(array, size);
|
||||
void *callstack[100];
|
||||
const int size = backtrace(callstack, 100);
|
||||
char **strings = backtrace_symbols(callstack, size);
|
||||
size_t rdelim;
|
||||
|
||||
// See if they contain function between () e.g. "(__libc_start_main+0xd0)"
|
||||
// and see if cplus_demangle can make sense of part before +
|
||||
for (size_t i = 0; i < size; ++i)
|
||||
for (int i = 0; i < size; ++i)
|
||||
{
|
||||
string msg(strings[i]);
|
||||
fileName programFile;
|
||||
word address;
|
||||
std::string str(strings[i]);
|
||||
|
||||
os << '#' << label(i) << '\t' << msg << std::endl;
|
||||
os << '#' << i << '\t';
|
||||
|
||||
// Possibly shorten paths that appear to correspond to OpenFOAM
|
||||
// locations (platforms).
|
||||
//
|
||||
// Eg, "/path/openfoam/platforms/linux64GccDPInt32Opt/lib/libxyz.so"
|
||||
// --> "platforms/linux64GccDPInt32Opt/lib/libxyz.so"
|
||||
|
||||
auto ldelim = str.find('(');
|
||||
auto beg = str.find("/platforms/");
|
||||
|
||||
if (beg == std::string::npos || !beg || beg > ldelim)
|
||||
{
|
||||
beg = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
++beg;
|
||||
}
|
||||
|
||||
if
|
||||
(
|
||||
(ldelim != std::string::npos)
|
||||
&& (rdelim = str.find('+', ldelim+1)) != std::string::npos
|
||||
&& (rdelim > ldelim+1)
|
||||
)
|
||||
{
|
||||
// Found function between () e.g. "(__libc_start_main+0xd0)"
|
||||
// - demangle function name (before the '+' offset)
|
||||
// - preserve trailing [0xAddr]
|
||||
|
||||
os << str.substr(beg, ldelim-beg)
|
||||
<< ' '
|
||||
<< demangleSymbol
|
||||
(
|
||||
str.substr(ldelim+1, rdelim-ldelim-1).c_str()
|
||||
);
|
||||
|
||||
if ((rdelim = str.find('[', rdelim)) != std::string::npos)
|
||||
{
|
||||
os << ' ' << str.substr(rdelim);
|
||||
}
|
||||
}
|
||||
else if (beg)
|
||||
{
|
||||
// With shortened path name
|
||||
os << str.substr(beg);
|
||||
}
|
||||
else
|
||||
{
|
||||
// No modification to string
|
||||
os << str;
|
||||
}
|
||||
os << std::endl;
|
||||
}
|
||||
|
||||
free(strings);
|
||||
}
|
||||
|
||||
|
||||
void Foam::error::printStack(Ostream& os)
|
||||
{
|
||||
// Get raw stack symbols
|
||||
const size_t CALLSTACK_SIZE = 128;
|
||||
void *callstack[100];
|
||||
const int size = backtrace(callstack, 100);
|
||||
|
||||
void *callstack[CALLSTACK_SIZE];
|
||||
size_t size = backtrace(callstack, CALLSTACK_SIZE);
|
||||
Dl_info info;
|
||||
fileName fname;
|
||||
|
||||
Dl_info *info = new Dl_info;
|
||||
|
||||
fileName fname = "???";
|
||||
word address;
|
||||
|
||||
for (size_t i=0; i<size; ++i)
|
||||
for (int i = 0; i < size; ++i)
|
||||
{
|
||||
int st = dladdr(callstack[i], info);
|
||||
int st = dladdr(callstack[i], &info);
|
||||
|
||||
os << '#' << label(i) << " ";
|
||||
if (st != 0 && info->dli_fname != nullptr && info->dli_fname[0] != '\0')
|
||||
os << '#' << i << " ";
|
||||
if (st != 0 && info.dli_fname != nullptr && *(info.dli_fname))
|
||||
{
|
||||
fname = absolutePath(info->dli_fname);
|
||||
fname = whichPath(info.dli_fname);
|
||||
|
||||
os <<
|
||||
(
|
||||
(info->dli_sname != nullptr)
|
||||
? demangleSymbol(info->dli_sname)
|
||||
: "?"
|
||||
);
|
||||
if (info.dli_sname)
|
||||
{
|
||||
os << demangleSymbol(info.dli_sname).c_str();
|
||||
}
|
||||
else
|
||||
{
|
||||
os << '?';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
os << "?";
|
||||
fname = "???";
|
||||
os << '?';
|
||||
}
|
||||
|
||||
printSourceFileAndLine(os, fname, info, callstack[i]);
|
||||
os << nl;
|
||||
os << nl;
|
||||
}
|
||||
|
||||
delete info;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -339,9 +339,8 @@ $(IOdictionary)/IOdictionary.C
|
||||
db/IOobjects/IOMap/IOMaps.C
|
||||
db/IOobjects/decomposedBlockData/decomposedBlockData.C
|
||||
db/IOobjects/decomposedBlockData/decomposedBlockDataHeader.C
|
||||
db/IOobjects/rawIOField/rawIOFields.C
|
||||
db/IOobjects/GlobalIOField/GlobalIOFields.C
|
||||
|
||||
|
||||
db/IOobjects/GlobalIOList/globalIOLists.C
|
||||
|
||||
|
||||
|
||||
@ -239,7 +239,7 @@ inline UIntType repeat_value(unsigned val)
|
||||
template<class UIntType>
|
||||
inline Ostream& print(Ostream& os, UIntType value, char off='0', char on='1')
|
||||
{
|
||||
if (os.format() == IOstream::BINARY)
|
||||
if (os.format() == IOstreamOption::BINARY)
|
||||
{
|
||||
// Perhaps not the most sensible, but the only thing we currently have.
|
||||
os << label(value);
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -81,7 +81,7 @@ Foam::Istream& Foam::PackedList<Width>::readList(Istream& is)
|
||||
// Set list length to that read
|
||||
list.resize(len);
|
||||
|
||||
if (is.format() == IOstream::BINARY)
|
||||
if (is.format() == IOstreamOption::BINARY)
|
||||
{
|
||||
// Binary (always contiguous)
|
||||
|
||||
@ -184,7 +184,7 @@ Foam::Ostream& Foam::PackedList<Width>::writeList
|
||||
const PackedList<Width>& list = *this;
|
||||
const label len = list.size();
|
||||
|
||||
if (os.format() == IOstream::BINARY)
|
||||
if (os.format() == IOstreamOption::BINARY)
|
||||
{
|
||||
// Binary (always contiguous)
|
||||
|
||||
|
||||
@ -167,7 +167,7 @@ Foam::Ostream& Foam::CircularBuffer<T>::writeList
|
||||
}
|
||||
#endif
|
||||
|
||||
if (os.format() == IOstream::BINARY && is_contiguous<T>::value)
|
||||
if (os.format() == IOstreamOption::BINARY && is_contiguous<T>::value)
|
||||
{
|
||||
// Binary and contiguous
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -44,7 +44,7 @@ Foam::Ostream& Foam::IndirectListBase<T, Addr>::writeList
|
||||
|
||||
const label len = list.size();
|
||||
|
||||
if (os.format() == IOstream::BINARY && is_contiguous<T>::value)
|
||||
if (os.format() == IOstreamOption::BINARY && is_contiguous<T>::value)
|
||||
{
|
||||
// Binary and contiguous
|
||||
os << nl << len << nl;
|
||||
|
||||
@ -40,7 +40,7 @@ void Foam::FixedList<T, N>::writeEntry(Ostream& os) const
|
||||
if (token::compound::isCompound(tag))
|
||||
{
|
||||
os << tag << token::SPACE;
|
||||
if (os.format() == IOstream::BINARY && is_contiguous<T>::value)
|
||||
if (os.format() == IOstreamOption::BINARY && is_contiguous<T>::value)
|
||||
{
|
||||
// Need the size too so that List<Type>::readList parses correctly
|
||||
os << static_cast<label>(N);
|
||||
@ -90,7 +90,7 @@ Foam::Ostream& Foam::FixedList<T, N>::writeList
|
||||
// small and we prefer a consistent appearance.
|
||||
// Eg, FixedList<T,2> or Pair<T> as "(-1 -1)", never as "2{-1}"
|
||||
|
||||
if (os.format() == IOstream::BINARY && is_contiguous<T>::value)
|
||||
if (os.format() == IOstreamOption::BINARY && is_contiguous<T>::value)
|
||||
{
|
||||
// Binary and contiguous. Size is always non-zero
|
||||
|
||||
@ -158,7 +158,7 @@ Foam::Istream& Foam::FixedList<T, N>::readList
|
||||
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
||||
if (is.format() == IOstream::BINARY && is_contiguous<T>::value)
|
||||
if (is.format() == IOstreamOption::BINARY && is_contiguous<T>::value)
|
||||
{
|
||||
// Binary and contiguous. Length is non-zero
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -80,7 +80,7 @@ Foam::Istream& Foam::List<T>::readList(Istream& is)
|
||||
// Resize to actual length read
|
||||
list.resize(len);
|
||||
|
||||
if (is.format() == IOstream::BINARY && is_contiguous<T>::value)
|
||||
if (is.format() == IOstreamOption::BINARY && is_contiguous<T>::value)
|
||||
{
|
||||
// Binary and contiguous
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -47,7 +47,7 @@ void Foam::UList<T>::writeEntry(Ostream& os) const
|
||||
{
|
||||
os << *this;
|
||||
}
|
||||
else if (os.format() == IOstream::ASCII)
|
||||
else if (os.format() == IOstreamOption::ASCII)
|
||||
{
|
||||
// Zero-sized ASCII - Write size and delimiters
|
||||
os << 0 << token::BEGIN_LIST << token::END_LIST;
|
||||
@ -85,7 +85,7 @@ Foam::Ostream& Foam::UList<T>::writeList
|
||||
|
||||
const label len = list.size();
|
||||
|
||||
if (os.format() == IOstream::BINARY && is_contiguous<T>::value)
|
||||
if (os.format() == IOstreamOption::BINARY && is_contiguous<T>::value)
|
||||
{
|
||||
// Binary and contiguous
|
||||
|
||||
@ -211,7 +211,7 @@ Foam::Istream& Foam::UList<T>::readList(Istream& is)
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
if (is.format() == IOstream::BINARY && is_contiguous<T>::value)
|
||||
if (is.format() == IOstreamOption::BINARY && is_contiguous<T>::value)
|
||||
{
|
||||
// Binary and contiguous
|
||||
|
||||
|
||||
@ -199,7 +199,7 @@ bool Foam::CompactIOField<T, BaseType>::writeObject
|
||||
const bool valid
|
||||
) const
|
||||
{
|
||||
if (streamOpt.format() == IOstream::ASCII)
|
||||
if (streamOpt.format() == IOstreamOption::ASCII)
|
||||
{
|
||||
// Change type to be non-compact format type
|
||||
const word oldTypeName(typeName);
|
||||
@ -282,8 +282,8 @@ Foam::Ostream& Foam::operator<<
|
||||
const Foam::CompactIOField<T, BaseType>& L
|
||||
)
|
||||
{
|
||||
// Keep ascii writing same.
|
||||
if (os.format() == IOstream::ASCII)
|
||||
// Keep ASCII writing same
|
||||
if (os.format() == IOstreamOption::ASCII)
|
||||
{
|
||||
os << static_cast<const Field<T>&>(L);
|
||||
}
|
||||
|
||||
@ -174,11 +174,11 @@ bool Foam::CompactIOList<T, BaseType>::writeObject
|
||||
{
|
||||
if
|
||||
(
|
||||
streamOpt.format() == IOstream::BINARY
|
||||
streamOpt.format() == IOstreamOption::BINARY
|
||||
&& overflows()
|
||||
)
|
||||
{
|
||||
streamOpt.format(IOstream::ASCII);
|
||||
streamOpt.format(IOstreamOption::ASCII);
|
||||
|
||||
WarningInFunction
|
||||
<< "Overall number of elements of CompactIOList of size "
|
||||
@ -186,7 +186,7 @@ bool Foam::CompactIOList<T, BaseType>::writeObject
|
||||
<< nl << " Switching to ascii writing" << endl;
|
||||
}
|
||||
|
||||
if (streamOpt.format() == IOstream::ASCII)
|
||||
if (streamOpt.format() == IOstreamOption::ASCII)
|
||||
{
|
||||
// Change type to be non-compact format type
|
||||
const word oldTypeName(typeName);
|
||||
@ -264,8 +264,8 @@ Foam::Ostream& Foam::operator<<
|
||||
const Foam::CompactIOList<T, BaseType>& L
|
||||
)
|
||||
{
|
||||
// Keep ascii writing same.
|
||||
if (os.format() == IOstream::ASCII)
|
||||
// Keep ASCII writing same
|
||||
if (os.format() == IOstreamOption::ASCII)
|
||||
{
|
||||
os << static_cast<const List<T>&>(L);
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -38,7 +38,7 @@ Foam::GlobalIOField<Type>::GlobalIOField(const IOobject& io)
|
||||
// Check for MUST_READ_IF_MODIFIED
|
||||
warnNoRereading<GlobalIOField<Type>>();
|
||||
|
||||
readHeaderOk(IOstream::BINARY, typeName);
|
||||
readHeaderOk(IOstreamOption::BINARY, typeName);
|
||||
}
|
||||
|
||||
|
||||
@ -50,7 +50,7 @@ Foam::GlobalIOField<Type>::GlobalIOField(const IOobject& io, const label size)
|
||||
// Check for MUST_READ_IF_MODIFIED
|
||||
warnNoRereading<GlobalIOField<Type>>();
|
||||
|
||||
if (!readHeaderOk(IOstream::BINARY, typeName))
|
||||
if (!readHeaderOk(IOstreamOption::BINARY, typeName))
|
||||
{
|
||||
Field<Type>::setSize(size);
|
||||
}
|
||||
@ -69,7 +69,7 @@ Foam::GlobalIOField<Type>::GlobalIOField
|
||||
// Check for MUST_READ_IF_MODIFIED
|
||||
warnNoRereading<GlobalIOField<Type>>();
|
||||
|
||||
if (!readHeaderOk(IOstream::BINARY, typeName))
|
||||
if (!readHeaderOk(IOstreamOption::BINARY, typeName))
|
||||
{
|
||||
Field<Type>::operator=(content);
|
||||
}
|
||||
@ -90,7 +90,7 @@ Foam::GlobalIOField<Type>::GlobalIOField
|
||||
|
||||
Field<Type>::transfer(content);
|
||||
|
||||
readHeaderOk(IOstream::BINARY, typeName);
|
||||
readHeaderOk(IOstreamOption::BINARY, typeName);
|
||||
}
|
||||
|
||||
|
||||
@ -113,7 +113,7 @@ Foam::GlobalIOField<Type>::GlobalIOField
|
||||
Field<Type>::transfer(tfld.ref());
|
||||
}
|
||||
|
||||
if (!readHeaderOk(IOstream::BINARY, typeName))
|
||||
if (!readHeaderOk(IOstreamOption::BINARY, typeName))
|
||||
{
|
||||
Field<Type>::operator=(tfld());
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ Foam::GlobalIOList<Type>::GlobalIOList(const IOobject& io)
|
||||
// Check for MUST_READ_IF_MODIFIED
|
||||
warnNoRereading<GlobalIOList<Type>>();
|
||||
|
||||
readHeaderOk(IOstream::BINARY, typeName);
|
||||
readHeaderOk(IOstreamOption::BINARY, typeName);
|
||||
}
|
||||
|
||||
|
||||
@ -50,7 +50,7 @@ Foam::GlobalIOList<Type>::GlobalIOList(const IOobject& io, Foam::zero)
|
||||
// Check for MUST_READ_IF_MODIFIED
|
||||
warnNoRereading<GlobalIOList<Type>>();
|
||||
|
||||
readHeaderOk(IOstream::BINARY, typeName);
|
||||
readHeaderOk(IOstreamOption::BINARY, typeName);
|
||||
}
|
||||
|
||||
|
||||
@ -62,7 +62,7 @@ Foam::GlobalIOList<Type>::GlobalIOList(const IOobject& io, const label len)
|
||||
// Check for MUST_READ_IF_MODIFIED
|
||||
warnNoRereading<GlobalIOList<Type>>();
|
||||
|
||||
if (!readHeaderOk(IOstream::BINARY, typeName))
|
||||
if (!readHeaderOk(IOstreamOption::BINARY, typeName))
|
||||
{
|
||||
List<Type>::resize(len);
|
||||
}
|
||||
@ -81,7 +81,7 @@ Foam::GlobalIOList<Type>::GlobalIOList
|
||||
// Check for MUST_READ_IF_MODIFIED
|
||||
warnNoRereading<GlobalIOList<Type>>();
|
||||
|
||||
if (!readHeaderOk(IOstream::BINARY, typeName))
|
||||
if (!readHeaderOk(IOstreamOption::BINARY, typeName))
|
||||
{
|
||||
List<Type>::operator=(content);
|
||||
}
|
||||
@ -102,7 +102,7 @@ Foam::GlobalIOList<Type>::GlobalIOList
|
||||
|
||||
List<Type>::transfer(content);
|
||||
|
||||
readHeaderOk(IOstream::BINARY, typeName);
|
||||
readHeaderOk(IOstreamOption::BINARY, typeName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
Copyright (C) 2021-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -62,7 +62,7 @@ Foam::IOdictionary::IOdictionary
|
||||
:
|
||||
baseIOdictionary(io, fallback)
|
||||
{
|
||||
if (!readHeaderOk(IOstream::ASCII, wantedType) && fallback)
|
||||
if (!readHeaderOk(IOstreamOption::ASCII, wantedType) && fallback)
|
||||
{
|
||||
dictionary::operator=(*fallback);
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
Copyright (C) 2021-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -59,7 +59,7 @@ Foam::localIOdictionary::localIOdictionary
|
||||
:
|
||||
baseIOdictionary(io, fallback)
|
||||
{
|
||||
if (!readHeaderOk(IOstream::ASCII, wantedType) && fallback)
|
||||
if (!readHeaderOk(IOstreamOption::ASCII, wantedType) && fallback)
|
||||
{
|
||||
dictionary::operator=(*fallback);
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ Foam::unwatchedIOdictionary::unwatchedIOdictionary
|
||||
:
|
||||
baseIOdictionary(io, fallback)
|
||||
{
|
||||
if (!readHeaderOk(IOstream::ASCII, wantedType) && fallback)
|
||||
if (!readHeaderOk(IOstreamOption::ASCII, wantedType) && fallback)
|
||||
{
|
||||
dictionary::operator=(*fallback);
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -34,6 +34,7 @@ template<class Type>
|
||||
Foam::rawIOField<Type>::rawIOField(const IOobject& io, const bool readAverage)
|
||||
:
|
||||
regIOobject(io),
|
||||
hasAverage_(false),
|
||||
average_(Zero)
|
||||
{
|
||||
// Check for MUST_READ_IF_MODIFIED
|
||||
@ -61,15 +62,13 @@ Foam::rawIOField<Type>::rawIOField(const IOobject& io, const bool readAverage)
|
||||
{
|
||||
haveFile = true;
|
||||
|
||||
ISstream& is = isPtr();
|
||||
auto& is = *isPtr;
|
||||
|
||||
const token firstToken(is);
|
||||
|
||||
headerOk = is.good() && firstToken.isWord("FoamFile");
|
||||
}
|
||||
|
||||
isPtr.clear();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "rawIOField : object:" << io.name()
|
||||
@ -90,18 +89,31 @@ Foam::rawIOField<Type>::rawIOField(const IOobject& io, const bool readAverage)
|
||||
is >> static_cast<Field<Type>&>(*this);
|
||||
if (readAverage)
|
||||
{
|
||||
average_ = pTraits<Type>(is);
|
||||
hasAverage_ = true;
|
||||
is >> average_;
|
||||
}
|
||||
close();
|
||||
}
|
||||
}
|
||||
else if (haveFile)
|
||||
{
|
||||
// Failed reading - fall back to IFstream
|
||||
// Failed reading header - fall back to IFstream
|
||||
autoPtr<ISstream> isPtr(fileHandler().NewIFstream(io.objectPath()));
|
||||
|
||||
if (!isPtr || !isPtr->good())
|
||||
if (isPtr && isPtr->good())
|
||||
{
|
||||
auto& is = *isPtr;
|
||||
|
||||
is >> static_cast<Field<Type>&>(*this);
|
||||
if (readAverage)
|
||||
{
|
||||
hasAverage_ = true;
|
||||
is >> average_;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Error if missing and MUST_READ or MUST_READ_IF_MODIFIED
|
||||
if (io.readOpt() != IOobject::READ_IF_PRESENT)
|
||||
{
|
||||
FatalIOErrorInFunction(*isPtr)
|
||||
@ -109,16 +121,6 @@ Foam::rawIOField<Type>::rawIOField(const IOobject& io, const bool readAverage)
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ISstream& is = isPtr();
|
||||
|
||||
is >> static_cast<Field<Type>&>(*this);
|
||||
if (readAverage)
|
||||
{
|
||||
average_ = pTraits<Type>(is);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (debug)
|
||||
@ -132,11 +134,19 @@ Foam::rawIOField<Type>::rawIOField(const IOobject& io, const bool readAverage)
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::rawIOField<Type>::setAverage(const Type& val)
|
||||
{
|
||||
hasAverage_ = true;
|
||||
average_ = val;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
bool Foam::rawIOField<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
os << static_cast<const Field<Type>&>(*this);
|
||||
if (average_ != pTraits<Type>::zero)
|
||||
if (hasAverage_)
|
||||
{
|
||||
os << token::NL << average_;
|
||||
}
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -35,8 +35,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef rawIOField_H
|
||||
#define rawIOField_H
|
||||
#ifndef Foam_rawIOField_H
|
||||
#define Foam_rawIOField_H
|
||||
|
||||
#include "IOField.H"
|
||||
|
||||
@ -57,7 +57,10 @@ class rawIOField
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- The average of the field (Zero if not used)
|
||||
//- Has an average value
|
||||
bool hasAverage_;
|
||||
|
||||
//- The average for the field (zero if not used)
|
||||
Type average_;
|
||||
|
||||
|
||||
@ -72,7 +75,7 @@ public:
|
||||
rawIOField(const rawIOField&) = default;
|
||||
|
||||
//- Construct from IOobject
|
||||
explicit rawIOField(const IOobject& io, const bool readAverage);
|
||||
explicit rawIOField(const IOobject& io, const bool readAverage=false);
|
||||
|
||||
|
||||
//- Destructor
|
||||
@ -81,11 +84,21 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
const Type& average() const
|
||||
//- Has an average value
|
||||
bool hasAverage() const noexcept
|
||||
{
|
||||
return hasAverage_;
|
||||
}
|
||||
|
||||
//- The average value (if any)
|
||||
const Type& average() const noexcept
|
||||
{
|
||||
return average_;
|
||||
}
|
||||
|
||||
//- Set an average value
|
||||
void setAverage(const Type& val);
|
||||
|
||||
bool writeData(Ostream& os) const;
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -32,8 +32,8 @@ Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOmanip_H
|
||||
#define IOmanip_H
|
||||
#ifndef Foam_IOmanip_H
|
||||
#define Foam_IOmanip_H
|
||||
|
||||
#include "Istream.H"
|
||||
#include "Ostream.H"
|
||||
@ -178,21 +178,21 @@ inline Omanip<char> setfill(char fillch)
|
||||
}
|
||||
|
||||
|
||||
inline Omanip<IOstream::streamFormat> setformat
|
||||
inline Omanip<IOstreamOption::streamFormat> setformat
|
||||
(
|
||||
const IOstream::streamFormat fmt
|
||||
const IOstreamOption::streamFormat fmt
|
||||
)
|
||||
{
|
||||
return Omanip<IOstream::streamFormat>(&IOstream::format, fmt);
|
||||
return Omanip<IOstreamOption::streamFormat>(&IOstreamOption::format, fmt);
|
||||
}
|
||||
|
||||
|
||||
inline Omanip<IOstream::versionNumber> setversion
|
||||
inline Omanip<IOstreamOption::versionNumber> setversion
|
||||
(
|
||||
const IOstream::versionNumber ver
|
||||
const IOstreamOption::versionNumber ver
|
||||
)
|
||||
{
|
||||
return Omanip<IOstream::versionNumber>(&IOstream::version, ver);
|
||||
return Omanip<IOstreamOption::versionNumber>(&IOstreamOption::version, ver);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -118,22 +118,22 @@ void Foam::IOstream::print(Ostream& os) const
|
||||
|
||||
void Foam::IOstream::print(Ostream& os, const int streamState) const
|
||||
{
|
||||
if (streamState == ios_base::goodbit)
|
||||
if (streamState == std::ios_base::goodbit)
|
||||
{
|
||||
os << "ios_base::goodbit set : the last operation on stream succeeded"
|
||||
<< endl;
|
||||
}
|
||||
else if (streamState & ios_base::badbit)
|
||||
else if (streamState & std::ios_base::badbit)
|
||||
{
|
||||
os << "ios_base::badbit set : characters possibly lost"
|
||||
<< endl;
|
||||
}
|
||||
else if (streamState & ios_base::failbit)
|
||||
else if (streamState & std::ios_base::failbit)
|
||||
{
|
||||
os << "ios_base::failbit set : some type of formatting error"
|
||||
<< endl;
|
||||
}
|
||||
else if (streamState & ios_base::eofbit)
|
||||
else if (streamState & std::ios_base::eofbit)
|
||||
{
|
||||
os << "ios_base::eofbit set : at end of stream"
|
||||
<< endl;
|
||||
|
||||
@ -60,9 +60,9 @@ using std::ios_base;
|
||||
using std::istream;
|
||||
using std::ostream;
|
||||
|
||||
using std::cerr;
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
using std::cerr;
|
||||
|
||||
// Additional constructors and methods (as per v2012 and earlier)
|
||||
#define Foam_IOstream_extras
|
||||
@ -147,7 +147,7 @@ protected:
|
||||
//- Set stream state to be good
|
||||
void setGood() noexcept
|
||||
{
|
||||
ioState_ = std::ios_base::iostate(0);
|
||||
ioState_ = std::ios_base::goodbit;
|
||||
}
|
||||
|
||||
|
||||
@ -169,7 +169,7 @@ public:
|
||||
explicit IOstream(IOstreamOption streamOpt = IOstreamOption())
|
||||
:
|
||||
IOstreamOption(streamOpt),
|
||||
ioState_(std::ios_base::iostate(0)),
|
||||
ioState_(std::ios_base::goodbit),
|
||||
openClosed_(CLOSED),
|
||||
sizeofLabel_(static_cast<unsigned char>(sizeof(label))),
|
||||
sizeofScalar_(static_cast<unsigned char>(sizeof(scalar))),
|
||||
@ -233,7 +233,7 @@ public:
|
||||
//- True if next operation might succeed
|
||||
bool good() const noexcept
|
||||
{
|
||||
return ioState_ == 0;
|
||||
return ioState_ == 0; // == goodbit
|
||||
}
|
||||
|
||||
//- True if end of input seen
|
||||
@ -331,7 +331,7 @@ public:
|
||||
// \return the previous value
|
||||
label lineNumber(const label num) noexcept
|
||||
{
|
||||
const label old(lineNumber_);
|
||||
label old(lineNumber_);
|
||||
lineNumber_ = num;
|
||||
return old;
|
||||
}
|
||||
@ -440,31 +440,31 @@ inline IOstream& operator<<(IOstream& io, IOstreamManip f)
|
||||
|
||||
inline IOstream& dec(IOstream& io)
|
||||
{
|
||||
io.setf(ios_base::dec, ios_base::dec|ios_base::hex|ios_base::oct);
|
||||
io.setf(std::ios_base::dec, std::ios_base::basefield);
|
||||
return io;
|
||||
}
|
||||
|
||||
inline IOstream& hex(IOstream& io)
|
||||
{
|
||||
io.setf(ios_base::hex, ios_base::dec|ios_base::hex|ios_base::oct);
|
||||
io.setf(std::ios_base::hex, std::ios_base::basefield);
|
||||
return io;
|
||||
}
|
||||
|
||||
inline IOstream& oct(IOstream& io)
|
||||
{
|
||||
io.setf(ios_base::oct, ios_base::dec|ios_base::hex|ios_base::oct);
|
||||
io.setf(std::ios_base::oct, std::ios_base::basefield);
|
||||
return io;
|
||||
}
|
||||
|
||||
inline IOstream& fixed(IOstream& io)
|
||||
{
|
||||
io.setf(ios_base::fixed, ios_base::floatfield);
|
||||
io.setf(std::ios_base::fixed, std::ios_base::floatfield);
|
||||
return io;
|
||||
}
|
||||
|
||||
inline IOstream& scientific(IOstream& io)
|
||||
{
|
||||
io.setf(ios_base::scientific, ios_base::floatfield);
|
||||
io.setf(std::ios_base::scientific, std::ios_base::floatfield);
|
||||
return io;
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -156,11 +156,11 @@ public:
|
||||
//- Read a label
|
||||
virtual Istream& read(label&) = 0;
|
||||
|
||||
//- Read a floatScalar
|
||||
virtual Istream& read(floatScalar&) = 0;
|
||||
//- Read a float
|
||||
virtual Istream& read(float&) = 0;
|
||||
|
||||
//- Read a doubleScalar
|
||||
virtual Istream& read(doubleScalar&) = 0;
|
||||
//- Read a double
|
||||
virtual Istream& read(double&) = 0;
|
||||
|
||||
//- Read binary block
|
||||
virtual Istream& read(char*, std::streamsize) = 0;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -147,11 +147,11 @@ public:
|
||||
//- Write int64_t
|
||||
virtual Ostream& write(const int64_t val) = 0;
|
||||
|
||||
//- Write floatScalar
|
||||
virtual Ostream& write(const floatScalar val) = 0;
|
||||
//- Write float
|
||||
virtual Ostream& write(const float val) = 0;
|
||||
|
||||
//- Write doubleScalar
|
||||
virtual Ostream& write(const doubleScalar val) = 0;
|
||||
//- Write double
|
||||
virtual Ostream& write(const double val) = 0;
|
||||
|
||||
//- Write binary block.
|
||||
virtual Ostream& write(const char* data, std::streamsize count) = 0;
|
||||
|
||||
@ -156,11 +156,11 @@ public:
|
||||
//- Read a label
|
||||
Istream& read(label& val);
|
||||
|
||||
//- Read a floatScalar
|
||||
Istream& read(floatScalar& val);
|
||||
//- Read a float
|
||||
Istream& read(float& val);
|
||||
|
||||
//- Read a doubleScalar
|
||||
Istream& read(doubleScalar& val);
|
||||
//- Read a double
|
||||
Istream& read(double& val);
|
||||
|
||||
//- Read binary block with 8-byte alignment.
|
||||
Istream& read(char* data, std::streamsize count);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -49,11 +49,11 @@ inline static void processFlags(Istream& is, int flagMask)
|
||||
{
|
||||
if ((flagMask & token::ASCII))
|
||||
{
|
||||
is.format(IOstream::ASCII);
|
||||
is.format(IOstreamOption::ASCII);
|
||||
}
|
||||
else if ((flagMask & token::BINARY))
|
||||
{
|
||||
is.format(IOstream::BINARY);
|
||||
is.format(IOstreamOption::BINARY);
|
||||
}
|
||||
}
|
||||
|
||||
@ -359,7 +359,7 @@ Foam::Istream& Foam::UIPstreamBase::read(token& t)
|
||||
// Float
|
||||
case token::tokenType::FLOAT :
|
||||
{
|
||||
floatScalar val;
|
||||
float val;
|
||||
if (read(val))
|
||||
{
|
||||
t = val;
|
||||
@ -374,7 +374,7 @@ Foam::Istream& Foam::UIPstreamBase::read(token& t)
|
||||
// Double
|
||||
case token::tokenType::DOUBLE :
|
||||
{
|
||||
doubleScalar val;
|
||||
double val;
|
||||
if (read(val))
|
||||
{
|
||||
t = val;
|
||||
@ -432,14 +432,14 @@ Foam::Istream& Foam::UIPstreamBase::read(label& val)
|
||||
}
|
||||
|
||||
|
||||
Foam::Istream& Foam::UIPstreamBase::read(floatScalar& val)
|
||||
Foam::Istream& Foam::UIPstreamBase::read(float& val)
|
||||
{
|
||||
readFromBuffer(val);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Foam::Istream& Foam::UIPstreamBase::read(doubleScalar& val)
|
||||
Foam::Istream& Foam::UIPstreamBase::read(double& val)
|
||||
{
|
||||
readFromBuffer(val);
|
||||
return *this;
|
||||
|
||||
@ -173,11 +173,11 @@ public:
|
||||
//- Write int64_t as a label
|
||||
virtual Ostream& write(const int64_t val);
|
||||
|
||||
//- Write floatScalar
|
||||
virtual Ostream& write(const floatScalar val);
|
||||
//- Write float
|
||||
virtual Ostream& write(const float val);
|
||||
|
||||
//- Write doubleScalar
|
||||
virtual Ostream& write(const doubleScalar val);
|
||||
//- Write double
|
||||
virtual Ostream& write(const double val);
|
||||
|
||||
//- Write binary block with 8-byte alignment.
|
||||
virtual Ostream& write(const char* data, std::streamsize count);
|
||||
|
||||
@ -304,7 +304,7 @@ Foam::Ostream& Foam::UOPstreamBase::write(const int64_t val)
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::UOPstreamBase::write(const floatScalar val)
|
||||
Foam::Ostream& Foam::UOPstreamBase::write(const float val)
|
||||
{
|
||||
putChar(token::tokenType::FLOAT);
|
||||
writeToBuffer(val);
|
||||
@ -312,7 +312,7 @@ Foam::Ostream& Foam::UOPstreamBase::write(const floatScalar val)
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::UOPstreamBase::write(const doubleScalar val)
|
||||
Foam::Ostream& Foam::UOPstreamBase::write(const double val)
|
||||
{
|
||||
putChar(token::tokenType::DOUBLE);
|
||||
writeToBuffer(val);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -1001,7 +1001,7 @@ Foam::Istream& Foam::ISstream::read(label& val)
|
||||
}
|
||||
|
||||
|
||||
Foam::Istream& Foam::ISstream::read(floatScalar& val)
|
||||
Foam::Istream& Foam::ISstream::read(float& val)
|
||||
{
|
||||
is_ >> val;
|
||||
setState(is_.rdstate());
|
||||
@ -1009,7 +1009,7 @@ Foam::Istream& Foam::ISstream::read(floatScalar& val)
|
||||
}
|
||||
|
||||
|
||||
Foam::Istream& Foam::ISstream::read(doubleScalar& val)
|
||||
Foam::Istream& Foam::ISstream::read(double& val)
|
||||
{
|
||||
is_ >> val;
|
||||
setState(is_.rdstate());
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -36,8 +36,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ISstream_H
|
||||
#define ISstream_H
|
||||
#ifndef Foam_ISstream_H
|
||||
#define Foam_ISstream_H
|
||||
|
||||
#include "Istream.H"
|
||||
#include "fileName.H"
|
||||
@ -183,11 +183,11 @@ public:
|
||||
//- Read a label
|
||||
virtual Istream& read(label& val);
|
||||
|
||||
//- Read a floatScalar
|
||||
virtual Istream& read(floatScalar& val);
|
||||
//- Read a float
|
||||
virtual Istream& read(float& val);
|
||||
|
||||
//- Read a doubleScalar
|
||||
virtual Istream& read(doubleScalar& val);
|
||||
//- Read a double
|
||||
virtual Istream& read(double& val);
|
||||
|
||||
//- Read binary block
|
||||
virtual Istream& read(char* buf, std::streamsize count);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -196,7 +196,7 @@ Foam::Ostream& Foam::OSstream::write(const int64_t val)
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::OSstream::write(const floatScalar val)
|
||||
Foam::Ostream& Foam::OSstream::write(const float val)
|
||||
{
|
||||
os_ << val;
|
||||
setState(os_.rdstate());
|
||||
@ -204,7 +204,7 @@ Foam::Ostream& Foam::OSstream::write(const floatScalar val)
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::OSstream::write(const doubleScalar val)
|
||||
Foam::Ostream& Foam::OSstream::write(const double val)
|
||||
{
|
||||
os_ << val;
|
||||
setState(os_.rdstate());
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -36,8 +36,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef OSstream_H
|
||||
#define OSstream_H
|
||||
#ifndef Foam_OSstream_H
|
||||
#define Foam_OSstream_H
|
||||
|
||||
#include "Ostream.H"
|
||||
#include "fileName.H"
|
||||
@ -155,11 +155,11 @@ public:
|
||||
//- Write int64_t
|
||||
virtual Ostream& write(const int64_t val);
|
||||
|
||||
//- Write floatScalar
|
||||
virtual Ostream& write(const floatScalar val);
|
||||
//- Write float
|
||||
virtual Ostream& write(const float val);
|
||||
|
||||
//- Write doubleScalar
|
||||
virtual Ostream& write(const doubleScalar val);
|
||||
//- Write double
|
||||
virtual Ostream& write(const double val);
|
||||
|
||||
//- Write binary block
|
||||
virtual Ostream& write(const char* data, std::streamsize count);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -140,14 +140,14 @@ Foam::Ostream& Foam::prefixOSstream::write(const int64_t val)
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::prefixOSstream::write(const floatScalar val)
|
||||
Foam::Ostream& Foam::prefixOSstream::write(const float val)
|
||||
{
|
||||
checkWritePrefix();
|
||||
return OSstream::write(val);
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::prefixOSstream::write(const doubleScalar val)
|
||||
Foam::Ostream& Foam::prefixOSstream::write(const double val)
|
||||
{
|
||||
checkWritePrefix();
|
||||
return OSstream::write(val);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -38,8 +38,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef prefixOSstream_H
|
||||
#define prefixOSstream_H
|
||||
#ifndef Foam_prefixOSstream_H
|
||||
#define Foam_prefixOSstream_H
|
||||
|
||||
#include "OSstream.H"
|
||||
|
||||
@ -143,11 +143,11 @@ public:
|
||||
//- Write int64_t
|
||||
virtual Ostream& write(const int64_t val);
|
||||
|
||||
//- Write floatScalar
|
||||
virtual Ostream& write(const floatScalar val);
|
||||
//- Write float
|
||||
virtual Ostream& write(const float val);
|
||||
|
||||
//- Write doubleScalar
|
||||
virtual Ostream& write(const doubleScalar val);
|
||||
//- Write double
|
||||
virtual Ostream& write(const double val);
|
||||
|
||||
//- Write binary block
|
||||
virtual Ostream& write(const char* buf, std::streamsize count);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -530,14 +530,14 @@ Foam::Istream& Foam::ITstream::read(label&)
|
||||
}
|
||||
|
||||
|
||||
Foam::Istream& Foam::ITstream::read(floatScalar&)
|
||||
Foam::Istream& Foam::ITstream::read(float&)
|
||||
{
|
||||
NotImplemented;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Foam::Istream& Foam::ITstream::read(doubleScalar&)
|
||||
Foam::Istream& Foam::ITstream::read(double&)
|
||||
{
|
||||
NotImplemented;
|
||||
return *this;
|
||||
|
||||
@ -304,11 +304,11 @@ public:
|
||||
//- Read a label
|
||||
virtual Istream& read(label&);
|
||||
|
||||
//- Read a floatScalar
|
||||
virtual Istream& read(floatScalar&);
|
||||
//- Read a float
|
||||
virtual Istream& read(float&);
|
||||
|
||||
//- Read a doubleScalar
|
||||
virtual Istream& read(doubleScalar&);
|
||||
//- Read a double
|
||||
virtual Istream& read(double&);
|
||||
|
||||
//- Read binary block
|
||||
// \note Not implemented
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -125,7 +125,7 @@ Foam::Ostream& Foam::OTstream::write(const int64_t val)
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::OTstream::write(const floatScalar val)
|
||||
Foam::Ostream& Foam::OTstream::write(const float val)
|
||||
{
|
||||
append(token(val)); // tokenType::FLOAT
|
||||
|
||||
@ -133,7 +133,7 @@ Foam::Ostream& Foam::OTstream::write(const floatScalar val)
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::OTstream::write(const doubleScalar val)
|
||||
Foam::Ostream& Foam::OTstream::write(const double val)
|
||||
{
|
||||
append(token(val)); // tokenType::DOUBLE
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -38,8 +38,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef OTstream_H
|
||||
#define OTstream_H
|
||||
#ifndef Foam_OTstream_H
|
||||
#define Foam_OTstream_H
|
||||
|
||||
#include "token.H"
|
||||
#include "Ostream.H"
|
||||
@ -146,11 +146,11 @@ public:
|
||||
//- Write int64_t as a label
|
||||
virtual Ostream& write(const int64_t val);
|
||||
|
||||
//- Write floatScalar
|
||||
virtual Ostream& write(const floatScalar val);
|
||||
//- Write float
|
||||
virtual Ostream& write(const float val);
|
||||
|
||||
//- Write doubleScalar
|
||||
virtual Ostream& write(const doubleScalar val);
|
||||
//- Write double
|
||||
virtual Ostream& write(const double val);
|
||||
|
||||
//- Write binary block with 8-byte alignment.
|
||||
virtual Ostream& write(const char* data, std::streamsize count);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -40,8 +40,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef dummyISstream_H
|
||||
#define dummyISstream_H
|
||||
#ifndef Foam_dummyISstream_H
|
||||
#define Foam_dummyISstream_H
|
||||
|
||||
#include "StringStream.H"
|
||||
|
||||
@ -108,15 +108,15 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
//- Read a floatScalar
|
||||
virtual Istream& read(floatScalar&)
|
||||
//- Read a float
|
||||
virtual Istream& read(float&)
|
||||
{
|
||||
NotImplemented;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//- Read a doubleScalar
|
||||
virtual Istream& read(doubleScalar&)
|
||||
//- Read a double
|
||||
virtual Istream& read(double&)
|
||||
{
|
||||
NotImplemented;
|
||||
return *this;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -307,8 +307,8 @@ private:
|
||||
int flagVal; // bitmask - stored as int, not enum
|
||||
punctuationToken punctuationVal;
|
||||
label labelVal;
|
||||
floatScalar floatVal;
|
||||
doubleScalar doubleVal;
|
||||
float floatVal;
|
||||
double doubleVal;
|
||||
|
||||
// Pointers
|
||||
word* wordPtr;
|
||||
@ -365,10 +365,10 @@ public:
|
||||
inline explicit token(const label val, label lineNum=0) noexcept;
|
||||
|
||||
//- Construct float token
|
||||
inline explicit token(const floatScalar val, label lineNum=0) noexcept;
|
||||
inline explicit token(const float val, label lineNum=0) noexcept;
|
||||
|
||||
//- Construct double token
|
||||
inline explicit token(const doubleScalar val, label lineNum=0) noexcept;
|
||||
inline explicit token(const double val, label lineNum=0) noexcept;
|
||||
|
||||
//- Copy construct word token
|
||||
inline explicit token(const word& w, label lineNum=0);
|
||||
@ -531,11 +531,11 @@ public:
|
||||
|
||||
//- Return float value.
|
||||
// Report FatalIOError and return \b 0 if token is not FLOAT
|
||||
inline floatScalar floatToken() const;
|
||||
inline float floatToken() const;
|
||||
|
||||
//- Return double value.
|
||||
// Report FatalIOError and return \b 0 if token is not DOUBLE
|
||||
inline doubleScalar doubleToken() const;
|
||||
inline double doubleToken() const;
|
||||
|
||||
//- Return float or double value.
|
||||
// Report FatalIOError and return \b 0 if token is not a
|
||||
@ -607,10 +607,10 @@ public:
|
||||
inline void operator=(const label val);
|
||||
|
||||
//- Copy assign from float
|
||||
inline void operator=(const floatScalar val);
|
||||
inline void operator=(const float val);
|
||||
|
||||
//- Copy assign from double
|
||||
inline void operator=(const doubleScalar val);
|
||||
inline void operator=(const double val);
|
||||
|
||||
//- Copy assign from word content
|
||||
inline void operator=(const word& w);
|
||||
@ -636,8 +636,8 @@ public:
|
||||
inline bool operator==(const token& tok) const;
|
||||
inline bool operator==(const punctuationToken p) const noexcept;
|
||||
inline bool operator==(const label val) const noexcept;
|
||||
inline bool operator==(const floatScalar val) const noexcept;
|
||||
inline bool operator==(const doubleScalar val) const noexcept;
|
||||
inline bool operator==(const float val) const noexcept;
|
||||
inline bool operator==(const double val) const noexcept;
|
||||
inline bool operator==(const std::string& s) const;
|
||||
|
||||
|
||||
@ -646,8 +646,8 @@ public:
|
||||
inline bool operator!=(const token& tok) const;
|
||||
inline bool operator!=(const punctuationToken p) const noexcept;
|
||||
inline bool operator!=(const label val) const noexcept;
|
||||
inline bool operator!=(const floatScalar val) const noexcept;
|
||||
inline bool operator!=(const doubleScalar val) const noexcept;
|
||||
inline bool operator!=(const float val) const noexcept;
|
||||
inline bool operator!=(const double val) const noexcept;
|
||||
inline bool operator!=(const std::string& s) const;
|
||||
|
||||
|
||||
@ -677,11 +677,11 @@ public:
|
||||
|
||||
//- Return float value.
|
||||
// \deprecated(2020-01) - floatToken()
|
||||
floatScalar floatScalarToken() const { return floatToken(); }
|
||||
float floatScalarToken() const { return floatToken(); }
|
||||
|
||||
//- Return double value.
|
||||
// \deprecated(2020-01) - doubleToken()
|
||||
doubleScalar doubleScalarToken() const { return doubleToken(); }
|
||||
double doubleScalarToken() const { return doubleToken(); }
|
||||
|
||||
//- Deprecated(2017-11) transfer word pointer to the token
|
||||
// \deprecated(2017-11) - use move assign from word
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -174,7 +174,7 @@ inline Foam::token::token(const label val, label lineNum) noexcept
|
||||
}
|
||||
|
||||
|
||||
inline Foam::token::token(const floatScalar val, label lineNum) noexcept
|
||||
inline Foam::token::token(const float val, label lineNum) noexcept
|
||||
:
|
||||
data_(),
|
||||
type_(tokenType::FLOAT),
|
||||
@ -184,7 +184,7 @@ inline Foam::token::token(const floatScalar val, label lineNum) noexcept
|
||||
}
|
||||
|
||||
|
||||
inline Foam::token::token(const doubleScalar val, label lineNum) noexcept
|
||||
inline Foam::token::token(const double val, label lineNum) noexcept
|
||||
:
|
||||
data_(),
|
||||
type_(tokenType::DOUBLE),
|
||||
@ -528,7 +528,7 @@ inline bool Foam::token::isFloat() const noexcept
|
||||
}
|
||||
|
||||
|
||||
inline Foam::floatScalar Foam::token::floatToken() const
|
||||
inline float Foam::token::floatToken() const
|
||||
{
|
||||
if (type_ == tokenType::FLOAT)
|
||||
{
|
||||
@ -546,7 +546,7 @@ inline bool Foam::token::isDouble() const noexcept
|
||||
}
|
||||
|
||||
|
||||
inline Foam::doubleScalar Foam::token::doubleToken() const
|
||||
inline double Foam::token::doubleToken() const
|
||||
{
|
||||
if (type_ == tokenType::DOUBLE)
|
||||
{
|
||||
@ -817,7 +817,7 @@ inline void Foam::token::operator=(const label val)
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::token::operator=(const floatScalar val)
|
||||
inline void Foam::token::operator=(const float val)
|
||||
{
|
||||
reset();
|
||||
type_ = tokenType::FLOAT;
|
||||
@ -825,7 +825,7 @@ inline void Foam::token::operator=(const floatScalar val)
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::token::operator=(const doubleScalar val)
|
||||
inline void Foam::token::operator=(const double val)
|
||||
{
|
||||
reset();
|
||||
type_ = tokenType::DOUBLE;
|
||||
@ -955,7 +955,7 @@ inline bool Foam::token::operator==(const label val) const noexcept
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::token::operator==(const floatScalar val) const noexcept
|
||||
inline bool Foam::token::operator==(const float val) const noexcept
|
||||
{
|
||||
return
|
||||
(
|
||||
@ -965,7 +965,7 @@ inline bool Foam::token::operator==(const floatScalar val) const noexcept
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::token::operator==(const doubleScalar val) const noexcept
|
||||
inline bool Foam::token::operator==(const double val) const noexcept
|
||||
{
|
||||
return
|
||||
(
|
||||
@ -993,13 +993,13 @@ inline bool Foam::token::operator!=(const label val) const noexcept
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::token::operator!=(const floatScalar val) const noexcept
|
||||
inline bool Foam::token::operator!=(const float val) const noexcept
|
||||
{
|
||||
return !operator==(val);
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::token::operator!=(const doubleScalar val) const noexcept
|
||||
inline bool Foam::token::operator!=(const double val) const noexcept
|
||||
{
|
||||
return !operator==(val);
|
||||
}
|
||||
|
||||
@ -459,7 +459,7 @@ Foam::Time::Time
|
||||
writeOnce_(false),
|
||||
sigWriteNow_(*this, true),
|
||||
sigStopAtWriteNow_(*this, true),
|
||||
writeStreamOption_(IOstream::ASCII),
|
||||
writeStreamOption_(IOstreamOption::ASCII),
|
||||
graphFormat_("raw"),
|
||||
runTimeModifiable_(false),
|
||||
functionObjects_(*this, false)
|
||||
@ -525,7 +525,7 @@ Foam::Time::Time
|
||||
writeOnce_(false),
|
||||
sigWriteNow_(*this, true),
|
||||
sigStopAtWriteNow_(*this, true),
|
||||
writeStreamOption_(IOstream::ASCII),
|
||||
writeStreamOption_(IOstreamOption::ASCII),
|
||||
graphFormat_("raw"),
|
||||
runTimeModifiable_(false),
|
||||
functionObjects_(*this, false)
|
||||
@ -619,7 +619,7 @@ Foam::Time::Time
|
||||
writeOnce_(false),
|
||||
sigWriteNow_(*this, true),
|
||||
sigStopAtWriteNow_(*this, true),
|
||||
writeStreamOption_(IOstream::ASCII),
|
||||
writeStreamOption_(IOstreamOption::ASCII),
|
||||
graphFormat_("raw"),
|
||||
runTimeModifiable_(false),
|
||||
functionObjects_(*this, false)
|
||||
@ -693,7 +693,7 @@ Foam::Time::Time
|
||||
purgeWrite_(0),
|
||||
subCycling_(0),
|
||||
writeOnce_(false),
|
||||
writeStreamOption_(IOstream::ASCII),
|
||||
writeStreamOption_(IOstreamOption::ASCII),
|
||||
graphFormat_("raw"),
|
||||
runTimeModifiable_(false),
|
||||
functionObjects_(*this, false)
|
||||
|
||||
@ -385,19 +385,19 @@ public:
|
||||
}
|
||||
|
||||
//- The write stream format
|
||||
IOstream::streamFormat writeFormat() const
|
||||
IOstreamOption::streamFormat writeFormat() const
|
||||
{
|
||||
return writeStreamOption_.format();
|
||||
}
|
||||
|
||||
//- The write stream compression
|
||||
IOstream::compressionType writeCompression() const
|
||||
IOstreamOption::compressionType writeCompression() const
|
||||
{
|
||||
return writeStreamOption_.compression();
|
||||
}
|
||||
|
||||
//- The write stream version
|
||||
IOstream::versionNumber writeVersion() const
|
||||
IOstreamOption::versionNumber writeVersion() const
|
||||
{
|
||||
return writeStreamOption_.version();
|
||||
}
|
||||
|
||||
@ -116,28 +116,17 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- The value (const access)
|
||||
scalar value() const noexcept
|
||||
{
|
||||
return val_;
|
||||
}
|
||||
scalar value() const noexcept { return val_; }
|
||||
|
||||
//- The value (non-const access)
|
||||
scalar& value() noexcept
|
||||
{
|
||||
return val_;
|
||||
}
|
||||
scalar& value() noexcept { return val_; }
|
||||
|
||||
//- The name/key (const access)
|
||||
const T& name() const noexcept
|
||||
{
|
||||
return key_;
|
||||
}
|
||||
const T& name() const noexcept { return key_; }
|
||||
|
||||
//- The name/key (non-const access)
|
||||
T& name() noexcept
|
||||
{
|
||||
return key_;
|
||||
}
|
||||
T& name() noexcept { return key_; }
|
||||
|
||||
|
||||
//- True if values are equal (includes SMALL for rounding)
|
||||
bool equal(scalar val) const noexcept
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -28,6 +28,8 @@ License
|
||||
|
||||
#include "instant.H"
|
||||
#include "Time.H"
|
||||
#include "Pair.H"
|
||||
#include "UList.H"
|
||||
#include <cstdlib> // std::atof
|
||||
#include <utility> // std::move
|
||||
|
||||
@ -36,6 +38,62 @@ License
|
||||
const char* const Foam::instant::typeName = "instant";
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
Foam::label Foam::instant::findStart
|
||||
(
|
||||
const UList<instant>& times,
|
||||
const scalar timeVal
|
||||
)
|
||||
{
|
||||
for (label i = 0; i < times.size(); ++i)
|
||||
{
|
||||
if (timeVal <= times[i].value())
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Foam::Pair<Foam::label> Foam::instant::findRange
|
||||
(
|
||||
const UList<instant>& times,
|
||||
const scalar timeVal,
|
||||
const label start
|
||||
)
|
||||
{
|
||||
Pair<label> range(start, -1); // lower/upper
|
||||
|
||||
for (label i = start+1; i < times.size(); ++i)
|
||||
{
|
||||
if (timeVal < times[i].value())
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
range.first() = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (range.first() < 0 || range.first() >= times.size())
|
||||
{
|
||||
// Invalid
|
||||
return Pair<label>(-1, -1);
|
||||
}
|
||||
|
||||
if (range.first() < times.size()-1)
|
||||
{
|
||||
// Upper part of range within bounds
|
||||
range.second() = range.first()+1;
|
||||
}
|
||||
|
||||
return range;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::instant::instant(scalar timeValue)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user