-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelem_gauss.h
executable file
·150 lines (129 loc) · 3.73 KB
/
elem_gauss.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*
ver.03.03
file elem_gauss.h
*/
#pragma once
#include <vector>
#include "common.h"
#include "element.h"
#include "material.h"
#include "matrix_algebraic.h"
#include "node.h"
#include "sparse.h"
#define ELEM_GAUSS_TYPES \
typedef typename Parent::Default_matrix Default_matrix; \
typedef typename Parent::Default_gauss_point Default_gauss_point; \
typedef typename Parent::GP_WEIGHT_ARRAY GP_WEIGHT_ARRAY; \
typedef typename Parent::SHAPE_ARRAY SHAPE_ARRAY; \
typedef typename Parent::DNDXI_ARRAY DNDXI_ARRAY; \
typedef typename Parent::GP_COOR_ARRAY GP_COOR_ARRAY; \
#pragma once
template<const unsigned DIM,const unsigned NUM_NODES,class Default_matrix,class REAL=double>
class Gauss_point{
public:
typedef const double GP_WEIGHT_ARRAY;
typedef const double SHAPE_ARRAY[NUM_NODES];
typedef const double DNDXI_ARRAY[NUM_NODES][DIM];
typedef const double GP_COOR_ARRAY[DIM+1];
Gauss_point(
GP_WEIGHT_ARRAY& weight,
SHAPE_ARRAY& N,
DNDXI_ARRAY& dNdxi,
GP_COOR_ARRAY& coor
):
weight(weight),N(N),dNdxi(dNdxi),coor(coor)
{};
virtual ~Gauss_point(){};
Default_matrix F_;
Default_matrix F_rel_;
Default_matrix F_rel;
Default_matrix F_prev_;
Default_matrix sigma;
Default_matrix sigma_prev;
REAL jacob;
REAL jacob_prev;
REAL dNdX[NUM_NODES][DIM];
REAL dNdx[NUM_NODES][DIM];
REAL c[DIM][DIM][DIM][DIM];
GP_WEIGHT_ARRAY& weight;
SHAPE_ARRAY& N;
DNDXI_ARRAY& dNdxi;
GP_COOR_ARRAY& coor;
REAL X[DIM];
};
class Element_gauss_base:virtual public Element,virtual public Element_output{
protected:
virtual ~Element_gauss_base(){};
struct Matrix_iterator{
Matrix_iterator(double& ref_,unsigned a_,unsigned b_,unsigned i_,unsigned j_):
ref(ref_),a(a_),b(b_),i(i_),j(j_){};
void operator=(Matrix_iterator& right){
ref=right.ref;
a=right.a;
b=right.b;
i=right.i;
j=right.j;
}
double& ref;
unsigned a,b,i,j;
};
std::vector<Matrix_iterator> vmatrix_iterator;
};
template<const unsigned DIM,const unsigned NUM_NODES,const unsigned NUM_GP,class F_TYPE>
class Element_gauss:virtual public Element_gauss_base{
protected:
typedef Elastic<DIM,MATRIX33> Default_material;
typedef const double GP_WEIGHT_ARRAY[NUM_GP];
typedef const double SHAPE_ARRAY[NUM_GP][NUM_NODES];
typedef const double DNDXI_ARRAY[NUM_GP][NUM_NODES][DIM];
typedef const double GP_COOR_ARRAY[NUM_GP][DIM+1];
typedef Matrix33 Default_matrix;
typedef Gauss_point<DIM,NUM_NODES,Default_matrix> Default_gauss_point;
Element_gauss(
int* node_index,
Node* raw_nodes,
Default_material* material,
GP_WEIGHT_ARRAY& gp_weight,
SHAPE_ARRAY& N,
DNDXI_ARRAY& dNdxi,
GP_COOR_ARRAY& gp_coor
);
virtual ~Element_gauss();
virtual void calcK_c(Sparse& K);
virtual void calcK_sigma(Sparse& K);
void update_F(void);
void update_Constitutive(void);
void update_dNdx(void);
Default_material* material;
Node* nodes[NUM_NODES];
Default_gauss_point* gauss_points[NUM_GP];
public:
virtual void initialize(void);
virtual void initialize_sparse(Sparse& K);
virtual void update_loadstep(void);
virtual void update_iteration(void);
virtual void calcK(Sparse& K){
calcK_c(K);
calcK_sigma(K);
};
virtual void calcT(MATRIX& T);
void sync_Kmatrix(Sparse& K,bool symmetric=true);
//from element_output
double getStress(unsigned gp,unsigned i,unsigned j)const{
return gauss_points[gp]->sigma(i,j);
};
double get_F_(unsigned gp,unsigned i,unsigned j)const{
return gauss_points[gp]->F_(i,j);
};
double get_J_(unsigned gp)const{
const Default_matrix& F=gauss_points[gp]->F_;
return F.I1()+F.I2()+F.I3();
};
double get_pressure(unsigned gp)const{
return gauss_points[gp]->sigma.I1()/3.0;
};
double get_potential(unsigned gp)const{
return material->potential(&gauss_points[gp]->F_);
};
Node*& get_node(unsigned node){return nodes[node];};
};