Finite Element Domain Decomposition Library
FEDDLib
Loading...
Searching...
No Matches
NonLinElasticity_def.hpp
1#ifndef NonLinElasticity_def_hpp
2#define NonLinElasticity_def_hpp
3#include "NonLinElasticity_decl.hpp"
12
13
14namespace FEDD {
15template<class SC,class LO,class GO,class NO>
16NonLinElasticity<SC,LO,GO,NO>::NonLinElasticity(const DomainConstPtr_Type &domain, std::string FEType, ParameterListPtr_Type parameterList):
17NonLinearProblem<SC,LO,GO,NO>( parameterList, domain->getComm() ),
18u_rep_()
19{
20 this->nonLinearTolerance_ = this->parameterList_->sublist("Parameter").get("relNonLinTol",1.0e-6);
21 this->initNOXParameters();
22 this->addVariable( domain , FEType , "u" , domain->getDimension());
23 this->dim_ = this->getDomain(0)->getDimension();
24
25 C_ = this->parameterList_->sublist("Parameter").get("C",1.);
26
27 double density = this->parameterList_->sublist("Parameter").get("Density",1.);
28// poissonRatio_ = this->parameterList_->sublist("Parameter").get("Poisson Ratio",0.4);
29// mue_ = this->parameterList_->sublist("Parameter").get("Mu",2.0e+6);
30// // Berechne daraus nun E (Youngsches Modul) und die erste Lamé-Konstante \lambda
31// E_ = mue_*2.*(1. + poissonRatio_);
32// lambda_ = (poissonRatio_*E_)/((1 + poissonRatio_)*(1 - 2*poissonRatio_));
33
34}
35
36template<class SC,class LO,class GO,class NO>
37NonLinElasticity<SC,LO,GO,NO>::~NonLinElasticity(){
38
39}
40
41template<class SC,class LO,class GO,class NO>
42void NonLinElasticity<SC,LO,GO,NO>::info(){
43 this->infoProblem();
44 this->infoNonlinProblem();
45}
46
47template<class SC,class LO,class GO,class NO>
48void NonLinElasticity<SC,LO,GO,NO>::assemble(std::string type) const{
49
50 if (type == ""){
51 if (this->verbose_)
52 std::cout << "-- Assembly nonlinear elasticity ... " << std::flush;
53
54 MatrixPtr_Type A(new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
55
56 this->feFactory_->assemblyEmptyMatrix(A);
57
58 this->system_.reset(new BlockMatrix_Type(1));
59 this->system_->addBlock( A, 0, 0 );
60
61 double density = this->parameterList_->sublist("Parameter").get("Density",1000.);
62 std::string sourceType = this->parameterList_->sublist("Parameter").get("Source Type","volume");
63
64 this->assembleSourceTerm( 0. );
65 if(sourceType == "volume")
66 this->sourceTerm_->scale(density);
67
68 this->addToRhs( this->sourceTerm_ );
69
70 this->setBoundariesRHS();
71
72
73 this->solution_->putScalar(0.);
74
75 u_rep_ = Teuchos::rcp(new MultiVector_Type( this->getDomain(0)->getMapVecFieldRepeated() ));
76 MultiVectorConstPtr_Type u = this->solution_->getBlock(0);
77 u_rep_->importFromVector(u, true);
78
79 if (this->verbose_)
80 std::cout << "done -- " << std::endl;
81
82 this->reAssemble("Newton-Residual");
83 }
84 else
85 this->reAssemble(type);
86}
87
88template<class SC,class LO,class GO,class NO>
89void NonLinElasticity<SC,LO,GO,NO>::reAssemble(std::string type) const {
90 std::string material_model = this->parameterList_->sublist("Parameter").get("Material model","Neo-Hooke");
91
92 if (this->verbose_)
93 std::cout << "-- Reassembly nonlinear elasticity with material model " << material_model <<" ("<<type <<") ... " << std::flush;
94
95 if (type=="Newton-Residual") {
96 MultiVectorConstPtr_Type u = this->solution_->getBlock(0);
97
98 u_rep_->importFromVector(u, true);
99
100 MultiVectorPtr_Type f = Teuchos::rcp( new MultiVector_Type( this->getDomain(0)->getMapVecFieldRepeated(), 1 ) );
101 MatrixPtr_Type W = Teuchos::rcp(new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
102 this->feFactory_->assemblyElasticityJacobianAndStressAceFEM(this->dim_, this->getDomain(0)->getFEType(), W, f, u_rep_, this->parameterList_, C_);
103
104 MultiVectorPtr_Type fUnique = Teuchos::rcp( new MultiVector_Type( this->getDomain(0)->getMapVecFieldUnique(), 1 ) );
105 fUnique->putScalar(0.);
106 fUnique->exportFromVector( f, true, "Add" );
107
108 this->residualVec_->addBlock( fUnique, 0 );
109 this->system_->addBlock( W, 0, 0 );
110
111 // MultiVectorPtr_Type f = Teuchos::rcp( new MultiVector_Type( this->getDomain(0)->getMapVecFieldRepeated(), 1 ) );
112// this->feFactory_->assemblyElasticityStressesAceFEM(this->dim_, this->getDomain(0)->getFEType(), f, u_rep_, material_model, E_, nu_, C_);
113// MultiVectorPtr_Type fUnique = Teuchos::rcp( new MultiVector_Type( this->getDomain(0)->getMapVecFieldUnique(), 1 ) );
114// fUnique->putScalar(0.);
115// fUnique->importFromVector( f, true, "Add" );
116// this->residualVec_->addBlock( fUnique, 0 );
117 }
118 else if(type=="Newton"){ //we already assemble the new tangent when we calculate the stresses above
119
120 }
121 if (this->verbose_)
122 std::cout << "done -- " << std::endl;
123}
124
125template<class SC,class LO,class GO,class NO>
126void NonLinElasticity<SC,LO,GO,NO>::reAssemble( MatrixPtr_Type& massmatrix, std::string type ) const
127{
128
129}
130
131template<class SC,class LO,class GO,class NO>
132void NonLinElasticity<SC,LO,GO,NO>::reAssembleExtrapolation(BlockMultiVectorPtrArray_Type previousSolutions){
133
134
135 TEUCHOS_TEST_FOR_EXCEPTION( true, std::logic_error, "Only Newton/NOX implemented for nonlinear material models!");
136
137}
138
139
140template<class SC,class LO,class GO,class NO>
141void NonLinElasticity<SC,LO,GO,NO>::calculateNonLinResidualVec(std::string type, double time) const{
142
143 this->reAssemble("Newton-Residual");
144 if (!type.compare("standard")){
145 this->residualVec_->update(-1.,*this->rhs_,1.);
146 //if ( !this->sourceTerm_.is_null() )
147 // this->residualVec_->update(-1.,*this->sourceTerm_,1.);
148 }
149 else if(!type.compare("reverse")){
150 this->residualVec_->update(1.,*this->rhs_,-1.); // this = -1*this + 1*rhs
151 //if ( !this->sourceTerm_.is_null() )
152 // this->residualVec_->update(1.,*this->sourceTerm_,1.);
153 }
154 else{
155 TEUCHOS_TEST_FOR_EXCEPTION(true, std::runtime_error, "Unknown type for residual computation.");
156 }
157
158 // this might be set again by the TimeProblem after adding of M*u
159 this->bcFactory_->setBCMinusVector( this->residualVec_, this->solution_, time );
160
161}
162}
163#endif
Definition NonLinearProblem_decl.hpp:24
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement_decl.hpp:33