1 // SMESH HOMARD : implementation of SMESHHOMARD idl descriptions
3 // Copyright (C) 2011-2021 CEA/DEN, EDF R&D
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.
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.
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
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include "SMESH_Homard.hxx"
24 #include <Utils_SALOME_Exception.hxx>
25 #include <utilities.h>
38 namespace SMESHHOMARDImpl
41 std::string SEPARATOR = "|" ;
44 \brief Read next chunk of data from the string
47 The function tries to read next chunk of the data from the input string \a str.
48 The parameter \a start specifies the start position of next chunk. If the operation
49 read the chunk successfully, after its completion this parameter will refer to the
50 start position of the next chunk. The function returns resulting chunk as a string.
51 The status of the operation is returned via \a ok parameter.
53 \param str source data stream string
54 \param start start position to get next chunk
55 \param ok in this variable the status of the chunk reading operation is returned
56 \return next chunk read from the string
58 static std::string getNextChunk( const std::string& str, std::string::size_type& start, bool& ok )
60 std::string chunk = "";
62 if ( start <= str.size() ) {
63 std::string::size_type end = str.find( separator(), start );
64 chunk = str.substr( start, end == std::string::npos ? std::string::npos : end-start );
65 start = end == std::string::npos ? str.size()+1 : end + separator().size();
72 \brief Get persistence signature
73 \param type persistence entity type
74 \return persistence signature
76 std::string GetSignature( SignatureType type )
78 std::string signature = "";
80 case Case: signature = "CASE"; break;
81 case Zone: signature = "ZONE"; break;
82 case Hypothesis: signature = "HYPO"; break;
83 case Iteration: signature = "ITER"; break;
84 case Boundary: signature = "BOUNDARY"; break;
87 signature += separator();
92 \brief Get data separator
93 \return string that is used to separate data entities in the stream
95 std::string separator()
100 // =======================
102 // =======================
104 \brief Dump case to the string
105 \param cas case being dumped
106 \return string representation of the case
108 std::string Dump( const HOMARD_Cas& cas )
110 std::stringstream os;
113 MESSAGE( ". Sauvegarde du cas "<<cas.GetName());
115 os << separator() << cas.GetDirName();
116 os << separator() << cas.GetConfType();
118 std::vector<double> coor = cas.GetBoundingBox();
119 os << separator() << coor.size();
120 for ( unsigned int i = 0; i < coor.size(); i++ )
121 os << separator() << coor[i];
123 std::list<std::string> ListString = cas.GetIterations();
124 os << separator() << ListString.size();
125 std::list<std::string>::const_iterator it;
126 for ( it = ListString.begin(); it != ListString.end(); ++it )
127 os << separator() << *it;
129 ListString = cas.GetGroups();
130 os << separator() << ListString.size();
131 for ( it = ListString.begin(); it != ListString.end(); ++it )
132 os << separator() << *it;
133 ListString = cas.GetBoundaryGroup();
134 os << separator() << ListString.size();
135 for ( it = ListString.begin(); it != ListString.end(); ++it )
136 os << separator() << *it;
138 os << separator() << 0; //cas.GetPyram()
141 // MESSAGE( ". Fin avec "<<saux);
150 \brief Dump iteration to the string
151 \param iteration iteration being dumped
152 \return string representation of the iteration
154 std::string Dump( const HOMARD_Iteration& iteration )
156 std::stringstream os;
159 MESSAGE( ". Sauvegarde de l'iteration "<<iteration.GetName());
160 os << iteration.GetName();
161 os << separator() << iteration.GetState();
162 os << separator() << iteration.GetNumber();
163 os << separator() << iteration.GetMeshFile();
164 os << separator() << iteration.GetLogFile();
165 os << separator() << iteration.GetMeshName();
166 os << separator() << iteration.GetFieldFile();
167 os << separator() << iteration.GetTimeStep();
168 os << separator() << iteration.GetRank();
169 os << separator() << iteration.GetIterParentName();
171 std::list<std::string> ListString = iteration.GetIterations();
172 os << separator() << ListString.size();
173 std::list<std::string>::const_iterator it;
174 for ( it = ListString.begin(); it != ListString.end(); ++it )
175 os << separator() << *it;
177 os << separator() << iteration.GetHypoName();
178 os << separator() << iteration.GetCaseName();
179 os << separator() << iteration.GetDirNameLoc();
182 // MESSAGE( ". Fin avec "<<saux);
190 \brief Dump hypothesis to the string
191 \param hypothesis hypothesis being dumped
192 \return string representation of the hypothesis
194 std::string Dump( const HOMARD_Hypothesis& hypothesis )
196 std::stringstream os;
199 MESSAGE( ". Sauvegarde de l'hypothese "<<hypothesis.GetName());
200 os << hypothesis.GetName();
201 os << separator() << hypothesis.GetCaseCreation();
202 os << separator() << hypothesis.GetAdapType();
203 os << separator() << hypothesis.GetRefinType();
204 os << separator() << hypothesis.GetUnRefType();
205 os << separator() << hypothesis.GetFieldName();
206 os << separator() << hypothesis.GetRefinThrType();
207 os << separator() << hypothesis.GetThreshR();
208 os << separator() << hypothesis.GetUnRefThrType();
209 os << separator() << hypothesis.GetThreshC();
210 os << separator() << hypothesis.GetUseField();
211 os << separator() << hypothesis.GetUseComp();
212 os << separator() << hypothesis.GetTypeFieldInterp();
214 std::list<std::string> ListString = hypothesis.GetIterations();
215 std::list<std::string>::const_iterator it;
216 os << separator() << ListString.size();
217 for ( it = ListString.begin(); it != ListString.end(); ++it )
218 os << separator() << *it;
220 ListString = hypothesis.GetZones();
221 os << separator() << ListString.size();
222 for ( it = ListString.begin(); it != ListString.end(); ++it )
223 os << separator() << *it;
225 ListString = hypothesis.GetComps();
226 os << separator() << ListString.size();
227 for ( it = ListString.begin(); it != ListString.end(); ++it )
228 os << separator() << *it;
230 ListString = hypothesis.GetGroups();
231 os << separator() << ListString.size();
232 for ( it = ListString.begin(); it != ListString.end(); ++it )
233 os << separator() << *it;
235 ListString = hypothesis.GetFieldInterps();
236 os << separator() << ListString.size();
237 for ( it = ListString.begin(); it != ListString.end(); ++it )
238 os << separator() << *it;
240 os << separator() << hypothesis.GetNivMax();
241 os << separator() << hypothesis.GetDiamMin();
242 os << separator() << hypothesis.GetAdapInit();
243 os << separator() << hypothesis.GetExtraOutput();
246 // MESSAGE( ". Fin avec "<<saux);
250 // ==============================
251 // 1.5. Archivage d'une frontiere
252 // ==============================
255 \brief Dump boundary to the string
256 \param boundary boundary being dumped
257 \return string representation of the boundary
259 std::string Dump( const HOMARD_Boundary& boundary )
261 std::stringstream os;
263 MESSAGE( ". Sauvegarde de la frontiere "<<boundary.GetName());
265 int BoundaryType = boundary.GetType() ;
267 os << boundary.GetName() ;
268 os << separator() << BoundaryType ;
269 os << separator() << boundary.GetCaseCreation() ;
271 if ( BoundaryType == -1 )
273 os << separator() << boundary.GetDataFile();
275 else if ( BoundaryType == 0 )
277 os << separator() << boundary.GetMeshName();
278 os << separator() << boundary.GetDataFile();
281 std::vector<double> coor = boundary.GetCoords() ;
282 for ( unsigned int i = 0; i < coor.size(); i++ )
283 os << separator() << coor[i];
284 std::vector<double> limit = boundary.GetLimit();
285 for ( unsigned int i = 0; i < limit.size(); i++ )
286 os << separator() << limit[i];
289 std::list<std::string> ListString = boundary.GetGroups();
290 std::list<std::string>::const_iterator it;
291 os << separator() << ListString.size();
292 for ( it = ListString.begin(); it != ListString.end(); ++it )
293 os << separator() << *it;
296 // MESSAGE( ". Fin avec "<<saux);
301 // 2. Restauration des objets
302 // ==========================
304 // ==========================
307 \brief Restore case from the string
308 \param cas case being restored
309 \param stream string representation of the case
310 \return \c true if case is correctly restored or \c false otherwise
312 bool Restore( HOMARD_Cas& cas, const std::string& stream )
314 MESSAGE( ". Restoration du cas ");
315 std::string::size_type start = 0;
316 std::string chunk, chunkNext;
319 chunk = getNextChunk( stream, start, ok );
320 if ( !ok ) return false;
321 cas.SetName( chunk.c_str() );
323 chunk = getNextChunk( stream, start, ok );
324 if ( !ok ) return false;
325 cas.SetDirName( chunk.c_str() );
327 chunk = getNextChunk( stream, start, ok );
328 if ( !ok ) return false;
329 cas.SetConfType( atoi( chunk.c_str() ) );
331 chunk = getNextChunk( stream, start, ok );
332 if ( !ok ) return false;
334 int size = atoi( chunk.c_str() );
335 std::vector<double> boite;
336 boite.resize( size );
337 for ( int i = 0; i < size; i++ ) {
338 chunk = getNextChunk( stream, start, ok );
339 if ( !ok ) return false;
340 boite[i] = strtod( chunk.c_str(), 0 );
342 cas.SetBoundingBox( boite );
344 chunk = getNextChunk( stream, start, ok );
345 if ( !ok ) return false;
347 size = atoi( chunk.c_str() );
348 for ( int i = 0; i < size; i++ ) {
349 chunk = getNextChunk( stream, start, ok );
350 if ( !ok ) return false;
351 cas.AddIteration( chunk.c_str() );
354 chunk = getNextChunk( stream, start, ok );
355 if ( !ok ) return false;
356 size = atoi( chunk.c_str() );
357 for ( int i = 0; i < size; i++ )
359 chunk = getNextChunk( stream, start, ok );
360 if ( !ok ) return false;
361 cas.AddGroup( chunk.c_str() );
364 chunk = getNextChunk( stream, start, ok );
365 if ( !ok ) return false;
366 size = atoi( chunk.c_str() );
367 for ( int i = 0; i < size; i++ ) {
368 chunk = getNextChunk( stream, start, ok );
369 if ( !ok ) return false;
371 chunkNext = getNextChunk( stream, start, ok );
372 if ( !ok ) return false;
373 cas.AddBoundaryGroup( chunk.c_str(), chunkNext.c_str() );
376 chunk = getNextChunk( stream, start, ok );
377 if ( !ok ) return false;
378 //cas.SetPyram( atoi( chunk.c_str() ) );
387 \brief Restore iteration from the string
388 \param iteration iteration being restored
389 \param stream string representation of the iteration
390 \return \c true if iteration is correctly restored or \c false otherwise
392 bool Restore( HOMARD_Iteration& iteration, const std::string& stream )
394 std::string::size_type start = 0;
397 chunk = getNextChunk( stream, start, ok );
398 if ( !ok ) return false;
400 iteration.SetName( chunk.c_str() );
401 chunk = getNextChunk( stream, start, ok );
402 if ( !ok ) return false;
403 iteration.SetState( atoi( chunk.c_str() ) );
404 chunk = getNextChunk( stream, start, ok );
405 if ( !ok ) return false;
406 iteration.SetNumber( atoi( chunk.c_str() ) );
407 chunk = getNextChunk( stream, start, ok );
408 if ( !ok ) return false;
409 iteration.SetMeshFile( chunk.c_str() );
410 chunk = getNextChunk( stream, start, ok );
411 if ( !ok ) return false;
412 iteration.SetLogFile( chunk.c_str() );
413 chunk = getNextChunk( stream, start, ok );
414 if ( !ok ) return false;
415 iteration.SetMeshName( chunk.c_str() );
416 chunk = getNextChunk( stream, start, ok );
417 if ( !ok ) return false;
418 iteration.SetFieldFile( chunk.c_str() );
421 chunk = getNextChunk( stream, start, ok );
422 if ( !ok ) return false;
423 timestep = atoi( chunk.c_str() );
424 chunk = getNextChunk( stream, start, ok );
425 if ( !ok ) return false;
426 rank = atoi( chunk.c_str() );
427 iteration.SetTimeStepRank( timestep, rank );
428 chunk = getNextChunk( stream, start, ok );
429 if ( !ok ) return false;
430 iteration.SetIterParentName( chunk.c_str() );
432 chunk = getNextChunk( stream, start, ok );
433 if ( !ok ) return false;
434 int size = atoi( chunk.c_str() );
435 for ( int i = 0; i < size; i++ ) {
436 chunk = getNextChunk( stream, start, ok );
437 if ( !ok ) return false;
438 iteration.LinkNextIteration( chunk.c_str() );
441 chunk = getNextChunk( stream, start, ok );
442 if ( !ok ) return false;
443 iteration.SetHypoName( chunk.c_str() );
444 chunk = getNextChunk( stream, start, ok );
445 if ( !ok ) return false;
446 iteration.SetCaseName( chunk.c_str() );
447 chunk = getNextChunk( stream, start, ok );
448 if ( !ok ) return false;
449 iteration.SetDirNameLoc( chunk.c_str() );
458 \brief Restore hypothesis from the string
459 \param hypothesis hypothesis being restored
460 \param stream string representation of the hypothesis
461 \return \c true if hypothesis is correctly restored or \c false otherwise
463 bool Restore( HOMARD_Hypothesis& hypothesis, const std::string& stream )
465 std::string::size_type start = 0;
466 std::string chunk, chunkNext;
469 chunk = getNextChunk( stream, start, ok );
470 if ( !ok ) return false;
471 hypothesis.SetName( chunk.c_str() );
473 chunk = getNextChunk( stream, start, ok );
474 if ( !ok ) return false;
475 hypothesis.SetCaseCreation( chunk.c_str() );
477 chunk = getNextChunk( stream, start, ok );
478 if ( !ok ) return false;
479 hypothesis.SetAdapType( atoi( chunk.c_str() ) );
481 chunk = getNextChunk( stream, start, ok );
482 if ( !ok ) return false;
483 int typeraff = atoi( chunk.c_str() );
484 chunk = getNextChunk( stream, start, ok );
485 if ( !ok ) return false;
486 int typedera = atoi( chunk.c_str() );
487 hypothesis.SetRefinTypeDera( typeraff, typedera );
489 chunk = getNextChunk( stream, start, ok );
490 if ( !ok ) return false;
491 hypothesis.SetField( chunk.c_str() );
493 chunk = getNextChunk( stream, start, ok );
494 if ( !ok ) return false;
495 int typethr = atoi( chunk.c_str() );
496 chunk = getNextChunk( stream, start, ok );
497 if ( !ok ) return false;
498 double threshr = strtod( chunk.c_str(), 0 );
499 hypothesis.SetRefinThr( typethr, threshr );
501 chunk = getNextChunk( stream, start, ok );
502 if ( !ok ) return false;
503 int typethc = atoi( chunk.c_str() );
504 chunk = getNextChunk( stream, start, ok );
505 if ( !ok ) return false;
506 double threshc = strtod( chunk.c_str(), 0 );
507 hypothesis.SetUnRefThr( typethc, threshc );
509 chunk = getNextChunk( stream, start, ok );
510 if ( !ok ) return false;
511 hypothesis.SetUseField(atoi(chunk.c_str()));
513 chunk = getNextChunk( stream, start, ok );
514 if ( !ok ) return false;
515 hypothesis.SetUseComp(atoi(chunk.c_str()));
517 chunk = getNextChunk( stream, start, ok );
518 if ( !ok ) return false;
519 hypothesis.SetTypeFieldInterp(atoi(chunk.c_str()));
521 chunk = getNextChunk( stream, start, ok );
522 if ( !ok ) return false;
523 int size = atoi( chunk.c_str() );
524 for ( int i = 0; i < size; i++ ) {
525 chunk = getNextChunk( stream, start, ok );
526 if ( !ok ) return false;
527 hypothesis.LinkIteration( chunk.c_str() );
530 chunk = getNextChunk( stream, start, ok );
531 if ( !ok ) return false;
532 size = atoi( chunk.c_str() );
533 for ( int i = 0; i < size; i++ ) {
534 chunk = getNextChunk( stream, start, ok );
535 if ( !ok ) return false;
537 chunkNext = getNextChunk( stream, start, ok );
538 int typeuse = atoi( chunkNext.c_str() );
539 if ( !ok ) return false;
540 hypothesis.AddZone( chunk.c_str(), typeuse );
543 chunk = getNextChunk( stream, start, ok );
544 if ( !ok ) return false;
545 size = atoi( chunk.c_str() );
546 for ( int i = 0; i < size; i++ ) {
547 chunk = getNextChunk( stream, start, ok );
548 if ( !ok ) return false;
549 hypothesis.AddComp( chunk.c_str() );
552 chunk = getNextChunk( stream, start, ok );
553 if ( !ok ) return false;
554 size = atoi( chunk.c_str() );
555 for ( int i = 0; i < size; i++ ) {
556 chunk = getNextChunk( stream, start, ok );
557 if ( !ok ) return false;
558 hypothesis.AddGroup( chunk.c_str() );
561 chunk = getNextChunk( stream, start, ok );
562 if ( !ok ) return false;
563 size = atoi( chunk.c_str() );
564 for ( int i = 0; i < size; i++ ) {
565 chunk = getNextChunk( stream, start, ok );
566 if ( !ok ) return false;
568 chunkNext = getNextChunk( stream, start, ok );
569 int TypeInterp = atoi( chunkNext.c_str() );
570 if ( !ok ) return false;
571 hypothesis.AddFieldInterpType( chunk.c_str(), TypeInterp );
574 chunk = getNextChunk( stream, start, ok );
575 if ( !ok ) return false;
576 hypothesis.SetNivMax( atoi( chunk.c_str() ) );
578 chunk = getNextChunk( stream, start, ok );
579 if ( !ok ) return false;
580 hypothesis.SetDiamMin( strtod( chunk.c_str(), 0 ) );
582 chunk = getNextChunk( stream, start, ok );
583 if ( !ok ) return false;
584 hypothesis.SetAdapInit( strtod( chunk.c_str(), 0 ) );
586 chunk = getNextChunk( stream, start, ok );
587 if ( !ok ) return false;
588 hypothesis.SetExtraOutput( strtod( chunk.c_str(), 0 ) );
594 // =================================
595 // 2.5. Restauration d'une frontiere
596 // =================================
599 \brief Restore boundary from the string
600 \param boundary boundary being restored
601 \param stream string representation of the boundary
602 \return \c true if the boundary is correctly restored or \c false otherwise
604 bool Restore( HOMARD_Boundary& boundary, const std::string& stream )
606 std::string::size_type start = 0;
610 chunk = getNextChunk( stream, start, ok );
611 if ( !ok ) return false;
612 boundary.SetName( chunk.c_str() );
614 chunk = getNextChunk( stream, start, ok );
615 if ( !ok ) return false;
616 int BoundaryType = atoi( chunk.c_str() ) ;
617 boundary.SetType( BoundaryType );
619 chunk = getNextChunk( stream, start, ok );
620 if ( !ok ) return false;
621 boundary.SetCaseCreation( chunk.c_str() );
623 // Si analytique, les coordonnees des frontieres : le nombre depend du type
624 // Si discret, le maillage
625 // Si CAO, la géométrie
627 if ( BoundaryType == -1 ) { lgcoords = -1 ; }
628 else if ( BoundaryType == 1 ) { lgcoords = 7 ; }
629 else if ( BoundaryType == 2 ) { lgcoords = 4 ; }
630 else { lgcoords = 0 ; }
632 if ( lgcoords == -1 )
634 chunk = getNextChunk( stream, start, ok );
635 if ( !ok ) return false;
636 boundary.SetDataFile( chunk.c_str() );
638 else if ( lgcoords == 0 )
640 chunk = getNextChunk( stream, start, ok );
641 if ( !ok ) return false;
642 boundary.SetMeshName( chunk.c_str() );
644 chunk = getNextChunk( stream, start, ok );
645 if ( !ok ) return false;
646 boundary.SetDataFile( chunk.c_str() );
649 { std::vector<double> coords;
650 coords.resize( lgcoords );
651 for ( int i = 0; i < lgcoords; i++ ) {
652 chunk = getNextChunk( stream, start, ok );
653 if ( !ok ) return false;
654 coords[i] = strtod( chunk.c_str(), 0 );
656 if ( BoundaryType == 1 )
657 { boundary.SetCylinder(coords[0],coords[1],coords[2],coords[3],coords[4],coords[5],coords[6]); }
658 else if ( BoundaryType == 2 )
659 { boundary.SetSphere( coords[0], coords[1], coords[2], coords[3]); }
660 else if ( BoundaryType == 3 )
661 { boundary.SetConeA( coords[0], coords[1], coords[2], coords[3], coords[4], coords[5], coords[6]); }
662 else if ( BoundaryType == 4 )
663 { boundary.SetConeR( coords[0], coords[1], coords[2], coords[3], coords[4], coords[5], coords[6], coords[7]); }
664 // Remarque : la taille de coords est suffisante pour les limites
665 for ( int i = 0; i < 3; i++ ) {
666 chunk = getNextChunk( stream, start, ok );
667 if ( !ok ) return false;
668 coords[i] = strtod( chunk.c_str(), 0 );
670 boundary.SetLimit( coords[0], coords[1], coords[2]);
673 chunk = getNextChunk( stream, start, ok );
674 if ( !ok ) return false;
675 int size = atoi( chunk.c_str() );
676 for ( int i = 0; i < size; i++ ) {
677 chunk = getNextChunk( stream, start, ok );
678 if ( !ok ) return false;
679 boundary.AddGroup( chunk.c_str() );
685 //=============================================================================
687 * default constructor:
689 //=============================================================================
690 HOMARD_Boundary::HOMARD_Boundary():
691 _Name( "" ),_Type( 1 ),
692 _Xmin( 0 ), _Xmax( 0 ), _Ymin( 0 ), _Ymax( 0 ), _Zmin( 0 ), _Zmax( 0 ),
693 _Xaxe( 0 ), _Yaxe( 0 ), _Zaxe( 0 ),
694 _Xcentre( 0 ), _Ycentre( 0 ), _Zcentre( 0 ), _rayon( 0 ),
695 _Xincr( 0 ), _Yincr( 0 ), _Zincr( 0 )
697 MESSAGE("HOMARD_Boundary");
700 //=============================================================================
701 HOMARD_Boundary::~HOMARD_Boundary()
703 MESSAGE("~HOMARD_Boundary");
705 //=============================================================================
706 //=============================================================================
708 //=============================================================================
709 //=============================================================================
710 void HOMARD_Boundary::SetName( const char* Name )
712 _Name = std::string( Name );
714 //=============================================================================
715 std::string HOMARD_Boundary::GetName() const
719 //=============================================================================
720 std::string HOMARD_Boundary::GetDumpPython() const
722 std::ostringstream aScript;
726 aScript << _Name << " = smeshhomard.CreateBoundaryCAO(\"" << _Name << "\", ";
727 aScript << "\"" << _DataFile << "\")\n";
732 aScript << _Name << " = smeshhomard.CreateBoundaryDi(\"" << _Name << "\", ";
733 aScript << "\"" << _MeshName << "\", ";
734 aScript << "\"" << _DataFile << "\")\n";
739 aScript << _Name << " = smeshhomard.CreateBoundaryCylinder(\"" << _Name << "\", ";
740 aScript << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _rayon << ")\n";
745 aScript << _Name << " = smeshhomard.CreateBoundarySphere(\"" << _Name << "\", ";
746 aScript << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _rayon << ")\n";
751 aScript << _Name << " = smeshhomard.CreateBoundaryConeA(\"" << _Name << "\", ";
752 aScript << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _Angle << ", " << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ")\n";
757 aScript << _Name << " = smeshhomard.CreateBoundaryConeR(\"" << _Name << "\", ";
758 aScript << _Xcentre1 << ", " << _Ycentre1 << ", " << _Zcentre1 << ", " << _Rayon1 << ", " << _Xcentre2 << ", " << _Ycentre2 << ", " << _Zcentre2 << ", " << _Rayon2 << ")\n";
763 aScript << _Name << " = smeshhomard.CreateBoundaryTorus(\"" << _Name << "\", ";
764 aScript << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _Rayon1 << ", " << _Rayon2 << ")\n";
769 return aScript.str();
771 //=============================================================================
772 //=============================================================================
774 //=============================================================================
775 //=============================================================================
776 void HOMARD_Boundary::SetType( int Type )
780 //=============================================================================
781 int HOMARD_Boundary::GetType() const
785 //=============================================================================
786 void HOMARD_Boundary::SetMeshName( const char* MeshName )
788 _MeshName = std::string( MeshName );
790 //=============================================================================
791 std::string HOMARD_Boundary::GetMeshName() const
795 //=============================================================================
796 void HOMARD_Boundary::SetDataFile( const char* DataFile )
798 _DataFile = std::string( DataFile );
800 //=============================================================================
801 std::string HOMARD_Boundary::GetDataFile() const
805 //=======================================================================================
806 void HOMARD_Boundary::SetCylinder( double X0, double X1, double X2,
807 double X3, double X4, double X5, double X6 )
809 _Xcentre = X0; _Ycentre = X1; _Zcentre = X2;
810 _Xaxe = X3; _Yaxe = X4; _Zaxe = X5;
813 //======================================================================
814 void HOMARD_Boundary::SetSphere( double X0, double X1, double X2, double X3 )
816 _Xcentre = X0; _Ycentre = X1; _Zcentre = X2;
819 //======================================================================
820 void HOMARD_Boundary::SetConeR( double Xcentre1, double Ycentre1, double Zcentre1, double Rayon1,
821 double Xcentre2, double Ycentre2, double Zcentre2, double Rayon2)
823 _Xcentre1 = Xcentre1; _Ycentre1 = Ycentre1; _Zcentre1 = Zcentre1;
825 _Xcentre2 = Xcentre2; _Ycentre2 = Ycentre2; _Zcentre2 = Zcentre2;
828 //======================================================================
829 void HOMARD_Boundary::SetConeA( double Xaxe, double Yaxe, double Zaxe, double Angle,
830 double Xcentre, double Ycentre, double Zcentre)
832 _Xaxe = Xaxe; _Yaxe = Yaxe; _Zaxe = Zaxe;
834 _Xcentre = Xcentre; _Ycentre = Ycentre; _Zcentre = Zcentre;
836 //=======================================================================================
837 void HOMARD_Boundary::SetTorus( double X0, double X1, double X2,
838 double X3, double X4, double X5, double X6, double X7 )
840 _Xcentre = X0; _Ycentre = X1; _Zcentre = X2;
841 _Xaxe = X3; _Yaxe = X4; _Zaxe = X5;
845 //=======================================================================================
846 std::vector<double> HOMARD_Boundary::GetCoords() const
848 std::vector<double> mesCoor;
855 mesCoor.push_back( _Xcentre );
856 mesCoor.push_back( _Ycentre );
857 mesCoor.push_back( _Zcentre );
858 mesCoor.push_back( _Xaxe );
859 mesCoor.push_back( _Yaxe );
860 mesCoor.push_back( _Zaxe );
861 mesCoor.push_back( _rayon );
867 mesCoor.push_back( _Xcentre );
868 mesCoor.push_back( _Ycentre );
869 mesCoor.push_back( _Zcentre );
870 mesCoor.push_back( _rayon );
873 // Cone defini par un axe et un angle
876 mesCoor.push_back( _Xaxe );
877 mesCoor.push_back( _Yaxe );
878 mesCoor.push_back( _Zaxe );
879 mesCoor.push_back( _Angle );
880 mesCoor.push_back( _Xcentre );
881 mesCoor.push_back( _Ycentre );
882 mesCoor.push_back( _Zcentre );
885 // Cone defini par les 2 rayons
888 mesCoor.push_back( _Xcentre1 );
889 mesCoor.push_back( _Ycentre1 );
890 mesCoor.push_back( _Zcentre1 );
891 mesCoor.push_back( _Rayon1 );
892 mesCoor.push_back( _Xcentre2 );
893 mesCoor.push_back( _Ycentre2 );
894 mesCoor.push_back( _Zcentre2 );
895 mesCoor.push_back( _Rayon2 );
901 mesCoor.push_back( _Xcentre );
902 mesCoor.push_back( _Ycentre );
903 mesCoor.push_back( _Zcentre );
904 mesCoor.push_back( _Xaxe );
905 mesCoor.push_back( _Yaxe );
906 mesCoor.push_back( _Zaxe );
907 mesCoor.push_back( _Rayon1 );
908 mesCoor.push_back( _Rayon2 );
911 VERIFICATION( (_Type>=1) && (_Type<=5) ) ;
915 //======================================================================
916 void HOMARD_Boundary::SetLimit( double X0, double X1, double X2 )
918 _Xincr = X0; _Yincr = X1; _Zincr = X2;
920 //=======================================================================================
921 std::vector<double> HOMARD_Boundary::GetLimit() const
923 std::vector<double> mesLimit;
924 mesLimit.push_back( _Xincr );
925 mesLimit.push_back( _Yincr );
926 mesLimit.push_back( _Zincr );
929 //=============================================================================
930 void HOMARD_Boundary::AddGroup( const char* Group)
932 _ListGroupSelected.push_back(Group);
934 //=============================================================================
935 void HOMARD_Boundary::SetGroups( const std::list<std::string>& ListGroup )
937 _ListGroupSelected.clear();
938 std::list<std::string>::const_iterator it = ListGroup.begin();
939 while(it != ListGroup.end())
940 _ListGroupSelected.push_back((*it++));
942 //=============================================================================
943 const std::list<std::string>& HOMARD_Boundary::GetGroups() const
945 return _ListGroupSelected;
947 //=============================================================================
948 //=============================================================================
949 // Liens avec les autres structures
950 //=============================================================================
951 //=============================================================================
952 void HOMARD_Boundary::SetCaseCreation( const char* NomCasCreation )
954 _NomCasCreation = std::string( NomCasCreation );
956 //=============================================================================
957 std::string HOMARD_Boundary::GetCaseCreation() const
959 return _NomCasCreation;
961 //=============================================================================
963 //=============================================================================
965 * default constructor:
966 * Par defaut, l'adaptation est conforme, sans suivi de frontiere
968 //=============================================================================
969 HOMARD_Cas::HOMARD_Cas():
970 _Name(""), _NomDir("/tmp"), _ConfType(0)
972 MESSAGE("HOMARD_Cas");
974 //=============================================================================
975 HOMARD_Cas::~HOMARD_Cas()
976 //=============================================================================
978 MESSAGE("~HOMARD_Cas");
980 //=============================================================================
981 //=============================================================================
983 //=============================================================================
984 //=============================================================================
985 void HOMARD_Cas::SetName( const char* Name )
987 _Name = std::string( Name );
989 //=============================================================================
990 std::string HOMARD_Cas::GetName() const
994 //=============================================================================
995 std::string HOMARD_Cas::GetDumpPython() const
997 std::ostringstream aScript;
998 //aScript << _Name << ".SetDirName(\"" << _NomDir << "\")\n";
999 aScript << _Name << ".SetConfType(" << _ConfType << ")\n";
1000 // Suivi de frontieres
1001 std::list<std::string>::const_iterator it = _ListBoundaryGroup.begin();
1002 while (it != _ListBoundaryGroup.end()) {
1003 aScript << _Name << ".AddBoundaryGroup(\"" << *it << "\", \"";
1005 aScript << *it << "\")\n";
1009 return aScript.str();
1011 //=============================================================================
1012 //=============================================================================
1014 //=============================================================================
1015 //=============================================================================
1016 int HOMARD_Cas::SetDirName( const char* NomDir )
1018 // MESSAGE("SetDirName, NomDir : "<<NomDir);
1019 // MESSAGE("SetDirName, _NomDir : "<<_NomDir);
1021 // On vérifie qu'aucun calcul n'a eu lieu pour ce cas
1022 // MESSAGE("SetDirName, _ListIter.size() : "<<_ListIter.size());
1023 if ( _ListIter.size() > 1 ) { erreur = 1 ; }
1025 if ( CHDIR(NomDir) == 0 )
1026 { _NomDir = std::string( NomDir ); }
1031 if ( mkdir(NomDir, S_IRWXU|S_IRGRP|S_IXGRP) == 0 )
1033 if ( _mkdir(NomDir) == 0 )
1036 if ( CHDIR(NomDir) == 0 ) { _NomDir = std::string( NomDir ); }
1037 else { erreur = 2 ; }
1039 else { erreur = 2 ; }
1043 //=============================================================================
1044 std::string HOMARD_Cas::GetDirName() const
1048 //=============================================================================
1049 int HOMARD_Cas::GetNumberofIter()
1051 return _ListIter.size();
1054 // Le type de conformite ou non conformite
1056 //=============================================================================
1057 void HOMARD_Cas::SetConfType( int Conftype )
1059 // VERIFICATION( (Conftype>=-2) && (Conftype<=3) );
1060 _ConfType = Conftype;
1062 //=============================================================================
1063 const int HOMARD_Cas::GetConfType() const
1068 // La boite englobante
1070 //=============================================================================
1071 void HOMARD_Cas::SetBoundingBox( const std::vector<double>& extremas )
1074 _Boite.resize( extremas.size() );
1075 for ( unsigned int i = 0; i < extremas.size(); i++ )
1076 _Boite[i] = extremas[i];
1078 //=============================================================================
1079 const std::vector<double>& HOMARD_Cas::GetBoundingBox() const
1086 //=============================================================================
1087 void HOMARD_Cas::AddGroup( const char* Group )
1089 _ListGroup.push_back(Group);
1091 //=============================================================================
1092 void HOMARD_Cas::SetGroups( const std::list<std::string>& ListGroup )
1095 std::list<std::string>::const_iterator it = ListGroup.begin();
1096 while(it != ListGroup.end())
1098 _ListGroup.push_back((*it++));
1101 //=============================================================================
1102 const std::list<std::string>& HOMARD_Cas::GetGroups() const
1106 //=============================================================================
1107 void HOMARD_Cas::SupprGroups()
1114 //=============================================================================
1115 void HOMARD_Cas::AddBoundary( const char* Boundary )
1117 // MESSAGE ( ". HOMARD_Cas::AddBoundary : Boundary = " << Boundary );
1118 const char* Group = "";
1119 AddBoundaryGroup( Boundary, Group );
1121 //=============================================================================
1122 void HOMARD_Cas::AddBoundaryGroup( const char* Boundary, const char* Group )
1124 // MESSAGE ( ". HOMARD_Cas::AddBoundaryGroup : Boundary = " << Boundary );
1125 // MESSAGE ( ". HOMARD_Cas::AddBoundaryGroup : Group = " << Group );
1126 _ListBoundaryGroup.push_back( Boundary );
1127 _ListBoundaryGroup.push_back( Group );
1129 //=============================================================================
1130 const std::list<std::string>& HOMARD_Cas::GetBoundaryGroup() const
1132 return _ListBoundaryGroup;
1134 //=============================================================================
1135 void HOMARD_Cas::SupprBoundaryGroup()
1137 _ListBoundaryGroup.clear();
1139 //=============================================================================
1140 //=============================================================================
1141 // Liens avec les autres structures
1142 //=============================================================================
1143 //=============================================================================
1144 std::string HOMARD_Cas::GetIter0Name() const
1146 // Par construction de la liste, l'iteration a ete mise en tete.
1147 return (*(_ListIter.begin()));
1149 //=============================================================================
1150 void HOMARD_Cas::AddIteration( const char* NomIteration )
1152 _ListIter.push_back( std::string( NomIteration ) );
1154 //=============================================================================
1155 const std::list<std::string>& HOMARD_Cas::GetIterations() const
1159 //=============================================================================
1160 void HOMARD_Cas::SupprIterations()
1165 //=============================================================================
1166 //=============================================================================
1167 HomardDriver::HomardDriver(const std::string siter, const std::string siterp1):
1168 _HOMARD_Exec( "" ), _NomDir( "" ), _NomFichierConfBase( "HOMARD.Configuration" ),
1169 _NomFichierConf( "" ), _NomFichierDonn( "" ), _siter( "" ), _siterp1( "" ),
1170 _Texte( "" ), _bLu( false )
1172 MESSAGE("siter = "<<siter<<", siterp1 = "<<siterp1);
1173 // Le repertoire ou se trouve l'executable HOMARD
1176 if ( getenv("HOMARD_ROOT_DIR") != NULL ) { dir = getenv("HOMARD_ROOT_DIR") ; }
1177 dir += "/bin/salome";
1178 MESSAGE("dir ="<<dir);
1179 // L'executable HOMARD
1180 std::string executable = "homard";
1181 MESSAGE("executable ="<<executable);
1182 // Memorisation du nom complet de l'executable HOMARD
1183 _HOMARD_Exec = dir + "/" + executable ;
1184 MESSAGE("==> _HOMARD_Exec ="<<_HOMARD_Exec) ;
1187 _siterp1 = siterp1 ;
1189 //=============================================================================
1190 //=============================================================================
1191 HomardDriver::~HomardDriver()
1194 //===============================================================================
1196 //===============================================================================
1197 void HomardDriver::TexteInit( const std::string DirCompute, const std::string LogFile, const std::string Langue )
1199 MESSAGE("TexteInit, DirCompute ="<<DirCompute<<", LogFile ="<<LogFile);
1201 _Texte = "ListeStd \"" + LogFile + "\"\n" ;
1202 _Texte += "RepeTrav \"" + DirCompute + "\"\n" ;
1203 _Texte += "RepeInfo \"" + DirCompute + "\"\n" ;
1204 _Texte += "Langue \"" + Langue + "\"\n" ;
1207 //===============================================================================
1208 void HomardDriver::TexteAdap()
1210 MESSAGE("TexteAdap");
1212 _Texte += "Action homa\n";
1213 _Texte += "CCAssoci med\n";
1214 _Texte += "ModeHOMA 1\n";
1215 _Texte += "NumeIter " + _siter + "\n";
1218 //===============================================================================
1219 void HomardDriver::TexteInfo( int TypeBila, int NumeIter )
1221 MESSAGE("TexteInfo: TypeBila ="<<TypeBila<<", NumeIter ="<<NumeIter);
1223 _Texte += "ModeHOMA 2\n" ;
1224 std::stringstream saux1 ;
1226 std::string saux2 = saux1.str() ;
1227 _Texte += "TypeBila " + saux2 + "\n" ;
1228 if ( NumeIter == 0 )
1230 _Texte += "NumeIter 0\n" ;
1231 _Texte += "Action info_av\n" ;
1232 _Texte += "CCAssoci med\n" ;
1236 _Texte += "NumeIter " + _siter + "\n" ;
1237 _Texte += "Action info_ap\n" ;
1238 _Texte += "CCAssoci homard\n" ;
1243 //===============================================================================
1244 void HomardDriver::TexteMajCoords( int NumeIter )
1246 MESSAGE("TexteMajCoords: NumeIter ="<<NumeIter);
1248 _Texte += "ModeHOMA 5\n" ;
1249 _Texte += "NumeIter " + _siterp1 + "\n" ;
1250 _Texte += "Action homa\n" ;
1251 _Texte += "CCAssoci med\n" ;
1252 _Texte += "EcriFiHO N_SANS_FRONTIERE\n" ;
1256 //===============================================================================
1257 // B. Les maillages en entree et en sortie
1258 //===============================================================================
1259 void HomardDriver::TexteMaillage( const std::string NomMesh, const std::string MeshFile, int apres )
1261 MESSAGE("TexteMaillage, NomMesh = "<<NomMesh);
1262 MESSAGE("TexteMaillage, MeshFile = "<<MeshFile);
1263 MESSAGE("TexteMaillage, apres = "<<apres);
1266 if ( apres < 1 ) { saux = "__" ; }
1268 _Texte += "# Maillages Med " + saux + "\n" ;
1269 _Texte += "CCNoMN" + saux + " \"" + NomMesh + "\"\n" ;
1270 _Texte += "CCMaiN" + saux + " \"" + MeshFile + "\"\n" ;
1273 //===============================================================================
1274 void HomardDriver::TexteMaillageHOMARD( const std::string Dir, const std::string liter, int apres )
1276 MESSAGE("TexteMaillageHOMARD, Dir ="<<Dir<<", liter ="<<liter<<", apres ="<<apres);
1278 if ( apres < 1 ) { saux = "__" ; }
1279 else { saux = "P1" ; }
1281 _Texte += "# Maillage HOMARD " + liter + "\n" ;
1282 _Texte += "HOMaiN" + saux + " Mai" + liter + " \"" + Dir + "/maill." + liter + ".hom.med\"\n" ;
1285 //===============================================================================
1286 // C. Le pilotage de l'adaptation
1287 //===============================================================================
1288 void HomardDriver::TexteConfRaffDera( int ConfType, int TypeAdap, int TypeRaff, int TypeDera )
1290 MESSAGE("TexteConfRaffDera, ConfType ="<<ConfType);
1291 MESSAGE("TexteConfRaffDera, TypeAdap ="<<TypeAdap<<", TypeRaff ="<<TypeRaff<<", TypeDera ="<<TypeDera);
1293 // Type de conformite
1300 saux = "NON_CONFORME_1_ARETE" ;
1305 saux = "CONFORME_BOITES" ;
1315 saux = "NON_CONFORME" ;
1320 saux = "NON_CONFORME_1_NOEUD" ;
1325 saux = "NON_CONFORME_INDICATEUR" ;
1329 _Texte += "# Type de conformite\nTypeConf " + saux + "\n" ;
1331 // Type de raffinement/deraffinement
1333 if ( TypeAdap == -1 )
1335 if ( TypeRaff == 1 )
1337 saux = "TypeRaff uniforme\n" ;
1341 saux = "TypeRaff non\n" ;
1343 if ( TypeDera == 1 )
1345 saux += "TypeDera uniforme" ;
1349 saux += "TypeDera non" ;
1354 if ( TypeRaff == 1 )
1356 saux = "TypeRaff libre\n" ;
1360 saux = "TypeRaff non\n" ;
1362 if ( TypeDera == 1 )
1364 saux += "TypeDera libre" ;
1368 saux += "TypeDera non" ;
1371 _Texte += "# Type de raffinement/deraffinement\n" + saux + "\n" ;
1373 // MESSAGE("A la fin de HomardDriver::TexteConfRaffDera, _Texte ="<<_Texte);
1375 //===============================================================================
1376 void HomardDriver::TexteCompo( int NumeComp, const std::string NomCompo)
1378 MESSAGE("TexteCompo, NumeComp = "<<NumeComp<<", NomCompo = "<<NomCompo);
1379 _Texte +="CCCoChaI \"" + NomCompo + "\"\n" ;
1381 //===============================================================================
1382 void HomardDriver::TexteZone( int NumeZone, int ZoneType, int TypeUse, double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7, double x8 )
1384 MESSAGE("TexteZone, NumeZone = "<<NumeZone<<", ZoneType = "<<ZoneType<<", TypeUse = "<<TypeUse);
1385 MESSAGE("TexteZone, coor = "<< x0<<","<<x1<< ","<< x2<< ","<< x3<<","<<x4<<","<<x5<<","<<x6<<","<<x7<<","<<x8);
1387 std::string saux, saux2 ;
1390 // On convertit le type de zone au sens du module HOMARD dans Salome, ZoneType, dans le
1391 // type au sens de l'executable HOMARD, ZoneTypeHOMARD
1392 // Attention a mettre le bon signe a ZoneTypeHOMARD :
1393 // >0 signifie que l'on raffinera les mailles contenues dans la zone,
1394 // <0 signifie que l'on deraffinera
1396 int ZoneTypeHOMARD ;
1397 if ( ZoneType >= 11 && ZoneType <= 13 ) { ZoneTypeHOMARD = 1 ; }
1398 else if ( ZoneType >= 31 && ZoneType <= 33 ) { ZoneTypeHOMARD = 3 ; }
1399 else if ( ZoneType >= 61 && ZoneType <= 63 ) { ZoneTypeHOMARD = 6 ; }
1400 else { ZoneTypeHOMARD = ZoneType ; }
1402 if ( TypeUse < 0 ) { ZoneTypeHOMARD = -ZoneTypeHOMARD ; }
1404 std::stringstream saux1 ;
1406 saux = "#\n# Zone numero " + saux1.str() + "\n" ;
1408 { std::stringstream saux1 ;
1409 saux1 << NumeZone << " " << ZoneTypeHOMARD ;
1410 saux += "ZoRaType " + saux1.str() + "\n" ;
1415 if ( ZoneType == 11 ) // Z est constant X Homard <=> X Salome
1416 // Y Homard <=> Y Salome
1418 saux += "#Rectangle\n" ;
1419 { std::stringstream saux1 ;
1420 saux1 << NumeZone << " " << x0 ;
1421 saux += "ZoRaXmin " + saux1.str() + "\n" ;
1423 { std::stringstream saux1 ;
1424 saux1 << NumeZone << " " << x1 ;
1425 saux += "ZoRaXmax " + saux1.str() + "\n" ;
1427 { std::stringstream saux1 ;
1428 saux1 << NumeZone << " " << x2 ;
1429 saux += "ZoRaYmin " + saux1.str() + "\n" ;
1431 { std::stringstream saux1 ;
1432 saux1 << NumeZone << " " << x3 ;
1433 saux += "ZoRaYmax " + saux1.str() + "\n" ;
1437 else if ( ZoneType == 12 ) // X est constant X Homard <=> Y Salome
1438 // Y Homard <=> Z Salome
1440 saux += "#Rectangle\n" ;
1441 { std::stringstream saux1 ;
1442 saux1 << NumeZone << " " << x2 ;
1443 saux += "ZoRaXmin " + saux1.str() + "\n" ;
1445 { std::stringstream saux1 ;
1446 saux1 << NumeZone << " " << x3 ;
1447 saux += "ZoRaXmax " + saux1.str() + "\n" ;
1449 { std::stringstream saux1 ;
1450 saux1 << NumeZone << " " << x4 ;
1451 saux += "ZoRaYmin " + saux1.str() + "\n" ;
1453 { std::stringstream saux1 ;
1454 saux1 << NumeZone << " " << x5 ;
1455 saux += "ZoRaYmax " + saux1.str() + "\n" ;
1459 else if ( ZoneType == 13 ) // Y est constant X Homard <=> X Salome
1460 // Y Homard <=> Z Salome
1462 saux += "#Rectangle\n" ;
1463 { std::stringstream saux1 ;
1464 saux1 << NumeZone << " " << x0 ;
1465 saux += "ZoRaXmin " + saux1.str() + "\n" ;
1467 { std::stringstream saux1 ;
1468 saux1 << NumeZone << " " << x1 ;
1469 saux += "ZoRaXmax " + saux1.str() + "\n" ;
1471 { std::stringstream saux1 ;
1472 saux1 << NumeZone << " " << x4 ;
1473 saux += "ZoRaYmin " + saux1.str() + "\n" ;
1475 { std::stringstream saux1 ;
1476 saux1 << NumeZone << " " << x5 ;
1477 saux += "ZoRaYmax " + saux1.str() + "\n" ;
1481 // Cas du parallelepipede
1483 else if ( ZoneType == 2 )
1485 saux += "# Boite\n" ;
1486 { std::stringstream saux1 ;
1487 saux1 << NumeZone << " " << x0 ;
1488 saux += "ZoRaXmin " + saux1.str() + "\n" ;
1490 { std::stringstream saux1 ;
1491 saux1 << NumeZone << " " << x1 ;
1492 saux += "ZoRaXmax " + saux1.str() + "\n" ;
1494 { std::stringstream saux1 ;
1495 saux1 << NumeZone << " " << x2 ;
1496 saux += "ZoRaYmin " + saux1.str() + "\n" ;
1498 { std::stringstream saux1 ;
1499 saux1 << NumeZone << " " << x3 ;
1500 saux += "ZoRaYmax " + saux1.str() + "\n" ;
1502 { std::stringstream saux1 ;
1503 saux1 << NumeZone << " " << x4 ;
1504 saux += "ZoRaZmin " + saux1.str() + "\n" ;
1506 { std::stringstream saux1 ;
1507 saux1 << NumeZone << " " << x5 ;
1508 saux += "ZoRaZmax " + saux1.str() + "\n" ;
1514 else if ( ZoneType == 31 || ZoneType == 61 )
1516 saux += "# Sphere\n" ;
1517 { std::stringstream saux1 ;
1518 saux1 << NumeZone << " " << x0 ;
1519 saux += "ZoRaXCen " + saux1.str() + "\n" ;
1521 { std::stringstream saux1 ;
1522 saux1 << NumeZone << " " << x1 ;
1523 saux += "ZoRaYCen " + saux1.str() + "\n" ;
1525 { std::stringstream saux1 ;
1526 saux1 << NumeZone << " " << x6 ;
1527 saux2 = saux1.str() ;
1528 if ( ZoneType == 61 ) { saux += "ZoRaRayE " + saux2 + "\n" ; }
1529 else { saux += "ZoRaRayo " + saux2 + "\n" ; }
1531 if ( ZoneType == 61 )
1532 { std::stringstream saux1 ;
1533 saux1 << NumeZone << " " << x8 ;
1534 saux += "ZoRaRayI " + saux1.str() + "\n" ;
1537 else if ( ZoneType == 32 || ZoneType == 62 )
1539 saux += "# Sphere\n" ;
1540 { std::stringstream saux1 ;
1541 saux1 << NumeZone << " " << x1 ;
1542 saux += "ZoRaXCen " + saux1.str() + "\n" ;
1544 { std::stringstream saux1 ;
1545 saux1 << NumeZone << " " << x2 ;
1546 saux += "ZoRaYCen " + saux1.str() + "\n" ;
1548 { std::stringstream saux1 ;
1549 saux1 << NumeZone << " " << x6 ;
1550 saux2 = saux1.str() ;
1551 if ( ZoneType == 62 ) { saux += "ZoRaRayE " + saux2 + "\n" ; }
1552 else { saux += "ZoRaRayo " + saux2 + "\n" ; }
1554 if ( ZoneType == 62 )
1555 { std::stringstream saux1 ;
1556 saux1 << NumeZone << " " << x8 ;
1557 saux += "ZoRaRayI " + saux1.str() + "\n" ;
1560 else if ( ZoneType == 33 || ZoneType == 63 )
1562 saux += "# Sphere\n" ;
1563 { std::stringstream saux1 ;
1564 saux1 << NumeZone << " " << x0 ;
1565 saux += "ZoRaXCen " + saux1.str() + "\n" ;
1567 { std::stringstream saux1 ;
1568 saux1 << NumeZone << " " << x2 ;
1569 saux += "ZoRaYCen " + saux1.str() + "\n" ;
1571 { std::stringstream saux1 ;
1572 saux1 << NumeZone << " " << x6 ;
1573 saux2 = saux1.str() ;
1574 if ( ZoneType == 63 ) { saux += "ZoRaRayE " + saux2 + "\n" ; }
1575 else { saux += "ZoRaRayo " + saux2 + "\n" ; }
1577 if ( ZoneType == 63 )
1578 { std::stringstream saux1 ;
1579 saux1 << NumeZone << " " << x8 ;
1580 saux += "ZoRaRayI " + saux1.str() + "\n" ;
1586 else if ( ZoneType == 4 )
1588 saux += "# Sphere\n" ;
1589 { std::stringstream saux1 ;
1590 saux1 << NumeZone << " " << x0 ;
1591 saux += "ZoRaXCen " + saux1.str() + "\n" ;
1593 { std::stringstream saux1 ;
1594 saux1 << NumeZone << " " << x1 ;
1595 saux += "ZoRaYCen " + saux1.str() + "\n" ;
1597 { std::stringstream saux1 ;
1598 saux1 << NumeZone << " " << x2 ;
1599 saux += "ZoRaZCen " + saux1.str() + "\n" ;
1601 { std::stringstream saux1 ;
1602 saux1 << NumeZone << " " << x3 ;
1603 saux += "ZoRaRayo " + saux1.str() + "\n" ;
1607 // Cas du cylindre ou du tuyau
1609 else if ( ZoneType == 5 || ZoneType == 7 )
1611 if ( ZoneType == 5 ) { saux += "# Cylindre\n" ; }
1612 else { saux += "# Tuyau\n" ; }
1613 { std::stringstream saux1 ;
1614 saux1 << NumeZone << " " << x0 ;
1615 saux += "ZoRaXBas " + saux1.str() + "\n" ;
1617 { std::stringstream saux1 ;
1618 saux1 << NumeZone << " " << x1 ;
1619 saux += "ZoRaYBas " + saux1.str() + "\n" ;
1621 { std::stringstream saux1 ;
1622 saux1 << NumeZone << " " << x2 ;
1623 saux += "ZoRaZBas " + saux1.str() + "\n" ;
1625 { std::stringstream saux1 ;
1626 saux1 << NumeZone << " " << x3 ;
1627 saux += "ZoRaXAxe " + saux1.str() + "\n" ;
1629 { std::stringstream saux1 ;
1630 saux1 << NumeZone << " " << x4 ;
1631 saux += "ZoRaYAxe " + saux1.str() + "\n" ;
1633 { std::stringstream saux1 ;
1634 saux1 << NumeZone << " " << x5 ;
1635 saux += "ZoRaZAxe " + saux1.str() + "\n" ;
1637 { std::stringstream saux1 ;
1638 saux1 << NumeZone << " " << x6 ;
1639 saux2 = saux1.str() ;
1640 if ( ZoneType == 5 ) { saux += "ZoRaRayo " + saux2 + "\n" ; }
1641 else { saux += "ZoRaRayE " + saux2 + "\n" ; }
1643 { std::stringstream saux1 ;
1644 saux1 << NumeZone << " " << x7 ;
1645 saux += "ZoRaHaut " + saux1.str() + "\n" ;
1647 if ( ZoneType == 7 )
1648 { std::stringstream saux1 ;
1649 saux1 << NumeZone << " " << x8 ;
1650 saux += "ZoRaRayI " + saux1.str() + "\n" ;
1654 _Texte += saux + "#\n" ;
1656 // MESSAGE("A la fin de HomardDriver::TexteZone, _Texte ="<<_Texte);
1658 //===============================================================================
1659 void HomardDriver::TexteField( const std::string FieldName, const std::string FieldFile, int TimeStep, int Rank,
1660 int TypeThR, double ThreshR, int TypeThC, double ThreshC,
1661 int UsField, int UsCmpI )
1663 MESSAGE("TexteField, FieldName = "<<FieldName<<", FieldFile = "<<FieldFile);
1664 MESSAGE("TexteField, TimeStep = "<<TimeStep<<", Rank = "<<Rank);
1666 std::string saux, saux2 ;
1669 _Texte += "# Champ d'indicateurs\n" ;
1670 _Texte += "CCIndica \"" + FieldFile + "\"\n" ;
1671 _Texte += "CCNoChaI \"" + FieldName + "\"\n" ;
1673 // Cas ou on prend le dernier pas de temps
1674 if ( TimeStep == -2 )
1675 { _Texte += "CCNumPTI Last\n" ; }
1676 // Cas avec pas de temps
1677 else if ( TimeStep >= 0 )
1680 std::stringstream saux1 ;
1682 saux2 = saux1.str() ;
1683 _Texte += "CCNumPTI " + saux2 + "\n" ;
1687 std::stringstream saux1 ;
1689 saux2 = saux1.str() ;
1690 _Texte += "CCNumOrI " + saux2 + "\n" ;
1705 std::stringstream saux1 ;
1707 _Texte += "Seuil" + saux + " " + saux1.str() + "\n" ;
1721 std::stringstream saux1 ;
1723 _Texte += "Seuil" + saux + " " + saux1.str() + "\n" ;
1728 { saux = "MAILLE" ; }
1733 _Texte += "CCModeFI " + saux + "\n" ;
1740 { saux = "INFINI" ; }
1742 { saux = "RELATIF" ; }
1745 _Texte += "CCUsCmpI " + saux + "\n" ;
1748 //===============================================================================
1749 void HomardDriver::TexteGroup( const std::string GroupName )
1751 MESSAGE("TexteGroup, GroupName = "<<GroupName);
1753 _Texte += "CCGroAda \"" + GroupName + "\"\n" ;
1756 //===============================================================================
1757 // D. Les frontieres
1758 //===============================================================================
1759 void HomardDriver::TexteBoundaryOption( int BoundaryOption )
1761 MESSAGE("TexteBoundaryOption, BoundaryOption = "<<BoundaryOption);
1763 // Type de suivi de frontiere
1765 std::stringstream saux1 ;
1766 saux1 << BoundaryOption ;
1767 std::string saux = saux1.str() ;
1768 _Texte += "SuivFron " + saux + "\n" ;
1770 }//===============================================================================
1771 void HomardDriver::TexteBoundaryCAOGr( const std::string GroupName )
1773 MESSAGE("TexteBoundaryCAOGr, GroupName = "<<GroupName);
1775 _Texte += "GrFroCAO \"" + GroupName + "\"\n" ;
1779 //===============================================================================
1780 void HomardDriver::TexteBoundaryDi( const std::string MeshName, const std::string MeshFile )
1782 MESSAGE("TexteBoundaryDi, MeshName = "<<MeshName);
1783 MESSAGE("TexteBoundaryDi, MeshFile = "<<MeshFile);
1785 _Texte += "#\n# Frontiere discrete\n" ;
1786 _Texte += "CCNoMFro \"" + MeshName + "\"\n" ;
1787 _Texte += "CCFronti \"" + MeshFile + "\"\n" ;
1790 //===============================================================================
1791 void HomardDriver::TexteBoundaryDiGr( const std::string GroupName )
1793 MESSAGE("TexteBoundaryDiGr, GroupName = "<<GroupName);
1795 _Texte += "CCGroFro \"" + GroupName + "\"\n" ;
1798 //===============================================================================
1799 void HomardDriver::TexteBoundaryAn( const std::string NameBoundary, int NumeBoundary, int BoundaryType, double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7 )
1801 MESSAGE("TexteBoundaryAn, NameBoundary = "<<NameBoundary);
1802 // MESSAGE("TexteBoundaryAn, NumeBoundary = "<<NumeBoundary);
1803 MESSAGE("TexteBoundaryAn, BoundaryType = "<<BoundaryType);
1804 // MESSAGE("TexteBoundaryAn, coor = "<< x0<<","<<x1<< ","<< x2<< ","<< x3<<","<<x4<<","<<x5<<","<<x6","<<x7);
1806 std::string saux, saux2 ;
1810 std::stringstream saux1 ;
1811 saux1 << NumeBoundary ;
1812 saux2 = saux1.str() ;
1813 saux = "#\n# Frontiere numero " + saux2 + "\n" ;
1814 if ( BoundaryType == 1 )
1815 { saux += "# Cylindre\n" ; }
1816 if ( BoundaryType == 2 )
1817 { saux += "# Sphere\n" ; }
1818 if ( BoundaryType == 3 || BoundaryType == 4 )
1819 { saux += "# Cone\n" ; }
1820 if ( BoundaryType == 5 )
1821 { saux += "# Tore\n" ; }
1823 // Le nom de la frontiere
1825 { std::stringstream saux1 ;
1826 saux1 << NumeBoundary ;
1827 saux += "FANom " + saux1.str() + " \"" + NameBoundary + "\"\n" ;
1830 // Type de frontiere
1832 { std::stringstream saux1 ;
1833 saux1 << NumeBoundary << " " << BoundaryType ;
1834 saux += "FAType " + saux1.str() + "\n" ;
1839 if ( BoundaryType == 1 )
1841 { std::stringstream saux1 ;
1842 saux1 << NumeBoundary << " " << x0 ;
1843 saux2 = saux1.str() ;
1844 saux += "FAXCen " + saux1.str() + "\n" ;
1846 { std::stringstream saux1 ;
1847 saux1 << NumeBoundary << " " << x1 ;
1848 saux += "FAYCen " + saux1.str() + "\n" ;
1850 { std::stringstream saux1 ;
1851 saux1 << NumeBoundary << " " << x2 ;
1852 saux += "FAZCen " + saux1.str() + "\n" ;
1854 { std::stringstream saux1 ;
1855 saux1 << NumeBoundary << " " << x3 ;
1856 saux += "FAXAxe " + saux1.str() + "\n" ;
1858 { std::stringstream saux1 ;
1859 saux1 << NumeBoundary << " " << x4 ;
1860 saux += "FAYAxe " + saux1.str() + "\n" ;
1862 { std::stringstream saux1 ;
1863 saux1 << NumeBoundary << " " << x5 ;
1864 saux += "FAZAxe " + saux1.str() + "\n" ;
1866 { std::stringstream saux1 ;
1867 saux1 << NumeBoundary << " " << x6 ;
1868 saux += "FARayon " + saux1.str() + "\n" ;
1874 else if ( BoundaryType == 2 )
1876 { std::stringstream saux1 ;
1877 saux1 << NumeBoundary << " " << x0 ;
1878 saux += "FAXCen " + saux1.str() + "\n" ;
1880 { std::stringstream saux1 ;
1881 saux1 << NumeBoundary << " " << x1 ;
1882 saux += "FAYCen " + saux1.str() + "\n" ;
1884 { std::stringstream saux1 ;
1885 saux1 << NumeBoundary << " " << x2 ;
1886 saux += "FAZCen " + saux1.str() + "\n" ;
1888 { std::stringstream saux1 ;
1889 saux1 << NumeBoundary << " " << x3 ;
1890 saux += "FARayon " + saux1.str() + "\n" ;
1894 // Cas du cone defini par un axe et un angle
1896 if ( BoundaryType == 3 )
1898 { std::stringstream saux1 ;
1899 saux1 << NumeBoundary << " " << x0 ;
1900 saux += "FAXAxe " + saux1.str() + "\n" ;
1902 { std::stringstream saux1 ;
1903 saux1 << NumeBoundary << " " << x1 ;
1904 saux += "FAYAxe " + saux1.str() + "\n" ;
1906 { std::stringstream saux1 ;
1907 saux1 << NumeBoundary << " " << x2 ;
1908 saux += "FAZAxe " + saux1.str() + "\n" ;
1910 { std::stringstream saux1 ;
1911 saux1 << NumeBoundary << " " << x3 ;
1912 saux += "FAAngle " + saux1.str() + "\n" ;
1914 { std::stringstream saux1 ;
1915 saux1 << NumeBoundary << " " << x4 ;
1916 saux += "FAXCen " + saux1.str() + "\n" ;
1918 { std::stringstream saux1 ;
1919 saux1 << NumeBoundary << " " << x5 ;
1920 saux += "FAYCen " + saux1.str() + "\n" ;
1922 { std::stringstream saux1 ;
1923 saux1 << NumeBoundary << " " << x6 ;
1924 saux += "FAZCen " + saux1.str() + "\n" ;
1928 // Cas du cone defini par les 2 rayons
1930 if ( BoundaryType == 4 )
1932 { std::stringstream saux1 ;
1933 saux1 << NumeBoundary << " " << x0 ;
1934 saux += "FAXCen " + saux1.str() + "\n" ;
1936 { std::stringstream saux1 ;
1937 saux1 << NumeBoundary << " " << x1 ;
1938 saux += "FAYCen " + saux1.str() + "\n" ;
1940 { std::stringstream saux1 ;
1941 saux1 << NumeBoundary << " " << x2 ;
1942 saux += "FAZCen " + saux1.str() + "\n" ;
1944 { std::stringstream saux1 ;
1945 saux1 << NumeBoundary << " " << x3 ;
1946 saux += "FARayon " + saux1.str() + "\n" ;
1948 { std::stringstream saux1 ;
1949 saux1 << NumeBoundary << " " << x4 ;
1950 saux += "FAXCen2 " + saux1.str() + "\n" ;
1952 { std::stringstream saux1 ;
1953 saux1 << NumeBoundary << " " << x5 ;
1954 saux += "FAYCen2 " + saux1.str() + "\n" ;
1956 { std::stringstream saux1 ;
1957 saux1 << NumeBoundary << " " << x6 ;
1958 saux += "FAZCen2 " + saux1.str() + "\n" ;
1960 { std::stringstream saux1 ;
1961 saux1 << NumeBoundary << " " << x7 ;
1962 saux += "FARayon2 " + saux1.str() + "\n" ;
1968 if ( BoundaryType == 5 )
1970 { std::stringstream saux1 ;
1971 saux1 << NumeBoundary << " " << x0 ;
1972 saux2 = saux1.str() ;
1973 saux += "FAXCen " + saux1.str() + "\n" ;
1975 { std::stringstream saux1 ;
1976 saux1 << NumeBoundary << " " << x1 ;
1977 saux += "FAYCen " + saux1.str() + "\n" ;
1979 { std::stringstream saux1 ;
1980 saux1 << NumeBoundary << " " << x2 ;
1981 saux += "FAZCen " + saux1.str() + "\n" ;
1983 { std::stringstream saux1 ;
1984 saux1 << NumeBoundary << " " << x3 ;
1985 saux += "FAXAxe " + saux1.str() + "\n" ;
1987 { std::stringstream saux1 ;
1988 saux1 << NumeBoundary << " " << x4 ;
1989 saux += "FAYAxe " + saux1.str() + "\n" ;
1991 { std::stringstream saux1 ;
1992 saux1 << NumeBoundary << " " << x5 ;
1993 saux += "FAZAxe " + saux1.str() + "\n" ;
1995 { std::stringstream saux1 ;
1996 saux1 << NumeBoundary << " " << x6 ;
1997 saux += "FARayon " + saux1.str() + "\n" ;
1999 { std::stringstream saux1 ;
2000 saux1 << NumeBoundary << " " << x7 ;
2001 saux += "FARayon2 " + saux1.str() + "\n" ;
2005 _Texte += saux + "#\n" ;
2008 //===============================================================================
2009 void HomardDriver::TexteBoundaryAnGr( const std::string NameBoundary, int NumeBoundary, const std::string GroupName )
2011 MESSAGE("TexteBoundaryAnGr, NameBoundary = "<<NameBoundary);
2012 // MESSAGE("TexteBoundaryAnGr, NumeBoundary = "<<NumeBoundary);
2013 // MESSAGE("TexteBoundaryAnGr, GroupName = "<<GroupName);
2017 std::string saux, saux2 ;
2018 std::stringstream saux1 ;
2019 saux1 << NumeBoundary ;
2020 saux2 = saux1.str() ;
2021 saux = "#\n# Lien Frontiere/Groupe numero " + saux2 + "\n" ;
2023 saux += "FGNomFro " + saux2 + " \"" + NameBoundary + "\"\n" ;
2024 saux += "FGNomGro " + saux2 + " \"" + GroupName + "\"\n" ;
2026 _Texte += saux + "#\n" ;
2029 //===============================================================================
2030 // E. Les interpolations
2031 //===============================================================================
2032 // Les fichiers d'entree et de sortie des champs a interpoler
2033 void HomardDriver::TexteFieldInterp( const std::string FieldFile, const std::string MeshFile )
2035 MESSAGE("TexteFieldInterp, FieldFile = "<<FieldFile<<", MeshFile = "<<MeshFile);
2037 _Texte += "#\n# Interpolations des champs\n" ;
2039 // Fichier en entree
2040 _Texte += "CCSolN__ \"" + FieldFile + "\"\n" ;
2041 // Fichier en sortie
2042 _Texte += "CCSolNP1 \"" + MeshFile + "\"\n" ;
2044 // std::cerr << "A la fin de TexteFieldInterp _Texte ="<<_Texte << std::endl;
2046 //===============================================================================
2047 // Tous les champs sont a interpoler
2048 void HomardDriver::TexteFieldInterpAll( )
2050 MESSAGE("TexteFieldInterpAll");
2052 _Texte += "CCChaTou oui\n" ;
2054 //===============================================================================
2055 // Ecrit les caracteristiques de chaque interpolation sous la forme :
2056 // CCChaNom 1 "DEPL" ! Nom du 1er champ a interpoler
2057 // CCChaTIn 1 0 ! Mode d'interpolation : automatique
2058 // CCChaNom 2 "VOLUME" ! Nom du 2nd champ a interpoler
2059 // CCChaTIn 2 1 ! Mode d'interpolation : une variable extensive
2060 // CCChaPdT 2 14 ! Pas de temps 14
2061 // CCChaNuO 2 14 ! Numero d'ordre 14
2064 // NumeChamp : numero d'ordre du champ a interpoler
2065 // FieldName : nom du champ
2066 // TypeInterp : type d'interpolation
2067 // TimeStep : pas de temps retenu (>0 si pas de precision)
2068 // Rank : numero d'ordre retenu
2070 void HomardDriver::TexteFieldInterpNameType( int NumeChamp, const std::string FieldName, const std::string TypeInterp, int TimeStep, int Rank)
2072 MESSAGE("TexteFieldInterpNameType, NumeChamp = "<<NumeChamp<<", FieldName = "<<FieldName<<", TypeInterp = "<<TypeInterp);
2073 MESSAGE("TexteFieldInterpNameType, TimeStep = "<<TimeStep<<", Rank = "<<Rank);
2074 // Numero d'ordre du champ a interpoler
2075 std::stringstream saux1 ;
2076 saux1 << NumeChamp ;
2077 std::string saux = saux1.str() ;
2079 _Texte +="CCChaNom " + saux + " \"" + FieldName + "\"\n" ;
2080 // Type d'interpolation pour le champ
2081 _Texte +="CCChaTIn " + saux + " " + TypeInterp + "\n" ;
2083 if ( TimeStep >= 0 )
2086 std::stringstream saux1 ;
2088 _Texte += "CCChaPdT " + saux + " " + saux1.str() + "\n" ;
2091 std::stringstream saux1 ;
2093 _Texte += "CCChaNuO " + saux + " " + saux1.str() + "\n" ;
2097 //===============================================================================
2098 // F. Les options avancees
2099 //===============================================================================
2100 void HomardDriver::TexteAdvanced( int NivMax, double DiamMin, int AdapInit, int ExtraOutput )
2102 MESSAGE("TexteAdvanced, NivMax ="<<NivMax<<", DiamMin ="<<DiamMin<<", AdapInit ="<<AdapInit<<", ExtraOutput ="<<ExtraOutput);
2106 _Texte += "# Niveaux extremes\n" ;
2107 { std::stringstream saux1 ;
2109 _Texte += "NiveauMa " + saux1.str() + "\n" ;
2114 _Texte += "# Diametre minimal\n" ;
2115 { std::stringstream saux1 ;
2117 _Texte += "DiametMi " + saux1.str() + "\n" ;
2120 if ( AdapInit != 0 )
2123 { _Texte += "# Raffinement" ; }
2125 { _Texte += "# Deraffinement" ; }
2126 _Texte += " des regions sans indicateur\n" ;
2127 { std::stringstream saux1 ;
2129 _Texte += "AdapInit " + saux1.str() + "\n" ;
2132 if ( ExtraOutput % 2 == 0 )
2134 _Texte += "# Sortie des niveaux de raffinement\n" ;
2135 _Texte += "NCNiveau NIVEAU\n" ;
2137 if ( ExtraOutput % 3 == 0 )
2139 _Texte += "# Sortie des qualités des mailles\n" ;
2140 _Texte += "NCQualit QUAL\n" ;
2142 if ( ExtraOutput % 5 == 0 )
2144 _Texte += "# Sortie des diamètres des mailles\n" ;
2145 _Texte += "NCDiamet DIAM\n" ;
2147 if ( ExtraOutput % 7 == 0 )
2149 _Texte += "# Sortie des parents des mailles\n" ;
2150 _Texte += "NCParent PARENT\n" ;
2152 if ( ExtraOutput % 11 == 0 )
2154 _Texte += "# Volumes voisins par recollement\n" ;
2155 _Texte += "NCVoisRc Voisin-Recollement\n" ;
2158 //===============================================================================
2160 //===============================================================================
2161 void HomardDriver::TexteInfoCompute( int MessInfo )
2163 MESSAGE("TexteAdvanced, MessInfo ="<<MessInfo);
2165 if ( MessInfo != 0 )
2167 _Texte += "# Messages d'informations\n" ;
2168 { std::stringstream saux1 ;
2170 _Texte += "MessInfo " + saux1.str() + "\n" ;
2174 //===============================================================================
2175 void HomardDriver::CreeFichier( )
2178 if ( _modeHOMARD == 1 )
2179 { _NomFichierConf = _NomFichierConfBase + "." + _siter + ".vers." + _siterp1 ; }
2180 else if ( _modeHOMARD == 2 )
2181 { _NomFichierConf = _NomFichierConfBase + "." + _siter + ".info" ; }
2182 else if ( _modeHOMARD == 5 )
2183 { _NomFichierConf = _NomFichierConfBase + ".majc" ; }
2185 std::ofstream Fic(_NomFichierConf.c_str(), std::ios::out ) ;
2186 if (Fic.is_open() == true) { Fic << _Texte << std::endl ; }
2190 //===============================================================================
2191 // Creation du fichier de donnees pour l'information
2192 //===============================================================================
2193 void HomardDriver::CreeFichierDonn( )
2196 MESSAGE("CreeFichierDonn");
2197 _NomFichierDonn = "info.donn" ;
2203 std::ofstream Fic(_NomFichierDonn.c_str(), std::ios::out ) ;
2204 if (Fic.is_open() == true) { Fic << data << std::endl ; }
2208 //===============================================================================
2209 int HomardDriver::ExecuteHomard()
2211 MESSAGE("ExecuteHomard");
2212 std::string commande ;
2214 // Copie des Fichiers HOMARD
2215 commande = "cp " + _NomFichierConf + " " + _NomFichierConfBase ;
2216 codret = system(commande.c_str()) ;
2218 // Execution de HOMARD
2221 commande = _HOMARD_Exec.c_str() ;
2222 if ( _NomFichierDonn != "" ) { commande += " < " + _NomFichierDonn ; }
2223 codret = system(commande.c_str());
2224 if ( codret != 0) { MESSAGE ( "Erreur en executant HOMARD : " << codret ); };
2225 _NomFichierDonn = "" ;
2230 //=============================================================================
2231 //=============================================================================
2232 HOMARD_Gen::HOMARD_Gen()
2234 MESSAGE("HOMARD_Gen");
2237 //=============================================================================
2238 //=============================================================================
2239 HOMARD_Gen::~HOMARD_Gen()
2241 MESSAGE("~HOMARD_Gen");
2243 //=============================================================================
2245 //=============================================================================
2247 * default constructor:
2249 //=============================================================================
2250 HOMARD_Hypothesis::HOMARD_Hypothesis():
2251 _Name(""), _NomCasCreation(""),
2252 _TypeAdap(-1), _TypeRaff(0), _TypeDera(0),
2254 _TypeThR(0), _TypeThC(0),
2255 _ThreshR(0), _ThreshC(0),
2256 _UsField(0), _UsCmpI(0), _TypeFieldInterp(0),
2258 _NivMax(-1), _DiamMin(-1.0), _AdapInit(0), _ExtraOutput(1)
2260 MESSAGE("HOMARD_Hypothesis");
2263 //=============================================================================
2266 //=============================================================================
2267 HOMARD_Hypothesis::~HOMARD_Hypothesis()
2269 MESSAGE("~HOMARD_Hypothesis");
2271 //=============================================================================
2272 //=============================================================================
2274 //=============================================================================
2275 //=============================================================================
2276 void HOMARD_Hypothesis::SetName( const char* Name )
2278 _Name = std::string( Name );
2280 //=============================================================================
2281 std::string HOMARD_Hypothesis::GetName() const
2285 //=============================================================================
2286 //=============================================================================
2288 //=============================================================================
2289 //=============================================================================
2290 void HOMARD_Hypothesis::SetAdapType( int TypeAdap )
2292 VERIFICATION( (TypeAdap>=-1) && (TypeAdap<=1) );
2293 _TypeAdap = TypeAdap;
2295 //=============================================================================
2296 int HOMARD_Hypothesis::GetAdapType() const
2300 //=============================================================================
2301 void HOMARD_Hypothesis::SetRefinTypeDera( int TypeRaff, int TypeDera )
2303 VERIFICATION( (TypeRaff>=-1) && (TypeRaff<=1) );
2304 _TypeRaff = TypeRaff;
2305 VERIFICATION( (TypeDera>=-1) && (TypeDera<=1) );
2306 _TypeDera = TypeDera;
2308 //=============================================================================
2309 int HOMARD_Hypothesis::GetRefinType() const
2313 //=============================================================================
2314 int HOMARD_Hypothesis::GetUnRefType() const
2318 //=============================================================================
2319 void HOMARD_Hypothesis::SetField( const char* FieldName )
2321 _Field = std::string( FieldName );
2322 MESSAGE( "SetField : FieldName = " << FieldName );
2324 //=============================================================================
2325 std::string HOMARD_Hypothesis::GetFieldName() const
2329 //=============================================================================
2330 void HOMARD_Hypothesis::SetUseField( int UsField )
2332 VERIFICATION( (UsField>=0) && (UsField<=1) );
2335 //=============================================================================
2336 int HOMARD_Hypothesis::GetUseField() const
2340 //=============================================================================
2341 void HOMARD_Hypothesis::SetUseComp( int UsCmpI )
2343 MESSAGE ("SetUseComp pour UsCmpI = "<<UsCmpI) ;
2344 VERIFICATION( (UsCmpI>=0) && (UsCmpI<=2) );
2347 //=============================================================================
2348 int HOMARD_Hypothesis::GetUseComp() const
2352 //=============================================================================
2353 void HOMARD_Hypothesis::AddComp( const char* NomComp )
2355 // On commence par supprimer la composante au cas ou elle aurait deja ete inseree
2356 // Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la
2357 // definition de l'hypothese
2358 SupprComp( NomComp ) ;
2359 // Insertion veritable
2360 _ListComp.push_back( std::string( NomComp ) );
2362 //=============================================================================
2363 void HOMARD_Hypothesis::SupprComp( const char* NomComp )
2365 MESSAGE ("SupprComp pour "<<NomComp) ;
2366 std::list<std::string>::iterator it = find( _ListComp.begin(), _ListComp.end(), NomComp );
2367 if ( it != _ListComp.end() ) { it = _ListComp.erase( it ); }
2369 //=============================================================================
2370 void HOMARD_Hypothesis::SupprComps()
2374 //=============================================================================
2375 const std::list<std::string>& HOMARD_Hypothesis::GetComps() const
2379 //=============================================================================
2380 void HOMARD_Hypothesis::SetRefinThr( int TypeThR, double ThreshR )
2382 MESSAGE( "SetRefinThr : TypeThR = " << TypeThR << ", ThreshR = " << ThreshR );
2383 VERIFICATION( (TypeThR>=0) && (TypeThR<=4) );
2387 //=============================================================================
2388 int HOMARD_Hypothesis::GetRefinThrType() const
2392 //=============================================================================
2393 double HOMARD_Hypothesis::GetThreshR() const
2397 //=============================================================================
2398 void HOMARD_Hypothesis::SetUnRefThr( int TypeThC, double ThreshC )
2400 VERIFICATION( (TypeThC>=0) && (TypeThC<=4) );
2404 //=============================================================================
2405 int HOMARD_Hypothesis::GetUnRefThrType() const
2409 //=============================================================================
2410 double HOMARD_Hypothesis::GetThreshC() const
2414 //=============================================================================
2415 void HOMARD_Hypothesis::SetNivMax( int NivMax )
2416 //=============================================================================
2420 //=============================================================================
2421 const int HOMARD_Hypothesis::GetNivMax() const
2422 //=============================================================================
2426 //=============================================================================
2427 void HOMARD_Hypothesis::SetDiamMin( double DiamMin )
2428 //=============================================================================
2432 //=============================================================================
2433 const double HOMARD_Hypothesis::GetDiamMin() const
2434 //=============================================================================
2438 //=============================================================================
2439 void HOMARD_Hypothesis::SetAdapInit( int AdapInit )
2440 //=============================================================================
2442 _AdapInit = AdapInit;
2444 //=============================================================================
2445 const int HOMARD_Hypothesis::GetAdapInit() const
2446 //=============================================================================
2450 //=============================================================================
2451 void HOMARD_Hypothesis::SetExtraOutput( int ExtraOutput )
2452 //=============================================================================
2454 _ExtraOutput = ExtraOutput;
2456 //=============================================================================
2457 const int HOMARD_Hypothesis::GetExtraOutput() const
2458 //=============================================================================
2460 return _ExtraOutput;
2462 //=============================================================================
2463 void HOMARD_Hypothesis::AddGroup( const char* Group)
2465 // On commence par supprimer le groupe au cas ou il aurait deja ete insere
2466 // Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la
2467 // definition de l'hypothese
2468 SupprGroup( Group ) ;
2469 // Insertion veritable
2470 _ListGroupSelected.push_back(Group);
2472 //=============================================================================
2473 void HOMARD_Hypothesis::SupprGroup( const char* Group )
2475 MESSAGE ("SupprGroup pour "<<Group) ;
2476 std::list<std::string>::iterator it = find( _ListGroupSelected.begin(), _ListGroupSelected.end(), Group );
2477 if ( it != _ListGroupSelected.end() ) { it = _ListGroupSelected.erase( it ); }
2479 //=============================================================================
2480 void HOMARD_Hypothesis::SupprGroups()
2482 _ListGroupSelected.clear();
2484 //=============================================================================
2485 void HOMARD_Hypothesis::SetGroups( const std::list<std::string>& ListGroup )
2487 _ListGroupSelected.clear();
2488 std::list<std::string>::const_iterator it = ListGroup.begin();
2489 while(it != ListGroup.end())
2490 _ListGroupSelected.push_back((*it++));
2492 //=============================================================================
2493 const std::list<std::string>& HOMARD_Hypothesis::GetGroups() const
2495 return _ListGroupSelected;
2497 //=============================================================================
2498 // Type d'interpolation des champs :
2499 // 0 : aucun champ n'est interpole
2500 // 1 : tous les champs sont interpoles
2501 // 2 : certains champs sont interpoles
2502 void HOMARD_Hypothesis::SetTypeFieldInterp( int TypeFieldInterp )
2504 VERIFICATION( (TypeFieldInterp>=0) && (TypeFieldInterp<=2) );
2505 _TypeFieldInterp = TypeFieldInterp;
2507 //=============================================================================
2508 int HOMARD_Hypothesis::GetTypeFieldInterp() const
2510 return _TypeFieldInterp;
2512 //=============================================================================
2513 void HOMARD_Hypothesis::AddFieldInterpType( const char* FieldInterp, int TypeInterp )
2515 MESSAGE ("Dans AddFieldInterpType pour " << FieldInterp << " et TypeInterp = " << TypeInterp) ;
2516 // On commence par supprimer le champ au cas ou il aurait deja ete insere
2517 // Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la
2518 // definition de l'hypothese
2519 SupprFieldInterp( FieldInterp ) ;
2520 // Insertion veritable
2522 _ListFieldInterp.push_back( std::string( FieldInterp ) );
2524 std::stringstream saux1 ;
2525 saux1 << TypeInterp ;
2526 _ListFieldInterp.push_back( saux1.str() );
2527 // . Indication generale : certains champs sont a interpoler
2528 SetTypeFieldInterp ( 2 ) ;
2530 //=============================================================================
2531 void HOMARD_Hypothesis::SupprFieldInterp( const char* FieldInterp )
2533 MESSAGE ("Dans SupprFieldInterp pour " << FieldInterp) ;
2534 std::list<std::string>::iterator it = find( _ListFieldInterp.begin(), _ListFieldInterp.end(), FieldInterp ) ;
2535 // Attention a supprimer le nom du champ et le type d'usage
2536 if ( it != _ListFieldInterp.end() )
2538 it = _ListFieldInterp.erase( it ) ;
2539 it = _ListFieldInterp.erase( it ) ;
2541 // Decompte du nombre de champs restant a interpoler
2542 it = _ListFieldInterp.begin() ;
2544 while(it != _ListFieldInterp.end())
2549 MESSAGE("Nombre de champ restants = "<<cpt/2);
2550 // . Indication generale : aucun champ ne reste a interpoler
2553 SetTypeFieldInterp ( 0 ) ;
2556 //=============================================================================
2557 void HOMARD_Hypothesis::SupprFieldInterps()
2559 MESSAGE ("SupprFieldInterps") ;
2560 _ListFieldInterp.clear();
2561 // . Indication generale : aucun champ ne reste a interpoler
2562 SetTypeFieldInterp ( 0 ) ;
2564 //=============================================================================
2565 const std::list<std::string>& HOMARD_Hypothesis::GetFieldInterps() const
2567 return _ListFieldInterp;
2569 //=============================================================================
2570 //=============================================================================
2571 // Liens avec les autres structures
2572 //=============================================================================
2573 //=============================================================================
2574 void HOMARD_Hypothesis::SetCaseCreation( const char* NomCasCreation )
2576 _NomCasCreation = std::string( NomCasCreation );
2578 //=============================================================================
2579 std::string HOMARD_Hypothesis::GetCaseCreation() const
2581 return _NomCasCreation;
2583 //=============================================================================
2584 void HOMARD_Hypothesis::LinkIteration( const char* NomIteration )
2586 _ListIter.push_back( std::string( NomIteration ) );
2588 //=============================================================================
2589 void HOMARD_Hypothesis::UnLinkIteration( const char* NomIteration )
2591 std::list<std::string>::iterator it = find( _ListIter.begin(), _ListIter.end(), NomIteration ) ;
2592 if ( it != _ListIter.end() )
2594 MESSAGE ("Dans UnLinkIteration pour " << NomIteration) ;
2595 it = _ListIter.erase( it ) ;
2598 //=============================================================================
2599 void HOMARD_Hypothesis::UnLinkIterations()
2603 //=============================================================================
2604 const std::list<std::string>& HOMARD_Hypothesis::GetIterations() const
2608 //=============================================================================
2609 void HOMARD_Hypothesis::AddZone( const char* NomZone, int TypeUse )
2611 MESSAGE ("Dans AddZone pour " << NomZone << " et TypeUse = " << TypeUse) ;
2612 // On commence par supprimer la zone au cas ou elle aurait deja ete inseree
2613 // Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la
2614 // definition de l'hypothese
2615 SupprZone( NomZone ) ;
2616 // Insertion veritable
2618 _ListZone.push_back( std::string( NomZone ) );
2619 // . Usage de la zone
2620 std::stringstream saux1 ;
2622 _ListZone.push_back( saux1.str() );
2624 //=============================================================================
2625 void HOMARD_Hypothesis::SupprZone( const char* NomZone )
2627 MESSAGE ("Dans SupprZone pour " << NomZone) ;
2628 std::list<std::string>::iterator it = find( _ListZone.begin(), _ListZone.end(), NomZone );
2629 // Attention a supprimer le nom de zone et le type d'usage
2630 if ( it != _ListZone.end() )
2632 it = _ListZone.erase( it );
2633 it = _ListZone.erase( it );
2636 //=============================================================================
2637 void HOMARD_Hypothesis::SupprZones()
2641 //=============================================================================
2642 const std::list<std::string>& HOMARD_Hypothesis::GetZones() const
2647 //=============================================================================
2649 * default constructor:
2651 //=============================================================================
2652 HOMARD_Iteration::HOMARD_Iteration():
2653 _Name( "" ), _Etat( 0 ),
2655 _NomMesh( "" ), _MeshFile( "" ),
2656 _FieldFile( "" ), _TimeStep( -1 ), _Rank( -1 ),
2659 _NomHypo( "" ), _NomCas( "" ), _NomDir( "" ),
2663 MESSAGE("HOMARD_Iteration");
2665 //=============================================================================
2669 //=============================================================================
2670 HOMARD_Iteration::~HOMARD_Iteration()
2672 MESSAGE("~HOMARD_Iteration");
2674 //=============================================================================
2675 //=============================================================================
2677 //=============================================================================
2678 //=============================================================================
2679 void HOMARD_Iteration::SetName( const char* Name )
2681 _Name = std::string( Name );
2683 //=============================================================================
2684 std::string HOMARD_Iteration::GetName() const
2688 //=============================================================================
2689 //=============================================================================
2691 //=============================================================================
2692 //=============================================================================
2693 void HOMARD_Iteration::SetDirNameLoc( const char* NomDir )
2695 _NomDir = std::string( NomDir );
2697 //=============================================================================
2698 std::string HOMARD_Iteration::GetDirNameLoc() const
2702 //=============================================================================
2703 void HOMARD_Iteration::SetNumber( int NumIter )
2707 //=============================================================================
2708 int HOMARD_Iteration::GetNumber() const
2712 //=============================================================================
2713 void HOMARD_Iteration::SetState( int etat )
2717 //=============================================================================
2718 int HOMARD_Iteration::GetState() const
2722 //=============================================================================
2723 void HOMARD_Iteration::SetMeshName( const char* NomMesh )
2725 _NomMesh = std::string( NomMesh );
2727 //=============================================================================
2728 std::string HOMARD_Iteration::GetMeshName() const
2732 //=============================================================================
2733 void HOMARD_Iteration::SetMeshFile( const char* MeshFile )
2735 _MeshFile = std::string( MeshFile );
2737 //=============================================================================
2738 std::string HOMARD_Iteration::GetMeshFile() const
2742 //=============================================================================
2743 void HOMARD_Iteration::SetFieldFile( const char* FieldFile )
2745 _FieldFile = std::string( FieldFile );
2747 //=============================================================================
2748 std::string HOMARD_Iteration::GetFieldFile() const
2752 //=============================================================================
2753 // Instants pour le champ de pilotage
2754 //=============================================================================
2755 void HOMARD_Iteration::SetTimeStep( int TimeStep )
2757 _TimeStep = TimeStep;
2759 //=============================================================================
2760 void HOMARD_Iteration::SetTimeStepRank( int TimeStep, int Rank )
2762 _TimeStep = TimeStep;
2765 //=============================================================================
2766 void HOMARD_Iteration::SetTimeStepRankLast()
2770 //=============================================================================
2771 int HOMARD_Iteration::GetTimeStep() const
2775 //=============================================================================
2776 int HOMARD_Iteration::GetRank() const
2780 //=============================================================================
2781 // Instants pour un champ a interpoler
2782 //=============================================================================
2783 void HOMARD_Iteration::SetFieldInterpTimeStep( const char* FieldInterp, int TimeStep )
2785 SetFieldInterpTimeStepRank( FieldInterp, TimeStep, TimeStep ) ;
2787 //=============================================================================
2788 void HOMARD_Iteration::SetFieldInterpTimeStepRank( const char* FieldInterp, int TimeStep, int Rank )
2790 MESSAGE("Champ " << FieldInterp << ", hypothese " << _NomHypo )
2791 // Verification de la presence du champ dans l'hypothese
2792 std::list<std::string>::iterator it = find( _ListFieldInterp.begin(), _ListFieldInterp.end(), FieldInterp );
2793 if ( it == _ListFieldInterp.end() )
2795 INFOS("Champ " << FieldInterp << " ; hypothese " << _NomHypo )
2796 VERIFICATION("Le champ est inconnu dans l'hypothese associee a cette iteration." == 0);
2800 _ListFieldInterpTSR.push_back( std::string( FieldInterp ) );
2802 std::stringstream saux1 ;
2804 _ListFieldInterpTSR.push_back( saux1.str() );
2806 std::stringstream saux2 ;
2808 _ListFieldInterpTSR.push_back( saux2.str() );
2810 //=============================================================================
2811 const std::list<std::string>& HOMARD_Iteration::GetFieldInterpsTimeStepRank() const
2813 return _ListFieldInterpTSR;
2815 //=============================================================================
2816 void HOMARD_Iteration::SetFieldInterp( const char* FieldInterp )
2818 _ListFieldInterp.push_back( std::string( FieldInterp ) );
2820 //=============================================================================
2821 const std::list<std::string>& HOMARD_Iteration::GetFieldInterps() const
2823 return _ListFieldInterp;
2825 //=============================================================================
2826 void HOMARD_Iteration::SupprFieldInterps()
2828 _ListFieldInterp.clear();
2830 //=============================================================================
2831 void HOMARD_Iteration::SetLogFile( const char* LogFile )
2833 _LogFile = std::string( LogFile );
2835 //=============================================================================
2836 std::string HOMARD_Iteration::GetLogFile() const
2840 //=============================================================================
2841 void HOMARD_Iteration::SetFileInfo( const char* FileInfo )
2843 _FileInfo = std::string( FileInfo );
2845 //=============================================================================
2846 std::string HOMARD_Iteration::GetFileInfo() const
2850 //=============================================================================
2851 //=============================================================================
2852 // Liens avec les autres iterations
2853 //=============================================================================
2854 //=============================================================================
2855 void HOMARD_Iteration::LinkNextIteration( const char* NomIteration )
2857 _mesIterFilles.push_back( std::string( NomIteration ) );
2859 //=============================================================================
2860 void HOMARD_Iteration::UnLinkNextIteration( const char* NomIteration )
2862 std::list<std::string>::iterator it = find( _mesIterFilles.begin(), _mesIterFilles.end(), NomIteration ) ;
2863 if ( it != _mesIterFilles.end() )
2865 MESSAGE ("Dans UnLinkNextIteration pour " << NomIteration) ;
2866 it = _mesIterFilles.erase( it ) ;
2869 //=============================================================================
2870 void HOMARD_Iteration::UnLinkNextIterations()
2872 _mesIterFilles.clear();
2874 //=============================================================================
2875 const std::list<std::string>& HOMARD_Iteration::GetIterations() const
2877 return _mesIterFilles;
2879 //=============================================================================
2880 void HOMARD_Iteration::SetIterParentName( const char* IterParent )
2882 _IterParent = IterParent;
2884 //=============================================================================
2885 std::string HOMARD_Iteration::GetIterParentName() const
2889 //=============================================================================
2890 //=============================================================================
2891 // Liens avec les autres structures
2892 //=============================================================================
2893 //=============================================================================
2894 void HOMARD_Iteration::SetCaseName( const char* NomCas )
2896 _NomCas = std::string( NomCas );
2898 //=============================================================================
2899 std::string HOMARD_Iteration::GetCaseName() const
2903 //=============================================================================
2904 void HOMARD_Iteration::SetHypoName( const char* NomHypo )
2906 _NomHypo = std::string( NomHypo );
2908 //=============================================================================
2909 std::string HOMARD_Iteration::GetHypoName() const
2913 //=============================================================================
2914 //=============================================================================
2916 //=============================================================================
2917 //=============================================================================
2918 void HOMARD_Iteration::SetInfoCompute( int MessInfo )
2920 _MessInfo = MessInfo;
2922 //=============================================================================
2923 int HOMARD_Iteration::GetInfoCompute() const
2928 } // namespace SMESHHOMARDImpl /end/