libMesh
Public Member Functions | Protected Attributes | List of all members
libMesh::VariableGroup Class Reference

This class defines a logically grouped set of variables in the system. More...

#include <variable.h>

Inheritance diagram for libMesh::VariableGroup:
[legend]

Public Member Functions

 VariableGroup (System *sys, std::vector< std::string > var_names, const unsigned int var_number, const unsigned int first_scalar_num, const FEType &var_type)
 Constructor. More...
 
 VariableGroup (System *sys, std::vector< std::string > var_names, const unsigned int var_number, const unsigned int first_scalar_num, const FEType &var_type, const std::set< subdomain_id_type > &var_active_subdomains)
 Constructor. More...
 
 VariableGroup (const VariableGroup &)=default
 Standard constructors. More...
 
VariableGroupoperator= (const VariableGroup &)=default
 
 VariableGroup (VariableGroup &&)=default
 
VariableGroupoperator= (VariableGroup &&)=default
 
bool operator== (const VariableGroup &other) const
 
unsigned int n_variables () const
 
Variable variable (unsigned int v) const
 
Variable operator() (unsigned int v) const
 Support vg(v). More...
 
const std::string & name (unsigned int v) const
 
unsigned int number (unsigned int v) const
 
unsigned int first_scalar_number (unsigned int v) const
 
void append (std::string var_name)
 Appends a variable to the group. More...
 
unsigned int number () const
 
bool operator== (const Variable &other) const
 
Systemsystem () const
 
const std::string & name () const
 
unsigned int number () const
 
unsigned int first_scalar_number () const
 
const FETypetype () const
 
unsigned int n_components () const
 
bool active_on_subdomain (subdomain_id_type sid) const
 
bool implicitly_active () const
 
const std::set< subdomain_id_type > & active_subdomains () const
 

Protected Attributes

std::vector< std::string > _names
 
System_sys
 
std::string _name
 
std::set< subdomain_id_type_active_subdomains
 
unsigned int _number
 
unsigned int _first_scalar_number
 
FEType _type
 

Detailed Description

This class defines a logically grouped set of variables in the system.

VariableGroup is appropriate for representing several unknowns in the problem that are all approximated with the same finite element approximation family and (optionally) a list of subdomains to which the variables are restricted.

Definition at line 193 of file variable.h.

Constructor & Destructor Documentation

◆ VariableGroup() [1/4]

libMesh::VariableGroup::VariableGroup ( System sys,
std::vector< std::string >  var_names,
const unsigned int  var_number,
const unsigned int  first_scalar_num,
const FEType var_type 
)
inline

Constructor.

Omits the subdomain mapping, hence this constructor creates a variable which is active on all subdomains.

Definition at line 201 of file variable.h.

205  :
206  Variable (sys,
207  "var_group",
208  var_number,
209  first_scalar_num,
210  var_type),
211  _names(std::move(var_names))
212  {}
Variable(System *sys, std::string var_name, const unsigned int var_number, const unsigned int first_scalar_num, const FEType &var_type)
Constructor.
Definition: variable.h:58
std::vector< std::string > _names
Definition: variable.h:322

◆ VariableGroup() [2/4]

libMesh::VariableGroup::VariableGroup ( System sys,
std::vector< std::string >  var_names,
const unsigned int  var_number,
const unsigned int  first_scalar_num,
const FEType var_type,
const std::set< subdomain_id_type > &  var_active_subdomains 
)
inline

Constructor.

Takes a set which contains the subdomain indices for which this variable is active.

Definition at line 219 of file variable.h.

224  :
225 
226  Variable (sys,
227  "var_group",
228  var_number,
229  first_scalar_num,
230  var_type,
231  var_active_subdomains),
232  _names(std::move(var_names))
233  {}
Variable(System *sys, std::string var_name, const unsigned int var_number, const unsigned int first_scalar_num, const FEType &var_type)
Constructor.
Definition: variable.h:58
std::vector< std::string > _names
Definition: variable.h:322

◆ VariableGroup() [3/4]

libMesh::VariableGroup::VariableGroup ( const VariableGroup )
default

Standard constructors.

◆ VariableGroup() [4/4]

libMesh::VariableGroup::VariableGroup ( VariableGroup &&  )
default

Member Function Documentation

◆ active_on_subdomain()

bool libMesh::Variable::active_on_subdomain ( subdomain_id_type  sid) const
inlineinherited
Returns
true if this variable is active on subdomain sid, false otherwise.
Note
We interpret the special case of an empty _active_subdomains container as active everywhere, i.e. for all subdomains.

Definition at line 157 of file variable.h.

References libMesh::Variable::_active_subdomains.

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::DofMap::_dof_indices(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::FEGenericBase< FEOutputType< T >::type >::compute_proj_constraints(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DofMap::dof_indices(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::find_dofs_to_send(), libMesh::DofMap::local_variable_indices(), libMesh::DofMap::old_dof_indices(), libMesh::BoundaryProjectSolution::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SortAndCopy::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectInteriors::operator()(), libMesh::DofMap::reinit(), and libMesh::Nemesis_IO_Helper::write_nodal_solution().

158  { return (_active_subdomains.empty() || _active_subdomains.count(sid)); }
std::set< subdomain_id_type > _active_subdomains
Definition: variable.h:177

◆ active_subdomains()

const std::set<subdomain_id_type>& libMesh::Variable::active_subdomains ( ) const
inlineinherited

◆ append()

void libMesh::VariableGroup::append ( std::string  var_name)
inline

Appends a variable to the group.

Really only can be used by System in a very limited window of opportunity - after the user specifies variables but before the system is initialized.

Definition at line 318 of file variable.h.

References _names.

319  { _names.push_back (std::move(var_name)); }
std::vector< std::string > _names
Definition: variable.h:322

◆ first_scalar_number() [1/2]

unsigned int libMesh::Variable::first_scalar_number ( ) const
inlineinherited
Returns
The index of the first scalar component of this variable in the system.

Definition at line 134 of file variable.h.

References libMesh::Variable::_first_scalar_number.

Referenced by libMesh::System::n_components(), and variable().

135  { return _first_scalar_number; }
unsigned int _first_scalar_number
Definition: variable.h:179

◆ first_scalar_number() [2/2]

unsigned int libMesh::VariableGroup::first_scalar_number ( unsigned int  v) const
inline
Returns
The index of the first scalar component of this variable in the system.

Definition at line 307 of file variable.h.

References libMesh::Variable::_first_scalar_number, and n_variables().

308  {
309  libmesh_assert_less (v, this->n_variables());
310  return _first_scalar_number+v;
311  }
unsigned int _first_scalar_number
Definition: variable.h:179
unsigned int n_variables() const
Definition: variable.h:256

◆ implicitly_active()

bool libMesh::Variable::implicitly_active ( ) const
inlineinherited
Returns
true if this variable is active on all subdomains because it has no specified activity map. This can be used to perform more efficient computations in some places.

Definition at line 165 of file variable.h.

References libMesh::Variable::_active_subdomains.

Referenced by libMesh::System::add_variable().

166  { return _active_subdomains.empty(); }
std::set< subdomain_id_type > _active_subdomains
Definition: variable.h:177

◆ n_components()

unsigned int libMesh::Variable::n_components ( ) const
inlineinherited
Returns
The number of components of this variable.

Definition at line 146 of file variable.h.

References libMesh::Variable::_type, libMesh::FEType::family, libMesh::OrderWrapper::get_order(), libMesh::FEType::order, libMesh::SCALAR, and libMesh::Variable::type().

Referenced by libMesh::System::n_components(), libMesh::BoundaryVolumeSolutionTransfer::transfer_boundary_volume(), and libMesh::BoundaryVolumeSolutionTransfer::transfer_volume_boundary().

147  { return type().family == SCALAR ? _type.order.get_order() : 1; }
FEFamily family
The type of finite element.
Definition: fe_type.h:207
OrderWrapper order
The approximation order of the element.
Definition: fe_type.h:201
int get_order() const
Explicitly request the order as an int.
Definition: fe_type.h:80
const FEType & type() const
Definition: variable.h:140

◆ n_variables()

unsigned int libMesh::VariableGroup::n_variables ( ) const
inline

◆ name() [1/2]

const std::string& libMesh::Variable::name ( ) const
inlineinherited

◆ name() [2/2]

const std::string& libMesh::VariableGroup::name ( unsigned int  v) const
inline
Returns
The user-specified name of the variable.

Definition at line 285 of file variable.h.

References _names, and n_variables().

Referenced by libMesh::System::get_info().

286  {
287  libmesh_assert_less (v, this->n_variables());
288  return _names[v];
289  }
unsigned int n_variables() const
Definition: variable.h:256
std::vector< std::string > _names
Definition: variable.h:322

◆ number() [1/3]

unsigned int libMesh::Variable::number ( ) const
inlineinherited

◆ number() [2/3]

unsigned int libMesh::VariableGroup::number ( unsigned int  v) const
inline
Returns
The rank of this variable in the system.

Definition at line 294 of file variable.h.

References libMesh::Variable::_number, and n_variables().

Referenced by libMesh::DofMap::dof_indices(), and libMesh::DofMap::old_dof_indices().

295  {
296  libmesh_assert_less (v, this->n_variables());
297  return _number + v;
298  }
unsigned int n_variables() const
Definition: variable.h:256
unsigned int _number
Definition: variable.h:178

◆ number() [3/3]

unsigned int libMesh::Variable::number
inline
Returns
The rank of this variable in the system.

Definition at line 127 of file variable.h.

128  { return _number; }
unsigned int _number
Definition: variable.h:178

◆ operator()()

Variable libMesh::VariableGroup::operator() ( unsigned int  v) const
inline

Support vg(v).

Returns
A Variable for v.

Definition at line 279 of file variable.h.

References variable().

280  { return this->variable(v); }
Variable variable(unsigned int v) const
Definition: variable.h:263

◆ operator=() [1/2]

VariableGroup& libMesh::VariableGroup::operator= ( const VariableGroup )
default

◆ operator=() [2/2]

VariableGroup& libMesh::VariableGroup::operator= ( VariableGroup &&  )
default

◆ operator==() [1/2]

bool libMesh::Variable::operator== ( const Variable other) const
inlineinherited
Returns
true iff the other Variable has the same characteristics and system numbering as this one.

Definition at line 101 of file variable.h.

References libMesh::Variable::_active_subdomains, libMesh::Variable::_first_scalar_number, libMesh::Variable::_name, libMesh::Variable::_sys, and libMesh::Variable::_type.

102  {
103  return (_sys == other._sys) &&
104  (_name == other._name) &&
105  (_active_subdomains == other._active_subdomains) &&
106  (_first_scalar_number == other._first_scalar_number) &&
107  (_type == other._type);
108  }
std::set< subdomain_id_type > _active_subdomains
Definition: variable.h:177
std::string _name
Definition: variable.h:176
unsigned int _first_scalar_number
Definition: variable.h:179
System * _sys
Definition: variable.h:175

◆ operator==() [2/2]

bool libMesh::VariableGroup::operator== ( const VariableGroup other) const
inline
Returns
true iff the other VariableGroup has exactly the same Variable members as this one.

Definition at line 247 of file variable.h.

References _names.

248  {
249  return (this->Variable::operator==(other)) &&
250  (_names == other._names);
251  }
std::vector< std::string > _names
Definition: variable.h:322

◆ system()

System* libMesh::Variable::system ( ) const
inlineinherited

◆ type()

const FEType& libMesh::Variable::type ( ) const
inlineinherited
Returns
The FEType for this variable.

Definition at line 140 of file variable.h.

References libMesh::Variable::_type.

Referenced by libMesh::DofMap::_dof_indices(), libMesh::DofMap::_node_dof_indices(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DifferentiableSystem::add_second_order_dot_vars(), libMesh::FEMSystem::assembly(), libMesh::FEGenericBase< FEOutputType< T >::type >::compute_proj_constraints(), libMesh::FirstOrderUnsteadySolver::compute_second_order_eqns(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DofMap::distribute_scalar_dofs(), libMesh::DofMap::dof_indices(), libMesh::System::get_info(), main(), libMesh::Variable::n_components(), libMesh::DifferentiablePhysics::nonlocal_mass_residual(), libMesh::DofMap::old_dof_indices(), libMesh::BoundaryProjectSolution::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SortAndCopy::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectVertices::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectEdges::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectSides::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectInteriors::operator()(), libMesh::System::project_vector(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::DofMap::reinit(), libMesh::DofMap::SCALAR_dof_indices(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::DirectSolutionTransfer::transfer(), variable(), libMesh::System::write_parallel_data(), and libMesh::System::write_serialized_vector().

141  { return _type; }

◆ variable()

Variable libMesh::VariableGroup::variable ( unsigned int  v) const
inline
Returns
A Variable object constructed for an individual member of our group.

Definition at line 263 of file variable.h.

References libMesh::Variable::active_subdomains(), libMesh::Variable::first_scalar_number(), n_variables(), libMesh::Variable::name(), libMesh::Variable::number(), libMesh::Variable::system(), libMesh::Variable::type(), and libMesh::Variable::Variable().

Referenced by operator()().

264  {
265  libmesh_assert_less (v, this->n_variables());
266  return Variable (this->system(),
267  this->name(v),
268  this->number(v),
269  this->first_scalar_number(v),
270  this->type(),
271  this->active_subdomains());
272  }
Variable(System *sys, std::string var_name, const unsigned int var_number, const unsigned int first_scalar_num, const FEType &var_type)
Constructor.
Definition: variable.h:58
unsigned int first_scalar_number() const
Definition: variable.h:134
const std::set< subdomain_id_type > & active_subdomains() const
Definition: variable.h:171
unsigned int n_variables() const
Definition: variable.h:256
System * system() const
Definition: variable.h:113
const std::string & name() const
Definition: variable.h:121
unsigned int number() const
Definition: variable.h:127
const FEType & type() const
Definition: variable.h:140

Member Data Documentation

◆ _active_subdomains

std::set<subdomain_id_type> libMesh::Variable::_active_subdomains
protectedinherited

◆ _first_scalar_number

unsigned int libMesh::Variable::_first_scalar_number
protectedinherited

◆ _name

std::string libMesh::Variable::_name
protectedinherited

Definition at line 176 of file variable.h.

Referenced by libMesh::Variable::name(), and libMesh::Variable::operator==().

◆ _names

std::vector<std::string> libMesh::VariableGroup::_names
protected

Definition at line 322 of file variable.h.

Referenced by append(), n_variables(), name(), and operator==().

◆ _number

unsigned int libMesh::Variable::_number
protectedinherited

Definition at line 178 of file variable.h.

Referenced by libMesh::Variable::number(), and number().

◆ _sys

System* libMesh::Variable::_sys
protectedinherited

Definition at line 175 of file variable.h.

Referenced by libMesh::Variable::operator==(), and libMesh::Variable::system().

◆ _type

FEType libMesh::Variable::_type
protectedinherited

The documentation for this class was generated from the following file: