1 // HOMARD HOMARD : implementation of HOMARD idl descriptions
3 // Copyright (C) 2011-2013 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.
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 : Paul RASCLE, 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"
35 #include "utilities.h"
37 //=============================================================================
39 * default constructor:
41 //=============================================================================
42 HOMARD_Iteration::HOMARD_Iteration():
43 _Name( "" ), _Etat( false ),
45 _NomMesh( "" ), _MeshFile( "" ),
46 _FieldFile( "" ), _TimeStep( -1 ), _Rank( -1 ),
49 _NomHypo( "" ), _NomCas( "" ), _NomDir( "" ),
52 MESSAGE("HOMARD_Iter");
54 //=============================================================================
58 //=============================================================================
59 HOMARD_Iteration::~HOMARD_Iteration()
61 MESSAGE("~HOMARD_Iteration");
63 //=============================================================================
64 //=============================================================================
66 //=============================================================================
67 //=============================================================================
68 void HOMARD_Iteration::SetName( const char* Name )
70 _Name = std::string( Name );
72 //=============================================================================
73 std::string HOMARD_Iteration::GetName() const
77 //=============================================================================
78 std::string HOMARD_Iteration::GetDumpPython() const
80 if (_IterParent == "") return std::string(" ") ; // Pas de creation explicite de iteration 0";
82 MESSAGE (". Ecriture de l iteration " << _Name );
83 std::ostringstream aScript;
84 aScript << "\n# Creation of the iteration " << _Name << "\n";
87 aScript << "\t" << _Name << " = " << _NomCas << ".NextIteration(\"" << _Name << "\")\n";
91 aScript << "\t" << _Name << " = " << _IterParent << ".NextIteration(\"" << _Name << "\")\n";
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";
106 if ( ( _TimeStep != -1 ) and ( _Rank != -1 ) ) {
107 aScript << "\t" << _Name << ".SetTimeStepRank( " << _TimeStep << ", " << _Rank << " )\n";
112 // MESSAGE (".. Hypothese " << _NomHypo );
113 aScript << "\t" << _Name << ".AssociateHypo(\"" << _NomHypo << "\")\n";
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 );
119 return aScript.str();
121 //=============================================================================
122 //=============================================================================
124 //=============================================================================
125 //=============================================================================
126 void HOMARD_Iteration::SetDirNameLoc( const char* NomDir )
128 _NomDir = std::string( NomDir );
130 //=============================================================================
131 std::string HOMARD_Iteration::GetDirNameLoc() const
135 //=============================================================================
136 void HOMARD_Iteration::SetNumber( int NumIter )
140 //=============================================================================
141 int HOMARD_Iteration::GetNumber() const
145 //=============================================================================
146 void HOMARD_Iteration::SetState( int etat )
150 //=============================================================================
151 int HOMARD_Iteration::GetState() const
155 //=============================================================================
156 void HOMARD_Iteration::SetMeshName( const char* NomMesh )
158 _NomMesh = std::string( NomMesh );
160 //=============================================================================
161 std::string HOMARD_Iteration::GetMeshName() const
165 //=============================================================================
166 void HOMARD_Iteration::SetMeshFile( const char* MeshFile )
168 _MeshFile = std::string( MeshFile );
170 //=============================================================================
171 std::string HOMARD_Iteration::GetMeshFile() const
175 //=============================================================================
176 void HOMARD_Iteration::SetFieldFile( const char* FieldFile )
178 _FieldFile = std::string( FieldFile );
180 //=============================================================================
181 std::string HOMARD_Iteration::GetFieldFile() const
185 //=============================================================================
186 void HOMARD_Iteration::SetTimeStepRank( int TimeStep, int Rank )
188 _TimeStep = TimeStep;
191 //=============================================================================
192 void HOMARD_Iteration::SetTimeStepRankLast()
196 //=============================================================================
197 int HOMARD_Iteration::GetTimeStep() const
201 //=============================================================================
202 int HOMARD_Iteration::GetRank() const
206 //=============================================================================
207 void HOMARD_Iteration::SetLogFile( const char* LogFile )
209 _LogFile = std::string( LogFile );
211 //=============================================================================
212 std::string HOMARD_Iteration::GetLogFile() const
216 //=============================================================================
217 void HOMARD_Iteration::SetFileInfo( const char* FileInfo )
219 _FileInfo = std::string( FileInfo );
221 //=============================================================================
222 std::string HOMARD_Iteration::GetFileInfo() const
226 //=============================================================================
227 //=============================================================================
228 // Liens avec les autres iterations
229 //=============================================================================
230 //=============================================================================
231 void HOMARD_Iteration::LinkNextIteration( const char* NomIteration )
233 _mesIterFilles.push_back( std::string( NomIteration ) );
235 //=============================================================================
236 void HOMARD_Iteration::UnLinkNextIteration( const char* NomIteration )
238 std::list<std::string>::iterator it = find( _mesIterFilles.begin(), _mesIterFilles.end(), NomIteration ) ;
239 if ( it != _mesIterFilles.end() )
241 MESSAGE ("Dans UnLinkNextIteration pour " << NomIteration) ;
242 _mesIterFilles.erase( it ) ;
245 //=============================================================================
246 void HOMARD_Iteration::UnLinkNextIterations()
248 _mesIterFilles.clear();
250 //=============================================================================
251 const std::list<std::string>& HOMARD_Iteration::GetIterations() const
253 return _mesIterFilles;
255 //=============================================================================
256 void HOMARD_Iteration::SetIterParentName( const char* IterParent )
258 _IterParent = IterParent;
260 //=============================================================================
261 std::string HOMARD_Iteration::GetIterParentName() const
265 //=============================================================================
266 //=============================================================================
267 // Liens avec les autres structures
268 //=============================================================================
269 //=============================================================================
270 void HOMARD_Iteration::SetCaseName( const char* NomCas )
272 _NomCas = std::string( NomCas );
274 //=============================================================================
275 std::string HOMARD_Iteration::GetCaseName() const
279 //=============================================================================
280 void HOMARD_Iteration::SetHypoName( const char* NomHypo )
282 _NomHypo = std::string( NomHypo );
284 //=============================================================================
285 std::string HOMARD_Iteration::GetHypoName() const