mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: avoid blockMesh removal of files for special cases (issue #963)
- do not remove if the dictionary failed to load. - do not remove if -blockTopology was used.
This commit is contained in:
@ -28,8 +28,7 @@ Group
|
||||
grpMeshConversionUtilities
|
||||
|
||||
Description
|
||||
For mesh debugging: writes mesh as three separate OBJ files which can
|
||||
be viewed with e.g. javaview.
|
||||
For mesh debugging: writes mesh as three separate OBJ files.
|
||||
|
||||
meshPoints_XXX.obj : all points and edges as lines.
|
||||
meshFaceCentres_XXX.obj : all face centres.
|
||||
@ -61,6 +60,7 @@ void writeOBJ(const point& pt, Ostream& os)
|
||||
os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
|
||||
}
|
||||
|
||||
|
||||
// All edges of mesh
|
||||
void writePoints(const polyMesh& mesh, const fileName& timeName)
|
||||
{
|
||||
|
||||
@ -0,0 +1,87 @@
|
||||
// Set any cellZones
|
||||
// Note cell labelling unaffected by previous mergePatchPairs
|
||||
|
||||
{
|
||||
const label nZones = blocks.numZonedBlocks();
|
||||
if (nZones)
|
||||
{
|
||||
Info<< nl << "Adding cell zones" << endl;
|
||||
|
||||
// Map from zoneName to cellZone index
|
||||
HashTable<label> zoneMap(nZones);
|
||||
|
||||
// Cells per zone.
|
||||
List<DynamicList<label>> zoneCells(nZones);
|
||||
|
||||
// Running cell counter
|
||||
label celli = 0;
|
||||
|
||||
// Largest zone so far
|
||||
label freeZoneI = 0;
|
||||
|
||||
for (const block& b : blocks)
|
||||
{
|
||||
const word& zoneName = b.zoneName();
|
||||
const label nCellsInBlock = b.cells().size();
|
||||
|
||||
if (zoneName.size())
|
||||
{
|
||||
const auto iter = zoneMap.cfind(zoneName);
|
||||
|
||||
label zonei;
|
||||
|
||||
if (iter.found())
|
||||
{
|
||||
zonei = *iter;
|
||||
}
|
||||
else
|
||||
{
|
||||
zonei = freeZoneI++;
|
||||
|
||||
Info<< " " << zonei << '\t' << zoneName << endl;
|
||||
|
||||
zoneMap.insert(zoneName, zonei);
|
||||
}
|
||||
|
||||
|
||||
// Fill with cell ids
|
||||
|
||||
zoneCells[zonei].reserve
|
||||
(
|
||||
zoneCells[zonei].size() + nCellsInBlock
|
||||
);
|
||||
|
||||
const label endOfFill = celli + nCellsInBlock;
|
||||
|
||||
for (; celli < endOfFill; ++celli)
|
||||
{
|
||||
zoneCells[zonei].append(celli);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
celli += nCellsInBlock;
|
||||
}
|
||||
}
|
||||
|
||||
List<cellZone*> cz(zoneMap.size());
|
||||
forAllConstIters(zoneMap, iter)
|
||||
{
|
||||
const word& zoneName = iter.key();
|
||||
const label zonei = iter.object();
|
||||
|
||||
cz[zonei] = new cellZone
|
||||
(
|
||||
zoneName,
|
||||
zoneCells[zonei].shrink(),
|
||||
zonei,
|
||||
mesh.cellZones()
|
||||
);
|
||||
}
|
||||
|
||||
mesh.pointZones().resize(0);
|
||||
mesh.faceZones().resize(0);
|
||||
mesh.cellZones().resize(0);
|
||||
mesh.addZones(List<pointZone*>(), List<faceZone*>(), cz);
|
||||
}
|
||||
}
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -41,17 +41,20 @@ Usage
|
||||
|
||||
Options:
|
||||
- \par -blockTopology
|
||||
Write the topology as a set of edges in OBJ format.
|
||||
Write the topology as a set of edges in OBJ format and exit.
|
||||
|
||||
- \par -region \<name\>
|
||||
Specify an alternative mesh region.
|
||||
Specify alternative mesh region.
|
||||
|
||||
- \par -dict \<filename\>
|
||||
Specify alternative dictionary for the block mesh description.
|
||||
Alternative dictionary for the block mesh description.
|
||||
|
||||
- \par -sets
|
||||
Write cellZones as cellSets too (for processing purposes)
|
||||
|
||||
- \par -noClean
|
||||
Do not remove any existing polyMesh/ directory or files
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "Time.H"
|
||||
@ -78,58 +81,55 @@ using namespace Foam;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::addNote
|
||||
(
|
||||
"Block mesh generator.\n"
|
||||
" The ordering of vertex and face labels within a block as shown "
|
||||
"below.\n"
|
||||
" For the local vertex numbering in the sequence 0 to 7:\n"
|
||||
" Faces 0, 1 (x-direction) are left, right.\n"
|
||||
" Faces 2, 3 (y-direction) are front, back.\n"
|
||||
" Faces 4, 5 (z-direction) are bottom, top.\n"
|
||||
"\n"
|
||||
" 7 ---- 6\n"
|
||||
" f5 |\\ |\\ f3\n"
|
||||
" | | 4 ---- 5 \\\n"
|
||||
" | 3 |--- 2 | \\\n"
|
||||
" | \\| \\| f2\n"
|
||||
" f4 0 ---- 1\n"
|
||||
" Y Z\n"
|
||||
" \\ | f0 ------ f1\n"
|
||||
" \\|\n"
|
||||
" O--- X\n"
|
||||
);
|
||||
|
||||
argList::noParallel();
|
||||
argList::addBoolOption
|
||||
(
|
||||
"blockTopology",
|
||||
"Write block edges and centres as .obj files"
|
||||
"Write block edges and centres as obj files and exit"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"noClean",
|
||||
"Keep the existing files in the polyMesh"
|
||||
"Do not remove any existing polyMesh/ directory or files"
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"dict",
|
||||
"file",
|
||||
"Specify alternative dictionary for the blockMesh description"
|
||||
"Alternative dictionary for the blockMesh description"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"sets",
|
||||
"Write cellZones as cellSets too (for processing purposes)"
|
||||
);
|
||||
argList::addNote
|
||||
(
|
||||
"Block description\n"
|
||||
"\n"
|
||||
" For a given block, the correspondence between the ordering of\n"
|
||||
" vertex labels and face labels is shown below.\n"
|
||||
" For vertex numbering in the sequence 0 to 7 (block, centre):\n"
|
||||
" faces 0 (f0) and 1 are left and right, respectively;\n"
|
||||
" faces 2 and 3 are front and back; \n"
|
||||
" and faces 4 and 5 are bottom and top::\n"
|
||||
"\n"
|
||||
" 7 ---- 6\n"
|
||||
" f5 |\\ |\\ f3\n"
|
||||
" | | 4 ---- 5 \\\n"
|
||||
" | 3 |--- 2 | \\\n"
|
||||
" | \\| \\| f2\n"
|
||||
" f4 0 ---- 1\n"
|
||||
"\n"
|
||||
" Z f0 ----- f1\n"
|
||||
" | Y\n"
|
||||
" | /\n"
|
||||
" O --- X\n"
|
||||
);
|
||||
|
||||
#include "addRegionOption.H"
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
const word dictName("blockMeshDict");
|
||||
|
||||
word regionName;
|
||||
word regionPath;
|
||||
|
||||
@ -140,47 +140,59 @@ int main(int argc, char *argv[])
|
||||
regionPath = regionName;
|
||||
}
|
||||
|
||||
// Search for the appropriate blockMesh dictionary....
|
||||
|
||||
fileName dictPath;
|
||||
// Locate appropriate blockMeshDict
|
||||
#include "findBlockMeshDict.H"
|
||||
|
||||
// Check if the dictionary is specified on the command-line
|
||||
if (args.readIfPresent("dict", dictPath))
|
||||
blockMesh blocks(meshDict, regionName);
|
||||
|
||||
if (!blocks.valid())
|
||||
{
|
||||
if (isDir(dictPath))
|
||||
// Could/should be Fatal?
|
||||
|
||||
WarningIn(args.executable())
|
||||
<< "Did not generate any blocks. Stopping." << nl << endl;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
if (args.found("blockTopology"))
|
||||
{
|
||||
Info<< nl;
|
||||
|
||||
// Write mesh as edges.
|
||||
{
|
||||
dictPath /= dictName;
|
||||
}
|
||||
}
|
||||
// Check if dictionary is present in the constant directory
|
||||
else if
|
||||
(
|
||||
exists
|
||||
(
|
||||
runTime.path()/runTime.constant()
|
||||
/regionPath/polyMesh::meshSubDir/dictName
|
||||
)
|
||||
)
|
||||
{
|
||||
dictPath =
|
||||
runTime.constant()
|
||||
/regionPath/polyMesh::meshSubDir/dictName;
|
||||
OFstream os(runTime.path()/"blockTopology.obj");
|
||||
|
||||
// Warn that constant/polyMesh/blockMesh was selected instead of
|
||||
// system/blockMesh
|
||||
WarningIn(args[0])
|
||||
<< "Using the old blockMeshDict location: "
|
||||
<< dictPath << nl
|
||||
<< " instead of the default location: "
|
||||
<< runTime.system()/regionPath/dictName << nl
|
||||
<< endl;
|
||||
}
|
||||
// Otherwise assume the dictionary is present in the system directory
|
||||
else
|
||||
{
|
||||
dictPath = runTime.system()/regionPath/dictName;
|
||||
Info<< "Writing block structure as obj format: "
|
||||
<< os.name().name() << endl;
|
||||
|
||||
blocks.writeTopology(os);
|
||||
}
|
||||
|
||||
// Write centres of blocks
|
||||
{
|
||||
OFstream os(runTime.path()/"blockCentres.obj");
|
||||
|
||||
Info<< "Writing block centres as obj format: "
|
||||
<< os.name().name() << endl;
|
||||
|
||||
const polyMesh& topo = blocks.topology();
|
||||
|
||||
for (const point& cc : topo.cellCentres())
|
||||
{
|
||||
os << "v " << cc.x() << ' ' << cc.y() << ' ' << cc.z() << nl;
|
||||
}
|
||||
}
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!args.found("noClean"))
|
||||
{
|
||||
fileName polyMeshPath
|
||||
@ -205,74 +217,12 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
IOobject meshDictIO
|
||||
(
|
||||
dictPath,
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
);
|
||||
|
||||
if (!meshDictIO.typeHeaderOk<IOdictionary>(true))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< meshDictIO.objectPath()
|
||||
<< nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
Info<< "Creating block mesh from\n "
|
||||
<< meshDictIO.objectPath() << endl;
|
||||
|
||||
IOdictionary meshDict(meshDictIO);
|
||||
blockMesh blocks(meshDict, regionName);
|
||||
|
||||
if (args.found("blockTopology"))
|
||||
{
|
||||
// Write mesh as edges.
|
||||
{
|
||||
fileName objMeshFile("blockTopology.obj");
|
||||
|
||||
OFstream str(runTime.path()/objMeshFile);
|
||||
|
||||
Info<< nl << "Dumping block structure as Lightwave obj format"
|
||||
<< " to " << objMeshFile << endl;
|
||||
|
||||
blocks.writeTopology(str);
|
||||
}
|
||||
|
||||
// Write centres of blocks
|
||||
{
|
||||
fileName objCcFile("blockCentres.obj");
|
||||
|
||||
OFstream str(runTime.path()/objCcFile);
|
||||
|
||||
Info<< nl << "Dumping block centres as Lightwave obj format"
|
||||
<< " to " << objCcFile << endl;
|
||||
|
||||
const polyMesh& topo = blocks.topology();
|
||||
|
||||
const pointField& cellCentres = topo.cellCentres();
|
||||
|
||||
for (const point& cc : cellCentres)
|
||||
{
|
||||
//point cc = b.blockShape().centre(b.points());
|
||||
|
||||
str << "v " << cc.x() << ' ' << cc.y() << ' ' << cc.z() << nl;
|
||||
}
|
||||
}
|
||||
|
||||
Info<< nl << "end" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Info<< nl << "Creating polyMesh from blockMesh" << endl;
|
||||
|
||||
word defaultFacesName = "defaultFaces";
|
||||
word defaultFacesType = emptyPolyPatch::typeName;
|
||||
|
||||
polyMesh mesh
|
||||
(
|
||||
IOobject
|
||||
@ -290,97 +240,12 @@ int main(int argc, char *argv[])
|
||||
defaultFacesType
|
||||
);
|
||||
|
||||
// Read in a list of dictionaries for the merge patch pairs
|
||||
if (meshDict.found("mergePatchPairs"))
|
||||
{
|
||||
List<Pair<word>> mergePatchPairs
|
||||
(
|
||||
meshDict.lookup("mergePatchPairs")
|
||||
);
|
||||
|
||||
#include "mergePatchPairs.H"
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< nl << "There are no merge patch pairs edges" << endl;
|
||||
}
|
||||
// Handle merging of patch pairs. Dictionary entry "mergePatchPairs"
|
||||
#include "mergePatchPairs.H"
|
||||
|
||||
|
||||
// Set any cellZones (note: cell labelling unaffected by above
|
||||
// mergePatchPairs)
|
||||
|
||||
const label nZones = blocks.numZonedBlocks();
|
||||
if (nZones > 0)
|
||||
{
|
||||
Info<< nl << "Adding cell zones" << endl;
|
||||
|
||||
// Map from zoneName to cellZone index
|
||||
HashTable<label> zoneMap(nZones);
|
||||
|
||||
// Cells per zone.
|
||||
List<DynamicList<label>> zoneCells(nZones);
|
||||
|
||||
// Running cell counter
|
||||
label celli = 0;
|
||||
|
||||
// Largest zone so far
|
||||
label freeZoneI = 0;
|
||||
|
||||
forAll(blocks, blockI)
|
||||
{
|
||||
const block& b = blocks[blockI];
|
||||
const List<FixedList<label, 8>> blockCells = b.cells();
|
||||
const word& zoneName = b.zoneName();
|
||||
|
||||
if (zoneName.size())
|
||||
{
|
||||
HashTable<label>::const_iterator iter = zoneMap.find(zoneName);
|
||||
|
||||
label zoneI;
|
||||
|
||||
if (iter == zoneMap.end())
|
||||
{
|
||||
zoneI = freeZoneI++;
|
||||
|
||||
Info<< " " << zoneI << '\t' << zoneName << endl;
|
||||
|
||||
zoneMap.insert(zoneName, zoneI);
|
||||
}
|
||||
else
|
||||
{
|
||||
zoneI = iter();
|
||||
}
|
||||
|
||||
forAll(blockCells, i)
|
||||
{
|
||||
zoneCells[zoneI].append(celli++);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
celli += b.cells().size();
|
||||
}
|
||||
}
|
||||
|
||||
List<cellZone*> cz(zoneMap.size());
|
||||
forAllConstIter(HashTable<label>, zoneMap, iter)
|
||||
{
|
||||
label zoneI = iter();
|
||||
|
||||
cz[zoneI] = new cellZone
|
||||
(
|
||||
iter.key(),
|
||||
zoneCells[zoneI].shrink(),
|
||||
zoneI,
|
||||
mesh.cellZones()
|
||||
);
|
||||
}
|
||||
|
||||
mesh.pointZones().setSize(0);
|
||||
mesh.faceZones().setSize(0);
|
||||
mesh.cellZones().setSize(0);
|
||||
mesh.addZones(List<pointZone*>(0), List<faceZone*>(0), cz);
|
||||
}
|
||||
// Set any cellZones
|
||||
#include "addCellZones.H"
|
||||
|
||||
|
||||
// Detect any cyclic patches and force re-ordering of the faces
|
||||
@ -413,6 +278,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< nl << "Writing polyMesh with "
|
||||
<< mesh.cellZones().size() << " cellZones";
|
||||
|
||||
if (args.found("sets") && !mesh.cellZones().empty())
|
||||
{
|
||||
Info<< " (written as cellSets too)";
|
||||
@ -429,9 +295,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (args.found("sets"))
|
||||
{
|
||||
forAll(mesh.cellZones(), zonei)
|
||||
for (const cellZone& cz : mesh.cellZones())
|
||||
{
|
||||
const cellZone& cz = mesh.cellZones()[zonei];
|
||||
cellSet(mesh, cz.name(), cz).write();
|
||||
}
|
||||
}
|
||||
@ -453,11 +318,9 @@ int main(int argc, char *argv[])
|
||||
<< "Patches" << nl
|
||||
<< "----------------" << nl;
|
||||
|
||||
forAll(patches, patchi)
|
||||
for (const polyPatch& p : patches)
|
||||
{
|
||||
const polyPatch& p = patches[patchi];
|
||||
|
||||
Info<< " " << "patch " << patchi
|
||||
Info<< " " << "patch " << p.index()
|
||||
<< " (start: " << p.start()
|
||||
<< " size: " << p.size()
|
||||
<< ") name: " << p.name()
|
||||
|
||||
@ -0,0 +1,72 @@
|
||||
// Search for the appropriate blockMesh dictionary....
|
||||
const word dictName("blockMeshDict");
|
||||
|
||||
autoPtr<IOdictionary> meshDictPtr;
|
||||
|
||||
{
|
||||
fileName dictPath;
|
||||
|
||||
if (args.readIfPresent("dict", dictPath))
|
||||
{
|
||||
// Dictionary specified on the command-line ...
|
||||
|
||||
if (isDir(dictPath))
|
||||
{
|
||||
dictPath /= dictName;
|
||||
}
|
||||
}
|
||||
else if
|
||||
(
|
||||
exists
|
||||
(
|
||||
runTime.path()/runTime.constant()
|
||||
/regionPath/polyMesh::meshSubDir/dictName
|
||||
)
|
||||
)
|
||||
{
|
||||
// Dictionary present constant polyMesh directory (old-style)
|
||||
|
||||
dictPath =
|
||||
runTime.constant()
|
||||
/regionPath/polyMesh::meshSubDir/dictName;
|
||||
|
||||
|
||||
// Warn that constant/polyMesh/blockMeshDict was used
|
||||
// instead of system/blockMeshDict
|
||||
WarningIn(args.executable())
|
||||
<< "Using the old blockMeshDict location: "
|
||||
<< dictPath << nl
|
||||
<< " instead of the default location: "
|
||||
<< runTime.system()/regionPath/dictName << nl
|
||||
<< endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Assume dictionary is to be found in the system directory
|
||||
|
||||
dictPath = runTime.system()/regionPath/dictName;
|
||||
}
|
||||
|
||||
IOobject meshDictIO
|
||||
(
|
||||
dictPath,
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
);
|
||||
|
||||
if (!meshDictIO.typeHeaderOk<IOdictionary>(true))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< meshDictIO.objectPath() << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
Info<< "Creating block mesh from\n "
|
||||
<< meshDictIO.objectPath() << endl;
|
||||
|
||||
meshDictPtr = autoPtr<IOdictionary>::New(meshDictIO);
|
||||
}
|
||||
|
||||
const IOdictionary& meshDict = *meshDictPtr;
|
||||
@ -1,104 +1,118 @@
|
||||
if (mergePatchPairs.size())
|
||||
// Handle merging of patch pairs
|
||||
{
|
||||
List<Pair<word>> mergePatchPairs;
|
||||
|
||||
// Read in a list of dictionaries for the merge patch pairs
|
||||
if
|
||||
(
|
||||
meshDict.readIfPresent("mergePatchPairs", mergePatchPairs)
|
||||
&& mergePatchPairs.size()
|
||||
)
|
||||
{
|
||||
Info<< "Creating merge patch pairs" << nl << endl;
|
||||
|
||||
// Create and add point and face zones and mesh modifiers
|
||||
List<pointZone*> pz(mergePatchPairs.size());
|
||||
List<faceZone*> fz(3*mergePatchPairs.size());
|
||||
List<cellZone*> cz(0);
|
||||
|
||||
forAll(mergePatchPairs, pairI)
|
||||
{
|
||||
Info<< "Creating merge patch pairs" << nl << endl;
|
||||
const word mergeName
|
||||
(
|
||||
mergePatchPairs[pairI].first()
|
||||
+ mergePatchPairs[pairI].second()
|
||||
+ name(pairI)
|
||||
);
|
||||
|
||||
// Create and add point and face zones and mesh modifiers
|
||||
List<pointZone*> pz(mergePatchPairs.size());
|
||||
List<faceZone*> fz(3*mergePatchPairs.size());
|
||||
List<cellZone*> cz(0);
|
||||
// An empty zone for cut points
|
||||
pz[pairI] = new pointZone
|
||||
(
|
||||
mergeName + "CutPointZone",
|
||||
0,
|
||||
mesh.pointZones()
|
||||
);
|
||||
|
||||
forAll(mergePatchPairs, pairI)
|
||||
{
|
||||
const word mergeName
|
||||
(
|
||||
mergePatchPairs[pairI].first()
|
||||
+ mergePatchPairs[pairI].second()
|
||||
+ name(pairI)
|
||||
);
|
||||
|
||||
// An empty zone for cut points
|
||||
pz[pairI] = new pointZone
|
||||
(
|
||||
mergeName + "CutPointZone",
|
||||
0,
|
||||
mesh.pointZones()
|
||||
);
|
||||
|
||||
// Master patch
|
||||
const word masterPatchName(mergePatchPairs[pairI].first());
|
||||
const polyPatch& masterPatch =
|
||||
mesh.boundaryMesh()[masterPatchName];
|
||||
|
||||
fz[3*pairI] = new faceZone
|
||||
(
|
||||
mergeName + "MasterZone",
|
||||
identity(masterPatch.size(), masterPatch.start()),
|
||||
false, // none are flipped
|
||||
0,
|
||||
mesh.faceZones()
|
||||
);
|
||||
|
||||
// Slave patch
|
||||
const word slavePatchName(mergePatchPairs[pairI].second());
|
||||
const polyPatch& slavePatch =
|
||||
mesh.boundaryMesh()[slavePatchName];
|
||||
|
||||
fz[3*pairI + 1] = new faceZone
|
||||
(
|
||||
mergeName + "SlaveZone",
|
||||
identity(slavePatch.size(), slavePatch.start()),
|
||||
false, // none are flipped
|
||||
1,
|
||||
mesh.faceZones()
|
||||
);
|
||||
|
||||
// An empty zone for cut faces
|
||||
fz[3*pairI + 2] = new faceZone
|
||||
(
|
||||
mergeName + "CutFaceZone",
|
||||
2,
|
||||
mesh.faceZones()
|
||||
);
|
||||
} // end of all merge pairs
|
||||
|
||||
Info<< "Adding point and face zones" << endl;
|
||||
mesh.addZones(pz, fz, cz);
|
||||
|
||||
|
||||
Info<< "Creating attachPolyTopoChanger" << endl;
|
||||
attachPolyTopoChanger polyMeshAttacher(mesh);
|
||||
polyMeshAttacher.setSize(mergePatchPairs.size());
|
||||
|
||||
forAll(mergePatchPairs, pairI)
|
||||
{
|
||||
const word mergeName
|
||||
(
|
||||
mergePatchPairs[pairI].first()
|
||||
+ mergePatchPairs[pairI].second()
|
||||
+ name(pairI)
|
||||
);
|
||||
|
||||
// Add the sliding interface mesh modifier
|
||||
polyMeshAttacher.set
|
||||
// Master patch
|
||||
const word masterPatchName(mergePatchPairs[pairI].first());
|
||||
const polyPatch& masterPatch =
|
||||
mesh.boundaryMesh()[masterPatchName];
|
||||
|
||||
fz[3*pairI] = new faceZone
|
||||
(
|
||||
mergeName + "MasterZone",
|
||||
identity(masterPatch.size(), masterPatch.start()),
|
||||
false, // none are flipped
|
||||
0,
|
||||
mesh.faceZones()
|
||||
);
|
||||
|
||||
// Slave patch
|
||||
const word slavePatchName(mergePatchPairs[pairI].second());
|
||||
const polyPatch& slavePatch =
|
||||
mesh.boundaryMesh()[slavePatchName];
|
||||
|
||||
fz[3*pairI + 1] = new faceZone
|
||||
(
|
||||
mergeName + "SlaveZone",
|
||||
identity(slavePatch.size(), slavePatch.start()),
|
||||
false, // none are flipped
|
||||
1,
|
||||
mesh.faceZones()
|
||||
);
|
||||
|
||||
// An empty zone for cut faces
|
||||
fz[3*pairI + 2] = new faceZone
|
||||
(
|
||||
mergeName + "CutFaceZone",
|
||||
2,
|
||||
mesh.faceZones()
|
||||
);
|
||||
} // end of all merge pairs
|
||||
|
||||
Info<< "Adding point and face zones" << endl;
|
||||
mesh.addZones(pz, fz, cz);
|
||||
|
||||
|
||||
Info<< "Creating attachPolyTopoChanger" << endl;
|
||||
attachPolyTopoChanger polyMeshAttacher(mesh);
|
||||
polyMeshAttacher.setSize(mergePatchPairs.size());
|
||||
|
||||
forAll(mergePatchPairs, pairI)
|
||||
{
|
||||
const word mergeName
|
||||
(
|
||||
mergePatchPairs[pairI].first()
|
||||
+ mergePatchPairs[pairI].second()
|
||||
+ name(pairI)
|
||||
);
|
||||
|
||||
// Add the sliding interface mesh modifier
|
||||
polyMeshAttacher.set
|
||||
(
|
||||
pairI,
|
||||
new slidingInterface
|
||||
(
|
||||
"couple" + name(pairI),
|
||||
pairI,
|
||||
new slidingInterface
|
||||
(
|
||||
"couple" + name(pairI),
|
||||
pairI,
|
||||
polyMeshAttacher,
|
||||
mergeName + "MasterZone",
|
||||
mergeName + "SlaveZone",
|
||||
mergeName + "CutPointZone",
|
||||
mergeName + "CutFaceZone",
|
||||
mergePatchPairs[pairI].first(),
|
||||
mergePatchPairs[pairI].second(),
|
||||
slidingInterface::INTEGRAL, // always integral
|
||||
false,
|
||||
intersection::VISIBLE
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
polyMeshAttacher.attach(true);
|
||||
polyMeshAttacher,
|
||||
mergeName + "MasterZone",
|
||||
mergeName + "SlaveZone",
|
||||
mergeName + "CutPointZone",
|
||||
mergeName + "CutFaceZone",
|
||||
mergePatchPairs[pairI].first(),
|
||||
mergePatchPairs[pairI].second(),
|
||||
slidingInterface::INTEGRAL, // always integral
|
||||
false,
|
||||
intersection::VISIBLE
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
polyMeshAttacher.attach(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< nl << "There are no merge patch pairs" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -677,6 +677,11 @@ void writeMesh
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::addNote
|
||||
(
|
||||
"Automatic split hex mesher. Refines and snaps to surface"
|
||||
);
|
||||
|
||||
#include "addRegionOption.H"
|
||||
#include "addOverwriteOption.H"
|
||||
argList::addBoolOption
|
||||
|
||||
@ -82,8 +82,7 @@ void dumpPoints(const triSurface& surf, const labelList& borderPoint)
|
||||
{
|
||||
fileName fName("borderPoints.obj");
|
||||
|
||||
Info<< "Dumping borderPoints as Lightwave .obj file to " << fName
|
||||
<< "\nThis can be visualized with e.g. javaview (www.javaview.de)\n\n";
|
||||
Info<< "Dumping borderPoints as obj file: " << fName << endl;
|
||||
|
||||
OFstream os(fName);
|
||||
|
||||
@ -103,8 +102,7 @@ void dumpEdges(const triSurface& surf, const boolList& borderEdge)
|
||||
{
|
||||
fileName fName("borderEdges.obj");
|
||||
|
||||
Info<< "Dumping borderEdges as Lightwave .obj file to " << fName
|
||||
<< "\nThis can be visualized with e.g. javaview (www.javaview.de)\n\n";
|
||||
Info<< "Dumping borderEdges as obj file: " << fName << endl;
|
||||
|
||||
OFstream os(fName);
|
||||
|
||||
@ -129,7 +127,7 @@ void dumpFaces
|
||||
const Map<label>& connectedFaces
|
||||
)
|
||||
{
|
||||
Info<< "Dumping connectedFaces as .obj file to " << fName << nl;
|
||||
Info<< "Dumping connectedFaces as obj file: " << fName << endl;
|
||||
|
||||
OFstream os(fName);
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -80,16 +80,14 @@ Foam::blockMesh::blockMesh(const IOdictionary& dict, const word& regionName)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::blockMesh::~blockMesh()
|
||||
bool Foam::blockMesh::valid() const
|
||||
{
|
||||
delete topologyPtr_;
|
||||
return topologyPtr_.valid();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::blockMesh::verbose(const bool on)
|
||||
{
|
||||
verboseOutput = on;
|
||||
@ -191,17 +189,19 @@ Foam::wordList Foam::blockMesh::patchNames() const
|
||||
|
||||
Foam::label Foam::blockMesh::numZonedBlocks() const
|
||||
{
|
||||
label num = 0;
|
||||
const blockList& blocks = *this;
|
||||
|
||||
forAll(*this, blocki)
|
||||
label count = 0;
|
||||
|
||||
for (const block& blk : blocks)
|
||||
{
|
||||
if (operator[](blocki).zoneName().size())
|
||||
if (blk.zoneName().size())
|
||||
{
|
||||
num++;
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
||||
return num;
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
@ -209,19 +209,15 @@ void Foam::blockMesh::writeTopology(Ostream& os) const
|
||||
{
|
||||
const pointField& pts = topology().points();
|
||||
|
||||
forAll(pts, pI)
|
||||
for (const point& pt : pts)
|
||||
{
|
||||
const point& pt = pts[pI];
|
||||
|
||||
os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << endl;
|
||||
}
|
||||
|
||||
const edgeList& edges = topology().edges();
|
||||
|
||||
forAll(edges, eI)
|
||||
for (const edge& e : edges)
|
||||
{
|
||||
const edge& e = edges[eI];
|
||||
|
||||
os << "l " << e.start() + 1 << ' ' << e.end() + 1 << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -93,8 +93,9 @@ class blockMesh
|
||||
blockFaceList faces_;
|
||||
|
||||
//- The blocks themselves (the topology) as a polyMesh
|
||||
polyMesh* topologyPtr_;
|
||||
autoPtr<polyMesh> topologyPtr_;
|
||||
|
||||
//- The sum of all cells in each block
|
||||
label nPoints_;
|
||||
|
||||
//- The sum of all cells in each block
|
||||
@ -143,9 +144,13 @@ class blockMesh
|
||||
|
||||
void createCellShapes(cellShapeList& tmpBlockCells);
|
||||
|
||||
polyMesh* createTopology(const IOdictionary&, const word& regionName);
|
||||
autoPtr<polyMesh> createTopology
|
||||
(
|
||||
const IOdictionary& dict,
|
||||
const word& regionName
|
||||
);
|
||||
|
||||
void check(const polyMesh&, const dictionary&) const;
|
||||
void check(const polyMesh& bm, const dictionary& dict) const;
|
||||
|
||||
//- Determine the merge info and the final number of cells/points
|
||||
void calcMergeInfo();
|
||||
@ -159,9 +164,13 @@ class blockMesh
|
||||
void createCells() const;
|
||||
void createPatches() const;
|
||||
|
||||
//- As copy (not implemented)
|
||||
|
||||
//- No copy construct
|
||||
blockMesh(const blockMesh&) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const blockMesh&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -173,11 +182,11 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from IOdictionary
|
||||
blockMesh(const IOdictionary&, const word& regionName);
|
||||
blockMesh(const IOdictionary& dict, const word& regionName);
|
||||
|
||||
|
||||
//- Destructor
|
||||
~blockMesh();
|
||||
~blockMesh() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -196,6 +205,9 @@ public:
|
||||
return geometry_;
|
||||
}
|
||||
|
||||
//- True if the blockMesh topology exists
|
||||
bool valid() const;
|
||||
|
||||
//- Reference to point field defining the blockMesh
|
||||
// these points have not been scaled by scaleFactor
|
||||
const pointField& vertices() const;
|
||||
|
||||
@ -336,7 +336,7 @@ void Foam::blockMesh::createCellShapes
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::polyMesh* Foam::blockMesh::createTopology
|
||||
Foam::autoPtr<Foam::polyMesh> Foam::blockMesh::createTopology
|
||||
(
|
||||
const IOdictionary& meshDescription,
|
||||
const word& regionName
|
||||
@ -428,8 +428,7 @@ Foam::polyMesh* Foam::blockMesh::createTopology
|
||||
}
|
||||
|
||||
|
||||
|
||||
polyMesh* blockMeshPtr = nullptr;
|
||||
autoPtr<polyMesh> blockMeshPtr;
|
||||
|
||||
// Create the patches
|
||||
|
||||
@ -511,7 +510,7 @@ Foam::polyMesh* Foam::blockMesh::createTopology
|
||||
}
|
||||
}
|
||||
|
||||
blockMeshPtr = new polyMesh
|
||||
blockMeshPtr = autoPtr<polyMesh>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
@ -550,7 +549,7 @@ Foam::polyMesh* Foam::blockMesh::createTopology
|
||||
cellShapeList tmpBlockCells(blocks.size());
|
||||
createCellShapes(tmpBlockCells);
|
||||
|
||||
blockMeshPtr = new polyMesh
|
||||
blockMeshPtr = autoPtr<polyMesh>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
|
||||
@ -1296,10 +1296,7 @@ Foam::Map<Foam::label> Foam::surfaceFeatures::nearestSamples
|
||||
// Dump to obj file
|
||||
//
|
||||
|
||||
Pout<< endl
|
||||
<< "Dumping nearest surface feature points to nearestSamples.obj"
|
||||
<< endl
|
||||
<< "View this Lightwave-OBJ file with e.g. javaview" << endl
|
||||
Pout<< "Dumping nearest surface feature points to nearestSamples.obj"
|
||||
<< endl;
|
||||
|
||||
OFstream objStream("nearestSamples.obj");
|
||||
@ -1423,8 +1420,8 @@ Foam::Map<Foam::label> Foam::surfaceFeatures::nearestSamples
|
||||
{
|
||||
// Dump to obj file
|
||||
|
||||
Pout<< "Dumping nearest surface edges to nearestEdges.obj\n"
|
||||
<< "View this Lightwave-OBJ file with e.g. javaview\n" << endl;
|
||||
Pout<< "Dumping nearest surface edges to nearestEdges.obj"
|
||||
<< endl;
|
||||
|
||||
OFstream objStream("nearestEdges.obj");
|
||||
|
||||
@ -1577,8 +1574,8 @@ Foam::Map<Foam::pointIndexHit> Foam::surfaceFeatures::nearestEdges
|
||||
{
|
||||
// Dump to obj file
|
||||
|
||||
Pout<< "Dumping nearest surface feature edges to nearestEdges.obj\n"
|
||||
<< "View this Lightwave-OBJ file with e.g. javaview\n" << endl;
|
||||
Pout<< "Dumping nearest surface feature edges to nearestEdges.obj"
|
||||
<< endl;
|
||||
|
||||
OFstream objStream("nearestEdges.obj");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user