Vlasiator ebf0dd394 on dev (v5.4.0 + 1054 commits)
Loading...
Searching...
No Matches
fs_common.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 FS_COMMON_H
24#define FS_COMMON_H
25
26#include <cstdlib>
27#include <iostream>
28#include <cmath>
29#include <vector>
30#include <map>
31#include <list>
32#include <set>
33#include <stdint.h>
34
35#include <fsgrid.hpp>
36#include <phiprof.hpp>
37
38#include "../definitions.h"
39#include "../common.h"
40#include "../parameters.h"
41#include "../projects/project.h"
44
45// Constants: not needed as such, but if field solver is implemented on GPUs
46// these force CPU to use float accuracy, which in turn helps to compare
47// CPU and GPU results.
48
49const Real HALF = 0.5;
50const Real MINUS = -1.0;
51const Real PLUS = +1.0;
52const Real THIRD = 1.0/3.0;
53const Real FOURTH = 1.0/4.0;
54const Real SIXTH = 1.0/6.0;
55const Real EIGTH = 1.0/8.0;
56const Real TENTH = 1.0/10.0;
57const Real TWELWTH = 1.0/12.0;
58const Real TWO = 2.0;
59const Real ZERO = 0.0;
60
61static creal EPS = 1.0e-30;
62
63using namespace std;
64
66 fsgrids::perbspan perbdt2,
71 fsgrids::egradpespan egradpedt2,
73 fsgrids::momentsspan momentsdt2,
75 fsgrids::dmomentsspan dmoments,
76 fsgrids::dmomentsspan dmomentsdt2,
79 fsgrids::technicalspan technical, FieldSolverGrid &fsgrid, SysBoundary& sysBoundaries,
80 creal& dt, cuint subcycles);
81
83
94
95std::array<Real, Rec::N_REC_COEFFICIENTS>
98 const fsgrid::FsStencil& stencil, Real reconstructionOrder);
99
100std::array<Real, 3> interpolatePerturbedB(
104 std::map<std::array<int, 3>, std::array<Real, Rec::N_REC_COEFFICIENTS>>& reconstructionCoefficientsCache,
105 cint i,
106 cint j,
107 cint k,
108 const std::array<Real, 3> x
109);
110
111std::array<Real, 3> interpolateCurlB(
115 std::map<std::array<int, 3>, std::array<Real, Rec::N_REC_COEFFICIENTS>>& reconstructionCoefficientsCache,
116 cint i,
117 cint j,
118 cint k,
119 const std::array<Real, 3> x
120);
121
122#endif
for i
Definition Dispersion.m:24
dt
Definition Dispersion.m:39
SysBoundary contains the SysBoundaryConditions used in the simulation.
Definition sysboundary.h:54
const uint32_t cuint
Definition definitions.h:50
float Real
Definition definitions.h:41
const int cint
Definition definitions.h:45
fsgrid::FsGrid< FS_STENCIL_WIDTH > FieldSolverGrid
Definition definitions.h:78
const float creal
Definition definitions.h:42
static creal EPS
Definition fs_common.h:61
const Real THIRD
Definition fs_common.h:52
const Real TWELWTH
Definition fs_common.h:57
const Real EIGTH
Definition fs_common.h:55
const Real MINUS
Definition fs_common.h:50
std::array< Real, 3 > interpolateCurlB(fsgrids::perbspan perb, fsgrids::constdperbspan dperb, fsgrids::technicalspan technical, FieldSolverGrid &fsgrid, std::map< std::array< int, 3 >, std::array< Real, Rec::N_REC_COEFFICIENTS > > &reconstructionCoefficientsCache, cint i, cint j, cint k, const std::array< Real, 3 > x)
const Real HALF
Definition fs_common.h:49
const Real PLUS
Definition fs_common.h:51
const Real TENTH
Definition fs_common.h:56
const Real ZERO
Definition fs_common.h:59
const Real TWO
Definition fs_common.h:58
Real divideIfNonZero(creal rhoV, creal rho)
Helper function.
Definition fs_common.cpp:33
std::array< Real, Rec::N_REC_COEFFICIENTS > reconstructionCoefficients(fsgrids::perbspan perb, fsgrids::constdperbspan dperb, const fsgrid::FsStencil &stencil, Real reconstructionOrder)
Low-level helper function.
Definition fs_common.cpp:53
bool propagateFields(fsgrids::perbspan perb, fsgrids::perbspan perbdt2, fsgrids::efieldspan e, fsgrids::efieldspan edt2, fsgrids::ehallspan ehall, fsgrids::egradpespan egradpe, fsgrids::egradpespan egradpedt2, fsgrids::momentsspan moments, fsgrids::momentsspan momentsdt2, fsgrids::dperbspan dperb, fsgrids::dmomentsspan dmoments, fsgrids::dmomentsspan dmomentsdt2, fsgrids::bgbspan bgb, fsgrids::volspan vol, fsgrids::technicalspan technical, FieldSolverGrid &fsgrid, SysBoundary &sysBoundaries, creal &dt, cuint subcycles)
Top-level field propagation function.
Definition ldz_main.cpp:91
const Real SIXTH
Definition fs_common.h:54
const Real FOURTH
Definition fs_common.h:53
std::array< Real, 3 > interpolatePerturbedB(fsgrids::perbspan perb, fsgrids::constdperbspan dperb, fsgrids::technicalspan technical, FieldSolverGrid &fsgrid, std::map< std::array< int, 3 >, std::array< Real, Rec::N_REC_COEFFICIENTS > > &reconstructionCoefficientsCache, cint i, cint j, cint k, const std::array< Real, 3 > x)
const int j
const int k
@ b_xx
Definition fs_common.h:89
@ c_xxz
Definition fs_common.h:90
@ b_yyy
Definition fs_common.h:89
@ b_xxy
Definition fs_common.h:89
@ b_xyy
Definition fs_common.h:89
@ b_yz
Definition fs_common.h:89
@ a_x
Definition fs_common.h:88
@ a_z
Definition fs_common.h:88
@ a_xx
Definition fs_common.h:88
@ a_xy
Definition fs_common.h:88
@ a_y
Definition fs_common.h:88
@ c_xyz
Definition fs_common.h:90
@ b_yzz
Definition fs_common.h:89
@ c_yz
Definition fs_common.h:90
@ c_xzz
Definition fs_common.h:90
@ a_xxy
Definition fs_common.h:88
@ b_xyz
Definition fs_common.h:89
@ a_0
Definition fs_common.h:88
@ a_xxz
Definition fs_common.h:88
@ b_x
Definition fs_common.h:89
@ a_xxx
Definition fs_common.h:88
@ N_REC_COEFFICIENTS
Definition fs_common.h:91
@ c_yy
Definition fs_common.h:90
@ b_yyz
Definition fs_common.h:89
@ a_yz
Definition fs_common.h:88
@ b_yy
Definition fs_common.h:89
@ b_y
Definition fs_common.h:89
@ c_xy
Definition fs_common.h:90
@ c_zz
Definition fs_common.h:90
@ c_y
Definition fs_common.h:90
@ b_0
Definition fs_common.h:89
@ c_yzz
Definition fs_common.h:90
@ c_xz
Definition fs_common.h:90
@ c_yyz
Definition fs_common.h:90
@ a_xyz
Definition fs_common.h:88
@ a_yy
Definition fs_common.h:88
@ a_xz
Definition fs_common.h:88
@ c_x
Definition fs_common.h:90
@ a_xyy
Definition fs_common.h:88
@ c_z
Definition fs_common.h:90
@ b_xy
Definition fs_common.h:89
@ b_z
Definition fs_common.h:89
@ a_xzz
Definition fs_common.h:88
@ b_xz
Definition fs_common.h:89
@ a_zz
Definition fs_common.h:88
@ c_xx
Definition fs_common.h:90
@ b_zz
Definition fs_common.h:89
@ c_zzz
Definition fs_common.h:90
@ c_0
Definition fs_common.h:90
std::span< std::array< Real, fsgrids::bfield::N_BFIELD > > perbspan
Definition common.h:434
std::span< std::array< Real, fsgrids::moments::N_MOMENTS > > momentsspan
Definition common.h:446
std::span< std::array< Real, fsgrids::egradpe::N_EGRADPE > > egradpespan
Definition common.h:440
std::span< std::array< Real, fsgrids::dmoments::N_DMOMENTS > > dmomentsspan
Definition common.h:448
std::span< technical > technicalspan
Definition common.h:452
std::span< std::array< Real, bgbfield::N_BGB > > bgbspan
Definition common.h:444
std::span< std::array< Real, fsgrids::dperb::N_DPERB > > dperbspan
Definition common.h:442
std::span< std::array< Real, fsgrids::efield::N_EFIELD > > efieldspan
Definition common.h:436
std::span< std::array< Real, fsgrids::volfields::N_VOL > > volspan
Definition common.h:450
std::span< std::array< Real, fsgrids::ehall::N_EHALL > > ehallspan
Definition common.h:438
std::span< const std::array< Real, fsgrids::dperb::N_DPERB > > constdperbspan
Definition common.h:443