diff --git a/src/Core/CMakeLists.txt b/src/Core/CMakeLists.txt index 75c4ccbe..1de41062 100644 --- a/src/Core/CMakeLists.txt +++ b/src/Core/CMakeLists.txt @@ -106,7 +106,7 @@ endif() if (SEPA3D) target_include_directories (Core PUBLIC ${SEPARATRICE3D_INCLUDE_DIR}) endif (SEPA3D) -target_link_libraries (Core PUBLIC ${CORE_OPTIONAL_LIBRARIES_LIST} Mesquite::Mesquite cgns::cgns PkgConfig::GTS GMDSIg GMDSIo) +target_link_libraries (Core PUBLIC ${CORE_OPTIONAL_LIBRARIES_LIST} Mesquite::Mesquite cgns::cgns PkgConfig::GTS GMDSIg GMDSIo GMDSAero) # Etre capable une fois installée de retrouver vtk*, ... : # (Rem : en son absence on a Set runtime path of "/tmp/pignerol/install/lib/libCore.so.5.0.0" to "") ... set_target_properties (Core PROPERTIES INSTALL_RPATH_USE_LINK_PATH 1) diff --git a/src/Core/Mesh/CommandExportBlocksForCGNS.cpp b/src/Core/Mesh/CommandExportBlocksForCGNS.cpp index bc6a9488..4541d00b 100644 --- a/src/Core/Mesh/CommandExportBlocksForCGNS.cpp +++ b/src/Core/Mesh/CommandExportBlocksForCGNS.cpp @@ -8,7 +8,7 @@ namespace Mgx3D { /*----------------------------------------------------------------------------*/ CommandExportBlocksForCGNS:: CommandExportBlocksForCGNS(Internal::Context& context, const std::string& fileName) - : Internal::CommandInternal(context, "Export VTK total (géométrie)") + : Internal::CommandInternal(context, "Export CGNS total") , m_impl(context,fileName) { } @@ -21,7 +21,7 @@ namespace Mgx3D { void CommandExportBlocksForCGNS:: internalExecute() { - // écriture du VTK + // écriture du CGNS m_impl.perform(&getInfoCommand()); } /*----------------------------------------------------------------------------*/ diff --git a/src/Core/Mesh/ExportBlocksCGNSImplementation.cpp b/src/Core/Mesh/ExportBlocksCGNSImplementation.cpp index d8987c73..4162c8da 100644 --- a/src/Core/Mesh/ExportBlocksCGNSImplementation.cpp +++ b/src/Core/Mesh/ExportBlocksCGNSImplementation.cpp @@ -7,16 +7,12 @@ */ /*----------------------------------------------------------------------------*/ #include "Mesh/ExportBlocksCGNSImplementation.h" -#include "Geom/Volume.h" -#include "Geom/Surface.h" -#include "Geom/Curve.h" -#include "Geom/Vertex.h" #include "Mesh/MeshItf.h" #include "Mesh/Surface.h" /*----------------------------------------------------------------------------*/ #include #include -#include +#include /*----------------------------------------------------------------------------*/ #include #include @@ -26,8 +22,8 @@ namespace Mgx3D { namespace Mesh { /*----------------------------------------------------------------------------*/ ExportBlocksCGNSImplementation:: - ExportBlocksCGNSImplementation(Internal::Context& c, const std::string& n) - : m_context(c), m_filename(n) + ExportBlocksCGNSImplementation(Internal::Context& c, const std::string& filename) + : m_context(c), m_filename(filename) {} /*----------------------------------------------------------------------------*/ @@ -43,13 +39,14 @@ namespace Mgx3D { std::map n2v; - gmds::Mesh mesh(gmds::MeshModel(gmds::DIM3 | gmds::N | gmds::R | gmds::R2N | gmds::N2R)); + gmds::Mesh mesh(gmds::MeshModel(gmds::DIM3 | gmds::N | gmds::F | gmds::R | + gmds::R2N | gmds::N2R | gmds::R2F | gmds::F2R | gmds::F2N | gmds::N2F)); - gmds::Mesh localMesh = m_context.getMeshManager().getMesh()->getGMDSMesh(); + gmds::Mesh* localMesh = &m_context.getMeshManager().getMesh()->getGMDSMesh(); - for(int iVertex = 0; iVertex < localMesh.getNbNodes(); iVertex++){ - gmds::Node n_local = localMesh.get(iVertex); + for(int iVertex = 0; iVertex < localMesh->getNbNodes(); iVertex++){ + gmds::Node n_local = localMesh->get(iVertex); gmds::Node n = mesh.newNode(n_local.X(),n_local.Y(),n_local.Z()); } @@ -150,14 +147,18 @@ namespace Mgx3D { } } - gmds::IGMeshIOService ioService(&mesh); - gmds::VTKWriter writer(&ioService); - writer.setCellOptions(gmds::N|gmds::R); - writer.setDataOptions(gmds::N|gmds::R); - writer.write(m_filename); + int position = m_filename.find_last_of('/'); + + m_basename = m_filename.substr(position+1, m_filename.length()-position+1); + + m_path = m_filename.substr(0, position+1); + + gmds::aero::CGNSWriter3D writer3D(&mesh); + writer3D.write("",m_basename,m_path); + } /*----------------------------------------------------------------------------*/ - } // end namespace Topo + } // end namespace Mesh /*----------------------------------------------------------------------------*/ } // end namespace Mgx3D /*----------------------------------------------------------------------------*/ diff --git a/src/Core/Mesh/MeshManager.cpp b/src/Core/Mesh/MeshManager.cpp index fe7321d2..d0cf9008 100644 --- a/src/Core/Mesh/MeshManager.cpp +++ b/src/Core/Mesh/MeshManager.cpp @@ -621,7 +621,7 @@ CommandMeshExplorer* MeshManager::endExplorer(CommandMeshExplorer* oldExplo, boo // trace dans le script TkUtil::UTF8String cmd (TkUtil::Charset::UTF_8); - cmd << getContextAlias() << "." << "getTopoManager().exportBlocks("; + cmd << getContextAlias() << "." << "getTopoManager().exportBlocksForCGNS("; cmd <<"\""<setScriptCommand(cmd); diff --git a/src/Core/protected/Mesh/CommandExportBlocksForCGNS.h b/src/Core/protected/Mesh/CommandExportBlocksForCGNS.h index 42415148..5cc17d45 100644 --- a/src/Core/protected/Mesh/CommandExportBlocksForCGNS.h +++ b/src/Core/protected/Mesh/CommandExportBlocksForCGNS.h @@ -7,12 +7,11 @@ * Author: legoff */ /*----------------------------------------------------------------------------*/ -#ifndef MGX3D_GEOM_COMMANDEXPORTBLOCKSFORCGNS_H_ -#define MGX3D_GEOM_COMMANDEXPORTBLOCKSFORCGNS_H_ +#ifndef MGX3D_COMMANDEXPORTBLOCKSFORCGNS_H_ +#define MGX3D_COMMANDEXPORTBLOCKSFORCGNS_H_ /*----------------------------------------------------------------------------*/ #include "Internal/CommandInternal.h" #include "Utils/Vector.h" -#include "Geom/GeomEntity.h" #include "Internal/Context.h" #include "ExportBlocksCGNSImplementation.h" /*----------------------------------------------------------------------------*/ @@ -25,8 +24,7 @@ namespace Mesh { class GeomManager; /*----------------------------------------------------------------------------*/ /** \class CommandExportBlocksForCGNS - * \brief Commande permettant d'exporter l'ensemble des entités géométriques - * dans un fichier au format VTK + * \brief Commande permettant d'exporter le maillage au format CGNS */ /*----------------------------------------------------------------------------*/ class CommandExportBlocksForCGNS: public Internal::CommandInternal{ @@ -64,9 +62,9 @@ class CommandExportBlocksForCGNS: public Internal::CommandInternal{ ExportBlocksCGNSImplementation m_impl; }; /*----------------------------------------------------------------------------*/ -} // end namespace Geom +} // end namespace Mesh /*----------------------------------------------------------------------------*/ } // end namespace Mgx3D /*----------------------------------------------------------------------------*/ -#endif /* MGX3D_GEOM_COMMANDEXPORTBLOCKSFORCGNS_H_ */ +#endif /* MGX3D_COMMANDEXPORTBLOCKSFORCGNS_H_ */ /*----------------------------------------------------------------------------*/ diff --git a/src/Core/protected/Mesh/ExportBlocksCGNSImplementation.h b/src/Core/protected/Mesh/ExportBlocksCGNSImplementation.h index ad0c6359..667c0972 100644 --- a/src/Core/protected/Mesh/ExportBlocksCGNSImplementation.h +++ b/src/Core/protected/Mesh/ExportBlocksCGNSImplementation.h @@ -22,12 +22,12 @@ namespace Mgx3D { public: /*------------------------------------------------------------------------*/ - /** \brief Constructeur (exportation de toutes entités du GeomManager) + /** \brief Constructeur * * \param c le contexte * \param n le nom du fichier dans lequel se fait l'exportation */ - ExportBlocksCGNSImplementation(Internal::Context& c, const std::string& n); + ExportBlocksCGNSImplementation(Internal::Context& c, const std::string& filename); /*------------------------------------------------------------------------*/ /** \brief Destructeur @@ -45,8 +45,12 @@ namespace Mgx3D { /// contexte d'exécution Internal::Context& m_context; + std::string m_path; + /// fichier dans lequel on exporte std::string m_filename; + + std::string m_basename; }; /*----------------------------------------------------------------------------*/ @@ -54,7 +58,7 @@ namespace Mgx3D { /*----------------------------------------------------------------------------*/ } // end namespace Mgx3D /*----------------------------------------------------------------------------*/ -#endif /* EXPORTBLOCKCGNSSIMPLEMENTATION_H_ */ +#endif //EXPORTBLOCKSCGNSIMPLEMENTATION_H_ /*----------------------------------------------------------------------------*/ diff --git a/src/Core/protected/Mesh/MeshManager.h b/src/Core/protected/Mesh/MeshManager.h index 0874efab..6965a982 100644 --- a/src/Core/protected/Mesh/MeshManager.h +++ b/src/Core/protected/Mesh/MeshManager.h @@ -101,7 +101,7 @@ class MeshManager final : public Internal::CommandCreator { SET_SWIG_COMPLETABLE_METHOD(writeCGNS) /*------------------------------------------------------------------------*/ - /** \brief Export dans un fichier au format VTK de la structure de blocs + /** \brief Export dans un fichier au format CGNS du maillage * * \param n le nom du ficher dans lequel on exporte */ diff --git a/test_link/test_export_cgns.py b/test_link/test_export_cgns.py new file mode 100644 index 00000000..b65455bd --- /dev/null +++ b/test_link/test_export_cgns.py @@ -0,0 +1,35 @@ +import os +import pyMagix3D as Mgx3D + +def test_export_box(capfd): + ctx = Mgx3D.getStdContext() + ctx.clearSession() # Clean the session after the previous test + + cgnsfilename = "demiCylinder.cgns" + ctx.getTopoManager().newCylinderWithTopo (Mgx3D.Point(0, 0, 0), 1, Mgx3D.Vector(10, 0, 0), 360, True, .5, 10, 10, 10) + ctx.getTopoManager().splitAllBlocks ("Ar0013",.5) + ctx.getTopoManager().splitAllBlocks ("Ar0004",.5) + ctx.getTopoManager().splitAllBlocks ("Ar0070",.5) + ctx.getTopoManager().splitAllBlocks ("Ar0069",.5) + ctx.getTopoManager().splitAllBlocks ("Ar0176",.5) + ctx.getTopoManager().splitAllBlocks ("Ar0175",.5) + ctx.getTopoManager ( ).destroy (["Bl0075","Bl0076","Bl0077","Bl0078","Bl0079","Bl0080","Bl0081","Bl0082","Bl0091","Bl0092","Bl0093","Bl0094","Bl0095","Bl0096","Bl0097","Bl0098","Bl0099","Bl0100","Bl0101","Bl0102","Bl0115","Bl0116","Bl0117","Bl0118","Bl0119","Bl0120","Bl0121","Bl0122","Bl0131","Bl0132","Bl0133","Bl0134","Bl0135","Bl0136","Bl0137","Bl0138","Bl0139","Bl0140","Bl0141","Bl0142","Bl0083","Bl0084","Bl0085","Bl0086","Bl0123","Bl0124","Bl0125","Bl0126"], True) + ctx.getTopoManager().addToGroup (["Fa0393", "Fa0392", "Fa0285", "Fa0284", "Fa0395", "Fa0394", "Fa0287", "Fa0286", "Fa0279", "Fa0280", "Fa0387", "Fa0388", "Fa0278", "Fa0277", "Fa0386", "Fa0385"], 2, "Paroi") + ctx.getTopoManager().addToGroup (["Fa0295", "Fa0294", "Fa0403", "Fa0402", "Fa0353", "Fa0352", "Fa0461", "Fa0460", "Fa0345", "Fa0344", "Fa0453", "Fa0452", "Fa0329", "Fa0330", "Fa0437", "Fa0438"], 2, "Farfield") + ctx.getTopoManager().addToGroup (["Fa0096", "Fa0097", "Fa0136", "Fa0137", "Fa0129", "Fa0130", "Fa0125", "Fa0124", "Fa0094", "Fa0095", "Fa0134", "Fa0135", "Fa0128", "Fa0127", "Fa0122", "Fa0123"], 2, "Sortie") + ctx.getTopoManager().addToGroup (["Fa0360", "Fa0369", "Fa0359", "Fa0368", "Fa0252", "Fa0261", "Fa0251", "Fa0260", "Fa0327", "Fa0322", "Fa0326", "Fa0321", "Fa0435", "Fa0430", "Fa0434", "Fa0429"], 2, "Symetrie") + emp = Mgx3D.EdgeMeshingPropertyUniform(10) + ctx.getTopoManager().setParallelMeshingProperty (emp,"Ar0363") + emp = Mgx3D.EdgeMeshingPropertyUniform(10) + ctx.getTopoManager().setParallelMeshingProperty (emp,"Ar0364") + emp = Mgx3D.EdgeMeshingPropertyUniform(10) + ctx.getTopoManager().setParallelMeshingProperty (emp,"Ar0269") + emp = Mgx3D.EdgeMeshingPropertyUniform(10) + ctx.getTopoManager().setParallelMeshingProperty (emp,"Ar0270") + ctx.getMeshManager().newAllBlocksMesh() + ctx.getMeshManager().exportBlocksForCGNS(cgnsfilename) + + assert os.path.exists(cgnsfilename) + assert os.path.getsize(cgnsfilename) > 0 + out, err = capfd.readouterr() + assert len(err) == 0 \ No newline at end of file