1#ifndef VIENNASHE_SHE_EXPANSION_ORDER_HPP
2#define VIENNASHE_SHE_EXPANSION_ORDER_HPP
22#include "viennagrid/element/element.hpp"
23#include "viennagrid/mesh/mesh.hpp"
24#include "viennagrid/mesh/coboundary_iteration.hpp"
59 template <
typename DeviceType,
typename SHEQuantity>
62 typedef typename DeviceType::mesh_type MeshType;
64 typedef typename viennagrid::result_of::cell<MeshType>::type CellType;
66 typedef typename viennagrid::result_of::const_cell_range<MeshType>::type CellContainer;
67 typedef typename viennagrid::result_of::iterator<CellContainer>::type CellIterator;
69 typedef typename viennagrid::result_of::const_facet_range<CellType>::type FacetOnCellContainer;
70 typedef typename viennagrid::result_of::iterator<FacetOnCellContainer>::type FacetOnCellIterator;
74 CellContainer cells(mesh);
75 for (CellIterator cit = cells.begin();
80 for (std::size_t index_H = 1; index_H < quan.get_value_H_size() - 1; ++index_H)
82 if (quan.get_kinetic_energy(*cit, index_H) <= 0)
84 quan.set_expansion_order(*cit, index_H, 1);
93 bool all_neighbors_have_positive_kinetic_energy =
true;
95 FacetOnCellContainer facets_on_cell(*cit);
96 for (FacetOnCellIterator focit = facets_on_cell.begin();
97 focit != facets_on_cell.end();
104 if (quan.get_kinetic_energy(*other_cell, index_H-1) <= 0)
105 all_neighbors_have_positive_kinetic_energy =
false;
109 if (all_neighbors_have_positive_kinetic_energy)
114 quan.set_expansion_order(*cit, index_H, 1);
116 for (FacetOnCellIterator focit = facets_on_cell.begin();
117 focit != facets_on_cell.end();
124 quan.set_expansion_order(*other_cell, index_H, 1);
138 template <
typename DeviceType,
139 typename SHEQuantity>
143 typedef typename DeviceType::mesh_type MeshType;
145 typedef typename viennagrid::result_of::cell<MeshType>::type CellType;
146 typedef typename viennagrid::result_of::facet<MeshType>::type FacetType;
148 typedef typename viennagrid::result_of::const_facet_range<MeshType>::type FacetContainer;
149 typedef typename viennagrid::result_of::iterator<FacetContainer>::type FacetIterator;
151 typedef typename viennagrid::result_of::const_coboundary_range<MeshType, FacetType, CellType>::type CellOnFacetContainer;
152 typedef typename viennagrid::result_of::iterator<CellOnFacetContainer>::type CellOnFacetIterator;
160 for (
long i=0; i<10; ++i)
163 bool something_changed =
false;
165 FacetContainer facets(mesh);
166 for (FacetIterator fit = facets.begin();
170 CellOnFacetContainer cells_on_facet(
device.
mesh(), viennagrid::handle(
device.
mesh(), fit.handle()));
172 CellOnFacetIterator cofit = cells_on_facet.begin();
173 CellType
const & c1 = *cofit;
176 if (cofit == cells_on_facet.end())
179 CellType
const *c2_ptr = &(*cofit);
181 for (
size_t index_H = 0; index_H < quan.get_value_H_size(); ++index_H)
183 if ( quan.get_expansion_order(c1, index_H) > quan.get_expansion_order(*c2_ptr, index_H) + 2)
185 something_changed =
true;
186 quan.set_expansion_order(c1, index_H, quan.get_expansion_order(*c2_ptr, index_H) + 2);
188 if ( quan.get_expansion_order(*c2_ptr, index_H) > quan.get_expansion_order(*c2_ptr, index_H) + 2)
190 something_changed =
true;
191 quan.set_expansion_order(*c2_ptr, index_H, quan.get_expansion_order(*c2_ptr, index_H) + 2);
196 if (!something_changed)
206 template <
typename DeviceType,
207 typename SHEQuantity>
211 typedef typename DeviceType::mesh_type MeshType;
213 typedef typename viennagrid::result_of::cell<MeshType>::type CellType;
214 typedef typename viennagrid::result_of::facet<MeshType>::type FacetType;
216 typedef typename viennagrid::result_of::const_facet_range<MeshType>::type FacetContainer;
217 typedef typename viennagrid::result_of::iterator<FacetContainer>::type FacetIterator;
219 typedef typename viennagrid::result_of::const_coboundary_range<MeshType, FacetType, CellType>::type CellOnFacetContainer;
220 typedef typename viennagrid::result_of::iterator<CellOnFacetContainer>::type CellOnFacetIterator;
224 FacetContainer facets(mesh);
225 for (FacetIterator fit = facets.begin();
229 CellOnFacetContainer cells_on_facet(
device.
mesh(), viennagrid::handle(
device.
mesh(), fit.handle()));
231 CellOnFacetIterator cofit = cells_on_facet.begin();
232 CellType
const & c1 = *cofit;
234 CellType
const *c2_ptr = NULL;
236 if (cofit != cells_on_facet.end())
239 for (
size_t index_H = 0; index_H < quan.get_value_H_size(); ++index_H)
241 std::size_t order = quan.get_expansion_order(c1, index_H);
244 order = std::max<std::size_t>(order, quan.get_expansion_order(*c2_ptr, index_H));
245 quan.set_expansion_order(*fit, index_H, order);
261 template <
typename DeviceType,
typename VertexT,
typename EdgeT>
266 typedef typename DeviceType::mesh_type MeshType;
268 typedef typename viennagrid::result_of::cell<MeshType>::type CellType;
269 typedef typename viennagrid::result_of::facet<MeshType>::type FacetType;
271 typedef typename viennagrid::result_of::const_facet_range<MeshType>::type FacetContainer;
272 typedef typename viennagrid::result_of::iterator<FacetContainer>::type FacetIterator;
274 typedef typename viennagrid::result_of::const_cell_range<MeshType>::type CellContainer;
275 typedef typename viennagrid::result_of::iterator<CellContainer>::type CellIterator;
277 typedef typename viennagrid::result_of::const_coboundary_range<MeshType, FacetType, CellType>::type CellOnFacetContainer;
278 typedef typename viennagrid::result_of::iterator<CellOnFacetContainer>::type CellOnFacetIterator;
287 CellContainer cells(mesh);
288 for (CellIterator cit = cells.begin();
303 FacetContainer facets(mesh);
304 for (FacetIterator fit = facets.begin();
308 CellOnFacetContainer cells_on_facet(
device.
mesh(), viennagrid::handle(
device.
mesh(), fit.handle()));
310 CellOnFacetIterator cofit = cells_on_facet.begin();
311 CellType
const & c1 = *cofit;
313 CellType
const *c2_ptr = NULL;
315 if (cofit != cells_on_facet.end())
347 template <
typename DeviceType,
348 typename VertexT,
typename EdgeT>
366 template <
typename DeviceType>
Common routines for the assembly of SHE equations.
The main SHE configuration class. To be adjusted by the user for his/her needs.
long max_expansion_order() const
Returns the current maximum expansion order.
equation_id get_electron_equation() const
bool with_holes() const
Returns true if holes are considered in the simulation.
equation_id get_hole_equation() const
bool adaptive_expansions() const
Returns the flag for the use of adaptive expansions.
bool with_electrons() const
Returns true if electrons are considered in the simulation.
MeshT const & mesh() const
Returns the underlying mesh.
Defines the physical properties of a device, e.g. doping. This is the implementation for 2d and highe...
The main SHE simulator controller class. Acts as an accessor for all SHE quantities needed for the si...
UnknownSHEQuantityType const & electron_distribution_function() const
UnknownSHEQuantityType const & hole_distribution_function() const
General representation of any solver quantity defined on two different element types (e....
std::size_t get_expansion_order(AssociatedT1 const &elem, std::size_t index_H) const
std::size_t get_value_H_size() const
void set_expansion_order(AssociatedT1 const &elem, std::size_t index_H, std::size_t value)
The SHE configuration class is defined here.
Defines several filter functors for the device. A filter functor returns true if the supplied argumen...
Contains forward declarations and definition of small classes that must be defined at an early stage.
A logging facility providing fine-grained control over logging in ViennaSHE.
A very simple material database. Needs to be replaced by something more versatile soon.
void distribute_expansion_orders_impl(DeviceType const &device, viennashe::she::unknown_she_quantity< VertexT, EdgeT > &quan, viennashe::config const &conf)
Assigns the various expansion orders to the device. This is the implementation.
void smooth_expansion_order(DeviceType const &device, SHEQuantity &quan)
Smoothes the expansion order over the device such that neighboring vertices differ in their expansion...
void lower_expansion_order_near_bandedge(DeviceType const &device, SHEQuantity &quan)
Assigns the various expansion orders to the device. Uniform expansion order implemented here.
void distribute_expansion_orders(DeviceType &device, viennashe::she::unknown_she_quantity< VertexT, EdgeT > &quan, viennashe::config const &conf)
Assigns the various expansion orders to the device. This is the public interface.
void write_expansion_order_to_facets(DeviceType &device, SHEQuantity &quan)
Writes expansion orders on edges. Edge expansion order is given as max(order(v1), order(v2)),...
CellT const * get_other_cell_of_facet(MeshT const &mesh, FacetT const &facet, CellT const &cell)
Helper function returning a const-pointer to the 'second cell' of a facet, or NULL if there is no sec...
The main ViennaSHE namespace. All functionality resides inside this namespace.
Provides a number of fundamental constants. All constants in SI units.
Provides the exceptions used inside the viennashe::she namespace.
Defines a SHE quantity in (x, H)-space for use within the solvers of ViennaSHE.
Defines a generic simulator quantity for use within the solvers of ViennaSHE.
A container of all quantities defined for a certain timestep t.
Defines the log keys used within the viennashe::she namespace.