cfMesh clean-up: wrong location
This commit is contained in:
parent
b85d316382
commit
5d98ea3dea
90 changed files with 35 additions and 3358 deletions
|
@ -1,146 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | cfMesh: A library for mesh generation
|
||||
\\ / O peration |
|
||||
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
|
||||
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of cfMesh.
|
||||
|
||||
cfMesh 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 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Reads the AVL's surface mesh
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "foamTime.H"
|
||||
#include "triSurf.H"
|
||||
#include "triSurfModifier.H"
|
||||
#include "triFaceList.H"
|
||||
#include "labelLongList.H"
|
||||
#include "IFstream.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noParallel();
|
||||
argList::validArgs.clear();
|
||||
|
||||
argList::validArgs.append("input surface file");
|
||||
argList::validArgs.append("output surface file");
|
||||
argList args(argc, argv);
|
||||
|
||||
fileName inFileName(args.args()[1]);
|
||||
fileName outFileName(args.args()[2]);
|
||||
|
||||
if( inFileName.ext() != "flma" )
|
||||
{
|
||||
Info << "Cannot convert this mesh" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//- create the surface mesh
|
||||
triSurf ts;
|
||||
triSurfModifier tsm(ts);
|
||||
|
||||
label counter;
|
||||
|
||||
IFstream inFile(inFileName);
|
||||
|
||||
inFile >> counter;
|
||||
|
||||
//- read vertices
|
||||
pointField& points = tsm.pointsAccess();
|
||||
points.setSize(counter);
|
||||
forAll(points, pointI)
|
||||
{
|
||||
point& p = points[pointI];
|
||||
|
||||
inFile >> p.x();
|
||||
inFile >> p.y();
|
||||
inFile >> p.z();
|
||||
}
|
||||
|
||||
//- read facets
|
||||
inFile >> counter;
|
||||
geometricSurfacePatchList patches(1);
|
||||
patches[0].name() = "patch";
|
||||
LongList<labelledTri>& triangles = tsm.facetsAccess();
|
||||
triangles.setSize(counter);
|
||||
forAll(triangles, triI)
|
||||
{
|
||||
inFile >> counter;
|
||||
|
||||
if( counter != 3 )
|
||||
{
|
||||
Info << "Facet " << triI << " is not a triangle!!" << endl;
|
||||
Warning << "Cannot convert this surface!" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
for(label j=0;j<3;++j)
|
||||
inFile >> triangles[triI][2-j];
|
||||
|
||||
triangles[triI].region() = 0;
|
||||
}
|
||||
|
||||
//- read cell types
|
||||
inFile >> counter;
|
||||
forAll(triangles, triI)
|
||||
inFile >> counter;
|
||||
|
||||
//- start reading selections
|
||||
inFile >> counter;
|
||||
for(label selI=0;selI<counter;++selI)
|
||||
{
|
||||
//- read selection name
|
||||
word selName;
|
||||
inFile >> selName;
|
||||
|
||||
//- read selection type
|
||||
label selType;
|
||||
inFile >> selType;
|
||||
|
||||
//- read selection entries
|
||||
label size;
|
||||
inFile >> size;
|
||||
labelLongList entries(size);
|
||||
for(label i=0;i<size;++i)
|
||||
inFile >> entries[i];
|
||||
|
||||
//- store cell selections
|
||||
if( selType == 2 )
|
||||
{
|
||||
Info << "Adding subset " << selName << endl;
|
||||
const label setID = ts.addFacetSubset(selName);
|
||||
|
||||
forAll(entries, i)
|
||||
ts.addFacetToSubset(setID, entries[i]);
|
||||
}
|
||||
}
|
||||
|
||||
//- write the surface
|
||||
ts.writeSurface(outFileName);
|
||||
|
||||
Info << "End\n" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,3 +0,0 @@
|
|||
FLMAToSurface.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/FLMAToSurface
|
|
@ -1,166 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | cfMesh: A library for mesh generation
|
||||
\\ / O peration |
|
||||
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
|
||||
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of cfMesh.
|
||||
|
||||
cfMesh 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 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Creates surface patches from surface subsets
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "foamTime.H"
|
||||
#include "triSurf.H"
|
||||
#include "triSurfaceCopyParts.H"
|
||||
#include "demandDrivenData.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
void exportFeatureEdges
|
||||
(
|
||||
const triSurf& origSurf,
|
||||
const fileName& edgeFileName
|
||||
)
|
||||
{
|
||||
OFstream file(edgeFileName);
|
||||
|
||||
const pointField& points = origSurf.points();
|
||||
labelList newPointLabel(points.size(), -1);
|
||||
label nPoints(0);
|
||||
|
||||
const edgeLongList& featureEdges = origSurf.featureEdges();
|
||||
forAll(featureEdges, feI)
|
||||
{
|
||||
const edge& e = featureEdges[feI];
|
||||
|
||||
if( newPointLabel[e[0]] == -1 )
|
||||
newPointLabel[e[0]] = nPoints++;
|
||||
if( newPointLabel[e[1]] == -1 )
|
||||
newPointLabel[e[1]] = nPoints++;
|
||||
}
|
||||
|
||||
pointField pCopy(nPoints);
|
||||
forAll(newPointLabel, pI)
|
||||
{
|
||||
if( newPointLabel[pI] < 0 )
|
||||
continue;
|
||||
|
||||
pCopy[newPointLabel[pI]] = points[pI];
|
||||
}
|
||||
|
||||
//- write the header
|
||||
file << "# vtk DataFile Version 3.0\n";
|
||||
file << "vtk output\n";
|
||||
file << "ASCII\n";
|
||||
file << "DATASET POLYDATA\n";
|
||||
|
||||
//- write points
|
||||
file << "POINTS " << pCopy.size() << " float\n";
|
||||
forAll(pCopy, pI)
|
||||
{
|
||||
const point& p = pCopy[pI];
|
||||
file << p.x() << ' ' << p.y() << ' ' << p.z() << '\n';
|
||||
}
|
||||
|
||||
file << "\nLINES " << featureEdges.size()
|
||||
<< ' ' << 3*featureEdges.size() << nl;
|
||||
forAll(featureEdges, edgeI)
|
||||
{
|
||||
const edge& e = featureEdges[edgeI];
|
||||
file << "2 " << newPointLabel[e[0]]
|
||||
<< token::SPACE << newPointLabel[e[1]] << nl;
|
||||
}
|
||||
file << nl;
|
||||
|
||||
if( !file )
|
||||
FatalErrorIn
|
||||
(
|
||||
"void exportFeatureEdges(const triSurf&, const fileName&)"
|
||||
) << "Writting of feature edges failed!" << exit(FatalError);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noParallel();
|
||||
argList::validArgs.clear();
|
||||
|
||||
argList::validArgs.append("input surface file");
|
||||
argList::validArgs.append("output surface file");
|
||||
argList::validOptions.insert("exportSubsets", "");
|
||||
argList::validOptions.insert("exportFeatureEdges", "");
|
||||
argList args(argc, argv);
|
||||
|
||||
fileName inFileName(args.args()[1]);
|
||||
fileName outFileName(args.args()[2]);
|
||||
|
||||
fileName outFileNoExt = outFileName.lessExt();
|
||||
fileName outExtension = outFileName.ext();
|
||||
|
||||
Info << "Out file no ext " << outFileNoExt << endl;
|
||||
Info << "Extension " << outExtension << endl;
|
||||
|
||||
//- read the inout surface
|
||||
triSurf origSurf(inFileName);
|
||||
|
||||
//- write the surface in the requated format
|
||||
origSurf.writeSurface(outFileName);
|
||||
|
||||
//- export surface subsets as separate surface meshes
|
||||
if( args.options().found("exportSubsets") )
|
||||
{
|
||||
DynList<label> subsetIDs;
|
||||
origSurf.facetSubsetIndices(subsetIDs);
|
||||
|
||||
triSurfaceCopyParts copyParts(origSurf);
|
||||
|
||||
forAll(subsetIDs, subsetI)
|
||||
{
|
||||
//- get the name of the subset
|
||||
triSurf copySurf;
|
||||
wordList subsetName(1);
|
||||
subsetName[0] = origSurf.facetSubsetName(subsetIDs[subsetI]);
|
||||
|
||||
//- create a surface mesh corresponding to the subset
|
||||
copyParts.copySurface(subsetName, copySurf);
|
||||
|
||||
//- write the mesh on disk
|
||||
fileName fName = outFileNoExt+"_facetSubset_"+subsetName[0];
|
||||
fName += '.'+outExtension;
|
||||
|
||||
copySurf.writeSurface(fName);
|
||||
}
|
||||
}
|
||||
|
||||
if( args.options().found("exportFeatureEdges") )
|
||||
{
|
||||
fileName fName = outFileNoExt+"_featureEdges";
|
||||
fName += ".vtk";
|
||||
exportFeatureEdges(origSurf, fName);
|
||||
}
|
||||
|
||||
Info << "End\n" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,3 +0,0 @@
|
|||
FMSToSurface.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/FMSToSurface
|
|
@ -1,9 +0,0 @@
|
|||
EXE_INC = \
|
||||
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
|
||||
-I$(FOAM_SRC)/meshTools/lnInclude \
|
||||
-I$(FOAM_SRC)/edgeMesh/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lcfMesh \
|
||||
-lmeshTools \
|
||||
-ledgeMesh
|
|
@ -1,545 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | cfMesh: A library for mesh generation
|
||||
\\ / O peration |
|
||||
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
|
||||
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of cfMesh.
|
||||
|
||||
cfMesh 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 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
cfMesh utility to convert a surface file to VTK multiblock dataset
|
||||
format, including the patches, feature edges and surface features.
|
||||
|
||||
Author
|
||||
Ivor Clifford <ivor.clifford@psi.ch>
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "autoPtr.H"
|
||||
#include "OFstream.H"
|
||||
#include "triSurf.H"
|
||||
#include "triSurfModifier.H"
|
||||
#include "xmlTag.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Write the supplied pointList in serial vtkPolyData format
|
||||
void writePointsToVTK
|
||||
(
|
||||
const fileName& fn,
|
||||
const string& title,
|
||||
const UList<point>& points
|
||||
)
|
||||
{
|
||||
xmlTag xmlRoot("VTKFile");
|
||||
xmlRoot.addAttribute("type", "PolyData");
|
||||
|
||||
xmlTag& xmlPolyData = xmlRoot.addChild("PolyData");
|
||||
|
||||
xmlTag& xmlPiece = xmlPolyData.addChild("Piece");
|
||||
xmlPiece.addAttribute("NumberOfPoints", points.size());
|
||||
|
||||
xmlTag& xmlPoints = xmlPiece.addChild("Points");
|
||||
|
||||
xmlTag& xmlPointData = xmlPoints.addChild("DataArray");
|
||||
xmlPointData.addAttribute("type", "Float32");
|
||||
xmlPointData.addAttribute("NumberOfComponents", 3);
|
||||
xmlPointData.addAttribute("format", "ascii");
|
||||
xmlPointData << points;
|
||||
|
||||
OFstream os(fn);
|
||||
os << xmlRoot << endl;
|
||||
|
||||
Info << "Created " << fn << endl;
|
||||
}
|
||||
|
||||
|
||||
//- Write the supplied addressed pointList in serial vtkPolyData format
|
||||
void writePointsToVTK
|
||||
(
|
||||
const fileName& fn,
|
||||
const string& title,
|
||||
const UList<point>& points,
|
||||
unallocLabelList& addr
|
||||
)
|
||||
{
|
||||
// Create subaddressed points
|
||||
pointField newPoints(addr.size());
|
||||
|
||||
forAll(addr, i)
|
||||
{
|
||||
newPoints[i] = points[addr[i]];
|
||||
}
|
||||
|
||||
writePointsToVTK
|
||||
(
|
||||
fn,
|
||||
title,
|
||||
newPoints
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Write the supplied edgeList in serial vtkPolyData format
|
||||
void writeEdgesToVTK
|
||||
(
|
||||
const fileName& fn,
|
||||
const string& title,
|
||||
const UList<point>& points,
|
||||
const LongList<edge>& edges
|
||||
)
|
||||
{
|
||||
labelList connectivity(edges.size());
|
||||
|
||||
forAll(edges, edgeI)
|
||||
{
|
||||
connectivity[edgeI] = 2*(edgeI+1);
|
||||
}
|
||||
|
||||
xmlTag xmlRoot("VTKFile");
|
||||
xmlRoot.addAttribute("type", "PolyData");
|
||||
|
||||
xmlTag& xmlPolyData = xmlRoot.addChild("PolyData");
|
||||
|
||||
xmlTag& xmlPiece = xmlPolyData.addChild("Piece");
|
||||
xmlPiece.addAttribute("NumberOfPoints", points.size());
|
||||
xmlPiece.addAttribute("NumberOfLines", edges.size());
|
||||
|
||||
xmlTag& xmlPoints = xmlPiece.addChild("Points");
|
||||
|
||||
xmlTag& xmlPointData = xmlPoints.addChild("DataArray");
|
||||
xmlPointData.addAttribute("type", "Float32");
|
||||
xmlPointData.addAttribute("NumberOfComponents", 3);
|
||||
xmlPointData.addAttribute("format", "ascii");
|
||||
xmlPointData << points;
|
||||
|
||||
xmlTag& xmlEdges = xmlPiece.addChild("Lines");
|
||||
|
||||
xmlTag& xmlEdgeData = xmlEdges.addChild("DataArray");
|
||||
xmlEdgeData.addAttribute("type", "Int32");
|
||||
xmlEdgeData.addAttribute("Name", "connectivity");
|
||||
xmlEdgeData.addAttribute("format", "ascii");
|
||||
xmlEdgeData << edges;
|
||||
|
||||
xmlTag& xmlConnectData = xmlEdges.addChild("DataArray");
|
||||
xmlConnectData.addAttribute("type", "Int32");
|
||||
xmlConnectData.addAttribute("Name", "offsets");
|
||||
xmlConnectData.addAttribute("format", "ascii");
|
||||
xmlConnectData << connectivity;
|
||||
|
||||
OFstream os(fn);
|
||||
os << xmlRoot << endl;
|
||||
|
||||
Info << "Created " << fn << endl;
|
||||
}
|
||||
|
||||
//- Write the supplied edgeList subset in serial vtkPolyData format
|
||||
void writeEdgesToVTK
|
||||
(
|
||||
const fileName& fn,
|
||||
const string& title,
|
||||
const UList<point>& points,
|
||||
const LongList<edge>& edges,
|
||||
const unallocLabelList& addr
|
||||
)
|
||||
{
|
||||
// Remove unused points and create subaddressed edges
|
||||
DynamicList<point> newPoints;
|
||||
labelList newPointAddr(points.size(), -1);
|
||||
LongList<edge> newEdges(addr.size());
|
||||
|
||||
forAll(addr, addrI)
|
||||
{
|
||||
label edgeI = addr[addrI];
|
||||
|
||||
const edge& curEdge = edges[edgeI];
|
||||
edge& newEdge = newEdges[addrI];
|
||||
|
||||
forAll(curEdge, i)
|
||||
{
|
||||
label pointId = curEdge[i];
|
||||
|
||||
if (newPointAddr[pointId] == -1)
|
||||
{
|
||||
newPoints.append(points[pointId]);
|
||||
newPointAddr[pointId] = newPoints.size()-1;
|
||||
}
|
||||
|
||||
newEdge[i] = newPointAddr[pointId];
|
||||
}
|
||||
}
|
||||
|
||||
writeEdgesToVTK
|
||||
(
|
||||
fn,
|
||||
title,
|
||||
newPoints,
|
||||
newEdges
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Write the supplied facet list in serial vtkPolyData format
|
||||
void writeFacetsToVTK
|
||||
(
|
||||
const fileName& fn,
|
||||
const string& title,
|
||||
const UList<point>& points,
|
||||
const LongList<labelledTri>& facets
|
||||
)
|
||||
{
|
||||
labelList connectivity(facets.size());
|
||||
|
||||
forAll(facets, faceI)
|
||||
{
|
||||
connectivity[faceI] = 3*(faceI+1);
|
||||
}
|
||||
|
||||
labelList regionData(facets.size());
|
||||
|
||||
forAll(facets, faceI)
|
||||
{
|
||||
regionData[faceI] = facets[faceI].region();
|
||||
}
|
||||
|
||||
xmlTag xmlRoot("VTKFile");
|
||||
xmlRoot.addAttribute("type", "PolyData");
|
||||
|
||||
xmlTag& xmlPolyData = xmlRoot.addChild("PolyData");
|
||||
|
||||
xmlTag& xmlPiece = xmlPolyData.addChild("Piece");
|
||||
xmlPiece.addAttribute("NumberOfPoints", points.size());
|
||||
xmlPiece.addAttribute("NumberOfPolys", facets.size());
|
||||
|
||||
xmlTag& xmlPoints = xmlPiece.addChild("Points");
|
||||
|
||||
xmlTag& xmlPointData = xmlPoints.addChild("DataArray");
|
||||
xmlPointData.addAttribute("type", "Float32");
|
||||
xmlPointData.addAttribute("NumberOfComponents", 3);
|
||||
xmlPointData.addAttribute("format", "ascii");
|
||||
xmlPointData << points;
|
||||
|
||||
xmlTag& xmlPolys = xmlPiece.addChild("Polys");
|
||||
|
||||
xmlTag& xmlPolyDataArray = xmlPolys.addChild("DataArray");
|
||||
xmlPolyDataArray.addAttribute("type", "Int32");
|
||||
xmlPolyDataArray.addAttribute("Name", "connectivity");
|
||||
xmlPolyDataArray.addAttribute("format", "ascii");
|
||||
xmlPolyDataArray << facets;
|
||||
|
||||
xmlTag& xmlConnectData = xmlPolys.addChild("DataArray");
|
||||
xmlConnectData.addAttribute("type", "Int32");
|
||||
xmlConnectData.addAttribute("Name", "offsets");
|
||||
xmlConnectData.addAttribute("format", "ascii");
|
||||
xmlConnectData << connectivity;
|
||||
|
||||
xmlTag& xmlCellData = xmlPiece.addChild("CellData");
|
||||
|
||||
xmlTag& xmlCellDataArray = xmlCellData.addChild("DataArray");
|
||||
xmlCellDataArray.addAttribute("type", "Int32");
|
||||
xmlCellDataArray.addAttribute("Name", "region");
|
||||
xmlCellDataArray.addAttribute("format", "ascii");
|
||||
xmlCellDataArray << regionData;
|
||||
|
||||
OFstream os(fn);
|
||||
os << xmlRoot << endl;
|
||||
|
||||
Info << "Created " << fn << endl;
|
||||
}
|
||||
|
||||
|
||||
//- Write an addressed subset of the supplied facet list
|
||||
//- in serial vtkPolyData format
|
||||
void writeFacetsToVTK
|
||||
(
|
||||
const fileName& fn,
|
||||
const string& title,
|
||||
const pointField& points,
|
||||
const LongList<labelledTri>& facets,
|
||||
const unallocLabelList& addr
|
||||
)
|
||||
{
|
||||
// Remove unused points and create subaddressed facets
|
||||
DynamicList<point> newPoints;
|
||||
labelList newPointAddr(points.size(), -1);
|
||||
LongList<labelledTri> newFacets(addr.size());
|
||||
|
||||
forAll(addr, addrI)
|
||||
{
|
||||
label faceI = addr[addrI];
|
||||
|
||||
const labelledTri& facet = facets[faceI];
|
||||
const FixedList<label, 3>& pointIds = facet;
|
||||
FixedList<label, 3> newPointIds;
|
||||
|
||||
forAll(pointIds, i)
|
||||
{
|
||||
label pointId = pointIds[i];
|
||||
|
||||
if (newPointAddr[pointId] == -1)
|
||||
{
|
||||
newPoints.append(points[pointId]);
|
||||
newPointAddr[pointId] = newPoints.size()-1;
|
||||
}
|
||||
|
||||
newPointIds[i] = newPointAddr[pointId];
|
||||
}
|
||||
|
||||
newFacets[addrI] = labelledTri
|
||||
(
|
||||
newPointIds[0],
|
||||
newPointIds[1],
|
||||
newPointIds[2],
|
||||
facet.region()
|
||||
);
|
||||
}
|
||||
|
||||
writeFacetsToVTK
|
||||
(
|
||||
fn,
|
||||
title,
|
||||
newPoints,
|
||||
newFacets
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noParallel();
|
||||
argList::validArgs.clear();
|
||||
|
||||
argList::validArgs.append("input surface file");
|
||||
argList::validArgs.append("output prefix");
|
||||
argList args(argc, argv);
|
||||
|
||||
// Process commandline arguments
|
||||
fileName inFileName(args.args()[1]);
|
||||
fileName outPrefix(args.args()[2]);
|
||||
|
||||
// Read original surface
|
||||
triSurf origSurf(inFileName);
|
||||
|
||||
const pointField& points = origSurf.points();
|
||||
const LongList<labelledTri>& facets = origSurf.facets();
|
||||
const LongList<edge>& edges = origSurf.featureEdges();
|
||||
const geometricSurfacePatchList& patches = origSurf.patches();
|
||||
|
||||
label index = 0;
|
||||
|
||||
// Create file structure for multiblock dataset
|
||||
mkDir(outPrefix);
|
||||
mkDir(outPrefix + "/patches");
|
||||
mkDir(outPrefix + "/pointSubsets");
|
||||
mkDir(outPrefix + "/edgeSubsets");
|
||||
mkDir(outPrefix + "/faceSubsets");
|
||||
|
||||
// Create VTK multiblock dataset file
|
||||
xmlTag xmlRoot("VTKFile");
|
||||
xmlRoot.addAttribute("type", "vtkMultiBlockDataSet");
|
||||
xmlRoot.addAttribute("version", "1.0");
|
||||
xmlRoot.addAttribute("byte_order", "LittleEndian");
|
||||
|
||||
xmlTag& xmlDataSet = xmlRoot.addChild("vtkMultiBlockDataSet");
|
||||
|
||||
// Write faces and feature edges
|
||||
{
|
||||
fileName fn = outPrefix / "facets.vtp";
|
||||
|
||||
writeFacetsToVTK
|
||||
(
|
||||
outPrefix / "facets.vtp",
|
||||
outPrefix,
|
||||
points,
|
||||
facets
|
||||
);
|
||||
|
||||
xmlTag& tag = xmlDataSet.addChild("DataSet");
|
||||
tag.addAttribute("index", Foam::name(index++));
|
||||
tag.addAttribute("name", "facets");
|
||||
tag.addAttribute("file", fn);
|
||||
}
|
||||
|
||||
{
|
||||
fileName fn = outPrefix / "featureEdges.vtp";
|
||||
|
||||
writeEdgesToVTK
|
||||
(
|
||||
outPrefix / "featureEdges.vtp",
|
||||
"featureEdges",
|
||||
points,
|
||||
edges
|
||||
);
|
||||
|
||||
xmlTag& tag = xmlDataSet.addChild("DataSet");
|
||||
tag.addAttribute("index", Foam::name(index++));
|
||||
tag.addAttribute("name", "featureEdges");
|
||||
tag.addAttribute("file", fn);
|
||||
}
|
||||
|
||||
// Write patches
|
||||
// Create patch addressing
|
||||
List<DynamicList<label> > patchAddr(patches.size());
|
||||
|
||||
forAll(facets, faceI)
|
||||
{
|
||||
patchAddr[facets[faceI].region()].append(faceI);
|
||||
}
|
||||
|
||||
{
|
||||
xmlTag& xmlBlock = xmlDataSet.addChild("Block");
|
||||
xmlBlock.addAttribute("index", Foam::name(index++));
|
||||
xmlBlock.addAttribute("name", "patches");
|
||||
|
||||
forAll(patches, patchI)
|
||||
{
|
||||
word patchName = patches[patchI].name();
|
||||
|
||||
fileName fn = outPrefix / "patches" / patchName + ".vtp";
|
||||
|
||||
writeFacetsToVTK
|
||||
(
|
||||
fn,
|
||||
patchName,
|
||||
points,
|
||||
facets,
|
||||
patchAddr[patchI]
|
||||
);
|
||||
|
||||
xmlTag& tag = xmlBlock.addChild("DataSet");
|
||||
tag.addAttribute("index", Foam::name(patchI));
|
||||
tag.addAttribute("name", patchName);
|
||||
tag.addAttribute("file", fn);
|
||||
}
|
||||
}
|
||||
|
||||
// Write point subsets
|
||||
{
|
||||
xmlTag& xmlBlock = xmlDataSet.addChild("Block");
|
||||
xmlBlock.addAttribute("index", Foam::name(index++));
|
||||
xmlBlock.addAttribute("name", "pointSubsets");
|
||||
|
||||
DynList<label> subsetIndices;
|
||||
labelList subsetAddr;
|
||||
|
||||
origSurf.pointSubsetIndices(subsetIndices);
|
||||
|
||||
forAll(subsetIndices, id)
|
||||
{
|
||||
word subsetName = origSurf.pointSubsetName(id);
|
||||
origSurf.pointsInSubset(id, subsetAddr);
|
||||
|
||||
fileName fn = outPrefix / "pointSubsets" / subsetName + ".vtp";
|
||||
|
||||
writePointsToVTK
|
||||
(
|
||||
fn,
|
||||
subsetName,
|
||||
points,
|
||||
subsetAddr
|
||||
);
|
||||
|
||||
xmlTag& tag = xmlBlock.addChild("DataSet");
|
||||
tag.addAttribute("index", Foam::name(id));
|
||||
tag.addAttribute("name", subsetName);
|
||||
tag.addAttribute("file", fn);
|
||||
}
|
||||
}
|
||||
|
||||
// Write edge subsets
|
||||
{
|
||||
xmlTag& xmlBlock = xmlDataSet.addChild("Block");
|
||||
xmlBlock.addAttribute("index", Foam::name(index++));
|
||||
xmlBlock.addAttribute("name", "edgeSubsets");
|
||||
|
||||
DynList<label> subsetIndices;
|
||||
labelList subsetAddr;
|
||||
|
||||
origSurf.edgeSubsetIndices(subsetIndices);
|
||||
|
||||
forAll(subsetIndices, id)
|
||||
{
|
||||
word subsetName = origSurf.edgeSubsetName(id);
|
||||
origSurf.edgesInSubset(id, subsetAddr);
|
||||
|
||||
fileName fn = outPrefix / "edgeSubsets" / subsetName + ".vtp";
|
||||
|
||||
writeEdgesToVTK
|
||||
(
|
||||
fn,
|
||||
subsetName,
|
||||
points,
|
||||
edges,
|
||||
subsetAddr
|
||||
);
|
||||
|
||||
xmlTag& tag = xmlBlock.addChild("DataSet");
|
||||
tag.addAttribute("index", Foam::name(id));
|
||||
tag.addAttribute("name", subsetName);
|
||||
tag.addAttribute("file", fn);
|
||||
}
|
||||
}
|
||||
|
||||
// Write facet subsets
|
||||
{
|
||||
xmlTag& xmlBlock = xmlDataSet.addChild("Block");
|
||||
xmlBlock.addAttribute("index", Foam::name(index++));
|
||||
xmlBlock.addAttribute("name", "faceSubsets");
|
||||
|
||||
DynList<label> subsetIndices;
|
||||
labelList subsetAddr;
|
||||
|
||||
origSurf.facetSubsetIndices(subsetIndices);
|
||||
|
||||
forAll(subsetIndices, id)
|
||||
{
|
||||
word subsetName = origSurf.facetSubsetName(id);
|
||||
origSurf.facetsInSubset(id, subsetAddr);
|
||||
|
||||
fileName fn = outPrefix / "faceSubsets" / subsetName + ".vtp";
|
||||
|
||||
writeFacetsToVTK
|
||||
(
|
||||
fn,
|
||||
subsetName,
|
||||
points,
|
||||
facets,
|
||||
subsetAddr
|
||||
);
|
||||
|
||||
xmlTag& tag = xmlBlock.addChild("DataSet");
|
||||
tag.addAttribute("index", Foam::name(id));
|
||||
tag.addAttribute("name", subsetName);
|
||||
tag.addAttribute("file", fn);
|
||||
}
|
||||
}
|
||||
|
||||
OFstream os(outPrefix + ".vtm");
|
||||
os << xmlRoot << endl;
|
||||
|
||||
Info << "Created " << outPrefix + ".vtm" << endl;
|
||||
|
||||
Info << "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,3 +0,0 @@
|
|||
FMSToVTK.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/FMSToVTK
|
|
@ -1,9 +0,0 @@
|
|||
EXE_INC = \
|
||||
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
|
||||
-I$(FOAM_SRC)/meshTools/lnInclude \
|
||||
-I$(FOAM_SRC)/edgeMesh/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lcfMesh \
|
||||
-lmeshTools \
|
||||
-ledgeMesh
|
|
@ -1,297 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | foam-extend: Open Source CFD
|
||||
\\ / O peration |
|
||||
\\ / A nd | For copyright notice see file Copyright
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of foam-extend.
|
||||
|
||||
foam-extend 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 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::xmlTag
|
||||
|
||||
Description
|
||||
Simple XML tag class allowing child tags and attributes. Specialized
|
||||
output stream operators are provided to display or write the XML
|
||||
structure.
|
||||
|
||||
Author
|
||||
Ivor Clifford <ivor.clifford@psi.ch>
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef XMLtag_H
|
||||
#define XMLtag_H
|
||||
|
||||
#include "OStringStream.H"
|
||||
#include "HashTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class xmlTag Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class xmlTag
|
||||
:
|
||||
public OStringStream
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Tag name
|
||||
word name_;
|
||||
|
||||
//- Attributes
|
||||
HashTable<string> attributes_;
|
||||
|
||||
//- Child tags
|
||||
DynamicList<xmlTag> children_;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Null constructor
|
||||
xmlTag()
|
||||
:
|
||||
OStringStream(),
|
||||
name_("unknown"),
|
||||
attributes_(),
|
||||
children_()
|
||||
{}
|
||||
|
||||
//- Construct given tag name
|
||||
xmlTag(const word& name)
|
||||
:
|
||||
OStringStream(),
|
||||
name_(name),
|
||||
attributes_(),
|
||||
children_()
|
||||
{}
|
||||
|
||||
//- Construct as copy
|
||||
xmlTag(const xmlTag& tag)
|
||||
:
|
||||
OStringStream(tag),
|
||||
name_(tag.name_),
|
||||
attributes_(tag.attributes_),
|
||||
children_(tag.children_)
|
||||
{}
|
||||
|
||||
//- Destructor
|
||||
~xmlTag()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Add an attribute
|
||||
template<class T>
|
||||
void addAttribute(const keyType& key, const T& value)
|
||||
{
|
||||
OStringStream os;
|
||||
os << value;
|
||||
attributes_.insert(key, os.str());
|
||||
};
|
||||
|
||||
//- Add a fileName attribute
|
||||
void addAttribute(const keyType& key, const fileName& value)
|
||||
{
|
||||
attributes_.insert(key, value);
|
||||
};
|
||||
|
||||
//- Add a string attribute
|
||||
void addAttribute(const keyType& key, const string& value)
|
||||
{
|
||||
attributes_.insert(key, value);
|
||||
};
|
||||
|
||||
//- Add a word attribute
|
||||
void addAttribute(const keyType& key, const word& value)
|
||||
{
|
||||
attributes_.insert(key, value);
|
||||
};
|
||||
|
||||
//- Add a child
|
||||
xmlTag& addChild(const xmlTag& tag)
|
||||
{
|
||||
children_.append(tag);
|
||||
|
||||
return children_[children_.size()-1];
|
||||
};
|
||||
|
||||
//- Create and add a new child
|
||||
xmlTag& addChild(const word& name)
|
||||
{
|
||||
return addChild(xmlTag(name));
|
||||
}
|
||||
|
||||
// Member Operators
|
||||
|
||||
void operator=(const xmlTag& tag)
|
||||
{
|
||||
name_ = tag.name_;
|
||||
attributes_ = tag.attributes_;
|
||||
children_ = tag.children_;
|
||||
OStringStream::rewind();
|
||||
Foam::operator<<(*this, tag.str().c_str());
|
||||
};
|
||||
|
||||
// Friend IOstream Operators
|
||||
|
||||
friend Ostream& operator<<(Ostream&, const xmlTag&);
|
||||
|
||||
template<class Form, class Cmpt, int nCmpt>
|
||||
friend xmlTag& operator<<(xmlTag&, const VectorSpace<Form, Cmpt, nCmpt>&);
|
||||
|
||||
friend xmlTag& operator<<(xmlTag&, const labelledTri&);
|
||||
|
||||
template<class T, unsigned Size>
|
||||
friend xmlTag& operator<<(xmlTag&, const FixedList<T, Size>&);
|
||||
|
||||
template<class T>
|
||||
friend xmlTag& operator<<(xmlTag&, const LongList<T>&);
|
||||
|
||||
template<class T>
|
||||
friend xmlTag& operator<<(xmlTag&, const UList<T>&);
|
||||
};
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Write the tag in XML format to the supplied output stream
|
||||
Ostream& operator<<(Ostream& os, const xmlTag& tag)
|
||||
{
|
||||
// Tag name
|
||||
os << indent << '<' << tag.name_;
|
||||
|
||||
// Attributes and text
|
||||
for
|
||||
(
|
||||
HashTable<string>::const_iterator iter = tag.attributes_.cbegin();
|
||||
iter != tag.attributes_.cend();
|
||||
++iter
|
||||
)
|
||||
{
|
||||
os << token::SPACE << iter.key() << '=' << iter();
|
||||
}
|
||||
|
||||
if (tag.str().size() || tag.children_.size())
|
||||
{
|
||||
os << '>' << nl;
|
||||
|
||||
// Children
|
||||
os.incrIndent();
|
||||
|
||||
forAll(tag.children_, i)
|
||||
{
|
||||
os << tag.children_[i];
|
||||
}
|
||||
|
||||
os.decrIndent();
|
||||
|
||||
// Tag text
|
||||
os << tag.str().c_str();
|
||||
|
||||
// Close tag
|
||||
os << indent << "</" << tag.name_ << '>' << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Empty element tag
|
||||
os << "/>" << endl;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
//- Append the supplied data to the tag text
|
||||
template<class T>
|
||||
xmlTag& operator<<(xmlTag& tag, const UList<T>& data)
|
||||
{
|
||||
forAll(data, i)
|
||||
{
|
||||
tag << data[i] << token::SPACE;
|
||||
}
|
||||
|
||||
tag << nl;
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
//- Append the supplied data to the tag text
|
||||
template<class T>
|
||||
xmlTag& operator<<(xmlTag& tag, const LongList<T>& data)
|
||||
{
|
||||
forAll(data, i)
|
||||
{
|
||||
tag << data[i] << token::SPACE;
|
||||
}
|
||||
|
||||
tag << nl;
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
||||
//- Append the supplied data to the tag text
|
||||
template<class Form, class Cmpt, int nCmpt>
|
||||
xmlTag& operator<<(xmlTag& tag, const VectorSpace<Form, Cmpt, nCmpt>& data)
|
||||
{
|
||||
forAll(data, i)
|
||||
{
|
||||
tag << data[i] << token::SPACE;
|
||||
}
|
||||
|
||||
tag << nl;
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
//- Append the supplied data to the tag text
|
||||
template<class T, unsigned Size>
|
||||
xmlTag& operator<<(xmlTag& tag, const FixedList<T, Size>& data)
|
||||
{
|
||||
forAll(data, i)
|
||||
{
|
||||
tag << data[i] << token::SPACE;
|
||||
}
|
||||
|
||||
tag << nl;
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
//- Append the supplied data to the tag text
|
||||
xmlTag& operator<<(xmlTag& tag, const labelledTri& data)
|
||||
{
|
||||
const triFace& tFace = data;
|
||||
|
||||
return tag << tFace;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,3 +0,0 @@
|
|||
cartesian2DMesh.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/cartesian2DMesh
|
|
@ -1,61 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | cfMesh: A library for mesh generation
|
||||
\\ / O peration |
|
||||
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
|
||||
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of cfMesh.
|
||||
|
||||
cfMesh 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 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Application
|
||||
Generates cartesian mesh
|
||||
|
||||
Description
|
||||
Generates a 2D cartesian mesh
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "foamTime.H"
|
||||
#include "cartesian2DMeshGenerator.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
|
||||
//- 2d cartesian mesher cannot be run in parallel
|
||||
argList::noParallel();
|
||||
|
||||
cartesian2DMeshGenerator cmg(runTime);
|
||||
|
||||
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s\n"
|
||||
<< "ClockTime = " << runTime.elapsedClockTime() << " s" << endl;
|
||||
|
||||
cmg.writeMesh();
|
||||
|
||||
Info << "End\n" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,3 +0,0 @@
|
|||
cartesianMesh.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/cartesianMesh
|
|
@ -1,11 +0,0 @@
|
|||
EXE_INC = \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/edgeMesh/lnInclude \
|
||||
-I$(LIB_SRC)/mesh/cfMesh/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lmeshTools \
|
||||
-lfiniteVolume \
|
||||
-ledgeMesh \
|
||||
-lcfMesh
|
|
@ -1,59 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | cfMesh: A library for mesh generation
|
||||
\\ / O peration |
|
||||
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
|
||||
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of cfMesh.
|
||||
|
||||
cfMesh 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 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Application
|
||||
Generates cartesian mesh
|
||||
|
||||
Description
|
||||
- takes a triangulated surface and generates a cartesian mesh
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "objectRegistry.H"
|
||||
#include "foamTime.H"
|
||||
#include "cartesianMeshGenerator.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
|
||||
cartesianMeshGenerator cmg(runTime);
|
||||
|
||||
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s\n"
|
||||
<< "ClockTime = " << runTime.elapsedClockTime() << " s" << endl;
|
||||
|
||||
cmg.writeMesh();
|
||||
|
||||
Info << "End\n" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,3 +0,0 @@
|
|||
copySurfaceParts.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/copySurfaceParts
|
|
@ -1,80 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | cfMesh: A library for mesh generation
|
||||
\\ / O peration |
|
||||
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
|
||||
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of cfMesh.
|
||||
|
||||
cfMesh 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 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Finds feature edges and corners of a triangulated surface
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "IFstream.H"
|
||||
#include "fileName.H"
|
||||
#include "triSurf.H"
|
||||
#include "demandDrivenData.H"
|
||||
|
||||
#include "triSurfaceCopyParts.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
using namespace Foam;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noParallel();
|
||||
argList::validArgs.clear();
|
||||
argList::validArgs.append("input surface file");
|
||||
argList::validArgs.append("output surface file");
|
||||
argList::validArgs.append("patch/subset name");
|
||||
argList args(argc, argv);
|
||||
|
||||
const fileName inFileName(args.args()[1]);
|
||||
const fileName outFileName(args.args()[2]);
|
||||
|
||||
if( outFileName == inFileName )
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "Output file " << outFileName
|
||||
<< " would overwrite the input file."
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
wordList patches(1);
|
||||
patches[0] = args.args()[3];
|
||||
|
||||
triSurf originalSurface(inFileName);
|
||||
|
||||
triSurfaceCopyParts copyPart(originalSurface);
|
||||
|
||||
triSurf copy;
|
||||
|
||||
copyPart.copySurface(patches, copy);
|
||||
|
||||
copy.writeSurface(outFileName);
|
||||
|
||||
Info << "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,3 +0,0 @@
|
|||
extrudeEdgesInto2DSurface.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/extrudeEdgesInto2DSurface
|
|
@ -1,9 +0,0 @@
|
|||
EXE_INC = \
|
||||
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/edgeMesh/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lcfMesh \
|
||||
-lmeshTools \
|
||||
-ledgeMesh
|
|
@ -1,74 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | cfMesh: A library for mesh generation
|
||||
\\ / O peration |
|
||||
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
|
||||
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of cfMesh.
|
||||
|
||||
cfMesh 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 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Reads the surface mesh, remove the selected facets
|
||||
and writes the modified mesh into a new file
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "foamTime.H"
|
||||
#include "triSurf.H"
|
||||
#include "triSurfaceExtrude2DEdges.H"
|
||||
#include "demandDrivenData.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noParallel();
|
||||
argList::validArgs.clear();
|
||||
|
||||
argList::validArgs.append("input surface file");
|
||||
argList::validArgs.append("output surface file");
|
||||
|
||||
argList args(argc, argv);
|
||||
|
||||
fileName inFileName(args.args()[1]);
|
||||
fileName outFileName(args.args()[2]);
|
||||
|
||||
//- read the input surface
|
||||
triSurf origSurf(inFileName);
|
||||
|
||||
//- remove the selected facets
|
||||
triSurfaceExtrude2DEdges extruder(origSurf);
|
||||
|
||||
const triSurf* newSurfacePtr = extruder.extrudeSurface();
|
||||
|
||||
if( !newSurfacePtr )
|
||||
FatalError << "Extruding of the edge mesh failed!" << exit(FatalError);
|
||||
|
||||
//- write the modified surface mesh
|
||||
newSurfacePtr->writeSurface(outFileName);
|
||||
|
||||
deleteDemandDrivenData(newSurfacePtr);
|
||||
|
||||
Info << "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,9 +0,0 @@
|
|||
EXE_INC = \
|
||||
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/edgeMesh/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lcfMesh \
|
||||
-lmeshTools \
|
||||
-ledgeMesh
|
|
@ -1,3 +0,0 @@
|
|||
importSurfaceAsSubset.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/importSurfaceAsSubset
|
|
@ -1,9 +0,0 @@
|
|||
EXE_INC = \
|
||||
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/edgeMesh/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lcfMesh \
|
||||
-lmeshTools \
|
||||
-ledgeMesh
|
|
@ -1,84 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | cfMesh: A library for mesh generation
|
||||
\\ / O peration |
|
||||
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
|
||||
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of cfMesh.
|
||||
|
||||
cfMesh 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 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Finds feature edges and corners of a triangulated surface
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "IFstream.H"
|
||||
#include "fileName.H"
|
||||
#include "triSurf.H"
|
||||
#include "OFstream.H"
|
||||
#include "OSspecific.H"
|
||||
#include "demandDrivenData.H"
|
||||
#include "triSurfaceImportSurfaceAsSubset.H"
|
||||
#include <cstdlib>
|
||||
#include <sstream>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
using namespace Foam;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noParallel();
|
||||
argList::validArgs.clear();
|
||||
argList::validArgs.append("master surface file");
|
||||
argList::validArgs.append("import surface file");
|
||||
|
||||
argList args(argc, argv);
|
||||
|
||||
fileName inFileName(args.args()[1]);
|
||||
fileName importFileName(args.args()[2]);
|
||||
|
||||
triSurf originalSurface(inFileName);
|
||||
|
||||
triSurf importedSurface(importFileName);
|
||||
|
||||
triSurfaceImportSurfaceAsSubset importSurf(originalSurface);
|
||||
|
||||
importSurf.addSurfaceAsSubset(importedSurface, importFileName.lessExt());
|
||||
|
||||
if( inFileName.ext() == "fms" )
|
||||
{
|
||||
originalSurface.writeSurface(inFileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
fileName newName = inFileName.lessExt();
|
||||
newName.append(".fms");
|
||||
Warning << "Writting surface as " << newName
|
||||
<< " to preserve the subset!!" << endl;
|
||||
|
||||
originalSurface.writeSurface(newName);
|
||||
}
|
||||
|
||||
Info << "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,3 +0,0 @@
|
|||
improveSymmetryPlanes.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/improveSymmetryPlanes
|
|
@ -1,9 +0,0 @@
|
|||
EXE_INC = \
|
||||
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/edgeMesh/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lmeshTools \
|
||||
-ledgeMesh \
|
||||
-lcfMesh
|
|
@ -1,57 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | cfMesh: A library for mesh generation
|
||||
\\ / O peration |
|
||||
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
|
||||
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of cfMesh.
|
||||
|
||||
cfMesh 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 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Ensures that all mesh points belonging to a symmetryPlane are
|
||||
in a plane.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "foamTime.H"
|
||||
#include "polyMeshGenModifier.H"
|
||||
#include "symmetryPlaneOptimisation.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
|
||||
polyMeshGen pmg(runTime);
|
||||
pmg.read();
|
||||
|
||||
Info << "Starting optimisation of symmetry planes" << endl;
|
||||
symmetryPlaneOptimisation(pmg).optimizeSymmetryPlanes();
|
||||
|
||||
Info << "Writing mesh" << endl;
|
||||
pmg.write();
|
||||
|
||||
Info << "End\n" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,3 +0,0 @@
|
|||
mergeSurfacePatches.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/mergeSurfacePatches
|
|
@ -1,9 +0,0 @@
|
|||
EXE_INC = \
|
||||
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
|
||||
-I$(FOAM_SRC)/meshTools/lnInclude \
|
||||
-I$(FOAM_SRC)/edgeMesh/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lcfMesh \
|
||||
-lmeshTools \
|
||||
-ledgeMesh
|
|
@ -1,403 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | cfMesh: A library for mesh generation
|
||||
\\ / O peration |
|
||||
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
|
||||
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of cfMesh.
|
||||
|
||||
cfMesh 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 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
cfMesh utility to merge the supplied list of patches onto a single
|
||||
patch.
|
||||
|
||||
Author
|
||||
Ivor Clifford <ivor.clifford@psi.ch>
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "autoPtr.H"
|
||||
#include "foamTime.H"
|
||||
#include "triSurf.H"
|
||||
#include "triSurfModifier.H"
|
||||
#include "demandDrivenData.H"
|
||||
#include "Pair.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Find the supplied list of patch names and return a list of patch Ids
|
||||
void getPatchIds
|
||||
(
|
||||
const triSurf& origSurf,
|
||||
const wordList& patchNames,
|
||||
DynamicList<label>& patchIds
|
||||
)
|
||||
{
|
||||
const geometricSurfacePatchList& origPatches = origSurf.patches();
|
||||
|
||||
// Create patch name map
|
||||
HashSet<word> patchNameHash(patchNames);
|
||||
|
||||
// Find selected patches
|
||||
label nFound = 0;
|
||||
forAll(origPatches, patchI)
|
||||
{
|
||||
if (patchNameHash.found(origPatches[patchI].name()))
|
||||
{
|
||||
patchIds.append(patchI);
|
||||
nFound++;
|
||||
}
|
||||
}
|
||||
|
||||
if (nFound != patchNames.size())
|
||||
{
|
||||
WarningIn("getPatchIds")
|
||||
<< "Not all supplied patch names were found on the surface mesh" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Copy all face subsets from one triSurf to another
|
||||
void copyFaceSubsets
|
||||
(
|
||||
const triSurf& origSurf,
|
||||
triSurf& newSurf
|
||||
)
|
||||
{
|
||||
DynList<label> subsetIds;
|
||||
origSurf.facetSubsetIndices(subsetIds);
|
||||
|
||||
forAll(subsetIds, subsetI)
|
||||
{
|
||||
label newSubsetId = newSurf.addFacetSubset
|
||||
(
|
||||
origSurf.facetSubsetName(subsetI)
|
||||
);
|
||||
|
||||
labelList origFaces;
|
||||
origSurf.facetsInSubset(subsetI, origFaces);
|
||||
|
||||
forAll(origFaces, faceI)
|
||||
{
|
||||
newSurf.addFacetToSubset
|
||||
(
|
||||
newSubsetId,
|
||||
origFaces[faceI]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Copy all edge subsets from one triSurf to another
|
||||
void copyEdgeSubsets
|
||||
(
|
||||
const triSurf& origSurf,
|
||||
triSurf& newSurf
|
||||
)
|
||||
{
|
||||
DynList<label> subsetIds;
|
||||
origSurf.edgeSubsetIndices(subsetIds);
|
||||
|
||||
forAll(subsetIds, subsetI)
|
||||
{
|
||||
label newSubsetId = newSurf.addEdgeSubset
|
||||
(
|
||||
origSurf.edgeSubsetName(subsetI)
|
||||
);
|
||||
|
||||
labelList origEdges;
|
||||
origSurf.edgesInSubset(subsetI, origEdges);
|
||||
|
||||
forAll(origEdges, faceI)
|
||||
{
|
||||
newSurf.addEdgeToSubset
|
||||
(
|
||||
newSubsetId,
|
||||
origEdges[faceI]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Copy all point subsets from one triSurf to another
|
||||
void copyPointSubsets
|
||||
(
|
||||
const triSurf& origSurf,
|
||||
triSurf& newSurf
|
||||
)
|
||||
{
|
||||
DynList<label> subsetIds;
|
||||
origSurf.pointSubsetIndices(subsetIds);
|
||||
|
||||
forAll(subsetIds, subsetI)
|
||||
{
|
||||
label newSubsetId = newSurf.addPointSubset
|
||||
(
|
||||
origSurf.pointSubsetName(subsetI)
|
||||
);
|
||||
|
||||
labelList origPoints;
|
||||
origSurf.pointsInSubset(subsetI, origPoints);
|
||||
|
||||
forAll(origPoints, faceI)
|
||||
{
|
||||
newSurf.addPointToSubset
|
||||
(
|
||||
newSubsetId,
|
||||
origPoints[faceI]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Merge the supplied list of patchIds onto a new patch
|
||||
autoPtr<triSurf> mergeSurfacePatches
|
||||
(
|
||||
const triSurf& origSurf, // Surface
|
||||
const UList<label>& patchIds, // Ids of patches to merge
|
||||
const word& newPatchName, // Name of new (merged) patch
|
||||
bool keepPatches // Keep the original patches - they will be emptied
|
||||
)
|
||||
{
|
||||
const geometricSurfacePatchList& origPatches = origSurf.patches();
|
||||
const LongList<labelledTri>& origFacets = origSurf.facets();
|
||||
|
||||
label newPatchId = origPatches.size();
|
||||
|
||||
// Determine new patch type
|
||||
word newPatchType = origPatches[patchIds[0]].geometricType();
|
||||
|
||||
// Create patch addressing
|
||||
List<DynamicList<label> > patchAddr(origPatches.size()+1);
|
||||
|
||||
forAll(origFacets, faceI)
|
||||
{
|
||||
patchAddr[origFacets[faceI].region()].append(faceI);
|
||||
}
|
||||
|
||||
// Move selected patches to new patch
|
||||
forAll(patchIds, patchI)
|
||||
{
|
||||
patchAddr[newPatchId].append(patchAddr[patchIds[patchI]]);
|
||||
patchAddr[patchIds[patchI]].clear();
|
||||
}
|
||||
|
||||
// Create new facets list
|
||||
LongList<labelledTri> newFacets(origFacets.size());
|
||||
labelList newFaceAddr(origFacets.size(), -1);
|
||||
|
||||
label patchCount = 0;
|
||||
label faceI = 0;
|
||||
forAll(patchAddr, patchI)
|
||||
{
|
||||
const unallocLabelList& addr = patchAddr[patchI];
|
||||
|
||||
if(addr.size())
|
||||
{
|
||||
forAll(addr, i)
|
||||
{
|
||||
newFacets[faceI] = origFacets[addr[i]];
|
||||
newFacets[faceI].region() = patchCount;
|
||||
|
||||
newFaceAddr[addr[i]] = faceI;
|
||||
|
||||
faceI++;
|
||||
}
|
||||
}
|
||||
|
||||
if(addr.size() || keepPatches)
|
||||
{
|
||||
patchCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// Create new patch list
|
||||
geometricSurfacePatchList newPatches(patchCount);
|
||||
|
||||
patchCount = 0;
|
||||
forAll(origPatches, patchI)
|
||||
{
|
||||
// Only add patches if they contain faces
|
||||
if(patchAddr[patchI].size())
|
||||
{
|
||||
newPatches[patchCount] = origPatches[patchI];
|
||||
newPatches[patchCount].index() = patchCount;
|
||||
}
|
||||
|
||||
if(patchAddr[patchI].size() || keepPatches)
|
||||
{
|
||||
patchCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// Add new patch if it contains faces
|
||||
if(patchAddr[patchAddr.size()-1].size())
|
||||
{
|
||||
newPatches[patchCount] = geometricSurfacePatch
|
||||
(
|
||||
newPatchType,
|
||||
newPatchName,
|
||||
patchCount
|
||||
);
|
||||
}
|
||||
if(patchAddr[patchAddr.size()-1].size() || keepPatches)
|
||||
{
|
||||
patchCount++;
|
||||
}
|
||||
|
||||
// Create new surface
|
||||
autoPtr<triSurf> newSurf
|
||||
(
|
||||
new triSurf
|
||||
(
|
||||
newFacets,
|
||||
newPatches,
|
||||
origSurf.featureEdges(),
|
||||
origSurf.points()
|
||||
)
|
||||
);
|
||||
|
||||
// Transfer face subsets
|
||||
copyFaceSubsets(origSurf, newSurf());
|
||||
newSurf->updateFacetsSubsets(newFaceAddr);
|
||||
|
||||
// Transfer feature edge subsets
|
||||
copyEdgeSubsets(origSurf, newSurf());
|
||||
|
||||
// Transfer point subsets
|
||||
copyPointSubsets(origSurf, newSurf());
|
||||
|
||||
// Done
|
||||
return newSurf;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noParallel();
|
||||
argList::validArgs.clear();
|
||||
|
||||
argList::validArgs.append("input surface file");
|
||||
argList::validArgs.append("new patch");
|
||||
argList::validOptions.insert("patchNames", "list of names");
|
||||
argList::validOptions.insert("patchIds", "list of patchIds");
|
||||
argList::validOptions.insert("patchIdRange", "( start end )");
|
||||
argList::validOptions.insert("output", "file name (default overwrite)");
|
||||
argList::validOptions.insert("keep", "");
|
||||
argList args(argc, argv);
|
||||
|
||||
// Process commandline arguments
|
||||
fileName inFileName(args.args()[1]);
|
||||
|
||||
word newPatchName(args.args()[2]);
|
||||
|
||||
fileName outFileName(inFileName);
|
||||
|
||||
if( args.options().found("output") )
|
||||
{
|
||||
outFileName = args.options()["output"];
|
||||
}
|
||||
|
||||
bool keepPatches = false;
|
||||
|
||||
if( args.options().found("keep") )
|
||||
{
|
||||
keepPatches = true;
|
||||
}
|
||||
|
||||
// Read original surface
|
||||
triSurf origSurf(inFileName);
|
||||
|
||||
// Get patch ids
|
||||
DynamicList<label> patchIds;
|
||||
|
||||
if (args.options().found("patchNames"))
|
||||
{
|
||||
if (args.options().found("patchIds"))
|
||||
{
|
||||
FatalError() << "Cannot specify both patch names and ids"
|
||||
<< Foam::abort(FatalError);
|
||||
}
|
||||
|
||||
IStringStream is(args.options()["patchNames"]);
|
||||
wordList patchNames(is);
|
||||
|
||||
getPatchIds
|
||||
(
|
||||
origSurf,
|
||||
patchNames,
|
||||
patchIds
|
||||
);
|
||||
}
|
||||
if (args.options().found("patchIds"))
|
||||
{
|
||||
IStringStream is(args.options()["patchIds"]);
|
||||
|
||||
patchIds = labelList(is);
|
||||
}
|
||||
if (args.options().found("patchIds"))
|
||||
{
|
||||
IStringStream is(args.options()["patchIds"]);
|
||||
|
||||
patchIds.append(labelList(is));
|
||||
}
|
||||
if (args.options().found("patchIdRange"))
|
||||
{
|
||||
IStringStream is(args.options()["patchIdRange"]);
|
||||
|
||||
Pair<label> idRange(is);
|
||||
|
||||
for(label id = idRange.first(); id <= idRange.second(); id++)
|
||||
{
|
||||
patchIds.append(id);
|
||||
}
|
||||
}
|
||||
if (!patchIds.size())
|
||||
{
|
||||
FatalError() << "No patches specified"
|
||||
<< Foam::abort(FatalError);
|
||||
}
|
||||
|
||||
// Merge patches
|
||||
autoPtr<triSurf> newSurf = mergeSurfacePatches
|
||||
(
|
||||
origSurf,
|
||||
patchIds,
|
||||
newPatchName,
|
||||
keepPatches
|
||||
);
|
||||
|
||||
// Write new surface mesh
|
||||
newSurf->writeSurface(outFileName);
|
||||
|
||||
Info << "Original surface patches: " << origSurf.patches().size() << endl;
|
||||
Info << "Final surface patches: " << newSurf->patches().size() << endl;
|
||||
Info << "Surface written to " << outFileName << endl;
|
||||
|
||||
Info << "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,3 +0,0 @@
|
|||
meshToFPMA.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/meshToFPMA
|
|
@ -1,9 +0,0 @@
|
|||
EXE_INC = \
|
||||
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/edgeMesh/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lcfMesh \
|
||||
-ledgeMesh \
|
||||
-lmeshTools
|
|
@ -1,58 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | cfMesh: A library for mesh generation
|
||||
\\ / O peration |
|
||||
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
|
||||
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of cfMesh.
|
||||
|
||||
cfMesh 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 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Writes the mesh in fpma format readable by AVL's CfdWM
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "foamTime.H"
|
||||
#include "polyMeshGenModifier.H"
|
||||
#include "writeMeshFPMA.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
|
||||
polyMeshGen pmg(runTime);
|
||||
pmg.read();
|
||||
|
||||
if( Pstream::parRun() )
|
||||
{
|
||||
polyMeshGenModifier(pmg).addBufferCells();
|
||||
createFIRESelections(pmg);
|
||||
}
|
||||
|
||||
writeMeshFPMA(pmg, "convertedMesh");
|
||||
|
||||
Info << "End\n" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,11 +0,0 @@
|
|||
EXE_INC = \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/edgeMesh/lnInclude \
|
||||
-I$(LIB_SRC)/mesh/cfMesh/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lmeshTools \
|
||||
-lfiniteVolume \
|
||||
-ledgeMesh \
|
||||
-lcfMesh
|
|
@ -1,3 +0,0 @@
|
|||
patchesToSubsets.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/patchesToSubsets
|
|
@ -1,9 +0,0 @@
|
|||
EXE_INC = \
|
||||
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/edgeMesh/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lcfMesh \
|
||||
-lmeshTools \
|
||||
-ledgeMesh
|
|
@ -1,84 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | cfMesh: A library for mesh generation
|
||||
\\ / O peration |
|
||||
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
|
||||
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of cfMesh.
|
||||
|
||||
cfMesh 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 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Converts specified patches into subsets
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "foamTime.H"
|
||||
#include "triSurf.H"
|
||||
#include "triFaceList.H"
|
||||
#include "labelLongList.H"
|
||||
#include "IFstream.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noParallel();
|
||||
argList::validArgs.clear();
|
||||
|
||||
argList::validArgs.append("input surface file");
|
||||
argList::validArgs.append("output surface file");
|
||||
argList args(argc, argv);
|
||||
|
||||
fileName inFileName(args.args()[1]);
|
||||
fileName outFileName(args.args()[2]);
|
||||
|
||||
if( outFileName.ext() != "fms" )
|
||||
Warning << "The subsets cann only be saved in the .fms format" << endl;
|
||||
|
||||
triSurf origSurf(inFileName);
|
||||
|
||||
wordList patchNames(origSurf.patches().size());
|
||||
forAll(origSurf.patches(), patchI)
|
||||
patchNames[patchI] = origSurf.patches()[patchI].name();
|
||||
|
||||
forAll(patchNames, patchI)
|
||||
{
|
||||
labelLongList subsetFacets;
|
||||
forAll(origSurf, triI)
|
||||
{
|
||||
if( origSurf[triI].region() == patchI )
|
||||
subsetFacets.append(triI);
|
||||
}
|
||||
|
||||
const label subsetId = origSurf.addFacetSubset(patchNames[patchI]);
|
||||
|
||||
forAll(subsetFacets, i)
|
||||
origSurf.addFacetToSubset(subsetId, subsetFacets[i]);
|
||||
}
|
||||
|
||||
origSurf.writeSurface(outFileName);
|
||||
|
||||
Info << "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,3 +0,0 @@
|
|||
preparePar.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/preparePar
|
|
@ -1,9 +0,0 @@
|
|||
EXE_INC = \
|
||||
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
|
||||
-I$(FOAM_SRC)/meshTools/lnInclude \
|
||||
-I$(FOAM_SRC)/edgeMesh/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lcfMesh \
|
||||
-lmeshTools \
|
||||
-ledgeMesh
|
|
@ -1,100 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | cfMesh: A library for mesh generation
|
||||
\\ / O peration |
|
||||
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
|
||||
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of cfMesh.
|
||||
|
||||
cfMesh 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 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Application
|
||||
Prepares the case for a parallel mesh generation run
|
||||
|
||||
Description
|
||||
- creates processor* directories which contain data for processors
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "foamTime.H"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
|
||||
IOdictionary meshDict
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"meshDict",
|
||||
runTime.system(),
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
IOdictionary decomposeParDict
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"decomposeParDict",
|
||||
runTime.system(),
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
const label nProcessors
|
||||
(
|
||||
readLabel(decomposeParDict.lookup("numberOfSubdomains"))
|
||||
);
|
||||
|
||||
for(label procI=0;procI<nProcessors;++procI)
|
||||
{
|
||||
fileName file("processor");
|
||||
std::ostringstream ss;
|
||||
ss << procI;
|
||||
file += ss.str();
|
||||
Info << "Creating " << file << endl;
|
||||
|
||||
//- create a directory for processor data
|
||||
mkDir(runTime.path()/file);
|
||||
|
||||
//- copy the contents of the const directory into processor*
|
||||
cp(runTime.path()/"constant", runTime.path()/file);
|
||||
|
||||
//- generate 0 directories for
|
||||
mkDir(runTime.path()/file/"0");
|
||||
}
|
||||
|
||||
Info << "End\n" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,3 +0,0 @@
|
|||
removeSurfaceFacets.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/removeSurfaceFacets
|
|
@ -1,9 +0,0 @@
|
|||
EXE_INC = \
|
||||
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/edgeMesh/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lcfMesh \
|
||||
-lmeshTools \
|
||||
-ledgeMesh
|
|
@ -1,72 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | cfMesh: A library for mesh generation
|
||||
\\ / O peration |
|
||||
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
|
||||
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of cfMesh.
|
||||
|
||||
cfMesh 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 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Reads the surface mesh, remove the selected facets
|
||||
and writes the modified mesh into a new file
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "foamTime.H"
|
||||
#include "triSurf.H"
|
||||
#include "triSurfaceRemoveFacets.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noParallel();
|
||||
argList::validArgs.clear();
|
||||
|
||||
argList::validArgs.append("input surface file");
|
||||
argList::validArgs.append("output surface file");
|
||||
argList::validArgs.append("Subset/patch name");
|
||||
|
||||
argList args(argc, argv);
|
||||
|
||||
fileName inFileName(args.args()[1]);
|
||||
fileName outFileName(args.args()[2]);
|
||||
word patchName(args.args()[3]);
|
||||
|
||||
//- read the input surface
|
||||
triSurf origSurf(inFileName);
|
||||
|
||||
//- remove the selected facets
|
||||
triSurfaceRemoveFacets rsf(origSurf);
|
||||
|
||||
rsf.selectFacetsInPatch(patchName);
|
||||
|
||||
rsf.removeFacets();
|
||||
|
||||
//- write the modified surface mesh
|
||||
origSurf.writeSurface(outFileName);
|
||||
|
||||
Info << "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,9 +0,0 @@
|
|||
EXE_INC = \
|
||||
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/edgeMesh/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lcfMesh \
|
||||
-lmeshTools \
|
||||
-ledgeMesh
|
|
@ -1,3 +0,0 @@
|
|||
subsetToPatch.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/subsetToPatch
|
|
@ -1,9 +0,0 @@
|
|||
EXE_INC = \
|
||||
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
|
||||
-I$(FOAM_SRC)/meshTools/lnInclude \
|
||||
-I$(FOAM_SRC)/edgeMesh/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lcfMesh \
|
||||
-lmeshTools \
|
||||
-ledgeMesh
|
|
@ -1,170 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | cfMesh: A library for mesh generation
|
||||
\\ / O peration |
|
||||
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
|
||||
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of cfMesh.
|
||||
|
||||
cfMesh 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 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Creates surface patches from surface subsets
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "foamTime.H"
|
||||
#include "triSurf.H"
|
||||
#include "demandDrivenData.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
void makePatchFromSubset
|
||||
(
|
||||
triSurf& origSurf,
|
||||
const DynList<word>& subsetNames
|
||||
)
|
||||
{
|
||||
//- create new list of patches
|
||||
geometricSurfacePatchList newPatches
|
||||
(
|
||||
origSurf.patches().size() + subsetNames.size()
|
||||
);
|
||||
|
||||
//- set names of the new patches
|
||||
forAll(origSurf.patches(), patchI)
|
||||
newPatches[patchI].name() = origSurf.patches()[patchI].name();
|
||||
|
||||
forAll(subsetNames, subsetI)
|
||||
newPatches[origSurf.patches().size()+subsetI].name() =
|
||||
subsetNames[subsetI];
|
||||
|
||||
//- create new triangles
|
||||
LongList<labelledTri> newTriangles(origSurf.facets());
|
||||
|
||||
//- set patches for all triangles
|
||||
forAll(subsetNames, subsetI)
|
||||
{
|
||||
const label subsetID = origSurf.facetSubsetIndex(subsetNames[subsetI]);
|
||||
|
||||
labelLongList subsetFaces;
|
||||
origSurf.facetsInSubset(subsetID, subsetFaces);
|
||||
|
||||
const label regionI = origSurf.patches().size() + subsetI;
|
||||
|
||||
forAll(subsetFaces, fI)
|
||||
{
|
||||
newTriangles[subsetFaces[fI]].region() = regionI;
|
||||
}
|
||||
}
|
||||
|
||||
//- remove patches with no elements
|
||||
labelList nTrianglesInPatch(newPatches.size(), 0);
|
||||
forAll(newTriangles, triI)
|
||||
++nTrianglesInPatch[newTriangles[triI].region()];
|
||||
|
||||
Map<label> newPatchLabel;
|
||||
label counter(0);
|
||||
forAll(nTrianglesInPatch, patchI)
|
||||
{
|
||||
if( nTrianglesInPatch[patchI] )
|
||||
newPatchLabel.insert(patchI, counter++);
|
||||
}
|
||||
|
||||
geometricSurfacePatchList copyPatches(counter);
|
||||
counter = 0;
|
||||
forAll(newPatches, patchI)
|
||||
{
|
||||
if( newPatchLabel.found(patchI) )
|
||||
{
|
||||
copyPatches[newPatchLabel[patchI]].name() =
|
||||
newPatches[patchI].name();
|
||||
}
|
||||
}
|
||||
|
||||
newPatches = copyPatches;
|
||||
|
||||
//- renumber the patches in the list of triangles
|
||||
forAll(newTriangles, triI)
|
||||
newTriangles[triI].region() =
|
||||
newPatchLabel[newTriangles[triI].region()];
|
||||
|
||||
//- delete subsets converted to patches
|
||||
forAll(subsetNames, subsetI)
|
||||
{
|
||||
const label subsetID = origSurf.facetSubsetIndex(subsetNames[subsetI]);
|
||||
origSurf.removeFacetSubset(subsetID);
|
||||
}
|
||||
|
||||
//- update subsets
|
||||
origSurf.updateFacetsSubsets(newPatchLabel);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noParallel();
|
||||
argList::validArgs.clear();
|
||||
|
||||
argList::validArgs.append("input surface file");
|
||||
argList::validArgs.append("subset");
|
||||
argList args(argc, argv);
|
||||
|
||||
fileName inFileName(args.args()[1]);
|
||||
word subsetName(args.args()[2]);
|
||||
|
||||
triSurf* origSurfPtr = new triSurf(inFileName);
|
||||
|
||||
DynList<word> subsetNames;
|
||||
const label subsetID = origSurfPtr->facetSubsetIndex(subsetName);
|
||||
if( subsetID >= 0 )
|
||||
{
|
||||
Warning << "Subset " << subsetName
|
||||
<< " checking subsets containing this string!" << endl;
|
||||
|
||||
DynList<label> existingSubsets;
|
||||
origSurfPtr->facetSubsetIndices(existingSubsets);
|
||||
|
||||
forAll(existingSubsets, subsetI)
|
||||
{
|
||||
const word sName =
|
||||
origSurfPtr->facetSubsetName(existingSubsets[subsetI]);
|
||||
|
||||
if( sName.substr(0, subsetName.size()) == subsetName )
|
||||
{
|
||||
subsetNames.append(sName);
|
||||
}
|
||||
}
|
||||
|
||||
Info << "Converting " << subsetNames.size() << " subsets" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
subsetNames.append(subsetName);
|
||||
}
|
||||
|
||||
makePatchFromSubset(*origSurfPtr, subsetNames);
|
||||
origSurfPtr->writeSurface(inFileName);
|
||||
deleteDemandDrivenData(origSurfPtr);
|
||||
|
||||
Info << "End\n" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,3 +0,0 @@
|
|||
surfaceFeatureEdges.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/surfaceFeatureEdges
|
|
@ -1,9 +0,0 @@
|
|||
EXE_INC = \
|
||||
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/edgeMesh/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lcfMesh \
|
||||
-lmeshTools \
|
||||
-ledgeMesh
|
|
@ -1,104 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | cfMesh: A library for mesh generation
|
||||
\\ / O peration |
|
||||
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
|
||||
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of cfMesh.
|
||||
|
||||
cfMesh 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 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Finds feature edges and corners of a triangulated surface
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "IFstream.H"
|
||||
#include "fileName.H"
|
||||
#include "triSurf.H"
|
||||
#include "OFstream.H"
|
||||
#include "OSspecific.H"
|
||||
#include "demandDrivenData.H"
|
||||
#include <cstdlib>
|
||||
#include <sstream>
|
||||
|
||||
#include "triSurfaceDetectFeatureEdges.H"
|
||||
#include "triSurfacePatchManipulator.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
using namespace Foam;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noParallel();
|
||||
argList::validArgs.clear();
|
||||
argList::validArgs.append("input surface file");
|
||||
argList::validArgs.append("output surface file");
|
||||
argList::validOptions.insert("angle", "scalar");
|
||||
argList args(argc, argv);
|
||||
|
||||
fileName inFileName(args.args()[1]);
|
||||
fileName outFileName(args.args()[2]);
|
||||
|
||||
if (outFileName == inFileName)
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "Output file " << outFileName
|
||||
<< " would overwrite the input file."
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
scalar tol(45.0);
|
||||
if( args.options().found("angle") )
|
||||
{
|
||||
const scalar ang = readScalar(IStringStream(args.options()["angle"])());
|
||||
tol = ang;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info << "Using 45 deg as default angle!" << endl;
|
||||
}
|
||||
|
||||
triSurf originalSurface(inFileName);
|
||||
|
||||
triSurfaceDetectFeatureEdges edgeDetector(originalSurface, tol);
|
||||
edgeDetector.detectFeatureEdges();
|
||||
|
||||
if( outFileName.ext() == "fms" || outFileName.ext() == "FMS" )
|
||||
{
|
||||
Info << "Writing : " << outFileName << endl;
|
||||
originalSurface.writeSurface(outFileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
triSurfacePatchManipulator manipulator(originalSurface);
|
||||
const triSurf* newSurfPtr = manipulator.surfaceWithPatches();
|
||||
|
||||
Info << "Writing : " << outFileName << endl;
|
||||
newSurfPtr->writeSurface(outFileName);
|
||||
|
||||
deleteDemandDrivenData(newSurfPtr);
|
||||
}
|
||||
|
||||
Info << "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,3 +0,0 @@
|
|||
surfaceGenerateBoundingBox.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/surfaceGenerateBoundingBox
|
|
@ -1,9 +0,0 @@
|
|||
EXE_INC = \
|
||||
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/edgeMesh/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-ledgeMesh \
|
||||
-lcfMesh \
|
||||
-lmeshTools
|
|
@ -1,178 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | cfMesh: A library for mesh generation
|
||||
\\ / O peration |
|
||||
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
|
||||
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of cfMesh.
|
||||
|
||||
cfMesh 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 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Finds feature edges and corners of a triangulated surface
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "IFstream.H"
|
||||
#include "fileName.H"
|
||||
#include "triSurf.H"
|
||||
#include "triSurfModifier.H"
|
||||
#include "boundBox.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <sstream>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
using namespace Foam;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noParallel();
|
||||
argList::validArgs.clear();
|
||||
argList::validArgs.append("input surface file");
|
||||
argList::validArgs.append("output surface file");
|
||||
argList::validArgs.append("x-neg");
|
||||
argList::validArgs.append("x-pos");
|
||||
argList::validArgs.append("y-neg");
|
||||
argList::validArgs.append("y-pos");
|
||||
argList::validArgs.append("z-neg");
|
||||
argList::validArgs.append("z-pos");
|
||||
|
||||
argList args(argc, argv);
|
||||
|
||||
fileName inFileName(args.args()[1]);
|
||||
fileName outFileName(args.args()[2]);
|
||||
|
||||
if (outFileName == inFileName)
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "Output file " << outFileName
|
||||
<< " would overwrite the input file."
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
triSurf origSurface(inFileName);
|
||||
triSurfModifier sMod(origSurface);
|
||||
pointField& points = sMod.pointsAccess();
|
||||
|
||||
const boundBox bb(points);
|
||||
|
||||
vector negOffset, posOffset;
|
||||
for(label i=3;i<9;++i)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << args.args()[i];
|
||||
|
||||
scalar s;
|
||||
ss >> s;
|
||||
|
||||
if( i % 2 )
|
||||
{
|
||||
negOffset[(i-3)/2] = s;
|
||||
}
|
||||
else
|
||||
{
|
||||
posOffset[(i-3)/2] = s;
|
||||
}
|
||||
}
|
||||
|
||||
Info << "Neg offset " << negOffset << endl;
|
||||
Info << "Pos offset " << posOffset << endl;
|
||||
|
||||
const boundBox newBB(bb.min()-negOffset, bb.max()+posOffset);
|
||||
Info << "Surface bounding box " << bb << endl;
|
||||
Info << "Generated bounding box " << newBB << endl;
|
||||
|
||||
//- generate bounding box points
|
||||
const label nPoints = points.size();
|
||||
points.setSize(nPoints + 8);
|
||||
|
||||
points[nPoints] = newBB.min();
|
||||
points[nPoints+1] =
|
||||
point(newBB.max().x(), newBB.min().y(), newBB.min().z());
|
||||
points[nPoints+2] =
|
||||
point(newBB.min().x(), newBB.max().y(), newBB.min().z());
|
||||
points[nPoints+3] =
|
||||
point(newBB.max().x(), newBB.max().y(), newBB.min().z());
|
||||
points[nPoints+4] =
|
||||
point(newBB.min().x(), newBB.min().y(), newBB.max().z());
|
||||
points[nPoints+5] =
|
||||
point(newBB.max().x(), newBB.min().y(), newBB.max().z());
|
||||
points[nPoints+6] =
|
||||
point(newBB.min().x(), newBB.max().y(), newBB.max().z());
|
||||
points[nPoints+7] = newBB.max();
|
||||
|
||||
//- generate bounding bound triangles
|
||||
const label nTriangles = origSurface.size();
|
||||
LongList<labelledTri>& newTriangles = sMod.facetsAccess();
|
||||
newTriangles.setSize(nTriangles+12);
|
||||
|
||||
//- create patches
|
||||
geometricSurfacePatchList& newPatches = sMod.patchesAccess();
|
||||
const label nPatches = origSurface.patches().size();
|
||||
newPatches.setSize(nPatches+6);
|
||||
|
||||
newPatches[nPatches].name() = "xMin";
|
||||
newPatches[nPatches+1].name() = "xMax";
|
||||
newPatches[nPatches+2].name() = "yMin";
|
||||
newPatches[nPatches+3].name() = "yMax";
|
||||
newPatches[nPatches+4].name() = "zMin";
|
||||
newPatches[nPatches+5].name() = "zMax";
|
||||
|
||||
//- negative x direction
|
||||
newTriangles[nTriangles] =
|
||||
labelledTri(nPoints, nPoints+6, nPoints+2, nPatches);
|
||||
newTriangles[nTriangles+1] =
|
||||
labelledTri(nPoints, nPoints+4, nPoints+6, nPatches);
|
||||
//- positive x direction
|
||||
newTriangles[nTriangles+2] =
|
||||
labelledTri(nPoints+1, nPoints+3, nPoints+7, nPatches+1);
|
||||
newTriangles[nTriangles+3] =
|
||||
labelledTri(nPoints+1, nPoints+7, nPoints+5, nPatches+1);
|
||||
//- negative y direction
|
||||
newTriangles[nTriangles+4] =
|
||||
labelledTri(nPoints, nPoints+1, nPoints+5, nPatches+2);
|
||||
newTriangles[nTriangles+5] =
|
||||
labelledTri(nPoints, nPoints+5, nPoints+4, nPatches+2);
|
||||
//- positive y direction
|
||||
newTriangles[nTriangles+6] =
|
||||
labelledTri(nPoints+2, nPoints+7, nPoints+3, nPatches+3);
|
||||
newTriangles[nTriangles+7] =
|
||||
labelledTri(nPoints+2, nPoints+6, nPoints+7, nPatches+3);
|
||||
//- negative z direction
|
||||
newTriangles[nTriangles+8] =
|
||||
labelledTri(nPoints, nPoints+2, nPoints+3, nPatches+4);
|
||||
newTriangles[nTriangles+9] =
|
||||
labelledTri(nPoints, nPoints+3, nPoints+1, nPatches+4);
|
||||
//- positive z direction
|
||||
newTriangles[nTriangles+10] =
|
||||
labelledTri(nPoints+4, nPoints+7, nPoints+6, nPatches+5);
|
||||
newTriangles[nTriangles+11] =
|
||||
labelledTri(nPoints+4, nPoints+5, nPoints+7, nPatches+5);
|
||||
|
||||
//- write the surface
|
||||
origSurface.writeSurface(outFileName);
|
||||
|
||||
Info << "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,3 +0,0 @@
|
|||
surfaceToFMS.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/surfaceToFMS
|
|
@ -1,9 +0,0 @@
|
|||
EXE_INC = \
|
||||
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/edgeMesh/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lcfMesh \
|
||||
-lmeshTools \
|
||||
-ledgeMesh
|
|
@ -1,63 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | cfMesh: A library for mesh generation
|
||||
\\ / O peration |
|
||||
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
|
||||
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of cfMesh.
|
||||
|
||||
cfMesh 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 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Reads the specified surface and writes it in the fms format.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "IFstream.H"
|
||||
#include "fileName.H"
|
||||
#include "triSurf.H"
|
||||
#include "demandDrivenData.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
using namespace Foam;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noParallel();
|
||||
argList::validArgs.clear();
|
||||
argList::validArgs.append("input surface file");
|
||||
argList args(argc, argv);
|
||||
|
||||
const fileName inFileName(args.args()[1]);
|
||||
if( inFileName.ext() == "fms" )
|
||||
FatalError << "trying to convert a fms file to itself"
|
||||
<< exit(FatalError);
|
||||
|
||||
fileName outFileName(inFileName.lessExt()+".fms");
|
||||
|
||||
const triSurf surface(inFileName);
|
||||
|
||||
surface.writeSurface(outFileName);
|
||||
|
||||
Info << "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,3 +0,0 @@
|
|||
tetMesh.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/tetMesh
|
|
@ -1,11 +0,0 @@
|
|||
EXE_INC = \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/edgeMesh/lnInclude \
|
||||
-I$(LIB_SRC)/mesh/cfMesh/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lmeshTools \
|
||||
-lfiniteVolume \
|
||||
-ledgeMesh \
|
||||
-lcfMesh
|
|
@ -1,61 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | cfMesh: A library for mesh generation
|
||||
\\ / O peration |
|
||||
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
|
||||
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of cfMesh.
|
||||
|
||||
cfMesh 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 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Application
|
||||
Generates tetrahedral mesh
|
||||
|
||||
Description
|
||||
- takes a triangulated surface and generates a tetrahedral mesh
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "foamTime.H"
|
||||
#include "tetMeshGenerator.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
|
||||
//- tetrahedral mesher cannot be run in parallel yet
|
||||
argList::noParallel();
|
||||
|
||||
tetMeshGenerator tmg(runTime);
|
||||
|
||||
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s\n"
|
||||
<< "ClockTime = " << runTime.elapsedClockTime() << endl;
|
||||
|
||||
tmg.writeMesh();
|
||||
|
||||
Info << "End\n" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
|
@ -3,4 +3,5 @@ EXE_INC = \
|
|||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lcfMesh -lmeshTools
|
||||
-lcfMesh \
|
||||
-lmeshTools
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
EXE_INC = \
|
||||
-I$(FOAM_SRC)/mesh/cfMesh/lnInclude \
|
||||
-I$(FOAM_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lmeshTools \
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
EXE_INC = \
|
||||
-I$(FOAM_SRC)/mesh/cfMesh/lnInclude \
|
||||
-I$(FOAM_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lcfMesh \
|
||||
|
|
|
@ -1,217 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | foam-extend: Open Source CFD
|
||||
\\ / O peration | Version: 3.2
|
||||
\\ / A nd | Web: http://www.foam-extend.org
|
||||
\\/ M anipulation | For copyright notice see file Copyright
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of foam-extend.
|
||||
|
||||
foam-extend 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 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Writes the mesh in fpma format readable by AVL's CfdWM
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "objectRegistry.H"
|
||||
#include "foamTime.H"
|
||||
#include "polyMeshGenModifier.H"
|
||||
#include "IFstream.H"
|
||||
|
||||
#include "Map.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
|
||||
fileName inFileName;
|
||||
|
||||
Info << "Reading mesh from file " << endl;
|
||||
cin >> inFileName;
|
||||
|
||||
IFstream file(inFileName);
|
||||
|
||||
polyMeshGen pmg(runTime);
|
||||
polyMeshGenModifier meshModifier(pmg);
|
||||
|
||||
label counter;
|
||||
|
||||
//- read the number of vertices
|
||||
pointFieldPMG& points = meshModifier.pointsAccess();
|
||||
file >> counter;
|
||||
|
||||
//- read points from file
|
||||
points.setSize(counter);
|
||||
forAll(points, pointI)
|
||||
{
|
||||
point p;
|
||||
file >> p.x();
|
||||
file >> p.y();
|
||||
file >> p.z();
|
||||
|
||||
points[pointI] = p;
|
||||
}
|
||||
|
||||
//- read the number of faces
|
||||
file >> counter;
|
||||
|
||||
faceListPMG& faces = meshModifier.facesAccess();
|
||||
|
||||
//- read faces from file
|
||||
faces.setSize(counter);
|
||||
forAll(faces, faceI)
|
||||
{
|
||||
file >> counter;
|
||||
|
||||
face f;
|
||||
f.setSize(counter);
|
||||
|
||||
forAll(f, pI)
|
||||
file >> f[pI];
|
||||
|
||||
faces[faceI] = f.reverseFace();
|
||||
}
|
||||
|
||||
//- read the number of cells
|
||||
file >> counter;
|
||||
|
||||
//- read cells from file
|
||||
cellListPMG& cells = meshModifier.cellsAccess();
|
||||
cells.setSize(counter);
|
||||
|
||||
forAll(cells, cellI)
|
||||
{
|
||||
file >> counter;
|
||||
|
||||
cell& c = cells[cellI];
|
||||
|
||||
c.setSize(counter);
|
||||
|
||||
forAll(c, fI)
|
||||
file >> c[fI];
|
||||
}
|
||||
|
||||
//- read selections
|
||||
file >> counter;
|
||||
|
||||
wordList patchNames;
|
||||
Map<label> subsetToPatch;
|
||||
|
||||
for(label setI=0;setI<counter;++setI)
|
||||
{
|
||||
word sName;
|
||||
file >> sName;
|
||||
|
||||
label type;
|
||||
file >> type;
|
||||
|
||||
label nEntries;
|
||||
file >> nEntries;
|
||||
|
||||
switch( type )
|
||||
{
|
||||
case 3:
|
||||
{
|
||||
//- face selection
|
||||
const label id = pmg.addFaceSubset(sName);
|
||||
|
||||
patchNames.setSize(patchNames.size()+1);
|
||||
patchNames[patchNames.size()-1] = sName;
|
||||
subsetToPatch.insert(id, patchNames.size()-1);
|
||||
|
||||
Info << "Reading face selection " << sName << endl;
|
||||
|
||||
for(label i=0;i<nEntries;++i)
|
||||
{
|
||||
label entryI;
|
||||
file >> entryI;
|
||||
pmg.addFaceToSubset(id, entryI);
|
||||
}
|
||||
} break;
|
||||
case 2:
|
||||
{
|
||||
//- cell selection
|
||||
const label id = pmg.addCellSubset(sName);
|
||||
|
||||
for(label i=0;i<nEntries;++i)
|
||||
{
|
||||
label entryI;
|
||||
file >> entryI;
|
||||
pmg.addCellToSubset(id, entryI);
|
||||
}
|
||||
} break;
|
||||
case 1:
|
||||
{
|
||||
//- node selection
|
||||
const label id = pmg.addPointSubset(sName);
|
||||
|
||||
for(label i=0;i<nEntries;++i)
|
||||
{
|
||||
label entryI;
|
||||
file >> entryI;
|
||||
pmg.addPointToSubset(id, entryI);
|
||||
}
|
||||
} break;
|
||||
};
|
||||
}
|
||||
|
||||
//- create patches from face selections
|
||||
VRWGraph boundaryFaces;
|
||||
labelLongList boundaryOwner;
|
||||
labelLongList boundaryPatches;
|
||||
|
||||
const labelList& owner = pmg.owner();
|
||||
DynList<label> faceSubsets;
|
||||
pmg.faceSubsetIndices(faceSubsets);
|
||||
|
||||
forAll(faceSubsets, setI)
|
||||
{
|
||||
labelLongList setFaces;
|
||||
pmg.facesInSubset(faceSubsets[setI], setFaces);
|
||||
|
||||
forAll(setFaces, i)
|
||||
{
|
||||
boundaryFaces.appendList(faces[setFaces[i]]);
|
||||
boundaryOwner.append(owner[setFaces[i]]);
|
||||
boundaryPatches.append(subsetToPatch[faceSubsets[setI]]);
|
||||
}
|
||||
|
||||
pmg.removeFaceSubset(faceSubsets[setI]);
|
||||
}
|
||||
|
||||
meshModifier.reorderBoundaryFaces();
|
||||
meshModifier.replaceBoundary
|
||||
(
|
||||
patchNames,
|
||||
boundaryFaces,
|
||||
boundaryOwner,
|
||||
boundaryPatches
|
||||
);
|
||||
|
||||
pmg.write();
|
||||
|
||||
Info << "End\n" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,3 +0,0 @@
|
|||
FPMAToMesh.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/FPMAToMesh
|
|
@ -1,7 +0,0 @@
|
|||
EXE_INC = \
|
||||
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lcfMesh \
|
||||
-lmeshTools
|
|
@ -1,5 +1,5 @@
|
|||
EXE_INC = \
|
||||
-I$(FOAM_SRC)/mesh/cfMesh/lnInclude \
|
||||
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
EXE_INC = \
|
||||
-I$(FOAM_SRC)/mesh/cfMesh/lnInclude \
|
||||
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
EXE_INC = \
|
||||
-I$(FOAM_SRC)/mesh/cfMesh/lnInclude \
|
||||
-I$(FOAM_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
|
||||
EXE_LIBS = \
|
||||
-lcfMesh \
|
||||
|
|
|
@ -22,7 +22,7 @@ License
|
|||
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Reads the AVL's surface mesh
|
||||
Converts specified patches into subsets
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
EXE_INC = \
|
||||
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
|
||||
-I$(FOAM_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
|
||||
EXE_LIBS = \
|
||||
-lcfMesh \
|
||||
-lmeshTools
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
EXE_INC = \
|
||||
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
|
||||
-I$(FOAM_SRC)/meshTools/lnInclude
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lmeshTools \
|
||||
|
|
|
@ -29,7 +29,7 @@ Description
|
|||
#include "argList.H"
|
||||
#include "IFstream.H"
|
||||
#include "fileName.H"
|
||||
#include "triSurface.H"
|
||||
#include "triSurfModifier.H"
|
||||
#include "boundBox.H"
|
||||
#include "OFstream.H"
|
||||
#include <cstdlib>
|
||||
|
@ -67,8 +67,9 @@ int main(int argc, char *argv[])
|
|||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
triSurface origSurface(inFileName);
|
||||
const pointField& points = origSurface.points();
|
||||
triSurf origSurface(inFileName);
|
||||
triSurfModifier sMod(origSurface);
|
||||
pointField& points = sMod.pointsAccess();
|
||||
|
||||
const boundBox bb(points);
|
||||
|
||||
|
@ -100,36 +101,33 @@ int main(int argc, char *argv[])
|
|||
|
||||
//- generate bounding box points
|
||||
const label nPoints = points.size();
|
||||
pointField newPoints(nPoints+8);
|
||||
forAll(points, pointI)
|
||||
newPoints[pointI] = points[pointI];
|
||||
points.setSize(nPoints + 8);
|
||||
|
||||
newPoints[nPoints] = newBB.min();
|
||||
newPoints[nPoints+1] =
|
||||
points[nPoints] = newBB.min();
|
||||
points[nPoints+1] =
|
||||
point(newBB.max().x(), newBB.min().y(), newBB.min().z());
|
||||
newPoints[nPoints+2] =
|
||||
points[nPoints+2] =
|
||||
point(newBB.min().x(), newBB.max().y(), newBB.min().z());
|
||||
newPoints[nPoints+3] =
|
||||
points[nPoints+3] =
|
||||
point(newBB.max().x(), newBB.max().y(), newBB.min().z());
|
||||
newPoints[nPoints+4] =
|
||||
points[nPoints+4] =
|
||||
point(newBB.min().x(), newBB.min().y(), newBB.max().z());
|
||||
newPoints[nPoints+5] =
|
||||
points[nPoints+5] =
|
||||
point(newBB.max().x(), newBB.min().y(), newBB.max().z());
|
||||
newPoints[nPoints+6] =
|
||||
points[nPoints+6] =
|
||||
point(newBB.min().x(), newBB.max().y(), newBB.max().z());
|
||||
newPoints[nPoints+7] = newBB.max();
|
||||
points[nPoints+7] = newBB.max();
|
||||
|
||||
//- generate bounding bound triangles
|
||||
const label nTriangles = origSurface.size();
|
||||
List<labelledTri> newTriangles(nTriangles+12);
|
||||
forAll(origSurface, triI)
|
||||
newTriangles[triI] = origSurface[triI];
|
||||
LongList<labelledTri>& newTriangles = sMod.facetsAccess();
|
||||
newTriangles.setSize(nTriangles + 12);
|
||||
|
||||
//- create patches
|
||||
geometricSurfacePatchList& newPatches = sMod.patchesAccess();
|
||||
const label nPatches = origSurface.patches().size();
|
||||
geometricSurfacePatchList newPatches(nPatches+6);
|
||||
forAll(origSurface.patches(), patchI)
|
||||
newPatches[patchI] = origSurface.patches()[patchI];
|
||||
newPatches.setSize(nPatches + 6);
|
||||
|
||||
newPatches[nPatches].name() = "xMin";
|
||||
newPatches[nPatches+1].name() = "xMax";
|
||||
newPatches[nPatches+2].name() = "yMin";
|
||||
|
@ -169,8 +167,7 @@ int main(int argc, char *argv[])
|
|||
labelledTri(nPoints+4, nPoints+5, nPoints+7, nPatches+5);
|
||||
|
||||
//- write the surface
|
||||
triSurface newSurface(newTriangles, newPatches, newPoints);
|
||||
newSurface.write(outFileName);
|
||||
origSurface.writeSurface(outFileName);
|
||||
|
||||
Info << "End\n" << endl;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
EXE_INC = \
|
||||
-I$(FOAM_SRC)/mesh/cfMesh/lnInclude \
|
||||
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
|
|
Reference in a new issue