23 #ifdef FLOW123D_HAVE_BDDCML 26 #endif // FLOW123D_HAVE_BDDCML 41 "Relative residual tolerance, (to initial error).")
43 "Maximum number of outer iterations of the linear solver.")
46 "Maximum number of iterations of the linear solver with non-decreasing residual.")
48 "Number of levels in the multilevel method (=2 for the standard BDDC).")
50 "Use adaptive selection of constraints in BDDCML.")
52 "Level of verbosity of the BDDCML library:\n\n - 0 - no output\n - 1 - mild output\n - 2 - detailed output.")
63 const int matrixTypeInt,
65 const bool swap_sign )
69 #ifdef FLOW123D_HAVE_BDDCML 74 switch ( matrixTypeInt ) {
89 OLD_ASSERT(
true,
"Unknown matrix type %d", matrixTypeInt );
108 xprintf(
UsrErr,
"Compiled without support for BDDCML solver.\n");
109 #endif // FLOW123D_HAVE_BDDCML 136 #ifdef FLOW123D_HAVE_BDDCML 138 isngn_.resize(isngn.size());
139 std::copy( isngn.begin(), isngn.end(),
isngn_.begin() );
142 bddcml_ -> loadRawMesh( nDim, numNodes, numDofs, inet, nnet, nndf, isegn, isngn, isvgvn, xyz, element_permeability, meshDim );
148 PetscInt numDofsSubInt =
static_cast<int>(
isngn_.size( ) );
151 ISLocalToGlobalMapping subdomainMapping;
152 ierr = ISLocalToGlobalMappingCreate(
comm_, 1, numDofsSubInt, &(idx[0]), PETSC_COPY_VALUES, &subdomainMapping ); CHKERRV( ierr );
154 IS subdomainIndexSet;
156 ierr = ISCreateStride( PETSC_COMM_SELF, numDofsSubInt, 0, 1, &subdomainIndexSet );
157 ierr = ISLocalToGlobalMappingApplyIS( subdomainMapping, subdomainIndexSet, &from );
162 chkerr(ISDestroy( &subdomainIndexSet ));
163 chkerr(ISDestroy( &from ));
173 #endif // FLOW123D_HAVE_BDDCML 178 #ifdef FLOW123D_HAVE_BDDCML 179 namespace ublas = boost::numeric::ublas;
183 ublas::matrix< double > mat( nrow, ncol );
185 std::copy( &(rows[0]), &(rows[nrow]), myRows.begin() );
186 std::copy( &(cols[0]), &(cols[ncol]), myCols.begin() );
188 for (
int i = 0; i < nrow; i++ ) {
189 for (
int j = 0; j < ncol; j++ ) {
190 mat( i, j ) = vals[i*ncol + j];
197 bddcml_ -> insertToMatrix( mat, myRows, myCols );
198 #endif // FLOW123D_HAVE_BDDCML 203 #ifdef FLOW123D_HAVE_BDDCML 204 namespace ublas = boost::numeric::ublas;
207 ublas::vector< double > vec( nrow );
209 std::copy( &(rows[0]), &(rows[nrow]), myRows.begin() );
211 for (
int i = 0; i < nrow; i++ ) {
218 bddcml_ -> insertToRhs( vec, myRows );
219 #endif // FLOW123D_HAVE_BDDCML 224 #ifdef FLOW123D_HAVE_BDDCML 225 bddcml_ -> insertToDiagonalWeights( global_index, value );
226 #endif // FLOW123D_HAVE_BDDCML 231 #ifdef FLOW123D_HAVE_BDDCML 233 #endif // FLOW123D_HAVE_BDDCML 239 #ifdef FLOW123D_HAVE_BDDCML 241 #endif // FLOW123D_HAVE_BDDCML 247 #ifdef FLOW123D_HAVE_BDDCML 248 bddcml_ -> finishMatAssembly( );
249 #endif // FLOW123D_HAVE_BDDCML 254 #ifdef FLOW123D_HAVE_BDDCML 256 #endif // FLOW123D_HAVE_BDDCML 261 #ifdef FLOW123D_HAVE_BDDCML 271 LogOut().fmt(
"BDDCML converged reason: {} ( 0 means OK ) \n",
bddcml_ -> giveConvergedReason() );
272 LogOut().fmt(
"BDDCML converged in {} iterations. \n",
bddcml_ -> giveNumIterations() );
273 LogOut().fmt(
"BDDCML estimated condition number is {} \n",
bddcml_ -> giveCondNumber() );
281 double * locSolVecArray;
284 VecRestoreArray(
locSolVec_, &locSolVecArray );
296 #endif // FLOW123D_HAVE_BDDCML 313 #ifdef FLOW123D_HAVE_BDDCML 323 #endif // FLOW123D_HAVE_BDDCML 398 <<
"zzz(:,1:2) = zzz(:,1:2) + ones(size(zzz),2);\n" 399 <<
"matrix_bddc = spconvert(zzz);\n";
int bddcml_verbosity_level_
SetValuesMode status_
Set value status of the linear system.
double normRhs()
Get norm of right-hand side.
double get_solution_precision() override
VecScatter VSpetscToSubScatter_
scatter from solution_ to locSolVec_
std::vector< int > isngn_
indices of subdomain nodes in global numbering
PetscErrorCode rhs_zero_entries() override
virtual void set_from_input(const Input::Record in_rec)
Wrappers for linear systems based on MPIAIJ and MATIS format.
ConstraintVec_ constraints_
void chkerr(unsigned int ierr)
Replacement of new/delete operator in the spirit of xmalloc.
enum matrixTypeEnum MatrixType
void print_matrix(std::ostream &out)
#define ADD_CALLS(n_calls)
Increase number of calls in actual timer.
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)
#define LogOut()
Macro defining 'log' record of log.
static const Input::Type::Record & get_input_type()
bool use_adaptive_bddc_
should adaptive BDDC be used?
static constexpr bool value
void set_from_input(const Input::Record in_rec) override
void apply_constrains(double scalar=1.) override
unsigned int max_it_
maximum number of iterations of linear solver
Vec locSolVec_
local solution PETSc vector - sequential
#define START_TIMER(tag)
Starts a timer with specified tag.
int max_nondecr_it_
parameters expected from input file:
double a_tol_
absolute tolerance of linear solver
static const int registrar
Registrar of class to factory.
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
int number_of_levels_
number of levels in the multilevel method
la::BddcmlWrapper Bddcml_
symmetric positive definite,
general symmetric ( e.g. saddle point ),
double r_tol_
relative tolerance of linear solver
Bddcml_ * bddcml_
BDDCML wrapper.
PetscErrorCode mat_zero_entries() override
MPI_Comm get_comm() const
Returns communicator.
void mat_set_values(int nrow, int *rows, int ncol, int *cols, double *vals) override
void finish_assembly() override
static Input::Type::Abstract & get_input_type()
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 writeMatrix(std::ostream &out)
Outputs.
Vec solution_
PETSc vector constructed with vb array.
LinSys::SolveInfo solve() override
void set_tolerances(double r_tol, double a_tol, unsigned int max_it) override
void rhs_set_values(int nrow, int *rows, double *vals) override
Solver based on Multilevel BDDC - using corresponding class of OpenFTL package.