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 _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
67template <typename ComputeValueType>
68void
70{
72
73 std::array<const MortarNodalAuxKernelTempl<ComputeValueType> *, 1> consumers = {{this}};
74
76 _fe_problem,
77 amg(),
78 _tid,
79 _secondary_ip_sub_to_mats,
80 _primary_ip_sub_to_mats,
81 _secondary_boundary_mats);
82}
83
84template <typename ComputeValueType>
85void
87{
88 if (!_var.isNodalDefined())
89 return;
90
91 ComputeValueType value(0);
92 Real total_volume = 0;
93
94 const auto & its = amg().secondariesToMortarSegments(*_current_node);
95
96 auto act_functor = [&value, &total_volume, this]()
97 {
98 _msm_volume = 0;
99 setNormals();
100 value += computeValue();
101 total_volume += _msm_volume;
102 };
103
104 std::array<MortarNodalAuxKernelTempl<ComputeValueType> *, 1> consumers = {{this}};
105
107 _assembly,
108 _subproblem,
109 _fe_problem,
110 amg(),
111 _displaced,
112 consumers,
113 _tid,
114 _secondary_ip_sub_to_mats,
115 _primary_ip_sub_to_mats,
116 _secondary_boundary_mats,
117 act_functor,
118 /*reinit_mortar_user_objects=*/false);
119
120 // We have to reinit the node for this variable in order to get the dof index set for the node
121 _var.reinitNode();
122
123 // If the node doesn't have corresponding mortar segments, force the value assigned in this step
124 // to be zero. This can be useful when nodes initially do not project but will project at a
125 // different stage of the simulation
126
127 if (MooseUtils::relativeFuzzyEqual(total_volume, 0.0))
128 value = 0;
129 else
130 value /= total_volume;
131
132 // Allow mortar auxiliary kernels to compute quantities incrementally
133 if (!_incremental)
134 _var.setNodalValue(value);
135 else
136 {
137 mooseAssert(_u_old.size() == 1,
138 "Expected 1 value in MortarNodalAuxKernel, but got " << _u_old.size());
139 _var.setNodalValue(value + _u_old[0]);
140 }
141}
142
143template <typename ComputeValueType>
144void
146{
148 "not clear where this should be implemented in the compute loop. If you want to implement "
149 "this function, please contact a MOOSE developer and tell them your use case");
150}
151
152// 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
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()
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 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...