X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHOMARD%2FYACSDriver.cxx;h=3a559bcdc9fec98f80d96436b9755c7350367add;hb=refs%2Ftags%2FV9_13_0b1;hp=01b1f453ae7d6ae3b86b371be54c893c633fad77;hpb=c9cf46fbd6a8d5091139e6b484c5482ee797e346;p=modules%2Fhomard.git diff --git a/src/HOMARD/YACSDriver.cxx b/src/HOMARD/YACSDriver.cxx index 01b1f453..3a559bcd 100644 --- a/src/HOMARD/YACSDriver.cxx +++ b/src/HOMARD/YACSDriver.cxx @@ -1,11 +1,11 @@ // HOMARD HOMARD : implementation of HOMARD idl descriptions // -// Copyright (C) 2011-2013 CEA/DEN, EDF R&D +// Copyright (C) 2011-2024 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 @@ -22,25 +22,30 @@ // Pilote l'ecriture du fichier xml pour lancer un schema YACS #include +#ifndef WIN32 #include +#endif #include +#include "YACSDriver.hxx" +#include "HOMARD.hxx" #include "Utils_SALOME_Exception.hxx" #include "utilities.h" -#include "YACSDriver.hxx" //============================================================================= //============================================================================= -YACSDriver::YACSDriver(const std::string XMLFile, const std::string DirName): +YACSDriver::YACSDriver(const std::string XMLFile, const std::string DirName, const std::string LangueShort): _XMLFile( "" ), _DirName( "" ), _Texte( "" ), _Texte_parametres( "" ), - _noeud_1( "CreateHypothesis" ), + _noeud_1( "CreateCase" ), + _LangueShort( "" ), _bLu( false ) { MESSAGE("XMLFile = "<\n" ; - _Texte += " Etude_Initialisation.SetCurrentStudy\n" ; + INFOS("_LangueShort = "<<_LangueShort ); + if ( _LangueShort == "fr" ) { motcle = "Etude_Initialisation" ; } + else { motcle = "Study_Initialisation" ; } + INFOS("motcle = "<\n" ; _Texte += " " + methode + "\n" ; // 4. Les inports // 4.1. Le nom de la zone @@ -159,7 +173,7 @@ std::string YACSDriver::Texte_Iter_1_Zone( int ZoneType, const std::string pytho // La derniere valeur est toujours mise dans x8 x8 = GetStringInTexte ( ligne, ")", 0 ) ; MESSAGE("coor = "<< x0<<","< 10 ) and ( ZoneType < 14 ) ) +// 4.2.3. Cas du rectangle (11, 12, 13) + else if ( ( ZoneType > 10 ) && ( ZoneType < 14 ) ) { _Texte += Texte_inport( "double", "Umini" ) ; _Texte += Texte_inport( "double", "Umaxi" ) ; @@ -191,8 +205,8 @@ std::string YACSDriver::Texte_Iter_1_Zone( int ZoneType, const std::string pytho TexteParametre( node, "Orient", "int", x8 ) ; } // -// 4.2. Cas du disque (31, 32, 33) ou du disque perce (61, 62, 63) - else if ( ( ( ZoneType > 30 ) and ( ZoneType < 34 ) ) or ( ( ZoneType > 60 ) and ( ZoneType < 64 ) ) ) +// 4.2.4. Cas du disque (31, 32, 33) ou du disque perce (61, 62, 63) + else if ( ( ( ZoneType > 30 ) && ( ZoneType < 34 ) ) || ( ( ZoneType > 60 ) && ( ZoneType < 64 ) ) ) { _Texte += Texte_inport( "double", "Ucentre" ) ; _Texte += Texte_inport( "double", "Vcentre" ) ; @@ -209,7 +223,7 @@ std::string YACSDriver::Texte_Iter_1_Zone( int ZoneType, const std::string pytho TexteParametre( node, "Orient", "int", x8 ) ; } // -// 4.2. Cas de la sphere (4) +// 4.2.5. Cas de la sphere (4) else if ( ZoneType == 4 ) { _Texte += Texte_inport( "double", "Xcentre" ) ; @@ -222,8 +236,8 @@ std::string YACSDriver::Texte_Iter_1_Zone( int ZoneType, const std::string pytho TexteParametre( node, "Radius", "double", x8 ) ; } // -// 4.2. Cas du cylindre (5) ou du tuyau (7) - else if ( ZoneType == 5 or ZoneType == 7 ) +// 4.2.6. Cas du cylindre (5) ou du tuyau (7) + else if ( ZoneType == 5 || ZoneType == 7 ) { _Texte += Texte_inport( "double", "Xcentre" ) ; _Texte += Texte_inport( "double", "Ycentre" ) ; @@ -252,9 +266,9 @@ std::string YACSDriver::Texte_Iter_1_Zone( int ZoneType, const std::string pytho } } // -// 4.2. Erreur +// 4.2.7. Erreur else - { ASSERT("Type de zone inconnu." == 0); } + { VERIFICATION("Type de zone inconnu." == 0); } // // 5. La fin @@ -270,142 +284,174 @@ std::string YACSDriver::Texte_Iter_1_Zone( int ZoneType, const std::string pytho // pythonStructure : le python correspondant a la frontiere // methode : methode associee a la creation de la frontiere // BoundaryName : nom de la frontiere +// MeshName : nom du maillage dans le cas d'une frontiere discrete +// MeshFile : nom du fichier du maillage dans le cas d'une frontiere discrete //=============================================================================== -std::string YACSDriver::Texte_Iter_1_Boundary( int BoundaryType, const std::string pythonStructure, const std::string methode, const std::string BoundaryName ) +std::string YACSDriver::Texte_Iter_1_Boundary( int BoundaryType, const std::string pythonStructure, const std::string methode, const std::string BoundaryName, const std::string MeshName, const std::string MeshFile ) { MESSAGE("Texte_Iter_1_Boundary, BoundaryType = "<\n" ; - _Texte += " Etude_Initialisation.SetCurrentStudy\n" ; + if ( _LangueShort == "fr" ) { motcle = "Etude_Initialisation" ; } + else { motcle = "Study_Initialisation" ; } + _Texte += " " + motcle + ".UpdateStudy\n" ; _Texte += " " + methode + "\n" ; // 4. Les inports -// 4.1. Le nom de la zone +// ATTENTION : les noms doivent etre les memes que dans Gen.xml, donc HOMARD_Gen.idl +// 4.1. Le nom de la frontiere _Texte += Texte_inport( "string", "BoundaryName" ) ; TexteParametre( node, "BoundaryName", "string", BoundaryName ) ; -// 4.2. Les valeurs numeriques -// ATTENTION : les noms doivent etre les memes que dans Gen.xml, donc HOMARD_Gen.idl -// 4.2.1. Decodage des valeurs +// 4.2. Cas d une frontiere discrete + if (BoundaryType == 0) + { + _Texte += Texte_inport( "string", "MeshName" ) ; + TexteParametre( node, "MeshName", "string", MeshName ) ; + _Texte += Texte_inport( "string", "FileName" ) ; + TexteParametre( node, "FileName", "string", MeshFile ) ; + } +// 4.3. Cas d'une frontiere analytique : les valeurs numeriques + else + { +// 4.3.1. Decodage des valeurs // La chaine pythonStructure est de ce genre : // CreateBoundaryCylinder('cyl_2', 17.5, -2.5, -12.5, -100., -75., -25., 50.) // CreateBoundaryDi("intersection", "PIQUAGE", "/scratch/D68518/Salome/script/sfr_2d_piquage.fr.med") - std::string ligne = pythonStructure ; + std::string ligne = pythonStructure ; // On commence par ne garder que ce qui suit la premiere virgule - ligne = GetStringInTexte( ligne, ",", 1 ); + ligne = GetStringInTexte( ligne, ",", 1 ); // On boucle pour isoler toutes les chaines dans les virgules - std::string lignebis ; - std::string x0, x1, x2, x3, x4, x5, x6, x7 ; - int iaux = 0 ; - while ( ligne != lignebis ) - { - lignebis = GetStringInTexte ( ligne, ",", 0 ) ; + std::string lignebis ; + std::string x0, x1, x2, x3, x4, x5, x6, x7 ; + int iaux = 0 ; + while ( ligne != lignebis ) + { + lignebis = GetStringInTexte ( ligne, ",", 0 ) ; // MESSAGE("lignebis = "<\n" ; @@ -415,15 +461,15 @@ std::string YACSDriver::Texte_Iter_1_Boundary( int BoundaryType, const std::stri // } //=============================================================================== -// Controle des enchainements de noeud dans le noeud Iter_1 +// Fin du controle des enchainements de noeud dans le noeud Iter_1 //=============================================================================== std::string YACSDriver::Texte_Iter_1_control() { MESSAGE("Texte_Iter_1_control"); // std::string texte ; - texte = Texte_control ("CreateCase", "Case_Options") ; - texte += Texte_control ("Case_Options", "CreateHypothesis") ; + texte = Texte_control (_noeud_1, "CreateHypothesis", 1) ; + texte += Texte_control ("CreateHypothesis", "Case_Options", 0) ; // return texte ; // @@ -432,16 +478,19 @@ std::string YACSDriver::Texte_Iter_1_Boundary( int BoundaryType, const std::stri // Controle des enchainements de noeuds // noeud_1 : noeud de depart // noeud_2 : noeud d'arrivee +// option : 0 : sans caractere de saut de ligne a la fin +// 1 : avec caractere de saut de ligne a la fin //=============================================================================== - std::string YACSDriver::Texte_control( const std::string noeud_1, const std::string noeud_2 ) + std::string YACSDriver::Texte_control( const std::string noeud_1, const std::string noeud_2, int option ) { - MESSAGE("Texte_control, noeud_1 = "< " ; texte += "" + noeud_1 + "" ; texte += " " + noeud_2 + "" ; - texte += " \n" ; + texte += " " ; + if ( option == 1 ) { texte += "\n" ; } return texte ; // @@ -453,7 +502,7 @@ std::string YACSDriver::Texte_Iter_1_Boundary( int BoundaryType, const std::stri //=============================================================================== std::string YACSDriver::Texte_inport( const std::string inport_type, const std::string inport_nom ) { -// MESSAGE("Texte_control, inport_type = "< 0 ) + { + ligne_bis = ligne.substr( position ); + MESSAGE("\nligne_bis : "<< ligne_bis); + _Texte += concept + ligne_bis + "\n" ; + } + } + cptr += 1 ; + } +// +} +//=============================================================================== +// Manipulation des instructions python - 2 +// pythonTexte : le texte des instructions python a manipuler +// mot_cle : mot-cle dans les lignes a inserer +// concept : nom du concept a inserer +//=============================================================================== +void YACSDriver::Texte_python_2( const std::string pythonTexte, const std::string mot_cle, const std::string concept ) +{ + MESSAGE("Texte_python_2, pythonTexte\n"< 0 ) + { + int position = ligne.find_first_of( "." ) ; // MESSAGE("\nposition : "<< position); if ( position > 0 ) { @@ -515,11 +598,32 @@ void YACSDriver::Texte_python( const std::string pythonTexte, int indice, const _Texte += concept + ligne_bis + "\n" ; } } - cptr += 1 ; } // } //=============================================================================== +// Parametres de tests de convergence +//=============================================================================== +void YACSDriver::TexteAnalyse_Test_Convergence( int MaxIter, int MaxNode, int MaxElem ) +{ +// +// MESSAGE("TexteAnalyse_Test_Convergence"); + std::string chaine ; + std::ostringstream oss1; + oss1 << MaxIter; + chaine = oss1.str(); + _Texte += "MaxIter = " + chaine + "\n" ; + std::ostringstream oss2; + oss2 << MaxNode; + chaine = oss2.str(); + _Texte += "MaxNode = " + chaine + "\n" ; + std::ostringstream oss3; + oss3 << MaxElem; + chaine = oss3.str(); + _Texte += "MaxElem = " + chaine + "\n" ; +// +} +//=============================================================================== // Creation d'un parametre //=============================================================================== void YACSDriver::TexteParametre( const std::string node, const std::string port, const std::string type_value, const std::string value )