Vlasiator ebf0dd394 on dev (v5.4.0 + 1054 commits)
Loading...
Searching...
No Matches
project.h
Go to the documentation of this file.
1/*
2 * This file is part of Vlasiator.
3 * Copyright 2010-2016 Finnish Meteorological Institute
4 *
5 * For details of usage, see the COPYING file and read the "Rules of the Road"
6 * at http://www.physics.helsinki.fi/vlasiator/
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22
23#ifndef PROJECT_H
24#define PROJECT_H
25
27#include "fsgrid.hpp"
28#include <dccrg.hpp>
29#include <dccrg_cartesian_geometry.hpp>
30#include <random>
31
32namespace projects {
33
46 creal& vx, creal& vy, creal& vz,
47 creal& T, creal& rho, creal& mass
48 ) {
49 return rho * pow(mass / (2.0 * M_PI * physicalconstants::K_B * T), 1.5) *
50 exp(- mass * (vx*vx + vy*vy + vz*vz) / (2.0 * physicalconstants::K_B * T));
51 }
52
67 creal& vx, creal& vy, creal& vz,
68 creal& Tx, creal& Ty, creal& Tz,
69 creal& rho, creal& mass) {
70 return rho * pow(mass / (2.0 * M_PI * physicalconstants::K_B), 1.5) *
71 exp(- mass * (vx*vx/Tx + vy*vy/Ty + vz*vz/Tz) / (2.0 * physicalconstants::K_B)) /
72 sqrt(Tx*Ty*Tz);
73 }
74
75 class Project {
76 public:
77 Project();
78 virtual ~Project();
79
81 static void addParameters();
82
83 virtual Real getCorrectNumberDensity(spatial_cell::SpatialCell* cell,const uint popID) const;
84
86 virtual void getParameters();
87
89 virtual bool initialize();
90
92 virtual void hook(cuint& stage, const dccrg::Dccrg<spatial_cell::SpatialCell, dccrg::Cartesian_Geometry>& mpiGrid,
95
96 bool initialized();
97
105 virtual void setProjectBField(fsgrids::perbspan perb,
108
114 virtual void setupBeforeSetCell(const std::vector<CellID>& cells);
115
121
122 virtual bool canRefine(spatial_cell::SpatialCell* cell) const;
123
124 virtual bool shouldRefineCell(dccrg::Dccrg<spatial_cell::SpatialCell,dccrg::Cartesian_Geometry>& mpiGrid, CellID id, Real r_max2) const;
125
126 virtual bool shouldUnrefineCell(dccrg::Dccrg<spatial_cell::SpatialCell,dccrg::Cartesian_Geometry>& mpiGrid, CellID id, Real r_max2) const;
127
128 virtual bool refineSpatialCells( dccrg::Dccrg<spatial_cell::SpatialCell,dccrg::Cartesian_Geometry>& mpiGrid ) const;
129
134 virtual uint64_t adaptRefinement( dccrg::Dccrg<spatial_cell::SpatialCell,dccrg::Cartesian_Geometry>& mpiGrid ) const;
135
136
141 virtual bool forceRefinement( dccrg::Dccrg<spatial_cell::SpatialCell,dccrg::Cartesian_Geometry>& mpiGrid, int n ) const;
142
146 virtual bool filterRefined( dccrg::Dccrg<spatial_cell::SpatialCell,dccrg::Cartesian_Geometry>& mpiGrid ) const;
147
148 protected:
157 virtual uint findBlocksToInitialize(spatial_cell::SpatialCell* cell,const uint popID) const;
158
166 void setVelocitySpace(const uint popID,spatial_cell::SpatialCell* cell) const;
167
180
192 const uint popID,
193 const uint nRequested) const = 0;
194
195 void printPopulations();
196
197 virtual bool rescalesDensity(const uint popID) const;
198 void rescaleDensity(spatial_cell::SpatialCell* cell,const uint popID) const;
199
203 Real getRandomNumber(std::default_random_engine& randGen) const;
204
211 void setRandomSeed(uint64_t seedModifier, std::default_random_engine& randGen) const;
212
220 void setRandomCellSeed(spatial_cell::SpatialCell* cell, std::default_random_engine& randGen) const;
221
222 private:
223 uint seed;
224 static char rngStateBuffer[256];
225
227 };
228
230} // namespace projects
231
232
233#endif
234
sqrt(1.0+vA *vA/(c *c))) % Ion-acoustic wave cS
#define ARCH_HOSTDEV
void printPopulations()
Definition project.cpp:219
virtual void setupBeforeSetCell(const std::vector< CellID > &cells)
Definition project.cpp:142
virtual bool forceRefinement(dccrg::Dccrg< spatial_cell::SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, int n) const
Refine/unrefine spatial cells one level to the static criteria in the config.
Definition project.cpp:591
virtual Realf fillPhaseSpace(spatial_cell::SpatialCell *cell, const uint popID, const uint nRequested) const =0
virtual uint64_t adaptRefinement(dccrg::Dccrg< spatial_cell::SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid) const
Adapts refinement by one level according to the project. Returns true if any cells were refined,...
Definition project.cpp:516
virtual bool canRefine(spatial_cell::SpatialCell *cell) const
Definition project.cpp:421
Real getRandomNumber(std::default_random_engine &randGen) const
Definition project.cpp:317
virtual Real getCorrectNumberDensity(spatial_cell::SpatialCell *cell, const uint popID) const
Definition project.cpp:308
virtual bool initialize()
Definition project.cpp:113
virtual void getParameters()
Definition project.cpp:103
virtual uint findBlocksToInitialize(spatial_cell::SpatialCell *cell, const uint popID) const
Prepares a list of blocks to loop through when initialising.
Definition project.cpp:175
virtual bool shouldRefineCell(dccrg::Dccrg< spatial_cell::SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, CellID id, Real r_max2) const
Definition project.cpp:425
static char rngStateBuffer[256]
Definition project.h:224
virtual void setProjectBField(fsgrids::perbspan perb, fsgrids::bgbspan bgb, fsgrids::technicalspan technical, FieldSolverGrid &fsgrid)
Definition project.cpp:127
virtual bool refineSpatialCells(dccrg::Dccrg< spatial_cell::SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid) const
Definition project.cpp:354
static void addParameters()
Definition project.cpp:75
virtual bool rescalesDensity(const uint popID) const
Definition project.cpp:264
virtual void calcCellParameters(spatial_cell::SpatialCell *cell, creal &t)
Definition project.cpp:296
void rescaleDensity(spatial_cell::SpatialCell *cell, const uint popID) const
Definition project.cpp:272
virtual bool shouldUnrefineCell(dccrg::Dccrg< spatial_cell::SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, CellID id, Real r_max2) const
Definition project.cpp:470
void setRandomSeed(uint64_t seedModifier, std::default_random_engine &randGen) const
Definition project.cpp:326
virtual ~Project()
Definition project.cpp:73
void setRandomCellSeed(spatial_cell::SpatialCell *cell, std::default_random_engine &randGen) const
Definition project.cpp:336
void setVelocitySpace(const uint popID, spatial_cell::SpatialCell *cell) const
Sets the distribution function in a cell.
Definition project.cpp:235
bool baseClassInitialized
Definition project.h:226
virtual bool filterRefined(dccrg::Dccrg< spatial_cell::SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid) const
Boxcar filters spatial cells that were recently refined.
Definition project.cpp:601
void setCell(spatial_cell::SpatialCell *cell)
Set the perturbed fields and distribution of a cell according to the default simulation settings....
Definition project.cpp:150
const uint32_t cuint
Definition definitions.h:50
float Real
Definition definitions.h:41
uint64_t CellID
Definition definitions.h:54
float Realf
Definition definitions.h:33
fsgrid::FsGrid< FS_STENCIL_WIDTH > FieldSolverGrid
Definition definitions.h:78
const float creal
Definition definitions.h:42
std::span< std::array< Real, fsgrids::bfield::N_BFIELD > > perbspan
Definition common.h:434
std::span< technical > technicalspan
Definition common.h:452
std::span< std::array< Real, bgbfield::N_BGB > > bgbspan
Definition common.h:444
Definition common.h:560
const Real K_B
Definition common.h:571
Project * createProject()
Definition project.cpp:649
ARCH_HOSTDEV Realf MaxwellianPhaseSpaceDensity(creal &vx, creal &vy, creal &vz, creal &T, creal &rho, creal &mass)
Definition project.h:45
ARCH_HOSTDEV Realf TriMaxwellianPhaseSpaceDensity(creal &vx, creal &vy, creal &vz, creal &Tx, creal &Ty, creal &Tz, creal &rho, creal &mass)
Definition project.h:66