LCOV - code coverage report
Current view: top level - src/base - variable.C (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4229 (6a9aeb) with base 727f46 Lines: 4 10 40.0 %
Date: 2025-08-19 19:27:09 Functions: 1 2 50.0 %
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             : #include "libmesh/variable.h"
      19             : #include "libmesh/fe_interface.h"
      20             : 
      21             : namespace libMesh
      22             : {
      23           0 : unsigned int Variable::n_components() const
      24             : {
      25           0 :   if (_type.family == SCALAR)
      26           0 :     return _type.order.get_order();
      27             : 
      28           0 :   if (const auto fe_field_type = FEInterface::field_type(_type.family);
      29             :       fe_field_type == TYPE_VECTOR)
      30           0 :     libmesh_error_msg("Cannot determine the number of components. Please call the n_components "
      31             :                       "overload with a mesh argument");
      32             :   else
      33           0 :     return 1;
      34             : }
      35             : 
      36    30207882 : unsigned int Variable::n_components(const MeshBase & mesh) const
      37             : {
      38    30207882 :   if (_type.family == SCALAR)
      39         140 :     return _type.order.get_order();
      40             :   else
      41    30207742 :     return FEInterface::n_vec_dim(mesh, _type);
      42             : }
      43             : }

Generated by: LCOV version 1.14