Garfield++ v2r0
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
4
5namespace Heed {
6
7BGMesh::BGMesh(double fxmin, double fxmax, long fq)
8 : xmin(fxmin), xmax(fxmax), q(fq) {
9
10 mfunname("BGMesh::BGMesh(double fxmin, double fxmax, long fq)");
11 // The minimum is one interval and two points.
12 check_econd11(fq, <= 1, mcerr);
13 const double rk = pow(fxmax / fxmin, 1. / double(fq - 1));
14 x.resize(fq);
15 x[0] = fxmin;
16 x[fq - 1] = fxmax;
17 double xr = fxmin;
18 for (long n = 1; n < fq - 1; n++) {
19 xr *= rk;
20 x[n] = xr;
21 }
22}
23
24void BGMesh::print(std::ostream& file, int l) const {
25 if (l <= 0) return;
26 Ifile << "BGMesh (l=" << l << "): \n";
27 indn.n += 2;
28 Ifile << "xmin=" << xmin << " xmax=" << xmax << " quantity of intervals=" << q
29 << '\n';
30 if (l > 1) {
31 for (long k = 1; k < q; ++k) Iprintn(mcout, x[k]);
32 }
33 indn.n -= 2;
34}
35
36std::ostream& operator<<(std::ostream& file, const BGMesh& bgm) {
37 Ifile << "operator<<(std::ostream& file, const BGMesh& bgm):\n";
38 bgm.print(file, 2);
39 return file;
40}
41}
#define check_econd11(a, signb, stream)
Definition: FunNameStack.h:155
#define mfunname(string)
Definition: FunNameStack.h:45
Mesh of values.
Definition: BGMesh.h:12
virtual void print(std::ostream &file, int l) const
Definition: BGMesh.cpp:24
long q
Total number of points (not number of intervals).
Definition: BGMesh.h:19
double xmin
Definition: BGMesh.h:16
std::vector< double > x
Definition: BGMesh.h:20
double xmax
Definition: BGMesh.h:17
Definition: BGMesh.cpp:5
std::ostream & operator<<(std::ostream &file, const BGMesh &bgm)
Definition: BGMesh.cpp:36
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