10000 Create the two phase flow process by Yonghui56 · Pull Request #1530 · ufz/ogs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Create the two phase flow process #1530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions Applications/ApplicationsLib/ProjectData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "ProcessLib/LIE/SmallDeformation/CreateSmallDeformationProcess.h"
#include "ProcessLib/TES/CreateTESProcess.h"
#include "ProcessLib/HT/CreateHTProcess.h"
#include "ProcessLib/TwoPhaseFlowWithPP/CreateTwoPhaseFlowWithPPProcess.h"

namespace detail
{
Expand Down Expand Up @@ -311,8 +312,9 @@ void ProjectData::parseProcesses(BaseLib::ConfigTree const& processes_config,
else if (type == "LIQUID_FLOW")
{
process = ProcessLib::LiquidFlow::createLiquidFlowProcess(
*_mesh_vec[0], std::move(jacobian_assembler), _process_variables,
_parameters, integration_order, process_config);
*_mesh_vec[0], std::move(jacobian_assembler),
_process_variables, _parameters, integration_order,
process_config);
}
else if (type == "TES")
{
Expand Down Expand Up @@ -408,6 +410,16 @@ void ProjectData::parseProcesses(BaseLib::ConfigTree const& processes_config,
_process_variables, _parameters, integration_order,
process_config, _curves);
}

else if (type == "TWOPHASE_FLOW_PP")
{
process =
ProcessLib::TwoPhaseFlowWithPP::CreateTwoPhaseFlowWithPPProcess(
*_mesh_vec[0], std::move(jacobian_assembler),
_process_variables, _parameters, integration_order,
process_config, _curves);
}

else
{
OGS_FATAL("Unknown process type: %s", type.c_str());
Expand Down
26 changes: 25 additions & 1 deletion Applications/CLI/Tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ if(NOT OGS_USE_MPI)
)

AddTest(
NAME LARGE_2D_RichardsFlow_h_us_quad
NAME LARGE_2D_RichardsFlow_h_us_quad
PATH Parabolic/Richards
EXECUTABLE ogs
EXECUTABLE_ARGS RichardsFlow_2d.prj
Expand All @@ -372,6 +372,30 @@ if(NOT OGS_USE_MPI)
DIFF_DATA
h_us_quad_1000.vtu richards_pcs_0_ts_100_t_100.000000.vtu PRESSURE1 pressure
)
AddTest(
NAME 2D_TwoPhase_PP_Lia_quad
PATH Parabolic/TwoPhaseFlowPP/Liakopoulos
EXECUTABLE ogs
EXECUTABLE_ARGS Twophase_Lia_quad2_short.prj
TESTER vtkdiff
ABSTOL 1e-8 RELTOL 1e-12
DIFF_DATA
Lia_20.vtu twophaseflow_pcs_0_ts_119_t_20.000000.vtu capillary_pressure capillary_pressure
Lia_20.vtu twophaseflow_pcs_0_ts_119_t_20.000000.vtu gas_pressure gas_pressure
Lia_20.vtu twophaseflow_pcs_0_ts_119_t_20.000000.vtu saturation saturation
)
AddTest(
NAME LARGE_2D_TwoPhase_PP_Lia_quad
PATH Parabolic/TwoPhaseFlowPP/Liakopoulos
EXECUTABLE ogs
EXECUTABLE_ARGS Twophase_Lia_quad2_large.prj
TESTER vtkdiff
ABSTOL 1e-8 RELTOL 1e-12
DIFF_DATA
Lia_1000.vtu twophaseflow_pcs_0_ts_1180_t_1000.000000.vtu capillary_pressure capillary_pressure
Lia_1000.vtu twophaseflow_pcs_0_ts_1180_t_1000.000000.vtu gas_pressure gas_pressure
Lia_1000.vtu twophaseflow_pcs_0_ts_1180_t_1000.000000.vtu saturation saturation
)

AddTest(
NAME LARGE_2D_ThermalConvection_constviscosity
Expand Down
2 changes: 2 additions & 0 deletions MaterialLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ append_source_files(SOURCES PorousMedium/Storage)
append_source_files(SOURCES PorousMedium/Permeability)
append_source_files(SOURCES PorousMedium/UnsaturatedProperty/CapillaryPressure)

append_source_files(SOURCES TwoPhaseModels)

add_library(MaterialLib ${SOURCES} )
target_link_libraries(MaterialLib
BaseLib
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since files in TwoPhaseModels are for a set of process related parameters, I would like to move them to ProcessLib/TwoPhaseFlowWithPP.

In MaterialLib, I think, it should only has physical chemical models or parameters of fluids, solids and porous medium.

* \copyright
* Copyright (c) 2012-2016, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/

#include "CreateTwoPhaseFlowMaterialProperties.h"
#include <logog/include/logog.hpp>
#include "BaseLib/reorderVector.h"
#include "MaterialLib/Fluid/FluidProperty.h"
#include "MaterialLib/PorousMedium/Porosity/Porosity.h"
#include "MaterialLib/PorousMedium/Storage/Storage.h"
#include "MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.h"
#include "MeshLib/Mesh.h"
#include "MeshLib/PropertyVector.h"
#include "ProcessLib/Parameter/Parameter.h"
#include "ProcessLib/Parameter/SpatialPosition.h"
#include "TwoPhaseFlowWithPPMaterialProperties.h"

namespace MaterialLib
{
namespace TwoPhaseFlowWithPP
{
std::unique_ptr<TwoPhaseFlowWithPPMaterialProperties>
CreateTwoPhaseFlowMaterialProperties(
BaseLib::ConfigTree const& config,
bool const has_material_ids,
MeshLib::PropertyVector<int> const& material_ids)
{
DBUG("Reading material properties of two-phase flow process.");

//! \ogs_file_param{prj__material_property__fluid}
auto const& fluid_config = config.getConfigSubtree("fluid");

// Get fluid properties
//! \ogs_file_param{prj__material_property__liquid_density}
auto const& rho_conf = fluid_config.getConfigSubtree("liquid_density");
auto _liquid_density =
MaterialLib::Fluid::createFluidDensityModel(rho_conf);
//! \ogs_file_param{prj__material_property__gas_density}
auto const& rho_gas_conf = fluid_config.getConfigSubtree("gas_density");
auto _gas_density =
MaterialLib::Fluid::createFluidDensityModel(rho_gas_conf);
//! \ogs_file_param{prj__material_property__liquid_viscosity}
auto const& mu_conf = fluid_config.getConfigSubtree("liquid_viscosity");
auto _viscosity = MaterialLib::Fluid::createViscosityModel(mu_conf);
//! \ogs_file_param{prj__material_property__gas_viscosity}
auto const& mu_gas_conf = fluid_config.getConfigSubtree("gas_viscosity");
auto _gas_viscosity = MaterialLib::Fluid::createViscosityModel(mu_gas_conf);

// Get porous properties
std::vector<int> mat_ids;
std::vector<Eigen::MatrixXd> _intrinsic_permeability_models;
std::vector<std::unique_ptr<MaterialLib::PorousMedium::Porosity>>
_porosity_models;
std::vector<std::unique_ptr<MaterialLib::PorousMedium::Storage>>
_storage_models;
//! \ogs_file_param{prj__material_property__porous_medium}
auto const& poro_config = config.getConfigSubtree("porous_medium");
//! \ogs_file_param{prj__material_property__porous_medium__porous_medium}
for (auto const& conf : poro_config.getConfigSubtreeList("porous_medium"))
{
//! \ogs_file_attr{prj__material_property__porous_medium__porous_medium__id}
auto const id = conf.getConfigAttributeOptional<int>("id");
mat_ids.push_back(*id);

//! \ogs_file_param{prj__material_property__porous_medium__porous_medium__permeability}
auto const& permeability_conf = conf.getConfigSubtree("permeability");
_intrinsic_permeability_models.emplace_back(
MaterialLib::PorousMedium::createPermeabilityModel(permeability_conf));

//! \ogs_file_param{prj__material_property__porous_medium__porous_medium__porosity}
auto const& porosity_conf = conf.getConfigSubtree("porosity");
auto n = MaterialLib::PorousMedium::createPorosityModel(porosity_conf);
_porosity_models.emplace_back(std::move(n));

//! \ogs_file_param{prj__material_property__porous_medium__porous_medium__storage}
auto const& storage_conf = conf.getConfigSubtree("storage");
auto beta = MaterialLib::PorousMedium::createStorageModel(storage_conf);
_storage_models.emplace_back(std::move(beta));
}

BaseLib::reorderVector(_intrinsic_permeability_models, mat_ids);
BaseLib::reorderVector(_porosity_models, mat_ids);
BaseLib::reorderVector(_storage_models, mat_ids);

return std::unique_ptr<TwoPhaseFlowWithPPMaterialProperties>{
new TwoPhaseFlowWithPPMaterialProperties{
has_material_ids, material_ids, std::move(_liquid_density),
std::move(_viscosity), std::move(_gas_density),
std::move(_gas_viscosity), _intrinsic_permeability_models,
std::move(_porosity_models), std::move(_storage_models)}};
}

} // end namespace
} // end namespace
37 changes: 37 additions & 0 deletions MaterialLib/TwoPhaseModels/CreateTwoPhaseFlowMaterialProperties.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* \copyright
* Copyright (c) 2012-2016, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/

#ifndef OGS_CREATETWOPHASEFLOWMATERIALPROPERTIES_H
#define OGS_CREATETWOPHASEFLOWMATERIALPROPERTIES_H

#include <memory>
#include "MaterialLib/Fluid/FluidPropertyHeaders.h"
#include "MaterialLib/PorousMedium/Porosity/Porosity.h"
#include "MaterialLib/PorousMedium/PorousPropertyHeaders.h"
#include "MaterialLib/PorousMedium/Storage/Storage.h"
#include "MaterialLib/TwoPhaseModels/TwoPhaseFlowWithPPMaterialProperties.h"
namespace BaseLib
{
class ConfigTree;
}

namespace MaterialLib
{
namespace TwoPhaseFlowWithPP
{
std::unique_ptr<TwoPhaseFlowWithPPMaterialProperties>
CreateTwoPhaseFlowMaterialProperties(
BaseLib::ConfigTree const& config,
bool const has_material_ids,
MeshLib::PropertyVector<int> const& material_ids);

} // end namespace
} // end namespace

#endif /* CREATETWOPHASEFLOWMATERIALPROPERTIES_H */
133 changes: 133 additions & 0 deletions MaterialLib/TwoPhaseModels/TwoPhaseFlowWithPPMaterialProperties.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/**
* \copyright
* Copyright (c) 2012-2016, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/

#include "TwoPhaseFlowWithPPMaterialProperties.h"
#include <logog/include/logog.hpp>
#include "BaseLib/reorderVector.h"
#include "MaterialLib/Fluid/FluidProperty.h"
#include "MaterialLib/PorousMedium/Porosity/Porosity.h"
#include "MaterialLib/PorousMedium/Storage/Storage.h"
#include "MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.h"
#include "MeshLib/Mesh.h"
#include "MeshLib/PropertyVector.h"
#include "ProcessLib/Parameter/Parameter.h"
#include "ProcessLib/Parameter/SpatialPosition.h"

namespace MaterialLib
{
namespace TwoPhaseFlowWithPP
{
TwoPhaseFlowWithPPMaterialProperties::TwoPhaseFlowWithPPMaterialProperties(
bool const has_material_ids,
MeshLib::PropertyVector<int> const& material_ids,
std::unique_ptr<MaterialLib::Fluid::FluidProperty>
liquid_density,
std::unique_ptr<MaterialLib::Fluid::FluidProperty>
viscosity,
std::unique_ptr<MaterialLib::Fluid::FluidProperty>
gas_density,
std::unique_ptr<MaterialLib::Fluid::FluidProperty>
gas_viscosity,
std::vector<Eigen::MatrixXd>
intrinsic_permeability_models,
std::vector<std::unique_ptr<MaterialLib::PorousMedium::Porosity>>&&
porosity_models,
std::vector<std::unique_ptr<MaterialLib::PorousMedium::Storage>>&&
storage_models)
: _has_material_ids(has_material_ids),
_liquid_density(std::move(liquid_density)),
_viscosity(std::move(viscosity)),
_gas_density(std::move(gas_density)),
_gas_viscosity(std::move(gas_viscosity)),
_material_ids(material_ids),
_intrinsic_permeability_models(intrinsic_permeability_models),
_porosity_models(std::move(porosity_models)),
_storage_models(std::move(storage_models))
{
DBUG("Create material properties for Two-Phase flow with PP model.");
}

void TwoPhaseFlowWithPPMaterialProperties::setMaterialID(
const ProcessLib::SpatialPosition& pos)
{
if (!_has_material_ids)
{
_current_material_id = 0;
return;
}

assert(pos.getElementID().get() < _material_ids.size());
_current_material_id = _material_ids[pos.getElementID().get()];
}

double TwoPhaseFlowWithPPMaterialProperties::getLiquidDensity(
const double p, const double T) const
{
ArrayType vars;
vars[static_cast<int>(MaterialLib::Fluid::PropertyVariableType::T)] = T;
vars[static_cast<int>(MaterialLib::Fluid::PropertyVariableType::pl)] = p;
return _liquid_density->getValue(vars);
}

double TwoPhaseFlowWithPPMaterialProperties::getGasDensity(const double p,
const double T) const
{
ArrayType vars;
vars[static_cast<int>(MaterialLib::Fluid::PropertyVariableType::T)] = T;
vars[static_cast<int>(MaterialLib::Fluid::PropertyVariableType::pg)] = p;
return _gas_density->getValue(vars);
}

double TwoPhaseFlowWithPPMaterialProperties::getDerivGasDensity(
const double p, const double T) const
{
ArrayType vars;
vars[static_cast<int>(MaterialLib::Fluid::PropertyVariableType::T)] = T;
vars[static_cast<int>(MaterialLib::Fluid::PropertyVariableType::pg)] = p;

return _gas_density->getdValue(
vars, MaterialLib::Fluid::PropertyVariableType::pg);
}
double TwoPhaseFlowWithPPMaterialProperties::getLiquidViscosity(
const double p, const double T) const
{
ArrayType vars;
vars[static_cast<int>(MaterialLib::Fluid::PropertyVariableType::T)] = T;
vars[static_cast<int>(MaterialLib::Fluid::PropertyVariableType::pl)] = p;
return _viscosity->getValue(vars);
}

double TwoPhaseFlowWithPPMaterialProperties::getGasViscosity(
const double p, const double T) const
{
ArrayType vars;
vars[static_cast<int>(MaterialLib::Fluid::PropertyVariableType::T)] = T;
vars[static_cast<int>(MaterialLib::Fluid::PropertyVariableType::pg)] = p;
return _gas_viscosity->getValue(vars);
}

Eigen::MatrixXd const& TwoPhaseFlowWithPPMaterialProperties::getPermeability(
const double /*t*/, const ProcessLib::SpatialPosition& /*pos*/,
const int /*dim*/) const
{
return _intrinsic_permeability_models[_current_material_id];
}

double TwoPhaseFlowWithPPMaterialProperties::getPorosity(
const double /*t*/, const ProcessLib::SpatialPosition& /*pos*/,
const double p, const double T, const double porosity_variable) const
{
const double porosity =
_porosity_models[_current_material_id]->getValue(porosity_variable, T);

return porosity;
}

} // end of namespace
} // end of namespace
Loading
0