-
Notifications
You must be signed in to change notification settings - Fork 1
/
radiation_factory.cxx.in.py
49 lines (41 loc) · 1.22 KB
/
radiation_factory.cxx.in.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python3
models=[
"RadiatedPower",
# Needs an argument - file to read
#"InterpRadiatedPower",
"HutchinsonCarbonRadiation",
"HydrogenRadiatedPower",
"UpdatedRadiatedPower",
## commented out:
# "PostJensen"
# Testing only:
"TestingPower"
]
takesOptions={}
for model in models:
takesOptions[model]=False
takesOptions["TestingPower"]=True
def printl(*args):
print(*args,end='')
printl("""#include "radiation_factory.hxx"
#include "radiation.hxx"
RadiatedPower * RadiatedPowerFactory::create(Options * options){
std::string name;
options->get("RadiationType", name , "updatedradiatedpower");
return create(name, options);
}
RadiatedPower * RadiatedPowerFactory::create(const std::string & name, Options * options){
""")
for model in models:
printl("""if (name == "%s") {
return new %s(%s);
} else """%(model.lower(), model,"options->getSection(name)" if takesOptions[model] else ""))
printl("""{
throw BoutException("Cannot handle requested CrossSectionType.\\n"
"Requested %s - but we only support:\\n"\
""")
for model in models:
printl('\n "\t* '+model+'\\n"')
print(""",name.c_str());
}
}""")