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