Skip to content

Commit

Permalink
More comments
Browse files Browse the repository at this point in the history
  • Loading branch information
btalamini committed Jan 11, 2025
1 parent 96ea2bb commit fa277c5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/serac/physics/state/tests/test_finite_element_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,17 @@ class TestFiniteElementState : public testing::Test {

TEST_F(TestFiniteElementState, SetScalarStateFromFieldFunction)
{
// make a scalar-valued state
constexpr int p = 1;

FiniteElementState scalar_state(*mesh, H1<p>{}, "scalar_field");
// check that lambda captures work

// 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]; };
scalar_state.setFromField(scalar_field);

// Get the nodal positions for the state in a grid function
// Get the nodal positions corresponding to state dofs in a grid function
auto [coords_fe_space, coords_fe_coll] = serac::generateParFiniteElementSpace<H1<p, spatial_dim>>(mesh.get());
mfem::ParGridFunction nodal_coords_gf(coords_fe_space.get());
mesh->GetNodes(nodal_coords_gf);
Expand All @@ -61,7 +63,7 @@ TEST_F(TestFiniteElementState, SetScalarStateFromFieldFunction)
Xn[i] = nodal_coords_gf(dof_index);
}

// check that value set in the state matches the field function
// check that value set in the state for this node matches the field function
EXPECT_DOUBLE_EQ(scalar_field(Xn), scalar_state(node));
}
}
Expand Down

0 comments on commit fa277c5

Please sign in to comment.