From 8eeefed0c0ded5231af676c7e10cad0eeae2fa07 Mon Sep 17 00:00:00 2001
From: Thomas Fischer <thomas.fischer@ufz.de>
Date: Tue, 10 Nov 2020 12:03:17 +0100
Subject: [PATCH] [PL/ST] Delete LineSourceTerm impl.

The VolumetricSourceTerm is equal to the
LineSourceTerm. Consequently, it is possible to
use VolumetricSourceTerm and remove LineSourceTerm.
---
 .../SourceTerms/CreateLineSourceTerm.cpp      |  48 -------
 ProcessLib/SourceTerms/CreateLineSourceTerm.h |  47 -------
 ProcessLib/SourceTerms/CreateSourceTerm.cpp   |  16 +--
 .../CreateVolumetricSourceTerm.cpp            |  21 ++-
 .../SourceTerms/CreateVolumetricSourceTerm.h  |   3 +-
 ProcessLib/SourceTerms/LineSourceTerm.cpp     |  43 -------
 ProcessLib/SourceTerms/LineSourceTerm.h       |  40 ------
 ProcessLib/SourceTerms/LineSourceTermFEM.h    | 120 ------------------
 8 files changed, 19 insertions(+), 319 deletions(-)
 delete mode 100644 ProcessLib/SourceTerms/CreateLineSourceTerm.cpp
 delete mode 100644 ProcessLib/SourceTerms/CreateLineSourceTerm.h
 delete mode 100644 ProcessLib/SourceTerms/LineSourceTerm.cpp
 delete mode 100644 ProcessLib/SourceTerms/LineSourceTerm.h
 delete mode 100644 ProcessLib/SourceTerms/LineSourceTermFEM.h

diff --git a/ProcessLib/SourceTerms/CreateLineSourceTerm.cpp b/ProcessLib/SourceTerms/CreateLineSourceTerm.cpp
deleted file mode 100644
index b452997f26b..00000000000
--- a/ProcessLib/SourceTerms/CreateLineSourceTerm.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * \file
- * \copyright
- * Copyright (c) 2012-2020, 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 "CreateLineSourceTerm.h"
-
-#include "BaseLib/ConfigTree.h"
-#include "BaseLib/FileTools.h"
-#include "MeshLib/Mesh.h"
-#include "NumLib/DOF/LocalToGlobalIndexMap.h"
-#include "ParameterLib/Utils.h"
-#include "LineSourceTerm.h"
-
-namespace ProcessLib
-{
-std::unique_ptr<SourceTerm> createLineSourceTerm(
-    BaseLib::ConfigTree const& config, unsigned const bulk_mesh_dimension,
-    MeshLib::Mesh const& source_term_mesh,
-    std::unique_ptr<NumLib::LocalToGlobalIndexMap> source_term_dof_table,
-    std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
-    unsigned const integration_order, unsigned const shapefunction_order)
-{
-    //! \ogs_file_param{prj__process_variables__process_variable__source_terms__source_term__type}
-    config.checkConfigParameter("type", "Line");
-
-    DBUG("Constructing LineSourceTerm from config.");
-
-    // source term field name
-    auto const& line_source_term_parameter_name =
-        //! \ogs_file_param{prj__process_variables__process_variable__source_terms__source_term__Line__parameter}
-        config.getConfigParameter<std::string>("parameter");
-    auto& line_source_term = ParameterLib::findParameter<double>(
-        line_source_term_parameter_name, parameters, 1, &source_term_mesh);
-
-    DBUG("Using '{:s}' as line source term parameter.", line_source_term.name);
-
-    return std::make_unique<LineSourceTerm>(
-        bulk_mesh_dimension, source_term_mesh, std::move(source_term_dof_table),
-        integration_order, shapefunction_order, line_source_term);
-}
-
-}  // namespace ProcessLib
diff --git a/ProcessLib/SourceTerms/CreateLineSourceTerm.h b/ProcessLib/SourceTerms/CreateLineSourceTerm.h
deleted file mode 100644
index a8b02298bf9..00000000000
--- a/ProcessLib/SourceTerms/CreateLineSourceTerm.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * \file
- * \copyright
- * Copyright (c) 2012-2020, OpenGeoSys Community (http://www.opengeosys.org)
- *            Distributed under a Modified BSD License.
- *              See accompanying file LICENSE.txt or
- *              http://www.opengeosys.org/project/license
- *
- */
-
-#pragma once
-
-#include <memory>
-#include <vector>
-
-namespace BaseLib
-{
-class ConfigTree;
-}
-
-namespace MeshLib
-{
-class Mesh;
-}
-
-namespace NumLib
-{
-class LocalToGlobalIndexMap;
-}
-
-namespace ParameterLib
-{
-struct ParameterBase;
-}
-
-namespace ProcessLib
-{
-class SourceTerm;
-
-std::unique_ptr<SourceTerm> createLineSourceTerm(
-    BaseLib::ConfigTree const& config, unsigned const bulk_mesh_dimension,
-    MeshLib::Mesh const& source_term_mesh,
-    std::unique_ptr<NumLib::LocalToGlobalIndexMap> source_term_dof_table,
-    std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
-    unsigned const integration_order, unsigned const shapefunction_order);
-
-}   // namespace ProcessLib
diff --git a/ProcessLib/SourceTerms/CreateSourceTerm.cpp b/ProcessLib/SourceTerms/CreateSourceTerm.cpp
index 4337e30c8a0..3bb1550e822 100644
--- a/ProcessLib/SourceTerms/CreateSourceTerm.cpp
+++ b/ProcessLib/SourceTerms/CreateSourceTerm.cpp
@@ -10,7 +10,6 @@
 
 #include "CreateSourceTerm.h"
 
-#include "CreateLineSourceTerm.h"
 #include "CreateNodalSourceTerm.h"
 #include "CreateVolumetricSourceTerm.h"
 #ifdef OGS_USE_PYTHON
@@ -78,7 +77,7 @@ std::unique_ptr<SourceTerm> createSourceTerm(
             parameters);
     }
 
-    if (type == "Line")
+    if (type == "Line" || type == "Volumetric")
     {
         std::unique_ptr<NumLib::LocalToGlobalIndexMap> dof_table_source_term(
             dof_table_bulk.deriveBoundaryConstrainedMap(
@@ -88,23 +87,12 @@ std::unique_ptr<SourceTerm> createSourceTerm(
             dof_table_bulk.getMeshSubset(variable_id, *config.component_id)
                 .getMesh()
                 .getDimension();
-        return ProcessLib::createLineSourceTerm(
+        return ProcessLib::createVolumetricSourceTerm(
             config.config, bulk_mesh_dimension, config.mesh,
             std::move(dof_table_source_term), parameters, integration_order,
             shapefunction_order);
     }
 
-    if (type == "Volumetric")
-    {
-        std::unique_ptr<NumLib::LocalToGlobalIndexMap> dof_table_source_term(
-            dof_table_bulk.deriveBoundaryConstrainedMap(
-                variable_id, {*config.component_id},
-                std::move(source_term_mesh_subset)));
-        return ProcessLib::createVolumetricSourceTerm(
-            config.config, config.mesh, std::move(dof_table_source_term),
-            parameters, integration_order, shapefunction_order);
-    }
-
     if (type == "Python")
     {
 #ifdef OGS_USE_PYTHON
diff --git a/ProcessLib/SourceTerms/CreateVolumetricSourceTerm.cpp b/ProcessLib/SourceTerms/CreateVolumetricSourceTerm.cpp
index a296515f8a3..0acf5a373fc 100644
--- a/ProcessLib/SourceTerms/CreateVolumetricSourceTerm.cpp
+++ b/ProcessLib/SourceTerms/CreateVolumetricSourceTerm.cpp
@@ -20,15 +20,24 @@
 namespace ProcessLib
 {
 std::unique_ptr<SourceTerm> createVolumetricSourceTerm(
-    BaseLib::ConfigTree const& config, MeshLib::Mesh const& source_term_mesh,
+    BaseLib::ConfigTree const& config, unsigned const bulk_mesh_dimension,
+    MeshLib::Mesh const& source_term_mesh,
     std::unique_ptr<NumLib::LocalToGlobalIndexMap> source_term_dof_table,
     std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
     unsigned const integration_order, unsigned const shapefunction_order)
 {
     //! \ogs_file_param{prj__process_variables__process_variable__source_terms__source_term__type}
-    config.checkConfigParameter("type", "Volumetric");
-
-    DBUG("Constructing VolumetricSourceTerm from config.");
+    auto const type = config.peekConfigParameter<std::string>("type");
+    if (type == "Line")
+    {
+        config.checkConfigParameter("type", "Line");
+        DBUG("Constructing LineSourceTerm from config.");
+    }
+    else
+    {
+        config.checkConfigParameter("type", "Volumetric");
+        DBUG("Constructing VolumetricSourceTerm from config.");
+    }
 
     // source term field name
     auto const& volumetric_source_term_parameter_name =
@@ -42,8 +51,8 @@ std::unique_ptr<SourceTerm> createVolumetricSourceTerm(
          volumetric_source_term.name);
 
     return std::make_unique<VolumetricSourceTerm>(
-        source_term_mesh, std::move(source_term_dof_table), integration_order,
-        shapefunction_order, volumetric_source_term);
+        bulk_mesh_dimension, source_term_mesh, std::move(source_term_dof_table),
+        integration_order, shapefunction_order, volumetric_source_term);
 }
 
 }  // namespace ProcessLib
diff --git a/ProcessLib/SourceTerms/CreateVolumetricSourceTerm.h b/ProcessLib/SourceTerms/CreateVolumetricSourceTerm.h
index ee0d9588c9a..7ba75f90e15 100644
--- a/ProcessLib/SourceTerms/CreateVolumetricSourceTerm.h
+++ b/ProcessLib/SourceTerms/CreateVolumetricSourceTerm.h
@@ -38,7 +38,8 @@ namespace ProcessLib
 class SourceTerm;
 
 std::unique_ptr<SourceTerm> createVolumetricSourceTerm(
-    BaseLib::ConfigTree const& config, MeshLib::Mesh const& source_term_mesh,
+    BaseLib::ConfigTree const& config, unsigned const bulk_mesh_dimension,
+    MeshLib::Mesh const& source_term_mesh,
     std::unique_ptr<NumLib::LocalToGlobalIndexMap> source_term_dof_table,
     std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
     unsigned const integration_order, unsigned const shapefunction_order);
diff --git a/ProcessLib/SourceTerms/LineSourceTerm.cpp b/ProcessLib/SourceTerms/LineSourceTerm.cpp
deleted file mode 100644
index 432cc67aab0..00000000000
--- a/ProcessLib/SourceTerms/LineSourceTerm.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * \file
- * \copyright
- * Copyright (c) 2012-2020, 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 "LineSourceTerm.h"
-
-#include "ProcessLib/Utils/CreateLocalAssemblers.h"
-
-namespace ProcessLib
-{
-LineSourceTerm::LineSourceTerm(
-    unsigned const bulk_mesh_dimension, MeshLib::Mesh const& source_term_mesh,
-    std::unique_ptr<NumLib::LocalToGlobalIndexMap> source_term_dof_table,
-    unsigned const integration_order, unsigned const shapefunction_order,
-    ParameterLib::Parameter<double> const& source_term_parameter)
-    : SourceTerm(std::move(source_term_dof_table)),
-      _source_term_parameter(source_term_parameter)
-{
-    ProcessLib::createLocalAssemblers<LineSourceTermLocalAssembler>(
-        bulk_mesh_dimension, source_term_mesh.getElements(),
-        *_source_term_dof_table, shapefunction_order, _local_assemblers,
-        source_term_mesh.isAxiallySymmetric(), integration_order,
-        _source_term_parameter);
-}
-
-void LineSourceTerm::integrate(const double t, GlobalVector const& /*x*/,
-                               GlobalVector& b, GlobalMatrix* /*jac*/) const
-{
-    DBUG("Assemble LineSourceTerm.");
-
-    // Call global assembler for each local assembly item.
-    GlobalExecutor::executeMemberOnDereferenced(
-        &LineSourceTermLocalAssemblerInterface::integrate, _local_assemblers,
-        *_source_term_dof_table, t, b);
-}
-
-}  // namespace ProcessLib
diff --git a/ProcessLib/SourceTerms/LineSourceTerm.h b/ProcessLib/SourceTerms/LineSourceTerm.h
deleted file mode 100644
index 7623504fcf4..00000000000
--- a/ProcessLib/SourceTerms/LineSourceTerm.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * \file
- * \copyright
- * Copyright (c) 2012-2020, OpenGeoSys Community (http://www.opengeosys.org)
- *            Distributed under a Modified BSD License.
- *              See accompanying file LICENSE.txt or
- *              http://www.opengeosys.org/project/license
- *
- */
-
-#pragma once
-
-#include <memory>
-#include <vector>
-
-#include "SourceTerm.h"
-#include "LineSourceTermFEM.h"
-
-namespace ProcessLib
-{
-class LineSourceTerm final : public SourceTerm
-{
-public:
-    LineSourceTerm(
-        unsigned const bulk_mesh_dimension,
-        MeshLib::Mesh const& source_term_mesh,
-        std::unique_ptr<NumLib::LocalToGlobalIndexMap> source_term_dof_table,
-        unsigned const integration_order, unsigned const shapefunction_order,
-        ParameterLib::Parameter<double> const& source_term_parameter);
-
-    void integrate(const double t, GlobalVector const& x, GlobalVector& b,
-                   GlobalMatrix* jac) const override;
-
-private:
-    ParameterLib::Parameter<double> const& _source_term_parameter;
-    std::vector<std::unique_ptr<LineSourceTermLocalAssemblerInterface>>
-        _local_assemblers;
-};
-
-}  // namespace ProcessLib
diff --git a/ProcessLib/SourceTerms/LineSourceTermFEM.h b/ProcessLib/SourceTerms/LineSourceTermFEM.h
deleted file mode 100644
index 24fedf88403..00000000000
--- a/ProcessLib/SourceTerms/LineSourceTermFEM.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/**
- * \file
- * \copyright
- * Copyright (c) 2012-2020, OpenGeoSys Community (http://www.opengeosys.org)
- *            Distributed under a Modified BSD License.
- *              See accompanying file LICENSE.txt or
- *              http://www.opengeosys.org/project/license
- *
- */
-
-#pragma once
-
-#include <vector>
-
-#include "MathLib/LinAlg/Eigen/EigenMapTools.h"
-#include "NumLib/DOF/DOFTableUtil.h"
-#include "NumLib/Fem/FiniteElement/TemplateIsoparametric.h"
-#include "NumLib/Fem/InitShapeMatrices.h"
-#include "ParameterLib/Parameter.h"
-#include "ProcessLib/LocalAssemblerTraits.h"
-#include "SourceTermIntegrationPointData.h"
-
-namespace ProcessLib
-{
-class LineSourceTermLocalAssemblerInterface
-{
-public:
-    virtual void integrate(
-        std::size_t const id,
-        NumLib::LocalToGlobalIndexMap const& source_term_dof_table,
-        double const t, GlobalVector& b) = 0;
-    virtual ~LineSourceTermLocalAssemblerInterface() = default;
-};
-
-template <typename ShapeFunction, typename IntegrationMethod,
-          unsigned GlobalDim>
-class LineSourceTermLocalAssembler final
-    : public LineSourceTermLocalAssemblerInterface
-{
-    static const unsigned NUM_NODAL_DOF = 1;
-
-    using ShapeMatricesType = ShapeMatrixPolicyType<ShapeFunction, GlobalDim>;
-
-    using LocalAssemblerTraits = ProcessLib::LocalAssemblerTraits<
-        ShapeMatricesType, ShapeFunction::NPOINTS, NUM_NODAL_DOF, GlobalDim>;
-
-    using NodalVectorType = typename LocalAssemblerTraits::LocalVector;
-    using NodalRowVectorType = typename ShapeMatricesType::NodalRowVectorType;
-
-public:
-    LineSourceTermLocalAssembler(
-        MeshLib::Element const& element,
-        std::size_t const local_matrix_size,
-        bool const is_axially_symmetric,
-        unsigned const integration_order,
-        ParameterLib::Parameter<double> const& line_source_term_parameter)
-        : _parameter(line_source_term_parameter),
-          _integration_method(integration_order),
-          _element(element),
-          _local_rhs(local_matrix_size)
-    {
-        unsigned const n_integration_points =
-            _integration_method.getNumberOfPoints();
-
-        auto const shape_matrices =
-            NumLib::initShapeMatrices<ShapeFunction, ShapeMatricesType,
-                                      GlobalDim>(_element, is_axially_symmetric,
-                                                 _integration_method);
-
-        for (unsigned ip = 0; ip < n_integration_points; ip++)
-        {
-            _ip_data.emplace_back(
-                shape_matrices[ip].N,
-                _integration_method.getWeightedPoint(ip).getWeight() *
-                    shape_matrices[ip].integralMeasure *
-                    shape_matrices[ip].detJ);
-        }
-    }
-
-    void integrate(std::size_t const id,
-                   NumLib::LocalToGlobalIndexMap const& source_term_dof_table,
-                   double const t, GlobalVector& b) override
-    {
-        _local_rhs.setZero();
-
-        unsigned const n_integration_points =
-            _integration_method.getNumberOfPoints();
-
-        for (unsigned ip = 0; ip < n_integration_points; ip++)
-        {
-            auto const& N = _ip_data[ip].N;
-            auto const& w = _ip_data[ip].integration_weight;
-
-            ParameterLib::SpatialPosition const pos{
-                boost::none, _element.getID(), ip,
-                MathLib::Point3d(
-                    NumLib::interpolateCoordinates<ShapeFunction,
-                                                   ShapeMatricesType>(_element,
-                                                                      N))};
-            auto const st_val = _parameter(t, pos)[0];
-
-            _local_rhs.noalias() += st_val * w * N;
-        }
-        auto const indices = NumLib::getIndices(id, source_term_dof_table);
-        b.add(indices, _local_rhs);
-    }
-
-private:
-    ParameterLib::Parameter<double> const& _parameter;
-
-    IntegrationMethod const _integration_method;
-    std::vector<SourceTermIntegrationPointData<NodalRowVectorType>,
-                Eigen::aligned_allocator<
-                    SourceTermIntegrationPointData<NodalRowVectorType>>>
-        _ip_data;
-    MeshLib::Element const& _element;
-    NodalVectorType _local_rhs;
-};
-
-}  // namespace ProcessLib
-- 
GitLab