https://mooseframework.inl.gov
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 
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()),
32  TransientInterface(this),
33  ElementIDInterface(this),
34  _mesh(_subproblem.mesh()),
35  _q_point(_assembly.qPointsFace()),
36  _qrule(_assembly.qRuleFace()),
37  _JxW(_assembly.JxWFace()),
38  _coord(_assembly.coordTransformation()),
39  _normals(_assembly.normals()),
40  _current_elem(_assembly.elem()),
41  _current_side(_assembly.side()),
42  _current_side_elem(_assembly.sideElem()),
43  _current_side_volume(_assembly.sideElemVolume()),
44  _current_boundary_id(_assembly.currentBoundaryID())
45 {
46 }
47 
48 void
50 {
51  _face_infos.clear();
52 
53  // Either the element or the (active) neighbor is a valid argument to get a face info
54  const Elem * side_neighbor = _current_elem->neighbor_ptr(_current_side);
55 
56  mooseAssert(_current_elem, "We should have an element");
57  mooseAssert(_current_elem->active(), "The current element should be active");
58 
59  // No neighbor means we are at a boundary, a FaceInfo exists in the mesh
60  if (side_neighbor)
61  {
62  std::vector<const Elem *> candidate_neighbors = {side_neighbor};
63 
64  // neighbor is not active, we have to seek its refined children to get a FaceInfo
65  if (!side_neighbor->active())
66  side_neighbor->active_family_tree_by_neighbor(candidate_neighbors, _current_elem);
67 
68  for (const Elem * neighbor : candidate_neighbors)
69  {
70  const Elem * element = _current_elem;
71  auto side = _current_side;
72 
73  // If a neighbor exists, the face info may only be defined on the other side
74  // First check refinement level
75  if (_current_elem->level() < neighbor->level())
76  {
77  element = neighbor;
78  side = neighbor->which_neighbor_am_i(_current_elem);
79  }
80  // Then check ids
81  else if ((_current_elem->level() == neighbor->level()) &&
82  (_current_elem->id() > neighbor->id()))
83  {
84  element = neighbor;
85  side = neighbor->which_neighbor_am_i(_current_elem);
86  }
87  const auto fi = _mesh.faceInfo(element, side);
88  mooseAssert(fi, "Face info must not be null.");
89  _face_infos.push_back(fi);
90  }
91  }
92  else
93  {
94  const auto fi = _mesh.faceInfo(_current_elem, _current_side);
95  mooseAssert(fi, "Face info must not be null.");
96  _face_infos.push_back(fi);
97  }
98 }
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:2173
void getFaceInfos()
Computes the local FaceInfo(s) to use in functor arguments and interpolations.
const std::set< SubdomainID > EMPTY_BLOCK_IDS
Definition: MooseTypes.h:683
MooseMesh & _mesh
An interface for accessing Materials.
Intermediate base class that ties together all the interfaces for getting MooseVariableFEBases with t...
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:40
static InputParameters validParams()
Definition: UserObject.C:18