2010-05-12 13:27:55 +00:00
|
|
|
/*---------------------------------------------------------------------------*\
|
|
|
|
========= |
|
2013-12-11 16:09:41 +00:00
|
|
|
\\ / F ield | foam-extend: Open Source CFD
|
2016-06-20 15:00:40 +00:00
|
|
|
\\ / O peration | Version: 4.0
|
2015-05-17 13:32:07 +00:00
|
|
|
\\ / A nd | Web: http://www.foam-extend.org
|
|
|
|
\\/ M anipulation | For copyright notice see file Copyright
|
2010-05-12 13:27:55 +00:00
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
License
|
2013-12-11 16:09:41 +00:00
|
|
|
This file is part of foam-extend.
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2013-12-11 16:09:41 +00:00
|
|
|
foam-extend is free software: you can redistribute it and/or modify it
|
2010-05-12 13:27:55 +00:00
|
|
|
under the terms of the GNU General Public License as published by the
|
2013-12-11 16:09:41 +00:00
|
|
|
Free Software Foundation, either version 3 of the License, or (at your
|
2010-05-12 13:27:55 +00:00
|
|
|
option) any later version.
|
|
|
|
|
2013-12-11 16:09:41 +00:00
|
|
|
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.
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2013-12-11 16:09:41 +00:00
|
|
|
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
Description
|
|
|
|
Create intermediate mesh files from PROSTAR files
|
|
|
|
|
|
|
|
\*---------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
#include "starMesh.H"
|
|
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
|
|
|
|
|
|
// Specialist version of face comparison to deal with
|
|
|
|
// PROSTAR boundary format idiosyncracies
|
|
|
|
bool starMesh::starEqualFace
|
|
|
|
(
|
|
|
|
const face& boundaryFace,
|
|
|
|
const face& cellFace
|
|
|
|
) const
|
|
|
|
{
|
|
|
|
// A PROSTAR boundary face is defined by 4 vertices irrespective
|
|
|
|
// of its topology.
|
|
|
|
// In order to deal with all possibilities, cell face is
|
|
|
|
// considered equal if three of the vertices are the same.
|
|
|
|
bool cellFaceHappy = false;
|
|
|
|
|
|
|
|
label nEqual = 0;
|
|
|
|
|
|
|
|
forAll (cellFace, cellFaceLabelI)
|
|
|
|
{
|
|
|
|
const label curCellFaceLabel = cellFace[cellFaceLabelI];
|
|
|
|
|
|
|
|
forAll (boundaryFace, bouFaceLabelI)
|
|
|
|
{
|
|
|
|
if (boundaryFace[bouFaceLabelI] == curCellFaceLabel)
|
|
|
|
{
|
|
|
|
nEqual++;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nEqual >= 3)
|
|
|
|
{
|
|
|
|
cellFaceHappy = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Boundary face is happy if all of its vertices are recognised
|
|
|
|
bool boundaryFaceHappy = true;
|
|
|
|
|
|
|
|
forAll (boundaryFace, bouFaceLabelI)
|
|
|
|
{
|
|
|
|
const label curBouFaceLabel = boundaryFace[bouFaceLabelI];
|
|
|
|
|
|
|
|
bool found = false;
|
|
|
|
|
|
|
|
forAll (cellFace, cellFaceLabelI)
|
|
|
|
{
|
|
|
|
if (curBouFaceLabel == cellFace[cellFaceLabelI])
|
|
|
|
{
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
boundaryFaceHappy = boundaryFaceHappy && found;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (cellFaceHappy && boundaryFaceHappy);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void starMesh::markBoundaryFaces()
|
|
|
|
{
|
|
|
|
// set size of mark lists for the boundary
|
|
|
|
boundaryCellIDs_.setSize(boundary_.size());
|
|
|
|
boundaryCellFaceIDs_.setSize(boundary_.size());
|
|
|
|
|
|
|
|
forAll(boundary_, patchI)
|
|
|
|
{
|
|
|
|
const faceList& patchFaces = boundary_[patchI];
|
|
|
|
|
|
|
|
// set size of patch lists
|
|
|
|
labelList& curBoundaryCellIDs = boundaryCellIDs_[patchI];
|
|
|
|
labelList& curBoundaryCellFaceIDs = boundaryCellFaceIDs_[patchI];
|
|
|
|
|
|
|
|
curBoundaryCellIDs.setSize(patchFaces.size());
|
|
|
|
curBoundaryCellFaceIDs.setSize(patchFaces.size());
|
|
|
|
|
|
|
|
const labelListList& PointCells = pointCells();
|
|
|
|
|
|
|
|
forAll(patchFaces, faceI)
|
|
|
|
{
|
|
|
|
bool found = false;
|
|
|
|
|
|
|
|
const face& curFace = patchFaces[faceI];
|
|
|
|
const labelList& facePoints = curFace;
|
|
|
|
|
|
|
|
forAll(facePoints, pointI)
|
|
|
|
{
|
|
|
|
const labelList& facePointCells =
|
|
|
|
PointCells[facePoints[pointI]];
|
|
|
|
|
|
|
|
forAll(facePointCells, cellI)
|
|
|
|
{
|
|
|
|
const label curCellIndex = facePointCells[cellI];
|
|
|
|
|
2013-07-18 01:02:34 +00:00
|
|
|
const faceList& curCellFaces =
|
2010-05-12 13:27:55 +00:00
|
|
|
cellFaces_[curCellIndex];
|
|
|
|
|
|
|
|
forAll(curCellFaces, cellFaceI)
|
|
|
|
{
|
|
|
|
if (starEqualFace(curFace, curCellFaces[cellFaceI]))
|
|
|
|
{
|
|
|
|
// Found the cell face corresponding to this face
|
|
|
|
found = true;
|
|
|
|
|
|
|
|
// Set boundary face to the corresponding cell face
|
|
|
|
curBoundaryCellIDs[faceI] = curCellIndex;
|
|
|
|
curBoundaryCellFaceIDs[faceI] = cellFaceI;
|
|
|
|
}
|
|
|
|
if (found) break;
|
|
|
|
}
|
|
|
|
if (found) break;
|
|
|
|
}
|
|
|
|
if (found) break;
|
|
|
|
}
|
|
|
|
if (!found)
|
|
|
|
{
|
|
|
|
FatalErrorIn("starMesh::markBoundaryFaces()")
|
|
|
|
<< "Face " << faceI
|
|
|
|
<< " does not have neighbour cell."
|
|
|
|
<< " Face : " << endl << curFace << endl
|
|
|
|
<< "PROSTAR Command: vset,news,vlis";
|
|
|
|
|
|
|
|
forAll (curFace, spI)
|
|
|
|
{
|
|
|
|
if (curFace[spI] > -1 && curFace[spI] < starPointID_.size())
|
|
|
|
{
|
|
|
|
Info << "," << starPointID_[curFace[spI]];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Info << ",???";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FatalError << " $ bset,add,vset,all" << abort(FatalError);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void starMesh::collectBoundaryFaces()
|
|
|
|
{
|
|
|
|
Info << "Collecting boundary faces" << endl;
|
|
|
|
forAll(boundary_, patchI)
|
|
|
|
{
|
|
|
|
faceList& patchFaces = boundary_[patchI];
|
|
|
|
|
|
|
|
// set size of patch lists
|
|
|
|
const labelList& curBoundaryCellIDs = boundaryCellIDs_[patchI];
|
|
|
|
const labelList& curBoundaryCellFaceIDs = boundaryCellFaceIDs_[patchI];
|
|
|
|
|
|
|
|
forAll (curBoundaryCellIDs, faceI)
|
|
|
|
{
|
|
|
|
patchFaces[faceI] =
|
|
|
|
cellFaces_[curBoundaryCellIDs[faceI]]
|
|
|
|
[curBoundaryCellFaceIDs[faceI]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Info << "Finished collecting boundary faces" << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ************************************************************************* //
|