Skip to content
Merged
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
21 changes: 21 additions & 0 deletions include/systems/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -1927,6 +1927,22 @@ class System : public ReferenceCountedObject<System>,
*/
void prefer_hash_table_matrix_assembly(bool preference);

/**
* Instructs this system to prefix solve options with its name for solvers that leverage prefixes
*/
void prefix_with_name(bool value) { _prefix_with_name = value; }

/**
* @returns Whether we are name prefixing
*/
[[nodiscard]] bool prefix_with_name() const { return _prefix_with_name; }

/**
* @returns A prefix that may be applied to solver options. Note that this
* prefix is only used if \p prefix_with_name()
*/
std::string prefix() const { return this->name() + "_"; }

protected:

/**
Expand Down Expand Up @@ -2307,6 +2323,11 @@ class System : public ReferenceCountedObject<System>,
* Whether any of our matrices require an initial sparsity pattern computation in order to determine preallocation
*/
bool _require_sparsity_pattern;

/**
* Whether we are name prefixing solver options
*/
bool _prefix_with_name;
};


Expand Down
4 changes: 2 additions & 2 deletions src/systems/continuation_system.C
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ ContinuationSystem::ContinuationSystem (EquationSystems & es,
// moved.
linear_solver = LinearSolver<Number>::build(es.comm());

if (libMesh::on_command_line("--solver-system-names"))
linear_solver->init((this->name()+"_").c_str());
if (this->prefix_with_name())
linear_solver->init(this->prefix().c_str());
else
linear_solver->init();

Expand Down
4 changes: 2 additions & 2 deletions src/systems/implicit_system.C
Original file line number Diff line number Diff line change
Expand Up @@ -1208,8 +1208,8 @@ LinearSolver<Number> * ImplicitSystem::get_linear_solver() const

linear_solver = LinearSolver<Number>::build(this->comm());

if (libMesh::on_command_line("--solver-system-names"))
linear_solver->init((this->name() + "_").c_str());
if (this->prefix_with_name())
linear_solver->init(this->prefix().c_str());
else
linear_solver->init();

Expand Down
4 changes: 2 additions & 2 deletions src/systems/linear_implicit_system.C
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ void LinearImplicitSystem::solve ()
this->get_equation_systems();

// If the linear solver hasn't been initialized, we do so here.
if (libMesh::on_command_line("--solver-system-names"))
linear_solver->init((this->name()+"_").c_str());
if (this->prefix_with_name())
linear_solver->init(this->prefix().c_str());
else
linear_solver->init();

Expand Down
4 changes: 2 additions & 2 deletions src/systems/nonlinear_implicit_system.C
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ void NonlinearImplicitSystem::solve ()
}
else
{
if (libMesh::on_command_line("--solver-system-names"))
nonlinear_solver->init((this->name()+"_").c_str());
if (this->prefix_with_name())
nonlinear_solver->init(this->prefix().c_str());
else
nonlinear_solver->init();

Expand Down
5 changes: 4 additions & 1 deletion src/systems/system.C
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,11 @@ System::System (EquationSystems & es,
_hide_output (false),
project_with_constraints (true),
_prefer_hash_table_matrix_assembly(false),
_require_sparsity_pattern (false)
_require_sparsity_pattern (false),
_prefix_with_name (false)
{
if (libMesh::on_command_line("--solver-system-names"))
this->prefix_with_name(true);
}


Expand Down