Merge remote-tracking branch 'origin/master' into develop

This commit is contained in:
Andrew Heather
2025-06-27 09:41:03 +01:00
19 changed files with 210 additions and 122 deletions

View File

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

View File

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

View File

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

View File

@ -60,6 +60,9 @@ Description
// Flex may use register, which is deprecated and incompatible with C++17
#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;

View File

@ -56,6 +56,9 @@ Description
// Flex may use register, which is deprecated and incompatible with C++17
#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
#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
#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;

View File

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

View File

@ -44,6 +44,9 @@ Description
// Flex may use register, which is deprecated and incompatible with C++17
#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;

View File

@ -183,7 +183,8 @@ void Foam::zoneDistribute::setUpCommforZone
Foam::List<Foam::label> Foam::zoneDistribute::getCyclicPatches
(
const label celli,
const label globalIdx
const label globalIdx,
const vector globalIdxCellCentre
) const
{
// Initialise cyclic patch label list
@ -197,26 +198,26 @@ Foam::List<Foam::label> Foam::zoneDistribute::getCyclicPatches
const polyBoundaryMesh& bMesh = mesh_.boundaryMesh();
// Making list of cyclic patches to which celli belongs
List<label> celliCyclicPatches;
forAll(bMesh, patchi)
{
if (isA<cyclicPolyPatch>(bMesh[patchi]))
{
// Note: Probably not efficient due to use of found(celli) but
// typically only used for very few cells (interface cells and their
// point neighbours on cyclic boundaries).
if (bMesh[patchi].faceCells().found(celli))
{
celliCyclicPatches.append(patchi);
}
}
}
// So celli belongs to at least one cyclic patch.
// Let us figure out which.
if (globalNumbering_.isLocal(globalIdx)) // celli and globalIdx on same proc
{
// Making list of cyclic patches to which celli belongs
List<label> celliCyclicPatches;
forAll(bMesh, patchi)
{
if (isA<cyclicPolyPatch>(bMesh[patchi]))
{
// Note: Probably not efficient due to use of found(celli) but
// typically only used for very cells (interface cells and their
// point neighbours on cyclic boundaries).
if (bMesh[patchi].faceCells().found(celli))
{
celliCyclicPatches.append(patchi);
}
}
}
// Get all local point neighbor cells of celli, i.e. all point
// neighbours that are not on the other side of a cyclic patch.
List<label> localPointNeiCells(0);
@ -243,14 +244,14 @@ Foam::List<Foam::label> Foam::zoneDistribute::getCyclicPatches
{
for (const label patchi : celliCyclicPatches)
{
// find the corresponding cyclic neighbor patch ID
// Find the corresponding cyclic neighbor patch ID
const cyclicPolyPatch& cpp =
static_cast<const cyclicPolyPatch&>(bMesh[patchi]);
const label neiPatch = cpp.neighbPatchID();
// Check if the cell globalIdx is on neiPatch.
// If it is, append neiPatch to list of
// If it is, append neiPatch to list of patches to return
if (bMesh[neiPatch].faceCells().found(localIdx))
{
patches.append(neiPatch);
@ -267,75 +268,71 @@ Foam::List<Foam::label> Foam::zoneDistribute::getCyclicPatches
}
else // celli and globalIdx on differet processors
{
// Note: The following is needed if a celli is located at the interface
// (plicRDF), on a cyclic patch and a processor patch. In this case
// globalIdx may be on a different processor, but requires the
// transformation from a cyclic patch on the processor of celli.
List<label> cyclicID(3, -1);
List<vector> separationVectors(3, vector(0,0,0));
scalar distance = GREAT;
const List<label>& faces = mesh_.cells()[celli];
// Loop over all faces of celli and find cyclic patches
for (const label facei : faces)
forAll(celliCyclicPatches, cID)
{
if (mesh_.isInternalFace(facei)) continue;
cyclicID[cID] = celliCyclicPatches[cID];
const label patchi = bMesh.whichPatch(facei);
const cyclicPolyPatch* cpp = isA<cyclicPolyPatch>(bMesh[patchi]);
const label& patchI = celliCyclicPatches[cID];
const cyclicPolyPatch& cpp =
static_cast<const cyclicPolyPatch&>(bMesh[patchI]);
if (cpp)
if(cpp.transform() == coupledPolyPatch::transformType::ROTATIONAL)
{
// Get the neighbor cell across the cyclic face
const label cycNeiPatch = cpp->neighbPatchID();
const label cycNeiCell =
bMesh[cycNeiPatch].faceCells()[facei - cpp->start()];
const List<label>& cycNeiCellFaces = mesh_.cells()[cycNeiCell];
FatalErrorInFunction
<< "Rotational cyclic patches are not supported in parallel.\n"
<< "Try to decompose the domain so that the rotational cyclic patch "
<< "is not split in between processors."
<< exit(FatalError);
}
cpp.neighbPatch().transformPosition(separationVectors[cID], 0);
}
// Loop over all the faces of the neighbor cell
for (const label cycNeiCellFace : cycNeiCellFaces)
for(int i = 0; i < 2; i++)
{
for(int j = 0; j < 2; j++)
{
for(int k = 0; k < 2; k++)
{
if (mesh_.isInternalFace(cycNeiCellFace))
vector separation = i*separationVectors[0]
+ j*separationVectors[1]
+ k*separationVectors[2];
scalar testDistance = mag
(
(globalIdxCellCentre - separation)
-
mesh_.C()[celli]
);
if(debug) Info << "testDistance " << testDistance << endl;
if( testDistance < distance )
{
continue;
}
distance = testDistance;
patches = List<label>(0);
List<label> applyCyclic({i,j,k});
// Check if the neighbor cell has processor patches
const label neiPatch = bMesh.whichPatch(cycNeiCellFace);
const processorPolyPatch* ppp =
isA<processorPolyPatch>(bMesh[neiPatch]);
if(debug) Info << "distance " << distance << endl;
if(debug) Info << "separation " << separation << endl;
if(debug) Info << "applyCyclic " << applyCyclic << endl;
if (ppp)
{
// Avoid duplicate entries
if (patches.found(cycNeiPatch))
for(int n = 0; n < 3; n++)
{
continue;
}
// Since we can not access any information on globalIdx
// we use the cell centre map from the stencil to
// identify the cell.
const label localFaceID = cycNeiCellFace - ppp->start();
const vector neiCentre =
ppp->neighbFaceCellCentres()[localFaceID];
forAll(cyclicCentres_()[celli], k)
{
if
(
(
mag(cyclicCentres_()[celli][k] - neiCentre)
< 100*SMALL
)
&& (stencil_[celli][k] == globalIdx)
)
if(cyclicID[n] != -1 && applyCyclic[n] == 1)
{
patches.append(cycNeiPatch);
// Here an alternative might be to append patchi
// and do:
// cpp.transformPosition()
// instead of
// cpp.neighbPatch().transformPosition()
// in getValue()
const cyclicPolyPatch& cpp =
static_cast<const cyclicPolyPatch&>
(
bMesh[cyclicID[n]]
);
if(debug)
{
Info << "cpp.name() " << cpp.name() << endl;
}
patches.append(cpp.neighbPatchID());
}
}
}

View File

@ -186,7 +186,7 @@ public:
//- Finds and returns list of all cyclic patch labels to which celli's
// point neighbour cell, globalIdx, belongs. celli and globalIdx touch
// in at least one point on these patces. globalIdx typically belongs
// in at least one point on these patches. globalIdx typically belongs
// to stencil_[celli]. The returned label list is used to transform
// positions across cyclic boundaries e.g. to be able to calculate
// distances between cell centres and interface centres in plicRDF
@ -194,7 +194,8 @@ public:
List<label> getCyclicPatches
(
const label celli,
const label globalIdx
const label globalIdx,
const vector globalIdxCellCentre
) const;
//- Gives patchNumber and patchFaceNumber for a given

View File

@ -174,7 +174,12 @@ Foam::Map<Foam::Field<Type>> Foam::zoneDistribute::getPositionFields
List<label> cyclicPatches(0);
if(checkTransformation)
{
cyclicPatches = getCyclicPatches(celli, gblIdx);
cyclicPatches = getCyclicPatches
(
celli,
gblIdx,
getValue(phi, neiValues, gblIdx)
);
}
tmpField.append

View File

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

View File

@ -5,8 +5,8 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2007-2023 PCOpt/NTUA
Copyright (C) 2013-2023 FOSS GP
Copyright (C) 2007-2025 PCOpt/NTUA
Copyright (C) 2013-2025 FOSS GP
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -118,11 +118,11 @@ scalar objectiveUniformityCellZone::J()
const volVectorField& U = vars_.UInst();
const scalarField& V = mesh_.V().field();
for (const label zI : zones_)
forAll(zones_, zI)
{
const cellZone& zoneI = mesh_.cellZones()[zI];
scalarField VZone(V, zoneI);
vectorField UZone(U.primitiveField(), zoneI);
const cellZone& cz = mesh_.cellZones()[zones_[zI]];
scalarField VZone(V, cz);
vectorField UZone(U.primitiveField(), cz);
volZone_[zI] = gSum(VZone);
UMean_[zI] = gSum(UZone*VZone)/volZone_[zI];
UVar_[zI] = gSum(magSqr(UZone - UMean_[zI])*VZone)/volZone_[zI];
@ -138,10 +138,10 @@ void objectiveUniformityCellZone::update_dJdv()
{
const volVectorField& U = vars_.U();
for (const label zI : zones_)
forAll(zones_, zI)
{
const cellZone& zoneI = mesh_.cellZones()[zI];
for (const label cellI : zoneI)
const cellZone& cz = mesh_.cellZones()[zones_[zI]];
for (const label cellI : cz)
{
dJdvPtr_()[cellI] = (U[cellI] - UMean_[zI])/volZone_[zI];
}
@ -154,10 +154,10 @@ void objectiveUniformityCellZone::update_divDxDbMultiplier()
volScalarField& divDxDbMult = divDxDbMultPtr_();
const volVectorField& U = vars_.U();
for (const label zI : zones_)
forAll(zones_, zI)
{
const cellZone& zoneI = mesh_.cellZones()[zI];
for (const label cellI : zoneI)
const cellZone& cz = mesh_.cellZones()[zones_[zI]];
for (const label cellI : cz)
{
divDxDbMult[cellI] =
0.5*(magSqr(U[cellI] - UMean_[zI]) - UVar_[zI])/volZone_[zI];

View File

@ -1,6 +1,7 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments -no-recursion "$@"
cd "${0%/*}" || exit # Run from this directory
set -- -no-recursion "$@" # Parse arguments only
. ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments
. ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions # Require wmake functions
. ${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
#pragma clang diagnostic ignored "-Wdeprecated-register"
// A 'nothing' define to effectively remove from code as well (issue #3337)
#undef register
#define register
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -260,7 +260,7 @@ const Foam::volScalarField& Foam::reconstructedDistanceFunction::constructRDF
const labelListList& stencil = distribute.getStencil();
forAll(nextToInterface,celli)
forAll(nextToInterface, celli)
{
if (nextToInterface[celli])
{
@ -289,7 +289,17 @@ const Foam::volScalarField& Foam::reconstructedDistanceFunction::constructRDF
centre,
mapCentres,
gblIdx,
distribute.getCyclicPatches(celli, gblIdx)
distribute.getCyclicPatches
(
celli,
gblIdx,
distribute.getValue
(
centre,
mapCentres,
gblIdx
)
)
)
);
vector distanceToIntSeg(c - p);
@ -341,7 +351,12 @@ const Foam::volScalarField& Foam::reconstructedDistanceFunction::constructRDF
forAll(stencil[pCellI], j)
{
const label gblIdx = stencil[pCellI][j];
vector n = -distribute.getValue(normal, mapNormal, gblIdx);
vector n = -distribute.getValue
(
normal,
mapNormal,
gblIdx
);
if (mag(n) != 0)
{
n /= mag(n);
@ -352,7 +367,17 @@ const Foam::volScalarField& Foam::reconstructedDistanceFunction::constructRDF
centre,
mapCentres,
gblIdx,
distribute.getCyclicPatches(pCellI, gblIdx)
distribute.getCyclicPatches
(
pCellI,
gblIdx,
distribute.getValue
(
centre,
mapCentres,
gblIdx
)
)
)
);
vector distanceToIntSeg(c - p);

View File

@ -103,7 +103,12 @@ void Foam::reconstruction::plicRDF::interpolateNormal()
centre_,
mapCentre,
gblIdx,
exchangeFields.getCyclicPatches(celli, gblIdx)
exchangeFields.getCyclicPatches
(
celli,
gblIdx,
exchangeFields.getValue(mesh_.C(), mapCC, gblIdx)
)
)
);
vector distanceToIntSeg = (tensor::I- n*n) & (p - centre);
@ -157,7 +162,12 @@ void Foam::reconstruction::plicRDF::interpolateNormal()
exchangeFields.getPosition
(
mesh_.C(), mapCC, gblIdx,
exchangeFields.getCyclicPatches(celli, gblIdx)
exchangeFields.getCyclicPatches
(
celli,
gblIdx,
exchangeFields.getValue(mesh_.C(), mapCC, gblIdx)
)
)
);
alphaValues.append
@ -208,7 +218,12 @@ void Foam::reconstruction::plicRDF::gradSurf(const volScalarField& phi)
exchangeFields.getPosition
(
mesh_.C(), mapCC, gblIdx,
exchangeFields.getCyclicPatches(celli, gblIdx)
exchangeFields.getCyclicPatches
(
celli,
gblIdx,
exchangeFields.getValue(mesh_.C(), mapCC, gblIdx)
)
)
);
phiValues.append

View File

@ -1,2 +1,2 @@
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