1 | #include "elementBeam.h" |
---|
2 | #include "beam2Moments.h" |
---|
3 | #include "mixedTools.h" |
---|
4 | |
---|
5 | |
---|
6 | |
---|
7 | elementBeam::elementBeam() : abstractElement() { |
---|
8 | setDefaultValues(); |
---|
9 | setDefaults(); |
---|
10 | elementName_ = nomdElements("beam"); |
---|
11 | nbParam_ = elementName_.getElementNbParameters(); |
---|
12 | parametersString_ = new string[nbParam_+1]; |
---|
13 | // transportOk_ = true; |
---|
14 | } |
---|
15 | |
---|
16 | elementBeam::~elementBeam() {;} |
---|
17 | |
---|
18 | void elementBeam::setDefaultValues() { |
---|
19 | xDef_ = 0.0; |
---|
20 | xpDef_ = 0.0; |
---|
21 | yDef_ = 0.0; |
---|
22 | ypDef_ = 0.0; |
---|
23 | dlDef_ = 0.0; |
---|
24 | delDef_ = 0.0; |
---|
25 | p0Def_ = 0.0; |
---|
26 | } |
---|
27 | |
---|
28 | void elementBeam::setDefaults() { |
---|
29 | x_ = xDef_; |
---|
30 | xp_ = xpDef_; |
---|
31 | y_ = yDef_; |
---|
32 | yp_ = ypDef_; |
---|
33 | dl_ = dlDef_; |
---|
34 | del_ = delDef_; |
---|
35 | p0_ = p0Def_; |
---|
36 | } |
---|
37 | |
---|
38 | trivaluedBool elementBeam::is_accepted_by_software(nomDeLogiciel soft) const { |
---|
39 | if ( soft == nomDeLogiciel::transport ) return ok; |
---|
40 | else return error; |
---|
41 | } |
---|
42 | |
---|
43 | string* elementBeam::getParametersString() const { |
---|
44 | int compteur = -1; |
---|
45 | parametersString_[++compteur] = mixedTools::intToString(nbParam_); |
---|
46 | parametersString_[++compteur] = label_; |
---|
47 | parametersString_[++compteur] = mixedTools::doubleToString(x_); |
---|
48 | parametersString_[++compteur] = mixedTools::doubleToString(xp_); |
---|
49 | parametersString_[++compteur] = mixedTools::doubleToString(y_); |
---|
50 | parametersString_[++compteur] = mixedTools::doubleToString(yp_); |
---|
51 | parametersString_[++compteur] = mixedTools::doubleToString(dl_); |
---|
52 | parametersString_[++compteur] = mixedTools::doubleToString(del_); |
---|
53 | parametersString_[++compteur] = mixedTools::doubleToString(p0_); |
---|
54 | if ( compteur != nbParam_ ) { |
---|
55 | cerr << " elementBeam::getParametersString() : ERROR nr pf parameters dosnt match " << endl; |
---|
56 | return NULL; |
---|
57 | } |
---|
58 | return parametersString_; |
---|
59 | } |
---|
60 | |
---|
61 | void elementBeam::setParametersString(string* param) { |
---|
62 | if ( param == NULL ) |
---|
63 | { |
---|
64 | cerr << " elementBeam::setParametersString parameters empty parameter set"; |
---|
65 | return; |
---|
66 | } |
---|
67 | int compteur = -1; |
---|
68 | int nbparam = atoi(param[++compteur].c_str()); |
---|
69 | if ( nbparam != nbParam_ ) |
---|
70 | { |
---|
71 | cerr << " elementBeam::setParametersString parameters do not match for a BEAM"; |
---|
72 | return; |
---|
73 | } |
---|
74 | |
---|
75 | label_ = param[++compteur]; |
---|
76 | x_ = atof(param[++compteur].c_str()); |
---|
77 | xp_ = atof(param[++compteur].c_str()); |
---|
78 | y_ = atof(param[++compteur].c_str()); |
---|
79 | yp_ = atof(param[++compteur].c_str()); |
---|
80 | dl_ = atof(param[++compteur].c_str()); |
---|
81 | del_ = atof(param[++compteur].c_str()); |
---|
82 | p0_ = atof(param[++compteur].c_str()); |
---|
83 | } |
---|
84 | |
---|
85 | string elementBeam::parmelaOutputFlow() const |
---|
86 | { |
---|
87 | ostringstream sortie; |
---|
88 | cout << " BEAM sortie parmela non programmee " << endl; |
---|
89 | return sortie.str(); |
---|
90 | } |
---|
91 | |
---|
92 | string elementBeam::transportOutputFlow() const { |
---|
93 | ostringstream sortie; |
---|
94 | beam2Moments moments(x_, xp_, y_, yp_, dl_, del_); |
---|
95 | cout << " elementBeam::transportOutputFlow(), p0 = " << p0_ << endl; |
---|
96 | sortie << label_ << ":" << moments.writeToTransportInput(p0_); |
---|
97 | return sortie.str(); |
---|
98 | } |
---|
99 | |
---|
100 | string elementBeam::FileOutputFlow() const { |
---|
101 | ostringstream sortie; |
---|
102 | // sortie << elementName_.getElementType() << endl; |
---|
103 | sortie << elementName_.getElementLabel() << endl; |
---|
104 | sortie << label_ << endl; |
---|
105 | sortie << x_ << " " << xp_ << " " << y_ << " " << yp_ << endl; |
---|
106 | sortie << dl_ << " " << del_ << " " << p0_ << endl; |
---|
107 | cout << " elementBeam::FileOutputFlow, p0 = " << p0_ << endl; |
---|
108 | return sortie.str(); |
---|
109 | } |
---|
110 | |
---|
111 | void elementBeam::elementBeam::FileInput(ifstream& ifs) { |
---|
112 | ifs >> label_; |
---|
113 | ifs >> x_ >> xp_ >> y_ >> yp_; |
---|
114 | ifs >> dl_ >> del_ >> p0_; |
---|
115 | cout << " elementBeam::FileFileInput, p0 = " << p0_ << endl; |
---|
116 | lenghtElem_ = getLenghtOfElement(); |
---|
117 | cout << " elementBeam::FileInput calcule longueur = " << lenghtElem_ << endl; |
---|
118 | } |
---|