Salome HOME
c65ad8237711790efbd52cf2174486a2555eb992
[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 != -1 ) and ( _Rank != -1 ) ) {
102       aScript << "\t" << _Name << ".SetTimeStepRank( " << _TimeStep << ", " << _Rank << " )\n";
103     }
104   }
105
106 //   MESSAGE (".. Hypothese " << _NomHypo );
107   aScript << "\t" << _Name << ".AssociateHypo(\"" << _NomHypo << "\")\n";
108
109   if (_Etat == true)
110   {
111      aScript << "\tcodret = " <<_Name << ".Compute(1)\n";
112   }
113   else
114   {
115      aScript << "\t#codret = " <<_Name << ".Compute(1)\n";
116   }
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::SetEtat( bool etat )
147 {
148   _Etat = etat;
149 }
150 //=============================================================================
151 bool HOMARD_Iteration::GetEtat() 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 int HOMARD_Iteration::GetTimeStep() const
193 {
194   return _TimeStep;
195 }
196 //=============================================================================
197 int HOMARD_Iteration::GetRank() const
198 {
199   return _Rank;
200 }
201 //=============================================================================
202 void HOMARD_Iteration::SetMessFile( const char* MessFile )
203 {
204   _MessFile = std::string( MessFile );
205 }
206 //=============================================================================
207 std::string HOMARD_Iteration::GetMessFile() const
208 {
209   return _MessFile;
210 }
211 //=============================================================================
212 //=============================================================================
213 // Liens avec les autres iterations
214 //=============================================================================
215 //=============================================================================
216 void HOMARD_Iteration::LinkNextIteration( const char* NomIteration )
217 {
218   _mesIterFilles.push_back( std::string( NomIteration ) );
219 }
220 //=============================================================================
221 void HOMARD_Iteration::UnLinkNextIteration( const char* NomIteration )
222 {
223   std::list<std::string>::iterator it = find( _mesIterFilles.begin(), _mesIterFilles.end(), NomIteration ) ;
224   if ( it != _mesIterFilles.end() )
225   {
226     MESSAGE ("Dans UnLinkNextIteration pour " << NomIteration) ;
227     _mesIterFilles.erase( it ) ;
228   }
229 }
230 //=============================================================================
231 void HOMARD_Iteration::UnLinkNextIterations()
232 {
233   _mesIterFilles.clear();
234 }
235 //=============================================================================
236 const std::list<std::string>& HOMARD_Iteration::GetIterations() const
237 {
238   return _mesIterFilles;
239 }
240 //=============================================================================
241 void HOMARD_Iteration::SetIterParentName( const char* IterParent )
242 {
243   _IterParent = IterParent;
244 }
245 //=============================================================================
246 std::string HOMARD_Iteration::GetIterParentName() const
247 {
248   return _IterParent;
249 }
250 //=============================================================================
251 //=============================================================================
252 // Liens avec les autres structures
253 //=============================================================================
254 //=============================================================================
255 void HOMARD_Iteration::SetCaseName( const char* NomCas )
256 {
257   _NomCas = std::string( NomCas );
258 }
259 //=============================================================================
260 std::string HOMARD_Iteration::GetCaseName() const
261 {
262   return _NomCas;
263 }
264 //=============================================================================
265 void HOMARD_Iteration::SetHypoName( const char* NomHypo )
266 {
267   _NomHypo = std::string( NomHypo );
268 }
269 //=============================================================================
270 std::string HOMARD_Iteration::GetHypoName() const
271 {
272   return _NomHypo;
273 }