Flow123d  DF_patch_fe_mechanics-c13f069
mh_dofhandler.hh
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file mh_dofhandler.hh
15  * @brief
16  */
17 
18 #ifndef MH_DOFHANDLER_HH_
19 #define MH_DOFHANDLER_HH_
20 
21 #include <ext/alloc_traits.h> // for __alloc_traits<>::value_...
22 #include <sys/types.h> // for uint
23 #include <memory> // for shared_ptr, __shared_ptr
24 #include <unordered_map> // for unordered_map
25 #include <vector> // for vector
26 #include <armadillo>
27 #include "la/distribution.hh" // for Distribution
28 #include "system/index_types.hh" // for LongIdx
29 #include "mesh/accessors.hh" // for ElementAccessor, Side::edge_idx
30 #include "mesh/elements.h" // for Element::side, Element::dim
31 #include "mesh/mesh.h" // for Mesh
32 #include "mesh/region.hh" // for Region
33 #include "fem/dh_cell_accessor.hh" // for DHCellAccessor
34 
35 template <int spacedim> class LocalElementAccessorBase;
36 class DarcyMH;
37 class DarcyLMH;
38 class RichardsLMH;
39 
40 using namespace std;
41 
42 /// temporary solution to provide access to results
43 /// from DarcyFlowMH independent of mesh
45 public:
46  MH_DofHandler();
47  ~MH_DofHandler();
48  void reinit(Mesh *mesh);
49 
50  void prepare_parallel();
51  void make_row_numberings();
52 
53  void set_solution( double time, double * solution);
54 
55  inline double time_changed() const
56  { return time_; }
57 
58  unsigned int side_dof(const SideIter side) const;
59 
60  /// temporary replacement for DofHandler accessor, flux through given side
61  double side_flux(const Side &side) const;
62 
63  /// temporary replacement for DofHandler accessor, scalar (pressure) on edge of the side
64  double side_scalar(const Side &side) const;
65 
66  /// temporary replacement for DofHandler accessor, scalar (pressure) on element
67  double element_scalar( ElementAccessor<3> &ele ) const;
68 
69 protected:
71 
73  LongIdx *el_4_loc; //< array of idexes of local elements (in ordering matching the optimal global)
74  LongIdx *row_4_el; //< element index to matrix row
75  LongIdx *side_id_4_loc; //< array of ids of local sides
76  LongIdx *side_row_4_id; //< side id to matrix row
77  LongIdx *edge_4_loc; //< array of indexes of local edges
78  LongIdx *row_4_edge; //< edge index to matrix row
79 
80  // parallel
81  Distribution *edge_ds; //< optimal distribution of edges
82  Distribution *el_ds; //< optimal distribution of elements
83  Distribution *side_ds; //< optimal distribution of elements
84 
85 
86  /// Maps mesh index of the edge to the edge index in the mesh portion local to the processor.
87  /// Temporary solution until we have parallel mesh which should provide such information.
88  std::unordered_map<unsigned int, unsigned int> edge_new_local_4_mesh_idx_;
89 
90  double * mh_solution;
91  double time_;
92 
94  friend DarcyMH;
95  friend DarcyLMH;
96  friend RichardsLMH;
97 };
98 
99 
100 
101 typedef unsigned int uint;
102 
103 template <int spacedim>
105 public:
106 
108  : dh_cell_(dh_cell), global_indices_(dh_cell_.dh()->max_elem_dofs())
109  {
110  n_indices_ = dh_cell_.get_dof_indices(global_indices_);
111  }
112 
113  inline DHCellAccessor dh_cell() const {
114  return dh_cell_;
115  }
116 
117  uint dim() const {
118  return dh_cell_.dim();
119  }
120 
121  uint n_sides() const {
122  return element_accessor()->n_sides();
123  }
124 
126  return dh_cell_.elm();
127  }
128 
129  const arma::vec3 centre() const {
130  return element_accessor().centre();
131  }
132 
133  double measure() const {
134  return element_accessor().measure();
135  }
136 
137  Region region() const {
138  return element_accessor().region();
139  }
140 
142  return element_accessor().idx();
143  }
144 
145  uint ele_local_idx() const {
146  return dh_cell_.local_idx();
147  }
148 
150  return global_indices_[n_indices_/2];
151  }
152 
154  return dh_cell_.get_loc_dof_indices()[n_indices_/2];
155  }
156 
158  return global_indices_[(n_indices_+1)/2+i];
159  }
160 
162  return dh_cell_.get_loc_dof_indices()[(n_indices_+1)/2+i];
163  }
164 
166  return element_accessor().side(i);
167  }
168 
170  return global_indices_[i];
171  }
172 
174  return dh_cell_.get_loc_dof_indices()[i];
175  }
176 
177 private:
181 };
182 
183 /**
184  * This is prototype of further much more complex and general accessor templated by
185  * element dimension. In fact we shall need an accessor for every kind of element interaction integral.
186  */
187 template <int spacedim, int dim>
189 public:
191  : LocalElementAccessorBase<spacedim>(dh, loc_ele_idx)
192  {}
193 };
194 
195 
196 
197 #endif /* MH_DOFHANDLER_HH_ */
Cell accessor allow iterate over DOF handler cells.
Mixed-hybrid model of linear Darcy flow, possibly unsteady.
Mixed-hybrid model of linear Darcy flow, possibly unsteady.
const arma::vec3 centre() const
DHCellAccessor dh_cell() const
LocalElementAccessorBase(DHCellAccessor dh_cell)
std::vector< LongIdx > global_indices_
ElementAccessor< 3 > element_accessor() const
LocalElementAccessor(MH_DofHandler &dh, uint loc_ele_idx)
Distribution * el_ds
std::unordered_map< unsigned int, unsigned int > edge_new_local_4_mesh_idx_
vector< vector< unsigned int > > elem_side_to_global
LongIdx * edge_4_loc
double time_changed() const
LongIdx * row_4_el
Distribution * edge_ds
LongIdx * row_4_edge
double * mh_solution
friend RichardsLMH
LongIdx * side_id_4_loc
LongIdx * el_4_loc
Distribution * side_ds
LongIdx * side_row_4_id
Definition: mesh.h:362
Edge lumped mixed-hybrid solution of unsteady Darcy flow.
Definition: richards_lmh.hh:66
Support classes for parallel programing.
int LongIdx
Define type that represents indices of large arrays (elements, nodes, dofs etc.)
Definition: index_types.hh:24
unsigned int uint