|
hp-FEM
Adaptive hp-FEM suite for nano-optics
|
#include <vector>#include "hpfem/core/types.hpp"#include "hpfem/mesh/mesh.hpp"#include "hpfem/physics/conical_goal.hpp"#include "hpfem/physics/conical_scattering.hpp"#include "hpfem/physics/goal_oriented.hpp"#include "hpfem/physics/scattering.hpp"#include "hpfem/physics/sensitivity.hpp"

Go to the source code of this file.
Namespaces | |
| namespace | hpfem |
| namespace | hpfem::physics |
Typedefs | |
| using | hpfem::physics::NodeField = Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > |
| using | hpfem::physics::ComplexNodeField = Eigen::Matrix< Complex, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > |
| Complex node field, the gradient of a complex goal. | |
Functions | |
| template<int Dim> | |
| Index | hpfem::physics::num_geometry_nodes (const mesh::Mesh< Dim > &mesh) |
| Number of geometry nodes of the mesh: vertices plus edge nodes for order 2. | |
| template<int Dim> | |
| ComplexNodeField | hpfem::physics::shape_gradient (const Scattering< Dim > &problem, const ScatteringSolution< Dim > &solution, const Vector &adjoint, Real relative_step=1e-6) |
| ComplexNodeField | hpfem::physics::conical_shape_gradient (const ConicalScattering &problem, const ConicalSolution &solution, const ConicalAdjoint &adjoint, Real relative_step=1e-6) |
| The same for the conical solver. | |
| Complex | hpfem::physics::shape_sensitivity (const ComplexNodeField &gradient, const NodeField &velocity) |
| template<int Dim> | |
| Complex | hpfem::physics::shape_derivative (const Scattering< Dim > &problem, const ScatteringSolution< Dim > &solution, const Functional< Dim > &functional, const NodeField &velocity, Real relative_step=1e-6, Real functional_step=1e-6) |
| Complex | hpfem::physics::conical_shape_derivative (const ConicalScattering &problem, const ConicalSolution &solution, const ConicalFunctional &functional, const NodeField &velocity, Real relative_step=1e-6, Real functional_step=1e-6) |
The same for the conical solver and a ConicalFunctional. | |
| template<int Dim> | |
| Vector | hpfem::physics::shape_residual_derivative (const Scattering< Dim > &problem, const ScatteringSolution< Dim > &solution, const NodeField &velocity, Real relative_step=1e-6) |
| Vector | hpfem::physics::conical_shape_residual_derivative (const ConicalScattering &problem, const ConicalSolution &solution, const NodeField &velocity, Real relative_step=1e-6) |
| The same for the conical solver, stacked as (in-plane | scaled longitudinal). | |
| template<int Dim> | |
| Vector | hpfem::physics::functional_shape_derivative (const fespace::NedelecDofMap< Dim > &dofs, const Functional< Dim > &functional, const NodeField &velocity, Real functional_step=1e-6) |
| Vector | hpfem::physics::conical_functional_shape_derivative (const fespace::NedelecDofMap< 2 > &transverse, const fespace::DofMap< 2 > &longitudinal, const ConicalFunctional &functional, const NodeField &velocity, Real functional_step=1e-6) |
| The same for a conical functional, stacked as (in-plane | scaled longitudinal). | |
| template<int Dim> | |
| NodeField | hpfem::physics::region_normal_velocity (const mesh::Mesh< Dim > &mesh, mesh::Tag tag) |
| template<int Dim> | |
| void | hpfem::physics::move_nodes (mesh::Mesh< Dim > &mesh, const NodeField &velocity, Real t) |
Shape derivatives by the discrete adjoint on the mesh (M12, ADR-0011). The discrete goal \( Q = q^\top e \) depends on the geometry only through the node coordinates \( x \) of the mesh (vertices, and the edge nodes of second-order meshes): element matrices and loads are integrals over the mapped cells. With the adjoint \( z \) of sensitivity.hpp,
\[ \frac{\partial Q}{\partial x_{n,d}} = z^\top\Big(\frac{\partial b}{\partial x_{n,d}} - \frac{\partial A}{\partial x_{n,d}}\,e\Big) = \sum_{K \ni n} z_K^\top\Big(\frac{\partial b_K}{\partial x_{n,d}} - \frac{\partial A_K}{\partial x_{n,d}}\,e_K\Big) , \]
a sum over the cells sharing the node, whose element contributions are differentiated by central differences of the element integrals (step relative_step times the cell diameter; the integrals are smooth in the nodes, so the truncation error is of the order of the step squared). The result is the gradient of the discrete goal with respect to every node coordinate, exact up to that truncation (verified against finite differences of the solve on moved meshes in test_shape_sensitivity.cpp). Any geometry parameter then follows by the chain rule from its mesh velocity \( V = \partial x/\partial p \): \( dQ/dp = \sum_{n,d} (\partial Q/\partial x_{n,d})\,V_{n,d} \) (shape_sensitivity), e.g. the uniform normal growth of a tagged region (region_normal_velocity) for a radius or a layer thickness. This is the discrete counterpart of the Hadamard formula (the continuous shape derivative concentrates on the interface and involves the jumps of the coefficients); it needs no interface integrals, is consistent with the FEM solution at every resolution, and the velocity field is the user's parametrisation. The functional vector q itself depends on the nodes when its cells deform (a point value is a basis evaluation at reference coordinates that move with the cell, a line integral likewise): shape_derivative adds the directional derivative \( (\partial q/\partial x\cdot V)^\top e \) by central differences of the functional on meshes moved along V, so that the total \( dQ/dp \) is exact; shape_gradient alone takes q as fixed. Caveats: nodes on Dirichlet facets with non-zero data (incident facets) and on Bloch faces must not move (their data and pairing are taken as fixed); PML cells may deform (the stretch is a function of x and is differentiated with the rest). See docs/theory/maxwell.md#shape-derivatives.