File tree Expand file tree Collapse file tree 4 files changed +64
-0
lines changed Expand file tree Collapse file tree 4 files changed +64
-0
lines changed Original file line number Diff line number Diff line change @@ -300,6 +300,8 @@ PYBIND11_MODULE(_PyPartMC, m) {
300300 " Options controlling the execution of run_part()."
301301 )
302302 .def (py::init<const nlohmann::json&>())
303+ .def_property_readonly (" t_max" , RunPartOpt::t_max, " total simulation time" )
304+ .def_property_readonly (" del_t" , RunPartOpt::del_t , " time step" )
303305 ;
304306
305307 py::class_<BinGrid>(m," BinGrid" )
Original file line number Diff line number Diff line change @@ -96,4 +96,27 @@ subroutine f_run_part_opt_from_json(ptr_c) bind(C)
9696 call pmc_srand(rand_init, 0 )
9797
9898 end subroutine
99+
100+ subroutine f_run_part_opt_t_max (ptr_c , t_max ) bind(C)
101+ type (run_part_opt_t), pointer :: ptr_f = > null ()
102+ type (c_ptr), intent (in ) :: ptr_c
103+ real (c_double) :: t_max
104+
105+ call c_f_pointer(ptr_c, ptr_f)
106+
107+ t_max = ptr_f% t_max
108+
109+ end subroutine
110+
111+ subroutine f_run_part_opt_del_t (ptr_c , del_t ) bind(C)
112+ type (run_part_opt_t), pointer :: ptr_f = > null ()
113+ type (c_ptr), intent (in ) :: ptr_c
114+ real (c_double) :: del_t
115+
116+ call c_f_pointer(ptr_c, ptr_f)
117+
118+ del_t = ptr_f% del_t
119+
120+ end subroutine
121+
99122end module
Original file line number Diff line number Diff line change 1313extern " C" void f_run_part_opt_ctor (void *ptr) noexcept ;
1414extern " C" void f_run_part_opt_dtor (void *ptr) noexcept ;
1515extern " C" void f_run_part_opt_from_json (const void *ptr) noexcept ;
16+ extern " C" void f_run_part_opt_t_max (const void *ptr, double *t_max) noexcept ;
17+ extern " C" void f_run_part_opt_del_t (const void *ptr, double *del_t ) noexcept ;
1618
1719struct RunPartOpt {
1820 PMCResource ptr;
@@ -24,5 +26,21 @@ struct RunPartOpt {
2426 f_run_part_opt_from_json (this ->ptr .f_arg ());
2527 gimmick_ptr ().reset ();
2628 }
29+
30+ static auto t_max (const RunPartOpt &self){
31+ double t_max;
32+
33+ f_run_part_opt_t_max (self.ptr .f_arg (), &t_max);
34+
35+ return t_max;
36+ }
37+
38+ static auto del_t (const RunPartOpt &self){
39+ double del_t ;
40+
41+ f_run_part_opt_del_t (self.ptr .f_arg (), &del_t );
42+
43+ return del_t ;
44+ }
2745};
2846
Original file line number Diff line number Diff line change @@ -53,3 +53,24 @@ def test_dtor():
5353
5454 # assert
5555 pass
56+
57+ @staticmethod
58+ def test_get_t_max ():
59+ # arrange
60+ run_part_opt = ppmc .RunPartOpt (RUN_PART_OPT_CTOR_ARG_MINIMAL )
61+
62+ # act
63+ t_max = run_part_opt .t_max
64+
65+ # assert
66+ assert t_max == RUN_PART_OPT_CTOR_ARG_MINIMAL ["t_max" ]
67+
68+ @staticmethod
69+ def test_aero_del_t ():
70+ run_part_opt = ppmc .RunPartOpt (RUN_PART_OPT_CTOR_ARG_MINIMAL )
71+
72+ # act
73+ del_t = run_part_opt .del_t
74+
75+ # assert
76+ assert del_t == RUN_PART_OPT_CTOR_ARG_MINIMAL ["del_t" ]
You can’t perform that action at this time.
0 commit comments