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 "feddlib/core/AceFemAssembly/AceInterface/NeoHookQuadraticTets.hpp"
5#include <vector>
6#include <iostream>
7
8namespace FEDD {
9
10
21template <class SC, class LO, class GO, class NO>
22AssembleFE_LinElas<SC,LO,GO,NO>::AssembleFE_LinElas(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",3500.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);
31 FEType_ = std::get<1>(this->diskTuple_->at(0)); // FEType of Disk
32 dofs_ = std::get<2>(this->diskTuple_->at(0)); // Degrees of freedom per node
33 numNodes_ = std::get<3>(this->diskTuple_->at(0)); // Number of nodes of element
34
35 dofsElement_ = dofs_*numNodes_; // "Dimension of return matrix"
36
37}
38
46
47template <class SC, class LO, class GO, class NO>
49
50
51 SmallMatrixPtr_Type elementMatrix =Teuchos::rcp( new SmallMatrix_Type( dofsElement_)); // Matrix we fill with entries.
52
53 assemblyLinElas(elementMatrix); // Function that fills the matrix. We pass though a pointer that will be filled.
54
55 this->jacobian_ = elementMatrix ; // We init the jacobian matrix with the matrix we just build.
56}
57
65template <class SC, class LO, class GO, class NO>
66void AssembleFE_LinElas<SC,LO,GO,NO>::assemblyLinElas(SmallMatrixPtr_Type &elementMatrix) {
67
69 // dofs_
70 // FEType_
71 // numNodes_
72 // dofsElement_
73 // mu_
74 // poissonRatio_
75
78
79 std::vector<double> v(1002); //Working vector, size defined by AceGen-FEAP
80 std::vector<double> d(2); // Material parameters
81 std::vector<double> ul(30); // The solution vector(or displacement in this case)
82 std::vector<double> ul0(30); // Currently unused but must be passed to match FEAP template
83 std::vector<double> xl(30); // Nodal Positions in reference coordinates
84 std::vector<double> s(900); // Element Stiffness Matrix [Output from skr]
85 std::vector<double> p(30); // Residual vector [Output from skr]
86 std::vector<double> ht(10); // History parameters currently unused
87 std::vector<double> hp(10); // History parameters currently unused
88
89 d[0] = this->E_; // TODO: Check order if there is a problem
90 d[1] = this->poissonRatio_;
91
92 for(int i=0;i<30;i++)
93 ul[i] = (*this->solution_)[i]; // What is the order? I need it in the form (u1,v1,w1,u2,v2,w2,...)
94
95 int count = 0;
96 for(int i=0;i<this->numNodes_;i++)
97 for(int j=0;j<this->dofs_;j++){
98 xl[count] = this->getNodesRefConfig()[i][j];
99 count++;}
100
101 for(int i=0;i<s.size();i++)
102 s[i]=0.0;
103 for(int i=0;i<p.size();i++)
104 p[i]=0.0;
105
106 // std::cout << "[DEBUG] SKR-Jacobian Calls after this line!" << std::endl;
107 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
108 // std::cout << "[DEBUG] SKR-Jacobian Call successful!" << std::endl;
109 // Note: FEAP/Fortran returns matrices unrolled in column major form. This must be converted for use here.
110
111 /*std::cout << "[DEBUG] Printing FEAP output Stiffness vector" << std::endl;
112 for (int i=0;i<900;i++)
113 std::cout << std::setprecision(767) << s[i] << std::endl;*/
114
115 for (UN i=0; i < this->dofsElement_; i++) {
116 for (UN j=0; j < this->dofsElement_; j++) {
117 (*elementMatrix)[i][j] = -s[this->dofsElement_*j+i]; // Rolling into a matrix using column major (m*j+i)
118 }
119 }
120
121}
122
129template <class SC, class LO, class GO, class NO>
131
132 // [Efficiency] Need to know which is called first: assembleRHS() or assembleJacobian(), so that multiple calls to skr() may be avoided.
133 // Note skr() computes both elementMatrix_ and rhsVec_
134 std::vector<double> v(1002); //Working vector, size defined by AceGen-FEAP
135 std::vector<double> d(2); // Material parameters
136 std::vector<double> ul(30); // The solution vector(or displacement in this case)
137 std::vector<double> ul0(30); // Currently unused but must be passed to match FEAP template
138 std::vector<double> xl(30); // Nodal Positions in reference coordinates
139 std::vector<double> s(900); // Element Stiffness Matrix [Output from skr]
140 std::vector<double> p(30); // Residual vector [Output from skr]
141 std::vector<double> ht(10); // History parameters currently unused
142 std::vector<double> hp(10); // History parameters currently unused
143
144 d[0] = this->E_; // TODO: Check order if there is a problem
145 d[1] = this->poissonRatio_;
146
147 for(int i=0;i<30;i++)
148 ul[i] = (*this->solution_)[i];
149
150 int count = 0;
151 for(int i=0;i<this->numNodes_;i++)
152 for(int j=0;j<this->dofs_;j++){
153 xl[count] = this->getNodesRefConfig()[i][j];
154 count++;}
155
156 // Initialize arrays to 0
157 for(int i=0;i<s.size();i++)
158 s[i]=0.0;
159 for(int i=0;i<p.size();i++)
160 p[i]=0.0;
161
162 // std::cout << "[DEBUG] SKR-Rhs Calls after this line!" << std::endl;
163 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
164 // std::cout << "[DEBUG] SKR-Rhs Call successful!" << std::endl;
165 (*this->rhsVec_) = p;
166}
167
168}
169#endif
170
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:22
void assembleJacobian() override
Assemble the element Jacobian matrix.
Definition AssembleFE_LinElas_def.hpp:48
void assembleRHS() override
Assemble the element right hand side vector.
Definition AssembleFE_LinElas_def.hpp:130
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