GraviDy  1.0
Gravitational Dynamics N-body integrator
Hermite4.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016
3  *
4  * Cristián Maureira-Fredes <cmaureirafredes@gmail.com>
5  *
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  *
19  * 3. The name of the author may not be used to endorse or promote
20  * products derived from this software without specific prior written
21  * permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
24  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
27  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
31  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
33  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  *
35  */
36 #ifndef HERMITE4_HPP
37 #define HERMITE4_HPP
38 #include "utils/Logger.hpp"
39 #include "utils/NbodyUtils.hpp"
40 #include <limits>
41 
48 class Hermite4 {
49  public:
51  ~Hermite4();
52 
59 
60  unsigned int find_particles_to_move(double ITIME);
61  void next_integration_time(double &ATIME);
62  void init_dt(double &ATIME, float ETA, double ITIME);
63  void save_old_acc_jrk(unsigned int nact);
64  void alloc_arrays_host();
65  void free_arrays_host();
66  void init_data();
67 
68  /* Virtual methods to be implemented by the different versions */
70  virtual void integration() {}
72  virtual void predicted_pos_vel(double itime, double *t, double4 *r,
73  double4 *v, Forces *f, Predictor *p) {}
75  virtual void correction_pos_vel(double itime, unsigned int nact, double *dt,
76  double *t, unsigned int *move, Predictor *p,
77  Forces *f, Forces *old, double3 *a2,
78  double3 *a3, double4 *r, double4 *v) {}
80  virtual void force_calculation(Predictor pi, Predictor pj, Forces &fi) {}
82  virtual void init_acc_jrk(Predictor *p, Forces *f) {}
84  virtual void update_acc_jrk(unsigned int nact, unsigned int *move,
85  Predictor *p, Forces *f) {}
86 
87 };
88 
89 #endif // HERMITE4_HPP
Class in charge of all the logging system in the code.
Definition: Logger.hpp:60
virtual void predicted_pos_vel(double itime, double *t, double4 *r, double4 *v, Forces *f, Predictor *p)
Prediction virtual method to be implemented.
Definition: Hermite4.hpp:72
Logger * logger
Logger object reference.
Definition: Hermite4.hpp:56
void init_dt(double &ATIME, float ETA, double ITIME)
Initialization of the timesteps of the system.
Definition: Hermite4.cpp:105
This structure contains the predicted information of a particle in some moment of the integration...
Definition: common.hpp:192
Class in charge of the general aspects of the N-body integrator.
Definition: NbodySystem.hpp:51
void save_old_acc_jrk(unsigned int nact)
Method in charge of saving the old values of the acceleration and its first derivative to be use in t...
Definition: Hermite4.cpp:142
void free_arrays_host()
Method in charge of the memory deallocation of all the data structures.
Definition: Hermite4.cpp:173
void alloc_arrays_host()
Method in charge of the memory allocation of all the data structures.
Definition: Hermite4.cpp:155
virtual void integration()
Integration virtual method to be implemented.
Definition: Hermite4.hpp:70
void next_integration_time(double &ATIME)
Methods that look for the next integration time, looking for the minimum combination of timestep and ...
Definition: Hermite4.cpp:87
General class that define the structure to be follow by any implementation of the integrator (CPU...
Definition: Hermite4.hpp:48
unsigned int find_particles_to_move(double ITIME)
Method in charge of finding all the particles that need to be updated on the following integration st...
Definition: Hermite4.cpp:62
Hermite4(NbodySystem *ns, Logger *logger, NbodyUtils *nu)
Constructor in charge of calling the allocation and initialization methods.
Definition: Hermite4.cpp:39
virtual void init_acc_jrk(Predictor *p, Forces *f)
Force initialization virtual method to be implemented.
Definition: Hermite4.hpp:82
virtual void update_acc_jrk(unsigned int nact, unsigned int *move, Predictor *p, Forces *f)
Force update virtual method to be implemented.
Definition: Hermite4.hpp:84
~Hermite4()
Destructor in charge of calling the method that free the memory.
Definition: Hermite4.cpp:51
Defining the «double3» structure based on the CUDA definition for the CPU version, which not include the CUDA headers.
Definition: common.hpp:74
virtual void force_calculation(Predictor pi, Predictor pj, Forces &fi)
Force virtual method to be implemented.
Definition: Hermite4.hpp:80
virtual void correction_pos_vel(double itime, unsigned int nact, double *dt, double *t, unsigned int *move, Predictor *p, Forces *f, Forces *old, double3 *a2, double3 *a3, double4 *r, double4 *v)
Correction virtual method to be implemented.
Definition: Hermite4.hpp:75
Class in charge of the different properties of the system.
Definition: NbodyUtils.hpp:49
This structure contains the information of the Forces of a particle in some moment of the integration...
Definition: common.hpp:207
NbodySystem * ns
NbodySystem object reference.
Definition: Hermite4.hpp:54
Defining the «double4» structure based on the CUDA definition for the CPU version, which not include the CUDA headers.
Definition: common.hpp:67
NbodyUtils * nu
NbodyUtils object reference.
Definition: Hermite4.hpp:58
void init_data()
Method that initialize all the data structures that will be used in the integration of hte system...
Definition: Hermite4.cpp:191