diff --git a/src/mup_code b/src/mup_code index a1d7529a95..bda695ec15 100755 --- a/src/mup_code +++ b/src/mup_code @@ -33,6 +33,7 @@ DIRS="\ struct_ls\ struct_mv\ utilities\ + test\ " # Function to process a single directory diff --git a/src/parcsr_ls/CMakeLists.txt b/src/parcsr_ls/CMakeLists.txt index 5dd43fb8de..8806c44fa0 100644 --- a/src/parcsr_ls/CMakeLists.txt +++ b/src/parcsr_ls/CMakeLists.txt @@ -22,7 +22,6 @@ endif() set(REGULAR_SRCS amg_hybrid.c aux_interp.c - F90_hypre_laplace.c F90_HYPRE_parcsr_amg.c F90_HYPRE_parcsr_bicgstab.c F90_HYPRE_parcsr_block.c @@ -80,11 +79,9 @@ set(REGULAR_SRCS par_cgc_coarsen.c par_cheby.c par_coarse_parms.c - par_coordinates.c par_cr.c par_cycle.c par_add_cycle.c - par_difconv.c par_fsai.c par_fsai_setup.c par_fsai_solve.c @@ -97,9 +94,6 @@ set(REGULAR_SRCS par_mod_lr_interp.c par_mod_multi_interp.c par_multi_interp.c - par_laplace_27pt.c - par_laplace_9pt.c - par_laplace.c par_lr_interp.c par_mgr.c par_mgr_coarsen.c @@ -112,9 +106,6 @@ set(REGULAR_SRCS par_nodal_systems.c par_rap.c par_rap_communication.c - par_rotate_7pt.c - par_vardifconv.c - par_vardifconv_rs.c par_relax.c par_relax_more.c par_relax_interface.c diff --git a/src/parcsr_ls/HYPRE_parcsr_ls.h b/src/parcsr_ls/HYPRE_parcsr_ls.h index 43759ccaf0..6f714d7015 100644 --- a/src/parcsr_ls/HYPRE_parcsr_ls.h +++ b/src/parcsr_ls/HYPRE_parcsr_ls.h @@ -5043,120 +5043,6 @@ HYPRE_ILUGetFinalRelativeResidualNorm( HYPRE_Solver solver, HYPRE_Real *res_nor /*@}*/ -/*-------------------------------------------------------------------------- - *--------------------------------------------------------------------------*/ - -/*-------------------------------------------------------------------------- - * RDF: These don't belong in the external interface but are used in various - * test drivers. They should be moved into the test directory instead. - *--------------------------------------------------------------------------*/ - -HYPRE_ParCSRMatrix GenerateLaplacian(MPI_Comm comm, - HYPRE_BigInt nx, - HYPRE_BigInt ny, - HYPRE_BigInt nz, - HYPRE_Int P, - HYPRE_Int Q, - HYPRE_Int R, - HYPRE_Int p, - HYPRE_Int q, - HYPRE_Int r, - HYPRE_Real *value); - -HYPRE_ParCSRMatrix GenerateLaplacian27pt(MPI_Comm comm, - HYPRE_BigInt nx, - HYPRE_BigInt ny, - HYPRE_BigInt nz, - HYPRE_Int P, - HYPRE_Int Q, - HYPRE_Int R, - HYPRE_Int p, - HYPRE_Int q, - HYPRE_Int r, - HYPRE_Real *value); - -HYPRE_ParCSRMatrix GenerateLaplacian9pt(MPI_Comm comm, - HYPRE_BigInt nx, - HYPRE_BigInt ny, - HYPRE_Int P, - HYPRE_Int Q, - HYPRE_Int p, - HYPRE_Int q, - HYPRE_Real *value); - -HYPRE_ParCSRMatrix GenerateDifConv(MPI_Comm comm, - HYPRE_BigInt nx, - HYPRE_BigInt ny, - HYPRE_BigInt nz, - HYPRE_Int P, - HYPRE_Int Q, - HYPRE_Int R, - HYPRE_Int p, - HYPRE_Int q, - HYPRE_Int r, - HYPRE_Real *value); - -HYPRE_ParCSRMatrix -GenerateRotate7pt(MPI_Comm comm, - HYPRE_BigInt nx, - HYPRE_BigInt ny, - HYPRE_Int P, - HYPRE_Int Q, - HYPRE_Int p, - HYPRE_Int q, - HYPRE_Real alpha, - HYPRE_Real eps ); - -HYPRE_ParCSRMatrix -GenerateVarDifConv(MPI_Comm comm, - HYPRE_BigInt nx, - HYPRE_BigInt ny, - HYPRE_BigInt nz, - HYPRE_Int P, - HYPRE_Int Q, - HYPRE_Int R, - HYPRE_Int p, - HYPRE_Int q, - HYPRE_Int r, - HYPRE_Real eps, - HYPRE_ParVector *rhs_ptr); - -HYPRE_ParCSRMatrix -GenerateRSVarDifConv(MPI_Comm comm, - HYPRE_BigInt nx, - HYPRE_BigInt ny, - HYPRE_BigInt nz, - HYPRE_Int P, - HYPRE_Int Q, - HYPRE_Int R, - HYPRE_Int p, - HYPRE_Int q, - HYPRE_Int r, - HYPRE_Real eps, - HYPRE_ParVector *rhs_ptr, - HYPRE_Int type); - -float* -hypre_GenerateCoordinates(MPI_Comm comm, - HYPRE_BigInt nx, - HYPRE_BigInt ny, - HYPRE_BigInt nz, - HYPRE_Int P, - HYPRE_Int Q, - HYPRE_Int R, - HYPRE_Int p, - HYPRE_Int q, - HYPRE_Int r, - HYPRE_Int coorddim); - -/*-------------------------------------------------------------------------- - *--------------------------------------------------------------------------*/ - - - - - - /*-------------------------------------------------------------------------- *--------------------------------------------------------------------------*/ diff --git a/src/parcsr_ls/HYPRE_parcsr_ls_mup.h b/src/parcsr_ls/HYPRE_parcsr_ls_mup.h index 1fca390f2e..41723a5fe0 100644 --- a/src/parcsr_ls/HYPRE_parcsr_ls_mup.h +++ b/src/parcsr_ls/HYPRE_parcsr_ls_mup.h @@ -20,62 +20,6 @@ extern "C" { ******************************************************************************/ -HYPRE_ParCSRMatrix -GenerateDifConv_flt( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, hypre_float *value ); -HYPRE_ParCSRMatrix -GenerateDifConv_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, hypre_double *value ); -HYPRE_ParCSRMatrix -GenerateDifConv_long_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, hypre_long_double *value ); - -HYPRE_ParCSRMatrix -GenerateLaplacian_flt( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, hypre_float *value ); -HYPRE_ParCSRMatrix -GenerateLaplacian_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, hypre_double *value ); -HYPRE_ParCSRMatrix -GenerateLaplacian_long_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, hypre_long_double *value ); - -HYPRE_ParCSRMatrix -GenerateLaplacian27pt_flt( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, hypre_float *value ); -HYPRE_ParCSRMatrix -GenerateLaplacian27pt_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, hypre_double *value ); -HYPRE_ParCSRMatrix -GenerateLaplacian27pt_long_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, hypre_long_double *value ); - -HYPRE_ParCSRMatrix -GenerateLaplacian9pt_flt( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int p, HYPRE_Int q, hypre_float *value ); -HYPRE_ParCSRMatrix -GenerateLaplacian9pt_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int p, HYPRE_Int q, hypre_double *value ); -HYPRE_ParCSRMatrix -GenerateLaplacian9pt_long_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int p, HYPRE_Int q, hypre_long_double *value ); - -HYPRE_ParCSRMatrix -GenerateRSVarDifConv_flt( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, hypre_float eps, HYPRE_ParVector *rhs_ptr, HYPRE_Int type ); -HYPRE_ParCSRMatrix -GenerateRSVarDifConv_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, hypre_double eps, HYPRE_ParVector *rhs_ptr, HYPRE_Int type ); -HYPRE_ParCSRMatrix -GenerateRSVarDifConv_long_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, hypre_long_double eps, HYPRE_ParVector *rhs_ptr, HYPRE_Int type ); - -HYPRE_ParCSRMatrix -GenerateRotate7pt_flt( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int p, HYPRE_Int q, hypre_float alpha, hypre_float eps ); -HYPRE_ParCSRMatrix -GenerateRotate7pt_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int p, HYPRE_Int q, hypre_double alpha, hypre_double eps ); -HYPRE_ParCSRMatrix -GenerateRotate7pt_long_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int p, HYPRE_Int q, hypre_long_double alpha, hypre_long_double eps ); - -HYPRE_ParCSRMatrix -GenerateVarDifConv_flt( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, hypre_float eps, HYPRE_ParVector *rhs_ptr ); -HYPRE_ParCSRMatrix -GenerateVarDifConv_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, hypre_double eps, HYPRE_ParVector *rhs_ptr ); -HYPRE_ParCSRMatrix -GenerateVarDifConv_long_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, hypre_long_double eps, HYPRE_ParVector *rhs_ptr ); - -float* -hypre_GenerateCoordinates_flt( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Int coorddim ); -float* -hypre_GenerateCoordinates_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Int coorddim ); -float* -hypre_GenerateCoordinates_long_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Int coorddim ); - /*** DO NOT EDIT THIS FILE DIRECTLY (use ../config/gen_code.sh to generate) ***/ diff --git a/src/parcsr_ls/Makefile b/src/parcsr_ls/Makefile index 178be7cdda..10a865d2c3 100644 --- a/src/parcsr_ls/Makefile +++ b/src/parcsr_ls/Makefile @@ -45,7 +45,6 @@ HEADERS =\ FILES =\ amg_hybrid.c\ aux_interp.c\ - F90_hypre_laplace.c\ F90_HYPRE_parcsr_amg.c\ F90_HYPRE_parcsr_bicgstab.c\ F90_HYPRE_parcsr_block.c\ @@ -105,11 +104,9 @@ FILES =\ par_cgc_coarsen.c\ par_cheby.c\ par_coarse_parms.c\ - par_coordinates.c\ par_cr.c\ par_cycle.c\ par_add_cycle.c\ - par_difconv.c\ par_gauss_elim.c\ par_gsmg.c\ par_indepset.c\ @@ -121,9 +118,6 @@ FILES =\ par_mod_lr_interp.c\ par_multi_interp.c\ par_mod_multi_interp.c\ - par_laplace.c\ - par_laplace_27pt.c\ - par_laplace_9pt.c\ par_lr_interp.c\ par_mgr.c\ par_mgr_coarsen.c\ @@ -136,7 +130,6 @@ FILES =\ par_nodal_systems.c\ par_rap.c\ par_rap_communication.c\ - par_rotate_7pt.c\ par_relax.c\ par_relax_more.c\ par_relax_interface.c\ @@ -146,8 +139,6 @@ FILES =\ par_strength.c\ par_sv_interp.c\ par_sv_interp_ln.c\ - par_vardifconv.c\ - par_vardifconv_rs.c\ partial.c\ schwarz.c\ block_tridiag.c\ @@ -193,7 +184,7 @@ COBJS = ${FILES:.c=.o} CUOBJS = ${CUFILES:.c=.obj} OBJS = ${COBJS} ${CUOBJS} -ifeq (${MP_BUILD}, 1) +ifeq (${MP_BUILD}, 1) COBJS_single = ${FILES:.c=.o_flt} COBJS_double = ${FILES:.c=.o_dbl} diff --git a/src/parcsr_ls/_hypre_parcsr_ls.h b/src/parcsr_ls/_hypre_parcsr_ls.h index 3974a49d10..884da9567f 100644 --- a/src/parcsr_ls/_hypre_parcsr_ls.h +++ b/src/parcsr_ls/_hypre_parcsr_ls.h @@ -2195,25 +2195,6 @@ void hypre_BoomerAMGTruncateInterp ( hypre_ParCSRMatrix *P, HYPRE_Real eps, HYPR HYPRE_Int hypre_ParCSRMatrix_dof_func_offd ( hypre_ParCSRMatrix *A, HYPRE_Int num_functions, HYPRE_Int *dof_func, HYPRE_Int **dof_func_offd ); -/* par_laplace_27pt.c */ -HYPRE_Int hypre_map3 ( HYPRE_BigInt ix, HYPRE_BigInt iy, HYPRE_BigInt iz, HYPRE_Int p, HYPRE_Int q, - HYPRE_Int r, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_BigInt *nx_part, HYPRE_BigInt *ny_part, - HYPRE_BigInt *nz_part ); - -/* par_laplace_9pt.c */ -HYPRE_BigInt hypre_map2 ( HYPRE_BigInt ix, HYPRE_BigInt iy, HYPRE_Int p, HYPRE_Int q, - HYPRE_BigInt nx, HYPRE_BigInt *nx_part, HYPRE_BigInt *ny_part ); - -/* par_laplace.c */ -HYPRE_BigInt hypre_map ( HYPRE_BigInt ix, HYPRE_BigInt iy, HYPRE_BigInt iz, HYPRE_Int p, - HYPRE_Int q, HYPRE_Int r, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt *nx_part, - HYPRE_BigInt *ny_part, HYPRE_BigInt *nz_part ); -HYPRE_ParCSRMatrix GenerateSysLaplacian ( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, - HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, - HYPRE_Int num_fun, HYPRE_Real *mtrx, HYPRE_Real *value ); -HYPRE_ParCSRMatrix GenerateSysLaplacianVCoef ( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, - HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, - HYPRE_Int num_fun, HYPRE_Real *mtrx, HYPRE_Real *value ); /* par_lr_interp.c */ HYPRE_Int hypreDevice_extendWtoP ( HYPRE_Int P_nr_of_rows, HYPRE_Int W_nr_of_rows, @@ -2672,29 +2653,6 @@ HYPRE_Int hypre_BoomerAMGBuildPartialExtInterp ( hypre_ParCSRMatrix *A, HYPRE_In HYPRE_Int num_functions, HYPRE_Int *dof_func, HYPRE_Int debug_flag, HYPRE_Real trunc_factor, HYPRE_Int max_elmts, hypre_ParCSRMatrix **P_ptr ); -/* par_vardifconv.c */ -HYPRE_Real afun ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real bfun ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real cfun ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real dfun ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real efun ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real ffun ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real gfun ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real rfun ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real bndfun ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); - -/* par_vardifconv_rs.c */ -HYPRE_Real afun_rs ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real bfun_rs ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real cfun_rs ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real dfun_rs ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real efun_rs ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real ffun_rs ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real gfun_rs ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real rfun_rs ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real bndfun_rs ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); - - /* pcg_par.c */ void *hypre_ParKrylovCAlloc ( size_t count, size_t elt_size, HYPRE_MemoryLocation location ); HYPRE_Int hypre_ParKrylovFree ( void *ptr ); diff --git a/src/parcsr_ls/_hypre_parcsr_ls_mup.h b/src/parcsr_ls/_hypre_parcsr_ls_mup.h index fcd0990f5f..6affe12fe6 100644 --- a/src/parcsr_ls/_hypre_parcsr_ls_mup.h +++ b/src/parcsr_ls/_hypre_parcsr_ls_mup.h @@ -20,34 +20,6 @@ extern "C" { ******************************************************************************/ -HYPRE_ParCSRMatrix -GenerateSysLaplacian_flt( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Int num_fun, hypre_float *mtrx, hypre_float *value ); -HYPRE_ParCSRMatrix -GenerateSysLaplacian_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Int num_fun, hypre_double *mtrx, hypre_double *value ); -HYPRE_ParCSRMatrix -GenerateSysLaplacian_long_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Int num_fun, hypre_long_double *mtrx, hypre_long_double *value ); - -HYPRE_ParCSRMatrix -GenerateSysLaplacianVCoef_flt( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Int num_fun, hypre_float *mtrx, hypre_float *value ); -HYPRE_ParCSRMatrix -GenerateSysLaplacianVCoef_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Int num_fun, hypre_double *mtrx, hypre_double *value ); -HYPRE_ParCSRMatrix -GenerateSysLaplacianVCoef_long_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Int num_fun, hypre_long_double *mtrx, hypre_long_double *value ); - -HYPRE_Real -afun_flt( hypre_float xx, hypre_float yy, hypre_float zz ); -HYPRE_Real -afun_dbl( hypre_double xx, hypre_double yy, hypre_double zz ); -HYPRE_Real -afun_long_dbl( hypre_long_double xx, hypre_long_double yy, hypre_long_double zz ); - -HYPRE_Real -afun_rs_flt( hypre_float xx, hypre_float yy, hypre_float zz ); -HYPRE_Real -afun_rs_dbl( hypre_double xx, hypre_double yy, hypre_double zz ); -HYPRE_Real -afun_rs_long_dbl( hypre_long_double xx, hypre_long_double yy, hypre_long_double zz ); - void aux_indexFromMask_flt( HYPRE_Int n, HYPRE_Int *mask, HYPRE_Int *index ); void @@ -62,104 +34,6 @@ aux_maskCount_dbl( HYPRE_Int n, HYPRE_Int *mask ); HYPRE_Int aux_maskCount_long_dbl( HYPRE_Int n, HYPRE_Int *mask ); -HYPRE_Real -bfun_flt( hypre_float xx, hypre_float yy, hypre_float zz ); -HYPRE_Real -bfun_dbl( hypre_double xx, hypre_double yy, hypre_double zz ); -HYPRE_Real -bfun_long_dbl( hypre_long_double xx, hypre_long_double yy, hypre_long_double zz ); - -HYPRE_Real -bfun_rs_flt( hypre_float xx, hypre_float yy, hypre_float zz ); -HYPRE_Real -bfun_rs_dbl( hypre_double xx, hypre_double yy, hypre_double zz ); -HYPRE_Real -bfun_rs_long_dbl( hypre_long_double xx, hypre_long_double yy, hypre_long_double zz ); - -HYPRE_Real -bndfun_flt( hypre_float xx, hypre_float yy, hypre_float zz ); -HYPRE_Real -bndfun_dbl( hypre_double xx, hypre_double yy, hypre_double zz ); -HYPRE_Real -bndfun_long_dbl( hypre_long_double xx, hypre_long_double yy, hypre_long_double zz ); - -HYPRE_Real -bndfun_rs_flt( hypre_float xx, hypre_float yy, hypre_float zz ); -HYPRE_Real -bndfun_rs_dbl( hypre_double xx, hypre_double yy, hypre_double zz ); -HYPRE_Real -bndfun_rs_long_dbl( hypre_long_double xx, hypre_long_double yy, hypre_long_double zz ); - -HYPRE_Real -cfun_flt( hypre_float xx, hypre_float yy, hypre_float zz ); -HYPRE_Real -cfun_dbl( hypre_double xx, hypre_double yy, hypre_double zz ); -HYPRE_Real -cfun_long_dbl( hypre_long_double xx, hypre_long_double yy, hypre_long_double zz ); - -HYPRE_Real -cfun_rs_flt( hypre_float xx, hypre_float yy, hypre_float zz ); -HYPRE_Real -cfun_rs_dbl( hypre_double xx, hypre_double yy, hypre_double zz ); -HYPRE_Real -cfun_rs_long_dbl( hypre_long_double xx, hypre_long_double yy, hypre_long_double zz ); - -HYPRE_Real -dfun_flt( hypre_float xx, hypre_float yy, hypre_float zz ); -HYPRE_Real -dfun_dbl( hypre_double xx, hypre_double yy, hypre_double zz ); -HYPRE_Real -dfun_long_dbl( hypre_long_double xx, hypre_long_double yy, hypre_long_double zz ); - -HYPRE_Real -dfun_rs_flt( hypre_float xx, hypre_float yy, hypre_float zz ); -HYPRE_Real -dfun_rs_dbl( hypre_double xx, hypre_double yy, hypre_double zz ); -HYPRE_Real -dfun_rs_long_dbl( hypre_long_double xx, hypre_long_double yy, hypre_long_double zz ); - -HYPRE_Real -efun_flt( hypre_float xx, hypre_float yy, hypre_float zz ); -HYPRE_Real -efun_dbl( hypre_double xx, hypre_double yy, hypre_double zz ); -HYPRE_Real -efun_long_dbl( hypre_long_double xx, hypre_long_double yy, hypre_long_double zz ); - -HYPRE_Real -efun_rs_flt( hypre_float xx, hypre_float yy, hypre_float zz ); -HYPRE_Real -efun_rs_dbl( hypre_double xx, hypre_double yy, hypre_double zz ); -HYPRE_Real -efun_rs_long_dbl( hypre_long_double xx, hypre_long_double yy, hypre_long_double zz ); - -HYPRE_Real -ffun_flt( hypre_float xx, hypre_float yy, hypre_float zz ); -HYPRE_Real -ffun_dbl( hypre_double xx, hypre_double yy, hypre_double zz ); -HYPRE_Real -ffun_long_dbl( hypre_long_double xx, hypre_long_double yy, hypre_long_double zz ); - -HYPRE_Real -ffun_rs_flt( hypre_float xx, hypre_float yy, hypre_float zz ); -HYPRE_Real -ffun_rs_dbl( hypre_double xx, hypre_double yy, hypre_double zz ); -HYPRE_Real -ffun_rs_long_dbl( hypre_long_double xx, hypre_long_double yy, hypre_long_double zz ); - -HYPRE_Real -gfun_flt( hypre_float xx, hypre_float yy, hypre_float zz ); -HYPRE_Real -gfun_dbl( hypre_double xx, hypre_double yy, hypre_double zz ); -HYPRE_Real -gfun_long_dbl( hypre_long_double xx, hypre_long_double yy, hypre_long_double zz ); - -HYPRE_Real -gfun_rs_flt( hypre_float xx, hypre_float yy, hypre_float zz ); -HYPRE_Real -gfun_rs_dbl( hypre_double xx, hypre_double yy, hypre_double zz ); -HYPRE_Real -gfun_rs_long_dbl( hypre_long_double xx, hypre_long_double yy, hypre_long_double zz ); - HYPRE_Int hypre_ADSComputePi_flt( hypre_ParCSRMatrix *A, hypre_ParCSRMatrix *C, hypre_ParCSRMatrix *G, hypre_ParVector *x, hypre_ParVector *y, hypre_ParVector *z, hypre_ParCSRMatrix *PiNDx, hypre_ParCSRMatrix *PiNDy, hypre_ParCSRMatrix *PiNDz, hypre_ParCSRMatrix **Pi_ptr ); HYPRE_Int @@ -6621,20 +6495,6 @@ hypre_initialize_vecs_dbl( HYPRE_Int diag_n, HYPRE_Int offd_n, HYPRE_Int *diag_f void hypre_initialize_vecs_long_dbl( HYPRE_Int diag_n, HYPRE_Int offd_n, HYPRE_Int *diag_ftc, HYPRE_BigInt *offd_ftc, HYPRE_Int *diag_pm, HYPRE_Int *offd_pm, HYPRE_Int *tmp_CF ); -HYPRE_BigInt -hypre_map_flt( HYPRE_BigInt ix, HYPRE_BigInt iy, HYPRE_BigInt iz, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt *nx_part, HYPRE_BigInt *ny_part, HYPRE_BigInt *nz_part ); -HYPRE_BigInt -hypre_map_dbl( HYPRE_BigInt ix, HYPRE_BigInt iy, HYPRE_BigInt iz, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt *nx_part, HYPRE_BigInt *ny_part, HYPRE_BigInt *nz_part ); -HYPRE_BigInt -hypre_map_long_dbl( HYPRE_BigInt ix, HYPRE_BigInt iy, HYPRE_BigInt iz, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt *nx_part, HYPRE_BigInt *ny_part, HYPRE_BigInt *nz_part ); - -HYPRE_BigInt -hypre_map2_flt( HYPRE_BigInt ix, HYPRE_BigInt iy, HYPRE_Int p, HYPRE_Int q, HYPRE_BigInt nx, HYPRE_BigInt *nx_part, HYPRE_BigInt *ny_part ); -HYPRE_BigInt -hypre_map2_dbl( HYPRE_BigInt ix, HYPRE_BigInt iy, HYPRE_Int p, HYPRE_Int q, HYPRE_BigInt nx, HYPRE_BigInt *nx_part, HYPRE_BigInt *ny_part ); -HYPRE_BigInt -hypre_map2_long_dbl( HYPRE_BigInt ix, HYPRE_BigInt iy, HYPRE_Int p, HYPRE_Int q, HYPRE_BigInt nx, HYPRE_BigInt *nx_part, HYPRE_BigInt *ny_part ); - HYPRE_Int hypre_matinv_flt( hypre_float *x, hypre_float *a, HYPRE_Int k ); HYPRE_Int @@ -6726,20 +6586,6 @@ matrix_matrix_product_dbl( HYPRE_Int **i_element_edge_pointer, HYPRE_Int **j_ele HYPRE_Int matrix_matrix_product_long_dbl( HYPRE_Int **i_element_edge_pointer, HYPRE_Int **j_element_edge_pointer, HYPRE_Int *i_element_face, HYPRE_Int *j_element_face, HYPRE_Int *i_face_edge, HYPRE_Int *j_face_edge, HYPRE_Int num_elements, HYPRE_Int num_faces, HYPRE_Int num_edges ); -HYPRE_Real -rfun_flt( hypre_float xx, hypre_float yy, hypre_float zz ); -HYPRE_Real -rfun_dbl( hypre_double xx, hypre_double yy, hypre_double zz ); -HYPRE_Real -rfun_long_dbl( hypre_long_double xx, hypre_long_double yy, hypre_long_double zz ); - -HYPRE_Real -rfun_rs_flt( hypre_float xx, hypre_float yy, hypre_float zz ); -HYPRE_Real -rfun_rs_dbl( hypre_double xx, hypre_double yy, hypre_double zz ); -HYPRE_Real -rfun_rs_long_dbl( hypre_long_double xx, hypre_long_double yy, hypre_long_double zz ); - HYPRE_Int transpose_matrix_create_flt( HYPRE_Int **i_face_element_pointer, HYPRE_Int **j_face_element_pointer, HYPRE_Int *i_element_face, HYPRE_Int *j_element_face, HYPRE_Int num_elements, HYPRE_Int num_faces ); HYPRE_Int diff --git a/src/parcsr_ls/_hypre_parcsr_ls_mup_def.h b/src/parcsr_ls/_hypre_parcsr_ls_mup_def.h index 45caa6d997..e3f898f51f 100644 --- a/src/parcsr_ls/_hypre_parcsr_ls_mup_def.h +++ b/src/parcsr_ls/_hypre_parcsr_ls_mup_def.h @@ -671,33 +671,8 @@ #define HYPRE_SchwarzSetup HYPRE_MULTIPRECISION_FUNC ( HYPRE_SchwarzSetup ) #define HYPRE_SchwarzSolve HYPRE_MULTIPRECISION_FUNC ( HYPRE_SchwarzSolve ) #define HYPRE_TempParCSRSetupInterpreter HYPRE_MULTIPRECISION_FUNC ( HYPRE_TempParCSRSetupInterpreter ) -#define GenerateDifConv HYPRE_FIXEDPRECISION_FUNC ( GenerateDifConv ) -#define GenerateLaplacian HYPRE_FIXEDPRECISION_FUNC ( GenerateLaplacian ) -#define GenerateLaplacian27pt HYPRE_FIXEDPRECISION_FUNC ( GenerateLaplacian27pt ) -#define GenerateLaplacian9pt HYPRE_FIXEDPRECISION_FUNC ( GenerateLaplacian9pt ) -#define GenerateRSVarDifConv HYPRE_FIXEDPRECISION_FUNC ( GenerateRSVarDifConv ) -#define GenerateRotate7pt HYPRE_FIXEDPRECISION_FUNC ( GenerateRotate7pt ) -#define GenerateSysLaplacian HYPRE_FIXEDPRECISION_FUNC ( GenerateSysLaplacian ) -#define GenerateSysLaplacianVCoef HYPRE_FIXEDPRECISION_FUNC ( GenerateSysLaplacianVCoef ) -#define GenerateVarDifConv HYPRE_FIXEDPRECISION_FUNC ( GenerateVarDifConv ) -#define afun HYPRE_FIXEDPRECISION_FUNC ( afun ) -#define afun_rs HYPRE_FIXEDPRECISION_FUNC ( afun_rs ) #define aux_indexFromMask HYPRE_FIXEDPRECISION_FUNC ( aux_indexFromMask ) #define aux_maskCount HYPRE_FIXEDPRECISION_FUNC ( aux_maskCount ) -#define bfun HYPRE_FIXEDPRECISION_FUNC ( bfun ) -#define bfun_rs HYPRE_FIXEDPRECISION_FUNC ( bfun_rs ) -#define bndfun HYPRE_FIXEDPRECISION_FUNC ( bndfun ) -#define bndfun_rs HYPRE_FIXEDPRECISION_FUNC ( bndfun_rs ) -#define cfun HYPRE_FIXEDPRECISION_FUNC ( cfun ) -#define cfun_rs HYPRE_FIXEDPRECISION_FUNC ( cfun_rs ) -#define dfun HYPRE_FIXEDPRECISION_FUNC ( dfun ) -#define dfun_rs HYPRE_FIXEDPRECISION_FUNC ( dfun_rs ) -#define efun HYPRE_FIXEDPRECISION_FUNC ( efun ) -#define efun_rs HYPRE_FIXEDPRECISION_FUNC ( efun_rs ) -#define ffun HYPRE_FIXEDPRECISION_FUNC ( ffun ) -#define ffun_rs HYPRE_FIXEDPRECISION_FUNC ( ffun_rs ) -#define gfun HYPRE_FIXEDPRECISION_FUNC ( gfun ) -#define gfun_rs HYPRE_FIXEDPRECISION_FUNC ( gfun_rs ) #define hypre_ADSComputePi HYPRE_FIXEDPRECISION_FUNC ( hypre_ADSComputePi ) #define hypre_ADSComputePixyz HYPRE_FIXEDPRECISION_FUNC ( hypre_ADSComputePixyz ) #define hypre_ADSCreate HYPRE_FIXEDPRECISION_FUNC ( hypre_ADSCreate ) @@ -2124,8 +2099,6 @@ #define hypre_tempparcsrsetupinterprete HYPRE_FIXEDPRECISION_FUNC ( hypre_tempparcsrsetupinterprete ) #define hypre_update_entry HYPRE_FIXEDPRECISION_FUNC ( hypre_update_entry ) #define matrix_matrix_product HYPRE_FIXEDPRECISION_FUNC ( matrix_matrix_product ) -#define rfun HYPRE_FIXEDPRECISION_FUNC ( rfun ) -#define rfun_rs HYPRE_FIXEDPRECISION_FUNC ( rfun_rs ) #define transpose_matrix_create HYPRE_FIXEDPRECISION_FUNC ( transpose_matrix_create ) #endif diff --git a/src/parcsr_ls/_hypre_parcsr_ls_mup_undef.h b/src/parcsr_ls/_hypre_parcsr_ls_mup_undef.h index f2d19ec774..0c87cdf71d 100644 --- a/src/parcsr_ls/_hypre_parcsr_ls_mup_undef.h +++ b/src/parcsr_ls/_hypre_parcsr_ls_mup_undef.h @@ -668,33 +668,8 @@ #undef HYPRE_SchwarzSetup #undef HYPRE_SchwarzSolve #undef HYPRE_TempParCSRSetupInterpreter -#undef GenerateDifConv -#undef GenerateLaplacian -#undef GenerateLaplacian27pt -#undef GenerateLaplacian9pt -#undef GenerateRSVarDifConv -#undef GenerateRotate7pt -#undef GenerateSysLaplacian -#undef GenerateSysLaplacianVCoef -#undef GenerateVarDifConv -#undef afun -#undef afun_rs #undef aux_indexFromMask #undef aux_maskCount -#undef bfun -#undef bfun_rs -#undef bndfun -#undef bndfun_rs -#undef cfun -#undef cfun_rs -#undef dfun -#undef dfun_rs -#undef efun -#undef efun_rs -#undef ffun -#undef ffun_rs -#undef gfun -#undef gfun_rs #undef hypre_ADSComputePi #undef hypre_ADSComputePixyz #undef hypre_ADSCreate @@ -2121,6 +2096,4 @@ #undef hypre_tempparcsrsetupinterprete #undef hypre_update_entry #undef matrix_matrix_product -#undef rfun -#undef rfun_rs #undef transpose_matrix_create diff --git a/src/parcsr_ls/mup.fixed b/src/parcsr_ls/mup.fixed index 5fa91b4d8e..b5daee03a6 100644 --- a/src/parcsr_ls/mup.fixed +++ b/src/parcsr_ls/mup.fixed @@ -1,30 +1,5 @@ -GenerateDifConv -GenerateLaplacian -GenerateLaplacian27pt -GenerateLaplacian9pt -GenerateRSVarDifConv -GenerateRotate7pt -GenerateSysLaplacian -GenerateSysLaplacianVCoef -GenerateVarDifConv -afun -afun_rs aux_indexFromMask aux_maskCount -bfun -bfun_rs -bndfun -bndfun_rs -cfun -cfun_rs -dfun -dfun_rs -efun -efun_rs -ffun -ffun_rs -gfun -gfun_rs hypre_ADSComputePi hypre_ADSComputePixyz hypre_ADSCreate @@ -1451,6 +1426,4 @@ hypre_swap_int hypre_tempparcsrsetupinterprete hypre_update_entry matrix_matrix_product -rfun -rfun_rs transpose_matrix_create diff --git a/src/parcsr_ls/mup_fixed.c b/src/parcsr_ls/mup_fixed.c index bd7927c246..21d50c90d2 100644 --- a/src/parcsr_ls/mup_fixed.c +++ b/src/parcsr_ls/mup_fixed.c @@ -13,102 +13,6 @@ ******************************************************************************/ -/*--------------------------------------------------------------------------*/ - -HYPRE_ParCSRMatrix -GenerateDifConv( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Real *value ) -{ - return HYPRE_CURRENTPRECISION_FUNC(GenerateDifConv)( comm, nx, ny, nz, P, Q, R, p, q, r, value ); -} - -/*--------------------------------------------------------------------------*/ - -HYPRE_ParCSRMatrix -GenerateLaplacian( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Real *value ) -{ - return HYPRE_CURRENTPRECISION_FUNC(GenerateLaplacian)( comm, nx, ny, nz, P, Q, R, p, q, r, value ); -} - -/*--------------------------------------------------------------------------*/ - -HYPRE_ParCSRMatrix -GenerateLaplacian27pt( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Real *value ) -{ - return HYPRE_CURRENTPRECISION_FUNC(GenerateLaplacian27pt)( comm, nx, ny, nz, P, Q, R, p, q, r, value ); -} - -/*--------------------------------------------------------------------------*/ - -HYPRE_ParCSRMatrix -GenerateLaplacian9pt( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int p, HYPRE_Int q, HYPRE_Real *value ) -{ - return HYPRE_CURRENTPRECISION_FUNC(GenerateLaplacian9pt)( comm, nx, ny, P, Q, p, q, value ); -} - -/*--------------------------------------------------------------------------*/ - -HYPRE_ParCSRMatrix -GenerateRSVarDifConv( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Real eps, HYPRE_ParVector *rhs_ptr, HYPRE_Int type ) -{ - return HYPRE_CURRENTPRECISION_FUNC(GenerateRSVarDifConv)( comm, nx, ny, nz, P, Q, R, p, q, r, eps, rhs_ptr, type ); -} - -/*--------------------------------------------------------------------------*/ - -HYPRE_ParCSRMatrix -GenerateRotate7pt( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int p, HYPRE_Int q, HYPRE_Real alpha, HYPRE_Real eps ) -{ - return HYPRE_CURRENTPRECISION_FUNC(GenerateRotate7pt)( comm, nx, ny, P, Q, p, q, alpha, eps ); -} - -/*--------------------------------------------------------------------------*/ - -HYPRE_ParCSRMatrix -GenerateVarDifConv( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Real eps, HYPRE_ParVector *rhs_ptr ) -{ - return HYPRE_CURRENTPRECISION_FUNC(GenerateVarDifConv)( comm, nx, ny, nz, P, Q, R, p, q, r, eps, rhs_ptr ); -} - -/*--------------------------------------------------------------------------*/ - -float* -hypre_GenerateCoordinates( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Int coorddim ) -{ - return HYPRE_CURRENTPRECISION_FUNC(hypre_GenerateCoordinates)( comm, nx, ny, nz, P, Q, R, p, q, r, coorddim ); -} - - -/*--------------------------------------------------------------------------*/ - -HYPRE_ParCSRMatrix -GenerateSysLaplacian( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Int num_fun, HYPRE_Real *mtrx, HYPRE_Real *value ) -{ - return HYPRE_CURRENTPRECISION_FUNC(GenerateSysLaplacian)( comm, nx, ny, nz, P, Q, R, p, q, r, num_fun, mtrx, value ); -} - -/*--------------------------------------------------------------------------*/ - -HYPRE_ParCSRMatrix -GenerateSysLaplacianVCoef( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Int num_fun, HYPRE_Real *mtrx, HYPRE_Real *value ) -{ - return HYPRE_CURRENTPRECISION_FUNC(GenerateSysLaplacianVCoef)( comm, nx, ny, nz, P, Q, R, p, q, r, num_fun, mtrx, value ); -} - -/*--------------------------------------------------------------------------*/ - -HYPRE_Real -afun( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ) -{ - return HYPRE_CURRENTPRECISION_FUNC(afun)( xx, yy, zz ); -} - -/*--------------------------------------------------------------------------*/ - -HYPRE_Real -afun_rs( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ) -{ - return HYPRE_CURRENTPRECISION_FUNC(afun_rs)( xx, yy, zz ); -} /*--------------------------------------------------------------------------*/ @@ -128,118 +32,6 @@ aux_maskCount( HYPRE_Int n, HYPRE_Int *mask ) /*--------------------------------------------------------------------------*/ -HYPRE_Real -bfun( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ) -{ - return HYPRE_CURRENTPRECISION_FUNC(bfun)( xx, yy, zz ); -} - -/*--------------------------------------------------------------------------*/ - -HYPRE_Real -bfun_rs( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ) -{ - return HYPRE_CURRENTPRECISION_FUNC(bfun_rs)( xx, yy, zz ); -} - -/*--------------------------------------------------------------------------*/ - -HYPRE_Real -bndfun( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ) -{ - return HYPRE_CURRENTPRECISION_FUNC(bndfun)( xx, yy, zz ); -} - -/*--------------------------------------------------------------------------*/ - -HYPRE_Real -bndfun_rs( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ) -{ - return HYPRE_CURRENTPRECISION_FUNC(bndfun_rs)( xx, yy, zz ); -} - -/*--------------------------------------------------------------------------*/ - -HYPRE_Real -cfun( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ) -{ - return HYPRE_CURRENTPRECISION_FUNC(cfun)( xx, yy, zz ); -} - -/*--------------------------------------------------------------------------*/ - -HYPRE_Real -cfun_rs( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ) -{ - return HYPRE_CURRENTPRECISION_FUNC(cfun_rs)( xx, yy, zz ); -} - -/*--------------------------------------------------------------------------*/ - -HYPRE_Real -dfun( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ) -{ - return HYPRE_CURRENTPRECISION_FUNC(dfun)( xx, yy, zz ); -} - -/*--------------------------------------------------------------------------*/ - -HYPRE_Real -dfun_rs( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ) -{ - return HYPRE_CURRENTPRECISION_FUNC(dfun_rs)( xx, yy, zz ); -} - -/*--------------------------------------------------------------------------*/ - -HYPRE_Real -efun( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ) -{ - return HYPRE_CURRENTPRECISION_FUNC(efun)( xx, yy, zz ); -} - -/*--------------------------------------------------------------------------*/ - -HYPRE_Real -efun_rs( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ) -{ - return HYPRE_CURRENTPRECISION_FUNC(efun_rs)( xx, yy, zz ); -} - -/*--------------------------------------------------------------------------*/ - -HYPRE_Real -ffun( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ) -{ - return HYPRE_CURRENTPRECISION_FUNC(ffun)( xx, yy, zz ); -} - -/*--------------------------------------------------------------------------*/ - -HYPRE_Real -ffun_rs( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ) -{ - return HYPRE_CURRENTPRECISION_FUNC(ffun_rs)( xx, yy, zz ); -} - -/*--------------------------------------------------------------------------*/ - -HYPRE_Real -gfun( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ) -{ - return HYPRE_CURRENTPRECISION_FUNC(gfun)( xx, yy, zz ); -} - -/*--------------------------------------------------------------------------*/ - -HYPRE_Real -gfun_rs( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ) -{ - return HYPRE_CURRENTPRECISION_FUNC(gfun_rs)( xx, yy, zz ); -} - -/*--------------------------------------------------------------------------*/ - HYPRE_Int hypre_ADSComputePi( hypre_ParCSRMatrix *A, hypre_ParCSRMatrix *C, hypre_ParCSRMatrix *G, hypre_ParVector *x, hypre_ParVector *y, hypre_ParVector *z, hypre_ParCSRMatrix *PiNDx, hypre_ParCSRMatrix *PiNDy, hypre_ParCSRMatrix *PiNDz, hypre_ParCSRMatrix **Pi_ptr ) { @@ -7624,22 +7416,6 @@ hypre_initialize_vecs( HYPRE_Int diag_n, HYPRE_Int offd_n, HYPRE_Int *diag_ftc, /*--------------------------------------------------------------------------*/ -HYPRE_BigInt -hypre_map( HYPRE_BigInt ix, HYPRE_BigInt iy, HYPRE_BigInt iz, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt *nx_part, HYPRE_BigInt *ny_part, HYPRE_BigInt *nz_part ) -{ - return HYPRE_CURRENTPRECISION_FUNC(hypre_map)( ix, iy, iz, p, q, r, nx, ny, nx_part, ny_part, nz_part ); -} - -/*--------------------------------------------------------------------------*/ - -HYPRE_BigInt -hypre_map2( HYPRE_BigInt ix, HYPRE_BigInt iy, HYPRE_Int p, HYPRE_Int q, HYPRE_BigInt nx, HYPRE_BigInt *nx_part, HYPRE_BigInt *ny_part ) -{ - return HYPRE_CURRENTPRECISION_FUNC(hypre_map2)( ix, iy, p, q, nx, nx_part, ny_part ); -} - -/*--------------------------------------------------------------------------*/ - HYPRE_Int hypre_matinv( HYPRE_Real *x, HYPRE_Real *a, HYPRE_Int k ) { @@ -7744,22 +7520,6 @@ matrix_matrix_product( HYPRE_Int **i_element_edge_pointer, HYPRE_Int **j_element /*--------------------------------------------------------------------------*/ -HYPRE_Real -rfun( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ) -{ - return HYPRE_CURRENTPRECISION_FUNC(rfun)( xx, yy, zz ); -} - -/*--------------------------------------------------------------------------*/ - -HYPRE_Real -rfun_rs( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ) -{ - return HYPRE_CURRENTPRECISION_FUNC(rfun_rs)( xx, yy, zz ); -} - -/*--------------------------------------------------------------------------*/ - HYPRE_Int transpose_matrix_create( HYPRE_Int **i_face_element_pointer, HYPRE_Int **j_face_element_pointer, HYPRE_Int *i_element_face, HYPRE_Int *j_element_face, HYPRE_Int num_elements, HYPRE_Int num_faces ) { diff --git a/src/parcsr_ls/par_coordinates.c b/src/parcsr_ls/par_coordinates.c deleted file mode 100644 index f4896b75c7..0000000000 --- a/src/parcsr_ls/par_coordinates.c +++ /dev/null @@ -1,81 +0,0 @@ -/****************************************************************************** - * Copyright (c) 1998 Lawrence Livermore National Security, LLC and other - * HYPRE Project Developers. See the top-level COPYRIGHT file for details. - * - * SPDX-License-Identifier: (Apache-2.0 OR MIT) - ******************************************************************************/ - -#include "_hypre_parcsr_ls.h" - -/*-------------------------------------------------------------------------- - * hypre_GenerateCoordinates - *--------------------------------------------------------------------------*/ - -float * -hypre_GenerateCoordinates( MPI_Comm comm, - HYPRE_BigInt nx, - HYPRE_BigInt ny, - HYPRE_BigInt nz, - HYPRE_Int P, - HYPRE_Int Q, - HYPRE_Int R, - HYPRE_Int p, - HYPRE_Int q, - HYPRE_Int r, - HYPRE_Int coorddim) -{ - HYPRE_UNUSED_VAR(comm); - - HYPRE_BigInt ix, iy, iz; - HYPRE_Int cnt; - - HYPRE_Int nx_local, ny_local, nz_local; - HYPRE_Int local_num_rows; - - HYPRE_BigInt *nx_part; - HYPRE_BigInt *ny_part; - HYPRE_BigInt *nz_part; - - float *coord = NULL; - - if (coorddim < 1 || coorddim > 3) - { - return NULL; - } - - hypre_GeneratePartitioning(nx, P, &nx_part); - hypre_GeneratePartitioning(ny, Q, &ny_part); - hypre_GeneratePartitioning(nz, R, &nz_part); - - nx_local = (HYPRE_Int)(nx_part[p + 1] - nx_part[p]); - ny_local = (HYPRE_Int)(ny_part[q + 1] - ny_part[q]); - nz_local = (HYPRE_Int)(nz_part[r + 1] - nz_part[r]); - - local_num_rows = nx_local * ny_local * nz_local; - - coord = hypre_CTAlloc(float, coorddim * local_num_rows, HYPRE_MEMORY_HOST); - - cnt = 0; - for (iz = nz_part[r]; iz < nz_part[r + 1]; iz++) - { - for (iy = ny_part[q]; iy < ny_part[q + 1]; iy++) - { - for (ix = nx_part[p]; ix < nx_part[p + 1]; ix++) - { - /* set coordinates BM Oct 17, 2006 */ - if (coord) - { - if (nx > 1) { coord[cnt++] = ix; } - if (ny > 1) { coord[cnt++] = iy; } - if (nz > 1) { coord[cnt++] = iz; } - } - } - } - } - - hypre_TFree(nx_part, HYPRE_MEMORY_HOST); - hypre_TFree(ny_part, HYPRE_MEMORY_HOST); - hypre_TFree(nz_part, HYPRE_MEMORY_HOST); - - return coord; -} diff --git a/src/parcsr_ls/par_difconv.c b/src/parcsr_ls/par_difconv.c deleted file mode 100644 index 6e4fb5ae7b..0000000000 --- a/src/parcsr_ls/par_difconv.c +++ /dev/null @@ -1,343 +0,0 @@ -/****************************************************************************** - * Copyright (c) 1998 Lawrence Livermore National Security, LLC and other - * HYPRE Project Developers. See the top-level COPYRIGHT file for details. - * - * SPDX-License-Identifier: (Apache-2.0 OR MIT) - ******************************************************************************/ - -#include "_hypre_parcsr_ls.h" - -/*-------------------------------------------------------------------------- - * hypre_GenerateDifConv - *--------------------------------------------------------------------------*/ - -HYPRE_ParCSRMatrix -GenerateDifConv( MPI_Comm comm, - HYPRE_BigInt nx, - HYPRE_BigInt ny, - HYPRE_BigInt nz, - HYPRE_Int P, - HYPRE_Int Q, - HYPRE_Int R, - HYPRE_Int p, - HYPRE_Int q, - HYPRE_Int r, - HYPRE_Real *value ) -{ - hypre_ParCSRMatrix *A; - hypre_CSRMatrix *diag; - hypre_CSRMatrix *offd; - - HYPRE_Int *diag_i; - HYPRE_Int *diag_j; - HYPRE_Real *diag_data; - - HYPRE_Int *offd_i; - HYPRE_Int *offd_j = NULL; - HYPRE_BigInt *big_offd_j = NULL; - HYPRE_Real *offd_data = NULL; - - HYPRE_BigInt global_part[2]; - HYPRE_BigInt ix, iy, iz; - HYPRE_Int ip, iq, ir; - HYPRE_Int cnt, o_cnt; - HYPRE_Int local_num_rows; - HYPRE_BigInt *col_map_offd = NULL; - HYPRE_Int row_index; - HYPRE_Int i, j; - - HYPRE_Int nx_local, ny_local, nz_local; - HYPRE_Int num_cols_offd; - HYPRE_BigInt grid_size; - - HYPRE_BigInt *nx_part; - HYPRE_BigInt *ny_part; - HYPRE_BigInt *nz_part; - - HYPRE_Int num_procs; - HYPRE_Int P_busy, Q_busy, R_busy; - - hypre_MPI_Comm_size(comm, &num_procs); - - grid_size = nx * ny * nz; - - hypre_GeneratePartitioning(nx, P, &nx_part); - hypre_GeneratePartitioning(ny, Q, &ny_part); - hypre_GeneratePartitioning(nz, R, &nz_part); - - nx_local = (HYPRE_Int)(nx_part[p + 1] - nx_part[p]); - ny_local = (HYPRE_Int)(ny_part[q + 1] - ny_part[q]); - nz_local = (HYPRE_Int)(nz_part[r + 1] - nz_part[r]); - - local_num_rows = nx_local * ny_local * nz_local; - - ip = p; - iq = q; - ir = r; - - global_part[0] = nz_part[ir] * nx * ny + (ny_part[iq] * nx + nx_part[ip] * ny_local) * nz_local; - global_part[1] = global_part[0] + (HYPRE_BigInt)local_num_rows; - - diag_i = hypre_CTAlloc(HYPRE_Int, local_num_rows + 1, HYPRE_MEMORY_HOST); - offd_i = hypre_CTAlloc(HYPRE_Int, local_num_rows + 1, HYPRE_MEMORY_HOST); - - P_busy = hypre_min(nx, P); - Q_busy = hypre_min(ny, Q); - R_busy = hypre_min(nz, R); - - num_cols_offd = 0; - if (p) { num_cols_offd += ny_local * nz_local; } - if (p < P_busy - 1) { num_cols_offd += ny_local * nz_local; } - if (q) { num_cols_offd += nx_local * nz_local; } - if (q < Q_busy - 1) { num_cols_offd += nx_local * nz_local; } - if (r) { num_cols_offd += nx_local * ny_local; } - if (r < R_busy - 1) { num_cols_offd += nx_local * ny_local; } - - if (!local_num_rows) { num_cols_offd = 0; } - - cnt = 1; - o_cnt = 1; - diag_i[0] = 0; - offd_i[0] = 0; - for (iz = nz_part[ir]; iz < nz_part[ir + 1]; iz++) - { - for (iy = ny_part[iq]; iy < ny_part[iq + 1]; iy++) - { - for (ix = nx_part[ip]; ix < nx_part[ip + 1]; ix++) - { - diag_i[cnt] = diag_i[cnt - 1]; - offd_i[o_cnt] = offd_i[o_cnt - 1]; - diag_i[cnt]++; - if (iz > nz_part[ir]) - { - diag_i[cnt]++; - } - else - { - if (iz) - { - offd_i[o_cnt]++; - } - } - if (iy > ny_part[iq]) - { - diag_i[cnt]++; - } - else - { - if (iy) - { - offd_i[o_cnt]++; - } - } - if (ix > nx_part[ip]) - { - diag_i[cnt]++; - } - else - { - if (ix) - { - offd_i[o_cnt]++; - } - } - if (ix + 1 < nx_part[ip + 1]) - { - diag_i[cnt]++; - } - else - { - if (ix + 1 < nx) - { - offd_i[o_cnt]++; - } - } - if (iy + 1 < ny_part[iq + 1]) - { - diag_i[cnt]++; - } - else - { - if (iy + 1 < ny) - { - offd_i[o_cnt]++; - } - } - if (iz + 1 < nz_part[ir + 1]) - { - diag_i[cnt]++; - } - else - { - if (iz + 1 < nz) - { - offd_i[o_cnt]++; - } - } - cnt++; - o_cnt++; - } - } - } - - diag_j = hypre_CTAlloc(HYPRE_Int, diag_i[local_num_rows], HYPRE_MEMORY_HOST); - diag_data = hypre_CTAlloc(HYPRE_Real, diag_i[local_num_rows], HYPRE_MEMORY_HOST); - - if (offd_i[local_num_rows]) - { - offd_j = hypre_CTAlloc(HYPRE_Int, offd_i[local_num_rows], HYPRE_MEMORY_HOST); - big_offd_j = hypre_CTAlloc(HYPRE_BigInt, offd_i[local_num_rows], HYPRE_MEMORY_HOST); - offd_data = hypre_CTAlloc(HYPRE_Real, offd_i[local_num_rows], HYPRE_MEMORY_HOST); - } - - row_index = 0; - cnt = 0; - o_cnt = 0; - for (iz = nz_part[ir]; iz < nz_part[ir + 1]; iz++) - { - for (iy = ny_part[iq]; iy < ny_part[iq + 1]; iy++) - { - for (ix = nx_part[ip]; ix < nx_part[ip + 1]; ix++) - { - diag_j[cnt] = row_index; - diag_data[cnt++] = value[0]; - if (iz > nz_part[ir]) - { - diag_j[cnt] = row_index - nx_local * ny_local; - diag_data[cnt++] = value[3]; - } - else - { - if (iz) - { - big_offd_j[o_cnt] = hypre_map(ix, iy, iz - 1, ip, iq, ir - 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[3]; - } - } - if (iy > ny_part[iq]) - { - diag_j[cnt] = row_index - nx_local; - diag_data[cnt++] = value[2]; - } - else - { - if (iy) - { - big_offd_j[o_cnt] = hypre_map(ix, iy - 1, iz, ip, iq - 1, ir, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[2]; - } - } - if (ix > nx_part[ip]) - { - diag_j[cnt] = row_index - 1; - diag_data[cnt++] = value[1]; - } - else - { - if (ix) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy, iz, ip - 1, iq, ir, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - if (ix + 1 < nx_part[ip + 1]) - { - diag_j[cnt] = row_index + 1; - diag_data[cnt++] = value[4]; - } - else - { - if (ix + 1 < nx) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy, iz, ip + 1, iq, ir, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[4]; - } - } - if (iy + 1 < ny_part[iq + 1]) - { - diag_j[cnt] = row_index + nx_local; - diag_data[cnt++] = value[5]; - } - else - { - if (iy + 1 < ny) - { - big_offd_j[o_cnt] = hypre_map(ix, iy + 1, iz, ip, iq + 1, ir, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[5]; - } - } - if (iz + 1 < nz_part[ir + 1]) - { - diag_j[cnt] = row_index + nx_local * ny_local; - diag_data[cnt++] = value[6]; - } - else - { - if (iz + 1 < nz) - { - big_offd_j[o_cnt] = hypre_map(ix, iy, iz + 1, ip, iq, ir + 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[6]; - } - } - row_index++; - } - } - } - - if (num_cols_offd) - { - col_map_offd = hypre_CTAlloc(HYPRE_BigInt, num_cols_offd, HYPRE_MEMORY_HOST); - for (i = 0; i < num_cols_offd; i++) - { - col_map_offd[i] = big_offd_j[i]; - } - - hypre_BigQsort0(col_map_offd, 0, num_cols_offd - 1); - - for (i = 0; i < num_cols_offd; i++) - for (j = 0; j < num_cols_offd; j++) - if (big_offd_j[i] == col_map_offd[j]) - { - offd_j[i] = j; - break; - } - } - - A = hypre_ParCSRMatrixCreate(comm, grid_size, grid_size, - global_part, global_part, num_cols_offd, - diag_i[local_num_rows], - offd_i[local_num_rows]); - - hypre_ParCSRMatrixColMapOffd(A) = col_map_offd; - - diag = hypre_ParCSRMatrixDiag(A); - hypre_CSRMatrixI(diag) = diag_i; - hypre_CSRMatrixJ(diag) = diag_j; - hypre_CSRMatrixData(diag) = diag_data; - - offd = hypre_ParCSRMatrixOffd(A); - hypre_CSRMatrixI(offd) = offd_i; - if (num_cols_offd) - { - hypre_CSRMatrixJ(offd) = offd_j; - hypre_CSRMatrixData(offd) = offd_data; - } - - hypre_CSRMatrixMemoryLocation(diag) = HYPRE_MEMORY_HOST; - hypre_CSRMatrixMemoryLocation(offd) = HYPRE_MEMORY_HOST; - - hypre_ParCSRMatrixMigrate(A, hypre_HandleMemoryLocation(hypre_handle())); - - hypre_TFree(nx_part, HYPRE_MEMORY_HOST); - hypre_TFree(ny_part, HYPRE_MEMORY_HOST); - hypre_TFree(nz_part, HYPRE_MEMORY_HOST); - hypre_TFree(big_offd_j, HYPRE_MEMORY_HOST); - - return (HYPRE_ParCSRMatrix) A; -} diff --git a/src/parcsr_ls/par_laplace.c b/src/parcsr_ls/par_laplace.c deleted file mode 100644 index 433432119b..0000000000 --- a/src/parcsr_ls/par_laplace.c +++ /dev/null @@ -1,1362 +0,0 @@ -/****************************************************************************** - * Copyright (c) 1998 Lawrence Livermore National Security, LLC and other - * HYPRE Project Developers. See the top-level COPYRIGHT file for details. - * - * SPDX-License-Identifier: (Apache-2.0 OR MIT) - ******************************************************************************/ - -#include "_hypre_parcsr_ls.h" - -/*-------------------------------------------------------------------------- - * hypre_GenerateLaplacian - *--------------------------------------------------------------------------*/ - -HYPRE_ParCSRMatrix -GenerateLaplacian( MPI_Comm comm, - HYPRE_BigInt nx, - HYPRE_BigInt ny, - HYPRE_BigInt nz, - HYPRE_Int P, - HYPRE_Int Q, - HYPRE_Int R, - HYPRE_Int ip, - HYPRE_Int iq, - HYPRE_Int ir, - HYPRE_Real *value ) -{ - hypre_ParCSRMatrix *A; - hypre_CSRMatrix *diag; - hypre_CSRMatrix *offd; - - HYPRE_Int *diag_i; - HYPRE_Int *diag_j; - HYPRE_Real *diag_data; - - HYPRE_Int *offd_i; - HYPRE_Int *offd_j = NULL; - HYPRE_BigInt *big_offd_j = NULL; - HYPRE_Real *offd_data = NULL; - - HYPRE_BigInt global_part[2]; - HYPRE_BigInt ix, iy, iz; - HYPRE_Int cnt, o_cnt; - HYPRE_Int local_num_rows; - HYPRE_BigInt *col_map_offd; - HYPRE_Int row_index; - HYPRE_Int i, j; - - HYPRE_Int nx_local, ny_local, nz_local; - HYPRE_Int num_cols_offd; - HYPRE_BigInt grid_size; - - HYPRE_BigInt *nx_part; - HYPRE_BigInt *ny_part; - HYPRE_BigInt *nz_part; - - HYPRE_Int num_procs; - HYPRE_Int P_busy, Q_busy, R_busy; - - hypre_MPI_Comm_size(comm, &num_procs); - - grid_size = nx * ny * nz; - - hypre_GeneratePartitioning(nx, P, &nx_part); - hypre_GeneratePartitioning(ny, Q, &ny_part); - hypre_GeneratePartitioning(nz, R, &nz_part); - - nx_local = (HYPRE_Int)(nx_part[ip + 1] - nx_part[ip]); - ny_local = (HYPRE_Int)(ny_part[iq + 1] - ny_part[iq]); - nz_local = (HYPRE_Int)(nz_part[ir + 1] - nz_part[ir]); - - local_num_rows = nx_local * ny_local * nz_local; - - global_part[0] = nz_part[ir] * nx * ny + (ny_part[iq] * nx + nx_part[ip] * ny_local) * nz_local; - global_part[1] = global_part[0] + (HYPRE_BigInt)local_num_rows; - - diag_i = hypre_CTAlloc(HYPRE_Int, local_num_rows + 1, HYPRE_MEMORY_HOST); - offd_i = hypre_CTAlloc(HYPRE_Int, local_num_rows + 1, HYPRE_MEMORY_HOST); - - P_busy = hypre_min(nx, P); - Q_busy = hypre_min(ny, Q); - R_busy = hypre_min(nz, R); - - num_cols_offd = 0; - if (ip) { num_cols_offd += ny_local * nz_local; } - if (ip < P_busy - 1) { num_cols_offd += ny_local * nz_local; } - if (iq) { num_cols_offd += nx_local * nz_local; } - if (iq < Q_busy - 1) { num_cols_offd += nx_local * nz_local; } - if (ir) { num_cols_offd += nx_local * ny_local; } - if (ir < R_busy - 1) { num_cols_offd += nx_local * ny_local; } - - if (!local_num_rows) { num_cols_offd = 0; } - - col_map_offd = hypre_CTAlloc(HYPRE_BigInt, num_cols_offd, HYPRE_MEMORY_HOST); - - cnt = 1; - o_cnt = 1; - diag_i[0] = 0; - offd_i[0] = 0; - for (iz = nz_part[ir]; iz < nz_part[ir + 1]; iz++) - { - for (iy = ny_part[iq]; iy < ny_part[iq + 1]; iy++) - { - for (ix = nx_part[ip]; ix < nx_part[ip + 1]; ix++) - { - diag_i[cnt] = diag_i[cnt - 1]; - offd_i[o_cnt] = offd_i[o_cnt - 1]; - diag_i[cnt]++; - if (iz > nz_part[ir]) - { - diag_i[cnt]++; - } - else - { - if (iz) - { - offd_i[o_cnt]++; - } - } - if (iy > ny_part[iq] ) - { - diag_i[cnt]++; - } - else - { - if (iy) - { - offd_i[o_cnt]++; - } - } - if (ix > nx_part[ip] ) - { - diag_i[cnt]++; - } - else - { - if (ix) - { - offd_i[o_cnt]++; - } - } - if (ix + 1 < nx_part[ip + 1]) - { - diag_i[cnt]++; - } - else - { - if (ix + 1 < nx) - { - offd_i[o_cnt]++; - } - } - if (iy + 1 < ny_part[iq + 1]) - { - diag_i[cnt]++; - } - else - { - if (iy + 1 < ny) - { - offd_i[o_cnt]++; - } - } - if (iz + 1 < nz_part[ir + 1]) - { - diag_i[cnt]++; - } - else - { - if (iz + 1 < nz) - { - offd_i[o_cnt]++; - } - } - cnt++; - o_cnt++; - } - } - } - - diag_j = hypre_CTAlloc(HYPRE_Int, diag_i[local_num_rows], HYPRE_MEMORY_HOST); - diag_data = hypre_CTAlloc(HYPRE_Real, diag_i[local_num_rows], HYPRE_MEMORY_HOST); - - if (num_procs > 1) - { - big_offd_j = hypre_CTAlloc(HYPRE_BigInt, offd_i[local_num_rows], HYPRE_MEMORY_HOST); - offd_j = hypre_CTAlloc(HYPRE_Int, offd_i[local_num_rows], HYPRE_MEMORY_HOST); - offd_data = hypre_CTAlloc(HYPRE_Real, offd_i[local_num_rows], HYPRE_MEMORY_HOST); - } - - row_index = 0; - cnt = 0; - o_cnt = 0; - for (iz = nz_part[ir]; iz < nz_part[ir + 1]; iz++) - { - for (iy = ny_part[iq]; iy < ny_part[iq + 1]; iy++) - { - for (ix = nx_part[ip]; ix < nx_part[ip + 1]; ix++) - { - diag_j[cnt] = row_index; - diag_data[cnt++] = value[0]; - if (iz > nz_part[ir]) - { - diag_j[cnt] = row_index - nx_local * ny_local; - diag_data[cnt++] = value[3]; - } - else - { - if (iz) - { - big_offd_j[o_cnt] = hypre_map(ix, iy, iz - 1, ip, iq, ir - 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[3]; - } - } - if (iy > ny_part[iq]) - { - diag_j[cnt] = row_index - nx_local; - diag_data[cnt++] = value[2]; - } - else - { - if (iy) - { - big_offd_j[o_cnt] = hypre_map(ix, iy - 1, iz, ip, iq - 1, ir, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[2]; - } - } - if (ix > nx_part[ip]) - { - diag_j[cnt] = row_index - 1; - diag_data[cnt++] = value[1]; - } - else - { - if (ix) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy, iz, ip - 1, iq, ir, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - if (ix + 1 < nx_part[ip + 1]) - { - diag_j[cnt] = row_index + 1; - diag_data[cnt++] = value[1]; - } - else - { - if (ix + 1 < nx) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy, iz, ip + 1, iq, ir, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - if (iy + 1 < ny_part[iq + 1]) - { - diag_j[cnt] = row_index + nx_local; - diag_data[cnt++] = value[2]; - } - else - { - if (iy + 1 < ny) - { - big_offd_j[o_cnt] = hypre_map(ix, iy + 1, iz, ip, iq + 1, ir, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[2]; - } - } - if (iz + 1 < nz_part[ir + 1]) - { - diag_j[cnt] = row_index + nx_local * ny_local; - diag_data[cnt++] = value[3]; - } - else - { - if (iz + 1 < nz) - { - big_offd_j[o_cnt] = hypre_map(ix, iy, iz + 1, ip, iq, ir + 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[3]; - } - } - row_index++; - } - } - } - - if (num_procs > 1) - { - for (i = 0; i < num_cols_offd; i++) - { - col_map_offd[i] = big_offd_j[i]; - } - - hypre_BigQsort0(col_map_offd, 0, num_cols_offd - 1); - - for (i = 0; i < num_cols_offd; i++) - for (j = 0; j < num_cols_offd; j++) - if (big_offd_j[i] == col_map_offd[j]) - { - offd_j[i] = j; - break; - } - - /*for (i=0; i < offd_i[local_num_rows]; i++) - { - offd_j[i] = hypre_BigBinarySearch(col_map_offd,big_offd_j[i],num_cols_offd); - }*/ - } - - A = hypre_ParCSRMatrixCreate(comm, grid_size, grid_size, - global_part, global_part, num_cols_offd, - diag_i[local_num_rows], - offd_i[local_num_rows]); - - hypre_ParCSRMatrixColMapOffd(A) = col_map_offd; - - diag = hypre_ParCSRMatrixDiag(A); - hypre_CSRMatrixI(diag) = diag_i; - hypre_CSRMatrixJ(diag) = diag_j; - hypre_CSRMatrixData(diag) = diag_data; - - offd = hypre_ParCSRMatrixOffd(A); - hypre_CSRMatrixI(offd) = offd_i; - if (num_cols_offd) - { - hypre_CSRMatrixJ(offd) = offd_j; - hypre_CSRMatrixData(offd) = offd_data; - } - - hypre_CSRMatrixMemoryLocation(diag) = HYPRE_MEMORY_HOST; - hypre_CSRMatrixMemoryLocation(offd) = HYPRE_MEMORY_HOST; - - hypre_ParCSRMatrixMigrate(A, hypre_HandleMemoryLocation(hypre_handle())); - - hypre_TFree(nx_part, HYPRE_MEMORY_HOST); - hypre_TFree(ny_part, HYPRE_MEMORY_HOST); - hypre_TFree(nz_part, HYPRE_MEMORY_HOST); - hypre_TFree(big_offd_j, HYPRE_MEMORY_HOST); - - return (HYPRE_ParCSRMatrix) A; -} - -/*-------------------------------------------------------------------------- - *--------------------------------------------------------------------------*/ - -HYPRE_BigInt -hypre_map(HYPRE_BigInt ix, - HYPRE_BigInt iy, - HYPRE_BigInt iz, - HYPRE_Int p, - HYPRE_Int q, - HYPRE_Int r, - HYPRE_BigInt nx, - HYPRE_BigInt ny, - HYPRE_BigInt *nx_part, - HYPRE_BigInt *ny_part, - HYPRE_BigInt *nz_part) -{ - HYPRE_Int nx_local = (HYPRE_Int)(nx_part[p + 1] - nx_part[p]); - HYPRE_Int ny_local = (HYPRE_Int)(ny_part[q + 1] - ny_part[q]); - HYPRE_Int nz_local = (HYPRE_Int)(nz_part[r + 1] - nz_part[r]); - HYPRE_Int ix_local = (HYPRE_Int)(ix - nx_part[p]); - HYPRE_Int iy_local = (HYPRE_Int)(iy - ny_part[q]); - HYPRE_Int iz_local = (HYPRE_Int)(iz - nz_part[r]); - HYPRE_BigInt global_index; - - global_index = nz_part[r] * nx * ny + ny_part[q] * nx * (HYPRE_BigInt)nz_local + nx_part[p] * - (HYPRE_BigInt)(ny_local * nz_local); - global_index += (HYPRE_BigInt)((iz_local * ny_local + iy_local) * nx_local + ix_local); - return global_index; -} - -/*-------------------------------------------------------------------------- - * hypre_GenerateVectorLaplacian - this is the systems version - *--------------------------------------------------------------------------*/ - -HYPRE_ParCSRMatrix -GenerateSysLaplacian( MPI_Comm comm, - HYPRE_BigInt nx, - HYPRE_BigInt ny, - HYPRE_BigInt nz, - HYPRE_Int P, - HYPRE_Int Q, - HYPRE_Int R, - HYPRE_Int p, - HYPRE_Int q, - HYPRE_Int r, - HYPRE_Int num_fun, - HYPRE_Real *mtrx, - HYPRE_Real *value ) -{ - hypre_ParCSRMatrix *A; - hypre_CSRMatrix *diag; - hypre_CSRMatrix *offd; - - HYPRE_Int *diag_i; - HYPRE_Int *diag_j; - HYPRE_Real *diag_data; - - HYPRE_Int *offd_i; - HYPRE_Int *offd_j = NULL; - HYPRE_BigInt *big_offd_j = NULL; - HYPRE_Real *offd_data = NULL; - - HYPRE_BigInt global_part[2]; - HYPRE_Int ix, iy, iz; - HYPRE_Int cnt, o_cnt; - HYPRE_Int local_num_rows; - HYPRE_BigInt *col_map_offd; - HYPRE_Int row_index, row, col; - HYPRE_Int index, diag_index; - HYPRE_Int i, j; - - HYPRE_Int nx_local, ny_local, nz_local; - HYPRE_Int num_cols_offd; - HYPRE_BigInt grid_size; - HYPRE_Int local_grid_size; - HYPRE_Int first_j, j_ind; - HYPRE_BigInt big_first_j, big_num_fun = (HYPRE_BigInt)num_fun; - HYPRE_Int num_coeffs, num_offd_coeffs; - - HYPRE_BigInt *nx_part; - HYPRE_BigInt *ny_part; - HYPRE_BigInt *nz_part; - - HYPRE_Int num_procs; - HYPRE_Int P_busy, Q_busy, R_busy; - HYPRE_Real val; - HYPRE_Int gp_size; - - hypre_MPI_Comm_size(comm, &num_procs); - - grid_size = nx * ny * nz; - - hypre_GeneratePartitioning(nx, P, &nx_part); - hypre_GeneratePartitioning(ny, Q, &ny_part); - hypre_GeneratePartitioning(nz, R, &nz_part); - - nx_local = (HYPRE_Int)(nx_part[p + 1] - nx_part[p]); - ny_local = (HYPRE_Int)(ny_part[q + 1] - ny_part[q]); - nz_local = (HYPRE_Int)(nz_part[r + 1] - nz_part[r]); - - local_grid_size = nx_local * ny_local * nz_local; - local_num_rows = num_fun * local_grid_size; - - global_part[0] = nz_part[r] * nx * ny + (ny_part[q] * nx + nx_part[p] * ny_local) * nz_local; - global_part[1] = global_part[0] + (HYPRE_BigInt)local_grid_size; - gp_size = 2; - - diag_i = hypre_CTAlloc(HYPRE_Int, local_num_rows + 1, HYPRE_MEMORY_HOST); - offd_i = hypre_CTAlloc(HYPRE_Int, local_num_rows + 1, HYPRE_MEMORY_HOST); - - P_busy = hypre_min(nx, P); - Q_busy = hypre_min(ny, Q); - R_busy = hypre_min(nz, R); - - num_cols_offd = 0; - if (p) { num_cols_offd += ny_local * nz_local; } - if (p < P_busy - 1) { num_cols_offd += ny_local * nz_local; } - if (q) { num_cols_offd += nx_local * nz_local; } - if (q < Q_busy - 1) { num_cols_offd += nx_local * nz_local; } - if (r) { num_cols_offd += nx_local * ny_local; } - if (r < R_busy - 1) { num_cols_offd += nx_local * ny_local; } - num_cols_offd *= num_fun; - - if (!local_num_rows) { num_cols_offd = 0; } - - col_map_offd = hypre_CTAlloc(HYPRE_BigInt, num_cols_offd, HYPRE_MEMORY_HOST); - - cnt = 1; - diag_i[0] = 0; - offd_i[0] = 0; - for (iz = nz_part[r]; iz < nz_part[r + 1]; iz++) - { - for (iy = ny_part[q]; iy < ny_part[q + 1]; iy++) - { - for (ix = nx_part[p]; ix < nx_part[p + 1]; ix++) - { - diag_i[cnt] = diag_i[cnt - 1]; - offd_i[cnt] = offd_i[cnt - 1]; - diag_i[cnt] += num_fun; - if (iz > nz_part[r]) - { - diag_i[cnt] += num_fun; - } - else - { - if (iz) - { - offd_i[cnt] += num_fun; - } - } - if (iy > ny_part[q]) - { - diag_i[cnt] += num_fun; - } - else - { - if (iy) - { - offd_i[cnt] += num_fun; - } - } - if (ix > nx_part[p]) - { - diag_i[cnt] += num_fun; - } - else - { - if (ix) - { - offd_i[cnt] += num_fun; - } - } - if (ix + 1 < nx_part[p + 1]) - { - diag_i[cnt] += num_fun; - } - else - { - if (ix + 1 < nx) - { - offd_i[cnt] += num_fun; - } - } - if (iy + 1 < ny_part[q + 1]) - { - diag_i[cnt] += num_fun; - } - else - { - if (iy + 1 < ny) - { - offd_i[cnt] += num_fun; - } - } - if (iz + 1 < nz_part[r + 1]) - { - diag_i[cnt] += num_fun; - } - else - { - if (iz + 1 < nz) - { - offd_i[cnt] += num_fun; - } - } - num_coeffs = diag_i[cnt] - diag_i[cnt - 1]; - num_offd_coeffs = offd_i[cnt] - offd_i[cnt - 1]; - cnt++; - for (i = 1; i < num_fun; i++) - { - diag_i[cnt] = diag_i[cnt - 1] + num_coeffs; - offd_i[cnt] = offd_i[cnt - 1] + num_offd_coeffs; - cnt++; - } - } - } - } - - diag_j = hypre_CTAlloc(HYPRE_Int, diag_i[local_num_rows], HYPRE_MEMORY_HOST); - diag_data = hypre_CTAlloc(HYPRE_Real, diag_i[local_num_rows], HYPRE_MEMORY_HOST); - - if (num_procs > 1) - { - offd_j = hypre_CTAlloc(HYPRE_Int, offd_i[local_num_rows], HYPRE_MEMORY_HOST); - big_offd_j = hypre_CTAlloc(HYPRE_BigInt, offd_i[local_num_rows], HYPRE_MEMORY_HOST); - offd_data = hypre_CTAlloc(HYPRE_Real, offd_i[local_num_rows], HYPRE_MEMORY_HOST); - } - - row_index = 0; - for (iz = nz_part[r]; iz < nz_part[r + 1]; iz++) - { - for (iy = ny_part[q]; iy < ny_part[q + 1]; iy++) - { - for (ix = nx_part[p]; ix < nx_part[p + 1]; ix++) - { - cnt = diag_i[row_index];; - o_cnt = offd_i[row_index];; - num_coeffs = diag_i[row_index + 1] - diag_i[row_index]; - num_offd_coeffs = offd_i[row_index + 1] - offd_i[row_index]; - first_j = row_index; - for (i = 0; i < num_fun; i++) - { - for (j = 0; j < num_fun; j++) - { - j_ind = cnt + i * num_coeffs + j; - diag_j[j_ind] = first_j + j; - diag_data[j_ind] = value[0] * mtrx[i * num_fun + j]; - } - } - cnt += num_fun; - if (iz > nz_part[r]) - { - first_j = row_index - nx_local * ny_local * num_fun; - for (i = 0; i < num_fun; i++) - { - for (j = 0; j < num_fun; j++) - { - j_ind = cnt + i * num_coeffs + j; - diag_j[j_ind] = first_j + j; - diag_data[j_ind] = value[3] * mtrx[i * num_fun + j]; - } - } - cnt += num_fun; - } - else - { - if (iz) - { - big_first_j = big_num_fun * hypre_map(ix, iy, iz - 1, p, q, r - 1, nx, ny, - nx_part, ny_part, nz_part); - for (i = 0; i < num_fun; i++) - { - for (j = 0; j < num_fun; j++) - { - j_ind = o_cnt + i * num_offd_coeffs + j; - big_offd_j[j_ind] = big_first_j + (HYPRE_BigInt)j; - offd_data[j_ind] = value[3] * mtrx[i * num_fun + j]; - } - } - o_cnt += num_fun; - } - } - if (iy > ny_part[q]) - { - first_j = row_index - nx_local * num_fun; - for (i = 0; i < num_fun; i++) - { - for (j = 0; j < num_fun; j++) - { - j_ind = cnt + i * num_coeffs + j; - diag_j[j_ind] = first_j + j; - diag_data[j_ind] = value[2] * mtrx[i * num_fun + j]; - } - } - cnt += num_fun; - } - else - { - if (iy) - { - big_first_j = big_num_fun * hypre_map(ix, iy - 1, iz, p, q - 1, r, nx, ny, - nx_part, ny_part, nz_part); - for (i = 0; i < num_fun; i++) - { - for (j = 0; j < num_fun; j++) - { - j_ind = o_cnt + i * num_offd_coeffs + j; - big_offd_j[j_ind] = big_first_j + (HYPRE_BigInt)j; - offd_data[j_ind] = value[2] * mtrx[i * num_fun + j]; - } - } - o_cnt += num_fun; - } - } - if (ix > nx_part[p]) - { - first_j = row_index - num_fun; - for (i = 0; i < num_fun; i++) - { - for (j = 0; j < num_fun; j++) - { - j_ind = cnt + i * num_coeffs + j; - diag_j[j_ind] = first_j + j; - diag_data[j_ind] = value[1] * mtrx[i * num_fun + j]; - } - } - cnt += num_fun; - } - else - { - if (ix) - { - big_first_j = big_num_fun * hypre_map(ix - 1, iy, iz, p - 1, q, r, nx, ny, - nx_part, ny_part, nz_part); - for (i = 0; i < num_fun; i++) - { - for (j = 0; j < num_fun; j++) - { - j_ind = o_cnt + i * num_offd_coeffs + j; - big_offd_j[j_ind] = big_first_j + (HYPRE_BigInt)j; - offd_data[j_ind] = value[1] * mtrx[i * num_fun + j]; - } - } - o_cnt += num_fun; - } - } - if (ix + 1 < nx_part[p + 1]) - { - first_j = row_index + num_fun; - for (i = 0; i < num_fun; i++) - { - for (j = 0; j < num_fun; j++) - { - j_ind = cnt + i * num_coeffs + j; - diag_j[j_ind] = first_j + j; - diag_data[j_ind] = value[1] * mtrx[i * num_fun + j]; - } - } - cnt += num_fun; - } - else - { - if (ix + 1 < nx) - { - big_first_j = big_num_fun * hypre_map(ix + 1, iy, iz, p + 1, q, r, nx, ny, - nx_part, ny_part, nz_part); - for (i = 0; i < num_fun; i++) - { - for (j = 0; j < num_fun; j++) - { - j_ind = o_cnt + i * num_offd_coeffs + j; - big_offd_j[j_ind] = big_first_j + (HYPRE_BigInt)j; - offd_data[j_ind] = value[1] * mtrx[i * num_fun + j]; - } - } - o_cnt += num_fun; - } - } - if (iy + 1 < ny_part[q + 1]) - { - first_j = row_index + nx_local * num_fun; - for (i = 0; i < num_fun; i++) - { - for (j = 0; j < num_fun; j++) - { - j_ind = cnt + i * num_coeffs + j; - diag_j[j_ind] = first_j + j; - diag_data[j_ind] = value[2] * mtrx[i * num_fun + j]; - } - } - cnt += num_fun; - } - else - { - if (iy + 1 < ny) - { - big_first_j = big_num_fun * hypre_map(ix, iy + 1, iz, p, q + 1, r, nx, ny, - nx_part, ny_part, nz_part); - for (i = 0; i < num_fun; i++) - { - for (j = 0; j < num_fun; j++) - { - j_ind = o_cnt + i * num_offd_coeffs + j; - big_offd_j[j_ind] = big_first_j + (HYPRE_BigInt)j; - offd_data[j_ind] = value[2] * mtrx[i * num_fun + j]; - } - } - o_cnt += num_fun; - } - } - if (iz + 1 < nz_part[r + 1]) - { - first_j = row_index + nx_local * ny_local * num_fun; - for (i = 0; i < num_fun; i++) - { - for (j = 0; j < num_fun; j++) - { - j_ind = cnt + i * num_coeffs + j; - diag_j[j_ind] = first_j + j; - diag_data[j_ind] = value[3] * mtrx[i * num_fun + j]; - } - } - cnt += num_fun; - } - else - { - if (iz + 1 < nz) - { - big_first_j = big_num_fun * hypre_map(ix, iy, iz + 1, p, q, r + 1, nx, ny, - nx_part, ny_part, nz_part); - for (i = 0; i < num_fun; i++) - { - for (j = 0; j < num_fun; j++) - { - j_ind = o_cnt + i * num_offd_coeffs + j; - big_offd_j[j_ind] = big_first_j + (HYPRE_BigInt)j; - offd_data[j_ind] = value[3] * mtrx[i * num_fun + j]; - } - } - o_cnt += num_fun; - } - } - row_index += num_fun; - } - } - } - - if (num_procs > 1) - { - cnt = 0; - for (i = 0; i < local_num_rows; i += num_fun) - { - for (j = offd_i[i]; j < offd_i[i + 1]; j++) - { - col_map_offd[cnt++] = big_offd_j[j]; - } - } - - hypre_BigQsort0(col_map_offd, 0, num_cols_offd - 1); - - for (i = 0; i < num_fun * num_cols_offd; i++) - for (j = hypre_min(0, hypre_abs(i - num_fun)); j < num_cols_offd; j++) - if (big_offd_j[i] == col_map_offd[j]) - { - offd_j[i] = j; - break; - } - } - - for (i = 0; i < gp_size; i++) - { - global_part[i] *= big_num_fun; - } - - for (j = 1; j < num_fun; j++) - { - for (i = 0; i < local_grid_size; i++) - { - row = i * num_fun + j; - diag_index = diag_i[row]; - index = diag_index + j; - val = diag_data[diag_index]; - col = diag_j[diag_index]; - diag_data[diag_index] = diag_data[index]; - diag_j[diag_index] = diag_j[index]; - diag_data[index] = val; - diag_j[index] = col; - } - } - - A = hypre_ParCSRMatrixCreate(comm, big_num_fun * grid_size, big_num_fun * grid_size, - global_part, global_part, num_cols_offd, - diag_i[local_num_rows], - offd_i[local_num_rows]); - - hypre_ParCSRMatrixColMapOffd(A) = col_map_offd; - - diag = hypre_ParCSRMatrixDiag(A); - hypre_CSRMatrixI(diag) = diag_i; - hypre_CSRMatrixJ(diag) = diag_j; - hypre_CSRMatrixData(diag) = diag_data; - - offd = hypre_ParCSRMatrixOffd(A); - hypre_CSRMatrixI(offd) = offd_i; - if (num_cols_offd) - { - hypre_CSRMatrixJ(offd) = offd_j; - hypre_CSRMatrixData(offd) = offd_data; - } - - hypre_CSRMatrixMemoryLocation(diag) = HYPRE_MEMORY_HOST; - hypre_CSRMatrixMemoryLocation(offd) = HYPRE_MEMORY_HOST; - - hypre_ParCSRMatrixMigrate(A, hypre_HandleMemoryLocation(hypre_handle())); - - hypre_TFree(nx_part, HYPRE_MEMORY_HOST); - hypre_TFree(ny_part, HYPRE_MEMORY_HOST); - hypre_TFree(nz_part, HYPRE_MEMORY_HOST); - hypre_TFree(big_offd_j, HYPRE_MEMORY_HOST); - - return (HYPRE_ParCSRMatrix) A; -} - -/*-------------------------------------------------------------------------- - * hypre_GenerateVectorLaplacian - this is also a systems version and we can - * vary the diffusion coefficients in each block - *--------------------------------------------------------------------------*/ - -HYPRE_ParCSRMatrix -GenerateSysLaplacianVCoef( MPI_Comm comm, - HYPRE_BigInt nx, - HYPRE_BigInt ny, - HYPRE_BigInt nz, - HYPRE_Int P, - HYPRE_Int Q, - HYPRE_Int R, - HYPRE_Int p, - HYPRE_Int q, - HYPRE_Int r, - HYPRE_Int num_fun, - HYPRE_Real *mtrx, - HYPRE_Real *value ) -{ - hypre_ParCSRMatrix *A; - hypre_CSRMatrix *diag; - hypre_CSRMatrix *offd; - - HYPRE_Int *diag_i; - HYPRE_Int *diag_j; - HYPRE_Real *diag_data; - - HYPRE_Int *offd_i; - HYPRE_Int *offd_j = NULL; - HYPRE_BigInt *big_offd_j = NULL; - HYPRE_Real *offd_data = NULL; - - HYPRE_BigInt global_part[2]; - HYPRE_BigInt ix, iy, iz; - HYPRE_Int cnt, o_cnt; - HYPRE_Int local_num_rows; - HYPRE_BigInt *col_map_offd; - HYPRE_Int row_index, row, col; - HYPRE_Int index, diag_index; - HYPRE_Int i, j; - HYPRE_Int gp_size; - - HYPRE_Int nx_local, ny_local, nz_local; - HYPRE_Int num_cols_offd; - HYPRE_BigInt grid_size; - HYPRE_Int local_grid_size; - HYPRE_Int first_j, j_ind; - HYPRE_BigInt big_first_j, big_num_fun = (HYPRE_BigInt) num_fun; - HYPRE_Int num_coeffs, num_offd_coeffs; - - HYPRE_BigInt *nx_part; - HYPRE_BigInt *ny_part; - HYPRE_BigInt *nz_part; - - HYPRE_Int num_procs, P_busy, Q_busy, R_busy; - HYPRE_Real val; - - /* for indexing in values */ - HYPRE_Int sz = num_fun * num_fun; - - hypre_MPI_Comm_size(comm, &num_procs); - - grid_size = nx * ny * nz; - - hypre_GeneratePartitioning(nx, P, &nx_part); - hypre_GeneratePartitioning(ny, Q, &ny_part); - hypre_GeneratePartitioning(nz, R, &nz_part); - - nx_local = (HYPRE_Int)(nx_part[p + 1] - nx_part[p]); - ny_local = (HYPRE_Int)(ny_part[q + 1] - ny_part[q]); - nz_local = (HYPRE_Int)(nz_part[r + 1] - nz_part[r]); - - local_grid_size = nx_local * ny_local * nz_local; - global_part[0] = nz_part[r] * nx * ny + (ny_part[q] * nx + nx_part[p] * ny_local) * nz_local; - global_part[1] = global_part[0] + (HYPRE_BigInt)local_grid_size; - gp_size = 2; - - local_num_rows = num_fun * local_grid_size; - diag_i = hypre_CTAlloc(HYPRE_Int, local_num_rows + 1, HYPRE_MEMORY_HOST); - offd_i = hypre_CTAlloc(HYPRE_Int, local_num_rows + 1, HYPRE_MEMORY_HOST); - - P_busy = hypre_min(nx, P); - Q_busy = hypre_min(ny, Q); - R_busy = hypre_min(nz, R); - - num_cols_offd = 0; - if (p) { num_cols_offd += ny_local * nz_local; } - if (p < P_busy - 1) { num_cols_offd += ny_local * nz_local; } - if (q) { num_cols_offd += nx_local * nz_local; } - if (q < Q_busy - 1) { num_cols_offd += nx_local * nz_local; } - if (r) { num_cols_offd += nx_local * ny_local; } - if (r < R_busy - 1) { num_cols_offd += nx_local * ny_local; } - num_cols_offd *= num_fun; - - if (!local_num_rows) { num_cols_offd = 0; } - - col_map_offd = hypre_CTAlloc(HYPRE_BigInt, num_cols_offd, HYPRE_MEMORY_HOST); - - cnt = 1; - diag_i[0] = 0; - offd_i[0] = 0; - for (iz = nz_part[r]; iz < nz_part[r + 1]; iz++) - { - for (iy = ny_part[q]; iy < ny_part[q + 1]; iy++) - { - for (ix = nx_part[p]; ix < nx_part[p + 1]; ix++) - { - diag_i[cnt] = diag_i[cnt - 1]; - offd_i[cnt] = offd_i[cnt - 1]; - diag_i[cnt] += num_fun; - if (iz > nz_part[r]) - { - diag_i[cnt] += num_fun; - } - else - { - if (iz) - { - offd_i[cnt] += num_fun; - } - } - if (iy > ny_part[q]) - { - diag_i[cnt] += num_fun; - } - else - { - if (iy) - { - offd_i[cnt] += num_fun; - } - } - if (ix > nx_part[p]) - { - diag_i[cnt] += num_fun; - } - else - { - if (ix) - { - offd_i[cnt] += num_fun; - } - } - if (ix + 1 < nx_part[p + 1]) - { - diag_i[cnt] += num_fun; - } - else - { - if (ix + 1 < nx) - { - offd_i[cnt] += num_fun; - } - } - if (iy + 1 < ny_part[q + 1]) - { - diag_i[cnt] += num_fun; - } - else - { - if (iy + 1 < ny) - { - offd_i[cnt] += num_fun; - } - } - if (iz + 1 < nz_part[r + 1]) - { - diag_i[cnt] += num_fun; - } - else - { - if (iz + 1 < nz) - { - offd_i[cnt] += num_fun; - } - } - num_coeffs = diag_i[cnt] - diag_i[cnt - 1]; - num_offd_coeffs = offd_i[cnt] - offd_i[cnt - 1]; - cnt++; - for (i = 1; i < num_fun; i++) - { - diag_i[cnt] = diag_i[cnt - 1] + num_coeffs; - offd_i[cnt] = offd_i[cnt - 1] + num_offd_coeffs; - cnt++; - } - } - } - } - - diag_j = hypre_CTAlloc(HYPRE_Int, diag_i[local_num_rows], HYPRE_MEMORY_HOST); - diag_data = hypre_CTAlloc(HYPRE_Real, diag_i[local_num_rows], HYPRE_MEMORY_HOST); - - if (num_procs > 1) - { - offd_j = hypre_CTAlloc(HYPRE_Int, offd_i[local_num_rows], HYPRE_MEMORY_HOST); - big_offd_j = hypre_CTAlloc(HYPRE_BigInt, offd_i[local_num_rows], HYPRE_MEMORY_HOST); - offd_data = hypre_CTAlloc(HYPRE_Real, offd_i[local_num_rows], HYPRE_MEMORY_HOST); - } - - row_index = 0; - for (iz = nz_part[r]; iz < nz_part[r + 1]; iz++) - { - for (iy = ny_part[q]; iy < ny_part[q + 1]; iy++) - { - for (ix = nx_part[p]; ix < nx_part[p + 1]; ix++) - { - cnt = diag_i[row_index];; - o_cnt = offd_i[row_index];; - num_coeffs = diag_i[row_index + 1] - diag_i[row_index]; - num_offd_coeffs = offd_i[row_index + 1] - offd_i[row_index]; - first_j = row_index; - for (i = 0; i < num_fun; i++) - { - for (j = 0; j < num_fun; j++) - { - j_ind = cnt + i * num_coeffs + j; - diag_j[j_ind] = first_j + j; - diag_data[j_ind] = value[0 * sz + i * num_fun + j] * mtrx[i * num_fun + j]; - } - } - cnt += num_fun; - if (iz > nz_part[r]) - { - first_j = row_index - nx_local * ny_local * num_fun; - for (i = 0; i < num_fun; i++) - { - for (j = 0; j < num_fun; j++) - { - j_ind = cnt + i * num_coeffs + j; - diag_j[j_ind] = first_j + j; - diag_data[j_ind] = value[3 * sz + i * num_fun + j] * mtrx[i * num_fun + j]; - } - } - cnt += num_fun; - } - else - { - if (iz) - { - big_first_j = big_num_fun * hypre_map(ix, iy, iz - 1, p, q, r - 1, nx, ny, - nx_part, ny_part, nz_part); - for (i = 0; i < num_fun; i++) - { - for (j = 0; j < num_fun; j++) - { - j_ind = o_cnt + i * num_offd_coeffs + j; - big_offd_j[j_ind] = big_first_j + (HYPRE_BigInt)j; - offd_data[j_ind] = value[3 * sz + i * num_fun + j] * mtrx[i * num_fun + j]; - } - } - o_cnt += num_fun; - } - } - if (iy > ny_part[q]) - { - first_j = row_index - nx_local * num_fun; - for (i = 0; i < num_fun; i++) - { - for (j = 0; j < num_fun; j++) - { - j_ind = cnt + i * num_coeffs + j; - diag_j[j_ind] = first_j + j; - diag_data[j_ind] = value[2 * sz + i * num_fun + j] * mtrx[i * num_fun + j]; - } - } - cnt += num_fun; - } - else - { - if (iy) - { - big_first_j = big_num_fun * hypre_map(ix, iy - 1, iz, p, q - 1, r, nx, ny, - nx_part, ny_part, nz_part); - for (i = 0; i < num_fun; i++) - { - for (j = 0; j < num_fun; j++) - { - j_ind = o_cnt + i * num_offd_coeffs + j; - big_offd_j[j_ind] = big_first_j + (HYPRE_BigInt)j; - offd_data[j_ind] = value[2 * sz + i * num_fun + j] * mtrx[i * num_fun + j]; - } - } - o_cnt += num_fun; - } - } - if (ix > nx_part[p]) - { - first_j = row_index - num_fun; - for (i = 0; i < num_fun; i++) - { - for (j = 0; j < num_fun; j++) - { - j_ind = cnt + i * num_coeffs + j; - diag_j[j_ind] = first_j + j; - diag_data[j_ind] = value[1 * sz + i * num_fun + j] * mtrx[i * num_fun + j]; - } - } - cnt += num_fun; - } - else - { - if (ix) - { - big_first_j = big_num_fun * hypre_map(ix - 1, iy, iz, p - 1, q, r, nx, ny, - nx_part, ny_part, nz_part); - for (i = 0; i < num_fun; i++) - { - for (j = 0; j < num_fun; j++) - { - j_ind = o_cnt + i * num_offd_coeffs + j; - big_offd_j[j_ind] = big_first_j + (HYPRE_BigInt)j; - offd_data[j_ind] = value[1 * sz + i * num_fun + j] * mtrx[i * num_fun + j]; - } - } - o_cnt += num_fun; - } - } - if (ix + 1 < nx_part[p + 1]) - { - first_j = row_index + num_fun; - for (i = 0; i < num_fun; i++) - { - for (j = 0; j < num_fun; j++) - { - j_ind = cnt + i * num_coeffs + j; - diag_j[j_ind] = first_j + j; - diag_data[j_ind] = value[1 * sz + i * num_fun + j] * mtrx[i * num_fun + j]; - } - } - cnt += num_fun; - } - else - { - if (ix + 1 < nx) - { - big_first_j = big_num_fun * hypre_map(ix + 1, iy, iz, p + 1, q, r, nx, ny, - nx_part, ny_part, nz_part); - for (i = 0; i < num_fun; i++) - { - for (j = 0; j < num_fun; j++) - { - j_ind = o_cnt + i * num_offd_coeffs + j; - big_offd_j[j_ind] = big_first_j + (HYPRE_BigInt)j; - offd_data[j_ind] = value[1 * sz + i * num_fun + j] * mtrx[i * num_fun + j]; - } - } - o_cnt += num_fun; - } - } - if (iy + 1 < ny_part[q + 1]) - { - first_j = row_index + nx_local * num_fun; - for (i = 0; i < num_fun; i++) - { - for (j = 0; j < num_fun; j++) - { - j_ind = cnt + i * num_coeffs + j; - diag_j[j_ind] = first_j + j; - diag_data[j_ind] = value[2 * sz + i * num_fun + j] * mtrx[i * num_fun + j]; - } - } - cnt += num_fun; - } - else - { - if (iy + 1 < ny) - { - big_first_j = big_num_fun * hypre_map(ix, iy + 1, iz, p, q + 1, r, nx, ny, - nx_part, ny_part, nz_part); - for (i = 0; i < num_fun; i++) - { - for (j = 0; j < num_fun; j++) - { - j_ind = o_cnt + i * num_offd_coeffs + j; - big_offd_j[j_ind] = big_first_j + (HYPRE_BigInt)j; - offd_data[j_ind] = value[2 * sz + i * num_fun + j] * mtrx[i * num_fun + j]; - } - } - o_cnt += num_fun; - } - } - if (iz + 1 < nz_part[r + 1]) - { - first_j = row_index + nx_local * ny_local * num_fun; - for (i = 0; i < num_fun; i++) - { - for (j = 0; j < num_fun; j++) - { - j_ind = cnt + i * num_coeffs + j; - diag_j[j_ind] = first_j + j; - diag_data[j_ind] = value[3 * sz + i * num_fun + j] * mtrx[i * num_fun + j]; - } - } - cnt += num_fun; - } - else - { - if (iz + 1 < nz) - { - big_first_j = big_num_fun * hypre_map(ix, iy, iz + 1, p, q, r + 1, nx, ny, - nx_part, ny_part, nz_part); - for (i = 0; i < num_fun; i++) - { - for (j = 0; j < num_fun; j++) - { - j_ind = o_cnt + i * num_offd_coeffs + j; - big_offd_j[j_ind] = big_first_j + (HYPRE_BigInt)j; - offd_data[j_ind] = value[3 * sz + i * num_fun + j] * mtrx[i * num_fun + j]; - } - } - o_cnt += num_fun; - } - } - row_index += num_fun; - } - } - } - - if (num_procs > 1) - { - cnt = 0; - for (i = 0; i < local_num_rows; i += num_fun) - { - for (j = offd_i[i]; j < offd_i[i + 1]; j++) - { - col_map_offd[cnt++] = big_offd_j[j]; - } - } - - hypre_BigQsort0(col_map_offd, 0, num_cols_offd - 1); - - for (i = 0; i < num_fun * num_cols_offd; i++) - for (j = hypre_min(0, hypre_abs(i - num_fun)); j < num_cols_offd; j++) - if (big_offd_j[i] == col_map_offd[j]) - { - offd_j[i] = j; - break; - } - } - - for (i = 0; i < gp_size; i++) - { - global_part[i] *= num_fun; - } - - for (j = 1; j < num_fun; j++) - { - for (i = 0; i < local_grid_size; i++) - { - row = i * num_fun + j; - diag_index = diag_i[row]; - index = diag_index + j; - val = diag_data[diag_index]; - col = diag_j[diag_index]; - diag_data[diag_index] = diag_data[index]; - diag_j[diag_index] = diag_j[index]; - diag_data[index] = val; - diag_j[index] = col; - } - } - - A = hypre_ParCSRMatrixCreate(comm, num_fun * grid_size, num_fun * grid_size, - global_part, global_part, num_cols_offd, - diag_i[local_num_rows], - offd_i[local_num_rows]); - - hypre_ParCSRMatrixColMapOffd(A) = col_map_offd; - - diag = hypre_ParCSRMatrixDiag(A); - hypre_CSRMatrixI(diag) = diag_i; - hypre_CSRMatrixJ(diag) = diag_j; - hypre_CSRMatrixData(diag) = diag_data; - - offd = hypre_ParCSRMatrixOffd(A); - hypre_CSRMatrixI(offd) = offd_i; - if (num_cols_offd) - { - hypre_CSRMatrixJ(offd) = offd_j; - hypre_CSRMatrixData(offd) = offd_data; - } - - hypre_CSRMatrixMemoryLocation(diag) = HYPRE_MEMORY_HOST; - hypre_CSRMatrixMemoryLocation(offd) = HYPRE_MEMORY_HOST; - - hypre_ParCSRMatrixMigrate(A, hypre_HandleMemoryLocation(hypre_handle())); - - hypre_TFree(nx_part, HYPRE_MEMORY_HOST); - hypre_TFree(ny_part, HYPRE_MEMORY_HOST); - hypre_TFree(nz_part, HYPRE_MEMORY_HOST); - hypre_TFree(big_offd_j, HYPRE_MEMORY_HOST); - - return (HYPRE_ParCSRMatrix) A; -} diff --git a/src/parcsr_ls/par_laplace_27pt.c b/src/parcsr_ls/par_laplace_27pt.c deleted file mode 100644 index 43209d5031..0000000000 --- a/src/parcsr_ls/par_laplace_27pt.c +++ /dev/null @@ -1,1690 +0,0 @@ -/****************************************************************************** - * Copyright (c) 1998 Lawrence Livermore National Security, LLC and other - * HYPRE Project Developers. See the top-level COPYRIGHT file for details. - * - * SPDX-License-Identifier: (Apache-2.0 OR MIT) - ******************************************************************************/ - -#include "_hypre_parcsr_ls.h" - -/*-------------------------------------------------------------------------- - * hypre_GenerateLaplacian27pt - *--------------------------------------------------------------------------*/ - -HYPRE_ParCSRMatrix -GenerateLaplacian27pt(MPI_Comm comm, - HYPRE_BigInt nx, - HYPRE_BigInt ny, - HYPRE_BigInt nz, - HYPRE_Int P, - HYPRE_Int Q, - HYPRE_Int R, - HYPRE_Int p, - HYPRE_Int q, - HYPRE_Int r, - HYPRE_Real *value ) -{ - hypre_ParCSRMatrix *A; - hypre_CSRMatrix *diag; - hypre_CSRMatrix *offd; - - HYPRE_Int *diag_i; - HYPRE_Int *diag_j; - HYPRE_Real *diag_data; - - HYPRE_Int *offd_i; - HYPRE_Int *offd_j = NULL; - HYPRE_BigInt *big_offd_j = NULL; - HYPRE_Real *offd_data = NULL; - - HYPRE_BigInt global_part[2]; - HYPRE_BigInt ix, iy, iz; - HYPRE_Int cnt, o_cnt; - HYPRE_Int local_num_rows; - HYPRE_BigInt *col_map_offd; - HYPRE_BigInt *work; - HYPRE_Int row_index; - HYPRE_Int i; - - HYPRE_Int nx_local, ny_local, nz_local; - HYPRE_Int num_cols_offd; - HYPRE_Int nxy; - HYPRE_BigInt grid_size; - - HYPRE_BigInt *nx_part; - HYPRE_BigInt *ny_part; - HYPRE_BigInt *nz_part; - - HYPRE_Int num_procs; - HYPRE_Int P_busy, Q_busy, R_busy; - - hypre_MPI_Comm_size(comm, &num_procs); - - grid_size = nx * ny * nz; - - hypre_GeneratePartitioning(nx, P, &nx_part); - hypre_GeneratePartitioning(ny, Q, &ny_part); - hypre_GeneratePartitioning(nz, R, &nz_part); - - nx_local = (HYPRE_Int)(nx_part[p + 1] - nx_part[p]); - ny_local = (HYPRE_Int)(ny_part[q + 1] - ny_part[q]); - nz_local = (HYPRE_Int)(nz_part[r + 1] - nz_part[r]); - - local_num_rows = nx_local * ny_local * nz_local; - - global_part[0] = nz_part[r] * nx * ny + (ny_part[q] * nx + nx_part[p] * ny_local) * nz_local; - global_part[1] = global_part[0] + (HYPRE_BigInt)local_num_rows; - - diag_i = hypre_CTAlloc(HYPRE_Int, local_num_rows + 1, HYPRE_MEMORY_HOST); - offd_i = hypre_CTAlloc(HYPRE_Int, local_num_rows + 1, HYPRE_MEMORY_HOST); - - P_busy = hypre_min(nx, P); - Q_busy = hypre_min(ny, Q); - R_busy = hypre_min(nz, R); - - num_cols_offd = 0; - if (p) { num_cols_offd += ny_local * nz_local; } - if (p < P_busy - 1) { num_cols_offd += ny_local * nz_local; } - if (q) { num_cols_offd += nx_local * nz_local; } - if (q < Q_busy - 1) { num_cols_offd += nx_local * nz_local; } - if (r) { num_cols_offd += nx_local * ny_local; } - if (r < R_busy - 1) { num_cols_offd += nx_local * ny_local; } - if (p && q) { num_cols_offd += nz_local; } - if (p && q < Q_busy - 1 ) { num_cols_offd += nz_local; } - if (p < P_busy - 1 && q ) { num_cols_offd += nz_local; } - if (p < P_busy - 1 && q < Q_busy - 1 ) { num_cols_offd += nz_local; } - if (p && r) { num_cols_offd += ny_local; } - if (p && r < R_busy - 1 ) { num_cols_offd += ny_local; } - if (p < P_busy - 1 && r ) { num_cols_offd += ny_local; } - if (p < P_busy - 1 && r < R_busy - 1 ) { num_cols_offd += ny_local; } - if (q && r) { num_cols_offd += nx_local; } - if (q && r < R_busy - 1 ) { num_cols_offd += nx_local; } - if (q < Q_busy - 1 && r ) { num_cols_offd += nx_local; } - if (q < Q_busy - 1 && r < R_busy - 1 ) { num_cols_offd += nx_local; } - if (p && q && r) { num_cols_offd++; } - if (p && q && r < R_busy - 1) { num_cols_offd++; } - if (p && q < Q_busy - 1 && r) { num_cols_offd++; } - if (p && q < Q_busy - 1 && r < R_busy - 1) { num_cols_offd++; } - if (p < P_busy - 1 && q && r) { num_cols_offd++; } - if (p < P_busy - 1 && q && r < R_busy - 1 ) { num_cols_offd++; } - if (p < P_busy - 1 && q < Q_busy - 1 && r ) { num_cols_offd++; } - if (p < P_busy - 1 && q < Q_busy - 1 && r < R_busy - 1) { num_cols_offd++; } - - if (!local_num_rows) { num_cols_offd = 0; } - - col_map_offd = hypre_CTAlloc(HYPRE_BigInt, num_cols_offd, HYPRE_MEMORY_HOST); - - cnt = 0; - o_cnt = 0; - diag_i[0] = 0; - offd_i[0] = 0; - for (iz = nz_part[r]; iz < nz_part[r + 1]; iz++) - { - for (iy = ny_part[q]; iy < ny_part[q + 1]; iy++) - { - for (ix = nx_part[p]; ix < nx_part[p + 1]; ix++) - { - cnt++; - o_cnt++; - diag_i[cnt] = diag_i[cnt - 1]; - offd_i[o_cnt] = offd_i[o_cnt - 1]; - diag_i[cnt]++; - if (iz > nz_part[r]) - { - diag_i[cnt]++; - if (iy > ny_part[q]) - { - diag_i[cnt]++; - if (ix > nx_part[p]) - { - diag_i[cnt]++; - } - else - { - if (ix) - { - offd_i[o_cnt]++; - } - } - if (ix < nx_part[p + 1] - 1) - { - diag_i[cnt]++; - } - else - { - if (ix + 1 < nx) - { - offd_i[o_cnt]++; - } - } - } - else - { - if (iy) - { - offd_i[o_cnt]++; - if (ix > nx_part[p]) - { - offd_i[o_cnt]++; - } - else if (ix) - { - offd_i[o_cnt]++; - } - if (ix < nx_part[p + 1] - 1) - { - offd_i[o_cnt]++; - } - else if (ix < nx - 1) - { - offd_i[o_cnt]++; - } - } - } - if (ix > nx_part[p]) - { - diag_i[cnt]++; - } - else - { - if (ix) - { - offd_i[o_cnt]++; - } - } - if (ix + 1 < nx_part[p + 1]) - { - diag_i[cnt]++; - } - else - { - if (ix + 1 < nx) - { - offd_i[o_cnt]++; - } - } - if (iy + 1 < ny_part[q + 1]) - { - diag_i[cnt]++; - if (ix > nx_part[p]) - { - diag_i[cnt]++; - } - else - { - if (ix) - { - offd_i[o_cnt]++; - } - } - if (ix < nx_part[p + 1] - 1) - { - diag_i[cnt]++; - } - else - { - if (ix + 1 < nx) - { - offd_i[o_cnt]++; - } - } - } - else - { - if (iy + 1 < ny) - { - offd_i[o_cnt]++; - if (ix > nx_part[p]) - { - offd_i[o_cnt]++; - } - else if (ix) - { - offd_i[o_cnt]++; - } - if (ix < nx_part[p + 1] - 1) - { - offd_i[o_cnt]++; - } - else if (ix < nx - 1) - { - offd_i[o_cnt]++; - } - } - } - } - else - { - if (iz) - { - offd_i[o_cnt]++; - if (iy > ny_part[q]) - { - offd_i[o_cnt]++; - if (ix > nx_part[p]) - { - offd_i[o_cnt]++; - } - else - { - if (ix) - { - offd_i[o_cnt]++; - } - } - if (ix < nx_part[p + 1] - 1) - { - offd_i[o_cnt]++; - } - else - { - if (ix + 1 < nx) - { - offd_i[o_cnt]++; - } - } - } - else - { - if (iy) - { - offd_i[o_cnt]++; - if (ix > nx_part[p]) - { - offd_i[o_cnt]++; - } - else if (ix) - { - offd_i[o_cnt]++; - } - if (ix < nx_part[p + 1] - 1) - { - offd_i[o_cnt]++; - } - else if (ix < nx - 1) - { - offd_i[o_cnt]++; - } - } - } - if (ix > nx_part[p]) - { - offd_i[o_cnt]++; - } - else - { - if (ix) - { - offd_i[o_cnt]++; - } - } - if (ix + 1 < nx_part[p + 1]) - { - offd_i[o_cnt]++; - } - else - { - if (ix + 1 < nx) - { - offd_i[o_cnt]++; - } - } - if (iy + 1 < ny_part[q + 1]) - { - offd_i[o_cnt]++; - if (ix > nx_part[p]) - { - offd_i[o_cnt]++; - } - else - { - if (ix) - { - offd_i[o_cnt]++; - } - } - if (ix < nx_part[p + 1] - 1) - { - offd_i[o_cnt]++; - } - else - { - if (ix + 1 < nx) - { - offd_i[o_cnt]++; - } - } - } - else - { - if (iy + 1 < ny) - { - offd_i[o_cnt]++; - if (ix > nx_part[p]) - { - offd_i[o_cnt]++; - } - else if (ix) - { - offd_i[o_cnt]++; - } - if (ix < nx_part[p + 1] - 1) - { - offd_i[o_cnt]++; - } - else if (ix < nx - 1) - { - offd_i[o_cnt]++; - } - } - } - } - } - if (iy > ny_part[q]) - { - diag_i[cnt]++; - if (ix > nx_part[p]) - { - diag_i[cnt]++; - } - else - { - if (ix) - { - offd_i[o_cnt]++; - } - } - if (ix < nx_part[p + 1] - 1) - { - diag_i[cnt]++; - } - else - { - if (ix + 1 < nx) - { - offd_i[o_cnt]++; - } - } - } - else - { - if (iy) - { - offd_i[o_cnt]++; - if (ix > nx_part[p]) - { - offd_i[o_cnt]++; - } - else if (ix) - { - offd_i[o_cnt]++; - } - if (ix < nx_part[p + 1] - 1) - { - offd_i[o_cnt]++; - } - else if (ix < nx - 1) - { - offd_i[o_cnt]++; - } - } - } - if (ix > nx_part[p]) - { - diag_i[cnt]++; - } - else - { - if (ix) - { - offd_i[o_cnt]++; - } - } - if (ix + 1 < nx_part[p + 1]) - { - diag_i[cnt]++; - } - else - { - if (ix + 1 < nx) - { - offd_i[o_cnt]++; - } - } - if (iy + 1 < ny_part[q + 1]) - { - diag_i[cnt]++; - if (ix > nx_part[p]) - { - diag_i[cnt]++; - } - else - { - if (ix) - { - offd_i[o_cnt]++; - } - } - if (ix < nx_part[p + 1] - 1) - { - diag_i[cnt]++; - } - else - { - if (ix + 1 < nx) - { - offd_i[o_cnt]++; - } - } - } - else - { - if (iy + 1 < ny) - { - offd_i[o_cnt]++; - if (ix > nx_part[p]) - { - offd_i[o_cnt]++; - } - else if (ix) - { - offd_i[o_cnt]++; - } - if (ix < nx_part[p + 1] - 1) - { - offd_i[o_cnt]++; - } - else if (ix < nx - 1) - { - offd_i[o_cnt]++; - } - } - } - if (iz + 1 < nz_part[r + 1]) - { - diag_i[cnt]++; - if (iy > ny_part[q]) - { - diag_i[cnt]++; - if (ix > nx_part[p]) - { - diag_i[cnt]++; - } - else - { - if (ix) - { - offd_i[o_cnt]++; - } - } - if (ix < nx_part[p + 1] - 1) - { - diag_i[cnt]++; - } - else - { - if (ix + 1 < nx) - { - offd_i[o_cnt]++; - } - } - } - else - { - if (iy) - { - offd_i[o_cnt]++; - if (ix > nx_part[p]) - { - offd_i[o_cnt]++; - } - else if (ix) - { - offd_i[o_cnt]++; - } - if (ix < nx_part[p + 1] - 1) - { - offd_i[o_cnt]++; - } - else if (ix < nx - 1) - { - offd_i[o_cnt]++; - } - } - } - if (ix > nx_part[p]) - { - diag_i[cnt]++; - } - else - { - if (ix) - { - offd_i[o_cnt]++; - } - } - if (ix + 1 < nx_part[p + 1]) - { - diag_i[cnt]++; - } - else - { - if (ix + 1 < nx) - { - offd_i[o_cnt]++; - } - } - if (iy + 1 < ny_part[q + 1]) - { - diag_i[cnt]++; - if (ix > nx_part[p]) - { - diag_i[cnt]++; - } - else - { - if (ix) - { - offd_i[o_cnt]++; - } - } - if (ix < nx_part[p + 1] - 1) - { - diag_i[cnt]++; - } - else - { - if (ix + 1 < nx) - { - offd_i[o_cnt]++; - } - } - } - else - { - if (iy + 1 < ny) - { - offd_i[o_cnt]++; - if (ix > nx_part[p]) - { - offd_i[o_cnt]++; - } - else if (ix) - { - offd_i[o_cnt]++; - } - if (ix < nx_part[p + 1] - 1) - { - offd_i[o_cnt]++; - } - else if (ix < nx - 1) - { - offd_i[o_cnt]++; - } - } - } - } - else - { - if (iz + 1 < nz) - { - offd_i[o_cnt]++; - if (iy > ny_part[q]) - { - offd_i[o_cnt]++; - if (ix > nx_part[p]) - { - offd_i[o_cnt]++; - } - else - { - if (ix) - { - offd_i[o_cnt]++; - } - } - if (ix < nx_part[p + 1] - 1) - { - offd_i[o_cnt]++; - } - else - { - if (ix + 1 < nx) - { - offd_i[o_cnt]++; - } - } - } - else - { - if (iy) - { - offd_i[o_cnt]++; - if (ix > nx_part[p]) - { - offd_i[o_cnt]++; - } - else if (ix) - { - offd_i[o_cnt]++; - } - if (ix < nx_part[p + 1] - 1) - { - offd_i[o_cnt]++; - } - else if (ix < nx - 1) - { - offd_i[o_cnt]++; - } - } - } - if (ix > nx_part[p]) - { - offd_i[o_cnt]++; - } - else - { - if (ix) - { - offd_i[o_cnt]++; - } - } - if (ix + 1 < nx_part[p + 1]) - { - offd_i[o_cnt]++; - } - else - { - if (ix + 1 < nx) - { - offd_i[o_cnt]++; - } - } - if (iy + 1 < ny_part[q + 1]) - { - offd_i[o_cnt]++; - if (ix > nx_part[p]) - { - offd_i[o_cnt]++; - } - else - { - if (ix) - { - offd_i[o_cnt]++; - } - } - if (ix < nx_part[p + 1] - 1) - { - offd_i[o_cnt]++; - } - else - { - if (ix + 1 < nx) - { - offd_i[o_cnt]++; - } - } - } - else - { - if (iy + 1 < ny) - { - offd_i[o_cnt]++; - if (ix > nx_part[p]) - { - offd_i[o_cnt]++; - } - else if (ix) - { - offd_i[o_cnt]++; - } - if (ix < nx_part[p + 1] - 1) - { - offd_i[o_cnt]++; - } - else if (ix < nx - 1) - { - offd_i[o_cnt]++; - } - } - } - } - } - } - } - } - - diag_j = hypre_CTAlloc(HYPRE_Int, diag_i[local_num_rows], HYPRE_MEMORY_HOST); - diag_data = hypre_CTAlloc(HYPRE_Real, diag_i[local_num_rows], HYPRE_MEMORY_HOST); - - if (num_procs > 1) - { - big_offd_j = hypre_CTAlloc(HYPRE_BigInt, offd_i[local_num_rows], HYPRE_MEMORY_HOST); - offd_j = hypre_CTAlloc(HYPRE_Int, offd_i[local_num_rows], HYPRE_MEMORY_HOST); - offd_data = hypre_CTAlloc(HYPRE_Real, offd_i[local_num_rows], HYPRE_MEMORY_HOST); - } - - nxy = nx_local * ny_local; - row_index = 0; - cnt = 0; - o_cnt = 0; - for (iz = nz_part[r]; iz < nz_part[r + 1]; iz++) - { - for (iy = ny_part[q]; iy < ny_part[q + 1]; iy++) - { - for (ix = nx_part[p]; ix < nx_part[p + 1]; ix++) - { - diag_j[cnt] = row_index; - diag_data[cnt++] = value[0]; - if (iz > nz_part[r]) - { - if (iy > ny_part[q]) - { - if (ix > nx_part[p]) - { - diag_j[cnt] = row_index - nxy - nx_local - 1; - diag_data[cnt++] = value[1]; - } - else - { - if (ix) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy - 1, iz - 1, p - 1, q, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - diag_j[cnt] = row_index - nxy - nx_local; - diag_data[cnt++] = value[1]; - if (ix < nx_part[p + 1] - 1) - { - diag_j[cnt] = row_index - nxy - nx_local + 1; - diag_data[cnt++] = value[1]; - } - else - { - if (ix + 1 < nx) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy - 1, iz - 1, p + 1, q, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - } - else - { - if (iy) - { - if (ix > nx_part[p]) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy - 1, iz - 1, p, q - 1, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else if (ix) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy - 1, iz - 1, p - 1, q - 1, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - big_offd_j[o_cnt] = hypre_map(ix, iy - 1, iz - 1, p, q - 1, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - if (ix < nx_part[p + 1] - 1) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy - 1, iz - 1, p, q - 1, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else if (ix < nx - 1) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy - 1, iz - 1, p + 1, q - 1, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - } - if (ix > nx_part[p]) - { - diag_j[cnt] = row_index - nxy - 1; - diag_data[cnt++] = value[1]; - } - else - { - if (ix) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy, iz - 1, p - 1, q, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - diag_j[cnt] = row_index - nxy; - diag_data[cnt++] = value[1]; - if (ix + 1 < nx_part[p + 1]) - { - diag_j[cnt] = row_index - nxy + 1; - diag_data[cnt++] = value[1]; - } - else - { - if (ix + 1 < nx) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy, iz - 1, p + 1, q, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - if (iy + 1 < ny_part[q + 1]) - { - if (ix > nx_part[p]) - { - diag_j[cnt] = row_index - nxy + nx_local - 1; - diag_data[cnt++] = value[1]; - } - else - { - if (ix) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy + 1, iz - 1, p - 1, q, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - diag_j[cnt] = row_index - nxy + nx_local; - diag_data[cnt++] = value[1]; - if (ix < nx_part[p + 1] - 1) - { - diag_j[cnt] = row_index - nxy + nx_local + 1; - diag_data[cnt++] = value[1]; - } - else - { - if (ix + 1 < nx) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy + 1, iz - 1, p + 1, q, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - } - else - { - if (iy + 1 < ny) - { - if (ix > nx_part[p]) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy + 1, iz - 1, p, q + 1, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else if (ix) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy + 1, iz - 1, p - 1, q + 1, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - big_offd_j[o_cnt] = hypre_map(ix, iy + 1, iz - 1, p, q + 1, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - if (ix < nx_part[p + 1] - 1) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy + 1, iz - 1, p, q + 1, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else if (ix < nx - 1) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy + 1, iz - 1, p + 1, q + 1, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - } - } - else - { - if (iz) - { - if (iy > ny_part[q]) - { - if (ix > nx_part[p]) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy - 1, iz - 1, p, q, r - 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else - { - if (ix) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy - 1, iz - 1, p - 1, q, r - 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - big_offd_j[o_cnt] = hypre_map(ix, iy - 1, iz - 1, p, q, r - 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - if (ix < nx_part[p + 1] - 1) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy - 1, iz - 1, p, q, r - 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else - { - if (ix + 1 < nx) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy - 1, iz - 1, p + 1, q, r - 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - } - else - { - if (iy) - { - if (ix > nx_part[p]) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy - 1, iz - 1, p, q - 1, r - 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else if (ix) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy - 1, iz - 1, p - 1, q - 1, r - 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - big_offd_j[o_cnt] = hypre_map(ix, iy - 1, iz - 1, p, q - 1, r - 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - if (ix < nx_part[p + 1] - 1) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy - 1, iz - 1, p, q - 1, r - 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else if (ix < nx - 1) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy - 1, iz - 1, p + 1, q - 1, r - 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - } - if (ix > nx_part[p]) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy, iz - 1, p, q, r - 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else - { - if (ix) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy, iz - 1, p - 1, q, r - 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - big_offd_j[o_cnt] = hypre_map(ix, iy, iz - 1, p, q, r - 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - if (ix + 1 < nx_part[p + 1]) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy, iz - 1, p, q, r - 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else - { - if (ix + 1 < nx) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy, iz - 1, p + 1, q, r - 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - if (iy + 1 < ny_part[q + 1]) - { - if (ix > nx_part[p]) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy + 1, iz - 1, p, q, r - 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else - { - if (ix) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy + 1, iz - 1, p - 1, q, r - 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - big_offd_j[o_cnt] = hypre_map(ix, iy + 1, iz - 1, p, q, r - 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - if (ix < nx_part[p + 1] - 1) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy + 1, iz - 1, p, q, r - 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else - { - if (ix + 1 < nx) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy + 1, iz - 1, p + 1, q, r - 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - } - else - { - if (iy + 1 < ny) - { - if (ix > nx_part[p]) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy + 1, iz - 1, p, q + 1, r - 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else if (ix) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy + 1, iz - 1, p - 1, q + 1, r - 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - big_offd_j[o_cnt] = hypre_map(ix, iy + 1, iz - 1, p, q + 1, r - 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - if (ix < nx_part[p + 1] - 1) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy + 1, iz - 1, p, q + 1, r - 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else if (ix < nx - 1) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy + 1, iz - 1, p + 1, q + 1, r - 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - } - } - } - if (iy > ny_part[q]) - { - if (ix > nx_part[p]) - { - diag_j[cnt] = row_index - nx_local - 1; - diag_data[cnt++] = value[1]; - } - else - { - if (ix) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy - 1, iz, p - 1, q, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - diag_j[cnt] = row_index - nx_local; - diag_data[cnt++] = value[1]; - if (ix < nx_part[p + 1] - 1) - { - diag_j[cnt] = row_index - nx_local + 1; - diag_data[cnt++] = value[1]; - } - else - { - if (ix + 1 < nx) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy - 1, iz, p + 1, q, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - } - else - { - if (iy) - { - if (ix > nx_part[p]) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy - 1, iz, p, q - 1, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else if (ix) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy - 1, iz, p - 1, q - 1, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - big_offd_j[o_cnt] = hypre_map(ix, iy - 1, iz, p, q - 1, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - if (ix < nx_part[p + 1] - 1) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy - 1, iz, p, q - 1, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else if (ix < nx - 1) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy - 1, iz, p + 1, q - 1, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - } - if (ix > nx_part[p]) - { - diag_j[cnt] = row_index - 1; - diag_data[cnt++] = value[1]; - } - else - { - if (ix) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy, iz, p - 1, q, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - if (ix + 1 < nx_part[p + 1]) - { - diag_j[cnt] = row_index + 1; - diag_data[cnt++] = value[1]; - } - else - { - if (ix + 1 < nx) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy, iz, p + 1, q, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - if (iy + 1 < ny_part[q + 1]) - { - if (ix > nx_part[p]) - { - diag_j[cnt] = row_index + nx_local - 1; - diag_data[cnt++] = value[1]; - } - else - { - if (ix) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy + 1, iz, p - 1, q, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - diag_j[cnt] = row_index + nx_local; - diag_data[cnt++] = value[1]; - if (ix < nx_part[p + 1] - 1) - { - diag_j[cnt] = row_index + nx_local + 1; - diag_data[cnt++] = value[1]; - } - else - { - if (ix + 1 < nx) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy + 1, iz, p + 1, q, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - } - else - { - if (iy + 1 < ny) - { - if (ix > nx_part[p]) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy + 1, iz, p, q + 1, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else if (ix) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy + 1, iz, p - 1, q + 1, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - big_offd_j[o_cnt] = hypre_map(ix, iy + 1, iz, p, q + 1, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - if (ix < nx_part[p + 1] - 1) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy + 1, iz, p, q + 1, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else if (ix < nx - 1) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy + 1, iz, p + 1, q + 1, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - } - if (iz + 1 < nz_part[r + 1]) - { - if (iy > ny_part[q]) - { - if (ix > nx_part[p]) - { - diag_j[cnt] = row_index + nxy - nx_local - 1; - diag_data[cnt++] = value[1]; - } - else - { - if (ix) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy - 1, iz + 1, p - 1, q, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - diag_j[cnt] = row_index + nxy - nx_local; - diag_data[cnt++] = value[1]; - if (ix < nx_part[p + 1] - 1) - { - diag_j[cnt] = row_index + nxy - nx_local + 1; - diag_data[cnt++] = value[1]; - } - else - { - if (ix + 1 < nx) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy - 1, iz + 1, p + 1, q, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - } - else - { - if (iy) - { - if (ix > nx_part[p]) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy - 1, iz + 1, p, q - 1, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else if (ix) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy - 1, iz + 1, p - 1, q - 1, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - big_offd_j[o_cnt] = hypre_map(ix, iy - 1, iz + 1, p, q - 1, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - if (ix < nx_part[p + 1] - 1) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy - 1, iz + 1, p, q - 1, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else if (ix < nx - 1) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy - 1, iz + 1, p + 1, q - 1, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - } - if (ix > nx_part[p]) - { - diag_j[cnt] = row_index + nxy - 1; - diag_data[cnt++] = value[1]; - } - else - { - if (ix) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy, iz + 1, p - 1, q, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - diag_j[cnt] = row_index + nxy; - diag_data[cnt++] = value[1]; - if (ix + 1 < nx_part[p + 1]) - { - diag_j[cnt] = row_index + nxy + 1; - diag_data[cnt++] = value[1]; - } - else - { - if (ix + 1 < nx) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy, iz + 1, p + 1, q, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - if (iy + 1 < ny_part[q + 1]) - { - if (ix > nx_part[p]) - { - diag_j[cnt] = row_index + nxy + nx_local - 1; - diag_data[cnt++] = value[1]; - } - else - { - if (ix) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy + 1, iz + 1, p - 1, q, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - diag_j[cnt] = row_index + nxy + nx_local; - diag_data[cnt++] = value[1]; - if (ix < nx_part[p + 1] - 1) - { - diag_j[cnt] = row_index + nxy + nx_local + 1; - diag_data[cnt++] = value[1]; - } - else - { - if (ix + 1 < nx) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy + 1, iz + 1, p + 1, q, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - } - else - { - if (iy + 1 < ny) - { - if (ix > nx_part[p]) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy + 1, iz + 1, p, q + 1, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else if (ix) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy + 1, iz + 1, p - 1, q + 1, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - big_offd_j[o_cnt] = hypre_map(ix, iy + 1, iz + 1, p, q + 1, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - if (ix < nx_part[p + 1] - 1) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy + 1, iz + 1, p, q + 1, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else if (ix < nx - 1) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy + 1, iz + 1, p + 1, q + 1, r, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - } - } - else - { - if (iz + 1 < nz) - { - if (iy > ny_part[q]) - { - if (ix > nx_part[p]) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy - 1, iz + 1, p, q, r + 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else - { - if (ix) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy - 1, iz + 1, p - 1, q, r + 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - big_offd_j[o_cnt] = hypre_map(ix, iy - 1, iz + 1, p, q, r + 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - if (ix < nx_part[p + 1] - 1) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy - 1, iz + 1, p, q, r + 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else - { - if (ix + 1 < nx) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy - 1, iz + 1, p + 1, q, r + 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - } - else - { - if (iy) - { - if (ix > nx_part[p]) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy - 1, iz + 1, p, q - 1, r + 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else if (ix) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy - 1, iz + 1, p - 1, q - 1, r + 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - big_offd_j[o_cnt] = hypre_map(ix, iy - 1, iz + 1, p, q - 1, r + 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - if (ix < nx_part[p + 1] - 1) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy - 1, iz + 1, p, q - 1, r + 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else if (ix < nx - 1) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy - 1, iz + 1, p + 1, q - 1, r + 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - } - if (ix > nx_part[p]) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy, iz + 1, p, q, r + 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else - { - if (ix) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy, iz + 1, p - 1, q, r + 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - big_offd_j[o_cnt] = hypre_map(ix, iy, iz + 1, p, q, r + 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - if (ix + 1 < nx_part[p + 1]) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy, iz + 1, p, q, r + 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else - { - if (ix + 1 < nx) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy, iz + 1, p + 1, q, r + 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - if (iy + 1 < ny_part[q + 1]) - { - if (ix > nx_part[p]) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy + 1, iz + 1, p, q, r + 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else - { - if (ix) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy + 1, iz + 1, p - 1, q, r + 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - big_offd_j[o_cnt] = hypre_map(ix, iy + 1, iz + 1, p, q, r + 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - if (ix < nx_part[p + 1] - 1) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy + 1, iz + 1, p, q, r + 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else - { - if (ix + 1 < nx) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy + 1, iz + 1, p + 1, q, r + 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - } - else - { - if (iy + 1 < ny) - { - if (ix > nx_part[p]) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy + 1, iz + 1, p, q + 1, r + 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else if (ix) - { - big_offd_j[o_cnt] = hypre_map(ix - 1, iy + 1, iz + 1, p - 1, q + 1, r + 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - big_offd_j[o_cnt] = hypre_map(ix, iy + 1, iz + 1, p, q + 1, r + 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - if (ix < nx_part[p + 1] - 1) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy + 1, iz + 1, p, q + 1, r + 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - else if (ix < nx - 1) - { - big_offd_j[o_cnt] = hypre_map(ix + 1, iy + 1, iz + 1, p + 1, q + 1, r + 1, nx, ny, - nx_part, ny_part, nz_part); - offd_data[o_cnt++] = value[1]; - } - } - } - } - } - row_index++; - } - } - } - - if (num_procs > 1) - { - work = hypre_CTAlloc(HYPRE_BigInt, o_cnt, HYPRE_MEMORY_HOST); - - for (i = 0; i < o_cnt; i++) - { - work[i] = big_offd_j[i]; - } - - hypre_BigQsort0(work, 0, o_cnt - 1); - - col_map_offd[0] = work[0]; - cnt = 0; - for (i = 0; i < o_cnt; i++) - { - if (work[i] > col_map_offd[cnt]) - { - cnt++; - col_map_offd[cnt] = work[i]; - } - } - - for (i = 0; i < o_cnt; i++) - { - offd_j[i] = hypre_BigBinarySearch(col_map_offd, big_offd_j[i], num_cols_offd); - } - - hypre_TFree(work, HYPRE_MEMORY_HOST); - } - - A = hypre_ParCSRMatrixCreate(comm, grid_size, grid_size, - global_part, global_part, num_cols_offd, - diag_i[local_num_rows], - offd_i[local_num_rows]); - - hypre_ParCSRMatrixColMapOffd(A) = col_map_offd; - - diag = hypre_ParCSRMatrixDiag(A); - hypre_CSRMatrixI(diag) = diag_i; - hypre_CSRMatrixJ(diag) = diag_j; - hypre_CSRMatrixData(diag) = diag_data; - - offd = hypre_ParCSRMatrixOffd(A); - hypre_CSRMatrixI(offd) = offd_i; - if (num_cols_offd) - { - hypre_CSRMatrixJ(offd) = offd_j; - hypre_CSRMatrixData(offd) = offd_data; - } - - hypre_CSRMatrixMemoryLocation(diag) = HYPRE_MEMORY_HOST; - hypre_CSRMatrixMemoryLocation(offd) = HYPRE_MEMORY_HOST; - - hypre_ParCSRMatrixMigrate(A, hypre_HandleMemoryLocation(hypre_handle())); - - hypre_TFree(nx_part, HYPRE_MEMORY_HOST); - hypre_TFree(ny_part, HYPRE_MEMORY_HOST); - hypre_TFree(nz_part, HYPRE_MEMORY_HOST); - hypre_TFree(big_offd_j, HYPRE_MEMORY_HOST); - - return (HYPRE_ParCSRMatrix) A; -} diff --git a/src/parcsr_ls/par_rotate_7pt.c b/src/parcsr_ls/par_rotate_7pt.c deleted file mode 100644 index cf11eb759c..0000000000 --- a/src/parcsr_ls/par_rotate_7pt.c +++ /dev/null @@ -1,397 +0,0 @@ -/****************************************************************************** - * Copyright (c) 1998 Lawrence Livermore National Security, LLC and other - * HYPRE Project Developers. See the top-level COPYRIGHT file for details. - * - * SPDX-License-Identifier: (Apache-2.0 OR MIT) - ******************************************************************************/ - -#include "_hypre_parcsr_ls.h" - -/*-------------------------------------------------------------------------- - * hypre_GenerateLaplacian9pt - *--------------------------------------------------------------------------*/ - -HYPRE_ParCSRMatrix -GenerateRotate7pt( MPI_Comm comm, - HYPRE_BigInt nx, - HYPRE_BigInt ny, - HYPRE_Int P, - HYPRE_Int Q, - HYPRE_Int p, - HYPRE_Int q, - HYPRE_Real alpha, - HYPRE_Real eps ) -{ - hypre_ParCSRMatrix *A; - hypre_CSRMatrix *diag; - hypre_CSRMatrix *offd; - - HYPRE_Int *diag_i; - HYPRE_Int *diag_j; - HYPRE_Real *diag_data; - - HYPRE_Int *offd_i; - HYPRE_Int *offd_j = NULL; - HYPRE_Real *offd_data = NULL; - - HYPRE_Real *value; - HYPRE_Real ac, bc, cc, s, c, pi, x; - HYPRE_BigInt global_part[2]; - HYPRE_BigInt ix, iy; - HYPRE_Int cnt, o_cnt; - HYPRE_Int local_num_rows; - HYPRE_BigInt *col_map_offd; - HYPRE_BigInt *big_offd_j = NULL; - HYPRE_Int row_index; - HYPRE_Int i; - - HYPRE_Int nx_local, ny_local; - HYPRE_Int num_cols_offd; - HYPRE_BigInt grid_size; - - HYPRE_BigInt *nx_part; - HYPRE_BigInt *ny_part; - - HYPRE_Int num_procs; - HYPRE_Int P_busy, Q_busy; - - hypre_MPI_Comm_size(comm, &num_procs); - - grid_size = nx * ny; - - value = hypre_CTAlloc(HYPRE_Real, 4, HYPRE_MEMORY_HOST); - pi = 4.0 * hypre_atan(1.0); - x = pi * alpha / 180.0; - s = hypre_sin(x); - c = hypre_cos(x); - ac = -(c * c + eps * s * s); - bc = 2.0 * (1.0 - eps) * s * c; - cc = -(s * s + eps * c * c); - value[0] = -2 * (2 * ac + bc + 2 * cc); - value[1] = 2 * ac + bc; - value[2] = bc + 2 * cc; - value[3] = -bc; - - hypre_GeneratePartitioning(nx, P, &nx_part); - hypre_GeneratePartitioning(ny, Q, &ny_part); - - nx_local = (HYPRE_Int)(nx_part[p + 1] - nx_part[p]); - ny_local = (HYPRE_Int)(ny_part[q + 1] - ny_part[q]); - - local_num_rows = nx_local * ny_local; - - global_part[0] = ny_part[q] * nx + nx_part[p] * ny_local; - global_part[1] = global_part[0] + (HYPRE_BigInt)local_num_rows; - - diag_i = hypre_CTAlloc(HYPRE_Int, local_num_rows + 1, HYPRE_MEMORY_HOST); - offd_i = hypre_CTAlloc(HYPRE_Int, local_num_rows + 1, HYPRE_MEMORY_HOST); - - P_busy = hypre_min(nx, P); - Q_busy = hypre_min(ny, Q); - - num_cols_offd = 0; - if (p) { num_cols_offd += ny_local; } - if (p < P_busy - 1) { num_cols_offd += ny_local; } - if (q) { num_cols_offd += nx_local; } - if (q < Q_busy - 1) { num_cols_offd += nx_local; } - if (p && q) { num_cols_offd++; } - if (p && q < Q_busy - 1 ) { num_cols_offd++; } - if (p < P_busy - 1 && q ) { num_cols_offd++; } - if (p < P_busy - 1 && q < Q_busy - 1 ) { num_cols_offd++; } - - if (!local_num_rows) { num_cols_offd = 0; } - - col_map_offd = hypre_CTAlloc(HYPRE_BigInt, num_cols_offd, HYPRE_MEMORY_HOST); - - cnt = 0; - o_cnt = 0; - diag_i[0] = 0; - offd_i[0] = 0; - for (iy = ny_part[q]; iy < ny_part[q + 1]; iy++) - { - for (ix = nx_part[p]; ix < nx_part[p + 1]; ix++) - { - cnt++; - o_cnt++; - diag_i[cnt] = diag_i[cnt - 1]; - offd_i[o_cnt] = offd_i[o_cnt - 1]; - diag_i[cnt]++; - if (iy > ny_part[q]) - { - diag_i[cnt]++; - if (ix > nx_part[p]) - { - diag_i[cnt]++; - } - else - { - if (ix) - { - offd_i[o_cnt]++; - } - } - } - else - { - if (iy) - { - offd_i[o_cnt]++; - if (ix > nx_part[p]) - { - offd_i[o_cnt]++; - } - else if (ix) - { - offd_i[o_cnt]++; - } - } - } - if (ix > nx_part[p]) - { - diag_i[cnt]++; - } - else - { - if (ix) - { - offd_i[o_cnt]++; - } - } - if (ix + 1 < nx_part[p + 1]) - { - diag_i[cnt]++; - } - else - { - if (ix + 1 < nx) - { - offd_i[o_cnt]++; - } - } - if (iy + 1 < ny_part[q + 1]) - { - diag_i[cnt]++; - if (ix < nx_part[p + 1] - 1) - { - diag_i[cnt]++; - } - else - { - if (ix + 1 < nx) - { - offd_i[o_cnt]++; - } - } - } - else - { - if (iy + 1 < ny) - { - offd_i[o_cnt]++; - if (ix < nx_part[p + 1] - 1) - { - offd_i[o_cnt]++; - } - else if (ix < nx - 1) - { - offd_i[o_cnt]++; - } - } - } - } - } - - diag_j = hypre_CTAlloc(HYPRE_Int, diag_i[local_num_rows], HYPRE_MEMORY_HOST); - diag_data = hypre_CTAlloc(HYPRE_Real, diag_i[local_num_rows], HYPRE_MEMORY_HOST); - - if (num_procs > 1) - { - big_offd_j = hypre_CTAlloc(HYPRE_BigInt, offd_i[local_num_rows], HYPRE_MEMORY_HOST); - offd_j = hypre_CTAlloc(HYPRE_Int, offd_i[local_num_rows], HYPRE_MEMORY_HOST); - offd_data = hypre_CTAlloc(HYPRE_Real, offd_i[local_num_rows], HYPRE_MEMORY_HOST); - } - - row_index = 0; - cnt = 0; - o_cnt = 0; - for (iy = ny_part[q]; iy < ny_part[q + 1]; iy++) - { - for (ix = nx_part[p]; ix < nx_part[p + 1]; ix++) - { - diag_j[cnt] = row_index; - diag_data[cnt++] = value[0]; - if (iy > ny_part[q]) - { - if (ix > nx_part[p]) - { - diag_j[cnt] = row_index - nx_local - 1 ; - diag_data[cnt++] = value[3]; - } - else - { - if (ix) - { - big_offd_j[o_cnt] = hypre_map2(ix - 1, iy - 1, p - 1, q, nx, - nx_part, ny_part); - offd_data[o_cnt++] = value[3]; - } - } - diag_j[cnt] = row_index - nx_local; - diag_data[cnt++] = value[2]; - } - else - { - if (iy) - { - if (ix > nx_part[p]) - { - big_offd_j[o_cnt] = hypre_map2(ix - 1, iy - 1, p, q - 1, nx, - nx_part, ny_part); - offd_data[o_cnt++] = value[3]; - } - else if (ix) - { - big_offd_j[o_cnt] = hypre_map2(ix - 1, iy - 1, p - 1, q - 1, nx, - nx_part, ny_part); - offd_data[o_cnt++] = value[3]; - } - big_offd_j[o_cnt] = hypre_map2(ix, iy - 1, p, q - 1, nx, - nx_part, ny_part); - offd_data[o_cnt++] = value[2]; - } - } - if (ix > nx_part[p]) - { - diag_j[cnt] = row_index - 1; - diag_data[cnt++] = value[1]; - } - else - { - if (ix) - { - big_offd_j[o_cnt] = hypre_map2(ix - 1, iy, p - 1, q, nx, - nx_part, ny_part); - offd_data[o_cnt++] = value[1]; - } - } - if (ix + 1 < nx_part[p + 1]) - { - diag_j[cnt] = row_index + 1; - diag_data[cnt++] = value[1]; - } - else - { - if (ix + 1 < nx) - { - big_offd_j[o_cnt] = hypre_map2(ix + 1, iy, p + 1, q, nx, - nx_part, ny_part); - offd_data[o_cnt++] = value[1]; - } - } - if (iy + 1 < ny_part[q + 1]) - { - diag_j[cnt] = row_index + nx_local; - diag_data[cnt++] = value[2]; - if (ix < nx_part[p + 1] - 1) - { - diag_j[cnt] = row_index + nx_local + 1 ; - diag_data[cnt++] = value[3]; - } - else - { - if (ix + 1 < nx) - { - big_offd_j[o_cnt] = hypre_map2(ix + 1, iy + 1, p + 1, q, nx, - nx_part, ny_part); - offd_data[o_cnt++] = value[3]; - } - } - } - else - { - if (iy + 1 < ny) - { - big_offd_j[o_cnt] = hypre_map2(ix, iy + 1, p, q + 1, nx, - nx_part, ny_part); - offd_data[o_cnt++] = value[2]; - if (ix < nx_part[p + 1] - 1) - { - big_offd_j[o_cnt] = hypre_map2(ix + 1, iy + 1, p, q + 1, nx, - nx_part, ny_part); - offd_data[o_cnt++] = value[3]; - } - else if (ix < nx - 1) - { - big_offd_j[o_cnt] = hypre_map2(ix + 1, iy + 1, p + 1, q + 1, nx, - nx_part, ny_part); - offd_data[o_cnt++] = value[3]; - } - } - } - row_index++; - } - } - - if (num_procs > 1) - { - HYPRE_BigInt *work = hypre_CTAlloc(HYPRE_BigInt, o_cnt, HYPRE_MEMORY_HOST); - - for (i = 0; i < o_cnt; i++) - { - work[i] = big_offd_j[i]; - } - - hypre_BigQsort0(work, 0, o_cnt - 1); - - col_map_offd[0] = work[0]; - cnt = 0; - for (i = 0; i < o_cnt; i++) - { - if (work[i] > col_map_offd[cnt]) - { - cnt++; - col_map_offd[cnt] = work[i]; - } - } - - num_cols_offd = cnt + 1; - for (i = 0; i < o_cnt; i++) - { - offd_j[i] = hypre_BigBinarySearch(col_map_offd, big_offd_j[i], num_cols_offd); - } - - hypre_TFree(work, HYPRE_MEMORY_HOST); - hypre_TFree(big_offd_j, HYPRE_MEMORY_HOST); - } - - A = hypre_ParCSRMatrixCreate(comm, grid_size, grid_size, - global_part, global_part, num_cols_offd, - diag_i[local_num_rows], - offd_i[local_num_rows]); - - hypre_ParCSRMatrixColMapOffd(A) = col_map_offd; - - diag = hypre_ParCSRMatrixDiag(A); - hypre_CSRMatrixI(diag) = diag_i; - hypre_CSRMatrixJ(diag) = diag_j; - hypre_CSRMatrixData(diag) = diag_data; - - offd = hypre_ParCSRMatrixOffd(A); - hypre_CSRMatrixI(offd) = offd_i; - if (num_cols_offd) - { - hypre_CSRMatrixJ(offd) = offd_j; - hypre_CSRMatrixData(offd) = offd_data; - } - - hypre_CSRMatrixMemoryLocation(diag) = HYPRE_MEMORY_HOST; - hypre_CSRMatrixMemoryLocation(offd) = HYPRE_MEMORY_HOST; - - hypre_ParCSRMatrixMigrate(A, hypre_HandleMemoryLocation(hypre_handle())); - - hypre_TFree(nx_part, HYPRE_MEMORY_HOST); - hypre_TFree(ny_part, HYPRE_MEMORY_HOST); - hypre_TFree(value, HYPRE_MEMORY_HOST); - - return (HYPRE_ParCSRMatrix) A; -} diff --git a/src/parcsr_ls/protos.h b/src/parcsr_ls/protos.h index 3141bb6579..1f196c8cdf 100644 --- a/src/parcsr_ls/protos.h +++ b/src/parcsr_ls/protos.h @@ -736,25 +736,6 @@ void hypre_BoomerAMGTruncateInterp ( hypre_ParCSRMatrix *P, HYPRE_Real eps, HYPR HYPRE_Int hypre_ParCSRMatrix_dof_func_offd ( hypre_ParCSRMatrix *A, HYPRE_Int num_functions, HYPRE_Int *dof_func, HYPRE_Int **dof_func_offd ); -/* par_laplace_27pt.c */ -HYPRE_Int hypre_map3 ( HYPRE_BigInt ix, HYPRE_BigInt iy, HYPRE_BigInt iz, HYPRE_Int p, HYPRE_Int q, - HYPRE_Int r, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_BigInt *nx_part, HYPRE_BigInt *ny_part, - HYPRE_BigInt *nz_part ); - -/* par_laplace_9pt.c */ -HYPRE_BigInt hypre_map2 ( HYPRE_BigInt ix, HYPRE_BigInt iy, HYPRE_Int p, HYPRE_Int q, - HYPRE_BigInt nx, HYPRE_BigInt *nx_part, HYPRE_BigInt *ny_part ); - -/* par_laplace.c */ -HYPRE_BigInt hypre_map ( HYPRE_BigInt ix, HYPRE_BigInt iy, HYPRE_BigInt iz, HYPRE_Int p, - HYPRE_Int q, HYPRE_Int r, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt *nx_part, - HYPRE_BigInt *ny_part, HYPRE_BigInt *nz_part ); -HYPRE_ParCSRMatrix GenerateSysLaplacian ( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, - HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, - HYPRE_Int num_fun, HYPRE_Real *mtrx, HYPRE_Real *value ); -HYPRE_ParCSRMatrix GenerateSysLaplacianVCoef ( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, - HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, - HYPRE_Int num_fun, HYPRE_Real *mtrx, HYPRE_Real *value ); /* par_lr_interp.c */ HYPRE_Int hypreDevice_extendWtoP ( HYPRE_Int P_nr_of_rows, HYPRE_Int W_nr_of_rows, @@ -1213,29 +1194,6 @@ HYPRE_Int hypre_BoomerAMGBuildPartialExtInterp ( hypre_ParCSRMatrix *A, HYPRE_In HYPRE_Int num_functions, HYPRE_Int *dof_func, HYPRE_Int debug_flag, HYPRE_Real trunc_factor, HYPRE_Int max_elmts, hypre_ParCSRMatrix **P_ptr ); -/* par_vardifconv.c */ -HYPRE_Real afun ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real bfun ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real cfun ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real dfun ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real efun ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real ffun ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real gfun ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real rfun ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real bndfun ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); - -/* par_vardifconv_rs.c */ -HYPRE_Real afun_rs ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real bfun_rs ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real cfun_rs ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real dfun_rs ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real efun_rs ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real ffun_rs ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real gfun_rs ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real rfun_rs ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); -HYPRE_Real bndfun_rs ( HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz ); - - /* pcg_par.c */ void *hypre_ParKrylovCAlloc ( size_t count, size_t elt_size, HYPRE_MemoryLocation location ); HYPRE_Int hypre_ParKrylovFree ( void *ptr ); diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index 3489c9e342..db81343c87 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -16,13 +16,11 @@ endif() # Define list of executables set(TEST_SRCS - ij.c sstruct.c struct.c structmat.c ams_driver.c struct_migrate.c - ij_assembly.c ) # Mixed precision test executables (only built when mixed precision is enabled) @@ -40,6 +38,10 @@ add_hypre_executables("${TEST_SRCS}") # Special treatment for sstructmat as it depends on sstruct_helpers (not an executable) add_hypre_executable("sstructmat.c" "sstruct_helpers.c") +# Special treatment for ij drivers as they depend on ij_helpers (not an executable) +add_hypre_executable("ij.c" "ij_helpers.c") +add_hypre_executable("ij_assembly.c" "ij_helpers.c") + # Copy test input files configure_file(${CMAKE_CURRENT_SOURCE_DIR}/TEST_sstruct/sstruct.in.default ${CMAKE_CURRENT_BINARY_DIR}/sstruct.in.default COPYONLY) diff --git a/src/test/Makefile b/src/test/Makefile index 624b0a4da0..5833999d3c 100644 --- a/src/test/Makefile +++ b/src/test/Makefile @@ -63,13 +63,13 @@ LFLAGS =\ HYPRE_DRIVERS =\ ij.c\ ij_assembly.c\ + ij_mm.c\ sstruct.c\ sstructmat.c\ struct.c\ structmat.c\ ams_driver.c\ struct_migrate.c\ - ij_mm.c\ zboxloop.c\ HYPRE_MP_DRIVERS =\ @@ -103,6 +103,12 @@ HYPRE_F77_EXAMPLES_DRIVER_EXECS=${HYPRE_F77_EXAMPLES_DRIVERS:.c=} HYPRE_DRIVER_F77_EXECS=${HYPRE_DRIVERS_F77:.f=} HYPRE_DRIVER_CXX_EXECS=${HYPRE_DRIVERS_CXX:.cxx=} +ifeq (${MP_BUILD}, 1) + IJ_HELPER_OBJS = ij_helpers.o_flt ij_helpers.o_dbl ij_helpers.o_ldbl ij_helpers.o +else + IJ_HELPER_OBJS = ij_helpers.o +endif + all: ${HYPRE_DRIVER_EXECS} all77: ${HYPRE_DRIVER_F77_EXECS} @@ -112,7 +118,7 @@ all++: ${HYPRE_DRIVER_CXX_EXECS} install: clean: - rm -f *.o *.obj *.csv + rm -f *.o *.o_flt *.o_dbl *.o_ldbl *.obj *.csv rm -rf pchdir tca.map *inslog* distclean: clean @@ -139,13 +145,21 @@ distclean: clean ################################################################## # C -ij: ij.o +ij: ${IJ_HELPER_OBJS} ij.o @echo "Building" $@ "... " - ${LINK_CC} -o $@ $< ${LFLAGS} + ${LINK_CC} -o $@ $^ ${LFLAGS} -ij_assembly: ij_assembly.o +ij_assembly: ${IJ_HELPER_OBJS} ij_assembly.o @echo "Building" $@ "... " - ${LINK_CC} -o $@ $< ${LFLAGS} + ${LINK_CC} -o $@ $^ ${LFLAGS} + +ij_device: ${IJ_HELPER_OBJS} ij_device.o + @echo "Building" $@ "... " + ${LINK_CC} -o $@ $^ ${LFLAGS} + +ij_mm: ${IJ_HELPER_OBJS} ij_mm.o + @echo "Building" $@ "... " + ${LINK_CC} -o $@ $^ ${LFLAGS} # TODO (VPM): Update data structures on sstruct_helpers for GPUs # sstruct: sstruct_helpers.o sstruct.o @@ -176,14 +190,6 @@ struct_migrate: struct_migrate.o @echo "Building" $@ "... " ${LINK_CC} -o $@ $< ${LFLAGS} -ij_device: ij_device.o - @echo "Building" $@ "... " - ${LINK_CC} -o $@ $< ${LFLAGS} - -ij_mm: ij_mm.o - @echo "Building" $@ "... " - ${LINK_CC} -o $@ $< ${LFLAGS} - zboxloop: zboxloop.obj @echo "Building" $@ "... " ${LINK_CC} -o $@ $< ${LFLAGS} @@ -192,9 +198,9 @@ struct_newboxloop: struct_newboxloop.o $(KOKKOS_LINK_DEPENDS) @echo "Building" $@ "... " ${LINK_CC} -o $@ $< ${LFLAGS} -ij_mp: ij_mp.o +ij_mp: ${IJ_HELPER_OBJS} ij_mp.o @echo "Building" $@ "... " - ${LINK_CC} -o $@ $< ${LFLAGS} + ${LINK_CC} -o $@ $^ ${LFLAGS} struct_mp: struct_mp.o @echo "Building" $@ "... " diff --git a/src/test/ij.c b/src/test/ij.c index c5d16626cd..cdfde60193 100644 --- a/src/test/ij.c +++ b/src/test/ij.c @@ -7,7 +7,7 @@ /*-------------------------------------------------------------------------- * Test driver for unstructured matrix interface (IJ_matrix interface). - * Do `driver -help' for usage info. + * Do `./ij -help' for usage info. * This driver started from the driver for parcsr_linear_solvers, and it * works by first building a parcsr matrix as before and then "copying" * that matrix row-by-row into the IJMatrix interface. AJC 7/99. @@ -25,6 +25,7 @@ #include "HYPRE_parcsr_ls.h" #include "_hypre_parcsr_mv.h" #include "HYPRE_krylov.h" +#include "ij_helpers.h" #if defined (HYPRE_USING_CUDA) #include @@ -92,16 +93,6 @@ HYPRE_Int BuildParRotate7pt (MPI_Comm comm, HYPRE_Int argc, char *argv [], HYPRE HYPRE_ParCSRMatrix *A_ptr ); HYPRE_Int BuildParVarDifConv (MPI_Comm comm, HYPRE_Int argc, char *argv [], HYPRE_Int arg_index, HYPRE_ParCSRMatrix *A_ptr, HYPRE_ParVector *rhs_ptr ); -HYPRE_ParCSRMatrix GenerateSysLaplacian (MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, - HYPRE_BigInt nz, - HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, - HYPRE_Int num_fun, HYPRE_Real *mtrx, HYPRE_Real *value); -HYPRE_ParCSRMatrix GenerateSysLaplacianVCoef (MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, - HYPRE_BigInt nz, - HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, - HYPRE_Int num_fun, HYPRE_Real *mtrx, HYPRE_Real *value); -HYPRE_Int SetSysVcoefValues(HYPRE_Int num_fun, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, - HYPRE_Real vcx, HYPRE_Real vcy, HYPRE_Real vcz, HYPRE_Int mtx_entry, HYPRE_Real *values); HYPRE_Int BuildParCoordinates (MPI_Comm comm, HYPRE_Int argc, char *argv [], HYPRE_Int arg_index, HYPRE_Int *coorddim_ptr, float **coord_ptr ); @@ -9833,6 +9824,36 @@ ReadParVectorFromFile( MPI_Comm comm, return (0); } +/**************************************************************************/ + +static inline HYPRE_Int +SetSysVcoefValues(HYPRE_Int num_fun, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, + HYPRE_Real vcx, HYPRE_Real vcy, HYPRE_Real vcz, + HYPRE_Int mtx_entry, HYPRE_Real *values) +{ + HYPRE_Int sz = num_fun * num_fun; + + values[1 * sz + mtx_entry] = -vcx; + values[2 * sz + mtx_entry] = -vcy; + values[3 * sz + mtx_entry] = -vcz; + values[0 * sz + mtx_entry] = 0.0; + + if (nx > 1) + { + values[0 * sz + mtx_entry] += 2.0 * vcx; + } + if (ny > 1) + { + values[0 * sz + mtx_entry] += 2.0 * vcy; + } + if (nz > 1) + { + values[0 * sz + mtx_entry] += 2.0 * vcz; + } + + return 0; +} + /*---------------------------------------------------------------------- * Build standard 7-point laplacian in 3D with grid and anisotropy. * Parameters given in command line. @@ -11831,38 +11852,6 @@ BuildParVarDifConv( MPI_Comm comm, return (0); } -/**************************************************************************/ - -HYPRE_Int SetSysVcoefValues(HYPRE_Int num_fun, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, - HYPRE_Real vcx, - HYPRE_Real vcy, HYPRE_Real vcz, HYPRE_Int mtx_entry, HYPRE_Real *values) -{ - - - HYPRE_Int sz = num_fun * num_fun; - - values[1 * sz + mtx_entry] = -vcx; - values[2 * sz + mtx_entry] = -vcy; - values[3 * sz + mtx_entry] = -vcz; - values[0 * sz + mtx_entry] = 0.0; - - if (nx > 1) - { - values[0 * sz + mtx_entry] += 2.0 * vcx; - } - if (ny > 1) - { - values[0 * sz + mtx_entry] += 2.0 * vcy; - } - if (nz > 1) - { - values[0 * sz + mtx_entry] += 2.0 * vcz; - } - - return 0; - -} - /*---------------------------------------------------------------------- * Build coordinates for 1D/2D/3D *----------------------------------------------------------------------*/ @@ -11943,23 +11932,13 @@ BuildParCoordinates( MPI_Comm comm, if (ny < 2) { coorddim--; } if (nz < 2) { coorddim--; } - if (coorddim > 0) - { - coordinates = hypre_GenerateCoordinates(comm, nx, ny, nz, P, Q, R, p, q, r, coorddim); - } - else - { - coordinates = NULL; - } + coordinates = GenerateCoordinates(nx, ny, nz, P, Q, R, p, q, r, coorddim); *coorddim_ptr = coorddim; *coord_ptr = coordinates; return (0); } - -/* begin lobpcg */ - /*---------------------------------------------------------------------- * Build standard 7-point laplacian in 3D. *----------------------------------------------------------------------*/ @@ -12077,5 +12056,3 @@ BuildParIsoLaplacian( MPI_Comm comm, return (0); } - -/* end lobpcg */ diff --git a/src/test/ij_assembly.c b/src/test/ij_assembly.c index febf36320d..847a2f4355 100644 --- a/src/test/ij_assembly.c +++ b/src/test/ij_assembly.c @@ -17,7 +17,7 @@ #include "_hypre_parcsr_mv.h" #include "HYPRE_parcsr_ls.h" #include "_hypre_utilities.h" -//#include "_hypre_utilities.hpp" +#include "ij_helpers.h" HYPRE_Int buildMatrixEntries(MPI_Comm comm, HYPRE_Int nx, HYPRE_Int ny, HYPRE_Int nz, @@ -884,8 +884,3 @@ test_all(MPI_Comm comm, return hypre_error_flag; } - - - - - diff --git a/src/test/ij_device.c b/src/test/ij_device.c index a1fd59fedc..7bc728f5e5 100644 --- a/src/test/ij_device.c +++ b/src/test/ij_device.c @@ -25,6 +25,7 @@ #include "_hypre_parcsr_ls.h" #include "_hypre_parcsr_mv.h" #include "HYPRE_krylov.h" +#include "ij_helpers.h" #include "cuda_profiler_api.h" @@ -32,8 +33,6 @@ extern "C" { #endif - - HYPRE_Int BuildParFromFile (HYPRE_Int argc, char *argv [], HYPRE_Int arg_index, HYPRE_ParCSRMatrix *A_ptr ); HYPRE_Int BuildParRhsFromFile (HYPRE_Int argc, char *argv [], HYPRE_Int arg_index, @@ -57,13 +56,6 @@ HYPRE_Int BuildParRotate7pt (HYPRE_Int argc, char *argv [], HYPRE_Int arg_index, HYPRE_ParCSRMatrix *A_ptr ); HYPRE_Int BuildParVarDifConv (HYPRE_Int argc, char *argv [], HYPRE_Int arg_index, HYPRE_ParCSRMatrix *A_ptr, HYPRE_ParVector *rhs_ptr ); -HYPRE_ParCSRMatrix GenerateSysLaplacian (MPI_Comm comm, HYPRE_Int nx, HYPRE_Int ny, HYPRE_Int nz, - HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, - HYPRE_Int num_fun, HYPRE_Real *mtrx, HYPRE_Real *value); -HYPRE_ParCSRMatrix GenerateSysLaplacianVCoef (MPI_Comm comm, HYPRE_Int nx, HYPRE_Int ny, - HYPRE_Int nz, - HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, - HYPRE_Int num_fun, HYPRE_Real *mtrx, HYPRE_Real *value); HYPRE_Int SetSysVcoefValues(HYPRE_Int num_fun, HYPRE_Int nx, HYPRE_Int ny, HYPRE_Int nz, HYPRE_Real vcx, HYPRE_Real vcy, HYPRE_Real vcz, HYPRE_Int mtx_entry, HYPRE_Real *values); @@ -464,7 +456,38 @@ BuildParRhsFromFile( HYPRE_Int argc, } +/**************************************************************************/ + + +HYPRE_Int SetSysVcoefValues(HYPRE_Int num_fun, HYPRE_Int nx, HYPRE_Int ny, HYPRE_Int nz, + HYPRE_Real vcx, + HYPRE_Real vcy, HYPRE_Real vcz, HYPRE_Int mtx_entry, HYPRE_Real *values) +{ + + + HYPRE_Int sz = num_fun * num_fun; + + values[1 * sz + mtx_entry] = -vcx; + values[2 * sz + mtx_entry] = -vcy; + values[3 * sz + mtx_entry] = -vcz; + values[0 * sz + mtx_entry] = 0.0; + + if (nx > 1) + { + values[0 * sz + mtx_entry] += 2.0 * vcx; + } + if (ny > 1) + { + values[0 * sz + mtx_entry] += 2.0 * vcy; + } + if (nz > 1) + { + values[0 * sz + mtx_entry] += 2.0 * vcz; + } + + return 0; +} /*---------------------------------------------------------------------- * Build standard 7-point laplacian in 3D with grid and anisotropy. @@ -1746,39 +1769,6 @@ BuildParVarDifConv( HYPRE_Int argc, return (0); } -/**************************************************************************/ - - -HYPRE_Int SetSysVcoefValues(HYPRE_Int num_fun, HYPRE_Int nx, HYPRE_Int ny, HYPRE_Int nz, - HYPRE_Real vcx, - HYPRE_Real vcy, HYPRE_Real vcz, HYPRE_Int mtx_entry, HYPRE_Real *values) -{ - - - HYPRE_Int sz = num_fun * num_fun; - - values[1 * sz + mtx_entry] = -vcx; - values[2 * sz + mtx_entry] = -vcy; - values[3 * sz + mtx_entry] = -vcz; - values[0 * sz + mtx_entry] = 0.0; - - if (nx > 1) - { - values[0 * sz + mtx_entry] += 2.0 * vcx; - } - if (ny > 1) - { - values[0 * sz + mtx_entry] += 2.0 * vcy; - } - if (nz > 1) - { - values[0 * sz + mtx_entry] += 2.0 * vcz; - } - - return 0; - -} - /*---------------------------------------------------------------------- * Build coordinates for 1D/2D/3D *----------------------------------------------------------------------*/ @@ -1858,15 +1848,7 @@ BuildParCoordinates( HYPRE_Int argc, if (ny < 2) { coorddim--; } if (nz < 2) { coorddim--; } - if (coorddim > 0) - { - coordinates = hypre_GenerateCoordinates(hypre_MPI_COMM_WORLD, - nx, ny, nz, P, Q, R, p, q, r, coorddim); - } - else - { - coordinates = NULL; - } + coordinates = GenerateCoordinates(nx, ny, nz, P, Q, R, p, q, r, coorddim); *coorddim_ptr = coorddim; *coord_ptr = coordinates; diff --git a/src/test/ij_helpers.c b/src/test/ij_helpers.c new file mode 100644 index 0000000000..21c26ce4b0 --- /dev/null +++ b/src/test/ij_helpers.c @@ -0,0 +1,5435 @@ +/****************************************************************************** + * Copyright (c) 1998 Lawrence Livermore National Security, LLC and other + * HYPRE Project Developers. See the top-level COPYRIGHT file for details. + * + * SPDX-License-Identifier: (Apache-2.0 OR MIT) + ******************************************************************************/ + +#include "_hypre_parcsr_ls.h" +#include "ij_helpers.h" +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +/*-------------------------------------------------------------------------- + *--------------------------------------------------------------------------*/ + +static inline HYPRE_BigInt +map3(HYPRE_BigInt ix, HYPRE_BigInt iy, HYPRE_BigInt iz, + HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, + HYPRE_BigInt nx, HYPRE_BigInt ny, + HYPRE_BigInt *nx_part, HYPRE_BigInt *ny_part, HYPRE_BigInt *nz_part) +{ + HYPRE_Int nx_local = (HYPRE_Int)(nx_part[p + 1] - nx_part[p]); + HYPRE_Int ny_local = (HYPRE_Int)(ny_part[q + 1] - ny_part[q]); + HYPRE_Int nz_local = (HYPRE_Int)(nz_part[r + 1] - nz_part[r]); + HYPRE_Int ix_local = (HYPRE_Int)(ix - nx_part[p]); + HYPRE_Int iy_local = (HYPRE_Int)(iy - ny_part[q]); + HYPRE_Int iz_local = (HYPRE_Int)(iz - nz_part[r]); + HYPRE_BigInt global_index; + + global_index = nz_part[r] * nx * ny + + ny_part[q] * nx * (HYPRE_BigInt)nz_local + + nx_part[p] * (HYPRE_BigInt)(ny_local * nz_local); + global_index += (HYPRE_BigInt)((iz_local * ny_local + iy_local) * nx_local + ix_local); + return global_index; +} + +/*-------------------------------------------------------------------------- + *--------------------------------------------------------------------------*/ + +static inline HYPRE_BigInt +map2( HYPRE_BigInt ix, HYPRE_BigInt iy, + HYPRE_Int p, HYPRE_Int q, + HYPRE_BigInt nx, HYPRE_BigInt *nx_part, HYPRE_BigInt *ny_part) +{ + HYPRE_Int nx_local, ny_local; + HYPRE_Int ix_local, iy_local; + HYPRE_BigInt global_index; + + nx_local = (HYPRE_Int)(nx_part[p + 1] - nx_part[p]); + ny_local = (HYPRE_Int)(ny_part[q + 1] - ny_part[q]); + ix_local = (HYPRE_Int)(ix - nx_part[p]); + iy_local = (HYPRE_Int)(iy - ny_part[q]); + global_index = ny_part[q] * nx + nx_part[p] * (HYPRE_BigInt)ny_local; + global_index += (HYPRE_BigInt)(iy_local * nx_local + ix_local); + + return global_index; +} + +/*-------------------------------------------------------------------------- + * 7-pt Laplacian operator + *--------------------------------------------------------------------------*/ + +HYPRE_ParCSRMatrix +GenerateLaplacian( MPI_Comm comm, + HYPRE_BigInt nx, + HYPRE_BigInt ny, + HYPRE_BigInt nz, + HYPRE_Int P, + HYPRE_Int Q, + HYPRE_Int R, + HYPRE_Int ip, + HYPRE_Int iq, + HYPRE_Int ir, + HYPRE_Real *value ) +{ + hypre_ParCSRMatrix *A; + hypre_CSRMatrix *diag; + hypre_CSRMatrix *offd; + + HYPRE_Int *diag_i; + HYPRE_Int *diag_j; + HYPRE_Real *diag_data; + + HYPRE_Int *offd_i; + HYPRE_Int *offd_j = NULL; + HYPRE_BigInt *big_offd_j = NULL; + HYPRE_Real *offd_data = NULL; + + HYPRE_BigInt global_part[2]; + HYPRE_BigInt ix, iy, iz; + HYPRE_Int cnt, o_cnt; + HYPRE_Int local_num_rows; + HYPRE_BigInt *col_map_offd; + HYPRE_Int row_index; + HYPRE_Int i, j; + + HYPRE_Int nx_local, ny_local, nz_local; + HYPRE_Int num_cols_offd; + HYPRE_BigInt grid_size; + + HYPRE_BigInt *nx_part; + HYPRE_BigInt *ny_part; + HYPRE_BigInt *nz_part; + + HYPRE_Int num_procs; + HYPRE_Int P_busy, Q_busy, R_busy; + + hypre_MPI_Comm_size(comm, &num_procs); + + grid_size = nx * ny * nz; + + hypre_GeneratePartitioning(nx, P, &nx_part); + hypre_GeneratePartitioning(ny, Q, &ny_part); + hypre_GeneratePartitioning(nz, R, &nz_part); + + nx_local = (HYPRE_Int)(nx_part[ip + 1] - nx_part[ip]); + ny_local = (HYPRE_Int)(ny_part[iq + 1] - ny_part[iq]); + nz_local = (HYPRE_Int)(nz_part[ir + 1] - nz_part[ir]); + + local_num_rows = nx_local * ny_local * nz_local; + + global_part[0] = nz_part[ir] * nx * ny + (ny_part[iq] * nx + nx_part[ip] * ny_local) * nz_local; + global_part[1] = global_part[0] + (HYPRE_BigInt)local_num_rows; + + diag_i = hypre_CTAlloc(HYPRE_Int, local_num_rows + 1, HYPRE_MEMORY_HOST); + offd_i = hypre_CTAlloc(HYPRE_Int, local_num_rows + 1, HYPRE_MEMORY_HOST); + + P_busy = hypre_min(nx, P); + Q_busy = hypre_min(ny, Q); + R_busy = hypre_min(nz, R); + + num_cols_offd = 0; + if (ip) { num_cols_offd += ny_local * nz_local; } + if (ip < P_busy - 1) { num_cols_offd += ny_local * nz_local; } + if (iq) { num_cols_offd += nx_local * nz_local; } + if (iq < Q_busy - 1) { num_cols_offd += nx_local * nz_local; } + if (ir) { num_cols_offd += nx_local * ny_local; } + if (ir < R_busy - 1) { num_cols_offd += nx_local * ny_local; } + + if (!local_num_rows) { num_cols_offd = 0; } + + col_map_offd = hypre_CTAlloc(HYPRE_BigInt, num_cols_offd, HYPRE_MEMORY_HOST); + + cnt = 1; + o_cnt = 1; + diag_i[0] = 0; + offd_i[0] = 0; + for (iz = nz_part[ir]; iz < nz_part[ir + 1]; iz++) + { + for (iy = ny_part[iq]; iy < ny_part[iq + 1]; iy++) + { + for (ix = nx_part[ip]; ix < nx_part[ip + 1]; ix++) + { + diag_i[cnt] = diag_i[cnt - 1]; + offd_i[o_cnt] = offd_i[o_cnt - 1]; + diag_i[cnt]++; + if (iz > nz_part[ir]) + { + diag_i[cnt]++; + } + else + { + if (iz) + { + offd_i[o_cnt]++; + } + } + if (iy > ny_part[iq] ) + { + diag_i[cnt]++; + } + else + { + if (iy) + { + offd_i[o_cnt]++; + } + } + if (ix > nx_part[ip] ) + { + diag_i[cnt]++; + } + else + { + if (ix) + { + offd_i[o_cnt]++; + } + } + if (ix + 1 < nx_part[ip + 1]) + { + diag_i[cnt]++; + } + else + { + if (ix + 1 < nx) + { + offd_i[o_cnt]++; + } + } + if (iy + 1 < ny_part[iq + 1]) + { + diag_i[cnt]++; + } + else + { + if (iy + 1 < ny) + { + offd_i[o_cnt]++; + } + } + if (iz + 1 < nz_part[ir + 1]) + { + diag_i[cnt]++; + } + else + { + if (iz + 1 < nz) + { + offd_i[o_cnt]++; + } + } + cnt++; + o_cnt++; + } + } + } + + diag_j = hypre_CTAlloc(HYPRE_Int, diag_i[local_num_rows], HYPRE_MEMORY_HOST); + diag_data = hypre_CTAlloc(HYPRE_Real, diag_i[local_num_rows], HYPRE_MEMORY_HOST); + + if (num_procs > 1) + { + big_offd_j = hypre_CTAlloc(HYPRE_BigInt, offd_i[local_num_rows], HYPRE_MEMORY_HOST); + offd_j = hypre_CTAlloc(HYPRE_Int, offd_i[local_num_rows], HYPRE_MEMORY_HOST); + offd_data = hypre_CTAlloc(HYPRE_Real, offd_i[local_num_rows], HYPRE_MEMORY_HOST); + } + + row_index = 0; + cnt = 0; + o_cnt = 0; + for (iz = nz_part[ir]; iz < nz_part[ir + 1]; iz++) + { + for (iy = ny_part[iq]; iy < ny_part[iq + 1]; iy++) + { + for (ix = nx_part[ip]; ix < nx_part[ip + 1]; ix++) + { + diag_j[cnt] = row_index; + diag_data[cnt++] = value[0]; + if (iz > nz_part[ir]) + { + diag_j[cnt] = row_index - nx_local * ny_local; + diag_data[cnt++] = value[3]; + } + else + { + if (iz) + { + big_offd_j[o_cnt] = map3(ix, iy, iz - 1, ip, iq, ir - 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[3]; + } + } + if (iy > ny_part[iq]) + { + diag_j[cnt] = row_index - nx_local; + diag_data[cnt++] = value[2]; + } + else + { + if (iy) + { + big_offd_j[o_cnt] = map3(ix, iy - 1, iz, ip, iq - 1, ir, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[2]; + } + } + if (ix > nx_part[ip]) + { + diag_j[cnt] = row_index - 1; + diag_data[cnt++] = value[1]; + } + else + { + if (ix) + { + big_offd_j[o_cnt] = map3(ix - 1, iy, iz, ip - 1, iq, ir, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + if (ix + 1 < nx_part[ip + 1]) + { + diag_j[cnt] = row_index + 1; + diag_data[cnt++] = value[1]; + } + else + { + if (ix + 1 < nx) + { + big_offd_j[o_cnt] = map3(ix + 1, iy, iz, ip + 1, iq, ir, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + if (iy + 1 < ny_part[iq + 1]) + { + diag_j[cnt] = row_index + nx_local; + diag_data[cnt++] = value[2]; + } + else + { + if (iy + 1 < ny) + { + big_offd_j[o_cnt] = map3(ix, iy + 1, iz, ip, iq + 1, ir, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[2]; + } + } + if (iz + 1 < nz_part[ir + 1]) + { + diag_j[cnt] = row_index + nx_local * ny_local; + diag_data[cnt++] = value[3]; + } + else + { + if (iz + 1 < nz) + { + big_offd_j[o_cnt] = map3(ix, iy, iz + 1, ip, iq, ir + 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[3]; + } + } + row_index++; + } + } + } + + if (num_procs > 1) + { + for (i = 0; i < num_cols_offd; i++) + { + col_map_offd[i] = big_offd_j[i]; + } + + hypre_BigQsort0(col_map_offd, 0, num_cols_offd - 1); + + for (i = 0; i < num_cols_offd; i++) + for (j = 0; j < num_cols_offd; j++) + if (big_offd_j[i] == col_map_offd[j]) + { + offd_j[i] = j; + break; + } + + /*for (i=0; i < offd_i[local_num_rows]; i++) + { + offd_j[i] = hypre_BigBinarySearch(col_map_offd,big_offd_j[i],num_cols_offd); + }*/ + } + + A = hypre_ParCSRMatrixCreate(comm, grid_size, grid_size, + global_part, global_part, num_cols_offd, + diag_i[local_num_rows], + offd_i[local_num_rows]); + + hypre_ParCSRMatrixColMapOffd(A) = col_map_offd; + + diag = hypre_ParCSRMatrixDiag(A); + hypre_CSRMatrixI(diag) = diag_i; + hypre_CSRMatrixJ(diag) = diag_j; + hypre_CSRMatrixData(diag) = diag_data; + + offd = hypre_ParCSRMatrixOffd(A); + hypre_CSRMatrixI(offd) = offd_i; + if (num_cols_offd) + { + hypre_CSRMatrixJ(offd) = offd_j; + hypre_CSRMatrixData(offd) = offd_data; + } + + hypre_CSRMatrixMemoryLocation(diag) = HYPRE_MEMORY_HOST; + hypre_CSRMatrixMemoryLocation(offd) = HYPRE_MEMORY_HOST; + + hypre_ParCSRMatrixMigrate(A, hypre_HandleMemoryLocation(hypre_handle())); + + hypre_TFree(nx_part, HYPRE_MEMORY_HOST); + hypre_TFree(ny_part, HYPRE_MEMORY_HOST); + hypre_TFree(nz_part, HYPRE_MEMORY_HOST); + hypre_TFree(big_offd_j, HYPRE_MEMORY_HOST); + + return (HYPRE_ParCSRMatrix) A; +} + +/*-------------------------------------------------------------------------- + * 7-pt systems laplacian operator + *--------------------------------------------------------------------------*/ + +HYPRE_ParCSRMatrix +GenerateSysLaplacian( MPI_Comm comm, + HYPRE_BigInt nx, + HYPRE_BigInt ny, + HYPRE_BigInt nz, + HYPRE_Int P, + HYPRE_Int Q, + HYPRE_Int R, + HYPRE_Int p, + HYPRE_Int q, + HYPRE_Int r, + HYPRE_Int num_fun, + HYPRE_Real *mtrx, + HYPRE_Real *value ) +{ + hypre_ParCSRMatrix *A; + hypre_CSRMatrix *diag; + hypre_CSRMatrix *offd; + + HYPRE_Int *diag_i; + HYPRE_Int *diag_j; + HYPRE_Real *diag_data; + + HYPRE_Int *offd_i; + HYPRE_Int *offd_j = NULL; + HYPRE_BigInt *big_offd_j = NULL; + HYPRE_Real *offd_data = NULL; + + HYPRE_BigInt global_part[2]; + HYPRE_Int ix, iy, iz; + HYPRE_Int cnt, o_cnt; + HYPRE_Int local_num_rows; + HYPRE_BigInt *col_map_offd; + HYPRE_Int row_index, row, col; + HYPRE_Int index, diag_index; + HYPRE_Int i, j; + + HYPRE_Int nx_local, ny_local, nz_local; + HYPRE_Int num_cols_offd; + HYPRE_BigInt grid_size; + HYPRE_Int local_grid_size; + HYPRE_Int first_j, j_ind; + HYPRE_BigInt big_first_j, big_num_fun = (HYPRE_BigInt)num_fun; + HYPRE_Int num_coeffs, num_offd_coeffs; + + HYPRE_BigInt *nx_part; + HYPRE_BigInt *ny_part; + HYPRE_BigInt *nz_part; + + HYPRE_Int num_procs; + HYPRE_Int P_busy, Q_busy, R_busy; + HYPRE_Real val; + HYPRE_Int gp_size; + + hypre_MPI_Comm_size(comm, &num_procs); + + grid_size = nx * ny * nz; + + hypre_GeneratePartitioning(nx, P, &nx_part); + hypre_GeneratePartitioning(ny, Q, &ny_part); + hypre_GeneratePartitioning(nz, R, &nz_part); + + nx_local = (HYPRE_Int)(nx_part[p + 1] - nx_part[p]); + ny_local = (HYPRE_Int)(ny_part[q + 1] - ny_part[q]); + nz_local = (HYPRE_Int)(nz_part[r + 1] - nz_part[r]); + + local_grid_size = nx_local * ny_local * nz_local; + local_num_rows = num_fun * local_grid_size; + + global_part[0] = nz_part[r] * nx * ny + (ny_part[q] * nx + nx_part[p] * ny_local) * nz_local; + global_part[1] = global_part[0] + (HYPRE_BigInt)local_grid_size; + gp_size = 2; + + diag_i = hypre_CTAlloc(HYPRE_Int, local_num_rows + 1, HYPRE_MEMORY_HOST); + offd_i = hypre_CTAlloc(HYPRE_Int, local_num_rows + 1, HYPRE_MEMORY_HOST); + + P_busy = hypre_min(nx, P); + Q_busy = hypre_min(ny, Q); + R_busy = hypre_min(nz, R); + + num_cols_offd = 0; + if (p) { num_cols_offd += ny_local * nz_local; } + if (p < P_busy - 1) { num_cols_offd += ny_local * nz_local; } + if (q) { num_cols_offd += nx_local * nz_local; } + if (q < Q_busy - 1) { num_cols_offd += nx_local * nz_local; } + if (r) { num_cols_offd += nx_local * ny_local; } + if (r < R_busy - 1) { num_cols_offd += nx_local * ny_local; } + num_cols_offd *= num_fun; + + if (!local_num_rows) { num_cols_offd = 0; } + + col_map_offd = hypre_CTAlloc(HYPRE_BigInt, num_cols_offd, HYPRE_MEMORY_HOST); + + cnt = 1; + diag_i[0] = 0; + offd_i[0] = 0; + for (iz = nz_part[r]; iz < nz_part[r + 1]; iz++) + { + for (iy = ny_part[q]; iy < ny_part[q + 1]; iy++) + { + for (ix = nx_part[p]; ix < nx_part[p + 1]; ix++) + { + diag_i[cnt] = diag_i[cnt - 1]; + offd_i[cnt] = offd_i[cnt - 1]; + diag_i[cnt] += num_fun; + if (iz > nz_part[r]) + { + diag_i[cnt] += num_fun; + } + else + { + if (iz) + { + offd_i[cnt] += num_fun; + } + } + if (iy > ny_part[q]) + { + diag_i[cnt] += num_fun; + } + else + { + if (iy) + { + offd_i[cnt] += num_fun; + } + } + if (ix > nx_part[p]) + { + diag_i[cnt] += num_fun; + } + else + { + if (ix) + { + offd_i[cnt] += num_fun; + } + } + if (ix + 1 < nx_part[p + 1]) + { + diag_i[cnt] += num_fun; + } + else + { + if (ix + 1 < nx) + { + offd_i[cnt] += num_fun; + } + } + if (iy + 1 < ny_part[q + 1]) + { + diag_i[cnt] += num_fun; + } + else + { + if (iy + 1 < ny) + { + offd_i[cnt] += num_fun; + } + } + if (iz + 1 < nz_part[r + 1]) + { + diag_i[cnt] += num_fun; + } + else + { + if (iz + 1 < nz) + { + offd_i[cnt] += num_fun; + } + } + num_coeffs = diag_i[cnt] - diag_i[cnt - 1]; + num_offd_coeffs = offd_i[cnt] - offd_i[cnt - 1]; + cnt++; + for (i = 1; i < num_fun; i++) + { + diag_i[cnt] = diag_i[cnt - 1] + num_coeffs; + offd_i[cnt] = offd_i[cnt - 1] + num_offd_coeffs; + cnt++; + } + } + } + } + + diag_j = hypre_CTAlloc(HYPRE_Int, diag_i[local_num_rows], HYPRE_MEMORY_HOST); + diag_data = hypre_CTAlloc(HYPRE_Real, diag_i[local_num_rows], HYPRE_MEMORY_HOST); + + if (num_procs > 1) + { + offd_j = hypre_CTAlloc(HYPRE_Int, offd_i[local_num_rows], HYPRE_MEMORY_HOST); + big_offd_j = hypre_CTAlloc(HYPRE_BigInt, offd_i[local_num_rows], HYPRE_MEMORY_HOST); + offd_data = hypre_CTAlloc(HYPRE_Real, offd_i[local_num_rows], HYPRE_MEMORY_HOST); + } + + row_index = 0; + for (iz = nz_part[r]; iz < nz_part[r + 1]; iz++) + { + for (iy = ny_part[q]; iy < ny_part[q + 1]; iy++) + { + for (ix = nx_part[p]; ix < nx_part[p + 1]; ix++) + { + cnt = diag_i[row_index];; + o_cnt = offd_i[row_index];; + num_coeffs = diag_i[row_index + 1] - diag_i[row_index]; + num_offd_coeffs = offd_i[row_index + 1] - offd_i[row_index]; + first_j = row_index; + for (i = 0; i < num_fun; i++) + { + for (j = 0; j < num_fun; j++) + { + j_ind = cnt + i * num_coeffs + j; + diag_j[j_ind] = first_j + j; + diag_data[j_ind] = value[0] * mtrx[i * num_fun + j]; + } + } + cnt += num_fun; + if (iz > nz_part[r]) + { + first_j = row_index - nx_local * ny_local * num_fun; + for (i = 0; i < num_fun; i++) + { + for (j = 0; j < num_fun; j++) + { + j_ind = cnt + i * num_coeffs + j; + diag_j[j_ind] = first_j + j; + diag_data[j_ind] = value[3] * mtrx[i * num_fun + j]; + } + } + cnt += num_fun; + } + else + { + if (iz) + { + big_first_j = big_num_fun * map3(ix, iy, iz - 1, p, q, r - 1, nx, ny, + nx_part, ny_part, nz_part); + for (i = 0; i < num_fun; i++) + { + for (j = 0; j < num_fun; j++) + { + j_ind = o_cnt + i * num_offd_coeffs + j; + big_offd_j[j_ind] = big_first_j + (HYPRE_BigInt)j; + offd_data[j_ind] = value[3] * mtrx[i * num_fun + j]; + } + } + o_cnt += num_fun; + } + } + if (iy > ny_part[q]) + { + first_j = row_index - nx_local * num_fun; + for (i = 0; i < num_fun; i++) + { + for (j = 0; j < num_fun; j++) + { + j_ind = cnt + i * num_coeffs + j; + diag_j[j_ind] = first_j + j; + diag_data[j_ind] = value[2] * mtrx[i * num_fun + j]; + } + } + cnt += num_fun; + } + else + { + if (iy) + { + big_first_j = big_num_fun * map3(ix, iy - 1, iz, p, q - 1, r, nx, ny, + nx_part, ny_part, nz_part); + for (i = 0; i < num_fun; i++) + { + for (j = 0; j < num_fun; j++) + { + j_ind = o_cnt + i * num_offd_coeffs + j; + big_offd_j[j_ind] = big_first_j + (HYPRE_BigInt)j; + offd_data[j_ind] = value[2] * mtrx[i * num_fun + j]; + } + } + o_cnt += num_fun; + } + } + if (ix > nx_part[p]) + { + first_j = row_index - num_fun; + for (i = 0; i < num_fun; i++) + { + for (j = 0; j < num_fun; j++) + { + j_ind = cnt + i * num_coeffs + j; + diag_j[j_ind] = first_j + j; + diag_data[j_ind] = value[1] * mtrx[i * num_fun + j]; + } + } + cnt += num_fun; + } + else + { + if (ix) + { + big_first_j = big_num_fun * map3(ix - 1, iy, iz, p - 1, q, r, nx, ny, + nx_part, ny_part, nz_part); + for (i = 0; i < num_fun; i++) + { + for (j = 0; j < num_fun; j++) + { + j_ind = o_cnt + i * num_offd_coeffs + j; + big_offd_j[j_ind] = big_first_j + (HYPRE_BigInt)j; + offd_data[j_ind] = value[1] * mtrx[i * num_fun + j]; + } + } + o_cnt += num_fun; + } + } + if (ix + 1 < nx_part[p + 1]) + { + first_j = row_index + num_fun; + for (i = 0; i < num_fun; i++) + { + for (j = 0; j < num_fun; j++) + { + j_ind = cnt + i * num_coeffs + j; + diag_j[j_ind] = first_j + j; + diag_data[j_ind] = value[1] * mtrx[i * num_fun + j]; + } + } + cnt += num_fun; + } + else + { + if (ix + 1 < nx) + { + big_first_j = big_num_fun * map3(ix + 1, iy, iz, p + 1, q, r, nx, ny, + nx_part, ny_part, nz_part); + for (i = 0; i < num_fun; i++) + { + for (j = 0; j < num_fun; j++) + { + j_ind = o_cnt + i * num_offd_coeffs + j; + big_offd_j[j_ind] = big_first_j + (HYPRE_BigInt)j; + offd_data[j_ind] = value[1] * mtrx[i * num_fun + j]; + } + } + o_cnt += num_fun; + } + } + if (iy + 1 < ny_part[q + 1]) + { + first_j = row_index + nx_local * num_fun; + for (i = 0; i < num_fun; i++) + { + for (j = 0; j < num_fun; j++) + { + j_ind = cnt + i * num_coeffs + j; + diag_j[j_ind] = first_j + j; + diag_data[j_ind] = value[2] * mtrx[i * num_fun + j]; + } + } + cnt += num_fun; + } + else + { + if (iy + 1 < ny) + { + big_first_j = big_num_fun * map3(ix, iy + 1, iz, p, q + 1, r, nx, ny, + nx_part, ny_part, nz_part); + for (i = 0; i < num_fun; i++) + { + for (j = 0; j < num_fun; j++) + { + j_ind = o_cnt + i * num_offd_coeffs + j; + big_offd_j[j_ind] = big_first_j + (HYPRE_BigInt)j; + offd_data[j_ind] = value[2] * mtrx[i * num_fun + j]; + } + } + o_cnt += num_fun; + } + } + if (iz + 1 < nz_part[r + 1]) + { + first_j = row_index + nx_local * ny_local * num_fun; + for (i = 0; i < num_fun; i++) + { + for (j = 0; j < num_fun; j++) + { + j_ind = cnt + i * num_coeffs + j; + diag_j[j_ind] = first_j + j; + diag_data[j_ind] = value[3] * mtrx[i * num_fun + j]; + } + } + cnt += num_fun; + } + else + { + if (iz + 1 < nz) + { + big_first_j = big_num_fun * map3(ix, iy, iz + 1, p, q, r + 1, nx, ny, + nx_part, ny_part, nz_part); + for (i = 0; i < num_fun; i++) + { + for (j = 0; j < num_fun; j++) + { + j_ind = o_cnt + i * num_offd_coeffs + j; + big_offd_j[j_ind] = big_first_j + (HYPRE_BigInt)j; + offd_data[j_ind] = value[3] * mtrx[i * num_fun + j]; + } + } + o_cnt += num_fun; + } + } + row_index += num_fun; + } + } + } + + if (num_procs > 1) + { + cnt = 0; + for (i = 0; i < local_num_rows; i += num_fun) + { + for (j = offd_i[i]; j < offd_i[i + 1]; j++) + { + col_map_offd[cnt++] = big_offd_j[j]; + } + } + + hypre_BigQsort0(col_map_offd, 0, num_cols_offd - 1); + + for (i = 0; i < num_fun * num_cols_offd; i++) + for (j = hypre_min(0, hypre_abs(i - num_fun)); j < num_cols_offd; j++) + if (big_offd_j[i] == col_map_offd[j]) + { + offd_j[i] = j; + break; + } + } + + for (i = 0; i < gp_size; i++) + { + global_part[i] *= big_num_fun; + } + + for (j = 1; j < num_fun; j++) + { + for (i = 0; i < local_grid_size; i++) + { + row = i * num_fun + j; + diag_index = diag_i[row]; + index = diag_index + j; + val = diag_data[diag_index]; + col = diag_j[diag_index]; + diag_data[diag_index] = diag_data[index]; + diag_j[diag_index] = diag_j[index]; + diag_data[index] = val; + diag_j[index] = col; + } + } + + A = hypre_ParCSRMatrixCreate(comm, big_num_fun * grid_size, big_num_fun * grid_size, + global_part, global_part, num_cols_offd, + diag_i[local_num_rows], + offd_i[local_num_rows]); + + hypre_ParCSRMatrixColMapOffd(A) = col_map_offd; + + diag = hypre_ParCSRMatrixDiag(A); + hypre_CSRMatrixI(diag) = diag_i; + hypre_CSRMatrixJ(diag) = diag_j; + hypre_CSRMatrixData(diag) = diag_data; + + offd = hypre_ParCSRMatrixOffd(A); + hypre_CSRMatrixI(offd) = offd_i; + if (num_cols_offd) + { + hypre_CSRMatrixJ(offd) = offd_j; + hypre_CSRMatrixData(offd) = offd_data; + } + + hypre_CSRMatrixMemoryLocation(diag) = HYPRE_MEMORY_HOST; + hypre_CSRMatrixMemoryLocation(offd) = HYPRE_MEMORY_HOST; + + hypre_ParCSRMatrixMigrate(A, hypre_HandleMemoryLocation(hypre_handle())); + + hypre_TFree(nx_part, HYPRE_MEMORY_HOST); + hypre_TFree(ny_part, HYPRE_MEMORY_HOST); + hypre_TFree(nz_part, HYPRE_MEMORY_HOST); + hypre_TFree(big_offd_j, HYPRE_MEMORY_HOST); + + return (HYPRE_ParCSRMatrix) A; +} + +/*-------------------------------------------------------------------------- + * Systems laplacian with varying diffusion coefficients in each block + *--------------------------------------------------------------------------*/ + +HYPRE_ParCSRMatrix +GenerateSysLaplacianVCoef( MPI_Comm comm, + HYPRE_BigInt nx, + HYPRE_BigInt ny, + HYPRE_BigInt nz, + HYPRE_Int P, + HYPRE_Int Q, + HYPRE_Int R, + HYPRE_Int p, + HYPRE_Int q, + HYPRE_Int r, + HYPRE_Int num_fun, + HYPRE_Real *mtrx, + HYPRE_Real *value ) +{ + hypre_ParCSRMatrix *A; + hypre_CSRMatrix *diag; + hypre_CSRMatrix *offd; + + HYPRE_Int *diag_i; + HYPRE_Int *diag_j; + HYPRE_Real *diag_data; + + HYPRE_Int *offd_i; + HYPRE_Int *offd_j = NULL; + HYPRE_BigInt *big_offd_j = NULL; + HYPRE_Real *offd_data = NULL; + + HYPRE_BigInt global_part[2]; + HYPRE_BigInt ix, iy, iz; + HYPRE_Int cnt, o_cnt; + HYPRE_Int local_num_rows; + HYPRE_BigInt *col_map_offd; + HYPRE_Int row_index, row, col; + HYPRE_Int index, diag_index; + HYPRE_Int i, j; + HYPRE_Int gp_size; + + HYPRE_Int nx_local, ny_local, nz_local; + HYPRE_Int num_cols_offd; + HYPRE_BigInt grid_size; + HYPRE_Int local_grid_size; + HYPRE_Int first_j, j_ind; + HYPRE_BigInt big_first_j, big_num_fun = (HYPRE_BigInt) num_fun; + HYPRE_Int num_coeffs, num_offd_coeffs; + + HYPRE_BigInt *nx_part; + HYPRE_BigInt *ny_part; + HYPRE_BigInt *nz_part; + + HYPRE_Int num_procs, P_busy, Q_busy, R_busy; + HYPRE_Real val; + + /* for indexing in values */ + HYPRE_Int sz = num_fun * num_fun; + + hypre_MPI_Comm_size(comm, &num_procs); + + grid_size = nx * ny * nz; + + hypre_GeneratePartitioning(nx, P, &nx_part); + hypre_GeneratePartitioning(ny, Q, &ny_part); + hypre_GeneratePartitioning(nz, R, &nz_part); + + nx_local = (HYPRE_Int)(nx_part[p + 1] - nx_part[p]); + ny_local = (HYPRE_Int)(ny_part[q + 1] - ny_part[q]); + nz_local = (HYPRE_Int)(nz_part[r + 1] - nz_part[r]); + + local_grid_size = nx_local * ny_local * nz_local; + global_part[0] = nz_part[r] * nx * ny + (ny_part[q] * nx + nx_part[p] * ny_local) * nz_local; + global_part[1] = global_part[0] + (HYPRE_BigInt)local_grid_size; + gp_size = 2; + + local_num_rows = num_fun * local_grid_size; + diag_i = hypre_CTAlloc(HYPRE_Int, local_num_rows + 1, HYPRE_MEMORY_HOST); + offd_i = hypre_CTAlloc(HYPRE_Int, local_num_rows + 1, HYPRE_MEMORY_HOST); + + P_busy = hypre_min(nx, P); + Q_busy = hypre_min(ny, Q); + R_busy = hypre_min(nz, R); + + num_cols_offd = 0; + if (p) { num_cols_offd += ny_local * nz_local; } + if (p < P_busy - 1) { num_cols_offd += ny_local * nz_local; } + if (q) { num_cols_offd += nx_local * nz_local; } + if (q < Q_busy - 1) { num_cols_offd += nx_local * nz_local; } + if (r) { num_cols_offd += nx_local * ny_local; } + if (r < R_busy - 1) { num_cols_offd += nx_local * ny_local; } + num_cols_offd *= num_fun; + + if (!local_num_rows) { num_cols_offd = 0; } + + col_map_offd = hypre_CTAlloc(HYPRE_BigInt, num_cols_offd, HYPRE_MEMORY_HOST); + + cnt = 1; + diag_i[0] = 0; + offd_i[0] = 0; + for (iz = nz_part[r]; iz < nz_part[r + 1]; iz++) + { + for (iy = ny_part[q]; iy < ny_part[q + 1]; iy++) + { + for (ix = nx_part[p]; ix < nx_part[p + 1]; ix++) + { + diag_i[cnt] = diag_i[cnt - 1]; + offd_i[cnt] = offd_i[cnt - 1]; + diag_i[cnt] += num_fun; + if (iz > nz_part[r]) + { + diag_i[cnt] += num_fun; + } + else + { + if (iz) + { + offd_i[cnt] += num_fun; + } + } + if (iy > ny_part[q]) + { + diag_i[cnt] += num_fun; + } + else + { + if (iy) + { + offd_i[cnt] += num_fun; + } + } + if (ix > nx_part[p]) + { + diag_i[cnt] += num_fun; + } + else + { + if (ix) + { + offd_i[cnt] += num_fun; + } + } + if (ix + 1 < nx_part[p + 1]) + { + diag_i[cnt] += num_fun; + } + else + { + if (ix + 1 < nx) + { + offd_i[cnt] += num_fun; + } + } + if (iy + 1 < ny_part[q + 1]) + { + diag_i[cnt] += num_fun; + } + else + { + if (iy + 1 < ny) + { + offd_i[cnt] += num_fun; + } + } + if (iz + 1 < nz_part[r + 1]) + { + diag_i[cnt] += num_fun; + } + else + { + if (iz + 1 < nz) + { + offd_i[cnt] += num_fun; + } + } + num_coeffs = diag_i[cnt] - diag_i[cnt - 1]; + num_offd_coeffs = offd_i[cnt] - offd_i[cnt - 1]; + cnt++; + for (i = 1; i < num_fun; i++) + { + diag_i[cnt] = diag_i[cnt - 1] + num_coeffs; + offd_i[cnt] = offd_i[cnt - 1] + num_offd_coeffs; + cnt++; + } + } + } + } + + diag_j = hypre_CTAlloc(HYPRE_Int, diag_i[local_num_rows], HYPRE_MEMORY_HOST); + diag_data = hypre_CTAlloc(HYPRE_Real, diag_i[local_num_rows], HYPRE_MEMORY_HOST); + + if (num_procs > 1) + { + offd_j = hypre_CTAlloc(HYPRE_Int, offd_i[local_num_rows], HYPRE_MEMORY_HOST); + big_offd_j = hypre_CTAlloc(HYPRE_BigInt, offd_i[local_num_rows], HYPRE_MEMORY_HOST); + offd_data = hypre_CTAlloc(HYPRE_Real, offd_i[local_num_rows], HYPRE_MEMORY_HOST); + } + + row_index = 0; + for (iz = nz_part[r]; iz < nz_part[r + 1]; iz++) + { + for (iy = ny_part[q]; iy < ny_part[q + 1]; iy++) + { + for (ix = nx_part[p]; ix < nx_part[p + 1]; ix++) + { + cnt = diag_i[row_index];; + o_cnt = offd_i[row_index];; + num_coeffs = diag_i[row_index + 1] - diag_i[row_index]; + num_offd_coeffs = offd_i[row_index + 1] - offd_i[row_index]; + first_j = row_index; + for (i = 0; i < num_fun; i++) + { + for (j = 0; j < num_fun; j++) + { + j_ind = cnt + i * num_coeffs + j; + diag_j[j_ind] = first_j + j; + diag_data[j_ind] = value[0 * sz + i * num_fun + j] * mtrx[i * num_fun + j]; + } + } + cnt += num_fun; + if (iz > nz_part[r]) + { + first_j = row_index - nx_local * ny_local * num_fun; + for (i = 0; i < num_fun; i++) + { + for (j = 0; j < num_fun; j++) + { + j_ind = cnt + i * num_coeffs + j; + diag_j[j_ind] = first_j + j; + diag_data[j_ind] = value[3 * sz + i * num_fun + j] * mtrx[i * num_fun + j]; + } + } + cnt += num_fun; + } + else + { + if (iz) + { + big_first_j = big_num_fun * map3(ix, iy, iz - 1, p, q, r - 1, nx, ny, + nx_part, ny_part, nz_part); + for (i = 0; i < num_fun; i++) + { + for (j = 0; j < num_fun; j++) + { + j_ind = o_cnt + i * num_offd_coeffs + j; + big_offd_j[j_ind] = big_first_j + (HYPRE_BigInt)j; + offd_data[j_ind] = value[3 * sz + i * num_fun + j] * mtrx[i * num_fun + j]; + } + } + o_cnt += num_fun; + } + } + if (iy > ny_part[q]) + { + first_j = row_index - nx_local * num_fun; + for (i = 0; i < num_fun; i++) + { + for (j = 0; j < num_fun; j++) + { + j_ind = cnt + i * num_coeffs + j; + diag_j[j_ind] = first_j + j; + diag_data[j_ind] = value[2 * sz + i * num_fun + j] * mtrx[i * num_fun + j]; + } + } + cnt += num_fun; + } + else + { + if (iy) + { + big_first_j = big_num_fun * map3(ix, iy - 1, iz, p, q - 1, r, nx, ny, + nx_part, ny_part, nz_part); + for (i = 0; i < num_fun; i++) + { + for (j = 0; j < num_fun; j++) + { + j_ind = o_cnt + i * num_offd_coeffs + j; + big_offd_j[j_ind] = big_first_j + (HYPRE_BigInt)j; + offd_data[j_ind] = value[2 * sz + i * num_fun + j] * mtrx[i * num_fun + j]; + } + } + o_cnt += num_fun; + } + } + if (ix > nx_part[p]) + { + first_j = row_index - num_fun; + for (i = 0; i < num_fun; i++) + { + for (j = 0; j < num_fun; j++) + { + j_ind = cnt + i * num_coeffs + j; + diag_j[j_ind] = first_j + j; + diag_data[j_ind] = value[1 * sz + i * num_fun + j] * mtrx[i * num_fun + j]; + } + } + cnt += num_fun; + } + else + { + if (ix) + { + big_first_j = big_num_fun * map3(ix - 1, iy, iz, p - 1, q, r, nx, ny, + nx_part, ny_part, nz_part); + for (i = 0; i < num_fun; i++) + { + for (j = 0; j < num_fun; j++) + { + j_ind = o_cnt + i * num_offd_coeffs + j; + big_offd_j[j_ind] = big_first_j + (HYPRE_BigInt)j; + offd_data[j_ind] = value[1 * sz + i * num_fun + j] * mtrx[i * num_fun + j]; + } + } + o_cnt += num_fun; + } + } + if (ix + 1 < nx_part[p + 1]) + { + first_j = row_index + num_fun; + for (i = 0; i < num_fun; i++) + { + for (j = 0; j < num_fun; j++) + { + j_ind = cnt + i * num_coeffs + j; + diag_j[j_ind] = first_j + j; + diag_data[j_ind] = value[1 * sz + i * num_fun + j] * mtrx[i * num_fun + j]; + } + } + cnt += num_fun; + } + else + { + if (ix + 1 < nx) + { + big_first_j = big_num_fun * map3(ix + 1, iy, iz, p + 1, q, r, nx, ny, + nx_part, ny_part, nz_part); + for (i = 0; i < num_fun; i++) + { + for (j = 0; j < num_fun; j++) + { + j_ind = o_cnt + i * num_offd_coeffs + j; + big_offd_j[j_ind] = big_first_j + (HYPRE_BigInt)j; + offd_data[j_ind] = value[1 * sz + i * num_fun + j] * mtrx[i * num_fun + j]; + } + } + o_cnt += num_fun; + } + } + if (iy + 1 < ny_part[q + 1]) + { + first_j = row_index + nx_local * num_fun; + for (i = 0; i < num_fun; i++) + { + for (j = 0; j < num_fun; j++) + { + j_ind = cnt + i * num_coeffs + j; + diag_j[j_ind] = first_j + j; + diag_data[j_ind] = value[2 * sz + i * num_fun + j] * mtrx[i * num_fun + j]; + } + } + cnt += num_fun; + } + else + { + if (iy + 1 < ny) + { + big_first_j = big_num_fun * map3(ix, iy + 1, iz, p, q + 1, r, nx, ny, + nx_part, ny_part, nz_part); + for (i = 0; i < num_fun; i++) + { + for (j = 0; j < num_fun; j++) + { + j_ind = o_cnt + i * num_offd_coeffs + j; + big_offd_j[j_ind] = big_first_j + (HYPRE_BigInt)j; + offd_data[j_ind] = value[2 * sz + i * num_fun + j] * mtrx[i * num_fun + j]; + } + } + o_cnt += num_fun; + } + } + if (iz + 1 < nz_part[r + 1]) + { + first_j = row_index + nx_local * ny_local * num_fun; + for (i = 0; i < num_fun; i++) + { + for (j = 0; j < num_fun; j++) + { + j_ind = cnt + i * num_coeffs + j; + diag_j[j_ind] = first_j + j; + diag_data[j_ind] = value[3 * sz + i * num_fun + j] * mtrx[i * num_fun + j]; + } + } + cnt += num_fun; + } + else + { + if (iz + 1 < nz) + { + big_first_j = big_num_fun * map3(ix, iy, iz + 1, p, q, r + 1, nx, ny, + nx_part, ny_part, nz_part); + for (i = 0; i < num_fun; i++) + { + for (j = 0; j < num_fun; j++) + { + j_ind = o_cnt + i * num_offd_coeffs + j; + big_offd_j[j_ind] = big_first_j + (HYPRE_BigInt)j; + offd_data[j_ind] = value[3 * sz + i * num_fun + j] * mtrx[i * num_fun + j]; + } + } + o_cnt += num_fun; + } + } + row_index += num_fun; + } + } + } + + if (num_procs > 1) + { + cnt = 0; + for (i = 0; i < local_num_rows; i += num_fun) + { + for (j = offd_i[i]; j < offd_i[i + 1]; j++) + { + col_map_offd[cnt++] = big_offd_j[j]; + } + } + + hypre_BigQsort0(col_map_offd, 0, num_cols_offd - 1); + + for (i = 0; i < num_fun * num_cols_offd; i++) + for (j = hypre_min(0, hypre_abs(i - num_fun)); j < num_cols_offd; j++) + if (big_offd_j[i] == col_map_offd[j]) + { + offd_j[i] = j; + break; + } + } + + for (i = 0; i < gp_size; i++) + { + global_part[i] *= num_fun; + } + + for (j = 1; j < num_fun; j++) + { + for (i = 0; i < local_grid_size; i++) + { + row = i * num_fun + j; + diag_index = diag_i[row]; + index = diag_index + j; + val = diag_data[diag_index]; + col = diag_j[diag_index]; + diag_data[diag_index] = diag_data[index]; + diag_j[diag_index] = diag_j[index]; + diag_data[index] = val; + diag_j[index] = col; + } + } + + A = hypre_ParCSRMatrixCreate(comm, num_fun * grid_size, num_fun * grid_size, + global_part, global_part, num_cols_offd, + diag_i[local_num_rows], + offd_i[local_num_rows]); + + hypre_ParCSRMatrixColMapOffd(A) = col_map_offd; + + diag = hypre_ParCSRMatrixDiag(A); + hypre_CSRMatrixI(diag) = diag_i; + hypre_CSRMatrixJ(diag) = diag_j; + hypre_CSRMatrixData(diag) = diag_data; + + offd = hypre_ParCSRMatrixOffd(A); + hypre_CSRMatrixI(offd) = offd_i; + if (num_cols_offd) + { + hypre_CSRMatrixJ(offd) = offd_j; + hypre_CSRMatrixData(offd) = offd_data; + } + + hypre_CSRMatrixMemoryLocation(diag) = HYPRE_MEMORY_HOST; + hypre_CSRMatrixMemoryLocation(offd) = HYPRE_MEMORY_HOST; + + hypre_ParCSRMatrixMigrate(A, hypre_HandleMemoryLocation(hypre_handle())); + + hypre_TFree(nx_part, HYPRE_MEMORY_HOST); + hypre_TFree(ny_part, HYPRE_MEMORY_HOST); + hypre_TFree(nz_part, HYPRE_MEMORY_HOST); + hypre_TFree(big_offd_j, HYPRE_MEMORY_HOST); + + return (HYPRE_ParCSRMatrix) A; +} + +/*-------------------------------------------------------------------------- + * 9-pt Laplacian operator + *--------------------------------------------------------------------------*/ + +HYPRE_ParCSRMatrix +GenerateLaplacian9pt( MPI_Comm comm, + HYPRE_BigInt nx, + HYPRE_BigInt ny, + HYPRE_Int P, + HYPRE_Int Q, + HYPRE_Int p, + HYPRE_Int q, + HYPRE_Real *value ) +{ + hypre_ParCSRMatrix *A; + hypre_CSRMatrix *diag; + hypre_CSRMatrix *offd; + + HYPRE_Int *diag_i; + HYPRE_Int *diag_j; + HYPRE_Real *diag_data; + + HYPRE_Int *offd_i; + HYPRE_Int *offd_j = NULL; + HYPRE_Real *offd_data = NULL; + + HYPRE_BigInt global_part[2]; + HYPRE_BigInt ix, iy; + HYPRE_Int cnt, o_cnt; + HYPRE_Int local_num_rows; + HYPRE_BigInt *col_map_offd; + HYPRE_BigInt *big_offd_j = NULL; + HYPRE_Int row_index; + HYPRE_Int i; + + HYPRE_Int nx_local, ny_local; + HYPRE_Int num_cols_offd; + HYPRE_BigInt grid_size; + + HYPRE_BigInt *nx_part; + HYPRE_BigInt *ny_part; + + HYPRE_Int num_procs; + HYPRE_Int P_busy, Q_busy; + + hypre_MPI_Comm_size(comm, &num_procs); + + grid_size = nx * ny; + + hypre_GeneratePartitioning(nx, P, &nx_part); + hypre_GeneratePartitioning(ny, Q, &ny_part); + + nx_local = (HYPRE_Int)(nx_part[p + 1] - nx_part[p]); + ny_local = (HYPRE_Int)(ny_part[q + 1] - ny_part[q]); + + local_num_rows = nx_local * ny_local; + + global_part[0] = ny_part[q] * nx + nx_part[p] * ny_local; + global_part[1] = global_part[0] + (HYPRE_BigInt)local_num_rows; + + diag_i = hypre_CTAlloc(HYPRE_Int, local_num_rows + 1, HYPRE_MEMORY_HOST); + offd_i = hypre_CTAlloc(HYPRE_Int, local_num_rows + 1, HYPRE_MEMORY_HOST); + + P_busy = hypre_min(nx, P); + Q_busy = hypre_min(ny, Q); + + num_cols_offd = 0; + if (p) { num_cols_offd += ny_local; } + if (p < P_busy - 1) { num_cols_offd += ny_local; } + if (q) { num_cols_offd += nx_local; } + if (q < Q_busy - 1) { num_cols_offd += nx_local; } + if (p && q) { num_cols_offd++; } + if (p && q < Q_busy - 1 ) { num_cols_offd++; } + if (p < P_busy - 1 && q ) { num_cols_offd++; } + if (p < P_busy - 1 && q < Q_busy - 1 ) { num_cols_offd++; } + + if (!local_num_rows) { num_cols_offd = 0; } + + col_map_offd = hypre_CTAlloc(HYPRE_BigInt, num_cols_offd, HYPRE_MEMORY_HOST); + + cnt = 0; + o_cnt = 0; + diag_i[0] = 0; + offd_i[0] = 0; + for (iy = ny_part[q]; iy < ny_part[q + 1]; iy++) + { + for (ix = nx_part[p]; ix < nx_part[p + 1]; ix++) + { + cnt++; + o_cnt++; + diag_i[cnt] = diag_i[cnt - 1]; + offd_i[o_cnt] = offd_i[o_cnt - 1]; + diag_i[cnt]++; + if (iy > ny_part[q]) + { + diag_i[cnt]++; + if (ix > nx_part[p]) + { + diag_i[cnt]++; + } + else + { + if (ix) + { + offd_i[o_cnt]++; + } + } + if (ix < nx_part[p + 1] - 1) + { + diag_i[cnt]++; + } + else + { + if (ix + 1 < nx) + { + offd_i[o_cnt]++; + } + } + } + else + { + if (iy) + { + offd_i[o_cnt]++; + if (ix > nx_part[p]) + { + offd_i[o_cnt]++; + } + else if (ix) + { + offd_i[o_cnt]++; + } + if (ix < nx_part[p + 1] - 1) + { + offd_i[o_cnt]++; + } + else if (ix < nx - 1) + { + offd_i[o_cnt]++; + } + } + } + if (ix > nx_part[p]) + { + diag_i[cnt]++; + } + else + { + if (ix) + { + offd_i[o_cnt]++; + } + } + if (ix + 1 < nx_part[p + 1]) + { + diag_i[cnt]++; + } + else + { + if (ix + 1 < nx) + { + offd_i[o_cnt]++; + } + } + if (iy + 1 < ny_part[q + 1]) + { + diag_i[cnt]++; + if (ix > nx_part[p]) + { + diag_i[cnt]++; + } + else + { + if (ix) + { + offd_i[o_cnt]++; + } + } + if (ix < nx_part[p + 1] - 1) + { + diag_i[cnt]++; + } + else + { + if (ix + 1 < nx) + { + offd_i[o_cnt]++; + } + } + } + else + { + if (iy + 1 < ny) + { + offd_i[o_cnt]++; + if (ix > nx_part[p]) + { + offd_i[o_cnt]++; + } + else if (ix) + { + offd_i[o_cnt]++; + } + if (ix < nx_part[p + 1] - 1) + { + offd_i[o_cnt]++; + } + else if (ix < nx - 1) + { + offd_i[o_cnt]++; + } + } + } + } + } + + diag_j = hypre_CTAlloc(HYPRE_Int, diag_i[local_num_rows], HYPRE_MEMORY_HOST); + diag_data = hypre_CTAlloc(HYPRE_Real, diag_i[local_num_rows], HYPRE_MEMORY_HOST); + + if (num_procs > 1) + { + offd_j = hypre_CTAlloc(HYPRE_Int, offd_i[local_num_rows], HYPRE_MEMORY_HOST); + offd_data = hypre_CTAlloc(HYPRE_Real, offd_i[local_num_rows], HYPRE_MEMORY_HOST); + big_offd_j = hypre_CTAlloc(HYPRE_BigInt, offd_i[local_num_rows], HYPRE_MEMORY_HOST); + } + + row_index = 0; + cnt = 0; + o_cnt = 0; + for (iy = ny_part[q]; iy < ny_part[q + 1]; iy++) + { + for (ix = nx_part[p]; ix < nx_part[p + 1]; ix++) + { + diag_j[cnt] = row_index; + diag_data[cnt++] = value[0]; + if (iy > ny_part[q]) + { + if (ix > nx_part[p]) + { + diag_j[cnt] = row_index - nx_local - 1 ; + diag_data[cnt++] = value[1]; + } + else + { + if (ix) + { + big_offd_j[o_cnt] = map2(ix - 1, iy - 1, p - 1, q, nx, + nx_part, ny_part); + offd_data[o_cnt++] = value[1]; + } + } + diag_j[cnt] = row_index - nx_local; + diag_data[cnt++] = value[1]; + if (ix < nx_part[p + 1] - 1) + { + diag_j[cnt] = row_index - nx_local + 1 ; + diag_data[cnt++] = value[1]; + } + else + { + if (ix + 1 < nx) + { + big_offd_j[o_cnt] = map2(ix + 1, iy - 1, p + 1, q, nx, + nx_part, ny_part); + offd_data[o_cnt++] = value[1]; + } + } + } + else + { + if (iy) + { + if (ix > nx_part[p]) + { + big_offd_j[o_cnt] = map2(ix - 1, iy - 1, p, q - 1, nx, + nx_part, ny_part); + offd_data[o_cnt++] = value[1]; + } + else if (ix) + { + big_offd_j[o_cnt] = map2(ix - 1, iy - 1, p - 1, q - 1, nx, + nx_part, ny_part); + offd_data[o_cnt++] = value[1]; + } + big_offd_j[o_cnt] = map2(ix, iy - 1, p, q - 1, nx, + nx_part, ny_part); + offd_data[o_cnt++] = value[1]; + if (ix < nx_part[p + 1] - 1) + { + big_offd_j[o_cnt] = map2(ix + 1, iy - 1, p, q - 1, nx, + nx_part, ny_part); + offd_data[o_cnt++] = value[1]; + } + else if (ix + 1 < nx) + { + big_offd_j[o_cnt] = map2(ix + 1, iy - 1, p + 1, q - 1, nx, + nx_part, ny_part); + offd_data[o_cnt++] = value[1]; + } + } + } + if (ix > nx_part[p]) + { + diag_j[cnt] = row_index - 1; + diag_data[cnt++] = value[1]; + } + else + { + if (ix) + { + big_offd_j[o_cnt] = map2(ix - 1, iy, p - 1, q, nx, + nx_part, ny_part); + offd_data[o_cnt++] = value[1]; + } + } + if (ix + 1 < nx_part[p + 1]) + { + diag_j[cnt] = row_index + 1; + diag_data[cnt++] = value[1]; + } + else + { + if (ix + 1 < nx) + { + big_offd_j[o_cnt] = map2(ix + 1, iy, p + 1, q, nx, + nx_part, ny_part); + offd_data[o_cnt++] = value[1]; + } + } + if (iy + 1 < ny_part[q + 1]) + { + if (ix > nx_part[p]) + { + diag_j[cnt] = row_index + nx_local - 1 ; + diag_data[cnt++] = value[1]; + } + else + { + if (ix) + { + big_offd_j[o_cnt] = map2(ix - 1, iy + 1, p - 1, q, nx, + nx_part, ny_part); + offd_data[o_cnt++] = value[1]; + } + } + diag_j[cnt] = row_index + nx_local; + diag_data[cnt++] = value[1]; + if (ix < nx_part[p + 1] - 1) + { + diag_j[cnt] = row_index + nx_local + 1 ; + diag_data[cnt++] = value[1]; + } + else + { + if (ix + 1 < nx) + { + big_offd_j[o_cnt] = map2(ix + 1, iy + 1, p + 1, q, nx, + nx_part, ny_part); + offd_data[o_cnt++] = value[1]; + } + } + } + else + { + if (iy + 1 < ny) + { + if (ix > nx_part[p]) + { + big_offd_j[o_cnt] = map2(ix - 1, iy + 1, p, q + 1, nx, + nx_part, ny_part); + offd_data[o_cnt++] = value[1]; + } + else if (ix) + { + big_offd_j[o_cnt] = map2(ix - 1, iy + 1, p - 1, q + 1, nx, + nx_part, ny_part); + offd_data[o_cnt++] = value[1]; + } + big_offd_j[o_cnt] = map2(ix, iy + 1, p, q + 1, nx, + nx_part, ny_part); + offd_data[o_cnt++] = value[1]; + if (ix < nx_part[p + 1] - 1) + { + big_offd_j[o_cnt] = map2(ix + 1, iy + 1, p, q + 1, nx, + nx_part, ny_part); + offd_data[o_cnt++] = value[1]; + } + else if (ix < nx - 1) + { + big_offd_j[o_cnt] = map2(ix + 1, iy + 1, p + 1, q + 1, nx, + nx_part, ny_part); + offd_data[o_cnt++] = value[1]; + } + } + } + row_index++; + } + } + + if (num_procs > 1) + { + HYPRE_BigInt *tmp = hypre_CTAlloc(HYPRE_BigInt, o_cnt, HYPRE_MEMORY_HOST); + + for (i = 0; i < o_cnt; i++) + { + tmp[i] = big_offd_j[i]; + } + + hypre_BigQsort0(tmp, 0, o_cnt - 1); + + col_map_offd[0] = tmp[0]; + cnt = 0; + for (i = 0; i < o_cnt; i++) + { + if (tmp[i] > col_map_offd[cnt]) + { + cnt++; + col_map_offd[cnt] = tmp[i]; + } + } + + for (i = 0; i < o_cnt; i++) + { + offd_j[i] = hypre_BigBinarySearch(col_map_offd, big_offd_j[i], num_cols_offd); + } + + hypre_TFree(big_offd_j, HYPRE_MEMORY_HOST); + hypre_TFree(tmp, HYPRE_MEMORY_HOST); + } + + A = hypre_ParCSRMatrixCreate(comm, grid_size, grid_size, + global_part, global_part, num_cols_offd, + diag_i[local_num_rows], + offd_i[local_num_rows]); + + hypre_ParCSRMatrixColMapOffd(A) = col_map_offd; + + diag = hypre_ParCSRMatrixDiag(A); + hypre_CSRMatrixI(diag) = diag_i; + hypre_CSRMatrixJ(diag) = diag_j; + hypre_CSRMatrixData(diag) = diag_data; + + offd = hypre_ParCSRMatrixOffd(A); + hypre_CSRMatrixI(offd) = offd_i; + if (num_cols_offd) + { + hypre_CSRMatrixJ(offd) = offd_j; + hypre_CSRMatrixData(offd) = offd_data; + } + + hypre_CSRMatrixMemoryLocation(diag) = HYPRE_MEMORY_HOST; + hypre_CSRMatrixMemoryLocation(offd) = HYPRE_MEMORY_HOST; + + hypre_ParCSRMatrixMigrate(A, hypre_HandleMemoryLocation(hypre_handle())); + + hypre_TFree(nx_part, HYPRE_MEMORY_HOST); + hypre_TFree(ny_part, HYPRE_MEMORY_HOST); + + return (HYPRE_ParCSRMatrix) A; +} + +/*-------------------------------------------------------------------------- + * 27-pt laplacian operator + *--------------------------------------------------------------------------*/ + +HYPRE_ParCSRMatrix +GenerateLaplacian27pt(MPI_Comm comm, + HYPRE_BigInt nx, + HYPRE_BigInt ny, + HYPRE_BigInt nz, + HYPRE_Int P, + HYPRE_Int Q, + HYPRE_Int R, + HYPRE_Int p, + HYPRE_Int q, + HYPRE_Int r, + HYPRE_Real *value ) +{ + hypre_ParCSRMatrix *A; + hypre_CSRMatrix *diag; + hypre_CSRMatrix *offd; + + HYPRE_Int *diag_i; + HYPRE_Int *diag_j; + HYPRE_Real *diag_data; + + HYPRE_Int *offd_i; + HYPRE_Int *offd_j = NULL; + HYPRE_BigInt *big_offd_j = NULL; + HYPRE_Real *offd_data = NULL; + + HYPRE_BigInt global_part[2]; + HYPRE_BigInt ix, iy, iz; + HYPRE_Int cnt, o_cnt; + HYPRE_Int local_num_rows; + HYPRE_BigInt *col_map_offd; + HYPRE_BigInt *work; + HYPRE_Int row_index; + HYPRE_Int i; + + HYPRE_Int nx_local, ny_local, nz_local; + HYPRE_Int num_cols_offd; + HYPRE_Int nxy; + HYPRE_BigInt grid_size; + + HYPRE_BigInt *nx_part; + HYPRE_BigInt *ny_part; + HYPRE_BigInt *nz_part; + + HYPRE_Int num_procs; + HYPRE_Int P_busy, Q_busy, R_busy; + + hypre_MPI_Comm_size(comm, &num_procs); + + grid_size = nx * ny * nz; + + hypre_GeneratePartitioning(nx, P, &nx_part); + hypre_GeneratePartitioning(ny, Q, &ny_part); + hypre_GeneratePartitioning(nz, R, &nz_part); + + nx_local = (HYPRE_Int)(nx_part[p + 1] - nx_part[p]); + ny_local = (HYPRE_Int)(ny_part[q + 1] - ny_part[q]); + nz_local = (HYPRE_Int)(nz_part[r + 1] - nz_part[r]); + + local_num_rows = nx_local * ny_local * nz_local; + + global_part[0] = nz_part[r] * nx * ny + (ny_part[q] * nx + nx_part[p] * ny_local) * nz_local; + global_part[1] = global_part[0] + (HYPRE_BigInt)local_num_rows; + + diag_i = hypre_CTAlloc(HYPRE_Int, local_num_rows + 1, HYPRE_MEMORY_HOST); + offd_i = hypre_CTAlloc(HYPRE_Int, local_num_rows + 1, HYPRE_MEMORY_HOST); + + P_busy = hypre_min(nx, P); + Q_busy = hypre_min(ny, Q); + R_busy = hypre_min(nz, R); + + num_cols_offd = 0; + if (p) { num_cols_offd += ny_local * nz_local; } + if (p < P_busy - 1) { num_cols_offd += ny_local * nz_local; } + if (q) { num_cols_offd += nx_local * nz_local; } + if (q < Q_busy - 1) { num_cols_offd += nx_local * nz_local; } + if (r) { num_cols_offd += nx_local * ny_local; } + if (r < R_busy - 1) { num_cols_offd += nx_local * ny_local; } + if (p && q) { num_cols_offd += nz_local; } + if (p && q < Q_busy - 1 ) { num_cols_offd += nz_local; } + if (p < P_busy - 1 && q ) { num_cols_offd += nz_local; } + if (p < P_busy - 1 && q < Q_busy - 1 ) { num_cols_offd += nz_local; } + if (p && r) { num_cols_offd += ny_local; } + if (p && r < R_busy - 1 ) { num_cols_offd += ny_local; } + if (p < P_busy - 1 && r ) { num_cols_offd += ny_local; } + if (p < P_busy - 1 && r < R_busy - 1 ) { num_cols_offd += ny_local; } + if (q && r) { num_cols_offd += nx_local; } + if (q && r < R_busy - 1 ) { num_cols_offd += nx_local; } + if (q < Q_busy - 1 && r ) { num_cols_offd += nx_local; } + if (q < Q_busy - 1 && r < R_busy - 1 ) { num_cols_offd += nx_local; } + if (p && q && r) { num_cols_offd++; } + if (p && q && r < R_busy - 1) { num_cols_offd++; } + if (p && q < Q_busy - 1 && r) { num_cols_offd++; } + if (p && q < Q_busy - 1 && r < R_busy - 1) { num_cols_offd++; } + if (p < P_busy - 1 && q && r) { num_cols_offd++; } + if (p < P_busy - 1 && q && r < R_busy - 1 ) { num_cols_offd++; } + if (p < P_busy - 1 && q < Q_busy - 1 && r ) { num_cols_offd++; } + if (p < P_busy - 1 && q < Q_busy - 1 && r < R_busy - 1) { num_cols_offd++; } + + if (!local_num_rows) { num_cols_offd = 0; } + + col_map_offd = hypre_CTAlloc(HYPRE_BigInt, num_cols_offd, HYPRE_MEMORY_HOST); + + cnt = 0; + o_cnt = 0; + diag_i[0] = 0; + offd_i[0] = 0; + for (iz = nz_part[r]; iz < nz_part[r + 1]; iz++) + { + for (iy = ny_part[q]; iy < ny_part[q + 1]; iy++) + { + for (ix = nx_part[p]; ix < nx_part[p + 1]; ix++) + { + cnt++; + o_cnt++; + diag_i[cnt] = diag_i[cnt - 1]; + offd_i[o_cnt] = offd_i[o_cnt - 1]; + diag_i[cnt]++; + if (iz > nz_part[r]) + { + diag_i[cnt]++; + if (iy > ny_part[q]) + { + diag_i[cnt]++; + if (ix > nx_part[p]) + { + diag_i[cnt]++; + } + else + { + if (ix) + { + offd_i[o_cnt]++; + } + } + if (ix < nx_part[p + 1] - 1) + { + diag_i[cnt]++; + } + else + { + if (ix + 1 < nx) + { + offd_i[o_cnt]++; + } + } + } + else + { + if (iy) + { + offd_i[o_cnt]++; + if (ix > nx_part[p]) + { + offd_i[o_cnt]++; + } + else if (ix) + { + offd_i[o_cnt]++; + } + if (ix < nx_part[p + 1] - 1) + { + offd_i[o_cnt]++; + } + else if (ix < nx - 1) + { + offd_i[o_cnt]++; + } + } + } + if (ix > nx_part[p]) + { + diag_i[cnt]++; + } + else + { + if (ix) + { + offd_i[o_cnt]++; + } + } + if (ix + 1 < nx_part[p + 1]) + { + diag_i[cnt]++; + } + else + { + if (ix + 1 < nx) + { + offd_i[o_cnt]++; + } + } + if (iy + 1 < ny_part[q + 1]) + { + diag_i[cnt]++; + if (ix > nx_part[p]) + { + diag_i[cnt]++; + } + else + { + if (ix) + { + offd_i[o_cnt]++; + } + } + if (ix < nx_part[p + 1] - 1) + { + diag_i[cnt]++; + } + else + { + if (ix + 1 < nx) + { + offd_i[o_cnt]++; + } + } + } + else + { + if (iy + 1 < ny) + { + offd_i[o_cnt]++; + if (ix > nx_part[p]) + { + offd_i[o_cnt]++; + } + else if (ix) + { + offd_i[o_cnt]++; + } + if (ix < nx_part[p + 1] - 1) + { + offd_i[o_cnt]++; + } + else if (ix < nx - 1) + { + offd_i[o_cnt]++; + } + } + } + } + else + { + if (iz) + { + offd_i[o_cnt]++; + if (iy > ny_part[q]) + { + offd_i[o_cnt]++; + if (ix > nx_part[p]) + { + offd_i[o_cnt]++; + } + else + { + if (ix) + { + offd_i[o_cnt]++; + } + } + if (ix < nx_part[p + 1] - 1) + { + offd_i[o_cnt]++; + } + else + { + if (ix + 1 < nx) + { + offd_i[o_cnt]++; + } + } + } + else + { + if (iy) + { + offd_i[o_cnt]++; + if (ix > nx_part[p]) + { + offd_i[o_cnt]++; + } + else if (ix) + { + offd_i[o_cnt]++; + } + if (ix < nx_part[p + 1] - 1) + { + offd_i[o_cnt]++; + } + else if (ix < nx - 1) + { + offd_i[o_cnt]++; + } + } + } + if (ix > nx_part[p]) + { + offd_i[o_cnt]++; + } + else + { + if (ix) + { + offd_i[o_cnt]++; + } + } + if (ix + 1 < nx_part[p + 1]) + { + offd_i[o_cnt]++; + } + else + { + if (ix + 1 < nx) + { + offd_i[o_cnt]++; + } + } + if (iy + 1 < ny_part[q + 1]) + { + offd_i[o_cnt]++; + if (ix > nx_part[p]) + { + offd_i[o_cnt]++; + } + else + { + if (ix) + { + offd_i[o_cnt]++; + } + } + if (ix < nx_part[p + 1] - 1) + { + offd_i[o_cnt]++; + } + else + { + if (ix + 1 < nx) + { + offd_i[o_cnt]++; + } + } + } + else + { + if (iy + 1 < ny) + { + offd_i[o_cnt]++; + if (ix > nx_part[p]) + { + offd_i[o_cnt]++; + } + else if (ix) + { + offd_i[o_cnt]++; + } + if (ix < nx_part[p + 1] - 1) + { + offd_i[o_cnt]++; + } + else if (ix < nx - 1) + { + offd_i[o_cnt]++; + } + } + } + } + } + if (iy > ny_part[q]) + { + diag_i[cnt]++; + if (ix > nx_part[p]) + { + diag_i[cnt]++; + } + else + { + if (ix) + { + offd_i[o_cnt]++; + } + } + if (ix < nx_part[p + 1] - 1) + { + diag_i[cnt]++; + } + else + { + if (ix + 1 < nx) + { + offd_i[o_cnt]++; + } + } + } + else + { + if (iy) + { + offd_i[o_cnt]++; + if (ix > nx_part[p]) + { + offd_i[o_cnt]++; + } + else if (ix) + { + offd_i[o_cnt]++; + } + if (ix < nx_part[p + 1] - 1) + { + offd_i[o_cnt]++; + } + else if (ix < nx - 1) + { + offd_i[o_cnt]++; + } + } + } + if (ix > nx_part[p]) + { + diag_i[cnt]++; + } + else + { + if (ix) + { + offd_i[o_cnt]++; + } + } + if (ix + 1 < nx_part[p + 1]) + { + diag_i[cnt]++; + } + else + { + if (ix + 1 < nx) + { + offd_i[o_cnt]++; + } + } + if (iy + 1 < ny_part[q + 1]) + { + diag_i[cnt]++; + if (ix > nx_part[p]) + { + diag_i[cnt]++; + } + else + { + if (ix) + { + offd_i[o_cnt]++; + } + } + if (ix < nx_part[p + 1] - 1) + { + diag_i[cnt]++; + } + else + { + if (ix + 1 < nx) + { + offd_i[o_cnt]++; + } + } + } + else + { + if (iy + 1 < ny) + { + offd_i[o_cnt]++; + if (ix > nx_part[p]) + { + offd_i[o_cnt]++; + } + else if (ix) + { + offd_i[o_cnt]++; + } + if (ix < nx_part[p + 1] - 1) + { + offd_i[o_cnt]++; + } + else if (ix < nx - 1) + { + offd_i[o_cnt]++; + } + } + } + if (iz + 1 < nz_part[r + 1]) + { + diag_i[cnt]++; + if (iy > ny_part[q]) + { + diag_i[cnt]++; + if (ix > nx_part[p]) + { + diag_i[cnt]++; + } + else + { + if (ix) + { + offd_i[o_cnt]++; + } + } + if (ix < nx_part[p + 1] - 1) + { + diag_i[cnt]++; + } + else + { + if (ix + 1 < nx) + { + offd_i[o_cnt]++; + } + } + } + else + { + if (iy) + { + offd_i[o_cnt]++; + if (ix > nx_part[p]) + { + offd_i[o_cnt]++; + } + else if (ix) + { + offd_i[o_cnt]++; + } + if (ix < nx_part[p + 1] - 1) + { + offd_i[o_cnt]++; + } + else if (ix < nx - 1) + { + offd_i[o_cnt]++; + } + } + } + if (ix > nx_part[p]) + { + diag_i[cnt]++; + } + else + { + if (ix) + { + offd_i[o_cnt]++; + } + } + if (ix + 1 < nx_part[p + 1]) + { + diag_i[cnt]++; + } + else + { + if (ix + 1 < nx) + { + offd_i[o_cnt]++; + } + } + if (iy + 1 < ny_part[q + 1]) + { + diag_i[cnt]++; + if (ix > nx_part[p]) + { + diag_i[cnt]++; + } + else + { + if (ix) + { + offd_i[o_cnt]++; + } + } + if (ix < nx_part[p + 1] - 1) + { + diag_i[cnt]++; + } + else + { + if (ix + 1 < nx) + { + offd_i[o_cnt]++; + } + } + } + else + { + if (iy + 1 < ny) + { + offd_i[o_cnt]++; + if (ix > nx_part[p]) + { + offd_i[o_cnt]++; + } + else if (ix) + { + offd_i[o_cnt]++; + } + if (ix < nx_part[p + 1] - 1) + { + offd_i[o_cnt]++; + } + else if (ix < nx - 1) + { + offd_i[o_cnt]++; + } + } + } + } + else + { + if (iz + 1 < nz) + { + offd_i[o_cnt]++; + if (iy > ny_part[q]) + { + offd_i[o_cnt]++; + if (ix > nx_part[p]) + { + offd_i[o_cnt]++; + } + else + { + if (ix) + { + offd_i[o_cnt]++; + } + } + if (ix < nx_part[p + 1] - 1) + { + offd_i[o_cnt]++; + } + else + { + if (ix + 1 < nx) + { + offd_i[o_cnt]++; + } + } + } + else + { + if (iy) + { + offd_i[o_cnt]++; + if (ix > nx_part[p]) + { + offd_i[o_cnt]++; + } + else if (ix) + { + offd_i[o_cnt]++; + } + if (ix < nx_part[p + 1] - 1) + { + offd_i[o_cnt]++; + } + else if (ix < nx - 1) + { + offd_i[o_cnt]++; + } + } + } + if (ix > nx_part[p]) + { + offd_i[o_cnt]++; + } + else + { + if (ix) + { + offd_i[o_cnt]++; + } + } + if (ix + 1 < nx_part[p + 1]) + { + offd_i[o_cnt]++; + } + else + { + if (ix + 1 < nx) + { + offd_i[o_cnt]++; + } + } + if (iy + 1 < ny_part[q + 1]) + { + offd_i[o_cnt]++; + if (ix > nx_part[p]) + { + offd_i[o_cnt]++; + } + else + { + if (ix) + { + offd_i[o_cnt]++; + } + } + if (ix < nx_part[p + 1] - 1) + { + offd_i[o_cnt]++; + } + else + { + if (ix + 1 < nx) + { + offd_i[o_cnt]++; + } + } + } + else + { + if (iy + 1 < ny) + { + offd_i[o_cnt]++; + if (ix > nx_part[p]) + { + offd_i[o_cnt]++; + } + else if (ix) + { + offd_i[o_cnt]++; + } + if (ix < nx_part[p + 1] - 1) + { + offd_i[o_cnt]++; + } + else if (ix < nx - 1) + { + offd_i[o_cnt]++; + } + } + } + } + } + } + } + } + + diag_j = hypre_CTAlloc(HYPRE_Int, diag_i[local_num_rows], HYPRE_MEMORY_HOST); + diag_data = hypre_CTAlloc(HYPRE_Real, diag_i[local_num_rows], HYPRE_MEMORY_HOST); + + if (num_procs > 1) + { + big_offd_j = hypre_CTAlloc(HYPRE_BigInt, offd_i[local_num_rows], HYPRE_MEMORY_HOST); + offd_j = hypre_CTAlloc(HYPRE_Int, offd_i[local_num_rows], HYPRE_MEMORY_HOST); + offd_data = hypre_CTAlloc(HYPRE_Real, offd_i[local_num_rows], HYPRE_MEMORY_HOST); + } + + nxy = nx_local * ny_local; + row_index = 0; + cnt = 0; + o_cnt = 0; + for (iz = nz_part[r]; iz < nz_part[r + 1]; iz++) + { + for (iy = ny_part[q]; iy < ny_part[q + 1]; iy++) + { + for (ix = nx_part[p]; ix < nx_part[p + 1]; ix++) + { + diag_j[cnt] = row_index; + diag_data[cnt++] = value[0]; + if (iz > nz_part[r]) + { + if (iy > ny_part[q]) + { + if (ix > nx_part[p]) + { + diag_j[cnt] = row_index - nxy - nx_local - 1; + diag_data[cnt++] = value[1]; + } + else + { + if (ix) + { + big_offd_j[o_cnt] = map3(ix - 1, iy - 1, iz - 1, p - 1, q, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + diag_j[cnt] = row_index - nxy - nx_local; + diag_data[cnt++] = value[1]; + if (ix < nx_part[p + 1] - 1) + { + diag_j[cnt] = row_index - nxy - nx_local + 1; + diag_data[cnt++] = value[1]; + } + else + { + if (ix + 1 < nx) + { + big_offd_j[o_cnt] = map3(ix + 1, iy - 1, iz - 1, p + 1, q, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + } + else + { + if (iy) + { + if (ix > nx_part[p]) + { + big_offd_j[o_cnt] = map3(ix - 1, iy - 1, iz - 1, p, q - 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else if (ix) + { + big_offd_j[o_cnt] = map3(ix - 1, iy - 1, iz - 1, p - 1, q - 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + big_offd_j[o_cnt] = map3(ix, iy - 1, iz - 1, p, q - 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + if (ix < nx_part[p + 1] - 1) + { + big_offd_j[o_cnt] = map3(ix + 1, iy - 1, iz - 1, p, q - 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else if (ix < nx - 1) + { + big_offd_j[o_cnt] = map3(ix + 1, iy - 1, iz - 1, p + 1, q - 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + } + if (ix > nx_part[p]) + { + diag_j[cnt] = row_index - nxy - 1; + diag_data[cnt++] = value[1]; + } + else + { + if (ix) + { + big_offd_j[o_cnt] = map3(ix - 1, iy, iz - 1, p - 1, q, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + diag_j[cnt] = row_index - nxy; + diag_data[cnt++] = value[1]; + if (ix + 1 < nx_part[p + 1]) + { + diag_j[cnt] = row_index - nxy + 1; + diag_data[cnt++] = value[1]; + } + else + { + if (ix + 1 < nx) + { + big_offd_j[o_cnt] = map3(ix + 1, iy, iz - 1, p + 1, q, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + if (iy + 1 < ny_part[q + 1]) + { + if (ix > nx_part[p]) + { + diag_j[cnt] = row_index - nxy + nx_local - 1; + diag_data[cnt++] = value[1]; + } + else + { + if (ix) + { + big_offd_j[o_cnt] = map3(ix - 1, iy + 1, iz - 1, p - 1, q, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + diag_j[cnt] = row_index - nxy + nx_local; + diag_data[cnt++] = value[1]; + if (ix < nx_part[p + 1] - 1) + { + diag_j[cnt] = row_index - nxy + nx_local + 1; + diag_data[cnt++] = value[1]; + } + else + { + if (ix + 1 < nx) + { + big_offd_j[o_cnt] = map3(ix + 1, iy + 1, iz - 1, p + 1, q, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + } + else + { + if (iy + 1 < ny) + { + if (ix > nx_part[p]) + { + big_offd_j[o_cnt] = map3(ix - 1, iy + 1, iz - 1, p, q + 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else if (ix) + { + big_offd_j[o_cnt] = map3(ix - 1, iy + 1, iz - 1, p - 1, q + 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + big_offd_j[o_cnt] = map3(ix, iy + 1, iz - 1, p, q + 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + if (ix < nx_part[p + 1] - 1) + { + big_offd_j[o_cnt] = map3(ix + 1, iy + 1, iz - 1, p, q + 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else if (ix < nx - 1) + { + big_offd_j[o_cnt] = map3(ix + 1, iy + 1, iz - 1, p + 1, q + 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + } + } + else + { + if (iz) + { + if (iy > ny_part[q]) + { + if (ix > nx_part[p]) + { + big_offd_j[o_cnt] = map3(ix - 1, iy - 1, iz - 1, p, q, r - 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else + { + if (ix) + { + big_offd_j[o_cnt] = map3(ix - 1, iy - 1, iz - 1, p - 1, q, r - 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + big_offd_j[o_cnt] = map3(ix, iy - 1, iz - 1, p, q, r - 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + if (ix < nx_part[p + 1] - 1) + { + big_offd_j[o_cnt] = map3(ix + 1, iy - 1, iz - 1, p, q, r - 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else + { + if (ix + 1 < nx) + { + big_offd_j[o_cnt] = map3(ix + 1, iy - 1, iz - 1, p + 1, q, r - 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + } + else + { + if (iy) + { + if (ix > nx_part[p]) + { + big_offd_j[o_cnt] = map3(ix - 1, iy - 1, iz - 1, p, q - 1, r - 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else if (ix) + { + big_offd_j[o_cnt] = map3(ix - 1, iy - 1, iz - 1, p - 1, q - 1, r - 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + big_offd_j[o_cnt] = map3(ix, iy - 1, iz - 1, p, q - 1, r - 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + if (ix < nx_part[p + 1] - 1) + { + big_offd_j[o_cnt] = map3(ix + 1, iy - 1, iz - 1, p, q - 1, r - 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else if (ix < nx - 1) + { + big_offd_j[o_cnt] = map3(ix + 1, iy - 1, iz - 1, p + 1, q - 1, r - 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + } + if (ix > nx_part[p]) + { + big_offd_j[o_cnt] = map3(ix - 1, iy, iz - 1, p, q, r - 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else + { + if (ix) + { + big_offd_j[o_cnt] = map3(ix - 1, iy, iz - 1, p - 1, q, r - 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + big_offd_j[o_cnt] = map3(ix, iy, iz - 1, p, q, r - 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + if (ix + 1 < nx_part[p + 1]) + { + big_offd_j[o_cnt] = map3(ix + 1, iy, iz - 1, p, q, r - 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else + { + if (ix + 1 < nx) + { + big_offd_j[o_cnt] = map3(ix + 1, iy, iz - 1, p + 1, q, r - 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + if (iy + 1 < ny_part[q + 1]) + { + if (ix > nx_part[p]) + { + big_offd_j[o_cnt] = map3(ix - 1, iy + 1, iz - 1, p, q, r - 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else + { + if (ix) + { + big_offd_j[o_cnt] = map3(ix - 1, iy + 1, iz - 1, p - 1, q, r - 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + big_offd_j[o_cnt] = map3(ix, iy + 1, iz - 1, p, q, r - 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + if (ix < nx_part[p + 1] - 1) + { + big_offd_j[o_cnt] = map3(ix + 1, iy + 1, iz - 1, p, q, r - 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else + { + if (ix + 1 < nx) + { + big_offd_j[o_cnt] = map3(ix + 1, iy + 1, iz - 1, p + 1, q, r - 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + } + else + { + if (iy + 1 < ny) + { + if (ix > nx_part[p]) + { + big_offd_j[o_cnt] = map3(ix - 1, iy + 1, iz - 1, p, q + 1, r - 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else if (ix) + { + big_offd_j[o_cnt] = map3(ix - 1, iy + 1, iz - 1, p - 1, q + 1, r - 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + big_offd_j[o_cnt] = map3(ix, iy + 1, iz - 1, p, q + 1, r - 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + if (ix < nx_part[p + 1] - 1) + { + big_offd_j[o_cnt] = map3(ix + 1, iy + 1, iz - 1, p, q + 1, r - 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else if (ix < nx - 1) + { + big_offd_j[o_cnt] = map3(ix + 1, iy + 1, iz - 1, p + 1, q + 1, r - 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + } + } + } + if (iy > ny_part[q]) + { + if (ix > nx_part[p]) + { + diag_j[cnt] = row_index - nx_local - 1; + diag_data[cnt++] = value[1]; + } + else + { + if (ix) + { + big_offd_j[o_cnt] = map3(ix - 1, iy - 1, iz, p - 1, q, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + diag_j[cnt] = row_index - nx_local; + diag_data[cnt++] = value[1]; + if (ix < nx_part[p + 1] - 1) + { + diag_j[cnt] = row_index - nx_local + 1; + diag_data[cnt++] = value[1]; + } + else + { + if (ix + 1 < nx) + { + big_offd_j[o_cnt] = map3(ix + 1, iy - 1, iz, p + 1, q, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + } + else + { + if (iy) + { + if (ix > nx_part[p]) + { + big_offd_j[o_cnt] = map3(ix - 1, iy - 1, iz, p, q - 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else if (ix) + { + big_offd_j[o_cnt] = map3(ix - 1, iy - 1, iz, p - 1, q - 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + big_offd_j[o_cnt] = map3(ix, iy - 1, iz, p, q - 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + if (ix < nx_part[p + 1] - 1) + { + big_offd_j[o_cnt] = map3(ix + 1, iy - 1, iz, p, q - 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else if (ix < nx - 1) + { + big_offd_j[o_cnt] = map3(ix + 1, iy - 1, iz, p + 1, q - 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + } + if (ix > nx_part[p]) + { + diag_j[cnt] = row_index - 1; + diag_data[cnt++] = value[1]; + } + else + { + if (ix) + { + big_offd_j[o_cnt] = map3(ix - 1, iy, iz, p - 1, q, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + if (ix + 1 < nx_part[p + 1]) + { + diag_j[cnt] = row_index + 1; + diag_data[cnt++] = value[1]; + } + else + { + if (ix + 1 < nx) + { + big_offd_j[o_cnt] = map3(ix + 1, iy, iz, p + 1, q, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + if (iy + 1 < ny_part[q + 1]) + { + if (ix > nx_part[p]) + { + diag_j[cnt] = row_index + nx_local - 1; + diag_data[cnt++] = value[1]; + } + else + { + if (ix) + { + big_offd_j[o_cnt] = map3(ix - 1, iy + 1, iz, p - 1, q, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + diag_j[cnt] = row_index + nx_local; + diag_data[cnt++] = value[1]; + if (ix < nx_part[p + 1] - 1) + { + diag_j[cnt] = row_index + nx_local + 1; + diag_data[cnt++] = value[1]; + } + else + { + if (ix + 1 < nx) + { + big_offd_j[o_cnt] = map3(ix + 1, iy + 1, iz, p + 1, q, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + } + else + { + if (iy + 1 < ny) + { + if (ix > nx_part[p]) + { + big_offd_j[o_cnt] = map3(ix - 1, iy + 1, iz, p, q + 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else if (ix) + { + big_offd_j[o_cnt] = map3(ix - 1, iy + 1, iz, p - 1, q + 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + big_offd_j[o_cnt] = map3(ix, iy + 1, iz, p, q + 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + if (ix < nx_part[p + 1] - 1) + { + big_offd_j[o_cnt] = map3(ix + 1, iy + 1, iz, p, q + 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else if (ix < nx - 1) + { + big_offd_j[o_cnt] = map3(ix + 1, iy + 1, iz, p + 1, q + 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + } + if (iz + 1 < nz_part[r + 1]) + { + if (iy > ny_part[q]) + { + if (ix > nx_part[p]) + { + diag_j[cnt] = row_index + nxy - nx_local - 1; + diag_data[cnt++] = value[1]; + } + else + { + if (ix) + { + big_offd_j[o_cnt] = map3(ix - 1, iy - 1, iz + 1, p - 1, q, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + diag_j[cnt] = row_index + nxy - nx_local; + diag_data[cnt++] = value[1]; + if (ix < nx_part[p + 1] - 1) + { + diag_j[cnt] = row_index + nxy - nx_local + 1; + diag_data[cnt++] = value[1]; + } + else + { + if (ix + 1 < nx) + { + big_offd_j[o_cnt] = map3(ix + 1, iy - 1, iz + 1, p + 1, q, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + } + else + { + if (iy) + { + if (ix > nx_part[p]) + { + big_offd_j[o_cnt] = map3(ix - 1, iy - 1, iz + 1, p, q - 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else if (ix) + { + big_offd_j[o_cnt] = map3(ix - 1, iy - 1, iz + 1, p - 1, q - 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + big_offd_j[o_cnt] = map3(ix, iy - 1, iz + 1, p, q - 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + if (ix < nx_part[p + 1] - 1) + { + big_offd_j[o_cnt] = map3(ix + 1, iy - 1, iz + 1, p, q - 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else if (ix < nx - 1) + { + big_offd_j[o_cnt] = map3(ix + 1, iy - 1, iz + 1, p + 1, q - 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + } + if (ix > nx_part[p]) + { + diag_j[cnt] = row_index + nxy - 1; + diag_data[cnt++] = value[1]; + } + else + { + if (ix) + { + big_offd_j[o_cnt] = map3(ix - 1, iy, iz + 1, p - 1, q, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + diag_j[cnt] = row_index + nxy; + diag_data[cnt++] = value[1]; + if (ix + 1 < nx_part[p + 1]) + { + diag_j[cnt] = row_index + nxy + 1; + diag_data[cnt++] = value[1]; + } + else + { + if (ix + 1 < nx) + { + big_offd_j[o_cnt] = map3(ix + 1, iy, iz + 1, p + 1, q, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + if (iy + 1 < ny_part[q + 1]) + { + if (ix > nx_part[p]) + { + diag_j[cnt] = row_index + nxy + nx_local - 1; + diag_data[cnt++] = value[1]; + } + else + { + if (ix) + { + big_offd_j[o_cnt] = map3(ix - 1, iy + 1, iz + 1, p - 1, q, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + diag_j[cnt] = row_index + nxy + nx_local; + diag_data[cnt++] = value[1]; + if (ix < nx_part[p + 1] - 1) + { + diag_j[cnt] = row_index + nxy + nx_local + 1; + diag_data[cnt++] = value[1]; + } + else + { + if (ix + 1 < nx) + { + big_offd_j[o_cnt] = map3(ix + 1, iy + 1, iz + 1, p + 1, q, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + } + else + { + if (iy + 1 < ny) + { + if (ix > nx_part[p]) + { + big_offd_j[o_cnt] = map3(ix - 1, iy + 1, iz + 1, p, q + 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else if (ix) + { + big_offd_j[o_cnt] = map3(ix - 1, iy + 1, iz + 1, p - 1, q + 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + big_offd_j[o_cnt] = map3(ix, iy + 1, iz + 1, p, q + 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + if (ix < nx_part[p + 1] - 1) + { + big_offd_j[o_cnt] = map3(ix + 1, iy + 1, iz + 1, p, q + 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else if (ix < nx - 1) + { + big_offd_j[o_cnt] = map3(ix + 1, iy + 1, iz + 1, p + 1, q + 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + } + } + else + { + if (iz + 1 < nz) + { + if (iy > ny_part[q]) + { + if (ix > nx_part[p]) + { + big_offd_j[o_cnt] = map3(ix - 1, iy - 1, iz + 1, p, q, r + 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else + { + if (ix) + { + big_offd_j[o_cnt] = map3(ix - 1, iy - 1, iz + 1, p - 1, q, r + 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + big_offd_j[o_cnt] = map3(ix, iy - 1, iz + 1, p, q, r + 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + if (ix < nx_part[p + 1] - 1) + { + big_offd_j[o_cnt] = map3(ix + 1, iy - 1, iz + 1, p, q, r + 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else + { + if (ix + 1 < nx) + { + big_offd_j[o_cnt] = map3(ix + 1, iy - 1, iz + 1, p + 1, q, r + 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + } + else + { + if (iy) + { + if (ix > nx_part[p]) + { + big_offd_j[o_cnt] = map3(ix - 1, iy - 1, iz + 1, p, q - 1, r + 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else if (ix) + { + big_offd_j[o_cnt] = map3(ix - 1, iy - 1, iz + 1, p - 1, q - 1, r + 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + big_offd_j[o_cnt] = map3(ix, iy - 1, iz + 1, p, q - 1, r + 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + if (ix < nx_part[p + 1] - 1) + { + big_offd_j[o_cnt] = map3(ix + 1, iy - 1, iz + 1, p, q - 1, r + 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else if (ix < nx - 1) + { + big_offd_j[o_cnt] = map3(ix + 1, iy - 1, iz + 1, p + 1, q - 1, r + 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + } + if (ix > nx_part[p]) + { + big_offd_j[o_cnt] = map3(ix - 1, iy, iz + 1, p, q, r + 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else + { + if (ix) + { + big_offd_j[o_cnt] = map3(ix - 1, iy, iz + 1, p - 1, q, r + 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + big_offd_j[o_cnt] = map3(ix, iy, iz + 1, p, q, r + 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + if (ix + 1 < nx_part[p + 1]) + { + big_offd_j[o_cnt] = map3(ix + 1, iy, iz + 1, p, q, r + 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else + { + if (ix + 1 < nx) + { + big_offd_j[o_cnt] = map3(ix + 1, iy, iz + 1, p + 1, q, r + 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + if (iy + 1 < ny_part[q + 1]) + { + if (ix > nx_part[p]) + { + big_offd_j[o_cnt] = map3(ix - 1, iy + 1, iz + 1, p, q, r + 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else + { + if (ix) + { + big_offd_j[o_cnt] = map3(ix - 1, iy + 1, iz + 1, p - 1, q, r + 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + big_offd_j[o_cnt] = map3(ix, iy + 1, iz + 1, p, q, r + 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + if (ix < nx_part[p + 1] - 1) + { + big_offd_j[o_cnt] = map3(ix + 1, iy + 1, iz + 1, p, q, r + 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else + { + if (ix + 1 < nx) + { + big_offd_j[o_cnt] = map3(ix + 1, iy + 1, iz + 1, p + 1, q, r + 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + } + else + { + if (iy + 1 < ny) + { + if (ix > nx_part[p]) + { + big_offd_j[o_cnt] = map3(ix - 1, iy + 1, iz + 1, p, q + 1, r + 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else if (ix) + { + big_offd_j[o_cnt] = map3(ix - 1, iy + 1, iz + 1, p - 1, q + 1, r + 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + big_offd_j[o_cnt] = map3(ix, iy + 1, iz + 1, p, q + 1, r + 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + if (ix < nx_part[p + 1] - 1) + { + big_offd_j[o_cnt] = map3(ix + 1, iy + 1, iz + 1, p, q + 1, r + 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + else if (ix < nx - 1) + { + big_offd_j[o_cnt] = map3(ix + 1, iy + 1, iz + 1, p + 1, q + 1, r + 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + } + } + } + row_index++; + } + } + } + + if (num_procs > 1) + { + work = hypre_CTAlloc(HYPRE_BigInt, o_cnt, HYPRE_MEMORY_HOST); + + for (i = 0; i < o_cnt; i++) + { + work[i] = big_offd_j[i]; + } + + hypre_BigQsort0(work, 0, o_cnt - 1); + + col_map_offd[0] = work[0]; + cnt = 0; + for (i = 0; i < o_cnt; i++) + { + if (work[i] > col_map_offd[cnt]) + { + cnt++; + col_map_offd[cnt] = work[i]; + } + } + + for (i = 0; i < o_cnt; i++) + { + offd_j[i] = hypre_BigBinarySearch(col_map_offd, big_offd_j[i], num_cols_offd); + } + + hypre_TFree(work, HYPRE_MEMORY_HOST); + } + + A = hypre_ParCSRMatrixCreate(comm, grid_size, grid_size, + global_part, global_part, num_cols_offd, + diag_i[local_num_rows], + offd_i[local_num_rows]); + + hypre_ParCSRMatrixColMapOffd(A) = col_map_offd; + + diag = hypre_ParCSRMatrixDiag(A); + hypre_CSRMatrixI(diag) = diag_i; + hypre_CSRMatrixJ(diag) = diag_j; + hypre_CSRMatrixData(diag) = diag_data; + + offd = hypre_ParCSRMatrixOffd(A); + hypre_CSRMatrixI(offd) = offd_i; + if (num_cols_offd) + { + hypre_CSRMatrixJ(offd) = offd_j; + hypre_CSRMatrixData(offd) = offd_data; + } + + hypre_CSRMatrixMemoryLocation(diag) = HYPRE_MEMORY_HOST; + hypre_CSRMatrixMemoryLocation(offd) = HYPRE_MEMORY_HOST; + + hypre_ParCSRMatrixMigrate(A, hypre_HandleMemoryLocation(hypre_handle())); + + hypre_TFree(nx_part, HYPRE_MEMORY_HOST); + hypre_TFree(ny_part, HYPRE_MEMORY_HOST); + hypre_TFree(nz_part, HYPRE_MEMORY_HOST); + hypre_TFree(big_offd_j, HYPRE_MEMORY_HOST); + + return (HYPRE_ParCSRMatrix) A; +} + +/*-------------------------------------------------------------------------- + *--------------------------------------------------------------------------*/ + +HYPRE_ParCSRMatrix +GenerateRotate7pt( MPI_Comm comm, + HYPRE_BigInt nx, + HYPRE_BigInt ny, + HYPRE_Int P, + HYPRE_Int Q, + HYPRE_Int p, + HYPRE_Int q, + HYPRE_Real alpha, + HYPRE_Real eps ) +{ + hypre_ParCSRMatrix *A; + hypre_CSRMatrix *diag; + hypre_CSRMatrix *offd; + + HYPRE_Int *diag_i; + HYPRE_Int *diag_j; + HYPRE_Real *diag_data; + + HYPRE_Int *offd_i; + HYPRE_Int *offd_j = NULL; + HYPRE_Real *offd_data = NULL; + + HYPRE_Real *value; + HYPRE_Real ac, bc, cc, s, c, pi, x; + HYPRE_BigInt global_part[2]; + HYPRE_BigInt ix, iy; + HYPRE_Int cnt, o_cnt; + HYPRE_Int local_num_rows; + HYPRE_BigInt *col_map_offd; + HYPRE_BigInt *big_offd_j = NULL; + HYPRE_Int row_index; + HYPRE_Int i; + + HYPRE_Int nx_local, ny_local; + HYPRE_Int num_cols_offd; + HYPRE_BigInt grid_size; + + HYPRE_BigInt *nx_part; + HYPRE_BigInt *ny_part; + + HYPRE_Int num_procs; + HYPRE_Int P_busy, Q_busy; + + hypre_MPI_Comm_size(comm, &num_procs); + + grid_size = nx * ny; + + value = hypre_CTAlloc(HYPRE_Real, 4, HYPRE_MEMORY_HOST); + pi = 4.0 * hypre_atan(1.0); + x = pi * alpha / 180.0; + s = hypre_sin(x); + c = hypre_cos(x); + ac = -(c * c + eps * s * s); + bc = 2.0 * (1.0 - eps) * s * c; + cc = -(s * s + eps * c * c); + value[0] = -2 * (2 * ac + bc + 2 * cc); + value[1] = 2 * ac + bc; + value[2] = bc + 2 * cc; + value[3] = -bc; + + hypre_GeneratePartitioning(nx, P, &nx_part); + hypre_GeneratePartitioning(ny, Q, &ny_part); + + nx_local = (HYPRE_Int)(nx_part[p + 1] - nx_part[p]); + ny_local = (HYPRE_Int)(ny_part[q + 1] - ny_part[q]); + + local_num_rows = nx_local * ny_local; + + global_part[0] = ny_part[q] * nx + nx_part[p] * ny_local; + global_part[1] = global_part[0] + (HYPRE_BigInt)local_num_rows; + + diag_i = hypre_CTAlloc(HYPRE_Int, local_num_rows + 1, HYPRE_MEMORY_HOST); + offd_i = hypre_CTAlloc(HYPRE_Int, local_num_rows + 1, HYPRE_MEMORY_HOST); + + P_busy = hypre_min(nx, P); + Q_busy = hypre_min(ny, Q); + + num_cols_offd = 0; + if (p) { num_cols_offd += ny_local; } + if (p < P_busy - 1) { num_cols_offd += ny_local; } + if (q) { num_cols_offd += nx_local; } + if (q < Q_busy - 1) { num_cols_offd += nx_local; } + if (p && q) { num_cols_offd++; } + if (p && q < Q_busy - 1 ) { num_cols_offd++; } + if (p < P_busy - 1 && q ) { num_cols_offd++; } + if (p < P_busy - 1 && q < Q_busy - 1 ) { num_cols_offd++; } + + if (!local_num_rows) { num_cols_offd = 0; } + + col_map_offd = hypre_CTAlloc(HYPRE_BigInt, num_cols_offd, HYPRE_MEMORY_HOST); + + cnt = 0; + o_cnt = 0; + diag_i[0] = 0; + offd_i[0] = 0; + for (iy = ny_part[q]; iy < ny_part[q + 1]; iy++) + { + for (ix = nx_part[p]; ix < nx_part[p + 1]; ix++) + { + cnt++; + o_cnt++; + diag_i[cnt] = diag_i[cnt - 1]; + offd_i[o_cnt] = offd_i[o_cnt - 1]; + diag_i[cnt]++; + if (iy > ny_part[q]) + { + diag_i[cnt]++; + if (ix > nx_part[p]) + { + diag_i[cnt]++; + } + else + { + if (ix) + { + offd_i[o_cnt]++; + } + } + } + else + { + if (iy) + { + offd_i[o_cnt]++; + if (ix > nx_part[p]) + { + offd_i[o_cnt]++; + } + else if (ix) + { + offd_i[o_cnt]++; + } + } + } + if (ix > nx_part[p]) + { + diag_i[cnt]++; + } + else + { + if (ix) + { + offd_i[o_cnt]++; + } + } + if (ix + 1 < nx_part[p + 1]) + { + diag_i[cnt]++; + } + else + { + if (ix + 1 < nx) + { + offd_i[o_cnt]++; + } + } + if (iy + 1 < ny_part[q + 1]) + { + diag_i[cnt]++; + if (ix < nx_part[p + 1] - 1) + { + diag_i[cnt]++; + } + else + { + if (ix + 1 < nx) + { + offd_i[o_cnt]++; + } + } + } + else + { + if (iy + 1 < ny) + { + offd_i[o_cnt]++; + if (ix < nx_part[p + 1] - 1) + { + offd_i[o_cnt]++; + } + else if (ix < nx - 1) + { + offd_i[o_cnt]++; + } + } + } + } + } + + diag_j = hypre_CTAlloc(HYPRE_Int, diag_i[local_num_rows], HYPRE_MEMORY_HOST); + diag_data = hypre_CTAlloc(HYPRE_Real, diag_i[local_num_rows], HYPRE_MEMORY_HOST); + + if (num_procs > 1) + { + big_offd_j = hypre_CTAlloc(HYPRE_BigInt, offd_i[local_num_rows], HYPRE_MEMORY_HOST); + offd_j = hypre_CTAlloc(HYPRE_Int, offd_i[local_num_rows], HYPRE_MEMORY_HOST); + offd_data = hypre_CTAlloc(HYPRE_Real, offd_i[local_num_rows], HYPRE_MEMORY_HOST); + } + + row_index = 0; + cnt = 0; + o_cnt = 0; + for (iy = ny_part[q]; iy < ny_part[q + 1]; iy++) + { + for (ix = nx_part[p]; ix < nx_part[p + 1]; ix++) + { + diag_j[cnt] = row_index; + diag_data[cnt++] = value[0]; + if (iy > ny_part[q]) + { + if (ix > nx_part[p]) + { + diag_j[cnt] = row_index - nx_local - 1 ; + diag_data[cnt++] = value[3]; + } + else + { + if (ix) + { + big_offd_j[o_cnt] = map2(ix - 1, iy - 1, p - 1, q, nx, + nx_part, ny_part); + offd_data[o_cnt++] = value[3]; + } + } + diag_j[cnt] = row_index - nx_local; + diag_data[cnt++] = value[2]; + } + else + { + if (iy) + { + if (ix > nx_part[p]) + { + big_offd_j[o_cnt] = map2(ix - 1, iy - 1, p, q - 1, nx, + nx_part, ny_part); + offd_data[o_cnt++] = value[3]; + } + else if (ix) + { + big_offd_j[o_cnt] = map2(ix - 1, iy - 1, p - 1, q - 1, nx, + nx_part, ny_part); + offd_data[o_cnt++] = value[3]; + } + big_offd_j[o_cnt] = map2(ix, iy - 1, p, q - 1, nx, + nx_part, ny_part); + offd_data[o_cnt++] = value[2]; + } + } + if (ix > nx_part[p]) + { + diag_j[cnt] = row_index - 1; + diag_data[cnt++] = value[1]; + } + else + { + if (ix) + { + big_offd_j[o_cnt] = map2(ix - 1, iy, p - 1, q, nx, nx_part, ny_part); + offd_data[o_cnt++] = value[1]; + } + } + if (ix + 1 < nx_part[p + 1]) + { + diag_j[cnt] = row_index + 1; + diag_data[cnt++] = value[1]; + } + else + { + if (ix + 1 < nx) + { + big_offd_j[o_cnt] = map2(ix + 1, iy, p + 1, q, nx, nx_part, ny_part); + offd_data[o_cnt++] = value[1]; + } + } + if (iy + 1 < ny_part[q + 1]) + { + diag_j[cnt] = row_index + nx_local; + diag_data[cnt++] = value[2]; + if (ix < nx_part[p + 1] - 1) + { + diag_j[cnt] = row_index + nx_local + 1 ; + diag_data[cnt++] = value[3]; + } + else + { + if (ix + 1 < nx) + { + big_offd_j[o_cnt] = map2(ix + 1, iy + 1, p + 1, q, nx, nx_part, ny_part); + offd_data[o_cnt++] = value[3]; + } + } + } + else + { + if (iy + 1 < ny) + { + big_offd_j[o_cnt] = map2(ix, iy + 1, p, q + 1, nx, nx_part, ny_part); + offd_data[o_cnt++] = value[2]; + if (ix < nx_part[p + 1] - 1) + { + big_offd_j[o_cnt] = map2(ix + 1, iy + 1, p, q + 1, nx, nx_part, ny_part); + offd_data[o_cnt++] = value[3]; + } + else if (ix < nx - 1) + { + big_offd_j[o_cnt] = map2(ix + 1, iy + 1, p + 1, q + 1, nx, nx_part, ny_part); + offd_data[o_cnt++] = value[3]; + } + } + } + row_index++; + } + } + + if (num_procs > 1) + { + HYPRE_BigInt *work = hypre_CTAlloc(HYPRE_BigInt, o_cnt, HYPRE_MEMORY_HOST); + + for (i = 0; i < o_cnt; i++) + { + work[i] = big_offd_j[i]; + } + + hypre_BigQsort0(work, 0, o_cnt - 1); + + col_map_offd[0] = work[0]; + cnt = 0; + for (i = 0; i < o_cnt; i++) + { + if (work[i] > col_map_offd[cnt]) + { + cnt++; + col_map_offd[cnt] = work[i]; + } + } + + num_cols_offd = cnt + 1; + for (i = 0; i < o_cnt; i++) + { + offd_j[i] = hypre_BigBinarySearch(col_map_offd, big_offd_j[i], num_cols_offd); + } + + hypre_TFree(work, HYPRE_MEMORY_HOST); + hypre_TFree(big_offd_j, HYPRE_MEMORY_HOST); + } + + A = hypre_ParCSRMatrixCreate(comm, grid_size, grid_size, + global_part, global_part, num_cols_offd, + diag_i[local_num_rows], + offd_i[local_num_rows]); + + hypre_ParCSRMatrixColMapOffd(A) = col_map_offd; + + diag = hypre_ParCSRMatrixDiag(A); + hypre_CSRMatrixI(diag) = diag_i; + hypre_CSRMatrixJ(diag) = diag_j; + hypre_CSRMatrixData(diag) = diag_data; + + offd = hypre_ParCSRMatrixOffd(A); + hypre_CSRMatrixI(offd) = offd_i; + if (num_cols_offd) + { + hypre_CSRMatrixJ(offd) = offd_j; + hypre_CSRMatrixData(offd) = offd_data; + } + + hypre_CSRMatrixMemoryLocation(diag) = HYPRE_MEMORY_HOST; + hypre_CSRMatrixMemoryLocation(offd) = HYPRE_MEMORY_HOST; + + hypre_ParCSRMatrixMigrate(A, hypre_HandleMemoryLocation(hypre_handle())); + + hypre_TFree(nx_part, HYPRE_MEMORY_HOST); + hypre_TFree(ny_part, HYPRE_MEMORY_HOST); + hypre_TFree(value, HYPRE_MEMORY_HOST); + + return (HYPRE_ParCSRMatrix) A; +} + +/*-------------------------------------------------------------------------- + *--------------------------------------------------------------------------*/ + +static inline HYPRE_Real +afun(HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz) +{ + HYPRE_Real value; + /* value = 1.0 + 1000.0*hypre_abs(xx-yy); */ + if ((xx < 0.1 && yy < 0.1 && zz < 0.1) + || (xx < 0.1 && yy < 0.1 && zz > 0.9) + || (xx < 0.1 && yy > 0.9 && zz < 0.1) + || (xx > 0.9 && yy < 0.1 && zz < 0.1) + || (xx > 0.9 && yy > 0.9 && zz < 0.1) + || (xx > 0.9 && yy < 0.1 && zz > 0.9) + || (xx < 0.1 && yy > 0.9 && zz > 0.9) + || (xx > 0.9 && yy > 0.9 && zz > 0.9)) + { + value = 0.01; + } + else if (xx >= 0.1 && xx <= 0.9 + && yy >= 0.1 && yy <= 0.9 + && zz >= 0.1 && zz <= 0.9) + { + value = 1000.0; + } + else + { + value = 1.0 ; + } + /* HYPRE_Real value, pi; + pi = 4.0 * hypre_atan(1.0); + value = hypre_cos(pi*xx)*hypre_cos(pi*yy); */ + return value; +} + +static inline HYPRE_Real +bfun(HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz) +{ + HYPRE_Real value; + /* value = 1.0 + 1000.0*hypre_abs(xx-yy); */ + if ((xx < 0.1 && yy < 0.1 && zz < 0.1) + || (xx < 0.1 && yy < 0.1 && zz > 0.9) + || (xx < 0.1 && yy > 0.9 && zz < 0.1) + || (xx > 0.9 && yy < 0.1 && zz < 0.1) + || (xx > 0.9 && yy > 0.9 && zz < 0.1) + || (xx > 0.9 && yy < 0.1 && zz > 0.9) + || (xx < 0.1 && yy > 0.9 && zz > 0.9) + || (xx > 0.9 && yy > 0.9 && zz > 0.9)) + { + value = 0.01; + } + else if (xx >= 0.1 && xx <= 0.9 + && yy >= 0.1 && yy <= 0.9 + && zz >= 0.1 && zz <= 0.9) + { + value = 1000.0; + } + else + { + value = 1.0 ; + } + /* HYPRE_Real value, pi; + pi = 4.0 * hypre_atan(1.0); + value = 1.0 - 2.0*xx; + value = hypre_cos(pi*xx)*hypre_cos(pi*yy); */ + /* HYPRE_Real value; + value = 1.0 + 1000.0 * hypre_abs(xx-yy); + HYPRE_Real value, x0, y0; + x0 = hypre_abs(xx - 0.5); + y0 = hypre_abs(yy - 0.5); + if (y0 > x0) x0 = y0; + if (x0 >= 0.125 && x0 <= 0.25) + value = 1.0; + else + value = 1000.0;*/ + return value; +} + +static inline HYPRE_Real +cfun(HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz) +{ + HYPRE_Real value; + if ((xx < 0.1 && yy < 0.1 && zz < 0.1) + || (xx < 0.1 && yy < 0.1 && zz > 0.9) + || (xx < 0.1 && yy > 0.9 && zz < 0.1) + || (xx > 0.9 && yy < 0.1 && zz < 0.1) + || (xx > 0.9 && yy > 0.9 && zz < 0.1) + || (xx > 0.9 && yy < 0.1 && zz > 0.9) + || (xx < 0.1 && yy > 0.9 && zz > 0.9) + || (xx > 0.9 && yy > 0.9 && zz > 0.9)) + { + value = 0.01; + } + else if (xx >= 0.1 && xx <= 0.9 + && yy >= 0.1 && yy <= 0.9 + && zz >= 0.1 && zz <= 0.9) + { + value = 1000.0; + } + else + { + value = 1.0 ; + } + /*if (xx <= 0.75 && yy <= 0.75 && zz <= 0.75) + value = 0.1; + else if (xx > 0.75 && yy > 0.75 && zz > 0.75) + value = 100000; + else + value = 1.0 ;*/ + return value; +} + +static inline HYPRE_Real +dfun(HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz) +{ + HYPRE_UNUSED_VAR(xx); + HYPRE_UNUSED_VAR(yy); + HYPRE_UNUSED_VAR(zz); + + HYPRE_Real value; + /*HYPRE_Real pi; + pi = 4.0 * hypre_atan(1.0); + value = -hypre_sin(pi*xx)*hypre_cos(pi*yy);*/ + value = 0; + return value; +} + +static inline HYPRE_Real +efun(HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz) +{ + HYPRE_UNUSED_VAR(xx); + HYPRE_UNUSED_VAR(yy); + HYPRE_UNUSED_VAR(zz); + + HYPRE_Real value; + /*HYPRE_Real pi; + pi = 4.0 * hypre_atan(1.0); + value = hypre_sin(pi*yy)*hypre_cos(pi*xx);*/ + value = 0; + return value; +} + +static inline HYPRE_Real +ffun(HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz) +{ + HYPRE_UNUSED_VAR(xx); + HYPRE_UNUSED_VAR(yy); + HYPRE_UNUSED_VAR(zz); + + HYPRE_Real value; + value = 0.0; + return value; +} + +static inline HYPRE_Real +gfun(HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz) +{ + HYPRE_UNUSED_VAR(xx); + HYPRE_UNUSED_VAR(yy); + HYPRE_UNUSED_VAR(zz); + + HYPRE_Real value; + value = 0.0; + return value; +} + +static inline HYPRE_Real +rfun(HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz) +{ + HYPRE_UNUSED_VAR(xx); + HYPRE_UNUSED_VAR(yy); + HYPRE_UNUSED_VAR(zz); + + /* HYPRE_Real value, pi; + pi = 4.0 * hypre_atan(1.0); + value = -4.0*pi*pi*hypre_sin(pi*xx)*hypre_sin(pi*yy)*hypre_cos(pi*xx)*hypre_cos(pi*yy); */ + HYPRE_Real value; + /* value = xx*(1.0-xx)*yy*(1.0-yy); */ + value = 1.0; + return value; +} + +static inline HYPRE_Real +bndfun(HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz) +{ + HYPRE_UNUSED_VAR(xx); + HYPRE_UNUSED_VAR(yy); + HYPRE_UNUSED_VAR(zz); + + HYPRE_Real value; + /*HYPRE_Real pi; + pi = 4.0 * atan(1.0); + value = hypre_sin(pi*xx)+hypre_sin(13*pi*xx)+hypre_sin(pi*yy)+hypre_sin(13*pi*yy);*/ + value = 0.0; + return value; +} + +static inline HYPRE_Real +afun_rs(HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz) +{ + HYPRE_UNUSED_VAR(xx); + HYPRE_UNUSED_VAR(yy); + HYPRE_UNUSED_VAR(zz); + + HYPRE_Real value; + value = 1.0; + return value; +} + +static inline HYPRE_Real +bfun_rs(HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz) +{ + HYPRE_UNUSED_VAR(xx); + HYPRE_UNUSED_VAR(yy); + HYPRE_UNUSED_VAR(zz); + + HYPRE_Real value; + value = 1.0; + return value; +} + +static inline HYPRE_Real +cfun_rs(HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz) +{ + HYPRE_UNUSED_VAR(xx); + HYPRE_UNUSED_VAR(yy); + HYPRE_UNUSED_VAR(zz); + + HYPRE_Real value; + value = 1.0; + return value; +} + +static inline HYPRE_Real +dfun_rs(HYPRE_Real rs_example, HYPRE_Real rs_l, HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz) +{ + HYPRE_UNUSED_VAR(zz); + + HYPRE_Real value; + if (rs_example == 1) + { + value = hypre_sin(rs_l * M_PI / 8.0); + } + else if (rs_example == 2) + { + value = (2.0 * yy - 1.0) * (1.0 - xx * xx); + } + else + { + value = 4.0 * xx * (xx - 1.0) * (1.0 - 2.0 * yy); + } + return value; +} + +static inline HYPRE_Real +efun_rs(HYPRE_Real rs_example, HYPRE_Real rs_l, HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz) +{ + HYPRE_UNUSED_VAR(zz); + + HYPRE_Real value; + if (rs_example == 1) + { + value = hypre_cos(rs_l * M_PI / 8.0); + } + else if (rs_example == 2) + { + value = 2.0 * xx * yy * (yy - 1.0); + } + else + { + value = -4.0 * yy * (yy - 1.0) * (1.0 - 2.0 * xx); + } + return value; +} + +static inline HYPRE_Real +ffun_rs(HYPRE_Real rs_example, HYPRE_Real rs_l, HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz) +{ + HYPRE_Real value; + value = efun_rs(rs_example, rs_l, xx, yy, zz); + return value; +} + +static inline HYPRE_Real +gfun_rs(HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz) +{ + HYPRE_UNUSED_VAR(xx); + HYPRE_UNUSED_VAR(yy); + HYPRE_UNUSED_VAR(zz); + + HYPRE_Real value; + value = 0.0; + return value; +} + +static inline HYPRE_Real +rfun_rs(HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz) +{ + HYPRE_UNUSED_VAR(xx); + HYPRE_UNUSED_VAR(yy); + HYPRE_UNUSED_VAR(zz); + + HYPRE_Real value; + value = 1.0; + return value; +} + +static inline HYPRE_Real +bndfun_rs(HYPRE_Real xx, HYPRE_Real yy, HYPRE_Real zz) +{ + HYPRE_UNUSED_VAR(xx); + HYPRE_UNUSED_VAR(yy); + HYPRE_UNUSED_VAR(zz); + + HYPRE_Real value; + value = 0.0; + return value; +} + +/*-------------------------------------------------------------------------- + * hypre_GenerateDifConv + *--------------------------------------------------------------------------*/ + +HYPRE_ParCSRMatrix +GenerateDifConv( MPI_Comm comm, + HYPRE_BigInt nx, + HYPRE_BigInt ny, + HYPRE_BigInt nz, + HYPRE_Int P, + HYPRE_Int Q, + HYPRE_Int R, + HYPRE_Int p, + HYPRE_Int q, + HYPRE_Int r, + HYPRE_Real *value ) +{ + hypre_ParCSRMatrix *A; + hypre_CSRMatrix *diag; + hypre_CSRMatrix *offd; + + HYPRE_Int *diag_i; + HYPRE_Int *diag_j; + HYPRE_Real *diag_data; + + HYPRE_Int *offd_i; + HYPRE_Int *offd_j = NULL; + HYPRE_BigInt *big_offd_j = NULL; + HYPRE_Real *offd_data = NULL; + + HYPRE_BigInt global_part[2]; + HYPRE_BigInt ix, iy, iz; + HYPRE_Int ip, iq, ir; + HYPRE_Int cnt, o_cnt; + HYPRE_Int local_num_rows; + HYPRE_BigInt *col_map_offd = NULL; + HYPRE_Int row_index; + HYPRE_Int i, j; + + HYPRE_Int nx_local, ny_local, nz_local; + HYPRE_Int num_cols_offd; + HYPRE_BigInt grid_size; + + HYPRE_BigInt *nx_part; + HYPRE_BigInt *ny_part; + HYPRE_BigInt *nz_part; + + HYPRE_Int num_procs; + HYPRE_Int P_busy, Q_busy, R_busy; + + hypre_MPI_Comm_size(comm, &num_procs); + + grid_size = nx * ny * nz; + + hypre_GeneratePartitioning(nx, P, &nx_part); + hypre_GeneratePartitioning(ny, Q, &ny_part); + hypre_GeneratePartitioning(nz, R, &nz_part); + + nx_local = (HYPRE_Int)(nx_part[p + 1] - nx_part[p]); + ny_local = (HYPRE_Int)(ny_part[q + 1] - ny_part[q]); + nz_local = (HYPRE_Int)(nz_part[r + 1] - nz_part[r]); + + local_num_rows = nx_local * ny_local * nz_local; + + ip = p; + iq = q; + ir = r; + + global_part[0] = nz_part[ir] * nx * ny + (ny_part[iq] * nx + nx_part[ip] * ny_local) * nz_local; + global_part[1] = global_part[0] + (HYPRE_BigInt)local_num_rows; + + diag_i = hypre_CTAlloc(HYPRE_Int, local_num_rows + 1, HYPRE_MEMORY_HOST); + offd_i = hypre_CTAlloc(HYPRE_Int, local_num_rows + 1, HYPRE_MEMORY_HOST); + + P_busy = hypre_min(nx, P); + Q_busy = hypre_min(ny, Q); + R_busy = hypre_min(nz, R); + + num_cols_offd = 0; + if (p) { num_cols_offd += ny_local * nz_local; } + if (p < P_busy - 1) { num_cols_offd += ny_local * nz_local; } + if (q) { num_cols_offd += nx_local * nz_local; } + if (q < Q_busy - 1) { num_cols_offd += nx_local * nz_local; } + if (r) { num_cols_offd += nx_local * ny_local; } + if (r < R_busy - 1) { num_cols_offd += nx_local * ny_local; } + + if (!local_num_rows) { num_cols_offd = 0; } + + cnt = 1; + o_cnt = 1; + diag_i[0] = 0; + offd_i[0] = 0; + for (iz = nz_part[ir]; iz < nz_part[ir + 1]; iz++) + { + for (iy = ny_part[iq]; iy < ny_part[iq + 1]; iy++) + { + for (ix = nx_part[ip]; ix < nx_part[ip + 1]; ix++) + { + diag_i[cnt] = diag_i[cnt - 1]; + offd_i[o_cnt] = offd_i[o_cnt - 1]; + diag_i[cnt]++; + if (iz > nz_part[ir]) + { + diag_i[cnt]++; + } + else + { + if (iz) + { + offd_i[o_cnt]++; + } + } + if (iy > ny_part[iq]) + { + diag_i[cnt]++; + } + else + { + if (iy) + { + offd_i[o_cnt]++; + } + } + if (ix > nx_part[ip]) + { + diag_i[cnt]++; + } + else + { + if (ix) + { + offd_i[o_cnt]++; + } + } + if (ix + 1 < nx_part[ip + 1]) + { + diag_i[cnt]++; + } + else + { + if (ix + 1 < nx) + { + offd_i[o_cnt]++; + } + } + if (iy + 1 < ny_part[iq + 1]) + { + diag_i[cnt]++; + } + else + { + if (iy + 1 < ny) + { + offd_i[o_cnt]++; + } + } + if (iz + 1 < nz_part[ir + 1]) + { + diag_i[cnt]++; + } + else + { + if (iz + 1 < nz) + { + offd_i[o_cnt]++; + } + } + cnt++; + o_cnt++; + } + } + } + + diag_j = hypre_CTAlloc(HYPRE_Int, diag_i[local_num_rows], HYPRE_MEMORY_HOST); + diag_data = hypre_CTAlloc(HYPRE_Real, diag_i[local_num_rows], HYPRE_MEMORY_HOST); + + if (offd_i[local_num_rows]) + { + offd_j = hypre_CTAlloc(HYPRE_Int, offd_i[local_num_rows], HYPRE_MEMORY_HOST); + big_offd_j = hypre_CTAlloc(HYPRE_BigInt, offd_i[local_num_rows], HYPRE_MEMORY_HOST); + offd_data = hypre_CTAlloc(HYPRE_Real, offd_i[local_num_rows], HYPRE_MEMORY_HOST); + } + + row_index = 0; + cnt = 0; + o_cnt = 0; + for (iz = nz_part[ir]; iz < nz_part[ir + 1]; iz++) + { + for (iy = ny_part[iq]; iy < ny_part[iq + 1]; iy++) + { + for (ix = nx_part[ip]; ix < nx_part[ip + 1]; ix++) + { + diag_j[cnt] = row_index; + diag_data[cnt++] = value[0]; + if (iz > nz_part[ir]) + { + diag_j[cnt] = row_index - nx_local * ny_local; + diag_data[cnt++] = value[3]; + } + else + { + if (iz) + { + big_offd_j[o_cnt] = map3(ix, iy, iz - 1, ip, iq, ir - 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[3]; + } + } + if (iy > ny_part[iq]) + { + diag_j[cnt] = row_index - nx_local; + diag_data[cnt++] = value[2]; + } + else + { + if (iy) + { + big_offd_j[o_cnt] = map3(ix, iy - 1, iz, ip, iq - 1, ir, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[2]; + } + } + if (ix > nx_part[ip]) + { + diag_j[cnt] = row_index - 1; + diag_data[cnt++] = value[1]; + } + else + { + if (ix) + { + big_offd_j[o_cnt] = map3(ix - 1, iy, iz, ip - 1, iq, ir, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[1]; + } + } + if (ix + 1 < nx_part[ip + 1]) + { + diag_j[cnt] = row_index + 1; + diag_data[cnt++] = value[4]; + } + else + { + if (ix + 1 < nx) + { + big_offd_j[o_cnt] = map3(ix + 1, iy, iz, ip + 1, iq, ir, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[4]; + } + } + if (iy + 1 < ny_part[iq + 1]) + { + diag_j[cnt] = row_index + nx_local; + diag_data[cnt++] = value[5]; + } + else + { + if (iy + 1 < ny) + { + big_offd_j[o_cnt] = map3(ix, iy + 1, iz, ip, iq + 1, ir, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[5]; + } + } + if (iz + 1 < nz_part[ir + 1]) + { + diag_j[cnt] = row_index + nx_local * ny_local; + diag_data[cnt++] = value[6]; + } + else + { + if (iz + 1 < nz) + { + big_offd_j[o_cnt] = map3(ix, iy, iz + 1, ip, iq, ir + 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = value[6]; + } + } + row_index++; + } + } + } + + if (num_cols_offd) + { + col_map_offd = hypre_CTAlloc(HYPRE_BigInt, num_cols_offd, HYPRE_MEMORY_HOST); + for (i = 0; i < num_cols_offd; i++) + { + col_map_offd[i] = big_offd_j[i]; + } + + hypre_BigQsort0(col_map_offd, 0, num_cols_offd - 1); + + for (i = 0; i < num_cols_offd; i++) + for (j = 0; j < num_cols_offd; j++) + if (big_offd_j[i] == col_map_offd[j]) + { + offd_j[i] = j; + break; + } + } + + A = hypre_ParCSRMatrixCreate(comm, grid_size, grid_size, + global_part, global_part, num_cols_offd, + diag_i[local_num_rows], + offd_i[local_num_rows]); + + hypre_ParCSRMatrixColMapOffd(A) = col_map_offd; + + diag = hypre_ParCSRMatrixDiag(A); + hypre_CSRMatrixI(diag) = diag_i; + hypre_CSRMatrixJ(diag) = diag_j; + hypre_CSRMatrixData(diag) = diag_data; + + offd = hypre_ParCSRMatrixOffd(A); + hypre_CSRMatrixI(offd) = offd_i; + if (num_cols_offd) + { + hypre_CSRMatrixJ(offd) = offd_j; + hypre_CSRMatrixData(offd) = offd_data; + } + + hypre_CSRMatrixMemoryLocation(diag) = HYPRE_MEMORY_HOST; + hypre_CSRMatrixMemoryLocation(offd) = HYPRE_MEMORY_HOST; + + hypre_ParCSRMatrixMigrate(A, hypre_HandleMemoryLocation(hypre_handle())); + + hypre_TFree(nx_part, HYPRE_MEMORY_HOST); + hypre_TFree(ny_part, HYPRE_MEMORY_HOST); + hypre_TFree(nz_part, HYPRE_MEMORY_HOST); + hypre_TFree(big_offd_j, HYPRE_MEMORY_HOST); + + return (HYPRE_ParCSRMatrix) A; +} + +/*-------------------------------------------------------------------------- + * hypre_GenerateVarDifConv + *--------------------------------------------------------------------------*/ + +HYPRE_ParCSRMatrix +GenerateVarDifConv( MPI_Comm comm, + HYPRE_BigInt nx, + HYPRE_BigInt ny, + HYPRE_BigInt nz, + HYPRE_Int P, + HYPRE_Int Q, + HYPRE_Int R, + HYPRE_Int p, + HYPRE_Int q, + HYPRE_Int r, + HYPRE_Real eps, + HYPRE_ParVector *rhs_ptr) +{ + hypre_ParCSRMatrix *A; + hypre_CSRMatrix *diag; + hypre_CSRMatrix *offd; + hypre_ParVector *par_rhs; + hypre_Vector *rhs; + HYPRE_Real *rhs_data; + + HYPRE_Int *diag_i; + HYPRE_Int *diag_j; + HYPRE_Real *diag_data; + + HYPRE_Int *offd_i = NULL; + HYPRE_Int *offd_j = NULL; + HYPRE_BigInt *big_offd_j = NULL; + HYPRE_Real *offd_data = NULL; + + HYPRE_BigInt global_part[2]; + HYPRE_BigInt ix, iy, iz; + HYPRE_Int cnt, o_cnt; + HYPRE_Int local_num_rows; + HYPRE_BigInt *col_map_offd; + HYPRE_Int row_index; + HYPRE_Int i, j; + + HYPRE_Int nx_local, ny_local, nz_local; + HYPRE_Int num_cols_offd; + HYPRE_BigInt grid_size; + + HYPRE_BigInt *nx_part; + HYPRE_BigInt *ny_part; + HYPRE_BigInt *nz_part; + + HYPRE_Int num_procs; + HYPRE_Int P_busy, Q_busy, R_busy; + + HYPRE_Real hhx, hhy, hhz; + HYPRE_Real xx, yy, zz; + HYPRE_Real afp, afm, bfp, bfm, cfp, cfm, df, ef, ff, gf; + + hypre_MPI_Comm_size(comm, &num_procs); + + grid_size = nx * ny * nz; + + hypre_GeneratePartitioning(nx, P, &nx_part); + hypre_GeneratePartitioning(ny, Q, &ny_part); + hypre_GeneratePartitioning(nz, R, &nz_part); + + nx_local = (HYPRE_Int)(nx_part[p + 1] - nx_part[p]); + ny_local = (HYPRE_Int)(ny_part[q + 1] - ny_part[q]); + nz_local = (HYPRE_Int)(nz_part[r + 1] - nz_part[r]); + + local_num_rows = nx_local * ny_local * nz_local; + + global_part[0] = nz_part[r] * nx * ny + (ny_part[q] * nx + nx_part[p] * ny_local) * nz_local; + global_part[1] = global_part[0] + (HYPRE_BigInt)local_num_rows; + + diag_i = hypre_CTAlloc(HYPRE_Int, local_num_rows + 1, HYPRE_MEMORY_HOST); + offd_i = hypre_CTAlloc(HYPRE_Int, local_num_rows + 1, HYPRE_MEMORY_HOST); + rhs_data = hypre_CTAlloc(HYPRE_Real, local_num_rows, HYPRE_MEMORY_HOST); + + P_busy = hypre_min(nx, P); + Q_busy = hypre_min(ny, Q); + R_busy = hypre_min(nz, R); + + num_cols_offd = 0; + if (p) { num_cols_offd += ny_local * nz_local; } + if (p < P_busy - 1) { num_cols_offd += ny_local * nz_local; } + if (q) { num_cols_offd += nx_local * nz_local; } + if (q < Q_busy - 1) { num_cols_offd += nx_local * nz_local; } + if (r) { num_cols_offd += nx_local * ny_local; } + if (r < R_busy - 1) { num_cols_offd += nx_local * ny_local; } + + if (!local_num_rows) { num_cols_offd = 0; } + + col_map_offd = hypre_CTAlloc(HYPRE_BigInt, num_cols_offd, HYPRE_MEMORY_HOST); + + hhx = 1.0 / (HYPRE_Real)(nx + 1); + hhy = 1.0 / (HYPRE_Real)(ny + 1); + hhz = 1.0 / (HYPRE_Real)(nz + 1); + + cnt = 1; + o_cnt = 1; + diag_i[0] = 0; + offd_i[0] = 0; + for (iz = nz_part[r]; iz < nz_part[r + 1]; iz++) + { + for (iy = ny_part[q]; iy < ny_part[q + 1]; iy++) + { + for (ix = nx_part[p]; ix < nx_part[p + 1]; ix++) + { + diag_i[cnt] = diag_i[cnt - 1]; + offd_i[o_cnt] = offd_i[o_cnt - 1]; + diag_i[cnt]++; + if (iz > nz_part[r]) + { + diag_i[cnt]++; + } + else + { + if (iz) + { + offd_i[o_cnt]++; + } + } + if (iy > ny_part[q]) + { + diag_i[cnt]++; + } + else + { + if (iy) + { + offd_i[o_cnt]++; + } + } + if (ix > nx_part[p]) + { + diag_i[cnt]++; + } + else + { + if (ix) + { + offd_i[o_cnt]++; + } + } + if (ix + 1 < nx_part[p + 1]) + { + diag_i[cnt]++; + } + else + { + if (ix + 1 < nx) + { + offd_i[o_cnt]++; + } + } + if (iy + 1 < ny_part[q + 1]) + { + diag_i[cnt]++; + } + else + { + if (iy + 1 < ny) + { + offd_i[o_cnt]++; + } + } + if (iz + 1 < nz_part[r + 1]) + { + diag_i[cnt]++; + } + else + { + if (iz + 1 < nz) + { + offd_i[o_cnt]++; + } + } + cnt++; + o_cnt++; + } + } + } + + diag_j = hypre_CTAlloc(HYPRE_Int, diag_i[local_num_rows], HYPRE_MEMORY_HOST); + diag_data = hypre_CTAlloc(HYPRE_Real, diag_i[local_num_rows], HYPRE_MEMORY_HOST); + + if (num_procs > 1) + { + big_offd_j = hypre_CTAlloc(HYPRE_BigInt, offd_i[local_num_rows], HYPRE_MEMORY_HOST); + offd_j = hypre_CTAlloc(HYPRE_Int, offd_i[local_num_rows], HYPRE_MEMORY_HOST); + offd_data = hypre_CTAlloc(HYPRE_Real, offd_i[local_num_rows], HYPRE_MEMORY_HOST); + } + + row_index = 0; + cnt = 0; + o_cnt = 0; + for (iz = nz_part[r]; iz < nz_part[r + 1]; iz++) + { + zz = (HYPRE_Real)(iz + 1) * hhz; + for (iy = ny_part[q]; iy < ny_part[q + 1]; iy++) + { + yy = (HYPRE_Real)(iy + 1) * hhy; + for (ix = nx_part[p]; ix < nx_part[p + 1]; ix++) + { + xx = (HYPRE_Real)(ix + 1) * hhx; + afp = eps * afun(xx + 0.5 * hhx, yy, zz) / hhx / hhx; + afm = eps * afun(xx - 0.5 * hhx, yy, zz) / hhx / hhx; + bfp = eps * bfun(xx, yy + 0.5 * hhy, zz) / hhy / hhy; + bfm = eps * bfun(xx, yy - 0.5 * hhy, zz) / hhy / hhy; + cfp = eps * cfun(xx, yy, zz + 0.5 * hhz) / hhz / hhz; + cfm = eps * cfun(xx, yy, zz - 0.5 * hhz) / hhz / hhz; + df = dfun(xx, yy, zz) / hhx; + ef = efun(xx, yy, zz) / hhy; + ff = ffun(xx, yy, zz) / hhz; + gf = gfun(xx, yy, zz); + diag_j[cnt] = row_index; + diag_data[cnt++] = afp + afm + bfp + bfm + cfp + cfm + gf - df - ef - ff; + rhs_data[row_index] = rfun(xx, yy, zz); + if (ix == 0) { rhs_data[row_index] += afm * bndfun(0, yy, zz); } + if (iy == 0) { rhs_data[row_index] += bfm * bndfun(xx, 0, zz); } + if (iz == 0) { rhs_data[row_index] += cfm * bndfun(xx, yy, 0); } + if (ix + 1 == nx) { rhs_data[row_index] += (afp - df) * bndfun(1.0, yy, zz); } + if (iy + 1 == ny) { rhs_data[row_index] += (bfp - ef) * bndfun(xx, 1.0, zz); } + if (iz + 1 == nz) { rhs_data[row_index] += (cfp - ff) * bndfun(xx, yy, 1.0); } + if (iz > nz_part[r]) + { + diag_j[cnt] = row_index - nx_local * ny_local; + diag_data[cnt++] = -cfm; + } + else + { + if (iz) + { + big_offd_j[o_cnt] = map3(ix, iy, iz - 1, p, q, r - 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = -cfm; + } + } + if (iy > ny_part[q]) + { + diag_j[cnt] = row_index - nx_local; + diag_data[cnt++] = -bfm; + } + else + { + if (iy) + { + big_offd_j[o_cnt] = map3(ix, iy - 1, iz, p, q - 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = -bfm; + } + } + if (ix > nx_part[p]) + { + diag_j[cnt] = row_index - 1; + diag_data[cnt++] = -afm; + } + else + { + if (ix) + { + big_offd_j[o_cnt] = map3(ix - 1, iy, iz, p - 1, q, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = -afm; + } + } + if (ix + 1 < nx_part[p + 1]) + { + diag_j[cnt] = row_index + 1; + diag_data[cnt++] = -afp + df; + } + else + { + if (ix + 1 < nx) + { + big_offd_j[o_cnt] = map3(ix + 1, iy, iz, p + 1, q, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = -afp + df; + } + } + if (iy + 1 < ny_part[q + 1]) + { + diag_j[cnt] = row_index + nx_local; + diag_data[cnt++] = -bfp + ef; + } + else + { + if (iy + 1 < ny) + { + big_offd_j[o_cnt] = map3(ix, iy + 1, iz, p, q + 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = -bfp + ef; + } + } + if (iz + 1 < nz_part[r + 1]) + { + diag_j[cnt] = row_index + nx_local * ny_local; + diag_data[cnt++] = -cfp + ff; + } + else + { + if (iz + 1 < nz) + { + big_offd_j[o_cnt] = map3(ix, iy, iz + 1, p, q, r + 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = -cfp + ff; + } + } + row_index++; + } + } + } + + if (num_procs > 1) + { + for (i = 0; i < num_cols_offd; i++) + { + col_map_offd[i] = big_offd_j[i]; + } + + hypre_BigQsort0(col_map_offd, 0, num_cols_offd - 1); + + for (i = 0; i < num_cols_offd; i++) + for (j = 0; j < num_cols_offd; j++) + if (big_offd_j[i] == col_map_offd[j]) + { + offd_j[i] = j; + break; + } + hypre_TFree(big_offd_j, HYPRE_MEMORY_HOST); + } + + par_rhs = hypre_ParVectorCreate(comm, grid_size, global_part); + rhs = hypre_ParVectorLocalVector(par_rhs); + hypre_VectorData(rhs) = rhs_data; + hypre_VectorMemoryLocation(rhs) = HYPRE_MEMORY_HOST; + + A = hypre_ParCSRMatrixCreate(comm, grid_size, grid_size, + global_part, global_part, num_cols_offd, + diag_i[local_num_rows], + offd_i[local_num_rows]); + + hypre_ParCSRMatrixColMapOffd(A) = col_map_offd; + + diag = hypre_ParCSRMatrixDiag(A); + hypre_CSRMatrixI(diag) = diag_i; + hypre_CSRMatrixJ(diag) = diag_j; + hypre_CSRMatrixData(diag) = diag_data; + + offd = hypre_ParCSRMatrixOffd(A); + hypre_CSRMatrixI(offd) = offd_i; + if (num_cols_offd) + { + hypre_CSRMatrixJ(offd) = offd_j; + hypre_CSRMatrixData(offd) = offd_data; + } + + hypre_CSRMatrixMemoryLocation(diag) = HYPRE_MEMORY_HOST; + hypre_CSRMatrixMemoryLocation(offd) = HYPRE_MEMORY_HOST; + + hypre_ParCSRMatrixMigrate(A, hypre_HandleMemoryLocation(hypre_handle())); + hypre_ParVectorMigrate(par_rhs, hypre_HandleMemoryLocation(hypre_handle())); + + hypre_TFree(nx_part, HYPRE_MEMORY_HOST); + hypre_TFree(ny_part, HYPRE_MEMORY_HOST); + hypre_TFree(nz_part, HYPRE_MEMORY_HOST); + + *rhs_ptr = (HYPRE_ParVector) par_rhs; + + return (HYPRE_ParCSRMatrix) A; +} + +/*-------------------------------------------------------------------------- + * hypre_GenerateVarDifConv: with the FD discretization and examples + * in Ruge-Stuben's paper ``Algebraic Multigrid'' + *--------------------------------------------------------------------------*/ + +HYPRE_ParCSRMatrix +GenerateRSVarDifConv( MPI_Comm comm, + HYPRE_BigInt nx, + HYPRE_BigInt ny, + HYPRE_BigInt nz, + HYPRE_Int P, + HYPRE_Int Q, + HYPRE_Int R, + HYPRE_Int p, + HYPRE_Int q, + HYPRE_Int r, + HYPRE_Real eps, + HYPRE_ParVector *rhs_ptr, + HYPRE_Int type) +{ + hypre_ParCSRMatrix *A; + hypre_CSRMatrix *diag; + hypre_CSRMatrix *offd; + hypre_ParVector *par_rhs; + hypre_Vector *rhs; + HYPRE_Real *rhs_data; + + HYPRE_Int *diag_i; + HYPRE_Int *diag_j; + HYPRE_Real *diag_data; + + HYPRE_Int *offd_i = NULL; + HYPRE_Int *offd_j = NULL; + HYPRE_BigInt *big_offd_j = NULL; + HYPRE_Real *offd_data = NULL; + + HYPRE_BigInt global_part[2]; + HYPRE_BigInt ix, iy, iz; + HYPRE_Int cnt, o_cnt; + HYPRE_Int local_num_rows; + HYPRE_BigInt *col_map_offd; + HYPRE_Int row_index; + HYPRE_Int i, j; + + HYPRE_Int nx_local, ny_local, nz_local; + HYPRE_Int num_cols_offd; + HYPRE_BigInt grid_size; + + + HYPRE_BigInt *nx_part; + HYPRE_BigInt *ny_part; + HYPRE_BigInt *nz_part; + + HYPRE_Int num_procs, my_id; + HYPRE_Int P_busy, Q_busy, R_busy; + + HYPRE_Real hhx, hhy, hhz; + HYPRE_Real xx, yy, zz; + HYPRE_Real afp, afm, bfp, bfm, cfp, cfm, di, ai, mux, ei, bi; + HYPRE_Real muy, fi, ci, muz, dfm, dfp, efm, efp, ffm, ffp, gi; + + HYPRE_Int rs_example = 1; + HYPRE_Real rs_l = 3.0; + + hypre_MPI_Comm_size(comm, &num_procs); + hypre_MPI_Comm_rank(comm, &my_id); + + if (type >= 1 && type <= 3) + { + rs_example = type; + } + + grid_size = nx * ny * nz; + + hypre_GeneratePartitioning(nx, P, &nx_part); + hypre_GeneratePartitioning(ny, Q, &ny_part); + hypre_GeneratePartitioning(nz, R, &nz_part); + + nx_local = (HYPRE_Int)(nx_part[p + 1] - nx_part[p]); + ny_local = (HYPRE_Int)(ny_part[q + 1] - ny_part[q]); + nz_local = (HYPRE_Int)(nz_part[r + 1] - nz_part[r]); + + local_num_rows = nx_local * ny_local * nz_local; + + global_part[0] = nz_part[r] * nx * ny + (ny_part[q] * nx + nx_part[p] * ny_local) * nz_local; + global_part[1] = global_part[0] + (HYPRE_BigInt)local_num_rows; + + diag_i = hypre_CTAlloc(HYPRE_Int, local_num_rows + 1, HYPRE_MEMORY_HOST); + offd_i = hypre_CTAlloc(HYPRE_Int, local_num_rows + 1, HYPRE_MEMORY_HOST); + rhs_data = hypre_CTAlloc(HYPRE_Real, local_num_rows, HYPRE_MEMORY_HOST); + + P_busy = hypre_min(nx, P); + Q_busy = hypre_min(ny, Q); + R_busy = hypre_min(nz, R); + + num_cols_offd = 0; + if (p) { num_cols_offd += ny_local * nz_local; } + if (p < P_busy - 1) { num_cols_offd += ny_local * nz_local; } + if (q) { num_cols_offd += nx_local * nz_local; } + if (q < Q_busy - 1) { num_cols_offd += nx_local * nz_local; } + if (r) { num_cols_offd += nx_local * ny_local; } + if (r < R_busy - 1) { num_cols_offd += nx_local * ny_local; } + + if (!local_num_rows) { num_cols_offd = 0; } + + col_map_offd = hypre_CTAlloc(HYPRE_BigInt, num_cols_offd, HYPRE_MEMORY_HOST); + + hhx = 1.0 / (HYPRE_Real)(nx + 1); + hhy = 1.0 / (HYPRE_Real)(ny + 1); + hhz = 1.0 / (HYPRE_Real)(nz + 1); + + cnt = 1; + o_cnt = 1; + diag_i[0] = 0; + offd_i[0] = 0; + for (iz = nz_part[r]; iz < nz_part[r + 1]; iz++) + { + for (iy = ny_part[q]; iy < ny_part[q + 1]; iy++) + { + for (ix = nx_part[p]; ix < nx_part[p + 1]; ix++) + { + diag_i[cnt] = diag_i[cnt - 1]; + offd_i[o_cnt] = offd_i[o_cnt - 1]; + diag_i[cnt]++; + if (iz > nz_part[r]) + { + diag_i[cnt]++; + } + else + { + if (iz) + { + offd_i[o_cnt]++; + } + } + if (iy > ny_part[q]) + { + diag_i[cnt]++; + } + else + { + if (iy) + { + offd_i[o_cnt]++; + } + } + if (ix > nx_part[p]) + { + diag_i[cnt]++; + } + else + { + if (ix) + { + offd_i[o_cnt]++; + } + } + if (ix + 1 < nx_part[p + 1]) + { + diag_i[cnt]++; + } + else + { + if (ix + 1 < nx) + { + offd_i[o_cnt]++; + } + } + if (iy + 1 < ny_part[q + 1]) + { + diag_i[cnt]++; + } + else + { + if (iy + 1 < ny) + { + offd_i[o_cnt]++; + } + } + if (iz + 1 < nz_part[r + 1]) + { + diag_i[cnt]++; + } + else + { + if (iz + 1 < nz) + { + offd_i[o_cnt]++; + } + } + cnt++; + o_cnt++; + } + } + } + + diag_j = hypre_CTAlloc(HYPRE_Int, diag_i[local_num_rows], HYPRE_MEMORY_HOST); + diag_data = hypre_CTAlloc(HYPRE_Real, diag_i[local_num_rows], HYPRE_MEMORY_HOST); + + if (num_procs > 1) + { + big_offd_j = hypre_CTAlloc(HYPRE_BigInt, offd_i[local_num_rows], HYPRE_MEMORY_HOST); + offd_j = hypre_CTAlloc(HYPRE_Int, offd_i[local_num_rows], HYPRE_MEMORY_HOST); + offd_data = hypre_CTAlloc(HYPRE_Real, offd_i[local_num_rows], HYPRE_MEMORY_HOST); + } + + row_index = 0; + cnt = 0; + o_cnt = 0; + for (iz = nz_part[r]; iz < nz_part[r + 1]; iz++) + { + zz = (HYPRE_Real)(iz + 1) * hhz; + for (iy = ny_part[q]; iy < ny_part[q + 1]; iy++) + { + yy = (HYPRE_Real)(iy + 1) * hhy; + for (ix = nx_part[p]; ix < nx_part[p + 1]; ix++) + { + xx = (HYPRE_Real)(ix + 1) * hhx; + afp = -eps * afun_rs(xx + 0.5 * hhx, yy, zz) / hhx / hhx; + afm = -eps * afun_rs(xx - 0.5 * hhx, yy, zz) / hhx / hhx; + bfp = -eps * bfun_rs(xx, yy + 0.5 * hhy, zz) / hhy / hhy; + bfm = -eps * bfun_rs(xx, yy - 0.5 * hhy, zz) / hhy / hhy; + cfp = -eps * cfun_rs(xx, yy, zz + 0.5 * hhz) / hhz / hhz; + cfm = -eps * cfun_rs(xx, yy, zz - 0.5 * hhz) / hhz / hhz; + /* first order terms */ + /* x-direction */ + di = dfun_rs(rs_example, rs_l, xx, yy, zz); + ai = afun_rs(xx, yy, zz); + if (di * hhx > eps * ai) + { + mux = eps * ai / (2.0 * di * hhx); + } + else if (di * hhx < -eps * ai) + { + mux = 1.0 + eps * ai / (2.0 * di * hhx); + } + else + { + mux = 0.5; + } + /* y-direction */ + ei = efun_rs(rs_example, rs_l, xx, yy, zz); + bi = bfun_rs(xx, yy, zz); + if (ei * hhy > eps * bi) + { + muy = eps * bi / (2.0 * ei * hhy); + } + else if (ei * hhy < -eps * bi) + { + muy = 1.0 + eps * bi / (2.0 * ei * hhy); + } + else + { + muy = 0.5; + } + /* z-direction */ + fi = ffun_rs(rs_example, rs_l, xx, yy, zz); + ci = cfun_rs(xx, yy, zz); + if (fi * hhz > eps * ci) + { + muz = eps * ci / (2.0 * fi * hhz); + } + else if (fi * hhz < -eps * ci) + { + muz = 1.0 + eps * ci / (2.0 * fi * hhz); + } + else + { + muz = 0.5; + } + + dfm = di * (mux - 1.0) / hhx; + dfp = di * mux / hhx; + efm = ei * (muy - 1.0) / hhy; + efp = ei * muy / hhy; + ffm = fi * (muz - 1.0) / hhz; + ffp = fi * muz / hhz; + gi = gfun_rs(xx, yy, zz); + /* stencil: center */ + diag_j[cnt] = row_index; + diag_data[cnt++] = -(afp + afm + bfp + bfm + cfp + cfm + + dfp + dfm + efp + efm + ffp + ffm) + gi; + /* rhs vector */ + rhs_data[row_index] = rfun_rs(xx, yy, zz); + /* apply boundary conditions */ + if (ix == 0) { rhs_data[row_index] -= (afm + dfm) * bndfun_rs(0, yy, zz); } + if (iy == 0) { rhs_data[row_index] -= (bfm + efm) * bndfun_rs(xx, 0, zz); } + if (iz == 0) { rhs_data[row_index] -= (cfm + ffm) * bndfun_rs(xx, yy, 0); } + if (ix + 1 == nx) { rhs_data[row_index] -= (afp + dfp) * bndfun_rs(1.0, yy, zz); } + if (iy + 1 == ny) { rhs_data[row_index] -= (bfp + efp) * bndfun_rs(xx, 1.0, zz); } + if (iz + 1 == nz) { rhs_data[row_index] -= (cfp + ffp) * bndfun_rs(xx, yy, 1.0); } + /* stencil: z- */ + if (iz > nz_part[r]) + { + diag_j[cnt] = row_index - nx_local * ny_local; + diag_data[cnt++] = cfm + ffm; + } + else + { + if (iz) + { + big_offd_j[o_cnt] = map3(ix, iy, iz - 1, p, q, r - 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = cfm + ffm; + } + } + /* stencil: y- */ + if (iy > ny_part[q]) + { + diag_j[cnt] = row_index - nx_local; + diag_data[cnt++] = bfm + efm; + } + else + { + if (iy) + { + big_offd_j[o_cnt] = map3(ix, iy - 1, iz, p, q - 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = bfm + efm; + } + } + /* stencil: x- */ + if (ix > nx_part[p]) + { + diag_j[cnt] = row_index - 1; + diag_data[cnt++] = afm + dfm; + } + else + { + if (ix) + { + big_offd_j[o_cnt] = map3(ix - 1, iy, iz, p - 1, q, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = afm + dfm; + } + } + /* stencil: x+ */ + if (ix + 1 < nx_part[p + 1]) + { + diag_j[cnt] = row_index + 1; + diag_data[cnt++] = afp + dfp; + } + else + { + if (ix + 1 < nx) + { + big_offd_j[o_cnt] = map3(ix + 1, iy, iz, p + 1, q, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = afp + dfp; + } + } + /* stencil: y+ */ + if (iy + 1 < ny_part[q + 1]) + { + diag_j[cnt] = row_index + nx_local; + diag_data[cnt++] = bfp + efp; + } + else + { + if (iy + 1 < ny) + { + big_offd_j[o_cnt] = map3(ix, iy + 1, iz, p, q + 1, r, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = bfp + efp; + } + } + /* stencil: z+ */ + if (iz + 1 < nz_part[r + 1]) + { + diag_j[cnt] = row_index + nx_local * ny_local; + diag_data[cnt++] = cfp + ffp; + } + else + { + if (iz + 1 < nz) + { + big_offd_j[o_cnt] = map3(ix, iy, iz + 1, p, q, r + 1, nx, ny, + nx_part, ny_part, nz_part); + offd_data[o_cnt++] = cfp + ffp; + } + } + /* done with this row */ + row_index++; + } + } + } + + if (num_procs > 1) + { + for (i = 0; i < num_cols_offd; i++) + { + col_map_offd[i] = big_offd_j[i]; + } + + hypre_BigQsort0(col_map_offd, 0, num_cols_offd - 1); + + for (i = 0; i < num_cols_offd; i++) + for (j = 0; j < num_cols_offd; j++) + if (big_offd_j[i] == col_map_offd[j]) + { + offd_j[i] = j; + break; + } + hypre_TFree(big_offd_j, HYPRE_MEMORY_HOST); + } + + par_rhs = hypre_ParVectorCreate(comm, grid_size, global_part); + rhs = hypre_ParVectorLocalVector(par_rhs); + hypre_VectorData(rhs) = rhs_data; + + A = hypre_ParCSRMatrixCreate(comm, grid_size, grid_size, + global_part, global_part, num_cols_offd, + diag_i[local_num_rows], + offd_i[local_num_rows]); + + hypre_ParCSRMatrixColMapOffd(A) = col_map_offd; + + diag = hypre_ParCSRMatrixDiag(A); + hypre_CSRMatrixI(diag) = diag_i; + hypre_CSRMatrixJ(diag) = diag_j; + hypre_CSRMatrixData(diag) = diag_data; + + offd = hypre_ParCSRMatrixOffd(A); + hypre_CSRMatrixI(offd) = offd_i; + if (num_cols_offd) + { + hypre_CSRMatrixJ(offd) = offd_j; + hypre_CSRMatrixData(offd) = offd_data; + } + + hypre_TFree(nx_part, HYPRE_MEMORY_HOST); + hypre_TFree(ny_part, HYPRE_MEMORY_HOST); + hypre_TFree(nz_part, HYPRE_MEMORY_HOST); + + *rhs_ptr = (HYPRE_ParVector) par_rhs; + + return (HYPRE_ParCSRMatrix) A; +} + +/*-------------------------------------------------------------------------- + *--------------------------------------------------------------------------*/ + +float * +GenerateCoordinates(HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, + HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, + HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, + HYPRE_Int coorddim) +{ + HYPRE_BigInt ix, iy, iz; + HYPRE_Int cnt; + + HYPRE_Int nx_local, ny_local, nz_local; + HYPRE_Int local_num_rows; + + HYPRE_BigInt *nx_part; + HYPRE_BigInt *ny_part; + HYPRE_BigInt *nz_part; + + float *coord = NULL; + + if (coorddim < 1 || coorddim > 3) + { + return NULL; + } + + hypre_GeneratePartitioning(nx, P, &nx_part); + hypre_GeneratePartitioning(ny, Q, &ny_part); + hypre_GeneratePartitioning(nz, R, &nz_part); + + nx_local = (HYPRE_Int)(nx_part[p + 1] - nx_part[p]); + ny_local = (HYPRE_Int)(ny_part[q + 1] - ny_part[q]); + nz_local = (HYPRE_Int)(nz_part[r + 1] - nz_part[r]); + + local_num_rows = nx_local * ny_local * nz_local; + if (!local_num_rows) + { + return NULL; + } + + coord = hypre_TAlloc(float, coorddim * local_num_rows, HYPRE_MEMORY_HOST); + + cnt = 0; + for (iz = nz_part[r]; iz < nz_part[r + 1]; iz++) + { + for (iy = ny_part[q]; iy < ny_part[q + 1]; iy++) + { + for (ix = nx_part[p]; ix < nx_part[p + 1]; ix++) + { + /* set coordinates BM Oct 17, 2006 */ + if (nx > 1) { coord[cnt++] = ix; } + if (ny > 1) { coord[cnt++] = iy; } + if (nz > 1) { coord[cnt++] = iz; } + } + } + } + + hypre_TFree(nx_part, HYPRE_MEMORY_HOST); + hypre_TFree(ny_part, HYPRE_MEMORY_HOST); + hypre_TFree(nz_part, HYPRE_MEMORY_HOST); + + return coord; +} diff --git a/src/test/ij_helpers.h b/src/test/ij_helpers.h new file mode 100644 index 0000000000..13fe2cd339 --- /dev/null +++ b/src/test/ij_helpers.h @@ -0,0 +1,64 @@ +/****************************************************************************** + * Copyright (c) 1998 Lawrence Livermore National Security, LLC and other + * HYPRE Project Developers. See the top-level COPYRIGHT file for details. + * + * SPDX-License-Identifier: (Apache-2.0 OR MIT) + ******************************************************************************/ + +#include "HYPRE_config.h" +#ifdef HYPRE_MIXED_PRECISION +#include "_hypre_mup_def.h" +#include "ij_helpers_mup.h" +#include "ij_helpers_mup_def.h" +#endif + +HYPRE_ParCSRMatrix GenerateLaplacian( MPI_Comm comm, + HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, + HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, + HYPRE_Int ip, HYPRE_Int iq, HYPRE_Int ir, + HYPRE_Real *value ); +HYPRE_ParCSRMatrix GenerateSysLaplacian( MPI_Comm comm, + HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, + HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, + HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, + HYPRE_Int num_fun, HYPRE_Real *mtrx, HYPRE_Real *value ); +HYPRE_ParCSRMatrix GenerateSysLaplacianVCoef( MPI_Comm comm, + HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, + HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, + HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, + HYPRE_Int num_fun, HYPRE_Real *mtrx, HYPRE_Real *value ); +HYPRE_ParCSRMatrix GenerateLaplacian9pt( MPI_Comm comm, + HYPRE_BigInt nx, HYPRE_BigInt ny, + HYPRE_Int P, HYPRE_Int Q, + HYPRE_Int p, HYPRE_Int q, + HYPRE_Real *value ); +HYPRE_ParCSRMatrix GenerateLaplacian27pt( MPI_Comm comm, + HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, + HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, + HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, + HYPRE_Real *value ); +HYPRE_ParCSRMatrix GenerateRotate7pt( MPI_Comm comm, + HYPRE_BigInt nx, HYPRE_BigInt ny, + HYPRE_Int P, HYPRE_Int Q, + HYPRE_Int p, HYPRE_Int q, + HYPRE_Real alpha, HYPRE_Real eps ); +HYPRE_ParCSRMatrix GenerateDifConv( MPI_Comm comm, + HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, + HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, + HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, + HYPRE_Real *value ); +HYPRE_ParCSRMatrix GenerateVarDifConv( MPI_Comm comm, + HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, + HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, + HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, + HYPRE_Real eps, HYPRE_ParVector *rhs_ptr ); +HYPRE_ParCSRMatrix GenerateRSVarDifConv( MPI_Comm comm, + HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, + HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, + HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, + HYPRE_Real eps, HYPRE_ParVector *rhs_ptr, + HYPRE_Int type ); +float * GenerateCoordinates( HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, + HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, + HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, + HYPRE_Int coorddim ); diff --git a/src/test/ij_helpers_mup.h b/src/test/ij_helpers_mup.h new file mode 100644 index 0000000000..6e161d9d5a --- /dev/null +++ b/src/test/ij_helpers_mup.h @@ -0,0 +1,123 @@ + +/*** DO NOT EDIT THIS FILE DIRECTLY (use ../config/gen_code.sh to generate) ***/ + +#ifndef hypre_IJ_HELPERS_MUP_HEADER +#define hypre_IJ_HELPERS_MUP_HEADER + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined (HYPRE_MIXED_PRECISION) + +/*** DO NOT EDIT THIS FILE DIRECTLY (use ../config/gen_code.sh to generate) ***/ + +/****************************************************************************** + * Copyright (c) 1998 Lawrence Livermore National Security, LLC and other + * HYPRE Project Developers. See the top-level COPYRIGHT file for details. + * + * SPDX-License-Identifier: (Apache-2.0 OR MIT) + ******************************************************************************/ + + +float * +GenerateCoordinates_flt( HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Int coorddim ); +float * +GenerateCoordinates_dbl( HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Int coorddim ); +float * +GenerateCoordinates_long_dbl( HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Int coorddim ); + +HYPRE_ParCSRMatrix +GenerateDifConv_flt( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, hypre_float *value ); +HYPRE_ParCSRMatrix +GenerateDifConv_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, hypre_double *value ); +HYPRE_ParCSRMatrix +GenerateDifConv_long_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, hypre_long_double *value ); + +HYPRE_ParCSRMatrix +GenerateLaplacian_flt( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int ip, HYPRE_Int iq, HYPRE_Int ir, hypre_float *value ); +HYPRE_ParCSRMatrix +GenerateLaplacian_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int ip, HYPRE_Int iq, HYPRE_Int ir, hypre_double *value ); +HYPRE_ParCSRMatrix +GenerateLaplacian_long_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int ip, HYPRE_Int iq, HYPRE_Int ir, hypre_long_double *value ); + +HYPRE_ParCSRMatrix +GenerateLaplacian27pt_flt( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, hypre_float *value ); +HYPRE_ParCSRMatrix +GenerateLaplacian27pt_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, hypre_double *value ); +HYPRE_ParCSRMatrix +GenerateLaplacian27pt_long_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, hypre_long_double *value ); + +HYPRE_ParCSRMatrix +GenerateLaplacian9pt_flt( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int p, HYPRE_Int q, hypre_float *value ); +HYPRE_ParCSRMatrix +GenerateLaplacian9pt_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int p, HYPRE_Int q, hypre_double *value ); +HYPRE_ParCSRMatrix +GenerateLaplacian9pt_long_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int p, HYPRE_Int q, hypre_long_double *value ); + +HYPRE_ParCSRMatrix +GenerateRSVarDifConv_flt( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, hypre_float eps, HYPRE_ParVector *rhs_ptr, HYPRE_Int type ); +HYPRE_ParCSRMatrix +GenerateRSVarDifConv_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, hypre_double eps, HYPRE_ParVector *rhs_ptr, HYPRE_Int type ); +HYPRE_ParCSRMatrix +GenerateRSVarDifConv_long_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, hypre_long_double eps, HYPRE_ParVector *rhs_ptr, HYPRE_Int type ); + +HYPRE_ParCSRMatrix +GenerateRotate7pt_flt( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int p, HYPRE_Int q, hypre_float alpha, hypre_float eps ); +HYPRE_ParCSRMatrix +GenerateRotate7pt_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int p, HYPRE_Int q, hypre_double alpha, hypre_double eps ); +HYPRE_ParCSRMatrix +GenerateRotate7pt_long_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int p, HYPRE_Int q, hypre_long_double alpha, hypre_long_double eps ); + +HYPRE_ParCSRMatrix +GenerateSysLaplacian_flt( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Int num_fun, hypre_float *mtrx, hypre_float *value ); +HYPRE_ParCSRMatrix +GenerateSysLaplacian_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Int num_fun, hypre_double *mtrx, hypre_double *value ); +HYPRE_ParCSRMatrix +GenerateSysLaplacian_long_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Int num_fun, hypre_long_double *mtrx, hypre_long_double *value ); + +HYPRE_ParCSRMatrix +GenerateSysLaplacianVCoef_flt( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Int num_fun, hypre_float *mtrx, hypre_float *value ); +HYPRE_ParCSRMatrix +GenerateSysLaplacianVCoef_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Int num_fun, hypre_double *mtrx, hypre_double *value ); +HYPRE_ParCSRMatrix +GenerateSysLaplacianVCoef_long_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Int num_fun, hypre_long_double *mtrx, hypre_long_double *value ); + +HYPRE_ParCSRMatrix +GenerateVarDifConv_flt( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, hypre_float eps, HYPRE_ParVector *rhs_ptr ); +HYPRE_ParCSRMatrix +GenerateVarDifConv_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, hypre_double eps, HYPRE_ParVector *rhs_ptr ); +HYPRE_ParCSRMatrix +GenerateVarDifConv_long_dbl( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, hypre_long_double eps, HYPRE_ParVector *rhs_ptr ); + + +/*** DO NOT EDIT THIS FILE DIRECTLY (use ../config/gen_code.sh to generate) ***/ + +/****************************************************************************** + * Copyright (c) 1998 Lawrence Livermore National Security, LLC and other + * HYPRE Project Developers. See the top-level COPYRIGHT file for details. + * + * SPDX-License-Identifier: (Apache-2.0 OR MIT) + ******************************************************************************/ + + + +/*** DO NOT EDIT THIS FILE DIRECTLY (use ../config/gen_code.sh to generate) ***/ + +/****************************************************************************** + * Copyright (c) 1998 Lawrence Livermore National Security, LLC and other + * HYPRE Project Developers. See the top-level COPYRIGHT file for details. + * + * SPDX-License-Identifier: (Apache-2.0 OR MIT) + ******************************************************************************/ + + + +#endif + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/src/test/ij_helpers_mup_def.h b/src/test/ij_helpers_mup_def.h new file mode 100644 index 0000000000..6c9509d566 --- /dev/null +++ b/src/test/ij_helpers_mup_def.h @@ -0,0 +1,29 @@ + +/*** DO NOT EDIT THIS FILE DIRECTLY (use ../config/gen_code.sh to generate) ***/ + +/****************************************************************************** + * Copyright (c) 1998 Lawrence Livermore National Security, LLC and other + * HYPRE Project Developers. See the top-level COPYRIGHT file for details. + * + * SPDX-License-Identifier: (Apache-2.0 OR MIT) + ******************************************************************************/ + +/* Header file for transforming multiprecision functions names */ + +#ifndef hypre_IJ_HELPERS_MUP_DEF_HEADER +#define hypre_IJ_HELPERS_MUP_DEF_HEADER + +#include "_hypre_mup_def.h" + +#define GenerateCoordinates HYPRE_FIXEDPRECISION_FUNC ( GenerateCoordinates ) +#define GenerateDifConv HYPRE_FIXEDPRECISION_FUNC ( GenerateDifConv ) +#define GenerateLaplacian HYPRE_FIXEDPRECISION_FUNC ( GenerateLaplacian ) +#define GenerateLaplacian27pt HYPRE_FIXEDPRECISION_FUNC ( GenerateLaplacian27pt ) +#define GenerateLaplacian9pt HYPRE_FIXEDPRECISION_FUNC ( GenerateLaplacian9pt ) +#define GenerateRSVarDifConv HYPRE_FIXEDPRECISION_FUNC ( GenerateRSVarDifConv ) +#define GenerateRotate7pt HYPRE_FIXEDPRECISION_FUNC ( GenerateRotate7pt ) +#define GenerateSysLaplacian HYPRE_FIXEDPRECISION_FUNC ( GenerateSysLaplacian ) +#define GenerateSysLaplacianVCoef HYPRE_FIXEDPRECISION_FUNC ( GenerateSysLaplacianVCoef ) +#define GenerateVarDifConv HYPRE_FIXEDPRECISION_FUNC ( GenerateVarDifConv ) + +#endif diff --git a/src/test/ij_helpers_mup_undef.h b/src/test/ij_helpers_mup_undef.h new file mode 100644 index 0000000000..ce90b18992 --- /dev/null +++ b/src/test/ij_helpers_mup_undef.h @@ -0,0 +1,24 @@ + +/*** DO NOT EDIT THIS FILE DIRECTLY (use ../config/gen_code.sh to generate) ***/ + +/****************************************************************************** + * Copyright (c) 1998 Lawrence Livermore National Security, LLC and other + * HYPRE Project Developers. See the top-level COPYRIGHT file for details. + * + * SPDX-License-Identifier: (Apache-2.0 OR MIT) + ******************************************************************************/ + +/* Header file for transforming multiprecision functions names */ + +#undef hypre_IJ_HELPERS_MUP_DEF_HEADER + +#undef GenerateCoordinates +#undef GenerateDifConv +#undef GenerateLaplacian +#undef GenerateLaplacian27pt +#undef GenerateLaplacian9pt +#undef GenerateRSVarDifConv +#undef GenerateRotate7pt +#undef GenerateSysLaplacian +#undef GenerateSysLaplacianVCoef +#undef GenerateVarDifConv diff --git a/src/test/ij_mm.c b/src/test/ij_mm.c index 10535ee670..3adae8c8fd 100644 --- a/src/test/ij_mm.c +++ b/src/test/ij_mm.c @@ -25,6 +25,7 @@ #include "_hypre_parcsr_ls.h" #include "_hypre_parcsr_mv.h" #include "HYPRE_krylov.h" +#include "ij_helpers.h" #ifdef HYPRE_USING_CUDA #include "cuda_profiler_api.h" @@ -2731,15 +2732,7 @@ BuildParCoordinates( HYPRE_Int argc, if (ny < 2) { coorddim--; } if (nz < 2) { coorddim--; } - if (coorddim > 0) - { - coordinates = hypre_GenerateCoordinates(hypre_MPI_COMM_WORLD, - nx, ny, nz, P, Q, R, p, q, r, coorddim); - } - else - { - coordinates = NULL; - } + coordinates = GenerateCoordinates(nx, ny, nz, P, Q, R, p, q, r, coorddim); *coorddim_ptr = coorddim; *coord_ptr = coordinates; diff --git a/src/test/ij_mp.c b/src/test/ij_mp.c index b3a8ddf7f6..d9a6458697 100644 --- a/src/test/ij_mp.c +++ b/src/test/ij_mp.c @@ -25,9 +25,10 @@ #include "HYPRE_IJ_mv.h" #include "HYPRE_parcsr_ls.h" -#include "_hypre_parcsr_ls.h" // Needed for GenerateSysLaplacian call below +//#include "_hypre_parcsr_ls.h" // Needed for GenerateSysLaplacian call below #include "_hypre_parcsr_mv.h" #include "HYPRE_krylov.h" +#include "ij_helpers.h" #include @@ -3221,5 +3222,3 @@ BuildParVarDifConv_mp( HYPRE_Int argc, return (0); } - - diff --git a/src/test/mup.fixed b/src/test/mup.fixed new file mode 100644 index 0000000000..2aaf7c4de1 --- /dev/null +++ b/src/test/mup.fixed @@ -0,0 +1,10 @@ +GenerateCoordinates +GenerateDifConv +GenerateLaplacian +GenerateLaplacian27pt +GenerateLaplacian9pt +GenerateRSVarDifConv +GenerateRotate7pt +GenerateSysLaplacian +GenerateSysLaplacianVCoef +GenerateVarDifConv diff --git a/src/test/mup.functions b/src/test/mup.functions new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/test/mup.methods b/src/test/mup.methods new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/test/mup_code b/src/test/mup_code new file mode 100755 index 0000000000..48aab7be82 --- /dev/null +++ b/src/test/mup_code @@ -0,0 +1,7 @@ +#!/bin/bash +# Copyright (c) 1998 Lawrence Livermore National Security, LLC and other +# HYPRE Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +../config/gen_code.sh ij_helpers.h ij_helpers.h mup diff --git a/src/test/mup_fixed.c b/src/test/mup_fixed.c new file mode 100644 index 0000000000..c4080b0fe2 --- /dev/null +++ b/src/test/mup_fixed.c @@ -0,0 +1,179 @@ + +/*** DO NOT EDIT THIS FILE DIRECTLY (use ../config/gen_code.sh to generate) ***/ + +#include "ij_helpers.h" + +#ifdef HYPRE_MIXED_PRECISION + +/****************************************************************************** + * Copyright (c) 1998 Lawrence Livermore National Security, LLC and other + * HYPRE Project Developers. See the top-level COPYRIGHT file for details. + * + * SPDX-License-Identifier: (Apache-2.0 OR MIT) + ******************************************************************************/ + + +/*--------------------------------------------------------------------------*/ + +float * +GenerateCoordinates( HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Int coorddim ) +{ + return HYPRE_CURRENTPRECISION_FUNC(GenerateCoordinates)( nx, ny, nz, P, Q, R, p, q, r, coorddim ); +} + +/*--------------------------------------------------------------------------*/ + +HYPRE_ParCSRMatrix +GenerateDifConv( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Real *value ) +{ + return HYPRE_CURRENTPRECISION_FUNC(GenerateDifConv)( comm, nx, ny, nz, P, Q, R, p, q, r, value ); +} + +/*--------------------------------------------------------------------------*/ + +HYPRE_ParCSRMatrix +GenerateLaplacian( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int ip, HYPRE_Int iq, HYPRE_Int ir, HYPRE_Real *value ) +{ + return HYPRE_CURRENTPRECISION_FUNC(GenerateLaplacian)( comm, nx, ny, nz, P, Q, R, ip, iq, ir, value ); +} + +/*--------------------------------------------------------------------------*/ + +HYPRE_ParCSRMatrix +GenerateLaplacian27pt( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Real *value ) +{ + return HYPRE_CURRENTPRECISION_FUNC(GenerateLaplacian27pt)( comm, nx, ny, nz, P, Q, R, p, q, r, value ); +} + +/*--------------------------------------------------------------------------*/ + +HYPRE_ParCSRMatrix +GenerateLaplacian9pt( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int p, HYPRE_Int q, HYPRE_Real *value ) +{ + return HYPRE_CURRENTPRECISION_FUNC(GenerateLaplacian9pt)( comm, nx, ny, P, Q, p, q, value ); +} + +/*--------------------------------------------------------------------------*/ + +HYPRE_ParCSRMatrix +GenerateRSVarDifConv( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Real eps, HYPRE_ParVector *rhs_ptr, HYPRE_Int type ) +{ + return HYPRE_CURRENTPRECISION_FUNC(GenerateRSVarDifConv)( comm, nx, ny, nz, P, Q, R, p, q, r, eps, rhs_ptr, type ); +} + +/*--------------------------------------------------------------------------*/ + +HYPRE_ParCSRMatrix +GenerateRotate7pt( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int p, HYPRE_Int q, HYPRE_Real alpha, HYPRE_Real eps ) +{ + return HYPRE_CURRENTPRECISION_FUNC(GenerateRotate7pt)( comm, nx, ny, P, Q, p, q, alpha, eps ); +} + +/*--------------------------------------------------------------------------*/ + +HYPRE_ParCSRMatrix +GenerateSysLaplacian( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Int num_fun, HYPRE_Real *mtrx, HYPRE_Real *value ) +{ + return HYPRE_CURRENTPRECISION_FUNC(GenerateSysLaplacian)( comm, nx, ny, nz, P, Q, R, p, q, r, num_fun, mtrx, value ); +} + +/*--------------------------------------------------------------------------*/ + +HYPRE_ParCSRMatrix +GenerateSysLaplacianVCoef( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Int num_fun, HYPRE_Real *mtrx, HYPRE_Real *value ) +{ + return HYPRE_CURRENTPRECISION_FUNC(GenerateSysLaplacianVCoef)( comm, nx, ny, nz, P, Q, R, p, q, r, num_fun, mtrx, value ); +} + +/*--------------------------------------------------------------------------*/ + +HYPRE_ParCSRMatrix +GenerateVarDifConv( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Real eps, HYPRE_ParVector *rhs_ptr ) +{ + return HYPRE_CURRENTPRECISION_FUNC(GenerateVarDifConv)( comm, nx, ny, nz, P, Q, R, p, q, r, eps, rhs_ptr ); +} + + +/*--------------------------------------------------------------------------*/ + +float * +GenerateCoordinates( HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Int coorddim ) +{ + return HYPRE_CURRENTPRECISION_FUNC(GenerateCoordinates)( nx, ny, nz, P, Q, R, p, q, r, coorddim ); +} + +/*--------------------------------------------------------------------------*/ + +HYPRE_ParCSRMatrix +GenerateDifConv( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Real *value ) +{ + return HYPRE_CURRENTPRECISION_FUNC(GenerateDifConv)( comm, nx, ny, nz, P, Q, R, p, q, r, value ); +} + +/*--------------------------------------------------------------------------*/ + +HYPRE_ParCSRMatrix +GenerateLaplacian( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int ip, HYPRE_Int iq, HYPRE_Int ir, HYPRE_Real *value ) +{ + return HYPRE_CURRENTPRECISION_FUNC(GenerateLaplacian)( comm, nx, ny, nz, P, Q, R, ip, iq, ir, value ); +} + +/*--------------------------------------------------------------------------*/ + +HYPRE_ParCSRMatrix +GenerateLaplacian27pt( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Real *value ) +{ + return HYPRE_CURRENTPRECISION_FUNC(GenerateLaplacian27pt)( comm, nx, ny, nz, P, Q, R, p, q, r, value ); +} + +/*--------------------------------------------------------------------------*/ + +HYPRE_ParCSRMatrix +GenerateLaplacian9pt( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int p, HYPRE_Int q, HYPRE_Real *value ) +{ + return HYPRE_CURRENTPRECISION_FUNC(GenerateLaplacian9pt)( comm, nx, ny, P, Q, p, q, value ); +} + +/*--------------------------------------------------------------------------*/ + +HYPRE_ParCSRMatrix +GenerateRSVarDifConv( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Real eps, HYPRE_ParVector *rhs_ptr, HYPRE_Int type ) +{ + return HYPRE_CURRENTPRECISION_FUNC(GenerateRSVarDifConv)( comm, nx, ny, nz, P, Q, R, p, q, r, eps, rhs_ptr, type ); +} + +/*--------------------------------------------------------------------------*/ + +HYPRE_ParCSRMatrix +GenerateRotate7pt( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int p, HYPRE_Int q, HYPRE_Real alpha, HYPRE_Real eps ) +{ + return HYPRE_CURRENTPRECISION_FUNC(GenerateRotate7pt)( comm, nx, ny, P, Q, p, q, alpha, eps ); +} + +/*--------------------------------------------------------------------------*/ + +HYPRE_ParCSRMatrix +GenerateSysLaplacian( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Int num_fun, HYPRE_Real *mtrx, HYPRE_Real *value ) +{ + return HYPRE_CURRENTPRECISION_FUNC(GenerateSysLaplacian)( comm, nx, ny, nz, P, Q, R, p, q, r, num_fun, mtrx, value ); +} + +/*--------------------------------------------------------------------------*/ + +HYPRE_ParCSRMatrix +GenerateSysLaplacianVCoef( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Int num_fun, HYPRE_Real *mtrx, HYPRE_Real *value ) +{ + return HYPRE_CURRENTPRECISION_FUNC(GenerateSysLaplacianVCoef)( comm, nx, ny, nz, P, Q, R, p, q, r, num_fun, mtrx, value ); +} + +/*--------------------------------------------------------------------------*/ + +HYPRE_ParCSRMatrix +GenerateVarDifConv( MPI_Comm comm, HYPRE_BigInt nx, HYPRE_BigInt ny, HYPRE_BigInt nz, HYPRE_Int P, HYPRE_Int Q, HYPRE_Int R, HYPRE_Int p, HYPRE_Int q, HYPRE_Int r, HYPRE_Real eps, HYPRE_ParVector *rhs_ptr ) +{ + return HYPRE_CURRENTPRECISION_FUNC(GenerateVarDifConv)( comm, nx, ny, nz, P, Q, R, p, q, r, eps, rhs_ptr ); +} + + +#endif + diff --git a/src/test/mup_functions.c b/src/test/mup_functions.c new file mode 100644 index 0000000000..56fa74f8ca --- /dev/null +++ b/src/test/mup_functions.c @@ -0,0 +1,19 @@ + +/*** DO NOT EDIT THIS FILE DIRECTLY (use ../config/gen_code.sh to generate) ***/ + +#include "ij_helpers.h" + +#ifdef HYPRE_MIXED_PRECISION + +/****************************************************************************** + * Copyright (c) 1998 Lawrence Livermore National Security, LLC and other + * HYPRE Project Developers. See the top-level COPYRIGHT file for details. + * + * SPDX-License-Identifier: (Apache-2.0 OR MIT) + ******************************************************************************/ + + + + +#endif + diff --git a/src/test/mup_pre.c b/src/test/mup_pre.c new file mode 100644 index 0000000000..56fa74f8ca --- /dev/null +++ b/src/test/mup_pre.c @@ -0,0 +1,19 @@ + +/*** DO NOT EDIT THIS FILE DIRECTLY (use ../config/gen_code.sh to generate) ***/ + +#include "ij_helpers.h" + +#ifdef HYPRE_MIXED_PRECISION + +/****************************************************************************** + * Copyright (c) 1998 Lawrence Livermore National Security, LLC and other + * HYPRE Project Developers. See the top-level COPYRIGHT file for details. + * + * SPDX-License-Identifier: (Apache-2.0 OR MIT) + ******************************************************************************/ + + + + +#endif +