X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHOMARD%2FHOMARD_DriverTools.cxx;h=5a7740bb6a6016270089bd2584bf0f6991fb23e2;hb=5b1d82dd069b1e815985e542a500cc67f3fdfc82;hp=818f4ae39d867cefdb9211b56db47e5baf238cf6;hpb=a3b974f0f68b4ea42bbfadb42106996e9a1842c8;p=modules%2Fhomard.git diff --git a/src/HOMARD/HOMARD_DriverTools.cxx b/src/HOMARD/HOMARD_DriverTools.cxx index 818f4ae3..5a7740bb 100644 --- a/src/HOMARD/HOMARD_DriverTools.cxx +++ b/src/HOMARD/HOMARD_DriverTools.cxx @@ -1,9 +1,9 @@ -// Copyright (C) 2011-2013 CEA/DEN, EDF R&D +// Copyright (C) 2011-2023 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 @@ -27,6 +27,7 @@ #include "HOMARD_Hypothesis.hxx" #include "HOMARD_Iteration.hxx" #include "HOMARD_Zone.hxx" +#include "HOMARD_YACS.hxx" #include #include #include "utilities.h" @@ -34,7 +35,7 @@ namespace HOMARD { - const char* const SEPARATOR = "|"; + std::string SEPARATOR = "|" ; /*! \brief Read next chunk of data from the string @@ -78,6 +79,7 @@ namespace HOMARD case Hypothesis: signature = "HYPO"; break; case Iteration: signature = "ITER"; break; case Boundary: signature = "BOUNDARY"; break; + case YACS: signature = "YACS"; break; default: break; } signature += separator(); @@ -90,11 +92,11 @@ namespace HOMARD */ std::string separator() { - return std::string( SEPARATOR ); + return SEPARATOR ; } // ======================= -// Case +// 1.1. Case // ======================= /*! \brief Dump case to the string @@ -110,6 +112,7 @@ namespace HOMARD os << cas.GetName(); os << separator() << cas.GetDirName(); os << separator() << cas.GetConfType(); + os << separator() << cas.GetExtType(); std::vector coor = cas.GetBoundingBox(); os << separator() << coor.size(); @@ -138,8 +141,9 @@ namespace HOMARD return saux ; } // -// Iteration -// ========== +// ============== +// 1.2. Iteration +// ============== // /*! \brief Dump iteration to the string @@ -153,7 +157,7 @@ namespace HOMARD // ... MESSAGE( ". Sauvegarde de l'iteration "< coor = boundary.GetCoords() ; @@ -322,9 +333,31 @@ namespace HOMARD } // -// Restauration des objets +// ========= +// 1.6. YACS +// ========= + + /*! + \brief Dump YACS to the string + \param yacs yacs being dumped + \return string representation of the zone + */ + std::string Dump( const HOMARD_YACS& yacs ) + { + std::stringstream os; + std::string saux ; + MESSAGE( ". Sauvegarde du schema YACS "< coords; int lgcoords ; - if ( ZoneType == 2 or ( ZoneType >= 11 and ZoneType <= 13 ) ) { lgcoords = 6 ; } + if ( ZoneType == 2 || ( ZoneType >= 11 && ZoneType <= 13 ) ) { lgcoords = 6 ; } else if ( ZoneType == 4 ) { lgcoords = 4 ; } - else if ( ZoneType == 5 or ( ZoneType >= 31 and ZoneType <= 33 ) ) { lgcoords = 8 ; } - else if ( ZoneType == 7 or ( ZoneType >= 61 and ZoneType <= 63 ) ) { lgcoords = 9 ; } + else if ( ZoneType == 5 || ( ZoneType >= 31 && ZoneType <= 33 ) ) { lgcoords = 8 ; } + else if ( ZoneType == 7 || ( ZoneType >= 61 && ZoneType <= 63 ) ) { lgcoords = 9 ; } else return false; coords.resize( lgcoords ); for ( int i = 0; i < lgcoords; i++ ) { @@ -645,13 +689,13 @@ namespace HOMARD if ( !ok ) return false; coords[i] = strtod( chunk.c_str(), 0 ); } - if ( ZoneType == 2 or ( ZoneType >= 11 and ZoneType <= 13 ) ) + if ( ZoneType == 2 || ( ZoneType >= 11 && ZoneType <= 13 ) ) { zone.SetBox( coords[0], coords[1], coords[2], coords[3], coords[4], coords[5] ); } else if ( ZoneType == 4 ) { zone.SetSphere( coords[0], coords[1], coords[2], coords[3] ); } - else if ( ZoneType == 5 or ( ZoneType >= 31 and ZoneType <= 33 ) ) + else if ( ZoneType == 5 || ( ZoneType >= 31 && ZoneType <= 33 ) ) { zone.SetCylinder( coords[0], coords[1], coords[2], coords[3], coords[4], coords[5], coords[6], coords[7] ); } - else if ( ZoneType == 7 or ( ZoneType >= 61 and ZoneType <= 63 ) ) + else if ( ZoneType == 7 || ( ZoneType >= 61 && ZoneType <= 63 ) ) { zone.SetPipe( coords[0], coords[1], coords[2], coords[3], coords[4], coords[5], coords[6], coords[7], coords[8] ); } // Remarque : la taille de coords est suffisante pour les limites for ( int i = 0; i < 3; i++ ) { @@ -673,6 +717,7 @@ namespace HOMARD } // +// ================================= // 2.5. Restauration d'une frontiere // ================================= @@ -680,7 +725,7 @@ namespace HOMARD \brief Restore boundary from the string \param boundary boundary being restored \param stream string representation of the boundary - \return \c true if zone is correctly restored or \c false otherwise + \return \c true if the boundary is correctly restored or \c false otherwise */ bool Restore( HOMARD_Boundary& boundary, const std::string& stream ) { @@ -703,12 +748,20 @@ namespace HOMARD // Si analytique, les coordonnees des frontieres : le nombre depend du type // Si discret, le maillage + // Si CAO, la géométrie int lgcoords ; - if ( BoundaryType == 1 ) { lgcoords = 7 ; } + if ( BoundaryType == -1 ) { lgcoords = -1 ; } + else if ( BoundaryType == 1 ) { lgcoords = 7 ; } else if ( BoundaryType == 2 ) { lgcoords = 4 ; } else { lgcoords = 0 ; } // - if ( lgcoords == 0 ) + if ( lgcoords == -1 ) + { + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + boundary.SetDataFile( chunk.c_str() ); + } + else if ( lgcoords == 0 ) { chunk = getNextChunk( stream, start, ok ); if ( !ok ) return false; @@ -716,7 +769,7 @@ namespace HOMARD chunk = getNextChunk( stream, start, ok ); if ( !ok ) return false; - boundary.SetMeshFile( chunk.c_str() ); + boundary.SetDataFile( chunk.c_str() ); } else { std::vector coords; @@ -755,4 +808,33 @@ namespace HOMARD return true; } +// +// ================================== +// 2.6. Restauration d'un schema YACS +// ================================== + + /*! + \brief Restore a schema YACS from the string + \param yacs yacs being restored + \param stream string representation of the schema yacs + \return \c true if yacs is correctly restored or \c false otherwise + */ + bool Restore( HOMARD_YACS& yacs, const std::string& stream ) + { + std::string::size_type start = 0; + std::string chunk; + bool ok; + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + yacs.SetName( chunk.c_str() ); + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + int YACSType = atoi( chunk.c_str() ) ; + yacs.SetType( YACSType ); + + return true; + } + } // namespace HOMARD /end/