libMesh
variable.C
Go to the documentation of this file.
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 unsigned int Variable::n_components() const
24 {
25  if (_type.family == SCALAR)
26  return _type.order.get_order();
27 
28  if (const auto fe_field_type = FEInterface::field_type(_type.family);
29  fe_field_type == TYPE_VECTOR)
30  libmesh_error_msg("Cannot determine the number of components. Please call the n_components "
31  "overload with a mesh argument");
32  else
33  return 1;
34 }
35 
36 unsigned int Variable::n_components(const MeshBase & mesh) const
37 {
38  if (_type.family == SCALAR)
39  return _type.order.get_order();
40  else
42 }
43 }
FEFamily family
The type of finite element.
Definition: fe_type.h:221
MeshBase & mesh
static FEFieldType field_type(const FEType &fe_type)
OrderWrapper order
The approximation order of the element.
Definition: fe_type.h:215
The libMesh namespace provides an interface to certain functionality in the library.
This is the MeshBase class.
Definition: mesh_base.h:75
unsigned int n_components() const
Definition: variable.C:23
static unsigned int n_vec_dim(const MeshBase &mesh, const FEType &fe_type)
int get_order() const
Explicitly request the order as an int.
Definition: fe_type.h:80