Skip to content

Commit 166710a

Browse files
committed
Avoid compiler warnings
1 parent 953d7b0 commit 166710a

File tree

4 files changed

+54
-63
lines changed

4 files changed

+54
-63
lines changed

application/adamantine.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ get_p_order_and_n_material_states(boost::property_tree::ptree &database)
106106

107107
// Sanity check
108108
adamantine::ASSERT_THROW(
109-
p_order >= 0 && p_order < 5,
109+
p_order < 5,
110110
"Error when computing the polynomial order of the material properties");
111111
adamantine::ASSERT_THROW(
112112
n_material_states > 0 && n_material_states < 4,

source/MaterialProperty.hh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,6 @@ public:
5656
dealii::parallel::distributed::Triangulation<dim> const &tria,
5757
boost::property_tree::ptree const &database);
5858

59-
/**
60-
* Copy constructor. It should only be called by KOKKOS_CLASS_LAMBDA. The
61-
* copy constructor does not copy all the member variables of the class.
62-
*/
63-
MaterialProperty(MaterialProperty<dim, p_order, MaterialStates,
64-
MemorySpaceType> const &other);
65-
6659
/**
6760
* Return true if the material properties are given in table format.
6861
* Return false if they are given in polynomial format.

source/MaterialProperty.templates.hh

Lines changed: 44 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -146,19 +146,6 @@ MaterialProperty<dim, p_order, MaterialStates, MemorySpaceType>::
146146
fill_properties(database);
147147
}
148148

149-
template <int dim, int p_order, typename MaterialStates,
150-
typename MemorySpaceType>
151-
MaterialProperty<dim, p_order, MaterialStates, MemorySpaceType>::
152-
MaterialProperty(MaterialProperty<dim, p_order, MaterialStates,
153-
MemorySpaceType> const &other)
154-
: _use_table(other._use_table),
155-
_state_property_tables(other._state_property_tables),
156-
_state_property_polynomials(other._state_property_polynomials),
157-
_properties(other._properties), _state(other._state),
158-
_property_values(other._property_values), _fe(0)
159-
{
160-
}
161-
162149
template <int dim, int p_order, typename MaterialStates,
163150
typename MemorySpaceType>
164151
double
@@ -243,14 +230,15 @@ void MaterialProperty<dim, p_order, MaterialStates,
243230
#ifdef ADAMANTINE_DEBUG
244231
if constexpr (std::is_same_v<MemorySpaceType, dealii::MemorySpace::Host>)
245232
{
233+
auto state = _state;
246234
Kokkos::parallel_for(
247235
"adamantine::set_state_nan",
248236
Kokkos::MDRangePolicy<Kokkos::DefaultHostExecutionSpace,
249237
Kokkos::Rank<2>>(
250238
{{0, 0}}, {{MaterialStates::n_material_states,
251239
static_cast<int>(_dofs_map.size())}}),
252-
KOKKOS_CLASS_LAMBDA(int i, int j) {
253-
_state(i, j) = std::numeric_limits<double>::signaling_NaN();
240+
KOKKOS_LAMBDA(int i, int j) {
241+
state(i, j) = std::numeric_limits<double>::signaling_NaN();
254242
});
255243
}
256244
#endif
@@ -297,10 +285,16 @@ void MaterialProperty<dim, p_order, MaterialStates, MemorySpaceType>::update(
297285
using ExecutionSpace = std::conditional_t<
298286
std::is_same_v<MemorySpaceType, dealii::MemorySpace::Host>,
299287
Kokkos::DefaultHostExecutionSpace, Kokkos::DefaultExecutionSpace>;
288+
auto properties = _properties;
289+
auto state = _state;
290+
auto use_table = _use_table;
291+
auto property_values = _property_values;
292+
auto state_property_tables = _state_property_tables;
293+
auto state_property_polynomials = _state_property_polynomials;
300294
Kokkos::parallel_for(
301295
"adamantine::update_material_properties",
302296
Kokkos::RangePolicy<ExecutionSpace>(0, material_ids_size),
303-
KOKKOS_CLASS_LAMBDA(int i) {
297+
KOKKOS_LAMBDA(int i) {
304298
unsigned int constexpr solid =
305299
static_cast<unsigned int>(MaterialStates::State::solid);
306300
unsigned int constexpr prop_solidus =
@@ -313,13 +307,14 @@ void MaterialProperty<dim, p_order, MaterialStates, MemorySpaceType>::update(
313307
double liquid_ratio = 0.;
314308

315309
dealii::types::material_id material_id = material_ids_mirror(i);
316-
double const solidus = _properties(material_id, prop_solidus);
317-
double const liquidus = _properties(material_id, prop_liquidus);
310+
double const solidus = properties(material_id, prop_solidus);
311+
double const liquidus = properties(material_id, prop_liquidus);
318312
unsigned int const dof = mp_dofs_mirror(i);
319313

320314
// Work-around CUDA compiler complaining that the first call to a
321315
// captured-variable is inside a constexpr.
322316
double *temp_average_local = temperature_average_local;
317+
auto local_state = state;
323318

324319
if constexpr (!std::is_same_v<MaterialStates, Solid>)
325320
{
@@ -345,19 +340,19 @@ void MaterialProperty<dim, p_order, MaterialStates, MemorySpaceType>::update(
345340
// become liquid, and the liquid can only become solid, the ratio of
346341
// powder can only decrease.
347342
double powder_ratio =
348-
Kokkos::min(1. - liquid_ratio, _state(powder, dof));
343+
Kokkos::min(1. - liquid_ratio, state(powder, dof));
349344
solid_ratio = 1. - liquid_ratio - powder_ratio;
350345

351346
// Update _state
352-
_state(powder, dof) = powder_ratio;
347+
state(powder, dof) = powder_ratio;
353348
}
354-
_state(liquid, dof) = liquid_ratio;
349+
state(liquid, dof) = liquid_ratio;
355350
}
356351

357352
// Update _state
358-
_state(solid, dof) = solid_ratio;
353+
state(solid, dof) = solid_ratio;
359354

360-
if (_use_table)
355+
if (use_table)
361356
{
362357
for (unsigned int property = 0;
363358
property < g_n_thermal_state_properties; ++property)
@@ -366,10 +361,10 @@ void MaterialProperty<dim, p_order, MaterialStates, MemorySpaceType>::update(
366361
material_state < MaterialStates::n_material_states;
367362
++material_state)
368363
{
369-
_property_values(property, dof) +=
370-
_state(material_state, dof) *
364+
property_values(property, dof) +=
365+
state(material_state, dof) *
371366
compute_property_from_table(
372-
_state_property_tables, material_id, material_state,
367+
state_property_tables, material_id, material_state,
373368
property, temp_average_local[dof]);
374369
}
375370
}
@@ -385,10 +380,10 @@ void MaterialProperty<dim, p_order, MaterialStates, MemorySpaceType>::update(
385380
{
386381
for (unsigned int i = 0; i <= p_order; ++i)
387382
{
388-
_property_values(property, dof) +=
389-
_state(material_state, dof) *
390-
_state_property_polynomials(material_id, material_state,
391-
property, i) *
383+
property_values(property, dof) +=
384+
state(material_state, dof) *
385+
state_property_polynomials(material_id, material_state,
386+
property, i) *
392387
std::pow(temp_average_local[dof], i);
393388
}
394389
}
@@ -409,9 +404,9 @@ void MaterialProperty<dim, p_order, MaterialStates, MemorySpaceType>::update(
409404
material_state < MaterialStates::n_material_states;
410405
++material_state)
411406
{
412-
_property_values(specific_heat_prop, dof) +=
413-
_state(material_state, dof) *
414-
_properties(material_id, latent_heat_prop) /
407+
property_values(specific_heat_prop, dof) +=
408+
state(material_state, dof) *
409+
properties(material_id, latent_heat_prop) /
415410
(liquidus - solidus);
416411
}
417412
}
@@ -430,9 +425,9 @@ void MaterialProperty<dim, p_order, MaterialStates, MemorySpaceType>::update(
430425
static_cast<unsigned int>(Property::radiation_temperature_infty);
431426
double const T = temp_average_local[dof];
432427
double const T_infty =
433-
_properties(material_id, radiation_temperature_infty_prop);
434-
double const emissivity = _property_values(emissivity_prop, dof);
435-
_property_values(radiation_heat_transfer_coef_prop, dof) =
428+
properties(material_id, radiation_temperature_infty_prop);
429+
double const emissivity = property_values(emissivity_prop, dof);
430+
property_values(radiation_heat_transfer_coef_prop, dof) =
436431
emissivity * Constant::stefan_boltzmann * (T + T_infty) *
437432
(T * T + T_infty * T_infty);
438433
});
@@ -680,18 +675,17 @@ void MaterialProperty<dim, p_order, MaterialStates, MemorySpaceType>::
680675
using ExecutionSpace = std::conditional_t<
681676
std::is_same_v<MemorySpaceType, dealii::MemorySpace::Host>,
682677
Kokkos::DefaultHostExecutionSpace, Kokkos::DefaultExecutionSpace>;
678+
auto state = _state;
683679
Kokkos::parallel_for(
684680
"adamantine::set_state_device",
685-
Kokkos::RangePolicy<ExecutionSpace>(0, cell_i),
686-
KOKKOS_CLASS_LAMBDA(int i) {
681+
Kokkos::RangePolicy<ExecutionSpace>(0, cell_i), KOKKOS_LAMBDA(int i) {
687682
double liquid_ratio_sum = 0.;
688683
for (unsigned int q = 0; q < n_q_points; ++q)
689684
{
690685
liquid_ratio_sum += liquid_ratio(mapping(i, q));
691686
}
692-
_state(liquid_state, mp_dof(i)) = liquid_ratio_sum / n_q_points;
693-
_state(solid_state, mp_dof(i)) =
694-
1. - _state(liquid_state, mp_dof(i));
687+
state(liquid_state, mp_dof(i)) = liquid_ratio_sum / n_q_points;
688+
state(solid_state, mp_dof(i)) = 1. - state(liquid_state, mp_dof(i));
695689
});
696690
}
697691
else if constexpr (std::is_same_v<MaterialStates, SolidLiquidPowder>)
@@ -701,22 +695,22 @@ void MaterialProperty<dim, p_order, MaterialStates, MemorySpaceType>::
701695
using ExecutionSpace = std::conditional_t<
702696
std::is_same_v<MemorySpaceType, dealii::MemorySpace::Host>,
703697
Kokkos::DefaultHostExecutionSpace, Kokkos::DefaultExecutionSpace>;
698+
auto state = _state;
704699
Kokkos::parallel_for(
705700
"adamantine::set_state_device",
706-
Kokkos::RangePolicy<ExecutionSpace>(0, cell_i),
707-
KOKKOS_CLASS_LAMBDA(int i) {
701+
Kokkos::RangePolicy<ExecutionSpace>(0, cell_i), KOKKOS_LAMBDA(int i) {
708702
double liquid_ratio_sum = 0.;
709703
double powder_ratio_sum = 0.;
710704
for (unsigned int q = 0; q < n_q_points; ++q)
711705
{
712706
liquid_ratio_sum += liquid_ratio(mapping(i, q));
713707
powder_ratio_sum += powder_ratio(mapping(i, q));
714708
}
715-
_state(liquid_state, mp_dof(i)) = liquid_ratio_sum / n_q_points;
716-
_state(powder_state, mp_dof(i)) = powder_ratio_sum / n_q_points;
717-
_state(solid_state, mp_dof(i)) = 1. -
718-
_state(liquid_state, mp_dof(i)) -
719-
_state(powder_state, mp_dof(i));
709+
state(liquid_state, mp_dof(i)) = liquid_ratio_sum / n_q_points;
710+
state(powder_state, mp_dof(i)) = powder_ratio_sum / n_q_points;
711+
state(solid_state, mp_dof(i)) = 1. -
712+
state(liquid_state, mp_dof(i)) -
713+
state(powder_state, mp_dof(i));
720714
});
721715
}
722716
}
@@ -775,10 +769,11 @@ void MaterialProperty<dim, p_order, MaterialStates,
775769
using ExecutionSpace = std::conditional_t<
776770
std::is_same_v<MemorySpaceType, dealii::MemorySpace::Host>,
777771
Kokkos::DefaultHostExecutionSpace, Kokkos::DefaultExecutionSpace>;
772+
auto state = _state;
778773
Kokkos::parallel_for(
779774
"adamantine::set_initial_state",
780775
Kokkos::RangePolicy<ExecutionSpace>(0, user_indices.extent(0)),
781-
KOKKOS_CLASS_LAMBDA(int i) { _state(user_indices(i), mp_dofs(i)) = 1.; });
776+
KOKKOS_LAMBDA(int i) { state(user_indices(i), mp_dofs(i)) = 1.; });
782777
}
783778

784779
template <int dim, int p_order, typename MaterialStates,

source/types.hh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#ifndef TYPES_HH
99
#define TYPES_HH
1010

11+
#include <Kokkos_NumericTraits.hpp>
12+
1113
#include <array>
1214
#include <string>
1315

@@ -163,18 +165,19 @@ struct axis;
163165
template <>
164166
struct axis<2>
165167
{
166-
static int constexpr x = 0;
167-
static int constexpr y = -1;
168-
static int constexpr z = 1;
168+
static unsigned int constexpr x = 0;
169+
static unsigned int constexpr y =
170+
Kokkos::Experimental::finite_max_v<unsigned int>;
171+
static unsigned int constexpr z = 1;
169172
};
170173

171174
// dim == 3 specialization
172175
template <>
173176
struct axis<3>
174177
{
175-
static int constexpr x = 0;
176-
static int constexpr y = 1;
177-
static int constexpr z = 2;
178+
static unsigned int constexpr x = 0;
179+
static unsigned int constexpr y = 1;
180+
static unsigned int constexpr z = 2;
178181
};
179182

180183
/**

0 commit comments

Comments
 (0)