Salome HOME
45be4842417544a3ec498d17122189bda761397b
[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                          SetBoundingBox( const std::vector<double>& extremas );
152   const std::vector<double>&    GetBoundingBox() const;
153
154   void                          AddGroup( const char* Group);
155   void                          SetGroups( const std::list<std::string>& ListGroup );
156   const std::list<std::string>& GetGroups() const;
157   void                          SupprGroups();
158
159   void                          AddBoundary( const char* Boundary );
160   void                          AddBoundaryGroup( const char* Boundary, const char* Group );
161   const std::list<std::string>& GetBoundaryGroup() const;
162   void                          SupprBoundaryGroup();
163
164 // Liens avec les autres structures
165   std::string                   GetIter0Name() const;
166
167   void                          AddIteration( const char* NomIteration );
168   const std::list<std::string>& GetIterations() const;
169   void                          SupprIterations();
170
171 private:
172   std::string                   _Name;
173   std::string                   _NomDir;
174   int                           _ConfType;
175   int                           _Etat;
176
177   std::vector<double>           _Boite;         // cf HomardQTCommun pour structure du vecteur
178   std::list<std::string>        _ListGroup;
179   std::list<std::string>        _ListBoundaryGroup;
180
181   typedef std::string           IterName;
182   typedef std::list<IterName>   IterNames;
183   IterNames                     _ListIter;
184 };
185
186 class HOMARDIMPL_EXPORT HomardDriver
187 {
188 public:
189   HomardDriver(const std::string siter, const std::string siterp1);
190   ~HomardDriver();
191   //
192   void        TexteInit( const std::string DirCompute, const std::string LogFile, const std::string Langue );
193   void        TexteInfo( int TypeBila, int NumeIter );
194   void        TexteMajCoords( int NumeIter );
195   void        CreeFichierDonn();
196   void        TexteAdap();
197   void        CreeFichier();
198   void        TexteMaillage( const std::string NomMesh, const std::string MeshFile, int apres );
199   void        TexteMaillageHOMARD( const std::string Dir, const std::string liter, int apres );
200   void        TexteConfRaffDera( int ConfType, int TypeAdap, int TypeRaff, int TypeDera );
201   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 );
202   void        TexteGroup( const std::string GroupName );
203   void        TexteField( const std::string FieldName, const std::string FieldFile,
204                           int TimeStep, int Rank,
205                           int TypeThR, double ThreshR, int TypeThC, double ThreshC,
206                           int UsField, int UsCmpI );
207   void        TexteCompo( int NumeComp, const std::string NomCompo);
208
209   void        TexteBoundaryOption( int BoundaryOption );
210   void        TexteBoundaryCAOGr( const std::string GroupName );
211   void        TexteBoundaryDi( const std::string MeshName, const std::string MeshFile );
212   void        TexteBoundaryDiGr( const std::string GroupName );
213   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 );
214   void        TexteBoundaryAnGr( const std::string NameBoundary, int NumeBoundary, const std::string GroupName );
215
216   void        TexteFieldInterp( const std::string FieldFile, const std::string MeshFile );
217   void        TexteFieldInterpAll();
218   void        TexteFieldInterpNameType( int NumeChamp, const std::string FieldName, const std::string TypeInterp, int TimeStep, int Rank );
219   void        TexteAdvanced( int NivMax, double DiamMin, int AdapInit, int LevelOutput );
220   void        TexteInfoCompute( int MessInfo );
221   //
222   int         ExecuteHomard();
223
224 public:
225   int         _modeHOMARD;
226   std::string _HOMARD_Exec;
227   std::string _NomDir;
228   std::string _NomFichierConfBase;
229   std::string _NomFichierConf;
230   std::string _NomFichierDonn;
231   std::string _siter;
232   std::string _siterp1;
233   std::string _Texte;
234   int         _TimeStep;
235   int         _Rank;
236   bool _bLu;
237 };
238
239 class HOMARD_Iteration;
240 class HOMARD_Hypothesis;
241
242   //! persistence entity type
243   typedef enum { Case, Zone, Hypothesis, Iteration, Boundary } SignatureType;
244
245   //! get persistence signature
246   HOMARDIMPL_EXPORT std::string GetSignature( SignatureType type );
247
248   //! get data separator
249   HOMARDIMPL_EXPORT std::string separator();
250
251   //! dump boundary to the string
252   HOMARDIMPL_EXPORT std::string Dump( const SMESHHOMARDImpl::HOMARD_Boundary& boundary );
253   //! dump case to the string
254   HOMARDIMPL_EXPORT std::string Dump( const SMESHHOMARDImpl::HOMARD_Cas& cas );
255   //! dump iteration to the string
256   HOMARDIMPL_EXPORT std::string Dump( const SMESHHOMARDImpl::HOMARD_Iteration& iteration );
257   //! dump hypothesis to the string
258   HOMARDIMPL_EXPORT std::string Dump( const SMESHHOMARDImpl::HOMARD_Hypothesis& hypothesis );
259
260   //! restore boundary from the string
261   HOMARDIMPL_EXPORT bool Restore( SMESHHOMARDImpl::HOMARD_Boundary& boundary, const std::string& stream );
262   //! restore case from the string
263   HOMARDIMPL_EXPORT bool Restore( SMESHHOMARDImpl::HOMARD_Cas& cas, const std::string& stream );
264   //! restore hypothesis from the string
265   HOMARDIMPL_EXPORT bool Restore( SMESHHOMARDImpl::HOMARD_Hypothesis& hypothesis, const std::string& stream );
266   //! restore iteration from the string
267   HOMARDIMPL_EXPORT bool Restore( SMESHHOMARDImpl::HOMARD_Iteration& iteration, const std::string& stream );
268
269 class HOMARDIMPL_EXPORT HOMARD_Gen
270 {
271 public :
272   HOMARD_Gen();
273   ~HOMARD_Gen();
274 };
275
276 class HOMARDIMPL_EXPORT HOMARD_Hypothesis
277 {
278 public:
279   HOMARD_Hypothesis();
280   ~HOMARD_Hypothesis();
281
282 // Generalites
283   void                          SetName( const char* Name );
284   std::string                   GetName() const;
285
286 // Caracteristiques
287   void                          SetAdapType( int TypeAdap );
288   int                           GetAdapType() const;
289   void                          SetRefinTypeDera( int TypeRaff, int TypeDera );
290   int                           GetRefinType() const;
291   int                           GetUnRefType() const;
292
293   void                          SetField( const char* FieldName );
294   std::string                   GetFieldName() const;
295   void                          SetUseField( int UsField );
296   int                           GetUseField()    const;
297
298   void                          SetUseComp( int UsCmpI );
299   int                           GetUseComp()    const;
300   void                          AddComp( const char* NomComp );
301   void                          SupprComp( const char* NomComp );
302   void                          SupprComps();
303   const std::list<std::string>& GetComps() const;
304
305   void                          SetRefinThr( int TypeThR, double ThreshR );
306   int                           GetRefinThrType()   const;
307   double                        GetThreshR()   const;
308   void                          SetUnRefThr( int TypeThC, double ThreshC );
309   int                           GetUnRefThrType()   const;
310   double                        GetThreshC()   const;
311
312   void                          SetNivMax( int NivMax );
313   const int                     GetNivMax() const;
314
315   void                          SetDiamMin( double DiamMin );
316   const double                  GetDiamMin() const;
317
318   void                          SetAdapInit( int AdapInit );
319   const int                     GetAdapInit() const;
320
321   void                          SetExtraOutput( int ExtraOutput );
322   const int                     GetExtraOutput() const;
323
324   void                          AddGroup( const char* Group);
325   void                          SupprGroup( const char* Group );
326   void                          SupprGroups();
327   void                          SetGroups(const std::list<std::string>& ListGroup );
328   const std::list<std::string>& GetGroups() const;
329
330   void                          SetTypeFieldInterp( int TypeFieldInterp );
331   int                           GetTypeFieldInterp() const;
332   void                          AddFieldInterpType( const char* FieldInterp, int TypeInterp );
333   void                          SupprFieldInterp( const char* FieldInterp );
334   void                          SupprFieldInterps();
335   const std::list<std::string>& GetFieldInterps() const;
336
337 // Liens avec les autres structures
338   void                          SetCaseCreation( const char* NomCasCreation );
339   std::string                   GetCaseCreation() const;
340
341   void                          LinkIteration( const char* NomIter );
342   void                          UnLinkIteration( const char* NomIter );
343   void                          UnLinkIterations();
344   const std::list<std::string>& GetIterations() const;
345
346   void                          AddZone( const char* NomZone, int TypeUse );
347   void                          SupprZone( const char* NomZone );
348   void                          SupprZones();
349   const std::list<std::string>& GetZones() const;
350
351 private:
352   std::string                   _Name;
353   std::string                   _NomCasCreation;
354
355   int                           _TypeAdap; // -1 pour une adapation Uniforme,
356                                            //  0 si l adaptation depend des zones,
357                                            //  1 pour des champs
358
359   int                           _TypeRaff;
360   int                           _TypeDera;
361
362   std::string                   _Field;
363   int                           _TypeThR;
364   int                           _TypeThC;
365   double                        _ThreshR;
366   double                        _ThreshC;
367   int                           _UsField;
368   int                           _UsCmpI;
369   int                           _TypeFieldInterp; // 0 pour aucune interpolation,
370                                                   // 1 pour interpolation de tous les champs,
371                                                   // 2 pour une liste
372   int                           _NivMax;
373   double                        _DiamMin;
374   int                           _AdapInit;
375   int                           _ExtraOutput;
376
377   std::list<std::string>        _ListIter;
378   std::list<std::string>        _ListZone;
379   std::list<std::string>        _ListComp;
380   std::list<std::string>        _ListGroupSelected;
381   std::list<std::string>        _ListFieldInterp;
382 };
383
384 class HOMARDIMPL_EXPORT HOMARD_Iteration
385 {
386 public:
387   HOMARD_Iteration();
388   ~HOMARD_Iteration();
389
390   // Generalites
391   void                          SetName( const char* Name );
392   std::string                   GetName() const;
393
394   // Caracteristiques
395   void                          SetDirNameLoc( const char* NomDir );
396   std::string                   GetDirNameLoc() const;
397
398   void                          SetNumber( int NumIter );
399   int                           GetNumber() const;
400
401   void                          SetState( int etat );
402   int                           GetState() const;
403
404   void                          SetMeshName( const char* NomMesh );
405   std::string                   GetMeshName() const;
406
407   void                          SetMeshFile( const char* MeshFile );
408   std::string                   GetMeshFile() const;
409
410   void                          SetFieldFile( const char* FieldFile );
411   std::string                   GetFieldFile() const;
412 // Instants pour le champ de pilotage
413   void                          SetTimeStep( int TimeStep );
414   void                          SetTimeStepRank( int TimeStep, int Rank );
415   void                          SetTimeStepRankLast();
416   int                           GetTimeStep() const;
417   int                           GetRank() const;
418 // Instants pour un champ a interpoler
419   void                          SetFieldInterpTimeStep( const char* FieldInterp, int TimeStep );
420   void                          SetFieldInterpTimeStepRank( const char* FieldInterp, int TimeStep, int Rank );
421   const std::list<std::string>& GetFieldInterpsTimeStepRank() const;
422   void                          SetFieldInterp( const char* FieldInterp );
423   const std::list<std::string>& GetFieldInterps() const;
424   void                          SupprFieldInterps();
425
426   void                          SetLogFile( const char* LogFile );
427   std::string                   GetLogFile() const;
428
429   void                          SetFileInfo( const char* FileInfo );
430   std::string                   GetFileInfo() const;
431
432 // Liens avec les autres iterations
433   void                          LinkNextIteration( const char* NomIteration );
434   void                          UnLinkNextIteration( const char* NomIteration );
435   void                          UnLinkNextIterations();
436   const std::list<std::string>& GetIterations() const;
437
438   void                          SetIterParentName( const char* iterParent );
439   std::string                   GetIterParentName() const;
440
441 // Liens avec les autres structures
442   void                          SetCaseName( const char* NomCas );
443   std::string                   GetCaseName() const;
444
445   void                          SetHypoName( const char* NomHypo );
446   std::string                   GetHypoName() const;
447
448 // Divers
449   void                          SetInfoCompute( int MessInfo );
450   int                           GetInfoCompute() const;
451
452 private:
453   std::string                   _Name;
454   int                           _Etat;
455   int                           _NumIter;
456   std::string                   _NomMesh;
457   std::string                   _MeshFile;
458   std::string                   _FieldFile;
459   int                           _TimeStep;
460   int                           _Rank;
461   std::string                   _LogFile;
462   std::string                   _IterParent;
463   std::string                   _NomHypo;
464   std::string                   _NomCas;
465   std::string                   _NomDir;
466   std::list<std::string>        _mesIterFilles;
467   std::string                   _FileInfo;
468   int                           _MessInfo;
469   // La liste des champs retenus par l'hypothese
470   std::list<std::string>        _ListFieldInterp;
471   // La liste des triplets (champs, pas de temps, numero d'ordre) retenus par l'iteration
472   std::list<std::string>        _ListFieldInterpTSR;
473 };
474
475 }; // namespace SMESHHOMARDImpl
476
477 #endif