Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
00e865c8
Commit
00e865c8
authored
Sep 15, 2008
by
mattijs
Browse files
distributed surfaces
parent
62223c71
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
src/autoMesh/autoHexMesh/autoHexMeshDriver/autoRefineDriver.C
View file @
00e865c8
...
...
@@ -25,6 +25,7 @@ License
\*----------------------------------------------------------------------------*/
#include
"autoRefineDriver.H"
#include
"meshRefinement.H"
#include
"fvMesh.H"
#include
"Time.H"
#include
"boundBox.H"
...
...
src/autoMesh/autoHexMesh/autoHexMeshDriver/autoRefineDriver.H
View file @
00e865c8
...
...
@@ -35,7 +35,7 @@ SourceFiles
#ifndef autoRefineDriver_H
#define autoRefineDriver_H
#include
"
meshRefinement
.H"
#include
"
treeBoundBox
.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...
...
@@ -45,6 +45,9 @@ namespace Foam
// Forward declaration of classes
class
featureEdgeMesh
;
class
refinementParameters
;
class
meshRefinement
;
class
decompositionMethod
;
class
fvMeshDistribute
;
/*---------------------------------------------------------------------------*\
Class autoRefineDriver Declaration
...
...
src/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C
View file @
00e865c8
...
...
@@ -51,6 +51,9 @@ License
#include
"meshTools.H"
#include
"OFstream.H"
#include
"geomDecomp.H"
#include
"Random.H"
#include
"searchableSurfaces.H"
#include
"treeBoundBox.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
...
...
@@ -122,13 +125,36 @@ void Foam::meshRefinement::updateIntersections(const labelList& changedFaces)
{
const
pointField
&
cellCentres
=
mesh_
.
cellCentres
();
label
nTotEdges
=
returnReduce
(
surfaceIndex_
.
size
(),
sumOp
<
label
>
());
label
nChangedFaces
=
returnReduce
(
changedFaces
.
size
(),
sumOp
<
label
>
());
// Stats on edges to test. Count proc faces only once.
PackedList
<
1
>
isMasterFace
(
syncTools
::
getMasterFaces
(
mesh_
));
{
label
nMasterFaces
=
0
;
forAll
(
isMasterFace
,
faceI
)
{
if
(
isMasterFace
.
get
(
faceI
)
==
1
)
{
nMasterFaces
++
;
}
}
reduce
(
nMasterFaces
,
sumOp
<
label
>
());
label
nChangedFaces
=
0
;
forAll
(
changedFaces
,
i
)
{
if
(
isMasterFace
.
get
(
changedFaces
[
i
])
==
1
)
{
nChangedFaces
++
;
}
}
reduce
(
nChangedFaces
,
sumOp
<
label
>
());
Info
<<
"Edge intersection testing:"
<<
nl
<<
" Number of edges : "
<<
nMasterFaces
<<
nl
<<
" Number of edges to retest : "
<<
nChangedFaces
<<
endl
;
}
Info
<<
"Edge intersection testing:"
<<
nl
<<
" Number of edges : "
<<
nTotEdges
<<
nl
<<
" Number of edges to retest : "
<<
nChangedFaces
<<
endl
;
// Get boundary face centre and level. Coupled aware.
labelList
neiLevel
(
mesh_
.
nFaces
()
-
mesh_
.
nInternalFaces
());
...
...
@@ -838,11 +864,14 @@ Foam::meshRefinement::meshRefinement
Foam
::
label
Foam
::
meshRefinement
::
countHits
()
const
{
// Stats on edges to test. Count proc faces only once.
PackedList
<
1
>
isMasterFace
(
syncTools
::
getMasterFaces
(
mesh_
));
label
nHits
=
0
;
forAll
(
surfaceIndex_
,
faceI
)
{
if
(
surfaceIndex_
[
faceI
]
>=
0
)
if
(
surfaceIndex_
[
faceI
]
>=
0
&&
isMasterFace
.
get
(
faceI
)
==
1
)
{
nHits
++
;
}
...
...
@@ -996,11 +1025,6 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::meshRefinement::balance
if
(
Pstream
::
parRun
())
{
//Info<< nl
// << "Doing final balancing" << nl
// << "---------------------" << nl
// << endl;
//
//if (debug_)
//{
// const_cast<Time&>(mesh_.time())++;
...
...
@@ -1014,17 +1038,12 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::meshRefinement::balance
// Faces where owner and neighbour are not 'connected' so can
// go to different processors.
boolList
blockedFace
(
mesh_
.
nFaces
(),
true
);
label
nUnblocked
=
0
;
// Pairs of baffles
List
<
labelPair
>
couples
;
if
(
keepZoneFaces
)
{
label
nNamed
=
surfaces
().
getNamedSurfaces
().
size
();
Info
<<
"Found "
<<
nNamed
<<
" surfaces with faceZones."
<<
" Applying special decomposition to keep those together."
<<
endl
;
// Determine decomposition to keep/move surface zones
// on one processor. The reason is that snapping will make these
// into baffles, move and convert them back so if they were
...
...
@@ -1039,8 +1058,6 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::meshRefinement::balance
// Get faces whose owner and neighbour should stay together,
// i.e. they are not 'blocked'.
label
nZoned
=
0
;
forAll
(
fzNames
,
surfI
)
{
if
(
fzNames
[
surfI
].
size
()
>
0
)
...
...
@@ -1055,14 +1072,18 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::meshRefinement::balance
if
(
blockedFace
[
fZone
[
i
]])
{
blockedFace
[
fZone
[
i
]]
=
false
;
n
Zon
ed
++
;
n
Unblock
ed
++
;
}
}
}
}
Info
<<
"Found "
<<
returnReduce
(
nZoned
,
sumOp
<
label
>
())
<<
" zoned faces to keep together."
<<
endl
;
}
reduce
(
nUnblocked
,
sumOp
<
label
>
());
if
(
keepZoneFaces
)
{
Info
<<
"Found "
<<
nUnblocked
<<
" zoned faces to keep together."
<<
endl
;
}
if
(
keepBaffles
)
...
...
@@ -1073,29 +1094,43 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::meshRefinement::balance
identity
(
mesh_
.
nFaces
()
-
mesh_
.
nInternalFaces
())
+
mesh_
.
nInternalFaces
()
);
}
label
nCouples
=
returnReduce
(
couples
.
size
(),
sumOp
<
label
>
());
Info
<<
"Found "
<<
returnReduce
(
couples
.
size
(),
sumOp
<
label
>
())
<<
" baffles to keep together."
if
(
keepBaffles
)
{
Info
<<
"Found "
<<
nCouples
<<
" baffles to keep together."
<<
endl
;
}
distribution
=
decomposeCombineRegions
(
blockedFace
,
couples
,
decomposer
);
if
(
nUnblocked
>
0
||
nCouples
>
0
)
{
Info
<<
"Applying special decomposition to keep baffles"
<<
" and zoned faces together."
<<
endl
;
labelList
nProcCells
(
distributor
.
countCells
(
distribution
));
Pstream
::
listCombineGather
(
nProcCells
,
plusEqOp
<
label
>
());
Pstream
::
listCombineScatter
(
nProcCells
);
distribution
=
decomposeCombineRegions
(
blockedFace
,
couples
,
decomposer
);
Info
<<
"Calculated decomposition:"
<<
endl
;
forAll
(
nProcCells
,
procI
)
labelList
nProcCells
(
distributor
.
countCells
(
distribution
));
Pstream
::
listCombineGather
(
nProcCells
,
plusEqOp
<
label
>
());
Pstream
::
listCombineScatter
(
nProcCells
);
Info
<<
"Calculated decomposition:"
<<
endl
;
forAll
(
nProcCells
,
procI
)
{
Info
<<
" "
<<
procI
<<
'\t'
<<
nProcCells
[
procI
]
<<
endl
;
}
Info
<<
endl
;
}
else
{
Info
<<
" "
<<
procI
<<
'\t'
<<
nProcCells
[
procI
]
<<
endl
;
// Normal decomposition
distribution
=
decomposer
.
decompose
(
mesh_
.
cellCentres
());
}
Info
<<
endl
;
}
else
{
...
...
@@ -1715,6 +1750,36 @@ void Foam::meshRefinement::distribute(const mapDistributePolyMesh& map)
{
map
.
distributeFaceData
(
userFaceData_
[
i
].
second
());
}
// Redistribute surface and any fields on it.
{
Random
rndGen
(
653213
);
// Get local mesh bounding box. Single box for now.
List
<
treeBoundBox
>
meshBb
(
1
);
treeBoundBox
&
bb
=
meshBb
[
0
];
bb
=
boundBox
(
mesh_
.
points
(),
false
);
bb
=
bb
.
extend
(
rndGen
,
1E-4
);
// Distribute all geometry (so refinementSurfaces and shellSurfaces)
searchableSurfaces
&
geometry
=
const_cast
<
searchableSurfaces
&>
(
surfaces_
.
geometry
());
forAll
(
geometry
,
i
)
{
autoPtr
<
mapDistribute
>
faceMap
;
autoPtr
<
mapDistribute
>
pointMap
;
geometry
[
i
].
distribute
(
meshBb
,
false
,
// do not keep outside triangles
faceMap
,
pointMap
);
faceMap
.
clear
();
pointMap
.
clear
();
}
}
}
...
...
src/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C
View file @
00e865c8
...
...
@@ -386,7 +386,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::createBaffles
FatalErrorIn
(
"meshRefinement::createBaffles"
"(const
label, const
labelList&, const labelList&)"
"(const labelList&, const labelList&)"
)
<<
"Illegal size :"
<<
" ownPatch:"
<<
ownPatch
.
size
()
<<
" neiPatch:"
<<
neiPatch
.
size
()
...
...
@@ -412,7 +412,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::createBaffles
FatalErrorIn
(
"meshRefinement::createBaffles"
"(const
label, const
labelList&, const labelList&)"
"(const labelList&, const labelList&)"
)
<<
"Non synchronised at face:"
<<
faceI
<<
" on patch:"
<<
mesh_
.
boundaryMesh
().
whichPatch
(
faceI
)
<<
" fc:"
<<
mesh_
.
faceCentres
()[
faceI
]
<<
endl
...
...
@@ -461,7 +461,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::createBaffles
//- Redo the intersections on the newly create baffle faces. Note that
// this changes also the cell centre positions.
labelHashSet
baffledFacesSet
(
2
*
nBaffles
);
faceSet
baffledFacesSet
(
mesh_
,
"
baffledFacesSet
"
,
2
*
nBaffles
);
const
labelList
&
reverseFaceMap
=
map
().
reverseFaceMap
();
const
labelList
&
faceMap
=
map
().
faceMap
();
...
...
@@ -496,6 +496,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::createBaffles
}
}
}
baffledFacesSet
.
sync
(
mesh_
);
updateMesh
(
map
,
baffledFacesSet
.
toc
());
...
...
@@ -1886,15 +1887,15 @@ void Foam::meshRefinement::baffleAndSplitMesh
labelList
facePatch
(
//markFacesOnProblemCells
//(
// globalToPatch
//)
markFacesOnProblemCellsGeometric
markFacesOnProblemCells
(
motionDict
,
globalToPatch
)
//markFacesOnProblemCellsGeometric
//(
// motionDict,
// globalToPatch
//)
);
Info
<<
"Analyzed problem cells in = "
<<
runTime
.
cpuTimeIncrement
()
<<
" s
\n
"
<<
nl
<<
endl
;
...
...
src/autoMesh/autoHexMesh/meshRefinement/meshRefinementRefine.C
View file @
00e865c8
...
...
@@ -1091,8 +1091,8 @@ Foam::labelList Foam::meshRefinement::refineCandidates
// << " local allowable refinement:" << nAllowRefine << nl
// << endl;
//- Disable refinement shortcut
label
nAllowRefine
=
labelMax
;
//- Disable refinement shortcut
. nAllowRefine is per processor limit.
label
nAllowRefine
=
labelMax
/
Pstream
::
nProcs
()
;
// Marked for refinement (>= 0) or not (-1). Actual value is the
// index of the surface it intersects.
...
...
src/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C
View file @
00e865c8
...
...
@@ -25,19 +25,13 @@ License
\*----------------------------------------------------------------------------*/
#include
"refinementSurfaces.H"
#include
"orientedSurface.H"
#include
"Time.H"
#include
"searchableSurfaces.H"
#include
"shellSurfaces.H"
#include
"triSurfaceMesh.H"
#include
"labelPair.H"
#include
"searchableSurfacesQueries.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
#include
"UPtrList.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
...
...
@@ -438,31 +432,6 @@ Foam::labelList Foam::refinementSurfaces::getClosedNamedSurfaces() const
}
// Orient surface (if they're closed) before any searching is done.
void
Foam
::
refinementSurfaces
::
orientSurface
(
const
point
&
keepPoint
,
triSurfaceMesh
&
s
)
{
// Flip surface so keepPoint is outside.
bool
anyFlipped
=
orientedSurface
::
orient
(
s
,
keepPoint
,
true
);
if
(
anyFlipped
)
{
// orientedSurface will have done a clearOut of the surface.
// we could do a clearout of the triSurfaceMeshes::trees()
// but these aren't affected by orientation (except for cached
// sideness which should not be set at this point. !!Should
// check!)
Info
<<
"orientSurfaces : Flipped orientation of surface "
<<
s
.
searchableSurface
::
name
()
<<
" so point "
<<
keepPoint
<<
" is outside."
<<
endl
;
}
}
// Count number of triangles per surface region
Foam
::
labelList
Foam
::
refinementSurfaces
::
countRegions
(
const
triSurface
&
s
)
{
...
...
@@ -485,7 +454,7 @@ void Foam::refinementSurfaces::setMinLevelFields
const
shellSurfaces
&
shells
)
{
minLevelFields_
.
setSize
(
surfaces_
.
size
());
//
minLevelFields_.setSize(surfaces_.size());
forAll
(
surfaces_
,
surfI
)
{
...
...
@@ -495,26 +464,24 @@ void Foam::refinementSurfaces::setMinLevelFields
{
const
triSurfaceMesh
&
triMesh
=
refCast
<
const
triSurfaceMesh
>
(
geom
);
minLevelField
s_
.
set
autoPtr
<
triSurfaceLabelField
>
minLevelField
Ptr
(
surfI
,
new
triSurfaceLabelField
(
IOobject
(
triMesh
.
searchableSurface
::
name
()
,
"minLevel"
,
triMesh
.
objectRegistry
::
time
().
constant
(),
// directory
"triSurface"
,
// instance
triMesh
,
IOobject
::
NO_READ
,
IOobject
::
AUTO_WRITE
,
false
IOobject
::
AUTO_WRITE
),
triMesh
,
dimless
)
);
triSurfaceLabelField
&
minLevelField
=
minLevelField
s_
[
surfI
]
;
triSurfaceLabelField
&
minLevelField
=
minLevelField
Ptr
()
;
const
triSurface
&
s
=
static_cast
<
const
triSurface
&>
(
triMesh
);
...
...
@@ -542,6 +509,9 @@ void Foam::refinementSurfaces::setMinLevelFields
shellLevel
[
triI
]
);
}
// Store field on triMesh
minLevelFieldPtr
.
ptr
()
->
store
();
}
}
}
...
...
@@ -569,17 +539,38 @@ void Foam::refinementSurfaces::findHigherIntersection
return
;
}
// Precalculate per surface whether it has a minlevelfield
UPtrList
<
triSurfaceLabelField
>
minLevelFields
(
surfaces_
.
size
());
forAll
(
surfaces_
,
surfI
)
{
const
searchableSurface
&
geom
=
allGeometry_
[
surfaces_
[
surfI
]];
if
(
isA
<
triSurfaceMesh
>
(
geom
))
{
const
triSurfaceMesh
&
triMesh
=
refCast
<
const
triSurfaceMesh
>
(
geom
);
minLevelFields
.
set
(
surfI
,
&
const_cast
<
triSurfaceLabelField
&>
(
triMesh
.
lookupObject
<
triSurfaceLabelField
>
(
"minLevel"
)
)
);
}
}
// Work arrays
labelList
hitMap
(
identity
(
start
.
size
()));
pointField
p0
(
start
);
pointField
p1
(
end
);
List
<
pointIndexHit
>
hitInfo
(
start
.
size
());
forAll
(
surfaces_
,
surfI
)
{
allGeometry_
[
surfaces_
[
surfI
]].
findLineAny
(
p0
,
p1
,
hitInfo
);
// Copy all hits into arguments, continue with misses
label
newI
=
0
;
forAll
(
hitInfo
,
hitI
)
...
...
@@ -592,12 +583,12 @@ void Foam::refinementSurfaces::findHigherIntersection
// Check if minLevelField for this surface.
if
(
minLevelFields
_
.
set
(
surfI
)
&&
minLevelFields
_
[
surfI
].
size
()
>
0
minLevelFields
.
set
(
surfI
)
&&
minLevelFields
[
surfI
].
size
()
>
0
)
{
minLocalLevel
=
minLevelFields
_
[
surfI
][
hitInfo
[
hitI
].
index
()];
minLevelFields
[
surfI
][
hitInfo
[
hitI
].
index
()];
}
else
{
...
...
@@ -668,30 +659,57 @@ void Foam::refinementSurfaces::findAllHigherIntersections
{
allGeometry_
[
surfaces_
[
surfI
]].
findLineAll
(
start
,
end
,
hitInfo
);
// Repack hits for surface into flat list
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// To avoid overhead of calling getRegion for every point
label
n
=
0
;
forAll
(
hitInfo
,
pointI
)
{
const
List
<
pointIndexHit
>&
pHits
=
hitInfo
[
pointI
];
allGeometry_
[
surfaces_
[
surfI
]].
getRegion
(
pHits
,
pRegions
);
allGeometry_
[
surfaces_
[
surfI
]].
getNormal
(
pHits
,
pNormals
);
n
+=
hitInfo
[
pointI
].
size
();
}
// Extract those hits that are on higher levelled surfaces.
// Note: should move extraction of region, normal outside of loop
// below for if getRegion/getNormal have high overhead.
List
<
pointIndexHit
>
surfInfo
(
n
);
labelList
pointMap
(
n
);
n
=
0
;
forAll
(
pHits
,
pHitI
)
forAll
(
hitInfo
,
pointI
)
{
const
List
<
pointIndexHit
>&
pHits
=
hitInfo
[
pointI
];
forAll
(
pHits
,
i
)
{
label
region
=
globalRegion
(
surfI
,
pRegions
[
pHitI
]);
surfInfo
[
n
]
=
pHits
[
i
];
pointMap
[
n
]
=
pointI
;
n
++
;
}
}
if
(
maxLevel_
[
region
]
>
currentLevel
[
pointI
])
{
// Append to pointI info
label
sz
=
surfaceNormal
[
pointI
].
size
();
surfaceNormal
[
pointI
].
setSize
(
sz
+
1
);
surfaceNormal
[
pointI
][
sz
]
=
pNormals
[
pHitI
];
labelList
surfRegion
(
n
);
vectorField
surfNormal
(
n
);
allGeometry_
[
surfaces_
[
surfI
]].
getRegion
(
surfInfo
,
surfRegion
);
allGeometry_
[
surfaces_
[
surfI
]].
getNormal
(
surfInfo
,
surfNormal
);
surfaceLevel
[
pointI
].
setSize
(
sz
+
1
);
surfaceLevel
[
pointI
][
sz
]
=
maxLevel_
[
region
];
}
surfInfo
.
clear
();
// Extract back into pointwise
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
forAll
(
surfRegion
,
i
)
{
label
region
=
globalRegion
(
surfI
,
surfRegion
[
i
]);
label
pointI
=
pointMap
[
i
];
if
(
maxLevel_
[
region
]
>
currentLevel
[
pointI
])
{
// Append to pointI info
label
sz
=
surfaceNormal
[
pointI
].
size
();
surfaceNormal
[
pointI
].
setSize
(
sz
+
1
);
surfaceNormal
[
pointI
][
sz
]
=
surfNormal
[
i
];
surfaceLevel
[
pointI
].
setSize
(
sz
+
1
);
surfaceLevel
[
pointI
][
sz
]
=
maxLevel_
[
region
];
}
}
}
...
...
src/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.H
View file @
00e865c8
...
...
@@ -90,9 +90,6 @@ class refinementSurfaces
//- From global region number to refinement level
labelList
maxLevel_
;
//- Per surface refinement level adapted for shells.
PtrList
<
triSurfaceLabelField
>
minLevelFields_
;
// Private Member Functions
...
...
@@ -213,13 +210,6 @@ public:
const
shellSurfaces
&
shells
);
//- Helper: orient (closed only) surfaces so keepPoint is outside.
static
void
orientSurface
(
const
point
&
keepPoint
,
triSurfaceMesh
&
surface
);
//- Helper: count number of triangles per region
static
labelList
countRegions
(
const
triSurface
&
);
...
...
src/meshTools/searchableSurface/distributedTriSurfaceMesh.C
0 → 100644
View file @
00e865c8
This diff is collapsed.
Click to expand it.
src/meshTools/searchableSurface/distributedTriSurfaceMesh.H
0 → 100644
View file @
00e865c8
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\/ 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA