Salome HOME
Merge from V6_3_BR 06/06/2011
[modules/homard.git] / src / HOMARD / HOMARD_Iteration.cxx
1 //  HOMARD HOMARD : implementation of HOMARD idl descriptions
2 //
3 // Copyright (C) 2011  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( 0 ), _Rank( 0 ),
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 //=============================================================================
60 bool HOMARD_Iteration::Compute()
61 {
62   MESSAGE("Compute --> ne fait rien");
63   _Etat=true;
64   return true;
65 }
66
67 //=============================================================================
68 /*!
69 */
70 //=============================================================================
71 void HOMARD_Iteration::SetName( const char* NomIter )
72 {
73   _NomIter = std::string( NomIter );
74 }
75
76 //=============================================================================
77 /*!
78 */
79 //=============================================================================
80 std::string HOMARD_Iteration::GetName() const
81 {
82   return _NomIter;
83 }
84
85 //=============================================================================
86 /*!
87 */
88 //=============================================================================
89 std::string HOMARD_Iteration::GetDumpPython() const
90 {
91   if (_IterParent == "") return std::string(" ") ;   // Pas de creation explicite de iteration 0";
92
93   std::ostringstream aScript;
94   aScript << "\n# Creation of the iteration " << _NomIter << "\n";
95   if( _NumIter == 1 )
96   {
97        aScript << "\t" << _NomIter << " = homard.CreateIteration('";
98        aScript <<  _NomIter << "', "<<  _NomCas << ".GetIter0Name() )\n";
99   }
100    else
101   {
102        aScript << "\t" << _NomIter << " = homard.CreateIteration('";
103        aScript <<  _NomIter << "', '" << _IterParent << "')\n";
104   }
105 // Le nom du maillage produit
106   aScript << "\t" << _NomIter << ".SetMeshName('" << _NomMesh << "')\n" ;
107 // Le fichier du maillage produit
108   aScript << "\t" << _NomIter << ".SetMeshFile('" << _MeshFile << "')\n";
109   if (_FieldFile != "") {
110     aScript << "\t" << _NomIter << ".SetFieldFile('" << _FieldFile << "')\n";
111     aScript << "\t" << _NomIter << ".SetTimeStepRank(" << _Rank << ", " << _TimeStep << ")\n";
112   }
113
114   aScript << "\thomard.AssociateIterHypo('" <<_NomIter << "', '" << _NomHypo << "')\n";
115   if (_Etat == true)
116   {
117      aScript << "\tresult = homard.Compute('" <<_NomIter << "', 1)\n";
118   }
119   else
120   {
121      aScript << "\t# result = homard.Compute('" <<_NomIter << "', 1)\n";
122   }
123
124   return aScript.str();
125 }
126 //=============================================================================
127 /*!
128 */
129 //=============================================================================
130 void HOMARD_Iteration::SetEtat( bool etat )
131 {
132   _Etat = etat;
133 }
134
135 //=============================================================================
136 /*!
137 */
138 //=============================================================================
139 bool HOMARD_Iteration::GetEtat() const
140 {
141   return _Etat;
142 }
143
144 //=============================================================================
145 /*!
146 */
147 //=============================================================================
148 void HOMARD_Iteration::SetNumber( int NumIter )
149 {
150   _NumIter = NumIter;
151 }
152
153 //=============================================================================
154 /*!
155 */
156 //=============================================================================
157 int HOMARD_Iteration::GetNumber() const
158 {
159   return _NumIter;
160 }
161
162 //=============================================================================
163 /*!
164 */
165 //=============================================================================
166 void HOMARD_Iteration::SetMeshName( const char* NomMesh )
167 {
168   _NomMesh = std::string( NomMesh );
169 }
170
171 //=============================================================================
172 /*!
173 */
174 //=============================================================================
175 std::string HOMARD_Iteration::GetMeshName() const
176 {
177   return _NomMesh;
178 }
179
180 //=============================================================================
181 /*!
182 */
183 //=============================================================================
184 void HOMARD_Iteration::SetIterParent( const char* IterParent )
185 {
186   _IterParent = IterParent;
187 }
188
189 //=============================================================================
190 /*!
191 */
192 //=============================================================================
193 std::string HOMARD_Iteration::GetIterParent() const
194 {
195   return _IterParent;
196 }
197
198 //=============================================================================
199 /*!
200 */
201 //=============================================================================
202 void HOMARD_Iteration::AddIteration( const char* NomIteration )
203 {
204   _mesIterFilles.push_back( std::string( NomIteration ) );
205 }
206
207 //=============================================================================
208 /*!
209 */
210 //=============================================================================
211 const std::list<std::string>& HOMARD_Iteration::GetIterations() const
212 {
213   return _mesIterFilles;
214 }
215
216 //=============================================================================
217 /*!
218 */
219 //=============================================================================
220 void HOMARD_Iteration::SupprIterations()
221 {
222   _mesIterFilles.clear();
223 }
224
225 //=============================================================================
226 /*!
227 */
228 //=============================================================================
229 void HOMARD_Iteration::SetHypoName( const char* NomHypo )
230 {
231   _NomHypo = std::string( NomHypo );
232 }
233
234 //=============================================================================
235 /*!
236 */
237 //=============================================================================
238 std::string HOMARD_Iteration::GetHypoName() const
239 {
240   return _NomHypo;
241 }
242
243 //=============================================================================
244 /*!
245 */
246 //=============================================================================
247 void HOMARD_Iteration::SetMeshFile( const char* MeshFile )
248 {
249   _MeshFile = std::string( MeshFile );
250 }
251
252 //=============================================================================
253 /*!
254 */
255 //=============================================================================
256 std::string HOMARD_Iteration::GetMeshFile() const
257 {
258   return _MeshFile;
259 }
260
261 //=============================================================================
262 /*!
263 */
264 //=============================================================================
265 void HOMARD_Iteration::SetFieldFile( const char* FieldFile )
266 {
267   _FieldFile = std::string( FieldFile );
268 }
269 //=============================================================================
270 std::string HOMARD_Iteration::GetFieldFile() const
271 {
272   return _FieldFile;
273 }
274
275 //=============================================================================
276 /*!
277 */
278 //=============================================================================
279 void HOMARD_Iteration::SetTimeStepRank( int TimeStep, int Rank )
280 {
281   _TimeStep = TimeStep;
282   _Rank = Rank;
283 }
284 //=============================================================================
285 int HOMARD_Iteration::GetTimeStep() const
286 {
287   return _TimeStep;
288 }
289 //=============================================================================
290 int HOMARD_Iteration::GetRank() const
291 {
292   return _Rank;
293 }
294
295 //=============================================================================
296 /*!
297 */
298 //=============================================================================
299 void HOMARD_Iteration::SetCaseName( const char* NomCas )
300 {
301   _NomCas = std::string( NomCas );
302 }
303
304 //=============================================================================
305 /*!
306 */
307 //=============================================================================
308 std::string HOMARD_Iteration::GetCaseName() const
309 {
310   return _NomCas;
311 }
312 //=============================================================================
313 /*!
314 */
315 //=============================================================================
316 void HOMARD_Iteration::SetDirName( const char* NomDir )
317 {
318   _NomDir = std::string( NomDir );
319 }
320 //=============================================================================
321 /*!
322 */
323 //=============================================================================
324 std::string HOMARD_Iteration::GetDirName() const
325 {
326    return _NomDir;
327 }
328 /*!
329 */
330 //=============================================================================
331 void HOMARD_Iteration::SetMessFile( const char* MessFile )
332 {
333   _MessFile = std::string( MessFile );
334 }
335
336 //=============================================================================
337 /*!
338 */
339 //=============================================================================
340 std::string HOMARD_Iteration::GetMessFile() const
341 {
342   return _MessFile;
343 }