www.mooseframework.org
SideUserObject.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
17 {
21  params.addRelationshipManager("GhostLowerDElems",
24  return params;
25 }
26 
28  : UserObject(parameters),
29  BoundaryRestrictableRequired(this, false), // false for applying to sidesets
30  MaterialPropertyInterface(this, Moose::EMPTY_BLOCK_IDS, boundaryIDs()),
31  Coupleable(this, false),
33  TransientInterface(this),
34  ElementIDInterface(this),
35  _mesh(_subproblem.mesh()),
36  _q_point(_assembly.qPointsFace()),
37  _qrule(_assembly.qRuleFace()),
38  _JxW(_assembly.JxWFace()),
39  _coord(_assembly.coordTransformation()),
40  _normals(_assembly.normals()),
41  _current_elem(_assembly.elem()),
42  _current_side(_assembly.side()),
43  _current_side_elem(_assembly.sideElem()),
44  _current_side_volume(_assembly.sideElemVolume()),
45  _current_boundary_id(_assembly.currentBoundaryID())
46 {
47  // Keep track of which variables are coupled so we know what we depend on
48  const std::vector<MooseVariableFEBase *> & coupled_vars = getCoupledMooseVars();
49  for (const auto & var : coupled_vars)
51 }
52 
53 void
55 {
56  _face_infos.clear();
57 
58  // Either the element or the (active) neighbor is a valid argument to get a face info
59  const Elem * side_neighbor = _current_elem->neighbor_ptr(_current_side);
60 
61  mooseAssert(_current_elem, "We should have an element");
62  mooseAssert(_current_elem->active(), "The current element should be active");
63 
64  // No neighbor means we are at a boundary, a FaceInfo exists in the mesh
65  if (side_neighbor)
66  {
67  std::vector<const Elem *> candidate_neighbors = {side_neighbor};
68 
69  // neighbor is not active, we have to seek its refined children to get a FaceInfo
70  if (!side_neighbor->active())
71  side_neighbor->active_family_tree_by_neighbor(candidate_neighbors, _current_elem);
72 
73  for (const Elem * neighbor : candidate_neighbors)
74  {
75  const Elem * element = _current_elem;
76  auto side = _current_side;
77 
78  // If a neighbor exists, the face info may only be defined on the other side
79  // First check refinement level
80  if (_current_elem->level() < neighbor->level())
81  {
82  element = neighbor;
83  side = neighbor->which_neighbor_am_i(_current_elem);
84  }
85  // Then check ids
86  else if ((_current_elem->level() == neighbor->level()) &&
87  (_current_elem->id() > neighbor->id()))
88  {
89  element = neighbor;
90  side = neighbor->which_neighbor_am_i(_current_elem);
91  }
92  const auto fi = _mesh.faceInfo(element, side);
93  mooseAssert(fi, "Face info must not be null.");
94  _face_infos.push_back(fi);
95  }
96  }
97  else
98  {
99  const auto fi = _mesh.faceInfo(_current_elem, _current_side);
100  mooseAssert(fi, "Face info must not be null.");
101  _face_infos.push_back(fi);
102  }
103 }
static InputParameters validParams()
A class for requiring an object to be boundary restricted.
const unsigned int & _current_side
current side of the current element
SideUserObject(const InputParameters &parameters)
MeshBase & mesh
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
static InputParameters validParams()
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.
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.
const std::vector< const FaceInfo * > & faceInfo() const
Accessor for local FaceInfo objects.
Definition: MooseMesh.h:2108
void getFaceInfos()
Computes the local FaceInfo(s) to use in functor arguments and interpolations.
const std::vector< MooseVariableFieldBase * > & getCoupledMooseVars() const
Get the list of all coupled variables.
Definition: Coupleable.h:70
Interface for objects that needs coupling capabilities.
Definition: Coupleable.h:45
void addMooseVariableDependency(MooseVariableFieldBase *var)
Call this function to add the passed in MooseVariableFieldBase as a variable that this object depends...
const std::set< SubdomainID > EMPTY_BLOCK_IDS
Definition: MooseTypes.h:596
MooseMesh & _mesh
An interface for accessing Materials.
const Elem *const & _current_elem
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
Base class for user-specific data.
Definition: UserObject.h:39
static InputParameters validParams()
Definition: UserObject.C:18