search_swept_face.h
Go to the documentation of this file.
1 /*
2 This file is part of the Ristra portage project.
3 Please see the license file at the root of this repository, or at:
4  https://github.com/laristra/portage/blob/master/LICENSE
5 */
6 
7 #ifndef PORTAGE_SEARCH_SEARCH_SWEPT_FACE_H_
8 #define PORTAGE_SEARCH_SEARCH_SWEPT_FACE_H_
9 
10 #include <vector>
11 #include <algorithm>
12 
13 // portage includes
15 
16 namespace Portage {
17 
26 template <int D, Entity_kind on_what,
27  typename SourceMeshType, typename TargetMeshType>
29 public:
31  SearchSweptFace() = delete;
32 
33  // Constructor with Meshes
45  SearchSweptFace(const SourceMeshType & source_mesh,
46  const TargetMeshType & target_mesh)
47  : sourceMesh_(source_mesh), targetMesh_(target_mesh) {
48 #ifdef DEBUG
49  int numSourceCells = sourceMesh_.num_owned_cells() +
50  sourceMesh_.num_ghost_cells();
51  int numTargetCells = targetMesh_.num_owned_cells() +
52  targetMesh_.num_ghost_cells();
53  assert(numSourceCells == numTargetCells);
54 #endif
55  } // SearchSweptFace::SearchSweptFace
56 
58  SearchSweptFace(const SearchSweptFace&) = delete;
59 
61  SearchSweptFace & operator = (const SearchSweptFace &) = delete;
62 
64  ~SearchSweptFace() = default;
65 
75  std::vector<int> operator() (const int entityId) const {
76  std::vector<int> candidates;
77  std::cerr << "Swept face search is not implemented for a generic entity kind" << std::endl;
78  return candidates;
79  }
80 
81 private:
82  const SourceMeshType &sourceMesh_;
83  const TargetMeshType &targetMesh_;
84 }; // class SearchSweptFace
85 
93 template <int D, typename SourceMeshType, typename TargetMeshType>
94 class SearchSweptFace<D, Entity_kind::NODE, SourceMeshType, TargetMeshType> {
95 public:
97  SearchSweptFace() = delete;
98 
99  // Constructor with Meshes
112  SearchSweptFace(const SourceMeshType & source_mesh,
113  const TargetMeshType & target_mesh)
114  : sourceMesh_(source_mesh), targetMesh_(target_mesh) {
115 #ifdef DEBUG
116  int numSourceCells = sourceMesh_.num_owned_cells() +
117  sourceMesh_.num_ghost_cells();
118  int numTargetCells = targetMesh_.num_owned_cells() +
119  targetMesh_.num_ghost_cells();
120  assert(numSourceCells == numTargetCells);
121 #endif
122  } // SearchSweptFace::SearchSweptFace
123 
125  SearchSweptFace & operator = (const SearchSweptFace &) = delete;
126 
128  ~SearchSweptFace() = default;
129 
140  std::vector<int> operator() (const int entityId) const {
141  std::vector<int> candidates;
142  std::cerr << "Swept face search is not implemented for nodal control volumes" << std::endl;
143  return candidates;
144  }
145 
146 private:
147  const SourceMeshType &sourceMesh_;
148  const TargetMeshType &targetMesh_;
149 }; // class SearchSweptFace
150 
158 template <int D, typename SourceMeshType, typename TargetMeshType>
159 class SearchSweptFace<D, Entity_kind::CELL, SourceMeshType, TargetMeshType> {
160 public:
162  SearchSweptFace() = delete;
163 
164  // Constructor with Meshes
176  SearchSweptFace(const SourceMeshType & source_mesh,
177  const TargetMeshType & target_mesh)
178  : sourceMesh_(source_mesh), targetMesh_(target_mesh) {
179 #ifdef DEBUG
180  int numSourceCells = sourceMesh_.num_owned_cells() +
181  sourceMesh_.num_ghost_cells();
182  int numTargetCells = targetMesh_.num_owned_cells() +
183  targetMesh_.num_ghost_cells();
184  assert(numSourceCells == numTargetCells);
185 #endif
186  } // SearchSweptFace::SearchSweptFace
187 
189  SearchSweptFace & operator = (const SearchSweptFace &) = delete;
190 
192  ~SearchSweptFace() = default;
193 
203  std::vector<int> operator() (const int entityId) const {
204  std::vector<int> candidates;
205  sourceMesh_.cell_get_face_adj_cells(entityId, Entity_type::ALL, &candidates);
206 #ifdef DEBUG
207  std::vector<int> alt_candidates;
208  targetMesh_.cell_get_face_adj_cells(entityId, Entity_type::ALL, &alt_candidates);
209  assert(candidates.size() == alt_candidates.size());
210  int const num_candidates = candidates.size();
211  for (int icc = 0; icc < num_candidates; icc++)
212  assert(candidates[icc] == alt_candidates[icc]);
213 #endif
214 
215  return candidates;
216  }
217 
218 private:
219  const SourceMeshType &sourceMesh_;
220  const TargetMeshType &targetMesh_;
221 }; // class SearchSweptFace
222 
223 } // namespace Portage
224 
225 #endif // PORTAGE_SEARCH_SEARCH_SWEPT_FACE_H_
SearchSweptFace & operator=(const SearchSweptFace &)=delete
Assignment operator (disabled)
SearchSweptFace(const SourceMeshType &source_mesh, const TargetMeshType &target_mesh)
Builds the search structure for the swept face algorithm.
Definition: search_swept_face.h:112
std::vector< int > operator()(const int entityId) const
Find the source mesh entities that are adjacent to the given target mesh entity through the faces...
Definition: search_swept_face.h:75
~SearchSweptFace()=default
Destructor.
SearchSweptFace()=delete
Default constructor (disabled)
The search algorithm that is used for the swept face remap.
Definition: search_swept_face.h:28
SearchSweptFace(const SourceMeshType &source_mesh, const TargetMeshType &target_mesh)
Builds the search structure for the swept face algorithm.
Definition: search_swept_face.h:45
Definition: coredriver.h:42
SearchSweptFace(const SourceMeshType &source_mesh, const TargetMeshType &target_mesh)
Builds the search structure for the swept face algorithm.
Definition: search_swept_face.h:176