11#ifndef MACH_FUNCTIONAL_OUTPUT
22#define MACH_FUNCTIONAL_OUTPUT
33
4+ #include < list>
5+ #include < map>
6+ #include < string>
7+ #include < vector>
8+
49#include " mfem.hpp"
510#include " nlohmann/json.hpp"
611
@@ -35,6 +40,17 @@ class FunctionalOutput final
3540 template <typename T>
3641 void addOutputDomainIntegrator (T *integrator);
3742
43+ // / Adds domain integrator restricted to certain elements specified by the
44+ // / attributes listed in @a bdr_attr_marker to the nonlinear form that backs
45+ // / this output, and adds a reference to it to in integs as a MachIntegrator
46+ // / \param[in] integrator - integrator to add to functional
47+ // / \param[in] bdr_attr_marker - lists element attributes this integrator
48+ // / should be used on
49+ // / \tparam T - type of integrator, used for constructing MachIntegrator
50+ template <typename T>
51+ void addOutputDomainIntegrator (T *integrator,
52+ std::vector<int > bdr_attr_marker);
53+
3854 // / Adds interface integrator to the nonlinear form that backs this output,
3955 // / and adds a reference to it to in integs as a MachIntegrator
4056 // / \param[in] integrator - integrator to add to functional
@@ -47,6 +63,17 @@ class FunctionalOutput final
4763 // / \param[in] integrator - integrator to add to functional
4864 // / \tparam T - type of integrator, used for constructing MachIntegrator
4965 template <typename T>
66+ void addOutputBdrFaceIntegrator (T *integrator);
67+
68+ // / Adds boundary integrator restricted to certain boundaries specified by
69+ // / the attributes listed in @a bdr_attr_marker to the nonlinear form that
70+ // / backs this output, and adds a reference to it to in integs as a
71+ // / MachIntegrator
72+ // / \param[in] integrator - integrator to add to functional
73+ // / \param[in] bdr_attr_marker - lists boundary attributes this integrator
74+ // / should be used on
75+ // / \tparam T - type of integrator, used for constructing MachIntegrator
76+ template <typename T>
5077 void addOutputBdrFaceIntegrator (T *integrator,
5178 std::vector<int > bdr_attr_marker);
5279
@@ -64,8 +91,12 @@ class FunctionalOutput final
6491
6592 // / Collection of integrators to be applied.
6693 std::vector<MachIntegrator> integs;
94+
95+ // / Collection of element attribute markers for domain integrators
96+ std::list<mfem::Array<int >> domain_markers;
97+
6798 // / Collection of boundary markers for boundary integrators
68- std::vector <mfem::Array<int >> bdr_markers;
99+ std::list <mfem::Array<int >> bdr_markers;
69100
70101 // / map of linear forms that will compute \frac{\partial J}{\partial field}
71102 // / for each field the functional depends on
@@ -84,6 +115,19 @@ void FunctionalOutput::addOutputDomainIntegrator(T *integrator)
84115 *integrator, *func_fields, output_sens, output_scalar_sens);
85116}
86117
118+ template <typename T>
119+ void FunctionalOutput::addOutputDomainIntegrator (
120+ T *integrator,
121+ std::vector<int > bdr_attr_marker)
122+ {
123+ integs.emplace_back (*integrator);
124+ auto &marker = domain_markers.emplace_back (bdr_attr_marker.size ());
125+ marker.Assign (bdr_attr_marker.data ());
126+ output.AddDomainIntegrator (integrator, marker);
127+ mach::addSensitivityIntegrator (
128+ *integrator, *func_fields, output_sens, output_scalar_sens);
129+ }
130+
87131template <typename T>
88132void FunctionalOutput::addOutputInteriorFaceIntegrator (T *integrator)
89133{
@@ -93,15 +137,24 @@ void FunctionalOutput::addOutputInteriorFaceIntegrator(T *integrator)
93137 *integrator, *func_fields, output_sens, output_scalar_sens);
94138}
95139
140+ template <typename T>
141+ void FunctionalOutput::addOutputBdrFaceIntegrator (T *integrator)
142+ {
143+ integs.emplace_back (*integrator);
144+ output.AddBdrFaceIntegrator (integrator);
145+ mach::addSensitivityIntegrator (
146+ *integrator, *func_fields, output_sens, output_scalar_sens);
147+ }
148+
96149template <typename T>
97150void FunctionalOutput::addOutputBdrFaceIntegrator (
98151 T *integrator,
99152 std::vector<int > bdr_attr_marker)
100153{
101154 integs.emplace_back (*integrator);
102- bdr_markers.emplace_back (bdr_attr_marker.size ());
103- bdr_markers. back () .Assign (bdr_attr_marker.data ());
104- output.AddBdrFaceIntegrator (integrator, bdr_markers. back () );
155+ auto &marker = bdr_markers.emplace_back (bdr_attr_marker.size ());
156+ marker .Assign (bdr_attr_marker.data ());
157+ output.AddBdrFaceIntegrator (integrator, marker );
105158 mach::addSensitivityIntegrator (
106159 *integrator, *func_fields, output_sens, output_scalar_sens);
107160}
0 commit comments