www.mooseframework.org
InternalSideUserObject.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 "InternalSideUserObject.h"
11 #include "Assembly.h"
12 
15 {
20 
21  // Need one layer of ghosting
22  params.addRelationshipManager("ElementSideNeighborLayers",
25 
26  return params;
27 }
28 
30  : UserObject(parameters),
31  BlockRestrictable(this),
33  NeighborCoupleable(this, false, false),
35  TransientInterface(this),
36  ElementIDInterface(this),
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_elem_volume(_assembly.elemVolume()),
45  _current_side(_assembly.side()),
46  _current_side_elem(_assembly.sideElem()),
47  _current_side_volume(_assembly.sideElemVolume()),
48  _neighbor_elem(_assembly.neighbor()),
49  _current_neighbor_volume(_assembly.neighborVolume())
50 {
51  // Keep track of which variables are coupled so we know what we depend on
52  const std::vector<MooseVariableFEBase *> & coupled_vars = getCoupledMooseVars();
53  for (const auto & var : coupled_vars)
55 }
56 
57 const Real &
59 {
60  return _assembly.neighborVolume();
61 }
62 
63 void
65 {
66  _face_infos.clear();
67 
68  // Either the element or the (active) neighbor is a valid argument to get a face info
69  const Elem * side_neighbor = _current_elem->neighbor_ptr(_current_side);
70 
71  mooseAssert(_current_elem, "We should have an element");
72  mooseAssert(_current_elem->active(), "The current element should be active");
73 
74  // No neighbor means we are at a boundary, a FaceInfo exists in the mesh
75  if (side_neighbor)
76  {
77  std::vector<const Elem *> candidate_neighbors = {side_neighbor};
78 
79  // neighbor is not active, we have to seek its refined children to get a FaceInfo
80  if (!side_neighbor->active())
81  side_neighbor->active_family_tree_by_neighbor(candidate_neighbors, _current_elem);
82 
83  for (const Elem * neighbor : candidate_neighbors)
84  {
85  const Elem * element = _current_elem;
86  auto side = _current_side;
87 
88  // If a neighbor exists, the face info may only be defined on the other side
89  // First check refinement level
90  if (_current_elem->level() < neighbor->level())
91  {
92  element = neighbor;
93  side = neighbor->which_neighbor_am_i(_current_elem);
94  }
95  // Then check ids
96  else if ((_current_elem->level() == neighbor->level()) &&
97  (_current_elem->id() > neighbor->id()))
98  {
99  element = neighbor;
100  side = neighbor->which_neighbor_am_i(_current_elem);
101  }
102  const auto fi = _mesh.faceInfo(element, side);
103  mooseAssert(fi, "Face info must not be null.");
104  _face_infos.push_back(fi);
105  }
106  }
107  else
108  {
109  const auto fi = _mesh.faceInfo(_current_elem, _current_side);
110  mooseAssert(fi, "Face info must not be null.");
111  _face_infos.push_back(fi);
112  }
113 }
const Real & neighborVolume()
Returns the reference to the current neighbor volume.
Definition: Assembly.h:461
const unsigned int & _current_side
current side of the current element
const Real & getNeighborElemVolume()
The volume (or length) of the current neighbor.
void getFaceInfos()
Computes the local FaceInfo(s) to use in functor arguments and interpolations.
Assembly & _assembly
Definition: UserObject.h:218
static InputParameters validParams()
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.
static InputParameters validParams()
Interface for objects that needs transient capabilities.
const std::vector< const FaceInfo * > & faceInfo() const
Accessor for local FaceInfo objects.
Definition: MooseMesh.h:2108
InternalSideUserObject(const InputParameters &parameters)
const Elem *const & _current_elem
pointer to the current element object
const std::vector< MooseVariableFieldBase * > & getCoupledMooseVars() const
Get the list of all coupled variables.
Definition: Coupleable.h:70
void addMooseVariableDependency(MooseVariableFieldBase *var)
Call this function to add the passed in MooseVariableFieldBase as a variable that this object depends...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const std::set< BoundaryID > EMPTY_BOUNDARY_IDS
Definition: MooseTypes.h:597
std::vector< const FaceInfo * > _face_infos
Holds the FaceInfos to loop on to consider all active neighbors of an element on a given side...
An interface that restricts an object to subdomains via the &#39;blocks&#39; input parameter.
This interface is designed for DGKernel, InternalSideUserObject, InterfaceUserObject, where material properties on a side of both its primary side (face) and its secondary side (neighbor) all required.
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
Enhances Coupleable interface to also couple the values from neighbor elements.
static InputParameters validParams()
Definition: UserObject.C:18