Salome HOME
Call FrontTrack via its python interface
[modules/smesh.git] / src / SMESH / SMESH_Homard.cxx
1 // SMESH HOMARD : implementation of SMESHHOMARD idl descriptions
2 //
3 // Copyright (C) 2011-2021  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, or (at your option) any later version.
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
22 #include "SMESH_Homard.hxx"
23
24 #include <Utils_SALOME_Exception.hxx>
25 #include <utilities.h>
26
27 #include <iostream>
28 #include <sstream>
29 #include <cstdlib>
30 #include <sys/stat.h>
31
32 #ifndef WIN32
33 #include <unistd.h>
34 #else
35 #include <direct.h>
36 #endif
37
38 namespace SMESHHOMARDImpl
39 {
40
41   std::string SEPARATOR = "|" ;
42
43   /*!
44     \brief Read next chunk of data from the string
45     \internal
46
47     The function tries to read next chunk of the data from the input string \a str.
48     The parameter \a start specifies the start position of next chunk. If the operation
49     read the chunk successfully, after its completion this parameter will refer to the
50     start position of the next chunk. The function returns resulting chunk as a string.
51     The status of the operation is returned via \a ok parameter.
52
53     \param str source data stream string
54     \param start start position to get next chunk
55     \param ok in this variable the status of the chunk reading operation is returned
56     \return next chunk read from the string
57   */
58   static std::string getNextChunk( const std::string& str, std::string::size_type& start, bool& ok )
59   {
60     std::string chunk = "";
61     ok = false;
62     if ( start <= str.size() ) {
63       std::string::size_type end = str.find( separator(), start );
64       chunk = str.substr( start, end == std::string::npos ? std::string::npos : end-start );
65       start = end == std::string::npos ? str.size()+1 : end + separator().size();
66       ok = true;
67     }
68     return chunk;
69   }
70
71   /*!
72     \brief Get persistence signature
73     \param type persistence entity type
74     \return persistence signature
75   */
76   std::string GetSignature( SignatureType type )
77   {
78     std::string signature = "";
79     switch ( type ) {
80     case Case:       signature = "CASE"; break;
81     case Zone:       signature = "ZONE"; break;
82     case Hypothesis: signature = "HYPO"; break;
83     case Iteration:  signature = "ITER"; break;
84     case Boundary:   signature = "BOUNDARY"; break;
85     default: break;
86     }
87     signature += separator();
88     return signature;
89   }
90
91   /*!
92     \brief Get data separator
93     \return string that is used to separate data entities in the stream
94   */
95   std::string separator()
96   {
97     return SEPARATOR ;
98   }
99
100 // =======================
101 // 1.1. Case
102 // =======================
103   /*!
104     \brief Dump case to the string
105     \param cas case being dumped
106     \return string representation of the case
107   */
108   std::string Dump( const HOMARD_Cas& cas )
109   {
110     std::stringstream os;
111     std::string saux ;
112     // ...
113     MESSAGE( ". Sauvegarde du cas "<<cas.GetName());
114     os << cas.GetName();
115     os << separator() << cas.GetDirName();
116     os << separator() << cas.GetConfType();
117
118     std::vector<double> coor = cas.GetBoundingBox();
119     os << separator() << coor.size();
120     for ( unsigned int i = 0; i < coor.size(); i++ )
121           os << separator() << coor[i];
122
123     std::list<std::string> ListString = cas.GetIterations();
124     os << separator() << ListString.size();
125     std::list<std::string>::const_iterator it;
126     for ( it = ListString.begin(); it != ListString.end(); ++it )
127           os << separator() << *it;
128
129     ListString = cas.GetGroups();
130     os << separator() << ListString.size();
131     for ( it = ListString.begin(); it != ListString.end(); ++it )
132          os << separator() << *it;
133     ListString = cas.GetBoundaryGroup();
134     os << separator() << ListString.size();
135     for ( it = ListString.begin(); it != ListString.end(); ++it )
136          os << separator() << *it;
137
138     os << separator() << 0; //cas.GetPyram()
139
140     saux = os.str();
141 //     MESSAGE( ". Fin avec "<<saux);
142     return saux ;
143   }
144 //
145 // ==============
146 // 1.2. Iteration
147 // ==============
148 //
149   /*!
150     \brief Dump iteration to the string
151     \param iteration iteration being dumped
152     \return string representation of the iteration
153   */
154   std::string Dump( const HOMARD_Iteration& iteration )
155   {
156     std::stringstream os;
157     std::string saux ;
158     // ...
159     MESSAGE( ". Sauvegarde de l'iteration "<<iteration.GetName());
160     os << iteration.GetName();
161     os << separator() << iteration.GetState();
162     os << separator() << iteration.GetNumber();
163     os << separator() << iteration.GetMeshFile();
164     os << separator() << iteration.GetLogFile();
165     os << separator() << iteration.GetMeshName();
166     os << separator() << iteration.GetFieldFile();
167     os << separator() << iteration.GetTimeStep();
168     os << separator() << iteration.GetRank();
169     os << separator() << iteration.GetIterParentName();
170     //
171     std::list<std::string> ListString = iteration.GetIterations();
172     os << separator() << ListString.size();
173     std::list<std::string>::const_iterator it;
174     for ( it = ListString.begin(); it != ListString.end(); ++it )
175       os << separator() << *it;
176
177     os << separator() << iteration.GetHypoName();
178     os << separator() << iteration.GetCaseName();
179     os << separator() << iteration.GetDirNameLoc();
180
181     saux = os.str();
182 //     MESSAGE( ". Fin avec "<<saux);
183     return saux ;
184   }
185 //
186 // ==============
187 // 1.3. hypothese
188 // ==============
189   /*!
190     \brief Dump hypothesis to the string
191     \param hypothesis hypothesis being dumped
192     \return string representation of the hypothesis
193   */
194   std::string Dump( const HOMARD_Hypothesis& hypothesis )
195   {
196     std::stringstream os;
197     std::string saux ;
198     // ...
199     MESSAGE( ". Sauvegarde de l'hypothese "<<hypothesis.GetName());
200     os << hypothesis.GetName();
201     os << separator() << hypothesis.GetCaseCreation();
202     os << separator() << hypothesis.GetAdapType();
203     os << separator() << hypothesis.GetRefinType();
204     os << separator() << hypothesis.GetUnRefType();
205     os << separator() << hypothesis.GetFieldName();
206     os << separator() << hypothesis.GetRefinThrType();
207     os << separator() << hypothesis.GetThreshR();
208     os << separator() << hypothesis.GetUnRefThrType();
209     os << separator() << hypothesis.GetThreshC();
210     os << separator() << hypothesis.GetUseField();
211     os << separator() << hypothesis.GetUseComp();
212     os << separator() << hypothesis.GetTypeFieldInterp();
213
214     std::list<std::string> ListString = hypothesis.GetIterations();
215     std::list<std::string>::const_iterator it;
216     os << separator() << ListString.size();
217     for ( it = ListString.begin(); it != ListString.end(); ++it )
218          os << separator() << *it;
219
220     ListString = hypothesis.GetZones();
221     os << separator() << ListString.size();
222     for ( it = ListString.begin(); it != ListString.end(); ++it )
223           os << separator() << *it;
224
225     ListString = hypothesis.GetComps();
226     os << separator() << ListString.size();
227     for ( it = ListString.begin(); it != ListString.end(); ++it )
228          os << separator() << *it;
229
230     ListString = hypothesis.GetGroups();
231     os << separator() << ListString.size();
232     for ( it = ListString.begin(); it != ListString.end(); ++it )
233           os << separator() << *it;
234
235     ListString = hypothesis.GetFieldInterps();
236     os << separator() << ListString.size();
237     for ( it = ListString.begin(); it != ListString.end(); ++it )
238           os << separator() << *it;
239
240     os << separator() << hypothesis.GetNivMax();
241     os << separator() << hypothesis.GetDiamMin();
242     os << separator() << hypothesis.GetAdapInit();
243     os << separator() << hypothesis.GetExtraOutput();
244
245     saux = os.str();
246 //     MESSAGE( ". Fin avec "<<saux);
247     return saux ;
248   }
249 //
250 // ==============================
251 // 1.5. Archivage d'une frontiere
252 // ==============================
253
254   /*!
255     \brief Dump boundary to the string
256     \param boundary boundary being dumped
257     \return string representation of the boundary
258   */
259   std::string Dump( const HOMARD_Boundary& boundary )
260   {
261     std::stringstream os;
262     std::string saux ;
263     MESSAGE( ". Sauvegarde de la frontiere "<<boundary.GetName());
264
265     int BoundaryType = boundary.GetType() ;
266
267     os << boundary.GetName() ;
268     os << separator() << BoundaryType ;
269     os << separator() << boundary.GetCaseCreation() ;
270
271     if ( BoundaryType == -1 )
272     {
273       os << separator() << boundary.GetDataFile();
274     }
275     else if ( BoundaryType == 0 )
276     {
277       os << separator() << boundary.GetMeshName();
278       os << separator() << boundary.GetDataFile();
279     }
280     else {
281       std::vector<double> coor = boundary.GetCoords() ;
282       for ( unsigned int i = 0; i < coor.size(); i++ )
283             os << separator() << coor[i];
284       std::vector<double> limit = boundary.GetLimit();
285       for ( unsigned int i = 0; i < limit.size(); i++ )
286             os << separator() << limit[i];
287     }
288
289     std::list<std::string> ListString = boundary.GetGroups();
290     std::list<std::string>::const_iterator it;
291     os << separator() << ListString.size();
292     for ( it = ListString.begin(); it != ListString.end(); ++it )
293           os << separator() << *it;
294
295     saux = os.str();
296 //     MESSAGE( ". Fin avec "<<saux);
297     return saux ;
298   }
299
300 //
301 // 2. Restauration des objets
302 // ==========================
303 // 2.1. Case
304 // ==========================
305 //
306   /*!
307     \brief Restore case from the string
308     \param cas case being restored
309     \param stream string representation of the case
310     \return \c true if case is correctly restored or \c false otherwise
311   */
312   bool Restore( HOMARD_Cas& cas, const std::string& stream )
313   {
314     MESSAGE( ". Restoration du cas ");
315     std::string::size_type start = 0;
316     std::string chunk, chunkNext;
317     bool ok;
318     // ...
319     chunk = getNextChunk( stream, start, ok );
320     if ( !ok ) return false;
321     cas.SetName( chunk.c_str() );
322
323     chunk = getNextChunk( stream, start, ok );
324     if ( !ok ) return false;
325     cas.SetDirName( chunk.c_str() );
326
327     chunk = getNextChunk( stream, start, ok );
328     if ( !ok ) return false;
329     cas.SetConfType( atoi( chunk.c_str() ) );
330
331     chunk = getNextChunk( stream, start, ok );
332     if ( !ok ) return false;
333
334     int size = atoi( chunk.c_str() );
335     std::vector<double> boite;
336     boite.resize( size );
337     for ( int i = 0; i < size; i++ ) {
338       chunk = getNextChunk( stream, start, ok );
339       if ( !ok ) return false;
340       boite[i] = strtod( chunk.c_str(), 0 );
341     }
342     cas.SetBoundingBox( boite );
343
344     chunk = getNextChunk( stream, start, ok );
345     if ( !ok ) return false;
346
347     size = atoi( chunk.c_str() );
348     for ( int i = 0; i < size; i++ ) {
349       chunk = getNextChunk( stream, start, ok );
350       if ( !ok ) return false;
351       cas.AddIteration( chunk.c_str() );
352     }
353
354     chunk = getNextChunk( stream, start, ok );
355     if ( !ok ) return false;
356     size = atoi( chunk.c_str() );
357     for ( int i = 0; i < size; i++ )
358     {
359       chunk = getNextChunk( stream, start, ok );
360       if ( !ok ) return false;
361       cas.AddGroup( chunk.c_str() );
362     }
363
364     chunk = getNextChunk( stream, start, ok );
365     if ( !ok ) return false;
366     size = atoi( chunk.c_str() );
367     for ( int i = 0; i < size; i++ ) {
368       chunk = getNextChunk( stream, start, ok );
369       if ( !ok ) return false;
370       i++;
371       chunkNext = getNextChunk( stream, start, ok );
372       if ( !ok ) return false;
373       cas.AddBoundaryGroup( chunk.c_str(), chunkNext.c_str() );
374     }
375
376     chunk = getNextChunk( stream, start, ok );
377     if ( !ok ) return false;
378     //cas.SetPyram( atoi( chunk.c_str() ) );
379
380     return true;
381   }
382 //
383 // ==============
384 // 2.2. Iteration
385 // ==============
386   /*!
387     \brief Restore iteration from the string
388     \param iteration iteration being restored
389     \param stream string representation of the iteration
390     \return \c true if iteration is correctly restored or \c false otherwise
391   */
392   bool Restore( HOMARD_Iteration& iteration, const std::string& stream )
393   {
394     std::string::size_type start = 0;
395     std::string chunk;
396     bool ok;
397     chunk = getNextChunk( stream, start, ok );
398     if ( !ok ) return false;
399
400     iteration.SetName( chunk.c_str() );
401     chunk = getNextChunk( stream, start, ok );
402     if ( !ok ) return false;
403     iteration.SetState( atoi( chunk.c_str() ) );
404     chunk = getNextChunk( stream, start, ok );
405     if ( !ok ) return false;
406     iteration.SetNumber( atoi( chunk.c_str() ) );
407     chunk = getNextChunk( stream, start, ok );
408     if ( !ok ) return false;
409     iteration.SetMeshFile( chunk.c_str() );
410     chunk = getNextChunk( stream, start, ok );
411     if ( !ok ) return false;
412     iteration.SetLogFile( chunk.c_str() );
413     chunk = getNextChunk( stream, start, ok );
414     if ( !ok ) return false;
415     iteration.SetMeshName( chunk.c_str() );
416     chunk = getNextChunk( stream, start, ok );
417     if ( !ok ) return false;
418     iteration.SetFieldFile( chunk.c_str() );
419     // .
420     int timestep, rank;
421     chunk = getNextChunk( stream, start, ok );
422     if ( !ok ) return false;
423     timestep = atoi( chunk.c_str() );
424     chunk = getNextChunk( stream, start, ok );
425     if ( !ok ) return false;
426     rank = atoi( chunk.c_str() );
427     iteration.SetTimeStepRank( timestep, rank );
428     chunk = getNextChunk( stream, start, ok );
429     if ( !ok ) return false;
430     iteration.SetIterParentName( chunk.c_str() );
431     //
432     chunk = getNextChunk( stream, start, ok );
433     if ( !ok ) return false;
434     int size = atoi( chunk.c_str() );
435     for ( int i = 0; i < size; i++ ) {
436       chunk = getNextChunk( stream, start, ok );
437       if ( !ok ) return false;
438       iteration.LinkNextIteration( chunk.c_str() );
439     }
440     //
441     chunk = getNextChunk( stream, start, ok );
442     if ( !ok ) return false;
443     iteration.SetHypoName( chunk.c_str() );
444     chunk = getNextChunk( stream, start, ok );
445     if ( !ok ) return false;
446     iteration.SetCaseName( chunk.c_str() );
447     chunk = getNextChunk( stream, start, ok );
448     if ( !ok ) return false;
449     iteration.SetDirNameLoc( chunk.c_str() );
450     return true;
451   }
452
453 //
454 // ==============
455 // 2.3. hypothese
456 // ==============
457   /*!
458     \brief Restore hypothesis from the string
459     \param hypothesis hypothesis being restored
460     \param stream string representation of the hypothesis
461     \return \c true if hypothesis is correctly restored or \c false otherwise
462   */
463   bool Restore( HOMARD_Hypothesis& hypothesis, const std::string& stream )
464   {
465     std::string::size_type start = 0;
466     std::string chunk, chunkNext;
467     bool ok;
468
469     chunk = getNextChunk( stream, start, ok );
470     if ( !ok ) return false;
471     hypothesis.SetName( chunk.c_str() );
472
473     chunk = getNextChunk( stream, start, ok );
474     if ( !ok ) return false;
475     hypothesis.SetCaseCreation( chunk.c_str() );
476
477     chunk = getNextChunk( stream, start, ok );
478     if ( !ok ) return false;
479     hypothesis.SetAdapType( atoi( chunk.c_str() ) );
480
481     chunk = getNextChunk( stream, start, ok );
482     if ( !ok ) return false;
483     int typeraff = atoi( chunk.c_str() );
484     chunk = getNextChunk( stream, start, ok );
485     if ( !ok ) return false;
486     int typedera = atoi( chunk.c_str() );
487     hypothesis.SetRefinTypeDera( typeraff, typedera );
488
489     chunk = getNextChunk( stream, start, ok );
490     if ( !ok ) return false;
491     hypothesis.SetField( chunk.c_str() );
492
493     chunk = getNextChunk( stream, start, ok );
494     if ( !ok ) return false;
495     int typethr = atoi( chunk.c_str() );
496     chunk = getNextChunk( stream, start, ok );
497     if ( !ok ) return false;
498     double threshr = strtod( chunk.c_str(), 0 );
499     hypothesis.SetRefinThr( typethr, threshr );
500
501     chunk = getNextChunk( stream, start, ok );
502     if ( !ok ) return false;
503     int typethc = atoi( chunk.c_str() );
504     chunk = getNextChunk( stream, start, ok );
505     if ( !ok ) return false;
506     double threshc = strtod( chunk.c_str(), 0 );
507     hypothesis.SetUnRefThr( typethc, threshc );
508
509     chunk = getNextChunk( stream, start, ok );
510     if ( !ok ) return false;
511     hypothesis.SetUseField(atoi(chunk.c_str()));
512
513     chunk = getNextChunk( stream, start, ok );
514     if ( !ok ) return false;
515     hypothesis.SetUseComp(atoi(chunk.c_str()));
516
517     chunk = getNextChunk( stream, start, ok );
518     if ( !ok ) return false;
519     hypothesis.SetTypeFieldInterp(atoi(chunk.c_str()));
520
521     chunk = getNextChunk( stream, start, ok );
522     if ( !ok ) return false;
523     int size = atoi( chunk.c_str() );
524     for ( int i = 0; i < size; i++ ) {
525       chunk = getNextChunk( stream, start, ok );
526       if ( !ok ) return false;
527       hypothesis.LinkIteration( chunk.c_str() );
528     }
529
530     chunk = getNextChunk( stream, start, ok );
531     if ( !ok ) return false;
532     size = atoi( chunk.c_str() );
533     for ( int i = 0; i < size; i++ ) {
534       chunk = getNextChunk( stream, start, ok );
535       if ( !ok ) return false;
536       i++;
537       chunkNext = getNextChunk( stream, start, ok );
538       int typeuse = atoi( chunkNext.c_str() );
539       if ( !ok ) return false;
540       hypothesis.AddZone( chunk.c_str(), typeuse );
541     }
542
543     chunk = getNextChunk( stream, start, ok );
544     if ( !ok ) return false;
545     size = atoi( chunk.c_str() );
546     for ( int i = 0; i < size; i++ ) {
547       chunk = getNextChunk( stream, start, ok );
548       if ( !ok ) return false;
549       hypothesis.AddComp( chunk.c_str() );
550     }
551
552     chunk = getNextChunk( stream, start, ok );
553     if ( !ok ) return false;
554     size = atoi( chunk.c_str() );
555     for ( int i = 0; i < size; i++ ) {
556       chunk = getNextChunk( stream, start, ok );
557       if ( !ok ) return false;
558       hypothesis.AddGroup( chunk.c_str() );
559     }
560
561     chunk = getNextChunk( stream, start, ok );
562     if ( !ok ) return false;
563     size = atoi( chunk.c_str() );
564     for ( int i = 0; i < size; i++ ) {
565       chunk = getNextChunk( stream, start, ok );
566       if ( !ok ) return false;
567       i++;
568       chunkNext = getNextChunk( stream, start, ok );
569       int TypeInterp = atoi( chunkNext.c_str() );
570       if ( !ok ) return false;
571       hypothesis.AddFieldInterpType( chunk.c_str(), TypeInterp );
572     }
573
574     chunk = getNextChunk( stream, start, ok );
575     if ( !ok ) return false;
576     hypothesis.SetNivMax( atoi( chunk.c_str() ) );
577
578     chunk = getNextChunk( stream, start, ok );
579     if ( !ok ) return false;
580     hypothesis.SetDiamMin( strtod( chunk.c_str(), 0 ) );
581
582     chunk = getNextChunk( stream, start, ok );
583     if ( !ok ) return false;
584     hypothesis.SetAdapInit( strtod( chunk.c_str(), 0 ) );
585
586     chunk = getNextChunk( stream, start, ok );
587     if ( !ok ) return false;
588     hypothesis.SetExtraOutput( strtod( chunk.c_str(), 0 ) );
589
590     return true;
591   }
592
593 //
594 // =================================
595 // 2.5. Restauration d'une frontiere
596 // =================================
597
598   /*!
599     \brief Restore boundary from the string
600     \param boundary boundary being restored
601     \param stream string representation of the boundary
602     \return \c true if the boundary is correctly restored or \c false otherwise
603   */
604   bool Restore( HOMARD_Boundary& boundary, const std::string& stream )
605   {
606     std::string::size_type start = 0;
607     std::string chunk;
608     bool ok;
609
610     chunk = getNextChunk( stream, start, ok );
611     if ( !ok ) return false;
612     boundary.SetName( chunk.c_str() );
613
614     chunk = getNextChunk( stream, start, ok );
615     if ( !ok ) return false;
616     int BoundaryType = atoi( chunk.c_str() ) ;
617     boundary.SetType( BoundaryType );
618
619     chunk = getNextChunk( stream, start, ok );
620     if ( !ok ) return false;
621     boundary.SetCaseCreation( chunk.c_str() );
622
623     // Si analytique, les coordonnees des frontieres : le nombre depend du type
624     // Si discret, le maillage
625     // Si CAO, la géométrie
626     int lgcoords ;
627     if ( BoundaryType == -1 ) { lgcoords = -1 ; }
628     else if ( BoundaryType == 1 ) { lgcoords = 7 ; }
629     else if ( BoundaryType == 2 ) { lgcoords = 4 ; }
630     else { lgcoords = 0 ; }
631 //
632     if ( lgcoords == -1 )
633     {
634       chunk = getNextChunk( stream, start, ok );
635       if ( !ok ) return false;
636       boundary.SetDataFile( chunk.c_str() );
637     }
638     else if ( lgcoords == 0 )
639     {
640       chunk = getNextChunk( stream, start, ok );
641       if ( !ok ) return false;
642       boundary.SetMeshName( chunk.c_str() );
643
644       chunk = getNextChunk( stream, start, ok );
645       if ( !ok ) return false;
646       boundary.SetDataFile( chunk.c_str() );
647     }
648     else
649     { std::vector<double> coords;
650       coords.resize( lgcoords );
651       for ( int i = 0; i < lgcoords; i++ ) {
652         chunk = getNextChunk( stream, start, ok );
653         if ( !ok ) return false;
654         coords[i] = strtod( chunk.c_str(), 0 );
655       }
656       if ( BoundaryType == 1 )
657       { boundary.SetCylinder(coords[0],coords[1],coords[2],coords[3],coords[4],coords[5],coords[6]); }
658       else if ( BoundaryType == 2 )
659       { boundary.SetSphere( coords[0], coords[1], coords[2], coords[3]); }
660       else if ( BoundaryType == 3 )
661       { boundary.SetConeA( coords[0], coords[1], coords[2], coords[3], coords[4], coords[5], coords[6]); }
662       else if ( BoundaryType == 4 )
663       { boundary.SetConeR( coords[0], coords[1], coords[2], coords[3], coords[4], coords[5], coords[6], coords[7]); }
664       // Remarque : la taille de coords est suffisante pour les limites
665       for ( int i = 0; i < 3; i++ ) {
666         chunk = getNextChunk( stream, start, ok );
667         if ( !ok ) return false;
668         coords[i] = strtod( chunk.c_str(), 0 );
669       }
670       boundary.SetLimit( coords[0], coords[1], coords[2]);
671     }
672     // Les groupes
673     chunk = getNextChunk( stream, start, ok );
674     if ( !ok ) return false;
675     int size = atoi( chunk.c_str() );
676     for ( int i = 0; i < size; i++ ) {
677       chunk = getNextChunk( stream, start, ok );
678       if ( !ok ) return false;
679       boundary.AddGroup( chunk.c_str() );
680     }
681
682     return true;
683   }
684
685 //=============================================================================
686 /*!
687  *  default constructor:
688  */
689 //=============================================================================
690 HOMARD_Boundary::HOMARD_Boundary():
691   _Name( "" ),_Type( 1 ),
692   _Xmin( 0 ), _Xmax( 0 ), _Ymin( 0 ), _Ymax( 0 ), _Zmin( 0 ), _Zmax( 0 ),
693   _Xaxe( 0 ), _Yaxe( 0 ), _Zaxe( 0 ),
694   _Xcentre( 0 ), _Ycentre( 0 ), _Zcentre( 0 ), _rayon( 0 ),
695   _Xincr( 0 ), _Yincr( 0 ), _Zincr( 0 )
696 {
697   MESSAGE("HOMARD_Boundary");
698 }
699
700 //=============================================================================
701 HOMARD_Boundary::~HOMARD_Boundary()
702 {
703   MESSAGE("~HOMARD_Boundary");
704 }
705 //=============================================================================
706 //=============================================================================
707 // Generalites
708 //=============================================================================
709 //=============================================================================
710 void HOMARD_Boundary::SetName( const char* Name )
711 {
712   _Name = std::string( Name );
713 }
714 //=============================================================================
715 std::string HOMARD_Boundary::GetName() const
716 {
717   return _Name;
718 }
719 //=============================================================================
720 std::string HOMARD_Boundary::GetDumpPython() const
721 {
722   std::ostringstream aScript;
723   switch (_Type) {
724     case -1:
725     {
726       aScript << _Name << " = smeshhomard.CreateBoundaryCAO(\"" << _Name << "\", ";
727       aScript << "\"" << _DataFile << "\")\n";
728       break ;
729     }
730     case 0:
731     {
732       aScript << _Name << " = smeshhomard.CreateBoundaryDi(\"" << _Name << "\", ";
733       aScript << "\"" << _MeshName << "\", ";
734       aScript << "\"" << _DataFile << "\")\n";
735       break ;
736     }
737     case 1:
738     {
739       aScript << _Name << " = smeshhomard.CreateBoundaryCylinder(\"" << _Name << "\", ";
740       aScript << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _rayon << ")\n";
741       break ;
742     }
743     case 2:
744     {
745       aScript << _Name << " = smeshhomard.CreateBoundarySphere(\"" << _Name << "\", ";
746       aScript << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _rayon << ")\n";
747       break ;
748     }
749     case 3:
750     {
751       aScript << _Name << " = smeshhomard.CreateBoundaryConeA(\"" << _Name << "\", ";
752       aScript << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _Angle << ", " << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ")\n";
753       break ;
754     }
755     case 4:
756     {
757       aScript << _Name << " = smeshhomard.CreateBoundaryConeR(\"" << _Name << "\", ";
758       aScript << _Xcentre1 << ", " << _Ycentre1 << ", " << _Zcentre1 << ", " << _Rayon1 << ", " << _Xcentre2 << ", " << _Ycentre2 << ", " << _Zcentre2 << ", " << _Rayon2 << ")\n";
759       break ;
760     }
761     case 5:
762     {
763       aScript << _Name << " = smeshhomard.CreateBoundaryTorus(\"" << _Name << "\", ";
764       aScript << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _Rayon1 << ", " << _Rayon2 << ")\n";
765       break ;
766     }
767   }
768
769   return aScript.str();
770 }
771 //=============================================================================
772 //=============================================================================
773 // Caracteristiques
774 //=============================================================================
775 //=============================================================================
776 void HOMARD_Boundary::SetType( int Type )
777 {
778   _Type = Type;
779 }
780 //=============================================================================
781 int HOMARD_Boundary::GetType() const
782 {
783   return _Type;
784 }
785 //=============================================================================
786 void HOMARD_Boundary::SetMeshName( const char* MeshName )
787 {
788   _MeshName = std::string( MeshName );
789 }
790 //=============================================================================
791 std::string HOMARD_Boundary::GetMeshName() const
792 {
793   return _MeshName;
794 }
795 //=============================================================================
796 void HOMARD_Boundary::SetDataFile( const char* DataFile )
797 {
798   _DataFile = std::string( DataFile );
799 }
800 //=============================================================================
801 std::string HOMARD_Boundary::GetDataFile() const
802 {
803   return _DataFile;
804 }
805 //=======================================================================================
806 void HOMARD_Boundary::SetCylinder( double X0, double X1, double X2,
807                                    double X3, double X4, double X5, double X6 )
808 {
809   _Xcentre = X0; _Ycentre = X1; _Zcentre = X2;
810   _Xaxe = X3; _Yaxe = X4; _Zaxe = X5;
811   _rayon = X6;
812 }
813 //======================================================================
814 void HOMARD_Boundary::SetSphere( double X0, double X1, double X2, double X3 )
815 {
816   _Xcentre = X0; _Ycentre = X1; _Zcentre = X2;
817   _rayon = X3;
818 }
819 //======================================================================
820 void HOMARD_Boundary::SetConeR( double Xcentre1, double Ycentre1, double Zcentre1, double Rayon1,
821                                 double Xcentre2, double Ycentre2, double Zcentre2, double Rayon2)
822 {
823   _Xcentre1 = Xcentre1; _Ycentre1 = Ycentre1; _Zcentre1 = Zcentre1;
824   _Rayon1 = Rayon1;
825   _Xcentre2 = Xcentre2; _Ycentre2 = Ycentre2; _Zcentre2 = Zcentre2;
826   _Rayon2 = Rayon2;
827 }
828 //======================================================================
829 void HOMARD_Boundary::SetConeA( double Xaxe, double Yaxe, double Zaxe, double Angle,
830                                 double Xcentre, double Ycentre, double Zcentre)
831 {
832   _Xaxe = Xaxe; _Yaxe = Yaxe; _Zaxe = Zaxe;
833   _Angle = Angle;
834   _Xcentre = Xcentre; _Ycentre = Ycentre; _Zcentre = Zcentre;
835 }
836 //=======================================================================================
837 void HOMARD_Boundary::SetTorus( double X0, double X1, double X2,
838                                 double X3, double X4, double X5, double X6, double X7 )
839 {
840   _Xcentre = X0; _Ycentre = X1; _Zcentre = X2;
841   _Xaxe = X3; _Yaxe = X4; _Zaxe = X5;
842   _Rayon1 = X6;
843   _Rayon2 = X7;
844 }
845 //=======================================================================================
846 std::vector<double> HOMARD_Boundary::GetCoords() const
847 {
848   std::vector<double> mesCoor;
849 //
850   switch (_Type)
851   {
852 //  Cylindre
853     case 1:
854     {
855       mesCoor.push_back( _Xcentre );
856       mesCoor.push_back( _Ycentre );
857       mesCoor.push_back( _Zcentre );
858       mesCoor.push_back( _Xaxe );
859       mesCoor.push_back( _Yaxe );
860       mesCoor.push_back( _Zaxe );
861       mesCoor.push_back( _rayon );
862       break ;
863     }
864 //  Sphere
865     case 2:
866     {
867       mesCoor.push_back( _Xcentre );
868       mesCoor.push_back( _Ycentre );
869       mesCoor.push_back( _Zcentre );
870       mesCoor.push_back( _rayon );
871       break ;
872     }
873 //  Cone defini par un axe et un angle
874     case 3:
875     {
876       mesCoor.push_back( _Xaxe );
877       mesCoor.push_back( _Yaxe );
878       mesCoor.push_back( _Zaxe );
879       mesCoor.push_back( _Angle );
880       mesCoor.push_back( _Xcentre );
881       mesCoor.push_back( _Ycentre );
882       mesCoor.push_back( _Zcentre );
883       break ;
884     }
885 //  Cone defini par les 2 rayons
886     case 4:
887     {
888       mesCoor.push_back( _Xcentre1 );
889       mesCoor.push_back( _Ycentre1 );
890       mesCoor.push_back( _Zcentre1 );
891       mesCoor.push_back( _Rayon1 );
892       mesCoor.push_back( _Xcentre2 );
893       mesCoor.push_back( _Ycentre2 );
894       mesCoor.push_back( _Zcentre2 );
895       mesCoor.push_back( _Rayon2 );
896       break ;
897     }
898 //  Tore
899     case 5:
900     {
901       mesCoor.push_back( _Xcentre );
902       mesCoor.push_back( _Ycentre );
903       mesCoor.push_back( _Zcentre );
904       mesCoor.push_back( _Xaxe );
905       mesCoor.push_back( _Yaxe );
906       mesCoor.push_back( _Zaxe );
907       mesCoor.push_back( _Rayon1 );
908       mesCoor.push_back( _Rayon2 );
909       break ;
910     }
911     VERIFICATION( (_Type>=1) && (_Type<=5) ) ;
912   }
913   return mesCoor;
914 }
915 //======================================================================
916 void HOMARD_Boundary::SetLimit( double X0, double X1, double X2 )
917 {
918   _Xincr = X0; _Yincr = X1; _Zincr = X2;
919 }
920 //=======================================================================================
921 std::vector<double> HOMARD_Boundary::GetLimit() const
922 {
923   std::vector<double> mesLimit;
924   mesLimit.push_back( _Xincr );
925   mesLimit.push_back( _Yincr );
926   mesLimit.push_back( _Zincr );
927   return mesLimit;
928 }
929 //=============================================================================
930 void HOMARD_Boundary::AddGroup( const char* Group)
931 {
932   _ListGroupSelected.push_back(Group);
933 }
934 //=============================================================================
935 void HOMARD_Boundary::SetGroups( const std::list<std::string>& ListGroup )
936 {
937   _ListGroupSelected.clear();
938   std::list<std::string>::const_iterator it = ListGroup.begin();
939   while(it != ListGroup.end())
940     _ListGroupSelected.push_back((*it++));
941 }
942 //=============================================================================
943 const std::list<std::string>& HOMARD_Boundary::GetGroups() const
944 {
945   return _ListGroupSelected;
946 }
947 //=============================================================================
948 //=============================================================================
949 // Liens avec les autres structures
950 //=============================================================================
951 //=============================================================================
952 void HOMARD_Boundary::SetCaseCreation( const char* NomCasCreation )
953 {
954   _NomCasCreation = std::string( NomCasCreation );
955 }
956 //=============================================================================
957 std::string HOMARD_Boundary::GetCaseCreation() const
958 {
959   return _NomCasCreation;
960 }
961 //=============================================================================
962
963 //=============================================================================
964 /*!
965  *  default constructor:
966  *  Par defaut, l'adaptation est conforme, sans suivi de frontiere
967  */
968 //=============================================================================
969 HOMARD_Cas::HOMARD_Cas():
970   _Name(""), _NomDir("/tmp"), _ConfType(0)
971 {
972   MESSAGE("HOMARD_Cas");
973 }
974 //=============================================================================
975 HOMARD_Cas::~HOMARD_Cas()
976 //=============================================================================
977 {
978   MESSAGE("~HOMARD_Cas");
979 }
980 //=============================================================================
981 //=============================================================================
982 // Generalites
983 //=============================================================================
984 //=============================================================================
985 void HOMARD_Cas::SetName( const char* Name )
986 {
987   _Name = std::string( Name );
988 }
989 //=============================================================================
990 std::string HOMARD_Cas::GetName() const
991 {
992   return _Name;
993 }
994 //=============================================================================
995 std::string HOMARD_Cas::GetDumpPython() const
996 {
997   std::ostringstream aScript;
998   //aScript << _Name << ".SetDirName(\"" << _NomDir << "\")\n";
999   aScript << _Name << ".SetConfType(" << _ConfType << ")\n";
1000   // Suivi de frontieres
1001   std::list<std::string>::const_iterator it = _ListBoundaryGroup.begin();
1002   while (it != _ListBoundaryGroup.end()) {
1003     aScript << _Name << ".AddBoundaryGroup(\"" << *it << "\", \"";
1004     it++;
1005     aScript << *it << "\")\n";
1006     it++;
1007   }
1008
1009   return aScript.str();
1010 }
1011 //=============================================================================
1012 //=============================================================================
1013 // Caracteristiques
1014 //=============================================================================
1015 //=============================================================================
1016 int HOMARD_Cas::SetDirName( const char* NomDir )
1017 {
1018 //   MESSAGE("SetDirName,  NomDir : "<<NomDir);
1019 //   MESSAGE("SetDirName, _NomDir : "<<_NomDir);
1020   int erreur = 0 ;
1021   // On vérifie qu'aucun calcul n'a eu lieu pour ce cas
1022 //   MESSAGE("SetDirName, _ListIter.size() : "<<_ListIter.size());
1023   if ( _ListIter.size() > 1 ) { erreur = 1 ; }
1024   // Creation
1025   if ( CHDIR(NomDir) == 0 )
1026   { _NomDir = std::string( NomDir ); }
1027   else
1028   {
1029
1030 #ifndef WIN32
1031     if ( mkdir(NomDir, S_IRWXU|S_IRGRP|S_IXGRP) == 0 )
1032 #else
1033     if ( _mkdir(NomDir) == 0 )
1034 #endif
1035     {
1036       if ( CHDIR(NomDir) == 0 ) { _NomDir = std::string( NomDir ); }
1037       else                      { erreur = 2 ; }
1038     }
1039     else { erreur = 2 ; }
1040   };
1041   return erreur ;
1042 }
1043 //=============================================================================
1044 std::string HOMARD_Cas::GetDirName() const
1045 {
1046   return _NomDir;
1047 }
1048 //=============================================================================
1049 int HOMARD_Cas::GetNumberofIter()
1050 {
1051   return _ListIter.size();
1052 }
1053 //
1054 // Le type de conformite ou non conformite
1055 //
1056 //=============================================================================
1057 void HOMARD_Cas::SetConfType( int Conftype )
1058 {
1059 //   VERIFICATION( (Conftype>=-2) && (Conftype<=3) );
1060   _ConfType = Conftype;
1061 }
1062 //=============================================================================
1063 const int HOMARD_Cas::GetConfType() const
1064 {
1065   return _ConfType;
1066 }
1067 //
1068 // La boite englobante
1069 //
1070 //=============================================================================
1071 void HOMARD_Cas::SetBoundingBox( const std::vector<double>& extremas )
1072 {
1073   _Boite.clear();
1074   _Boite.resize( extremas.size() );
1075   for ( unsigned int i = 0; i < extremas.size(); i++ )
1076     _Boite[i] = extremas[i];
1077 }
1078 //=============================================================================
1079 const std::vector<double>& HOMARD_Cas::GetBoundingBox() const
1080 {
1081   return _Boite;
1082 }
1083 //
1084 // Les groupes
1085 //
1086 //=============================================================================
1087 void HOMARD_Cas::AddGroup( const char* Group )
1088 {
1089   _ListGroup.push_back(Group);
1090 }
1091 //=============================================================================
1092 void HOMARD_Cas::SetGroups( const std::list<std::string>& ListGroup )
1093 {
1094   _ListGroup.clear();
1095   std::list<std::string>::const_iterator it = ListGroup.begin();
1096   while(it != ListGroup.end())
1097   {
1098     _ListGroup.push_back((*it++));
1099   }
1100 }
1101 //=============================================================================
1102 const std::list<std::string>& HOMARD_Cas::GetGroups() const
1103 {
1104   return _ListGroup;
1105 }
1106 //=============================================================================
1107 void HOMARD_Cas::SupprGroups()
1108 {
1109   _ListGroup.clear();
1110 }
1111 //
1112 // Les frontieres
1113 //
1114 //=============================================================================
1115 void HOMARD_Cas::AddBoundary( const char* Boundary )
1116 {
1117 //   MESSAGE ( ". HOMARD_Cas::AddBoundary : Boundary = " << Boundary );
1118   const char* Group = "";
1119   AddBoundaryGroup( Boundary, Group );
1120 }
1121 //=============================================================================
1122 void HOMARD_Cas::AddBoundaryGroup( const char* Boundary, const char* Group )
1123 {
1124 //   MESSAGE ( ". HOMARD_Cas::AddBoundaryGroup : Boundary = " << Boundary );
1125 //   MESSAGE ( ". HOMARD_Cas::AddBoundaryGroup : Group = " << Group );
1126   _ListBoundaryGroup.push_back( Boundary );
1127   _ListBoundaryGroup.push_back( Group    );
1128 }
1129 //=============================================================================
1130 const std::list<std::string>& HOMARD_Cas::GetBoundaryGroup() const
1131 {
1132   return _ListBoundaryGroup;
1133 }
1134 //=============================================================================
1135 void HOMARD_Cas::SupprBoundaryGroup()
1136 {
1137   _ListBoundaryGroup.clear();
1138 }
1139 //=============================================================================
1140 //=============================================================================
1141 // Liens avec les autres structures
1142 //=============================================================================
1143 //=============================================================================
1144 std::string HOMARD_Cas::GetIter0Name() const
1145 {
1146 // Par construction de la liste, l'iteration a ete mise en tete.
1147   return (*(_ListIter.begin()));
1148 }
1149 //=============================================================================
1150 void HOMARD_Cas::AddIteration( const char* NomIteration )
1151 {
1152   _ListIter.push_back( std::string( NomIteration ) );
1153 }
1154 //=============================================================================
1155 const std::list<std::string>& HOMARD_Cas::GetIterations() const
1156 {
1157   return _ListIter;
1158 }
1159 //=============================================================================
1160 void HOMARD_Cas::SupprIterations()
1161 {
1162   _ListIter.clear();
1163 }
1164
1165 //=============================================================================
1166 //=============================================================================
1167 HomardDriver::HomardDriver(const std::string siter, const std::string siterp1):
1168   _HOMARD_Exec( "" ), _NomDir( "" ), _NomFichierConfBase( "HOMARD.Configuration" ),
1169   _NomFichierConf( "" ), _NomFichierDonn( "" ), _siter( "" ), _siterp1( "" ),
1170   _Texte( "" ), _bLu( false )
1171 {
1172   MESSAGE("siter = "<<siter<<", siterp1 = "<<siterp1);
1173   // Le repertoire ou se trouve l'executable HOMARD
1174   std::string dir ;
1175   // TODO?
1176   if ( getenv("HOMARD_ROOT_DIR") != NULL ) { dir = getenv("HOMARD_ROOT_DIR") ; }
1177   dir += "/bin/salome";
1178   MESSAGE("dir ="<<dir);
1179   // L'executable HOMARD
1180   std::string executable = "homard";
1181   MESSAGE("executable ="<<executable);
1182   // Memorisation du nom complet de l'executable HOMARD
1183   _HOMARD_Exec = dir + "/" + executable ;
1184   MESSAGE("==> _HOMARD_Exec ="<<_HOMARD_Exec) ;
1185   //
1186   _siter = siter ;
1187   _siterp1 = siterp1 ;
1188 }
1189 //=============================================================================
1190 //=============================================================================
1191 HomardDriver::~HomardDriver()
1192 {
1193 }
1194 //===============================================================================
1195 // A. Generalites
1196 //===============================================================================
1197 void HomardDriver::TexteInit( const std::string DirCompute, const std::string LogFile, const std::string Langue )
1198 {
1199   MESSAGE("TexteInit, DirCompute ="<<DirCompute<<", LogFile ="<<LogFile);
1200 //
1201   _Texte  = "ListeStd \"" + LogFile + "\"\n" ;
1202   _Texte += "RepeTrav \"" + DirCompute + "\"\n" ;
1203   _Texte += "RepeInfo \"" + DirCompute + "\"\n" ;
1204   _Texte += "Langue \"" + Langue + "\"\n" ;
1205 //
1206 }
1207 //===============================================================================
1208 void HomardDriver::TexteAdap()
1209 {
1210   MESSAGE("TexteAdap");
1211
1212   _Texte += "Action   homa\n";
1213   _Texte += "CCAssoci med\n";
1214   _Texte += "ModeHOMA 1\n";
1215   _Texte += "NumeIter " + _siter + "\n";
1216   _modeHOMARD = 1;
1217 }
1218 //===============================================================================
1219 void HomardDriver::TexteInfo( int TypeBila, int NumeIter )
1220 {
1221   MESSAGE("TexteInfo: TypeBila ="<<TypeBila<<", NumeIter ="<<NumeIter);
1222 //
1223   _Texte += "ModeHOMA 2\n" ;
1224   std::stringstream saux1 ;
1225   saux1 << TypeBila ;
1226   std::string saux2 = saux1.str() ;
1227   _Texte += "TypeBila " + saux2 + "\n" ;
1228   if ( NumeIter ==  0 )
1229   {
1230     _Texte += "NumeIter 0\n" ;
1231     _Texte += "Action   info_av\n" ;
1232     _Texte += "CCAssoci med\n" ;
1233   }
1234   else
1235   {
1236     _Texte += "NumeIter " + _siter + "\n" ;
1237     _Texte += "Action   info_ap\n" ;
1238     _Texte += "CCAssoci homard\n" ;
1239   }
1240   _modeHOMARD = 2 ;
1241 //
1242 }
1243 //===============================================================================
1244 void HomardDriver::TexteMajCoords( int NumeIter )
1245 {
1246   MESSAGE("TexteMajCoords: NumeIter ="<<NumeIter);
1247 //
1248   _Texte += "ModeHOMA 5\n" ;
1249   _Texte += "NumeIter " + _siterp1 + "\n" ;
1250   _Texte += "Action   homa\n" ;
1251   _Texte += "CCAssoci med\n" ;
1252   _Texte += "EcriFiHO N_SANS_FRONTIERE\n" ;
1253   _modeHOMARD = 5 ;
1254 //
1255 }
1256 //===============================================================================
1257 // B. Les maillages en entree et en sortie
1258 //===============================================================================
1259 void HomardDriver::TexteMaillage( const std::string NomMesh, const std::string MeshFile, int apres )
1260 {
1261   MESSAGE("TexteMaillage, NomMesh  = "<<NomMesh);
1262   MESSAGE("TexteMaillage, MeshFile = "<<MeshFile);
1263   MESSAGE("TexteMaillage, apres = "<<apres);
1264   std::string saux ;
1265   saux = "P1" ;
1266   if ( apres < 1 ) { saux = "__" ; }
1267
1268   _Texte += "# Maillages Med " + saux + "\n" ;
1269   _Texte += "CCNoMN" + saux + " \"" + NomMesh  + "\"\n" ;
1270   _Texte += "CCMaiN" + saux + " \"" + MeshFile + "\"\n" ;
1271 }
1272
1273 //===============================================================================
1274 void HomardDriver::TexteMaillageHOMARD( const std::string Dir, const std::string liter, int apres )
1275 {
1276   MESSAGE("TexteMaillageHOMARD, Dir ="<<Dir<<", liter ="<<liter<<", apres ="<<apres);
1277   std::string saux ;
1278   if ( apres < 1 ) { saux = "__" ; }
1279   else             { saux = "P1" ; }
1280
1281   _Texte += "# Maillage HOMARD " + liter + "\n" ;
1282   _Texte += "HOMaiN" + saux + " Mai" + liter   + " \"" + Dir + "/maill." + liter   + ".hom.med\"\n" ;
1283 }
1284
1285 //===============================================================================
1286 // C. Le pilotage de l'adaptation
1287 //===============================================================================
1288 void HomardDriver::TexteConfRaffDera( int ConfType, int TypeAdap, int TypeRaff, int TypeDera )
1289 {
1290   MESSAGE("TexteConfRaffDera, ConfType ="<<ConfType);
1291   MESSAGE("TexteConfRaffDera, TypeAdap ="<<TypeAdap<<", TypeRaff ="<<TypeRaff<<", TypeDera ="<<TypeDera);
1292 //
1293 // Type de conformite
1294 //
1295   std::string saux ;
1296   switch (ConfType)
1297   {
1298     case -2: //
1299     {
1300       saux = "NON_CONFORME_1_ARETE" ;
1301       break;
1302     }
1303     case -1: //
1304     {
1305       saux = "CONFORME_BOITES" ;
1306       break;
1307     }
1308     case 0: //
1309     {
1310       saux = "CONFORME" ;
1311       break;
1312     }
1313     case 1: //
1314     {
1315       saux = "NON_CONFORME" ;
1316       break;
1317     }
1318     case 2: //
1319     {
1320       saux = "NON_CONFORME_1_NOEUD" ;
1321       break;
1322     }
1323     case 3: //
1324     {
1325       saux = "NON_CONFORME_INDICATEUR" ;
1326       break;
1327     }
1328   }
1329   _Texte += "# Type de conformite\nTypeConf " + saux + "\n" ;
1330 //
1331 // Type de raffinement/deraffinement
1332 //
1333   if ( TypeAdap == -1 )
1334   {
1335     if ( TypeRaff == 1 )
1336     {
1337       saux = "TypeRaff uniforme\n" ;
1338     }
1339     else
1340     {
1341       saux = "TypeRaff non\n" ;
1342     }
1343     if ( TypeDera == 1 )
1344     {
1345       saux += "TypeDera uniforme" ;
1346     }
1347     else
1348     {
1349       saux += "TypeDera non" ;
1350     }
1351   }
1352   else
1353   {
1354     if ( TypeRaff == 1 )
1355     {
1356       saux = "TypeRaff libre\n" ;
1357     }
1358     else
1359     {
1360       saux = "TypeRaff non\n" ;
1361     }
1362     if ( TypeDera == 1 )
1363     {
1364       saux += "TypeDera libre" ;
1365     }
1366     else
1367     {
1368       saux += "TypeDera non" ;
1369     }
1370   }
1371   _Texte += "# Type de raffinement/deraffinement\n" + saux + "\n" ;
1372 //
1373 //   MESSAGE("A la fin de HomardDriver::TexteConfRaffDera, _Texte ="<<_Texte);
1374 }
1375 //===============================================================================
1376 void HomardDriver::TexteCompo( int NumeComp, const std::string NomCompo)
1377 {
1378   MESSAGE("TexteCompo, NumeComp = "<<NumeComp<<", NomCompo = "<<NomCompo);
1379   _Texte +="CCCoChaI \"" + NomCompo + "\"\n" ;
1380 }
1381 //===============================================================================
1382 void HomardDriver::TexteZone( int NumeZone, int ZoneType, int TypeUse, double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7, double x8 )
1383 {
1384   MESSAGE("TexteZone, NumeZone = "<<NumeZone<<", ZoneType = "<<ZoneType<<", TypeUse = "<<TypeUse);
1385   MESSAGE("TexteZone, coor = "<< x0<<","<<x1<< ","<< x2<< ","<< x3<<","<<x4<<","<<x5<<","<<x6<<","<<x7<<","<<x8);
1386 //
1387   std::string saux, saux2 ;
1388 //
1389 // Type de zones
1390 // On convertit le type de zone au sens du module HOMARD dans Salome, ZoneType, dans le
1391 // type au sens de l'executable HOMARD, ZoneTypeHOMARD
1392 // Attention a mettre le bon signe a ZoneTypeHOMARD :
1393 //    >0 signifie que l'on raffinera les mailles contenues dans la zone,
1394 //    <0 signifie que l'on deraffinera
1395 //
1396   int ZoneTypeHOMARD ;
1397   if ( ZoneType >= 11 && ZoneType <= 13 ) { ZoneTypeHOMARD = 1 ; }
1398   else if ( ZoneType >= 31 && ZoneType <= 33 ) { ZoneTypeHOMARD = 3 ; }
1399   else if ( ZoneType >= 61 && ZoneType <= 63 ) { ZoneTypeHOMARD = 6 ; }
1400   else { ZoneTypeHOMARD = ZoneType ; }
1401 //
1402   if ( TypeUse < 0 ) { ZoneTypeHOMARD = -ZoneTypeHOMARD ; }
1403 //
1404   std::stringstream saux1 ;
1405   saux1 << NumeZone ;
1406   saux = "#\n# Zone numero " + saux1.str() + "\n" ;
1407 //
1408   { std::stringstream saux1 ;
1409     saux1 << NumeZone << " " << ZoneTypeHOMARD ;
1410     saux += "ZoRaType " + saux1.str() + "\n" ;
1411   }
1412 //
1413 // Cas du rectangle
1414 //
1415   if ( ZoneType == 11 ) // Z est constant X Homard <=> X Salome
1416 //                                        Y Homard <=> Y Salome
1417   {
1418     saux += "#Rectangle\n" ;
1419     { std::stringstream saux1 ;
1420       saux1 << NumeZone << " " << x0 ;
1421       saux += "ZoRaXmin " + saux1.str() + "\n" ;
1422     }
1423     { std::stringstream saux1 ;
1424       saux1 << NumeZone << " " << x1 ;
1425       saux += "ZoRaXmax " + saux1.str() + "\n" ;
1426     }
1427     { std::stringstream saux1 ;
1428       saux1 << NumeZone << " " << x2 ;
1429       saux += "ZoRaYmin " + saux1.str() + "\n" ;
1430     }
1431     { std::stringstream saux1 ;
1432       saux1 << NumeZone << " " << x3 ;
1433       saux += "ZoRaYmax " + saux1.str() + "\n" ;
1434     }
1435   }
1436 //
1437   else if ( ZoneType == 12 ) // X est constant X Homard <=> Y Salome
1438 //                                             Y Homard <=> Z Salome
1439   {
1440     saux += "#Rectangle\n" ;
1441     { std::stringstream saux1 ;
1442       saux1 << NumeZone << " " << x2 ;
1443       saux += "ZoRaXmin " + saux1.str() + "\n" ;
1444     }
1445     { std::stringstream saux1 ;
1446       saux1 << NumeZone << " " << x3 ;
1447       saux += "ZoRaXmax " + saux1.str() + "\n" ;
1448     }
1449     { std::stringstream saux1 ;
1450       saux1 << NumeZone << " " << x4 ;
1451       saux += "ZoRaYmin " + saux1.str() + "\n" ;
1452     }
1453     { std::stringstream saux1 ;
1454       saux1 << NumeZone << " " << x5 ;
1455       saux += "ZoRaYmax " + saux1.str() + "\n" ;
1456     }
1457   }
1458 //
1459   else if ( ZoneType == 13 ) // Y est constant X Homard <=> X Salome
1460 //                                             Y Homard <=> Z Salome
1461   {
1462     saux += "#Rectangle\n" ;
1463     { std::stringstream saux1 ;
1464       saux1 << NumeZone << " " << x0 ;
1465       saux += "ZoRaXmin " + saux1.str() + "\n" ;
1466     }
1467     { std::stringstream saux1 ;
1468       saux1 << NumeZone << " " << x1 ;
1469       saux += "ZoRaXmax " + saux1.str() + "\n" ;
1470     }
1471     { std::stringstream saux1 ;
1472       saux1 << NumeZone << " " << x4 ;
1473       saux += "ZoRaYmin " + saux1.str() + "\n" ;
1474     }
1475     { std::stringstream saux1 ;
1476       saux1 << NumeZone << " " << x5 ;
1477       saux += "ZoRaYmax " + saux1.str() + "\n" ;
1478     }
1479   }
1480 //
1481 // Cas du parallelepipede
1482 //
1483   else if ( ZoneType == 2 )
1484   {
1485     saux += "# Boite\n" ;
1486     { std::stringstream saux1 ;
1487       saux1 << NumeZone << " " << x0 ;
1488       saux += "ZoRaXmin " + saux1.str() + "\n" ;
1489     }
1490     { std::stringstream saux1 ;
1491       saux1 << NumeZone << " " << x1 ;
1492       saux += "ZoRaXmax " + saux1.str() + "\n" ;
1493     }
1494     { std::stringstream saux1 ;
1495       saux1 << NumeZone << " " << x2 ;
1496       saux += "ZoRaYmin " + saux1.str() + "\n" ;
1497     }
1498     { std::stringstream saux1 ;
1499       saux1 << NumeZone << " " << x3 ;
1500       saux += "ZoRaYmax " + saux1.str() + "\n" ;
1501     }
1502     { std::stringstream saux1 ;
1503       saux1 << NumeZone << " " << x4 ;
1504       saux += "ZoRaZmin " + saux1.str() + "\n" ;
1505     }
1506     { std::stringstream saux1 ;
1507       saux1 << NumeZone << " " << x5 ;
1508       saux += "ZoRaZmax " + saux1.str() + "\n" ;
1509     }
1510   }
1511 //
1512 // Cas du disque
1513 //
1514   else if ( ZoneType == 31 || ZoneType == 61 )
1515   {
1516     saux += "# Sphere\n" ;
1517     { std::stringstream saux1 ;
1518       saux1 << NumeZone << " " << x0 ;
1519       saux += "ZoRaXCen " + saux1.str() + "\n" ;
1520     }
1521     { std::stringstream saux1 ;
1522       saux1 << NumeZone << " " << x1 ;
1523       saux += "ZoRaYCen " + saux1.str() + "\n" ;
1524     }
1525     { std::stringstream saux1 ;
1526       saux1 << NumeZone << " " << x6 ;
1527       saux2 = saux1.str() ;
1528       if ( ZoneType == 61 ) { saux += "ZoRaRayE " + saux2 + "\n" ; }
1529       else                  { saux += "ZoRaRayo " + saux2 + "\n" ; }
1530     }
1531     if ( ZoneType == 61 )
1532     { std::stringstream saux1 ;
1533       saux1 << NumeZone << " " << x8 ;
1534       saux += "ZoRaRayI " + saux1.str() + "\n" ;
1535     }
1536   }
1537   else if ( ZoneType == 32 || ZoneType == 62 )
1538   {
1539     saux += "# Sphere\n" ;
1540     { std::stringstream saux1 ;
1541       saux1 << NumeZone << " " << x1 ;
1542       saux += "ZoRaXCen " + saux1.str() + "\n" ;
1543     }
1544     { std::stringstream saux1 ;
1545       saux1 << NumeZone << " " << x2 ;
1546       saux += "ZoRaYCen " + saux1.str() + "\n" ;
1547     }
1548     { std::stringstream saux1 ;
1549       saux1 << NumeZone << " " << x6 ;
1550       saux2 = saux1.str() ;
1551       if ( ZoneType == 62 ) { saux += "ZoRaRayE " + saux2 + "\n" ; }
1552       else                  { saux += "ZoRaRayo " + saux2 + "\n" ; }
1553     }
1554     if ( ZoneType == 62 )
1555     { std::stringstream saux1 ;
1556       saux1 << NumeZone << " " << x8 ;
1557       saux += "ZoRaRayI " + saux1.str() + "\n" ;
1558     }
1559   }
1560   else if ( ZoneType == 33 || ZoneType == 63 )
1561   {
1562     saux += "# Sphere\n" ;
1563     { std::stringstream saux1 ;
1564       saux1 << NumeZone << " " << x0 ;
1565       saux += "ZoRaXCen " + saux1.str() + "\n" ;
1566     }
1567     { std::stringstream saux1 ;
1568       saux1 << NumeZone << " " << x2 ;
1569       saux += "ZoRaYCen " + saux1.str() + "\n" ;
1570     }
1571     { std::stringstream saux1 ;
1572       saux1 << NumeZone << " " << x6 ;
1573       saux2 = saux1.str() ;
1574       if ( ZoneType == 63 ) { saux += "ZoRaRayE " + saux2 + "\n" ; }
1575       else                  { saux += "ZoRaRayo " + saux2 + "\n" ; }
1576     }
1577     if ( ZoneType == 63 )
1578     { std::stringstream saux1 ;
1579       saux1 << NumeZone << " " << x8 ;
1580       saux += "ZoRaRayI " + saux1.str() + "\n" ;
1581     }
1582   }
1583 //
1584 // Cas de la sphere
1585 //
1586   else if ( ZoneType == 4 )
1587   {
1588     saux += "# Sphere\n" ;
1589     { std::stringstream saux1 ;
1590       saux1 << NumeZone << " " << x0 ;
1591       saux += "ZoRaXCen " + saux1.str() + "\n" ;
1592     }
1593     { std::stringstream saux1 ;
1594       saux1 << NumeZone << " " << x1 ;
1595       saux += "ZoRaYCen " + saux1.str() + "\n" ;
1596     }
1597     { std::stringstream saux1 ;
1598       saux1 << NumeZone << " " << x2 ;
1599       saux += "ZoRaZCen " + saux1.str() + "\n" ;
1600     }
1601     { std::stringstream saux1 ;
1602       saux1 << NumeZone << " " << x3 ;
1603       saux += "ZoRaRayo " + saux1.str() + "\n" ;
1604     }
1605   }
1606 //
1607 // Cas du cylindre ou du tuyau
1608 //
1609   else if ( ZoneType == 5 || ZoneType == 7 )
1610   {
1611     if ( ZoneType == 5 ) { saux += "# Cylindre\n" ; }
1612     else                 { saux += "# Tuyau\n" ; }
1613     { std::stringstream saux1 ;
1614       saux1 << NumeZone << " " << x0 ;
1615       saux += "ZoRaXBas " + saux1.str() + "\n" ;
1616     }
1617     { std::stringstream saux1 ;
1618       saux1 << NumeZone << " " << x1 ;
1619       saux += "ZoRaYBas " + saux1.str() + "\n" ;
1620     }
1621     { std::stringstream saux1 ;
1622       saux1 << NumeZone << " " << x2 ;
1623       saux += "ZoRaZBas " + saux1.str() + "\n" ;
1624     }
1625     { std::stringstream saux1 ;
1626       saux1 << NumeZone << " " << x3 ;
1627       saux += "ZoRaXAxe " + saux1.str() + "\n" ;
1628     }
1629     { std::stringstream saux1 ;
1630       saux1 << NumeZone << " " << x4 ;
1631       saux += "ZoRaYAxe " + saux1.str() + "\n" ;
1632     }
1633     { std::stringstream saux1 ;
1634       saux1 << NumeZone << " " << x5 ;
1635       saux += "ZoRaZAxe " + saux1.str() + "\n" ;
1636     }
1637     { std::stringstream saux1 ;
1638       saux1 << NumeZone << " " << x6 ;
1639       saux2 = saux1.str() ;
1640      if ( ZoneType == 5 ) { saux += "ZoRaRayo " + saux2 + "\n" ; }
1641      else                 { saux += "ZoRaRayE " + saux2 + "\n" ; }
1642     }
1643     { std::stringstream saux1 ;
1644       saux1 << NumeZone << " " << x7 ;
1645       saux += "ZoRaHaut " + saux1.str() + "\n" ;
1646     }
1647     if ( ZoneType == 7 )
1648     { std::stringstream saux1 ;
1649       saux1 << NumeZone << " " << x8 ;
1650       saux += "ZoRaRayI " + saux1.str() + "\n" ;
1651     }
1652   }
1653 //
1654   _Texte += saux + "#\n" ;
1655 //
1656 //   MESSAGE("A la fin de HomardDriver::TexteZone, _Texte ="<<_Texte);
1657 }
1658 //===============================================================================
1659 void HomardDriver::TexteField( const std::string FieldName, const std::string FieldFile, int TimeStep, int Rank,
1660                int TypeThR, double ThreshR, int TypeThC, double ThreshC,
1661                int UsField, int UsCmpI )
1662 {
1663   MESSAGE("TexteField, FieldName = "<<FieldName<<", FieldFile = "<<FieldFile);
1664   MESSAGE("TexteField, TimeStep = "<<TimeStep<<", Rank = "<<Rank);
1665
1666   std::string saux, saux2 ;
1667 //
1668 //
1669   _Texte += "# Champ d'indicateurs\n" ;
1670   _Texte += "CCIndica \"" + FieldFile  + "\"\n" ;
1671   _Texte += "CCNoChaI \"" + FieldName  + "\"\n" ;
1672
1673 // Cas ou on prend le dernier pas de temps
1674   if ( TimeStep == -2 )
1675   { _Texte += "CCNumPTI Last\n" ; }
1676 // Cas avec pas de temps
1677   else if ( TimeStep >= 0 )
1678   {
1679     {
1680       std::stringstream saux1 ;
1681       saux1 << TimeStep ;
1682       saux2 = saux1.str() ;
1683       _Texte += "CCNumPTI " + saux2  + "\n" ;
1684     }
1685     if ( Rank >= 0 )
1686     {
1687       std::stringstream saux1 ;
1688       saux1 << Rank ;
1689       saux2 = saux1.str() ;
1690       _Texte += "CCNumOrI " + saux2  + "\n" ;
1691     }
1692   }
1693 //
1694   saux = " " ;
1695   if ( TypeThR == 1 )
1696   { saux = "Hau" ; }
1697   if ( TypeThR == 2 )
1698   { saux = "HRe" ; }
1699   if ( TypeThR == 3 )
1700   { saux = "HPE" ; }
1701   if ( TypeThR == 4 )
1702   { saux = "HMS" ; }
1703   if ( saux != " " )
1704   {
1705     std::stringstream saux1 ;
1706     saux1 << ThreshR ;
1707     _Texte += "Seuil" + saux + " " + saux1.str()  + "\n" ;
1708   }
1709 //
1710   saux = " " ;
1711   if ( TypeThC == 1 )
1712   { saux = "Bas" ; }
1713   if ( TypeThC == 2 )
1714   { saux = "BRe" ; }
1715   if ( TypeThC == 3 )
1716   { saux = "BPE" ; }
1717   if ( TypeThC == 4 )
1718   { saux = "BMS" ; }
1719   if ( saux != " " )
1720   {
1721     std::stringstream saux1 ;
1722     saux1 << ThreshC ;
1723     _Texte += "Seuil" + saux + " " + saux1.str()  + "\n" ;
1724   }
1725 //
1726   saux = " " ;
1727   if ( UsField == 0 )
1728   { saux = "MAILLE" ; }
1729   if ( UsField == 1 )
1730   { saux = "SAUT" ; }
1731   if ( saux != " " )
1732   {
1733     _Texte += "CCModeFI " + saux  + "\n" ;
1734   }
1735 //
1736   saux = " " ;
1737   if ( UsCmpI == 0 )
1738   { saux = "L2" ; }
1739   if ( UsCmpI == 1 )
1740   { saux = "INFINI" ; }
1741   if ( UsCmpI == 2 )
1742   { saux = "RELATIF" ; }
1743   if ( saux != " " )
1744   {
1745     _Texte += "CCUsCmpI " + saux  + "\n" ;
1746   }
1747 }
1748 //===============================================================================
1749 void HomardDriver::TexteGroup( const std::string GroupName )
1750 {
1751   MESSAGE("TexteGroup, GroupName = "<<GroupName);
1752 //
1753   _Texte += "CCGroAda \"" + GroupName  + "\"\n" ;
1754 //
1755 }
1756 //===============================================================================
1757 // D. Les frontieres
1758 //===============================================================================
1759 void HomardDriver::TexteBoundaryOption( int BoundaryOption )
1760 {
1761   MESSAGE("TexteBoundaryOption, BoundaryOption = "<<BoundaryOption);
1762 //
1763 // Type de suivi de frontiere
1764 //
1765   std::stringstream saux1 ;
1766   saux1 << BoundaryOption ;
1767   std::string saux = saux1.str() ;
1768   _Texte += "SuivFron " + saux + "\n" ;
1769 //
1770 }//===============================================================================
1771 void HomardDriver::TexteBoundaryCAOGr(  const std::string GroupName )
1772 {
1773   MESSAGE("TexteBoundaryCAOGr, GroupName  = "<<GroupName);
1774 //
1775   _Texte += "GrFroCAO \"" + GroupName + "\"\n" ;
1776 //
1777 }
1778
1779 //===============================================================================
1780 void HomardDriver::TexteBoundaryDi(  const std::string MeshName, const std::string MeshFile )
1781 {
1782   MESSAGE("TexteBoundaryDi, MeshName  = "<<MeshName);
1783   MESSAGE("TexteBoundaryDi, MeshFile  = "<<MeshFile);
1784 //
1785   _Texte += "#\n# Frontiere discrete\n" ;
1786   _Texte += "CCNoMFro \"" + MeshName + "\"\n" ;
1787   _Texte += "CCFronti \"" + MeshFile + "\"\n" ;
1788 //
1789 }
1790 //===============================================================================
1791 void HomardDriver::TexteBoundaryDiGr(  const std::string GroupName )
1792 {
1793   MESSAGE("TexteBoundaryDiGr, GroupName  = "<<GroupName);
1794 //
1795   _Texte += "CCGroFro \"" + GroupName + "\"\n" ;
1796 //
1797 }
1798 //===============================================================================
1799 void HomardDriver::TexteBoundaryAn( const std::string NameBoundary, int NumeBoundary, int BoundaryType, double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7 )
1800 {
1801   MESSAGE("TexteBoundaryAn, NameBoundary = "<<NameBoundary);
1802 //   MESSAGE("TexteBoundaryAn, NumeBoundary = "<<NumeBoundary);
1803   MESSAGE("TexteBoundaryAn, BoundaryType = "<<BoundaryType);
1804 //   MESSAGE("TexteBoundaryAn, coor         = "<< x0<<","<<x1<< ","<< x2<< ","<< x3<<","<<x4<<","<<x5<<","<<x6","<<x7);
1805 //
1806   std::string saux, saux2 ;
1807 //
1808 // Commentaires
1809 //
1810   std::stringstream saux1 ;
1811   saux1 << NumeBoundary ;
1812   saux2 = saux1.str() ;
1813   saux = "#\n# Frontiere numero " + saux2 + "\n" ;
1814   if ( BoundaryType == 1 )
1815   { saux += "# Cylindre\n" ; }
1816   if ( BoundaryType == 2 )
1817   { saux += "# Sphere\n" ; }
1818   if ( BoundaryType == 3 || BoundaryType == 4 )
1819   { saux += "# Cone\n" ; }
1820   if ( BoundaryType == 5 )
1821   { saux += "# Tore\n" ; }
1822 //
1823 // Le nom de la frontiere
1824 //
1825   { std::stringstream saux1 ;
1826     saux1 << NumeBoundary ;
1827     saux += "FANom " + saux1.str() + " \"" + NameBoundary + "\"\n" ;
1828   }
1829 //
1830 // Type de frontiere
1831 //
1832   { std::stringstream saux1 ;
1833     saux1 << NumeBoundary << " " << BoundaryType ;
1834     saux += "FAType " + saux1.str() + "\n" ;
1835   }
1836 //
1837 // Cas du cylindre
1838 //
1839   if ( BoundaryType == 1 )
1840   {
1841     { std::stringstream saux1 ;
1842       saux1 << NumeBoundary << " " << x0 ;
1843       saux2 = saux1.str() ;
1844       saux += "FAXCen " + saux1.str() + "\n" ;
1845     }
1846     { std::stringstream saux1 ;
1847       saux1 << NumeBoundary << " " << x1 ;
1848       saux += "FAYCen " + saux1.str() + "\n" ;
1849     }
1850     { std::stringstream saux1 ;
1851       saux1 << NumeBoundary << " " << x2 ;
1852       saux += "FAZCen " + saux1.str() + "\n" ;
1853     }
1854     { std::stringstream saux1 ;
1855       saux1 << NumeBoundary << " " << x3 ;
1856       saux += "FAXAxe " + saux1.str() + "\n" ;
1857     }
1858     { std::stringstream saux1 ;
1859       saux1 << NumeBoundary << " " << x4 ;
1860       saux += "FAYAxe " + saux1.str() + "\n" ;
1861     }
1862     { std::stringstream saux1 ;
1863       saux1 << NumeBoundary << " " << x5 ;
1864       saux += "FAZAxe " + saux1.str() + "\n" ;
1865     }
1866     { std::stringstream saux1 ;
1867       saux1 << NumeBoundary << " " << x6 ;
1868       saux += "FARayon " + saux1.str() + "\n" ;
1869     }
1870  }
1871 //
1872 // Cas de la sphere
1873 //
1874   else if ( BoundaryType == 2 )
1875   {
1876     { std::stringstream saux1 ;
1877       saux1 << NumeBoundary << " " << x0 ;
1878       saux += "FAXCen " + saux1.str() + "\n" ;
1879     }
1880     { std::stringstream saux1 ;
1881       saux1 << NumeBoundary << " " << x1 ;
1882       saux += "FAYCen " + saux1.str() + "\n" ;
1883     }
1884     { std::stringstream saux1 ;
1885       saux1 << NumeBoundary << " " << x2 ;
1886       saux += "FAZCen " + saux1.str() + "\n" ;
1887     }
1888     { std::stringstream saux1 ;
1889       saux1 << NumeBoundary << " " << x3 ;
1890       saux += "FARayon " + saux1.str() + "\n" ;
1891     }
1892   }
1893 //
1894 // Cas du cone defini par un axe et un angle
1895 //
1896   if ( BoundaryType == 3 )
1897   {
1898     { std::stringstream saux1 ;
1899       saux1 << NumeBoundary << " " << x0 ;
1900       saux += "FAXAxe " + saux1.str() + "\n" ;
1901     }
1902     { std::stringstream saux1 ;
1903       saux1 << NumeBoundary << " " << x1 ;
1904       saux += "FAYAxe " + saux1.str() + "\n" ;
1905     }
1906     { std::stringstream saux1 ;
1907       saux1 << NumeBoundary << " " << x2 ;
1908       saux += "FAZAxe " + saux1.str() + "\n" ;
1909     }
1910     { std::stringstream saux1 ;
1911       saux1 << NumeBoundary << " " << x3 ;
1912       saux += "FAAngle " + saux1.str() + "\n" ;
1913     }
1914     { std::stringstream saux1 ;
1915       saux1 << NumeBoundary << " " << x4 ;
1916       saux += "FAXCen " + saux1.str() + "\n" ;
1917     }
1918     { std::stringstream saux1 ;
1919       saux1 << NumeBoundary << " " << x5 ;
1920       saux += "FAYCen " + saux1.str() + "\n" ;
1921     }
1922     { std::stringstream saux1 ;
1923       saux1 << NumeBoundary << " " << x6 ;
1924       saux += "FAZCen " + saux1.str() + "\n" ;
1925     }
1926  }
1927 //
1928 // Cas du cone defini par les 2 rayons
1929 //
1930   if ( BoundaryType == 4 )
1931   {
1932     { std::stringstream saux1 ;
1933       saux1 << NumeBoundary << " " << x0 ;
1934       saux += "FAXCen " + saux1.str() + "\n" ;
1935     }
1936     { std::stringstream saux1 ;
1937       saux1 << NumeBoundary << " " << x1 ;
1938       saux += "FAYCen " + saux1.str() + "\n" ;
1939     }
1940     { std::stringstream saux1 ;
1941       saux1 << NumeBoundary << " " << x2 ;
1942       saux += "FAZCen " + saux1.str() + "\n" ;
1943     }
1944     { std::stringstream saux1 ;
1945       saux1 << NumeBoundary << " " << x3 ;
1946       saux += "FARayon " + saux1.str() + "\n" ;
1947     }
1948     { std::stringstream saux1 ;
1949       saux1 << NumeBoundary << " " << x4 ;
1950       saux += "FAXCen2 " + saux1.str() + "\n" ;
1951     }
1952     { std::stringstream saux1 ;
1953       saux1 << NumeBoundary << " " << x5 ;
1954       saux += "FAYCen2 " + saux1.str() + "\n" ;
1955     }
1956     { std::stringstream saux1 ;
1957       saux1 << NumeBoundary << " " << x6 ;
1958       saux += "FAZCen2 " + saux1.str() + "\n" ;
1959     }
1960     { std::stringstream saux1 ;
1961       saux1 << NumeBoundary << " " << x7 ;
1962       saux += "FARayon2 " + saux1.str() + "\n" ;
1963     }
1964  }
1965 //
1966 // Cas du tore
1967 //
1968   if ( BoundaryType == 5 )
1969   {
1970     { std::stringstream saux1 ;
1971       saux1 << NumeBoundary << " " << x0 ;
1972       saux2 = saux1.str() ;
1973       saux += "FAXCen " + saux1.str() + "\n" ;
1974     }
1975     { std::stringstream saux1 ;
1976       saux1 << NumeBoundary << " " << x1 ;
1977       saux += "FAYCen " + saux1.str() + "\n" ;
1978     }
1979     { std::stringstream saux1 ;
1980       saux1 << NumeBoundary << " " << x2 ;
1981       saux += "FAZCen " + saux1.str() + "\n" ;
1982     }
1983     { std::stringstream saux1 ;
1984       saux1 << NumeBoundary << " " << x3 ;
1985       saux += "FAXAxe " + saux1.str() + "\n" ;
1986     }
1987     { std::stringstream saux1 ;
1988       saux1 << NumeBoundary << " " << x4 ;
1989       saux += "FAYAxe " + saux1.str() + "\n" ;
1990     }
1991     { std::stringstream saux1 ;
1992       saux1 << NumeBoundary << " " << x5 ;
1993       saux += "FAZAxe " + saux1.str() + "\n" ;
1994     }
1995     { std::stringstream saux1 ;
1996       saux1 << NumeBoundary << " " << x6 ;
1997       saux += "FARayon  " + saux1.str() + "\n" ;
1998     }
1999     { std::stringstream saux1 ;
2000       saux1 << NumeBoundary << " " << x7 ;
2001       saux += "FARayon2 " + saux1.str() + "\n" ;
2002     }
2003  }
2004 //
2005   _Texte += saux + "#\n" ;
2006 //
2007 }
2008 //===============================================================================
2009 void HomardDriver::TexteBoundaryAnGr( const std::string NameBoundary, int NumeBoundary, const std::string GroupName )
2010 {
2011   MESSAGE("TexteBoundaryAnGr, NameBoundary  = "<<NameBoundary);
2012 //   MESSAGE("TexteBoundaryAnGr, NumeBoundary  = "<<NumeBoundary);
2013 //   MESSAGE("TexteBoundaryAnGr, GroupName  = "<<GroupName);
2014 //
2015 // Commentaires
2016 //
2017   std::string saux, saux2 ;
2018   std::stringstream saux1 ;
2019   saux1 << NumeBoundary ;
2020   saux2 = saux1.str() ;
2021   saux = "#\n# Lien Frontiere/Groupe numero " + saux2 + "\n" ;
2022 //
2023   saux += "FGNomFro " + saux2 + " \"" + NameBoundary + "\"\n" ;
2024   saux += "FGNomGro " + saux2 + " \"" + GroupName + "\"\n" ;
2025 //
2026   _Texte += saux + "#\n" ;
2027 //
2028 }
2029 //===============================================================================
2030 // E. Les interpolations
2031 //===============================================================================
2032 // Les fichiers d'entree et de sortie des champs a interpoler
2033 void HomardDriver::TexteFieldInterp( const std::string FieldFile, const std::string MeshFile )
2034 {
2035   MESSAGE("TexteFieldInterp, FieldFile = "<<FieldFile<<", MeshFile = "<<MeshFile);
2036 //
2037   _Texte += "#\n# Interpolations des champs\n" ;
2038 //
2039 // Fichier en entree
2040   _Texte += "CCSolN__ \"" + FieldFile + "\"\n" ;
2041 // Fichier en sortie
2042   _Texte += "CCSolNP1 \"" + MeshFile  + "\"\n" ;
2043 //
2044 //  std::cerr << "A la fin de TexteFieldInterp _Texte ="<<_Texte << std::endl;
2045 }
2046 //===============================================================================
2047 // Tous les champs sont a interpoler
2048 void HomardDriver::TexteFieldInterpAll( )
2049 {
2050   MESSAGE("TexteFieldInterpAll");
2051 //
2052   _Texte += "CCChaTou oui\n" ;
2053 }
2054 //===============================================================================
2055 // Ecrit les caracteristiques de chaque interpolation sous la forme :
2056 //   CCChaNom 1 "DEPL"     ! Nom du 1er champ a interpoler
2057 //   CCChaTIn 1 0          ! Mode d'interpolation : automatique
2058 //   CCChaNom 2 "VOLUME"   ! Nom du 2nd champ a interpoler
2059 //   CCChaTIn 2 1          ! Mode d'interpolation : une variable extensive
2060 //   CCChaPdT 2 14         ! Pas de temps 14
2061 //   CCChaNuO 2 14         ! Numero d'ordre 14
2062 //   etc.
2063 //
2064 // NumeChamp : numero d'ordre du champ a interpoler
2065 // FieldName : nom du champ
2066 // TypeInterp : type d'interpolation
2067 // TimeStep : pas de temps retenu (>0 si pas de precision)
2068 // Rank : numero d'ordre retenu
2069 //
2070 void HomardDriver::TexteFieldInterpNameType( int NumeChamp, const std::string FieldName, const std::string TypeInterp, int TimeStep, int Rank)
2071 {
2072   MESSAGE("TexteFieldInterpNameType, NumeChamp = "<<NumeChamp<<", FieldName = "<<FieldName<<", TypeInterp = "<<TypeInterp);
2073   MESSAGE("TexteFieldInterpNameType, TimeStep = "<<TimeStep<<", Rank = "<<Rank);
2074 // Numero d'ordre du champ a interpoler
2075   std::stringstream saux1 ;
2076   saux1 << NumeChamp ;
2077   std::string saux = saux1.str() ;
2078 // Nom du champ
2079   _Texte +="CCChaNom " + saux + " \"" + FieldName + "\"\n" ;
2080 // Type d'interpolation pour le champ
2081   _Texte +="CCChaTIn " + saux + " " + TypeInterp + "\n" ;
2082 //
2083   if ( TimeStep >= 0 )
2084   {
2085     {
2086       std::stringstream saux1 ;
2087       saux1 << TimeStep ;
2088       _Texte += "CCChaPdT " + saux + " " + saux1.str()  + "\n" ;
2089     }
2090     {
2091       std::stringstream saux1 ;
2092       saux1 << Rank ;
2093       _Texte += "CCChaNuO " + saux + " " + saux1.str()  + "\n" ;
2094     }
2095   }
2096 }
2097 //===============================================================================
2098 // F. Les options avancees
2099 //===============================================================================
2100 void HomardDriver::TexteAdvanced( int NivMax, double DiamMin, int AdapInit, int ExtraOutput )
2101 {
2102   MESSAGE("TexteAdvanced, NivMax ="<<NivMax<<", DiamMin ="<<DiamMin<<", AdapInit ="<<AdapInit<<", ExtraOutput ="<<ExtraOutput);
2103
2104   if ( NivMax > 0 )
2105   {
2106     _Texte += "# Niveaux extremes\n" ;
2107     { std::stringstream saux1 ;
2108       saux1 << NivMax ;
2109       _Texte += "NiveauMa " + saux1.str() + "\n" ;
2110     }
2111   }
2112   if ( DiamMin > 0 )
2113   {
2114     _Texte += "# Diametre minimal\n" ;
2115     { std::stringstream saux1 ;
2116       saux1 << DiamMin ;
2117       _Texte += "DiametMi " + saux1.str()  + "\n" ;
2118     }
2119   }
2120   if ( AdapInit != 0 )
2121   {
2122     if ( AdapInit > 0 )
2123     { _Texte += "# Raffinement" ; }
2124     else
2125     { _Texte += "# Deraffinement" ; }
2126     _Texte += " des regions sans indicateur\n" ;
2127     { std::stringstream saux1 ;
2128       saux1 << AdapInit ;
2129       _Texte += "AdapInit " + saux1.str() + "\n" ;
2130     }
2131   }
2132   if ( ExtraOutput % 2 == 0 )
2133   {
2134     _Texte += "# Sortie des niveaux de raffinement\n" ;
2135     _Texte += "NCNiveau NIVEAU\n" ;
2136   }
2137   if ( ExtraOutput % 3 == 0 )
2138   {
2139     _Texte += "# Sortie des qualités des mailles\n" ;
2140     _Texte += "NCQualit QUAL\n" ;
2141   }
2142   if ( ExtraOutput % 5 == 0 )
2143   {
2144     _Texte += "# Sortie des diamètres des mailles\n" ;
2145     _Texte += "NCDiamet DIAM\n" ;
2146   }
2147   if ( ExtraOutput % 7 == 0 )
2148   {
2149     _Texte += "# Sortie des parents des mailles\n" ;
2150     _Texte += "NCParent PARENT\n" ;
2151   }
2152   if ( ExtraOutput % 11 == 0 )
2153   {
2154     _Texte += "# Volumes voisins par recollement\n" ;
2155     _Texte += "NCVoisRc Voisin-Recollement\n" ;
2156   }
2157 }
2158 //===============================================================================
2159 // G. Les messages
2160 //===============================================================================
2161 void HomardDriver::TexteInfoCompute( int MessInfo )
2162 {
2163   MESSAGE("TexteAdvanced, MessInfo ="<<MessInfo);
2164
2165   if ( MessInfo != 0 )
2166   {
2167      _Texte += "# Messages d'informations\n" ;
2168     { std::stringstream saux1 ;
2169       saux1 << MessInfo ;
2170       _Texte += "MessInfo " + saux1.str()  + "\n" ;
2171     }
2172    }
2173 }
2174 //===============================================================================
2175 void HomardDriver::CreeFichier( )
2176 {
2177 //
2178   if ( _modeHOMARD == 1 )
2179   { _NomFichierConf = _NomFichierConfBase + "." + _siter + ".vers." + _siterp1 ; }
2180   else if ( _modeHOMARD == 2 )
2181   { _NomFichierConf = _NomFichierConfBase + "." + _siter + ".info" ; }
2182   else if ( _modeHOMARD == 5 )
2183   { _NomFichierConf = _NomFichierConfBase + ".majc" ; }
2184 //
2185   std::ofstream Fic(_NomFichierConf.c_str(), std::ios::out ) ;
2186   if (Fic.is_open() == true) { Fic << _Texte << std::endl ; }
2187   Fic.close() ;
2188 //
2189 }
2190 //===============================================================================
2191 // Creation du fichier de donnees pour l'information
2192 //===============================================================================
2193 void HomardDriver::CreeFichierDonn( )
2194 {
2195 //
2196   MESSAGE("CreeFichierDonn");
2197   _NomFichierDonn = "info.donn" ;
2198 //
2199   std::string data ;
2200   data  = "0\n" ;
2201   data += "0\n" ;
2202   data += "q\n" ;
2203   std::ofstream Fic(_NomFichierDonn.c_str(), std::ios::out ) ;
2204   if (Fic.is_open() == true) { Fic << data << std::endl ; }
2205   Fic.close() ;
2206 //
2207 }
2208 //===============================================================================
2209 int HomardDriver::ExecuteHomard()
2210 {
2211   MESSAGE("ExecuteHomard");
2212   std::string commande ;
2213   int codret ;
2214   // Copie des Fichiers HOMARD
2215   commande = "cp " + _NomFichierConf + " " + _NomFichierConfBase ;
2216   codret = system(commande.c_str()) ;
2217
2218 // Execution de HOMARD
2219   if ( codret == 0)
2220   {
2221     commande = _HOMARD_Exec.c_str() ;
2222     if ( _NomFichierDonn != "" ) { commande += " < " + _NomFichierDonn ; }
2223     codret = system(commande.c_str());
2224     if ( codret != 0) { MESSAGE ( "Erreur en executant HOMARD : " << codret ); };
2225     _NomFichierDonn = "" ;
2226   };
2227   return codret ;
2228 }
2229
2230 //=============================================================================
2231 //=============================================================================
2232 HOMARD_Gen::HOMARD_Gen()
2233 {
2234   MESSAGE("HOMARD_Gen");
2235 }
2236
2237 //=============================================================================
2238 //=============================================================================
2239 HOMARD_Gen::~HOMARD_Gen()
2240 {
2241   MESSAGE("~HOMARD_Gen");
2242 }
2243 //=============================================================================
2244
2245 //=============================================================================
2246 /*!
2247  *  default constructor:
2248  */
2249 //=============================================================================
2250 HOMARD_Hypothesis::HOMARD_Hypothesis():
2251   _Name(""), _NomCasCreation(""),
2252   _TypeAdap(-1), _TypeRaff(0), _TypeDera(0),
2253   _Field(""),
2254   _TypeThR(0), _TypeThC(0),
2255   _ThreshR(0), _ThreshC(0),
2256   _UsField(0), _UsCmpI(0), _TypeFieldInterp(0),
2257
2258   _NivMax(-1), _DiamMin(-1.0), _AdapInit(0), _ExtraOutput(1)
2259 {
2260   MESSAGE("HOMARD_Hypothesis");
2261 }
2262
2263 //=============================================================================
2264 /*!
2265  */
2266 //=============================================================================
2267 HOMARD_Hypothesis::~HOMARD_Hypothesis()
2268 {
2269   MESSAGE("~HOMARD_Hypothesis");
2270 }
2271 //=============================================================================
2272 //=============================================================================
2273 // Generalites
2274 //=============================================================================
2275 //=============================================================================
2276 void HOMARD_Hypothesis::SetName( const char* Name )
2277 {
2278   _Name = std::string( Name );
2279 }
2280 //=============================================================================
2281 std::string HOMARD_Hypothesis::GetName() const
2282 {
2283   return _Name;
2284 }
2285 //=============================================================================
2286 //=============================================================================
2287 // Caracteristiques
2288 //=============================================================================
2289 //=============================================================================
2290 void HOMARD_Hypothesis::SetAdapType( int TypeAdap )
2291 {
2292   VERIFICATION( (TypeAdap>=-1) && (TypeAdap<=1) );
2293   _TypeAdap = TypeAdap;
2294 }
2295 //=============================================================================
2296 int HOMARD_Hypothesis::GetAdapType() const
2297 {
2298   return _TypeAdap;
2299 }
2300 //=============================================================================
2301 void HOMARD_Hypothesis::SetRefinTypeDera( int TypeRaff, int TypeDera )
2302 {
2303   VERIFICATION( (TypeRaff>=-1) && (TypeRaff<=1) );
2304   _TypeRaff = TypeRaff;
2305   VERIFICATION( (TypeDera>=-1) && (TypeDera<=1) );
2306   _TypeDera = TypeDera;
2307 }
2308 //=============================================================================
2309 int HOMARD_Hypothesis::GetRefinType() const
2310 {
2311   return _TypeRaff;
2312 }
2313 //=============================================================================
2314 int HOMARD_Hypothesis::GetUnRefType() const
2315 {
2316   return _TypeDera;
2317 }
2318 //=============================================================================
2319 void HOMARD_Hypothesis::SetField( const char* FieldName )
2320 {
2321   _Field = std::string( FieldName );
2322   MESSAGE( "SetField : FieldName = " << FieldName );
2323 }
2324 //=============================================================================
2325 std::string HOMARD_Hypothesis::GetFieldName() const
2326 {
2327   return _Field;
2328 }
2329 //=============================================================================
2330 void HOMARD_Hypothesis::SetUseField( int UsField )
2331 {
2332   VERIFICATION( (UsField>=0) && (UsField<=1) );
2333   _UsField = UsField;
2334 }
2335 //=============================================================================
2336 int HOMARD_Hypothesis::GetUseField() const
2337 {
2338   return _UsField;
2339 }
2340 //=============================================================================
2341 void HOMARD_Hypothesis::SetUseComp( int UsCmpI )
2342 {
2343   MESSAGE ("SetUseComp pour UsCmpI = "<<UsCmpI) ;
2344   VERIFICATION( (UsCmpI>=0) && (UsCmpI<=2) );
2345   _UsCmpI = UsCmpI;
2346 }
2347 //=============================================================================
2348 int HOMARD_Hypothesis::GetUseComp() const
2349 {
2350   return _UsCmpI;
2351 }
2352 //=============================================================================
2353 void HOMARD_Hypothesis::AddComp( const char* NomComp )
2354 {
2355 // On commence par supprimer la composante au cas ou elle aurait deja ete inseree
2356 // Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la
2357 // definition de l'hypothese
2358   SupprComp( NomComp ) ;
2359 // Insertion veritable
2360   _ListComp.push_back( std::string( NomComp ) );
2361 }
2362 //=============================================================================
2363 void HOMARD_Hypothesis::SupprComp( const char* NomComp )
2364 {
2365   MESSAGE ("SupprComp pour "<<NomComp) ;
2366   std::list<std::string>::iterator it = find( _ListComp.begin(), _ListComp.end(), NomComp );
2367   if ( it != _ListComp.end() ) { it = _ListComp.erase( it ); }
2368 }
2369 //=============================================================================
2370 void HOMARD_Hypothesis::SupprComps()
2371 {
2372   _ListComp.clear();
2373 }
2374 //=============================================================================
2375 const std::list<std::string>& HOMARD_Hypothesis::GetComps() const
2376 {
2377   return _ListComp;
2378 }
2379 //=============================================================================
2380 void HOMARD_Hypothesis::SetRefinThr( int TypeThR, double ThreshR )
2381 {
2382   MESSAGE( "SetRefinThr : TypeThR = " << TypeThR << ", ThreshR = " << ThreshR );
2383   VERIFICATION( (TypeThR>=0) && (TypeThR<=4) );
2384   _TypeThR = TypeThR;
2385   _ThreshR = ThreshR;
2386 }
2387 //=============================================================================
2388 int HOMARD_Hypothesis::GetRefinThrType() const
2389 {
2390   return _TypeThR;
2391 }
2392 //=============================================================================
2393 double HOMARD_Hypothesis::GetThreshR() const
2394 {
2395   return _ThreshR;
2396 }
2397 //=============================================================================
2398 void HOMARD_Hypothesis::SetUnRefThr( int TypeThC, double ThreshC )
2399 {
2400   VERIFICATION( (TypeThC>=0) && (TypeThC<=4) );
2401   _TypeThC = TypeThC;
2402   _ThreshC = ThreshC;
2403 }
2404 //=============================================================================
2405 int HOMARD_Hypothesis::GetUnRefThrType() const
2406 {
2407   return _TypeThC;
2408 }
2409 //=============================================================================
2410 double HOMARD_Hypothesis::GetThreshC() const
2411 {
2412   return _ThreshC;
2413 }
2414 //=============================================================================
2415 void HOMARD_Hypothesis::SetNivMax( int NivMax )
2416 //=============================================================================
2417 {
2418   _NivMax = NivMax;
2419 }
2420 //=============================================================================
2421 const int HOMARD_Hypothesis::GetNivMax() const
2422 //=============================================================================
2423 {
2424   return _NivMax;
2425 }
2426 //=============================================================================
2427 void HOMARD_Hypothesis::SetDiamMin( double DiamMin )
2428 //=============================================================================
2429 {
2430   _DiamMin = DiamMin;
2431 }
2432 //=============================================================================
2433 const double HOMARD_Hypothesis::GetDiamMin() const
2434 //=============================================================================
2435 {
2436   return _DiamMin;
2437 }
2438 //=============================================================================
2439 void HOMARD_Hypothesis::SetAdapInit( int AdapInit )
2440 //=============================================================================
2441 {
2442   _AdapInit = AdapInit;
2443 }
2444 //=============================================================================
2445 const int HOMARD_Hypothesis::GetAdapInit() const
2446 //=============================================================================
2447 {
2448   return _AdapInit;
2449 }
2450 //=============================================================================
2451 void HOMARD_Hypothesis::SetExtraOutput( int ExtraOutput )
2452 //=============================================================================
2453 {
2454   _ExtraOutput = ExtraOutput;
2455 }
2456 //=============================================================================
2457 const int HOMARD_Hypothesis::GetExtraOutput() const
2458 //=============================================================================
2459 {
2460   return _ExtraOutput;
2461 }
2462 //=============================================================================
2463 void HOMARD_Hypothesis::AddGroup( const char* Group)
2464 {
2465 // On commence par supprimer le groupe au cas ou il aurait deja ete insere
2466 // Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la
2467 // definition de l'hypothese
2468   SupprGroup( Group ) ;
2469 // Insertion veritable
2470   _ListGroupSelected.push_back(Group);
2471 }
2472 //=============================================================================
2473 void HOMARD_Hypothesis::SupprGroup( const char* Group )
2474 {
2475   MESSAGE ("SupprGroup pour "<<Group) ;
2476   std::list<std::string>::iterator it = find( _ListGroupSelected.begin(), _ListGroupSelected.end(), Group );
2477   if ( it != _ListGroupSelected.end() ) { it = _ListGroupSelected.erase( it ); }
2478 }
2479 //=============================================================================
2480 void HOMARD_Hypothesis::SupprGroups()
2481 {
2482   _ListGroupSelected.clear();
2483 }
2484 //=============================================================================
2485 void HOMARD_Hypothesis::SetGroups( const std::list<std::string>& ListGroup )
2486 {
2487   _ListGroupSelected.clear();
2488   std::list<std::string>::const_iterator it = ListGroup.begin();
2489   while(it != ListGroup.end())
2490     _ListGroupSelected.push_back((*it++));
2491 }
2492 //=============================================================================
2493 const std::list<std::string>& HOMARD_Hypothesis::GetGroups() const
2494 {
2495   return _ListGroupSelected;
2496 }
2497 //=============================================================================
2498 // Type d'interpolation des champs :
2499 //   0 : aucun champ n'est interpole
2500 //   1 : tous les champs sont interpoles
2501 //   2 : certains champs sont interpoles
2502 void HOMARD_Hypothesis::SetTypeFieldInterp( int TypeFieldInterp )
2503 {
2504   VERIFICATION( (TypeFieldInterp>=0) && (TypeFieldInterp<=2) );
2505   _TypeFieldInterp = TypeFieldInterp;
2506 }
2507 //=============================================================================
2508 int HOMARD_Hypothesis::GetTypeFieldInterp() const
2509 {
2510   return _TypeFieldInterp;
2511 }
2512 //=============================================================================
2513 void HOMARD_Hypothesis::AddFieldInterpType( const char* FieldInterp, int TypeInterp )
2514 {
2515   MESSAGE ("Dans AddFieldInterpType pour " << FieldInterp << " et TypeInterp = " << TypeInterp) ;
2516 // On commence par supprimer le champ au cas ou il aurait deja ete insere
2517 // Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la
2518 // definition de l'hypothese
2519   SupprFieldInterp( FieldInterp ) ;
2520 // Insertion veritable
2521 // . Nom du champ
2522   _ListFieldInterp.push_back( std::string( FieldInterp ) );
2523 // . Usage du champ
2524   std::stringstream saux1 ;
2525   saux1 << TypeInterp ;
2526   _ListFieldInterp.push_back( saux1.str() );
2527 // . Indication generale : certains champs sont a interpoler
2528   SetTypeFieldInterp ( 2 ) ;
2529 }
2530 //=============================================================================
2531 void HOMARD_Hypothesis::SupprFieldInterp( const char* FieldInterp )
2532 {
2533   MESSAGE ("Dans SupprFieldInterp pour " << FieldInterp) ;
2534   std::list<std::string>::iterator it = find( _ListFieldInterp.begin(), _ListFieldInterp.end(), FieldInterp ) ;
2535 // Attention a supprimer le nom du champ et le type d'usage
2536   if ( it != _ListFieldInterp.end() )
2537   {
2538     it = _ListFieldInterp.erase( it ) ;
2539     it = _ListFieldInterp.erase( it ) ;
2540   }
2541 // Decompte du nombre de champs restant a interpoler
2542   it = _ListFieldInterp.begin() ;
2543   int cpt = 0 ;
2544   while(it != _ListFieldInterp.end())
2545   {
2546     cpt += 1 ;
2547     (*it++);
2548   }
2549   MESSAGE("Nombre de champ restants = "<<cpt/2);
2550 // . Indication generale : aucun champ ne reste a interpoler
2551   if ( cpt == 0 )
2552   {
2553     SetTypeFieldInterp ( 0 ) ;
2554   }
2555 }
2556 //=============================================================================
2557 void HOMARD_Hypothesis::SupprFieldInterps()
2558 {
2559   MESSAGE ("SupprFieldInterps") ;
2560   _ListFieldInterp.clear();
2561 // . Indication generale : aucun champ ne reste a interpoler
2562   SetTypeFieldInterp ( 0 ) ;
2563 }
2564 //=============================================================================
2565 const std::list<std::string>& HOMARD_Hypothesis::GetFieldInterps() const
2566 {
2567   return _ListFieldInterp;
2568 }
2569 //=============================================================================
2570 //=============================================================================
2571 // Liens avec les autres structures
2572 //=============================================================================
2573 //=============================================================================
2574 void HOMARD_Hypothesis::SetCaseCreation( const char* NomCasCreation )
2575 {
2576   _NomCasCreation = std::string( NomCasCreation );
2577 }
2578 //=============================================================================
2579 std::string HOMARD_Hypothesis::GetCaseCreation() const
2580 {
2581   return _NomCasCreation;
2582 }
2583 //=============================================================================
2584 void HOMARD_Hypothesis::LinkIteration( const char* NomIteration )
2585 {
2586   _ListIter.push_back( std::string( NomIteration ) );
2587 }
2588 //=============================================================================
2589 void HOMARD_Hypothesis::UnLinkIteration( const char* NomIteration )
2590 {
2591   std::list<std::string>::iterator it = find( _ListIter.begin(), _ListIter.end(), NomIteration ) ;
2592   if ( it != _ListIter.end() )
2593   {
2594     MESSAGE ("Dans UnLinkIteration pour " << NomIteration) ;
2595     it = _ListIter.erase( it ) ;
2596   }
2597 }
2598 //=============================================================================
2599 void HOMARD_Hypothesis::UnLinkIterations()
2600 {
2601   _ListIter.clear();
2602 }
2603 //=============================================================================
2604 const std::list<std::string>& HOMARD_Hypothesis::GetIterations() const
2605 {
2606   return _ListIter;
2607 }
2608 //=============================================================================
2609 void HOMARD_Hypothesis::AddZone( const char* NomZone, int TypeUse )
2610 {
2611   MESSAGE ("Dans AddZone pour " << NomZone << " et TypeUse = " << TypeUse) ;
2612 // On commence par supprimer la zone au cas ou elle aurait deja ete inseree
2613 // Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la
2614 // definition de l'hypothese
2615   SupprZone( NomZone ) ;
2616 // Insertion veritable
2617 // . Nom de la zone
2618   _ListZone.push_back( std::string( NomZone ) );
2619 // . Usage de la zone
2620   std::stringstream saux1 ;
2621   saux1 << TypeUse ;
2622   _ListZone.push_back( saux1.str() );
2623 }
2624 //=============================================================================
2625 void HOMARD_Hypothesis::SupprZone( const char* NomZone )
2626 {
2627   MESSAGE ("Dans SupprZone pour " << NomZone) ;
2628   std::list<std::string>::iterator it = find( _ListZone.begin(), _ListZone.end(), NomZone );
2629 // Attention a supprimer le nom de zone et le type d'usage
2630   if ( it != _ListZone.end() )
2631   {
2632     it = _ListZone.erase( it );
2633     it = _ListZone.erase( it );
2634   }
2635 }
2636 //=============================================================================
2637 void HOMARD_Hypothesis::SupprZones()
2638 {
2639   _ListZone.clear();
2640 }
2641 //=============================================================================
2642 const std::list<std::string>& HOMARD_Hypothesis::GetZones() const
2643 {
2644   return _ListZone;
2645 }
2646
2647 //=============================================================================
2648 /*!
2649  *  default constructor:
2650  */
2651 //=============================================================================
2652 HOMARD_Iteration::HOMARD_Iteration():
2653   _Name( "" ), _Etat( 0 ),
2654  _NumIter( -1 ),
2655   _NomMesh( "" ), _MeshFile( "" ),
2656   _FieldFile( "" ), _TimeStep( -1 ), _Rank( -1 ),
2657   _LogFile( "" ),
2658   _IterParent( "" ),
2659   _NomHypo( "" ), _NomCas( "" ), _NomDir( "" ),
2660   _FileInfo( "" ),
2661  _MessInfo( 1 )
2662 {
2663   MESSAGE("HOMARD_Iteration");
2664 }
2665 //=============================================================================
2666 /*!
2667  *
2668  */
2669 //=============================================================================
2670 HOMARD_Iteration::~HOMARD_Iteration()
2671 {
2672   MESSAGE("~HOMARD_Iteration");
2673 }
2674 //=============================================================================
2675 //=============================================================================
2676 // Generalites
2677 //=============================================================================
2678 //=============================================================================
2679 void HOMARD_Iteration::SetName( const char* Name )
2680 {
2681   _Name = std::string( Name );
2682 }
2683 //=============================================================================
2684 std::string HOMARD_Iteration::GetName() const
2685 {
2686   return _Name;
2687 }
2688 //=============================================================================
2689 //=============================================================================
2690 // Caracteristiques
2691 //=============================================================================
2692 //=============================================================================
2693 void HOMARD_Iteration::SetDirNameLoc( const char* NomDir )
2694 {
2695   _NomDir = std::string( NomDir );
2696 }
2697 //=============================================================================
2698 std::string HOMARD_Iteration::GetDirNameLoc() const
2699 {
2700    return _NomDir;
2701 }
2702 //=============================================================================
2703 void HOMARD_Iteration::SetNumber( int NumIter )
2704 {
2705   _NumIter = NumIter;
2706 }
2707 //=============================================================================
2708 int HOMARD_Iteration::GetNumber() const
2709 {
2710   return _NumIter;
2711 }
2712 //=============================================================================
2713 void HOMARD_Iteration::SetState( int etat )
2714 {
2715   _Etat = etat;
2716 }
2717 //=============================================================================
2718 int HOMARD_Iteration::GetState() const
2719 {
2720   return _Etat;
2721 }
2722 //=============================================================================
2723 void HOMARD_Iteration::SetMeshName( const char* NomMesh )
2724 {
2725   _NomMesh = std::string( NomMesh );
2726 }
2727 //=============================================================================
2728 std::string HOMARD_Iteration::GetMeshName() const
2729 {
2730   return _NomMesh;
2731 }
2732 //=============================================================================
2733 void HOMARD_Iteration::SetMeshFile( const char* MeshFile )
2734 {
2735   _MeshFile = std::string( MeshFile );
2736 }
2737 //=============================================================================
2738 std::string HOMARD_Iteration::GetMeshFile() const
2739 {
2740   return _MeshFile;
2741 }
2742 //=============================================================================
2743 void HOMARD_Iteration::SetFieldFile( const char* FieldFile )
2744 {
2745   _FieldFile = std::string( FieldFile );
2746 }
2747 //=============================================================================
2748 std::string HOMARD_Iteration::GetFieldFile() const
2749 {
2750   return _FieldFile;
2751 }
2752 //=============================================================================
2753 // Instants pour le champ de pilotage
2754 //=============================================================================
2755 void HOMARD_Iteration::SetTimeStep( int TimeStep )
2756 {
2757   _TimeStep = TimeStep;
2758 }
2759 //=============================================================================
2760 void HOMARD_Iteration::SetTimeStepRank( int TimeStep, int Rank )
2761 {
2762   _TimeStep = TimeStep;
2763   _Rank = Rank;
2764 }
2765 //=============================================================================
2766 void HOMARD_Iteration::SetTimeStepRankLast()
2767 {
2768   _TimeStep = -2;
2769 }
2770 //=============================================================================
2771 int HOMARD_Iteration::GetTimeStep() const
2772 {
2773   return _TimeStep;
2774 }
2775 //=============================================================================
2776 int HOMARD_Iteration::GetRank() const
2777 {
2778   return _Rank;
2779 }
2780 //=============================================================================
2781 // Instants pour un champ a interpoler
2782 //=============================================================================
2783 void HOMARD_Iteration::SetFieldInterpTimeStep( const char* FieldInterp, int TimeStep )
2784 {
2785   SetFieldInterpTimeStepRank( FieldInterp, TimeStep, TimeStep ) ;
2786 }
2787 //=============================================================================
2788 void HOMARD_Iteration::SetFieldInterpTimeStepRank( const char* FieldInterp, int TimeStep, int Rank )
2789 {
2790   MESSAGE("Champ " << FieldInterp << ", hypothese " << _NomHypo )
2791 // Verification de la presence du champ dans l'hypothese
2792   std::list<std::string>::iterator it = find( _ListFieldInterp.begin(), _ListFieldInterp.end(), FieldInterp );
2793   if ( it == _ListFieldInterp.end() )
2794   {
2795     INFOS("Champ " << FieldInterp << " ; hypothese " << _NomHypo )
2796     VERIFICATION("Le champ est inconnu dans l'hypothese associee a cette iteration." == 0);
2797   }
2798
2799 // . Nom du champ
2800   _ListFieldInterpTSR.push_back( std::string( FieldInterp ) );
2801 // . Pas de temps
2802   std::stringstream saux1 ;
2803   saux1 << TimeStep ;
2804   _ListFieldInterpTSR.push_back( saux1.str() );
2805 // . Numero d'ordre
2806   std::stringstream saux2 ;
2807   saux2 << Rank ;
2808   _ListFieldInterpTSR.push_back( saux2.str() );
2809 }
2810 //=============================================================================
2811 const std::list<std::string>& HOMARD_Iteration::GetFieldInterpsTimeStepRank() const
2812 {
2813   return _ListFieldInterpTSR;
2814 }
2815 //=============================================================================
2816 void HOMARD_Iteration::SetFieldInterp( const char* FieldInterp )
2817 {
2818   _ListFieldInterp.push_back( std::string( FieldInterp ) );
2819 }
2820 //=============================================================================
2821 const std::list<std::string>& HOMARD_Iteration::GetFieldInterps() const
2822 {
2823   return _ListFieldInterp;
2824 }
2825 //=============================================================================
2826 void HOMARD_Iteration::SupprFieldInterps()
2827 {
2828   _ListFieldInterp.clear();
2829 }
2830 //=============================================================================
2831 void HOMARD_Iteration::SetLogFile( const char* LogFile )
2832 {
2833   _LogFile = std::string( LogFile );
2834 }
2835 //=============================================================================
2836 std::string HOMARD_Iteration::GetLogFile() const
2837 {
2838   return _LogFile;
2839 }
2840 //=============================================================================
2841 void HOMARD_Iteration::SetFileInfo( const char* FileInfo )
2842 {
2843   _FileInfo = std::string( FileInfo );
2844 }
2845 //=============================================================================
2846 std::string HOMARD_Iteration::GetFileInfo() const
2847 {
2848   return _FileInfo;
2849 }
2850 //=============================================================================
2851 //=============================================================================
2852 // Liens avec les autres iterations
2853 //=============================================================================
2854 //=============================================================================
2855 void HOMARD_Iteration::LinkNextIteration( const char* NomIteration )
2856 {
2857   _mesIterFilles.push_back( std::string( NomIteration ) );
2858 }
2859 //=============================================================================
2860 void HOMARD_Iteration::UnLinkNextIteration( const char* NomIteration )
2861 {
2862   std::list<std::string>::iterator it = find( _mesIterFilles.begin(), _mesIterFilles.end(), NomIteration ) ;
2863   if ( it != _mesIterFilles.end() )
2864   {
2865     MESSAGE ("Dans UnLinkNextIteration pour " << NomIteration) ;
2866     it = _mesIterFilles.erase( it ) ;
2867   }
2868 }
2869 //=============================================================================
2870 void HOMARD_Iteration::UnLinkNextIterations()
2871 {
2872   _mesIterFilles.clear();
2873 }
2874 //=============================================================================
2875 const std::list<std::string>& HOMARD_Iteration::GetIterations() const
2876 {
2877   return _mesIterFilles;
2878 }
2879 //=============================================================================
2880 void HOMARD_Iteration::SetIterParentName( const char* IterParent )
2881 {
2882   _IterParent = IterParent;
2883 }
2884 //=============================================================================
2885 std::string HOMARD_Iteration::GetIterParentName() const
2886 {
2887   return _IterParent;
2888 }
2889 //=============================================================================
2890 //=============================================================================
2891 // Liens avec les autres structures
2892 //=============================================================================
2893 //=============================================================================
2894 void HOMARD_Iteration::SetCaseName( const char* NomCas )
2895 {
2896   _NomCas = std::string( NomCas );
2897 }
2898 //=============================================================================
2899 std::string HOMARD_Iteration::GetCaseName() const
2900 {
2901   return _NomCas;
2902 }
2903 //=============================================================================
2904 void HOMARD_Iteration::SetHypoName( const char* NomHypo )
2905 {
2906   _NomHypo = std::string( NomHypo );
2907 }
2908 //=============================================================================
2909 std::string HOMARD_Iteration::GetHypoName() const
2910 {
2911   return _NomHypo;
2912 }
2913 //=============================================================================
2914 //=============================================================================
2915 // Divers
2916 //=============================================================================
2917 //=============================================================================
2918 void HOMARD_Iteration::SetInfoCompute( int MessInfo )
2919 {
2920   _MessInfo = MessInfo;
2921 }
2922 //=============================================================================
2923 int HOMARD_Iteration::GetInfoCompute() const
2924 {
2925   return _MessInfo;
2926 }
2927
2928 } // namespace SMESHHOMARDImpl /end/