2 #include <petsc/finclude/petscksp.h>
13 real(dp),
dimension(:),
pointer,
contiguous :: array => null()
38 character(len=*) :: name
39 character(len=*) :: mem_path
41 petscerrorcode :: ierr
43 this%is_mem_managed = .true.
47 call veccreatempiwitharray(petsc_comm_world, 1, n, petsc_decide, &
48 this%array, this%vec_impl, ierr)
50 call veccreateseqwitharray(petsc_comm_world, 1, n, this%array, &
55 call this%zero_entries()
65 petscerrorcode :: ierr
67 this%is_mem_managed = .false.
69 allocate (this%array(n))
71 call veccreatempiwitharray(petsc_comm_world, 1, n, petsc_decide, &
72 this%array, this%vec_impl, ierr)
74 call veccreateseqwitharray(petsc_comm_world, 1, n, this%array, &
79 call this%zero_entries()
88 petscerrorcode :: ierr
90 call vecdestroy(this%vec_impl, ierr)
92 if (this%is_mem_managed)
then
95 deallocate (this%array)
104 real(dp),
dimension(:),
pointer,
contiguous :: array
112 integer(I4B) :: start
115 petscerrorcode :: ierr
118 call vecgetownershiprange(this%vec_impl, start,
end, ierr)
131 petscerrorcode :: ierr
133 call vecgetsize(this%vec_impl,
size, ierr)
145 val = this%array(idx)
154 petscerrorcode :: ierr
156 call veczeroentries(this%vec_impl, ierr)
158 call vecassemblybegin(this%vec_impl, ierr)
160 call vecassemblyend(this%vec_impl, ierr)
172 this%array(idx) = val
181 class(vectorbasetype),
pointer :: vec_x
183 petscerrorcode :: ierr
191 call vecaxpy(this%vec_impl, alpha, x%vec_impl, ierr)
202 petscerrorcode :: ierr
204 call vecnorm(this%vec_impl, norm_2, n2, ierr)
212 petscerrorcode :: ierr
214 call vecview(this%vec_impl, petsc_viewer_stdout_world, ierr)
This module contains simulation constants.
real(dp), parameter dzero
real constant zero
This module defines variable data types.
subroutine petsc_vec_print(this)
real(dp) function petsc_vec_norm2(this)
Calculate this vector's (global) 2-norm.
real(dp) function petsc_vec_get_value_local(this, idx)
Gets a value from the vector at the local index.
subroutine petsc_vec_get_ownership_range(this, start, end)
subroutine petsc_vec_destroy(this)
Clean up.
subroutine petsc_vec_create(this, n)
Create a PETSc vector, with memory.
subroutine petsc_vec_create_mm(this, n, name, mem_path)
Create a PETSc vector, with memory.
subroutine petsc_vec_axpy(this, alpha, vec_x)
Calculate AXPY: y = a*x + y.
integer(i4b) function petsc_vec_get_size(this)
real(dp) function, dimension(:), pointer, contiguous petsc_vec_get_array(this)
Get a pointer to the underlying data array.
subroutine petsc_vec_zero_entries(this)
set all elements to zero
subroutine petsc_vec_set_value_local(this, idx, val)
Set vector value at local index.
This module contains simulation variables.
character(len=linelength) simulation_mode