1 // HOMARD HOMARD : implementation of HOMARD idl descriptions
3 // Copyright (C) 2011-2022 CEA/DEN, EDF R&D
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, or (at your option) any later version.
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.
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
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : HOMARD_Iteration.cxx
22 // Author : Gerald NICOLAS, EDF
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
32 // Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier
34 #include "HOMARD_Iteration.hxx"
36 #include "utilities.h"
38 //=============================================================================
40 * default constructor:
42 //=============================================================================
43 HOMARD_Iteration::HOMARD_Iteration():
44 _Name( "" ), _Etat( 0 ),
46 _NomMesh( "" ), _MeshFile( "" ),
47 _FieldFile( "" ), _TimeStep( -1 ), _Rank( -1 ),
50 _NomHypo( "" ), _NomCas( "" ), _NomDir( "" ),
54 MESSAGE("HOMARD_Iteration");
56 //=============================================================================
60 //=============================================================================
61 HOMARD_Iteration::~HOMARD_Iteration()
63 MESSAGE("~HOMARD_Iteration");
65 //=============================================================================
66 //=============================================================================
68 //=============================================================================
69 //=============================================================================
70 void HOMARD_Iteration::SetName( const char* Name )
72 _Name = std::string( Name );
74 //=============================================================================
75 std::string HOMARD_Iteration::GetName() const
79 //=============================================================================
80 std::string HOMARD_Iteration::GetDumpPython() const
82 if (_IterParent == "") return std::string(" ") ; // Pas de creation explicite de iteration 0";
84 MESSAGE (". Ecriture de l iteration " << _Name );
85 std::ostringstream aScript;
86 aScript << "\n# Creation of the iteration " << _Name << "\n";
89 aScript << "\t" << _Name << " = " << _NomCas << ".NextIteration(\"" << _Name << "\")\n";
93 aScript << "\t" << _Name << " = " << _IterParent << ".NextIteration(\"" << _Name << "\")\n";
95 // L'hypothese (doit etre au debut)
96 aScript << "\t" << _Name << ".AssociateHypo(\"" << _NomHypo << "\")\n";
97 // Le nom du maillage produit
98 // MESSAGE (".. maillage produit " << _NomMesh );
99 aScript << "\t" << _Name << ".SetMeshName(\"" << _NomMesh << "\")\n" ;
100 // Le fichier du maillage produit
101 aScript << "\t" << _Name << ".SetMeshFile(\"" << _MeshFile << "\")\n";
102 // Le fichier des champs
103 if ( _FieldFile != "" )
105 aScript << "\t" << _Name << ".SetFieldFile(\"" << _FieldFile << "\")\n";
107 // Si champ de pilotage, valeurs de pas de temps
108 MESSAGE (". champ de pilotage : _TimeStep = " << _TimeStep << ", _Rank : " << _Rank);
109 if ( _TimeStep != -1 )
111 if ( _TimeStep == -2 ) {
112 aScript << "\t" << _Name << ".SetTimeStepRankLast()\n";
116 if ( _TimeStep != -1 )
120 aScript << "\t" << _Name << ".SetTimeStep( " << _TimeStep << " )\n";
124 aScript << "\t" << _Name << ".SetTimeStepRank( " << _TimeStep << ", " << _Rank << " )\n";
129 // Les instants d'interpolation
130 MESSAGE (". instants d'interpolation ");
131 std::list<std::string>::const_iterator it = _ListFieldInterpTSR.begin() ;
132 while(it != _ListFieldInterpTSR.end())
134 std::string FieldName = std::string((*it)) ;
135 // MESSAGE ("... FieldName = "<< FieldName);
137 std::string TimeStepstr = std::string((*it)) ;
138 // MESSAGE ("... TimeStepstr = "<< TimeStepstr);
140 std::string Rankstr = std::string((*it)) ;
141 // MESSAGE ("... Rankstr = "<< Rankstr);
143 aScript << "\t" << _Name << ".SetFieldInterpTimeStepRank( \"" << FieldName << "\"" ;
144 aScript << ", " << TimeStepstr ;
145 aScript << ", " << Rankstr << " )\n" ;
149 MESSAGE (". Compute ");
150 if ( _Etat == 2 ) { aScript << "\tcodret = " <<_Name << ".Compute(1, 1)\n"; }
151 else { aScript << "\t#codret = " <<_Name << ".Compute(1, 1)\n"; }
152 // MESSAGE (". Fin de l ecriture de l iteration " << _Name );
154 return aScript.str();
156 //=============================================================================
157 //=============================================================================
159 //=============================================================================
160 //=============================================================================
161 void HOMARD_Iteration::SetDirNameLoc( const char* NomDir )
163 _NomDir = std::string( NomDir );
165 //=============================================================================
166 std::string HOMARD_Iteration::GetDirNameLoc() const
170 //=============================================================================
171 void HOMARD_Iteration::SetNumber( int NumIter )
175 //=============================================================================
176 int HOMARD_Iteration::GetNumber() const
180 //=============================================================================
181 void HOMARD_Iteration::SetState( int etat )
185 //=============================================================================
186 int HOMARD_Iteration::GetState() const
190 //=============================================================================
191 void HOMARD_Iteration::SetMeshName( const char* NomMesh )
193 _NomMesh = std::string( NomMesh );
195 //=============================================================================
196 std::string HOMARD_Iteration::GetMeshName() const
200 //=============================================================================
201 void HOMARD_Iteration::SetMeshFile( const char* MeshFile )
203 _MeshFile = std::string( MeshFile );
205 //=============================================================================
206 std::string HOMARD_Iteration::GetMeshFile() const
210 //=============================================================================
211 void HOMARD_Iteration::SetFieldFile( const char* FieldFile )
213 _FieldFile = std::string( FieldFile );
215 //=============================================================================
216 std::string HOMARD_Iteration::GetFieldFile() const
220 //=============================================================================
221 // Instants pour le champ de pilotage
222 //=============================================================================
223 void HOMARD_Iteration::SetTimeStep( int TimeStep )
225 _TimeStep = TimeStep;
227 //=============================================================================
228 void HOMARD_Iteration::SetTimeStepRank( int TimeStep, int Rank )
230 _TimeStep = TimeStep;
233 //=============================================================================
234 void HOMARD_Iteration::SetTimeStepRankLast()
238 //=============================================================================
239 int HOMARD_Iteration::GetTimeStep() const
243 //=============================================================================
244 int HOMARD_Iteration::GetRank() const
248 //=============================================================================
249 // Instants pour un champ a interpoler
250 //=============================================================================
251 void HOMARD_Iteration::SetFieldInterpTimeStep( const char* FieldInterp, int TimeStep )
253 SetFieldInterpTimeStepRank( FieldInterp, TimeStep, TimeStep ) ;
255 //=============================================================================
256 void HOMARD_Iteration::SetFieldInterpTimeStepRank( const char* FieldInterp, int TimeStep, int Rank )
258 MESSAGE("Champ " << FieldInterp << ", hypothese " << _NomHypo );
259 // Verification de la presence du champ dans l'hypothese
260 std::list<std::string>::iterator it = find( _ListFieldInterp.begin(), _ListFieldInterp.end(), FieldInterp );
261 if ( it == _ListFieldInterp.end() )
263 INFOS("Champ " << FieldInterp << " ; hypothese " << _NomHypo )
264 VERIFICATION("Le champ est inconnu dans l'hypothese associee a cette iteration." == 0);
268 _ListFieldInterpTSR.push_back( std::string( FieldInterp ) );
270 std::stringstream saux1 ;
272 _ListFieldInterpTSR.push_back( saux1.str() );
274 std::stringstream saux2 ;
276 _ListFieldInterpTSR.push_back( saux2.str() );
278 //=============================================================================
279 const std::list<std::string>& HOMARD_Iteration::GetFieldInterpsTimeStepRank() const
281 return _ListFieldInterpTSR;
283 //=============================================================================
284 void HOMARD_Iteration::SetFieldInterp( const char* FieldInterp )
286 _ListFieldInterp.push_back( std::string( FieldInterp ) );
288 //=============================================================================
289 const std::list<std::string>& HOMARD_Iteration::GetFieldInterps() const
291 return _ListFieldInterp;
293 //=============================================================================
294 void HOMARD_Iteration::SupprFieldInterps()
296 _ListFieldInterp.clear();
298 //=============================================================================
299 void HOMARD_Iteration::SetLogFile( const char* LogFile )
301 _LogFile = std::string( LogFile );
303 //=============================================================================
304 std::string HOMARD_Iteration::GetLogFile() const
308 //=============================================================================
309 void HOMARD_Iteration::SetFileInfo( const char* FileInfo )
311 _FileInfo = std::string( FileInfo );
313 //=============================================================================
314 std::string HOMARD_Iteration::GetFileInfo() const
318 //=============================================================================
319 //=============================================================================
320 // Liens avec les autres iterations
321 //=============================================================================
322 //=============================================================================
323 void HOMARD_Iteration::LinkNextIteration( const char* NomIteration )
325 _mesIterFilles.push_back( std::string( NomIteration ) );
327 //=============================================================================
328 void HOMARD_Iteration::UnLinkNextIteration( const char* NomIteration )
330 std::list<std::string>::iterator it = find( _mesIterFilles.begin(), _mesIterFilles.end(), NomIteration ) ;
331 if ( it != _mesIterFilles.end() )
333 MESSAGE ("Dans UnLinkNextIteration pour " << NomIteration) ;
334 it = _mesIterFilles.erase( it ) ;
337 //=============================================================================
338 void HOMARD_Iteration::UnLinkNextIterations()
340 _mesIterFilles.clear();
342 //=============================================================================
343 const std::list<std::string>& HOMARD_Iteration::GetIterations() const
345 return _mesIterFilles;
347 //=============================================================================
348 void HOMARD_Iteration::SetIterParentName( const char* IterParent )
350 _IterParent = IterParent;
352 //=============================================================================
353 std::string HOMARD_Iteration::GetIterParentName() const
357 //=============================================================================
358 //=============================================================================
359 // Liens avec les autres structures
360 //=============================================================================
361 //=============================================================================
362 void HOMARD_Iteration::SetCaseName( const char* NomCas )
364 _NomCas = std::string( NomCas );
366 //=============================================================================
367 std::string HOMARD_Iteration::GetCaseName() const
371 //=============================================================================
372 void HOMARD_Iteration::SetHypoName( const char* NomHypo )
374 _NomHypo = std::string( NomHypo );
376 //=============================================================================
377 std::string HOMARD_Iteration::GetHypoName() const
381 //=============================================================================
382 //=============================================================================
384 //=============================================================================
385 //=============================================================================
386 void HOMARD_Iteration::SetInfoCompute( int MessInfo )
388 _MessInfo = MessInfo;
390 //=============================================================================
391 int HOMARD_Iteration::GetInfoCompute() const