cppyabm  1.0.17
An agent-based library to integrate C++ and Python
main.cpp
Go to the documentation of this file.
1 #ifdef DEALII
2 #include <deal.II/grid/tria.h>
3 #include <deal.II/grid/tria_accessor.h>
4 #include <deal.II/grid/tria_iterator.h>
5 #include <deal.II/grid/grid_generator.h>
6 #include <deal.II/grid/grid_out.h>
7 #include <deal.II/grid/grid_in.h>
8 #include <iostream>
9 #include <fstream>
10 #include <cmath>
11 using namespace dealii;
12 using namespace std;
13 
14 void _dealii() {
15  auto first_grid = [&]() {
16  Triangulation<2> tria;
17  GridGenerator::hyper_cube(tria);
18  tria.refine_global(4); // a cube with an area and patch size
19  for (auto& cell : tria.active_cell_iterators()) {
20  cout << cell->index() << endl;
21  }
22  map<unsigned, double> inputs;
23 
24  map<unsigned, double> outputs;
25 
26  };
27 
28  auto second_grid = [&]() {
29  Triangulation<2> tria;
30  ifstream file("grid-1.vtk");
31  GridIn<2, 2> grid;
32  grid.attach_triangulation(tria);
33  grid.read_vtk(file);
34  for (auto& cell : tria.active_cell_iterators()) {
35  cout << cell->index() << endl;
36  }
37  cout << tria.n_active_cells() << endl;
38  };
39  first_grid();
40  //second_grid();
41 }
42 
43 
44 #endif //dealii
45 #ifdef VTK
46 #include <vtkGenericDataObjectReader.h>
47 #include <vtkStructuredGrid.h>
48 #include <vtkSmartPointer.h>
49 #include <vtkPolyData.h>
50 #include <string>
51 void _vtk()
52 {
53  cout << "insde vtk" << endl;
54  // simply set filename here (oh static joy)
55  std::string inputFilename = "setYourPathToVtkFileHere";
56 
57  // Get all data from the file
58  vtkSmartPointer<vtkGenericDataObjectReader> reader =
59  vtkSmartPointer<vtkGenericDataObjectReader>::New();
60  reader->SetFileName(inputFilename.c_str());
61  reader->Update();
62 
63  // All of the standard data types can be checked and obtained like this:
64  if (reader->IsFilePolyData())
65  {
66  std::cout << "output is a polydata" << std::endl;
67  vtkPolyData* output = reader->GetPolyDataOutput();
68  std::cout << "output has " << output->GetNumberOfPoints() << " points." << std::endl;
69  }
70 
71 
72 }
73 #endif //vtk
74 
75 
76 int main()
77 {
78 #ifdef DEALII
79  _dealii();
80 #endif //DEALII
81 #ifdef VTK
82  _vtk();
83 #endif //vtk
84 
85 
86 }
87 
88 
main
int main()
Definition: main.cpp:76
script.file
file
Definition: script.py:191