5double OneFunc(
double* x,
int* parameter)
10void drag2D(
double* x,
double* res,
double t,
const double* parameters)
18void drag3D(
double* x,
double* res,
double t,
const double* parameters)
27void lift2D(
double* x,
double* res,
double t,
const double* parameters)
35void lift3D(
double* x,
double* res,
double t,
const double* parameters)
47template<
class SC,
class LO,
class GO,
class NO>
48FSI<SC,LO,GO,NO>::FSI(
const DomainConstPtr_Type &domainVelocity, std::string FETypeVelocity,
49 const DomainConstPtr_Type &domainPressure, std::string FETypePressure,
50 const DomainConstPtr_Type &domainStructure, std::string FETypeStructure,
51 const DomainConstPtr_Type &domainInterface, std::string FETypeInterface,
52 const DomainConstPtr_Type &domainGeometry, std::string FETypeGeometry,
53 ParameterListPtr_Type parameterListFluid, ParameterListPtr_Type parameterListStructure,
54 ParameterListPtr_Type parameterListFSI, ParameterListPtr_Type parameterListGeometry,
63problemStructureNonLin_(),
65meshDisplacementOld_rep_(),
66meshDisplacementNew_rep_(),
73materialModel_( parameterListStructure->sublist(
"Parameter").get(
"Material model",
"linear") ),
78 this->nonLinearTolerance_ = this->parameterList_->sublist(
"Parameter").get(
"relNonLinTol",1.0e-6);
79 geometryExplicit_ = this->parameterList_->sublist(
"Parameter").get(
"Geometry Explicit",
true);
81 this->initNOXParameters();
84 std::string linearization = parameterListFSI->sublist(
"General").get(
"Linearization",
"FixedPoint");
86 TEUCHOS_TEST_FOR_EXCEPTION( !(linearization ==
"Newton" || linearization ==
"NOX") && materialModel_ !=
"linear", std::runtime_error,
"Nonlinear material models can only be used with Newton's method or FixedPoint (nonlinear material Jacobian will still be used).");
88 this->addVariable( domainVelocity, FETypeVelocity,
"u_f", domainVelocity->getDimension() );
89 this->addVariable( domainPressure, FETypePressure,
"p", 1);
90 this->addVariable( domainStructure, FETypeStructure,
"d_s", domainStructure->getDimension() );
91 this->addVariable( domainInterface, FETypeInterface,
"lambda", domainInterface->getDimension() );
92 this->addVariable( domainGeometry, FETypeGeometry,
"d_f", domainGeometry->getDimension() );
93 this->dim_ = this->getDomain(0)->getDimension();
95 problemFluid_ = Teuchos::rcp(
new FluidProblem_Type( domainVelocity, FETypeVelocity, domainPressure, FETypePressure, parameterListFluid ) );
96 problemFluid_->initializeProblem();
98 if (materialModel_==
"linear"){
99 problemStructure_ = Teuchos::rcp(
new StructureProblem_Type( domainStructure, FETypeStructure, parameterListStructure ) );
100 problemStructure_->initializeProblem();
103 problemStructureNonLin_ = Teuchos::rcp(
new StructureNonLinProblem_Type( domainStructure, FETypeStructure, parameterListStructure) );
104 problemStructureNonLin_->initializeProblem();
107 problemGeometry_ = Teuchos::rcp(
new GeometryProblem_Type( domainGeometry, FETypeGeometry, parameterListGeometry ) );
108 problemGeometry_->initializeProblem();
111 meshDisplacementNew_rep_ = Teuchos::rcp(
new MultiVector_Type( this->getDomain(4)->getMapVecFieldRepeated() ) );
112 meshDisplacementOld_rep_ = Teuchos::rcp(
new MultiVector_Type( this->getDomain(4)->getMapVecFieldRepeated() ) );
113 u_rep_ = Teuchos::rcp(
new MultiVector_Type( this->getDomain(0)->getMapVecFieldRepeated() ) );
114 w_rep_ = Teuchos::rcp(
new MultiVector_Type( this->getDomain(0)->getMapVecFieldRepeated() ) );
115 u_minus_w_rep_ = Teuchos::rcp(
new MultiVector_Type( this->getDomain(0)->getMapVecFieldRepeated() ) );
118 if ( parameterListFSI->sublist(
"General").get(
"Export Extra Data",
false) ){
120 findDisplacementTurek2DBenchmark();
121 else if (this->dim_==3)
122 findDisplacementRichter3DBenchmark();
124 if ( parameterListFSI->sublist(
"General").get(
"Export drag and lift",
false) ){
125 exporterTxtDrag_ = Teuchos::rcp(
new ExporterTxt () );
126 exporterTxtDrag_->setup(
"drag_force", this->comm_ );
127 exporterTxtLift_ = Teuchos::rcp(
new ExporterTxt () );
128 exporterTxtLift_->setup(
"lift_force", this->comm_ );
130 p_rep_ = Teuchos::rcp(
new MultiVector_Type( this->getDomain(1)->getMapRepeated() ) );
134template<
class SC,
class LO,
class GO,
class NO>
135void FSI<SC,LO,GO,NO>::findDisplacementTurek2DBenchmark(){
136 valuesForExport_.resize(1);
137 vec_dbl_Type x = {0.6,0.2};
139 valuesForExport_[0] = this->getDomain(2)->findInPointsUnique( x );
142template<
class SC,
class LO,
class GO,
class NO>
143void FSI<SC,LO,GO,NO>::findDisplacementRichter3DBenchmark(){
144 valuesForExport_.resize(1);
145 vec_dbl_Type x = {0.45,0.15,0.15};
147 valuesForExport_[0] = this->getDomain(2)->findInPointsUnique( x );
150template<
class SC,
class LO,
class GO,
class NO>
151FSI<SC,LO,GO,NO>::~FSI()
153 if (!exporterGeo_.is_null()) {
154 exporterGeo_->closeExporter();
158template<
class SC,
class LO,
class GO,
class NO>
159void FSI<SC,LO,GO,NO>::info()
162 this->infoNonlinProblem();
166template<
class SC,
class LO,
class GO,
class NO>
167void FSI<SC,LO,GO,NO>::assemble( std::string type )
const
172 std::cout <<
"-- Assembly FSI ... " << std::endl;
177 this->problemFluid_->assemble();
181 if (materialModel_==
"linear")
182 this->problemStructure_->assemble();
184 this->problemStructureNonLin_->assemble();
186 this->problemGeometry_->assemble();
188 if ( geometryExplicit_ && this->parameterList_->sublist(
"Exporter").get(
"Export GE geometry solution",
false)){
189 exporterGeo_ = Teuchos::rcp(
new Exporter_Type());
191 DomainConstPtr_Type dom = this->getDomain(4);
193 int exportEveryXTimesteps = this->parameterList_->sublist(
"Exporter").get(
"Export every X timesteps", 1 );
194 std::string suffix = this->parameterList_->sublist(
"Exporter").get(
"Geometry Suffix",
"" );
195 std::string varName =
"d_f" + suffix;
197 MeshPtr_Type meshNonConst = Teuchos::rcp_const_cast<Mesh_Type>( dom->getMesh() );
198 exporterGeo_->setup(varName, meshNonConst, dom->getFEType(), exportEveryXTimesteps, this->parameterList_);
200 MultiVectorConstPtr_Type exportVector = this->problemGeometry_->getSolution()->getBlock(0);
202 exporterGeo_->addVariable( exportVector, varName,
"Vector", this->dim_, dom->getMapUnique() );
206 if (!geometryExplicit_) {
210 this->problemGeometry_->setBoundariesSystem();
211 this->problemGeometry_->getRhs()->putScalar(0.0);
223 MatrixPtr_Type C1_T(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), 1 ) );
224 MatrixPtr_Type C1(
new Matrix_Type( this->getDomain(0)->getInterfaceMapVecFieldUnique(), 1 ) );
225 MatrixPtr_Type C2(
new Matrix_Type( this->getDomain(0)->getInterfaceMapVecFieldUnique(), 1 ) );
226 MatrixPtr_Type C3_T(
new Matrix_Type( this->getDomain(2)->getMapVecFieldUnique(), 1 ) );
230 MatrixPtr_Type C4(
new Matrix_Type( this->getDomain(4)->getMapVecFieldUnique(), 1 ) );
233 this->feFactory_->assemblyFSICoupling(this->dim_, this->domain_FEType_vec_.at(0), C1, C1_T, 0, 0,
234 this->getDomain(0)->getInterfaceMapVecFieldUnique(), this->getDomain(0)->getMapVecFieldUnique(),
true);
239 this->feFactory_->assemblyFSICoupling(this->dim_, this->domain_FEType_vec_.at(2), C2, C3_T, 0, 2,
240 this->getDomain(0)->getInterfaceMapVecFieldUnique(), this->getDomain(2)->getMapVecFieldUnique(),
true);
244 if(!geometryExplicit_)
248 this->feFactory_->assemblyGeometryCoupling(this->dim_, this->domain_FEType_vec_.at(4), C4, 4,
249 this->getDomain(0)->getGlobalInterfaceMapUnique(),
250 this->getDomain(2)->getMapVecFieldUnique(),
251 this->getDomain(4)->getMapVecFieldUnique(),
true);
254 MatrixPtr_Type dummyC;
256 if ( !this->getDomain(0)->getGlobalInterfaceMapVecFieldPartial().is_null() ) {
257 dummyC.reset(
new Matrix_Type( this->getDomain(0)->getInterfaceMapVecFieldUnique(), 1 ) );
258 this->feFactory_->assemblyDummyCoupling(this->dim_, this->domain_FEType_vec_.at(0), dummyC, 0,
true);
264 double dt = this->parameterList_->sublist(
"Timestepping Parameter").get(
"dt",0.02);
269 C2->scale( -(1.0/dt) );
274 C2->fillComplete(this->getDomain(2)->getMapVecFieldUnique(), this->getDomain(0)->getInterfaceMapVecFieldUnique());
275 C3_T->fillComplete(this->getDomain(0)->getInterfaceMapVecFieldUnique(), this->getDomain(2)->getMapVecFieldUnique());
281 if(!geometryExplicit_)
286 C4->fillComplete(this->getDomain(2)->getMapVecFieldUnique(), this->getDomain(4)->getMapVecFieldUnique());
294 if(geometryExplicit_)
295 this->system_.reset(
new BlockMatrix_Type(4));
297 this->system_.reset(
new BlockMatrix_Type(5));
300 this->system_->addBlock( this->problemFluid_->system_->getBlock(0,0), 0, 0 );
301 this->system_->addBlock( this->problemFluid_->system_->getBlock(0,1), 0, 1 );
302 this->system_->addBlock( this->problemFluid_->system_->getBlock(1,0), 1, 0 );
303 if (this->getDomain(0)->getFEType()==
"P1")
304 this->system_->addBlock( this->problemFluid_->system_->getBlock(1,1), 1, 1 );
307 if (materialModel_==
"linear")
308 this->system_->addBlock( this->problemStructure_->system_->getBlock(0,0), 2, 2 );
310 this->system_->addBlock( this->problemStructureNonLin_->system_->getBlock(0,0), 2, 2 );
312 this->system_->addBlock( C1_T, 0, 3 );
313 this->system_->addBlock( C3_T, 2, 3 );
314 this->system_->addBlock( C1, 3, 0 );
315 this->system_->addBlock( C2, 3, 2 );
317 if (!dummyC.is_null())
318 this->system_->addBlock( dummyC, 3, 3 );
320 if(!geometryExplicit_)
323 this->system_->addBlock( this->problemGeometry_->system_->getBlock(0,0), 4, 4 );
325 this->system_->addBlock( C4, 4, 2 );
336 this->setFromPartialVectorsInit();
339 timeSteppingTool_ = Teuchos::rcp(
new TimeSteppingTools(sublist(this->parameterList_,
"Timestepping Parameter") , this->comm_));
340 ParameterListPtr_Type plStructure;
341 if (materialModel_==
"linear")
342 plStructure = this->problemStructure_->getParameterList();
344 plStructure = this->problemStructureNonLin_->getParameterList();
346 setupSubTimeProblems(this->problemFluid_->getParameterList(), plStructure);
350 std::cout <<
"done -- " << std::endl;
358template<
class SC,
class LO,
class GO,
class NO>
359void FSI<SC,LO,GO,NO>::reAssemble(std::string type)
const
362 double dt = this->parameterList_->sublist(
"Timestepping Parameter").get(
"dt",0.02);
365 double density = this->problemFluid_->getParameterList()->sublist(
"Parameter").get(
"Density",1.);
366 double viscosity = this->problemFluid_->getParameterList()->sublist(
"Parameter").get(
"Viscosity",1.);
368 if(type ==
"UpdateMeshDisplacement")
371 std::cout <<
"-- Reassembly (UpdateMeshDisplacement)" <<
'\n';
375 updateMeshDisplacement();
379 if(type ==
"SolveGeometryProblem")
382 std::cout <<
"-- Reassembly (SolveGeometryProblem)" <<
'\n';
384 solveGeometryProblem();
388 if(type ==
"UpdateTime")
391 std::cout <<
"-- Reassembly (UpdateTime)" <<
'\n';
397 if(type ==
"UpdateFluidInTime")
400 std::cout <<
"-- Reassembly (UpdateFluidInTime)" <<
'\n';
406 if(type ==
"MoveMesh")
409 std::cout <<
"-- Reassembly (MoveMesh)" <<
'\n';
415 if(type ==
"AddInterfaceBlockRHS")
418 std::cout <<
"-- Reassembly (AddInterfaceBlockRHS)" <<
'\n';
420 addInterfaceBlockRHS();
424 if(type ==
"ComputeFluidRHSInTime")
427 std::cout <<
"-- Reassembly (ComputeFluidRHSInTime)" <<
'\n';
429 computeFluidRHSInTime( );
432 if(type ==
"ComputeSolidRHSInTime")
435 std::cout <<
"-- Reassembly (ComputeSolidRHSInTime)" <<
'\n';
437 computeSolidRHSInTime( );
445 MultiVectorConstPtr_Type fluidSolution = this->solution_->getBlock(0);
446 u_rep_->importFromVector(fluidSolution,
true);
447 u_minus_w_rep_->importFromVector(fluidSolution,
true);
449 MultiVectorConstPtr_Type geometrySolution;
450 if(geometryExplicit_)
452 geometrySolution = this->problemGeometry_->getSolution()->getBlock(0);
456 geometrySolution = this->solution_->getBlock(4);
458 meshDisplacementNew_rep_->importFromVector(geometrySolution,
true);
460 *w_rep_ = *meshDisplacementNew_rep_;
461 w_rep_->update(-1.0, *meshDisplacementOld_rep_, 1.0);
462 w_rep_->scale( 1.0/dt );
464 u_minus_w_rep_->update( -1.0, *w_rep_, 1.0 );
467 MultiVectorConstPtr_Type pressureSolution = this->solution_->getBlock(1);
468 p_rep_->importFromVector(pressureSolution,
true);
476 if(type ==
"ForTime")
479 std::cout <<
"-- Reassembly (ForTime)" <<
'\n';
482 if(geometryExplicit_)
489 this->problemFluid_->assembleConstantMatrices();
492 P_.reset(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
500 this->feFactory_->assemblyAdditionalConvection( this->dim_, this->domain_FEType_vec_.at(0), P_, w_rep_,
true );
505 P_->fillComplete( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getMapVecFieldUnique());
510 this->system_->addBlock( this->problemFluid_->system_->getBlock(0,1), 0, 1 );
511 this->system_->addBlock( this->problemFluid_->system_->getBlock(1,0), 1, 0 );
512 if (this->problemFluid_->system_->blockExists(1,1))
513 this->system_->addBlock( this->problemFluid_->system_->getBlock(1,1), 1, 1 );
524 MatrixPtr_Type APNW = Teuchos::rcp(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
526 if(geometryExplicit_)
529 if(type ==
"FixedPoint")
531 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::runtime_error,
"should always be called by the residual and never here.");
533 else if(type ==
"Newton")
536 std::cout <<
"-- Reassembly GE (Newton)" <<
'\n';
537 std::cout <<
"-- Reassembly GE (Newton) ... full reassembly" <<
'\n';
540 problemFluid_->reAssemble(
"Newton" );
542 if (materialModel_ !=
"linear")
543 this->problemStructureNonLin_->reAssemble(
"Newton");
549 if(type ==
"FixedPoint")
551 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::runtime_error,
"should always be called by the residual and never here.");
553 else if(type ==
"Newton")
556 std::cout <<
"-- Reassembly GI (Newton)" <<
'\n';
557 std::cout <<
"-- Reassembly GI (Newton) ... only W" <<
'\n';
560 problemFluid_->reAssemble(
"Newton" );
564 MatrixPtr_Type shapeVelocity = Teuchos::rcp(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
565 MatrixPtr_Type shapeDiv = Teuchos::rcp(
new Matrix_Type( this->getDomain(1)->getMapUnique(), this->getDomain(1)->getDimension() * this->getDomain(1)->getApproxEntriesPerRow() ) );
567 this->feFactory_->assemblyShapeDerivativeVelocity(this->dim_, this->domain_FEType_vec_.at(4), this->domain_FEType_vec_.at(1),
568 shapeVelocity, 4, u_rep_, w_rep_, p_rep_, dt, density, viscosity,
true);
569 this->feFactory_->assemblyShapeDerivativeDivergence(this->dim_, this->domain_FEType_vec_.at(4), this->domain_FEType_vec_.at(1),
570 shapeDiv, 1, 4, this->getDomain(1)->getMapUnique(), this->getDomain(4)->getMapVecFieldUnique(), u_rep_,
true);
571 shapeDiv->resumeFill();
572 shapeDiv->scale(-1.0);
573 shapeDiv->fillComplete(this->getDomain(4)->getMapVecFieldUnique(), this->getDomain(1)->getMapUnique());
576 this->system_->addBlock(shapeVelocity, 0, 4);
577 this->system_->addBlock(shapeDiv, 1, 4);
579 if (materialModel_ !=
"linear")
580 this->problemStructureNonLin_->reAssemble(
"Newton");
585 this->system_->addBlock( problemFluid_->getSystem()->getBlock( 0, 0 ), 0, 0 );
587 if (materialModel_ !=
"linear")
588 this->system_->addBlock( this->problemStructureNonLin_->getSystem()->getBlock(0,0), 2, 2 );
591template<
class SC,
class LO,
class GO,
class NO>
592void FSI<SC,LO,GO,NO>::reAssembleExtrapolation(BlockMultiVectorPtrArray_Type previousSolutions)
594 double dt = this->parameterList_->sublist(
"Timestepping Parameter").get(
"dt",0.02);
596 double density = this->problemFluid_->getParameterList()->sublist(
"Parameter").get(
"Density",1.);
601 MultiVectorConstPtr_Type geometrySolution;
602 if(geometryExplicit_)
604 geometrySolution = this->problemGeometry_->getSolution()->getBlock(0);
608 geometrySolution = this->solution_->getBlock(4);
610 meshDisplacementNew_rep_->importFromVector(geometrySolution,
true);
613 *w_rep_ = *meshDisplacementNew_rep_;
615 w_rep_->update(-1.0, *meshDisplacementOld_rep_, 1.0);
616 w_rep_->scale(1.0/dt);
623 if (previousSolutions.size() >= 2)
625 MultiVectorPtr_Type extrapolatedVector = Teuchos::rcp(
new MultiVector_Type( previousSolutions[0]->getBlock(0) ) );
629 extrapolatedVector->update( -1., *previousSolutions[1]->getBlock(0), 2. );
631 u_rep_->importFromVector(extrapolatedVector,
true);
633 else if(previousSolutions.size() == 1)
635 MultiVectorConstPtr_Type u = previousSolutions[0]->getBlock(0);
636 u_rep_->importFromVector(u,
true);
638 else if (previousSolutions.size() == 0)
640 MultiVectorConstPtr_Type u = this->solution_->getBlock(0);
641 u_rep_->importFromVector(u,
true);
645 *u_minus_w_rep_ = *u_rep_;
647 u_minus_w_rep_->update(-1.0, *w_rep_, 1.0);
654 MatrixPtr_Type APN = Teuchos::rcp(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
656 MatrixPtr_Type N = Teuchos::rcp(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
657 this->feFactory_->assemblyAdvectionVecField( this->dim_, this->domain_FEType_vec_.at(0), N, u_minus_w_rep_,
true );
659 P_.reset(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
661 this->feFactory_->assemblyAdditionalConvection( this->dim_, this->domain_FEType_vec_.at(0), P_, w_rep_,
true );
665 P_->fillComplete( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getMapVecFieldUnique());
670 N->fillComplete( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getMapVecFieldUnique());
672 this->problemFluid_->A_->addMatrix(1.0, APN, 0.0);
673 P_->addMatrix(1.0, APN, 1.0);
674 N->addMatrix(1.0, APN, 1.0);
676 APN->fillComplete( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getMapVecFieldUnique() );
678 this->system_->addBlock( APN, 0, 0 );
681template<
class SC,
class LO,
class GO,
class NO>
682void FSI<SC,LO,GO,NO>::calculateNonLinResidualVec(std::string type,
double time)
const
685 MultiVectorConstPtr_Type geometrySolution;
687 if(geometryExplicit_)
688 geometrySolution = this->problemGeometry_->getSolution()->getBlock(0);
691 geometrySolution = this->solution_->getBlock(4);
694 meshDisplacementNew_rep_->importFromVector(geometrySolution,
true);
696 MultiVectorConstPtr_Type fluidSolution = this->solution_->getBlock(0);
697 u_rep_->importFromVector(fluidSolution,
true);
698 u_minus_w_rep_->importFromVector(fluidSolution,
true);
700 *w_rep_ = *meshDisplacementNew_rep_;
701 w_rep_->update(-1.0, *meshDisplacementOld_rep_, 1.0);
702 double dt = this->parameterList_->sublist(
"Timestepping Parameter").get(
"dt",0.02);
703 w_rep_->scale(1.0/dt);
705 u_minus_w_rep_->update(-1.0, *w_rep_, 1.0);
707 if (!geometryExplicit_) {
709 P_.reset(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
710 double density = this->problemTimeFluid_->getParameterList()->sublist(
"Parameter").get(
"Density",1000.e-0);
712 this->feFactory_->assemblyAdditionalConvection( this->dim_, this->domain_FEType_vec_.at(0), P_, w_rep_,
true );
716 P_->fillComplete( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getMapVecFieldUnique());
718 problemFluid_->assembleConstantMatrices();
720 this->system_->addBlock( this->problemFluid_->system_->getBlock(0,1), 0, 1 );
721 this->system_->addBlock( this->problemFluid_->system_->getBlock(1,0), 1, 0 );
722 TEUCHOS_TEST_FOR_EXCEPTION(this->problemFluid_->system_->blockExists(1,1) , std::runtime_error,
"Stabilization is used. Account for it.");
724 if ( this->verbose_ )
725 std::cout <<
"Warning: Wrong consideration of temporal discretization for multi-stage RK methods!" << std::endl;
727 this->problemFluid_->calculateNonLinResidualVecWithMeshVelo(
"reverse", time, u_minus_w_rep_, P_ );
728 this->system_->addBlock( problemFluid_->getSystem()->getBlock( 0, 0 ), 0, 0 );
731 if (materialModel_!=
"linear"){
732 this->problemStructureNonLin_->calculateNonLinResidualVec(
"reverse", time );
733 this->residualVec_->addBlock( this->problemStructureNonLin_->getResidualVector()->getBlockNonConst(0) , 2);
737 MultiVectorPtr_Type residualSolidFSI =
738 Teuchos::rcp_const_cast<MultiVector_Type>( this->residualVec_->getBlock(2) );
739 this->problemStructure_->getSystem()->getBlock(0,0)->apply( *this->problemStructure_->getSolution()->getBlock(0), *residualSolidFSI, Teuchos::NO_TRANS, -1. );
740 MultiVectorPtr_Type resSolidNonConst = Teuchos::rcp_const_cast<MultiVector_Type> ( this->residualVec_->getBlock(2) );
741 resSolidNonConst->update(1., *this->problemStructure_->getRhs()->getBlock(0), 1.);
745 MultiVectorPtr_Type residualFluidVelocityFSI =
746 Teuchos::rcp_const_cast<MultiVector_Type>( this->residualVec_->getBlock(0) );
747 MultiVectorPtr_Type residualSolidFSI =
748 Teuchos::rcp_const_cast<MultiVector_Type>( this->residualVec_->getBlock(2) );
750 MultiVectorPtr_Type residualCouplingFSI =
751 Teuchos::rcp_const_cast<MultiVector_Type>( this->residualVec_->getBlock(3) );
752 residualCouplingFSI->update( 1. , *this->rhs_->getBlock(3), 0. );
755 this->system_->getBlock(0,3)->apply( *this->solution_->getBlock(3) , *residualFluidVelocityFSI, Teuchos::NO_TRANS, -1., 1. );
757 this->system_->getBlock(2,3)->apply( *this->solution_->getBlock(3) , *residualSolidFSI, Teuchos::NO_TRANS, -1., 1. );
759 this->system_->getBlock(3,0)->apply( *this->solution_->getBlock(0) , *residualCouplingFSI, Teuchos::NO_TRANS, -1., 1. );
761 this->system_->getBlock(3,2)->apply( *this->solution_->getBlock(2) , *residualCouplingFSI, Teuchos::NO_TRANS, -1., 1. );
763 if (!geometryExplicit_) {
765 MultiVectorPtr_Type residualGeometryFSI =
766 Teuchos::rcp_const_cast<MultiVector_Type>( this->residualVec_->getBlock(4) );
767 residualGeometryFSI->update( 1. , *this->rhs_->getBlock(4), 0. );
769 this->system_->getBlock(4,4)->apply( *this->solution_->getBlock(4) , *residualGeometryFSI, Teuchos::NO_TRANS, -1., 1. );
771 this->system_->getBlock(4,2)->apply( *this->solution_->getBlock(2) , *residualGeometryFSI, Teuchos::NO_TRANS, -1., 1. );
775 if (type ==
"reverse")
776 this->bcFactory_->setBCMinusVector( this->residualVec_, this->solution_, time );
777 else if (type ==
"standard"){
778 this->residualVec_->scale(-1.);
779 this->bcFactory_->setVectorMinusBC( this->residualVec_, this->solution_, time );
793template<
class SC,
class LO,
class GO,
class NO>
794void FSI<SC,LO,GO,NO>::setFromPartialVectorsInit()
const
798 this->solution_->addBlock( this->problemFluid_->getSolution()->getBlockNonConst(0), 0 );
799 this->residualVec_->addBlock( this->problemFluid_->getResidualVector()->getBlockNonConst(0), 0 );
800 this->residualVec_->addBlock( this->problemFluid_->getResidualVector()->getBlockNonConst(0), 0 );
801 this->rhs_->addBlock( this->problemFluid_->getRhs()->getBlockNonConst(0), 0 );
802 this->sourceTerm_->addBlock( this->problemFluid_->getSourceTerm()->getBlockNonConst(0), 0 );
805 this->solution_->addBlock( this->problemFluid_->getSolution()->getBlockNonConst(1), 1 );
806 this->residualVec_->addBlock( this->problemFluid_->getResidualVector()->getBlockNonConst(1), 1 );
807 this->rhs_->addBlock( this->problemFluid_->getRhs()->getBlockNonConst(1), 1 );
808 this->previousSolution_->addBlock( this->problemFluid_->getPreviousSolution()->getBlockNonConst(1), 1 );
809 this->sourceTerm_->addBlock( this->problemFluid_->getSourceTerm()->getBlockNonConst(1), 1 );
811 if (materialModel_==
"linear"){
812 this->solution_->addBlock( this->problemStructure_->getSolution()->getBlockNonConst(0), 2 );
814 this->rhs_->addBlock( this->problemStructure_->getRhs()->getBlockNonConst(0), 2 );
815 this->sourceTerm_->addBlock( this->problemStructure_->getSourceTerm()->getBlockNonConst(0), 2 );
818 this->solution_->addBlock( this->problemStructureNonLin_->getSolution()->getBlockNonConst(0), 2 );
819 this->residualVec_->addBlock( this->problemStructureNonLin_->getResidualVector()->getBlockNonConst(0), 2 );
820 this->rhs_->addBlock( this->problemStructureNonLin_->getRhs()->getBlockNonConst(0), 2 );
821 this->previousSolution_->addBlock( this->problemStructureNonLin_->getPreviousSolution()->getBlockNonConst(0), 2 );
822 this->sourceTerm_->addBlock( this->problemStructureNonLin_->getSourceTerm()->getBlockNonConst(0), 2 );
825 if(!geometryExplicit_){
826 this->solution_->addBlock( this->problemGeometry_->getSolution()->getBlockNonConst(0), 4 );
828 this->rhs_->addBlock( this->problemGeometry_->getRhs()->getBlockNonConst(0), 4 );
829 this->sourceTerm_->addBlock( this->problemGeometry_->getSourceTerm()->getBlockNonConst(0), 4 );
833template<
class SC,
class LO,
class GO,
class NO>
834void FSI<SC,LO,GO,NO>::updateMeshDisplacement()
const
837 *meshDisplacementOld_rep_ = *meshDisplacementNew_rep_;
842template<
class SC,
class LO,
class GO,
class NO>
843void FSI<SC,LO,GO,NO>::solveGeometryProblem()
const
845 DomainPtr_Type domainFluid = Teuchos::rcp_const_cast<Domain_Type>(this->getDomain(0));
846 DomainPtr_Type domainStruct = Teuchos::rcp_const_cast<Domain_Type>(this->getDomain(2));
849 MapConstPtr_Type interfaceMapFluidVecField = domainFluid->getInterfaceMapVecFieldUnique();
850 MapConstPtr_Type interfaceMapStructureVecField = domainStruct->getInterfaceMapVecFieldUnique();
852 MapConstPtr_Type interfaceMapGlobalFluidVecField = domainFluid->getGlobalInterfaceMapVecFieldUnique();
853 MapConstPtr_Type interfaceMapGlobalStructureVecField = domainStruct->getGlobalInterfaceMapVecFieldUnique();
855 MeshUnstrPtr_Type meshUnstructuredFluid = Teuchos::rcp_dynamic_cast<MeshUnstr_Type>( domainFluid->getMesh() );
856 vec3D_GO_ptr_Type indicesGlobalMatchedOriginFluid = meshUnstructuredFluid->getMeshInterface()->getIndicesGlobalMatchedOrigin();
859 MultiVectorConstPtr_Type struc_sol_unique = this->solution_->getBlock(2);
862 MultiVectorPtr_Type interfaceSolutionStruct = Teuchos::rcp(
new MultiVector_Type( interfaceMapStructureVecField, 1 ) );
866 Teuchos::ArrayRCP< SC > valuesInterface = interfaceSolutionStruct->getDataNonConst(0);
867 Teuchos::ArrayRCP< SC > valuesStructure = struc_sol_unique->getDataNonConst(0);
869 for(UN i = 0; i < valuesInterface.size(); i++)
871 GO interfaceIDGlobal = interfaceMapGlobalStructureVecField->getGlobalElement( i );
891 LO localInterfaceIDinStructure = domainStruct->getMapVecFieldUnique()->getLocalElement(interfaceIDGlobal);
893 valuesInterface[i] = valuesStructure[localInterfaceIDinStructure];
897 MultiVectorPtr_Type interfaceSolutionFluid = Teuchos::rcp(
new MultiVector_Type( interfaceMapFluidVecField, 1 ) );
898 interfaceSolutionFluid->importFromVector( interfaceSolutionStruct );
902 this->problemGeometry_->setBoundariesSystem();
903 this->problemGeometry_->getRhs()->putScalar(0.0);
905 Teuchos::ArrayRCP< SC > valuesInterface = interfaceSolutionFluid->getDataNonConst(0);
906 Teuchos::ArrayRCP< SC > valuesFluidRhs = this->problemGeometry_->getRhs()->getBlock(0)->getDataNonConst(0);
909 for(UN i = 0; i < valuesInterface.size(); i++)
911 GO interfaceIDGlobal = interfaceMapGlobalFluidVecField->getGlobalElement( i );
932 LO localInterfaceIDinFluid = domainFluid->getMapVecFieldUnique()->getLocalElement(interfaceIDGlobal);
934 valuesFluidRhs[localInterfaceIDinFluid] = valuesInterface[i];
939 this->problemGeometry_->solve();
941 if (!exporterGeo_.is_null())
942 this->exporterGeo_->save( this->timeSteppingTool_->currentTime() );
952template<
class SC,
class LO,
class GO,
class NO>
953void FSI<SC,LO,GO,NO>::setupSubTimeProblems(ParameterListPtr_Type parameterListFluid, ParameterListPtr_Type parameterListStructure)
const
956 std::cout <<
"-- Setup FSI Sub-TimeProblems \n" << std::flush;
958 double dt = timeSteppingTool_->get_dt();
959 double beta = timeSteppingTool_->get_beta();
961 int sizeFluid = this->problemFluid_->getSystem()->size();
963 if (materialModel_==
"linear")
964 sizeStructure = this->problemStructure_->getSystem()->size();
966 sizeStructure = this->problemStructureNonLin_->getSystem()->size();
968 problemTimeFluid_.reset(
new TimeProblem<SC,LO,GO,NO>(*this->problemFluid_, this->comm_));
969 if (materialModel_==
"linear")
970 problemTimeStructure_.reset(
new TimeProblem<SC,LO,GO,NO>(*this->problemStructure_, this->comm_));
972 problemTimeStructure_.reset(
new TimeProblem<SC,LO,GO,NO>(*this->problemStructureNonLin_, this->comm_));
977 SmallMatrix<double> massCoeffFluid(sizeFluid);
978 SmallMatrix<double> problemCoeffFluid(sizeFluid);
979 SmallMatrix<int> defFluid(sizeFluid);
981 double coeffSourceTermFluid = 0.0;
982 if ( this->getParameterList()->sublist(
"Timestepping Parameter").get(
"Class",
"Multistep") ==
"Multistep" ) {
983 for (
int i=0; i<sizeFluid; i++) {
984 for (
int j=0; j<sizeFluid; j++) {
985 if ((*defTS_)[i][j]==1 && i==j) {
987 massCoeffFluid[i][j] = timeSteppingTool_->getInformationBDF(0) / dt;
990 massCoeffFluid[i][j] = 0.0;
994 for (
int i=0; i<sizeFluid; i++) {
995 for (
int j=0; j<sizeFluid; j++){
996 if ((*defTS_)[i][j]==1){
997 problemCoeffFluid[i][j] = timeSteppingTool_->getInformationBDF(1);
998 coeffSourceTermFluid = timeSteppingTool_->getInformationBDF(1);
1001 problemCoeffFluid[i][j] = 1.;
1005 this->problemTimeFluid_->setTimeDef(defFluid);
1006 this->problemTimeFluid_->setTimeParameters(massCoeffFluid,problemCoeffFluid);
1009 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Implement other FSI fluid time stepping than BDF.");
1015 SmallMatrix<double> massCoeffStructure(sizeStructure);
1016 SmallMatrix<double> problemCoeffStructure(sizeStructure);
1017 SmallMatrix<int> defStructure(sizeStructure);
1018 double coeffSourceTermStructure = 0.0;
1021 for(
int i = 0; i < sizeStructure; i++)
1023 for(
int j = 0; j < sizeStructure; j++)
1027 if((*defTS_)[i + sizeFluid][j + sizeFluid] == 1 && i == j)
1029 defStructure[i][j] = 1;
1031 massCoeffStructure[i][j] = 1.0/(dt*dt*beta);
1035 massCoeffStructure[i][j] = 0.;
1041 for(
int i = 0; i < sizeStructure; i++)
1043 for(
int j = 0; j < sizeStructure; j++)
1045 if((*defTS_)[i + sizeFluid][j + sizeFluid] == 1)
1047 problemCoeffStructure[i][j] = 1.0;
1049 coeffSourceTermStructure = 1.0;
1053 problemCoeffStructure[i][j] = 1.0;
1057 this->problemTimeStructure_->setTimeDef(defStructure);
1058 this->problemTimeStructure_->setTimeParameters(massCoeffStructure,problemCoeffStructure);
1060 this->problemTimeFluid_->assemble(
"MassSystem" );
1061 this->problemTimeStructure_->assemble(
"MassSystem" );
1065template<
class SC,
class LO,
class GO,
class NO>
1066void FSI<SC,LO,GO,NO>::setFluidMassmatrix( MatrixPtr_Type& massmatrix )
const
1071 double density = this->problemTimeFluid_->getParameterList()->sublist(
"Parameter").get(
"Density",1000.e-0);
1072 int size = this->problemTimeFluid_->getSystem()->size();
1074 this->problemTimeFluid_->systemMass_.reset(
new BlockMatrix_Type(size));
1076 massmatrix = Teuchos::rcp(
new Matrix_Type( this->problemTimeFluid_->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getApproxEntriesPerRow() ) );
1078 this->feFactory_->assemblyMass( this->dim_, this->problemTimeFluid_->getFEType(0),
"Vector", massmatrix, 0,
true );
1079 massmatrix->resumeFill();
1080 massmatrix->scale(density);
1081 massmatrix->fillComplete( this->problemTimeFluid_->getDomain(0)->getMapVecFieldUnique(), this->problemTimeFluid_->getDomain(0)->getMapVecFieldUnique() );
1083 this->problemTimeFluid_->systemMass_->addBlock(massmatrix, 0, 0);
1089template<
class SC,
class LO,
class GO,
class NO>
1090void FSI<SC,LO,GO,NO>::computeFluidRHSInTime( )
const
1095 int sizeFluid = this->problemFluid_->getSystem()->size();
1096 double dt = timeSteppingTool_->get_dt();
1097 int nmbBDF = timeSteppingTool_->getBDFNumber();
1099 vec_dbl_Type coeffPrevSteps(nmbBDF);
1100 for(
int i = 0; i < coeffPrevSteps.size(); i++)
1102 coeffPrevSteps.at(i) = timeSteppingTool_->getInformationBDF(i+2) / dt;
1105 if (timeSteppingTool_->currentTime()==0.) {
1106 SmallMatrix<double> tmpmassCoeff(sizeFluid);
1107 SmallMatrix<double> tmpproblemCoeff(sizeFluid);
1108 for (
int i=0; i<sizeFluid; i++) {
1109 for (
int j=0; j<sizeFluid; j++) {
1110 if ((*defTS_)[i][j]==1 && i==j) {
1111 tmpmassCoeff[i][j] = 1. / dt;
1114 tmpmassCoeff[i][j] = 0.;
1118 for (
int i=0; i<sizeFluid; i++) {
1119 for (
int j=0; j<sizeFluid; j++){
1120 if ((*defTS_)[i][j]==1){
1121 tmpproblemCoeff[i][j] = 1.;
1124 tmpproblemCoeff[i][j] = 1.;
1128 this->problemTimeFluid_->setTimeParameters(tmpmassCoeff, tmpproblemCoeff);
1130 if (timeSteppingTool_->currentTime()==0.) {
1131 vec_dbl_Type tmpcoeffPrevSteps(1, 1. / dt);
1132 this->problemTimeFluid_->updateMultistepRhsFSI(tmpcoeffPrevSteps,1);
1135 this->problemTimeFluid_->updateMultistepRhsFSI(coeffPrevSteps,nmbBDF);
1139 if (this->problemTimeFluid_->hasSourceTerm()) {
1140 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Check sourceterm.");
1145 if (timeSteppingTool_->currentTime()==0.) {
1146 SmallMatrix<double> massCoeffFluid(sizeFluid);
1147 SmallMatrix<double> problemCoeffFluid(sizeFluid);
1149 for (
int i=0; i<sizeFluid; i++) {
1150 for (
int j=0; j<sizeFluid; j++) {
1151 if ((*defTS_)[i][j]==1 && i==j) {
1152 massCoeffFluid[i][j] = timeSteppingTool_->getInformationBDF(0) / dt;
1155 massCoeffFluid[i][j] = 0.0;
1159 for (
int i=0; i<sizeFluid; i++) {
1160 for (
int j=0; j<sizeFluid; j++){
1161 if ((*defTS_)[i][j]==1){
1162 problemCoeffFluid[i][j] = timeSteppingTool_->getInformationBDF(1);
1165 problemCoeffFluid[i][j] = 1.;
1170 this->problemTimeFluid_->setTimeParameters(massCoeffFluid, problemCoeffFluid);
1178template<
class SC,
class LO,
class GO,
class NO>
1179void FSI<SC,LO,GO,NO>::updateFluidInTime()
const
1181 int nmbBDF = timeSteppingTool_->getBDFNumber();
1183 if(nmbBDF<2 && !this->parameterList_->sublist(
"General").get(
"Linearization",
"FixedPoint").compare(
"Extrapolation")) {
1184 if (timeSteppingTool_->currentTime()!=0.){
1185 this->problemTimeFluid_->updateSolutionMultiPreviousStep(2);
1186 this->problemTimeFluid_->updateSystemMassMultiPreviousStep(2);
1189 this->problemTimeFluid_->updateSolutionMultiPreviousStep(1);
1190 this->problemTimeFluid_->updateSystemMassMultiPreviousStep(1);
1194 this->problemTimeFluid_->updateSolutionMultiPreviousStep(nmbBDF);
1195 this->problemTimeFluid_->updateSystemMassMultiPreviousStep(nmbBDF);
1199template<
class SC,
class LO,
class GO,
class NO>
1200void FSI<SC,LO,GO,NO>::computeSolidRHSInTime()
const {
1204 double dt = timeSteppingTool_->get_dt();
1205 double beta = timeSteppingTool_->get_beta();
1206 double gamma = timeSteppingTool_->get_gamma();
1209 vec_dbl_Type coeffTemp(1);
1210 coeffTemp.at(0) = 1.0;
1213 this->problemTimeStructure_->updateSolutionNewmarkPreviousStep(dt, beta, gamma);
1219 this->problemTimeStructure_->updateNewmarkRhs(dt, beta, gamma, coeffTemp);
1222 double time = timeSteppingTool_->currentTime() + dt;
1226 if (this->problemTimeStructure_->hasSourceTerm())
1228 this->problemTimeStructure_->assembleSourceTerm( time );
1234 double coeffSourceTermStructure = 1.0;
1235 BlockMultiVectorPtr_Type tmpPtr = this->problemTimeStructure_->getSourceTerm();
1236 this->problemTimeStructure_->getRhs()->update(coeffSourceTermStructure, *tmpPtr, 1.);
1241template<
class SC,
class LO,
class GO,
class NO>
1242void FSI<SC,LO,GO,NO>::setSolidMassmatrix( MatrixPtr_Type& massmatrix )
const
1247 double density = this->problemTimeStructure_->getParameterList()->sublist(
"Parameter").get(
"Density",1000.e-0);
1248 int size = this->problemTimeStructure_->getSystem()->size();
1250 if(timeSteppingTool_->currentTime() == 0.0)
1252 this->problemTimeStructure_->systemMass_.reset(
new BlockMatrix_Type(size));
1255 massmatrix = Teuchos::rcp(
new Matrix_Type( this->problemTimeStructure_->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getApproxEntriesPerRow() ) );
1257 this->feFactory_->assemblyMass(this->dim_, this->problemTimeStructure_->getFEType(0),
"Vector", massmatrix, 2,
true);
1258 massmatrix->resumeFill();
1259 massmatrix->scale(density);
1260 massmatrix->fillComplete( this->problemTimeStructure_->getDomain(0)->getMapVecFieldUnique(), this->problemTimeStructure_->getDomain(0)->getMapVecFieldUnique());
1262 this->problemTimeStructure_->systemMass_->addBlock( massmatrix, 0, 0 );
1269template<
class SC,
class LO,
class GO,
class NO>
1270void FSI<SC,LO,GO,NO>::updateTime()
const
1272 timeSteppingTool_->t_ = timeSteppingTool_->t_ + timeSteppingTool_->dt_prev_;
1275template<
class SC,
class LO,
class GO,
class NO>
1276void FSI<SC,LO,GO,NO>::moveMesh()
const
1279 MultiVectorConstPtr_Type displacementUniqueConst;
1280 if(geometryExplicit_)
1282 displacementUniqueConst = this->problemGeometry_->getSolution()->getBlock(0);
1286 displacementUniqueConst = this->solution_->getBlock(4);
1288 MultiVectorPtr_Type displacementRepeated = Teuchos::rcp(
new MultiVector_Type( this->problemGeometry_->getDomain(0)->getMapVecFieldRepeated() ) );
1290 displacementRepeated->importFromVector( displacementUniqueConst );
1291 MultiVectorPtr_Type displacementUnique = Teuchos::rcp_const_cast<MultiVector_Type>(displacementUniqueConst);
1298 ( Teuchos::rcp_const_cast<Domain_Type>(this->getDomain(0)) )->moveMesh(displacementUnique, displacementRepeated);
1299 ( Teuchos::rcp_const_cast<Domain_Type>(this->getDomain(1)) )->moveMesh(displacementUnique, displacementRepeated);
1300 ( Teuchos::rcp_const_cast<Domain_Type>(this->problemFluid_->getDomain(0)) )->moveMesh(displacementUnique, displacementRepeated);
1301 ( Teuchos::rcp_const_cast<Domain_Type>(this->problemFluid_->getDomain(1)) )->moveMesh(displacementUnique, displacementRepeated);
1302 ( Teuchos::rcp_const_cast<Domain_Type>(this->problemTimeFluid_->getDomain(0)) )->moveMesh(displacementUnique, displacementRepeated);
1303 ( Teuchos::rcp_const_cast<Domain_Type>(this->problemTimeFluid_->getDomain(1)) )->moveMesh(displacementUnique, displacementRepeated);
1307template<
class SC,
class LO,
class GO,
class NO>
1308void FSI<SC,LO,GO,NO>::addInterfaceBlockRHS()
const
1310 MultiVectorPtr_Type vectorToAdd = Teuchos::rcp(
new MultiVector_Type( this->rhs_->getBlock(3) ) );
1312 C2_->apply(*(this->solution_->getBlock(2)), *vectorToAdd);
1313 this->rhs_->addBlock(vectorToAdd, 3);
1317template<
class SC,
class LO,
class GO,
class NO>
1318void FSI<SC,LO,GO,NO>::evalModelImpl(
const Thyra::ModelEvaluatorBase::InArgs<SC> &inArgs,
1319 const Thyra::ModelEvaluatorBase::OutArgs<SC> &outArgs
1322 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"implement NOX for steady FSI.");
1323 std::string type = this->parameterList_->sublist(
"General").get(
"Preconditioner Method",
"Monolithic");
1333template<
class SC,
class LO,
class GO,
class NO>
1334void FSI<SC,LO,GO,NO>::getValuesOfInterest( vec_dbl_Type& values ){
1336 getValuesOfInterest2DBenchmark( values );
1337 else if(this->dim_==3)
1338 getValuesOfInterest3DBenchmark( values);
1342template<
class SC,
class LO,
class GO,
class NO>
1343void FSI<SC,LO,GO,NO>::getValuesOfInterest2DBenchmark( vec_dbl_Type& values ){
1346 if ( valuesForExport_[0] >= 0. ) {
1347 LO loc = valuesForExport_[0] + 10*Teuchos::ScalarTraits<SC>::eps();
1348 values[0] = this->getSolution()->getBlock(2)->getData(0)[2*loc];
1349 values[1] = this->getSolution()->getBlock(2)->getData(0)[2*loc+1];
1353template<
class SC,
class LO,
class GO,
class NO>
1354void FSI<SC,LO,GO,NO>::getValuesOfInterest3DBenchmark( vec_dbl_Type& values ){
1356 if ( valuesForExport_[0] >= 0. ) {
1357 LO loc = valuesForExport_[0] + 10*Teuchos::ScalarTraits<SC>::eps();
1358 values[0] = this->getSolution()->getBlock(2)->getData(0)[3*loc];
1359 values[1] = this->getSolution()->getBlock(2)->getData(0)[3*loc+1];
1360 values[2] = this->getSolution()->getBlock(2)->getData(0)[3*loc+2];
1364template<
class SC,
class LO,
class GO,
class NO>
1365void FSI<SC,LO,GO,NO>::computeValuesOfInterestAndExport(){
1366 if ( this->getParameterList()->sublist(
"General").get(
"Export drag and lift",
false) ) {
1368 int dim = this->dim_;
1369 TEUCHOS_TEST_FOR_EXCEPTION( this->parameterList_->sublist(
"Parameter").get(
"Criterion",
"Residual") ==
"Update", std::runtime_error,
"Wrong nonlinear criterion to calculate the drag coefficient. The last system is the Newton system but we need the fixed point system. Either use Criterion=Residual or implement for Criterion=Update." );
1371 TEUCHOS_TEST_FOR_EXCEPTION( this->problemFluid_->hasSourceTerm(), std::runtime_error,
"We need to substract the additional source term: drag = < F*u + B_T*p + C1_T*lamba - f, v >" );
1373 Teuchos::Array<SC> drag(1);
1374 Teuchos::Array<SC> lift(1);
1376 BlockMultiVectorPtr_Type uDrag = Teuchos::rcp(
new BlockMultiVector_Type( this->problemFluid_->getSolution() ) );
1377 BlockMultiVectorPtr_Type uLift = Teuchos::rcp(
new BlockMultiVector_Type( this->problemFluid_->getSolution() ) );
1380 this->problemFluid_->assembleDivAndStab();
1382 this->problemFluid_->getSystem()->apply( *this->problemFluid_->getSolution(), *uDrag );
1383 this->problemFluid_->getSystem()->apply( *this->problemFluid_->getSolution(), *uLift );
1385 MultiVectorPtr_Type C1T_lambda = Teuchos::rcp(
new MultiVector_Type( this->getSolution()->getBlock(0) ) );
1386 this->system_->getBlock(0,3)->apply( *this->getSolution()->getBlock(3), *C1T_lambda );
1388 uDrag->getBlockNonConst(0)->update( 1., *C1T_lambda, 1. );
1389 uLift->getBlockNonConst(0)->update( 1., *C1T_lambda, 1. );
1391 BCPtr_Type bcFactoryDrag = Teuchos::rcp(
new BC_Type( ) );
1392 BCPtr_Type bcFactoryLift = Teuchos::rcp(
new BC_Type( ) );
1394 DomainConstPtr_Type domainVelocityConst = this->problemFluid_->getDomain(0);
1395 DomainPtr_Type domainVelocity = Teuchos::rcp_const_cast<Domain_Type>(domainVelocityConst);
1397 bcFactoryDrag->addBC(drag2D, 4, 0, domainVelocity,
"Dirichlet", dim);
1398 bcFactoryDrag->addBC(drag2D, 5, 0, domainVelocity,
"Dirichlet", dim);
1399 bcFactoryLift->addBC(lift2D, 4, 0, domainVelocity,
"Dirichlet", dim);
1400 bcFactoryLift->addBC(lift2D, 5, 0, domainVelocity,
"Dirichlet", dim);
1402 else if( dim == 3 ){
1403 bcFactoryDrag->addBC(drag3D, 3, 0, domainVelocity,
"Dirichlet", dim);
1404 bcFactoryDrag->addBC(drag3D, 6, 0, domainVelocity,
"Dirichlet", dim);
1405 bcFactoryLift->addBC(lift3D, 3, 0, domainVelocity,
"Dirichlet", dim);
1406 bcFactoryLift->addBC(lift3D, 6, 0, domainVelocity,
"Dirichlet", dim);
1409 BlockMultiVectorPtr_Type vD = Teuchos::rcp(
new BlockMultiVector_Type( this->problemFluid_->getSolution() ) );
1410 BlockMultiVectorPtr_Type vL = Teuchos::rcp(
new BlockMultiVector_Type( this->problemFluid_->getSolution() ) );
1415 bcFactoryDrag->setRHS( vD );
1416 bcFactoryLift->setRHS( vL );
1418 uDrag->dot( vD, drag() );
1419 uLift->dot( vL, lift() );
1435 exporterTxtDrag_->exportData( drag[0] );
1436 exporterTxtLift_->exportData( lift[0] );
1440template<
class SC,
class LO,
class GO,
class NO>
1441void FSI<SC,LO,GO,NO>::initializeGE(){
1445 if (geometryExplicit_) {
1446 this->solution_->resize( 4 );
1447 this->rhs_->resize( 4 );
1448 this->sourceTerm_->resize( 4 );
1449 this->rhsFuncVec_.resize( 4 );
1450 this->previousSolution_->resize( 4 );
1451 this->residualVec_->resize( 4 );
1452 this->initVectorSpaces();
Definition NonLinearProblem_decl.hpp:24
This class represents a templated small Matrix of type T. Primarily created for 2x2 and 3x3 matrices....
Definition SmallMatrix.hpp:22
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement.cpp:5