1 | |
---|
2 | #include <iostream> |
---|
3 | |
---|
4 | #include "elementDrift.h" |
---|
5 | #include "mathematicalTools.h" |
---|
6 | #include "mixedTools.h" |
---|
7 | |
---|
8 | elementDrift::elementDrift() : abstractElement() |
---|
9 | { |
---|
10 | elementName_ = nomdElements("drift"); |
---|
11 | nbParam_ = elementName_.getElementNbParameters(); |
---|
12 | parametersString_ = new string[nbParam_+1]; |
---|
13 | // parmelaOk_ = true; |
---|
14 | // transportOk_ = true; |
---|
15 | // transportElementName_ = "*DRIFT*"; |
---|
16 | } |
---|
17 | |
---|
18 | trivaluedBool elementDrift::is_accepted_by_software(nomDeLogiciel soft) const { |
---|
19 | if ( soft == nomDeLogiciel::transport ) return ok; |
---|
20 | else if ( soft == nomDeLogiciel::parmela ) return ok; |
---|
21 | else return error; |
---|
22 | } |
---|
23 | |
---|
24 | |
---|
25 | string* elementDrift::getParametersString() const |
---|
26 | { |
---|
27 | int compteur = -1; |
---|
28 | parametersString_[++compteur] = mixedTools::intToString(nbParam_); |
---|
29 | parametersString_[++compteur] = label_; |
---|
30 | parametersString_[++compteur] = mixedTools::doubleToString(lenghtElem_); |
---|
31 | parametersString_[++compteur] = mixedTools::doubleToString(aperture_); |
---|
32 | if ( compteur != nbParam_ ) { |
---|
33 | cerr << " elementDrift::getParametersString() : ERROR nr pf parameters dosnt match " << endl; |
---|
34 | return NULL; |
---|
35 | } |
---|
36 | return parametersString_; |
---|
37 | } |
---|
38 | |
---|
39 | void elementDrift::setParametersString(string* param) |
---|
40 | { |
---|
41 | if ( param == NULL ) |
---|
42 | { |
---|
43 | cerr << " elementDrift::setParametersString parameters empty parameter set"; |
---|
44 | return; |
---|
45 | } |
---|
46 | int compteur = -1; |
---|
47 | int nbparam = atoi(param[++compteur].c_str()); |
---|
48 | if ( nbparam != nbParam_ ) |
---|
49 | { |
---|
50 | cerr << " elementDrift::setParametersString parameters do not match for a DRIFT"; |
---|
51 | return; |
---|
52 | } |
---|
53 | label_ = param[++compteur]; |
---|
54 | lenghtElem_ = atof(param[++compteur].c_str()); |
---|
55 | aperture_ = atof(param[++compteur].c_str()); |
---|
56 | } |
---|
57 | |
---|
58 | string elementDrift::parmelaOutputFlow() const |
---|
59 | { |
---|
60 | ostringstream sortie; |
---|
61 | sortie << "DRIFT /l=" << lenghtElem_ << " /aper=" << aperture_ << " /iout=1"; |
---|
62 | return sortie.str(); |
---|
63 | } |
---|
64 | |
---|
65 | |
---|
66 | string elementDrift::transportOutputFlow() const |
---|
67 | { |
---|
68 | ostringstream sortie; |
---|
69 | // longueur en m |
---|
70 | sortie << label_ << ":" << " DRIFT, L=" << 0.01*lenghtElem_ << ";"; |
---|
71 | return sortie.str(); |
---|
72 | } |
---|
73 | |
---|
74 | |
---|
75 | string elementDrift::FileOutputFlow() const |
---|
76 | { |
---|
77 | ostringstream sortie; |
---|
78 | // sortie << elementName_.getElementType() << endl; |
---|
79 | sortie << elementName_.getElementLabel() << endl; |
---|
80 | sortie << label_ << endl; |
---|
81 | sortie << lenghtElem_ << " " << aperture_ <<endl; |
---|
82 | return sortie.str(); |
---|
83 | } |
---|
84 | |
---|
85 | void elementDrift::FileInput(ifstream& ifs) |
---|
86 | { |
---|
87 | ifs >> label_; |
---|
88 | ifs >> lenghtElem_ >> aperture_; |
---|
89 | } |
---|