Skip to content

Commit d5265fa

Browse files
committed
improve factory
1 parent 87a33f8 commit d5265fa

21 files changed

+420
-222
lines changed

src/lib/abstract_objects/wenoof_alpha_object.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module wenoof_alpha_object
1616
public :: alpha_object
1717
public :: alpha_object_constructor
1818

19-
type, extends(base_object_constructor) :: alpha_object_constructor
19+
type, extends(base_object_constructor), abstract :: alpha_object_constructor
2020
!< Abstract alpha (non linear weights) object constructor.
2121
contains
2222
endtype alpha_object_constructor

src/lib/abstract_objects/wenoof_base_object.F90

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ module wenoof_base_object
1717

1818
real(RPP), parameter :: EPS_DEF=10._RPP**(-6) !< Small epsilon to avoid division by zero, default value.
1919

20-
type :: base_object_constructor
20+
type, abstract :: base_object_constructor
2121
!< Abstract base object constructor.
2222
integer(I_P) :: S=0_I_P !< Stencils dimension.
2323
logical :: face_left=.true. !< Activate left-face interpolation computation.
2424
logical :: face_right=.true. !< Activate right-face interpolation computation.
2525
real(RPP) :: eps=EPS_DEF !< Small epsilon to avoid division by zero.
26+
contains
27+
procedure, pass(self) :: create => create_base_object_constructor
2628
endtype base_object_constructor
2729

2830
type, abstract :: base_object
@@ -70,6 +72,25 @@ elemental subroutine destroy_interface(self)
7072
endinterface
7173

7274
contains
75+
! base object constructor
76+
77+
! public methods
78+
subroutine create_base_object_constructor(self, S, face_left, face_right, eps)
79+
!< Create alpha constructor.
80+
class(base_object_constructor), intent(inout) :: self !< Constructor.
81+
integer(I_P), intent(in) :: S !< Stencils dimension.
82+
logical, intent(in), optional :: face_left !< Activate left-face interpolations.
83+
logical, intent(in), optional :: face_right !< Activate right-face interpolations.
84+
real(RPP), intent(in), optional :: eps !< Small epsilon to avoid division by zero.
85+
86+
self%S = S
87+
if (present(face_left)) self%face_left = face_left
88+
if (present(face_right)) self%face_right = face_right
89+
if (present(eps)) self%eps = eps
90+
endsubroutine create_base_object_constructor
91+
92+
! base object
93+
7394
! public non overridable methods
7495
subroutine create_(self, constructor)
7596
!< Create object.

src/lib/abstract_objects/wenoof_beta_object.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module wenoof_beta_object
1414
public :: beta_object
1515
public :: beta_object_constructor
1616

17-
type, extends(base_object_constructor) :: beta_object_constructor
17+
type, extends(base_object_constructor), abstract :: beta_object_constructor
1818
!< Abstract Beta coefficients object constructor.
1919
endtype beta_object_constructor
2020

src/lib/abstract_objects/wenoof_interpolations_object.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module wenoof_interpolations_object
1414
public :: interpolations_object
1515
public :: interpolations_object_constructor
1616

17-
type, extends(base_object_constructor) :: interpolations_object_constructor
17+
type, extends(base_object_constructor), abstract :: interpolations_object_constructor
1818
!< Abstract interpolations object constructor.
1919
endtype interpolations_object_constructor
2020

src/lib/abstract_objects/wenoof_interpolator_object.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module wenoof_interpolator_object
1616
public :: interpolator_object
1717
public :: interpolator_object_constructor
1818

19-
type, extends(base_object_constructor) :: interpolator_object_constructor
19+
type, extends(base_object_constructor), abstract :: interpolator_object_constructor
2020
!< Abstract interpolator object constructor.
2121
!<
2222
!< @note Every concrete WENO interpolator implementations must define their own constructor type.

src/lib/abstract_objects/wenoof_kappa_object.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module wenoof_kappa_object
1414
public :: kappa_object
1515
public :: kappa_object_constructor
1616

17-
type, extends(base_object_constructor) :: kappa_object_constructor
17+
type, extends(base_object_constructor), abstract :: kappa_object_constructor
1818
!< Abstract kappa object constructor.
1919
endtype kappa_object_constructor
2020

src/lib/concrete_objects/wenoof_alpha_rec_js.F90

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ module wenoof_alpha_rec_js
66
!< Schemes*, Guang-Shan Jiang, Chi-Wang Shu, JCP, 1996, vol. 126, pp. 202--228, doi:10.1006/jcph.1996.0130.
77

88
#ifdef r16p
9-
use penf, only: I_P, RPP=>R16P
9+
use penf, only: I_P, RPP=>R16P, str
1010
#else
11-
use penf, only: I_P, RPP=>R8P
11+
use penf, only: I_P, RPP=>R8P, str
1212
#endif
1313
use wenoof_alpha_object
1414
use wenoof_base_object
@@ -19,7 +19,6 @@ module wenoof_alpha_rec_js
1919
private
2020
public :: alpha_rec_js
2121
public :: alpha_rec_js_constructor
22-
public :: create_alpha_rec_js_constructor
2322

2423
type, extends(alpha_object_constructor) :: alpha_rec_js_constructor
2524
!< Jiang-Shu alpha object constructor.
@@ -39,22 +38,6 @@ module wenoof_alpha_rec_js
3938
endtype alpha_rec_js
4039

4140
contains
42-
! public non TBP
43-
subroutine create_alpha_rec_js_constructor(S, constructor, face_left, face_right, eps)
44-
!< Create alpha constructor.
45-
integer(I_P), intent(in) :: S !< Stencils dimension.
46-
class(alpha_object_constructor), allocatable, intent(out) :: constructor !< Constructor.
47-
logical, intent(in), optional :: face_left !< Activate left-face interpolations.
48-
logical, intent(in), optional :: face_right !< Activate right-face interpolations.
49-
real(RPP), intent(in), optional :: eps !< Small epsilon to avoid division by zero.
50-
51-
allocate(alpha_rec_js_constructor :: constructor)
52-
constructor%S = S
53-
if (present(face_left)) constructor%face_left = face_left
54-
if (present(face_right)) constructor%face_right = face_right
55-
if (present(eps)) constructor%eps = eps
56-
endsubroutine create_alpha_rec_js_constructor
57-
5841
! deferred public methods
5942
subroutine create(self, constructor)
6043
!< Create alpha.
@@ -87,13 +70,16 @@ pure subroutine compute(self, beta, kappa)
8770

8871
pure function description(self) result(string)
8972
!< Return alpha string-descripition.
90-
class(alpha_rec_js), intent(in) :: self !< Alpha coefficient.
91-
character(len=:), allocatable :: string !< String-description.
73+
class(alpha_rec_js), intent(in) :: self !< Alpha coefficient.
74+
character(len=:), allocatable :: string !< String-description.
75+
character(len=1), parameter :: nl=new_line('a') !< New line char.
9276

93-
#ifndef DEBUG
94-
! error stop in pure procedure is a F2015 feature not yet supported in debug mode
95-
error stop 'alpha_rec_js%description to be implemented, do not use!'
96-
#endif
77+
string = ' Jiang-Shu alpha coefficients for reconstructor:'//nl
78+
string = string//' - S = '//trim(str(self%S))//nl
79+
string = string//' - f1 = '//trim(str(self%f1))//nl
80+
string = string//' - f2 = '//trim(str(self%f2))//nl
81+
string = string//' - ff = '//trim(str(self%ff))//nl
82+
string = string//' - eps = '//trim(str(self%eps))
9783
endfunction description
9884

9985
elemental subroutine destroy(self)

src/lib/concrete_objects/wenoof_beta_rec_js.F90

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ module wenoof_beta_rec_js
1919
private
2020
public :: beta_rec_js
2121
public :: beta_rec_js_constructor
22-
public :: create_beta_rec_js_constructor
2322

2423
type, extends(beta_object_constructor) :: beta_rec_js_constructor
2524
!< Jiang-Shu and Gerolymos-Senechal-Vallet beta object constructor.
@@ -43,20 +42,6 @@ module wenoof_beta_rec_js
4342
endtype beta_rec_js
4443

4544
contains
46-
! public non TBP procedures
47-
subroutine create_beta_rec_js_constructor(S, constructor, face_left, face_right)
48-
!< Create beta constructor.
49-
integer(I_P), intent(in) :: S !< Stencils dimension.
50-
class(beta_object_constructor), allocatable, intent(out) :: constructor !< Constructor.
51-
logical, intent(in), optional :: face_left !< Activate left-face interpolations.
52-
logical, intent(in), optional :: face_right !< Activate right-face interpolations.
53-
54-
allocate(beta_rec_js_constructor :: constructor)
55-
constructor%S = S
56-
if (present(face_left)) constructor%face_left = face_left
57-
if (present(face_right)) constructor%face_right = face_right
58-
endsubroutine create_beta_rec_js_constructor
59-
6045
! public deferred methods
6146
subroutine create(self, constructor)
6247
!< Create beta.

src/lib/concrete_objects/wenoof_interpolations_rec_js.F90

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ module wenoof_interpolations_rec_js
1919
private
2020
public :: interpolations_rec_js
2121
public :: interpolations_rec_js_constructor
22-
public :: create_interpolations_rec_js_constructor
2322

2423
type, extends(interpolations_object_constructor) :: interpolations_rec_js_constructor
2524
!< Jiang-Shu (Lagrange) interpolations object for derivative reconstruction constructor.
@@ -43,20 +42,6 @@ module wenoof_interpolations_rec_js
4342
endtype interpolations_rec_js
4443

4544
contains
46-
! public non TBP procedures
47-
subroutine create_interpolations_rec_js_constructor(S, constructor, face_left, face_right)
48-
!< Create interpolations constructor.
49-
integer(I_P), intent(in) :: S !< Stencils dimension.
50-
class(interpolations_object_constructor), allocatable, intent(out) :: constructor !< Constructor.
51-
logical, intent(in), optional :: face_left !< Activate left-face interpolations.
52-
logical, intent(in), optional :: face_right !< Activate right-face interpolations.
53-
54-
allocate(interpolations_rec_js_constructor :: constructor)
55-
constructor%S = S
56-
if (present(face_left)) constructor%face_left = face_left
57-
if (present(face_right)) constructor%face_right = face_right
58-
endsubroutine create_interpolations_rec_js_constructor
59-
6045
! public deferred methods
6146
subroutine create(self, constructor)
6247
!< Create interpolations.

src/lib/concrete_objects/wenoof_kappa_rec_js.F90

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ module wenoof_kappa_rec_js
1919
private
2020
public :: kappa_rec_js
2121
public :: kappa_rec_js_constructor
22-
public :: create_kappa_rec_js_constructor
2322

2423
type, extends(kappa_object_constructor) :: kappa_rec_js_constructor
2524
!< Jiang-Shu and Gerolymos-Senechal-Vallet optimal kappa object constructor.
@@ -41,16 +40,6 @@ module wenoof_kappa_rec_js
4140
endtype kappa_rec_js
4241

4342
contains
44-
! public non TBP procedures
45-
subroutine create_kappa_rec_js_constructor(S, constructor)
46-
!< Create kappa constructor.
47-
integer(I_P), intent(in) :: S !< Stencils dimension.
48-
class(kappa_object_constructor), allocatable, intent(out) :: constructor !< Constructor.
49-
50-
allocate(kappa_rec_js_constructor :: constructor)
51-
constructor%S = S
52-
endsubroutine create_kappa_rec_js_constructor
53-
5443
! deferred public methods
5544
subroutine create(self, constructor)
5645
!< Create kappa.

0 commit comments

Comments
 (0)