本文整理汇总了C++中baselib::ConfigTree::getConfigSubtreeOptional方法的典型用法代码示例。如果您正苦于以下问题:C++ ConfigTree::getConfigSubtreeOptional方法的具体用法?C++ ConfigTree::getConfigSubtreeOptional怎么用?C++ ConfigTree::getConfigSubtreeOptional使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类baselib::ConfigTree
的用法示例。
在下文中一共展示了ConfigTree::getConfigSubtreeOptional方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createFluidProperties
std::unique_ptr<FluidProperties> createFluidProperties(
BaseLib::ConfigTree const& config)
{
//! \ogs_file_param{material__fluid__density}
auto const& rho_conf = config.getConfigSubtree("density");
auto liquid_density = MaterialLib::Fluid::createFluidDensityModel(rho_conf);
//! \ogs_file_param{material__fluid__viscosity}
auto const& mu_conf = config.getConfigSubtree("viscosity");
auto viscosity = MaterialLib::Fluid::createViscosityModel(mu_conf);
const bool is_mu_density_dependent =
(viscosity->getName().find("density dependent") != std::string::npos);
bool is_cp_density_dependent = false;
std::unique_ptr<MaterialLib::Fluid::FluidProperty> specific_heat_capacity =
nullptr;
auto heat_capacity__opt_conf =
//! \ogs_file_param{material__fluid__specific_heat_capacity}
config.getConfigSubtreeOptional("specific_heat_capacity");
if (heat_capacity__opt_conf)
{
const auto& heat_capacity_conf = *heat_capacity__opt_conf;
specific_heat_capacity =
createSpecificFluidHeatCapacityModel(heat_capacity_conf);
is_cp_density_dependent =
(specific_heat_capacity->getName().find("density dependent") !=
std::string::npos);
}
bool is_KT_density_dependent = false;
std::unique_ptr<MaterialLib::Fluid::FluidProperty> thermal_conductivity =
nullptr;
auto const& thermal_conductivity_opt_conf =
//! \ogs_file_param{material__fluid__thermal_conductivity}
config.getConfigSubtreeOptional("thermal_conductivity");
if (thermal_conductivity_opt_conf)
{
auto const& thermal_conductivity_conf = *thermal_conductivity_opt_conf;
thermal_conductivity =
MaterialLib::Fluid::createFluidThermalConductivityModel(
thermal_conductivity_conf);
is_KT_density_dependent =
(specific_heat_capacity->getName().find("density dependent") !=
std::string::npos);
}
if (is_mu_density_dependent || is_cp_density_dependent ||
is_KT_density_dependent)
return std::make_unique<
MaterialLib::Fluid::FluidPropertiesWithDensityDependentModels>(
std::move(liquid_density), std::move(viscosity),
std::move(specific_heat_capacity), std::move(thermal_conductivity),
is_mu_density_dependent, is_cp_density_dependent,
is_KT_density_dependent);
return std::make_unique<
MaterialLib::Fluid::PrimaryVariableDependentFluidProperties>(
std::move(liquid_density), std::move(viscosity),
std::move(specific_heat_capacity), std::move(thermal_conductivity));
}
示例2: createSecondaryVariables
void createSecondaryVariables(
BaseLib::ConfigTree const& config,
SecondaryVariableCollection& secondary_variables,
NumLib::NamedFunctionCaller& named_function_caller)
{
auto sec_vars_config =
//! \ogs_file_param{prj__processes__process__secondary_variables}
config.getConfigSubtreeOptional("secondary_variables");
if (!sec_vars_config)
return;
for (
auto sec_var_config :
//! \ogs_file_param{prj__processes__process__secondary_variables__secondary_variable}
sec_vars_config->getConfigSubtreeList("secondary_variable"))
{
auto const type =
//! \ogs_file_attr{prj__processes__process__secondary_variables__secondary_variable__type}
sec_var_config.getConfigAttribute<std::string>("type");
auto const internal_name =
//! \ogs_file_attr{prj__processes__process__secondary_variables__secondary_variable__internal_name}
sec_var_config.getConfigAttribute<std::string>("internal_name");
auto const output_name =
//! \ogs_file_attr{prj__processes__process__secondary_variables__secondary_variable__output_name}
sec_var_config.getConfigAttribute<std::string>("output_name");
secondary_variables.addNameMapping(internal_name, output_name);
if (type == "static")
{
// alright
}
else if (type == "dynamic")
{
auto const& sink_fct = internal_name;
for (
auto const plug :
//! \ogs_file_param{prj__processes__process__secondary_variables__secondary_variable__plug}
sec_var_config.getConfigParameterList("plug"))
{
auto const sink_arg =
//! \ogs_file_attr{prj__processes__process__secondary_variables__secondary_variable__plug__sink_arg}
plug.getConfigAttribute<std::string>("sink_arg");
auto const source_fct =
//! \ogs_file_attr{prj__processes__process__secondary_variables__secondary_variable__plug__source_fct}
plug.getConfigAttribute<std::string>("source_fct");
named_function_caller.plug(sink_fct, sink_arg, source_fct);
}
}
}
}
示例3: createGroundwaterFlowProcess
std::unique_ptr<Process> createGroundwaterFlowProcess(
MeshLib::Mesh& mesh,
Process::NonlinearSolver& nonlinear_solver,
std::unique_ptr<Process::TimeDiscretization>&& time_discretization,
std::vector<ProcessVariable> const& variables,
std::vector<std::unique_ptr<ParameterBase>> const& parameters,
BaseLib::ConfigTree const& config)
{
//! \ogs_file_param{process__type}
config.checkConfigParameter("type", "GROUNDWATER_FLOW");
DBUG("Create GroundwaterFlowProcess.");
// Process variable.
auto process_variables = findProcessVariables(
variables, config,
{//! \ogs_file_param_special{process__GROUNDWATER_FLOW__process_variables__process_variable}
"process_variable"});
// Hydraulic conductivity parameter.
auto& hydraulic_conductivity = findParameter<double,
MeshLib::Element const&>(
config,
//! \ogs_file_param_special{process__GROUNDWATER_FLOW__hydraulic_conductivity}
"hydraulic_conductivity",
parameters);
DBUG("Use \'%s\' as hydraulic conductivity parameter.",
hydraulic_conductivity.name.c_str());
GroundwaterFlowProcessData process_data{hydraulic_conductivity};
SecondaryVariableCollection secondary_variables{
//! \ogs_file_param{process__secondary_variables}
config.getConfigSubtreeOptional("secondary_variables"),
{//! \ogs_file_param_special{process__GROUNDWATER_FLOW__secondary_variables__darcy_velocity_x}
"darcy_velocity_x",
//! \ogs_file_param_special{process__GROUNDWATER_FLOW__secondary_variables__darcy_velocity_y}
"darcy_velocity_y",
//! \ogs_file_param_special{process__GROUNDWATER_FLOW__secondary_variables__darcy_velocity_z}
"darcy_velocity_z"}};
ProcessOutput
//! \ogs_file_param{process__output}
process_output{config.getConfigSubtree("output"), process_variables,
secondary_variables};
return std::unique_ptr<Process>{new GroundwaterFlowProcess{
mesh, nonlinear_solver, std::move(time_discretization),
std::move(process_variables), std::move(process_data),
std::move(secondary_variables), std::move(process_output)}};
}
示例4: assert
std::unique_ptr<Output> Output::
newInstance(const BaseLib::ConfigTree &config, std::string const& output_directory)
{
auto const output_iteration_results =
//! \ogs_file_param{prj__output__output_iteration_results}
config.getConfigParameterOptional<bool>("output_iteration_results");
std::unique_ptr<Output> out{new Output{
BaseLib::joinPaths(output_directory,
//! \ogs_file_param{prj__output__prefix}
config.getConfigParameter<std::string>("prefix")),
output_iteration_results ? *output_iteration_results : false}};
//! \ogs_file_param{prj__output__timesteps}
if (auto const timesteps = config.getConfigSubtreeOptional("timesteps"))
{
//! \ogs_file_param{prj__output__timesteps__pair}
for (auto pair : timesteps->getConfigSubtreeList("pair"))
{
//! \ogs_file_param{prj__output__timesteps__pair__repeat}
auto repeat = pair.getConfigParameter<unsigned>("repeat");
//! \ogs_file_param{prj__output__timesteps__pair__each_steps}
auto each_steps = pair.getConfigParameter<unsigned>("each_steps");
assert(repeat != 0 && each_steps != 0);
out->_repeats_each_steps.emplace_back(repeat, each_steps);
}
if (out->_repeats_each_steps.empty()) {
OGS_FATAL("You have not given any pair (<repeat/>, <each_steps/>) that defines"
" at which timesteps output shall be written. Aborting.");
}
}
else
{
out->_repeats_each_steps.emplace_back(1, 1);
}
return out;
}
示例5: DBUG
ProcessVariable::ProcessVariable(
BaseLib::ConfigTree const& config,
MeshLib::Mesh& mesh,
std::vector<std::unique_ptr<MeshLib::Mesh>> const& meshes,
std::vector<std::unique_ptr<ParameterBase>> const& parameters)
: //! \ogs_file_param{prj__process_variables__process_variable__name}
_name(config.getConfigParameter<std::string>("name")),
_mesh(mesh),
//! \ogs_file_param{prj__process_variables__process_variable__components}
_n_components(config.getConfigParameter<int>("components")),
//! \ogs_file_param{prj__process_variables__process_variable__order}
_shapefunction_order(config.getConfigParameter<unsigned>("order")),
_initial_condition(findParameter<double>(
//! \ogs_file_param{prj__process_variables__process_variable__initial_condition}
config.getConfigParameter<std::string>("initial_condition"),
parameters, _n_components))
{
DBUG("Constructing process variable %s", _name.c_str());
if (_shapefunction_order < 1 || 2 < _shapefunction_order)
OGS_FATAL("The given shape function order %d is not supported", _shapefunction_order);
// Boundary conditions
//! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions}
if (auto bcs_config = config.getConfigSubtreeOptional("boundary_conditions"))
{
for (auto bc_config :
//! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition}
bcs_config->getConfigSubtreeList("boundary_condition"))
{
auto const& mesh = findMeshInConfig(bc_config, meshes);
auto component_id =
//! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__component}
bc_config.getConfigParameterOptional<int>("component");
if (!component_id && _n_components == 1)
// default value for single component vars.
component_id = 0;
_bc_configs.emplace_back(std::move(bc_config), mesh, component_id);
}
} else {
INFO("No boundary conditions found.");
}
// Source terms
//! \ogs_file_param{prj__process_variables__process_variable__source_terms}
if (auto sts_config = config.getConfigSubtreeOptional("source_terms"))
{
for (auto st_config :
//! \ogs_file_param{prj__process_variables__process_variable__source_terms__source_term}
sts_config->getConfigSubtreeList("source_term"))
{
MeshLib::Mesh const& mesh = findMeshInConfig(st_config, meshes);
auto component_id =
//! \ogs_file_param{prj__process_variables__process_variable__source_terms__source_term__component}
st_config.getConfigParameterOptional<int>("component");
if (!component_id && _n_components == 1)
// default value for single component vars.
component_id = 0;
_source_term_configs.emplace_back(std::move(st_config), mesh,
component_id);
}
} else {
INFO("No source terms found.");
}
}