1#ifndef NAVIERSTOKES_def_hpp
2#define NAVIERSTOKES_def_hpp
3#include "NavierStokes_decl.hpp"
5#ifndef NAVIER_STOKES_START
6#define NAVIER_STOKES_START(A,S) Teuchos::RCP<Teuchos::TimeMonitor> A = Teuchos::rcp(new Teuchos::TimeMonitor(*Teuchos::TimeMonitor::getNewTimer(std::string("Assemble Navier-Stokes:") + std::string(S))));
9#ifndef NAVIER_STOKES_STOP
10#define NAVIER_STOKES_STOP(A) A.reset();
22void sxOne2D(
double* x,
double* res,
double t,
double* parameter){
29void syOne2D(
double* x,
double* res,
double t,
double* parameter){
36void sDummyFunc(
double* x,
double* res,
double t,
double* parameter){
41void zeroDirichletBC(
double* x,
double* res,
double t,
const double* parameters){
48double OneFunction(
double* x,
int* parameter)
53void dummyFuncRhs(
double* x,
double* res,
double* parameters){
66template<
class SC,
class LO,
class GO,
class NO>
67NavierStokes<SC,LO,GO,NO>::NavierStokes(
const DomainConstPtr_Type &domainVelocity, std::string FETypeVelocity,
const DomainConstPtr_Type &domainPressure, std::string FETypePressure, ParameterListPtr_Type parameterList ):
70pressureIDsLoc(new vec_int_Type(2)),
74 this->nonLinearTolerance_ = this->parameterList_->sublist(
"Parameter").get(
"relNonLinTol",1.0e-6);
75 this->initNOXParameters();
77 this->addVariable( domainVelocity , FETypeVelocity ,
"u" , domainVelocity->getDimension());
78 this->addVariable( domainPressure , FETypePressure ,
"p" , 1);
79 this->dim_ = this->getDomain(0)->getDimension();
81 u_rep_ = Teuchos::rcp(
new MultiVector_Type( this->getDomain(0)->getMapVecFieldRepeated() ) );
83 if (parameterList->sublist(
"Parameter").get(
"Calculate Coefficients",
false)) {
84 vec2D_dbl_ptr_Type vectmpPointsPressure = domainPressure->getPointsUnique();
85 vec2D_dbl_Type::iterator it;
88 if (domainPressure->getDimension() == 2) {
89 it = find_if(vectmpPointsPressure->begin(), vectmpPointsPressure->end(),
90 [&] (
const std::vector<double>& a){
91 if (a.at(0) >= 0.15-1.e-12 && a.at(0) <= 0.15+1.e-12
92 && a.at(1) >= 0.2-1.e-12 && a.at(1) <= 0.2+1.e-12) {
100 if (it != vectmpPointsPressure->end()) {
101 front = distance(vectmpPointsPressure->begin(),it);
103 it = find_if(vectmpPointsPressure->begin(), vectmpPointsPressure->end(),
104 [&] (
const std::vector<double>& a){
105 if (a.at(0) >= 0.25-1.e-12 && a.at(0) <= 0.25+1.e-12
106 && a.at(1) >= 0.2-1.e-12 && a.at(1) <= 0.2+1.e-12) {
114 if (it != vectmpPointsPressure->end()) {
115 back = distance(vectmpPointsPressure->begin(),it);
117 pressureIDsLoc->at(0) = front;
118 pressureIDsLoc->at(1) = back;
120 else if(domainPressure->getDimension() == 3){
121#ifdef ASSERTS_WARNINGS
122 MYASSERT(
false,
"Not implemented to calc coefficients in 3D!");
127 if(!this->parameterList_->sublist(
"General").get(
"Preconditioner Method",
"Diagonal").compare(
"PCD")
128 || !this->parameterList_->sublist(
"General").get(
"Preconditioner Method",
"Diagonal").compare(
"LSC")
129 || !this->parameterList_->sublist(
"Teko Parameters").sublist(
"Preconditioner Types").sublist(
"Teko").get(
"Inverse Type",
"SIMPLE").compare(
"PCD")
130 || !this->parameterList_->sublist(
"Teko Parameters").sublist(
"Preconditioner Types").sublist(
"Teko").get(
"Inverse Type",
"SIMPLE").compare(
"LSC-Pressure-Laplace") )
132 this->bcFactoryPCD_.reset(
new BCBuilder<SC,LO,GO,NO>( ));
133 this->bcFactoryPCD_->addBC(zeroDirichletBC, 3, 0, Teuchos::rcp_const_cast<Domain_Type>( domainPressure ),
"Dirichlet", 1);
136 if(this->parameterList_->sublist(
"General").get(
"Augmented Lagrange",
false))
137 augmentedLagrange_ =
true;
141template<
class SC,
class LO,
class GO,
class NO>
142void NavierStokes<SC,LO,GO,NO>::info(){
144 this->infoNonlinProblem();
147template<
class SC,
class LO,
class GO,
class NO>
148void NavierStokes<SC,LO,GO,NO>::assemble( std::string type )
const{
152 std::cout <<
"-- Assembly Navier-Stokes ... " << std::endl;
154 assembleConstantMatrices();
157 std::cout <<
"done -- " << std::endl;
159 else if(type==
"UpdateTime"){
160 this->newtonStep_ = 0;
163 else if(type ==
"UpdateConvectionDiffusionOperator")
164 this->updateConvectionDiffusionOperator();
170template<
class SC,
class LO,
class GO,
class NO>
171void NavierStokes<SC,LO,GO,NO>::assembleConstantMatrices()
const{
174 std::cout <<
"-- Assembly constant matrices Navier-Stokes ... " << std::flush;
176 double viscosity = this->parameterList_->sublist(
"Parameter").get(
"Viscosity",1.);
177 double density = this->parameterList_->sublist(
"Parameter").get(
"Density",1.);
182 A_.reset(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
184 if ( this->parameterList_->sublist(
"Parameter").get(
"Symmetric gradient",
false) )
185 this->feFactory_->assemblyStress(this->dim_, this->domain_FEType_vec_.at(0), A_, OneFunction, dummy,
true);
187 this->feFactory_->assemblyLaplaceVecField(this->dim_, this->domain_FEType_vec_.at(0), 2, A_,
true);
191 A_->scale(viscosity);
194 A_->fillComplete( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getMapVecFieldUnique());
196 if (this->system_.is_null())
197 this->system_.reset(
new BlockMatrix_Type(2));
199 this->system_->addBlock( A_, 0, 0 );
200 assembleDivAndStab();
203 if ( !this->parameterList_->sublist(
"General").get(
"Preconditioner Method",
"Monolithic").compare(
"Teko")
204 || !this->parameterList_->sublist(
"General").get(
"Preconditioner Method",
"Diagonal").compare(
"PCD")
205 || !this->parameterList_->sublist(
"General").get(
"Preconditioner Method",
"Diagonal").compare(
"LSC")) {
212 if (!this->parameterList_->sublist(
"Teko Parameters").sublist(
"Preconditioner Types").sublist(
"Teko").get(
"Inverse Type",
"None").compare(
"LSC")
213 || !this->parameterList_->sublist(
"Teko Parameters").sublist(
"Preconditioner Types").sublist(
"Teko").get(
"Inverse Type",
"None").compare(
"LSC-Pressure-Laplace")
214 || !this->parameterList_->sublist(
"Teko Parameters").sublist(
"Preconditioner Types").sublist(
"Teko").get(
"Inverse Type",
"None").compare(
"SIMPLE")
215 || !this->parameterList_->sublist(
"General").get(
"Preconditioner Method",
"Diagonal").compare(
"LSC")) {
217 MatrixPtr_Type Mvelocity(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getApproxEntriesPerRow() ) );
219 if(this->parameterList_->sublist(
"Parameter").get(
"BFBT",
false)){
221 std::cout <<
"\n Setting M_u to be the identity Matrix to use BFBT preconditioner " << std::endl;
223 this->feFactory_->assemblyIdentity( Mvelocity );
226 this->feFactory_->assemblyMass( this->dim_, this->domain_FEType_vec_.at(0),
"Vector", Mvelocity,
true );
229 this->getPreconditionerConst()->setVelocityMassMatrix( Mvelocity );
232 std::cout <<
"\n Velocity mass matrix for LSC block preconditioner is assembled and used for the preconditioner." << std::endl;
235 if(!this->parameterList_->sublist(
"Teko Parameters").sublist(
"Preconditioner Types").sublist(
"Teko").get(
"Inverse Type",
"SIMPLE").compare(
"LSC-Pressure-Laplace")
236 || !this->parameterList_->sublist(
"General").get(
"Preconditioner Method",
"Diagonal").compare(
"LSC"))
238 MatrixPtr_Type Lp(
new Matrix_Type( this->getDomain(1)->getMapUnique(), this->getDomain(1)->getApproxEntriesPerRow() ) );
239 this->feFactory_->assemblyLaplace( this->dim_, this->domain_FEType_vec_.at(1), 2, Lp,
true );
241 BlockMatrixPtr_Type bcBlockMatrix(
new BlockMatrix_Type (1));
242 bcBlockMatrix->addBlock(Lp,0,0);
243 bcFactoryPCD_->setSystemScaled(bcBlockMatrix);
245 this->getPreconditionerConst()->setPressureLaplaceMatrix( Lp);
254 else if(!this->parameterList_->sublist(
"Teko Parameters").sublist(
"Preconditioner Types").sublist(
"Teko").get(
"Inverse Type",
"SIMPLE").compare(
"PCD")
255 || !this->parameterList_->sublist(
"General").get(
"Preconditioner Method",
"Diagonal").compare(
"PCD") ){
259 MatrixPtr_Type Mvelocity(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getApproxEntriesPerRow() ) );
260 this->feFactory_->assemblyMass( this->dim_, this->domain_FEType_vec_.at(0),
"Vector", Mvelocity,
true );
261 this->getPreconditionerConst()->setVelocityMassMatrix( Mvelocity );
266 MatrixPtr_Type Mpressure(
new Matrix_Type( this->getDomain(1)->getMapUnique(), this->getDomain(1)->getApproxEntriesPerRow() ) );
267 this->feFactory_->assemblyMass( this->dim_, this->domain_FEType_vec_.at(1),
"Scalar", Mpressure,
true );
269 this->getPreconditionerConst()->setPressureMassMatrix( Mpressure );
274 MatrixPtr_Type Lp(
new Matrix_Type( this->getDomain(1)->getMapUnique(), this->getDomain(1)->getApproxEntriesPerRow() ) );
275 this->feFactory_->assemblyLaplace( this->dim_, this->domain_FEType_vec_.at(1), 2, Lp,
true );
276 Ap_.reset(
new Matrix_Type(Lp));
279 BlockMatrixPtr_Type bcBlockMatrix(
new BlockMatrix_Type (1));
280 bcBlockMatrix->addBlock(Lp,0,0);
282 bcFactoryPCD_->setSystemScaled(bcBlockMatrix);
283 this->getPreconditionerConst()->setPressureLaplaceMatrix( Lp);
288 MatrixPtr_Type Kp(
new Matrix_Type( this->getDomain(1)->getMapUnique(), this->getDomain(1)->getApproxEntriesPerRow() ) );
291 MatrixPtr_Type AdvPressure(
new Matrix_Type( this->getDomain(1)->getMapUnique(), this->getDomain(1)->getApproxEntriesPerRow() ) );
292 this->feFactory_->assemblyAdvectionVecFieldScalar( this->dim_, this->domain_FEType_vec_.at(1), this->domain_FEType_vec_.at(0),AdvPressure, u_rep_,
true );
295 MatrixPtr_Type Ap2(
new Matrix_Type( Ap_) );
297 SC kinVisco = this->parameterList_->sublist(
"Parameter").get(
"Viscosity",1.);
299 Ap2->scale(kinVisco);
303 MatrixPtr_Type K_robin(
new Matrix_Type( this->getDomain(1)->getMapUnique(), this->getDomain(1)->getDimension() * this->getDomain(1)->getApproxEntriesPerRow()*2 ) );
304 vec_dbl_Type funcParameter(1,kinVisco);
305 this->feFactory_->assemblySurfaceRobinBC(this->dim_, this->getDomain(1)->getFEType(),this->getDomain(0)->getFEType(),u_rep_,K_robin, funcParameter, dummyFuncRhs,this->parameterList_);
306 K_robin->addMatrix(-1.,Kp,1.);
309 Ap2->addMatrix(1.,Kp,1.);
310 AdvPressure->addMatrix(1.,Kp,1.);
314 bcBlockMatrix->addBlock(Kp,0,0);
315 bcFactoryPCD_->setSystemScaled(bcBlockMatrix);
318 this->getPreconditionerConst()->setPCDOperator( Kp );
324 std::string precType = this->parameterList_->sublist(
"General").get(
"Preconditioner Method",
"Monolithic");
325 if ( precType ==
"Diagonal" || precType ==
"Triangular" ) {
326 MatrixPtr_Type Mpressure(
new Matrix_Type( this->getDomain(1)->getMapUnique(), this->getDomain(1)->getApproxEntriesPerRow() ) );
328 this->feFactory_->assemblyMass( this->dim_, this->domain_FEType_vec_.at(1),
"Scalar", Mpressure,
true );
329 SC kinVisco = this->parameterList_->sublist(
"Parameter").get(
"Viscosity",1.);
331 if(augmentedLagrange_){
332 double gamma = this->parameterList_->sublist(
"General").get(
"Gamma",1.0);
333 Mpressure->scale(-1./(kinVisco+gamma));
336 Mpressure->scale(-1./kinVisco);
338 this->getPreconditionerConst()->setPressureMassMatrix( Mpressure );
342 std::cout <<
" Call Reassemble FixedPoint and Newton to allocate the Matrix pattern " << std::endl;
346 this->reAssemble(
"FixedPoint");
347 this->reAssemble(
"Newton");
350 std::cout <<
"done -- " << std::endl;
355template<
class SC,
class LO,
class GO,
class NO>
356void NavierStokes<SC,LO,GO,NO>::updateConvectionDiffusionOperator()
const{
358 if ( !this->parameterList_->sublist(
"Teko Parameters").sublist(
"Preconditioner Types").sublist(
"Teko").get(
"Inverse Type",
"SIMPLE").compare(
"PCD")
359 || !this->parameterList_->sublist(
"General").get(
"Preconditioner Method",
"Monolithic").compare(
"PCD"))
362 NAVIER_STOKES_START(ReassemblePCD,
" Reassembling Matrix for PCD ");
364 MultiVectorConstPtr_Type u = this->solution_->getBlock(0);
365 u_rep_->importFromVector(u,
true);
368 MatrixPtr_Type Fp(
new Matrix_Type( this->getDomain(1)->getMapUnique(), this->getDomain(1)->getApproxEntriesPerRow() ) );
371 MatrixPtr_Type AdvPressure(
new Matrix_Type( this->getDomain(1)->getMapUnique(), this->getDomain(1)->getApproxEntriesPerRow() ) );
372 this->feFactory_->assemblyAdvectionVecFieldScalar( this->dim_, this->domain_FEType_vec_.at(1), this->domain_FEType_vec_.at(0),AdvPressure, u_rep_,
true );
375 MatrixPtr_Type Ap2(
new Matrix_Type( Ap_ ) );
376 SC kinVisco = this->parameterList_->sublist(
"Parameter").get(
"Viscosity",1.);
378 Ap2->scale(kinVisco);
383 MatrixPtr_Type Kext(
new Matrix_Type( this->getDomain(1)->getMapUnique(), this->getDomain(1)->getDimension() * this->getDomain(1)->getApproxEntriesPerRow()*2 ) );
384 vec_dbl_Type funcParameter(1,kinVisco);
385 this->feFactory_->assemblySurfaceRobinBC(this->dim_, this->getDomain(1)->getFEType(),this->getDomain(0)->getFEType(),u_rep_,Kext, funcParameter, dummyFuncRhs,this->parameterList_);
386 Kext->addMatrix(-1.,Fp,1.);
389 Ap2->addMatrix(1.,Fp,1.);
390 AdvPressure->addMatrix(1.,Fp,1.);
393 if(this->parameterList_->sublist(
"Timestepping Parameter").get(
"dt",-1.)> -1 ){
394 MatrixPtr_Type Mp2(
new Matrix_Type( Mp_ ) );
395 double dt = this->parameterList_->sublist(
"Timestepping Parameter").get(
"dt",-1.);
397 if(this->parameterList_->sublist(
"Timestepping Parameter").get(
"BDF",1) == 1)
399 else if(this->parameterList_->sublist(
"Timestepping Parameter").get(
"BDF",1) == 2)
400 Mp2->scale(3./(2.*dt));
402 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"PCD operator for transient problems only defined for BDF-1 and BDF-2.");
405 Mp2->addMatrix(1.,Fp,1.);
409 BlockMatrixPtr_Type bcBlockMatrix(
new BlockMatrix_Type (1));
411 bcBlockMatrix->addBlock(Fp,0,0);
412 bcFactoryPCD_->setSystemScaled(bcBlockMatrix);
417 this->getPreconditionerConst()->setPCDOperator( Fp );
419 NAVIER_STOKES_STOP(ReassemblePCD);
422template<
class SC,
class LO,
class GO,
class NO>
423void NavierStokes<SC,LO,GO,NO>::assembleDivAndStab()
const{
425 double viscosity = this->parameterList_->sublist(
"Parameter").get(
"Viscosity",1.);
426 double density = this->parameterList_->sublist(
"Parameter").get(
"Density",1.);
428 MatrixPtr_Type BT(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(1)->getDimension() * this->getDomain(1)->getApproxEntriesPerRow() ) );
430 MapConstPtr_Type pressureMap;
431 if ( this->getDomain(1)->getFEType() ==
"P0" )
432 pressureMap = this->getDomain(1)->getElementMap();
434 pressureMap = this->getDomain(1)->getMapUnique();
436 MatrixPtr_Type B(
new Matrix_Type( pressureMap, this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
440 this->feFactory_->assemblyDivAndDivTFast(this->dim_, this->getFEType(0), this->getFEType(1), 2, B, BT, this->getDomain(0)->getMapVecFieldUnique(), pressureMap,
true );
448 B->fillComplete( this->getDomain(0)->getMapVecFieldUnique(), pressureMap );
449 BT->fillComplete( pressureMap, this->getDomain(0)->getMapVecFieldUnique() );
451 this->system_->addBlock( BT, 0, 1 );
452 this->system_->addBlock( B, 1, 0 );
454 if ( !this->getFEType(0).compare(
"P1") || !this->getFEType(0).compare(
"Q1") ) {
455 C.reset(
new Matrix_Type( this->getDomain(1)->getMapUnique(), this->getDomain(1)->getApproxEntriesPerRow() ) );
456 this->feFactory_->assemblyBDStabilization( this->dim_, this->getFEType(0), C,
true);
458 C->scale( -1. / ( viscosity * density ) );
459 C->fillComplete( pressureMap, pressureMap );
461 this->system_->addBlock( C, 1, 1 );
475 if(augmentedLagrange_){
476 NAVIER_STOKES_START(AssembleAugmentedLagrangianComponent,
"AssembleDivAndStab: AL - Assemble BT Mp B");
478 double gamma = this->parameterList_->sublist(
"General").get(
"Gamma",1.0);
480 MatrixPtr_Type Mp(
new Matrix_Type( this->getDomain(1)->getMapUnique(), this->getDomain(1)->getApproxEntriesPerRow() ) );
481 this->feFactory_->assemblyMass( this->dim_, this->domain_FEType_vec_.at(1),
"Scalar", Mp,
true );
483 MatrixPtr_Type MpInv = Mp->buildDiagonalInverse(
"Diagonal");
487 MpInv->fillComplete();
490 MatrixPtr_Type BT_M(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension()*this->getDomain(0)->getApproxEntriesPerRow() ) );
491 BT_M->Multiply(BT,
false,MpInv,
false);
495 MatrixPtr_Type BT_M_B(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension()*this->getDomain(0)->getApproxEntriesPerRow() ) );
496 BT_M_B->Multiply(BT_M,
false,B,
false);
502 NAVIER_STOKES_STOP(AssembleAugmentedLagrangianComponent);
509template<
class SC,
class LO,
class GO,
class NO>
510void NavierStokes<SC,LO,GO,NO>::reAssemble( MatrixPtr_Type& massmatrix, std::string type )
const
515template<
class SC,
class LO,
class GO,
class NO>
516void NavierStokes<SC,LO,GO,NO>::reAssembleFSI(std::string type, MultiVectorPtr_Type u_minus_w, MatrixPtr_Type P)
const {
519 std::cout <<
"-- Reassembly Navier-Stokes ("<< type <<
") for FSI ... " << std::flush;
521 double density = this->parameterList_->sublist(
"Parameter").get(
"Density",1.);
523 MatrixPtr_Type ANW = Teuchos::rcp(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
524 if (type==
"FixedPoint") {
526 MatrixPtr_Type N = Teuchos::rcp(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
527 this->feFactory_->assemblyAdvectionVecField( this->dim_, this->domain_FEType_vec_.at(0), N, u_minus_w,
true );
531 N->fillComplete( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getMapVecFieldUnique());
532 A_->addMatrix(1.,ANW,0.);
534 N->addMatrix(1.,ANW,1.);
536 P->addMatrix(1.,ANW,1.);
540 else if(type==
"Newton"){
541 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"reAssembleFSI should only be called for FPI-System.");
543 ANW->fillComplete( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getMapVecFieldUnique() );
545 this->system_->addBlock( ANW, 0, 0 );
548 std::cout <<
"done -- " << std::endl;
552template<
class SC,
class LO,
class GO,
class NO>
553void NavierStokes<SC,LO,GO,NO>::reAssemble(std::string type)
const {
557 std::cout <<
"-- Reassembly Navier-Stokes ("<< type <<
") ... " << std::flush;
559 double density = this->parameterList_->sublist(
"Parameter").get(
"Density",1.);
560 int allocationFactor = 1;
561 if(augmentedLagrange_)
562 allocationFactor = 3;
563 MatrixPtr_Type ANW = Teuchos::rcp(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), allocationFactor*this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
564 if (type==
"FixedPoint") {
566 MultiVectorConstPtr_Type u = this->solution_->getBlock(0);
567 u_rep_->importFromVector(u,
true);
569 MatrixPtr_Type N = Teuchos::rcp(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
570 this->feFactory_->assemblyAdvectionVecField( this->dim_, this->domain_FEType_vec_.at(0), N, u_rep_,
true );
574 N->fillComplete( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getMapVecFieldUnique());
576 A_->addMatrix(1.,ANW,0.);
577 N->addMatrix(1.,ANW,1.);
580 else if(type==
"Newton"){
582 MatrixPtr_Type W = Teuchos::rcp(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
583 this->feFactory_->assemblyAdvectionInUVecField( this->dim_, this->domain_FEType_vec_.at(0), W, u_rep_,
true );
586 W->fillComplete( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getMapVecFieldUnique());
587 this->system_->getBlock( 0, 0 )->addMatrix(1.,ANW,0.);
588 W->addMatrix(1.,ANW,1.);
592 if(augmentedLagrange_)
593 BT_Mp_B_->addMatrix(1.,ANW,1.);
595 ANW->fillComplete( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getMapVecFieldUnique() );
597 this->system_->addBlock( ANW, 0, 0 );
600 std::cout <<
"done -- " << std::endl;
603template<
class SC,
class LO,
class GO,
class NO>
604void NavierStokes<SC,LO,GO,NO>::reAssembleExtrapolation(BlockMultiVectorPtrArray_Type previousSolutions){
607 std::cout <<
"-- Reassembly Navier-Stokes (Extrapolation) ... " << std::flush;
610 double density = this->parameterList_->sublist(
"Parameter").get(
"Density",1.);
612 if (previousSolutions.size()>=2) {
614 MultiVectorPtr_Type extrapolatedVector = Teuchos::rcp(
new MultiVector_Type( previousSolutions[0]->getBlock(0) ) );
616 extrapolatedVector->update( -1., *previousSolutions[1]->getBlock(0), 2. );
618 u_rep_->importFromVector(extrapolatedVector,
true);
620 else if(previousSolutions.size()==1){
621 MultiVectorConstPtr_Type u = previousSolutions[0]->getBlock(0);
622 u_rep_->importFromVector(u,
true);
624 else if (previousSolutions.size()==0){
625 MultiVectorConstPtr_Type u = this->solution_->getBlock(0);
626 u_rep_->importFromVector(u,
true);
629 MatrixPtr_Type ANW = Teuchos::rcp(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
631 MatrixPtr_Type N = Teuchos::rcp(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
632 this->feFactory_->assemblyAdvectionVecField( this->dim_, this->domain_FEType_vec_.at(0), N, u_rep_,
true );
636 N->fillComplete( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getMapVecFieldUnique());
638 A_->addMatrix(1.,ANW,0.);
639 N->addMatrix(1.,ANW,1.);
641 ANW->fillComplete( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getMapVecFieldUnique() );
643 this->system_->addBlock( ANW, 0, 0 );
646 std::cout <<
"done -- " << std::endl;
752template<
class SC,
class LO,
class GO,
class NO>
753void NavierStokes<SC,LO,GO,NO>::calculateNonLinResidualVec(std::string type,
double time)
const{
756 std::cout <<
"-- NavierStokes::calculateNonLinResidualVec ("<< type <<
") ... " << std::flush;
760 this->reAssemble(
"FixedPoint");
763 if (this->coeff_.size() == 0)
764 this->system_->apply( *this->solution_, *this->residualVec_ );
766 this->system_->apply( *this->solution_, *this->residualVec_, this->coeff_ );
768 if(augmentedLagrange_){
769 MultiVectorPtr_Type rhsAL = Teuchos::rcp(
new MultiVector_Type( this->residualVec_->getBlock(0) ) );
770 BT_Mp_->apply( *this->residualVec_->getBlock(1), *rhsAL );
771 this->residualVec_->getBlockNonConst(0)->update(1.,*rhsAL,1.);
774 if (!type.compare(
"standard")){
775 this->residualVec_->update(-1.,*this->rhs_,1.);
779 this->bcFactory_->setVectorMinusBC( this->residualVec_, this->solution_, time );
782 else if(!type.compare(
"reverse")){
783 this->residualVec_->update(1.,*this->rhs_,-1.);
787 this->bcFactory_->setBCMinusVector( this->residualVec_, this->solution_, time );
792template<
class SC,
class LO,
class GO,
class NO>
793void NavierStokes<SC,LO,GO,NO>::calculateNonLinResidualVecWithMeshVelo(std::string type,
double time, MultiVectorPtr_Type u_minus_w, MatrixPtr_Type P)
const{
796 this->reAssembleFSI(
"FixedPoint", u_minus_w, P );
801 this->system_->apply( *this->solution_, *this->residualVec_ );
804 if (!type.compare(
"standard")){
805 this->residualVec_->update(-1.,*this->rhs_,1.);
806 if ( !this->sourceTerm_.is_null() )
807 this->residualVec_->update(-1.,*this->sourceTerm_,1.);
809 else if(!type.compare(
"reverse")){
810 this->residualVec_->update(1.,*this->rhs_,-1.);
811 if ( !this->sourceTerm_.is_null() )
812 this->residualVec_->update(1.,*this->sourceTerm_,1.);
816 this->bcFactory_->setBCMinusVector( this->residualVec_, this->solution_, time );
Definition NonLinearProblem_decl.hpp:24
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement_decl.hpp:33