45 namespace it = Input::Type;
51 "Maximum number of iterations of the linear solver with non-decreasing residual.")
53 "Number of levels in the multilevel method (=2 for the standard BDDC).")
55 "Use adaptive selection of constraints in BDDCML.")
57 "Level of verbosity of the BDDCML library: 0 - no output, 1 - mild output, 2 - detailed output.");
63 const int matrixTypeInt,
65 const bool swap_sign )
74 switch ( matrixTypeInt ) {
89 ASSERT(
true,
"Unknown matrix type %d", matrixTypeInt );
103 PetscInt numDofsSubInt =
static_cast<PetscInt
>( numDofsSub );
108 xprintf(
UsrErr,
"Compiled without support for BDDCML solver.\n");
109 #endif // HAVE_BDDCML
125 isngn_.resize(isngn.size());
126 std::copy( isngn.begin(), isngn.end(),
isngn_.begin() );
127 ASSERT( numDofs ==
size_,
"Global problem size mismatch!" );
129 bddcml_ -> loadRawMesh( nDim, numNodes, numDofs, inet, nnet, nndf, isegn, isngn, isvgvn, xyz, element_permeability, meshDim );
135 PetscInt numDofsSubInt =
static_cast<int>(
isngn_.size( ) );
138 ISLocalToGlobalMapping subdomainMapping;
139 ierr = ISLocalToGlobalMappingCreate(
comm_, numDofsSubInt, &(idx[0]), PETSC_COPY_VALUES, &subdomainMapping ); CHKERRV( ierr );
141 IS subdomainIndexSet;
143 ierr = ISCreateStride( PETSC_COMM_SELF, numDofsSubInt, 0, 1, &subdomainIndexSet );
144 ierr = ISLocalToGlobalMappingApplyIS( subdomainMapping, subdomainIndexSet, &from );
149 ierr = ISDestroy( &subdomainIndexSet ); CHKERRV( ierr );
150 ierr = ISDestroy( &from ); CHKERRV( ierr );
160 #endif // HAVE_BDDCML
166 namespace ublas = boost::numeric::ublas;
170 ublas::matrix< double > mat( nrow, ncol );
172 std::copy( &(rows[0]), &(rows[nrow]), myRows.begin() );
173 std::copy( &(cols[0]), &(cols[ncol]), myCols.begin() );
175 for (
int i = 0; i < nrow; i++ ) {
176 for (
int j = 0; j < ncol; j++ ) {
177 mat( i, j ) = vals[i*ncol + j];
184 bddcml_ -> insertToMatrix( mat, myRows, myCols );
185 #endif // HAVE_BDDCML
191 namespace ublas = boost::numeric::ublas;
194 ublas::vector< double > vec( nrow );
196 std::copy( &(rows[0]), &(rows[nrow]), myRows.begin() );
198 for (
int i = 0; i < nrow; i++ ) {
205 bddcml_ -> insertToRhs( vec, myRows );
206 #endif // HAVE_BDDCML
212 bddcml_ -> insertToDiagonalWeights( global_index, value );
213 #endif // HAVE_BDDCML
220 #endif // HAVE_BDDCML
228 #endif // HAVE_BDDCML
235 bddcml_ -> finishMatAssembly( );
236 #endif // HAVE_BDDCML
243 #endif // HAVE_BDDCML
253 DBGMSG(
"BDDCML converged reason: %d ( 0 means OK ) \n",
bddcml_ -> giveConvergedReason() );
254 DBGMSG(
"BDDCML converged in %d iterations. \n",
bddcml_ -> giveNumIterations() );
255 DBGMSG(
"BDDCML estimated condition number is %f \n",
bddcml_ -> giveCondNumber() );
261 double * locSolVecArray;
264 VecRestoreArray(
locSolVec_, &locSolVecArray );
273 return bddcml_ -> giveConvergedReason();
276 #endif // HAVE_BDDCML
300 ierr = VecDestroy( &
locSolVec_ ); CHKERRV( ierr );
305 #endif // HAVE_BDDCML
int bddcml_verbosity_level_
SetValuesMode status_
Set value status of the linear system.
double normRhs()
Get norm of right-hand side.
void mat_set_values(int nrow, int *rows, int ncol, int *cols, double *vals)
VecScatter VSpetscToSubScatter_
scatter from solution_ to locSolVec_
std::vector< int > isngn_
indices of subdomain nodes in global numbering
PetscErrorCode rhs_zero_entries() override
Wrappers for linear systems based on MPIAIJ and MATIS format.
ConstraintVec_ constraints_
enum matrixTypeEnum MatrixType
unsigned size_
global number of matrix rows, i.e. problem size
void load_mesh(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_permeability, const int meshDim)
void rhs_set_values(int nrow, int *rows, double *vals)
bool use_adaptive_bddc_
should adaptive BDDC be used?
static Input::Type::AbstractRecord input_type
Vec locSolVec_
local solution PETSc vector - sequential
int max_nondecr_it_
parameters expected from input file:
void diagonal_weights_set_value(int global_index, double value)
double residual_norm_
local solution array pointing into Vec solution_
const bool swap_sign_
swap sign of matrix and rhs entries, e.g. to make the matrix SPD
double get_solution_precision()
int number_of_levels_
number of levels in the multilevel method
la::BddcmlWrapper Bddcml_
symmetric positive definite,
general symmetric ( e.g. saddle point ),
static Input::Type::Record input_type
Bddcml_ * bddcml_
BDDCML wrapper.
PetscErrorCode mat_zero_entries() override
MPI_Comm get_comm() const
Returns communicator.
Abstract linear system class.
void apply_constrains(double scalar=1.)
std::vector< double > locSolution_
subdomain solution
LinSys_BDDC(const unsigned numDofsSub, const Distribution *rows_ds, const int matrixTypeInt=0, const int numSubLoc=1, const bool swap_sign=false)
void set_from_input(const Input::Record in_rec)
Vec solution_
PETSc vector constructed with vb array.
Solver based on Multilevel BDDC - using corresponding class of OpenFTL package.