Finite Element Domain Decomposition Library
FEDDLib
Loading...
Searching...
No Matches
AssembleFE_LinElas_def.hpp
1#ifndef ASSEMBLEFE_LINELAS_DEF_hpp
2#define ASSEMBLEFE_LINELAS_DEF_hpp
3
4#include "AssembleFE_LinElas_decl.hpp"
5#include "feddlib/core/AceFemAssembly/AceInterface/NeoHookQuadraticTets.hpp"
6#include <vector>
7#include <iostream>
8
9namespace FEDD {
10
11
22template <class SC, class LO, class GO, class NO>
23AssembleFE_LinElas<SC,LO,GO,NO>::AssembleFE_LinElas(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",3500.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 assemblyLinElas(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_LinElas<SC,LO,GO,NO>::assemblyLinElas(SmallMatrixPtr_Type &elementMatrix) {
69
71 // dofs_
72 // FEType_
73 // numNodes_
74 // dofsElement_
75 // mu_
76 // poissonRatio_
77
80
81 std::vector<double> v(1002); //Working vector, size defined by AceGen-FEAP
82 std::vector<double> d(2); // Material parameters
83 std::vector<double> ul(30); // The solution vector(or displacement in this case)
84 std::vector<double> ul0(30); // Currently unused but must be passed to match FEAP template
85 std::vector<double> xl(30); // Nodal Positions in reference coordinates
86 std::vector<double> s(900); // Element Stiffness Matrix [Output from skr]
87 std::vector<double> p(30); // Residual vector [Output from skr]
88 std::vector<double> ht(10); // History parameters currently unused
89 std::vector<double> hp(10); // History parameters currently unused
90
91 d[0] = this->E_; // TODO: Check order if there is a problem
92 d[1] = this->poissonRatio_;
93
94 for(int i=0;i<30;i++)
95 ul[i] = (*this->solution_)[i]; // What is the order? I need it in the form (u1,v1,w1,u2,v2,w2,...)
96
97 int count = 0;
98 for(int i=0;i<this->numNodes_;i++)
99 for(int j=0;j<this->dofs_;j++){
100 xl[count] = this->getNodesRefConfig()[i][j];
101 count++;}
102
103 for(int i=0;i<s.size();i++)
104 s[i]=0.0;
105 for(int i=0;i<p.size();i++)
106 p[i]=0.0;
107
108 // std::cout << "[DEBUG] SKR-Jacobian Calls after this line!" << std::endl;
109 skr1(&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
110 // std::cout << "[DEBUG] SKR-Jacobian Call successful!" << std::endl;
111 // Note: FEAP/Fortran returns matrices unrolled in column major form. This must be converted for use here.
112
113 /*std::cout << "[DEBUG] Printing FEAP output Stiffness vector" << std::endl;
114 for (int i=0;i<900;i++)
115 std::cout << std::setprecision(767) << s[i] << std::endl;*/
116
117 for (UN i=0; i < this->dofsElement_; i++) {
118 for (UN j=0; j < this->dofsElement_; j++) {
119 (*elementMatrix)[i][j] = -s[this->dofsElement_*j+i]; // Rolling into a matrix using column major (m*j+i)
120 }
121 }
122
123}
124
131template <class SC, class LO, class GO, class NO>
133
134 // [Efficiency] Need to know which is called first: assembleRHS() or assembleJacobian(), so that multiple calls to skr() may be avoided.
135 // Note skr() computes both elementMatrix_ and rhsVec_
136 std::vector<double> v(1002); //Working vector, size defined by AceGen-FEAP
137 std::vector<double> d(2); // Material parameters
138 std::vector<double> ul(30); // The solution vector(or displacement in this case)
139 std::vector<double> ul0(30); // Currently unused but must be passed to match FEAP template
140 std::vector<double> xl(30); // Nodal Positions in reference coordinates
141 std::vector<double> s(900); // Element Stiffness Matrix [Output from skr]
142 std::vector<double> p(30); // Residual vector [Output from skr]
143 std::vector<double> ht(10); // History parameters currently unused
144 std::vector<double> hp(10); // History parameters currently unused
145
146 d[0] = this->E_; // TODO: Check order if there is a problem
147 d[1] = this->poissonRatio_;
148
149 for(int i=0;i<30;i++)
150 ul[i] = (*this->solution_)[i];
151
152 int count = 0;
153 for(int i=0;i<this->numNodes_;i++)
154 for(int j=0;j<this->dofs_;j++){
155 xl[count] = this->getNodesRefConfig()[i][j];
156 count++;}
157
158 // Initialize arrays to 0
159 for(int i=0;i<s.size();i++)
160 s[i]=0.0;
161 for(int i=0;i<p.size();i++)
162 p[i]=0.0;
163
164 // std::cout << "[DEBUG] SKR-Rhs Calls after this line!" << std::endl;
165 skr1(&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
166 // std::cout << "[DEBUG] SKR-Rhs Call successful!" << std::endl;
167 (*this->rhsVec_) = p;
168}
169
170}
171#endif
172
AssembleFE_LinElas(int flag, vec2D_dbl_Type nodesRefConfig, ParameterListPtr_Type parameters, tuple_disk_vec_ptr_Type tuple)
Constructor for AssembleFE_Laplace.
Definition AssembleFE_LinElas_def.hpp:23
void assembleJacobian() override
Assemble the element Jacobian matrix.
Definition AssembleFE_LinElas_def.hpp:50
void assembleRHS() override
Assemble the element right hand side vector.
Definition AssembleFE_LinElas_def.hpp:132
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