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

This commit is contained in:
Mark Olesen 2024-02-20 15:23:47 +01:00
commit 87eed74e42
8 changed files with 135 additions and 86 deletions

View File

@ -1,2 +1,2 @@
api=2312
patch=0
patch=240220

View File

@ -197,8 +197,8 @@ if ( "$FOAM_MPI" != dummy ) then
_foamAddLib "${FOAM_LIBBIN}/${FOAM_MPI}"
endif
# OpenFOAM user, group libraries
_foamAddLib "${FOAM_USER_LIBBIN}:${FOAM_SITE_LIBBIN}"
_foamAddLib "$FOAM_SITE_LIBBIN" # OpenFOAM group libraries
_foamAddLib "$FOAM_USER_LIBBIN" # OpenFOAM user libraries
if ( -d "$WM_PROJECT_DIR/doc/man1" ) then
_foamAddMan "$WM_PROJECT_DIR/doc"

View File

@ -229,8 +229,8 @@ then
_foamAddLib "$FOAM_LIBBIN/$FOAM_MPI"
fi
# OpenFOAM user, group libraries
_foamAddLib "$FOAM_USER_LIBBIN:$FOAM_SITE_LIBBIN"
_foamAddLib "$FOAM_SITE_LIBBIN" # OpenFOAM group libraries
_foamAddLib "$FOAM_USER_LIBBIN" # OpenFOAM user libraries
if [ -d "$WM_PROJECT_DIR/doc/man1" ]
then

@ -1 +1 @@
Subproject commit a7af00a48d3a4962a08aeea445c6f8db797bc823
Subproject commit 06b391bb475f0386342b6f9b7fe5496ae87e464f

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2019-2023 OpenCFD Ltd.
Copyright (C) 2019-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -133,7 +133,7 @@ Foam::schemesLookup::schemesLookup
obr.time().system(),
obr,
rOpt,
IOobject::NO_WRITE
IOobjectOption::NO_WRITE
),
fallback
),
@ -153,18 +153,23 @@ Foam::schemesLookup::schemesLookup
fluxRequiredDefault_(false),
steady_(false)
{
// Treat as MUST_READ_IF_MODIFIED whenever possible
// Treat as READ_MODIFIED whenever possible
if
(
readOpt() == IOobject::MUST_READ
readOpt() == IOobjectOption::MUST_READ
|| (isReadOptional() && headerOk())
)
{
readOpt(IOobject::MUST_READ_IF_MODIFIED);
readOpt(IOobjectOption::READ_MODIFIED);
addWatch();
}
if (readOpt() == IOobject::MUST_READ_IF_MODIFIED)
// Update: from values read or copied in
if
(
readOpt() == IOobjectOption::READ_MODIFIED
|| !dictionary::empty()
)
{
read(selectedDict());
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2023 OpenCFD Ltd.
Copyright (C) 2019-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -174,7 +174,7 @@ Foam::solution::solution
obr.time().system(),
obr,
rOpt,
IOobject::NO_WRITE
IOobjectOption::NO_WRITE
),
fallback
),
@ -184,18 +184,23 @@ Foam::solution::solution
eqnRelaxDict_(),
solvers_()
{
// Treat as MUST_READ_IF_MODIFIED whenever possible
// Treat as READ_MODIFIED whenever possible
if
(
readOpt() == IOobject::MUST_READ
readOpt() == IOobjectOption::MUST_READ
|| (isReadOptional() && headerOk())
)
{
readOpt(IOobject::MUST_READ_IF_MODIFIED);
readOpt(IOobjectOption::READ_MODIFIED);
addWatch();
}
if (readOpt() == IOobject::MUST_READ_IF_MODIFIED)
// Update: from values read or copied in
if
(
readOpt() == IOobjectOption::READ_MODIFIED
|| !dictionary::empty()
)
{
read(selectedDict());
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2023 OpenCFD Ltd.
Copyright (C) 2023-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -26,7 +26,6 @@ License
\*---------------------------------------------------------------------------*/
#include "triangulatedPatch.H"
#include "triPointRef.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -50,6 +49,8 @@ bool Foam::triangulatedPatch::randomPoint
// Find corresponding decomposed face triangle
// Note: triWght_ is sized nTri+1 (zero added at start)
//
// TBD: binary search with findLower(triWght_, c) ??
label trii = 0;
for (label i = 0; i < triWght_.size() - 1; ++i)
{
@ -62,11 +63,9 @@ bool Foam::triangulatedPatch::randomPoint
// Find random point in triangle
const pointField& points = patch_.points();
const face& tf = triFace_[trii];
const triPointRef tri(points[tf[0]], points[tf[1]], points[tf[2]]);
result = tri.randomPoint(rnd);
facei = triToFace_[trii];
result = triFace_[trii].tri(points).randomPoint(rnd);
facei = triFace_[trii].index();
celli = patch_.faceCells()[facei];
if (perturbTol_ > 0)
@ -97,7 +96,6 @@ Foam::triangulatedPatch::triangulatedPatch
patch_(patch),
perturbTol_(perturbTol),
triFace_(),
triToFace_(),
triWght_()
{
update();
@ -115,70 +113,95 @@ Foam::triangulatedPatch::triangulatedPatch
{}
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
void Foam::triangulatedPatch::triangulate
(
const polyPatch& pp,
List<labelledTri>& tris
)
{
const pointField& points = pp.points();
// Triangulate the patch faces and create addressing
label nTris = 0;
for (const face& f : pp)
{
nTris += f.nTriangles();
}
DynamicList<labelledTri> dynTris(nTris);
DynamicList<face> tfaces(8); // work array
label facei = 0;
for (const face& f : pp)
{
tfaces.clear();
f.triangles(points, tfaces);
for (const auto& t : tfaces)
{
dynTris.emplace_back(t[0], t[1], t[2], facei);
}
++facei;
}
tris.transfer(dynTris);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::triangulatedPatch::update()
{
triFace_.clear();
triWght_.clear();
triangulate(patch_, triFace_);
const pointField& points = patch_.points();
// Triangulate the patch faces and create addressing
DynamicList<label> triToFace(2*patch_.size());
DynamicList<face> triFace(2*patch_.size());
DynamicList<scalar> triWght(2*patch_.size());
DynamicList<face> tris(8);
const label myProci = UPstream::myProcNo();
const label numProc = UPstream::nProcs();
// Calculate the cumulative triangle weights
triWght_.resize_nocopy(triFace_.size()+1);
auto iter = triWght_.begin();
// Set zero value at the start of the tri area/weight list
triWght.push_back(0);
scalar patchArea = 0;
*iter = patchArea;
++iter;
forAll(patch_, facei)
// Calculate cumulative and total area (processor-local at this point)
for (const auto& t : triFace_)
{
const face& f = patch_[facei];
patchArea += t.mag(points);
tris.clear();
f.triangles(points, tris);
for (const auto& t : tris)
{
triToFace.push_back(facei);
triFace.push_back(t);
triWght.push_back(t.mag(points));
}
*iter = patchArea;
++iter;
}
scalarList procSumWght(Pstream::nProcs()+1, Zero);
procSumWght[Pstream::myProcNo()+1] = sum(triWght);
// FIXME: use allGatherList of subslice
scalarList procSumWght(numProc+1, Foam::zero{});
procSumWght[myProci+1] = patchArea;
Pstream::listCombineReduce(procSumWght, maxEqOp<scalar>());
// Convert to cumulative
for (label i = 1; i < procSumWght.size(); ++i)
{
// Convert to cumulative
procSumWght[i] += procSumWght[i-1];
}
const scalar offset = procSumWght[Pstream::myProcNo()];
forAll(triWght, i)
const scalar offset = procSumWght[myProci];
const scalar totalArea = procSumWght.back();
// Apply processor offset and normalise - for a global 0-1 interval
for (scalar& w : triWght_)
{
if (i)
{
// Convert to cumulative
triWght[i] += triWght[i-1];
}
// Apply processor offset
triWght[i] += offset;
w = (w + offset) / totalArea;
}
// Normalise
const scalar sumWght = procSumWght.back();
for (scalar& w : triWght)
{
w /= sumWght;
}
// Transfer to persistent storage
triFace_.transfer(triFace);
triToFace_.transfer(triToFace);
triWght_.transfer(triWght);
}
@ -190,6 +213,14 @@ bool Foam::triangulatedPatch::randomLocalPoint
label& celli
) const
{
if (triWght_.empty())
{
result = point::min;
facei = -1;
celli = -1;
return false;
}
const scalar c = rnd.position<scalar>(triWght_.front(), triWght_.back());
return randomPoint(rnd, c, result, facei, celli);
@ -204,20 +235,23 @@ bool Foam::triangulatedPatch::randomGlobalPoint
label& celli
) const
{
boolList valid(UPstream::nProcs(), false);
valid[UPstream::myProcNo()] = randomLocalPoint(rnd, result, facei, celli);
UPstream::listGatherValues(valid);
forAll(valid, proci)
if (UPstream::parRun())
{
// Choose first valid processor
if (valid[proci])
{
return (proci == UPstream::myProcNo());
}
}
const scalar c = rnd.sample01<scalar>();
const bool ok = randomPoint(rnd, c, result, facei, celli);
return false;
boolList valid(UPstream::listGatherValues(ok));
// Select the first valid processor
label proci = valid.find(true);
Pstream::broadcast(proci);
return (proci == UPstream::myProcNo());
}
else
{
return randomLocalPoint(rnd, result, facei, celli);
}
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2023 OpenCFD Ltd.
Copyright (C) 2023-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -35,6 +35,7 @@ Description
#define Foam_triangulatedPatch_H
#include "polyMesh.H"
#include "labelledTri.H"
#include "Random.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -55,13 +56,12 @@ class triangulatedPatch
//- Perturbation tolerance to move the point towards the cell centre
bool perturbTol_;
//- Face triangles
faceList triFace_;
//- The polyPatch faces as triangles, the index of each corresponds
//- to the undecomposed patch face index.
List<labelledTri> triFace_;
//- Triangle to patch face addressing
labelList triToFace_;
//- Triangle weights
//- The cumulative triangle area per triangle face,
//- globally normalised as a 0-1 interval.
scalarList triWght_;
@ -81,6 +81,11 @@ class triangulatedPatch
) const;
// Static Member Functions
//- Triangulate the patch faces and create addressing
static void triangulate(const polyPatch& pp, List<labelledTri>& tris);
public:
//- Constructors