Salome HOME
d983675c8c70e4292175faae6913d3572d25a646
[modules/smesh.git] / src / SMESH / SMESH_Homard.hxx
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.hxx
22 //  Author : Gerald NICOLAS, EDF
23 //  Module : HOMARD
24
25 #ifndef _SMESH_HOMARD_ADAPT_HXX_
26 #define _SMESH_HOMARD_ADAPT_HXX_
27
28 // C'est le ASSERT de SALOMELocalTrace/utilities.h dans KERNEL
29 #ifndef VERIFICATION
30 #define VERIFICATION(condition) \
31         if (!(condition)){INTERRUPTION("CONDITION "<<#condition<<" NOT VERIFIED")}
32 #endif /* VERIFICATION */
33
34 #ifdef WIN32
35   #if defined HOMARDIMPL_EXPORTS || defined HOMARDImpl_EXPORTS
36     #define HOMARDIMPL_EXPORT __declspec( dllexport )
37   #else
38     #define HOMARDIMPL_EXPORT __declspec( dllimport )
39   #endif
40 #else
41    #define HOMARDIMPL_EXPORT
42 #endif
43
44 // La gestion des repertoires
45 #ifndef CHDIR
46   #ifdef WIN32
47     #define CHDIR _chdir
48   #else
49     #define CHDIR chdir
50   #endif
51 #endif
52
53 #include <vector>
54 #include <string>
55 #include <list>
56
57 #include <iostream>
58 #include <fstream>
59
60 #if defined WIN32
61 #pragma warning ( disable: 4251 )
62 #endif
63
64 namespace SMESHHOMARDImpl
65 {
66
67 class HOMARDIMPL_EXPORT HOMARD_Boundary
68 {
69 public:
70   HOMARD_Boundary();
71   ~HOMARD_Boundary();
72
73 // Generalites
74   void                          SetName( const char* Name );
75   std::string                   GetName() const;
76
77   std::string                   GetDumpPython() const;
78
79 // Caracteristiques
80   void                          SetType( int Type );
81   int                           GetType() const;
82
83   void                          SetMeshName( const char* MeshName );
84   std::string                   GetMeshName() const;
85
86   void                          SetDataFile( const char* DataFile );
87   std::string                   GetDataFile() const;
88
89   void                          SetCylinder( double X0, double X1, double X2, double X3,
90                                              double X4, double X5, double X6 );
91   void                          SetSphere( double X0, double X1, double X2, double X3 );
92   void                          SetConeR( double Xcentre1, double Ycentre1, double Zcentre1, double Rayon1,
93                                           double Xcentre2, double Ycentre2, double Zcentre2, double Rayon2);
94   void                          SetConeA( double Xaxe, double Yaxe, double Zaxe, double Angle,
95                                           double Xcentre, double Ycentre, double ZCentre);
96   void                          SetTorus( double X0, double X1, double X2, double X3,
97                                              double X4, double X5, double X6, double X7 );
98
99   std::vector<double>           GetCoords() const;
100
101   void                          SetLimit( double X0, double X1, double X2 );
102   std::vector<double>           GetLimit() const;
103
104   void                          AddGroup( const char* LeGroupe);
105   void                          SetGroups(const std::list<std::string>& ListGroup );
106   const std::list<std::string>& GetGroups() const;
107
108 // Liens avec les autres structures
109   std::string                   GetCaseCreation() const;
110   void                          SetCaseCreation( const char* NomCasCreation );
111
112 private:
113   std::string                   _Name;
114   std::string                   _NomCasCreation;
115   std::string                   _DataFile;
116   std::string                   _MeshName;
117   int                           _Type;
118   double                        _Xmin, _Xmax, _Ymin, _Ymax, _Zmin, _Zmax;
119   double                        _Xaxe, _Yaxe, _Zaxe;
120   double                        _Xcentre, _Ycentre, _Zcentre, _rayon;
121   double                        _Xincr, _Yincr, _Zincr;
122   double                        _Xcentre1, _Ycentre1, _Zcentre1, _Rayon1;
123   double                        _Xcentre2, _Ycentre2, _Zcentre2, _Rayon2;
124   double                        _Angle;
125
126   std::list<std::string>        _ListGroupSelected;
127
128 };
129
130 class HOMARDIMPL_EXPORT HOMARD_Cas
131 {
132 public:
133   HOMARD_Cas();
134   ~HOMARD_Cas();
135
136 // Generalites
137   void                          SetName( const char* Name );
138   std::string                   GetName() const;
139
140   std::string                   GetDumpPython() const;
141
142 // Caracteristiques
143   int                           SetDirName( const char* NomDir );
144   std::string                   GetDirName() const;
145
146   int                           GetNumberofIter();
147
148   void                          SetConfType( int ConfType );
149   const int                     GetConfType() const;
150
151   void                          SetExtType( int ExtType );
152   const int                     GetExtType() const;
153
154   void                          SetBoundingBox( const std::vector<double>& extremas );
155   const std::vector<double>&    GetBoundingBox() const;
156
157   void                          AddGroup( const char* Group);
158   void                          SetGroups( const std::list<std::string>& ListGroup );
159   const std::list<std::string>& GetGroups() const;
160   void                          SupprGroups();
161
162   void                          AddBoundary( const char* Boundary );
163   void                          AddBoundaryGroup( const char* Boundary, const char* Group );
164   const std::list<std::string>& GetBoundaryGroup() const;
165   void                          SupprBoundaryGroup();
166
167   void                          SetPyram( int Pyram );
168   const int                     GetPyram() const;
169
170 // Liens avec les autres structures
171   std::string                   GetIter0Name() const;
172
173   void                          AddIteration( const char* NomIteration );
174   const std::list<std::string>& GetIterations() const;
175   void                          SupprIterations();
176
177 private:
178   std::string                   _Name;
179   std::string                   _NomDir;
180   int                           _ConfType;
181   int                           _ExtType;
182   int                           _Etat;
183
184   std::vector<double>           _Boite;         // cf HomardQTCommun pour structure du vecteur
185   std::list<std::string>        _ListGroup;
186   std::list<std::string>        _ListBoundaryGroup;
187
188   int                           _Pyram;
189
190   typedef std::string           IterName;
191   typedef std::list<IterName>   IterNames;
192   IterNames                     _ListIter;
193 };
194
195 class HOMARDIMPL_EXPORT HomardDriver
196 {
197 public:
198   HomardDriver(const std::string siter, const std::string siterp1);
199   ~HomardDriver();
200   //
201   void        TexteInit( const std::string DirCompute, const std::string LogFile, const std::string Langue );
202   void        TexteInfo( int TypeBila, int NumeIter );
203   void        TexteMajCoords( int NumeIter );
204   void        CreeFichierDonn();
205   void        TexteAdap( int ExtType );
206   void        CreeFichier();
207   void        TexteMaillage( const std::string NomMesh, const std::string MeshFile, int apres );
208   void        TexteMaillageHOMARD( const std::string Dir, const std::string liter, int apres );
209   void        TexteConfRaffDera( int ConfType, int TypeAdap, int TypeRaff, int TypeDera );
210   void        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 );
211   void        TexteGroup( const std::string GroupName );
212   void        TexteField( const std::string FieldName, const std::string FieldFile,
213                           int TimeStep, int Rank,
214                           int TypeThR, double ThreshR, int TypeThC, double ThreshC,
215                           int UsField, int UsCmpI );
216   void        TexteCompo( int NumeComp, const std::string NomCompo);
217
218   void        TexteBoundaryOption( int BoundaryOption );
219   void        TexteBoundaryCAOGr( const std::string GroupName );
220   void        TexteBoundaryDi( const std::string MeshName, const std::string MeshFile );
221   void        TexteBoundaryDiGr( const std::string GroupName );
222   void        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 );
223   void        TexteBoundaryAnGr( const std::string NameBoundary, int NumeBoundary, const std::string GroupName );
224
225   void        TexteFieldInterp( const std::string FieldFile, const std::string MeshFile );
226   void        TexteFieldInterpAll();
227   void        TexteFieldInterpNameType( int NumeChamp, const std::string FieldName, const std::string TypeInterp, int TimeStep, int Rank );
228   void        TexteAdvanced( int Pyram, int NivMax, double DiamMin, int AdapInit, int LevelOutput );
229   void        TexteInfoCompute( int MessInfo );
230   //
231   int         ExecuteHomard(int option);
232   //
233
234 public:
235   int         _modeHOMARD;
236   std::string _HOMARD_Exec;
237   std::string _NomDir;
238   std::string _NomFichierConfBase;
239   std::string _NomFichierConf;
240   std::string _NomFichierDonn;
241   std::string _siter;
242   std::string _siterp1;
243   std::string _Texte;
244   int         _TimeStep;
245   int         _Rank;
246   bool _bLu;
247 };
248
249 class HOMARD_Iteration;
250 class HOMARD_Hypothesis;
251
252   //! persistence entity type
253   typedef enum { Case, Zone, Hypothesis, Iteration, Boundary } SignatureType;
254
255   //! get persistence signature
256   HOMARDIMPL_EXPORT std::string GetSignature( SignatureType type );
257
258   //! get data separator
259   HOMARDIMPL_EXPORT std::string separator();
260
261   //! dump boundary to the string
262   HOMARDIMPL_EXPORT std::string Dump( const SMESHHOMARDImpl::HOMARD_Boundary& boundary );
263   //! dump case to the string
264   HOMARDIMPL_EXPORT std::string Dump( const SMESHHOMARDImpl::HOMARD_Cas& cas );
265   //! dump iteration to the string
266   HOMARDIMPL_EXPORT std::string Dump( const SMESHHOMARDImpl::HOMARD_Iteration& iteration );
267   //! dump hypothesis to the string
268   HOMARDIMPL_EXPORT std::string Dump( const SMESHHOMARDImpl::HOMARD_Hypothesis& hypothesis );
269
270   //! restore boundary from the string
271   HOMARDIMPL_EXPORT bool Restore( SMESHHOMARDImpl::HOMARD_Boundary& boundary, const std::string& stream );
272   //! restore case from the string
273   HOMARDIMPL_EXPORT bool Restore( SMESHHOMARDImpl::HOMARD_Cas& cas, const std::string& stream );
274   //! restore hypothesis from the string
275   HOMARDIMPL_EXPORT bool Restore( SMESHHOMARDImpl::HOMARD_Hypothesis& hypothesis, const std::string& stream );
276   //! restore iteration from the string
277   HOMARDIMPL_EXPORT bool Restore( SMESHHOMARDImpl::HOMARD_Iteration& iteration, const std::string& stream );
278
279 class HOMARDIMPL_EXPORT HOMARD_Gen
280 {
281 public :
282   HOMARD_Gen();
283   ~HOMARD_Gen();
284 };
285
286 class HOMARDIMPL_EXPORT HOMARD_Hypothesis
287 {
288 public:
289   HOMARD_Hypothesis();
290   ~HOMARD_Hypothesis();
291
292 // Generalites
293   void                          SetName( const char* Name );
294   std::string                   GetName() const;
295
296   std::string                   GetDumpPython() const;
297
298 // Caracteristiques
299   void                          SetAdapType( int TypeAdap );
300   int                           GetAdapType() const;
301   void                          SetRefinTypeDera( int TypeRaff, int TypeDera );
302   int                           GetRefinType() const;
303   int                           GetUnRefType() const;
304
305   void                          SetField( const char* FieldName );
306   std::string                   GetFieldName() const;
307   void                          SetUseField( int UsField );
308   int                           GetUseField()    const;
309
310   void                          SetUseComp( int UsCmpI );
311   int                           GetUseComp()    const;
312   void                          AddComp( const char* NomComp );
313   void                          SupprComp( const char* NomComp );
314   void                          SupprComps();
315   const std::list<std::string>& GetComps() const;
316
317   void                          SetRefinThr( int TypeThR, double ThreshR );
318   int                           GetRefinThrType()   const;
319   double                        GetThreshR()   const;
320   void                          SetUnRefThr( int TypeThC, double ThreshC );
321   int                           GetUnRefThrType()   const;
322   double                        GetThreshC()   const;
323
324   void                          SetNivMax( int NivMax );
325   const int                     GetNivMax() const;
326
327   void                          SetDiamMin( double DiamMin );
328   const double                  GetDiamMin() const;
329
330   void                          SetAdapInit( int AdapInit );
331   const int                     GetAdapInit() const;
332
333   void                          SetExtraOutput( int ExtraOutput );
334   const int                     GetExtraOutput() const;
335
336   void                          AddGroup( const char* Group);
337   void                          SupprGroup( const char* Group );
338   void                          SupprGroups();
339   void                          SetGroups(const std::list<std::string>& ListGroup );
340   const std::list<std::string>& GetGroups() const;
341
342   void                          SetTypeFieldInterp( int TypeFieldInterp );
343   int                           GetTypeFieldInterp() const;
344   void                          AddFieldInterpType( const char* FieldInterp, int TypeInterp );
345   void                          SupprFieldInterp( const char* FieldInterp );
346   void                          SupprFieldInterps();
347   const std::list<std::string>& GetFieldInterps() const;
348
349 // Liens avec les autres structures
350   void                          SetCaseCreation( const char* NomCasCreation );
351   std::string                   GetCaseCreation() const;
352
353   void                          LinkIteration( const char* NomIter );
354   void                          UnLinkIteration( const char* NomIter );
355   void                          UnLinkIterations();
356   const std::list<std::string>& GetIterations() const;
357
358   void                          AddZone( const char* NomZone, int TypeUse );
359   void                          SupprZone( const char* NomZone );
360   void                          SupprZones();
361   const std::list<std::string>& GetZones() const;
362
363 private:
364   std::string                   _Name;
365   std::string                   _NomCasCreation;
366
367   int                           _TypeAdap; // -1 pour une adapation Uniforme,
368                                            //  0 si l adaptation depend des zones,
369                                            //  1 pour des champs
370
371   int                           _TypeRaff;
372   int                           _TypeDera;
373
374   std::string                   _Field;
375   int                           _TypeThR;
376   int                           _TypeThC;
377   double                        _ThreshR;
378   double                        _ThreshC;
379   int                           _UsField;
380   int                           _UsCmpI;
381   int                           _TypeFieldInterp; // 0 pour aucune interpolation,
382                                                   // 1 pour interpolation de tous les champs,
383                                                   // 2 pour une liste
384   int                           _NivMax;
385   double                        _DiamMin;
386   int                           _AdapInit;
387   int                           _ExtraOutput;
388
389   std::list<std::string>        _ListIter;
390   std::list<std::string>        _ListZone;
391   std::list<std::string>        _ListComp;
392   std::list<std::string>        _ListGroupSelected;
393   std::list<std::string>        _ListFieldInterp;
394 };
395
396 class HOMARDIMPL_EXPORT HOMARD_Iteration
397 {
398 public:
399   HOMARD_Iteration();
400   ~HOMARD_Iteration();
401
402 // Generalites
403   void                          SetName( const char* Name );
404   std::string                   GetName() const;
405
406   std::string                   GetDumpPython() const;
407
408 // Caracteristiques
409   void                          SetDirNameLoc( const char* NomDir );
410   std::string                   GetDirNameLoc() const;
411
412   void                          SetNumber( int NumIter );
413   int                           GetNumber() const;
414
415   void                          SetState( int etat );
416   int                           GetState() const;
417
418   void                          SetMeshName( const char* NomMesh );
419   std::string                   GetMeshName() const;
420
421   void                          SetMeshFile( const char* MeshFile );
422   std::string                   GetMeshFile() const;
423
424   void                          SetFieldFile( const char* FieldFile );
425   std::string                   GetFieldFile() const;
426 // Instants pour le champ de pilotage
427   void                          SetTimeStep( int TimeStep );
428   void                          SetTimeStepRank( int TimeStep, int Rank );
429   void                          SetTimeStepRankLast();
430   int                           GetTimeStep() const;
431   int                           GetRank() const;
432 // Instants pour un champ a interpoler
433   void                          SetFieldInterpTimeStep( const char* FieldInterp, int TimeStep );
434   void                          SetFieldInterpTimeStepRank( const char* FieldInterp, int TimeStep, int Rank );
435   const std::list<std::string>& GetFieldInterpsTimeStepRank() const;
436   void                          SetFieldInterp( const char* FieldInterp );
437   const std::list<std::string>& GetFieldInterps() const;
438   void                          SupprFieldInterps();
439
440   void                          SetLogFile( const char* LogFile );
441   std::string                   GetLogFile() const;
442
443   void                          SetFileInfo( const char* FileInfo );
444   std::string                   GetFileInfo() const;
445
446 // Liens avec les autres iterations
447   void                          LinkNextIteration( const char* NomIteration );
448   void                          UnLinkNextIteration( const char* NomIteration );
449   void                          UnLinkNextIterations();
450   const std::list<std::string>& GetIterations() const;
451
452   void                          SetIterParentName( const char* iterParent );
453   std::string                   GetIterParentName() const;
454
455 // Liens avec les autres structures
456   void                          SetCaseName( const char* NomCas );
457   std::string                   GetCaseName() const;
458
459   void                          SetHypoName( const char* NomHypo );
460   std::string                   GetHypoName() const;
461
462 // Divers
463   void                          SetInfoCompute( int MessInfo );
464   int                           GetInfoCompute() const;
465
466 private:
467   std::string                   _Name;
468   int                           _Etat;
469   int                           _NumIter;
470   std::string                   _NomMesh;
471   std::string                   _MeshFile;
472   std::string                   _FieldFile;
473   int                           _TimeStep;
474   int                           _Rank;
475   std::string                   _LogFile;
476   std::string                   _IterParent;
477   std::string                   _NomHypo;
478   std::string                   _NomCas;
479   std::string                   _NomDir;
480   std::list<std::string>        _mesIterFilles;
481   std::string                   _FileInfo;
482   int                           _MessInfo;
483   // La liste des champs retenus par l'hypothese
484   std::list<std::string>        _ListFieldInterp;
485   // La liste des triplets (champs, pas de temps, numero d'ordre) retenus par l'iteration
486   std::list<std::string>        _ListFieldInterpTSR;
487 };
488
489 }; // namespace SMESHHOMARDImpl
490
491 #endif