GEOS
ParallelTopologyChange.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2016-2024 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2024 TotalEnergies
7  * Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University
8  * Copyright (c) 2023-2024 Chevron
9  * Copyright (c) 2019- GEOS/GEOSX Contributors
10  * All rights reserved
11  *
12  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
13  * ------------------------------------------------------------------------------------------------------------
14  */
15 
20 #ifndef GEOS_PHYSICSSOLVERS_SURFACEGENERATION_PARALLELTOPOLOGYCHANGE_HPP_
21 #define GEOS_PHYSICSSOLVERS_SURFACEGENERATION_PARALLELTOPOLOGYCHANGE_HPP_
22 
23 #include "common/DataTypes.hpp"
25 
26 #define PARALLEL_TOPOLOGY_CHANGE_METHOD 1
27 
28 namespace geos
29 {
30 class MeshLevel;
31 class NeighborCommunicator;
32 
34 {
35  std::set< localIndex > newNodes;
36  std::set< localIndex > newEdges;
37  std::set< localIndex > newFaces;
38  std::set< localIndex > modifiedNodes;
39  std::set< localIndex > modifiedEdges;
40  std::set< localIndex > modifiedFaces;
41  map< std::pair< localIndex, localIndex >, std::set< localIndex > > newElements;
42  map< std::pair< localIndex, localIndex >, std::set< localIndex > > modifiedElements;
43 
44  void clearNewFromModified()
45  {
46  for( localIndex const a : newNodes )
47  {
48  modifiedNodes.erase( a );
49  }
50 
51  for( localIndex const a : newEdges )
52  {
53  modifiedEdges.erase( a );
54  }
55 
56  for( localIndex const a : newFaces )
57  {
58  modifiedFaces.erase( a );
59  }
60  }
61 
62  void insert( ModifiedObjectLists const & modifiedObjects )
63  {
64  newNodes.insert( modifiedObjects.newNodes.begin(),
65  modifiedObjects.newNodes.end() );
66  modifiedNodes.insert( modifiedObjects.modifiedNodes.begin(),
67  modifiedObjects.modifiedNodes.end() );
68 
69  newEdges.insert( modifiedObjects.newEdges.begin(),
70  modifiedObjects.newEdges.end() );
71  modifiedEdges.insert( modifiedObjects.modifiedEdges.begin(),
72  modifiedObjects.modifiedEdges.end() );
73 
74  newFaces.insert( modifiedObjects.newFaces.begin(),
75  modifiedObjects.newFaces.end() );
76  modifiedFaces.insert( modifiedObjects.modifiedFaces.begin(),
77  modifiedObjects.modifiedFaces.end() );
78 
79  for( auto & iter : modifiedObjects.newElements )
80  {
81  std::pair< localIndex, localIndex > const & key = iter.first;
82  std::set< localIndex > const & values = iter.second;
83  newElements[key].insert( values.begin(), values.end() );
84  }
85 
86  for( auto & iter : modifiedObjects.modifiedElements )
87  {
88  std::pair< localIndex, localIndex > const & key = iter.first;
89  std::set< localIndex > const & values = iter.second;
90  modifiedElements[key].insert( values.begin(), values.end() );
91  }
92 
93  }
94 };
95 
96 namespace parallelTopologyChange
97 {
98 
99 void synchronizeTopologyChange( MeshLevel * const mesh,
101  ModifiedObjectLists & modifiedObjects,
102  ModifiedObjectLists & receivedObjects,
103  int mpiCommOrder );
104 
105 
106 
108 {
109  void init( ElementRegionManager const & elemManager )
110  {
111  m_nodes.resize( 0 );
112  m_edges.resize( 0 );
113  m_faces.resize( 0 );
114  m_elements.resize( elemManager.numRegions() );
115  m_elementsView.resize( elemManager.numRegions() );
116  m_elementsData.resize( elemManager.numRegions() );
117  m_size = 0;
118 
119  for( localIndex er=0; er<elemManager.numRegions(); ++er )
120  {
121  ElementRegionBase const & elemRegion = elemManager.getRegion( er );
122  m_elements[er].resize( elemRegion.numSubRegions());
123  m_elementsView[er].resize( elemRegion.numSubRegions());
124  m_elementsData[er].resize( elemRegion.numSubRegions());
125  for( localIndex esr=0; esr<elemRegion.numSubRegions(); ++esr )
126  {
127  m_elementsData[er][esr].resize( 0 );
128  m_elements[er][esr].set( m_elementsData[er][esr] );
129  m_elementsView[er][esr] = m_elementsData[er][esr];
130  }
131  }
132  }
133 
134 
135  localIndex_array m_nodes;
136  localIndex_array m_edges;
137  localIndex_array m_faces;
140 
141  array1d< array1d< localIndex_array > > m_elementsData;
142  buffer_type::size_type m_size;
143 
144 };
145 
147 {
148  void init( buffer_type const & receiveBuffer,
149  ElementRegionManager const & elemManager )
150  {
151  m_bufferPtr = receiveBuffer.data();
152  TopologyChangeStepData::init( elemManager );
153  }
154 
155  buffer_unit_type const * m_bufferPtr;
156 };
157 
158 }
159 
160 }
161 
162 #endif /* GEOS_PHYSICSSOLVERS_SURFACEGENERATION_PARALLELTOPOLOGYCHANGE_HPP_ */
The ElementRegionBase is the base class to manage the data stored at the element level.
localIndex numSubRegions() const
Get the number of subregions in the region.
The ElementRegionManager class provides an interface to ObjectManagerBase in order to manage ElementR...
array1d< array1d< ReferenceWrapper< VIEWTYPE > > > ElementReferenceAccessor
The ElementViewAccessor at the ElementRegionManager level is a 2D array of ReferenceWrapper around VI...
localIndex numRegions() const
Get number of the regions.
array1d< array1d< VIEWTYPE > > ElementViewAccessor
The ElementViewAccessor at the ElementRegionManager level is an array of array of VIEWTYPE.
T const & getRegion(KEY_TYPE const &key) const
Get a element region.
Class facilitating the representation of a multi-level discretization of a MeshBody.
Definition: MeshLevel.hpp:42
Base template for ordered and unordered maps.
Definition: DataTypes.hpp:337
array1d< localIndex > localIndex_array
A 1-dimensional array of geos::localIndex types.
Definition: DataTypes.hpp:407
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:84
stdVector< buffer_unit_type > buffer_type
Type of storage for communication buffers.
Definition: DataTypes.hpp:124
std::vector< T, Allocator > stdVector
signed char buffer_unit_type
Type stored in communication buffers.
Definition: DataTypes.hpp:117
Array< T, 1 > array1d
Alias for 1D array.
Definition: DataTypes.hpp:184