63 MatrixPtr_Type A(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
65 this->feFactory_->assemblyEmptyMatrix(A);
67 this->system_.reset(
new BlockMatrix_Type(1));
68 this->system_->addBlock( A, 0, 0 );
70 double density = this->parameterList_->sublist(
"Parameter").get(
"Density",1000.);
71 std::string sourceType = this->parameterList_->sublist(
"Parameter").get(
"Source Type",
"volume");
73 this->assembleSourceTerm( 0. );
74 if(sourceType ==
"volume")
79 this->setBoundariesRHS();
81 this->solution_->putScalar(0.);
83 u_rep_ = Teuchos::rcp(
new MultiVector_Type( this->getDomain(0)->getMapVecFieldRepeated() ));
84 MultiVectorConstPtr_Type u = this->solution_->getBlock(0);
85 u_rep_->importFromVector(u,
true);
88 std::cout <<
"done -- " << std::endl;
90 this->reAssemble(
"Newton-Residual");
92 else if(type ==
"UpdateTime")
95 std::cout <<
"-- Reassembly (UpdateTime)" <<
'\n';
101 this->reAssemble(type);
105template<
class SC,
class LO,
class GO,
class NO>
106void NonLinElasticity<SC,LO,GO,NO>::updateTime()
const
108 timeSteppingTool_->t_ = timeSteppingTool_->t_ + timeSteppingTool_->dt_prev_;
111template<
class SC,
class LO,
class GO,
class NO>
112void NonLinElasticity<SC,LO,GO,NO>::reAssemble(std::string type)
const {
113 std::string material_model = this->parameterList_->sublist(
"Parameter").get(
"Material model",
"Neo-Hooke");
116 std::cout <<
"-- Reassembly nonlinear elasticity with material model " << material_model <<
" ("<<type <<
") ... " << std::flush;
118 if (type==
"Newton-Residual") {
119 MultiVectorConstPtr_Type u = this->solution_->getBlock(0);
120 u_rep_->importFromVector(u,
true);
122 MultiVectorPtr_Type f = Teuchos::rcp(
new MultiVector_Type( this->getDomain(0)->getMapVecFieldRepeated(), 1 ) );
124 MatrixPtr_Type W = Teuchos::rcp(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
126 #ifdef FEDD_HAVE_ACEGENINTERFACE
127 bool useInterface = this->parameterList_->sublist(
"Parameter").get(
"Use AceGen Interface",
true);
128 if(this->getFEType(0) ==
"P2" && useInterface && this->dim_==3 && material_model ==
"Neo-Hooke"){
129 this->system_->addBlock( W, 0, 0 );
132 this->residualVec_->addBlock( f, 0 );
134 if(this->parameterList_->sublist(
"Parameter").get(
"SCI",
false) ==
true || this->parameterList_->sublist(
"Parameter").get(
"FSCI",
false) ==
true )
135 this->feFactory_->assemblyAceDeformDiffuBlock(this->dim_, this->getDomain(0)->getFEType(), this->getDomain(0)->getFEType(), 2, 1,this->dim_,concentration_,u_rep_,this->system_,0,0,this->residualVec_,0, this->parameterList_,
"Jacobian",
true);
137 this->feFactory_->assemblyNonLinearElasticity(this->dim_, this->getDomain(0)->getFEType(),2, this->dim_, u_rep_, this->system_, this->residualVec_, this->parameterList_,
true);
141 this->feFactory_->assemblyElasticityJacobianAndStressAceFEM(this->dim_, this->getDomain(0)->getFEType(), W, f, u_rep_, this->parameterList_, C_);
143 this->feFactory_->assemblyElasticityJacobianAndStressAceFEM(this->dim_, this->getDomain(0)->getFEType(), W, f, u_rep_, this->parameterList_, C_);
146 MultiVectorPtr_Type fUnique = Teuchos::rcp(
new MultiVector_Type( this->getDomain(0)->getMapVecFieldUnique(), 1 ) );
147 fUnique->putScalar(0.);
148 fUnique->exportFromVector( f,
true,
"Add" );
150 this->residualVec_->addBlock( fUnique, 0 );
151 this->system_->addBlock( W, 0, 0 );
154 assembleSourceTermLoadstepping();
157 else if(type==
"Newton"){
161 std::cout <<
"done -- " << std::endl;
164template<
class SC,
class LO,
class GO,
class NO>
165void NonLinElasticity<SC,LO,GO,NO>::reAssemble( MatrixPtr_Type& massmatrix, std::string type )
const
170template<
class SC,
class LO,
class GO,
class NO>
171void NonLinElasticity<SC,LO,GO,NO>::reAssembleExtrapolation(BlockMultiVectorPtrArray_Type previousSolutions){
174 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Only Newton/NOX implemented for nonlinear material models!");
179template<
class SC,
class LO,
class GO,
class NO>
180void NonLinElasticity<SC,LO,GO,NO>::assembleSourceTermLoadstepping(
double time)
const
182 double dt = timeSteppingTool_->get_dt();
183 double beta = timeSteppingTool_->get_beta();
184 double gamma = timeSteppingTool_->get_gamma();
187 if( loadStepping_ ==
true){
189 this->getRhs()->scale(0.0);
193 if (this->hasSourceTerm())
197 MultiVectorPtr_Type FERhs = Teuchos::rcp(
new MultiVector_Type( this->getDomain(0)->getMapVecFieldRepeated() ));
198 vec_dbl_Type funcParameter(4,0.);
199 funcParameter[0] = timeSteppingTool_->t_;
201 funcParameter[1] =this->parameterList_->sublist(
"Parameter").get(
"Volume force",0.00211);
203 funcParameter[3] =this->parameterList_->sublist(
"Parameter").get(
"Final time force",1.0);
204 funcParameter[4] =this->parameterList_->sublist(
"Parameter").get(
"dt",0.1);
207 if(nonlinearExternalForce_){
208 MatrixPtr_Type A(
new Matrix_Type (this->system_->getBlock(0,0)));
210 MatrixPtr_Type AKext(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
211 MatrixPtr_Type Kext(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow()*2 ) );
212 MultiVectorPtr_Type Kext_vec;
213 this->feFactory_->assemblyNonlinearSurfaceIntegralExternal(this->dim_, this->getDomain(0)->getFEType(),FERhs, u_rep_,Kext, funcParameter, this->rhsFuncVec_[0],this->parameterList_);
215 A->addMatrix(1.,AKext,0.);
216 Kext->addMatrix(1.,AKext,1.);
218 AKext->fillComplete(this->getDomain(0)->getMapVecFieldUnique(),this->getDomain(0)->getMapVecFieldUnique());
220 this->system_->addBlock(AKext,0,0);
224 this->feFactory_->assemblySurfaceIntegralExternal(this->dim_, this->getDomain(0)->getFEType(),FERhs, u_rep_, funcParameter, this->rhsFuncVec_[0],this->parameterList_);
227 this->sourceTerm_->getBlockNonConst(0)->exportFromVector( FERhs,
false,
"Add" );
230 this->assembleSourceTerm( timeSteppingTool_->t_ );
236 double coeffSourceTermStructure = 1.0;
237 BlockMultiVectorPtr_Type tmpPtr= this->sourceTerm_;
239 this->getRhs()->update(coeffSourceTermStructure, *tmpPtr, 1.);
240 this->rhs_->addBlock( this->getRhs()->getBlockNonConst(0), 0 );
246template<
class SC,
class LO,
class GO,
class NO>
249 this->reAssemble(
"Newton-Residual");
251#ifdef FEDD_HAVE_ACEGENINTERFACE
252 if(this->getFEType(0) ==
"P2" && this->parameterList_->sublist(
"Parameter").get(
"Use AceGen Interface",
true)){
253 if(this->parameterList_->sublist(
"Parameter").get(
"SCI",
false) ==
true || this->parameterList_->sublist(
"Parameter").get(
"FSCI",
false) ==
true ){
254 this->feFactory_->assemblyAceDeformDiffuBlock(this->dim_, this->getDomain(0)->getFEType(), this->getDomain(0)->getFEType(), 2, 1,this->dim_,concentration_,u_rep_,this->system_,0,0,this->residualVec_,0, this->parameterList_,
"Rhs",
true);
258 if(this->parameterList_->sublist(
"Parameter").get(
"SCI",
false) ==
false && this->parameterList_->sublist(
"Parameter").get(
"FSCI",
false) ==
false ){
260 if (!type.compare(
"standard")){
261 this->residualVec_->update(-1.,*this->rhs_,1.);
265 else if(!type.compare(
"reverse")){
266 this->residualVec_->update(1.,*this->rhs_,-1.);
271 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::runtime_error,
"Unknown type for residual computation.");
275 this->bcFactory_->setBCMinusVector( this->residualVec_, this->solution_, time );