Merge branch 'master' of github.com-OpenFOAM:OpenFOAM/OpenFOAM-dev

This commit is contained in:
Henry Weller
2023-04-05 15:58:53 +01:00
48 changed files with 668 additions and 60 deletions

View File

@ -64,7 +64,7 @@ Foam::tmp<Foam::pointField> Foam::mappedPatchBase::patchLocalPoints() const
void Foam::mappedPatchBase::calcMapping() const
{
if (mapPtr_.valid())
if (treeMapPtr_.valid())
{
FatalErrorInFunction
<< "Mapping already calculated" << exit(FatalError);
@ -96,12 +96,8 @@ void Foam::mappedPatchBase::calcMapping() const
true
);
// Build the mapping...
//
// This octree based solution is deprecated. The "matching" patch-to-patch
// method is equivalent, less code, and should be more efficiently
// parallelised.
if (!patchToPatchIsUsed_)
// Build the mapping
if (usingTree_)
{
const globalIndex patchGlobalIndex(patch_.size());
@ -242,7 +238,7 @@ void Foam::mappedPatchBase::calcMapping() const
// Construct distribution schedule
List<Map<label>> compactMap;
mapPtr_.reset
treeMapPtr_.reset
(
new distributionMap
(
@ -255,23 +251,22 @@ void Foam::mappedPatchBase::calcMapping() const
const labelList oldSampleIndices(move(sampleIndices));
// Construct input mapping for data to be distributed
nbrPatchFaceIndices_ = labelList(mapPtr_->constructSize(), -1);
UIndirectList<label>(nbrPatchFaceIndices_, oldToNew) = oldSampleIndices;
treeNbrPatchFaceIndices_ = labelList(treeMapPtr_->constructSize(), -1);
UIndirectList<label>(treeNbrPatchFaceIndices_, oldToNew) =
oldSampleIndices;
// Reverse the map. This means the map is "forward" when going from
// the neighbour patch to this patch, which is logical.
mapPtr_.reset
treeMapPtr_.reset
(
new distributionMap
(
patch_.size(),
move(mapPtr_->constructMap()),
move(mapPtr_->subMap())
move(treeMapPtr_->constructMap()),
move(treeMapPtr_->subMap())
)
);
}
// This (much simpler) patch-to-patch solution supersedes the above
else
{
if (patchToPatchIsValid_)
@ -310,13 +305,14 @@ Foam::mappedPatchBase::mappedPatchBase(const polyPatch& pp)
nbrRegionName_(patch_.boundaryMesh().mesh().name()),
nbrPatchName_(patch_.name()),
transform_(true),
mapPtr_(nullptr),
nbrPatchFaceIndices_(),
patchToPatchIsUsed_(false),
usingTree_(true),
treeMapPtr_(nullptr),
treeNbrPatchFaceIndices_(),
patchToPatchIsValid_(false),
patchToPatchPtr_(nullptr),
matchTol_(defaultMatchTol_),
reMapAfterMove_(true)
reMapAfterMove_(true),
reMapNbr_(false)
{}
@ -333,13 +329,14 @@ Foam::mappedPatchBase::mappedPatchBase
nbrRegionName_(nbrRegionName),
nbrPatchName_(nbrPatchName),
transform_(transform),
mapPtr_(nullptr),
nbrPatchFaceIndices_(),
patchToPatchIsUsed_(false),
usingTree_(true),
treeMapPtr_(nullptr),
treeNbrPatchFaceIndices_(),
patchToPatchIsValid_(false),
patchToPatchPtr_(nullptr),
matchTol_(defaultMatchTol_),
reMapAfterMove_(true)
reMapAfterMove_(true),
reMapNbr_(false)
{}
@ -373,13 +370,13 @@ Foam::mappedPatchBase::mappedPatchBase
? cyclicTransform(true)
: cyclicTransform(dict, false)
),
mapPtr_(nullptr),
nbrPatchFaceIndices_(),
patchToPatchIsUsed_(dict.found("method") || dict.found("sampleMode")),
usingTree_(!dict.found("method") && !dict.found("sampleMode")),
treeMapPtr_(nullptr),
treeNbrPatchFaceIndices_(),
patchToPatchIsValid_(false),
patchToPatchPtr_
(
patchToPatchIsUsed_
!usingTree_
? patchToPatch::New
(
dict.lookupBackwardsCompatible<word>({"method", "sampleMode"}),
@ -388,7 +385,8 @@ Foam::mappedPatchBase::mappedPatchBase
: nullptr
),
matchTol_(dict.lookupOrDefault("matchTolerance", defaultMatchTol_)),
reMapAfterMove_(dict.lookupOrDefault<bool>("reMapAfterMove", true))
reMapAfterMove_(dict.lookupOrDefault<bool>("reMapAfterMove", true)),
reMapNbr_(false)
{
const bool haveCoupleGroup = coupleGroup_.valid();
@ -426,18 +424,19 @@ Foam::mappedPatchBase::mappedPatchBase
nbrRegionName_(mpb.nbrRegionName_),
nbrPatchName_(mpb.nbrPatchName_),
transform_(mpb.transform_),
mapPtr_(nullptr),
nbrPatchFaceIndices_(),
patchToPatchIsUsed_(mpb.patchToPatchIsUsed_),
usingTree_(mpb.usingTree_),
treeMapPtr_(nullptr),
treeNbrPatchFaceIndices_(),
patchToPatchIsValid_(false),
patchToPatchPtr_
(
patchToPatchIsUsed_
!usingTree_
? patchToPatch::New(mpb.patchToPatchPtr_->type(), false).ptr()
: nullptr
),
matchTol_(mpb.matchTol_),
reMapAfterMove_(true)
reMapAfterMove_(true),
reMapNbr_(false)
{}
@ -497,9 +496,10 @@ void Foam::mappedPatchBase::clearOut()
{
if (reMapAfterMove_)
{
mapPtr_.clear();
nbrPatchFaceIndices_.clear();
treeMapPtr_.clear();
treeNbrPatchFaceIndices_.clear();
patchToPatchIsValid_ = false;
reMapNbr_ = true;
}
}
@ -525,7 +525,7 @@ void Foam::mappedPatchBase::write(Ostream& os) const
transform_.write(os);
if (patchToPatchIsUsed_)
if (!usingTree_)
{
writeEntry(os, "method", patchToPatchPtr_->type());
}

View File

@ -89,15 +89,19 @@ protected:
//- The transformation between the patches
mutable cyclicTransform transform_;
//- Distributor (if not using patch-to-patch)
mutable autoPtr<distributionMap> mapPtr_;
//- Are we using the tree mapping method, or a patch-to-patch
// intersection engine? The former is typically faster on small,
// pairs of patches with identical meshes. The latter is better
// parallelised and provides options for connecting patches with
// differing surface meshes.
const bool usingTree_;
//- Indices of the neighbouring patch faces who's values have to be
// supplied to the distribution map (if not using patch-to-patch)
mutable labelList nbrPatchFaceIndices_;
//- Distributor (if using tree)
mutable autoPtr<distributionMap> treeMapPtr_;
//- Is the patch-to-patch intersection engine being used?
const bool patchToPatchIsUsed_;
//- Indices of the neighbouring patch faces who's values
// have to be supplied to the distribution map (if using tree)
mutable labelList treeNbrPatchFaceIndices_;
//- Is the patch-to-patch intersection engine up to date? (if using
// patch-to-patch)
@ -116,6 +120,9 @@ protected:
// Defaults to true.
const bool reMapAfterMove_;
//- Do we need to re-map the neighbour because this patch moved?
mutable bool reMapNbr_;
// Protected Member Functions

View File

@ -46,8 +46,8 @@ inline bool Foam::mappedPatchBase::symmetric() const
nbrPatchIsMapped()
&& nbrMappedPatch().nbrRegionName_ == patch_.boundaryMesh().mesh().name()
&& nbrMappedPatch().nbrPatchName_ == patch_.name()
&& patchToPatchIsUsed_
&& nbrMappedPatch().patchToPatchIsUsed_
&& !usingTree_
&& !nbrMappedPatch().usingTree_
&& nbrMappedPatch().patchToPatchPtr_->type() == patchToPatchPtr_->type();
}

View File

@ -113,15 +113,26 @@ Foam::mappedPatchBase::fromNeighbour(const Field<Type>& nbrFld) const
return nbrFld;
}
if (!patchToPatchIsUsed_)
if (nbrPatchIsMapped() && nbrMappedPatch().reMapNbr_)
{
if (mapPtr_.empty())
treeMapPtr_.clear();
treeNbrPatchFaceIndices_.clear();
patchToPatchIsValid_ = false;
nbrMappedPatch().reMapNbr_ = false;
}
if (usingTree_)
{
if (treeMapPtr_.empty())
{
calcMapping();
}
tmp<Field<Type>> tResult(new Field<Type>(nbrFld, nbrPatchFaceIndices_));
mapPtr_->distribute(tResult.ref());
tmp<Field<Type>> tResult
(
new Field<Type>(nbrFld, treeNbrPatchFaceIndices_)
);
treeMapPtr_->distribute(tResult.ref());
return transform_.transform().transform(tResult);
}
else
@ -135,11 +146,6 @@ Foam::mappedPatchBase::fromNeighbour(const Field<Type>& nbrFld) const
calcMapping();
}
if (!patchToPatchIsValid_ && !symmetric())
{
calcMapping();
}
return
transform_.transform().transform
(
@ -170,17 +176,25 @@ Foam::mappedPatchBase::toNeighbour(const Field<Type>& fld) const
return fld;
}
if (!patchToPatchIsUsed_)
if (nbrPatchIsMapped() && nbrMappedPatch().reMapNbr_)
{
if (mapPtr_.empty())
treeMapPtr_.clear();
treeNbrPatchFaceIndices_.clear();
patchToPatchIsValid_ = false;
nbrMappedPatch().reMapNbr_ = false;
}
if (usingTree_)
{
if (treeMapPtr_.empty())
{
calcMapping();
}
Field<Type> nbrFld(fld);
mapPtr_->reverseDistribute(nbrPatchFaceIndices_.size(), nbrFld);
treeMapPtr_->reverseDistribute(treeNbrPatchFaceIndices_.size(), nbrFld);
tmp<Field<Type>> tResult(new Field<Type>(nbrPolyPatch().size()));
tResult.ref().rmap(nbrFld, nbrPatchFaceIndices_);
tResult.ref().rmap(nbrFld, treeNbrPatchFaceIndices_);
return transform_.transform().invTransform(tResult);
}
else

View File

@ -0,0 +1,45 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class volVectorField;
location "0";
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
#includeEtc "caseDicts/setConstraintTypes"
rotor
{
type movingWallVelocity;
value $internalField;
}
stator
{
type movingWallVelocity;
value $internalField;
}
nonCouple
{
type movingWallSlipVelocity;
value $internalField;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,44 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class volScalarField;
location "0";
object epsilon;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -3 0 0 0 0];
internalField uniform 20;
boundaryField
{
#includeEtc "caseDicts/setConstraintTypes"
rotor
{
type epsilonWallFunction;
value $internalField;
}
stator
{
type epsilonWallFunction;
value $internalField;
}
nonCouple
{
type zeroGradient;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,44 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class volScalarField;
location "0";
object k;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 1;
boundaryField
{
#includeEtc "caseDicts/setConstraintTypes"
rotor
{
type kqRWallFunction;
value uniform 0;
}
stator
{
type kqRWallFunction;
value uniform 0;
}
nonCouple
{
type zeroGradient;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,44 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class volScalarField;
location "0";
object nut;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -1 0 0 0 0];
internalField uniform 0;
boundaryField
{
#includeEtc "caseDicts/setConstraintTypes"
rotor
{
type nutkWallFunction;
value uniform 0;
}
stator
{
type nutkWallFunction;
value uniform 0;
}
nonCouple
{
type zeroGradient;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,42 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class volScalarField;
location "0";
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 0;
boundaryField
{
#includeEtc "caseDicts/setConstraintTypes"
rotor
{
type zeroGradient;
}
stator
{
type zeroGradient;
}
nonCouple
{
type zeroGradient;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,16 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions
application=$(getApplication)
runApplication blockMesh -dict $FOAM_TUTORIALS/resources/blockMesh/mixerVessel2D
runApplication createBaffles -overwrite
runApplication splitBaffles -overwrite
runApplication createNonConformalCouples -overwrite nonCouple1 nonCouple2
runApplication $application
#------------------------------------------------------------------------------

View File

@ -0,0 +1,36 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "constant";
object dynamicMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
mover
{
type motionSolver;
libs ("libfvMeshMovers.so" "libfvMotionSolvers.so");
motionSolver solidBody;
cellZone rotor;
solidBodyMotionFunction rotatingMotion;
origin (0 0 0);
axis (0 0 1);
rpm 60;
}
// ************************************************************************* //

View File

@ -0,0 +1,22 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "constant";
object physicalProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
viscosityModel constant;
nu [0 2 -1 0 0 0 0] 1e-05;
// ************************************************************************* //

View File

@ -0,0 +1,89 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application foamRun;
solver incompressibleFluid;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 5;
deltaT 1e-3;
writeControl adjustableRunTime;
writeInterval 0.05;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
adjustTimeStep yes;
maxCo 0.5;
functions
{
cartesianToCylindrical
{
type cylindrical;
libs ("libfieldFunctionObjects.so");
origin (0 0 0);
axis (0 0 1);
field U;
writeControl outputTime;
writeInterval 1;
}
#includeFunc fieldAverage(cylindrical(U))
cylindricalToCartesian
{
type cylindrical;
libs ("libfieldFunctionObjects.so");
origin (0 0 0);
axis (0 0 1);
field cylindrical(U)Mean;
toCartesian true;
result UMean;
writeControl outputTime;
writeInterval 1;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,45 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "system";
object createBafflesDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
internalFacesOnly true;
#include "$FOAM_TUTORIALS/resources/blockMesh/mixerVessel2D"
baffles
{
nonCouple
{
type searchableSurface;
surface searchableCylinder;
point1 (0 0 -100);
point2 (0 0 100);
radius $rotorRegion;
owner
{
name nonCouple1;
type patch;
}
neighbour
{
name nonCouple2;
type patch;
}
}
}
// ************************************************************************* //

View File

@ -0,0 +1,53 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "system";
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default Euler;
}
gradSchemes
{
default Gauss linear;
grad(p) Gauss linear;
grad(U) Gauss linear;
}
divSchemes
{
default none;
div(phi,U) Gauss linearUpwind grad(U);
div((nuEff*dev2(T(grad(U))))) Gauss linear;
}
laplacianSchemes
{
default Gauss linear corrected;
}
interpolationSchemes
{
default linear;
interpolate(HbyA) linear;
}
snGradSchemes
{
default corrected;
}
// ************************************************************************* //

View File

@ -0,0 +1,87 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "system";
object fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solvers
{
"pcorr.*"
{
solver GAMG;
smoother GaussSeidel;
cacheAgglomeration no;
tolerance 0.02;
relTol 0;
}
p
{
$pcorr;
tolerance 1e-6;
relTol 0.01;
}
pFinal
{
$p;
tolerance 1e-6;
relTol 0;
}
U
{
solver smoothSolver;
smoother GaussSeidel;
tolerance 1e-5;
relTol 0.01;
}
UFinal
{
$U;
tolerance 1e-6;
relTol 0;
}
cellMotionUx
{
solver PCG;
preconditioner DIC;
tolerance 1e-8;
relTol 0;
}
}
PIMPLE
{
nOuterCorrectors 2;
nCorrectors 1;
nNonOrthogonalCorrectors 0;
correctPhi yes;
correctMeshPhi no;
pRefCell 0;
pRefValue 0;
}
relaxationFactors
{
equations
{
".*" 1;
}
}
// ************************************************************************* //

View File

@ -21,7 +21,7 @@ MRF
origin (0 0 0);
axis (0 0 1);
rpm 1000;
rpm 60;
}
// ************************************************************************* //

View File

@ -0,0 +1,20 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "constant";
object momentumTransport;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
simulationType laminar;
// ************************************************************************* //

View File

@ -21,7 +21,7 @@ MRF
origin (0 0 0);
axis (0 0 1);
rpm 100;
rpm 60;
}
// ************************************************************************* //