Skip to content

Commit 9b1d4e3

Browse files
authored
Merge pull request #730 from c-p-schmidt/clean-scatra-set-state-methods
Clean scatra set state methods
2 parents a552839 + ae65466 commit 9b1d4e3

30 files changed

+258
-280
lines changed

src/adapter/4C_adapter_scatra_fluid_coupling_algorithm.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,14 @@ void Adapter::ScaTraFluidCouplingAlgorithm::setup()
8484
// transfer the initial convective velocity from initial fluid field to scalar transport field
8585
// subgrid scales not transferred since they are zero at time t=0.0
8686
if (!volcoupl_fluidscatra_)
87-
scatra_field()->set_velocity_field(fluid_field()->convective_vel(), nullptr, nullptr, nullptr);
87+
{
88+
scatra_field()->set_convective_velocity(*fluid_field()->convective_vel());
89+
}
8890
else
89-
scatra_field()->set_velocity_field(
90-
volcoupl_fluidscatra_->apply_vector_mapping21(*fluid_field()->convective_vel()), nullptr,
91-
nullptr, nullptr);
91+
{
92+
scatra_field()->set_convective_velocity(
93+
*volcoupl_fluidscatra_->apply_vector_mapping21(*fluid_field()->convective_vel()));
94+
}
9295

9396
// ensure that both single field solvers use the same
9497
// time integration scheme

src/elch/4C_elch_dyn.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ void elch_dyn(int restart)
108108
if (restart) scatraonly.scatra_field()->read_restart(restart);
109109

110110
// set velocity field
111-
// note: The order read_restart() before set_velocity_field() is important here!!
112-
// for time-dependent velocity fields, set_velocity_field() is additionally called in each
113-
// prepare_time_step()-call
114-
scatraonly.scatra_field()->set_velocity_field();
111+
// note: The order read_restart() before set_velocity_field_from_function() is important
112+
// here!! for time-dependent velocity fields, set_velocity_field_from_function() is
113+
// additionally called in each prepare_time_step()-call
114+
scatraonly.scatra_field()->set_velocity_field_from_function();
115115

116116
// enter time loop to solve problem with given convective velocity
117117
scatraonly.scatra_field()->time_loop();

src/elch/4C_elch_moving_boundary_algorithm.cpp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void ElCh::MovingBoundaryAlgorithm::setup()
8181
}
8282

8383
// transfer moving mesh data
84-
scatra_field()->apply_mesh_movement(ale_field()->dispnp());
84+
scatra_field()->apply_mesh_movement(*ale_field()->dispnp());
8585

8686
// initialize the multivector for all possible cases
8787
fluxn_ = scatra_field()->calc_flux_at_boundary(false);
@@ -111,12 +111,13 @@ void ElCh::MovingBoundaryAlgorithm::time_loop()
111111
if (not pseudotransient_)
112112
{
113113
// transfer convective velocity = fluid velocity - grid velocity
114-
scatra_field()->set_velocity_field(fluid_field()->convective_vel(), // = velnp - grid velocity
115-
fluid_field()->hist(), nullptr, nullptr);
114+
scatra_field()->set_convective_velocity(*fluid_field()->convective_vel());
115+
scatra_field()->set_velocity_field(*fluid_field()->convective_vel());
116+
scatra_field()->set_acceleration_field(*fluid_field()->hist());
116117
}
117118

118119
// transfer moving mesh data
119-
scatra_field()->apply_mesh_movement(ale_field()->dispnp());
120+
scatra_field()->apply_mesh_movement(*ale_field()->dispnp());
120121

121122
// time loop
122123
while (not_finished())
@@ -248,37 +249,35 @@ void ElCh::MovingBoundaryAlgorithm::solve_scatra()
248249
{
249250
if (Core::Communication::my_mpi_rank(get_comm()) == 0)
250251
{
251-
std::cout << std::endl;
252-
std::cout << "************************" << std::endl;
253-
std::cout << " ELCH SOLVER " << std::endl;
254-
std::cout << "************************" << std::endl;
252+
std::cout << '\n';
253+
std::cout << "************************" << '\n';
254+
std::cout << " ELCH SOLVER " << '\n';
255+
std::cout << "************************" << '\n';
255256
}
256257

257258
switch (fluid_field()->tim_int_scheme())
258259
{
259260
case Inpar::FLUID::timeint_npgenalpha:
260261
case Inpar::FLUID::timeint_afgenalpha:
261262
FOUR_C_THROW("ConvectiveVel() not implemented for Gen.Alpha versions");
262-
break;
263263
case Inpar::FLUID::timeint_one_step_theta:
264264
case Inpar::FLUID::timeint_bdf2:
265265
{
266266
if (not pseudotransient_)
267267
{
268268
// transfer convective velocity = fluid velocity - grid velocity
269-
scatra_field()->set_velocity_field(
270-
fluid_field()->convective_vel(), // = velnp - grid velocity
271-
fluid_field()->hist(), nullptr, nullptr);
269+
scatra_field()->set_convective_velocity(*fluid_field()->convective_vel());
270+
scatra_field()->set_velocity_field(*fluid_field()->convective_vel());
271+
scatra_field()->set_acceleration_field(*fluid_field()->hist());
272272
}
273273
}
274274
break;
275275
default:
276276
FOUR_C_THROW("Time integration scheme not supported");
277-
break;
278277
}
279278

280279
// transfer moving mesh data
281-
scatra_field()->apply_mesh_movement(ale_field()->dispnp());
280+
scatra_field()->apply_mesh_movement(*ale_field()->dispnp());
282281

283282
// solve coupled electrochemistry equations
284283
scatra_field()->solve();

src/fs3i/4C_fs3i_fps3i_partitioned.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -615,11 +615,11 @@ void FS3I::PartFPS3I::set_struct_scatra_solution()
615615
void FS3I::PartFPS3I::set_mesh_disp()
616616
{
617617
// fluid field
618-
scatravec_[0]->scatra_field()->apply_mesh_movement(fpsi_->fluid_field()->dispnp());
618+
scatravec_[0]->scatra_field()->apply_mesh_movement(*fpsi_->fluid_field()->dispnp());
619619

620620
// Poro field
621621
scatravec_[1]->scatra_field()->apply_mesh_movement(
622-
fpsi_->poro_field()->structure_field()->dispnp());
622+
*fpsi_->poro_field()->structure_field()->dispnp());
623623
}
624624

625625

@@ -637,10 +637,9 @@ void FS3I::PartFPS3I::set_velocity_fields()
637637
case Inpar::ScaTra::velocity_zero:
638638
case Inpar::ScaTra::velocity_function:
639639
{
640-
for (unsigned i = 0; i < scatravec_.size(); ++i)
640+
for (auto scatra : scatravec_)
641641
{
642-
std::shared_ptr<Adapter::ScaTraBaseAlgorithm> scatra = scatravec_[i];
643-
scatra->scatra_field()->set_velocity_field();
642+
scatra->scatra_field()->set_velocity_field_from_function();
644643
}
645644
break;
646645
}
@@ -652,8 +651,8 @@ void FS3I::PartFPS3I::set_velocity_fields()
652651

653652
for (unsigned i = 0; i < scatravec_.size(); ++i)
654653
{
655-
std::shared_ptr<Adapter::ScaTraBaseAlgorithm> scatra = scatravec_[i];
656-
scatra->scatra_field()->set_velocity_field(convel[i], nullptr, vel[i], nullptr);
654+
scatravec_[i]->scatra_field()->set_convective_velocity(*convel[i]);
655+
scatravec_[i]->scatra_field()->set_velocity_field(*vel[i]);
657656
}
658657
break;
659658
}
@@ -671,7 +670,7 @@ void FS3I::PartFPS3I::set_wall_shear_stresses()
671670
for (unsigned i = 0; i < scatravec_.size(); ++i)
672671
{
673672
std::shared_ptr<Adapter::ScaTraBaseAlgorithm> scatra = scatravec_[i];
674-
scatra->scatra_field()->set_wall_shear_stresses(wss[i]);
673+
scatra->scatra_field()->set_wall_shear_stresses(*wss[i]);
675674
}
676675
}
677676

@@ -686,7 +685,7 @@ void FS3I::PartFPS3I::set_pressure_fields()
686685
for (unsigned i = 0; i < scatravec_.size(); ++i)
687686
{
688687
std::shared_ptr<Adapter::ScaTraBaseAlgorithm> scatra = scatravec_[i];
689-
scatra->scatra_field()->set_pressure_field(pressure[i]);
688+
scatra->scatra_field()->set_pressure_field(*pressure[i]);
690689
}
691690
}
692691

src/fs3i/4C_fs3i_partitioned.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -683,12 +683,12 @@ void FS3I::PartFS3I::set_mesh_disp() const
683683
// fluid field
684684
std::shared_ptr<Adapter::ScaTraBaseAlgorithm> fluidscatra = scatravec_[0];
685685
fluidscatra->scatra_field()->apply_mesh_movement(
686-
fluid_to_fluid_scalar(fsi_->fluid_field()->dispnp()));
686+
*fluid_to_fluid_scalar(fsi_->fluid_field()->dispnp()));
687687

688688
// structure field
689689
std::shared_ptr<Adapter::ScaTraBaseAlgorithm> structscatra = scatravec_[1];
690690
structscatra->scatra_field()->apply_mesh_movement(
691-
structure_to_structure_scalar(fsi_->structure_field()->dispnp()));
691+
*structure_to_structure_scalar(fsi_->structure_field()->dispnp()));
692692
}
693693

694694

@@ -702,9 +702,9 @@ void FS3I::PartFS3I::set_velocity_fields() const
702702

703703
for (unsigned i = 0; i < scatravec_.size(); ++i)
704704
{
705-
std::shared_ptr<Adapter::ScaTraBaseAlgorithm> scatra = scatravec_[i];
706-
scatra->scatra_field()->set_velocity_field(vol_mortar_master_to_slavei(i, convel[i]), nullptr,
707-
vol_mortar_master_to_slavei(i, vel[i]), nullptr);
705+
scatravec_[i]->scatra_field()->set_convective_velocity(
706+
*vol_mortar_master_to_slavei(i, convel[i]));
707+
scatravec_[i]->scatra_field()->set_velocity_field(*vol_mortar_master_to_slavei(i, vel[i]));
708708
}
709709
}
710710

@@ -762,7 +762,7 @@ void FS3I::PartFS3I::set_wall_shear_stresses() const
762762
for (unsigned i = 0; i < scatravec_.size(); ++i)
763763
{
764764
std::shared_ptr<Adapter::ScaTraBaseAlgorithm> scatra = scatravec_[i];
765-
scatra->scatra_field()->set_wall_shear_stresses(vol_mortar_master_to_slavei(i, wss[i]));
765+
scatra->scatra_field()->set_wall_shear_stresses(*vol_mortar_master_to_slavei(i, wss[i]));
766766
}
767767
}
768768

src/fs3i/4C_fs3i_partitioned_2wc.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ void FS3I::PartFS3I2Wc::initial_calculations()
103103
{
104104
// set initial fluid velocity field for evaluation of initial scalar
105105
// time derivative in fluid-based scalar transport
106-
scatravec_[0]->scatra_field()->set_velocity_field(
107-
fsi_->fluid_field()->velnp(), nullptr, nullptr, nullptr);
106+
scatravec_[0]->scatra_field()->set_convective_velocity(*fsi_->fluid_field()->velnp());
108107

109108
// set initial value of thermodynamic pressure in fluid-based scalar
110109
// transport

src/levelset/4C_levelset_algorithm.hpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,6 @@ namespace ScaTra
6666
//! set the velocity field (zero or field by function) (pure level-set problems)
6767
void set_velocity_field(bool init = false);
6868

69-
/// set convective velocity field (+ pressure and acceleration field as
70-
/// well as fine-scale velocity field, if required) (function for coupled fluid problems)
71-
void set_velocity_field(std::shared_ptr<const Core::LinAlg::Vector<double>> convvel,
72-
std::shared_ptr<const Core::LinAlg::Vector<double>> acc,
73-
std::shared_ptr<const Core::LinAlg::Vector<double>> vel,
74-
std::shared_ptr<const Core::LinAlg::Vector<double>> fsvel, bool setpressure = false,
75-
bool init = false);
76-
77-
7869
// output position of center of mass assuming a smoothed interfaces
7970
void mass_center_using_smoothing();
8071

src/levelset/4C_levelset_algorithm_utils.cpp

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ FOUR_C_NAMESPACE_OPEN
2929
void ScaTra::LevelSetAlgorithm::set_velocity_field(bool init)
3030
{
3131
// call function of base class
32-
ScaTraTimIntImpl::set_velocity_field();
32+
ScaTraTimIntImpl::set_velocity_field_from_function();
3333

3434
// note: This function is only called from the level-set dyn. This is ok, since
3535
// we only want to initialize conveln_ at the beginning of the simulation.
@@ -38,29 +38,6 @@ void ScaTra::LevelSetAlgorithm::set_velocity_field(bool init)
3838
}
3939

4040

41-
/*----------------------------------------------------------------------*
42-
| set convective velocity field (+ pressure and acceleration field as |
43-
| well as fine-scale velocity field, if required) rasthofer 11/13 |
44-
*----------------------------------------------------------------------*/
45-
void ScaTra::LevelSetAlgorithm::set_velocity_field(
46-
std::shared_ptr<const Core::LinAlg::Vector<double>> convvel,
47-
std::shared_ptr<const Core::LinAlg::Vector<double>> acc,
48-
std::shared_ptr<const Core::LinAlg::Vector<double>> vel,
49-
std::shared_ptr<const Core::LinAlg::Vector<double>> fsvel, bool setpressure, bool init)
50-
{
51-
// call routine of base class
52-
ScaTraTimIntImpl::set_velocity_field(convvel, acc, vel, fsvel, setpressure);
53-
54-
// manipulate velocity field away from the interface
55-
if (extract_interface_vel_) manipulate_fluid_field_for_gfunc();
56-
57-
// estimate velocity at contact points, i.e., intersection points of interface and (no-slip) walls
58-
if (cpbc_) apply_contact_point_boundary_condition();
59-
60-
return;
61-
}
62-
63-
6441
/*----------------------------------------------------------------------*
6542
| add problem depended params for assemble_mat_and_rhs rasthofer 09/13 |
6643
*----------------------------------------------------------------------*/

src/loma/4C_loma_algorithm.cpp

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,13 @@ void LowMach::Algorithm::time_loop()
311311
/*----------------------------------------------------------------------*/
312312
void LowMach::Algorithm::initial_calculations()
313313
{
314-
// set initial velocity field for evaluation of initial scalar time
315-
// derivative in SCATRA
316-
scatra_field()->set_velocity_field(
317-
fluid_field()->velnp(), nullptr, nullptr, fluid_field()->fs_vel());
314+
// set initial velocity field for evaluation of initial scalar time derivative in SCATRA
315+
scatra_field()->set_convective_velocity(*fluid_field()->velnp());
316+
scatra_field()->set_velocity_field(*fluid_field()->velnp());
317+
if (scatra_field()->fine_scale_velocity_field_required())
318+
{
319+
scatra_field()->set_fine_scale_velocity(*fluid_field()->fs_vel());
320+
}
318321

319322
// set initial value of thermodynamic pressure in SCATRA
320323
std::dynamic_pointer_cast<ScaTra::ScaTraTimIntLoma>(scatra_field())->set_initial_therm_pressure();
@@ -328,11 +331,6 @@ void LowMach::Algorithm::initial_calculations()
328331
fluid_field()->set_scalar_fields(scatra_field()->phinp(),
329332
std::dynamic_pointer_cast<ScaTra::ScaTraTimIntLoma>(scatra_field())->therm_press_np(),
330333
nullptr, scatra_field()->discretization());
331-
332-
// write initial fields
333-
// output();
334-
335-
return;
336334
}
337335

338336

@@ -532,8 +530,6 @@ void LowMach::Algorithm::mono_loop()
532530
// check convergence and stop iteration loop if convergence is achieved
533531
stopnonliniter = convergence_check(itnum);
534532
}
535-
536-
return;
537533
}
538534

539535

@@ -547,22 +543,32 @@ void LowMach::Algorithm::set_fluid_values_in_scatra()
547543
{
548544
case Inpar::FLUID::timeint_afgenalpha:
549545
{
550-
scatra_field()->set_velocity_field(
551-
fluid_field()->velaf(), fluid_field()->accam(), nullptr, fluid_field()->fs_vel(), true);
546+
scatra_field()->set_acceleration_field(*fluid_field()->accam());
547+
scatra_field()->set_convective_velocity(*fluid_field()->velaf());
548+
scatra_field()->set_velocity_field(*fluid_field()->velaf());
549+
if (scatra_field()->fine_scale_velocity_field_required() and
550+
fluid_field()->fs_vel() != nullptr)
551+
{
552+
scatra_field()->set_fine_scale_velocity(*fluid_field()->fs_vel());
553+
}
552554
}
553555
break;
554556
case Inpar::FLUID::timeint_one_step_theta:
555557
case Inpar::FLUID::timeint_bdf2:
556558
{
557-
scatra_field()->set_velocity_field(
558-
fluid_field()->velnp(), fluid_field()->hist(), nullptr, fluid_field()->fs_vel(), true);
559+
scatra_field()->set_acceleration_field(*fluid_field()->hist());
560+
scatra_field()->set_convective_velocity(*fluid_field()->velnp());
561+
scatra_field()->set_velocity_field(*fluid_field()->velnp());
562+
if (scatra_field()->fine_scale_velocity_field_required() and
563+
fluid_field()->fs_vel() != nullptr)
564+
{
565+
scatra_field()->set_fine_scale_velocity(*fluid_field()->fs_vel());
566+
}
559567
}
560568
break;
561569
default:
562570
FOUR_C_THROW("Time integration scheme not supported");
563-
break;
564571
}
565-
return;
566572
}
567573

568574

src/loma/4C_loma_dyn.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ void loma_dyn(int restart)
104104
if (restart) (scatraonly.scatra_field())->read_restart(restart);
105105

106106
// set initial velocity field
107-
// note: The order read_restart() before set_velocity_field() is important here!!
108-
// for time-dependent velocity fields, set_velocity_field() is additionally called in each
109-
// prepare_time_step()-call
110-
(scatraonly.scatra_field())->set_velocity_field();
107+
// note: The order read_restart() before set_velocity_field_from_function() is important
108+
// here!! for time-dependent velocity fields, set_velocity_field_from_function() is
109+
// additionally called in each prepare_time_step()-call
110+
(scatraonly.scatra_field())->set_velocity_field_from_function();
111111

112112
// enter time loop to solve problem with given convective velocity field
113113
(scatraonly.scatra_field())->time_loop();

0 commit comments

Comments
 (0)