iocgns_example_00002.cpp
1 /*---------------------------------------------------------------------------*\
2  *
3  * mimmo
4  *
5  * Copyright (C) 2015-2021 OPTIMAD engineering Srl
6  *
7  * -------------------------------------------------------------------------
8  * License
9  * This file is part of mimmo.
10  *
11  * mimmo is free software: you can redistribute it and/or modify it
12  * under the terms of the GNU Lesser General Public License v3 (LGPL)
13  * as published by the Free Software Foundation.
14  *
15  * mimmo is distributed in the hope that it will be useful, but WITHOUT
16  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18  * License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with mimmo. If not, see <http://www.gnu.org/licenses/>.
22  *
23  \ *---------------------------------------------------------------------------*/
24 #include <mimmo_iocgns.hpp>
25 #include <mimmo_utils.hpp>
26 #if MIMMO_ENABLE_MPI
27  #include <mimmo_parallel.hpp>
28 #endif
29 
45 // =================================================================================== //
46 
47 void example00002() {
48 
49  /*
50  Create IOCGNS object to import the cgns mesh.
51  Bulk volume and relative boundary mesh will be exposed
52  */
53  mimmo::IOCGNS * cgnsI = new mimmo::IOCGNS(mimmo::IOCGNS::IOCGNS_Mode::READ);
54  cgnsI->setDir("geodata");
55  cgnsI->setFilename("grid");
56 
57 #if MIMMO_ENABLE_MPI
58  /*
59  Distribute bulk/boundary meshes among processes
60  */
61  mimmo::Partition *partition = new mimmo::Partition();
62  partition->setPartitionMethod(mimmo::PartitionMethod::PARTGEOM);
63  partition->setPlotInExecution(true);
64 #endif
65 
66  /*
67  Check the status of the mesh elements: min/max volume, skewness
68  skewness of the boundary cell elements etc...
69  */
70  mimmo::MeshChecker* checkmesh = new mimmo::MeshChecker();
71  checkmesh->setPlotInExecution(true);
72  checkmesh->setMinimumVolumeTolerance(1.0E-1);
73  checkmesh->setMaximumVolumeTolerance(1.0E9);
74  checkmesh->setMaximumSkewnessTolerance(80.0);
75  checkmesh->setMaximumBoundarySkewnessTolerance(90.0);
76  checkmesh->setMinimumFaceValidityTolerance(0.2);
77  checkmesh->setMinimumVolumeChangeTolerance(5.0E-2);
78 
79  /* Create block connections. */
80 #if MIMMO_ENABLE_MPI
81  mimmo::pin::addPin(cgnsI, partition, M_GEOM, M_GEOM) ;
82  mimmo::pin::addPin(cgnsI, partition, M_GEOM2, M_GEOM2) ;
83  mimmo::pin::addPin(partition, checkmesh, M_GEOM, M_GEOM);
84 #else
85  mimmo::pin::addPin(cgnsI, checkmesh, M_GEOM, M_GEOM) ;
86 #endif
87 
88  /* Create and execute chain. */
89  mimmo::Chain ch0;
90  ch0.addObject(cgnsI);
91 #if MIMMO_ENABLE_MPI
92  ch0.addObject(partition);
93 #endif
94  ch0.addObject(checkmesh);
95 
96  ch0.exec(true);
97 
98  /* Destroy objects. */
99  delete cgnsI;
100 #if MIMMO_ENABLE_MPI
101  delete partition;
102 #endif
103  delete checkmesh;
104 
105  return;
106 }
107 
108 // =================================================================================== //
109 
110 int main( int argc, char *argv[] ) {
111 
112  BITPIT_UNUSED(argc);
113  BITPIT_UNUSED(argv);
114 
115 #if MIMMO_ENABLE_MPI
116  MPI_Init(&argc, &argv);
117 
118  {
119 #endif
120  try{
122  example00002();
123  }
124  catch(std::exception & e){
125  std::cout<<"iocgns_example_00002 exited with an error of type : "<<e.what()<<std::endl;
126  return 1;
127  }
128 #if MIMMO_ENABLE_MPI
129  }
130 
131  MPI_Finalize();
132 #endif
133 
134  return 0;
135 }
void exec(bool debug=false)
Definition: Chain.cpp:284
void setMinimumFaceValidityTolerance(double tol)
Chain is the class used to manage the chain execution of multiple executable blocks (manipulation obj...
Definition: Chain.hpp:48
#define M_GEOM
void setMaximumVolumeTolerance(double tol)
void setMaximumBoundarySkewnessTolerance(double tol)
void setMinimumVolumeChangeTolerance(double tol)
#define M_GEOM2
MeshChecker is the class to evaluate the quality of a volume mesh.
Definition: MeshChecker.hpp:87
void setMaximumSkewnessTolerance(double tol)
bool addPin(BaseManipulation *objSend, BaseManipulation *objRec, PortID portS, PortID portR, bool forced)
void setMinimumVolumeTolerance(double tol)
int addObject(BaseManipulation *obj, int id_=-1)
Definition: Chain.cpp:170