Compare commits

..

1 Commits

Author SHA1 Message Date
256dafeea5 ENH: fvMatrix: adding setValues for patch
Speedup in offloading
2025-03-05 09:11:47 +00:00
476 changed files with 5962 additions and 10972 deletions

View File

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

View File

@ -36,12 +36,11 @@ Description
if (adjustTimeStep)
{
scalar maxDeltaTFact = maxCo/(CoNum + StCoNum + SMALL);
scalar deltaTFact =
Foam::min(Foam::min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
scalar deltaTFact = min(min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
runTime.setDeltaT
(
Foam::min
min
(
deltaTFact*runTime.deltaTValue(),
maxDeltaT

View File

@ -1,5 +1,5 @@
if (adjustTimeStep)
{
runTime.setDeltaT(Foam::min(dtChem, maxDeltaT));
runTime.setDeltaT(min(dtChem, maxDeltaT));
Info<< "deltaT = " << runTime.deltaTValue() << endl;
}

View File

@ -54,18 +54,9 @@ if (adjustTimeStep)
runTime.setDeltaT
(
Foam::min
min
(
dt0
* Foam::min
(
Foam::min
(
TFactorFluid,
Foam::min(TFactorFilm, TFactorSolid)
),
1.2
),
dt0*min(min(TFactorFluid, min(TFactorFilm, TFactorSolid)), 1.2),
maxDeltaT
)
);

View File

@ -75,10 +75,8 @@
)
{
rDeltaT =
(
rDeltaT0
* Foam::max(rDeltaT/rDeltaT0, scalar(1) - rDeltaTDampingCoeff)
);
*max(rDeltaT/rDeltaT0, scalar(1) - rDeltaTDampingCoeff);
Info<< "Damped flow time scale min/max = "
<< gMin(1/rDeltaT.primitiveField())

View File

@ -1,7 +1,7 @@
scalar CoNum = -GREAT;
forAll(fluidRegions, regionI)
{
CoNum = Foam::max
CoNum = max
(
compressibleCourantNo
(

View File

@ -31,7 +31,7 @@
);
scalar maxPhiCoNum =
CoNum =
0.5*gMax
(
sumPhi/fluidRegions[regioni].V().field()
@ -41,9 +41,9 @@
(
fvc::surfaceSum(mag(phi1 - phi2))().primitiveField()
/ fluidRegions[regioni].V().field()
)*runTime.deltaTValue();
)*runTime.deltaTValue(),
CoNum = Foam::max(CoNum, Foam::max(maxPhiCoNum, UrCoNum));
CoNum = max(UrCoNum, CoNum);
}
}

View File

@ -2,7 +2,7 @@
forAll(fluidRegions, regioni)
{
CoNum = Foam::max
CoNum = max
(
compressibleCourantNo
(
@ -17,7 +17,7 @@
/*
forAll(porousFluidRegions, porousi)
{
CoNum = Foam::max
CoNum = max
(
compressibleCourantNo
(

View File

@ -47,10 +47,10 @@ if (adjustTimeStep)
runTime.setDeltaT
(
Foam::min
min
(
Foam::min(maxCo/CoNum, maxDi/DiNum)*runTime.deltaTValue(),
Foam::min(runTime.deltaTValue(), maxDeltaT)
min(maxCo/CoNum, maxDi/DiNum)*runTime.deltaTValue(),
min(runTime.deltaTValue(), maxDeltaT)
)
);
Info<< "deltaT = " << runTime.deltaTValue() << endl;

View File

@ -49,17 +49,17 @@ if (adjustTimeStep)
scalar maxDeltaTSolid = maxDi/(DiNum + SMALL);
scalar deltaTFluid =
Foam::min
min
(
Foam::min(maxDeltaTFluid, 1.0 + 0.1*maxDeltaTFluid),
min(maxDeltaTFluid, 1.0 + 0.1*maxDeltaTFluid),
1.2
);
runTime.setDeltaT
(
Foam::min
min
(
Foam::min(deltaTFluid, maxDeltaTSolid)*runTime.deltaTValue(),
min(deltaTFluid, maxDeltaTSolid)*runTime.deltaTValue(),
maxDeltaT
)
);

View File

@ -22,7 +22,7 @@ forAll(solidRegions, i)
tmp<volScalarField> trho = thermo.rho();
const volScalarField& rho = trho();
DiNum = Foam::max
DiNum = max
(
solidRegionDiffNo
(

View File

@ -17,7 +17,7 @@ scalar DiNum = -GREAT;
tmp<volScalarField> trho = thermo.rho();
const volScalarField& rho = trho();
DiNum = Foam::max
DiNum = max
(
solidRegionDiffNo
(

View File

@ -36,16 +36,13 @@ Description
if (adjustTimeStep)
{
const scalar maxDeltaTFact =
Foam::min
(
maxCo/(CoNum + SMALL), maxCo/(surfaceFilm.CourantNumber() + SMALL)
);
min(maxCo/(CoNum + SMALL), maxCo/(surfaceFilm.CourantNumber() + SMALL));
const scalar deltaTFact =
Foam::min(Foam::min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
min(min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
runTime.setDeltaT
(
Foam::min
min
(
deltaTFact*runTime.deltaTValue(),
maxDeltaT

View File

@ -36,14 +36,13 @@ Description
if (adjustTimeStep)
{
scalar maxDeltaTFact =
Foam::min(maxCo/(CoNum + SMALL), maxAlphaCo/(alphaCoNum + SMALL));
min(maxCo/(CoNum + SMALL), maxAlphaCo/(alphaCoNum + SMALL));
scalar deltaTFact =
Foam::min(Foam::min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
scalar deltaTFact = min(min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
runTime.setDeltaT
(
Foam::min
min
(
deltaTFact*runTime.deltaTValue(),
maxDeltaT

View File

@ -36,14 +36,13 @@ Description
if (adjustTimeStep)
{
scalar maxDeltaTFact =
Foam::min(maxCo/(CoNum + SMALL), maxAcousticCo/(acousticCoNum + SMALL));
min(maxCo/(CoNum + SMALL), maxAcousticCo/(acousticCoNum + SMALL));
scalar deltaTFact =
Foam::min(Foam::min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
scalar deltaTFact = min(min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
runTime.setDeltaT
(
Foam::min
min
(
deltaTFact*runTime.deltaTValue(),
maxDeltaT

View File

@ -37,15 +37,11 @@ if (adjustTimeStep)
if (CoNum > SMALL)
{
scalar maxDeltaTFact =
Foam::min
(
maxCo/(CoNum + SMALL),
maxAcousticCo/(acousticCoNum + SMALL)
);
min(maxCo/(CoNum + SMALL), maxAcousticCo/(acousticCoNum + SMALL));
runTime.setDeltaT
(
Foam::min
min
(
maxDeltaTFact*runTime.deltaTValue(),
maxDeltaT

View File

@ -26,12 +26,12 @@ forAll(dgdt, celli)
{
if (dgdt[celli] > 0.0)
{
Sp[celli] -= dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
Su[celli] += dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
Sp[celli] -= dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
Su[celli] += dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
}
else if (dgdt[celli] < 0.0)
{
Sp[celli] += dgdt[celli]/Foam::max(alpha1[celli], 1e-4);
Sp[celli] += dgdt[celli]/max(alpha1[celli], 1e-4);
}
}

View File

@ -26,12 +26,12 @@ forAll(dgdt, celli)
{
if (dgdt[celli] > 0.0)
{
Sp[celli] -= dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
Su[celli] += dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
Sp[celli] -= dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
Su[celli] += dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
}
else if (dgdt[celli] < 0.0)
{
Sp[celli] += dgdt[celli]/Foam::max(alpha1[celli], 1e-4);
Sp[celli] += dgdt[celli]/max(alpha1[celli], 1e-4);
}
}

View File

@ -26,12 +26,12 @@ forAll(dgdt, celli)
{
if (dgdt[celli] > 0.0)
{
Sp[celli] -= dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
Su[celli] += dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
Sp[celli] -= dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
Su[celli] += dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
}
else if (dgdt[celli] < 0.0)
{
Sp[celli] += dgdt[celli]/Foam::max(alpha1[celli], 1e-4);
Sp[celli] += dgdt[celli]/max(alpha1[celli], 1e-4);
}
}

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.
@ -679,7 +679,7 @@ void Foam::radiation::laserDTRM::calculate()
}
}
scalar totalQ = gWeightedSum(mesh_.V(), Q_.primitiveField());
scalar totalQ = gSum(Q_.primitiveFieldRef()*mesh_.V());
Info << "Total energy absorbed [W]: " << totalQ << endl;
if (mesh_.time().writeTime())

View File

@ -36,13 +36,13 @@ Description
if (adjustTimeStep)
{
scalar maxDeltaTFact =
Foam::min
min
(
maxCo/(CoNum + SMALL),
Foam::min
min
(
maxAlphaCo/(alphaCoNum + SMALL),
Foam::min
min
(
maxAlphaDdt/(ddtAlphaNum + SMALL),
maxDi/(DiNum + SMALL)
@ -50,12 +50,11 @@ if (adjustTimeStep)
)
);
scalar deltaTFact =
Foam::min(Foam::min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
scalar deltaTFact = min(min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
runTime.setDeltaT
(
Foam::min
min
(
deltaTFact*runTime.deltaTValue(),
maxDeltaT

View File

@ -8,5 +8,5 @@
Info<< "Max Ur Courant Number = " << UrCoNum << endl;
CoNum = Foam::max(CoNum, UrCoNum);
CoNum = max(CoNum, UrCoNum);
}

View File

@ -8,5 +8,5 @@
Info<< "Max Ur Courant Number = " << UrCoNum << endl;
CoNum = Foam::max(CoNum, UrCoNum);
CoNum = max(CoNum, UrCoNum);
}

View File

@ -51,20 +51,17 @@ Description
//- Mapping of some fundamental and aggregate types to MPI data types
enum class dataTypes : int
{
// Fundamental Types [10]:
Basic_begin,
type_byte = Basic_begin,
type_int16,
// Builtin Types [8]:
DataTypes_begin, //!< Begin builtin types (internal use)
type_byte = DataTypes_begin, // also for char, unsigned char
type_int32,
type_int64,
type_uint16,
type_uint32,
type_uint64,
type_float,
type_double,
type_long_double,
invalid,
Basic_end = invalid
invalid
};
@ -72,19 +69,20 @@ enum class dataTypes : int
// Partial copy from UPstreamTraits.H
//- UPstream data type corresponding to an intrinsic (MPI) type
//- A supported UPstream data type (intrinsic or user-defined)
template<class T>
struct UPstream_mpi_dataType : std::false_type
struct UPstream_base_dataType : std::false_type
{
static constexpr auto datatype_id = dataTypes::invalid;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Specializations of the above,
// each to match the elements of UPstream::dataTypes
// Specializations to match elements of UPstream::dataTypes
#undef defineUPstreamDataTraits
#define defineUPstreamDataTraits(TypeId, Type) \
template<> struct UPstream_mpi_dataType<Type> : std::true_type \
template<> struct UPstream_base_dataType<Type> : std::true_type \
{ \
static constexpr auto datatype_id = dataTypes::TypeId; \
};
@ -92,10 +90,8 @@ struct UPstream_mpi_dataType : std::false_type
defineUPstreamDataTraits(type_byte, char);
defineUPstreamDataTraits(type_byte, unsigned char);
defineUPstreamDataTraits(type_int16, int16_t);
defineUPstreamDataTraits(type_int32, int32_t);
defineUPstreamDataTraits(type_int64, int64_t);
defineUPstreamDataTraits(type_uint16, uint16_t);
defineUPstreamDataTraits(type_uint32, uint32_t);
defineUPstreamDataTraits(type_uint64, uint64_t);
defineUPstreamDataTraits(type_float, float);
@ -113,8 +109,8 @@ struct UPstream_alias_dataType
:
std::bool_constant
<
// Basic MPI type
UPstream_mpi_dataType<std::remove_cv_t<T>>::value ||
// Base type (no alias needed)
UPstream_base_dataType<std::remove_cv_t<T>>::value ||
(
// Or some int 32/64 type to re-map
std::is_integral_v<T>
@ -122,11 +118,15 @@ struct UPstream_alias_dataType
)
>
{
// Is it using the base type? (no alias needed)
static constexpr bool is_base =
UPstream_base_dataType<std::remove_cv_t<T>>::value;
using base = std::conditional_t
<
UPstream_mpi_dataType<std::remove_cv_t<T>>::value,
std::remove_cv_t<T>, // <- using mpi type (no alias)
std::conditional_t // <- using alias
UPstream_base_dataType<std::remove_cv_t<T>>::value, // is_base
std::remove_cv_t<T>,
std::conditional_t
<
(
std::is_integral_v<T>
@ -138,32 +138,12 @@ struct UPstream_alias_dataType
std::conditional_t<std::is_signed_v<T>, int32_t, uint32_t>,
std::conditional_t<std::is_signed_v<T>, int64_t, uint64_t>
>,
char // Fallback is a byte (eg, arbitrary contiguous data)
char // Fallback value (assuming it is contiguous)
>
>;
static constexpr auto datatype_id =
UPstream_mpi_dataType<base>::datatype_id;
};
// Handle int8_t/uint8_t as aliases since 'signed char' etc may be
// ambiguous
//- Map \c int8_t to UPstream::dataTypes::type_byte
template<>
struct UPstream_alias_dataType<int8_t> : std::true_type
{
using base = char;
static constexpr auto datatype_id = dataTypes::type_byte;
};
//- Map \c uint8_t to UPstream::dataTypes::type_byte
template<>
struct UPstream_alias_dataType<uint8_t> : std::true_type
{
using base = unsigned char;
static constexpr auto datatype_id = dataTypes::type_byte;
UPstream_base_dataType<base>::datatype_id;
};
@ -192,31 +172,26 @@ void print(const char* name, bool showLimits = true)
}
// A declared or deduced MPI type, or aliased
if constexpr (UPstream_mpi_dataType<T>::value)
{
std::cout
<< " is_mpi=("
<< int(UPstream_mpi_dataType<T>::datatype_id) << ')';
}
else
{
std::cout << " is_mpi=(null)";
}
std::cout
<< " is_mpi=" << UPstream_base_dataType<T>::value
<< " (" << int(UPstream_base_dataType<T>::datatype_id) << ")";
// Any aliases?
if constexpr (UPstream_alias_dataType<T>::value)
if (UPstream_alias_dataType<T>::value)
{
if constexpr (UPstream_mpi_dataType<T>::value)
if (UPstream_alias_dataType<T>::is_base)
{
std::cout << " alias=base";
std::cout<< " is_base";
}
else
{
std::cout
<< " alias=("
<< int(UPstream_alias_dataType<T>::datatype_id) << ')';
std::cout<< " is_alias ("
<< int(UPstream_alias_dataType<T>::datatype_id) << ")";
}
}
else
{
std::cout<< " no_alias";
}
std::cout<< '\n';
}
@ -242,7 +217,6 @@ int main(int argc, char *argv[])
std::cout << '\n';
print<char>("char");
print<signed char>("signed char");
print<unsigned char>("unsigned char");
print<short>("short");
print<int>("int");

View File

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

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.
@ -74,11 +74,15 @@ Ostream& toString(Ostream& os, const List<char>& list)
void printTokens(Istream& is)
{
label count = 0;
Info<< "stream tokens:" << endl;
for (token tok; tok.read(is); ++count)
token t;
while (is.good())
{
Info<< " : " << tok << endl;
is >> t;
if (t.good())
{
++count;
Info<< "token: " << t << endl;
}
}
Info<< count << " tokens" << endl;
@ -451,12 +455,6 @@ int main(int argc, char *argv[])
"( const char input \"string\" to tokenize )\n"
"List<label> 5(0 1 2 3 4);";
// printTokens
{
ISpanStream is(charInput);
printTokens(is);
}
string stringInput("( string ; input \"string\" to tokenize )");
List<char> listInput

View File

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

View File

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

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2025 OpenCFD Ltd.
Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -35,7 +35,6 @@ Description
#include "FixedList.H"
#include "labelList.H"
#include "vectorList.H"
#include "SubList.H"
#include "ListOps.H"
#include "IFstream.H"
#include "OFstream.H"
@ -201,7 +200,6 @@ int main(int argc, char *argv[])
argList::addBoolOption("order");
argList::addBoolOption("labelList");
argList::addBoolOption("vectorList");
argList::addBoolOption("ulist");
argList args(argc, argv);
@ -263,37 +261,6 @@ int main(int argc, char *argv[])
}
if (args.found("ulist"))
{
using span_type = stdFoam::span<vector>;
using ulist_type = UList<vector>;
ulist_type view1, view2;
span_type span1, span2;
List<vector> list(10, vector::one);
Info<< "List: " << Foam::name(list.data()) << nl;
Info<< "view: " << Foam::name(view1.data()) << nl;
Info<< "span: " << Foam::name(span1.data()) << nl;
view1 = list.slice(4);
span1 = span_type(list.begin(4), list.size()-4);
Info<< "view [4]:" << Foam::name(view1.data()) << nl;
Info<< "span [4]:" << Foam::name(span1.data()) << nl;
view2 = std::move(view1);
span2 = std::move(span1);
Info<< "view old:" << Foam::name(view1.data()) << nl;
Info<< "span old:" << Foam::name(span1.data()) << nl;
Info<< "view [4]:" << Foam::name(view2.data()) << nl;
Info<< "span [4]:" << Foam::name(span2.data()) << nl;
view1 = list.slice(7);
Info<< "view [7]:" << Foam::name(view1.data()) << nl;
}
Info<< nl << "Done" << nl << endl;
return 0;
}

View File

@ -37,40 +37,35 @@ Description
#include "vector.H"
#include "tensor.H"
#include "uLabel.H"
#include "MinMax.H"
#include "Switch.H"
#include "IOstreams.H"
#include "UPstream.H"
#include <functional>
#include <type_traits>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
using namespace Foam;
namespace Foam
{
// Add in some extras from functional
//- Map std::plus to \c UPstream::opCodes::op_sum
template<>
struct UPstream_opType<std::plus<void>> : std::true_type
{
static constexpr auto opcode_id = UPstream::opCodes::op_sum;
};
//- Map 'signed char' to UPstream::dataTypes::type_byte
// Caution with: may be identical to int8_t mapping!!
#if 0
template<>
struct UPstream_alias_dataType<signed char> : std::true_type
{
using base = char;
static constexpr auto datatype_id = UPstream::dataTypes::type_byte;
};
#endif
// Just for debugging
const List<std::string> dataType_names
({
"byte",
"int32",
"int64",
"uint32",
"uint64",
"float",
"double",
"long_double",
"float(2)",
"double(2)",
"float(3)",
"double(3)",
"float(6)",
"double(6)",
"float(9)",
"double(9)"
});
//- Test for pTraits typeName member : default is false
template<class T, class = void>
@ -87,93 +82,24 @@ struct check_has_typeName
std::true_type
{};
} // End namespace Foam
// Possible future change...
// //- A supported UPstream data type (intrinsic or user-defined)
// template<>
// struct UPstream_base_dataType<complex> : std::true_type
// {
// static constexpr auto datatype_id = []()
// {
// if constexpr (sizeof(complex) == 2*sizeof(float))
// return UPstream::dataTypes::type_2float;
// else
// return UPstream::dataTypes::type_2double;
// }();
// };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Just for debugging
static const Foam::List<std::string> dataType_names
({
"byte",
"int16",
"int32",
"int64",
"uint16",
"uint32",
"uint64",
"float",
"double",
"long_double",
"float[3]",
"double[3]",
"float[6]",
"double[6]",
"float[9]",
"double[9]"
});
// Just for debugging
static const Foam::List<std::string> opType_names
({
"op_min",
"op_max",
"op_sum",
"op_prod",
"op_bool_and",
"op_bool_or",
"op_bool_xor",
"op_bit_and",
"op_bit_or",
"op_bit_xor",
"op_replace",
"op_no_op"
});
using namespace Foam;
void printDataTypeId(UPstream::dataTypes datatype_id)
{
if (datatype_id != UPstream::dataTypes::invalid)
{
const int index = int(datatype_id);
if (index < dataType_names.size())
{
Info<< dataType_names[index];
}
else
{
Info<< '(' << index << ')';
}
}
}
void printOpCodeId(UPstream::opCodes opcode_id)
{
if (opcode_id != UPstream::opCodes::invalid)
{
const int index = int(opcode_id);
if (index < opType_names.size())
{
Info<< ':' << opType_names[index].c_str();
}
else
{
Info<< '(' << index << ')';
}
}
else
{
Info<< "(null)";
}
}
template<class T, bool showSize = false>
void printTypeName()
template<class T>
void printTypeName(const bool showSize = false)
{
// Both float and double have pTraits typeName = "scalar"!
if constexpr (std::is_same_v<float, std::remove_cv_t<T>>)
@ -192,13 +118,12 @@ void printTypeName()
{
Info<< typeid(T).name();
}
if constexpr (showSize)
if (showSize)
{
Info<< " (" << sizeof(T) << " bytes)";
}
}
template<class Type, bool UseTypeName = true>
void printPstreamTraits(const std::string_view name = std::string_view())
{
@ -208,111 +133,55 @@ void printPstreamTraits(const std::string_view name = std::string_view())
{
Info<< name << ' ';
}
if constexpr (UseTypeName)
{
printTypeName<Type, true>();
printTypeName<Type>(true);
}
else
{
Info<< typeid(Type).name() << " (" << sizeof(Type) << " bytes)";
}
{
using cmpt = typename Foam::pTraits_cmptType<Type>::type;
if constexpr (!std::is_same_v<Type, cmpt>)
{
Info<< ", cmpt:";
if constexpr (UseTypeName)
{
printTypeName<cmpt, true>();
}
else
{
Info<< typeid(cmpt).name() << " (" << sizeof(cmpt) << " bytes)";
}
}
Info<< typeid(Type).name();
Info<< " (" << sizeof(Type) << " bytes)";
}
Info<< ", cmpt:";
printTypeName<typename Foam::pTraits_cmptType<Type>::type>(true);
Info<< nl
<< " is_contiguous:"
<< is_contiguous<Type>::value;
<< is_contiguous<Type>::value
<< ", is base:"
<< UPstream_base_dataType<Type>::value
<< ", is cmpt:"
<< UPstream_dataType<Type>::value << nl;
if constexpr (UPstream_mpi_dataType<Type>::value)
{
Info<< ", is_mpi=("
<< int(UPstream_mpi_dataType<Type>::datatype_id) << ')';
}
else
{
std::cout << ", is_mpi=(null)";
}
if constexpr (UPstream_user_dataType<Type>::value)
{
Info<< ", is_user=("
<< int(UPstream_user_dataType<Type>::datatype_id) << ')';
}
else
{
std::cout << ", is_user=(null)";
}
if constexpr (UPstream_any_dataType<Type>::value)
{
Info<< ", is_any=("
<< int(UPstream_any_dataType<Type>::datatype_id) << ')';
}
else
{
std::cout << ", is_any=(null)";
}
Info<< "is base:"
<< UPstream_base_dataType<Type>::value
<< " (type:" << int(UPstream_base_dataType<Type>::datatype_id)
<< ") is alias:" << UPstream_alias_dataType<Type>::value
<< " (type:" << int(UPstream_alias_dataType<Type>::datatype_id)
<< ")" << nl;
// Any aliases?
if constexpr
(
UPstream_alias_dataType<Type>::value
&& !UPstream_mpi_dataType<Type>::value
)
{
Info<< ", alias=("
<< int(UPstream_alias_dataType<Type>::datatype_id) << ')';
}
Info<< " base-type:" << int(UPstream_basic_dataType<Type>::datatype_id)
<< " data-type:" << int(UPstream_dataType<Type>::datatype_id)
<< nl;
{
int index = int(UPstream_base_dataType<Type>::datatype_id);
Info<< "datatype: " << index;
if constexpr (UPstream_basic_dataType<Type>::value)
{
Info<< " base-type=";
printDataTypeId(UPstream_basic_dataType<Type>::datatype_id);
}
else if constexpr (UPstream_dataType<Type>::value)
{
Info<< " data-type=";
printDataTypeId(UPstream_dataType<Type>::datatype_id);
if (index < dataType_names.size())
{
Info<< ' ' << dataType_names[index];
}
Info<< nl;
}
{
// Use element or component type (or byte-wise) for data type
using base = typename UPstream_dataType<Type>::base;
constexpr auto datatype = UPstream_dataType<Type>::datatype_id;
Info<< " : ";
if constexpr (UseTypeName)
{
printTypeName<base, true>();
}
else
{
Info<< typeid(base).name() << " (" << sizeof(base) << " bytes)";
}
Info<< " cmpt-type=";
printDataTypeId(UPstream_dataType<Type>::datatype_id);
Info<< " count=" << UPstream_dataType<Type>::size(1);
Info<< nl;
Info<< "datatype => ";
printTypeName<base>();
Info<< " (" << sizeof(Type)/sizeof(base) << " elems)" << nl
<< "datatype: " << static_cast<int>(datatype) << nl;
}
}
@ -321,44 +190,15 @@ template<class BinaryOp>
void printOpCodeTraits(BinaryOp bop, std::string_view name)
{
Info<< "op: " << name << ' ';
printOpCodeId(UPstream_opType<BinaryOp>::opcode_id);
Info<< nl;
}
template<class DataType, class BinaryOp>
void printOpCodeTraits(BinaryOp bop, std::string_view name)
{
Info<< "op: " << name << ' ';
printOpCodeId(UPstream_opType<BinaryOp>::opcode_id);
if constexpr (!std::is_void_v<DataType>)
if constexpr (UPstream_opType<BinaryOp>::value)
{
if constexpr (UPstream_basic_dataType<DataType>::value)
{
Info<< " [supported type]";
}
else
{
Info<< " [disabled]";
}
Info<< "supported";
}
Info<< nl;
}
template<class DataType, class BinaryOp>
void print_data_opType(BinaryOp bop, std::string_view name)
{
Info<< "op: " << name << ' ';
printOpCodeId(UPstream_data_opType<BinaryOp, DataType>::opcode_id);
const bool ok = UPstream_data_opType<BinaryOp, DataType>::value;
Info<< " okay=" << ok << nl;
else
{
Info<< "unknown";
}
Info<< ": " << int(UPstream_opType<BinaryOp>::opcode_id) << nl;
}
@ -370,16 +210,6 @@ int main()
printPstreamTraits<bool>();
printPstreamTraits<label>();
printPstreamTraits<char, false>("<char>");
printPstreamTraits<signed char, false>("<signed char>");
printPstreamTraits<unsigned char, false>("<unsigned char>");
printPstreamTraits<int8_t, false>("<int8_t>");
printPstreamTraits<uint8_t, false>("<uint8_t>");
printPstreamTraits<int16_t, false>("<int16_t>");
printPstreamTraits<uint16_t, false>("<uint16_t>");
printPstreamTraits<int>("<int>");
printPstreamTraits<long>("<long>");
printPstreamTraits<unsigned>("<unsigned>");
@ -428,35 +258,6 @@ int main()
printOpCodeTraits(bitAndOp<unsigned>{}, "bitAnd<unsigned>");
printOpCodeTraits(bitOrOp<unsigned>{}, "bitOr<unsigned>");
printOpCodeTraits<vector>(sumOp<vector>{}, "sum");
printOpCodeTraits(sumOp<scalarMinMax>{}, "sum");
printOpCodeTraits(std::plus<>{}, "sum");
printOpCodeTraits<bool>(std::plus<>{}, "sum");
printOpCodeTraits<vector>(std::plus<>{}, "sum");
// Expect success
Info<< nl << "expect success" << nl;
print_data_opType<vector>(maxOp<scalar>(), "maxOp(scalar)");
print_data_opType<unsigned>(bitOrOp<unsigned>(), "bitOrOp(unsigned)");
print_data_opType<uint8_t>(bitOrOp<uint8_t>(), "bitOrOp(uint8_t)");
print_data_opType<uint16_t>(bitOrOp<uint16_t>(), "bitOrOp(uint16_t)");
// Even allow signed integrals
print_data_opType<int>(bitOrOp<int>(), "bitOrOp(int)");
print_data_opType<int8_t>(bitOrOp<int8_t>(), "bitOrOp(int8_t)");
// Failure - supported op, unsupported data type.
Info<< nl << "expect failure" << nl;
print_data_opType<bool>(maxOp<scalar>(), "maxOp(scalar, bool)");
print_data_opType<bool>(bitOrOp<unsigned>(), "bitOrOp(unsigned, bool)");
// False positives. Failure - supported op, unsupported data type.
Info<< nl << "false positives" << nl;
print_data_opType<void>(maxOp<bool>(), "maxOp(bool, void)");
print_data_opType<float>(bitOrOp<unsigned>(), "bitOrOp(unsigned, float)");
Info<< nl << "End\n" << endl;
return 0;

View File

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

View File

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

View File

@ -1,282 +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/>.
Application
Test-gather-scatter1
Description
Simple tests for gather/scatter
\*---------------------------------------------------------------------------*/
#include "List.H"
#include "argList.H"
#include "Time.H"
#include "Pstream.H"
#include "IOstreams.H"
using namespace Foam;
//- Ostensibly the inverse of gatherList, but actually works like
//- a broadcast that skips overwriting the local rank!
template<class T>
void real_scatterList
(
//! [in,out]
UList<T>& values,
[[maybe_unused]] const int tag = UPstream::msgType(),
const int communicator = UPstream::worldComm
)
{
if (!UPstream::is_parallel(communicator))
{
// Nothing to do
return;
}
else if constexpr (is_contiguous_v<T>)
{
// This part is a real in-place scatter:
// In-place scatter for contiguous types - one element per rank
// - on master:
// * send pointer is the full list
// * recv pointer is first destination
// - on rank:
// * send pointer is irrelevant
// * recv pointer is destination in the list
//
// So can simply use identical pointers for send/recv
auto* ptr = values.data() + UPstream::myProcNo(communicator);
UPstream::mpiScatter(ptr, ptr, 1, communicator);
}
else
{
// Communication order
const auto& commOrder = UPstream::whichCommunication(communicator);
Pstream::scatterList_algorithm(commOrder, values, tag, communicator);
}
}
//- gatherList_algorithm, but with specific communication style
template<class T>
void gatherList_algo
(
const bool linear,
//! [in,out]
UList<T>& values,
[[maybe_unused]] const int tag = UPstream::msgType(),
const int communicator = UPstream::worldComm
)
{
if (UPstream::is_parallel(communicator))
{
Pstream::gatherList_algorithm
(
UPstream::whichCommunication(communicator, linear),
values,
tag,
communicator
);
}
}
//- scatterList_algorithm, but with specific communication style
template<class T>
void scatterList_algo
(
const bool linear,
//! [in,out]
UList<T>& values,
[[maybe_unused]] const int tag = UPstream::msgType(),
const int communicator = UPstream::worldComm
)
{
if (UPstream::is_parallel(communicator))
{
Pstream::scatterList_algorithm
(
UPstream::whichCommunication(communicator, linear),
values,
tag,
communicator
);
}
}
// Perform tests
template<class ListType, class ResetCode>
void doTest(ResetCode reset)
{
ListType values;
reset(values);
Pout<< nl << "before:" << flatOutput(values) << endl;
Pstream::broadcastList(values);
Pout<< "broadcast:" << flatOutput(values) << endl;
reset(values);
Pout<< nl << "before:" << flatOutput(values) << endl;
Pstream::scatterList(values);
Pout<< "scatter:" << flatOutput(values) << endl;
reset(values);
Pout<< "before:" << flatOutput(values) << endl;
real_scatterList(values);
Pout<< "inplace:" << flatOutput(values) << endl;
using control = std::pair<int, int>;
const char* algoType[2] = { "tree", "linear" };
for
(
auto [gather, scatter] :
{
control{0, 0},
control{1, 1},
control{0, 1},
control{1, 0}
}
)
{
reset(values);
Pout<< nl << "before:" << flatOutput(values) << endl;
gatherList_algo(gather, values);
Pout<< "gather[" << algoType[gather] << "]:"
<< flatOutput(values) << endl;
scatterList_algo(scatter, values);
Pout<< "scatter[" << algoType[scatter] << "]:"
<< flatOutput(values) << endl;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
argList::noCheckProcessorDirectories();
argList::addVerboseOption("increase UPstream::debug level");
#include "setRootCase.H"
const int optVerbose = args.verbose();
if (optVerbose)
{
UPstream::debug = optVerbose;
}
Pout<< nl << "Test contiguous" << endl;
{
doTest<labelList>
(
[](auto& values){
if (UPstream::master())
{
values = identity(UPstream::nProcs());
}
else
{
values.resize(UPstream::nProcs());
values = -1;
values[UPstream::myProcNo()] = 10 * UPstream::myProcNo();
}
}
);
}
Pout<< nl << "Test non-contiguous" << endl;
{
doTest<wordList>
(
[](auto& values) {
values.resize(UPstream::nProcs());
if (UPstream::master())
{
forAll(values, i)
{
values[i] = "proc" + Foam::name(i);
}
}
else
{
values = "none";
values[UPstream::myProcNo()] =
"_" + Foam::name(UPstream::myProcNo());
}
}
);
}
// Test dummy broadcast as well
Pout<< nl << "Test broadcastList" << endl;
{
wordList list;
Pout<< nl << "before: " << flatOutput(list) << endl;
Pstream::broadcastList(list);
Pout<< "-> " << flatOutput(list) << endl;
}
// Test in-place reduce
Pout<< nl << "Test in-place reduce" << endl;
{
FixedList<label, 6> list;
list = UPstream::myProcNo();
Pout<< nl << "before: " << flatOutput(list) << endl;
UPstream::mpiReduce
(
list.data(),
list.size(),
UPstream::opCodes::op_sum,
UPstream::worldComm
);
Pout<< "-> " << flatOutput(list) << endl;
}
Info<< nl << "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -345,8 +345,8 @@ static void reportOffsets(const globalIndex& gi)
UPstream::broadcast
(
allOffsets.data(),
allOffsets.size(),
allOffsets.data_bytes(),
allOffsets.size_bytes(),
interNodeComm
);
}
@ -508,7 +508,7 @@ int main(int argc, char *argv[])
#include "setRootCase.H"
const bool useLocalComms = UPstream::usingNodeComms(UPstream::worldComm);
const bool useLocalComms = UPstream::usingNodeComms();
bool useWindow = args.found("window");
bool useBuiltin = args.found("builtin");

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -115,13 +115,6 @@ int main(int argc, char *argv[])
);
if (UPstream::parRun())
{
const auto& procs = UPstream::localNode_parentProcs();
Perr<< "local processors: [" << procs.min()
<< ".." << procs.max() << ']' << endl;
}
// Generate the graph
if (UPstream::master(UPstream::worldComm))
{

View File

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

View File

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

View File

@ -1,354 +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/>.
Application
Test-one-sided1
Description
Simple test of one-sided communication
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "IPstream.H"
#include "OPstream.H"
#include "SubField.H"
#include "vector.H"
#include "IOstreams.H"
using namespace Foam;
template<class T>
Ostream& printSpanInfo(Ostream& os, const UList<T>& span)
{
os << "addr=" << Foam::name(span.cdata())
<< " size= " << span.size();
return os;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
argList::noCheckProcessorDirectories();
argList::addVerboseOption();
argList::addBoolOption("no-shared", "disable shared memory tests");
argList::addBoolOption("no-sleep", "disable sleep for async test");
#include "setRootCase.H"
const bool with_shared = !args.found("no-shared");
const bool with_sleep = !args.found("no-sleep");
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< nl
<< "nProcs = " << UPstream::nProcs()
<< " with " << UPstream::nComms() << " predefined comm(s)" << nl;
if (!UPstream::parRun())
{
Info<< "###############" << nl
<< "Not running in parallel. Stopping now" << nl
<< "###############" << endl;
return 1;
}
const auto myProci = UPstream::myProcNo();
const auto numProc = UPstream::nProcs();
// Make some windows
Field<label> buffer(10 + myProci);
buffer = myProci;
Pout<< "input: " << flatOutput(buffer) << endl;
UPstream::Window win;
win.create(buffer, UPstream::worldComm);
// Pass 1
// - grab things from sub-ranks
if (UPstream::master())
{
win.lock_all(true);
win.get
(
buffer.slice(4, 2),
1, // target_rank
2 // target_disp
);
win.unlock_all();
}
Pout<< "output: " << flatOutput(buffer) << endl;
// Pass 2:
// accumulate into master
if (UPstream::is_subrank())
{
win.lock(0);
win.put
(
UPstream::opCodes::op_sum,
buffer.slice(2, 4),
UPstream::masterNo(),
2 // target_disp
);
win.unlock(0);
}
Pout<< "updated: " << flatOutput(buffer) << endl;
// Pass 3:
// Update some values - something very asynchronous
if (UPstream::is_subrank())
{
if (with_sleep)
{
if (UPstream::myProcNo() % 3)
{
Foam::sleep(3);
}
else
{
Foam::sleep(1);
}
}
buffer *= 10;
forAll(buffer, i)
{
buffer[i] *= 1 + (i % 3);
}
}
// Needs a process sync, otherwise master fetches old values
UPstream::barrier(UPstream::worldComm);
label lastValue(-1);
if (UPstream::master())
{
win.lock_all(true);
for (const auto proci : UPstream::subProcs())
{
win.fetch_and_op
(
UPstream::opCodes::op_sum,
buffer[0],
lastValue,
proci,
2 // target_disp
);
}
// Force changes to occur
win.flush_all();
win.unlock_all();
}
Pout<< "last-value : " << lastValue << nl
<< "final : " << flatOutput(buffer) << endl;
labelList allUpdates;
if (UPstream::master())
{
allUpdates.resize(UPstream::nProcs(), -10);
win.lock_all(true);
for (const auto proci : UPstream::subProcs())
{
win.get_value
(
allUpdates[proci],
proci,
2 // target_disp
);
}
win.flush_all();
win.unlock_all();
}
Info<< "gets: " << flatOutput(allUpdates) << endl;
// This should fail (runtime)
#if 0
if (UPstream::master())
{
labelPair value1(-1, -1);
win.lock_all(true);
for (const auto proci : UPstream::subProcs())
{
win.fetch_and_op
(
UPstream::opCodes::op_sum,
value1,
lastValue,
proci,
8 // target_disp
);
}
win.unlock_all();
}
#endif
// Last thing before closing out
// replace values. Not very efficient...
// Persistent data to move onto target:
const label newValue(333);
const label multiplier(-3);
if (UPstream::master())
{
win.lock_all(true);
for (const auto proci : UPstream::subProcs())
{
win.fetch_and_op
(
UPstream::opCodes::op_replace,
newValue,
lastValue,
proci, // target_rank
3 // target_disp
);
win.put_value
(
UPstream::opCodes::op_prod,
multiplier,
proci, // target_rank
5 // target_disp
);
}
win.unlock_all();
}
win.close(); // process collective
Pout<< "modified: " << flatOutput(buffer) << endl;
if (with_shared)
{
// Make some shared window
UList<label> newBuffer;
{
label localLen(0);
if
(
(myProci == 3)
|| (myProci == numProc-2)
)
{
localLen = 0;
}
else
{
localLen = (10 + UPstream::myProcNo());
}
// Just to prove that we can shallow copy the view...
newBuffer =
win.allocate_shared<label>(localLen, UPstream::worldComm);
}
newBuffer = UPstream::myProcNo();
Pout<< "Shared: " << flatOutput(newBuffer) << endl;
{
UList<label> local = win.view<label>();
Pout<< "local win: ";
printSpanInfo(Pout, local) << endl;
}
Pout<< "Query rank1" << endl;
{
// UPtrList<UList<label>> totalList(UPstream::nProcs());
//
// totalList.set(0, &newBuffer);
const label* ptr0 = nullptr;
{
UList<label> buf = win.view_shared<label>(0);
ptr0 = buf.cdata();
Pout<< "addr 0 = " << Foam::name(ptr0)
<< " diff = " << label(0)
<< " + " << buf.size() << endl;
}
// UList<label> other = win.global_view<label>();
for (const auto proci : UPstream::subProcs())
{
UList<label> other = win.view_shared<label>(proci);
const label* ptr = other.cdata();
Pout<< "addr " << proci << " = "
<< Foam::name(ptr)
<< " diff = " << label(ptr - ptr0)
<< " + " << other.size() << endl;
// totalList.set(proci, &other);
}
}
win.close();
}
// Since close() is ignored on null window,
// can call it an arbitrary number of times
win.close();
win.close();
win.close();
Info<< "\nEnd\n" << endl;
return 0;
}
// ************************************************************************* //

View File

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

View File

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

View File

@ -35,8 +35,11 @@ Description
#include "Switch.H"
#include "stringOps.H"
#include "regExp.H"
#include "SubStrings.H"
#include "regExpCxx.H"
#ifndef _WIN32
#include "regExpPosix.H"
#endif
using namespace Foam;
@ -86,6 +89,20 @@ static Ostream& operator<<(Ostream& os, const regExpCxx::results_type& sm)
}
// Simple output of match groups
#ifndef _WIN32
static Ostream& operator<<(Ostream& os, const regExpPosix::results_type& sm)
{
for (std::smatch::size_type i = 1; i < sm.size(); ++i)
{
os << " " << sm.str(i);
}
return os;
}
#endif
template<class RegexType>
void generalTests()
{
@ -282,6 +299,10 @@ int main(int argc, char *argv[])
argList::noFunctionObjects();
argList::noParallel();
argList::addBoolOption("cxx", "Test C++11 regular expressions");
#ifndef _WIN32
argList::addBoolOption("posix", "Test POSIX regular expressions");
#endif
argList::addOption
(
"regex",
@ -300,16 +321,34 @@ int main(int argc, char *argv[])
#ifdef _GLIBCXX_RELEASE
Info<< "_GLIBCXX_RELEASE = " << (_GLIBCXX_RELEASE) << nl;
#endif
#ifdef __clang_major__
Info<< "__clang_major__ = " << (__clang_major__) << nl;
if constexpr (std::is_same_v<regExp, regExpCxx>)
{
Info<< "Foam::regExp uses C++11 regex" << nl;
}
#ifndef _WIN32
if constexpr (std::is_same_v<regExp, regExpPosix>)
{
Info<< "Foam::regExp uses POSIX regex" << nl;
}
#endif
Info<< "sizeof std::regex: " << sizeof(std::regex) << nl;
Info<< "sizeof regExp: " << sizeof(Foam::regExp) << nl;
Info<< "sizeof regex C++11: " << sizeof(regExpCxx) << nl;
#ifndef _WIN32
Info<< "sizeof regex POSIX: " << sizeof(regExpPosix) << nl;
#endif
Info<< "sizeof word: " << sizeof(Foam::word) << nl;
Info<< "sizeof wordRe: " << sizeof(Foam::wordRe) << nl;
Info<< "sizeof keyType: " << sizeof(Foam::keyType) << nl;
if (!args.count({"cxx", "posix"}))
{
args.setOption("cxx");
Info<< "Assuming -cxx as default" << nl;
}
Info<< nl;
if (args.found("regex"))
{
std::string expr(args["regex"]);
@ -320,15 +359,31 @@ int main(int argc, char *argv[])
<< "quotemeta: "
<< stringOps::quotemeta(expr, regExpCxx::meta()) << nl
<< nl;
#ifndef _WIN32
Info<< "(posix):" << nl
<< "meta : " << Switch(regExpPosix::is_meta(expr)) << nl
<< "quotemeta: "
<< stringOps::quotemeta(expr, regExpPosix::meta()) << nl
<< nl;
#endif
Info<< nl;
}
else if (args.size() < 2)
{
Info<< "No test files specified .. restrict to general tests" << nl;
if (args.found("cxx"))
{
generalTests<regExpCxx>();
}
#ifndef _WIN32
if (args.found("posix"))
{
generalTests<regExpPosix>();
}
#endif
}
for (label argi = 1; argi < args.size(); ++argi)
@ -339,9 +394,17 @@ int main(int argc, char *argv[])
Info<< "Test expressions:" << tests << endl;
IOobject::writeDivider(Info) << endl;
if (args.found("cxx"))
{
testExpressions<regExpCxx>(tests);
}
#ifndef _WIN32
if (args.found("posix"))
{
testExpressions<regExpPosix>(tests);
}
#endif
}
Info<< "\nDone" << nl << endl;

View File

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

View File

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

View File

@ -89,7 +89,7 @@ int main(int argc, char *argv[])
inputType in1("move-construct-from");
Info<<"move construct from " << in1.size() << nl;
Info<<"move construct from " << in1.length() << nl;
outputType out1(std::move(in1));
@ -100,7 +100,7 @@ int main(int argc, char *argv[])
out1 = "some-text-rubbish";
out1.resize(10);
Info<<"move assign from " << in1.size() << nl;
Info<<"move assign from " << in1.length() << nl;
out1 = std::move(in1);
@ -329,7 +329,7 @@ int main(int argc, char *argv[])
string s2(s.expand());
cout<< "output string with " << s2.size() << " characters\n";
cout<< "output string with " << s2.length() << " characters\n";
cout<< "ostream<< >" << s2 << "<\n";
Info<< "Ostream<< >" << s2 << "<\n";
Info<< "hash:" << hex << string::hasher()(s2) << dec << endl;

View File

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

View File

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

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2025 OpenCFD Ltd.
Copyright (C) 2017-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -43,19 +43,18 @@ template<class StringType>
void printSubStrings
(
const StringType& str,
const SubStrings& split
const SubStrings<StringType>& split
)
{
Info<< "string {" << str.size() << " chars} = " << str << nl
<< split.size() << " elements {" << split.length() << " chars}"
<< nl;
for (unsigned i = 0; i < split.size(); ++i)
unsigned i = 0;
for (const auto s : split)
{
const auto& s = split[i];
Info<< "[" << i << "] {" << s.length() << " chars} = "
<< split.view(i) << " == " << s.str()
<< nl;
Info<< "[" << i++ << "] {" << s.length() << " chars} = "
<< s.str() << nl;
}
}

View File

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

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2025 OpenCFD Ltd.
Copyright (C) 2018-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -32,10 +32,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "vectorField.H"
#include "boolVector.H"
#include "labelVector.H"
#include "IOstreams.H"
#include "FixedList.H"
#include "Random.H"
#include <algorithm>
#include <random>
@ -128,42 +125,6 @@ void testNormalise(Field<Type>& fld)
}
// Transcribe vectorspace information into a FixedList
template<class Type>
void testTranscribe(Type& input)
{
if constexpr
(
is_vectorspace_v<Type>
&& std::is_floating_point_v<typename pTraits_cmptType<Type>::type>
)
{
constexpr auto nCmpts = pTraits_nComponents<Type>::value;
using cmpt = typename pTraits_cmptType<Type>::type;
FixedList<cmpt, nCmpts+1> values;
values.back() = 100; // some additional data
VectorSpaceOps<nCmpts>::copy_n(input.cdata(), values.data());
Info<< "Transcribed " << input << " => " << values << nl;
for (auto& val : values)
{
val *= -1;
}
VectorSpaceOps<nCmpts>::copy_n(values.cdata(), input.data());
Info<< " copied back (-1) as " << input
<< " from " << values << nl;
}
else
{
Info<< "Did not transcribe " << input << nl;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
@ -279,16 +240,6 @@ int main(int argc, char *argv[])
testNormalise(vfld2);
}
Info<< nl
<< "Test transcribing components" << nl;
{
vector vec1(1.1, 2.2, 3.3);
testTranscribe(vec1);
labelVector vec2(10, 20, 30);
testTranscribe(vec2);
}
Info<< "\nEnd\n" << nl;
return 0;

View File

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

View File

@ -108,13 +108,13 @@ Input
if (numNbrs == 1)
{
//if (pointSetPtr) pointSetPtr->insert(mesh.edges()[meshEdgei]);
labelTyp = Foam::max(labelTyp, TopoType::OPEN);
labelTyp = max(labelTyp, TopoType::OPEN);
}
else if (numNbrs == 0 || numNbrs > 2)
{
if (pointSetPtr) pointSetPtr->insert(mesh.edges()[meshEdgei]);
if (badEdgesPtr) badEdgesPtr->insert(edgei);
labelTyp = Foam::max(labelTyp, TopoType::ILLEGAL);
labelTyp = max(labelTyp, TopoType::ILLEGAL);
}
}
reduce(labelTyp, maxOp<label>());

View File

@ -368,8 +368,7 @@ void subsetTopoSets
Info<< "Subsetting " << set.type() << ' ' << set.name() << endl;
labelHashSet subset;
subset.reserve(Foam::min(set.size(), map.size()));
labelHashSet subset(2*min(set.size(), map.size()));
// Map the data
forAll(map, i)

View File

@ -142,26 +142,26 @@ scalar getEdgeStats(const primitiveMesh& mesh, const direction excludeCmpt)
if (mag(eVec & x) > 1-edgeTol)
{
minX = Foam::min(minX, eMag);
maxX = Foam::max(maxX, eMag);
minX = min(minX, eMag);
maxX = max(maxX, eMag);
nX++;
}
else if (mag(eVec & y) > 1-edgeTol)
{
minY = Foam::min(minY, eMag);
maxY = Foam::max(maxY, eMag);
minY = min(minY, eMag);
maxY = max(maxY, eMag);
nY++;
}
else if (mag(eVec & z) > 1-edgeTol)
{
minZ = Foam::min(minZ, eMag);
maxZ = Foam::max(maxZ, eMag);
minZ = min(minZ, eMag);
maxZ = max(maxZ, eMag);
nZ++;
}
else
{
minOther = Foam::min(minOther, eMag);
maxOther = Foam::max(maxOther, eMag);
minOther = min(minOther, eMag);
maxOther = max(maxOther, eMag);
}
}
@ -179,19 +179,19 @@ scalar getEdgeStats(const primitiveMesh& mesh, const direction excludeCmpt)
if (excludeCmpt == 0)
{
return Foam::min(minY, Foam::min(minZ, minOther));
return min(minY, min(minZ, minOther));
}
else if (excludeCmpt == 1)
{
return Foam::min(minX, Foam::min(minZ, minOther));
return min(minX, min(minZ, minOther));
}
else if (excludeCmpt == 2)
{
return Foam::min(minX, Foam::min(minY, minOther));
return min(minX, min(minY, minOther));
}
else
{
return Foam::min(minX, Foam::min(minY, Foam::min(minZ, minOther)));
return min(minX, min(minY, min(minZ, minOther)));
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2025 OpenCFD Ltd.
Copyright (C) 2019-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -49,7 +49,7 @@ Description
#include <cstdio>
#include "scalar.H"
#include "SpanStream.H"
#include "StringStream.H"
#include "argList.H"
#include "Time.H"
@ -57,23 +57,25 @@ Description
#include "emptyPolyPatch.H"
#include "preservePatchTypes.H"
#include "cellShape.H"
#include "SLList.H"
#include "SLPtrList.H"
// Flex may use register, which is deprecated and incompatible with C++17
#pragma clang diagnostic ignored "-Wdeprecated-register"
using namespace Foam;
DynamicList<point> dynPoints;
DynamicList<label> dynPointMap;
SLList<point> slPoints;
SLList<label> slPointMap;
label maxNodei = 0;
DynamicList<labelList> dynCellLabels;
DynamicList<label> dynCellMap;
DynamicList<label> dynCellType;
SLPtrList<labelList> slCellLabels;
SLList<label> slCellMap;
SLList<label> slCellType;
label maxCelli = 0;
// Per patch index, the cell/face pairs
PtrList<DynamicList<labelPair>> patchCellFaces;
PtrList<SLList<label>> slPatchCells;
PtrList<SLList<label>> slPatchCellFaces;
// Cell types
Map<word> cellTypes;
@ -124,18 +126,22 @@ elementType ^{space}"TYPE"{cspace}
%%
%{
labelList labels(8);
%}
/* ------------------------------------------------------------------------- *\
------ Start Lexing ------
\* ------------------------------------------------------------------------- */
{node}{label}{cspace}{x}{cspace}{y}{cspace}{z}{space}\n {
ISpanStream is(YYText());
IStringStream nodeStream(YYText());
char tag, c;
label nodei;
point& node = dynPoints.emplace_back();
is
>> tag // skip 'N'
point node;
nodeStream
>> tag
>> c >> nodei
>> c >> node.x()
>> c >> node.y()
@ -143,18 +149,17 @@ elementType ^{space}"TYPE"{cspace}
if (nodei > maxNodei) maxNodei = nodei;
dynPointMap.push_back(nodei);
slPointMap.append(nodei);
slPoints.append(node);
}
{element}{label}{cspace}{label}{cspace}{label}{cspace}{label}{cspace}{label}{cspace}{label}{cspace}{label}{cspace}{label}{cspace}{label}{space}\n {
ISpanStream is(YYText());
IStringStream elementStream(YYText());
char tag, c;
label celli;
labelList& labels = dynCellLabels.emplace_back(8);
is
>> tag >> tag // skip 'EN'
elementStream
>> tag >> tag
>> c >> celli
>> c >> labels[0]
>> c >> labels[1]
@ -167,50 +172,66 @@ elementType ^{space}"TYPE"{cspace}
if (celli > maxCelli) maxCelli = celli;
dynCellMap.push_back(celli);
dynCellType.push_back(currentTypei);
slCellMap.append(celli);
slCellLabels.append(new labelList(labels));
slCellType.append(currentTypei);
}
{bface}{label}{cspace}{label}{cspace}{identifier}{cspace}{integer}{cspace}{value}{space}\n {
ISpanStream is(YYText());
IStringStream bfaceStream(YYText());
char tag, c;
label elementi, facei;
label elementi;
label facei;
scalar indexValue, unknown;
is
>> tag >> tag >> tag // skip 'SFE'
bfaceStream
>> tag >> tag >> tag
>> c >> elementi
>> c >> facei
>> c >> tag >> tag >> tag >> tag
>> c >> unknown
>> c >> indexValue;
const label patchi = label(indexValue);
label patchi = label(indexValue);
if (patchCellFaces.size() < patchi)
if (patchi > slPatchCells.size())
{
label i = patchCellFaces.size();
slPatchCells.setSize(patchi);
patchCellFaces.resize(patchi);
for (; i < patchi; ++i)
forAll(slPatchCells, i)
{
patchCellFaces.try_emplace(i);
if (!slPatchCells.set(i))
{
slPatchCells.set(i, new SLList<label>);
}
}
}
patchCellFaces[patchi-1].emplace_back(elementi, facei);
if (patchi > slPatchCellFaces.size())
{
slPatchCellFaces.setSize(patchi);
forAll(slPatchCells, i)
{
if (!slPatchCellFaces.set(i))
{
slPatchCellFaces.set(i, new SLList<label>);
}
}
}
slPatchCells[patchi-1].append(elementi);
slPatchCellFaces[patchi-1].append(facei);
}
{elementTypeName}{label}{cspace}{identifier}{space}\n {
ISpanStream is(YYText());
IStringStream elementStream(YYText());
char tag,c;
label cellTypei;
word cellTypeName;
is
elementStream
>> tag >> tag // skip 'ET'
>> c >> cellTypei
>> c >> cellTypeName;
@ -223,11 +244,10 @@ elementType ^{space}"TYPE"{cspace}
{elementType}{label}{space}\n {
ISpanStream is(YYText());
IStringStream elementStream(YYText());
char tag,c;
label cellTypei;
is
elementStream
>> tag >> tag >> tag >> tag // skip 'TYPE'
>> c >> cellTypei;
@ -261,8 +281,10 @@ label findFace(const polyMesh& mesh, const face& f)
{
const labelList& pFaces = mesh.pointFaces()[f[0]];
for (const label facei : pFaces)
forAll(pFaces, i)
{
label facei = pFaces[i];
if (mesh.faces()[facei] == f)
{
return facei;
@ -301,8 +323,7 @@ int main(int argc, char *argv[])
FatalError.exit();
}
// Actually uses default=0 to skip unnecessary scaling by factor 1.
const scalar scaleFactor = args.getOrDefault<scalar>("scale", 0);
const scalar scaleFactor = args.getOrDefault<scalar>("scale", 1);
#include "createTime.H"
@ -323,32 +344,32 @@ int main(int argc, char *argv[])
Info<< "Creating points" << endl;
pointField points(std::move(dynPoints));
pointField points(slPoints.size());
// Scale points by the given scale factor
if (scaleFactor > 0)
label i = 0;
for (const point& pt : slPoints)
{
points *= scaleFactor;
// Scale points for the given scale factor
points[i++] = scaleFactor * pt;
}
labelList pointMap(maxNodei+1);
i = 0;
for (const label pointi : slPointMap)
{
label i = 0;
for (const label pointi : dynPointMap)
{
pointMap[pointi] = i++;
}
pointMap[pointi] = i++;
}
Info<< "Creating cells" << endl;
labelList cellMap(maxCelli+1);
i = 0;
for (const label celli : slCellMap)
{
label i = 0;
for (const label celli : dynCellMap)
{
cellMap[celli] = i++;
}
cellMap[celli] = i++;
}
@ -357,15 +378,15 @@ int main(int argc, char *argv[])
const cellModel& pyr = cellModel::ref(cellModel::PYR);
const cellModel& tet = cellModel::ref(cellModel::TET);
FixedList<label, 8> labelsHex;
FixedList<label, 6> labelsPrism;
FixedList<label, 5> labelsPyramid;
FixedList<label, 4> labelsTet;
labelList labelsHex(8);
labelList labelsPrism(6);
labelList labelsPyramid(5);
labelList labelsTet(4);
cellShapeList cellShapes(dynCellLabels.size());
cellShapeList cellShapes(slCellLabels.size());
label nCells = 0;
for (const labelList& labels : dynCellLabels)
for (const labelList& labels : slCellLabels)
{
if // Tetrahedron
(
@ -469,29 +490,37 @@ int main(int argc, char *argv[])
Info<< "Creating boundary patches" << endl;
faceListList boundary(patchCellFaces.size());
wordList patchNames(patchCellFaces.size());
faceListList boundary(slPatchCells.size());
wordList patchNames(slPatchCells.size());
forAll(patchCellFaces, patchi)
forAll(slPatchCells, patchi)
{
DynamicList<face> patchFaces;
SLList<face> patchFaces;
patchFaces.reserve(patchCellFaces[patchi].size());
auto cellIter = slPatchCells[patchi].cbegin();
auto faceIter = slPatchCellFaces[patchi].cbegin();
for (const auto& tup : patchCellFaces[patchi])
for
(
;
cellIter.good() && faceIter.good();
++cellIter, ++faceIter
)
{
const label celli = tup.first();
const label facei = tup.second();
const cellShape& shape = cellShapes[cellMap[cellIter()]];
const cellShape& shape = cellShapes[cellMap[celli]];
patchFaces.push_back
patchFaces.append
(
shape.faces()[faceIndex[shape.nFaces()][facei-1]]
shape.faces()
[
faceIndex
[shape.nFaces()]
[faceIter()-1]
]
);
}
boundary[patchi] = std::move(patchFaces);
boundary[patchi] = patchFaces;
patchNames[patchi] = polyPatch::defaultName(patchi + 1);
}
@ -514,8 +543,8 @@ int main(int argc, char *argv[])
// Now split the boundary faces into external and internal faces. All
// faces go into faceZones and external faces go into patches.
List<faceList> patchFaces(patchCellFaces.size());
labelList patchNFaces(patchCellFaces.size(), Zero);
List<faceList> patchFaces(slPatchCells.size());
labelList patchNFaces(slPatchCells.size(), Zero);
forAll(boundary, patchi)
{
const faceList& bFaces = boundary[patchi];
@ -615,7 +644,7 @@ int main(int argc, char *argv[])
Info<< "Creating faceZone " << patchNames[patchi]
<< " with " << bFaceLabels.size() << " faces" << endl;
fz.push_back
fz.append
(
new faceZone
(
@ -631,20 +660,29 @@ int main(int argc, char *argv[])
// CellZones
for (const label cellType : cellTypes.sortedToc())
labelList types = cellTypes.sortedToc();
forAll(types, typei)
{
const label cellType = types[typei];
// Pick up cells in zone
DynamicList<label> addr;
auto cellMapIter = dynCellMap.cbegin();
auto cellMapIter = slCellMap.cbegin();
auto typeIter = slCellType.cbegin();
for (const auto& ctype : dynCellType)
for
(
;
typeIter.good();
++typeIter, ++cellMapIter
)
{
if (ctype == cellType)
if (typeIter() == cellType)
{
addr.push_back(cellMap[*cellMapIter]);
addr.append(cellMap[cellMapIter()]);
}
++cellMapIter;
}
Info<< "Creating cellZone " << cellTypes[cellType]
@ -656,7 +694,7 @@ int main(int argc, char *argv[])
(
cellTypes[cellType],
addr,
cz.size(),
typei,
pShapeMesh.cellZones()
)
);

View File

@ -271,7 +271,7 @@ int main(int argc, char *argv[])
if (blockPFacePointi != blockPFacePointi2)
{
sqrMergeTol =
Foam::min
min
(
sqrMergeTol,
magSqr
@ -338,16 +338,16 @@ int main(int argc, char *argv[])
blockNFacePoints[blockNFacePointi]
+ blockOffsets[blockNlabel];
label minPN = Foam::min(PpointLabel, NpointLabel);
label minPN = min(PpointLabel, NpointLabel);
if (pointMergeList[PpointLabel] != -1)
{
minPN = Foam::min(minPN, pointMergeList[PpointLabel]);
minPN = min(minPN, pointMergeList[PpointLabel]);
}
if (pointMergeList[NpointLabel] != -1)
{
minPN = Foam::min(minPN, pointMergeList[NpointLabel]);
minPN = min(minPN, pointMergeList[NpointLabel]);
}
pointMergeList[PpointLabel]
@ -411,7 +411,7 @@ int main(int argc, char *argv[])
pointMergeList[PpointLabel]
= pointMergeList[NpointLabel]
= Foam::min
= min
(
pointMergeList[PpointLabel],
pointMergeList[NpointLabel]

View File

@ -645,7 +645,7 @@ bool Foam::fileFormats::ensightMeshReader::readGeometry
// Parse all
SubStrings split;
SubStrings<string> split;
while (is.good())
{

View File

@ -350,7 +350,7 @@ mtype {space}"MTYPE:"{space}
// Find out how many labels are expected. If less or equal to
// seven, read them all and finish with it. If there is more,
// set read of the next line
label labelsToRead = Foam::min(8, nVertices);
label labelsToRead = min(8, nVertices);
label labelI = 0;
for (; labelI < labelsToRead; labelI++)
{
@ -387,7 +387,7 @@ mtype {space}"MTYPE:"{space}
labelList& curLabels = cellLabels[curNumberOfCells];
label labelsToRead = Foam::min
label labelsToRead = min
(
(nCellContinuationLines + 1)*7,
curLabels.size()

View File

@ -269,7 +269,7 @@ void readCells
label maxUnvPoint = 0;
forAll(unvPointID, pointi)
{
maxUnvPoint = Foam::max(maxUnvPoint, unvPointID[pointi]);
maxUnvPoint = max(maxUnvPoint, unvPointID[pointi]);
}
labelList unvToFoam(invert(maxUnvPoint+1, unvPointID));
@ -784,7 +784,7 @@ int main(int argc, char *argv[])
label maxUnvPoint = 0;
forAll(unvPointID, pointi)
{
maxUnvPoint = Foam::max(maxUnvPoint, unvPointID[pointi]);
maxUnvPoint = max(maxUnvPoint, unvPointID[pointi]);
}
labelList unvToFoam(invert(maxUnvPoint+1, unvPointID));

View File

@ -8,10 +8,10 @@
{
if (kivaVersion == kiva3v)
{
regionIndex = Foam::max
regionIndex = max
(
Foam::max(idface[quadFace[0]], idface[quadFace[1]]),
Foam::max(idface[quadFace[2]], idface[quadFace[3]])
max(idface[quadFace[0]], idface[quadFace[1]]),
max(idface[quadFace[2]], idface[quadFace[3]])
);
if (regionIndex > 0)

View File

@ -148,7 +148,7 @@ for (label i=0; i<nPoints; i++)
end = pointMap[end];
}
label minLabel = Foam::min(start, end);
label minLabel = min(start, end);
pointMap[start] = pointMap[end] = minLabel;
}
@ -181,7 +181,7 @@ forAll(cellShapes, celli)
label bcIDs[11] = {-1, 0, 2, 4, -1, 5, -1, 6, 7, 8, 9};
constexpr label nBCs = 12;
const label nBCs = 12;
const word* kivaPatchTypes[nBCs] =
{
@ -232,7 +232,7 @@ const char* kivaPatchNames[nBCs] =
};
List<DynamicList<face>> pFaces[nBCs];
List<SLList<face>> pFaces[nBCs];
face quadFace(4);
face triFace(3);
@ -331,29 +331,29 @@ if
{
forAll(pf, pfi)
{
minz = Foam::min(minz, points[pf[pfi]].z());
minz = min(minz, points[pf[pfi]].z());
}
}
minz += SMALL;
DynamicList<face> newLinerFaces;
SLList<face> newLinerFaces;
for (const face& pf : pFaces[LINER][0])
{
scalar minfz = GREAT;
for (const label pointi : pf)
forAll(pf, pfi)
{
minfz = Foam::min(minfz, points[pointi].z());
minfz = min(minfz, points[pf[pfi]].z());
}
if (minfz > minz)
{
pFaces[CYLINDERHEAD][0].push_back(pf);
pFaces[CYLINDERHEAD][0].append(pf);
}
else
{
newLinerFaces.push_back(pf);
newLinerFaces.append(pf);
}
}
@ -361,33 +361,33 @@ if
{
Info<< "Transferred " << pFaces[LINER][0].size() - newLinerFaces.size()
<< " faces from liner region to cylinder head" << endl;
pFaces[LINER][0] = std::move(newLinerFaces);
pFaces[LINER][0] = newLinerFaces;
}
DynamicList<face> newCylinderHeadFaces;
SLList<face> newCylinderHeadFaces;
for (const face& pf : pFaces[CYLINDERHEAD][0])
{
scalar minfz = GREAT;
for (const label pointi : pf)
forAll(pf, pfi)
{
minfz = Foam::min(minfz, points[pointi].z());
minfz = min(minfz, points[pf[pfi]].z());
}
if (minfz < zHeadMin)
{
pFaces[LINER][0].push_back(pf);
pFaces[LINER][0].append(pf);
}
else
{
newCylinderHeadFaces.push_back(pf);
newCylinderHeadFaces.append(pf);
}
}
if (pFaces[CYLINDERHEAD][0].size() != newCylinderHeadFaces.size())
{
Info<< "Transferred faces from cylinder-head region to linder" << endl;
pFaces[CYLINDERHEAD][0] = std::move(newCylinderHeadFaces);
pFaces[CYLINDERHEAD][0] = newCylinderHeadFaces;
}
}
@ -396,9 +396,9 @@ if
label nPatches = 0;
for (int bci=0; bci<nBCs; bci++)
{
for (const auto& faces : pFaces[bci])
forAll(pFaces[bci], rgi)
{
if (faces.size())
if (pFaces[bci][rgi].size())
{
nPatches++;
}
@ -415,34 +415,31 @@ if (pFaces[WEDGE].size() && pFaces[WEDGE][0].size())
const scalar tanTheta = Foam::tan(degToRad(2.5));
auto iterf = pFaces[WEDGE][0].cbegin();
auto iterb = pFaces[WEDGE][1].cbegin();
const auto end_iterf = pFaces[WEDGE][0].cend();
const auto end_iterb = pFaces[WEDGE][1].cend();
auto iterf = pFaces[WEDGE][0].begin();
auto iterb = pFaces[WEDGE][1].begin();
for
(
;
(iterf != end_iterf) && (iterb != end_iterb);
iterf.good() && iterb.good();
++iterf, ++iterb
)
{
const auto& facef = *iterf;
const auto& faceb = *iterb;
for (direction d=0; d<4; d++)
{
points[facef[d]].y() = -tanTheta*points[facef[d]].x();
points[faceb[d]].y() = tanTheta*points[faceb[d]].x();
points[iterf()[d]].y() = -tanTheta*points[iterf()[d]].x();
points[iterb()[d]].y() = tanTheta*points[iterb()[d]].x();
}
}
}
else
{
pFaces[CYCLIC].resize(1);
pFaces[CYCLIC].setSize(1);
pFaces[CYCLIC][0] = pFaces[WEDGE][0];
pFaces[CYCLIC][0].push_back(pFaces[WEDGE][1]);
for (const face& pf : pFaces[WEDGE][1])
{
pFaces[CYCLIC][0].append(pf);
}
pFaces[WEDGE].clear();
nPatches--;

View File

@ -188,7 +188,7 @@ int main(int argc, char *argv[])
}
maxPatch = Foam::max(maxPatch, patchi);
maxPatch = max(maxPatch, patchi);
triFace tri(readLabel(str)-1, readLabel(str)-1, readLabel(str)-1);

View File

@ -556,8 +556,8 @@ void calcEdgeMinMaxZone
forAll(eFaces, i)
{
label zoneI = mappedZoneID[eFaces[i]];
minZoneID[edgeI] = Foam::min(minZoneID[edgeI], zoneI);
maxZoneID[edgeI] = Foam::max(maxZoneID[edgeI], zoneI);
minZoneID[edgeI] = min(minZoneID[edgeI], zoneI);
maxZoneID[edgeI] = max(maxZoneID[edgeI], zoneI);
}
}
}
@ -661,8 +661,8 @@ void countExtrudePatches
}
// Synchronise decision. Actual numbers are not important, just make
// sure that they're > 0 on all processors.
Pstream::listReduce(zoneSidePatch, sumOp<label>());
Pstream::listReduce(zoneZonePatch, sumOp<label>());
Pstream::listCombineReduce(zoneSidePatch, plusEqOp<label>());
Pstream::listCombineReduce(zoneZonePatch, plusEqOp<label>());
}
@ -813,8 +813,8 @@ void addCoupledPatches
forAll(eFaces, i)
{
label proci = procID[eFaces[i]];
minProcID[edgeI] = Foam::min(minProcID[edgeI], proci);
maxProcID[edgeI] = Foam::max(maxProcID[edgeI], proci);
minProcID[edgeI] = min(minProcID[edgeI], proci);
maxProcID[edgeI] = max(maxProcID[edgeI], proci);
}
}
}
@ -1291,7 +1291,7 @@ void extrudeGeometricProperties
label celli = regionMesh.faceOwner()[facei];
if (regionMesh.isInternalFace(facei))
{
celli = Foam::max(celli, regionMesh.faceNeighbour()[facei]);
celli = max(celli, regionMesh.faceNeighbour()[facei]);
}
// Calculate layer from cell numbering (see createShellMesh)
@ -2210,8 +2210,8 @@ int main(int argc, char *argv[])
if (addSidePatches && (zone0 != zone1)) // || (cos(angle) > blabla))
{
label minZone = Foam::min(zone0,zone1);
label maxZone = Foam::max(zone0,zone1);
label minZone = min(zone0,zone1);
label maxZone = max(zone0,zone1);
label index = minZone*zoneNames.size()+maxZone;
ePatches.setSize(eFaces.size());

View File

@ -3,7 +3,6 @@ MarchingCubes = fastdualoctree_sgp
include $(GENERAL_RULES)/cgal
EXE_INC = \
$(c++LESSWARN) \
-DUNIX \
/* -IMarchingCubes */ \
-I$(FASTDUALOCTREE_SRC_PATH) \

View File

@ -26,7 +26,7 @@ void maxFaceToCell
const cell& cFaces = cells[cellI];
forAll(cFaces, i)
{
cellFld[cellI] = Foam::max(cellFld[cellI], faceData[cFaces[i]]);
cellFld[cellI] = max(cellFld[cellI], faceData[cFaces[i]]);
}
}
@ -56,7 +56,7 @@ void minFaceToCell
const cell& cFaces = cells[cellI];
forAll(cFaces, i)
{
cellFld[cellI] = Foam::min(cellFld[cellI], faceData[cFaces[i]]);
cellFld[cellI] = min(cellFld[cellI], faceData[cFaces[i]]);
}
}
@ -87,8 +87,8 @@ void minFaceToCell
// Internal faces
forAll(own, facei)
{
cellFld[own[facei]] = Foam::min(cellFld[own[facei]], faceData[facei]);
cellFld[nei[facei]] = Foam::min(cellFld[nei[facei]], faceData[facei]);
cellFld[own[facei]] = min(cellFld[own[facei]], faceData[facei]);
cellFld[nei[facei]] = min(cellFld[nei[facei]], faceData[facei]);
}
// Patch faces
@ -99,7 +99,7 @@ void minFaceToCell
forAll(fc, i)
{
cellFld[fc[i]] = Foam::min(cellFld[fc[i]], fvp[i]);
cellFld[fc[i]] = min(cellFld[fc[i]], fvp[i]);
}
}
@ -178,14 +178,7 @@ void Foam::writeFields
(
radToDeg
(
Foam::acos
(
Foam::min
(
scalar(1),
Foam::max(scalar(-1), faceOrthogonality)
)
)
Foam::acos(min(scalar(1), max(scalar(-1), faceOrthogonality)))
)
);
@ -541,7 +534,7 @@ void Foam::writeFields
ownCc,
fc
).quality();
ownVol = Foam::min(ownVol, tetQual);
ownVol = min(ownVol, tetQual);
}
}
if (mesh.isInternalFace(facei))
@ -557,7 +550,7 @@ void Foam::writeFields
fc,
neiCc
).quality();
neiVol = Foam::min(neiVol, tetQual);
neiVol = min(neiVol, tetQual);
}
}
}
@ -609,10 +602,8 @@ void Foam::writeFields
// Internal faces
forAll(own, facei)
{
cellFld[own[facei]] =
Foam::min(cellFld[own[facei]], ownPyrVol[facei]);
cellFld[nei[facei]] =
Foam::min(cellFld[nei[facei]], neiPyrVol[facei]);
cellFld[own[facei]] = min(cellFld[own[facei]], ownPyrVol[facei]);
cellFld[nei[facei]] = min(cellFld[nei[facei]], neiPyrVol[facei]);
}
// Patch faces
@ -623,8 +614,7 @@ void Foam::writeFields
forAll(fc, i)
{
const label meshFacei = fvp.patch().start();
cellFld[fc[i]] =
Foam::min(cellFld[fc[i]], ownPyrVol[meshFacei]);
cellFld[fc[i]] = min(cellFld[fc[i]], ownPyrVol[meshFacei]);
}
}
@ -635,7 +625,7 @@ void Foam::writeFields
if (writeFaceFields)
{
scalarField minFacePyrVol(neiPyrVol);
minFacePyrVol = Foam::min
minFacePyrVol = min
(
minFacePyrVol,
SubField<scalar>(ownPyrVol, mesh.nInternalFaces())

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2019-2025 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -37,7 +37,7 @@ Description
#include "argList.H"
#include "OFstream.H"
#include "stringOps.H"
#include "StringStream.H"
#include "point.H"
#include "DynamicList.H"
@ -58,49 +58,58 @@ string getLine(std::ifstream& is)
}
// Token list with one of the following:
// f v1 v2 v3 ...
// f v1/vt1 v2/vt2 v3/vt3 ...
// l v1 v2 v3 ...
// l v1/vt1 v2/vt2 v3/vt3 ...
static label readObjVertices
(
const SubStrings& tokens,
DynamicList<label>& verts
)
// Read space-separated vertices (with optional '/' arguments)
labelList parseVertices(const string& line)
{
verts.clear();
DynamicList<label> verts;
bool first = true;
for (const auto& tok : tokens)
// Assume 'l' is followed by space.
string::size_type endNum = 1;
do
{
if (first)
string::size_type startNum = line.find_first_not_of(' ', endNum);
if (startNum == string::npos)
{
// skip initial "f" or "l"
first = false;
continue;
break;
}
std::string vrtSpec(tok.str());
endNum = line.find(' ', startNum);
if
(
const auto slash = vrtSpec.find('/');
slash != std::string::npos
)
string vertexSpec;
if (endNum != string::npos)
{
vrtSpec.erase(slash);
vertexSpec = line.substr(startNum, endNum-startNum);
}
else
{
vertexSpec = line.substr(startNum, line.size() - startNum);
}
label vertId = readLabel(vrtSpec);
string::size_type slashPos = vertexSpec.find('/');
verts.push_back(vertId - 1);
label vertI = 0;
if (slashPos != string::npos)
{
IStringStream intStream(vertexSpec.substr(0, slashPos));
intStream >> vertI;
}
else
{
IStringStream intStream(vertexSpec);
intStream >> vertI;
}
verts.append(vertI - 1);
}
while (true);
return verts.size();
return verts.shrink();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
@ -133,8 +142,6 @@ int main(int argc, char *argv[])
DynamicList<labelList> polyLines;
DynamicList<labelList> polygons;
DynamicList<label> dynVerts;
bool hasWarned = false;
label lineNo = 0;
@ -145,58 +152,33 @@ int main(int argc, char *argv[])
if (line.empty()) continue;
const auto tokens = stringOps::splitSpace(line);
// Require command and some arguments
if (tokens.size() < 2)
{
continue;
}
const word cmd = word::validate(tokens[0]);
// Read first word
IStringStream lineStream(line);
word cmd(lineStream);
if (cmd == "v")
{
// Vertex
// v x y z
scalar x, y, z;
points.emplace_back
(
readScalar(tokens[1]),
readScalar(tokens[2]),
readScalar(tokens[3])
);
lineStream >> x >> y >> z;
points.append(point(x, y, z));
}
else if (cmd == "vn")
{
// Vertex normals
// vn x y z
scalar x, y, z;
pointNormals.emplace_back
(
readScalar(tokens[1]),
readScalar(tokens[2]),
readScalar(tokens[3])
);
lineStream >> x >> y >> z;
pointNormals.append(vector(x, y, z));
}
else if (cmd == "l")
{
// Line
// l v1 v2 v3 ...
// OR
// l v1/vt1 v2/vt2 v3/vt3 ...
readObjVertices(tokens, dynVerts);
polyLines.emplace_back() = dynVerts;
polyLines.append(parseVertices(line));
}
else if (cmd == "f")
{
// f v1 v2 v3 ...
// OR
// f v1/vt1 v2/vt2 v3/vt3 ...
readObjVertices(tokens, dynVerts);
polygons.emplace_back() = dynVerts;
polygons.append(parseVertices(line));
}
else if (cmd != "")
{
@ -206,7 +188,7 @@ int main(int argc, char *argv[])
WarningInFunction
<< "Unrecognized OBJ command " << cmd << nl
<< "In line " << line
<< "In line " << lineStream.str()
<< " at linenumber " << lineNo << nl
<< "Only recognized commands are 'v' and 'l'.\n"
<< "If this is a surface command use surfaceConvert instead"
@ -248,42 +230,46 @@ int main(int argc, char *argv[])
}
label nItems = 0;
for (const labelList& line : polyLines)
forAll(polyLines, polyI)
{
nItems += line.size() + 1;
nItems += polyLines[polyI].size() + 1;
}
outFile
<< "LINES " << polyLines.size() << ' ' << nItems << nl;
for (const labelList& line : polyLines)
forAll(polyLines, polyI)
{
const labelList& line = polyLines[polyI];
outFile << line.size();
for (const label vrt : line)
forAll(line, i)
{
outFile << ' ' << vrt;
outFile << ' ' << line[i];
}
outFile << nl;
}
nItems = 0;
for (const labelList& line : polygons)
forAll(polygons, polyI)
{
nItems += line.size() + 1;
nItems += polygons[polyI].size() + 1;
}
outFile
<< "POLYGONS " << polygons.size() << ' ' << nItems << nl;
for (const labelList& line : polygons)
forAll(polygons, polyI)
{
const labelList& line = polygons[polyI];
outFile << line.size();
for (const label vrt : line)
forAll(line, i)
{
outFile << ' ' << vrt;
outFile << ' ' << line[i];
}
outFile << nl;
}

View File

@ -100,26 +100,26 @@ void printEdgeStats(const polyMesh& mesh)
if (mag(eVec & x) > 1-edgeTol)
{
minX = Foam::min(minX, eMag);
maxX = Foam::max(maxX, eMag);
minX = min(minX, eMag);
maxX = max(maxX, eMag);
nX++;
}
else if (mag(eVec & y) > 1-edgeTol)
{
minY = Foam::min(minY, eMag);
maxY = Foam::max(maxY, eMag);
minY = min(minY, eMag);
maxY = max(maxY, eMag);
nY++;
}
else if (mag(eVec & z) > 1-edgeTol)
{
minZ = Foam::min(minZ, eMag);
maxZ = Foam::max(maxZ, eMag);
minZ = min(minZ, eMag);
maxZ = max(maxZ, eMag);
nZ++;
}
else
{
minOther = Foam::min(minOther, eMag);
maxOther = Foam::max(maxOther, eMag);
minOther = min(minOther, eMag);
maxOther = max(maxOther, eMag);
}
}
}

View File

@ -465,7 +465,7 @@ labelList getRegionFaceOrder
// Do region interfaces
{
const label nRegions = Foam::max(cellToRegion)+1;
const label nRegions = max(cellToRegion)+1;
// Sort in increasing region
SortableList<label> sortKey(mesh.nInternalFaces(), labelMax);
@ -478,10 +478,8 @@ labelList getRegionFaceOrder
if (ownRegion != neiRegion)
{
sortKey[facei] =
(
Foam::min(ownRegion, neiRegion)*nRegions
+ Foam::max(ownRegion, neiRegion)
);
min(ownRegion, neiRegion)*nRegions
+max(ownRegion, neiRegion);
}
}

View File

@ -320,10 +320,10 @@ bool doCommand
const globalMeshData& parData = mesh.globalData();
label typSize =
Foam::max
max
(
parData.nTotalCells(),
Foam::max
max
(
parData.nTotalFaces(),
parData.nTotalPoints()
@ -375,7 +375,7 @@ bool doCommand
topoSet& currentSet = currentSetPtr();
// Presize it according to current mesh data.
currentSet.reserve(Foam::max(currentSet.size(), typSize));
currentSet.reserve(max(currentSet.size(), typSize));
}
}

View File

@ -269,7 +269,11 @@ void addToInterface
EdgeMap<Map<label>>& regionsToSize
)
{
const edge interface(ownRegion, neiRegion, true); // sort=true
edge interface
(
min(ownRegion, neiRegion),
max(ownRegion, neiRegion)
);
auto iter = regionsToSize.find(interface);
@ -505,7 +509,11 @@ void getInterfaceSizes
zoneID = mesh.faceZones().whichZone(facei);
}
const edge interface(ownRegion, neiRegion, true); // sort=true
edge interface
(
min(ownRegion, neiRegion),
max(ownRegion, neiRegion)
);
faceToInterface[facei] = regionsToInterface[interface][zoneID];
}
@ -524,7 +532,11 @@ void getInterfaceSizes
zoneID = mesh.faceZones().whichZone(facei);
}
const edge interface(ownRegion, neiRegion, true); // sort=true
edge interface
(
min(ownRegion, neiRegion),
max(ownRegion, neiRegion)
);
faceToInterface[facei] = regionsToInterface[interface][zoneID];
}
@ -1069,7 +1081,7 @@ label findCorrespondingRegion
}
}
Pstream::listReduce(cellsInZone, sumOp<label>());
Pstream::listCombineReduce(cellsInZone, plusEqOp<label>());
// Pick region with largest overlap of zoneI
label regionI = findMax(cellsInZone);

View File

@ -295,8 +295,7 @@ void subsetTopoSets
Info<< "Subsetting " << set.type() << " " << set.name() << endl;
labelHashSet subset;
subset.reserve(Foam::min(set.size(), map.size()));
labelHashSet subset(2*min(set.size(), map.size()));
// Map the data
forAll(map, i)

View File

@ -1,3 +1,3 @@
addr2line.cxx
addr2line.C
EXE = $(FOAM_APPBIN)/addr2line

View File

@ -1,6 +1,2 @@
/* Disable normal project defaults */
PROJECT_INC =
PROJECT_LIBS =
/* EXE_INC = */
/* EXE_LIBS = */

View File

@ -6,7 +6,6 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018 Alexey Matveichev
Copyright (C) 2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -34,11 +33,12 @@ Description
#include <getopt.h>
#include <cstdlib>
#include <regex>
#include <string>
#include <vector>
#include <iostream>
#include "regExp.H"
#include "SubStrings.H"
static void usage();
static void version();
@ -53,6 +53,7 @@ int main(int argc, char *argv[])
int optHelp = 0, optFunctions = 0, optVersion = 0;
int ch;
std::string filename = "a.out";
std::vector<std::string> addresses;
static struct option opts[] =
{
@ -99,9 +100,15 @@ int main(int argc, char *argv[])
argc -= optind;
argv += optind;
for (std::string addr; argc > 0; --argc, ++argv)
while (argc > 0)
{
addresses.push_back(std::string(*argv));
++argv;
--argc;
}
for (const auto& addr : addresses)
{
addr.assign(*argv);
std::cout<< '\n' << getLine(filename, addr).c_str() << '\n';
}
@ -183,10 +190,10 @@ std::string getLine(const std::string& filename, const std::string& addr)
);
static std::regex re(".+LineEntry: .+: (.+):([0-9]+):[0-9]+");
std::smatch groups;
Foam::regExp re(".+LineEntry: .+: (.+):([0-9]+):[0-9]+");
if (!std::regex_match(line, groups, re))
Foam::regExp::results_type groups;
if (!re.match(line, groups))
{
line = "??:0";
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 OpenFOAM Foundation
Copyright (C) 2017-2025 OpenCFD Ltd.
Copyright (C) 2017-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -140,38 +140,6 @@ using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Read dictionary from IFstream, setting the stream to ascii/binary mode
//- depending on the 'FoamFile' header content
dictionary readDictionary(Istream& is)
{
auto format = is.format();
// If the file starts with 'FoamFile { ... }'
token tok;
if
(
(tok.read(is) && tok.isWord("FoamFile"))
&& (tok.read(is) && tok.isPunctuation(token::BEGIN_BLOCK))
)
{
is.putBack(tok); // Put back '{'
// FoamFile sub-dictionary content
dictionary header(is);
// Get "format" if present
format = IOstreamOption::formatEnum("format", header, format);
}
// Start again. Probably does not work well with IPstream though
is.rewind();
is.format(format);
// Read, preserving headers
return dictionary(is, true);
}
//- Convert very old ':' scope syntax to less old '.' scope syntax,
// but leave anything with '/' delimiters untouched
bool upgradeScope(word& entryName)
@ -298,8 +266,6 @@ void removeDict(dictionary& dict, const dictionary& dictToRemove)
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
argList::addNote
@ -307,7 +273,7 @@ int main(int argc, char *argv[])
"Interrogate and manipulate dictionaries"
);
argList::noBanner(); // Essential if redirecting stdout
argList::noBanner();
argList::noJobInfo();
argList::addArgument("dict", "The dictionary file to process");
argList::addBoolOption("keywords", "List keywords");
@ -370,7 +336,7 @@ int main(int argc, char *argv[])
"disableFunctionEntries",
"Disable expansion of dictionary directives - #include, #codeStream etc"
);
profiling::disable(); // Disable profiling (and its output)
profiling::disable(); // Disable profiling (and its output)
argList args(argc, argv);
@ -403,7 +369,7 @@ int main(int argc, char *argv[])
const auto dictFileName = args.get<fileName>(1);
auto dictFile = autoPtr<IFstream>::New(dictFileName);
if (!dictFile || !dictFile().good())
if (!dictFile().good())
{
FatalErrorInFunction
<< "Cannot open file " << dictFileName
@ -413,13 +379,8 @@ int main(int argc, char *argv[])
bool changed = false;
// Read, preserving headers
//// dictionary dict(dictFile(), true);
dictionary dict = readDictionary(dictFile());
// The extracted dictionary format
const auto dictFormat = dictFile().format();
// Read but preserve headers
dictionary dict(dictFile(), true);
if (listIncludes)
{
@ -453,10 +414,8 @@ int main(int argc, char *argv[])
<< exit(FatalError, 1);
}
// Read, preserving headers
//// diffDict.read(diffFile, true);
diffDict = readDictionary(diffFile);
// Read but preserve headers
diffDict.read(diffFile, true);
optDiff = true;
}
else if (args.readIfPresent("diff-etc", diffFileName))
@ -477,9 +436,8 @@ int main(int argc, char *argv[])
<< exit(FatalError, 1);
}
// Read, preserving headers
//// diffDict.read(diffFile, true);
diffDict = readDictionary(diffFile);
// Read but preserve headers
diffDict.read(diffFile, true);
optDiff = true;
}
}
@ -634,12 +592,10 @@ int main(int argc, char *argv[])
dict.write(Info, false);
}
// Close the input file
dictFile.reset();
if (changed)
{
OFstream os(dictFileName, dictFormat);
dictFile.clear();
OFstream os(dictFileName);
IOobject::writeBanner(os);
IOobject::writeDivider(os);
dict.write(os, false);

View File

@ -1131,7 +1131,7 @@ int main(int argc, char *argv[])
for
(
label addedI=next;
addedI < Foam::min(proci+step, nProcs);
addedI<min(proci+step, nProcs);
addedI++
)
{

View File

@ -403,11 +403,11 @@ void printMeshData(const polyMesh& mesh)
<< nBndFaces-nProcFaces << endl;
}
maxProcCells = Foam::max(maxProcCells, nLocalCells);
maxProcCells = max(maxProcCells, nLocalCells);
totProcFaces += nProcFaces;
totProcPatches += nei.size();
maxProcFaces = Foam::max(maxProcFaces, nProcFaces);
maxProcPatches = Foam::max(maxProcPatches, nei.size());
maxProcFaces = max(maxProcFaces, nProcFaces);
maxProcPatches = max(maxProcPatches, nei.size());
}
// Summary stats

View File

@ -131,7 +131,7 @@ int main(int argc, char *argv[])
args.readIfPresent("format", setFormat);
args.readIfPresent("stride", sampleFrequency);
sampleFrequency = Foam::max(1, sampleFrequency); // sanity
sampleFrequency = max(1, sampleFrequency); // sanity
// Setup the writer
auto writerPtr =
@ -179,14 +179,14 @@ int main(int argc, char *argv[])
maxIds.resize(origProc+1, -1);
}
maxIds[origProc] = Foam::max(maxIds[origProc], origId);
maxIds[origProc] = max(maxIds[origProc], origId);
}
}
const label maxNProcs = returnReduce(maxIds.size(), maxOp<label>());
maxIds.resize(maxNProcs, -1);
Pstream::listReduce(maxIds, maxOp<label>());
Pstream::listCombineReduce(maxIds, maxEqOp<label>());
// From ids to count
const labelList numIds = maxIds + 1;

View File

@ -40,7 +40,7 @@ Foam::Field<T> Foam::channelIndex::regionSum(const Field<T>& cellField) const
}
// Global sum
Pstream::listReduce(regionField, sumOp<T>());
Pstream::listCombineReduce(regionField, plusEqOp<T>());
return regionField;
}

View File

@ -1056,7 +1056,7 @@ void calc_drag_etc
const scalar expon =
(
br > 0.0
? Foam::clamp((surr_br / br - 0.25) * 4.0 / 3.0, Foam::zero_one{})
? min(max((surr_br / br - 0.25) * 4.0 / 3.0, scalar(0)), scalar(1))
: 0.0
);
@ -1114,16 +1114,16 @@ void Foam::PDRarrays::blockageSummary() const
totVolBlock += v_block(ijk) * pdrBlock.V(ijk);
totArea += surf(ijk);
totCount += Foam::max(0, obs_count(ijk));
totCount += max(0, obs_count(ijk));
totDrag.x() += Foam::max(0, drag_s(ijk).xx());
totDrag.y() += Foam::max(0, drag_s(ijk).yy());
totDrag.z() += Foam::max(0, drag_s(ijk).zz());
totDrag.x() += max(0, drag_s(ijk).xx());
totDrag.y() += max(0, drag_s(ijk).yy());
totDrag.z() += max(0, drag_s(ijk).zz());
for (direction cmpt=0; cmpt < vector::nComponents; ++cmpt)
{
totBlock[cmpt] += Foam::max(0, area_block_s(ijk)[cmpt]);
totBlock[cmpt] += Foam::max(0, area_block_r(ijk)[cmpt]);
totBlock[cmpt] += max(0, area_block_s(ijk)[cmpt]);
totBlock[cmpt] += max(0, area_block_r(ijk)[cmpt]);
}
}
}

View File

@ -302,7 +302,7 @@ void Foam::PDRutils::circle_overlap
scalar da = ac - 0.5 * (a1 + a2);
scalar db = bc - 0.5 * (b1 + b2);
scalar dc = std::hypot(da, db);
scalar rat1 = Foam::min(Foam::max((dc / sqrt(area) - 0.3) * 1.4, 0), 1);
scalar rat1 = min(max((dc / sqrt(area) - 0.3) * 1.4, 0), 1);
scalar drg0 = c_drag(ia,ib).xx();
scalar drg1 = c_drag(ia,ib).yy();
scalar drg = std::hypot(drg0, drg1);
@ -449,8 +449,8 @@ scalar block_overlap
{
PDRobstacle over;
over.pt = Foam::max(blk1.pt, blk2.pt);
over.span = Foam::min(max1, max2) - over.pt;
over.pt = max(blk1.pt, blk2.pt);
over.span = min(max1, max2) - over.pt;
assert(cmptProduct(over.span) > 0.0);
@ -603,11 +603,11 @@ scalar block_cylinder_overlap
over.x() = a_centre - 0.5 * a_lblk;
over.y() = b_centre - 0.5 * b_lblk;
over.z() = Foam::max(blk1.z(), cyl2.z());
over.z() = max(blk1.z(), cyl2.z());
over.span.x() = a_lblk;
over.span.y() = b_lblk;
over.span.z() = Foam::min(max1.z(), cyl2.z() + cyl2.len()) - over.z();
over.span.z() = min(max1.z(), cyl2.z() + cyl2.len()) - over.z();
assert(over.x() > -200.0);
assert(over.x() < 2000.0);
}
@ -668,11 +668,11 @@ scalar block_cylinder_overlap
over.z() = a_centre - a_lblk * 0.5;
over.x() = b_centre - b_lblk * 0.5;
over.y() = Foam::max(blk1.y(), cyl2.y());
over.y() = max(blk1.y(), cyl2.y());
over.span.z() = a_lblk;
over.span.x() = b_lblk;
over.span.y() = Foam::min(max1.y(), cyl2.y() + cyl2.len()) - over.y();
over.span.y() = min(max1.y(), cyl2.y() + cyl2.len()) - over.y();
}
break;
@ -734,11 +734,11 @@ scalar block_cylinder_overlap
over.y() = a_centre - a_lblk * 0.5;
over.z() = b_centre - b_lblk * 0.5;
over.x() = Foam::max(blk1.x(), cyl2.x());
over.x() = max(blk1.x(), cyl2.x());
over.span.y() = a_lblk;
over.span.z() = b_lblk;
over.span.x() = Foam::min(max1.x(), cyl2.x() + cyl2.len()) - over.x();
over.span.x() = min(max1.x(), cyl2.x() + cyl2.len()) - over.x();
}
break;
}

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