19 #ifndef la_bddcml_wrapper_h
20 #define la_bddcml_wrapper_h
22 #include <boost/numeric/ublas/matrix.hpp>
23 #include <boost/numeric/ublas/vector.hpp>
34 #ifdef FLOW123D_HAVE_BDDCML
36 #include <bddcml_interface_c.h>
43 namespace ublas = boost::numeric::ublas;
47 template<
typename DOFHOLDER,
typename MAPTYPE >
50 unsigned globalIndex = np -> giveId( );
52 typename MAPTYPE::iterator pos =
map.find( globalIndex );
54 .error(
"Cannot remap node 'globalIndex' to local indices. \n");
55 int localIndexInt = pos -> second;
108 const unsigned numDofsSub,
126 const int meshDim = 0 );
157 void fixDOF(
const unsigned index,
const double scalar = 1. );
172 int verboseLevel = 0,
179 bool use_adaptive =
false
218 { std::fill(
sol_.begin( ),
sol_.end( ), 0. );
237 template<
typename VEC1,
typename VEC2>
238 void giveSolution(
const VEC1 & dofIndices, VEC2 & result )
const;
304 template<
typename VEC1,
typename VEC2>
306 VEC2 & result )
const
309 typename VEC1::const_iterator dofIter = dofIndices.begin();
310 typename VEC1::const_iterator dofEnd = dofIndices.end();
311 typename VEC2::iterator valIter = result.begin();
312 for ( ; dofIter != dofEnd; ++dofIter ) {
317 .error(
"Cannot remap index dofIter to local indices in solution distribution. \n ");
318 unsigned indLoc = pos -> second;
321 *valIter++ =
sol_[ indLoc ];
#define ASSERT_PERMANENT(expr)
Allow use shorter versions of macro names if these names is not used with external library.
Multilevel BDDC based linear system solver.
const int numDofsSub_
number of subdomain dofs
void clearRhs()
Fill RHS with zeros.
double normSol_
norm of the global solution
std::vector< int > isvgvn_
Indices of Subdomain Variables in Global Variable Numbering ( i.e. dof mapping )
bool isMatAssembled_
true if matrix is assembled
void destroyRhs()
Destroy RHS.
std::vector< double > sol_
distributed solution vector
la::MatrixCoo< int, double > coo_
matrix in coordinate format (COO)
int nProc_
number of processors in communicator
ublas::vector< double > SubVec_
la::MatrixCoo< int, double > diagWeightsCoo_
diagonal of subdomain matrix in sparse format and global numbers
int numIter_
required number of iterations
double giveCondNumber()
Give estimate of condition number.
void clearBC()
Blank arrays for boundary conditions.
void clearMatrix()
Fill matrix with zeros.
double normRhs()
Get norm of right-hand side.
std::vector< double > element_data_
array with data on elements, here used for permeability for each element
double normSol()
Get norm of solution.
int rank_
ID of processors in communicator.
void insertToMatrix(const SubMat_ &eStiff, const VecUint_ &rowIndices, const VecUint_ &colIndices)
insert submatrix to system matrix - into coordinate matrix object
void destroyBC()
Destroy boundary conditions.
std::vector< double > xyz_
void destroySol()
Destroy solution.
enum matrixTypeEnum MatrixType
double normRhs_
norm of the global right-hand side
void solveSystem(double tol=1.e-7, int numLevels=2, std::vector< int > *numSubAtLevels=NULL, int verboseLevel=0, int maxIt=1000, int ndecrMax=30, bool use_adaptive=false)
Solve the system.
std::vector< double > fixv_
values of fixed boundary conditions at places of ifix_ - values outside fixed dofs are ignored
void giveSolution(const VEC1 &dofIndices, VEC2 &result) const
Give access to the solution vector.
void destroyMatrix()
Destroy matrix.
@ SPD
symmetric positive definite,
@ GENERAL
general (default),
@ SPD_VIA_SYMMETRICGENERAL
@ SYMMETRICGENERAL
general symmetric ( e.g. saddle point ),
std::vector< int > isngn_
Indices of Subdomain Nodes in Global Numbering.
void applyConstraints(ConstraintVec_ &constraints, const double factor, const double scalar)
int numElem_
total number of elements
void insertToDiagonalWeights(const int &index, const double &value)
const MatrixType matrixType_
type of matrix
std::vector< std::pair< unsigned, double > > ConstraintVec_
std::vector< int > inet_
safety state variable to warn if solver is called without loading subdomain mesh
std::vector< unsigned > VecUint_
const MPI_Comm comm_
communicator
std::vector< double > rhsVec_
vector with RHS values restricted to subdomain, i.e. values are repeated at shared nodes
int giveNumIterations()
Give number of iteration.
ublas::matrix< double > SubMat_
int giveConvergedReason()
Give reason of convergence.
const int numDofs_
number of total dofs
void writeMatrix(std::ostream &out)
Outputs.
void loadRawMesh(const int nDim, const int numNodes, const std::vector< int > &inet, const std::vector< int > &nnet, const std::vector< int > &nndf, const std::vector< int > &isegn, const std::vector< int > &isngn, const std::vector< int > &isvgvn, const std::vector< double > &xyz, const std::vector< double > &element_data, const int meshDim=0)
Load raw data about mesh.
~BddcmlWrapper()
Destructor frees the BDDCML structures.
int meshDim_
mesh dimension, may differ from space dimension - e.g. 2 for shells in 3D
void insertToRhs(const SubVec_ &eForce, const VecUint_ &dofIndices)
insert subvector to system rhs vector
void prepareMatAssembly(unsigned numElements, unsigned elMatSize)
Prepare assembly of matrix - reserve space in underlying coordinate matrix object.
bool isDiagAssembled_
true if diagonal is assembled
int numElemSub_
number of elements in subdomain
void finishAssembly()
Compatibility call which does absolutely nothing.
void fixDOF(const unsigned index, const double scalar=1.)
int numNodes_
total number of nodes
BddcmlWrapper(const unsigned numDofs, const unsigned numDofsSub, const MatrixType matrixType=GENERAL, const MPI_Comm comm=MPI_COMM_WORLD, int numSubLoc=1)
std::vector< int > isegn_
Indices of Subdomain Elements in Global Numbering.
std::map< unsigned, unsigned > Global2LocalMap_
void finishMatAssembly()
Finalize assembly of matrix.
std::vector< int > ifix_
indices of fixed boundary conditions - ( 0 for free variable, 1 for constrained dof )
Global2LocalMap_ global2LocalDofMap_
type for storage of global to local map
void clearSol()
Fill solution with zeros.
void finishDiagAssembly()
Finalize assembly of diagonal.
int numNodesSub_
number of nodes in subdomain
int numSubLoc_
number of subdomains on process
void clear()
destroy all contents
void prepareAssembly(const IndexType length)
std::ostream & write(std::ostream &out)
debug-output
IndexType nnz() const
Return number of non-zeros.
static constexpr bool value
int getLocalNumber(DOFHOLDER *np, MAPTYPE &map)