2014-06-10 13:43:32 +00:00
|
|
|
/*---------------------------------------------------------------------------*\
|
|
|
|
========= |
|
|
|
|
\\ / 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"
|
2014-06-17 10:42:41 +00:00
|
|
|
#include "objectRegistry.H"
|
2014-06-10 13:43:32 +00:00
|
|
|
#include "Time.H"
|
|
|
|
#include "polyMeshGenModifier.H"
|
|
|
|
#include "IFstream.H"
|
|
|
|
|
|
|
|
#include "Map.H"
|
|
|
|
|
|
|
|
using namespace Foam;
|
|
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
2015-05-15 13:57:39 +00:00
|
|
|
{
|
2014-06-10 13:43:32 +00:00
|
|
|
|
|
|
|
# include "setRootCase.H"
|
|
|
|
# include "createTime.H"
|
|
|
|
|
|
|
|
fileName inFileName;
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
Info << "Reading mesh from file " << endl;
|
|
|
|
cin >> inFileName;
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
IFstream file(inFileName);
|
|
|
|
|
|
|
|
polyMeshGen pmg(runTime);
|
|
|
|
polyMeshGenModifier meshModifier(pmg);
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
label counter;
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
//- read the number of vertices
|
|
|
|
pointFieldPMG& points = meshModifier.pointsAccess();
|
|
|
|
file >> counter;
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
//- read points from file
|
|
|
|
points.setSize(counter);
|
|
|
|
forAll(points, pointI)
|
|
|
|
{
|
|
|
|
point p;
|
|
|
|
file >> p.x();
|
|
|
|
file >> p.y();
|
|
|
|
file >> p.z();
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
points[pointI] = p;
|
|
|
|
}
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
//- read the number of faces
|
|
|
|
file >> counter;
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
faceListPMG& faces = meshModifier.facesAccess();
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
//- read faces from file
|
|
|
|
faces.setSize(counter);
|
|
|
|
forAll(faces, faceI)
|
|
|
|
{
|
|
|
|
file >> counter;
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
face f;
|
|
|
|
f.setSize(counter);
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
forAll(f, pI)
|
|
|
|
file >> f[pI];
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
faces[faceI] = f.reverseFace();
|
|
|
|
}
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
//- read the number of cells
|
|
|
|
file >> counter;
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
//- read cells from file
|
|
|
|
cellListPMG& cells = meshModifier.cellsAccess();
|
|
|
|
cells.setSize(counter);
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
forAll(cells, cellI)
|
|
|
|
{
|
|
|
|
file >> counter;
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
cell& c = cells[cellI];
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
c.setSize(counter);
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
forAll(c, fI)
|
|
|
|
file >> c[fI];
|
|
|
|
}
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
//- read selections
|
|
|
|
file >> counter;
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
wordList patchNames;
|
|
|
|
Map<label> subsetToPatch;
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
for(label setI=0;setI<counter;++setI)
|
|
|
|
{
|
|
|
|
word sName;
|
|
|
|
file >> sName;
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
label type;
|
|
|
|
file >> type;
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
label nEntries;
|
|
|
|
file >> nEntries;
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
switch( type )
|
|
|
|
{
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
//- face selection
|
|
|
|
const label id = pmg.addFaceSubset(sName);
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
patchNames.setSize(patchNames.size()+1);
|
|
|
|
patchNames[patchNames.size()-1] = sName;
|
|
|
|
subsetToPatch.insert(id, patchNames.size()-1);
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
Info << "Reading face selection " << sName << endl;
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
for(label i=0;i<nEntries;++i)
|
|
|
|
{
|
|
|
|
label entryI;
|
|
|
|
file >> entryI;
|
|
|
|
pmg.addFaceToSubset(id, entryI);
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
//- cell selection
|
|
|
|
const label id = pmg.addCellSubset(sName);
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
for(label i=0;i<nEntries;++i)
|
|
|
|
{
|
|
|
|
label entryI;
|
|
|
|
file >> entryI;
|
|
|
|
pmg.addCellToSubset(id, entryI);
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
//- node selection
|
|
|
|
const label id = pmg.addPointSubset(sName);
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
for(label i=0;i<nEntries;++i)
|
|
|
|
{
|
|
|
|
label entryI;
|
|
|
|
file >> entryI;
|
|
|
|
pmg.addPointToSubset(id, entryI);
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
};
|
|
|
|
}
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
//- create patches from face selections
|
|
|
|
VRWGraph boundaryFaces;
|
|
|
|
labelLongList boundaryOwner;
|
|
|
|
labelLongList boundaryPatches;
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
const labelList& owner = pmg.owner();
|
|
|
|
DynList<label> faceSubsets;
|
|
|
|
pmg.faceSubsetIndices(faceSubsets);
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
forAll(faceSubsets, setI)
|
|
|
|
{
|
|
|
|
labelLongList setFaces;
|
|
|
|
pmg.facesInSubset(faceSubsets[setI], setFaces);
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
forAll(setFaces, i)
|
|
|
|
{
|
|
|
|
boundaryFaces.appendList(faces[setFaces[i]]);
|
|
|
|
boundaryOwner.append(owner[setFaces[i]]);
|
|
|
|
boundaryPatches.append(subsetToPatch[faceSubsets[setI]]);
|
|
|
|
}
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
pmg.removeFaceSubset(faceSubsets[setI]);
|
|
|
|
}
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
meshModifier.reorderBoundaryFaces();
|
|
|
|
meshModifier.replaceBoundary
|
|
|
|
(
|
|
|
|
patchNames,
|
|
|
|
boundaryFaces,
|
|
|
|
boundaryOwner,
|
|
|
|
boundaryPatches
|
|
|
|
);
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
pmg.write();
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-06-10 13:43:32 +00:00
|
|
|
Info << "End\n" << endl;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ************************************************************************* //
|