49 #include "../egs_cylinders/egs_cylinders.h"
50 #include "../egs_planes/egs_planes.h"
52 static bool EGS_RZ_LOCAL inputSet =
false;
54 string EGS_RZGeometry::RZType =
"EGS_RZ";
57 vector<EGS_Float> rads, vector<EGS_Float> zbs,
const string &name) :
62 radii.insert(radii.begin(), 0.);
65 vector<EGS_Float> vol;
66 for (
size_t r=0; r < radii.size()-1; r++) {
68 EGS_Float rmin = radii[r];
69 EGS_Float rmax = radii[r+1];
71 EGS_Float area = M_PI*(rmax*rmax - rmin*rmin);
73 for (
size_t plane = 0; plane < zbounds.size()-1; plane++) {
74 EGS_Float zmin = zbounds[plane];
75 EGS_Float zmax = zbounds[plane+1];
76 reg_vol.push_back((zmax-zmin)*area);
83 if (idir == ZDIR && ind >= 0 && ind < (
int)zbounds.size()) {
86 else if (idir == RDIR && ind >= 0 && ind < (
int)radii.size()) {
95 return zbounds.size() - 1;
97 else if (dir == RDIR) {
98 return radii.size() - 1;
104 if (ireg < 0 || ireg >=
nreg) {
107 return reg_vol[ireg];
114 vector<EGS_Float> getRadiiByShells(
EGS_Input *input) {
116 vector<EGS_Float> radii;
119 int err = input->
getInput(
"number of shells", nshells);
124 vector<EGS_Float> thick;
125 err = input->
getInput(
"shell thickness", thick);
131 for (
size_t shell_group=0; shell_group < min(thick.size(), nshells.size()); shell_group++) {
133 for (
int shell = 0; shell < nshells[shell_group]; shell++) {
134 cur_r += thick[shell_group];
135 radii.push_back(cur_r);
144 vector<EGS_Float> getRadii(
EGS_Input *input) {
146 vector<EGS_Float> radii;
147 int err = input->
getInput(
"radii", radii);
150 radii = getRadiiByShells(input);
158 vector<EGS_Float> EGS_RZ_LOCAL getZPlanesBySlabs(
EGS_Input *input) {
160 vector<EGS_Float> zplanes;
164 int err = input->
getInput(
"first plane", zo);
166 egsWarning(
"RZ: missing 'first plane' input. Assuming zo=0");
171 err = input->
getInput(
"number of slabs", nslabs);
176 vector<EGS_Float> thick;
177 err = input->
getInput(
"slab thickness", thick);
182 EGS_Float cur_z = zo;
183 zplanes.push_back(zo);
184 for (
size_t slab_group=0; slab_group < min(thick.size(), nslabs.size()); slab_group++) {
186 for (
int slab = 0; slab < nslabs[slab_group]; slab++) {
187 cur_z += thick[slab_group];
188 zplanes.push_back(cur_z);
196 vector<EGS_Float> EGS_RZ_LOCAL getZPlanes(
EGS_Input *input) {
198 vector<EGS_Float> zplanes;
199 int err = input->
getInput(
"z-planes", zplanes);
201 zplanes = getZPlanesBySlabs(input);
208 bool allIncreasing(vector<EGS_Float> vec) {
210 if (vec.size() == 0) {
214 EGS_Float last = vec[0];
215 for (
size_t i=1; i < vec.size(); i++) {
216 if (vec[i] <= last) {
231 static void setInputs() {
234 setBaseGeometryInputs();
236 geomBlockInput->getSingleInput(
"library")->setValues({
"egs_rz"});
239 auto radPtr = geomBlockInput->addSingleInput(
"radii",
false,
"A list of radii, must be in increasing order");
240 auto planePtr = geomBlockInput->addSingleInput(
"z-planes",
false,
"Input for z-planes");
243 auto num_shellPtr = geomBlockInput->addSingleInput(
"number of shells",
false,
"A list of the number of shells");
244 auto shellPtr = geomBlockInput->addSingleInput(
"shell thickness",
false,
"A list of shell thicknesses");
245 auto firstPtr = geomBlockInput->addSingleInput(
"first plane",
false,
"The z position of the first plane, when listing a number of slabs");
246 auto num_slabPtr = geomBlockInput->addSingleInput(
"number of slabs",
false,
"A list of the number of slabs");
247 auto slabPtr = geomBlockInput->addSingleInput(
"slab thickness",
false,
"A list of the slab thicknesses");
250 radPtr->addDependency(num_shellPtr,
"",
true);
251 radPtr->addDependency(shellPtr,
"",
true);
252 radPtr->addDependency(firstPtr,
"",
true);
253 radPtr->addDependency(num_slabPtr,
"",
true);
254 radPtr->addDependency(slabPtr,
"",
true);
255 planePtr->addDependency(num_shellPtr,
"",
true);
256 planePtr->addDependency(shellPtr,
"",
true);
257 planePtr->addDependency(firstPtr,
"",
true);
258 planePtr->addDependency(num_slabPtr,
"",
true);
259 planePtr->addDependency(slabPtr,
"",
true);
260 num_shellPtr->addDependency(radPtr,
"",
true);
261 num_shellPtr->addDependency(planePtr,
"",
true);
262 shellPtr->addDependency(radPtr,
"",
true);
263 shellPtr->addDependency(planePtr,
"",
true);
264 firstPtr->addDependency(radPtr,
"",
true);
265 firstPtr->addDependency(planePtr,
"",
true);
266 num_slabPtr->addDependency(radPtr,
"",
true);
267 num_slabPtr->addDependency(planePtr,
"",
true);
268 slabPtr->addDependency(radPtr,
"",
true);
269 slabPtr->addDependency(planePtr,
"",
true);
272 EGS_RZ_EXPORT
string getExample() {
281 z-planes= -4 -3 -2 -1 0 1 2 3 4
290 EGS_RZ_EXPORT shared_ptr<EGS_BlockInput> getInputs() {
294 return geomBlockInput;
300 egsWarning(
"createGeometry(egs_rz): null input?\n");
304 vector<EGS_Float> radii = egs_rz::getRadii(input);
305 if (radii.size() == 0) {
306 egsWarning(
"createGeometry(rz): wrong/missing radii inputs\n");
309 if (!egs_rz::allIncreasing(radii)) {
310 egsWarning(
"createGeometry(rz): radii must be monotonically increasing\n");
314 vector<EGS_Float> zplanes = egs_rz::getZPlanes(input);
315 if (zplanes.size() == 0) {
316 egsWarning(
"createGeometry(rz): wrong/missing z plane inputs\n");
323 vector<EGS_BaseGeometry *> rz_geoms;
324 rz_geoms.push_back(planes);
325 rz_geoms.push_back(cyl);
330 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.