Port update: to utilities/post-processing

This commit is contained in:
Hrvoje Jasak 2010-08-25 22:42:57 +01:00
parent 903edadc00
commit 773cdd6f3e
583 changed files with 134042 additions and 6031 deletions

View file

@ -412,7 +412,7 @@ bool limitRefinementLevel
}
}
if (addCutCells.size() > 0)
if (addCutCells.size())
{
// Add cells to cutCells.
@ -478,7 +478,7 @@ void doRefinement
{
const labelList& added = addedCells[oldCellI];
if (added.size() > 0)
if (added.size())
{
// Give all cells resulting from split the refinement level
// of the master.
@ -894,7 +894,7 @@ int main(int argc, char *argv[])
<< " Selected for refinement :" << cutCells.size() << nl
<< endl;
if (cutCells.size() == 0)
if (cutCells.empty())
{
Info<< "Stopping refining since 0 cells selected to be refined ..."
<< nl << endl;

View file

@ -1,21 +1,14 @@
/*---------------------------------------------------------------------------*\
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.0 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\ / O peration | Version: 1.6 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
root "/home/penfold/mattijs/foam/mattijs2.1/run/icoFoam";
case "cavity";
instance "system";
local "";
class dictionary;
object autoRefineMeshDict;
}

View file

@ -47,7 +47,7 @@ Description
#include "polyMesh.H"
#include "mapPolyMesh.H"
#include "mathematicalConstants.H"
#include "PackedList.H"
#include "PackedBoolList.H"
#include "SortableList.H"
using namespace Foam;
@ -73,20 +73,17 @@ labelList getSortedEdges
const edge& e = edges[edgeI];
label fp = findIndex(f, e[0]);
label fp1 = (fp+1) % f.size();
label fp1 = f.fcIndex(fp);
if (f[fp1] == e[1])
{
// Edgei in fp-fp1 order
// EdgeI between fp -> fp1
faceEdges[fp] = edgeI;
}
else
{
// Edgei between fp-1 and fp
label fpMin1 = (fp == 0 ? f.size()-1 : fp-1);
faceEdges[fpMin1] = edgeI;
// EdgeI between fp-1 -> fp
faceEdges[f.rcIndex(fp)] = edgeI;
}
}
@ -176,7 +173,7 @@ label mergeEdges
// Return master point edge needs to be collapsed to (or -1)
label edgeMaster(const PackedList<1>& boundaryPoint, const edge& e)
label edgeMaster(const PackedBoolList& boundaryPoint, const edge& e)
{
label masterPoint = -1;
@ -214,7 +211,7 @@ label edgeMaster(const PackedList<1>& boundaryPoint, const edge& e)
label collapseSmallEdges
(
const polyMesh& mesh,
const PackedList<1>& boundaryPoint,
const PackedBoolList& boundaryPoint,
const scalar minLen,
edgeCollapser& collapser
)
@ -253,7 +250,7 @@ label collapseSmallEdges
label collapseHighAspectFaces
(
const polyMesh& mesh,
const PackedList<1>& boundaryPoint,
const PackedBoolList& boundaryPoint,
const scalar areaFac,
const scalar edgeRatio,
edgeCollapser& collapser
@ -345,7 +342,7 @@ void set(const labelList& elems, const bool val, boolList& status)
label simplifyFaces
(
const polyMesh& mesh,
const PackedList<1>& boundaryPoint,
const PackedBoolList& boundaryPoint,
const label minSize,
const scalar lenGap,
edgeCollapser& collapser
@ -461,13 +458,15 @@ int main(int argc, char *argv[])
# include "setRootCase.H"
# include "createTime.H"
runTime.functionObjects().off();
# include "createPolyMesh.H"
const word oldInstance = mesh.pointsInstance();
scalar minLen(readScalar(IStringStream(args.additionalArgs()[0])()));
scalar angle(readScalar(IStringStream(args.additionalArgs()[1])()));
bool overwrite = args.options().found("overwrite");
bool overwrite = args.optionFound("overwrite");
scalar maxCos = Foam::cos(angle*180/mathematicalConstant::pi);
scalar maxCos = Foam::cos(angle*mathematicalConstant::pi/180.0);
Info<< "Merging:" << nl
<< " edges with length less than " << minLen << " meters" << nl
@ -483,7 +482,7 @@ int main(int argc, char *argv[])
const faceList& faces = mesh.faces();
// Get all points on the boundary
PackedList<1> boundaryPoint(mesh.nPoints(), false);
PackedBoolList boundaryPoint(mesh.nPoints());
label nIntFaces = mesh.nInternalFaces();
for (label faceI = nIntFaces; faceI < mesh.nFaces(); faceI++)
@ -585,8 +584,12 @@ int main(int argc, char *argv[])
{
runTime++;
}
else
{
mesh.setInstance(oldInstance);
}
Info << "Writing collapsed mesh to time " << runTime.value() << endl;
Info<< "Writing collapsed mesh to time " << runTime.timeName() << endl;
mesh.write();
}

View file

@ -123,8 +123,9 @@ void checkSnapMesh
Pout<< "Checking face angles" << endl;
label nOldSize = wrongFaces.size();
mesh.checkFaceAngles(false, &wrongFaces);
Pout<< "Detected additional concave " << wrongFaces.size() - nOldSize
mesh.checkFaceAngles(false, maxConcave, &wrongFaces);
Pout<< "Detected additional " << wrongFaces.size() - nOldSize
<< " faces with concavity > " << maxConcave << " degrees"
<< endl;
}
@ -176,7 +177,7 @@ label mergePatchFaces
List<faceList> allFaceSetsFaces(allFaceSets.size());
forAll(allFaceSets, setI)
{
allFaceSetsFaces[setI] = IndirectList<face>
allFaceSetsFaces[setI] = UIndirectList<face>
(
mesh.faces(),
allFaceSets[setI]
@ -438,26 +439,21 @@ int main(int argc, char *argv[])
# include "setRootCase.H"
# include "createTime.H"
runTime.functionObjects().off();
# include "createPolyMesh.H"
const word oldInstance = mesh.pointsInstance();
scalar featureAngle(readScalar(IStringStream(args.additionalArgs()[0])()));
scalar minCos = Foam::cos(featureAngle*mathematicalConstant::pi/180.0);
scalar concaveAngle = defaultConcaveAngle;
if (args.options().found("concaveAngle"))
{
concaveAngle = readScalar
(
IStringStream(args.options()["concaveAngle"])()
);
}
args.optionReadIfPresent("concaveAngle", concaveAngle);
scalar concaveSin = Foam::sin(concaveAngle*mathematicalConstant::pi/180.0);
bool snapMeshDict = args.options().found("snapMesh");
bool overwrite = args.options().found("overwrite");
bool snapMeshDict = args.optionFound("snapMesh");
bool overwrite = args.optionFound("overwrite");
Info<< "Merging all faces of a cell" << nl
<< " - which are on the same patch" << nl
@ -500,6 +496,11 @@ int main(int argc, char *argv[])
if (nChanged > 0)
{
if (overwrite)
{
mesh.setInstance(oldInstance);
}
Info<< "Writing morphed mesh to time " << runTime.timeName() << endl;
mesh.write();

View file

@ -277,7 +277,7 @@ void Foam::cellSplitter::setRefinement
label index = findIndex(f0, e[0]);
bool edgeInFaceOrder = (f0[(index+1) % f0.size()] == e[1]);
bool edgeInFaceOrder = (f0[f0.fcIndex(index)] == e[1]);
// Check if cellI is the face owner
@ -323,7 +323,7 @@ void Foam::cellSplitter::setRefinement
label index = findIndex(f1, e[0]);
bool edgeInFaceOrder = (f1[(index+1) % f1.size()] == e[1]);
bool edgeInFaceOrder = (f1[f1.fcIndex(index)] == e[1]);
// Check if cellI is the face owner

View file

@ -332,9 +332,11 @@ int main(int argc, char *argv[])
# include "setRootCase.H"
# include "createTime.H"
runTime.functionObjects().off();
# include "createPolyMesh.H"
const word oldInstance = mesh.pointsInstance();
bool overwrite = args.options().found("overwrite");
bool overwrite = args.optionFound("overwrite");
Info<< "Reading modifyMeshDict\n" << endl;
@ -357,18 +359,21 @@ int main(int argc, char *argv[])
(
dict.lookup("facesToTriangulate")
);
bool cutBoundary =
pointsToMove.size() > 0
|| edgesToSplit.size() > 0
|| facesToTriangulate.size() > 0;
(
pointsToMove.size()
|| edgesToSplit.size()
|| facesToTriangulate.size()
);
List<Pair<point> > edgesToCollapse(dict.lookup("edgesToCollapse"));
bool collapseEdge = edgesToCollapse.size() > 0;
bool collapseEdge = edgesToCollapse.size();
List<Pair<point> > cellsToPyramidise(dict.lookup("cellsToSplit"));
bool cellsToSplit = cellsToPyramidise.size() > 0;
bool cellsToSplit = cellsToPyramidise.size();
//List<Tuple<pointField,point> >
// cellsToCreate(dict.lookup("cellsToCreate"));
@ -522,7 +527,7 @@ int main(int argc, char *argv[])
Info<< nl << "There was a problem in one of the inputs in the"
<< " dictionary. Not modifying mesh." << endl;
}
else if (cellToPyrCentre.size() > 0)
else if (cellToPyrCentre.size())
{
Info<< nl << "All input cells located. Modifying mesh." << endl;
@ -549,12 +554,16 @@ int main(int argc, char *argv[])
{
runTime++;
}
else
{
mesh.setInstance(oldInstance);
}
// Write resulting mesh
Info << "Writing modified mesh to time " << runTime.value() << endl;
Info << "Writing modified mesh to time " << runTime.timeName() << endl;
mesh.write();
}
else if (edgeToPos.size() > 0)
else if (edgeToPos.size())
{
Info<< nl << "All input edges located. Modifying mesh." << endl;
@ -598,9 +607,13 @@ int main(int argc, char *argv[])
{
runTime++;
}
else
{
mesh.setInstance(oldInstance);
}
// Write resulting mesh
Info << "Writing modified mesh to time " << runTime.value() << endl;
Info << "Writing modified mesh to time " << runTime.timeName() << endl;
mesh.write();
}
else
@ -637,9 +650,13 @@ int main(int argc, char *argv[])
{
runTime++;
}
else
{
mesh.setInstance(oldInstance);
}
// Write resulting mesh
Info << "Writing modified mesh to time " << runTime.value() << endl;
Info << "Writing modified mesh to time " << runTime.timeName() << endl;
mesh.write();
}

View file

@ -1,21 +1,14 @@
/*---------------------------------------------------------------------------*\
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.0 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\ / O peration | Version: 1.6 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
root "/home/penfold/mattijs/foam/mattijs2.2/run/icoFoam";
case "cavityTut";
instance "system";
local "";
class dictionary;
object modifyMeshDict;
}

View file

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Hex 2x2x2 refiner
Refines a hex mesh by 2x2x2 cell splitting.
\*---------------------------------------------------------------------------*/
@ -56,11 +56,14 @@ int main(int argc, char *argv[])
argList::validArgs.append("cellSet");
# include "setRootCase.H"
# include "createTime.H"
runTime.functionObjects().off();
# include "createMesh.H"
const word oldInstance = mesh.pointsInstance();
pointMesh pMesh(mesh);
word cellSetName(args.args()[1]);
bool overwrite = args.options().found("overwrite");
bool overwrite = args.optionFound("overwrite");
Info<< "Reading cells to refine from cellSet " << cellSetName
<< nl << endl;
@ -176,6 +179,11 @@ int main(int argc, char *argv[])
Pout<< "Refined from " << returnReduce(map().nOldCells(), sumOp<label>())
<< " to " << mesh.globalData().nTotalCells() << " cells." << nl << endl;
if (overwrite)
{
mesh.setInstance(oldInstance);
meshCutter.setInstance(oldInstance);
}
Info<< "Writing mesh to " << runTime.timeName() << endl;
mesh.write();

View file

@ -23,9 +23,10 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Utility to refine cells next to patches. Takes a patchName
and number of layers to refine. Works out cells within these layers
and refines those in the wall-normal direction.
Utility to refine cells next to patches.
Takes a patchName and number of layers to refine. Works out cells within
these layers and refines those in the wall-normal direction.
\*---------------------------------------------------------------------------*/
@ -53,12 +54,14 @@ int main(int argc, char *argv[])
# include "setRootCase.H"
# include "createTime.H"
runTime.functionObjects().off();
# include "createPolyMesh.H"
const word oldInstance = mesh.pointsInstance();
word patchName(args.additionalArgs()[0]);
scalar weight(readScalar(IStringStream(args.additionalArgs()[1])()));
bool overwrite = args.options().found("overwrite");
bool overwrite = args.optionFound("overwrite");
label patchID = mesh.boundaryMesh().findPatchID(patchName);
@ -98,11 +101,11 @@ int main(int argc, char *argv[])
// List of cells to refine
//
bool useSet = args.options().found("useSet");
bool useSet = args.optionFound("useSet");
if (useSet)
{
word setName(args.options()["useSet"]);
word setName(args.option("useSet"));
Info<< "Subsetting cells to cut based on cellSet" << setName << endl
<< endl;
@ -183,10 +186,6 @@ int main(int argc, char *argv[])
<< endl;
// Transfer DynamicLists to straight ones.
labelList cutEdges;
cutEdges.transfer(allCutEdges);
allCutEdges.clear();
scalarField cutEdgeWeights;
cutEdgeWeights.transfer(allCutEdgeWeights);
allCutEdgeWeights.clear();
@ -198,7 +197,7 @@ int main(int argc, char *argv[])
mesh,
cutCells.toc(), // cells candidate for cutting
labelList(0), // cut vertices
cutEdges, // cut edges
allCutEdges, // cut edges
cutEdgeWeights // weight on cut edges
);
@ -228,8 +227,13 @@ int main(int argc, char *argv[])
// Update stored labels on meshCutter.
cutter.updateMesh(morphMap());
if (overwrite)
{
mesh.setInstance(oldInstance);
}
// Write resulting mesh
Info << "Writing refined morphMesh to time " << runTime.value() << endl;
Info << "Writing refined morphMesh to time " << runTime.timeName() << endl;
mesh.write();

View file

@ -110,7 +110,7 @@ int main(int argc, char *argv[])
<< " to allow for some truncation error."
<< nl << endl;
bool readLevel = args.options().found("readLevel");
bool readLevel = args.optionFound("readLevel");
const scalarField& vols = mesh.cellVolumes();
@ -206,9 +206,9 @@ int main(int argc, char *argv[])
runTime.timeName(),
runTime
),
mesh.points(),
mesh.faces(),
mesh.cells()
xferCopy(mesh.points()), // could we safely re-use the data?
xferCopy(mesh.faces()),
xferCopy(mesh.cells())
);
// Add the boundary patches
@ -336,7 +336,7 @@ int main(int argc, char *argv[])
)
{}
if (refCells.size() > 0)
if (refCells.size())
{
Info<< "Collected " << refCells.size() << " cells that need to be"
<< " refined to get closer to overall 2:1 refinement level limit"

View file

@ -53,9 +53,11 @@ int main(int argc, char *argv[])
# include "setRootCase.H"
# include "createTime.H"
runTime.functionObjects().off();
# include "createMesh.H"
const word oldInstance = mesh.pointsInstance();
bool overwrite = args.options().found("overwrite");
bool overwrite = args.optionFound("overwrite");
word setName(args.additionalArgs()[0]);
@ -171,6 +173,10 @@ int main(int argc, char *argv[])
{
runTime++;
}
else
{
mesh.setInstance(oldInstance);
}
// Take over refinement levels and write to new time directory.
Pout<< "Writing mesh to time " << runTime.timeName() << endl;

View file

@ -1,21 +1,14 @@
/*---------------------------------------------------------------------------*\
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.0 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\ / O peration | Version: 1.6 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
root "/home/penfold/mattijs/foam/mattijs2.1/run/icoFoam";
case "cavity";
instance "system";
local "";
class dictionary;
object selectCellsDict;
}

View file

@ -23,10 +23,11 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Utility to split cells with flat faces. Uses a geometric cut with a plane
dividing the edge angle into two so might produce funny cells. For hexes
it will use by default a cut from edge onto opposite edge (i.e. purely
topological).
Utility to split cells with flat faces.
Uses a geometric cut with a plane dividing the edge angle into two so
might produce funny cells. For hexes it will use by default a cut from
edge onto opposite edge (i.e. purely topological).
Options:
- split cells from cellSet only
@ -531,7 +532,9 @@ int main(int argc, char *argv[])
# include "setRootCase.H"
# include "createTime.H"
runTime.functionObjects().off();
# include "createPolyMesh.H"
const word oldInstance = mesh.pointsInstance();
scalar featureAngle(readScalar(IStringStream(args.additionalArgs()[0])()));
@ -539,23 +542,19 @@ int main(int argc, char *argv[])
scalar minCos = Foam::cos(radAngle);
scalar minSin = Foam::sin(radAngle);
bool readSet = args.options().found("set");
bool geometry = args.options().found("geometry");
bool overwrite = args.options().found("overwrite");
bool readSet = args.optionFound("set");
bool geometry = args.optionFound("geometry");
bool overwrite = args.optionFound("overwrite");
scalar edgeTol = 0.2;
if (args.options().found("tol"))
{
edgeTol = readScalar(IStringStream(args.options()["tol"])());
}
args.optionReadIfPresent("tol", edgeTol);
Info<< "Trying to split cells with internal angles > feature angle\n" << nl
<< "featureAngle : " << featureAngle << nl
<< "edge snapping tol : " << edgeTol << nl;
if (readSet)
{
Info<< "candidate cells : cellSet " << args.options()["set"] << nl;
Info<< "candidate cells : cellSet " << args.option("set") << nl;
}
else
{
@ -583,7 +582,7 @@ int main(int argc, char *argv[])
if (readSet)
{
// Read cells to cut from cellSet
cellSet cells(mesh, args.options()["set"]);
cellSet cells(mesh, args.option("set"));
cellsToCut = cells;
}
@ -650,7 +649,7 @@ int main(int argc, char *argv[])
// Remove cut cells from cellsToCut (Note:only relevant if -readSet)
forAll(cuts.cellLoops(), cellI)
{
if (cuts.cellLoops()[cellI].size() > 0)
if (cuts.cellLoops()[cellI].size())
{
//Info<< "Removing cut cell " << cellI << " from wishlist"
// << endl;
@ -691,7 +690,13 @@ int main(int argc, char *argv[])
Info<< "Remaining:" << cellsToCut.size() << endl;
// Write resulting mesh
Info << "Writing refined morphMesh to time " << runTime.value() << endl;
if (overwrite)
{
mesh.setInstance(oldInstance);
}
Info<< "Writing refined morphMesh to time " << runTime.timeName()
<< endl;
mesh.write();
}

View file

@ -1,28 +1,18 @@
#!/bin/sh
#
# Build optional components (eg, may depend on third-party libraries)
# -----------------------------------------------------------------------------
cd ${0%/*} || exit 1 # run from this directory
set -x
# run from this directory only
cd ${0%/*} || exit 1
if [ "`uname -s`" == Darwin ]; then
WM_SHARED_SUFFIX=dylib
else
WM_SHARED_SUFFIX=so
fi
# build libccmio and create lnInclude directory
( cd $WM_THIRD_PARTY_DIR && ./AllwmakeLibccmio )
# build libccmio if required
if [ ! -e $FOAM_LIBBIN/libccmio.$WM_SHARED_SUFFIX ]
then
(
cd $WM_THIRD_PARTY_DIR && ./AllwmakeLibccmio
)
fi
# if the library built okay, the headers must exist too
if [ -e $FOAM_LIBBIN/libccmio.$WM_SHARED_SUFFIX ]
# if the library built properly, the headers should exist too
if [ -e $FOAM_LIBBIN/libccmio.so ]
then
wmake ccm26ToFoam
fi
# end
# ----------------------------------------------------------------- end-of-file

View file

@ -302,7 +302,7 @@ void ReadProblem
prostarI = regionI;
Pout<< "For region:" << regionI
<< " did not find ProstarRegionNumber entry. Assuming "
<< "did not find ProstarRegionNumber entry. Assuming "
<< prostarI << endl;
}
@ -617,7 +617,7 @@ int main(int argc, char *argv[])
{
fileName ccmFile(args.additionalArgs()[0]);
if (!exists(ccmFile))
if (!isFile(ccmFile))
{
FatalErrorIn(args.executable())
<< "Cannot read file " << ccmFile
@ -686,7 +686,6 @@ int main(int argc, char *argv[])
NULL,
NULL
);
if (err != kCCMIONoErr)
{
FatalErrorIn(args.executable())
@ -912,10 +911,10 @@ int main(int argc, char *argv[])
runTime.constant(),
runTime
),
foamPoints,
foamFaces,
foamOwner,
foamNeighbour
xferMove<pointField>(foamPoints),
xferMove<faceList>(foamFaces),
xferCopy<labelList>(foamOwner),
xferMove<labelList>(foamNeighbour)
);
// Create patches. Use patch types to determine what Foam types to generate.

View file

@ -1,4 +1,4 @@
/*---------------------------------------------------------------------------*\
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
@ -246,10 +246,7 @@ int main(int argc, char *argv[])
}
scalar scaleFactor = 1.0;
if (args.options().found("scale"))
{
scaleFactor = atof(args.options()["scale"].c_str());
}
args.optionReadIfPresent("scale", scaleFactor);
# include "createTime.H"

View file

@ -60,10 +60,7 @@ int main(int argc, char *argv[])
}
scalar scaleFactor = 1.0;
if (args.options().found("scale"))
{
scaleFactor = atof(args.options()["scale"].c_str());
}
args.optionReadIfPresent("scale", scaleFactor);
# include "createTime.H"
@ -584,7 +581,7 @@ int main(int argc, char *argv[])
forAll (rawPatches, patchI)
{
if (rawPatches[patchI].size() > 0 && cfxPatchTypes[patchI] != "BLKBDY")
if (rawPatches[patchI].size() && cfxPatchTypes[patchI] != "BLKBDY")
{
// Check if this name has been already created
label existingPatch = -1;

View file

@ -1,8 +1,8 @@
/*---------------------------------------------------------------------------*\
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -48,6 +48,7 @@ Description
#include "Swap.H"
#include "IFstream.H"
#include "wordIOList.H"
#include "readHexLabel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -93,6 +94,9 @@ DynamicList<label> cellGroupStartIndex;
DynamicList<label> cellGroupEndIndex;
DynamicList<label> cellGroupType;
// Special parsing of (incorrect) Cubit files
bool cubitFile = false;
void uniquify(word& name, HashSet<word>& patchNames)
{
@ -623,11 +627,20 @@ endOfSection {space}")"{space}
BEGIN(readZoneGroupData);
}
<readZoneGroupData>{space}{label}{space}{word}{space}{word}{space}{label}? {
<readZoneGroupData>{space}{hexLabel}{space}{word}{space}{word}{space}{label}? {
IStringStream zoneDataStream(YYText());
// cell zone-ID not in hexadecimal!!! Inconsistency
label zoneID(readLabel(zoneDataStream));
label zoneID = -1;
if (cubitFile)
{
zoneID = readHexLabel(zoneDataStream);
}
else
{
zoneID = readLabel(zoneDataStream);
}
groupType.insert(zoneID, word(zoneDataStream));
groupName.insert(zoneID, word(zoneDataStream));
@ -753,6 +766,7 @@ int main(int argc, char *argv[])
argList::validOptions.insert("scale", "scale factor");
argList::validOptions.insert("ignoreCellGroups", "cell group names");
argList::validOptions.insert("ignoreFaceGroups", "face group names");
argList::validOptions.insert("cubit", "");
argList args(argc, argv);
@ -761,21 +775,28 @@ int main(int argc, char *argv[])
FatalError.exit();
}
if (args.options().found("scale"))
{
scaleFactor = atof(args.options()["scale"].c_str());
}
args.optionReadIfPresent("scale", scaleFactor);
HashSet<word> ignoreCellGroups;
if (args.options().found("ignoreCellGroups"))
if (args.optionFound("ignoreCellGroups"))
{
IStringStream(args.options()["ignoreCellGroups"])() >> ignoreCellGroups;
args.optionLookup("ignoreCellGroups")() >> ignoreCellGroups;
}
HashSet<word> ignoreFaceGroups;
if (args.options().found("ignoreFaceGroups"))
if (args.optionFound("ignoreFaceGroups"))
{
IStringStream(args.options()["ignoreFaceGroups"])() >> ignoreFaceGroups;
args.optionLookup("ignoreFaceGroups")() >> ignoreFaceGroups;
}
cubitFile = args.options().found("cubit");
if (cubitFile)
{
Info<< nl
<< "Assuming Cubit generated file"
<< " (incorrect face orientation; hexadecimal zoneIDs)."
<< nl << endl;
}
# include "createTime.H"
@ -820,6 +841,8 @@ int main(int argc, char *argv[])
// Pre-filtering: flip "owner" boundary or wrong oriented internal
// faces and move to neighbour
boolList fm(faces.size(), false);
forAll (faces, facei)
{
if
@ -827,8 +850,12 @@ int main(int argc, char *argv[])
owner[facei] == -1
|| (neighbour[facei] != -1 && owner[facei] > neighbour[facei])
)
{
fm[facei] = true;
if (!cubitFile)
{
faces[facei] = faces[facei].reverseFace();
}
Swap(owner[facei], neighbour[facei]);
}
}
@ -884,10 +911,10 @@ int main(int argc, char *argv[])
runTime.constant(),
runTime
),
pointField(0),
faceList(0),
labelList(0),
labelList(0)
xferCopy(pointField()),
xferCopy(faceList()),
xferCopy(labelList()),
xferCopy(labelList())
);

View file

@ -51,7 +51,7 @@ cellShape create3DCellShape
static List<const cellModel*> fluentCellModelLookup
(
7,
reinterpret_cast<const cellModel*>(NULL)
reinterpret_cast<const cellModel*>(0)
);
fluentCellModelLookup[2] = cellModeller::lookup("tet");

View file

@ -1,4 +1,4 @@
/*---------------------------------------------------------------------------*\
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
@ -56,7 +56,8 @@ Description
#include "readHexLabel.H"
#include "cellShapeRecognition.H"
#include "repatch.H"
#include "repatchPolyTopoChanger.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -383,7 +384,7 @@ endOfSection {space}")"{space}
scalar x = readScalar(vertexXyzStream);
scalar y = readScalar(vertexXyzStream);
points[pointI] = convertToMeters*point(x, y, 0);
points[pointI] = point(x, y, 0);
pointI++;
}
@ -875,13 +876,10 @@ int main(int argc, char *argv[])
}
scalar scaleFactor = 1.0;
if (args.options().found("scale"))
{
scaleFactor = atof(args.options()["scale"].c_str());
}
args.optionReadIfPresent("scale", scaleFactor);
bool writeSets = args.options().found("writeSets");
bool writeZones = args.options().found("writeZones");
bool writeSets = args.optionFound("writeSets");
bool writeZones = args.optionFound("writeZones");
# include "createTime.H"
@ -1181,7 +1179,7 @@ int main(int argc, char *argv[])
runTime.constant(),
runTime
),
points,
xferMove(points),
cellShapes,
patches,
patchNames,
@ -1580,7 +1578,7 @@ int main(int argc, char *argv[])
// Use facePatchIDs map to reorder boundary faces into compact regions
repatch repatcher(pShapeMesh);
repatchPolyTopoChanger repatcher(pShapeMesh);
// Add new list of patches
repatcher.changePatches(newPatches);
@ -1592,7 +1590,7 @@ int main(int argc, char *argv[])
repatcher.changePatchID(faceI, facePatchID[idI]);
}
repatcher.execute();
repatcher.repatch();
preservePatchTypes
(
@ -1642,7 +1640,7 @@ int main(int argc, char *argv[])
boundaryZones[pI].append(bPatches[pI].name());
}
label cnt=0;
label cnt = 0;
SLList<label>::iterator cg = cellGroupZoneID.begin();
SLList<label>::iterator start = cellGroupStartIndex.begin();
SLList<label>::iterator end = cellGroupEndIndex.begin();
@ -1661,8 +1659,8 @@ int main(int argc, char *argv[])
// Mark zone cells, used for finding faces
boolList zoneCell(pShapeMesh.nCells(), false);
// shift cell indizes by 1
label nr=0;
// Shift cell indices by 1
label nr = 0;
for (label celli = (start() - 1); celli < end(); celli++)
{
cls[nr] = celli;

View file

@ -174,17 +174,11 @@ void Foam::fluentFvMesh::writeFluentMesh() const
nWrittenFaces += patchFaces.size();
// Write patch type
if
(
typeid(boundary()[patchI]) == typeid(wallFvPatch)
)
if (isA<wallFvPatch>(boundary()[patchI]))
{
fluentMeshFile << 3;
}
else if
(
typeid(boundary()[patchI]) == typeid(symmetryFvPatch)
)
else if (isA<symmetryFvPatch>(boundary()[patchI]))
{
fluentMeshFile << 7;
}
@ -282,17 +276,11 @@ void Foam::fluentFvMesh::writeFluentMesh() const
<< "(39 (" << patchI + 10 << " ";
// Write patch type
if
(
typeid(boundary()[patchI]) == typeid(wallFvPatch)
)
if (isA<wallFvPatch>(boundary()[patchI]))
{
fluentMeshFile << "wall ";
}
else if
(
typeid(boundary()[patchI]) == typeid(symmetryFvPatch)
)
else if (isA<symmetryFvPatch>(boundary()[patchI]))
{
fluentMeshFile << "symmetry ";
}

View file

@ -61,6 +61,7 @@ See Also
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "timeSelector.H"
#include "Time.H"
#include "polyMesh.H"
#include "STARCDMeshWriter.H"
@ -73,23 +74,20 @@ using namespace Foam;
int main(int argc, char *argv[])
{
argList::noParallel();
timeSelector::addOptions();
argList::validOptions.insert("scale", "scale");
argList::validOptions.insert("noBnd", "");
argList::validOptions.insert("tri", "");
argList::validOptions.insert("surface", "");
# include "addTimeOptions.H"
# include "setRootCase.H"
# include "createTime.H"
// Get times list
instantList Times = runTime.times();
// set startTime and endTime depending on -time and -latestTime options
# include "checkTimeOptions.H"
runTime.setTime(Times[startTime], startTime);
instantList timeDirs = timeSelector::select0(runTime, args);
bool surfaceOnly = false;
if (args.options().found("surface") or args.options().found("tri"))
if (args.optionFound("surface") || args.optionFound("tri"))
{
surfaceOnly = true;
}
@ -100,16 +98,15 @@ int main(int argc, char *argv[])
exportName = meshWriter::defaultSurfaceName;
}
if (args.options().found("case"))
if (args.optionFound("case"))
{
exportName += '-' + args.globalCaseName();
}
// default: rescale from [m] to [mm]
scalar scaleFactor = 1000;
if (args.options().found("scale"))
if (args.optionReadIfPresent("scale", scaleFactor))
{
scaleFactor = readScalar(IStringStream(args.options()["scale"])());
if (scaleFactor <= 0)
{
scaleFactor = 1;
@ -118,21 +115,20 @@ int main(int argc, char *argv[])
# include "createPolyMesh.H"
// bool firstCheck = true;
for (label timeI = startTime; timeI < endTime; ++timeI)
forAll(timeDirs, timeI)
{
runTime.setTime(Times[timeI], timeI);
runTime.setTime(timeDirs[timeI], timeI);
# include "getTimeIndex.H"
polyMesh::readUpdateState state = mesh.readUpdate();
if (timeI == startTime || state != polyMesh::UNCHANGED)
if (!timeI || state != polyMesh::UNCHANGED)
{
meshWriters::STARCD writer(mesh, scaleFactor);
if (args.options().found("noBnd"))
if (args.optionFound("noBnd"))
{
writer.noBoundary();
}
@ -145,7 +141,7 @@ int main(int argc, char *argv[])
if (surfaceOnly)
{
if (args.options().found("tri"))
if (args.optionFound("tri"))
{
writer.writeSurface(meshName, true);
}

View file

@ -1,4 +1,4 @@
/*---------------------------------------------------------------------------*\
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
@ -646,10 +646,7 @@ int main(int argc, char *argv[])
}
scalar scaleFactor = 1.0;
if (args.options().found("scale"))
{
scaleFactor = atof(args.options()["scale"].c_str());
}
args.optionReadIfPresent("scale", scaleFactor);
# include "createTime.H"
@ -851,7 +848,7 @@ int main(int argc, char *argv[])
runTime.constant(),
runTime
),
points,
xferMove(points),
cells,
boundary,
patchNames,

View file

@ -0,0 +1,79 @@
// Parametres geometriques
r1 = 200*Cos(Pi/4)/1000;
r2 = 200*Cos(Pi/4)/1000;
h1 = 250/1000;
h2 = 360/1000;
h3 = 900/1000;
h4 = 1900/1000;
// Parametres de maillage
// selon le rayon
rCells = 10/2; rRatio = 0.85;
// selon S1
S1Cells = 30/2; S1ratio = 1;
// selon S2
S2Cells = 35/2; S2ratio = 0.95;
// selon S3
S3Cells = 20/2; S3ratio = 1;
Point(1) = {r1, r1, h4};
Point(2) = {r1, r1, h3};
Point(3) = {r2, r2, h2};
Point(4) = {r2, r2, h1};
Point(5) = {0, 0, h1};
Point(6) = {0, 0, h2};
Point(7) = {0, 0, h3};
Point(8) = {0, 0, h4};
Line(1) = {8, 1};
Line(2) = {1, 2};
Line(3) = {7, 2};
Line(4) = {8, 7};
Line(5) = {2, 3};
Line(6) = {6, 3};
Line(7) = {7, 6};
Line(8) = {3, 4};
Line(9) = {5, 4};
Line(10) = {6, 5};
Line Loop(11) = {1, 2, -3, -4};
Ruled Surface(12) = {11};
Line Loop(13) = {5, -6, -7, 3};
Ruled Surface(14) = {13};
Line Loop(15) = {8, -9, -10, 6};
Ruled Surface(16) = {15};
Transfinite Line {1, 3, 6, 9} = rCells Using Progression rRatio;
Transfinite Line {4, 2} = S1Cells Using Progression S1ratio;
Transfinite Line {7, 5} = S2Cells Using Progression S2ratio;
Transfinite Line {10, 8} = S3Cells Using Progression S3ratio;
Transfinite Surface {12} = {8, 1, 2, 7};
Transfinite Surface {14} = {7, 2, 3, 6};
Transfinite Surface {16} = {6, 3, 4, 5};
Recombine Surface {12, 14, 16};
Extrude {{0, 0, 1}, {0, 0, 0}, Pi/2} {
Surface{12, 14, 16};
Layers{25};
Recombine;
}
Extrude {{0, 0, 1}, {0, 0, 0}, Pi/2} {
Surface{33, 50, 67};
Layers{25};
Recombine;
}
Extrude {{0, 0, 1}, {0, 0, 0}, Pi/2} {
Surface{84, 101, 118};
Layers{25};
Recombine;
}
Extrude {{0, 0, 1}, {0, 0, 0}, Pi/2} {
Surface{135, 152, 169};
Layers{25};
Recombine;
}
Physical Surface("entree") = {126, 75, 24, 177};
Physical Surface("S1") = {28, 181, 130, 79};
Physical Surface("S2") = {93, 42, 193, 144};
Physical Surface("S3") = {110, 59, 205, 161};
Physical Surface("fond") = {113, 62, 208, 164};
Physical Volume("fluide") = {4, 7, 10, 1, 5, 8, 11, 2, 9, 12, 3, 6};

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -47,7 +47,7 @@ Description
#include "polyMesh.H"
#include "IFstream.H"
#include "cellModeller.H"
#include "repatch.H"
#include "repatchPolyTopoChanger.H"
#include "cellSet.H"
#include "faceSet.H"
@ -312,11 +312,36 @@ void readPhysNames(IFstream& inFile, Map<word>& physicalNames)
string line;
inFile.getLine(line);
IStringStream lineStr(line);
label nSpaces = lineStr.str().count(' ');
if(nSpaces == 1)
{
lineStr >> regionI >> regionName;
Info<< " " << regionI << '\t' << string::validate<word>(regionName)
<< endl;
Info<< " " << regionI << '\t'
<< string::validate<word>(regionName) << endl;
}
else if(nSpaces == 2)
{
// >= Gmsh2.4 physical types has tag in front.
label physType;
lineStr >> physType >> regionI >> regionName;
if (physType == 1)
{
Info<< " " << "Line " << regionI << '\t'
<< string::validate<word>(regionName) << endl;
}
else if (physType == 2)
{
Info<< " " << "Surface " << regionI << '\t'
<< string::validate<word>(regionName) << endl;
}
else if (physType == 3)
{
Info<< " " << "Volume " << regionI << '\t'
<< string::validate<word>(regionName) << endl;
}
}
physicalNames.insert(regionI, string::validate<word>(regionName));
}
@ -657,6 +682,16 @@ void readCells
<< " tet :" << nTet << endl
<< endl;
if (cells.size() == 0)
{
FatalErrorIn("readCells(..)")
<< "No cells read from file " << inFile.name() << nl
<< "Does your file specify any 3D elements (hex=" << MSHHEX
<< ", prism=" << MSHPRISM << ", pyramid=" << MSHPYR
<< ", tet=" << MSHTET << ")?" << nl
<< "Perhaps you have not exported the 3D elements?"
<< exit(FatalError);
}
Info<< "CellZones:" << nl
<< "Zone\tSize" << endl;
@ -667,7 +702,7 @@ void readCells
const labelList& zCells = zoneCells[zoneI];
if (zCells.size() > 0)
if (zCells.size())
{
Info<< " " << zoneI << '\t' << zCells.size() << endl;
}
@ -689,7 +724,7 @@ int main(int argc, char *argv[])
fileName mshName(args.additionalArgs()[0]);
bool keepOrientation = args.options().found("keepOrientation");
bool keepOrientation = args.optionFound("keepOrientation");
// Storage for points
pointField points;
@ -778,7 +813,7 @@ int main(int argc, char *argv[])
forAll(zoneCells, zoneI)
{
if (zoneCells[zoneI].size() > 0)
if (zoneCells[zoneI].size())
{
nValidCellZones++;
}
@ -835,7 +870,7 @@ int main(int argc, char *argv[])
runTime.constant(),
runTime
),
points,
xferMove(points),
cells,
boundaryFaces,
boundaryPatchNames,
@ -845,7 +880,7 @@ int main(int argc, char *argv[])
boundaryPatchPhysicalTypes
);
repatch repatcher(mesh);
repatchPolyTopoChanger repatcher(mesh);
// Now use the patchFaces to patch up the outside faces of the mesh.
@ -910,7 +945,7 @@ int main(int argc, char *argv[])
const labelList& zFaces = zoneFaces[zoneI];
if (zFaces.size() > 0)
if (zFaces.size())
{
nValidFaceZones++;
@ -923,7 +958,7 @@ int main(int argc, char *argv[])
//Get polyMesh to write to constant
runTime.setTime(instant(runTime.constant()), 0);
repatcher.execute();
repatcher.repatch();
List<cellZone*> cz;
List<faceZone*> fz;
@ -940,7 +975,7 @@ int main(int argc, char *argv[])
forAll(zoneCells, zoneI)
{
if (zoneCells[zoneI].size() > 0)
if (zoneCells[zoneI].size())
{
label physReg = zoneToPhys[zoneI];
@ -979,7 +1014,7 @@ int main(int argc, char *argv[])
forAll(zoneFaces, zoneI)
{
if (zoneFaces[zoneI].size() > 0)
if (zoneFaces[zoneI].size())
{
label physReg = zoneToPhys[zoneI];
@ -1011,7 +1046,7 @@ int main(int argc, char *argv[])
}
}
if (cz.size() > 0 || fz.size() > 0)
if (cz.size() || fz.size())
{
mesh.addZones(List<pointZone*>(0), fz, cz);
}

View file

@ -208,12 +208,13 @@ void readPoints
{
hasWarned = true;
WarningIn
IOWarningIn
(
"readPoints(IFstream&, label&, DynamicList<point>"
", DynamicList<label>&)"
", DynamicList<label>&)",
is
) << "Points not in order starting at point " << pointI
<< " at line " << is.lineNumber()
//<< " at line " << is.lineNumber()
//<< abort(FatalError);
<< endl;
}
@ -429,46 +430,52 @@ void readPatches
>> dofSet >> tempSet >> contactSet >> nFaces;
is.getLine(line);
patchNames.append(string::validate<word>(line));
word groupName = string::validate<word>(line);
Info<< "For facegroup " << group
<< " named " << patchNames[patchNames.size()-1]
Info<< "For group " << group
<< " named " << groupName
<< " trying to read " << nFaces << " patch face indices."
<< endl;
patchFaceIndices.append(labelList(0));
labelList& faceIndices = patchFaceIndices[patchFaceIndices.size()-1];
faceIndices.setSize(nFaces);
label faceI = 0;
labelList groupIndices(nFaces);
label groupType = -1;
nFaces = 0;
while (faceI < faceIndices.size())
while (nFaces < groupIndices.size())
{
is.getLine(line);
IStringStream lineStr(line);
// Read one (for last face) or two entries from line.
label nRead = 2;
if (faceI == faceIndices.size()-1)
if (nFaces == groupIndices.size()-1)
{
nRead = 1;
}
for (label i = 0; i < nRead; i++)
{
label typeCode, tag, nodeLeaf, component;
label tag, nodeLeaf, component;
lineStr >> typeCode >> tag >> nodeLeaf >> component;
lineStr >> groupType >> tag >> nodeLeaf >> component;
if (typeCode != 8)
groupIndices[nFaces++] = tag;
}
}
// Store
if (groupType == 8)
{
FatalErrorIn("readPatches")
<< "When reading patches expect Entity Type Code 8"
<< nl << "At line " << is.lineNumber()
<< exit(FatalError);
}
faceIndices[faceI++] = tag;
patchNames.append(groupName);
patchFaceIndices.append(groupIndices);
}
else
{
IOWarningIn("readPatches(..)", is)
<< "When reading patches expect entity type code 8"
<< nl << " Skipping group code " << groupType
<< endl;
}
}
@ -572,6 +579,7 @@ int main(int argc, char *argv[])
{
argList::noParallel();
argList::validArgs.append(".unv file");
argList::validOptions.insert("dump", "");
# include "setRootCase.H"
# include "createTime.H"
@ -751,7 +759,7 @@ int main(int argc, char *argv[])
List<faceList> patchFaceVerts;
if (dofVertIndices.size() > 0)
if (dofVertIndices.size())
{
// Use the vertex constraints to patch. Is of course bit dodgy since
// face goes on patch if all its vertices are on a constraint.
@ -806,7 +814,7 @@ int main(int argc, char *argv[])
forAll(dynPatchFaces, patchI)
{
patchFaceVerts[patchI].transfer(dynPatchFaces[patchI].shrink());
patchFaceVerts[patchI].transfer(dynPatchFaces[patchI]);
}
}
else
@ -845,13 +853,13 @@ int main(int argc, char *argv[])
pointField polyPoints;
polyPoints.transfer(points);
points.clear();
// Length scaling factor
polyPoints /= lengthScale;
// For debugging: dump boundary faces as triSurface
if (args.optionFound("dump"))
{
DynamicList<labelledTri> triangles(boundaryFaces.size());
@ -887,7 +895,6 @@ int main(int argc, char *argv[])
}
Info<< "Constructing mesh with non-default patches of size:" << nl;
forAll(patchNames, patchI)
{
@ -907,14 +914,14 @@ int main(int argc, char *argv[])
runTime.constant(),
runTime
),
polyPoints,
xferMove(polyPoints),
cellVerts,
patchFaceVerts, //boundaryFaces,
patchNames, //boundaryPatchNames,
wordList(patchNames.size(), polyPatch::typeName), //boundaryPatchTypes,
"defaultFaces", //defaultFacesName
polyPatch::typeName, //defaultFacesType,
wordList(0) //boundaryPatchPhysicalTypes
patchFaceVerts, // boundaryFaces,
patchNames, // boundaryPatchNames,
wordList(patchNames.size(), polyPatch::typeName), // boundaryPatchTypes,
"defaultFaces", // defaultFacesName
polyPatch::typeName, // defaultFacesType,
wordList(0) // boundaryPatchPhysicalTypes
);
mesh.write();

View file

@ -0,0 +1,394 @@
-1
2411
1 0 0 0
2.0000000000000000E+02 3.0000000000000000E+02 0.0000000000000000E+00
2 0 0 0
2.0000000000000000E+02 3.0000000000000000E+02 2.1000000000000000E+02
3 0 0 0
2.0000000000000000E+02 0.0000000000000000E+00 0.0000000000000000E+00
4 0 0 0
2.0000000000000000E+02 0.0000000000000000E+00 2.1000000000000000E+02
5 0 0 0
0.0000000000000000E+00 3.0000000000000000E+02 0.0000000000000000E+00
6 0 0 0
0.0000000000000000E+00 3.0000000000000000E+02 2.1000000000000000E+02
7 0 0 0
0.0000000000000000E+00 0.0000000000000000E+00 0.0000000000000000E+00
8 0 0 0
0.0000000000000000E+00 0.0000000000000000E+00 2.1000000000000000E+02
9 0 0 0
0.0000000000000000E+00 1.0020000000000000E+02 2.1000000000000000E+02
10 0 0 0
0.0000000000000000E+00 2.0009999999999999E+02 2.1000000000000000E+02
11 0 0 0
1.0000000000000000E+02 3.0000000000000000E+02 2.1000000000000000E+02
12 0 0 0
2.0000000000000000E+02 1.0020000000000000E+02 2.1000000000000000E+02
13 0 0 0
2.0000000000000000E+02 2.0009999999999999E+02 2.1000000000000000E+02
14 0 0 0
1.0000000000000000E+02 0.0000000000000000E+00 2.1000000000000000E+02
15 0 0 0
0.0000000000000000E+00 1.0020000000000000E+02 0.0000000000000000E+00
16 0 0 0
0.0000000000000000E+00 2.0009999999999999E+02 0.0000000000000000E+00
17 0 0 0
1.0000000000000000E+02 3.0000000000000000E+02 0.0000000000000000E+00
18 0 0 0
2.0000000000000000E+02 1.0020000000000000E+02 0.0000000000000000E+00
19 0 0 0
2.0000000000000000E+02 2.0009999999999999E+02 0.0000000000000000E+00
20 0 0 0
1.0000000000000000E+02 0.0000000000000000E+00 0.0000000000000000E+00
21 0 0 0
2.0000000000000000E+02 3.0000000000000000E+02 1.0500000000000000E+02
22 0 0 0
0.0000000000000000E+00 3.0000000000000000E+02 1.0500000000000000E+02
23 0 0 0
2.0000000000000000E+02 0.0000000000000000E+00 1.0500000000000000E+02
24 0 0 0
0.0000000000000000E+00 0.0000000000000000E+00 1.0500000000000000E+02
25 0 0 0
9.6161727574445891E+01 1.3290789499900029E+02 2.1000000000000000E+02
26 0 0 0
8.0082880863556014E+01 2.2412763570985578E+02 2.1000000000000000E+02
27 0 0 0
9.6161727574240444E+01 1.3290789499883087E+02 0.0000000000000000E+00
28 0 0 0
8.0082880863392205E+01 2.2412763570989483E+02 0.0000000000000000E+00
29 0 0 0
2.0000000000000000E+02 1.5011560268321134E+02 1.0500000000592973E+02
30 0 0 0
0.0000000000000000E+00 1.5011560299451648E+02 1.0499999963389952E+02
31 0 0 0
9.9094099553883055E+01 7.2457929267250009E+01 1.0499999994714025E+02
-1
-1
2412
1 11 2 1 7 2
0 0 0
9 8
2 11 2 1 7 2
0 0 0
10 9
3 11 2 1 7 2
0 0 0
6 10
4 11 2 1 7 2
0 0 0
11 6
5 11 2 1 7 2
0 0 0
2 11
6 11 2 1 7 2
0 0 0
4 12
7 11 2 1 7 2
0 0 0
12 13
8 11 2 1 7 2
0 0 0
13 2
9 11 2 1 7 2
0 0 0
8 14
10 11 2 1 7 2
0 0 0
14 4
11 11 2 1 7 2
0 0 0
7 15
12 11 2 1 7 2
0 0 0
15 16
13 11 2 1 7 2
0 0 0
16 5
14 11 2 1 7 2
0 0 0
5 17
15 11 2 1 7 2
0 0 0
17 1
16 11 2 1 7 2
0 0 0
18 3
17 11 2 1 7 2
0 0 0
19 18
18 11 2 1 7 2
0 0 0
1 19
19 11 2 1 7 2
0 0 0
20 7
20 11 2 1 7 2
0 0 0
3 20
21 11 2 1 7 2
0 0 0
21 1
22 11 2 1 7 2
0 0 0
2 21
23 11 2 1 7 2
0 0 0
5 22
24 11 2 1 7 2
0 0 0
22 6
25 11 2 1 7 2
0 0 0
3 23
26 11 2 1 7 2
0 0 0
23 4
27 11 2 1 7 2
0 0 0
24 7
28 11 2 1 7 2
0 0 0
8 24
29 41 2 1 7 3
9 8 14
30 41 2 1 7 3
10 9 25
31 41 2 1 7 3
6 10 26
32 41 2 1 7 3
11 6 26
33 41 2 1 7 3
10 25 26
34 41 2 1 7 3
2 11 13
35 41 2 1 7 3
4 12 14
36 41 2 1 7 3
12 13 25
37 41 2 1 7 3
14 12 25
38 41 2 1 7 3
9 14 25
39 41 2 1 7 3
13 11 26
40 41 2 1 7 3
13 26 25
41 41 2 1 7 3
7 15 20
42 41 2 1 7 3
15 16 27
43 41 2 1 7 3
16 5 28
44 41 2 1 7 3
27 16 28
45 41 2 1 7 3
5 17 28
46 41 2 1 7 3
17 1 19
47 41 2 1 7 3
18 3 20
48 41 2 1 7 3
19 18 27
49 41 2 1 7 3
18 20 27
50 41 2 1 7 3
20 15 27
51 41 2 1 7 3
17 19 28
52 41 2 1 7 3
28 19 27
53 41 2 1 7 3
17 5 22
54 41 2 1 7 3
1 17 21
55 41 2 1 7 3
2 21 11
56 41 2 1 7 3
6 11 22
57 41 2 1 7 3
22 11 21
58 41 2 1 7 3
22 21 17
59 41 2 1 7 3
7 20 24
60 41 2 1 7 3
20 3 23
61 41 2 1 7 3
23 4 14
62 41 2 1 7 3
14 8 24
63 41 2 1 7 3
14 24 23
64 41 2 1 7 3
20 23 24
65 41 2 1 7 3
23 3 18
66 41 2 1 7 3
4 23 12
67 41 2 1 7 3
13 12 29
68 41 2 1 7 3
2 13 21
69 41 2 1 7 3
22 16 30
70 41 2 1 7 3
13 29 21
71 41 2 1 7 3
1 21 19
72 41 2 1 7 3
12 23 29
73 41 2 1 7 3
18 19 29
74 41 2 1 7 3
23 18 29
75 41 2 1 7 3
15 24 30
76 41 2 1 7 3
29 19 21
77 41 2 1 7 3
7 24 15
78 41 2 1 7 3
24 8 9
79 41 2 1 7 3
9 10 30
80 41 2 1 7 3
10 6 22
81 41 2 1 7 3
30 10 22
82 41 2 1 7 3
16 15 30
83 41 2 1 7 3
22 5 16
84 41 2 1 7 3
24 9 30
85 111 2 1 7 4
21 28 22 17
86 111 2 1 7 4
31 18 29 23
87 111 2 1 7 4
31 29 18 27
88 111 2 1 7 4
29 21 26 13
89 111 2 1 7 4
29 25 26 30
90 111 2 1 7 4
26 28 29 30
91 111 2 1 7 4
16 28 5 22
92 111 2 1 7 4
30 25 10 9
93 111 2 1 7 4
16 30 15 27
94 111 2 1 7 4
26 25 10 30
95 111 2 1 7 4
21 28 26 22
96 111 2 1 7 4
31 20 18 23
97 111 2 1 7 4
27 28 16 30
98 111 2 1 7 4
18 27 29 19
99 111 2 1 7 4
21 22 26 11
100 111 2 1 7 4
23 4 12 14
101 111 2 1 7 4
31 25 29 30
102 111 2 1 7 4
31 18 20 27
103 111 2 1 7 4
21 11 26 13
104 111 2 1 7 4
22 28 5 17
105 111 2 1 7 4
2 11 21 13
106 111 2 1 7 4
29 25 12 13
107 111 2 1 7 4
30 28 16 22
108 111 2 1 7 4
31 24 20 23
109 111 2 1 7 4
26 28 30 22
110 111 2 1 7 4
21 17 19 28
111 111 2 1 7 4
15 24 31 30
112 111 2 1 7 4
31 9 30 24
113 111 2 1 7 4
15 30 31 27
114 111 2 1 7 4
8 14 24 9
115 111 2 1 7 4
26 22 10 6
116 111 2 1 7 4
31 25 12 29
117 111 2 1 7 4
31 29 12 23
118 111 2 1 7 4
31 30 9 25
119 111 2 1 7 4
21 1 19 17
120 111 2 1 7 4
29 19 27 28
121 111 2 1 7 4
10 22 26 30
122 111 2 1 7 4
29 28 26 21
123 111 2 1 7 4
7 20 15 24
124 111 2 1 7 4
11 22 26 6
125 111 2 1 7 4
29 28 27 30
126 111 2 1 7 4
31 23 12 14
127 111 2 1 7 4
26 25 29 13
128 111 2 1 7 4
15 27 31 20
129 111 2 1 7 4
21 19 29 28
130 111 2 1 7 4
18 3 23 20
131 111 2 1 7 4
15 20 31 24
132 111 2 1 7 4
27 31 29 30
133 111 2 1 7 4
31 14 9 24
134 111 2 1 7 4
31 9 14 25
135 111 2 1 7 4
31 14 12 25
136 111 2 1 7 4
31 23 14 24
-1
-1
2467
0 0 0 0 0 0 0 10
outlet
8 70 0 0 8 67 0 0
8 68 0 0 8 71 0 0
8 76 0 0 8 66 0 0
8 72 0 0 8 73 0 0
8 74 0 0 8 65 0 0
1 0 0 0 0 0 0 12
inlet
8 36 0 0 8 30 0 0
8 31 0 0 8 37 0 0
8 34 0 0 8 38 0 0
8 33 0 0 8 35 0 0
8 32 0 0 8 29 0 0
8 39 0 0 8 40 0 0
2 0 0 0 0 0 0 12
nodes
7 2 0 0 7 4 0 0
7 6 0 0 7 8 0 0
7 9 0 0 7 10 0 0
7 11 0 0 7 12 0 0
7 13 0 0 7 14 0 0
7 25 0 0 7 26 0 0
-1

View file

@ -68,15 +68,15 @@ int main(int argc, char *argv[])
# include "createTime.H"
fileName kivaFileName("otape17");
if (args.options().found("file"))
if (args.optionFound("file"))
{
kivaFileName = args.options()["file"];
kivaFileName = args.option("file");
}
kivaVersions kivaVersion = kiva3v;
if (args.options().found("version"))
if (args.optionFound("version"))
{
word kivaVersionName = args.options()["version"];
word kivaVersionName = args.option("version");
if (kivaVersionName == "kiva3")
{
@ -99,10 +99,7 @@ int main(int argc, char *argv[])
}
scalar zHeadMin = -GREAT;
if (args.options().found("zHeadMin"))
{
zHeadMin = atof(args.options()["zHeadMin"].c_str());
}
args.optionReadIfPresent("zHeadMin", zHeadMin);
# include "readKivaGrid.H"

View file

@ -576,7 +576,7 @@ polyMesh pShapeMesh
runTime.constant(),
runTime
),
points,
xferMove(points),
cellShapes,
boundary,
patchNames,

View file

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Reads .msh format generated by the Adventure system.
Converts .msh file generated by the Adventure system.
Note: the .msh format does not contain any boundary information. It is
purely a description of the internal mesh.
@ -62,14 +62,12 @@ int main(int argc, char *argv[])
# include "setRootCase.H"
# include "createTime.H"
bool readHex(args.options().found("hex"));
bool readHex = args.optionFound("hex");
fileName mshFile(args.additionalArgs()[0]);
IFstream mshStream(mshFile);
label nCells;
mshStream >> nCells;
if (readHex)
@ -140,7 +138,7 @@ int main(int argc, char *argv[])
runTime.constant(),
runTime
),
points,
xferMove(points),
cells,
faceListList(0),
wordList(0),

View file

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
read Neutral file format as written by Netgen4.4.
Converts neutral file format as written by Netgen v4.4.
Example:
@ -89,13 +89,11 @@ using namespace Foam;
int main(int argc, char *argv[])
{
argList::validArgs.append("Neutral file");
argList::validOptions.insert("overwrite", "");
# include "setRootCase.H"
# include "createTime.H"
fileName neuFile(args.additionalArgs()[0]);
bool overwrite = args.options().found("overwrite");
IFstream str(neuFile);
@ -244,7 +242,7 @@ int main(int argc, char *argv[])
}
if (vertsToBoundary.size() > 0)
if (vertsToBoundary.size())
{
// Didn't find cells connected to boundary faces.
WarningIn(args.executable())
@ -291,20 +289,13 @@ int main(int argc, char *argv[])
<< patchNames[patchI] << "\t\t"
<< allPatchFaces[patchI].size() << endl;
allPatchFaces[patchI].shrink();
patchFaces[patchI].transfer(allPatchFaces[patchI]);
allPatchFaces[patchI].clear();
}
Info<< endl;
}
if (!overwrite)
{
runTime++;
}
polyMesh mesh
(
IOobject
@ -313,7 +304,7 @@ int main(int argc, char *argv[])
runTime.constant(),
runTime
),
points,
xferMove(points),
cells,
patchFaces,
patchNames,

View file

@ -28,7 +28,8 @@ Description
Work in progress! Handles ascii multiblock (and optionally singleBlock)
format.
By default expects blanking. Use -noBlank if none.
Use -2D <thickness> if 2D.
Use -2D @a thickness if 2D.
Niklas Nordin has experienced a problem with lefthandedness of the blocks.
The code should detect this automatically - see hexBlock::readPoints but
if this goes wrong just set the blockHandedness_ variable to 'right'
@ -70,18 +71,14 @@ int main(int argc, char *argv[])
}
scalar scaleFactor = 1.0;
if (args.options().found("scale"))
{
scaleFactor = atof(args.options()["scale"].c_str());
}
args.optionReadIfPresent("scale", scaleFactor);
bool readBlank = !args.options().found("noBlank");
bool singleBlock = args.options().found("singleBlock");
scalar twoDThicknes = -1;
if (args.options().found("2D"))
bool readBlank = !args.optionFound("noBlank");
bool singleBlock = args.optionFound("singleBlock");
scalar twoDThickness = -1;
if (args.optionReadIfPresent("2D", twoDThickness))
{
twoDThicknes = readScalar(IStringStream(args.options()["2D"])());
Info<< "Reading 2D case by extruding points by " << twoDThicknes
Info<< "Reading 2D case by extruding points by " << twoDThickness
<< " in z direction." << nl << endl;
}
@ -113,7 +110,7 @@ int main(int argc, char *argv[])
forAll (blocks, blockI)
{
if (twoDThicknes > 0)
if (twoDThickness > 0)
{
// Fake second set of points (done in readPoints below)
plot3dFile >> nx >> ny;
@ -138,7 +135,7 @@ int main(int argc, char *argv[])
forAll (blocks, blockI)
{
Info<< "block " << blockI << ":" << nl;
blocks[blockI].readPoints(readBlank, twoDThicknes, plot3dFile);
blocks[blockI].readPoints(readBlank, twoDThickness, plot3dFile);
sumPoints += blocks[blockI].nBlockPoints();
nMeshCells += blocks[blockI].nBlockCells();
Info<< nl;
@ -231,7 +228,7 @@ int main(int argc, char *argv[])
runTime.constant(),
runTime
),
newPoints,
xferMove(newPoints),
cellShapes,
boundary,
patchNames,

View file

@ -1,3 +1,4 @@
meshDualiser.C
polyDualMeshApp.C
EXE = $(FOAM_APPBIN)/polyDualMesh

View file

@ -1,6 +1,9 @@
EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/conversion/lnInclude
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude
EXE_LIBS = \
-lmeshTools -lconversion
-lfiniteVolume \
-ldynamicMesh \
-lmeshTools

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,262 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
meshDualiser
Description
Creates dual of polyMesh. Every point becomes a cell (or multiple cells
for feature points), a walk around every edge creates faces between them.
Put all points you want in the final mesh into featurePoints; all edge(mid)s
you want in the final mesh into featureEdges; all face(centre)s in
faceFaces.
Usually to preserve boundaries:
- all boundary faces are featureFaces
- all edges and points inbetween different patches are
featureEdges/points.
In same way you can also preserve internal faces (e.g. faceZones)
SourceFiles
meshDualiser.C
\*---------------------------------------------------------------------------*/
#ifndef meshDualiser_H
#define meshDualiser_H
#include "DynamicList.H"
#include "PackedBoolList.H"
#include "boolList.H"
#include "typeInfo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class polyMesh;
class polyTopoChange;
/*---------------------------------------------------------------------------*\
Class meshDualiser Declaration
\*---------------------------------------------------------------------------*/
class meshDualiser
{
// Private data
const polyMesh& mesh_;
//- From point on cell to dual cell. Either single entry or
// one entry per pointCells
labelListList pointToDualCells_;
//- From point to dual point (or -1 if not feature point).
labelList pointToDualPoint_;
//- From cell to dual point. All cells become point
labelList cellToDualPoint_;
//- From face to dual point (or -1 if not feature face)
labelList faceToDualPoint_;
//- From edge to dual point (or -1 if not feature edge)
labelList edgeToDualPoint_;
// Private Member Functions
static void checkPolyTopoChange(const polyTopoChange&);
static void dumpPolyTopoChange(const polyTopoChange&, const fileName&);
//- Find dual cell given point and cell
label findDualCell(const label cellI, const label pointI) const;
//- Helper function to generate dualpoints on all boundary edges
// emanating from (boundary & feature) point
void generateDualBoundaryEdges
(
const PackedBoolList&,
const label pointI,
polyTopoChange&
);
//- Check that owner and neighbour of face have same dual cell
bool sameDualCell
(
const label faceI,
const label pointI
) const;
//- Add internal face
label addInternalFace
(
const label masterPointI,
const label masterEdgeI,
const label masterFaceI,
const bool edgeOrder,
const label dualCell0,
const label dualCell1,
const DynamicList<label>& verts,
polyTopoChange& meshMod
) const;
//- Add boundary face
label addBoundaryFace
(
const label masterPointI,
const label masterEdgeI,
const label masterFaceI,
const label dualCellI,
const label patchI,
const DynamicList<label>& verts,
polyTopoChange& meshMod
) const;
//- Create internal faces walking around edge
void createFacesAroundEdge
(
const bool splitFace,
const PackedBoolList&,
const label edgeI,
const label startFaceI,
polyTopoChange&,
boolList& doneEFaces
) const;
//- Create single internal face from internal face
void createFaceFromInternalFace
(
const label faceI,
label& fp,
polyTopoChange&
) const;
//- Creates boundary faces walking around point on patchI.
void createFacesAroundBoundaryPoint
(
const label patchI,
const label patchPointI,
const label startFaceI,
polyTopoChange&,
boolList& donePFaces // pFaces visited
) const;
//- Disallow default bitwise copy construct
meshDualiser(const meshDualiser&);
//- Disallow default bitwise assignment
void operator=(const meshDualiser&);
public:
//- Runtime type information
ClassName("meshDualiser");
// Constructors
//- Construct from mesh
meshDualiser(const polyMesh&);
// Member Functions
// Access
//- From point on cell to dual cell. Either single entry or
// one entry per pointCells.
const labelListList& pointToDualCells() const
{
return pointToDualCells_;
}
//- From point to dual point (or -1 if not feature point).
const labelList& pointToDualPoint() const
{
return pointToDualPoint_;
}
//- From cell to dual point (at cell centre). All cells become
// points.
const labelList& cellToDualPoint() const
{
return cellToDualPoint_;
}
//- From face to dual point (at face centre; or -1 if not
// feature face).
const labelList& faceToDualPoint() const
{
return faceToDualPoint_;
}
//- From edge to dual point (at edge mid; or -1 if not feature
// edge).
const labelList& edgeToDualPoint() const
{
return edgeToDualPoint_;
}
// Edit
//- Insert all changes into meshMod to convert the polyMesh into
// its dual.
// featureFaces : faces where we want a point at the face centre
// featureEdges : edges ,, edge mid
// featurePoints : points ,, point. Two variants:
// singleCellFeaturePoints : point becomes one dualcell.
// Use this for e.g. convex boundary points.
// multiCellFeaturePoints : one dualcell per original cell
// around point. Use this for e.g. concave boundary points
// since it prevents big concave boundary cells.
void setRefinement
(
const bool splitFace,
const labelList& featureFaces,
const labelList& featureEdges,
const labelList& singleCellFeaturePoints,
const labelList& multiCellFeaturePoints,
polyTopoChange& meshMod
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -22,35 +22,370 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
polyDualMesh
Description
Calculate the dual of a polyMesh. Adheres to all the feature&patch edges
Calculate the dual of a polyMesh. Adheres to all the feature and patch
edges.
Usage
- polyDualMesh featureAngle
Detects any boundary edge > angle and creates multiple boundary faces
for it. Normal behaviour is to have each point become a cell
(1.5 behaviour)
@param -concaveMultiCells
Creates multiple cells for each point on a concave edge. Might limit
the amount of distortion on some meshes.
@param -splitAllFaces
Normally only constructs a single face between two cells. This single face
might be too distorted. splitAllFaces will create a single face for every
original cell the face passes through. The mesh will thus have
multiple faces inbetween two cells! (so is not strictly upper-triangular
anymore - checkMesh will complain)
@param -doNotPreserveFaceZones:
By default all faceZones are preserved by marking all faces, edges and
points on them as features. The -doNotPreserveFaceZones disables this
behaviour.
Note: is just a driver for meshDualiser. Substitute your own
simpleMarkFeatures to have different behaviour.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "polyDualMesh.H"
#include "timeSelector.H"
#include "fvMesh.H"
#include "mathematicalConstants.H"
#include "polyTopoChange.H"
#include "mapPolyMesh.H"
#include "PackedBoolList.H"
#include "meshTools.H"
#include "OFstream.H"
#include "meshDualiser.H"
#include "ReadFields.H"
#include "volFields.H"
#include "surfaceFields.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Naive feature detection. All boundary edges with angle > featureAngle become
// feature edges. All points on feature edges become feature points. All
// boundary faces become feature faces.
void simpleMarkFeatures
(
const polyMesh& mesh,
const PackedBoolList& isBoundaryEdge,
const scalar featureAngle,
const bool concaveMultiCells,
const bool doNotPreserveFaceZones,
labelList& featureFaces,
labelList& featureEdges,
labelList& singleCellFeaturePoints,
labelList& multiCellFeaturePoints
)
{
scalar minCos = Foam::cos(featureAngle * mathematicalConstant::pi/180.0);
const polyBoundaryMesh& patches = mesh.boundaryMesh();
// Working sets
labelHashSet featureEdgeSet;
labelHashSet singleCellFeaturePointSet;
labelHashSet multiCellFeaturePointSet;
// 1. Mark all edges between patches
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
forAll(patches, patchI)
{
const polyPatch& pp = patches[patchI];
const labelList& meshEdges = pp.meshEdges();
// All patch corner edges. These need to be feature points & edges!
for (label edgeI = pp.nInternalEdges(); edgeI < pp.nEdges(); edgeI++)
{
label meshEdgeI = meshEdges[edgeI];
featureEdgeSet.insert(meshEdgeI);
singleCellFeaturePointSet.insert(mesh.edges()[meshEdgeI][0]);
singleCellFeaturePointSet.insert(mesh.edges()[meshEdgeI][1]);
}
}
// 2. Mark all geometric feature edges
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Make distinction between convex features where the boundary point becomes
// a single cell and concave features where the boundary point becomes
// multiple 'half' cells.
// Addressing for all outside faces
primitivePatch allBoundary
(
SubList<face>
(
mesh.faces(),
mesh.nFaces()-mesh.nInternalFaces(),
mesh.nInternalFaces()
),
mesh.points()
);
// Check for non-manifold points (surface pinched at point)
allBoundary.checkPointManifold(false, &singleCellFeaturePointSet);
// Check for non-manifold edges (surface pinched at edge)
const labelListList& edgeFaces = allBoundary.edgeFaces();
const labelList& meshPoints = allBoundary.meshPoints();
forAll(edgeFaces, edgeI)
{
const labelList& eFaces = edgeFaces[edgeI];
if (eFaces.size() > 2)
{
const edge& e = allBoundary.edges()[edgeI];
//Info<< "Detected non-manifold boundary edge:" << edgeI
// << " coords:"
// << allBoundary.points()[meshPoints[e[0]]]
// << allBoundary.points()[meshPoints[e[1]]] << endl;
singleCellFeaturePointSet.insert(meshPoints[e[0]]);
singleCellFeaturePointSet.insert(meshPoints[e[1]]);
}
}
// Check for features.
forAll(edgeFaces, edgeI)
{
const labelList& eFaces = edgeFaces[edgeI];
if (eFaces.size() == 2)
{
label f0 = eFaces[0];
label f1 = eFaces[1];
// check angle
const vector& n0 = allBoundary.faceNormals()[f0];
const vector& n1 = allBoundary.faceNormals()[f1];
if ((n0 & n1) < minCos)
{
const edge& e = allBoundary.edges()[edgeI];
label v0 = meshPoints[e[0]];
label v1 = meshPoints[e[1]];
label meshEdgeI = meshTools::findEdge(mesh, v0, v1);
featureEdgeSet.insert(meshEdgeI);
// Check if convex or concave by looking at angle
// between face centres and normal
vector c1c0
(
allBoundary[f1].centre(allBoundary.points())
- allBoundary[f0].centre(allBoundary.points())
);
if (concaveMultiCells && (c1c0 & n0) > SMALL)
{
// Found concave edge. Make into multiCell features
Info<< "Detected concave feature edge:" << edgeI
<< " cos:" << (c1c0 & n0)
<< " coords:"
<< allBoundary.points()[v0]
<< allBoundary.points()[v1]
<< endl;
singleCellFeaturePointSet.erase(v0);
multiCellFeaturePointSet.insert(v0);
singleCellFeaturePointSet.erase(v1);
multiCellFeaturePointSet.insert(v1);
}
else
{
// Convex. singleCell feature.
if (!multiCellFeaturePointSet.found(v0))
{
singleCellFeaturePointSet.insert(v0);
}
if (!multiCellFeaturePointSet.found(v1))
{
singleCellFeaturePointSet.insert(v1);
}
}
}
}
}
// 3. Mark all feature faces
// ~~~~~~~~~~~~~~~~~~~~~~~~~
// Face centres that need inclusion in the dual mesh
labelHashSet featureFaceSet(mesh.nFaces()-mesh.nInternalFaces());
// A. boundary faces.
for (label faceI = mesh.nInternalFaces(); faceI < mesh.nFaces(); faceI++)
{
featureFaceSet.insert(faceI);
}
// B. face zones.
const faceZoneMesh& faceZones = mesh.faceZones();
if (doNotPreserveFaceZones)
{
if (faceZones.size() > 0)
{
WarningIn("simpleMarkFeatures(..)")
<< "Detected " << faceZones.size()
<< " faceZones. These will not be preserved."
<< endl;
}
}
else
{
if (faceZones.size() > 0)
{
Info<< "Detected " << faceZones.size()
<< " faceZones. Preserving these by marking their"
<< " points, edges and faces as features." << endl;
}
forAll(faceZones, zoneI)
{
const faceZone& fz = faceZones[zoneI];
Info<< "Inserting all faces in faceZone " << fz.name()
<< " as features." << endl;
forAll(fz, i)
{
label faceI = fz[i];
const face& f = mesh.faces()[faceI];
const labelList& fEdges = mesh.faceEdges()[faceI];
featureFaceSet.insert(faceI);
forAll(f, fp)
{
// Mark point as multi cell point (since both sides of
// face should have different cells)
singleCellFeaturePointSet.erase(f[fp]);
multiCellFeaturePointSet.insert(f[fp]);
// Make sure there are points on the edges.
featureEdgeSet.insert(fEdges[fp]);
}
}
}
}
// Transfer to arguments
featureFaces = featureFaceSet.toc();
featureEdges = featureEdgeSet.toc();
singleCellFeaturePoints = singleCellFeaturePointSet.toc();
multiCellFeaturePoints = multiCellFeaturePointSet.toc();
}
// Dump features to .obj files
void dumpFeatures
(
const polyMesh& mesh,
const labelList& featureFaces,
const labelList& featureEdges,
const labelList& singleCellFeaturePoints,
const labelList& multiCellFeaturePoints
)
{
{
OFstream str("featureFaces.obj");
Info<< "Dumping centres of featureFaces to obj file " << str.name()
<< endl;
forAll(featureFaces, i)
{
meshTools::writeOBJ(str, mesh.faceCentres()[featureFaces[i]]);
}
}
{
OFstream str("featureEdges.obj");
Info<< "Dumping featureEdges to obj file " << str.name() << endl;
label vertI = 0;
forAll(featureEdges, i)
{
const edge& e = mesh.edges()[featureEdges[i]];
meshTools::writeOBJ(str, mesh.points()[e[0]]);
vertI++;
meshTools::writeOBJ(str, mesh.points()[e[1]]);
vertI++;
str<< "l " << vertI-1 << ' ' << vertI << nl;
}
}
{
OFstream str("singleCellFeaturePoints.obj");
Info<< "Dumping featurePoints that become a single cell to obj file "
<< str.name() << endl;
forAll(singleCellFeaturePoints, i)
{
meshTools::writeOBJ(str, mesh.points()[singleCellFeaturePoints[i]]);
}
}
{
OFstream str("multiCellFeaturePoints.obj");
Info<< "Dumping featurePoints that become multiple cells to obj file "
<< str.name() << endl;
forAll(multiCellFeaturePoints, i)
{
meshTools::writeOBJ(str, mesh.points()[multiCellFeaturePoints[i]]);
}
}
}
int main(int argc, char *argv[])
{
argList::noParallel();
timeSelector::addOptions(true, false);
argList::validArgs.append("feature angle[0-180]");
argList::validOptions.insert("splitAllFaces", "");
argList::validOptions.insert("concaveMultiCells", "");
argList::validOptions.insert("doNotPreserveFaceZones", "");
argList::validOptions.insert("overwrite", "");
# include "setRootCase.H"
# include "createTime.H"
# include "createPolyMesh.H"
instantList timeDirs = timeSelector::select0(runTime, args);
# include "createMesh.H"
const word oldInstance = mesh.pointsInstance();
// Mark boundary edges and points.
// (Note: in 1.4.2 we can use the built-in mesh point ordering
// facility instead)
PackedBoolList isBoundaryEdge(mesh.nEdges());
for (label faceI = mesh.nInternalFaces(); faceI < mesh.nFaces(); faceI++)
{
const labelList& fEdges = mesh.faceEdges()[faceI];
forAll(fEdges, i)
{
isBoundaryEdge.set(fEdges[i], 1);
}
}
scalar featureAngle(readScalar(IStringStream(args.additionalArgs()[0])()));
bool overwrite = args.options().found("overwrite");
scalar minCos = Foam::cos(featureAngle * mathematicalConstant::pi/180.0);
@ -58,18 +393,154 @@ int main(int argc, char *argv[])
<< "minCos :" << minCos << endl
<< endl;
polyDualMesh dualMesh(mesh, minCos);
const bool splitAllFaces = args.optionFound("splitAllFaces");
if (splitAllFaces)
{
Info<< "Splitting all internal faces to create multiple faces"
<< " between two cells." << nl
<< endl;
}
const bool overwrite = args.optionFound("overwrite");
const bool doNotPreserveFaceZones = args.optionFound
(
"doNotPreserveFaceZones"
);
const bool concaveMultiCells = args.optionFound("concaveMultiCells");
if (concaveMultiCells)
{
Info<< "Generating multiple cells for points on concave feature edges."
<< nl << endl;
}
// Face(centre)s that need inclusion in the dual mesh
labelList featureFaces;
// Edge(centre)s ,,
labelList featureEdges;
// Points (that become a single cell) that need inclusion in the dual mesh
labelList singleCellFeaturePoints;
// Points (that become a multiple cells) ,,
labelList multiCellFeaturePoints;
// Sample implementation of feature detection.
simpleMarkFeatures
(
mesh,
isBoundaryEdge,
featureAngle,
concaveMultiCells,
doNotPreserveFaceZones,
featureFaces,
featureEdges,
singleCellFeaturePoints,
multiCellFeaturePoints
);
// If we want to split all polyMesh faces into one dualface per cell
// we are passing through we also need a point
// at the polyMesh facecentre and edgemid of the faces we want to
// split.
if (splitAllFaces)
{
featureEdges = identity(mesh.nEdges());
featureFaces = identity(mesh.nFaces());
}
// Write obj files for debugging
dumpFeatures
(
mesh,
featureFaces,
featureEdges,
singleCellFeaturePoints,
multiCellFeaturePoints
);
// Read objects in time directory
IOobjectList objects(mesh, runTime.timeName());
// Read vol fields.
PtrList<volScalarField> vsFlds;
ReadFields(mesh, objects, vsFlds);
PtrList<volVectorField> vvFlds;
ReadFields(mesh, objects, vvFlds);
PtrList<volSphericalTensorField> vstFlds;
ReadFields(mesh, objects, vstFlds);
PtrList<volSymmTensorField> vsymtFlds;
ReadFields(mesh, objects, vsymtFlds);
PtrList<volTensorField> vtFlds;
ReadFields(mesh, objects, vtFlds);
// Read surface fields.
PtrList<surfaceScalarField> ssFlds;
ReadFields(mesh, objects, ssFlds);
PtrList<surfaceVectorField> svFlds;
ReadFields(mesh, objects, svFlds);
PtrList<surfaceSphericalTensorField> sstFlds;
ReadFields(mesh, objects, sstFlds);
PtrList<surfaceSymmTensorField> ssymtFlds;
ReadFields(mesh, objects, ssymtFlds);
PtrList<surfaceTensorField> stFlds;
ReadFields(mesh, objects, stFlds);
// Topo change container
polyTopoChange meshMod(mesh.boundaryMesh().size());
// Mesh dualiser engine
meshDualiser dualMaker(mesh);
// Insert all commands into polyTopoChange to create dual of mesh. This does
// all the hard work.
dualMaker.setRefinement
(
splitAllFaces,
featureFaces,
featureEdges,
singleCellFeaturePoints,
multiCellFeaturePoints,
meshMod
);
// Create mesh, return map from old to new mesh.
autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh, false);
// Update fields
mesh.updateMesh(map);
// Optionally inflate mesh
if (map().hasMotionPoints())
{
mesh.movePoints(map().preMotionPoints());
}
if (!overwrite)
{
runTime++;
}
else
{
mesh.setInstance(oldInstance);
}
Pout<< "Writing dualMesh to " << runTime.timeName() << endl;
Info<< "Writing dual mesh to " << runTime.timeName() << endl;
dualMesh.write();
mesh.write();
Info << "End\n" << endl;
Info<< "End\n" << endl;
return 0;
}

View file

@ -136,7 +136,7 @@ void sammMesh::readCouples()
forAll (curFaces, faceI)
{
if (curFaces[faceI].size() == 0)
if (curFaces[faceI].empty())
{
zeroSizeFound++;
}
@ -153,7 +153,7 @@ void sammMesh::readCouples()
forAll (oldFaces, faceI)
{
if (oldFaces[faceI].size() > 0)
if (oldFaces[faceI].size())
{
curFaces[nFaces] = oldFaces[faceI];

View file

@ -90,13 +90,13 @@ const label sammMesh::shapeFaceLookup[19][9] =
List<const cellModel*> sammMesh::sammShapeLookup
(
256,
reinterpret_cast<cellModel*>(NULL)
reinterpret_cast<cellModel*>(0)
);
List<const label*> sammMesh::sammAddressingTable
(
256,
reinterpret_cast<label*>(NULL)
reinterpret_cast<label*>(0)
);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //

View file

@ -51,10 +51,7 @@ int main(int argc, char *argv[])
}
scalar scaleFactor = 1.0;
if (args.options().found("scale"))
{
scaleFactor = atof(args.options()["scale"].c_str());
}
args.optionReadIfPresent("scale", scaleFactor);
# include "createTime.H"
@ -69,7 +66,7 @@ int main(int argc, char *argv[])
Info<< nl << "End" << nl << endl;
return(0);
return 0;
}

View file

@ -45,8 +45,7 @@ void starMesh::createCoupleMatches()
// existing points list
// Estimate the number of cells affected by couple matches
const label cellMapSize =
min
const label cellMapSize = min
(
cellShapes_.size()/10,
couples_.size()*2
@ -885,7 +884,7 @@ void starMesh::createCoupleMatches()
<< "newSlaveEdges: " << newSlaveEdges << endl;
# endif
edge startEdge;
edge startEdge(-1, -1);
// Remember where the start edge was found:
// 0 for not found
@ -1097,7 +1096,7 @@ void starMesh::createCoupleMatches()
<< "edges to consider: " << edgesToConsider << endl;
# endif
if (edgesToConsider.size() == 0)
if (edgesToConsider.empty())
{
FatalErrorIn("void starMesh::createCoupleMatches()")
<< setprecision(12)
@ -1420,7 +1419,7 @@ void starMesh::createCoupleMatches()
} // end of arbitrary match
}
if (couples_.size() > 0)
if (couples_.size())
{
// Loop through all cells and reset faces for removal to zero size
const labelList crfToc = cellRemovedFaces.toc();
@ -1442,7 +1441,7 @@ void starMesh::createCoupleMatches()
cellFaces_[curCell][curRemovedFacesIter()].setSize(0);
}
if (curRemovedFaces.size() > 0)
if (curRemovedFaces.size())
{
// reset the shape pointer to unknown
cellShapes_[curCell] = cellShape(*unknownPtr_, labelList(0));
@ -1468,7 +1467,7 @@ void starMesh::createCoupleMatches()
// copy original faces that have not been removed
forAll (oldFaces, faceI)
{
if (oldFaces[faceI].size() > 0)
if (oldFaces[faceI].size())
{
newFaces[nNewFaces] = oldFaces[faceI];
nNewFaces++;
@ -1491,7 +1490,7 @@ void starMesh::createCoupleMatches()
// reset the size of the face list
newFaces.setSize(nNewFaces);
if (curAddedFaces.size() > 0)
if (curAddedFaces.size())
{
// reset the shape pointer to unknown
cellShapes_[curCell] = cellShape(*unknownPtr_, labelList(0));

View file

@ -48,7 +48,7 @@ void starMesh::addRegularCell
label regularTypeFlag = -1;
// grab the shape from the table
const cellModel* curModelPtr = reinterpret_cast<cellModel*>(NULL);
const cellModel* curModelPtr = reinterpret_cast<cellModel*>(0);
if // Tetrahedron
(
@ -130,7 +130,7 @@ void starMesh::addSAMMcell
// grab the shape from the table
label sammTypeFlag = -1;
const cellModel* curModelPtr = reinterpret_cast<cellModel*>(NULL);
const cellModel* curModelPtr = reinterpret_cast<cellModel*>(0);
switch (typeFlag)
{

View file

@ -264,7 +264,7 @@ starMesh::starMesh
readCouples();
if (couples_.size() > 0)
if (couples_.size())
{
createCoupleMatches();
}

View file

@ -51,10 +51,7 @@ int main(int argc, char *argv[])
}
scalar scaleFactor = 1.0;
if (args.options().found("scale"))
{
scaleFactor = atof(args.options()["scale"].c_str());
}
args.optionReadIfPresent("scale", scaleFactor);
# include "createTime.H"
@ -69,7 +66,7 @@ int main(int argc, char *argv[])
Info<< nl << "End" << nl << endl;
return(0);
return 0;
}

View file

@ -0,0 +1,726 @@
724 4 0
1 48 170 84 171
2 78 202 171 213
3 16 48 45 171
4 128 159 108 191
5 167 168 77 200
6 72 166 25 199
7 8 197 44 198
8 162 166 72 199
9 50 84 83 196
10 67 126 17 172
11 48 125 45 171
12 103 150 63 210
13 102 177 59 194
14 119 172 75 213
15 10 157 69 208
16 126 167 119 172
17 30 157 107 190
18 52 182 180 209
19 88 192 105 205
20 152 194 104 203
21 107 187 150 190
22 23 141 86 192
23 97 99 140 184
24 55 189 133 207
25 97 138 31 151
26 35 142 60 194
27 27 118 74 164
28 101 127 21 152
29 126 171 167 200
30 90 109 55 133
31 21 178 152 203
32 134 173 93 174
33 27 83 50 84
34 85 127 29 211
35 164 176 111 202
36 65 153 105 156
37 149 186 59 203
38 88 87 129 130
39 23 141 97 151
40 177 178 136 203
41 76 164 43 198
42 84 176 126 202
43 89 116 90 133
44 40 112 71 113
45 40 70 71 112
46 125 126 45 171
47 133 161 66 176
48 65 105 14 156
49 66 189 187 207
50 67 68 38 110
51 60 144 62 61
52 124 165 33 204
53 52 128 108 191
54 26 90 89 116
55 114 164 76 198
56 150 190 104 192
57 59 186 102 194
58 69 157 103 190
59 120 170 196 122
60 116 164 117 197
61 5 112 41 113
62 37 110 107 157
63 132 181 32 189
64 121 122 18 196
65 84 123 27 202
66 73 195 163 199
67 182 204 137 209
68 140 97 23 99
69 96 136 135 178
70 28 80 57 81
71 23 99 97 141
72 153 156 63 193
73 100 152 21 178
74 148 151 146 190
75 115 43 15 213
76 138 186 139 188
77 48 125 84 170
78 105 153 65 155
79 108 204 182 209
80 104 193 192 205
81 18 83 40 121
82 32 111 89 133
83 59 95 94 149
84 135 136 34 178
85 95 137 132 189
86 57 80 52 108
87 104 151 149 186
88 186 194 59 203
89 152 191 150 193
90 115 197 8 198
91 170 125 201 48
92 140 183 7 184
93 9 108 52 128
94 70 5 71 112
95 44 116 26 117
96 84 126 125 171
97 66 159 126 161
98 52 191 108 209
99 41 112 72 113
100 108 191 159 209
101 125 170 201 160
102 77 168 167 169
103 103 157 30 190
104 52 9 57 108
105 127 152 101 193
106 38 68 37 110
107 133 189 66 207
108 8 76 115 198
109 65 153 143 154
110 31 151 138 206
111 62 144 6 61
112 192 193 105 205
113 153 154 101 211
114 72 163 111 199
115 13 101 100 212
116 104 187 150 191
117 13 154 101 212
118 23 97 86 151
119 102 61 144 194
120 153 193 63 211
121 20 159 126 160
122 14 88 130 156
123 30 107 37 159
124 65 154 2 155
125 42 111 89 162
126 85 150 30 191
127 194 205 142 212
128 97 141 99 151
129 120 82 50 170
130 22 60 61 102
131 66 161 126 176
132 30 128 85 191
133 59 139 102 186
134 54 89 26 90
135 70 112 40 114
136 66 159 107 187
137 32 132 91 181
138 49 124 80 160
139 56 91 12 92
140 126 159 37 161
141 78 168 46 169
142 144 177 102 194
143 113 121 40 196
144 86 148 129 192
145 7 184 183 185
146 17 109 90 133
147 141 192 88 205
148 167 168 45 169
149 97 184 139 185
150 2 154 64 155
151 111 195 181 199
152 78 123 47 171
153 84 176 111 195
154 49 160 80 201
155 43 197 115 198
156 38 67 24 68
157 93 174 173 189
158 150 152 104 191
159 24 167 77 200
160 122 170 49 201
161 71 112 5 113
162 163 195 111 199
163 17 172 126 176
164 124 160 49 195
165 37 106 30 159
166 40 113 71 121
167 136 178 96 203
168 127 191 152 193
169 67 167 126 172
170 139 185 102 186
171 66 187 107 207
172 104 187 149 206
173 40 74 19 114
174 84 170 123 171
175 107 110 37 161
176 42 164 114 198
177 63 193 150 211
178 39 161 107 207
179 50 123 84 170
180 49 170 160 201
181 46 168 4 169
182 84 170 49 196
183 49 195 84 196
184 183 184 99 185
185 111 114 42 164
186 31 158 146 190
187 109 161 39 207
188 54 90 55 175
189 44 197 117 198
190 111 163 84 195
191 117 164 42 198
192 73 121 113 163
193 86 97 31 151
194 90 133 55 175
195 125 160 84 170
196 80 160 81 201
197 160 176 126 195
198 144 100 34 177
199 139 149 59 188
200 103 146 69 190
201 74 114 40 163
202 107 150 30 190
203 74 118 43 164
204 4 168 77 169
205 27 84 50 123
206 189 206 187 207
207 151 192 141 205
208 163 195 73 196
209 71 18 40 121
210 149 151 138 186
211 43 118 15 213
212 35 145 141 205
213 146 148 86 151
214 100 194 152 203
215 36 138 97 139
216 147 192 190 210
217 107 158 39 207
218 95 132 94 149
219 60 102 22 145
220 183 140 99 184
221 89 111 32 162
222 28 81 48 201
223 34 177 100 178
224 146 147 53 148
225 111 162 72 199
226 60 142 13 194
227 181 195 66 204
228 108 160 33 204
229 31 138 93 206
230 119 167 126 171
231 107 161 66 207
232 180 191 52 209
233 126 202 176 213
234 45 126 68 200
235 53 146 103 147
236 38 37 10 110
237 15 118 78 213
238 101 152 100 212
239 138 151 149 206
240 26 116 89 117
241 10 110 37 157
242 171 202 126 213
243 129 147 87 148
244 100 101 21 152
245 97 98 36 139
246 52 80 33 108
247 48 170 79 201
248 98 184 7 185
249 153 154 65 155
250 55 173 133 189
251 149 151 104 206
252 143 2 65 154
253 78 171 119 213
254 58 108 9 128
255 9 52 51 128
256 60 62 144 194
257 94 138 93 188
258 132 149 95 189
259 9 58 57 108
260 104 190 151 192
261 105 192 156 193
262 69 103 53 146
263 70 40 19 114
264 95 149 137 189
265 192 193 150 210
266 58 81 57 108
267 102 145 60 194
268 57 81 80 108
269 52 127 51 191
270 12 92 91 179
271 60 61 102 194
272 150 192 104 193
273 30 150 103 190
274 130 88 87 156
275 13 142 100 194
276 53 147 129 148
277 125 126 84 160
278 55 109 39 207
279 129 131 88 130
280 30 159 128 191
281 86 141 23 151
282 153 155 105 193
283 40 114 112 163
284 27 196 84 202
285 85 128 51 191
286 160 195 33 204
287 94 134 93 174
288 109 133 17 161
289 109 110 39 161
290 84 160 49 170
291 89 90 54 175
292 96 137 92 179
293 31 146 86 151
294 117 197 164 198
295 15 78 46 119
296 91 92 56 166
297 112 113 40 163
298 45 168 167 200
299 68 126 67 200
300 136 177 34 178
301 49 122 121 196
302 92 137 91 179
303 63 103 85 150
304 92 165 56 166
305 167 171 45 200
306 81 160 125 201
307 29 85 51 127
308 46 119 78 169
309 172 176 75 213
310 131 130 129 3
311 88 129 87 192
312 119 171 126 213
313 39 158 55 207
314 105 193 155 212
315 15 119 75 213
316 33 182 108 204
317 104 187 152 203
318 16 123 48 171
319 107 159 66 161
320 123 170 48 171
321 84 125 48 171
322 124 195 165 204
323 146 151 31 190
324 74 83 27 163
325 37 159 107 161
326 47 4 46 168
327 136 149 59 203
328 20 68 45 126
329 82 123 50 170
330 20 106 68 126
331 37 110 68 161
332 80 81 28 201
333 24 68 67 200
334 46 78 47 168
335 67 126 68 161
336 93 138 134 188
337 68 106 37 126
338 20 126 125 160
339 163 196 27 202
340 72 114 111 163
341 33 108 80 160
342 55 173 54 175
343 45 125 20 126
344 50 170 84 196
345 133 173 55 175
346 80 124 33 160
347 63 193 156 210
348 68 126 37 161
349 104 152 150 193
350 133 164 116 176
351 145 194 186 205
352 126 160 66 176
353 107 206 158 207
354 12 96 92 179
355 118 164 27 202
356 164 197 43 198
357 89 133 90 175
358 67 109 17 161
359 105 193 35 205
360 55 133 109 207
361 33 160 124 195
362 173 174 11 175
363 137 187 149 203
364 79 170 122 201
365 39 158 107 190
366 150 191 85 211
367 40 121 83 196
368 32 133 132 189
369 56 165 25 166
370 42 114 111 162
371 141 145 99 205
372 27 163 83 196
373 92 137 96 182
374 149 187 104 203
375 126 167 67 200
376 137 180 96 182
377 102 186 145 194
378 62 60 13 194
379 15 75 115 213
380 85 103 30 150
381 49 160 84 195
382 137 181 66 204
383 59 149 139 186
384 98 139 97 184
385 51 127 85 191
386 149 187 137 189
387 91 166 32 181
388 139 184 98 185
389 31 190 151 206
390 100 178 177 194
391 150 187 107 191
392 149 186 138 188
393 51 128 52 191
394 108 182 52 209
395 59 136 95 149
396 93 138 94 149
397 94 149 132 189
398 132 133 32 175
399 135 136 96 179
400 92 182 33 204
401 137 187 66 189
402 137 181 132 189
403 88 141 23 192
404 187 206 107 207
405 107 110 39 208
406 37 126 106 159
407 94 149 138 188
408 11 173 134 174
409 159 191 187 209
410 13 100 62 194
411 105 155 142 212
412 35 205 193 212
413 152 187 104 191
414 60 145 35 194
415 14 105 88 156
416 33 165 92 204
417 133 181 66 189
418 107 190 157 208
419 39 190 107 208
420 20 125 81 160
421 80 108 81 160
422 100 177 144 194
423 138 139 36 188
424 49 170 122 196
425 132 174 94 189
426 139 186 149 188
427 134 138 36 188
428 144 62 100 194
429 91 137 92 181
430 92 166 91 181
431 107 187 159 191
432 141 151 86 192
433 165 199 181 204
434 150 159 30 191
435 129 148 87 192
436 100 142 13 212
437 52 180 21 191
438 107 159 150 191
439 142 205 35 212
440 37 107 30 157
441 21 127 52 191
442 92 181 137 204
443 129 88 131 192
444 103 147 146 190
445 137 182 92 204
446 87 156 88 192
447 91 137 95 179
448 135 96 12 179
449 164 202 118 213
450 110 157 10 208
451 101 193 152 212
452 152 205 194 212
453 21 152 127 191
454 193 205 152 212
455 59 149 94 188
456 30 106 58 159
457 67 110 109 161
458 68 110 67 161
459 66 204 108 209
460 32 181 133 189
461 17 126 67 161
462 106 126 20 159
463 111 114 72 162
464 40 83 74 163
465 48 79 28 201
466 30 150 107 159
467 108 128 58 159
468 58 128 30 159
469 39 110 107 161
470 83 121 18 196
471 134 94 93 188
472 86 129 131 192
473 126 159 66 160
474 66 159 108 160
475 166 181 165 199
476 186 194 104 205
477 81 108 58 160
478 108 159 58 160
479 81 106 20 160
480 106 159 20 160
481 99 186 151 205
482 52 108 33 182
483 178 194 100 203
484 78 169 119 171
485 58 106 81 160
486 58 159 106 160
487 112 114 72 163
488 111 164 133 176
489 54 173 11 175
490 177 194 178 203
491 25 166 165 199
492 19 74 43 164
493 19 114 74 164
494 111 163 114 164
495 114 163 74 164
496 152 178 100 203
497 111 181 162 199
498 76 19 43 164
499 76 114 19 164
500 89 117 116 164
501 116 133 89 164
502 42 117 89 164
503 89 111 42 164
504 89 133 111 164
505 48 82 79 170
506 82 48 16 170
507 48 123 16 170
508 16 123 82 170
509 43 115 76 198
510 75 164 116 197
511 126 171 84 202
512 84 196 163 202
513 84 171 123 202
514 78 118 27 202
515 120 1 82 170
516 120 122 1 170
517 82 1 79 170
518 1 122 79 170
519 47 168 78 171
520 45 168 47 171
521 16 45 47 171
522 47 123 16 171
523 59 194 177 203
524 152 191 21 203
525 32 133 89 175
526 104 186 149 203
527 119 169 167 171
528 167 169 45 171
529 45 169 168 171
530 168 169 78 171
531 104 194 186 203
532 59 177 136 203
533 137 149 95 203
534 95 149 136 203
535 17 161 133 176
536 126 161 17 176
537 116 164 75 176
538 75 172 116 176
539 90 133 116 176
540 116 172 90 176
541 17 133 90 176
542 90 172 17 176
543 150 193 63 210
544 195 199 165 204
545 66 181 137 189
546 81 125 48 201
547 165 166 92 181
548 32 162 111 181
549 32 166 162 181
550 45 171 126 200
551 111 133 32 181
552 147 148 146 190
553 105 156 153 193
554 66 161 133 207
555 91 132 95 181
556 132 137 95 181
557 95 137 91 181
558 99 151 141 205
559 111 176 133 181
560 133 176 66 181
561 66 176 111 181
562 40 163 113 196
563 145 186 99 205
564 88 105 35 205
565 113 163 121 196
566 84 195 163 196
567 121 163 73 196
568 187 191 152 203
569 83 163 40 196
570 83 84 27 196
571 138 149 93 206
572 107 190 158 206
573 97 151 99 186
574 144 61 60 194
575 187 190 107 206
576 157 190 69 208
577 22 145 102 186
578 102 185 22 186
579 104 192 151 205
580 126 176 84 195
581 67 167 24 200
582 116 117 44 197
583 97 139 138 186
584 138 151 97 186
585 162 181 166 199
586 66 181 111 195
587 99 145 22 186
588 97 185 139 186
589 66 176 160 195
590 183 99 22 186
591 183 185 99 186
592 22 185 183 186
593 99 184 97 186
594 99 185 184 186
595 184 185 97 186
596 111 176 66 195
597 84 160 126 195
598 35 141 88 205
599 87 148 147 192
600 137 204 66 209
601 86 151 148 192
602 181 199 195 204
603 174 175 173 189
604 173 175 133 189
605 132 175 174 189
606 133 175 132 189
607 133 161 109 207
608 159 187 66 209
609 93 149 94 189
610 94 174 93 189
611 146 190 158 208
612 158 190 39 208
613 66 187 137 209
614 180 182 137 209
615 108 159 66 209
616 190 192 150 210
617 85 191 127 211
618 127 193 101 211
619 101 193 153 211
620 103 190 150 210
621 69 190 146 208
622 88 156 105 192
623 63 150 85 211
624 23 131 88 192
625 86 131 23 192
626 151 190 148 192
627 148 190 147 192
628 101 154 143 211
629 29 127 101 211
630 29 101 143 211
631 143 154 153 211
632 78 119 15 213
633 118 202 78 213
634 33 195 124 204
635 93 158 31 206
636 158 190 31 206
637 107 157 110 208
638 66 160 108 204
639 165 181 92 204
640 66 195 160 204
641 156 193 192 210
642 149 189 93 206
643 187 189 149 206
644 170 120 196 50
645 73 124 121 196
646 73 195 124 196
647 121 124 49 196
648 124 195 49 196
649 50 83 18 196
650 50 18 120 196
651 18 122 120 196
652 151 186 104 205
653 73 165 124 199
654 165 195 124 199
655 124 195 73 199
656 73 163 113 199
657 25 165 73 199
658 73 113 41 199
659 41 113 72 199
660 113 72 163 112
661 72 113 163 199
662 41 72 25 199
663 25 73 41 199
664 111 176 84 202
665 27 123 78 202
666 123 171 78 202
667 84 163 111 202
668 163 164 111 202
669 74 163 27 202
670 74 164 163 202
671 27 164 74 202
672 95 179 137 203
673 136 179 95 203
674 137 179 96 203
675 96 179 136 203
676 96 178 21 203
677 147 190 103 210
678 156 192 87 210
679 87 192 147 210
680 96 180 137 203
681 21 180 96 203
682 35 194 145 205
683 43 164 118 213
684 142 194 35 205
685 152 193 104 205
686 104 194 152 205
687 126 176 172 213
688 126 172 119 213
689 151 190 104 206
690 150 187 104 206
691 150 190 187 206
692 104 190 150 206
693 93 206 189 207
694 158 206 93 207
695 158 173 55 207
696 173 189 55 207
697 93 173 158 207
698 93 189 173 207
699 187 203 137 209
700 137 203 180 209
701 191 203 187 209
702 21 191 180 209
703 21 203 191 209
704 180 203 21 209
705 150 193 191 211
706 191 193 127 211
707 13 142 64 212
708 64 154 13 212
709 152 194 100 212
710 100 194 142 212
711 105 142 35 212
712 35 193 105 212
713 64 155 154 212
714 142 155 64 212
715 154 155 153 212
716 155 193 153 212
717 101 154 153 212
718 153 193 101 212
719 75 176 164 213
720 176 202 164 213
721 43 197 164 213
722 164 197 75 213
723 75 197 115 213
724 115 197 43 213
# Generated by tetgen -qfa0.005 beam.poly

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,215 @@
213 3 0 0
1 0 0 0
2 2 0 0
3 2 1 0
4 0 1 0
5 0 0 1
6 2 0 1
7 2 1 1
8 0 1 1
9 1.0000469999999999 0 0
10 0.999668 1 0
11 0.99944500000000003 1 1
12 1.000594 0 1
13 2 0 0.50021530000000003
14 2 0.50012599999999996 0
15 0 1 0.50045629999999997
16 0 0.49964989999999998 0
17 0.62483357601847556 1 0.49991643678795222
18 0 0 0.5
19 0 0.5 1
20 0.62494657145582122 0.49985790875808178 0
21 1.375120204581187 0 0.4997949845615941
22 2 0.5 1
23 2 1 0.5
24 0.499834 1 0
25 0.50029699999999999 0 1
26 0.49972250000000001 1 1
27 0 0.50000006130646835 0.49999993869353165
28 0.50002349999999995 0 0
29 1.5000235 0 0
30 1.1458145624989733 0.5000553177266871 0
31 1.3748336567109987 1 0.5000836868059465
32 0.75044549999999999 0.49971323947400004 1
33 0.75044549999999999 0 0.50013668162500002
34 1.500297 0 1
35 2 0.49999999206099965 0.49999999206099965
36 1.4997225000000001 1 1
37 0.88530655619767451 0.69523571541331353 0
38 0.74975100000000006 1 0
39 0.99985800700011418 1 0.39062501526316751
40 0 0.2500000613064608 0.7499999386935392
41 0.2501485 0 1
42 0.37527044007359472 0.62466041202689604 1
43 0 0.7497720581817594 0.74999999997204392
44 0.24986125000000001 1 1
45 0.31241083060970776 0.68739558038665782 0
46 0 1 0.25022814999999998
47 0 0.74982495000000005 0
48 0.3125356465289606 0.31239559711921033 0
49 0.37524548555134551 0 0.37523962153691648
50 0 0.25000000002145584 0.25017492745143088
51 1.2500352499999998 0 0
52 1.0626973305232652 0 0.34361890927552119
53 1.4998339999999999 1 0
54 0.74958374999999999 1 1
55 0.88519156134454835 1 0.69523493182271912
56 0.75044549999999999 0 1
57 0.75003524999999993 0 0
58 0.88545457775712011 0.3046775110714553 0
59 1.4999999173907641 0.49999999435116604 1
60 2 0.25010760364761792 0.74999999999829137
61 2 0.25 1
62 2 0 0.75010765000000001
63 1.5729133203896351 0.4271084905205621 0
64 2 0 0.25010765000000001
65 2 0.25006299999999998 0
66 0.81619988117037301 0.51616065956439328 0.48387527405505287
67 0.62479250000000008 1 0.23434098330631092
68 0.62479250000000008 0.7655391212272894 0
69 1.2497509999999998 1 0
70 0 0.25 1
71 0 0 0.75
72 0.37522274999999999 0.29980854989635936 1
73 0.37522274999999999 0 0.70013946473134281
74 0 0.49988605975809192 0.74988593714516283
75 0.31255174452459605 1 0.65638401293888804
76 0 0.75 1
77 0.249917 1 0
78 0 0.70831779089254521 0.29167340665919461
79 0.25001174999999998 0 0
80 0.62526649037406934 0 0.25017085386153537
81 0.625029375 0.23429805042184107 0
82 0 0.24982494999999999 0
83 0 0.25008755567468249 0.50008743306175329
84 0.33552291795286748 0.37713361953826796 0.37295234921245662
85 1.3275022682494733 0.27703395451399626 0
86 1.6873917295541676 1 0.31254602883562033
87 1.7393002110516891 0.73944000928409781 0
88 2 0.7499999999989998 0.25006298412499983
89 0.62528740222670842 0.74964177558619371 1
90 0.62465312500000003 1 0.76556323888302447
91 0.87551975000000004 0.24985661973700002 1
92 0.87551975000000004 0 0.75006834081249996
93 1.1922864636768418 1 0.75390684273024755
94 1.24958375 0.74986113453803516 1
95 1.1698804466514103 0.41956399899988917 1
96 1.187959730551635 0 0.74997433471920583
97 1.6874419282782818 1 0.68754603555472626
98 1.7498612499999999 1 1
99 2 0.74999999206099988 0.74999999206099988
100 1.6597700161872737 0 0.69432640578660343
101 1.6597808229817657 0 0.30542952755181008
102 1.7499999601075902 0.375 1
103 1.3990667318832528 0.69603906683685635 0
104 1.4950021306707608 0.49065317884606224 0.49500212996719484
105 2 0.37509449999999989 0.24996850198475024
106 0.82837583873678577 0.49993500845038119 0
107 1.0695558475797649 0.66971322958604163 0.29687786818700823
108 0.85307867962811157 0.24362257622712302 0.31516017245746403
109 0.82827226523186892 1 0.49992109713449329
110 0.85617934854666022 1 0.20723770847200895
111 0.52956259724790877 0.46221182650782827 0.70815142735106607
112 0.197844687328108 0.19781366296788089 1
113 0.19785716305721113 0 0.8021738538924329
114 0.2208783106844166 0.46225714309073845 1
115 0 1 0.75022814999999998
116 0.43264896150206789 1 0.81375076634557386
117 0.374791875 0.83312128766119486 1
118 0 0.72915434172921567 0.52082680685839422
119 0.25758862433333551 1 0.37534222499999997
120 0 0 0.25
121 0.22089000562634489 0 0.53767874257955828
122 0.21890193241166289 0 0.21890047052636122
123 0 0.48262354769989868 0.23265983080935737
124 0.52955330709238257 0 0.53770034194467331
125 0.49219718763882514 0.367036574432759 0
126 0.5505556528350013 0.63265541955504201 0.30493806376468496
127 1.4081582558189005 0 0.24254676799800692
128 1.1015512434437607 0.21206527974784434 0
129 1.7499169999999999 1 0
130 2 0.75006299999999992 0
131 2 1 0.25
132 0.99401036538229792 0.63676792199224752 1
133 0.75067050430146165 0.71769786903092825 0.71464771158468776
134 1.24958375 1 1
135 1.2504455000000001 0 1
136 1.3860715978416591 0.24993221667186555 1
137 1.0317202752404047 0.31469238410894046 0.6853270709080328
138 1.4426349216014702 1 0.74140038799848562
139 1.6247918750000001 0.75006931305374525 1
140 2 1 0.75
141 2 0.74996849602949978 0.50003148809249964
142 2 0.24999994966813449 0.49999998078418173
143 1.7500117500000001 0 0
144 1.7501484999999999 0 1
145 2 0.5000537978534545 0.74994618626854503
146 1.3747924999999996 1 0.23440908488585499
147 1.5571177737167572 0.81232629338982021 0
148 1.5545253193695066 1 0.17972930755262501
149 1.3104200347998118 0.56041577372755713 0.74814782862252316
150 1.3685266838244452 0.48564116582667954 0.21802764397288932
151 1.5873602781685263 0.78126669962189421 0.50005942609143139
152 1.5838618227448735 0.20899413185535243 0.49987585715718413
153 1.7498120256325995 0.25018792583716926 0
154 1.8148371462917434 0 0.18519382949207305
155 2 0.18752406345187056 0.18753523208397008
156 1.7770110643184227 0.51886547556217666 0
157 1.1389013076817112 0.76226887437066193 0
158 1.1602175406966813 1 0.53828850106094039
159 0.90095306490776128 0.48470516503498373 0.2446998657917499
160 0.57742475390278236 0.27551969863450299 0.27345305390889807
161 0.81036655925196366 0.7630643710333207 0.35054165377955776
162 0.52956259724790877 0.46221182650782827 1
163 0.29250079461431827 0.2842960350422109 0.71570127112180726
164 0.27385619515889037 0.6248453002643185 0.71436194557321087
165 0.62168045737651678 0 0.77560610491729931
166 0.62537124999999993 0.2188435803315899 1
167 0.40196038774740384 1 0.20267603513549107
168 0.17704223351222992 0.82288246470050785 0
169 0.18892018646284411 1 0.18899622733072144
170 0.23373058746113159 0.23679172957531613 0.21078402860060638
171 0.24428427259573549 0.59937304517793366 0.24724219230200442
172 0.42388190576270124 1 0.4887158204143946
173 1.0208555875954755 1 0.81817459887813815
174 1.0669175695053206 0.81733378836053194 1
175 0.8464712840664248 0.80134170756139955 1
176 0.60552202714220704 0.62419153018194229 0.54239960836207701
177 1.606777848712118 0.19973253606683206 1
178 1.4250560553222698 0 0.732249791887851
179 1.12551975 0.19352873225326209 1
180 1.1620342234529084 0 0.53548179044497457
181 0.77419059143108437 0.35536625456813642 0.76865650139332142
182 0.95600842566592681 0 0.52050427577014857
183 2 0.75 1
184 1.8229055680968635 1 0.82294606919028224
185 1.8124074661770861 0.8124421408239394 1
186 1.6847465495324894 0.55699324455967203 0.74450659675858755
187 1.1945125727535346 0.47020737648361044 0.48501348343009743
188 1.4371531545555845 0.81243056656291324 1
189 1.0230031981183827 0.60745624022002409 0.70905352953001077
190 1.3178218537541635 0.74283221838842173 0.24644567916733129
191 1.2298563370114035 0.23209604059822986 0.27403980288191482
192 1.7289412043422971 0.73378563235104455 0.27218740896208421
193 1.6944192651948711 0.39497422853539144 0.28096087015676863
194 1.719021973042385 0.27206088666699435 0.73925099693622187
195 0.51628118103442489 0.26487001488387318 0.53136856951372224
196 0.22693818747394334 0.22584860839480125 0.50499300132112901
197 0.18870598201308805 1 0.81131589108741564
198 0.18140974929389231 0.81855222162009078 1
199 0.52377345173705003 0.22575111801259504 0.77599180569982884
200 0.44512574719134834 0.82031319413422632 0
201 0.43769402753141229 0 0.18763960779463965
202 0.23194582827732274 0.56348972010969589 0.48517047319960538
203 1.404605953982319 0.2885118284317002 0.71332319773860509
204 0.83285106746651061 0.22679389369216291 0.56316489552371896
205 1.746191712341544 0.57096666984982924 0.48834249131610469
206 1.2698479063322867 0.73902081556323673 0.53223169180184582
207 1.0027339377070847 0.7783240018776667 0.51915438810718473
208 1.1247094999999998 1 0.19525173141898322
209 1.0585177272595161 0.22306568484158776 0.45497453797743681
210 1.5766743500280587 0.62019545180903912 0
211 1.5362846212581589 0.2135856104587727 0
212 1.7956396187713533 0.19223457391785517 0.37621602432494938
213 0.2338562054207384 0.80644498148268706 0.52587899633894741
# Generated by tetgen -qfa0.005 beam.poly

View file

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Reads .ele and .node and .face files as written by tetgen.
Converts .ele and .node and .face files, written by tetgen.
Make sure to use add boundary attributes to the smesh file
(5 fifth column in the element section)
@ -54,8 +54,9 @@ Description
NOTE:
- for some reason boundary faces point inwards. I just reverse them
always. Might use some geometric check instead.
- marked faces might not actually be boundary faces of mesh. This is not handled
and you'll have to run without face file (-noFaceFile option)
- marked faces might not actually be boundary faces of mesh.
This is hopefully handled now by first constructing without boundaries
and then reconstructing with boundary faces.
\*---------------------------------------------------------------------------*/
@ -69,20 +70,40 @@ using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Find label of face.
label findFace(const primitiveMesh& mesh, const face& f)
{
const labelList& pFaces = mesh.pointFaces()[f[0]];
forAll(pFaces, i)
{
label faceI = pFaces[i];
if (mesh.faces()[faceI] == f)
{
return faceI;
}
}
FatalErrorIn("findFace(const primitiveMesh&, const face&)")
<< "Cannot find face " << f << " in mesh." << abort(FatalError);
return -1;
}
// Main program:
int main(int argc, char *argv[])
{
argList::validArgs.append("file prefix");
argList::validOptions.insert("noFaceFile", "");
argList::validOptions.insert("overwrite", "");
# include "setRootCase.H"
# include "createTime.H"
bool readFaceFile = !args.options().found("noFaceFile");
bool overwrite = args.options().found("overwrite");
bool readFaceFile = !args.optionFound("noFaceFile");
fileName prefix(args.additionalArgs()[0]);
@ -108,14 +129,14 @@ int main(int argc, char *argv[])
Info<< "Reading .face file for boundary information" << nl << endl;
}
if (!exists(nodeFile) || !exists(eleFile))
if (!isFile(nodeFile) || !isFile(eleFile))
{
FatalErrorIn(args.executable())
<< "Cannot read " << nodeFile << " or " << eleFile
<< exit(FatalError);
}
if (readFaceFile && !exists(faceFile))
if (readFaceFile && !isFile(faceFile))
{
FatalErrorIn(args.executable())
<< "Cannot read " << faceFile << endl
@ -139,7 +160,7 @@ int main(int argc, char *argv[])
{
nodeStream.getLine(line);
}
while((line.size() > 0) && (line[0] == '#'));
while (line.size() && line[0] == '#');
IStringStream nodeLine(line);
@ -172,7 +193,7 @@ int main(int argc, char *argv[])
{
nodeStream.getLine(line);
if ((line.size() > 0) && (line[0] != '#'))
if (line.size() && line[0] != '#')
{
IStringStream nodeLine(line);
@ -216,7 +237,7 @@ int main(int argc, char *argv[])
{
eleStream.getLine(line);
}
while((line.size() > 0) && (line[0] == '#'));
while (line.size() && line[0] == '#');
IStringStream eleLine(line);
@ -260,7 +281,7 @@ int main(int argc, char *argv[])
{
eleStream.getLine(line);
if ((line.size() > 0) && (line[0] != '#'))
if (line.size() && line[0] != '#')
{
IStringStream eleLine(line);
@ -287,6 +308,36 @@ int main(int argc, char *argv[])
}
//
// Construct mesh with default boundary only
//
autoPtr<polyMesh> meshPtr
(
new polyMesh
(
IOobject
(
polyMesh::defaultRegion,
runTime.constant(),
runTime
),
xferCopy(points),
cells,
faceListList(0),
wordList(0), // boundaryPatchNames
wordList(0), // boundaryPatchTypes
"defaultFaces",
polyPatch::typeName,
wordList(0)
)
);
const polyMesh& mesh = meshPtr;
if (readFaceFile)
{
label nPatches = 0;
// List of Foam vertices per boundary face
@ -295,8 +346,6 @@ int main(int argc, char *argv[])
// For each boundary faces the Foam patchID
labelList boundaryPatch;
if (readFaceFile)
{
//
// read boundary faces
//
@ -307,7 +356,7 @@ int main(int argc, char *argv[])
{
faceStream.getLine(line);
}
while((line.size() > 0) && (line[0] == '#'));
while (line.size() && line[0] == '#');
IStringStream faceLine(line);
@ -349,7 +398,7 @@ int main(int argc, char *argv[])
{
faceStream.getLine(line);
if ((line.size() > 0) && (line[0] != '#'))
if (line.size() && line[0] != '#')
{
IStringStream faceLine(line);
@ -366,6 +415,9 @@ int main(int argc, char *argv[])
f[2-i] = nodeToPoint[nodeI];
}
if (findFace(mesh, f) >= mesh.nInternalFaces())
{
boundaryFaces[faceI] = f;
if (nFaceAttr > 0)
@ -377,7 +429,8 @@ int main(int argc, char *argv[])
// Get Foam patchID and update region->patch table.
label patchI = 0;
Map<label>::iterator patchFind = regionToPatch.find(region);
Map<label>::iterator patchFind =
regionToPatch.find(region);
if (patchFind == regionToPatch.end())
{
@ -406,6 +459,13 @@ int main(int argc, char *argv[])
faceI++;
}
}
}
// Trim
boundaryFaces.setSize(faceI);
boundaryPatch.setSize(faceI);
// Print region to patch mapping
Info<< "Regions:" << endl;
@ -421,13 +481,10 @@ int main(int argc, char *argv[])
<< iter() << endl;
}
Info<< endl;
}
// Storage for boundary faces
faceListList patchFaces(nPatches);
wordList patchNames(nPatches);
forAll(patchNames, patchI)
@ -441,8 +498,6 @@ int main(int argc, char *argv[])
wordList patchPhysicalTypes(nPatches, polyPatch::typeName);
if (readFaceFile)
{
// Sort boundaryFaces by patch using boundaryPatch.
List<DynamicList<face> > allPatchFaces(nPatches);
@ -460,18 +515,15 @@ int main(int argc, char *argv[])
Info<< " " << patchNames[patchI] << " : "
<< allPatchFaces[patchI].size() << endl;
patchFaces[patchI].transfer(allPatchFaces[patchI].shrink());
patchFaces[patchI].transfer(allPatchFaces[patchI]);
}
Info<< endl;
}
if (!overwrite)
{
runTime++;
}
polyMesh mesh
meshPtr.reset
(
new polyMesh
(
IOobject
(
@ -479,7 +531,7 @@ int main(int argc, char *argv[])
runTime.constant(),
runTime
),
points,
xferMove(points),
cells,
patchFaces,
patchNames,
@ -487,12 +539,14 @@ int main(int argc, char *argv[])
defaultFacesName,
defaultFacesType,
patchPhysicalTypes
)
);
}
Info<< "Writing mesh to " << runTime.constant() << endl << endl;
mesh.write();
meshPtr().write();
Info<< "End\n" << endl;

View file

@ -32,11 +32,13 @@ Description
patch_YYY_XXX.obj : all face centres of patch YYY
Optional: patch faces (as polygons) : patchFaces_YYY_XXX.obj
Optional: - patch faces (as polygons) : patchFaces_YYY_XXX.obj
- non-manifold edges : patchEdges_YYY_XXX.obj
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "timeSelector.H"
#include "Time.H"
#include "polyMesh.H"
#include "OFstream.H"
@ -50,7 +52,7 @@ using namespace Foam;
void writeOBJ(const point& pt, Ostream& os)
{
os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << endl;
os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
}
// All edges of mesh
@ -74,8 +76,7 @@ void writePoints(const polyMesh& mesh, const fileName& timeName)
{
const edge& e = mesh.edges()[edgeI];
pointStream << "l " << e.start() + 1 << ' ' << e.end() + 1
<< endl;
pointStream << "l " << e.start() + 1 << ' ' << e.end() + 1 << nl;
}
}
@ -276,7 +277,47 @@ void writePatchFaces
{
patchFaceStream << ' ' << f[fp]+1;
}
patchFaceStream << endl;
patchFaceStream << nl;
}
}
}
void writePatchBoundaryEdges
(
const polyMesh& mesh,
const fileName& timeName
)
{
const polyBoundaryMesh& patches = mesh.boundaryMesh();
forAll(patches, patchI)
{
const polyPatch& pp = patches[patchI];
fileName edgeFile
(
mesh.time().path()
/ "patchEdges_" + pp.name() + '_' + timeName + ".obj"
);
Info << "Writing patch edges to " << edgeFile << endl;
OFstream patchEdgeStream(edgeFile);
forAll(pp.localPoints(), pointI)
{
writeOBJ(pp.localPoints()[pointI], patchEdgeStream);
}
for (label edgeI = pp.nInternalEdges(); edgeI < pp.nEdges(); edgeI++)
{
if (pp.edgeFaces()[edgeI].size() == 1)
{
const edge& e = pp.edges()[edgeI];
patchEdgeStream<< "l " << e[0]+1 << ' ' << e[1]+1 << nl;
}
}
}
}
@ -336,23 +377,27 @@ void writePointCells
int main(int argc, char *argv[])
{
timeSelector::addOptions();
argList::validOptions.insert("patchFaces", "");
argList::validOptions.insert("patchEdges", "");
argList::validOptions.insert("cell", "cellI");
argList::validOptions.insert("face", "faceI");
argList::validOptions.insert("point", "pointI");
argList::validOptions.insert("cellSet", "setName");
argList::validOptions.insert("faceSet", "setName");
# include "addRegionOption.H"
# include "addTimeOptions.H"
# include "setRootCase.H"
# include "createTime.H"
runTime.functionObjects().off();
bool patchFaces = args.options().found("patchFaces");
bool doCell = args.options().found("cell");
bool doPoint = args.options().found("point");
bool doFace = args.options().found("face");
bool doCellSet = args.options().found("cellSet");
bool doFaceSet = args.options().found("faceSet");
bool patchFaces = args.optionFound("patchFaces");
bool patchEdges = args.optionFound("patchEdges");
bool doCell = args.optionFound("cell");
bool doPoint = args.optionFound("point");
bool doFace = args.optionFound("face");
bool doCellSet = args.optionFound("cellSet");
bool doFaceSet = args.optionFound("faceSet");
Info<< "Writing mesh objects as .obj files such that the object"
@ -360,50 +405,43 @@ int main(int argc, char *argv[])
<< "(for points, faces, cells) is consistent with"
<< " Foam numbering (starting from 0)." << endl << endl;
// Get times list
instantList Times = runTime.times();
instantList timeDirs = timeSelector::select0(runTime, args);
# include "checkTimeOptions.H"
# include "createNamedPolyMesh.H"
runTime.setTime(Times[startTime], startTime);
# include "createPolyMesh.H"
bool firstCheck = true;
for (label i=startTime; i<endTime; i++)
forAll(timeDirs, timeI)
{
runTime.setTime(Times[i], i);
runTime.setTime(timeDirs[timeI], timeI);
Info<< "Time = " << runTime.timeName() << endl;
polyMesh::readUpdateState state = mesh.readUpdate();
if (firstCheck || state != polyMesh::UNCHANGED)
if (!timeI || state != polyMesh::UNCHANGED)
{
if (patchFaces)
{
writePatchFaces(mesh, runTime.timeName());
}
else if (doCell)
if (patchEdges)
{
label cellI =
readLabel(IStringStream(args.options()["cell"])());
writePatchBoundaryEdges(mesh, runTime.timeName());
}
if (doCell)
{
label cellI = args.optionRead<label>("cell");
writePoints(mesh, cellI, runTime.timeName());
}
else if (doPoint)
if (doPoint)
{
label pointI =
readLabel(IStringStream(args.options()["point"])());
label pointI = args.optionRead<label>("point");
writePointCells(mesh, pointI, runTime.timeName());
}
else if (doFace)
if (doFace)
{
label faceI =
readLabel(IStringStream(args.options()["face"])());
label faceI = args.optionRead<label>("face");
fileName fName
(
@ -423,9 +461,9 @@ int main(int argc, char *argv[])
meshTools::writeOBJ(str, faceList(1, f), mesh.points());
}
else if (doCellSet)
if (doCellSet)
{
word setName(args.options()["cellSet"]);
word setName(args.option("cellSet"));
cellSet cells(mesh, setName);
@ -435,9 +473,9 @@ int main(int argc, char *argv[])
writePoints(mesh, cells.toc(), runTime.timeName());
}
else if (doFaceSet)
if (doFaceSet)
{
word setName(args.options()["faceSet"]);
word setName(args.option("faceSet"));
faceSet faces(mesh, setName);
@ -466,7 +504,16 @@ int main(int argc, char *argv[])
faces.toc()
);
}
else
else if
(
!patchFaces
&& !patchEdges
&& !doCell
&& !doPoint
&& !doFace
&& !doCellSet
&& !doFaceSet
)
{
// points & edges
writePoints(mesh, runTime.timeName());
@ -486,9 +533,7 @@ int main(int argc, char *argv[])
Info << "No mesh." << endl;
}
firstCheck = false;
Info << endl << endl;
Info << nl << endl;
}

View file

@ -6,11 +6,10 @@ $(curvedEdges)/polyLine.C
$(curvedEdges)/polyLineEdge.C
$(curvedEdges)/arcEdge.C
$(curvedEdges)/ellipseEdge.C
$(curvedEdges)/spline.C
$(curvedEdges)/BSpline.C
$(curvedEdges)/simpleSplineEdge.C
$(curvedEdges)/polySplineEdge.C
$(curvedEdges)/lineDivide.C
$(curvedEdges)/CatmullRomSpline.C
$(curvedEdges)/splineEdge.C
blockMesh.C
blockDescriptor.C
@ -27,6 +26,6 @@ blockPoints.C
blockCells.C
blockBoundary.C
genBlockMesh.C
blockMeshApp.C
EXE = $(FOAM_APPBIN)/blockMesh

View file

@ -1,3 +0,0 @@
argList::noParallel();
argList::validOptions.insert("blockTopology", "");
# include "addRegionOption.H"

View file

@ -27,7 +27,6 @@ Description
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "block.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -28,18 +28,12 @@ Description
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "block.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void block::blockBoundary()
void Foam::block::blockBoundary()
{
label ni = blockDef_.n().x();
label nj = blockDef_.n().y();
@ -212,9 +206,4 @@ void block::blockBoundary()
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -28,18 +28,11 @@ Description
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "block.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void block::blockCells()
void Foam::block::blockCells()
{
label ni = blockDef_.n().x();
label nj = blockDef_.n().y();
@ -69,9 +62,4 @@ void block::blockCells()
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -32,21 +32,16 @@ Description
#include "blockMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from IOdictionary
blockMesh::blockMesh(IOdictionary& meshDescription)
Foam::blockMesh::blockMesh(IOdictionary& meshDescription)
:
topologyPtr_(createTopology(meshDescription)),
scale_(readScalar(meshDescription.lookup("convertToMeters"))),
blockOffsets_(createBlockOffsets()),
mergeList_(createMergeList()),
points_(createPoints()),
points_(createPoints(meshDescription)),
cells_(createCells()),
patches_(createPatches())
{}
@ -54,7 +49,7 @@ blockMesh::blockMesh(IOdictionary& meshDescription)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
blockMesh::~blockMesh()
Foam::blockMesh::~blockMesh()
{
delete topologyPtr_;
}
@ -62,7 +57,7 @@ blockMesh::~blockMesh()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const polyMesh& blockMesh::topology() const
const Foam::polyMesh& Foam::blockMesh::topology() const
{
if (!topologyPtr_)
{
@ -75,13 +70,7 @@ const polyMesh& blockMesh::topology() const
}
const curvedEdgeList& blockMesh::edges() const
{
return edges_;
}
wordList blockMesh::patchNames() const
Foam::wordList Foam::blockMesh::patchNames() const
{
const polyPatchList& patchTopologies = topology().boundaryMesh();
wordList names(patchTopologies.size());
@ -95,7 +84,7 @@ wordList blockMesh::patchNames() const
}
wordList blockMesh::patchTypes() const
Foam::wordList Foam::blockMesh::patchTypes() const
{
const polyPatchList& patchTopologies = topology().boundaryMesh();
wordList types(patchTopologies.size());
@ -109,7 +98,7 @@ wordList blockMesh::patchTypes() const
}
wordList blockMesh::patchPhysicalTypes() const
Foam::wordList Foam::blockMesh::patchPhysicalTypes() const
{
const polyPatchList& patchTopologies = topology().boundaryMesh();
wordList physicalTypes(patchTopologies.size());
@ -123,13 +112,13 @@ wordList blockMesh::patchPhysicalTypes() const
}
label blockMesh::numZonedBlocks() const
Foam::label Foam::blockMesh::numZonedBlocks() const
{
label num = 0;
forAll(*this, blockI)
{
if (operator[](blockI).blockDef().zoneName().size() > 0)
if (operator[](blockI).blockDef().zoneName().size())
{
num++;
}
@ -139,7 +128,7 @@ label blockMesh::numZonedBlocks() const
}
void blockMesh::writeTopology(Ostream& os) const
void Foam::blockMesh::writeTopology(Ostream& os) const
{
const pointField& pts = topology().points();
@ -160,9 +149,4 @@ void blockMesh::writeTopology(Ostream& os) const
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -62,8 +62,6 @@ class blockMesh
polyMesh* topologyPtr_;
scalar scale_;
labelList blockOffsets_;
labelList mergeList_;
@ -94,7 +92,7 @@ class blockMesh
labelList createBlockOffsets();
labelList createMergeList();
pointField createPoints();
pointField createPoints(const dictionary&);
cellShapeList createCells();
faceList createPatchFaces(const polyPatch& patchTopologyFaces);
@ -123,7 +121,10 @@ public:
const polyMesh& topology() const;
const curvedEdgeList& edges() const;
const curvedEdgeList& edges() const
{
return edges_;
}
const pointField& points() const
{

View file

@ -22,9 +22,29 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
blockMesh
Description
A multi-block mesh generator.
Uses the block mesh description found in
@a constant/polyMesh/blockMeshDict
(or @a constant/\<region\>/polyMesh/blockMeshDict).
Usage
- blockMesh [OPTION]
@param -blockTopology \n
Write the topology as a set of edges in OBJ format.
@param -region \<name\> \n
Specify an alternative mesh region.
@param -dict \<dictionary\> \n
Specify an alternative dictionary for the block mesh description.
\*---------------------------------------------------------------------------*/
#include "Time.H"
@ -53,58 +73,88 @@ using namespace Foam;
int main(int argc, char *argv[])
{
argList::noParallel();
# include "addOptions.H"
argList::validOptions.insert("blockTopology", "");
argList::validOptions.insert("dict", "dictionary");
# include "addRegionOption.H"
# include "setRootCase.H"
# include "createTime.H"
# include "checkOptions.H"
const word dictName("blockMeshDict");
word regionName;
fileName polyMeshDir;
if (args.options().found("region"))
if (args.optionFound("region"))
{
regionName = args.options()["region"];
// constant/<region>/polyMesh/blockMeshDict
regionName = args.option("region");
polyMeshDir = regionName/polyMesh::meshSubDir;
Info<< nl << "Generating mesh for region " << regionName << endl;
}
else
{
// constant/polyMesh/blockMeshDict
regionName = polyMesh::defaultRegion;
polyMeshDir = polyMesh::meshSubDir;
}
autoPtr<IOobject> meshDictIoPtr;
Info<< nl << "Reading block mesh description dictionary" << endl;
if (args.optionFound("dict"))
{
fileName dictPath(args.option("dict"));
IOobject meshDescriptionIOobject
meshDictIoPtr.set
(
"blockMeshDict",
new IOobject
(
(
isDir(dictPath)
? dictPath/dictName
: dictPath
),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
}
else
{
meshDictIoPtr.set
(
new IOobject
(
dictName,
runTime.constant(),
polyMeshDir,
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
}
if (!meshDescriptionIOobject.headerOk())
if (!meshDictIoPtr->headerOk())
{
FatalErrorIn(args.executable())
<< "Cannot open mesh description file " << nl
<< runTime.constant()/polyMeshDir/"blockMeshDict" << nl
<< "Cannot open mesh description file\n "
<< meshDictIoPtr->objectPath()
<< nl
<< exit(FatalError);
}
IOdictionary meshDescription(meshDescriptionIOobject);
Info<< nl << "Creating block mesh from\n "
<< meshDictIoPtr->objectPath() << nl << endl;
Info<< nl << "Creating block mesh" << endl;
blockMesh blocks(meshDescription);
IOdictionary meshDict(meshDictIoPtr());
blockMesh blocks(meshDict);
if (writeTopo)
if (args.optionFound("blockTopology"))
{
// Write mesh as edges.
{
@ -159,7 +209,7 @@ int main(int argc, char *argv[])
(
runTime,
runTime.constant(),
polyMeshDir, //polyMesh::meshSubDir
polyMeshDir,
patchNames,
patchTypes,
defaultFacesName,
@ -187,13 +237,11 @@ int main(int argc, char *argv[])
// Read in a list of dictionaries for the merge patch pairs
if (meshDescription.found("mergePatchPairs"))
if (meshDict.found("mergePatchPairs"))
{
Info<< nl << "Creating merge patch pairs" << nl << endl;
List<Pair<word> > mergePatchPairs
(
meshDescription.lookup("mergePatchPairs")
meshDict.lookup("mergePatchPairs")
);
if (mergePatchPairs.size() > 0)
@ -354,7 +402,7 @@ int main(int argc, char *argv[])
const labelListList& blockCells = b.cells();
const word& zoneName = b.blockDef().zoneName();
if (zoneName.size() > 0)
if (zoneName.size())
{
HashTable<label>::const_iterator iter = zoneMap.find(zoneName);
@ -421,8 +469,7 @@ int main(int argc, char *argv[])
IOstream::defaultPrecision(10);
Info << nl << "Writing polyMesh" << endl;
mesh.removeFiles(mesh.instance());
mesh.removeFiles();
if (!mesh.write())
{
FatalErrorIn(args.executable())
@ -430,7 +477,8 @@ int main(int argc, char *argv[])
<< exit(FatalError);
}
Info<< nl << "end" << endl;
Info<< nl << "End" << endl;
return 0;
}

View file

@ -28,7 +28,6 @@ Description
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "block.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //

View file

@ -28,16 +28,10 @@ Description
#include "blockMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Check the blockMesh topology
void blockMesh::checkBlockMesh(const polyMesh& bm)
void Foam::blockMesh::checkBlockMesh(const polyMesh& bm)
{
Info<< nl << "Check block mesh topology" << endl;
@ -148,9 +142,4 @@ void blockMesh::checkBlockMesh(const polyMesh& bm)
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -1 +0,0 @@
bool writeTopo = args.options().found("blockTopology");

View file

@ -27,17 +27,11 @@ Description
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "blockMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
labelList blockMesh::createBlockOffsets()
Foam::labelList Foam::blockMesh::createBlockOffsets()
{
Info<< nl << "Creating block offsets" << endl;
@ -63,10 +57,4 @@ labelList blockMesh::createBlockOffsets()
return BlockOffsets;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -29,14 +29,9 @@ License
#include "blockMesh.H"
#include "cellModeller.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
cellShapeList blockMesh::createCells()
Foam::cellShapeList Foam::blockMesh::createCells()
{
Info<< nl << "Creating cells" << endl;
@ -76,10 +71,4 @@ cellShapeList blockMesh::createCells()
return cells;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -26,14 +26,9 @@ License
#include "blockMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
labelList blockMesh::createMergeList()
Foam::labelList Foam::blockMesh::createMergeList()
{
Info<< nl << "Creating merge list " << flush;
@ -98,7 +93,7 @@ labelList blockMesh::createMergeList()
// the size of the block.
boundBox bb(blockCells[blockPlabel].points(blockFaces, blockPoints));
const scalar mergeSqrDist = SMALL*magSqr(bb.max() - bb.min());
const scalar mergeSqrDist = SMALL*magSqr(bb.span());
// This is an N^2 algorithm
@ -561,9 +556,4 @@ labelList blockMesh::createMergeList()
return MergeList;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -29,14 +29,9 @@ Description
#include "blockMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
faceList blockMesh::createPatchFaces
Foam::faceList Foam::blockMesh::createPatchFaces
(
const polyPatch& patchTopologyFaces
)
@ -157,7 +152,7 @@ faceList blockMesh::createPatchFaces
}
faceListList blockMesh::createPatches()
Foam::faceListList Foam::blockMesh::createPatches()
{
Info<< "\nCreating patches\n";
@ -173,9 +168,4 @@ faceListList blockMesh::createPatches()
return patches;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -28,24 +28,26 @@ Description
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "blockMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
pointField blockMesh::createPoints()
Foam::pointField Foam::blockMesh::createPoints(const dictionary& dict)
{
Info<< nl << "Creating points" << endl;
blockMesh& blocks = *this;
scalar scaleFactor = 1.0;
// optional 'convertToMeters' (or 'scale'?)
if (!dict.readIfPresent("convertToMeters", scaleFactor))
{
dict.readIfPresent("scale", scaleFactor);
}
Info<< nl << "Creating points with scale " << scaleFactor << endl;
pointField points(nPoints_);
blockMesh& blocks = *this;
forAll(blocks, blockLabel)
{
const pointField& blockPoints = blocks[blockLabel].points();
@ -59,17 +61,11 @@ pointField blockMesh::createPoints()
blockPointLabel
+ blockOffsets_[blockLabel]
]
] = scale_*blockPoints[blockPointLabel];
] = scaleFactor * blockPoints[blockPointLabel];
}
}
return points;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -40,9 +40,9 @@ bool Foam::blockMesh::blockLabelsOK
{
bool ok = true;
for (int i=0; i<blockShape.size(); i++)
forAll(blockShape, blockI)
{
if (blockShape[i] < 0)
if (blockShape[blockI] < 0)
{
ok = false;
@ -52,10 +52,10 @@ bool Foam::blockMesh::blockLabelsOK
"(const label blockLabel, const pointField& points, "
"const cellShape& blockShape)"
) << "block " << blockLabel
<< " point label " << blockShape[i]
<< " point label " << blockShape[blockI]
<< " less than zero" << endl;
}
else if (blockShape[i] >= points.size())
else if (blockShape[blockI] >= points.size())
{
ok = false;
@ -65,7 +65,7 @@ bool Foam::blockMesh::blockLabelsOK
"(const label blockLabel, const pointField& points, "
"const cellShape& blockShape)"
) << "block " << blockLabel
<< " point label " << blockShape[i]
<< " point label " << blockShape[blockI]
<< " larger than " << points.size() - 1
<< " the largest defined point label" << endl;
}
@ -84,38 +84,34 @@ bool Foam::blockMesh::patchLabelsOK
{
bool ok = true;
for (label facei=0; facei<patchFaces.size(); facei++)
forAll(patchFaces, faceI)
{
const labelList& labels = patchFaces[facei];
const labelList& f = patchFaces[faceI];
for (int i=0; i<labels.size(); i++)
forAll(f, fp)
{
if (labels[i] < 0)
if (f[fp] < 0)
{
ok = false;
WarningIn
(
"bool Foam::blockMesh::patchLabelsOK"
"(const label patchLabel, const pointField& points, "
"const faceList& patchFaces)"
"bool Foam::blockMesh::patchLabelsOK(...)"
) << "patch " << patchLabel
<< " face " << facei
<< " point label " << labels[i]
<< " face " << faceI
<< " point label " << f[fp]
<< " less than zero" << endl;
}
else if (labels[i] >= points.size())
else if (f[fp] >= points.size())
{
ok = false;
WarningIn
(
"bool Foam::blockMesh::patchLabelsOK"
"(const label patchLabel, const pointField& points, "
"const faceList& patchFaces)"
"bool Foam::blockMesh::patchLabelsOK(...)"
) << "patch " << patchLabel
<< " face " << facei
<< " point label " << labels[i]
<< " face " << faceI
<< " point label " << f[fp]
<< " larger than " << points.size() - 1
<< " the largest defined point label" << endl;
}
@ -137,23 +133,13 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription)
word defaultPatchName = "defaultFaces";
word defaultPatchType = emptyPolyPatch::typeName;
// get names and types for the unassigned patch faces
if (meshDescription.found("defaultPatch"))
{
const dictionary& defaultPatch =
meshDescription.subDict("defaultPatch");
// get names/types for the unassigned patch faces
// this is a bit heavy handed (and ugly), but there is currently
// no easy way to rename polyMesh patches subsequently
if (defaultPatch.found("name"))
if (const dictionary* dictPtr = meshDescription.subDictPtr("defaultPatch"))
{
defaultPatch.lookup("name") >> defaultPatchName;
}
if (defaultPatch.found("type"))
{
defaultPatch.lookup("type") >> defaultPatchType;
}
dictPtr->readIfPresent("name", defaultPatchName);
dictPtr->readIfPresent("type", defaultPatchType);
}
Info<< nl << "Creating blockCorners" << endl;
@ -456,4 +442,3 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription)
// ************************************************************************* //

View file

@ -22,137 +22,120 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
BSpline : cubic spline going through all the knots
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "BSpline.H"
#include "simpleMatrix.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
pointField BSpline::findKnots
(
const pointField& allknots,
const vector& fstend,
const vector& sndend
)
{
label newnKnots(allknots.size() + 2);
label NKnots(allknots.size());
pointField newknots(newnKnots);
// set up 1/6 and 2/3 which are the matrix elements throughout most
// of the matrix
register scalar oneSixth = 1.0/6.0;
register scalar twoThird = 2.0/3.0;
simpleMatrix<vector> M(newnKnots);
// set up the matrix
M[0][0] = -0.5*scalar(NKnots - 1);
M[0][2] = 0.5*scalar(NKnots - 1);
for (register label i=1; i<newnKnots-1; i++)
{
M[i][i-1] = oneSixth;
M[i][i] = twoThird;
M[i][i+1] = oneSixth;
}
M[newnKnots - 1][newnKnots - 3] = -0.5*scalar(NKnots - 1);
M[newnKnots - 1][newnKnots - 1] = 0.5*scalar(NKnots - 1);
// set up the vector
for (label i=1; i<=NKnots; i++)
{
M.source()[i] = allknots[i-1];
}
// set the gradients at the two ends
if (mag(fstend)<1e-8)
{
// set to the default : forward differences on the end knots
M.source()[0] = allknots[1] - allknots[0];
M.source()[0] /= mag(M.source()[0]);
M.source()[NKnots+1] = M.source()[NKnots-1] - M.source()[NKnots];
M.source()[NKnots+1] /= mag(M.source()[NKnots+1]);
}
else
{
// set to the gradient vectors provided
M.source()[0] = fstend/mag(fstend);
M.source()[NKnots+1] = sndend/mag(sndend);
}
// invert the equation to find the control knots
newknots = M.solve();
return newknots;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
BSpline::BSpline(const pointField& Knots)
:
spline(findKnots(Knots))
{}
// Construct from components
BSpline::BSpline
Foam::BSpline::BSpline
(
const pointField& Knots,
const vector& fstend,
const vector& sndend
const pointField& knots,
const bool closed
)
:
spline(findKnots(Knots, fstend, sndend))
polyLine(knots, closed)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
//- Return the real position of a point on the curve given by
// the parameter 0 <= lambda <= 1
vector BSpline::realPosition(scalar mu)
Foam::point Foam::BSpline::position(const scalar mu) const
{
return spline::position(mu);
// endpoints
if (mu < SMALL)
{
return points_[0];
}
else if (mu > 1 - SMALL)
{
return points_[points_.size()-1];
}
scalar lambda = mu;
label segment = localParameter(lambda);
return position(segment, lambda);
}
//- Return the position of a point on the curve given by
// the parameter 0 <= lambda <= 1
vector BSpline::position(const scalar mu) const
Foam::point Foam::BSpline::position
(
const label segment,
const scalar mu
) const
{
return spline::position((1.0/(nKnots() - 1))*(1.0 + mu*(nKnots() - 3)));
// out-of-bounds
if (segment < 0)
{
return points_[0];
}
else if (segment > nSegments())
{
return points_[points_.size()-1];
}
const point& p0 = points()[segment];
const point& p1 = points()[segment+1];
// special cases - no calculation needed
if (mu <= 0.0)
{
return p0;
}
else if (mu >= 1.0)
{
return p1;
}
// determine the end points
point e0;
point e1;
if (segment == 0)
{
// end: simple reflection
e0 = 2*p0 - p1;
}
else
{
e0 = points()[segment-1];
}
if (segment+1 == nSegments())
{
// end: simple reflection
e1 = 2*p1 - p0;
}
else
{
e1 = points()[segment+2];
}
return 1.0/6.0 *
(
( e0 + 4*p0 + p1 )
+ mu *
(
( -3*e0 + 3*p1 )
+ mu *
(
( 3*e0 - 6*p0 + 3*p1 )
+ mu *
( -e0 + 3*p0 - 3*p1 + e1 )
)
)
);
}
//- Return the length of the curve
scalar BSpline::length() const
Foam::scalar Foam::BSpline::length() const
{
notImplemented("BSpline::length() const");
return 1.0;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -26,7 +26,33 @@ Class
Foam::BSpline
Description
BSpline : cubic spline going through all the knots
An implementation of B-splines.
In this implementation, the end tangents are created automatically
by reflection.
In matrix form, the @e local interpolation on the interval t=[0..1] is
described as follows:
@verbatim
P(t) = 1/6 * [ t^3 t^2 t 1 ] * [ -1 3 -3 1 ] * [ P-1 ]
[ 3 -6 3 0 ] [ P0 ]
[ -3 0 3 0 ] [ P1 ]
[ 1 4 1 0 ] [ P2 ]
@endverbatim
Where P-1 and P2 represent the neighbouring points or the extrapolated
end points. Simple reflection is used to automatically create the end
points.
The spline is discretized based on the chord length of the individual
segments. In rare cases (sections with very high curvatures), the
resulting distribution may be sub-optimal.
SeeAlso
CatmullRomSpline
ToDo
A future implementation could also handle closed splines.
SourceFiles
BSpline.C
@ -36,7 +62,7 @@ SourceFiles
#ifndef BSpline_H
#define BSpline_H
#include "spline.H"
#include "polyLine.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -49,45 +75,38 @@ namespace Foam
class BSpline
:
public spline
public polyLine
{
// Private member functions
// Private Member Functions
scalar remap(const scalar&);
//- Disallow default bitwise copy construct
BSpline(const BSpline&);
pointField findKnots
(
const pointField&,
const vector& fstend = vector::zero,
const vector& sndend = vector::zero
);
//- Disallow default bitwise assignment
void operator=(const BSpline&);
public:
// Constructors
//- Construct from components
BSpline(const pointField& knots);
//- Construct from components
BSpline
(
const pointField& knots,
const vector& fstend,
const vector& sndend
const bool notImplementedClosed = false
);
// Member Functions
//- Return the real position of a point on the curve given by
// the parameter 0 <= lambda <= 1
vector realPosition(scalar lambda);
//- Return the point position corresponding to the curve parameter
// 0 <= lambda <= 1
point position(const scalar lambda) const;
//- Return the position of a point on the curve given by
// the parameter 0 <= lambda <= 1
vector position(const scalar lambda) const;
//- Return the point position corresponding to the local parameter
// 0 <= lambda <= 1 on the given segment
point position(const label segment, const scalar lambda) const;
//- Return the length of the curve
scalar length() const;

View file

@ -0,0 +1,141 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "CatmullRomSpline.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::CatmullRomSpline::CatmullRomSpline
(
const pointField& knots,
const bool closed
)
:
polyLine(knots, closed)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::point Foam::CatmullRomSpline::position(const scalar mu) const
{
// endpoints
if (mu < SMALL)
{
return points()[0];
}
else if (mu > 1 - SMALL)
{
return points()[points().size()-1];
}
scalar lambda = mu;
label segment = localParameter(lambda);
return position(segment, lambda);
}
Foam::point Foam::CatmullRomSpline::position
(
const label segment,
const scalar mu
) const
{
// out-of-bounds
if (segment < 0)
{
return points()[0];
}
else if (segment > nSegments())
{
return points()[points().size()-1];
}
const point& p0 = points()[segment];
const point& p1 = points()[segment+1];
// special cases - no calculation needed
if (mu <= 0.0)
{
return p0;
}
else if (mu >= 1.0)
{
return p1;
}
// determine the end points
point e0;
point e1;
if (segment == 0)
{
// end: simple reflection
e0 = 2*p0 - p1;
}
else
{
e0 = points()[segment-1];
}
if (segment+1 == nSegments())
{
// end: simple reflection
e1 = 2*p1 - p0;
}
else
{
e1 = points()[segment+2];
}
return 0.5 *
(
( 2*p0 )
+ mu *
(
( -e0 + p1 )
+ mu *
(
( 2*e0 - 5*p0 + 4*p1 - e1 )
+ mu *
( -e0 + 3*p0 - 3*p1 + e1 )
)
)
);
}
Foam::scalar Foam::CatmullRomSpline::length() const
{
notImplemented("CatmullRomSpline::length() const");
return 1.0;
}
// ************************************************************************* //

View file

@ -0,0 +1,126 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::CatmullRomSpline
Description
An implementation of Catmull-Rom splines
(sometimes known as Overhauser splines).
In this implementation, the end tangents are created automatically
by reflection.
In matrix form, the @e local interpolation on the interval t=[0..1] is
described as follows:
@verbatim
P(t) = 1/2 * [ t^3 t^2 t 1 ] * [ -1 3 -3 1 ] * [ P-1 ]
[ 2 -5 4 -1 ] [ P0 ]
[ -1 0 1 0 ] [ P1 ]
[ 0 2 0 0 ] [ P2 ]
@endverbatim
Where P-1 and P2 represent the neighbouring points or the extrapolated
end points. Simple reflection is used to automatically create the end
points.
The spline is discretized based on the chord length of the individual
segments. In rare cases (sections with very high curvatures), the
resulting distribution may be sub-optimal.
SeeAlso
http://www.algorithmist.net/catmullrom.html provides a nice
introduction
ToDo
A future implementation could also handle closed splines.
SourceFiles
CatmullRomSpline.C
\*---------------------------------------------------------------------------*/
#ifndef CatmullRomSpline_H
#define CatmullRomSpline_H
#include "polyLine.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class CatmullRomSpline Declaration
\*---------------------------------------------------------------------------*/
class CatmullRomSpline
:
public polyLine
{
// Private Member Functions
//- Disallow default bitwise copy construct
CatmullRomSpline(const CatmullRomSpline&);
//- Disallow default bitwise assignment
void operator=(const CatmullRomSpline&);
public:
// Constructors
//- Construct from components
CatmullRomSpline
(
const pointField& knots,
const bool notImplementedClosed = false
);
// Member Functions
//- Return the point position corresponding to the curve parameter
// 0 <= lambda <= 1
point position(const scalar lambda) const;
//- Return the point position corresponding to the local parameter
// 0 <= lambda <= 1 on the given segment
point position(const label segment, const scalar lambda) const;
//- Return the length of the curve - not implemented
scalar length() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -22,26 +22,18 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
arcEdge class : defines the arcEdge of a circle in terms of 3 points on its
circumference
\*---------------------------------------------------------------------------*/
#include "arcEdge.H"
#include "mathematicalConstants.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(arcEdge, 0);
// Add the curvedEdge constructor functions to the hash tables
curvedEdge::addIstreamConstructorToTable<arcEdge>
addArcEdgeIstreamConstructorToTable_;
addToRunTimeSelectionTable(curvedEdge, arcEdge, Istream);
}
@ -69,7 +61,7 @@ Foam::cylindricalCS Foam::arcEdge::calcAngle()
scalar fact = 0.5*(bsqr - adotb)/denom;
vector centre = 0.5*a + fact*((a ^ b) ^ a);
point centre = 0.5*a + fact*((a ^ b) ^ a);
centre += p1_;
@ -79,19 +71,25 @@ Foam::cylindricalCS Foam::arcEdge::calcAngle()
vector r3(p3_ - centre);
// find angles
scalar tmp = (r3&r1)/(mag(r3)*mag(r1));
angle_ = acos(tmp)*180.0/mathematicalConstant::pi;
angle_ = (acos((r3 & r1)/(mag(r3) * mag(r1))))
* 180.0/mathematicalConstant::pi;
// check if the vectors define an exterior or an interior arcEdge
if (((r1 ^ r2)&(r1 ^ r3)) < 0.0) angle_ = 360 - angle_;
if (((r1 ^ r2) & (r1 ^ r3)) < 0.0)
{
angle_ = 360.0 - angle_;
}
vector tempAxis(0.0,0.0,0.0);
vector tempAxis;
if (angle_ <= 180.0)
{
tempAxis = r1 ^ r3;
if (mag(tempAxis)/(mag(r1)*mag(r3)) < 0.001) tempAxis = r1 ^ r2;
if (mag(tempAxis)/(mag(r1)*mag(r3)) < 0.001)
{
tempAxis = r1 ^ r2;
}
}
else
{
@ -101,30 +99,28 @@ Foam::cylindricalCS Foam::arcEdge::calcAngle()
radius_ = mag(r3);
// set up and return the local coordinate system
return cylindricalCS("tmpCS", centre, tempAxis, r1);
return cylindricalCS("arcEdgeCS", centre, tempAxis, r1);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::arcEdge::arcEdge
(
const pointField& points,
const label start,
const label end,
const vector& P2
const point& pMid
)
:
curvedEdge(points, start, end),
p1_(points_[start_]),
p2_(P2),
p2_(pMid),
p3_(points_[end_]),
cs_(calcAngle())
{}
// Construct from Istream
Foam::arcEdge::arcEdge(const pointField& points, Istream& is)
:
curvedEdge(points, is),
@ -137,7 +133,7 @@ Foam::arcEdge::arcEdge(const pointField& points, Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::vector Foam::arcEdge::position(const scalar lambda) const
Foam::point Foam::arcEdge::position(const scalar lambda) const
{
if (lambda < 0 || lambda > 1)
{
@ -150,7 +146,7 @@ Foam::vector Foam::arcEdge::position(const scalar lambda) const
{
return p1_;
}
else if (lambda > 1-SMALL)
else if (lambda > 1 - SMALL)
{
return p3_;
}
@ -161,13 +157,10 @@ Foam::vector Foam::arcEdge::position(const scalar lambda) const
}
//- Return the length of the curve
Foam::scalar Foam::arcEdge::length() const
{
return angle_*radius_*mathematicalConstant::pi/180.0;
return (angle_ * radius_) * mathematicalConstant::pi/180.0;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// ************************************************************************* //

View file

@ -26,8 +26,7 @@ Class
Foam::arcEdge
Description
arcEdge class : defines the arcEdge of a circle in terms of 3 points on its
circumference
Defines the arcEdge of a circle in terms of 3 points on its circumference
SourceFiles
arcEdge.C
@ -55,13 +54,22 @@ class arcEdge
{
// Private data
vector p1_, p2_, p3_;
point p1_, p2_, p3_;
cylindricalCS cs_;
scalar angle_;
scalar radius_;
cylindricalCS cs_;
// Private Member Functions
//- Calculate the coordinate system, angle and radius
cylindricalCS calcAngle();
//- Disallow default bitwise copy construct
arcEdge(const arcEdge&);
//- Disallow default bitwise assignment
void operator=(const arcEdge&);
public:
//- Runtime type information
@ -75,7 +83,7 @@ public:
(
const pointField& points,
const label start, const label end,
const vector&
const point& pMid
);
//- Construct from Istream setting pointsList
@ -89,9 +97,9 @@ public:
// Member Functions
//- Return the position of a point on the curve given by
// the parameter 0 <= lambda <= 1
vector position(const scalar) const;
//- Return the point position corresponding to the curve parameter
// 0 <= lambda <= 1
point position(const scalar) const;
//- Return the length of the curve
scalar length() const;

View file

@ -22,51 +22,24 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
library functions that will define a curvedEdge in space
parameterised for 0<lambda<1 from the beginning
point to the end point.
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "curvedEdge.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(curvedEdge, 0);
// Define the constructor function hash tables
HashTable<curvedEdge::IstreamConstructorPtr_>*
curvedEdge::IstreamConstructorTablePtr_;
// Hash table Constructor called from the table add functions.
void curvedEdge::constructTables()
{
static bool constructed = false;
if (!constructed)
{
curvedEdge::IstreamConstructorTablePtr_
= new HashTable<curvedEdge::IstreamConstructorPtr_>;
constructed = true;
}
defineTypeNameAndDebug(curvedEdge, 0);
defineRunTimeSelectionTable(curvedEdge, Istream);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
curvedEdge::curvedEdge
Foam::curvedEdge::curvedEdge
(
const pointField& points,
const label start,
@ -79,8 +52,7 @@ curvedEdge::curvedEdge
{}
// Construct from Istream
curvedEdge::curvedEdge(const pointField& points, Istream& is)
Foam::curvedEdge::curvedEdge(const pointField& points, Istream& is)
:
points_(points),
start_(readLabel(is)),
@ -88,8 +60,7 @@ curvedEdge::curvedEdge(const pointField& points, Istream& is)
{}
// Copy construct
curvedEdge::curvedEdge(const curvedEdge& c)
Foam::curvedEdge::curvedEdge(const curvedEdge& c)
:
points_(c.points_),
start_(c.start_),
@ -97,16 +68,18 @@ curvedEdge::curvedEdge(const curvedEdge& c)
{}
//- Clone function
autoPtr<curvedEdge> curvedEdge::clone() const
Foam::autoPtr<Foam::curvedEdge> Foam::curvedEdge::clone() const
{
notImplemented("curvedEdge::clone() const");
return autoPtr<curvedEdge>(NULL);
}
//- New function which constructs and returns pointer to a curvedEdge
autoPtr<curvedEdge> curvedEdge::New(const pointField& points, Istream& is)
Foam::autoPtr<Foam::curvedEdge> Foam::curvedEdge::New
(
const pointField& points,
Istream& is
)
{
if (debug)
{
@ -115,61 +88,59 @@ autoPtr<curvedEdge> curvedEdge::New(const pointField& points, Istream& is)
<< endl;
}
word curvedEdgeType(is);
word edgeType(is);
HashTable<IstreamConstructorPtr_>::iterator curvedEdgeConstructorIter =
IstreamConstructorTablePtr_->find(curvedEdgeType);
IstreamConstructorTable::iterator cstrIter =
IstreamConstructorTablePtr_->find(edgeType);
if (curvedEdgeConstructorIter == IstreamConstructorTablePtr_->end())
if (cstrIter == IstreamConstructorTablePtr_->end())
{
FatalErrorIn("curvedEdge::New(const pointField&, Istream&)")
<< "Unknown curvedEdge type " << curvedEdgeType << endl << endl
<< "Unknown curvedEdge type " << edgeType << endl << endl
<< "Valid curvedEdge types are" << endl
<< IstreamConstructorTablePtr_->toc()
<< abort(FatalError);
}
return autoPtr<curvedEdge>(curvedEdgeConstructorIter()(points, is));
return autoPtr<curvedEdge>(cstrIter()(points, is));
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
//- Return the complete knotList by adding the start and end points to the
// given list
pointField knotlist
Foam::pointField Foam::curvedEdge::appendEndPoints
(
const pointField& points,
const label start,
const label end,
const pointField& otherknots
const pointField& otherKnots
)
{
label listsize(otherknots.size() + 2);
pointField tmp(listsize);
pointField allKnots(otherKnots.size() + 2);
tmp[0] = points[start];
// start/end knots
allKnots[0] = points[start];
allKnots[otherKnots.size() + 1] = points[end];
for (register label i=1; i<listsize-1; i++)
// intermediate knots
forAll(otherKnots, knotI)
{
tmp[i] = otherknots[i-1];
allKnots[knotI+1] = otherKnots[knotI];
}
tmp[listsize-1] = points[end];
return tmp;
return allKnots;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
void curvedEdge::operator=(const curvedEdge&)
void Foam::curvedEdge::operator=(const curvedEdge&)
{
notImplemented("void curvedEdge::operator=(const curvedEdge&)");
}
Ostream& operator<<(Ostream& os, const curvedEdge& p)
Foam::Ostream& Foam::operator<<(Ostream& os, const curvedEdge& p)
{
os << p.start_ << tab << p.end_ << endl;
@ -177,9 +148,4 @@ Ostream& operator<<(Ostream& os, const curvedEdge& p)
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -26,9 +26,8 @@ Class
Foam::curvedEdge
Description
curvedEdges : library functions that will define a curvedEdge in space
parameterised for 0<lambda<1 from the beginning point to the end point.
This file contains the abstract base class curvedEdge.
Define a curved edge that is parameterized for 0<lambda<1
between the start and end point.
SourceFiles
curvedEdge.C
@ -38,6 +37,7 @@ SourceFiles
#ifndef curvedEdges_H
#define curvedEdges_H
#include "edge.H"
#include "pointField.H"
#include "typeInfo.H"
#include "HashTable.H"
@ -59,55 +59,40 @@ protected:
// Protected data
const pointField& points_;
const label start_, end_;
const label start_;
const label end_;
// Protected Member Functions
//- Return a complete point field by appending the start/end points
// to the given list
static pointField appendEndPoints
(
const pointField&,
const label start,
const label end,
const pointField& otherKnots
);
public:
// Constructor Hash tables
//- Runtime type information
TypeName("curvedEdge");
//- Construct from Istream function pointer type
typedef autoPtr<curvedEdge> (*IstreamConstructorPtr_)
(const pointField&, Istream&);
// Declare run-time constructor selection tables
//- Construct from Istream function pointer table pointer
static HashTable<IstreamConstructorPtr_>*
IstreamConstructorTablePtr_;
// Hash table constructor classes and functions
//- Hash table Constructor.
// Must be called from the table add functions below.
static void constructTables();
//- Class to add constructor from Istream to Hash table
template<class curvedEdgeType>
class addIstreamConstructorToTable
{
public:
static autoPtr<curvedEdge> New
declareRunTimeSelectionTable
(
autoPtr,
curvedEdge,
Istream,
(
const pointField& points,
Istream& is
)
{
return autoPtr<curvedEdge>(new curvedEdgeType(points, is));
}
addIstreamConstructorToTable()
{
curvedEdge::constructTables();
curvedEdge::IstreamConstructorTablePtr_
->insert(curvedEdgeType::typeName, New);
}
};
//- Runtime type information
TypeName("curvedEdge");
),
(points, is)
);
// Constructors
@ -141,34 +126,37 @@ public:
// Member Functions
//- Return label of start point
label start() const
{
return start_;
}
inline label start() const;
//- Return label of end point
label end() const
{
return end_;
}
inline label end() const;
//- Compare the given start and end points with those of this curve
bool compare(const label start, const label end) const
{
return
(
(start_ == start && end_ == end)
|| (start_ == end && end_ == start)
);
}
//- Compare the given start and end points with this curve
// - 0: different
// - +1: identical
// - -1: same edge, but different orientation
inline int compare(const curvedEdge&) const;
//- Return the position of a point on the curve given by
// the parameter 0 <= lambda <= 1
virtual vector position(const scalar) const = 0;
//- Compare the given start and end points with this curve
// - 0: different
// - +1: identical
// - -1: same edge, but different orientation
inline int compare(const edge&) const;
//- Compare the given start and end points with this curve
// - 0: different
// - +1: identical
// - -1: same edge, but different orientation
inline int compare(const label start, const label end) const;
//- Return the point position corresponding to the curve parameter
// 0 <= lambda <= 1
virtual point position(const scalar) const = 0;
//- Return the length of the curve
virtual scalar length() const = 0;
// Member operators
void operator=(const curvedEdge&);
@ -179,23 +167,16 @@ public:
};
//- Return the complete knotList by adding the start and end points to the
// given list
pointField knotlist
(
const pointField& points,
const label start,
const label end,
const pointField& otherknots
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "curvedEdgeI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -24,75 +24,47 @@ License
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const List<word>& molConfig::molIdList() const
inline Foam::label Foam::curvedEdge::start() const
{
return idList_;
return start_;
}
inline const labelField& molConfig::id() const
inline Foam::label Foam::curvedEdge::end() const
{
return id_;
return end_;
}
inline const scalarField& molConfig::mass() const
inline int Foam::curvedEdge::compare(const label start, const label end) const
{
return mass_;
if (start_ == start && end_ == end)
{
return 1;
}
else if (start_ == end && end_ == start)
{
return -1;
}
else
{
return 0;
}
}
inline const vectorField& molConfig::positions() const
inline int Foam::curvedEdge::compare(const curvedEdge& e) const
{
return positions_;
return Foam::curvedEdge::compare(e.start(), e.end());
}
inline const labelField& molConfig::cells() const
inline int Foam::curvedEdge::compare(const edge& e) const
{
return cells_;
return Foam::curvedEdge::compare(e.start(), e.end());
}
inline const vectorField& molConfig::U() const
{
return U_;
}
inline const vectorField& molConfig::A() const
{
return A_;
}
inline const labelField& molConfig::tethered() const
{
return tethered_;
}
inline const vectorField& molConfig::tetherPositions() const
{
return tetherPositions_;
}
inline label molConfig::nMol() const
{
return nMol_;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -22,10 +22,11 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
InClass
Typedef
Foam::curvedEdgeList
Description
A PtrList of curvedEdges
\*---------------------------------------------------------------------------*/

View file

@ -22,9 +22,6 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
lineDivide class : divides a line into segments
\*---------------------------------------------------------------------------*/
#include "error.H"
@ -32,66 +29,58 @@ Description
#include "lineDivide.H"
#include "curvedEdge.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
lineDivide::lineDivide(const curvedEdge& bc, const label n, const scalar xratio)
Foam::lineDivide::lineDivide
(
const curvedEdge& cedge,
const label ndiv,
const scalar xratio
)
:
points_(n + 1),
divisions_(n + 1),
noPoints_(n)
points_(ndiv + 1),
divisions_(ndiv + 1)
{
scalar np(n);
scalar lambda(0.0);
divisions_[0] = 0.0;
divisions_[ndiv] = 1.0;
// calculate the spacing
if (xratio == 1.0)
{
scalar y(1.0/np);
for (label i=0; i<=noPoints_; i++)
for (label i=1; i < ndiv; i++)
{
lambda = scalar(i)/np;
points_[i] = bc.position(lambda);
divisions_[i] = y*i;
divisions_[i] = scalar(i)/ndiv;
}
}
else
{
points_[0] = bc.position(0.0);
divisions_[0] = 0.0;
scalar xrpower = 1.0;
for (label i=1; i<=noPoints_; i++)
for (label i=1; i < ndiv; i++)
{
lambda = (1.0 - pow(xratio, i))/(1.0 - pow(xratio, np));
points_[i] = bc.position(lambda);
divisions_[i] = lambda;
xrpower *= xratio;
divisions_[i] = (1.0 - pow(xratio, i))/(1.0 - pow(xratio, ndiv));
}
}
// calculate the points
for (label i=0; i <= ndiv; i++)
{
points_[i] = cedge.position(divisions_[i]);
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const pointField& lineDivide::points() const
const Foam::pointField& Foam::lineDivide::points() const
{
return points_;
}
const scalarList& lineDivide::lambdaDivisions() const
const Foam::scalarList& Foam::lineDivide::lambdaDivisions() const
{
return divisions_;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -26,7 +26,7 @@ Class
Foam::lineDivide
Description
lineDivide class : divides a line into segments
Divides a line into segments
SourceFiles
lineDivide.C
@ -55,16 +55,20 @@ class lineDivide
// Private data
pointField points_;
scalarList divisions_;
label noPoints_;
scalarList divisions_;
public:
// Constructors
//- Construct from components
lineDivide(const curvedEdge&, const label, const scalar = 1.0);
//- Construct from components with discretization and expansion ratio
lineDivide
(
const curvedEdge&,
const label ndiv,
const scalar xratio = 1.0
);
// Member Functions

View file

@ -22,58 +22,47 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
line class : defines a straight line between the start point and the
end point
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "lineEdge.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(lineEdge, 0);
// Add the curvedEdge constructor functions to the hash tables
curvedEdge::addIstreamConstructorToTable<lineEdge>
addLineEdgeIstreamConstructorToTable_;
namespace Foam
{
defineTypeNameAndDebug(lineEdge, 0);
addToRunTimeSelectionTable(curvedEdge, lineEdge, Istream);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
lineEdge::lineEdge
Foam::lineEdge::lineEdge
(
const pointField& points,
const label start,
const label end
)
:
curvedEdge(points, start, end),
startPoint_(points_[start_]),
direction_(points_[end_] - points_[start_])
curvedEdge(points, start, end)
{}
// Construct from Istream
lineEdge::lineEdge(const pointField& points, Istream& is)
Foam::lineEdge::lineEdge(const pointField& points, Istream& is)
:
curvedEdge(points, is),
startPoint_(points_[start_]),
direction_(points_[end_] - points_[start_])
curvedEdge(points, is)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
Foam::lineEdge::~lineEdge()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
vector lineEdge::position(const scalar lambda) const
Foam::point Foam::lineEdge::position(const scalar lambda) const
{
if (lambda < 0 || lambda > 1)
{
@ -82,19 +71,14 @@ vector lineEdge::position(const scalar lambda) const
<< abort(FatalError);
}
return startPoint_ + lambda*direction_;
return points_[start_] + lambda * (points_[end_] - points_[start_]);
}
//- Return the length of the curve
scalar lineEdge::length() const
Foam::scalar Foam::lineEdge::length() const
{
return mag(direction_);
return mag(points_[end_] - points_[start_]);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -26,8 +26,7 @@ Class
Foam::lineEdge
Description
lineEdge class : defines a straight line between the start point and the
end point
A straight edge between the start point and the end point.
SourceFiles
lineEdge.C
@ -53,11 +52,13 @@ class lineEdge
:
public curvedEdge
{
// Private data
// Private Member Functions
vector startPoint_;
vector direction_;
//- Disallow default bitwise copy construct
lineEdge(const lineEdge&);
//- Disallow default bitwise assignment
void operator=(const lineEdge&);
public:
@ -67,22 +68,21 @@ public:
// Constructors
//- Construct from components
lineEdge(const pointField& points, const label start, const label end);
lineEdge(const pointField&, const label start, const label end);
//- Construct from Istream setting pointsList
lineEdge(const pointField& points, Istream&);
//- Construct from Istream with a pointField
lineEdge(const pointField&, Istream&);
// Destructor
virtual ~lineEdge(){}
//- Destructor
virtual ~lineEdge();
// Member Functions
//- Return the position of a point on the curve given by
// the parameter 0 <= lambda <= 1
vector position(const scalar) const;
//- Return the point position corresponding to the curve parameter
// 0 <= lambda <= 1
point position(const scalar) const;
//- Return the length of the curve
scalar length() const;

View file

@ -22,116 +22,162 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
polyLineEdge class : defines a curvedEdge in terms of a series of
straight line segments
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "polyLine.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// calcDistances generates the distances_ lookup table (cumulative
// distance along the line) from the individual vectors to the points
void polyLine::calcDistances()
void Foam::polyLine::calcParam()
{
distances_[0] = 0.0;
param_.setSize(points_.size());
for (label i=1; i<distances_.size(); i++)
if (param_.size())
{
distances_[i] =
mag(controlPoints_[i] - controlPoints_[i-1])
+ distances_[i-1];
param_[0] = 0.0;
for (label i=1; i < param_.size(); i++)
{
param_[i] = param_[i-1] + mag(points_[i] - points_[i-1]);
}
lineLength_ = distances_[distances_.size()-1];
for (label i=1; i<distances_.size(); i++)
// normalize on the interval 0-1
lineLength_ = param_[param_.size()-1];
for (label i=1; i < param_.size() - 1; i++)
{
distances_[i] /= lineLength_;
param_[i] /= lineLength_;
}
param_[param_.size()-1] = 1.0;
}
else
{
lineLength_ = 0.0;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
polyLine::polyLine(const pointField& ps)
Foam::polyLine::polyLine(const pointField& ps, const bool)
:
controlPoints_(ps),
distances_(ps.size())
points_(ps),
lineLength_(0.0),
param_(0)
{
if (ps.size())
{
calcDistances();
}
calcParam();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
vector polyLine::position(const scalar lambda) const
const Foam::pointField& Foam::polyLine::points() const
{
// check range of lambda
if (lambda < 0 || lambda > 1)
{
FatalErrorIn("polyLine::position(const scalar)")
<< "Parameter out of range, "
<< "lambda = " << lambda
<< abort(FatalError);
}
// Quick calc of endpoints
if (lambda < SMALL)
{
return controlPoints_[0];
}
else if (lambda > 1 - SMALL)
{
return controlPoints_[controlPoints_.size()-1];
}
// search table of cumulative distance to find which linesegment we
// are on
label i(0);
do
{
i++;
} while (distances_[i] < lambda);
i--; // we overshot!
// construct position vector
scalar offsetDist =
(lambda - distances_[i])
/(distances_[i+1] - distances_[i]);
vector offsetV = controlPoints_[i+1] - controlPoints_[i];
return controlPoints_[i] + offsetDist*offsetV;
return points_;
}
scalar polyLine::length() const
Foam::label Foam::polyLine::nSegments() const
{
return points_.size()-1;
}
Foam::label Foam::polyLine::localParameter(scalar& lambda) const
{
// check endpoints
if (lambda < SMALL)
{
lambda = 0;
return 0;
}
else if (lambda > 1 - SMALL)
{
lambda = 1;
return nSegments();
}
// search table of cumulative distances to find which line-segment
// we are on. Check the upper bound.
label segmentI = 1;
while (param_[segmentI] < lambda)
{
segmentI++;
}
segmentI--; // we want the corresponding lower bound
// the local parameter [0-1] on this line segment
lambda =
(
( lambda - param_[segmentI] )
/ ( param_[segmentI+1] - param_[segmentI] )
);
return segmentI;
}
Foam::point Foam::polyLine::position(const scalar mu) const
{
// check endpoints
if (mu < SMALL)
{
return points_[0];
}
else if (mu > 1 - SMALL)
{
return points_[points_.size()-1];
}
scalar lambda = mu;
label segment = localParameter(lambda);
return position(segment, lambda);
}
Foam::point Foam::polyLine::position
(
const label segment,
const scalar mu
) const
{
// out-of-bounds
if (segment < 0)
{
return points_[0];
}
else if (segment > nSegments())
{
return points_[points_.size()-1];
}
const point& p0 = points()[segment];
const point& p1 = points()[segment+1];
// special cases - no calculation needed
if (mu <= 0.0)
{
return p0;
}
else if (mu >= 1.0)
{
return p1;
}
else
{
// linear interpolation
return points_[segment] + mu * (p1 - p0);
}
}
Foam::scalar Foam::polyLine::length() const
{
return lineLength_;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -26,9 +26,11 @@ Class
Foam::polyLine
Description
polyLine class : defines a curvedEdge in terms of a series of straight
line segments. This is the basic polyLine class which implements
just the line (no topology : its not derived from curvedEdge)
A series of straight line segments, which can also be interpreted as
a series of control points for splines, etc.
ToDo
A future implementation could also handle a closed polyLine.
SourceFiles
polyLine.C
@ -53,33 +55,65 @@ namespace Foam
class polyLine
{
// Private Member Functions
//- Disallow default bitwise copy construct
polyLine(const polyLine&);
//- Disallow default bitwise assignment
void operator=(const polyLine&);
protected:
// Protected data
pointField controlPoints_;
scalarList distances_;
//- The control points or ends of each segments
pointField points_;
//- The real line length
scalar lineLength_;
//- The rational (0-1) cumulative parameter value for each point
scalarList param_;
// Protected member functions
void calcDistances();
//- Precalculate the rational cumulative parameter value
// and the line-length
void calcParam();
//- Return the line segment and the local parameter [0..1]
// corresponding to the global lambda [0..1]
label localParameter(scalar& lambda) const;
public:
// Constructors
//- Construct from components
polyLine(const pointField& ps);
polyLine
(
const pointField&,
const bool notImplementedClosed = false
);
// Member Functions
//- Return the position of a point on the curve given by
// the parameter 0 <= lambda <= 1
vector position(const scalar) const;
//- Return const-access to the control-points
const pointField& points() const;
//- Return the number of line segments
label nSegments() const;
//- Return the point position corresponding to the curve parameter
// 0 <= lambda <= 1
point position(const scalar) const;
//- Return the point position corresponding to the local parameter
// 0 <= lambda <= 1 on the given segment
point position(const label segment, const scalar) const;
//- Return the length of the curve
scalar length() const;

View file

@ -22,71 +22,61 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "polyLineEdge.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(polyLineEdge, 0);
// Add the curvedEdge constructor functions to the hash tables
curvedEdge::addIstreamConstructorToTable<polyLineEdge>
addPolyLineEdgeIstreamConstructorToTable_;
namespace Foam
{
defineTypeNameAndDebug(polyLineEdge, 0);
addToRunTimeSelectionTable(curvedEdge, polyLineEdge, Istream);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
polyLineEdge::polyLineEdge
Foam::polyLineEdge::polyLineEdge
(
const pointField& ps,
const label start,
const label end,
const pointField& otherpoints
const pointField& otherPoints
)
:
curvedEdge(ps, start, end),
polyLine(knotlist(ps,start,end,otherpoints))
polyLine(appendEndPoints(ps, start_, end_, otherPoints))
{}
// Construct from Istream
polyLineEdge::polyLineEdge(const pointField& ps, Istream& is)
Foam::polyLineEdge::polyLineEdge(const pointField& ps, Istream& is)
:
curvedEdge(ps, is),
polyLine(knotlist(ps, start_, end_, pointField(is)))
polyLine(appendEndPoints(ps, start_, end_, pointField(is)))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::polyLineEdge::~polyLineEdge()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
//- Return the position of a point on the curve given by
// the parameter 0 <= lambda <= 1
vector polyLineEdge::position(const scalar lambda) const
Foam::point Foam::polyLineEdge::position(const scalar lambda) const
{
return polyLine::position(lambda);
}
//- Return the length of the curve
scalar polyLineEdge::length() const
Foam::scalar Foam::polyLineEdge::length() const
{
return polyLine::lineLength_;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -26,8 +26,7 @@ Class
Foam::polyLineEdge
Description
polyLineEdge class : defines a curvedEdge in terms of a series of straight
line segments. This is the public face of polyLine
A curvedEdge defined in terms of a series of straight line segments.
SourceFiles
polyLineEdge.C
@ -54,6 +53,14 @@ class polyLineEdge
public curvedEdge,
public polyLine
{
// Private Member Functions
//- Disallow default bitwise copy construct
polyLineEdge(const polyLineEdge&);
//- Disallow default bitwise assignment
void operator=(const polyLineEdge&);
public:
@ -66,26 +73,25 @@ public:
//- Construct from components
polyLineEdge
(
const pointField& ps,
const pointField&,
const label start,
const label end,
const pointField& otherpoints
const pointField& otherPoints
);
//- Construct from Istream
polyLineEdge(const pointField& ps, Istream&);
polyLineEdge(const pointField&, Istream&);
// Destructor
virtual ~polyLineEdge(){}
//- Destructor
virtual ~polyLineEdge();
// Member Functions
//- Return the position of a point on the curve given by
// the parameter 0 <= lambda <= 1
vector position(const scalar lambda) const;
//- Return the point position corresponding to the curve parameter
// 0 <= lambda <= 1
point position(const scalar lambda) const;
//- Return the length of the curve
scalar length() const;

View file

@ -1,117 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
spline class : define a basic spline on nKnots knots - this
does not go anywhere near these knots (will act as a base type for
various splines that will have real uses)
\*---------------------------------------------------------------------------*/
#include "spline.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
spline::spline(const pointField& a)
:
knots_(a)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// function B : this is the blending function for constructing the
// spline
scalar spline::B(const scalar& tau) const
{
scalar value = 0.0;
if (tau>=2.0 || tau<=-2.0)
{
value = 0.0;
}
else if (tau<=-1.0)
{
value = pow((2.0 + tau),3.0)/6.0;
}
else if (tau<=0.0)
{
value = (4.0 - 6.0*tau*tau - 3.0*tau*tau*tau)/6.0;
}
else if (tau<=1.0)
{
value = (4.0 - 6.0*tau*tau + 3.0*tau*tau*tau)/6.0;
}
else if (tau<=2.0)
{
value = pow((2.0 - tau),3.0)/6.0;
}
else
{
FatalErrorIn("spline::B(const scalar&)")
<< "How the hell did we get here???, "
<< "tau = " << tau
<< abort(FatalError);
}
return value;
}
// position : returns the position along the spline corresponding to the
// variable mu1
vector spline::position(const scalar mu1) const
{
vector tmp(vector::zero);
for (register label i=0; i<knots_.size(); i++)
{
tmp += B((knots_.size() - 1)*mu1 - i)*knots_[i];
}
return tmp;
}
//- Return the length of the spline curve
scalar spline::length() const
{
notImplemented("spline::length() const");
return 1.0;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -22,88 +22,96 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
simpleSplineEdge : the actual access class for Bspline
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "splineEdge.H"
#include "addToRunTimeSelectionTable.H"
#include "simpleSplineEdge.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(simpleSplineEdge, 0);
namespace Foam
{
defineTypeNameAndDebug(splineEdge, 0);
addToRunTimeSelectionTable
(
curvedEdge,
splineEdge,
Istream
);
// compatibility with old names
addNamedToRunTimeSelectionTable
(
curvedEdge,
splineEdge,
Istream,
simpleSpline
);
// compatibility with old names
addNamedToRunTimeSelectionTable
(
curvedEdge,
splineEdge,
Istream,
polySpline
);
}
// Add the curvedEdge constructor functions to the hash tables
curvedEdge::addIstreamConstructorToTable<simpleSplineEdge>
addSimpleSplineEdgeIstreamConstructorToTable_;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
simpleSplineEdge::simpleSplineEdge
Foam::splineEdge::splineEdge
(
const pointField& points,
const label start,
const label end,
const pointField& otherknots
const pointField& internalPoints
)
:
curvedEdge(points, start, end),
BSpline(knotlist(points, start, end, otherknots))
CatmullRomSpline(appendEndPoints(points, start, end, internalPoints))
{}
// Construct from components
simpleSplineEdge::simpleSplineEdge
(
const pointField& points,
const label start,
const label end,
const pointField& otherknots,
const vector& fstend,
const vector& sndend
)
:
curvedEdge(points, start, end),
BSpline(knotlist(points, start, end, otherknots), fstend, sndend)
{}
// Construct from Istream
simpleSplineEdge::simpleSplineEdge(const pointField& points, Istream& is)
Foam::splineEdge::splineEdge(const pointField& points, Istream& is)
:
curvedEdge(points, is),
BSpline(knotlist(points, start_, end_, pointField(is)))
CatmullRomSpline(appendEndPoints(points, start_, end_, pointField(is)))
{
token t(is);
is.putBack(t);
// compatibility - might also have start/end tangents - discard them
if (t == token::BEGIN_LIST)
{
vector tangent0Ignored(is);
vector tangent1Ignored(is);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::splineEdge::~splineEdge()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
//- Return the position of a point on the simple spline curve given by
// the parameter 0 <= lambda <= 1
vector simpleSplineEdge::position(const scalar mu) const
Foam::point Foam::splineEdge::position(const scalar mu) const
{
return BSpline::position(mu);
return CatmullRomSpline::position(mu);
}
//- Return the length of the simple spline curve
scalar simpleSplineEdge::length() const
Foam::scalar Foam::splineEdge::length() const
{
notImplemented("simpleSplineEdge::length() const");
return 1.0;
return CatmullRomSpline::length();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -23,21 +23,25 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::simpleSplineEdge
Foam::splineEdge
Description
simpleSplineEdge : the actual access class for Bspline
A curvedEdge interface for Catmull-Rom splines.
Note
For compatibility, also accepts the type names 'polySpline' and
'simpleSpline'.
SourceFiles
simpleSplineEdge.C
splineEdge.C
\*---------------------------------------------------------------------------*/
#ifndef simpleSplineEdge_H
#define simpleSplineEdge_H
#ifndef splineEdge_H
#define splineEdge_H
#include "curvedEdge.H"
#include "BSpline.H"
#include "CatmullRomSpline.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -45,60 +49,56 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class simpleSplineEdge Declaration
Class splineEdge Declaration
\*---------------------------------------------------------------------------*/
class simpleSplineEdge
class splineEdge
:
public curvedEdge,
public BSpline
public CatmullRomSpline
{
// Private Member Functions
//- Disallow default bitwise copy construct
splineEdge(const splineEdge&);
//- Disallow default bitwise assignment
void operator=(const splineEdge&);
public:
//- Runtime type information
TypeName("simpleSpline");
TypeName("spline");
// Constructors
//- Construct from components
simpleSplineEdge
splineEdge
(
const pointField& ps,
const pointField&,
const label start,
const label end,
const pointField& otherknots
const pointField& internalPoints
);
//- Construct from components
simpleSplineEdge
(
const pointField& points,
const label start,
const label end,
const pointField& otherknots,
const vector& fstend,
const vector& sndend
);
//- Construct from Istream setting pointsList
simpleSplineEdge(const pointField&, Istream&);
//- Construct from Istream, setting pointsList
splineEdge(const pointField&, Istream&);
// Destructor
virtual ~simpleSplineEdge(){}
//- Destructor
virtual ~splineEdge();
// Member Functions
//- Return the position of a point on the simple spline curve given by
// the parameter 0 <= lambda <= 1
vector position(const scalar mu) const;
//- Return the point position corresponding to the curve parameter
// 0 <= lambda <= 1
virtual point position(const scalar) const;
//- Return the length of the simple spline curve
scalar length() const;
//- Return the length of the spline curve (not implemented)
virtual scalar length() const;
};

View file

@ -100,7 +100,7 @@ void blockDescriptor::setEdge(label edgeI, label start, label end, label dim)
scalar gExp = calcGexp(expand_[edgeI], dim);
// divide the line
lineDivide divEdge(curvedEdges_[nCEI], dim, 1.0/gExp);
lineDivide divEdge(curvedEdges_[nCEI], dim, 1.0/(gExp + SMALL));
pointField p = divEdge.points();
scalarList d = divEdge.lambdaDivisions();

View file

@ -61,10 +61,12 @@ int main(int argc, char *argv[])
argList::validOptions.insert("overwrite", "");
# include "setRootCase.H"
# include "createTime.H"
runTime.functionObjects().off();
# include "createPolyMesh.H"
const word oldInstance = mesh.pointsInstance();
scalar thickness(readScalar(IStringStream(args.additionalArgs()[0])()));
bool overwrite = args.options().found("overwrite");
bool overwrite = args.optionFound("overwrite");
// Check that mesh is 2D
@ -87,7 +89,7 @@ int main(int argc, char *argv[])
// ~~~~~~~~~~~~~~~~~~~~~~
scalar minRange = GREAT;
direction extrudeDir = -1;
direction extrudeDir = 4; //illegal value.
for (direction dir = 0; dir < 3; dir++)
{
@ -181,6 +183,10 @@ int main(int argc, char *argv[])
{
runTime++;
}
else
{
mesh.setInstance(oldInstance);
}
// Take over refinement levels and write to new time directory.
Pout<< "Writing extruded mesh to time " << runTime.timeName() << nl

View file

@ -1,6 +1,8 @@
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
set -x
wclean libso extrudeModel
wclean
# ----------------------------------------------------------------- end-of-file

View file

@ -1,6 +1,8 @@
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
set -x
wmake libso extrudeModel
wmake
# ----------------------------------------------------------------- end-of-file

View file

@ -1,8 +1,8 @@
EXE_INC = \
-IextrudedMesh \
-IextrudeModel/lnInclude \
-I$(FOAM_SRC)/meshTools/lnInclude \
-I$(FOAM_SRC)/dynamicMesh/lnInclude
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude
EXE_LIBS = \
-lmeshTools \

View file

@ -23,7 +23,9 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Extrude mesh from existing patch or from patch read from file.
Extrude mesh from existing patch (by default outwards facing normals;
optional flips faces) or from patch read from file.
Note: Merges close points so be careful.
Type of extrusion prescribed by run-time selectable model.
@ -54,26 +56,12 @@ using namespace Foam;
int main(int argc, char *argv[])
{
# include "setRoots.H"
# include "setRootCase.H"
# include "createTimeExtruded.H"
if (args.options().found("sourceRoot") == args.options().found("surface"))
{
FatalErrorIn(args.executable())
<< "Need to specify either -sourceRoot/Case/Patch or -surface"
<< " option to specify the source of the patch to extrude"
<< exit(FatalError);
}
autoPtr<extrudedMesh> meshPtr(NULL);
autoPtr<extrudeModel> model
(
extrudeModel::New
(
IOdictionary
IOdictionary dict
(
IOobject
(
@ -82,27 +70,33 @@ int main(int argc, char *argv[])
runTimeExtruded,
IOobject::MUST_READ
)
)
)
);
if (args.options().found("sourceRoot"))
autoPtr<extrudeModel> model(extrudeModel::New(dict));
const word sourceType(dict.lookup("constructFrom"));
autoPtr<faceMesh> fMesh;
if (sourceType == "patch")
{
fileName rootDirSource(args.options()["sourceRoot"]);
fileName caseDirSource(args.options()["sourceCase"]);
fileName patchName(args.options()["sourcePatch"]);
fileName sourceCasePath(dict.lookup("sourceCase"));
sourceCasePath.expand();
fileName sourceRootDir = sourceCasePath.path();
fileName sourceCaseDir = sourceCasePath.name();
word patchName(dict.lookup("sourcePatch"));
Info<< "Extruding patch " << patchName
<< " on mesh " << rootDirSource << ' ' << caseDirSource << nl
<< " on mesh " << sourceCasePath << nl
<< endl;
Time runTime
(
Time::controlDictName,
rootDirSource,
caseDirSource
sourceRootDir,
sourceCaseDir
);
# include "createPolyMesh.H"
#include "createPolyMesh.H"
label patchID = mesh.boundaryMesh().findPatchID(patchName);
@ -116,53 +110,61 @@ int main(int argc, char *argv[])
}
const polyPatch& pp = mesh.boundaryMesh()[patchID];
fMesh.reset(new faceMesh(pp.localFaces(), pp.localPoints()));
{
fileName surfName(patchName + ".sMesh");
Info<< "Writing patch as surfaceMesh to " << surfName << nl << endl;
faceMesh fMesh(pp.localFaces(), pp.localPoints());
fileName surfName(runTime.path()/patchName + ".sMesh");
Info<< "Writing patch as surfaceMesh to "
<< surfName << nl << endl;
OFstream os(surfName);
os << fMesh << nl;
os << fMesh() << nl;
}
meshPtr.reset
(
new extrudedMesh
(
IOobject
(
extrudedMesh::defaultRegion,
runTimeExtruded.constant(),
runTimeExtruded
),
pp,
model()
)
);
}
else
else if (sourceType == "surface")
{
// Read from surface
fileName surfName(args.options()["surface"]);
fileName surfName(dict.lookup("surface"));
Info<< "Extruding surfaceMesh read from file " << surfName << nl
<< endl;
IFstream is(surfName);
faceMesh fMesh(is);
fMesh.reset(new faceMesh(is));
Info<< "Read patch from file " << surfName << ':' << nl
<< " points : " << fMesh.points().size() << nl
<< " faces : " << fMesh.size() << nl
Info<< "Read patch from file " << surfName << nl
<< endl;
}
else
{
FatalErrorIn(args.executable())
<< "Illegal 'constructFrom' specification. Should either be "
<< "patch or surface." << exit(FatalError);
}
Switch flipNormals(dict.lookup("flipNormals"));
if (flipNormals)
{
Info<< "Flipping faces." << nl << endl;
faceList faces(fMesh().size());
forAll(faces, i)
{
faces[i] = fMesh()[i].reverseFace();
}
fMesh.reset(new faceMesh(faces, fMesh().localPoints()));
}
Info<< "Extruding patch with :" << nl
<< " points : " << fMesh().points().size() << nl
<< " faces : " << fMesh().size() << nl
<< " normals[0] : " << fMesh().faceNormals()[0]
<< nl
<< endl;
meshPtr.reset
(
new extrudedMesh
extrudedMesh mesh
(
IOobject
(
@ -170,22 +172,18 @@ int main(int argc, char *argv[])
runTimeExtruded.constant(),
runTimeExtruded
),
fMesh,
fMesh(),
model()
)
);
}
extrudedMesh& mesh = meshPtr();
const boundBox& bb = mesh.globalData().bb();
const vector span(bb.max() - bb.min());
const scalar minDim = min(span[0], min(span[1], span[2]));
const scalar mergeDim = 1E-4*minDim;
const vector span = bb.span();
const scalar mergeDim = 1e-4 * bb.minDim();
Pout<< "Mesh bounding box:" << bb << nl
<< " with span:" << span << nl
<< "Merge distance :" << mergeDim << nl
Info<< "Mesh bounding box : " << bb << nl
<< " with span : " << span << nl
<< "Merge distance : " << mergeDim << nl
<< endl;
const polyBoundaryMesh& patches = mesh.boundaryMesh();
@ -204,7 +202,7 @@ int main(int argc, char *argv[])
// ~~~~~~~~~~~~~~
{
Pout<< "Collapsing edges < " << mergeDim << " ..." << nl << endl;
Info<< "Collapsing edges < " << mergeDim << " ..." << nl << endl;
// Edge collapsing engine
edgeCollapser collapser(mesh);
@ -220,7 +218,7 @@ int main(int argc, char *argv[])
if (d < mergeDim)
{
Pout<< "Merging edge " << e << " since length " << d
Info<< "Merging edge " << e << " since length " << d
<< " << " << mergeDim << nl;
// Collapse edge to e[0]
@ -253,9 +251,10 @@ int main(int argc, char *argv[])
// Merging front and back patch faces
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (args.options().found("mergeFaces"))
Switch mergeFaces(dict.lookup("mergeFaces"));
if (mergeFaces)
{
Pout<< "Assuming full 360 degree axisymmetric case;"
Info<< "Assuming full 360 degree axisymmetric case;"
<< " stitching faces on patches "
<< patches[origPatchID].name() << " and "
<< patches[otherPatchID].name() << " together ..." << nl << endl;
@ -304,7 +303,7 @@ int main(int argc, char *argv[])
);
// Execute all polyMeshModifiers
autoPtr<mapPolyMesh> morphMap = stitcher.changeMesh();
autoPtr<mapPolyMesh> morphMap = stitcher.changeMesh(true);
mesh.movePoints(morphMap->preMotionPoints());
}

View file

@ -1,6 +1,6 @@
EXE_INC = \
-I$(FOAM_SRC)/meshTools/lnInclude \
-I$(FOAM_SRC)/dynamicMesh/lnInclude
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude
EXE_LIBS = \
-lmeshTools \

View file

@ -47,7 +47,14 @@ linearNormal::linearNormal(const dictionary& dict)
:
extrudeModel(typeName, dict),
thickness_(readScalar(coeffDict_.lookup("thickness")))
{}
{
if (thickness_ <= SMALL)
{
FatalErrorIn("linearNormal(const dictionary&)")
<< "thickness should be positive : " << thickness_
<< exit(FatalError);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

View file

@ -48,7 +48,7 @@ wedge::wedge(const dictionary& dict)
:
extrudeModel(typeName, dict),
axisPt_(coeffDict_.lookup("axisPt")),
axisNormal_(coeffDict_.lookup("axisNormal")),
axis_(coeffDict_.lookup("axis")),
angle_
(
readScalar(coeffDict_.lookup("angle"))
@ -88,7 +88,8 @@ point wedge::operator()
}
else
{
sliceAngle = angle_*(layer + 1)/nLayers_;
//sliceAngle = angle_*(layer + 1)/nLayers_;
sliceAngle = angle_*layer/nLayers_;
}
// Find projection onto axis (or rather decompose surfacePoint
@ -96,7 +97,7 @@ point wedge::operator()
// of surface point and surface normal.
point d = surfacePoint - axisPt_;
d -= (axisNormal_ & d)*axisNormal_;
d -= (axis_ & d)*axis_;
scalar dMag = mag(d);
@ -107,7 +108,7 @@ point wedge::operator()
if (dMag > VSMALL)
{
vector n = (d/dMag) ^ axisNormal_;
vector n = (d/dMag) ^ axis_;
rotatedPoint +=
+ cos(sliceAngle)*d
@ -124,4 +125,3 @@ point wedge::operator()
} // End namespace Foam
// ************************************************************************* //

View file

@ -60,13 +60,13 @@ class wedge
{
// Private data
//- point on axis
//- Point on axis
const point axisPt_;
//- normalized direction of axis
const vector axisNormal_;
//- Normalized direction of axis
const vector axis_;
//- overall angle (radians)
//- Overall angle (radians)
const scalar angle_;
@ -80,6 +80,7 @@ public:
//- Construct from components
wedge(const dictionary& dict);
//- Destrcuctor
~wedge();

View file

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / O peration | Version: 1.6 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
@ -14,23 +14,50 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
extrudeModel wedge;
// Where to get surface from: either from surface ('surface') or
// from (flipped) patch of existing case ('patch')
constructFrom patch; //surface;
// If construct from (flipped) patch
sourceCase "$FOAM_RUN/icoFoam/cavity";
sourcePatch movingWall;
// Flip surface normals before usage.
flipNormals false;
// If construct from surface
surface "movingWall.sMesh";
// Do front and back need to be merged? Usually only makes sense for 360
// degree wedges.
mergeFaces true;
//- Linear extrusion in point-normal direction
//extrudeModel linearNormal;
//- Wedge extrusion. If nLayers is 1 assumes symmetry around plane.
extrudeModel wedge;
//- Extrudes into sphere around (0 0 0)
//extrudeModel linearRadial;
//- Extrudes into sphere with grading according to pressure (atmospherics)
//extrudeModel sigmaRadial;
nLayers 1;
nLayers 20;
wedgeCoeffs
{
axisPt (0 0 0);
axisNormal (0 -1 0);
angle 2.0;
axisPt (0 0.1 0);
axis (-1 0 0);
angle 360; // For nLayers=1 assume symmetry so angle/2 on each side
}
linearNormalCoeffs
{
thickness 0.1;
thickness 0.05;
}
linearRadialCoeffs

Some files were not shown because too many files have changed in this diff Show more