]> SALOME platform Git repositories - modules/homard.git/blob - src/HOMARD/HOMARD_Iteration.cxx
Salome HOME
Selection of the last time step; Back to the current directory after a computation...
[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 // 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   _MessFile( "" ),
48   _IterParent( "" ),
49   _NomHypo( "" ), _NomCas( "" ), _NomDir( "" )
50 {
51   MESSAGE("HOMARD_Iter");
52 }
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)
116   {
117      aScript << "\tcodret = " <<_Name << ".Compute(1)\n";
118   }
119   else
120   {
121      aScript << "\t#codret = " <<_Name << ".Compute(1)\n";
122   }
123 //   MESSAGE (". Fin de l ecriture de l iteration " << _Name );
124
125   return aScript.str();
126 }
127 //=============================================================================
128 //=============================================================================
129 // Caracteristiques
130 //=============================================================================
131 //=============================================================================
132 void HOMARD_Iteration::SetDirName( const char* NomDir )
133 {
134   _NomDir = std::string( NomDir );
135 }
136 //=============================================================================
137 std::string HOMARD_Iteration::GetDirName() const
138 {
139    return _NomDir;
140 }
141 //=============================================================================
142 void HOMARD_Iteration::SetNumber( int NumIter )
143 {
144   _NumIter = NumIter;
145 }
146 //=============================================================================
147 int HOMARD_Iteration::GetNumber() const
148 {
149   return _NumIter;
150 }
151 //=============================================================================
152 void HOMARD_Iteration::SetEtat( bool etat )
153 {
154   _Etat = etat;
155 }
156 //=============================================================================
157 bool HOMARD_Iteration::GetEtat() const
158 {
159   return _Etat;
160 }
161 //=============================================================================
162 void HOMARD_Iteration::SetMeshName( const char* NomMesh )
163 {
164   _NomMesh = std::string( NomMesh );
165 }
166 //=============================================================================
167 std::string HOMARD_Iteration::GetMeshName() const
168 {
169   return _NomMesh;
170 }
171 //=============================================================================
172 void HOMARD_Iteration::SetMeshFile( const char* MeshFile )
173 {
174   _MeshFile = std::string( MeshFile );
175 }
176 //=============================================================================
177 std::string HOMARD_Iteration::GetMeshFile() const
178 {
179   return _MeshFile;
180 }
181 //=============================================================================
182 void HOMARD_Iteration::SetFieldFile( const char* FieldFile )
183 {
184   _FieldFile = std::string( FieldFile );
185 }
186 //=============================================================================
187 std::string HOMARD_Iteration::GetFieldFile() const
188 {
189   return _FieldFile;
190 }
191 //=============================================================================
192 void HOMARD_Iteration::SetTimeStepRank( int TimeStep, int Rank )
193 {
194   _TimeStep = TimeStep;
195   _Rank = Rank;
196 }
197 //=============================================================================
198 void HOMARD_Iteration::SetTimeStepRankLast()
199 {
200   _TimeStep = -2;
201 }
202 //=============================================================================
203 int HOMARD_Iteration::GetTimeStep() const
204 {
205   return _TimeStep;
206 }
207 //=============================================================================
208 int HOMARD_Iteration::GetRank() const
209 {
210   return _Rank;
211 }
212 //=============================================================================
213 void HOMARD_Iteration::SetMessFile( const char* MessFile )
214 {
215   _MessFile = std::string( MessFile );
216 }
217 //=============================================================================
218 std::string HOMARD_Iteration::GetMessFile() const
219 {
220   return _MessFile;
221 }
222 //=============================================================================
223 //=============================================================================
224 // Liens avec les autres iterations
225 //=============================================================================
226 //=============================================================================
227 void HOMARD_Iteration::LinkNextIteration( const char* NomIteration )
228 {
229   _mesIterFilles.push_back( std::string( NomIteration ) );
230 }
231 //=============================================================================
232 void HOMARD_Iteration::UnLinkNextIteration( const char* NomIteration )
233 {
234   std::list<std::string>::iterator it = find( _mesIterFilles.begin(), _mesIterFilles.end(), NomIteration ) ;
235   if ( it != _mesIterFilles.end() )
236   {
237     MESSAGE ("Dans UnLinkNextIteration pour " << NomIteration) ;
238     _mesIterFilles.erase( it ) ;
239   }
240 }
241 //=============================================================================
242 void HOMARD_Iteration::UnLinkNextIterations()
243 {
244   _mesIterFilles.clear();
245 }
246 //=============================================================================
247 const std::list<std::string>& HOMARD_Iteration::GetIterations() const
248 {
249   return _mesIterFilles;
250 }
251 //=============================================================================
252 void HOMARD_Iteration::SetIterParentName( const char* IterParent )
253 {
254   _IterParent = IterParent;
255 }
256 //=============================================================================
257 std::string HOMARD_Iteration::GetIterParentName() const
258 {
259   return _IterParent;
260 }
261 //=============================================================================
262 //=============================================================================
263 // Liens avec les autres structures
264 //=============================================================================
265 //=============================================================================
266 void HOMARD_Iteration::SetCaseName( const char* NomCas )
267 {
268   _NomCas = std::string( NomCas );
269 }
270 //=============================================================================
271 std::string HOMARD_Iteration::GetCaseName() const
272 {
273   return _NomCas;
274 }
275 //=============================================================================
276 void HOMARD_Iteration::SetHypoName( const char* NomHypo )
277 {
278   _NomHypo = std::string( NomHypo );
279 }
280 //=============================================================================
281 std::string HOMARD_Iteration::GetHypoName() const
282 {
283   return _NomHypo;
284 }