Salome HOME
updated copyright message
[modules/homard.git] / src / HOMARD / HOMARD_Hypothesis.cxx
index da2782160ca4c4caa7b64dc893be93778f3e757e..bcb496f3667b8152112950ac142883cecfe75580 100644 (file)
@@ -1,11 +1,11 @@
-//  HOMARD HOMARD : implementaion of HOMARD idl descriptions
+//  HOMARD HOMARD : implementation of HOMARD idl descriptions
 //
-// Copyright (C) 2011-2012  CEA/DEN, EDF R&D
+// Copyright (C) 2011-2023  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //  File   : HOMARD_Hypothesis.cxx
-//  Author : Paul RASCLE, EDF
+//  Author : Gerald NICOLAS, EDF
 //  Module : HOMARD
+//
+// Remarques :
+// L'ordre de description des fonctions est le meme dans tous les fichiers
+// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx :
+// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore
+// 2. Les caracteristiques
+// 3. Le lien avec les autres structures
+//
+// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier
 
 #include "HOMARD_Hypothesis.hxx"
+#include "HOMARD.hxx"
 #include "utilities.h"
 
 //=============================================================================
@@ -49,36 +59,15 @@ HOMARD_Hypothesis::~HOMARD_Hypothesis()
 {
   MESSAGE("~HOMARD_Hypothesis");
 }
-
 //=============================================================================
-/*!
- */
-//=============================================================================
-void HOMARD_Hypothesis::SetCaseCreation( const char* NomCasCreation )
-{
-  _NomCasCreation = std::string( NomCasCreation );
-}
-
-//=============================================================================
-/*!
-*/
 //=============================================================================
-std::string HOMARD_Hypothesis::GetCaseCreation() const
-{
-  return _NomCasCreation;
-}
+// Generalites
 //=============================================================================
-/*!
-*/
 //=============================================================================
 void HOMARD_Hypothesis::SetName( const char* Name )
 {
   _Name = std::string( Name );
 }
-
-//=============================================================================
-/*!
-*/
 //=============================================================================
 std::string HOMARD_Hypothesis::GetName() const
 {
@@ -90,7 +79,13 @@ std::string HOMARD_Hypothesis::GetDumpPython() const
   std::ostringstream aScript;
   aScript << "\n# Creation of the hypothesis " << _Name << "\n" ;
   aScript << "\t" << _Name << " = homard.CreateHypothesis(\"" << _Name << "\")\n";
-  aScript << "\t" << _Name << ".SetAdapRefinUnRef(" << _TypeAdap << ", " << _TypeRaff << ", " << _TypeDera << ")\n";
+  if ( _TypeAdap == -1 )
+  {
+    int TypeRaffDera ;
+    if ( _TypeRaff == 1 ) { TypeRaffDera = 1 ; }
+    else                  { TypeRaffDera = -1 ; }
+    aScript << "\t" << _Name << ".SetUnifRefinUnRef(" << TypeRaffDera << ")\n";
+  }
 
 // Raffinement selon des zones geometriques
   std::list<std::string>::const_iterator it = _ListZone.begin();
@@ -111,8 +106,8 @@ std::string HOMARD_Hypothesis::GetDumpPython() const
     aScript << "\t" << _Name << ".SetField(\"" << _Field << "\")\n";
     aScript << "\t" << _Name << ".SetUseField(" << _UsField << ")\n";
     aScript << "\t" << _Name << ".SetUseComp(" << _UsCmpI << ")\n";
-    std::list<std::string>::const_iterator it_comp = _ListComposant.begin();
-    while(it_comp != _ListComposant.end())
+    std::list<std::string>::const_iterator it_comp = _ListComp.begin();
+    while(it_comp != _ListComp.end())
     {
       aScript << "\t" << _Name << ".AddComp(\"" << *it_comp << "\")\n";
       it_comp++;
@@ -131,17 +126,22 @@ std::string HOMARD_Hypothesis::GetDumpPython() const
    for ( it=_ListGroupSelected.begin(); it!=_ListGroupSelected.end();it++)
        aScript << "\t" << _Name << ".AddGroup(\""  << (*it) <<  "\")\n" ;
 
-// Interpolation champ
-  aScript << "\t" << _Name << ".SetTypeFieldInterp(" << _TypeFieldInterp << ")\n";
+// Interpolation des champs
   if ( _TypeFieldInterp == 2 )
   {
     std::list<std::string>::const_iterator it_champ = _ListFieldInterp.begin();
     while(it_champ != _ListFieldInterp.end())
     {
-      aScript << "\t" << _Name << ".AddFieldInterp(\"" << *it_champ << "\")\n";
+      aScript << "\t" << _Name << ".AddFieldInterpType( \"" << *it_champ  <<  "\" " ;
+      it_champ++;
+      aScript << ", " << *it_champ << ")\n";
       it_champ++;
     }
   }
+  else if ( _TypeFieldInterp != 0 )
+  {
+    aScript << "\t" << _Name << ".SetTypeFieldInterp(" << _TypeFieldInterp << ")\n";
+  }
   if ( _NivMax > 0 )
   {
     aScript << "\t" <<_Name << ".SetNivMax(" << _NivMax << ")\n";
@@ -154,67 +154,46 @@ std::string HOMARD_Hypothesis::GetDumpPython() const
   {
     aScript << "\t" <<_Name << ".SetAdapInit(" << _AdapInit << ")\n";
   }
-  if ( _LevelOutput != 0 )
+  if ( _ExtraOutput != 1 )
   {
-    aScript << "\t" <<_Name << ".SetLevelOutput(" << _LevelOutput << ")\n";
+    aScript << "\t" <<_Name << ".SetExtraOutput(" << _ExtraOutput << ")\n";
   }
 
   return aScript.str();
 }
-
-
 //=============================================================================
-/*!
-*/
+//=============================================================================
+// Caracteristiques
+//=============================================================================
 //=============================================================================
 void HOMARD_Hypothesis::SetAdapType( int TypeAdap )
 {
-  ASSERT (!((TypeAdap < -1) or (TypeAdap > 1)));
+  VERIFICATION( (TypeAdap>=-1) && (TypeAdap<=1) );
   _TypeAdap = TypeAdap;
 }
-
-//=============================================================================
-/*!
-*/
 //=============================================================================
 int HOMARD_Hypothesis::GetAdapType() const
 {
   return _TypeAdap;
 }
-
-//=============================================================================
-/*!
-*/
 //=============================================================================
 void HOMARD_Hypothesis::SetRefinTypeDera( int TypeRaff, int TypeDera )
 {
-  ASSERT(!(( TypeRaff < 0) or (TypeRaff > 1)));
+  VERIFICATION( (TypeRaff>=-1) && (TypeRaff<=1) );
   _TypeRaff = TypeRaff;
-  ASSERT(! ((TypeDera < 0) or (TypeDera > 1)));
+  VERIFICATION( (TypeDera>=-1) && (TypeDera<=1) );
   _TypeDera = TypeDera;
 }
-
-//=============================================================================
-/*!
-*/
 //=============================================================================
 int HOMARD_Hypothesis::GetRefinType() const
 {
   return _TypeRaff;
 }
-
-//=============================================================================
-/*!
-*/
 //=============================================================================
 int HOMARD_Hypothesis::GetUnRefType() const
 {
   return _TypeDera;
 }
-
-//=============================================================================
-/*!
-*/
 //=============================================================================
 void HOMARD_Hypothesis::SetField( const char* FieldName )
 {
@@ -222,40 +201,67 @@ void HOMARD_Hypothesis::SetField( const char* FieldName )
   MESSAGE( "SetField : FieldName = " << FieldName );
 }
 //=============================================================================
-void HOMARD_Hypothesis::SetRefinThr( int TypeThR, double ThreshR )
+std::string HOMARD_Hypothesis::GetFieldName() const
 {
-  MESSAGE( "SetRefinThr : TypeThR = " << TypeThR << ", ThreshR = " << ThreshR );
-  ASSERT(!(( TypeThR < 0) or (TypeThR > 3 )));
-  _TypeThR = TypeThR;
-  _ThreshR = ThreshR;
+  return _Field;
 }
 //=============================================================================
-void HOMARD_Hypothesis::SetUnRefThr( int TypeThC, double ThreshC )
+void HOMARD_Hypothesis::SetUseField( int UsField )
 {
-  ASSERT(!((TypeThC < 0) or (TypeThC > 3)));
-  _TypeThC = TypeThC;
-  _ThreshC = ThreshC;
+  VERIFICATION( (UsField>=0) && (UsField<=1) );
+  _UsField = UsField;
+}
+//=============================================================================
+int HOMARD_Hypothesis::GetUseField() const
+{
+  return _UsField;
 }
 //=============================================================================
 void HOMARD_Hypothesis::SetUseComp( int UsCmpI )
 {
-  ASSERT(!((UsCmpI < 0) or (UsCmpI > 2)));
+  MESSAGE ("SetUseComp pour UsCmpI = "<<UsCmpI) ;
+  VERIFICATION( (UsCmpI>=0) && (UsCmpI<=2) );
   _UsCmpI = UsCmpI;
 }
 //=============================================================================
-void HOMARD_Hypothesis::SetUseField( int UsField )
+int HOMARD_Hypothesis::GetUseComp() const
 {
-  ASSERT(!((UsField < 0) or (UsField > 1 )));
-  _UsField = UsField;
+  return _UsCmpI;
 }
-
 //=============================================================================
-/*!
-*/
+void HOMARD_Hypothesis::AddComp( const char* NomComp )
+{
+// On commence par supprimer la composante au cas ou elle aurait deja ete inseree
+// Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la
+// definition de l'hypothese
+  SupprComp( NomComp ) ;
+// Insertion veritable
+  _ListComp.push_back( std::string( NomComp ) );
+}
 //=============================================================================
-std::string HOMARD_Hypothesis::GetFieldName() const
+void HOMARD_Hypothesis::SupprComp( const char* NomComp )
 {
-  return _Field;
+  MESSAGE ("SupprComp pour "<<NomComp) ;
+  std::list<std::string>::iterator it = find( _ListComp.begin(), _ListComp.end(), NomComp );
+  if ( it != _ListComp.end() ) { it = _ListComp.erase( it ); }
+}
+//=============================================================================
+void HOMARD_Hypothesis::SupprComps()
+{
+  _ListComp.clear();
+}
+//=============================================================================
+const std::list<std::string>& HOMARD_Hypothesis::GetComps() const
+{
+  return _ListComp;
+}
+//=============================================================================
+void HOMARD_Hypothesis::SetRefinThr( int TypeThR, double ThreshR )
+{
+  MESSAGE( "SetRefinThr : TypeThR = " << TypeThR << ", ThreshR = " << ThreshR );
+  VERIFICATION( (TypeThR>=0) && (TypeThR<=4) );
+  _TypeThR = TypeThR;
+  _ThreshR = ThreshR;
 }
 //=============================================================================
 int HOMARD_Hypothesis::GetRefinThrType() const
@@ -268,101 +274,91 @@ double HOMARD_Hypothesis::GetThreshR() const
   return _ThreshR;
 }
 //=============================================================================
+void HOMARD_Hypothesis::SetUnRefThr( int TypeThC, double ThreshC )
+{
+  VERIFICATION( (TypeThC>=0) && (TypeThC<=4) );
+  _TypeThC = TypeThC;
+  _ThreshC = ThreshC;
+}
+//=============================================================================
 int HOMARD_Hypothesis::GetUnRefThrType() const
 {
   return _TypeThC;
 }
-
 //=============================================================================
 double HOMARD_Hypothesis::GetThreshC() const
 {
   return _ThreshC;
 }
 //=============================================================================
-int HOMARD_Hypothesis::GetUseField() const
-{
-  return _UsField;
-}
+void HOMARD_Hypothesis::SetNivMax( int NivMax )
 //=============================================================================
-int HOMARD_Hypothesis::GetUseCompI() const
 {
-  return _UsCmpI;
+  _NivMax = NivMax;
 }
 //=============================================================================
-/*!
-*/
+const int HOMARD_Hypothesis::GetNivMax() const
 //=============================================================================
-void HOMARD_Hypothesis::AddIteration( const char* NomIteration )
 {
-  _ListIter.push_back( std::string( NomIteration ) );
+  return _NivMax;
 }
 //=============================================================================
-void HOMARD_Hypothesis::SupprIterations()
-{
-  _ListIter.clear();
-}
+void HOMARD_Hypothesis::SetDiamMin( double DiamMin )
 //=============================================================================
-const std::list<std::string>& HOMARD_Hypothesis::GetIterations() const
 {
-  return _ListIter;
+  _DiamMin = DiamMin;
 }
 //=============================================================================
-/*!
-*/
+const double HOMARD_Hypothesis::GetDiamMin() const
 //=============================================================================
-void HOMARD_Hypothesis::AddZone( const char* NomZone, int TypeUse )
 {
-  _ListZone.push_back( std::string( NomZone ) );
-  std::stringstream saux1 ;
-  saux1 << TypeUse ;
-  std::string saux2 = saux1.str() ;
-  _ListZone.push_back( saux2 );
+  return _DiamMin;
 }
 //=============================================================================
-void HOMARD_Hypothesis::SupprZone( const char* NomZone )
+void HOMARD_Hypothesis::SetAdapInit( int AdapInit )
+//=============================================================================
 {
-  std::list<std::string>::iterator it = find( _ListZone.begin(), _ListZone.end(), NomZone );
-  if ( it != _ListZone.end() )
-  {
-    _ListZone.erase( it );
-  }
+  _AdapInit = AdapInit;
 }
 //=============================================================================
-void HOMARD_Hypothesis::SupprZones()
+const int HOMARD_Hypothesis::GetAdapInit() const
+//=============================================================================
 {
-  _ListZone.clear();
+  return _AdapInit;
 }
 //=============================================================================
-const std::list<std::string>& HOMARD_Hypothesis::GetZones() const
+void HOMARD_Hypothesis::SetExtraOutput( int ExtraOutput )
+//=============================================================================
 {
-  return _ListZone;
+  _ExtraOutput = ExtraOutput;
 }
 //=============================================================================
-/*!
-*/
+const int HOMARD_Hypothesis::GetExtraOutput() const
 //=============================================================================
-void HOMARD_Hypothesis::AddComp( const char* NomComposant )
 {
-  _ListComposant.push_back( std::string( NomComposant ) );
+  return _ExtraOutput;
 }
 //=============================================================================
-void HOMARD_Hypothesis::SupprComp()
+void HOMARD_Hypothesis::AddGroup( const char* Group)
 {
-  std::cerr << "HOMARD_Hypothesis::SupprComp" << std::endl;
-  _ListComposant.clear();
+// On commence par supprimer le groupe au cas ou il aurait deja ete insere
+// Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la
+// definition de l'hypothese
+  SupprGroup( Group ) ;
+// Insertion veritable
+  _ListGroupSelected.push_back(Group);
 }
 //=============================================================================
-const std::list<std::string>& HOMARD_Hypothesis::GetListComp() const
+void HOMARD_Hypothesis::SupprGroup( const char* Group )
 {
-  return _ListComposant;
+  MESSAGE ("SupprGroup pour "<<Group) ;
+  std::list<std::string>::iterator it = find( _ListGroupSelected.begin(), _ListGroupSelected.end(), Group );
+  if ( it != _ListGroupSelected.end() ) { it = _ListGroupSelected.erase( it ); }
 }
 //=============================================================================
-/*!
-*/
-//=============================================================================
-const std::list<std::string>& HOMARD_Hypothesis::GetGroups() const
+void HOMARD_Hypothesis::SupprGroups()
 {
-  return _ListGroupSelected;
+  _ListGroupSelected.clear();
 }
 //=============================================================================
 void HOMARD_Hypothesis::SetGroups( const std::list<std::string>& ListGroup )
@@ -373,91 +369,156 @@ void HOMARD_Hypothesis::SetGroups( const std::list<std::string>& ListGroup )
     _ListGroupSelected.push_back((*it++));
 }
 //=============================================================================
-void HOMARD_Hypothesis::AddGroup( const char* Group)
+const std::list<std::string>& HOMARD_Hypothesis::GetGroups() const
 {
-  _ListGroupSelected.push_back(Group);
+  return _ListGroupSelected;
 }
 //=============================================================================
-/*!
-*/
-//=============================================================================
+// Type d'interpolation des champs :
+//   0 : aucun champ n'est interpole
+//   1 : tous les champs sont interpoles
+//   2 : certains champs sont interpoles
 void HOMARD_Hypothesis::SetTypeFieldInterp( int TypeFieldInterp )
 {
-  ASSERT (!((TypeFieldInterp < -1) or (TypeFieldInterp > 2)));
+  VERIFICATION( (TypeFieldInterp>=0) && (TypeFieldInterp<=2) );
   _TypeFieldInterp = TypeFieldInterp;
 }
-
-//=============================================================================
-/*!
-*/
 //=============================================================================
 int HOMARD_Hypothesis::GetTypeFieldInterp() const
 {
   return _TypeFieldInterp;
 }
-/*!
-*/
 //=============================================================================
-void HOMARD_Hypothesis::AddFieldInterp( const char* FieldInterp )
+void HOMARD_Hypothesis::AddFieldInterpType( const char* FieldInterp, int TypeInterp )
 {
+  MESSAGE ("Dans AddFieldInterpType pour " << FieldInterp << " et TypeInterp = " << TypeInterp) ;
+// On commence par supprimer le champ au cas ou il aurait deja ete insere
+// Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la
+// definition de l'hypothese
+  SupprFieldInterp( FieldInterp ) ;
+// Insertion veritable
+// . Nom du champ
   _ListFieldInterp.push_back( std::string( FieldInterp ) );
+// . Usage du champ
+  std::stringstream saux1 ;
+  saux1 << TypeInterp ;
+  _ListFieldInterp.push_back( saux1.str() );
+// . Indication generale : certains champs sont a interpoler
+  SetTypeFieldInterp ( 2 ) ;
 }
 //=============================================================================
-void HOMARD_Hypothesis::SupprFieldInterp()
+void HOMARD_Hypothesis::SupprFieldInterp( const char* FieldInterp )
 {
-  std::cerr << "HOMARD_Hypothesis::SupprFieldInterpp" << std::endl;
+  MESSAGE ("Dans SupprFieldInterp pour " << FieldInterp) ;
+  std::list<std::string>::iterator it = find( _ListFieldInterp.begin(), _ListFieldInterp.end(), FieldInterp ) ;
+// Attention a supprimer le nom du champ et le type d'usage
+  if ( it != _ListFieldInterp.end() )
+  {
+    it = _ListFieldInterp.erase( it ) ;
+    it = _ListFieldInterp.erase( it ) ;
+  }
+// Decompte du nombre de champs restant a interpoler
+  it = _ListFieldInterp.begin() ;
+  int cpt = 0 ;
+  while(it != _ListFieldInterp.end())
+  {
+    cpt += 1 ;
+    (*it++);
+  }
+  MESSAGE("Nombre de champ restants = "<<cpt/2);
+// . Indication generale : aucun champ ne reste a interpoler
+  if ( cpt == 0 )
+  {
+    SetTypeFieldInterp ( 0 ) ;
+  }
+}
+//=============================================================================
+void HOMARD_Hypothesis::SupprFieldInterps()
+{
+  MESSAGE ("SupprFieldInterps") ;
   _ListFieldInterp.clear();
+// . Indication generale : aucun champ ne reste a interpoler
+  SetTypeFieldInterp ( 0 ) ;
 }
 //=============================================================================
-const std::list<std::string>& HOMARD_Hypothesis::GetListFieldInterp() const
+const std::list<std::string>& HOMARD_Hypothesis::GetFieldInterps() const
 {
   return _ListFieldInterp;
 }
 //=============================================================================
-void HOMARD_Hypothesis::SetNivMax( int NivMax )
 //=============================================================================
-{
-  _NivMax = NivMax;
-}
+// Liens avec les autres structures
 //=============================================================================
-const int HOMARD_Hypothesis::GetNivMax() const
 //=============================================================================
+void HOMARD_Hypothesis::SetCaseCreation( const char* NomCasCreation )
 {
-  return _NivMax;
+  _NomCasCreation = std::string( NomCasCreation );
 }
 //=============================================================================
-void HOMARD_Hypothesis::SetAdapInit( int AdapInit )
-//=============================================================================
+std::string HOMARD_Hypothesis::GetCaseCreation() const
 {
-  _AdapInit = AdapInit;
+  return _NomCasCreation;
 }
 //=============================================================================
-const int HOMARD_Hypothesis::GetAdapInit() const
-//=============================================================================
+void HOMARD_Hypothesis::LinkIteration( const char* NomIteration )
 {
-  return _AdapInit;
+  _ListIter.push_back( std::string( NomIteration ) );
 }
 //=============================================================================
-void HOMARD_Hypothesis::SetDiamMin( double DiamMin )
-//=============================================================================
+void HOMARD_Hypothesis::UnLinkIteration( const char* NomIteration )
 {
-  _DiamMin = DiamMin;
+  std::list<std::string>::iterator it = find( _ListIter.begin(), _ListIter.end(), NomIteration ) ;
+  if ( it != _ListIter.end() )
+  {
+    MESSAGE ("Dans UnLinkIteration pour " << NomIteration) ;
+    it = _ListIter.erase( it ) ;
+  }
 }
 //=============================================================================
-const double HOMARD_Hypothesis::GetDiamMin() const
+void HOMARD_Hypothesis::UnLinkIterations()
+{
+  _ListIter.clear();
+}
 //=============================================================================
+const std::list<std::string>& HOMARD_Hypothesis::GetIterations() const
 {
-  return _DiamMin;
+  return _ListIter;
 }
 //=============================================================================
-void HOMARD_Hypothesis::SetLevelOutput( int LevelOutput )
+void HOMARD_Hypothesis::AddZone( const char* NomZone, int TypeUse )
+{
+  MESSAGE ("Dans AddZone pour " << NomZone << " et TypeUse = " << TypeUse) ;
+// On commence par supprimer la zone au cas ou elle aurait deja ete inseree
+// Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la
+// definition de l'hypothese
+  SupprZone( NomZone ) ;
+// Insertion veritable
+// . Nom de la zone
+  _ListZone.push_back( std::string( NomZone ) );
+// . Usage de la zone
+  std::stringstream saux1 ;
+  saux1 << TypeUse ;
+  _ListZone.push_back( saux1.str() );
+}
 //=============================================================================
+void HOMARD_Hypothesis::SupprZone( const char* NomZone )
 {
-  _LevelOutput = LevelOutput;
+  MESSAGE ("Dans SupprZone pour " << NomZone) ;
+  std::list<std::string>::iterator it = find( _ListZone.begin(), _ListZone.end(), NomZone );
+// Attention a supprimer le nom de zone et le type d'usage
+  if ( it != _ListZone.end() )
+  {
+    it = _ListZone.erase( it );
+    it = _ListZone.erase( it );
+  }
 }
 //=============================================================================
-const int HOMARD_Hypothesis::GetLevelOutput() const
+void HOMARD_Hypothesis::SupprZones()
+{
+  _ListZone.clear();
+}
 //=============================================================================
+const std::list<std::string>& HOMARD_Hypothesis::GetZones() const
 {
-  return _LevelOutput;
+  return _ListZone;
 }