1#ifndef VIENNASHE_SIMULATOR_QUANTITY_HPP
2#define VIENNASHE_SIMULATOR_QUANTITY_HPP
26#include "viennagrid/mesh/mesh.hpp"
36 inline std::string
potential() {
return "Electrostatic potential"; }
50 template<
typename AssociatedT,
typename ValueT =
double>
61 std::size_t num_values,
64 values_(num_values, default_value) {}
67 std::vector<ValueT>
const & values_array)
69 values_(values_array) {}
78 std::string
name()
const {
return name_; }
82 std::vector<ValueT> values_;
85 template<
typename AssociatedT,
typename ValueT =
double>
95 std::size_t num_values,
97 : name_(quan_name), values_(num_values, default_value) {}
100 std::vector<ValueT>
const & values_array)
101 : name_(quan_name), values_(values_array) {}
112 std::string
name()
const {
return name_; }
116 std::vector<ValueT> values_;
119 template <
typename ValueT =
double>
126 template<
typename AssociatedT,
typename ValueT =
double>
129 std::size_t get_id(AssociatedT
const & elem)
const {
return static_cast<std::size_t
>(elem.id().get()); }
142 std::size_t num_values,
145 equation_(quan_equation),
146 values_ (num_values, default_value),
148 boundary_values_ (num_values, default_value),
149 boundary_values_alpha_ (num_values, 0),
150 defined_but_unknown_mask_(num_values, false),
151 unknowns_indices_ (num_values, -1),
157 equation_(o.equation_),
159 boundary_types_ (o.boundary_types_),
160 boundary_values_ (o.boundary_values_),
161 boundary_values_alpha_ (o.boundary_values_alpha_),
162 defined_but_unknown_mask_(o.defined_but_unknown_mask_),
163 unknowns_indices_ (o.unknowns_indices_),
164 log_damping_ (o.log_damping_)
170 equation_ = o.equation_;
172 boundary_types_ = o.boundary_types_;
173 boundary_values_ = o.boundary_values_;
174 boundary_values_alpha_ = o.boundary_values_alpha_;
175 defined_but_unknown_mask_= o.defined_but_unknown_mask_;
176 unknowns_indices_ = o.unknowns_indices_;
177 log_damping_ = o.log_damping_;
204 ret.
alpha = boundary_values_alpha_.at(get_id(elem));
205 ret.
beta = boundary_values_.at(get_id(elem));
215 boundary_values_.at(get_id(elem)) =
values.beta;
216 boundary_values_alpha_.at(get_id(elem)) =
values.alpha;
231 for (std::size_t i=0; i<unknowns_indices_.size(); ++i)
233 if (unknowns_indices_[i] >= 0)
240 std::vector<ValueT>
const &
values()
const {
return values_; }
241 std::vector<boundary_type_id>
const &
boundary_types()
const {
return boundary_types_; }
253 std::vector<ValueT> values_;
254 std::vector<boundary_type_id> boundary_types_;
255 std::vector<ValueT> boundary_values_;
256 std::vector<ValueT> boundary_values_alpha_;
257 std::vector<bool> defined_but_unknown_mask_;
258 std::vector<long> unknowns_indices_;
Common representation of any quantity associated with objects of a certain type.
AssociatedT associated_type
ValueT operator()(associated_type const &elem) const
const_quantity(std::string quan_name, std::size_t num_values, value_type default_value=value_type())
const_quantity(self_type const &o)
ValueT at(associated_type const &elem) const
void operator=(self_type const &o)
ValueT get_value(associated_type const &elem) const
const_quantity< AssociatedT, ValueT > self_type
const_quantity(std::string quan_name, std::vector< ValueT > const &values_array)
associated_type access_type
non_const_quantity(std::string quan_name, std::size_t num_values, value_type default_value=value_type())
ValueT operator()(associated_type const &elem) const
non_const_quantity(std::string quan_name, std::vector< ValueT > const &values_array)
non_const_quantity(self_type const &o)
ValueT at(associated_type const &elem) const
non_const_quantity< AssociatedT, ValueT > self_type
AssociatedT associated_type
void operator=(self_type const &o)
void set_value(associated_type const &elem, ValueT value)
ValueT get_value(associated_type const &elem) const
equation_id get_equation() const
std::string get_name() const
unknown_quantity< AssociatedT, ValueT > self_type
std::vector< long > const & unknowns_indices() const
std::vector< bool > const & defined_but_unknown_mask() const
void set_boundary_value(associated_type const &elem, robin_boundary_type const &values)
Setter function for Robin boundary conditions.
unknown_quantity(self_type const &o)
ValueT at(associated_type const &elem) const
bool get_unknown_mask(associated_type const &elem) const
void set_logarithmic_damping(bool b)
ValueT get_value(associated_type const &elem) const
void set_boundary_value(associated_type const &elem, ValueT value)
robin_boundary_coefficients< ValueT > robin_boundary_type
void set_value(associated_type const &elem, robin_boundary_type value)
std::vector< ValueT > const & values() const
bool get_logarithmic_damping() const
ValueT get_boundary_value(associated_type const &elem) const
std::vector< boundary_type_id > const & boundary_types() const
ValueT operator()(associated_type const &elem) const
long get_unknown_index(associated_type const &elem) const
std::size_t get_unknown_num() const
std::vector< ValueT > const & boundary_values() const
robin_boundary_type get_boundary_values(associated_type const &elem) const
Returns the coefficients alpha and beta for the Robin boundary condition du/dn = beta - alpha u.
boundary_type_id get_boundary_type(associated_type const &elem) const
void set_boundary_type(associated_type const &elem, boundary_type_id value)
unknown_quantity(std::string const &quan_name, equation_id quan_equation, std::size_t num_values, value_type default_value=value_type())
void operator=(self_type const &o)
AssociatedT associated_type
void set_unknown_mask(associated_type const &elem, bool value)
void set_value(associated_type const &elem, ValueT value)
void set_unknown_index(associated_type const &elem, long value)
Contains forward declarations and definition of small classes that must be defined at an early stage.
std::string lattice_temperature()
std::string hole_density()
std::string electron_distribution_function()
std::string density_gradient_hole_correction()
std::string hole_distribution_function()
std::string density_gradient_electron_correction()
std::string electron_density()
The main ViennaSHE namespace. All functionality resides inside this namespace.
equation_id
An enumeration of all equation types ViennaSHE supports.
boundary_type_id
An enumeration of all boundary conditions ViennaSHE supports.