47 #include "../egs_cylinders/egs_cylinders.h"
48 #include "../egs_planes/egs_planes.h"
51 string EGS_RZGeometry::RZType =
"EGS_RZ";
54 vector<EGS_Float> rads, vector<EGS_Float> zbs,
const string &name) :
59 radii.insert(radii.begin(), 0.);
62 vector<EGS_Float> vol;
63 for (
size_t r=0; r < radii.size()-1; r++) {
65 EGS_Float rmin = radii[r];
66 EGS_Float rmax = radii[r+1];
68 EGS_Float area = M_PI*(rmax*rmax - rmin*rmin);
70 for (
size_t plane = 0; plane < zbounds.size()-1; plane++) {
71 EGS_Float zmin = zbounds[plane];
72 EGS_Float zmax = zbounds[plane+1];
73 reg_vol.push_back((zmax-zmin)*area);
80 if (idir == ZDIR && ind >= 0 && ind < (
int)zbounds.size()) {
83 else if (idir == RDIR && ind >= 0 && ind < (
int)radii.size()) {
92 return zbounds.size() - 1;
94 else if (dir == RDIR) {
95 return radii.size() - 1;
101 if (ireg < 0 || ireg >=
nreg) {
104 return reg_vol[ireg];
111 vector<EGS_Float> getRadiiByShells(
EGS_Input *input) {
113 vector<EGS_Float> radii;
116 int err = input->
getInput(
"number of shells", nshells);
121 vector<EGS_Float> thick;
122 err = input->
getInput(
"shell thickness", thick);
128 for (
size_t shell_group=0; shell_group < min(thick.size(), nshells.size()); shell_group++) {
130 for (
int shell = 0; shell < nshells[shell_group]; shell++) {
131 cur_r += thick[shell_group];
132 radii.push_back(cur_r);
141 vector<EGS_Float> getRadii(
EGS_Input *input) {
143 vector<EGS_Float> radii;
144 int err = input->
getInput(
"radii", radii);
147 radii = getRadiiByShells(input);
155 vector<EGS_Float> EGS_RZ_LOCAL getZPlanesBySlabs(
EGS_Input *input) {
157 vector<EGS_Float> zplanes;
161 int err = input->
getInput(
"first plane", zo);
163 egsWarning(
"RZ: missing 'first plane' input. Assuming zo=0");
168 err = input->
getInput(
"number of slabs", nslabs);
173 vector<EGS_Float> thick;
174 err = input->
getInput(
"slab thickness", thick);
179 EGS_Float cur_z = zo;
180 zplanes.push_back(zo);
181 for (
size_t slab_group=0; slab_group < min(thick.size(), nslabs.size()); slab_group++) {
183 for (
int slab = 0; slab < nslabs[slab_group]; slab++) {
184 cur_z += thick[slab_group];
185 zplanes.push_back(cur_z);
193 vector<EGS_Float> EGS_RZ_LOCAL getZPlanes(
EGS_Input *input) {
195 vector<EGS_Float> zplanes;
196 int err = input->
getInput(
"z-planes", zplanes);
198 zplanes = getZPlanesBySlabs(input);
205 bool allIncreasing(vector<EGS_Float> vec) {
207 if (vec.size() == 0) {
211 EGS_Float last = vec[0];
212 for (
size_t i=1; i < vec.size(); i++) {
213 if (vec[i] <= last) {
231 egsWarning(
"createGeometry(egs_rz): null input?\n");
235 vector<EGS_Float> radii = egs_rz::getRadii(input);
236 if (radii.size() == 0) {
237 egsWarning(
"createGeometry(rz): wrong/missing radii inputs\n");
240 if (!egs_rz::allIncreasing(radii)) {
241 egsWarning(
"createGeometry(rz): radii must be monotonically increasing\n");
245 vector<EGS_Float> zplanes = egs_rz::getZPlanes(input);
246 if (zplanes.size() == 0) {
247 egsWarning(
"createGeometry(rz): wrong/missing z plane inputs\n");
254 vector<EGS_BaseGeometry *> rz_geoms;
255 rz_geoms.push_back(planes);
256 rz_geoms.push_back(cyl);
261 egsWarning(
"createGeometry(rz): failed to create nd geometry\n");
EGS_Float getBound(int idir, int ind)
get RZ boundary for a given direction and directional index
EGS_Float getVolume(int ireg)
get mass of a given region
A class representing 3D vectors.
a subclass of EGS_NDGeometry for conveniently defining an RZ geometry
int setLabels(EGS_Input *input)
Set the labels from an input block.
EGS_GLIB_EXPORT EGS_BaseGeometry * createGeometry(EGS_Input *input)
Base geometry class. Every geometry class must be derived from EGS_BaseGeometry.
static string getUniqueName()
Get a unique geometry name.
void setMedia(EGS_Input *inp)
Set the media in the geometry from the input pointed to by inp.
A set of parallel planes.
A set of concentric cylinders.
void setName(EGS_Input *inp)
Set the name of the geometry from the input inp.
A projector into the z-plane.
int getNRegDir(int dir)
get number of regions in a given direction
A class modeling a N-dimensional geometry.
EGS_RZGeometry(vector< EGS_BaseGeometry * > geoms, vector< EGS_Float > rads, vector< EGS_Float > zbs, const string &name="")
RZ geometry constructor.
int nreg
Number of local regions in this geometry.
An egs_nd_geometry wrapper to simplify RZ geometry creation.
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.