https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SideUserObject.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 "SideUserObject.h"
11#include "SubProblem.h"
12#include "MooseTypes.h"
13#include "Assembly.h"
14#include "FEProblemBase.h"
15#include "MaterialBase.h"
16#include "MaterialWarehouse.h"
17
29
31 : UserObject(parameters),
32 BoundaryRestrictableRequired(this, false), // false for applying to sidesets
33 MaterialPropertyInterface(this, Moose::EMPTY_BLOCK_IDS, boundaryIDs()),
37 _mesh(_subproblem.mesh()),
38 _q_point(_assembly.qPointsFace()),
39 _qrule(_assembly.qRuleFace()),
40 _JxW(_assembly.JxWFace()),
41 _coord(_assembly.coordTransformation()),
42 _normals(_assembly.normals()),
43 _current_elem(_assembly.elem()),
44 _current_side(_assembly.side()),
45 _current_side_elem(_assembly.sideElem()),
46 _current_side_volume(_assembly.sideElemVolume()),
47 _current_boundary_id(_assembly.currentBoundaryID())
48{
49}
50
51void
59
60void
62{
63 const auto & consumed_props = getMatPropDependencies();
64 if (consumed_props.empty())
65 return;
66
67 const auto & interface_materials = _fe_problem.getInterfaceMaterialsWarehouse();
68 const auto & registry = _fe_problem.getMaterialPropertyRegistry();
69
70 for (const auto bnd_id : boundaryIDs())
71 {
72 if (!interface_materials.hasActiveBoundaryObjects(bnd_id, _tid))
73 continue;
74
75 for (const auto & material : interface_materials.getActiveBoundaryObjects(bnd_id, _tid))
76 for (const auto supplied_prop : material->getSuppliedPropIDs())
77 if (consumed_props.count(supplied_prop))
78 paramError("boundary",
79 "Side user object '",
80 name(),
81 "' consumes material property '",
82 registry.getName(supplied_prop),
83 "', which is declared by interface material '",
84 material->name(),
85 "'. Side user objects do not execute in an interface material context; use a "
86 "class derived from InterfaceUserObject or InterfacePostprocessor for "
87 "interface quantities. Please refer to "
88 "https://github.com/idaholab/moose/pull/33168 for further context.");
89 }
90}
91
92void
94{
95 _face_infos.clear();
96
97 // Either the element or the (active) neighbor is a valid argument to get a face info
98 const Elem * side_neighbor = _current_elem->neighbor_ptr(_current_side);
99
100 mooseAssert(_current_elem, "We should have an element");
101 mooseAssert(_current_elem->active(), "The current element should be active");
102
103 // No neighbor means we are at a boundary, a FaceInfo exists in the mesh
104 if (side_neighbor)
105 {
106 std::vector<const Elem *> candidate_neighbors = {side_neighbor};
107
108 // neighbor is not active, we have to seek its refined children to get a FaceInfo
109 if (!side_neighbor->active())
110 side_neighbor->active_family_tree_by_neighbor(candidate_neighbors, _current_elem);
111
112 for (const Elem * neighbor : candidate_neighbors)
113 {
114 const Elem * element = _current_elem;
115 auto side = _current_side;
116
117 // If a neighbor exists, the face info may only be defined on the other side
118 // First check refinement level
119 if (_current_elem->level() < neighbor->level())
120 {
121 element = neighbor;
122 side = neighbor->which_neighbor_am_i(_current_elem);
123 }
124 // Then check ids
125 else if ((_current_elem->level() == neighbor->level()) &&
126 (_current_elem->id() > neighbor->id()))
127 {
128 element = neighbor;
129 side = neighbor->which_neighbor_am_i(_current_elem);
130 }
131 const auto fi = _mesh.faceInfo(element, side);
132 mooseAssert(fi, "Face info must not be null.");
133 _face_infos.push_back(fi);
134 }
135 }
136 else
137 {
138 const auto fi = _mesh.faceInfo(_current_elem, _current_side);
139 mooseAssert(fi, "Face info must not be null.");
140 _face_infos.push_back(fi);
141 }
142}
A class for requiring an object to be boundary restricted.
virtual const std::set< BoundaryID > & boundaryIDs() const
Return the boundary IDs for this object.
Intermediate base class that ties together all the interfaces for getting MooseVariableFEBases with t...
const MaterialWarehouse & getInterfaceMaterialsWarehouse() const
const MaterialPropertyRegistry & getMaterialPropertyRegistry() const
bool sideUOInterfaceMatPropIntegrityCheck() const
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addRelationshipManager(const std::string &name, Moose::RelationshipManagerType rm_type, Moose::RelationshipManagerInputParameterCallback input_parameter_callback=nullptr)
Tells MOOSE about a RelationshipManager that this object needs.
An interface for accessing Materials.
virtual const std::unordered_set< unsigned int > & getMatPropDependencies() const
Retrieve the set of material properties that this object depends on.
static InputParameters validParams()
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
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
const std::vector< const FaceInfo * > & faceInfo() const
Accessor for local FaceInfo objects.
Definition MooseMesh.h:2349
virtual void initialSetup()
Gets called at the beginning of the simulation before this object is asked to do its job.
const unsigned int & _current_side
current side of the current element
static InputParameters validParams()
MooseMesh & _mesh
void checkNoInterfaceMaterialPropertyDependencies() const
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job.
const Elem *const & _current_elem
SideUserObject(const InputParameters &parameters)
void getFaceInfos()
Computes the local FaceInfo(s) to use in functor arguments and interpolations.
std::vector< const FaceInfo * > _face_infos
Holds the FaceInfos to loop on to consider all active neighbors of an element on a given side.
Interface for objects that needs transient capabilities.
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.
const THREAD_ID _tid
Thread ID of this postprocessor.
Base class for user-specific data.
Definition UserObject.h:20
static InputParameters validParams()
Definition UserObject.C:14
MeshBase & mesh
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...