95 [&] (
const std::vector<double>& a){
96 if (a.at(0) >= 0.15-1.e-12 && a.at(0) <= 0.15+1.e-12
97 && a.at(1) >= 0.2-1.e-12 && a.at(1) <= 0.2+1.e-12) {
105 if (it != vectmpPointsPressure->end()) {
106 front = distance(vectmpPointsPressure->begin(),it);
108 it = find_if(vectmpPointsPressure->begin(), vectmpPointsPressure->end(),
109 [&] (
const std::vector<double>& a){
110 if (a.at(0) >= 0.25-1.e-12 && a.at(0) <= 0.25+1.e-12
111 && a.at(1) >= 0.2-1.e-12 && a.at(1) <= 0.2+1.e-12) {
119 if (it != vectmpPointsPressure->end()) {
120 back = distance(vectmpPointsPressure->begin(),it);
122 pressureIDsLoc->at(0) = front;
123 pressureIDsLoc->at(1) = back;
125 else if(domainPressure->getDimension() == 3){
126#ifdef ASSERTS_WARNINGS
127 MYASSERT(
false,
"Not implemented to calc coefficients in 3D!");
132 if(!this->parameterList_->sublist(
"General").get(
"Preconditioner Method",
"Diagonal").compare(
"PCD")
133 || !this->parameterList_->sublist(
"General").get(
"Preconditioner Method",
"Diagonal").compare(
"LSC")
134 || !this->parameterList_->sublist(
"Teko Parameters").sublist(
"Preconditioner Types").sublist(
"Teko").get(
"Inverse Type",
"SIMPLE").compare(
"PCD")
135 || !this->parameterList_->sublist(
"Teko Parameters").sublist(
"Preconditioner Types").sublist(
"Teko").get(
"Inverse Type",
"SIMPLE").compare(
"LSC-Pressure-Laplace") )
138 int flagOutlet = this->parameterList_->sublist(
"General").get(
"Flag Outlet Fluid", 3);
139 int flagInterface = this->parameterList_->sublist(
"General").get(
"Flag Interface", 6);
141 this->bcFactoryPCD_.reset(
new BCBuilder<SC,LO,GO,NO>( ));
142 this->bcFactoryPCD_->addBC(zeroDirichletBC, flagOutlet, 0, Teuchos::rcp_const_cast<Domain_Type>( domainPressure ),
"Dirichlet", 1);
149 if(this->parameterList_->sublist(
"General").get(
"Augmented Lagrange",
false))
150 augmentedLagrange_ =
true;
153 NNZ_A_.reset(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
154 establishNNZPattern();
158template<
class SC,
class LO,
class GO,
class NO>
159void NavierStokes<SC,LO,GO,NO>::info(){
161 this->infoNonlinProblem();
164template<
class SC,
class LO,
class GO,
class NO>
169 std::cout <<
"-- Assembly Navier-Stokes ... " << std::endl;
171 assembleConstantMatrices();
174 std::cout <<
"done -- " << std::endl;
176 else if(type==
"UpdateTime"){
177 this->newtonStep_ = 0;
180 else if(type ==
"UpdateConvectionDiffusionOperator")
187template<
class SC,
class LO,
class GO,
class NO>
188void NavierStokes<SC,LO,GO,NO>::assembleConstantMatrices()
const{
191 std::cout <<
"-- Assembly constant matrices Navier-Stokes ... " << std::flush;
193 double viscosity = this->parameterList_->sublist(
"Parameter").get(
"Viscosity",1.);
194 double density = this->parameterList_->sublist(
"Parameter").get(
"Density",1.);
199 A_.reset(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
201 if ( this->parameterList_->sublist(
"Parameter").get(
"Symmetric gradient",
false) )
202 this->feFactory_->assemblyStress(this->dim_, this->domain_FEType_vec_.at(0), A_, OneFunction, dummy,
true);
204 this->feFactory_->assemblyLaplaceVecField(this->dim_, this->domain_FEType_vec_.at(0), 2, A_,
true);
208 A_->scale(viscosity);
211 A_->fillComplete( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getMapVecFieldUnique());
213 if (this->system_.is_null())
214 this->system_.reset(
new BlockMatrix_Type(2));
216 this->system_->addBlock( A_, 0, 0 );
217 assembleDivAndStab();
221 if(this->parameterList_->sublist(
"Parameter").get(
"Use Pressure Projection",
false) && (!this->getFEType(0).compare(
"P2") || (!this->getFEType(0).compare(
"Q2") && !this->getFEType(1).compare(
"Q1"))) && !this->parameterList_->sublist(
"General").get(
"Preconditioner Method",
"Monolithic").compare(
"Monolithic")){
223 BlockMultiVectorPtr_Type projection(
new BlockMultiVector_Type (2));
225 MultiVectorPtr_Type P(
new MultiVector_Type( this->getDomain(1)->getMapUnique(), 1 ) );
227 this->feFactory_->assemblyPressureMeanValue( this->dim_,this->getFEType(1),P) ;
230 MultiVectorPtr_Type vel0(
new MultiVector_Type( this->getDomain(0)->getMapVecFieldUnique(), 1 ) );
234 projection->addBlock(vel0,0);
235 projection->addBlock(P,1);
238 this->getPreconditionerConst()->setPressureProjection( projection );
241 std::cout <<
"\n 'Use pressure correction' was set to 'true'. This requires a version of Trilinos that includes pressure correction in the FROSch_OverlappingOperator!!" << std::endl;
246 if ( !this->parameterList_->sublist(
"General").get(
"Preconditioner Method",
"Monolithic").compare(
"Teko")
247 || !this->parameterList_->sublist(
"General").get(
"Preconditioner Method",
"Diagonal").compare(
"PCD")
248 || !this->parameterList_->sublist(
"General").get(
"Preconditioner Method",
"Diagonal").compare(
"LSC")) {
255 if (!this->parameterList_->sublist(
"Teko Parameters").sublist(
"Preconditioner Types").sublist(
"Teko").get(
"Inverse Type",
"None").compare(
"LSC")
256 || !this->parameterList_->sublist(
"Teko Parameters").sublist(
"Preconditioner Types").sublist(
"Teko").get(
"Inverse Type",
"None").compare(
"LSC-Pressure-Laplace")
257 || !this->parameterList_->sublist(
"Teko Parameters").sublist(
"Preconditioner Types").sublist(
"Teko").get(
"Inverse Type",
"None").compare(
"SIMPLE")
258 || !this->parameterList_->sublist(
"General").get(
"Preconditioner Method",
"Diagonal").compare(
"LSC")) {
260 MatrixPtr_Type Mvelocity(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getApproxEntriesPerRow() ) );
262 if(this->parameterList_->sublist(
"Parameter").get(
"BFBT",
false)){
264 std::cout <<
"\n Setting M_u to be the identity Matrix to use BFBT preconditioner " << std::endl;
266 this->feFactory_->assemblyIdentity( Mvelocity );
269 this->feFactory_->assemblyMass( this->dim_, this->domain_FEType_vec_.at(0),
"Vector", Mvelocity,
true );
272 this->getPreconditionerConst()->setVelocityMassMatrix( Mvelocity );
275 std::cout <<
"\n Velocity mass matrix for LSC block preconditioner is assembled and used for the preconditioner." << std::endl;
278 if(!this->parameterList_->sublist(
"Teko Parameters").sublist(
"Preconditioner Types").sublist(
"Teko").get(
"Inverse Type",
"SIMPLE").compare(
"LSC-Pressure-Laplace")
279 || !this->parameterList_->sublist(
"General").get(
"Preconditioner Method",
"Diagonal").compare(
"LSC"))
281 MatrixPtr_Type Lp(
new Matrix_Type( this->getDomain(1)->getMapUnique(), this->getDomain(1)->getApproxEntriesPerRow() ) );
282 this->feFactory_->assemblyLaplace( this->dim_, this->domain_FEType_vec_.at(1), 2, Lp,
true );
284 BlockMatrixPtr_Type bcBlockMatrix(
new BlockMatrix_Type (1));
285 bcBlockMatrix->addBlock(Lp,0,0);
286 bcFactoryPCD_->setSystemScaled(bcBlockMatrix);
288 this->getPreconditionerConst()->setPressureLaplaceMatrix( Lp);
297 else if(!this->parameterList_->sublist(
"Teko Parameters").sublist(
"Preconditioner Types").sublist(
"Teko").get(
"Inverse Type",
"SIMPLE").compare(
"PCD")
298 || !this->parameterList_->sublist(
"General").get(
"Preconditioner Method",
"Diagonal").compare(
"PCD") ){
302 MatrixPtr_Type Mvelocity(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getApproxEntriesPerRow() ) );
303 this->feFactory_->assemblyMass( this->dim_, this->domain_FEType_vec_.at(0),
"Vector", Mvelocity,
true );
304 this->getPreconditionerConst()->setVelocityMassMatrix( Mvelocity );
309 MatrixPtr_Type Mpressure(
new Matrix_Type( this->getDomain(1)->getMapUnique(), this->getDomain(1)->getApproxEntriesPerRow() ) );
310 this->feFactory_->assemblyMass( this->dim_, this->domain_FEType_vec_.at(1),
"Scalar", Mpressure,
true );
312 this->getPreconditionerConst()->setPressureMassMatrix( Mpressure );
317 SC density = this->parameterList_->sublist(
"Parameter").get(
"Density",1.);
319 MatrixPtr_Type Lp(
new Matrix_Type( this->getDomain(1)->getMapUnique(), this->getDomain(1)->getApproxEntriesPerRow() ) );
320 this->feFactory_->assemblyLaplace( this->dim_, this->domain_FEType_vec_.at(1), 2, Lp,
true );
324 Ap_.reset(
new Matrix_Type(Lp));
327 BlockMatrixPtr_Type bcBlockMatrix(
new BlockMatrix_Type (1));
328 bcBlockMatrix->addBlock(Lp,0,0);
330 bcFactoryPCD_->setSystemScaled(bcBlockMatrix);
331 this->getPreconditionerConst()->setPressureLaplaceMatrix( Lp);
336 MatrixPtr_Type Kp(
new Matrix_Type( this->getDomain(1)->getMapUnique(), this->getDomain(1)->getApproxEntriesPerRow() ) );
339 MatrixPtr_Type AdvPressure(
new Matrix_Type( this->getDomain(1)->getMapUnique(), this->getDomain(1)->getApproxEntriesPerRow() ) );
340 this->feFactory_->assemblyAdvectionVecFieldScalar( this->dim_, this->domain_FEType_vec_.at(1), this->domain_FEType_vec_.at(0),AdvPressure, u_rep_,
true );
343 MatrixPtr_Type Ap2(
new Matrix_Type( Ap_) );
345 SC kinVisco = this->parameterList_->sublist(
"Parameter").get(
"Viscosity",1.);
348 Ap2->scale(kinVisco);
353 MatrixPtr_Type K_robin(
new Matrix_Type( this->getDomain(1)->getMapUnique(), this->getDomain(1)->getDimension() * this->getDomain(1)->getApproxEntriesPerRow()*2 ) );
354 int flagInlet =this->parameterList_->sublist(
"General").get(
"Flag Inlet Fluid", 2);
356 vec_dbl_Type funcParameter(1,flagInlet);
357 funcParameter.push_back(0.0);
358 this->feFactory_->assemblySurfaceRobinBC(this->dim_, this->getDomain(1)->getFEType(),this->getDomain(0)->getFEType(),u_rep_,K_robin, funcParameter, dummyFuncRhs,this->parameterList_);
359 K_robin->addMatrix(-1.,Kp,1.);
362 Ap2->addMatrix(1.,Kp,1.);
363 AdvPressure->addMatrix(1.,Kp,1.);
368 bcBlockMatrix->addBlock(Kp,0,0);
369 bcFactoryPCD_->setSystemScaled(bcBlockMatrix);
372 this->getPreconditionerConst()->setPCDOperator( Kp );
378 std::string precType = this->parameterList_->sublist(
"General").get(
"Preconditioner Method",
"Monolithic");
379 if ( precType ==
"Diagonal" || precType ==
"Triangular" ) {
380 MatrixPtr_Type Mpressure(
new Matrix_Type( this->getDomain(1)->getMapUnique(), this->getDomain(1)->getApproxEntriesPerRow() ) );
382 this->feFactory_->assemblyMass( this->dim_, this->domain_FEType_vec_.at(1),
"Scalar", Mpressure,
true );
383 SC kinVisco = this->parameterList_->sublist(
"Parameter").get(
"Viscosity",1.);
385 if(augmentedLagrange_){
386 double gamma = this->parameterList_->sublist(
"General").get(
"Gamma",1.0);
387 Mpressure->scale(-1./(kinVisco+gamma));
390 Mpressure->scale(-1./kinVisco);
392 this->getPreconditionerConst()->setPressureMassMatrix( Mpressure );
396 std::cout <<
" Allocate the Matrix pattern " << std::endl;
399 MatrixPtr_Type A_withNNZ = Teuchos::rcp(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
400 A_->addMatrix(1.,A_withNNZ,0.);
401 NNZ_A_->addMatrix(1.,A_withNNZ,1.);
403 A_withNNZ->fillComplete( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getMapVecFieldUnique());
404 this->system_->addBlock( A_withNNZ, 0, 0 );
407 std::cout <<
"done -- " << std::endl;
412template<
class SC,
class LO,
class GO,
class NO>
415 if ( !this->parameterList_->sublist(
"Teko Parameters").sublist(
"Preconditioner Types").sublist(
"Teko").get(
"Inverse Type",
"SIMPLE").compare(
"PCD")
416 || !this->parameterList_->sublist(
"General").get(
"Preconditioner Method",
"Monolithic").compare(
"PCD"))
418 std::cout <<
"NavierStokes<SC,LO,GO,NO>::updateConvectionDiffusionOperator() set to TRUE" << std::endl;
419 NAVIER_STOKES_START(ReassemblePCD,
" Reassembling Matrix for PCD ");
421 MultiVectorConstPtr_Type u = this->solution_->getBlock(0);
422 u_rep_->importFromVector(u,
true);
425 MatrixPtr_Type Fp(
new Matrix_Type( this->getDomain(1)->getMapUnique(), this->getDomain(1)->getApproxEntriesPerRow() ) );
428 MatrixPtr_Type AdvPressure(
new Matrix_Type( this->getDomain(1)->getMapUnique(), this->getDomain(1)->getApproxEntriesPerRow() ) );
429 this->feFactory_->assemblyAdvectionVecFieldScalar( this->dim_, this->domain_FEType_vec_.at(1), this->domain_FEType_vec_.at(0),AdvPressure, u_rep_,
true );
432 MatrixPtr_Type Ap2(
new Matrix_Type( Ap_ ) );
433 SC kinVisco = this->parameterList_->sublist(
"Parameter").get(
"Viscosity",1.);
434 SC density = this->parameterList_->sublist(
"Parameter").get(
"Density",1.);
437 Ap2->scale(kinVisco);
442 MatrixPtr_Type Kext(
new Matrix_Type( this->getDomain(1)->getMapUnique(), this->getDomain(1)->getDimension() * this->getDomain(1)->getApproxEntriesPerRow()*2 ) );
443 int flagInlet =this->parameterList_->sublist(
"General").get(
"Flag Inlet Fluid", 2);
444 vec_dbl_Type funcParameter(1,flagInlet);
445 funcParameter.push_back(0.0);
447 this->feFactory_->assemblySurfaceRobinBC(this->dim_, this->getDomain(1)->getFEType(),this->getDomain(0)->getFEType(),u_rep_,Kext, funcParameter, dummyFuncRhs,this->parameterList_);
448 Kext->addMatrix(-1.,Fp,1.);
451 Ap2->addMatrix(1.,Fp,1.);
452 AdvPressure->addMatrix(1.,Fp,1.);
456 if(this->parameterList_->sublist(
"Timestepping Parameter").get(
"dt",-1.)> -1 ){
457 MatrixPtr_Type Mp2(
new Matrix_Type( Mp_ ) );
458 double dt = this->parameterList_->sublist(
"Timestepping Parameter").get(
"dt",-1.);
460 if(this->parameterList_->sublist(
"Timestepping Parameter").get(
"BDF",1) == 1)
462 else if(this->parameterList_->sublist(
"Timestepping Parameter").get(
"BDF",1) == 2)
463 Mp2->scale(3./(2.*dt));
465 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"PCD operator for transient problems only defined for BDF-1 and BDF-2.");
469 Mp2->addMatrix(1.,Fp,1.);
474 BlockMatrixPtr_Type bcBlockMatrix(
new BlockMatrix_Type (1));
476 bcBlockMatrix->addBlock(Fp,0,0);
477 bcFactoryPCD_->setSystemScaled(bcBlockMatrix);
482 this->getPreconditionerConst()->setPCDOperator( Fp );
484 NAVIER_STOKES_STOP(ReassemblePCD);
487template<
class SC,
class LO,
class GO,
class NO>
488void NavierStokes<SC,LO,GO,NO>::assembleDivAndStab()
const{
490 double viscosity = this->parameterList_->sublist(
"Parameter").get(
"Viscosity",1.);
491 double density = this->parameterList_->sublist(
"Parameter").get(
"Density",1.);
493 MatrixPtr_Type BT(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(1)->getDimension() * this->getDomain(1)->getApproxEntriesPerRow() ) );
495 MapConstPtr_Type pressureMap;
496 if ( this->getDomain(1)->getFEType() ==
"P0" )
497 pressureMap = this->getDomain(1)->getElementMap();
499 pressureMap = this->getDomain(1)->getMapUnique();
501 MatrixPtr_Type B(
new Matrix_Type( pressureMap, this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
505 this->feFactory_->assemblyDivAndDivTFast(this->dim_, this->getFEType(0), this->getFEType(1), 2, B, BT, this->getDomain(0)->getMapVecFieldUnique(), pressureMap,
true );
513 B->fillComplete( this->getDomain(0)->getMapVecFieldUnique(), pressureMap );
514 BT->fillComplete( pressureMap, this->getDomain(0)->getMapVecFieldUnique() );
516 this->system_->addBlock( BT, 0, 1 );
517 this->system_->addBlock( B, 1, 0 );
519 if ( !this->getFEType(0).compare(
"P1") || !this->getFEType(0).compare(
"Q1") ) {
520 C.reset(
new Matrix_Type( this->getDomain(1)->getMapUnique(), this->getDomain(1)->getApproxEntriesPerRow() ) );
521 this->feFactory_->assemblyBDStabilization( this->dim_, this->getFEType(0), C,
true);
523 C->scale( -1. / ( viscosity * density ) );
524 C->fillComplete( pressureMap, pressureMap );
526 this->system_->addBlock( C, 1, 1 );
532 if(augmentedLagrange_){
533 NAVIER_STOKES_START(AssembleAugmentedLagrangianComponent,
"AssembleDivAndStab: AL - Assemble BT Mp B");
535 double gamma = this->parameterList_->sublist(
"General").get(
"Gamma",1.0);
537 MatrixPtr_Type Mp(
new Matrix_Type( this->getDomain(1)->getMapUnique(), this->getDomain(1)->getApproxEntriesPerRow() ) );
538 this->feFactory_->assemblyMass( this->dim_, this->domain_FEType_vec_.at(1),
"Scalar", Mp,
true );
540 MatrixPtr_Type MpInv = Mp->buildDiagonalInverse(
"Diagonal");
544 MpInv->fillComplete();
547 MatrixPtr_Type BT_M(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension()*this->getDomain(0)->getApproxEntriesPerRow() ) );
548 BT_M->Multiply(BT,
false,MpInv,
false);
552 MatrixPtr_Type BT_M_B(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension()*this->getDomain(0)->getApproxEntriesPerRow() ) );
553 BT_M_B->Multiply(BT_M,
false,B,
false);
557 NAVIER_STOKES_STOP(AssembleAugmentedLagrangianComponent);
562template<
class SC,
class LO,
class GO,
class NO>
563void NavierStokes<SC,LO,GO,NO>::reAssemble( MatrixPtr_Type& massmatrix, std::string type )
const
568template<
class SC,
class LO,
class GO,
class NO>
569void NavierStokes<SC,LO,GO,NO>::reAssembleFSI(std::string type, MultiVectorPtr_Type u_minus_w, MatrixPtr_Type P)
const {
572 std::cout <<
"-- Reassembly Navier-Stokes ("<< type <<
") for FSI ... " << std::flush;
574 double density = this->parameterList_->sublist(
"Parameter").get(
"Density",1.);
576 MatrixPtr_Type ANW = Teuchos::rcp(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
577 if (type==
"FixedPoint") {
579 MatrixPtr_Type N = Teuchos::rcp(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
580 this->feFactory_->assemblyAdvectionVecField( this->dim_, this->domain_FEType_vec_.at(0), N, u_minus_w,
true );
584 N->fillComplete( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getMapVecFieldUnique());
585 A_->addMatrix(1.,ANW,0.);
587 N->addMatrix(1.,ANW,1.);
589 P->addMatrix(1.,ANW,1.);
593 else if(type==
"Newton"){
594 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"reAssembleFSI should only be called for FPI-System.");
596 ANW->fillComplete( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getMapVecFieldUnique() );
598 this->system_->addBlock( ANW, 0, 0 );
601 std::cout <<
"done -- " << std::endl;
605template<
class SC,
class LO,
class GO,
class NO>
606void NavierStokes<SC,LO,GO,NO>::reAssemble(std::string type)
const {
610 std::cout <<
"-- Reassembly Navier-Stokes ("<< type <<
") ... " << std::flush;
612 double density = this->parameterList_->sublist(
"Parameter").get(
"Density",1.);
615 int allocationFactor = 1;
616 if(augmentedLagrange_)
617 allocationFactor = 3;
618 MatrixPtr_Type ANW = Teuchos::rcp(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), allocationFactor*this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
619 if (type==
"FixedPoint") {
621 MultiVectorConstPtr_Type u = this->solution_->getBlock(0);
622 u_rep_->importFromVector(u,
true);
624 MatrixPtr_Type N = Teuchos::rcp(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
625 this->feFactory_->assemblyAdvectionVecField( this->dim_, this->domain_FEType_vec_.at(0), N, u_rep_,
true );
629 N->fillComplete( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getMapVecFieldUnique());
631 A_->addMatrix(1.,ANW,0.);
632 N->addMatrix(1.,ANW,1.);
635 else if(type==
"Newton"){
637 MatrixPtr_Type W = Teuchos::rcp(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
638 this->feFactory_->assemblyAdvectionInUVecField( this->dim_, this->domain_FEType_vec_.at(0), W, u_rep_,
true );
641 W->fillComplete( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getMapVecFieldUnique());
642 this->system_->getBlock( 0, 0 )->addMatrix(1.,ANW,0.);
643 W->addMatrix(1.,ANW,1.);
647 if(augmentedLagrange_)
648 BT_Mp_B_->addMatrix(1.,ANW,1.);
650 ANW->fillComplete( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getMapVecFieldUnique() );
652 this->system_->addBlock( ANW, 0, 0 );
655 std::cout <<
"done -- " << std::endl;
663template<
class SC,
class LO,
class GO,
class NO>
664void NavierStokes<SC,LO,GO,NO>::establishNNZPattern()
const {
668 std::cout <<
"-- Establish NNZ Pattern Navier-Stokes ... " << std::flush;
670 MatrixPtr_Type ANW = Teuchos::rcp(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
672 MultiVectorPtr_Type zeroVec = Teuchos::rcp(
new MultiVector_Type( this->getDomain(0)->getMapVecFieldRepeated(), 1 ) );
673 zeroVec->putScalar(0.0);
675 MatrixPtr_Type N = Teuchos::rcp(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
676 this->feFactory_->assemblyAdvectionVecField( this->dim_, this->domain_FEType_vec_.at(0), N, zeroVec,
true );
678 N->addMatrix(1.,ANW,0.);
680 MatrixPtr_Type W = Teuchos::rcp(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
681 this->feFactory_->assemblyAdvectionInUVecField( this->dim_, this->domain_FEType_vec_.at(0), W, zeroVec,
true );
683 W->addMatrix(1.,ANW,1.);
685 ANW->fillComplete( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getMapVecFieldUnique() );
690 std::cout <<
"done -- " << std::endl;
693template<
class SC,
class LO,
class GO,
class NO>
694void NavierStokes<SC,LO,GO,NO>::reAssembleExtrapolation(BlockMultiVectorPtrArray_Type previousSolutions){
697 std::cout <<
"-- Reassembly Navier-Stokes (Extrapolation) ... " << std::flush;
700 double density = this->parameterList_->sublist(
"Parameter").get(
"Density",1.);
702 if (previousSolutions.size()>=2) {
704 MultiVectorPtr_Type extrapolatedVector = Teuchos::rcp(
new MultiVector_Type( previousSolutions[0]->getBlock(0) ) );
706 extrapolatedVector->update( -1., *previousSolutions[1]->getBlock(0), 2. );
708 u_rep_->importFromVector(extrapolatedVector,
true);
710 else if(previousSolutions.size()==1){
711 MultiVectorConstPtr_Type u = previousSolutions[0]->getBlock(0);
712 u_rep_->importFromVector(u,
true);
714 else if (previousSolutions.size()==0){
715 MultiVectorConstPtr_Type u = this->solution_->getBlock(0);
716 u_rep_->importFromVector(u,
true);
719 MatrixPtr_Type ANW = Teuchos::rcp(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
721 MatrixPtr_Type N = Teuchos::rcp(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
722 this->feFactory_->assemblyAdvectionVecField( this->dim_, this->domain_FEType_vec_.at(0), N, u_rep_,
true );
726 N->fillComplete( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getMapVecFieldUnique());
728 A_->addMatrix(1.,ANW,0.);
729 N->addMatrix(1.,ANW,1.);
731 ANW->fillComplete( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getMapVecFieldUnique() );
733 this->system_->addBlock( ANW, 0, 0 );
736 std::cout <<
"done -- " << std::endl;
739template<
class SC,
class LO,
class GO,
class NO>
743 std::cout <<
"-- NavierStokes::calculateNonLinResidualVec ("<< type <<
") ... " << std::flush;
745 this->reAssemble(
"FixedPoint");
748 if (this->coeff_.size() == 0)
749 this->system_->apply( *this->solution_, *this->residualVec_ );
751 this->system_->apply( *this->solution_, *this->residualVec_, this->coeff_ );
754 if(augmentedLagrange_){
755 MultiVectorPtr_Type rhsAL = Teuchos::rcp(
new MultiVector_Type( this->residualVec_->getBlock(0) ) );
756 BT_Mp_->apply( *this->residualVec_->getBlock(1), *rhsAL );
757 this->residualVec_->getBlockNonConst(0)->update(1.,*rhsAL,1.);
760 if (!type.compare(
"standard")){
761 this->residualVec_->update(-1.,*this->rhs_,1.);
763 this->bcFactory_->setVectorMinusBC( this->residualVec_, this->solution_, time );
766 else if(!type.compare(
"reverse")){
767 this->residualVec_->update(1.,*this->rhs_,-1.);
769 this->bcFactory_->setBCMinusVector( this->residualVec_, this->solution_, time );