4 #pragma GCC diagnostic push
5 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
7 #pragma GCC diagnostic pop
9 #include <eigen3/Eigen/Sparse>
10 #include <eigen3/Eigen/Dense>
22 template <
int N,
int NPI>
27 explicit element(
const std::vector<Nodes::Node> &_p_node ,
29 std::initializer_list<int> & _i
36 std::cout<<
"Warning: element constructor is given an init list with size() != N\n";
51 Eigen::Matrix<double,2*N,2*N>
Kp;
54 Eigen::Matrix<double,2*N,1>
Lp;
57 inline constexpr
int getN(
void)
const {
return N; }
60 inline constexpr
int getNPI(
void)
const {
return NPI; }
69 void buildMatP(Eigen::Ref<Eigen::Matrix<double,2*N,3*N>>
P )
72 Eigen::Matrix<double,Nodes::DIM,N,Eigen::RowMajor> tempo;
73 for (
int i = 0; i <
N; i++) { tempo.col(i) =
getNode(i).
ep; }
75 P.template block<N,N>(0,0).diagonal() = tempo.row(Nodes::IDX_X);
76 P.template block<N,N>(0,
N).diagonal() = tempo.row(Nodes::IDX_Y);
77 P.template block<N,N>(0,2*
N).diagonal() = tempo.row(Nodes::IDX_Z);
79 for (
int i = 0; i <
N; i++) { tempo.col(i) =
getNode(i).
eq; }
81 P.template block<N,N>(
N,0).diagonal() = tempo.row(Nodes::IDX_X);
82 P.template block<N,N>(
N,
N).diagonal() = tempo.row(Nodes::IDX_Y);
83 P.template block<N,N>(
N,2*
N).diagonal() = tempo.row(Nodes::IDX_Z);
88 std::vector<Eigen::Triplet<double>> &K )
const
90 for (
int i = 0; i <
N; i++)
94 for (
int j = 0; j <
N; j++)
97 if(
Kp(i,j) != 0) K.emplace_back( NOD + i_, j_,
Kp(i,j) );
98 if (
Kp(i,
N + j) != 0) K.emplace_back( NOD + i_, NOD + j_,
Kp(i,
N + j) );
99 if (
Kp(
N + i,j) != 0) K.emplace_back( i_, j_,
Kp(
N + i,j) );
100 if (
Kp(
N + i,
N + j) != 0) K.emplace_back( i_, NOD + j_,
Kp(
N + i,
N + j) );
107 Eigen::Ref<Eigen::VectorXd> L )
const
109 for (
int i = 0; i <
N; i++)
111 const int i_ =
ind[i];
113 { L(NOD + i_) +=
Lp[i]; }
115 { L(i_) +=
Lp[
N + i]; }
122 std::cout <<
"idxPrm: " <<
idxPrm <<
" ind: {";
123 for(
unsigned int i = 0; i <
N-1; i++)
124 { std::cout <<
ind[i] <<
": " <<
refNode[
ind[i]].p << std::endl; }
129 virtual void getPtGauss(Eigen::Ref<Eigen::Matrix<double,Nodes::DIM,NPI>> result)
const = 0;
137 {
return (
refNode.size() > 0); }
141 { std::for_each(
ind.begin(),
ind.end(),[](
int & _i){ _i--; } ); }
Template abstract class, mother class for tetraedrons and facettes.
Definition: element.h:24
int idxPrm
Definition: element.h:45
void assemblage_vect(const int NOD, Eigen::Ref< Eigen::VectorXd > L) const
Definition: element.h:106
void zeroBasing(void)
Definition: element.h:140
Eigen::Matrix< double, 2 *N, 1 > Lp
Definition: element.h:54
bool existNodes(void)
Definition: element.h:136
constexpr int getNPI(void) const
Definition: element.h:60
void buildMatP(Eigen::Ref< Eigen::Matrix< double, 2 *N, 3 *N >> P)
Definition: element.h:69
void infos() const
Definition: element.h:120
virtual void getPtGauss(Eigen::Ref< Eigen::Matrix< double, Nodes::DIM, NPI >> result) const =0
Eigen::Matrix< double, NPI, 1 > weight
Definition: element.h:48
virtual void orientate()=0
std::vector< int > ind
Definition: element.h:42
element(const std::vector< Nodes::Node > &_p_node, const int _idx, std::initializer_list< int > &_i)
Definition: element.h:27
constexpr int getN(void) const
Definition: element.h:57
void assemblage_mat(const int NOD, std::vector< Eigen::Triplet< double >> &K) const
Definition: element.h:87
Eigen::Matrix< double, 2 *N, 2 *N > Kp
Definition: element.h:51
const Nodes::Node & getNode(const int i) const
Definition: element.h:133
const std::vector< Nodes::Node > & refNode
Definition: element.h:145
const int N
Definition: facette.h:17
const int NPI
Definition: facette.h:18
const int P
Definition: fmm_demag.h:32
header to define struct Node
Eigen::Vector3d eq
Definition: node.h:64
Eigen::Vector3d ep
Definition: node.h:63