Interface Documentation
Version: invalid
parallel_definition.hh
Go to the documentation of this file.
1 /*
2  @@@@@@@@ @@ @@@@@@ @@@@@@@@ @@
3  /@@///// /@@ @@////@@ @@////// /@@
4  /@@ /@@ @@@@@ @@ // /@@ /@@
5  /@@@@@@@ /@@ @@///@@/@@ /@@@@@@@@@/@@
6  /@@//// /@@/@@@@@@@/@@ ////////@@/@@
7  /@@ /@@/@@//// //@@ @@ /@@/@@
8  /@@ @@@//@@@@@@ //@@@@@@ @@@@@@@@ /@@
9  // /// ////// ////// //////// //
10 
11  Copyright (c) 2016, Los Alamos National Security, LLC
12  All rights reserved.
13  */
14 #pragma once
15 
19 
20 #include <vector>
21 
22 namespace flecsi {
23 namespace topo {
24 namespace unstructured_impl {
25 
26 template<size_t DIMENSION, typename REAL_TYPE = double>
27 class parallel_definition : public definition<DIMENSION, REAL_TYPE>
28 {
29 public:
31  using byte_t = unsigned char;
32 
34  using real_t = REAL_TYPE;
35 
36  virtual std::vector<size_t>
37  entities(size_t from_dimension, size_t to_dimension, size_t id) const = 0;
38 
39  virtual const util::crs & entities_crs(size_t, size_t) const = 0;
40 
41  virtual const std::vector<size_t> & local_to_global(size_t dim) const = 0;
42 
43  virtual const std::map<size_t, size_t> & global_to_local(
44  size_t dim) const = 0;
45 
46  virtual void create_graph(size_t from_dimension,
47  size_t to_dimension,
48  size_t min_connections,
49  util::dcrs & dcrs) const = 0;
50 
51  virtual void pack(size_t dimension,
52  size_t local_id,
53  std::vector<byte_t> & buffer) const = 0;
54 
55  virtual void
56  unpack(size_t dimension, size_t local_id, byte_t const *& buffer) = 0;
57 
58  virtual void erase(size_t dimension,
59  const std::vector<size_t> & local_ids) = 0;
60 
61  virtual void build_connectivity() = 0;
62 
63  virtual void vertex(size_t id, real_t * coord) const = 0;
64 
65  virtual const std::vector<size_t> & face_owners() const = 0;
66  virtual const std::vector<size_t> & region_ids() const = 0;
67 };
68 
69 //----------------------------------------------------------------------------
70 // A utilitiy for casting to byte arrays
71 //----------------------------------------------------------------------------
72 template<typename DATA_TYPE, typename BUFFER_TYPE>
73 void
74 cast_insert(DATA_TYPE const * const data, size_t len, BUFFER_TYPE & buf) {
75  using buf_value_t = std::decay_t<decltype(buf[0])>;
76  auto n = sizeof(DATA_TYPE) * len;
77  auto p = reinterpret_cast<const buf_value_t *>(data);
78  buf.insert(buf.end(), p, p + n);
79 };
80 
81 //----------------------------------------------------------------------------
82 // A utilitiy for casting from byte arrays
83 //----------------------------------------------------------------------------
84 template<typename BUFFER_TYPE, typename DATA_TYPE>
85 void
86 uncast(BUFFER_TYPE const *& buffer, size_t len, DATA_TYPE * data) {
87  auto n = sizeof(DATA_TYPE) * len;
88  auto p = reinterpret_cast<BUFFER_TYPE *>(data);
89  std::copy(buffer, buffer + n, p);
90  auto start = buffer + n;
91  buffer += n;
92 };
93 
94 } // namespace unstructured_impl
95 } // namespace topo
96 } // namespace flecsi
virtual std::vector< size_t > entities(size_t from_dimension, size_t to_dimension, size_t id) const =0
Definition: crs.hh:48
unsigned char byte_t
a byte type used for migrating data
Definition: parallel_definition.hh:31
int start(const std::function< int()> &action)
Definition: execution.hh:69
Definition: crs.hh:254
REAL_TYPE real_t
the floating point type
Definition: parallel_definition.hh:34
Definition: parallel_definition.hh:27
Definition: control.hh:31
static constexpr size_t dimension()
Definition: definition.hh:51