Skip to content

Commit 0a9164c

Browse files
authored
Merge pull request #170 from LIHPC-Computational-Geometry/cgns_update_final
Cgns update final
2 parents a135089 + bedeead commit 0a9164c

File tree

8 files changed

+70
-32
lines changed

8 files changed

+70
-32
lines changed

src/Core/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ endif()
106106
if (SEPA3D)
107107
target_include_directories (Core PUBLIC ${SEPARATRICE3D_INCLUDE_DIR})
108108
endif (SEPA3D)
109-
target_link_libraries (Core PUBLIC ${CORE_OPTIONAL_LIBRARIES_LIST} Mesquite::Mesquite cgns::cgns PkgConfig::GTS GMDSIg GMDSIo)
109+
target_link_libraries (Core PUBLIC ${CORE_OPTIONAL_LIBRARIES_LIST} Mesquite::Mesquite cgns::cgns PkgConfig::GTS GMDSIg GMDSIo GMDSAero)
110110
# Etre capable une fois installée de retrouver vtk*, ... :
111111
# (Rem : en son absence on a Set runtime path of "/tmp/pignerol/install/lib/libCore.so.5.0.0" to "") ...
112112
set_target_properties (Core PROPERTIES INSTALL_RPATH_USE_LINK_PATH 1)

src/Core/Mesh/CommandExportBlocksForCGNS.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Mgx3D {
88
/*----------------------------------------------------------------------------*/
99
CommandExportBlocksForCGNS::
1010
CommandExportBlocksForCGNS(Internal::Context& context, const std::string& fileName)
11-
: Internal::CommandInternal(context, "Export VTK total (géométrie)")
11+
: Internal::CommandInternal(context, "Export CGNS total")
1212
, m_impl(context,fileName)
1313
{
1414
}
@@ -21,7 +21,7 @@ namespace Mgx3D {
2121
void CommandExportBlocksForCGNS::
2222
internalExecute()
2323
{
24-
// écriture du VTK
24+
// écriture du CGNS
2525
m_impl.perform(&getInfoCommand());
2626
}
2727
/*----------------------------------------------------------------------------*/

src/Core/Mesh/ExportBlocksCGNSImplementation.cpp

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,12 @@
77
*/
88
/*----------------------------------------------------------------------------*/
99
#include "Mesh/ExportBlocksCGNSImplementation.h"
10-
#include "Geom/Volume.h"
11-
#include "Geom/Surface.h"
12-
#include "Geom/Curve.h"
13-
#include "Geom/Vertex.h"
1410
#include "Mesh/MeshItf.h"
1511
#include "Mesh/Surface.h"
1612
/*----------------------------------------------------------------------------*/
1713
#include <gmds/ig/Mesh.h>
1814
#include <gmds/io/IGMeshIOService.h>
19-
#include <gmds/io/VTKWriter.h>
15+
#include <gmds/aero/CGNSWriter3D.h>
2016
/*----------------------------------------------------------------------------*/
2117
#include <TkUtil/MemoryError.h>
2218
#include <iostream>
@@ -26,8 +22,8 @@ namespace Mgx3D {
2622
namespace Mesh {
2723
/*----------------------------------------------------------------------------*/
2824
ExportBlocksCGNSImplementation::
29-
ExportBlocksCGNSImplementation(Internal::Context& c, const std::string& n)
30-
: m_context(c), m_filename(n)
25+
ExportBlocksCGNSImplementation(Internal::Context& c, const std::string& filename)
26+
: m_context(c), m_filename(filename)
3127
{}
3228

3329
/*----------------------------------------------------------------------------*/
@@ -43,13 +39,14 @@ namespace Mgx3D {
4339

4440
std::map<gmds::TCellID,unsigned long> n2v;
4541

46-
gmds::Mesh mesh(gmds::MeshModel(gmds::DIM3 | gmds::N | gmds::R | gmds::R2N | gmds::N2R));
42+
gmds::Mesh mesh(gmds::MeshModel(gmds::DIM3 | gmds::N | gmds::F | gmds::R |
43+
gmds::R2N | gmds::N2R | gmds::R2F | gmds::F2R | gmds::F2N | gmds::N2F));
4744

48-
gmds::Mesh localMesh = m_context.getMeshManager().getMesh()->getGMDSMesh();
45+
gmds::Mesh* localMesh = &m_context.getMeshManager().getMesh()->getGMDSMesh();
4946

5047

51-
for(int iVertex = 0; iVertex < localMesh.getNbNodes(); iVertex++){
52-
gmds::Node n_local = localMesh.get<gmds::Node>(iVertex);
48+
for(int iVertex = 0; iVertex < localMesh->getNbNodes(); iVertex++){
49+
gmds::Node n_local = localMesh->get<gmds::Node>(iVertex);
5350
gmds::Node n = mesh.newNode(n_local.X(),n_local.Y(),n_local.Z());
5451
}
5552

@@ -150,14 +147,18 @@ namespace Mgx3D {
150147
}
151148
}
152149

153-
gmds::IGMeshIOService ioService(&mesh);
154-
gmds::VTKWriter writer(&ioService);
155-
writer.setCellOptions(gmds::N|gmds::R);
156-
writer.setDataOptions(gmds::N|gmds::R);
157-
writer.write(m_filename);
150+
int position = m_filename.find_last_of('/');
151+
152+
m_basename = m_filename.substr(position+1, m_filename.length()-position+1);
153+
154+
m_path = m_filename.substr(0, position+1);
155+
156+
gmds::aero::CGNSWriter3D writer3D(&mesh);
157+
writer3D.write("",m_basename,m_path);
158+
158159
}
159160
/*----------------------------------------------------------------------------*/
160-
} // end namespace Topo
161+
} // end namespace Mesh
161162
/*----------------------------------------------------------------------------*/
162163
} // end namespace Mgx3D
163164
/*----------------------------------------------------------------------------*/

src/Core/Mesh/MeshManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ CommandMeshExplorer* MeshManager::endExplorer(CommandMeshExplorer* oldExplo, boo
621621

622622
// trace dans le script
623623
TkUtil::UTF8String cmd (TkUtil::Charset::UTF_8);
624-
cmd << getContextAlias() << "." << "getTopoManager().exportBlocks(";
624+
cmd << getContextAlias() << "." << "getTopoManager().exportBlocksForCGNS(";
625625
cmd <<"\""<<n<<"\")";
626626
command->setScriptCommand(cmd);
627627

src/Core/protected/Mesh/CommandExportBlocksForCGNS.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@
77
* Author: legoff
88
*/
99
/*----------------------------------------------------------------------------*/
10-
#ifndef MGX3D_GEOM_COMMANDEXPORTBLOCKSFORCGNS_H_
11-
#define MGX3D_GEOM_COMMANDEXPORTBLOCKSFORCGNS_H_
10+
#ifndef MGX3D_COMMANDEXPORTBLOCKSFORCGNS_H_
11+
#define MGX3D_COMMANDEXPORTBLOCKSFORCGNS_H_
1212
/*----------------------------------------------------------------------------*/
1313
#include "Internal/CommandInternal.h"
1414
#include "Utils/Vector.h"
15-
#include "Geom/GeomEntity.h"
1615
#include "Internal/Context.h"
1716
#include "ExportBlocksCGNSImplementation.h"
1817
/*----------------------------------------------------------------------------*/
@@ -25,8 +24,7 @@ namespace Mesh {
2524
class GeomManager;
2625
/*----------------------------------------------------------------------------*/
2726
/** \class CommandExportBlocksForCGNS
28-
* \brief Commande permettant d'exporter l'ensemble des entités géométriques
29-
* dans un fichier au format VTK
27+
* \brief Commande permettant d'exporter le maillage au format CGNS
3028
*/
3129
/*----------------------------------------------------------------------------*/
3230
class CommandExportBlocksForCGNS: public Internal::CommandInternal{
@@ -64,9 +62,9 @@ class CommandExportBlocksForCGNS: public Internal::CommandInternal{
6462
ExportBlocksCGNSImplementation m_impl;
6563
};
6664
/*----------------------------------------------------------------------------*/
67-
} // end namespace Geom
65+
} // end namespace Mesh
6866
/*----------------------------------------------------------------------------*/
6967
} // end namespace Mgx3D
7068
/*----------------------------------------------------------------------------*/
71-
#endif /* MGX3D_GEOM_COMMANDEXPORTBLOCKSFORCGNS_H_ */
69+
#endif /* MGX3D_COMMANDEXPORTBLOCKSFORCGNS_H_ */
7270
/*----------------------------------------------------------------------------*/

src/Core/protected/Mesh/ExportBlocksCGNSImplementation.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ namespace Mgx3D {
2222
public:
2323

2424
/*------------------------------------------------------------------------*/
25-
/** \brief Constructeur (exportation de toutes entités du GeomManager)
25+
/** \brief Constructeur
2626
*
2727
* \param c le contexte
2828
* \param n le nom du fichier dans lequel se fait l'exportation
2929
*/
30-
ExportBlocksCGNSImplementation(Internal::Context& c, const std::string& n);
30+
ExportBlocksCGNSImplementation(Internal::Context& c, const std::string& filename);
3131

3232
/*------------------------------------------------------------------------*/
3333
/** \brief Destructeur
@@ -45,16 +45,20 @@ namespace Mgx3D {
4545
/// contexte d'exécution
4646
Internal::Context& m_context;
4747

48+
std::string m_path;
49+
4850
/// fichier dans lequel on exporte
4951
std::string m_filename;
52+
53+
std::string m_basename;
5054
};
5155

5256
/*----------------------------------------------------------------------------*/
5357
} // end namespace Mesh
5458
/*----------------------------------------------------------------------------*/
5559
} // end namespace Mgx3D
5660
/*----------------------------------------------------------------------------*/
57-
#endif /* EXPORTBLOCKCGNSSIMPLEMENTATION_H_ */
61+
#endif //EXPORTBLOCKSCGNSIMPLEMENTATION_H_
5862
/*----------------------------------------------------------------------------*/
5963

6064

src/Core/protected/Mesh/MeshManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class MeshManager final : public Internal::CommandCreator {
101101
SET_SWIG_COMPLETABLE_METHOD(writeCGNS)
102102

103103
/*------------------------------------------------------------------------*/
104-
/** \brief Export dans un fichier au format VTK de la structure de blocs
104+
/** \brief Export dans un fichier au format CGNS du maillage
105105
*
106106
* \param n le nom du ficher dans lequel on exporte
107107
*/

test_link/test_export_cgns.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import os
2+
import pyMagix3D as Mgx3D
3+
4+
def test_export_box(capfd):
5+
ctx = Mgx3D.getStdContext()
6+
ctx.clearSession() # Clean the session after the previous test
7+
8+
cgnsfilename = "demiCylinder.cgns"
9+
ctx.getTopoManager().newCylinderWithTopo (Mgx3D.Point(0, 0, 0), 1, Mgx3D.Vector(10, 0, 0), 360, True, .5, 10, 10, 10)
10+
ctx.getTopoManager().splitAllBlocks ("Ar0013",.5)
11+
ctx.getTopoManager().splitAllBlocks ("Ar0004",.5)
12+
ctx.getTopoManager().splitAllBlocks ("Ar0070",.5)
13+
ctx.getTopoManager().splitAllBlocks ("Ar0069",.5)
14+
ctx.getTopoManager().splitAllBlocks ("Ar0176",.5)
15+
ctx.getTopoManager().splitAllBlocks ("Ar0175",.5)
16+
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)
17+
ctx.getTopoManager().addToGroup (["Fa0393", "Fa0392", "Fa0285", "Fa0284", "Fa0395", "Fa0394", "Fa0287", "Fa0286", "Fa0279", "Fa0280", "Fa0387", "Fa0388", "Fa0278", "Fa0277", "Fa0386", "Fa0385"], 2, "Paroi")
18+
ctx.getTopoManager().addToGroup (["Fa0295", "Fa0294", "Fa0403", "Fa0402", "Fa0353", "Fa0352", "Fa0461", "Fa0460", "Fa0345", "Fa0344", "Fa0453", "Fa0452", "Fa0329", "Fa0330", "Fa0437", "Fa0438"], 2, "Farfield")
19+
ctx.getTopoManager().addToGroup (["Fa0096", "Fa0097", "Fa0136", "Fa0137", "Fa0129", "Fa0130", "Fa0125", "Fa0124", "Fa0094", "Fa0095", "Fa0134", "Fa0135", "Fa0128", "Fa0127", "Fa0122", "Fa0123"], 2, "Sortie")
20+
ctx.getTopoManager().addToGroup (["Fa0360", "Fa0369", "Fa0359", "Fa0368", "Fa0252", "Fa0261", "Fa0251", "Fa0260", "Fa0327", "Fa0322", "Fa0326", "Fa0321", "Fa0435", "Fa0430", "Fa0434", "Fa0429"], 2, "Symetrie")
21+
emp = Mgx3D.EdgeMeshingPropertyUniform(10)
22+
ctx.getTopoManager().setParallelMeshingProperty (emp,"Ar0363")
23+
emp = Mgx3D.EdgeMeshingPropertyUniform(10)
24+
ctx.getTopoManager().setParallelMeshingProperty (emp,"Ar0364")
25+
emp = Mgx3D.EdgeMeshingPropertyUniform(10)
26+
ctx.getTopoManager().setParallelMeshingProperty (emp,"Ar0269")
27+
emp = Mgx3D.EdgeMeshingPropertyUniform(10)
28+
ctx.getTopoManager().setParallelMeshingProperty (emp,"Ar0270")
29+
ctx.getMeshManager().newAllBlocksMesh()
30+
ctx.getMeshManager().exportBlocksForCGNS(cgnsfilename)
31+
32+
assert os.path.exists(cgnsfilename)
33+
assert os.path.getsize(cgnsfilename) > 0
34+
out, err = capfd.readouterr()
35+
assert len(err) == 0

0 commit comments

Comments
 (0)