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 )
77 switch ( matrixTypeInt ) {
92 ASSERT(
true,
"Unknown matrix type %d", matrixTypeInt );
106 PetscInt numDofsSubInt =
static_cast<PetscInt
>( numDofsSub );
107 ierr = VecCreateSeq( PETSC_COMM_SELF, numDofsSubInt, &
locSolVec_ );
110 xprintf(
UsrErr,
"Compiled without support for BDDCML solver.\n");
111 #endif // HAVE_BDDCML
127 isngn_.resize(isngn.size());
128 std::copy( isngn.begin(), isngn.end(),
isngn_.begin() );
129 ASSERT( numDofs ==
size_,
"Global problem size mismatch!" );
131 bddcml_ -> loadRawMesh( nDim, numNodes, numDofs, inet, nnet, nndf, isegn, isngn, isvgvn, xyz, element_permeability, meshDim );
137 PetscInt numDofsSubInt =
static_cast<int>(
isngn_.size( ) );
143 ISLocalToGlobalMapping subdomainMapping;
144 ierr = ISLocalToGlobalMappingCreate(
comm_, numDofsSubInt, &(idx[0]), PETSC_COPY_VALUES, &subdomainMapping ); CHKERRV( ierr );
146 IS subdomainIndexSet;
148 ierr = ISCreateStride( PETSC_COMM_SELF, numDofsSubInt, 0, 1, &subdomainIndexSet );
149 ierr = ISLocalToGlobalMappingApplyIS( subdomainMapping, subdomainIndexSet, &from );
157 ierr = ISDestroy( &subdomainIndexSet ); CHKERRV( ierr );
158 ierr = ISDestroy( &from ); CHKERRV( ierr );
162 double * locSolVecArray;
163 ierr = VecGetArray(
locSolVec_, &locSolVecArray ); CHKERRV( ierr );
165 ierr = VecRestoreArray(
locSolVec_, &locSolVecArray ); CHKERRV( ierr );
170 #endif // HAVE_BDDCML
176 namespace ublas = boost::numeric::ublas;
180 ublas::matrix< double > mat( nrow, ncol );
182 std::copy( &(rows[0]), &(rows[nrow]), myRows.begin() );
183 std::copy( &(cols[0]), &(cols[ncol]), myCols.begin() );
185 for (
int i = 0; i < nrow; i++ ) {
186 for (
int j = 0; j < ncol; j++ ) {
187 mat( i, j ) = vals[i*ncol + j];
194 bddcml_ -> insertToMatrix( mat, myRows, myCols );
195 #endif // HAVE_BDDCML
201 namespace ublas = boost::numeric::ublas;
204 ublas::vector< double > vec( nrow );
206 std::copy( &(rows[0]), &(rows[nrow]), myRows.begin() );
208 for (
int i = 0; i < nrow; i++ ) {
215 bddcml_ -> insertToRhs( vec, myRows );
216 #endif // HAVE_BDDCML
222 bddcml_ -> insertToDiagonalWeights( global_index, value );
223 #endif // HAVE_BDDCML
230 #endif // HAVE_BDDCML
238 #endif // HAVE_BDDCML
245 bddcml_ -> finishMatAssembly( );
246 #endif // HAVE_BDDCML
253 #endif // HAVE_BDDCML
263 DBGMSG(
"BDDCML converged reason: %d ( 0 means OK ) \n",
bddcml_ -> giveConvergedReason() );
264 DBGMSG(
"BDDCML converged in %d iterations. \n",
bddcml_ -> giveNumIterations() );
265 DBGMSG(
"BDDCML estimated condition number is %f \n",
bddcml_ -> giveCondNumber() );
271 double * locSolVecArray;
273 ierr = VecGetArray(
locSolVec_, &locSolVecArray );
275 ierr = VecRestoreArray(
locSolVec_, &locSolVecArray );
284 return bddcml_ -> giveConvergedReason();
287 #endif // HAVE_BDDCML
297 #endif // HAVE_BDDCML
304 std::copy( globalSolution.begin(), globalSolution.end(),
globalSolution_.begin() );
305 #endif // HAVE_BDDCML
328 ierr = VecDestroy( &
locSolVec_ ); CHKERRV( ierr );
333 #endif // HAVE_BDDCML
352 for (
unsigned int i = 0; i <
isngn_.size(); i++ ) {
356 for (
int iProc = 1; iProc < nProc; iProc++ ) {
367 locSolutionNeib.resize( length );
371 for (
int i = 0; i < length; i++ ) {
379 int length =
isngn_.size();
386 #endif // HAVE_BDDCML
#define MPI_Recv(buf, count, datatype, source, tag, comm, status)
int bddcml_verbosity_level_
std::vector< double > globalSolution_
global solution in numbering for linear system
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
void get_whole_solution(std::vector< double > &globalSolution)
SetValuesMode status
Set value status of the linear system.
Wrappers for linear systems based on MPIAIJ and MATIS format.
ConstraintVec_ constraints_
enum matrixTypeEnum MatrixType
#define MPI_Send(buf, count, datatype, dest, tag, comm)
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.
#define MPI_Bcast(buffer, count, datatype, root, comm)
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_whole_solution(std::vector< double > &globalSolution)
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.