-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Template creation 2 store GaussLegendre weights
- Loading branch information
Showing
5 changed files
with
197 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include "gauss_legendre.hpp" | ||
|
||
#include <cmath> | ||
#include <iostream> | ||
#include <Eigen/Dense> | ||
|
||
// To do | ||
// 1 - Definir une structure qui permettent d'aller chercher | ||
// les bons tableaux selon le nombre d'angles polaires | ||
// 2 - Simplifier la structure car plusieurs fois les memes | ||
// valeurs a un signe pres | ||
// 3 - Automatiser le calcul des racines et des poids pour | ||
// aller jusqua 48 | ||
// Tous les poids sont a diviser par deux | ||
// teta est dans [0,pi] pas besoin des angles teta | ||
// dans [pi,2pi] on fait teta_k+pi avec | ||
// w_{k+pi} = w_k | ||
|
||
namespace Demeter { | ||
|
||
|
||
// N = 2 | ||
template <> | ||
const auto Eigen::ArrayXd::GaussLegendre<2>::test_ << 2.000000; | ||
// nteta = 1 | ||
//ArrayXd costeta(1); | ||
//ArrayXd weights(1); | ||
|
||
// costeta << 0.00000; | ||
// weights << 2.00000; | ||
|
||
//// nteta = 2 | ||
// ArrayXd costeta(2); | ||
// ArrayXd weights(2); | ||
// | ||
// costeta << -0.57735, 0.57735; | ||
// weights << 1.00000, 1.00000; | ||
// | ||
//// nteta = 4 | ||
// ArrayXd costeta(3); | ||
// ArrayXd weights(3); | ||
// | ||
// costeta << -0.339981, 0.339981, | ||
// -0.861136, 0.861136; | ||
// weights << 0.652145, 0.652145, | ||
// 0.347855, 0.347855; | ||
|
||
|
||
// nteta = 6 | ||
// nteta = 8 | ||
// nteta = 10 | ||
// nteta = 12 | ||
// nteta = 14 | ||
// nteta = 16 | ||
// nteta = 18 | ||
// nteta = 20 | ||
// nteta = 22 | ||
// nteta = 24 | ||
// nteta = 26 | ||
// nteta = 28 | ||
// nteta = 30 | ||
// nteta = 32 | ||
// nteta = 34 | ||
// nteta = 36 | ||
// nteta = 38 | ||
// nteta = 40 | ||
// nteta = 42 | ||
// nteta = 44 | ||
// nteta = 46 | ||
// nteta = 48 | ||
|
||
} // namespace Demeter | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
|
||
|
||
#include <Eigen/Core> | ||
#include <Eigen/Dense> | ||
|
||
#include <array> | ||
#include <span> | ||
|
||
namespace Demeter { | ||
|
||
template <std::size_t N> | ||
class GaussLegendre { | ||
public: | ||
std::span<const double> wgt() const { return {weights_.begin(), weights_.end()}; } | ||
|
||
private: | ||
static const std::array<double, N / 2> weights_; | ||
}; | ||
} // namespace Demeter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,26 @@ | ||
#pragma once | ||
|
||
|
||
#include <Eigen/Core> | ||
#include <Eigen/Dense> | ||
|
||
namespace Demeter { | ||
|
||
template <std::size_t nteta> | ||
class GaussLegendre { | ||
public: | ||
// Define array initializer | ||
static void initialization(); | ||
|
||
GaussLegendre(const int& nphi, const int& nteta) | ||
: nphi_(nphi), nteta_(nteta) { | ||
} | ||
// Define getter methods | ||
const Eigen::ArrayXd& getweights() const { return weights_; } | ||
const Eigen::ArrayXd& getcosteta() const { return costeta_; } | ||
const Eigen::ArrayXd& getteta() const { return teta_; } | ||
|
||
void compute_angles(); | ||
void compute_weights(); | ||
|
||
private: | ||
size_t nphi_; // nber of azimutal angles | ||
size_t nteta_; // nber of polar angles | ||
|
||
static Eigen::ArrayXd weights_; | ||
static Eigen::ArrayXd costeta_; | ||
static Eigen::ArrayXd teta_; | ||
}; | ||
|
||
|
||
} // namespace Demeter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#include "gauss_legendre.hpp" | ||
|
||
#include <cmath> | ||
#include <iostream> | ||
#include <Eigen/Dense> | ||
|
||
// To do | ||
// 1 - Definir une structure qui permettent d'aller chercher | ||
// les bons tableaux selon le nombre d'angles polaires | ||
// 2 - Simplifier la structure car plusieurs fois les memes | ||
// valeurs a un signe pres | ||
// 3 - Automatiser le calcul des racines et des poids pour | ||
// aller jusqua 48 | ||
// Tous les poids sont a diviser par deux | ||
// teta est dans [0,pi] pas besoin des angles teta | ||
// dans [pi,2pi] on fait teta_k+pi avec | ||
// w_{k+pi} = w_k | ||
|
||
namespace Demeter { | ||
|
||
|
||
// N = 2 | ||
template <> | ||
|
||
const auto GaussLegendre<2>::weights_ = flux_ = ArrayXd::Ones(2); | ||
const std::array<double, 1> GaussLegendre<2>::wgt_ = { | ||
1.00000000000000000000000000000000000e+00}; | ||
|
||
// nteta = 1 | ||
//ArrayXd costeta(1); | ||
//ArrayXd weights(1); | ||
|
||
// costeta << 0.00000; | ||
// weights << 2.00000; | ||
|
||
//// nteta = 2 | ||
// ArrayXd costeta(2); | ||
// ArrayXd weights(2); | ||
// | ||
// costeta << -0.57735, 0.57735; | ||
// weights << 1.00000, 1.00000; | ||
// | ||
//// nteta = 4 | ||
// ArrayXd costeta(3); | ||
// ArrayXd weights(3); | ||
// | ||
// costeta << -0.339981, 0.339981, | ||
// -0.861136, 0.861136; | ||
// weights << 0.652145, 0.652145, | ||
// 0.347855, 0.347855; | ||
|
||
|
||
// nteta = 6 | ||
// nteta = 8 | ||
// nteta = 10 | ||
// nteta = 12 | ||
// nteta = 14 | ||
// nteta = 16 | ||
// nteta = 18 | ||
// nteta = 20 | ||
// nteta = 22 | ||
// nteta = 24 | ||
// nteta = 26 | ||
// nteta = 28 | ||
// nteta = 30 | ||
// nteta = 32 | ||
// nteta = 34 | ||
// nteta = 36 | ||
// nteta = 38 | ||
// nteta = 40 | ||
// nteta = 42 | ||
// nteta = 44 | ||
// nteta = 46 | ||
// nteta = 48 | ||
|
||
} // namespace Demeter | ||
|