Skip to content

Commit 6eb3bdf

Browse files
authored
Merge pull request #61 from OptimalDesignLab/restricted-functional-domain-integs
Update the FunctionalOutput
2 parents 3abd431 + 29e2f88 commit 6eb3bdf

3 files changed

Lines changed: 65 additions & 7 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ endif (MFEM_USE_EGADS)
143143

144144
target_compile_features(mach
145145
PUBLIC
146-
cxx_std_11
146+
cxx_std_17
147147
)
148148

149149
set_target_properties(mach
@@ -275,7 +275,7 @@ if (BUILD_PYTHON_WRAPPER)
275275

276276
target_compile_features(pyMach
277277
PUBLIC
278-
cxx_std_11
278+
cxx_std_17
279279
)
280280

281281
if (MACH_USE_CLANG_TIDY)

src/common/functional_output.hpp

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
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+
87131
template <typename T>
88132
void 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+
96149
template <typename T>
97150
void 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
}

test/catch.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7559,7 +7559,12 @@ namespace Catch {
75597559

75607560
#ifdef CATCH_PLATFORM_MAC
75617561

7562-
#define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */
7562+
// use inline assembler
7563+
#if defined(__i386__) || defined(__x86_64__)
7564+
#define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */
7565+
#elif defined(__aarch64__)
7566+
#define CATCH_TRAP() __asm__(".inst 0xd4200000") /* NOLINT */
7567+
#endif
75637568

75647569
#elif defined(CATCH_PLATFORM_LINUX)
75657570
// If we can use inline assembler, do it because this allows us to break

0 commit comments

Comments
 (0)