1#ifndef NonLinTPM_def_hpp
2#define NonLinTPM_def_hpp
3#include "NonLinTPM_decl.hpp"
17template<
class SC,
class LO,
class GO,
class NO>
18NonLinTPM<SC,LO,GO,NO>::NonLinTPM(
const DomainConstPtr_Type &domainVelocity, std::string FETypeVelocity,
const DomainConstPtr_Type &domainPressure, std::string FETypePressure, ParameterListPtr_Type parameterList):
22 this->addVariable( domainVelocity , FETypeVelocity ,
"u" , domainVelocity->getDimension());
23 this->addVariable( domainPressure , FETypePressure ,
"p" , 1);
24 this->dim_ = this->getDomain(0)->getDimension();
27template<
class SC,
class LO,
class GO,
class NO>
28NonLinTPM<SC,LO,GO,NO>::~NonLinTPM(){
32template<
class SC,
class LO,
class GO,
class NO>
33void NonLinTPM<SC,LO,GO,NO>::info(){
122template<
class SC,
class LO,
class GO,
class NO>
123void NonLinTPM<SC,LO,GO,NO>::calculateNonLinResidualVec(std::string type,
double time)
const{
125 this->assemble(
"Newton-Residual");
126 if (type ==
"external" ){
127 this->residualVec_->update(1.,*this->rhs_,0.);
128 if ( !this->sourceTerm_.is_null() ){
129 this->residualVec_->update(-1.,*this->sourceTerm_,1.);
133 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::runtime_error,
"Unknown type for residual computation.");
135 this->bcFactory_->setBCMinusVector( this->residualVec_, this->solution_, time );
139template<
class SC,
class LO,
class GO,
class NO>
140void NonLinTPM<SC,LO,GO,NO>::reAssemble( BlockMultiVectorPtr_Type previousSolution )
const {
141 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::runtime_error,
"This should not be used.");
142 MultiVectorConstPtr_Type u_prev = previousSolution->getBlock(0);
143 MultiVectorConstPtr_Type p_prev = previousSolution->getBlock(1);
144 u_repTime_->importFromVector(u_prev,
true);
145 p_repTime_->importFromVector(p_prev,
true);
149template<
class SC,
class LO,
class GO,
class NO>
150void NonLinTPM<SC,LO,GO,NO>::assemble( std::string type )
const{
153 std::cout <<
"-- Assembly nonlinear TPM " <<
" ("<<type <<
") ... " << std::flush;
155 std::string tpmType = this->parameterList_->sublist(
"Parameter").get(
"TPM Type",
"Biot");
157 if (type==
"Newton-Residual") {
161 if (type ==
"FirstAssemble") {
162 if (u_repNewton_.is_null()){
163 u_repNewton_ = Teuchos::rcp(
new MultiVector_Type( this->getDomain(0)->getMapVecFieldRepeated() )) ;
164 u_repNewton_->putScalar(0.);
166 if (p_repNewton_.is_null()){
167 p_repNewton_ = Teuchos::rcp(
new MultiVector_Type( this->getDomain(1)->getMapRepeated() )) ;
168 p_repNewton_->putScalar(0.);
171 if (u_repTime_.is_null()){
172 u_repTime_ = Teuchos::rcp(
new MultiVector_Type( this->getDomain(0)->getMapVecFieldRepeated() )) ;
173 u_repTime_->putScalar(0.);
175 if (p_repTime_.is_null()){
176 p_repTime_ = Teuchos::rcp(
new MultiVector_Type( this->getDomain(1)->getMapRepeated() )) ;
177 p_repTime_->putScalar(0.);
182 if (type ==
"SetSolutionInTime") {
183 TEUCHOS_TEST_FOR_EXCEPTION( u_repTime_.is_null(), std::runtime_error,
"u_repTime_ not initialized.");
184 TEUCHOS_TEST_FOR_EXCEPTION( p_repTime_.is_null(), std::runtime_error,
"p_repTime_ not initialized.");
185 MultiVectorConstPtr_Type u = this->solution_->getBlock(0);
186 MultiVectorConstPtr_Type p = this->solution_->getBlock(1);
187 u_repTime_->importFromVector(u,
true);
188 p_repTime_->importFromVector(p,
true);
190 else if (type ==
"SetSolutionNewton") {
191 TEUCHOS_TEST_FOR_EXCEPTION( u_repNewton_.is_null(), std::runtime_error,
"u_repNewton_ not initialized.");
192 TEUCHOS_TEST_FOR_EXCEPTION( p_repNewton_.is_null(), std::runtime_error,
"p_repNewton_ not initialized.");
194 MultiVectorConstPtr_Type u = this->solution_->getBlock(0);
195 MultiVectorConstPtr_Type p = this->solution_->getBlock(1);
196 u_repNewton_->importFromVector(u,
true);
197 p_repNewton_->importFromVector(p,
true);
199 else if( type ==
"FirstAssemble" || type ==
"Assemble" || type ==
"OnlyUpdate" || type ==
"AssembleAndUpdate"){
201 std::cout <<
"-- External assembly ... " << std::flush;
203 MapConstPtr_Type mapRepeatedConst1 = this->getDomain(0)->getMapRepeated();
204 MapConstPtr_Type mapRepeatedConst2 = this->getDomain(1)->getMapRepeated();
205 MapPtr_Type mapRepeated1 = Teuchos::rcp_const_cast<Map_Type>(mapRepeatedConst1);
206 MapPtr_Type mapRepeated2 = Teuchos::rcp_const_cast<Map_Type>(mapRepeatedConst2);
208 MatrixPtr_Type A00(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
209 MatrixPtr_Type A01(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(1)->getDimension() * this->getDomain(1)->getApproxEntriesPerRow() ) );
210 MatrixPtr_Type A10(
new Matrix_Type( this->getDomain(1)->getMapUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
211 MatrixPtr_Type A11(
new Matrix_Type( this->getDomain(1)->getMapUnique(), this->getDomain(1)->getDimension() * this->getDomain(1)->getApproxEntriesPerRow() ) );
214 MultiVectorPtr_Type F0(
new MultiVector_Type( this->getDomain(0)->getMapVecFieldRepeated(), 1 ) );
215 MultiVectorPtr_Type F1(
new MultiVector_Type( this->getDomain(1)->getMapRepeated(), 1 ) );
217 bool update(type ==
"FirstAssemble" || type ==
"Assemble" || type ==
"AssembleAndUpdate");
218 bool updateHistory(type ==
"OnlyUpdate" || type ==
"AssembleAndUpdate");
220 if(tpmType ==
"Biot" || tpmType ==
"Biot-StVK"){
221 this->feFactory_->assemblyAceGenTPM(A00,
229 this->parameterList_,
238 this->system_->addBlock( A00, 0, 0 );
239 this->system_->addBlock( A01, 0, 1 );
240 this->system_->addBlock( A10, 1, 0 );
241 this->system_->addBlock( A11, 1, 1 );
244 MultiVectorPtr_Type F0Unique = Teuchos::rcp(
new MultiVector_Type( this->getDomain(0)->getMapVecFieldUnique() ) );
245 MultiVectorPtr_Type F1Unique = Teuchos::rcp(
new MultiVector_Type( this->getDomain(1)->getMapUnique() ) );
246 F0Unique->exportFromVector( F0,
false,
"Add" );
247 F1Unique->exportFromVector( F1,
false,
"Add" );
249 this->rhs_->addBlock( F0Unique, 0 );
250 this->rhs_->addBlock( F1Unique, 1 );
254 std::cout <<
"done -- " << std::endl;
258template<
class SC,
class LO,
class GO,
class NO>
259void NonLinTPM<SC,LO,GO,NO>::reAssemble( MatrixPtr_Type& massmatrix, std::string type )
const
264template<
class SC,
class LO,
class GO,
class NO>
265void NonLinTPM<SC,LO,GO,NO>::reAssembleExtrapolation(BlockMultiVectorPtrArray_Type previousSolutions){
268 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Only Newton for NonLinTPM!");
272template<
class SC,
class LO,
class GO,
class NO>
273void NonLinTPM<SC,LO,GO,NO>::evalModelImpl(
const Thyra::ModelEvaluatorBase::InArgs<SC> &inArgs,
274 const Thyra::ModelEvaluatorBase::OutArgs<SC> &outArgs
277 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Not implemented! NonLinTPM evalModelImpl(...)");
281template<
class SC,
class LO,
class GO,
class NO>
282Teuchos::RCP<Thyra::LinearOpBase<SC> > NonLinTPM<SC,LO,GO,NO>::create_W_op()
const
284 Teuchos::RCP<Thyra::LinearOpBase<SC> > dummy;
288template<
class SC,
class LO,
class GO,
class NO>
289Teuchos::RCP<Thyra::PreconditionerBase<SC> > NonLinTPM<SC,LO,GO,NO>::create_W_prec()
const
291 Teuchos::RCP<Thyra::PreconditionerBase<SC> > dummy;
Definition NonLinearProblem_decl.hpp:24
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement.cpp:5