ViennaSHE 1.3.0
Free open-source semiconductor device simulator using spherical harmonics expansions techniques.
dump_device_mesh.hpp
Go to the documentation of this file.
1#ifndef VIENNASHE_UTIL_DUMP_DEVICE_MESH_HPP
2#define VIENNASHE_UTIL_DUMP_DEVICE_MESH_HPP
3/* ============================================================================
4 Copyright (c) 2011-2022, Institute for Microelectronics,
5 Institute for Analysis and Scientific Computing,
6 TU Wien.
7
8 -----------------
9 ViennaSHE - The Vienna Spherical Harmonics Expansion Boltzmann Solver
10 -----------------
11
12 http://viennashe.sourceforge.net/
13
14 License: MIT (X11), see file LICENSE in the base directory
15=============================================================================== */
16
17#include "viennashe/forwards.h"
18#include "viennashe/device.hpp"
19
20#include "viennagrid/forwards.hpp"
21
22namespace viennashe
23{
24 namespace util
25 {
26
27 template < typename DeviceT, typename IndexT >
28 void dump_mesh(DeviceT const & device, double ** vertices, IndexT & num_vertices,
29 IndexT ** cells, IndexT & num_cells
30 )
31 {
32 typedef typename DeviceT::mesh_type MeshType;
33 typedef typename viennagrid::result_of::point<MeshType>::type PointType;
34 typedef typename viennagrid::result_of::cell<MeshType>::type CellType;
35
36 typedef typename viennagrid::result_of::const_vertex_range<MeshType>::type VertexContainer;
37 typedef typename viennagrid::result_of::const_cell_range<MeshType>::type CellContainer;
38
39 typedef typename viennagrid::result_of::const_vertex_range<CellType>::type VertexOnCellContainer;
40 typedef typename viennagrid::result_of::iterator<VertexOnCellContainer>::type VertexOnCellIterator;
41
42 if (vertices == 0) throw std::invalid_argument("vertices = NULL !");
43 if (cells == 0) throw std::invalid_argument("cells = NULL !");
44
45 VertexContainer grid_vertices(device.mesh());
46 CellContainer grid_cells(device.mesh());
47 const size_t dim = PointType::dim;
48
49 // Dump sizes
50 num_vertices = static_cast<IndexT>(grid_vertices.size());
51 num_cells = static_cast<IndexT>(grid_cells.size());
52
53 // Dump vertices (iterate the C-way to have the indices)
54 for (std::size_t i = 0; i < grid_vertices.size(); ++i)
55 {
56 for (std::size_t j = 0; j < dim; ++j) vertices[i][j] = viennagrid::point(grid_vertices[i])[j];
57 }
58
59 // Dump cells (iterate the C-way to have the indices)
60 for (std::size_t i = 0; i < grid_cells.size(); ++i)
61 {
62 VertexOnCellContainer vertices_on_cell(grid_cells[i]);
63 std::size_t j = 0;
64 for (VertexOnCellIterator vit = vertices_on_cell.begin(); vit != vertices_on_cell.end(); ++vit, ++j)
65 {
66 cells[i][j] = static_cast<IndexT>(vit->id().get());
67 }
68 }
69
70 } // dump_mesh
71
72 }
73} // namespace viennashe
74
75
76#endif /* VIENNASHE_UTIL_DUMP_DEVICE_MESH_HPP */
77
MeshT const & mesh() const
Returns the underlying mesh.
Definition: device.hpp:145
Defines the physical properties of a device, e.g. doping. This is the implementation for 2d and highe...
Definition: device.hpp:818
Contains the definition of a device class independent of the actual macroscopic model to be solved.
Contains forward declarations and definition of small classes that must be defined at an early stage.
void dump_mesh(DeviceT const &device, double **vertices, IndexT &num_vertices, IndexT **cells, IndexT &num_cells)
The main ViennaSHE namespace. All functionality resides inside this namespace.
Definition: accessors.hpp:40