From 01134790420b49b821771672cc21785a1e92bfac Mon Sep 17 00:00:00 2001
From: Christoph Lehmann <christoph.lehmann@ufz.de>
Date: Wed, 3 Aug 2016 15:47:46 +0200
Subject: [PATCH] [PL] removed old BC classes

---
 ProcessLib/DirichletBc.h                      |  27 ----
 ProcessLib/NeumannBc.cpp                      |  88 --------------
 ProcessLib/NeumannBc.h                        |  84 -------------
 ProcessLib/NeumannBcAssembler.h               | 110 -----------------
 ProcessLib/NeumannBcConfig.h                  | 115 ------------------
 .../UniformDirichletBoundaryCondition.cpp     |  80 ------------
 .../UniformDirichletBoundaryCondition.h       |  58 ---------
 7 files changed, 562 deletions(-)
 delete mode 100644 ProcessLib/DirichletBc.h
 delete mode 100644 ProcessLib/NeumannBc.cpp
 delete mode 100644 ProcessLib/NeumannBc.h
 delete mode 100644 ProcessLib/NeumannBcAssembler.h
 delete mode 100644 ProcessLib/NeumannBcConfig.h
 delete mode 100644 ProcessLib/UniformDirichletBoundaryCondition.cpp
 delete mode 100644 ProcessLib/UniformDirichletBoundaryCondition.h

diff --git a/ProcessLib/DirichletBc.h b/ProcessLib/DirichletBc.h
deleted file mode 100644
index 924fb1a2d2e..00000000000
--- a/ProcessLib/DirichletBc.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * \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
- *
- */
-
-#ifndef PROCESS_LIB_DIRICHLETBC_H
-#define PROCESS_LIB_DIRICHLETBC_H
-
-#include <vector>
-
-#include "NumLib/IndexValueVector.h"
-
-namespace ProcessLib
-{
-
-/// A dirichlet boundary condition is represented by a list of global indices
-/// with corresponding values.
-template <typename IndexType>
-using DirichletBc = NumLib::IndexValueVector<IndexType>;
-
-}  // namespace ProcessLib
-
-#endif  // PROCESS_LIB_DIRICHLETBC_H
diff --git a/ProcessLib/NeumannBc.cpp b/ProcessLib/NeumannBc.cpp
deleted file mode 100644
index da0b3e24d33..00000000000
--- a/ProcessLib/NeumannBc.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * \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
- *
- */
-
-#include "NeumannBc.h"
-
-#include "NumLib/Fem/FiniteElement/TemplateIsoparametric.h"
-#include "NumLib/Fem/ShapeMatrixPolicy.h"
-
-#include "MeshLib/MeshSearch/NodeSearch.h"
-
-#include "Utils/CreateLocalAssemblers.h"
-
-namespace ProcessLib
-{
-
-NeumannBc::NeumannBc(
-    NeumannBcConfig const& bc,
-    unsigned const integration_order,
-    NumLib::LocalToGlobalIndexMap const& local_to_global_index_map,
-    int const variable_id,
-    int const component_id)
-    : _function(*bc.getFunction()),
-      _integration_order(integration_order)
-{
-    assert(component_id < static_cast<int>(local_to_global_index_map.getNumberOfComponents()));
-
-    // deep copy because the neumann bc config destroys the elements.
-    std::transform(bc.elementsBegin(), bc.elementsEnd(),
-            std::back_inserter(_elements),
-            std::mem_fn(&MeshLib::Element::clone));
-
-    std::vector<MeshLib::Node*> nodes = MeshLib::getUniqueNodes(_elements);
-
-    auto const& mesh_subsets =
-        local_to_global_index_map.getMeshSubsets(variable_id, component_id);
-
-    // TODO extend the node intersection to all parts of mesh_subsets, i.e.
-    // to each of the MeshSubset in the mesh_subsets.
-    _mesh_subset_all_nodes =
-        mesh_subsets.getMeshSubset(0).getIntersectionByNodes(nodes);
-    std::unique_ptr<MeshLib::MeshSubsets> all_mesh_subsets{
-        new MeshLib::MeshSubsets{_mesh_subset_all_nodes}};
-
-    // Create local DOF table from intersected mesh subsets for the given
-    // variable and component ids.
-    _local_to_global_index_map.reset(
-        local_to_global_index_map.deriveBoundaryConstrainedMap(
-            variable_id, component_id, std::move(all_mesh_subsets),
-            _elements));
-}
-
-NeumannBc::~NeumannBc()
-{
-    delete _mesh_subset_all_nodes;
-
-    for (auto e : _elements)
-        delete e;
-}
-
-void NeumannBc::integrate(const double t, GlobalVector& b)
-{
-    GlobalExecutor::executeMemberOnDereferenced(
-        &LocalNeumannBcAsmDataInterface::assemble, _local_assemblers,
-        *_local_to_global_index_map, t, b);
-}
-
-void NeumannBc::initialize(unsigned global_dim)
-{
-    auto elementValueLookup = [this](MeshLib::Element const&)
-    {
-        return _function();
-    };
-
-    createLocalAssemblers<LocalNeumannBcAsmData>(
-        global_dim, _elements,
-        *_local_to_global_index_map, _integration_order,
-        _local_assemblers,
-        elementValueLookup
-        );
-}
-
-}   // namespace ProcessLib
diff --git a/ProcessLib/NeumannBc.h b/ProcessLib/NeumannBc.h
deleted file mode 100644
index 76dda085128..00000000000
--- a/ProcessLib/NeumannBc.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * \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
- *
- */
-
-#ifndef PROCESS_LIB_NEUMANN_BC_H_
-#define PROCESS_LIB_NEUMANN_BC_H_
-
-#include <memory>
-#include <vector>
-
-#include "MeshLib/MeshSubset.h"
-#include "NumLib/NumericsConfig.h"
-#include "NeumannBcConfig.h"
-#include "NeumannBcAssembler.h"
-
-namespace ProcessLib
-{
-
-/// The NeumannBc class is a process which is integrating a single, Neumann type
-/// boundary condition in to the global matrix and the right-hand-side.
-///
-/// The process operates on a set of elements and a subset of the DOF-table (the
-/// local to global index map). For each element a local assembler is created
-/// (NeumannBcAssembler).
-///
-/// In the construction phase the NeumannBcConfig together with global DOF-table
-/// and mesh subset are used.
-/// The creation of the local assemblers and binding to the global matrix and
-/// right-hand-sides happen in the initialize() function.
-/// The integration() function provides calls then the actual integration of the
-/// Neumann boundary condition.
-class NeumannBc
-{
-public:
-    /// Create a Neumann boundary condition process from given config,
-    /// DOF-table, and a mesh subset for a given variable and its component.
-    /// A local DOF-table, a subset of the given one, is constructed.
-    NeumannBc(
-        NeumannBcConfig const& bc,
-        unsigned const integration_order,
-        NumLib::LocalToGlobalIndexMap const& local_to_global_index_map,
-        int const variable_id,
-        int const component_id);
-
-    ~NeumannBc();
-
-    /// Calls local assemblers which calculate their contributions to the global
-    /// matrix and the right-hand-side.
-    void integrate(const double t, GlobalVector& b);
-
-    void initialize(unsigned global_dim);
-
-private:
-    /// The right-hand-side function of the Neumann boundary condition given as
-    /// \f$ \alpha(x) \, \partial u(x) / \partial n = \text{_function}(x)\f$.
-    MathLib::ConstantFunction<double> const _function;
-
-    /// Vector of lower-dimensional elements on which the boundary condition is
-    /// defined.
-    std::vector<MeshLib::Element*> _elements;
-
-    MeshLib::MeshSubset const* _mesh_subset_all_nodes = nullptr;
-
-    /// Local dof table, a subset of the global one restricted to the
-    /// participating #_elements of the boundary condition.
-    std::unique_ptr<NumLib::LocalToGlobalIndexMap> _local_to_global_index_map;
-
-    /// Integration order for integration over the lower-dimensional elements of
-    /// the #_function.
-    unsigned const _integration_order;
-
-    /// Local assemblers for each element of #_elements.
-    std::vector<std::unique_ptr<LocalNeumannBcAsmDataInterface>> _local_assemblers;
-
-};
-
-}   // namespace ProcessLib
-
-#endif  // PROCESS_LIB_NEUMANN_BC_H_
diff --git a/ProcessLib/NeumannBcAssembler.h b/ProcessLib/NeumannBcAssembler.h
deleted file mode 100644
index f731702f24f..00000000000
--- a/ProcessLib/NeumannBcAssembler.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/**
- * \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
- *
- */
-
-#ifndef PROCESS_LIB_NEUMANN_BC_ASSEMBLER_H_
-#define PROCESS_LIB_NEUMANN_BC_ASSEMBLER_H_
-
-#include <memory>
-#include <vector>
-
-#include "NumLib/DOF/DOFTableUtil.h"
-#include "NumLib/Fem/FiniteElement/TemplateIsoparametric.h"
-#include "NumLib/Fem/ShapeMatrixPolicy.h"
-
-namespace ProcessLib
-{
-
-class LocalNeumannBcAsmDataInterface
-{
-public:
-    virtual ~LocalNeumannBcAsmDataInterface() = default;
-
-    virtual void assemble(std::size_t const id,
-                          NumLib::LocalToGlobalIndexMap const& dof_table,
-                          double const t, GlobalVector& b) = 0;
-};
-
-template <typename ShapeFunction_,
-         typename IntegrationMethod_,
-         unsigned GlobalDim>
-class LocalNeumannBcAsmData : public LocalNeumannBcAsmDataInterface
-{
-public:
-    using ShapeFunction = ShapeFunction_;
-    using NodalMatrixType = typename ShapeMatrixPolicyType<ShapeFunction,GlobalDim>::NodalMatrixType;
-    using NodalVectorType = typename ShapeMatrixPolicyType<ShapeFunction,GlobalDim>::NodalVectorType;
-
-    using ShapeMatricesType = ShapeMatrixPolicyType<ShapeFunction,GlobalDim>;
-    using ShapeMatrices = typename ShapeMatricesType::ShapeMatrices;
-
-    /// The neumann_bc_value factor is directly integrated into the local
-    /// element matrix.
-    LocalNeumannBcAsmData(
-            MeshLib::Element const& e,
-            std::size_t const local_matrix_size,
-            unsigned const integration_order,
-            std::function<double (MeshLib::Element const&)> const& value_lookup)
-    {
-        using FemType = NumLib::TemplateIsoparametric<
-            ShapeFunction, ShapeMatricesType>;
-
-        FemType fe(*static_cast<const typename ShapeFunction::MeshElement*>(&e));
-
-        _integration_order = integration_order;
-        IntegrationMethod_ integration_method(_integration_order);
-        std::size_t const n_integration_points = integration_method.getNumberOfPoints();
-
-        _shape_matrices.reserve(n_integration_points);
-        for (std::size_t ip(0); ip < n_integration_points; ip++) {
-            _shape_matrices.emplace_back(ShapeFunction::DIM, GlobalDim,
-                                         ShapeFunction::NPOINTS);
-            fe.computeShapeFunctions(
-                    integration_method.getWeightedPoint(ip).getCoords(),
-                    _shape_matrices[ip], GlobalDim);
-        }
-
-        _neumann_bc_value = value_lookup(e);
-
-        _localRhs.reset(new NodalVectorType(local_matrix_size));
-    }
-
-    void assemble(std::size_t const id,
-                  NumLib::LocalToGlobalIndexMap const& dof_table,
-                  double const t, GlobalVector& b) override
-    {
-        (void) t; // TODO time-dependent Neumann BCs
-
-        _localRhs->setZero();
-
-        IntegrationMethod_ integration_method(_integration_order);
-        std::size_t const n_integration_points = integration_method.getNumberOfPoints();
-
-        for (std::size_t ip(0); ip < n_integration_points; ip++) {
-            auto const& sm = _shape_matrices[ip];
-            auto const& wp = integration_method.getWeightedPoint(ip);
-            _localRhs->noalias() += sm.N * _neumann_bc_value
-                        * sm.detJ * wp.getWeight();
-        }
-
-        auto const indices = NumLib::getIndices(id, dof_table);
-        b.add(indices, *_localRhs);
-    }
-
-private:
-    std::vector<ShapeMatrices> _shape_matrices;
-    double _neumann_bc_value;
-
-    std::unique_ptr<NodalVectorType> _localRhs;
-
-    unsigned _integration_order = 2;
-};
-
-}   // namespace ProcessLib
-
-#endif  // PROCESS_LIB_NEUMANN_BC_ASSEMBLER_H_
diff --git a/ProcessLib/NeumannBcConfig.h b/ProcessLib/NeumannBcConfig.h
deleted file mode 100644
index 8db8117c3a6..00000000000
--- a/ProcessLib/NeumannBcConfig.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/**
- * \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
- *
- */
-
-#ifndef PROCESS_LIB_NEUMANN_BC_CONFIG_H_
-#define PROCESS_LIB_NEUMANN_BC_CONFIG_H_
-
-#include <logog/include/logog.hpp>
-
-#include "BaseLib/ConfigTree.h"
-#include "MathLib/ConstantFunction.h"
-#include "MeshGeoToolsLib/BoundaryElementsSearcher.h"
-#include "MeshLib/Elements/Element.h"
-
-namespace GeoLib
-{
-    class GeoObject;
-}
-
-namespace ProcessLib
-{
-
-class BoundaryConditionConfig
-{
-public:
-    BoundaryConditionConfig(GeoLib::GeoObject const& geometry)
-        : _geometry(geometry)
-    { }
-
-    virtual ~BoundaryConditionConfig() = default;
-
-protected:
-    GeoLib::GeoObject const& _geometry;
-};
-
-
-/// Configuration of a Neumann type boundary condition read from input file.
-class NeumannBcConfig : public BoundaryConditionConfig
-{
-public:
-    NeumannBcConfig(GeoLib::GeoObject const& geometry,
-                    BaseLib::ConfigTree const& config)
-        : BoundaryConditionConfig(geometry)
-    {
-        DBUG("Constructing NeumannBcConfig from config.");
-        //! \ogs_file_param{boundary_condition__type}
-        config.checkConfigParameter("type", "UniformNeumann");
-
-        //! \ogs_file_param{boundary_condition__UniformNeumann__value}
-        double const value = config.getConfigParameter<double>("value");
-        DBUG("Using value %g", value);
-
-        _function = new MathLib::ConstantFunction<double>(value);
-    }
-
-    ~NeumannBcConfig()
-    {
-        for (auto e : _elements)
-            delete e;
-
-        delete _function;
-    }
-
-    /// Initialize Neumann type boundary conditions.
-    /// Fills in elements of the particular geometry of the boundary condition.
-    /// The elements are appended to the \c elements vector.
-    void initialize(MeshGeoToolsLib::BoundaryElementsSearcher& searcher)
-    {
-        std::vector<MeshLib::Element*> elems =
-            searcher.getBoundaryElements(_geometry);
-
-        // deep copy because the searcher destroys the elements.
-        std::transform(elems.cbegin(), elems.cend(),
-                std::back_inserter(_elements),
-                std::mem_fn(&MeshLib::Element::clone));
-    }
-
-    /// Iterator over elements of the boundary condition.
-    std::vector<MeshLib::Element*>::const_iterator
-    elementsBegin() const
-    {
-        return _elements.cbegin();
-    }
-
-    /// Past the end iterator over elements of the boundary condition.
-    /// \sa elementsBegin().
-    std::vector<MeshLib::Element*>::const_iterator
-    elementsEnd() const
-    {
-        return _elements.cend();
-    }
-
-    /// Returns the right-hand-side function of the boundary condition.
-    MathLib::ConstantFunction<double>*
-    getFunction() const
-    {
-        return _function;
-    }
-
-private:
-    /// Domain of the boundary condition.
-    std::vector<MeshLib::Element*> _elements;
-
-    /// A function given on the domain of the boundary condition.
-    MathLib::ConstantFunction<double>* _function = nullptr;
-};
-
-}   // namespace ProcessLib
-
-#endif  // PROCESS_LIB_NEUMANN_BC_CONFIG_H_
diff --git a/ProcessLib/UniformDirichletBoundaryCondition.cpp b/ProcessLib/UniformDirichletBoundaryCondition.cpp
deleted file mode 100644
index 686a7ce2491..00000000000
--- a/ProcessLib/UniformDirichletBoundaryCondition.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- * \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
- *
- */
-
-#include "UniformDirichletBoundaryCondition.h"
-
-#include <algorithm>
-#include <vector>
-
-#include <logog/include/logog.hpp>
-
-namespace ProcessLib
-{
-UniformDirichletBoundaryCondition::UniformDirichletBoundaryCondition(
-    GeoLib::GeoObject const& geometry, BaseLib::ConfigTree const& config)
-    : _geometry(geometry)
-{
-    DBUG("Constructing UniformDirichletBoundaryCondition from config.");
-    //! \ogs_file_param{boundary_condition__type}
-    config.checkConfigParameter("type", "UniformDirichlet");
-
-    //! \ogs_file_param{boundary_condition__UniformDirichlet__value}
-    _value = config.getConfigParameter<double>("value");
-    DBUG("Using value %g", _value);
-}
-
-UniformDirichletBoundaryCondition::UniformDirichletBoundaryCondition(
-    GeoLib::GeoObject const& geometry, double value)
-    : _value(value), _geometry(geometry)
-{
-    DBUG("Constructed UniformDirichletBoundaryCondition using value %g",
-         _value);
-}
-
-/// Initialize Dirichlet type boundary conditions.
-/// Fills in global_ids of the particular geometry of the boundary condition
-/// and the corresponding values.
-/// The ids and the constant values are then used to construct DirichletBc
-/// object.
-void UniformDirichletBoundaryCondition::initialize(
-    MeshGeoToolsLib::MeshNodeSearcher& searcher,
-    NumLib::LocalToGlobalIndexMap const& dof_table,
-    int const component_id,
-    int const variable_id,
-    DirichletBc<GlobalIndexType>& bc)
-{
-    // Find nodes' ids on the given mesh on which this boundary condition
-    // is defined.
-    std::vector<std::size_t> ids = searcher.getMeshNodeIDs(_geometry);
-
-    // convert mesh node ids to global index for the given component
-    bc.ids.reserve(bc.ids.size() + ids.size());
-    bc.values.reserve(bc.values.size() + ids.size());
-    for (auto& id : ids)
-    {
-        MeshLib::Location l(searcher.getMeshId(), MeshLib::MeshItemType::Node,
-                            id);
-        // TODO: that might be slow, but only done once
-        const auto g_idx =
-            dof_table.getGlobalIndex(l, variable_id, component_id);
-        // For the DDC approach (e.g. with PETSc option), the negative
-        // index of g_idx 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 (g_idx >= 0)
-        {
-            bc.ids.emplace_back(g_idx);
-            bc.values.emplace_back(_value);
-        }
-    }
-}
-
-}   // namespace ProcessLib
diff --git a/ProcessLib/UniformDirichletBoundaryCondition.h b/ProcessLib/UniformDirichletBoundaryCondition.h
deleted file mode 100644
index fa916628a20..00000000000
--- a/ProcessLib/UniformDirichletBoundaryCondition.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * \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
- *
- */
-
-#ifndef PROCESS_LIB_BOUNDARY_CONDITION_H_
-#define PROCESS_LIB_BOUNDARY_CONDITION_H_
-
-#include "BaseLib/ConfigTree.h"
-#include "MeshGeoToolsLib/MeshNodeSearcher.h"
-#include "NumLib/DOF/LocalToGlobalIndexMap.h"
-#include "NumLib/NumericsConfig.h" // for GlobalIndexType
-
-#include "DirichletBc.h"
-
-namespace GeoLib
-{
-class GeoObject;
-}
-
-namespace ProcessLib
-{
-/// The UniformDirichletBoundaryCondition class describes a constant in space
-/// and time Dirichlet boundary condition.
-/// The expected parameter in the passed configuration is "value" which, when
-/// not present defaults to zero.
-class UniformDirichletBoundaryCondition
-{
-public:
-    UniformDirichletBoundaryCondition(GeoLib::GeoObject const& geometry,
-                                      BaseLib::ConfigTree const& config);
-
-    UniformDirichletBoundaryCondition(GeoLib::GeoObject const& geometry,
-                                      double value);
-
-    /// Initialize Dirichlet type boundary conditions.
-    /// Fills in global_ids of the particular geometry of the boundary condition
-    /// and the corresponding values.
-    /// The ids and the constant values are then used to construct DirichletBc
-    /// object.
-    void initialize(MeshGeoToolsLib::MeshNodeSearcher& searcher,
-                    NumLib::LocalToGlobalIndexMap const& dof_table,
-                    int const variable_id,
-                    int const component_id,
-                    DirichletBc<GlobalIndexType>& bc);
-
-private:
-    double _value;
-    GeoLib::GeoObject const& _geometry;
-};
-
-}  // namespace ProcessLib
-
-#endif  // PROCESS_LIB_BOUNDARY_CONDITION_H_
-- 
GitLab