Salome HOME
136228c1e2356e3319d652c4f8135e0f8962fa25
[modules/homard.git] / src / HOMARD_I / HOMARD_Iteration_i.cxx
1 // Copyright (C) 2011-2013  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Remarques :
20 // L'ordre de description des fonctions est le meme dans tous les fichiers
21 // HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx :
22 // 1. Les generalites : Name, Delete, DumpPython, Dump, Restore
23 // 2. Les caracteristiques
24 // 3. Le lien avec les autres structures
25 //
26 // Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier
27 //
28
29 #include "HOMARD_Iteration_i.hxx"
30 #include "HOMARD_Gen_i.hxx"
31 #include "HOMARD_Iteration.hxx"
32 #include "HOMARD_DriverTools.hxx"
33
34 #include "SALOMEDS_Tool.hxx"
35
36 #include "utilities.h"
37
38 //=============================================================================
39 /*!
40  *  standard constructor
41  */
42 //=============================================================================
43 HOMARD_Iteration_i::HOMARD_Iteration_i()
44 {
45   MESSAGE( "Default constructor, not for use" );
46   ASSERT( 0 );
47 }
48 //=============================================================================
49 /*!
50  *  standard constructor
51  */
52 //=============================================================================
53 HOMARD_Iteration_i::HOMARD_Iteration_i( CORBA::ORB_ptr orb,
54                                         HOMARD::HOMARD_Gen_var engine )
55 {
56   MESSAGE("constructor");
57   _gen_i = engine;
58   _orb = orb;
59   myHomardIteration = new ::HOMARD_Iteration();
60   ASSERT( myHomardIteration );
61 }
62 //=============================================================================
63 /*!
64  *  standard destructor
65  */
66 //=============================================================================
67 HOMARD_Iteration_i::~HOMARD_Iteration_i()
68 {
69 }
70 //=============================================================================
71 //=============================================================================
72 // Generalites
73 //=============================================================================
74 //=============================================================================
75 void HOMARD_Iteration_i::SetName( const char* Name )
76 {
77   ASSERT( myHomardIteration );
78   myHomardIteration->SetName( Name );
79 }
80 //=============================================================================
81 char* HOMARD_Iteration_i::GetName()
82 {
83   ASSERT( myHomardIteration );
84   return CORBA::string_dup( myHomardIteration->GetName().c_str() );
85 }
86 //=============================================================================
87 CORBA::Long  HOMARD_Iteration_i::Delete( CORBA::Long Option )
88 {
89   ASSERT( myHomardIteration );
90   char* IterName = GetName() ;
91   MESSAGE ( "Delete : destruction de l'iteration " << IterName << ", Option = " << Option );
92   return _gen_i->DeleteIteration(IterName, Option) ;
93 }
94 //=============================================================================
95 char* HOMARD_Iteration_i::GetDumpPython()
96 {
97   ASSERT( myHomardIteration );
98   return CORBA::string_dup( myHomardIteration->GetDumpPython().c_str() );
99 }
100 //=============================================================================
101 std::string HOMARD_Iteration_i::Dump() const
102 {
103   return HOMARD::Dump( *myHomardIteration );
104 }
105 //=============================================================================
106 bool HOMARD_Iteration_i::Restore( const std::string& stream )
107 {
108   return HOMARD::Restore( *myHomardIteration, stream );
109 }
110 //=============================================================================
111 //=============================================================================
112 // Caracteristiques
113 //=============================================================================
114 //=============================================================================
115 void HOMARD_Iteration_i::SetDirNameLoc( const char* NomDir )
116 {
117   ASSERT( myHomardIteration );
118   myHomardIteration->SetDirNameLoc( NomDir );
119 }
120 //=============================================================================
121 char* HOMARD_Iteration_i::GetDirNameLoc()
122 {
123   ASSERT( myHomardIteration );
124   return CORBA::string_dup( myHomardIteration->GetDirNameLoc().c_str() );
125 }
126 //=============================================================================
127 char* HOMARD_Iteration_i::GetDirName()
128 {
129   ASSERT( myHomardIteration );
130   std::string casename = myHomardIteration->GetCaseName() ;
131   HOMARD::HOMARD_Cas_ptr caseiter = _gen_i->GetCase(casename.c_str()) ;
132   std::string dirnamecase = caseiter->GetDirName() ;
133   std::string dirname = dirnamecase + "/" +  GetDirNameLoc() ;
134   return CORBA::string_dup( dirname.c_str() );
135 }
136 //=============================================================================
137 void HOMARD_Iteration_i::SetNumber( CORBA::Long NumIter )
138 {
139   ASSERT( myHomardIteration );
140   myHomardIteration->SetNumber( NumIter );
141 }
142 //=============================================================================
143 CORBA::Long HOMARD_Iteration_i::GetNumber()
144 {
145   ASSERT( myHomardIteration );
146   return  myHomardIteration->GetNumber() ;
147 }
148 //=============================================================================
149 void HOMARD_Iteration_i::SetState( CORBA::Long Etat )
150 {
151   ASSERT( myHomardIteration );
152   myHomardIteration->SetState( Etat );
153 }
154 //=============================================================================
155 CORBA::Long HOMARD_Iteration_i::GetState()
156 {
157   ASSERT( myHomardIteration );
158   return myHomardIteration->GetState() ;
159 }
160 //=============================================================================
161 void HOMARD_Iteration_i::SetMeshName( const char* NomMesh )
162 {
163   ASSERT( myHomardIteration );
164   myHomardIteration->SetMeshName( NomMesh );
165 }
166 //=============================================================================
167 char* HOMARD_Iteration_i::GetMeshName()
168 {
169   ASSERT( myHomardIteration );
170   return CORBA::string_dup( myHomardIteration->GetMeshName().c_str() );
171 }
172 //=============================================================================
173 void HOMARD_Iteration_i::SetMeshFile( const char* MeshFile )
174 {
175   ASSERT( myHomardIteration );
176   myHomardIteration->SetMeshFile( MeshFile );
177 }
178 //=============================================================================
179 char* HOMARD_Iteration_i::GetMeshFile()
180 {
181   ASSERT( myHomardIteration );
182   return CORBA::string_dup( myHomardIteration->GetMeshFile().c_str() );
183 }
184 //=============================================================================
185 void HOMARD_Iteration_i::SetFieldFile( const char* FieldFile )
186 {
187   ASSERT( myHomardIteration );
188   myHomardIteration->SetFieldFile( FieldFile );
189 }
190 //=============================================================================
191 char* HOMARD_Iteration_i::GetFieldFile()
192 {
193   ASSERT( myHomardIteration );
194   return CORBA::string_dup( myHomardIteration->GetFieldFile().c_str() );
195 }
196 //=============================================================================
197 void HOMARD_Iteration_i::SetTimeStepRank( CORBA::Long TimeStep, CORBA::Long Rank )
198 {
199   ASSERT( myHomardIteration );
200   myHomardIteration->SetTimeStepRank( TimeStep, Rank );
201 }
202 //=============================================================================
203 void HOMARD_Iteration_i::SetTimeStepRankLast()
204 {
205   ASSERT( myHomardIteration );
206   myHomardIteration->SetTimeStepRankLast();
207 }
208 //=============================================================================
209 CORBA::Long HOMARD_Iteration_i::GetTimeStep()
210 {
211   ASSERT( myHomardIteration );
212   return  CORBA::Long( myHomardIteration->GetTimeStep() );
213 }
214 //=============================================================================
215 CORBA::Long HOMARD_Iteration_i::GetRank()
216 {
217   ASSERT( myHomardIteration );
218   return  CORBA::Long( myHomardIteration->GetRank() );
219 }
220 //=============================================================================
221 void HOMARD_Iteration_i::SetLogFile( const char* LogFile )
222 {
223   ASSERT( myHomardIteration );
224   myHomardIteration->SetLogFile( LogFile );
225 }
226 //=============================================================================
227 char* HOMARD_Iteration_i::GetLogFile()
228 {
229   ASSERT( myHomardIteration );
230   return CORBA::string_dup( myHomardIteration->GetLogFile().c_str() );
231 }
232 //=============================================================================
233 CORBA::Long HOMARD_Iteration_i::Compute(CORBA::Long etatMenage, CORBA::Long Option)
234 {
235   MESSAGE ( "Compute : calcul d'une iteration"<<", Option = "<<Option );
236   ASSERT( myHomardIteration );
237 //
238 // Nom de l'iteration
239   char* IterName = GetName() ;
240   CORBA::Long modeHOMARD = 1 ;
241   CORBA::Long Option1 = 1 ;
242   MESSAGE ( "Compute : calcul de l'teration " << IterName );
243   return _gen_i->Compute(IterName, etatMenage, modeHOMARD, Option1, Option) ;
244 }
245 //=============================================================================
246 void HOMARD_Iteration_i::MeshInfo(CORBA::Long Qual, CORBA::Long Diam, CORBA::Long Conn, CORBA::Long Tail, CORBA::Long Inte)
247 {
248   MESSAGE ( "MeshInfo : information sur le maillage associe a une iteration" );
249   ASSERT( myHomardIteration );
250 //
251   int Option = 1 ;
252   MeshInfoOption( Qual, Diam, Conn, Tail, Inte, Option ) ;
253 //
254   return ;
255 }
256 //=============================================================================
257 void HOMARD_Iteration_i::MeshInfoOption(CORBA::Long Qual, CORBA::Long Diam, CORBA::Long Conn, CORBA::Long Tail, CORBA::Long Inte, CORBA::Long Option)
258 {
259   MESSAGE ( "MeshInfoOption : information sur le maillage associe a une iteration" );
260   ASSERT( myHomardIteration );
261 //
262 // Nom de l'iteration
263   char* IterName = GetName() ;
264   CORBA::Long etatMenage = -1 ;
265   CORBA::Long modeHOMARD = 7 ;
266   if ( Qual != 0 ) { modeHOMARD = modeHOMARD*5 ; }
267   if ( Diam != 0 ) { modeHOMARD = modeHOMARD*19 ; }
268   if ( Conn != 0 ) { modeHOMARD = modeHOMARD*11 ; }
269   if ( Tail != 0 ) { modeHOMARD = modeHOMARD*13 ; }
270   if ( Inte != 0 ) { modeHOMARD = modeHOMARD*3 ; }
271   MESSAGE ( "MeshInfoOption : information sur le maillage de l'iteration " << IterName );
272   CORBA::Long Option2 = 1 ;
273   CORBA::Long codret = _gen_i->Compute(IterName, etatMenage, modeHOMARD, Option, Option2) ;
274   MESSAGE ( "MeshInfoOption : codret = " << codret );
275 //
276   return ;
277 }
278 //=============================================================================
279 void HOMARD_Iteration_i::SetFileInfo( const char* FileInfo )
280 {
281   ASSERT( myHomardIteration );
282   myHomardIteration->SetFileInfo( FileInfo );
283 }
284 //=============================================================================
285 char* HOMARD_Iteration_i::GetFileInfo()
286 {
287   ASSERT( myHomardIteration );
288   return CORBA::string_dup( myHomardIteration->GetFileInfo().c_str() );
289 }
290 //=============================================================================
291 //=============================================================================
292 // Liens avec les autres iterations
293 //=============================================================================
294 //=============================================================================
295 HOMARD::HOMARD_Iteration_ptr HOMARD_Iteration_i::NextIteration( const char* IterName )
296 {
297 // Nom de l'iteration parent
298   char* NomIterParent = GetName() ;
299   MESSAGE ( "NextIteration : creation de l'iteration " << IterName << " comme fille de " << NomIterParent );
300   return _gen_i->CreateIteration(IterName, NomIterParent) ;
301 }
302 //=============================================================================
303 void HOMARD_Iteration_i::LinkNextIteration( const char* NomIteration )
304 {
305   ASSERT( myHomardIteration );
306   myHomardIteration->LinkNextIteration( NomIteration );
307 }
308 //=============================================================================
309 void HOMARD_Iteration_i::UnLinkNextIteration( const char* NomIteration )
310 {
311   ASSERT( myHomardIteration );
312   myHomardIteration->UnLinkNextIteration( NomIteration );
313 }
314 //=============================================================================
315 HOMARD::listeIterFilles* HOMARD_Iteration_i::GetIterations()
316 {
317   ASSERT( myHomardIteration );
318   const std::list<std::string>& maListe = myHomardIteration->GetIterations();
319   HOMARD::listeIterFilles_var aResult = new HOMARD::listeIterFilles;
320   aResult->length( maListe.size() );
321   std::list<std::string>::const_iterator it;
322   int i = 0;
323   for ( it = maListe.begin(); it != maListe.end(); it++ )
324   {
325     aResult[i++] = CORBA::string_dup( (*it).c_str() );
326   }
327   return aResult._retn();
328 }
329 //=============================================================================
330 void HOMARD_Iteration_i::SetIterParentName( const char* NomIterParent )
331 {
332   ASSERT( myHomardIteration );
333   myHomardIteration->SetIterParentName( NomIterParent );
334 }
335 //=============================================================================
336 char* HOMARD_Iteration_i::GetIterParentName()
337 {
338   ASSERT( myHomardIteration );
339   return CORBA::string_dup( myHomardIteration->GetIterParentName().c_str() );
340 }
341 //=============================================================================
342 HOMARD::HOMARD_Iteration_ptr HOMARD_Iteration_i::GetIterParent()
343 {
344 // Nom de l'iteration parent
345   char* NomIterParent = GetIterParentName() ;
346   MESSAGE ( "GetIterParent : NomIterParent = " << NomIterParent );
347   return _gen_i->GetIteration(NomIterParent) ;
348 }
349 //=============================================================================
350 //=============================================================================
351 // Liens avec les autres structures
352 //=============================================================================
353 //=============================================================================
354 void HOMARD_Iteration_i::SetCaseName( const char* NomCas )
355 {
356   ASSERT( myHomardIteration );
357   myHomardIteration->SetCaseName( NomCas );
358 }
359 //=============================================================================
360 char* HOMARD_Iteration_i::GetCaseName()
361 {
362   ASSERT( myHomardIteration );
363   return CORBA::string_dup( myHomardIteration->GetCaseName().c_str() );
364 }
365 //=============================================================================
366 void HOMARD_Iteration_i::AssociateHypo( const char* NomHypo )
367 {
368   ASSERT( myHomardIteration );
369 //
370 // Nom de l'iteration
371   char* IterName = GetName() ;
372   MESSAGE ( ". IterName = " << IterName );
373   return _gen_i->AssociateIterHypo(IterName, NomHypo) ;
374 }
375 //=============================================================================
376 void HOMARD_Iteration_i::SetHypoName( const char* NomHypo )
377 {
378   ASSERT( myHomardIteration );
379   myHomardIteration->SetHypoName( NomHypo );
380 }
381 //=============================================================================
382 char* HOMARD_Iteration_i::GetHypoName()
383 {
384   ASSERT( myHomardIteration );
385   return CORBA::string_dup( myHomardIteration->GetHypoName().c_str() );
386 }