Skip to content

Commit f94da89

Browse files
committed
chore: attempt getter, setter for mimetic order
1 parent 404b79c commit f94da89

File tree

3 files changed

+67
-4
lines changed

3 files changed

+67
-4
lines changed

src/matcha/mimetic_m.f90

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,19 @@ module mimetic_m
99
public :: mimetic_t
1010
public :: operator(.div.)
1111

12+
1213
type, extends(subdomain_t) :: mimetic_t
14+
private
15+
! Interpolating weights
16+
real, allocatable :: Q_(:)
17+
real, allocatable :: P_(:)
18+
integer :: mimetic_k_ = 2 ! Order 2, 4 or 6
1319
contains
20+
procedure, pass(self) :: setOrder
1421
generic :: operator(.grad.) => gradient
1522
procedure, private :: gradient
16-
end type
23+
procedure mimetic_k
24+
end type
1725

1826
interface operator(.div.)
1927

@@ -33,6 +41,18 @@ module function gradient(rhs) result(gradient_rhs)
3341
type(mimetic_t), allocatable :: gradient_rhs(:)
3442
end function
3543

44+
module subroutine setOrder(my_k, self)
45+
implicit none
46+
integer, intent(in) :: my_k
47+
class(mimetic_t), intent(out) :: self
48+
end subroutine
49+
50+
pure module function mimetic_k(self) result(my_k)
51+
implicit none
52+
class(mimetic_t), intent(in) :: self
53+
real my_k
54+
end function
55+
3656
end interface
3757

3858
end module

src/matcha/mimetic_s.f90

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,13 @@
1515
allocate(gradient_rhs(3))
1616
call gradient_rhs%subdomain_t%define(side=1., boundary_val=0., internal_val=0., n=21)
1717
end procedure
18-
18+
19+
module procedure setOrder
20+
self%mimetic_k_ = my_k
21+
end procedure
22+
23+
module procedure mimetic_k
24+
my_k = self%mimetic_k_
25+
end procedure
26+
1927
end submodule mimetic_s

test/mimetic_test_m.F90

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,18 @@ function results() result(test_results)
3939

4040
#if HAVE_MULTI_IMAGE_SUPPORT
4141
test_descriptions = [ &
42-
test_description_t("the divergence of a gradient matching a Laplacian", div_grad_matches_laplacian) &
42+
test_description_t("the divergence of a gradient matching a Laplacian - Multi-Image", div_grad_matches_laplacian) &
43+
,test_description_t("div test1 - Multi-Image", div_test1) &
4344
]
4445
#else
4546
procedure(diagnosis_function_i), pointer :: div_grad_matches_laplacian_ptr
47+
procedure(diagnosis_function_i), pointer :: div_test1_ptr
4648
div_grad_matches_laplacian_ptr => div_grad_matches_laplacian
49+
div_test1_ptr => div_test1
4750

4851
test_descriptions = [ &
49-
test_description_t("the divergence of a gradient matching a Laplacian", div_grad_matches_laplacian_ptr) &
52+
test_description_t("the divergence of a gradient matching a Laplacian - Non Mult-Image", div_grad_matches_laplacian_ptr) &
53+
,test_description_t("div test1 - Non Multi-Image", div_test1_ptr) &
5054
]
5155
#endif
5256
test_results = test_descriptions%run()
@@ -57,6 +61,8 @@ function div_grad_matches_laplacian() result(test_diagnosis)
5761
real, parameter :: tolerance = 1.E-06
5862
type(mimetic_t) phi
5963

64+
! For now I'll use n = order*2 + 1, = 5
65+
6066
call phi%define(side=1., boundary_val=0., internal_val=0., n=21)
6167

6268
#ifndef __GFORTRAN__
@@ -73,4 +79,33 @@ function div_grad_matches_laplacian() result(test_diagnosis)
7379
#endif
7480
end function
7581

82+
function div_test1() result(test_diagnosis)
83+
type(test_diagnosis_t) test_diagnosis
84+
real, parameter :: tolerance = 1.E-06
85+
type(mimetic_t) phi
86+
integer :: mimetic_k
87+
88+
call phi%define(side=1., boundary_val=0., internal_val=0., n=21)
89+
!call phi%setOrder(my_k=2)
90+
mimetic_k = phi%mimetic_k()
91+
write (*,*) "mimetic_k = ", mimetic_k
92+
93+
#ifndef __GFORTRAN__
94+
#else
95+
block
96+
type(mimetic_t) div_grad_phi, laplacian_phi
97+
div_grad_phi = .div. (.grad. phi)
98+
laplacian_phi = .laplacian. phi
99+
end block
100+
#endif
101+
102+
test_diagnosis = test_diagnosis_t( &
103+
test_passed = .true. &
104+
,diagnostics_string = "Test passed" &
105+
)
106+
107+
108+
end function
109+
110+
76111
end module mimetic_test_m

0 commit comments

Comments
 (0)