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

View File

@ -157,6 +157,16 @@ public:
const vectorField& offset 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 //- Construct from dictionary
directMappedPatchBase(const polyPatch&, const 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 Foam::directMappedPolyPatch::directMappedPolyPatch
( (
const word& name, const word& name,

View File

@ -115,6 +115,20 @@ public:
const polyBoundaryMesh& bm 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 //- Construct from dictionary
directMappedPolyPatch 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 Foam::directMappedWallPolyPatch::directMappedWallPolyPatch
( (
const word& name, const word& name,

View File

@ -115,6 +115,20 @@ public:
const polyBoundaryMesh& bm 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 //- Construct from dictionary
directMappedWallPolyPatch directMappedWallPolyPatch
( (

View File

@ -18,30 +18,13 @@ dictionaryReplacement
{ {
boundary boundary
{ {
".*" minX
{ {
type wall; type wall;
} }
bottomAir_to_leftSolid maxX
{ {
offset ( 0 0 0 ); type wall;
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;
} }
} }

View File

@ -18,37 +18,17 @@ dictionaryReplacement
{ {
boundary boundary
{ {
".*" minY
{ {
type patch; type patch;
} }
heater_to_bottomAir minZ
{ {
offset ( 0 0 0 ); type patch;
sampleMode nearestPatchFace;
sampleRegion bottomAir;
samplePatch bottomAir_to_heater;
} }
heater_to_leftSolid maxZ
{ {
offset ( 0 0 0 ); type patch;
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;
} }
} }

View File

@ -18,30 +18,13 @@ dictionaryReplacement
{ {
boundary boundary
{ {
".*" minZ
{ {
type patch; type patch;
} }
leftSolid_to_bottomAir maxZ
{ {
offset ( 0 0 0 ); type patch;
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;;
} }
} }

View File

@ -18,30 +18,13 @@ dictionaryReplacement
{ {
boundary boundary
{ {
".*" minZ
{ {
type patch; type patch;
} }
rightSolid_to_heater maxZ
{ {
offset ( 0 0 0 ); type patch;
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;
} }
} }

View File

@ -16,43 +16,6 @@ FoamFile
dictionaryReplacement 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 U
{ {
internalField uniform (0.01 0 0); internalField uniform (0.01 0 0);

View File

@ -16,31 +16,6 @@ FoamFile
dictionaryReplacement 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 U
{ {
internalField uniform (0 0 0); internalField uniform (0 0 0);

View File

@ -16,38 +16,6 @@ FoamFile
dictionaryReplacement 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 T
{ {
internalField uniform 300; internalField uniform 300;

View File

@ -16,31 +16,6 @@ FoamFile
dictionaryReplacement 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 T
{ {
internalField uniform 300; internalField uniform 300;

View File

@ -16,31 +16,6 @@ FoamFile
dictionaryReplacement 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 T
{ {
internalField uniform 300; internalField uniform 300;

View File

@ -16,31 +16,6 @@ FoamFile
dictionaryReplacement 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 U
{ {
internalField uniform ( 0.01 0 0 ); internalField uniform ( 0.01 0 0 );