HYPRE_Int hypre_BiCGSTABSetup( void *bicgstab_vdata, void *A, void *b, void *x ) { hypre_BiCGSTABData *bicgstab_data = (hypre_BiCGSTABData *)bicgstab_vdata; hypre_BiCGSTABFunctions *bicgstab_functions = bicgstab_data->functions; HYPRE_Int max_iter = (bicgstab_data -> max_iter); HYPRE_Int (*precond_setup)(void*,void*,void*,void*) = (bicgstab_functions -> precond_setup); void *precond_data = (bicgstab_data -> precond_data); (bicgstab_data -> A) = A; /*-------------------------------------------------- * The arguments for NewVector are important to * maintain consistency between the setup and * compute phases of matvec and the preconditioner. *--------------------------------------------------*/ if ((bicgstab_data -> p) == NULL) (bicgstab_data -> p) = (*(bicgstab_functions->CreateVector))(b); if ((bicgstab_data -> q) == NULL) (bicgstab_data -> q) = (*(bicgstab_functions->CreateVector))(b); if ((bicgstab_data -> r) == NULL) (bicgstab_data -> r) = (*(bicgstab_functions->CreateVector))(b); if ((bicgstab_data -> r0) == NULL) (bicgstab_data -> r0) = (*(bicgstab_functions->CreateVector))(b); if ((bicgstab_data -> s) == NULL) (bicgstab_data -> s) = (*(bicgstab_functions->CreateVector))(b); if ((bicgstab_data -> v) == NULL) (bicgstab_data -> v) = (*(bicgstab_functions->CreateVector))(b); if ((bicgstab_data -> matvec_data) == NULL) (bicgstab_data -> matvec_data) = (*(bicgstab_functions->MatvecCreate))(A, x); precond_setup(precond_data, A, b, x); /*----------------------------------------------------- * Allocate space for log info *-----------------------------------------------------*/ if ((bicgstab_data->logging)>0 || (bicgstab_data->print_level) > 0) { if ((bicgstab_data -> norms) == NULL) (bicgstab_data -> norms) = hypre_CTAlloc(HYPRE_Real, max_iter + 1); } if ((bicgstab_data -> print_level) > 0) { if ((bicgstab_data -> log_file_name) == NULL) (bicgstab_data -> log_file_name) = (char*)"bicgstab.out.log"; } return hypre_error_flag; }
int hypre_GMRESSetup( void *gmres_vdata, void *A, void *b, void *x ) { hypre_GMRESData *gmres_data = gmres_vdata; hypre_GMRESFunctions *gmres_functions = gmres_data->functions; int k_dim = (gmres_data -> k_dim); int max_iter = (gmres_data -> max_iter); int (*precond_setup)(void*, void*, void*, void*) = (gmres_functions->precond_setup); void *precond_data = (gmres_data -> precond_data); int ierr = 0; (gmres_data -> A) = A; /*-------------------------------------------------- * The arguments for NewVector are important to * maintain consistency between the setup and * compute phases of matvec and the preconditioner. *--------------------------------------------------*/ if ((gmres_data -> p) == NULL) (gmres_data -> p) = (*(gmres_functions->CreateVectorArray))(k_dim+1,x); if ((gmres_data -> r) == NULL) (gmres_data -> r) = (*(gmres_functions->CreateVector))(b); if ((gmres_data -> w) == NULL) (gmres_data -> w) = (*(gmres_functions->CreateVector))(b); if ((gmres_data -> matvec_data) == NULL) (gmres_data -> matvec_data) = (*(gmres_functions->MatvecCreate))(A, x); ierr = precond_setup(precond_data, A, b, x); /*----------------------------------------------------- * Allocate space for log info *-----------------------------------------------------*/ if ( (gmres_data->logging)>0 || (gmres_data->print_level) > 0 ) { if ((gmres_data -> norms) == NULL) (gmres_data -> norms) = hypre_CTAllocF(double, max_iter + 1,gmres_functions); } if ( (gmres_data->print_level) > 0 ) { if ((gmres_data -> log_file_name) == NULL) (gmres_data -> log_file_name) = "gmres.out.log"; } return ierr; }
HYPRE_Int hypre_LOBPCGSetup( void *pcg_vdata, void *A, void *b, void *x ) { hypre_LOBPCGData *pcg_data = pcg_vdata; HYPRE_MatvecFunctions * mv = pcg_data->matvecFunctions; HYPRE_Int (*precond_setup)() = (pcg_data->precondFunctions).PrecondSetup; void *precond_data = (pcg_data->precondData); (pcg_data->A) = A; if ( pcg_data->matvecData != NULL ) (*(mv->MatvecDestroy))(pcg_data->matvecData); (pcg_data->matvecData) = (*(mv->MatvecCreate))(A, x); if ( precond_setup != NULL ) { if ( pcg_data->T == NULL ) precond_setup(precond_data, A, b, x); else precond_setup(precond_data, pcg_data->T, b, x); } return hypre_error_flag; }
HYPRE_Int hypre_LGMRESSetup( void *lgmres_vdata, void *A, void *b, void *x ) { hypre_LGMRESData *lgmres_data = (hypre_LGMRESData *)lgmres_vdata; hypre_LGMRESFunctions *lgmres_functions = lgmres_data->functions; HYPRE_Int k_dim = (lgmres_data -> k_dim); HYPRE_Int max_iter = (lgmres_data -> max_iter); HYPRE_Int (*precond_setup)(void*,void*,void*,void*) = (lgmres_functions->precond_setup); void *precond_data = (lgmres_data -> precond_data); HYPRE_Int rel_change = (lgmres_data -> rel_change); /* lgmres mod */ HYPRE_Int aug_dim = (lgmres_data -> aug_dim); (lgmres_data -> A) = A; /*-------------------------------------------------- * The arguments for NewVector are important to * maintain consistency between the setup and * compute phases of matvec and the preconditioner. *--------------------------------------------------*/ if ((lgmres_data -> p) == NULL) (lgmres_data -> p) = (void**)(*(lgmres_functions->CreateVectorArray))(k_dim+1,x); if ((lgmres_data -> r) == NULL) (lgmres_data -> r) = (*(lgmres_functions->CreateVector))(b); if ((lgmres_data -> w) == NULL) (lgmres_data -> w) = (*(lgmres_functions->CreateVector))(b); if (rel_change) { if ((lgmres_data -> w_2) == NULL) (lgmres_data -> w_2) = (*(lgmres_functions->CreateVector))(b); } /* lgmres mod */ (lgmres_data -> aug_vecs) = (void**)(*(lgmres_functions->CreateVectorArray))(aug_dim+1,x); /* one extra */ (lgmres_data -> a_aug_vecs) = (void**)(*(lgmres_functions->CreateVectorArray))(aug_dim,x); (lgmres_data -> aug_order) = hypre_CTAllocF(HYPRE_Int,aug_dim,lgmres_functions); /*---*/ if ((lgmres_data -> matvec_data) == NULL) (lgmres_data -> matvec_data) = (*(lgmres_functions->MatvecCreate))(A, x); precond_setup(precond_data, A, b, x); /*----------------------------------------------------- * Allocate space for log info *-----------------------------------------------------*/ if ( (lgmres_data->logging)>0 || (lgmres_data->print_level) > 0 ) { if ((lgmres_data -> norms) == NULL) (lgmres_data -> norms) = hypre_CTAllocF(HYPRE_Real, max_iter + 1,lgmres_functions); } if ( (lgmres_data->print_level) > 0 ) { if ((lgmres_data -> log_file_name) == NULL) (lgmres_data -> log_file_name) = (char*)"gmres.out.log"; } return hypre_error_flag; }