Skip to content

Commit

Permalink
Merge pull request #1655 from ExtremeFLOW/fix/example_poisson
Browse files Browse the repository at this point in the history
Fix Poisson example
  • Loading branch information
njansson authored Jan 6, 2025
2 parents 6e1ab93 + 878bb41 commit 18649dd
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 19 deletions.
46 changes: 32 additions & 14 deletions examples/poisson/ax_poisson.f90
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
module ax_poisson
use ax_product
use ax_product
use mxm_wrapper
use mesh
use space
use coefs
use math
use num_types
use utils
implicit none

type, public, extends(ax_t) :: ax_poisson_t
contains
procedure, nopass :: compute => ax_poisson_compute
procedure, nopass :: compute => ax_poisson_compute
procedure, pass(this) :: compute_vector => ax_poisson_compute_vector
end type ax_poisson_t

contains

subroutine ax_poisson_compute(w, u, coef, msh, Xh)
type(mesh_t), intent(inout) :: msh
type(space_t), intent(inout) :: Xh
type(coef_t), intent(inout) :: coef
real(kind=rp), intent(inout) :: w(Xh%lx, Xh%ly, Xh%lz, msh%nelv)
real(kind=rp), intent(inout) :: u(Xh%lx, Xh%ly, Xh%lz, msh%nelv)

real(kind=rp) :: ur(Xh%lx**3)
real(kind=rp) :: us(Xh%lx**3)
real(kind=rp) :: ut(Xh%lx**3)
real(kind=rp) :: wk(Xh%lx**3)
integer :: e

do e = 1, msh%nelv
call ax_e(w(1,1,1,e), u(1,1,1,e), &
coef%g11(1,1,1,e), coef%g22(1,1,1,e), coef%g33(1,1,1,e), &
Expand All @@ -54,16 +56,16 @@ subroutine ax_e(w, u, g11, g22, g33, ur, us, ut, wk, lx, D, Dt)

n = lx - 1
call local_grad3(ur, us, ut, u, n, D, Dt)
do i=1, lx**3

do i = 1, lx**3
wr = g11(i)*ur(i)
ws = g22(i)*us(i)
wt = g33(i)*ut(i)
ur(i) = wr
us(i) = ws
ut(i) = wt
enddo
end do

call local_grad3_t(w, ur, us, ut, n, D, Dt, wk)

end subroutine ax_e
Expand All @@ -82,9 +84,9 @@ subroutine local_grad3(ur, us, ut, u, n, D, Dt)
m2 = m1*m1

call mxm(D ,m1,u,m1,ur,m2)
do k=0,n
do k = 0, n
call mxm(u(0,0,k),m1,Dt,m1,us(0,0,k),m1)
enddo
end do
call mxm(u,m2,Dt,m1,ut,m1)

end subroutine local_grad3
Expand All @@ -106,14 +108,30 @@ subroutine local_grad3_t(u,ur,us,ut,N,D,Dt,w)

call mxm(Dt,m1,ur,m1,u,m2)

do k=0,N
do k = 0, N
call mxm(us(0,0,k),m1,D ,m1,w(0,0,k),m1)
enddo
end do
call add2(u,w,m3)

call mxm(ut,m2,D ,m1,w,m1)
call add2(u,w,m3)

end subroutine local_grad3_t


subroutine ax_poisson_compute_vector(this, au, av, aw, u, v, w, coef, msh, Xh)
class(ax_poisson_t), intent(in) :: this
type(space_t), intent(inout) :: Xh
type(mesh_t), intent(inout) :: msh
type(coef_t), intent(inout) :: coef
real(kind=rp), intent(inout) :: au(Xh%lx, Xh%ly, Xh%lz, msh%nelv)
real(kind=rp), intent(inout) :: av(Xh%lx, Xh%ly, Xh%lz, msh%nelv)
real(kind=rp), intent(inout) :: aw(Xh%lx, Xh%ly, Xh%lz, msh%nelv)
real(kind=rp), intent(inout) :: u(Xh%lx, Xh%ly, Xh%lz, msh%nelv)
real(kind=rp), intent(inout) :: v(Xh%lx, Xh%ly, Xh%lz, msh%nelv)
real(kind=rp), intent(inout) :: w(Xh%lx, Xh%ly, Xh%lz, msh%nelv)

call neko_error('Not in use')

end subroutine ax_poisson_compute_vector

end module ax_poisson
10 changes: 6 additions & 4 deletions examples/poisson/driver.f90
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ program poisson
type(field_t) :: x
type(ax_poisson_t) :: ax
type(coef_t) :: coef
type(cg_t) :: solver
class(ksp_t), allocatable :: solver
type(ksp_monitor_t) :: ksp_mon
integer :: argc, lx, n, n_glb, niter, ierr
character(len=80) :: suffix
Expand All @@ -31,7 +31,9 @@ program poisson
stop
end if

call neko_init
call neko_init
call neko_job_info

call get_command_argument(1, fname)
call get_command_argument(2, lxchar)
call get_command_argument(3, iterchar)
Expand All @@ -52,7 +54,7 @@ program poisson

n = Xh%lx * Xh%ly * Xh%lz * msh%nelv

call dir_bc%init(coef)
call dir_bc%init_base(coef)
call dir_bc%set_g(real(0.0d0,rp))

!user specified
Expand All @@ -61,7 +63,7 @@ program poisson
call dir_bc%finalize()
call bclst%init()
call bclst%append(dir_bc)
call solver%init(n, niter, abs_tol = tol)
call krylov_solver_factory(solver, n, 'cg', niter, abstol = tol)

allocate(f(n))

Expand Down
2 changes: 1 addition & 1 deletion src/.depends
Original file line number Diff line number Diff line change
Expand Up @@ -333,4 +333,4 @@ wall_models/wall_model.lo : wall_models/wall_model.f90 common/log.lo comm/comm.l
wall_models/rough_log_law.lo : wall_models/rough_log_law.f90 common/utils.lo common/json_utils.lo field/field_registry.lo wall_models/wall_model.lo config/neko_config.lo sem/coef.lo sem/dofmap.lo config/num_types.lo field/field.lo
wall_models/spalding.lo : wall_models/spalding.f90 common/utils.lo common/log.lo common/json_utils.lo field/field_registry.lo wall_models/wall_model.lo config/neko_config.lo sem/coef.lo sem/dofmap.lo config/num_types.lo field/field.lo
wall_models/wall_model_fctry.lo : wall_models/wall_model_fctry.f90 common/json_utils.lo common/utils.lo wall_models/rough_log_law.lo wall_models/spalding.lo les/vreman.lo wall_models/wall_model.lo
neko.lo : neko.f90 common/json_utils.lo common/runtime_statistics.lo bc/field_dirichlet_vector.lo bc/field_dirichlet.lo mesh/point_zone_registry.lo mesh/point_zones/sphere_point_zone.lo mesh/point_zones/box_point_zone.lo mesh/point_zone.lo sem/point_interpolator.lo common/time_interpolator.lo io/data_streamer.lo simulation_components/simcomp_executor.lo field/scratch_registry.lo field/field_registry.lo qoi/drag_torque.lo common/system.lo simulation_components/spectral_error.lo simulation_components/probes.lo simulation_components/simulation_component.lo math/tensor.lo math/matrix.lo math/vector.lo scalar/scalar_user_source_term.lo fluid/fluid_user_source_term.lo field/field_list.lo fluid/fluid_stats.lo sem/cpr.lo sem/map_2d.lo sem/map_1d.lo math/bcknd/device/device_math.lo device/device.lo common/jobctrl.lo common/signal.lo common/user_intf.lo common/projection.lo math/mathops.lo math/operators.lo simulation.lo io/output.lo io/output_controller.lo case.lo config/neko_config.lo comm/parmetis.lo math/ax.lo bc/dirichlet.lo bc/wall.lo bc/bc.lo sem/coef.lo gs/gather_scatter.lo comm/mpi_types.lo field/field.lo io/file.lo common/global_interpolation.lo math/mxm_wrapper.lo io/format/map.lo field/mesh_field.lo mesh/point.lo mesh/mesh.lo adt/tuple.lo adt/stack.lo adt/uset.lo adt/htable.lo sem/space.lo sem/dofmap.lo sem/speclib.lo math/math.lo common/log.lo common/utils.lo comm/comm.lo config/num_types.lo
neko.lo : neko.f90 common/json_utils.lo common/runtime_statistics.lo bc/field_dirichlet_vector.lo bc/field_dirichlet.lo mesh/point_zone_registry.lo mesh/point_zones/sphere_point_zone.lo mesh/point_zones/box_point_zone.lo mesh/point_zone.lo sem/point_interpolator.lo common/time_interpolator.lo io/data_streamer.lo simulation_components/simcomp_executor.lo field/scratch_registry.lo field/field_registry.lo qoi/drag_torque.lo common/system.lo simulation_components/spectral_error.lo simulation_components/probes.lo simulation_components/simulation_component.lo math/tensor.lo math/matrix.lo math/vector.lo scalar/scalar_user_source_term.lo fluid/fluid_user_source_term.lo field/field_list.lo fluid/fluid_stats.lo sem/cpr.lo sem/map_2d.lo sem/map_1d.lo math/bcknd/device/device_math.lo device/device.lo common/jobctrl.lo common/signal.lo common/user_intf.lo common/projection.lo math/mathops.lo math/operators.lo simulation.lo io/output.lo io/output_controller.lo case.lo config/neko_config.lo comm/parmetis.lo math/ax.lo bc/dirichlet.lo bc/wall.lo bc/bc_list.lo bc/bc.lo sem/coef.lo krylov/krylov.lo gs/gather_scatter.lo comm/mpi_types.lo field/field.lo io/file.lo common/global_interpolation.lo math/mxm_wrapper.lo io/format/map.lo field/mesh_field.lo mesh/point.lo mesh/mesh.lo adt/tuple.lo adt/stack.lo adt/uset.lo adt/htable.lo sem/space.lo sem/dofmap.lo sem/speclib.lo math/math.lo common/log.lo common/utils.lo comm/comm.lo config/num_types.lo
2 changes: 2 additions & 0 deletions src/neko.f90
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ module neko
use field, only : field_t, field_ptr_t
use neko_mpi_types
use gather_scatter
use krylov
use coefs, only : coef_t
use bc
use bc_list
use wall, only : no_slip_wall_t
use dirichlet, only : dirichlet_t
use ax_product, only : ax_t, ax_helm_factory
Expand Down

0 comments on commit 18649dd

Please sign in to comment.