Line data Source code
1 : // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 : // SPDX-License-Identifier: Apache-2.0
3 :
4 : #ifndef PALACE_MODELS_SURFACE_POST_OPERATOR_HPP
5 : #define PALACE_MODELS_SURFACE_POST_OPERATOR_HPP
6 :
7 : #include <map>
8 : #include <memory>
9 : #include <vector>
10 : #include <mfem.hpp>
11 : #include "fem/coefficient.hpp"
12 :
13 : namespace palace
14 : {
15 :
16 : class GridFunction;
17 : class IoData;
18 : class MaterialOperator;
19 :
20 : namespace config
21 : {
22 :
23 : struct SurfaceFluxData;
24 : struct InterfaceDielectricData;
25 : struct FarFieldPostData;
26 :
27 : } // namespace config
28 :
29 : //
30 : // A class handling boundary surface postprocessing.
31 : //
32 : class SurfacePostOperator
33 : {
34 : private:
35 : // Mapping from surface index to data structure containing surface postprocessing
36 : // information for surface flux or interface dielectric participation.
37 17 : struct SurfaceData
38 : {
39 : mfem::Array<int> attr_list;
40 :
41 0 : virtual ~SurfaceData() = default;
42 : };
43 0 : struct SurfaceFluxData : public SurfaceData
44 : {
45 : SurfaceFlux type;
46 : bool two_sided;
47 : mfem::Vector center;
48 :
49 : SurfaceFluxData(const config::SurfaceFluxData &data, const mfem::ParMesh &mesh,
50 : const mfem::Array<int> &bdr_attr_marker);
51 :
52 : std::unique_ptr<mfem::Coefficient> GetCoefficient(const mfem::ParGridFunction *E,
53 : const mfem::ParGridFunction *B,
54 : const MaterialOperator &mat_op) const;
55 : };
56 : struct InterfaceDielectricData : public SurfaceData
57 : {
58 : InterfaceDielectric type;
59 : double t, epsilon, tandelta;
60 :
61 : InterfaceDielectricData(const config::InterfaceDielectricData &data,
62 : const mfem::ParMesh &mesh,
63 : const mfem::Array<int> &bdr_attr_marker);
64 :
65 : std::unique_ptr<mfem::Coefficient> GetCoefficient(const GridFunction &E,
66 : const MaterialOperator &mat_op) const;
67 : };
68 17 : struct FarFieldData : public SurfaceData
69 : {
70 : std::vector<std::pair<double, double>> thetaphis;
71 :
72 18 : FarFieldData() = default;
73 : FarFieldData(const config::FarFieldPostData &data, const mfem::ParMesh &mesh,
74 : const mfem::Array<int> &bdr_attr_marker);
75 :
76 : size_t size() const { return thetaphis.size(); }
77 : };
78 :
79 : // Reference to material property operator (not owned).
80 : const MaterialOperator &mat_op;
81 :
82 : // Reference to scalar finite element space used for computing surface integrals (not
83 : // owned).
84 : mfem::ParFiniteElementSpace &h1_fespace;
85 :
86 : // Reference to vector finite element space used for computing far-field integrals (not
87 : // owned).
88 : mfem::ParFiniteElementSpace &nd_fespace;
89 :
90 : double GetLocalSurfaceIntegral(mfem::Coefficient &f,
91 : const mfem::Array<int> &attr_marker) const;
92 :
93 : public:
94 : // Data structures for postprocessing the surface with the given type.
95 : std::map<int, SurfaceFluxData> flux_surfs;
96 : std::map<int, InterfaceDielectricData> eps_surfs;
97 : FarFieldData farfield;
98 :
99 : SurfacePostOperator(const IoData &iodata, const MaterialOperator &mat_op,
100 : mfem::ParFiniteElementSpace &h1_fespace,
101 : mfem::ParFiniteElementSpace &nd_fespace);
102 :
103 : // Get surface integrals computing electric or magnetic field flux through a boundary.
104 : std::complex<double> GetSurfaceFlux(int idx, const GridFunction *E,
105 : const GridFunction *B) const;
106 :
107 : // Batch version for multiple theta/phi pairs
108 : std::vector<std::array<std::complex<double>, 3>>
109 : GetFarFieldrE(const std::vector<std::pair<double, double>> &theta_phi_pairs,
110 : const GridFunction &E, const GridFunction &B, double omega_re,
111 : double omega_im) const;
112 :
113 : // Get surface integrals computing interface dielectric energy.
114 : double GetInterfaceLossTangent(int idx) const;
115 : double GetInterfaceElectricFieldEnergy(int idx, const GridFunction &E) const;
116 :
117 0 : int GetVDim() const { return mat_op.SpaceDimension(); };
118 : };
119 :
120 : } // namespace palace
121 :
122 : #endif // PALACE_MODELS_SURFACE_POST_OPERATOR_HPP
|