Compare commits

..

1 Commits

Author SHA1 Message Date
7b7229fc13 ENH: integrate memory pool support for List allocations
- provides an optional memory management using a memory pool.
  Currently can support Umpire (https://github.com/LLNL/Umpire)

  When available, its use can be controlled by the FOAM_MEMORY_POOL
  environment variable, or the memory_pool Optimisation switch
  (etc/controlDict).

Notes:

  Use of the memory-pool is controlled by the 'is_aligned_type()' test
  and the minimum field size, controlled by the 'use_memory_pool()' test.

  If the memory-pool is not enabled or not required according to the two
  above tests, the allocation falls back to either an aligned or unaligned
  allocation (depending on the field size).

  The thresholds for aligned, unaligned, memory-pool allocation
  are still a compile-time option. Made by direct edit of the
  corrsponding functions.
2025-05-22 16:22:09 +02:00
10445 changed files with 19684 additions and 34337 deletions

3
.gitignore vendored
View File

@ -11,7 +11,6 @@
# File-browser settings - anywhere
.directory
.DS_Store # OSX app store
# Backup/recovery versions - anywhere
.#*
@ -39,8 +38,6 @@ linux*Gcc*/
linux*Icc*/
solaris*Gcc*/
SunOS*Gcc*/
darwin*Clang*/
darwin*Gcc*/
platforms/
# Top-level build directories

View File

@ -49,7 +49,7 @@
<!--
Providing details of your set-up can help us identify any issues, e.g.
OpenFOAM version : v2506|v2412|v2406|v2312|v2306 etc
OpenFOAM version : v2412|v2406|v2312|v2306|v2212 etc
Operating system : ubuntu|openSUSE|RedHat etc
Hardware info : any info that may help?
Compiler : gcc|clang etc

View File

@ -1,15 +1,13 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
set -- -all="${0##*/}" "$@" # Execute this instead of ./Allwmake
# Run from OPENFOAM top-level directory only
cd "${0%/*}" || exit
wmake -check-dir "$WM_PROJECT_DIR" 2>/dev/null || {
echo "Error (${0##*/}) : not located in \$WM_PROJECT_DIR"
echo " Check your OpenFOAM environment and installation"
exit 1
}
if [ -f "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments ]
then . "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments || \
then . "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments -no-recursion "$@" || \
echo "Argument parse error"
else
echo "Error (${0##*/}) : WM_PROJECT_DIR appears to be incorrect"
@ -33,7 +31,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
#------------------------------------------------------------------------------

View File

@ -1,15 +1,13 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
set -- -all="${0##*/}" "$@" # Execute this instead of ./Allwmake
# Run from OPENFOAM top-level directory only
cd "${0%/*}" || exit
wmake -check-dir "$WM_PROJECT_DIR" 2>/dev/null || {
echo "Error (${0##*/}) : not located in \$WM_PROJECT_DIR"
echo " Check your OpenFOAM environment and installation"
exit 1
}
if [ -f "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments ]
then . "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments || \
then . "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments -no-recursion "$@" || \
echo "Argument parse error"
else
echo "Error (${0##*/}) : WM_PROJECT_DIR appears to be incorrect"
@ -33,7 +31,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
#------------------------------------------------------------------------------

View File

@ -1,2 +1,2 @@
api=2506
api=2501
patch=0

View File

@ -40,9 +40,9 @@ Violations of the Trademark are monitored, and will be duly prosecuted.
If OpenFOAM has already been compiled on your system, simply source
the appropriate `etc/bashrc` or `etc/cshrc` file and get started.
For example, for the OpenFOAM-v2506 version:
For example, for the OpenFOAM-v2412 version:
```
source /installation/path/OpenFOAM-v2506/etc/bashrc
source /installation/path/OpenFOAM-v2412/etc/bashrc
```
## Compiling OpenFOAM
@ -127,8 +127,8 @@ These 3rd-party sources are normally located in a directory parallel
to the OpenFOAM directory. For example,
```
/path/parent
|-- OpenFOAM-v2506
\-- ThirdParty-v2506
|-- OpenFOAM-v2412
\-- ThirdParty-v2412
```
There are, however, many cases where this simple convention is inadequate:
@ -156,9 +156,9 @@ when locating the ThirdParty directory with the following precedence:
2. PREFIX/ThirdParty-VERSION
* this corresponds to the traditional approach
3. PREFIX/ThirdParty-vAPI
* allows for an updated value of VERSION, *eg*, `v2506-myCustom`,
* allows for an updated value of VERSION, *eg*, `v2412-myCustom`,
without requiring a renamed ThirdParty. The API value would still
be `2412` and the original `ThirdParty-v2506/` would be found.
be `2412` and the original `ThirdParty-v2412/` would be found.
4. PREFIX/ThirdParty-API
* same as the previous example, but using an unadorned API value.
5. PREFIX/ThirdParty-common

View File

@ -13,13 +13,7 @@ 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 = Zero;
{
U.internalFieldRef() = Zero;
U.boundaryFieldRef() = Zero;
}
U = dimensionedVector(U.dimensions(), Zero);
surfaceScalarField phi
(

View File

@ -1086,7 +1086,7 @@ void Foam::multiphaseMixtureThermo::solveAlphas
MULES::limitSum(alphaPhiCorrs);
rhoPhi_ = Zero;
rhoPhi_ = dimensionedScalar(dimensionSet(1, 0, -1, 0, 0), Zero);
volScalarField sumAlpha
(

View File

@ -63,11 +63,23 @@ 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_);
}
}

View File

@ -557,7 +557,7 @@ void Foam::radiation::laserDTRM::calculate()
// Reset the field
Q_ == Zero;
Q_ == dimensionedScalar(Q_.dimensions(), Zero);
a_ = absorptionEmission_->a();
e_ = absorptionEmission_->e();

View File

@ -232,7 +232,7 @@
surfaceScalarField mSfGradp("mSfGradp", pEqnIncomp.flux()/rAUf);
phasei = 0;
phi = Zero;
phi = dimensionedScalar("phi", phi.dimensions(), Zero);
for (phaseModel& phase : fluid.phases())
{
@ -261,7 +261,7 @@
mSfGradp = pEqnIncomp.flux()/rAUf;
U = Zero;
U = dimensionedVector("U", dimVelocity, Zero);
phasei = 0;
for (phaseModel& phase : fluid.phases())

View File

@ -626,7 +626,7 @@ void Foam::multiphaseMixture::solveAlphas
MULES::limitSum(alphaPhiCorrs);
rhoPhi_ = Zero;
rhoPhi_ = dimensionedScalar(dimMass/dimTime, Zero);
volScalarField sumAlpha
(

View File

@ -14,6 +14,6 @@ if (!(runTime.timeIndex() % 5))
if (smi < -SMALL)
{
Info<< "Resetting Dcorr to 0" << endl;
Dcorr == Zero;
Dcorr == dimensionedVector(Dcorr.dimensions(), Zero);
}
}

View File

@ -1,6 +1,6 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. "${WM_PROJECT_DIR:?}"/wmake/scripts/wmakeFunctions # Need wmake functions
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions # Require wmake functions
#------------------------------------------------------------------------------

View File

@ -1,9 +1,7 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
set -- -all="${0##*/}" "$@" # Execute this instead of ./Allwmake
. "${WM_PROJECT_DIR:?}"/wmake/scripts/AllwmakeParseArguments
. "${WM_PROJECT_DIR:?}"/wmake/scripts/wmakeFunctions # Need wmake functions
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments -no-recursion "$@"
. ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions # Require wmake functions
#------------------------------------------------------------------------------
# Environment

View File

@ -1,3 +1,3 @@
Test-CompactIOList.cxx
Test-CompactIOList.C
EXE = $(FOAM_USER_APPBIN)/Test-CompactIOList

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2020-2025 OpenCFD Ltd.
Copyright (C) 2020-2022 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
Test-CompactIOList
testCompactIOList
Description
Simple demonstration and test application for the CompactIOList container
@ -46,20 +46,13 @@ 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);
if (args.found("ascii"))
{
streamOpt.format(IOstreamOption::ASCII);
}
const label size = args.getOrDefault<label>("count", 20000000);
const label size = 20000000;
// Old format
// ~~~~~~~~~~
@ -70,50 +63,39 @@ int main(int argc, char *argv[])
(
IOobject
(
"faces2-plain",
"faces2",
runTime.constant(),
polyMesh::meshSubDir,
runTime,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
)
),
size
);
faces2.resize(size, face(identity(4)));
const face f(identity(4));
Info<< "Plain format faceList " << faces2.objectRelPath() << nl;
Info<< " constructed in = " << runTime.cpuTimeIncrement()
<< " s" << endl;
forAll(faces2, i)
{
faces2[i] = f;
}
Info<< "Constructed faceList in = "
<< runTime.cpuTimeIncrement() << " s" << nl << endl;
faces2.writeObject(streamOpt, true);
Info<< " wrote in = "
<< runTime.cpuTimeIncrement() << " s" << endl;
// Read (size only)
label count = faceIOList::readContentsSize
(
IOobject
(
"faces2-plain",
runTime.constant(),
polyMesh::meshSubDir,
runTime,
IOobject::MUST_READ
)
);
Info<< " counted " << count << " faces on disk in = "
<< runTime.cpuTimeIncrement() << " s" << endl;
Info<< "Written old format faceList in = "
<< runTime.cpuTimeIncrement() << " s" << nl << endl;
// Read
faceIOList faces2b
faceIOList faces3
(
IOobject
(
"faces2-plain",
"faces2",
runTime.constant(),
polyMesh::meshSubDir,
runTime,
@ -123,7 +105,7 @@ int main(int argc, char *argv[])
)
);
Info<< " read " << faces2b.size() << " faces in = "
Info<< "Read old format " << faces3.size() << " faceList in = "
<< runTime.cpuTimeIncrement() << " s" << nl << endl;
}
@ -132,54 +114,44 @@ int main(int argc, char *argv[])
// ~~~~~~~~~~
{
// Construct big faceList in compact format
// Construct big faceList in new format
faceCompactIOList faces2
(
IOobject
(
"faces2-compact",
"faces2",
runTime.constant(),
polyMesh::meshSubDir,
runTime,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
)
),
size
);
faces2.resize(size, face(identity(4)));
const face f(identity(4));
Info<< "Compact format faceList" << faces2.objectRelPath() << nl;
Info<< " constructed in = "
<< runTime.cpuTimeIncrement() << " s" << endl;
forAll(faces2, i)
{
faces2[i] = f;
}
Info<< "Constructed new format faceList in = "
<< runTime.cpuTimeIncrement() << " s" << nl << endl;
faces2.writeObject(streamOpt, true);
Info<< " wrote in = "
<< runTime.cpuTimeIncrement() << " s" << endl;
// Read (size only)
label count = faceCompactIOList::readContentsSize
(
IOobject
(
"faces2-compact",
runTime.constant(),
polyMesh::meshSubDir,
runTime,
IOobject::MUST_READ
)
);
Info<< " counted " << count << " faces on disk in = "
<< runTime.cpuTimeIncrement() << " s" << endl;
Info<< "Written new format faceList in = "
<< runTime.cpuTimeIncrement() << " s" << nl << endl;
// Read
faceCompactIOList faces2b
faceCompactIOList faces3
(
IOobject
(
"faces2-compact",
"faces2",
runTime.constant(),
polyMesh::meshSubDir,
runTime,
@ -189,7 +161,7 @@ int main(int argc, char *argv[])
)
);
Info<< " read " << faces2b.size() << " faces in = "
Info<< "Read new format " << faces3.size() << " faceList in = "
<< runTime.cpuTimeIncrement() << " s" << nl << endl;
}

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,3 +1,3 @@
Test-HashPtrTable.cxx
Test-HashPtrTable.C
EXE = $(FOAM_USER_APPBIN)/Test-HashPtrTable

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2017-2025 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -42,55 +42,33 @@ Description
using namespace Foam;
bool verbosity = true;
// Gratuitous class inheritance
template<class T>
class BoxedType
class Scalar
{
T data_;
scalar data_;
public:
static bool verbose;
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;
constexpr Scalar() noexcept : data_(0) {}
Scalar(scalar val) noexcept : data_(val) {}
~Scalar()
{
if (verbosity) Info<< "delete Scalar: " << value() << nl;
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;
}
auto clone() const { return autoPtr<Scalar>::New(*this); }
};
Ostream& operator<<(Ostream& os, const Scalar& item)
{
return (os << item.value());
}
bool Scalar::verbose = true;
template<class T>

View File

@ -1,3 +1,3 @@
Test-HashTable2.cxx
Test-HashTable2.C
EXE = $(FOAM_USER_APPBIN)/Test-HashTable2

View File

@ -1,3 +1,3 @@
Test-HashTable3.cxx
Test-HashTable3.C
EXE = $(FOAM_USER_APPBIN)/Test-HashTable3

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -89,6 +89,12 @@ 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());

View File

@ -1,3 +1,3 @@
Test-IOobjectList.cxx
Test-IOobjectList.C
EXE = $(FOAM_USER_APPBIN)/Test-IOobjectList

View File

@ -1,3 +1,3 @@
Test-ISLList.cxx
Test-ISLList.C
EXE = $(FOAM_USER_APPBIN)/Test-ISLList

View File

@ -1,3 +1,3 @@
Test-IStringStream.cxx
Test-IStringStream.C
EXE = $(FOAM_USER_APPBIN)/Test-IStringStream

View File

@ -51,7 +51,6 @@ See also
#include "IndirectList.H"
#include "SubList.H"
#include "SliceList.H"
#include "SubField.H"
#include "ListPolicy.H"
#include <list>
@ -106,7 +105,7 @@ void printMyString(const UList<string>& lst)
{
MyStrings slist2(lst);
Info<< slist2 << nl;
Info<<slist2 << nl;
}
@ -204,6 +203,16 @@ 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)
@ -272,33 +281,6 @@ int main(int argc, char *argv[])
};
Info<< "list4: " << list4 << endl;
{
List<scalar> list4Mag = ListOps::create<scalar>
(
list4,
[](const auto& a){ return a.mag(); }
);
const auto equalMag = [](const auto& a, const auto& b)
{
return (Foam::mag(a) == Foam::mag(b));
};
Info<< "list4 (mag): " << list4Mag << endl;
bool same = ListOps::equal(list4, list4Mag, equalMag);
Info<< "mag(list4) == list4(mag): " << same << nl;
SubField<scalar>(list4Mag) *= -1;
same = ListOps::equal(list4, list4Mag, equalMag);
Info<< "mag(list4) == list4(mag): " << same << nl;
SubField<scalar>(list4Mag) *= 1.1;
same = ListOps::equal(list4, list4Mag, equalMag);
Info<< "mag(list4) == list4(mag): " << same << nl;
}
List<vector> list5
{
{5, 3, 1},
@ -360,7 +342,7 @@ int main(int argc, char *argv[])
auto shrtList = ListOps::create<short>
(
longLabelList,
[](label val){ return val; }
[](const label& val){ return val; }
);
printListOutputType<short>("short") << nl;
@ -557,7 +539,7 @@ int main(int argc, char *argv[])
auto scalars = ListOps::create<scalar>
(
labels,
[](label val){ return scalar(1.5*val); }
[](const label& val){ return scalar(1.5*val); }
);
Info<< "scalars: " << flatOutput(scalars) << endl;
}
@ -566,7 +548,7 @@ int main(int argc, char *argv[])
auto vectors = ListOps::create<vector>
(
labels,
[](label val){ return vector(1.2*val, -1.2*val, 0); }
[](const label& val){ return vector(1.2*val, -1.2*val, 0); }
);
Info<< "vectors: " << flatOutput(vectors) << endl;
}
@ -575,7 +557,7 @@ int main(int argc, char *argv[])
auto longs = ListOps::create<long>
(
labels,
[](label val){ return val; }
[](const label& val){ return val; }
);
Info<< "longs: " << flatOutput(longs) << endl;
}
@ -593,7 +575,7 @@ int main(int argc, char *argv[])
(
labelRange().cbegin(),
labelRange(15).cend(),
[](label val){ return scalar(-1.125*val); }
[](const label& val){ return scalar(-1.125*val); }
);
Info<< "scalars: " << flatOutput(scalars) << endl;
}

View File

@ -89,6 +89,12 @@ 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());
@ -183,25 +189,12 @@ int main(int argc, char *argv[])
printInfo(obuf);
// Overwrite at some position
if (auto i = obuf.view().find("item5"); i != std::string::npos)
{
// obuf.seek(0.60 * obuf.size());
obuf.seek(i);
obuf << "<OVERWRITE>" << nl;
}
obuf.stdStream().rdbuf()->pubseekpos(0.60 * obuf.size());
obuf << "<" << nl << "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

View File

@ -1,3 +0,0 @@
Test-OCharStream2.cxx
EXE = $(FOAM_USER_APPBIN)/Test-OCharStream2

View File

@ -1,2 +0,0 @@
/* EXE_INC = */
/* EXE_LIBS = */

View File

@ -1,473 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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;
}
// ************************************************************************* //

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2025 OpenCFD Ltd.
Copyright (C) 2017-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -65,6 +65,7 @@ int main(int argc, char *argv[])
OCountStream cnt;
OCharStream cstr;
OStringStream sstr;
ocountstream plain;
generateOutput(cstr);
@ -76,6 +77,7 @@ int main(int argc, char *argv[])
Info<< "counter state: " << (cnt.stdStream().rdstate()) << nl
<< "via char-stream: " << label(cstr.view().size()) << " chars" << nl
<< "via string-stream: " << label(sstr.count()) << " chars" << nl
<< "via ocountstream: " << plain.count() << " chars" << endl;
fileName outputName;

View File

@ -1,3 +1,3 @@
Test-OStringStream.cxx
Test-OStringStream.C
EXE = $(FOAM_USER_APPBIN)/Test-OStringStream

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,3 +1,3 @@
Test-PackedList.cxx
Test-PackedList.C
EXE = $(FOAM_USER_APPBIN)/Test-PackedList

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,3 +1,3 @@
Test-PtrDictionary1.cxx
Test-PtrDictionary1.C
EXE = $(FOAM_USER_APPBIN)/Test-PtrDictionary1

View File

@ -42,8 +42,6 @@ Description
using namespace Foam;
bool verbosity = true;
class ent
:
public Dictionary<ent>::link
@ -75,12 +73,14 @@ class Scalar
public:
static bool verbose;
constexpr Scalar() noexcept : data_(0) {}
Scalar(scalar val) noexcept : data_(val) {}
~Scalar()
{
if (verbosity) Info<< "delete Scalar: " << data_ << endl;
if (verbose) Info<< "delete Scalar: " << data_ << endl;
}
scalar value() const noexcept { return data_; }
@ -93,6 +93,8 @@ public:
}
};
bool Scalar::verbose = true;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:

View File

@ -1,3 +1,3 @@
Test-PtrList.cxx
Test-PtrList.C
EXE = $(FOAM_USER_APPBIN)/Test-PtrList

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2018-2025 OpenCFD Ltd.
Copyright (C) 2018-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -41,85 +41,35 @@ Description
using namespace Foam;
bool verbosity = true;
// Gratuitous class inheritance
template<class T>
class BoxedType
class Scalar
{
T data_;
scalar data_;
public:
static bool verbose;
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;
constexpr Scalar() noexcept : data_(0) {}
Scalar(scalar val) noexcept : data_(val) {}
~Scalar()
{
if (verbosity) Info<< "delete Scalar: " << value() << nl;
if (verbose) Info<< "delete Scalar: " << data_ << endl;
}
auto clone() const { return autoPtr<Scalar>::New(*this); }
};
Ostream& operator<<(Ostream& os, const Scalar& item)
{
return (os << item.value());
}
scalar value() const noexcept { return data_; }
scalar& value() noexcept { return data_; }
autoPtr<Scalar> clone() const { return autoPtr<Scalar>::New(data_); }
class Integer : public BoxedType<label>
{
public:
using BoxedType<label>::BoxedType;
~Integer()
friend Ostream& operator<<(Ostream& os, const Scalar& item)
{
if (verbosity) Info<< "delete Integer: " << value() << nl;
os << item.value();
return os;
}
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);
}
bool Scalar::verbose = true;
// As per
@ -136,7 +86,20 @@ Ostream& printAddr
const UPtrList<T>& list
)
{
return list.printAddresses(os);
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;
}
@ -213,11 +176,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 " << Foam::name(ptr) << nl;
os << "unused " << name(ptr) << nl;
}
}
@ -301,9 +264,9 @@ int main(int argc, char *argv[])
Info<< "DLPtrList: " << llist1 << endl;
verbosity = false;
Scalar::verbose = false;
llist1.clear();
verbosity = true;
Scalar::verbose = true;
}
#endif
@ -381,44 +344,6 @@ 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)
@ -593,7 +518,6 @@ int main(int argc, char *argv[])
print(Info, dynlist1d);
Info<< "addresses:" << nl;
dynlist1d.printAddresses(Info, true);
printAddr(Info, dynlist1d);
PtrList<Scalar> list1d;

View File

@ -1,3 +1,3 @@
Test-PtrListDictionary.cxx
Test-PtrListDictionary.C
EXE = $(FOAM_USER_APPBIN)/Test-PtrListDictionary

View File

@ -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 (verbosity) Info<< "delete Scalar: " << value() << nl;
if (verbose) Info<< "delete Scalar: " << data_ << endl;
}
scalar value() const noexcept { return data_; }
const scalar& value() const noexcept { return data_; }
scalar& value() noexcept { return data_; }
auto clone() const { return autoPtr<Scalar>::New(*this); }
autoPtr<Scalar> clone() const { return autoPtr<Scalar>::New(data_); }
friend Ostream& operator<<(Ostream& os, const Scalar& item)
{
@ -67,6 +67,8 @@ public:
}
};
bool Scalar::verbose = true;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:

View File

@ -91,6 +91,12 @@ 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());

View File

@ -1,3 +1,3 @@
Test-base64Encoding.cxx
Test-base64Encoding.C
EXE = $(FOAM_USER_APPBIN)/Test-base64Encoding

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2025 OpenCFD Ltd.
Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -35,31 +35,25 @@ 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 auto& input = unit.first();
const auto& expected = unit.second();
const string& input = unit.first();
const string& expected = unit.second();
Foam::ocharstream os;
std::ostringstream os;
{
base64Layer b64(os);
b64.write(input.data(), input.size());
base64Layer b64(os);
b64.write(input.data(), input.size());
b64.close();
if (b64.close())
{
// Extra information
// std::cerr<< "closed with pending data" << nl;
}
}
const auto encoded = os.view();
const string encoded = os.str();
Info<< input << nl;
@ -84,7 +78,7 @@ bool test(std::initializer_list<Pair<string>> list)
{
bool good = true;
for (const auto& t : list)
for (const Pair<string>& t : list)
{
good = test(t) && good;
}
@ -97,7 +91,7 @@ bool test(const UList<Pair<string>>& list)
{
bool good = true;
for (const auto& t : list)
for (const Pair<string>& t : list)
{
good = test(t) && good;
}
@ -113,7 +107,7 @@ void testMixed(std::ostream& os, const UList<Pair<string>>& list)
os << "<test-mixed>" << nl;
int i=0;
for (const auto& t : list)
for (const Pair<string>& t : list)
{
const string& input = t.first();

View File

@ -1,3 +1,3 @@
Test-bitSet1.cxx
Test-bitSet1.C
EXE = $(FOAM_USER_APPBIN)/Test-bitSet1

View File

@ -142,9 +142,6 @@ 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
}
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2025 OpenCFD Ltd.
Copyright (C) 2018-2021 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:" << bools.all()
<< " any:" << bools.any()
<< " none:" << bools.none() << nl;
<< " all:" << BitOps::all(bools)
<< " any:" << BitOps::any(bools)
<< " none:" << BitOps::none(bools) << nl;
return Info;
}
@ -137,11 +137,11 @@ inline bool compare
const std::string& expected
)
{
const auto& store = bitset.storage();
const List<unsigned int>& store = bitset.storage();
std::string has;
for (label blocki=0; blocki < bitset.num_blocks(); ++blocki)
for (label blocki=0; blocki < bitset.nBlocks(); ++blocki)
{
has += toString(store[blocki]);
}
@ -194,10 +194,8 @@ int main(int argc, char *argv[])
{
boolList bools = list1.values();
Info<< "===============" << nl;
Info<< "bools: " << flatOutput(bools) << nl;
Info<< " ";
info(bools);
Info<<"===============" << nl;
Info<<"bools: " << flatOutput(bools) << nl;
for (int i : { -10, 0, 8, 15, 32})
{
@ -240,18 +238,17 @@ 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

View File

@ -1,3 +1,3 @@
Test-boolList.cxx
Test-boolList.C
EXE = $(FOAM_USER_APPBIN)/Test-boolList

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020-2025 OpenCFD Ltd.
Copyright (C) 2020-2022 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:" << bools.all()
<< " any:" << bools.any()
<< " none:" << bools.none() << nl;
<< " all:" << BitOps::all(bools)
<< " any:" << BitOps::any(bools)
<< " none:" << BitOps::none(bools) << nl;
return Info;
}

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,3 +1,3 @@
Test-dictionary.cxx
Test-dictionary.C
EXE = $(FOAM_USER_APPBIN)/Test-dictionary

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,3 +1,3 @@
Test-dictionary2.cxx
Test-dictionary2.C
EXE = $(FOAM_USER_APPBIN)/Test-dictionary2

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2025 OpenCFD Ltd.
Copyright (C) 2017-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -47,18 +47,8 @@ void entryInfo(entry* e)
{
if (e)
{
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;
Info<<"added "
<< e->keyword() << ": " << typeid(e).name() << nl;
}
}
@ -210,31 +200,12 @@ 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))
{
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;
entry* e = dict1.add
(
word::printf("entry%d", i),
string("entry" + Foam::name(i))
);
entryInfo(e);
}

View File

@ -1,3 +1,3 @@
Test-dictionaryCopy.cxx
Test-dictionaryCopy.C
EXE = $(FOAM_USER_APPBIN)/Test-dictionaryCopy

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

Some files were not shown because too many files have changed in this diff Show More