Flow123d  release_1.8.2-1603-g0109a2b
mh_dofhandler.cc
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.cc
15  * @brief
16  */
17 
18 #include "flow/mh_dofhandler.hh"
19 #include "mesh/mesh.h"
20 #include "mesh/side_impl.hh"
21 
23  elem_side_to_global.resize(mesh->n_elements() );
24  FOR_ELEMENTS(mesh, ele) elem_side_to_global[ele.index()].resize(ele->n_sides());
25 
26  unsigned int i_side_global=0;
27  FOR_ELEMENTS(mesh, ele) {
28  for(unsigned int i_lside=0; i_lside < ele->n_sides(); i_lside++)
29  elem_side_to_global[ele.index()][i_lside] = i_side_global++;
30  }
31 }
32 
33 
34 unsigned int MH_DofHandler::side_dof(const SideIter side) const {
35  return elem_side_to_global[ side->element().index() ][ side->el_idx() ];
36 }
37 
38 
39 void MH_DofHandler::set_solution( double time, double * solution, double precision) {
40  OLD_ASSERT( solution != NULL, "Empty solution.\n");
41  mh_solution = solution;
43  time_ = time;
44 }
45 
46 /// temporary replacement for DofHandler accessor, flux through given side
47 double MH_DofHandler::side_flux(const Side &side) const {
48  return mh_solution[ elem_side_to_global[ side.element().index() ][ side.el_idx() ] ];
49 }
50 
51 /// temporary replacement for DofHandler accessor, scalar (pressure) on edge of the side
52 double MH_DofHandler::side_scalar(const Side &side) const {
53  unsigned int i_edg = side.edge_idx();
54  return mh_solution[ side.mesh()->n_sides() + side.mesh()->n_elements() + i_edg ];
55 }
56 
57 
59  return mh_solution[ ele->mesh_->n_sides() + ele.index() ];
60 }
Definition: sides.h:31
void reinit(Mesh *mesh)
#define FOR_ELEMENTS(_mesh_, __i)
Definition: mesh.h:408
unsigned int edge_idx() const
Definition: side_impl.hh:60
Definition: mesh.h:99
int index() const
Definition: sys_vector.hh:78
unsigned int n_sides()
Definition: mesh.cc:173
double precision() const
vector< vector< unsigned int > > elem_side_to_global
#define OLD_ASSERT(...)
Definition: global_defs.h:128
unsigned int n_elements() const
Definition: mesh.h:142
double element_scalar(ElementFullIter &ele) const
temporary replacement for DofHandler accessor, scalar (pressure) on element
unsigned int side_dof(const SideIter side) const
double side_flux(const Side &side) const
temporary replacement for DofHandler accessor, flux through given side
ElementFullIter element() const
Definition: side_impl.hh:51
unsigned int el_idx() const
Definition: side_impl.hh:80
double * mh_solution
void set_solution(double time, double *solution, double precision)
double side_scalar(const Side &side) const
temporary replacement for DofHandler accessor, scalar (pressure) on edge of the side ...
double solution_precision
Mesh * mesh() const
Definition: side_impl.hh:56