https://mooseframework.inl.gov
MortarNodalAuxKernel.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "MortarNodalAuxKernel.h"
11 #include "MooseVariableField.h"
12 #include "MortarUtils.h"
13 #include "MooseUtils.h"
15 #include "libmesh/quadrature.h"
16 
17 namespace
18 {
19 const InputParameters &
20 setBoundaryParam(const InputParameters & params_in)
21 {
22  InputParameters & ret = const_cast<InputParameters &>(params_in);
23  ret.set<std::vector<BoundaryName>>("boundary") = {
24  params_in.get<BoundaryName>("secondary_boundary")};
25  return ret;
26 }
27 }
28 
29 template <typename ComputeValueType>
32 {
35  params.set<bool>("ghost_point_neighbors") = true;
36  params.suppressParameter<std::vector<BoundaryName>>("boundary");
37  params.suppressParameter<std::vector<SubdomainName>>("block");
38  params.addParam<bool>(
39  "incremental", false, "Whether to accumulate mortar auxiliary kernel value");
40 
41  // We should probably default use_displaced_mesh to true. If no displaced mesh exists
42  // FEProblemBase::addKernel will automatically correct it to false. However,
43  // this will still prompt a call from AugmentSparsityOnInterface to get a displaced
44  // mortar interface since object._use_displaced_mesh = true.
45 
46  return params;
47 }
48 
49 template <typename ComputeValueType>
51  const InputParameters & parameters)
52  : AuxKernelTempl<ComputeValueType>(setBoundaryParam(parameters)),
54  _displaced(this->template getParam<bool>("use_displaced_mesh")),
55  _fe_problem(*this->template getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")),
56  _msm_volume(0),
57  _incremental(this->template getParam<bool>("incremental")),
58  _u_old(uOld()),
59  _test_lower(_var.phiLower()),
60  _coord_msm(_assembly.mortarCoordTransformation())
61 {
62  if (!isNodal())
63  paramError("variable",
64  "MortarNodalAuxKernel derived classes populate nodal aux variables only.");
65 }
66 
67 template <typename ComputeValueType>
68 void
70 {
71  std::array<const MortarNodalAuxKernelTempl<ComputeValueType> *, 1> consumers = {{this}};
72 
74  _fe_problem,
75  amg(),
76  _tid,
77  _secondary_ip_sub_to_mats,
78  _primary_ip_sub_to_mats,
79  _secondary_boundary_mats);
80 }
81 
82 template <typename ComputeValueType>
83 void
85 {
86  if (!_var.isNodalDefined())
87  return;
88 
89  ComputeValueType value(0);
90  Real total_volume = 0;
91 
92  const auto & its = amg().secondariesToMortarSegments(*_current_node);
93 
94  auto act_functor = [&value, &total_volume, this]()
95  {
96  _msm_volume = 0;
97  setNormals();
98  value += computeValue();
99  total_volume += _msm_volume;
100  };
101 
102  std::array<MortarNodalAuxKernelTempl<ComputeValueType> *, 1> consumers = {{this}};
103 
105  _assembly,
106  _subproblem,
107  _fe_problem,
108  amg(),
109  _displaced,
110  consumers,
111  _tid,
112  _secondary_ip_sub_to_mats,
113  _primary_ip_sub_to_mats,
114  _secondary_boundary_mats,
115  act_functor,
116  /*reinit_mortar_user_objects=*/false);
117 
118  // We have to reinit the node for this variable in order to get the dof index set for the node
119  _var.reinitNode();
120 
121  // If the node doesn't have corresponding mortar segments, force the value assigned in this step
122  // to be zero. This can be useful when nodes initially do not project but will project at a
123  // different stage of the simulation
124 
125  if (MooseUtils::relativeFuzzyEqual(total_volume, 0.0))
126  value = 0;
127  else
128  value /= total_volume;
129 
130  // Allow mortar auxiliary kernels to compute quantities incrementally
131  if (!_incremental)
132  _var.setNodalValue(value);
133  else
134  {
135  mooseAssert(_u_old.size() == 1,
136  "Expected 1 value in MortarNodalAuxKernel, but got " << _u_old.size());
137  _var.setNodalValue(value + _u_old[0]);
138  }
139 }
140 
141 template <typename ComputeValueType>
142 void
144 {
145  mooseError(
146  "not clear where this should be implemented in the compute loop. If you want to implement "
147  "this function, please contact a MOOSE developer and tell them your use case");
148 }
149 
150 // Explicitly instantiates the two versions of the MortarNodalAuxKernelTempl class
151 template class MortarNodalAuxKernelTempl<Real>;
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
Definition: MooseBase.h:439
void precalculateValue() override final
This callback is used for AuxKernelTempls that need to perform a per-element calculation.
void setupMortarMaterials(const Consumers &consumers, FEProblemBase &fe_problem, const AutomaticMortarGeneration &amg, const THREAD_ID tid, std::map< SubdomainID, std::deque< MaterialBase *>> &secondary_ip_sub_to_mats, std::map< SubdomainID, std::deque< MaterialBase *>> &primary_ip_sub_to_mats, std::deque< MaterialBase *> &secondary_boundary_mats)
This function creates containers of materials necessary to execute the mortar method for a supplied s...
Definition: MortarUtils.h:317
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
void compute() override
Computes the value and stores it in the solution vector.
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
static InputParameters validParams()
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...
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
An interface for accessing mortar mesh data.
MortarNodalAuxKernelTempl(const InputParameters &parameters)
void suppressParameter(const std::string &name)
This method suppresses an inherited parameter so that it isn&#39;t required or valid in the derived class...
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job...
Base class for creating new nodally-based mortar auxiliary kernels.
void loopOverMortarSegments(const Iterators &secondary_elems_to_mortar_segments, Assembly &assembly, SubProblem &subproblem, FEProblemBase &fe_problem, const AutomaticMortarGeneration &amg, const bool displaced, const Consumers &consumers, const THREAD_ID tid, const std::map< SubdomainID, std::deque< MaterialBase *>> &secondary_ip_sub_to_mats, const std::map< SubdomainID, std::deque< MaterialBase *>> &primary_ip_sub_to_mats, const std::deque< MaterialBase *> &secondary_boundary_mats, const ActionFunctor act, const bool reinit_mortar_user_objects)
This method will loop over pairs of secondary elements and their corresponding mortar segments...
Definition: MortarUtils.h:70
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static InputParameters validParams()
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
static InputParameters validParams()
Definition: AuxKernel.C:27
Base class for creating new auxiliary kernels and auxiliary boundary conditions.
Definition: AuxKernel.h:17
bool isNodal() const
Nodal or elemental kernel?
Definition: AuxKernel.h:43