Skip to content
Snippets Groups Projects
Commit 7c22fbaa authored by wenqing's avatar wenqing
Browse files

[TimeInterval] Added a creator

parent 5ba81b63
No related branches found
No related tags found
No related merge requests found
/**
* \copyright
* Copyright (c) 2012-2018, 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: TimeInterval.cpp
*
* Created on November 27, 2018, 5:06 PM
*
*/
#include "TimeInterval.h"
#include "BaseLib/ConfigTree.h"
namespace NumLib
{
std::unique_ptr<TimeInterval> createTimeInterval(
BaseLib::ConfigTree const& config)
{
//! \ogs_file_param{prj__time_loop__processes__process__time_interval}
auto const& time_interval_config = config.getConfigSubtree("time_interval");
const double start_time =
//! \ogs_file_param{prj__time_loop__processes__process__time_interval__start_time}
time_interval_config.getConfigParameter<double>("start_time");
const double end_time =
//! \ogs_file_param{prj__time_loop__processes__process__time_interval__end_time}
time_interval_config.getConfigParameter<double>("end_time");
return std::make_unique<NumLib::TimeInterval>(start_time, end_time);
}
} // end of namespace
...@@ -12,6 +12,11 @@ ...@@ -12,6 +12,11 @@
*/ */
#pragma once #pragma once
namespace BaseLib
{
class ConfigTree;
}
namespace NumLib namespace NumLib
{ {
/*! /*!
...@@ -36,4 +41,7 @@ private: ...@@ -36,4 +41,7 @@ private:
const double _end_time; const double _end_time;
}; };
std::unique_ptr<TimeInterval> createTimeInterval(
BaseLib::ConfigTree const& config);
} // end of namespace } // end of namespace
...@@ -25,14 +25,13 @@ namespace ProcessLib ...@@ -25,14 +25,13 @@ namespace ProcessLib
{ {
DirichletBoundaryConditionWithinTimeInterval:: DirichletBoundaryConditionWithinTimeInterval::
DirichletBoundaryConditionWithinTimeInterval( DirichletBoundaryConditionWithinTimeInterval(
double const start_time, double const end_time, std::unique_ptr<NumLib::TimeInterval> time_interval,
Parameter<double> const& parameter, MeshLib::Mesh const& bc_mesh, Parameter<double> const& parameter, MeshLib::Mesh const& bc_mesh,
NumLib::LocalToGlobalIndexMap const& dof_table_bulk, NumLib::LocalToGlobalIndexMap const& dof_table_bulk,
int const variable_id, int const component_id) int const variable_id, int const component_id)
: DirichletBoundaryCondition(parameter, bc_mesh, dof_table_bulk, : DirichletBoundaryCondition(parameter, bc_mesh, dof_table_bulk,
variable_id, component_id), variable_id, component_id),
_time_interval( _time_interval(std::move(time_interval))
std::make_unique<NumLib::TimeInterval>(start_time, end_time))
{ {
} }
...@@ -48,8 +47,6 @@ void DirichletBoundaryConditionWithinTimeInterval::getEssentialBCValues( ...@@ -48,8 +47,6 @@ void DirichletBoundaryConditionWithinTimeInterval::getEssentialBCValues(
bc_values.ids.clear(); bc_values.ids.clear();
bc_values.values.clear(); bc_values.values.clear();
return;
} }
std::unique_ptr<DirichletBoundaryCondition> std::unique_ptr<DirichletBoundaryCondition>
...@@ -86,17 +83,12 @@ createDirichletBoundaryConditionWithinTimeInterval( ...@@ -86,17 +83,12 @@ createDirichletBoundaryConditionWithinTimeInterval(
} }
#endif // USE_PETSC #endif // USE_PETSC
const double start_time = //! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__DirichletWithinTimeInterval__time_interval}
//! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__DirichletWithinTimeInterval__start_time} config.peekConfigParameter<std::string>("time_interval");
config.getConfigParameter<double>("start_time");
const double end_time =
//! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__DirichletWithinTimeInterval__end_time}
config.getConfigParameter<double>("end_time");
return std::make_unique<DirichletBoundaryConditionWithinTimeInterval>( return std::make_unique<DirichletBoundaryConditionWithinTimeInterval>(
start_time, end_time, param, bc_mesh, dof_table_bulk, variable_id, NumLib::createTimeInterval(config), param, bc_mesh,
component_id); dof_table_bulk, variable_id, component_id);
} }
} // namespace ProcessLib } // namespace ProcessLib
...@@ -28,7 +28,7 @@ class DirichletBoundaryConditionWithinTimeInterval final ...@@ -28,7 +28,7 @@ class DirichletBoundaryConditionWithinTimeInterval final
{ {
public: public:
DirichletBoundaryConditionWithinTimeInterval( DirichletBoundaryConditionWithinTimeInterval(
double const start_time, double const end_time, std::unique_ptr<NumLib::TimeInterval> time_interval,
Parameter<double> const& parameter, MeshLib::Mesh const& bc_mesh, Parameter<double> const& parameter, MeshLib::Mesh const& bc_mesh,
NumLib::LocalToGlobalIndexMap const& dof_table_bulk, NumLib::LocalToGlobalIndexMap const& dof_table_bulk,
int const variable_id, int const component_id); int const variable_id, int const component_id);
......
...@@ -136,8 +136,10 @@ ...@@ -136,8 +136,10 @@
<geometry>bottom</geometry> <geometry>bottom</geometry>
<type>DirichletWithinTimeInterval</type> <type>DirichletWithinTimeInterval</type>
<parameter>bc_bottom</parameter> <parameter>bc_bottom</parameter>
<start_time> 0.0 </start_time> <time_interval>
<end_time> 10.0 </end_time> <start_time> 0.0 </start_time>
<end_time> 10.0 </end_time>
</time_interval>
</boundary_condition> </boundary_condition>
</boundary_conditions> </boundary_conditions>
</process_variable> </process_variable>
......
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