EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
egs_radiative_splitting.cpp
Go to the documentation of this file.
1 /*
2 ###############################################################################
3 #
4 # EGSnrc egs++ radiative splitting object
5 # Copyright (C) 2018 National Research Council Canada
6 #
7 # This file is part of EGSnrc.
8 #
9 # EGSnrc is free software: you can redistribute it and/or modify it under
10 # the terms of the GNU Affero General Public License as published by the
11 # Free Software Foundation, either version 3 of the License, or (at your
12 # option) any later version.
13 #
14 # EGSnrc is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 # FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
17 # more details.
18 #
19 # You should have received a copy of the GNU Affero General Public License
20 # along with EGSnrc. If not, see <http://www.gnu.org/licenses/>.
21 #
22 ###############################################################################
23 #
24 # Author: Ernesto Mainegra-Hing, 2018
25 #
26 # Contributors:
27 #
28 ###############################################################################
29 #
30 # A general radiative splitting tool.
31 #
32 # TODO:
33 #
34 # - Add directional radiative splitting (DRS)
35 #
36 ###############################################################################
37 */
38 
39 
45 #include <fstream>
46 #include <string>
47 #include <cstdlib>
48 
50 #include "egs_input.h"
51 #include "egs_functions.h"
52 
53 EGS_RadiativeSplitting::EGS_RadiativeSplitting(const string &Name,
54  EGS_ObjectFactory *f) :
55  nsplit(1) {
56  otype = "EGS_RadiativeSplitting";
57 }
58 
59 EGS_RadiativeSplitting::~EGS_RadiativeSplitting() {
60 }
61 
62 void EGS_RadiativeSplitting::setApplication(EGS_Application *App) {
64  if (!app) {
65  return;
66  }
67 
68  char buf[32];
69 
70  // Set EGSnrc internal radiative splitting number .
71  app->setRadiativeSplitting(nsplit);
72 
73  description = "\n===========================================\n";
74  description += "Radiative splitting Object (";
75  description += name;
76  description += ")\n";
77  description += "===========================================\n";
78  if (nsplit > 1) {
79  description +="\n - Splitting radiative events in ";
80  sprintf(buf,"%d\n\n",nsplit);
81  description += buf;
82  }
83  else if (nsplit == 1) {
84  description +="\n - NO radiative splitting";
85  }
86  else {
87  description +="\n - BEWARE: Turning OFF radiative events !!!";
88  }
89  description += "\n===========================================\n\n";
90 }
91 
92 //*********************************************************************
93 // Process input for this ausgab object
94 //
95 //**********************************************************************
96 extern "C" {
97 
98  EGS_RADIATIVE_SPLITTING_EXPORT EGS_AusgabObject *createAusgabObject(EGS_Input *input,
99  EGS_ObjectFactory *f) {
100  const static char *func = "createAusgabObject(radiative_splitting)";
101  if (!input) {
102  egsWarning("%s: null input?\n",func);
103  return 0;
104  }
105 
106  EGS_Float nsplit = 1.0;
107  int err = input->getInput("splitting",nsplit);
108 
109  //=================================================
110 
111  /* Setup radiative splitting object with input parameters */
113  result->setSplitting(nsplit);
114  result->setName(input);
115  return result;
116  }
117 }
string description
A short ausgab object description.
EGS_Input class header file.
Global egspp functions header file.
An object factory.
A radiative splitting object: header.
void setName(EGS_Input *inp)
Set the name of the object from the information provided by inp.
A radiative splitting ausgab object: header.
string name
The object name.
A class for storing information in a tree-like structure of key-value pairs. This class is used throu...
Definition: egs_input.h:182
string otype
The object type.
virtual void setApplication(EGS_Application *App)
Set the application this object belongs to.
int getInput(const string &key, vector< string > &values) const
Assign values to an array of strings from an input identified by key.
Definition: egs_input.cpp:338
Base class for advanced EGSnrc C++ applications.
EGS_Application * app
The application this object belongs to.
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.