Salome HOME
Merge from V6_main_20120808 08Aug12
[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( 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 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   if (_FieldFile != "") {
98     aScript << "\t" << _NomIter << ".SetFieldFile(\"" << _FieldFile << "\")\n";
99     aScript << "\tTimeStep = " << _TimeStep << "\n";
100     aScript << "\tRank = " << _Rank << "\n";
101     aScript << "\t" << _NomIter << ".SetTimeStepRank( TimeStep, Rank )\n";
102   }
103
104   aScript << "\thomard.AssociateIterHypo(\"" <<_NomIter << "\", \"" << _NomHypo << "\")\n";
105   if (_Etat == true)
106   {
107      aScript << "\tcodret = homard.Compute(\"" <<_NomIter << "\", 1)\n";
108   }
109   else
110   {
111      aScript << "\t#codret = homard.Compute(\"" <<_NomIter << "\", 1)\n";
112   }
113
114   return aScript.str();
115 }
116 //=============================================================================
117 /*!
118 */
119 //=============================================================================
120 void HOMARD_Iteration::SetEtat( bool etat )
121 {
122   _Etat = etat;
123 }
124
125 //=============================================================================
126 /*!
127 */
128 //=============================================================================
129 bool HOMARD_Iteration::GetEtat() const
130 {
131   return _Etat;
132 }
133
134 //=============================================================================
135 /*!
136 */
137 //=============================================================================
138 void HOMARD_Iteration::SetNumber( int NumIter )
139 {
140   _NumIter = NumIter;
141 }
142
143 //=============================================================================
144 /*!
145 */
146 //=============================================================================
147 int HOMARD_Iteration::GetNumber() const
148 {
149   return _NumIter;
150 }
151
152 //=============================================================================
153 /*!
154 */
155 //=============================================================================
156 void HOMARD_Iteration::SetMeshName( const char* NomMesh )
157 {
158   _NomMesh = std::string( NomMesh );
159 }
160
161 //=============================================================================
162 /*!
163 */
164 //=============================================================================
165 std::string HOMARD_Iteration::GetMeshName() const
166 {
167   return _NomMesh;
168 }
169
170 //=============================================================================
171 /*!
172 */
173 //=============================================================================
174 void HOMARD_Iteration::SetIterParent( const char* IterParent )
175 {
176   _IterParent = IterParent;
177 }
178
179 //=============================================================================
180 /*!
181 */
182 //=============================================================================
183 std::string HOMARD_Iteration::GetIterParent() const
184 {
185   return _IterParent;
186 }
187
188 //=============================================================================
189 /*!
190 */
191 //=============================================================================
192 void HOMARD_Iteration::AddIteration( const char* NomIteration )
193 {
194   _mesIterFilles.push_back( std::string( NomIteration ) );
195 }
196
197 //=============================================================================
198 /*!
199 */
200 //=============================================================================
201 const std::list<std::string>& HOMARD_Iteration::GetIterations() const
202 {
203   return _mesIterFilles;
204 }
205
206 //=============================================================================
207 /*!
208 */
209 //=============================================================================
210 void HOMARD_Iteration::SupprIterations()
211 {
212   _mesIterFilles.clear();
213 }
214
215 //=============================================================================
216 /*!
217 */
218 //=============================================================================
219 void HOMARD_Iteration::SetHypoName( const char* NomHypo )
220 {
221   _NomHypo = std::string( NomHypo );
222 }
223
224 //=============================================================================
225 /*!
226 */
227 //=============================================================================
228 std::string HOMARD_Iteration::GetHypoName() const
229 {
230   return _NomHypo;
231 }
232
233 //=============================================================================
234 /*!
235 */
236 //=============================================================================
237 void HOMARD_Iteration::SetMeshFile( const char* MeshFile )
238 {
239   _MeshFile = std::string( MeshFile );
240 }
241
242 //=============================================================================
243 /*!
244 */
245 //=============================================================================
246 std::string HOMARD_Iteration::GetMeshFile() const
247 {
248   return _MeshFile;
249 }
250
251 //=============================================================================
252 /*!
253 */
254 //=============================================================================
255 void HOMARD_Iteration::SetFieldFile( const char* FieldFile )
256 {
257   _FieldFile = std::string( FieldFile );
258 }
259 //=============================================================================
260 std::string HOMARD_Iteration::GetFieldFile() const
261 {
262   return _FieldFile;
263 }
264
265 //=============================================================================
266 /*!
267 */
268 //=============================================================================
269 void HOMARD_Iteration::SetTimeStepRank( int TimeStep, int Rank )
270 {
271   _TimeStep = TimeStep;
272   _Rank = Rank;
273 }
274 //=============================================================================
275 int HOMARD_Iteration::GetTimeStep() const
276 {
277   return _TimeStep;
278 }
279 //=============================================================================
280 int HOMARD_Iteration::GetRank() const
281 {
282   return _Rank;
283 }
284
285 //=============================================================================
286 /*!
287 */
288 //=============================================================================
289 void HOMARD_Iteration::SetCaseName( const char* NomCas )
290 {
291   _NomCas = std::string( NomCas );
292 }
293
294 //=============================================================================
295 /*!
296 */
297 //=============================================================================
298 std::string HOMARD_Iteration::GetCaseName() const
299 {
300   return _NomCas;
301 }
302 //=============================================================================
303 /*!
304 */
305 //=============================================================================
306 void HOMARD_Iteration::SetDirName( const char* NomDir )
307 {
308   _NomDir = std::string( NomDir );
309 }
310 //=============================================================================
311 /*!
312 */
313 //=============================================================================
314 std::string HOMARD_Iteration::GetDirName() const
315 {
316    return _NomDir;
317 }
318 /*!
319 */
320 //=============================================================================
321 void HOMARD_Iteration::SetMessFile( const char* MessFile )
322 {
323   _MessFile = std::string( MessFile );
324 }
325
326 //=============================================================================
327 /*!
328 */
329 //=============================================================================
330 std::string HOMARD_Iteration::GetMessFile() const
331 {
332   return _MessFile;
333 }