Salome HOME
InfoCompute
[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  _MessInfo( 1 )
52 {
53   MESSAGE("HOMARD_Iter");
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) { aScript << "\tcodret = "  <<_Name << ".Compute(1, 2)\n"; }
117   else               { aScript << "\t#codret = " <<_Name << ".Compute(1, 2)\n"; }
118 //   MESSAGE (". Fin de l ecriture de l iteration " << _Name );
119
120   return aScript.str();
121 }
122 //=============================================================================
123 //=============================================================================
124 // Caracteristiques
125 //=============================================================================
126 //=============================================================================
127 void HOMARD_Iteration::SetDirNameLoc( const char* NomDir )
128 {
129   _NomDir = std::string( NomDir );
130 }
131 //=============================================================================
132 std::string HOMARD_Iteration::GetDirNameLoc() const
133 {
134    return _NomDir;
135 }
136 //=============================================================================
137 void HOMARD_Iteration::SetNumber( int NumIter )
138 {
139   _NumIter = NumIter;
140 }
141 //=============================================================================
142 int HOMARD_Iteration::GetNumber() const
143 {
144   return _NumIter;
145 }
146 //=============================================================================
147 void HOMARD_Iteration::SetState( int etat )
148 {
149   _Etat = etat;
150 }
151 //=============================================================================
152 int HOMARD_Iteration::GetState() const
153 {
154   return _Etat;
155 }
156 //=============================================================================
157 void HOMARD_Iteration::SetMeshName( const char* NomMesh )
158 {
159   _NomMesh = std::string( NomMesh );
160 }
161 //=============================================================================
162 std::string HOMARD_Iteration::GetMeshName() const
163 {
164   return _NomMesh;
165 }
166 //=============================================================================
167 void HOMARD_Iteration::SetMeshFile( const char* MeshFile )
168 {
169   _MeshFile = std::string( MeshFile );
170 }
171 //=============================================================================
172 std::string HOMARD_Iteration::GetMeshFile() const
173 {
174   return _MeshFile;
175 }
176 //=============================================================================
177 void HOMARD_Iteration::SetFieldFile( const char* FieldFile )
178 {
179   _FieldFile = std::string( FieldFile );
180 }
181 //=============================================================================
182 std::string HOMARD_Iteration::GetFieldFile() const
183 {
184   return _FieldFile;
185 }
186 //=============================================================================
187 void HOMARD_Iteration::SetTimeStepRank( int TimeStep, int Rank )
188 {
189   _TimeStep = TimeStep;
190   _Rank = Rank;
191 }
192 //=============================================================================
193 void HOMARD_Iteration::SetTimeStepRankLast()
194 {
195   _TimeStep = -2;
196 }
197 //=============================================================================
198 int HOMARD_Iteration::GetTimeStep() const
199 {
200   return _TimeStep;
201 }
202 //=============================================================================
203 int HOMARD_Iteration::GetRank() const
204 {
205   return _Rank;
206 }
207 //=============================================================================
208 void HOMARD_Iteration::SetLogFile( const char* LogFile )
209 {
210   _LogFile = std::string( LogFile );
211 }
212 //=============================================================================
213 std::string HOMARD_Iteration::GetLogFile() const
214 {
215   return _LogFile;
216 }
217 //=============================================================================
218 void HOMARD_Iteration::SetFileInfo( const char* FileInfo )
219 {
220   _FileInfo = std::string( FileInfo );
221 }
222 //=============================================================================
223 std::string HOMARD_Iteration::GetFileInfo() const
224 {
225   return _FileInfo;
226 }
227 //=============================================================================
228 //=============================================================================
229 // Liens avec les autres iterations
230 //=============================================================================
231 //=============================================================================
232 void HOMARD_Iteration::LinkNextIteration( const char* NomIteration )
233 {
234   _mesIterFilles.push_back( std::string( NomIteration ) );
235 }
236 //=============================================================================
237 void HOMARD_Iteration::UnLinkNextIteration( const char* NomIteration )
238 {
239   std::list<std::string>::iterator it = find( _mesIterFilles.begin(), _mesIterFilles.end(), NomIteration ) ;
240   if ( it != _mesIterFilles.end() )
241   {
242     MESSAGE ("Dans UnLinkNextIteration pour " << NomIteration) ;
243     _mesIterFilles.erase( it ) ;
244   }
245 }
246 //=============================================================================
247 void HOMARD_Iteration::UnLinkNextIterations()
248 {
249   _mesIterFilles.clear();
250 }
251 //=============================================================================
252 const std::list<std::string>& HOMARD_Iteration::GetIterations() const
253 {
254   return _mesIterFilles;
255 }
256 //=============================================================================
257 void HOMARD_Iteration::SetIterParentName( const char* IterParent )
258 {
259   _IterParent = IterParent;
260 }
261 //=============================================================================
262 std::string HOMARD_Iteration::GetIterParentName() const
263 {
264   return _IterParent;
265 }
266 //=============================================================================
267 //=============================================================================
268 // Liens avec les autres structures
269 //=============================================================================
270 //=============================================================================
271 void HOMARD_Iteration::SetCaseName( const char* NomCas )
272 {
273   _NomCas = std::string( NomCas );
274 }
275 //=============================================================================
276 std::string HOMARD_Iteration::GetCaseName() const
277 {
278   return _NomCas;
279 }
280 //=============================================================================
281 void HOMARD_Iteration::SetHypoName( const char* NomHypo )
282 {
283   _NomHypo = std::string( NomHypo );
284 }
285 //=============================================================================
286 std::string HOMARD_Iteration::GetHypoName() const
287 {
288   return _NomHypo;
289 }
290 //=============================================================================
291 //=============================================================================
292 // Divers
293 //=============================================================================
294 //=============================================================================
295 void HOMARD_Iteration::SetInfoCompute( int MessInfo )
296 {
297   _MessInfo = MessInfo;
298 }
299 //=============================================================================
300 int HOMARD_Iteration::GetInfoCompute() const
301 {
302   return _MessInfo;
303 }