diff --git a/src/lib/abstract_objects/wenoof_base_object.f90 b/src/lib/abstract_objects/wenoof_base_object.f90 index 060609b..e94492c 100644 --- a/src/lib/abstract_objects/wenoof_base_object.f90 +++ b/src/lib/abstract_objects/wenoof_base_object.f90 @@ -15,10 +15,17 @@ module wenoof_base_object type, abstract :: base_object_constructor !< Abstract base object constructor. - integer(I_P) :: S=0_I_P !< Stencils dimension. - real(R_P) :: eps=EPS_DEF !< Small epsilon to avoid division by zero. + integer(I_P) :: S=0_I_P !< Stencils dimension. + real(R_P) :: eps=EPS_DEF !< Small epsilon to avoid division by zero. contains + ! public methods procedure, pass(self) :: create => create_base_object_constructor + ! public operators + generic :: assignment(=) => constr_assign_constr !< `=` overloading. + ! public deferred methods + procedure(constr_assign_constr_interface), pass(lhs), deferred :: constr_assign_constr !< `=` operator. + ! public non overridable methods + procedure, pass(lhs), non_overridable :: assign_ => assign_constr_ !< Assign object. endtype base_object_constructor type, abstract :: base_object @@ -28,17 +35,38 @@ module wenoof_base_object integer(I_P) :: S=0_I_P !< Stencils dimension. real(R_P) :: eps=EPS_DEF !< Small epsilon to avoid division by zero. contains + ! public operators + generic :: assignment(=) => object_assign_object !< `=` overloading. ! public deferred methods - procedure(create_interface), pass(self), deferred :: create !< Create object. - procedure(description_interface), pass(self), deferred :: description !< Return object string-description. - procedure(destroy_interface), pass(self), deferred :: destroy !< Destroy object. + procedure(create_interface), pass(self), deferred :: create !< Create object. + procedure(description_interface), pass(self), deferred :: description !< Return object string-description. + procedure(destroy_interface), pass(self), deferred :: destroy !< Destroy object. + procedure(object_assign_object_interface), pass(lhs), deferred :: object_assign_object !< `=` operator. ! public non overridable methods + procedure, pass(lhs), non_overridable :: assign_ !< Assign object. procedure, pass(self), non_overridable :: create_ !< Create object. procedure, pass(self), non_overridable :: destroy_ !< Destroy object. endtype base_object +abstract interface + !< Abstract interfaces of [[base_object_constructor]]. + subroutine constr_assign_constr_interface(lhs, rhs) + !< `=` operator. + import :: base_object_constructor + class(base_object_constructor), intent(inout) :: lhs !< Left hand side. + class(base_object_constructor), intent(in) :: rhs !< Right hand side. + endsubroutine constr_assign_constr_interface +endinterface + abstract interface !< Abstract interfaces of [[base_object]]. + subroutine object_assign_object_interface(lhs, rhs) + !< `=` operator. + import :: base_object + class(base_object), intent(inout) :: lhs !< Left hand side. + class(base_object), intent(in) :: rhs !< Right hand side. + endsubroutine object_assign_object_interface + subroutine create_interface(self, constructor) !< Create object. !< @@ -77,9 +105,28 @@ subroutine create_base_object_constructor(self, S, eps) if (present(eps)) self%eps = eps endsubroutine create_base_object_constructor + ! public non overridable methods + subroutine assign_constr_(lhs, rhs) + !< Assign object constructor. + class(base_object_constructor), intent(inout) :: lhs !< Left hand side. + class(base_object_constructor), intent(in) :: rhs !< Right hand side. + + lhs%S = rhs%S + lhs%eps = rhs%eps + endsubroutine assign_constr_ + ! base object ! public non overridable methods + subroutine assign_(lhs, rhs) + !< Assign object. + class(base_object), intent(inout) :: lhs !< Left hand side. + class(base_object), intent(in) :: rhs !< Right hand side. + + lhs%S = rhs%S + lhs%eps = rhs%eps + endsubroutine assign_ + subroutine create_(self, constructor) !< Create object. class(base_object), intent(inout) :: self !< Object. diff --git a/src/lib/abstract_objects/wenoof_interpolations_object.f90 b/src/lib/abstract_objects/wenoof_interpolations_object.f90 index ed7e115..4068d33 100644 --- a/src/lib/abstract_objects/wenoof_interpolations_object.f90 +++ b/src/lib/abstract_objects/wenoof_interpolations_object.f90 @@ -12,8 +12,6 @@ module wenoof_interpolations_object type, extends(base_object_constructor), abstract :: interpolations_object_constructor !< Abstract interpolations object constructor. - real(R_P), allocatable :: stencil(:) !< Stencil used for interpolation, [1-S:S-1]. - real(R_P) :: x_target !< Coordinate of the interpolation point. endtype interpolations_object_constructor type, extends(base_object), abstract :: interpolations_object diff --git a/src/lib/abstract_objects/wenoof_weights_object.f90 b/src/lib/abstract_objects/wenoof_weights_object.f90 index 39d4bf5..f6b1a66 100644 --- a/src/lib/abstract_objects/wenoof_weights_object.f90 +++ b/src/lib/abstract_objects/wenoof_weights_object.f90 @@ -10,7 +10,7 @@ module wenoof_weights_object public :: weights_object public :: weights_object_constructor -type, extends(base_object_constructor) :: weights_object_constructor +type, extends(base_object_constructor), abstract :: weights_object_constructor !< Abstract weights object constructor. endtype weights_object_constructor diff --git a/src/lib/concrete_objects/wenoof_alpha_int_js.f90 b/src/lib/concrete_objects/wenoof_alpha_int_js.f90 index 7e40edc..151db41 100644 --- a/src/lib/concrete_objects/wenoof_alpha_int_js.f90 +++ b/src/lib/concrete_objects/wenoof_alpha_int_js.f90 @@ -7,7 +7,7 @@ module wenoof_alpha_int_js use penf, only : I_P, R_P, str use wenoof_alpha_object, only : alpha_object, alpha_object_constructor -use wenoof_base_object, only : base_object_constructor +use wenoof_base_object, only : base_object, base_object_constructor implicit none private @@ -16,6 +16,9 @@ module wenoof_alpha_int_js type, extends(alpha_object_constructor) :: alpha_int_js_constructor !< Jiang-Shu alpha object constructor. + contains + ! public deferred methods + procedure, pass(lhs) :: constr_assign_constr !< `=` operator. endtype alpha_int_js_constructor type, extends(alpha_object) :: alpha_int_js @@ -25,14 +28,26 @@ module wenoof_alpha_int_js !< ENO Schemes*, Guang-Shan Jiang, Chi-Wang Shu, JCP, 1996, vol. 126, pp. 202--228, doi:10.1006/jcph.1996.0130. contains ! public deferred methods - procedure, pass(self) :: create !< Create alpha. - procedure, pass(self) :: compute_int !< Compute alpha (interpolate). - procedure, pass(self) :: compute_rec !< Compute alpha (reconstruct). - procedure, pass(self) :: description !< Return object string-description. - procedure, pass(self) :: destroy !< Destroy alpha. + procedure, pass(self) :: create !< Create alpha. + procedure, pass(self) :: compute_int !< Compute alpha (interpolate). + procedure, pass(self) :: compute_rec !< Compute alpha (reconstruct). + procedure, pass(self) :: description !< Return object string-description. + procedure, pass(self) :: destroy !< Destroy alpha. + procedure, pass(lhs) :: object_assign_object !< `=` operator. endtype alpha_int_js contains + ! constructor + + ! deferred public methods + subroutine constr_assign_constr(lhs, rhs) + !< `=` operator. + class(alpha_int_js_constructor), intent(inout) :: lhs !< Left hand side. + class(base_object_constructor), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + endsubroutine constr_assign_constr + ! deferred public methods subroutine create(self, constructor) !< Create alpha. @@ -85,4 +100,12 @@ elemental subroutine destroy(self) call self%destroy_ endsubroutine destroy + + subroutine object_assign_object(lhs, rhs) + !< `=` operator. + class(alpha_int_js), intent(inout) :: lhs !< Left hand side. + class(base_object), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + endsubroutine object_assign_object endmodule wenoof_alpha_int_js diff --git a/src/lib/concrete_objects/wenoof_alpha_int_m.f90 b/src/lib/concrete_objects/wenoof_alpha_int_m.f90 index 6eb6521..888c587 100644 --- a/src/lib/concrete_objects/wenoof_alpha_int_m.f90 +++ b/src/lib/concrete_objects/wenoof_alpha_int_m.f90 @@ -10,7 +10,7 @@ module wenoof_alpha_int_m use wenoof_alpha_object, only : alpha_object, alpha_object_constructor use wenoof_alpha_rec_js, only : alpha_rec_js, alpha_rec_js_constructor use wenoof_alpha_rec_z, only : alpha_rec_z, alpha_rec_z_constructor -use wenoof_base_object, only : base_object_constructor +use wenoof_base_object, only : base_object, base_object_constructor implicit none private @@ -20,6 +20,9 @@ module wenoof_alpha_int_m type, extends(alpha_object_constructor) :: alpha_int_m_constructor !< Henrick alpha (non linear weights) object constructor. character(len=:), allocatable :: base_type !< Base alpha coefficient type. + contains + ! public deferred methods + procedure, pass(lhs) :: constr_assign_constr !< `=` operator. endtype alpha_int_m_constructor type, extends(alpha_object) :: alpha_int_m @@ -28,17 +31,33 @@ module wenoof_alpha_int_m !< @note The provided alpha implements the alpha coefficients defined in *Mapped weighted essentially non-oscillatory schemes: !< Achieving optimal order near critical points*, Andrew K. Henrick, Tariq D. Aslam, Joseph M. Powers, !< JCP, 2005, vol. 207, pp. 542-567, doi:10.1016/j.jcp.2005.01.023. - class(alpha_object), allocatable :: alpha_base !< Base alpha to be re-mapped. + class(alpha_object), allocatable :: alpha_base !< Base alpha to be re-mapped. contains ! public deferred methods - procedure, pass(self) :: create !< Create alpha. - procedure, pass(self) :: compute_int !< Compute alpha (interpolate). - procedure, pass(self) :: compute_rec !< Compute alpha (reconstruct). - procedure, pass(self) :: description !< Return object string-description. - procedure, pass(self) :: destroy !< Destroy alpha. + procedure, pass(self) :: create !< Create alpha. + procedure, pass(self) :: compute_int !< Compute alpha (interpolate). + procedure, pass(self) :: compute_rec !< Compute alpha (reconstruct). + procedure, pass(self) :: description !< Return object string-description. + procedure, pass(self) :: destroy !< Destroy alpha. + procedure, pass(lhs) :: object_assign_object !< `=` operator. endtype alpha_int_m contains + ! constructor + + ! deferred public methods + subroutine constr_assign_constr(lhs, rhs) + !< `=` operator. + class(alpha_int_m_constructor), intent(inout) :: lhs !< Left hand side. + class(base_object_constructor), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + select type(rhs) + type is(alpha_int_m_constructor) + if (allocated(rhs%base_type)) lhs%base_type = rhs%base_type + endselect + endsubroutine constr_assign_constr + ! deferred public methods subroutine create(self, constructor) !< Create alpha. @@ -125,4 +144,21 @@ elemental subroutine destroy(self) call self%destroy_ if (allocated(self%alpha_base)) deallocate(self%alpha_base) endsubroutine destroy + + subroutine object_assign_object(lhs, rhs) + !< `=` operator. + class(alpha_int_m), intent(inout) :: lhs !< Left hand side. + class(base_object), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + select type(rhs) + type is(alpha_int_m) + if (allocated(rhs%alpha_base)) then + if (.not.allocated(lhs%alpha_base)) allocate(lhs%alpha_base, mold=rhs%alpha_base) + lhs%alpha_base = rhs%alpha_base + else + if (allocated(lhs%alpha_base)) deallocate(lhs%alpha_base) + endif + endselect + endsubroutine object_assign_object endmodule wenoof_alpha_int_m diff --git a/src/lib/concrete_objects/wenoof_alpha_int_z.f90 b/src/lib/concrete_objects/wenoof_alpha_int_z.f90 index 35a4b5a..d835449 100644 --- a/src/lib/concrete_objects/wenoof_alpha_int_z.f90 +++ b/src/lib/concrete_objects/wenoof_alpha_int_z.f90 @@ -8,7 +8,7 @@ module wenoof_alpha_int_z use penf, only : I_P, R_P, str use wenoof_alpha_object, only : alpha_object, alpha_object_constructor -use wenoof_base_object, only : base_object_constructor +use wenoof_base_object, only : base_object, base_object_constructor implicit none private @@ -17,6 +17,9 @@ module wenoof_alpha_int_z type, extends(alpha_object_constructor) :: alpha_int_z_constructor !< Borges alpha (non linear weights) object constructor. + contains + ! public deferred methods + procedure, pass(lhs) :: constr_assign_constr !< `=` operator. endtype alpha_int_z_constructor type, extends(alpha_object) :: alpha_int_z @@ -27,13 +30,25 @@ module wenoof_alpha_int_z !< 2008, vol. 227, pp. 3191-3211, doi: 10.1016/j.jcp.2007.11.038. contains ! public deferred methods - procedure, pass(self) :: create !< Create alpha. - procedure, pass(self) :: compute_int !< Compute alpha (interpolate). - procedure, pass(self) :: compute_rec !< Compute alpha (reconstruct). - procedure, pass(self) :: description !< Return object string-description. - procedure, pass(self) :: destroy !< Destroy alpha. + procedure, pass(self) :: create !< Create alpha. + procedure, pass(self) :: compute_int !< Compute alpha (interpolate). + procedure, pass(self) :: compute_rec !< Compute alpha (reconstruct). + procedure, pass(self) :: description !< Return object string-description. + procedure, pass(self) :: destroy !< Destroy alpha. + procedure, pass(lhs) :: object_assign_object !< `=` operator. endtype alpha_int_z contains + ! constructor + + ! deferred public methods + subroutine constr_assign_constr(lhs, rhs) + !< `=` operator. + class(alpha_int_z_constructor), intent(inout) :: lhs !< Left hand side. + class(base_object_constructor), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + endsubroutine constr_assign_constr + ! public deferred methods subroutine create(self, constructor) !< Create alpha. @@ -87,6 +102,14 @@ elemental subroutine destroy(self) call self%destroy_ endsubroutine destroy + subroutine object_assign_object(lhs, rhs) + !< `=` operator. + class(alpha_int_z), intent(inout) :: lhs !< Left hand side. + class(base_object), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + endsubroutine object_assign_object + ! private non TBP pure function tau(S, beta) result(w_tau) !< Compute the tau coefficient used in the WENO-Z alpha coefficients. diff --git a/src/lib/concrete_objects/wenoof_alpha_rec_js.f90 b/src/lib/concrete_objects/wenoof_alpha_rec_js.f90 index ea3c93a..9fc4e4f 100644 --- a/src/lib/concrete_objects/wenoof_alpha_rec_js.f90 +++ b/src/lib/concrete_objects/wenoof_alpha_rec_js.f90 @@ -7,7 +7,7 @@ module wenoof_alpha_rec_js use penf, only : I_P, R_P, str use wenoof_alpha_object, only : alpha_object, alpha_object_constructor -use wenoof_base_object, only : base_object_constructor +use wenoof_base_object, only : base_object, base_object_constructor implicit none private @@ -16,6 +16,9 @@ module wenoof_alpha_rec_js type, extends(alpha_object_constructor) :: alpha_rec_js_constructor !< Jiang-Shu alpha object constructor. + contains + ! public deferred methods + procedure, pass(lhs) :: constr_assign_constr !< `=` operator. endtype alpha_rec_js_constructor type, extends(alpha_object) :: alpha_rec_js @@ -25,14 +28,26 @@ module wenoof_alpha_rec_js !< ENO Schemes*, Guang-Shan Jiang, Chi-Wang Shu, JCP, 1996, vol. 126, pp. 202--228, doi:10.1006/jcph.1996.0130. contains ! public deferred methods - procedure, pass(self) :: create !< Create alpha. - procedure, pass(self) :: compute_int !< Compute alpha (interpolate). - procedure, pass(self) :: compute_rec !< Compute alpha (reconstruct). - procedure, pass(self) :: description !< Return object string-description. - procedure, pass(self) :: destroy !< Destroy alpha. + procedure, pass(self) :: create !< Create alpha. + procedure, pass(self) :: compute_int !< Compute alpha (interpolate). + procedure, pass(self) :: compute_rec !< Compute alpha (reconstruct). + procedure, pass(self) :: description !< Return object string-description. + procedure, pass(self) :: destroy !< Destroy alpha. + procedure, pass(lhs) :: object_assign_object !< `=` operator. endtype alpha_rec_js contains + ! constructor + + ! deferred public methods + subroutine constr_assign_constr(lhs, rhs) + !< `=` operator. + class(alpha_rec_js_constructor), intent(inout) :: lhs !< Left hand side. + class(base_object_constructor), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + endsubroutine constr_assign_constr + ! deferred public methods subroutine create(self, constructor) !< Create alpha. @@ -87,4 +102,12 @@ elemental subroutine destroy(self) call self%destroy_ endsubroutine destroy + + subroutine object_assign_object(lhs, rhs) + !< `=` operator. + class(alpha_rec_js), intent(inout) :: lhs !< Left hand side. + class(base_object), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + endsubroutine object_assign_object endmodule wenoof_alpha_rec_js diff --git a/src/lib/concrete_objects/wenoof_alpha_rec_m.f90 b/src/lib/concrete_objects/wenoof_alpha_rec_m.f90 index 28842d7..8ad6310 100644 --- a/src/lib/concrete_objects/wenoof_alpha_rec_m.f90 +++ b/src/lib/concrete_objects/wenoof_alpha_rec_m.f90 @@ -10,7 +10,7 @@ module wenoof_alpha_rec_m use wenoof_alpha_object, only : alpha_object, alpha_object_constructor use wenoof_alpha_rec_js, only : alpha_rec_js, alpha_rec_js_constructor use wenoof_alpha_rec_z, only : alpha_rec_z, alpha_rec_z_constructor -use wenoof_base_object, only : base_object_constructor +use wenoof_base_object, only : base_object, base_object_constructor implicit none private @@ -20,6 +20,9 @@ module wenoof_alpha_rec_m type, extends(alpha_object_constructor) :: alpha_rec_m_constructor !< Henrick alpha (non linear weights) object constructor. character(len=:), allocatable :: base_type !< Base alpha coefficient type. + contains + ! public deferred methods + procedure, pass(lhs) :: constr_assign_constr !< `=` operator. endtype alpha_rec_m_constructor type, extends(alpha_object) :: alpha_rec_m @@ -31,14 +34,30 @@ module wenoof_alpha_rec_m class(alpha_object), allocatable :: alpha_base !< Base alpha to be re-mapped. contains ! public deferred methods - procedure, pass(self) :: create !< Create alpha. - procedure, pass(self) :: compute_int !< Compute alpha (interpolate). - procedure, pass(self) :: compute_rec !< Compute alpha (reconstruct). - procedure, pass(self) :: description !< Return alpha string-description. - procedure, pass(self) :: destroy !< Destroy alpha. + procedure, pass(self) :: create !< Create alpha. + procedure, pass(self) :: compute_int !< Compute alpha (interpolate). + procedure, pass(self) :: compute_rec !< Compute alpha (reconstruct). + procedure, pass(self) :: description !< Return alpha string-description. + procedure, pass(self) :: destroy !< Destroy alpha. + procedure, pass(lhs) :: object_assign_object !< `=` operator. endtype alpha_rec_m contains + ! constructor + + ! deferred public methods + subroutine constr_assign_constr(lhs, rhs) + !< `=` operator. + class(alpha_rec_m_constructor), intent(inout) :: lhs !< Left hand side. + class(base_object_constructor), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + select type(rhs) + type is(alpha_rec_m_constructor) + if (allocated(rhs%base_type)) lhs%base_type = rhs%base_type + endselect + endsubroutine constr_assign_constr + ! deferred public methods subroutine create(self, constructor) !< Create alpha. @@ -128,4 +147,21 @@ elemental subroutine destroy(self) call self%destroy_ if (allocated(self%alpha_base)) deallocate(self%alpha_base) endsubroutine destroy + + subroutine object_assign_object(lhs, rhs) + !< `=` operator. + class(alpha_rec_m), intent(inout) :: lhs !< Left hand side. + class(base_object), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + select type(rhs) + type is(alpha_rec_m) + if (allocated(rhs%alpha_base)) then + if (.not.allocated(lhs%alpha_base)) allocate(lhs%alpha_base, mold=rhs%alpha_base) + lhs%alpha_base = rhs%alpha_base + else + if (allocated(lhs%alpha_base)) deallocate(lhs%alpha_base) + endif + endselect + endsubroutine object_assign_object endmodule wenoof_alpha_rec_m diff --git a/src/lib/concrete_objects/wenoof_alpha_rec_z.f90 b/src/lib/concrete_objects/wenoof_alpha_rec_z.f90 index ea90e98..d57e3af 100644 --- a/src/lib/concrete_objects/wenoof_alpha_rec_z.f90 +++ b/src/lib/concrete_objects/wenoof_alpha_rec_z.f90 @@ -8,7 +8,7 @@ module wenoof_alpha_rec_z use penf, only : I_P, R_P, str use wenoof_alpha_object, only : alpha_object, alpha_object_constructor -use wenoof_base_object, only : base_object_constructor +use wenoof_base_object, only : base_object, base_object_constructor implicit none private @@ -17,6 +17,9 @@ module wenoof_alpha_rec_z type, extends(alpha_object_constructor) :: alpha_rec_z_constructor !< Borges alpha (non linear weights) object constructor. + contains + ! public deferred methods + procedure, pass(lhs) :: constr_assign_constr !< `=` operator. endtype alpha_rec_z_constructor type, extends(alpha_object) :: alpha_rec_z @@ -27,13 +30,26 @@ module wenoof_alpha_rec_z !< 2008, vol. 227, pp. 3191-3211, doi: 10.1016/j.jcp.2007.11.038. contains ! public deferred methods - procedure, pass(self) :: create !< Create alpha. - procedure, pass(self) :: compute_int !< Compute alpha (interpolate). - procedure, pass(self) :: compute_rec !< Compute alpha (reconstruct). - procedure, pass(self) :: description !< Return alpha string-description. - procedure, pass(self) :: destroy !< Destroy alpha. + procedure, pass(self) :: create !< Create alpha. + procedure, pass(self) :: compute_int !< Compute alpha (interpolate). + procedure, pass(self) :: compute_rec !< Compute alpha (reconstruct). + procedure, pass(self) :: description !< Return alpha string-description. + procedure, pass(self) :: destroy !< Destroy alpha. + procedure, pass(lhs) :: object_assign_object !< `=` operator. endtype alpha_rec_z + contains + ! constructor + + ! deferred public methods + subroutine constr_assign_constr(lhs, rhs) + !< `=` operator. + class(alpha_rec_z_constructor), intent(inout) :: lhs !< Left hand side. + class(base_object_constructor), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + endsubroutine constr_assign_constr + ! public deferred methods subroutine create(self, constructor) !< Create alpha. @@ -89,6 +105,14 @@ elemental subroutine destroy(self) call self%destroy_ endsubroutine destroy + subroutine object_assign_object(lhs, rhs) + !< `=` operator. + class(alpha_rec_z), intent(inout) :: lhs !< Left hand side. + class(base_object), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + endsubroutine object_assign_object + ! private non TBP pure function tau(S, beta) result(w_tau) !< Compute the tau coefficient used in the WENO-Z alpha coefficients. diff --git a/src/lib/concrete_objects/wenoof_beta_int_js.f90 b/src/lib/concrete_objects/wenoof_beta_int_js.f90 index 954a16e..4f81ce7 100644 --- a/src/lib/concrete_objects/wenoof_beta_int_js.f90 +++ b/src/lib/concrete_objects/wenoof_beta_int_js.f90 @@ -7,7 +7,7 @@ module wenoof_beta_int_js !< doi:10.1137/070679065. use penf, only : I_P, R_P, str -use wenoof_base_object, only : base_object_constructor +use wenoof_base_object, only : base_object, base_object_constructor use wenoof_beta_object, only : beta_object, beta_object_constructor implicit none @@ -17,6 +17,9 @@ module wenoof_beta_int_js type, extends(beta_object_constructor) :: beta_int_js_constructor !< Jiang-Shu and Gerolymos-Senechal-Vallet beta object constructor. + contains + ! public deferred methods + procedure, pass(lhs) :: constr_assign_constr !< `=` operator. endtype beta_int_js_constructor type, extends(beta_object) :: beta_int_js @@ -29,14 +32,26 @@ module wenoof_beta_int_js real(R_P), allocatable :: coef(:,:,:) !< Beta coefficients [0:S-1,0:S-1,0:S-1]. contains ! public deferred methods - procedure, pass(self) :: create !< Create beta. - procedure, pass(self) :: compute_int !< Compute beta (interpolate). - procedure, pass(self) :: compute_rec !< Compute beta (reconstruct). - procedure, pass(self) :: description !< Return object string-description. - procedure, pass(self) :: destroy !< Destroy beta. + procedure, pass(self) :: create !< Create beta. + procedure, pass(self) :: compute_int !< Compute beta (interpolate). + procedure, pass(self) :: compute_rec !< Compute beta (reconstruct). + procedure, pass(self) :: description !< Return object string-description. + procedure, pass(self) :: destroy !< Destroy beta. + procedure, pass(lhs) :: object_assign_object !< `=` operator. endtype beta_int_js contains + ! constructor + + ! deferred public methods + subroutine constr_assign_constr(lhs, rhs) + !< `=` operator. + class(beta_int_js_constructor), intent(inout) :: lhs !< Left hand side. + class(base_object_constructor), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + endsubroutine constr_assign_constr + ! public deferred methods subroutine create(self, constructor) !< Create beta. @@ -2411,4 +2426,20 @@ elemental subroutine destroy(self) call self%destroy_ if (allocated(self%coef)) deallocate(self%coef) endsubroutine destroy + + subroutine object_assign_object(lhs, rhs) + !< `=` operator. + class(beta_int_js), intent(inout) :: lhs !< Left hand side. + class(base_object), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + select type(rhs) + type is(beta_int_js) + if (allocated(rhs%coef)) then + lhs%coef = rhs%coef + else + if (allocated(lhs%coef)) deallocate(lhs%coef) + endif + endselect + endsubroutine object_assign_object endmodule wenoof_beta_int_js diff --git a/src/lib/concrete_objects/wenoof_beta_rec_js.f90 b/src/lib/concrete_objects/wenoof_beta_rec_js.f90 index 7dc05d5..1d335ba 100644 --- a/src/lib/concrete_objects/wenoof_beta_rec_js.f90 +++ b/src/lib/concrete_objects/wenoof_beta_rec_js.f90 @@ -8,7 +8,7 @@ module wenoof_beta_rec_js !< doi:10.1016/j.jcp.2009.07.039 use penf, only : I_P, R_P, str -use wenoof_base_object, only : base_object_constructor +use wenoof_base_object, only : base_object, base_object_constructor use wenoof_beta_object, only : beta_object, beta_object_constructor implicit none @@ -18,6 +18,9 @@ module wenoof_beta_rec_js type, extends(beta_object_constructor) :: beta_rec_js_constructor !< Jiang-Shu and Gerolymos-Senechal-Vallet beta object constructor. + contains + ! public deferred methods + procedure, pass(lhs) :: constr_assign_constr !< `=` operator. endtype beta_rec_js_constructor type, extends(beta_object) :: beta_rec_js @@ -31,14 +34,26 @@ module wenoof_beta_rec_js real(R_P), allocatable :: coef(:,:,:) !< Beta coefficients [0:S-1,0:S-1,0:S-1]. contains ! public deferred methods - procedure, pass(self) :: create !< Create beta. - procedure, pass(self) :: compute_int !< Compute beta (interpolate). - procedure, pass(self) :: compute_rec !< Compute beta (reconstruct). - procedure, pass(self) :: description !< Return object string-description. - procedure, pass(self) :: destroy !< Destroy beta. + procedure, pass(self) :: create !< Create beta. + procedure, pass(self) :: compute_int !< Compute beta (interpolate). + procedure, pass(self) :: compute_rec !< Compute beta (reconstruct). + procedure, pass(self) :: description !< Return object string-description. + procedure, pass(self) :: destroy !< Destroy beta. + procedure, pass(lhs) :: object_assign_object !< `=` operator. endtype beta_rec_js contains + ! constructor + + ! deferred public methods + subroutine constr_assign_constr(lhs, rhs) + !< `=` operator. + class(beta_rec_js_constructor), intent(inout) :: lhs !< Left hand side. + class(base_object_constructor), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + endsubroutine constr_assign_constr + ! public deferred methods subroutine create(self, constructor) !< Create beta. @@ -2415,4 +2430,20 @@ elemental subroutine destroy(self) call self%destroy_ if (allocated(self%coef)) deallocate(self%coef) endsubroutine destroy + + subroutine object_assign_object(lhs, rhs) + !< `=` operator. + class(beta_rec_js), intent(inout) :: lhs !< Left hand side. + class(base_object), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + select type(rhs) + type is(beta_rec_js) + if (allocated(rhs%coef)) then + lhs%coef = rhs%coef + else + if (allocated(lhs%coef)) deallocate(lhs%coef) + endif + endselect + endsubroutine object_assign_object endmodule wenoof_beta_rec_js diff --git a/src/lib/concrete_objects/wenoof_interpolations_int_js.f90 b/src/lib/concrete_objects/wenoof_interpolations_int_js.f90 index 47b4598..fe59f48 100644 --- a/src/lib/concrete_objects/wenoof_interpolations_int_js.f90 +++ b/src/lib/concrete_objects/wenoof_interpolations_int_js.f90 @@ -7,7 +7,7 @@ module wenoof_interpolations_int_js !< doi:10.1137/070679065. use penf, only : I_P, R_P, str -use wenoof_base_object, only : base_object_constructor +use wenoof_base_object, only : base_object, base_object_constructor use wenoof_interpolations_object, only : interpolations_object, interpolations_object_constructor implicit none @@ -17,6 +17,11 @@ module wenoof_interpolations_int_js type, extends(interpolations_object_constructor) :: interpolations_int_js_constructor !< Jiang-Shu (Lagrange) interpolations object for function interpolation constructor. + real(R_P), allocatable :: stencil(:) !< Stencil used for interpolation, [1-S:S-1]. + real(R_P) :: x_target !< Coordinate of the interpolation point. + contains + ! public deferred methods + procedure, pass(lhs) :: constr_assign_constr !< `=` operator. endtype interpolations_int_js_constructor type, extends(interpolations_object) :: interpolations_int_js @@ -28,14 +33,35 @@ module wenoof_interpolations_int_js real(R_P), allocatable :: coef(:,:) !< Polynomial coefficients [0:S-1,0:S-1]. contains ! public deferred methods - procedure, pass(self) :: create !< Create interpolations. - procedure, pass(self) :: compute_int !< Compute interpolations (interpolate). - procedure, pass(self) :: compute_rec !< Compute interpolations (reconstruct). - procedure, pass(self) :: description !< Return object string-description. - procedure, pass(self) :: destroy !< Destroy interpolations. + procedure, pass(self) :: create !< Create interpolations. + procedure, pass(self) :: compute_int !< Compute interpolations (interpolate). + procedure, pass(self) :: compute_rec !< Compute interpolations (reconstruct). + procedure, pass(self) :: description !< Return object string-description. + procedure, pass(self) :: destroy !< Destroy interpolations. + procedure, pass(lhs) :: object_assign_object !< `=` operator. endtype interpolations_int_js contains + ! constructor + + ! deferred public methods + subroutine constr_assign_constr(lhs, rhs) + !< `=` operator. + class(interpolations_int_js_constructor), intent(inout) :: lhs !< Left hand side. + class(base_object_constructor), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + select type(rhs) + type is(interpolations_int_js_constructor) + if (allocated(rhs%stencil)) then + lhs%stencil = rhs%stencil + else + if (allocated(lhs%stencil)) deallocate(lhs%stencil) + endif + lhs%x_target = rhs%x_target + endselect + endsubroutine constr_assign_constr + ! public deferred methods subroutine create(self, constructor) !< Create interpolations. @@ -384,4 +410,20 @@ elemental subroutine destroy(self) call self%destroy_ if (allocated(self%coef)) deallocate(self%coef) endsubroutine destroy + + subroutine object_assign_object(lhs, rhs) + !< `=` operator. + class(interpolations_int_js), intent(inout) :: lhs !< Left hand side. + class(base_object), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + select type(rhs) + type is(interpolations_int_js) + if (allocated(rhs%coef)) then + lhs%coef = rhs%coef + else + if (allocated(lhs%coef)) deallocate(lhs%coef) + endif + endselect + endsubroutine object_assign_object endmodule wenoof_interpolations_int_js diff --git a/src/lib/concrete_objects/wenoof_interpolations_rec_js.f90 b/src/lib/concrete_objects/wenoof_interpolations_rec_js.f90 index 8475ab4..ba764a7 100644 --- a/src/lib/concrete_objects/wenoof_interpolations_rec_js.f90 +++ b/src/lib/concrete_objects/wenoof_interpolations_rec_js.f90 @@ -8,7 +8,7 @@ module wenoof_interpolations_rec_js !< doi:10.1016/j.jcp.2009.07.039 use penf, only : I_P, R_P, str -use wenoof_base_object, only : base_object_constructor +use wenoof_base_object, only : base_object, base_object_constructor use wenoof_interpolations_object, only : interpolations_object, interpolations_object_constructor implicit none @@ -18,6 +18,9 @@ module wenoof_interpolations_rec_js type, extends(interpolations_object_constructor) :: interpolations_rec_js_constructor !< Jiang-Shu (Lagrange) interpolations object for derivative reconstruction constructor. + contains + ! public deferred methods + procedure, pass(lhs) :: constr_assign_constr !< `=` operator. endtype interpolations_rec_js_constructor type, extends(interpolations_object) :: interpolations_rec_js @@ -31,14 +34,26 @@ module wenoof_interpolations_rec_js real(R_P), allocatable :: coef(:,:,:) !< Polynomial coefficients [1:2,0:S-1,0:S-1]. contains ! public deferred methods - procedure, pass(self) :: create !< Create interpolations. - procedure, pass(self) :: compute_int !< Compute interpolations (interpolate). - procedure, pass(self) :: compute_rec !< Compute interpolations (reconstruct). - procedure, pass(self) :: description !< Return object string-description. - procedure, pass(self) :: destroy !< Destroy interpolations. + procedure, pass(self) :: create !< Create interpolations. + procedure, pass(self) :: compute_int !< Compute interpolations (interpolate). + procedure, pass(self) :: compute_rec !< Compute interpolations (reconstruct). + procedure, pass(self) :: description !< Return object string-description. + procedure, pass(self) :: destroy !< Destroy interpolations. + procedure, pass(lhs) :: object_assign_object !< `=` operator. endtype interpolations_rec_js contains + ! constructor + + ! deferred public methods + subroutine constr_assign_constr(lhs, rhs) + !< `=` operator. + class(interpolations_rec_js_constructor), intent(inout) :: lhs !< Left hand side. + class(base_object_constructor), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + endsubroutine constr_assign_constr + ! public deferred methods subroutine create(self, constructor) !< Create interpolations. @@ -363,4 +378,20 @@ elemental subroutine destroy(self) call self%destroy_ if (allocated(self%coef)) deallocate(self%coef) endsubroutine destroy + + subroutine object_assign_object(lhs, rhs) + !< `=` operator. + class(interpolations_rec_js), intent(inout) :: lhs !< Left hand side. + class(base_object), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + select type(rhs) + type is(interpolations_rec_js) + if (allocated(rhs%coef)) then + lhs%coef = rhs%coef + else + if (allocated(lhs%coef)) deallocate(lhs%coef) + endif + endselect + endsubroutine object_assign_object endmodule wenoof_interpolations_rec_js diff --git a/src/lib/concrete_objects/wenoof_interpolator_js.f90 b/src/lib/concrete_objects/wenoof_interpolator_js.f90 index 714e515..fd38ddc 100644 --- a/src/lib/concrete_objects/wenoof_interpolator_js.f90 +++ b/src/lib/concrete_objects/wenoof_interpolator_js.f90 @@ -4,7 +4,7 @@ module wenoof_interpolator_js use, intrinsic :: iso_fortran_env, only : stderr=>error_unit use penf, only : I_P, R_P, str -use wenoof_base_object, only : base_object_constructor +use wenoof_base_object, only : base_object, base_object_constructor use wenoof_interpolations_factory, only : interpolations_factory use wenoof_interpolations_object, only : interpolations_object use wenoof_interpolator_object, only : interpolator_object, interpolator_object_constructor @@ -18,6 +18,9 @@ module wenoof_interpolator_js type, extends(interpolator_object_constructor) :: interpolator_js_constructor !< Jiang-Shu (upwind) interpolator object constructor. + contains + ! public deferred methods + procedure, pass(lhs) :: constr_assign_constr !< `=` operator. endtype interpolator_js_constructor type, extends(interpolator_object) :: interpolator_js @@ -37,9 +40,37 @@ module wenoof_interpolator_js procedure, pass(self) :: interpolate_int_standard !< Interpolate values (without providing debug values, interpolate). procedure, pass(self) :: interpolate_rec_debug !< Interpolate values (providing also debug values, reconstruct). procedure, pass(self) :: interpolate_rec_standard !< Interpolate values (without providing debug values, reconstruct). + procedure, pass(lhs) :: object_assign_object !< `=` operator. endtype interpolator_js contains + ! constructor + + ! deferred public methods + subroutine constr_assign_constr(lhs, rhs) + !< `=` operator. + class(interpolator_js_constructor), intent(inout) :: lhs !< Left hand side. + class(base_object_constructor), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + select type(rhs) + type is(interpolator_js_constructor) + if (allocated(rhs%interpolations_constructor)) then + if (.not.allocated(lhs%interpolations_constructor)) & + allocate(lhs%interpolations_constructor, mold=rhs%interpolations_constructor) + lhs%interpolations_constructor = rhs%interpolations_constructor + else + if (allocated(lhs%interpolations_constructor)) deallocate(lhs%interpolations_constructor) + endif + if (allocated(rhs%weights_constructor)) then + if (.not.allocated(lhs%weights_constructor)) allocate(lhs%weights_constructor, mold=rhs%weights_constructor) + lhs%weights_constructor = rhs%weights_constructor + else + if (allocated(lhs%weights_constructor)) deallocate(lhs%weights_constructor) + endif + endselect + endsubroutine constr_assign_constr + ! public deferred methods subroutine create(self, constructor) !< Create interpolator. @@ -133,4 +164,27 @@ pure subroutine interpolate_rec_standard(self, stencil, interpolation) real(R_P), intent(out) :: interpolation(1:) !< Result of the interpolation, [1:2]. ! empty procedure endsubroutine interpolate_rec_standard + + subroutine object_assign_object(lhs, rhs) + !< `=` operator. + class(interpolator_js), intent(inout) :: lhs !< Left hand side. + class(base_object), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + select type(rhs) + type is(interpolator_js) + if (allocated(rhs%interpolations)) then + if (.not.allocated(lhs%interpolations)) allocate(lhs%interpolations, mold=rhs%interpolations) + lhs%interpolations = rhs%interpolations + else + if (allocated(lhs%interpolations)) deallocate(lhs%interpolations) + endif + if (allocated(rhs%weights)) then + if (.not.allocated(lhs%weights)) allocate(lhs%weights, mold=rhs%weights) + lhs%weights = rhs%weights + else + if (allocated(lhs%weights)) deallocate(lhs%weights) + endif + endselect + endsubroutine object_assign_object endmodule wenoof_interpolator_js diff --git a/src/lib/concrete_objects/wenoof_kappa_int_js.f90 b/src/lib/concrete_objects/wenoof_kappa_int_js.f90 index a115428..1e5c6f6 100644 --- a/src/lib/concrete_objects/wenoof_kappa_int_js.f90 +++ b/src/lib/concrete_objects/wenoof_kappa_int_js.f90 @@ -7,7 +7,7 @@ module wenoof_kappa_int_js !< doi:10.1137/070679065. use penf, only : I_P, R_P, str -use wenoof_base_object, only : base_object_constructor +use wenoof_base_object, only : base_object, base_object_constructor use wenoof_interpolations_factory, only : interpolations_factory use wenoof_interpolations_object, only : interpolations_object, interpolations_object_constructor use wenoof_interpolations_int_js, only : interpolations_int_js @@ -23,6 +23,9 @@ module wenoof_kappa_int_js class(interpolations_object_constructor), allocatable :: interpolations_constructor !< Interpolations coefficients constructor. real(R_P), allocatable :: stencil(:) !< Stencil used for interpolation, [1-S:S-1]. real(R_P) :: x_target !< Coordinate of the interpolation point. + contains + ! public deferred methods + procedure, pass(lhs) :: constr_assign_constr !< `=` operator. endtype kappa_int_js_constructor type, extends(kappa_object):: kappa_int_js @@ -35,14 +38,42 @@ module wenoof_kappa_int_js real(R_P), allocatable :: values(:) !< Kappa coefficients values [0:S-1]. contains ! public deferred methods - procedure, pass(self) :: create !< Create kappa. - procedure, pass(self) :: compute_int !< Compute kappa (interpolate). - procedure, pass(self) :: compute_rec !< Compute kappa (reconstruct). - procedure, pass(self) :: description !< Return object string-description. - procedure, pass(self) :: destroy !< Destroy kappa. + procedure, pass(self) :: create !< Create kappa. + procedure, pass(self) :: compute_int !< Compute kappa (interpolate). + procedure, pass(self) :: compute_rec !< Compute kappa (reconstruct). + procedure, pass(self) :: description !< Return object string-description. + procedure, pass(self) :: destroy !< Destroy kappa. + procedure, pass(lhs) :: object_assign_object !< `=` operator. endtype kappa_int_js contains + ! constructor + + ! deferred public methods + subroutine constr_assign_constr(lhs, rhs) + !< `=` operator. + class(kappa_int_js_constructor), intent(inout) :: lhs !< Left hand side. + class(base_object_constructor), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + select type(rhs) + type is(kappa_int_js_constructor) + if (allocated(rhs%interpolations_constructor)) then + if (.not.allocated(lhs%interpolations_constructor)) & + allocate(lhs%interpolations_constructor, mold=rhs%interpolations_constructor) + lhs%interpolations_constructor = rhs%interpolations_constructor + else + if (allocated(lhs%interpolations_constructor)) deallocate(lhs%interpolations_constructor) + endif + if (allocated(rhs%stencil)) then + lhs%stencil = rhs%stencil + else + if (allocated(lhs%stencil)) deallocate(lhs%stencil) + endif + lhs%x_target = rhs%x_target + endselect + endsubroutine constr_assign_constr + ! deferred public methods subroutine create(self, constructor) !< Create kappa. @@ -252,4 +283,26 @@ elemental subroutine destroy(self) call self%destroy_ if (allocated(self%values)) deallocate(self%values) endsubroutine destroy + + subroutine object_assign_object(lhs, rhs) + !< `=` operator. + class(kappa_int_js), intent(inout) :: lhs !< Left hand side. + class(base_object), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + select type(rhs) + type is(kappa_int_js) + if (allocated(rhs%interpolations)) then + if (.not.allocated(lhs%interpolations)) allocate(lhs%interpolations, mold=rhs%interpolations) + lhs%interpolations = rhs%interpolations + else + if (allocated(lhs%interpolations)) deallocate(lhs%interpolations) + endif + if (allocated(rhs%values)) then + lhs%values = rhs%values + else + if (allocated(lhs%values)) deallocate(lhs%values) + endif + endselect + endsubroutine object_assign_object endmodule wenoof_kappa_int_js diff --git a/src/lib/concrete_objects/wenoof_kappa_rec_js.f90 b/src/lib/concrete_objects/wenoof_kappa_rec_js.f90 index 156ea9b..42b3f75 100644 --- a/src/lib/concrete_objects/wenoof_kappa_rec_js.f90 +++ b/src/lib/concrete_objects/wenoof_kappa_rec_js.f90 @@ -8,7 +8,7 @@ module wenoof_kappa_rec_js !< doi:10.1016/j.jcp.2009.07.039 use penf, only : I_P, R_P, str -use wenoof_base_object, only : base_object_constructor +use wenoof_base_object, only : base_object, base_object_constructor use wenoof_kappa_object, only : kappa_object, kappa_object_constructor implicit none @@ -18,6 +18,9 @@ module wenoof_kappa_rec_js type, extends(kappa_object_constructor) :: kappa_rec_js_constructor !< Jiang-Shu and Gerolymos-Senechal-Vallet optimal kappa object constructor. + contains + ! public deferred methods + procedure, pass(lhs) :: constr_assign_constr !< `=` operator. endtype kappa_rec_js_constructor type, extends(kappa_object):: kappa_rec_js @@ -30,14 +33,26 @@ module wenoof_kappa_rec_js real(R_P), allocatable :: values(:,:) !< Kappa coefficients values [1:2,0:S-1]. contains ! public deferred methods - procedure, pass(self) :: create !< Create kappa. - procedure, pass(self) :: compute_int !< Compute kappa (interpolate). - procedure, pass(self) :: compute_rec !< Compute kappa (reconstruct). - procedure, pass(self) :: description !< Return object string-description. - procedure, pass(self) :: destroy !< Destroy kappa. + procedure, pass(self) :: create !< Create kappa. + procedure, pass(self) :: compute_int !< Compute kappa (interpolate). + procedure, pass(self) :: compute_rec !< Compute kappa (reconstruct). + procedure, pass(self) :: description !< Return object string-description. + procedure, pass(self) :: destroy !< Destroy kappa. + procedure, pass(lhs) :: object_assign_object !< `=` operator. endtype kappa_rec_js contains + ! constructor + + ! deferred public methods + subroutine constr_assign_constr(lhs, rhs) + !< `=` operator. + class(kappa_rec_js_constructor), intent(inout) :: lhs !< Left hand side. + class(base_object_constructor), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + endsubroutine constr_assign_constr + ! deferred public methods subroutine create(self, constructor) !< Create kappa. @@ -202,4 +217,20 @@ elemental subroutine destroy(self) call self%destroy_ if (allocated(self%values)) deallocate(self%values) endsubroutine destroy + + subroutine object_assign_object(lhs, rhs) + !< `=` operator. + class(kappa_rec_js), intent(inout) :: lhs !< Left hand side. + class(base_object), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + select type(rhs) + type is(kappa_rec_js) + if (allocated(rhs%values)) then + lhs%values = rhs%values + else + if (allocated(lhs%values)) deallocate(lhs%values) + endif + endselect + endsubroutine object_assign_object endmodule wenoof_kappa_rec_js diff --git a/src/lib/concrete_objects/wenoof_reconstructor_js.f90 b/src/lib/concrete_objects/wenoof_reconstructor_js.f90 index d5e049b..ac1cdae 100644 --- a/src/lib/concrete_objects/wenoof_reconstructor_js.f90 +++ b/src/lib/concrete_objects/wenoof_reconstructor_js.f90 @@ -4,7 +4,7 @@ module wenoof_reconstructor_js use, intrinsic :: iso_fortran_env, only : stderr=>error_unit use penf, only : I_P, R_P, str -use wenoof_base_object, only : base_object_constructor +use wenoof_base_object, only : base_object, base_object_constructor use wenoof_interpolations_factory, only : interpolations_factory use wenoof_interpolations_object, only : interpolations_object use wenoof_interpolator_object, only : interpolator_object, interpolator_object_constructor @@ -18,6 +18,9 @@ module wenoof_reconstructor_js type, extends(interpolator_object_constructor) :: reconstructor_js_constructor !< Jiang-Shu (upwind) reconstructor object constructor. + contains + ! public deferred methods + procedure, pass(lhs) :: constr_assign_constr !< `=` operator. endtype reconstructor_js_constructor type, extends(interpolator_object) :: reconstructor_js @@ -37,9 +40,37 @@ module wenoof_reconstructor_js procedure, pass(self) :: interpolate_int_standard !< Interpolate values (without providing debug values, interpolate). procedure, pass(self) :: interpolate_rec_debug !< Interpolate values (providing also debug values, reconstruct). procedure, pass(self) :: interpolate_rec_standard !< Interpolate values (without providing debug values, reconstruct). + procedure, pass(lhs) :: object_assign_object !< `=` operator. endtype reconstructor_js contains + ! constructor + + ! deferred public methods + subroutine constr_assign_constr(lhs, rhs) + !< `=` operator. + class(reconstructor_js_constructor), intent(inout) :: lhs !< Left hand side. + class(base_object_constructor), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + select type(rhs) + type is(reconstructor_js_constructor) + if (allocated(rhs%interpolations_constructor)) then + if (.not.allocated(lhs%interpolations_constructor)) & + allocate(lhs%interpolations_constructor, mold=rhs%interpolations_constructor) + lhs%interpolations_constructor = rhs%interpolations_constructor + else + if (allocated(lhs%interpolations_constructor)) deallocate(lhs%interpolations_constructor) + endif + if (allocated(rhs%weights_constructor)) then + if (.not.allocated(lhs%weights_constructor)) allocate(lhs%weights_constructor, mold=rhs%weights_constructor) + lhs%weights_constructor = rhs%weights_constructor + else + if (allocated(lhs%weights_constructor)) deallocate(lhs%weights_constructor) + endif + endselect + endsubroutine constr_assign_constr + ! public deferred methods subroutine create(self, constructor) !< Create reconstructor. @@ -138,4 +169,27 @@ pure subroutine interpolate_rec_standard(self, stencil, interpolation) enddo enddo endsubroutine interpolate_rec_standard + + subroutine object_assign_object(lhs, rhs) + !< `=` operator. + class(reconstructor_js), intent(inout) :: lhs !< Left hand side. + class(base_object), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + select type(rhs) + type is(reconstructor_js) + if (allocated(rhs%interpolations)) then + if (.not.allocated(lhs%interpolations)) allocate(lhs%interpolations, mold=rhs%interpolations) + lhs%interpolations = rhs%interpolations + else + if (allocated(lhs%interpolations)) deallocate(lhs%interpolations) + endif + if (allocated(rhs%weights)) then + if (.not.allocated(lhs%weights)) allocate(lhs%weights, mold=rhs%weights) + lhs%weights = rhs%weights + else + if (allocated(lhs%weights)) deallocate(lhs%weights) + endif + endselect + endsubroutine object_assign_object endmodule wenoof_reconstructor_js diff --git a/src/lib/concrete_objects/wenoof_weights_int_js.f90 b/src/lib/concrete_objects/wenoof_weights_int_js.f90 index 5181eb8..3c39fdf 100644 --- a/src/lib/concrete_objects/wenoof_weights_int_js.f90 +++ b/src/lib/concrete_objects/wenoof_weights_int_js.f90 @@ -10,7 +10,7 @@ module wenoof_weights_int_js use penf, only : I_P, R_P, str use wenoof_alpha_factory, only : alpha_factory use wenoof_alpha_object, only : alpha_object, alpha_object_constructor -use wenoof_base_object, only : base_object_constructor +use wenoof_base_object, only : base_object, base_object_constructor use wenoof_beta_factory, only : beta_factory use wenoof_beta_object, only : beta_object, beta_object_constructor use wenoof_kappa_factory, only : kappa_factory @@ -28,6 +28,9 @@ module wenoof_weights_int_js class(alpha_object_constructor), allocatable :: alpha_constructor !< Alpha coefficients (non linear weights) constructor. class(beta_object_constructor), allocatable :: beta_constructor !< Beta coefficients (smoothness indicators) constructor. class(kappa_object_constructor), allocatable :: kappa_constructor !< kappa coefficients (optimal, linear weights) constructor. + contains + ! public deferred methods + procedure, pass(lhs) :: constr_assign_constr !< `=` operator. endtype weights_int_js_constructor type, extends(weights_object):: weights_int_js @@ -49,9 +52,42 @@ module wenoof_weights_int_js procedure, pass(self) :: destroy !< Destroy weights. procedure, pass(self) :: smoothness_indicators_int !< Return smoothness indicators (interpolate). procedure, pass(self) :: smoothness_indicators_rec !< Return smoothness indicators (reconstrcut). + procedure, pass(lhs) :: object_assign_object !< `=` operator. endtype weights_int_js contains + ! constructor + + ! deferred public methods + subroutine constr_assign_constr(lhs, rhs) + !< `=` operator. + class(weights_int_js_constructor), intent(inout) :: lhs !< Left hand side. + class(base_object_constructor), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + select type(rhs) + type is(weights_int_js_constructor) + if (allocated(rhs%alpha_constructor)) then + if (.not.allocated(lhs%alpha_constructor)) allocate(lhs%alpha_constructor, mold=rhs%alpha_constructor) + lhs%alpha_constructor = rhs%alpha_constructor + else + if (allocated(lhs%alpha_constructor)) deallocate(lhs%alpha_constructor) + endif + if (allocated(rhs%beta_constructor)) then + if (.not.allocated(lhs%beta_constructor)) allocate(lhs%beta_constructor, mold=rhs%beta_constructor) + lhs%beta_constructor = rhs%beta_constructor + else + if (allocated(lhs%beta_constructor)) deallocate(lhs%beta_constructor) + endif + if (allocated(rhs%kappa_constructor)) then + if (.not.allocated(lhs%kappa_constructor)) allocate(lhs%kappa_constructor, mold=rhs%kappa_constructor) + lhs%kappa_constructor = rhs%kappa_constructor + else + if (allocated(lhs%kappa_constructor)) deallocate(lhs%kappa_constructor) + endif + endselect + endsubroutine constr_assign_constr + ! deferred public methods subroutine create(self, constructor) !< Create reconstructor. @@ -141,4 +177,33 @@ pure subroutine smoothness_indicators_rec(self, si) real(R_P), intent(out) :: si(:,:) !< Smoothness indicators. ! empty procedure endsubroutine smoothness_indicators_rec + + subroutine object_assign_object(lhs, rhs) + !< `=` operator. + class(weights_int_js), intent(inout) :: lhs !< Left hand side. + class(base_object), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + select type(rhs) + type is(weights_int_js) + if (allocated(rhs%alpha)) then + if (.not.allocated(lhs%alpha)) allocate(lhs%alpha, mold=rhs%alpha) + lhs%alpha = rhs%alpha + else + if (allocated(lhs%alpha)) deallocate(lhs%alpha) + endif + if (allocated(rhs%beta)) then + if (.not.allocated(lhs%beta)) allocate(lhs%beta, mold=rhs%beta) + lhs%beta = rhs%beta + else + if (allocated(lhs%beta)) deallocate(lhs%beta) + endif + if (allocated(rhs%kappa)) then + if (.not.allocated(lhs%kappa)) allocate(lhs%kappa, mold=rhs%kappa) + lhs%kappa = rhs%kappa + else + if (allocated(lhs%kappa)) deallocate(lhs%kappa) + endif + endselect + endsubroutine object_assign_object endmodule wenoof_weights_int_js diff --git a/src/lib/concrete_objects/wenoof_weights_rec_js.f90 b/src/lib/concrete_objects/wenoof_weights_rec_js.f90 index 745ca09..97c72c4 100644 --- a/src/lib/concrete_objects/wenoof_weights_rec_js.f90 +++ b/src/lib/concrete_objects/wenoof_weights_rec_js.f90 @@ -10,7 +10,7 @@ module wenoof_weights_rec_js use penf, only : I_P, R_P, str use wenoof_alpha_factory, only : alpha_factory use wenoof_alpha_object, only : alpha_object, alpha_object_constructor -use wenoof_base_object, only : base_object_constructor +use wenoof_base_object, only : base_object, base_object_constructor use wenoof_beta_factory, only : beta_factory use wenoof_beta_object, only : beta_object, beta_object_constructor use wenoof_kappa_factory, only : kappa_factory @@ -28,6 +28,9 @@ module wenoof_weights_rec_js class(alpha_object_constructor), allocatable :: alpha_constructor !< Alpha coefficients (non linear weights) constructor. class(beta_object_constructor), allocatable :: beta_constructor !< Beta coefficients (smoothness indicators) constructor. class(kappa_object_constructor), allocatable :: kappa_constructor !< kappa coefficients (optimal, linear weights) constructor. + contains + ! public deferred methods + procedure, pass(lhs) :: constr_assign_constr !< `=` operator. endtype weights_rec_js_constructor type, extends(weights_object):: weights_rec_js @@ -49,9 +52,42 @@ module wenoof_weights_rec_js procedure, pass(self) :: destroy !< Destroy weights. procedure, pass(self) :: smoothness_indicators_int !< Return smoothness indicators (interpolate). procedure, pass(self) :: smoothness_indicators_rec !< Return smoothness indicators (reconstruct). + procedure, pass(lhs) :: object_assign_object !< `=` operator. endtype weights_rec_js contains + ! constructor + + ! deferred public methods + subroutine constr_assign_constr(lhs, rhs) + !< `=` operator. + class(weights_rec_js_constructor), intent(inout) :: lhs !< Left hand side. + class(base_object_constructor), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + select type(rhs) + type is(weights_rec_js_constructor) + if (allocated(rhs%alpha_constructor)) then + if (.not.allocated(lhs%alpha_constructor)) allocate(lhs%alpha_constructor, mold=rhs%alpha_constructor) + lhs%alpha_constructor = rhs%alpha_constructor + else + if (allocated(lhs%alpha_constructor)) deallocate(lhs%alpha_constructor) + endif + if (allocated(rhs%beta_constructor)) then + if (.not.allocated(lhs%beta_constructor)) allocate(lhs%beta_constructor, mold=rhs%beta_constructor) + lhs%beta_constructor = rhs%beta_constructor + else + if (allocated(lhs%beta_constructor)) deallocate(lhs%beta_constructor) + endif + if (allocated(rhs%kappa_constructor)) then + if (.not.allocated(lhs%kappa_constructor)) allocate(lhs%kappa_constructor, mold=rhs%kappa_constructor) + lhs%kappa_constructor = rhs%kappa_constructor + else + if (allocated(lhs%kappa_constructor)) deallocate(lhs%kappa_constructor) + endif + endselect + endsubroutine constr_assign_constr + ! deferred public methods subroutine create(self, constructor) !< Create reconstructor. @@ -144,4 +180,33 @@ pure subroutine smoothness_indicators_rec(self, si) real(R_P), intent(out) :: si(:,:) !< Smoothness indicators. ! TODO implement this endsubroutine smoothness_indicators_rec + + subroutine object_assign_object(lhs, rhs) + !< `=` operator. + class(weights_rec_js), intent(inout) :: lhs !< Left hand side. + class(base_object), intent(in) :: rhs !< Right hand side. + + call lhs%assign_(rhs=rhs) + select type(rhs) + type is(weights_rec_js) + if (allocated(rhs%alpha)) then + if (.not.allocated(lhs%alpha)) allocate(lhs%alpha, mold=rhs%alpha) + lhs%alpha = rhs%alpha + else + if (allocated(lhs%alpha)) deallocate(lhs%alpha) + endif + if (allocated(rhs%beta)) then + if (.not.allocated(lhs%beta)) allocate(lhs%beta, mold=rhs%beta) + lhs%beta = rhs%beta + else + if (allocated(lhs%beta)) deallocate(lhs%beta) + endif + if (allocated(rhs%kappa)) then + if (.not.allocated(lhs%kappa)) allocate(lhs%kappa, mold=rhs%kappa) + lhs%kappa = rhs%kappa + else + if (allocated(lhs%kappa)) deallocate(lhs%kappa) + endif + endselect + endsubroutine object_assign_object endmodule wenoof_weights_rec_js diff --git a/src/lib/factories/wenoof_interpolations_factory.f90 b/src/lib/factories/wenoof_interpolations_factory.f90 index bd1c6c7..4e89f95 100644 --- a/src/lib/factories/wenoof_interpolations_factory.f90 +++ b/src/lib/factories/wenoof_interpolations_factory.f90 @@ -58,9 +58,12 @@ subroutine create_constructor_int(interpolator_type, S, stencil, x_target, const class(interpolations_object_constructor), allocatable, intent(out) :: constructor !< Constructor. allocate(interpolations_int_js_constructor :: constructor) - allocate(constructor%stencil(1-S:S-1)) - constructor%stencil = stencil - constructor%x_target = x_target + select type(constructor) + type is(interpolations_int_js_constructor) + allocate(constructor%stencil(1-S:S-1)) + constructor%stencil = stencil + constructor%x_target = x_target + endselect call constructor%create(S=S) endsubroutine create_constructor_int endmodule wenoof_interpolations_factory diff --git a/src/lib/factories/wenoof_interpolator_factory.f90 b/src/lib/factories/wenoof_interpolator_factory.f90 index e90ee74..2f9fe0d 100644 --- a/src/lib/factories/wenoof_interpolator_factory.f90 +++ b/src/lib/factories/wenoof_interpolator_factory.f90 @@ -60,11 +60,15 @@ subroutine create_constructor(interpolator_type, S, interpolations_constructor, call constructor%create(S=S) select type(constructor) type is(interpolator_js_constructor) - allocate(constructor%interpolations_constructor, source=interpolations_constructor) - allocate(constructor%weights_constructor, source=weights_constructor) + allocate(constructor%interpolations_constructor, mold=interpolations_constructor) + constructor%interpolations_constructor = interpolations_constructor + allocate(constructor%weights_constructor, mold=weights_constructor) + constructor%weights_constructor = weights_constructor type is(reconstructor_js_constructor) - allocate(constructor%interpolations_constructor, source=interpolations_constructor) - allocate(constructor%weights_constructor, source=weights_constructor) + allocate(constructor%interpolations_constructor, mold=interpolations_constructor) + constructor%interpolations_constructor = interpolations_constructor + allocate(constructor%weights_constructor, mold=weights_constructor) + constructor%weights_constructor = weights_constructor endselect endsubroutine create_constructor endmodule wenoof_interpolator_factory diff --git a/src/lib/factories/wenoof_kappa_factory.f90 b/src/lib/factories/wenoof_kappa_factory.f90 index d06a3d9..1c6a634 100644 --- a/src/lib/factories/wenoof_kappa_factory.f90 +++ b/src/lib/factories/wenoof_kappa_factory.f90 @@ -65,7 +65,8 @@ subroutine create_constructor_int(interpolator_type, S, stencil, x_target, inter constructor%stencil = stencil constructor%x_target = x_target call constructor%create(S=S) - allocate(constructor%interpolations_constructor, source=interpolations_constructor) + allocate(constructor%interpolations_constructor, mold=interpolations_constructor) + constructor%interpolations_constructor = interpolations_constructor endselect endsubroutine create_constructor_int endmodule wenoof_kappa_factory diff --git a/src/lib/factories/wenoof_weights_factory.f90 b/src/lib/factories/wenoof_weights_factory.f90 index 26758c1..ced46b8 100644 --- a/src/lib/factories/wenoof_weights_factory.f90 +++ b/src/lib/factories/wenoof_weights_factory.f90 @@ -74,13 +74,19 @@ subroutine create_constructor(interpolator_type, S, alpha_constructor, beta_cons call constructor%create(S=S) select type(constructor) type is(weights_int_js_constructor) - allocate(constructor%alpha_constructor, source=alpha_constructor) - allocate(constructor%beta_constructor, source=beta_constructor) - allocate(constructor%kappa_constructor, source=kappa_constructor) + allocate(constructor%alpha_constructor, mold=alpha_constructor) + constructor%alpha_constructor = alpha_constructor + allocate(constructor%beta_constructor, mold=beta_constructor) + constructor%beta_constructor = beta_constructor + allocate(constructor%kappa_constructor, mold=kappa_constructor) + constructor%kappa_constructor = kappa_constructor type is(weights_rec_js_constructor) - allocate(constructor%alpha_constructor, source=alpha_constructor) - allocate(constructor%beta_constructor, source=beta_constructor) - allocate(constructor%kappa_constructor, source=kappa_constructor) + allocate(constructor%alpha_constructor, mold=alpha_constructor) + constructor%alpha_constructor = alpha_constructor + allocate(constructor%beta_constructor, mold=beta_constructor) + constructor%beta_constructor = beta_constructor + allocate(constructor%kappa_constructor, mold=kappa_constructor) + constructor%kappa_constructor = kappa_constructor endselect endsubroutine create_constructor endmodule wenoof_weights_factory diff --git a/src/tests/wenoof_test_linear_advection.f90 b/src/tests/wenoof_test_linear_advection.f90 index 8812341..59acc79 100644 --- a/src/tests/wenoof_test_linear_advection.f90 +++ b/src/tests/wenoof_test_linear_advection.f90 @@ -328,7 +328,8 @@ subroutine advection_assign_advection(lhs, rhs) if (allocated(rhs%BC_R)) lhs%BC_R = rhs%BC_R if (allocated(rhs%interpolator)) then if (allocated(lhs%interpolator)) deallocate(lhs%interpolator) - allocate(lhs%interpolator, source=rhs%interpolator) + allocate(lhs%interpolator, mold=rhs%interpolator) + lhs%interpolator = rhs%interpolator endif endselect endsubroutine advection_assign_advection