4 #ifndef la_bddcml_wrapper_h
5 #define la_bddcml_wrapper_h
7 #include <boost/numeric/ublas/matrix.hpp>
8 #include <boost/numeric/ublas/vector.hpp>
20 #include <bddcml_interface_c.h>
26 namespace ublas = boost::numeric::ublas;
30 template<
typename DOFHOLDER,
typename MAPTYPE >
33 unsigned globalIndex = np -> giveId( );
35 typename MAPTYPE::iterator pos = map.find( globalIndex );
37 "Cannot remap node index %d to local indices. \n ", globalIndex );
38 int localIndexInt = pos -> second;
91 const unsigned numDofsSub,
92 const MatrixType matrixType =
GENERAL,
100 void loadRawMesh(
const int nDim,
const int numNodes,
const int numDofs,
109 const int meshDim = 0 );
116 const VecUint_ & rowIndices,
117 const VecUint_ & colIndices );
123 void insertToRhs(
const SubVec_ & eForce,
const VecUint_ & dofIndices );
134 void applyConstraints( ConstraintVec_ & constraints,
const double factor,
const double scalar );
140 void fixDOF(
const unsigned index,
const double scalar = 1. );
155 int verboseLevel = 0,
162 bool use_adaptive =
false
201 { std::fill(
sol_.begin( ),
sol_.end( ), 0. );
220 template<
typename VEC1,
typename VEC2>
221 void giveSolution(
const VEC1 & dofIndices, VEC2 & result )
const;
286 #include "bddcml_wrapper.ipp"
double giveCondNumber()
Give estimate of condition number.
void applyConstraints(ConstraintVec_ &constraints, const double factor, const double scalar)
void destroyRhs()
Destroy RHS.
double normSol()
Get norm of solution.
void prepareAssembly(const IndexType length)
double normRhs()
Get norm of right-hand side.
std::vector< double > fixv_
values of fixed boundary conditions at places of ifix_ - values outside fixed dofs are ignored ...
BddcmlWrapper(const unsigned numDofs, const unsigned numDofsSub, const MatrixType matrixType=GENERAL, const MPI_Comm comm=MPI_COMM_WORLD, int numSubLoc=1)
std::ostream & write(std::ostream &out)
debug-output
int giveConvergedReason()
Give reason of convergence.
int nProc_
number of processors in communicator
int numIter_
required number of iterations
void finishMatAssembly()
Finalize assembly of matrix.
int rank_
ID of processors in communicator.
void prepareMatAssembly(unsigned numElements, unsigned elMatSize)
Prepare assembly of matrix - reserve space in underlying coordinate matrix object.
std::vector< int > inet_
safety state variable to warn if solver is called without loading subdomain mesh
~BddcmlWrapper()
Destructor frees the BDDCML structures.
std::vector< double > xyz_
int numNodes_
total number of nodes
void destroySol()
Destroy solution.
Global2LocalMap_ global2LocalDofMap_
type for storage of global to local map
enum matrixTypeEnum MatrixType
IndexType nnz() const
Return number of non-zeros.
la::MatrixCoo< int, double > coo_
matrix in coordinate format (COO)
void insertToMatrix(const SubMat_ &eStiff, const VecUint_ &rowIndices, const VecUint_ &colIndices)
insert submatrix to system matrix - into coordinate matrix object
double normSol_
norm of the global solution
I/O functions with filename storing, able to track current line in opened file. All standard stdio fu...
const MatrixType matrixType_
type of matrix
int numElem_
total number of elements
int numSubLoc_
number of subdomains on process
std::vector< double > sol_
distributed solution vector
Global macros to enhance readability and debugging, general constants.
void giveSolution(const VEC1 &dofIndices, VEC2 &result) const
Give access to the solution vector.
std::vector< int > isvgvn_
Indices of Subdomain Variables in Global Variable Numbering ( i.e. dof mapping )
std::vector< int > isegn_
Indices of Subdomain Elements in Global Numbering.
int numElemSub_
number of elements in subdomain
void clearSol()
Fill solution with zeros.
int getLocalNumber(DOFHOLDER *np, MAPTYPE &map)
std::vector< double > rhsVec_
vector with RHS values restricted to subdomain, i.e. values are repeated at shared nodes ...
bool isMatAssembled_
true if matrix is assembled
void insertToDiagonalWeights(const int &index, const double &value)
std::vector< int > ifix_
indices of fixed boundary conditions - ( 0 for free variable, 1 for constrained dof ) ...
symmetric positive definite,
general symmetric ( e.g. saddle point ),
void clearMatrix()
Fill matrix with zeros.
bool isDiagAssembled_
true if diagonal is assembled
void destroyBC()
Destroy boundary conditions.
void fixDOF(const unsigned index, const double scalar=1.)
std::vector< int > isngn_
Indices of Subdomain Nodes in Global Numbering.
std::vector< unsigned > VecUint_
void loadRawMesh(const int nDim, const int numNodes, const int numDofs, 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.
int meshDim_
mesh dimension, may differ from space dimension - e.g. 2 for shells in 3D
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.
int numNodesSub_
number of nodes in subdomain
std::map< unsigned, unsigned > Global2LocalMap_
void finishDiagAssembly()
Finalize assembly of diagonal.
int giveNumIterations()
Give number of iteration.
const MPI_Comm comm_
communicator
ublas::vector< double > SubVec_
void clearRhs()
Fill RHS with zeros.
std::vector< double > element_data_
array with data on elements, here used for permeability for each element
void finishAssembly()
Compatibility call which does absolutely nothing.
la::MatrixCoo< int, double > diagWeightsCoo_
diagonal of subdomain matrix in sparse format and global numbers
void clearBC()
Blank arrays for boundary conditions.
void writeMatrix(std::ostream &out)
Outputs.
const int numDofsSub_
number of subdomain dofs
void destroyMatrix()
Destroy matrix.
Multilevel BDDC based linear system solver.
const int numDofs_
number of total dofs
ublas::matrix< double > SubMat_
void clear()
destroy all contents
double normRhs_
norm of the global right-hand side
std::vector< std::pair< unsigned, double > > ConstraintVec_
void insertToRhs(const SubVec_ &eForce, const VecUint_ &dofIndices)
insert subvector to system rhs vector