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 #ifndef SPARTA_PARTICLE_H 16 #define SPARTA_PARTICLE_H 17 18 #include "stdio.h" 19 #include "pointers.h" 20 21 namespace SPARTA_NS { 22 23 class Particle : protected Pointers { 24 public: 25 int exist; // 1 if particles exist 26 int sorted; // 1 if particles are sorted by grid cell 27 28 struct Species { // info on each particle species, read from file 29 char id[16]; // species ID 30 double molwt; // molecular weight 31 double mass; // molecular mass 32 double specwt; // species weight 33 double charge; // multiple of electron charge 34 double rotrel; // inverse rotational relaxation number 35 double rottemp[3]; // rotational temperature(s) 36 double vibtemp[4]; // vibrational temperature(s) 37 double vibrel[4]; // inverse vibrational relaxation number(s) 38 int vibdegen[4]; // vibrational mode degeneracies 39 int rotdof,vibdof; // rotational/vibrational DOF 40 int nrottemp,nvibmode; // # of rotational/vibrational temps/modes defined 41 int internaldof; // 1 if either rotdof or vibdof != 0 42 int vibdiscrete_read; // 1 if species.vib file read for this species 43 }; 44 45 struct RotFile { // extra rotation info read from rotfile 46 char id[16]; 47 double rottemp[4]; 48 int ntemp; 49 }; 50 51 struct VibFile { // extra vibration info read from vibfile 52 char id[16]; 53 double vibrel[4]; 54 double vibtemp[4]; 55 int vibdegen[4]; 56 int nmode; 57 }; 58 59 Species *species; // list of particle species info 60 int nspecies; // # of defined species 61 int maxvibmode; // max vibmode of any species (mode = dof/2) 62 63 class Mixture **mixture; 64 int nmixture; 65 int maxmixture; 66 67 struct OnePart { 68 int id; // particle ID 69 int ispecies; // particle species index 70 int icell; // which local Grid::cells the particle is in 71 double x[3]; // particle position 72 double v[3]; // particle velocity 73 double erot; // rotational energy 74 double evib; // vibrational energy 75 int flag; // used for migration status 76 double dtremain; // portion of move timestep remaining 77 double weight; // particle or cell weight, if weighting enabled 78 }; 79 80 struct OnePartRestart { 81 int id; // particle ID 82 int ispecies; // particle species index 83 cellint icell; // cell ID the particle is in 84 int nsplit; // 1 for unsplit cell 85 // else neg of sub cell index (0 to Nsplit-1) 86 double x[3]; // particle position 87 double v[3]; // particle velocity 88 double erot; // rotational energy 89 double evib; // vibrational energy 90 }; 91 92 bigint nglobal; // global # of particles 93 int nlocal; // # of particles I own 94 int maxlocal; // max # particles list can hold 95 OnePart *particles; // list of particles I own 96 97 // currently stored in grid.h for every cell, whether I own it or not 98 // not sure why storing it here is slower 99 100 //int *cellcount; // count of particles in each grid cell I own 101 //int *first; // index of first particle in each grid cell 102 103 int *next; // index of next particle in each grid cell 104 105 // extra custom vectors/arrays for per-particle data 106 // ncustom > 0 if there are any extra arrays 107 // custom attributes are created by various commands 108 // these variables are public, others below are private 109 110 int ncustom; // # of custom attributes, some may be deleted 111 int *etype; // type = INT/DOUBLE of each attribute 112 int *esize; // size = 0 for vector, N for array columns 113 int *ewhich; // index into eivec,eiarray,edvec,edarray for data 114 115 int **eivec; // pointer to each integer vector 116 int ***eiarray; // pointer to each integer array 117 double **edvec; // pointer to each double vector 118 double ***edarray; // pointer to each double array 119 120 // restart buffers, filled by read_restart 121 122 int nlocal_restart; 123 char *particle_restart; 124 125 // Kokkos settings 126 127 int copy,copymode; // 1 if copy of class (prevents deallocation of 128 // base class when child copy is destroyed) 129 130 // methods 131 132 Particle(class SPARTA *); 133 virtual ~Particle(); 134 void init(); 135 virtual void compress_migrate(int, int *); 136 void compress_rebalance(); 137 void compress_rebalance_sorted(); 138 void compress_reactions(int, int *); 139 void sort(); 140 void sort_allocate(); 141 void remove_all_from_cell(int); 142 virtual void grow(int); 143 virtual void grow_species(); 144 void grow_next(); 145 virtual void pre_weight(); 146 virtual void post_weight(); 147 148 virtual int add_particle(int, int, int, double *, double *, double, double); 149 virtual int add_particle(); 150 int clone_particle(int); 151 void add_species(int, char **); 152 void add_mixture(int, char **); 153 int find_species(char *); 154 int find_mixture(char *); 155 double erot(int, double, class RanKnuth *); 156 double evib(int, double, class RanKnuth *); 157 158 void write_restart_species(FILE *fp); 159 void read_restart_species(FILE *fp); 160 void write_restart_mixture(FILE *fp); 161 void read_restart_mixture(FILE *fp); 162 163 int size_restart(); 164 bigint size_restart_big(); 165 int pack_restart(char *); 166 void pack_restart(char *, int, int); 167 int unpack_restart(char *); 168 void unpack_restart(char *, int &, int, int); 169 170 int find_custom(char *); 171 void error_custom(); 172 virtual int add_custom(char *, int, int); 173 virtual void grow_custom(int, int, int); 174 virtual void remove_custom(int); 175 virtual void copy_custom(int, int); 176 int sizeof_custom(); 177 void write_restart_custom(FILE *fp); 178 void read_restart_custom(FILE *fp); 179 virtual void pack_custom(int, char *); 180 virtual void unpack_custom(char *, int); 181 182 bigint memory_usage(); 183 184 protected: 185 int me; 186 int maxgrid; // max # of indices first can hold 187 int maxsort; // max # of particles next can hold 188 int maxspecies; // max size of species list 189 190 FILE *fp; // file pointer for species, rotation, vibration 191 int nfile; // # of species read from file 192 int maxfile; // max size of file list 193 194 Species *filespecies; // list of species read from file 195 RotFile *filerot; // list of species rotation info read from file 196 VibFile *filevib; // list of species vibration info read from file 197 198 class RanKnuth *wrandom; // RNG for particle weighting 199 200 // extra custom vectors/arrays for per-particle data 201 // ncustom > 0 if there are any extra arrays 202 // these varaiables are private, others above are public 203 204 char **ename; // name of each attribute 205 206 int ncustom_ivec; // # of integer vector attributes 207 int ncustom_iarray; // # of integer array attributes 208 int *icustom_ivec; // index into ncustom for each integer vector 209 int *icustom_iarray; // index into ncustom for each integer array 210 int *eicol; // # of columns in each integer array (esize) 211 212 int ncustom_dvec; // # of double vector attributes 213 int ncustom_darray; // # of double array attributes 214 int *icustom_dvec; // index into ncustom for each double vector 215 int *icustom_darray; // index into ncustom for each double array 216 int *edcol; // # of columns in each double array (esize) 217 218 int *custom_restart_flag; // flag on each custom vec/array read from restart 219 // used to delete them if not redefined in 220 // restart script 221 222 // private methods 223 224 void read_species_file(); 225 void read_rotation_file(); 226 void read_vibration_file(); 227 int wordcount(char *, char **); 228 }; 229 230 } 231 232 #endif 233 234 /* ERROR/WARNING messages: 235 236 E: Per-processor particle count is too big 237 238 No processor can have more particle than fit in a 32-bit integer, 239 approximately 2 billion. 240 241 E: Illegal ... command 242 243 Self-explanatory. Check the input script syntax and compare to the 244 documentation for the command. You can use -echo screen as a 245 command-line option when running SPARTA to see the offending line. 246 247 E: Cannot open species file %s 248 249 Self-explanatory. 250 251 E: Invalid character in species ID 252 253 The only allowed characters are alphanumeric, an underscore, a plus 254 sign, or a minus sign. 255 256 E: Species ID is already defined 257 258 Species IDs must be unique. 259 260 E: Species ID does not appear in species file 261 262 Could not find the requested species in the specified file. 263 264 E: Incorrect line format in species file 265 266 Line read did not have expected number of fields. 267 268 E: Invalid species ID in species file 269 270 Species IDs are limited to 15 characters. 271 272 */ 273