1 | #include "elementSoleno.h" |
---|
2 | #include "mixedTools.h" |
---|
3 | |
---|
4 | |
---|
5 | elementSoleno::elementSoleno() : abstractElement() |
---|
6 | { |
---|
7 | cout << " passage constructeur elementSoleno " << endl; |
---|
8 | setDefaultValues(); |
---|
9 | setDefaults(); |
---|
10 | elementName_ = nomdElements("soleno"); |
---|
11 | nbParam_ = elementName_.getElementNbParameters(); |
---|
12 | parametersString_ = new string[nbParam_+1]; |
---|
13 | // registerAcceptableSoftware(nomDeLogiciel::transport, TBoolOk); |
---|
14 | // registerAcceptableSoftware(nomDeLogiciel::parmela, TBoolOk); |
---|
15 | } |
---|
16 | |
---|
17 | |
---|
18 | void elementSoleno::setDefaultValues() |
---|
19 | { |
---|
20 | defaultSpecificName_ = "solnd"; |
---|
21 | B0Def_ = 0.0; |
---|
22 | varyB0Def_ = false; |
---|
23 | } |
---|
24 | |
---|
25 | void elementSoleno::setDefaults() |
---|
26 | { |
---|
27 | specificName_ = defaultSpecificName_; |
---|
28 | B0_ = B0Def_; |
---|
29 | varyB0_ = varyB0Def_; |
---|
30 | } |
---|
31 | |
---|
32 | |
---|
33 | string* elementSoleno::getParametersString() const |
---|
34 | { |
---|
35 | cout << " passage elementSoleno::getParametersString() B0_= " << B0_ << endl; |
---|
36 | int compteur = -1; |
---|
37 | parametersString_[++compteur] = mixedTools::intToString(nbParam_); |
---|
38 | parametersString_[++compteur] = specificName_; |
---|
39 | parametersString_[++compteur] = mixedTools::doubleToString(lenghtElem_); |
---|
40 | parametersString_[++compteur] = mixedTools::doubleToString(aperture_); |
---|
41 | parametersString_[++compteur] = mixedTools::doubleToString(B0_); |
---|
42 | parametersString_[++compteur] = mixedTools::intToString(varyB0_); |
---|
43 | if ( compteur != nbParam_ ) { |
---|
44 | cerr << " elementSoleno::getParametersString() : ERROR nr pf parameters dosnt match " << endl; |
---|
45 | return NULL; |
---|
46 | } |
---|
47 | return parametersString_; |
---|
48 | } |
---|
49 | |
---|
50 | |
---|
51 | void elementSoleno::setParametersString(string* param) |
---|
52 | { |
---|
53 | if ( param == NULL ) |
---|
54 | { |
---|
55 | cerr << " elementSoleno::setParametersString parameters empty parameter set"; |
---|
56 | return; |
---|
57 | } |
---|
58 | int compteur = -1; |
---|
59 | int nbparam = atoi(param[++compteur].c_str()); |
---|
60 | if ( nbparam != nbParam_ ) |
---|
61 | { |
---|
62 | cerr << " elementSoleno::setParametersString parameters do not match for a SOLENOID"; |
---|
63 | return; |
---|
64 | } |
---|
65 | specificName_ = param[++compteur]; |
---|
66 | lenghtElem_ = atof(param[++compteur].c_str()); |
---|
67 | aperture_ = atof(param[++compteur].c_str()); |
---|
68 | B0_ = atof(param[++compteur].c_str()); |
---|
69 | varyB0_ = atoi(param[++compteur].c_str()); |
---|
70 | } |
---|
71 | |
---|
72 | // string elementSoleno::parmelaOutputFlow() const |
---|
73 | // { |
---|
74 | // ostringstream sortie; |
---|
75 | // // on passe l'induction magnetique en Gauss |
---|
76 | // sortie << "SOLENOID /l=" << lenghtElem_ << " /aper=" << aperture_ << " /iout=1 /h=" << 1000.*B0_ << endl; |
---|
77 | // return sortie.str(); |
---|
78 | // } |
---|
79 | |
---|
80 | // string elementSoleno::transportOutputFlow() const |
---|
81 | // { |
---|
82 | // ostringstream sortie; |
---|
83 | // // on passe la longueur en metres |
---|
84 | // sortie << specificName_ << ":" << " SOLENOID, L=" << 0.01*lenghtElem_ << ", B=" << B0_ << ";" << endl; |
---|
85 | // if ( varyB0_ ) { |
---|
86 | // sortie << " VARY, " << specificName_+"[B]" << ";" << endl; |
---|
87 | // } |
---|
88 | // return sortie.str(); |
---|
89 | // } |
---|
90 | |
---|
91 | string elementSoleno::FileOutputFlow() const |
---|
92 | { |
---|
93 | ostringstream sortie; |
---|
94 | // sortie << elementName_.getElementType() << endl; |
---|
95 | sortie << elementName_.getGenericLabel() << endl; |
---|
96 | sortie << specificName_ << endl; |
---|
97 | sortie << lenghtElem_ << " " << aperture_<< " " << B0_ << " " << varyB0_ << endl; |
---|
98 | return sortie.str(); |
---|
99 | } |
---|
100 | |
---|
101 | |
---|
102 | vector< pair<string, vector<string> > > elementSoleno::parametersToSoftware () const { |
---|
103 | vector< pair<string, vector<string> > > sortie; |
---|
104 | sortie.push_back( pair<string, vector<string> >("labelsGenericSpecific", vector<string>() ) ); |
---|
105 | sortie.back().second.push_back(elementName_.getGenericLabel()); |
---|
106 | sortie.back().second.push_back(specificName_); |
---|
107 | sortie.push_back( pair<string, vector<string> >("lenghtAperture", vector<string>() ) ); |
---|
108 | sortie.back().second.push_back(mixedTools::doubleToString(lenghtElem_)); |
---|
109 | sortie.back().second.push_back(mixedTools::doubleToString(aperture_)); |
---|
110 | sortie.push_back( pair<string, vector<string> >("field", vector<string>() ) ); |
---|
111 | sortie.back().second.push_back(mixedTools::doubleToString(B0_)); |
---|
112 | sortie.push_back( pair<string, vector<string> >("isBvariable", vector<string>() ) ); |
---|
113 | sortie.back().second.push_back(mixedTools::intToString(varyB0_)); |
---|
114 | return sortie; |
---|
115 | } |
---|
116 | |
---|
117 | |
---|
118 | void elementSoleno::FileInput(ifstream& ifs) |
---|
119 | { |
---|
120 | ifs >> specificName_; |
---|
121 | ifs >> lenghtElem_ >> aperture_ >> B0_ >> varyB0_ ; |
---|
122 | } |
---|
123 | |
---|
124 | |
---|
125 | string elementSoleno::print() { |
---|
126 | string txt = ""; |
---|
127 | |
---|
128 | txt += specificName_; |
---|
129 | txt += "\nlength (cm) : "; |
---|
130 | txt += mixedTools::doubleToString(lenghtElem_); |
---|
131 | txt += "\naperture (cm) : "; |
---|
132 | txt += mixedTools::doubleToString(aperture_); |
---|
133 | txt += "\nfield (kG) : "; |
---|
134 | txt += mixedTools::doubleToString(B0_); |
---|
135 | txt += "\n : may vary ? "; |
---|
136 | txt += mixedTools::boolToString(varyB0_); |
---|
137 | |
---|
138 | return txt; |
---|
139 | } |
---|