opm-simulators
GridDataOutput.hpp
Go to the documentation of this file.
1 /*
2  Copyright 2023 Inria, Bretagne–Atlantique Research Center
3 
4  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef OPM_GRID_DATA_OUTPUT_HPP
21 #define OPM_GRID_DATA_OUTPUT_HPP
22 
23 #include <opm/common/ErrorMacros.hpp>
24 
25 #include <dune/grid/common/partitionset.hh>
26 
27 #include <iosfwd>
28 #include <string>
29 
88 namespace Opm::GridDataOutput
89 {
93 enum ConnectivityVertexOrder { DUNE = 0, VTK = 1 };
94 
95 template <class GridView, unsigned int partitions>
97 {
98 public:
131  explicit SimMeshDataAccessor(const GridView& gridView,
132  Dune::PartitionSet<partitions> dunePartition);
133 
142  bool polyhedralCellPresent() const;
143 
151  void countEntities();
152 
165  template <typename T>
166  long writeGridPoints(T* x_inout, T* y_inout, T* z_inout, long max_size = 0) const;
167 
181  template <typename VectType>
182  long writeGridPoints(VectType& x_inout, VectType& y_inout, VectType& z_inout) const;
183 
194  template <typename T>
195  long writeGridPoints_AOS(T* xyz_inout, long max_size = 0) const;
196 
206  template <typename VectType>
207  long writeGridPoints_AOS(VectType& xyz_inout) const;
208 
219  template <typename T>
220  long writeGridPoints_SOA(T* xyz_inout, long max_size = 0) const;
221 
231  template <typename VectType>
232  long writeGridPoints_SOA(VectType& xyz_inout) const;
233 
245  template <typename Integer>
246  long writeConnectivity(Integer* connectivity_inout,
247  ConnectivityVertexOrder whichOrder, long max_size = 0) const;
248 
261  template <typename VectType>
262  long writeConnectivity(VectType& connectivity_inout,
263  ConnectivityVertexOrder whichOrder) const;
264 
276  template <typename Integer>
277  long writeOffsetsCells(Integer* offsets_inout, long max_size = 0) const;
278 
289  template <typename VectType>
290  long writeOffsetsCells(VectType& offsets_inout) const;
291 
302  template <typename Integer>
303  long writeCellTypes(Integer* types_inout, long max_size = 0) const;
304 
313  template <typename VectType>
314  long writeCellTypes(VectType& types_inout) const;
315 
316  std::string getPartitionTypeString() const;
317 
318  Dune::PartitionSet<partitions> getPartition(void)
319  {
320  return this->dunePartition_;
321  }
322 
323  void printGridDetails(std::ostream& outstr) const;
324 
325  int getNCells() const
326  {
327  return ncells_;
328  }
329 
330  int getNVertices() const
331  {
332  return nvertices_;
333  }
334 
335  int getNCorners() const
336  {
337  return ncorners_;
338  }
339 
340  std::string getError() const
341  {
342  return error_;
343  }
344 
345  void clearError()
346  {
347  error_.clear();
348  }
349 
350  bool hasError() const
351  {
352  return !error_.empty();
353  }
354 
355 protected:
356  GridView gridView_; // the grid
357 
358  Dune::PartitionSet<partitions> dunePartition_;
359  unsigned int partition_value_;
360 
364  int ncells_;
373 
374  int dimw_; // dimensions of the input grid
375 
376 private:
377  std::string error_;
378 };
379 
380 } // namespace Opm::GridDataOutput
381 
382 #endif
bool polyhedralCellPresent() const
Checks for cells that have polyhedral type within the current partition of cells. ...
Definition: GridDataOutput_impl.hpp:46
void countEntities()
Count the vertices, cells and corners.
Definition: GridDataOutput_impl.hpp:55
long writeGridPoints(T *x_inout, T *y_inout, T *z_inout, long max_size=0) const
Write the positions of vertices - directly to the pointers given in parameters.
Definition: GridDataOutput_impl.hpp:74
Definition: GridDataOutput.cpp:32
ConnectivityVertexOrder
Allows selection of order of vertices in writeConnectivity()
Definition: GridDataOutput.hpp:93
long writeCellTypes(Integer *types_inout, long max_size=0) const
Write the cell types values - directly to the pointer given in parameter 1.
Definition: GridDataOutput_impl.hpp:443
Definition: GridDataOutput.hpp:96
long writeOffsetsCells(Integer *offsets_inout, long max_size=0) const
Write the offsets values - directly to the pointer given in parameter 1.
Definition: GridDataOutput_impl.hpp:394
long writeConnectivity(Integer *connectivity_inout, ConnectivityVertexOrder whichOrder, long max_size=0) const
Write the connectivity array - directly to the pointer given in parameter 1 Reorders the indices as s...
Definition: GridDataOutput_impl.hpp:309
int ncorners_
Current partition grid information
Definition: GridDataOutput.hpp:372
int nvertices_
Current partition grid information
Definition: GridDataOutput.hpp:368
int ncells_
Current partition grid information
Definition: GridDataOutput.hpp:364
long writeGridPoints_AOS(T *xyz_inout, long max_size=0) const
Write the positions of vertices - directly to the pointers given in parameters as Array of Structures...
Definition: GridDataOutput_impl.hpp:157
long writeGridPoints_SOA(T *xyz_inout, long max_size=0) const
Write the positions of vertices - directly to the pointers given in parameters as Structure of Arrays...
Definition: GridDataOutput_impl.hpp:227
SimMeshDataAccessor(const GridView &gridView, Dune::PartitionSet< partitions > dunePartition)
Construct a SimMeshDataAccessor working on a specific GridView and specialize to a Dune::PartitionSet...
Definition: GridDataOutput_impl.hpp:36