1 #include <lifev/navier_stokes_blocks/solver/NavierStokesOperator.hpp> 7 NavierStokesOperator::NavierStokesOperator():
8 M_name(
"NavierStokesOperator"),
14 void NavierStokesOperator::setUp(
const std::shared_ptr<BlockEpetra_Map> & map,
const commPtr_Type & comm)
18 M_nBlockRows = map->nBlocks();
19 M_nBlockCols = M_nBlockRows;
21 M_rangeMap = M_domainMap;
22 M_oper.resize(M_nBlockRows, M_nBlockCols);
27 void NavierStokesOperator::setUp(
const std::shared_ptr<BlockEpetra_Map> & domainMap,
28 const std::shared_ptr<BlockEpetra_Map> & rangeMap,
29 const commPtr_Type & comm)
33 M_nBlockRows = rangeMap->nBlocks();
34 M_nBlockCols = domainMap->nBlocks();
36 M_domainMap = domainMap;
37 M_rangeMap = rangeMap;
39 M_oper.resize(M_nBlockRows, M_nBlockCols);
44 void NavierStokesOperator::setUp(
const operatorPtrContainer_Type & blockOper,
const commPtr_Type & comm)
47 M_nBlockRows = blockOper.size1();
48 M_nBlockCols = blockOper.size2();
53 for(
UInt iblock=0; iblock < M_nBlockRows; ++iblock)
54 for(
UInt jblock=0; jblock < M_nBlockCols; ++jblock)
56 if(blockOper(iblock,jblock) != 0 && rangeBlockMaps[iblock]==0)
58 rangeBlockMaps[iblock].reset(
new Epetra_Map(blockOper(iblock,jblock)->OperatorRangeMap() ));
59 jblock = M_nBlockCols;
63 for(
UInt jblock=0; jblock < M_nBlockCols; ++jblock)
64 for(
UInt iblock=0; iblock < M_nBlockRows; ++iblock)
66 if(blockOper(iblock,jblock) != 0 && domainBlockMaps[jblock]==0)
68 domainBlockMaps[jblock].reset(
new Epetra_Map(blockOper(iblock,jblock)->OperatorDomainMap() ));
69 iblock = M_nBlockRows;
73 M_domainMap.reset(
new BlockEpetra_Map(domainBlockMaps));
74 M_rangeMap.reset(
new BlockEpetra_Map(rangeBlockMaps));
82 void NavierStokesOperator::setBlock(
UInt iblock,
UInt jblock,
const operatorPtr_Type & operBlock)
84 ASSERT_PRE(M_rangeMap->blockMap(iblock)->PointSameAs(operBlock->OperatorRangeMap()),
"Wrong range map");
85 ASSERT_PRE(M_domainMap->blockMap(jblock)->PointSameAs(operBlock->OperatorDomainMap()),
"Wrong domain map");
87 M_oper(iblock, jblock) = operBlock;
91 void NavierStokesOperator::fillComplete()
94 for(
UInt iblock = 0; iblock < M_nBlockRows; ++iblock)
95 for(
UInt jblock = 0; jblock < M_nBlockCols; ++jblock)
97 if(M_oper(iblock,jblock).get() == 0)
100 nullOp->setUp(M_domainMap->blockMap(jblock), M_rangeMap->blockMap(iblock) );
101 M_oper(iblock,jblock).reset(nullOp);
103 ASSERT(M_rangeMap->blockMap(iblock)->PointSameAs(M_oper(iblock,jblock)->OperatorRangeMap()),
"Wrong range map");
104 ASSERT(M_domainMap->blockMap(jblock)->PointSameAs(M_oper(iblock,jblock)->OperatorDomainMap()),
"Wrong domain map");
108 int NavierStokesOperator::SetUseTranspose(
bool useTranspose)
110 M_useTranspose = useTranspose;
111 #ifdef HAVE_LIFEV_DEBUG 113 for (UInt i(0); i<M_nBlockRows; ++i)
114 for (UInt j(0); j<M_nBlockCols; ++j)
116 EPETRA_CHK_ERR(M_oper(i,j)->SetUseTranspose(
true));
117 EPETRA_CHK_ERR(M_oper(i,j)->SetUseTranspose(
false));
123 int NavierStokesOperator::Apply(
const vector_Type & X, vector_Type & Y)
const 127 error = applyTranspose(X,Y);
129 error = applyNoTranspose(X,Y);
133 int NavierStokesOperator::ApplyInverse(
const vector_Type & X, vector_Type & Y)
const 139 const NavierStokesOperator::operatorPtr_Type& NavierStokesOperator::block(
UInt iblock,
UInt jblock)
const 141 ASSERT (iblock<M_nBlockRows,
"Error! Index out of bounds.\n");
142 ASSERT (jblock<M_nBlockCols,
"Error! Index out of bounds.\n");
143 return M_oper(iblock,jblock);
152 int NavierStokesOperator::applyNoTranspose(
const vector_Type & X, vector_Type & Y)
const 154 ASSERT_PRE(X.Map().SameAs(*(M_domainMap->monolithicMap())),
"The map of X is not conforming with domain map.");
155 ASSERT_PRE(Y.Map().SameAs(*(M_rangeMap->monolithicMap())),
"The map of Y is not conforming with range map.");
156 ASSERT_PRE(X.NumVectors() == Y.NumVectors(),
"The number of vectors in X and Y is different" );
158 const std::unique_ptr<BlockEpetra_MultiVector> Xview( createBlockView(X, *M_domainMap) );
159 const std::unique_ptr<BlockEpetra_MultiVector> Yview( createBlockView(Y, *M_rangeMap) );
162 Yview->PutScalar(0.0);
166 for(
UInt iblock=0; iblock < M_nBlockRows; ++iblock)
167 for(
UInt jblock=0; jblock < M_nBlockCols; ++jblock)
169 EPETRA_CHK_ERR(M_oper(iblock, jblock)->Apply(Xview->block(jblock), tmpY.block(iblock) ));
170 EPETRA_CHK_ERR(Yview->block(iblock).Update(1.0, tmpY.block(iblock), 1.0));
176 int NavierStokesOperator::applyTranspose(
const vector_Type & X, vector_Type & Y)
const 178 ASSERT_PRE(X.Map().SameAs(*(M_rangeMap->monolithicMap())),
"The map of X is not conforming with domain map.");
179 ASSERT_PRE(Y.Map().SameAs(*(M_domainMap->monolithicMap())),
"The map of Y is not conforming with range map.");
180 ASSERT_PRE(X.NumVectors() == Y.NumVectors(),
"The number of vectors in X and Y is different" );
182 const std::unique_ptr<BlockEpetra_MultiVector> Xview( createBlockView(X, *M_rangeMap) );
183 const std::unique_ptr<BlockEpetra_MultiVector> Yview( createBlockView(Y, *M_domainMap) );
186 Yview->PutScalar(0.0);
189 for(
UInt iblock=0; iblock < M_nBlockCols; ++iblock)
190 for(
UInt jblock=0; jblock < M_nBlockRows; ++jblock)
192 EPETRA_CHK_ERR(M_oper(iblock,jblock)->SetUseTranspose(
true));
193 EPETRA_CHK_ERR(M_oper(iblock, jblock)->Apply(Xview->block(jblock), tmpY.block(iblock) ));
194 EPETRA_CHK_ERR(Yview->block(iblock).Update(1.0, tmpY.block(iblock), 1.0));
195 EPETRA_CHK_ERR(M_oper(iblock,jblock)->SetUseTranspose(
false));
This class handles block access to parallel monolithic Vectors with an underling block structure...
void updateInverseJacobian(const UInt &iQuadPt)
std::vector< mapPtr_Type > mapPtrContainer_Type
A derived class from Epetra_MultiVector specialized to handle parallel block structured Vectors...
uint32_type UInt
generic unsigned integer (used mainly for addressing)