Skip to content

Commit e329f50

Browse files
committed
Move setting of convective velocity
to dedicated method and use const reference instead of shared pointer
1 parent b09d435 commit e329f50

12 files changed

+84
-76
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_moving_boundary_algorithm.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,9 @@ 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(
116+
fluid_field()->hist(), fluid_field()->convective_vel(), nullptr);
116117
}
117118

118119
// transfer moving mesh data
@@ -248,33 +249,31 @@ 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_convective_velocity(*fluid_field()->convective_vel());
269270
scatra_field()->set_velocity_field(
270-
fluid_field()->convective_vel(), // = velnp - grid velocity
271-
fluid_field()->hist(), nullptr, nullptr);
271+
fluid_field()->hist(), fluid_field()->convective_vel(), nullptr);
272272
}
273273
}
274274
break;
275275
default:
276276
FOUR_C_THROW("Time integration scheme not supported");
277-
break;
278277
}
279278

280279
// transfer moving mesh data

src/fs3i/4C_fs3i_fps3i_partitioned.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,8 +651,8 @@ void FS3I::PartFPS3I::set_velocity_fields()
651651

652652
for (unsigned i = 0; i < scatravec_.size(); ++i)
653653
{
654-
std::shared_ptr<Adapter::ScaTraBaseAlgorithm> scatra = scatravec_[i];
655-
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(nullptr, vel[i], nullptr);
656656
}
657657
break;
658658
}

src/fs3i/4C_fs3i_partitioned.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -702,9 +702,10 @@ 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(
708+
nullptr, vol_mortar_master_to_slavei(i, vel[i]), nullptr);
708709
}
709710
}
710711

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/loma/4C_loma_algorithm.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,9 @@ 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(nullptr, fluid_field()->velnp(), fluid_field()->fs_vel());
318317

319318
// set initial value of thermodynamic pressure in SCATRA
320319
std::dynamic_pointer_cast<ScaTra::ScaTraTimIntLoma>(scatra_field())->set_initial_therm_pressure();
@@ -328,11 +327,6 @@ void LowMach::Algorithm::initial_calculations()
328327
fluid_field()->set_scalar_fields(scatra_field()->phinp(),
329328
std::dynamic_pointer_cast<ScaTra::ScaTraTimIntLoma>(scatra_field())->therm_press_np(),
330329
nullptr, scatra_field()->discretization());
331-
332-
// write initial fields
333-
// output();
334-
335-
return;
336330
}
337331

338332

@@ -545,15 +539,17 @@ void LowMach::Algorithm::set_fluid_values_in_scatra()
545539
{
546540
case Inpar::FLUID::timeint_afgenalpha:
547541
{
542+
scatra_field()->set_convective_velocity(*fluid_field()->velaf());
548543
scatra_field()->set_velocity_field(
549-
fluid_field()->velaf(), fluid_field()->accam(), nullptr, fluid_field()->fs_vel());
544+
fluid_field()->accam(), fluid_field()->velaf(), fluid_field()->fs_vel());
550545
}
551546
break;
552547
case Inpar::FLUID::timeint_one_step_theta:
553548
case Inpar::FLUID::timeint_bdf2:
554549
{
550+
scatra_field()->set_convective_velocity(*fluid_field()->velnp());
555551
scatra_field()->set_velocity_field(
556-
fluid_field()->velnp(), fluid_field()->hist(), nullptr, fluid_field()->fs_vel());
552+
fluid_field()->hist(), fluid_field()->velnp(), fluid_field()->fs_vel());
557553
}
558554
break;
559555
default:

src/poroelast_scatra/4C_poroelast_scatra_base.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ void PoroElastScaTra::PoroScatraBase::set_velocity_fields()
179179
velnp = volcoupl_fluidscatra_->apply_vector_mapping21(*poro_->fluid_field()->velnp());
180180
}
181181

182-
scatra_->scatra_field()->set_velocity_field(convel, nullptr, velnp, nullptr);
182+
scatra_->scatra_field()->set_convective_velocity(*convel);
183+
scatra_->scatra_field()->set_velocity_field(nullptr, velnp, nullptr);
183184
}
184185

185186
/*----------------------------------------------------------------------*

src/scatra/4C_scatra_algorithm.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ void ScaTra::ScaTraAlgorithm::prepare_time_step_convection()
225225
default:
226226
{
227227
FOUR_C_THROW("Selected time integration scheme is not available!");
228-
break;
229228
}
230229
}
231230

@@ -234,16 +233,17 @@ void ScaTra::ScaTraAlgorithm::prepare_time_step_convection()
234233
// transfer the initial(!!) convective velocity
235234
//(fluid initial field was set inside the constructor of fluid base class)
236235
if (step() == 1)
237-
scatra_field()->set_velocity_field(
238-
fluid_field()->velnp(), fluid_field()->hist(), nullptr, nullptr);
236+
{
237+
scatra_field()->set_convective_velocity(*fluid_field()->velnp());
238+
scatra_field()->set_velocity_field(fluid_field()->hist(), fluid_field()->velnp(), nullptr);
239+
}
239240

240241
// prepare time step (+ initialize one-step-theta scheme correctly with
241242
// velocity given above)
242243
scatra_field()->prepare_time_step();
243244
}
244245

245246
/*----------------------------------------------------------------------*
246-
| Print scatra solver type to screen fang 08/14 |
247247
*----------------------------------------------------------------------*/
248248
void ScaTra::ScaTraAlgorithm::print_scatra_solver()
249249
{
@@ -305,15 +305,17 @@ void ScaTra::ScaTraAlgorithm::set_velocity_field()
305305
case Inpar::FLUID::timeint_npgenalpha:
306306
case Inpar::FLUID::timeint_afgenalpha:
307307
{
308-
scatra_field()->set_velocity_field(fluid_to_scatra(fluid_field()->velaf()),
308+
scatra_field()->set_convective_velocity(*fluid_to_scatra(fluid_field()->velaf()));
309+
scatra_field()->set_velocity_field(
309310
fluid_to_scatra(fluid_field()->accam()), fluid_to_scatra(fluid_field()->velaf()), fsvel);
310311
break;
311312
}
312313
case Inpar::FLUID::timeint_one_step_theta:
313314
case Inpar::FLUID::timeint_bdf2:
314315
case Inpar::FLUID::timeint_stationary:
315316
{
316-
scatra_field()->set_velocity_field(fluid_to_scatra(fluid_field()->velnp()),
317+
scatra_field()->set_convective_velocity(*fluid_to_scatra(fluid_field()->velnp()));
318+
scatra_field()->set_velocity_field(
317319
fluid_to_scatra(fluid_field()->hist()), fluid_to_scatra(fluid_field()->velnp()), fsvel);
318320
break;
319321
}

src/scatra/4C_scatra_timint_implicit.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,28 +1461,38 @@ void ScaTra::ScaTraTimIntImpl::set_mean_concentration(
14611461
mean_conc_ = MeanConc;
14621462
}
14631463

1464+
/*----------------------------------------------------------------------*
1465+
*----------------------------------------------------------------------*/
1466+
void ScaTra::ScaTraTimIntImpl::set_convective_velocity(
1467+
const Core::LinAlg::Vector<double>& convective_velocity) const
1468+
{
1469+
// time measurement
1470+
TEUCHOS_FUNC_TIME_MONITOR("SCATRA: set convective velocity field");
1471+
1472+
// checks
1473+
FOUR_C_ASSERT(velocity_field_type_ == Inpar::ScaTra::velocity_Navier_Stokes,
1474+
"Wrong set_velocity_field() called for velocity field type {}!", velocity_field_type_);
1475+
FOUR_C_ASSERT(nds_vel() < discret_->num_dof_sets(), "Too few dof sets on scatra discretization!");
1476+
1477+
// provide scatra discretization with convective velocity
1478+
discret_->set_state(nds_vel(), "convective velocity field", convective_velocity);
1479+
}
1480+
1481+
14641482
/*----------------------------------------------------------------------*
14651483
*----------------------------------------------------------------------*/
14661484
void ScaTra::ScaTraTimIntImpl::set_velocity_field(
1467-
std::shared_ptr<const Core::LinAlg::Vector<double>> convvel,
14681485
std::shared_ptr<const Core::LinAlg::Vector<double>> acc,
14691486
std::shared_ptr<const Core::LinAlg::Vector<double>> vel,
14701487
std::shared_ptr<const Core::LinAlg::Vector<double>> fsvel)
14711488
{
14721489
// time measurement
1473-
TEUCHOS_FUNC_TIME_MONITOR("SCATRA: set convective velocity field");
1490+
TEUCHOS_FUNC_TIME_MONITOR("SCATRA: set velocity fields");
14741491

1475-
//---------------------------------------------------------------------------
1476-
// preliminaries
1477-
//---------------------------------------------------------------------------
1478-
if (convvel == nullptr) FOUR_C_THROW("Velocity state is nullptr");
1479-
1480-
if (velocity_field_type_ != Inpar::ScaTra::velocity_Navier_Stokes)
1481-
FOUR_C_THROW(
1482-
"Wrong set_velocity_field() called for velocity field type {}!", velocity_field_type_);
1483-
1484-
if (nds_vel() >= discret_->num_dof_sets())
1485-
FOUR_C_THROW("Too few dofsets on scatra discretization!");
1492+
// checks
1493+
FOUR_C_ASSERT(velocity_field_type_ == Inpar::ScaTra::velocity_Navier_Stokes,
1494+
"Wrong set_velocity_field() called for velocity field type {}!", velocity_field_type_);
1495+
FOUR_C_ASSERT(nds_vel() < discret_->num_dof_sets(), "Too few dof sets on scatra discretization!");
14861496

14871497
// boolean indicating whether fine-scale velocity vector exists
14881498
// -> if yes, multifractal subgrid-scale modeling is applied
@@ -1503,18 +1513,8 @@ void ScaTra::ScaTraTimIntImpl::set_velocity_field(
15031513
if (turbmodel_ == Inpar::FLUID::no_model and fssgd_ == Inpar::ScaTra::fssugrdiff_no)
15041514
fsvelswitch = false;
15051515

1506-
// provide scatra discretization with convective velocity
1507-
discret_->set_state(nds_vel(), "convective velocity field", *convvel);
1508-
15091516
// provide scatra discretization with velocity
1510-
if (vel != nullptr)
1511-
discret_->set_state(nds_vel(), "velocity field", *vel);
1512-
else
1513-
{
1514-
// if velocity vector is not provided by the respective algorithm, we
1515-
// assume that it equals the given convective velocity:
1516-
discret_->set_state(nds_vel(), "velocity field", *convvel);
1517-
}
1517+
if (vel != nullptr) discret_->set_state(nds_vel(), "velocity field", *vel);
15181518

15191519
// provide scatra discretization with acceleration field if required
15201520
if (acc != nullptr) discret_->set_state(nds_vel(), "acceleration field", *acc);

src/scatra/4C_scatra_timint_implicit.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,17 +244,18 @@ namespace ScaTra
244244
*/
245245
void set_external_force() const;
246246

247+
//! set the @convective_velocity vector to the scalar transport discretization
248+
void set_convective_velocity(const Core::LinAlg::Vector<double>& convective_velocity) const;
249+
247250
/*!
248-
* @brief set convective velocity field (+ pressure and acceleration field as well as fine-scale
249-
* velocity field, if required)
251+
* @brief set velocity field (+ pressure and acceleration field as well as fine-scale velocity
252+
* field, if required)
250253
*
251-
* @param convvel convective velocity/press. vector
252254
* @param acc acceleration vector
253255
* @param vel velocity vector
254256
* @param fsvel fine-scale velocity vector
255257
*/
256-
void set_velocity_field(std::shared_ptr<const Core::LinAlg::Vector<double>> convvel,
257-
std::shared_ptr<const Core::LinAlg::Vector<double>> acc,
258+
void set_velocity_field(std::shared_ptr<const Core::LinAlg::Vector<double>> acc,
258259
std::shared_ptr<const Core::LinAlg::Vector<double>> vel,
259260
std::shared_ptr<const Core::LinAlg::Vector<double>> fsvel);
260261

0 commit comments

Comments
 (0)