-// Copyright (C) 2011-2012 CEA/DEN, EDF R&D
+// Copyright (C) 2011-2013 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
#include "utilities.h"
#include <vector>
+#include <sys/stat.h>
//=============================================================================
/*!
return CORBA::string_dup( myHomardCas->GetName().c_str() );
}
//=============================================================================
-CORBA::Long HOMARD_Cas_i::Delete()
+CORBA::Long HOMARD_Cas_i::Delete( CORBA::Long Option )
{
ASSERT( myHomardCas );
char* CaseName = GetName() ;
- MESSAGE ( "Delete : destruction du cas " << CaseName );
- return _gen_i->DeleteCase(CaseName) ;
+ MESSAGE ( "Delete : destruction du cas " << CaseName << ", Option = " << Option );
+ return _gen_i->DeleteCase(CaseName, Option) ;
}
//=============================================================================
char* HOMARD_Cas_i::GetDumpPython()
void HOMARD_Cas_i::SetDirName( const char* NomDir )
{
ASSERT( myHomardCas );
- myHomardCas->SetDirName( NomDir );
+ int codret ;
+ // A. recuperation du nom ; on ne fait rien si c'est le meme
+ char* oldrep = GetDirName() ;
+ MESSAGE ( "SetDirName : passage de oldrep = "<< oldrep << " a NomDir = "<<NomDir);
+ if ( oldrep == NomDir ) { return ; }
+ // B. Changement/creation du repertoire
+ codret = myHomardCas->SetDirName( NomDir );
+ if ( codret != 0 )
+ {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::BAD_PARAM;
+ std::string text ;
+ if ( codret == 1 ) { text = "The directory for the case cannot be modified because some iterations are already defined." ; }
+ else { text = "The directory for the case cannot be reached." ; }
+ es.text = CORBA::string_dup(text.c_str());
+ throw SALOME::SALOME_Exception(es);
+ }
+ // C. 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
+ 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
+ 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
+ std::string nomDirIterTotal ;
+ nomDirIterTotal = std::string(NomDir) + "/" + std::string(nomDirIter) ;
+ if (mkdir(nomDirIterTotal.c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0)
+ {
+ MESSAGE ( "nomDirIterTotal : " << nomDirIterTotal ) ;
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::BAD_PARAM;
+ std::string text = "The directory for the starting iteration cannot be created." ;
+ es.text = CORBA::string_dup(text.c_str());
+ throw SALOME::SALOME_Exception(es);
+ }
+ // C.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) ;
+ codret = system(commande.c_str()) ;
+ if ( codret != 0 )
+ {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::BAD_PARAM;
+ std::string text = "The starting point for the case cannot be moved into the new directory." ;
+ es.text = CORBA::string_dup(text.c_str());
+ throw SALOME::SALOME_Exception(es);
+ }
+ commande = "rm -rf " + std::string(oldnomDirIterTotal) ;
+ codret = system(commande.c_str()) ;
+ if ( codret != 0 )
+ {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::BAD_PARAM;
+ std::string text = "The starting point for the case cannot be deleted." ;
+ es.text = CORBA::string_dup(text.c_str());
+ throw SALOME::SALOME_Exception(es);
+ }
+ // C.5. Memorisation du nom du repertoire de l'iteration
+ Iter->SetDirNameLoc(nomDirIter) ;
+ }
+ return ;
}
//=============================================================================
char* HOMARD_Cas_i::GetDirName()
return CORBA::string_dup( myHomardCas->GetDirName().c_str() );
}
//=============================================================================
-CORBA::Long HOMARD_Cas_i::GetNumber()
+CORBA::Long HOMARD_Cas_i::GetState()
{
ASSERT( myHomardCas );
- return myHomardCas->GetNumber();
+// Nom de l'iteration initiale
+ char* Iter0Name = GetIter0Name() ;
+ HOMARD::HOMARD_Iteration_ptr Iter = _gen_i->GetIteration(Iter0Name) ;
+ int state = Iter->GetNumber() ;
+ return state ;
+}
+//=============================================================================
+CORBA::Long HOMARD_Cas_i::GetNumberofIter()
+{
+ ASSERT( myHomardCas );
+ return myHomardCas->GetNumberofIter();
}
//=============================================================================
void HOMARD_Cas_i::SetConfType( CORBA::Long ConfType )
{
VExtrema[i] = LesExtrema[i];
}
-
myHomardCas->SetBoundingBox( VExtrema );
}
//=============================================================================
{
ListString.push_back(std::string(ListGroup[i]));
}
-
myHomardCas->SetGroups( ListString );
}
//=============================================================================
return myHomardCas->GetPyram();
}
//=============================================================================
+void HOMARD_Cas_i::MeshInfo(CORBA::Long Qual, CORBA::Long Diam, CORBA::Long Conn, CORBA::Long Tail, CORBA::Long Inte)
+{
+ MESSAGE ( "MeshInfo : information sur le maillage initial du cas" );
+ ASSERT( myHomardCas );
+//
+// Nom de l'iteration
+ char* IterName = GetIter0Name() ;
+ CORBA::Long etatMenage = -1 ;
+ CORBA::Long modeHOMARD = 7 ;
+ CORBA::Long Option1 = 1 ;
+ CORBA::Long Option2 = 1 ;
+ if ( Qual != 0 ) { modeHOMARD = modeHOMARD*5 ; }
+ if ( Diam != 0 ) { modeHOMARD = modeHOMARD*19 ; }
+ if ( Conn != 0 ) { modeHOMARD = modeHOMARD*11 ; }
+ if ( Tail != 0 ) { modeHOMARD = modeHOMARD*13 ; }
+ if ( Inte != 0 ) { modeHOMARD = modeHOMARD*3 ; }
+ CORBA::Long codret = _gen_i->Compute(IterName, etatMenage, modeHOMARD, Option1, Option2) ;
+ MESSAGE ( "MeshInfo : codret = " << codret );
+ return ;
+}
+//=============================================================================
//=============================================================================
// Liens avec les autres structures
//=============================================================================
//=============================================================================
HOMARD::HOMARD_Iteration_ptr HOMARD_Cas_i::GetIter0()
{
-// Nom de l'iteration parent
+// Nom de l'iteration initiale
char* Iter0Name = GetIter0Name() ;
MESSAGE ( "GetIter0 : Iter0Name = " << Iter0Name );
return _gen_i->GetIteration(Iter0Name) ;
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) ;
+}