LCOV - code coverage report
Current view: top level - src/base - periodic_boundary_base.C (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4229 (6a9aeb) with base 727f46 Lines: 31 34 91.2 %
Date: 2025-08-19 19:27:09 Functions: 8 9 88.9 %
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             : // Local Includes
      19             : #include "libmesh/libmesh_config.h"
      20             : 
      21             : #ifdef LIBMESH_ENABLE_PERIODIC
      22             : 
      23             : #include "libmesh/periodic_boundary_base.h"
      24             : 
      25             : #include "libmesh/boundary_info.h" // BoundaryInfo::invalid_id
      26             : 
      27             : // C++ Includes
      28             : #include <memory>
      29             : 
      30             : 
      31             : namespace libMesh
      32             : {
      33             : 
      34        1073 : PeriodicBoundaryBase::PeriodicBoundaryBase() :
      35         997 :   myboundary(BoundaryInfo::invalid_id),
      36        1073 :   pairedboundary(BoundaryInfo::invalid_id)
      37             : {
      38        1073 : }
      39             : 
      40             : 
      41             : 
      42        1539 : PeriodicBoundaryBase::PeriodicBoundaryBase(const PeriodicBoundaryBase & o) :
      43        1539 :   myboundary(o.myboundary),
      44        1539 :   pairedboundary(o.pairedboundary),
      45        1539 :   variables(o.variables)
      46             : {
      47             :   // Make a deep copy of _transformation_matrix, if it's not null
      48        1539 :   if(o._transformation_matrix)
      49             :   {
      50         840 :     this->_transformation_matrix = std::make_unique<DenseMatrix<Real>>();
      51         426 :     *(this->_transformation_matrix) = *(o._transformation_matrix);
      52             :   }
      53        1539 : }
      54             : 
      55             : 
      56             : 
      57        1704 : void PeriodicBoundaryBase::set_variable(unsigned int var)
      58             : {
      59        1656 :   variables.insert(var);
      60        1704 : }
      61             : 
      62             : 
      63             : 
      64           0 : void PeriodicBoundaryBase::merge(const PeriodicBoundaryBase & pb)
      65             : {
      66           0 :   variables.insert(pb.variables.begin(), pb.variables.end());
      67           0 : }
      68             : 
      69             : 
      70             : 
      71      126080 : bool PeriodicBoundaryBase::is_my_variable(unsigned int var_num) const
      72             : {
      73      133880 :   bool a = variables.empty() || (!variables.empty() && variables.find(var_num) != variables.end());
      74      126080 :   return a;
      75             : }
      76             : 
      77             : 
      78             : 
      79       38282 : bool PeriodicBoundaryBase::has_transformation_matrix() const
      80             : {
      81       38282 :   return bool(_transformation_matrix);
      82             : }
      83             : 
      84             : 
      85             : 
      86       14256 : const DenseMatrix<Real> & PeriodicBoundaryBase::get_transformation_matrix() const
      87             : {
      88       14256 :   libmesh_error_msg_if(!has_transformation_matrix(),
      89             :                        "Transformation matrix is not defined");
      90             : 
      91       14256 :   return *_transformation_matrix;
      92             : }
      93             : 
      94             : 
      95             : 
      96         568 : void PeriodicBoundaryBase::set_transformation_matrix(const DenseMatrix<Real> & matrix)
      97             : {
      98             :   // Make a deep copy of matrix
      99        1120 :   this->_transformation_matrix = std::make_unique<DenseMatrix<Real>>();
     100         568 :   *(this->_transformation_matrix) = matrix;
     101             : 
     102             :   // if _transformation_matrix is defined then it must be the same sie as variables.
     103          16 :   libmesh_assert_equal_to(_transformation_matrix->m(), variables.size());
     104          16 :   libmesh_assert_equal_to(_transformation_matrix->n(), variables.size());
     105         568 : }
     106             : 
     107             : 
     108             : 
     109       11996 : const std::set<unsigned int> & PeriodicBoundaryBase::get_variables() const
     110             : {
     111       11996 :   return variables;
     112             : }
     113             : 
     114             : } // namespace libMesh
     115             : 
     116             : #endif // LIBMESH_ENABLE_PERIODIC

Generated by: LCOV version 1.14