https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Private Attributes | Friends | List of all members
JvarMapInterfaceBase< T > Class Template Reference

Base class ("Veneer") that implements the actual mapping from 'jvar' in into the _coupled_moose_vars array. More...

#include <JvarMapInterface.h>

Inheritance diagram for JvarMapInterfaceBase< T >:
[legend]

Public Types

typedef std::vector< int > JvarMap
 

Public Member Functions

 JvarMapInterfaceBase (const InputParameters &parameters)
 
unsigned int mapJvarToCvar (unsigned int jvar)
 Return index into the _coupled_moose_vars array for a given jvar.
 
int mapJvarToCvar (unsigned int jvar, const JvarMap &jvar_map)
 Return an index into a specific coupled variable vector for a given jvar.
 
const JvarMap & getJvarMap ()
 Obtain the map connecting libmesh variable ID number to its position in the _coupled_moose_vars vector.
 
const JvarMap & getParameterJvarMap (std::string parameter_name)
 Make a specific map for a given parameter name representing a couple variable (vector)
 
bool mapJvarToCvar (unsigned int jvar, unsigned int &cvar)
 Set the cvar value to the mapped jvar value and return true if the mapping exists.
 

Static Public Member Functions

static InputParameters validParams ()
 

Protected Attributes

const unsigned int _n_args
 number of coupled moose variables
 

Private Attributes

const std::size_t _jvar_max_size
 number of nonlinear variables in the system
 
JvarMap _jvar_map
 look-up table to determine the _coupled_moose_vars index for the jvar parameter
 
std::map< std::string, JvarMap > _jvar_local_map
 map of local look-up tables for specific parameters
 

Friends

class JvarMapKernelInterface< T >
 
class JvarMapIntegratedBCInterface< T >
 

Detailed Description

template<class T>
class JvarMapInterfaceBase< T >

Base class ("Veneer") that implements the actual mapping from 'jvar' in into the _coupled_moose_vars array.

Definition at line 60 of file JvarMapInterface.h.

Member Typedef Documentation

◆ JvarMap

template<class T >
typedef std::vector<int> JvarMapInterfaceBase< T >::JvarMap

Definition at line 63 of file JvarMapInterface.h.

Constructor & Destructor Documentation

◆ JvarMapInterfaceBase()

template<class T >
JvarMapInterfaceBase< T >::JvarMapInterfaceBase ( const InputParameters &  parameters)

Definition at line 125 of file JvarMapInterface.h.

126 : T(parameters),
127 _n_args(this->_coupled_standard_moose_vars.size()),
128 _jvar_max_size(this->_sys.nVariables()),
130{
131 // populate map
132 for (auto it : Moose::enumerate(this->_coupled_moose_vars))
133 {
134 const auto & var = *it.value();
135
136 // skip variables from other systems (AuxVariables or variables of another nonlinear system)
137 // as off-diagonal jacobian entries are not calculated for them. Their numbers are local to
138 // their own system, so they cannot be distinguished by comparing against nVariables()
139 if (&var.sys() == &this->_sys)
140 _jvar_map[var.number()] = it.index();
141 }
142
143 // mark the kernel variable for the check in computeOffDiagJacobian
144 _jvar_map[this->_var.number()] = 0;
145}
const unsigned int _n_args
number of coupled moose variables
JvarMap _jvar_map
look-up table to determine the _coupled_moose_vars index for the jvar parameter
const std::size_t _jvar_max_size
number of nonlinear variables in the system
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
_enumerate_range< Iterator > enumerate(Iterator first, Iterator last, typename std::iterator_traits< Iterator >::difference_type initial)
Enumerate function for iterating over a range and obtaining both a reference to the underlying type a...
Definition Enumerate.h:52

Member Function Documentation

◆ getJvarMap()

template<class T >
const JvarMap & JvarMapInterfaceBase< T >::getJvarMap ( )
inline

Obtain the map connecting libmesh variable ID number to its position in the _coupled_moose_vars vector.

Definition at line 80 of file JvarMapInterface.h.

80{ return _jvar_map; }

◆ getParameterJvarMap()

template<class T >
const JvarMapInterfaceBase< T >::JvarMap & JvarMapInterfaceBase< T >::getParameterJvarMap ( std::string  parameter_name)

Make a specific map for a given parameter name representing a couple variable (vector)

Definition at line 170 of file JvarMapInterface.h.

171{
172 auto & jvar_map = _jvar_local_map[parameter_name];
173 jvar_map.assign(_jvar_max_size, -1);
174
175 // populate local map
176 const auto num = this->coupledComponents(parameter_name);
177 for (std::size_t i = 0; i < num; ++i)
178 {
179 const auto & var = *this->getVar(parameter_name, i);
180
181 // skip variables from other systems, see the constructor
182 if (&var.sys() == &this->_sys)
183 jvar_map[var.number()] = i;
184 }
185
186 return jvar_map;
187}
std::map< std::string, JvarMap > _jvar_local_map
map of local look-up tables for specific parameters

◆ mapJvarToCvar() [1/3]

template<class T >
unsigned int JvarMapInterfaceBase< T >::mapJvarToCvar ( unsigned int  jvar)

Return index into the _coupled_moose_vars array for a given jvar.

Definition at line 149 of file JvarMapInterface.h.

150{
151 mooseAssert(jvar < _jvar_max_size,
152 "Calling mapJvarToCvar for an invalid Moose variable number. Maybe an AuxVariable?");
153 int cit = _jvar_map[jvar];
154
155 mooseAssert(cit >= 0, "Calling mapJvarToCvar for a variable not coupled to this kernel.");
156 return cit;
157}

Referenced by MatReaction::computeQpOffDiagJacobian().

◆ mapJvarToCvar() [2/3]

template<class T >
int JvarMapInterfaceBase< T >::mapJvarToCvar ( unsigned int  jvar,
const JvarMap &  jvar_map 
)

Return an index into a specific coupled variable vector for a given jvar.

A negative return value indicates that the jvar value does not point to a variable in the couple variable vector corresponding to the mapped parameter.

Definition at line 161 of file JvarMapInterface.h.

162{
163 mooseAssert(jvar < _jvar_max_size,
164 "Calling mapJvarToCvar for an invalid Moose variable number. Maybe an AuxVariable?");
165 return jvar_map[jvar];
166}

◆ mapJvarToCvar() [3/3]

template<class T >
bool JvarMapInterfaceBase< T >::mapJvarToCvar ( unsigned int  jvar,
unsigned int &  cvar 
)

Set the cvar value to the mapped jvar value and return true if the mapping exists.

Otherwise return false.

Parameters
[in]jvarVariable number passed as argument to computeQpOffDiagJacobian
[out]cvarCorresponding index into the _coupled_moose_vars array
Returns
true if the requested variable is coupled, false otherwise

◆ validParams()

template<class T >
InputParameters JvarMapInterfaceBase< T >::validParams ( )
static

Definition at line 115 of file JvarMapInterface.h.

116{
117 auto params = T::validParams();
118 params.addCoupledVar("coupled_variables",
119 "Vector of nonlinear variable arguments this object depends on");
120
121 return params;
122}

Friends And Related Symbol Documentation

◆ JvarMapIntegratedBCInterface< T >

template<class T >
friend class JvarMapIntegratedBCInterface< T >
friend

Definition at line 107 of file JvarMapInterface.h.

◆ JvarMapKernelInterface< T >

template<class T >
friend class JvarMapKernelInterface< T >
friend

Definition at line 107 of file JvarMapInterface.h.

Member Data Documentation

◆ _jvar_local_map

template<class T >
std::map<std::string, JvarMap> JvarMapInterfaceBase< T >::_jvar_local_map
private

map of local look-up tables for specific parameters

Definition at line 107 of file JvarMapInterface.h.

Referenced by JvarMapInterfaceBase< T >::getParameterJvarMap().

◆ _jvar_map

template<class T >
JvarMap JvarMapInterfaceBase< T >::_jvar_map
private

◆ _jvar_max_size

template<class T >
const std::size_t JvarMapInterfaceBase< T >::_jvar_max_size
private

◆ _n_args

template<class T >
const unsigned int JvarMapInterfaceBase< T >::_n_args
protected

number of coupled moose variables

Definition at line 97 of file JvarMapInterface.h.

Referenced by MatReaction::MatReaction().


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