Skip to content

Commit ec620bb

Browse files
committed
Merge branch 'release/0.2.1'
2 parents d6f322d + d2499f9 commit ec620bb

24 files changed

+782
-100
lines changed

src/lib/abstract_objects/wenoof_base_object.f90

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,17 @@ module wenoof_base_object
1515

1616
type, abstract :: base_object_constructor
1717
!< Abstract base object constructor.
18-
integer(I_P) :: S=0_I_P !< Stencils dimension.
19-
real(R_P) :: eps=EPS_DEF !< Small epsilon to avoid division by zero.
18+
integer(I_P) :: S=0_I_P !< Stencils dimension.
19+
real(R_P) :: eps=EPS_DEF !< Small epsilon to avoid division by zero.
2020
contains
21+
! public methods
2122
procedure, pass(self) :: create => create_base_object_constructor
23+
! public operators
24+
generic :: assignment(=) => constr_assign_constr !< `=` overloading.
25+
! public deferred methods
26+
procedure(constr_assign_constr_interface), pass(lhs), deferred :: constr_assign_constr !< `=` operator.
27+
! public non overridable methods
28+
procedure, pass(lhs), non_overridable :: assign_ => assign_constr_ !< Assign object.
2229
endtype base_object_constructor
2330

2431
type, abstract :: base_object
@@ -28,17 +35,38 @@ module wenoof_base_object
2835
integer(I_P) :: S=0_I_P !< Stencils dimension.
2936
real(R_P) :: eps=EPS_DEF !< Small epsilon to avoid division by zero.
3037
contains
38+
! public operators
39+
generic :: assignment(=) => object_assign_object !< `=` overloading.
3140
! public deferred methods
32-
procedure(create_interface), pass(self), deferred :: create !< Create object.
33-
procedure(description_interface), pass(self), deferred :: description !< Return object string-description.
34-
procedure(destroy_interface), pass(self), deferred :: destroy !< Destroy object.
41+
procedure(create_interface), pass(self), deferred :: create !< Create object.
42+
procedure(description_interface), pass(self), deferred :: description !< Return object string-description.
43+
procedure(destroy_interface), pass(self), deferred :: destroy !< Destroy object.
44+
procedure(object_assign_object_interface), pass(lhs), deferred :: object_assign_object !< `=` operator.
3545
! public non overridable methods
46+
procedure, pass(lhs), non_overridable :: assign_ !< Assign object.
3647
procedure, pass(self), non_overridable :: create_ !< Create object.
3748
procedure, pass(self), non_overridable :: destroy_ !< Destroy object.
3849
endtype base_object
3950

51+
abstract interface
52+
!< Abstract interfaces of [[base_object_constructor]].
53+
subroutine constr_assign_constr_interface(lhs, rhs)
54+
!< `=` operator.
55+
import :: base_object_constructor
56+
class(base_object_constructor), intent(inout) :: lhs !< Left hand side.
57+
class(base_object_constructor), intent(in) :: rhs !< Right hand side.
58+
endsubroutine constr_assign_constr_interface
59+
endinterface
60+
4061
abstract interface
4162
!< Abstract interfaces of [[base_object]].
63+
subroutine object_assign_object_interface(lhs, rhs)
64+
!< `=` operator.
65+
import :: base_object
66+
class(base_object), intent(inout) :: lhs !< Left hand side.
67+
class(base_object), intent(in) :: rhs !< Right hand side.
68+
endsubroutine object_assign_object_interface
69+
4270
subroutine create_interface(self, constructor)
4371
!< Create object.
4472
!<
@@ -77,9 +105,28 @@ subroutine create_base_object_constructor(self, S, eps)
77105
if (present(eps)) self%eps = eps
78106
endsubroutine create_base_object_constructor
79107

108+
! public non overridable methods
109+
subroutine assign_constr_(lhs, rhs)
110+
!< Assign object constructor.
111+
class(base_object_constructor), intent(inout) :: lhs !< Left hand side.
112+
class(base_object_constructor), intent(in) :: rhs !< Right hand side.
113+
114+
lhs%S = rhs%S
115+
lhs%eps = rhs%eps
116+
endsubroutine assign_constr_
117+
80118
! base object
81119

82120
! public non overridable methods
121+
subroutine assign_(lhs, rhs)
122+
!< Assign object.
123+
class(base_object), intent(inout) :: lhs !< Left hand side.
124+
class(base_object), intent(in) :: rhs !< Right hand side.
125+
126+
lhs%S = rhs%S
127+
lhs%eps = rhs%eps
128+
endsubroutine assign_
129+
83130
subroutine create_(self, constructor)
84131
!< Create object.
85132
class(base_object), intent(inout) :: self !< Object.

src/lib/abstract_objects/wenoof_interpolations_object.f90

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ module wenoof_interpolations_object
1212

1313
type, extends(base_object_constructor), abstract :: interpolations_object_constructor
1414
!< Abstract interpolations object constructor.
15-
real(R_P), allocatable :: stencil(:) !< Stencil used for interpolation, [1-S:S-1].
16-
real(R_P) :: x_target !< Coordinate of the interpolation point.
1715
endtype interpolations_object_constructor
1816

1917
type, extends(base_object), abstract :: interpolations_object

src/lib/abstract_objects/wenoof_weights_object.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module wenoof_weights_object
1010
public :: weights_object
1111
public :: weights_object_constructor
1212

13-
type, extends(base_object_constructor) :: weights_object_constructor
13+
type, extends(base_object_constructor), abstract :: weights_object_constructor
1414
!< Abstract weights object constructor.
1515
endtype weights_object_constructor
1616

src/lib/concrete_objects/wenoof_alpha_int_js.f90

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module wenoof_alpha_int_js
77

88
use penf, only : I_P, R_P, str
99
use wenoof_alpha_object, only : alpha_object, alpha_object_constructor
10-
use wenoof_base_object, only : base_object_constructor
10+
use wenoof_base_object, only : base_object, base_object_constructor
1111

1212
implicit none
1313
private
@@ -16,6 +16,9 @@ module wenoof_alpha_int_js
1616

1717
type, extends(alpha_object_constructor) :: alpha_int_js_constructor
1818
!< Jiang-Shu alpha object constructor.
19+
contains
20+
! public deferred methods
21+
procedure, pass(lhs) :: constr_assign_constr !< `=` operator.
1922
endtype alpha_int_js_constructor
2023

2124
type, extends(alpha_object) :: alpha_int_js
@@ -25,14 +28,26 @@ module wenoof_alpha_int_js
2528
!< ENO Schemes*, Guang-Shan Jiang, Chi-Wang Shu, JCP, 1996, vol. 126, pp. 202--228, doi:10.1006/jcph.1996.0130.
2629
contains
2730
! public deferred methods
28-
procedure, pass(self) :: create !< Create alpha.
29-
procedure, pass(self) :: compute_int !< Compute alpha (interpolate).
30-
procedure, pass(self) :: compute_rec !< Compute alpha (reconstruct).
31-
procedure, pass(self) :: description !< Return object string-description.
32-
procedure, pass(self) :: destroy !< Destroy alpha.
31+
procedure, pass(self) :: create !< Create alpha.
32+
procedure, pass(self) :: compute_int !< Compute alpha (interpolate).
33+
procedure, pass(self) :: compute_rec !< Compute alpha (reconstruct).
34+
procedure, pass(self) :: description !< Return object string-description.
35+
procedure, pass(self) :: destroy !< Destroy alpha.
36+
procedure, pass(lhs) :: object_assign_object !< `=` operator.
3337
endtype alpha_int_js
3438

3539
contains
40+
! constructor
41+
42+
! deferred public methods
43+
subroutine constr_assign_constr(lhs, rhs)
44+
!< `=` operator.
45+
class(alpha_int_js_constructor), intent(inout) :: lhs !< Left hand side.
46+
class(base_object_constructor), intent(in) :: rhs !< Right hand side.
47+
48+
call lhs%assign_(rhs=rhs)
49+
endsubroutine constr_assign_constr
50+
3651
! deferred public methods
3752
subroutine create(self, constructor)
3853
!< Create alpha.
@@ -85,4 +100,12 @@ elemental subroutine destroy(self)
85100

86101
call self%destroy_
87102
endsubroutine destroy
103+
104+
subroutine object_assign_object(lhs, rhs)
105+
!< `=` operator.
106+
class(alpha_int_js), intent(inout) :: lhs !< Left hand side.
107+
class(base_object), intent(in) :: rhs !< Right hand side.
108+
109+
call lhs%assign_(rhs=rhs)
110+
endsubroutine object_assign_object
88111
endmodule wenoof_alpha_int_js

src/lib/concrete_objects/wenoof_alpha_int_m.f90

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module wenoof_alpha_int_m
1010
use wenoof_alpha_object, only : alpha_object, alpha_object_constructor
1111
use wenoof_alpha_rec_js, only : alpha_rec_js, alpha_rec_js_constructor
1212
use wenoof_alpha_rec_z, only : alpha_rec_z, alpha_rec_z_constructor
13-
use wenoof_base_object, only : base_object_constructor
13+
use wenoof_base_object, only : base_object, base_object_constructor
1414

1515
implicit none
1616
private
@@ -20,6 +20,9 @@ module wenoof_alpha_int_m
2020
type, extends(alpha_object_constructor) :: alpha_int_m_constructor
2121
!< Henrick alpha (non linear weights) object constructor.
2222
character(len=:), allocatable :: base_type !< Base alpha coefficient type.
23+
contains
24+
! public deferred methods
25+
procedure, pass(lhs) :: constr_assign_constr !< `=` operator.
2326
endtype alpha_int_m_constructor
2427

2528
type, extends(alpha_object) :: alpha_int_m
@@ -28,17 +31,33 @@ module wenoof_alpha_int_m
2831
!< @note The provided alpha implements the alpha coefficients defined in *Mapped weighted essentially non-oscillatory schemes:
2932
!< Achieving optimal order near critical points*, Andrew K. Henrick, Tariq D. Aslam, Joseph M. Powers,
3033
!< JCP, 2005, vol. 207, pp. 542-567, doi:10.1016/j.jcp.2005.01.023.
31-
class(alpha_object), allocatable :: alpha_base !< Base alpha to be re-mapped.
34+
class(alpha_object), allocatable :: alpha_base !< Base alpha to be re-mapped.
3235
contains
3336
! public deferred methods
34-
procedure, pass(self) :: create !< Create alpha.
35-
procedure, pass(self) :: compute_int !< Compute alpha (interpolate).
36-
procedure, pass(self) :: compute_rec !< Compute alpha (reconstruct).
37-
procedure, pass(self) :: description !< Return object string-description.
38-
procedure, pass(self) :: destroy !< Destroy alpha.
37+
procedure, pass(self) :: create !< Create alpha.
38+
procedure, pass(self) :: compute_int !< Compute alpha (interpolate).
39+
procedure, pass(self) :: compute_rec !< Compute alpha (reconstruct).
40+
procedure, pass(self) :: description !< Return object string-description.
41+
procedure, pass(self) :: destroy !< Destroy alpha.
42+
procedure, pass(lhs) :: object_assign_object !< `=` operator.
3943
endtype alpha_int_m
4044

4145
contains
46+
! constructor
47+
48+
! deferred public methods
49+
subroutine constr_assign_constr(lhs, rhs)
50+
!< `=` operator.
51+
class(alpha_int_m_constructor), intent(inout) :: lhs !< Left hand side.
52+
class(base_object_constructor), intent(in) :: rhs !< Right hand side.
53+
54+
call lhs%assign_(rhs=rhs)
55+
select type(rhs)
56+
type is(alpha_int_m_constructor)
57+
if (allocated(rhs%base_type)) lhs%base_type = rhs%base_type
58+
endselect
59+
endsubroutine constr_assign_constr
60+
4261
! deferred public methods
4362
subroutine create(self, constructor)
4463
!< Create alpha.
@@ -125,4 +144,21 @@ elemental subroutine destroy(self)
125144
call self%destroy_
126145
if (allocated(self%alpha_base)) deallocate(self%alpha_base)
127146
endsubroutine destroy
147+
148+
subroutine object_assign_object(lhs, rhs)
149+
!< `=` operator.
150+
class(alpha_int_m), intent(inout) :: lhs !< Left hand side.
151+
class(base_object), intent(in) :: rhs !< Right hand side.
152+
153+
call lhs%assign_(rhs=rhs)
154+
select type(rhs)
155+
type is(alpha_int_m)
156+
if (allocated(rhs%alpha_base)) then
157+
if (.not.allocated(lhs%alpha_base)) allocate(lhs%alpha_base, mold=rhs%alpha_base)
158+
lhs%alpha_base = rhs%alpha_base
159+
else
160+
if (allocated(lhs%alpha_base)) deallocate(lhs%alpha_base)
161+
endif
162+
endselect
163+
endsubroutine object_assign_object
128164
endmodule wenoof_alpha_int_m

src/lib/concrete_objects/wenoof_alpha_int_z.f90

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module wenoof_alpha_int_z
88

99
use penf, only : I_P, R_P, str
1010
use wenoof_alpha_object, only : alpha_object, alpha_object_constructor
11-
use wenoof_base_object, only : base_object_constructor
11+
use wenoof_base_object, only : base_object, base_object_constructor
1212

1313
implicit none
1414
private
@@ -17,6 +17,9 @@ module wenoof_alpha_int_z
1717

1818
type, extends(alpha_object_constructor) :: alpha_int_z_constructor
1919
!< Borges alpha (non linear weights) object constructor.
20+
contains
21+
! public deferred methods
22+
procedure, pass(lhs) :: constr_assign_constr !< `=` operator.
2023
endtype alpha_int_z_constructor
2124

2225
type, extends(alpha_object) :: alpha_int_z
@@ -27,13 +30,25 @@ module wenoof_alpha_int_z
2730
!< 2008, vol. 227, pp. 3191-3211, doi: 10.1016/j.jcp.2007.11.038.
2831
contains
2932
! public deferred methods
30-
procedure, pass(self) :: create !< Create alpha.
31-
procedure, pass(self) :: compute_int !< Compute alpha (interpolate).
32-
procedure, pass(self) :: compute_rec !< Compute alpha (reconstruct).
33-
procedure, pass(self) :: description !< Return object string-description.
34-
procedure, pass(self) :: destroy !< Destroy alpha.
33+
procedure, pass(self) :: create !< Create alpha.
34+
procedure, pass(self) :: compute_int !< Compute alpha (interpolate).
35+
procedure, pass(self) :: compute_rec !< Compute alpha (reconstruct).
36+
procedure, pass(self) :: description !< Return object string-description.
37+
procedure, pass(self) :: destroy !< Destroy alpha.
38+
procedure, pass(lhs) :: object_assign_object !< `=` operator.
3539
endtype alpha_int_z
3640
contains
41+
! constructor
42+
43+
! deferred public methods
44+
subroutine constr_assign_constr(lhs, rhs)
45+
!< `=` operator.
46+
class(alpha_int_z_constructor), intent(inout) :: lhs !< Left hand side.
47+
class(base_object_constructor), intent(in) :: rhs !< Right hand side.
48+
49+
call lhs%assign_(rhs=rhs)
50+
endsubroutine constr_assign_constr
51+
3752
! public deferred methods
3853
subroutine create(self, constructor)
3954
!< Create alpha.
@@ -87,6 +102,14 @@ elemental subroutine destroy(self)
87102
call self%destroy_
88103
endsubroutine destroy
89104

105+
subroutine object_assign_object(lhs, rhs)
106+
!< `=` operator.
107+
class(alpha_int_z), intent(inout) :: lhs !< Left hand side.
108+
class(base_object), intent(in) :: rhs !< Right hand side.
109+
110+
call lhs%assign_(rhs=rhs)
111+
endsubroutine object_assign_object
112+
90113
! private non TBP
91114
pure function tau(S, beta) result(w_tau)
92115
!< Compute the tau coefficient used in the WENO-Z alpha coefficients.

src/lib/concrete_objects/wenoof_alpha_rec_js.f90

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module wenoof_alpha_rec_js
77

88
use penf, only : I_P, R_P, str
99
use wenoof_alpha_object, only : alpha_object, alpha_object_constructor
10-
use wenoof_base_object, only : base_object_constructor
10+
use wenoof_base_object, only : base_object, base_object_constructor
1111

1212
implicit none
1313
private
@@ -16,6 +16,9 @@ module wenoof_alpha_rec_js
1616

1717
type, extends(alpha_object_constructor) :: alpha_rec_js_constructor
1818
!< Jiang-Shu alpha object constructor.
19+
contains
20+
! public deferred methods
21+
procedure, pass(lhs) :: constr_assign_constr !< `=` operator.
1922
endtype alpha_rec_js_constructor
2023

2124
type, extends(alpha_object) :: alpha_rec_js
@@ -25,14 +28,26 @@ module wenoof_alpha_rec_js
2528
!< ENO Schemes*, Guang-Shan Jiang, Chi-Wang Shu, JCP, 1996, vol. 126, pp. 202--228, doi:10.1006/jcph.1996.0130.
2629
contains
2730
! public deferred methods
28-
procedure, pass(self) :: create !< Create alpha.
29-
procedure, pass(self) :: compute_int !< Compute alpha (interpolate).
30-
procedure, pass(self) :: compute_rec !< Compute alpha (reconstruct).
31-
procedure, pass(self) :: description !< Return object string-description.
32-
procedure, pass(self) :: destroy !< Destroy alpha.
31+
procedure, pass(self) :: create !< Create alpha.
32+
procedure, pass(self) :: compute_int !< Compute alpha (interpolate).
33+
procedure, pass(self) :: compute_rec !< Compute alpha (reconstruct).
34+
procedure, pass(self) :: description !< Return object string-description.
35+
procedure, pass(self) :: destroy !< Destroy alpha.
36+
procedure, pass(lhs) :: object_assign_object !< `=` operator.
3337
endtype alpha_rec_js
3438

3539
contains
40+
! constructor
41+
42+
! deferred public methods
43+
subroutine constr_assign_constr(lhs, rhs)
44+
!< `=` operator.
45+
class(alpha_rec_js_constructor), intent(inout) :: lhs !< Left hand side.
46+
class(base_object_constructor), intent(in) :: rhs !< Right hand side.
47+
48+
call lhs%assign_(rhs=rhs)
49+
endsubroutine constr_assign_constr
50+
3651
! deferred public methods
3752
subroutine create(self, constructor)
3853
!< Create alpha.
@@ -87,4 +102,12 @@ elemental subroutine destroy(self)
87102

88103
call self%destroy_
89104
endsubroutine destroy
105+
106+
subroutine object_assign_object(lhs, rhs)
107+
!< `=` operator.
108+
class(alpha_rec_js), intent(inout) :: lhs !< Left hand side.
109+
class(base_object), intent(in) :: rhs !< Right hand side.
110+
111+
call lhs%assign_(rhs=rhs)
112+
endsubroutine object_assign_object
90113
endmodule wenoof_alpha_rec_js

0 commit comments

Comments
 (0)