-
Notifications
You must be signed in to change notification settings - Fork 239
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
endJunction
merged 2 commits into
ufz:master
from
Yonghui56:pr_twophasewithpp_curve_test
Nov 20, 2016
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
MaterialLib/TwoPhaseModels/CreateTwoPhaseFlowMaterialProperties.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/** | ||
* \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
37
MaterialLib/TwoPhaseModels/CreateTwoPhaseFlowMaterialProperties.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
133
MaterialLib/TwoPhaseModels/TwoPhaseFlowWithPPMaterialProperties.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.