Skip to content

Commit

Permalink
Apply style updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Agent Style committed Jan 29, 2025
1 parent f3520cb commit 7824276
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/serac/numerics/equation_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ namespace serac {

/// @brief A simple exception class for recording Newton and TrustRegion failures
class SolverException : public std::exception {
public:
public:
/// constructor
SolverException(const std::string& message) : msg(message) {}

/// the message returned by the exception
const char* what() const noexcept override { return msg.c_str(); }

private:
private:
/// message string
std::string msg;
};
Expand Down
12 changes: 8 additions & 4 deletions src/serac/physics/solid_mechanics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ class SolidMechanics<order, dim, Parameters<parameter_space...>, std::integer_se
bool checkpoint_to_disk = false, bool use_warm_start = true, int max_timestep_cutbacks = 5)
: SolidMechanics(
std::make_unique<EquationSolver>(nonlinear_opts, lin_opts, StateManager::mesh(mesh_tag).GetComm()),
timestepping_opts, physics_name, mesh_tag, parameter_names, cycle, time, checkpoint_to_disk, use_warm_start, max_timestep_cutbacks)
timestepping_opts, physics_name, mesh_tag, parameter_names, cycle, time, checkpoint_to_disk, use_warm_start,
max_timestep_cutbacks)
{
}

Expand All @@ -164,7 +165,8 @@ class SolidMechanics<order, dim, Parameters<parameter_space...>, std::integer_se
*/
SolidMechanics(std::unique_ptr<serac::EquationSolver> solver, const serac::TimesteppingOptions timestepping_opts,
const std::string& physics_name, std::string mesh_tag, std::vector<std::string> parameter_names = {},
int cycle = 0, double time = 0.0, bool checkpoint_to_disk = false, bool use_warm_start = true, int max_timestep_cutbacks = 5)
int cycle = 0, double time = 0.0, bool checkpoint_to_disk = false, bool use_warm_start = true,
int max_timestep_cutbacks = 5)
: BasePhysics(physics_name, mesh_tag, cycle, time, checkpoint_to_disk),
displacement_(
StateManager::newState(H1<order, dim>{}, detail::addPrefix(physics_name, "displacement"), mesh_tag_)),
Expand Down Expand Up @@ -1532,7 +1534,7 @@ class SolidMechanics<order, dim, Parameters<parameter_space...>, std::integer_se
return;
}

static constexpr bool solver_info_print=false;
static constexpr bool solver_info_print = false;

bool solver_success = true;
try {
Expand All @@ -1542,7 +1544,9 @@ class SolidMechanics<order, dim, Parameters<parameter_space...>, std::integer_se
warmStartDisplacement(dt, step_fraction_of_dt_to_try);
nonlin_solver_->solve(displacement_);
} catch (const std::exception& e) {
if (mpi_rank_ == 0 && solver_info_print) { mfem::out << "Caught nonlinear solver exception: " << e.what() << std::endl; }
if (mpi_rank_ == 0 && solver_info_print) {
mfem::out << "Caught nonlinear solver exception: " << e.what() << std::endl;
}
displacement_ -= du_;
solver_success = false;
quasiStaticSolve(dt, 0.5 * step_fraction_of_dt_to_try, level + 1);
Expand Down
13 changes: 7 additions & 6 deletions src/serac/physics/tests/solid_statics_patch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,20 +307,21 @@ double pressure_error()
Domain material_block = EntireDomain(pmesh);
Domain boundary = EntireBoundary(pmesh);

// Construct a solid mechanics solver
// Construct a solid mechanics solver
serac::NonlinearSolverOptions nonlin_solver_options{
.nonlin_solver = NonlinearSolver::Newton, .relative_tol = 0.0, .absolute_tol = 1.0e-14, .max_iterations = 30};

LinearSolverOptions cg_solver_options{.linear_solver = LinearSolver::CG,
LinearSolverOptions cg_solver_options{.linear_solver = LinearSolver::CG,
.preconditioner = Preconditioner::HypreJacobi,
.relative_tol = 1.0e-6,
.absolute_tol = 1.0e-16,
.relative_tol = 1.0e-6,
.absolute_tol = 1.0e-16,
.max_iterations = 500,
.print_level = 0};
.print_level = 0};

auto equation_solver = std::make_unique<EquationSolver>(nonlin_solver_options, cg_solver_options, pmesh.GetComm());

SolidMechanics<p, dim> solid(std::move(equation_solver), solid_mechanics::default_quasistatic_options, "solid", mesh_tag, std::vector<std::string>{}, 0, 0.0, false, true, 2);
SolidMechanics<p, dim> solid(std::move(equation_solver), solid_mechanics::default_quasistatic_options, "solid",
mesh_tag, std::vector<std::string>{}, 0, 0.0, false, true, 2);

solid_mechanics::NeoHookean mat{.density = 1.0, .K = 1.0, .G = 1.0};

Expand Down

0 comments on commit 7824276

Please sign in to comment.