Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ endif (MFEM_USE_EGADS)

target_compile_features(mach
PUBLIC
cxx_std_11
cxx_std_17
)

set_target_properties(mach
Expand Down Expand Up @@ -275,7 +275,7 @@ if (BUILD_PYTHON_WRAPPER)

target_compile_features(pyMach
PUBLIC
cxx_std_11
cxx_std_17
)

if (MACH_USE_CLANG_TIDY)
Expand Down
61 changes: 57 additions & 4 deletions src/common/functional_output.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#ifndef MACH_FUNCTIONAL_OUTPUT
#define MACH_FUNCTIONAL_OUTPUT

#include <list>
#include <map>
#include <string>
#include <vector>

#include "mfem.hpp"
#include "nlohmann/json.hpp"

Expand Down Expand Up @@ -35,6 +40,17 @@ class FunctionalOutput final
template <typename T>
void addOutputDomainIntegrator(T *integrator);

/// Adds domain integrator restricted to certain elements specified by the
/// attributes listed in @a bdr_attr_marker to the nonlinear form that backs
/// this output, and adds a reference to it to in integs as a MachIntegrator
/// \param[in] integrator - integrator to add to functional
/// \param[in] bdr_attr_marker - lists element attributes this integrator
/// should be used on
/// \tparam T - type of integrator, used for constructing MachIntegrator
template <typename T>
void addOutputDomainIntegrator(T *integrator,
std::vector<int> bdr_attr_marker);

/// Adds interface integrator to the nonlinear form that backs this output,
/// and adds a reference to it to in integs as a MachIntegrator
/// \param[in] integrator - integrator to add to functional
Expand All @@ -47,6 +63,17 @@ class FunctionalOutput final
/// \param[in] integrator - integrator to add to functional
/// \tparam T - type of integrator, used for constructing MachIntegrator
template <typename T>
void addOutputBdrFaceIntegrator(T *integrator);

/// Adds boundary integrator restricted to certain boundaries specified by
/// the attributes listed in @a bdr_attr_marker to the nonlinear form that
/// backs this output, and adds a reference to it to in integs as a
/// MachIntegrator
/// \param[in] integrator - integrator to add to functional
/// \param[in] bdr_attr_marker - lists boundary attributes this integrator
/// should be used on
/// \tparam T - type of integrator, used for constructing MachIntegrator
template <typename T>
void addOutputBdrFaceIntegrator(T *integrator,
std::vector<int> bdr_attr_marker);

Expand All @@ -64,8 +91,12 @@ class FunctionalOutput final

/// Collection of integrators to be applied.
std::vector<MachIntegrator> integs;

/// Collection of element attribute markers for domain integrators
std::list<mfem::Array<int>> domain_markers;

/// Collection of boundary markers for boundary integrators
std::vector<mfem::Array<int>> bdr_markers;
std::list<mfem::Array<int>> bdr_markers;

/// map of linear forms that will compute \frac{\partial J}{\partial field}
/// for each field the functional depends on
Expand All @@ -84,6 +115,19 @@ void FunctionalOutput::addOutputDomainIntegrator(T *integrator)
*integrator, *func_fields, output_sens, output_scalar_sens);
}

template <typename T>
void FunctionalOutput::addOutputDomainIntegrator(
T *integrator,
std::vector<int> bdr_attr_marker)
{
integs.emplace_back(*integrator);
auto &marker = domain_markers.emplace_back(bdr_attr_marker.size());
marker.Assign(bdr_attr_marker.data());
output.AddDomainIntegrator(integrator, marker);
mach::addSensitivityIntegrator(
*integrator, *func_fields, output_sens, output_scalar_sens);
}

template <typename T>
void FunctionalOutput::addOutputInteriorFaceIntegrator(T *integrator)
{
Expand All @@ -93,15 +137,24 @@ void FunctionalOutput::addOutputInteriorFaceIntegrator(T *integrator)
*integrator, *func_fields, output_sens, output_scalar_sens);
}

template <typename T>
void FunctionalOutput::addOutputBdrFaceIntegrator(T *integrator)
{
integs.emplace_back(*integrator);
output.AddBdrFaceIntegrator(integrator);
mach::addSensitivityIntegrator(
*integrator, *func_fields, output_sens, output_scalar_sens);
}

template <typename T>
void FunctionalOutput::addOutputBdrFaceIntegrator(
T *integrator,
std::vector<int> bdr_attr_marker)
{
integs.emplace_back(*integrator);
bdr_markers.emplace_back(bdr_attr_marker.size());
bdr_markers.back().Assign(bdr_attr_marker.data());
output.AddBdrFaceIntegrator(integrator, bdr_markers.back());
auto &marker = bdr_markers.emplace_back(bdr_attr_marker.size());
marker.Assign(bdr_attr_marker.data());
output.AddBdrFaceIntegrator(integrator, marker);
mach::addSensitivityIntegrator(
*integrator, *func_fields, output_sens, output_scalar_sens);
}
Expand Down
7 changes: 6 additions & 1 deletion test/catch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7559,7 +7559,12 @@ namespace Catch {

#ifdef CATCH_PLATFORM_MAC

#define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */
// use inline assembler
#if defined(__i386__) || defined(__x86_64__)
#define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */
#elif defined(__aarch64__)
#define CATCH_TRAP() __asm__(".inst 0xd4200000") /* NOLINT */
#endif

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