www.mooseframework.org
NearestNodeValueAux.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #include "NearestNodeValueAux.h"
16 
17 #include "SystemBase.h"
18 #include "NearestNodeLocator.h"
19 
20 template <>
23 {
25  params.addClassDescription("Retrieves a field value from the closest node on the paired boundary "
26  "and stores it on this boundary or block.");
27  params.set<bool>("_dual_restrictable") = true;
28  params.addRequiredParam<BoundaryName>("paired_boundary", "The boundary to get the value from.");
29  params.addRequiredCoupledVar("paired_variable", "The variable to get the value of.");
30  params.set<bool>("use_displaced_mesh") = true;
31  return params;
32 }
33 
35  : AuxKernel(parameters),
36  _nearest_node(
37  getNearestNodeLocator(parameters.get<BoundaryName>("paired_boundary"), boundaryNames()[0])),
38  _serialized_solution(_nl_sys.currentSolution()),
39  _paired_variable(coupled("paired_variable"))
40 {
41  if (boundaryNames().size() > 1)
42  mooseError("NearestNodeValueAux can only be used with one boundary at a time!");
43 }
44 
45 Real
47 {
48  // Assumes the variable you are coupling to is from the nonlinear system for now.
49  const Node * nearest = _nearest_node.nearestNode(_current_node->id());
50  mooseAssert(nearest != NULL, "I do not have the nearest node for you");
51  dof_id_type dof_number = nearest->dof_number(_nl_sys.number(), _paired_variable, 0);
52 
53  return (*_serialized_solution)(dof_number);
54 }
const NumericVector< Number > *& _serialized_solution
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
SystemBase & _nl_sys
Definition: AuxKernel.h:141
const std::vector< BoundaryName > & boundaryNames() const
Return the boundary names for this object.
InputParameters validParams< AuxKernel >()
Definition: AuxKernel.C:30
const Node *& _current_node
Current node (valid only for nodal kernels)
Definition: AuxKernel.h:186
NearestNodeLocator & _nearest_node
Base class for creating new auxiliary kernels and auxiliary boundary conditions.
Definition: AuxKernel.h:51
virtual Real computeValue() override
NearestNodeValueAux(const InputParameters &parameters)
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
virtual unsigned int number()
Gets the number of this system.
Definition: SystemBase.C:604
const Node * nearestNode(dof_id_type node_id)
Valid to call this after findNodes() has been called to get a pointer to the nearest node...
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
void mooseError(Args &&...args) const
Definition: MooseObject.h:80
unsigned int _paired_variable
InputParameters validParams< NearestNodeValueAux >()