Skip to content

Commit

Permalink
Manage string GS identifiers in SystemSolver class only.
Browse files Browse the repository at this point in the history
  • Loading branch information
pelesh committed Mar 21, 2024
1 parent db62874 commit 4e67be2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 47 deletions.
26 changes: 0 additions & 26 deletions resolve/GramSchmidt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,32 +48,6 @@ namespace ReSolve
return 0;
}

int GramSchmidt::setVariant(std::string variant)
{
if (setup_complete_) {
freeGramSchmidtData();
setup_complete_ = false;
}

if (variant == "cgs2") {
variant_ = GramSchmidt::cgs2;
} else if (variant == "mgs") {
variant_ = GramSchmidt::mgs;
} else if (variant == "mgs_two_synch") {
variant_ = GramSchmidt::mgs_two_synch;
} else if (variant == "mgs_pm") {
variant_ = GramSchmidt::mgs_pm;
} else if (variant == "cgs1") {
variant_ = GramSchmidt::cgs1;
} else {
out::warning() << "Gram-Schmidt variant " << variant << " not recognized.\n";
out::warning() << "Using default cgs2 Gram-Schmidt variant.\n";
variant_ = GramSchmidt::cgs2;
}

return 0;
}

GramSchmidt::GSVariant GramSchmidt::getVariant()
{
return variant_;
Expand Down
1 change: 0 additions & 1 deletion resolve/GramSchmidt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace ReSolve
GramSchmidt(VectorHandler* vh, GSVariant variant);
~GramSchmidt();
int setVariant(GramSchmidt::GSVariant variant);
int setVariant(std::string variant);
GSVariant getVariant();
real_type* getL(); //only for low synch, returns null ptr otherwise

Expand Down
2 changes: 1 addition & 1 deletion resolve/LinSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ namespace ReSolve
return flexible_;
}

int LinSolverIterative::setOrthogonalization(GramSchmidt* gs)
int LinSolverIterative::setOrthogonalization(GramSchmidt* /* gs */)
{
out::error() << "Solver does not implement setting orthogonalization.\n";
return 1;
Expand Down
40 changes: 21 additions & 19 deletions resolve/SystemSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -756,28 +756,30 @@ namespace ReSolve
// Private methods
//

int SystemSolver::setGramSchmidtMethod(std::string gsMethod)
int SystemSolver::setGramSchmidtMethod(std::string variant)
{
if (gs_ != nullptr) {
gs_->setVariant(gsMethod);
return 0;
}

if (gsMethod == "cgs2") {
gs_ = new GramSchmidt(vectorHandler_, GramSchmidt::cgs2);
} else if (gsMethod == "mgs") {
gs_ = new GramSchmidt(vectorHandler_, GramSchmidt::mgs);
} else if (gsMethod == "mgs_two_synch") {
gs_ = new GramSchmidt(vectorHandler_, GramSchmidt::mgs_two_synch);
} else if (gsMethod == "mgs_pm") {
gs_ = new GramSchmidt(vectorHandler_, GramSchmidt::mgs_pm);
} else if (gsMethod == "cgs1") {
gs_ = new GramSchmidt(vectorHandler_, GramSchmidt::cgs1);
// Map string input to the Gram-Schmidt variant enum
GramSchmidt::GSVariant gs_variant;
if (variant == "cgs2") {
gs_variant = GramSchmidt::cgs2;
} else if (variant == "mgs") {
gs_variant = GramSchmidt::mgs;
} else if (variant == "mgs_two_synch") {
gs_variant = GramSchmidt::mgs_two_synch;
} else if (variant == "mgs_pm") {
gs_variant = GramSchmidt::mgs_pm;
} else if (variant == "cgs1") {
gs_variant = GramSchmidt::cgs1;
} else {
out::warning() << "Gram-Schmidt variant " << gsMethod_ << " not recognized.\n";
out::warning() << "Gram-Schmidt variant " << variant << " not recognized.\n";
out::warning() << "Using default cgs2 Gram-Schmidt variant.\n";
gs_ = new GramSchmidt(vectorHandler_, GramSchmidt::cgs2);
gsMethod_ = "cgs2";
gs_variant = GramSchmidt::cgs2;
}

if (gs_) {
gs_->setVariant(gs_variant);
} else {
gs_ = new GramSchmidt(vectorHandler_, gs_variant);
}

return 0;
Expand Down

0 comments on commit 4e67be2

Please sign in to comment.