Compare commits

...

6 Commits

Author SHA1 Message Date
99a3f10729 ENH: AMIInterpolation: make matching more robust 2025-08-06 11:05:43 +01:00
0fa124af45 ENH: subsetMesh: support for mesh maps 2025-05-29 17:27:51 +01:00
b7ce6bf69d CONFIG: inject -no-recursion into the argument list (#3198)
- sourcing a file with '-no-recursion "$@"' does not work with dash.
  Need to modify the argument list directly.
2025-03-19 15:28:57 +01:00
0a53013499 BUG: foamReport mesh quantities are not parallel (fixes #3338) 2025-03-17 11:53:23 +01:00
47f2ff618d COMP: remove obsolete -fsimdmath flag for ARM64 (#3326) 2025-03-17 09:59:42 +01:00
47575aabf2 COMP: compilation with clang (c++17) and older flex files (fixes #3337)
- The register keyword has been removed from c++17 but old flex
  versions (version < 2.6.0) produce code including it, leading to
  compilation errors when using clang (despite disabling the diagnostic).
  gcc compiles but issues warnings.

- use '#define register' as empty as a workaround
2025-03-17 09:58:20 +01:00
17 changed files with 210 additions and 26 deletions

View File

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

View File

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

View File

@ -1,6 +1,7 @@
#!/bin/sh #!/bin/sh
cd "${0%/*}" || exit # Run from this directory cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments -no-recursion "$@" set -- -no-recursion "$@" # Parse arguments only
. ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments
. ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions # Require wmake functions . ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions # Require wmake functions
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -62,6 +62,9 @@ Description
// Flex may use register, which is deprecated and incompatible with C++17 // Flex may use register, which is deprecated and incompatible with C++17
#pragma clang diagnostic ignored "-Wdeprecated-register" #pragma clang diagnostic ignored "-Wdeprecated-register"
// A 'nothing' define to effectively remove from code as well (issue #3337)
#undef register
#define register
using namespace Foam; using namespace Foam;

View File

@ -56,6 +56,9 @@ Description
// Flex may use register, which is deprecated and incompatible with C++17 // Flex may use register, which is deprecated and incompatible with C++17
#pragma clang diagnostic ignored "-Wdeprecated-register" #pragma clang diagnostic ignored "-Wdeprecated-register"
// A 'nothing' define to effectively remove from code as well (issue #3337)
#undef register
#define register
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -63,6 +63,9 @@ Description
// Flex may use register, which is deprecated and incompatible with C++17 // Flex may use register, which is deprecated and incompatible with C++17
#pragma clang diagnostic ignored "-Wdeprecated-register" #pragma clang diagnostic ignored "-Wdeprecated-register"
// A 'nothing' define to effectively remove from code as well (issue #3337)
#undef register
#define register
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -51,6 +51,9 @@ Description
// Flex may use register, which is deprecated and incompatible with C++17 // Flex may use register, which is deprecated and incompatible with C++17
#pragma clang diagnostic ignored "-Wdeprecated-register" #pragma clang diagnostic ignored "-Wdeprecated-register"
// A 'nothing' define to effectively remove from code as well (issue #3337)
#undef register
#define register
using namespace Foam; using namespace Foam;

View File

@ -53,6 +53,7 @@ Description
#include "pointSet.H" #include "pointSet.H"
#include "ReadFields.H" #include "ReadFields.H"
#include "processorMeshes.H" #include "processorMeshes.H"
#include "IOmapDistributePolyMesh.H"
using namespace Foam; using namespace Foam;
@ -369,6 +370,11 @@ int main(int argc, char *argv[])
"Subset with cellZone(s) instead of cellSet." "Subset with cellZone(s) instead of cellSet."
" The command argument may be a list of words or regexs" " The command argument may be a list of words or regexs"
); );
argList::addBoolOption
(
"no-map",
"Suppress writing of map."
);
argList::addOption argList::addOption
( (
"resultTime", "resultTime",
@ -393,6 +399,7 @@ int main(int argc, char *argv[])
const bool useCellZone = args.found("zone"); const bool useCellZone = args.found("zone");
const bool overwrite = args.found("overwrite"); const bool overwrite = args.found("overwrite");
const bool noMap = args.found("no-map");
const bool specifiedInstance = args.readIfPresent const bool specifiedInstance = args.readIfPresent
( (
"resultTime", "resultTime",
@ -663,8 +670,6 @@ int main(int argc, char *argv[])
Info<< "Writing subsetted mesh and fields to time " << runTime.timeName() Info<< "Writing subsetted mesh and fields to time " << runTime.timeName()
<< endl; << endl;
subsetter.subMesh().write(); subsetter.subMesh().write();
processorMeshes::removeFiles(subsetter.subMesh());
auto* subPointMeshPtr = auto* subPointMeshPtr =
subsetter.subMesh().thisDb().findObject<pointMesh> subsetter.subMesh().thisDb().findObject<pointMesh>
( (
@ -676,6 +681,115 @@ int main(int argc, char *argv[])
subPointMesh.setInstance(subsetter.subMesh().facesInstance()); subPointMesh.setInstance(subsetter.subMesh().facesInstance());
subPointMesh.write(); subPointMesh.write();
} }
processorMeshes::removeFiles(subsetter.subMesh());
if (!noMap)
{
const auto& subMesh = subsetter.subMesh();
const auto& pbm = mesh.boundaryMesh();
labelList patchStarts(pbm.size());
labelList patchNMeshPoints(pbm.size());
for (const auto& pp : pbm)
{
patchStarts[pp.index()] = pp.start();
patchNMeshPoints[pp.index()] = pp.nPoints();
}
const label myProcNo = UPstream::myProcNo(mesh.comm());
// cellMap
labelListList cellSubMap(UPstream::nProcs(mesh.comm()));
cellSubMap[myProcNo] = subsetter.cellMap();
labelListList cellConstructMap(UPstream::nProcs(mesh.comm()));
cellConstructMap[myProcNo] = identity(subMesh.nCells());
mapDistribute cellMap
(
subMesh.nCells(),
std::move(cellSubMap),
std::move(cellConstructMap),
false,
false,
mesh.comm()
);
// faceMap
labelListList faceSubMap(UPstream::nProcs(mesh.comm()));
faceSubMap[myProcNo] = subsetter.faceMap();
labelListList faceConstructMap(UPstream::nProcs(mesh.comm()));
faceConstructMap[myProcNo] = identity(subMesh.nFaces());
mapDistribute faceMap
(
subMesh.nFaces(),
std::move(faceSubMap),
std::move(faceConstructMap),
false,
false,
mesh.comm()
);
// pointMap
labelListList pointSubMap(UPstream::nProcs(mesh.comm()));
pointSubMap[myProcNo] = subsetter.pointMap();
labelListList pointConstructMap(UPstream::nProcs(mesh.comm()));
pointConstructMap[myProcNo] = identity(subMesh.nPoints());
mapDistribute pointMap
(
subMesh.nPoints(),
std::move(pointSubMap),
std::move(pointConstructMap),
false,
false,
mesh.comm()
);
// patchMap
labelListList patchSubMap(UPstream::nProcs(mesh.comm()));
patchSubMap[myProcNo] = identity(pbm.size());
labelListList patchConstructMap(UPstream::nProcs(mesh.comm()));
patchConstructMap[myProcNo] = identity(pbm.size()); // or subMesh?
mapDistribute patchMap
(
subMesh.nPoints(),
std::move(patchSubMap),
std::move(patchConstructMap),
false,
false,
mesh.comm()
);
mapDistributePolyMesh map
(
mesh.nPoints(), // old points
mesh.nFaces(), // old faces
mesh.nCells(), // old cells
std::move(patchStarts),
std::move(patchNMeshPoints),
std::move(pointMap),
std::move(faceMap),
std::move(cellMap),
std::move(patchMap)
);
const IOobject io
(
"parentMeshAddressing",
subMesh.facesInstance(),
fvMesh::meshSubDir,
subMesh.thisDb(),
IOobjectOption::NO_READ,
IOobjectOption::NO_WRITE,
IOobjectOption::NO_REGISTER
);
Info<< "Writing map from subsetted to original mesh to "
<< io.objectRelPath() << endl;
IOmapDistributePolyMeshRef(io, map).write();
}
// Volume fields // Volume fields

View File

@ -1,6 +1,7 @@
#!/bin/sh #!/bin/sh
cd "${0%/*}" || exit # Run from this directory cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments -no-recursion "$@" set -- -no-recursion "$@" # Parse arguments only
. ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments
. ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions # Require wmake functions . ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions # Require wmake functions
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -44,6 +44,9 @@ Description
// Flex may use register, which is deprecated and incompatible with C++17 // Flex may use register, which is deprecated and incompatible with C++17
#pragma clang diagnostic ignored "-Wdeprecated-register" #pragma clang diagnostic ignored "-Wdeprecated-register"
// A 'nothing' define to effectively remove from code as well (issue #3337)
#undef register
#define register
using namespace Foam; using namespace Foam;

View File

@ -51,6 +51,26 @@ namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::refPtr<Foam::fvMesh>
Foam::fvMesh::parentMesh(const objectRegistry& obr) const
{
const fvMesh* meshPtr = isA<fvMesh>(obr);
if (meshPtr)
{
return refPtr<fvMesh>(*meshPtr);
}
else if (obr.isTimeDb())
{
return refPtr<fvMesh>();
}
else
{
return parentMesh(obr.parent());
}
}
void Foam::fvMesh::clearGeomNotOldVol() void Foam::fvMesh::clearGeomNotOldVol()
{ {
meshObject::clearUpto meshObject::clearUpto

View File

@ -164,6 +164,9 @@ protected:
void makeCf() const; void makeCf() const;
//- Helper: search for parent mesh
refPtr<fvMesh> parentMesh(const objectRegistry& obr) const;
//- No copy construct //- No copy construct
fvMesh(const fvMesh&) = delete; fvMesh(const fvMesh&) = delete;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2024 OpenCFD Ltd. Copyright (C) 2024-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -32,6 +32,7 @@ License
#include "cloud.H" #include "cloud.H"
#include "foamVersion.H" #include "foamVersion.H"
#include "fvMesh.H" #include "fvMesh.H"
#include "globalMeshData.H"
#include "IFstream.H" #include "IFstream.H"
#include "stringOps.H" #include "stringOps.H"
#include "substitutionModel.H" #include "substitutionModel.H"
@ -56,7 +57,7 @@ void Foam::functionObjects::foamReport::setStaticBuiltins()
substitutionModel::addBuiltinStr substitutionModel::addBuiltinStr
( (
"OF_PROC_ZERO_DIR", "OF_PROC_ZERO_DIR",
Pstream::parRun() ? "processor0" : "" UPstream::parRun() ? "processor0" : ""
); );
substitutionModel::addBuiltin("OF_API", foamVersion::api); substitutionModel::addBuiltin("OF_API", foamVersion::api);
@ -72,26 +73,45 @@ void Foam::functionObjects::foamReport::setStaticBuiltins()
substitutionModel::addBuiltinStr("OF_CASE_PATH", argList::envGlobalPath()); substitutionModel::addBuiltinStr("OF_CASE_PATH", argList::envGlobalPath());
substitutionModel::addBuiltinStr("OF_CASE_NAME", time().globalCaseName()); substitutionModel::addBuiltinStr("OF_CASE_NAME", time().globalCaseName());
substitutionModel::addBuiltin("OF_NPROCS", Pstream::nProcs()); substitutionModel::addBuiltin("OF_NPROCS", UPstream::nProcs());
// Set mesh builtins when there is only 1 mesh // Set mesh builtins when there is only 1 mesh
const auto meshes = time_.lookupClass<fvMesh>(); const auto meshes = time_.csorted<fvMesh>();
if (meshes.size() == 1) if (meshes.size() == 1)
{ {
const auto& mesh = *(meshes.begin().val()); const auto& mesh = meshes[0];
substitutionModel::addBuiltin("OF_MESH_NCELLS", mesh.nCells());
substitutionModel::addBuiltin("OF_MESH_NFACES", mesh.nFaces()); substitutionModel::addBuiltin
substitutionModel::addBuiltin("OF_MESH_NEDGES", mesh.nEdges()); (
substitutionModel::addBuiltin("OF_MESH_NPOINTS", mesh.nPoints()); "OF_MESH_NCELLS",
mesh.globalData().nTotalCells()
);
substitutionModel::addBuiltin
(
"OF_MESH_NFACES",
mesh.globalData().nTotalFaces()
);
substitutionModel::addBuiltin
(
"OF_MESH_NEDGES",
returnReduce(mesh.nEdges(), sumOp<label>())
);
substitutionModel::addBuiltin
(
"OF_MESH_NPOINTS",
mesh.globalData().nTotalPoints()
);
substitutionModel::addBuiltin substitutionModel::addBuiltin
( (
"OF_MESH_NINTERNALFACES", "OF_MESH_NINTERNALFACES",
mesh.nInternalFaces() returnReduce(mesh.nInternalFaces(), sumOp<label>())
); );
substitutionModel::addBuiltin substitutionModel::addBuiltin
( (
"OF_MESH_NBOUNDARYFACES", "OF_MESH_NBOUNDARYFACES",
mesh.nBoundaryFaces() // TBD: use mesh.boundaryMesh().nNonProcessorFaces() ?
returnReduce(mesh.nBoundaryFaces(), sumOp<label>())
); );
substitutionModel::addBuiltin substitutionModel::addBuiltin
( (
@ -123,8 +143,8 @@ void Foam::functionObjects::foamReport::setDynamicBuiltins()
substitutionModel::setBuiltinStr("OF_DATE_NOW", clock::date()); substitutionModel::setBuiltinStr("OF_DATE_NOW", clock::date());
substitutionModel::setBuiltinStr("OF_CLOCK_NOW", clock::clockTime()); substitutionModel::setBuiltinStr("OF_CLOCK_NOW", clock::clockTime());
substitutionModel::setBuiltin("OF_NREGIONS", time().names<fvMesh>().size()); substitutionModel::setBuiltin("OF_NREGIONS", time().count<fvMesh>());
substitutionModel::setBuiltin("OF_NCLOUDS", time().names<cloud>().size()); substitutionModel::setBuiltin("OF_NCLOUDS", time().count<cloud>());
} }

View File

@ -705,6 +705,8 @@ bool Foam::faceAreaWeightAMI::calculate
srcCentroids_[i].transfer(srcCtr[i]); srcCentroids_[i].transfer(srcCtr[i]);
} }
tgtAddress_.setSize(tgtAddr.size());
tgtWeights_.setSize(tgtWght.size());
forAll(tgtAddr, i) forAll(tgtAddr, i)
{ {
tgtAddress_[i].transfer(tgtAddr[i]); tgtAddress_[i].transfer(tgtAddr[i]);

View File

@ -1,6 +1,7 @@
#!/bin/sh #!/bin/sh
cd "${0%/*}" || exit # Run from this directory cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments -no-recursion "$@" set -- -no-recursion "$@" # Parse arguments only
. ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments
. ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions # Require wmake functions . ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions # Require wmake functions
. ${WM_PROJECT_DIR:?}/wmake/scripts/have_scotch . ${WM_PROJECT_DIR:?}/wmake/scripts/have_scotch

View File

@ -39,6 +39,9 @@ License
// Flex may use register, which is deprecated and incompatible with C++17 // Flex may use register, which is deprecated and incompatible with C++17
#pragma clang diagnostic ignored "-Wdeprecated-register" #pragma clang diagnostic ignored "-Wdeprecated-register"
// A 'nothing' define to effectively remove from code as well (issue #3337)
#undef register
#define register
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -1,2 +1,2 @@
c++DBUG = c++DBUG =
c++OPT = -ffp-contract=fast -ffast-math -O3 -funsafe-math-optimizations -fsimdmath -armpl c++OPT = -ffp-contract=fast -ffast-math -O3 -funsafe-math-optimizations -armpl