Skip to content
Snippets Groups Projects
Commit 3dfd80ea authored by wenqing's avatar wenqing Committed by Dmitri Naumov
Browse files

[Process] Moved BoudaryCondition and SourceTerms to one directory.

parent 8278941d
No related branches found
No related tags found
No related merge requests found
Showing
with 54 additions and 53 deletions
...@@ -34,8 +34,7 @@ if(OGS_USE_PYTHON) ...@@ -34,8 +34,7 @@ if(OGS_USE_PYTHON)
# this is up to you). TODO: Enable further compiler/linker flags. # this is up to you). TODO: Enable further compiler/linker flags.
target_link_libraries( target_link_libraries(
ogs_embedded_python PUBLIC pybind11::embed ogs_embedded_python PUBLIC pybind11::embed
PRIVATE ProcessLibBoundaryConditionPythonModule PRIVATE ProcessLibBoundaryConditionAndSourceTermPythonModule
ProcessLibSourceTermPythonModule
) )
target_compile_definitions( target_compile_definitions(
ogs_embedded_python ogs_embedded_python
......
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
#include <pybind11/embed.h> #include <pybind11/embed.h>
#include "BaseLib/Logging.h" #include "BaseLib/Logging.h"
#include "ProcessLib/BoundaryCondition/Python/BHEInflowPythonBoundaryConditionModule.h" #include "ProcessLib/BoundaryConditionAndSourceTerm/Python/BHEInflowPythonBoundaryConditionModule.h"
#include "ProcessLib/BoundaryCondition/Python/PythonBoundaryConditionModule.h" #include "ProcessLib/BoundaryConditionAndSourceTerm/Python/PythonBoundaryConditionModule.h"
#include "ProcessLib/SourceTerms/Python/PythonSourceTermModule.h" #include "ProcessLib/BoundaryConditionAndSourceTerm/Python/PythonSourceTermModule.h"
PYBIND11_EMBEDDED_MODULE(OpenGeoSys, m) PYBIND11_EMBEDDED_MODULE(OpenGeoSys, m)
{ {
......
...@@ -22,7 +22,7 @@ namespace NumLib ...@@ -22,7 +22,7 @@ namespace NumLib
class LocalToGlobalIndexMap; class LocalToGlobalIndexMap;
template <typename> template <typename>
struct IndexValueVector; struct IndexValueVector;
} } // namespace NumLib
namespace ParameterLib namespace ParameterLib
{ {
struct ParameterBase; struct ParameterBase;
......
...@@ -10,11 +10,10 @@ ...@@ -10,11 +10,10 @@
#pragma once #pragma once
#include "BoundaryCondition.h"
#include "NumLib/IndexValueVector.h" #include "NumLib/IndexValueVector.h"
#include "ProcessLib/ProcessVariable.h" #include "ProcessLib/ProcessVariable.h"
#include "BoundaryCondition.h"
namespace ProcessLib namespace ProcessLib
{ {
class BoundaryConditionCollection final class BoundaryConditionCollection final
...@@ -35,7 +34,8 @@ public: ...@@ -35,7 +34,8 @@ public:
getKnownSolutions(double const t, GlobalVector const& x) const getKnownSolutions(double const t, GlobalVector const& x) const
{ {
auto const n_bcs = _boundary_conditions.size(); auto const n_bcs = _boundary_conditions.size();
for (std::size_t i=0; i<n_bcs; ++i) { for (std::size_t i = 0; i < n_bcs; ++i)
{
auto const& bc = *_boundary_conditions[i]; auto const& bc = *_boundary_conditions[i];
auto& dirichlet_storage = _dirichlet_bcs[i]; auto& dirichlet_storage = _dirichlet_bcs[i];
bc.getEssentialBCValues(t, x, dirichlet_storage); bc.getEssentialBCValues(t, x, dirichlet_storage);
...@@ -73,7 +73,8 @@ public: ...@@ -73,7 +73,8 @@ public:
} }
private: private:
mutable std::vector<NumLib::IndexValueVector<GlobalIndexType>> _dirichlet_bcs; mutable std::vector<NumLib::IndexValueVector<GlobalIndexType>>
_dirichlet_bcs;
std::vector<std::unique_ptr<BoundaryCondition>> _boundary_conditions; std::vector<std::unique_ptr<BoundaryCondition>> _boundary_conditions;
std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const&
_parameters; _parameters;
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include "MeshLib/MeshSearch/NodeSearch.h" // for getUniqueNodes #include "MeshLib/MeshSearch/NodeSearch.h" // for getUniqueNodes
#include "MeshLib/Node.h" #include "MeshLib/Node.h"
#include "ParameterLib/Utils.h" #include "ParameterLib/Utils.h"
#include "ProcessLib/Utils/ForBoundaryConditionOrSourceTerm/CreateLocalAssemblers.h" #include "ProcessLib/BoundaryConditionAndSourceTerm/Utils/CreateLocalAssemblers.h"
namespace ProcessLib namespace ProcessLib
{ {
...@@ -78,8 +78,9 @@ ConstraintDirichletBoundaryCondition::ConstraintDirichletBoundaryCondition( ...@@ -78,8 +78,9 @@ ConstraintDirichletBoundaryCondition::ConstraintDirichletBoundaryCondition(
"bulk_node_ids", MeshLib::MeshItemType::Node, 1); "bulk_node_ids", MeshLib::MeshItemType::Node, 1);
auto const& bulk_nodes = bulk_mesh.getNodes(); auto const& bulk_nodes = bulk_mesh.getNodes();
auto get_bulk_element_face_id = [&](auto const bulk_element_id, auto get_bulk_element_face_id =
MeshLib::Element const* bc_elem) { [&](auto const bulk_element_id, MeshLib::Element const* bc_elem)
{
auto const* bulk_elem = _bulk_mesh.getElement(bulk_element_id); auto const* bulk_elem = _bulk_mesh.getElement(bulk_element_id);
std::array<MeshLib::Node*, 3> nodes{ std::array<MeshLib::Node*, 3> nodes{
{bulk_nodes[(*bulk_node_ids)[bc_elem->getNode(0)->getID()]], {bulk_nodes[(*bulk_node_ids)[bc_elem->getNode(0)->getID()]],
...@@ -89,18 +90,20 @@ ConstraintDirichletBoundaryCondition::ConstraintDirichletBoundaryCondition( ...@@ -89,18 +90,20 @@ ConstraintDirichletBoundaryCondition::ConstraintDirichletBoundaryCondition(
}; };
_bulk_ids.reserve(bc_elements.size()); _bulk_ids.reserve(bc_elements.size());
std::transform(begin(bc_elements), end(bc_elements), std::transform(
std::back_inserter(_bulk_ids), [&](auto const* bc_element) { begin(bc_elements), end(bc_elements), std::back_inserter(_bulk_ids),
auto const bulk_element_id = [&](auto const* bc_element)
(*bulk_element_ids)[bc_element->getID()]; {
return std::make_pair(bulk_element_id, auto const bulk_element_id =
get_bulk_element_face_id( (*bulk_element_ids)[bc_element->getID()];
bulk_element_id, bc_element)); return std::make_pair(
}); bulk_element_id,
get_bulk_element_face_id(bulk_element_id, bc_element));
});
const int shape_function_order = 1; const int shape_function_order = 1;
BoundaryConditionOrSourceTerm::createLocalAssemblers< BoundaryConditionAndSourceTerm::createLocalAssemblers<
ConstraintDirichletBoundaryConditionLocalAssembler>( ConstraintDirichletBoundaryConditionLocalAssembler>(
_bulk_mesh.getDimension(), _bc_mesh.getElements(), *_dof_table_boundary, _bulk_mesh.getDimension(), _bc_mesh.getElements(), *_dof_table_boundary,
shape_function_order, _local_assemblers, _bc_mesh.isAxiallySymmetric(), shape_function_order, _local_assemblers, _bc_mesh.isAxiallySymmetric(),
...@@ -121,9 +124,8 @@ void ConstraintDirichletBoundaryCondition::preTimestep( ...@@ -121,9 +124,8 @@ void ConstraintDirichletBoundaryCondition::preTimestep(
x, t, x, t,
[this](std::size_t const element_id, [this](std::size_t const element_id,
MathLib::Point3d const& pnt, double const t, MathLib::Point3d const& pnt, double const t,
std::vector<GlobalVector*> const& x) { std::vector<GlobalVector*> const& x)
return _getFlux(element_id, pnt, t, x); { return _getFlux(element_id, pnt, t, x); });
});
} }
} }
...@@ -138,7 +140,8 @@ void ConstraintDirichletBoundaryCondition::getEssentialBCValues( ...@@ -138,7 +140,8 @@ void ConstraintDirichletBoundaryCondition::getEssentialBCValues(
std::vector<std::pair<GlobalIndexType, double>> tmp_bc_values; std::vector<std::pair<GlobalIndexType, double>> tmp_bc_values;
auto isFlux = [&](const std::size_t element_id) { auto isFlux = [&](const std::size_t element_id)
{
return _lower ? _flux_values[element_id] < _constraint_threshold return _lower ? _flux_values[element_id] < _constraint_threshold
: _flux_values[element_id] > _constraint_threshold; : _flux_values[element_id] > _constraint_threshold;
}; };
...@@ -193,9 +196,8 @@ void ConstraintDirichletBoundaryCondition::getEssentialBCValues( ...@@ -193,9 +196,8 @@ void ConstraintDirichletBoundaryCondition::getEssentialBCValues(
// first: sort the (node id, value) pairs according to the node id // first: sort the (node id, value) pairs according to the node id
std::sort(tmp_bc_values.begin(), tmp_bc_values.end(), std::sort(tmp_bc_values.begin(), tmp_bc_values.end(),
[](std::pair<GlobalIndexType, double> const& a, [](std::pair<GlobalIndexType, double> const& a,
std::pair<GlobalIndexType, double> const& b) { std::pair<GlobalIndexType, double> const& b)
return a.first < b.first; { return a.first < b.first; });
});
// second: average the values over equal node id ranges // second: average the values over equal node id ranges
unsigned cnt = 1; unsigned cnt = 1;
GlobalIndexType current_id = tmp_bc_values.begin()->first; GlobalIndexType current_id = tmp_bc_values.begin()->first;
...@@ -259,11 +261,10 @@ createConstraintDirichletBoundaryCondition( ...@@ -259,11 +261,10 @@ createConstraintDirichletBoundaryCondition(
const int process_id = 0; const int process_id = 0;
auto process_variables = auto process_variables =
constraining_process.getProcessVariables(process_id); constraining_process.getProcessVariables(process_id);
auto constraining_pv = std::find_if( auto constraining_pv =
process_variables.cbegin(), process_variables.cend(), std::find_if(process_variables.cbegin(), process_variables.cend(),
[&constraining_process_variable](ProcessVariable const& pv) { [&constraining_process_variable](ProcessVariable const& pv)
return pv.getName() == constraining_process_variable; { return pv.getName() == constraining_process_variable; });
});
if (constraining_pv == std::end(process_variables)) if (constraining_pv == std::end(process_variables))
{ {
auto const& constraining_process_variable_name = auto const& constraining_process_variable_name =
...@@ -320,9 +321,8 @@ createConstraintDirichletBoundaryCondition( ...@@ -320,9 +321,8 @@ createConstraintDirichletBoundaryCondition(
lower, lower,
[&constraining_process](std::size_t const element_id, [&constraining_process](std::size_t const element_id,
MathLib::Point3d const& pnt, double const t, MathLib::Point3d const& pnt, double const t,
std::vector<GlobalVector*> const& x) { std::vector<GlobalVector*> const& x)
return constraining_process.getFlux(element_id, pnt, t, x); { return constraining_process.getFlux(element_id, pnt, t, x); });
});
} }
} // namespace ProcessLib } // namespace ProcessLib
...@@ -11,12 +11,11 @@ ...@@ -11,12 +11,11 @@
#pragma once #pragma once
#include "BoundaryCondition.h" #include "BoundaryCondition.h"
#include "ConstraintDirichletBoundaryConditionLocalAssembler.h"
#include "NumLib/DOF/LocalToGlobalIndexMap.h" #include "NumLib/DOF/LocalToGlobalIndexMap.h"
#include "NumLib/IndexValueVector.h" #include "NumLib/IndexValueVector.h"
#include "ParameterLib/Parameter.h" #include "ParameterLib/Parameter.h"
#include "ConstraintDirichletBoundaryConditionLocalAssembler.h"
namespace ProcessLib namespace ProcessLib
{ {
/// The ConstraintDirichletBoundaryCondition class describes a Dirichlet-type /// The ConstraintDirichletBoundaryCondition class describes a Dirichlet-type
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
namespace ProcessLib namespace ProcessLib
{ {
struct IntegrationPointData final struct IntegrationPointData final
{ {
IntegrationPointData(double const& detJ, IntegrationPointData(double const& detJ,
...@@ -72,9 +71,8 @@ public: ...@@ -72,9 +71,8 @@ public:
/// @param bulk_ids Pairs of bulk element ids and bulk element face ids. /// @param bulk_ids Pairs of bulk element ids and bulk element face ids.
ConstraintDirichletBoundaryConditionLocalAssembler( ConstraintDirichletBoundaryConditionLocalAssembler(
MeshLib::Element const& surface_element, MeshLib::Element const& surface_element,
std::size_t /* local_matrix_size */, std::size_t /* local_matrix_size */, bool const is_axially_symmetric,
bool const is_axially_symmetric, unsigned const integration_order, unsigned const integration_order, MeshLib::Mesh const& bulk_mesh,
MeshLib::Mesh const& bulk_mesh,
std::vector<std::pair<std::size_t, unsigned>> bulk_ids) std::vector<std::pair<std::size_t, unsigned>> bulk_ids)
: _surface_element(surface_element), : _surface_element(surface_element),
_integration_method(integration_order), _integration_method(integration_order),
......
...@@ -43,4 +43,4 @@ std::unique_ptr<SourceTerm> createNodalSourceTerm( ...@@ -43,4 +43,4 @@ std::unique_ptr<SourceTerm> createNodalSourceTerm(
std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const&
parameters); parameters);
} // namespace ProcessLib } // namespace ProcessLib
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
#pragma once #pragma once
#include <vector>
#include <memory> #include <memory>
#include <vector>
#include "ParameterLib/Parameter.h" #include "ParameterLib/Parameter.h"
......
...@@ -44,4 +44,4 @@ std::unique_ptr<SourceTerm> createVolumetricSourceTerm( ...@@ -44,4 +44,4 @@ std::unique_ptr<SourceTerm> createVolumetricSourceTerm(
std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters, std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
unsigned const integration_order, unsigned const shapefunction_order); unsigned const integration_order, unsigned const shapefunction_order);
} // namespace ProcessLib } // namespace ProcessLib
...@@ -60,16 +60,18 @@ void DeactivatedSubdomainDirichlet::getEssentialBCValues( ...@@ -60,16 +60,18 @@ void DeactivatedSubdomainDirichlet::getEssentialBCValues(
.template getPropertyVector<std::size_t>( .template getPropertyVector<std::size_t>(
"bulk_element_ids", MeshLib::MeshItemType::Cell, 1); "bulk_element_ids", MeshLib::MeshItemType::Cell, 1);
auto is_inactive = [&](MeshLib::Element const* const e) { auto is_inactive = [&](MeshLib::Element const* const e)
return none_of( {
begin(*_active_element_ids), end(*_active_element_ids), return none_of(begin(*_active_element_ids), end(*_active_element_ids),
[&](auto const id) { return id == bulk_element_ids[e->getID()]; }); [&](auto const id)
{ return id == bulk_element_ids[e->getID()]; });
}; };
std::vector<MeshLib::Node*> inactive_nodes_in_bc_mesh; std::vector<MeshLib::Node*> inactive_nodes_in_bc_mesh;
std::copy_if(begin(_subdomain.inner_nodes), end(_subdomain.inner_nodes), std::copy_if(begin(_subdomain.inner_nodes), end(_subdomain.inner_nodes),
back_inserter(inactive_nodes_in_bc_mesh), back_inserter(inactive_nodes_in_bc_mesh),
[&](MeshLib::Node* const n) { [&](MeshLib::Node* const n)
{
const auto& connected_elements = n->getElements(); const auto& connected_elements = n->getElements();
return std::all_of(begin(connected_elements), return std::all_of(begin(connected_elements),
...@@ -80,7 +82,8 @@ void DeactivatedSubdomainDirichlet::getEssentialBCValues( ...@@ -80,7 +82,8 @@ void DeactivatedSubdomainDirichlet::getEssentialBCValues(
{ {
std::copy_if(begin(_subdomain.outer_nodes), end(_subdomain.outer_nodes), std::copy_if(begin(_subdomain.outer_nodes), end(_subdomain.outer_nodes),
back_inserter(inactive_nodes_in_bc_mesh), back_inserter(inactive_nodes_in_bc_mesh),
[&](MeshLib::Node* const n) { [&](MeshLib::Node* const n)
{
const auto& connected_elements = n->getElements(); const auto& connected_elements = n->getElements();
return std::all_of(begin(connected_elements), return std::all_of(begin(connected_elements),
...@@ -89,7 +92,8 @@ void DeactivatedSubdomainDirichlet::getEssentialBCValues( ...@@ -89,7 +92,8 @@ void DeactivatedSubdomainDirichlet::getEssentialBCValues(
}); });
} }
auto time_interval_contains = [&](double const t) { auto time_interval_contains = [&](double const t)
{
return _time_interval.getSupportMin() <= t && return _time_interval.getSupportMin() <= t &&
t <= _time_interval.getSupportMax(); t <= _time_interval.getSupportMax();
}; };
......
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