1#ifndef NAVIERSTOKESASSFE_def_hpp
2#define NAVIERSTOKESASSFE_def_hpp
3#include "NavierStokesAssFE_decl.hpp"
42template<
class SC,
class LO,
class GO,
class NO>
43NavierStokesAssFE<SC,LO,GO,NO>::NavierStokesAssFE(
const DomainConstPtr_Type &domainVelocity, std::string FETypeVelocity,
const DomainConstPtr_Type &domainPressure, std::string FETypePressure, ParameterListPtr_Type parameterList ):
46pressureIDsLoc(new vec_int_Type(2)),
52 this->nonLinearTolerance_ = this->parameterList_->sublist(
"Parameter").get(
"relNonLinTol",1.0e-6);
53 this->initNOXParameters();
55 this->addVariable( domainVelocity , FETypeVelocity ,
"u" , domainVelocity->getDimension());
56 this->addVariable( domainPressure , FETypePressure ,
"p" , 1);
57 this->dim_ = this->getDomain(0)->getDimension();
59 u_rep_ = Teuchos::rcp(
new MultiVector_Type( this->getDomain(0)->getMapVecFieldRepeated() ) );
61 p_rep_ = Teuchos::rcp(
new MultiVector_Type( this->getDomain(1)->getMapRepeated() ) );
63 if (parameterList->sublist(
"Parameter").get(
"Calculate Coefficients",
false)) {
64 vec2D_dbl_ptr_Type vectmpPointsPressure = domainPressure->getPointsUnique();
65 vec2D_dbl_Type::iterator it;
68 if (domainPressure->getDimension() == 2) {
69 it = find_if(vectmpPointsPressure->begin(), vectmpPointsPressure->end(),
70 [&] (
const std::vector<double>& a){
71 if (a.at(0) >= 0.15-1.e-12 && a.at(0) <= 0.15+1.e-12
72 && a.at(1) >= 0.2-1.e-12 && a.at(1) <= 0.2+1.e-12) {
80 if (it != vectmpPointsPressure->end()) {
81 front = distance(vectmpPointsPressure->begin(),it);
83 it = find_if(vectmpPointsPressure->begin(), vectmpPointsPressure->end(),
84 [&] (
const std::vector<double>& a){
85 if (a.at(0) >= 0.25-1.e-12 && a.at(0) <= 0.25+1.e-12
86 && a.at(1) >= 0.2-1.e-12 && a.at(1) <= 0.2+1.e-12) {
94 if (it != vectmpPointsPressure->end()) {
95 back = distance(vectmpPointsPressure->begin(),it);
97 pressureIDsLoc->at(0) = front;
98 pressureIDsLoc->at(1) = back;
100 else if(domainPressure->getDimension() == 3){
101#ifdef ASSERTS_WARNINGS
102 MYASSERT(
false,
"Not implemented to calc coefficients in 3D!");
109template<
class SC,
class LO,
class GO,
class NO>
110void NavierStokesAssFE<SC,LO,GO,NO>::info(){
112 this->infoNonlinProblem();
115template<
class SC,
class LO,
class GO,
class NO>
116void NavierStokesAssFE<SC,LO,GO,NO>::assemble( std::string type )
const{
120 std::cout <<
"-- Assembly Navier-Stokes ... " << std::endl;
122 assembleConstantMatrices();
125 std::cout <<
"done -- " << std::endl;
132template<
class SC,
class LO,
class GO,
class NO>
133void NavierStokesAssFE<SC,LO,GO,NO>::assembleConstantMatrices()
const{
136 std::cout <<
"-- Assembly constant matrices Navier-Stokes ... " << std::flush;
138 double viscosity = this->parameterList_->sublist(
"Parameter").get(
"Viscosity",1.);
139 double density = this->parameterList_->sublist(
"Parameter").get(
"Density",1.);
144 A_.reset(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
146 MapConstPtr_Type pressureMap;
147 if ( this->getDomain(1)->getFEType() ==
"P0" )
148 pressureMap = this->getDomain(1)->getElementMap();
150 pressureMap = this->getDomain(1)->getMapUnique();
152 if (this->system_.is_null())
153 this->system_.reset(
new BlockMatrix_Type(2));
155 if (this->residualVec_.is_null())
156 this->residualVec_.reset(
new BlockMultiVector_Type(2));
158 MatrixPtr_Type B(
new Matrix_Type( pressureMap, this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
159 MatrixPtr_Type BT(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(1)->getDimension() * this->getDomain(1)->getApproxEntriesPerRow() ) );
160 MatrixPtr_Type C(
new Matrix_Type( pressureMap,1));
163 this->system_->addBlock(A_,0,0);
164 this->system_->addBlock(BT,0,1);
165 this->system_->addBlock(B,1,0);
166 this->system_->addBlock(C,1,1);
168 this->feFactory_->assemblyNavierStokes(this->dim_, this->getDomain(0)->getFEType(), this->getDomain(1)->getFEType(), 2, this->dim_,1,u_rep_,p_rep_,this->system_,this->residualVec_,this->coeff_, this->parameterList_,
false,
"Jacobian",
true);
170 if ( !this->getFEType(0).compare(
"P1") ) {
171 C.reset(
new Matrix_Type( this->getDomain(1)->getMapUnique(), this->getDomain(1)->getApproxEntriesPerRow() ) );
172 this->feFactory_->assemblyBDStabilization( this->dim_,
"P1", C,
true);
174 C->scale( -1. / ( viscosity * density ) );
175 C->fillComplete( pressureMap, pressureMap );
177 this->system_->addBlock( C, 1, 1 );
184 if ( !this->parameterList_->sublist(
"General").get(
"Preconditioner Method",
"Monolithic").compare(
"Teko") ) {
185 if (!this->parameterList_->sublist(
"General").get(
"Assemble Velocity Mass",
false)) {
186 MatrixPtr_Type Mvelocity(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getApproxEntriesPerRow() ) );
188 this->feFactory_->assemblyMass( this->dim_, this->domain_FEType_vec_.at(0),
"Vector", Mvelocity,
true );
190 this->getPreconditionerConst()->setVelocityMassMatrix( Mvelocity );
192 std::cout <<
"\nVelocity mass matrix for LSC block preconditioner is assembled." << std::endl;
195 std::cout <<
"\nVelocity mass matrix for LSC block preconditioner not assembled." << std::endl;
199 std::string precType = this->parameterList_->sublist(
"General").get(
"Preconditioner Method",
"Monolithic");
200 if ( precType ==
"Diagonal" || precType ==
"Triangular" ) {
201 MatrixPtr_Type Mpressure(
new Matrix_Type( this->getDomain(1)->getMapUnique(), this->getDomain(1)->getApproxEntriesPerRow() ) );
203 this->feFactory_->assemblyMass( this->dim_, this->domain_FEType_vec_.at(1),
"Scalar", Mpressure,
true );
204 SC kinVisco = this->parameterList_->sublist(
"Parameter").get(
"Viscosity",1.);
205 Mpressure->scale(-1./kinVisco);
206 this->getPreconditionerConst()->setPressureMassMatrix( Mpressure );
209 std::cout <<
" Call Reassemble FixedPoint and Newton to allocate the Matrix pattern " << std::endl;
212 this->reAssemble(
"Newton");
215 std::cout <<
"done -- " << std::endl;
220template<
class SC,
class LO,
class GO,
class NO>
221void NavierStokesAssFE<SC,LO,GO,NO>::reAssemble( MatrixPtr_Type& massmatrix, std::string type )
const
228template<
class SC,
class LO,
class GO,
class NO>
229void NavierStokesAssFE<SC,LO,GO,NO>::reAssemble(std::string type)
const {
233 std::cout <<
"-- Reassembly Navier-Stokes ("<< type <<
") ... " << std::flush;
235 double density = this->parameterList_->sublist(
"Parameter").get(
"Density",1.);
237 MatrixPtr_Type ANW = Teuchos::rcp(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
239 MultiVectorConstPtr_Type u = this->solution_->getBlock(0);
240 u_rep_->importFromVector(u,
true);
242 MultiVectorConstPtr_Type p = this->solution_->getBlock(1);
243 p_rep_->importFromVector(p,
true);
248 this->system_->addBlock(ANW,0,0);
250 this->feFactory_->assemblyNavierStokes(this->dim_, this->getDomain(0)->getFEType(), this->getDomain(1)->getFEType(), 2, this->dim_,1,u_rep_,p_rep_,this->system_, this->residualVec_,this->coeff_,this->parameterList_,
true,
"FixedPoint",
true);
251 this->feFactory_->assemblyNavierStokes(this->dim_, this->getDomain(0)->getFEType(), this->getDomain(1)->getFEType(), 2, this->dim_,1,u_rep_,p_rep_,this->system_, this->residualVec_,this->coeff_,this->parameterList_,
true,
"Rhs",
true);
254 else if (type==
"FixedPoint" ) {
256 this->system_->addBlock(ANW,0,0);
257 this->feFactory_->assemblyNavierStokes(this->dim_, this->getDomain(0)->getFEType(), this->getDomain(1)->getFEType(), 2, this->dim_,1,u_rep_,p_rep_,this->system_, this->residualVec_,this->coeff_,this->parameterList_,
true,
"FixedPoint",
true);
259 else if(type==
"Newton"){
261 this->system_->addBlock(ANW,0,0);
262 this->feFactory_->assemblyNavierStokes(this->dim_, this->getDomain(0)->getFEType(), this->getDomain(1)->getFEType(), 2, this->dim_,1,u_rep_,p_rep_,this->system_,this->residualVec_, this->coeff_,this->parameterList_,
true,
"Jacobian",
true);
266 this->system_->addBlock(ANW,0,0);
269 std::cout <<
"done -- " << std::endl;
275template<
class SC,
class LO,
class GO,
class NO>
276void NavierStokesAssFE<SC,LO,GO,NO>::calculateNonLinResidualVec(std::string type,
double time)
const{
279 this->reAssemble(
"Rhs");
282 if(this->getDomain(0)->getFEType() ==
"P1"){
284 MultiVectorPtr_Type residualPressureTmp = Teuchos::rcp(
new MultiVector_Type( this->getDomain(1)->getMapUnique() ));
286 this->system_->getBlock(1,1)->apply( *(this->solution_->getBlock(1)), *residualPressureTmp);
288 this->residualVec_->getBlockNonConst(1)->update(1.,*residualPressureTmp,1.);
300 if (!type.compare(
"standard")){
301 this->residualVec_->update(-1.,*this->rhs_,1.);
305 this->bcFactory_->setVectorMinusBC( this->residualVec_, this->solution_, time );
308 else if(!type.compare(
"reverse")){
309 this->residualVec_->update(1.,*this->rhs_,-1.);
313 this->bcFactory_->setBCMinusVector( this->residualVec_, this->solution_, time );
320template<
class SC,
class LO,
class GO,
class NO>
321void NavierStokesAssFE<SC,LO,GO,NO>::evalModelImpl(
const Thyra::ModelEvaluatorBase::InArgs<SC> &inArgs,
322 const Thyra::ModelEvaluatorBase::OutArgs<SC> &outArgs
325 std::string type = this->parameterList_->sublist(
"General").get(
"Preconditioner Method",
"Monolithic");
326 if ( !type.compare(
"Monolithic"))
327 evalModelImplMonolithic( inArgs, outArgs );
328 else if ( !type.compare(
"Teko")){
330 evalModelImplBlock( inArgs, outArgs );
332 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Teko not found! Build Trilinos with Teko.");
336 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Unkown preconditioner/solver type.");
346template<
class SC,
class LO,
class GO,
class NO>
347void NavierStokesAssFE<SC,LO,GO,NO>::evalModelImplMonolithic(
const Thyra::ModelEvaluatorBase::InArgs<SC> &inArgs,
348 const Thyra::ModelEvaluatorBase::OutArgs<SC> &outArgs )
const
354 using Teuchos::rcp_dynamic_cast;
355 using Teuchos::rcp_const_cast;
356 using Teuchos::ArrayView;
357 using Teuchos::Array;
358 RCP<Teuchos::FancyOStream> fancy = Teuchos::fancyOStream(Teuchos::rcpFromRef(std::cout));
359 TEUCHOS_TEST_FOR_EXCEPTION( inArgs.get_x().is_null(), std::logic_error,
"inArgs.get_x() is null.");
361 RCP< const Thyra::VectorBase< SC > > vecThyra = inArgs.get_x();
362 RCP<Teuchos::FancyOStream> out = Teuchos::VerboseObjectBase::getDefaultOStream();
364 RCP< Thyra::VectorBase< SC > > vecThyraNonConst = rcp_const_cast<Thyra::VectorBase< SC > >(vecThyra);
366 this->solution_->fromThyraMultiVector(vecThyraNonConst);
368 const RCP<Thyra::MultiVectorBase<SC> > f_out = outArgs.get_f();
369 const RCP<Thyra::LinearOpBase<SC> > W_out = outArgs.get_W_op();
370 const RCP<Thyra::PreconditionerBase<SC> > W_prec_out = outArgs.get_W_prec();
372 typedef Thyra::TpetraOperatorVectorExtraction<SC,LO,GO,NO> tpetra_extract;
373 typedef Tpetra::CrsMatrix<SC,LO,GO,NO> TpetraMatrix_Type;
374 typedef RCP<TpetraMatrix_Type> TpetraMatrixPtr_Type;
375 typedef RCP<const TpetraMatrix_Type> TpetraMatrixConstPtr_Type;
377 const bool fill_f = nonnull(f_out);
378 const bool fill_W = nonnull(W_out);
379 const bool fill_W_prec = nonnull(W_prec_out);
382 if ( fill_f || fill_W || fill_W_prec ) {
389 this->calculateNonLinResidualVec(
"standard");
393 Teuchos::RCP<Thyra::MultiVectorBase<SC> > f_thyra = this->getResidualVector()->getThyraMultiVector();
394 f_out->assign(*f_thyra);
396 TpetraMatrixPtr_Type W;
398 this->reAssemble(
"Newton");
400 this->setBoundariesSystem();
402 Teuchos::RCP<TpetraOp_Type> W_tpetra = tpetra_extract::getTpetraOperator(W_out);
403 Teuchos::RCP<TpetraMatrix_Type> W_tpetraMat = Teuchos::rcp_dynamic_cast<TpetraMatrix_Type>(W_tpetra);
405 TpetraMatrixConstPtr_Type W_systemTpetra = this->getSystem()->getMergedMatrix()->getTpetraMatrix();
406 TpetraMatrixPtr_Type W_systemTpetraNonConst = rcp_const_cast<TpetraMatrix_Type>(W_systemTpetra);
411 Teuchos::RCP<TpetraMatrix_Type> tpetraMatTpetra = W_systemTpetraNonConst;
412 W_tpetraMat->resumeFill();
414 for (
auto i=0; i<tpetraMatTpetra->getMap()->getLocalNumElements(); i++) {
415 typename Tpetra::CrsMatrix<SC,LO,GO,NO>::local_inds_host_view_type indices;
416 typename Tpetra::CrsMatrix<SC,LO,GO,NO>::values_host_view_type values;
417 tpetraMatTpetra->getLocalRowView( i, indices, values);
418 W_tpetraMat->replaceLocalValues( i, indices, values);
420 W_tpetraMat->fillComplete();
423 this->setupPreconditioner(
"Monolithic" );
428 std::string levelCombination = this->parameterList_->sublist(
"ThyraPreconditioner").sublist(
"Preconditioner Types").sublist(
"FROSch").get(
"Level Combination",
"Additive");
429 if (!levelCombination.compare(
"Multiplicative")) {
430 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Multiplicative Level Combination is not supported for NOX.");
454template<
class SC,
class LO,
class GO,
class NO>
455void NavierStokesAssFE<SC,LO,GO,NO>::evalModelImplBlock(
const Thyra::ModelEvaluatorBase::InArgs<SC> &inArgs,
456 const Thyra::ModelEvaluatorBase::OutArgs<SC> &outArgs )
const
462 using Teuchos::rcp_dynamic_cast;
463 using Teuchos::rcp_const_cast;
464 using Teuchos::ArrayView;
465 using Teuchos::Array;
467 RCP<Teuchos::FancyOStream> fancy = Teuchos::fancyOStream(Teuchos::rcpFromRef(std::cout));
468 TEUCHOS_TEST_FOR_EXCEPTION( inArgs.get_x().is_null(), std::logic_error,
"inArgs.get_x() is null.");
470 RCP< const Thyra::VectorBase< SC > > vecThyra = inArgs.get_x();
471 RCP<Teuchos::FancyOStream> out = Teuchos::VerboseObjectBase::getDefaultOStream();
473 RCP< Thyra::VectorBase< SC > > vecThyraNonConst = rcp_const_cast<Thyra::VectorBase< SC > >(vecThyra);
475 RCP< Thyra::ProductVectorBase< SC > > vecThyraBlock = rcp_dynamic_cast<Thyra::ProductVectorBase< SC > > (vecThyraNonConst);
477 this->solution_->getBlockNonConst(0)->fromThyraMultiVector( vecThyraBlock->getNonconstVectorBlock(0) );
478 this->solution_->getBlockNonConst(1)->fromThyraMultiVector( vecThyraBlock->getNonconstVectorBlock(1) );
480 const RCP<Thyra::MultiVectorBase<SC> > f_out = outArgs.get_f();
481 const RCP<Thyra::LinearOpBase<SC> > W_out = outArgs.get_W_op();
482 const RCP<Thyra::PreconditionerBase<SC> > W_prec_out = outArgs.get_W_prec();
484 typedef Thyra::TpetraOperatorVectorExtraction<SC,LO,GO,NO> tpetra_extract;
485 typedef Tpetra::CrsMatrix<SC,LO,GO,NO> TpetraMatrix_Type;
486 typedef RCP<TpetraMatrix_Type> TpetraMatrixPtr_Type;
487 typedef RCP<const TpetraMatrix_Type> TpetraMatrixConstPtr_Type;
489 const bool fill_f = nonnull(f_out);
490 const bool fill_W = nonnull(W_out);
491 const bool fill_W_prec = nonnull(W_prec_out);
493 if ( fill_f || fill_W || fill_W_prec ) {
500 this->calculateNonLinResidualVec(
"standard");
502 Teko::MultiVector f0;
503 Teko::MultiVector f1;
504 f0 = this->getResidualVector()->getBlockNonConst(0)->getThyraMultiVector();
505 f1 = this->getResidualVector()->getBlockNonConst(1)->getThyraMultiVector();
507 std::vector<Teko::MultiVector> f_vec; f_vec.push_back(f0); f_vec.push_back(f1);
509 Teko::MultiVector f = Teko::buildBlockedMultiVector(f_vec);
514 TpetraMatrixPtr_Type W;
517 typedef Tpetra::CrsMatrix<SC,LO,GO,NO> TpetraCrsMatrix;
519 this->reAssemble(
"Newton");
521 this->setBoundariesSystem();
523 RCP<ThyraBlockOp_Type> W_blocks = rcp_dynamic_cast<ThyraBlockOp_Type>(W_out);
524 RCP<const ThyraOp_Type> W_block00 = W_blocks->getBlock(0,0);
525 RCP<ThyraOp_Type> W_block00NonConst = rcp_const_cast<ThyraOp_Type>( W_block00 );
526 RCP<TpetraOp_Type> W_tpetra = tpetra_extract::getTpetraOperator( W_block00NonConst );
528 RCP<TpetraMatrix_Type> W_tpetraMat = Teuchos::rcp_dynamic_cast<TpetraMatrix_Type>(W_tpetra);
530 TpetraMatrixConstPtr_Type W_matrixTpetra = this->getSystem()->getBlock(0,0)->getTpetraMatrix();
531 TpetraMatrixPtr_Type W_matrixTpetraNonConst = rcp_const_cast<TpetraMatrix_Type>(W_matrixTpetra);
532 RCP<TpetraMatrix_Type> tpetraMatTpetra = W_matrixTpetraNonConst;
534 W_tpetraMat->resumeFill();
536 for (
auto i=0; i<tpetraMatTpetra->getMap()->getLocalNumElements(); i++) {
537 typename Tpetra::CrsMatrix<SC,LO,GO,NO>::local_inds_host_view_type indices;
538 typename Tpetra::CrsMatrix<SC,LO,GO,NO>::values_host_view_type values;
539 tpetraMatTpetra->getLocalRowView( i, indices, values);
540 W_tpetraMat->replaceLocalValues( i, indices, values);
542 W_tpetraMat->fillComplete();
547 if (stokesTekoPrecUsed_){
548 this->setupPreconditioner(
"Teko" );
551 stokesTekoPrecUsed_ =
true;
556 ParameterListPtr_Type tmpSubList = sublist( sublist( sublist( sublist( this->parameterList_,
"Teko Parameters" ) ,
"Preconditioner Types" ) ,
"Teko" ) ,
"Inverse Factory Library" );
558 std::string levelCombination1 = tmpSubList->sublist(
"FROSch-Velocity" ).get(
"Level Combination",
"Additive");
559 std::string levelCombination2 = tmpSubList->sublist(
"FROSch-Pressure" ).get(
"Level Combination",
"Additive");
561 if ( !levelCombination1.compare(
"Multiplicative") || !levelCombination2.compare(
"Multiplicative") ) {
563 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Multiplicative Level Combination is not supported for NOX.");
564 ParameterListPtr_Type solverPList = this->getLinearSolverBuilder()->getNonconstParameterList();
579template<
class SC,
class LO,
class GO,
class NO>
588 this->system_->apply( *this->solution_, *this->residualVec_ );
591 if (!type.compare(
"standard")){
592 this->residualVec_->update(-1.,*this->rhs_,1.);
594 this->residualVec_->update(-1.,*this->
sourceTerm_,1.);
596 else if(!type.compare(
"reverse")){
597 this->residualVec_->update(1.,*this->rhs_,-1.);
599 this->residualVec_->update(1.,*this->
sourceTerm_,1.);
603 this->bcFactory_->setBCMinusVector( this->residualVec_, this->solution_, time );
610template<
class SC,
class LO,
class GO,
class NO>
611Teuchos::RCP<Thyra::LinearOpBase<SC> > NavierStokesAssFE<SC,LO,GO,NO>::create_W_op()
const
616 std::string type = this->parameterList_->sublist(
"General").get(
"Preconditioner Method",
"Monolithic");
617 if ( !type.compare(
"Monolithic"))
618 return create_W_op_Monolithic( );
619 else if ( !type.compare(
"Teko")){
621 return create_W_op_Block( );
623 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Teko not found! Build Trilinos with Teko.");
627 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Unkown preconditioner/solver type.");
630template<
class SC,
class LO,
class GO,
class NO>
631Teuchos::RCP<Thyra::LinearOpBase<SC> > NavierStokesAssFE<SC,LO,GO,NO>::create_W_op_Monolithic()
const
633 Teuchos::RCP<const Thyra::LinearOpBase<SC> > W_opConst = this->system_->getThyraLinOp();
634 Teuchos::RCP<Thyra::LinearOpBase<SC> > W_op = Teuchos::rcp_const_cast<Thyra::LinearOpBase<SC> >(W_opConst);
639template<
class SC,
class LO,
class GO,
class NO>
640Teuchos::RCP<Thyra::LinearOpBase<SC> > NavierStokesAssFE<SC,LO,GO,NO>::create_W_op_Block()
const
643 Teko::LinearOp thyraF = this->system_->getBlock(0,0)->getThyraLinOp();
644 Teko::LinearOp thyraBT = this->system_->getBlock(0,1)->getThyraLinOp();
645 Teko::LinearOp thyraB = this->system_->getBlock(1,0)->getThyraLinOp();
647 if (!this->system_->blockExists(1,1)){
648 MatrixPtr_Type dummy = Teuchos::rcp(
new Matrix_Type( this->system_->getBlock(1,0)->getMap(), 1 ) );
649 dummy->fillComplete();
650 this->system_->addBlock( dummy, 1, 1 );
653 Teko::LinearOp thyraC = this->system_->getBlock(1,1)->getThyraLinOp();
655 Teuchos::RCP<const Thyra::LinearOpBase<SC> > W_opConst = Thyra::block2x2(thyraF,thyraBT,thyraB,thyraC);
656 Teuchos::RCP<Thyra::LinearOpBase<SC> > W_op = Teuchos::rcp_const_cast<Thyra::LinearOpBase<SC> >(W_opConst);
661template<
class SC,
class LO,
class GO,
class NO>
662Teuchos::RCP<Thyra::PreconditionerBase<SC> > NavierStokesAssFE<SC,LO,GO,NO>::create_W_prec()
const
665 this->initializeSolverBuilder();
667 std::string type = this->parameterList_->sublist(
"General").get(
"Preconditioner Method",
"Monolithic");
668 this->setBoundariesSystem();
670 if (!type.compare(
"Teko")) {
671 this->setupPreconditioner( type );
672 stokesTekoPrecUsed_ =
false;
675 this->setupPreconditioner( type );
678 Teuchos::RCP<const Thyra::PreconditionerBase<SC> > thyraPrec = this->getPreconditionerConst()->getThyraPrecConst();
679 Teuchos::RCP<Thyra::PreconditionerBase<SC> > thyraPrecNonConst = Teuchos::rcp_const_cast<Thyra::PreconditionerBase<SC> >(thyraPrec);
681 return thyraPrecNonConst;
721template<
class SC,
class LO,
class GO,
class NO>
722void NavierStokesAssFE<SC,LO,GO,NO>::reAssembleExtrapolation(BlockMultiVectorPtrArray_Type previousSolutions){
725 std::cout <<
"-- Reassembly Navier-Stokes (Extrapolation) ... " << std::flush;
728 double density = this->parameterList_->sublist(
"Parameter").get(
"Density",1.);
730 if (previousSolutions.size()>=2) {
732 MultiVectorPtr_Type extrapolatedVector = Teuchos::rcp(
new MultiVector_Type( previousSolutions[0]->getBlock(0) ) );
734 extrapolatedVector->update( -1., *previousSolutions[1]->getBlock(0), 2. );
736 u_rep_->importFromVector(extrapolatedVector,
true);
738 else if(previousSolutions.size()==1){
739 MultiVectorConstPtr_Type u = previousSolutions[0]->getBlock(0);
740 u_rep_->importFromVector(u,
true);
742 else if (previousSolutions.size()==0){
743 MultiVectorConstPtr_Type u = this->solution_->getBlock(0);
744 u_rep_->importFromVector(u,
true);
747 MatrixPtr_Type ANW = Teuchos::rcp(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
749 MatrixPtr_Type N = Teuchos::rcp(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
750 this->feFactory_->assemblyAdvectionVecField( this->dim_, this->domain_FEType_vec_.at(0), N, u_rep_,
true );
754 N->fillComplete( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getMapVecFieldUnique());
756 A_->addMatrix(1.,ANW,0.);
757 N->addMatrix(1.,ANW,1.);
759 ANW->fillComplete( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getMapVecFieldUnique() );
761 this->system_->addBlock( ANW, 0, 0 );
764 std::cout <<
"done -- " << std::endl;
773template<
class SC,
class LO,
class GO,
class NO>
774void NavierStokesAssFE<SC,LO,GO,NO>::computeSteadyPostprocessingViscosity_Solution() {
777 MultiVectorConstPtr_Type u = this->solution_->getBlock(0);
778 u_rep_->importFromVector(u,
true);
780 MultiVectorConstPtr_Type p = this->solution_->getBlock(1);
781 p_rep_->importFromVector(p,
true);
786 viscosity_element_ = Teuchos::rcp(
new MultiVector_Type( this->getDomain(0)->getElementMap() ) );
787 this->feFactory_->computeSteadyViscosityFE_CM(this->dim_, this->getDomain(0)->getFEType(), this->getDomain(1)->getFEType(), this->dim_,1,u_rep_,p_rep_,this->parameterList_);
789 Teuchos::RCP<const MultiVector<SC,LO,GO,NO>> exportSolutionViscosityAssFE = this->feFactory_->const_output_fields->getBlock(0);
790 viscosity_element_->importFromVector(exportSolutionViscosityAssFE,
true);
void calculateNonLinResidualVecWithMeshVelo(std::string type, double time, MultiVectorPtr_Type u_minus_w, MatrixPtr_Type P) const
Block Approach for Nonlinear Solver NOX. Input. Includes calculation of the residual vector and updat...
Definition NavierStokesAssFE_def.hpp:580
Definition NonLinearProblem_decl.hpp:24
BlockMultiVectorPtr_Type sourceTerm_
Definition Problem_decl.hpp:237
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement.cpp:5