mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' of /home/dm4/OpenFOAM/OpenFOAM-dev
This commit is contained in:
@ -35,6 +35,16 @@ Description
|
||||
the boundary point intact. When both points inside it chooses random. When
|
||||
both points on boundary random again.
|
||||
|
||||
Usage
|
||||
- collapseEdges <edge length> <merge angle> [OPTION]
|
||||
|
||||
\param -allowCellCollapse \n
|
||||
Allow collapsing of cells to a single point
|
||||
|
||||
\param -meshQuality \n
|
||||
Only collapse if not exceeding user defined (in \a system/meshQualityDict)
|
||||
quality settings
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
@ -1178,7 +1188,7 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"checkMeshQuality",
|
||||
"meshQuality",
|
||||
"Only collapse if not exceeding given meshQualityDict limits"
|
||||
);
|
||||
|
||||
@ -1195,7 +1205,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
const bool allowCellCollapse = args.optionFound("allowCellCollapse");
|
||||
const bool overwrite = args.optionFound("overwrite");
|
||||
const bool checkQuality = args.optionFound("checkMeshQuality");
|
||||
const bool checkQuality = args.optionFound("meshQuality");
|
||||
|
||||
scalar maxCos = Foam::cos(degToRad(angle));
|
||||
|
||||
|
||||
@ -96,8 +96,9 @@ bool Foam::cellSizeControlSurfaces::evalCellSizeFunctions
|
||||
|
||||
if (cellSizeFunctions_.size())
|
||||
{
|
||||
// Initialise to the last (lowest) priority
|
||||
label previousPriority = cellSizeFunctions_.last().priority();
|
||||
// Maintain priority of current hit. Initialise so it always goes
|
||||
// through at least once.
|
||||
label previousPriority = -1;
|
||||
|
||||
forAll(cellSizeFunctions_, i)
|
||||
{
|
||||
|
||||
@ -196,7 +196,7 @@ void Foam::conformalVoronoiMesh::buildSurfaceConformation
|
||||
{
|
||||
if (vit->internalPoint() && !vit->nearBoundary())
|
||||
{
|
||||
const Foam::point& pt = topoint(vit->point());
|
||||
pointFromPoint pt = topoint(vit->point());
|
||||
const scalar range = sqr(2.0*targetCellSize(pt));
|
||||
|
||||
pointIndexHit pHit;
|
||||
|
||||
@ -238,6 +238,25 @@ int main(int argc, char *argv[])
|
||||
dict.lookup("constructFrom")
|
||||
);
|
||||
|
||||
// Any merging of small edges
|
||||
const scalar mergeTol(dict.lookupOrDefault<scalar>("mergeTol", 1e-4));
|
||||
|
||||
Info<< "Extruding from " << ExtrudeModeNames[mode]
|
||||
<< " using model " << model().type() << endl;
|
||||
if (flipNormals)
|
||||
{
|
||||
Info<< "Flipping normals before extruding" << endl;
|
||||
}
|
||||
if (mergeTol > 0)
|
||||
{
|
||||
Info<< "Collapsing edges < " << mergeTol << " of bounding box" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "Not collapsing any edges after extrusion" << endl;
|
||||
}
|
||||
Info<< endl;
|
||||
|
||||
|
||||
// Generated mesh (one of either)
|
||||
autoPtr<fvMesh> meshFromMesh;
|
||||
@ -251,10 +270,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (mode == PATCH || mode == MESH)
|
||||
{
|
||||
if (flipNormals)
|
||||
if (flipNormals && mode == MESH)
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "Flipping normals not supported for extrusions from patch."
|
||||
<< "Flipping normals not supported for extrusions from mesh."
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
@ -297,6 +316,60 @@ int main(int argc, char *argv[])
|
||||
addPatchCellLayer layerExtrude(mesh, (mode == MESH));
|
||||
|
||||
const labelList meshFaces(patchFaces(patches, sourcePatches));
|
||||
|
||||
if (mode == PATCH && flipNormals)
|
||||
{
|
||||
// Cheat. Flip patch faces in mesh. This invalidates the
|
||||
// mesh (open cells) but does produce the correct extrusion.
|
||||
polyTopoChange meshMod(mesh);
|
||||
forAll(meshFaces, i)
|
||||
{
|
||||
label meshFaceI = meshFaces[i];
|
||||
|
||||
label patchI = patches.whichPatch(meshFaceI);
|
||||
label own = mesh.faceOwner()[meshFaceI];
|
||||
label nei = -1;
|
||||
if (patchI == -1)
|
||||
{
|
||||
nei = mesh.faceNeighbour()[meshFaceI];
|
||||
}
|
||||
|
||||
label zoneI = mesh.faceZones().whichZone(meshFaceI);
|
||||
bool zoneFlip = false;
|
||||
if (zoneI != -1)
|
||||
{
|
||||
label index = mesh.faceZones()[zoneI].whichFace(meshFaceI);
|
||||
zoneFlip = mesh.faceZones()[zoneI].flipMap()[index];
|
||||
}
|
||||
|
||||
meshMod.modifyFace
|
||||
(
|
||||
mesh.faces()[meshFaceI].reverseFace(), // modified face
|
||||
meshFaceI, // label of face
|
||||
own, // owner
|
||||
nei, // neighbour
|
||||
true, // face flip
|
||||
patchI, // patch for face
|
||||
zoneI, // zone for face
|
||||
zoneFlip // face flip in zone
|
||||
);
|
||||
}
|
||||
|
||||
// Change the mesh. No inflation.
|
||||
autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh, false);
|
||||
|
||||
// Update fields
|
||||
mesh.updateMesh(map);
|
||||
|
||||
// Move mesh (since morphing does not do this)
|
||||
if (map().hasMotionPoints())
|
||||
{
|
||||
mesh.movePoints(map().preMotionPoints());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
indirectPrimitivePatch extrudePatch
|
||||
(
|
||||
IndirectList<face>
|
||||
@ -471,11 +544,6 @@ int main(int argc, char *argv[])
|
||||
displacement[pointI] = extrudePt - layer0Points[pointI];
|
||||
}
|
||||
|
||||
if (flipNormals)
|
||||
{
|
||||
Info<< "Flipping faces." << nl << endl;
|
||||
displacement = -displacement;
|
||||
}
|
||||
|
||||
// Check if wedge (has layer0 different from original patch points)
|
||||
// If so move the mesh to starting position.
|
||||
@ -666,7 +734,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
const boundBox& bb = mesh.bounds();
|
||||
const vector span = bb.span();
|
||||
const scalar mergeDim = 1e-4 * bb.minDim();
|
||||
const scalar mergeDim = mergeTol * bb.minDim();
|
||||
|
||||
Info<< "Mesh bounding box : " << bb << nl
|
||||
<< " with span : " << span << nl
|
||||
@ -677,6 +745,7 @@ int main(int argc, char *argv[])
|
||||
// Collapse edges
|
||||
// ~~~~~~~~~~~~~~
|
||||
|
||||
if (mergeDim > 0)
|
||||
{
|
||||
Info<< "Collapsing edges < " << mergeDim << " ..." << nl << endl;
|
||||
|
||||
|
||||
@ -31,7 +31,8 @@ exposedPatchName movingWall;
|
||||
// If construct from surface:
|
||||
surface "movingWall.stl";
|
||||
|
||||
// Flip surface normals before usage.
|
||||
// Flip surface normals before usage. Valid only for extrude from surface or
|
||||
// patch.
|
||||
flipNormals false;
|
||||
|
||||
//- Linear extrusion in point-normal direction
|
||||
@ -87,4 +88,8 @@ sigmaRadialCoeffs
|
||||
// degree wedges.
|
||||
mergeFaces false; //true;
|
||||
|
||||
// Merge small edges. Fraction of bounding box.
|
||||
mergeTol 0;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -36,7 +36,7 @@ Usage
|
||||
\param -allTopology \n
|
||||
Checks all (including non finite-volume specific) addressing
|
||||
|
||||
\param -meshQualityDict \n
|
||||
\param -meshQuality \n
|
||||
Checks against user defined (in \a system/meshQualityDict) quality settings
|
||||
|
||||
\param -region \<name\> \n
|
||||
@ -81,7 +81,7 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"meshQualityDict",
|
||||
"meshQuality",
|
||||
"read user-defined mesh quality criterions from system/meshQualityDict"
|
||||
);
|
||||
|
||||
@ -93,7 +93,7 @@ int main(int argc, char *argv[])
|
||||
const bool noTopology = args.optionFound("noTopology");
|
||||
const bool allGeometry = args.optionFound("allGeometry");
|
||||
const bool allTopology = args.optionFound("allTopology");
|
||||
const bool meshQualityDict = args.optionFound("meshQualityDict");
|
||||
const bool meshQuality = args.optionFound("meshQuality");
|
||||
|
||||
if (noTopology)
|
||||
{
|
||||
@ -108,14 +108,14 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
Info<< "Enabling all geometry checks." << nl << endl;
|
||||
}
|
||||
if (meshQualityDict)
|
||||
if (meshQuality)
|
||||
{
|
||||
Info<< "Enabling user-defined geometry checks." << nl << endl;
|
||||
}
|
||||
|
||||
|
||||
autoPtr<IOdictionary> qualDict;
|
||||
if (meshQualityDict)
|
||||
if (meshQuality)
|
||||
{
|
||||
qualDict.reset
|
||||
(
|
||||
@ -166,7 +166,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
nFailedChecks += checkGeometry(mesh, allGeometry);
|
||||
|
||||
if (meshQualityDict)
|
||||
if (meshQuality)
|
||||
{
|
||||
nFailedChecks += checkMeshQuality(mesh, qualDict());
|
||||
}
|
||||
@ -191,7 +191,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
label nFailedChecks = checkGeometry(mesh, allGeometry);
|
||||
|
||||
if (meshQualityDict)
|
||||
if (meshQuality)
|
||||
{
|
||||
nFailedChecks += checkMeshQuality(mesh, qualDict());
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -206,6 +206,14 @@ int main(int argc, char *argv[])
|
||||
runTime
|
||||
);
|
||||
|
||||
// cvMesh vertices
|
||||
writeMeshObject<pointIOField>
|
||||
(
|
||||
"internalDelaunayVertices",
|
||||
regionPrefix,
|
||||
runTime
|
||||
);
|
||||
|
||||
if (runTime.writeFormat() == IOstream::ASCII)
|
||||
{
|
||||
// Only do zones when converting from binary to ascii
|
||||
|
||||
@ -51,9 +51,6 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
|
||||
// Check who has a mesh
|
||||
const bool haveMesh = isDir(io.time().path()/io.instance()/meshSubDir);
|
||||
|
||||
Pout<< "meshpath:" << io.time().path()/io.instance()/meshSubDir << endl;
|
||||
Pout<< "haveMesh:" << haveMesh << endl;
|
||||
|
||||
if (!haveMesh)
|
||||
{
|
||||
// Create dummy mesh. Only used on procs that don't have mesh.
|
||||
@ -293,8 +290,10 @@ Pout<< "haveMesh:" << haveMesh << endl;
|
||||
if (!haveMesh)
|
||||
{
|
||||
// We created a dummy mesh file above. Delete it.
|
||||
//Pout<< "Removing dummy mesh " << io.objectPath() << endl;
|
||||
rmDir(io.objectPath());
|
||||
const fileName meshFiles = io.time().path()/io.instance()/meshSubDir;
|
||||
//Pout<< "Removing dummy mesh " << meshFiles << endl;
|
||||
mesh.removeFiles();
|
||||
rmDir(meshFiles);
|
||||
}
|
||||
|
||||
// Force recreation of globalMeshData.
|
||||
|
||||
@ -3,7 +3,7 @@ autoPtr<basicThermo> thermo
|
||||
basicThermo::New(mesh)
|
||||
);
|
||||
|
||||
const volScalarField& h = thermo->h();
|
||||
const volScalarField& h = thermo->he();
|
||||
|
||||
volScalarField rho
|
||||
(
|
||||
|
||||
@ -32,7 +32,6 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "hCombustionThermo.H"
|
||||
#include "RASModel.H"
|
||||
#include "wallFvPatch.H"
|
||||
|
||||
@ -41,7 +40,7 @@ Description
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
timeSelector::addOptions();
|
||||
# include "addRegionOption.H"
|
||||
#include "addRegionOption.H"
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
instantList timeDirs = timeSelector::select0(runTime, args);
|
||||
|
||||
@ -472,6 +472,33 @@ void unmarkBaffles
|
||||
}
|
||||
|
||||
|
||||
void writeStats(const extendedFeatureEdgeMesh& fem, Ostream& os)
|
||||
{
|
||||
os << " points : " << fem.points().size() << nl
|
||||
<< " of which" << nl
|
||||
<< " convex : "
|
||||
<< fem.concaveStart() << nl
|
||||
<< " concave : "
|
||||
<< (fem.mixedStart()-fem.concaveStart()) << nl
|
||||
<< " mixed : "
|
||||
<< (fem.nonFeatureStart()-fem.mixedStart()) << nl
|
||||
<< " non-feature : "
|
||||
<< (fem.points().size()-fem.nonFeatureStart()) << nl
|
||||
<< " edges : " << fem.edges().size() << nl
|
||||
<< " of which" << nl
|
||||
<< " external edges : "
|
||||
<< fem.internalStart() << nl
|
||||
<< " internal edges : "
|
||||
<< (fem.flatStart()- fem.internalStart()) << nl
|
||||
<< " flat edges : "
|
||||
<< (fem.openStart()- fem.flatStart()) << nl
|
||||
<< " open edges : "
|
||||
<< (fem.multipleStart()- fem.openStart()) << nl
|
||||
<< " multiply connected : "
|
||||
<< (fem.edges().size()- fem.multipleStart()) << nl;
|
||||
}
|
||||
|
||||
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@ -514,7 +541,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
forAllConstIter(dictionary, dict, iter)
|
||||
{
|
||||
dictionary surfaceDict = dict.subDict(iter().keyword());
|
||||
const dictionary& surfaceDict = iter().dict();
|
||||
|
||||
const fileName surfFileName = iter().keyword();
|
||||
const fileName sFeatFileName = surfFileName.lessExt().name();
|
||||
@ -522,16 +549,16 @@ int main(int argc, char *argv[])
|
||||
Info<< "Surface : " << surfFileName << nl << endl;
|
||||
|
||||
const Switch writeVTK =
|
||||
surfaceDict.lookupOrAddDefault<Switch>("writeVTK", "off");
|
||||
surfaceDict.lookupOrDefault<Switch>("writeVTK", "off");
|
||||
const Switch writeObj =
|
||||
surfaceDict.lookupOrAddDefault<Switch>("writeObj", "off");
|
||||
surfaceDict.lookupOrDefault<Switch>("writeObj", "off");
|
||||
|
||||
const Switch curvature =
|
||||
surfaceDict.lookupOrAddDefault<Switch>("curvature", "off");
|
||||
surfaceDict.lookupOrDefault<Switch>("curvature", "off");
|
||||
const Switch featureProximity =
|
||||
surfaceDict.lookupOrAddDefault<Switch>("featureProximity", "off");
|
||||
surfaceDict.lookupOrDefault<Switch>("featureProximity", "off");
|
||||
const Switch closeness =
|
||||
surfaceDict.lookupOrAddDefault<Switch>("closeness", "off");
|
||||
surfaceDict.lookupOrDefault<Switch>("closeness", "off");
|
||||
|
||||
const word extractionMethod = surfaceDict.lookup("extractionMethod");
|
||||
|
||||
@ -579,7 +606,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
|
||||
// Either construct features from surface & featureAngle or read set.
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
surfaceFeatures set(surf);
|
||||
|
||||
@ -670,7 +697,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (surfaceDict.isDict("subsetFeatures"))
|
||||
{
|
||||
dictionary subsetDict = surfaceDict.subDict("subsetFeatures");
|
||||
const dictionary& subsetDict = surfaceDict.subDict
|
||||
(
|
||||
"subsetFeatures"
|
||||
);
|
||||
|
||||
if (subsetDict.found("insideBox"))
|
||||
{
|
||||
@ -704,7 +734,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
const Switch manifoldEdges =
|
||||
subsetDict.lookupOrAddDefault<Switch>("manifoldEdges", "no");
|
||||
subsetDict.lookupOrDefault<Switch>("manifoldEdges", "no");
|
||||
|
||||
if (manifoldEdges)
|
||||
{
|
||||
@ -746,16 +776,6 @@ int main(int argc, char *argv[])
|
||||
// newSet.writeObj("final");
|
||||
//}
|
||||
|
||||
Info<< nl
|
||||
<< "Final feature set after trimming and subsetting:" << nl
|
||||
<< " feature points : " << newSet.featurePoints().size() << nl
|
||||
<< " feature edges : " << newSet.featureEdges().size() << nl
|
||||
<< " of which" << nl
|
||||
<< " region edges : " << newSet.nRegionEdges() << nl
|
||||
<< " external edges : " << newSet.nExternalEdges() << nl
|
||||
<< " internal edges : " << newSet.nInternalEdges() << nl
|
||||
<< endl;
|
||||
|
||||
// Extracting and writing a extendedFeatureEdgeMesh
|
||||
extendedFeatureEdgeMesh feMesh
|
||||
(
|
||||
@ -764,6 +784,51 @@ int main(int argc, char *argv[])
|
||||
sFeatFileName + ".extendedFeatureEdgeMesh"
|
||||
);
|
||||
|
||||
|
||||
if (surfaceDict.isDict("addFeatures"))
|
||||
{
|
||||
const dictionary& subsetDict = surfaceDict.subDict
|
||||
(
|
||||
"addFeatures"
|
||||
);
|
||||
|
||||
const word addFeName = subsetDict["name"];
|
||||
Info<< "Adding (without merging) features from " << addFeName
|
||||
<< nl << endl;
|
||||
|
||||
const Switch flip = subsetDict["flip"];
|
||||
|
||||
extendedFeatureEdgeMesh addFeMesh
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
addFeName,
|
||||
runTime.time().constant(),
|
||||
"extendedFeatureEdgeMesh",
|
||||
runTime.time(),
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
Info<< "Read " << addFeMesh.name() << nl;
|
||||
writeStats(addFeMesh, Info);
|
||||
|
||||
if (flip)
|
||||
{
|
||||
Info<< "Flipping " << addFeMesh.name() << endl;
|
||||
addFeMesh.flipNormals();
|
||||
Info<< "After flipping " << addFeMesh.name() << nl;
|
||||
writeStats(addFeMesh, Info);
|
||||
}
|
||||
|
||||
feMesh.add(addFeMesh);
|
||||
}
|
||||
|
||||
|
||||
Info<< nl
|
||||
<< "Final feature set:" << nl;
|
||||
writeStats(feMesh, Info);
|
||||
|
||||
Info<< nl << "Writing extendedFeatureEdgeMesh to "
|
||||
<< feMesh.objectPath() << endl;
|
||||
|
||||
|
||||
@ -70,6 +70,12 @@ surface2.nas
|
||||
manifoldEdges no;
|
||||
}
|
||||
|
||||
addFeatures
|
||||
{
|
||||
// Add (without merging) another extendedFeatureEdgeMesh
|
||||
name axZ.extendedFeatureEdgeMesh;
|
||||
}
|
||||
|
||||
// Output the curvature of the surface
|
||||
curvature no;
|
||||
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/triSurface/lnInclude
|
||||
-I$(LIB_SRC)/surfMesh/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lmeshTools \
|
||||
-ltriSurface
|
||||
-lsurfMesh
|
||||
|
||||
|
||||
@ -22,23 +22,29 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Extracts triSurface from a polyMesh. Triangulates all boundary faces.
|
||||
Region numbers on triangles are the patch numbers of the polyMesh.
|
||||
Extracts surface from a polyMesh. Depending on output surface format
|
||||
triangulates faces.
|
||||
|
||||
Region numbers on faces cannot be guaranteed to be the same as the patch
|
||||
indices.
|
||||
|
||||
Optionally only triangulates named patches.
|
||||
|
||||
If run in parallel the processor patches get filtered out by default and
|
||||
the mesh gets merged. (based on vertex position, not topology, so might go
|
||||
wrong!).
|
||||
the mesh gets merged (based on topology).
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
#include "argList.H"
|
||||
#include "Time.H"
|
||||
#include "polyMesh.H"
|
||||
#include "triSurface.H"
|
||||
#include "triSurfaceTools.H"
|
||||
#include "processorPolyPatch.H"
|
||||
#include "ListListOps.H"
|
||||
#include "uindirectPrimitivePatch.H"
|
||||
#include "globalMeshData.H"
|
||||
#include "globalIndex.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -50,7 +56,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
argList::addNote
|
||||
(
|
||||
"extract surface from a polyMesh and triangulate boundary faces"
|
||||
"extract surface from a polyMesh"
|
||||
);
|
||||
argList::validArgs.append("output file");
|
||||
#include "addRegionOption.H"
|
||||
@ -63,27 +69,37 @@ int main(int argc, char *argv[])
|
||||
(
|
||||
"patches",
|
||||
"(patch0 .. patchN)",
|
||||
"only triangulate named patches"
|
||||
"only triangulate selected patches (wildcards supported)"
|
||||
);
|
||||
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
const fileName outFileName(runTime.path()/args[1]);
|
||||
const word outFileName(args[1]);
|
||||
|
||||
Info<< "Extracting triSurface from boundaryMesh ..."
|
||||
Info<< "Extracting surface from boundaryMesh ..."
|
||||
<< endl << endl;
|
||||
|
||||
Pout<< "Reading mesh from time " << runTime.value() << endl;
|
||||
|
||||
#include "createNamedPolyMesh.H"
|
||||
|
||||
const bool includeProcPatches =
|
||||
!(
|
||||
args.optionFound("excludeProcPatches")
|
||||
|| Pstream::parRun()
|
||||
);
|
||||
|
||||
if (includeProcPatches)
|
||||
{
|
||||
Info<< "Including all processor patches." << nl << endl;
|
||||
}
|
||||
else if (Pstream::parRun())
|
||||
{
|
||||
Info<< "Excluding all processor patches." << nl << endl;
|
||||
}
|
||||
|
||||
Info<< "Reading mesh from time " << runTime.value() << endl;
|
||||
|
||||
#include "createNamedPolyMesh.H"
|
||||
|
||||
|
||||
// Create local surface from:
|
||||
// - explicitly named patches only (-patches (at your option)
|
||||
// - all patches (default in sequential mode)
|
||||
@ -98,24 +114,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (args.optionFound("patches"))
|
||||
{
|
||||
const wordList patchNames
|
||||
includePatches = bMesh.patchSet
|
||||
(
|
||||
args.optionLookup("patches")()
|
||||
wordReList(args.optionLookup("patches")())
|
||||
);
|
||||
|
||||
forAll(patchNames, patchNameI)
|
||||
{
|
||||
const word& patchName = patchNames[patchNameI];
|
||||
const label patchI = bMesh.findPatchID(patchName);
|
||||
|
||||
if (patchI == -1)
|
||||
{
|
||||
FatalErrorIn(args.executable()) << "No such patch "
|
||||
<< patchName << endl << "Patches are " << bMesh.names()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
includePatches.insert(patchI);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -127,212 +129,155 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
includePatches.insert(patchI);
|
||||
}
|
||||
else
|
||||
{
|
||||
Pout<< patch.name() << " : skipped since processorPatch"
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
triSurface localSurface
|
||||
|
||||
|
||||
// Collect sizes. Hash on names to handle local-only patches (e.g.
|
||||
// processor patches)
|
||||
HashTable<label> patchSize(1000);
|
||||
label nFaces = 0;
|
||||
forAllConstIter(labelHashSet, includePatches, iter)
|
||||
{
|
||||
const polyPatch& pp = bMesh[iter.key()];
|
||||
patchSize.insert(pp.name(), pp.size());
|
||||
nFaces += pp.size();
|
||||
}
|
||||
Pstream::mapCombineGather(patchSize, plusEqOp<label>());
|
||||
|
||||
|
||||
// Allocate zone/patch for all patches
|
||||
HashTable<label> compactZoneID(1000);
|
||||
forAllConstIter(HashTable<label>, patchSize, iter)
|
||||
{
|
||||
label sz = compactZoneID.size();
|
||||
compactZoneID.insert(iter.key(), sz);
|
||||
}
|
||||
Pstream::mapCombineScatter(compactZoneID);
|
||||
|
||||
|
||||
// Rework HashTable into labelList just for speed of conversion
|
||||
labelList patchToCompactZone(bMesh.size(), -1);
|
||||
forAllConstIter(HashTable<label>, compactZoneID, iter)
|
||||
{
|
||||
label patchI = bMesh.findPatchID(iter.key());
|
||||
if (patchI != -1)
|
||||
{
|
||||
patchToCompactZone[patchI] = iter();
|
||||
}
|
||||
}
|
||||
|
||||
// Collect faces on zones
|
||||
DynamicList<label> faceLabels(nFaces);
|
||||
DynamicList<label> compactZones(nFaces);
|
||||
forAllConstIter(labelHashSet, includePatches, iter)
|
||||
{
|
||||
const polyPatch& pp = bMesh[iter.key()];
|
||||
forAll(pp, i)
|
||||
{
|
||||
faceLabels.append(pp.start()+i);
|
||||
compactZones.append(patchToCompactZone[pp.index()]);
|
||||
}
|
||||
}
|
||||
|
||||
// Addressing engine for all faces
|
||||
uindirectPrimitivePatch allBoundary
|
||||
(
|
||||
triSurfaceTools::triangulate
|
||||
(
|
||||
mesh.boundaryMesh(),
|
||||
includePatches
|
||||
)
|
||||
UIndirectList<face>(mesh.faces(), faceLabels),
|
||||
mesh.points()
|
||||
);
|
||||
|
||||
|
||||
// Find correspondence to master points
|
||||
labelList pointToGlobal;
|
||||
labelList uniqueMeshPoints;
|
||||
autoPtr<globalIndex> globalNumbers = mesh.globalData().mergePoints
|
||||
(
|
||||
allBoundary.meshPoints(),
|
||||
allBoundary.meshPointMap(),
|
||||
pointToGlobal,
|
||||
uniqueMeshPoints
|
||||
);
|
||||
|
||||
if (!Pstream::parRun())
|
||||
// Gather all unique points on master
|
||||
List<pointField> gatheredPoints(Pstream::nProcs());
|
||||
gatheredPoints[Pstream::myProcNo()] = pointField
|
||||
(
|
||||
mesh.points(),
|
||||
uniqueMeshPoints
|
||||
);
|
||||
Pstream::gatherList(gatheredPoints);
|
||||
|
||||
// Gather all faces
|
||||
List<faceList> gatheredFaces(Pstream::nProcs());
|
||||
gatheredFaces[Pstream::myProcNo()] = allBoundary.localFaces();
|
||||
forAll(gatheredFaces[Pstream::myProcNo()], i)
|
||||
{
|
||||
Info<< "Writing surface to " << outFileName << endl;
|
||||
|
||||
localSurface.write(outFileName);
|
||||
inplaceRenumber(pointToGlobal, gatheredFaces[Pstream::myProcNo()][i]);
|
||||
}
|
||||
else
|
||||
Pstream::gatherList(gatheredFaces);
|
||||
|
||||
// Gather all ZoneIDs
|
||||
List<labelList> gatheredZones(Pstream::nProcs());
|
||||
gatheredZones[Pstream::myProcNo()] = compactZones.xfer();
|
||||
Pstream::gatherList(gatheredZones);
|
||||
|
||||
// On master combine all points, faces, zones
|
||||
if (Pstream::master())
|
||||
{
|
||||
// Write local surface
|
||||
fileName localPath = runTime.path()/runTime.caseName() + ".obj";
|
||||
pointField allPoints = ListListOps::combine<pointField>
|
||||
(
|
||||
gatheredPoints,
|
||||
accessOp<pointField>()
|
||||
);
|
||||
gatheredPoints.clear();
|
||||
|
||||
Pout<< "Writing local surface to " << localPath << endl;
|
||||
faceList allFaces = ListListOps::combine<faceList>
|
||||
(
|
||||
gatheredFaces,
|
||||
accessOp<faceList>()
|
||||
);
|
||||
gatheredFaces.clear();
|
||||
|
||||
localSurface.write(localPath);
|
||||
|
||||
Info<< endl;
|
||||
labelList allZones = ListListOps::combine<labelList>
|
||||
(
|
||||
gatheredZones,
|
||||
accessOp<labelList>()
|
||||
);
|
||||
gatheredZones.clear();
|
||||
|
||||
|
||||
// Gather all points on master
|
||||
List<pointField> gatheredPoints(Pstream::nProcs());
|
||||
|
||||
gatheredPoints[Pstream::myProcNo()] = localSurface.points();
|
||||
|
||||
Pstream::gatherList(gatheredPoints);
|
||||
|
||||
|
||||
// Gather all localSurface patches
|
||||
List<geometricSurfacePatchList> gatheredPatches(Pstream::nProcs());
|
||||
|
||||
gatheredPatches[Pstream::myProcNo()] = localSurface.patches();
|
||||
|
||||
Pstream::gatherList(gatheredPatches);
|
||||
|
||||
|
||||
// Gather all faces
|
||||
List<List<labelledTri> > gatheredFaces(Pstream::nProcs());
|
||||
|
||||
gatheredFaces[Pstream::myProcNo()] = localSurface;
|
||||
|
||||
Pstream::gatherList(gatheredFaces);
|
||||
|
||||
|
||||
if (Pstream::master())
|
||||
// Zones
|
||||
surfZoneIdentifierList surfZones(compactZoneID.size());
|
||||
forAllConstIter(HashTable<label>, compactZoneID, iter)
|
||||
{
|
||||
// On master combine all points
|
||||
pointField allPoints =
|
||||
ListListOps::combine<pointField>
|
||||
(
|
||||
gatheredPoints,
|
||||
accessOp<pointField>()
|
||||
);
|
||||
|
||||
// Count number of patches.
|
||||
label nPatches = 0;
|
||||
|
||||
forAll(gatheredPatches, procI)
|
||||
{
|
||||
nPatches += gatheredPatches[procI].size();
|
||||
}
|
||||
|
||||
// Count number of faces.
|
||||
label nFaces = 0;
|
||||
|
||||
forAll(gatheredFaces, procI)
|
||||
{
|
||||
nFaces += gatheredFaces[procI].size();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Loop over all processors and
|
||||
// - construct mapping from local to global patches
|
||||
// - relabel faces (both points and regions)
|
||||
|
||||
label newPatchI = 0;
|
||||
|
||||
// Name to new patchI
|
||||
HashTable<label> nameToIndex(2*nPatches);
|
||||
|
||||
// Storage (oversized) for all patches
|
||||
geometricSurfacePatchList allPatches(nPatches);
|
||||
|
||||
label newFaceI = 0;
|
||||
|
||||
// Storage for all faces
|
||||
List<labelledTri> allFaces(nFaces);
|
||||
|
||||
// Offset into allPoints for current processor
|
||||
label pointOffset = 0;
|
||||
|
||||
for (label procI = 0; procI < Pstream::nProcs(); procI++)
|
||||
{
|
||||
Info<< "Processor " << procI << endl
|
||||
<< "-----------" << endl;
|
||||
|
||||
const geometricSurfacePatchList& patches =
|
||||
gatheredPatches[procI];
|
||||
|
||||
// From local patch numbering to global
|
||||
labelList localToGlobal(patches.size());
|
||||
|
||||
forAll(patches, patchI)
|
||||
{
|
||||
const geometricSurfacePatch& sp = patches[patchI];
|
||||
|
||||
if (!nameToIndex.found(sp.name()))
|
||||
{
|
||||
nameToIndex.insert(sp.name(), newPatchI);
|
||||
|
||||
localToGlobal[patchI] = newPatchI;
|
||||
|
||||
allPatches[newPatchI] = sp;
|
||||
|
||||
newPatchI++;
|
||||
}
|
||||
else
|
||||
{
|
||||
localToGlobal[patchI] = nameToIndex[sp.name()];
|
||||
}
|
||||
}
|
||||
|
||||
Info<< "Local patch to global patch mapping:"
|
||||
<< endl;
|
||||
|
||||
forAll(patches, patchI)
|
||||
{
|
||||
Info<< " name : " << patches[patchI].name() << endl
|
||||
<< " local : " << patchI << endl
|
||||
<< " global : " << localToGlobal[patchI]
|
||||
<< endl;
|
||||
}
|
||||
|
||||
Info<< "Local points added in global points starting at "
|
||||
<< pointOffset
|
||||
<< endl;
|
||||
|
||||
|
||||
// Collect and relabel faces
|
||||
const List<labelledTri>& localFaces = gatheredFaces[procI];
|
||||
|
||||
|
||||
forAll(localFaces, faceI)
|
||||
{
|
||||
const labelledTri& f = localFaces[faceI];
|
||||
|
||||
allFaces[newFaceI++] =
|
||||
labelledTri
|
||||
(
|
||||
f[0] + pointOffset,
|
||||
f[1] + pointOffset,
|
||||
f[2] + pointOffset,
|
||||
localToGlobal[f.region()]
|
||||
);
|
||||
}
|
||||
|
||||
pointOffset += gatheredPoints[procI].size();
|
||||
|
||||
Info<< endl;
|
||||
}
|
||||
allPatches.setSize(newPatchI);
|
||||
|
||||
// We now have allPoints, allFaces and allPatches.
|
||||
// Construct overall (yet unmerged) surface from these.
|
||||
|
||||
triSurface allSurf(allFaces, allPatches, allPoints);
|
||||
|
||||
// Cleanup (which does point merge as well)
|
||||
allSurf.cleanup(false);
|
||||
|
||||
// Write surface mesh
|
||||
|
||||
label slashIndex = runTime.caseName().find_last_of('/');
|
||||
|
||||
fileName globalCasePath(runTime.caseName().substr(0, slashIndex));
|
||||
|
||||
Info<< "Writing merged surface to " << globalCasePath << endl;
|
||||
|
||||
// create database for the sequential run
|
||||
fileName globalPath
|
||||
(
|
||||
runTime.rootPath()
|
||||
/ globalCasePath
|
||||
/ args[1]
|
||||
);
|
||||
|
||||
allSurf.write(globalPath);
|
||||
surfZones[iter()] = surfZoneIdentifier(iter.key(), iter());
|
||||
Info<< "surfZone " << iter() << " : " << surfZones[iter()].name()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
UnsortedMeshedSurface<face> unsortedFace
|
||||
(
|
||||
xferMove(allPoints),
|
||||
xferMove(allFaces),
|
||||
xferMove(allZones),
|
||||
xferMove(surfZones)
|
||||
);
|
||||
|
||||
|
||||
MeshedSurface<face> sortedFace(unsortedFace);
|
||||
|
||||
fileName globalCasePath
|
||||
(
|
||||
runTime.processorCase()
|
||||
? runTime.path()/".."/outFileName
|
||||
: runTime.path()/outFileName
|
||||
);
|
||||
|
||||
Info<< "Writing merged surface to " << globalCasePath << endl;
|
||||
|
||||
sortedFace.write(globalCasePath);
|
||||
}
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -37,12 +37,13 @@ Description
|
||||
#include "OSspecific.H"
|
||||
|
||||
#include "specieThermo.H"
|
||||
#include "absoluteEnthalpy.H"
|
||||
#include "janafThermo.H"
|
||||
#include "perfectGas.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
typedef specieThermo<janafThermo<perfectGas> > thermo;
|
||||
typedef specieThermo<janafThermo<perfectGas>, absoluteEnthalpy> thermo;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -178,7 +179,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "products " << (1/products.nMoles())*products << ';' << endl;
|
||||
|
||||
scalar Tad = products.TH(reactants.H(T0), 1000.0);
|
||||
scalar Tad = products.THa(reactants.Ha(T0), 1000.0);
|
||||
Info<< "Tad = " << Tad << nl << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -36,13 +36,14 @@ Description
|
||||
#include "IOmanip.H"
|
||||
|
||||
#include "specieThermo.H"
|
||||
#include "absoluteEnthalpy.H"
|
||||
#include "janafThermo.H"
|
||||
#include "perfectGas.H"
|
||||
#include "SLPtrList.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
typedef specieThermo<janafThermo<perfectGas> > thermo;
|
||||
typedef specieThermo<janafThermo<perfectGas>, absoluteEnthalpy> thermo;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -39,12 +39,13 @@ Description
|
||||
#include "IOmanip.H"
|
||||
|
||||
#include "specieThermo.H"
|
||||
#include "absoluteEnthalpy.H"
|
||||
#include "janafThermo.H"
|
||||
#include "perfectGas.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
typedef specieThermo<janafThermo<perfectGas> > thermo;
|
||||
typedef specieThermo<janafThermo<perfectGas>, absoluteEnthalpy> thermo;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -241,7 +242,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
|
||||
scalar equilibriumFlameTemperatureNew =
|
||||
products.TH(reactants.H(T0), adiabaticFlameTemperature);
|
||||
products.THa(reactants.Ha(T0), adiabaticFlameTemperature);
|
||||
|
||||
if (j==0)
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -36,13 +36,14 @@ Description
|
||||
#include "OSspecific.H"
|
||||
|
||||
#include "specieThermo.H"
|
||||
#include "absoluteEnthalpy.H"
|
||||
#include "janafThermo.H"
|
||||
#include "perfectGas.H"
|
||||
#include "mixture.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
typedef specieThermo<janafThermo<perfectGas> > thermo;
|
||||
typedef specieThermo<janafThermo<perfectGas>, absoluteEnthalpy> thermo;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -115,7 +116,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
Info<< "Adiabatic flame temperature of mixture " << rMix.name() << " = "
|
||||
<< products.TH(reactants.H(T0), 1000.0) << " K" << endl;
|
||||
<< products.THa(reactants.Ha(T0), 1000.0) << " K" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user