13#include "feddlib/core/FE/Domain.hpp"
14#include "feddlib//core/FE/FE.hpp"
15#include "feddlib/problems/Solver/Preconditioner.hpp"
18void ZeroDirichlet(
double* x,
double* res,
double t,
double* parameters){
25double OneFunction(
double* x,
int* parameter)
30template<
class SC,
class LO,
class GO,
class NO>
31Stokes<SC,LO,GO,NO>::Stokes(
const DomainConstPtr_Type &domainVelocity, std::string FETypeVelocity,
const DomainConstPtr_Type &domainPressure, std::string FETypePressure, ParameterListPtr_Type parameterList):
32Problem<SC,LO,GO,NO>(parameterList, domainVelocity->getComm())
35 this->addVariable( domainVelocity , FETypeVelocity ,
"u" , domainVelocity->getDimension());
36 this->addVariable( domainPressure , FETypePressure ,
"p" , 1);
38 this->dim_ = this->getDomain(0)->getDimension();
41template<
class SC,
class LO,
class GO,
class NO>
42Stokes<SC,LO,GO,NO>::~Stokes(){
46template<
class SC,
class LO,
class GO,
class NO>
47void Stokes<SC,LO,GO,NO>::info(){
51template<
class SC,
class LO,
class GO,
class NO>
52void Stokes<SC,LO,GO,NO>::assemble( std::string type )
const{
55 std::cout <<
"-- Assembly ... " << std::flush;
57 double viscosity = this->parameterList_->sublist(
"Parameter").get(
"Viscosity",1.);
59 MatrixPtr_Type A(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getApproxEntriesPerRow() ) );
60 MatrixPtr_Type BT(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(1)->getDimension() * this->getDomain(1)->getApproxEntriesPerRow() ) );
62 MapConstPtr_Type pressureMap;
63 if ( this->getDomain(1)->getFEType() ==
"P0" )
64 pressureMap = this->getDomain(1)->getElementMap();
66 pressureMap = this->getDomain(1)->getMapUnique();
68 MatrixPtr_Type B(
new Matrix_Type( pressureMap, this->getDomain(0)->getDimension() * this->getDomain(0)->getApproxEntriesPerRow() ) );
72 std::cout <<
" A ... " << std::flush;
74 if ( this->parameterList_->sublist(
"Parameter").get(
"Symmetric gradient",
false) )
75 this->feFactory_->assemblyStress(this->dim_, this->domain_FEType_vec_.at(0), A, OneFunction, dummy,
true);
77 this->feFactory_->assemblyLaplaceVecField(this->dim_, this->domain_FEType_vec_.at(0), 2, A,
true);
80 std::cout <<
"B and B^T ... " << std::flush;
82 this->feFactory_->assemblyDivAndDivT(this->dim_, this->getFEType(0), this->getFEType(1), 2, B, BT, this->getDomain(0)->getMapVecFieldUnique(), pressureMap,
true );
92 A->fillComplete( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getMapVecFieldUnique());
93 B->fillComplete( this->getDomain(0)->getMapVecFieldUnique(), pressureMap );
94 BT->fillComplete( pressureMap, this->getDomain(0)->getMapVecFieldUnique() );
96 this->system_.reset(
new BlockMatrix_Type(2));
98 this->system_->addBlock( A, 0, 0 );
99 this->system_->addBlock( BT, 0, 1 );
100 this->system_->addBlock( B, 1, 0 );
104 if ( !this->getFEType(0).compare(
"P1") ) {
105 C.reset(
new Matrix_Type( this->getDomain(1)->getMapUnique(), this->getDomain(1)->getApproxEntriesPerRow() ) );
106 this->feFactory_->assemblyBDStabilization( this->dim_,
"P1", C,
true);
108 C->scale( -1./viscosity );
109 C->fillComplete( pressureMap, pressureMap );
110 this->system_->addBlock( C, 1, 1 );
113 if ( !this->parameterList_->sublist(
"General").get(
"Preconditioner Method",
"Monolithic").compare(
"Teko") ) {
114 if (!this->parameterList_->sublist(
"General").get(
"Assemble Velocity Mass",
false)) {
115 MatrixPtr_Type Mvelocity(
new Matrix_Type( this->getDomain(0)->getMapVecFieldUnique(), this->getDomain(0)->getApproxEntriesPerRow() ) );
117 this->feFactory_->assemblyMass( this->dim_, this->domain_FEType_vec_.at(0),
"Vector", Mvelocity,
true );
119 this->getPreconditionerConst()->setVelocityMassMatrix( Mvelocity );
121 std::cout <<
"\nVelocity mass matrix for LSC block preconditioner is assembled." << std::endl;
124 std::cout <<
"\nVelocity mass matrix for LSC block preconditioner not assembled." << std::endl;
128 std::string precType = this->parameterList_->sublist(
"General").get(
"Preconditioner Method",
"Monolithic");
129 if ( precType ==
"Diagonal" || precType ==
"Triangular" ) {
130 MatrixPtr_Type Mpressure(
new Matrix_Type( this->getDomain(1)->getMapUnique(), this->getDomain(1)->getApproxEntriesPerRow() ) );
132 this->feFactory_->assemblyMass( this->dim_, this->domain_FEType_vec_.at(1),
"Scalar", Mpressure,
true );
134 Mpressure->resumeFill();
135 Mpressure->scale(-1./viscosity);
136 Mpressure->fillComplete( pressureMap, pressureMap );
137 this->getPreconditionerConst()->setPressureMassMatrix( Mpressure );
140 this->assembleSourceTerm( 0. );
141 this->addToRhs( this->sourceTerm_ );
145 std::cout <<
"done -- " << std::endl;
Definition Problem_decl.hpp:42
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement_decl.hpp:36