Skip to content
Snippets Groups Projects
Commit 931fc44e authored by wenqing's avatar wenqing
Browse files

[MPL] New h/cpp files in MPL/Utils containing

getFluidDensity and getFluidDensityAndViscosity for
single phase flow models.
parent 1d6959fb
No related branches found
No related tags found
No related merge requests found
/**
* \file
* \copyright
* Copyright (c) 2012-2025, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
* Created on January 21, 2025, 4:10 PM
*/
#include "GetFluidDensityAndViscosity.h"
#include "MaterialLib/MPL/Phase.h"
#include "MaterialLib/MPL/VariableType.h"
#include "ParameterLib/SpatialPosition.h"
namespace MaterialPropertyLib
{
double getFluidDensity(double const t, double const dt,
ParameterLib::SpatialPosition const& pos,
Phase const& fluid_phase, VariableArray& vars)
{
// Compute density:
// Quick workaround: If fluid density is described as ideal gas, then
// the molar mass must be passed to the MPL::IdealGasLaw via the
// variable_array and the fluid must have the property
// MPL::PropertyType::molar_mass. For other density models (e.g.
// Constant), it is not mandatory to specify the molar mass.
if (fluid_phase.hasProperty(MaterialPropertyLib::PropertyType::molar_mass))
{
vars.molar_mass =
fluid_phase.property(MaterialPropertyLib::PropertyType::molar_mass)
.template value<double>(vars, pos, t, dt);
}
return fluid_phase[MaterialPropertyLib::PropertyType::density]
.template value<double>(vars, pos, t, dt);
}
std::tuple<double, double> getFluidDensityAndViscosity(
double const t, double const dt, ParameterLib::SpatialPosition const& pos,
MaterialPropertyLib::Phase const& fluid_phase,
MaterialPropertyLib::VariableArray& vars)
{
auto const fluid_density = getFluidDensity(t, dt, pos, fluid_phase, vars);
assert(fluid_density > 0.);
vars.density = fluid_density;
auto const viscosity =
fluid_phase[MaterialPropertyLib::PropertyType::viscosity]
.template value<double>(vars, pos, t, dt);
return {fluid_density, viscosity};
}
} // namespace MaterialPropertyLib
/**
* \file
* \copyright
* Copyright (c) 2012-2025, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
* Created on January 21, 2025, 4:10 PM
*/
#pragma once
#include <tuple>
namespace ParameterLib
{
class SpatialPosition;
}
namespace MaterialPropertyLib
{
class Phase;
class VariableArray;
/// It computes fluid density and viscosity for single phase flow model.
std::tuple<double, double> getFluidDensityAndViscosity(
double const t, double const dt, ParameterLib::SpatialPosition const& pos,
Phase const& fluid_phase, VariableArray& vars);
/// It computes fluid density for single phase flow model.
double getFluidDensity(double const t, double const dt,
ParameterLib::SpatialPosition const& pos,
Phase const& fluid_phase, VariableArray& vars);
} // namespace MaterialPropertyLib
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment