1 /* ----------------------------------------------------------------------
2    SPARTA - Stochastic PArallel Rarefied-gas Time-accurate Analyzer
3    http://sparta.sandia.gov
4    Steve Plimpton, sjplimp@sandia.gov, Michael Gallis, magalli@sandia.gov
5    Sandia National Laboratories
6 
7    Copyright (2014) Sandia Corporation.  Under the terms of Contract
8    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
9    certain rights in this software.  This software is distributed under
10    the GNU General Public License.
11 
12    See the README file in the top-level SPARTA directory.
13 ------------------------------------------------------------------------- */
14 
15 #include "math.h"
16 #include "fix_vibmode_kokkos.h"
17 #include "update.h"
18 #include "particle.h"
19 #include "collide.h"
20 #include "comm.h"
21 #include "random_mars.h"
22 #include "random_knuth.h"
23 #include "math_const.h"
24 #include "error.h"
25 #include "sparta_masks.h"
26 
27 using namespace SPARTA_NS;
28 using namespace MathConst;
29 
30 enum{INT,DOUBLE};                      // several files
31 enum{NONE,DISCRETE,SMOOTH};            // several files
32 
33 /* ---------------------------------------------------------------------- */
34 
FixVibmodeKokkos(SPARTA * sparta,int narg,char ** arg)35 FixVibmodeKokkos::FixVibmodeKokkos(SPARTA *sparta, int narg, char **arg) :
36   FixVibmode(sparta, narg, arg),
37   rand_pool(12345 + comm->me
38 #ifdef SPARTA_KOKKOS_EXACT
39             , sparta
40 #endif
41             )
42 {
43 #ifdef SPARTA_KOKKOS_EXACT
44   rand_pool.init(random);
45 #endif
46 }
47 
48 /* ---------------------------------------------------------------------- */
49 
~FixVibmodeKokkos()50 FixVibmodeKokkos::~FixVibmodeKokkos()
51 {
52 #ifdef SPARTA_KOKKOS_EXACT
53   rand_pool.destroy();
54 #endif
55 }
56 
57 /* ----------------------------------------------------------------------
58    called when a particle with index is created
59     or when temperature dependent properties need to be updated
60    populate all vibrational modes and set evib = sum of mode energies
61 ------------------------------------------------------------------------- */
62 
update_custom(int index,double temp_thermal,double temp_rot,double temp_vib,double * vstream)63 void FixVibmodeKokkos::update_custom(int index, double temp_thermal,
64                                      double temp_rot, double temp_vib,
65                                      double *vstream)
66 {
67   ParticleKokkos* particle_kk = (ParticleKokkos*) particle;
68   particle_kk->sync(Host,PARTICLE_MASK|SPECIES_MASK|CUSTOM_MASK);
69   FixVibmode::update_custom(index, temp_thermal, temp_rot, temp_vib, vstream);
70   particle_kk->modify(Host,PARTICLE_MASK|CUSTOM_MASK);
71 }
72 
73