From 320e70af1d2f0a66b707f730657d2507677e3442 Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Fri, 13 Jan 2023 09:19:08 +0000 Subject: [PATCH] mappedPatchBase: Add "samePatch" option This option means that a one field can be mapped to another within the same patch without specifying the patch name. E.g.: walls { type mappedValue; //neighbourPatch walls; // <-- Previously required. Still supported. samePatch yes; // <-- New alternative specification field T.liquid; value $internalField; } This is useful when the boundary condition is specified using a regular expression for the patch name. "wall_.*" { type mappedValue; //neighbourPatch ???; // <-- No unique name can be given samePatch yes; // <-- Still works field T.liquid; value $internalField; } --- .../mappedPatchBase/mappedPatchBase.C | 44 ++++++++++++------- .../multiphaseEuler/Grossetete/0/T.gas | 2 +- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/meshTools/mappedPatches/mappedPatchBase/mappedPatchBase.C b/src/meshTools/mappedPatches/mappedPatchBase/mappedPatchBase.C index 6830d23fe4..a0f2177e99 100644 --- a/src/meshTools/mappedPatches/mappedPatchBase/mappedPatchBase.C +++ b/src/meshTools/mappedPatches/mappedPatchBase/mappedPatchBase.C @@ -354,20 +354,17 @@ Foam::mappedPatchBase::mappedPatchBase coupleGroup_(dict), nbrRegionName_ ( - dict.lookupOrDefaultBackwardsCompatible + coupleGroup_.valid() ? word::null + : dict.lookupOrDefaultBackwardsCompatible ( {"neighbourRegion", "sampleRegion"}, - coupleGroup_.valid() ? word::null : pp.boundaryMesh().mesh().name() + pp.boundaryMesh().mesh().name() ) ), nbrPatchName_ ( - coupleGroup_.valid() - ? dict.lookupOrDefaultBackwardsCompatible - ( - {"neighbourPatch", "samplePatch"}, - word::null - ) + coupleGroup_.valid() ? word::null + : dict.lookupOrDefault("samePatch", false) ? pp.name() : dict.lookupBackwardsCompatible({"neighbourPatch", "samplePatch"}) ), transform_ @@ -392,15 +389,27 @@ Foam::mappedPatchBase::mappedPatchBase ), matchTol_(dict.lookupOrDefault("matchTolerance", defaultMatchTol_)) { - if - ( - coupleGroup_.valid() - && (nbrRegionName_ != word::null || nbrPatchName_ != word::null) - ) + const bool haveCoupleGroup = coupleGroup_.valid(); + + const bool haveNbrRegion = + dict.found("neighbourRegion") || dict.found("sampleRegion"); + const bool haveNbrPatch = + dict.found("neighbourPatch") || dict.found("samplePatch"); + + const bool isSamePatch = dict.lookupOrDefault("samePatch", false); + + if ((haveNbrRegion || haveNbrPatch || isSamePatch) && haveCoupleGroup) { FatalIOErrorInFunction(dict) - << "Either a coupleGroup or a neighbourRegion/Patch should be " - << "specified, not both" << exit(FatalIOError); + << "Either neighbourRegion/Patch information or a coupleGroup " + << "should be specified, not both" << exit(FatalIOError); + } + + if (haveNbrPatch && isSamePatch) + { + FatalIOErrorInFunction(dict) + << "Either a neighbourPatch should be specified, or samePatch " + << "should be set to true, not both" << exit(FatalIOError); } } @@ -493,11 +502,12 @@ void Foam::mappedPatchBase::clearOut() bool Foam::mappedPatchBase::specified(const dictionary& dict) { return - dict.found("neighbourRegion") + dict.found("coupleGroup") + || dict.found("neighbourRegion") || dict.found("sampleRegion") || dict.found("neighbourPatch") || dict.found("samplePatch") - || dict.found("coupleGroup"); + || dict.found("samePatch"); } diff --git a/tutorials/modules/multiphaseEuler/Grossetete/0/T.gas b/tutorials/modules/multiphaseEuler/Grossetete/0/T.gas index 6db81fec14..be70a06fa9 100644 --- a/tutorials/modules/multiphaseEuler/Grossetete/0/T.gas +++ b/tutorials/modules/multiphaseEuler/Grossetete/0/T.gas @@ -35,7 +35,7 @@ boundaryField walls { type mappedValue; - neighbourPatch walls; + samePatch yes; field T.liquid; value $internalField; }