Skip to content

Commit

Permalink
Address redundant parsers.
Browse files Browse the repository at this point in the history
  • Loading branch information
tupek2 committed Aug 8, 2024
1 parent 8c85261 commit 765219e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 35 deletions.
7 changes: 7 additions & 0 deletions src/serac/physics/solid_mechanics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1758,12 +1758,19 @@ class SolidMechanics<order, dim, Parameters<parameter_space...>, std::integer_se
void warmStartDisplacement(double dt)
{
SERAC_MARK_FUNCTION;

du_ = 0.0;
for (auto& bc : bcs_.essentials()) {
// apply the future boundary conditions, but use the most recent Jacobians stiffness.
bc.setDofs(du_, time_ + dt);
}

auto& constrained_dofs = bcs_.allEssentialTrueDofs();
for (int i = 0; i < constrained_dofs.Size(); i++) {
int j = constrained_dofs[i];
du_[j] -= displacement_(j);
}

if (use_warm_start_ && is_quasistatic_) {
// Update the linearized Jacobian matrix
auto r = (*residual_)(time_ + dt, shape_displacement_, displacement_, acceleration_,
Expand Down
36 changes: 1 addition & 35 deletions src/serac/physics/tests/solid_nonlinear_solve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@
#include "serac/infrastructure/profiling.hpp"
#include "serac/infrastructure/terminator.hpp"

//#include "mesh/vtk.hpp"
//#include <vtkSimplePointsWriter.h>
//#include <vtkSphereSource.h>


using namespace serac;

std::string mesh_path = ".";
Expand Down Expand Up @@ -314,40 +309,11 @@ TEST(SolidMechanics, nonlinear_solve_buckle_easy) { functional_solid_test_nonlin
//TEST(SolidMechanics, nonlinear_solve_buckle_hard) { functional_solid_test_nonlinear_buckle(3e-2); }
//TEST(SolidMechanics, nonlinear_solve_euler) { functional_solid_test_euler(); }

class InputParser
{
public:
InputParser(int& argc, char** argv){
for (int i=1; i < argc; ++i) {
this->tokens.push_back(std::string(argv[i]));
}
}
std::string getCmdOption(const std::string& option) const {
std::vector<std::string>::const_iterator itr;
itr = std::find(this->tokens.begin(), this->tokens.end(), option);
if (itr != this->tokens.end() && ++itr != this->tokens.end()) {
return *itr;
}
static const std::string empty_string("");
return empty_string;
}
bool cmdOptionExists(const std::string& option) const {
return std::find(this->tokens.begin(), this->tokens.end(), option)
!= this->tokens.end();
}
private:
std::vector <std::string> tokens;
};

int main(int argc, char* argv[])
{
InputParser parser(argc, argv);
auto filename = parser.getCmdOption("-p");
if (!filename.empty()) {
mesh_path = filename;
}

axom::CLI::App app{"Nonlinear problems"};
app.add_option("-p", mesh_path, "Mesh file to use")->check(axom::CLI::ExistingFile);
app.add_option("--nonlinear-solver", nonlinSolve, "Nonlinear solver", true);
app.add_option("--preconditioner", prec, "Preconditioner", true);
app.set_help_flag("--help");
Expand Down

0 comments on commit 765219e

Please sign in to comment.