ENH: splitMeshRegions now fills in coupling information in directMapped patch.

- added directMapped*Patch constructors with uniform offset
- changed splitMeshRegions to use it
- adapted chtMultiRegionFoam tutorials
This commit is contained in:
mattijs
2010-01-27 13:24:06 +00:00
parent 6684a0d563
commit 011bbf46bc
17 changed files with 164 additions and 275 deletions

View File

@ -64,6 +64,7 @@ Description
#include "syncTools.H"
#include "ReadFields.H"
#include "directMappedWallPolyPatch.H"
#include "zeroGradientFvPatchFields.H"
using namespace Foam;
@ -164,25 +165,24 @@ void reorderPatchFields(fvMesh& mesh, const labelList& oldToNew)
// Adds patch if not yet there. Returns patchID.
template<class PatchType>
label addPatch(fvMesh& mesh, const word& patchName)
label addPatch(fvMesh& mesh, const polyPatch& patch)
{
polyBoundaryMesh& polyPatches =
const_cast<polyBoundaryMesh&>(mesh.boundaryMesh());
label patchI = polyPatches.findPatchID(patchName);
label patchI = polyPatches.findPatchID(patch.name());
if (patchI != -1)
{
if (isA<PatchType>(polyPatches[patchI]))
if (polyPatches[patchI].type() == patch.type())
{
// Already there
return patchI;
}
else
{
FatalErrorIn("addPatch<PatchType>(fvMesh&, const word&)")
<< "Already have patch " << patchName
<< " but of type " << PatchType::typeName
FatalErrorIn("addPatch(fvMesh&, const polyPatch*)")
<< "Already have patch " << patch.name()
<< " but of type " << patch.type()
<< exit(FatalError);
}
}
@ -219,14 +219,12 @@ label addPatch(fvMesh& mesh, const word& patchName)
polyPatches.set
(
sz,
polyPatch::New
patch.clone
(
PatchType::typeName,
patchName,
0, // size
startFaceI,
insertPatchI,
polyPatches
polyPatches,
insertPatchI, //index
0, //size
startFaceI //start
)
);
fvPatches.setSize(sz+1);
@ -1086,16 +1084,37 @@ EdgeMap<label> addRegionPatches
if (interfaceSizes[e] > 0)
{
label patchI = addPatch<directMappedWallPolyPatch>
const word inter1 = regionNames[e[0]] + "_to_" + regionNames[e[1]];
const word inter2 = regionNames[e[1]] + "_to_" + regionNames[e[0]];
directMappedWallPolyPatch patch1
(
mesh,
regionNames[e[0]] + "_to_" + regionNames[e[1]]
inter1,
0, // overridden
0, // overridden
0, // overridden
regionNames[e[1]], // sampleRegion
directMappedPatchBase::NEARESTPATCHFACE,
inter2, // samplePatch
point::zero, // offset
mesh.boundaryMesh()
);
addPatch<directMappedWallPolyPatch>
label patchI = addPatch(mesh, patch1);
directMappedWallPolyPatch patch2
(
mesh,
regionNames[e[1]] + "_to_" + regionNames[e[0]]
inter2,
0,
0,
0,
regionNames[e[0]], // sampleRegion
directMappedPatchBase::NEARESTPATCHFACE,
inter1,
point::zero, // offset
mesh.boundaryMesh()
);
addPatch(mesh, patch2);
Info<< "For interface between region " << e[0]
<< " and " << e[1] << " added patch " << patchI
@ -1495,7 +1514,8 @@ int main(int argc, char *argv[])
false
),
mesh,
dimensionedScalar("zero", dimless, 0)
dimensionedScalar("zero", dimless, 0),
zeroGradientFvPatchScalarField::typeName
);
forAll(cellRegion, cellI)
{

View File

@ -623,6 +623,27 @@ Foam::directMappedPatchBase::directMappedPatchBase
{}
Foam::directMappedPatchBase::directMappedPatchBase
(
const polyPatch& pp,
const word& sampleRegion,
const sampleMode mode,
const word& samplePatch,
const vector& offset
)
:
patch_(pp),
sampleRegion_(sampleRegion),
mode_(mode),
samplePatch_(samplePatch),
uniformOffset_(true),
offset_(offset),
offsets_(0),
sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
mapPtr_(NULL)
{}
Foam::directMappedPatchBase::directMappedPatchBase
(
const polyPatch& pp,

View File

@ -157,6 +157,16 @@ public:
const vectorField& offset
);
//- Construct from components
directMappedPatchBase
(
const polyPatch& pp,
const word& sampleRegion,
const sampleMode sampleMode,
const word& samplePatch,
const vector& offset
);
//- Construct from dictionary
directMappedPatchBase(const polyPatch&, const dictionary&);

View File

@ -82,6 +82,31 @@ Foam::directMappedPolyPatch::directMappedPolyPatch
{}
Foam::directMappedPolyPatch::directMappedPolyPatch
(
const word& name,
const label size,
const label start,
const label index,
const word& sampleRegion,
const directMappedPatchBase::sampleMode mode,
const word& samplePatch,
const vector& offset,
const polyBoundaryMesh& bm
)
:
polyPatch(name, size, start, index, bm),
directMappedPatchBase
(
static_cast<const polyPatch&>(*this),
sampleRegion,
mode,
samplePatch,
offset
)
{}
Foam::directMappedPolyPatch::directMappedPolyPatch
(
const word& name,

View File

@ -115,6 +115,20 @@ public:
const polyBoundaryMesh& bm
);
//- Construct from components. Uniform offset.
directMappedPolyPatch
(
const word& name,
const label size,
const label start,
const label index,
const word& sampleRegion,
const directMappedPatchBase::sampleMode mode,
const word& samplePatch,
const vector& offset,
const polyBoundaryMesh& bm
);
//- Construct from dictionary
directMappedPolyPatch
(

View File

@ -87,6 +87,31 @@ Foam::directMappedWallPolyPatch::directMappedWallPolyPatch
{}
Foam::directMappedWallPolyPatch::directMappedWallPolyPatch
(
const word& name,
const label size,
const label start,
const label index,
const word& sampleRegion,
const directMappedPatchBase::sampleMode mode,
const word& samplePatch,
const vector& offset,
const polyBoundaryMesh& bm
)
:
wallPolyPatch(name, size, start, index, bm),
directMappedPatchBase
(
static_cast<const polyPatch&>(*this),
sampleRegion,
mode,
samplePatch,
offset
)
{}
Foam::directMappedWallPolyPatch::directMappedWallPolyPatch
(
const word& name,

View File

@ -115,6 +115,20 @@ public:
const polyBoundaryMesh& bm
);
//- Construct from components. Uniform offset.
directMappedWallPolyPatch
(
const word& name,
const label size,
const label start,
const label index,
const word& sampleRegion,
const directMappedPatchBase::sampleMode mode,
const word& samplePatch,
const vector& offset,
const polyBoundaryMesh& bm
);
//- Construct from dictionary
directMappedWallPolyPatch
(

View File

@ -18,30 +18,13 @@ dictionaryReplacement
{
boundary
{
".*"
minX
{
type wall;
}
bottomAir_to_leftSolid
maxX
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion leftSolid;
samplePatch leftSolid_to_bottomAir;
}
bottomAir_to_rightSolid
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion rightSolid;
samplePatch rightSolid_to_bottomAir;
}
bottomAir_to_heater
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion heater;
samplePatch heater_to_bottomAir;
type wall;
}
}

View File

@ -18,37 +18,17 @@ dictionaryReplacement
{
boundary
{
".*"
minY
{
type patch;
}
heater_to_bottomAir
minZ
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion bottomAir;
samplePatch bottomAir_to_heater;
type patch;
}
heater_to_leftSolid
maxZ
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion leftSolid;
samplePatch leftSolid_to_heater;
}
heater_to_rightSolid
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion rightSolid;
samplePatch rightSolid_to_heater;
}
heater_to_topAir
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion topAir;
samplePatch topAir_to_heater;
type patch;
}
}

View File

@ -18,30 +18,13 @@ dictionaryReplacement
{
boundary
{
".*"
minZ
{
type patch;
}
leftSolid_to_bottomAir
maxZ
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion bottomAir;
samplePatch bottomAir_to_leftSolid;
}
leftSolid_to_heater
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion heater;
samplePatch heater_to_leftSolid;;
}
leftSolid_to_topAir
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion topAir;
samplePatch topAir_to_leftSolid;;
type patch;
}
}

View File

@ -18,30 +18,13 @@ dictionaryReplacement
{
boundary
{
".*"
minZ
{
type patch;
}
rightSolid_to_heater
maxZ
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion heater;
samplePatch heater_to_rightSolid;
}
rightSolid_to_bottomAir
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion bottomAir;
samplePatch bottomAir_to_rightSolid;
}
rightSolid_to_topAir
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion topAir;
samplePatch topAir_to_rightSolid;
type patch;
}
}

View File

@ -16,43 +16,6 @@ FoamFile
dictionaryReplacement
{
boundary
{
".*"
{
type wall;
}
minX
{
type patch;
}
maxX
{
type patch;
}
topAir_to_leftSolid
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion leftSolid;
samplePatch leftSolid_to_topAir;
}
topAir_to_heater
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion heater;
samplePatch heater_to_topAir;
}
topAir_to_rightSolid
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion rightSolid;
samplePatch rightSolid_to_topAir;
}
}
U
{
internalField uniform (0.01 0 0);

View File

@ -16,31 +16,6 @@ FoamFile
dictionaryReplacement
{
boundary
{
bottomAir_to_leftSolid
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion leftSolid;
samplePatch leftSolid_to_bottomAir;
}
bottomAir_to_rightSolid
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion rightSolid;
samplePatch rightSolid_to_bottomAir;
}
bottomAir_to_heater
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion heater;
samplePatch heater_to_bottomAir;
}
}
U
{
internalField uniform (0 0 0);

View File

@ -16,38 +16,6 @@ FoamFile
dictionaryReplacement
{
boundary
{
heater_to_bottomAir
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion bottomAir;
samplePatch bottomAir_to_heater;
}
heater_to_leftSolid
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion leftSolid;
samplePatch leftSolid_to_heater;
}
heater_to_rightSolid
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion rightSolid;
samplePatch rightSolid_to_heater;
}
heater_to_topAir
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion topAir;
samplePatch topAir_to_heater;
}
}
T
{
internalField uniform 300;

View File

@ -16,31 +16,6 @@ FoamFile
dictionaryReplacement
{
boundary
{
leftSolid_to_bottomAir
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion bottomAir;
samplePatch bottomAir_to_leftSolid;
}
leftSolid_to_heater
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion heater;
samplePatch heater_to_leftSolid;;
}
leftSolid_to_topAir
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion topAir;
samplePatch topAir_to_leftSolid;;
}
}
T
{
internalField uniform 300;

View File

@ -16,31 +16,6 @@ FoamFile
dictionaryReplacement
{
boundary
{
rightSolid_to_heater
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion heater;
samplePatch heater_to_rightSolid;
}
rightSolid_to_bottomAir
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion bottomAir;
samplePatch bottomAir_to_rightSolid;
}
rightSolid_to_topAir
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion topAir;
samplePatch topAir_to_rightSolid;
}
}
T
{
internalField uniform 300;

View File

@ -16,31 +16,6 @@ FoamFile
dictionaryReplacement
{
boundary
{
topAir_to_leftSolid
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion leftSolid;
samplePatch leftSolid_to_topAir;
}
topAir_to_heater
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion heater;
samplePatch heater_to_topAir;
}
topAir_to_rightSolid
{
offset ( 0 0 0 );
sampleMode nearestPatchFace;
sampleRegion rightSolid;
samplePatch rightSolid_to_topAir;
}
}
U
{
internalField uniform ( 0.01 0 0 );