Salome HOME
mise a jour pour la poursuite d'iterations
[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 HOMARD_Iteration::~HOMARD_Iteration()
60 {
61   MESSAGE("~HOMARD_Iteration");
62 }
63 //=============================================================================
64 //=============================================================================
65 // Generalites
66 //=============================================================================
67 //=============================================================================
68 void HOMARD_Iteration::SetName( const char* Name )
69 {
70   _Name = std::string( Name );
71 }
72 //=============================================================================
73 std::string HOMARD_Iteration::GetName() const
74 {
75   return _Name;
76 }
77 //=============================================================================
78 std::string HOMARD_Iteration::GetDumpPython() const
79 {
80   if (_IterParent == "") return std::string(" ") ;   // Pas de creation explicite de iteration 0";
81
82   MESSAGE (". Ecriture de l iteration " << _Name );
83   std::ostringstream aScript;
84   aScript << "\n# Creation of the iteration " << _Name << "\n";
85   if( _NumIter == 1 )
86   {
87        aScript << "\t" << _Name << " = " << _NomCas << ".NextIteration(\"" << _Name << "\")\n";
88   }
89    else
90   {
91        aScript << "\t" << _Name << " = " << _IterParent << ".NextIteration(\"" << _Name << "\")\n";
92   }
93 // Le nom du maillage produit
94 //   MESSAGE (".. maillage produit " << _NomMesh );
95   aScript << "\t" << _Name << ".SetMeshName(\"" << _NomMesh << "\")\n" ;
96 // Le fichier du maillage produit
97   aScript << "\t" << _Name << ".SetMeshFile(\"" << _MeshFile << "\")\n";
98 // Le fichier des champs, avec l'instant eventuel
99   if ( _FieldFile != "" ) {
100     aScript << "\t" << _Name << ".SetFieldFile(\"" << _FieldFile << "\")\n";
101     if ( _TimeStep == -2 ) {
102       aScript << "\t" << _Name << ".SetTimeStepRankLast()\n";
103     }
104     else
105     {
106       if ( ( _TimeStep != -1 ) and ( _Rank != -1 ) ) {
107         aScript << "\t" << _Name << ".SetTimeStepRank( " << _TimeStep << ", " << _Rank << " )\n";
108       }
109     }
110   }
111
112 //   MESSAGE (".. Hypothese " << _NomHypo );
113   aScript << "\t" << _Name << ".AssociateHypo(\"" << _NomHypo << "\")\n";
114
115   if (_Etat == true) { aScript << "\tcodret = "  <<_Name << ".Compute(1, 2)\n"; }
116   else               { aScript << "\t#codret = " <<_Name << ".Compute(1, 2)\n"; }
117 //   MESSAGE (". Fin de l ecriture de l iteration " << _Name );
118
119   return aScript.str();
120 }
121 //=============================================================================
122 //=============================================================================
123 // Caracteristiques
124 //=============================================================================
125 //=============================================================================
126 void HOMARD_Iteration::SetDirName( const char* NomDir )
127 {
128   _NomDir = std::string( NomDir );
129 }
130 //=============================================================================
131 std::string HOMARD_Iteration::GetDirName() const
132 {
133    return _NomDir;
134 }
135 //=============================================================================
136 void HOMARD_Iteration::SetNumber( int NumIter )
137 {
138   _NumIter = NumIter;
139 }
140 //=============================================================================
141 int HOMARD_Iteration::GetNumber() const
142 {
143   return _NumIter;
144 }
145 //=============================================================================
146 void HOMARD_Iteration::SetState( int etat )
147 {
148   _Etat = etat;
149 }
150 //=============================================================================
151 int HOMARD_Iteration::GetState() const
152 {
153   return _Etat;
154 }
155 //=============================================================================
156 void HOMARD_Iteration::SetMeshName( const char* NomMesh )
157 {
158   _NomMesh = std::string( NomMesh );
159 }
160 //=============================================================================
161 std::string HOMARD_Iteration::GetMeshName() const
162 {
163   return _NomMesh;
164 }
165 //=============================================================================
166 void HOMARD_Iteration::SetMeshFile( const char* MeshFile )
167 {
168   _MeshFile = std::string( MeshFile );
169 }
170 //=============================================================================
171 std::string HOMARD_Iteration::GetMeshFile() const
172 {
173   return _MeshFile;
174 }
175 //=============================================================================
176 void HOMARD_Iteration::SetFieldFile( const char* FieldFile )
177 {
178   _FieldFile = std::string( FieldFile );
179 }
180 //=============================================================================
181 std::string HOMARD_Iteration::GetFieldFile() const
182 {
183   return _FieldFile;
184 }
185 //=============================================================================
186 void HOMARD_Iteration::SetTimeStepRank( int TimeStep, int Rank )
187 {
188   _TimeStep = TimeStep;
189   _Rank = Rank;
190 }
191 //=============================================================================
192 void HOMARD_Iteration::SetTimeStepRankLast()
193 {
194   _TimeStep = -2;
195 }
196 //=============================================================================
197 int HOMARD_Iteration::GetTimeStep() const
198 {
199   return _TimeStep;
200 }
201 //=============================================================================
202 int HOMARD_Iteration::GetRank() const
203 {
204   return _Rank;
205 }
206 //=============================================================================
207 void HOMARD_Iteration::SetLogFile( const char* LogFile )
208 {
209   _LogFile = std::string( LogFile );
210 }
211 //=============================================================================
212 std::string HOMARD_Iteration::GetLogFile() const
213 {
214   return _LogFile;
215 }
216 //=============================================================================
217 void HOMARD_Iteration::SetFileInfo( const char* FileInfo )
218 {
219   _FileInfo = std::string( FileInfo );
220 }
221 //=============================================================================
222 std::string HOMARD_Iteration::GetFileInfo() const
223 {
224   return _FileInfo;
225 }
226 //=============================================================================
227 //=============================================================================
228 // Liens avec les autres iterations
229 //=============================================================================
230 //=============================================================================
231 void HOMARD_Iteration::LinkNextIteration( const char* NomIteration )
232 {
233   _mesIterFilles.push_back( std::string( NomIteration ) );
234 }
235 //=============================================================================
236 void HOMARD_Iteration::UnLinkNextIteration( const char* NomIteration )
237 {
238   std::list<std::string>::iterator it = find( _mesIterFilles.begin(), _mesIterFilles.end(), NomIteration ) ;
239   if ( it != _mesIterFilles.end() )
240   {
241     MESSAGE ("Dans UnLinkNextIteration pour " << NomIteration) ;
242     _mesIterFilles.erase( it ) ;
243   }
244 }
245 //=============================================================================
246 void HOMARD_Iteration::UnLinkNextIterations()
247 {
248   _mesIterFilles.clear();
249 }
250 //=============================================================================
251 const std::list<std::string>& HOMARD_Iteration::GetIterations() const
252 {
253   return _mesIterFilles;
254 }
255 //=============================================================================
256 void HOMARD_Iteration::SetIterParentName( const char* IterParent )
257 {
258   _IterParent = IterParent;
259 }
260 //=============================================================================
261 std::string HOMARD_Iteration::GetIterParentName() const
262 {
263   return _IterParent;
264 }
265 //=============================================================================
266 //=============================================================================
267 // Liens avec les autres structures
268 //=============================================================================
269 //=============================================================================
270 void HOMARD_Iteration::SetCaseName( const char* NomCas )
271 {
272   _NomCas = std::string( NomCas );
273 }
274 //=============================================================================
275 std::string HOMARD_Iteration::GetCaseName() const
276 {
277   return _NomCas;
278 }
279 //=============================================================================
280 void HOMARD_Iteration::SetHypoName( const char* NomHypo )
281 {
282   _NomHypo = std::string( NomHypo );
283 }
284 //=============================================================================
285 std::string HOMARD_Iteration::GetHypoName() const
286 {
287   return _NomHypo;
288 }