Garfield++ 3.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
BGMesh.cpp
Go to the documentation of this file.
1#include <cmath>
2
5
6namespace Heed {
7
8BGMesh::BGMesh(double fxmin, double fxmax, long fq)
9 : xmin(fxmin), xmax(fxmax), q(fq) {
10
11 mfunname("BGMesh::BGMesh(double fxmin, double fxmax, long fq)");
12 // The minimum is one interval and two points.
13 check_econd11(fq, <= 1, mcerr);
14 const double rk = pow(fxmax / fxmin, 1. / double(fq - 1));
15 x.resize(fq);
16 x[0] = fxmin;
17 x[fq - 1] = fxmax;
18 double xr = fxmin;
19 for (long n = 1; n < fq - 1; n++) {
20 xr *= rk;
21 x[n] = xr;
22 }
23}
24
25void BGMesh::print(std::ostream& file, int l) const {
26 if (l <= 0) return;
27 Ifile << "BGMesh (l=" << l << "): \n";
28 indn.n += 2;
29 Ifile << "xmin=" << xmin << " xmax=" << xmax << " quantity of intervals=" << q
30 << '\n';
31 if (l > 1) {
32 for (long k = 1; k < q; ++k) Iprintn(mcout, x[k]);
33 }
34 indn.n -= 2;
35}
36
37std::ostream& operator<<(std::ostream& file, const BGMesh& bgm) {
38 Ifile << "operator<<(std::ostream& file, const BGMesh& bgm):\n";
39 bgm.print(file, 2);
40 return file;
41}
42}
#define check_econd11(a, signb, stream)
Definition: FunNameStack.h:155
#define mfunname(string)
Definition: FunNameStack.h:45
Mesh of values.
Definition: BGMesh.h:10
void print(std::ostream &file, int l) const
Definition: BGMesh.cpp:25
long q
Total number of points (not number of intervals).
Definition: BGMesh.h:17
double xmin
Definition: BGMesh.h:14
std::vector< double > x
Definition: BGMesh.h:18
BGMesh()=default
double xmax
Definition: BGMesh.h:15
Definition: BGMesh.cpp:6
std::ostream & operator<<(std::ostream &file, const BGMesh &bgm)
Definition: BGMesh.cpp:37
DoubleAc pow(const DoubleAc &f, double p)
Definition: DoubleAc.cpp:337
indentation indn
Definition: prstream.cpp:15
#define mcout
Definition: prstream.h:126
#define Ifile
Definition: prstream.h:196
#define mcerr
Definition: prstream.h:128
#define Iprintn(file, name)
Definition: prstream.h:205