Flow123d  release_3.0.0-955-g4db4b48
discrete_space.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 discrete_space.cc
15  * @brief Implementation of class which provides the finite element for every mesh cell.
16  * @author Jan Stebel
17  */
18 
19 #include "fem/discrete_space.hh"
20 #include "fem/finite_element.hh"
21 #include "mesh/mesh.h"
22 #include "mesh/duplicate_nodes.h"
23 
24 
25 
27 {
28  unsigned int n_dofs = 0;
29  switch (cell->dim())
30  {
31  case 0:
32  for (unsigned int d=0; d<fe0_->n_dofs(); d++)
33  if (fe0_->dof(d).dim == 0)
34  n_dofs++;
35  break;
36  case 1:
37  for (unsigned int d=0; d<fe1_->n_dofs(); d++)
38  if (fe1_->dof(d).dim == 1)
39  n_dofs++;
40  break;
41  case 2:
42  for (unsigned int d=0; d<fe2_->n_dofs(); d++)
43  if (fe2_->dof(d).dim == 2)
44  n_dofs++;
45  break;
46  case 3:
47  for (unsigned int d=0; d<fe3_->n_dofs(); d++)
48  if (fe3_->dof(d).dim == 3)
49  n_dofs++;
50  break;
51  }
52  return n_dofs;
53 }
54 
55 
56 unsigned int EqualOrderDiscreteSpace::n_node_dofs(unsigned int nid) const
57 {
58  unsigned int n_dofs = 0;
59  unsigned int dim = mesh_->tree->node_dim()[nid];
60  switch (dim)
61  {
62  case 0:
63  for (unsigned int d=0; d<fe0_->n_dofs(); d++)
64  if (fe0_->dof(d).dim == 0 && fe0_->dof(d).n_face_idx == 0)
65  n_dofs++;
66  break;
67  case 1:
68  for (unsigned int d=0; d<fe1_->n_dofs(); d++)
69  if (fe1_->dof(d).dim == 0 && fe1_->dof(d).n_face_idx == 0)
70  n_dofs++;
71  break;
72  case 2:
73  for (unsigned int d=0; d<fe2_->n_dofs(); d++)
74  if (fe2_->dof(d).dim == 0 && fe2_->dof(d).n_face_idx == 0)
75  n_dofs++;
76  break;
77  case 3:
78  for (unsigned int d=0; d<fe3_->n_dofs(); d++)
79  if (fe3_->dof(d).dim == 0 && fe3_->dof(d).n_face_idx == 0)
80  n_dofs++;
81  break;
82  }
83  return n_dofs;
84 }
85 
86 
87 
88 template<> FiniteElement<0> *DiscreteSpace::fe(const ElementAccessor<3> &cell) const { return fe0d(cell); }
89 template<> FiniteElement<1> *DiscreteSpace::fe(const ElementAccessor<3> &cell) const { return fe1d(cell); }
90 template<> FiniteElement<2> *DiscreteSpace::fe(const ElementAccessor<3> &cell) const { return fe2d(cell); }
91 template<> FiniteElement<3> *DiscreteSpace::fe(const ElementAccessor<3> &cell) const { return fe3d(cell); }
92 
93 
94 
95 
96 
const std::vector< unsigned int > & node_dim() const
FiniteElement< 2 > * fe2_
FiniteElement< 1 > * fe1_
DuplicateNodes * tree
Definition: mesh.h:277
unsigned int dim
Association to n-face of given dimension (point, line, triangle, tetrahedron.
unsigned int n_face_idx
Index of n-face to which the dof is associated.
FiniteElement< dim > * fe(const ElementAccessor< 3 > &) const
Return finite element object for given element.
unsigned int n_elem_dofs(const ElementAccessor< 3 > &cell) const override
Number of dofs associated to element (not shared by adjacent elements).
FiniteElement< 1 > * fe1d(const ElementAccessor< 3 > &cell) const override
unsigned int dim() const
Definition: elements.h:124
Declaration of class which provides the finite element for every mesh cell.
FiniteElement< 2 > * fe2d(const ElementAccessor< 3 > &cell) const override
FiniteElement< 0 > * fe0d(const ElementAccessor< 3 > &cell) const override
unsigned int n_node_dofs(unsigned int nid) const override
Number of dofs associated to node. nid is the node index in the mesh tree.
FiniteElement< 3 > * fe3_
FiniteElement< 3 > * fe3d(const ElementAccessor< 3 > &cell) const override
const Dof & dof(unsigned int i) const
Returns i -th degree of freedom.
const unsigned int n_dofs() const
Returns the number of degrees of freedom needed by the finite element.
Abstract class for description of finite elements.
FiniteElement< 0 > * fe0_