1#ifndef VIENNASHE_UTIL_POSTPROC_ELECTRIC_FLUX_DENSITY_HPP
2#define VIENNASHE_UTIL_POSTPROC_ELECTRIC_FLUX_DENSITY_HPP
25#include "viennagrid/mesh/mesh.hpp"
26#include "viennagrid/algorithm/volume.hpp"
27#include "viennagrid/algorithm/inner_prod.hpp"
52 template <
typename DeviceType,
typename PotentialAccessorType >
55 typedef typename DeviceType::mesh_type
MeshType;
57 typedef typename viennagrid::result_of::facet<MeshType>::type
FacetType;
58 typedef typename viennagrid::result_of::cell<MeshType>::type
CellType;
62 template <
typename FacetType>
65 typedef typename viennagrid::result_of::const_coboundary_range<MeshType, FacetType, CellType>::type CellOnFacetContainer;
66 typedef typename viennagrid::result_of::iterator<CellOnFacetContainer>::type CellOnFacetIterator;
67 typedef typename viennagrid::result_of::point<MeshType>::type PointType;
69 CellOnFacetContainer cells_on_facet(device_.mesh(), viennagrid::handle(device_.mesh(), facet));
71 if (cells_on_facet.size() < 2)
74 CellOnFacetIterator cofit = cells_on_facet.begin();
82 const double potential_center = potential_.get_value(c1);
83 const double potential_outer = potential_.get_value(c2);
85 PointType centroid_other_cell = viennagrid::centroid(c2);
86 PointType centroid_cell = viennagrid::centroid(c1);
87 PointType cell_connection = centroid_other_cell - centroid_cell;
94 PointType facet_center = viennagrid::centroid(facet);
95 double connection_in_cell = viennagrid::norm(facet_center - centroid_cell);
96 double connection_in_other_cell = viennagrid::norm(facet_center - centroid_other_cell);
97 const double permittivity_mean = (connection_in_cell + connection_in_other_cell) /
100 const double Emag = -(potential_outer - potential_center) / connection_len;
102 return Emag * permittivity_mean;
106 DeviceType
const & device_;
107 PotentialAccessorType
const & potential_;
118 template <
typename DeviceType,
typename PotentialAccessorType >
122 typedef typename DeviceType::mesh_type MeshType;
123 typedef typename MeshType::config_type ConfigType;
125 typedef typename viennagrid::result_of::point<MeshType>::type PointType;
128 typedef typename viennagrid::result_of::facet<MeshType>::type
FacetType;
129 typedef typename viennagrid::result_of::cell<MeshType>::type
CellType;
141 return facet_eval(facet);
147 typedef typename viennagrid::result_of::const_facet_range<CellType>::type FacetOnCellContainer;
152 std::vector<double> E(3);
154 if (!no_conductor_filter(device_.get_material(cell)))
return E;
158 FieldOnFacetEvaluator facet_evaluator(device_, potential_);
160 FacetOnCellContainer facets_on_cell(cell);
162 cell, facets_on_cell,
163 result, facet_evaluator);
168 DeviceType
const & device_;
169 PotentialAccessorType
const & potential_;
Defines a set of checker functors for micro-tests within ViennaSHE.
Defines the physical properties of a device, e.g. doping. This is the implementation for 2d and highe...
Simple checker class for checking whether a certain material is of a given type (conductor,...
Accessor for obtaining the permittivity in the device.
A functor which holds a single value. Used in most of the postprocessing routines.
Helper routines for projecting normal components of a vector-valued quantity defined on edges to vert...
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.
double permittivity(long material_id)
Convenience function for returning the permittivity of the material identified by the ID provided.
VectorType::value_type norm_2(VectorType const &v)
void dual_box_flux_to_cell(DeviceT const &device, CellT const &cell, FacetContainerT const &facets, CellSetterT &cell_setter, FacetAccessorT const &facet_access)
Interpolates normal components of the flux defined on each facet to cells. Mostly used for visualizat...
The main ViennaSHE namespace. All functionality resides inside this namespace.
@ MATERIAL_NO_CONDUCTOR_ID
Provides a number of fundamental constants. All constants in SI units.
Returns a few helper routines for computing physical quantities. To be replaced in the future.
Simple accessor to get the electric flux density along an edge.
viennagrid::result_of::cell< MeshType >::type CellType
electric_flux_on_facet(DeviceType const &device, PotentialAccessorType const &potential)
DeviceType::mesh_type MeshType
viennagrid::result_of::facet< MeshType >::type FacetType
double operator()(FacetType const &facet) const
An electric flux accessor. Provides the electric flux along edges and on vertices given the electrost...
double operator()(FacetType const &facet) const
viennagrid::result_of::cell< MeshType >::type CellType
value_type operator()(CellType const &cell) const
viennagrid::result_of::facet< MeshType >::type FacetType
electric_flux_wrapper(DeviceType const &device, PotentialAccessorType const &potential)
std::vector< double > value_type