RockyML  0.0.1
A High-Performance Scientific Computing Framework
init.h
1 /*
2  Copyright (C) 2022 Amirabbas Asadi , All Rights Reserved
3  distributed under Apache-2.0 license
4 */
5 #ifndef ROCKY_ZAGROS_INIT_STRATEGY
6 #define ROCKY_ZAGROS_INIT_STRATEGY
7 #include <rocky/zagros/strategies/strategy.h>
8 
9 namespace rocky{
10 namespace zagros{
11 
16 template<typename T_e, int T_dim>
17 class init_strategy: public basic_strategy<T_e, T_dim>{};
18 
23 template<typename T_e, int T_dim>
24 class uniform_init_strategy: public init_strategy<T_e, T_dim>{
25 protected:
26  system<T_e>* problem_;
27  basic_scontainer<T_e, T_dim>* container_;
28 
29  T_e rand_uniform(T_e lb, T_e ub){
30  std::uniform_real_distribution<T_e> dist(lb, ub);
31  return dist(rocky::utils::random::prng());
32  }
33 public:
35  this->problem_ = problem;
36  this->container_ = container;
37  }
38  virtual void apply(){
39  tbb::parallel_for(0, this->container_->n_particles(), [&](auto p){
40  for(int d=0; d<T_dim; ++d)
41  this->container_->particle(p)[d] = rand_uniform(this->problem_->lower_bound(p), this->problem_->upper_bound(p));
42  });
43  };
44 };
45 
46 
47 };
48 };
49 #endif
rocky::zagros::uniform_init_strategy
Uniform initializer.
Definition: init.h:24
rocky::zagros::init_strategy
Interface for initialization strategies.
Definition: init.h:17
rocky::zagros::basic_scontainer
a data container representing a scontainer
Definition: scontainer.h:31
rocky::zagros::system
Definition: system.h:20
rocky::zagros::basic_strategy
Interface for all strategies.
Definition: strategy.h:31