48 #include "../egs_cylinders/egs_cylinders.h"
49 #include "../egs_planes/egs_planes.h"
52 string EGS_RZGeometry::RZType =
"EGS_RZ";
55 vector<EGS_Float> rads, vector<EGS_Float> zbs,
const string &name) :
60 radii.insert(radii.begin(), 0.);
63 vector<EGS_Float> vol;
64 for (
size_t r=0; r < radii.size()-1; r++) {
66 EGS_Float rmin = radii[r];
67 EGS_Float rmax = radii[r+1];
69 EGS_Float area = M_PI*(rmax*rmax - rmin*rmin);
71 for (
size_t plane = 0; plane < zbounds.size()-1; plane++) {
72 EGS_Float zmin = zbounds[plane];
73 EGS_Float zmax = zbounds[plane+1];
74 reg_vol.push_back((zmax-zmin)*area);
81 if (idir == ZDIR && ind >= 0 && ind < (
int)zbounds.size()) {
84 else if (idir == RDIR && ind >= 0 && ind < (
int)radii.size()) {
93 return zbounds.size() - 1;
95 else if (dir == RDIR) {
96 return radii.size() - 1;
102 if (ireg < 0 || ireg >=
nreg) {
105 return reg_vol[ireg];
112 vector<EGS_Float> getRadiiByShells(
EGS_Input *input) {
114 vector<EGS_Float> radii;
117 int err = input->
getInput(
"number of shells", nshells);
122 vector<EGS_Float> thick;
123 err = input->
getInput(
"shell thickness", thick);
129 for (
size_t shell_group=0; shell_group < min(thick.size(), nshells.size()); shell_group++) {
131 for (
int shell = 0; shell < nshells[shell_group]; shell++) {
132 cur_r += thick[shell_group];
133 radii.push_back(cur_r);
142 vector<EGS_Float> getRadii(
EGS_Input *input) {
144 vector<EGS_Float> radii;
145 int err = input->
getInput(
"radii", radii);
148 radii = getRadiiByShells(input);
156 vector<EGS_Float> EGS_RZ_LOCAL getZPlanesBySlabs(
EGS_Input *input) {
158 vector<EGS_Float> zplanes;
162 int err = input->
getInput(
"first plane", zo);
164 egsWarning(
"RZ: missing 'first plane' input. Assuming zo=0");
169 err = input->
getInput(
"number of slabs", nslabs);
174 vector<EGS_Float> thick;
175 err = input->
getInput(
"slab thickness", thick);
180 EGS_Float cur_z = zo;
181 zplanes.push_back(zo);
182 for (
size_t slab_group=0; slab_group < min(thick.size(), nslabs.size()); slab_group++) {
184 for (
int slab = 0; slab < nslabs[slab_group]; slab++) {
185 cur_z += thick[slab_group];
186 zplanes.push_back(cur_z);
194 vector<EGS_Float> EGS_RZ_LOCAL getZPlanes(
EGS_Input *input) {
196 vector<EGS_Float> zplanes;
197 int err = input->
getInput(
"z-planes", zplanes);
199 zplanes = getZPlanesBySlabs(input);
206 bool allIncreasing(vector<EGS_Float> vec) {
208 if (vec.size() == 0) {
212 EGS_Float last = vec[0];
213 for (
size_t i=1; i < vec.size(); i++) {
214 if (vec[i] <= last) {
232 egsWarning(
"createGeometry(egs_rz): null input?\n");
236 vector<EGS_Float> radii = egs_rz::getRadii(input);
237 if (radii.size() == 0) {
238 egsWarning(
"createGeometry(rz): wrong/missing radii inputs\n");
241 if (!egs_rz::allIncreasing(radii)) {
242 egsWarning(
"createGeometry(rz): radii must be monotonically increasing\n");
246 vector<EGS_Float> zplanes = egs_rz::getZPlanes(input);
247 if (zplanes.size() == 0) {
248 egsWarning(
"createGeometry(rz): wrong/missing z plane inputs\n");
255 vector<EGS_BaseGeometry *> rz_geoms;
256 rz_geoms.push_back(planes);
257 rz_geoms.push_back(cyl);
262 egsWarning(
"createGeometry(rz): failed to create nd geometry\n");
Base geometry class. Every geometry class must be derived from EGS_BaseGeometry.
void setMedia(EGS_Input *inp)
Set the media in the geometry from the input pointed to by inp.
int nreg
Number of local regions in this geometry.
void setName(EGS_Input *inp)
Set the name of the geometry from the input inp.
static string getUniqueName()
Get a unique geometry name.
int setLabels(EGS_Input *input)
Set the labels from an input block.
A set of concentric cylinders.
A class modeling a N-dimensional geometry.
A set of parallel planes.
a subclass of EGS_NDGeometry for conveniently defining an RZ geometry
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
EGS_RZGeometry(vector< EGS_BaseGeometry * > geoms, vector< EGS_Float > rads, vector< EGS_Float > zbs, const string &name="")
RZ geometry constructor.
int getNRegDir(int dir)
get number of regions in a given direction
A class representing 3D vectors.
A projector into the z-plane.
EGS_GLIB_EXPORT EGS_BaseGeometry * createGeometry(EGS_Input *input)
An egs_nd_geometry wrapper to simplify RZ geometry creation.
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.