Flow123d  3.9.1-c3f8cb5
quadrature.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 quadrature.hh
15  * @brief Basic definitions of numerical quadrature rules.
16  * @author Jan Stebel
17  */
18 
19 #include "quadrature/quadrature.hh"
20 
21 
22 
24 {
25  ASSERT( dim_ == q.dim_ );
27  weights = q.weights;
28  return *this;
29 }
30 
31 
32 Quadrature::Quadrature(unsigned int dimension, unsigned int n_q)
33 : dim_(dimension),
34  quadrature_points(dimension, 1, n_q),
35  weights(n_q, 0)
36 {}
37 
38 
40  dim_(q.dim_),
41  quadrature_points(q.quadrature_points),
42  weights(q.weights)
43 {}
44 
45 
46 template<unsigned int bulk_dim>
47 Quadrature Quadrature::make_from_side(unsigned int sid) const
48 {
49  ASSERT( bulk_dim == dim_ + 1 );
51 
52  Quadrature q(dim_+1, size());
53  Armor::ArmaVec<double, bulk_dim+1> el_bar_coords, final_bar;
54 
55  for (unsigned int k=0; k<size(); k++)
56  {
57  //compute barycentric coordinates on element
59 
60  el_bar_coords = RefElement<bulk_dim>::template interpolate<bulk_dim-1>(p, sid);
61 
62  //get local coordinates and set
64  q.weights[k] = weight(k);
65  }
66 
67  return q;
68 }
69 
70 // Specialized subquadrature consructor for dim=1.
71 template<> Quadrature Quadrature::make_from_side<1>(unsigned int sid) const
72 {
73  ASSERT_EQ(size(), 1);
74  Quadrature q(1, 1);
75  q.quadrature_points.set(0) = Armor::ArmaVec<double, 1>({ (double)sid });
76  q.weight(0) = 1;
77 
78  return q;
79 }
80 
81 template Quadrature Quadrature::make_from_side<2>(unsigned int sid) const;
82 template Quadrature Quadrature::make_from_side<3>(unsigned int sid) const;
83 
84 
RefElement
Definition: ref_element.hh:339
ASSERT
#define ASSERT(expr)
Definition: asserts.hh:351
Quadrature::weights
std::vector< double > weights
List of weights to the quadrature points.
Definition: quadrature.hh:147
Quadrature::operator=
Quadrature & operator=(const Quadrature &q)
Definition: quadrature.cc:23
Quadrature::size
unsigned int size() const
Returns number of quadrature points.
Definition: quadrature.hh:86
RefElement::bary_to_local
static LocalPoint bary_to_local(const BaryPoint &bp)
Converts from barycentric to local coordinates.
Definition: ref_element.cc:201
Quadrature::weight
double weight(unsigned int i) const
Returns the ith weight.
Definition: quadrature.hh:107
ASSERT_EQ
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual) only for debug mode.
Definition: asserts.hh:333
Armor::Array::set
ArrayMatSet set(uint index)
Definition: armor.hh:838
Quadrature::Quadrature
Quadrature(const Quadrature &q)
Copy constructor.
Definition: quadrature.cc:39
Quadrature::dim_
const unsigned int dim_
Dimension of quadrature points.
Definition: quadrature.hh:133
quadrature.hh
Basic definitions of numerical quadrature rules.
Quadrature::quadrature_points
Armor::Array< double > quadrature_points
List of quadrature points.
Definition: quadrature.hh:140
RefElement::local_to_bary
static BaryPoint local_to_bary(const LocalPoint &lp)
Converts from local to barycentric coordinates.
Definition: ref_element.cc:187
Quadrature
Base class for quadrature rules on simplices in arbitrary dimensions.
Definition: quadrature.hh:48
Armor::ArmaVec
typename arma::Col< Type >::template fixed< nr > ArmaVec
Definition: armor.hh:505
Quadrature::make_from_side
Quadrature make_from_side(unsigned int sid) const
Definition: quadrature.cc:47