Salome HOME
Debug, example
[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   // TODO?
1188   if ( getenv("HOMARD_ROOT_DIR") != NULL ) { dir = getenv("HOMARD_ROOT_DIR") ; }
1189   dir += "/bin/salome";
1190   MESSAGE("dir ="<<dir);
1191   // L'executable HOMARD
1192   std::string executable = "homard";
1193   MESSAGE("executable ="<<executable);
1194   // Memorisation du nom complet de l'executable HOMARD
1195   _HOMARD_Exec = dir + "/" + executable ;
1196   MESSAGE("==> _HOMARD_Exec ="<<_HOMARD_Exec) ;
1197   //
1198   _siter = siter ;
1199   _siterp1 = siterp1 ;
1200 }
1201 //=============================================================================
1202 //=============================================================================
1203 HomardDriver::~HomardDriver()
1204 {
1205 }
1206 //===============================================================================
1207 // A. Generalites
1208 //===============================================================================
1209 void HomardDriver::TexteInit( const std::string DirCompute, const std::string LogFile, const std::string Langue )
1210 {
1211   MESSAGE("TexteInit, DirCompute ="<<DirCompute<<", LogFile ="<<LogFile);
1212 //
1213   _Texte  = "ListeStd \"" + LogFile + "\"\n" ;
1214   _Texte += "RepeTrav \"" + DirCompute + "\"\n" ;
1215   _Texte += "RepeInfo \"" + DirCompute + "\"\n" ;
1216   _Texte += "Langue \"" + Langue + "\"\n" ;
1217 //
1218 }
1219 //===============================================================================
1220 void HomardDriver::TexteAdap()
1221 {
1222   MESSAGE("TexteAdap");
1223
1224   _Texte += "Action   homa\n";
1225   _Texte += "CCAssoci med\n";
1226   _Texte += "ModeHOMA 1\n";
1227   _Texte += "NumeIter " + _siter + "\n";
1228   _modeHOMARD = 1;
1229 }
1230 //===============================================================================
1231 void HomardDriver::TexteInfo( int TypeBila, int NumeIter )
1232 {
1233   MESSAGE("TexteInfo: TypeBila ="<<TypeBila<<", NumeIter ="<<NumeIter);
1234 //
1235   _Texte += "ModeHOMA 2\n" ;
1236   std::stringstream saux1 ;
1237   saux1 << TypeBila ;
1238   std::string saux2 = saux1.str() ;
1239   _Texte += "TypeBila " + saux2 + "\n" ;
1240   if ( NumeIter ==  0 )
1241   {
1242     _Texte += "NumeIter 0\n" ;
1243     _Texte += "Action   info_av\n" ;
1244     _Texte += "CCAssoci med\n" ;
1245   }
1246   else
1247   {
1248     _Texte += "NumeIter " + _siter + "\n" ;
1249     _Texte += "Action   info_ap\n" ;
1250     _Texte += "CCAssoci homard\n" ;
1251   }
1252   _modeHOMARD = 2 ;
1253 //
1254 }
1255 //===============================================================================
1256 void HomardDriver::TexteMajCoords( int NumeIter )
1257 {
1258   MESSAGE("TexteMajCoords: NumeIter ="<<NumeIter);
1259 //
1260   _Texte += "ModeHOMA 5\n" ;
1261   _Texte += "NumeIter " + _siterp1 + "\n" ;
1262   _Texte += "Action   homa\n" ;
1263   _Texte += "CCAssoci med\n" ;
1264   _Texte += "EcriFiHO N_SANS_FRONTIERE\n" ;
1265   _modeHOMARD = 5 ;
1266 //
1267 }
1268 //===============================================================================
1269 // B. Les maillages en entree et en sortie
1270 //===============================================================================
1271 void HomardDriver::TexteMaillage( const std::string NomMesh, const std::string MeshFile, int apres )
1272 {
1273   MESSAGE("TexteMaillage, NomMesh  = "<<NomMesh);
1274   MESSAGE("TexteMaillage, MeshFile = "<<MeshFile);
1275   MESSAGE("TexteMaillage, apres = "<<apres);
1276   std::string saux ;
1277   saux = "P1" ;
1278   if ( apres < 1 ) { saux = "__" ; }
1279
1280   _Texte += "# Maillages Med " + saux + "\n" ;
1281   _Texte += "CCNoMN" + saux + " \"" + NomMesh  + "\"\n" ;
1282   _Texte += "CCMaiN" + saux + " \"" + MeshFile + "\"\n" ;
1283 }
1284
1285 //===============================================================================
1286 void HomardDriver::TexteMaillageHOMARD( const std::string Dir, const std::string liter, int apres )
1287 {
1288   MESSAGE("TexteMaillageHOMARD, Dir ="<<Dir<<", liter ="<<liter<<", apres ="<<apres);
1289   std::string saux ;
1290   if ( apres < 1 ) { saux = "__" ; }
1291   else             { saux = "P1" ; }
1292
1293   _Texte += "# Maillage HOMARD " + liter + "\n" ;
1294   _Texte += "HOMaiN" + saux + " Mai" + liter   + " \"" + Dir + "/maill." + liter   + ".hom.med\"\n" ;
1295 }
1296
1297 //===============================================================================
1298 // C. Le pilotage de l'adaptation
1299 //===============================================================================
1300 void HomardDriver::TexteConfRaffDera( int ConfType, int TypeAdap, int TypeRaff, int TypeDera )
1301 {
1302   MESSAGE("TexteConfRaffDera, ConfType ="<<ConfType);
1303   MESSAGE("TexteConfRaffDera, TypeAdap ="<<TypeAdap<<", TypeRaff ="<<TypeRaff<<", TypeDera ="<<TypeDera);
1304 //
1305 // Type de conformite
1306 //
1307   std::string saux ;
1308   switch (ConfType)
1309   {
1310     case -2: //
1311     {
1312       saux = "NON_CONFORME_1_ARETE" ;
1313       break;
1314     }
1315     case -1: //
1316     {
1317       saux = "CONFORME_BOITES" ;
1318       break;
1319     }
1320     case 0: //
1321     {
1322       saux = "CONFORME" ;
1323       break;
1324     }
1325     case 1: //
1326     {
1327       saux = "NON_CONFORME" ;
1328       break;
1329     }
1330     case 2: //
1331     {
1332       saux = "NON_CONFORME_1_NOEUD" ;
1333       break;
1334     }
1335     case 3: //
1336     {
1337       saux = "NON_CONFORME_INDICATEUR" ;
1338       break;
1339     }
1340   }
1341   _Texte += "# Type de conformite\nTypeConf " + saux + "\n" ;
1342 //
1343 // Type de raffinement/deraffinement
1344 //
1345   if ( TypeAdap == -1 )
1346   {
1347     if ( TypeRaff == 1 )
1348     {
1349       saux = "TypeRaff uniforme\n" ;
1350     }
1351     else
1352     {
1353       saux = "TypeRaff non\n" ;
1354     }
1355     if ( TypeDera == 1 )
1356     {
1357       saux += "TypeDera uniforme" ;
1358     }
1359     else
1360     {
1361       saux += "TypeDera non" ;
1362     }
1363   }
1364   else
1365   {
1366     if ( TypeRaff == 1 )
1367     {
1368       saux = "TypeRaff libre\n" ;
1369     }
1370     else
1371     {
1372       saux = "TypeRaff non\n" ;
1373     }
1374     if ( TypeDera == 1 )
1375     {
1376       saux += "TypeDera libre" ;
1377     }
1378     else
1379     {
1380       saux += "TypeDera non" ;
1381     }
1382   }
1383   _Texte += "# Type de raffinement/deraffinement\n" + saux + "\n" ;
1384 //
1385 //   MESSAGE("A la fin de HomardDriver::TexteConfRaffDera, _Texte ="<<_Texte);
1386 }
1387 //===============================================================================
1388 void HomardDriver::TexteCompo( int NumeComp, const std::string NomCompo)
1389 {
1390   MESSAGE("TexteCompo, NumeComp = "<<NumeComp<<", NomCompo = "<<NomCompo);
1391   _Texte +="CCCoChaI \"" + NomCompo + "\"\n" ;
1392 }
1393 //===============================================================================
1394 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 )
1395 {
1396   MESSAGE("TexteZone, NumeZone = "<<NumeZone<<", ZoneType = "<<ZoneType<<", TypeUse = "<<TypeUse);
1397   MESSAGE("TexteZone, coor = "<< x0<<","<<x1<< ","<< x2<< ","<< x3<<","<<x4<<","<<x5<<","<<x6<<","<<x7<<","<<x8);
1398 //
1399   std::string saux, saux2 ;
1400 //
1401 // Type de zones
1402 // On convertit le type de zone au sens du module HOMARD dans Salome, ZoneType, dans le
1403 // type au sens de l'executable HOMARD, ZoneTypeHOMARD
1404 // Attention a mettre le bon signe a ZoneTypeHOMARD :
1405 //    >0 signifie que l'on raffinera les mailles contenues dans la zone,
1406 //    <0 signifie que l'on deraffinera
1407 //
1408   int ZoneTypeHOMARD ;
1409   if ( ZoneType >= 11 && ZoneType <= 13 ) { ZoneTypeHOMARD = 1 ; }
1410   else if ( ZoneType >= 31 && ZoneType <= 33 ) { ZoneTypeHOMARD = 3 ; }
1411   else if ( ZoneType >= 61 && ZoneType <= 63 ) { ZoneTypeHOMARD = 6 ; }
1412   else { ZoneTypeHOMARD = ZoneType ; }
1413 //
1414   if ( TypeUse < 0 ) { ZoneTypeHOMARD = -ZoneTypeHOMARD ; }
1415 //
1416   std::stringstream saux1 ;
1417   saux1 << NumeZone ;
1418   saux = "#\n# Zone numero " + saux1.str() + "\n" ;
1419 //
1420   { std::stringstream saux1 ;
1421     saux1 << NumeZone << " " << ZoneTypeHOMARD ;
1422     saux += "ZoRaType " + saux1.str() + "\n" ;
1423   }
1424 //
1425 // Cas du rectangle
1426 //
1427   if ( ZoneType == 11 ) // Z est constant X Homard <=> X Salome
1428 //                                        Y Homard <=> Y Salome
1429   {
1430     saux += "#Rectangle\n" ;
1431     { std::stringstream saux1 ;
1432       saux1 << NumeZone << " " << x0 ;
1433       saux += "ZoRaXmin " + saux1.str() + "\n" ;
1434     }
1435     { std::stringstream saux1 ;
1436       saux1 << NumeZone << " " << x1 ;
1437       saux += "ZoRaXmax " + saux1.str() + "\n" ;
1438     }
1439     { std::stringstream saux1 ;
1440       saux1 << NumeZone << " " << x2 ;
1441       saux += "ZoRaYmin " + saux1.str() + "\n" ;
1442     }
1443     { std::stringstream saux1 ;
1444       saux1 << NumeZone << " " << x3 ;
1445       saux += "ZoRaYmax " + saux1.str() + "\n" ;
1446     }
1447   }
1448 //
1449   else if ( ZoneType == 12 ) // X est constant X Homard <=> Y Salome
1450 //                                             Y Homard <=> Z Salome
1451   {
1452     saux += "#Rectangle\n" ;
1453     { std::stringstream saux1 ;
1454       saux1 << NumeZone << " " << x2 ;
1455       saux += "ZoRaXmin " + saux1.str() + "\n" ;
1456     }
1457     { std::stringstream saux1 ;
1458       saux1 << NumeZone << " " << x3 ;
1459       saux += "ZoRaXmax " + saux1.str() + "\n" ;
1460     }
1461     { std::stringstream saux1 ;
1462       saux1 << NumeZone << " " << x4 ;
1463       saux += "ZoRaYmin " + saux1.str() + "\n" ;
1464     }
1465     { std::stringstream saux1 ;
1466       saux1 << NumeZone << " " << x5 ;
1467       saux += "ZoRaYmax " + saux1.str() + "\n" ;
1468     }
1469   }
1470 //
1471   else if ( ZoneType == 13 ) // Y est constant X Homard <=> X Salome
1472 //                                             Y Homard <=> Z Salome
1473   {
1474     saux += "#Rectangle\n" ;
1475     { std::stringstream saux1 ;
1476       saux1 << NumeZone << " " << x0 ;
1477       saux += "ZoRaXmin " + saux1.str() + "\n" ;
1478     }
1479     { std::stringstream saux1 ;
1480       saux1 << NumeZone << " " << x1 ;
1481       saux += "ZoRaXmax " + saux1.str() + "\n" ;
1482     }
1483     { std::stringstream saux1 ;
1484       saux1 << NumeZone << " " << x4 ;
1485       saux += "ZoRaYmin " + saux1.str() + "\n" ;
1486     }
1487     { std::stringstream saux1 ;
1488       saux1 << NumeZone << " " << x5 ;
1489       saux += "ZoRaYmax " + saux1.str() + "\n" ;
1490     }
1491   }
1492 //
1493 // Cas du parallelepipede
1494 //
1495   else if ( ZoneType == 2 )
1496   {
1497     saux += "# Boite\n" ;
1498     { std::stringstream saux1 ;
1499       saux1 << NumeZone << " " << x0 ;
1500       saux += "ZoRaXmin " + saux1.str() + "\n" ;
1501     }
1502     { std::stringstream saux1 ;
1503       saux1 << NumeZone << " " << x1 ;
1504       saux += "ZoRaXmax " + saux1.str() + "\n" ;
1505     }
1506     { std::stringstream saux1 ;
1507       saux1 << NumeZone << " " << x2 ;
1508       saux += "ZoRaYmin " + saux1.str() + "\n" ;
1509     }
1510     { std::stringstream saux1 ;
1511       saux1 << NumeZone << " " << x3 ;
1512       saux += "ZoRaYmax " + saux1.str() + "\n" ;
1513     }
1514     { std::stringstream saux1 ;
1515       saux1 << NumeZone << " " << x4 ;
1516       saux += "ZoRaZmin " + saux1.str() + "\n" ;
1517     }
1518     { std::stringstream saux1 ;
1519       saux1 << NumeZone << " " << x5 ;
1520       saux += "ZoRaZmax " + saux1.str() + "\n" ;
1521     }
1522   }
1523 //
1524 // Cas du disque
1525 //
1526   else if ( ZoneType == 31 || ZoneType == 61 )
1527   {
1528     saux += "# Sphere\n" ;
1529     { std::stringstream saux1 ;
1530       saux1 << NumeZone << " " << x0 ;
1531       saux += "ZoRaXCen " + saux1.str() + "\n" ;
1532     }
1533     { std::stringstream saux1 ;
1534       saux1 << NumeZone << " " << x1 ;
1535       saux += "ZoRaYCen " + saux1.str() + "\n" ;
1536     }
1537     { std::stringstream saux1 ;
1538       saux1 << NumeZone << " " << x6 ;
1539       saux2 = saux1.str() ;
1540       if ( ZoneType == 61 ) { saux += "ZoRaRayE " + saux2 + "\n" ; }
1541       else                  { saux += "ZoRaRayo " + saux2 + "\n" ; }
1542     }
1543     if ( ZoneType == 61 )
1544     { std::stringstream saux1 ;
1545       saux1 << NumeZone << " " << x8 ;
1546       saux += "ZoRaRayI " + saux1.str() + "\n" ;
1547     }
1548   }
1549   else if ( ZoneType == 32 || ZoneType == 62 )
1550   {
1551     saux += "# Sphere\n" ;
1552     { std::stringstream saux1 ;
1553       saux1 << NumeZone << " " << x1 ;
1554       saux += "ZoRaXCen " + saux1.str() + "\n" ;
1555     }
1556     { std::stringstream saux1 ;
1557       saux1 << NumeZone << " " << x2 ;
1558       saux += "ZoRaYCen " + saux1.str() + "\n" ;
1559     }
1560     { std::stringstream saux1 ;
1561       saux1 << NumeZone << " " << x6 ;
1562       saux2 = saux1.str() ;
1563       if ( ZoneType == 62 ) { saux += "ZoRaRayE " + saux2 + "\n" ; }
1564       else                  { saux += "ZoRaRayo " + saux2 + "\n" ; }
1565     }
1566     if ( ZoneType == 62 )
1567     { std::stringstream saux1 ;
1568       saux1 << NumeZone << " " << x8 ;
1569       saux += "ZoRaRayI " + saux1.str() + "\n" ;
1570     }
1571   }
1572   else if ( ZoneType == 33 || ZoneType == 63 )
1573   {
1574     saux += "# Sphere\n" ;
1575     { std::stringstream saux1 ;
1576       saux1 << NumeZone << " " << x0 ;
1577       saux += "ZoRaXCen " + saux1.str() + "\n" ;
1578     }
1579     { std::stringstream saux1 ;
1580       saux1 << NumeZone << " " << x2 ;
1581       saux += "ZoRaYCen " + saux1.str() + "\n" ;
1582     }
1583     { std::stringstream saux1 ;
1584       saux1 << NumeZone << " " << x6 ;
1585       saux2 = saux1.str() ;
1586       if ( ZoneType == 63 ) { saux += "ZoRaRayE " + saux2 + "\n" ; }
1587       else                  { saux += "ZoRaRayo " + saux2 + "\n" ; }
1588     }
1589     if ( ZoneType == 63 )
1590     { std::stringstream saux1 ;
1591       saux1 << NumeZone << " " << x8 ;
1592       saux += "ZoRaRayI " + saux1.str() + "\n" ;
1593     }
1594   }
1595 //
1596 // Cas de la sphere
1597 //
1598   else if ( ZoneType == 4 )
1599   {
1600     saux += "# Sphere\n" ;
1601     { std::stringstream saux1 ;
1602       saux1 << NumeZone << " " << x0 ;
1603       saux += "ZoRaXCen " + saux1.str() + "\n" ;
1604     }
1605     { std::stringstream saux1 ;
1606       saux1 << NumeZone << " " << x1 ;
1607       saux += "ZoRaYCen " + saux1.str() + "\n" ;
1608     }
1609     { std::stringstream saux1 ;
1610       saux1 << NumeZone << " " << x2 ;
1611       saux += "ZoRaZCen " + saux1.str() + "\n" ;
1612     }
1613     { std::stringstream saux1 ;
1614       saux1 << NumeZone << " " << x3 ;
1615       saux += "ZoRaRayo " + saux1.str() + "\n" ;
1616     }
1617   }
1618 //
1619 // Cas du cylindre ou du tuyau
1620 //
1621   else if ( ZoneType == 5 || ZoneType == 7 )
1622   {
1623     if ( ZoneType == 5 ) { saux += "# Cylindre\n" ; }
1624     else                 { saux += "# Tuyau\n" ; }
1625     { std::stringstream saux1 ;
1626       saux1 << NumeZone << " " << x0 ;
1627       saux += "ZoRaXBas " + saux1.str() + "\n" ;
1628     }
1629     { std::stringstream saux1 ;
1630       saux1 << NumeZone << " " << x1 ;
1631       saux += "ZoRaYBas " + saux1.str() + "\n" ;
1632     }
1633     { std::stringstream saux1 ;
1634       saux1 << NumeZone << " " << x2 ;
1635       saux += "ZoRaZBas " + saux1.str() + "\n" ;
1636     }
1637     { std::stringstream saux1 ;
1638       saux1 << NumeZone << " " << x3 ;
1639       saux += "ZoRaXAxe " + saux1.str() + "\n" ;
1640     }
1641     { std::stringstream saux1 ;
1642       saux1 << NumeZone << " " << x4 ;
1643       saux += "ZoRaYAxe " + saux1.str() + "\n" ;
1644     }
1645     { std::stringstream saux1 ;
1646       saux1 << NumeZone << " " << x5 ;
1647       saux += "ZoRaZAxe " + saux1.str() + "\n" ;
1648     }
1649     { std::stringstream saux1 ;
1650       saux1 << NumeZone << " " << x6 ;
1651       saux2 = saux1.str() ;
1652      if ( ZoneType == 5 ) { saux += "ZoRaRayo " + saux2 + "\n" ; }
1653      else                 { saux += "ZoRaRayE " + saux2 + "\n" ; }
1654     }
1655     { std::stringstream saux1 ;
1656       saux1 << NumeZone << " " << x7 ;
1657       saux += "ZoRaHaut " + saux1.str() + "\n" ;
1658     }
1659     if ( ZoneType == 7 )
1660     { std::stringstream saux1 ;
1661       saux1 << NumeZone << " " << x8 ;
1662       saux += "ZoRaRayI " + saux1.str() + "\n" ;
1663     }
1664   }
1665 //
1666   _Texte += saux + "#\n" ;
1667 //
1668 //   MESSAGE("A la fin de HomardDriver::TexteZone, _Texte ="<<_Texte);
1669 }
1670 //===============================================================================
1671 void HomardDriver::TexteField( const std::string FieldName, const std::string FieldFile, int TimeStep, int Rank,
1672                int TypeThR, double ThreshR, int TypeThC, double ThreshC,
1673                int UsField, int UsCmpI )
1674 {
1675   MESSAGE("TexteField, FieldName = "<<FieldName<<", FieldFile = "<<FieldFile);
1676   MESSAGE("TexteField, TimeStep = "<<TimeStep<<", Rank = "<<Rank);
1677
1678   std::string saux, saux2 ;
1679 //
1680 //
1681   _Texte += "# Champ d'indicateurs\n" ;
1682   _Texte += "CCIndica \"" + FieldFile  + "\"\n" ;
1683   _Texte += "CCNoChaI \"" + FieldName  + "\"\n" ;
1684
1685 // Cas ou on prend le dernier pas de temps
1686   if ( TimeStep == -2 )
1687   { _Texte += "CCNumPTI Last\n" ; }
1688 // Cas avec pas de temps
1689   else if ( TimeStep >= 0 )
1690   {
1691     {
1692       std::stringstream saux1 ;
1693       saux1 << TimeStep ;
1694       saux2 = saux1.str() ;
1695       _Texte += "CCNumPTI " + saux2  + "\n" ;
1696     }
1697     if ( Rank >= 0 )
1698     {
1699       std::stringstream saux1 ;
1700       saux1 << Rank ;
1701       saux2 = saux1.str() ;
1702       _Texte += "CCNumOrI " + saux2  + "\n" ;
1703     }
1704   }
1705 //
1706   saux = " " ;
1707   if ( TypeThR == 1 )
1708   { saux = "Hau" ; }
1709   if ( TypeThR == 2 )
1710   { saux = "HRe" ; }
1711   if ( TypeThR == 3 )
1712   { saux = "HPE" ; }
1713   if ( TypeThR == 4 )
1714   { saux = "HMS" ; }
1715   if ( saux != " " )
1716   {
1717     std::stringstream saux1 ;
1718     saux1 << ThreshR ;
1719     _Texte += "Seuil" + saux + " " + saux1.str()  + "\n" ;
1720   }
1721 //
1722   saux = " " ;
1723   if ( TypeThC == 1 )
1724   { saux = "Bas" ; }
1725   if ( TypeThC == 2 )
1726   { saux = "BRe" ; }
1727   if ( TypeThC == 3 )
1728   { saux = "BPE" ; }
1729   if ( TypeThC == 4 )
1730   { saux = "BMS" ; }
1731   if ( saux != " " )
1732   {
1733     std::stringstream saux1 ;
1734     saux1 << ThreshC ;
1735     _Texte += "Seuil" + saux + " " + saux1.str()  + "\n" ;
1736   }
1737 //
1738   saux = " " ;
1739   if ( UsField == 0 )
1740   { saux = "MAILLE" ; }
1741   if ( UsField == 1 )
1742   { saux = "SAUT" ; }
1743   if ( saux != " " )
1744   {
1745     _Texte += "CCModeFI " + saux  + "\n" ;
1746   }
1747 //
1748   saux = " " ;
1749   if ( UsCmpI == 0 )
1750   { saux = "L2" ; }
1751   if ( UsCmpI == 1 )
1752   { saux = "INFINI" ; }
1753   if ( UsCmpI == 2 )
1754   { saux = "RELATIF" ; }
1755   if ( saux != " " )
1756   {
1757     _Texte += "CCUsCmpI " + saux  + "\n" ;
1758   }
1759 }
1760 //===============================================================================
1761 void HomardDriver::TexteGroup( const std::string GroupName )
1762 {
1763   MESSAGE("TexteGroup, GroupName = "<<GroupName);
1764 //
1765   _Texte += "CCGroAda \"" + GroupName  + "\"\n" ;
1766 //
1767 }
1768 //===============================================================================
1769 // D. Les frontieres
1770 //===============================================================================
1771 void HomardDriver::TexteBoundaryOption( int BoundaryOption )
1772 {
1773   MESSAGE("TexteBoundaryOption, BoundaryOption = "<<BoundaryOption);
1774 //
1775 // Type de suivi de frontiere
1776 //
1777   std::stringstream saux1 ;
1778   saux1 << BoundaryOption ;
1779   std::string saux = saux1.str() ;
1780   _Texte += "SuivFron " + saux + "\n" ;
1781 //
1782 }//===============================================================================
1783 void HomardDriver::TexteBoundaryCAOGr(  const std::string GroupName )
1784 {
1785   MESSAGE("TexteBoundaryCAOGr, GroupName  = "<<GroupName);
1786 //
1787   _Texte += "GrFroCAO \"" + GroupName + "\"\n" ;
1788 //
1789 }
1790
1791 //===============================================================================
1792 void HomardDriver::TexteBoundaryDi(  const std::string MeshName, const std::string MeshFile )
1793 {
1794   MESSAGE("TexteBoundaryDi, MeshName  = "<<MeshName);
1795   MESSAGE("TexteBoundaryDi, MeshFile  = "<<MeshFile);
1796 //
1797   _Texte += "#\n# Frontiere discrete\n" ;
1798   _Texte += "CCNoMFro \"" + MeshName + "\"\n" ;
1799   _Texte += "CCFronti \"" + MeshFile + "\"\n" ;
1800 //
1801 }
1802 //===============================================================================
1803 void HomardDriver::TexteBoundaryDiGr(  const std::string GroupName )
1804 {
1805   MESSAGE("TexteBoundaryDiGr, GroupName  = "<<GroupName);
1806 //
1807   _Texte += "CCGroFro \"" + GroupName + "\"\n" ;
1808 //
1809 }
1810 //===============================================================================
1811 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 )
1812 {
1813   MESSAGE("TexteBoundaryAn, NameBoundary = "<<NameBoundary);
1814 //   MESSAGE("TexteBoundaryAn, NumeBoundary = "<<NumeBoundary);
1815   MESSAGE("TexteBoundaryAn, BoundaryType = "<<BoundaryType);
1816 //   MESSAGE("TexteBoundaryAn, coor         = "<< x0<<","<<x1<< ","<< x2<< ","<< x3<<","<<x4<<","<<x5<<","<<x6","<<x7);
1817 //
1818   std::string saux, saux2 ;
1819 //
1820 // Commentaires
1821 //
1822   std::stringstream saux1 ;
1823   saux1 << NumeBoundary ;
1824   saux2 = saux1.str() ;
1825   saux = "#\n# Frontiere numero " + saux2 + "\n" ;
1826   if ( BoundaryType == 1 )
1827   { saux += "# Cylindre\n" ; }
1828   if ( BoundaryType == 2 )
1829   { saux += "# Sphere\n" ; }
1830   if ( BoundaryType == 3 || BoundaryType == 4 )
1831   { saux += "# Cone\n" ; }
1832   if ( BoundaryType == 5 )
1833   { saux += "# Tore\n" ; }
1834 //
1835 // Le nom de la frontiere
1836 //
1837   { std::stringstream saux1 ;
1838     saux1 << NumeBoundary ;
1839     saux += "FANom " + saux1.str() + " \"" + NameBoundary + "\"\n" ;
1840   }
1841 //
1842 // Type de frontiere
1843 //
1844   { std::stringstream saux1 ;
1845     saux1 << NumeBoundary << " " << BoundaryType ;
1846     saux += "FAType " + saux1.str() + "\n" ;
1847   }
1848 //
1849 // Cas du cylindre
1850 //
1851   if ( BoundaryType == 1 )
1852   {
1853     { std::stringstream saux1 ;
1854       saux1 << NumeBoundary << " " << x0 ;
1855       saux2 = saux1.str() ;
1856       saux += "FAXCen " + saux1.str() + "\n" ;
1857     }
1858     { std::stringstream saux1 ;
1859       saux1 << NumeBoundary << " " << x1 ;
1860       saux += "FAYCen " + saux1.str() + "\n" ;
1861     }
1862     { std::stringstream saux1 ;
1863       saux1 << NumeBoundary << " " << x2 ;
1864       saux += "FAZCen " + saux1.str() + "\n" ;
1865     }
1866     { std::stringstream saux1 ;
1867       saux1 << NumeBoundary << " " << x3 ;
1868       saux += "FAXAxe " + saux1.str() + "\n" ;
1869     }
1870     { std::stringstream saux1 ;
1871       saux1 << NumeBoundary << " " << x4 ;
1872       saux += "FAYAxe " + saux1.str() + "\n" ;
1873     }
1874     { std::stringstream saux1 ;
1875       saux1 << NumeBoundary << " " << x5 ;
1876       saux += "FAZAxe " + saux1.str() + "\n" ;
1877     }
1878     { std::stringstream saux1 ;
1879       saux1 << NumeBoundary << " " << x6 ;
1880       saux += "FARayon " + saux1.str() + "\n" ;
1881     }
1882  }
1883 //
1884 // Cas de la sphere
1885 //
1886   else if ( BoundaryType == 2 )
1887   {
1888     { std::stringstream saux1 ;
1889       saux1 << NumeBoundary << " " << x0 ;
1890       saux += "FAXCen " + saux1.str() + "\n" ;
1891     }
1892     { std::stringstream saux1 ;
1893       saux1 << NumeBoundary << " " << x1 ;
1894       saux += "FAYCen " + saux1.str() + "\n" ;
1895     }
1896     { std::stringstream saux1 ;
1897       saux1 << NumeBoundary << " " << x2 ;
1898       saux += "FAZCen " + saux1.str() + "\n" ;
1899     }
1900     { std::stringstream saux1 ;
1901       saux1 << NumeBoundary << " " << x3 ;
1902       saux += "FARayon " + saux1.str() + "\n" ;
1903     }
1904   }
1905 //
1906 // Cas du cone defini par un axe et un angle
1907 //
1908   if ( BoundaryType == 3 )
1909   {
1910     { std::stringstream saux1 ;
1911       saux1 << NumeBoundary << " " << x0 ;
1912       saux += "FAXAxe " + saux1.str() + "\n" ;
1913     }
1914     { std::stringstream saux1 ;
1915       saux1 << NumeBoundary << " " << x1 ;
1916       saux += "FAYAxe " + saux1.str() + "\n" ;
1917     }
1918     { std::stringstream saux1 ;
1919       saux1 << NumeBoundary << " " << x2 ;
1920       saux += "FAZAxe " + saux1.str() + "\n" ;
1921     }
1922     { std::stringstream saux1 ;
1923       saux1 << NumeBoundary << " " << x3 ;
1924       saux += "FAAngle " + saux1.str() + "\n" ;
1925     }
1926     { std::stringstream saux1 ;
1927       saux1 << NumeBoundary << " " << x4 ;
1928       saux += "FAXCen " + saux1.str() + "\n" ;
1929     }
1930     { std::stringstream saux1 ;
1931       saux1 << NumeBoundary << " " << x5 ;
1932       saux += "FAYCen " + saux1.str() + "\n" ;
1933     }
1934     { std::stringstream saux1 ;
1935       saux1 << NumeBoundary << " " << x6 ;
1936       saux += "FAZCen " + saux1.str() + "\n" ;
1937     }
1938  }
1939 //
1940 // Cas du cone defini par les 2 rayons
1941 //
1942   if ( BoundaryType == 4 )
1943   {
1944     { std::stringstream saux1 ;
1945       saux1 << NumeBoundary << " " << x0 ;
1946       saux += "FAXCen " + saux1.str() + "\n" ;
1947     }
1948     { std::stringstream saux1 ;
1949       saux1 << NumeBoundary << " " << x1 ;
1950       saux += "FAYCen " + saux1.str() + "\n" ;
1951     }
1952     { std::stringstream saux1 ;
1953       saux1 << NumeBoundary << " " << x2 ;
1954       saux += "FAZCen " + saux1.str() + "\n" ;
1955     }
1956     { std::stringstream saux1 ;
1957       saux1 << NumeBoundary << " " << x3 ;
1958       saux += "FARayon " + saux1.str() + "\n" ;
1959     }
1960     { std::stringstream saux1 ;
1961       saux1 << NumeBoundary << " " << x4 ;
1962       saux += "FAXCen2 " + saux1.str() + "\n" ;
1963     }
1964     { std::stringstream saux1 ;
1965       saux1 << NumeBoundary << " " << x5 ;
1966       saux += "FAYCen2 " + saux1.str() + "\n" ;
1967     }
1968     { std::stringstream saux1 ;
1969       saux1 << NumeBoundary << " " << x6 ;
1970       saux += "FAZCen2 " + saux1.str() + "\n" ;
1971     }
1972     { std::stringstream saux1 ;
1973       saux1 << NumeBoundary << " " << x7 ;
1974       saux += "FARayon2 " + saux1.str() + "\n" ;
1975     }
1976  }
1977 //
1978 // Cas du tore
1979 //
1980   if ( BoundaryType == 5 )
1981   {
1982     { std::stringstream saux1 ;
1983       saux1 << NumeBoundary << " " << x0 ;
1984       saux2 = saux1.str() ;
1985       saux += "FAXCen " + saux1.str() + "\n" ;
1986     }
1987     { std::stringstream saux1 ;
1988       saux1 << NumeBoundary << " " << x1 ;
1989       saux += "FAYCen " + saux1.str() + "\n" ;
1990     }
1991     { std::stringstream saux1 ;
1992       saux1 << NumeBoundary << " " << x2 ;
1993       saux += "FAZCen " + saux1.str() + "\n" ;
1994     }
1995     { std::stringstream saux1 ;
1996       saux1 << NumeBoundary << " " << x3 ;
1997       saux += "FAXAxe " + saux1.str() + "\n" ;
1998     }
1999     { std::stringstream saux1 ;
2000       saux1 << NumeBoundary << " " << x4 ;
2001       saux += "FAYAxe " + saux1.str() + "\n" ;
2002     }
2003     { std::stringstream saux1 ;
2004       saux1 << NumeBoundary << " " << x5 ;
2005       saux += "FAZAxe " + saux1.str() + "\n" ;
2006     }
2007     { std::stringstream saux1 ;
2008       saux1 << NumeBoundary << " " << x6 ;
2009       saux += "FARayon  " + saux1.str() + "\n" ;
2010     }
2011     { std::stringstream saux1 ;
2012       saux1 << NumeBoundary << " " << x7 ;
2013       saux += "FARayon2 " + saux1.str() + "\n" ;
2014     }
2015  }
2016 //
2017   _Texte += saux + "#\n" ;
2018 //
2019 }
2020 //===============================================================================
2021 void HomardDriver::TexteBoundaryAnGr( const std::string NameBoundary, int NumeBoundary, const std::string GroupName )
2022 {
2023   MESSAGE("TexteBoundaryAnGr, NameBoundary  = "<<NameBoundary);
2024 //   MESSAGE("TexteBoundaryAnGr, NumeBoundary  = "<<NumeBoundary);
2025 //   MESSAGE("TexteBoundaryAnGr, GroupName  = "<<GroupName);
2026 //
2027 // Commentaires
2028 //
2029   std::string saux, saux2 ;
2030   std::stringstream saux1 ;
2031   saux1 << NumeBoundary ;
2032   saux2 = saux1.str() ;
2033   saux = "#\n# Lien Frontiere/Groupe numero " + saux2 + "\n" ;
2034 //
2035   saux += "FGNomFro " + saux2 + " \"" + NameBoundary + "\"\n" ;
2036   saux += "FGNomGro " + saux2 + " \"" + GroupName + "\"\n" ;
2037 //
2038   _Texte += saux + "#\n" ;
2039 //
2040 }
2041 //===============================================================================
2042 // E. Les interpolations
2043 //===============================================================================
2044 // Les fichiers d'entree et de sortie des champs a interpoler
2045 void HomardDriver::TexteFieldInterp( const std::string FieldFile, const std::string MeshFile )
2046 {
2047   MESSAGE("TexteFieldInterp, FieldFile = "<<FieldFile<<", MeshFile = "<<MeshFile);
2048 //
2049   _Texte += "#\n# Interpolations des champs\n" ;
2050 //
2051 // Fichier en entree
2052   _Texte += "CCSolN__ \"" + FieldFile + "\"\n" ;
2053 // Fichier en sortie
2054   _Texte += "CCSolNP1 \"" + MeshFile  + "\"\n" ;
2055 //
2056 //  std::cerr << "A la fin de TexteFieldInterp _Texte ="<<_Texte << std::endl;
2057 }
2058 //===============================================================================
2059 // Tous les champs sont a interpoler
2060 void HomardDriver::TexteFieldInterpAll( )
2061 {
2062   MESSAGE("TexteFieldInterpAll");
2063 //
2064   _Texte += "CCChaTou oui\n" ;
2065 }
2066 //===============================================================================
2067 // Ecrit les caracteristiques de chaque interpolation sous la forme :
2068 //   CCChaNom 1 "DEPL"     ! Nom du 1er champ a interpoler
2069 //   CCChaTIn 1 0          ! Mode d'interpolation : automatique
2070 //   CCChaNom 2 "VOLUME"   ! Nom du 2nd champ a interpoler
2071 //   CCChaTIn 2 1          ! Mode d'interpolation : une variable extensive
2072 //   CCChaPdT 2 14         ! Pas de temps 14
2073 //   CCChaNuO 2 14         ! Numero d'ordre 14
2074 //   etc.
2075 //
2076 // NumeChamp : numero d'ordre du champ a interpoler
2077 // FieldName : nom du champ
2078 // TypeInterp : type d'interpolation
2079 // TimeStep : pas de temps retenu (>0 si pas de precision)
2080 // Rank : numero d'ordre retenu
2081 //
2082 void HomardDriver::TexteFieldInterpNameType( int NumeChamp, const std::string FieldName, const std::string TypeInterp, int TimeStep, int Rank)
2083 {
2084   MESSAGE("TexteFieldInterpNameType, NumeChamp = "<<NumeChamp<<", FieldName = "<<FieldName<<", TypeInterp = "<<TypeInterp);
2085   MESSAGE("TexteFieldInterpNameType, TimeStep = "<<TimeStep<<", Rank = "<<Rank);
2086 // Numero d'ordre du champ a interpoler
2087   std::stringstream saux1 ;
2088   saux1 << NumeChamp ;
2089   std::string saux = saux1.str() ;
2090 // Nom du champ
2091   _Texte +="CCChaNom " + saux + " \"" + FieldName + "\"\n" ;
2092 // Type d'interpolation pour le champ
2093   _Texte +="CCChaTIn " + saux + " " + TypeInterp + "\n" ;
2094 //
2095   if ( TimeStep >= 0 )
2096   {
2097     {
2098       std::stringstream saux1 ;
2099       saux1 << TimeStep ;
2100       _Texte += "CCChaPdT " + saux + " " + saux1.str()  + "\n" ;
2101     }
2102     {
2103       std::stringstream saux1 ;
2104       saux1 << Rank ;
2105       _Texte += "CCChaNuO " + saux + " " + saux1.str()  + "\n" ;
2106     }
2107   }
2108 }
2109 //===============================================================================
2110 // F. Les options avancees
2111 //===============================================================================
2112 void HomardDriver::TexteAdvanced( int NivMax, double DiamMin, int AdapInit, int ExtraOutput )
2113 {
2114   MESSAGE("TexteAdvanced, NivMax ="<<NivMax<<", DiamMin ="<<DiamMin<<", AdapInit ="<<AdapInit<<", ExtraOutput ="<<ExtraOutput);
2115
2116   if ( NivMax > 0 )
2117   {
2118     _Texte += "# Niveaux extremes\n" ;
2119     { std::stringstream saux1 ;
2120       saux1 << NivMax ;
2121       _Texte += "NiveauMa " + saux1.str() + "\n" ;
2122     }
2123   }
2124   if ( DiamMin > 0 )
2125   {
2126     _Texte += "# Diametre minimal\n" ;
2127     { std::stringstream saux1 ;
2128       saux1 << DiamMin ;
2129       _Texte += "DiametMi " + saux1.str()  + "\n" ;
2130     }
2131   }
2132   if ( AdapInit != 0 )
2133   {
2134     if ( AdapInit > 0 )
2135     { _Texte += "# Raffinement" ; }
2136     else
2137     { _Texte += "# Deraffinement" ; }
2138     _Texte += " des regions sans indicateur\n" ;
2139     { std::stringstream saux1 ;
2140       saux1 << AdapInit ;
2141       _Texte += "AdapInit " + saux1.str() + "\n" ;
2142     }
2143   }
2144   if ( ExtraOutput % 2 == 0 )
2145   {
2146     _Texte += "# Sortie des niveaux de raffinement\n" ;
2147     _Texte += "NCNiveau NIVEAU\n" ;
2148   }
2149   if ( ExtraOutput % 3 == 0 )
2150   {
2151     _Texte += "# Sortie des qualités des mailles\n" ;
2152     _Texte += "NCQualit QUAL\n" ;
2153   }
2154   if ( ExtraOutput % 5 == 0 )
2155   {
2156     _Texte += "# Sortie des diamètres des mailles\n" ;
2157     _Texte += "NCDiamet DIAM\n" ;
2158   }
2159   if ( ExtraOutput % 7 == 0 )
2160   {
2161     _Texte += "# Sortie des parents des mailles\n" ;
2162     _Texte += "NCParent PARENT\n" ;
2163   }
2164   if ( ExtraOutput % 11 == 0 )
2165   {
2166     _Texte += "# Volumes voisins par recollement\n" ;
2167     _Texte += "NCVoisRc Voisin-Recollement\n" ;
2168   }
2169 }
2170 //===============================================================================
2171 // G. Les messages
2172 //===============================================================================
2173 void HomardDriver::TexteInfoCompute( int MessInfo )
2174 {
2175   MESSAGE("TexteAdvanced, MessInfo ="<<MessInfo);
2176
2177   if ( MessInfo != 0 )
2178   {
2179      _Texte += "# Messages d'informations\n" ;
2180     { std::stringstream saux1 ;
2181       saux1 << MessInfo ;
2182       _Texte += "MessInfo " + saux1.str()  + "\n" ;
2183     }
2184    }
2185 }
2186 //===============================================================================
2187 void HomardDriver::CreeFichier( )
2188 {
2189 //
2190   if ( _modeHOMARD == 1 )
2191   { _NomFichierConf = _NomFichierConfBase + "." + _siter + ".vers." + _siterp1 ; }
2192   else if ( _modeHOMARD == 2 )
2193   { _NomFichierConf = _NomFichierConfBase + "." + _siter + ".info" ; }
2194   else if ( _modeHOMARD == 5 )
2195   { _NomFichierConf = _NomFichierConfBase + ".majc" ; }
2196 //
2197   std::ofstream Fic(_NomFichierConf.c_str(), std::ios::out ) ;
2198   if (Fic.is_open() == true) { Fic << _Texte << std::endl ; }
2199   Fic.close() ;
2200 //
2201 }
2202 //===============================================================================
2203 // Creation du fichier de donnees pour l'information
2204 //===============================================================================
2205 void HomardDriver::CreeFichierDonn( )
2206 {
2207 //
2208   MESSAGE("CreeFichierDonn");
2209   _NomFichierDonn = "info.donn" ;
2210 //
2211   std::string data ;
2212   data  = "0\n" ;
2213   data += "0\n" ;
2214   data += "q\n" ;
2215   std::ofstream Fic(_NomFichierDonn.c_str(), std::ios::out ) ;
2216   if (Fic.is_open() == true) { Fic << data << std::endl ; }
2217   Fic.close() ;
2218 //
2219 }
2220 //===============================================================================
2221 int HomardDriver::ExecuteHomard()
2222 {
2223   MESSAGE("ExecuteHomard");
2224   std::string commande ;
2225   int codret ;
2226   // Copie des Fichiers HOMARD
2227   commande = "cp " + _NomFichierConf + " " + _NomFichierConfBase ;
2228   codret = system(commande.c_str()) ;
2229
2230 // Execution de HOMARD
2231   if ( codret == 0)
2232   {
2233     commande = _HOMARD_Exec.c_str() ;
2234     if ( _NomFichierDonn != "" ) { commande += " < " + _NomFichierDonn ; }
2235     codret = system(commande.c_str());
2236     if ( codret != 0) { MESSAGE ( "Erreur en executant HOMARD : " << codret ); };
2237     _NomFichierDonn = "" ;
2238   };
2239   return codret ;
2240 }
2241
2242 //=============================================================================
2243 //=============================================================================
2244 HOMARD_Gen::HOMARD_Gen()
2245 {
2246   MESSAGE("HOMARD_Gen");
2247 }
2248
2249 //=============================================================================
2250 //=============================================================================
2251 HOMARD_Gen::~HOMARD_Gen()
2252 {
2253   MESSAGE("~HOMARD_Gen");
2254 }
2255 //=============================================================================
2256
2257 //=============================================================================
2258 /*!
2259  *  default constructor:
2260  */
2261 //=============================================================================
2262 HOMARD_Hypothesis::HOMARD_Hypothesis():
2263   _Name(""), _NomCasCreation(""),
2264   _TypeAdap(-1), _TypeRaff(0), _TypeDera(0),
2265   _Field(""),
2266   _TypeThR(0), _TypeThC(0),
2267   _ThreshR(0), _ThreshC(0),
2268   _UsField(0), _UsCmpI(0), _TypeFieldInterp(0),
2269
2270   _NivMax(-1), _DiamMin(-1.0), _AdapInit(0), _ExtraOutput(1)
2271 {
2272   MESSAGE("HOMARD_Hypothesis");
2273 }
2274
2275 //=============================================================================
2276 /*!
2277  */
2278 //=============================================================================
2279 HOMARD_Hypothesis::~HOMARD_Hypothesis()
2280 {
2281   MESSAGE("~HOMARD_Hypothesis");
2282 }
2283 //=============================================================================
2284 //=============================================================================
2285 // Generalites
2286 //=============================================================================
2287 //=============================================================================
2288 void HOMARD_Hypothesis::SetName( const char* Name )
2289 {
2290   _Name = std::string( Name );
2291 }
2292 //=============================================================================
2293 std::string HOMARD_Hypothesis::GetName() const
2294 {
2295   return _Name;
2296 }
2297 //=============================================================================
2298 //=============================================================================
2299 // Caracteristiques
2300 //=============================================================================
2301 //=============================================================================
2302 void HOMARD_Hypothesis::SetAdapType( int TypeAdap )
2303 {
2304   VERIFICATION( (TypeAdap>=-1) && (TypeAdap<=1) );
2305   _TypeAdap = TypeAdap;
2306 }
2307 //=============================================================================
2308 int HOMARD_Hypothesis::GetAdapType() const
2309 {
2310   return _TypeAdap;
2311 }
2312 //=============================================================================
2313 void HOMARD_Hypothesis::SetRefinTypeDera( int TypeRaff, int TypeDera )
2314 {
2315   VERIFICATION( (TypeRaff>=-1) && (TypeRaff<=1) );
2316   _TypeRaff = TypeRaff;
2317   VERIFICATION( (TypeDera>=-1) && (TypeDera<=1) );
2318   _TypeDera = TypeDera;
2319 }
2320 //=============================================================================
2321 int HOMARD_Hypothesis::GetRefinType() const
2322 {
2323   return _TypeRaff;
2324 }
2325 //=============================================================================
2326 int HOMARD_Hypothesis::GetUnRefType() const
2327 {
2328   return _TypeDera;
2329 }
2330 //=============================================================================
2331 void HOMARD_Hypothesis::SetField( const char* FieldName )
2332 {
2333   _Field = std::string( FieldName );
2334   MESSAGE( "SetField : FieldName = " << FieldName );
2335 }
2336 //=============================================================================
2337 std::string HOMARD_Hypothesis::GetFieldName() const
2338 {
2339   return _Field;
2340 }
2341 //=============================================================================
2342 void HOMARD_Hypothesis::SetUseField( int UsField )
2343 {
2344   VERIFICATION( (UsField>=0) && (UsField<=1) );
2345   _UsField = UsField;
2346 }
2347 //=============================================================================
2348 int HOMARD_Hypothesis::GetUseField() const
2349 {
2350   return _UsField;
2351 }
2352 //=============================================================================
2353 void HOMARD_Hypothesis::SetUseComp( int UsCmpI )
2354 {
2355   MESSAGE ("SetUseComp pour UsCmpI = "<<UsCmpI) ;
2356   VERIFICATION( (UsCmpI>=0) && (UsCmpI<=2) );
2357   _UsCmpI = UsCmpI;
2358 }
2359 //=============================================================================
2360 int HOMARD_Hypothesis::GetUseComp() const
2361 {
2362   return _UsCmpI;
2363 }
2364 //=============================================================================
2365 void HOMARD_Hypothesis::AddComp( const char* NomComp )
2366 {
2367 // On commence par supprimer la composante au cas ou elle aurait deja ete inseree
2368 // Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la
2369 // definition de l'hypothese
2370   SupprComp( NomComp ) ;
2371 // Insertion veritable
2372   _ListComp.push_back( std::string( NomComp ) );
2373 }
2374 //=============================================================================
2375 void HOMARD_Hypothesis::SupprComp( const char* NomComp )
2376 {
2377   MESSAGE ("SupprComp pour "<<NomComp) ;
2378   std::list<std::string>::iterator it = find( _ListComp.begin(), _ListComp.end(), NomComp );
2379   if ( it != _ListComp.end() ) { it = _ListComp.erase( it ); }
2380 }
2381 //=============================================================================
2382 void HOMARD_Hypothesis::SupprComps()
2383 {
2384   _ListComp.clear();
2385 }
2386 //=============================================================================
2387 const std::list<std::string>& HOMARD_Hypothesis::GetComps() const
2388 {
2389   return _ListComp;
2390 }
2391 //=============================================================================
2392 void HOMARD_Hypothesis::SetRefinThr( int TypeThR, double ThreshR )
2393 {
2394   MESSAGE( "SetRefinThr : TypeThR = " << TypeThR << ", ThreshR = " << ThreshR );
2395   VERIFICATION( (TypeThR>=0) && (TypeThR<=4) );
2396   _TypeThR = TypeThR;
2397   _ThreshR = ThreshR;
2398 }
2399 //=============================================================================
2400 int HOMARD_Hypothesis::GetRefinThrType() const
2401 {
2402   return _TypeThR;
2403 }
2404 //=============================================================================
2405 double HOMARD_Hypothesis::GetThreshR() const
2406 {
2407   return _ThreshR;
2408 }
2409 //=============================================================================
2410 void HOMARD_Hypothesis::SetUnRefThr( int TypeThC, double ThreshC )
2411 {
2412   VERIFICATION( (TypeThC>=0) && (TypeThC<=4) );
2413   _TypeThC = TypeThC;
2414   _ThreshC = ThreshC;
2415 }
2416 //=============================================================================
2417 int HOMARD_Hypothesis::GetUnRefThrType() const
2418 {
2419   return _TypeThC;
2420 }
2421 //=============================================================================
2422 double HOMARD_Hypothesis::GetThreshC() const
2423 {
2424   return _ThreshC;
2425 }
2426 //=============================================================================
2427 void HOMARD_Hypothesis::SetNivMax( int NivMax )
2428 //=============================================================================
2429 {
2430   _NivMax = NivMax;
2431 }
2432 //=============================================================================
2433 const int HOMARD_Hypothesis::GetNivMax() const
2434 //=============================================================================
2435 {
2436   return _NivMax;
2437 }
2438 //=============================================================================
2439 void HOMARD_Hypothesis::SetDiamMin( double DiamMin )
2440 //=============================================================================
2441 {
2442   _DiamMin = DiamMin;
2443 }
2444 //=============================================================================
2445 const double HOMARD_Hypothesis::GetDiamMin() const
2446 //=============================================================================
2447 {
2448   return _DiamMin;
2449 }
2450 //=============================================================================
2451 void HOMARD_Hypothesis::SetAdapInit( int AdapInit )
2452 //=============================================================================
2453 {
2454   _AdapInit = AdapInit;
2455 }
2456 //=============================================================================
2457 const int HOMARD_Hypothesis::GetAdapInit() const
2458 //=============================================================================
2459 {
2460   return _AdapInit;
2461 }
2462 //=============================================================================
2463 void HOMARD_Hypothesis::SetExtraOutput( int ExtraOutput )
2464 //=============================================================================
2465 {
2466   _ExtraOutput = ExtraOutput;
2467 }
2468 //=============================================================================
2469 const int HOMARD_Hypothesis::GetExtraOutput() const
2470 //=============================================================================
2471 {
2472   return _ExtraOutput;
2473 }
2474 //=============================================================================
2475 void HOMARD_Hypothesis::AddGroup( const char* Group)
2476 {
2477 // On commence par supprimer le groupe au cas ou il aurait deja ete insere
2478 // Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la
2479 // definition de l'hypothese
2480   SupprGroup( Group ) ;
2481 // Insertion veritable
2482   _ListGroupSelected.push_back(Group);
2483 }
2484 //=============================================================================
2485 void HOMARD_Hypothesis::SupprGroup( const char* Group )
2486 {
2487   MESSAGE ("SupprGroup pour "<<Group) ;
2488   std::list<std::string>::iterator it = find( _ListGroupSelected.begin(), _ListGroupSelected.end(), Group );
2489   if ( it != _ListGroupSelected.end() ) { it = _ListGroupSelected.erase( it ); }
2490 }
2491 //=============================================================================
2492 void HOMARD_Hypothesis::SupprGroups()
2493 {
2494   _ListGroupSelected.clear();
2495 }
2496 //=============================================================================
2497 void HOMARD_Hypothesis::SetGroups( const std::list<std::string>& ListGroup )
2498 {
2499   _ListGroupSelected.clear();
2500   std::list<std::string>::const_iterator it = ListGroup.begin();
2501   while(it != ListGroup.end())
2502     _ListGroupSelected.push_back((*it++));
2503 }
2504 //=============================================================================
2505 const std::list<std::string>& HOMARD_Hypothesis::GetGroups() const
2506 {
2507   return _ListGroupSelected;
2508 }
2509 //=============================================================================
2510 // Type d'interpolation des champs :
2511 //   0 : aucun champ n'est interpole
2512 //   1 : tous les champs sont interpoles
2513 //   2 : certains champs sont interpoles
2514 void HOMARD_Hypothesis::SetTypeFieldInterp( int TypeFieldInterp )
2515 {
2516   VERIFICATION( (TypeFieldInterp>=0) && (TypeFieldInterp<=2) );
2517   _TypeFieldInterp = TypeFieldInterp;
2518 }
2519 //=============================================================================
2520 int HOMARD_Hypothesis::GetTypeFieldInterp() const
2521 {
2522   return _TypeFieldInterp;
2523 }
2524 //=============================================================================
2525 void HOMARD_Hypothesis::AddFieldInterpType( const char* FieldInterp, int TypeInterp )
2526 {
2527   MESSAGE ("Dans AddFieldInterpType pour " << FieldInterp << " et TypeInterp = " << TypeInterp) ;
2528 // On commence par supprimer le champ au cas ou il aurait deja ete insere
2529 // Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la
2530 // definition de l'hypothese
2531   SupprFieldInterp( FieldInterp ) ;
2532 // Insertion veritable
2533 // . Nom du champ
2534   _ListFieldInterp.push_back( std::string( FieldInterp ) );
2535 // . Usage du champ
2536   std::stringstream saux1 ;
2537   saux1 << TypeInterp ;
2538   _ListFieldInterp.push_back( saux1.str() );
2539 // . Indication generale : certains champs sont a interpoler
2540   SetTypeFieldInterp ( 2 ) ;
2541 }
2542 //=============================================================================
2543 void HOMARD_Hypothesis::SupprFieldInterp( const char* FieldInterp )
2544 {
2545   MESSAGE ("Dans SupprFieldInterp pour " << FieldInterp) ;
2546   std::list<std::string>::iterator it = find( _ListFieldInterp.begin(), _ListFieldInterp.end(), FieldInterp ) ;
2547 // Attention a supprimer le nom du champ et le type d'usage
2548   if ( it != _ListFieldInterp.end() )
2549   {
2550     it = _ListFieldInterp.erase( it ) ;
2551     it = _ListFieldInterp.erase( it ) ;
2552   }
2553 // Decompte du nombre de champs restant a interpoler
2554   it = _ListFieldInterp.begin() ;
2555   int cpt = 0 ;
2556   while(it != _ListFieldInterp.end())
2557   {
2558     cpt += 1 ;
2559     (*it++);
2560   }
2561   MESSAGE("Nombre de champ restants = "<<cpt/2);
2562 // . Indication generale : aucun champ ne reste a interpoler
2563   if ( cpt == 0 )
2564   {
2565     SetTypeFieldInterp ( 0 ) ;
2566   }
2567 }
2568 //=============================================================================
2569 void HOMARD_Hypothesis::SupprFieldInterps()
2570 {
2571   MESSAGE ("SupprFieldInterps") ;
2572   _ListFieldInterp.clear();
2573 // . Indication generale : aucun champ ne reste a interpoler
2574   SetTypeFieldInterp ( 0 ) ;
2575 }
2576 //=============================================================================
2577 const std::list<std::string>& HOMARD_Hypothesis::GetFieldInterps() const
2578 {
2579   return _ListFieldInterp;
2580 }
2581 //=============================================================================
2582 //=============================================================================
2583 // Liens avec les autres structures
2584 //=============================================================================
2585 //=============================================================================
2586 void HOMARD_Hypothesis::SetCaseCreation( const char* NomCasCreation )
2587 {
2588   _NomCasCreation = std::string( NomCasCreation );
2589 }
2590 //=============================================================================
2591 std::string HOMARD_Hypothesis::GetCaseCreation() const
2592 {
2593   return _NomCasCreation;
2594 }
2595 //=============================================================================
2596 void HOMARD_Hypothesis::LinkIteration( const char* NomIteration )
2597 {
2598   _ListIter.push_back( std::string( NomIteration ) );
2599 }
2600 //=============================================================================
2601 void HOMARD_Hypothesis::UnLinkIteration( const char* NomIteration )
2602 {
2603   std::list<std::string>::iterator it = find( _ListIter.begin(), _ListIter.end(), NomIteration ) ;
2604   if ( it != _ListIter.end() )
2605   {
2606     MESSAGE ("Dans UnLinkIteration pour " << NomIteration) ;
2607     it = _ListIter.erase( it ) ;
2608   }
2609 }
2610 //=============================================================================
2611 void HOMARD_Hypothesis::UnLinkIterations()
2612 {
2613   _ListIter.clear();
2614 }
2615 //=============================================================================
2616 const std::list<std::string>& HOMARD_Hypothesis::GetIterations() const
2617 {
2618   return _ListIter;
2619 }
2620 //=============================================================================
2621 void HOMARD_Hypothesis::AddZone( const char* NomZone, int TypeUse )
2622 {
2623   MESSAGE ("Dans AddZone pour " << NomZone << " et TypeUse = " << TypeUse) ;
2624 // On commence par supprimer la zone au cas ou elle aurait deja ete inseree
2625 // Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la
2626 // definition de l'hypothese
2627   SupprZone( NomZone ) ;
2628 // Insertion veritable
2629 // . Nom de la zone
2630   _ListZone.push_back( std::string( NomZone ) );
2631 // . Usage de la zone
2632   std::stringstream saux1 ;
2633   saux1 << TypeUse ;
2634   _ListZone.push_back( saux1.str() );
2635 }
2636 //=============================================================================
2637 void HOMARD_Hypothesis::SupprZone( const char* NomZone )
2638 {
2639   MESSAGE ("Dans SupprZone pour " << NomZone) ;
2640   std::list<std::string>::iterator it = find( _ListZone.begin(), _ListZone.end(), NomZone );
2641 // Attention a supprimer le nom de zone et le type d'usage
2642   if ( it != _ListZone.end() )
2643   {
2644     it = _ListZone.erase( it );
2645     it = _ListZone.erase( it );
2646   }
2647 }
2648 //=============================================================================
2649 void HOMARD_Hypothesis::SupprZones()
2650 {
2651   _ListZone.clear();
2652 }
2653 //=============================================================================
2654 const std::list<std::string>& HOMARD_Hypothesis::GetZones() const
2655 {
2656   return _ListZone;
2657 }
2658
2659 //=============================================================================
2660 /*!
2661  *  default constructor:
2662  */
2663 //=============================================================================
2664 HOMARD_Iteration::HOMARD_Iteration():
2665   _Name( "" ), _Etat( 0 ),
2666  _NumIter( -1 ),
2667   _NomMesh( "" ), _MeshFile( "" ),
2668   _FieldFile( "" ), _TimeStep( -1 ), _Rank( -1 ),
2669   _LogFile( "" ),
2670   _IterParent( "" ),
2671   _NomHypo( "" ), _NomCas( "" ), _NomDir( "" ),
2672   _FileInfo( "" ),
2673  _MessInfo( 1 )
2674 {
2675   MESSAGE("HOMARD_Iteration");
2676 }
2677 //=============================================================================
2678 /*!
2679  *
2680  */
2681 //=============================================================================
2682 HOMARD_Iteration::~HOMARD_Iteration()
2683 {
2684   MESSAGE("~HOMARD_Iteration");
2685 }
2686 //=============================================================================
2687 //=============================================================================
2688 // Generalites
2689 //=============================================================================
2690 //=============================================================================
2691 void HOMARD_Iteration::SetName( const char* Name )
2692 {
2693   _Name = std::string( Name );
2694 }
2695 //=============================================================================
2696 std::string HOMARD_Iteration::GetName() const
2697 {
2698   return _Name;
2699 }
2700 //=============================================================================
2701 //=============================================================================
2702 // Caracteristiques
2703 //=============================================================================
2704 //=============================================================================
2705 void HOMARD_Iteration::SetDirNameLoc( const char* NomDir )
2706 {
2707   _NomDir = std::string( NomDir );
2708 }
2709 //=============================================================================
2710 std::string HOMARD_Iteration::GetDirNameLoc() const
2711 {
2712    return _NomDir;
2713 }
2714 //=============================================================================
2715 void HOMARD_Iteration::SetNumber( int NumIter )
2716 {
2717   _NumIter = NumIter;
2718 }
2719 //=============================================================================
2720 int HOMARD_Iteration::GetNumber() const
2721 {
2722   return _NumIter;
2723 }
2724 //=============================================================================
2725 void HOMARD_Iteration::SetState( int etat )
2726 {
2727   _Etat = etat;
2728 }
2729 //=============================================================================
2730 int HOMARD_Iteration::GetState() const
2731 {
2732   return _Etat;
2733 }
2734 //=============================================================================
2735 void HOMARD_Iteration::SetMeshName( const char* NomMesh )
2736 {
2737   _NomMesh = std::string( NomMesh );
2738 }
2739 //=============================================================================
2740 std::string HOMARD_Iteration::GetMeshName() const
2741 {
2742   return _NomMesh;
2743 }
2744 //=============================================================================
2745 void HOMARD_Iteration::SetMeshFile( const char* MeshFile )
2746 {
2747   _MeshFile = std::string( MeshFile );
2748 }
2749 //=============================================================================
2750 std::string HOMARD_Iteration::GetMeshFile() const
2751 {
2752   return _MeshFile;
2753 }
2754 //=============================================================================
2755 void HOMARD_Iteration::SetFieldFile( const char* FieldFile )
2756 {
2757   _FieldFile = std::string( FieldFile );
2758 }
2759 //=============================================================================
2760 std::string HOMARD_Iteration::GetFieldFile() const
2761 {
2762   return _FieldFile;
2763 }
2764 //=============================================================================
2765 // Instants pour le champ de pilotage
2766 //=============================================================================
2767 void HOMARD_Iteration::SetTimeStep( int TimeStep )
2768 {
2769   _TimeStep = TimeStep;
2770 }
2771 //=============================================================================
2772 void HOMARD_Iteration::SetTimeStepRank( int TimeStep, int Rank )
2773 {
2774   _TimeStep = TimeStep;
2775   _Rank = Rank;
2776 }
2777 //=============================================================================
2778 void HOMARD_Iteration::SetTimeStepRankLast()
2779 {
2780   _TimeStep = -2;
2781 }
2782 //=============================================================================
2783 int HOMARD_Iteration::GetTimeStep() const
2784 {
2785   return _TimeStep;
2786 }
2787 //=============================================================================
2788 int HOMARD_Iteration::GetRank() const
2789 {
2790   return _Rank;
2791 }
2792 //=============================================================================
2793 // Instants pour un champ a interpoler
2794 //=============================================================================
2795 void HOMARD_Iteration::SetFieldInterpTimeStep( const char* FieldInterp, int TimeStep )
2796 {
2797   SetFieldInterpTimeStepRank( FieldInterp, TimeStep, TimeStep ) ;
2798 }
2799 //=============================================================================
2800 void HOMARD_Iteration::SetFieldInterpTimeStepRank( const char* FieldInterp, int TimeStep, int Rank )
2801 {
2802   MESSAGE("Champ " << FieldInterp << ", hypothese " << _NomHypo )
2803 // Verification de la presence du champ dans l'hypothese
2804   std::list<std::string>::iterator it = find( _ListFieldInterp.begin(), _ListFieldInterp.end(), FieldInterp );
2805   if ( it == _ListFieldInterp.end() )
2806   {
2807     INFOS("Champ " << FieldInterp << " ; hypothese " << _NomHypo )
2808     VERIFICATION("Le champ est inconnu dans l'hypothese associee a cette iteration." == 0);
2809   }
2810
2811 // . Nom du champ
2812   _ListFieldInterpTSR.push_back( std::string( FieldInterp ) );
2813 // . Pas de temps
2814   std::stringstream saux1 ;
2815   saux1 << TimeStep ;
2816   _ListFieldInterpTSR.push_back( saux1.str() );
2817 // . Numero d'ordre
2818   std::stringstream saux2 ;
2819   saux2 << Rank ;
2820   _ListFieldInterpTSR.push_back( saux2.str() );
2821 }
2822 //=============================================================================
2823 const std::list<std::string>& HOMARD_Iteration::GetFieldInterpsTimeStepRank() const
2824 {
2825   return _ListFieldInterpTSR;
2826 }
2827 //=============================================================================
2828 void HOMARD_Iteration::SetFieldInterp( const char* FieldInterp )
2829 {
2830   _ListFieldInterp.push_back( std::string( FieldInterp ) );
2831 }
2832 //=============================================================================
2833 const std::list<std::string>& HOMARD_Iteration::GetFieldInterps() const
2834 {
2835   return _ListFieldInterp;
2836 }
2837 //=============================================================================
2838 void HOMARD_Iteration::SupprFieldInterps()
2839 {
2840   _ListFieldInterp.clear();
2841 }
2842 //=============================================================================
2843 void HOMARD_Iteration::SetLogFile( const char* LogFile )
2844 {
2845   _LogFile = std::string( LogFile );
2846 }
2847 //=============================================================================
2848 std::string HOMARD_Iteration::GetLogFile() const
2849 {
2850   return _LogFile;
2851 }
2852 //=============================================================================
2853 void HOMARD_Iteration::SetFileInfo( const char* FileInfo )
2854 {
2855   _FileInfo = std::string( FileInfo );
2856 }
2857 //=============================================================================
2858 std::string HOMARD_Iteration::GetFileInfo() const
2859 {
2860   return _FileInfo;
2861 }
2862 //=============================================================================
2863 //=============================================================================
2864 // Liens avec les autres iterations
2865 //=============================================================================
2866 //=============================================================================
2867 void HOMARD_Iteration::LinkNextIteration( const char* NomIteration )
2868 {
2869   _mesIterFilles.push_back( std::string( NomIteration ) );
2870 }
2871 //=============================================================================
2872 void HOMARD_Iteration::UnLinkNextIteration( const char* NomIteration )
2873 {
2874   std::list<std::string>::iterator it = find( _mesIterFilles.begin(), _mesIterFilles.end(), NomIteration ) ;
2875   if ( it != _mesIterFilles.end() )
2876   {
2877     MESSAGE ("Dans UnLinkNextIteration pour " << NomIteration) ;
2878     it = _mesIterFilles.erase( it ) ;
2879   }
2880 }
2881 //=============================================================================
2882 void HOMARD_Iteration::UnLinkNextIterations()
2883 {
2884   _mesIterFilles.clear();
2885 }
2886 //=============================================================================
2887 const std::list<std::string>& HOMARD_Iteration::GetIterations() const
2888 {
2889   return _mesIterFilles;
2890 }
2891 //=============================================================================
2892 void HOMARD_Iteration::SetIterParentName( const char* IterParent )
2893 {
2894   _IterParent = IterParent;
2895 }
2896 //=============================================================================
2897 std::string HOMARD_Iteration::GetIterParentName() const
2898 {
2899   return _IterParent;
2900 }
2901 //=============================================================================
2902 //=============================================================================
2903 // Liens avec les autres structures
2904 //=============================================================================
2905 //=============================================================================
2906 void HOMARD_Iteration::SetCaseName( const char* NomCas )
2907 {
2908   _NomCas = std::string( NomCas );
2909 }
2910 //=============================================================================
2911 std::string HOMARD_Iteration::GetCaseName() const
2912 {
2913   return _NomCas;
2914 }
2915 //=============================================================================
2916 void HOMARD_Iteration::SetHypoName( const char* NomHypo )
2917 {
2918   _NomHypo = std::string( NomHypo );
2919 }
2920 //=============================================================================
2921 std::string HOMARD_Iteration::GetHypoName() const
2922 {
2923   return _NomHypo;
2924 }
2925 //=============================================================================
2926 //=============================================================================
2927 // Divers
2928 //=============================================================================
2929 //=============================================================================
2930 void HOMARD_Iteration::SetInfoCompute( int MessInfo )
2931 {
2932   _MessInfo = MessInfo;
2933 }
2934 //=============================================================================
2935 int HOMARD_Iteration::GetInfoCompute() const
2936 {
2937   return _MessInfo;
2938 }
2939
2940 } // namespace SMESHHOMARDImpl /end/