-// Copyright (C) 2011-2013 CEA/DEN, EDF R&D
+// Copyright (C) 2011-2022 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
//
// 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 :
#include "HOMARD_Gen_i.hxx"
#include "HOMARD_Cas.hxx"
#include "HOMARD_DriverTools.hxx"
+#include "HOMARD.hxx"
#include "utilities.h"
#include <vector>
#include <sys/stat.h>
+#ifdef WIN32
+#include <direct.h>
+#endif
+
//=============================================================================
/*!
* standard constructor
int codret ;
// A. recuperation du nom ; on ne fait rien si c'est le meme
char* oldrep = GetDirName() ;
+ if ( strcmp(oldrep,NomDir) == 0 )
+ {
+ return ;
+ }
MESSAGE ( "SetDirName : passage de oldrep = "<< oldrep << " a NomDir = "<<NomDir);
- if ( oldrep == NomDir ) { return ; }
- // B. Changement/creation du repertoire
+ // B. controle de l'usage du repertoire
+ char* CaseName = GetName() ;
+ char* casenamedir = _gen_i->VerifieDir(NomDir) ;
+ if ( ( std::string(casenamedir).size() > 0 ) & ( strcmp(CaseName,casenamedir)!=0 ) )
+ {
+ INFOS ( "Le repertoire " << NomDir << " est deja utilise pour le cas "<< casenamedir );
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::BAD_PARAM;
+ std::string text ;
+ text = "The directory " + std::string(NomDir) + " is already used for the case " + std::string(casenamedir) ;
+ es.text = CORBA::string_dup(text.c_str());
+ throw SALOME::SALOME_Exception(es);
+ }
+ // C. Changement/creation du repertoire
codret = myHomardCas->SetDirName( NomDir );
if ( codret != 0 )
{
es.text = CORBA::string_dup(text.c_str());
throw SALOME::SALOME_Exception(es);
}
- // C. En cas de reprise, deplacement du point de depart
+ // D. En cas de reprise, deplacement du point de depart
if ( GetState() != 0 )
{
MESSAGE ( "etat : " << GetState() ) ;
- // C.1. Nom local du repertoire de l'iteration de depart dans le repertoire actuel du cas
+ // D.1. Nom local du repertoire de l'iteration de depart dans le repertoire actuel du cas
HOMARD::HOMARD_Iteration_ptr Iter = GetIter0() ;
char* DirNameIter = Iter->GetDirNameLoc() ;
MESSAGE ( "SetDirName : nom actuel pour le repertoire de l iteration, DirNameIter = "<< DirNameIter);
- // C.2. Recherche d'un nom local pour l'iteration de depart dans le futur repertoire du cas
+ // D.2. Recherche d'un nom local pour l'iteration de depart dans le futur repertoire du cas
char* nomDirIter = _gen_i->CreateDirNameIter(NomDir, 0 );
MESSAGE ( "SetDirName : nom futur pour le repertoire de l iteration, nomDirIter = "<< nomDirIter);
- // C.3. Creation du futur repertoire local pour l'iteration de depart
+ // D.3. Creation du futur repertoire local pour l'iteration de depart
std::string nomDirIterTotal ;
nomDirIterTotal = std::string(NomDir) + "/" + std::string(nomDirIter) ;
+#ifndef WIN32
if (mkdir(nomDirIterTotal.c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0)
+#else
+ if (_mkdir(nomDirIterTotal.c_str()) != 0)
+#endif
{
MESSAGE ( "nomDirIterTotal : " << nomDirIterTotal ) ;
SALOME::ExceptionStruct es;
es.text = CORBA::string_dup(text.c_str());
throw SALOME::SALOME_Exception(es);
}
- // C.4. Deplacement du contenu du repertoire
+ // D.4. Deplacement du contenu du repertoire
std::string oldnomDirIterTotal ;
oldnomDirIterTotal = std::string(oldrep) + "/" + std::string(DirNameIter) ;
std::string commande = "mv " + std::string(oldnomDirIterTotal) + "/*" + " " + std::string(nomDirIterTotal) ;
es.text = CORBA::string_dup(text.c_str());
throw SALOME::SALOME_Exception(es);
}
- // C.5. Memorisation du nom du repertoire de l'iteration
+ // D.5. Memorisation du nom du repertoire de l'iteration
Iter->SetDirNameLoc(nomDirIter) ;
}
return ;
void HOMARD_Cas_i::SetConfType( CORBA::Long ConfType )
{
ASSERT( myHomardCas );
+// VERIFICATION( (ConfType>=-2) && (ConfType<=3) );
myHomardCas->SetConfType( ConfType );
}
//=============================================================================
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 );
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 );
- // La frontiere est-elle deja enregistree pour ce cas ?
+ // 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<std::string>& ListBoundaryGroup = myHomardCas->GetBoundaryGroup();
std::list<std::string>::const_iterator it;
- int existe = 0;
- for ( it = ListBoundaryGroup.begin(); it != ListBoundaryGroup.end(); it++ )
+ // B. Controles
+ const char * boun ;
+ int erreur = 0 ;
+ while ( erreur == 0 )
{
- if ( *it == BoundaryName )
- { existe = 1 ; }
- it++ ;
+ // 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 ;
}
- // Enregistrement de la frontiere dans la reference du cas
- myHomardCas->AddBoundaryGroup( BoundaryName, Group );
- // Pour une nouvelle frontiere, publication dans l'arbre d'etudes sous le cas
- if ( existe == 0 )
+ // 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
{
- char* CaseName = GetName() ;
- MESSAGE ( "AddBoundaryGroup : insertion de la frontiere dans l'arbre de " << CaseName );
- _gen_i->PublishBoundaryUnderCase(CaseName, BoundaryName) ;
+ 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);
}
}
//=============================================================================
return aResult._retn();
}
//=============================================================================
+void HOMARD_Cas_i::SupprBoundaryGroup()
+{
+ MESSAGE ("SupprBoundaryGroup");
+ ASSERT(myHomardCas );
+ myHomardCas->SupprBoundaryGroup();
+}
+//=============================================================================
void HOMARD_Cas_i::SetPyram( CORBA::Long Pyram )
{
MESSAGE ("SetPyram, Pyram = " << Pyram );
nbiterfilles = ListeIterFilles->length() ;
// MESSAGE ( ".. nbiterfilles = " << nbiterfilles );
// S'il y a au moins 2 filles, arret : on ne sait pas faire
- ASSERT( nbiterfilles <= 1 ) ;
+ VERIFICATION( nbiterfilles <= 1 ) ;
// S'il y a une fille unique, on recupere le nom de la fille et on recommence
if ( nbiterfilles == 1 )
{ IterName = ListeIterFilles[0] ; }
ASSERT( myHomardCas );
myHomardCas->AddIteration( NomIteration );
}
+//=============================================================================
+//=============================================================================
+// YACS
+//=============================================================================
+//=============================================================================
+//=============================================================================
+// 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
+// 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 )
+{
+// Nom du cas
+ const char* CaseName = GetName() ;
+ MESSAGE ( "CreateYACSSchema : Schema YACS pour le cas " << YACSName);
+ MESSAGE ( "nomCas : " << CaseName);
+ MESSAGE ( "ScriptFile : " << ScriptFile);
+ MESSAGE ( "DirName : " << DirName);
+ MESSAGE ( "MeshFile : " << MeshFile);
+ return _gen_i->CreateYACSSchema(YACSName, CaseName, ScriptFile, DirName, MeshFile) ;
+}