https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
11#include "MooseVariableField.h"
12#include "MortarUtils.h"
13#include "MooseUtils.h"
15#include "libmesh/quadrature.h"
16
17namespace
18{
19const InputParameters &
20setBoundaryParam(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
29template <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
49template <typename ComputeValueType>
51 const InputParameters & parameters)
52 : AuxKernelTempl<ComputeValueType>(setBoundaryParam(parameters)),
54 *parameters.getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")),
56 _displaced(this->template getParam<bool>("use_displaced_mesh")),
57 _fe_problem(*this->template getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")),
58 _msm_volume(0),
59 _incremental(this->template getParam<bool>("incremental")),
60 _u_old(uOld()),
61 _test_lower(_var.phiLower()),
62 _coord_msm(_assembly.mortarCoordTransformation())
63{
64 if (!isNodal())
65 paramError("variable",
66 "MortarNodalAuxKernel derived classes populate nodal aux variables only.");
67}
68
69template <typename ComputeValueType>
70void
77
78template <typename ComputeValueType>
79void
81{
82 std::array<const MortarNodalAuxKernelTempl<ComputeValueType> *, 1> consumers = {{this}};
83
85 _fe_problem,
86 amg(),
87 _tid,
88 _secondary_ip_sub_to_mats,
89 _primary_ip_sub_to_mats,
90 _secondary_boundary_mats);
91}
92
93template <typename ComputeValueType>
94void
96{
97 // We may be registered with a warehouse that owns multiple interfaces; only react to the one
98 // we actually consume.
99 if (&amg_in == &amg())
100 setupMortarMaterials();
101}
102
103template <typename ComputeValueType>
104void
106{
107 if (!_var.isNodalDefined())
108 return;
109
110 ComputeValueType value(0);
111 Real total_volume = 0;
112
113 const auto & its = amg().secondariesToMortarSegments(*_current_node);
114
115 auto act_functor = [&value, &total_volume, this]()
116 {
117 _msm_volume = 0;
118 setNormals();
119 value += computeValue();
120 total_volume += _msm_volume;
121 };
122
123 std::array<MortarNodalAuxKernelTempl<ComputeValueType> *, 1> consumers = {{this}};
124
126 _assembly,
127 _subproblem,
128 _fe_problem,
129 amg(),
130 _displaced,
131 consumers,
132 _tid,
133 _secondary_ip_sub_to_mats,
134 _primary_ip_sub_to_mats,
135 _secondary_boundary_mats,
136 act_functor,
137 /*reinit_mortar_user_objects=*/false);
138
139 // We have to reinit the node for this variable in order to get the dof index set for the node
140 _var.reinitNode();
141
142 // If the node doesn't have corresponding mortar segments, force the value assigned in this step
143 // to be zero. This can be useful when nodes initially do not project but will project at a
144 // different stage of the simulation
145
146 if (MooseUtils::relativeFuzzyEqual(total_volume, 0.0))
147 value = 0;
148 else
149 value /= total_volume;
150
151 // Allow mortar auxiliary kernels to compute quantities incrementally
152 if (!_incremental)
153 _var.setNodalValue(value);
154 else
155 {
156 mooseAssert(_u_old.size() == 1,
157 "Expected 1 value in MortarNodalAuxKernel, but got " << _u_old.size());
158 _var.setNodalValue(value + _u_old[0]);
159 }
160}
161
162template <typename ComputeValueType>
163void
165{
167 "not clear where this should be implemented in the compute loop. If you want to implement "
168 "this function, please contact a MOOSE developer and tell them your use case");
169}
170
171// Explicitly instantiates the two versions of the MortarNodalAuxKernelTempl class
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
This class is a container/interface for the objects involved in automatic generation of mortar spaces...
virtual 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 auxiliary kernels and auxiliary boundary conditions.
Definition AuxKernel.h:28
bool isNodal() const
Nodal or elemental kernel?
Definition AuxKernel.h:43
static InputParameters validParams()
Definition AuxKernel.C:27
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void suppressParameter(const std::string &name)
This method suppresses an inherited parameter so that it isn't required or valid in the derived class...
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.
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.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
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:457
An interface for accessing mortar mesh data.
static InputParameters validParams()
Interface for objects that need to be notified when the mortar segment mesh for an interface they con...
Base class for creating new nodally-based mortar auxiliary kernels.
void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job.
void precalculateValue() override final
This callback is used for AuxKernelTempls that need to perform a per-element calculation.
void compute() override
Computes the value and stores it in the solution vector.
static InputParameters validParams()
void setupMortarMaterials()
(Re)builds the material containers required by this mortar auxiliary kernel for the mortar segment me...
void mortarSetup(const AutomaticMortarGeneration &amg) override
Called by the MortarInterfaceWarehouse whenever amg's mortar segment mesh coverage has changed,...
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:91
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...