Skip to content

Commit

Permalink
[LF] Set phase_variable in LiquidFlowData
Browse files Browse the repository at this point in the history
  • Loading branch information
wenqing authored and TomFischer committed Oct 15, 2024
1 parent 1d5d4c6 commit 9f72c2e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
10 changes: 9 additions & 1 deletion ProcessLib/LiquidFlow/CreateLiquidFlowProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@ std::unique_ptr<Process> createLiquidFlowProcess(
*aperture_config, "parameter", parameters, 1);
}

// The uniqueness of phase has already been checked in
// `checkMPLProperties`.
MaterialPropertyLib::Variable const phase_variable =
(*ranges::begin(media_map.media()))->hasPhase("Gas")
? MaterialPropertyLib::Variable::gas_phase_pressure
: MaterialPropertyLib::Variable::liquid_phase_pressure;

LiquidFlowData process_data{
covertEquationBalanceTypeFromString(equation_balance_type_str),
std::move(media_map),
Expand All @@ -197,7 +204,8 @@ std::unique_ptr<Process> createLiquidFlowProcess(
std::move(specific_body_force),
has_gravity,
*aperture_size_parameter,
NumLib::ShapeMatrixCache{integration_order}};
NumLib::ShapeMatrixCache{integration_order},
phase_variable};

return std::make_unique<LiquidFlowProcess>(
std::move(name), mesh, std::move(jacobian_assembler), parameters,
Expand Down
3 changes: 3 additions & 0 deletions ProcessLib/LiquidFlow/LiquidFlowData.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <Eigen/Core>

#include "MaterialLib/MPL/MaterialSpatialDistributionMap.h"
#include "MaterialLib/MPL/VariableType.h"
#include "NumLib/Fem/ShapeMatrixCache.h"
#include "ParameterLib/Parameter.h"

Expand Down Expand Up @@ -54,6 +55,8 @@ struct LiquidFlowData final

/// caches for each mesh element type the shape matrix
NumLib::ShapeMatrixCache shape_matrix_cache;

MaterialPropertyLib::Variable const phase_variable;
};

} // namespace LiquidFlow
Expand Down
20 changes: 8 additions & 12 deletions ProcessLib/LiquidFlow/LiquidFlowLocalAssembler-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,10 @@ void LiquidFlowLocalAssembler<ShapeFunction, GlobalDim>::

auto const& medium = *_process_data.media_map.getMedium(_element.getID());
auto const& fluid_phase = fluidPhase(medium);
bool is_gas_phase = medium.hasPhase("Gas");
auto const fluid_pressure_variable =
is_gas_phase ? MaterialPropertyLib::Variable::gas_phase_pressure
: MaterialPropertyLib::Variable::liquid_phase_pressure;

MaterialPropertyLib::VariableArray vars;
auto& phase_pressue =
is_gas_phase ? vars.gas_phase_pressure : vars.liquid_phase_pressure;
auto& phase_pressure = medium.hasPhase("Gas") ? vars.gas_phase_pressure
: vars.liquid_phase_pressure;

vars.temperature =
medium[MaterialPropertyLib::PropertyType::reference_temperature]
Expand All @@ -160,7 +156,7 @@ void LiquidFlowLocalAssembler<ShapeFunction, GlobalDim>::
auto const& ip_data = _ip_data[ip];
auto const& N = Ns[ip];

phase_pressue = N.dot(local_p_vec);
phase_pressure = N.dot(local_p_vec);

auto const [fluid_density, viscosity] =
getFluidDensityAndViscosity(t, dt, pos, fluid_phase, vars);
Expand All @@ -175,8 +171,8 @@ void LiquidFlowLocalAssembler<ShapeFunction, GlobalDim>::
auto const get_drho_dp = [&]()
{
return fluid_phase[MaterialPropertyLib::PropertyType::density]
.template dValue<double>(vars, fluid_pressure_variable, pos, t,
dt);
.template dValue<double>(vars, _process_data.phase_variable,
pos, t, dt);
};
auto const storage =
_process_data.equation_balance_type == EquationBalanceType::volume
Expand Down Expand Up @@ -295,8 +291,8 @@ void LiquidFlowLocalAssembler<ShapeFunction, GlobalDim>::
auto const& fluid_phase = fluidPhase(medium);

MaterialPropertyLib::VariableArray vars;
auto& phase_pressue = medium.hasPhase("Gas") ? vars.gas_phase_pressure
: vars.liquid_phase_pressure;
auto& phase_pressure = medium.hasPhase("Gas") ? vars.gas_phase_pressure
: vars.liquid_phase_pressure;

vars.temperature =
medium[MaterialPropertyLib::PropertyType::reference_temperature]
Expand All @@ -315,7 +311,7 @@ void LiquidFlowLocalAssembler<ShapeFunction, GlobalDim>::
auto const& ip_data = _ip_data[ip];
auto const& N = Ns[ip];

phase_pressue = N.dot(local_p_vec);
phase_pressure = N.dot(local_p_vec);

auto const [fluid_density, viscosity] =
getFluidDensityAndViscosity(t, dt, pos, fluid_phase, vars);
Expand Down

0 comments on commit 9f72c2e

Please sign in to comment.