Skip to content

Commit

Permalink
add three functions to retrieve all dofs on an element idaholab#9690
Browse files Browse the repository at this point in the history
  • Loading branch information
YaqiWang committed Aug 30, 2017
1 parent ad8d9b9 commit 36a74b4
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
21 changes: 21 additions & 0 deletions framework/include/base/MooseVariable.h
Expand Up @@ -401,6 +401,27 @@ class MooseVariable : public MooseVariableBase
*/
Number getElementalValue(const Elem * elem, unsigned int idx = 0) const;

/**
* Retrieve all the Elemental DOFs
* @param elem The element we are computing on
* @param dofs The retrieved DOFs
*/
void getElementalValues(const Elem * elem, DenseVector<Number> & dofs) const;

/**
* Retrieve all the old Elemental DOFs
* @param elem The element we are computing on
* @param dofs The retrieved old DOFs
*/
void getElementalValuesOld(const Elem * elem, DenseVector<Number> & dofs) const;

/**
* Retrieve all the older Elemental DOFs
* @param elem The element we are computing on
* @param dofs The retrieved older DOFs
*/
void getElementalValuesOlder(const Elem * elem, DenseVector<Number> & dofs) const;

/**
* Whether or not this variable is actually using the shape function value.
*
Expand Down
33 changes: 33 additions & 0 deletions framework/src/base/MooseVariable.C
Expand Up @@ -1899,3 +1899,36 @@ MooseVariable::getElementalValue(const Elem * elem, unsigned int idx) const

return (*_sys.currentSolution())(dof_indices[idx]);
}

void
MooseVariable::getElementalValues(const Elem * elem, DenseVector<Number> & dofs) const
{
std::vector<dof_id_type> dof_indices;
_dof_map.dof_indices(elem, dof_indices, _var_num);
unsigned int num_dofs = _dof_indices.size();
dofs.resize(num_dofs);
for (unsigned int i = 0; i < num_dofs; ++i)
dofs(i) = (*_sys.currentSolution())(_dof_indices[i]);
}

void
MooseVariable::getElementalValuesOld(const Elem * elem, DenseVector<Number> & dofs) const
{
std::vector<dof_id_type> dof_indices;
_dof_map.dof_indices(elem, dof_indices, _var_num);
unsigned int num_dofs = _dof_indices.size();
dofs.resize(num_dofs);
for (unsigned int i = 0; i < num_dofs; ++i)
dofs(i) = _sys.solutionOld()(_dof_indices[i]);
}

void
MooseVariable::getElementalValuesOlder(const Elem * elem, DenseVector<Number> & dofs) const
{
std::vector<dof_id_type> dof_indices;
_dof_map.dof_indices(elem, dof_indices, _var_num);
unsigned int num_dofs = _dof_indices.size();
dofs.resize(num_dofs);
for (unsigned int i = 0; i < num_dofs; ++i)
dofs(i) = _sys.solutionOlder()(_dof_indices[i]);
}

0 comments on commit 36a74b4

Please sign in to comment.