meshOctreeModifierUpdateCommunicationPattern.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | cfMesh: A library for mesh generation
4  \\ / O peration |
5  \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6  \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of cfMesh.
10 
11  cfMesh is free software; you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by the
13  Free Software Foundation; either version 3 of the License, or (at your
14  option) any later version.
15 
16  cfMesh is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
23 
24 Description
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "meshOctreeModifier.H"
29 #include "HashSet.H"
30 
31 # ifdef USE_OMP
32 #include <omp.h>
33 # endif
34 
35 //#define OCTREETiming
36 //#define OCTREE_DEBUG
37 
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 
40 namespace Foam
41 {
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
46 {
47  # ifdef OCTREETiming
48  const scalar startTime = omp_get_wtime();
49  # endif
50 
52 
53  //- create the list which contains ranges of addresses at a given processor
55 
56  //- create the range for the current processor
57  range[Pstream::myProcNo()].first() = leaves[0]->coordinates();
58  range[Pstream::myProcNo()].second() =
59  leaves[leaves.size()-1]->coordinates();
60 
61  //- communicate missing ranges
64 
65  //- find missing child cubes in the tree. These coordinates are located on
66  //- other processors, and they must fit in the range of cubes located
67  //- on that processor.
70 
71  labelHashSet newNeiProcs;
72  forAll(migratedCubes, mcI)
73  {
74  const meshOctreeCubeCoordinates& cc = migratedCubes[mcI];
75  forAll(range, procI)
76  {
77  if( procI == Pstream::myProcNo() )
78  continue;
79 
80  if( (cc >= range[procI].first()) && (cc <= range[procI].second()) )
81  newNeiProcs.insert(procI);
82  }
83  }
84 
85  //- create new neighbour procs and their range
86  octree_.neiProcs_ = newNeiProcs.toc();
87 
91 
92  # ifdef OCTREETiming
93  Info << "Time for updating communication pattern "
94  << (omp_get_wtime()-startTime) << endl;
95  # endif
96 }
97 
98 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
99 
100 } // End namespace Foam
101 
102 // ************************************************************************* //
Foam::meshOctree::neiRange_
List< Pair< meshOctreeCubeCoordinates > > neiRange_
Definition: meshOctree.H:68
Foam::HashTable::toc
List< Key > toc() const
Return the table of contents.
Definition: HashTable.C:201
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::meshOctreeCubeCoordinates
Definition: meshOctreeCubeCoordinates.H:55
Foam::Pstream::scatterList
static void scatterList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Scatter data. Reverse of gatherList.
Definition: gatherScatterList.C:205
Foam::meshOctreeCube::findCoordinatesOfMissingCubes
void findCoordinatesOfMissingCubes(LongList< meshOctreeCubeCoordinates > &coordinates) const
find coordinates of cubes which are located on other processors
Definition: meshOctreeCubeRecursiveFunctions.C:207
Foam::UPstream::nProcs
static label nProcs(const label communicator=0)
Number of processes in parallel run.
Definition: UPstream.H:387
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::LongList::size
label size() const
Size of the active part of the list.
Definition: LongListI.H:203
Foam::HashSet< label, Hash< label > >
meshOctreeModifier.H
Foam::LongList
Definition: LongList.H:55
Foam::Info
messageStream Info
HashSet.H
Foam::meshOctree::leaves_
LongList< meshOctreeCube * > leaves_
list of cubes which are leaves of the octree
Definition: meshOctree.H:89
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::meshOctree::neiProcs_
labelList neiProcs_
Definition: meshOctree.H:63
Foam::meshOctreeModifier::updateCommunicationPattern
void updateCommunicationPattern()
Definition: meshOctreeModifierUpdateCommunicationPattern.C:45
Foam::UPstream::myProcNo
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Definition: UPstream.H:405
Foam::Pstream::gatherList
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
Definition: gatherScatterList.C:49
range
scalar range
Definition: LISASMDCalcMethod1.H:12
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::HashSet::insert
bool insert(const Key &key)
Insert a new entry.
Definition: HashSet.H:116
startTime
Foam::label startTime
Definition: checkTimeOptions.H:5
Foam::meshOctree::initialCubePtr_
meshOctreeCube * initialCubePtr_
Root cube of the octree structure.
Definition: meshOctree.H:71
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::meshOctreeModifier::octree_
meshOctree & octree_
Reference to the octree.
Definition: meshOctreeModifier.H:52