Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/Core/Mesh/CommandExportBlocksForCGNS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}
Expand All @@ -21,7 +21,7 @@ namespace Mgx3D {
void CommandExportBlocksForCGNS::
internalExecute()
{
// écriture du VTK
// écriture du CGNS
m_impl.perform(&getInfoCommand());
}
/*----------------------------------------------------------------------------*/
Expand Down
35 changes: 18 additions & 17 deletions src/Core/Mesh/ExportBlocksCGNSImplementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <gmds/ig/Mesh.h>
#include <gmds/io/IGMeshIOService.h>
#include <gmds/io/VTKWriter.h>
#include <gmds/aero/CGNSWriter3D.h>
/*----------------------------------------------------------------------------*/
#include <TkUtil/MemoryError.h>
#include <iostream>
Expand All @@ -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)
{}

/*----------------------------------------------------------------------------*/
Expand All @@ -43,13 +39,14 @@ namespace Mgx3D {

std::map<gmds::TCellID,unsigned long> 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<gmds::Node>(iVertex);
for(int iVertex = 0; iVertex < localMesh->getNbNodes(); iVertex++){
gmds::Node n_local = localMesh->get<gmds::Node>(iVertex);
gmds::Node n = mesh.newNode(n_local.X(),n_local.Y(),n_local.Z());
}

Expand Down Expand Up @@ -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
/*----------------------------------------------------------------------------*/
2 changes: 1 addition & 1 deletion src/Core/Mesh/MeshManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<"\""<<n<<"\")";
command->setScriptCommand(cmd);

Expand Down
12 changes: 5 additions & 7 deletions src/Core/protected/Mesh/CommandExportBlocksForCGNS.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
/*----------------------------------------------------------------------------*/
Expand All @@ -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{
Expand Down Expand Up @@ -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_ */
/*----------------------------------------------------------------------------*/
10 changes: 7 additions & 3 deletions src/Core/protected/Mesh/ExportBlocksCGNSImplementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -45,16 +45,20 @@ 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;
};

/*----------------------------------------------------------------------------*/
} // end namespace Mesh
/*----------------------------------------------------------------------------*/
} // end namespace Mgx3D
/*----------------------------------------------------------------------------*/
#endif /* EXPORTBLOCKCGNSSIMPLEMENTATION_H_ */
#endif //EXPORTBLOCKSCGNSIMPLEMENTATION_H_
/*----------------------------------------------------------------------------*/


Expand Down
2 changes: 1 addition & 1 deletion src/Core/protected/Mesh/MeshManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
35 changes: 35 additions & 0 deletions test_link/test_export_cgns.py
Original file line number Diff line number Diff line change
@@ -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