28 class SchedulerUtility {
34 template<
class T,
class flt>
35 inline void fields_forward_euler(
u32 field_idx,
u32 derfield_idx, flt dt) {
37 using namespace shamrock::patch;
40 shamsys::instance::get_compute_scheduler().get_queue(),
41 pdat.get_field<T>(field_idx).get_buf(),
42 pdat.get_field<T>(derfield_idx).get_buf(),
48 template<
class T,
class flt>
49 inline void fields_leapfrog_corrector(
50 u32 field_idx,
u32 derfield_idx,
u32 derfield_old_idx, flt hdt) {
52 using namespace shamrock::patch;
55 shamsys::instance::get_compute_scheduler().get_queue(),
56 pdat.get_field<T>(field_idx).get_buf(),
57 pdat.get_field<T>(derfield_idx).get_buf(),
58 pdat.get_field<T>(derfield_old_idx).get_buf(),
64 template<
class T,
class flt>
65 inline void fields_leapfrog_corrector_positive_only(
66 u32 field_idx,
u32 derfield_idx,
u32 derfield_old_idx, flt hdt) {
68 using namespace shamrock::patch;
70 integrators::leapfrog_corrector_positive_only(
71 shamsys::instance::get_compute_scheduler().get_queue(),
72 pdat.get_field<T>(field_idx).get_buf(),
73 pdat.get_field<T>(derfield_idx).get_buf(),
74 pdat.get_field<T>(derfield_old_idx).get_buf(),
80 template<
class T,
class flt>
81 inline void fields_leapfrog_corrector(
88 using namespace shamrock::patch;
91 shamsys::instance::get_compute_scheduler().get_queue(),
92 pdat.get_field<T>(field_idx).get_buf(),
93 pdat.get_field<T>(derfield_idx).get_buf(),
94 derfield_old.get_field(cur_p.
id_patch).get_buf(),
95 field_epsilon.get_field(cur_p.
id_patch).get_buf(),
96 pdat.get_obj_cnt() * derfield_old.get_nvar(),
101 template<
class T,
class flt>
102 inline void fields_leapfrog_corrector_positive_only(
109 using namespace shamrock::patch;
111 integrators::leapfrog_corrector_positive_only(
112 shamsys::instance::get_compute_scheduler().get_queue(),
113 pdat.get_field<T>(field_idx).get_buf(),
114 pdat.get_field<T>(derfield_idx).get_buf(),
115 derfield_old.get_field(cur_p.
id_patch).get_buf(),
116 field_epsilon.get_field(cur_p.
id_patch).get_buf(),
117 pdat.get_obj_cnt() * derfield_old.get_nvar(),
123 inline void fields_apply_periodicity(
u32 field_idx, std::pair<T, T> box) {
125 using namespace shamrock::patch;
128 shamsys::instance::get_compute_scheduler().get_queue(),
129 pdat.get_field<T>(field_idx).get_buf(),
136 inline void fields_apply_shearing_periodicity(
142 shambase::VecComponent<T> shear_value,
143 shambase::VecComponent<T> shear_speed) {
146 using namespace shamrock::patch;
149 shamsys::instance::get_compute_scheduler().get_queue(),
150 pdat.get_field<T>(field_idx).get_buf(),
151 pdat.get_field<T>(field_velocity).get_buf(),
162 inline void fields_swap(
u32 field_idx1,
u32 field_idx2) {
164 using namespace shamrock::patch;
167 shamsys::instance::get_compute_scheduler().get_queue(),
168 pdat.get_field<T>(field_idx1).get_buf(),
169 pdat.get_field<T>(field_idx2).get_buf(),
175 inline T compute_rank_max(
u32 field_idx) {
177 using namespace shamrock::patch;
178 T ret = shambase::VectorProperties<T>::get_min();
180 ret = sham::max(ret, pdat.get_field<T>(field_idx).compute_max());
187 inline T compute_rank_min(
u32 field_idx) {
189 using namespace shamrock::patch;
190 T ret = shambase::VectorProperties<T>::get_max();
192 ret = sham::min(ret, pdat.get_field<T>(field_idx).compute_min());
199 inline T compute_rank_sum(
u32 field_idx) {
201 using namespace shamrock::patch;
202 T ret = shambase::VectorProperties<T>::get_zero();
204 ret += pdat.get_field<T>(field_idx).compute_sum();
211 inline shambase::VecComponent<T> compute_rank_dot_sum(
u32 field_idx) {
213 using namespace shamrock::patch;
214 shambase::VecComponent<T> ret = 0;
216 ret += pdat.get_field<T>(field_idx).compute_dot_sum();
234 using namespace shamrock::patch;
237 cfield.field_data.add_obj(id_patch, pdat_field.duplicate(new_name));
247 using namespace shamrock::patch;
250 cfield.field_data.add_obj(id_patch, pdat_field.duplicate(new_name));
267 using namespace shamrock::patch;
269 if (pdat.get_obj_cnt() == 0) {
272 auto it = cfield.field_data.add_obj(
291 std::string new_name,
u32 nvar, std::function<
u32(
u64)> size_getter) {
294 using namespace shamrock::patch;
296 if (pdat.get_obj_cnt() == 0) {
299 auto it = cfield.field_data.add_obj(
321 using namespace shamrock::patch;
323 auto it = cfield.field_data.add_obj(
327 ins.override(value_init);