Compare commits

..

1 Commits

Author SHA1 Message Date
fffffff98d COMP: clear out memory in argList (#3065)
- exit in constructor bypasses RAII
2023-12-21 17:40:29 +01:00
39 changed files with 290 additions and 435 deletions

View File

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

View File

@ -197,8 +197,8 @@ if ( "$FOAM_MPI" != dummy ) then
_foamAddLib "${FOAM_LIBBIN}/${FOAM_MPI}"
endif
_foamAddLib "$FOAM_SITE_LIBBIN" # OpenFOAM group libraries
_foamAddLib "$FOAM_USER_LIBBIN" # OpenFOAM user libraries
# OpenFOAM user, group libraries
_foamAddLib "${FOAM_USER_LIBBIN}:${FOAM_SITE_LIBBIN}"
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
_foamAddLib "$FOAM_SITE_LIBBIN" # OpenFOAM group libraries
_foamAddLib "$FOAM_USER_LIBBIN" # OpenFOAM user libraries
# OpenFOAM user, group libraries
_foamAddLib "$FOAM_USER_LIBBIN:$FOAM_SITE_LIBBIN"
if [ -d "$WM_PROJECT_DIR/doc/man1" ]
then

View File

@ -519,8 +519,7 @@ public:
if (newCapacity < len)
{
// Increase capacity (doubling)
newCapacity =
Foam::max(label(len), label(2*storage_.size()));
newCapacity = max(len, label(2*storage_.size()));
}
// Info<<"request:" << len

View File

@ -176,11 +176,10 @@ makeBoundary
new SlicedPatchField<Type>
(
p,
DimensionedField<Type, GeoMesh>::null()
DimensionedField<Type, GeoMesh>::null(),
bField[patchi]
)
);
bf[patchi].UList<Type>::shallowCopy(bField[patchi]);
}
}

View File

@ -1082,6 +1082,9 @@ Foam::argList::argList
<< " -help-full' for extended usage" << nl
<< nl;
args_.clear();
options_.clearStorage();
UPstream::exit(1); // works for serial and parallel
}
@ -1242,6 +1245,9 @@ void Foam::argList::parse
if (quickExit)
{
args_.clear();
options_.clearStorage();
std::exit(0);
}
}
@ -1252,6 +1258,9 @@ void Foam::argList::parse
foamVersion::printBuildInfo(Info.stdStream(), false);
FatalError.write(Info, false);
args_.clear();
options_.clearStorage();
UPstream::exit(1); // works for serial and parallel
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2023-2024 OpenCFD Ltd.
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -332,47 +332,35 @@ void Foam::GAMGSolver::gatherMatrices
const label proci = UPstream::myProcNo(comm);
// All interfaceBouCoeffs need to be sent across
bitSet validCoeffs(interfaces.size());
forAll(interfaceBouCoeffs, intI)
{
if (interfaceBouCoeffs.set(intI))
{
validCoeffs.set(intI);
}
}
// Only preserved interfaces need to be sent across
bitSet validInterface(interfaces.size());
labelList validInterface(interfaces.size(), -1);
forAll(interfaces, intI)
{
const label allIntI = boundaryMap[proci][intI];
if (interfaces.set(intI) && allIntI != -1)
{
validInterface.set(intI);
validInterface[intI] = intI;
}
}
UOPstream toMaster(UPstream::masterNo(), pBufs);
toMaster<< mat
<< token::SPACE << validCoeffs
<< token::SPACE << validInterface;
toMaster<< mat << token::SPACE << validInterface;
for (const label intI : validCoeffs)
forAll(validInterface, intI)
{
toMaster
<< interfaceBouCoeffs[intI]
<< interfaceIntCoeffs[intI];
}
for (const label intI : validInterface)
{
const auto& interface = refCast<const GAMGInterfaceField>
(
interfaces[intI]
);
if (validInterface[intI] != -1)
{
const auto& interface = refCast<const GAMGInterfaceField>
(
interfaces[intI]
);
toMaster << interface.type();
interface.write(toMaster);
toMaster
<< interfaceBouCoeffs[intI]
<< interfaceIntCoeffs[intI]
<< interface.type();
interface.write(toMaster);
}
}
}
@ -401,41 +389,60 @@ void Foam::GAMGSolver::gatherMatrices
otherMats.set(otherI, new lduMatrix(destMesh, fromProc));
// Receive bitSet of/valid interfaceCoeffs/interfaces
const bitSet validCoeffs(fromProc);
const bitSet validInterface(fromProc);
// Receive number of/valid interfaces
// >= 0 : remote interface index
// -1 : invalid interface
const labelList validInterface(fromProc);
otherBouCoeffs.emplace_set(otherI, validCoeffs.size());
otherIntCoeffs.emplace_set(otherI, validCoeffs.size());
otherInterfaces.emplace_set(otherI, validInterface.size());
otherBouCoeffs.set
(
otherI,
new FieldField<Field, scalar>(validInterface.size())
);
otherIntCoeffs.set
(
otherI,
new FieldField<Field, scalar>(validInterface.size())
);
otherInterfaces.set
(
otherI,
new PtrList<lduInterfaceField>(validInterface.size())
);
// Receive individual interface contributions
for (const label intI : validCoeffs)
forAll(validInterface, intI)
{
otherBouCoeffs[otherI].emplace_set(intI, fromProc);
otherIntCoeffs[otherI].emplace_set(intI, fromProc);
}
// Receive individual interface contributions
for (const label intI : validInterface)
{
const word coupleType(fromProc);
const label allIntI = boundaryMap[proci][intI];
otherInterfaces[otherI].set
(
intI,
GAMGInterfaceField::New
if (validInterface[intI] != -1)
{
otherBouCoeffs[otherI].set
(
coupleType,
refCast<const GAMGInterface>
intI,
new scalarField(fromProc)
);
otherIntCoeffs[otherI].set
(
intI,
new scalarField(fromProc)
);
const word coupleType(fromProc);
const label allIntI = boundaryMap[proci][intI];
otherInterfaces[otherI].set
(
intI,
GAMGInterfaceField::New
(
destInterfaces[allIntI]
),
fromProc
).release()
);
coupleType,
refCast<const GAMGInterface>
(
destInterfaces[allIntI]
),
fromProc
).release()
);
}
}
}
}

View File

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

View File

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

View File

@ -123,13 +123,13 @@ bool Foam::polyMesh::checkFaceOrthogonality
reduce(severeNonOrth, sumOp<label>());
reduce(errorNonOrth, sumOp<label>());
const scalar maxNonOrth = radToDeg(::acos(clamp(minDDotS, -1, 1)));
const scalar aveNonOrth = radToDeg(::acos(clamp(sumDDotS/nSummed, -1, 1)));
dictionary& meshDict = const_cast<dictionary&>(data().meshDict());
if (nSummed > 0)
{
scalar maxNonOrth = radToDeg(::acos(clamp(minDDotS, -1, 1)));
scalar aveNonOrth = radToDeg(::acos(clamp(sumDDotS/nSummed, -1, 1)));
meshDict.set("maxNonOrth", maxNonOrth);
meshDict.set("aveNonOrth", aveNonOrth);

View File

@ -538,10 +538,6 @@ inline Foam::Tensor<Cmpt> Foam::Tensor<Cmpt>::inv2D
template<class Cmpt>
#if defined(__GNUC__) && !defined(__clang__)
// Workaround for gcc (11+) that fails to handle tensor dot vector
__attribute__((optimize("no-tree-vectorize")))
#endif
inline Foam::Tensor<Cmpt>
Foam::Tensor<Cmpt>::inner(const Tensor<Cmpt>& t2) const
{
@ -565,10 +561,6 @@ Foam::Tensor<Cmpt>::inner(const Tensor<Cmpt>& t2) const
template<class Cmpt>
#if defined(__GNUC__) && !defined(__clang__)
// Workaround for gcc (11+) that fails to handle tensor dot vector
__attribute__((optimize("no-tree-vectorize")))
#endif
inline Foam::Tensor<Cmpt>
Foam::Tensor<Cmpt>::schur(const Tensor<Cmpt>& t2) const
{
@ -1111,10 +1103,6 @@ operator&(const Tensor<Cmpt>& t1, const Tensor<Cmpt>& t2)
//- Inner-product of a SphericalTensor and a Tensor
template<class Cmpt>
#if defined(__GNUC__) && !defined(__clang__)
// Workaround for gcc (11+) that fails to handle tensor dot vector
__attribute__((optimize("no-tree-vectorize")))
#endif
inline Tensor<Cmpt>
operator&(const SphericalTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
{
@ -1129,10 +1117,6 @@ operator&(const SphericalTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
//- Inner-product of a Tensor and a SphericalTensor
template<class Cmpt>
#if defined(__GNUC__) && !defined(__clang__)
// Workaround for gcc (11+) that fails to handle tensor dot vector
__attribute__((optimize("no-tree-vectorize")))
#endif
inline Tensor<Cmpt>
operator&(const Tensor<Cmpt>& t1, const SphericalTensor<Cmpt>& st2)
{
@ -1147,10 +1131,6 @@ operator&(const Tensor<Cmpt>& t1, const SphericalTensor<Cmpt>& st2)
//- Inner-product of a SymmTensor and a Tensor
template<class Cmpt>
#if defined(__GNUC__) && !defined(__clang__)
// Workaround for gcc (11+) that fails to handle tensor dot vector
__attribute__((optimize("no-tree-vectorize")))
#endif
inline Tensor<Cmpt>
operator&(const SymmTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
{
@ -1173,10 +1153,6 @@ operator&(const SymmTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
//- Inner-product of a Tensor and a SymmTensor
template<class Cmpt>
#if defined(__GNUC__) && !defined(__clang__)
// Workaround for gcc (11+) that fails to handle tensor dot vector
__attribute__((optimize("no-tree-vectorize")))
#endif
inline Tensor<Cmpt>
operator&(const Tensor<Cmpt>& t1, const SymmTensor<Cmpt>& st2)
{
@ -1217,10 +1193,6 @@ operator&(const Tensor<Cmpt>& t, const Vector<Cmpt>& v)
//- Inner-product of a Vector and a Tensor
template<class Cmpt>
#if defined(__GNUC__) && !defined(__clang__)
// Workaround for gcc (11+) that fails to handle tensor dot vector
__attribute__((optimize("no-tree-vectorize")))
#endif
inline Vector<Cmpt>
operator&(const Vector<Cmpt>& v, const Tensor<Cmpt>& t)
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2017 OpenFOAM Foundation
Copyright (C) 2019-2024 OpenCFD Ltd.
Copyright (C) 2019-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -444,14 +444,7 @@ void Foam::cyclicACMIFvPatchField<Type>::initEvaluate
<< " starting send&receive"
<< endl;
// Bypass polyPatch to get nbrId.
// - use cyclicACMIFvPatch::neighbPatch() virtual instead
const cyclicACMIFvPatch& neighbPatch = cyclicACMIPatch_.neighbPatch();
const labelUList& nbrFaceCells = neighbPatch.faceCells();
const Field<Type> pnf(this->primitiveField(), nbrFaceCells);
// Assert that all receives are known to have finished
if (!recvRequests_.empty())
if (!this->ready())
{
FatalErrorInFunction
<< "Outstanding recv request(s) on patch "
@ -460,8 +453,11 @@ void Foam::cyclicACMIFvPatchField<Type>::initEvaluate
<< abort(FatalError);
}
// Assume that sends are also OK
sendRequests_.clear();
// By-pass polyPatch to get nbrId. Instead use cyclicACMIFvPatch virtual
// neighbPatch()
const cyclicACMIFvPatch& neighbPatch = cyclicACMIPatch_.neighbPatch();
const labelUList& nbrFaceCells = neighbPatch.faceCells();
const Field<Type> pnf(this->primitiveField(), nbrFaceCells);
cyclicACMIPatch_.initInterpolate
(
@ -519,10 +515,6 @@ void Foam::cyclicACMIFvPatchField<Type>::evaluate
).ptr()
);
// Receive requests all handled by last function call
recvRequests_.clear();
auto& patchNeighbourField = patchNeighbourFieldPtr_.ref();
if (doTransform())
@ -567,16 +559,7 @@ void Foam::cyclicACMIFvPatchField<Type>::initInterfaceMatrixUpdate
<< " starting send&receive"
<< endl;
const labelUList& nbrFaceCells =
lduAddr.patchAddr(cyclicACMIPatch_.neighbPatchID());
solveScalarField pnf(psiInternal, nbrFaceCells);
// Transform according to the transformation tensors
transformCoupleField(pnf, cmpt);
// Assert that all receives are known to have finished
if (!recvRequests_.empty())
if (!this->ready())
{
FatalErrorInFunction
<< "Outstanding recv request(s) on patch "
@ -585,8 +568,13 @@ void Foam::cyclicACMIFvPatchField<Type>::initInterfaceMatrixUpdate
<< abort(FatalError);
}
// Assume that sends are also OK
sendRequests_.clear();
const labelUList& nbrFaceCells =
lduAddr.patchAddr(cyclicACMIPatch_.neighbPatchID());
solveScalarField pnf(psiInternal, nbrFaceCells);
// Transform according to the transformation tensors
transformCoupleField(pnf, cmpt);
cyclicACMIPatch_.initInterpolate
(
@ -647,9 +635,6 @@ void Foam::cyclicACMIFvPatchField<Type>::updateInterfaceMatrix
recvRequests_,
scalarRecvBufs_
);
// Receive requests all handled by last function call
recvRequests_.clear();
}
else
{
@ -691,16 +676,7 @@ void Foam::cyclicACMIFvPatchField<Type>::initInterfaceMatrixUpdate
<< exit(FatalError);
}
const labelUList& nbrFaceCells =
lduAddr.patchAddr(cyclicACMIPatch_.neighbPatchID());
Field<Type> pnf(psiInternal, nbrFaceCells);
// Transform according to the transformation tensors
transformCoupleField(pnf);
// Assert that all receives are known to have finished
if (!recvRequests_.empty())
if (!this->ready())
{
FatalErrorInFunction
<< "Outstanding recv request(s) on patch "
@ -709,8 +685,13 @@ void Foam::cyclicACMIFvPatchField<Type>::initInterfaceMatrixUpdate
<< abort(FatalError);
}
// Assume that sends are also OK
sendRequests_.clear();
const labelUList& nbrFaceCells =
lduAddr.patchAddr(cyclicACMIPatch_.neighbPatchID());
Field<Type> pnf(psiInternal, nbrFaceCells);
// Transform according to the transformation tensors
transformCoupleField(pnf);
cyclicACMIPatch_.initInterpolate
(
@ -760,9 +741,6 @@ void Foam::cyclicACMIFvPatchField<Type>::updateInterfaceMatrix
recvRequests_,
recvBufs_
);
// Receive requests all handled by last function call
recvRequests_.clear();
}
else
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019-2024 OpenCFD Ltd.
Copyright (C) 2019-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -446,27 +446,14 @@ void Foam::cyclicAMIFvPatchField<Type>::initEvaluate
// Start sending
// Bypass polyPatch to get nbrId.
// - use cyclicACMIFvPatch::neighbPatch() virtual instead
// By-pass polyPatch to get nbrId. Instead use cyclicAMIFvPatch virtual
// neighbPatch()
const cyclicAMIFvPatch& neighbPatch = cyclicAMIPatch_.neighbPatch();
const labelUList& nbrFaceCells = neighbPatch.faceCells();
const Field<Type> pnf(this->primitiveField(), nbrFaceCells);
const cyclicAMIPolyPatch& cpp = cyclicAMIPatch_.cyclicAMIPatch();
// Assert that all receives are known to have finished
if (!recvRequests_.empty())
{
FatalErrorInFunction
<< "Outstanding recv request(s) on patch "
<< cyclicAMIPatch_.name()
<< " field " << this->internalField().name()
<< abort(FatalError);
}
// Assume that sends are also OK
sendRequests_.clear();
cpp.initInterpolate
(
pnf,
@ -529,10 +516,6 @@ void Foam::cyclicAMIFvPatchField<Type>::evaluate
defaultValues
).ptr()
);
// Receive requests all handled by last function call
recvRequests_.clear();
auto& patchNeighbourField = patchNeighbourFieldPtr_.ref();
if (doTransform())
@ -580,19 +563,6 @@ void Foam::cyclicAMIFvPatchField<Type>::initInterfaceMatrixUpdate
const cyclicAMIPolyPatch& cpp = cyclicAMIPatch_.cyclicAMIPatch();
// Assert that all receives are known to have finished
if (!recvRequests_.empty())
{
FatalErrorInFunction
<< "Outstanding recv request(s) on patch "
<< cyclicAMIPatch_.name()
<< " field " << this->internalField().name()
<< abort(FatalError);
}
// Assume that sends are also OK
sendRequests_.clear();
cpp.initInterpolate
(
pnf,
@ -654,9 +624,6 @@ void Foam::cyclicAMIFvPatchField<Type>::updateInterfaceMatrix
scalarRecvBufs_,
defaultValues
);
// Receive requests all handled by last function call
recvRequests_.clear();
}
else
{
@ -715,19 +682,6 @@ void Foam::cyclicAMIFvPatchField<Type>::initInterfaceMatrixUpdate
const cyclicAMIPolyPatch& cpp = cyclicAMIPatch_.cyclicAMIPatch();
// Assert that all receives are known to have finished
if (!recvRequests_.empty())
{
FatalErrorInFunction
<< "Outstanding recv request(s) on patch "
<< cyclicAMIPatch_.name()
<< " field " << this->internalField().name()
<< abort(FatalError);
}
// Assume that sends are also OK
sendRequests_.clear();
cpp.initInterpolate
(
pnf,
@ -788,9 +742,6 @@ void Foam::cyclicAMIFvPatchField<Type>::updateInterfaceMatrix
recvBufs_,
defaultValues
);
// Receive requests all handled by last function call
recvRequests_.clear();
}
else
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013 OpenFOAM Foundation
Copyright (C) 2019-2024 OpenCFD Ltd.
Copyright (C) 2019,2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -217,18 +217,6 @@ void Foam::cyclicACMIGAMGInterfaceField::initInterfaceMatrixUpdate
: AMI.srcMap()
);
// Assert that all receives are known to have finished
if (!recvRequests_.empty())
{
FatalErrorInFunction
<< "Outstanding recv request(s) on patch "
<< cyclicACMIInterface_.index()
<< abort(FatalError);
}
// Assume that sends are also OK
sendRequests_.clear();
// Insert send/receive requests (non-blocking). See e.g.
// cyclicAMIPolyPatchTemplates.C
const label oldWarnComm = UPstream::commWarn(AMI.comm());
@ -288,9 +276,6 @@ void Foam::cyclicACMIGAMGInterfaceField::updateInterfaceMatrix
solveScalarField work;
map.receive(recvRequests_, scalarRecvBufs_, work);
// Receive requests all handled by last function call
recvRequests_.clear();
solveScalarField pnf(faceCells.size(), Zero);
AMI.weightedSum
(

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation
Copyright (C) 2019-2024 OpenCFD Ltd.
Copyright (C) 2019,2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -218,18 +218,6 @@ void Foam::cyclicAMIGAMGInterfaceField::initInterfaceMatrixUpdate
: AMI.srcMap()
);
// Assert that all receives are known to have finished
if (!recvRequests_.empty())
{
FatalErrorInFunction
<< "Outstanding recv request(s) on patch "
<< cyclicAMIInterface_.index()
<< abort(FatalError);
}
// Assume that sends are also OK
sendRequests_.clear();
// Insert send/receive requests (non-blocking). See e.g.
// cyclicAMIPolyPatchTemplates.C
const label oldWarnComm = UPstream::commWarn(AMI.comm());
@ -302,9 +290,6 @@ void Foam::cyclicAMIGAMGInterfaceField::updateInterfaceMatrix
solveScalarField work;
map.receive(recvRequests_, scalarRecvBufs_, work);
// Receive requests all handled by last function call
recvRequests_.clear();
solveScalarField pnf(faceCells.size(), Zero);
AMI.weightedSum
(

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2020-2021,2024 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -201,10 +201,7 @@ Foam::mappedPatchBase::updateSampleMeshTime() const
{
if (!updateSampleMeshTimePtr_)
{
// Note: explicitly register on our mesh instead of sampleMesh
// since otherwise the destructor might give problems since sampleMesh
// might have already been taken down before.
const auto& mesh = patch_.boundaryMesh().mesh();
const auto& mesh = sampleMesh();
updateSampleMeshTimePtr_.reset
(

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2023-2024 OpenCFD Ltd.
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -26,6 +26,7 @@ License
\*---------------------------------------------------------------------------*/
#include "triangulatedPatch.H"
#include "triPointRef.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -49,8 +50,6 @@ 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)
{
@ -63,9 +62,11 @@ 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 = triFace_[trii].tri(points).randomPoint(rnd);
facei = triFace_[trii].index();
result = tri.randomPoint(rnd);
facei = triToFace_[trii];
celli = patch_.faceCells()[facei];
if (perturbTol_ > 0)
@ -96,6 +97,7 @@ Foam::triangulatedPatch::triangulatedPatch
patch_(patch),
perturbTol_(perturbTol),
triFace_(),
triToFace_(),
triWght_()
{
update();
@ -113,95 +115,70 @@ 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();
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();
// 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);
// Set zero value at the start of the tri area/weight list
scalar patchArea = 0;
*iter = patchArea;
++iter;
triWght.push_back(0);
// Calculate cumulative and total area (processor-local at this point)
for (const auto& t : triFace_)
forAll(patch_, facei)
{
patchArea += t.mag(points);
const face& f = patch_[facei];
*iter = patchArea;
++iter;
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));
}
}
// FIXME: use allGatherList of subslice
scalarList procSumWght(numProc+1, Foam::zero{});
procSumWght[myProci+1] = patchArea;
scalarList procSumWght(Pstream::nProcs()+1, Zero);
procSumWght[Pstream::myProcNo()+1] = sum(triWght);
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[myProci];
const scalar totalArea = procSumWght.back();
// Apply processor offset and normalise - for a global 0-1 interval
for (scalar& w : triWght_)
const scalar offset = procSumWght[Pstream::myProcNo()];
forAll(triWght, i)
{
w = (w + offset) / totalArea;
if (i)
{
// Convert to cumulative
triWght[i] += triWght[i-1];
}
// Apply processor offset
triWght[i] += offset;
}
// 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);
}
@ -213,14 +190,6 @@ 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);
@ -235,23 +204,20 @@ bool Foam::triangulatedPatch::randomGlobalPoint
label& celli
) const
{
if (UPstream::parRun())
boolList valid(UPstream::nProcs(), false);
valid[UPstream::myProcNo()] = randomLocalPoint(rnd, result, facei, celli);
UPstream::listGatherValues(valid);
forAll(valid, proci)
{
const scalar c = rnd.sample01<scalar>();
const bool ok = randomPoint(rnd, c, result, facei, celli);
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);
// Choose first valid processor
if (valid[proci])
{
return (proci == UPstream::myProcNo());
}
}
return false;
}

View File

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

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2024 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -39,11 +39,7 @@ Foam::sampledMeshedSurface::sampleOnFaces
{
const Type deflt
(
defaultValues_.getOrDefault<Type>
(
sampler.psi().name(),
Foam::zero{}
)
defaultValues_.getOrDefault<Type>(sampler.psi().name(), Zero)
);
const labelList& elements = sampleElements_;
@ -75,16 +71,13 @@ Foam::sampledMeshedSurface::sampleOnFaces
const polyBoundaryMesh& pbm = mesh().boundaryMesh();
Field<Type> bVals(mesh().nBoundaryFaces(), deflt);
Field<Type> bVals(mesh().nBoundaryFaces(), Zero);
const auto& bField = sampler.psi().boundaryField();
forAll(bField, patchi)
{
// Note: restrict transcribing to actual size of the patch field
// - handles "empty" patch type etc.
const auto& pfld = bField[patchi];
SubList<Type>(bVals, pfld.size(), pbm[patchi].offset()) = pfld;
SubList<Type>(bVals, pbm[patchi].range()) = bField[patchi];
}
// Sample within the flat boundary field
@ -116,11 +109,7 @@ Foam::sampledMeshedSurface::sampleOnPoints
{
const Type deflt
(
defaultValues_.getOrDefault<Type>
(
interpolator.psi().name(),
Foam::zero{}
)
defaultValues_.getOrDefault<Type>(interpolator.psi().name(), Zero)
);
const labelList& elements = sampleElements_;

View File

@ -10,11 +10,11 @@ FoamFile
version 2.0;
format ascii;
class volScalarField;
object nuTilda;
object muTilda;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -1 0 0 0 0];
dimensions [1 -1 -1 0 0 0 0];
internalField uniform 0;

View File

@ -36,7 +36,7 @@ divSchemes
div(phi,k) Gauss limitedLinear 1;
div(phi,B) Gauss limitedLinear 1;
div(phi,nuTilda) Gauss limitedLinear 1;
div(phi,muTilda) Gauss limitedLinear 1;
div(B) Gauss linear;
div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear;
@ -57,9 +57,5 @@ snGradSchemes
default corrected;
}
wallDist
{
method meshWave;
}
// ************************************************************************* //

View File

@ -13,8 +13,8 @@ rm -rf 0/domain3 constant/domain3 system/domain3
# Remove fluid fields from solid regions (important for post-processing)
for region in $(foamListRegions solid)
do
rm -f 0/$region/{rho,nut,alphat,epsilon,k,U,p_rgh,qr,G,IDefault}
rm -f processor*/0/$region/{rho,nut,alphat,epsilon,k,U,p_rgh,qr,G,IDefault}
rm -f 0/$region/{rho,mut,alphat,epsilon,k,U,p_rgh,qr,G,IDefault}
rm -f processor*/0/$region/{rho,mut,alphat,epsilon,k,U,p_rgh,qr,G,IDefault}
done
# Set the initial fields

View File

@ -15,8 +15,8 @@ rm -rf 0/domain3 constant/domain3 system/domain3
# Remove fluid fields from solid regions (important for post-processing)
for region in $(foamListRegions solid)
do
rm -f 0/"$region"/{rho,nut,alphat,epsilon,k,U,p_rgh,qr,G,IDefault}
rm -f processor*/0/"$region"/{rho,nut,alphat,epsilon,k,U,p_rgh,qr,G,IDefault}
rm -f 0/"$region"/{rho,mut,alphat,epsilon,k,U,p_rgh,qr,G,IDefault}
rm -f processor*/0/"$region"/{rho,mut,alphat,epsilon,k,U,p_rgh,qr,G,IDefault}
done
# Set the initial fields

View File

@ -0,0 +1,60 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2312 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format binary;
class volScalarField;
object mut;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [1 -1 -1 0 0 0 0];
internalField uniform 0;
boundaryField
{
inlet
{
type calculated;
value uniform 0;
}
outlet
{
type calculated;
value uniform 0;
}
symmetry
{
type symmetryPlane;
}
walls
{
type mutkWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
cabin_to_ice
{
type mutkWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
}
// ************************************************************************* //

View File

@ -29,7 +29,8 @@ divSchemes
default Gauss linear;
div(phi,U) bounded Gauss linearUpwind gradUConv;
div(-phi,Ua) bounded Gauss linearUpwind gradUaConv;
div(-phi,Uaas1) bounded Gauss linearUpwind gradUaConv;
div(-phi,Uavol) bounded Gauss linearUpwind gradUaConv;
div((nuEff*dev(grad(U).T()))) Gauss linear;
div((nuEff*dev(grad(Ua).T()))) Gauss linear;

View File

@ -16,7 +16,7 @@ FoamFile
dimensions [ 0 1 -1 0 0 0 0 ];
internalField uniform ( 4.95 0 0 );
internalField uniform ( 0.3 0 0 );
boundaryField
{
@ -46,7 +46,7 @@ boundaryField
Inlet
{
type fixedValue;
value uniform ( 4.95 0 0 );
value uniform ( 0.3 0 0 );
}
Outlet

View File

@ -22,13 +22,13 @@ startTime 0;
stopAt endTime;
endTime 100;
endTime 70;
deltaT 1;
writeControl timeStep;
writeInterval 100;
writeInterval 70;
purgeWrite 0;

View File

@ -108,7 +108,7 @@ adjointManagers
type flowRatePartition;
inletPatches (inlet);
outletPatches (outlet outlet-right);
targetFractions (0.3 0.7);
targetFractions (0.5 0.5);
target 1.e-05;
normalize true;
}

View File

@ -108,7 +108,7 @@ adjointManagers
type flowRatePartition;
inletPatches (inlet);
outletPatches (outlet outlet-right);
targetFractions (0.7 0.3);
targetFractions (0.5 0.5);
target 1.e-05;
normalize true;
}

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / O peration | Version: v2312 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
@ -15,11 +15,6 @@ FoamFile
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
numberOfSubdomains 60;
method hierarchical;
coeffs
{
n (5 4 3);
}
method scotch;
// ************************************************************************* //

View File

@ -29,9 +29,8 @@ solvers
relTol 0.01;
}
"U|Ua.*"
"U|Ua.*" smoothSolver
{
solver smoothSolver;
smoother GaussSeidel;
tolerance 1e-12;
relTol 0.1;

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / O peration | Version: v2312 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
@ -15,11 +15,6 @@ FoamFile
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
numberOfSubdomains 60;
method hierarchical;
coeffs
{
n (5 4 3);
}
method scotch;
// ************************************************************************* //

View File

@ -29,9 +29,8 @@ solvers
relTol 0.01;
}
"U|Ua.*"
"U|Ua.*" smoothSolver
{
solver smoothSolver;
smoother GaussSeidel;
tolerance 1e-12;
relTol 0.1;

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / O peration | Version: v2312 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
@ -15,11 +15,6 @@ FoamFile
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
numberOfSubdomains 60;
method hierarchical;
coeffs
{
n (5 4 3);
}
method scotch;
// ************************************************************************* //

View File

@ -29,9 +29,8 @@ solvers
relTol 0.01;
}
"U|Ua.*"
"U|Ua.*" smoothSolver
{
solver smoothSolver;
smoother GaussSeidel;
tolerance 1e-12;
relTol 0.1;

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / O peration | Version: v2312 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
@ -15,11 +15,6 @@ FoamFile
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
numberOfSubdomains 60;
method hierarchical;
coeffs
{
n (5 4 3);
}
method scotch;
// ************************************************************************* //

View File

@ -29,9 +29,8 @@ solvers
relTol 0.01;
}
"U|Ua.*"
"U|Ua.*" smoothSolver
{
solver smoothSolver;
smoother GaussSeidel;
tolerance 1e-12;
relTol 0.1;

View File

@ -12,7 +12,7 @@ runParallel $(getApplication)
if [[ ! -z $(which cartesian2DMesh) ]]
then
cd reEval
./AllrunReEval > log.AllrunReEval 2>&1 && echo "End" >> log.AllrunReEval
./AllrunReEval > log.AllrunReEval 2>&1 &
cd ..
fi