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_CURL_CURL_OPERATOR_HPP
5 : #define PALACE_MODELS_CURL_CURL_OPERATOR_HPP
6 :
7 : #include <memory>
8 : #include <vector>
9 : #include <mfem.hpp>
10 : #include "fem/fespace.hpp"
11 : #include "linalg/operator.hpp"
12 : #include "linalg/vector.hpp"
13 : #include "models/materialoperator.hpp"
14 : #include "models/surfacecurrentoperator.hpp"
15 :
16 : namespace palace
17 : {
18 :
19 : class IoData;
20 : class Mesh;
21 :
22 : //
23 : // A class handling discretization of curl-curl problems for magnetostatics.
24 : //
25 : class CurlCurlOperator
26 : {
27 : private:
28 : // Helper variable for log file printing.
29 : bool print_hdr;
30 :
31 : // Essential boundary condition attributes.
32 : mfem::Array<int> dbc_attr;
33 : std::vector<mfem::Array<int>> dbc_tdof_lists;
34 :
35 : // Objects defining the finite element spaces for the magnetic vector potential
36 : // (Nedelec) and magnetic flux density (Raviart-Thomas) on the given mesh. The H1 spaces
37 : // are used for various purposes throughout the code including postprocessing.
38 : std::vector<std::unique_ptr<mfem::ND_FECollection>> nd_fecs;
39 : std::vector<std::unique_ptr<mfem::H1_FECollection>> h1_fecs;
40 : std::unique_ptr<mfem::RT_FECollection> rt_fec;
41 : FiniteElementSpaceHierarchy nd_fespaces, h1_fespaces;
42 : FiniteElementSpace rt_fespace;
43 :
44 : // Operator for domain material properties.
45 : MaterialOperator mat_op;
46 :
47 : // Operator for source current excitation.
48 : SurfaceCurrentOperator surf_j_op;
49 :
50 : mfem::Array<int> SetUpBoundaryProperties(const IoData &iodata, const mfem::ParMesh &mesh);
51 : void CheckBoundaryProperties();
52 :
53 : public:
54 : CurlCurlOperator(const IoData &iodata, const std::vector<std::unique_ptr<Mesh>> &mesh);
55 :
56 : // Return material operator for postprocessing.
57 12 : const MaterialOperator &GetMaterialOp() const { return mat_op; }
58 :
59 : // Access to underlying BC operator objects for postprocessing.
60 : const auto &GetSurfaceCurrentOp() const { return surf_j_op; }
61 :
62 : // Return the parallel finite element space objects.
63 0 : auto &GetNDSpaces() { return nd_fespaces; }
64 : const auto &GetNDSpaces() const { return nd_fespaces; }
65 : auto &GetNDSpace() { return nd_fespaces.GetFinestFESpace(); }
66 : const auto &GetNDSpace() const { return nd_fespaces.GetFinestFESpace(); }
67 : auto &GetH1Spaces() { return h1_fespaces; }
68 : const auto &GetH1Spaces() const { return h1_fespaces; }
69 : auto &GetH1Space() { return h1_fespaces.GetFinestFESpace(); }
70 : const auto &GetH1Space() const { return h1_fespaces.GetFinestFESpace(); }
71 3 : auto &GetRTSpace() { return rt_fespace; }
72 : const auto &GetRTSpace() const { return rt_fespace; }
73 :
74 : // Access the underlying mesh object.
75 : const auto &GetMesh() const { return GetNDSpace().GetMesh(); }
76 :
77 : // Return the number of true (conforming) dofs on the finest ND space.
78 : auto GlobalTrueVSize() const { return GetNDSpace().GlobalTrueVSize(); }
79 :
80 : // Construct and return system matrix representing discretized curl-curl operator for
81 : // Ampere's law.
82 : std::unique_ptr<Operator> GetStiffnessMatrix();
83 :
84 : // Construct and return the discrete curl matrix.
85 : const Operator &GetCurlMatrix() const
86 : {
87 3 : return GetRTSpace().GetDiscreteInterpolator(GetNDSpace());
88 : }
89 :
90 : // Assemble the right-hand side source term vector for a current source applied on
91 : // specified excited boundaries.
92 : void GetExcitationVector(int idx, Vector &RHS);
93 :
94 : // Get the associated MPI communicator.
95 : MPI_Comm GetComm() const { return GetNDSpace().GetComm(); }
96 : };
97 :
98 : } // namespace palace
99 :
100 : #endif // PALACE_MODELS_CURL_CURL_OPERATOR_HPP
|