cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mesh.h
Go to the documentation of this file.
1 /* This file is part of Cloudy and is copyright (C)1978-2017 by Gary J. Ferland and
2  * others. For conditions of distribution and use see copyright notice in license.txt */
3 
4 #ifndef MESH_H_
5 #define MESH_H_
6 
7 #include "thirdparty.h"
8 #include "energy.h"
9 
10 class t_mesh {
11 
16  double p_emm;
17 
19  double p_egamry;
20 
24 
26  string p_mesh_md5sum;
27 
31  vector<double> p_RangeUpperLimit;
32  vector<double> p_RangeResolution;
33 
35  vector<Energy> p_edges;
36 
38  vector<double> p_anu;
39 
41  vector<double> p_anu_edge;
42 
44  vector<double> p_widflx;
45 
47  vector<double> p_anulog10;
48  vector<double> p_anuln;
49  vector<double> p_anusqrt;
50  vector<double> p_anu2;
51  vector<double> p_anu3;
52 
53  /* this routine reads continuum_mesh.ini */
54  void p_ReadResolution();
55 
56  /* this routine defines the frequency mesh */
57  void p_SetupMesh(bool lgUnitCell);
58 
59  // Set up special edges that need to be merged into the frequency mesh
60  void p_SetupEdges();
61 public:
62  /* set up the frequency mesh */
63  void InitMesh(bool lgUnitCell)
64  {
65  if( lgMeshSetUp() )
66  return;
67  p_SetupEdges();
69  p_SetupMesh(lgUnitCell);
70  }
71  /* perform sanity checks on the frequency mesh */
72  void ValidateEdges() const;
73  void CheckMesh() const;
74 
75  bool lgMeshSetUp() const
76  {
77  return ( p_anu.size() > 0 );
78  }
79  // getters and setters
80  long ncells() const
81  {
82  return long(p_anu.size());
83  }
84  double emm() const
85  {
86  return p_emm;
87  }
88  double egamry() const
89  {
90  return p_egamry;
91  }
92  double getResolutionScaleFactor() const
93  {
95  }
96  void setResolutionScaleFactor(double fac)
97  {
98  if( !lgMeshSetUp() )
100  else
102  }
103  string mesh_md5sum() const
104  {
105  return p_mesh_md5sum;
106  }
107  const double* anuptr() const
108  {
109  return get_ptr(p_anu);
110  }
111  double anu(size_t i) const
112  {
113  return p_anu[i];
114  }
115  double anu2(size_t i) const
116  {
117  return p_anu2[i];
118  }
119  double anu3(size_t i) const
120  {
121  return p_anu3[i];
122  }
123  double anuln(size_t i) const
124  {
125  return p_anuln[i];
126  }
127  const double* anulog10ptr() const
128  {
129  return get_ptr(p_anulog10);
130  }
131  double anulog10(size_t i) const
132  {
133  return p_anulog10[i];
134  }
135  double anusqrt(size_t i) const
136  {
137  return p_anusqrt[i];
138  }
139  double anumin(size_t i) const
140  {
141  return p_anu_edge[i];
142  }
143  double anumax(size_t i) const
144  {
145  return p_anu_edge[i+1];
146  }
147  double widflx(size_t i) const
148  {
149  return p_widflx[i];
150  }
151  // return index ic such that p_anu_edge[ic] <= anu < p_anu_edge[ic+1]
152  size_t ipointC(double anu) const
153  {
154  ASSERT( lgMeshSetUp() );
155  ASSERT( anu >= p_anu_edge.front() && anu <= p_anu_edge.back() );
156  return hunt_bisect( p_anu_edge, anu );
157  }
158  // same as ipointC, but on fortran scale
159  size_t ipointF(double anu) const
160  {
161  return ipointC(anu) + 1;
162  }
163  // return smallest index ic such that p_anu[ic] >= threshold
164  // this guarantees that rfield.anu(ic) - threshold is always non-negative.
165  size_t ithreshC(double threshold) const
166  {
167  ASSERT( lgMeshSetUp() );
168  ASSERT( threshold >= p_anu.front() && threshold <= p_anu.back() );
169  size_t ic = hunt_bisect( p_anu, threshold );
170  // this if is nearly always taken...
171  if( p_anu[ic] < threshold )
172  ++ic;
173  return ic;
174  }
175  // same as ithreshC, but on fortran scale
176  size_t ithreshF(double threshold) const
177  {
178  return ithreshC(threshold) + 1;
179  }
180 
181  // constructor
183  {
184  static const Energy Elo( 10., "MHz" );
185  static const Energy Ehi( 100., "MeV" );
186 
187  // these are the low and high energy bounds of the continuum
188  p_emm = Elo.Ryd();
189  p_egamry = Ehi.Ryd();
190  // this is set with the set continuum resolution command
192  p_mesh_md5sum = MD5datafile( "continuum_mesh.ini" );
193  }
194 };
195 
196 #endif /* MESH_H_ */
double emm() const
Definition: mesh.h:84
vector< double > p_RangeUpperLimit
Definition: mesh.h:31
T * get_ptr(T *v)
Definition: cddefines.h:1113
double widflx(size_t i) const
Definition: mesh.h:147
void CheckMesh() const
Definition: mesh.cpp:322
vector< double > p_anulog10
Definition: mesh.h:47
string mesh_md5sum() const
Definition: mesh.h:103
double p_egamry
Definition: mesh.h:19
string MD5datafile(const char *fnam, access_scheme scheme)
void InitMesh(bool lgUnitCell)
Definition: mesh.h:63
double anu(size_t i) const
Definition: mesh.h:111
void ValidateEdges() const
Definition: mesh.cpp:274
void setResolutionScaleFactor(double fac)
Definition: mesh.h:96
vector< double > p_RangeResolution
Definition: mesh.h:32
long hunt_bisect(const T x[], long n, T xval)
Definition: thirdparty.h:303
double anuln(size_t i) const
Definition: mesh.h:123
const double * anuptr() const
Definition: mesh.h:107
t_mesh()
Definition: mesh.h:182
bool fp_equal(sys_float x, sys_float y, int n=3)
Definition: cddefines.h:858
vector< double > p_anu3
Definition: mesh.h:51
size_t ipointC(double anu) const
Definition: mesh.h:152
void p_SetupMesh(bool lgUnitCell)
Definition: mesh.cpp:145
vector< double > p_widflx
Definition: mesh.h:44
bool lgMeshSetUp() const
Definition: mesh.h:75
Definition: mesh.h:10
vector< double > p_anu
Definition: mesh.h:38
double p_emm
Definition: mesh.h:16
vector< Energy > p_edges
Definition: mesh.h:35
double anusqrt(size_t i) const
Definition: mesh.h:135
size_t ipointF(double anu) const
Definition: mesh.h:159
vector< double > p_anuln
Definition: mesh.h:48
double anu2(size_t i) const
Definition: mesh.h:115
double anu3(size_t i) const
Definition: mesh.h:119
vector< double > p_anu2
Definition: mesh.h:50
double anumin(size_t i) const
Definition: mesh.h:139
size_t ithreshF(double threshold) const
Definition: mesh.h:176
vector< double > p_anu_edge
Definition: mesh.h:41
#define ASSERT(exp)
Definition: cddefines.h:617
double p_ResolutionScaleFactor
Definition: mesh.h:23
vector< double > p_anusqrt
Definition: mesh.h:49
double Ryd() const
Definition: energy.h:33
Definition: energy.h:9
double egamry() const
Definition: mesh.h:88
size_t ithreshC(double threshold) const
Definition: mesh.h:165
long ncells() const
Definition: mesh.h:80
void p_SetupEdges()
Definition: mesh.cpp:230
double anumax(size_t i) const
Definition: mesh.h:143
string p_mesh_md5sum
Definition: mesh.h:26
double anulog10(size_t i) const
Definition: mesh.h:131
void p_ReadResolution()
Definition: mesh.cpp:11
const double * anulog10ptr() const
Definition: mesh.h:127
double getResolutionScaleFactor() const
Definition: mesh.h:92