Skip to content

Commit 3cb9195

Browse files
committed
- cleaning + test
1 parent fe73794 commit 3cb9195

File tree

7 files changed

+53
-19
lines changed

7 files changed

+53
-19
lines changed

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: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
/*----------------------------------------------------------------------------*/
1313
#include <gmds/ig/Mesh.h>
1414
#include <gmds/io/IGMeshIOService.h>
15-
#include <gmds/io/VTKWriter.h>
1615
#include <gmds/aero/CGNSWriter3D.h>
1716
/*----------------------------------------------------------------------------*/
1817
#include <TkUtil/MemoryError.h>
@@ -40,13 +39,14 @@ namespace Mgx3D {
4039

4140
std::map<gmds::TCellID,unsigned long> n2v;
4241

43-
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));
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));
4444

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

4747

48-
for(int iVertex = 0; iVertex < localMesh.getNbNodes(); iVertex++){
49-
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);
5050
gmds::Node n = mesh.newNode(n_local.X(),n_local.Y(),n_local.Z());
5151
}
5252

@@ -158,7 +158,7 @@ namespace Mgx3D {
158158

159159
}
160160
/*----------------------------------------------------------------------------*/
161-
} // end namespace Topo
161+
} // end namespace Mesh
162162
/*----------------------------------------------------------------------------*/
163163
} // end namespace Mgx3D
164164
/*----------------------------------------------------------------------------*/

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ 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
@@ -58,7 +58,7 @@ namespace Mgx3D {
5858
/*----------------------------------------------------------------------------*/
5959
} // end namespace Mgx3D
6060
/*----------------------------------------------------------------------------*/
61-
#endif /* EXPORTBLOCKCGNSSIMPLEMENTATION_H_ */
61+
#endif //EXPORTBLOCKSCGNSIMPLEMENTATION_H_
6262
/*----------------------------------------------------------------------------*/
6363

6464

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: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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("")
31+
ctx.getGeomManager().exportVTK(cgnsfilename)
32+
33+
assert os.path.exists(cgnsfilename)
34+
assert os.path.getsize(cgnsfilename) > 0
35+
out, err = capfd.readouterr()
36+
assert len(err) == 0

0 commit comments

Comments
 (0)