Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2272 from wenqing/time_dependent_D_BC
Dirichlet boundary condition within a time interval
- Loading branch information
Showing
19 changed files
with
666 additions
and
79 deletions.
There are no files selected for viewing
This file contains 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,36 @@ | ||
/** | ||
* \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 BaseLib | ||
{ | ||
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_interval_config.getConfigParameter<double>("start"); | ||
|
||
const double end_time = | ||
//! \ogs_file_param{prj__time_loop__processes__process__time_interval__end} | ||
time_interval_config.getConfigParameter<double>("end"); | ||
|
||
return std::make_unique<BaseLib::TimeInterval>(start_time, end_time); | ||
} | ||
} // end of namespace |
This file contains 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,46 @@ | ||
/** | ||
* | ||
* \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.h | ||
* | ||
* Created on November 26, 2018, 4:44 PM | ||
*/ | ||
#pragma once | ||
|
||
#include <memory> | ||
|
||
namespace BaseLib | ||
{ | ||
class ConfigTree; | ||
|
||
/*! | ||
* Class for a time interval, which has a member to check whether the given time | ||
* is in this time interval. | ||
*/ | ||
class TimeInterval final | ||
{ | ||
public: | ||
TimeInterval(const double start_time, const double end_time) | ||
: _start_time(start_time), _end_time(end_time) | ||
{ | ||
} | ||
|
||
bool contains(const double current_time) const | ||
{ | ||
return (current_time >= _start_time && current_time <= _end_time); | ||
} | ||
|
||
private: | ||
const double _start_time; | ||
const double _end_time; | ||
}; | ||
|
||
std::unique_ptr<TimeInterval> createTimeInterval( | ||
BaseLib::ConfigTree const& config); | ||
|
||
} // end of namespace |
4 changes: 4 additions & 0 deletions
4
...boundary_condition/DirichletWithinTimeInterval/c_DirichletWithinTimeInterval.md
This file contains 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,4 @@ | ||
It defines a Dirichlet boundary condition that exists only in a time interval. | ||
|
||
Benchmark: | ||
Tests/Data/Parabolic/LiquidFlow/TimeIntervalDirichletBC/TimeIntervalDirichletBC.prj |
2 changes: 2 additions & 0 deletions
2
...undary_conditions/boundary_condition/DirichletWithinTimeInterval/t_parameter.md
This file contains 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,2 @@ | ||
The value of the Dirichlet boundary condition within the | ||
specified time interval. |
1 change: 1 addition & 0 deletions
1
...ry_conditions/boundary_condition/DirichletWithinTimeInterval/t_time_interval.md
This file contains 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 @@ | ||
\copydoc ogs_file_param__prj__time_loop__processes__process__time_interval |
1 change: 1 addition & 0 deletions
1
...on/ProjectFile/prj/time_loop/processes/process/time_interval/i_time_interval.md
This file contains 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 @@ | ||
It defines a time interval. |
1 change: 1 addition & 0 deletions
1
Documentation/ProjectFile/prj/time_loop/processes/process/time_interval/t_end.md
This file contains 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 @@ | ||
The end time of the time interval. |
1 change: 1 addition & 0 deletions
1
Documentation/ProjectFile/prj/time_loop/processes/process/time_interval/t_start.md
This file contains 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 @@ | ||
The start time of the time interval. |
This file contains 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 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 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
95 changes: 95 additions & 0 deletions
95
ProcessLib/BoundaryCondition/DirichletBoundaryConditionAuxiliaryFunctions.cpp
This file contains 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,95 @@ | ||
/** | ||
* | ||
* \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: DirichletBoundaryConditionAuxiliaryFunctions.cpp | ||
* | ||
* Created on November 28, 2018, 11:26 AM | ||
*/ | ||
#include "DirichletBoundaryConditionAuxiliaryFunctions.h" | ||
|
||
#include "NumLib/IndexValueVector.h" | ||
#include "NumLib/DOF/LocalToGlobalIndexMap.h" | ||
#include "ProcessLib/Parameter/Parameter.h" | ||
|
||
namespace ProcessLib | ||
{ | ||
void checkParametersOfDirichletBoundaryCondition( | ||
MeshLib::Mesh const& bc_mesh, | ||
NumLib::LocalToGlobalIndexMap const& dof_table_bulk, | ||
int const variable_id, | ||
int const component_id) | ||
{ | ||
if (variable_id >= | ||
static_cast<int>(dof_table_bulk.getNumberOfVariables()) || | ||
component_id >= | ||
dof_table_bulk.getNumberOfVariableComponents(variable_id)) | ||
{ | ||
OGS_FATAL( | ||
"Variable id or component id too high. Actual values: (%d, " | ||
"%d), maximum values: (%d, %d).", | ||
variable_id, component_id, dof_table_bulk.getNumberOfVariables(), | ||
dof_table_bulk.getNumberOfVariableComponents(variable_id)); | ||
} | ||
|
||
if (!bc_mesh.getProperties().existsPropertyVector<std::size_t>( | ||
"bulk_node_ids")) | ||
{ | ||
OGS_FATAL( | ||
"The required bulk node ids map does not exist in the boundary " | ||
"mesh '%s'.", | ||
bc_mesh.getName().c_str()); | ||
} | ||
|
||
DBUG( | ||
"Found %d nodes for Dirichlet BCs for the variable %d and " | ||
"component " | ||
"%d", | ||
bc_mesh.getNodes().size(), variable_id, component_id); | ||
} | ||
|
||
void getEssentialBCValuesLocal( | ||
Parameter<double> const& parameter, MeshLib::Mesh const& bc_mesh, | ||
NumLib::LocalToGlobalIndexMap const& dof_table_boundary, | ||
int const variable_id, int const component_id, const double t, | ||
GlobalVector const& /*x*/, | ||
NumLib::IndexValueVector<GlobalIndexType>& bc_values) | ||
{ | ||
SpatialPosition pos; | ||
|
||
bc_values.ids.clear(); | ||
bc_values.values.clear(); | ||
|
||
// convert mesh node ids to global index for the given component | ||
bc_values.ids.reserve(bc_values.ids.size() + bc_mesh.getNumberOfNodes()); | ||
bc_values.values.reserve(bc_values.values.size() + | ||
bc_mesh.getNumberOfNodes()); | ||
for (auto const* const node : bc_mesh.getNodes()) | ||
{ | ||
auto const id = node->getID(); | ||
pos.setNodeID(node->getID()); | ||
// TODO: that might be slow, but only done once | ||
auto const global_index = dof_table_boundary.getGlobalIndex( | ||
{bc_mesh.getID(), MeshLib::MeshItemType::Node, id}, variable_id, | ||
component_id); | ||
if (global_index == NumLib::MeshComponentMap::nop) | ||
continue; | ||
// For the DDC approach (e.g. with PETSc option), the negative | ||
// index of global_index means that the entry by that index is a ghost | ||
// one, which should be dropped. Especially for PETSc routines | ||
// MatZeroRows and MatZeroRowsColumns, which are called to apply the | ||
// Dirichlet BC, the negative index is not accepted like other matrix or | ||
// vector PETSc routines. Therefore, the following if-condition is | ||
// applied. | ||
if (global_index >= 0) | ||
{ | ||
bc_values.ids.emplace_back(global_index); | ||
bc_values.values.emplace_back(parameter(t, pos).front()); | ||
} | ||
} | ||
} | ||
} // end of name space |
Oops, something went wrong.