Commit 3f9f49f4 authored by Franjo's avatar Franjo
Browse files

Merge branch 'defect-polyMeshEdgeExtraction' into development

parents 944c8360 99b75260
......@@ -59,11 +59,54 @@ addToRunTimeSelectionTable
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
bool createFundamentalSheetsJFS::isTopologyOk() const
{
const PtrList<boundaryPatch>& boundaries = mesh_.boundaries();
const label start = boundaries[0].patchStart();
const label end
(
boundaries[boundaries.size()-1].patchStart() +
boundaries[boundaries.size()-1].patchSize()
);
const labelList& owner = mesh_.owner();
//- count the number of boundary faces in every cell
//- cells with more than one boundary face cause problem to the
//- sheet insertion procedure
labelList nBndFacesInCell(mesh_.cells().size(), 0);
bool isOkTopo(true);
for(label faceI=start;faceI<end;++faceI)
{
++nBndFacesInCell[owner[faceI]];
if( nBndFacesInCell[owner[faceI]] > 1 )
{
isOkTopo = false;
break;
}
}
reduce(isOkTopo, minOp<bool>());
return isOkTopo;
}
void createFundamentalSheetsJFS::createInitialSheet()
{
if( !createWrapperSheet_ )
{
if( isTopologyOk() )
return;
Warning << "Found invalid topology!"
<< "\nStarting creating initial wrapper sheet" << endl;
}
Info << "Creating initial wrapper sheet" << endl;
const PtrList<boundaryPatch>& boundaries = mesh_.boundaries();
const label start = boundaries[0].patchStart();
......@@ -78,17 +121,28 @@ void createFundamentalSheetsJFS::createInitialSheet()
LongList<labelPair> extrudeFaces(end-start);
# ifdef USE_OMP
# pragma omp parallel for
# pragma omp parallel for schedule(guided, 100)
# endif
for(label faceI=start;faceI<end;++faceI)
extrudeFaces[faceI-start] = labelPair(faceI, owner[faceI]);
extrudeLayer(mesh_, extrudeFaces);
Info << "Finished creating initial wrapper sheet" << endl;
}
void createFundamentalSheetsJFS::createSheetsAtFeatureEdges()
{
Info << "Starting creating sheets at feature edges" << endl;
const PtrList<boundaryPatch>& boundaries = mesh_.boundaries();
if( returnReduce(boundaries.size(), maxOp<label>()) < 2 )
{
Info << "Skipping creating sheets at feature edges" << endl;
return;
}
const cellListPMG& cells = mesh_.cells();
const labelList& owner = mesh_.owner();
const labelList& neighbour = mesh_.neighbour();
......@@ -109,14 +163,12 @@ void createFundamentalSheetsJFS::createSheetsAtFeatureEdges()
const label patchEnd = patchStart + boundaries[patchI].patchSize();
for(label faceI=patchStart;faceI<patchEnd;++faceI)
{
facePatch[faceI-start] = patchI;
}
}
List<DynList<label, 3> > patchCell(mesh_.cells().size());
labelList patchCell(mesh_.cells().size(), -1);
forAll(facePatch, bfI)
patchCell[owner[start+bfI]].appendIfNotIn(facePatch[bfI]);
patchCell[owner[start+bfI]] = facePatch[bfI];
# ifdef DEBUGSheets
labelList patchSheetId(boundaries.size());
......@@ -126,40 +178,20 @@ void createFundamentalSheetsJFS::createSheetsAtFeatureEdges()
forAll(patchCell, cellI)
{
if( patchCell[cellI].size() > 1 )
Warning << "Cell " << cellI
<< " is in patches " << patchCell[cellI] << endl;
if( patchCell[cellI] < 0 )
continue;
forAll(patchCell[cellI], patchI)
mesh_.addCellToSubset
(
patchSheetId[patchCell[cellI][patchI]],
cellI
);
mesh_.addCellToSubset(patchSheetId[patchCell[cellI]], cellI);
}
# endif
LongList<labelPair> front;
# ifdef USE_OMP
const label nThreads = 2 * omp_get_num_procs();
const label nThreads = 3 * omp_get_num_procs();
# pragma omp parallel num_threads(nThreads)
# endif
{
# ifdef USE_OMP
# pragma omp for
# endif
forAll(patchCell, cellI)
patchCell[cellI] = -1;
# ifdef USE_OMP
# pragma omp barrier
# pragma omp for
# endif
for(label faceI=start;faceI<end;++faceI)
patchCell[owner[faceI]] = mesh_.faceIsInPatch(faceI);
//- create the front faces
LongList<labelPair> localFront;
......@@ -183,7 +215,7 @@ void createFundamentalSheetsJFS::createSheetsAtFeatureEdges()
if( nei == cellI )
nei = neighbour[c[fI]];
if( !patchCell[nei].contains(patchI) )//patchCell[nei] != patchI )
if( patchCell[nei] != patchI )
localFront.append(labelPair(c[fI], cellI));
}
}
......@@ -221,6 +253,8 @@ void createFundamentalSheetsJFS::createSheetsAtFeatureEdges()
//- extrude the layer
extrudeLayer(mesh_, front);
Info << "Finished creating sheets at feature edges" << endl;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
......
......@@ -57,6 +57,9 @@ class createFundamentalSheetsJFS
public createFundamentalSheets
{
// Private member functions
//- check if all cells have only one face at the boundary
bool isTopologyOk() const;
//- create inital sheet from all boundary faces of the surface mesh
void createInitialSheet();
......
testEdgeExtractorFUN.C
EXE = $(FOAM_USER_APPBIN)/testEdgeExtractorFUN
EXE_INC = \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude \
-I../../meshLibrary/lnInclude
EXE_LIBS = \
-L$(FOAM_USER_LIBBIN) \
-lmeshLibrary \
-ledgeMesh \
-ltriSurface \
-lmeshTools
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2005-2007 Franjo Juretic
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Application
Test for smoothers
Description
- reads the mesh and tries to untangle negative volume cells
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "polyMeshGen.H"
#include "meshSurfaceEdgeExtractorFUN.H"
#include "triSurf.H"
#include "meshOctree.H"
#include "meshOctreeCreator.H"
#include "triSurfacePatchManipulator.H"
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
)
);
const fileName surfFile(meshDict.lookup("surfaceFile"));
const triSurf* surfacePtr = new triSurf(surfFile);
if( surfacePtr->featureEdges().size() != 0 )
{
//- create surface patches based on the feature edges
//- and update the meshDict based on the given data
triSurfacePatchManipulator manipulator(*surfacePtr);
const triSurf* surfaceWithPatches =
manipulator.surfaceWithPatches(&meshDict);
//- delete the old surface and assign the new one
deleteDemandDrivenData(surfacePtr);
surfacePtr = surfaceWithPatches;
}
meshOctree mo(*surfacePtr);
meshOctreeCreator(mo, meshDict).createOctreeWithRefinedBoundary(20, 30);
polyMeshGen pmg(runTime);
pmg.read();
meshSurfaceEdgeExtractorFUN(pmg, mo, false);
deleteDemandDrivenData(surfacePtr);
pmg.write();
Info << "End\n" << endl;
return 0;
}
// ************************************************************************* //
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment