Compare commits
6 Commits
feature-gm
...
feature-am
| Author | SHA1 | Date | |
|---|---|---|---|
| 1307c4eb2e | |||
| de8dd7a5cf | |||
| a083ebb7bf | |||
| 279abca7fa | |||
| 8c89c8f417 | |||
| e44184e626 |
@ -1,2 +1,2 @@
|
||||
api=2402
|
||||
patch=240522
|
||||
api=2401
|
||||
patch=240220
|
||||
|
||||
@ -188,6 +188,8 @@ 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"
|
||||
@ -278,6 +280,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
IOFieldRef<vector>(ioOutput, mesh.points()).write();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-OCountStream.cxx
|
||||
Test-OCountStream.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-OCountStream
|
||||
|
||||
@ -65,11 +65,11 @@ int main(int argc, char *argv[])
|
||||
|
||||
OCountStream cnt;
|
||||
OCharStream cstr;
|
||||
OStringStream sstr;
|
||||
OStringStream str;
|
||||
ocountstream plain;
|
||||
|
||||
generateOutput(cstr);
|
||||
generateOutput(sstr);
|
||||
generateOutput(str);
|
||||
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: " << label(sstr.count()) << " chars" << nl
|
||||
<< "via string-stream: " << str.str().size() << " chars" << nl
|
||||
<< "via ocountstream: " << plain.count() << " chars" << endl;
|
||||
|
||||
fileName outputName;
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2022-2024 OpenCFD Ltd.
|
||||
Copyright (C) 2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -32,14 +32,10 @@ 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>
|
||||
@ -59,150 +55,25 @@ 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-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("append", "Use append mode");
|
||||
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"))
|
||||
@ -212,11 +83,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
IOstreamOption::appendType append =
|
||||
(
|
||||
args.found("append-app") ? IOstreamOption::APPEND_APP
|
||||
: args.found("append-ate") ? IOstreamOption::APPEND_ATE
|
||||
: IOstreamOption::NO_APPEND
|
||||
args.found("append")
|
||||
? IOstreamOption::APPEND
|
||||
: IOstreamOption::NON_APPEND
|
||||
);
|
||||
|
||||
IOstreamOption::atomicType atomic =
|
||||
(
|
||||
args.found("atomic")
|
||||
@ -227,6 +97,7 @@ 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");
|
||||
@ -243,31 +114,16 @@ int main(int argc, char *argv[])
|
||||
append
|
||||
);
|
||||
|
||||
generateOverwriteContent(os, with_seekend, seek_out);
|
||||
}
|
||||
os << "=========================" << endl;
|
||||
|
||||
{
|
||||
OFstream os
|
||||
(
|
||||
atomic,
|
||||
baseDir/"Test1-app.txt",
|
||||
streamOpt,
|
||||
IOstreamOption::APPEND_APP
|
||||
);
|
||||
InfoErr<< "open: " << os.name() << endl;
|
||||
InfoErr<< "... sleep" << endl;
|
||||
|
||||
generateOverwriteContent(os, with_seekend, seek_out);
|
||||
}
|
||||
listFiles(baseDir);
|
||||
|
||||
{
|
||||
OFstream os
|
||||
(
|
||||
atomic,
|
||||
baseDir/"Test1-ate.txt",
|
||||
streamOpt,
|
||||
IOstreamOption::APPEND_ATE
|
||||
);
|
||||
sleep(2);
|
||||
|
||||
generateOverwriteContent(os, with_seekend, seek_out);
|
||||
os << "+++++++++++++++++++++++++++++++++++" << endl;
|
||||
}
|
||||
|
||||
{
|
||||
@ -276,21 +132,39 @@ int main(int argc, char *argv[])
|
||||
atomic,
|
||||
baseDir/"Test2.txt",
|
||||
streamOpt
|
||||
// NON_APPEND
|
||||
);
|
||||
|
||||
generateContent(os, with_seekend);
|
||||
}
|
||||
os << "=========================" << endl;
|
||||
|
||||
InfoErr<< "open: " << os.name() << endl;
|
||||
InfoErr<< "... sleep" << endl;
|
||||
|
||||
listFiles(baseDir);
|
||||
|
||||
sleep(2);
|
||||
|
||||
os << "+++++++++++++++++++++++++++++++++++" << endl;
|
||||
}
|
||||
{
|
||||
OFstream os
|
||||
(
|
||||
atomic,
|
||||
baseDir/"Test3.txt",
|
||||
streamOpt,
|
||||
IOstreamOption::APPEND_APP
|
||||
IOstreamOption::APPEND
|
||||
);
|
||||
|
||||
generateContent(os, with_seekend, with_seekend);
|
||||
os << "=========================" << endl;
|
||||
|
||||
InfoErr<< "open: " << os.name() << endl;
|
||||
InfoErr<< "... sleep" << endl;
|
||||
|
||||
listFiles(baseDir);
|
||||
|
||||
sleep(2);
|
||||
|
||||
os << "+++++++++++++++++++++++++++++++++++" << endl;
|
||||
}
|
||||
{
|
||||
OFstream os
|
||||
@ -300,17 +174,35 @@ int main(int argc, char *argv[])
|
||||
IOstreamOption::COMPRESSED
|
||||
);
|
||||
|
||||
// No seekend with COMPRESSED
|
||||
generateContent(os, false);
|
||||
os << "=========================" << endl;
|
||||
|
||||
InfoErr<< "open: " << os.name() << endl;
|
||||
InfoErr<< "... sleep" << endl;
|
||||
|
||||
listFiles(baseDir);
|
||||
|
||||
sleep(2);
|
||||
|
||||
os << "+++++++++++++++++++++++++++++++++++" << endl;
|
||||
}
|
||||
{
|
||||
OFstream os
|
||||
(
|
||||
IOstreamOption::ATOMIC,
|
||||
baseDir/"Test5.txt"
|
||||
// ASCII UNCOMPRESSED NON_APPEND
|
||||
);
|
||||
|
||||
generateContent(os, with_seekend);
|
||||
os << "=========================" << endl;
|
||||
|
||||
InfoErr<< "open: " << os.name() << endl;
|
||||
InfoErr<< "... sleep" << endl;
|
||||
|
||||
listFiles(baseDir);
|
||||
|
||||
sleep(2);
|
||||
|
||||
os << "+++++++++++++++++++++++++++++++++++" << endl;
|
||||
}
|
||||
|
||||
Info<< nl << "done:" << endl;
|
||||
|
||||
@ -201,6 +201,7 @@ using namespace Foam;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#include "addTimeOptions.H"
|
||||
argList::addArgument("patch");
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
@ -53,37 +53,46 @@ int main(int argc, char *argv[])
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
word coherentInst;
|
||||
fileName coherentInst;
|
||||
coherentInst =
|
||||
(
|
||||
runTime.findInstance
|
||||
(
|
||||
polyMesh::meshSubDir,
|
||||
"coherent",
|
||||
IOobject::READ_IF_PRESENT,
|
||||
word::null, // No stop instance
|
||||
false // No "constant" fallback (word::null instead)
|
||||
IOobject::READ_IF_PRESENT
|
||||
)
|
||||
);
|
||||
|
||||
Info<< "Found coherent \"" << coherentInst << '"' << nl;
|
||||
// Unfortunately with READ_IF_PRESENT, cannot tell if the file
|
||||
// was actually found or not
|
||||
|
||||
Info<< "check: " << (coherentInst/polyMesh::meshSubDir/"coherent") << nl;
|
||||
|
||||
if (!Foam::isFile(coherentInst/polyMesh::meshSubDir/"coherent"))
|
||||
{
|
||||
coherentInst.clear();
|
||||
}
|
||||
|
||||
Info<< "found coherent: " << coherentInst << nl;
|
||||
|
||||
PtrList<entry> entries;
|
||||
|
||||
if (!coherentInst.empty())
|
||||
{
|
||||
dictionary coherent =
|
||||
IOdictionary::readContents
|
||||
IOdictionary coherent
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"coherent",
|
||||
coherentInst,
|
||||
polyMesh::meshSubDir,
|
||||
runTime,
|
||||
IOobject::MUST_READ
|
||||
)
|
||||
);
|
||||
"coherent",
|
||||
coherentInst,
|
||||
polyMesh::meshSubDir,
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
)
|
||||
);
|
||||
|
||||
ITstream& is = coherent.lookup("boundary");
|
||||
is >> entries;
|
||||
@ -96,7 +105,7 @@ int main(int argc, char *argv[])
|
||||
Info<< "size: " << polyBoundaryMeshEntries::patchSizes(entries) << nl;
|
||||
Info<< nl;
|
||||
|
||||
word boundaryInst;
|
||||
fileName boundaryInst;
|
||||
boundaryInst =
|
||||
(
|
||||
runTime.findInstance
|
||||
@ -107,7 +116,7 @@ int main(int argc, char *argv[])
|
||||
)
|
||||
);
|
||||
|
||||
Info<< "Found boundary: \"" << boundaryInst << '"' << nl;
|
||||
Info<< "found boundary: " << boundaryInst << nl;
|
||||
|
||||
polyBoundaryMeshEntries pbm
|
||||
(
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2024 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2023 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-checkDecomposePar
|
||||
checkDecomposePar
|
||||
|
||||
Group
|
||||
grpParallelUtilities
|
||||
@ -35,9 +35,8 @@ Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "timeSelector.H"
|
||||
#include "polyMesh.H"
|
||||
#include "OSspecific.H"
|
||||
#include "fvCFD.H"
|
||||
#include "cpuTime.H"
|
||||
#include "IFstream.H"
|
||||
#include "regionProperties.H"
|
||||
@ -45,14 +44,10 @@ 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"
|
||||
@ -70,6 +65,9 @@ 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);
|
||||
@ -77,8 +75,8 @@ int main(int argc, char *argv[])
|
||||
// Set time from database
|
||||
#include "createTime.H"
|
||||
|
||||
// Allow override of time from specified time options, or no-op
|
||||
timeSelector::setTimeIfPresent(runTime, args);
|
||||
// Allow override of time
|
||||
instantList times = timeSelector::selectIfPresent(runTime, args);
|
||||
|
||||
// Allow override of decomposeParDict location
|
||||
const fileName decompDictFile =
|
||||
@ -97,7 +95,7 @@ int main(int argc, char *argv[])
|
||||
Info<< "\n\nDecomposing mesh " << regionName << nl << endl;
|
||||
Info<< "Create mesh..." << flush;
|
||||
|
||||
polyMesh mesh
|
||||
fvMesh mesh
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
@ -113,7 +111,7 @@ int main(int argc, char *argv[])
|
||||
Info<< " nCells = " << mesh.nCells() << endl;
|
||||
|
||||
// Expected format is a simple ASCII list
|
||||
cellToProc.resize(mesh.nCells());
|
||||
cellToProc.setSize(mesh.nCells());
|
||||
{
|
||||
IFstream is(decompFile);
|
||||
|
||||
|
||||
@ -123,7 +123,7 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
|
||||
Info<< testInput << nl;
|
||||
auto args = stringOps::splitSpace(testInput);
|
||||
SubStrings<string> args = stringOps::splitSpace(testInput);
|
||||
Info<< "split into " << args.size() << " args" << nl;
|
||||
|
||||
CStringList inC(args);
|
||||
|
||||
3
applications/test/dimField/Make/files
Normal file
3
applications/test/dimField/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
Test-dimField.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-dimField
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020-2024 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2022 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-dimField1
|
||||
Test-dimField
|
||||
|
||||
Description
|
||||
Simple tests for DimensionedField
|
||||
@ -52,12 +52,7 @@ 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"
|
||||
|
||||
@ -65,23 +60,19 @@ int main(int argc, char *argv[])
|
||||
Info<< "Tensor field\n" << endl;
|
||||
DimensionedField<tensor, volMesh> tensorfld
|
||||
(
|
||||
mesh.newIOobject
|
||||
IOobject
|
||||
(
|
||||
"tensor",
|
||||
{ IOobject::READ_IF_PRESENT, IOobject::NO_WRITE }
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
{ IOobject::READ_IF_PRESENT, IOobject::NO_REGISTER }
|
||||
),
|
||||
mesh,
|
||||
dimensioned<tensor>(dimless, tensor(1,2,3,4,5,6,7,8,9))
|
||||
);
|
||||
|
||||
if (doWrite)
|
||||
{
|
||||
tensorfld.write();
|
||||
}
|
||||
|
||||
|
||||
Info<< nl;
|
||||
Info().beginBlock("transformed") << tensorfld.T();
|
||||
Info().beginBlock("transformed")
|
||||
<< tensorfld.T() << nl;
|
||||
Info().endBlock();
|
||||
|
||||
{
|
||||
@ -93,8 +84,8 @@ int main(int argc, char *argv[])
|
||||
dimensioned<scalar>(14)
|
||||
);
|
||||
|
||||
Info<< nl;
|
||||
Info().beginBlock(tfld().type()) << tfld;
|
||||
Info().beginBlock(tfld().type())
|
||||
<< tfld << nl;
|
||||
Info().endBlock();
|
||||
}
|
||||
|
||||
@ -107,8 +98,8 @@ int main(int argc, char *argv[])
|
||||
dimensioned<scalar>(5)
|
||||
);
|
||||
|
||||
Info<< nl;
|
||||
Info().beginBlock(tfld().type()) << tfld();
|
||||
Info().beginBlock(tfld().type())
|
||||
<< tfld() << nl;
|
||||
Info().endBlock();
|
||||
|
||||
// From dissimilar types
|
||||
@ -120,8 +111,8 @@ int main(int argc, char *argv[])
|
||||
dimensioned<vector>(Zero)
|
||||
);
|
||||
|
||||
Info<< nl;
|
||||
Info().beginBlock(tfld2().type()) << tfld2();
|
||||
Info().beginBlock(tfld2().type())
|
||||
<< tfld2() << nl;
|
||||
Info().endBlock();
|
||||
}
|
||||
}
|
||||
@ -131,13 +122,20 @@ int main(int argc, char *argv[])
|
||||
Info<< "uint8 field\n" << endl;
|
||||
DimensionedField<uint8_t, volMesh> statefld
|
||||
(
|
||||
mesh.newIOobject("state")
|
||||
IOobject
|
||||
(
|
||||
"state",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensioned<uint8_t>(dimless, uint8_t{100})
|
||||
);
|
||||
|
||||
Info<< nl;
|
||||
Info().beginBlock("stateField") << statefld;
|
||||
Info().beginBlock("stateField")
|
||||
<< statefld << nl;
|
||||
Info().endBlock();
|
||||
}
|
||||
#endif
|
||||
@ -1,3 +0,0 @@
|
||||
Test-dimField1.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-dimField1
|
||||
3
applications/test/ensightFile/Make/files
Normal file
3
applications/test/ensightFile/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
Test-ensightFile.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-ensightFile
|
||||
8
applications/test/ensightFile/Make/options
Normal file
8
applications/test/ensightFile/Make/options
Normal file
@ -0,0 +1,8 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/fileFormats/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/conversion/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lmeshTools \
|
||||
-lconversion
|
||||
@ -24,10 +24,10 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Application
|
||||
Test-ensightFileName
|
||||
Test-ensightFile
|
||||
|
||||
Description
|
||||
Check cleanup of ensight file and variable names
|
||||
check cleanup of ensight file and variable names
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
Test-ensightFile1.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-ensightFile1
|
||||
@ -1,5 +0,0 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/fileFormats/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfileFormats
|
||||
@ -1,137 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,3 +0,0 @@
|
||||
Test-ensightFileName.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-ensightFileName
|
||||
@ -1,5 +0,0 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/fileFormats/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfileFormats
|
||||
@ -32,7 +32,6 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "timeSelector.H"
|
||||
#include "fvMesh.H"
|
||||
#include "volFields.H"
|
||||
#include "Time.H"
|
||||
@ -127,14 +126,14 @@ void writeStencilStats(const labelListList& stencil)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
timeSelector::addOptions_singleTime(); // Single-time options
|
||||
|
||||
#include "addTimeOptions.H"
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
// Set time from specified time options, or force start from Time=0
|
||||
timeSelector::setTimeIfPresent(runTime, args, true);
|
||||
|
||||
// Get times list
|
||||
instantList Times = runTime.times();
|
||||
#include "checkTimeOptions.H"
|
||||
runTime.setTime(Times[startTime], startTime);
|
||||
#include "createMesh.H"
|
||||
|
||||
// Force calculation of extended edge addressing
|
||||
|
||||
@ -32,7 +32,6 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "timeSelector.H"
|
||||
#include "fvMesh.H"
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
@ -108,16 +107,14 @@ void writeStencilStats(const labelListList& stencil)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noFunctionObjects(); // Never use function objects
|
||||
|
||||
timeSelector::addOptions_singleTime(); // Single-time options
|
||||
|
||||
#include "addTimeOptions.H"
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
// Set time from specified time options, or force start from Time=0
|
||||
timeSelector::setTimeIfPresent(runTime, args, true);
|
||||
|
||||
// Get times list
|
||||
instantList Times = runTime.times();
|
||||
#include "checkTimeOptions.H"
|
||||
runTime.setTime(Times[startTime], startTime);
|
||||
#include "createMesh.H"
|
||||
|
||||
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
Test-faMesh-try.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-faMesh-try
|
||||
@ -1,7 +0,0 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteArea/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteArea \
|
||||
-lmeshTools
|
||||
@ -1,63 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2023 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-faMesh-try
|
||||
|
||||
Description
|
||||
Test for loading of faMesh
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "faMesh.H"
|
||||
#include "polyMesh.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#include "addRegionOption.H"
|
||||
#include "addFaRegionOption.H"
|
||||
#include "setRootCase.H"
|
||||
|
||||
#include "createTime.H"
|
||||
#include "createNamedPolyMesh.H"
|
||||
|
||||
#include "getFaRegionOption.H"
|
||||
|
||||
autoPtr<faMesh> aMeshPtr = faMesh::TryNew(areaRegionName, mesh);
|
||||
|
||||
Info<< "area-mesh: " << Switch::name(aMeshPtr) << nl;
|
||||
|
||||
Info<< "\nEnd\n" << nl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,3 +0,0 @@
|
||||
Test-faMeshesRegistry.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-faMeshesRegistry
|
||||
@ -1,7 +0,0 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteArea/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteArea \
|
||||
-lmeshTools
|
||||
@ -1,68 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2023 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-faMeshesRegistry
|
||||
|
||||
Description
|
||||
Basic tests for faMeshesRegistry
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "faMesh.H"
|
||||
#include "faMeshesRegistry.H"
|
||||
#include "polyMesh.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#include "setRootCase.H"
|
||||
|
||||
#include "createTime.H"
|
||||
#include "createPolyMesh.H"
|
||||
|
||||
Info<< "mesh 0: " << mesh.sortedNames() << nl;
|
||||
|
||||
faMeshesRegistry& reg =
|
||||
const_cast<faMeshesRegistry&>(faMeshesRegistry::New(mesh));
|
||||
|
||||
// faMeshesRegistry faReg = faMeshesRegistry(mesh);
|
||||
|
||||
faMesh mesh1(mesh, Foam::zero{});
|
||||
faMesh mesh2("mesh2", mesh, Foam::zero{});
|
||||
|
||||
reg.write();
|
||||
|
||||
Info<< "\nEnd\n" << nl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -5,5 +5,4 @@ EXE_INC = \
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-lmeshTools \
|
||||
-ldynamicMesh
|
||||
|
||||
@ -32,7 +32,6 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "timeSelector.H"
|
||||
#include "fvMesh.H"
|
||||
#include "volFields.H"
|
||||
#include "Time.H"
|
||||
@ -52,33 +51,22 @@ using namespace Foam;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
timeSelector::addOptions_singleTime(); // Single-time options
|
||||
|
||||
argList::addBoolOption
|
||||
(
|
||||
"inflate",
|
||||
"Use inflation/deflation for deleting cells"
|
||||
);
|
||||
|
||||
#include "addTimeOptions.H"
|
||||
argList::addArgument("inflate (true|false)");
|
||||
#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 bool inflate = args.found("inflate");
|
||||
const Switch inflate(args[1]);
|
||||
|
||||
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 auto items = stringOps::splitAny(str, " ,;");
|
||||
const SubStrings<std::string> items = stringOps::splitAny(str, " ,;");
|
||||
|
||||
DynamicList<PrimitiveType> values(items.size());
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2023-2024 OpenCFD Ltd.
|
||||
Copyright (C) 2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -50,9 +50,6 @@ void printInfo(const meshObjects::gravity& g)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::addBoolOption("checkout", "Test checkout with release");
|
||||
argList::addBoolOption("release", "Test release instead of delete");
|
||||
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
@ -73,81 +70,14 @@ int main(int argc, char *argv[])
|
||||
printInfo(g);
|
||||
}
|
||||
|
||||
Pout<< "registered:"
|
||||
<< flatOutput(runTime.sortedToc()) << nl << endl;
|
||||
Pout<< "registered:" << flatOutput(runTime.sortedToc()) << nl << endl;
|
||||
}
|
||||
|
||||
std::unique_ptr<meshObjects::gravity> release1;
|
||||
std::unique_ptr<meshObjects::gravity> release2;
|
||||
meshObjects::gravity::Delete("g", runTime);
|
||||
meshObjects::gravity::Delete("something-not-in-registry", runTime);
|
||||
|
||||
if (args.found("release"))
|
||||
{
|
||||
// Ugly!
|
||||
typedef
|
||||
MeshObject<Time, TopologicalMeshObject, meshObjects::gravity>
|
||||
parent_type;
|
||||
|
||||
release1 = meshObjects::gravity::Release("g", runTime);
|
||||
release2 = meshObjects::gravity::Release("#none#", runTime);
|
||||
|
||||
Info<< "release: " << Switch::name(bool(release1))
|
||||
<< ", " << Switch::name(bool(release2)) << nl;
|
||||
|
||||
Info<< "after Release: "
|
||||
<< flatOutput(runTime.sortedToc()) << endl;
|
||||
|
||||
// Do checkout by hand (ugly)
|
||||
if (args.found("checkout"))
|
||||
{
|
||||
if (release1)
|
||||
{
|
||||
release1->parent_type::checkOut();
|
||||
}
|
||||
|
||||
if (release2)
|
||||
{
|
||||
release2->parent_type::checkOut();
|
||||
}
|
||||
|
||||
Info<< "after checkout: "
|
||||
<< flatOutput(runTime.sortedToc()) << endl;
|
||||
}
|
||||
}
|
||||
else if (args.found("checkout"))
|
||||
{
|
||||
// Do checkout as part of release
|
||||
release1 = meshObjects::gravity::Release("g", runTime, true);
|
||||
release2 = meshObjects::gravity::Release("#none#", runTime, true);
|
||||
|
||||
Info<< "release: " << Switch::name(bool(release1))
|
||||
<< ", " << Switch::name(bool(release2)) << nl;
|
||||
|
||||
Info<< "after Release/Checkout(true) : "
|
||||
<< flatOutput(runTime.sortedToc()) << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
meshObjects::gravity::Delete("g", runTime);
|
||||
meshObjects::gravity::Delete("#none#", runTime);
|
||||
|
||||
Info<< "after Delete: "
|
||||
<< flatOutput(runTime.sortedToc()) << endl;
|
||||
}
|
||||
|
||||
|
||||
if (meshObjects::gravity::Store(std::move(release1)))
|
||||
{
|
||||
Info<< "Store pointer" << endl;
|
||||
}
|
||||
|
||||
if (release2)
|
||||
{
|
||||
release2.reset();
|
||||
Info<< "Clear pointer" << endl;
|
||||
}
|
||||
|
||||
Info<< "Before exit: "
|
||||
<< flatOutput(runTime.sortedToc()) << endl;
|
||||
Info<< "after Delete" << nl;
|
||||
Pout<< "registered:" << flatOutput(runTime.sortedToc()) << endl;
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
|
||||
@ -5,5 +5,4 @@ EXE_INC = \
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-lmeshTools \
|
||||
-ldynamicMesh
|
||||
|
||||
@ -33,7 +33,6 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "timeSelector.H"
|
||||
#include "Time.H"
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
@ -53,28 +52,21 @@ using namespace Foam;
|
||||
// Main program:
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
timeSelector::addOptions_singleTime(); // Single-time options
|
||||
|
||||
argList::addBoolOption
|
||||
(
|
||||
"inflate",
|
||||
"Use inflation/deflation for splitting/deleting cells"
|
||||
);
|
||||
|
||||
#include "addTimeOptions.H"
|
||||
argList::addArgument("inflate (true|false)");
|
||||
#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 bool inflate = args.found("inflate");
|
||||
|
||||
const pointConstraints& pc = pointConstraints::New(pointMesh::New(mesh));
|
||||
|
||||
const Switch inflate(args[1]);
|
||||
|
||||
if (inflate)
|
||||
{
|
||||
Info<< "Splitting/deleting cells using inflation/deflation"
|
||||
<< nl << endl;
|
||||
Info<< "Splitting/deleting cells using inflation/deflation" << nl
|
||||
<< endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -83,8 +75,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
|
||||
const pointConstraints& pc = pointConstraints::New(pointMesh::New(mesh));
|
||||
|
||||
Random rndGen(0);
|
||||
|
||||
|
||||
|
||||
@ -51,6 +51,7 @@ 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())
|
||||
{
|
||||
List<namedDictionary> list(dEntry.stream());
|
||||
|
||||
Info<< "input: " << dEntry << nl
|
||||
<< "list: " << list << nl;
|
||||
continue;
|
||||
}
|
||||
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-2024 OpenCFD Ltd.
|
||||
Copyright (C) 2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -44,62 +44,175 @@ Description
|
||||
using namespace Foam;
|
||||
|
||||
|
||||
//- 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
|
||||
// Looks like Pstream::exchangeBuf
|
||||
template<class T>
|
||||
void do_exchangeBuf
|
||||
(
|
||||
const std::size_t max_bytes = std::size_t(0)
|
||||
) noexcept
|
||||
const label sendSize,
|
||||
const char* sendData,
|
||||
const label recvSize,
|
||||
char* recvData,
|
||||
const int tag,
|
||||
const label comm,
|
||||
const bool wait
|
||||
)
|
||||
{
|
||||
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
|
||||
);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//- 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
|
||||
// Looks like Pstream::exchangeContainer
|
||||
template<class Container, class T>
|
||||
void do_exchangeContainer
|
||||
(
|
||||
const int64_t max_bytes
|
||||
) noexcept
|
||||
const Container& sendData,
|
||||
const label recvSize,
|
||||
Container& recvData,
|
||||
const int tag,
|
||||
const label comm,
|
||||
const bool wait
|
||||
)
|
||||
{
|
||||
return
|
||||
(
|
||||
(max_bytes < 0) // (numBytes fewer than INT_MAX)
|
||||
? std::size_t(INT_MAX + max_bytes)
|
||||
: std::size_t(max_bytes)
|
||||
);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Container, class Type>
|
||||
template<class Container, class T>
|
||||
void broadcast_chunks
|
||||
(
|
||||
Container& sendData,
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm
|
||||
const int64_t maxComms_bytes = UPstream::maxCommsSize
|
||||
const label comm = UPstream::worldComm,
|
||||
const bool wait = true
|
||||
)
|
||||
{
|
||||
// OR static_assert(is_contiguous<T>::value, "Contiguous data only!")
|
||||
if (!is_contiguous<Type>::value)
|
||||
if (!is_contiguous<T>::value)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Contiguous data only." << sizeof(Type)
|
||||
<< Foam::abort(FatalError);
|
||||
<< "Contiguous data only." << sizeof(T) << Foam::abort(FatalError);
|
||||
}
|
||||
|
||||
if (maxComms_bytes == 0)
|
||||
if (UPstream::maxCommsSize <= 0)
|
||||
{
|
||||
// Do in one go
|
||||
Info<< "send " << sendData.size() << " elements in one go" << endl;
|
||||
@ -114,90 +227,93 @@ 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.
|
||||
|
||||
// The chunk size (number of elements) corresponding to max byte transfer
|
||||
// Is zero for non-chunked exchanges.
|
||||
const std::size_t chunkSize
|
||||
// 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
|
||||
(
|
||||
PstreamDetail_maxTransferCount<Type>
|
||||
max
|
||||
(
|
||||
PstreamDetail_maxTransferBytes(maxComms_bytes)
|
||||
static_cast<label>(1),
|
||||
static_cast<label>(UPstream::maxCommsSize/sizeof(T))
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
if (chunkSize)
|
||||
label nChunks(0);
|
||||
{
|
||||
// Get max send count (elements)
|
||||
// forAll(sendBufs, proci)
|
||||
// {
|
||||
// if (proci != Pstream::myProcNo(comm))
|
||||
// {
|
||||
// nChunks = max(nChunks, sendBufs[proci].size());
|
||||
// }
|
||||
// }
|
||||
nChunks = sendSize;
|
||||
|
||||
// Convert from send count (elements) to number of chunks.
|
||||
// Can normally calculate with (count-1), but add some safety
|
||||
label nChunks = 1 + (sendSize/label(chunkSize));
|
||||
if (nChunks)
|
||||
{
|
||||
nChunks = 1 + (nChunks/maxChunkSize);
|
||||
}
|
||||
reduce(nChunks, maxOp<label>(), tag, comm);
|
||||
|
||||
Info
|
||||
<< "send " << sendSize << " elements ("
|
||||
<< (sendSize*sizeof(Type)) << " bytes) in " << nChunks
|
||||
<< " chunks of " << label(chunkSize) << " elements ("
|
||||
<< label(chunkSize*sizeof(Type)) << " bytes) for maxCommsSize:"
|
||||
<< label(maxComms_bytes)
|
||||
<< (sendSize*sizeof(T)) << " bytes) in " << nChunks
|
||||
<< " chunks of " << maxChunkSize << " elements ("
|
||||
<< (maxChunkSize*sizeof(T)) << " bytes) for maxCommsSize:"
|
||||
<< Pstream::maxCommsSize
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
// stress-test with shortened sendSize
|
||||
// will produce useless loops, but no calls
|
||||
// sendSize /= 2;
|
||||
|
||||
typedef stdFoam::span<Type> sendType;
|
||||
label nSend(0);
|
||||
label startSend(0);
|
||||
char* charPtrSend;
|
||||
|
||||
do
|
||||
for (label iter = 0; iter < nChunks; ++iter)
|
||||
{
|
||||
sendType payload(sendData.data(), sendData.size());
|
||||
nSend = min
|
||||
(
|
||||
maxChunkSize,
|
||||
sendSize-startSend
|
||||
);
|
||||
|
||||
if (!chunkSize)
|
||||
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)
|
||||
{
|
||||
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
|
||||
);
|
||||
startSend += nSend;
|
||||
}
|
||||
}
|
||||
while (false);
|
||||
|
||||
Info<< "final" << endl;
|
||||
Info<< "final: " << startSend << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -217,7 +333,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
labelList input1;
|
||||
if (UPstream::master())
|
||||
if (Pstream::master())
|
||||
{
|
||||
input1 = identity(500);
|
||||
}
|
||||
@ -232,7 +348,7 @@ int main(int argc, char *argv[])
|
||||
// Mostly the same with PstreamBuffers
|
||||
if (false)
|
||||
{
|
||||
PstreamBuffers pBufs;
|
||||
PstreamBuffers pBufs(UPstream::commsTypes::nonBlocking);
|
||||
|
||||
labelList sendData;
|
||||
if (Pstream::master())
|
||||
|
||||
@ -62,7 +62,7 @@ scalar sumReduce
|
||||
scalar procValue;
|
||||
UIPstream::read
|
||||
(
|
||||
UPstream::commsTypes::buffered,
|
||||
UPstream::commsTypes::blocking,
|
||||
proci,
|
||||
reinterpret_cast<char*>(&procValue),
|
||||
sizeof(scalar),
|
||||
@ -79,7 +79,7 @@ scalar sumReduce
|
||||
{
|
||||
UOPstream::write
|
||||
(
|
||||
UPstream::commsTypes::buffered,
|
||||
UPstream::commsTypes::blocking,
|
||||
proci,
|
||||
reinterpret_cast<const char*>(&sum),
|
||||
sizeof(scalar),
|
||||
@ -93,7 +93,7 @@ scalar sumReduce
|
||||
{
|
||||
UOPstream::write
|
||||
(
|
||||
UPstream::commsTypes::buffered,
|
||||
UPstream::commsTypes::blocking,
|
||||
UPstream::masterNo(),
|
||||
reinterpret_cast<const char*>(&localValue),
|
||||
sizeof(scalar),
|
||||
@ -105,7 +105,7 @@ scalar sumReduce
|
||||
{
|
||||
UIPstream::read
|
||||
(
|
||||
UPstream::commsTypes::buffered,
|
||||
UPstream::commsTypes::blocking,
|
||||
UPstream::masterNo(),
|
||||
reinterpret_cast<char*>(&sum),
|
||||
sizeof(scalar),
|
||||
|
||||
@ -41,7 +41,14 @@ Description
|
||||
#include "PstreamReduceOps.H"
|
||||
#include "SHA1.H"
|
||||
|
||||
#include "openfoam_mpi.H"
|
||||
// Include MPI without any C++ bindings
|
||||
#ifndef MPICH_SKIP_MPICXX
|
||||
#define MPICH_SKIP_MPICXX
|
||||
#endif
|
||||
#ifndef OMPI_SKIP_MPICXX
|
||||
#define OMPI_SKIP_MPICXX
|
||||
#endif
|
||||
#include <mpi.h>
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
|
||||
@ -41,7 +41,14 @@ Description
|
||||
#include "StringStream.H"
|
||||
#include "Random.H"
|
||||
|
||||
#include "openfoam_mpi.H"
|
||||
// Include MPI without any C++ bindings
|
||||
#ifndef MPICH_SKIP_MPICXX
|
||||
#define MPICH_SKIP_MPICXX
|
||||
#endif
|
||||
#ifndef OMPI_SKIP_MPICXX
|
||||
#define OMPI_SKIP_MPICXX
|
||||
#endif
|
||||
#include <mpi.h>
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
|
||||
@ -130,7 +130,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (bool barrier_active = false, done = false; !done; /*nil*/)
|
||||
{
|
||||
std::pair<int, int64_t> probed =
|
||||
std::pair<int, int> 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;
|
||||
|
||||
@ -40,7 +40,14 @@ Description
|
||||
#include "Pstream.H"
|
||||
#include <iostream>
|
||||
|
||||
#include "openfoam_mpi.H"
|
||||
// Include MPI without any C++ bindings
|
||||
#ifndef MPICH_SKIP_MPICXX
|
||||
#define MPICH_SKIP_MPICXX
|
||||
#endif
|
||||
#ifndef OMPI_SKIP_MPICXX
|
||||
#define OMPI_SKIP_MPICXX
|
||||
#endif
|
||||
#include <mpi.h>
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
|
||||
@ -119,7 +119,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (bool barrier_active = false, done = false; !done; /*nil*/)
|
||||
{
|
||||
std::pair<int, int64_t> probed =
|
||||
std::pair<int, int> 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)
|
||||
{
|
||||
|
||||
@ -66,7 +66,7 @@ int main(int argc, char *argv[])
|
||||
Pstream::myProcNo()
|
||||
);
|
||||
|
||||
PstreamBuffers pBufs;
|
||||
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
|
||||
|
||||
if (!Pstream::master())
|
||||
{
|
||||
@ -150,7 +150,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Do a non-blocking send inbetween
|
||||
{
|
||||
PstreamBuffers pBufs;
|
||||
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
|
||||
|
||||
for (const int proci : Pstream::allProcs())
|
||||
{
|
||||
|
||||
@ -131,7 +131,7 @@ void testTransfer(const T& input)
|
||||
for (const int proci : UPstream::subProcs())
|
||||
{
|
||||
Perr<< "master sending to proc:" << proci << endl;
|
||||
OPstream os(UPstream::commsTypes::buffered, proci);
|
||||
OPstream os(UPstream::commsTypes::blocking, proci);
|
||||
os << data;
|
||||
}
|
||||
}
|
||||
@ -139,7 +139,7 @@ void testTransfer(const T& input)
|
||||
{
|
||||
{
|
||||
Perr<< "proc sending to master" << endl;
|
||||
OPstream os(UPstream::commsTypes::buffered, UPstream::masterNo());
|
||||
OPstream os(UPstream::commsTypes::blocking, UPstream::masterNo());
|
||||
os << data;
|
||||
}
|
||||
|
||||
@ -169,7 +169,7 @@ void testTokenized(const T& data)
|
||||
for (const int proci : UPstream::subProcs())
|
||||
{
|
||||
Perr<< "master sending to proc:" << proci << endl;
|
||||
OPstream os(UPstream::commsTypes::buffered, proci);
|
||||
OPstream os(UPstream::commsTypes::blocking, proci);
|
||||
os << tok;
|
||||
}
|
||||
}
|
||||
@ -177,7 +177,7 @@ void testTokenized(const T& data)
|
||||
{
|
||||
{
|
||||
Perr<< "proc sending to master" << endl;
|
||||
OPstream os(UPstream::commsTypes::buffered, UPstream::masterNo());
|
||||
OPstream os(UPstream::commsTypes::blocking, UPstream::masterNo());
|
||||
os << tok;
|
||||
}
|
||||
|
||||
|
||||
@ -7,6 +7,5 @@ EXE_INC = \
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-ldynamicFvMesh \
|
||||
-lsampling \
|
||||
-loverset
|
||||
|
||||
@ -56,7 +56,6 @@ Description
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "simpleControl.H"
|
||||
#include "predicates.H"
|
||||
#include "dynamicFvMesh.H"
|
||||
#include "dynamicOversetFvMesh.H"
|
||||
|
||||
@ -98,7 +97,6 @@ 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);
|
||||
}
|
||||
|
||||
@ -34,7 +34,14 @@ Description
|
||||
#include "globalMeshData.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
#include "openfoam_mpi.H"
|
||||
// Include MPI without any C++ bindings
|
||||
#ifndef MPICH_SKIP_MPICXX
|
||||
#define MPICH_SKIP_MPICXX
|
||||
#endif
|
||||
#ifndef OMPI_SKIP_MPICXX
|
||||
#define OMPI_SKIP_MPICXX
|
||||
#endif
|
||||
#include <mpi.h>
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
|
||||
@ -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-2024 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -34,7 +34,6 @@ Description
|
||||
#include "argList.H"
|
||||
#include "fileName.H"
|
||||
#include "stringOps.H"
|
||||
#include "Switch.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -66,9 +65,6 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noBanner();
|
||||
argList::noParallel();
|
||||
argList::noMandatoryArgs();
|
||||
argList::addArgument("string .. stringN");
|
||||
|
||||
argList::addOption
|
||||
(
|
||||
"any",
|
||||
@ -93,12 +89,6 @@ int main(int argc, char *argv[])
|
||||
"int",
|
||||
"test split on fixed width"
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"begin",
|
||||
"int",
|
||||
"begin offset for splits"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"slash",
|
||||
@ -114,25 +104,18 @@ int main(int argc, char *argv[])
|
||||
"empty",
|
||||
"preserve empty strings in split"
|
||||
);
|
||||
|
||||
argList args(argc, argv);
|
||||
argList args(argc, argv, false, true);
|
||||
|
||||
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"];
|
||||
@ -142,7 +125,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (label argi=1; argi < args.size(); ++argi)
|
||||
{
|
||||
auto split = stringOps::splitAny(args[argi], str, beginOffset);
|
||||
const auto split = stringOps::splitAny(args[argi], str);
|
||||
printSubStrings(args[argi], split);
|
||||
}
|
||||
|
||||
@ -161,7 +144,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (label argi=1; argi < args.size(); ++argi)
|
||||
{
|
||||
auto split = stringOps::split(args[argi], str, beginOffset);
|
||||
const auto split = stringOps::split(args[argi], str);
|
||||
printSubStrings(args[argi], split);
|
||||
}
|
||||
|
||||
@ -178,11 +161,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (label argi=1; argi < args.size(); ++argi)
|
||||
{
|
||||
auto split = stringOps::splitSpace(args[argi], beginOffset);
|
||||
printSubStrings(args[argi], split);
|
||||
|
||||
Info<< "pop_front(2)" << nl;
|
||||
split.pop_front(2);
|
||||
const auto split = stringOps::splitSpace(args[argi]);
|
||||
printSubStrings(args[argi], split);
|
||||
}
|
||||
|
||||
@ -201,8 +180,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (label argi=1; argi < args.size(); ++argi)
|
||||
{
|
||||
auto split =
|
||||
stringOps::split(args[argi], delim, beginOffset, keepEmpty);
|
||||
const auto split = stringOps::split(args[argi], delim, keepEmpty);
|
||||
printSubStrings(args[argi], split);
|
||||
}
|
||||
|
||||
@ -221,7 +199,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (label argi=1; argi < args.size(); ++argi)
|
||||
{
|
||||
auto split = stringOps::splitFixed(args[argi], width, beginOffset);
|
||||
const auto split = stringOps::splitFixed(args[argi], width);
|
||||
printSubStrings(args[argi], split);
|
||||
}
|
||||
|
||||
@ -241,8 +219,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (label argi=1; argi < args.size(); ++argi)
|
||||
{
|
||||
auto split =
|
||||
stringOps::split(args[argi], delim, beginOffset, keepEmpty);
|
||||
const auto split = stringOps::split(args[argi], delim, keepEmpty);
|
||||
printSubStrings(args[argi], split);
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ Description
|
||||
Format options:
|
||||
\table
|
||||
Property | Description | Required | Default
|
||||
commsType | scheduled/nonBlocking/buffered | no | scheduled
|
||||
commsType | blocking/nonBlocking/scheduled | no | scheduled
|
||||
merge | Enable geometry/field merging | no | true
|
||||
write | Write file(s) | no | false
|
||||
narrow | Communicate with narrowed values | no | false
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2024 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -35,9 +35,6 @@ Description
|
||||
#include "labelList.H"
|
||||
#include "scalarList.H"
|
||||
#include "DynamicList.H"
|
||||
#include "labelField.H"
|
||||
#include "scalarField.H"
|
||||
#include "SubField.H"
|
||||
#include "SpanStream.H"
|
||||
#include "formattingEntry.H"
|
||||
|
||||
@ -93,7 +90,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
// This also works, but not actually using the autoPtr directly
|
||||
|
||||
autoPtr<token::compound> ptr
|
||||
autoPtr<token::Compound<labelList>> ptr
|
||||
(
|
||||
new token::Compound<labelList>(identity(10, -9))
|
||||
);
|
||||
@ -134,50 +131,44 @@ int main(int argc, char *argv[])
|
||||
Info<< "resized: "
|
||||
<< ctok1.info() << nl << ctok1 << endl;
|
||||
|
||||
const scalarList* listptr = ctok1.compoundToken().isA<scalarList>();
|
||||
if (listptr)
|
||||
{
|
||||
// Using isA<> on compoundToken()
|
||||
const auto* listptr = ctok1.compoundToken().isA<scalarList>();
|
||||
if (listptr)
|
||||
for (scalar& val : const_cast<scalarList&>(*listptr))
|
||||
{
|
||||
// sneaky, SubField bypasses const!
|
||||
scalarField::subField fld(*listptr);
|
||||
fld *= 5;
|
||||
|
||||
Info<< "multiplied List<scalar>: "
|
||||
<< ctok1.info() << nl << ctok1 << endl;
|
||||
val *= 5;
|
||||
}
|
||||
|
||||
Info<< "multiplied List<scalar>: "
|
||||
<< ctok1.info() << nl << ctok1 << endl;
|
||||
}
|
||||
|
||||
listptr = ctok1.isCompound<scalarList>();
|
||||
if (listptr)
|
||||
{
|
||||
// Using isCompound<...> - combined check
|
||||
|
||||
const auto* listptr = ctok1.isCompound<scalarList>();
|
||||
if (listptr)
|
||||
for (scalar& val : const_cast<scalarList&>(*listptr))
|
||||
{
|
||||
scalarField::subField fld(*listptr);
|
||||
fld /= 2;
|
||||
|
||||
Info<< "divided List<scalar>: "
|
||||
<< ctok1.info() << nl << ctok1 << endl;
|
||||
val /= 2;
|
||||
}
|
||||
|
||||
Info<< "divided List<scalar>: "
|
||||
<< ctok1.info() << nl << ctok1 << endl;
|
||||
}
|
||||
|
||||
const labelList* listptr2 = ctok1.isCompound<labelList>();
|
||||
if (listptr2)
|
||||
{
|
||||
// Using isCompound<...> - combined check
|
||||
|
||||
const auto* listptr = ctok1.isCompound<labelList>();
|
||||
if (listptr)
|
||||
for (label& val : const_cast<labelList&>(*listptr2))
|
||||
{
|
||||
labelField::subField fld(*listptr);
|
||||
fld /= 2;
|
||||
val /= 2;
|
||||
}
|
||||
|
||||
Info<< "divided List<label>: "
|
||||
<< ctok1.info() << nl << ctok1 << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "compound is not List<label>" << nl;
|
||||
}
|
||||
Info<< "divided List<label>: "
|
||||
<< ctok1.info() << nl << ctok1 << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "compound is not List<label>" << nl;
|
||||
}
|
||||
|
||||
Info<< "Before fill_zero: " << ctok1 << endl;
|
||||
@ -192,33 +183,57 @@ int main(int argc, char *argv[])
|
||||
auto& ct = ctok1.refCompoundToken();
|
||||
|
||||
ct.resize(20);
|
||||
bool handled = false;
|
||||
bool handled = true;
|
||||
|
||||
switch (ct.typeCode())
|
||||
{
|
||||
#undef doLocalCode
|
||||
#define doLocalCode(TokenType, cmptType, cmptValue) \
|
||||
\
|
||||
case TokenType : \
|
||||
{ \
|
||||
UList<cmptType> cmpts \
|
||||
( \
|
||||
reinterpret_cast<cmptType*>(ct.data_bytes()), \
|
||||
label(ct.size_bytes() / sizeof(cmptType)) \
|
||||
); \
|
||||
cmpts = cmptValue; \
|
||||
handled = true; \
|
||||
break; \
|
||||
case token::tokenType::BOOL :
|
||||
{
|
||||
UList<bool> cmpts
|
||||
(
|
||||
reinterpret_cast<bool*>(ct.data_bytes()),
|
||||
label(ct.size_bytes() / sizeof(bool))
|
||||
);
|
||||
cmpts = false;
|
||||
}
|
||||
break;
|
||||
|
||||
doLocalCode(token::tokenType::BOOL, bool, false);
|
||||
doLocalCode(token::tokenType::LABEL, label, 123);
|
||||
doLocalCode(token::tokenType::FLOAT, float, 2.7);
|
||||
doLocalCode(token::tokenType::DOUBLE, double, 3.1415);
|
||||
case token::tokenType::LABEL :
|
||||
{
|
||||
UList<label> cmpts
|
||||
(
|
||||
reinterpret_cast<label*>(ct.data_bytes()),
|
||||
label(ct.size_bytes() / sizeof(label))
|
||||
);
|
||||
cmpts = 123;
|
||||
}
|
||||
break;
|
||||
|
||||
#undef doLocalCode
|
||||
case token::tokenType::FLOAT :
|
||||
{
|
||||
UList<float> cmpts
|
||||
(
|
||||
reinterpret_cast<float*>(ct.data_bytes()),
|
||||
label(ct.size_bytes() / sizeof(float))
|
||||
);
|
||||
cmpts = 2.7;
|
||||
}
|
||||
break;
|
||||
|
||||
default : break;
|
||||
case token::tokenType::DOUBLE :
|
||||
{
|
||||
UList<double> cmpts
|
||||
(
|
||||
reinterpret_cast<double*>(ct.data_bytes()),
|
||||
label(ct.size_bytes() / sizeof(double))
|
||||
);
|
||||
cmpts = 3.1415;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
handled = false;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -226,10 +241,6 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
Info<< "assigned: " << ctok1 << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "Warning: not handled!" << nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -316,65 +327,6 @@ int main(int argc, char *argv[])
|
||||
Info<< "content" << nl << entry3 << nl;
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
primitiveEntry entry0("entry");
|
||||
|
||||
Info<< "empty: " << entry0 << nl;
|
||||
|
||||
// populate
|
||||
{
|
||||
tokenList& toks = entry0.stream();
|
||||
toks.resize(2);
|
||||
toks[0] = word("nonuniform");
|
||||
toks[1] = token::Compound<scalarList>::New(10, scalar(1));
|
||||
}
|
||||
|
||||
Info<< entry0 << nl;
|
||||
|
||||
// Modify contents
|
||||
for (auto& tok : entry0.stream())
|
||||
{
|
||||
if (tok.isCompound<scalarList>())
|
||||
{
|
||||
tok.refCompoundToken<scalarList>() = 2;
|
||||
}
|
||||
}
|
||||
|
||||
Info<< entry0 << nl;
|
||||
|
||||
|
||||
// Find and 'capture' contents
|
||||
|
||||
{
|
||||
typedef List<scalar> ListType;
|
||||
|
||||
auto* inputDataPtr =
|
||||
const_cast<ListType*>(entry0.stream().findCompound<ListType>());
|
||||
|
||||
if (inputDataPtr)
|
||||
{
|
||||
Info<< "found input data" << nl;
|
||||
Info<< entry0 << nl;
|
||||
|
||||
ListType inputData(std::move(*inputDataPtr));
|
||||
|
||||
Info<< "input data, after move" << nl;
|
||||
Info<< entry0 << nl;
|
||||
|
||||
ListType replaceData(5, scalar(3.145));
|
||||
|
||||
// some manipulation
|
||||
replaceData.back() = scalar(1.414);
|
||||
|
||||
inputDataPtr->swap(replaceData);
|
||||
Info<< "with replaced values" << nl;
|
||||
}
|
||||
}
|
||||
|
||||
Info<< entry0 << nl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2017 Wikki Ltd
|
||||
Copyright (C) 2021-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2021-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -77,7 +77,6 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
|
||||
#include "addRegionOption.H"
|
||||
#include "addFaRegionOption.H"
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
#include "createNamedPolyMesh.H"
|
||||
@ -91,7 +90,8 @@ int main(int argc, char *argv[])
|
||||
faMesh::geometryOrder(geometryOrder);
|
||||
}
|
||||
|
||||
#include "createNamedFaMesh.H"
|
||||
// Create
|
||||
faMesh aMesh(mesh);
|
||||
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
|
||||
@ -55,7 +55,7 @@ do
|
||||
|
||||
bitSet haveMeshOnProc;
|
||||
std::unique_ptr<faMeshSubset> subsetter;
|
||||
IOobjectList objects;
|
||||
IOobjectList objects(0);
|
||||
|
||||
refPtr<fileOperation> newHandler(fileOperation::NewUncollated());
|
||||
|
||||
@ -70,13 +70,7 @@ do
|
||||
|
||||
const bool oldParRun = UPstream::parRun(false);
|
||||
|
||||
objects = IOobjectList
|
||||
(
|
||||
serialMesh.time(),
|
||||
runTime.timeName(),
|
||||
serialMesh.dbDir(),
|
||||
IOobjectOption::NO_REGISTER
|
||||
);
|
||||
objects = IOobjectList(serialMesh.time(), runTime.timeName());
|
||||
|
||||
UPstream::parRun(oldParRun);
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2021-2024 OpenCFD Ltd.
|
||||
Copyright (C) 2021-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
@ -18,8 +18,7 @@ Required Classes
|
||||
- Foam::IOdictionary
|
||||
|
||||
Required Variables
|
||||
- regionName [word] (the polyMesh region)
|
||||
- areaRegionName [word] (the areaMesh region)
|
||||
- regionName [word]
|
||||
- args [argList]
|
||||
- runTime [Time]
|
||||
|
||||
@ -36,7 +35,6 @@ autoPtr<IOdictionary> meshDictPtr;
|
||||
{
|
||||
fileName dictPath;
|
||||
const word& regionDir = Foam::polyMesh::regionName(regionName);
|
||||
const word& areaRegionDir = Foam::polyMesh::regionName(areaRegionName);
|
||||
|
||||
if (args.readIfPresent("dict", dictPath))
|
||||
{
|
||||
@ -49,30 +47,38 @@ autoPtr<IOdictionary> meshDictPtr;
|
||||
}
|
||||
else if
|
||||
(
|
||||
// Dictionary under system/faMeshDefinition ?
|
||||
// (v2312 and earlier)
|
||||
|
||||
areaRegionDir.empty()
|
||||
&& exists
|
||||
// Check global location
|
||||
exists
|
||||
(
|
||||
runTime.path()/runTime.caseSystem()
|
||||
runTime.path()/runTime.caseConstant()
|
||||
/ regionDir/faMesh::meshSubDir/dictName
|
||||
)
|
||||
)
|
||||
{
|
||||
// Dictionary present directly in system/ (v2312 and earlier)
|
||||
|
||||
dictPath = runTime.system()/regionDir/dictName;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use system/finite-area/ directory, with region qualifications
|
||||
// Dictionary present in constant faMesh directory (old-style)
|
||||
|
||||
dictPath =
|
||||
(
|
||||
runTime.system()/regionDir
|
||||
/ faMesh::prefix()/areaRegionDir/dictName
|
||||
runTime.constant()
|
||||
/ regionDir/faMesh::meshSubDir/dictName
|
||||
);
|
||||
|
||||
// Warn that constant/faMesh/faMeshDefinition was used
|
||||
// instead of system/faMeshDefinition
|
||||
#if 0
|
||||
WarningIn(args.executable())
|
||||
<< "Using the old faMeshDefinition location: "
|
||||
<< dictPath << nl
|
||||
<< " instead of default location: "
|
||||
<< runTime.system()/regionDir/dictName << nl
|
||||
<< endl;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
// Assume dictionary is in the system directory
|
||||
|
||||
dictPath = runTime.system()/regionDir/dictName;
|
||||
}
|
||||
|
||||
IOobject meshDictIO
|
||||
|
||||
@ -104,13 +104,10 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
|
||||
#include "addRegionOption.H"
|
||||
#include "addFaRegionOption.H"
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
#include "createNamedPolyMesh.H"
|
||||
|
||||
#include "getFaRegionOption.H"
|
||||
|
||||
const bool doDecompose = !args.found("no-decompose");
|
||||
const bool doDecompFields = !args.found("no-fields");
|
||||
|
||||
@ -136,15 +133,8 @@ int main(int argc, char *argv[])
|
||||
// Preliminary checks
|
||||
#include "checkPatchTopology.H"
|
||||
|
||||
Info << "Create areaMesh";
|
||||
if (!Foam::polyMesh::regionName(areaRegionName).empty())
|
||||
{
|
||||
Foam::Info << ' ' << areaRegionName;
|
||||
}
|
||||
Info << " for polyMesh at time = " << runTime.timeName() << nl;
|
||||
|
||||
// Create
|
||||
faMesh aMesh(areaRegionName, mesh, meshDefDict);
|
||||
faMesh aMesh(mesh, meshDefDict);
|
||||
|
||||
// Mesh information (less verbose)
|
||||
faMeshTools::printMeshChecks(aMesh, 0);
|
||||
|
||||
@ -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("noZero")
|
||||
// !args.found("zeroTime")
|
||||
// && !args.found("time")
|
||||
// && !args.found("latestTime")
|
||||
// && Times.size() > 2
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2022-2024 OpenCFD Ltd.
|
||||
Copyright (C) 2022-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -93,34 +93,29 @@ void Foam::fileFormats::ensightMeshReader::readIDs
|
||||
(
|
||||
ensightReadFile& is,
|
||||
const bool doRead,
|
||||
const label elemCount,
|
||||
const label nShapes,
|
||||
labelList& foamToElem,
|
||||
Map<label>& elemToFoam
|
||||
) const
|
||||
{
|
||||
const label begElem = foamToElem.size();
|
||||
const label endElem = begElem + elemCount;
|
||||
|
||||
foamToElem.resize(foamToElem.size()+elemCount);
|
||||
|
||||
const label sz = foamToElem.size();
|
||||
foamToElem.resize(sz+nShapes);
|
||||
if (doRead)
|
||||
{
|
||||
elemToFoam.reserve(elemToFoam.size()+elemCount);
|
||||
|
||||
for (label elemi = begElem; elemi < endElem; ++elemi)
|
||||
elemToFoam.reserve(elemToFoam.size()+nShapes);
|
||||
for (label shapei = 0; shapei < nShapes; shapei++)
|
||||
{
|
||||
label id;
|
||||
is.read(id);
|
||||
foamToElem[elemi] = id;
|
||||
elemToFoam.insert(id, elemi);
|
||||
label elemi;
|
||||
is.read(elemi);
|
||||
foamToElem[sz+shapei] = elemi;
|
||||
elemToFoam.insert(elemi, sz+shapei);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// identity
|
||||
for (label elemi = begElem; elemi < endElem; ++elemi)
|
||||
for (label shapei = 0; shapei < nShapes; shapei++)
|
||||
{
|
||||
foamToElem[elemi] = elemi;
|
||||
foamToElem[sz+shapei] = sz+shapei;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -214,54 +209,37 @@ bool Foam::fileFormats::ensightMeshReader::readGoldPart
|
||||
// Work
|
||||
DynamicList<label> verts;
|
||||
|
||||
string buffer;
|
||||
string line;
|
||||
while (is.good())
|
||||
{
|
||||
do
|
||||
{
|
||||
// Get entire line/string
|
||||
is.read(buffer);
|
||||
is.readKeyword(line);
|
||||
}
|
||||
while (buffer.empty() && is.good());
|
||||
while (line.empty() && is.good());
|
||||
|
||||
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);
|
||||
const auto split = stringOps::splitSpace(line);
|
||||
|
||||
if (split.empty())
|
||||
if (split.size() == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto keyword(split[0].str());
|
||||
|
||||
if (keyword == "part")
|
||||
if (split[0] == "part")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (keyword == "node_ids")
|
||||
else if (split[0] == "node_ids")
|
||||
{
|
||||
const label nPoints = points.size();
|
||||
// Ignore point ids
|
||||
for (label pointi = 0; pointi < nPoints; ++pointi)
|
||||
// Ignore for now
|
||||
for (label i = 0; i < nPoints; i++)
|
||||
{
|
||||
label id;
|
||||
is.read(id);
|
||||
label index;
|
||||
is.read(index);
|
||||
}
|
||||
}
|
||||
else if (keyword == "coordinates")
|
||||
else if (split[0] == "coordinates")
|
||||
{
|
||||
label nPoints;
|
||||
is.read(nPoints);
|
||||
@ -279,205 +257,207 @@ bool Foam::fileFormats::ensightMeshReader::readGoldPart
|
||||
nodeIdToPoints
|
||||
);
|
||||
|
||||
points.setSize(nPoints);
|
||||
|
||||
is.readPoints(nPoints, points);
|
||||
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());
|
||||
}
|
||||
}
|
||||
else if (keyword == "tetra4")
|
||||
else if (split[0] == "tetra4")
|
||||
{
|
||||
label elemCount;
|
||||
is.read(elemCount);
|
||||
label nShapes;
|
||||
is.read(nShapes);
|
||||
|
||||
Pout<< indent<< "tetra4 " << elemCount
|
||||
Pout<< indent<< "tetra4 " << nShapes
|
||||
<< " starting at line " << is.lineNumber()
|
||||
<< " position " << is.stdStream().tellg() << endl;
|
||||
|
||||
const label celli = cells.size();
|
||||
cells.resize(celli+nShapes);
|
||||
|
||||
readIDs
|
||||
(
|
||||
is,
|
||||
read_elem_ids,
|
||||
elemCount,
|
||||
nShapes,
|
||||
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 (auto& cellFaces : myElements)
|
||||
for (label shapei = 0; shapei < nShapes; shapei++)
|
||||
{
|
||||
readVerts(is, 4, nodeIdToPoints, verts);
|
||||
if (setHandedness_)
|
||||
{
|
||||
setHandedness(model, verts, points);
|
||||
}
|
||||
cellFaces = cellShape(model, verts).faces();
|
||||
const cellShape cellVerts(model, verts);
|
||||
cells[celli+shapei] = cellVerts.faces();
|
||||
}
|
||||
}
|
||||
else if (keyword == "pyramid5")
|
||||
else if (split[0] == "pyramid5")
|
||||
{
|
||||
label elemCount;
|
||||
is.read(elemCount);
|
||||
label nShapes;
|
||||
is.read(nShapes);
|
||||
|
||||
Pout<< indent<< "pyramid5 " << elemCount
|
||||
Pout<< indent<< "pyramid5 " << nShapes
|
||||
<< " starting at line " << is.lineNumber()
|
||||
<< " position " << is.stdStream().tellg() << endl;
|
||||
|
||||
const label celli = cells.size();
|
||||
cells.resize(celli+nShapes);
|
||||
|
||||
readIDs
|
||||
(
|
||||
is,
|
||||
read_elem_ids,
|
||||
elemCount,
|
||||
nShapes,
|
||||
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 (auto& cellFaces : myElements)
|
||||
for (label shapei = 0; shapei < nShapes; shapei++)
|
||||
{
|
||||
readVerts(is, 5, nodeIdToPoints, verts);
|
||||
if (setHandedness_)
|
||||
{
|
||||
setHandedness(model, verts, points);
|
||||
}
|
||||
cellFaces = cellShape(model, verts).faces();
|
||||
const cellShape cellVerts(model, verts);
|
||||
cells[celli+shapei] = cellVerts.faces();
|
||||
}
|
||||
}
|
||||
else if (keyword == "penta6")
|
||||
else if (split[0] == "penta6")
|
||||
{
|
||||
label elemCount;
|
||||
is.read(elemCount);
|
||||
label nShapes;
|
||||
is.read(nShapes);
|
||||
|
||||
Pout<< indent<< "penta6 " << elemCount
|
||||
Pout<< indent<< "penta6 " << nShapes
|
||||
<< " starting at line " << is.lineNumber()
|
||||
<< " position " << is.stdStream().tellg() << endl;
|
||||
|
||||
const label celli = cells.size();
|
||||
cells.resize(celli+nShapes);
|
||||
|
||||
readIDs
|
||||
(
|
||||
is,
|
||||
read_elem_ids,
|
||||
elemCount,
|
||||
nShapes,
|
||||
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 (auto& cellFaces : myElements)
|
||||
for (label shapei = 0; shapei < nShapes; shapei++)
|
||||
{
|
||||
readVerts(is, 6, nodeIdToPoints, verts);
|
||||
if (setHandedness_)
|
||||
{
|
||||
setHandedness(model, verts, points);
|
||||
}
|
||||
cellFaces = cellShape(model, verts).faces();
|
||||
const cellShape cellVerts(model, verts);
|
||||
cells[celli+shapei] = cellVerts.faces();
|
||||
}
|
||||
}
|
||||
else if (keyword == "hexa8")
|
||||
else if (split[0] == "hexa8")
|
||||
{
|
||||
label elemCount;
|
||||
is.read(elemCount);
|
||||
label nShapes;
|
||||
is.read(nShapes);
|
||||
|
||||
Pout<< indent<< "hexa8 " << elemCount
|
||||
Pout<< indent<< "hexa8 " << nShapes
|
||||
<< " starting at line " << is.lineNumber()
|
||||
<< " position " << is.stdStream().tellg() << endl;
|
||||
|
||||
const label celli = cells.size();
|
||||
cells.resize(celli+nShapes);
|
||||
|
||||
readIDs
|
||||
(
|
||||
is,
|
||||
read_elem_ids,
|
||||
elemCount,
|
||||
nShapes,
|
||||
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 (auto& cellFaces : myElements)
|
||||
for (label shapei = 0; shapei < nShapes; shapei++)
|
||||
{
|
||||
readVerts(is, 8, nodeIdToPoints, verts);
|
||||
if (setHandedness_)
|
||||
{
|
||||
setHandedness(model, verts, points);
|
||||
}
|
||||
cellFaces = cellShape(model, verts).faces();
|
||||
const cellShape cellVerts(model, verts);
|
||||
cells[celli+shapei] = cellVerts.faces();
|
||||
}
|
||||
}
|
||||
else if (keyword == "nfaced")
|
||||
else if (split[0] == "nfaced")
|
||||
{
|
||||
label elemCount;
|
||||
is.read(elemCount);
|
||||
label nShapes;
|
||||
is.read(nShapes);
|
||||
|
||||
Pout<< indent<< "nfaced " << elemCount
|
||||
Pout<< indent<< "nfaced " << nShapes
|
||||
<< " starting at line " << is.lineNumber()
|
||||
<< " position " << is.stdStream().tellg() << endl;
|
||||
|
||||
const label celli = cells.size();
|
||||
cells.resize(celli+nShapes);
|
||||
|
||||
readIDs
|
||||
(
|
||||
is,
|
||||
read_elem_ids,
|
||||
elemCount,
|
||||
nShapes,
|
||||
cellToElemIds,
|
||||
elemIdToCells
|
||||
);
|
||||
|
||||
// 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)
|
||||
for (label shapei = 0; shapei < nShapes; shapei++)
|
||||
{
|
||||
label nFaces;
|
||||
is.read(nFaces);
|
||||
cellFaces.resize(nFaces);
|
||||
faceList& cellFaces = cells[celli+shapei];
|
||||
cellFaces.setSize(nFaces);
|
||||
}
|
||||
|
||||
for (auto& cellFaces : myElements)
|
||||
for (label shapei = 0; shapei < nShapes; shapei++)
|
||||
{
|
||||
for (face& f : cellFaces)
|
||||
faceList& cellFaces = cells[celli+shapei];
|
||||
forAll(cellFaces, cellFacei)
|
||||
{
|
||||
label nVerts;
|
||||
is.read(nVerts);
|
||||
f.resize(nVerts);
|
||||
cellFaces[cellFacei].setSize(nVerts);
|
||||
}
|
||||
}
|
||||
|
||||
for (faceList& cellFaces : myElements)
|
||||
for (label shapei = 0; shapei < nShapes; shapei++)
|
||||
{
|
||||
for (face& f : cellFaces)
|
||||
faceList& cellFaces = cells[celli+shapei];
|
||||
forAll(cellFaces, cellFacei)
|
||||
{
|
||||
face& f = cellFaces[cellFacei];
|
||||
readVerts(is, f.size(), nodeIdToPoints, verts);
|
||||
f.labelList::operator=(verts);
|
||||
}
|
||||
}
|
||||
|
||||
// Full check
|
||||
forAll(myElements, elemi)
|
||||
{
|
||||
for (const face& f : myElements[elemi])
|
||||
{
|
||||
for (label pointi : f)
|
||||
forAll(f, fp)
|
||||
{
|
||||
if (pointi < 0 || pointi >= points.size())
|
||||
if (f[fp] < 0 || f[fp] >= points.size())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Face:" << elemi
|
||||
FatalErrorInFunction<< "Face:" << shapei
|
||||
<< " verts:" << f
|
||||
<< " indexes outside points:" << points.size()
|
||||
<< exit(FatalError);
|
||||
@ -486,104 +466,107 @@ bool Foam::fileFormats::ensightMeshReader::readGoldPart
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (keyword == "tria3")
|
||||
else if (split[0] == "tria3")
|
||||
{
|
||||
label elemCount;
|
||||
is.read(elemCount);
|
||||
label nShapes;
|
||||
is.read(nShapes);
|
||||
|
||||
Pout<< indent << "tria3 " << elemCount
|
||||
Pout<< indent << "tria3 " << nShapes
|
||||
<< " starting at line " << is.lineNumber()
|
||||
<< " position " << is.stdStream().tellg() << endl;
|
||||
|
||||
const label facei = faces.size();
|
||||
|
||||
readIDs
|
||||
(
|
||||
is,
|
||||
read_elem_ids,
|
||||
elemCount,
|
||||
nShapes,
|
||||
faceToElemIDs,
|
||||
elemIdToFaces
|
||||
);
|
||||
|
||||
// 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);
|
||||
faces.setSize(facei+nShapes);
|
||||
|
||||
for (face& f : myElements)
|
||||
for (label shapei = 0; shapei < nShapes; shapei++)
|
||||
{
|
||||
auto& f = faces[facei+shapei];
|
||||
f.setSize(3);
|
||||
readVerts(is, f.size(), nodeIdToPoints, verts);
|
||||
f.labelList::operator=(verts);
|
||||
}
|
||||
}
|
||||
else if (keyword == "quad4")
|
||||
else if (split[0] == "quad4")
|
||||
{
|
||||
label elemCount;
|
||||
is.read(elemCount);
|
||||
label nShapes;
|
||||
is.read(nShapes);
|
||||
|
||||
Pout<< indent << "quad4 " << elemCount
|
||||
Pout<< indent << "quad4 " << nShapes
|
||||
<< " starting at line " << is.lineNumber()
|
||||
<< " position " << is.stdStream().tellg() << endl;
|
||||
|
||||
const label facei = faces.size();
|
||||
|
||||
readIDs
|
||||
(
|
||||
is,
|
||||
read_elem_ids,
|
||||
elemCount,
|
||||
nShapes,
|
||||
faceToElemIDs,
|
||||
elemIdToFaces
|
||||
);
|
||||
|
||||
// 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);
|
||||
faces.setSize(facei+nShapes);
|
||||
|
||||
for (face& f : myElements)
|
||||
for (label shapei = 0; shapei < nShapes; shapei++)
|
||||
{
|
||||
auto& f = faces[facei+shapei];
|
||||
f.setSize(4);
|
||||
readVerts(is, f.size(), nodeIdToPoints, verts);
|
||||
f.labelList::operator=(verts);
|
||||
}
|
||||
}
|
||||
else if (keyword == "nsided")
|
||||
else if (split[0] == "nsided")
|
||||
{
|
||||
label elemCount;
|
||||
is.read(elemCount);
|
||||
label nShapes;
|
||||
is.read(nShapes);
|
||||
|
||||
Pout<< indent << "nsided " << elemCount
|
||||
Pout<< indent << "nsided " << nShapes
|
||||
<< " starting at line " << is.lineNumber()
|
||||
<< " position " << is.stdStream().tellg() << endl;
|
||||
|
||||
const label facei = faces.size();
|
||||
|
||||
readIDs
|
||||
(
|
||||
is,
|
||||
read_elem_ids,
|
||||
elemCount,
|
||||
nShapes,
|
||||
faceToElemIDs,
|
||||
elemIdToFaces
|
||||
);
|
||||
|
||||
// Extend and fill the new trailing portion
|
||||
const label startElemi = cells.size();
|
||||
faces.resize(startElemi+elemCount);
|
||||
faceList::subList myElements = faces.slice(startElemi);
|
||||
faces.setSize(facei+nShapes);
|
||||
|
||||
for (face& f : myElements)
|
||||
for (label shapei = 0; shapei < nShapes; shapei++)
|
||||
{
|
||||
auto& f = faces[facei+shapei];
|
||||
label nVerts;
|
||||
is.read(nVerts);
|
||||
f.resize(nVerts);
|
||||
f.setSize(nVerts);
|
||||
}
|
||||
|
||||
for (face& f : myElements)
|
||||
for (label shapei = 0; shapei < nShapes; shapei++)
|
||||
{
|
||||
auto& f = faces[facei+shapei];
|
||||
readVerts(is, f.size(), nodeIdToPoints, verts);
|
||||
f.labelList::operator=(verts);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningInFunction << "Unhandled key " << keyword
|
||||
<< " from line " << buffer
|
||||
WarningInFunction << "Unhandled key " << string(split[0])
|
||||
<< " from line " << line
|
||||
<< " starting at line " << is.lineNumber()
|
||||
<< " position " << is.stdStream().tellg() << endl;
|
||||
}
|
||||
@ -601,21 +584,16 @@ 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 buffer;
|
||||
|
||||
// Ensight Geometry File
|
||||
is.read(buffer);
|
||||
Info<< "Ensight : " << buffer << nl;
|
||||
|
||||
// Description - 1
|
||||
is.read(buffer);
|
||||
Info<< "Ensight : " << buffer << nl;
|
||||
string header;
|
||||
is.read(header);
|
||||
Info<< "Ensight : " << header << endl;
|
||||
is.read(header);
|
||||
Info<< "Ensight : " << header << endl;
|
||||
|
||||
|
||||
bool read_node_ids = false;
|
||||
@ -645,72 +623,61 @@ bool Foam::fileFormats::ensightMeshReader::readGeometry
|
||||
|
||||
|
||||
// Parse all
|
||||
SubStrings<string> split;
|
||||
|
||||
string line;
|
||||
while (is.good())
|
||||
{
|
||||
do
|
||||
{
|
||||
// Get entire line/string
|
||||
is.read(buffer);
|
||||
is.readKeyword(line);
|
||||
}
|
||||
while (buffer.empty() && is.good());
|
||||
if (buffer.contains("END TIME STEP"))
|
||||
while (line.empty() && is.good());
|
||||
const auto split = stringOps::splitSpace(line);
|
||||
|
||||
if (split[0] == "extents")
|
||||
{
|
||||
// END TIME STEP is a valid means to terminate input
|
||||
break;
|
||||
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;
|
||||
}
|
||||
split = stringOps::splitSpace(buffer);
|
||||
|
||||
if (split.empty())
|
||||
else if (split[0] == "node")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto keyword(split[0].str());
|
||||
|
||||
if (keyword == "extents")
|
||||
{
|
||||
// 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]);
|
||||
word id(split[1]);
|
||||
word op(split[2]);
|
||||
if (op == "given" || op == "ignore")
|
||||
{
|
||||
Pout<< indent << "Reading node ids" << endl;
|
||||
read_node_ids = true;
|
||||
}
|
||||
}
|
||||
else if (keyword == "element")
|
||||
else if (split[0] == "element")
|
||||
{
|
||||
// "element id (off|assign|given|ignore)"
|
||||
std::string op(split[2]);
|
||||
word id(split[1]);
|
||||
word op(split[2]);
|
||||
if (op == "given" || op == "ignore")
|
||||
{
|
||||
Pout<< indent << "Reading element ids" << endl;
|
||||
read_elem_ids = true;
|
||||
}
|
||||
}
|
||||
else if (keyword == "part")
|
||||
else if (split[0] == "part")
|
||||
{
|
||||
bool finished = false;
|
||||
do
|
||||
{
|
||||
// Read part id and name
|
||||
is.read(partIDs.emplace_back());
|
||||
is.read(partNames.emplace_back());
|
||||
// Make space
|
||||
partIDs.emplace_back();
|
||||
is.read(partIDs.back());
|
||||
|
||||
partNames.emplace_back();
|
||||
is.read(partNames.back());
|
||||
|
||||
Pout<< indent
|
||||
<< "Reading part " << partIDs.back()
|
||||
@ -987,7 +954,7 @@ bool Foam::fileFormats::ensightMeshReader::readGeometry
|
||||
const face& f = rotateFace(cFaces[cFacei], rotatedFace);
|
||||
|
||||
const auto fFnd = vertsToCell.find(f);
|
||||
if (fFnd.good())
|
||||
if (fFnd)
|
||||
{
|
||||
// Already inserted. Internal face.
|
||||
vertsToCell.erase(fFnd);
|
||||
@ -1059,12 +1026,7 @@ bool Foam::fileFormats::ensightMeshReader::readGeometry
|
||||
)
|
||||
);
|
||||
|
||||
if (cAndF.good())
|
||||
{
|
||||
partCellAndFace[patchFacei++] = cAndF.val();
|
||||
vertsToCell.erase(cAndF);
|
||||
}
|
||||
else
|
||||
if (!cAndF)
|
||||
{
|
||||
//WarningInFunction
|
||||
// << "Did not find face " << facei
|
||||
@ -1074,6 +1036,11 @@ 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(0, runTime.constant()), 0);
|
||||
runTime.setTime(instant(runTime.constant()), 0);
|
||||
|
||||
repatcher.repatch();
|
||||
|
||||
|
||||
@ -618,7 +618,7 @@ void Foam::conformalVoronoiMesh::reorderProcessorPatches
|
||||
labelList rotation(faces.size(), Zero);
|
||||
labelList faceMap(faces.size(), label(-1));
|
||||
|
||||
PstreamBuffers pBufs;
|
||||
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
|
||||
|
||||
// Send ordering
|
||||
forAll(sortMesh.boundaryMesh(), patchi)
|
||||
|
||||
@ -568,9 +568,10 @@ void syncPoints
|
||||
}
|
||||
}
|
||||
|
||||
// buffered send
|
||||
OPstream toNbr
|
||||
(
|
||||
UPstream::commsTypes::buffered,
|
||||
UPstream::commsTypes::blocking,
|
||||
procPatch.neighbProcNo()
|
||||
);
|
||||
toNbr << patchInfo;
|
||||
|
||||
@ -145,7 +145,6 @@ Usage
|
||||
#include "hexRef8Data.H"
|
||||
#include "regionProperties.H"
|
||||
#include "polyMeshTools.H"
|
||||
#include "subsetAdjacency.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -195,56 +194,21 @@ tmp<volScalarField> createScalarField
|
||||
}
|
||||
|
||||
|
||||
// Calculate band of mesh
|
||||
// label getBand(const labelUList& owner, const labelUList& neighbour)
|
||||
// {
|
||||
// label bandwidth = 0;
|
||||
//
|
||||
// forAll(neighbour, facei)
|
||||
// {
|
||||
// const label width = neighbour[facei] - owner[facei];
|
||||
//
|
||||
// if (bandwidth < width)
|
||||
// {
|
||||
// bandwidth = width;
|
||||
// }
|
||||
// }
|
||||
// return bandwidth;
|
||||
// }
|
||||
|
||||
|
||||
// Calculate band and profile of matrix. Profile is scalar to avoid overflow
|
||||
Tuple2<label, scalar> getBand
|
||||
(
|
||||
const CompactListList<label>& mat
|
||||
)
|
||||
// Calculate band of matrix
|
||||
label getBand(const labelList& owner, const labelList& neighbour)
|
||||
{
|
||||
Tuple2<label, scalar> metrics(0, 0);
|
||||
label band = 0;
|
||||
|
||||
auto& bandwidth = metrics.first();
|
||||
auto& profile = metrics.second();
|
||||
|
||||
forAll(mat, celli)
|
||||
forAll(neighbour, facei)
|
||||
{
|
||||
const auto& neighbours = mat[celli];
|
||||
label diff = neighbour[facei] - owner[facei];
|
||||
|
||||
const label nNbr = neighbours.size();
|
||||
|
||||
if (nNbr)
|
||||
if (diff > band)
|
||||
{
|
||||
// Max distance
|
||||
const label width = (neighbours[nNbr-1] - celli);
|
||||
|
||||
if (bandwidth < width)
|
||||
{
|
||||
bandwidth = width;
|
||||
}
|
||||
|
||||
profile += scalar(width);
|
||||
band = diff;
|
||||
}
|
||||
}
|
||||
|
||||
return metrics;
|
||||
return band;
|
||||
}
|
||||
|
||||
|
||||
@ -253,36 +217,28 @@ void getBand
|
||||
(
|
||||
const bool calculateIntersect,
|
||||
const label nCells,
|
||||
const labelUList& owner,
|
||||
const labelUList& neighbour,
|
||||
const labelList& owner,
|
||||
const labelList& neighbour,
|
||||
label& bandwidth,
|
||||
scalar& profile, // scalar to avoid overflow
|
||||
scalar& sumSqrIntersect // scalar to avoid overflow
|
||||
)
|
||||
{
|
||||
labelList cellBandwidth(nCells, Foam::zero{});
|
||||
|
||||
bandwidth = 0;
|
||||
scalarField nIntersect(nCells, Foam::zero{});
|
||||
|
||||
forAll(neighbour, facei)
|
||||
{
|
||||
const label own = owner[facei];
|
||||
const label nei = neighbour[facei];
|
||||
label own = owner[facei];
|
||||
label nei = neighbour[facei];
|
||||
|
||||
// Note: mag not necessary for correct (upper-triangular) ordering.
|
||||
const label width = nei - own;
|
||||
|
||||
if (cellBandwidth[nei] < width)
|
||||
{
|
||||
cellBandwidth[nei] = width;
|
||||
|
||||
if (bandwidth < width)
|
||||
{
|
||||
bandwidth = width;
|
||||
}
|
||||
}
|
||||
label diff = nei-own;
|
||||
cellBandwidth[nei] = max(cellBandwidth[nei], diff);
|
||||
}
|
||||
|
||||
bandwidth = max(cellBandwidth);
|
||||
|
||||
// Do not use field algebra because of conversion label to scalar
|
||||
profile = 0;
|
||||
for (const label width : cellBandwidth)
|
||||
@ -290,16 +246,14 @@ void getBand
|
||||
profile += scalar(width);
|
||||
}
|
||||
|
||||
sumSqrIntersect = 0;
|
||||
sumSqrIntersect = 0.0;
|
||||
if (calculateIntersect)
|
||||
{
|
||||
scalarField nIntersect(nCells, Foam::zero{});
|
||||
|
||||
forAll(nIntersect, celli)
|
||||
{
|
||||
for (label colI = celli-cellBandwidth[celli]; colI <= celli; colI++)
|
||||
{
|
||||
nIntersect[colI] += scalar(1);
|
||||
nIntersect[colI] += 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -721,8 +675,9 @@ CompactListList<label> regionRenumber
|
||||
|
||||
forAll(regionCellOrder, regioni)
|
||||
{
|
||||
// Info<< " region " << regioni << " starts at "
|
||||
// << regionCellOrder.localStart(regioni) << nl;
|
||||
// Info<< " region " << regioni
|
||||
// << " starts at " << regionCellOrder.localStart(regioni)
|
||||
// << nl;
|
||||
|
||||
// No parallel communication
|
||||
const bool oldParRun = UPstream::parRun(false);
|
||||
@ -748,42 +703,27 @@ CompactListList<label> regionRenumber
|
||||
{
|
||||
timer.resetTimeIncrement();
|
||||
|
||||
// Create adjacency matrix of the full mesh and subset subsequently.
|
||||
// This is more efficient than creating adjacency matrices of
|
||||
// sub-meshes.
|
||||
|
||||
// No parallel communication
|
||||
const bool oldParRun = UPstream::parRun(false);
|
||||
|
||||
// The local connectivity of the full (non-subsetted) mesh
|
||||
CompactListList<label> meshCellCells;
|
||||
globalMeshData::calcCellCells(mesh, meshCellCells);
|
||||
UPstream::parRun(oldParRun); // Restore parallel state
|
||||
|
||||
timings[TimingType::CELL_CELLS] += timer.timeIncrement();
|
||||
|
||||
// For the respective subMesh selections
|
||||
bitSet subsetCells(mesh.nCells());
|
||||
|
||||
forAll(regionCellOrder, regioni)
|
||||
{
|
||||
// Info<< " region " << regioni << " starts at "
|
||||
// << regionCellOrder.localStart(regioni) << nl;
|
||||
|
||||
subsetCells = false;
|
||||
subsetCells.set(regionCellOrder[regioni]);
|
||||
|
||||
// Connectivity of local sub-mesh
|
||||
labelList cellMap;
|
||||
CompactListList<label> subCellCells =
|
||||
subsetAdjacency(subsetCells, meshCellCells, cellMap);
|
||||
|
||||
timings[TimingType::CELL_CELLS] += timer.timeIncrement();
|
||||
// Info<< " region " << regioni
|
||||
// << " starts at " << regionCellOrder.localStart(regioni)
|
||||
// << nl;
|
||||
|
||||
// No parallel communication
|
||||
const bool oldParRun = UPstream::parRun(false);
|
||||
|
||||
labelList subCellOrder = method.renumber(subCellCells);
|
||||
// Connectivity of local sub-mesh
|
||||
CompactListList<label> cellCells;
|
||||
labelList cellMap = globalMeshData::calcCellCells
|
||||
(
|
||||
mesh,
|
||||
regionCellOrder[regioni],
|
||||
cellCells
|
||||
);
|
||||
|
||||
timings[TimingType::CELL_CELLS] += timer.timeIncrement();
|
||||
|
||||
labelList subCellOrder = method.renumber(cellCells);
|
||||
|
||||
UPstream::parRun(oldParRun); // Restore parallel state
|
||||
|
||||
@ -803,10 +743,6 @@ 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"
|
||||
@ -867,8 +803,11 @@ int main(int argc, char *argv[])
|
||||
"eg, 'reverse true;'"
|
||||
);
|
||||
|
||||
argList::noFunctionObjects(); // Never use function objects
|
||||
|
||||
#include "addAllRegionOptions.H"
|
||||
#include "addOverwriteOption.H"
|
||||
#include "addTimeOptions.H"
|
||||
|
||||
// -------------------------
|
||||
|
||||
@ -896,10 +835,10 @@ int main(int argc, char *argv[])
|
||||
const bool dryrun = args.dryRun();
|
||||
|
||||
const bool readDict = args.found("dict");
|
||||
const bool doDecompose = args.found("decompose");
|
||||
const bool doFrontWidth = args.found("frontWidth");
|
||||
const bool overwrite = args.found("overwrite");
|
||||
const bool doFields = !args.found("no-fields");
|
||||
const bool doFrontWidth = args.found("frontWidth") && !doDecompose;
|
||||
const bool doDecompose = args.found("decompose");
|
||||
|
||||
word renumberMethodName;
|
||||
args.readIfPresent("renumber-method", renumberMethodName);
|
||||
@ -907,7 +846,8 @@ int main(int argc, char *argv[])
|
||||
if (doDecompose && UPstream::parRun())
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "Cannot use -decompose option in parallel ... giving up" << nl
|
||||
<< "Cannot use -decompose option in parallel"
|
||||
<< " ... giving up" << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
@ -927,15 +867,14 @@ int main(int argc, char *argv[])
|
||||
// Get region names
|
||||
#include "getAllRegionOptions.H"
|
||||
|
||||
// Set time from specified time options, or force start from Time=0
|
||||
timeSelector::setTimeIfPresent(runTime, args, true);
|
||||
// Get times list
|
||||
instantList Times = runTime.times();
|
||||
|
||||
// Set startTime depending on -time and -latestTime options
|
||||
#include "checkTimeOptions.H"
|
||||
|
||||
runTime.setTime(Times[startTime], startTime);
|
||||
|
||||
// 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();
|
||||
@ -949,10 +888,7 @@ int main(int argc, char *argv[])
|
||||
for (fvMesh& mesh : meshes)
|
||||
{
|
||||
// Reset time in case of multiple meshes and not overwrite
|
||||
if (!overwrite)
|
||||
{
|
||||
runTime.setTime(startTime.first(), startTime.second());
|
||||
}
|
||||
runTime.setTime(Times[startTime], startTime);
|
||||
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
@ -972,21 +908,21 @@ int main(int argc, char *argv[])
|
||||
|
||||
reduce(band, maxOp<label>());
|
||||
reduce(profile, sumOp<scalar>());
|
||||
reduce(sumSqrIntersect, sumOp<scalar>());
|
||||
|
||||
scalar rmsFrontwidth = Foam::sqrt
|
||||
(
|
||||
sumSqrIntersect/mesh.globalData().nTotalCells()
|
||||
);
|
||||
|
||||
Info<< "Mesh " << mesh.name()
|
||||
<< " size: " << mesh.globalData().nTotalCells() << nl
|
||||
<< "Before renumbering" << nl
|
||||
<< "Before renumbering :" << nl
|
||||
<< " band : " << band << nl
|
||||
<< " profile : " << profile << nl;
|
||||
|
||||
if (doFrontWidth)
|
||||
{
|
||||
reduce(sumSqrIntersect, sumOp<scalar>());
|
||||
scalar rmsFrontwidth = Foam::sqrt
|
||||
(
|
||||
sumSqrIntersect/mesh.globalData().nTotalCells()
|
||||
);
|
||||
|
||||
Info<< " rms frontwidth : " << rmsFrontwidth << nl;
|
||||
}
|
||||
|
||||
@ -1155,7 +1091,10 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
|
||||
|
||||
// List of stored objects to clear from mesh (after reading)
|
||||
// List of objects read from time directory
|
||||
// List of stored objects to clear from mesh
|
||||
|
||||
IOobjectList objects;
|
||||
DynamicList<regIOobject*> storedObjects;
|
||||
|
||||
if (!dryrun && doFields)
|
||||
@ -1164,60 +1103,55 @@ int main(int argc, char *argv[])
|
||||
|
||||
timer.resetTimeIncrement();
|
||||
|
||||
IOobjectList objects(mesh, runTime.timeName());
|
||||
objects = IOobjectList(mesh, runTime.timeName());
|
||||
storedObjects.reserve(objects.size());
|
||||
|
||||
const predicates::always nameMatcher;
|
||||
|
||||
// Read GeometricFields
|
||||
|
||||
#undef doLocalCode
|
||||
#define doLocalCode(FieldType) \
|
||||
#undef ReadFields
|
||||
#define ReadFields(FieldType) \
|
||||
readFields<FieldType>(mesh, objects, nameMatcher, storedObjects);
|
||||
|
||||
// Read volume fields
|
||||
doLocalCode(volScalarField);
|
||||
doLocalCode(volVectorField);
|
||||
doLocalCode(volSphericalTensorField);
|
||||
doLocalCode(volSymmTensorField);
|
||||
doLocalCode(volTensorField);
|
||||
ReadFields(volScalarField);
|
||||
ReadFields(volVectorField);
|
||||
ReadFields(volSphericalTensorField);
|
||||
ReadFields(volSymmTensorField);
|
||||
ReadFields(volTensorField);
|
||||
|
||||
// Read internal fields
|
||||
doLocalCode(volScalarField::Internal);
|
||||
doLocalCode(volVectorField::Internal);
|
||||
doLocalCode(volSphericalTensorField::Internal);
|
||||
doLocalCode(volSymmTensorField::Internal);
|
||||
doLocalCode(volTensorField::Internal);
|
||||
ReadFields(volScalarField::Internal);
|
||||
ReadFields(volVectorField::Internal);
|
||||
ReadFields(volSphericalTensorField::Internal);
|
||||
ReadFields(volSymmTensorField::Internal);
|
||||
ReadFields(volTensorField::Internal);
|
||||
|
||||
// Read surface fields
|
||||
doLocalCode(surfaceScalarField);
|
||||
doLocalCode(surfaceVectorField);
|
||||
doLocalCode(surfaceSphericalTensorField);
|
||||
doLocalCode(surfaceSymmTensorField);
|
||||
doLocalCode(surfaceTensorField);
|
||||
ReadFields(surfaceScalarField);
|
||||
ReadFields(surfaceVectorField);
|
||||
ReadFields(surfaceSphericalTensorField);
|
||||
ReadFields(surfaceSymmTensorField);
|
||||
ReadFields(surfaceTensorField);
|
||||
|
||||
|
||||
// Read point fields
|
||||
const pointMesh& pMesh = pointMesh::New(mesh);
|
||||
#undef doLocalCode
|
||||
#define doLocalCode(FieldType) \
|
||||
#undef ReadPointFields
|
||||
#define ReadPointFields(FieldType) \
|
||||
readFields<FieldType>(pMesh, objects, nameMatcher, storedObjects);
|
||||
|
||||
doLocalCode(pointScalarField);
|
||||
doLocalCode(pointVectorField);
|
||||
doLocalCode(pointSphericalTensorField);
|
||||
doLocalCode(pointSymmTensorField);
|
||||
doLocalCode(pointTensorField);
|
||||
ReadPointFields(pointScalarField);
|
||||
ReadPointFields(pointVectorField);
|
||||
ReadPointFields(pointSphericalTensorField);
|
||||
ReadPointFields(pointSymmTensorField);
|
||||
ReadPointFields(pointTensorField);
|
||||
|
||||
#undef doLocalCode
|
||||
#undef ReadFields
|
||||
#undef ReadPointFields
|
||||
|
||||
timings[TimingType::READ_FIELDS] += timer.timeIncrement();
|
||||
|
||||
// Write loaded fields when mesh.write() is called
|
||||
for (auto* fldptr : storedObjects)
|
||||
{
|
||||
fldptr->writeOpt(IOobject::AUTO_WRITE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1290,13 +1224,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
|
||||
CompactListList<label> regionCellOrder =
|
||||
regionRenumber
|
||||
(
|
||||
renumberPtr(),
|
||||
mesh,
|
||||
cellToRegion,
|
||||
decomposePtr().nDomains()
|
||||
);
|
||||
regionRenumber(renumberPtr(), mesh, cellToRegion);
|
||||
|
||||
cellOrder = regionCellOrder.values();
|
||||
|
||||
@ -1658,25 +1586,19 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
reduce(band, maxOp<label>());
|
||||
reduce(profile, sumOp<scalar>());
|
||||
reduce(sumSqrIntersect, sumOp<scalar>());
|
||||
|
||||
Info<< "After renumbering";
|
||||
if (doDecompose)
|
||||
{
|
||||
Info<< " [values are misleading with -decompose option]";
|
||||
}
|
||||
scalar rmsFrontwidth = Foam::sqrt
|
||||
(
|
||||
sumSqrIntersect/mesh.globalData().nTotalCells()
|
||||
);
|
||||
|
||||
Info<< nl
|
||||
Info<< "After renumbering :" << nl
|
||||
<< " band : " << band << nl
|
||||
<< " profile : " << profile << nl;
|
||||
|
||||
if (doFrontWidth)
|
||||
{
|
||||
reduce(sumSqrIntersect, sumOp<scalar>());
|
||||
scalar rmsFrontwidth = Foam::sqrt
|
||||
(
|
||||
sumSqrIntersect/mesh.globalData().nTotalCells()
|
||||
);
|
||||
|
||||
Info<< " rms frontwidth : " << rmsFrontwidth << nl;
|
||||
}
|
||||
|
||||
|
||||
@ -1,168 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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, distributed under GPL-3.0-or-later.
|
||||
|
||||
Description
|
||||
Subsetting of an adjacency matrix (as CompactListList).
|
||||
Can be relocated elsewhere.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "CompactListList.H"
|
||||
#include "bitSet.H"
|
||||
#include "ListOps.H"
|
||||
#include "Map.H"
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Perform a subset of the adjacency matrix
|
||||
CompactListList<label> subsetAdjacency
|
||||
(
|
||||
const bitSet& select, // could also be labelHashSet
|
||||
const CompactListList<label>& input,
|
||||
labelList& subMap
|
||||
)
|
||||
{
|
||||
// Corresponds to cellMap etc (the original selection)
|
||||
subMap = select.sortedToc();
|
||||
|
||||
// Ensure that the subMap corresponds to a valid subset
|
||||
{
|
||||
label validSize = 0;
|
||||
|
||||
const label nTotal = input.size();
|
||||
|
||||
forAllReverse(subMap, i)
|
||||
{
|
||||
if (subMap[i] < nTotal)
|
||||
{
|
||||
validSize = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
subMap.resize(validSize);
|
||||
}
|
||||
|
||||
|
||||
// Assumed to be sparse - use Map for reverse lookup
|
||||
const Map<label> reverseMap(invertToMap(subMap));
|
||||
|
||||
|
||||
// Pass 1: determine the selected sub-sizes
|
||||
labelList sizes(subMap.size(), Foam::zero{});
|
||||
|
||||
forAll(subMap, idx)
|
||||
{
|
||||
for (const label nbr : input[subMap[idx]])
|
||||
{
|
||||
if
|
||||
(
|
||||
select.test(nbr)
|
||||
&& reverseMap.contains(nbr) // extra consistency (paranoid)
|
||||
)
|
||||
{
|
||||
++sizes[idx];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CompactListList<label> output(sizes);
|
||||
|
||||
// Reuse sizes as output offset into output.values()
|
||||
sizes = labelList::subList(output.offsets(), output.size());
|
||||
labelList& values = output.values();
|
||||
|
||||
|
||||
// Pass 2: extract sub-adjacent matrix
|
||||
|
||||
label newNbr = -1;
|
||||
|
||||
forAll(subMap, idx)
|
||||
{
|
||||
for (const label nbr : input[subMap[idx]])
|
||||
{
|
||||
if
|
||||
(
|
||||
select.test(nbr)
|
||||
&& (newNbr = reverseMap.lookup(nbr, -1)) >= 0
|
||||
)
|
||||
{
|
||||
values[sizes[idx]++] = newNbr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
// Perform a subset of the adjacency matrix
|
||||
CompactListList<label> subsetAdjacency
|
||||
(
|
||||
const labelRange& slice,
|
||||
const CompactListList<label>& input,
|
||||
labelList& subMap
|
||||
)
|
||||
{
|
||||
// Ensure that the selection corresponds to a valid subset
|
||||
const labelRange select = slice.subset0(input.size());
|
||||
|
||||
// Corresponds to cellMap etc (the original selection)
|
||||
subMap = Foam::identity(select);
|
||||
|
||||
|
||||
// Pass 1: determine the selected sub-sizes
|
||||
labelList sizes(subMap.size(), Foam::zero{});
|
||||
|
||||
forAll(subMap, idx)
|
||||
{
|
||||
for (const label nbr : input[subMap[idx]])
|
||||
{
|
||||
if (select.contains(nbr))
|
||||
{
|
||||
++sizes[idx];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CompactListList<label> output(sizes);
|
||||
|
||||
// Reuse sizes as output offset into output.values()
|
||||
sizes = labelList::subList(output.offsets(), output.size());
|
||||
labelList& values = output.values();
|
||||
|
||||
|
||||
// Pass 2: extract sub-adjacent matrix
|
||||
|
||||
const label localOffset = select.start();
|
||||
|
||||
forAll(subMap, idx)
|
||||
{
|
||||
for (const label nbr : input[subMap[idx]])
|
||||
{
|
||||
if (select.contains(nbr))
|
||||
{
|
||||
values[sizes[idx]++] = nbr - localOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -62,13 +62,12 @@ 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",
|
||||
@ -76,13 +75,14 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
|
||||
#include "addRegionOption.H"
|
||||
#include "addTimeOptions.H"
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
const bool noFlipMap = args.found("noFlipMap");
|
||||
|
||||
// Allow override of time from specified time options, or no-op
|
||||
timeSelector::setTimeIfPresent(runTime, args);
|
||||
// Get times list
|
||||
(void)timeSelector::selectIfPresent(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,17 +549,16 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
Info<< finder.dict();
|
||||
}
|
||||
else if (finder.isStream())
|
||||
else if (finder.ref().isStream())
|
||||
{
|
||||
bool separator = false;
|
||||
bool addSep = false;
|
||||
|
||||
for (const token& tok : finder.stream())
|
||||
const tokenList& tokens = finder.ref().stream();
|
||||
|
||||
for (const token& tok : tokens)
|
||||
{
|
||||
if (separator)
|
||||
{
|
||||
Info<< token::SPACE;
|
||||
}
|
||||
separator = true;
|
||||
if (addSep) Info<< token::SPACE;
|
||||
addSep = true;
|
||||
Info<< tok;
|
||||
}
|
||||
Info<< endl;
|
||||
|
||||
@ -173,7 +173,7 @@ namespace Foam
|
||||
// Uses polyMesh/fvMesh meshSubDir by default
|
||||
autoPtr<labelIOList> procAddressing
|
||||
(
|
||||
const objectRegistry& procRegistry,
|
||||
const fvMesh& procMesh,
|
||||
const word& name,
|
||||
const word& instance,
|
||||
const word& local = fvMesh::meshSubDir
|
||||
@ -186,7 +186,7 @@ autoPtr<labelIOList> procAddressing
|
||||
name,
|
||||
instance,
|
||||
local,
|
||||
procRegistry,
|
||||
procMesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
@ -199,13 +199,13 @@ autoPtr<labelIOList> procAddressing
|
||||
// Uses the finiteArea meshSubDir
|
||||
autoPtr<labelIOList> faProcAddressing
|
||||
(
|
||||
const objectRegistry& procRegistry,
|
||||
const fvMesh& procMesh,
|
||||
const word& name,
|
||||
const word& instance,
|
||||
const word& local = faMesh::meshSubDir
|
||||
)
|
||||
{
|
||||
return procAddressing(procRegistry, name, instance, local);
|
||||
return procAddressing(procMesh, name, instance, local);
|
||||
}
|
||||
|
||||
|
||||
@ -797,22 +797,11 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Field objects at this time
|
||||
IOobjectList objects;
|
||||
IOobjectList faObjects;
|
||||
|
||||
if (doDecompFields)
|
||||
{
|
||||
// List of volume mesh objects for this instance
|
||||
objects = IOobjectList(mesh, runTime.timeName());
|
||||
|
||||
// List of area mesh objects (assuming single region)
|
||||
faObjects = IOobjectList
|
||||
(
|
||||
mesh.time(),
|
||||
runTime.timeName(),
|
||||
faMesh::dbDir(mesh, word::null),
|
||||
IOobjectOption::NO_REGISTER
|
||||
);
|
||||
|
||||
// Ignore generated fields: (cellDist)
|
||||
objects.remove("cellDist");
|
||||
}
|
||||
@ -821,15 +810,12 @@ int main(int argc, char *argv[])
|
||||
autoPtr<faMeshDecomposition> faMeshDecompPtr;
|
||||
if (doFiniteArea)
|
||||
{
|
||||
const word boundaryInst =
|
||||
mesh.time().findInstance(mesh.meshDir(), "boundary");
|
||||
|
||||
IOobject io
|
||||
(
|
||||
"faBoundary",
|
||||
boundaryInst,
|
||||
faMesh::meshDir(mesh, word::null),
|
||||
mesh.time(),
|
||||
mesh.time().findInstance(mesh.meshDir(), "boundary"),
|
||||
faMesh::meshSubDir,
|
||||
mesh,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
@ -1239,7 +1225,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (doDecompFields)
|
||||
{
|
||||
areaFieldCache.readAllFields(aMesh, faObjects);
|
||||
areaFieldCache.readAllFields(aMesh, objects);
|
||||
}
|
||||
|
||||
const label nAreaFields = areaFieldCache.size();
|
||||
@ -1307,7 +1293,7 @@ int main(int argc, char *argv[])
|
||||
autoPtr<labelIOList> tfaceProcAddr =
|
||||
faProcAddressing
|
||||
(
|
||||
procMesh,
|
||||
procFvMesh,
|
||||
"faceProcAddressing",
|
||||
runTime.constant()
|
||||
);
|
||||
@ -1316,7 +1302,7 @@ int main(int argc, char *argv[])
|
||||
autoPtr<labelIOList> tboundaryProcAddr =
|
||||
faProcAddressing
|
||||
(
|
||||
procMesh,
|
||||
procFvMesh,
|
||||
"boundaryProcAddressing",
|
||||
runTime.constant()
|
||||
);
|
||||
@ -1325,7 +1311,7 @@ int main(int argc, char *argv[])
|
||||
autoPtr<labelIOList> tedgeProcAddr =
|
||||
faProcAddressing
|
||||
(
|
||||
procMesh,
|
||||
procFvMesh,
|
||||
"edgeProcAddressing",
|
||||
runTime.constant()
|
||||
);
|
||||
|
||||
@ -132,6 +132,9 @@ class domainDecomposition
|
||||
labelList& elementToZone
|
||||
);
|
||||
|
||||
//- Append single element to list
|
||||
static void append(labelList&, const label);
|
||||
|
||||
//- Add face to inter-processor patch
|
||||
void addInterProcFace
|
||||
(
|
||||
|
||||
@ -39,6 +39,14 @@ Description
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::domainDecomposition::append(labelList& lst, const label elem)
|
||||
{
|
||||
label sz = lst.size();
|
||||
lst.setSize(sz+1);
|
||||
lst[sz] = elem;
|
||||
}
|
||||
|
||||
|
||||
void Foam::domainDecomposition::addInterProcFace
|
||||
(
|
||||
const label facei,
|
||||
@ -346,8 +354,9 @@ void Foam::domainDecomposition::decomposeMesh()
|
||||
procFaceAddressing_[proci].size();
|
||||
|
||||
// Add size as last element to substarts and transfer
|
||||
subPatchStarts[proci][interPatch].append
|
||||
append
|
||||
(
|
||||
subPatchStarts[proci][interPatch],
|
||||
curInterPatchFaces[interPatch].size()
|
||||
);
|
||||
procProcessorPatchSubPatchIDs_[proci][i].transfer
|
||||
|
||||
@ -103,8 +103,8 @@ void Foam::domainDecomposition::processInterCyclics
|
||||
if (interPatchFaces[proci][interI].size() > oldSz)
|
||||
{
|
||||
// Added faces to this interface. Add an entry
|
||||
subPatchIDs[proci][interI].append(patchi);
|
||||
subPatchStarts[proci][interI].append(oldSz);
|
||||
append(subPatchIDs[proci][interI], patchi);
|
||||
append(subPatchStarts[proci][interI], oldSz);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -382,25 +382,9 @@ int main(int argc, char *argv[])
|
||||
IOobjectList objects
|
||||
(
|
||||
procMeshes.meshes()[0],
|
||||
databases[0].timeName(),
|
||||
IOobjectOption::NO_REGISTER
|
||||
databases[0].timeName()
|
||||
);
|
||||
|
||||
IOobjectList faObjects;
|
||||
|
||||
if (doFiniteArea && doFields)
|
||||
{
|
||||
// List of area mesh objects (assuming single region)
|
||||
// - scan on processor0
|
||||
faObjects = IOobjectList
|
||||
(
|
||||
procMeshes.meshes()[0],
|
||||
databases[0].timeName(),
|
||||
faMesh::dbDir(word::null), // local relative to mesh
|
||||
IOobjectOption::NO_REGISTER
|
||||
);
|
||||
}
|
||||
|
||||
if (doFields)
|
||||
{
|
||||
// If there are any FV fields, reconstruct them
|
||||
@ -561,12 +545,12 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if
|
||||
(
|
||||
faObjects.count<areaScalarField>()
|
||||
|| faObjects.count<areaVectorField>()
|
||||
|| faObjects.count<areaSphericalTensorField>()
|
||||
|| faObjects.count<areaSymmTensorField>()
|
||||
|| faObjects.count<areaTensorField>()
|
||||
|| faObjects.count<edgeScalarField>()
|
||||
objects.count<areaScalarField>()
|
||||
|| objects.count<areaVectorField>()
|
||||
|| objects.count<areaSphericalTensorField>()
|
||||
|| objects.count<areaSymmTensorField>()
|
||||
|| objects.count<areaTensorField>()
|
||||
|| objects.count<edgeScalarField>()
|
||||
)
|
||||
{
|
||||
Info << "Reconstructing FA fields" << nl << endl;
|
||||
@ -584,7 +568,7 @@ int main(int argc, char *argv[])
|
||||
procFaMeshes.boundaryProcAddressing()
|
||||
);
|
||||
|
||||
reconstructor.reconstructAllFields(faObjects);
|
||||
reconstructor.reconstructAllFields(objects);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2024 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -314,7 +314,11 @@ boundBox procBounds
|
||||
{
|
||||
fileName pointsInstance
|
||||
(
|
||||
procDb.findInstance(polyMesh::meshDir(regionName), "points")
|
||||
procDb.findInstance
|
||||
(
|
||||
polyMesh::meshDir(regionName),
|
||||
"points"
|
||||
)
|
||||
);
|
||||
|
||||
if (pointsInstance != procDb.timeName())
|
||||
@ -339,7 +343,11 @@ boundBox procBounds
|
||||
IOobject
|
||||
(
|
||||
"points",
|
||||
pointsInstance,
|
||||
procDb.findInstance
|
||||
(
|
||||
polyMesh::meshDir(regionName),
|
||||
"points"
|
||||
),
|
||||
polyMesh::meshDir(regionName),
|
||||
procDb,
|
||||
IOobject::MUST_READ,
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2012-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2024 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -31,7 +31,6 @@ License
|
||||
#include "Pstream.H"
|
||||
#include "OSspecific.H"
|
||||
#include "decomposedBlockData.H"
|
||||
#include "IFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
@ -162,54 +161,19 @@ Foam::boolList Foam::haveMeshFile
|
||||
(
|
||||
handler.filePath(runTime.path()/meshPath/meshFile)
|
||||
);
|
||||
|
||||
bool found = handler.isFile(fName);
|
||||
if (returnReduceAnd(found)) // worldComm
|
||||
{
|
||||
// Bit tricky: avoid having all slaves open file since this involves
|
||||
// reading it on master and broadcasting it. This fails if file > 2G.
|
||||
// So instead only read on master
|
||||
|
||||
bool isCollated = false;
|
||||
|
||||
// Note: can test only world-master. Since even host-collated will have
|
||||
// same file format type for all processors
|
||||
if (UPstream::master(UPstream::worldComm))
|
||||
autoPtr<ISstream> isPtr(fileHandler().NewIFstream(fName));
|
||||
if (isPtr && isPtr->good())
|
||||
{
|
||||
const bool oldParRun = UPstream::parRun(false);
|
||||
auto& is = *isPtr;
|
||||
|
||||
IFstream is(fName);
|
||||
if (is.good())
|
||||
{
|
||||
IOobject io(meshFile, meshPath, runTime);
|
||||
io.readHeader(is);
|
||||
IOobject io(meshFile, meshPath, runTime);
|
||||
io.readHeader(is);
|
||||
|
||||
isCollated = decomposedBlockData::isCollatedType(io);
|
||||
}
|
||||
UPstream::parRun(oldParRun);
|
||||
}
|
||||
Pstream::broadcast(isCollated); //UPstream::worldComm
|
||||
|
||||
|
||||
// Collect block-number in individual filenames (might differ
|
||||
// on different processors)
|
||||
if (isCollated)
|
||||
{
|
||||
const label nProcs = UPstream::nProcs(fileHandler().comm());
|
||||
const label myProcNo = UPstream::myProcNo(fileHandler().comm());
|
||||
|
||||
// Collect file names on master of local communicator
|
||||
const fileNameList fNames
|
||||
(
|
||||
Pstream::listGatherValues
|
||||
(
|
||||
fName,
|
||||
fileHandler().comm(),
|
||||
UPstream::msgType()
|
||||
)
|
||||
);
|
||||
|
||||
// Collect local block number
|
||||
label myBlockNumber = -1;
|
||||
if (decomposedBlockData::isCollatedType(io))
|
||||
{
|
||||
fileName path, pDir, local;
|
||||
procRangeType group;
|
||||
@ -224,6 +188,7 @@ Foam::boolList Foam::haveMeshFile
|
||||
numProcs
|
||||
);
|
||||
|
||||
label myBlockNumber = 0;
|
||||
if (proci == -1 && group.empty())
|
||||
{
|
||||
// 'processorsXXX' format so contains all ranks
|
||||
@ -234,53 +199,12 @@ Foam::boolList Foam::haveMeshFile
|
||||
{
|
||||
// 'processorsXXX_n-m' format so check for the
|
||||
// relative rank
|
||||
myBlockNumber = myProcNo;
|
||||
myBlockNumber = UPstream::myProcNo(fileHandler().comm());
|
||||
}
|
||||
|
||||
// Check if block for the local rank is inside file
|
||||
found = decomposedBlockData::hasBlock(is, myBlockNumber);
|
||||
}
|
||||
const labelList myBlockNumbers
|
||||
(
|
||||
Pstream::listGatherValues
|
||||
(
|
||||
myBlockNumber,
|
||||
fileHandler().comm(),
|
||||
UPstream::msgType()
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
|
||||
// Determine for all whether the filename exists in the collated
|
||||
// file.
|
||||
boolList allFound(nProcs, false);
|
||||
|
||||
if (UPstream::master(fileHandler().comm()))
|
||||
{
|
||||
// Store nBlocks and index of file that was used for nBlocks
|
||||
label nBlocks = -1;
|
||||
label blockRanki = -1;
|
||||
forAll(fNames, ranki)
|
||||
{
|
||||
if
|
||||
(
|
||||
blockRanki == -1
|
||||
|| (fNames[ranki] != fNames[blockRanki])
|
||||
)
|
||||
{
|
||||
blockRanki = ranki;
|
||||
IFstream is(fNames[ranki]);
|
||||
nBlocks = decomposedBlockData::getNumBlocks(is);
|
||||
}
|
||||
|
||||
allFound[ranki] = (myBlockNumbers[ranki] < nBlocks);
|
||||
}
|
||||
}
|
||||
|
||||
found = Pstream::listScatterValues
|
||||
(
|
||||
allFound,
|
||||
fileHandler().comm(),
|
||||
UPstream::msgType()
|
||||
);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -184,7 +184,7 @@ Foam::parLagrangianDistributor::distributeLagrangianPositions
|
||||
labelListList sendMap;
|
||||
|
||||
// Transfer buffers
|
||||
PstreamBuffers pBufs;
|
||||
PstreamBuffers pBufs(UPstream::commsTypes::nonBlocking);
|
||||
|
||||
{
|
||||
// List of lists of particles to be transferred for all of the
|
||||
|
||||
@ -102,7 +102,6 @@ Usage
|
||||
#include "faMeshSubset.H"
|
||||
#include "faMeshTools.H"
|
||||
#include "faMeshDistributor.H"
|
||||
#include "faMeshesRegistry.H"
|
||||
#include "parFaFieldDistributorCache.H"
|
||||
|
||||
#include "redistributeLagrangian.H"
|
||||
@ -907,26 +906,12 @@ autoPtr<mapDistributePolyMesh> redistributeAndWrite
|
||||
}
|
||||
|
||||
|
||||
// If faMeshesRegistry exists, it is also owned by the polyMesh and will
|
||||
// be destroyed by clearGeom() in fvMeshDistribute::distribute()
|
||||
//
|
||||
// Rescue faMeshesRegistry from destruction by temporarily moving
|
||||
// it to be locally owned.
|
||||
std::unique_ptr<faMeshesRegistry> faMeshesRegistry_saved
|
||||
(
|
||||
faMeshesRegistry::Release(mesh)
|
||||
);
|
||||
|
||||
// Mesh distribution engine
|
||||
fvMeshDistribute distributor(mesh);
|
||||
|
||||
// Do all the distribution of mesh and fields
|
||||
autoPtr<mapDistributePolyMesh> distMap = distributor.distribute(decomp);
|
||||
|
||||
// Restore ownership onto the polyMesh
|
||||
faMeshesRegistry::Store(std::move(faMeshesRegistry_saved));
|
||||
|
||||
|
||||
// Print some statistics
|
||||
InfoOrPout<< "After distribution:" << endl;
|
||||
printMeshData(mesh);
|
||||
@ -1613,8 +1598,7 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
const fileName areaMeshSubDir
|
||||
(
|
||||
// Assume single-region area mesh
|
||||
faMesh::meshDir(regionName, word::null)
|
||||
polyMesh::regionName(regionName) / faMesh::meshSubDir
|
||||
);
|
||||
|
||||
InfoOrPout
|
||||
@ -2517,8 +2501,7 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
const fileName areaMeshSubDir
|
||||
(
|
||||
// Assume single-region area mesh
|
||||
faMesh::meshDir(regionName, word::null)
|
||||
polyMesh::regionName(regionName) / faMesh::meshSubDir
|
||||
);
|
||||
|
||||
InfoOrPout
|
||||
|
||||
@ -21,38 +21,29 @@ Requires
|
||||
|
||||
// Initially all possible objects that are available at the final time
|
||||
List<wordHashSet> availableRegionObjectNames(meshes.size());
|
||||
List<wordHashSet> availableFaRegionObjectNames(meshes.size());
|
||||
|
||||
forAll(meshes, regioni)
|
||||
{
|
||||
const auto& mesh = meshes[regioni];
|
||||
|
||||
IOobjectList objects;
|
||||
IOobjectList faObjects;
|
||||
IOobjectList objects(0);
|
||||
|
||||
if (doConvertFields && !timeDirs.empty())
|
||||
{
|
||||
// List of volume mesh objects for this instance
|
||||
objects = IOobjectList(mesh, timeDirs.back().name());
|
||||
|
||||
// List of area mesh objects (assuming single region)
|
||||
faObjects = IOobjectList
|
||||
(
|
||||
mesh.time(),
|
||||
timeDirs.back().name(),
|
||||
faMesh::dbDir(mesh, word::null),
|
||||
IOobjectOption::NO_REGISTER
|
||||
);
|
||||
|
||||
if (fieldSelector && !fieldSelector().empty())
|
||||
{
|
||||
objects.filterObjects(fieldSelector());
|
||||
faObjects.filterObjects(fieldSelector());
|
||||
}
|
||||
|
||||
if (fieldSelector && !fieldSelector().empty())
|
||||
{
|
||||
objects.filterObjects(fieldSelector());
|
||||
}
|
||||
|
||||
// Remove "*_0" restart fields
|
||||
objects.prune_0();
|
||||
faObjects.prune_0();
|
||||
|
||||
if (!doPointValues)
|
||||
{
|
||||
@ -68,38 +59,12 @@ forAll(meshes, regioni)
|
||||
}
|
||||
}
|
||||
|
||||
// Volume fields
|
||||
if (!objects.empty())
|
||||
{
|
||||
wordList objectNames(objects.sortedNames());
|
||||
wordList objectNames(objects.sortedNames());
|
||||
|
||||
// Check availability for all times...
|
||||
checkData
|
||||
(
|
||||
mesh.thisDb(),
|
||||
timeDirs,
|
||||
objectNames
|
||||
);
|
||||
// Check availability for all times...
|
||||
checkData(mesh, timeDirs, objectNames);
|
||||
|
||||
availableRegionObjectNames[regioni] = objectNames;
|
||||
}
|
||||
|
||||
// Area fields
|
||||
if (!faObjects.empty())
|
||||
{
|
||||
wordList objectNames(faObjects.sortedNames());
|
||||
|
||||
// Check availability for all times... (assuming single region)
|
||||
checkData
|
||||
(
|
||||
mesh.time(),
|
||||
timeDirs,
|
||||
objectNames,
|
||||
faMesh::dbDir(mesh, word::null)
|
||||
);
|
||||
|
||||
availableFaRegionObjectNames[regioni] = objectNames;
|
||||
}
|
||||
availableRegionObjectNames[regioni] = objectNames;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2021-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
@ -14,8 +14,6 @@ Description
|
||||
Code chunk for converting area fields
|
||||
included by foamToEnsight.
|
||||
|
||||
Possible objects to convert are given in faObjects
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -25,7 +23,7 @@ if (doFiniteArea && ensFaCasePtr && ensFaMeshPtr)
|
||||
{
|
||||
Info<< " area field (";
|
||||
|
||||
writeAllAreaFields(*ensFaCasePtr, *ensFaMeshPtr, faObjects);
|
||||
writeAllAreaFields(*ensFaCasePtr, *ensFaMeshPtr, objects);
|
||||
|
||||
Info<< " )" << nl;
|
||||
}
|
||||
|
||||
@ -554,8 +554,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
autoPtr<ensightGeoFile> os =
|
||||
ensCase.newGeometry(hasMovingMesh);
|
||||
|
||||
ensMesh.write(os.ref());
|
||||
ensMesh.write(os);
|
||||
}
|
||||
|
||||
// finite-area
|
||||
@ -563,8 +562,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
autoPtr<ensightGeoFile> os =
|
||||
ensFaCasePtr->newGeometry(hasMovingMesh);
|
||||
|
||||
ensFaMeshPtr->write(os.ref());
|
||||
ensFaMeshPtr->write(os);
|
||||
}
|
||||
}
|
||||
|
||||
@ -579,20 +577,6 @@ int main(int argc, char *argv[])
|
||||
// Volume, internal, point fields
|
||||
#include "convertVolumeFields.H"
|
||||
|
||||
// The finite-area objects at this time
|
||||
IOobjectList faObjects;
|
||||
|
||||
if (ensFaMeshPtr)
|
||||
{
|
||||
faObjects =
|
||||
IOobjectList(ensFaMeshPtr->mesh(), runTime.timeName());
|
||||
|
||||
faObjects.filterObjects
|
||||
(
|
||||
availableFaRegionObjectNames[regioni]
|
||||
);
|
||||
}
|
||||
|
||||
// The finiteArea fields
|
||||
#include "convertAreaFields.H"
|
||||
|
||||
|
||||
@ -55,7 +55,7 @@ label timeIndex = 0;
|
||||
else
|
||||
{
|
||||
goodTimeIndex = false;
|
||||
Info<< "skip ... missing file: " << io.objectRelPath() << endl;
|
||||
Info<< "skip ... missing entry " << io.objectPath() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -32,10 +32,9 @@ License
|
||||
|
||||
Foam::label Foam::checkData
|
||||
(
|
||||
const objectRegistry& obr,
|
||||
const fvMesh& mesh,
|
||||
const instantList& timeDirs,
|
||||
wordList& objectNames,
|
||||
const fileName& local
|
||||
wordList& objectNames
|
||||
)
|
||||
{
|
||||
// Assume prune_0() was used prior to calling this
|
||||
@ -44,9 +43,6 @@ Foam::label Foam::checkData
|
||||
|
||||
for (const word& fieldName : objectNames)
|
||||
{
|
||||
// // If prune_0() not previously used...
|
||||
// if (objectNames.ends_with("_0")) continue;
|
||||
|
||||
bool good = false;
|
||||
|
||||
for (const instant& inst : timeDirs)
|
||||
@ -56,8 +52,7 @@ Foam::label Foam::checkData
|
||||
(
|
||||
fieldName,
|
||||
inst.name(),
|
||||
local,
|
||||
obr,
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
|
||||
@ -164,10 +164,9 @@ tmp<VolumeField<Type>> makeZeroGradientField
|
||||
// ignore fields that are not available for all time-steps
|
||||
label checkData
|
||||
(
|
||||
const objectRegistry& obr,
|
||||
const fvMesh& mesh,
|
||||
const instantList& timeDirs,
|
||||
wordList& objectNames,
|
||||
const fileName& local = fileName::null
|
||||
wordList& objectNames
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2023-2024 OpenCFD Ltd.
|
||||
Copyright (C) 2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -36,7 +36,6 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "timeSelector.H"
|
||||
#include "fvMesh.H"
|
||||
#include "volFields.H"
|
||||
#include "pointFields.H"
|
||||
@ -146,22 +145,20 @@ 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"
|
||||
|
||||
// Set time from specified time options, or force start from Time=0
|
||||
timeSelector::setTimeIfPresent(runTime, args, true);
|
||||
// Get times list
|
||||
instantList Times = runTime.times();
|
||||
#include "checkTimeOptions.H"
|
||||
runTime.setTime(Times[startTime], startTime);
|
||||
|
||||
// Read the mesh
|
||||
#include "createNamedMesh.H"
|
||||
|
||||
@ -29,7 +29,7 @@ if (doFiniteArea)
|
||||
autoPtr<faMesh> faMeshPtr;
|
||||
|
||||
const label nAreaFields =
|
||||
faObjects.count(stringListOps::foundOp<word>(fieldTypes::area));
|
||||
objects.count(stringListOps::foundOp<word>(fieldTypes::area));
|
||||
|
||||
if (nAreaFields || withMeshIds)
|
||||
{
|
||||
@ -40,7 +40,7 @@ if (doFiniteArea)
|
||||
{
|
||||
const faMesh& areaMesh = faMeshPtr();
|
||||
|
||||
reportFields::area(Info, faObjects);
|
||||
reportFields::area(Info, objects);
|
||||
|
||||
const auto& pp = faMeshPtr->patch();
|
||||
|
||||
@ -97,7 +97,7 @@ if (doFiniteArea)
|
||||
(
|
||||
writer,
|
||||
areaMesh,
|
||||
faObjects,
|
||||
objects,
|
||||
true // syncPar
|
||||
);
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -141,7 +141,7 @@ Note
|
||||
#include "pointSet.H"
|
||||
#include "HashOps.H"
|
||||
#include "regionProperties.H"
|
||||
#include "stringListOps.H" // For stringListOps::findMatching()
|
||||
#include "stringListOps.H"
|
||||
|
||||
#include "Cloud.H"
|
||||
#include "readFields.H"
|
||||
@ -780,34 +780,21 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
IOobjectList objects;
|
||||
IOobjectList faObjects;
|
||||
IOobjectList objects(0);
|
||||
|
||||
if (doConvertFields)
|
||||
{
|
||||
// List of volume mesh objects for this instance
|
||||
// List of objects for this time
|
||||
objects =
|
||||
IOobjectList(meshProxy.baseMesh(), runTime.timeName());
|
||||
|
||||
// List of area mesh objects (assuming single region)
|
||||
faObjects =
|
||||
IOobjectList
|
||||
(
|
||||
runTime,
|
||||
runTime.timeName(),
|
||||
faMesh::dbDir(meshProxy.baseMesh(), word::null),
|
||||
IOobjectOption::NO_REGISTER
|
||||
);
|
||||
|
||||
if (fieldSelector && !fieldSelector().empty())
|
||||
{
|
||||
objects.filterObjects(fieldSelector());
|
||||
faObjects.filterObjects(fieldSelector());
|
||||
}
|
||||
|
||||
// Remove "*_0" restart fields
|
||||
objects.prune_0();
|
||||
faObjects.prune_0();
|
||||
|
||||
if (!doPointValues)
|
||||
{
|
||||
|
||||
@ -353,7 +353,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
#include "createTime.H"
|
||||
|
||||
runTime.setTime(instant(0, runTime.constant()), 0);
|
||||
runTime.setTime(instant(runTime.constant()), 0);
|
||||
|
||||
#include "createNamedMesh.H"
|
||||
|
||||
|
||||
@ -106,7 +106,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
|
||||
runTime.setTime(instant(0, runTime.constant()), 0);
|
||||
runTime.setTime(instant(runTime.constant()), 0);
|
||||
|
||||
#include "createNamedMesh.H"
|
||||
|
||||
|
||||
@ -80,6 +80,7 @@ Usage
|
||||
#include "IOobjectList.H"
|
||||
#include "IOPtrList.H"
|
||||
#include "volFields.H"
|
||||
#include "stringListOps.H"
|
||||
#include "timeSelector.H"
|
||||
|
||||
using namespace Foam;
|
||||
@ -188,7 +189,7 @@ labelList findMatches
|
||||
const HashTable<wordList>& shortcuts,
|
||||
const wordList& shortcutNames,
|
||||
const wordList& thisKeys,
|
||||
const wordRe& key
|
||||
const keyType& key
|
||||
)
|
||||
{
|
||||
labelList matches;
|
||||
@ -196,20 +197,20 @@ labelList findMatches
|
||||
if (key.isPattern())
|
||||
{
|
||||
// Wildcard match
|
||||
matches = wordRes::matching(key, thisKeys);
|
||||
matches = findStrings(key, thisKeys);
|
||||
}
|
||||
else if (shortcuts.size())
|
||||
{
|
||||
// See if patchGroups expand to valid thisKeys
|
||||
labelList indices = wordRes::matching(key, shortcutNames);
|
||||
labelList indices = findStrings(key, shortcutNames);
|
||||
|
||||
for (const label idx : indices)
|
||||
{
|
||||
const word& name = shortcutNames[idx];
|
||||
const wordList& keys = shortcuts[name];
|
||||
for (const word& k : keys)
|
||||
forAll(keys, j)
|
||||
{
|
||||
const label index = thisKeys.find(k);
|
||||
const label index = thisKeys.find(keys[j]);
|
||||
if (index != -1)
|
||||
{
|
||||
matches.append(index);
|
||||
|
||||
@ -26,8 +26,8 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef Foam_MapConsistentVolFields_H
|
||||
#define Foam_MapConsistentVolFields_H
|
||||
#ifndef MapConsistentVolFields_H
|
||||
#define MapConsistentVolFields_H
|
||||
|
||||
#include "GeometricField.H"
|
||||
#include "meshToMesh.H"
|
||||
@ -41,42 +41,48 @@ namespace Foam
|
||||
template<class Type>
|
||||
void evaluateConstraintTypes(GeometricField<Type, fvPatchField, volMesh>& fld)
|
||||
{
|
||||
auto& bfld = fld.boundaryFieldRef();
|
||||
auto& fldBf = fld.boundaryFieldRef();
|
||||
|
||||
const UPstream::commsTypes commsType = UPstream::defaultCommsType;
|
||||
const label startOfRequests = UPstream::nRequests();
|
||||
|
||||
if
|
||||
(
|
||||
commsType == UPstream::commsTypes::buffered
|
||||
commsType == UPstream::commsTypes::blocking
|
||||
|| commsType == UPstream::commsTypes::nonBlocking
|
||||
)
|
||||
{
|
||||
const label startOfRequests = UPstream::nRequests();
|
||||
|
||||
for (auto& pfld : bfld)
|
||||
forAll(fldBf, patchi)
|
||||
{
|
||||
fvPatchField<Type>& tgtField = fldBf[patchi];
|
||||
|
||||
if
|
||||
(
|
||||
pfld.type() == pfld.patch().patch().type()
|
||||
&& polyPatch::constraintType(pfld.patch().patch().type())
|
||||
tgtField.type() == tgtField.patch().patch().type()
|
||||
&& polyPatch::constraintType(tgtField.patch().patch().type())
|
||||
)
|
||||
{
|
||||
pfld.initEvaluate(commsType);
|
||||
tgtField.initEvaluate(commsType);
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for outstanding requests (non-blocking)
|
||||
UPstream::waitRequests(startOfRequests);
|
||||
|
||||
for (auto& pfld : bfld)
|
||||
// Wait for outstanding requests
|
||||
if (commsType == UPstream::commsTypes::nonBlocking)
|
||||
{
|
||||
UPstream::waitRequests(startOfRequests);
|
||||
}
|
||||
|
||||
forAll(fldBf, patchi)
|
||||
{
|
||||
fvPatchField<Type>& tgtField = fldBf[patchi];
|
||||
|
||||
if
|
||||
(
|
||||
pfld.type() == pfld.patch().patch().type()
|
||||
&& polyPatch::constraintType(pfld.patch().patch().type())
|
||||
tgtField.type() == tgtField.patch().patch().type()
|
||||
&& polyPatch::constraintType(tgtField.patch().patch().type())
|
||||
)
|
||||
{
|
||||
pfld.evaluate(commsType);
|
||||
tgtField.evaluate(commsType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -88,21 +94,22 @@ void evaluateConstraintTypes(GeometricField<Type, fvPatchField, volMesh>& fld)
|
||||
for (const auto& schedEval : patchSchedule)
|
||||
{
|
||||
const label patchi = schedEval.patch;
|
||||
auto& pfld = bfld[patchi];
|
||||
|
||||
fvPatchField<Type>& tgtField = fldBf[patchi];
|
||||
|
||||
if
|
||||
(
|
||||
pfld.type() == pfld.patch().patch().type()
|
||||
&& polyPatch::constraintType(pfld.patch().patch().type())
|
||||
tgtField.type() == tgtField.patch().patch().type()
|
||||
&& polyPatch::constraintType(tgtField.patch().patch().type())
|
||||
)
|
||||
{
|
||||
if (schedEval.init)
|
||||
{
|
||||
pfld.initEvaluate(commsType);
|
||||
tgtField.initEvaluate(commsType);
|
||||
}
|
||||
else
|
||||
{
|
||||
pfld.evaluate(commsType);
|
||||
tgtField.evaluate(commsType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2017 DHI
|
||||
Copyright (C) 2017-2024 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2020 German Aerospace Center (DLR)
|
||||
Copyright (C) 2020 Johan Roenby
|
||||
-------------------------------------------------------------------------------
|
||||
@ -39,7 +39,6 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "timeSelector.H"
|
||||
|
||||
#include "triSurface.H"
|
||||
#include "triSurfaceTools.H"
|
||||
@ -140,10 +139,6 @@ 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 "
|
||||
@ -156,14 +151,9 @@ 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-2024 OpenCFD Ltd.
|
||||
Copyright (C) 2022-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -36,7 +36,6 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "timeSelector.H"
|
||||
#include "Time.H"
|
||||
#include "fvMesh.H"
|
||||
#include "faMesh.H"
|
||||
@ -657,10 +656,6 @@ 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"
|
||||
@ -675,15 +670,8 @@ 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;
|
||||
|
||||
@ -51,7 +51,6 @@ Description
|
||||
#include "emptyPolyPatch.H"
|
||||
#include "processorPolyPatch.H"
|
||||
#include "ListListOps.H"
|
||||
#include "stringListOps.H" // For stringListOps::findMatching()
|
||||
#include "indirectPrimitivePatch.H"
|
||||
#include "globalMeshData.H"
|
||||
#include "globalIndex.H"
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2014 OpenFOAM Foundation
|
||||
Copyright (C) 2020-2024 OpenCFD Ltd.
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -294,7 +294,7 @@ bool Foam::searchableSurfaceModifiers::cut::modify
|
||||
// Find the surfaces to cut with
|
||||
for (const wordRe& cutterName : cutterNames_)
|
||||
{
|
||||
labelList geomIDs = wordRes::matching(cutterName, geometry_.names());
|
||||
labelList geomIDs = findStrings(cutterName, geometry_.names());
|
||||
|
||||
for (const label geomI : geomIDs)
|
||||
{
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2024 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -130,14 +130,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (const entry& e : regionsDict)
|
||||
{
|
||||
const wordRe regionName(e.keyword());
|
||||
const keyType& regionName = e.keyword();
|
||||
const dictionary& regionDict = e.dict();
|
||||
|
||||
labelList regionIDs
|
||||
(
|
||||
wordRes::matching(regionName, surf.regions())
|
||||
);
|
||||
|
||||
autoPtr<searchableSurfaceModifier> modifier
|
||||
(
|
||||
searchableSurfaceModifier::New
|
||||
@ -148,6 +143,9 @@ int main(int argc, char *argv[])
|
||||
)
|
||||
);
|
||||
|
||||
labelList regionIDs =
|
||||
findStrings(regionName, surf.regions());
|
||||
|
||||
if (modifier().modify(regionIDs, surf))
|
||||
{
|
||||
changed = true;
|
||||
|
||||
@ -56,7 +56,7 @@ Usage
|
||||
|
||||
#include "argList.H"
|
||||
#include "MeshedSurfaces.H"
|
||||
#include "stringListOps.H" // For stringListOps::findMatching()
|
||||
#include "stringListOps.H"
|
||||
#include "geometricSurfacePatch.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -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,322 +0,0 @@
|
||||
#!/bin/bash
|
||||
#------------------------------------------------------------------------------
|
||||
# ========= |
|
||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
# \\ / O peration |
|
||||
# \\ / A nd | www.openfoam.com
|
||||
# \\/ M anipulation |
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright (C) 2023-2024 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
#
|
||||
# Script
|
||||
# foamUpgradeFiniteArea
|
||||
#
|
||||
# Description
|
||||
# Relocate finite-area files to new sub-directory locations
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
printHelp() {
|
||||
cat <<USAGE
|
||||
|
||||
Usage: ${0##*/} [OPTION]
|
||||
options:
|
||||
-case=DIR Specify starting directory, default is cwd
|
||||
-dry-run | -n Test without performing actions
|
||||
-verbose | -v Additional verbosity
|
||||
-force (currently ignored)
|
||||
-link-back Link back from new finite-area/ to old locations
|
||||
-no-mesh Do not move system/faMeshDefinition
|
||||
-git Use 'git mv' when making changes
|
||||
-help Print help and exit
|
||||
|
||||
Relocate finite-area files to new sub-directory locations
|
||||
|
||||
Equivalent options:
|
||||
| -case=DIR | -case DIR |
|
||||
|
||||
USAGE
|
||||
exit 0 # A clean exit
|
||||
}
|
||||
|
||||
# Report error and exit
|
||||
die()
|
||||
{
|
||||
exec 1>&2
|
||||
echo
|
||||
echo "Error encountered:"
|
||||
while [ "$#" -ge 1 ]; do echo " $1"; shift; done
|
||||
echo
|
||||
echo "See '${0##*/} -help' for usage"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Parse options
|
||||
unset caseDir optDryRun optGit optVerbose optLink optMeshDef hadError
|
||||
|
||||
while [ "$#" -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
(- | --)
|
||||
shift
|
||||
break # Stop option parsing
|
||||
;;
|
||||
(-h | -help*) printHelp ;;
|
||||
|
||||
(-n | -dry-run) optDryRun="(dry-run) " ;;
|
||||
(-v | -verbose) optVerbose=true ;;
|
||||
(-f | -force) echo "Ignored option: ${1%%=*}" 1>&2 ;;
|
||||
(-link-back) optLink=back ;;
|
||||
# (-link-only) optLink=forward ;;
|
||||
(-no-mesh) optMeshDef=false ;;
|
||||
(-git) optGit=true ;;
|
||||
|
||||
(-case=*)
|
||||
caseDir="${1#*=}"
|
||||
;;
|
||||
(-case)
|
||||
caseDir="$2"
|
||||
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
|
||||
shift
|
||||
;;
|
||||
|
||||
(-*) die "unknown option: $1" ;;
|
||||
(*) die "unknown argument: $1" ;;
|
||||
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ -n "$caseDir" ]
|
||||
then
|
||||
cd "$caseDir" 2>/dev/null || {
|
||||
echo "${0##*/}: No such directory $caseDir" 1>&2
|
||||
exit 2
|
||||
}
|
||||
fi
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Proper umask
|
||||
umask 022
|
||||
|
||||
# The commands
|
||||
copy_cmd="cp -a${optVerbose:+ -v}"
|
||||
move_cmd="mv${optVerbose:+ -v}"
|
||||
link_cmd="ln -sf${optVerbose:+ -v}"
|
||||
mkdir_cmd="mkdir -p"
|
||||
|
||||
if [ -n "$optDryRun" ]
|
||||
then
|
||||
if [ -n "$optVerbose" ]
|
||||
then
|
||||
copy_cmd="echo cp -a"
|
||||
move_cmd="echo mv"
|
||||
link_cmd="echo ln -sf"
|
||||
mkdir_cmd="echo mkdir -p"
|
||||
else
|
||||
copy_cmd=true
|
||||
move_cmd=true
|
||||
link_cmd=true
|
||||
mkdir_cmd=true
|
||||
fi
|
||||
elif [ -n "$optGit" ]
|
||||
then
|
||||
move_cmd="git mv"
|
||||
link_cmd="echo no symlink for git:"
|
||||
fi
|
||||
|
||||
regionDir="finite-area"
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Various script parts
|
||||
#
|
||||
# awk : scan file for FoamFile { ... class NAME; }
|
||||
|
||||
read -d '' getClass_awk << 'AWK_CONTENT'
|
||||
BEGIN { state = 0 } # 0=begin, 1=header, 2=done
|
||||
|
||||
/FoamFile/ { if (!state) { state = 1; next; } exit; }
|
||||
|
||||
# FoamFile begin contents
|
||||
/\{/ { if (state == 1) state = 2; next; }
|
||||
|
||||
# FoamFile end contents
|
||||
/\}/ { if (state == 2) exit; next; }
|
||||
|
||||
/^[ ]*class[ ]/ {
|
||||
if (state == 2)
|
||||
{
|
||||
sub("^[ ]*class[ ]+", "")
|
||||
sub("[ ;]*$", "")
|
||||
print
|
||||
exit
|
||||
}
|
||||
next
|
||||
}
|
||||
AWK_CONTENT
|
||||
|
||||
|
||||
# Check for FoamFile and return extracted 'class'
|
||||
getFoamFile_class()
|
||||
{
|
||||
local file="$1"
|
||||
local class
|
||||
|
||||
if grep -q FoamFile "$file" 2>/dev/null
|
||||
then
|
||||
# class="$(foamDictionary -disableFunctionEntries -entry FoamFile/class -value "$file" 2> stderr)"
|
||||
class="$(awk -- "$getClass_awk" "$file")"
|
||||
fi
|
||||
echo "$class"
|
||||
}
|
||||
|
||||
|
||||
# Check if class corresponds to an finite-area field
|
||||
# eg, areaScalarField, ... edgeVectorField
|
||||
isAreaFieldClass()
|
||||
{
|
||||
case "$1" in
|
||||
(area*Field | edge*Field) return 0 ;;
|
||||
esac
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#Debug# getFoamFile_class "system/faSchemes"
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Link back from the local finite-area/ directory to the current directory
|
||||
# variables
|
||||
# - regionDir = "finite-area"
|
||||
#
|
||||
performLinkBack()
|
||||
{
|
||||
local file
|
||||
|
||||
if [ -d "$regionDir" ]
|
||||
then
|
||||
find "$regionDir" -maxdepth 1 -type f 2>/dev/null | while read file
|
||||
do
|
||||
file="${file#*/}"
|
||||
|
||||
if [ -f "$regionDir/$file" ] && [ ! -f "$file" ]
|
||||
then
|
||||
echo "${optDryRun} ln -s $regionDir/$file $file" 1>&2
|
||||
$link_cmd "$regionDir/$file" "$file"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Move from current directory to local finite-area/ directory
|
||||
# variables
|
||||
# - regionDir = "finite-area"
|
||||
#
|
||||
performMove()
|
||||
{
|
||||
local file="$1"
|
||||
|
||||
if [ -f "$regionDir/$file" ]
|
||||
then
|
||||
echo "${optDryRun} already: $regionDir/$file" 1>&2
|
||||
elif [ -f "$file" ]
|
||||
then
|
||||
$mkdir_cmd "$regionDir"
|
||||
echo "${optDryRun} mv $file -> $regionDir/" 1>&2
|
||||
$move_cmd "$file" "$regionDir/$file"
|
||||
elif [ -n "$file" ]
|
||||
then
|
||||
echo "${optDryRun} no $file" 1>&2
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# system
|
||||
# ----
|
||||
if [ -d system ]
|
||||
then
|
||||
(
|
||||
cd system || exit
|
||||
currDir="system"
|
||||
|
||||
echo "${optDryRun}Examining files in $currDir/" 1>&2
|
||||
|
||||
performMove faSchemes
|
||||
performMove faSolution
|
||||
|
||||
if [ "$optMeshDef" = false ]
|
||||
then
|
||||
echo "${optDryRun} ignore: faMeshDefinition" 1>&2
|
||||
else
|
||||
performMove faMeshDefinition
|
||||
fi
|
||||
|
||||
if [ -d "$regionDir" ] && [ "$optLink" = back ]
|
||||
then
|
||||
performLinkBack
|
||||
fi
|
||||
)
|
||||
else
|
||||
echo "${optDryRun}No system/ directory..." 1>&2
|
||||
fi
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# time dirs (initial conditions)
|
||||
# ----
|
||||
|
||||
for timeDir in 0 0.orig
|
||||
do
|
||||
if [ -d "$timeDir" ]
|
||||
then
|
||||
(
|
||||
cd "$timeDir" || exit
|
||||
currDir="$timeDir"
|
||||
|
||||
echo "${optDryRun}Examining $currDir/" 1>&2
|
||||
|
||||
find . -maxdepth 1 -type f | while read file
|
||||
do
|
||||
file="${file#*/}"
|
||||
|
||||
case "$file" in
|
||||
(*.gz)
|
||||
echo "${optDryRun} ignoring compressed file: $file" 1>&2
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
|
||||
className="$(getFoamFile_class "$file")"
|
||||
|
||||
if isAreaFieldClass "$className"
|
||||
then
|
||||
performMove "$file"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -d "$regionDir" ] && [ "$optLink" = back ]
|
||||
then
|
||||
performLinkBack
|
||||
fi
|
||||
)
|
||||
else
|
||||
echo "${optDryRun}No $timeDir/ directory..." 1>&2
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@ -6,7 +6,7 @@
|
||||
# \\/ M anipulation |
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
# Copyright (C) 2015-2024 OpenCFD Ltd.
|
||||
# Copyright (C) 2015-2023 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
@ -501,9 +501,9 @@ cloneParallelCase()
|
||||
}
|
||||
|
||||
|
||||
# If 0.orig/ exists, copy (overwrite) into 0/ [ie, serial case]
|
||||
# * -processor : copy into processor directories instead
|
||||
# * -all : copy into serial and processor directories
|
||||
# Overwrite 0/ with the contents of 0.orig/ if it exists.
|
||||
# The -processor option to do the processor directories instead
|
||||
#
|
||||
restore0Dir()
|
||||
{
|
||||
if [ ! -d 0.orig ]
|
||||
@ -513,27 +513,35 @@ restore0Dir()
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
(-all | -proc | -processor*)
|
||||
if [ "$1" = "-all" ]
|
||||
then
|
||||
echo "Restore 0/ from 0.orig/ [serial/processor dirs]" 1>&2
|
||||
\rm -rf 0
|
||||
\cp -r 0.orig 0 2>/dev/null
|
||||
else
|
||||
echo "Restore 0/ from 0.orig/ [processor dirs]" 1>&2
|
||||
fi
|
||||
-proc | -processor | -processors)
|
||||
echo "Restore 0/ from 0.orig/ [processor directories]"
|
||||
|
||||
\ls -d processor* | xargs -I {} \rm -rf ./{}/0
|
||||
\ls -d processor* | xargs -I {} \cp -r 0.orig ./{}/0 > /dev/null 2>&1
|
||||
|
||||
# Remove '#include' directives from field dictionaries
|
||||
# for collated format
|
||||
if [ "$1" = "-processors" ]
|
||||
then
|
||||
(
|
||||
echo "Filter #include directives in processors/0:"
|
||||
\cd processors/0 2>/dev/null || exit 0
|
||||
for file in $(grep -l "#include" * 2>/dev/null)
|
||||
do
|
||||
foamDictionary "$file" > "$file.$$." && mv "$file.$$." "$file"
|
||||
echo " $file"
|
||||
done | tr -d '\n'
|
||||
echo
|
||||
)
|
||||
fi
|
||||
;;
|
||||
|
||||
(*)
|
||||
echo "Restore 0/ from 0.orig/" 1>&2
|
||||
*)
|
||||
echo "Restore 0/ from 0.orig/"
|
||||
\rm -rf 0
|
||||
\cp -r 0.orig 0 2>/dev/null
|
||||
;;
|
||||
esac
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -43,10 +43,6 @@ cellSet_doc
|
||||
sets (c1 c2);
|
||||
// or
|
||||
set c1;
|
||||
// or
|
||||
zones (c1Zone c2Zone);
|
||||
// or
|
||||
zone c1Zone;
|
||||
}
|
||||
|
||||
|
||||
@ -66,10 +62,6 @@ cellSet_doc
|
||||
sets (f0 f1);
|
||||
// or
|
||||
set f0; // Name of faceSet
|
||||
// or
|
||||
zones (f0Zone f1Zone);
|
||||
// or
|
||||
zone f0Zone;
|
||||
|
||||
//- selection option (mandatory)
|
||||
option any; // cell with any face in faceSet
|
||||
@ -135,10 +127,6 @@ cellSet_doc
|
||||
sets (p0 p1);
|
||||
// or
|
||||
sets p0;
|
||||
// or
|
||||
zones (p0Zone p1Zone);
|
||||
// or
|
||||
zone p0Zone;
|
||||
|
||||
option any; // cell with any point in pointSet
|
||||
//option edge; // cell with an edge with both points in pointSet
|
||||
@ -266,10 +254,6 @@ faceSet_doc
|
||||
sets (c0 c1);
|
||||
// or
|
||||
set c0; // Name of cellSet
|
||||
// or
|
||||
zones (c0Zone c1Zone);
|
||||
// or
|
||||
zone c0Zone;
|
||||
|
||||
option all; // All faces of cells
|
||||
//option both; // Only faces with owner+neighbour in cellSet
|
||||
@ -326,10 +310,6 @@ faceSet_doc
|
||||
sets (p0 p1);
|
||||
// or
|
||||
set p0; // Name of pointSet
|
||||
// or
|
||||
zones (p0Zone p1Zone);
|
||||
// or
|
||||
zone p0Zone;
|
||||
|
||||
option any; // Faces using any point in pointSet
|
||||
//option all // Faces with all points in pointSet
|
||||
@ -419,10 +399,6 @@ pointSet_doc
|
||||
sets (c1 c2);
|
||||
// or
|
||||
set c1;
|
||||
// or
|
||||
zones (c1Zone c2Zone);
|
||||
// or
|
||||
zone c1Zone;
|
||||
|
||||
option all; // all points of cell
|
||||
}
|
||||
@ -445,10 +421,6 @@ pointSet_doc
|
||||
sets (f1 f2);
|
||||
// or
|
||||
set f1;
|
||||
// or
|
||||
zones (f1Zone f2Zone);
|
||||
// or
|
||||
zone f1Zone;
|
||||
|
||||
option all; // all points of face
|
||||
}
|
||||
@ -474,10 +446,6 @@ pointSet_doc
|
||||
sets (p1 p2);
|
||||
// or
|
||||
set p1;
|
||||
// or
|
||||
zones (p1Zone p2Zone);
|
||||
// or
|
||||
zone p1Zone;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v2406 |
|
||||
| \\ / O peration | Version: v2312 |
|
||||
| \\ / A nd | Website: www.openfoam.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -132,7 +132,7 @@ OptimisationSwitches
|
||||
// MPI/Parallel settings
|
||||
// =====================
|
||||
|
||||
// Default communication type (nonBlocking | scheduled | buffered)
|
||||
// Default communication type (nonBlocking | scheduled | blocking);
|
||||
commsType nonBlocking;
|
||||
|
||||
// Transfer double as float for processor boundaries. Mostly defunct.
|
||||
@ -146,18 +146,13 @@ 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.
|
||||
//
|
||||
// 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
|
||||
// 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)
|
||||
maxCommsSize 0;
|
||||
|
||||
// Optional (experimental) feature in lduMatrixUpdate
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user