Skip to content

Commit

Permalink
add back physics module interface
Browse files Browse the repository at this point in the history
  • Loading branch information
white238 committed Aug 21, 2024
1 parent ae121e9 commit 7e2acd6
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/serac/numerics/functional/quadrature_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ namespace serac {
* @tparam the data type to be stored at each quadrature point
*
* @note users are not intended to create these objects directly, instead
* they should use the StateManager::newQuadratureDataBuffer()
* they should use the PhysicsModule::createQuadratureDataBuffer()
*/
template <typename T>
struct QuadratureData {
Expand Down
19 changes: 16 additions & 3 deletions src/serac/physics/solid_mechanics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ class SolidMechanics<order, dim, Parameters<parameter_space...>, std::integer_se
if constexpr (dim == 3) {
serac::solid_mechanics::J2SmallStrain<serac::solid_mechanics::LinearHardening>::State initial_state{};
setMaterial(std::get<serac::solid_mechanics::J2SmallStrain<serac::solid_mechanics::LinearHardening>>(mat),
StateManager::newQuadratureDataBuffer(mesh_tag, order, dim, initial_state));
createQuadratureDataBuffer(initial_state));
} else {
SLIC_ERROR_ROOT("J2 materials only work for 3D simulations");
}
Expand All @@ -301,7 +301,7 @@ class SolidMechanics<order, dim, Parameters<parameter_space...>, std::integer_se
if constexpr (dim == 3) {
serac::solid_mechanics::J2SmallStrain<serac::solid_mechanics::PowerLawHardening>::State initial_state{};
setMaterial(std::get<serac::solid_mechanics::J2SmallStrain<serac::solid_mechanics::PowerLawHardening>>(mat),
StateManager::newQuadratureDataBuffer(mesh_tag, order, dim, initial_state));
createQuadratureDataBuffer(initial_state));
} else {
SLIC_ERROR_ROOT("J2 materials only work for 3D simulations");
}
Expand All @@ -310,7 +310,7 @@ class SolidMechanics<order, dim, Parameters<parameter_space...>, std::integer_se
if constexpr (dim == 3) {
serac::solid_mechanics::J2SmallStrain<serac::solid_mechanics::VoceHardening>::State initial_state{};
setMaterial(std::get<serac::solid_mechanics::J2SmallStrain<serac::solid_mechanics::VoceHardening>>(mat),
StateManager::newQuadratureDataBuffer(mesh_tag, order, dim, initial_state));
createQuadratureDataBuffer(initial_state));
} else {
SLIC_ERROR_ROOT("J2 materials only work for 3D simulations");
}
Expand Down Expand Up @@ -409,6 +409,19 @@ class SolidMechanics<order, dim, Parameters<parameter_space...>, std::integer_se
initializeSolidMechanicsStates();
}

/**
* @brief Create a shared ptr to a quadrature data buffer for the given material type
*
* @tparam T the type to be created at each quadrature point
* @param initial_state the value to be broadcast to each quadrature point
* @return std::shared_ptr< QuadratureData<T> >
*/
template <typename T>
qdata_type<T> createQuadratureDataBuffer(T initial_state)
{
return StateManager::newQuadratureDataBuffer(mesh_tag_, order, dim, initial_state);
}

/**
* @brief Set essential displacement boundary conditions (strongly enforced)
*
Expand Down
2 changes: 1 addition & 1 deletion src/serac/physics/tests/lce_Brighenti_tensile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ TEST(LiquidCrystalElastomer, Brighenti)
transition_temperature, Nb2);

LiquidCrystElastomerBrighenti::State initial_state{};
auto qdata = StateManager::newQuadratureDataBuffer(mesh_tag, p, dim, initial_state);
auto qdata = solid_solver.createQuadratureDataBuffer(initial_state);
solid_solver.setMaterial(DependsOn<TEMPERATURE_INDEX, GAMMA_INDEX>{}, mat, qdata);

// prescribe symmetry conditions
Expand Down
2 changes: 1 addition & 1 deletion src/serac/physics/tests/solid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void functional_solid_test_static_J2()

Material::State initial_state{};

auto qdata = StateManager::newQuadratureDataBuffer(mesh_tag, p, dim, initial_state);
auto qdata = solid_solver.createQuadratureDataBuffer(initial_state);

solid_solver.setMaterial(mat, qdata);

Expand Down
6 changes: 3 additions & 3 deletions src/serac/physics/tests/thermal_mechanics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void functional_test_static_3D(double expected_norm)

GreenSaintVenantThermoelasticMaterial material{rho, E, nu, c, alpha, theta_ref, k};
GreenSaintVenantThermoelasticMaterial::State initial_state{};
auto qdata = StateManager::newQuadratureDataBuffer(mesh_tag, p, dim, initial_state);
auto qdata = thermal_solid_solver.createQuadratureDataBuffer(initial_state);
thermal_solid_solver.setMaterial(material, qdata);

// Define the function for the initial temperature and boundary condition
Expand Down Expand Up @@ -154,7 +154,7 @@ void functional_test_shrinking_3D(double expected_norm)
double k = 1.0;
GreenSaintVenantThermoelasticMaterial material{rho, E, nu, c, alpha, theta_ref, k};
GreenSaintVenantThermoelasticMaterial::State initial_state{};
auto qdata = StateManager::newQuadratureDataBuffer(mesh_tag, p, dim, initial_state);
auto qdata = thermal_solid_solver.createQuadratureDataBuffer(initial_state);
thermal_solid_solver.setMaterial(material, qdata);

// Define the function for the initial temperature
Expand Down Expand Up @@ -249,7 +249,7 @@ void parameterized()

ParameterizedGreenSaintVenantThermoelasticMaterial material{rho, E, nu, c, alpha0, theta_ref, k};
ParameterizedGreenSaintVenantThermoelasticMaterial::State initial_state{};
auto qdata = StateManager::newQuadratureDataBuffer(mesh_tag, p, dim, initial_state);
auto qdata = thermal_solid_solver.createQuadratureDataBuffer(initial_state);
thermal_solid_solver.setMaterial(material, qdata);

// parameterize the coefficient of thermal expansion
Expand Down
13 changes: 13 additions & 0 deletions src/serac/physics/thermomechanics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,19 @@ class Thermomechanics : public BasePhysics {
time_ += dt;
}

/**
* @brief Create a shared ptr to a quadrature data buffer for the given material type
*
* @tparam T the type to be created at each quadrature point
* @param initial_state the value to be broadcast to each quadrature point
* @return std::shared_ptr< QuadratureData<T> >
*/
template <typename T>
std::shared_ptr<QuadratureData<T>> createQuadratureDataBuffer(T initial_state)
{
return solid_.createQuadratureDataBuffer(initial_state);
}

/**
* @brief This is an adaptor class that makes a thermomechanical material usable by
* the thermal module, by discarding the solid-mechanics-specific information
Expand Down

0 comments on commit 7e2acd6

Please sign in to comment.