Skip to content

Commit

Permalink
Merge pull request #1319 from LLNL/tupek/setFromFieldFunctionRef
Browse files Browse the repository at this point in the history
Tupek/set from field function ref
tupek2 authored Jan 28, 2025
2 parents b617964 + 657b552 commit 55f781b
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/serac/physics/state/finite_element_state.hpp
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@
#include <functional>
#include <memory>
#include <optional>
#include <type_traits>

#include "mfem.hpp"

@@ -73,7 +74,8 @@ decltype(first_argument_helper(&F::operator())) first_argument_helper(F);
* Extract type of first argument of a free callable
*/
template <typename T>
using first_argument = decltype(first_argument_helper(std::declval<T>()));
using first_argument = typename std::remove_const<
typename std::remove_reference<decltype(first_argument_helper(std::declval<T>()))>::type>::type;

/**
* @brief Evaluate a function of a tensor with an mfem Vector object
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ TEST_F(TestFiniteElementState, SetScalarStateFromFieldFunction)
// Set state with field function.
// Check that lambda captures work with this.
double c = 2.0;
auto scalar_field = [c](tensor<double, spatial_dim> X) -> double { return c * X[0]; };
auto scalar_field = [c](const tensor<double, spatial_dim>& X) -> double { return c * X[0]; };
scalar_state.setFromFieldFunction(scalar_field);

// Get the nodal positions corresponding to state dofs in a grid function

0 comments on commit 55f781b

Please sign in to comment.