Skip to content

Commit b35388c

Browse files
committed
- integrating CGNSWriter3D for aero output
1 parent 63602bb commit b35388c

File tree

10 files changed

+123
-35
lines changed

10 files changed

+123
-35
lines changed

aero/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ set(GMDS_INC
7373
inc/gmds/aero/SU2Writer_3D.h
7474
inc/gmds/aero/TransfiniteInterpolation_3D.h
7575
inc/gmds/aero/Utils.h
76-
76+
inc/gmds/aero/CGNSWriter3D.h
7777
)
7878
set(GMDS_SRC
7979
src/AbstractAeroBoundaries.cpp
@@ -142,6 +142,7 @@ set(GMDS_SRC
142142
src/TransfiniteInterpolation_3D.cpp
143143
src/Utils.cpp
144144
src/main.cpp
145+
src/CGNSWriter3D.cpp
145146
)
146147
#==============================================================================
147148
add_library(${GMDS_LIB} ${GMDS_INC} ${GMDS_SRC})

aero/inc/gmds/aero/AeroPipeline_3D.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ class LIB_GMDS_AERO_API AeroPipeline_3D : public AbstractAeroPipeline {
2828
*/
2929
AbstractAeroPipeline::STATUS execute() override;
3030
/*------------------------------------------------------------------------*/
31+
/** \brief Get the 3D blocking structure
32+
*/
33+
Blocking3D* getBlocking();
3134

3235
private:
3336
/*------------------------------------------------------------------------*/

blocking/inc/gmds/blocking/CGNSWriter3D.h renamed to aero/inc/gmds/aero/CGNSWriter3D.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,23 @@
99
/*----------------------------------------------------------------------------*/
1010
#include <cgnslib.h>
1111
/*----------------------------------------------------------------------------*/
12-
#include "LIB_GMDS_BLOCKING_export.h"
13-
#include "gmds/ig/Blocking2D.h"
12+
#include "Blocking3D.h"
13+
#include "LIB_GMDS_AERO_export.h"
14+
// #include "gmds/ig/Blocking2D.h"
1415
/*----------------------------------------------------------------------------*/
1516
namespace gmds {
1617

17-
namespace blocking {
18+
namespace aero {
1819

19-
class LIB_GMDS_BLOCKING_API CGNSWriter3D
20+
class LIB_GMDS_AERO_API CGNSWriter3D
2021
{
2122
public:
2223
/** @brief Constructor
2324
*
2425
* @param AMeshService an implementation of an io service to write data
2526
* into a mesh
2627
*/
27-
CGNSWriter3D(Blocking2D *ABlocking);
28+
CGNSWriter3D(Blocking3D *ABlocking);
2829

2930
CGNSWriter3D(Mesh *AMesh);
3031

aero/src/AbstractAeroPipeline.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ AbstractAeroPipeline::AbstractAeroPipeline(std::string &Aparams, std::string &Aw
8484
p.get("section_Extrusion","y_lim_insertions", m_params.y_lim);
8585
p.get("section_Extrusion","z_lim_insertions", m_params.z_lim);
8686
p.get("section_Extrusion","insertions_allowed_on_first_layer", m_params.insertions_allowed_on_first_layer);
87-
p.get("section_Extrusion","nbr_linear_blocks_smoothing", m_params.nbr_linear_blocks_smoothing);
87+
//p.get("section_Extrusion","nbr_linear_blocks_smoothing", m_params.nbr_linear_blocks_smoothing);
8888

8989
p.get("section_Curved_Blocks","max_degree", m_params.max_degree);
9090
p.get("section_Curved_Blocks","max_error", m_params.max_error);

aero/src/AeroPipeline_3D.cpp

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3130,4 +3130,70 @@ AeroPipeline_3D::smoothingLinearBlocks(int nb_iteration)
31303130

31313131
}
31323132
}
3133+
/*------------------------------------------------------------------------*/
3134+
Blocking3D*
3135+
AeroPipeline_3D::getBlocking()
3136+
{
3137+
//std::cout<<"Writing blocks for cgns"<<std::endl;
3138+
gmds::Variable<int>* discrI = m_Blocking3D.newVariable<int, gmds::GMDS_REGION>("discrI");
3139+
gmds::Variable<int>* discrJ = m_Blocking3D.newVariable<int, gmds::GMDS_REGION>("discrJ");
3140+
gmds::Variable<int>* discrK = m_Blocking3D.newVariable<int, gmds::GMDS_REGION>("discrK");
3141+
gmds::Variable<int>* farfield = m_Blocking3D.newVariable<int, gmds::GMDS_NODE>("Farfield");
3142+
gmds::Variable<int>* paroi = m_Blocking3D.newVariable<int, gmds::GMDS_NODE>("Paroi");
3143+
Variable<int>* var_couche_blocking = m_Blocking3D.getVariable<int, GMDS_NODE>("GMDS_Couche");
3144+
int max_layer = 0;
3145+
for(auto b : m_Blocking3D.allBlocks()){
3146+
gmds::Variable<int>* internalNodes = m_Blocking3D.newVariable<int, gmds::GMDS_NODE>("block"+std::to_string(b.id()));
3147+
//std::cout<<"Block "<<b.id()<<std::endl;
3148+
int b_discrI = b.getNbDiscretizationI(),b_discrJ = b.getNbDiscretizationJ(), b_discrK = b.getNbDiscretizationK();
3149+
discrI->set(b.id(), b_discrI);
3150+
discrJ->set(b.id(), b_discrJ);
3151+
discrK->set(b.id(), b_discrK);
3152+
int iNode = 0;
3153+
for(int k = 0; k < b_discrK; k++){
3154+
for(int j = 0; j < b_discrJ; j++){
3155+
for(int i = 0; i < b_discrI; i++){
3156+
internalNodes->set(b(i,j,k).id(),iNode+1);
3157+
iNode++;
3158+
}
3159+
}
3160+
}
3161+
for(int i_b = 0; i_b<8; i_b++){
3162+
int layer = var_couche_blocking->value(b.getNode(i_b).id());
3163+
max_layer = layer > max_layer ? layer : max_layer;
3164+
}
3165+
}
3166+
for(auto f : m_Blocking3D.faces()){
3167+
Blocking3D::BlockFace b_f = m_Blocking3D.blockFace(f);
3168+
bool isWall = true;
3169+
bool isFF = true;
3170+
for(int i_n = 0; i_n<4; i_n++){
3171+
if(var_couche_blocking->value(b_f.getNode(i_n).id()) != 0) isWall = false;
3172+
if(var_couche_blocking->value(b_f.getNode(i_n).id()) != max_layer) isFF = false;
3173+
}
3174+
int bf_discrI = b_f.getNbDiscretizationI(), bf_discrJ = b_f.getNbDiscretizationJ();
3175+
if(isFF) {
3176+
for (int j = 0; j < bf_discrJ; j++) {
3177+
for (int i = 0; i < bf_discrI; i++) {
3178+
farfield->set(b_f(i, j).id(), 1);
3179+
}
3180+
}
3181+
}else if(isWall){
3182+
for (int j = 0; j < bf_discrJ; j++) {
3183+
for (int i = 0; i < bf_discrI; i++) {
3184+
paroi->set(b_f(i, j).id(), 1);
3185+
}
3186+
}
3187+
}
3188+
}
3189+
/*gmds::IGMeshIOService ioService(&m_Blocking3D);
3190+
gmds::VTKWriter vtkWriter(&ioService);
3191+
vtkWriter.setCellOptions(gmds::N|gmds::R);
3192+
vtkWriter.setDataOptions(gmds::N|gmds::R);
3193+
std::cout<<"start writing"<<std::endl;
3194+
vtkWriter.write("CGNS_"+m_params.output_file);
3195+
std::cout<<"end writing"<<std::endl;*/
3196+
//return "CGNS_"+m_params.output_file;
3197+
return &m_Blocking3D;
3198+
}
31333199
/*------------------------------------------------------------------------*/

blocking/src/CGNSWriter3D.cpp renamed to aero/src/CGNSWriter3D.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
// Created by calderans on 29/06/2023.
44
//
55
/*----------------------------------------------------------------------------*/
6+
#include "gmds/aero/CGNSWriter3D.h"
67
#include "gmds/ig/MeshDoctor.h"
78
#include "gmds/io/IGMeshIOService.h"
89
#include "gmds/io/VTKReader.h"
910
#include <fstream>
10-
#include <gmds/blocking/CGNSWriter3D.h>
1111
#include <iomanip>
1212
/*----------------------------------------------------------------------------*/
1313
using namespace gmds;
1414
/*----------------------------------------------------------------------------*/
15-
using namespace blocking;
15+
using namespace aero;
1616

1717
#define Structured CG_Structured
1818
#define RealDouble CG_RealDouble
@@ -21,7 +21,7 @@ using namespace blocking;
2121
#define Unstructured CG_Unstructured
2222
#define TRI_3 CG_TRI_3
2323
/*----------------------------------------------------------------------------*/
24-
CGNSWriter3D::CGNSWriter3D(Blocking2D *ABlocking)
24+
CGNSWriter3D::CGNSWriter3D(Blocking3D *ABlocking)
2525
:m_blocks(ABlocking),m_mesh(nullptr)
2626
{}
2727
/*----------------------------------------------------------------------------*/
@@ -182,7 +182,7 @@ void CGNSWriter3D::writeZones()
182182
idinter1 = 1;
183183
idmax1 = 2;
184184
break;
185-
case 1:
185+
case 2:
186186
pts1[0] = 1;
187187
pts1[1] = 1;
188188
pts1[2] = 1;
@@ -199,7 +199,7 @@ void CGNSWriter3D::writeZones()
199199
idinter1 = 1;
200200
idmax1 = 5;
201201
break;
202-
case 2:
202+
case 5:
203203
pts1[0] = discrI;
204204
pts1[1] = 1;
205205
pts1[2] = 1;
@@ -250,7 +250,7 @@ void CGNSWriter3D::writeZones()
250250
idinter1 = 3;
251251
idmax1 = 7;
252252
break;
253-
case 5:
253+
case 1:
254254
pts1[0] = 1; // X1
255255
pts1[1] = 1; // Y1
256256
pts1[2] = discrK; // Z1
@@ -509,7 +509,7 @@ void CGNSWriter3D::writeZones()
509509
pts_bc[4] = discrJ; // Y2
510510
pts_bc[5] = 1; // Z2
511511
break;
512-
case 1:
512+
case 2:
513513
pts_bc[0] = 1;
514514
pts_bc[1] = 1;
515515
pts_bc[2] = 1;
@@ -518,7 +518,7 @@ void CGNSWriter3D::writeZones()
518518
pts_bc[4] = 1;
519519
pts_bc[5] = discrK;
520520
break;
521-
case 2:
521+
case 5:
522522
pts_bc[0] = discrI;
523523
pts_bc[1] = 1;
524524
pts_bc[2] = 1;
@@ -545,7 +545,7 @@ void CGNSWriter3D::writeZones()
545545
pts_bc[4] = discrJ;
546546
pts_bc[5] = discrK;
547547
break;
548-
case 5:
548+
case 1:
549549
pts_bc[0] = 1; // X1
550550
pts_bc[1] = 1; // Y1
551551
pts_bc[2] = discrK; // Z1
@@ -612,7 +612,7 @@ void CGNSWriter3D::writeBoundaryCondition(int &num_bc, cgsize_t* pts, int id_zon
612612
}
613613
/*----------------------------------------------------------------------------*/
614614
void CGNSWriter3D::write(const std::string &AInFileName, const std::string &AOutFileName, const std::string &AWorkingDir){
615-
615+
/*
616616
std::cout<<"Start reading"<<std::endl;
617617
618618
gmds::IGMeshIOService ioService(m_blocks);
@@ -626,7 +626,7 @@ void CGNSWriter3D::write(const std::string &AInFileName, const std::string &AOut
626626
MeshDoctor doc(m_blocks);
627627
doc.buildFacesAndR2F();
628628
doc.buildF2R(m_blocks->getModel());
629-
629+
*/
630630
m_block_grid = m_blocks->newVariable<std::vector<TCellID>,GMDS_REGION>("block_grid");
631631

632632
VarDiscrI = m_blocks->getVariable<int,GMDS_REGION>("discrI");

aero/src/main.cpp

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/*------------------------------------------------------------------------*/
44
#ifdef USE_CGNS
55
#include <gmds/blocking/CGNSWriter.h>
6+
#include <gmds/aero/CGNSWriter3D.h>
67
#endif
78
#include <gmds/aero/AbstractAeroPipeline.h>
89
#include <gmds/aero/AeroPipeline_2D.h>
@@ -20,30 +21,46 @@ int main(int argc, char* argv[])
2021
{
2122
std::cout << "=== AERO ALGO ====" << std::endl;
2223

23-
if (argc != 4 )
24-
{
24+
if (argc != 5) {
2525
std::cout << "Merci de préciser <repertoire/de/travail> <fichier_param.ini> <fichier_sorti.cgns>" << std::endl;
2626
exit(0);
2727
}
2828

2929
std::string dir(argv[1]);
3030
std::string param_file(argv[2]);
3131
std::string output_file(argv[3]);
32+
std::string dimension(argv[4]);
3233

33-
std::string input_file=dir+param_file;
34+
std::string input_file = dir +"/"+ param_file;
3435

35-
// Mesh Generation
36-
AeroPipeline_2D algo_aero2D(input_file, dir);
37-
AbstractAeroPipeline::STATUS aero2D_result = algo_aero2D.execute();
36+
if (dimension == "2D") {
37+
// Mesh Generation
38+
// Mesh Generation
39+
AeroPipeline_2D algo_aero2D(input_file, dir);
40+
AbstractAeroPipeline::STATUS aero2D_result = algo_aero2D.execute();
3841

39-
if(aero2D_result == AbstractAeroPipeline::SUCCESS) {
42+
if (aero2D_result == AbstractAeroPipeline::SUCCESS) {
4043
#ifdef USE_CGNS
41-
blocking::CGNSWriter writer(algo_aero2D.getBlocking());
42-
writer.write(output_file, dir);
44+
blocking::CGNSWriter writer(algo_aero2D.getBlocking());
45+
writer.write(output_file, dir);
4346
#else
44-
std::cout<<"CGNS export is desactivated"<<std::endl;
47+
std::cout << "CGNS export is desactivated" << std::endl;
4548
#endif
46-
}else{
47-
std::cout<<"Erreur dans le pipeline Aero"<<std::endl;
49+
}
50+
}
51+
else if (dimension == "3D") {
52+
// Mesh Generation
53+
dir = dir + "/";
54+
AeroPipeline_3D algo_aero3D(input_file, dir);
55+
AbstractAeroPipeline::STATUS aero_result = algo_aero3D.execute();
56+
57+
if (aero_result == AbstractAeroPipeline::SUCCESS) {
58+
#ifdef USE_CGNS
59+
gmds::aero::CGNSWriter3D writer(algo_aero3D.getBlocking());
60+
writer.write("", output_file, dir);
61+
#else
62+
std::cout << "CGNS export is desactivated" << std::endl;
63+
#endif
64+
}
4865
}
4966
}

blocking/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ set(GMDS_INC
1818
if(WITH_CGNS)
1919
message(TEST)
2020
set(GMDS_INC ${GMDS_INC} inc/gmds/blocking/CGNSWriter.h
21-
inc/gmds/blocking/CGNSWriter3D.h)
21+
)
2222
endif()
2323

2424
set(GMDS_SRC
@@ -33,7 +33,7 @@ set(GMDS_SRC
3333

3434
if(WITH_CGNS)
3535
set(GMDS_SRC ${GMDS_SRC} src/CGNSWriter.cpp
36-
src/CGNSWriter3D.cpp)
36+
)
3737
endif()
3838
#==============================================================================
3939
add_library(${GMDS_LIB} ${GMDS_INC} ${GMDS_SRC})

blocking/src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// Created by calderans on 30/06/23.
33
//
4-
#include <gmds/blocking/CGNSWriter3D.h>
4+
55

66
using namespace gmds;
77
using namespace blocking;

blocking/src/main_cgns.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// Created by calderans on 30/06/23.
33
//
4-
#include <gmds/blocking/CGNSWriter3D.h>
4+
#include "../../aero/inc/gmds/aero/CGNSWriter3D.h"
55

66
using namespace gmds;
77
using namespace blocking;
@@ -18,7 +18,7 @@ int main(int argc, char** argv)
1818
std::string path(argv[2]);
1919
std::string filename(argv[3]);
2020

21-
CGNSWriter3D writer3D;
21+
gmds::aero::CGNSWriter3D writer3D;
2222
writer3D.write(param_file,filename,path);
2323

2424
}

0 commit comments

Comments
 (0)