Sets up the discretization stencil. Each entry represents the relative offset (in index space) E.g.: a 2D 5-pt stencil would have the following geometry -- Offset { {0,0}, {-1,0}, {1,0}, {0,-1}, {0,1} } E.g.: a 3D 7-pt stencil would have the following geometry -- Offset { {0,0,0}, {-1,0,0}, {1,0,0}, {0,-1,0}, {0,1,0}, {0,0,-1}, {0,0,1} }
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hypre_obj), | intent(inout) | :: | this |
Hypre machinery |
impure subroutine hypre_obj_SetupStencilS(this) !> Sets up the discretization stencil. ! Each entry represents the relative offset (in index space) ! E.g.: a 2D 5-pt stencil would have the following geometry ! -- Offset { {0,0}, {-1,0}, {1,0}, {0,-1}, {0,1} } ! E.g.: a 3D 7-pt stencil would have the following geometry ! -- Offset { {0,0,0}, {-1,0,0}, {1,0,0}, {0,-1,0}, {0,1,0}, {0,0,-1}, {0,0,1} } implicit none class(hypre_obj), intent(inout) :: this !! Hypre machinery ! Work variables integer, allocatable :: offset(:,:) integer, allocatable :: offset_(:) integer :: n integer :: ierr ! Determine stencil size this%st_size= 1+2*this%dim*this%st ! Create an empty stencil object call HYPRE_StructStencilCreate(this%dim,this%st_size,this%stencil,ierr) ! Set the stencil entries allocate(offset(this%st_size,this%dim)) allocate(offset_(this%dim)) ! Offsets of a 7-point stencil select case (this%dim) case (2) offset(1,:)=[ 0, 0] offset(2,:)=[-1, 0] offset(3,:)=[ 1, 0] offset(4,:)=[ 0,-1] offset(5,:)=[ 0, 1] case (3) offset(1,:)=[ 0, 0, 0] offset(2,:)=[-1, 0, 0] offset(3,:)=[ 1, 0, 0] offset(4,:)=[ 0,-1, 0] offset(5,:)=[ 0, 1, 0] offset(6,:)=[ 0, 0,-1] offset(7,:)=[ 0, 0, 1] end select ! Assign stencil entries do n=1,this%st_size offset_=offset(n,1:this%dim) call HYPRE_StructStencilSetElement(this%stencil,n-1,offset_,ierr) end do deallocate(offset,offset_) return end subroutine hypre_obj_SetupStencilS