distributed surfaces

This commit is contained in:
mattijs
2008-09-15 12:17:19 +01:00
parent 62223c712c
commit 00e865c8d5
10 changed files with 3010 additions and 123 deletions

View File

@ -25,6 +25,7 @@ License
\*----------------------------------------------------------------------------*/
#include "autoRefineDriver.H"
#include "meshRefinement.H"
#include "fvMesh.H"
#include "Time.H"
#include "boundBox.H"

View File

@ -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

View File

@ -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 : " << nTotEdges << nl
<< " Number of edges : " << nMasterFaces << 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;
nZoned++;
nUnblocked++;
}
}
}
}
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,12 +1094,20 @@ 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;
}
if (nUnblocked > 0 || nCouples > 0)
{
Info<< "Applying special decomposition to keep baffles"
<< " and zoned faces together." << endl;
distribution = decomposeCombineRegions
(
blockedFace,
@ -1102,6 +1131,12 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::meshRefinement::balance
// Normal decomposition
distribution = decomposer.decompose(mesh_.cellCentres());
}
}
else
{
// Normal decomposition
distribution = decomposer.decompose(mesh_.cellCentres());
}
if (debug)
{
@ -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();
}
}
}

View File

@ -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;

View File

@ -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.

View File

@ -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);
minLevelFields_.set
autoPtr<triSurfaceLabelField> minLevelFieldPtr
(
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 = minLevelFields_[surfI];
triSurfaceLabelField& minLevelField = minLevelFieldPtr();
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,33 +659,60 @@ 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)
{
n += hitInfo[pointI].size();
}
List<pointIndexHit> surfInfo(n);
labelList pointMap(n);
n = 0;
forAll(hitInfo, pointI)
{
const List<pointIndexHit>& pHits = hitInfo[pointI];
allGeometry_[surfaces_[surfI]].getRegion(pHits, pRegions);
allGeometry_[surfaces_[surfI]].getNormal(pHits, pNormals);
// 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.
forAll(pHits, pHitI)
forAll(pHits, i)
{
label region = globalRegion(surfI, pRegions[pHitI]);
surfInfo[n] = pHits[i];
pointMap[n] = pointI;
n++;
}
}
labelList surfRegion(n);
vectorField surfNormal(n);
allGeometry_[surfaces_[surfI]].getRegion(surfInfo, surfRegion);
allGeometry_[surfaces_[surfI]].getNormal(surfInfo, surfNormal);
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] = pNormals[pHitI];
surfaceNormal[pointI][sz] = surfNormal[i];
surfaceLevel[pointI].setSize(sz+1);
surfaceLevel[pointI][sz] = maxLevel_[region];
}
}
}
}
}

View File

@ -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&);

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,453 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Class
Foam::distributedTriSurfaceMesh
Description
IOoject and searching on triSurface
SourceFiles
distributedTriSurfaceMesh.C
\*---------------------------------------------------------------------------*/
#ifndef distributedTriSurfaceMesh_H
#define distributedTriSurfaceMesh_H
#include "triSurfaceMesh.H"
#include "IOdictionary.H"
#include "Pair.H"
#include "globalIndex.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class mapDistribute;
/*---------------------------------------------------------------------------*\
Class distributedTriSurfaceMesh Declaration
\*---------------------------------------------------------------------------*/
class distributedTriSurfaceMesh
:
public triSurfaceMesh
{
private:
// Static data
//- Merging distance
static scalar mergeDist_;
// Private member data
//- Bounding box settings
IOdictionary dict_;
//- bounding boxes of all processors
List<List<treeBoundBox> > procBb_;
//- Global triangle numbering
mutable autoPtr<globalIndex> globalTris_;
// Private Member Functions
// Read
//- Read my additional data
bool read();
// Line intersection
static bool isLocal
(
const List<treeBoundBox>& myBbs,
const point& start,
const point& end
);
//- Split segment into subsegments overlapping the processor
// bounding boxes. Sort per processor.
void splitSegment
(
const label,
const point& start,
const point& end,
DynamicList<Pair<point> >&,
DynamicList<label>&,
List<DynamicList<label> >&
) const;
//- Divide edges into local and remote segments. Construct map to
// distribute and collect data.
autoPtr<mapDistribute> constructSegments
(
const pointField& start,
const pointField& end,
List<Pair<point> >& allSegments,
List<label>& allSegmentMap
) const;
//- Split edges, distribute, test and collect.
void findLine
(
const bool nearestIntersection,
const pointField& start,
const pointField& end,
List<pointIndexHit>& info
) const;
// Triangle index
//- Obtains global indices from pointIndexHit and swaps them back
// to their original processor. Used to calculate local region
// and normal.
autoPtr<mapDistribute> calcLocalQueries
(
const List<pointIndexHit>&,
labelList& triangleIndex
) const;
// Nearest
label calcOverlappingProcs
(
const point& centre,
const scalar radiusSqr,
boolList& overlaps
) const;
autoPtr<mapDistribute> calcLocalQueries
(
const pointField& centres,
const scalarField& radiusSqr,
pointField& allCentres,
scalarField& allRadiusSqr,
labelList& allSegmentMap
) const;
// Surface redistribution
//- Calculate surface bounding box
void calcBounds(boundBox& bb, label& nPoints) const;
//- Does any part of triangle overlap bb.
static bool overlaps
(
const List<treeBoundBox>& bb,
const point& p0,
const point& p1,
const point& p2
);
//- Find points used in subset
static void subsetMeshMap
(
const triSurface& s,
const boolList& include,
const label nIncluded,
labelList& newToOldPoints,
labelList& oldToNewPoints,
labelList& newToOldFaces
);
//- Construct subsetted surface
static triSurface subsetMesh
(
const triSurface& s,
const labelList& newToOldPoints,
const labelList& oldToNewPoints,
const labelList& newToOldFaces
);
//- Subset given marked faces
static triSurface subsetMesh
(
const triSurface& s,
const boolList& include,
labelList& newToOldPoints,
labelList& newToOldFaces
);
//- Subset given marked faces
static triSurface subsetMesh
(
const triSurface& s,
const labelList& newToOldFaces,
labelList& newToOldPoints
);
//- Find triangle otherF in allFaces.
static label findTriangle
(
const List<labelledTri>& allFaces,
const labelListList& allPointFaces,
const labelledTri& otherF
);
//- Merge triSurface (subTris, subPoints) into allTris, allPoints.
static void merge
(
const scalar mergeDist,
const List<labelledTri>& subTris,
const pointField& subPoints,
List<labelledTri>& allTris,
pointField& allPoints,
labelList& faceConstructMap,
labelList& pointConstructMap
);
//- Distribute stored fields
template<class Type>
void distributeFields(const mapDistribute& map);
//- Disallow default bitwise copy construct
distributedTriSurfaceMesh(const distributedTriSurfaceMesh&);
//- Disallow default bitwise assignment
void operator=(const distributedTriSurfaceMesh&);
public:
//- Runtime type information
TypeName("distributedTriSurfaceMesh");
// Constructors
//- Construct from triSurface
distributedTriSurfaceMesh
(
const IOobject&,
const triSurface&,
const dictionary& dict
);
//- Construct read
distributedTriSurfaceMesh(const IOobject& io);
//- Construct from dictionary (used by searchableSurface)
distributedTriSurfaceMesh
(
const IOobject& io,
const dictionary& dict
);
// Destructor
virtual ~distributedTriSurfaceMesh();
//- Clear storage
void clearOut();
// Member Functions
//- Return merge distance
static scalar mergeDist()
{
return mergeDist_;
}
//- Set the merge distance, returning the previous value
static scalar setMergeDist(const scalar t)
{
if (t < -VSMALL)
{
FatalErrorIn
(
"scalar distributedTriSurfaceMesh::setMergeDist"
"(const scalar t)"
) << "Negative merge distance tolerance. This is not allowed."
<< abort(FatalError);
}
scalar oldTol = mergeDist_;
mergeDist_ = t;
return oldTol;
}
//- Triangle indexing (demand driven)
const globalIndex& globalTris() const;
// searchableSurface implementation
//- Whether supports volume type below. I.e. whether is closed.
// Not supported.
virtual bool hasVolumeType() const
{
return false;
}
//- Range of global indices that can be returned.
virtual label globalSize() const
{
const labelList& offsets = globalTris().offsets();
return offsets[offsets.size()-1];
}
virtual void findNearest
(
const pointField& sample,
const scalarField& nearestDistSqr,
List<pointIndexHit>&
) const;
virtual void findLine
(
const pointField& start,
const pointField& end,
List<pointIndexHit>&
) const;
virtual void findLineAny
(
const pointField& start,
const pointField& end,
List<pointIndexHit>&
) const;
//- Get all intersections in order from start to end.
virtual void findLineAll
(
const pointField& start,
const pointField& end,
List<List<pointIndexHit> >&
) const;
//- From a set of points and indices get the region
virtual void getRegion
(
const List<pointIndexHit>&,
labelList& region
) const;
//- From a set of points and indices get the normal
virtual void getNormal
(
const List<pointIndexHit>&,
vectorField& normal
) const;
//- Determine type (inside/outside/mixed) for point. unknown if
// cannot be determined (e.g. non-manifold surface)
virtual void getVolumeType
(
const pointField&,
List<volumeType>&
) const;
//- Set bounds of surface. Bounds currently set as list of
// bounding boxes. Will do redistribution of surface to locally
// have all triangles overlapping bounds.
// Larger bounds: more triangles (memory), more fully local tests
// (quick).
// keepNonLocal = true : keep triangles that do not overlap
// any processor bounds.
// Should really be split into a routine to determine decomposition
// and one that does actual distribution but determining
// decomposition with duplicate triangle merging requires
// same amoun as work as actual distribution.
virtual void distribute
(
const List<treeBoundBox>&,
const bool keepNonLocal,
autoPtr<mapDistribute>& faceMap,
autoPtr<mapDistribute>& pointMap
);
// Other
//- Specific to triSurfaceMesh: from a set of hits (points and
// indices) get the specified field. Misses do not get set.
virtual void getField
(
const word& fieldName,
const List<pointIndexHit>&,
labelList& values
) const;
//- Subset the part of surface that is overlapping bounds.
static triSurface overlappingSurface
(
const triSurface&,
const List<treeBoundBox>&,
labelList& subPointMap,
labelList& subFaceMap
);
//- Print some stats. Parallel aware version of
// triSurface::writeStats.
void writeStats(Ostream& os) const;
// regIOobject implementation
//- Write using given format, version and compression
virtual bool writeObject
(
IOstream::streamFormat fmt,
IOstream::versionNumber ver,
IOstream::compressionType cmp
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "distributedTriSurfaceMeshTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,139 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
\*---------------------------------------------------------------------------*/
#include "distributedTriSurfaceMesh.H"
#include "triSurfaceFields.H"
#include "mapDistribute.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
//template<class Type>
//void Foam::distributedTriSurfaceMesh::getField
//(
// const word& fieldName,
// const List<pointIndexHit>& info,
// List<Type>& values
//) const
//{
// typedef DimensionedField<Type, triSurfaceGeoMesh> DimensionedSurfField;
//
//
// // Get query data (= local index of triangle)
// // ~~~~~~~~~~~~~~
//
// labelList triangleIndex(info.size());
// autoPtr<mapDistribute> mapPtr
// (
// calcLocalQueries
// (
// info,
// triangleIndex
// )
// );
// const mapDistribute& map = mapPtr();
//
//
// // Do my tests
// // ~~~~~~~~~~~
//
// const DimensionedSurfField& fld = lookupObject<DimensionedSurfField>
// (
// fieldName
// );
// const triSurface& s = static_cast<const triSurface&>(*this);
//
// values.setSize(triangleIndex.size());
//
// forAll(triangleIndex, i)
// {
// label triI = triangleIndex[i];
// values[i] = fld[triI];
// }
//
//
// // Send back results
// // ~~~~~~~~~~~~~~~~~
//
// map.distribute
// (
// Pstream::nonBlocking,
// List<labelPair>(0),
// info.size(),
// map.constructMap(), // what to send
// map.subMap(), // what to receive
// values
// );
//}
template<class Type>
void Foam::distributedTriSurfaceMesh::distributeFields
(
const mapDistribute& map
)
{
typedef DimensionedField<Type, triSurfaceGeoMesh> DimensionedSurfField;
HashTable<const DimensionedSurfField*> fields
(
objectRegistry::lookupClass
<DimensionedSurfField >()
);
for
(
typename HashTable<const DimensionedSurfField*>::iterator fieldIter =
fields.begin();
fieldIter != fields.end();
++fieldIter
)
{
DimensionedSurfField& field =
const_cast<DimensionedSurfField&>(*fieldIter());
label oldSize = field.size();
map.distribute
(
Pstream::nonBlocking,
List<labelPair>(0),
map.constructSize(),
map.subMap(),
map.constructMap(),
field
);
if (debug)
{
Info<< "Mapped " << field.typeName << ' ' << field.name()
<< " from size " << oldSize << " to size " << field.size()
<< endl;
}
}
}
// ************************************************************************* //