Vlasiator ebf0dd394 on dev (v5.4.0 + 1054 commits)
Loading...
Searching...
No Matches
vlsvextract.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 * File: vlsvextract.h
23 * Author: sandroos
24 *
25 * Created on April 14, 2015, 2:08 PM
26 *
27 */
28
29#ifndef VLSVEXTRACT_H
30#define VLSVEXTRACT_H
31
32#include <cstdlib>
33#include <array>
34#include <vector>
35
36#include "definitions.h"
37
38//A struct for holding info on cell structure (the grid)
39struct CellStructure {
40 uint64_t cell_bounds[3];
41 Real cell_length[3];
43
44 uint64_t vcell_bounds[3];
47 uint32_t maxVelRefLevel;
48
51};
52
53template<typename REAL>
54struct NodeCrd {
55 static REAL EPS;
56 REAL x;
57 REAL y;
58 REAL z;
59
60 NodeCrd(const REAL& x, const REAL& y, const REAL& z);
61
62 bool comp(const NodeCrd<REAL>& n) const;
63};
64
65struct NodeComp {
66 bool operator()(const NodeCrd<double>& a, const NodeCrd<double>& b) const;
67 bool operator()(const NodeCrd<float>& a, const NodeCrd<float>& b) const;
68};
69
70//A class for holding user options
72public:
78 uint64_t cellId;
79 std::vector<uint64_t> cellIdList;
81 std::vector<std::string> outputDirectoryPath;
82 std::array<Real, 3> coordinates;
83 std::array<Real, 3> point1;
84 std::array<Real, 3> point2;
85
87 getCellIdFromLine = false;
88 getCellIdFromInput = false;
90 rotateVectors = false;
91 plasmaFrame =false;
92 cellId = std::numeric_limits<uint64_t>::max();
94 }
95
97};
98
99bool setVelocityMeshVariables(vlsv::Reader& vlsvReader,CellStructure& cellStruct);
100bool setVelocityMeshVariables(vlsv::Reader& vlsvReader,CellStructure& cellStruct,
101 const std::string& popName);
102
103template<typename REAL> inline
104NodeCrd<REAL>::NodeCrd(const REAL& x,const REAL& y,const REAL& z): x(x),y(y),z(z) { }
105
106template<typename REAL> inline
107bool NodeCrd<REAL>::comp(const NodeCrd<REAL>& n) const {
108 REAL EPS1, EPS2, EPS;
109 EPS1 = 1.0e-6 * fabs(x);
110 EPS2 = 1.0e-6 * fabs(n.x);
111 if (x == 0.0) EPS1 = 1.0e-7;
112 if (n.x == 0.0) EPS2 = 1.0e-7;
113 EPS = max(EPS1, EPS2);
114 if (fabs(x - n.x) > EPS) return false;
115
116 EPS1 = 1.0e-6 * fabs(y);
117 EPS2 = 1.0e-6 * fabs(n.y);
118 if (y == 0.0) EPS1 = 1.0e-7;
119 if (n.y == 0.0) EPS2 = 1.0e-7;
120 EPS = max(EPS1, EPS2);
121 if (fabs(y - n.y) > EPS) return false;
122
123 EPS1 = 1.0e-6 * fabs(z);
124 EPS2 = 1.0e-6 * fabs(n.z);
125 if (z == 0.0) EPS1 = 1.0e-7;
126 if (n.z == 0.0) EPS2 = 1.0e-7;
127 EPS = max(EPS1, EPS2);
128 if (fabs(z - n.z) > EPS) return false;
129 return true;
130}
131
132#endif // VLSVEXTRACT_H
133
std::vector< std::string > outputDirectoryPath
Definition vlsvextract.h:81
bool rotateVectors
Definition vlsvextract.h:76
bool getCellIdFromLine
Definition vlsvextract.h:73
bool getCellIdFromInput
Definition vlsvextract.h:74
std::array< Real, 3 > point1
Definition vlsvextract.h:83
uint32_t numberOfCoordinatesInALine
Definition vlsvextract.h:80
std::array< Real, 3 > coordinates
Definition vlsvextract.h:82
bool plasmaFrame
Definition vlsvextract.h:77
std::array< Real, 3 > point2
Definition vlsvextract.h:84
std::vector< uint64_t > cellIdList
Definition vlsvextract.h:79
uint64_t cellId
Definition vlsvextract.h:78
bool getCellIdFromCoordinates
Definition vlsvextract.h:75
float Real
Definition definitions.h:41
static creal EPS
Definition fs_common.h:61
uint64_t vcell_bounds[3]
Definition vlsv2silo.cpp:52
Real min_vcoordinates[3]
Definition vlsv2silo.cpp:56
uint32_t maxVelRefLevel
Definition vlsvextract.h:47
Real vblock_length[3]
Definition vlsv2silo.cpp:54
uint64_t cell_bounds[3]
Definition vlsv2silo.cpp:45
int slicedCoords[3]
Definition vlsvextract.h:49
Real min_coordinates[3]
Definition vlsv2silo.cpp:49
Real slicedCoordValues[3]
Definition vlsvextract.h:50
Real cell_length[3]
Definition vlsv2silo.cpp:47
bool operator()(const NodeCrd< double > &a, const NodeCrd< double > &b) const
bool operator()(const NodeCrd< float > &a, const NodeCrd< float > &b) const
NodeCrd(const REAL &x, const REAL &y, const REAL &z)
bool comp(const NodeCrd< REAL > &n) const
static ARCH_HOSTDEV VecSimple< T > max(VecSimple< T > const &l, VecSimple< T > const &r)
bool setVelocityMeshVariables(vlsv::Reader &vlsvReader, CellStructure &cellStruct)