Salome HOME
Merge from V6_main 01/04/2013
[modules/homard.git] / src / HOMARD / HOMARD_Iteration.cxx
1 //  HOMARD HOMARD : implementation of HOMARD idl descriptions
2 //
3 // Copyright (C) 2011-2013  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 // Remarques :
26 // L'ordre de description des fonctions est le meme dans tous les fichiers
27 // HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx :
28 // 1. Les generalites : Name, Delete, DumpPython, Dump, Restore
29 // 2. Les caracteristiques
30 // 3. Le lien avec les autres structures
31 //
32 // Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier
33
34 #include "HOMARD_Iteration.hxx"
35 #include "utilities.h"
36
37 //=============================================================================
38 /*!
39  *  default constructor:
40  */
41 //=============================================================================
42 HOMARD_Iteration::HOMARD_Iteration():
43   _Name( "" ), _Etat( false ),
44  _NumIter( -1 ),
45   _NomMesh( "" ), _MeshFile( "" ),
46   _FieldFile( "" ), _TimeStep( -1 ), _Rank( -1 ),
47   _LogFile( "" ),
48   _IterParent( "" ),
49   _NomHypo( "" ), _NomCas( "" ), _NomDir( "" ),
50   _FileInfo( "" )
51 {
52   MESSAGE("HOMARD_Iter");
53 }
54
55 //=============================================================================
56 /*!
57  *
58  */
59 //=============================================================================
60 HOMARD_Iteration::~HOMARD_Iteration()
61 {
62   MESSAGE("~HOMARD_Iteration");
63 }
64 //=============================================================================
65 //=============================================================================
66 // Generalites
67 //=============================================================================
68 //=============================================================================
69 void HOMARD_Iteration::SetName( const char* Name )
70 {
71   _Name = std::string( Name );
72 }
73 //=============================================================================
74 std::string HOMARD_Iteration::GetName() const
75 {
76   return _Name;
77 }
78 //=============================================================================
79 std::string HOMARD_Iteration::GetDumpPython() const
80 {
81   if (_IterParent == "") return std::string(" ") ;   // Pas de creation explicite de iteration 0";
82
83   MESSAGE (". Ecriture de l iteration " << _Name );
84   std::ostringstream aScript;
85   aScript << "\n# Creation of the iteration " << _Name << "\n";
86   if( _NumIter == 1 )
87   {
88        aScript << "\t" << _Name << " = " << _NomCas << ".NextIteration(\"" << _Name << "\")\n";
89   }
90    else
91   {
92        aScript << "\t" << _Name << " = " << _IterParent << ".NextIteration(\"" << _Name << "\")\n";
93   }
94 // Le nom du maillage produit
95 //   MESSAGE (".. maillage produit " << _NomMesh );
96   aScript << "\t" << _Name << ".SetMeshName(\"" << _NomMesh << "\")\n" ;
97 // Le fichier du maillage produit
98   aScript << "\t" << _Name << ".SetMeshFile(\"" << _MeshFile << "\")\n";
99 // Le fichier des champs, avec l'instant eventuel
100   if ( _FieldFile != "" ) {
101     aScript << "\t" << _Name << ".SetFieldFile(\"" << _FieldFile << "\")\n";
102     if ( _TimeStep == -2 ) {
103       aScript << "\t" << _Name << ".SetTimeStepRankLast()\n";
104     }
105     else
106     {
107       if ( ( _TimeStep != -1 ) and ( _Rank != -1 ) ) {
108         aScript << "\t" << _Name << ".SetTimeStepRank( " << _TimeStep << ", " << _Rank << " )\n";
109       }
110     }
111   }
112
113 //   MESSAGE (".. Hypothese " << _NomHypo );
114   aScript << "\t" << _Name << ".AssociateHypo(\"" << _NomHypo << "\")\n";
115
116   if (_Etat == true)
117   {
118      aScript << "\tcodret = " <<_Name << ".Compute(1)\n";
119   }
120   else
121   {
122      aScript << "\t#codret = " <<_Name << ".Compute(1)\n";
123   }
124 //   MESSAGE (". Fin de l ecriture de l iteration " << _Name );
125
126   return aScript.str();
127 }
128 //=============================================================================
129 //=============================================================================
130 // Caracteristiques
131 //=============================================================================
132 //=============================================================================
133 void HOMARD_Iteration::SetDirName( const char* NomDir )
134 {
135   _NomDir = std::string( NomDir );
136 }
137 //=============================================================================
138 std::string HOMARD_Iteration::GetDirName() const
139 {
140    return _NomDir;
141 }
142 //=============================================================================
143 void HOMARD_Iteration::SetNumber( int NumIter )
144 {
145   _NumIter = NumIter;
146 }
147 //=============================================================================
148 int HOMARD_Iteration::GetNumber() const
149 {
150   return _NumIter;
151 }
152 //=============================================================================
153 void HOMARD_Iteration::SetEtat( bool etat )
154 {
155   _Etat = etat;
156 }
157 //=============================================================================
158 bool HOMARD_Iteration::GetEtat() const
159 {
160   return _Etat;
161 }
162 //=============================================================================
163 void HOMARD_Iteration::SetMeshName( const char* NomMesh )
164 {
165   _NomMesh = std::string( NomMesh );
166 }
167 //=============================================================================
168 std::string HOMARD_Iteration::GetMeshName() const
169 {
170   return _NomMesh;
171 }
172 //=============================================================================
173 void HOMARD_Iteration::SetMeshFile( const char* MeshFile )
174 {
175   _MeshFile = std::string( MeshFile );
176 }
177 //=============================================================================
178 std::string HOMARD_Iteration::GetMeshFile() const
179 {
180   return _MeshFile;
181 }
182 //=============================================================================
183 void HOMARD_Iteration::SetFieldFile( const char* FieldFile )
184 {
185   _FieldFile = std::string( FieldFile );
186 }
187 //=============================================================================
188 std::string HOMARD_Iteration::GetFieldFile() const
189 {
190   return _FieldFile;
191 }
192 //=============================================================================
193 void HOMARD_Iteration::SetTimeStepRank( int TimeStep, int Rank )
194 {
195   _TimeStep = TimeStep;
196   _Rank = Rank;
197 }
198 //=============================================================================
199 void HOMARD_Iteration::SetTimeStepRankLast()
200 {
201   _TimeStep = -2;
202 }
203 //=============================================================================
204 int HOMARD_Iteration::GetTimeStep() const
205 {
206   return _TimeStep;
207 }
208 //=============================================================================
209 int HOMARD_Iteration::GetRank() const
210 {
211   return _Rank;
212 }
213 //=============================================================================
214 void HOMARD_Iteration::SetLogFile( const char* LogFile )
215 {
216   _LogFile = std::string( LogFile );
217 }
218 //=============================================================================
219 std::string HOMARD_Iteration::GetLogFile() const
220 {
221   return _LogFile;
222 }
223 //=============================================================================
224 void HOMARD_Iteration::SetFileInfo( const char* FileInfo )
225 {
226   _FileInfo = std::string( FileInfo );
227 }
228 //=============================================================================
229 std::string HOMARD_Iteration::GetFileInfo() const
230 {
231   return _FileInfo;
232 }
233 //=============================================================================
234 //=============================================================================
235 // Liens avec les autres iterations
236 //=============================================================================
237 //=============================================================================
238 void HOMARD_Iteration::LinkNextIteration( const char* NomIteration )
239 {
240   _mesIterFilles.push_back( std::string( NomIteration ) );
241 }
242 //=============================================================================
243 void HOMARD_Iteration::UnLinkNextIteration( const char* NomIteration )
244 {
245   std::list<std::string>::iterator it = find( _mesIterFilles.begin(), _mesIterFilles.end(), NomIteration ) ;
246   if ( it != _mesIterFilles.end() )
247   {
248     MESSAGE ("Dans UnLinkNextIteration pour " << NomIteration) ;
249     _mesIterFilles.erase( it ) ;
250   }
251 }
252 //=============================================================================
253 void HOMARD_Iteration::UnLinkNextIterations()
254 {
255   _mesIterFilles.clear();
256 }
257 //=============================================================================
258 const std::list<std::string>& HOMARD_Iteration::GetIterations() const
259 {
260   return _mesIterFilles;
261 }
262 //=============================================================================
263 void HOMARD_Iteration::SetIterParentName( const char* IterParent )
264 {
265   _IterParent = IterParent;
266 }
267 //=============================================================================
268 std::string HOMARD_Iteration::GetIterParentName() const
269 {
270   return _IterParent;
271 }
272 //=============================================================================
273 //=============================================================================
274 // Liens avec les autres structures
275 //=============================================================================
276 //=============================================================================
277 void HOMARD_Iteration::SetCaseName( const char* NomCas )
278 {
279   _NomCas = std::string( NomCas );
280 }
281 //=============================================================================
282 std::string HOMARD_Iteration::GetCaseName() const
283 {
284   return _NomCas;
285 }
286 //=============================================================================
287 void HOMARD_Iteration::SetHypoName( const char* NomHypo )
288 {
289   _NomHypo = std::string( NomHypo );
290 }
291 //=============================================================================
292 std::string HOMARD_Iteration::GetHypoName() const
293 {
294   return _NomHypo;
295 }