Merge remote branch 'OpenCFD/master' into olesenm

This commit is contained in:
Mark Olesen
2010-03-18 16:22:10 +01:00
6 changed files with 337 additions and 114 deletions

View File

@ -189,8 +189,8 @@ Foam::createShellMesh::createShellMesh
void Foam::createShellMesh::setRefinement
(
const pointField& thickness,
const labelList& extrudeMasterPatchID,
const labelList& extrudeSlavePatchID,
const labelList& topPatchID,
const labelList& bottomPatchID,
const labelListList& extrudeEdgePatches,
polyTopoChange& meshMod
)
@ -205,14 +205,14 @@ void Foam::createShellMesh::setRefinement
if
(
extrudeMasterPatchID.size() != patch_.size()
&& extrudeSlavePatchID.size() != patch_.size()
topPatchID.size() != patch_.size()
&& bottomPatchID.size() != patch_.size()
)
{
FatalErrorIn("createShellMesh::setRefinement(..)")
<< "nFaces:" << patch_.size()
<< " extrudeMasterPatchID:" << extrudeMasterPatchID.size()
<< " extrudeSlavePatchID:" << extrudeSlavePatchID.size()
<< " topPatchID:" << topPatchID.size()
<< " bottomPatchID:" << bottomPatchID.size()
<< exit(FatalError);
}
@ -302,11 +302,9 @@ void Foam::createShellMesh::setRefinement
}
// Add face on patch' master side
//labelList masterFaces(patch_.localFaces().size());
// Add face on bottom side
forAll(patch_.localFaces(), faceI)
{
//masterFaces[faceI] =
meshMod.addFace
(
patch_.localFaces()[faceI].reverseFace(),// vertices
@ -316,14 +314,14 @@ void Foam::createShellMesh::setRefinement
-1, // masterEdgeID
faceToFaceMap.size(), // masterFaceID : current faceI
true, // flipFaceFlux
extrudeMasterPatchID[faceI],// patchID
bottomPatchID[faceI],// patchID
-1, // zoneID
false // zoneFlip
);
faceToFaceMap.append(faceI+1); // points to unflipped original face
faceToFaceMap.append(-faceI-1); // points to flipped original face
faceToEdgeMap.append(-1);
//Pout<< "Added master face "
//Pout<< "Added bottom face "
// << patch_.localFaces()[faceI].reverseFace()
// << " own " << addedCells[faceI]
// << " at " << patch_.faceCentres()[faceI]
@ -331,8 +329,7 @@ void Foam::createShellMesh::setRefinement
}
// Add face on patch' slave side
//labelList slaveFaces(patch_.localFaces().size());
// Add face on top
forAll(patch_.localFaces(), faceI)
{
// Get face in original ordering
@ -346,7 +343,6 @@ void Foam::createShellMesh::setRefinement
newF[fp] = addedPoints[region];
}
//slaveFaces[faceI] =
meshMod.addFace
(
newF, // vertices
@ -356,14 +352,14 @@ void Foam::createShellMesh::setRefinement
-1, // masterEdgeID
faceToFaceMap.size(), // masterFaceID : current faceI
false, // flipFaceFlux
extrudeSlavePatchID[faceI], // patchID
topPatchID[faceI], // patchID
-1, // zoneID
false // zoneFlip
);
faceToFaceMap.append(-faceI-1);
faceToFaceMap.append(faceI+1); // unflipped
faceToEdgeMap.append(-1);
//Pout<< "Added slave face " << newF
//Pout<< "Added top face " << newF
// << " own " << addedCells[faceI]
// << " at " << patch_.faceCentres()[faceI]
// << endl;

View File

@ -31,6 +31,10 @@ Description
SourceFiles
createShellMesh.C
Extrudes into thickness direction.
- bottom faces originate from reversed original faces (have turning index)
- top faces originate from original faces (no turning index)
\*---------------------------------------------------------------------------*/
#ifndef createShellMesh_H
@ -59,9 +63,6 @@ class createShellMesh
//- Reference to patch to extrude
const primitiveFacePatch& patch_;
// //- Non-manifold edges on patch
// const PackedBoolList& nonManifoldEdge_;
//- Per point on face the region
const faceList& pointRegions_;
@ -99,7 +100,6 @@ public:
createShellMesh
(
const primitiveFacePatch& patch,
// const PackedBoolList& nonManifoldEdge,
const faceList& pointRegions,
const labelList& regionPoints
);
@ -117,10 +117,10 @@ public:
}
//- From region face to patch face. Contains turning index:
// > 0 : face originating from master side
// (owner side for unflipped face)
// < 0 : (bottom) face originating from slave side
// (neighbour side for unflipped face)
// > 0 : face in same orientation as patch face. face will
// be in top patch
// < 0 : face in opposite orientation as patch face. face will
// be in bottom patch
// = 0 : for all side faces
const labelList& faceToFaceMap() const
{
@ -155,8 +155,8 @@ public:
void setRefinement
(
const pointField& thickness,
const labelList& extrudeMasterPatchID,
const labelList& extrudeSlavePatchID,
const labelList& topPatchID,
const labelList& bottomPatchID,
const labelListList& extrudeEdgePatches,
polyTopoChange& meshMod
);

View File

@ -37,6 +37,73 @@ Description
if flipMap is false)
- not parallel
Internal face extrusion
-----------------------
+-------------+
| |
| |
+---AAAAAAA---+
| |
| |
+-------------+
AAA=faceZone to extrude.
For the case of no flipMap the extrusion starts at owner and extrudes
into the space of the neighbour:
+CCCCCCC+
| | <= extruded mesh
+BBBBBBB+
+-------------+
| |
| (neighbour) |
|___CCCCCCC___| <= original mesh (with 'baffles' added)
| BBBBBBB |
|(owner side) |
| |
+-------------+
BBB=directMapped between owner on original mesh and new extrusion.
(zero offset)
CCC=directMapped between neighbour on original mesh and new extrusion
(offset due to the thickness of the extruded mesh)
For the case of flipMap the extrusion is the other way around: from the
neighbour side into the owner side.
Boundary face extrusion
-----------------------
+--AAAAAAA--+
| |
| |
+-----------+
AAA=faceZone to extrude. E.g. slave side is owner side (no flipmap)
becomes
+CCCCCCC+
| | <= extruded mesh
+BBBBBBB+
+--BBBBBBB--+
| | <= original mesh
| |
+-----------+
BBB=directMapped between original mesh and new extrusion
CCC=polypatch
Usage
- extrudeToRegionMesh <regionName> <faceZones> <thickness>
@ -467,6 +534,30 @@ void reorderPatches
}
// Remove zero-sized patches
void deleteEmptyPatches(fvMesh& mesh)
{
const polyBoundaryMesh& patches = mesh.boundaryMesh();
labelList oldToNew(patches.size());
label usedI = 0;
label notUsedI = patches.size();
forAll(patches, patchI)
{
if (returnReduce(patches[patchI].size(), sumOp<label>()) == 0)
{
oldToNew[patchI] = --notUsedI;
}
else
{
oldToNew[patchI] = usedI++;
}
}
reorderPatches(mesh, oldToNew, usedI);
}
void createDummyFvMeshFiles(const polyMesh& mesh, const word& regionName)
{
// Create dummy system/fv*
@ -585,23 +676,6 @@ int main(int argc, char *argv[])
}
// Add interface patches
// Note: should be one per faceZone?
word masterPatchName = regionName + "_to_" + shellRegionName + "_master";
label masterPatchID = addPatch<directMappedWallPolyPatch>
(
mesh,
masterPatchName
);
word slavePatchName = regionName + "_to_" + shellRegionName + "_slave";
label slavePatchID = addPatch<directMappedWallPolyPatch>
(
mesh,
slavePatchName
);
// Create dummy fv* files
createDummyFvMeshFiles(mesh, shellRegionName);
@ -620,39 +694,49 @@ int main(int argc, char *argv[])
Info<< "Writing meshes to " << meshInstance << nl << endl;
// Collect faces to extrude
const polyBoundaryMesh& patches = mesh.boundaryMesh();
const faceZoneMesh& faceZones = mesh.faceZones();
label nExtrudeFaces = 0;
// Check zones
// ~~~~~~~~~~~
labelList zoneIDs(zoneNames.size());
forAll(zoneNames, i)
{
label zoneI = faceZones.findZoneID(zoneNames[i]);
if (zoneI == -1)
zoneIDs[i] = faceZones.findZoneID(zoneNames[i]);
if (zoneIDs[i] == -1)
{
FatalErrorIn(args.executable())
<< "Cannot find zone " << zoneNames[i] << endl
<< "Valid zones are " << faceZones.names()
<< exit(FatalError);
}
nExtrudeFaces += faceZones[zoneI].size();
}
// Collect faces to extrude and per-face information
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
label nExtrudeFaces = 0;
forAll(zoneIDs, i)
{
nExtrudeFaces += faceZones[zoneIDs[i]].size();
}
labelList extrudeMeshFaces(nExtrudeFaces);
faceList zoneFaces(nExtrudeFaces);
labelList zoneID(nExtrudeFaces);
boolList zoneFlipMap(nExtrudeFaces);
nExtrudeFaces = 0;
forAll(zoneNames, i)
forAll(zoneIDs, i)
{
label zoneI = faceZones.findZoneID(zoneNames[i]);
const faceZone& fz = faceZones[zoneI];
const faceZone& fz = faceZones[zoneIDs[i]];
const primitiveFacePatch& fzp = fz();
forAll(fz, j)
{
extrudeMeshFaces[nExtrudeFaces] = fz[j];
zoneFaces[nExtrudeFaces] = fzp[j];
zoneID[nExtrudeFaces] = zoneI;
zoneID[nExtrudeFaces] = zoneIDs[i];
zoneFlipMap[nExtrudeFaces] = fz.flipMap()[j];
nExtrudeFaces++;
}
@ -662,13 +746,6 @@ int main(int argc, char *argv[])
const faceList& extrudeFaces = extrudePatch.localFaces();
const labelListList& edgeFaces = extrudePatch.edgeFaces();
labelList extrudeSlavePatchID(extrudePatch.size());
labelList extrudeMasterPatchID(extrudePatch.size());
forAll(extrudeMeshFaces, i)
{
extrudeSlavePatchID[i] = slavePatchID;
extrudeMasterPatchID[i] = masterPatchID;
}
Info<< "extrudePatch :"
<< " faces:" << extrudePatch.size()
@ -678,6 +755,128 @@ int main(int argc, char *argv[])
<< endl;
// Check whether the zone is internal or external faces to determine
// what patch type to insert. Cannot be mixed
// since then how to couple? - directMapped only valid for a whole patch.
boolList isInternal(zoneIDs.size(), false);
forAll(zoneIDs, i)
{
const faceZone& fz = faceZones[zoneIDs[i]];
forAll(fz, j)
{
if (mesh.isInternalFace(fz[j]))
{
isInternal[i] = true;
break;
}
}
}
Pstream::listCombineGather(isInternal, orEqOp<bool>());
Pstream::listCombineScatter(isInternal);
forAll(zoneIDs, i)
{
const faceZone& fz = faceZones[zoneIDs[i]];
if (isInternal[i])
{
Info<< "FaceZone " << fz.name() << " has internal faces" << endl;
}
else
{
Info<< "FaceZone " << fz.name() << " has boundary faces" << endl;
}
}
// Add interface patches
// ~~~~~~~~~~~~~~~~~~~~~
Info<< "Adding coupling patches:" << nl << nl
<< "patchID\tpatch\ttype" << nl
<< "-------\t-----\t----"
<< endl;
labelList interRegionTopPatch(zoneNames.size());
labelList interRegionBottomPatch(zoneNames.size());
label nCoupled = 0;
forAll(zoneIDs, i)
{
word interName(regionName+"_to_"+shellRegionName+'_'+zoneNames[i]);
if (isInternal[i])
{
interRegionTopPatch[i] = addPatch<directMappedWallPolyPatch>
(
mesh,
interName + "_top"
);
nCoupled++;
Info<< interRegionTopPatch[i]
<< '\t' << patches[interRegionTopPatch[i]].name()
<< '\t' << patches[interRegionTopPatch[i]].type()
<< nl;
interRegionBottomPatch[i] = addPatch<directMappedWallPolyPatch>
(
mesh,
interName + "_bottom"
);
nCoupled++;
Info<< interRegionBottomPatch[i]
<< '\t' << patches[interRegionBottomPatch[i]].name()
<< '\t' << patches[interRegionBottomPatch[i]].type()
<< nl;
}
else
{
interRegionTopPatch[i] = addPatch<polyPatch>
(
mesh,
zoneNames[i] + "_top"
);
nCoupled++;
Info<< interRegionTopPatch[i]
<< '\t' << patches[interRegionTopPatch[i]].name()
<< '\t' << patches[interRegionTopPatch[i]].type()
<< nl;
interRegionBottomPatch[i] = addPatch<directMappedWallPolyPatch>
(
mesh,
interName
);
nCoupled++;
Info<< interRegionBottomPatch[i]
<< '\t' << patches[interRegionBottomPatch[i]].name()
<< '\t' << patches[interRegionBottomPatch[i]].type()
<< nl;
}
}
Info<< "Added " << nCoupled << " inter-region patches." << nl
<< endl;
labelList extrudeTopPatchID(extrudePatch.size());
labelList extrudeBottomPatchID(extrudePatch.size());
nExtrudeFaces = 0;
forAll(zoneNames, i)
{
label zoneI = faceZones.findZoneID(zoneNames[i]);
const faceZone& fz = faceZones[zoneI];
forAll(fz, j)
{
extrudeTopPatchID[nExtrudeFaces] = interRegionTopPatch[i];
extrudeBottomPatchID[nExtrudeFaces] = interRegionBottomPatch[i];
nExtrudeFaces++;
}
}
// Count how many patches on special edges of extrudePatch are necessary
// - zoneXXX_sides
// - zoneXXX_zoneYYY
@ -716,9 +915,9 @@ int main(int argc, char *argv[])
Pstream::listCombineScatter(zoneZonePatch);
// Now check which patches to add.
Info<< "Adding patches for edges on zones:" << nl
<< "\tpatchID\tpatch" << nl
<< "\t-------\t-----"
Info<< "Adding patches for edges on zones:" << nl << nl
<< "patchID\tpatch" << nl
<< "-------\t-----"
<< endl;
label nSide = 0;
@ -726,15 +925,14 @@ int main(int argc, char *argv[])
{
if (zoneSidePatch[zoneI] > 0)
{
word patchName = faceZones[zoneI].name() + "_" + "sidePatch";
word patchName = faceZones[zoneI].name() + "_" + "side";
zoneSidePatch[zoneI] = addPatch<polyPatch>
(
mesh,
patchName
);
Info<< '\t' << zoneSidePatch[zoneI]
<< '\t' << patchName << nl;
Info<< zoneSidePatch[zoneI] << '\t' << patchName << nl;
nSide++;
}
@ -744,9 +942,9 @@ int main(int argc, char *argv[])
Info<< "Adding inter-zone patches:" << nl
<< "\tpatchID\tpatch" << nl
<< "\t-------\t-----"
Info<< "Adding inter-zone patches:" << nl << nl
<< "patchID\tpatch" << nl
<< "-------\t-----"
<< endl;
dictionary transformDict;
@ -777,7 +975,7 @@ int main(int argc, char *argv[])
transformDict
);
Info<< '\t' << zoneZonePatch[index]
Info<< zoneZonePatch[index]
<< '\t' << patchName << nl;
nInter++;
@ -943,12 +1141,7 @@ int main(int argc, char *argv[])
// Create a new mesh
// ~~~~~~~~~~~~~~~~~
createShellMesh extruder
(
extrudePatch,
pointRegions,
regionPoints
);
createShellMesh extruder(extrudePatch, pointRegions, regionPoints);
autoPtr<fvMesh> regionMeshPtr;
@ -959,8 +1152,8 @@ int main(int argc, char *argv[])
extruder.setRefinement
(
thickness*regionNormals,
extrudeMasterPatchID,
extrudeSlavePatchID,
extrudeTopPatchID,
extrudeBottomPatchID,
extrudeEdgePatches,
meshMod
);
@ -990,11 +1183,12 @@ int main(int argc, char *argv[])
extruder.updateMesh(shellMap);
// Change master and slave boundary conditions on regionMesh
// Change top and bottom boundary conditions on regionMesh
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Save offsets from shell mesh back to original mesh
pointField masterOffsets, slaveOffsets;
List<pointField> topOffsets(zoneIDs.size());
List<pointField> bottomOffsets(zoneIDs.size());
{
const polyBoundaryMesh& regionPatches = regionMesh.boundaryMesh();
@ -1002,9 +1196,16 @@ int main(int argc, char *argv[])
forAll(regionPatches, patchI)
{
const polyPatch& pp = regionPatches[patchI];
if (pp.name() == masterPatchName)
if
(
isA<directMappedWallPolyPatch>(pp)
&& (findIndex(interRegionTopPatch, patchI) != -1)
)
{
masterOffsets = calcOffset(extrudePatch, extruder, pp);
label index = findIndex(interRegionTopPatch, patchI);
topOffsets[index] = calcOffset(extrudePatch, extruder, pp);
newPatches[patchI] = new directMappedWallPolyPatch
(
@ -1012,16 +1213,22 @@ int main(int argc, char *argv[])
pp.size(),
pp.start(),
patchI,
regionName, // sampleRegion
directMappedPatchBase::NEARESTPATCHFACE, // sampleMode
pp.name(), // samplePatch
masterOffsets, // offset
regionName, // sampleRegion
directMappedPatchBase::NEARESTPATCHFACE,// sampleMode
pp.name(), // samplePatch
topOffsets[index], // offset
patches
);
}
else if (pp.name() == slavePatchName)
else if
(
isA<directMappedWallPolyPatch>(pp)
&& (findIndex(interRegionBottomPatch, patchI) != -1)
)
{
slaveOffsets = calcOffset(extrudePatch, extruder, pp);
label index = findIndex(interRegionBottomPatch, patchI);
bottomOffsets[index] = calcOffset(extrudePatch, extruder, pp);
newPatches[patchI] = new directMappedWallPolyPatch
(
@ -1029,10 +1236,10 @@ int main(int argc, char *argv[])
pp.size(),
pp.start(),
patchI,
regionName, // sampleRegion
directMappedPatchBase::NEARESTPATCHFACE, // sampleMode
pp.name(), // samplePatch
slaveOffsets, // offset
regionName, // sampleRegion
directMappedPatchBase::NEARESTPATCHFACE,// sampleMode
pp.name(), // samplePatch
bottomOffsets[index], // offset
patches
);
}
@ -1049,6 +1256,7 @@ int main(int argc, char *argv[])
}
regionMesh.removeFvBoundary();
regionMesh.addFvPatches(newPatches, true);
deleteEmptyPatches(regionMesh);
}
@ -1153,7 +1361,7 @@ int main(int argc, char *argv[])
{
polyTopoChange meshMod(mesh);
// Modify faces to be in master patch
// Modify faces to be in bottom (= always coupled) patch
forAll(extrudeMeshFaces, zoneFaceI)
{
label meshFaceI = extrudeMeshFaces[zoneFaceI];
@ -1170,7 +1378,7 @@ int main(int argc, char *argv[])
mesh.faceOwner()[meshFaceI],// owner
-1, // neighbour
false, // face flip
masterPatchID, // patch for face
extrudeBottomPatchID[zoneFaceI],// patch for face
zoneI, // zone for face
flip // face flip in zone
);
@ -1184,14 +1392,14 @@ int main(int argc, char *argv[])
mesh.faceNeighbour()[meshFaceI],// owner
-1, // neighbour
true, // face flip
masterPatchID, // patch for face
extrudeBottomPatchID[zoneFaceI],// patch for face
zoneI, // zone for face
!flip // face flip in zone
);
}
}
// Add faces (using same points) to be in slave patch
// Add faces (using same points) to be in top patch
forAll(extrudeMeshFaces, zoneFaceI)
{
label meshFaceI = extrudeMeshFaces[zoneFaceI];
@ -1211,7 +1419,7 @@ int main(int argc, char *argv[])
-1, // master edge
meshFaceI, // master face
true, // flip flux
slavePatchID, // patch for face
extrudeTopPatchID[zoneFaceI], // patch for face
-1, // zone for face
false // face flip in zone
);
@ -1228,7 +1436,7 @@ int main(int argc, char *argv[])
-1, // master edge
meshFaceI, // master face
false, // flip flux
slavePatchID, // patch for face
extrudeTopPatchID[zoneFaceI], // patch for face
-1, // zone for face
false // zone flip
);
@ -1266,33 +1474,45 @@ int main(int argc, char *argv[])
forAll(patches, patchI)
{
const polyPatch& pp = patches[patchI];
if (pp.name() == masterPatchName)
if
(
isA<directMappedWallPolyPatch>(pp)
&& (findIndex(interRegionTopPatch, patchI) != -1)
)
{
label index = findIndex(interRegionTopPatch, patchI);
newPatches[patchI] = new directMappedWallPolyPatch
(
pp.name(),
pp.size(),
pp.start(),
patchI,
shellRegionName, // sampleRegion
directMappedPatchBase::NEARESTPATCHFACE, // sampleMode
pp.name(), // samplePatch
-masterOffsets, // offset
shellRegionName, // sampleRegion
directMappedPatchBase::NEARESTPATCHFACE,// sampleMode
pp.name(), // samplePatch
-topOffsets[index], // offset
patches
);
}
else if (pp.name() == slavePatchName)
else if
(
isA<directMappedWallPolyPatch>(pp)
&& (findIndex(interRegionBottomPatch, patchI) != -1)
)
{
label index = findIndex(interRegionBottomPatch, patchI);
newPatches[patchI] = new directMappedWallPolyPatch
(
pp.name(),
pp.size(),
pp.start(),
patchI,
shellRegionName, // sampleRegion
directMappedPatchBase::NEARESTPATCHFACE, // sampleMode
pp.name(), // samplePatch
-slaveOffsets, // offset
shellRegionName, // sampleRegion
directMappedPatchBase::NEARESTPATCHFACE,// sampleMode
pp.name(), // samplePatch
-bottomOffsets[index], // offset
patches
);
}
@ -1309,6 +1529,7 @@ int main(int argc, char *argv[])
}
mesh.removeFvBoundary();
mesh.addFvPatches(newPatches, true);
deleteEmptyPatches(mesh);
}

View File

@ -960,7 +960,14 @@ int main(int argc, char *argv[])
# endif
}
if (rawLine.empty() || rawLine[0] == '#')
// Strip off anything after #
string::size_type i = rawLine.find_first_of("#");
if (i != string::npos)
{
rawLine = rawLine(0, i);
}
if (rawLine.empty())
{
continue;
}

View File

@ -181,7 +181,6 @@ inline unsigned Hash<triFace>::operator()(const triFace& t, unsigned seed) const
//- Hash specialization for hashing triFace - a commutative hash value.
// Hash incrementally.
template<>
inline unsigned Hash<triFace>::operator()(const triFace& t) const
{

View File

@ -148,11 +148,10 @@ void Foam::displacementLayeredMotionFvMotionSolver::walkStructured
// Current info on points
List<pointEdgeStructuredWalk> allPointInfo(mesh().nPoints());
// Mark points inside cellZone.
// Mark points inside cellZone.
// Note that we use points0, not mesh.points()
// so as not to accumulate errors.
forAll(isZonePoint, pointI)
{
if (isZonePoint[pointI])
@ -169,6 +168,7 @@ void Foam::displacementLayeredMotionFvMotionSolver::walkStructured
// Current info on edges
List<pointEdgeStructuredWalk> allEdgeInfo(mesh().nEdges());
// Mark edges inside cellZone
forAll(isZoneEdge, edgeI)
{