Skip to content

Commit da343d2

Browse files
authored
Merge pull request #695 from vovannikov/nln_solver_rename_solution_group
Some refactoring of the group related methods in nonlinear solvers
2 parents 3e1f4ff + 6a88e4d commit da343d2

9 files changed

+13
-37
lines changed

src/fsi/src/partitioned/model_evaluator/4C_fsi_str_model_evaluator_partitioned.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ Solid::ModelEvaluator::PartitionedFSI::solve_relaxation_linear(
122122
const_cast<Solid::Nln::SOLVER::Generic&>(*(ti_impl->get_nln_solver_ptr()));
123123

124124
// get the solution group
125-
::NOX::Abstract::Group& grp = nlnsolver.solution_group();
125+
::NOX::Abstract::Group& grp = nlnsolver.get_solution_group();
126126
NOX::Nln::Group* grp_ptr = dynamic_cast<NOX::Nln::Group*>(&grp);
127127
if (grp_ptr == nullptr) FOUR_C_THROW("Dynamic cast failed!");
128128

src/structure_new/src/explicit/4C_structure_new_timint_explicit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ void Solid::TimeInt::Explicit::evaluate()
109109
{
110110
check_init_setup();
111111
throw_if_state_not_in_sync_with_nox_group();
112-
::NOX::Abstract::Group& grp = nln_solver().solution_group();
112+
::NOX::Abstract::Group& grp = nln_solver().get_solution_group();
113113

114114
auto* grp_ptr = dynamic_cast<NOX::Nln::Group*>(&grp);
115115
if (grp_ptr == nullptr) FOUR_C_THROW("Dynamic cast failed!");

src/structure_new/src/implicit/4C_structure_new_timint_implicit.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void Solid::TimeInt::Implicit::set_state(const std::shared_ptr<Core::LinAlg::Vec
8484
integrator_ptr()->set_state(*x);
8585
::NOX::Epetra::Vector x_nox(
8686
Teuchos::rcpFromRef(*x->get_ptr_of_epetra_vector()), ::NOX::Epetra::Vector::CreateView);
87-
nln_solver().solution_group().setX(x_nox);
87+
nln_solver().get_solution_group().setX(x_nox);
8888
set_state_in_sync_with_nox_group(true);
8989
}
9090

@@ -109,7 +109,7 @@ void Solid::TimeInt::Implicit::prepare_time_step()
109109
double& time_np = data_global_state().get_time_np();
110110
time_np = data_global_state().get_time_n() + (*data_global_state().get_delta_time())[0]; */
111111

112-
::NOX::Abstract::Group& grp = nln_solver().solution_group();
112+
::NOX::Abstract::Group& grp = nln_solver().get_solution_group();
113113
predictor().predict(grp);
114114
}
115115

@@ -130,7 +130,7 @@ int Solid::TimeInt::Implicit::integrate_step()
130130
{
131131
check_init_setup();
132132
// do the predictor step
133-
::NOX::Abstract::Group& grp = nln_solver().solution_group();
133+
::NOX::Abstract::Group& grp = nln_solver().get_solution_group();
134134
predictor().predict(grp);
135135
return solve();
136136
}
@@ -158,7 +158,7 @@ void Solid::TimeInt::Implicit::update_state_incrementally(
158158

159159
check_init_setup();
160160
throw_if_state_not_in_sync_with_nox_group();
161-
::NOX::Abstract::Group& grp = nln_solver().solution_group();
161+
::NOX::Abstract::Group& grp = nln_solver().get_solution_group();
162162

163163
auto* grp_ptr = dynamic_cast<NOX::Nln::Group*>(&grp);
164164
FOUR_C_ASSERT(grp_ptr != nullptr, "Dynamic cast failed!");
@@ -202,7 +202,7 @@ void Solid::TimeInt::Implicit::evaluate()
202202
{
203203
check_init_setup();
204204
throw_if_state_not_in_sync_with_nox_group();
205-
::NOX::Abstract::Group& grp = nln_solver().solution_group();
205+
::NOX::Abstract::Group& grp = nln_solver().get_solution_group();
206206

207207
auto* grp_ptr = dynamic_cast<NOX::Nln::Group*>(&grp);
208208
FOUR_C_ASSERT(grp_ptr != nullptr, "Dynamic cast failed!");
@@ -225,14 +225,6 @@ const ::NOX::Abstract::Group& Solid::TimeInt::Implicit::get_solution_group() con
225225
return nln_solver().get_solution_group();
226226
}
227227

228-
/*----------------------------------------------------------------------------*
229-
*----------------------------------------------------------------------------*/
230-
std::shared_ptr<::NOX::Abstract::Group> Solid::TimeInt::Implicit::solution_group_ptr()
231-
{
232-
check_init_setup();
233-
return Core::Utils::shared_ptr_from_ref(nln_solver().solution_group());
234-
}
235-
236228
/*----------------------------------------------------------------------------*
237229
*----------------------------------------------------------------------------*/
238230
Inpar::Solid::ConvergenceStatus Solid::TimeInt::Implicit::perform_error_action(

src/structure_new/src/implicit/4C_structure_new_timint_implicit.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,6 @@ namespace Solid
129129
//! returns the current solution group
130130
[[nodiscard]] const ::NOX::Abstract::Group& get_solution_group() const override;
131131

132-
//! returns the current solution group ptr
133-
std::shared_ptr<::NOX::Abstract::Group> solution_group_ptr() override;
134-
135132
Solid::IMPLICIT::Generic& impl_int()
136133
{
137134
check_init_setup();

src/structure_new/src/implicit/4C_structure_new_timint_implicitbase.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,6 @@ namespace Solid
8888
protected:
8989
/// Returns the current solution group (pure virtual)
9090
virtual const ::NOX::Abstract::Group& get_solution_group() const = 0;
91-
92-
//! Returns the current solution group ptr
93-
virtual std::shared_ptr<::NOX::Abstract::Group> solution_group_ptr() = 0;
9491
};
9592
} // namespace TimeInt
9693
} // namespace Solid

src/structure_new/src/nonlinear_solver/4C_structure_new_nln_solver_generic.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,14 @@ Teuchos::RCP<::NOX::Abstract::Group>& Solid::Nln::SOLVER::Generic::group_ptr()
6161

6262
/*----------------------------------------------------------------------------*
6363
*----------------------------------------------------------------------------*/
64-
::NOX::Abstract::Group& Solid::Nln::SOLVER::Generic::group()
64+
::NOX::Abstract::Group& Solid::Nln::SOLVER::Generic::get_solution_group()
6565
{
66-
check_init();
66+
check_init_setup();
6767
FOUR_C_ASSERT(group_ptr_, "The group pointer should be initialized beforehand!");
68+
6869
return *group_ptr_;
6970
}
7071

71-
/*----------------------------------------------------------------------------*
72-
*----------------------------------------------------------------------------*/
73-
::NOX::Abstract::Group& Solid::Nln::SOLVER::Generic::solution_group() { return group(); }
74-
7572
/*----------------------------------------------------------------------------*
7673
*----------------------------------------------------------------------------*/
7774
const ::NOX::Abstract::Group& Solid::Nln::SOLVER::Generic::get_solution_group() const

src/structure_new/src/nonlinear_solver/4C_structure_new_nln_solver_generic.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ namespace Solid
8181
*
8282
* The nox group has to be initialized in one of the derived setup() routines beforehand.
8383
*/
84-
::NOX::Abstract::Group& solution_group();
84+
::NOX::Abstract::Group& get_solution_group();
8585
const ::NOX::Abstract::Group& get_solution_group() const;
8686

8787
//! Get the number of nonlinear iterations
@@ -188,7 +188,6 @@ namespace Solid
188188
/*! returns the nox group (pointer) (only for internal use)
189189
*
190190
* The nox group has to be initialized in one of the derived setup() routines. */
191-
::NOX::Abstract::Group& group();
192191
Teuchos::RCP<::NOX::Abstract::Group>& group_ptr();
193192

194193
protected:

src/structure_new/src/nonlinear_solver/4C_structure_new_nln_solver_nox.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,6 @@ enum Inpar::Solid::ConvergenceStatus Solid::Nln::SOLVER::Nox::solve()
197197
if (data_sdyn().get_divergence_action() == Inpar::Solid::divcont_stop)
198198
problem_->check_final_status(finalstatus);
199199

200-
// copy the solution group into the class variable
201-
group() = nlnsolver_->getSolutionGroup();
202-
203200
return convert_final_status(finalstatus);
204201
}
205202

src/structure_new/src/nonlinear_solver/4C_structure_new_nln_solver_singlestep.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ enum Inpar::Solid::ConvergenceStatus Solid::Nln::SOLVER::SingleStep::solve()
104104
{
105105
check_init_setup();
106106

107-
auto& nln_group = dynamic_cast<NOX::Nln::Group&>(group());
107+
auto& nln_group = dynamic_cast<NOX::Nln::Group&>(*group_ptr());
108108

109-
const auto& x_epetra = dynamic_cast<const ::NOX::Epetra::Vector&>(group().getX());
109+
const auto& x_epetra = dynamic_cast<const ::NOX::Epetra::Vector&>(group_ptr()->getX());
110110

111111
nln_group.set_is_valid_newton(true); // to circumvent the check in ::NOX::Solver::SingleStep
112112
nln_group.set_is_valid_rhs(false); // force to compute the RHS
@@ -115,9 +115,6 @@ enum Inpar::Solid::ConvergenceStatus Solid::Nln::SOLVER::SingleStep::solve()
115115
//// do one non-linear step using solve
116116
::NOX::StatusTest::StatusType stepstatus = nlnsolver_->solve();
117117

118-
// copy the solution group into the class variable
119-
group() = nlnsolver_->getSolutionGroup();
120-
121118
integrator().set_state(Core::LinAlg::Vector<double>(x_epetra.getEpetraVector()));
122119

123120
return convert_final_status(stepstatus);

0 commit comments

Comments
 (0)