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