hp-FEM
Adaptive hp-FEM suite for nano-optics
Loading...
Searching...
No Matches
postprocess.hpp
Go to the documentation of this file.
1#pragma once
10
11#include <functional>
12#include <vector>
13
15#include "hpfem/core/types.hpp"
18#include "hpfem/mesh/mesh.hpp"
21
22namespace hpfem::physics {
23
27template <int Dim>
28struct Surface {
33 std::vector<Facet> facets;
34
40 [[nodiscard]] static Surface around_cells(const mesh::Mesh<Dim>& mesh, mesh::Tag cell_tag);
42 [[nodiscard]] static Surface boundary(const mesh::Mesh<Dim>& mesh, mesh::Tag facet_tag);
44 [[nodiscard]] static Surface whole_boundary(const mesh::Mesh<Dim>& mesh);
52 [[nodiscard]] static Surface plane(const mesh::Mesh<Dim>& mesh, int axis, Real coordinate,
53 int direction, Real tolerance = 1e-9);
54};
55
58template <int Dim>
66
70template <int Dim>
71[[nodiscard]] std::vector<SurfacePoint<Dim>> surface_quadrature(const mesh::Mesh<Dim>& mesh,
72 const Surface<Dim>& surface,
73 int order);
74
76template <int Dim>
79
81template <int Dim>
83 const Vector& e_h);
85template <int Dim>
88template <int Dim>
90 const SurfaceField<Dim>& b, Complex factor);
91
95template <int Dim>
96[[nodiscard]] Real poynting_flux(const mesh::Mesh<Dim>& mesh, const Surface<Dim>& surface,
97 const SurfaceField<Dim>& field, Real omega,
98 const materials::MaterialMap& materials, int order);
100template <int Dim>
101[[nodiscard]] Real poynting_flux(const fespace::NedelecDofMap<Dim>& dofs, const Vector& e_h,
102 Real omega, const materials::MaterialMap& materials,
103 const Surface<Dim>& surface, int extra_order = 2);
104
107template <int Dim>
108[[nodiscard]] Real absorbed_power(const fespace::NedelecDofMap<Dim>& dofs, const Vector& e_h,
109 Real omega, const materials::MaterialMap& materials,
110 int extra_order = 2);
113template <int Dim>
114[[nodiscard]] std::vector<Real> absorbed_power_per_cell(const fespace::NedelecDofMap<Dim>& dofs,
115 const Vector& e_h, Real omega,
116 const materials::MaterialMap& materials,
117 int extra_order = 2);
118
121[[nodiscard]] Real plane_wave_intensity(Real amplitude, const materials::Material& medium);
122
132template <int Dim>
133[[nodiscard]] CrossSections cross_sections(const Scattering<Dim>& problem,
134 const ScatteringSolution<Dim>& solution,
135 const Surface<Dim>& surface, Real incident_amplitude,
136 int extra_order = 2);
137
149 [[nodiscard]] Real residual() const noexcept {
151 }
152 [[nodiscard]] Real relative_residual() const noexcept {
153 return incident > 0 ? residual() / incident : 0.0;
154 }
155};
156
163[[nodiscard]] PowerBalance power_balance(const Scattering<2>& problem,
164 const ScatteringSolution<2>& solution,
165 const Surface<2>& reflection, Real period,
166 Real kn_incident, Real incident_amplitude = 1.0,
167 const Surface<2>* transmission = nullptr,
168 int extra_order = 2);
169
173template <int Dim>
174[[nodiscard]] Real absorbed_power(const Scattering<Dim>& problem,
175 const ScatteringSolution<Dim>& solution, int extra_order = 2);
176
177extern template struct Surface<2>;
178extern template struct Surface<3>;
179extern template Real absorbed_power<2>(const Scattering<2>&, const ScatteringSolution<2>&, int);
180extern template Real absorbed_power<3>(const Scattering<3>&, const ScatteringSolution<3>&, int);
181extern template std::vector<SurfacePoint<2>> surface_quadrature<2>(const mesh::Mesh<2>&,
182 const Surface<2>&, int);
183extern template std::vector<SurfacePoint<3>> surface_quadrature<3>(const mesh::Mesh<3>&,
184 const Surface<3>&, int);
190 Complex);
192 Complex);
193extern template Real poynting_flux<2>(const mesh::Mesh<2>&, const Surface<2>&,
195 int);
196extern template Real poynting_flux<3>(const mesh::Mesh<3>&, const Surface<3>&,
198 int);
200 const materials::MaterialMap&, const Surface<2>&, int);
202 const materials::MaterialMap&, const Surface<3>&, int);
204 const materials::MaterialMap&, int);
206 const materials::MaterialMap&, int);
207extern template std::vector<Real> absorbed_power_per_cell<2>(const fespace::NedelecDofMap<2>&,
208 const Vector&, Real,
209 const materials::MaterialMap&, int);
210extern template std::vector<Real> absorbed_power_per_cell<3>(const fespace::NedelecDofMap<3>&,
211 const Vector&, Real,
212 const materials::MaterialMap&, int);
214 const Surface<2>&, Real, int);
216 const Surface<3>&, Real, int);
217
218} // namespace hpfem::physics
Definition dof_map.hpp:51
Definition material.hpp:149
Definition material.hpp:31
Definition mesh.hpp:61
Assembles, constrains and solves a scattering problem and evaluates its fields.
Definition scattering.hpp:96
Eigen::Matrix< Complex, Dim==2 ? 1 :3, 1 > ComplexCurl
Curl of a physical field: scalar (1-vector) in 2D, 3-vector in 3D.
Definition maxwell_forms.hpp:34
Eigen::Matrix< Complex, Dim, 1 > ComplexVector
Definition maxwell_forms.hpp:31
std::int32_t Tag
Integer tag of a physical group (Gmsh convention: positive; 0 means untagged).
Definition mesh.hpp:23
Definition absorption.hpp:21
template Real poynting_flux< 3 >(const mesh::Mesh< 3 > &, const Surface< 3 > &, const SurfaceField< 3 > &, Real, const materials::MaterialMap &, int)
template std::vector< Real > absorbed_power_per_cell< 2 >(const fespace::NedelecDofMap< 2 > &, const Vector &, Real, const materials::MaterialMap &, int)
template SurfaceField< 2 > combined_field< 2 >(const SurfaceField< 2 > &, const SurfaceField< 2 > &, Complex)
SurfaceField< Dim > analytic_field(const IncidentField< Dim > &field)
Sampler of an analytic field.
Real poynting_flux(const mesh::Mesh< Dim > &mesh, const Surface< Dim > &surface, const SurfaceField< Dim > &field, Real omega, const materials::MaterialMap &materials, int order)
PowerBalance power_balance(const Scattering< 2 > &problem, const ScatteringSolution< 2 > &solution, const Surface< 2 > &reflection, Real period, Real kn_incident, Real incident_amplitude=1.0, const Surface< 2 > *transmission=nullptr, int extra_order=2)
SurfaceField< Dim > combined_field(const SurfaceField< Dim > &a, const SurfaceField< Dim > &b, Complex factor)
Sampler of the sum a + factor * b.
SurfaceField< Dim > discrete_field(const fespace::NedelecDofMap< Dim > &dofs, const Vector &e_h)
Sampler of a discrete field (coefficients on the DoF map).
template SurfaceField< 2 > analytic_field< 2 >(const IncidentField< 2 > &)
template Real absorbed_power< 3 >(const Scattering< 3 > &, const ScatteringSolution< 3 > &, int)
Real plane_wave_intensity(Real amplitude, const materials::Material &medium)
template SurfaceField< 2 > discrete_field< 2 >(const fespace::NedelecDofMap< 2 > &, const Vector &)
Real absorbed_power(const fespace::NedelecDofMap< Dim > &dofs, const Vector &e_h, Real omega, const materials::MaterialMap &materials, int extra_order=2)
template SurfaceField< 3 > combined_field< 3 >(const SurfaceField< 3 > &, const SurfaceField< 3 > &, Complex)
template Real absorbed_power< 2 >(const Scattering< 2 > &, const ScatteringSolution< 2 > &, int)
template SurfaceField< 3 > discrete_field< 3 >(const fespace::NedelecDofMap< 3 > &, const Vector &)
std::vector< Real > absorbed_power_per_cell(const fespace::NedelecDofMap< Dim > &dofs, const Vector &e_h, Real omega, const materials::MaterialMap &materials, int extra_order=2)
template std::vector< SurfacePoint< 3 > > surface_quadrature< 3 >(const mesh::Mesh< 3 > &, const Surface< 3 > &, int)
template CrossSections cross_sections< 3 >(const Scattering< 3 > &, const ScatteringSolution< 3 > &, const Surface< 3 > &, Real, int)
CrossSections cross_sections(const Scattering< Dim > &problem, const ScatteringSolution< Dim > &solution, const Surface< Dim > &surface, Real incident_amplitude, int extra_order=2)
template Real poynting_flux< 2 >(const mesh::Mesh< 2 > &, const Surface< 2 > &, const SurfaceField< 2 > &, Real, const materials::MaterialMap &, int)
template CrossSections cross_sections< 2 >(const Scattering< 2 > &, const ScatteringSolution< 2 > &, const Surface< 2 > &, Real, int)
template std::vector< Real > absorbed_power_per_cell< 3 >(const fespace::NedelecDofMap< 3 > &, const Vector &, Real, const materials::MaterialMap &, int)
template SurfaceField< 3 > analytic_field< 3 >(const IncidentField< 3 > &)
template std::vector< SurfacePoint< 2 > > surface_quadrature< 2 >(const mesh::Mesh< 2 > &, const Surface< 2 > &, int)
std::vector< SurfacePoint< Dim > > surface_quadrature(const mesh::Mesh< Dim > &mesh, const Surface< Dim > &surface, int order)
std::function< void(const SurfacePoint< Dim > &, assembly::ComplexVector< Dim > &, assembly::ComplexCurl< Dim > &)> SurfaceField
Field sampler: value and curl of a field at a surface point.
Definition postprocess.hpp:78
double Real
Definition types.hpp:15
Eigen::Matrix< Real, Dim, 1 > Point
Definition types.hpp:27
std::int64_t Index
global indices (DoFs, entities)
Definition types.hpp:17
Eigen::Matrix< Complex, Eigen::Dynamic, 1 > Vector
Definition types.hpp:20
constexpr Index kInvalidIndex
"No entity" marker, e.g. the neighbour across a boundary facet.
Definition types.hpp:31
std::complex< double > Complex
Definition types.hpp:16
Definition postprocess.hpp:127
Real absorption
Definition postprocess.hpp:129
Real extinction
Definition postprocess.hpp:130
Real scattering
Definition postprocess.hpp:128
Definition sources.hpp:22
Definition postprocess.hpp:144
Real incident
Definition postprocess.hpp:145
Real reflected
Definition postprocess.hpp:146
Real absorbed
Definition postprocess.hpp:148
Real residual() const noexcept
Definition postprocess.hpp:149
Real relative_residual() const noexcept
Definition postprocess.hpp:152
Real transmitted
Definition postprocess.hpp:147
Coefficients of the unknown field on the DoF map.
Definition scattering.hpp:86
Definition postprocess.hpp:59
Point< Dim > x
Definition postprocess.hpp:60
Real weight
Definition postprocess.hpp:62
Point< Dim > normal
Definition postprocess.hpp:61
Point< Dim > xi
Definition postprocess.hpp:64
Index cell
Definition postprocess.hpp:63
Definition postprocess.hpp:29
Index inside_cell
Definition postprocess.hpp:31
Index facet
Definition postprocess.hpp:30
Definition postprocess.hpp:28
std::vector< Facet > facets
Definition postprocess.hpp:33
static Surface plane(const mesh::Mesh< Dim > &mesh, int axis, Real coordinate, int direction, Real tolerance=1e-9)
static Surface around_cells(const mesh::Mesh< Dim > &mesh, mesh::Tag cell_tag)
static Surface boundary(const mesh::Mesh< Dim > &mesh, mesh::Tag facet_tag)
Boundary facets carrying facet_tag, normal out of the domain.
static Surface whole_boundary(const mesh::Mesh< Dim > &mesh)
The whole domain boundary, normal out of the domain.