Vlasiator ebf0dd394 on dev (v5.4.0 + 1054 commits)
Loading...
Searching...
No Matches
read_gaussian_population.cpp
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 * File: read_gaussian_population.cpp
23 * Author: sandroos
24 *
25 * Created on March 19, 2015.
26 */
27
28#include <cstdlib>
29#include <iostream>
30#include "../readparameters.h"
31
33
34using namespace std;
35
36namespace projects {
37
38 bool ReadGaussianPopulation::addParameters(const std::string& prefix) {
39 // Add input variables to config file reader
40 typedef Readparameters RP;
41 RP::add(prefix+".n", "Number of populations to use", 0);
42 RP::addComposing(prefix+".rho", "Number density (m^-3)");
43 RP::addComposing(prefix+".rhoPertAbsAmp", "Absolute amplitude of the density perturbation");
44 RP::addComposing(prefix+".Tx", "Temperature (K)");
45 RP::addComposing(prefix+".Ty", "Temperature");
46 RP::addComposing(prefix+".Tz", "Temperature");
47 RP::addComposing(prefix+".Vx", "Bulk velocity x component (m/s)");
48 RP::addComposing(prefix+".Vy", "Bulk velocity y component (m/s)");
49 RP::addComposing(prefix+".Vz", "Bulk velocity z component (m/s)");
50 return true;
51 }
52
53 bool ReadGaussianPopulation::getParameters(const std::string& prefix,projects::GaussianPopulation& populations) {
54 // Read values of input variables
55 typedef Readparameters RP;
56 RP::get(prefix+".n", populations.numberOfPopulations);
57 RP::get(prefix+".rho", populations.rho);
58 RP::get(prefix+".rhoPertAbsAmp", populations.rhoPertAbsAmp);
59 RP::get(prefix+".Tx", populations.Tx);
60 RP::get(prefix+".Ty", populations.Ty);
61 RP::get(prefix+".Tz", populations.Tz);
62 RP::get(prefix+".Vx", populations.Vx);
63 RP::get(prefix+".Vy", populations.Vy);
64 RP::get(prefix+".Vz", populations.Vz);
65
66 // Do some sanity check on input variables
67 bool success = true;
68 if (populations.numberOfPopulations < 1) {
69 cerr << "ERROR, you need to define at least one particle population " << __FILE__ << ":" << __LINE__ << endl;
70 success = false;
71 }
72 if (populations.numberOfPopulations != populations.rho.size()) {
73 cerr << "ERROR, number of populations does not match the size of rho in " << __FILE__ << ":" << __LINE__ << endl;
74 success = false;
75 }
76 if (populations.numberOfPopulations != populations.rhoPertAbsAmp.size()) {
77 cerr << "ERROR, number of populations does not match the size of rhoPertAbsAmp in " << __FILE__ << ":" << __LINE__ << endl;
78 success = false;
79 }
80 if (populations.numberOfPopulations != populations.Tx.size()) {
81 cerr << "ERROR, number of populations does not match the size of Tx in " << __FILE__ << ":" << __LINE__ << endl;
82 success = false;
83 }
84 if (populations.numberOfPopulations != populations.Ty.size()) {
85 cerr << "ERROR, number of populations does not match the size of Ty in " << __FILE__ << ":" << __LINE__ << endl;
86 success = false;
87 }
88 if (populations.numberOfPopulations != populations.Tz.size()) {
89 cerr << "ERROR, number of populations does not match the size of Tz in " << __FILE__ << ":" << __LINE__ << endl;
90 success = false;
91 }
92 if (populations.numberOfPopulations != populations.Vx.size()) {
93 cerr << "ERROR, number of populations does not match the size of Vx in " << __FILE__ << ":" << __LINE__ << endl;
94 success = false;
95 }
96 if (populations.numberOfPopulations != populations.Vy.size()) {
97 cerr << "ERROR, number of populations does not match the size of Vy in " << __FILE__ << ":" << __LINE__ << endl;
98 success = false;
99 }
100 if (populations.numberOfPopulations != populations.Vz.size()) {
101 cerr << "ERROR, number of populations does not match the size of Vz in " << __FILE__ << ":" << __LINE__ << endl;
102 success = false;
103 }
104 return success;
105 }
106
107} // namespace projects
bool getParameters(const std::string &prefix, projects::GaussianPopulation &populations)
bool addParameters(const std::string &prefix)