Flow123d
mh_dofhandler.cc
Go to the documentation of this file.
1 /*
2  * mh_dofhandler.cc
3  *
4  * Created on: Jun 18, 2012
5  * Author: jb
6  */
7 
8 #include "flow/mh_dofhandler.hh"
9 #include "mesh/mesh.h"
10 #include "mesh/side_impl.hh"
11 
13  elem_side_to_global.resize(mesh->n_elements() );
14  FOR_ELEMENTS(mesh, ele) elem_side_to_global[ele.index()].resize(ele->n_sides());
15 
16  unsigned int i_side_global=0;
17  FOR_ELEMENTS(mesh, ele) {
18  for(unsigned int i_lside=0; i_lside < ele->n_sides(); i_lside++)
19  elem_side_to_global[ele.index()][i_lside] = i_side_global++;
20  }
21 }
22 
23 
24 unsigned int MH_DofHandler::side_dof(const SideIter side) const {
25  return elem_side_to_global[ side->element().index() ][ side->el_idx() ];
26 }
27 
28 
29 void MH_DofHandler::set_solution( double time, double * solution, double precision) {
30  ASSERT( solution != NULL, "Empty solution.\n");
31  mh_solution = solution;
33  time_ = time;
34 }
35 
36 /// temporary replacement for DofHandler accessor, flux through given side
37 double MH_DofHandler::side_flux(const Side &side) const {
38  return mh_solution[ elem_side_to_global[ side.element().index() ][ side.el_idx() ] ];
39 }
40 
41 /// temporary replacement for DofHandler accessor, scalar (pressure) on edge of the side
42 double MH_DofHandler::side_scalar(const Side &side) const {
43  unsigned int i_edg = side.edge_idx();
44  return mh_solution[ side.mesh()->n_sides() + side.mesh()->n_elements() + i_edg ];
45 }
46 
47 
49  return mh_solution[ ele->mesh_->n_sides() + ele.index() ];
50 }