Skip to content

Commit

Permalink
we need for now to shortcut a few calls in MooseVariableData for spec…
Browse files Browse the repository at this point in the history
…ial tags otherwise end up with redundant evaluations idaholab#17586
  • Loading branch information
YaqiWang authored and somu15 committed May 15, 2021
1 parent 70b7967 commit 02c8b21
Showing 1 changed file with 78 additions and 26 deletions.
104 changes: 78 additions & 26 deletions framework/src/variables/MooseVariableData.C
Expand Up @@ -1917,8 +1917,21 @@ template <typename OutputType>
const typename MooseVariableData<OutputType>::DoFValue &
MooseVariableData<OutputType>::vectorTagDofValue(TagID tag) const
{
_need_vector_tag_dof_u[tag] = true;
return _vector_tags_dof_u[tag];
// we need to check special tags until we use tagging for all evaluations
// otherwise we will have redundant evaluations.
if (tag == _subproblem.getVectorTagID(Moose::SOLUTION_TAG))
return dofValues();
else if (_subproblem.vectorTagExists(Moose::OLD_SOLUTION_TAG) &&
tag == _subproblem.getVectorTagID(Moose::OLD_SOLUTION_TAG))
return dofValuesOld();
else if (_subproblem.vectorTagExists(Moose::OLDER_SOLUTION_TAG) &&
tag == _subproblem.getVectorTagID(Moose::OLDER_SOLUTION_TAG))
return dofValuesOlder();
else
{
_need_vector_tag_dof_u[tag] = true;
return _vector_tags_dof_u[tag];
}
}

template <typename OutputType>
Expand Down Expand Up @@ -2202,15 +2215,28 @@ MooseVariableData<OutputType>::nodalVectorTagValue(TagID tag) const
{
if (isNodal())
{
_need_vector_tag_dof_u[tag] = true;

if (_sys.hasVector(tag) && tag < _vector_tags_dof_u.size())
return _vector_tags_dof_u[tag];
// we need to check special tags until we use tagging for all evaluations
// otherwise we will have redundant evaluations.
if (tag == _subproblem.getVectorTagID(Moose::SOLUTION_TAG))
return dofValues();
else if (_subproblem.vectorTagExists(Moose::OLD_SOLUTION_TAG) &&
tag == _subproblem.getVectorTagID(Moose::OLD_SOLUTION_TAG))
return dofValuesOld();
else if (_subproblem.vectorTagExists(Moose::OLDER_SOLUTION_TAG) &&
tag == _subproblem.getVectorTagID(Moose::OLD_SOLUTION_TAG))
return dofValuesOlder();
else
mooseError("Tag is not associated with any vector or there is no any data for tag ",
tag,
" for nodal variable ",
_var.name());
{
_need_vector_tag_dof_u[tag] = true;

if (_sys.hasVector(tag) && tag < _vector_tags_dof_u.size())
return _vector_tags_dof_u[tag];
else
mooseError("Tag is not associated with any vector or there is no any data for tag ",
tag,
" for nodal variable ",
_var.name());
}
}
else
mooseError("Nodal values can be requested only on nodal variables, variable '",
Expand Down Expand Up @@ -2244,30 +2270,56 @@ template <typename OutputType>
const typename MooseVariableData<OutputType>::FieldVariableValue &
MooseVariableData<OutputType>::vectorTagValue(TagID tag) const
{
_need_vector_tag_u[tag] = true;

if (_sys.hasVector(tag) && tag < _vector_tag_u.size())
return _vector_tag_u[tag];
// we need to check special tags until we use tagging for all evaluations
// otherwise we will have redundant evaluations.
if (tag == _subproblem.getVectorTagID(Moose::SOLUTION_TAG))
return sln(Moose::Current);
else if (_subproblem.vectorTagExists(Moose::OLD_SOLUTION_TAG) &&
tag == _subproblem.getVectorTagID(Moose::OLD_SOLUTION_TAG))
return sln(Moose::Old);
else if (_subproblem.vectorTagExists(Moose::OLDER_SOLUTION_TAG) &&
tag == _subproblem.getVectorTagID(Moose::OLD_SOLUTION_TAG))
return sln(Moose::Older);
else
mooseError("Tag is not associated with any vector or there is no any data for tag ",
tag,
" for variable ",
_var.name());
{
_need_vector_tag_u[tag] = true;

if (_sys.hasVector(tag) && tag < _vector_tag_u.size())
return _vector_tag_u[tag];
else
mooseError("Tag is not associated with any vector or there is no any data for tag ",
tag,
" for variable ",
_var.name());
}
}

template <typename OutputType>
const typename MooseVariableData<OutputType>::FieldVariableGradient &
MooseVariableData<OutputType>::vectorTagGradient(TagID tag) const
{
_need_vector_tag_grad[tag] = true;

if (_sys.hasVector(tag) && tag < _vector_tag_grad.size())
return _vector_tag_grad[tag];
// we need to check special tags until we use tagging for all evaluations
// otherwise we will have redundant evaluations.
if (tag == _subproblem.getVectorTagID(Moose::SOLUTION_TAG))
return gradSln(Moose::Current);
else if (_subproblem.vectorTagExists(Moose::OLD_SOLUTION_TAG) &&
tag == _subproblem.getVectorTagID(Moose::OLD_SOLUTION_TAG))
return gradSln(Moose::Old);
else if (_subproblem.vectorTagExists(Moose::OLDER_SOLUTION_TAG) &&
tag == _subproblem.getVectorTagID(Moose::OLD_SOLUTION_TAG))
return gradSln(Moose::Older);
else
mooseError("Tag is not associated with any vector or there is no any data for tag ",
tag,
" for variable ",
_var.name());
{
_need_vector_tag_grad[tag] = true;

if (_sys.hasVector(tag) && tag < _vector_tag_grad.size())
return _vector_tag_grad[tag];
else
mooseError("Tag is not associated with any vector or there is no any data for tag ",
tag,
" for variable ",
_var.name());
}
}

template <typename OutputType>
Expand Down

0 comments on commit 02c8b21

Please sign in to comment.