Finite Element Domain Decomposition Library
FEDDLib
Loading...
Searching...
No Matches
AssembleFE_NonLinElas2_def.hpp
1#ifndef AssembleFE_NonLinElas2_DEF_hpp
2#define AssembleFE_NonLinElas2_DEF_hpp
3
4#include "feddlib/core/AceFemAssembly/AceInterface/NeoHookQuadraticTets3.hpp"
5#include <vector>
6#include <iostream>
7
8namespace FEDD {
9
10
21template <class SC, class LO, class GO, class NO>
22 AssembleFE_NonLinElas2<SC,LO,GO,NO>:: AssembleFE_NonLinElas2(int flag, vec2D_dbl_Type nodesRefConfig, ParameterListPtr_Type params,tuple_disk_vec_ptr_Type tuple):
23AssembleFE<SC,LO,GO,NO>(flag, nodesRefConfig, params,tuple)
24{
26 E_ = this->params_->sublist("Parameter").get("E",1000.0); // the last value is the dafault value, in case no parameter is set
27 //lambda_ = this->params_->sublist("Parameter").get("lambda",1.);
28 poissonRatio_ = this->params_->sublist("Parameter").get("Poisson Ratio",0.4e-0);
29
32 FEType_ = std::get<1>(this->diskTuple_->at(0)); // FEType of Disk
33 dofs_ = std::get<2>(this->diskTuple_->at(0)); // Degrees of freedom per node
34 numNodes_ = std::get<3>(this->diskTuple_->at(0)); // Number of nodes of element
35
36 dofsElement_ = dofs_*numNodes_; // "Dimension of return matrix"
37
38}
39
47
48template <class SC, class LO, class GO, class NO>
50
51
52 SmallMatrixPtr_Type elementMatrix =Teuchos::rcp( new SmallMatrix_Type( dofsElement_)); // Matrix we fill with entries.
53
54 assemblyNonLinElas(elementMatrix); // Function that fills the matrix. We pass though a pointer that will be filled.
55
56 this->jacobian_ = elementMatrix ; // We init the jacobian matrix with the matrix we just build.
57}
58
66template <class SC, class LO, class GO, class NO>
67void AssembleFE_NonLinElas2<SC,LO,GO,NO>::assemblyNonLinElas(SmallMatrixPtr_Type &elementMatrix) {
68
70 // dofs_
71 // FEType_
72 // numNodes_
73 // dofsElement_
74 // mu_
75 // poissonRatio_
76
79 this->rhsVec_.reset( new vec_dbl_Type ( dofsElement_,0.) );
80
81
82 std::vector<double> v(1066); //Working vector, size defined by AceGen-FEAP
83 std::vector<double> d(2); // Material parameters
84 std::vector<double> ul(30); // The solution vector(or displacement in this case)
85 std::vector<double> ul0(30); // Currently unused but must be passed to match FEAP template
86 std::vector<double> xl(30); // Nodal Positions in reference coordinates
87 std::vector<double> s(900); // Element Stiffness Matrix [Output from skr]
88 std::vector<double> p(30); // Residual vector [Output from skr]
89 std::vector<double> ht(10); // History parameters currently unused
90 std::vector<double> hp(10); // History parameters currently unused
91
92 d[0] = this->E_; // TODO: Check order if there is a problem
93 d[1] = this->poissonRatio_;
94
95 for(int i=0;i<30;i++)
96 ul[i] = (*this->solution_)[i]; // What is the order? I need it in the form (u1,v1,w1,u2,v2,w2,...)
97
98 int count = 0;
99 for(int i=0;i<this->numNodes_;i++)
100 for(int j=0;j<this->dofs_;j++){
101 xl[count] = this->getNodesRefConfig()[i][j];
102 count++;}
103
104 for(int i=0;i<s.size();i++)
105 s[i]=0.0;
106 for(int i=0;i<p.size();i++)
107 p[i]=0.0;
108
109 // std::cout << "[DEBUG] SKR-Jacobian Calls after this line!" << std::endl;
110 skr3(&v[0],&d[0],&ul[0],&ul0[0],&xl[0],&s[0],&p[0],&ht[0],&hp[0]); // Fortran subroutine call modifies s and p
111 // std::cout << "[DEBUG] SKR-Jacobian Call successful!" << std::endl;
112 // Note: FEAP/Fortran returns matrices unrolled in column major form. This must be converted for use here.
113
114 /* std::cout << "[DEBUG] Printing FEAP output Stiffness vector" << std::endl;
115 for (int i=0;i<900;i++)
116 std::cout << s[i] << " ";*/
117
118 for (UN i=0; i < this->dofsElement_; i++) {
119 for (UN j=0; j < this->dofsElement_; j++) {
120 (*elementMatrix)[i][j] = -s[this->dofsElement_*j+i]; // Rolling into a matrix using column major (m*j+i)
121 }
122 }
123
124}
125
132template <class SC, class LO, class GO, class NO>
134
135 // [Efficiency] Need to know which is called first: assembleRHS() or assembleJacobian(), so that multiple calls to skr() may be avoided.
136 // Note skr() computes both elementMatrix_ and rhsVec_
137 std::vector<double> v(1066); //Working vector, size defined by AceGen-FEAP
138 std::vector<double> d(2); // Material parameters
139 std::vector<double> ul(30); // The solution vector(or displacement in this case)
140 std::vector<double> ul0(30); // Currently unused but must be passed to match FEAP template
141 std::vector<double> xl(30); // Nodal Positions in reference coordinates
142 std::vector<double> s(900); // Element Stiffness Matrix [Output from skr]
143 std::vector<double> p(30); // Residual vector [Output from skr]
144 std::vector<double> ht(10); // History parameters currently unused
145 std::vector<double> hp(10); // History parameters currently unused
146
147 d[0] = this->E_; // TODO: Check order if there is a problem
148 d[1] = this->poissonRatio_;
149
150 for(int i=0;i<30;i++){
151 ul[i] = (*this->solution_)[i];
152 }
153
154 int count = 0;
155 for(int i=0;i<this->numNodes_;i++)
156 for(int j=0;j<this->dofs_;j++){
157 xl[count] = this->getNodesRefConfig()[i][j];
158 count++;}
159
160 // Initialize arrays to 0
161 for(int i=0;i<s.size();i++)
162 s[i]=0.0;
163 for(int i=0;i<p.size();i++)
164 p[i]=0.0;
165
166 // std::cout << "[DEBUG] SKR-Rhs Calls after this line!" << std::endl;
167 skr3(&v[0],&d[0],&ul[0],&ul0[0],&xl[0],&s[0],&p[0],&ht[0],&hp[0]); // Fortran subroutine call modifies s and p
168 // std::cout << "[DEBUG] SKR-Rhs Call successful!" << std::endl;
169
170 for(int i=0; i< p.size(); i++)
171 (*this->rhsVec_)[i] = -p[i];
172}
173template <class SC, class LO, class GO, class NO>
174void AssembleFE_NonLinElas2<SC,LO,GO,NO>:: updateParameter(std::string type, double value){
175 if(type == "E")
176 this->E_ = value;
177
178
179}
180
181
182}
183#endif
184
void updateParameter(std::string type, double value) override
Update the parameter read from the ParameterList.
Definition AssembleFE_NonLinElas2_def.hpp:174
void assembleRHS() override
Assemble the element right hand side vector.
Definition AssembleFE_NonLinElas2_def.hpp:133
AssembleFE_NonLinElas2(int flag, vec2D_dbl_Type nodesRefConfig, ParameterListPtr_Type parameters, tuple_disk_vec_ptr_Type tuple)
Constructor for AssembleFE_NonLinElas2.
Definition AssembleFE_NonLinElas2_def.hpp:22
void assembleJacobian() override
Assemble the element Jacobian matrix.
Definition AssembleFE_NonLinElas2_def.hpp:49
AssembleFE(int flag, vec2D_dbl_Type nodesRefConfig, ParameterListPtr_Type parameters, tuple_disk_vec_ptr_Type tuple)
Definition AssembleFE_def.hpp:8
vec2D_dbl_Type getNodesRefConfig()
Definition AssembleFE_def.hpp:142
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement_decl.hpp:36