FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
barycentre_driver.hpp
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#pragma once
7
8// includes, FEAT
9#include <kernel/cubature/driver_base.hpp>
10#include <kernel/util/meta_math.hpp>
11
12namespace FEAT
13{
14 namespace Cubature
15 {
17 namespace Intern
18 {
19 template<typename Shape_>
20 class BarycentreDriverBase :
21 public DriverBase<Shape_>
22 {
23 public:
25 static constexpr bool variadic = false;
27 static constexpr int num_points = 1;
28
30 static String name()
31 {
32 return "barycentre";
33 }
34
41 template<typename Functor_>
42 static void alias(Functor_& functor)
43 {
44 functor.alias("midpoint");
45 }
46 };
47 } // namespace Intern
49
61 template<typename Shape_>
62 class BarycentreDriver DOXY({});
63
64 // Simplex specialization
65 template<int dim_>
66 class BarycentreDriver<Shape::Simplex<dim_> > :
67 public Intern::BarycentreDriverBase<Shape::Simplex<dim_> >
68 {
69 public:
76 template<
77 typename Weight_,
78 typename Coord_,
79 typename Point_>
80 static void fill(Rule<Shape::Simplex<dim_>, Weight_, Coord_, Point_>& rule)
81 {
82 rule.get_weight(0) = Weight_(1) / Weight_(MetaMath::Factorial<dim_>::value);
83
84 // create coords of barycentre point
85 for(int i(0); i < dim_; ++i)
86 {
87 rule.get_coord(0, i) = Coord_(1) / Coord_(dim_ + 1);
88 }
89 }
90 }; // class BarycentreDriver<Simplex<...>>
91
92 // Hypercube specialization
93 template<int dim_>
94 class BarycentreDriver<Shape::Hypercube<dim_> > :
95 public Intern::BarycentreDriverBase<Shape::Hypercube<dim_> >
96 {
97 public:
104 template<
105 typename Weight_,
106 typename Coord_,
107 typename Point_>
108 static void fill(Rule<Shape::Hypercube<dim_>, Weight_, Coord_, Point_>& rule)
109 {
110 rule.get_weight(0) = Weight_(1 << dim_);
111
112 // create coords of barycentre point
113 for(int i(0); i < dim_; ++i)
114 {
115 rule.get_coord(0, i) = Coord_(0);
116 }
117 }
118 }; // class BarycentreDriver<Hypercube<...>>
119 } // namespace Cubature
120} // namespace FEAT
static void fill(Rule< Shape::Hypercube< dim_ >, Weight_, Coord_, Point_ > &rule)
Fills the cubature rule structure.
static void fill(Rule< Shape::Simplex< dim_ >, Weight_, Coord_, Point_ > &rule)
Fills the cubature rule structure.
Barycentre Rule driver class template.
Cubature Rule class template.
Definition: rule.hpp:38
FEAT namespace.
Definition: adjactor.hpp:12
Factorial template meta-program.
Definition: meta_math.hpp:31
Hypercube shape tag struct template.
Definition: shape.hpp:64
Simplex shape tag struct template.
Definition: shape.hpp:44