ViennaSHE 1.3.0
Free open-source semiconductor device simulator using spherical harmonics expansions techniques.
filter.hpp
Go to the documentation of this file.
1#ifndef VIENNASHE_UTIL_FILTER_HPP
2#define VIENNASHE_UTIL_FILTER_HPP
3
4/* ============================================================================
5 Copyright (c) 2011-2022, Institute for Microelectronics,
6 Institute for Analysis and Scientific Computing,
7 TU Wien.
8
9 -----------------
10 ViennaSHE - The Vienna Spherical Harmonics Expansion Boltzmann Solver
11 -----------------
12
13 http://viennashe.sourceforge.net/
14
15 License: MIT (X11), see file LICENSE in the base directory
16=============================================================================== */
17
18#include <iostream>
19#include <sstream>
20#include <string>
21#include <stdexcept>
22
23#include "viennagrid/mesh/coboundary_iteration.hpp"
24
25#include "viennashe/forwards.h"
28
33namespace viennashe
34{
36 namespace util
37 {
38
41 {
42 template <typename T>
43 bool operator()(T const &) const { return true; }
44 };
45
48 {
49 template <typename T>
50 bool operator()(T const &) const { return false; }
51 };
52
54 template <typename DeviceType>
56 {
57 typedef typename DeviceType::mesh_type MeshType;
58
59 public:
60 typedef typename viennagrid::result_of::cell<MeshType>::type cell_type;
61
62 semiconductor_filter(DeviceType const & d) : device_(d) {}
63
64 bool operator()(cell_type const & cell) const { return viennashe::materials::is_semiconductor(device_.get_material(cell)); }
65
66 private:
67 DeviceType const & device_;
68 };
69
71 template <typename DeviceType>
73 {
74 typedef typename DeviceType::mesh_type MeshType;
75
76 public:
77 typedef typename viennagrid::result_of::vertex<MeshType>::type vertex_type;
78 typedef typename viennagrid::result_of::cell<MeshType>::type cell_type;
79
80 contact_filter(DeviceType const & d) : device_(d) {}
81
82 bool operator()(vertex_type const & v) const { return device_.has_contact_potential(v); }
83 bool operator()(cell_type const & c) const { return device_.has_contact_potential(c); }
84
85 private:
86 DeviceType const & device_;
87 };
88
90 template <typename DeviceType>
92 {
93 typedef typename DeviceType::mesh_type MeshType;
94
95 public:
96 typedef typename viennagrid::result_of::vertex<MeshType>::type vertex_type;
97 typedef typename viennagrid::result_of::cell<MeshType>::type cell_type;
98
99 no_contact_filter(DeviceType const & d) : device_(d) {}
100
101 bool operator()(vertex_type const & v) const { return !device_.has_contact_potential(v); }
102 bool operator()(cell_type const & cell) const { return !device_.has_contact_potential(cell); }
103
104 private:
105 DeviceType const & device_;
106 };
107
108
110 template <typename DeviceType>
112 {
113 typedef typename DeviceType::mesh_type MeshType;
114
115 public:
116 typedef typename viennagrid::result_of::cell<MeshType>::type cell_type;
117
118 no_contact_and_semiconductor_filter(DeviceType const & d) : device_(d) {}
119
120 bool operator()(cell_type const & cell) const
121 {
122 return !device_.has_contact_potential(cell)
123 && viennashe::materials::is_semiconductor(device_.get_material(cell));
124 }
125
126 private:
127 DeviceType const & device_;
128 };
129
130
131
132 namespace detail
133 {
134 template <long a, long b>
136 {
137 enum { value = (a < b) };
138 };
139 } // detail
140 //TODO: Think about adding this generic filter to ViennaGrid
142 template <typename DeviceType, typename ElementTagT, typename CheckerType>
144 {
145 typedef typename DeviceType::mesh_type MeshType;
146
147 public:
148 vicinity_filter(DeviceType const & d, CheckerType const & c) : device_(d), checker_(c) {}
149
150 // checks on ncell coboundary
151 template <typename NCellType>
153 bool>::type
154 operator()(NCellType const & cell) const
155 {
156 typedef typename viennagrid::result_of::const_coboundary_range<MeshType, NCellType, ElementTagT>::type VicinityContainer;
157 typedef typename viennagrid::result_of::iterator<VicinityContainer>::type VicinityIterator;
158
159 VicinityContainer vicinity(device_.mesh(), viennagrid::handle(device_.mesh(), cell));
160 for (VicinityIterator vit = vicinity.begin();
161 vit != vicinity.end();
162 ++vit)
163 {
164 if (checker_(*vit))
165 return true;
166 }
167
168 return false;
169 }
170
171 // checks on ncell boundary
172 template <typename NCellType>
173 typename viennashe::enable_if< (NCellType::tag::dim > ElementTagT::dim), //topological dimension
174 bool>::type
175 operator()(NCellType const & cell) const
176 {
177 typedef typename viennagrid::result_of::const_element_range<NCellType, ElementTagT>::type VicinityContainer;
178 typedef typename viennagrid::result_of::iterator<VicinityContainer>::type VicinityIterator;
179
180 VicinityContainer vicinity = viennagrid::elements<ElementTagT>(cell);
181 for (VicinityIterator vit = vicinity.begin();
182 vit != vicinity.end();
183 ++vit)
184 {
185 if (checker_(*vit))
186 return true;
187 }
188
189 return false;
190 }
191
192 private:
193 DeviceType const & device_;
194 CheckerType const & checker_;
195 };
196
197
199 template <typename DeviceType>
201 {
202 typedef typename DeviceType::mesh_type MeshType;
203
204 public:
205 typedef typename viennagrid::result_of::cells<MeshType>::type cell_type;
206
207 metal_filter(DeviceType const & d) : device_(d) {}
208
209 bool operator()(cell_type const & cell) const { return viennashe::materials::is_conductor(device_.get_material(cell)); }
210
211 private:
212 DeviceType const & device_;
213 };
214
216 template <typename DeviceType>
218 {
219 typedef typename DeviceType::mesh_type MeshType;
220
221 public:
222 typedef typename viennagrid::result_of::cell<MeshType>::type cell_type;
223
224 oxide_filter(DeviceType const & d) : device_(d) {}
225
226 bool operator()(cell_type const & cell) const { return viennashe::materials::is_insulator(device_.get_material(cell)); }
227
228 private:
229 DeviceType const & device_;
230 };
231
232
233
234 // feel free to add further filters here
235
236
237 } //namespace util
238} //namespace viennashe
239#endif
A simple filter to find cells and vertices which have potential boundary conditions.
Definition: filter.hpp:73
bool operator()(cell_type const &c) const
Definition: filter.hpp:83
bool operator()(vertex_type const &v) const
Definition: filter.hpp:82
contact_filter(DeviceType const &d)
Definition: filter.hpp:80
viennagrid::result_of::vertex< MeshType >::type vertex_type
Definition: filter.hpp:77
viennagrid::result_of::cell< MeshType >::type cell_type
Definition: filter.hpp:78
A filter accepting metal cells only.
Definition: filter.hpp:201
bool operator()(cell_type const &cell) const
Definition: filter.hpp:209
metal_filter(DeviceType const &d)
Definition: filter.hpp:207
viennagrid::result_of::cells< MeshType >::type cell_type
Definition: filter.hpp:205
A filter used to filter cells, which are neither semiconductors (by material) nor contacts (by potent...
Definition: filter.hpp:112
bool operator()(cell_type const &cell) const
Definition: filter.hpp:120
viennagrid::result_of::cell< MeshType >::type cell_type
Definition: filter.hpp:116
The inverse filter to the contact_filter.
Definition: filter.hpp:92
viennagrid::result_of::vertex< MeshType >::type vertex_type
Definition: filter.hpp:96
no_contact_filter(DeviceType const &d)
Definition: filter.hpp:99
bool operator()(cell_type const &cell) const
Definition: filter.hpp:102
viennagrid::result_of::cell< MeshType >::type cell_type
Definition: filter.hpp:97
bool operator()(vertex_type const &v) const
Definition: filter.hpp:101
A filter accepting oxide cells only.
Definition: filter.hpp:218
viennagrid::result_of::cell< MeshType >::type cell_type
Definition: filter.hpp:222
bool operator()(cell_type const &cell) const
Definition: filter.hpp:226
oxide_filter(DeviceType const &d)
Definition: filter.hpp:224
A filter accepting semiconductor cells only.
Definition: filter.hpp:56
semiconductor_filter(DeviceType const &d)
Definition: filter.hpp:62
bool operator()(cell_type const &cell) const
Definition: filter.hpp:64
viennagrid::result_of::cell< MeshType >::type cell_type
Definition: filter.hpp:60
A filter returning true if any of the neighboring ncells of dimension 'dim' evaluate to true.
Definition: filter.hpp:144
viennashe::enable_if< detail::is_lesser< NCellType::tag::dim, ElementTagT::dim >::value, bool >::type operator()(NCellType const &cell) const
Definition: filter.hpp:154
vicinity_filter(DeviceType const &d, CheckerType const &c)
Definition: filter.hpp:148
Simple enable-if variant that uses the SFINAE pattern.
Contains forward declarations and definition of small classes that must be defined at an early stage.
A very simple material database. Needs to be replaced by something more versatile soon.
bool is_semiconductor(long material_id)
Convenience function for checking whether the supplied material ID refers to a semiconductor.
Definition: all.hpp:156
bool is_insulator(long material_id)
Convenience function for checking whether the supplied material ID refers to an oxide.
Definition: all.hpp:165
bool is_conductor(long material_id)
Convenience function for checking whether the supplied material ID refers to a metal.
Definition: all.hpp:147
The main ViennaSHE namespace. All functionality resides inside this namespace.
Definition: accessors.hpp:40
Simple enable-if variant that uses the SFINAE pattern.
Definition: enable_if.hpp:27
A trivial filter, all objects are accepted.
Definition: filter.hpp:41
bool operator()(T const &) const
Definition: filter.hpp:43
A trivial filter, no objects shall be accepted.
Definition: filter.hpp:48
bool operator()(T const &) const
Definition: filter.hpp:50