convert_geom_file.cc File Reference
#include <iostream>
#include <fstream>
#include <vector>
#include <math.h>

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int argc  ,
char argv[] 
)
37  {
38 
39  // Convert argument to strings that specify the input file name
40  string mesh_file_name(argv[1]);
41 
42 // Read the output mesh file to find informations about the nodes
43 // and elements of the mesh
44 
45 ifstream infile(mesh_file_name.c_str(), ios_base::in);
46 unsigned n_node;
47 infile>>n_node;
48 vector<double> x(n_node);
49 vector<double> y(n_node);
50 vector<int> vertinfo(n_node);
51  for(unsigned i=0;i<n_node;i++)
52  {
53  infile>>x[i];
54  infile>>y[i];
55  infile>>vertinfo[i];
56  }
57 unsigned n_vx;
58 infile>>n_vx;
59 vector<int> nodecode(n_vx);
60 vector<int> icurv(n_vx);
61 vector<double> ucurv(n_vx);
62  for(unsigned i=0;i<n_vx;i++)
63  {
64  infile>>nodecode[i];
65  infile>>icurv[i];
66  infile>>ucurv[i];
67  }
68 unsigned n_local_node;
69 infile>>n_local_node;
70 unsigned n_element;
71 infile>>n_element;
72 unsigned b=n_local_node*n_element;
73 vector<int> v(b);
74 vector<int> edgeinfo(b);
75 unsigned k=0;
76 for(unsigned i=0;i<n_element;i++)
77  {
78  for(unsigned j=0;j<n_local_node;j++)
79  {
80  infile>>v[k];
81  k++;
82  }
83  }
84 unsigned l=0;
85 for(unsigned i=0;i<n_element;i++)
86  {
87  for(unsigned j=0;j<n_local_node;j++)
88  {
89  infile>>edgeinfo[l];
90  l++;
91  }
92  }
93 
94 infile.close();
95 
96 // Create a file of type ".quad" to visualize the mesh with geomview
97 
98 
99  unsigned nn=0;
100  char result[20];
101  sprintf(result,"%s","mesh.quad");
102  ofstream outfile(result,ios_base::out);
103  outfile<<"QUAD"<<'\n';
104  for(unsigned i=0;i<n_element;i++)
105  {
106  for(unsigned j=0;j<n_local_node;j++)
107  {
108  outfile<<x[v[nn]-1]<<" "<<y[v[nn]-1]<<" 0 ";
109  nn++;
110  }
111  outfile<<'\n';
112  }
113  outfile.close();
114 
115 
116 
117 } //end of main
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Scalar * b
Definition: benchVecAdd.cpp:17
Scalar * y
Definition: level1_cplx_impl.h:128
char char char int int * k
Definition: level2_impl.h:374
list x
Definition: plotDoE.py:28
std::ofstream out("Result.txt")
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References b, i, j, k, out(), v, plotDoE::x, and y.