LCOV - code coverage report
Current view: top level - src/base - dirichlet_boundary.C (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4229 (6a9aeb) with base 727f46 Lines: 59 112 52.7 %
Date: 2025-08-19 19:27:09 Functions: 8 15 53.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // The libMesh Finite Element Library.
       2             : // Copyright (C) 2002-2025 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
       3             : 
       4             : // This library is free software; you can redistribute it and/or
       5             : // modify it under the terms of the GNU Lesser General Public
       6             : // License as published by the Free Software Foundation; either
       7             : // version 2.1 of the License, or (at your option) any later version.
       8             : 
       9             : // This library is distributed in the hope that it will be useful,
      10             : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      12             : // Lesser General Public License for more details.
      13             : 
      14             : // You should have received a copy of the GNU Lesser General Public
      15             : // License along with this library; if not, write to the Free Software
      16             : // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
      17             : 
      18             : 
      19             : 
      20             : #include "libmesh/dirichlet_boundaries.h"
      21             : 
      22             : #ifdef LIBMESH_ENABLE_DIRICHLET
      23             : 
      24             : // Local Includes
      25             : #include "libmesh/composite_fem_function.h"
      26             : #include "libmesh/composite_function.h"
      27             : #include "libmesh/vector_value.h"
      28             : 
      29             : // C++ Includes
      30             : #include <memory>
      31             : 
      32             : namespace libMesh
      33             : {
      34             : 
      35        5410 : DirichletBoundary::
      36             : DirichletBoundary(std::set<boundary_id_type> b_in,
      37             :                   std::vector<unsigned int> variables_in,
      38             :                   const FunctionBase<Number> * f_in,
      39        5410 :                   const FunctionBase<Gradient> * g_in) :
      40         154 :   b(std::move(b_in)),
      41         154 :   variables(std::move(variables_in)),
      42        5410 :   f(f_in ? f_in->clone() : nullptr),
      43        5102 :   g(g_in ? g_in->clone() : nullptr),
      44        5102 :   f_system(nullptr),
      45        5718 :   jacobian_tolerance(0.)
      46             : {
      47         154 :   libmesh_assert(f);
      48        5410 :   f->init();
      49        5410 :   if (g)
      50           0 :     g->init();
      51        5410 : }
      52             : 
      53             : 
      54        6016 : DirichletBoundary::
      55             : DirichletBoundary(std::set<boundary_id_type> b_in,
      56             :                   std::vector<unsigned int> variables_in,
      57             :                   const FunctionBase<Number> & f_in,
      58        6016 :                   VariableIndexing type) :
      59         170 :   b(std::move(b_in)),
      60        5846 :   variables(std::move(variables_in)),
      61        5676 :   f_system(nullptr),
      62        6016 :   jacobian_tolerance(0.)
      63             : {
      64        6016 :   if (type == LOCAL_VARIABLE_ORDER)
      65             :     {
      66        4215 :       auto c = std::make_unique<CompositeFunction<Number>>();
      67        4215 :       c->attach_subfunction(f_in, variables);
      68        3983 :       f = std::move(c);
      69        3867 :     }
      70             :   else
      71        3780 :     f = f_in.clone();
      72             : 
      73        6016 :   f->init();
      74        6016 : }
      75             : 
      76             : 
      77        1633 : DirichletBoundary::
      78             : DirichletBoundary(std::set<boundary_id_type> b_in,
      79             :                   std::vector<unsigned int> variables_in,
      80             :                   const FunctionBase<Number> & f_in,
      81             :                   const FunctionBase<Gradient> & g_in,
      82        1633 :                   VariableIndexing type) :
      83          46 :   b(std::move(b_in)),
      84        1587 :   variables(std::move(variables_in)),
      85        1541 :   f_system(nullptr),
      86        1633 :   jacobian_tolerance(0.)
      87             : {
      88        1633 :   if (type == LOCAL_VARIABLE_ORDER)
      89             :     {
      90           0 :       auto cf = std::make_unique<CompositeFunction<Number>>();
      91           0 :       cf->attach_subfunction(f_in, variables);
      92           0 :       f = std::move(cf);
      93             : 
      94           0 :       auto cg = std::make_unique<CompositeFunction<Gradient>>();
      95           0 :       cg->attach_subfunction(g_in, variables);
      96           0 :       g = std::move(cg);
      97           0 :     }
      98             :   else
      99             :     {
     100        3174 :       f = f_in.clone();
     101        3220 :       g = g_in.clone();
     102             :     }
     103             : 
     104        1633 :   f->init();
     105        1633 :   g->init();
     106        1633 : }
     107             : 
     108             : 
     109           0 : DirichletBoundary::
     110             : DirichletBoundary(std::set<boundary_id_type> b_in,
     111             :                   std::vector<unsigned int> variables_in,
     112             :                   const System & f_sys_in,
     113             :                   const FEMFunctionBase<Number> * f_in,
     114           0 :                   const FEMFunctionBase<Gradient> * g_in) :
     115           0 :   b(std::move(b_in)),
     116           0 :   variables(std::move(variables_in)),
     117           0 :   f_fem(f_in ? f_in->clone() : nullptr),
     118           0 :   g_fem(g_in ? g_in->clone() : nullptr),
     119           0 :   f_system(&f_sys_in),
     120           0 :   jacobian_tolerance(0.)
     121             : {
     122           0 :   libmesh_assert(f_fem);
     123           0 : }
     124             : 
     125             : 
     126           0 : DirichletBoundary::
     127             : DirichletBoundary(std::set<boundary_id_type> b_in,
     128             :                   std::vector<unsigned int> variables_in,
     129             :                   const System & f_sys_in,
     130             :                   const FEMFunctionBase<Number> & f_in,
     131           0 :                   VariableIndexing type) :
     132           0 :   b(std::move(b_in)),
     133           0 :   variables(std::move(variables_in)),
     134           0 :   f_system(&f_sys_in),
     135           0 :   jacobian_tolerance(0.)
     136             : {
     137           0 :   if (type == LOCAL_VARIABLE_ORDER)
     138             :     {
     139           0 :       auto c = std::make_unique<CompositeFEMFunction<Number>>();
     140           0 :       c->attach_subfunction(f_in, variables);
     141           0 :       f_fem = std::move(c);
     142           0 :     }
     143             :   else
     144           0 :     f_fem = f_in.clone();
     145           0 : }
     146             : 
     147             : 
     148           0 : DirichletBoundary::
     149             : DirichletBoundary(std::set<boundary_id_type> b_in,
     150             :                   std::vector<unsigned int> variables_in,
     151             :                   const System & f_sys_in,
     152             :                   const FEMFunctionBase<Number> & f_in,
     153             :                   const FEMFunctionBase<Gradient> & g_in,
     154           0 :                   VariableIndexing type) :
     155           0 :   b(std::move(b_in)),
     156           0 :   variables(std::move(variables_in)),
     157           0 :   f_system(&f_sys_in),
     158           0 :   jacobian_tolerance(0.)
     159             : {
     160           0 :   if (type == LOCAL_VARIABLE_ORDER)
     161             :     {
     162           0 :       auto cf = std::make_unique<CompositeFEMFunction<Number>>();
     163           0 :       cf->attach_subfunction(f_in, variables);
     164           0 :       f_fem = std::move(cf);
     165             : 
     166           0 :       auto cg = std::make_unique<CompositeFEMFunction<Gradient>>();
     167           0 :       cg->attach_subfunction(g_in, variables);
     168           0 :       g_fem = std::move(cg);
     169           0 :     }
     170             :   else
     171             :     {
     172           0 :       f_fem = f_in.clone();
     173           0 :       g_fem = g_in.clone();
     174             :     }
     175           0 : }
     176             : 
     177             : 
     178       13059 : DirichletBoundary::
     179       13059 : DirichletBoundary(const DirichletBoundary & d_in) :
     180         370 :   b(d_in.b),
     181       13059 :   variables(d_in.variables),
     182       13429 :   f(d_in.f ? d_in.f->clone() : nullptr),
     183       12781 :   g(d_in.g ? d_in.g->clone() : nullptr),
     184       12689 :   f_fem(d_in.f_fem ? d_in.f_fem->clone() : nullptr),
     185       12689 :   g_fem(d_in.g_fem ? d_in.g_fem->clone() : nullptr),
     186       13059 :   f_system(d_in.f_system),
     187       16019 :   jacobian_tolerance(d_in.jacobian_tolerance)
     188             : {
     189         370 :   libmesh_assert(f || f_fem);
     190         370 :   libmesh_assert(!(f && f_fem));
     191         370 :   libmesh_assert(!(f && g_fem));
     192         370 :   libmesh_assert(!(f_fem && g));
     193         370 :   libmesh_assert(!(f_fem && !f_system));
     194       13059 :   if (f)
     195       13059 :     f->init();
     196       13059 :   if (g)
     197        1633 :     g->init();
     198       13059 : }
     199             : 
     200             : 
     201           0 : DirichletBoundary & DirichletBoundary::operator= (const DirichletBoundary & rhs)
     202             : {
     203             :   // Implementation in terms of the copy constructor to avoid code duplication.
     204           0 :   DirichletBoundary tmp(rhs);
     205           0 :   std::swap(tmp, *this); // class must be "MoveAssignable" and "MoveConstructible" for std::swap to work.
     206           0 :   return *this;
     207           0 : }
     208             : 
     209             : 
     210       24906 : DirichletBoundary::~DirichletBoundary () = default;
     211             : 
     212             : } // namespace libMesh
     213             : 
     214             : #endif // LIBMESH_ENABLE_DIRICHLET

Generated by: LCOV version 1.14