Salome HOME
Merge from V6_main 13/12/2012
[modules/homard.git] / src / HOMARD / HOMARD_Iteration.cxx
1 //  HOMARD HOMARD : implementation of HOMARD idl descriptions
2 //
3 // Copyright (C) 2011-2012  CEA/DEN, EDF R&D
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18 //
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 //
21 //  File   : HOMARD_Iteration.cxx
22 //  Author : Paul RASCLE, EDF
23 //  Module : HOMARD
24
25 #include "HOMARD_Iteration.hxx"
26 #include "utilities.h"
27
28 //=============================================================================
29 /*!
30  *  default constructor:
31  */
32 //=============================================================================
33 HOMARD_Iteration::HOMARD_Iteration():
34   _NomIter( "" ), _Etat( false ),
35  _NumIter( -1 ),
36   _NomMesh( "" ), _MeshFile( "" ),
37   _FieldFile( "" ), _TimeStep( -1 ), _Rank( -1 ),
38   _MessFile( "" ),
39   _IterParent( "" ),
40   _NomHypo( "" ), _NomCas( "" ), _NomDir( "" )
41 {
42   MESSAGE("HOMARD_Iter");
43 }
44
45 //=============================================================================
46 /*!
47  *
48  */
49 //=============================================================================
50 HOMARD_Iteration::~HOMARD_Iteration()
51 {
52   MESSAGE("~HOMARD_Iteration");
53 }
54
55 //=============================================================================
56 /*!
57 */
58 //=============================================================================
59 void HOMARD_Iteration::SetName( const char* NomIter )
60 {
61   _NomIter = std::string( NomIter );
62 }
63
64 //=============================================================================
65 /*!
66 */
67 //=============================================================================
68 std::string HOMARD_Iteration::GetName() const
69 {
70   return _NomIter;
71 }
72
73 //=============================================================================
74 /*!
75 */
76 //=============================================================================
77 std::string HOMARD_Iteration::GetDumpPython() const
78 {
79   if (_IterParent == "") return std::string(" ") ;   // Pas de creation explicite de iteration 0";
80
81   std::ostringstream aScript;
82   aScript << "\n# Creation of the iteration " << _NomIter << "\n";
83   if( _NumIter == 1 )
84   {
85        aScript << "\t" << _NomIter << " = homard.CreateIteration(\"";
86        aScript <<  _NomIter << "\", "<<  _NomCas << ".GetIter0Name() )\n";
87   }
88    else
89   {
90        aScript << "\t" << _NomIter << " = homard.CreateIteration(\"";
91        aScript <<  _NomIter << "\", \"" << _IterParent << "\")\n";
92   }
93 // Le nom du maillage produit
94   aScript << "\t" << _NomIter << ".SetMeshName(\"" << _NomMesh << "\")\n" ;
95 // Le fichier du maillage produit
96   aScript << "\t" << _NomIter << ".SetMeshFile(\"" << _MeshFile << "\")\n";
97 // Le fichier des champs, avec l'instant eventuel
98   if ( _FieldFile != "" ) {
99     aScript << "\t" << _NomIter << ".SetFieldFile(\"" << _FieldFile << "\")\n";
100     if ( ( _TimeStep != -1 ) and ( _Rank != -1 ) ) {
101       aScript << "\t" << _NomIter << ".SetTimeStepRank( " << _TimeStep << ", " << _Rank << " )\n";
102     }
103   }
104
105   aScript << "\thomard.AssociateIterHypo(\"" <<_NomIter << "\", \"" << _NomHypo << "\")\n";
106   if (_Etat == true)
107   {
108      aScript << "\tcodret = " <<_NomIter << ".Compute(1)\n";
109   }
110   else
111   {
112      aScript << "\t#codret = " <<_NomIter << ".Compute(1)\n";
113   }
114
115   return aScript.str();
116 }
117 //=============================================================================
118 /*!
119 */
120 //=============================================================================
121 void HOMARD_Iteration::SetEtat( bool etat )
122 {
123   _Etat = etat;
124 }
125
126 //=============================================================================
127 /*!
128 */
129 //=============================================================================
130 bool HOMARD_Iteration::GetEtat() const
131 {
132   return _Etat;
133 }
134
135 //=============================================================================
136 /*!
137 */
138 //=============================================================================
139 void HOMARD_Iteration::SetNumber( int NumIter )
140 {
141   _NumIter = NumIter;
142 }
143
144 //=============================================================================
145 /*!
146 */
147 //=============================================================================
148 int HOMARD_Iteration::GetNumber() const
149 {
150   return _NumIter;
151 }
152
153 //=============================================================================
154 /*!
155 */
156 //=============================================================================
157 void HOMARD_Iteration::SetMeshName( const char* NomMesh )
158 {
159   _NomMesh = std::string( NomMesh );
160 }
161
162 //=============================================================================
163 /*!
164 */
165 //=============================================================================
166 std::string HOMARD_Iteration::GetMeshName() const
167 {
168   return _NomMesh;
169 }
170
171 //=============================================================================
172 /*!
173 */
174 //=============================================================================
175 void HOMARD_Iteration::SetIterParent( const char* IterParent )
176 {
177   _IterParent = IterParent;
178 }
179
180 //=============================================================================
181 /*!
182 */
183 //=============================================================================
184 std::string HOMARD_Iteration::GetIterParent() const
185 {
186   return _IterParent;
187 }
188
189 //=============================================================================
190 /*!
191 */
192 //=============================================================================
193 void HOMARD_Iteration::AddIteration( const char* NomIteration )
194 {
195   _mesIterFilles.push_back( std::string( NomIteration ) );
196 }
197
198 //=============================================================================
199 /*!
200 */
201 //=============================================================================
202 const std::list<std::string>& HOMARD_Iteration::GetIterations() const
203 {
204   return _mesIterFilles;
205 }
206
207 //=============================================================================
208 /*!
209 */
210 //=============================================================================
211 void HOMARD_Iteration::SupprIterations()
212 {
213   _mesIterFilles.clear();
214 }
215
216 //=============================================================================
217 /*!
218 */
219 //=============================================================================
220 void HOMARD_Iteration::SetHypoName( const char* NomHypo )
221 {
222   _NomHypo = std::string( NomHypo );
223 }
224
225 //=============================================================================
226 /*!
227 */
228 //=============================================================================
229 std::string HOMARD_Iteration::GetHypoName() const
230 {
231   return _NomHypo;
232 }
233
234 //=============================================================================
235 /*!
236 */
237 //=============================================================================
238 void HOMARD_Iteration::SetMeshFile( const char* MeshFile )
239 {
240   _MeshFile = std::string( MeshFile );
241 }
242
243 //=============================================================================
244 /*!
245 */
246 //=============================================================================
247 std::string HOMARD_Iteration::GetMeshFile() const
248 {
249   return _MeshFile;
250 }
251
252 //=============================================================================
253 /*!
254 */
255 //=============================================================================
256 void HOMARD_Iteration::SetFieldFile( const char* FieldFile )
257 {
258   _FieldFile = std::string( FieldFile );
259 }
260 //=============================================================================
261 std::string HOMARD_Iteration::GetFieldFile() const
262 {
263   return _FieldFile;
264 }
265
266 //=============================================================================
267 /*!
268 */
269 //=============================================================================
270 void HOMARD_Iteration::SetTimeStepRank( int TimeStep, int Rank )
271 {
272   _TimeStep = TimeStep;
273   _Rank = Rank;
274 }
275 //=============================================================================
276 int HOMARD_Iteration::GetTimeStep() const
277 {
278   return _TimeStep;
279 }
280 //=============================================================================
281 int HOMARD_Iteration::GetRank() const
282 {
283   return _Rank;
284 }
285
286 //=============================================================================
287 /*!
288 */
289 //=============================================================================
290 void HOMARD_Iteration::SetCaseName( const char* NomCas )
291 {
292   _NomCas = std::string( NomCas );
293 }
294
295 //=============================================================================
296 /*!
297 */
298 //=============================================================================
299 std::string HOMARD_Iteration::GetCaseName() const
300 {
301   return _NomCas;
302 }
303 //=============================================================================
304 /*!
305 */
306 //=============================================================================
307 void HOMARD_Iteration::SetDirName( const char* NomDir )
308 {
309   _NomDir = std::string( NomDir );
310 }
311 //=============================================================================
312 /*!
313 */
314 //=============================================================================
315 std::string HOMARD_Iteration::GetDirName() const
316 {
317    return _NomDir;
318 }
319 /*!
320 */
321 //=============================================================================
322 void HOMARD_Iteration::SetMessFile( const char* MessFile )
323 {
324   _MessFile = std::string( MessFile );
325 }
326
327 //=============================================================================
328 /*!
329 */
330 //=============================================================================
331 std::string HOMARD_Iteration::GetMessFile() const
332 {
333   return _MessFile;
334 }