1 | #include "elementCell.h" |
---|
2 | |
---|
3 | #include <iostream> |
---|
4 | |
---|
5 | #include "mathematicalTools.h" |
---|
6 | #include "mixedTools.h" |
---|
7 | |
---|
8 | |
---|
9 | |
---|
10 | elementCell::elementCell() : abstractElement() |
---|
11 | { |
---|
12 | setDefaultValues(); |
---|
13 | setDefaults(); |
---|
14 | elementName_ = nomdElements("cell"); |
---|
15 | nbParam_ = elementName_.getElementNbParameters(); |
---|
16 | parametersString_ = new string[nbParam_+1]; |
---|
17 | parmelaOk_ = true; |
---|
18 | } |
---|
19 | |
---|
20 | void elementCell::setDefaultValues() |
---|
21 | { |
---|
22 | initialPhaseDef_ = 0.0; |
---|
23 | acceleratingFieldDef_ = 1.0; |
---|
24 | acceleratingShapeFileDef_ = string(" "); |
---|
25 | focusingMagFileDef_ = string(" "); |
---|
26 | offsetMagDef_ = 0.0; |
---|
27 | scaleFactorDef_ = 1.0; |
---|
28 | } |
---|
29 | |
---|
30 | void elementCell::setDefaults() |
---|
31 | { |
---|
32 | initialPhase_ = initialPhaseDef_; |
---|
33 | acceleratingField_ = acceleratingFieldDef_; |
---|
34 | acceleratingShapeFile_ = acceleratingShapeFileDef_; |
---|
35 | focusingMagFile_ = focusingMagFileDef_; |
---|
36 | offsetMag_ = offsetMagDef_; |
---|
37 | scaleFactor_ = scaleFactorDef_; |
---|
38 | } |
---|
39 | |
---|
40 | string* elementCell::getParametersString() const |
---|
41 | { |
---|
42 | int compteur = -1; |
---|
43 | parametersString_[++compteur] = mixedTools::intToString(nbParam_); |
---|
44 | parametersString_[++compteur] = label_; |
---|
45 | parametersString_[++compteur] = mixedTools::doubleToString(lenghtElem_); |
---|
46 | parametersString_[++compteur] = mixedTools::doubleToString(aperture_); |
---|
47 | parametersString_[++compteur] = mixedTools::doubleToString(initialPhase_); |
---|
48 | parametersString_[++compteur] = mixedTools::doubleToString( phaseStepMax_); |
---|
49 | parametersString_[++compteur] = mixedTools::doubleToString(acceleratingField_); |
---|
50 | parametersString_[++compteur] = acceleratingShapeFile_; |
---|
51 | parametersString_[++compteur] = focusingMagFile_; |
---|
52 | parametersString_[++compteur] = mixedTools::doubleToString(offsetMag_); |
---|
53 | parametersString_[++compteur] = mixedTools::doubleToString(scaleFactor_); |
---|
54 | if ( compteur != nbParam_ ) { |
---|
55 | cerr << " elementCell::getParametersString() : ERROR nr pf parameters dosnt match " << endl; |
---|
56 | return NULL; |
---|
57 | } |
---|
58 | return parametersString_; |
---|
59 | } |
---|
60 | |
---|
61 | |
---|
62 | void elementCell::setParametersString(string* param) |
---|
63 | { |
---|
64 | if ( param == NULL ) |
---|
65 | { |
---|
66 | cerr << " elementCell::setParametersString parameters empty parameter set"; |
---|
67 | return; |
---|
68 | } |
---|
69 | int compteur = -1; |
---|
70 | int nbparam = atoi(param[++compteur].c_str()); |
---|
71 | if ( nbparam != nbParam_ ) |
---|
72 | { |
---|
73 | cerr << " elementCell::setParametersString parameters do not match for a CELL"; |
---|
74 | return; |
---|
75 | } |
---|
76 | |
---|
77 | label_ = param[++compteur]; |
---|
78 | lenghtElem_ = atof(param[++compteur].c_str()); |
---|
79 | aperture_ = atof(param[++compteur].c_str()); |
---|
80 | initialPhase_ = atof(param[++compteur].c_str()); |
---|
81 | phaseStepMax_ = atof(param[++compteur].c_str()); |
---|
82 | acceleratingField_ = atof(param[++compteur].c_str()); |
---|
83 | acceleratingShapeFile_ = param[++compteur]; |
---|
84 | focusingMagFile_ = param[++compteur]; |
---|
85 | offsetMag_ = atof(param[++compteur].c_str()); |
---|
86 | scaleFactor_ = atof(param[++compteur].c_str()); |
---|
87 | } |
---|
88 | |
---|
89 | string elementCell::parmelaOutputFlow() const |
---|
90 | { |
---|
91 | ostringstream sortie; |
---|
92 | // on prend les troncatures tmax et rmax à 3 sigmas |
---|
93 | sortie << "CELL /l=" << lenghtElem_ << " /aper=" << aperture_ << endl; |
---|
94 | sortie << " /iout=1 /phi0=" << initialPhase_ << " /E0=" << acceleratingField_ << endl; |
---|
95 | sortie << " /nc=1 /dwtmax=" << phaseStepMax_ << " /sym=-1" << endl; |
---|
96 | sortie << "CFIELD 1" << endl; |
---|
97 | sortie << acceleratingShapeFile_ << endl; |
---|
98 | if ( focusingMagFile_ != "") { |
---|
99 | sortie << "POISSON /zoff=" << offsetMag_ << " /rmult=" << scaleFactor_ << endl; |
---|
100 | sortie << focusingMagFile_; |
---|
101 | } |
---|
102 | |
---|
103 | return sortie.str(); |
---|
104 | } |
---|
105 | |
---|
106 | |
---|
107 | string elementCell::FileOutputFlow() const |
---|
108 | { |
---|
109 | ostringstream sortie; |
---|
110 | // sortie << elementName_.getElementType() << endl; |
---|
111 | sortie << elementName_.getElementLabel() << endl; |
---|
112 | sortie << label_ << endl; |
---|
113 | sortie << lenghtElem_ << " " << aperture_ << endl; |
---|
114 | sortie << initialPhase_ << " " << acceleratingField_ << endl; |
---|
115 | sortie << phaseStepMax_ << endl; |
---|
116 | sortie << acceleratingShapeFile_ << endl; |
---|
117 | sortie << focusingMagFile_ << endl; |
---|
118 | sortie << offsetMag_ << " " << scaleFactor_ << endl; |
---|
119 | return sortie.str(); |
---|
120 | } |
---|
121 | |
---|
122 | void elementCell::FileInput(ifstream& ifs) |
---|
123 | { |
---|
124 | ifs >> label_; |
---|
125 | ifs >> lenghtElem_ >> aperture_; |
---|
126 | ifs >> initialPhase_ >> acceleratingField_; |
---|
127 | ifs >> phaseStepMax_; |
---|
128 | ifs >> acceleratingShapeFile_; |
---|
129 | ifs >> focusingMagFile_; |
---|
130 | ifs >> offsetMag_ >> scaleFactor_; |
---|
131 | } |
---|