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
436 changed files with 5939 additions and 10975 deletions

View File

@ -1,2 +1,2 @@
api=2501
api=2412
patch=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.
@ -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

@ -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

@ -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

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

View File

@ -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);
@ -337,23 +337,23 @@ if
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

@ -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>());
}

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

@ -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

@ -1081,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

@ -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

@ -186,7 +186,7 @@ int main(int argc, char *argv[])
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

@ -229,7 +229,7 @@ void Foam::VF::raySearchEngine::createAgglomeration(const IOobject& io)
Pstream::allGatherList(allSf_);
Pstream::allGatherList(allAgg_);
Pstream::listGather(patchAreas_, sumOp<scalar>());
Pstream::listCombineGather(patchAreas_, plusEqOp<scalar>());
Pstream::broadcast(patchAreas_);
globalNumbering_ = globalIndex(nCoarseFace_);
@ -262,11 +262,8 @@ void Foam::VF::raySearchEngine::createGeometry()
Pstream::allGatherList(allCf_);
Pstream::allGatherList(allSf_);
// Pstream::listCombineGather(patchAreas_, plusEqOp<scalar>());
// Pstream::broadcast(patchAreas_);
// Basic type and op_sum, so can use listReduce (ie, mpiAllReduce)
Pstream::listReduce(patchAreas_, sumOp<scalar>());
Pstream::listCombineGather(patchAreas_, plusEqOp<scalar>());
Pstream::broadcast(patchAreas_);
globalNumbering_ = globalIndex(nFace_);
}

View File

@ -407,7 +407,7 @@ bool setFaceFieldType
}
}
Pstream::listReduce(nChanged, sumOp<label>());
Pstream::listCombineReduce(nChanged, plusEqOp<label>());
auto& fieldBf = field.boundaryFieldRef();

View File

@ -1,7 +1,6 @@
include $(GENERAL_RULES)/cgal-header-only
EXE_INC = \
$(c++LESSWARN) \
$(COMP_FLAGS) \
${CGAL_INC} \
-I$(LIB_SRC)/finiteVolume/lnInclude \

View File

@ -105,13 +105,8 @@ Description
#include <vector>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#if defined(CGAL_VERSION_NR) && (CGAL_VERSION_NR < 1060011000)
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_triangle_primitive.h>
#else
#include <CGAL/AABB_traits_3.h>
#include <CGAL/AABB_triangle_primitive_3.h>
#endif
#include <CGAL/Surface_mesh.h>
typedef CGAL::Simple_cartesian<double> K;
@ -121,13 +116,8 @@ typedef K::Triangle_3 Triangle;
typedef K::Segment_3 Segment;
typedef std::vector<Triangle>::iterator Iterator;
#if defined(CGAL_VERSION_NR) && (CGAL_VERSION_NR < 1060011000)
typedef CGAL::AABB_triangle_primitive<K, Iterator> Primitive;
typedef CGAL::AABB_traits<K, Primitive> AABB_triangle_traits;
#else
typedef CGAL::AABB_triangle_primitive_3<K, Iterator> Primitive;
typedef CGAL::AABB_traits_3<K, Primitive> AABB_triangle_traits;
#endif
typedef CGAL::AABB_tree<AABB_triangle_traits> Tree;
// Used boost::optional prior to CGAL-6.0

View File

@ -6,7 +6,6 @@ EXE_NDEBUG = -DNDEBUG
include $(GENERAL_RULES)/cgal
EXE_INC = \
$(c++LESSWARN) \
${ROUNDING_MATH} \
${EXE_NDEBUG} \
${CGAL_INC} \

View File

@ -97,11 +97,7 @@ Description
#pragma clang diagnostic ignored "-Wbitwise-instead-of-logical"
#include <CGAL/AABB_tree.h>
#if defined(CGAL_VERSION_NR) && (CGAL_VERSION_NR < 1060011000)
#include <CGAL/AABB_traits.h>
#else
#include <CGAL/AABB_traits_3.h>
#endif
#include <CGAL/AABB_face_graph_triangle_primitive.h>
#include "CGALIndexedPolyhedron.H"
#include "PolyhedronReader.H"
@ -109,11 +105,7 @@ typedef CGAL::AABB_face_graph_triangle_primitive
<
Polyhedron, CGAL::Default, CGAL::Tag_false
> Primitive;
#if defined(CGAL_VERSION_NR) && (CGAL_VERSION_NR < 1060011000)
typedef CGAL::AABB_traits<K, Primitive> Traits;
#else
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
#endif
typedef CGAL::AABB_tree<Traits> Tree;
// Used boost::optional prior to CGAL-6.0

View File

@ -47,7 +47,7 @@ Description
#include "janafThermo.H"
#include "absoluteEnthalpy.H"
#include "PtrDynList.H"
#include "SLPtrList.H"
#include "IOdictionary.H"
using namespace Foam;
@ -104,12 +104,27 @@ int main(int argc, char *argv[])
thermo H2O(thermoData.subDict("H2O")); H2O *= H2O.W();
thermo CO(thermoData.subDict("CO")); CO *= CO.W();
PtrDynList<thermo> EQreactions(4);
SLPtrList<thermo> EQreactions;
EQreactions.emplace_back((CO2 == CO + 0.5*O2));
EQreactions.emplace_back((O2 == 2*O));
EQreactions.emplace_back((H2O == H2 + 0.5*O2));
EQreactions.emplace_back((H2O == H + OH));
EQreactions.append
(
new thermo(CO2 == CO + 0.5*O2)
);
EQreactions.append
(
new thermo(O2 == 2*O)
);
EQreactions.append
(
new thermo(H2O == H2 + 0.5*O2)
);
EQreactions.append
(
new thermo(H2O == H + OH)
);
for (const thermo& react : EQreactions)

View File

@ -43,8 +43,6 @@ options:
-local Same as -spawn=1
-remote Same as -spawn=2
-clean Remove log and startup files
-no-core Restrict core dump to 0 size
-quick Valgrind with 'summary' (not 'full') and use -no-core
-decompose-dict=<file> Specific decomposeParDict name
-help Print the usage
@ -110,9 +108,8 @@ Linux)
esac
unset appName appArgs nProcs
unset method spawn optClean optValue opt_nocore
unset method spawn optClean optValue
optConfirm=true
opt_leakcheck=full
decompDict="system/decomposeParDict"
@ -156,15 +153,6 @@ do
: "${spawn:=local}"
;;
-quick)
opt_leakcheck="summary"
opt_nocore=true
;;
-no-core)
opt_nocore=true
;;
-valgr*)
method="valgrind"
unset optConfirm
@ -350,16 +338,12 @@ fi
case "$sourceFoam" in
*/bashrc)
sourceFoam=". $sourceFoam $FOAM_SETTINGS || true"
sourceFoam=". $sourceFoam $FOAM_SETTINGS"
;;
esac
echo "**sourceFoam: $sourceFoam" 1>&2
# remove old files
rm -rf ./mpirun.files
rm -rf ./mpirun.log
mkdir -p ./mpirun.files
mkdir -p ./mpirun.log
@ -391,12 +375,6 @@ $sourceFoam
cd "${PWD}" || exit
COMMANDS
if [ "$opt_nocore" = true ]
then
echo "# no coredump" >> "$procCmdFile"
echo "ulimit -c 0 2>/dev/null" >> "$procCmdFile"
fi
# Add to the mpirun.schema
case "$method" in
(*xterm*) echo "${node}${xterm} -e ${procCmdFile}" >> "$schema_file" ;;
@ -422,16 +400,10 @@ COMMANDS
echo "read input"
;;
(valgrind | valgrind-log)
echo "# valgrind does not work nicely with RMA (libfabric)"
echo "export FI_PROVIDER=tcp"
echo
echo "valgrind --leak-check=$opt_leakcheck --show-reachable=yes $exec $appArgs > $procLog 2>&1"
echo "valgrind --leak-check=full --show-reachable=yes $exec $appArgs > $procLog 2>&1"
;;
(valgrind-xterm)
echo "# valgrind does not work nicely with RMA (libfabric)"
echo "export FI_PROVIDER=tcp"
echo
echo "valgrind --leak-check=$opt_leakcheck --show-reachable=yes $exec $appArgs 2>&1 | tee $procLog"
echo "valgrind --leak-check=full --show-reachable=yes $exec $appArgs 2>&1 | tee $procLog"
echo "read input"
;;
(gperf)

View File

@ -7,7 +7,7 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2016-2025 OpenCFD Ltd.
# Copyright (C) 2016-2021 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -103,7 +103,6 @@ Components versions (ThirdParty)
-fftw VER specify 'fffw_version'
-kahip VER specify 'KAHIP_VERSION'
-metis VER specify 'METIS_VERSION'
-petsc VER specify 'petsc_version'
-scotch VER specify 'SCOTCH_VERSION' (eg, scotch_6.0.4)
HELP_HEAD
@ -119,23 +118,8 @@ Components specified by absolute path
-fftw-path DIR Path for 'FFTW_ARCH_PATH' (overrides -fftw)
-kahip-path DIR Path for 'KAHIP_ARCH_PATH' (overrides -kahip)
-metis-path DIR Path for 'METIS_ARCH_PATH' (overrides -metis)
-petsc-path DIR Path for 'PETSC_ARCH_PATH' (overrides -petsc)
-scotch-path DIR Path for 'SCOTCH_ARCH_PATH' (overrides -scotch)
-gmp-path DIR Path for 'GMP_ARCH_PATH' (in cgal config)
-mpfr-path DIR Path for 'MPFR_ARCH_PATH' (in cgal config)
Components specified by homebrew (treat like system locations)
Sets version as system, path from brew --prefix
-adios-brew, -adios2-brew, -boost-brew, -cgal-brew,
-fftw-brew, -kahip-brew, -metis-brew, -scotch-brew
-with-homebrew Shortcut for selecting all the above
-gmp-brew Homebrew for 'GMP_ARCH_PATH' (in cgal config)
-mpfr-brew Homebrew for 'MPFR_ARCH_PATH' (in cgal config)
-petsc-brew Homebrew for petsc
Graphics
-paraview VER specify 'ParaView_VERSION' (eg, 5.9.0 or system)
-paraview-qt VER specify 'ParaView_QT' (eg, qt-system)
@ -253,8 +237,8 @@ replace()
while [ "$#" -ge 2 ]
do
key="$1"
val="$2"
key=$1
val=$2
shift 2
_inlineSed \
@ -278,83 +262,18 @@ replaceCsh()
while [ "$#" -ge 2 ]
do
key="$1"
val="$2"
key=$1
val=$2
shift 2
_inlineSed \
"$file" \
"setenv [ ]*$key .*" \
"setenv [ ]*$key [^ #]*" \
"setenv $key $val" \
"Replaced $key by '$val'"
done
}
# Remove leading '#config#' marker from '#config export VAR=...'
removeConfigMarker()
{
local file="$1"
shift
local var cmd
while [ "$#" -ge 1 ]
do
var="$1"
shift
cmd='/^#config# *export [ ]*'"$var"'=/s@^#config# *@@'
if grep -q '^#config#' "$file" 2> /dev/null
then
sed -i -e "$cmd" "$file"
else
break
fi
done
}
# Remove leading '#config#' marker from '#config setenv VAR ...'
removeConfigMarkerCsh()
{
local file="$1"
shift
local var cmd
while [ "$#" -ge 1 ]
do
var="$1"
shift
cmd='/^#config# *setenv [ ]*'"$var"'/s@^#config# *@@'
if grep -q '^#config#' "$file" 2> /dev/null
then
sed -i -e "$cmd" "$file"
else
break
fi
done
}
# Remove leading '#config#' marker from '#config export VAR=...'
removeEtcConfigMarker()
{
local file="$1"
shift
file="$(_foamEtc "$file")"
removeConfigMarker "$file" "$@"
}
# Remove leading '#config#' marker from '#config setenv VAR ...'
removeEtcConfigMarkerCsh()
{
local file="$1"
shift
file="$(_foamEtc "$file")"
removeConfigMarkerCsh "$file" "$@"
}
# Locate file with foamEtcFile -mode=o and forward to replace()
replaceEtc()
{
@ -377,30 +296,6 @@ replaceEtcCsh()
}
# Locate file with foamEtcFile -mode=o and forward to replace()
replaceBrewEtc()
{
local file="$1"
local var="$2"
local pkg="$3"
file="$(_foamEtc "$file")"
replace "$file" "$var" '"$(brew --prefix '"$pkg"' 2>/dev/null)"'
}
# Locate file with foamEtcFile -mode=o and forward to replaceCsh()
replaceBrewEtcCsh()
{
local file="$1"
local var="$2"
local pkg="$3"
file="$(_foamEtc "$file")"
replaceCsh "$file" "$var" '`brew --prefix '"$pkg"'`'
}
# Get the option's value (argument), or die on missing or empty argument
# $1 option
# $2 value
@ -485,46 +380,23 @@ removeCshMagic()
#------------------------------------------------------------------------------
unset adjusted optHomebrew
# Pre-scan options
case "$@" in (*-with-homebrew*) optHomebrew=true;; esac
# Preload with some options
if [ "$optHomebrew" = true ]
then
set -- \
-adios2-brew \
-boost-brew \
-cgal-brew \
-fftw-brew \
-kahip-brew \
-metis-brew \
-scotch-brew \
"$@"
fi
unset adjusted
# Parse options
while [ "$#" -gt 0 ]
do
unset brewName optValue
case "$1" in
-help-c*) # Compat help
printHelp -compat
;;
-help-f* | --help-f*) # Full help
-help-f*) # Full help
printHelp -full
;;
-h | -help* | --help) # Short help
-h | -help*) # Short help
printHelp
;;
'')
# Discard empty arguments
;;
-with-homebrew)
# Already handled (above)
;;
-debug-list)
# Undocumented (experimental)
@ -565,7 +437,8 @@ CONFIG_CSH
-project-path=* | -project-path)
# Replace WM_PROJECT_DIR=...
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
@ -582,7 +455,8 @@ CONFIG_CSH
-version=* | -version | -foamVersion | --projectVersion)
# Replace WM_PROJECT_VERSION=...
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
@ -628,7 +502,8 @@ CONFIG_CSH
-clang=* | -clang)
# Replace default_clang_version=...
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
@ -642,7 +517,8 @@ CONFIG_CSH
-gcc=* | -gcc)
# Replace default_gcc_version=...
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
@ -656,7 +532,8 @@ CONFIG_CSH
-system-compiler | -system)
# Replace WM_COMPILER_TYPE=... and WM_COMPILER=...
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
@ -674,7 +551,8 @@ CONFIG_CSH
-third-compiler | -third | -ThirdParty)
# Replace WM_COMPILER_TYPE=... and WM_COMPILER=...
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
@ -719,7 +597,8 @@ CONFIG_CSH
-mpi=* | -mpi)
# Explicitly set WM_MPLIB=...
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
@ -782,7 +661,8 @@ CONFIG_CSH
-adios | -adios2)
# Replace adios2_version=...
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
@ -796,7 +676,8 @@ CONFIG_CSH
-adios-path | -adios2-path)
# Replace ADIOS2_ARCH_PATH=...
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
@ -808,22 +689,10 @@ CONFIG_CSH
fi
;;
-adios-brew | -adios2-brew)
brewName=adios2; optValue="${brewName}-system"
# Replace adios2_version=...
replaceEtc config.sh/adios2 adios2_version "$optValue"
replaceEtc config.csh/adios2 adios2_version "$optValue"
# Replace ADIOS2_ARCH_PATH=...
replaceBrewEtc config.sh/adios2 ADIOS2_ARCH_PATH "$brewName"
replaceBrewEtcCsh config.csh/adios2 ADIOS2_ARCH_PATH "$brewName"
adjusted=true
;;
-boost)
# Replace boost_version=... (config is cgal or CGAL)
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
cfgName=cgal; _foamEtc -q config.sh/"$cfgName" || cfgName=CGAL
if [ -n "$optValue" ]
@ -838,38 +707,24 @@ CONFIG_CSH
-boost-path)
# Replace BOOST_ARCH_PATH=... (config is cgal or CGAL)
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
cfgName=cgal; _foamEtc -q config.sh/"$cfgName" || cfgName=CGAL
if [ -n "$optValue" ]
then
replaceEtc config.sh/"$cfgName" BOOST_ARCH_PATH "\"$optValue\""
replaceEtcCsh config.csh/"$cfgName" BOOST_ARCH_PATH "\"$optValue\""
replaceEtc config.sh/"$cfgName" BOOST_ARCH_PATH "\"$optValue\""
replaceEtc config.csh/"$cfgName" BOOST_ARCH_PATH "\"$optValue\""
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-boost-brew)
brewName=boost; optValue="${brewName}-system"
# (config is cgal or CGAL)
cfgName=cgal; _foamEtc -q config.sh/"$cfgName" || cfgName=CGAL
# Replace boost_version=...
replaceEtc config.sh/"$cfgName" boost_version "$optValue"
replaceEtc config.csh/"$cfgName" boost_version "$optValue"
# Replace BOOST_ARCH_PATH=...
replaceBrewEtc config.sh/"$cfgName" BOOST_ARCH_PATH "$brewName"
replaceBrewEtcCsh config.csh/"$cfgName" BOOST_ARCH_PATH "$brewName"
adjusted=true
;;
-cgal)
# Replace cgal_version=... (config is cgal or CGAL)
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
cfgName=cgal; _foamEtc -q config.sh/"$cfgName" || cfgName=CGAL
if [ -n "$optValue" ]
@ -884,7 +739,8 @@ CONFIG_CSH
-cgal-path)
# Replace CGAL_ARCH_PATH=... (config is cgal or CGAL)
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
cfgName=cgal; _foamEtc -q config.sh/"$cfgName" || cfgName=CGAL
if [ -n "$optValue" ]
@ -897,96 +753,10 @@ CONFIG_CSH
fi
;;
-cgal-brew)
brewName=cgal; optValue="${brewName}-system"
# (config is cgal or CGAL)
cfgName=cgal; _foamEtc -q config.sh/"$cfgName" || cfgName=CGAL
# Replace cgal_version=...
replaceEtc config.sh/"$cfgName" cgal_version "$optValue"
replaceEtc config.csh/"$cfgName" cgal_version "$optValue"
# Replace CGAL_ARCH_PATH=... (config is cgal or CGAL)
replaceBrewEtc config.sh/"$cfgName" CGAL_ARCH_PATH "$brewName"
replaceBrewEtcCsh config.csh/"$cfgName" CGAL_ARCH_PATH "$brewName"
adjusted=true
;;
-gmp-path)
# Replace GMP_ARCH_PATH=... (config is cgal or CGAL)
getOptionValue "$@"; shift "${nOptArgs:-0}"
cfgName=cgal; _foamEtc -q config.sh/"$cfgName" || cfgName=CGAL
if [ -n "$optValue" ]
then
# Remove leading '#config#' marker
removeEtcConfigMarker config.sh/"$cfgName" GMP_ARCH_PATH
removeEtcConfigMarkerCsh config.csh/"$cfgName" GMP_ARCH_PATH
replaceEtc config.sh/"$cfgName" GMP_ARCH_PATH "\"$optValue\""
replaceEtcCsh config.csh/"$cfgName" GMP_ARCH_PATH "\"$optValue\""
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-gmp-brew)
brewName=gmp; optValue="${brewName}-system"
# (config is cgal or CGAL)
cfgName=cgal; _foamEtc -q config.sh/"$cfgName" || cfgName=CGAL
# Remove leading '#config#' marker
removeEtcConfigMarker config.sh/"$cfgName" GMP_ARCH_PATH
removeEtcConfigMarkerCsh config.csh/"$cfgName" GMP_ARCH_PATH
# Replace GMP_ARCH_PATH=... (config is cgal or CGAL)
replaceBrewEtc config.sh/"$cfgName" GMP_ARCH_PATH "$brewName"
replaceBrewEtcCsh config.csh/"$cfgName" GMP_ARCH_PATH "$brewName"
adjusted=true
;;
-mpfr-path)
# Replace MPFR_ARCH_PATH=... (config is cgal or CGAL)
getOptionValue "$@"; shift "${nOptArgs:-0}"
cfgName=cgal; _foamEtc -q config.sh/"$cfgName" || cfgName=CGAL
if [ -n "$optValue" ]
then
# Remove leading '#config#' marker
removeEtcConfigMarker config.sh/"$cfgName" MPFR_ARCH_PATH
removeEtcConfigMarkerCsh config.csh/"$cfgName" MPFR_ARCH_PATH
replaceEtc config.sh/"$cfgName" MPFR_ARCH_PATH "\"$optValue\""
replaceEtcCsh config.csh/"$cfgName" MPFR_ARCH_PATH "\"$optValue\""
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-mpfr-brew)
brewName=mpfr; optValue="${brewName}-system"
# (config is cgal or CGAL)
cfgName=cgal; _foamEtc -q config.sh/"$cfgName" || cfgName=CGAL
# Remove leading '#config#' marker
removeEtcConfigMarker config.sh/"$cfgName" MPFR_ARCH_PATH
removeEtcConfigMarkerCsh config.csh/"$cfgName" MPFR_ARCH_PATH
# Replace MPFR_ARCH_PATH=... (config is cgal or CGAL)
replaceBrewEtc config.sh/"$cfgName" MPFR_ARCH_PATH "$brewName"
replaceBrewEtcCsh config.csh/"$cfgName" MPFR_ARCH_PATH "$brewName"
adjusted=true
;;
-fftw)
# Replace fftw_version=...
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
# config.sh/fftw or config.sh/FFTW
cfgName=fftw; _foamEtc -q config.sh/"$cfgName" || cfgName=FFTW
@ -1002,7 +772,8 @@ CONFIG_CSH
-fftw-path)
# Replace FFTW_ARCH_PATH=...
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
# config.sh/fftw or config.sh/FFTW
cfgName=fftw; _foamEtc -q config.sh/"$cfgName" || cfgName=FFTW
@ -1016,25 +787,10 @@ CONFIG_CSH
fi
;;
-fftw-brew)
brewName=fftw; optValue="${brewName}-system"
# (config is fftw or FFTW)
cfgName=fftw; _foamEtc -q config.sh/"$cfgName" || cfgName=FFTW
# Replace fftw_version=...
replaceEtc config.sh/"$cfgName" fftw_version "$optValue"
replaceEtc config.csh/"$cfgName" fftw_version "$optValue"
# Replace FFTW_ARCH_PATH=...
replaceBrewEtc config.sh/"$cfgName" FFTW_ARCH_PATH "$brewName"
replaceBrewEtcCsh config.csh/"$cfgName" FFTW_ARCH_PATH "$brewName"
adjusted=true
;;
-cmake)
# Replace cmake_version=...
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
@ -1047,7 +803,8 @@ CONFIG_CSH
-cmake-path)
# Replace CMAKE_ARCH_PATH=...
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
@ -1060,7 +817,8 @@ CONFIG_CSH
-kahip)
# Replace KAHIP_VERSION=...
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
@ -1073,7 +831,8 @@ CONFIG_CSH
-kahip-path)
# Replace KAHIP_ARCH_PATH=...
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
@ -1084,20 +843,10 @@ CONFIG_CSH
fi
;;
-kahip-brew)
brewName=kahip; optValue="${brewName}-system"
# Replace KAHIP_VERSION=...
replaceEtc config.sh/kahip KAHIP_VERSION "$optValue"
# Replace KAHIP_ARCH_PATH=...
replaceBrewEtc config.sh/kahip KAHIP_ARCH_PATH "$brewName"
adjusted=true
;;
-metis)
# Replace METIS_VERSION=...
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
@ -1110,7 +859,8 @@ CONFIG_CSH
-metis-path)
# Replace METIS_ARCH_PATH=...
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
@ -1121,62 +871,10 @@ CONFIG_CSH
fi
;;
-metis-brew)
brewName=metis; optValue="${brewName}-system"
# Replace METIS_VERSION=...
replaceEtc config.sh/metis METIS_VERSION "$optValue"
adjusted=true
# Replace METIS_ARCH_PATH=...
replaceBrewEtc config.sh/metis METIS_ARCH_PATH "$brewName"
adjusted=true
;;
-petsc)
# Replace petsc_version=...
getOptionValue "$@"; shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/petsc petsc_version "$optValue"
replaceEtc config.csh/petsc petsc_version "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-petsc-path)
# Replace PETSC_ARCH_PATH=...
getOptionValue "$@"; shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/petsc PETSC_ARCH_PATH "\"$optValue\""
replaceEtcCsh config.csh/petsc PETSC_ARCH_PATH "\"$optValue\""
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-petsc-brew)
brewName=petsc; optValue="${brewName}-system"
# Replace petsc_version=...
replaceEtc config.sh/petsc petsc_version "$optValue"
replaceEtc config.csh/petsc petsc_version "$optValue"
# Replace PETSC_ARCH_PATH=...
replaceBrewEtc config.sh/petsc PETSC_ARCH_PATH "$brewName"
replaceBrewEtcCsh config.csh/petsc PETSC_ARCH_PATH "$brewName"
adjusted=true
;;
-scotch | -scotchVersion | --scotchVersion)
# Replace SCOTCH_VERSION=...
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
@ -1189,7 +887,8 @@ CONFIG_CSH
-scotch-path | -scotchArchPath | --scotchArchPath)
# Replace SCOTCH_ARCH_PATH=...
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
@ -1200,16 +899,6 @@ CONFIG_CSH
fi
;;
-scotch-brew)
brewName=scotch; optValue="${brewName}-system"
# Replace SCOTCH_VERSION=...
replaceEtc config.sh/scotch SCOTCH_VERSION "$optValue"
# Replace SCOTCH_ARCH_PATH=...
replaceBrewEtc config.sh/scotch SCOTCH_ARCH_PATH "$brewName"
adjusted=true
;;
## Graphics ##
@ -1234,7 +923,8 @@ CONFIG_CSH
-paraview-qt)
# Replace ParaView_QT=...
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
@ -1248,7 +938,8 @@ CONFIG_CSH
-paraview-path | -paraviewInstall | --paraviewInstall)
# Replace ParaView_DIR=...
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
@ -1262,7 +953,8 @@ CONFIG_CSH
-llvm)
# Replace mesa_llvm=...
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
@ -1276,7 +968,8 @@ CONFIG_CSH
-mesa)
# Replace mesa_version=...
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
@ -1290,7 +983,8 @@ CONFIG_CSH
-vtk)
# Replace vtk_version=...
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
@ -1304,7 +998,8 @@ CONFIG_CSH
-llvm-path)
# Replace LLVM_ARCH_PATH=...
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
@ -1318,7 +1013,8 @@ CONFIG_CSH
-mesa-path)
# Replace MESA_ARCH_PATH...
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
@ -1332,7 +1028,8 @@ CONFIG_CSH
-vtk-path)
# Replace VTK_DIR...
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
@ -1356,7 +1053,8 @@ CONFIG_CSH
-archOption | --archOption | \
-foamInstall | --foamInstall | -projectName | --projectName)
echo "Ignoring obsolete option: $1" 1>&2
getOptionValue "$@"; shift "${nOptArgs:-0}"
getOptionValue "$@"
shift "${nOptArgs:-0}"
;;
*)

View File

@ -6,7 +6,7 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2014-2016 OpenFOAM Foundation
# Copyright (C) 2016-2025 OpenCFD Ltd.
# Copyright (C) 2016-2021 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -39,9 +39,6 @@
#
# Can also disable by renaming/removing this file or by creating an empty
# file with the same name at a user or site location.
#
# The leading '#config#' marker provides an edit point for
# foamConfigurePaths
#------------------------------------------------------------------------------
# USER EDITABLE PART: Changes made here may be lost with the next upgrade
@ -51,8 +48,8 @@ set cgal_version=CGAL-4.14.3
setenv BOOST_ARCH_PATH "$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$boost_version"
setenv CGAL_ARCH_PATH "$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$cgal_version"
#config# setenv GMP_ARCH_PATH ...
#config# setenv MPFR_ARCH_PATH ...
# setenv GMP_ARCH_PATH ...
# setenv MPFR_ARCH_PATH ...
# END OF (NORMAL) USER EDITABLE PART
#------------------------------------------------------------------------------

View File

@ -6,7 +6,7 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2016-2025 OpenCFD Ltd.
# Copyright (C) 2016-2022 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -32,7 +32,7 @@ setenv WM_COMPILER_LIB_ARCH # Ending for lib directories
if (! $?WM_COMPILE_OPTION ) setenv WM_COMPILE_OPTION
# Adjust according to system and architecture
switch ("$WM_ARCH")
switch ($WM_ARCH)
case Linux:
setenv WM_ARCH linux
@ -74,22 +74,11 @@ case Linux:
breaksw
# arm64 or x86_64 architectures
# Note: /usr/bin/{gcc,g++} normally just symlinks to clang/clang++
# which may not behave as expected.
case Darwin:
setenv WM_ARCH darwin64
if ( "$WM_COMPILER" == Gcc ) then
setenv WM_COMPILER Clang
# Honour use of gcc, when version=... is specifed in WM_COMPILE_CONTROL
# (eg, gcc installed via homebrew)
if ( $?WM_COMPILE_CONTROL ) then
if ( "$WM_COMPILE_CONTROL" =~ "*version=*" ) then
setenv WM_COMPILER Gcc
endif
endif
if ( "$WM_COMPILER" == Clang ) then
echo "openfoam (darwin): using clang instead of gcc"
endif
echo "openfoam (darwin): using clang instead of gcc"
endif
breaksw
@ -225,8 +214,8 @@ _foamEtc -config compiler
# ThirdParty base for compilers
set archDir="$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH"
switch ("${WM_COMPILER_TYPE}/${WM_COMPILER}")
case ThirdParty/Gcc*:
switch ("$WM_COMPILER_TYPE-$WM_COMPILER")
case ThirdParty-Gcc*:
if (! $?gmp_version ) set gmp_version=gmp-system
if (! $?mpfr_version ) set mpfr_version=mpfr-system
if (! $?mpc_version ) set mpc_version=mpc-system
@ -274,7 +263,7 @@ GCC_NOT_FOUND
endif
breaksw
case ThirdParty/Clang*:
case ThirdParty-Clang*:
set clangDir="$archDir/$clang_version"
# Check that the compiler directory can be found
@ -301,9 +290,9 @@ CLANG_NOT_FOUND
endif
breaksw
case /*:
case system/*:
case ThirdParty/*:
case -*:
case system-*:
case ThirdParty-*:
# Using empty (system), system compiler or other ThirdParty compiler
breaksw

View File

@ -6,7 +6,7 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2014-2016 OpenFOAM Foundation
# Copyright (C) 2016-2025 OpenCFD Ltd.
# Copyright (C) 2016-2021 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -40,9 +40,6 @@
#
# Can also disable by renaming/removing this file or by creating an empty
# file with the same name at a user or site location.
#
# The leading '#config#' marker provides an edit point for
# foamConfigurePaths
#------------------------------------------------------------------------------
# USER EDITABLE PART: Changes made here may be lost with the next upgrade
@ -52,8 +49,8 @@ cgal_version=CGAL-4.14.3
export BOOST_ARCH_PATH="$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$boost_version"
export CGAL_ARCH_PATH="$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$cgal_version"
#config# export GMP_ARCH_PATH=...
#config# export MPFR_ARCH_PATH=...
# export GMP_ARCH_PATH=...
# export MPFR_ARCH_PATH=...
# END OF (NORMAL) USER EDITABLE PART
#------------------------------------------------------------------------------
@ -65,14 +62,14 @@ fi
if command -v _foamAddLibAuto >/dev/null # Normal sourcing (not makeCGAL)
then
_foamAddLibAuto "$BOOST_ARCH_PATH" "lib$WM_COMPILER_LIB_ARCH"
_foamAddLibAuto "$CGAL_ARCH_PATH" "lib$WM_COMPILER_LIB_ARCH"
_foamAddLibAuto $BOOST_ARCH_PATH lib$WM_COMPILER_LIB_ARCH
_foamAddLibAuto $CGAL_ARCH_PATH lib$WM_COMPILER_LIB_ARCH
# GMP/MPFR may have already been added with ThirdParty compiler, but cannot
# be certain so add here. Any duplicates will be removed later.
_foamAddLibAuto "$GMP_ARCH_PATH" # No fallback libdir
_foamAddLibAuto "$MPFR_ARCH_PATH" # No fallback libdir
_foamAddLibAuto $GMP_ARCH_PATH # No fallback libdir
_foamAddLibAuto $MPFR_ARCH_PATH # No fallback libdir
unset boost_version cgal_version

View File

@ -5,7 +5,7 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2016-2025 OpenCFD Ltd.
# Copyright (C) 2016-2021 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -47,7 +47,7 @@ fi
if command -v _foamAddLibAuto >/dev/null # Normal sourcing (not makeFFTW)
then
_foamAddLibAuto "$FFTW_ARCH_PATH" "lib$WM_COMPILER_LIB_ARCH"
_foamAddLibAuto $FFTW_ARCH_PATH lib$WM_COMPILER_LIB_ARCH
unset fftw_version

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, distributed under GPL-3.0-or-later.
@ -36,9 +36,9 @@ then
# Normal sourcing (not makeAdios2)
# Only add to PATH if the directory really exists
if _foamAddLibAuto "$ADIOS2_ARCH_PATH"
if _foamAddLibAuto $ADIOS2_ARCH_PATH
then
_foamAddPath "$ADIOS2_ARCH_PATH"/bin
_foamAddPath $ADIOS2_ARCH_PATH/bin
fi
unset adios2_version

View File

@ -5,7 +5,7 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2024-2025 OpenCFD Ltd.
# Copyright (C) 2024 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -41,7 +41,7 @@ if command -v _foamAddLibAuto >/dev/null
then
# Normal sourcing (not makeHDF5)
_foamAddLibAuto "$HDF5_ARCH_PATH"
_foamAddLibAuto $HDF5_ARCH_PATH
unset hdf5_version

View File

@ -5,7 +5,7 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2025 OpenCFD Ltd.
# Copyright (C) 2018-2024 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -41,7 +41,7 @@ if command -v _foamAddLibAuto >/dev/null
then
# Normal sourcing (not makeHYPRE)
_foamAddLibAuto "$HYPRE_ARCH_PATH"
_foamAddLibAuto $HYPRE_ARCH_PATH
unset hypre_version

View File

@ -5,7 +5,7 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2025 OpenCFD Ltd.
# Copyright (C) 2018-2024 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -41,7 +41,7 @@ if command -v _foamAddLibAuto >/dev/null
then
# Normal sourcing (not makePETSC)
_foamAddLibAuto "$PETSC_ARCH_PATH"
_foamAddLibAuto $PETSC_ARCH_PATH
unset petsc_version

View File

@ -6,7 +6,7 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2016-2025 OpenCFD Ltd.
# Copyright (C) 2016-2022 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -70,21 +70,13 @@ Linux)
;;
# arm64 or x86_64 architectures
# Note: /usr/bin/{gcc,g++} normally just symlinks to clang/clang++
# which may not behave as expected.
Darwin)
WM_ARCH=darwin64
# Defult to clang (not gcc) as system compiler
if [ "$WM_COMPILER" = Gcc ]
then
# Honour use of gcc, when version=... is specifed in WM_COMPILE_CONTROL
# (eg, gcc installed via homebrew)
case "$WM_COMPILE_CONTROL" in
(*version=*) ;;
(*)
WM_COMPILER=Clang
echo "openfoam (darwin): using clang instead of gcc" 1>&2
;;
esac
WM_COMPILER=Clang
echo "openfoam (darwin): using clang instead of gcc" 1>&2
fi
;;
@ -225,8 +217,8 @@ _foamEtc -config compiler
# ThirdParty base for compilers
archDir="$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH"
case "${WM_COMPILER_TYPE}/${WM_COMPILER}" in
(ThirdParty/Gcc*)
case "$WM_COMPILER_TYPE-$WM_COMPILER" in
ThirdParty-Gcc*)
gccDir="$archDir/$gcc_version"
gmpDir="$archDir/${gmp_version:-gmp-system}"
mpfrDir="$archDir/${mpfr_version:-mpfr-system}"
@ -267,7 +259,7 @@ GCC_NOT_FOUND
fi
;;
(ThirdParty/Clang*)
ThirdParty-Clang*)
clangDir="$archDir/$clang_version"
# Check that the compiler directory can be found
@ -293,11 +285,11 @@ CLANG_NOT_FOUND
fi
;;
(/* | system/* | ThirdParty/*)
-* | system-* | ThirdParty-*)
# Using empty (system), system compiler or other ThirdParty compiler
;;
(*)
*)
/bin/cat << UNKNOWN_TYPE 1>&2
===============================================================================
Unknown WM_COMPILER_TYPE="$WM_COMPILER_TYPE" - treating as 'system'

View File

@ -1,30 +0,0 @@
#----------------------------------*-sh-*--------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2025 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# File
# etc/config.sh/umpire
# [experimental]
#
# Description
# Setup for UMPIRE include/libraries (usually ThirdParty installation).
#
# Note
# No csh version. This file is only used by wmake.
#
#------------------------------------------------------------------------------
# USER EDITABLE PART: Changes made here may be lost with the next upgrade
umpire_version=umpire-2025.03.0
export UMPIRE_ARCH_PATH="$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$umpire_version"
# END OF (NORMAL) USER EDITABLE PART
#------------------------------------------------------------------------------

View File

@ -147,15 +147,6 @@ OptimisationSwitches
// >= 3 : when there are more than N nodes
nodeComms.min 0;
// Selection of topology-aware routines (bitmask)
// 0: disabled [default]
// 1: broadcast [MPI]
// 4: gather/all-gather [MPI]
// 16: combine (reduction) [manual algorithm]
// 32: mapGather (reduction) [manual algorithm]
// 64: gatherList/scatterList [manual algorithm]
topoControl 0;
// Transfer double as float for processor boundaries. Mostly defunct.
floatTransfer 0;

View File

@ -3,13 +3,13 @@ MSwindows.C
cpuInfo/cpuInfo.C
memInfo/memInfo.C
signals/sigFpe.cxx
signals/sigInt.cxx
signals/sigQuit.cxx
signals/sigSegv.cxx
signals/sigStopAtWriteNow.cxx
signals/sigWriteNow.cxx
signals/timer.cxx
signals/sigFpe.C
signals/sigInt.C
signals/sigQuit.C
signals/sigSegv.C
signals/sigStopAtWriteNow.C
signals/sigWriteNow.C
signals/timer.C
fileStat/fileStat.C

View File

@ -36,9 +36,11 @@ License
#include "Switch.H"
#include <float.h> // For *fp functions
#include <algorithm>
#include <limits>
// File-local functions
#include "signalMacros.cxx"
#include "signalMacros.C"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -194,15 +196,37 @@ void Foam::sigFpe::unset(bool verbose)
}
void Foam::sigFpe::fillNan(UList<float>& list)
void Foam::sigFpe::fillNan(char* buf, size_t count)
{
sigFpe::fill_with_NaN(list.data(), list.size());
if (!buf || !count) return;
// Fill with signaling_NaN
const scalar val = std::numeric_limits<scalar>::signaling_NaN();
// Can dispatch with
// - std::execution::parallel_unsequenced_policy
// - std::execution::unsequenced_policy
std::fill_n
(
reinterpret_cast<scalar*>(buf), (count/sizeof(scalar)), val
);
}
void Foam::sigFpe::fillNan(UList<double>& list)
void Foam::sigFpe::fillNan(UList<scalar>& list)
{
sigFpe::fill_with_NaN(list.data(), list.size());
if (list.empty()) return;
// Fill with signaling_NaN
const scalar val = std::numeric_limits<scalar>::signaling_NaN();
// Can dispatch with
// - std::execution::parallel_unsequenced_policy
// - std::execution::unsequenced_policy
std::fill_n
(
list.data(), list.size(), val
);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2025 OpenCFD Ltd.
Copyright (C) 2018-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -50,15 +50,13 @@ Description
restores original). The class behaves as a singleton.
SourceFiles
sigFpe.cxx
sigFpe.C
\*---------------------------------------------------------------------------*/
#ifndef Foam_sigFpe_H
#define Foam_sigFpe_H
#include <algorithm>
#include <limits>
#include <cstddef> // For std::size_t
#include "scalarFwd.H"
@ -98,23 +96,6 @@ class sigFpe
//- Handler for caught signals - ends job and prints stack
static void sigHandler(int);
//- Fill (float | double) buffer with signalling NaN
template<class FloatType>
inline static void fill_with_NaN(FloatType* buf, size_t count)
{
if (buf && count)
{
const auto val =
std::numeric_limits<FloatType>::signaling_NaN();
// [float|double] so do not need std::uninitialized_fill_n()
// Can dispatch with
// - std::execution::par_unseq
// - std::execution::unseq
std::fill_n(buf, count, val);
}
}
public:
@ -143,15 +124,6 @@ public:
//- True if NaN memory initialisation is currently active.
static bool nanActive() noexcept { return nanActive_; }
//- Set NaN memory initialisation on/off.
// \return the previous value
static bool nanActive(bool on) noexcept
{
bool old(nanActive_);
nanActive_ = on;
return old;
}
//- Activate SIGFPE handler when FOAM_SIGFPE is enabled.
//- Activate fill memory with signaling_NaN when FOAM_SETNAN is enabled
static void set(bool verbose=false);
@ -159,37 +131,11 @@ public:
//- Deactivate SIGFPE handler and NaN memory initialisation
static void unset(bool verbose=false);
//- Fill data block with signaling_NaN values
static void fillNan(char* buf, size_t count);
//- Fill data block with signaling_NaN values if nanActive().
//- Does a reinterpret to \c Foam::scalar
inline static void fillNan_if(void* buf, size_t count)
{
if (nanActive_)
{
fill_with_NaN
(
reinterpret_cast<Foam::scalar*>(buf),
(count/sizeof(Foam::scalar))
);
}
}
//- Fill data block with signaling_NaN values.
//- Does a reinterpret to \c Foam::scalar
static void fillNan(char* buf, size_t count)
{
fill_with_NaN
(
reinterpret_cast<Foam::scalar*>(buf),
(count/sizeof(Foam::scalar))
);
}
//- Fill data block with (float) signaling_NaN values
static void fillNan(UList<float>& list);
//- Fill data block with (double) signaling_NaN values
static void fillNan(UList<double>& list);
//- Fill data block with signaling_NaN values
static void fillNan(UList<scalar>& list);
// Helpers

View File

@ -33,7 +33,7 @@ License
#include "IOstreams.H"
// File-local functions
#include "signalMacros.cxx"
#include "signalMacros.C"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

View File

@ -41,7 +41,7 @@ See also
Foam::JobInfo
SourceFiles
sigInt.cxx
sigInt.C
\*---------------------------------------------------------------------------*/

View File

@ -33,7 +33,7 @@ License
#include "IOstreams.H"
// File-local functions
#include "signalMacros.cxx"
#include "signalMacros.C"
// NOTE: SIGBREAK is the best alternative to SIGQUIT on windows

View File

@ -40,7 +40,7 @@ See also
Foam::JobInfo
SourceFiles
sigQuit.cxx
sigQuit.C
\*---------------------------------------------------------------------------*/

View File

@ -32,7 +32,7 @@ License
#include "IOstreams.H"
// File-local functions
#include "signalMacros.cxx"
#include "signalMacros.C"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

View File

@ -40,7 +40,7 @@ See also
Foam::JobInfo
SourceFiles
sigSegv.cxx
sigSegv.C
\*---------------------------------------------------------------------------*/

View File

@ -34,7 +34,7 @@ License
#include "Time.H"
// File-local functions
#include "signalMacros.cxx"
#include "signalMacros.C"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

View File

@ -32,7 +32,7 @@ Description
The interrupt is defined by OptimisationSwitches::stopAtWriteNowSignal
SourceFiles
sigStopAtWriteNow.cxx
sigStopAtWriteNow.C
See also
Foam::JobInfo

View File

@ -33,7 +33,7 @@ License
#include "Time.H"
// File-local functions
#include "signalMacros.cxx"
#include "signalMacros.C"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

View File

@ -32,7 +32,7 @@ Description
The interrupt is defined by OptimisationSwitches::writeNowSignal
SourceFiles
sigWriteNow.cxx
sigWriteNow.C
\*---------------------------------------------------------------------------*/

View File

@ -27,7 +27,7 @@ Description
File-local code for setting/resetting signal handlers.
SourceFiles
signalMacros.cxx
signalMacros.C
\*---------------------------------------------------------------------------*/

View File

@ -39,7 +39,7 @@ License
#include <windows.h>
// File-local functions
#include "signalMacros.cxx"
#include "signalMacros.C"
#undef SIGALRM
#define SIGALRM 14

View File

@ -57,7 +57,7 @@ Note
?something to do with stack frames.
SourceFiles
timer.cxx
timer.C
\*---------------------------------------------------------------------------*/

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