Flow123d  release_3.0.0-1165-gffc6a5f
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_DBG( dim_ == q.dim_ );
27  weights = q.weights;
28  return *this;
29 }
30 
31 
32 Quadrature::Quadrature(unsigned int dimension, const unsigned int n_q)
33 : dim_(dimension),
34  quadrature_points(n_q, dimension),
35  weights(n_q, 0)
36 {}
37 
38 
40  dim_(q.dim_),
42  weights(q.weights)
43 {}
44 
45 
46 
47 
48 
49 
50 
51 template<unsigned int bulk_dim>
52 Quadrature Quadrature::make_from_side(unsigned int sid, unsigned int pid)
53 {
54  ASSERT_DBG( bulk_dim == dim_ + 1 );
55 
56  // Below we permute point coordinates according to permutation
57  // of nodes on side. We just check that these numbers equal.
59 
60  Quadrature q(dim_+1, size());
61  arma::vec::fixed<bulk_dim+1> el_bar_coords, final_bar;
62 
63  for (unsigned int k=0; k<size(); k++)
64  {
65  //compute barycentric coordinates on element
66  arma::vec::fixed<bulk_dim> p = RefElement<bulk_dim-1>::local_to_bary(point<bulk_dim-1>(k).arma());
67  arma::vec::fixed<bulk_dim> pp;
68 
69  //permute
70  for (unsigned int i=0; i<RefElement<bulk_dim>::n_nodes_per_side; i++) {
71  pp(RefElement<bulk_dim>::side_permutations[pid][i]) = p(i);
72  }
73 
74  el_bar_coords = RefElement<bulk_dim>::template interpolate<bulk_dim-1>(pp,sid);
75 
76  //get local coordinates and set
77  q.point<bulk_dim>(k) = RefElement<bulk_dim>::bary_to_local(el_bar_coords);
78  q.weight(k) = weight(k);
79  }
80 
81  return q;
82 }
83 
84 // Specialized subquadrature consructor for dim=1.
85 template<> Quadrature Quadrature::make_from_side<1>(unsigned int sid, unsigned int pid)
86 {
87  Quadrature q(1, 1);
88  q.point<1>(0) = { (double)sid };
89  q.weight(0) = 1;
90 
91  return q;
92 }
93 
94 template Quadrature Quadrature::make_from_side<2>(unsigned int sid, unsigned int pid);
95 template Quadrature Quadrature::make_from_side<3>(unsigned int sid, unsigned int pid);
Quadrature(const Quadrature &q)
Copy constructor.
Definition: quadrature.cc:39
Quadrature make_from_side(unsigned int sid, unsigned int pid)
Definition: quadrature.cc:52
double weight(const unsigned int i) const
Returns the ith weight.
Definition: quadrature.hh:101
Base class for quadrature rules on simplices in arbitrary dimensions.
Definition: quadrature.hh:48
Armor::vec< point_dim > point(const unsigned int i) const
Returns the ith quadrature point.
Definition: quadrature.hh:90
const unsigned int size() const
Returns number of quadrature points.
Definition: quadrature.hh:85
std::vector< double > weights
List of weights to the quadrature points.
Definition: quadrature.hh:141
Basic definitions of numerical quadrature rules.
const unsigned int dim_
Dimension of quadrature points.
Definition: quadrature.hh:127
#define ASSERT_DBG(expr)
Definition: asserts.hh:349
static BaryPoint local_to_bary(const LocalPoint &lp)
Converts from local to barycentric coordinates.
Definition: ref_element.cc:296
Quadrature & operator=(const Quadrature &q)
Definition: quadrature.cc:23
Armor::array quadrature_points
List of quadrature points.
Definition: quadrature.hh:134