diff --git a/framework/include/auxkernels/TagMatrixAux.h b/framework/include/auxkernels/TagMatrixAux.h index 12d9e5589950..963a0ad7b0a0 100644 --- a/framework/include/auxkernels/TagMatrixAux.h +++ b/framework/include/auxkernels/TagMatrixAux.h @@ -31,7 +31,5 @@ class TagMatrixAux : public AuxKernel protected: virtual Real computeValue() override; - TagID _tag_id; const VariableValue & _v; }; - diff --git a/framework/include/auxkernels/TagVectorAux.h b/framework/include/auxkernels/TagVectorAux.h index 3d4046db723d..3054d135f4c5 100644 --- a/framework/include/auxkernels/TagVectorAux.h +++ b/framework/include/auxkernels/TagVectorAux.h @@ -31,7 +31,5 @@ class TagVectorAux : public AuxKernel protected: virtual Real computeValue() override; - TagID _tag_id; const VariableValue & _v; }; - diff --git a/framework/include/interfaces/Coupleable.h b/framework/include/interfaces/Coupleable.h index 0b145a0720c0..2f75e5894982 100644 --- a/framework/include/interfaces/Coupleable.h +++ b/framework/include/interfaces/Coupleable.h @@ -247,6 +247,10 @@ class Coupleable virtual const VariableValue & coupledVectorTagValue(const std::string & var_name, TagID tag, unsigned int comp = 0) const; + virtual const VariableValue & coupledVectorTagValue(const std::string & var_name, + const std::string & tag_name, + unsigned int comp = 0) const; + /** * Returns the values for all of a coupled variable's components for a given tag * @param var_name Name of coupled variable @@ -256,6 +260,9 @@ class Coupleable std::vector coupledVectorTagValues(const std::string & var_name, TagID tag) const; + std::vector coupledVectorTagValues(const std::string & var_name, + const std::string & tag_name) const; + /** * Returns gradient of a coupled variable for a given tag * @param var_name Name of coupled variable @@ -267,6 +274,10 @@ class Coupleable virtual const VariableGradient & coupledVectorTagGradient(const std::string & var_name, TagID tag, unsigned int comp = 0) const; + virtual const VariableGradient & coupledVectorTagGradient(const std::string & var_name, + const std::string & tag_name, + unsigned int comp = 0) const; + /** * Returns gradients for all of a coupled variable's components for a given tag * @param var_name Name of coupled variable @@ -276,6 +287,9 @@ class Coupleable std::vector coupledVectorTagGradients(const std::string & var_name, TagID tag) const; + std::vector + coupledVectorTagGradients(const std::string & var_name, const std::string & tag_name) const; + /** * Returns dof value of a coupled variable for a given tag * @param var_name Name of coupled variable @@ -286,6 +300,10 @@ class Coupleable virtual const VariableValue & coupledVectorTagDofValue(const std::string & var_name, TagID tag, unsigned int comp = 0) const; + virtual const VariableValue & coupledVectorTagDofValue(const std::string & var_name, + const std::string & tag_name, + unsigned int comp = 0) const; + /** * Returns the dof values for all of a coupled variable's components for a given tag * @param var_name Name of coupled variable @@ -295,6 +313,9 @@ class Coupleable std::vector coupledVectorTagDofValues(const std::string & var_name, TagID tag) const; + std::vector coupledVectorTagDofValues(const std::string & var_name, + const std::string & tag_name) const; + /** * Returns value of a coupled variable for a given tag. This couples the diag vector of matrix * @param var_name Name of coupled variable @@ -306,6 +327,10 @@ class Coupleable virtual const VariableValue & coupledMatrixTagValue(const std::string & var_name, TagID tag, unsigned int comp = 0) const; + virtual const VariableValue & coupledMatrixTagValue(const std::string & var_name, + const std::string & tag_name, + unsigned int comp = 0) const; + /** * Returns the diagonal matrix values for all of a coupled variable's components for a given tag * @param var_name Name of coupled variable @@ -315,6 +340,9 @@ class Coupleable std::vector coupledMatrixTagValues(const std::string & var_name, TagID tag) const; + std::vector coupledMatrixTagValues(const std::string & var_name, + const std::string & tag_name) const; + /** * Returns value of a coupled vector variable * @param var_name Name of coupled vector variable diff --git a/framework/src/auxkernels/TagMatrixAux.C b/framework/src/auxkernels/TagMatrixAux.C index c2805f4204ed..51e7bf81f0c5 100644 --- a/framework/src/auxkernels/TagMatrixAux.C +++ b/framework/src/auxkernels/TagMatrixAux.C @@ -17,7 +17,7 @@ InputParameters TagMatrixAux::validParams() { InputParameters params = AuxKernel::validParams(); - params.addParam("matrix_tag", "TagName", "Tag Name this Aux works on"); + params.addParam("matrix_tag", "TagName", "Tag Name this Aux works on"); params.addRequiredCoupledVar("v", "The coupled variable whose components are coupled to AuxVariable"); params.set("execute_on", true) = {EXEC_TIMESTEP_END}; @@ -27,9 +27,7 @@ TagMatrixAux::validParams() } TagMatrixAux::TagMatrixAux(const InputParameters & parameters) - : AuxKernel(parameters), - _tag_id(_subproblem.getMatrixTagID(getParam("matrix_tag"))), - _v(coupledMatrixTagValue("v", _tag_id)) + : AuxKernel(parameters), _v(coupledMatrixTagValue("v", "matrix_tag")) { auto & execute_on = getParam("execute_on"); if (execute_on.size() != 1 || !execute_on.contains(EXEC_TIMESTEP_END)) diff --git a/framework/src/auxkernels/TagVectorAux.C b/framework/src/auxkernels/TagVectorAux.C index 0df1d9d9c031..de36a9dd805c 100644 --- a/framework/src/auxkernels/TagVectorAux.C +++ b/framework/src/auxkernels/TagVectorAux.C @@ -18,7 +18,7 @@ TagVectorAux::validParams() { InputParameters params = AuxKernel::validParams(); - params.addRequiredParam("vector_tag", "Tag Name this Aux works on"); + params.addRequiredParam("vector_tag", "Tag Name this Aux works on"); params.addRequiredCoupledVar("v", "The coupled variable whose components are coupled to AuxVariable"); params.set("execute_on", true) = {EXEC_TIMESTEP_END}; @@ -28,9 +28,7 @@ TagVectorAux::validParams() } TagVectorAux::TagVectorAux(const InputParameters & parameters) - : AuxKernel(parameters), - _tag_id(_subproblem.getVectorTagID(getParam("vector_tag"))), - _v(coupledVectorTagValue("v", _tag_id)) + : AuxKernel(parameters), _v(coupledVectorTagValue("v", "vector_tag")) { auto & execute_on = getParam("execute_on"); if (execute_on.size() != 1 || !execute_on.contains(EXEC_TIMESTEP_END)) diff --git a/framework/src/interfaces/Coupleable.C b/framework/src/interfaces/Coupleable.C index d7335203eabf..0e6d3d5daea1 100644 --- a/framework/src/interfaces/Coupleable.C +++ b/framework/src/interfaces/Coupleable.C @@ -492,6 +492,25 @@ Coupleable::coupledVectorTagValue(const std::string & var_name, TagID tag, unsig return var->vectorTagValue(tag); } +const VariableValue & +Coupleable::coupledVectorTagValue(const std::string & var_name, + const std::string & tag_name, + unsigned int comp) const +{ + if (!_c_parameters.isParamValid(tag_name)) + mooseError("Tag name parameter '", tag_name, "' is invalid"); + + TagName tagname = _c_parameters.get(tag_name); + if (tagname == Moose::SOLUTION_TAG) + return coupledValue(var_name, comp); + + if (!_c_fe_problem.vectorTagExists(tagname)) + mooseError("Tagged vector with tag name '", tagname, "' does not exist"); + + TagID tag = _c_fe_problem.getVectorTagID(tagname); + return coupledVectorTagValue(var_name, tag, comp); +} + const VariableGradient & Coupleable::coupledVectorTagGradient(const std::string & var_name, TagID tag, @@ -514,6 +533,25 @@ Coupleable::coupledVectorTagGradient(const std::string & var_name, return var->vectorTagGradient(tag); } +const VariableGradient & +Coupleable::coupledVectorTagGradient(const std::string & var_name, + const std::string & tag_name, + unsigned int comp) const +{ + if (!_c_parameters.isParamValid(tag_name)) + mooseError("Tag name parameter '", tag_name, "' is invalid"); + + TagName tagname = _c_parameters.get(tag_name); + if (tagname == Moose::SOLUTION_TAG) + return coupledGradient(var_name, comp); + + if (!_c_fe_problem.vectorTagExists(tagname)) + mooseError("Tagged vector with tag name '", tagname, "' does not exist"); + + TagID tag = _c_fe_problem.getVectorTagID(tagname); + return coupledVectorTagGradient(var_name, tag, comp); +} + const VariableValue & Coupleable::coupledVectorTagDofValue(const std::string & var_name, TagID tag, @@ -529,6 +567,25 @@ Coupleable::coupledVectorTagDofValue(const std::string & var_name, return var->vectorTagDofValue(tag); } +const VariableValue & +Coupleable::coupledVectorTagDofValue(const std::string & var_name, + const std::string & tag_name, + unsigned int comp) const +{ + if (!_c_parameters.isParamValid(tag_name)) + mooseError("Tag name parameter '", tag_name, "' is invalid"); + + TagName tagname = _c_parameters.get(tag_name); + if (tagname == Moose::SOLUTION_TAG) + return coupledDofValues(var_name, comp); + + if (!_c_fe_problem.vectorTagExists(tagname)) + mooseError("Tagged vector with tag name '", tagname, "' does not exist"); + + TagID tag = _c_fe_problem.getVectorTagID(tagname); + return coupledVectorTagDofValue(var_name, tag, comp); +} + const VariableValue & Coupleable::coupledMatrixTagValue(const std::string & var_name, TagID tag, unsigned int comp) const { @@ -544,6 +601,22 @@ Coupleable::coupledMatrixTagValue(const std::string & var_name, TagID tag, unsig return var->matrixTagValue(tag); } +const VariableValue & +Coupleable::coupledMatrixTagValue(const std::string & var_name, + const std::string & tag_name, + unsigned int comp) const +{ + if (!_c_parameters.isParamValid(tag_name)) + mooseError("Tag name parameter '", tag_name, "' is invalid"); + + TagName tagname = _c_parameters.get(tag_name); + if (!_c_fe_problem.matrixTagExists(tagname)) + mooseError("Matrix tag name '", tagname, "' does not exist"); + + TagID tag = _c_fe_problem.getMatrixTagID(tagname); + return coupledMatrixTagValue(var_name, tag, comp); +} + const VectorVariableValue & Coupleable::coupledVectorValue(const std::string & var_name, unsigned int comp) const { @@ -1951,6 +2024,23 @@ Coupleable::coupledVectorTagValues(const std::string & var_name, TagID tag) cons return coupledVectorHelper(var_name, func); } +std::vector +Coupleable::coupledVectorTagValues(const std::string & var_name, const std::string & tag_name) const +{ + if (!_c_parameters.isParamValid(tag_name)) + mooseError("Tag name parameter '", tag_name, "' is invalid"); + + TagName tagname = _c_parameters.get(tag_name); + if (tagname == Moose::SOLUTION_TAG) + return coupledValues(var_name); + + if (!_c_fe_problem.vectorTagExists(tagname)) + mooseError("Tagged vector with tag name '", tagname, "' does not exist"); + + TagID tag = _c_fe_problem.getVectorTagID(tagname); + return coupledVectorTagValues(var_name, tag); +} + std::vector Coupleable::coupledVectorTagGradients(const std::string & var_name, TagID tag) const { @@ -1960,6 +2050,24 @@ Coupleable::coupledVectorTagGradients(const std::string & var_name, TagID tag) c return coupledVectorHelper(var_name, func); } +std::vector +Coupleable::coupledVectorTagGradients(const std::string & var_name, + const std::string & tag_name) const +{ + if (!_c_parameters.isParamValid(tag_name)) + mooseError("Tag name parameter '", tag_name, "' is invalid"); + + TagName tagname = _c_parameters.get(tag_name); + if (tagname == Moose::SOLUTION_TAG) + return coupledGradients(var_name); + + if (!_c_fe_problem.vectorTagExists(tagname)) + mooseError("Tagged vector with tag name '", tagname, "' does not exist"); + + TagID tag = _c_fe_problem.getVectorTagID(tagname); + return coupledVectorTagGradients(var_name, tag); +} + std::vector Coupleable::coupledVectorTagDofValues(const std::string & var_name, TagID tag) const { @@ -1969,6 +2077,24 @@ Coupleable::coupledVectorTagDofValues(const std::string & var_name, TagID tag) c return coupledVectorHelper(var_name, func); } +std::vector +Coupleable::coupledVectorTagDofValues(const std::string & var_name, + const std::string & tag_name) const +{ + if (!_c_parameters.isParamValid(tag_name)) + mooseError("Tag name parameter '", tag_name, "' is invalid"); + + TagName tagname = _c_parameters.get(tag_name); + if (tagname == Moose::SOLUTION_TAG) + return coupledAllDofValues(var_name); + + if (!_c_fe_problem.vectorTagExists(tagname)) + mooseError("Tagged vector with tag name '", tagname, "' does not exist"); + + TagID tag = _c_fe_problem.getVectorTagID(tagname); + return coupledVectorTagDofValues(var_name, tag); +} + std::vector Coupleable::coupledMatrixTagValues(const std::string & var_name, TagID tag) const { @@ -1978,6 +2104,20 @@ Coupleable::coupledMatrixTagValues(const std::string & var_name, TagID tag) cons return coupledVectorHelper(var_name, func); } +std::vector +Coupleable::coupledMatrixTagValues(const std::string & var_name, const std::string & tag_name) const +{ + if (!_c_parameters.isParamValid(tag_name)) + mooseError("Tag name parameter '", tag_name, "' is invalid"); + + TagName tagname = _c_parameters.get(tag_name); + if (!_c_fe_problem.matrixTagExists(tagname)) + mooseError("Matrix tag name '", tagname, "' does not exist"); + + TagID tag = _c_fe_problem.getMatrixTagID(tagname); + return coupledMatrixTagValues(var_name, tag); +} + std::vector Coupleable::coupledValuesOld(const std::string & var_name) const {