Compare commits
84 Commits
master
...
reworked-c
| Author | SHA1 | Date | |
|---|---|---|---|
| 6f21313466 | |||
| 5bb3ad052f | |||
| c5b9d9b532 | |||
| 23542cabc8 | |||
| 278ad6fb44 | |||
| b0d29ba8d6 | |||
| a42fa7949b | |||
| c6fc90b629 | |||
| 1d1e0c5f13 | |||
| 462d04dcd4 | |||
| d39b8a5c94 | |||
| b30d42c391 | |||
| f3998b8833 | |||
| 1fa20428a8 | |||
| ac1c41a51b | |||
| c378893bcb | |||
| d4019e497d | |||
| 8be698528a | |||
| 2d522e921f | |||
| f7fd9f8186 | |||
| 1e715d3847 | |||
| f4b50daa3c | |||
| 6d2a6a5ef9 | |||
| d6e75fb289 | |||
| 63ef1f20e8 | |||
| b9d8f99bc2 | |||
| ec2b71f324 | |||
| 52f2c42e54 | |||
| aee63e7418 | |||
| a26f7c243a | |||
| 88ff32b713 | |||
| 4c13fd8658 | |||
| bd57627955 | |||
| 19caabbd56 | |||
| d8250512f6 | |||
| 7fa861f09b | |||
| 202b448b8f | |||
| 4cc8423c94 | |||
| f96c5fafb0 | |||
| 376674d568 | |||
| b2135600a8 | |||
| 697b8a1436 | |||
| a85b0f0736 | |||
| 3ad17ddf5e | |||
| 2446f3f0c7 | |||
| f3c97d41bd | |||
| 8aa69ad976 | |||
| 9c13057b80 | |||
| 8357b7e28b | |||
| 828693bc90 | |||
| 1f5eb55eeb | |||
| 3a78203863 | |||
| 14b68a7f05 | |||
| 45f34f558b | |||
| f000a8e43d | |||
| 24b79d3469 | |||
| 821cdf6681 | |||
| eaf17337aa | |||
| 1642841868 | |||
| 891ac808de | |||
| fe7006acd7 | |||
| 0483e4826a | |||
| 6a72b0e607 | |||
| fcc8e62e47 | |||
| 631b6e5111 | |||
| 83107a192c | |||
| 233da9adaa | |||
| 954a54ea73 | |||
| 9cbf544ecd | |||
| 1bcad518c6 | |||
| a32493778a | |||
| e4c1a252c6 | |||
| c108153d06 | |||
| 53af711c6a | |||
| a68ed1371f | |||
| 6ac50a3307 | |||
| 0a421c99ab | |||
| 20e04a88f7 | |||
| 9629ae8aa9 | |||
| 7a8089e076 | |||
| 4cd1912e4c | |||
| 9eede215b0 | |||
| d37c685523 | |||
| bbef1bc289 |
3
.gitignore
vendored
3
.gitignore
vendored
@ -11,6 +11,7 @@
|
||||
|
||||
# File-browser settings - anywhere
|
||||
.directory
|
||||
.DS_Store # OSX app store
|
||||
|
||||
# Backup/recovery versions - anywhere
|
||||
.#*
|
||||
@ -38,6 +39,8 @@ linux*Gcc*/
|
||||
linux*Icc*/
|
||||
solaris*Gcc*/
|
||||
SunOS*Gcc*/
|
||||
darwin*Clang*/
|
||||
darwin*Gcc*/
|
||||
platforms/
|
||||
|
||||
# Top-level build directories
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
cd "${0%/*}" || exit # Run from this directory
|
||||
set -- -no-recursion "$@" # Parse arguments only
|
||||
set -- -all="${0##*/}" "$@" # Execute this instead of ./Allwmake
|
||||
|
||||
# Run from OPENFOAM top-level directory only
|
||||
wmake -check-dir "$WM_PROJECT_DIR" 2>/dev/null || {
|
||||
@ -33,7 +33,7 @@ case "$FOAM_MODULE_PREFIX" in
|
||||
;;
|
||||
(*)
|
||||
# Use wmake -all instead of Allwmake to allow for overrides
|
||||
( cd "$WM_PROJECT_DIR/modules" 2>/dev/null && wmake -all )
|
||||
( cd "$WM_PROJECT_DIR/modules" 2>/dev/null && wmake -all $* )
|
||||
esac
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
cd "${0%/*}" || exit # Run from this directory
|
||||
set -- -no-recursion "$@" # Parse arguments only
|
||||
set -- -all="${0##*/}" "$@" # Execute this instead of ./Allwmake
|
||||
|
||||
# Run from OPENFOAM top-level directory only
|
||||
wmake -check-dir "$WM_PROJECT_DIR" 2>/dev/null || {
|
||||
@ -33,7 +33,7 @@ case "$FOAM_MODULE_PREFIX" in
|
||||
;;
|
||||
(*)
|
||||
# Use wmake -all instead of Allwmake to allow for overrides
|
||||
( cd "$WM_PROJECT_DIR/plugins" 2>/dev/null && wmake -all )
|
||||
( cd "$WM_PROJECT_DIR/plugins" 2>/dev/null && wmake -all $* )
|
||||
esac
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
@ -15,11 +15,10 @@ volVectorField U
|
||||
// Initialise the velocity internal field to zero
|
||||
// Note: explicitly bypass evaluation of contraint patch overrides
|
||||
// (e.g. swirlFanVelocity might lookup phi,rho)
|
||||
//U = dimensionedVector(U.dimensions(), Zero);
|
||||
//U = Zero;
|
||||
{
|
||||
const dimensionedVector dt(U.dimensions(), Zero);
|
||||
U.internalFieldRef() = dt;
|
||||
U.boundaryFieldRef() = dt.value();
|
||||
U.internalFieldRef() = Zero;
|
||||
U.boundaryFieldRef() = Zero;
|
||||
}
|
||||
|
||||
surfaceScalarField phi
|
||||
|
||||
@ -1086,7 +1086,7 @@ void Foam::multiphaseMixtureThermo::solveAlphas
|
||||
|
||||
MULES::limitSum(alphaPhiCorrs);
|
||||
|
||||
rhoPhi_ = dimensionedScalar(dimensionSet(1, 0, -1, 0, 0), Zero);
|
||||
rhoPhi_ = Zero;
|
||||
|
||||
volScalarField sumAlpha
|
||||
(
|
||||
|
||||
@ -63,23 +63,11 @@ Foam::DTRMParticle::DTRMParticle
|
||||
{
|
||||
is >> p0_ >> p1_ >> I0_ >> I_ >> dA_ >> transmissiveId_;
|
||||
}
|
||||
else if (!is.checkLabelSize<>() || !is.checkScalarSize<>())
|
||||
{
|
||||
// Non-native label or scalar size
|
||||
|
||||
is.beginRawRead();
|
||||
|
||||
readRawScalar(is, p0_.data(), vector::nComponents);
|
||||
readRawScalar(is, p1_.data(), vector::nComponents);
|
||||
readRawScalar(is, &I0_);
|
||||
readRawScalar(is, &I_);
|
||||
readRawScalar(is, &dA_);
|
||||
readRawLabel(is, &transmissiveId_);
|
||||
|
||||
is.endRawRead();
|
||||
}
|
||||
else
|
||||
{
|
||||
// No non-native streaming
|
||||
is.fatalCheckNativeSizes(FUNCTION_NAME);
|
||||
|
||||
is.read(reinterpret_cast<char*>(&p0_), sizeofFields_);
|
||||
}
|
||||
}
|
||||
|
||||
@ -557,7 +557,7 @@ void Foam::radiation::laserDTRM::calculate()
|
||||
|
||||
|
||||
// Reset the field
|
||||
Q_ == dimensionedScalar(Q_.dimensions(), Zero);
|
||||
Q_ == Zero;
|
||||
|
||||
a_ = absorptionEmission_->a();
|
||||
e_ = absorptionEmission_->e();
|
||||
|
||||
@ -232,7 +232,7 @@
|
||||
surfaceScalarField mSfGradp("mSfGradp", pEqnIncomp.flux()/rAUf);
|
||||
|
||||
phasei = 0;
|
||||
phi = dimensionedScalar("phi", phi.dimensions(), Zero);
|
||||
phi = Zero;
|
||||
|
||||
for (phaseModel& phase : fluid.phases())
|
||||
{
|
||||
@ -261,7 +261,7 @@
|
||||
|
||||
mSfGradp = pEqnIncomp.flux()/rAUf;
|
||||
|
||||
U = dimensionedVector("U", dimVelocity, Zero);
|
||||
U = Zero;
|
||||
|
||||
phasei = 0;
|
||||
for (phaseModel& phase : fluid.phases())
|
||||
|
||||
@ -626,7 +626,7 @@ void Foam::multiphaseMixture::solveAlphas
|
||||
|
||||
MULES::limitSum(alphaPhiCorrs);
|
||||
|
||||
rhoPhi_ = dimensionedScalar(dimMass/dimTime, Zero);
|
||||
rhoPhi_ = Zero;
|
||||
|
||||
volScalarField sumAlpha
|
||||
(
|
||||
|
||||
@ -14,6 +14,6 @@ if (!(runTime.timeIndex() % 5))
|
||||
if (smi < -SMALL)
|
||||
{
|
||||
Info<< "Resetting Dcorr to 0" << endl;
|
||||
Dcorr == dimensionedVector(Dcorr.dimensions(), Zero);
|
||||
Dcorr == Zero;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
cd "${0%/*}" || exit # Run from this directory
|
||||
. ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions # Require wmake functions
|
||||
cd "${0%/*}" || exit # Run from this directory
|
||||
. "${WM_PROJECT_DIR:?}"/wmake/scripts/wmakeFunctions # Need wmake functions
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
#!/bin/sh
|
||||
cd "${0%/*}" || exit # Run from this directory
|
||||
set -- -no-recursion "$@" # Parse arguments only
|
||||
. ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments
|
||||
. ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions # Require wmake functions
|
||||
set -- -all="${0##*/}" "$@" # Execute this instead of ./Allwmake
|
||||
|
||||
. "${WM_PROJECT_DIR:?}"/wmake/scripts/AllwmakeParseArguments
|
||||
. "${WM_PROJECT_DIR:?}"/wmake/scripts/wmakeFunctions # Need wmake functions
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Environment
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-CompactIOList.C
|
||||
Test-CompactIOList.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-CompactIOList
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -25,7 +25,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Application
|
||||
testCompactIOList
|
||||
Test-CompactIOList
|
||||
|
||||
Description
|
||||
Simple demonstration and test application for the CompactIOList container
|
||||
@ -46,13 +46,20 @@ using namespace Foam;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::addBoolOption("ascii", "use ascii format");
|
||||
argList::addOption("count", "number of faces");
|
||||
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
IOstreamOption streamOpt(IOstreamOption::BINARY);
|
||||
// IOstreamOption streamOpt(IOstreamOption::ASCII);
|
||||
|
||||
const label size = 20000000;
|
||||
if (args.found("ascii"))
|
||||
{
|
||||
streamOpt.format(IOstreamOption::ASCII);
|
||||
}
|
||||
|
||||
const label size = args.getOrDefault<label>("count", 20000000);
|
||||
|
||||
// Old format
|
||||
// ~~~~~~~~~~
|
||||
@ -63,39 +70,50 @@ int main(int argc, char *argv[])
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"faces2",
|
||||
"faces2-plain",
|
||||
runTime.constant(),
|
||||
polyMesh::meshSubDir,
|
||||
runTime,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
),
|
||||
size
|
||||
)
|
||||
);
|
||||
|
||||
const face f(identity(4));
|
||||
faces2.resize(size, face(identity(4)));
|
||||
|
||||
forAll(faces2, i)
|
||||
{
|
||||
faces2[i] = f;
|
||||
}
|
||||
|
||||
Info<< "Constructed faceList in = "
|
||||
<< runTime.cpuTimeIncrement() << " s" << nl << endl;
|
||||
Info<< "Plain format faceList " << faces2.objectRelPath() << nl;
|
||||
Info<< " constructed in = " << runTime.cpuTimeIncrement()
|
||||
<< " s" << endl;
|
||||
|
||||
|
||||
faces2.writeObject(streamOpt, true);
|
||||
|
||||
Info<< "Written old format faceList in = "
|
||||
<< runTime.cpuTimeIncrement() << " s" << nl << endl;
|
||||
Info<< " wrote in = "
|
||||
<< runTime.cpuTimeIncrement() << " s" << endl;
|
||||
|
||||
// Read
|
||||
faceIOList faces3
|
||||
// Read (size only)
|
||||
label count = faceIOList::readContentsSize
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"faces2",
|
||||
"faces2-plain",
|
||||
runTime.constant(),
|
||||
polyMesh::meshSubDir,
|
||||
runTime,
|
||||
IOobject::MUST_READ
|
||||
)
|
||||
);
|
||||
|
||||
Info<< " counted " << count << " faces on disk in = "
|
||||
<< runTime.cpuTimeIncrement() << " s" << endl;
|
||||
|
||||
// Read
|
||||
faceIOList faces2b
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"faces2-plain",
|
||||
runTime.constant(),
|
||||
polyMesh::meshSubDir,
|
||||
runTime,
|
||||
@ -105,7 +123,7 @@ int main(int argc, char *argv[])
|
||||
)
|
||||
);
|
||||
|
||||
Info<< "Read old format " << faces3.size() << " faceList in = "
|
||||
Info<< " read " << faces2b.size() << " faces in = "
|
||||
<< runTime.cpuTimeIncrement() << " s" << nl << endl;
|
||||
}
|
||||
|
||||
@ -114,44 +132,54 @@ int main(int argc, char *argv[])
|
||||
// ~~~~~~~~~~
|
||||
|
||||
{
|
||||
// Construct big faceList in new format
|
||||
// Construct big faceList in compact format
|
||||
faceCompactIOList faces2
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"faces2",
|
||||
"faces2-compact",
|
||||
runTime.constant(),
|
||||
polyMesh::meshSubDir,
|
||||
runTime,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
),
|
||||
size
|
||||
)
|
||||
);
|
||||
|
||||
const face f(identity(4));
|
||||
faces2.resize(size, face(identity(4)));
|
||||
|
||||
forAll(faces2, i)
|
||||
{
|
||||
faces2[i] = f;
|
||||
}
|
||||
|
||||
Info<< "Constructed new format faceList in = "
|
||||
<< runTime.cpuTimeIncrement() << " s" << nl << endl;
|
||||
Info<< "Compact format faceList" << faces2.objectRelPath() << nl;
|
||||
Info<< " constructed in = "
|
||||
<< runTime.cpuTimeIncrement() << " s" << endl;
|
||||
|
||||
|
||||
faces2.writeObject(streamOpt, true);
|
||||
|
||||
Info<< "Written new format faceList in = "
|
||||
<< runTime.cpuTimeIncrement() << " s" << nl << endl;
|
||||
Info<< " wrote in = "
|
||||
<< runTime.cpuTimeIncrement() << " s" << endl;
|
||||
|
||||
// Read
|
||||
faceCompactIOList faces3
|
||||
// Read (size only)
|
||||
label count = faceCompactIOList::readContentsSize
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"faces2",
|
||||
"faces2-compact",
|
||||
runTime.constant(),
|
||||
polyMesh::meshSubDir,
|
||||
runTime,
|
||||
IOobject::MUST_READ
|
||||
)
|
||||
);
|
||||
Info<< " counted " << count << " faces on disk in = "
|
||||
<< runTime.cpuTimeIncrement() << " s" << endl;
|
||||
|
||||
// Read
|
||||
faceCompactIOList faces2b
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"faces2-compact",
|
||||
runTime.constant(),
|
||||
polyMesh::meshSubDir,
|
||||
runTime,
|
||||
@ -161,7 +189,7 @@ int main(int argc, char *argv[])
|
||||
)
|
||||
);
|
||||
|
||||
Info<< "Read new format " << faces3.size() << " faceList in = "
|
||||
Info<< " read " << faces2b.size() << " faces in = "
|
||||
<< runTime.cpuTimeIncrement() << " s" << nl << endl;
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-HashPtrTable.C
|
||||
Test-HashPtrTable.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-HashPtrTable
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -42,33 +42,55 @@ Description
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
class Scalar
|
||||
bool verbosity = true;
|
||||
|
||||
// Gratuitous class inheritance
|
||||
template<class T>
|
||||
class BoxedType
|
||||
{
|
||||
scalar data_;
|
||||
T data_;
|
||||
|
||||
public:
|
||||
|
||||
static bool verbose;
|
||||
|
||||
constexpr Scalar() noexcept : data_(0) {}
|
||||
Scalar(scalar val) noexcept : data_(val) {}
|
||||
constexpr BoxedType() noexcept : data_(0) {}
|
||||
BoxedType(T val) noexcept : data_(val) {}
|
||||
|
||||
~BoxedType()
|
||||
{
|
||||
if (verbosity) Info<< " [delete BoxedType: " << value() << ']' << nl;
|
||||
}
|
||||
|
||||
T value() const noexcept { return data_; }
|
||||
T& value() noexcept { return data_; }
|
||||
|
||||
auto clone() const { return autoPtr<BoxedType<T>>::New(*this); }
|
||||
};
|
||||
|
||||
template<class T> Ostream& operator<<(Ostream& os, const BoxedType<T>& item)
|
||||
{
|
||||
return (os << " -> " << item.value());
|
||||
}
|
||||
|
||||
|
||||
class Scalar : public BoxedType<scalar>
|
||||
{
|
||||
public:
|
||||
|
||||
using BoxedType<scalar>::BoxedType;
|
||||
|
||||
~Scalar()
|
||||
{
|
||||
if (verbose) Info<< "delete Scalar: " << data_ << endl;
|
||||
}
|
||||
|
||||
const scalar& value() const noexcept { return data_; }
|
||||
scalar& value() noexcept { return data_; }
|
||||
|
||||
friend Ostream& operator<<(Ostream& os, const Scalar& item)
|
||||
{
|
||||
os << item.value();
|
||||
return os;
|
||||
if (verbosity) Info<< "delete Scalar: " << value() << nl;
|
||||
}
|
||||
auto clone() const { return autoPtr<Scalar>::New(*this); }
|
||||
};
|
||||
|
||||
bool Scalar::verbose = true;
|
||||
Ostream& operator<<(Ostream& os, const Scalar& item)
|
||||
{
|
||||
return (os << item.value());
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
@ -1,3 +1,3 @@
|
||||
Test-HashTable2.C
|
||||
Test-HashTable2.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-HashTable2
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-HashTable3.C
|
||||
Test-HashTable3.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-HashTable3
|
||||
|
||||
@ -89,12 +89,6 @@ Ostream& printView(Ostream& os, std::string_view s)
|
||||
}
|
||||
|
||||
|
||||
Ostream& printView(Ostream& os, stdFoam::span<char> s)
|
||||
{
|
||||
return printView(os, s.begin(), s.end());
|
||||
}
|
||||
|
||||
|
||||
Ostream& printView(Ostream& os, const UList<char>& list)
|
||||
{
|
||||
return printView(os, list.begin(), list.end());
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-IOobjectList.C
|
||||
Test-IOobjectList.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-IOobjectList
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-ISLList.C
|
||||
Test-ISLList.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-ISLList
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-IStringStream.C
|
||||
Test-IStringStream.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-IStringStream
|
||||
|
||||
@ -106,7 +106,7 @@ void printMyString(const UList<string>& lst)
|
||||
{
|
||||
MyStrings slist2(lst);
|
||||
|
||||
Info<<slist2 << nl;
|
||||
Info<< slist2 << nl;
|
||||
}
|
||||
|
||||
|
||||
@ -204,16 +204,6 @@ int main(int argc, char *argv[])
|
||||
Info<<" " << *iter;
|
||||
}
|
||||
Info<< nl;
|
||||
|
||||
Info<< "data:" << Foam::name(ident.cdata())
|
||||
<< " size:" << ident.size() << nl;
|
||||
|
||||
|
||||
Info<< "resize_unsafe(10)" << nl;
|
||||
ident.resize_unsafe(10);
|
||||
|
||||
Info<< "data:" << Foam::name(ident.cdata())
|
||||
<< " size:" << ident.size() << nl;
|
||||
}
|
||||
|
||||
if (false)
|
||||
@ -370,7 +360,7 @@ int main(int argc, char *argv[])
|
||||
auto shrtList = ListOps::create<short>
|
||||
(
|
||||
longLabelList,
|
||||
[](const label& val){ return val; }
|
||||
[](label val){ return val; }
|
||||
);
|
||||
|
||||
printListOutputType<short>("short") << nl;
|
||||
@ -567,7 +557,7 @@ int main(int argc, char *argv[])
|
||||
auto scalars = ListOps::create<scalar>
|
||||
(
|
||||
labels,
|
||||
[](const label& val){ return scalar(1.5*val); }
|
||||
[](label val){ return scalar(1.5*val); }
|
||||
);
|
||||
Info<< "scalars: " << flatOutput(scalars) << endl;
|
||||
}
|
||||
@ -576,7 +566,7 @@ int main(int argc, char *argv[])
|
||||
auto vectors = ListOps::create<vector>
|
||||
(
|
||||
labels,
|
||||
[](const label& val){ return vector(1.2*val, -1.2*val, 0); }
|
||||
[](label val){ return vector(1.2*val, -1.2*val, 0); }
|
||||
);
|
||||
Info<< "vectors: " << flatOutput(vectors) << endl;
|
||||
}
|
||||
@ -585,7 +575,7 @@ int main(int argc, char *argv[])
|
||||
auto longs = ListOps::create<long>
|
||||
(
|
||||
labels,
|
||||
[](const label& val){ return val; }
|
||||
[](label val){ return val; }
|
||||
);
|
||||
Info<< "longs: " << flatOutput(longs) << endl;
|
||||
}
|
||||
@ -603,7 +593,7 @@ int main(int argc, char *argv[])
|
||||
(
|
||||
labelRange().cbegin(),
|
||||
labelRange(15).cend(),
|
||||
[](const label& val){ return scalar(-1.125*val); }
|
||||
[](label val){ return scalar(-1.125*val); }
|
||||
);
|
||||
Info<< "scalars: " << flatOutput(scalars) << endl;
|
||||
}
|
||||
|
||||
@ -89,12 +89,6 @@ Ostream& printView(Ostream& os, std::string_view s)
|
||||
}
|
||||
|
||||
|
||||
Ostream& printView(Ostream& os, stdFoam::span<char> s)
|
||||
{
|
||||
return printView(os, s.begin(), s.end());
|
||||
}
|
||||
|
||||
|
||||
Ostream& printView(Ostream& os, const UList<char>& list)
|
||||
{
|
||||
return printView(os, list.begin(), list.end());
|
||||
@ -189,12 +183,25 @@ int main(int argc, char *argv[])
|
||||
printInfo(obuf);
|
||||
|
||||
// Overwrite at some position
|
||||
obuf.stdStream().rdbuf()->pubseekpos(0.60 * obuf.size());
|
||||
obuf << "<" << nl << "OVERWRITE" << nl;
|
||||
if (auto i = obuf.view().find("item5"); i != std::string::npos)
|
||||
{
|
||||
// obuf.seek(0.60 * obuf.size());
|
||||
obuf.seek(i);
|
||||
obuf << "<OVERWRITE>" << nl;
|
||||
}
|
||||
|
||||
Info<<"after overwrite" << nl;
|
||||
printInfo(obuf);
|
||||
|
||||
// Truncate
|
||||
{
|
||||
constexpr float fraction = 0.90;
|
||||
Info<<"truncated at " << (100*fraction) << "% ["
|
||||
<< int(fraction*obuf.size()) << " chars]" << nl;
|
||||
obuf.seek(fraction*obuf.size());
|
||||
printInfo(obuf);
|
||||
}
|
||||
|
||||
Info<< "transfer contents to a List or ICharStream" << nl;
|
||||
|
||||
// Reclaim data storage from OCharStream -> ICharStream
|
||||
|
||||
3
applications/test/OCharStream2/Make/files
Normal file
3
applications/test/OCharStream2/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
Test-OCharStream2.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-OCharStream2
|
||||
2
applications/test/OCharStream2/Make/options
Normal file
2
applications/test/OCharStream2/Make/options
Normal file
@ -0,0 +1,2 @@
|
||||
/* EXE_INC = */
|
||||
/* EXE_LIBS = */
|
||||
473
applications/test/OCharStream2/Test-OCharStream2.cxx
Normal file
473
applications/test/OCharStream2/Test-OCharStream2.cxx
Normal file
@ -0,0 +1,473 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2025 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/>.
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "SpanStream.H"
|
||||
#include "wordList.H"
|
||||
#include "IOstreams.H"
|
||||
#include "argList.H"
|
||||
|
||||
#include <charconv>
|
||||
#include <cctype>
|
||||
#include <cstdio>
|
||||
#include <limits>
|
||||
#include <iomanip>
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
Ostream& printString(Ostream& os, const char* first, const char* last)
|
||||
{
|
||||
os << '"';
|
||||
for (; first != last; (void)++first)
|
||||
{
|
||||
os << *first;
|
||||
}
|
||||
os << '"';
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
Ostream& printView(Ostream& os, const char* first, const char* last)
|
||||
{
|
||||
char buf[4];
|
||||
os << label(last-first) << '(';
|
||||
|
||||
for (; first != last; (void)++first)
|
||||
{
|
||||
const char c = *first;
|
||||
|
||||
if (isprint(c))
|
||||
{
|
||||
os << c;
|
||||
}
|
||||
else if (c == '\t')
|
||||
{
|
||||
os << "\\t";
|
||||
}
|
||||
else if (c == '\n')
|
||||
{
|
||||
os << "\\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
::snprintf(buf, 4, "%02X", c);
|
||||
os << "\\x" << buf;
|
||||
}
|
||||
}
|
||||
os << ')';
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
Ostream& printView(Ostream& os, std::string_view s)
|
||||
{
|
||||
return printView(os, s.begin(), s.end());
|
||||
}
|
||||
|
||||
|
||||
Ostream& printView(Ostream& os, const UList<char>& list)
|
||||
{
|
||||
return printView(os, list.begin(), list.end());
|
||||
}
|
||||
|
||||
|
||||
Ostream& writeList(Ostream& os, const UList<char>& list)
|
||||
{
|
||||
return printView(os, list);
|
||||
}
|
||||
|
||||
|
||||
Ostream& toString(Ostream& os, const UList<char>& list)
|
||||
{
|
||||
return printString(os, list.begin(), list.end());
|
||||
}
|
||||
|
||||
|
||||
Ostream& toString(Ostream& os, std::string_view s)
|
||||
{
|
||||
return printString(os, s.begin(), s.end());
|
||||
}
|
||||
|
||||
|
||||
template<class BufType>
|
||||
void printInfo(const BufType& buf)
|
||||
{
|
||||
Info<< nl << "=========================" << endl;
|
||||
buf.print(Info);
|
||||
Info<< "addr: " << Foam::name(buf.view().data()) << nl;
|
||||
toString(Info, buf.view());
|
||||
Info<< nl << "=========================" << endl;
|
||||
}
|
||||
|
||||
|
||||
// Return a left-padded integer as "word"
|
||||
template<class IntType>
|
||||
std::string leftpadded(IntType val, char fillch = ' ')
|
||||
{
|
||||
std::string buf;
|
||||
buf.resize((std::numeric_limits<IntType>::digits10+1), fillch);
|
||||
|
||||
auto first = (buf.data());
|
||||
auto last = (buf.data() + buf.size());
|
||||
|
||||
auto result = std::to_chars(first, last, val);
|
||||
|
||||
if (result.ec == std::errc{})
|
||||
{
|
||||
auto* iter = result.ptr;
|
||||
int count = std::distance(iter, last);
|
||||
|
||||
std::cout << "did not fill: " << count << " chars\n";
|
||||
|
||||
// With two spaces before comments
|
||||
if (count > 0) { *iter++ = ' '; --count; }
|
||||
if (count > 0) { *iter++ = ' '; --count; }
|
||||
for (char c = (count >= 2 ? '/' : ' '); count > 0; --count)
|
||||
{
|
||||
*iter++ = c;
|
||||
}
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
template<class IntType>
|
||||
void leftpad(std::ostream& os, IntType val, char fillch = ' ')
|
||||
{
|
||||
// set fill char and width
|
||||
os.setf(std::ios_base::left, std::ios_base::adjustfield);
|
||||
fillch = os.fill(fillch);
|
||||
os.width(std::numeric_limits<IntType>::digits10+1);
|
||||
os << val;
|
||||
// restore fill char
|
||||
os.fill(fillch);
|
||||
}
|
||||
|
||||
|
||||
template<class IntType>
|
||||
void rightpad(std::ostream& os, IntType val, char fillch = ' ')
|
||||
{
|
||||
// set fill char and width
|
||||
os.setf(std::ios_base::right, std::ios_base::adjustfield);
|
||||
fillch = os.fill(fillch);
|
||||
os.width(std::numeric_limits<IntType>::digits10+1);
|
||||
os << val;
|
||||
// restore fill char
|
||||
os.fill(fillch);
|
||||
}
|
||||
|
||||
|
||||
// Left-padded value with trailing comment slashes
|
||||
template<class IntType>
|
||||
void leftpad(ocharstream& os, IntType val)
|
||||
{
|
||||
const auto beg = os.tellp();
|
||||
os << val;
|
||||
int count = (std::numeric_limits<IntType>::digits10+1) - (os.tellp() - beg);
|
||||
|
||||
// With two spaces before comments
|
||||
if (count > 0) { os << ' '; --count; }
|
||||
if (count > 0) { os << ' '; --count; }
|
||||
for (const char c = (count >= 2 ? '/' : ' '); count > 0; --count)
|
||||
{
|
||||
os << c;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noBanner();
|
||||
argList::noParallel();
|
||||
argList::addBoolOption("fake-zerosize", "Fake overwriting with zero data");
|
||||
argList::addBoolOption("dict-format", "Format as dictionary entry");
|
||||
|
||||
#include "setRootCase.H"
|
||||
|
||||
const bool optFakeZerosize = args.found("fake-zerosize");
|
||||
const bool isDictFormat = args.found("dict-format");
|
||||
|
||||
// const constexpr int width = (std::numeric_limits<label>::digits10+1);
|
||||
|
||||
// experiment with to_chars instead of streaming
|
||||
{
|
||||
// Some value
|
||||
label val(1234);
|
||||
|
||||
auto fixed = leftpadded(val);
|
||||
Info<< "leftpadded " << val << " : " << fixed << nl;
|
||||
}
|
||||
|
||||
ocharstream labelbuf;
|
||||
labelbuf.reserve_exact(32);
|
||||
|
||||
// Some value
|
||||
labelbuf.rewind();
|
||||
rightpad(labelbuf, label(10));
|
||||
|
||||
printInfo(labelbuf);
|
||||
|
||||
OCharStream obuf;
|
||||
obuf.reserve_exact(48);
|
||||
|
||||
printInfo(obuf);
|
||||
|
||||
obuf.push_back('>');
|
||||
obuf.append(" string_view ");
|
||||
obuf.push_back('<');
|
||||
printInfo(obuf);
|
||||
|
||||
obuf.pop_back(8);
|
||||
printInfo(obuf);
|
||||
|
||||
obuf.pop_back(100);
|
||||
printInfo(obuf);
|
||||
|
||||
|
||||
// Fill with some content
|
||||
for (int i = 0; i < 26; ++i)
|
||||
{
|
||||
obuf<< char('A' + i);
|
||||
}
|
||||
|
||||
// Change letter 'O' to '_'
|
||||
if (auto i = obuf.view().find('O'); i != std::string::npos)
|
||||
{
|
||||
obuf.overwrite(i, '_');
|
||||
}
|
||||
|
||||
// append and push_back some content
|
||||
obuf.append(5, '<');
|
||||
obuf.push_back('#');
|
||||
obuf.append(5, '>');
|
||||
|
||||
printInfo(obuf);
|
||||
|
||||
obuf.pop_back(8);
|
||||
printInfo(obuf);
|
||||
|
||||
// Slightly silly test
|
||||
{
|
||||
const auto list = obuf.list();
|
||||
Info<< "list content:" << list << nl;
|
||||
Info<< "view content:" << nl << list.view() << nl;
|
||||
}
|
||||
|
||||
obuf.overwrite(4, labelbuf.view());
|
||||
printInfo(obuf);
|
||||
|
||||
obuf.overwrite(20, "####");
|
||||
printInfo(obuf);
|
||||
|
||||
Info<< "operation Ignored..." << nl;
|
||||
obuf.overwrite(45, "????");
|
||||
printInfo(obuf);
|
||||
|
||||
// Update with new value
|
||||
{
|
||||
labelbuf.rewind();
|
||||
rightpad(labelbuf, label(200), '.');
|
||||
obuf.overwrite(4, labelbuf.view());
|
||||
|
||||
printInfo(obuf);
|
||||
}
|
||||
|
||||
// With yet another value (non-fixed width)
|
||||
{
|
||||
labelbuf.rewind();
|
||||
labelbuf << label(15);
|
||||
obuf.overwrite(4, labelbuf.view());
|
||||
|
||||
printInfo(obuf);
|
||||
}
|
||||
|
||||
// Slightly harder test
|
||||
{
|
||||
std::string chars(26, '?');
|
||||
|
||||
for (int i = 0; i < 26; ++i)
|
||||
{
|
||||
chars[i] = char('A' + i);
|
||||
}
|
||||
|
||||
auto& os = obuf;
|
||||
os.rewind();
|
||||
|
||||
const word procName("processor0");
|
||||
|
||||
// Write as primitiveEntry or commented content
|
||||
// // constexpr bool isDictFormat = true;
|
||||
|
||||
// if constexpr (isDictFormat)
|
||||
if (isDictFormat)
|
||||
{
|
||||
// Like writeKeyword() with compoundToken
|
||||
os << nl << procName << ' ' << word("List<char>") << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Human-readable comments
|
||||
os << nl << "// " << procName << nl;
|
||||
}
|
||||
|
||||
// This is the code we want to have, but assume we don't know
|
||||
// the size or data beforehand.
|
||||
//
|
||||
// if (str && len > 0)
|
||||
// {
|
||||
// // Special treatment for char data (binary I/O only)
|
||||
// const auto oldFmt = os.format(IOstreamOption::BINARY);
|
||||
//
|
||||
// os << label(len) << nl;
|
||||
// os.write(str, len);
|
||||
// os << nl;
|
||||
//
|
||||
// os.format(oldFmt);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// os << label(0) << nl;
|
||||
// }
|
||||
|
||||
// Position before writing the label
|
||||
const auto labelBegin = os.tellp();
|
||||
|
||||
// Replace: os << label(len) << nl;
|
||||
// with a fixed-length version
|
||||
{
|
||||
labelbuf.rewind();
|
||||
rightpad(labelbuf, 0);
|
||||
|
||||
os.append(labelbuf.view());
|
||||
os << nl;
|
||||
}
|
||||
|
||||
constexpr bool testUnknown = true;
|
||||
|
||||
label dataCount = 0;
|
||||
|
||||
if constexpr (testUnknown)
|
||||
{
|
||||
// Pretend we don't know the number of characters a priori
|
||||
|
||||
const auto oldFmt = os.format(IOstreamOption::BINARY);
|
||||
|
||||
const auto lineNumber = os.lineNumber();
|
||||
|
||||
// count is unknown but irrelevant for serial
|
||||
os.beginRawWrite(0);
|
||||
|
||||
// Position before raw binary data
|
||||
const auto dataBegin = os.tellp();
|
||||
|
||||
// Some type of output, streaming etc
|
||||
os.writeRaw(chars.data(), chars.size());
|
||||
|
||||
// How many chars of binary data written?
|
||||
dataCount = (os.tellp() - dataBegin);
|
||||
|
||||
os.endRawWrite();
|
||||
os.lineNumber() = lineNumber;
|
||||
os << nl;
|
||||
|
||||
os.format(oldFmt);
|
||||
}
|
||||
else
|
||||
{
|
||||
// If we had all data collected a priori
|
||||
|
||||
dataCount = chars.size();
|
||||
|
||||
const auto oldFmt = os.format(IOstreamOption::BINARY);
|
||||
|
||||
if (dataCount > 0)
|
||||
{
|
||||
os.write(chars.data(), chars.size());
|
||||
os << nl;
|
||||
}
|
||||
os.format(oldFmt);
|
||||
}
|
||||
|
||||
if (optFakeZerosize)
|
||||
{
|
||||
dataCount = 0; // fake zero-size
|
||||
}
|
||||
|
||||
printInfo(os);
|
||||
|
||||
// Update the data count with the correct value
|
||||
|
||||
if (dataCount > 0)
|
||||
{
|
||||
labelbuf.rewind();
|
||||
leftpad(labelbuf, label(dataCount));
|
||||
|
||||
os.overwrite(labelBegin, labelbuf.view());
|
||||
}
|
||||
else
|
||||
{
|
||||
os.seek(int64_t(labelBegin)-1);
|
||||
|
||||
// if constexpr (isDictFormat)
|
||||
if (isDictFormat)
|
||||
{
|
||||
os << ' ' << label(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
os << nl << label(0) << nl;
|
||||
}
|
||||
}
|
||||
|
||||
// if constexpr (isDictFormat)
|
||||
if (isDictFormat)
|
||||
{
|
||||
os.endEntry();
|
||||
}
|
||||
|
||||
printInfo(os);
|
||||
|
||||
Info<< "view: " << os.view(4, 8) << nl;
|
||||
Info<< "view: " << os.view(32) << nl;
|
||||
// Ignores out-of-range
|
||||
Info<< "view: " << os.view(1000) << nl;
|
||||
}
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -65,7 +65,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
OCountStream cnt;
|
||||
OCharStream cstr;
|
||||
OStringStream sstr;
|
||||
ocountstream plain;
|
||||
|
||||
generateOutput(cstr);
|
||||
@ -77,7 +76,6 @@ 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 ocountstream: " << plain.count() << " chars" << endl;
|
||||
|
||||
fileName outputName;
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-OStringStream.C
|
||||
Test-OStringStream.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-OStringStream
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-PackedList.C
|
||||
Test-PackedList.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-PackedList
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-PtrDictionary1.C
|
||||
Test-PtrDictionary1.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-PtrDictionary1
|
||||
|
||||
@ -42,6 +42,8 @@ Description
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
bool verbosity = true;
|
||||
|
||||
class ent
|
||||
:
|
||||
public Dictionary<ent>::link
|
||||
@ -73,14 +75,12 @@ class Scalar
|
||||
|
||||
public:
|
||||
|
||||
static bool verbose;
|
||||
|
||||
constexpr Scalar() noexcept : data_(0) {}
|
||||
Scalar(scalar val) noexcept : data_(val) {}
|
||||
|
||||
~Scalar()
|
||||
{
|
||||
if (verbose) Info<< "delete Scalar: " << data_ << endl;
|
||||
if (verbosity) Info<< "delete Scalar: " << data_ << endl;
|
||||
}
|
||||
|
||||
scalar value() const noexcept { return data_; }
|
||||
@ -93,8 +93,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
bool Scalar::verbose = true;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
@ -1,3 +1,3 @@
|
||||
Test-PtrList.C
|
||||
Test-PtrList.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-PtrList
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -41,35 +41,85 @@ Description
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
class Scalar
|
||||
bool verbosity = true;
|
||||
|
||||
// Gratuitous class inheritance
|
||||
template<class T>
|
||||
class BoxedType
|
||||
{
|
||||
scalar data_;
|
||||
T data_;
|
||||
|
||||
public:
|
||||
|
||||
static bool verbose;
|
||||
|
||||
constexpr Scalar() noexcept : data_(0) {}
|
||||
Scalar(scalar val) noexcept : data_(val) {}
|
||||
constexpr BoxedType() noexcept : data_(0) {}
|
||||
BoxedType(T val) noexcept : data_(val) {}
|
||||
|
||||
~BoxedType()
|
||||
{
|
||||
if (verbosity) Info<< " [delete BoxedType: " << value() << ']' << nl;
|
||||
}
|
||||
|
||||
T value() const noexcept { return data_; }
|
||||
T& value() noexcept { return data_; }
|
||||
|
||||
auto clone() const { return autoPtr<BoxedType<T>>::New(*this); }
|
||||
};
|
||||
|
||||
template<class T> Ostream& operator<<(Ostream& os, const BoxedType<T>& item)
|
||||
{
|
||||
return (os << " -> " << item.value());
|
||||
}
|
||||
|
||||
|
||||
class Scalar : public BoxedType<scalar>
|
||||
{
|
||||
public:
|
||||
|
||||
using BoxedType<scalar>::BoxedType;
|
||||
|
||||
~Scalar()
|
||||
{
|
||||
if (verbose) Info<< "delete Scalar: " << data_ << endl;
|
||||
}
|
||||
|
||||
scalar value() const noexcept { return data_; }
|
||||
scalar& value() noexcept { return data_; }
|
||||
|
||||
autoPtr<Scalar> clone() const { return autoPtr<Scalar>::New(data_); }
|
||||
|
||||
friend Ostream& operator<<(Ostream& os, const Scalar& item)
|
||||
{
|
||||
os << item.value();
|
||||
return os;
|
||||
if (verbosity) Info<< "delete Scalar: " << value() << nl;
|
||||
}
|
||||
auto clone() const { return autoPtr<Scalar>::New(*this); }
|
||||
};
|
||||
|
||||
bool Scalar::verbose = true;
|
||||
Ostream& operator<<(Ostream& os, const Scalar& item)
|
||||
{
|
||||
return (os << item.value());
|
||||
}
|
||||
|
||||
|
||||
class Integer : public BoxedType<label>
|
||||
{
|
||||
public:
|
||||
|
||||
using BoxedType<label>::BoxedType;
|
||||
|
||||
~Integer()
|
||||
{
|
||||
if (verbosity) Info<< "delete Integer: " << value() << nl;
|
||||
}
|
||||
auto clone() const { return autoPtr<Integer>::New(*this); }
|
||||
};
|
||||
|
||||
Ostream& operator<<(Ostream& os, const Integer& item)
|
||||
{
|
||||
return (os << item.value());
|
||||
}
|
||||
|
||||
|
||||
//- Permit up-casting to the base class (eg, fvMesh to polyMesh).
|
||||
// Usually only for holding (const) references.
|
||||
// Exercise caution with the
|
||||
template<class Base, class Derived>
|
||||
std::enable_if_t<std::is_base_of_v<Base, Derived>, const UPtrList<Base>&>
|
||||
upcast(const UPtrList<Derived>& This)
|
||||
{
|
||||
return *reinterpret_cast<const UPtrList<Base>*>(&This);
|
||||
}
|
||||
|
||||
|
||||
// As per
|
||||
@ -86,20 +136,7 @@ Ostream& printAddr
|
||||
const UPtrList<T>& list
|
||||
)
|
||||
{
|
||||
const label len = list.size();
|
||||
|
||||
// Size and start delimiter
|
||||
os << nl << indent << len << nl
|
||||
<< indent << token::BEGIN_LIST << incrIndent << nl;
|
||||
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
os << "addr=" << Foam::name(list.get(i)) << nl;
|
||||
}
|
||||
|
||||
// End delimiter
|
||||
os << decrIndent << indent << token::END_LIST << nl;
|
||||
return os;
|
||||
return list.printAddresses(os);
|
||||
}
|
||||
|
||||
|
||||
@ -176,11 +213,11 @@ Ostream& print
|
||||
{
|
||||
const label cap = list.capacity();
|
||||
|
||||
for (label i=len; i < cap; ++i)
|
||||
for (label i = len; i < cap; ++i)
|
||||
{
|
||||
const T* ptr = list.get(i);
|
||||
|
||||
os << "unused " << name(ptr) << nl;
|
||||
os << "unused " << Foam::name(ptr) << nl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -264,9 +301,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "DLPtrList: " << llist1 << endl;
|
||||
|
||||
Scalar::verbose = false;
|
||||
verbosity = false;
|
||||
llist1.clear();
|
||||
Scalar::verbose = true;
|
||||
verbosity = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -344,6 +381,44 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
|
||||
// Test upcasting - dangerous
|
||||
{
|
||||
const auto& base =
|
||||
*reinterpret_cast<UPtrList<BoxedType<scalar>>*>(&list1);
|
||||
|
||||
Info<< "list :" << list1 << nl;
|
||||
Info<< "base :" << base << nl;
|
||||
}
|
||||
|
||||
// Expect bad things to happen!!
|
||||
{
|
||||
const auto& base =
|
||||
*reinterpret_cast<UPtrList<BoxedType<label>>*>(&list1);
|
||||
|
||||
Info<< "list :" << list1 << nl;
|
||||
Info<< "base :" << base << nl;
|
||||
}
|
||||
|
||||
// Test upcasting - compile safer (make as member function?)
|
||||
{
|
||||
// const auto& base = list1.upcast<BoxedType<scalar>>();
|
||||
const auto& base = upcast<BoxedType<scalar>>(list1);
|
||||
|
||||
Info<< "list :" << list1 << nl;
|
||||
Info<< "base :" << base << nl;
|
||||
}
|
||||
|
||||
// Refuse to compile (good!)
|
||||
#if 0
|
||||
{
|
||||
// const auto& base = list1.upcast<BoxedType<label>>();
|
||||
const auto& base = upcast<BoxedType<label>>(list1);
|
||||
|
||||
Info<< "list :" << list1 << nl;
|
||||
Info<< "base :" << base << nl;
|
||||
}
|
||||
#endif
|
||||
|
||||
PtrList<Scalar> list2(15);
|
||||
Info<< "Emplace set " << list2.size() << " values" << nl;
|
||||
forAll(list2, i)
|
||||
@ -518,6 +593,7 @@ int main(int argc, char *argv[])
|
||||
print(Info, dynlist1d);
|
||||
|
||||
Info<< "addresses:" << nl;
|
||||
dynlist1d.printAddresses(Info, true);
|
||||
printAddr(Info, dynlist1d);
|
||||
|
||||
PtrList<Scalar> list1d;
|
||||
@ -1,3 +1,3 @@
|
||||
Test-PtrListDictionary.C
|
||||
Test-PtrListDictionary.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-PtrListDictionary
|
||||
|
||||
@ -39,26 +39,26 @@ Description
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
bool verbosity = true;
|
||||
|
||||
class Scalar
|
||||
{
|
||||
scalar data_;
|
||||
|
||||
public:
|
||||
|
||||
static bool verbose;
|
||||
|
||||
constexpr Scalar() noexcept : data_(0) {}
|
||||
Scalar(scalar val) noexcept : data_(val) {}
|
||||
|
||||
~Scalar()
|
||||
{
|
||||
if (verbose) Info<< "delete Scalar: " << data_ << endl;
|
||||
if (verbosity) Info<< "delete Scalar: " << value() << nl;
|
||||
}
|
||||
|
||||
const scalar& value() const noexcept { return data_; }
|
||||
scalar value() const noexcept { return data_; }
|
||||
scalar& value() noexcept { return data_; }
|
||||
|
||||
autoPtr<Scalar> clone() const { return autoPtr<Scalar>::New(data_); }
|
||||
auto clone() const { return autoPtr<Scalar>::New(*this); }
|
||||
|
||||
friend Ostream& operator<<(Ostream& os, const Scalar& item)
|
||||
{
|
||||
@ -67,8 +67,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
bool Scalar::verbose = true;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
@ -91,12 +91,6 @@ Ostream& printView(Ostream& os, std::string_view s)
|
||||
}
|
||||
|
||||
|
||||
Ostream& printView(Ostream& os, stdFoam::span<char> s)
|
||||
{
|
||||
return printView(os, s.begin(), s.end());
|
||||
}
|
||||
|
||||
|
||||
Ostream& printView(Ostream& os, const UList<char>& list)
|
||||
{
|
||||
return printView(os, list.begin(), list.end());
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-base64Encoding.C
|
||||
Test-base64Encoding.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-base64Encoding
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -35,25 +35,31 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "base64Layer.H"
|
||||
#include "SpanStream.H"
|
||||
#include "List.H"
|
||||
#include "Pair.H"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
bool test(const Pair<string>& unit)
|
||||
{
|
||||
const string& input = unit.first();
|
||||
const string& expected = unit.second();
|
||||
const auto& input = unit.first();
|
||||
const auto& expected = unit.second();
|
||||
|
||||
std::ostringstream os;
|
||||
Foam::ocharstream os;
|
||||
|
||||
base64Layer b64(os);
|
||||
b64.write(input.data(), input.size());
|
||||
b64.close();
|
||||
{
|
||||
base64Layer b64(os);
|
||||
b64.write(input.data(), input.size());
|
||||
|
||||
const string encoded = os.str();
|
||||
if (b64.close())
|
||||
{
|
||||
// Extra information
|
||||
// std::cerr<< "closed with pending data" << nl;
|
||||
}
|
||||
}
|
||||
|
||||
const auto encoded = os.view();
|
||||
|
||||
Info<< input << nl;
|
||||
|
||||
@ -78,7 +84,7 @@ bool test(std::initializer_list<Pair<string>> list)
|
||||
{
|
||||
bool good = true;
|
||||
|
||||
for (const Pair<string>& t : list)
|
||||
for (const auto& t : list)
|
||||
{
|
||||
good = test(t) && good;
|
||||
}
|
||||
@ -91,7 +97,7 @@ bool test(const UList<Pair<string>>& list)
|
||||
{
|
||||
bool good = true;
|
||||
|
||||
for (const Pair<string>& t : list)
|
||||
for (const auto& t : list)
|
||||
{
|
||||
good = test(t) && good;
|
||||
}
|
||||
@ -107,7 +113,7 @@ void testMixed(std::ostream& os, const UList<Pair<string>>& list)
|
||||
os << "<test-mixed>" << nl;
|
||||
|
||||
int i=0;
|
||||
for (const Pair<string>& t : list)
|
||||
for (const auto& t : list)
|
||||
{
|
||||
const string& input = t.first();
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-bitSet1.C
|
||||
Test-bitSet1.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-bitSet1
|
||||
|
||||
@ -142,6 +142,9 @@ int main(int argc, char *argv[])
|
||||
Info<< "got: " << bset1 << nl
|
||||
<< "and: " << bset2 << nl
|
||||
<< "and: " << bset3 << nl;
|
||||
|
||||
Info<< "==";
|
||||
bset3.writeList(Info, 10) << nl; // matrix-like output
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -75,9 +75,9 @@ inline Ostream& info(const UList<bool>& bools)
|
||||
Info<< "size=" << bools.size()
|
||||
<< " count=" << BitOps::count(bools)
|
||||
<< " !count=" << BitOps::count(bools, false)
|
||||
<< " all:" << BitOps::all(bools)
|
||||
<< " any:" << BitOps::any(bools)
|
||||
<< " none:" << BitOps::none(bools) << nl;
|
||||
<< " all:" << bools.all()
|
||||
<< " any:" << bools.any()
|
||||
<< " none:" << bools.none() << nl;
|
||||
|
||||
return Info;
|
||||
}
|
||||
@ -137,11 +137,11 @@ inline bool compare
|
||||
const std::string& expected
|
||||
)
|
||||
{
|
||||
const List<unsigned int>& store = bitset.storage();
|
||||
const auto& store = bitset.storage();
|
||||
|
||||
std::string has;
|
||||
|
||||
for (label blocki=0; blocki < bitset.nBlocks(); ++blocki)
|
||||
for (label blocki=0; blocki < bitset.num_blocks(); ++blocki)
|
||||
{
|
||||
has += toString(store[blocki]);
|
||||
}
|
||||
@ -194,8 +194,10 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
boolList bools = list1.values();
|
||||
|
||||
Info<<"===============" << nl;
|
||||
Info<<"bools: " << flatOutput(bools) << nl;
|
||||
Info<< "===============" << nl;
|
||||
Info<< "bools: " << flatOutput(bools) << nl;
|
||||
Info<< " ";
|
||||
info(bools);
|
||||
|
||||
for (int i : { -10, 0, 8, 15, 32})
|
||||
{
|
||||
@ -238,17 +240,18 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
#ifdef TEST_SFINAE
|
||||
// This should fail to compile:
|
||||
{
|
||||
labelList labels = list1.toc();
|
||||
if (labels.test(0))
|
||||
{
|
||||
Info<<"no" << endl;
|
||||
Info<< "no" << endl;
|
||||
}
|
||||
|
||||
List<double*> ptrs(10, nullptr);
|
||||
if (ptrs.get(0))
|
||||
{
|
||||
Info<<"no" << endl;
|
||||
Info<< "no" << endl;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-boolList.C
|
||||
Test-boolList.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-boolList
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -71,9 +71,9 @@ inline Ostream& info(const UList<bool>& bools)
|
||||
Info<< "size=" << bools.size()
|
||||
<< " count=" << BitOps::count(bools)
|
||||
<< " !count=" << BitOps::count(bools, false)
|
||||
<< " all:" << BitOps::all(bools)
|
||||
<< " any:" << BitOps::any(bools)
|
||||
<< " none:" << BitOps::none(bools) << nl;
|
||||
<< " all:" << bools.all()
|
||||
<< " any:" << bools.any()
|
||||
<< " none:" << bools.none() << nl;
|
||||
|
||||
return Info;
|
||||
}
|
||||
@ -1,3 +1,3 @@
|
||||
Test-dictionary.C
|
||||
Test-dictionary.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-dictionary
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-dictionary2.C
|
||||
Test-dictionary2.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-dictionary2
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -47,8 +47,18 @@ void entryInfo(entry* e)
|
||||
{
|
||||
if (e)
|
||||
{
|
||||
Info<<"added "
|
||||
<< e->keyword() << ": " << typeid(e).name() << nl;
|
||||
Info<< "added "
|
||||
<< e->keyword() << ": " << typeid(e).name();
|
||||
|
||||
if (auto* stream = e->streamPtr())
|
||||
{
|
||||
Info<< " tokens: "; stream->tokens().writeList(Info);
|
||||
}
|
||||
if (auto* dict = e->dictPtr())
|
||||
{
|
||||
Info<< " dictionary:";
|
||||
}
|
||||
Info<< nl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -200,12 +210,31 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
dictionary tmpdict;
|
||||
|
||||
// Add an empty entry and populate afterwards
|
||||
if (entry* e = dict1.set(word::printf("entry%d", i), nullptr))
|
||||
{
|
||||
entry* e = dict1.add
|
||||
(
|
||||
word::printf("entry%d", i),
|
||||
string("entry" + Foam::name(i))
|
||||
);
|
||||
auto& toks = e->stream();
|
||||
toks.resize(2);
|
||||
|
||||
toks[0] = word("value" + Foam::name(i));
|
||||
toks[1] = 10*i;
|
||||
entryInfo(e);
|
||||
}
|
||||
|
||||
// Add an entry from given list of tokens
|
||||
{
|
||||
tokenList toks(2);
|
||||
toks[0] = word("value" + Foam::name(i));
|
||||
toks[1] = 10*i;
|
||||
|
||||
Info<< "set token0: " << Foam::name(&(toks[0])) << nl;
|
||||
|
||||
entry* e = dict1.set(word::printf("_entry%d", i), std::move(toks));
|
||||
|
||||
// verify that the address is identical (ie, move semantics worked)
|
||||
auto& newToks = e->stream();
|
||||
Info<< "get token0: " << Foam::name(&(newToks[0])) << nl;
|
||||
|
||||
entryInfo(e);
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-dictionaryCopy.C
|
||||
Test-dictionaryCopy.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-dictionaryCopy
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-fileOperation1.C
|
||||
Test-fileOperation1.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-fileOperation1
|
||||
|
||||
@ -27,7 +27,7 @@ Application
|
||||
Test-fileOperation1
|
||||
|
||||
Description
|
||||
Test string parsing and other bits for fileOperation
|
||||
Test string parsing and other bits for fileOperation
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -42,7 +42,8 @@ Description
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
word toString(const fileOperation::procRangeType& group)
|
||||
template<class IntType>
|
||||
word toString(const IntRange<IntType>& group)
|
||||
{
|
||||
if (group.empty())
|
||||
{
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -24,8 +25,10 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Application
|
||||
Test-memInfo
|
||||
|
||||
Description
|
||||
Very basic test for memInfo values
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -33,6 +36,7 @@ Description
|
||||
#include "IOstreams.H"
|
||||
#include "List.H"
|
||||
#include "vector.H"
|
||||
#include "Switch.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -41,9 +45,13 @@ using namespace Foam;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
const int n = 10000000;
|
||||
constexpr int n = 10000000;
|
||||
const char* const memTags = "peak/size/rss/free mem: ";
|
||||
|
||||
Info<< nl
|
||||
<< "memInfo::supported() = " << Switch(memInfo::supported()) << nl
|
||||
<< nl;
|
||||
|
||||
memInfo mem;
|
||||
|
||||
Info<< memTags << mem << endl;
|
||||
|
||||
@ -186,9 +186,9 @@ int main()
|
||||
|
||||
Info<< nl << "some interesting label limits:" << nl;
|
||||
std::cout<< "sizeof = " << sizeof(label) << nl;
|
||||
std::cout<< "min = " << pTraits<label>::min << nl;
|
||||
std::cout<< "max = " << pTraits<label>::max << nl;
|
||||
std::cout<< "umax = " << pTraits<uLabel>::max << nl;
|
||||
std::cout<< "min = " << pTraits<label>::min_ << nl;
|
||||
std::cout<< "max = " << pTraits<label>::max_ << nl;
|
||||
std::cout<< "umax = " << pTraits<uLabel>::max_ << nl;
|
||||
|
||||
std::cout<< "max_2 = " << pTraits<label>::max/2 << " <=> "
|
||||
<< (1L << (sizeof(label)*8-2)) << nl;
|
||||
|
||||
@ -185,9 +185,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
broadcast_chunks<labelList, label>(input1);
|
||||
|
||||
Pstream::maxCommsSize = 33;
|
||||
UPstream::maxCommsSize = 33;
|
||||
|
||||
args.readIfPresent("comms-size", Pstream::maxCommsSize);
|
||||
args.readIfPresent("comms-size", UPstream::maxCommsSize);
|
||||
|
||||
broadcast_chunks<labelList, label>(input1);
|
||||
|
||||
@ -197,11 +197,11 @@ int main(int argc, char *argv[])
|
||||
PstreamBuffers pBufs;
|
||||
|
||||
labelList sendData;
|
||||
if (Pstream::master())
|
||||
if (UPstream::master())
|
||||
{
|
||||
sendData = identity(500);
|
||||
|
||||
for (const int proci : Pstream::subProcs())
|
||||
for (const int proci : UPstream::subProcs())
|
||||
{
|
||||
UOPstream os(proci, pBufs);
|
||||
os << sendData;
|
||||
@ -211,7 +211,7 @@ int main(int argc, char *argv[])
|
||||
Info<< "call finishedSends()" << endl;
|
||||
pBufs.finishedScatters();
|
||||
|
||||
if (!Pstream::master())
|
||||
if (UPstream::is_subrank())
|
||||
{
|
||||
UIPstream is(UPstream::masterNo(), pBufs);
|
||||
is >> sendData;
|
||||
@ -225,11 +225,11 @@ int main(int argc, char *argv[])
|
||||
labelListList recvBufs(UPstream::nProcs());
|
||||
labelList recvSizes;
|
||||
|
||||
if (Pstream::master())
|
||||
if (UPstream::master())
|
||||
{
|
||||
for (const int proci : Pstream::allProcs())
|
||||
for (const int proci : UPstream::allProcs())
|
||||
{
|
||||
if (proci != Pstream::myProcNo())
|
||||
if (proci != UPstream::myProcNo())
|
||||
{
|
||||
sendBufs[proci] = identity(500);
|
||||
}
|
||||
@ -253,11 +253,11 @@ int main(int argc, char *argv[])
|
||||
Map<labelList> recvBufs;
|
||||
Map<label> recvSizes;
|
||||
|
||||
if (Pstream::master())
|
||||
if (UPstream::master())
|
||||
{
|
||||
for (const int proci : Pstream::allProcs())
|
||||
for (const int proci : UPstream::allProcs())
|
||||
{
|
||||
if (proci != Pstream::myProcNo())
|
||||
if (proci != UPstream::myProcNo())
|
||||
{
|
||||
sendBufs(proci) = identity(500);
|
||||
}
|
||||
|
||||
@ -110,21 +110,25 @@ int main(int argc, char *argv[])
|
||||
<< " (self) reduced " << selfVal << nl;
|
||||
|
||||
// Identical size on all procs
|
||||
bitSet procUsed(nProcs);
|
||||
|
||||
if ((myRank % 4) == 0)
|
||||
{
|
||||
procUsed.set(myRank);
|
||||
bitSet localUsed(nProcs);
|
||||
localUsed.set(myRank, ((myRank % 4) == 0));
|
||||
|
||||
Pout<< "local procUsed " << localUsed << nl;
|
||||
localUsed.reduceOr(UPstream::worldComm, false);
|
||||
Pout<< "reduce procUsed " << localUsed << nl;
|
||||
}
|
||||
|
||||
// With allGather
|
||||
{
|
||||
bitSet procUsed
|
||||
(
|
||||
bitSet::allGather((myRank % 4) == 0)
|
||||
);
|
||||
|
||||
Pout<< "allGather: " << procUsed << nl;
|
||||
}
|
||||
|
||||
Pout<< "local procUsed " << procUsed << nl;
|
||||
reduce
|
||||
(
|
||||
procUsed.data(),
|
||||
procUsed.size_data(),
|
||||
bitOrOp<unsigned int>()
|
||||
);
|
||||
Pout<< "reduce procUsed " << procUsed << nl;
|
||||
|
||||
// Identical size on all procs
|
||||
// encode as 0:empty, 1:uniform, 2:nonuniform, 3:mixed
|
||||
@ -147,12 +151,26 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
Pout<< "local uniform " << uniformity << nl;
|
||||
reduce
|
||||
// reduce with op<..>()
|
||||
#if 1
|
||||
Foam::reduce
|
||||
(
|
||||
uniformity.data(),
|
||||
uniformity.size_data(),
|
||||
bitOrOp<unsigned int>()
|
||||
uniformity.num_blocks(),
|
||||
bitOrOp<unsigned int>(),
|
||||
UPstream::msgType(), // ignored
|
||||
UPstream::worldComm
|
||||
);
|
||||
#else
|
||||
// Direct call to MPI_Allreduce
|
||||
UPstream::mpiAllReduce
|
||||
(
|
||||
uniformity.data(),
|
||||
uniformity.num_blocks(),
|
||||
UPstream::opCodes::op_bit_or,
|
||||
UPstream::worldComm
|
||||
);
|
||||
#endif
|
||||
Pout<< "reduce uniform " << uniformity << nl;
|
||||
}
|
||||
|
||||
@ -160,8 +178,8 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
Pair<label> val
|
||||
(
|
||||
Pstream::myProcNo(UPstream::commWorld()),
|
||||
Pstream::myProcNo(UPstream::commWorld())
|
||||
UPstream::myProcNo(UPstream::commWorld()),
|
||||
UPstream::myProcNo(UPstream::commWorld())
|
||||
);
|
||||
|
||||
Pair<label> worldVal = val;
|
||||
|
||||
@ -79,7 +79,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
#include "setRootCase.H"
|
||||
|
||||
if (!Pstream::parRun())
|
||||
if (!UPstream::parRun())
|
||||
{
|
||||
Info<< "\nWarning: not parallel - skipping further tests\n" << endl;
|
||||
return 0;
|
||||
@ -97,7 +97,7 @@ int main(int argc, char *argv[])
|
||||
DynamicList<MPI_Request> recvRequests(10);
|
||||
|
||||
|
||||
if (!Pstream::master())
|
||||
if (UPstream::is_subrank())
|
||||
{
|
||||
// Send some random length to master
|
||||
|
||||
|
||||
@ -76,7 +76,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
#include "setRootCase.H"
|
||||
|
||||
if (!Pstream::parRun())
|
||||
if (!UPstream::parRun())
|
||||
{
|
||||
Info<< "\nWarning: not parallel - skipping further tests\n" << endl;
|
||||
return 0;
|
||||
@ -96,7 +96,7 @@ int main(int argc, char *argv[])
|
||||
// Map request indices to procs
|
||||
Map<label> recvFromProc(20);
|
||||
|
||||
if (!Pstream::master())
|
||||
if (UPstream::is_subrank())
|
||||
{
|
||||
// Send some random length to master
|
||||
|
||||
|
||||
3
applications/test/parallel-file-write1/Make/files
Normal file
3
applications/test/parallel-file-write1/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
Test-parallel-file-write1.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-parallel-file-write1
|
||||
2
applications/test/parallel-file-write1/Make/options
Normal file
2
applications/test/parallel-file-write1/Make/options
Normal file
@ -0,0 +1,2 @@
|
||||
/* EXE_INC = */
|
||||
/* EXE_LIBS = */
|
||||
@ -0,0 +1,260 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2025 Mark Olesen
|
||||
-------------------------------------------------------------------------------
|
||||
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-parallel-file-write1
|
||||
|
||||
Description
|
||||
Simple test of writing with MPI/IO
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "Time.H"
|
||||
#include "Switch.H"
|
||||
#include "UPstreamFile.H"
|
||||
#include "SpanStream.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
template<class IntType>
|
||||
void zeropadded(std::ostream& os, IntType val, char fillch = '0')
|
||||
{
|
||||
// set fill char and width
|
||||
os.setf(std::ios_base::right, std::ios_base::adjustfield);
|
||||
fillch = os.fill(fillch);
|
||||
os.width(std::numeric_limits<IntType>::digits10+1);
|
||||
os << val;
|
||||
// restore fill char
|
||||
os.fill(fillch);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noCheckProcessorDirectories();
|
||||
argList::addVerboseOption();
|
||||
argList::addBoolOption("master-footer", "Write footer from master");
|
||||
|
||||
#include "setRootCase.H"
|
||||
|
||||
if (!UPstream::parRun())
|
||||
{
|
||||
Info<< "###############" << nl
|
||||
<< "Not running in parallel. Stopping now" << nl
|
||||
<< "###############" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
const bool optMasterFooter = args.found("master-footer");
|
||||
|
||||
Info<< nl << "Write master-footer: " << Switch::name(optMasterFooter)
|
||||
<< nl << nl;
|
||||
|
||||
Info<< "Create time (without controlDict)\n" << endl;
|
||||
|
||||
auto runTimePtr = Time::New();
|
||||
auto& runTime = runTimePtr();
|
||||
|
||||
const auto myProc = UPstream::myProcNo();
|
||||
const auto nProcs = UPstream::nProcs();
|
||||
|
||||
// Some content
|
||||
OCharStream charset;
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
charset<< char('A' + i);
|
||||
}
|
||||
|
||||
// Header/footer buffers - these can be separate or bundled into
|
||||
// the first/last blocks
|
||||
|
||||
OCharStream header;
|
||||
OCharStream footer;
|
||||
|
||||
// Content buffer
|
||||
OCharStream os(IOstream::BINARY);
|
||||
|
||||
{
|
||||
const auto v = charset.view();
|
||||
|
||||
os << nl;
|
||||
os.beginBlock(word("rank" + Foam::name(myProc)));
|
||||
|
||||
for (int repeat = 0; repeat <= myProc; ++repeat)
|
||||
{
|
||||
os << indent << word("entry" + Foam::name(repeat))
|
||||
<< ' ' << word("List<char>");
|
||||
// os << nl;
|
||||
os << ' ';
|
||||
os << label(v.size());
|
||||
os.write(v.data(), v.size());
|
||||
// os << nl;
|
||||
os.endEntry();
|
||||
}
|
||||
|
||||
os.endBlock();
|
||||
}
|
||||
|
||||
// Bundle the footer into the last block
|
||||
if (!optMasterFooter && (myProc == nProcs-1))
|
||||
{
|
||||
IOobject::writeEndDivider(os);
|
||||
}
|
||||
|
||||
|
||||
// All content now exists - commit to disk
|
||||
const std::string_view blockData(os.view());
|
||||
const int64_t blockSize(blockData.size());
|
||||
|
||||
// Collect sizes
|
||||
const List<int64_t> sizes
|
||||
(
|
||||
UPstream::allGatherValues(blockSize, UPstream::worldComm)
|
||||
);
|
||||
|
||||
|
||||
// Format header with size information
|
||||
if (UPstream::master())
|
||||
{
|
||||
header
|
||||
<< "Simple MPI/IO test with " << nProcs << " ranks" << nl << nl;
|
||||
|
||||
ocharstream labelbuf;
|
||||
labelbuf.reserve_exact(32);
|
||||
|
||||
// Position before writing a label
|
||||
auto labelBegin = header.tellp();
|
||||
|
||||
header.beginBlock("meta");
|
||||
{
|
||||
header << indent << word("data.start") << ' ';
|
||||
|
||||
labelBegin = header.tellp();
|
||||
|
||||
// Add the start value (placeholder)
|
||||
{
|
||||
labelbuf.rewind();
|
||||
zeropadded(labelbuf, label(0));
|
||||
header.append(labelbuf.view());
|
||||
}
|
||||
|
||||
header.endEntry();
|
||||
|
||||
header << indent << word("data.sizes") << nl;
|
||||
sizes.writeList(header); // flatOutput
|
||||
header.endEntry();
|
||||
}
|
||||
header.endBlock();
|
||||
|
||||
header << nl;
|
||||
IOobject::writeDivider(header);
|
||||
|
||||
// Now update with the correct size
|
||||
{
|
||||
labelbuf.rewind();
|
||||
zeropadded(labelbuf, label(header.view().size()));
|
||||
header.overwrite(labelBegin, labelbuf.view());
|
||||
}
|
||||
|
||||
// Bundled the footer into the last block or from master?
|
||||
if (optMasterFooter)
|
||||
{
|
||||
IOobject::writeEndDivider(footer);
|
||||
}
|
||||
}
|
||||
|
||||
// With additional header/footer
|
||||
int64_t headerSize(header.view().size());
|
||||
int64_t footerSize(footer.view().size());
|
||||
|
||||
Pstream::broadcast(headerSize);
|
||||
if (optMasterFooter)
|
||||
{
|
||||
Pstream::broadcast(footerSize);
|
||||
}
|
||||
|
||||
|
||||
int64_t totalSize(headerSize);
|
||||
for (int i = 0; i < myProc; ++i)
|
||||
{
|
||||
totalSize += sizes[i];
|
||||
}
|
||||
|
||||
const int64_t blockOffset(totalSize);
|
||||
|
||||
for (int i = myProc; i < nProcs; ++i)
|
||||
{
|
||||
totalSize += sizes[i];
|
||||
}
|
||||
const int64_t footerOffset(totalSize);
|
||||
totalSize += footerSize;
|
||||
|
||||
|
||||
Pout<< "write size=" << label(blockSize)
|
||||
<< " at=" << label(blockOffset) << " total=" << label(totalSize) << nl;
|
||||
|
||||
{
|
||||
UPstream::File file;
|
||||
|
||||
bool ok = file.open_write
|
||||
(
|
||||
UPstream::worldComm,
|
||||
runTime.globalPath()/"mpiio-test1.txt",
|
||||
IOstreamOption::ATOMIC
|
||||
);
|
||||
|
||||
if (ok)
|
||||
{
|
||||
Info<< "writing: " << file.name() << nl;
|
||||
|
||||
if (UPstream::master())
|
||||
{
|
||||
// A no-op for empty buffer
|
||||
ok = file.write_at(0, header.view());
|
||||
}
|
||||
|
||||
ok = file.write_at_all(blockOffset, blockData);
|
||||
|
||||
if (UPstream::master())
|
||||
{
|
||||
// A no-op for empty buffer
|
||||
ok = file.write_at(footerOffset, footer.view());
|
||||
}
|
||||
}
|
||||
|
||||
file.set_size(totalSize);
|
||||
file.close();
|
||||
}
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -52,7 +52,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
const bool optNonBlocking = args.found("non-blocking");
|
||||
|
||||
if (!Pstream::parRun())
|
||||
if (!UPstream::parRun())
|
||||
{
|
||||
Info<< "\nWarning: not parallel - skipping further tests\n" << endl;
|
||||
return 0;
|
||||
@ -73,7 +73,7 @@ int main(int argc, char *argv[])
|
||||
DynamicList<UPstream::Request> sendRequests(10);
|
||||
DynamicList<UPstream::Request> recvRequests(10);
|
||||
|
||||
if (!Pstream::master())
|
||||
if (UPstream::is_subrank())
|
||||
{
|
||||
// Send some random length to master
|
||||
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-SHA1.C
|
||||
Test-SHA1.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-SHA1
|
||||
|
||||
@ -64,6 +64,10 @@ int main(int argc, char * argv[])
|
||||
osha<< str;
|
||||
Info<< osha.digest() << " : output << to empty" << nl;
|
||||
|
||||
osha.reset();
|
||||
osha<< std::string_view(str);
|
||||
Info<< osha.digest() << " : << string_view [ not quite right !]" << nl;
|
||||
|
||||
sha.clear();
|
||||
sha.append(str);
|
||||
shaDig = sha;
|
||||
@ -42,7 +42,7 @@ using namespace Foam;
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
stringList strings
|
||||
{
|
||||
({
|
||||
"hello",
|
||||
"heello",
|
||||
"heeello",
|
||||
@ -52,7 +52,7 @@ int main(int argc, char *argv[])
|
||||
"okey",
|
||||
"okkey",
|
||||
"okkkey",
|
||||
};
|
||||
});
|
||||
labelList matches;
|
||||
|
||||
wordRes matcher1(ICharStream("( okey \"[hy]e+.*\" )")());
|
||||
@ -72,12 +72,14 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
Info<< "Match found using ListOps = "
|
||||
<< ListOps::found(strings, regExp(".*ee.*")) << nl;
|
||||
|
||||
Info<< "First index = "
|
||||
<< ListOps::find(strings, regExp(".*ee.*")) << nl;
|
||||
{
|
||||
regExp matcher(".*ee.*");
|
||||
|
||||
Info<< "Match found using ListOps = "
|
||||
<< ListOps::found_if(strings, matcher) << nl
|
||||
<< "First index = "
|
||||
<< ListOps::find_if(strings, matcher) << nl;
|
||||
}
|
||||
Info<< endl;
|
||||
|
||||
matches = findMatchingStrings(matcher1, strings);
|
||||
|
||||
@ -33,6 +33,7 @@ Description
|
||||
|
||||
#include "vectorField.H"
|
||||
#include "boolVector.H"
|
||||
#include "complexVector.H"
|
||||
#include "labelVector.H"
|
||||
#include "IOstreams.H"
|
||||
#include "FixedList.H"
|
||||
@ -164,6 +165,30 @@ void testTranscribe(Type& input)
|
||||
}
|
||||
|
||||
|
||||
// Test of adding to vectors, possible of dissimilar types
|
||||
template<class Target, class Source>
|
||||
void testAdding(const Target& a, const Source& b)
|
||||
{
|
||||
typedef typename Target::cmptType cmptType1;
|
||||
typedef typename Source::cmptType cmptType2;
|
||||
|
||||
Info<< " "
|
||||
<< pTraits<Target>::typeName << " += "
|
||||
<< pTraits<Source>::typeName << " : ";
|
||||
|
||||
if constexpr (std::is_convertible_v<cmptType2, cmptType1>)
|
||||
{
|
||||
Target res(a);
|
||||
res += b;
|
||||
Info<< a << " += " << b << " == " << res << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "unsupported" << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
@ -173,6 +198,37 @@ int main(int argc, char *argv[])
|
||||
Info<<"normalised: " << vector::uniform(VSMALL).normalise() << nl;
|
||||
Info<<"normalised: " << vector::uniform(ROOTVSMALL).normalise() << nl;
|
||||
|
||||
{
|
||||
complexVector cvec(complex(1), complex(0), complex(0));
|
||||
doubleVector dvec(1, 0, 0);
|
||||
floatVector fvec(1, 0, 0);
|
||||
labelVector lvec(1, 0, 0);
|
||||
|
||||
Info<< nl << "additions:" << nl;
|
||||
|
||||
testAdding(cvec, cvec);
|
||||
testAdding(cvec, dvec);
|
||||
testAdding(cvec, fvec);
|
||||
testAdding(cvec, lvec);
|
||||
|
||||
testAdding(dvec, cvec);
|
||||
testAdding(dvec, dvec);
|
||||
testAdding(dvec, fvec);
|
||||
testAdding(dvec, lvec);
|
||||
|
||||
testAdding(fvec, cvec);
|
||||
testAdding(fvec, dvec);
|
||||
testAdding(fvec, fvec);
|
||||
testAdding(fvec, lvec);
|
||||
|
||||
testAdding(lvec, cvec);
|
||||
testAdding(lvec, dvec);
|
||||
testAdding(lvec, fvec);
|
||||
testAdding(lvec, lvec);
|
||||
|
||||
Info<< nl;
|
||||
}
|
||||
|
||||
{
|
||||
vector vec1(0.5, 0.5, 0.5);
|
||||
vector vec2(0.5, 0.51, -0.5);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -857,16 +857,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if
|
||||
(
|
||||
obj.isHeaderClass<volScalarField>()
|
||||
|| obj.isHeaderClass<volVectorField>()
|
||||
|| obj.isHeaderClass<volSphericalTensorField>()
|
||||
|| obj.isHeaderClass<volTensorField>()
|
||||
|| obj.isHeaderClass<volSymmTensorField>()
|
||||
|| obj.isHeaderClass<surfaceScalarField>()
|
||||
|| obj.isHeaderClass<surfaceVectorField>()
|
||||
|| obj.isHeaderClass<surfaceSphericalTensorField>()
|
||||
|| obj.isHeaderClass<surfaceSymmTensorField>()
|
||||
|| obj.isHeaderClass<surfaceTensorField>()
|
||||
Foam::fieldTypes::is_volume(obj.headerClassName())
|
||||
|| Foam::fieldTypes::is_surface(obj.headerClassName())
|
||||
)
|
||||
{
|
||||
objects.add(objPtr);
|
||||
|
||||
@ -86,7 +86,7 @@ void constructVolFields(fvMesh& mesh, const vtkUnstructuredReader& reader)
|
||||
);
|
||||
auto& fld = tfld.ref();
|
||||
fld.instance() = mesh.time().timeName();
|
||||
fld.writeOpt() = IOobject::AUTO_WRITE;
|
||||
fld.writeOpt(IOobject::AUTO_WRITE);
|
||||
|
||||
// Fill cell values
|
||||
fld.internalFieldRef().field() =
|
||||
|
||||
@ -152,7 +152,7 @@ Description
|
||||
|
||||
if
|
||||
(
|
||||
!cleanupPatches.found(patchName)
|
||||
!cleanupPatches.contains(patchName)
|
||||
|| returnReduceOr(oldPatches[patchi].size())
|
||||
)
|
||||
{
|
||||
@ -188,8 +188,9 @@ Description
|
||||
|
||||
// Cleanup empty merged point zones
|
||||
{
|
||||
PtrList<pointZone>& zones = mesh.pointZones();
|
||||
mesh.pointZones().clearAddressing();
|
||||
auto& zmesh = mesh.pointZones();
|
||||
zmesh.clearAddressing();
|
||||
PtrList<pointZone>& zones = zmesh;
|
||||
|
||||
wordHashSet removedZones(2*zones.size());
|
||||
|
||||
@ -198,12 +199,11 @@ Description
|
||||
{
|
||||
if
|
||||
(
|
||||
!cleanupPointZones.found(zones[zonei].name())
|
||||
!cleanupPointZones.contains(zones[zonei].name())
|
||||
|| returnReduceOr(zones[zonei].size())
|
||||
)
|
||||
{
|
||||
zones.set(nZones, zones.release(zonei));
|
||||
zones[nZones].index() = nZones; // re-index
|
||||
++nZones;
|
||||
}
|
||||
else
|
||||
@ -212,6 +212,7 @@ Description
|
||||
}
|
||||
}
|
||||
zones.resize(nZones);
|
||||
zmesh.reindex();
|
||||
|
||||
if (removedZones.size())
|
||||
{
|
||||
@ -223,8 +224,9 @@ Description
|
||||
|
||||
// Cleanup empty merged face zones
|
||||
{
|
||||
PtrList<faceZone>& zones = mesh.faceZones();
|
||||
mesh.faceZones().clearAddressing();
|
||||
auto& zmesh = mesh.faceZones();
|
||||
zmesh.clearAddressing();
|
||||
PtrList<faceZone>& zones = zmesh;
|
||||
|
||||
wordHashSet removedZones(2*zones.size());
|
||||
|
||||
@ -233,12 +235,11 @@ Description
|
||||
{
|
||||
if
|
||||
(
|
||||
!cleanupFaceZones.found(zones[zonei].name())
|
||||
!cleanupFaceZones.contains(zones[zonei].name())
|
||||
|| returnReduceOr(zones[zonei].size())
|
||||
)
|
||||
{
|
||||
zones.set(nZones, zones.release(zonei));
|
||||
zones[nZones].index() = nZones; // re-index
|
||||
++nZones;
|
||||
}
|
||||
else
|
||||
@ -247,6 +248,7 @@ Description
|
||||
}
|
||||
}
|
||||
zones.resize(nZones);
|
||||
zmesh.reindex();
|
||||
|
||||
if (removedZones.size())
|
||||
{
|
||||
|
||||
@ -473,16 +473,6 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
|
||||
|
||||
// Precalculate mesh edges for pp.edges.
|
||||
const labelList meshEdges
|
||||
(
|
||||
extrudePatch.meshEdges
|
||||
(
|
||||
mesh.edges(),
|
||||
mesh.pointEdges()
|
||||
)
|
||||
);
|
||||
|
||||
// Global face indices engine
|
||||
const globalIndex globalFaces(mesh.nFaces());
|
||||
|
||||
|
||||
@ -13,28 +13,40 @@ const Enum<writeChecksFormatType> writeChecksFormatTypeNames
|
||||
|
||||
writeChecksFormatType writeChecksFormat(writeChecksFormatType::none);
|
||||
|
||||
auto writeMeshChecks = [](const fvMesh& mesh, const writeChecksFormatType fmt)
|
||||
auto writeMeshChecks = [&](const fvMesh& mesh, const writeChecksFormatType fmt)
|
||||
{
|
||||
// Early exit if 'none' option is set
|
||||
if (fmt == writeChecksFormatType::none)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (UPstream::master())
|
||||
{
|
||||
fileName path(mesh.time().globalPath()/"checkMesh");
|
||||
if (mesh.name() != polyMesh::defaultRegion)
|
||||
{
|
||||
path += "_" + mesh.name();
|
||||
}
|
||||
|
||||
OFstream os(path.ext(writeChecksFormatTypeNames[fmt]));
|
||||
|
||||
Info<< "Writing mesh data to " << os.name() << nl << endl;
|
||||
|
||||
switch (fmt)
|
||||
{
|
||||
case writeChecksFormatType::dictionary:
|
||||
{
|
||||
OFstream os(mesh.time().globalPath()/"checkMesh.dict");
|
||||
|
||||
IOdictionary data
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
mesh.time().globalPath()/"checkMesh.dict",
|
||||
os.name(),
|
||||
mesh,
|
||||
IOobject::NO_READ
|
||||
)
|
||||
);
|
||||
|
||||
Info<< "Writing mesh data to " << os.name() << nl << endl;
|
||||
|
||||
data.writeHeader(os);
|
||||
|
||||
mesh.data().meshDict().write(os, false);
|
||||
@ -45,13 +57,9 @@ auto writeMeshChecks = [](const fvMesh& mesh, const writeChecksFormatType fmt)
|
||||
}
|
||||
case writeChecksFormatType::JSON:
|
||||
{
|
||||
OFstream os(mesh.time().globalPath()/"checkMesh.json");
|
||||
|
||||
Info<< "Writing mesh data to " << os.name() << nl << endl;
|
||||
|
||||
JSONformatter json(os);
|
||||
|
||||
json.writeDict(mesh.data().meshDict());
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2024 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -42,14 +42,14 @@ Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "cyclicPolyPatch.H"
|
||||
#include "syncTools.H"
|
||||
#include "argList.H"
|
||||
#include "Time.H"
|
||||
#include "OFstream.H"
|
||||
#include "meshTools.H"
|
||||
#include "faceSet.H"
|
||||
#include "IOPtrList.H"
|
||||
#include "cyclicPolyPatch.H"
|
||||
#include "syncTools.H"
|
||||
#include "polyTopoChange.H"
|
||||
#include "polyModifyFace.H"
|
||||
#include "polyAddFace.H"
|
||||
@ -942,6 +942,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
|
||||
// Maintain list of added patches so we exclude them from filtering
|
||||
// later on
|
||||
List<DynamicList<word>> allAddedPatches(meshes.size());
|
||||
|
||||
// Loop over all regions
|
||||
|
||||
@ -1036,6 +1039,7 @@ int main(int argc, char *argv[])
|
||||
fvPatchFieldBase::calculatedType(),
|
||||
true
|
||||
);
|
||||
allAddedPatches[meshi].append(ppPtr->name());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1087,6 +1091,7 @@ int main(int argc, char *argv[])
|
||||
fvPatchFieldBase::calculatedType(),
|
||||
true
|
||||
);
|
||||
allAddedPatches[meshi].append(ppPtr->name());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1116,6 +1121,7 @@ int main(int argc, char *argv[])
|
||||
fvPatchFieldBase::calculatedType(),
|
||||
true
|
||||
);
|
||||
allAddedPatches[meshi].append(ppPtr->name());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1453,7 +1459,7 @@ int main(int argc, char *argv[])
|
||||
Info<< "Removing patches with no faces in them." << nl << endl;
|
||||
const wordList oldPatchNames(mesh.boundaryMesh().names());
|
||||
const wordList oldPatchTypes(mesh.boundaryMesh().types());
|
||||
fvMeshTools::removeEmptyPatches(mesh, true);
|
||||
fvMeshTools::removeEmptyPatches(mesh, allAddedPatches[meshi], true);
|
||||
forAll(oldPatchNames, patchi)
|
||||
{
|
||||
const word& pName = oldPatchNames[patchi];
|
||||
@ -1476,14 +1482,11 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
++runTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(meshes, meshi)
|
||||
{
|
||||
fvMesh& mesh = meshes[meshi];
|
||||
|
||||
mesh.setInstance(oldInstances[meshi]);
|
||||
}
|
||||
forAll(meshes, meshi)
|
||||
{
|
||||
fvMesh& mesh = meshes[meshi];
|
||||
mesh.setInstance(overwrite ? oldInstances[meshi] : runTime.timeName());
|
||||
}
|
||||
|
||||
// More precision (for points data)
|
||||
@ -1493,6 +1496,21 @@ int main(int argc, char *argv[])
|
||||
forAll(meshes, meshi)
|
||||
{
|
||||
fvMesh& mesh = meshes[meshi];
|
||||
|
||||
// Override bcs with explicitly provided info. Done late so there
|
||||
// are already patch faces
|
||||
forAll(patchInfoDicts[meshi], sourcei)
|
||||
{
|
||||
const dictionary& patchDict = patchInfoDicts[meshi][sourcei];
|
||||
const word& patchName = patchNames[meshi][sourcei];
|
||||
const label patchID = mesh.boundary().findPatchID(patchName);
|
||||
if (patchID != -1 && patchDict.found("patchFields"))
|
||||
{
|
||||
const dictionary& pfd = patchDict.subDict("patchFields");
|
||||
fvMeshTools::setPatchFields(mesh, patchID, pfd);
|
||||
}
|
||||
}
|
||||
|
||||
Info<< "\n\nWriting repatched mesh " << mesh.name()
|
||||
<< " to " << runTime.timeName() << nl << endl;
|
||||
mesh.clearOut(); // remove meshPhi
|
||||
|
||||
@ -251,18 +251,31 @@ const dictionary& lookupScopedDict
|
||||
return dict;
|
||||
}
|
||||
|
||||
const entry* eptr = dict.findScoped(subDictName, keyType::LITERAL);
|
||||
const auto finder = dict.csearchScoped(subDictName, keyType::LITERAL);
|
||||
|
||||
if (!eptr || !eptr->isDict())
|
||||
if (!finder.good() || !finder.isDict())
|
||||
{
|
||||
// Not found or not a dictionary
|
||||
FatalIOErrorInFunction(dict)
|
||||
<< "'" << subDictName << "' not found in dictionary "
|
||||
<< dict.name() << " or is not a dictionary" << nl
|
||||
<< "Known entries are " << dict.keys()
|
||||
<< '"' << subDictName << '"' << nl;
|
||||
|
||||
if (!finder.good())
|
||||
{
|
||||
FatalIOError << "Not found in dictionary";
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalIOError << "Not a dictionary entry";
|
||||
}
|
||||
|
||||
FatalIOError
|
||||
<< nl << nl
|
||||
<< "Known entries of " << finder.context().name() << " : " << nl
|
||||
<< finder.context().keys()
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
return eptr->dict();
|
||||
return finder.dict();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -383,29 +383,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
if
|
||||
(
|
||||
io.isHeaderClass<volScalarField>()
|
||||
|| io.isHeaderClass<volVectorField>()
|
||||
|| io.isHeaderClass<volSphericalTensorField>()
|
||||
|| io.isHeaderClass<volSymmTensorField>()
|
||||
|| io.isHeaderClass<volTensorField>()
|
||||
|
||||
|| io.isHeaderClass<surfaceScalarField>()
|
||||
|| io.isHeaderClass<surfaceVectorField>()
|
||||
|| io.isHeaderClass<surfaceSphericalTensorField>()
|
||||
|| io.isHeaderClass<surfaceSymmTensorField>()
|
||||
|| io.isHeaderClass<surfaceTensorField>()
|
||||
|
||||
|| io.isHeaderClass<pointScalarField>()
|
||||
|| io.isHeaderClass<pointVectorField>()
|
||||
|| io.isHeaderClass<pointSphericalTensorField>()
|
||||
|| io.isHeaderClass<pointSymmTensorField>()
|
||||
|| io.isHeaderClass<pointTensorField>()
|
||||
|
||||
|| io.isHeaderClass<volScalarField::Internal>()
|
||||
|| io.isHeaderClass<volVectorField::Internal>()
|
||||
|| io.isHeaderClass<volSphericalTensorField::Internal>()
|
||||
|| io.isHeaderClass<volSymmTensorField::Internal>()
|
||||
|| io.isHeaderClass<volTensorField::Internal>()
|
||||
Foam::fieldTypes::is_volume(io.headerClassName())
|
||||
|| Foam::fieldTypes::is_internal(io.headerClassName())
|
||||
|| Foam::fieldTypes::is_surface(io.headerClassName())
|
||||
|| Foam::fieldTypes::is_point(io.headerClassName())
|
||||
)
|
||||
{
|
||||
Info<< " Reading " << io.headerClassName()
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2012-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2024 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -78,11 +78,9 @@ bool Foam::checkFileExistence(const fileName& fName)
|
||||
for (const fileName& dirN : dirEntries)
|
||||
{
|
||||
// Analyse directory name
|
||||
fileName rp, rd, rl;
|
||||
label rNum;
|
||||
label rNum(-1);
|
||||
const label readProci =
|
||||
fileOperation::splitProcessorPath
|
||||
(dirN, rp, rd, rl, group, rNum);
|
||||
fileOperation::detectProcessorPath(dirN, group, &rNum);
|
||||
|
||||
if (proci == readProci)
|
||||
{
|
||||
@ -211,18 +209,8 @@ Foam::boolList Foam::haveMeshFile
|
||||
// Collect local block number
|
||||
label myBlockNumber = -1;
|
||||
{
|
||||
fileName path, pDir, local;
|
||||
procRangeType group;
|
||||
label numProcs;
|
||||
label proci = fileOperation::splitProcessorPath
|
||||
(
|
||||
fName,
|
||||
path,
|
||||
pDir,
|
||||
local,
|
||||
group,
|
||||
numProcs
|
||||
);
|
||||
label proci = fileOperation::detectProcessorPath(fName, group);
|
||||
|
||||
if (proci == -1 && group.empty())
|
||||
{
|
||||
|
||||
@ -64,7 +64,7 @@ Foam::label Foam::parLagrangianDistributor::readAllFields
|
||||
); \
|
||||
\
|
||||
nTotal += parLagrangianDistributor::readFields \
|
||||
<CompactIOField<Field<Type>, Type>> \
|
||||
<CompactIOField<Field<Type>>> \
|
||||
( \
|
||||
cloud, \
|
||||
haveCloud, \
|
||||
@ -177,7 +177,7 @@ Foam::label Foam::parLagrangianDistributor::distributeAllStoredFields
|
||||
); \
|
||||
\
|
||||
nTotal += this->distributeStoredFields \
|
||||
<CompactIOField<Field<Type>, Type>> \
|
||||
<CompactIOField<Field<Type>>> \
|
||||
( \
|
||||
lagrangianMap, \
|
||||
cloud \
|
||||
|
||||
@ -156,14 +156,15 @@ Foam::label Foam::parLagrangianDistributor::distributeFieldFields
|
||||
const wordRes& selectedFields
|
||||
) const
|
||||
{
|
||||
typedef CompactIOField<Field<Type>, Type> Container;
|
||||
typedef CompactIOField<Field<Type>> Container;
|
||||
typedef IOField<Field<Type>> fallbackType;
|
||||
|
||||
DynamicList<word> fieldNames;
|
||||
|
||||
// CompactIOField Field names
|
||||
fieldNames.push_back
|
||||
(
|
||||
filterObjects<CompactIOField<Field<Type>, Type>>
|
||||
filterObjects<Container>
|
||||
(
|
||||
objects,
|
||||
selectedFields
|
||||
@ -173,7 +174,7 @@ Foam::label Foam::parLagrangianDistributor::distributeFieldFields
|
||||
// IOField Field names
|
||||
fieldNames.push_back
|
||||
(
|
||||
filterObjects<IOField<Field<Type>>>
|
||||
filterObjects<fallbackType>
|
||||
(
|
||||
objects,
|
||||
selectedFields
|
||||
|
||||
@ -57,14 +57,7 @@ forAll(meshes, regioni)
|
||||
if (!doPointValues)
|
||||
{
|
||||
// Prune point fields if disabled
|
||||
objects.filterClasses
|
||||
(
|
||||
[](const word& clsName)
|
||||
{
|
||||
return fieldTypes::point.found(clsName);
|
||||
},
|
||||
true // prune
|
||||
);
|
||||
objects.filterClasses(Foam::fieldTypes::is_point, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
@ -28,8 +28,7 @@ if (doFiniteArea)
|
||||
|
||||
autoPtr<faMesh> faMeshPtr;
|
||||
|
||||
const label nAreaFields =
|
||||
faObjects.count(stringListOps::foundOp<word>(fieldTypes::area));
|
||||
const label nAreaFields = faObjects.count(Foam::fieldTypes::is_area);
|
||||
|
||||
if (nAreaFields || withMeshIds)
|
||||
{
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
@ -53,10 +53,7 @@ if (doLagrangian)
|
||||
}
|
||||
|
||||
// Limited to basic IOField types
|
||||
cloudObjs.filterClasses
|
||||
(
|
||||
stringListOps::foundOp<word>(fieldTypes::basic)
|
||||
);
|
||||
cloudObjs.filterClasses(Foam::fieldTypes::is_basic);
|
||||
|
||||
// Are there cloud fields (globally)?
|
||||
if (returnReduceAnd(cloudObjs.empty()))
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
@ -23,10 +23,7 @@ Description
|
||||
{
|
||||
using reportFields = foamToVtkReportFields;
|
||||
|
||||
const label nVolFields =
|
||||
(
|
||||
objects.count(stringListOps::foundOp<word>(fieldTypes::volume))
|
||||
);
|
||||
const label nVolFields = objects.count(Foam::fieldTypes::is_volume);
|
||||
|
||||
reportFields::volume(Info, objects);
|
||||
|
||||
|
||||
@ -24,21 +24,21 @@ Description
|
||||
const label nVolFields =
|
||||
(
|
||||
(doInternal || doBoundary)
|
||||
? objects.count(stringListOps::foundOp<word>(fieldTypes::volume))
|
||||
? objects.count(Foam::fieldTypes::is_volume)
|
||||
: 0
|
||||
);
|
||||
|
||||
const label nDimFields =
|
||||
(
|
||||
(doInternal || doBoundary)
|
||||
? objects.count(stringListOps::foundOp<word>(fieldTypes::internal))
|
||||
? objects.count(Foam::fieldTypes::is_internal)
|
||||
: 0
|
||||
);
|
||||
|
||||
label nPointFields =
|
||||
(
|
||||
doPointValues
|
||||
? objects.count(stringListOps::foundOp<word>(fieldTypes::point))
|
||||
? objects.count(Foam::fieldTypes::is_point)
|
||||
: 0
|
||||
);
|
||||
|
||||
|
||||
@ -803,14 +803,7 @@ int main(int argc, char *argv[])
|
||||
if (!doPointValues)
|
||||
{
|
||||
// Prune point fields if disabled
|
||||
objects.filterClasses
|
||||
(
|
||||
[](const word& clsName)
|
||||
{
|
||||
return fieldTypes::point.found(clsName);
|
||||
},
|
||||
true // prune
|
||||
);
|
||||
objects.filterClasses(Foam::fieldTypes::is_point, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -104,16 +104,7 @@ IOobjectList preFilterFields
|
||||
|
||||
const IOobject& io = *(iter.val());
|
||||
|
||||
if
|
||||
(
|
||||
//OR: fieldTypes::basic.found(io.headerClassName())
|
||||
io.isHeaderClass<IOField<label>>()
|
||||
|| io.isHeaderClass<IOField<scalar>>()
|
||||
|| io.isHeaderClass<IOField<vector>>()
|
||||
|| io.isHeaderClass<IOField<sphericalTensor>>()
|
||||
|| io.isHeaderClass<IOField<symmTensor>>()
|
||||
|| io.isHeaderClass<IOField<tensor>>()
|
||||
)
|
||||
if (Foam::fieldTypes::is_basic(io.headerClassName()))
|
||||
{
|
||||
// Transfer from cloudObjects -> filteredObjects
|
||||
filteredObjects.add(cloudObjects.remove(fldName));
|
||||
|
||||
@ -647,10 +647,10 @@ void Foam::PDRarrays::addBlockage
|
||||
|
||||
const word patchName = word::validate(identifier.substr(0, spc));
|
||||
|
||||
patchNum = ListOps::find
|
||||
patchNum = ListOps::find_if
|
||||
(
|
||||
patches,
|
||||
[=](const PDRpatchDef& p){ return patchName == p.patchName; },
|
||||
[&](const PDRpatchDef& p){ return patchName == p.patchName; },
|
||||
1 // skip 0 (blocked face)
|
||||
);
|
||||
|
||||
|
||||
@ -129,7 +129,7 @@ void MapLagrangianFields
|
||||
MapLagrangianFields
|
||||
<
|
||||
IOField<Field<Type>>,
|
||||
CompactIOField<Field<Type>, Type>
|
||||
CompactIOField<Field<Type>>
|
||||
>
|
||||
(
|
||||
cloudName,
|
||||
@ -141,8 +141,8 @@ void MapLagrangianFields
|
||||
|
||||
MapLagrangianFields
|
||||
<
|
||||
CompactIOField<Field<Type>, Type>,
|
||||
CompactIOField<Field<Type>, Type>
|
||||
CompactIOField<Field<Type>>,
|
||||
CompactIOField<Field<Type>>
|
||||
>
|
||||
(
|
||||
cloudName,
|
||||
|
||||
@ -133,7 +133,7 @@ void MapLagrangianFields
|
||||
MapLagrangianFields
|
||||
<
|
||||
IOField<Field<Type>>,
|
||||
CompactIOField<Field<Type>, Type>
|
||||
CompactIOField<Field<Type>>
|
||||
>
|
||||
(
|
||||
cloudName,
|
||||
@ -145,8 +145,8 @@ void MapLagrangianFields
|
||||
|
||||
MapLagrangianFields
|
||||
<
|
||||
CompactIOField<Field<Type>, Type>,
|
||||
CompactIOField<Field<Type>, Type>
|
||||
CompactIOField<Field<Type>>,
|
||||
CompactIOField<Field<Type>>
|
||||
>
|
||||
(
|
||||
cloudName,
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2014-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -268,6 +268,12 @@ int main(int argc, char *argv[])
|
||||
argList::noParallel();
|
||||
argList::addArgument("hookTolerance", "The point merge tolerance");
|
||||
argList::addOption("dict", "file", "Alternative surfaceHookUpDict");
|
||||
argList::addOption
|
||||
(
|
||||
"maxIters",
|
||||
"number",
|
||||
"Maximum number of iterations (default: 100)"
|
||||
);
|
||||
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
@ -281,9 +287,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
const scalar dist(args.get<scalar>(1));
|
||||
const scalar matchTolerance(Foam::max(1e-6*dist, SMALL));
|
||||
const label maxIters = 100;
|
||||
const label maxIters = args.getOrDefault<label>("maxIters", 100);
|
||||
|
||||
Info<< "Hooking distance = " << dist << endl;
|
||||
Info<< "Hooking distance = " << dist << nl
|
||||
<< "Maximum iterations = " << maxIters << endl;
|
||||
|
||||
searchableSurfaces surfs
|
||||
(
|
||||
|
||||
@ -16,8 +16,7 @@
|
||||
# mpirunDebug
|
||||
#
|
||||
# Description
|
||||
# Invoke mpirun with separate per-processor log files
|
||||
# or running in separate XTerms.
|
||||
# Invoke mpirun with separate per-processor log files etc.
|
||||
# Requires bash on all processors.
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
@ -100,15 +99,6 @@ methodNumberToName()
|
||||
#-------------------------------------------------------------------------------
|
||||
# Basic settings
|
||||
|
||||
case "$(uname -s)" in
|
||||
Linux)
|
||||
ECHO='echo -e'
|
||||
;;
|
||||
*)
|
||||
ECHO='echo'
|
||||
;;
|
||||
esac
|
||||
|
||||
unset appName appArgs nProcs
|
||||
unset method spawn optClean optValue opt_nocore
|
||||
optConfirm=true
|
||||
@ -250,7 +240,7 @@ then
|
||||
echo "Cleanup old mpirunDebug files..."
|
||||
rm -f gdbCommands mpirun.schema vgcore.*
|
||||
rm -f processor*.log processor*.sh
|
||||
rm -rf mpirun.log mpirun.files
|
||||
rm -rf mpirun.files mpirun.log
|
||||
echo " gdbCommands mpirun.schema vgcore.*"
|
||||
echo " processor*.{log,sh}"
|
||||
echo " mpirun.{files,log}/"
|
||||
@ -289,7 +279,7 @@ exec=$(command -v $appName)
|
||||
if [ -z "$method" ]
|
||||
then
|
||||
echo "Choose running method: ${methodPrompt}"
|
||||
$ECHO "[normal] > \c"
|
||||
echo -e "[normal] > \c"
|
||||
read input
|
||||
: "${input:=0}" # Default (0) normal
|
||||
|
||||
@ -301,7 +291,7 @@ fi
|
||||
if [ -z "$spawn" ]
|
||||
then
|
||||
echo "Run all processes local or distributed? 1)local 2)remote"
|
||||
$ECHO "[local] > \c"
|
||||
echo -e "[local] > \c"
|
||||
read input
|
||||
: "${input:=1}" # Default (1) local
|
||||
|
||||
@ -478,7 +468,7 @@ unset cmd
|
||||
|
||||
case "$WM_MPLIB" in
|
||||
*OPENMPI*)
|
||||
cmd="mpirun --oversubscribe -app "$schema_file" </dev/null"
|
||||
cmd="mpirun --oversubscribe -app "$schema_file""
|
||||
;;
|
||||
MPICH)
|
||||
cmd="mpiexec"
|
||||
@ -511,13 +501,14 @@ echo 1>&2
|
||||
if [ -n "$optConfirm" ]
|
||||
then
|
||||
# Pause before running
|
||||
$ECHO "Press return to execute.\c"
|
||||
echo -e "Press return to execute, or ^C to abort...\c"
|
||||
read input
|
||||
else
|
||||
echo "starting: $(date '+%Y-%m-%d %H:%M:%S %z' 2>/dev/null)" 1>&2
|
||||
echo 1>&2
|
||||
fi
|
||||
echo "starting: $(date '+%Y-%m-%d %H:%M:%S %z' 2>/dev/null)" 1>&2
|
||||
echo 1>&2
|
||||
|
||||
exec </dev/null
|
||||
exec $cmd
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
# \\/ M anipulation |
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
# Copyright (C) 2015-2023 OpenCFD Ltd.
|
||||
# Copyright (C) 2015-2025 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
@ -32,10 +32,13 @@ cleanTimeDirectories()
|
||||
}
|
||||
|
||||
|
||||
# Various files (logs, paraview, etc)
|
||||
# Various files (logs, paraview, some mpirunDebug, etc)
|
||||
# Note: leave mpirun.log/ files untouched, since they may still be useful
|
||||
# for later diagnosis
|
||||
cleanAuxiliary()
|
||||
{
|
||||
rm -rf \
|
||||
./mpirun.files \
|
||||
./log ./log.* ./log-* ./logSummary.* \
|
||||
./.fxLock ./*.xml ./ParaView* ./paraFoam* \
|
||||
./*.blockMesh ./*.foam ./*.OpenFOAM \
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
# \\/ M anipulation |
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
# Copyright (C) 2015-2024 OpenCFD Ltd.
|
||||
# Copyright (C) 2015-2025 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
@ -233,7 +233,7 @@ getApplication()
|
||||
#
|
||||
runApplication()
|
||||
{
|
||||
local appName appRun optValue logFile logMode
|
||||
local appRun optValue logDir logMode prefix suffix
|
||||
|
||||
# Any additional parsed arguments (eg, decomposeParDict)
|
||||
local appArgs
|
||||
@ -250,8 +250,16 @@ runApplication()
|
||||
(-o | -overwrite)
|
||||
logMode=overwrite
|
||||
;;
|
||||
(-d | -directory)
|
||||
logDir="${2%/}/"
|
||||
shift
|
||||
;;
|
||||
(-p | -prefix)
|
||||
prefix="$2"
|
||||
shift
|
||||
;;
|
||||
(-s | -suffix)
|
||||
logFile=".$2"
|
||||
suffix=".${2#.}"
|
||||
shift
|
||||
;;
|
||||
|
||||
@ -279,10 +287,10 @@ runApplication()
|
||||
shift
|
||||
done
|
||||
|
||||
appName="${appRun##*/}"
|
||||
logFile="log.$appName$logFile"
|
||||
local appName="${appRun##*/}"
|
||||
local logFile="$logDir${prefix:-log.}$appName$suffix"
|
||||
|
||||
if [ -f "$logFile" ] && [ -z "$logMode" ]
|
||||
if [ -z "$logMode" ] && [ -f "$logFile" ]
|
||||
then
|
||||
echo "$appName already run on $PWD:" \
|
||||
"remove log file '$logFile' to re-run"
|
||||
@ -290,9 +298,9 @@ runApplication()
|
||||
echo "Running $appRun on $PWD"
|
||||
if [ "$logMode" = append ]
|
||||
then
|
||||
$appRun $appArgs "$@" >> $logFile 2>&1
|
||||
$appRun $appArgs "$@" >> "$logFile" 2>&1
|
||||
else
|
||||
$appRun $appArgs "$@" > $logFile 2>&1
|
||||
$appRun $appArgs "$@" > "$logFile" 2>&1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@ -304,7 +312,7 @@ runApplication()
|
||||
#
|
||||
runParallel()
|
||||
{
|
||||
local appName appRun optValue logFile logMode
|
||||
local appRun optValue logDir logMode prefix suffix
|
||||
local mpiopts nProcs
|
||||
|
||||
# Any additional parsed arguments (eg, decomposeParDict)
|
||||
@ -332,8 +340,16 @@ runParallel()
|
||||
(-o | -overwrite)
|
||||
logMode=overwrite
|
||||
;;
|
||||
(-d | -directory)
|
||||
logDir="${2%/}/"
|
||||
shift
|
||||
;;
|
||||
(-p | -prefix)
|
||||
prefix="$2"
|
||||
shift
|
||||
;;
|
||||
(-s | -suffix)
|
||||
logFile=".$2"
|
||||
suffix=".${2#.}"
|
||||
shift
|
||||
;;
|
||||
(-n | -np)
|
||||
@ -370,10 +386,10 @@ runParallel()
|
||||
|
||||
[ -n "$nProcs" ] || nProcs=$(getNumberOfProcessors system/decomposeParDict)
|
||||
|
||||
appName="${appRun##*/}"
|
||||
logFile="log.$appName$logFile"
|
||||
local appName="${appRun##*/}"
|
||||
local logFile="$logDir${prefix:-log.}$appName$suffix"
|
||||
|
||||
if [ -f "$logFile" ] && [ -z "$logMode" ]
|
||||
if [ -z "$logMode" ] && [ -f "$logFile" ]
|
||||
then
|
||||
echo "$appName already run on $PWD:" \
|
||||
"remove log file '$logFile' to re-run"
|
||||
@ -383,11 +399,11 @@ runParallel()
|
||||
if [ "$logMode" = append ]
|
||||
then
|
||||
(
|
||||
"$mpirun" $mpiopts -n "${nProcs:?}" $appRun $appArgs "$@" </dev/null >> $logFile 2>&1
|
||||
"$mpirun" $mpiopts -n "${nProcs:?}" $appRun $appArgs "$@" </dev/null >> "$logFile" 2>&1
|
||||
)
|
||||
else
|
||||
(
|
||||
"$mpirun" $mpiopts -n "${nProcs:?}" $appRun $appArgs "$@" </dev/null > $logFile 2>&1
|
||||
"$mpirun" $mpiopts -n "${nProcs:?}" $appRun $appArgs "$@" </dev/null > "$logFile" 2>&1
|
||||
)
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -120,6 +120,7 @@ Components specified by absolute path
|
||||
-kahip-path DIR Path for 'KAHIP_ARCH_PATH' (overrides -kahip)
|
||||
-metis-path DIR Path for 'METIS_ARCH_PATH' (overrides -metis)
|
||||
-petsc-path DIR Path for 'PETSC_ARCH_PATH' (overrides -petsc)
|
||||
-readline-path Path for 'READLINE_ARCH_PATH'
|
||||
-scotch-path DIR Path for 'SCOTCH_ARCH_PATH' (overrides -scotch)
|
||||
|
||||
-gmp-path DIR Path for 'GMP_ARCH_PATH' (in cgal config)
|
||||
@ -128,7 +129,7 @@ Components specified by absolute path
|
||||
Components specified by homebrew (treat like system locations)
|
||||
Sets version as system, path from brew --prefix
|
||||
-adios-brew, -adios2-brew, -boost-brew, -cgal-brew,
|
||||
-fftw-brew, -kahip-brew, -metis-brew, -scotch-brew
|
||||
-fftw-brew, -kahip-brew, -metis-brew, -readline-brew -scotch-brew
|
||||
|
||||
-with-homebrew Shortcut for selecting all the above
|
||||
|
||||
@ -500,6 +501,7 @@ then
|
||||
-fftw-brew \
|
||||
-kahip-brew \
|
||||
-metis-brew \
|
||||
-readline-brew \
|
||||
-scotch-brew \
|
||||
"$@"
|
||||
fi
|
||||
@ -1174,6 +1176,35 @@ CONFIG_CSH
|
||||
adjusted=true
|
||||
;;
|
||||
|
||||
-readline-path)
|
||||
# Replace READLINE_ARCH_PATH=...
|
||||
getOptionValue "$@"; shift "${nOptArgs:-0}"
|
||||
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
# Remove leading '#config#' marker
|
||||
removeEtcConfigMarker config.sh/readline READLINE_ARCH_PATH
|
||||
|
||||
replaceEtc config.sh/readline READLINE_ARCH_PATH "\"$optValue\""
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
;;
|
||||
|
||||
-readline-brew)
|
||||
brewName=readline; optValue="${brewName}-system"
|
||||
|
||||
# Remove leading '#config#' marker
|
||||
removeEtcConfigMarker config.sh/readline READLINE_ARCH_PATH
|
||||
|
||||
# Replace READLINE_ARCH_PATH=...
|
||||
replaceBrewEtc config.sh/readline READLINE_ARCH_PATH "$brewName"
|
||||
|
||||
# Replaced READLINE_ARCH_PATH=...
|
||||
adjusted=true
|
||||
;;
|
||||
|
||||
-scotch | -scotchVersion | --scotchVersion)
|
||||
# Replace SCOTCH_VERSION=...
|
||||
getOptionValue "$@"; shift "${nOptArgs:-0}"
|
||||
|
||||
27
etc/config.sh/readline
Normal file
27
etc/config.sh/readline
Normal file
@ -0,0 +1,27 @@
|
||||
#----------------------------------*-sh-*--------------------------------------
|
||||
# ========= |
|
||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
# \\ / O peration |
|
||||
# \\ / A nd | www.openfoam.com
|
||||
# \\/ M anipulation |
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright (C) 2025 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
#
|
||||
# File
|
||||
# etc/config.sh/readline
|
||||
# [optional/experimental: not sourced by OpenFOAM-*/etc/bashrc]
|
||||
#
|
||||
# Description
|
||||
# Example setup for READLINE locations
|
||||
#
|
||||
# The leading '#config#' marker provides an edit point for
|
||||
# foamConfigurePaths
|
||||
#------------------------------------------------------------------------------
|
||||
# USER EDITABLE PART: Changes made here may be lost with the next upgrade
|
||||
|
||||
#config# export READLINE_ARCH_PATH=...
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user