KIDS  ver-0.0.1
KIDS : Kernel Integrated Dynamics Simulator
Loading...
Searching...
No Matches
Kernel_Iter.cpp
Go to the documentation of this file.
1#include "kids/Kernel_Iter.h"
2
3#include "kids/hash_fnv1a.h"
4#include "kids/macro_utils.h"
5#include "kids/vars_list.h"
6
7namespace PROJECT_NS {
8
9const std::string Kernel_Iter::getName() { return "Kernel_Iter"; }
10
12
13void Kernel_Iter::setInputParam_impl(std::shared_ptr<Param>& PM) {
14 t0 = PM->get_double("t0", LOC(), phys::time_d, 0.0f);
15 tend = PM->get_double("tend", LOC(), phys::time_d, 1.0f);
16 dt = PM->get_double("dt", LOC(), phys::time_d, 0.1f);
17 sstep = PM->get_int("sstep", LOC(), 1);
18 nstep = sstep * (int((tend - t0) / (sstep * dt)) + 1); // @bug?
19 nsamp = nstep / sstep + 1;
20}
21
22void Kernel_Iter::setInputDataSet_impl(std::shared_ptr<DataSet>& DS) {
23 t_ptr = DS->def(DATA::iter::t);
24 dt_ptr = DS->def(DATA::iter::dt);
29 succ_ptr = DS->def(DATA::iter::succ);
30 // initializarion
31 DS->def_int("iter.sstep", &sstep);
32 DS->def_int("iter.nstep", &nstep);
33 DS->def_int("iter.nsamp", &nsamp);
34}
35
37 t_ptr[0] = t0;
38 dt_ptr[0] = dt;
39 istep_ptr[0] = 0;
40 isamp_ptr[0] = 0;
41 succ_ptr[0] = true;
42 return stat;
43}
44
46 while (istep_ptr[0] < nstep) {
47 at_samplingstep_finally_ptr[0] = ((istep_ptr[0] + 1) % sstep == 0);
49
50 for (auto& pkernel : _child_kernels) { pkernel->executeKernel(stat); }
51
52 t_ptr[0] += dt_ptr[0];
53
54 istep_ptr[0]++;
55 isamp_ptr[0] = istep_ptr[0] / sstep;
56 }
57 at_samplingstep_initially_ptr[0] = true; // only record!
58 dt_ptr[0] = 0; // no-dynamics!
59 return stat;
60}
61}; // namespace PROJECT_NS
virtual const std::string getName()
Get the name of the kernel.
virtual void setInputDataSet_impl(std::shared_ptr< DataSet > &DS)
Virtual function to set input data set for the kernel implementation.
virtual int getType() const
Get the type of the kernel.
kids_bint * at_samplingstep_finally_ptr
Definition Kernel_Iter.h:25
virtual Status & executeKernel_impl(Status &stat)
Virtual function to execute the kernel implementation.
virtual Status & initializeKernel_impl(Status &stat)
Virtual function to initialize the kernel implementation.
virtual void setInputParam_impl(std::shared_ptr< Param > &PM)
Virtual function to set input parameters for the kernel implementation.
kids_bint * at_samplingstep_initially_ptr
Definition Kernel_Iter.h:24
std::vector< std::shared_ptr< Kernel > > _child_kernels
Vector containing shared pointers to the child kernels of this kernel.
Definition Kernel.h:298
#define LOC()
show the location information for debug
Definition fmt.h:49
#define FUNCTION_NAME
Definition macro_utils.h:9
VARIABLE< kids_real > dt
VARIABLE< kids_real > t
VARIABLE< kids_bint > at_samplingstep_finally
VARIABLE< kids_bint > at_samplingstep_initially
VARIABLE< kids_int > istep
VARIABLE< kids_int > isamp
VARIABLE< kids_bint > succ
< http://warp.povusers.org/FunctionParser/fparser.html
Definition Context.h:39
constexpr dimension7 time_d
[T]
Definition phys.h:187
constexpr uint32_t hash(const char *str)
Definition hash_fnv1a.h:12
declaration of variables used in the program.