X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHOMARD_I%2FHOMARD_Cas_i.cxx;h=036dacef1a82ac0b12c274d36ff71c08e937f83c;hb=93b74e737a747c3a8921de65af6f4b9894267313;hp=105a487af2b2d79ab357b8898334d60ae5461b94;hpb=4aef4b766c3248f82b3a3ad1a19225b4826db280;p=modules%2Fhomard.git diff --git a/src/HOMARD_I/HOMARD_Cas_i.cxx b/src/HOMARD_I/HOMARD_Cas_i.cxx old mode 100755 new mode 100644 index 105a487a..036dacef --- a/src/HOMARD_I/HOMARD_Cas_i.cxx +++ b/src/HOMARD_I/HOMARD_Cas_i.cxx @@ -1,9 +1,9 @@ -// Copyright (C) 2011-2013 CEA/DEN, EDF R&D +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D // // 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 @@ -16,6 +16,7 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // 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 : @@ -236,6 +237,7 @@ CORBA::Long HOMARD_Cas_i::GetNumberofIter() void HOMARD_Cas_i::SetConfType( CORBA::Long ConfType ) { ASSERT( myHomardCas ); +// VERIFICATION( (ConfType>=-2) && (ConfType<=3) ); myHomardCas->SetConfType( ConfType ); } //============================================================================= @@ -245,6 +247,19 @@ CORBA::Long HOMARD_Cas_i::GetConfType() return myHomardCas->GetConfType(); } //============================================================================= +void HOMARD_Cas_i::SetExtType( CORBA::Long ExtType ) +{ + ASSERT( myHomardCas ); +// VERIFICATION( (ExtType>=0) && (ExtType<=2) ); + myHomardCas->SetExtType( ExtType ); +} +//============================================================================= +CORBA::Long HOMARD_Cas_i::GetExtType() +{ + ASSERT( myHomardCas ); + return myHomardCas->GetExtType(); +} +//============================================================================= void HOMARD_Cas_i::SetBoundingBox( const HOMARD::extrema& LesExtrema ) { ASSERT( myHomardCas ); @@ -304,46 +319,140 @@ HOMARD::ListGroupType* HOMARD_Cas_i::GetGroups() return aResult._retn(); } //============================================================================= +void HOMARD_Cas_i::AddBoundary(const char* BoundaryName) +{ + MESSAGE ("HOMARD_Cas_i::AddBoundary : BoundaryName = "<< BoundaryName ); + const char * Group = "" ; + AddBoundaryGroup( BoundaryName, Group) ; +} +//============================================================================= void HOMARD_Cas_i::AddBoundaryGroup( const char* BoundaryName, const char* Group) { - MESSAGE ("AddBoundaryGroup : BoundaryName = "<< BoundaryName << ", Group = " << Group ); + MESSAGE ("HOMARD_Cas_i::AddBoundaryGroup : BoundaryName = "<< BoundaryName << ", Group = " << Group ); ASSERT( myHomardCas ); - // A. La liste des frontiere+groupes + // A. Préalables + // A.1. Caractéristiques de la frontière à ajouter + HOMARD::HOMARD_Boundary_ptr myBoundary = _gen_i->GetBoundary(BoundaryName) ; + ASSERT(!CORBA::is_nil(myBoundary)); + int BoundaryType = myBoundary->GetType(); + MESSAGE ( ". BoundaryType = " << BoundaryType ); + // A.2. La liste des frontiere+groupes const std::list& ListBoundaryGroup = myHomardCas->GetBoundaryGroup(); std::list::const_iterator it; - // B. La frontiere - // B.1. La frontiere est-elle deja enregistree pour ce cas ? - bool existe = false ; - for ( it = ListBoundaryGroup.begin(); it != ListBoundaryGroup.end(); it++ ) + // B. Controles + const char * boun ; + int erreur = 0 ; + while ( erreur == 0 ) { -// MESSAGE (".. Frontiere : "<< *it ); - if ( *it == BoundaryName ) { existe = true ; } - it++ ; - } - // B.2. Pour une nouvelle frontiere, publication dans l'arbre d'etudes sous le cas - if ( !existe ) - { - char* CaseName = GetName() ; - MESSAGE ( "AddBoundaryGroup : insertion de la frontiere dans l'arbre de " << CaseName ); - _gen_i->PublishBoundaryUnderCase(CaseName, BoundaryName) ; + // B.1. Si on ajoute une frontière CAO, elle doit être la seule frontière + if ( BoundaryType == -1 ) + { + for ( it = ListBoundaryGroup.begin(); it != ListBoundaryGroup.end(); it++ ) + { + boun = (*it).c_str() ; + MESSAGE (".. Frontiere enregistrée : "<< boun ); + if ( *it != BoundaryName ) + { erreur = 1 ; + break ; } + // On saute le nom du groupe + it++ ; + } + } + if ( erreur != 0 ) { break ; } + // B.2. Si on ajoute une frontière non CAO, il ne doit pas y avoir de frontière CAO + if ( BoundaryType != -1 ) + { + for ( it = ListBoundaryGroup.begin(); it != ListBoundaryGroup.end(); it++ ) + { + boun = (*it).c_str() ; + MESSAGE (".. Frontiere enregistrée : "<< boun ); + HOMARD::HOMARD_Boundary_ptr myBoundary_0 = _gen_i->GetBoundary(boun) ; + int BoundaryType_0 = myBoundary_0->GetType(); + MESSAGE ( ".. BoundaryType_0 = " << BoundaryType_0 ); + if ( BoundaryType_0 == -1 ) + { erreur = 2 ; + break ; } + // On saute le nom du groupe + it++ ; + } + if ( erreur != 0 ) { break ; } + } + // B.3. Si on ajoute une frontière discrète, il ne doit pas y avoir d'autre frontière discrète + if ( BoundaryType == 0 ) + { + for ( it = ListBoundaryGroup.begin(); it != ListBoundaryGroup.end(); it++ ) + { + boun = (*it).c_str() ; + MESSAGE (".. Frontiere enregistrée : "<< boun ); + if ( boun != BoundaryName ) + { + HOMARD::HOMARD_Boundary_ptr myBoundary_0 = _gen_i->GetBoundary(boun) ; + int BoundaryType_0 = myBoundary_0->GetType(); + MESSAGE ( ".. BoundaryType_0 = " << BoundaryType_0 ); + if ( BoundaryType_0 == 0 ) + { erreur = 3 ; + break ; } + } + // On saute le nom du groupe + it++ ; + } + if ( erreur != 0 ) { break ; } + } + // B.4. Pour une nouvelle frontiere, publication dans l'arbre d'etudes sous le cas + bool existe = false ; + for ( it = ListBoundaryGroup.begin(); it != ListBoundaryGroup.end(); it++ ) + { + MESSAGE (".. Frontiere : "<< *it ); + if ( *it == BoundaryName ) { existe = true ; } + // On saute le nom du groupe + it++ ; + } + if ( !existe ) + { + char* CaseName = GetName() ; + MESSAGE ( "AddBoundaryGroup : insertion de la frontiere dans l'arbre de " << CaseName ); + _gen_i->PublishBoundaryUnderCase(CaseName, BoundaryName) ; + } + // B.5. Le groupe est-il deja enregistre pour une frontiere de ce cas ? + for ( it = ListBoundaryGroup.begin(); it != ListBoundaryGroup.end(); it++ ) + { + boun = (*it).c_str() ; + it++ ; + MESSAGE (".. Groupe enregistré : "<< *it ); + if ( *it == Group ) + { erreur = 5 ; + break ; } + } + if ( erreur != 0 ) { break ; } + // + break ; } - // C. Le groupe est-il deja enregistre pour une frontiere de ce cas ? - for ( it = ListBoundaryGroup.begin(); it != ListBoundaryGroup.end(); it++ ) + // F. Si aucune erreur, enregistrement du couple (frontiere,groupe) dans la reference du cas + // Sinon, arrêt + if ( erreur == 0 ) + { myHomardCas->AddBoundaryGroup( BoundaryName, Group ); } + else { - std::string boun = *it ; - it++ ; -// MESSAGE (".. Group : "<< *it ); - if ( *it == Group ) - { INFOS ("Frontiere " << boun << " Un groupe est deja associe " << Group ) ; - SALOME::ExceptionStruct es; - es.type = SALOME::BAD_PARAM; - es.text = "Invalid AddBoundaryGroup"; - throw SALOME::SALOME_Exception(es); - return ; - } + std::stringstream ss; + ss << erreur; + std::string str = ss.str(); + std::string texte ; + texte = "Erreur numéro " + str + " pour la frontière à enregistrer : " + std::string(BoundaryName) ; + if ( erreur == 1 ) { texte += "\nIl existe déjà la frontière " ; } + else if ( erreur == 2 ) { texte += "\nIl existe déjà la frontière CAO " ; } + else if ( erreur == 3 ) { texte += "\nIl existe déjà une frontière discrète : " ; } + else if ( erreur == 5 ) { texte += "\nLe groupe " + std::string(Group) + " est déjà enregistré pour la frontière " ; } + texte += std::string(boun) ; + // + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; +#ifdef _DEBUG_ + texte += "\nInvalid AddBoundaryGroup"; +#endif + INFOS(texte) ; + es.text = CORBA::string_dup(texte.c_str()); + throw SALOME::SALOME_Exception(es); } - // D. Enregistrement du couple (frontiere,groupe) dans la reference du cas - myHomardCas->AddBoundaryGroup( BoundaryName, Group ); } //============================================================================= HOMARD::ListBoundaryGroupType* HOMARD_Cas_i::GetBoundaryGroup() @@ -474,7 +583,7 @@ void HOMARD_Cas_i::AddIteration( const char* NomIteration ) // Creation d'un schema YACS // YACSName : nom du schema // ScriptFile : nom du fichier contenant le script de lancement du calcul -// DirName : le repertoire de lancement des calculs du schéma +// DirName : le repertoire de lancement des calculs du sch?ma // MeshFile : nom du fichier contenant le maillage pour le premier calcul //============================================================================= HOMARD::HOMARD_YACS_ptr HOMARD_Cas_i::CreateYACSSchema( const char* YACSName, const char* ScriptFile, const char* DirName, const char* MeshFile )