1#ifndef NonLinElasticity_def_hpp
2#define NonLinElasticity_def_hpp
3#include "NonLinElasticity_decl.hpp"
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):
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();
25 C_ = this->parameterList_->sublist(
"Parameter").get(
"C",1.);
27 double density = this->parameterList_->sublist(
"Parameter").get(
"Density",1.);
36template<
class SC,
class LO,
class GO,
class NO>
37NonLinElasticity<SC,LO,GO,NO>::~NonLinElasticity(){
41template<
class SC,
class LO,
class GO,
class NO>
42void NonLinElasticity<SC,LO,GO,NO>::info(){
44 this->infoNonlinProblem();
47template<
class SC,
class LO,
class GO,
class NO>
48void NonLinElasticity<SC,LO,GO,NO>::assemble(std::string type)
const{
52 std::cout <<
"-- Assembly nonlinear elasticity ... " << std::flush;
54 MatrixPtr_Type A(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
56 this->feFactory_->assemblyEmptyMatrix(A);
58 this->system_.reset(
new BlockMatrix_Type(1));
59 this->system_->addBlock( A, 0, 0 );
61 double density = this->parameterList_->sublist(
"Parameter").get(
"Density",1000.);
62 std::string sourceType = this->parameterList_->sublist(
"Parameter").get(
"Source Type",
"volume");
64 this->assembleSourceTerm( 0. );
65 if(sourceType ==
"volume")
66 this->sourceTerm_->scale(density);
68 this->addToRhs( this->sourceTerm_ );
70 this->setBoundariesRHS();
73 this->solution_->putScalar(0.);
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);
80 std::cout <<
"done -- " << std::endl;
82 this->reAssemble(
"Newton-Residual");
85 this->reAssemble(type);
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");
93 std::cout <<
"-- Reassembly nonlinear elasticity with material model " << material_model <<
" ("<<type <<
") ... " << std::flush;
95 if (type==
"Newton-Residual") {
96 MultiVectorConstPtr_Type u = this->solution_->getBlock(0);
98 u_rep_->importFromVector(u,
true);
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_);
104 MultiVectorPtr_Type fUnique = Teuchos::rcp(
new MultiVector_Type( this->getDomain(0)->getMapVecFieldUnique(), 1 ) );
105 fUnique->putScalar(0.);
106 fUnique->exportFromVector( f,
true,
"Add" );
108 this->residualVec_->addBlock( fUnique, 0 );
109 this->system_->addBlock( W, 0, 0 );
118 else if(type==
"Newton"){
122 std::cout <<
"done -- " << std::endl;
125template<
class SC,
class LO,
class GO,
class NO>
126void NonLinElasticity<SC,LO,GO,NO>::reAssemble( MatrixPtr_Type& massmatrix, std::string type )
const
131template<
class SC,
class LO,
class GO,
class NO>
132void NonLinElasticity<SC,LO,GO,NO>::reAssembleExtrapolation(BlockMultiVectorPtrArray_Type previousSolutions){
135 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Only Newton/NOX implemented for nonlinear material models!");
140template<
class SC,
class LO,
class GO,
class NO>
141void NonLinElasticity<SC,LO,GO,NO>::calculateNonLinResidualVec(std::string type,
double time)
const{
143 this->reAssemble(
"Newton-Residual");
144 if (!type.compare(
"standard")){
145 this->residualVec_->update(-1.,*this->rhs_,1.);
149 else if(!type.compare(
"reverse")){
150 this->residualVec_->update(1.,*this->rhs_,-1.);
155 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::runtime_error,
"Unknown type for residual computation.");
159 this->bcFactory_->setBCMinusVector( this->residualVec_, this->solution_, time );
Definition NonLinearProblem_decl.hpp:24
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement_decl.hpp:33