Skip to content
Open
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ endif()

# Tune BLT to our needs
if (NOT BLT_CXX_STD)
set(BLT_CXX_STD "c++17" CACHE STRING "")
set(BLT_CXX_STD "c++20" CACHE STRING "")
endif()

# These BLT tools are not used in Smith, turn them off
Expand Down
7 changes: 3 additions & 4 deletions cmake/SmithCompilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ endif()
set(_extra_flags "-Wshadow -Wdouble-promotion -Wconversion -Wundef -Wnull-dereference -Wold-style-cast")
blt_append_custom_compiler_flag(FLAGS_VAR CMAKE_CXX_FLAGS DEFAULT ${_extra_flags})

# Only clang has fine-grained control over the designated initializer warnings
# This can be added to the GCC flags when C++20 is available
# This should be compatible with Clang 8 through Clang 12
blt_append_custom_compiler_flag(FLAGS_VAR CMAKE_CXX_FLAGS CLANG "-Wpedantic -Wno-c++2a-extensions -Wunused-private-field")
# Clang specific warnings
# Note: pedantic is a gcc flag but throws a false positive in src/smith/numerics/petsc_solvers.cpp
blt_append_custom_compiler_flag(FLAGS_VAR CMAKE_CXX_FLAGS CLANG "-Wpedantic -Wunused-private-field")
38 changes: 19 additions & 19 deletions src/smith/infrastructure/about.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,26 @@ namespace smith {

std::string about()
{
using namespace axom::fmt;
[[maybe_unused]] constexpr std::string_view on = "ON";
[[maybe_unused]] constexpr std::string_view off = "OFF";

std::string about = "\n";

// Version info
about += format("Smith Version: {0}\n", version());
about += axom::fmt::format("Smith Version: {0}\n", version());
about += "\n";

// General configuration
#ifdef SMITH_DEBUG
about += format("Debug Build: {0}\n", on);
about += axom::fmt::format("Debug Build: {0}\n", on);
#else
about += format("Debug Build: {0}\n", off);
about += axom::fmt::format("Debug Build: {0}\n", off);
#endif

#ifdef SMITH_USE_CUDA
about += format("CUDA: {0}\n", on);
about += axom::fmt::format("CUDA: {0}\n", on);
#else
about += format("CUDA: {0}\n", off);
about += axom::fmt::format("CUDA: {0}\n", off);
#endif

about += "\n";
Expand All @@ -91,21 +90,21 @@ std::string about()
about += "Enabled Libraries:\n";

// Axom
about += format("Axom Version: {0}\n", axom::getVersion());
about += axom::fmt::format("Axom Version: {0}\n", axom::getVersion());

// Camp
about += format("Camp Version: {0}\n", CAMP_VERSION);
about += axom::fmt::format("Camp Version: {0}\n", CAMP_VERSION);

// Caliper
#ifdef SMITH_USE_CALIPER
about += format("Caliper Version: {0}\n", CALIPER_VERSION);
about += axom::fmt::format("Caliper Version: {0}\n", CALIPER_VERSION);
#else
disabled_libs.push_back("Caliper");
#endif

// Conduit
#ifdef SMITH_USE_CONDUIT
about += format("Conduit Version: {0}\n", CONDUIT_VERSION);
about += axom::fmt::format("Conduit Version: {0}\n", CONDUIT_VERSION);
#else
disabled_libs.push_back("Conduit");
#endif
Expand All @@ -117,9 +116,9 @@ std::string about()
if (H5get_libversion(&h5_maj, &h5_min, &h5_rel) < 0) {
SLIC_ERROR("Failed to retrieve HDF5 version.");
} else {
h5_version = format("{0}.{1}.{2}", h5_maj, h5_min, h5_rel);
h5_version = axom::fmt::format("{0}.{1}.{2}", h5_maj, h5_min, h5_rel);
}
about += format("HDF5 Version: {0}\n", h5_version);
about += axom::fmt::format("HDF5 Version: {0}\n", h5_version);
#else
disabled_libs.push_back("HDF5");
#endif
Expand All @@ -130,7 +129,7 @@ std::string about()
if (axom::utilities::string::startsWith(lua_version, "Lua ")) {
lua_version.erase(0, 4);
}
about += format("Lua Version: {0}\n", lua_version);
about += axom::fmt::format("Lua Version: {0}\n", lua_version);
#else
disabled_libs.push_back("Lua");
#endif
Expand All @@ -149,28 +148,29 @@ std::string about()
mfem_full_version.erase(0, 5);
}
if (mfem_sha[0] != '\0') {
mfem_full_version += format(" (Git SHA: {0})", mfem_sha);
mfem_full_version += axom::fmt::format(" (Git SHA: {0})", mfem_sha);
}
about += format("MFEM Version: {0}\n", mfem_full_version);
about += axom::fmt::format("MFEM Version: {0}\n", mfem_full_version);

// RAJA
#ifdef SMITH_USE_RAJA
about += format("RAJA Version: {0}.{1}.{2}\n", RAJA_VERSION_MAJOR, RAJA_VERSION_MINOR, RAJA_VERSION_PATCHLEVEL);
about += axom::fmt::format("RAJA Version: {0}.{1}.{2}\n", RAJA_VERSION_MAJOR, RAJA_VERSION_MINOR,
RAJA_VERSION_PATCHLEVEL);
#else
disabled_libs.push_back("RAJA");
#endif

// Tribol
#ifdef SMITH_USE_TRIBOL
about += format("Tribol Version: {0}\n", TRIBOL_VERSION_FULL);
about += axom::fmt::format("Tribol Version: {0}\n", TRIBOL_VERSION_FULL);
#else
disabled_libs.push_back("Tribol");
#endif

// Umpire
#ifdef SMITH_USE_UMPIRE
about += format("Umpire Version: {0}.{1}.{2}\n", umpire::get_major_version(), umpire::get_minor_version(),
umpire::get_patch_version());
about += axom::fmt::format("Umpire Version: {0}.{1}.{2}\n", umpire::get_major_version(),
umpire::get_minor_version(), umpire::get_patch_version());
#else
disabled_libs.push_back("Umpire");
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/smith/physics/functional_objective.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class FunctionalObjective<spatial_dim, Parameters<InputSpaces...>, std::integer_
const std::vector<ConstFieldPtr>& fs) const
{
return (*objective_)(time, *shape_disp, *fs[i]...);
};
}

/// @brief Utility to get array of jacobian functions, one for each input field in fs
template <int... i>
Expand All @@ -128,10 +128,10 @@ class FunctionalObjective<spatial_dim, Parameters<InputSpaces...>, std::integer_
using JacFuncType = std::function<decltype((*objective_)(DifferentiateWRT<1>{}, time, *shape_disp, *fs[i]...))(
double, ConstFieldPtr, const std::vector<ConstFieldPtr>&)>;
return std::array<JacFuncType, sizeof...(i)>{
[=](double _time, ConstFieldPtr _shape_disp, const std::vector<ConstFieldPtr>& _fs) {
[this](double _time, ConstFieldPtr _shape_disp, const std::vector<ConstFieldPtr>& _fs) {
return (*objective_)(DifferentiateWRT<i + 1>{}, _time, *_shape_disp, *_fs[i]...);
}...};
};
}

/// @brief timestep, this needs to be held here and modified for rate dependent applications.
mutable double dt_ = std::numeric_limits<double>::max();
Expand Down
8 changes: 4 additions & 4 deletions src/smith/physics/functional_weak_form.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,10 +407,10 @@ class FunctionalWeakForm<spatial_dim, OutputSpace, Parameters<InputSpaces...>,
using JacFuncType = std::function<decltype((*weak_form_)(DifferentiateWRT<1>{}, time, *shape_disp, *fs[i]...))(
double, ConstFieldPtr, const std::vector<ConstFieldPtr>&)>;
return std::array<JacFuncType, sizeof...(i)>{
[=](double _time, ConstFieldPtr _shape_disp, const std::vector<ConstFieldPtr>& _fs) {
[this](double _time, ConstFieldPtr _shape_disp, const std::vector<ConstFieldPtr>& _fs) {
return (*weak_form_)(DifferentiateWRT<i + 1>{}, _time, *_shape_disp, *_fs[i]...);
}...};
};
}

/// @brief Utility to get array of jvp functions, one for each input field in fs
template <int... i>
Expand All @@ -421,10 +421,10 @@ class FunctionalWeakForm<spatial_dim, OutputSpace, Parameters<InputSpaces...>,
std::function<decltype((*v_dot_weak_form_residual_)(DifferentiateWRT<1>{}, time, *shape_disp, *v, *fs[i]...))(
double, ConstFieldPtr, ConstFieldPtr, const std::vector<ConstFieldPtr>&)>;
return std::array<GradFuncType, sizeof...(i)>{
[=](double _time, ConstFieldPtr _shape_disp, ConstFieldPtr _v, const std::vector<ConstFieldPtr>& _fs) {
[this](double _time, ConstFieldPtr _shape_disp, ConstFieldPtr _v, const std::vector<ConstFieldPtr>& _fs) {
return (*v_dot_weak_form_residual_)(DifferentiateWRT<i + 2>{}, _time, *_shape_disp, *_v, *_fs[i]...);
}...};
};
}

/// @brief timestep, this needs to be held here and modified for rate dependent applications
mutable double dt_ = std::numeric_limits<double>::max();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ struct ParameterizedJ2Nonlinear {
{
using std::exp;
return sigma_sat - (sigma_sat - sigma_y) * exp(-accumulated_plastic_strain / strain_constant);
};
}
};

} // namespace smith::solid_mechanics
6 changes: 3 additions & 3 deletions src/smith/physics/materials/solid_material.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ struct LinearHardening {
auto operator()(T1 accumulated_plastic_strain, T2 accumulated_plastic_strain_rate) const
{
return sigma_y + Hi * accumulated_plastic_strain + overstress(eta, accumulated_plastic_strain_rate);
};
}
};

/**
Expand All @@ -220,7 +220,7 @@ struct PowerLawHardening {
using std::pow;
return sigma_y * pow(1.0 + accumulated_plastic_strain / eps0, 1.0 / n) +
overstress(eta, accumulated_plastic_strain_rate);
};
}
};

/**
Expand Down Expand Up @@ -252,7 +252,7 @@ struct VoceHardening {
auto& epsilon_p_dot = accumulated_plastic_strain_rate;
auto Y_vis = overstress(eta, epsilon_p_dot);
return Y_eq + Y_vis;
};
}
};

/// @brief J2 material with nonlinear isotropic hardening and linear kinematic hardening
Expand Down
40 changes: 25 additions & 15 deletions src/smith/physics/state/state_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,21 +160,14 @@ class StateManager {
std::string(geom_name)));
axom::sidre::Group* geom_group = qdatas_group->getGroup(std::string(geom_name));

// Verify size correctness
auto verify_size = [](axom::sidre::Group* group, axom::IndexType value, const std::string& view_name,
const std::string& err_msg) {
SLIC_ERROR_IF(
!group->hasView(view_name),
axom::fmt::format("Loaded Sidre Datastore does not have value '{}' for Quadrature Data.", view_name));
auto prev_value = group->getView(view_name)->getData<axom::IndexType>();
SLIC_ERROR_IF(value != prev_value, axom::fmt::format(err_msg, value, prev_value));
};
verify_size(geom_group, num_states, "num_states",
"Current number of Quadrature Data States '{}' does not match value in restart '{}'.");
verify_size(geom_group, state_size, "state_size",
"Current size of Quadrature Data State '{}' does not match value in restart '{}'.");
verify_size(geom_group, total_size, "total_size",
"Current total size of Quadrature Data States '{}' does not match value in restart '{}'.");
verifyQuadratureDataSize(
geom_group, num_states, "num_states",
"Current number of Quadrature Data States '{}' does not match value in restart '{}'.");
verifyQuadratureDataSize(geom_group, state_size, "state_size",
"Current size of Quadrature Data State '{}' does not match value in restart '{}'.");
verifyQuadratureDataSize(
geom_group, total_size, "total_size",
"Current total size of Quadrature Data States '{}' does not match value in restart '{}'.");

// Tell Sidre where the external array is
SLIC_ERROR_ROOT_IF(!geom_group->hasView("states"),
Expand Down Expand Up @@ -453,6 +446,23 @@ class StateManager {
static double time(std::string mesh_tag);

private:
/**
* @brief Verifies the current and restart size of Quadrature Data and errors
* with a helpful error message.
* @param[in] group Sidre Group that holds the Quadrature Datas
* @param[in] value Desired size of the Quadrature Data
* @param[in] view_name Name of the view that holds the specific Quadrature Data
* @param[in] err_msg Format string for helpful error message
*/
static void verifyQuadratureDataSize(axom::sidre::Group* group, axom::IndexType value, const char* view_name,
const char* err_msg)
{
SLIC_ERROR_IF(!group->hasView(view_name),
axom::fmt::format("Loaded Sidre Datastore does not have value '{}' for Quadrature Data.", view_name));
auto prev_value = group->getView(view_name)->getData<axom::IndexType>();
SLIC_ERROR_IF(value != prev_value, axom::fmt::format(axom::fmt::runtime(err_msg), value, prev_value));
}

/**
* @brief Creates a new datacollection based on a registered mesh
* @param[in] mesh_tag The mesh name used to name the new datacollection
Expand Down
4 changes: 2 additions & 2 deletions src/smith/physics/tests/dynamic_solid_adjoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,13 +526,13 @@ TEST_F(BucklingSensitivityFixture, QuasiStaticShapeSensitivities)
solid_solver->setFixedBCs(applied_displacement_surface);

auto K = smith::StateManager::newState(DensitySpace{}, kname, mesh_tag);
K.setFromFieldFunction([=](smith::tensor<double, dim> x) {
K.setFromFieldFunction([this](smith::tensor<double, dim> x) {
double scaling = ((x[0] < 3) && (x[0] > 2)) ? 0.99 : 0.001;
return scaling * mat.K0;
});

auto G = smith::StateManager::newState(DensitySpace{}, gname, mesh_tag);
G.setFromFieldFunction([=](smith::tensor<double, dim> x) {
G.setFromFieldFunction([this](smith::tensor<double, dim> x) {
double scaling = ((x[0] <= 3) && (x[0] >= 2)) ? 0.99 : 0.001;
return scaling * mat.G0;
});
Expand Down
4 changes: 2 additions & 2 deletions src/smith/physics/tests/thermomech_finite_diff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void FiniteDifferenceParameter(LoadingType load, size_t sensitivity_parameter_in

// Construct the appropriate dimension mesh and give it to the data store
std::string filename = SMITH_REPO_DIR "/data/meshes/patch2D_tris_and_quads.mesh";
std::string mesh_tag("mesh");
std::string mesh_tag = MESHTAG;

auto mesh =
std::make_shared<smith::Mesh>(buildMeshFromFile(filename), mesh_tag, serial_refinement, parallel_refinement);
Expand Down Expand Up @@ -281,7 +281,7 @@ void FiniteDifferenceShapeTest(LoadingType load)

// Construct the appropriate dimension mesh and give it to the data store
std::string filename = SMITH_REPO_DIR "/data/meshes/patch2D_tris_and_quads.mesh";
std::string mesh_tag("mesh");
std::string mesh_tag = MESHTAG;
auto mesh =
std::make_shared<smith::Mesh>(buildMeshFromFile(filename), mesh_tag, serial_refinement, parallel_refinement);

Expand Down
32 changes: 16 additions & 16 deletions src/smith/physics/tests/thermomech_statics_patch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,39 +218,39 @@ class ManufacturedSolution {
tm.setDisplacementBCs(disp_ebc_func, disp_ess_bdr);

// natural BCs
auto flux = [=](auto X, auto n0, auto /* time */, auto /* T */) {
auto flux = [this, &material](auto X, auto n0, auto /* time */, auto /* T */) {
typename MaterialType::State state{};

auto theta = evalT(get<0>(X));
auto dtheta_dX = gradT(get<0>(X));
auto du_dX = gradU(get<0>(X));
auto theta = this->evalT(get<0>(X));
auto dtheta_dX = this->gradT(get<0>(X));
auto du_dX = this->gradU(get<0>(X));

auto [stress, heat_accumulation, internal_heat_source, heat_flux] = material(state, du_dX, theta, dtheta_dX);
return dot(heat_flux, n0);
};
tm.setFluxBCs(flux, tm.mesh().entireBoundary());

auto traction = [=](auto X, auto n0, auto /* time */) {
auto traction = [this, &material](auto X, auto n0, auto /* time */) {
typename MaterialType::State state{};

auto theta = evalT(get_value(X));
auto dtheta_dX = gradT(get_value(X));
auto du_dX = gradU(get_value(X));
auto theta = this->evalT(get_value(X));
auto dtheta_dX = this->gradT(get_value(X));
auto du_dX = this->gradU(get_value(X));

auto [stress, heat_accumulation, internal_heat_source, heat_flux] = material(state, du_dX, theta, dtheta_dX);
return dot(stress, n0);
};
tm.setTraction(traction, tm.mesh().entireBoundary());

// Forcing functions
auto heat_source = [=](auto X, auto /* time */, auto /* T */, auto /* dTdX*/) {
auto heat_source = [this, &material](auto X, auto /* time */, auto /* T */, auto /* dTdX*/) {
typename MaterialType::State state{};

auto X_val_temp = get<0>(X);
auto X_val = get_value(X_val_temp);
auto theta = evalT(X_val);
auto dtheta_dX = gradT(make_dual(X_val));
auto du_dX = gradU(X_val);
auto theta = this->evalT(X_val);
auto dtheta_dX = this->gradT(make_dual(X_val));
auto du_dX = this->gradU(X_val);

auto [stress, heat_accumulation, internal_heat_source, heat_flux] = material(state, du_dX, theta, dtheta_dX);
auto dFluxdX = get_gradient(heat_flux);
Expand All @@ -259,13 +259,13 @@ class ManufacturedSolution {
};
tm.setSource(heat_source, tm.mesh().entireBody());

auto body_force = [=](auto X, auto /* time */) {
auto body_force = [this, &material](auto X, auto /* time */) {
typename MaterialType::State state{};

auto X_val = get_value(X);
auto theta = evalT(make_dual(X_val));
auto dtheta_dX = gradT(X_val);
auto du_dX = gradU(make_dual(X_val));
auto theta = this->evalT(make_dual(X_val));
auto dtheta_dX = this->gradT(X_val);
auto du_dX = this->gradU(make_dual(X_val));

auto [stress, heat_accumulation, internal_heat_source, heat_flux] = material(state, du_dX, theta, dtheta_dX);
auto dPdX = get_gradient(stress);
Expand Down
Loading