Skip to content
Snippets Groups Projects
Commit 2e9e8ff0 authored by wenqing's avatar wenqing
Browse files

[FL] Added a function to create heat capacity models of fluid

parent 144e1020
No related branches found
No related tags found
No related merge requests found
...@@ -9,6 +9,8 @@ append_source_files(SOURCES Fluid/Density) ...@@ -9,6 +9,8 @@ append_source_files(SOURCES Fluid/Density)
append_source_files(SOURCES Fluid/Viscosity) append_source_files(SOURCES Fluid/Viscosity)
append_source_files(SOURCES Fluid/GibbsFreeEnergy) append_source_files(SOURCES Fluid/GibbsFreeEnergy)
append_source_files(SOURCES Fluid/FluidProperties) append_source_files(SOURCES Fluid/FluidProperties)
append_source_files(SOURCES Fluid/SpecificHeatCapacity)
append_source_files(SOURCES Fluid/ThermalConductivity)
append_source_files(SOURCES PorousMedium/Porosity) append_source_files(SOURCES PorousMedium/Porosity)
append_source_files(SOURCES PorousMedium/Storage) append_source_files(SOURCES PorousMedium/Storage)
......
/**
* \brief A function for creating a specific heat capacity model for fluid
*
* \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
*
* \file CreateSpecificFluidHeatCapacityModel.cpp
*
*/
#include "CreateSpecificFluidHeatCapacityModel.h"
#include "BaseLib/Error.h"
#include "BaseLib/ConfigTree.h"
#include "MaterialLib/Fluid/FluidProperty.h"
#include "MaterialLib/Fluid/ConstantFluidProperty.h"
namespace MaterialLib
{
namespace Fluid
{
std::unique_ptr<FluidProperty> createSpecificFluidHeatCapacityModel(
BaseLib::ConfigTree const& config)
{
//! \ogs_file_param{material__fluid__specific_heat_capacity__type}
auto const type = config.getConfigParameter<std::string>("type");
if (type == "Constant")
return std::unique_ptr<FluidProperty>(new ConstantFluidProperty(
//! \ogs_file_param{material__fluid__specific_heat_capacity__Constant__value}
config.getConfigParameter<double>("value")));
// TODO: add more models
else
{
OGS_FATAL(
"The viscosity type %s is unavailable.\n"
"The available type is \n\tConstant\n",
type.data());
}
}
} // end namespace
} // end namespace
/**
* \brief A function for creating a specific heat capacity model for fluid
*
* \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
*
* \file CreateSpecificFluidHeatCapacityModel.h
*
*/
#ifndef OGS_CREATESPECIFICFLUIDHEATCAPACITYMODEL_H
#define OGS_CREATESPECIFICFLUIDHEATCAPACITYMODEL_H
#include <memory>
namespace BaseLib
{
class ConfigTree;
}
namespace MaterialLib
{
namespace Fluid
{
class FluidProperty;
/**
* Create a specific heat capacity model
* \param config ConfigTree object has a tag of `<specific_heat_capacity>`
*/
std::unique_ptr<FluidProperty> createSpecificFluidHeatCapacityModel(
BaseLib::ConfigTree const& config);
} // end namespace
} // end namespace
#endif /* OGS_CREATESPECIFICFLUIDHEATCAPACITY_H */
/**
* \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
*
* \file TestFluidSpecificHeatCapacityModel.cpp
*
*/
#include <gtest/gtest.h>
#include <memory>
#include "Tests/TestTools.h"
#include "BaseLib/ConfigTree.h"
#include "MaterialLib/PhysicalConstant.h"
#include "MaterialLib/Fluid/FluidProperty.h"
#include "MaterialLib/Fluid/ConstantFluidProperty.h"
#include "MaterialLib/Fluid/SpecificHeatCapacity/CreateSpecificFluidHeatCapacityModel.h"
using namespace MaterialLib;
using namespace MaterialLib::Fluid;
using ArrayType = MaterialLib::Fluid::FluidProperty::ArrayType;
std::unique_ptr<FluidProperty> createSpecificFluidHeatCapacityModel(
const char xml[])
{
auto const ptree = readXml(xml);
BaseLib::ConfigTree conf(ptree, "", BaseLib::ConfigTree::onerror,
BaseLib::ConfigTree::onwarning);
auto const& sub_config = conf.getConfigSubtree("specific_heat_capacity");
return MaterialLib::Fluid::createSpecificFluidHeatCapacityModel(sub_config);
}
TEST(MaterialFluid, checkConstantSpecificFluidHeatCapacityModel)
{
const char xml[] =
"<specific_heat_capacity>"
" <type>Constant</type>"
" <value> 900. </value> "
"</specific_heat_capacity>";
const auto cp = createSpecificFluidHeatCapacityModel(xml);
ArrayType dummy;
ASSERT_EQ(900., cp->getValue(dummy));
}
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