Compare commits
39 Commits
feature-co
...
feature-gm
| Author | SHA1 | Date | |
|---|---|---|---|
| fc20aa1c4d | |||
| 44f8550185 | |||
| ab1788ae33 | |||
| 578cb2b67c | |||
| 30d2e2d3cf | |||
| c07997d816 | |||
| 495fa6c577 | |||
| dfc9a8923a | |||
| ee895577ae | |||
| 9f032057b4 | |||
| 10b0c3cfca | |||
| 773548c283 | |||
| 9335b641f1 | |||
| ffc9894033 | |||
| 1406f9ec26 | |||
| b81fe70830 | |||
| bbde236be5 | |||
| 3b9176665f | |||
| 6a80d4de40 | |||
| 3f1d181b42 | |||
| 8d649d1737 | |||
| 21a84bdf91 | |||
| 1ad1957c41 | |||
| 4510067e63 | |||
| 8cf757daf0 | |||
| 6581c5792a | |||
| 03fb8f043e | |||
| 45ec64e6c8 | |||
| eb17ff1ea3 | |||
| a7538fab57 | |||
| 4fb85d1f76 | |||
| d9c73ae489 | |||
| e15d696a24 | |||
| dbfd1f90b1 | |||
| 883196981d | |||
| 3fed41547f | |||
| e22edc5dee | |||
| 0ef7589979 | |||
| e651d63566 |
@ -1,2 +1,2 @@
|
||||
api=2402
|
||||
patch=240220
|
||||
patch=240522
|
||||
|
||||
@ -188,8 +188,6 @@ int main(int argc, char *argv[])
|
||||
argList::addBoolOption("label", "Use label for tests (default)");
|
||||
argList::addBoolOption("ref", "Test writing by ref");
|
||||
|
||||
#include "addTimeOptions.H"
|
||||
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
#include "createPolyMesh.H"
|
||||
@ -280,7 +278,6 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
IOFieldRef<vector>(ioOutput, mesh.points()).write();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-OCountStream.C
|
||||
Test-OCountStream.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-OCountStream
|
||||
|
||||
@ -65,11 +65,11 @@ int main(int argc, char *argv[])
|
||||
|
||||
OCountStream cnt;
|
||||
OCharStream cstr;
|
||||
OStringStream str;
|
||||
OStringStream sstr;
|
||||
ocountstream plain;
|
||||
|
||||
generateOutput(cstr);
|
||||
generateOutput(str);
|
||||
generateOutput(sstr);
|
||||
generateOutput(cnt);
|
||||
generateOutput(plain);
|
||||
|
||||
@ -77,7 +77,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "counter state: " << (cnt.stdStream().rdstate()) << nl
|
||||
<< "via char-stream: " << label(cstr.view().size()) << " chars" << nl
|
||||
<< "via string-stream: " << str.str().size() << " chars" << nl
|
||||
<< "via string-stream: " << label(sstr.count()) << " chars" << nl
|
||||
<< "via ocountstream: " << plain.count() << " chars" << endl;
|
||||
|
||||
fileName outputName;
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2022 OpenCFD Ltd.
|
||||
Copyright (C) 2022-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -32,10 +32,14 @@ Description
|
||||
#include "IOstreams.H"
|
||||
#include "OSspecific.H"
|
||||
#include "argList.H"
|
||||
#include "clock.H"
|
||||
#include "Switch.H"
|
||||
#include "ListOps.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
std::string time_stamp;
|
||||
|
||||
void listFiles(const fileName& dir)
|
||||
{
|
||||
wordList files = ListOps::create<word>
|
||||
@ -55,25 +59,150 @@ void listFiles(const fileName& dir)
|
||||
}
|
||||
|
||||
|
||||
OSstream& printInfo(OFstream& os)
|
||||
{
|
||||
InfoErr
|
||||
<< "open: " << os.name() << nl
|
||||
<< "appending: " << Switch::name(os.is_appending())
|
||||
<< " tellp: "<< os.stdStream().tellp()
|
||||
<< " gz: " << Switch::name(os.compression()) << nl;
|
||||
|
||||
return InfoErr.stream();
|
||||
}
|
||||
|
||||
|
||||
void withHeader(OFstream& os)
|
||||
{
|
||||
const auto tellp = os.stdStream().tellp();
|
||||
|
||||
if (tellp <= 0)
|
||||
{
|
||||
InfoErr
|
||||
<< "Add header" << nl;
|
||||
os << "HEADER: " << time_stamp.c_str() << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class OSstreamType>
|
||||
void generateLines(OSstreamType& os, label count = 1)
|
||||
{
|
||||
for (label line = 1; line <= count; ++line)
|
||||
{
|
||||
os << "[" << line
|
||||
<< "] =============================================" << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class OSstreamType>
|
||||
void generateContent
|
||||
(
|
||||
OSstreamType& os,
|
||||
const bool with_seekend,
|
||||
const bool test_overwrite = false,
|
||||
const int64_t seek_out = -1
|
||||
)
|
||||
{
|
||||
if (with_seekend)
|
||||
{
|
||||
os.stdStream().seekp(0, std::ios_base::end);
|
||||
// OR? os.seek_end();
|
||||
}
|
||||
|
||||
printInfo(os);
|
||||
|
||||
withHeader(os);
|
||||
|
||||
if (test_overwrite && seek_out >= 0)
|
||||
{
|
||||
InfoErr<< "... seekp(" << seek_out << ")" << nl;
|
||||
|
||||
auto& oss = os.stdStream();
|
||||
|
||||
// Actually std::streampos, but cannot increment that
|
||||
|
||||
int64_t pos(seek_out);
|
||||
|
||||
const int64_t tellp_end = oss.tellp();
|
||||
|
||||
if (pos >= 0 && pos < tellp_end)
|
||||
{
|
||||
InfoErr
|
||||
<< "... fill from " << label(pos)
|
||||
<< " to " << label(tellp_end) << nl;
|
||||
|
||||
oss.seekp(pos);
|
||||
|
||||
while (pos < tellp_end)
|
||||
{
|
||||
// Fill with char 'X', rely on streambuf buffering
|
||||
oss << 'X';
|
||||
++pos;
|
||||
}
|
||||
|
||||
oss.seekp(seek_out);
|
||||
os << "More content [at " << seek_out << ']' << endl;
|
||||
}
|
||||
}
|
||||
|
||||
generateLines(os, 4);
|
||||
|
||||
printInfo(os)
|
||||
<< "... sleep" << endl;
|
||||
|
||||
listFiles(os.name().path());
|
||||
|
||||
sleep(2);
|
||||
|
||||
os << "[new content] +++++++++++++++++++++++++++++++++++" << endl;
|
||||
}
|
||||
|
||||
|
||||
template<class OSstreamType>
|
||||
void generateOverwriteContent
|
||||
(
|
||||
OSstreamType& os,
|
||||
const bool with_seekend,
|
||||
const int64_t seek_out = -1
|
||||
)
|
||||
{
|
||||
generateContent(os, with_seekend, true, seek_out);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::addBoolOption("gz", "Use compression");
|
||||
argList::addBoolOption("append", "Use append mode");
|
||||
argList::addBoolOption("append-app", "Use append app mode");
|
||||
argList::addBoolOption("append-ate", "Use append ate mode");
|
||||
argList::addBoolOption("seekend", "Seek to end after non-append open");
|
||||
argList::addOption("seek", "value", "Seek from start (default: 100)");
|
||||
argList::addBoolOption("atomic", "Use atomic");
|
||||
argList::addBoolOption("keep", "Do not remove test directory");
|
||||
argList::addOption("write", "file", "test writing to file");
|
||||
|
||||
#include "setRootCase.H"
|
||||
|
||||
// Same time-stamp for all generated files
|
||||
time_stamp = clock::dateTime();
|
||||
|
||||
const fileName baseDir("Test-OFstream-directory");
|
||||
|
||||
Foam::mkDir(baseDir);
|
||||
|
||||
InfoErr<< "mkdir: " << baseDir << endl;
|
||||
|
||||
Info<< "start:" << nl;
|
||||
listFiles(baseDir);
|
||||
|
||||
const bool with_seekend = args.found("seekend");
|
||||
|
||||
const int seek_out = args.getOrDefault<int>("seek", 100);
|
||||
|
||||
IOstreamOption streamOpt;
|
||||
|
||||
if (args.found("gz"))
|
||||
@ -83,10 +212,11 @@ int main(int argc, char *argv[])
|
||||
|
||||
IOstreamOption::appendType append =
|
||||
(
|
||||
args.found("append")
|
||||
? IOstreamOption::APPEND
|
||||
: IOstreamOption::NON_APPEND
|
||||
args.found("append-app") ? IOstreamOption::APPEND_APP
|
||||
: args.found("append-ate") ? IOstreamOption::APPEND_ATE
|
||||
: IOstreamOption::NO_APPEND
|
||||
);
|
||||
|
||||
IOstreamOption::atomicType atomic =
|
||||
(
|
||||
args.found("atomic")
|
||||
@ -97,7 +227,6 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
OFstream(baseDir/"dummy")() << "Some file content" << endl;
|
||||
|
||||
Foam::ln("dummy", baseDir/"Test2.txt");
|
||||
Foam::ln("dummy", baseDir/"Test3.txt");
|
||||
Foam::ln("dummy", baseDir/"Test4.txt");
|
||||
Foam::ln("dummy", baseDir/"Test4.txt.gz");
|
||||
@ -114,16 +243,31 @@ int main(int argc, char *argv[])
|
||||
append
|
||||
);
|
||||
|
||||
os << "=========================" << endl;
|
||||
generateOverwriteContent(os, with_seekend, seek_out);
|
||||
}
|
||||
|
||||
InfoErr<< "open: " << os.name() << endl;
|
||||
InfoErr<< "... sleep" << endl;
|
||||
{
|
||||
OFstream os
|
||||
(
|
||||
atomic,
|
||||
baseDir/"Test1-app.txt",
|
||||
streamOpt,
|
||||
IOstreamOption::APPEND_APP
|
||||
);
|
||||
|
||||
listFiles(baseDir);
|
||||
generateOverwriteContent(os, with_seekend, seek_out);
|
||||
}
|
||||
|
||||
sleep(2);
|
||||
{
|
||||
OFstream os
|
||||
(
|
||||
atomic,
|
||||
baseDir/"Test1-ate.txt",
|
||||
streamOpt,
|
||||
IOstreamOption::APPEND_ATE
|
||||
);
|
||||
|
||||
os << "+++++++++++++++++++++++++++++++++++" << endl;
|
||||
generateOverwriteContent(os, with_seekend, seek_out);
|
||||
}
|
||||
|
||||
{
|
||||
@ -132,39 +276,21 @@ int main(int argc, char *argv[])
|
||||
atomic,
|
||||
baseDir/"Test2.txt",
|
||||
streamOpt
|
||||
// NON_APPEND
|
||||
);
|
||||
|
||||
os << "=========================" << endl;
|
||||
|
||||
InfoErr<< "open: " << os.name() << endl;
|
||||
InfoErr<< "... sleep" << endl;
|
||||
|
||||
listFiles(baseDir);
|
||||
|
||||
sleep(2);
|
||||
|
||||
os << "+++++++++++++++++++++++++++++++++++" << endl;
|
||||
generateContent(os, with_seekend);
|
||||
}
|
||||
|
||||
{
|
||||
OFstream os
|
||||
(
|
||||
atomic,
|
||||
baseDir/"Test3.txt",
|
||||
streamOpt,
|
||||
IOstreamOption::APPEND
|
||||
IOstreamOption::APPEND_APP
|
||||
);
|
||||
|
||||
os << "=========================" << endl;
|
||||
|
||||
InfoErr<< "open: " << os.name() << endl;
|
||||
InfoErr<< "... sleep" << endl;
|
||||
|
||||
listFiles(baseDir);
|
||||
|
||||
sleep(2);
|
||||
|
||||
os << "+++++++++++++++++++++++++++++++++++" << endl;
|
||||
generateContent(os, with_seekend, with_seekend);
|
||||
}
|
||||
{
|
||||
OFstream os
|
||||
@ -174,35 +300,17 @@ int main(int argc, char *argv[])
|
||||
IOstreamOption::COMPRESSED
|
||||
);
|
||||
|
||||
os << "=========================" << endl;
|
||||
|
||||
InfoErr<< "open: " << os.name() << endl;
|
||||
InfoErr<< "... sleep" << endl;
|
||||
|
||||
listFiles(baseDir);
|
||||
|
||||
sleep(2);
|
||||
|
||||
os << "+++++++++++++++++++++++++++++++++++" << endl;
|
||||
// No seekend with COMPRESSED
|
||||
generateContent(os, false);
|
||||
}
|
||||
{
|
||||
OFstream os
|
||||
(
|
||||
IOstreamOption::ATOMIC,
|
||||
baseDir/"Test5.txt"
|
||||
// ASCII UNCOMPRESSED NON_APPEND
|
||||
);
|
||||
|
||||
os << "=========================" << endl;
|
||||
|
||||
InfoErr<< "open: " << os.name() << endl;
|
||||
InfoErr<< "... sleep" << endl;
|
||||
|
||||
listFiles(baseDir);
|
||||
|
||||
sleep(2);
|
||||
|
||||
os << "+++++++++++++++++++++++++++++++++++" << endl;
|
||||
generateContent(os, with_seekend);
|
||||
}
|
||||
|
||||
Info<< nl << "done:" << endl;
|
||||
|
||||
@ -201,7 +201,6 @@ using namespace Foam;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#include "addTimeOptions.H"
|
||||
argList::addArgument("patch");
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -24,7 +24,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Application
|
||||
checkDecomposePar
|
||||
Test-checkDecomposePar
|
||||
|
||||
Group
|
||||
grpParallelUtilities
|
||||
@ -35,8 +35,9 @@ Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "OSspecific.H"
|
||||
#include "fvCFD.H"
|
||||
#include "argList.H"
|
||||
#include "timeSelector.H"
|
||||
#include "polyMesh.H"
|
||||
#include "cpuTime.H"
|
||||
#include "IFstream.H"
|
||||
#include "regionProperties.H"
|
||||
@ -44,10 +45,14 @@ Description
|
||||
#include "decompositionInformation.H"
|
||||
#include "decompositionModel.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
timeSelector::addOptions_singleTime(); // Single-time options
|
||||
|
||||
argList::addNote
|
||||
(
|
||||
"Check decomposition from kaffpa (KaHIP) output"
|
||||
@ -65,9 +70,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
argList::addArgument("kaffpa-output-file");
|
||||
|
||||
// Include explicit constant options, have zero from time range
|
||||
timeSelector::addOptions(true, false);
|
||||
|
||||
#include "setRootCase.H"
|
||||
|
||||
const auto decompFile = args.get<fileName>(1);
|
||||
@ -75,8 +77,8 @@ int main(int argc, char *argv[])
|
||||
// Set time from database
|
||||
#include "createTime.H"
|
||||
|
||||
// Allow override of time
|
||||
instantList times = timeSelector::selectIfPresent(runTime, args);
|
||||
// Allow override of time from specified time options, or no-op
|
||||
timeSelector::setTimeIfPresent(runTime, args);
|
||||
|
||||
// Allow override of decomposeParDict location
|
||||
const fileName decompDictFile =
|
||||
@ -95,7 +97,7 @@ int main(int argc, char *argv[])
|
||||
Info<< "\n\nDecomposing mesh " << regionName << nl << endl;
|
||||
Info<< "Create mesh..." << flush;
|
||||
|
||||
fvMesh mesh
|
||||
polyMesh mesh
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
@ -111,7 +113,7 @@ int main(int argc, char *argv[])
|
||||
Info<< " nCells = " << mesh.nCells() << endl;
|
||||
|
||||
// Expected format is a simple ASCII list
|
||||
cellToProc.setSize(mesh.nCells());
|
||||
cellToProc.resize(mesh.nCells());
|
||||
{
|
||||
IFstream is(decompFile);
|
||||
|
||||
|
||||
@ -123,7 +123,7 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
|
||||
Info<< testInput << nl;
|
||||
SubStrings<string> args = stringOps::splitSpace(testInput);
|
||||
auto args = stringOps::splitSpace(testInput);
|
||||
Info<< "split into " << args.size() << " args" << nl;
|
||||
|
||||
CStringList inC(args);
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
Test-dimField.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-dimField
|
||||
3
applications/test/dimField1/Make/files
Normal file
3
applications/test/dimField1/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
Test-dimField1.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-dimField1
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -24,7 +24,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Application
|
||||
Test-dimField
|
||||
Test-dimField1
|
||||
|
||||
Description
|
||||
Simple tests for DimensionedField
|
||||
@ -52,7 +52,12 @@ namespace Foam
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::addBoolOption("write", "write some test fields");
|
||||
|
||||
#include "setRootCase.H"
|
||||
|
||||
const bool doWrite = args.found("write");
|
||||
|
||||
#include "createTime.H"
|
||||
#include "createMesh.H"
|
||||
|
||||
@ -60,19 +65,23 @@ int main(int argc, char *argv[])
|
||||
Info<< "Tensor field\n" << endl;
|
||||
DimensionedField<tensor, volMesh> tensorfld
|
||||
(
|
||||
IOobject
|
||||
mesh.newIOobject
|
||||
(
|
||||
"tensor",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
{ IOobject::READ_IF_PRESENT, IOobject::NO_REGISTER }
|
||||
{ IOobject::READ_IF_PRESENT, IOobject::NO_WRITE }
|
||||
),
|
||||
mesh,
|
||||
dimensioned<tensor>(dimless, tensor(1,2,3,4,5,6,7,8,9))
|
||||
);
|
||||
|
||||
Info().beginBlock("transformed")
|
||||
<< tensorfld.T() << nl;
|
||||
if (doWrite)
|
||||
{
|
||||
tensorfld.write();
|
||||
}
|
||||
|
||||
|
||||
Info<< nl;
|
||||
Info().beginBlock("transformed") << tensorfld.T();
|
||||
Info().endBlock();
|
||||
|
||||
{
|
||||
@ -84,8 +93,8 @@ int main(int argc, char *argv[])
|
||||
dimensioned<scalar>(14)
|
||||
);
|
||||
|
||||
Info().beginBlock(tfld().type())
|
||||
<< tfld << nl;
|
||||
Info<< nl;
|
||||
Info().beginBlock(tfld().type()) << tfld;
|
||||
Info().endBlock();
|
||||
}
|
||||
|
||||
@ -98,8 +107,8 @@ int main(int argc, char *argv[])
|
||||
dimensioned<scalar>(5)
|
||||
);
|
||||
|
||||
Info().beginBlock(tfld().type())
|
||||
<< tfld() << nl;
|
||||
Info<< nl;
|
||||
Info().beginBlock(tfld().type()) << tfld();
|
||||
Info().endBlock();
|
||||
|
||||
// From dissimilar types
|
||||
@ -111,8 +120,8 @@ int main(int argc, char *argv[])
|
||||
dimensioned<vector>(Zero)
|
||||
);
|
||||
|
||||
Info().beginBlock(tfld2().type())
|
||||
<< tfld2() << nl;
|
||||
Info<< nl;
|
||||
Info().beginBlock(tfld2().type()) << tfld2();
|
||||
Info().endBlock();
|
||||
}
|
||||
}
|
||||
@ -122,20 +131,13 @@ int main(int argc, char *argv[])
|
||||
Info<< "uint8 field\n" << endl;
|
||||
DimensionedField<uint8_t, volMesh> statefld
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"state",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh.newIOobject("state")
|
||||
mesh,
|
||||
dimensioned<uint8_t>(dimless, uint8_t{100})
|
||||
);
|
||||
|
||||
Info().beginBlock("stateField")
|
||||
<< statefld << nl;
|
||||
Info<< nl;
|
||||
Info().beginBlock("stateField") << statefld;
|
||||
Info().endBlock();
|
||||
}
|
||||
#endif
|
||||
@ -1,3 +0,0 @@
|
||||
Test-ensightFile.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-ensightFile
|
||||
@ -1,8 +0,0 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/fileFormats/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/conversion/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lmeshTools \
|
||||
-lconversion
|
||||
3
applications/test/ensightFile1/Make/files
Normal file
3
applications/test/ensightFile1/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
Test-ensightFile1.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-ensightFile1
|
||||
5
applications/test/ensightFile1/Make/options
Normal file
5
applications/test/ensightFile1/Make/options
Normal file
@ -0,0 +1,5 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/fileFormats/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfileFormats
|
||||
137
applications/test/ensightFile1/Test-ensightFile1.cxx
Normal file
137
applications/test/ensightFile1/Test-ensightFile1.cxx
Normal file
@ -0,0 +1,137 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Application
|
||||
Test-ensightFile
|
||||
|
||||
Description
|
||||
check cleanup of ensight file and variable names
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "ensightFile.H"
|
||||
#include "ensightGeoFile.H"
|
||||
#include "Switch.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noBanner();
|
||||
argList::noParallel();
|
||||
argList::addBoolOption("ascii", "open as ascii instead of binary");
|
||||
argList::addBoolOption("binary", "(default)");
|
||||
argList::addBoolOption("clear", "force clear of time-steps");
|
||||
argList::addBoolOption("no-end", "skip use of endTimeStep");
|
||||
argList::addBoolOption("append", "open in append mode");
|
||||
argList::addOption("geom", "geometry file");
|
||||
argList::addOption("field", "field file");
|
||||
|
||||
#include "setRootCase.H"
|
||||
|
||||
const bool with_ascii = args.found("ascii") && !args.found("binary");
|
||||
// const bool with_binary = args.found("binary");
|
||||
const bool with_append = args.found("append");
|
||||
const bool with_clear = args.found("clear");
|
||||
const bool without_end = args.found("no-end");
|
||||
|
||||
const IOstreamOption::streamFormat fmt =
|
||||
(
|
||||
with_ascii
|
||||
? IOstreamOption::ASCII
|
||||
: IOstreamOption::BINARY
|
||||
);
|
||||
|
||||
const IOstreamOption::appendType append =
|
||||
(
|
||||
with_append
|
||||
? IOstreamOption::APPEND_ATE
|
||||
: IOstreamOption::NO_APPEND
|
||||
);
|
||||
|
||||
|
||||
fileName file;
|
||||
if (args.readIfPresent("geom", file))
|
||||
{
|
||||
Info<< "Open " << file << " as geometry "
|
||||
<< " format:" << (with_ascii ? "ASCII" : "BINARY")
|
||||
<< " append:" << Switch::name(with_append) << nl;
|
||||
|
||||
ensightGeoFile ensFile(append, file, fmt);
|
||||
|
||||
if (append)
|
||||
{
|
||||
ensFile.beginTimeStep();
|
||||
|
||||
// At the moment need to pair begin/end time-step calls
|
||||
if (!without_end)
|
||||
{
|
||||
ensFile.endTimeStep();
|
||||
}
|
||||
}
|
||||
|
||||
if (with_clear)
|
||||
{
|
||||
ensFile.clearTimeSteps();
|
||||
}
|
||||
}
|
||||
|
||||
if (args.readIfPresent("field", file))
|
||||
{
|
||||
Info<< "Open " << file << " as field"
|
||||
<< " format:" << (with_ascii ? "ASCII" : "BINARY")
|
||||
<< " append:" << Switch::name(with_append) << nl;
|
||||
|
||||
ensightFile ensFile(append, file, fmt);
|
||||
|
||||
if (append)
|
||||
{
|
||||
ensFile.beginTimeStep();
|
||||
|
||||
// At the moment need to pair begin/end time-step calls
|
||||
if (!without_end)
|
||||
{
|
||||
ensFile.endTimeStep();
|
||||
}
|
||||
}
|
||||
|
||||
if (with_clear)
|
||||
{
|
||||
ensFile.clearTimeSteps();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
3
applications/test/ensightFileName/Make/files
Normal file
3
applications/test/ensightFileName/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
Test-ensightFileName.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-ensightFileName
|
||||
5
applications/test/ensightFileName/Make/options
Normal file
5
applications/test/ensightFileName/Make/options
Normal file
@ -0,0 +1,5 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/fileFormats/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfileFormats
|
||||
@ -24,10 +24,10 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Application
|
||||
Test-ensightFile
|
||||
Test-ensightFileName
|
||||
|
||||
Description
|
||||
check cleanup of ensight file and variable names
|
||||
Check cleanup of ensight file and variable names
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -32,6 +32,7 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "timeSelector.H"
|
||||
#include "fvMesh.H"
|
||||
#include "volFields.H"
|
||||
#include "Time.H"
|
||||
@ -126,14 +127,14 @@ void writeStencilStats(const labelListList& stencil)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#include "addTimeOptions.H"
|
||||
timeSelector::addOptions_singleTime(); // Single-time options
|
||||
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
// Get times list
|
||||
instantList Times = runTime.times();
|
||||
#include "checkTimeOptions.H"
|
||||
runTime.setTime(Times[startTime], startTime);
|
||||
// Set time from specified time options, or force start from Time=0
|
||||
timeSelector::setTimeIfPresent(runTime, args, true);
|
||||
|
||||
#include "createMesh.H"
|
||||
|
||||
// Force calculation of extended edge addressing
|
||||
|
||||
@ -32,6 +32,7 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "timeSelector.H"
|
||||
#include "fvMesh.H"
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
@ -107,14 +108,16 @@ void writeStencilStats(const labelListList& stencil)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#include "addTimeOptions.H"
|
||||
argList::noFunctionObjects(); // Never use function objects
|
||||
|
||||
timeSelector::addOptions_singleTime(); // Single-time options
|
||||
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
// Get times list
|
||||
instantList Times = runTime.times();
|
||||
#include "checkTimeOptions.H"
|
||||
runTime.setTime(Times[startTime], startTime);
|
||||
// Set time from specified time options, or force start from Time=0
|
||||
timeSelector::setTimeIfPresent(runTime, args, true);
|
||||
|
||||
#include "createMesh.H"
|
||||
|
||||
|
||||
|
||||
@ -5,4 +5,5 @@ EXE_INC = \
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-lmeshTools \
|
||||
-ldynamicMesh
|
||||
|
||||
@ -32,6 +32,7 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "timeSelector.H"
|
||||
#include "fvMesh.H"
|
||||
#include "volFields.H"
|
||||
#include "Time.H"
|
||||
@ -51,22 +52,33 @@ using namespace Foam;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#include "addTimeOptions.H"
|
||||
argList::addArgument("inflate (true|false)");
|
||||
timeSelector::addOptions_singleTime(); // Single-time options
|
||||
|
||||
argList::addBoolOption
|
||||
(
|
||||
"inflate",
|
||||
"Use inflation/deflation for deleting cells"
|
||||
);
|
||||
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
// Allow override of time from specified time options, or no-op
|
||||
timeSelector::setTimeIfPresent(runTime, args);
|
||||
|
||||
#include "createMesh.H"
|
||||
|
||||
const Switch inflate(args[1]);
|
||||
const bool inflate = args.found("inflate");
|
||||
|
||||
if (inflate)
|
||||
{
|
||||
Info<< "Deleting cells using inflation/deflation" << nl << endl;
|
||||
Info<< "Deleting cells using inflation/deflation"
|
||||
<< nl << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "Deleting cells, introducing points at new position" << nl
|
||||
<< endl;
|
||||
Info<< "Deleting cells, introducing points at new position"
|
||||
<< nl << endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ using namespace Foam;
|
||||
template<class PrimitiveType>
|
||||
static List<PrimitiveType> splitStringToList(const std::string& str)
|
||||
{
|
||||
const SubStrings<std::string> items = stringOps::splitAny(str, " ,;");
|
||||
const auto items = stringOps::splitAny(str, " ,;");
|
||||
|
||||
DynamicList<PrimitiveType> values(items.size());
|
||||
|
||||
|
||||
@ -5,4 +5,5 @@ EXE_INC = \
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-lmeshTools \
|
||||
-ldynamicMesh
|
||||
|
||||
@ -33,6 +33,7 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "timeSelector.H"
|
||||
#include "Time.H"
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
@ -52,21 +53,28 @@ using namespace Foam;
|
||||
// Main program:
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#include "addTimeOptions.H"
|
||||
argList::addArgument("inflate (true|false)");
|
||||
timeSelector::addOptions_singleTime(); // Single-time options
|
||||
|
||||
argList::addBoolOption
|
||||
(
|
||||
"inflate",
|
||||
"Use inflation/deflation for splitting/deleting cells"
|
||||
);
|
||||
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
// Allow override of time from specified time options, or no-op
|
||||
timeSelector::setTimeIfPresent(runTime, args);
|
||||
|
||||
#include "createMesh.H"
|
||||
|
||||
|
||||
const pointConstraints& pc = pointConstraints::New(pointMesh::New(mesh));
|
||||
|
||||
const Switch inflate(args[1]);
|
||||
const bool inflate = args.found("inflate");
|
||||
|
||||
if (inflate)
|
||||
{
|
||||
Info<< "Splitting/deleting cells using inflation/deflation" << nl
|
||||
<< endl;
|
||||
Info<< "Splitting/deleting cells using inflation/deflation"
|
||||
<< nl << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -75,6 +83,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
|
||||
const pointConstraints& pc = pointConstraints::New(pointMesh::New(mesh));
|
||||
|
||||
Random rndGen(0);
|
||||
|
||||
|
||||
|
||||
@ -51,7 +51,6 @@ using namespace Foam;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#include "addTimeOptions.H"
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
#include "createMesh.H"
|
||||
|
||||
@ -66,13 +66,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (const entry& dEntry : dict)
|
||||
{
|
||||
if (!dEntry.isStream())
|
||||
if (dEntry.isStream())
|
||||
{
|
||||
continue;
|
||||
List<namedDictionary> list(dEntry.stream());
|
||||
|
||||
Info<< "input: " << dEntry << nl
|
||||
<< "list: " << list << nl;
|
||||
}
|
||||
Info<< "input: " << dEntry << nl;
|
||||
List<namedDictionary> list(dEntry.stream());
|
||||
Info<< "list: " << list << nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2022 OpenCFD Ltd.
|
||||
Copyright (C) 2022-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -44,175 +44,62 @@ Description
|
||||
using namespace Foam;
|
||||
|
||||
|
||||
// Looks like Pstream::exchangeBuf
|
||||
template<class T>
|
||||
void do_exchangeBuf
|
||||
//- Number of elements corresponding to max byte transfer.
|
||||
// Normal upper limit is INT_MAX since MPI sizes are limited to <int>.
|
||||
template<class Type>
|
||||
inline std::size_t maxTransferCount
|
||||
(
|
||||
const label sendSize,
|
||||
const char* sendData,
|
||||
const label recvSize,
|
||||
char* recvData,
|
||||
const int tag,
|
||||
const label comm,
|
||||
const bool wait
|
||||
)
|
||||
const std::size_t max_bytes = std::size_t(0)
|
||||
) noexcept
|
||||
{
|
||||
const label startOfRequests = UPstream::nRequests();
|
||||
|
||||
// Set up receives
|
||||
// ~~~~~~~~~~~~~~~
|
||||
|
||||
// forAll(recvSizes, proci)
|
||||
{
|
||||
// if (proci != Pstream::myProcNo(comm) && recvSizes[proci] > 0)
|
||||
if (!Pstream::master(comm) && recvSize > 0)
|
||||
{
|
||||
UIPstream::read
|
||||
(
|
||||
UPstream::commsTypes::nonBlocking,
|
||||
UPstream::myProcNo(comm), // proci,
|
||||
recvData,
|
||||
recvSize*sizeof(T),
|
||||
tag,
|
||||
comm
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Set up sends
|
||||
// ~~~~~~~~~~~~
|
||||
|
||||
// forAll(sendBufs, proci)
|
||||
for (const int proci : Pstream::subProcs(comm))
|
||||
{
|
||||
if (sendSize > 0)
|
||||
// if (proci != Pstream::myProcNo(comm) && sendSizes[proci] > 0)
|
||||
{
|
||||
if
|
||||
(
|
||||
!UOPstream::write
|
||||
(
|
||||
UPstream::commsTypes::nonBlocking,
|
||||
proci,
|
||||
sendData,
|
||||
sendSize*sizeof(T),
|
||||
tag,
|
||||
comm
|
||||
)
|
||||
)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Cannot send outgoing message. "
|
||||
<< "to:" << proci << " nBytes:"
|
||||
<< label(sendSize*sizeof(T))
|
||||
<< Foam::abort(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Wait for all to finish
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
if (wait)
|
||||
{
|
||||
UPstream::waitRequests(startOfRequests);
|
||||
}
|
||||
return
|
||||
(
|
||||
(max_bytes == 0) // ie, unlimited
|
||||
? (std::size_t(0)) //
|
||||
: (max_bytes > std::size_t(INT_MAX)) // MPI limit is <int>
|
||||
? (std::size_t(INT_MAX) / sizeof(Type)) //
|
||||
: (max_bytes > sizeof(Type)) // require an integral number
|
||||
? (max_bytes / sizeof(Type)) //
|
||||
: (std::size_t(1)) // min of one element
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Looks like Pstream::exchangeContainer
|
||||
template<class Container, class T>
|
||||
void do_exchangeContainer
|
||||
//- Upper limit on number of transfer bytes.
|
||||
// Max bytes is normally INT_MAX since MPI sizes are limited to <int>.
|
||||
// Negative values indicate a subtraction from INT_MAX.
|
||||
inline std::size_t PstreamDetail_maxTransferBytes
|
||||
(
|
||||
const Container& sendData,
|
||||
const label recvSize,
|
||||
Container& recvData,
|
||||
const int tag,
|
||||
const label comm,
|
||||
const bool wait
|
||||
)
|
||||
const int64_t max_bytes
|
||||
) noexcept
|
||||
{
|
||||
const label startOfRequests = UPstream::nRequests();
|
||||
|
||||
// Set up receives
|
||||
// ~~~~~~~~~~~~~~~
|
||||
|
||||
// for (const int proci : Pstream::allProcs(comm))
|
||||
{
|
||||
if (!Pstream::master(comm) && recvSize > 0)
|
||||
// if (proci != Pstream::myProcNo(comm) && recvSize > 0)
|
||||
{
|
||||
UIPstream::read
|
||||
(
|
||||
UPstream::commsTypes::nonBlocking,
|
||||
UPstream::myProcNo(comm), // proci,
|
||||
recvData.data_bytes(),
|
||||
recvSize*sizeof(T),
|
||||
tag,
|
||||
comm
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Set up sends
|
||||
// ~~~~~~~~~~~~
|
||||
|
||||
if (Pstream::master(comm) && sendData.size() > 0)
|
||||
{
|
||||
for (const int proci : Pstream::subProcs(comm))
|
||||
{
|
||||
if
|
||||
(
|
||||
!UOPstream::write
|
||||
(
|
||||
UPstream::commsTypes::nonBlocking,
|
||||
proci,
|
||||
sendData.cdata_bytes(),
|
||||
sendData.size_bytes(),
|
||||
tag,
|
||||
comm
|
||||
)
|
||||
)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Cannot send outgoing message. "
|
||||
<< "to:" << proci << " nBytes:"
|
||||
<< label(sendData.size_bytes())
|
||||
<< Foam::abort(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for all to finish
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
if (wait)
|
||||
{
|
||||
UPstream::waitRequests(startOfRequests);
|
||||
}
|
||||
return
|
||||
(
|
||||
(max_bytes < 0) // (numBytes fewer than INT_MAX)
|
||||
? std::size_t(INT_MAX + max_bytes)
|
||||
: std::size_t(max_bytes)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Container, class T>
|
||||
template<class Container, class Type>
|
||||
void broadcast_chunks
|
||||
(
|
||||
Container& sendData,
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm,
|
||||
const bool wait = true
|
||||
const label comm = UPstream::worldComm
|
||||
const int64_t maxComms_bytes = UPstream::maxCommsSize
|
||||
)
|
||||
{
|
||||
// OR static_assert(is_contiguous<T>::value, "Contiguous data only!")
|
||||
if (!is_contiguous<T>::value)
|
||||
if (!is_contiguous<Type>::value)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Contiguous data only." << sizeof(T) << Foam::abort(FatalError);
|
||||
<< "Contiguous data only." << sizeof(Type)
|
||||
<< Foam::abort(FatalError);
|
||||
}
|
||||
|
||||
if (UPstream::maxCommsSize <= 0)
|
||||
if (maxComms_bytes == 0)
|
||||
{
|
||||
// Do in one go
|
||||
Info<< "send " << sendData.size() << " elements in one go" << endl;
|
||||
@ -227,93 +114,90 @@ void broadcast_chunks
|
||||
|
||||
sendData.resize_nocopy(recvSize); // A no-op on master
|
||||
|
||||
// Determine the number of chunks to send. Note that we
|
||||
// only have to look at the sending data since we are
|
||||
// guaranteed that some processor's sending size is some other
|
||||
// processor's receive size. Also we can ignore any local comms.
|
||||
|
||||
// We need to send chunks so the number of iterations:
|
||||
// maxChunkSize iterations
|
||||
// ------------ ----------
|
||||
// 0 0
|
||||
// 1..maxChunkSize 1
|
||||
// maxChunkSize+1..2*maxChunkSize 2
|
||||
// ...
|
||||
|
||||
const label maxChunkSize
|
||||
// The chunk size (number of elements) corresponding to max byte transfer
|
||||
// Is zero for non-chunked exchanges.
|
||||
const std::size_t chunkSize
|
||||
(
|
||||
max
|
||||
PstreamDetail_maxTransferCount<Type>
|
||||
(
|
||||
static_cast<label>(1),
|
||||
static_cast<label>(UPstream::maxCommsSize/sizeof(T))
|
||||
PstreamDetail_maxTransferBytes(maxComms_bytes)
|
||||
)
|
||||
);
|
||||
|
||||
label nChunks(0);
|
||||
{
|
||||
// Get max send count (elements)
|
||||
// forAll(sendBufs, proci)
|
||||
// {
|
||||
// if (proci != Pstream::myProcNo(comm))
|
||||
// {
|
||||
// nChunks = max(nChunks, sendBufs[proci].size());
|
||||
// }
|
||||
// }
|
||||
nChunks = sendSize;
|
||||
|
||||
if (chunkSize)
|
||||
{
|
||||
// Convert from send count (elements) to number of chunks.
|
||||
// Can normally calculate with (count-1), but add some safety
|
||||
if (nChunks)
|
||||
{
|
||||
nChunks = 1 + (nChunks/maxChunkSize);
|
||||
}
|
||||
reduce(nChunks, maxOp<label>(), tag, comm);
|
||||
label nChunks = 1 + (sendSize/label(chunkSize));
|
||||
|
||||
Info
|
||||
<< "send " << sendSize << " elements ("
|
||||
<< (sendSize*sizeof(T)) << " bytes) in " << nChunks
|
||||
<< " chunks of " << maxChunkSize << " elements ("
|
||||
<< (maxChunkSize*sizeof(T)) << " bytes) for maxCommsSize:"
|
||||
<< Pstream::maxCommsSize
|
||||
<< (sendSize*sizeof(Type)) << " bytes) in " << nChunks
|
||||
<< " chunks of " << label(chunkSize) << " elements ("
|
||||
<< label(chunkSize*sizeof(Type)) << " bytes) for maxCommsSize:"
|
||||
<< label(maxComms_bytes)
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
// stress-test with shortened sendSize
|
||||
// will produce useless loops, but no calls
|
||||
// sendSize /= 2;
|
||||
|
||||
label nSend(0);
|
||||
label startSend(0);
|
||||
char* charPtrSend;
|
||||
typedef stdFoam::span<Type> sendType;
|
||||
|
||||
for (label iter = 0; iter < nChunks; ++iter)
|
||||
do
|
||||
{
|
||||
nSend = min
|
||||
(
|
||||
maxChunkSize,
|
||||
sendSize-startSend
|
||||
);
|
||||
sendType payload(sendData.data(), sendData.size());
|
||||
|
||||
charPtrSend =
|
||||
(
|
||||
nSend > 0
|
||||
? reinterpret_cast<char*>(&(sendData[startSend]))
|
||||
: nullptr
|
||||
);
|
||||
|
||||
Info<< "iter " << iter
|
||||
<< ": beg=" << startSend << " len=" << nSend
|
||||
<< " (" << (nSend*sizeof(T)) << " bytes)" << endl;
|
||||
|
||||
UPstream::broadcast(charPtrSend, nSend*sizeof(T), comm);
|
||||
|
||||
// forAll(nSend, proci)
|
||||
if (!chunkSize)
|
||||
{
|
||||
startSend += nSend;
|
||||
UPstream::broadcast
|
||||
(
|
||||
payload.data_bytes(),
|
||||
payload.size_bytes(),
|
||||
comm
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
// Dispatch chunk-wise until there is nothing left
|
||||
for (int iter = 0; /*true*/; ++iter)
|
||||
{
|
||||
// The begin/end for the data window
|
||||
const std::size_t beg = (std::size_t(iter)*chunkSize);
|
||||
const std::size_t end = (std::size_t(iter+1)*chunkSize);
|
||||
|
||||
if (payload.size() <= beg)
|
||||
{
|
||||
// No more data windows
|
||||
break;
|
||||
}
|
||||
|
||||
sendType window
|
||||
(
|
||||
(end < payload.size())
|
||||
? payload.subspan(beg, end - beg)
|
||||
: payload.subspan(beg)
|
||||
);
|
||||
|
||||
Info<< "iter " << iter
|
||||
<< ": beg=" << label(beg) << " len=" << label(window.size())
|
||||
<< " (" << label(window.size_bytes()) << " bytes)" << endl;
|
||||
|
||||
UPstream::broadcast
|
||||
(
|
||||
window.data_bytes(),
|
||||
window.size_bytes(),
|
||||
comm
|
||||
);
|
||||
}
|
||||
}
|
||||
while (false);
|
||||
|
||||
Info<< "final: " << startSend << endl;
|
||||
Info<< "final" << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -333,7 +217,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
labelList input1;
|
||||
if (Pstream::master())
|
||||
if (UPstream::master())
|
||||
{
|
||||
input1 = identity(500);
|
||||
}
|
||||
@ -348,7 +232,7 @@ int main(int argc, char *argv[])
|
||||
// Mostly the same with PstreamBuffers
|
||||
if (false)
|
||||
{
|
||||
PstreamBuffers pBufs(UPstream::commsTypes::nonBlocking);
|
||||
PstreamBuffers pBufs;
|
||||
|
||||
labelList sendData;
|
||||
if (Pstream::master())
|
||||
|
||||
@ -130,7 +130,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (bool barrier_active = false, done = false; !done; /*nil*/)
|
||||
{
|
||||
std::pair<int, int> probed =
|
||||
std::pair<int, int64_t> probed =
|
||||
UPstream::probeMessage
|
||||
(
|
||||
UPstream::commsTypes::nonBlocking,
|
||||
@ -143,8 +143,8 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
// Message found and had size: receive it
|
||||
|
||||
const label proci = probed.first;
|
||||
const label count = probed.second;
|
||||
const label proci(probed.first);
|
||||
const label count(probed.second);
|
||||
|
||||
recvBufs(proci).resize_nocopy(count);
|
||||
recvFromProc(recvRequests.size()) = proci;
|
||||
|
||||
@ -119,7 +119,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (bool barrier_active = false, done = false; !done; /*nil*/)
|
||||
{
|
||||
std::pair<int, int> probed =
|
||||
std::pair<int, int64_t> probed =
|
||||
UPstream::probeMessage
|
||||
(
|
||||
UPstream::commsTypes::nonBlocking,
|
||||
@ -132,8 +132,8 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
// Message found and had size: receive it
|
||||
|
||||
const label proci = probed.first;
|
||||
const label count = probed.second;
|
||||
const label proci(probed.first);
|
||||
const label count(probed.second);
|
||||
|
||||
if (optNonBlocking)
|
||||
{
|
||||
|
||||
@ -7,5 +7,6 @@ EXE_INC = \
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-ldynamicFvMesh \
|
||||
-lsampling \
|
||||
-loverset
|
||||
|
||||
@ -56,6 +56,7 @@ Description
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "simpleControl.H"
|
||||
#include "predicates.H"
|
||||
#include "dynamicFvMesh.H"
|
||||
#include "dynamicOversetFvMesh.H"
|
||||
|
||||
@ -97,6 +98,7 @@ int main(int argc, char *argv[])
|
||||
component(T.ref(), mesh.C(), 1);
|
||||
// Interpolate + halo swap
|
||||
T.correctBoundaryConditions();
|
||||
// T.boundaryFieldRef().evaluate_if(predicates::always{});
|
||||
// Check halo swap
|
||||
dynamicOversetFvMesh::checkCoupledBC(T);
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "input: " << input << nl
|
||||
<< "expand: " << output << nl
|
||||
<< "split: " << stringOps::split(output, "/") << nl << nl;
|
||||
<< "split: " << stringOps::split(output, '/') << nl << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -34,6 +34,7 @@ Description
|
||||
#include "argList.H"
|
||||
#include "fileName.H"
|
||||
#include "stringOps.H"
|
||||
#include "Switch.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -65,6 +66,9 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noBanner();
|
||||
argList::noParallel();
|
||||
argList::noMandatoryArgs();
|
||||
argList::addArgument("string .. stringN");
|
||||
|
||||
argList::addOption
|
||||
(
|
||||
"any",
|
||||
@ -89,6 +93,12 @@ int main(int argc, char *argv[])
|
||||
"int",
|
||||
"test split on fixed width"
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"begin",
|
||||
"int",
|
||||
"begin offset for splits"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"slash",
|
||||
@ -104,18 +114,25 @@ int main(int argc, char *argv[])
|
||||
"empty",
|
||||
"preserve empty strings in split"
|
||||
);
|
||||
argList args(argc, argv, false, true);
|
||||
|
||||
argList args(argc, argv);
|
||||
|
||||
if (args.size() <= 1 && args.options().empty())
|
||||
{
|
||||
args.printUsage();
|
||||
}
|
||||
|
||||
const label beginOffset = args.getOrDefault<label>("begin", 0);
|
||||
|
||||
const bool keepEmpty = args.found("empty");
|
||||
|
||||
Info<< "begin offset: " << beginOffset << nl;
|
||||
Info<< "keep empty : " << Switch::name(keepEmpty) << nl;
|
||||
|
||||
const label nopts =
|
||||
args.count({"any", "slash", "space", "sub", "fixed", "char"});
|
||||
|
||||
|
||||
if (args.found("any"))
|
||||
{
|
||||
const std::string& str = args["any"];
|
||||
@ -125,7 +142,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (label argi=1; argi < args.size(); ++argi)
|
||||
{
|
||||
const auto split = stringOps::splitAny(args[argi], str);
|
||||
auto split = stringOps::splitAny(args[argi], str, beginOffset);
|
||||
printSubStrings(args[argi], split);
|
||||
}
|
||||
|
||||
@ -144,7 +161,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (label argi=1; argi < args.size(); ++argi)
|
||||
{
|
||||
const auto split = stringOps::split(args[argi], str);
|
||||
auto split = stringOps::split(args[argi], str, beginOffset);
|
||||
printSubStrings(args[argi], split);
|
||||
}
|
||||
|
||||
@ -161,7 +178,11 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (label argi=1; argi < args.size(); ++argi)
|
||||
{
|
||||
const auto split = stringOps::splitSpace(args[argi]);
|
||||
auto split = stringOps::splitSpace(args[argi], beginOffset);
|
||||
printSubStrings(args[argi], split);
|
||||
|
||||
Info<< "pop_front(2)" << nl;
|
||||
split.pop_front(2);
|
||||
printSubStrings(args[argi], split);
|
||||
}
|
||||
|
||||
@ -180,7 +201,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (label argi=1; argi < args.size(); ++argi)
|
||||
{
|
||||
const auto split = stringOps::split(args[argi], delim, keepEmpty);
|
||||
auto split =
|
||||
stringOps::split(args[argi], delim, beginOffset, keepEmpty);
|
||||
printSubStrings(args[argi], split);
|
||||
}
|
||||
|
||||
@ -199,7 +221,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (label argi=1; argi < args.size(); ++argi)
|
||||
{
|
||||
const auto split = stringOps::splitFixed(args[argi], width);
|
||||
auto split = stringOps::splitFixed(args[argi], width, beginOffset);
|
||||
printSubStrings(args[argi], split);
|
||||
}
|
||||
|
||||
@ -219,7 +241,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (label argi=1; argi < args.size(); ++argi)
|
||||
{
|
||||
const auto split = stringOps::split(args[argi], delim, keepEmpty);
|
||||
auto split =
|
||||
stringOps::split(args[argi], delim, beginOffset, keepEmpty);
|
||||
printSubStrings(args[argi], split);
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,7 +157,7 @@ int main(int argc, char *argv[])
|
||||
// // skip over time=0, unless some other time option has been specified
|
||||
// if
|
||||
// (
|
||||
// !args.found("zeroTime")
|
||||
// !args.found("noZero")
|
||||
// && !args.found("time")
|
||||
// && !args.found("latestTime")
|
||||
// && Times.size() > 2
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2022-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2022-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -93,29 +93,34 @@ void Foam::fileFormats::ensightMeshReader::readIDs
|
||||
(
|
||||
ensightReadFile& is,
|
||||
const bool doRead,
|
||||
const label nShapes,
|
||||
const label elemCount,
|
||||
labelList& foamToElem,
|
||||
Map<label>& elemToFoam
|
||||
) const
|
||||
{
|
||||
const label sz = foamToElem.size();
|
||||
foamToElem.resize(sz+nShapes);
|
||||
const label begElem = foamToElem.size();
|
||||
const label endElem = begElem + elemCount;
|
||||
|
||||
foamToElem.resize(foamToElem.size()+elemCount);
|
||||
|
||||
if (doRead)
|
||||
{
|
||||
elemToFoam.reserve(elemToFoam.size()+nShapes);
|
||||
for (label shapei = 0; shapei < nShapes; shapei++)
|
||||
elemToFoam.reserve(elemToFoam.size()+elemCount);
|
||||
|
||||
for (label elemi = begElem; elemi < endElem; ++elemi)
|
||||
{
|
||||
label elemi;
|
||||
is.read(elemi);
|
||||
foamToElem[sz+shapei] = elemi;
|
||||
elemToFoam.insert(elemi, sz+shapei);
|
||||
label id;
|
||||
is.read(id);
|
||||
foamToElem[elemi] = id;
|
||||
elemToFoam.insert(id, elemi);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (label shapei = 0; shapei < nShapes; shapei++)
|
||||
// identity
|
||||
for (label elemi = begElem; elemi < endElem; ++elemi)
|
||||
{
|
||||
foamToElem[sz+shapei] = sz+shapei;
|
||||
foamToElem[elemi] = elemi;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -209,37 +214,54 @@ bool Foam::fileFormats::ensightMeshReader::readGoldPart
|
||||
// Work
|
||||
DynamicList<label> verts;
|
||||
|
||||
string line;
|
||||
string buffer;
|
||||
while (is.good())
|
||||
{
|
||||
do
|
||||
{
|
||||
is.readKeyword(line);
|
||||
// Get entire line/string
|
||||
is.read(buffer);
|
||||
}
|
||||
while (line.empty() && is.good());
|
||||
while (buffer.empty() && is.good());
|
||||
|
||||
const auto split = stringOps::splitSpace(line);
|
||||
if (!is.good())
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if (buffer.contains("BEGIN TIME STEP"))
|
||||
{
|
||||
// Graciously handle a miscued start
|
||||
continue;
|
||||
}
|
||||
else if (buffer.contains("END TIME STEP"))
|
||||
{
|
||||
// END TIME STEP is a valid means to terminate input
|
||||
break;
|
||||
}
|
||||
const auto split = stringOps::splitSpace(buffer);
|
||||
|
||||
if (split.size() == 0)
|
||||
if (split.empty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (split[0] == "part")
|
||||
const auto keyword(split[0].str());
|
||||
|
||||
if (keyword == "part")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (split[0] == "node_ids")
|
||||
else if (keyword == "node_ids")
|
||||
{
|
||||
const label nPoints = points.size();
|
||||
// Ignore for now
|
||||
for (label i = 0; i < nPoints; i++)
|
||||
// Ignore point ids
|
||||
for (label pointi = 0; pointi < nPoints; ++pointi)
|
||||
{
|
||||
label index;
|
||||
is.read(index);
|
||||
label id;
|
||||
is.read(id);
|
||||
}
|
||||
}
|
||||
else if (split[0] == "coordinates")
|
||||
else if (keyword == "coordinates")
|
||||
{
|
||||
label nPoints;
|
||||
is.read(nPoints);
|
||||
@ -257,207 +279,205 @@ bool Foam::fileFormats::ensightMeshReader::readGoldPart
|
||||
nodeIdToPoints
|
||||
);
|
||||
|
||||
points.setSize(nPoints);
|
||||
|
||||
for (label pointi = 0; pointi < nPoints; pointi++)
|
||||
{
|
||||
is.read(points[pointi].x());
|
||||
}
|
||||
for (label pointi = 0; pointi < nPoints; pointi++)
|
||||
{
|
||||
is.read(points[pointi].y());
|
||||
}
|
||||
for (label pointi = 0; pointi < nPoints; pointi++)
|
||||
{
|
||||
is.read(points[pointi].z());
|
||||
}
|
||||
is.readPoints(nPoints, points);
|
||||
}
|
||||
else if (split[0] == "tetra4")
|
||||
else if (keyword == "tetra4")
|
||||
{
|
||||
label nShapes;
|
||||
is.read(nShapes);
|
||||
label elemCount;
|
||||
is.read(elemCount);
|
||||
|
||||
Pout<< indent<< "tetra4 " << nShapes
|
||||
Pout<< indent<< "tetra4 " << elemCount
|
||||
<< " starting at line " << is.lineNumber()
|
||||
<< " position " << is.stdStream().tellg() << endl;
|
||||
|
||||
const label celli = cells.size();
|
||||
cells.resize(celli+nShapes);
|
||||
|
||||
readIDs
|
||||
(
|
||||
is,
|
||||
read_elem_ids,
|
||||
nShapes,
|
||||
elemCount,
|
||||
cellToElemIds,
|
||||
elemIdToCells
|
||||
);
|
||||
|
||||
// Extend and fill the new trailing portion
|
||||
const label startElemi = cells.size();
|
||||
cells.resize(startElemi+elemCount);
|
||||
faceListList::subList myElements = cells.slice(startElemi);
|
||||
|
||||
const auto& model = cellModel::ref(cellModel::TET);
|
||||
for (label shapei = 0; shapei < nShapes; shapei++)
|
||||
for (auto& cellFaces : myElements)
|
||||
{
|
||||
readVerts(is, 4, nodeIdToPoints, verts);
|
||||
if (setHandedness_)
|
||||
{
|
||||
setHandedness(model, verts, points);
|
||||
}
|
||||
const cellShape cellVerts(model, verts);
|
||||
cells[celli+shapei] = cellVerts.faces();
|
||||
cellFaces = cellShape(model, verts).faces();
|
||||
}
|
||||
}
|
||||
else if (split[0] == "pyramid5")
|
||||
else if (keyword == "pyramid5")
|
||||
{
|
||||
label nShapes;
|
||||
is.read(nShapes);
|
||||
label elemCount;
|
||||
is.read(elemCount);
|
||||
|
||||
Pout<< indent<< "pyramid5 " << nShapes
|
||||
Pout<< indent<< "pyramid5 " << elemCount
|
||||
<< " starting at line " << is.lineNumber()
|
||||
<< " position " << is.stdStream().tellg() << endl;
|
||||
|
||||
const label celli = cells.size();
|
||||
cells.resize(celli+nShapes);
|
||||
|
||||
readIDs
|
||||
(
|
||||
is,
|
||||
read_elem_ids,
|
||||
nShapes,
|
||||
elemCount,
|
||||
cellToElemIds,
|
||||
elemIdToCells
|
||||
);
|
||||
|
||||
// Extend and fill the new trailing portion
|
||||
const label startElemi = cells.size();
|
||||
cells.resize(startElemi+elemCount);
|
||||
faceListList::subList myElements = cells.slice(startElemi);
|
||||
|
||||
const auto& model = cellModel::ref(cellModel::PYR);
|
||||
for (label shapei = 0; shapei < nShapes; shapei++)
|
||||
for (auto& cellFaces : myElements)
|
||||
{
|
||||
readVerts(is, 5, nodeIdToPoints, verts);
|
||||
if (setHandedness_)
|
||||
{
|
||||
setHandedness(model, verts, points);
|
||||
}
|
||||
const cellShape cellVerts(model, verts);
|
||||
cells[celli+shapei] = cellVerts.faces();
|
||||
cellFaces = cellShape(model, verts).faces();
|
||||
}
|
||||
}
|
||||
else if (split[0] == "penta6")
|
||||
else if (keyword == "penta6")
|
||||
{
|
||||
label nShapes;
|
||||
is.read(nShapes);
|
||||
label elemCount;
|
||||
is.read(elemCount);
|
||||
|
||||
Pout<< indent<< "penta6 " << nShapes
|
||||
Pout<< indent<< "penta6 " << elemCount
|
||||
<< " starting at line " << is.lineNumber()
|
||||
<< " position " << is.stdStream().tellg() << endl;
|
||||
|
||||
const label celli = cells.size();
|
||||
cells.resize(celli+nShapes);
|
||||
|
||||
readIDs
|
||||
(
|
||||
is,
|
||||
read_elem_ids,
|
||||
nShapes,
|
||||
elemCount,
|
||||
cellToElemIds,
|
||||
elemIdToCells
|
||||
);
|
||||
|
||||
// Extend and fill the new trailing portion
|
||||
const label startElemi = cells.size();
|
||||
cells.resize(startElemi+elemCount);
|
||||
faceListList::subList myElements = cells.slice(startElemi);
|
||||
|
||||
const auto& model = cellModel::ref(cellModel::PRISM);
|
||||
for (label shapei = 0; shapei < nShapes; shapei++)
|
||||
for (auto& cellFaces : myElements)
|
||||
{
|
||||
readVerts(is, 6, nodeIdToPoints, verts);
|
||||
if (setHandedness_)
|
||||
{
|
||||
setHandedness(model, verts, points);
|
||||
}
|
||||
const cellShape cellVerts(model, verts);
|
||||
cells[celli+shapei] = cellVerts.faces();
|
||||
cellFaces = cellShape(model, verts).faces();
|
||||
}
|
||||
}
|
||||
else if (split[0] == "hexa8")
|
||||
else if (keyword == "hexa8")
|
||||
{
|
||||
label nShapes;
|
||||
is.read(nShapes);
|
||||
label elemCount;
|
||||
is.read(elemCount);
|
||||
|
||||
Pout<< indent<< "hexa8 " << nShapes
|
||||
Pout<< indent<< "hexa8 " << elemCount
|
||||
<< " starting at line " << is.lineNumber()
|
||||
<< " position " << is.stdStream().tellg() << endl;
|
||||
|
||||
const label celli = cells.size();
|
||||
cells.resize(celli+nShapes);
|
||||
|
||||
readIDs
|
||||
(
|
||||
is,
|
||||
read_elem_ids,
|
||||
nShapes,
|
||||
elemCount,
|
||||
cellToElemIds,
|
||||
elemIdToCells
|
||||
);
|
||||
|
||||
// Extend and fill the new trailing portion
|
||||
const label startElemi = cells.size();
|
||||
cells.resize(startElemi+elemCount);
|
||||
faceListList::subList myElements = cells.slice(startElemi);
|
||||
|
||||
const auto& model = cellModel::ref(cellModel::HEX);
|
||||
for (label shapei = 0; shapei < nShapes; shapei++)
|
||||
for (auto& cellFaces : myElements)
|
||||
{
|
||||
readVerts(is, 8, nodeIdToPoints, verts);
|
||||
if (setHandedness_)
|
||||
{
|
||||
setHandedness(model, verts, points);
|
||||
}
|
||||
const cellShape cellVerts(model, verts);
|
||||
cells[celli+shapei] = cellVerts.faces();
|
||||
cellFaces = cellShape(model, verts).faces();
|
||||
}
|
||||
}
|
||||
else if (split[0] == "nfaced")
|
||||
else if (keyword == "nfaced")
|
||||
{
|
||||
label nShapes;
|
||||
is.read(nShapes);
|
||||
label elemCount;
|
||||
is.read(elemCount);
|
||||
|
||||
Pout<< indent<< "nfaced " << nShapes
|
||||
Pout<< indent<< "nfaced " << elemCount
|
||||
<< " starting at line " << is.lineNumber()
|
||||
<< " position " << is.stdStream().tellg() << endl;
|
||||
|
||||
const label celli = cells.size();
|
||||
cells.resize(celli+nShapes);
|
||||
|
||||
readIDs
|
||||
(
|
||||
is,
|
||||
read_elem_ids,
|
||||
nShapes,
|
||||
elemCount,
|
||||
cellToElemIds,
|
||||
elemIdToCells
|
||||
);
|
||||
|
||||
for (label shapei = 0; shapei < nShapes; shapei++)
|
||||
// Extend and fill the new trailing portion
|
||||
const label startElemi = cells.size();
|
||||
cells.resize(startElemi+elemCount);
|
||||
faceListList::subList myElements = cells.slice(startElemi);
|
||||
|
||||
for (auto& cellFaces : myElements)
|
||||
{
|
||||
label nFaces;
|
||||
is.read(nFaces);
|
||||
faceList& cellFaces = cells[celli+shapei];
|
||||
cellFaces.setSize(nFaces);
|
||||
cellFaces.resize(nFaces);
|
||||
}
|
||||
|
||||
for (label shapei = 0; shapei < nShapes; shapei++)
|
||||
for (auto& cellFaces : myElements)
|
||||
{
|
||||
faceList& cellFaces = cells[celli+shapei];
|
||||
forAll(cellFaces, cellFacei)
|
||||
for (face& f : cellFaces)
|
||||
{
|
||||
label nVerts;
|
||||
is.read(nVerts);
|
||||
cellFaces[cellFacei].setSize(nVerts);
|
||||
f.resize(nVerts);
|
||||
}
|
||||
}
|
||||
|
||||
for (label shapei = 0; shapei < nShapes; shapei++)
|
||||
for (faceList& cellFaces : myElements)
|
||||
{
|
||||
faceList& cellFaces = cells[celli+shapei];
|
||||
forAll(cellFaces, cellFacei)
|
||||
for (face& f : cellFaces)
|
||||
{
|
||||
face& f = cellFaces[cellFacei];
|
||||
readVerts(is, f.size(), nodeIdToPoints, verts);
|
||||
f.labelList::operator=(verts);
|
||||
}
|
||||
}
|
||||
|
||||
forAll(f, fp)
|
||||
// Full check
|
||||
forAll(myElements, elemi)
|
||||
{
|
||||
for (const face& f : myElements[elemi])
|
||||
{
|
||||
for (label pointi : f)
|
||||
{
|
||||
if (f[fp] < 0 || f[fp] >= points.size())
|
||||
if (pointi < 0 || pointi >= points.size())
|
||||
{
|
||||
FatalErrorInFunction<< "Face:" << shapei
|
||||
FatalErrorInFunction
|
||||
<< "Face:" << elemi
|
||||
<< " verts:" << f
|
||||
<< " indexes outside points:" << points.size()
|
||||
<< exit(FatalError);
|
||||
@ -466,107 +486,104 @@ bool Foam::fileFormats::ensightMeshReader::readGoldPart
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (split[0] == "tria3")
|
||||
else if (keyword == "tria3")
|
||||
{
|
||||
label nShapes;
|
||||
is.read(nShapes);
|
||||
label elemCount;
|
||||
is.read(elemCount);
|
||||
|
||||
Pout<< indent << "tria3 " << nShapes
|
||||
Pout<< indent << "tria3 " << elemCount
|
||||
<< " starting at line " << is.lineNumber()
|
||||
<< " position " << is.stdStream().tellg() << endl;
|
||||
|
||||
const label facei = faces.size();
|
||||
|
||||
readIDs
|
||||
(
|
||||
is,
|
||||
read_elem_ids,
|
||||
nShapes,
|
||||
elemCount,
|
||||
faceToElemIDs,
|
||||
elemIdToFaces
|
||||
);
|
||||
|
||||
faces.setSize(facei+nShapes);
|
||||
// Extend and fill the new trailing portion
|
||||
const label startElemi = cells.size();
|
||||
faces.resize(startElemi+elemCount, face(3)); // <- tria3
|
||||
faceList::subList myElements = faces.slice(startElemi);
|
||||
|
||||
for (label shapei = 0; shapei < nShapes; shapei++)
|
||||
for (face& f : myElements)
|
||||
{
|
||||
auto& f = faces[facei+shapei];
|
||||
f.setSize(3);
|
||||
readVerts(is, f.size(), nodeIdToPoints, verts);
|
||||
f.labelList::operator=(verts);
|
||||
}
|
||||
}
|
||||
else if (split[0] == "quad4")
|
||||
else if (keyword == "quad4")
|
||||
{
|
||||
label nShapes;
|
||||
is.read(nShapes);
|
||||
label elemCount;
|
||||
is.read(elemCount);
|
||||
|
||||
Pout<< indent << "quad4 " << nShapes
|
||||
Pout<< indent << "quad4 " << elemCount
|
||||
<< " starting at line " << is.lineNumber()
|
||||
<< " position " << is.stdStream().tellg() << endl;
|
||||
|
||||
const label facei = faces.size();
|
||||
|
||||
readIDs
|
||||
(
|
||||
is,
|
||||
read_elem_ids,
|
||||
nShapes,
|
||||
elemCount,
|
||||
faceToElemIDs,
|
||||
elemIdToFaces
|
||||
);
|
||||
|
||||
faces.setSize(facei+nShapes);
|
||||
// Extend and fill the new trailing portion
|
||||
const label startElemi = cells.size();
|
||||
faces.resize(startElemi+elemCount, face(4)); // <- quad4
|
||||
faceList::subList myElements = faces.slice(startElemi);
|
||||
|
||||
for (label shapei = 0; shapei < nShapes; shapei++)
|
||||
for (face& f : myElements)
|
||||
{
|
||||
auto& f = faces[facei+shapei];
|
||||
f.setSize(4);
|
||||
readVerts(is, f.size(), nodeIdToPoints, verts);
|
||||
f.labelList::operator=(verts);
|
||||
}
|
||||
}
|
||||
else if (split[0] == "nsided")
|
||||
else if (keyword == "nsided")
|
||||
{
|
||||
label nShapes;
|
||||
is.read(nShapes);
|
||||
label elemCount;
|
||||
is.read(elemCount);
|
||||
|
||||
Pout<< indent << "nsided " << nShapes
|
||||
Pout<< indent << "nsided " << elemCount
|
||||
<< " starting at line " << is.lineNumber()
|
||||
<< " position " << is.stdStream().tellg() << endl;
|
||||
|
||||
const label facei = faces.size();
|
||||
|
||||
readIDs
|
||||
(
|
||||
is,
|
||||
read_elem_ids,
|
||||
nShapes,
|
||||
elemCount,
|
||||
faceToElemIDs,
|
||||
elemIdToFaces
|
||||
);
|
||||
|
||||
faces.setSize(facei+nShapes);
|
||||
// Extend and fill the new trailing portion
|
||||
const label startElemi = cells.size();
|
||||
faces.resize(startElemi+elemCount);
|
||||
faceList::subList myElements = faces.slice(startElemi);
|
||||
|
||||
for (label shapei = 0; shapei < nShapes; shapei++)
|
||||
for (face& f : myElements)
|
||||
{
|
||||
auto& f = faces[facei+shapei];
|
||||
label nVerts;
|
||||
is.read(nVerts);
|
||||
f.setSize(nVerts);
|
||||
f.resize(nVerts);
|
||||
}
|
||||
|
||||
for (label shapei = 0; shapei < nShapes; shapei++)
|
||||
for (face& f : myElements)
|
||||
{
|
||||
auto& f = faces[facei+shapei];
|
||||
readVerts(is, f.size(), nodeIdToPoints, verts);
|
||||
f.labelList::operator=(verts);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningInFunction << "Unhandled key " << string(split[0])
|
||||
<< " from line " << line
|
||||
WarningInFunction << "Unhandled key " << keyword
|
||||
<< " from line " << buffer
|
||||
<< " starting at line " << is.lineNumber()
|
||||
<< " position " << is.stdStream().tellg() << endl;
|
||||
}
|
||||
@ -584,16 +601,21 @@ bool Foam::fileFormats::ensightMeshReader::readGeometry
|
||||
const scalar scaleFactor
|
||||
)
|
||||
{
|
||||
// Auto-detect ascii/binary format,
|
||||
// skips any initial "BEGIN TIME STEP"
|
||||
|
||||
ensightReadFile is(geometryFile_);
|
||||
|
||||
// Skip 'binary' tag
|
||||
is.readBinaryHeader();
|
||||
|
||||
string header;
|
||||
is.read(header);
|
||||
Info<< "Ensight : " << header << endl;
|
||||
is.read(header);
|
||||
Info<< "Ensight : " << header << endl;
|
||||
string buffer;
|
||||
|
||||
// Ensight Geometry File
|
||||
is.read(buffer);
|
||||
Info<< "Ensight : " << buffer << nl;
|
||||
|
||||
// Description - 1
|
||||
is.read(buffer);
|
||||
Info<< "Ensight : " << buffer << nl;
|
||||
|
||||
|
||||
bool read_node_ids = false;
|
||||
@ -623,61 +645,72 @@ bool Foam::fileFormats::ensightMeshReader::readGeometry
|
||||
|
||||
|
||||
// Parse all
|
||||
string line;
|
||||
SubStrings<string> split;
|
||||
|
||||
while (is.good())
|
||||
{
|
||||
do
|
||||
{
|
||||
is.readKeyword(line);
|
||||
// Get entire line/string
|
||||
is.read(buffer);
|
||||
}
|
||||
while (line.empty() && is.good());
|
||||
const auto split = stringOps::splitSpace(line);
|
||||
while (buffer.empty() && is.good());
|
||||
if (buffer.contains("END TIME STEP"))
|
||||
{
|
||||
// END TIME STEP is a valid means to terminate input
|
||||
break;
|
||||
}
|
||||
split = stringOps::splitSpace(buffer);
|
||||
|
||||
if (split[0] == "extents")
|
||||
if (split.empty())
|
||||
{
|
||||
point min;
|
||||
point max;
|
||||
is.read(min.x());
|
||||
is.read(max.x());
|
||||
is.read(min.y());
|
||||
is.read(max.y());
|
||||
is.read(min.z());
|
||||
is.read(max.z());
|
||||
Pout<< indent
|
||||
<< "Read extents " << boundBox(min, max)
|
||||
<< endl;
|
||||
continue;
|
||||
}
|
||||
else if (split[0] == "node")
|
||||
|
||||
const auto keyword(split[0].str());
|
||||
|
||||
if (keyword == "extents")
|
||||
{
|
||||
word id(split[1]);
|
||||
word op(split[2]);
|
||||
// Optional extents (xmin, xmax, ymin, ymax, zmin, zmax)
|
||||
|
||||
boundBox bb;
|
||||
point& min = bb.min();
|
||||
point& max = bb.max();
|
||||
|
||||
is.read(min.x()); is.read(max.x());
|
||||
is.read(min.y()); is.read(max.y());
|
||||
is.read(min.z()); is.read(max.z());
|
||||
|
||||
Pout<< indent << "Read extents " << bb << endl;
|
||||
}
|
||||
else if (keyword == "node")
|
||||
{
|
||||
// "node id (off|assign|given|ignore)"
|
||||
std::string op(split[2]);
|
||||
if (op == "given" || op == "ignore")
|
||||
{
|
||||
Pout<< indent << "Reading node ids" << endl;
|
||||
read_node_ids = true;
|
||||
}
|
||||
}
|
||||
else if (split[0] == "element")
|
||||
else if (keyword == "element")
|
||||
{
|
||||
word id(split[1]);
|
||||
word op(split[2]);
|
||||
// "element id (off|assign|given|ignore)"
|
||||
std::string op(split[2]);
|
||||
if (op == "given" || op == "ignore")
|
||||
{
|
||||
Pout<< indent << "Reading element ids" << endl;
|
||||
read_elem_ids = true;
|
||||
}
|
||||
}
|
||||
else if (split[0] == "part")
|
||||
else if (keyword == "part")
|
||||
{
|
||||
bool finished = false;
|
||||
do
|
||||
{
|
||||
// Make space
|
||||
partIDs.emplace_back();
|
||||
is.read(partIDs.back());
|
||||
|
||||
partNames.emplace_back();
|
||||
is.read(partNames.back());
|
||||
// Read part id and name
|
||||
is.read(partIDs.emplace_back());
|
||||
is.read(partNames.emplace_back());
|
||||
|
||||
Pout<< indent
|
||||
<< "Reading part " << partIDs.back()
|
||||
@ -954,7 +987,7 @@ bool Foam::fileFormats::ensightMeshReader::readGeometry
|
||||
const face& f = rotateFace(cFaces[cFacei], rotatedFace);
|
||||
|
||||
const auto fFnd = vertsToCell.find(f);
|
||||
if (fFnd)
|
||||
if (fFnd.good())
|
||||
{
|
||||
// Already inserted. Internal face.
|
||||
vertsToCell.erase(fFnd);
|
||||
@ -1026,7 +1059,12 @@ bool Foam::fileFormats::ensightMeshReader::readGeometry
|
||||
)
|
||||
);
|
||||
|
||||
if (!cAndF)
|
||||
if (cAndF.good())
|
||||
{
|
||||
partCellAndFace[patchFacei++] = cAndF.val();
|
||||
vertsToCell.erase(cAndF);
|
||||
}
|
||||
else
|
||||
{
|
||||
//WarningInFunction
|
||||
// << "Did not find face " << facei
|
||||
@ -1036,11 +1074,6 @@ bool Foam::fileFormats::ensightMeshReader::readGeometry
|
||||
// << " in part " << parti
|
||||
// << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
partCellAndFace[patchFacei++] = cAndF();
|
||||
vertsToCell.erase(cAndF);
|
||||
}
|
||||
}
|
||||
partCellAndFace.setSize(patchFacei);
|
||||
}
|
||||
|
||||
@ -1569,7 +1569,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
//Get polyMesh to write to constant
|
||||
|
||||
runTime.setTime(instant(runTime.constant()), 0);
|
||||
runTime.setTime(instant(0, runTime.constant()), 0);
|
||||
|
||||
repatcher.repatch();
|
||||
|
||||
|
||||
@ -803,6 +803,10 @@ CompactListList<label> regionRenumber
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noFunctionObjects(); // Never use function objects
|
||||
|
||||
timeSelector::addOptions_singleTime(); // Single-time options
|
||||
|
||||
argList::addNote
|
||||
(
|
||||
"Renumber mesh cells to reduce the bandwidth. Use the -lib option or"
|
||||
@ -863,11 +867,8 @@ int main(int argc, char *argv[])
|
||||
"eg, 'reverse true;'"
|
||||
);
|
||||
|
||||
argList::noFunctionObjects(); // Never use function objects
|
||||
|
||||
#include "addAllRegionOptions.H"
|
||||
#include "addOverwriteOption.H"
|
||||
#include "addTimeOptions.H"
|
||||
|
||||
// -------------------------
|
||||
|
||||
@ -926,14 +927,15 @@ int main(int argc, char *argv[])
|
||||
// Get region names
|
||||
#include "getAllRegionOptions.H"
|
||||
|
||||
// Get times list
|
||||
instantList Times = runTime.times();
|
||||
|
||||
// Set startTime depending on -time and -latestTime options
|
||||
#include "checkTimeOptions.H"
|
||||
|
||||
runTime.setTime(Times[startTime], startTime);
|
||||
// Set time from specified time options, or force start from Time=0
|
||||
timeSelector::setTimeIfPresent(runTime, args, true);
|
||||
|
||||
// Capture current time information for non-overwrite
|
||||
const Tuple2<instant, label> startTime
|
||||
(
|
||||
instant(runTime.value(), runTime.timeName()),
|
||||
runTime.timeIndex()
|
||||
);
|
||||
|
||||
// Start/reset all timings
|
||||
timer.resetTime();
|
||||
@ -947,7 +949,10 @@ int main(int argc, char *argv[])
|
||||
for (fvMesh& mesh : meshes)
|
||||
{
|
||||
// Reset time in case of multiple meshes and not overwrite
|
||||
runTime.setTime(Times[startTime], startTime);
|
||||
if (!overwrite)
|
||||
{
|
||||
runTime.setTime(startTime.first(), startTime.second());
|
||||
}
|
||||
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
|
||||
@ -62,12 +62,13 @@ using namespace Foam;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
timeSelector::addOptions_singleTime(); // Single-time options
|
||||
|
||||
argList::addNote
|
||||
(
|
||||
"Add point/face/cell Zones from similarly named point/face/cell Sets"
|
||||
);
|
||||
|
||||
timeSelector::addOptions(true, false); // constant(true), zero(false)
|
||||
argList::addBoolOption
|
||||
(
|
||||
"noFlipMap",
|
||||
@ -75,14 +76,13 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
|
||||
#include "addRegionOption.H"
|
||||
#include "addTimeOptions.H"
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
const bool noFlipMap = args.found("noFlipMap");
|
||||
|
||||
// Get times list
|
||||
(void)timeSelector::selectIfPresent(runTime, args);
|
||||
// Allow override of time from specified time options, or no-op
|
||||
timeSelector::setTimeIfPresent(runTime, args);
|
||||
|
||||
#include "createNamedPolyMesh.H"
|
||||
|
||||
|
||||
@ -240,9 +240,9 @@ int main(int argc, char *argv[])
|
||||
// Read set construct info from dictionary
|
||||
List<namedDictionary> actionEntries(topoSetDict.lookup("actions"));
|
||||
|
||||
forAll(timeDirs, timeI)
|
||||
forAll(timeDirs, timei)
|
||||
{
|
||||
runTime.setTime(timeDirs[timeI], timeI);
|
||||
runTime.setTime(timeDirs[timei], timei);
|
||||
Info<< "Time = " << runTime.timeName() << endl;
|
||||
|
||||
// Optionally re-read mesh
|
||||
|
||||
@ -549,16 +549,17 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
Info<< finder.dict();
|
||||
}
|
||||
else if (finder.ref().isStream())
|
||||
else if (finder.isStream())
|
||||
{
|
||||
bool addSep = false;
|
||||
bool separator = false;
|
||||
|
||||
const tokenList& tokens = finder.ref().stream();
|
||||
|
||||
for (const token& tok : tokens)
|
||||
for (const token& tok : finder.stream())
|
||||
{
|
||||
if (addSep) Info<< token::SPACE;
|
||||
addSep = true;
|
||||
if (separator)
|
||||
{
|
||||
Info<< token::SPACE;
|
||||
}
|
||||
separator = true;
|
||||
Info<< tok;
|
||||
}
|
||||
Info<< endl;
|
||||
|
||||
@ -554,7 +554,8 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
autoPtr<ensightGeoFile> os =
|
||||
ensCase.newGeometry(hasMovingMesh);
|
||||
ensMesh.write(os);
|
||||
|
||||
ensMesh.write(os.ref());
|
||||
}
|
||||
|
||||
// finite-area
|
||||
@ -562,7 +563,8 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
autoPtr<ensightGeoFile> os =
|
||||
ensFaCasePtr->newGeometry(hasMovingMesh);
|
||||
ensFaMeshPtr->write(os);
|
||||
|
||||
ensFaMeshPtr->write(os.ref());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2023 OpenCFD Ltd.
|
||||
Copyright (C) 2023-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -36,6 +36,7 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "timeSelector.H"
|
||||
#include "fvMesh.H"
|
||||
#include "volFields.H"
|
||||
#include "pointFields.H"
|
||||
@ -145,20 +146,22 @@ void ReadAndMapFields
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noFunctionObjects(); // Never use function objects
|
||||
|
||||
timeSelector::addOptions_singleTime(); // Single-time options
|
||||
|
||||
argList::addNote
|
||||
(
|
||||
"Convert polyMesh results to tetDualMesh"
|
||||
);
|
||||
|
||||
#include "addOverwriteOption.H"
|
||||
#include "addTimeOptions.H"
|
||||
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
// Get times list
|
||||
instantList Times = runTime.times();
|
||||
#include "checkTimeOptions.H"
|
||||
runTime.setTime(Times[startTime], startTime);
|
||||
|
||||
// Set time from specified time options, or force start from Time=0
|
||||
timeSelector::setTimeIfPresent(runTime, args, true);
|
||||
|
||||
// Read the mesh
|
||||
#include "createNamedMesh.H"
|
||||
|
||||
@ -353,7 +353,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
#include "createTime.H"
|
||||
|
||||
runTime.setTime(instant(runTime.constant()), 0);
|
||||
runTime.setTime(instant(0, runTime.constant()), 0);
|
||||
|
||||
#include "createNamedMesh.H"
|
||||
|
||||
|
||||
@ -106,7 +106,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
|
||||
runTime.setTime(instant(runTime.constant()), 0);
|
||||
runTime.setTime(instant(0, runTime.constant()), 0);
|
||||
|
||||
#include "createNamedMesh.H"
|
||||
|
||||
|
||||
@ -26,8 +26,8 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef MapConsistentVolFields_H
|
||||
#define MapConsistentVolFields_H
|
||||
#ifndef Foam_MapConsistentVolFields_H
|
||||
#define Foam_MapConsistentVolFields_H
|
||||
|
||||
#include "GeometricField.H"
|
||||
#include "meshToMesh.H"
|
||||
@ -41,10 +41,9 @@ namespace Foam
|
||||
template<class Type>
|
||||
void evaluateConstraintTypes(GeometricField<Type, fvPatchField, volMesh>& fld)
|
||||
{
|
||||
auto& fldBf = fld.boundaryFieldRef();
|
||||
auto& bfld = fld.boundaryFieldRef();
|
||||
|
||||
const UPstream::commsTypes commsType = UPstream::defaultCommsType;
|
||||
const label startOfRequests = UPstream::nRequests();
|
||||
|
||||
if
|
||||
(
|
||||
@ -52,37 +51,32 @@ void evaluateConstraintTypes(GeometricField<Type, fvPatchField, volMesh>& fld)
|
||||
|| commsType == UPstream::commsTypes::nonBlocking
|
||||
)
|
||||
{
|
||||
forAll(fldBf, patchi)
|
||||
{
|
||||
fvPatchField<Type>& tgtField = fldBf[patchi];
|
||||
const label startOfRequests = UPstream::nRequests();
|
||||
|
||||
for (auto& pfld : bfld)
|
||||
{
|
||||
if
|
||||
(
|
||||
tgtField.type() == tgtField.patch().patch().type()
|
||||
&& polyPatch::constraintType(tgtField.patch().patch().type())
|
||||
pfld.type() == pfld.patch().patch().type()
|
||||
&& polyPatch::constraintType(pfld.patch().patch().type())
|
||||
)
|
||||
{
|
||||
tgtField.initEvaluate(commsType);
|
||||
pfld.initEvaluate(commsType);
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for outstanding requests
|
||||
if (commsType == UPstream::commsTypes::nonBlocking)
|
||||
{
|
||||
UPstream::waitRequests(startOfRequests);
|
||||
}
|
||||
// Wait for outstanding requests (non-blocking)
|
||||
UPstream::waitRequests(startOfRequests);
|
||||
|
||||
forAll(fldBf, patchi)
|
||||
for (auto& pfld : bfld)
|
||||
{
|
||||
fvPatchField<Type>& tgtField = fldBf[patchi];
|
||||
|
||||
if
|
||||
(
|
||||
tgtField.type() == tgtField.patch().patch().type()
|
||||
&& polyPatch::constraintType(tgtField.patch().patch().type())
|
||||
pfld.type() == pfld.patch().patch().type()
|
||||
&& polyPatch::constraintType(pfld.patch().patch().type())
|
||||
)
|
||||
{
|
||||
tgtField.evaluate(commsType);
|
||||
pfld.evaluate(commsType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -94,22 +88,21 @@ void evaluateConstraintTypes(GeometricField<Type, fvPatchField, volMesh>& fld)
|
||||
for (const auto& schedEval : patchSchedule)
|
||||
{
|
||||
const label patchi = schedEval.patch;
|
||||
|
||||
fvPatchField<Type>& tgtField = fldBf[patchi];
|
||||
auto& pfld = bfld[patchi];
|
||||
|
||||
if
|
||||
(
|
||||
tgtField.type() == tgtField.patch().patch().type()
|
||||
&& polyPatch::constraintType(tgtField.patch().patch().type())
|
||||
pfld.type() == pfld.patch().patch().type()
|
||||
&& polyPatch::constraintType(pfld.patch().patch().type())
|
||||
)
|
||||
{
|
||||
if (schedEval.init)
|
||||
{
|
||||
tgtField.initEvaluate(commsType);
|
||||
pfld.initEvaluate(commsType);
|
||||
}
|
||||
else
|
||||
{
|
||||
tgtField.evaluate(commsType);
|
||||
pfld.evaluate(commsType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2017 DHI
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2024 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2020 German Aerospace Center (DLR)
|
||||
Copyright (C) 2020 Johan Roenby
|
||||
-------------------------------------------------------------------------------
|
||||
@ -39,6 +39,7 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "timeSelector.H"
|
||||
|
||||
#include "triSurface.H"
|
||||
#include "triSurfaceTools.H"
|
||||
@ -139,6 +140,10 @@ void setAlpha
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noFunctionObjects(); // Never use function objects
|
||||
|
||||
timeSelector::addOptions_singleTime(); // Single-time options
|
||||
|
||||
argList::addNote
|
||||
(
|
||||
"Uses cutCellIso to create a volume fraction field from an "
|
||||
@ -151,9 +156,14 @@ int main(int argc, char *argv[])
|
||||
"file",
|
||||
"Alternative setAlphaFieldDict dictionary"
|
||||
);
|
||||
|
||||
#include "addRegionOption.H"
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
// Set time from specified time options, or no-op
|
||||
timeSelector::setTimeIfPresent(runTime, args);
|
||||
|
||||
#include "createNamedMesh.H"
|
||||
|
||||
const word dictName("setAlphaFieldDict");
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2022-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2022-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -36,6 +36,7 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "timeSelector.H"
|
||||
#include "Time.H"
|
||||
#include "fvMesh.H"
|
||||
#include "faMesh.H"
|
||||
@ -656,6 +657,10 @@ struct setAreaField
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noFunctionObjects(); // Never use function objects
|
||||
|
||||
timeSelector::addOptions_singleTime(); // Single-time options
|
||||
|
||||
argList::addNote
|
||||
(
|
||||
"Set values on a selected set of cells/patch-faces via a dictionary"
|
||||
@ -670,8 +675,15 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
|
||||
#include "addRegionOption.H"
|
||||
|
||||
// -------------------------
|
||||
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
// Set time from specified time options, or no-op
|
||||
timeSelector::setTimeIfPresent(runTime, args);
|
||||
|
||||
#include "createNamedMesh.H"
|
||||
|
||||
autoPtr<faMesh> faMeshPtr;
|
||||
|
||||
@ -210,7 +210,7 @@ reportExecutable()
|
||||
{
|
||||
APP_NAME="$1"
|
||||
APP_SPEC="$2"
|
||||
APP_PATH="$(findExec $PATH $1)"
|
||||
APP_PATH="$(findExec "$PATH" "$1")"
|
||||
VERSION="unknown"
|
||||
|
||||
if [ -z "$APP_PATH" ]
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v2312 |
|
||||
| \\ / O peration | Version: v2406 |
|
||||
| \\ / A nd | Website: www.openfoam.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -146,13 +146,18 @@ OptimisationSwitches
|
||||
// The default and minimum is (20000000).
|
||||
mpiBufferSize 0;
|
||||
|
||||
// Optional max size (bytes) for unstructured data exchanges. In some
|
||||
// phases of OpenFOAM it can send over very large data chunks
|
||||
// Optional max size (bytes) for unstructured data exchanges.
|
||||
// In some phases of OpenFOAM it can send over very large data chunks
|
||||
// (e.g. in parallel load balancing) and some MPI implementations have
|
||||
// problems with this. Setting this variable > 0 indicates that the
|
||||
// data exchange needs to be done in multiple passes, each of maxCommsSize.
|
||||
// This is not switched on by default since it requires an additional
|
||||
// global reduction, even if multi-pass is not needed)
|
||||
// problems with this.
|
||||
//
|
||||
// This tuning parameter specifies the max number of bytes before
|
||||
// switching to a multi-pass send/recv
|
||||
// (currently only affects PstreamBuffers exchanges).
|
||||
//
|
||||
// 0 : disabled
|
||||
// >0 : limit exchanges to specified number of bytes
|
||||
// <0 : limit exchanges to INT_MAX minus specified number of bytes
|
||||
maxCommsSize 0;
|
||||
|
||||
// Optional (experimental) feature in lduMatrixUpdate
|
||||
|
||||
@ -445,6 +445,7 @@ $(lduMatrix)/solvers/PBiCGStab/PBiCGStab.C
|
||||
$(lduMatrix)/solvers/FPCG/FPCG.C
|
||||
$(lduMatrix)/solvers/PPCG/PPCG.C
|
||||
$(lduMatrix)/solvers/PPCR/PPCR.C
|
||||
$(lduMatrix)/solvers/GMRES/gmresSolver.C
|
||||
|
||||
$(lduMatrix)/smoothers/GaussSeidel/GaussSeidelSmoother.C
|
||||
$(lduMatrix)/smoothers/symGaussSeidel/symGaussSeidelSmoother.C
|
||||
|
||||
@ -121,6 +121,12 @@ class IOobject;
|
||||
template<>
|
||||
Ostream& operator<<(Ostream&, const InfoProxy<IOobject>&);
|
||||
|
||||
// Traits
|
||||
|
||||
//- Trait for specifying global vs. local IOobject file types
|
||||
template<class T>
|
||||
struct is_globalIOobject : std::false_type {};
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class IOobject Declaration
|
||||
@ -712,6 +718,8 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Specialization for \c void always returns true (no headerClassName check).
|
||||
template<>
|
||||
inline bool IOobject::isHeaderClass<void>() const
|
||||
@ -720,11 +728,6 @@ inline bool IOobject::isHeaderClass<void>() const
|
||||
}
|
||||
|
||||
|
||||
//- Trait for specifying global vs. local file types
|
||||
template<class T>
|
||||
struct is_globalIOobject : std::false_type {};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -122,6 +122,26 @@ Foam::GlobalIOField<Type>::GlobalIOField
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Field<Type> Foam::GlobalIOField<Type>::readContents(const IOobject& io)
|
||||
{
|
||||
IOobject rio(io, IOobjectOption::NO_REGISTER);
|
||||
if (rio.readOpt() == IOobjectOption::READ_MODIFIED)
|
||||
{
|
||||
rio.readOpt(IOobjectOption::MUST_READ);
|
||||
}
|
||||
|
||||
// The object is global
|
||||
rio.globalObject(true);
|
||||
|
||||
GlobalIOField<Type> reader(rio);
|
||||
|
||||
return Field<Type>(std::move(static_cast<Field<Type>&>(reader)));
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
@ -135,7 +155,8 @@ bool Foam::GlobalIOField<Type>::readData(Istream& is)
|
||||
template<class Type>
|
||||
bool Foam::GlobalIOField<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
return (os << static_cast<const Field<Type>&>(*this)).good();
|
||||
os << static_cast<const Field<Type>&>(*this);
|
||||
return os.good();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -85,13 +85,19 @@ public:
|
||||
GlobalIOField(const IOobject& io, const tmp<Field<Type>>& tfld);
|
||||
|
||||
|
||||
// Factory Methods
|
||||
|
||||
//- Read and return contents. The IOobject is never registered
|
||||
static Field<Type> readContents(const IOobject& io);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~GlobalIOField() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Is object global
|
||||
//- The object is global
|
||||
virtual bool global() const
|
||||
{
|
||||
return true;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -106,6 +106,26 @@ Foam::GlobalIOList<Type>::GlobalIOList
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::List<Type> Foam::GlobalIOList<Type>::readContents(const IOobject& io)
|
||||
{
|
||||
IOobject rio(io, IOobjectOption::NO_REGISTER);
|
||||
if (rio.readOpt() == IOobjectOption::READ_MODIFIED)
|
||||
{
|
||||
rio.readOpt(IOobjectOption::MUST_READ);
|
||||
}
|
||||
|
||||
// The object is global
|
||||
rio.globalObject(true);
|
||||
|
||||
GlobalIOList<Type> reader(rio);
|
||||
|
||||
return List<Type>(std::move(static_cast<List<Type>&>(reader)));
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
@ -119,7 +139,8 @@ bool Foam::GlobalIOList<Type>::readData(Istream& is)
|
||||
template<class Type>
|
||||
bool Foam::GlobalIOList<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
return (os << *this).good();
|
||||
os << static_cast<const List<Type>&>(*this);
|
||||
return os.good();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -85,6 +85,12 @@ public:
|
||||
GlobalIOList(const IOobject& io, List<Type>&& content);
|
||||
|
||||
|
||||
// Factory Methods
|
||||
|
||||
//- Read and return contents. The IOobject is never registered
|
||||
static List<Type> readContents(const IOobject& io);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~GlobalIOList() = default;
|
||||
|
||||
|
||||
@ -105,6 +105,9 @@ Foam::Map<T> Foam::IOMap<T>::readContents(const IOobject& io)
|
||||
rio.readOpt(IOobjectOption::MUST_READ);
|
||||
}
|
||||
|
||||
// The object is global
|
||||
rio.globalObject(true);
|
||||
|
||||
IOMap<T> reader(rio);
|
||||
|
||||
return Map<T>(std::move(static_cast<Map<T>&>(reader)));
|
||||
|
||||
@ -101,9 +101,7 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
bool writeData(Ostream& os) const;
|
||||
|
||||
//- Is object global
|
||||
//- This object is global
|
||||
virtual bool global() const
|
||||
{
|
||||
return true;
|
||||
@ -116,6 +114,9 @@ public:
|
||||
return globalFilePath(type());
|
||||
}
|
||||
|
||||
//- The writeData method for regIOobject write operation
|
||||
bool writeData(Ostream& os) const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2021-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2021-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -94,6 +94,16 @@ Foam::IOdictionary::IOdictionary
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
Foam::dictionary Foam::IOdictionary::readContents(const IOobject& io)
|
||||
{
|
||||
return readContents(io, typeName);
|
||||
}
|
||||
|
||||
|
||||
Foam::dictionary Foam::IOdictionary::readContents
|
||||
(
|
||||
const IOobject& io,
|
||||
const word& wantedType
|
||||
)
|
||||
{
|
||||
IOobject rio(io, IOobjectOption::NO_REGISTER);
|
||||
if (rio.readOpt() == IOobjectOption::READ_MODIFIED)
|
||||
@ -101,7 +111,14 @@ Foam::dictionary Foam::IOdictionary::readContents(const IOobject& io)
|
||||
rio.readOpt(IOobjectOption::MUST_READ);
|
||||
}
|
||||
|
||||
IOdictionary reader(rio);
|
||||
// The object is global
|
||||
rio.globalObject(true);
|
||||
|
||||
IOdictionary reader
|
||||
(
|
||||
rio,
|
||||
(wantedType.empty() ? typeName : wantedType)
|
||||
);
|
||||
|
||||
return dictionary(std::move(static_cast<dictionary&>(reader)));
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2021-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2021-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -89,9 +89,18 @@ public:
|
||||
|
||||
// Factory Methods
|
||||
|
||||
//- Read and return contents. The IOobject will not be registered
|
||||
//- Read and return contents, testing for "dictionary" type.
|
||||
//- The IOobject will not be registered
|
||||
static dictionary readContents(const IOobject& io);
|
||||
|
||||
//- Read and return contents, testing for expected type.
|
||||
//- The IOobject will not be registered
|
||||
static dictionary readContents
|
||||
(
|
||||
const IOobject& io,
|
||||
const word& wantedType
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~IOdictionary() = default;
|
||||
@ -99,14 +108,14 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Is object global
|
||||
//- The object is global
|
||||
virtual bool global() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//- Return complete path + object name if the file exists
|
||||
// either in the case/processor or case otherwise null
|
||||
//- either in the case/processor or case otherwise null
|
||||
virtual fileName filePath() const
|
||||
{
|
||||
return globalFilePath(type());
|
||||
|
||||
@ -92,7 +92,7 @@ bool Foam::baseIOdictionary::readData(Istream& is)
|
||||
{
|
||||
is >> *this;
|
||||
|
||||
if (writeDictionaries && Pstream::master() && !is.bad())
|
||||
if (writeDictionaries && UPstream::master() && !is.bad())
|
||||
{
|
||||
Sout<< nl
|
||||
<< "--- baseIOdictionary " << name()
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2021-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2021-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -91,6 +91,16 @@ Foam::localIOdictionary::localIOdictionary
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
Foam::dictionary Foam::localIOdictionary::readContents(const IOobject& io)
|
||||
{
|
||||
return readContents(io, typeName);
|
||||
}
|
||||
|
||||
|
||||
Foam::dictionary Foam::localIOdictionary::readContents
|
||||
(
|
||||
const IOobject& io,
|
||||
const word& wantedType
|
||||
)
|
||||
{
|
||||
IOobject rio(io, IOobjectOption::NO_REGISTER);
|
||||
if (rio.readOpt() == IOobjectOption::READ_MODIFIED)
|
||||
@ -98,7 +108,11 @@ Foam::dictionary Foam::localIOdictionary::readContents(const IOobject& io)
|
||||
rio.readOpt(IOobjectOption::MUST_READ);
|
||||
}
|
||||
|
||||
localIOdictionary reader(rio);
|
||||
localIOdictionary reader
|
||||
(
|
||||
rio,
|
||||
(wantedType.empty() ? typeName : wantedType)
|
||||
);
|
||||
|
||||
return dictionary(std::move(static_cast<dictionary&>(reader)));
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2021-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2021-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -86,9 +86,18 @@ public:
|
||||
|
||||
// Factory Methods
|
||||
|
||||
//- Read and return contents. The IOobject will not be registered
|
||||
//- Read and return contents, testing for "dictionary" type.
|
||||
//- The IOobject will not be registered
|
||||
static dictionary readContents(const IOobject& io);
|
||||
|
||||
//- Read and return contents, testing for expected type.
|
||||
//- The IOobject will not be registered
|
||||
static dictionary readContents
|
||||
(
|
||||
const IOobject& io,
|
||||
const word& wantedType
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~localIOdictionary() = default;
|
||||
@ -96,14 +105,14 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Is object global
|
||||
//- The object is not global
|
||||
virtual bool global() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//- Return complete path + object name if the file exists
|
||||
// in the case otherwise null
|
||||
//- in the case otherwise null
|
||||
virtual fileName filePath() const
|
||||
{
|
||||
// Use default (local only) search strategy
|
||||
|
||||
@ -101,14 +101,14 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Is object global
|
||||
//- The object is global
|
||||
virtual bool global() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//- Return complete path + object name if the file exists
|
||||
// either in the case/processor or case otherwise null
|
||||
//- either in the case/processor or case otherwise null
|
||||
virtual fileName filePath() const
|
||||
{
|
||||
return globalFilePath(type());
|
||||
|
||||
@ -28,7 +28,8 @@ Class
|
||||
Foam::IFstream
|
||||
|
||||
Description
|
||||
Input from file stream, using an ISstream
|
||||
Input from file stream as an ISstream, normally using \c std::ifstream
|
||||
for the actual input.
|
||||
|
||||
SourceFiles
|
||||
IFstream.C
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -66,7 +66,7 @@ Foam::OFstream::OFstream
|
||||
(
|
||||
pathname,
|
||||
streamOpt,
|
||||
(IOstreamOption::appendType::APPEND == append),
|
||||
append,
|
||||
(IOstreamOption::atomicType::ATOMIC == atomic)
|
||||
),
|
||||
OSstream(*(ofstreamPointer::get()), pathname, streamOpt)
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,7 +28,29 @@ Class
|
||||
Foam::OFstream
|
||||
|
||||
Description
|
||||
Output to file stream, using an OSstream
|
||||
Output to file stream as an OSstream, normally using \c std::ofstream
|
||||
for the actual output.
|
||||
|
||||
Note
|
||||
The atomic output works by creating an intermediate temporary file,
|
||||
which is renamed as an atomic operation when closing. It is not
|
||||
possible, or particularly desirable, to have an atomic in combination
|
||||
with append behaviour. If both are specified, append has priority.
|
||||
|
||||
Note
|
||||
An output file can be opened in two different \c append modes, both of
|
||||
which preserve existing files:
|
||||
-# A common append mode is APPEND_APP, which corresponds to the
|
||||
\c std::ios_base::app flag.
|
||||
A seek-to-end is performed at \em every write.
|
||||
It is thus not possible to use any manual seeks to overwrite parts
|
||||
of the file.
|
||||
-# The other append mode is APPEND_ATE, which roughly corresponds to the
|
||||
\c std::ios_base::ate flag behaviour.
|
||||
A seek-to-end is performed immediately after opening,
|
||||
but not subsequently.
|
||||
Manual seeks can be used to overwrite parts of the file.
|
||||
.
|
||||
|
||||
SourceFiles
|
||||
OFstream.C
|
||||
@ -64,53 +86,55 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct a null output file stream.
|
||||
// Behaves like \c /dev/null and is named accordingly
|
||||
//- Construct a null output file stream that behaves like \c /dev/null
|
||||
explicit OFstream(std::nullptr_t);
|
||||
|
||||
//- Construct with specified atomic behaviour
|
||||
//- from pathname, stream option, optional append
|
||||
//- from pathname, stream option, optional append (see note).
|
||||
OFstream
|
||||
(
|
||||
IOstreamOption::atomicType atomic,
|
||||
const fileName& pathname,
|
||||
IOstreamOption streamOpt = IOstreamOption(),
|
||||
IOstreamOption::appendType append = IOstreamOption::NON_APPEND
|
||||
IOstreamOption::appendType append = IOstreamOption::NO_APPEND
|
||||
);
|
||||
|
||||
//- Construct from pathname and other specifications
|
||||
//- Construct from pathname and other specifications.
|
||||
// See note on append mode.
|
||||
explicit OFstream
|
||||
(
|
||||
const fileName& pathname,
|
||||
IOstreamOption streamOpt = IOstreamOption(),
|
||||
IOstreamOption::appendType append = IOstreamOption::NON_APPEND
|
||||
IOstreamOption::appendType append = IOstreamOption::NO_APPEND
|
||||
)
|
||||
:
|
||||
OFstream(IOstreamOption::NON_ATOMIC, pathname, streamOpt, append)
|
||||
{}
|
||||
|
||||
//- Construct from pathname, format (uncompressed), optional append,
|
||||
//- Construct from pathname, format (uncompressed),
|
||||
//- optional append (see note),
|
||||
//- atomic behaviour as per system default
|
||||
OFstream
|
||||
(
|
||||
const fileName& pathname,
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::compressionType cmp = IOstreamOption::UNCOMPRESSED,
|
||||
IOstreamOption::appendType append = IOstreamOption::NON_APPEND
|
||||
IOstreamOption::appendType append = IOstreamOption::NO_APPEND
|
||||
)
|
||||
:
|
||||
OFstream(pathname, IOstreamOption(fmt, cmp), append)
|
||||
{}
|
||||
|
||||
//- Construct with specified atomic behaviour
|
||||
//- from pathname, format (uncompressed), optional append
|
||||
//- from pathname, format (uncompressed),
|
||||
//- optional append (see note).
|
||||
OFstream
|
||||
(
|
||||
IOstreamOption::atomicType atomic,
|
||||
const fileName& pathname,
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::compressionType cmp = IOstreamOption::UNCOMPRESSED,
|
||||
IOstreamOption::appendType append = IOstreamOption::NON_APPEND
|
||||
IOstreamOption::appendType append = IOstreamOption::NO_APPEND
|
||||
)
|
||||
:
|
||||
OFstream(atomic, pathname, IOstreamOption(fmt, cmp), append)
|
||||
@ -141,6 +165,21 @@ public:
|
||||
virtual void rewind();
|
||||
|
||||
|
||||
// Output stream modes
|
||||
|
||||
//- True if opened in append mode \em and file already existed
|
||||
bool is_appending() const noexcept
|
||||
{
|
||||
return ofstreamPointer::is_appending();
|
||||
}
|
||||
|
||||
//- True if file creation behaves as atomic
|
||||
bool is_atomic() const noexcept
|
||||
{
|
||||
return ofstreamPointer::is_atomic();
|
||||
}
|
||||
|
||||
|
||||
// Print
|
||||
|
||||
//- Print stream description
|
||||
@ -158,7 +197,7 @@ public:
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver,
|
||||
IOstreamOption::compressionType cmp = IOstreamOption::UNCOMPRESSED,
|
||||
IOstreamOption::appendType append = IOstreamOption::NON_APPEND
|
||||
IOstreamOption::appendType append = IOstreamOption::NO_APPEND
|
||||
)
|
||||
:
|
||||
OFstream(pathname, IOstreamOption(fmt, ver, cmp), append)
|
||||
|
||||
@ -194,20 +194,37 @@ public:
|
||||
|
||||
class ofstreamPointer
|
||||
{
|
||||
// Private Data Types
|
||||
|
||||
//- The file open/creation type (bitmask)
|
||||
enum modeType : char
|
||||
{
|
||||
NONE = 0, // Regular open (truncates existing)
|
||||
ATOMIC = 0x1, // Atomic file creation
|
||||
APPENDING = 0x2 // Is appending to an existing file
|
||||
};
|
||||
|
||||
|
||||
// Private Data
|
||||
|
||||
//- The stream pointer (ofstream | ogzstream | ocountstream, ...)
|
||||
std::unique_ptr<std::ostream> ptr_;
|
||||
|
||||
//- Atomic file creation
|
||||
bool atomic_;
|
||||
//- File output/creation type (atomic, append etc)
|
||||
char mode_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Clear any output mode information
|
||||
void clear_mode() noexcept { mode_ = modeType::NONE; }
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Reopen for compressed/non-compressed
|
||||
//- Reopen for compressed/non-compressed. Discards append status.
|
||||
void reopen(const std::string& pathname);
|
||||
|
||||
//- Close stream and rename file
|
||||
@ -245,16 +262,20 @@ public:
|
||||
//- Construct from pathname, option, append, file handling atomic
|
||||
// \param pathname The file name to open for writing
|
||||
// \param streamOpt Respects (UNCOMPRESSED | COMPRESSED)
|
||||
// \param append Open in append mode
|
||||
// \param append Open in specified append mode
|
||||
// \param atomic Write into temporary file (not target file).
|
||||
// This option should only be used with a stream wrapper
|
||||
// (eg, OFstream) that handles the final renaming.
|
||||
//
|
||||
// \note
|
||||
// There are two different append modes:
|
||||
// append at every write, or only append after opening.
|
||||
explicit ofstreamPointer
|
||||
(
|
||||
const fileName& pathname,
|
||||
IOstreamOption streamOpt = IOstreamOption(),
|
||||
const bool append = false,
|
||||
const bool atomic = false
|
||||
IOstreamOption::appendType append = IOstreamOption::NO_APPEND,
|
||||
bool atomic = false
|
||||
);
|
||||
|
||||
//- Construct from pathname, compression, append, file handling atomic
|
||||
@ -268,12 +289,12 @@ public:
|
||||
(
|
||||
const fileName& pathname,
|
||||
IOstreamOption::compressionType comp,
|
||||
const bool append = false,
|
||||
const bool atomic = false
|
||||
IOstreamOption::appendType append = IOstreamOption::NO_APPEND,
|
||||
bool atomic = false
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
// Static Functions
|
||||
|
||||
//- True if compiled with libz support
|
||||
static bool supports_gz() noexcept;
|
||||
@ -293,14 +314,34 @@ public:
|
||||
//- Which compression type?
|
||||
IOstreamOption::compressionType whichCompression() const;
|
||||
|
||||
//- True if opened in append mode \em and file already existed
|
||||
bool is_appending() const noexcept
|
||||
{
|
||||
return (mode_ & modeType::APPENDING);
|
||||
}
|
||||
|
||||
//- True if file creation behaves as atomic
|
||||
bool is_atomic() const noexcept
|
||||
{
|
||||
return (mode_ & modeType::ATOMIC);
|
||||
}
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
//- Return managed pointer and release ownership
|
||||
std::ostream* release() noexcept { return ptr_.release(); }
|
||||
//- Return managed pointer and release ownership.
|
||||
std::ostream* release() noexcept
|
||||
{
|
||||
clear_mode();
|
||||
return ptr_.release();
|
||||
}
|
||||
|
||||
//- Replace the managed pointer
|
||||
void reset(std::ostream* ptr) noexcept { ptr_.reset(ptr); }
|
||||
void reset(std::ostream* ptr) noexcept
|
||||
{
|
||||
clear_mode();
|
||||
ptr_.reset(ptr);
|
||||
}
|
||||
|
||||
|
||||
// Operators
|
||||
|
||||
@ -88,14 +88,14 @@ Foam::ifstreamPointer::ifstreamPointer
|
||||
Foam::ofstreamPointer::ofstreamPointer() noexcept
|
||||
:
|
||||
ptr_(),
|
||||
atomic_(false)
|
||||
mode_(modeType::NONE)
|
||||
{}
|
||||
|
||||
|
||||
Foam::ofstreamPointer::ofstreamPointer(std::nullptr_t)
|
||||
:
|
||||
ptr_(new Foam::ocountstream),
|
||||
atomic_(false)
|
||||
mode_(modeType::NONE)
|
||||
{}
|
||||
|
||||
|
||||
@ -103,27 +103,44 @@ Foam::ofstreamPointer::ofstreamPointer
|
||||
(
|
||||
const fileName& pathname,
|
||||
IOstreamOption streamOpt,
|
||||
const bool append,
|
||||
const bool atomic
|
||||
IOstreamOption::appendType append,
|
||||
bool atomic
|
||||
)
|
||||
:
|
||||
ptr_(),
|
||||
atomic_(atomic)
|
||||
mode_(modeType::NONE)
|
||||
{
|
||||
std::ios_base::openmode mode
|
||||
// Leave std::ios_base::trunc implicitly handled to make things
|
||||
// easier for append mode.
|
||||
|
||||
std::ios_base::openmode openmode
|
||||
(
|
||||
std::ios_base::out | std::ios_base::binary
|
||||
);
|
||||
|
||||
if (append)
|
||||
if (append == IOstreamOption::APPEND_APP)
|
||||
{
|
||||
mode |= std::ios_base::app;
|
||||
openmode |= std::ios_base::app;
|
||||
|
||||
// Cannot append to gzstream
|
||||
streamOpt.compression(IOstreamOption::UNCOMPRESSED);
|
||||
|
||||
// Cannot use append + atomic operation, without lots of extra work
|
||||
atomic_ = false;
|
||||
atomic = false;
|
||||
}
|
||||
else if (append == IOstreamOption::APPEND_ATE)
|
||||
{
|
||||
// Handle an "append-like" mode by opening "r+b" and NOT as "ab"
|
||||
// - file already exists: Sets read position to start
|
||||
// - file does not exist: Error
|
||||
|
||||
openmode |= std::ios_base::in; // [SIC] - use read bit, not append!
|
||||
|
||||
// Cannot append to gzstream
|
||||
streamOpt.compression(IOstreamOption::UNCOMPRESSED);
|
||||
|
||||
// Cannot use append + atomic operation, without lots of extra work
|
||||
atomic = false;
|
||||
}
|
||||
|
||||
|
||||
@ -146,9 +163,9 @@ Foam::ofstreamPointer::ofstreamPointer
|
||||
|
||||
#ifdef HAVE_LIBZ
|
||||
// TBD:
|
||||
// atomic_ = true; // Always treat COMPRESSED like an atomic
|
||||
// atomic = true; // Always treat COMPRESSED like an atomic
|
||||
|
||||
const fileName& target = (atomic_ ? pathname_tmp : pathname_gz);
|
||||
const fileName& target = (atomic ? pathname_tmp : pathname_gz);
|
||||
|
||||
// Remove old uncompressed version (if any)
|
||||
fType = Foam::type(pathname, false);
|
||||
@ -158,7 +175,7 @@ Foam::ofstreamPointer::ofstreamPointer
|
||||
}
|
||||
|
||||
// Avoid writing into symlinked files (non-append mode)
|
||||
if (!append || atomic_)
|
||||
if (atomic || (append == IOstreamOption::NO_APPEND))
|
||||
{
|
||||
fType = Foam::type(target, false);
|
||||
if (fType == fileName::SYMLINK)
|
||||
@ -167,7 +184,7 @@ Foam::ofstreamPointer::ofstreamPointer
|
||||
}
|
||||
}
|
||||
|
||||
ptr_.reset(new ogzstream(target, mode));
|
||||
ptr_.reset(new ogzstream(target, openmode));
|
||||
|
||||
#else /* HAVE_LIBZ */
|
||||
|
||||
@ -184,7 +201,7 @@ Foam::ofstreamPointer::ofstreamPointer
|
||||
|
||||
if (IOstreamOption::COMPRESSED != streamOpt.compression())
|
||||
{
|
||||
const fileName& target = (atomic_ ? pathname_tmp : pathname);
|
||||
const fileName& target = (atomic ? pathname_tmp : pathname);
|
||||
|
||||
// Remove old compressed version (if any)
|
||||
fType = Foam::type(pathname_gz, false);
|
||||
@ -194,7 +211,7 @@ Foam::ofstreamPointer::ofstreamPointer
|
||||
}
|
||||
|
||||
// Avoid writing into symlinked files (non-append mode)
|
||||
if (!append || atomic_)
|
||||
if (atomic || (append == IOstreamOption::NO_APPEND))
|
||||
{
|
||||
fType = Foam::type(target, false);
|
||||
if (fType == fileName::SYMLINK)
|
||||
@ -203,7 +220,75 @@ Foam::ofstreamPointer::ofstreamPointer
|
||||
}
|
||||
}
|
||||
|
||||
ptr_.reset(new std::ofstream(target, mode));
|
||||
// File pointer (std::ofstream)
|
||||
auto filePtr = std::make_unique<std::ofstream>(target, openmode);
|
||||
|
||||
if (append == IOstreamOption::APPEND_APP)
|
||||
{
|
||||
// Final handling for append 'app' (always non-atomic)
|
||||
|
||||
// Set output position to the end (like std::ios_base::ate)
|
||||
// but only to test if the file had a size.
|
||||
// No real performance problem since any subsequent write
|
||||
// will do the same anyhow.
|
||||
|
||||
filePtr->seekp(0, std::ios_base::end);
|
||||
if (filePtr->tellp() <= 0)
|
||||
{
|
||||
// Did not open an existing file
|
||||
append = IOstreamOption::NO_APPEND;
|
||||
}
|
||||
}
|
||||
else if (append == IOstreamOption::APPEND_ATE)
|
||||
{
|
||||
// Final handling for append 'ate' (always non-atomic)
|
||||
|
||||
if (filePtr->good())
|
||||
{
|
||||
// Success if file already exists.
|
||||
// Set output position to the end - like std::ios_base::ate
|
||||
|
||||
filePtr->seekp(0, std::ios_base::end);
|
||||
|
||||
if (filePtr->tellp() <= 0)
|
||||
{
|
||||
// Did not open an existing file
|
||||
append = IOstreamOption::NO_APPEND;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Error if file does not already exist.
|
||||
// Reopen as regular output mode only.
|
||||
|
||||
// Did not open an existing file
|
||||
append = IOstreamOption::NO_APPEND;
|
||||
|
||||
if (filePtr->is_open())
|
||||
{
|
||||
filePtr->close();
|
||||
}
|
||||
filePtr->clear();
|
||||
filePtr->open
|
||||
(
|
||||
target,
|
||||
(std::ios_base::out | std::ios_base::binary)
|
||||
);
|
||||
}
|
||||
}
|
||||
ptr_.reset(filePtr.release());
|
||||
}
|
||||
|
||||
// Is appending to an existing file
|
||||
if (append != IOstreamOption::NO_APPEND)
|
||||
{
|
||||
mode_ = modeType::APPENDING;
|
||||
}
|
||||
|
||||
// An atomic output operation (normally not appending!)
|
||||
if (atomic)
|
||||
{
|
||||
mode_ |= modeType::ATOMIC;
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,8 +297,8 @@ Foam::ofstreamPointer::ofstreamPointer
|
||||
(
|
||||
const fileName& pathname,
|
||||
IOstreamOption::compressionType comp,
|
||||
const bool append,
|
||||
const bool atomic
|
||||
IOstreamOption::appendType append,
|
||||
bool atomic
|
||||
)
|
||||
:
|
||||
ofstreamPointer
|
||||
@ -237,12 +322,12 @@ void Foam::ifstreamPointer::open
|
||||
// Forcibly close old stream (if any)
|
||||
ptr_.reset(nullptr);
|
||||
|
||||
const std::ios_base::openmode mode
|
||||
const std::ios_base::openmode openmode
|
||||
(
|
||||
std::ios_base::in | std::ios_base::binary
|
||||
);
|
||||
|
||||
ptr_.reset(new std::ifstream(pathname, mode));
|
||||
ptr_.reset(new std::ifstream(pathname, openmode));
|
||||
|
||||
if (!ptr_->good())
|
||||
{
|
||||
@ -254,7 +339,7 @@ void Foam::ifstreamPointer::open
|
||||
{
|
||||
#ifdef HAVE_LIBZ
|
||||
|
||||
ptr_.reset(new igzstream(pathname_gz, mode));
|
||||
ptr_.reset(new igzstream(pathname_gz, openmode));
|
||||
|
||||
#else /* HAVE_LIBZ */
|
||||
|
||||
@ -311,7 +396,7 @@ void Foam::ofstreamPointer::reopen(const std::string& pathname)
|
||||
gz->close();
|
||||
gz->clear();
|
||||
|
||||
if (atomic_)
|
||||
if (mode_ & modeType::ATOMIC)
|
||||
{
|
||||
gz->open
|
||||
(
|
||||
@ -341,10 +426,11 @@ void Foam::ofstreamPointer::reopen(const std::string& pathname)
|
||||
}
|
||||
file->clear();
|
||||
|
||||
// Don't need original request to append since rewind implies
|
||||
// trashing that anyhow.
|
||||
// Invalidate the appending into existing file information
|
||||
// since rewind usually means overwrite
|
||||
mode_ &= ~modeType::APPENDING;
|
||||
|
||||
if (atomic_)
|
||||
if (mode_ & modeType::ATOMIC)
|
||||
{
|
||||
file->open
|
||||
(
|
||||
@ -367,7 +453,13 @@ void Foam::ofstreamPointer::reopen(const std::string& pathname)
|
||||
|
||||
void Foam::ofstreamPointer::close(const std::string& pathname)
|
||||
{
|
||||
if (!atomic_ || pathname.empty()) return;
|
||||
// Invalidate the appending into existing file information
|
||||
mode_ &= ~modeType::APPENDING;
|
||||
|
||||
if (pathname.empty() || !(mode_ & modeType::ATOMIC))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBZ
|
||||
auto* gz = dynamic_cast<ogzstream*>(ptr_.get());
|
||||
|
||||
@ -107,7 +107,7 @@ public:
|
||||
const label comm,
|
||||
const fileName& pathname,
|
||||
IOstreamOption streamOpt = IOstreamOption(),
|
||||
IOstreamOption::appendType append = IOstreamOption::NON_APPEND,
|
||||
IOstreamOption::appendType append = IOstreamOption::NO_APPEND,
|
||||
const bool writeOnProc = true
|
||||
);
|
||||
|
||||
@ -118,7 +118,7 @@ public:
|
||||
const label comm,
|
||||
const fileName& pathname,
|
||||
IOstreamOption streamOpt = IOstreamOption(),
|
||||
IOstreamOption::appendType append = IOstreamOption::NON_APPEND,
|
||||
IOstreamOption::appendType append = IOstreamOption::NO_APPEND,
|
||||
const bool writeOnProc = true
|
||||
)
|
||||
:
|
||||
@ -140,7 +140,7 @@ public:
|
||||
IOstreamOption::atomicType atomic,
|
||||
const fileName& pathname,
|
||||
IOstreamOption streamOpt = IOstreamOption(),
|
||||
IOstreamOption::appendType append = IOstreamOption::NON_APPEND,
|
||||
IOstreamOption::appendType append = IOstreamOption::NO_APPEND,
|
||||
const bool writeOnProc = true
|
||||
)
|
||||
:
|
||||
@ -161,7 +161,7 @@ public:
|
||||
(
|
||||
const fileName& pathname,
|
||||
IOstreamOption streamOpt = IOstreamOption(),
|
||||
IOstreamOption::appendType append = IOstreamOption::NON_APPEND,
|
||||
IOstreamOption::appendType append = IOstreamOption::NO_APPEND,
|
||||
const bool writeOnProc = true
|
||||
)
|
||||
:
|
||||
|
||||
@ -166,9 +166,9 @@ inline Ostream& operator<<(Ostream& os, const Omanip<T>& m)
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
inline Smanip<ios_base::fmtflags> setf(const ios_base::fmtflags flags)
|
||||
inline Smanip<std::ios_base::fmtflags> setf(std::ios_base::fmtflags flags)
|
||||
{
|
||||
return Smanip<ios_base::fmtflags>(&IOstream::setf, flags);
|
||||
return Smanip<std::ios_base::fmtflags>(&IOstream::setf, flags);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -114,23 +114,19 @@ void Foam::IOstream::print(Ostream& os, const int streamState) const
|
||||
{
|
||||
if (streamState == std::ios_base::goodbit)
|
||||
{
|
||||
os << "ios_base::goodbit set : the last operation on stream succeeded"
|
||||
<< endl;
|
||||
os << "goodbit set : the last operation on stream succeeded" << endl;
|
||||
}
|
||||
else if (streamState & std::ios_base::badbit)
|
||||
{
|
||||
os << "ios_base::badbit set : characters possibly lost"
|
||||
<< endl;
|
||||
os << "badbit set : characters possibly lost" << endl;
|
||||
}
|
||||
else if (streamState & std::ios_base::failbit)
|
||||
{
|
||||
os << "ios_base::failbit set : some type of formatting error"
|
||||
<< endl;
|
||||
os << "failbit set : some type of formatting error" << endl;
|
||||
}
|
||||
else if (streamState & std::ios_base::eofbit)
|
||||
{
|
||||
os << "ios_base::eofbit set : at end of stream"
|
||||
<< endl;
|
||||
os << "eofbit set : at end of stream" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -339,9 +339,6 @@ public:
|
||||
return old;
|
||||
}
|
||||
|
||||
//- Return flags of stream
|
||||
virtual ios_base::fmtflags flags() const = 0;
|
||||
|
||||
//- Return the default precision
|
||||
static unsigned int defaultPrecision() noexcept
|
||||
{
|
||||
@ -387,27 +384,30 @@ public:
|
||||
ioState_ |= std::ios_base::badbit;
|
||||
}
|
||||
|
||||
//- Set flags of stream
|
||||
virtual ios_base::fmtflags flags(const ios_base::fmtflags f) = 0;
|
||||
//- Return current stream flags
|
||||
virtual std::ios_base::fmtflags flags() const = 0;
|
||||
|
||||
//- Set flags of stream
|
||||
ios_base::fmtflags setf(const ios_base::fmtflags f)
|
||||
//- Set stream flags, return old stream flags
|
||||
virtual std::ios_base::fmtflags flags(std::ios_base::fmtflags) = 0;
|
||||
|
||||
//- Set stream flag(s), return old stream flags
|
||||
std::ios_base::fmtflags setf(std::ios_base::fmtflags f)
|
||||
{
|
||||
return flags(flags() | f);
|
||||
}
|
||||
|
||||
//- Set flags of given field of stream
|
||||
ios_base::fmtflags setf
|
||||
//- Set stream flag(s) with mask, return old stream flags
|
||||
std::ios_base::fmtflags setf
|
||||
(
|
||||
const ios_base::fmtflags f,
|
||||
const ios_base::fmtflags mask
|
||||
const std::ios_base::fmtflags f,
|
||||
const std::ios_base::fmtflags mask
|
||||
)
|
||||
{
|
||||
return flags((flags() & ~mask) | (f & mask));
|
||||
}
|
||||
|
||||
//- Unset flags of stream
|
||||
void unsetf(const ios_base::fmtflags f)
|
||||
void unsetf(std::ios_base::fmtflags f)
|
||||
{
|
||||
flags(flags() & ~f);
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ Foam::UIPstream::UIPstream(const int fromProcNo, PstreamBuffers& buffers)
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "UIPstream::UIPstream PstreamBuffers :"
|
||||
Perr<< "UIPstream::UIPstream PstreamBuffers :"
|
||||
<< " fromProcNo:" << fromProcNo_
|
||||
<< " tag:" << tag_ << " comm:" << comm_
|
||||
<< " receive buffer size:" << messageSize_
|
||||
|
||||
@ -78,7 +78,7 @@ void Foam::Pstream::combineGather
|
||||
|
||||
if (debug & 2)
|
||||
{
|
||||
Pout<< " received from "
|
||||
Perr<< " received from "
|
||||
<< belowID << " data:" << received << endl;
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ void Foam::Pstream::combineGather
|
||||
|
||||
if (debug & 2)
|
||||
{
|
||||
Pout<< " received from "
|
||||
Perr<< " received from "
|
||||
<< belowID << " data:" << received << endl;
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ void Foam::Pstream::combineGather
|
||||
{
|
||||
if (debug & 2)
|
||||
{
|
||||
Pout<< " sending to " << myComm.above()
|
||||
Perr<< " sending to " << myComm.above()
|
||||
<< " data:" << value << endl;
|
||||
}
|
||||
|
||||
@ -190,7 +190,7 @@ void Foam::Pstream::listCombineGather
|
||||
|
||||
if (debug & 2)
|
||||
{
|
||||
Pout<< " received from "
|
||||
Perr<< " received from "
|
||||
<< belowID << " data:" << received << endl;
|
||||
}
|
||||
|
||||
@ -213,7 +213,7 @@ void Foam::Pstream::listCombineGather
|
||||
|
||||
if (debug & 2)
|
||||
{
|
||||
Pout<< " received from "
|
||||
Perr<< " received from "
|
||||
<< belowID << " data:" << received << endl;
|
||||
}
|
||||
|
||||
@ -229,7 +229,7 @@ void Foam::Pstream::listCombineGather
|
||||
{
|
||||
if (debug & 2)
|
||||
{
|
||||
Pout<< " sending to " << myComm.above()
|
||||
Perr<< " sending to " << myComm.above()
|
||||
<< " data:" << values << endl;
|
||||
}
|
||||
|
||||
@ -306,7 +306,7 @@ void Foam::Pstream::mapCombineGather
|
||||
|
||||
if (debug & 2)
|
||||
{
|
||||
Pout<< " received from "
|
||||
Perr<< " received from "
|
||||
<< belowID << " data:" << received << endl;
|
||||
}
|
||||
|
||||
@ -337,7 +337,7 @@ void Foam::Pstream::mapCombineGather
|
||||
{
|
||||
if (debug & 2)
|
||||
{
|
||||
Pout<< " sending to " << myComm.above()
|
||||
Perr<< " sending to " << myComm.above()
|
||||
<< " data:" << values << endl;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2023 OpenCFD Ltd.
|
||||
Copyright (C) 2023-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -82,7 +82,7 @@ void exchangeConsensus
|
||||
{
|
||||
buf.clear();
|
||||
}
|
||||
recvSizes = Zero;
|
||||
recvSizes = Foam::zero{};
|
||||
|
||||
if (!UPstream::is_rank(comm))
|
||||
{
|
||||
@ -109,7 +109,7 @@ void exchangeConsensus
|
||||
recvBufs[myProci] = sendBufs[myProci];
|
||||
if (myProci < recvSizes.size())
|
||||
{
|
||||
recvSizes[myProci] = recvBufs.size();
|
||||
recvSizes[myProci] = recvBufs[myProci].size();
|
||||
}
|
||||
}
|
||||
|
||||
@ -175,7 +175,7 @@ void exchangeConsensus
|
||||
|
||||
for (bool barrier_active = false, done = false; !done; /*nil*/)
|
||||
{
|
||||
std::pair<int, int> probed =
|
||||
std::pair<int, int64_t> probed =
|
||||
UPstream::probeMessage
|
||||
(
|
||||
UPstream::commsTypes::nonBlocking,
|
||||
@ -189,8 +189,8 @@ void exchangeConsensus
|
||||
// Message found and had size.
|
||||
// - receive into dest buffer location
|
||||
|
||||
const label proci = probed.first;
|
||||
const label count = (probed.second / sizeof(Type));
|
||||
const label proci(probed.first);
|
||||
const label count(probed.second / sizeof(Type));
|
||||
|
||||
auto& recvData = recvBufs[proci];
|
||||
recvData.resize(count); // OK with resize() instead of _nocopy()
|
||||
@ -254,10 +254,10 @@ void exchangeConsensus
|
||||
{
|
||||
static_assert(is_contiguous<Type>::value, "Contiguous data only!");
|
||||
|
||||
// TDB: const bool initialBarrier = (UPstream::tuning_NBX_ > 0);
|
||||
const bool initialBarrier = (UPstream::tuning_NBX_ > 0);
|
||||
|
||||
const label myProci = UPstream::myProcNo(comm);
|
||||
const label numProc = UPstream::myProcNo(comm);
|
||||
const label numProc = UPstream::nProcs(comm);
|
||||
|
||||
// Initial: clear all receive locations
|
||||
// Preferrable to clear out the map entries instead of the map itself
|
||||
@ -300,7 +300,12 @@ void exchangeConsensus
|
||||
// Setup sends
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
// TDB: initialBarrier ...
|
||||
// An initial barrier may help to avoid synchronisation problems
|
||||
// caused elsewhere
|
||||
if (initialBarrier)
|
||||
{
|
||||
UPstream::barrier(comm);
|
||||
}
|
||||
|
||||
|
||||
// Algorithm NBX: Nonblocking consensus with Map (HashTable) containers
|
||||
@ -347,7 +352,7 @@ void exchangeConsensus
|
||||
|
||||
for (bool barrier_active = false, done = false; !done; /*nil*/)
|
||||
{
|
||||
std::pair<int, int> probed =
|
||||
std::pair<int, int64_t> probed =
|
||||
UPstream::probeMessage
|
||||
(
|
||||
UPstream::commsTypes::nonBlocking,
|
||||
@ -361,8 +366,8 @@ void exchangeConsensus
|
||||
// Message found and had size.
|
||||
// - receive into dest buffer location
|
||||
|
||||
const label proci = probed.first;
|
||||
const label count = (probed.second / sizeof(Type));
|
||||
const label proci(probed.first);
|
||||
const label count(probed.second / sizeof(Type));
|
||||
|
||||
auto& recvData = recvBufs(proci);
|
||||
recvData.resize(count); // OK with resize() instead of _nocopy()
|
||||
|
||||
@ -107,7 +107,7 @@ void Foam::Pstream::gatherList
|
||||
|
||||
if (debug & 2)
|
||||
{
|
||||
Pout<< " received through "
|
||||
Perr<< " received through "
|
||||
<< belowID << " data from:" << belowID
|
||||
<< " data:" << values[belowID] << endl;
|
||||
}
|
||||
@ -119,7 +119,7 @@ void Foam::Pstream::gatherList
|
||||
|
||||
if (debug & 2)
|
||||
{
|
||||
Pout<< " received through "
|
||||
Perr<< " received through "
|
||||
<< belowID << " data from:" << leafID
|
||||
<< " data:" << values[leafID] << endl;
|
||||
}
|
||||
@ -136,7 +136,7 @@ void Foam::Pstream::gatherList
|
||||
|
||||
if (debug & 2)
|
||||
{
|
||||
Pout<< " sending to " << myComm.above()
|
||||
Perr<< " sending to " << myComm.above()
|
||||
<< " data from me:" << myProci
|
||||
<< " data:" << values[myProci] << endl;
|
||||
}
|
||||
@ -177,7 +177,7 @@ void Foam::Pstream::gatherList
|
||||
{
|
||||
if (debug & 2)
|
||||
{
|
||||
Pout<< " sending to "
|
||||
Perr<< " sending to "
|
||||
<< myComm.above() << " data from:" << leafID
|
||||
<< " data:" << values[leafID] << endl;
|
||||
}
|
||||
@ -259,7 +259,7 @@ void Foam::Pstream::scatterList
|
||||
|
||||
if (debug & 2)
|
||||
{
|
||||
Pout<< " received through "
|
||||
Perr<< " received through "
|
||||
<< myComm.above() << " data for:" << leafID
|
||||
<< " data:" << values[leafID] << endl;
|
||||
}
|
||||
@ -310,7 +310,7 @@ void Foam::Pstream::scatterList
|
||||
|
||||
if (debug & 2)
|
||||
{
|
||||
Pout<< " sent through "
|
||||
Perr<< " sent through "
|
||||
<< belowID << " data for:" << leafID
|
||||
<< " data:" << values[leafID] << endl;
|
||||
}
|
||||
|
||||
@ -61,8 +61,8 @@ void reduce
|
||||
{
|
||||
if (UPstream::warnComm >= 0 && comm != UPstream::warnComm)
|
||||
{
|
||||
Pout<< "** reducing:" << value << " with comm:" << comm << endl;
|
||||
error::printStack(Pout);
|
||||
Perr<< "** reducing:" << value << " with comm:" << comm << endl;
|
||||
error::printStack(Perr);
|
||||
}
|
||||
Pstream::gather(value, bop, tag, comm);
|
||||
Pstream::broadcast(value, comm);
|
||||
|
||||
@ -151,16 +151,18 @@ public:
|
||||
|
||||
// Stream State Functions
|
||||
|
||||
//- Return stream flags
|
||||
virtual ios_base::fmtflags flags() const override
|
||||
//- Return current stream flags.
|
||||
//- Dummy for parallel stream, returns 0.
|
||||
virtual std::ios_base::fmtflags flags() const override
|
||||
{
|
||||
return ios_base::fmtflags(0);
|
||||
return std::ios_base::fmtflags(0);
|
||||
}
|
||||
|
||||
//- Set flags of stream flags
|
||||
virtual ios_base::fmtflags flags(const ios_base::fmtflags) override
|
||||
//- Set stream flags, return old stream flags.
|
||||
//- Dummy for parallel stream, returns 0.
|
||||
virtual std::ios_base::fmtflags flags(std::ios_base::fmtflags) override
|
||||
{
|
||||
return ios_base::fmtflags(0);
|
||||
return std::ios_base::fmtflags(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -257,7 +257,7 @@ Foam::UIPstreamBase::~UIPstreamBase()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "UIPstreamBase Destructor : tag:" << tag_
|
||||
Perr<< "UIPstreamBase Destructor : tag:" << tag_
|
||||
<< " fromProcNo:" << fromProcNo_
|
||||
<< " clearing receive buffer of size "
|
||||
<< recvBuf_.size()
|
||||
|
||||
@ -144,12 +144,20 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Inquiry
|
||||
// Stream State Functions
|
||||
|
||||
//- Return flags of output stream
|
||||
virtual ios_base::fmtflags flags() const override
|
||||
//- Return current stream flags.
|
||||
//- Dummy for parallel stream, returns 0.
|
||||
virtual std::ios_base::fmtflags flags() const override
|
||||
{
|
||||
return ios_base::fmtflags(0);
|
||||
return std::ios_base::fmtflags(0);
|
||||
}
|
||||
|
||||
//- Set stream flags, return old stream flags.
|
||||
//- Dummy for parallel stream, returns 0.
|
||||
virtual std::ios_base::fmtflags flags(std::ios_base::fmtflags) override
|
||||
{
|
||||
return std::ios_base::fmtflags(0);
|
||||
}
|
||||
|
||||
|
||||
@ -281,15 +289,6 @@ public:
|
||||
virtual void rewind();
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
//- Set flags of stream
|
||||
virtual ios_base::fmtflags flags(const ios_base::fmtflags) override
|
||||
{
|
||||
return ios_base::fmtflags(0);
|
||||
}
|
||||
|
||||
|
||||
// Print
|
||||
|
||||
//- Print stream description to Ostream
|
||||
|
||||
@ -221,7 +221,7 @@ void Foam::UPstream::setParRun(const label nProcs, const bool haveThreads)
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "UPstream::setParRun :"
|
||||
Perr<< "UPstream::setParRun :"
|
||||
<< " nProcs:" << nProcs
|
||||
<< " haveThreads:" << haveThreads
|
||||
<< endl;
|
||||
@ -274,7 +274,7 @@ Foam::label Foam::UPstream::allocateCommunicator
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "Allocating communicator " << index << nl
|
||||
Perr<< "Allocating communicator " << index << nl
|
||||
<< " parent : " << parentIndex << nl
|
||||
<< " procs : " << subRanks << nl
|
||||
<< endl;
|
||||
@ -335,7 +335,7 @@ Foam::label Foam::UPstream::allocateCommunicator
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "Allocating communicator " << index << nl
|
||||
Perr<< "Allocating communicator " << index << nl
|
||||
<< " parent : " << parentIndex << nl
|
||||
<< " procs : " << flatOutput(subRanks) << nl
|
||||
<< endl;
|
||||
@ -492,7 +492,7 @@ bool Foam::UPstream::allocateHostCommunicatorPairs()
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "Allocating host communicators "
|
||||
Perr<< "Allocating host communicators "
|
||||
<< interHostComm_ << ", " << intraHostComm_ << nl
|
||||
<< " parent : " << parentCommunicator << nl
|
||||
<< endl;
|
||||
@ -588,7 +588,7 @@ void Foam::UPstream::freeCommunicator
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "Communicators : Freeing communicator " << communicator
|
||||
Perr<< "Communicators : Freeing communicator " << communicator
|
||||
<< " parent: " << parentComm_[communicator]
|
||||
<< " myProcNo: " << myProcNo_[communicator]
|
||||
<< endl;
|
||||
|
||||
@ -565,14 +565,14 @@ public:
|
||||
|
||||
//- Probe for an incoming message.
|
||||
//
|
||||
// \param commsType Blocking or not
|
||||
// \param commsType Non-blocking or not
|
||||
// \param fromProcNo The source rank (negative == ANY_SOURCE)
|
||||
// \param tag The source message tag
|
||||
// \param communicator The communicator index
|
||||
//
|
||||
// \returns source rank and message size (bytes)
|
||||
// and (-1, 0) on failure
|
||||
static std::pair<int,int> probeMessage
|
||||
static std::pair<int,int64_t> probeMessage
|
||||
(
|
||||
const UPstream::commsTypes commsType,
|
||||
const int fromProcNo,
|
||||
|
||||
@ -147,14 +147,17 @@ public:
|
||||
|
||||
// Stream State
|
||||
|
||||
//- Return flags of output stream
|
||||
virtual ios_base::fmtflags flags() const override
|
||||
//- Return current stream flags
|
||||
virtual std::ios_base::fmtflags flags() const override
|
||||
{
|
||||
return is_.flags();
|
||||
}
|
||||
|
||||
//- Set stream flags
|
||||
virtual ios_base::fmtflags flags(const ios_base::fmtflags f) override
|
||||
//- Set stream flags, return old stream flags
|
||||
virtual std::ios_base::fmtflags flags
|
||||
(
|
||||
std::ios_base::fmtflags f
|
||||
) override
|
||||
{
|
||||
return is_.flags(f);
|
||||
}
|
||||
|
||||
@ -138,14 +138,17 @@ public:
|
||||
|
||||
// Stream State
|
||||
|
||||
//- Get stream flags
|
||||
virtual ios_base::fmtflags flags() const override
|
||||
//- Get current stream flags
|
||||
virtual std::ios_base::fmtflags flags() const override
|
||||
{
|
||||
return os_.flags();
|
||||
}
|
||||
|
||||
//- Set stream flags
|
||||
virtual ios_base::fmtflags flags(const ios_base::fmtflags f) override
|
||||
//- Set stream flags, return old stream flags
|
||||
virtual std::ios_base::fmtflags flags
|
||||
(
|
||||
std::ios_base::fmtflags f
|
||||
) override
|
||||
{
|
||||
return os_.flags(f);
|
||||
}
|
||||
|
||||
@ -215,6 +215,9 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- The number of bytes outputted
|
||||
std::streamsize count() { return stream_.tellp(); }
|
||||
|
||||
//- Get the string.
|
||||
//- As Foam::string instead of std::string (may change in future)
|
||||
Foam::string str() const { return Foam::string(stream_.str()); }
|
||||
|
||||
@ -499,16 +499,18 @@ public:
|
||||
|
||||
// Stream State Functions
|
||||
|
||||
//- Get stream flags - always 0
|
||||
virtual ios_base::fmtflags flags() const override
|
||||
//- Return current stream flags.
|
||||
//- Dummy for token stream, returns 0.
|
||||
virtual std::ios_base::fmtflags flags() const override
|
||||
{
|
||||
return ios_base::fmtflags(0);
|
||||
return std::ios_base::fmtflags(0);
|
||||
}
|
||||
|
||||
//- Set flags of stream - ignored
|
||||
ios_base::fmtflags flags(const ios_base::fmtflags) override
|
||||
//- Set stream flags, return old stream flags.
|
||||
//- Dummy for token stream, returns 0.
|
||||
std::ios_base::fmtflags flags(std::ios_base::fmtflags) override
|
||||
{
|
||||
return ios_base::fmtflags(0);
|
||||
return std::ios_base::fmtflags(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -181,16 +181,18 @@ public:
|
||||
|
||||
// Stream State Functions
|
||||
|
||||
//- Get flags of output stream
|
||||
virtual ios_base::fmtflags flags() const override
|
||||
//- Return current stream flags.
|
||||
//- Dummy for token stream, returns 0.
|
||||
virtual std::ios_base::fmtflags flags() const override
|
||||
{
|
||||
return ios_base::fmtflags(0);
|
||||
return std::ios_base::fmtflags(0);
|
||||
}
|
||||
|
||||
//- Set flags of stream - ignored
|
||||
std::ios_base::fmtflags flags(const ios_base::fmtflags) override
|
||||
//- Set stream flags, return old stream flags.
|
||||
//- Dummy for token stream, returns 0.
|
||||
std::ios_base::fmtflags flags(std::ios_base::fmtflags) override
|
||||
{
|
||||
return ios_base::fmtflags(0);
|
||||
return std::ios_base::fmtflags(0);
|
||||
}
|
||||
|
||||
//- Flush stream
|
||||
|
||||
@ -73,16 +73,18 @@ public:
|
||||
|
||||
// Stream-state
|
||||
|
||||
//- Return flags of stream
|
||||
virtual ios_base::fmtflags flags() const override
|
||||
//- Return current stream flags.
|
||||
//- Dummy for dummy stream, returns 0.
|
||||
virtual std::ios_base::fmtflags flags() const override
|
||||
{
|
||||
return ios_base::fmtflags(0);
|
||||
return std::ios_base::fmtflags(0);
|
||||
}
|
||||
|
||||
//- Set flags of stream
|
||||
virtual ios_base::fmtflags flags(const ios_base::fmtflags) override
|
||||
//- Set stream flags, return old stream flags.
|
||||
//- Dummy for dummy stream, returns 0.
|
||||
virtual std::ios_base::fmtflags flags(std::ios_base::fmtflags) override
|
||||
{
|
||||
return ios_base::fmtflags(0);
|
||||
return std::ios_base::fmtflags(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -337,10 +337,10 @@ public:
|
||||
TypeNameNoDebug("Compound<T>");
|
||||
|
||||
//- No copy construct
|
||||
Compound<T>(const Compound<T>&) = delete;
|
||||
Compound(const Compound<T>&) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
Compound<T>& operator=(const Compound<T>&) = delete;
|
||||
void operator=(const Compound<T>&) = delete;
|
||||
|
||||
// Constructors
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -115,7 +115,7 @@ void Foam::timeSelector::addOptions
|
||||
argList::addBoolOption
|
||||
(
|
||||
"constant",
|
||||
"Include the 'constant/' dir in the times list"
|
||||
"Include 'constant/' dir in the times list"
|
||||
);
|
||||
}
|
||||
if (withZero)
|
||||
@ -123,13 +123,13 @@ void Foam::timeSelector::addOptions
|
||||
argList::addBoolOption
|
||||
(
|
||||
"withZero",
|
||||
"Include the '0/' dir in the times list"
|
||||
"Include '0/' dir in the times list"
|
||||
);
|
||||
}
|
||||
argList::addBoolOption
|
||||
(
|
||||
"noZero",
|
||||
string("Exclude the '0/' dir from the times list")
|
||||
string("Exclude '0/' dir from the times list")
|
||||
+ (
|
||||
withZero
|
||||
? ", has precedence over the -withZero option"
|
||||
@ -150,6 +150,32 @@ void Foam::timeSelector::addOptions
|
||||
}
|
||||
|
||||
|
||||
void Foam::timeSelector::addOptions_singleTime()
|
||||
{
|
||||
argList::addBoolOption
|
||||
(
|
||||
"constant",
|
||||
"Include 'constant/' dir in the times"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"noZero",
|
||||
"Exclude '0/' dir from the times (currently ignored)"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"latestTime",
|
||||
"Select the latest time"
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"time",
|
||||
"value",
|
||||
"Select the nearest time to the specified value"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::instantList Foam::timeSelector::select
|
||||
(
|
||||
const instantList& times,
|
||||
@ -291,4 +317,77 @@ Foam::instantList Foam::timeSelector::selectIfPresent
|
||||
}
|
||||
|
||||
|
||||
bool Foam::timeSelector::setTimeIfPresent
|
||||
(
|
||||
Time& runTime,
|
||||
const argList& args,
|
||||
const bool forceInitial
|
||||
)
|
||||
{
|
||||
label timei = -1;
|
||||
instantList times;
|
||||
|
||||
if
|
||||
(
|
||||
forceInitial
|
||||
|| args.found("constant")
|
||||
|| args.found("latestTime")
|
||||
|| args.found("time")
|
||||
// Currently ignoring -noZero, -withZero
|
||||
)
|
||||
{
|
||||
// Get times list
|
||||
times = runTime.times();
|
||||
}
|
||||
|
||||
if (times.size())
|
||||
{
|
||||
// Start from first time (eg, for -constant or forced)
|
||||
timei = 0;
|
||||
|
||||
// Determine latestTime selection (if any)
|
||||
// This must appear before the -time option processing
|
||||
if (args.found("latestTime"))
|
||||
{
|
||||
timei = times.size() - 1;
|
||||
}
|
||||
else if (args.found("time"))
|
||||
{
|
||||
const scalar target = args.get<scalar>("time");
|
||||
|
||||
timei = TimePaths::findClosestTimeIndex(times, target);
|
||||
}
|
||||
|
||||
|
||||
// Avoid "constant" unless specifically requested with -constant,
|
||||
// and the -constant option is actually an expected option
|
||||
|
||||
if
|
||||
(
|
||||
(timei >= 0 && timei < times.size()-1)
|
||||
&& times[timei].name() == "constant"
|
||||
&& (argList::validOptions.found("constant") && !args.found("constant"))
|
||||
)
|
||||
{
|
||||
++timei;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (timei >= 0 && timei < times.size())
|
||||
{
|
||||
// Specified a timeSelector option, or forceInitial.
|
||||
// Set the runTime accordingly.
|
||||
|
||||
runTime.setTime(times[timei], timei);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No timeSelector option specified. Do not change runTime.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,14 +28,13 @@ Class
|
||||
Foam::timeSelector
|
||||
|
||||
Description
|
||||
A List of scalarRange for selecting times.
|
||||
|
||||
The timeSelector provides a convenient means of selecting multiple
|
||||
times. A typical use would be the following:
|
||||
times.
|
||||
|
||||
A typical use would be the following:
|
||||
\verbatim
|
||||
timeSelector::addOptions();
|
||||
// add other options
|
||||
...
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
instantList timeDirs = timeSelector::select0(runTime, args);
|
||||
@ -46,11 +45,11 @@ Description
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
The result program would receive \b -time, \b -latestTime, \b -constant
|
||||
and \b -noZero options. The \b -constant option explicitly includes the
|
||||
With the \c addOptions() method, application receives
|
||||
\b -time, \b -latestTime, \b -constant and \b -noZero options.
|
||||
The \b -constant option explicitly includes the
|
||||
\c constant/ directory in the time list and the \b -noZero option
|
||||
explicitly excludes the \c 0/ directory from the time list.
|
||||
|
||||
There may however also be many cases in which neither the \c constant/
|
||||
directory nor the \c 0/ directory contain particularly relevant
|
||||
information. This might occur, for example, when post-processing
|
||||
@ -66,6 +65,25 @@ Description
|
||||
\c 0/ directory from being included in the default time range and in the
|
||||
\b -latestTime selection.
|
||||
|
||||
It is also possible to use the timeSelector for setting a single time.
|
||||
Typical use would be the following:
|
||||
|
||||
\verbatim
|
||||
timeSelector::addOptions_singleTime();
|
||||
...
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
timeSelector::setTimeIfPresent(runTime, args);
|
||||
\endverbatim
|
||||
|
||||
With the \c addOptions_singleTime() method, application receives
|
||||
\b -time, \b -latestTime, \b -constant options. In the case,
|
||||
the \b -time option is intended to be a single value and not include
|
||||
any ranges.
|
||||
|
||||
The subsequent call to \c setTimeIfPresent() will scan the arguments
|
||||
for relevant time options and use them to set the time.
|
||||
|
||||
SourceFiles
|
||||
timeSelector.C
|
||||
|
||||
@ -135,6 +153,14 @@ public:
|
||||
|
||||
//- Add timeSelector options to argList::validOptions
|
||||
//
|
||||
// \par Options added:
|
||||
// - \c -constant
|
||||
// - \c -time
|
||||
// - \c -latestTime
|
||||
// - \c -noZero
|
||||
// - \c -withZero
|
||||
// .
|
||||
//
|
||||
// \param constant
|
||||
// Add the \b -constant option to include the \c constant/ directory
|
||||
//
|
||||
@ -150,6 +176,16 @@ public:
|
||||
const bool withZero=false
|
||||
);
|
||||
|
||||
//- Add single-time timeSelector options to argList::validOptions()
|
||||
//
|
||||
// \par Options added:
|
||||
// - \c -constant
|
||||
// - \c -time
|
||||
// - \c -latestTime
|
||||
// - \c -noZero (ignored)
|
||||
// .
|
||||
static void addOptions_singleTime();
|
||||
|
||||
//- Return the set of times selected based on the argList options
|
||||
static instantList select
|
||||
(
|
||||
@ -167,14 +203,25 @@ public:
|
||||
const argList& args
|
||||
);
|
||||
|
||||
//- If any time option provided return the set of times (as select0)
|
||||
//- otherwise return just the current time.
|
||||
//- If any time option provided return the set of times -
|
||||
//- as per select0() - otherwise return just the current time.
|
||||
// Also set the runTime to the first instance
|
||||
static instantList selectIfPresent
|
||||
(
|
||||
Time& runTime,
|
||||
const argList& args
|
||||
);
|
||||
|
||||
//- Set the runTime based on \c -constant (if present),
|
||||
//- \c -time (value), or \c -latestTime.
|
||||
// This method is a no-op if no relevant options have been specified.
|
||||
static bool setTimeIfPresent
|
||||
(
|
||||
Time& runTime,
|
||||
const argList& args,
|
||||
//! Force initial time (default: 0) even if no options specified
|
||||
const bool forceInitial = false
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -183,8 +183,7 @@ public:
|
||||
pointer eptr_;
|
||||
|
||||
|
||||
//- Construct for the given dictionary context.
|
||||
// Allow implicit conversion
|
||||
//- Implicit construct for the given dictionary context
|
||||
Searcher(dict_pointer dict) noexcept
|
||||
:
|
||||
dict_(dict),
|
||||
@ -212,6 +211,7 @@ public:
|
||||
bool good() const noexcept { return eptr_; }
|
||||
|
||||
//- True if entry was found
|
||||
// \deprecated(2019-01) - prefer good() method
|
||||
bool found() const noexcept { return eptr_; }
|
||||
|
||||
//- The containing dictionary context
|
||||
@ -229,19 +229,32 @@ public:
|
||||
return (eptr_ && eptr_->dictPtr());
|
||||
}
|
||||
|
||||
//- True if found entry is a stream.
|
||||
bool isStream() const noexcept
|
||||
{
|
||||
return (eptr_ && eptr_->streamPtr());
|
||||
}
|
||||
|
||||
//- Pointer to the found entry as a dictionary, nullptr otherwise
|
||||
dict_pointer dictPtr() const noexcept
|
||||
{
|
||||
return eptr_ ? eptr_->dictPtr() : nullptr;
|
||||
return (eptr_ ? eptr_->dictPtr() : nullptr);
|
||||
}
|
||||
|
||||
//- Reference the found entry as a dictionary.
|
||||
// (Error if not found, or not a dictionary).
|
||||
dict_reference dict() const
|
||||
//- Pointer to the found entry as a stream, nullptr otherwise
|
||||
ITstream* streamPtr() const noexcept
|
||||
{
|
||||
return eptr_->dict();
|
||||
return (eptr_ ? eptr_->streamPtr() : nullptr);
|
||||
}
|
||||
|
||||
//- Return the found entry as a dictionary.
|
||||
//- Error if not found, or not a dictionary.
|
||||
dict_reference dict() const { return eptr_->dict(); }
|
||||
|
||||
//- Return the found entry as a ITstream.
|
||||
//- Error if not found, or not a stream.
|
||||
ITstream& stream() const { return eptr_->stream(); }
|
||||
|
||||
//- Permit an explicit cast to the other (const/non-const) searcher
|
||||
explicit operator const Searcher<!Const>&() const
|
||||
{
|
||||
@ -249,16 +262,10 @@ public:
|
||||
}
|
||||
|
||||
//- A pointer to the entry (nullptr if not found)
|
||||
pointer operator->() const noexcept
|
||||
{
|
||||
return eptr_;
|
||||
}
|
||||
pointer operator->() const noexcept { return eptr_; }
|
||||
|
||||
//- A reference to the entry (Error if not found)
|
||||
reference operator*() const
|
||||
{
|
||||
return *eptr_;
|
||||
}
|
||||
reference operator*() const { return *eptr_; }
|
||||
};
|
||||
|
||||
|
||||
@ -557,7 +564,7 @@ public:
|
||||
) const;
|
||||
|
||||
//- Find and return a sub-dictionary pointer if present
|
||||
//- (and a sub-dictionary) otherwise return nullptr.
|
||||
//- (and it is a dictionary) otherwise return nullptr.
|
||||
//
|
||||
// \param keyword the keyword to search for
|
||||
// \param matchOpt search mode (default: non-recursive with patterns)
|
||||
@ -570,7 +577,7 @@ public:
|
||||
) const;
|
||||
|
||||
//- Find and return a sub-dictionary pointer if present
|
||||
//- (and a sub-dictionary) otherwise return nullptr.
|
||||
//- (and it is a dictionary) otherwise return nullptr.
|
||||
//
|
||||
// \param keyword the keyword to search for
|
||||
// \param matchOpt search mode (default: non-recursive with patterns)
|
||||
@ -582,13 +589,14 @@ public:
|
||||
enum keyType::option matchOpt = keyType::REGEX
|
||||
);
|
||||
|
||||
//- Find a sub-dictionary.
|
||||
//- Find and return an entry stream if present
|
||||
//- (and it is a stream) otherwise return nullptr.
|
||||
//
|
||||
// \param keyword the keyword to search for
|
||||
// \param matchOpt search mode (default: non-recursive with patterns)
|
||||
//
|
||||
// \return true if the sub-dictionary was found
|
||||
inline bool isDict
|
||||
// \return pointer to ITstream or a nullptr
|
||||
inline ITstream* findStream
|
||||
(
|
||||
const word& keyword,
|
||||
enum keyType::option matchOpt = keyType::REGEX
|
||||
@ -1283,7 +1291,7 @@ public:
|
||||
|
||||
// Shortcuts - when a templated classes also inherits from a dictionary
|
||||
|
||||
#undef defineDictionaryGetter
|
||||
#undef defineDictionaryGetter
|
||||
#define defineDictionaryGetter(Func, Type) \
|
||||
/*! \brief Same as get\<Type\>(const word&, keyType::option) */ \
|
||||
Type Func \
|
||||
@ -1307,6 +1315,18 @@ public:
|
||||
|
||||
// Housekeeping
|
||||
|
||||
//- Check for existence of a sub-dictionary.
|
||||
//- Generally prefer findDict() for more flexibility.
|
||||
FOAM_DEPRECATED_STRICT(2024-05, "findDict()")
|
||||
bool isDict
|
||||
(
|
||||
const word& keyword,
|
||||
enum keyType::option matchOpt = keyType::REGEX
|
||||
) const
|
||||
{
|
||||
return static_cast<bool>(findDict(keyword, matchOpt));
|
||||
}
|
||||
|
||||
//- Same as getOrDefault()
|
||||
template<class T>
|
||||
FOAM_DEPRECATED_STRICT(2019-06, "getOrDefault()")
|
||||
@ -1320,7 +1340,6 @@ public:
|
||||
return getOrDefault<T>(keyword, deflt, matchOpt);
|
||||
}
|
||||
|
||||
|
||||
//- Same as getOrAdd()
|
||||
template<class T>
|
||||
FOAM_DEPRECATED_STRICT(2019-06, "getOrAdd()")
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2021-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2021-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -147,13 +147,13 @@ inline Foam::dictionary* Foam::dictionary::findDict
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::dictionary::isDict
|
||||
inline Foam::ITstream* Foam::dictionary::findStream
|
||||
(
|
||||
const word& keyword,
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
return static_cast<bool>(findDict(keyword, matchOpt));
|
||||
return csearch(keyword, matchOpt).streamPtr();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -214,32 +214,34 @@ public:
|
||||
virtual label endLineNumber() const = 0;
|
||||
|
||||
|
||||
//- Return true if this entry is a stream
|
||||
virtual bool isStream() const noexcept { return false; }
|
||||
//- True if this entry is a stream
|
||||
virtual bool isStream() const noexcept { return this->streamPtr(); }
|
||||
|
||||
//- Return pointer to token stream, if entry is a primitive entry
|
||||
// Return nullptr if the entry is not a primitive entry
|
||||
virtual ITstream* streamPtr() const { return nullptr; }
|
||||
//- Return pointer to token stream, if it is a primitive entry,
|
||||
//- otherwise return nullptr
|
||||
virtual ITstream* streamPtr() const noexcept { return nullptr; }
|
||||
|
||||
//- Return token stream, if entry is a primitive entry
|
||||
virtual ITstream& stream() const = 0;
|
||||
|
||||
|
||||
//- Return true if this entry is a dictionary
|
||||
//- True if this entry is a dictionary
|
||||
virtual bool isDict() const noexcept { return this->dictPtr(); }
|
||||
|
||||
//- Return pointer to dictionary, if entry is a dictionary.
|
||||
// Return nullptr if the entry is not a dictionary.
|
||||
//- Return pointer to dictionary, if entry is a dictionary,
|
||||
//- otherwise return nullptr.
|
||||
virtual const dictionary* dictPtr() const noexcept { return nullptr; }
|
||||
|
||||
//- Return non-const pointer to dictionary, if entry is a dictionary
|
||||
// Return nullptr if the entry is not a dictionary.
|
||||
//- Return non-const pointer to dictionary, if entry is a dictionary,
|
||||
//- otherwise return nullptr.
|
||||
virtual dictionary* dictPtr() noexcept { return nullptr; }
|
||||
|
||||
//- Return dictionary, if entry is a dictionary
|
||||
//- Return dictionary, if entry is a dictionary,
|
||||
//- otherwise Fatal.
|
||||
virtual const dictionary& dict() const = 0;
|
||||
|
||||
//- Return non-const access to dictionary, if entry is a dictionary
|
||||
//- Return non-const access to dictionary, if entry is a dictionary,
|
||||
//- otherwise Fatal.
|
||||
virtual dictionary& dict() = 0;
|
||||
|
||||
|
||||
|
||||
@ -247,7 +247,7 @@ bool Foam::entry::New
|
||||
if (finder.good())
|
||||
{
|
||||
// Read as primitiveEntry
|
||||
const keyType newKeyword(finder.ptr()->stream());
|
||||
const keyType newKeyword(finder.stream());
|
||||
|
||||
return parentDict.add
|
||||
(
|
||||
|
||||
@ -273,7 +273,7 @@ Foam::primitiveEntry::primitiveEntry
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::ITstream* Foam::primitiveEntry::streamPtr() const
|
||||
Foam::ITstream* Foam::primitiveEntry::streamPtr() const noexcept
|
||||
{
|
||||
ITstream* ptr = const_cast<primitiveEntry*>(this);
|
||||
ptr->seek(0);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user