Skip to content

Commit

Permalink
Optimize get_inv_rho_cp
Browse files Browse the repository at this point in the history
  • Loading branch information
Rombur committed Mar 15, 2024
1 parent 96b8fe4 commit c73e7ff
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion source/ThermalOperator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -474,12 +474,19 @@ ThermalOperator<dim, use_table, p_order, fe_degree, MaterialStates,
_material_properties.get(material_id[n], Property::latent_heat);
}

unsigned int constexpr solid =
static_cast<unsigned int>(MaterialStates::State::solid);
unsigned int constexpr liquid =
static_cast<unsigned int>(MaterialStates::State::liquid);

// We only need to take the latent heat into account if both the liquid and
// the solid phases are present. We could use an if with two conditions but
// that is very slow. Instead, we create a new variable is_mushy that is
// non-zero when there is both solid and liquid.
auto is_mushy = state_ratios[liquid] * state_ratios[solid];
for (unsigned int n = 0; n < specific_heat.size(); ++n)
{
if (state_ratios[liquid][n] > 0.0 && (state_ratios[liquid][n] < 1.0))
if (is_mushy[n] > 0.0)
{
specific_heat[n] += latent_heat[n] / (liquidus[n] - solidus[n]);
}
Expand Down

0 comments on commit c73e7ff

Please sign in to comment.