Flow123d  master-f44eb46
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 template<> Quadrature Quadrature::make_from_side<0>(FMT_UNUSED unsigned int sid) const
71 {
72  ASSERT(false); // 0-dim elements have no sides.
73  return Quadrature(0, 0);
74 }
75 
76 // Specialized subquadrature consructor for dim=1.
77 template<> Quadrature Quadrature::make_from_side<1>(unsigned int sid) const
78 {
79  ASSERT_EQ(size(), 1);
80  Quadrature q(1, 1);
81  q.quadrature_points.set(0) = Armor::ArmaVec<double, 1>({ (double)sid });
82  q.weight(0) = 1;
83 
84  return q;
85 }
86 
87 template Quadrature Quadrature::make_from_side<2>(unsigned int sid) const;
88 template Quadrature Quadrature::make_from_side<3>(unsigned int sid) const;
89 
90 
#define ASSERT(expr)
Definition: asserts.hh:351
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual) only for debug mode.
Definition: asserts.hh:333
ArrayMatSet set(uint index)
Definition: armor.hh:838
Base class for quadrature rules on simplices in arbitrary dimensions.
Definition: quadrature.hh:48
Quadrature make_from_side(unsigned int sid) const
Definition: quadrature.cc:47
unsigned int size() const
Returns number of quadrature points.
Definition: quadrature.hh:86
Quadrature(const Quadrature &q)
Copy constructor.
Definition: quadrature.cc:39
std::vector< double > weights
List of weights to the quadrature points.
Definition: quadrature.hh:143
Quadrature & operator=(const Quadrature &q)
Definition: quadrature.cc:23
double weight(unsigned int i) const
Returns the ith weight.
Definition: quadrature.hh:103
Armor::Array< double > quadrature_points
List of quadrature points.
Definition: quadrature.hh:136
const unsigned int dim_
Dimension of quadrature points.
Definition: quadrature.hh:129
static LocalPoint bary_to_local(const BaryPoint &bp)
Converts from barycentric to local coordinates.
Definition: ref_element.cc:201
static BaryPoint local_to_bary(const LocalPoint &lp)
Converts from local to barycentric coordinates.
Definition: ref_element.cc:187
typename arma::Col< Type >::template fixed< nr > ArmaVec
Definition: armor.hh:505
#define FMT_UNUSED
Definition: posix.h:75
Basic definitions of numerical quadrature rules.