Commit 98242960 authored by franjo's avatar franjo
Browse files

Progress towards multi-material meshing


git-svn-id: https://pl5.projectlocker.com/igui/meshGeneration/svn@7 fdcce57e-7e00-11e2-b579-49867b4cea03
parent b4ee75c4
EXE_INC = \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude -g -ggdb -DFULLDEBUG -O0
-I$(LIB_SRC)/meshTools/lnInclude
/* EXE_LIBS = -lcfdTools */
......@@ -29,8 +29,11 @@ Description
#include "findNonManifoldInterfaces.H"
#include "meshOctree.H"
#include "findCellsIntersectingSurface.H"
#include "triSurf.H"
#include "demandDrivenData.H"
#define DEBUGNonManifoldInterfaces
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
......@@ -40,14 +43,169 @@ namespace Foam
void findNonManifoldInterfaces::findIntersectedCells()
{
Info << "Starting finding cells intersected by the surface" << endl;
findCellsIntersectingSurface cis(mesh_, octree_);
intersectedCells_ = cis.facetsIntersectingCells();
const VRWGraph& facetsIntersectedCells = cis.facetsIntersectingCells();
//- find which surface patches intersect a cell
const triSurf& surface = octree_.surface();
patchesIntersectingCells_.clear();
patchesIntersectingCells_.setSize(facetsIntersectedCells.size());
forAll(facetsIntersectedCells, cellI)
{
forAllRow(facetsIntersectedCells, cellI, i)
{
const label triI = facetsIntersectedCells(cellI, i);
patchesIntersectingCells_.appendIfNotIn
(
cellI,
surface[triI].region()
);
}
}
# ifdef DEBUGNonManifoldInterfaces
Map<label> regionToID;
forAll(patchesIntersectingCells_, cellI)
{
forAllRow(patchesIntersectingCells_, cellI, i)
{
const label regionI = patchesIntersectingCells_(cellI, i);
Map<label>::iterator iter = regionToID.find(regionI);
if( iter == regionToID.end() )
{
const word sName =
"intersected_"+mesh_.boundaries()[regionI].patchName();
regionToID.insert
(
regionI,
mesh_.addCellSubset(sName)
);
iter = regionToID.find(regionI);
}
mesh_.addCellToSubset(iter(), cellI);
}
}
# endif
Info << "Finished finding cells intersected by the surface" << endl;
}
void findNonManifoldInterfaces::findNeighbouringGroups()
{
//- start assigning neighbouring cells of the intersected cells into groups
neiGroups_.setSize(0);
neiGroups_.setSize(patchesIntersectingCells_.size());
const labelList& owner = mesh_.owner();
const labelList& neighbour = mesh_.neighbour();
for(label fI=0;fI<mesh_.nInternalFaces();++fI)
{
const label own = owner[fI];
const label nei = neighbour[fI];
if( patchesIntersectingCells_.sizeOfRow(own) )
{
forAllRow(patchesIntersectingCells_, own, i)
{
const label patchI = patchesIntersectingCells_(own, i);
if( !patchesIntersectingCells_.contains(nei, patchI) )
neiGroups_.append(nei, patchI);
}
}
else if( patchesIntersectingCells_.sizeOfRow(nei) )
{
forAllRow(patchesIntersectingCells_, nei, i)
{
const label patchI = patchesIntersectingCells_(nei, i);
if( !patchesIntersectingCells_.contains(own, patchI) )
neiGroups_.append(own, patchI);
}
}
}
# ifdef DEBUGNonManifoldInterfaces
Map<label> regionToID;
forAll(neiGroups_, cellI)
{
forAllRow(neiGroups_, cellI, i)
{
const label regionI = neiGroups_(cellI, i);
Map<label>::iterator iter = regionToID.find(regionI);
if( iter == regionToID.end() )
{
const word sName =
"neighboursOfPatch_" +
mesh_.boundaries()[regionI].patchName();
regionToID.insert
(
regionI,
mesh_.addCellSubset(sName)
);
iter = regionToID.find(regionI);
}
mesh_.addCellToSubset(iter(), cellI);
}
}
# endif
}
bool findNonManifoldInterfaces::findFaceCandidates()
{
internalFacePatches_.clear();
internalFacePatches_.setSize(mesh_.nInternalFaces());
const labelList& owner = mesh_.owner();
const labelList& neighbour = mesh_.neighbour();
forAll(internalFacePatches_, faceI)
{
const label own = owner[faceI];
const label nei = neighbour[faceI];
forAllRow(patchesIntersectingCells_, own , i)
{
const label patchI = patchesIntersectingCells_(own, i);
if(
!patchesIntersectingCells_.contains(nei, patchI) &&
neiGroups_.contains(nei, patchI)
)
internalFacePatches_.appendIfNotIn(faceI, patchI);
}
forAllRow(patchesIntersectingCells_, nei , i)
{
const label patchI = patchesIntersectingCells_(nei, i);
if(
!patchesIntersectingCells_.contains(own, patchI) &&
neiGroups_.contains(own, patchI)
)
internalFacePatches_.appendIfNotIn(faceI, patchI);
}
}
//- check if there exist any proximity problems
forAll(internalFacePatches_, faceI)
{
if( internalFacePatches_.sizeOfRow(faceI) < 2 )
continue;
//- check if it is a proximity problem
}
return false;
}
bool findNonManifoldInterfaces::extractInterfaces()
......@@ -59,7 +217,7 @@ bool findNonManifoldInterfaces::extractInterfaces()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from mesh, octree, regions for boundary vertices
// Construct from mesh and octree
findNonManifoldInterfaces::findNonManifoldInterfaces
(
polyMeshGen& mesh,
......@@ -67,7 +225,10 @@ findNonManifoldInterfaces::findNonManifoldInterfaces
)
:
mesh_(mesh),
octree_(octree)
octree_(octree),
patchesIntersectingCells_(),
neiGroups_(),
internalFacePatches_()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
......@@ -79,7 +240,20 @@ findNonManifoldInterfaces::~findNonManifoldInterfaces()
void findNonManifoldInterfaces::createNonManifoldInterfaces()
{
do
{
//- find cells intersected by the surface
findIntersectedCells();
//- find cells near the intersected cells
findNeighbouringGroups();
} while( findFaceCandidates() );
if( extractInterfaces() )
WarningIn
(
"void findNonManifoldInterfaces::createNonManifoldInterfaces()"
) << "Could not generate all internal interfaces" << endl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -62,12 +62,16 @@ class findNonManifoldInterfaces
const meshOctree& octree_;
//- graph of mesh cells intesected by surface facets
VRWGraph intersectedCells_;
VRWGraph patchesIntersectingCells_;
//- cell groups assigned to neighbouring cells
//- of the intersected cells
VRWGraph neiGroups_;
//- store information about face candidates
//- and the patches they may be mapped to
VRWGraph internalFacePatches_;
// Private member functions
//- find intersected cells
void findIntersectedCells();
......@@ -75,6 +79,10 @@ class findNonManifoldInterfaces
//- find neighbouring groups
void findNeighbouringGroups();
//- find faces which are candidates to be constrained
//- to the internal interfaces
bool findFaceCandidates();
//- extract non-manifold interfaces
bool extractInterfaces();
......
testNonManifoldInterfaces.C
EXE = $(FOAM_USER_APPBIN)/testNonManifoldInterfaces
EXE_INC = -I$(LIB_SRC)/triSurface/lnInclude -I$(LIB_SRC)/meshTools/lnInclude -I../../meshLibrary/lnInclude
EXE_LIBS = -lMeshLibrary -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 "findNonManifoldInterfaces.H"
#include "meshOctree.H"
#include "meshOctreeCreator.H"
#include "triSurf.H"
#include "Time.H"
#include "polyMeshGen.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
polyMeshGen pmg(runTime);
pmg.read();
Info << "Finished reading mesh" << endl;
IOdictionary meshDict
(
IOobject
(
"meshDict",
runTime.system(),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
const fileName surfaceFile = meshDict.lookup("surfaceFile");
triSurf surf(runTime.path()/surfaceFile);
// construct the octree
meshOctree octree(surf);
meshOctreeCreator(octree, meshDict).createOctreeWithRefinedBoundary(8);
findNonManifoldInterfaces nmi(pmg, octree);
nmi.createNonManifoldInterfaces();
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