Skip to content
Snippets Groups Projects
Commit 53ecd0fa authored by wenqing's avatar wenqing
Browse files

[FL] Added a model creation function for heat conductivity

parent 2e9e8ff0
No related branches found
No related tags found
No related merge requests found
/**
* \brief A function for creating a thermal conductivity 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 CreateFluidThermalConductivityModel.cpp
*
*/
#include "CreateFluidThermalConductivityModel.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> createFluidThermalConductivityModel(
BaseLib::ConfigTree const& config)
{
//! \ogs_file_param{material__fluid__thermal_conductivity__type}
auto const type = config.getConfigParameter<std::string>("type");
if (type == "Constant")
return std::unique_ptr<FluidProperty>(new ConstantFluidProperty(
//! \ogs_file_param{material__fluid__thermal_conductivity__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 thermal conductivity 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 CreateFluidThermalConductivityModel.h
*
*/
#ifndef OGS_CREATE_FLUID_THERMAL_CONDUCTIVITY_MODEL_H
#define OGS_CREATE_FLUID_THERMAL_CONDUCTIVITY_MODEL_H
#include <memory>
namespace BaseLib
{
class ConfigTree;
}
namespace MaterialLib
{
namespace Fluid
{
class FluidProperty;
/**
* Create a thermal conductivity model
* \param config ConfigTree object has a tag of `<thermal_conductivity>`
*/
std::unique_ptr<FluidProperty> createFluidThermalConductivityModel(
BaseLib::ConfigTree const& config);
} // end namespace
} // end namespace
#endif // OGS_CREATE_FLUID_THERMAL_CONDUCTIVITY_MODEL_H
...@@ -34,7 +34,7 @@ std::unique_ptr<FluidProperty> createSpecificFluidHeatCapacityModel( ...@@ -34,7 +34,7 @@ std::unique_ptr<FluidProperty> createSpecificFluidHeatCapacityModel(
BaseLib::ConfigTree conf(ptree, "", BaseLib::ConfigTree::onerror, BaseLib::ConfigTree conf(ptree, "", BaseLib::ConfigTree::onerror,
BaseLib::ConfigTree::onwarning); BaseLib::ConfigTree::onwarning);
auto const& sub_config = conf.getConfigSubtree("specific_heat_capacity"); auto const& sub_config = conf.getConfigSubtree("specific_heat_capacity");
return MaterialLib::Fluid::createSpecificFluidHeatCapacityModel(sub_config); return createSpecificFluidHeatCapacityModel(sub_config);
} }
TEST(MaterialFluid, checkConstantSpecificFluidHeatCapacityModel) TEST(MaterialFluid, checkConstantSpecificFluidHeatCapacityModel)
......
/**
* \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 TestFluidThermalConductivityModel.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/ThermalConductivity/CreateFluidThermalConductivityModel.h"
#include "MaterialLib/Fluid/Density/LiquidDensity.h"
using namespace MaterialLib;
using namespace MaterialLib::Fluid;
using ArrayType = MaterialLib::Fluid::FluidProperty::ArrayType;
std::unique_ptr<FluidProperty> createFluidThermalConductivityModel(
const char xml[])
{
auto const ptree = readXml(xml);
BaseLib::ConfigTree conf(ptree, "", BaseLib::ConfigTree::onerror,
BaseLib::ConfigTree::onwarning);
auto const& sub_config = conf.getConfigSubtree("thermal_conductivity");
return createFluidThermalConductivityModel(sub_config);
}
TEST(Material, checkConstantFluidThermalConductivity)
{
const char xml[] =
"<thermal_conductivity>"
" <type>Constant</type>"
" <value> .45 </value> "
"</thermal_conductivity>";
const auto lambda = createFluidThermalConductivityModel(xml);
ArrayType dummy;
ASSERT_EQ(.45, lambda->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