Merged executable and utilities

This commit is contained in:
Franjo Juretic 2015-06-25 22:49:29 +02:00 committed by Dominik Christ
parent a188134cb2
commit eff9a36c3b
76 changed files with 3954 additions and 0 deletions

View file

@ -0,0 +1,146 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "Time.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;
}
// ************************************************************************* //

View file

@ -0,0 +1,3 @@
FLMAToSurface.C
EXE = $(FOAM_APPBIN)/FLMAToSurface

View file

@ -0,0 +1,11 @@
EXE_INC = \
-I../../meshLibrary/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude
EXE_LIBS = \
-ltriSurface \
-lmeshLibrary \
-lmeshTools \
-ledgeMesh

View file

@ -0,0 +1,166 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "Time.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;
}
// ************************************************************************* //

View file

@ -0,0 +1,3 @@
FMSToSurface.C
EXE = $(FOAM_APPBIN)/FMSToSurface

View file

@ -0,0 +1,11 @@
EXE_INC = \
-I../../meshLibrary/lnInclude \
-I$(FOAM_SRC)/meshTools/lnInclude \
-I$(FOAM_SRC)/triSurface/lnInclude \
-I$(FOAM_SRC)/edgeMesh/lnInclude
EXE_LIBS = \
-ltriSurface \
-lmeshTools \
-ledgeMesh \
-lmeshLibrary

View file

@ -0,0 +1,545 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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;
}
// ************************************************************************* //

View file

@ -0,0 +1,3 @@
FMSToVTK.C
EXE = $(FOAM_APPBIN)/FMSToVTK

View file

@ -0,0 +1,11 @@
EXE_INC = \
-I../../meshLibrary/lnInclude \
-I$(FOAM_SRC)/meshTools/lnInclude \
-I$(FOAM_SRC)/triSurface/lnInclude \
-I$(FOAM_SRC)/edgeMesh/lnInclude
EXE_LIBS = \
-ltriSurface \
-ledgeMesh \
-lmeshLibrary \
-lmeshTools

View file

@ -0,0 +1,297 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //

View file

@ -0,0 +1,3 @@
cartesian2DMesh.C
EXE = $(FOAM_APPBIN)/cartesian2DMesh

View file

@ -0,0 +1,13 @@
EXE_INC = \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude \
-I../../meshLibrary/lnInclude
EXE_LIBS = \
-lmeshTools \
-ltriSurface \
-lfiniteVolume \
-ledgeMesh \
-lmeshLibrary

View file

@ -0,0 +1,61 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "Time.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;
}
// ************************************************************************* //

View file

@ -0,0 +1,3 @@
cartesianMesh.C
EXE = $(FOAM_APPBIN)/cartesianMesh

View file

@ -0,0 +1,13 @@
EXE_INC = \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude \
-I../../meshLibrary/lnInclude
EXE_LIBS = \
-lmeshTools \
-ltriSurface \
-lfiniteVolume \
-ledgeMesh \
-lmeshLibrary

View file

@ -0,0 +1,59 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "Time.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;
}
// ************************************************************************* //

View file

@ -0,0 +1,3 @@
checkSurfaceMesh.C
EXE = $(FOAM_APPBIN)/checkSurfaceMesh

View file

@ -0,0 +1,11 @@
EXE_INC = \
-I../../meshLibrary/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude
EXE_LIBS = \
-ltriSurface \
-lmeshLibrary \
-lmeshTools \
-ledgeMesh

View file

@ -0,0 +1,226 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "triSurfaceChecks.H"
#include "boundBox.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]);
triSurf surf(inFileName);
label nFailed(0);
boundBox bb;
triSurfaceChecks::calculateBoundingBox(surf, bb);
Info << "\nNumber of points " << surf.nPoints() << endl;
Info << "Number of triangles " << surf.size() << endl;
Info << "Number of patches " << surf.patches().size() << endl;
Info << "Number of feature edges " << surf.nFeatureEdges() << endl;
Info << "Bounding box " << bb << nl << nl << endl;
const scalar distTol = SMALL * bb.mag();
//- calculate manifolds
const label nManifolds = triSurfaceChecks::checkSurfaceManifolds(surf);
if( nManifolds > 1 )
{
++nFailed;
Info << "\nSurface mesh consists of " << nManifolds
<< " manifolds!!" << endl;
Info << "You cannot mesh geometries consisting of more than"
<< " one domain, and it must not contain baffles"
<< " in the domain which shall be meshed." << endl;
}
else
{
Info << "\nSurface mesh consists of a single manifold." << endl;
}
//- find open boundary edges
if( triSurfaceChecks::checkForHoles(surf) )
{
++nFailed;
Info << "\nSurface mesh has open boundaries!!" << endl;
Info << "This indicates that there may be some holes in the surface"
<< " mesh. Holes in the mesh must be smaller than the specified"
<< " cell size at this location. In addition, please avoid"
<< " using the automatic refinement procedure."
<< " Please avoid using the minCellSize option." << endl;
}
else
{
Info << "No open edges found in the surface mesh." << endl;
}
//- find non-manifold edges
if( triSurfaceChecks::checkForNonManifoldEdges(surf) )
{
++nFailed;
Info << "\nSurface mesh has non-manifold edges!!" << endl;
Info << "This indicates that the surface mesh consists of multiple"
<< " domains and/or baffles. Please make sure that they are not"
<< " in the domain which shall be meshed." << endl;
}
else
{
Info << "Surface does not have any non-manifold edges." << endl;
}
//- check the number of disconnected parts
if( triSurfaceChecks::checkDisconnectedParts(surf) > 1 )
{
++nFailed;
Info << "\nSurface mesh consists of disconnected parts!!" << endl;
Info << "This is not a problem if there exists a region surrounding"
<< " all other regions! In other case, the mesher will generate"
<< " the mesh in the domains with most cells." << endl;
}
else
{
Info << "Surface mesh consists of a single region." << endl;
}
//- find triangles with small angles
if( triSurfaceChecks::checkAngles(surf, "smallAngles", 1.0) )
{
++nFailed;
Info << "\nSurface mesh has some bad-quality triangles with"
<< " angles smaller than 1.0 deg!!" << endl;
Info << "This may cause problems to the automatic refinement"
<< " procedure. Please avoid using the minCellSize option."
<< endl;
}
else
{
Info << "No sliver triangles found." << endl;
}
//- find self-intersections in the surface mesh
if
(
triSurfaceChecks::checkSelfIntersections
(
surf,
"selfIntersect",
distTol
)
)
{
++nFailed;
Info << "\nFound self-intersecting parts in the surface mesh!!" << endl;
Info << "This causes problems to the automatic refinement procedure"
<< " Please avoid using the minCellSize option."
<< " It can also cause problems to the boundary layer"
<< " generation procedure." << endl;
}
else
{
Info << "No self-intersections found." << endl;
}
//- find overlaps in the surface mesh
if
(
triSurfaceChecks::checkOverlaps
(
surf,
"overlaps",
distTol,
5.0
)
)
{
++nFailed;
Info << "\nFound overlapping parts in the surface mesh!!" << endl;
Info << "This causes problems to the automatic refinement procedure."
<< " Please avoid using the minCellSize option." << endl;
}
//- check for existence of collocated points
if
(
triSurfaceChecks::checkCollocatedPoints
(
surf,
"collocatedPoints",
distTol
)
)
{
++nFailed;
Info << "\nFound collocated points in the surface mesh!!" << endl;
Info << "This causes problems to the automatic refinement procedure."
<< " Please avoid using the minCellSize option." << endl;
}
Info << nl << endl;
if( nFailed )
{
Info << "\nFound " << nFailed
<< " checks indicating potential problems." << endl;
Info << "However, it does not mean that you cannot generate"
<< " a valid mesh.\n" << endl;
surf.writeSurface(inFileName);
}
else
{
Info << "\nSurface passes all checks.\n" << endl;
}
Info << "End\n" << endl;
return 0;
}
// ************************************************************************* //

View file

@ -0,0 +1,3 @@
copySurfaceParts.C
EXE = $(FOAM_APPBIN)/copySurfaceParts

View file

@ -0,0 +1,11 @@
EXE_INC = \
-I../../meshLibrary/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude
EXE_LIBS = \
-ltriSurface \
-lmeshLibrary \
-lmeshTools \
-ledgeMesh

View file

@ -0,0 +1,80 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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;
}
// ************************************************************************* //

View file

@ -0,0 +1,3 @@
extrudeEdgesInto2DSurface.C
EXE = $(FOAM_APPBIN)/extrudeEdgesInto2DSurface

View file

@ -0,0 +1,11 @@
EXE_INC = \
-I../../meshLibrary/lnInclude \
-I$(FOAM_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude
EXE_LIBS = \
-ltriSurface \
-lmeshLibrary \
-lmeshTools \
-ledgeMesh

View file

@ -0,0 +1,74 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "Time.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;
}
// ************************************************************************* //

View file

@ -0,0 +1,3 @@
generateBoundaryLayers.C
EXE = $(FOAM_APPBIN)/generateBoundaryLayers

View file

@ -0,0 +1,11 @@
EXE_INC = \
-I../../meshLibrary/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude
EXE_LIBS = \
-lmeshTools \
-ltriSurface \
-ledgeMesh \
-lmeshLibrary

View file

@ -0,0 +1,148 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Generates boundary layers in the existing mesh, based on the settings
given in meshDict. It also performs necessary quality optimisation.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "polyMeshGenModifier.H"
#include "meshOptimizer.H"
#include "boundaryLayers.H"
#include "refineBoundaryLayers.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void generateLayer
(
polyMeshGen& mesh,
const dictionary& meshDict,
const bool layers2D
)
{
boundaryLayers bl(mesh);
if( layers2D )
bl.activate2DMode();
if( meshDict.found("boundaryLayers") )
{
const dictionary& bndLayers = meshDict.subDict("boundaryLayers");
if( bndLayers.found("nLayers") )
{
const label nLayers = readLabel(bndLayers.lookup("nLayers"));
if( nLayers > 0 )
bl.addLayerForAllPatches();
}
else if( bndLayers.found("patchBoundaryLayers") )
{
const dictionary& patchLayers =
bndLayers.subDict("patchBoundaryLayers");
const wordList createLayers = patchLayers.toc();
forAll(createLayers, patchI)
bl.addLayerForPatch(createLayers[patchI]);
}
}
else
{
bl.addLayerForAllPatches();
}
}
void meshOptimisation(polyMeshGen& mesh)
{
meshOptimizer mOpt(mesh);
mOpt.optimizeMeshFV();
mOpt.optimizeLowQualityFaces();
mOpt.untangleMeshFV();
mOpt.optimizeBoundaryLayer();
mOpt.untangleMeshFV();
}
void layerRefinement(polyMeshGen& mesh, const dictionary& meshDict)
{
if( meshDict.isDict("boundaryLayers") )
{
refineBoundaryLayers refLayers(mesh);
refineBoundaryLayers::readSettings(meshDict, refLayers);
refLayers.refineLayers();
meshOptimizer(mesh).untangleBoundaryLayer();
}
}
int main(int argc, char *argv[])
{
argList::validOptions.insert("2DLayers", "bool");
# include "setRootCase.H"
# include "createTime.H"
IOdictionary meshDict
(
IOobject
(
"meshDict",
runTime.system(),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
//- load the mesh from disk
polyMeshGen pmg(runTime);
pmg.read();
bool is2DLayer(false);
if( args.options().found("2DLayers") )
is2DLayer = true;
//- generate the initial boundary layer
generateLayer(pmg, meshDict, is2DLayer);
//- optimisation of mesh quality
meshOptimisation(pmg);
//- perform layer refinement
layerRefinement(pmg, meshDict);
Info << "Writing mesh" << endl;
pmg.write();
Info << "End\n" << endl;
return 0;
}
// ************************************************************************* //

View file

@ -0,0 +1,3 @@
importSurfaceAsSubset.C
EXE = $(FOAM_APPBIN)/importSurfaceAsSubset

View file

@ -0,0 +1,11 @@
EXE_INC = \
-I../../meshLibrary/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude
EXE_LIBS = \
-ltriSurface \
-ledgeMesh \
-lmeshLibrary \
-lmeshTools

View file

@ -0,0 +1,84 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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;
}
// ************************************************************************* //

View file

@ -0,0 +1,3 @@
improveMeshQuality.C
EXE = $(FOAM_APPBIN)/improveMeshQuality

View file

@ -0,0 +1,11 @@
EXE_INC = \
-I../../meshLibrary/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude
EXE_LIBS = \
-lmeshTools \
-ltriSurface \
-ledgeMesh \
-lmeshLibrary

View file

@ -0,0 +1,156 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Performs point relocations in the mesh (smoothing) in order to
improve quality measures. It does not make the mesh invalied.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "polyMeshGenModifier.H"
#include "meshOptimizer.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
argList::validArgs.clear();
argList::validOptions.insert("nLoops", "int");
argList::validOptions.insert("nIterations", "int");
argList::validOptions.insert("nSurfaceIterations", "int");
argList::validOptions.insert("qualityThreshold", "scalar");
argList::validOptions.insert("constrainedCellsSet", "word");
# include "setRootCase.H"
# include "createTime.H"
//- read the settings
label nIterations(50);
label nLoops(10);
label nSurfaceIterations(2);
scalar qualityThreshold(0.1);
if( args.options().found("nLoops") )
{
nLoops = readLabel(IStringStream(args.options()["nLoops"])());
}
else
{
Info << "Default number of loops is 10" << endl;
}
if( args.options().found("nIterations") )
{
nIterations =
readLabel(IStringStream(args.options()["nIterations"])());
}
else
{
Info << "Default number of iterations is 50" << endl;
}
if( args.options().found("nSurfaceIterations") )
{
nSurfaceIterations =
readLabel(IStringStream(args.options()["nSurfaceIterations"])());
}
else
{
Info << "Default number of surface iterations is 2" << endl;
}
if( args.options().found("qualityThreshold") )
{
qualityThreshold =
readScalar(IStringStream(args.options()["qualityThreshold"])());
}
else
{
Info << "Using default quality threshold 0.1" << endl;
}
word constrainedCellSet;
if( args.options().found("constrainedCellsSet") )
{
constrainedCellSet = args.options()["constrainedCellsSet"];
}
else
{
Info << "No constraints applied on the smoothing procedure" << endl;
}
//- load the mesh from disk
polyMeshGen pmg(runTime);
pmg.read();
//- construct the smoother
meshOptimizer mOpt(pmg);
if( !constrainedCellSet.empty() )
{
//- lock cells in constrainedCellSet
mOpt.lockCellsInSubset(constrainedCellSet);
//- find boundary faces which shall be locked
labelLongList lockedBndFaces, selectedCells;
const label sId = pmg.cellSubsetIndex(constrainedCellSet);
pmg.cellsInSubset(sId, selectedCells);
boolList activeCell(pmg.cells().size(), false);
forAll(selectedCells, i)
activeCell[selectedCells[i]] = true;
}
//- clear geometry information before volume smoothing
pmg.clearAddressingData();
//- perform optimisation using the laplace smoother and
mOpt.optimizeMeshFV
(
nLoops,
nLoops,
nIterations,
nSurfaceIterations
);
//- perform optimisation of worst quality faces
mOpt.optimizeMeshFVBestQuality(nLoops, qualityThreshold);
//- check the mesh again and untangl bad regions if any of them exist
mOpt.untangleMeshFV(nLoops, nIterations, nSurfaceIterations);
Info << "Writing mesh" << endl;
pmg.write();
Info << "End\n" << endl;
return 0;
}
// ************************************************************************* //

View file

@ -0,0 +1,3 @@
improveSymmetryPlanes.C
EXE = $(FOAM_APPBIN)/improveSymmetryPlanes

View file

@ -0,0 +1,9 @@
EXE_INC = \
-I../../meshLibrary/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude
EXE_LIBS = \
-lmeshTools \
-ledgeMesh \
-lmeshLibrary

View file

@ -0,0 +1,57 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "Time.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;
}
// ************************************************************************* //

View file

@ -0,0 +1,3 @@
mergeSurfacePatches.C
EXE = $(FOAM_APPBIN)/mergeSurfacePatches

View file

@ -0,0 +1,11 @@
EXE_INC = \
-I../../meshLibrary/lnInclude \
-I$(FOAM_SRC)/meshTools/lnInclude \
-I$(FOAM_SRC)/triSurface/lnInclude \
-I$(FOAM_SRC)/edgeMesh/lnInclude
EXE_LIBS = \
-ltriSurface \
-ledgeMesh \
-lmeshLibrary \
-lmeshTools

View file

@ -0,0 +1,403 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "Time.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;
}
// ************************************************************************* //

View file

@ -0,0 +1,3 @@
meshToFPMA.C
EXE = $(FOAM_APPBIN)/meshToFPMA

View file

@ -0,0 +1,9 @@
EXE_INC = \
-I../../meshLibrary/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude
EXE_LIBS = \
-lmeshLibrary \
-ledgeMesh \
-lmeshTools

View file

@ -0,0 +1,58 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "Time.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;
}
// ************************************************************************* //

View file

@ -0,0 +1,3 @@
pMesh.C
EXE = $(FOAM_APPBIN)/pMesh

View file

@ -0,0 +1,13 @@
EXE_INC = \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude \
-I../../meshLibrary/lnInclude
EXE_LIBS = \
-lmeshTools \
-ltriSurface \
-lfiniteVolume \
-ledgeMesh \
-lmeshLibrary

View file

@ -0,0 +1,61 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 polyhedral mesh
Description
- takes a triangulated surface and generates a body-fitted polyhedral mesh
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "voronoiMeshGenerator.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
//- polyhedral mesher cannot be run in parallel yet
argList::noParallel();
voronoiMeshGenerator pmg(runTime);
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s\n"
<< "ClockTime = " << runTime.elapsedClockTime() << endl;
pmg.writeMesh();
Info << "End\n" << endl;
return 0;
}
// ************************************************************************* //

View file

@ -0,0 +1,3 @@
patchesToSubsets.C
EXE = $(FOAM_APPBIN)/patchesToSubsets

View file

@ -0,0 +1,11 @@
EXE_INC = \
-I../../meshLibrary/lnInclude \
-I$(FOAM_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude
EXE_LIBS = \
-ltriSurface \
-ledgeMesh \
-lmeshLibrary \
-lmeshTools

View file

@ -0,0 +1,84 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "Time.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;
}
// ************************************************************************* //

View file

@ -0,0 +1,3 @@
preparePar.C
EXE = $(FOAM_APPBIN)/preparePar

View file

@ -0,0 +1,11 @@
EXE_INC = \
-I../../meshLibrary/lnInclude \
-I$(FOAM_SRC)/meshTools/lnInclude \
-I$(FOAM_SRC)/triSurface/lnInclude \
-I$(FOAM_SRC)/edgeMesh/lnInclude
EXE_LIBS = \
-ltriSurface \
-lmeshTools \
-ledgeMesh \
-lmeshLibrary

View file

@ -0,0 +1,100 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "Time.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;
}
// ************************************************************************* //

View file

@ -0,0 +1,3 @@
removeSurfaceFacets.C
EXE = $(FOAM_APPBIN)/removeSurfaceFacets

View file

@ -0,0 +1,11 @@
EXE_INC = \
-I../../meshLibrary/lnInclude \
-I$(FOAM_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude
EXE_LIBS = \
-ltriSurface \
-ledgeMesh \
-lmeshLibrary \
-lmeshTools

View file

@ -0,0 +1,72 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "Time.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;
}
// ************************************************************************* //

View file

@ -0,0 +1,3 @@
scaleMesh.C
EXE = $(FOAM_APPBIN)/scaleMesh

View file

@ -0,0 +1,11 @@
EXE_INC = \
-I../../meshLibrary/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude
EXE_LIBS = \
-ltriSurface \
-ledgeMesh \
-lmeshLibrary \
-lmeshTools

View file

@ -0,0 +1,73 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Scales the mesh into other units.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "polyMeshGen.H"
#include "helperFunctions.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
using namespace Foam;
int main(int argc, char *argv[])
{
argList::validArgs.append("scalingFactor");
# include "setRootCase.H"
# include "createTime.H"
const scalar scalingFactor(help::textToScalar(args.args()[1]));
Info << "Scaling mesh vertices by a factor " << scalingFactor << endl;
//- read the mesh from disk
polyMeshGen pmg(runTime);
Info << "Reading mesh" << endl;
pmg.read();
//- scale the points
pointFieldPMG& pts = pmg.points();
# ifdef USE_OMP
# pragma omp parallel for schedule(dynamic, 100)
# endif
forAll(pts, pointI)
pts[pointI] *= scalingFactor;
//- write the mesh back on disk
Info << "Writting scaled mesh" << endl;
pmg.write();
Info << "End\n" << endl;
return 0;
}
// ************************************************************************* //

View file

@ -0,0 +1,3 @@
scaleSurfaceMesh.C
EXE = $(FOAM_APPBIN)/scaleSurfaceMesh

View file

@ -0,0 +1,11 @@
EXE_INC = \
-I../../meshLibrary/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude
EXE_LIBS = \
-ltriSurface \
-ledgeMesh \
-lmeshLibrary \
-lmeshTools

View file

@ -0,0 +1,74 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Scales surface vertices by a precribed factor.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "IFstream.H"
#include "fileName.H"
#include "triSurf.H"
#include "triSurfModifier.H"
#include "helperFunctions.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("scalingFactor");
argList args(argc, argv);
const fileName inFileName(args.args()[1]);
const fileName outFileName(args.args()[2]);
const scalar scalingFactor(help::textToScalar(args.args()[3]));
//- read the surface mesh
triSurf surface(inFileName);
triSurfModifier sMod(surface);
pointField& pts = sMod.pointsAccess();
//- scales the vertices
# ifdef USE_OMP
# pragma omp parallel for schedule(dynamic, 100)
# endif
forAll(pts, pointI)
pts[pointI] *= scalingFactor;
//- write the mesh back on disk
surface.writeSurface(outFileName);
Info << "End\n" << endl;
return 0;
}
// ************************************************************************* //

View file

@ -0,0 +1,3 @@
subsetToPatch.C
EXE = $(FOAM_APPBIN)/subsetToPatch

View file

@ -0,0 +1,11 @@
EXE_INC = \
-I../../meshLibrary/lnInclude \
-I$(FOAM_SRC)/meshTools/lnInclude \
-I$(FOAM_SRC)/triSurface/lnInclude \
-I$(FOAM_SRC)/edgeMesh/lnInclude
EXE_LIBS = \
-ltriSurface \
-ledgeMesh \
-lmeshLibrary \
-lmeshTools

View file

@ -0,0 +1,170 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "Time.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;
}
// ************************************************************************* //

View file

@ -0,0 +1,3 @@
surfaceFeatureEdges.C
EXE = $(FOAM_APPBIN)/surfaceFeatureEdges

View file

@ -0,0 +1,11 @@
EXE_INC = \
-I../../meshLibrary/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude
EXE_LIBS = \
-ltriSurface \
-ledgeMesh \
-lmeshLibrary \
-lmeshTools

View file

@ -0,0 +1,104 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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;
}
// ************************************************************************* //

View file

@ -0,0 +1,3 @@
surfaceGenerateBoundingBox.C
EXE = $(FOAM_APPBIN)/surfaceGenerateBoundingBox

View file

@ -0,0 +1,11 @@
EXE_INC = \
-I../../meshLibrary/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude
EXE_LIBS = \
-ltriSurface \
-ledgeMesh \
-lmeshLibrary \
-lmeshTools

View file

@ -0,0 +1,178 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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;
}
// ************************************************************************* //

View file

@ -0,0 +1,3 @@
surfaceToFMS.C
EXE = $(FOAM_APPBIN)/surfaceToFMS

View file

@ -0,0 +1,11 @@
EXE_INC = \
-I../../meshLibrary/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude
EXE_LIBS = \
-ltriSurface \
-ledgeMesh \
-lmeshLibrary \
-lmeshTools

View file

@ -0,0 +1,63 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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;
}
// ************************************************************************* //

View file

@ -0,0 +1,3 @@
tetMesh.C
EXE = $(FOAM_APPBIN)/tetMesh

View file

@ -0,0 +1,13 @@
EXE_INC = \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude \
-I../../meshLibrary/lnInclude
EXE_LIBS = \
-lmeshTools \
-ltriSurface \
-lfiniteVolume \
-ledgeMesh \
-lmeshLibrary

View file

@ -0,0 +1,61 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "Time.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;
}
// ************************************************************************* //