1 // HOMARD HOMARD : implementation of HOMARD idl descriptions
3 // Copyright (C) 2011-2012 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( "" )
51 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";
117 aScript << "\tcodret = " <<_Name << ".Compute(1)\n";
121 aScript << "\t#codret = " <<_Name << ".Compute(1)\n";
123 // MESSAGE (". Fin de l ecriture de l iteration " << _Name );
125 return aScript.str();
127 //=============================================================================
128 //=============================================================================
130 //=============================================================================
131 //=============================================================================
132 void HOMARD_Iteration::SetDirName( const char* NomDir )
134 _NomDir = std::string( NomDir );
136 //=============================================================================
137 std::string HOMARD_Iteration::GetDirName() const
141 //=============================================================================
142 void HOMARD_Iteration::SetNumber( int NumIter )
146 //=============================================================================
147 int HOMARD_Iteration::GetNumber() const
151 //=============================================================================
152 void HOMARD_Iteration::SetEtat( bool etat )
156 //=============================================================================
157 bool HOMARD_Iteration::GetEtat() const
161 //=============================================================================
162 void HOMARD_Iteration::SetMeshName( const char* NomMesh )
164 _NomMesh = std::string( NomMesh );
166 //=============================================================================
167 std::string HOMARD_Iteration::GetMeshName() const
171 //=============================================================================
172 void HOMARD_Iteration::SetMeshFile( const char* MeshFile )
174 _MeshFile = std::string( MeshFile );
176 //=============================================================================
177 std::string HOMARD_Iteration::GetMeshFile() const
181 //=============================================================================
182 void HOMARD_Iteration::SetFieldFile( const char* FieldFile )
184 _FieldFile = std::string( FieldFile );
186 //=============================================================================
187 std::string HOMARD_Iteration::GetFieldFile() const
191 //=============================================================================
192 void HOMARD_Iteration::SetTimeStepRank( int TimeStep, int Rank )
194 _TimeStep = TimeStep;
197 //=============================================================================
198 void HOMARD_Iteration::SetTimeStepRankLast()
202 //=============================================================================
203 int HOMARD_Iteration::GetTimeStep() const
207 //=============================================================================
208 int HOMARD_Iteration::GetRank() const
212 //=============================================================================
213 void HOMARD_Iteration::SetMessFile( const char* MessFile )
215 _MessFile = std::string( MessFile );
217 //=============================================================================
218 std::string HOMARD_Iteration::GetMessFile() const
222 //=============================================================================
223 //=============================================================================
224 // Liens avec les autres iterations
225 //=============================================================================
226 //=============================================================================
227 void HOMARD_Iteration::LinkNextIteration( const char* NomIteration )
229 _mesIterFilles.push_back( std::string( NomIteration ) );
231 //=============================================================================
232 void HOMARD_Iteration::UnLinkNextIteration( const char* NomIteration )
234 std::list<std::string>::iterator it = find( _mesIterFilles.begin(), _mesIterFilles.end(), NomIteration ) ;
235 if ( it != _mesIterFilles.end() )
237 MESSAGE ("Dans UnLinkNextIteration pour " << NomIteration) ;
238 _mesIterFilles.erase( it ) ;
241 //=============================================================================
242 void HOMARD_Iteration::UnLinkNextIterations()
244 _mesIterFilles.clear();
246 //=============================================================================
247 const std::list<std::string>& HOMARD_Iteration::GetIterations() const
249 return _mesIterFilles;
251 //=============================================================================
252 void HOMARD_Iteration::SetIterParentName( const char* IterParent )
254 _IterParent = IterParent;
256 //=============================================================================
257 std::string HOMARD_Iteration::GetIterParentName() const
261 //=============================================================================
262 //=============================================================================
263 // Liens avec les autres structures
264 //=============================================================================
265 //=============================================================================
266 void HOMARD_Iteration::SetCaseName( const char* NomCas )
268 _NomCas = std::string( NomCas );
270 //=============================================================================
271 std::string HOMARD_Iteration::GetCaseName() const
275 //=============================================================================
276 void HOMARD_Iteration::SetHypoName( const char* NomHypo )
278 _NomHypo = std::string( NomHypo );
280 //=============================================================================
281 std::string HOMARD_Iteration::GetHypoName() const