https://mooseframework.inl.gov
InternalSideUserObject.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 "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),
34  TransientInterface(this),
35  ElementIDInterface(this),
36  _mesh(_subproblem.mesh()),
37  _q_point(_assembly.qPointsFace()),
38  _qrule(_assembly.qRuleFace()),
39  _JxW(_assembly.JxWFace()),
40  _coord(_assembly.coordTransformation()),
41  _normals(_assembly.normals()),
42  _current_elem(_assembly.elem()),
43  _current_elem_volume(_assembly.elemVolume()),
44  _current_side(_assembly.side()),
45  _current_side_elem(_assembly.sideElem()),
46  _current_side_volume(_assembly.sideElemVolume()),
47  _neighbor_elem(_assembly.neighbor()),
48  _current_neighbor_volume(_assembly.neighborVolume())
49 {
50 }
51 
52 const Real &
54 {
55  return _assembly.neighborVolume();
56 }
57 
58 void
60 {
61  _face_infos.clear();
62 
63  // Either the element or the (active) neighbor is a valid argument to get a face info
64  const Elem * side_neighbor = _current_elem->neighbor_ptr(_current_side);
65 
66  mooseAssert(_current_elem, "We should have an element");
67  mooseAssert(_current_elem->active(), "The current element should be active");
68 
69  // No neighbor means we are at a boundary, a FaceInfo exists in the mesh
70  if (side_neighbor)
71  {
72  std::vector<const Elem *> candidate_neighbors = {side_neighbor};
73 
74  // neighbor is not active, we have to seek its refined children to get a FaceInfo
75  if (!side_neighbor->active())
76  side_neighbor->active_family_tree_by_neighbor(candidate_neighbors, _current_elem);
77 
78  for (const Elem * neighbor : candidate_neighbors)
79  {
80  const Elem * element = _current_elem;
81  auto side = _current_side;
82 
83  // If a neighbor exists, the face info may only be defined on the other side
84  // First check refinement level
85  if (_current_elem->level() < neighbor->level())
86  {
87  element = neighbor;
88  side = neighbor->which_neighbor_am_i(_current_elem);
89  }
90  // Then check ids
91  else if ((_current_elem->level() == neighbor->level()) &&
92  (_current_elem->id() > neighbor->id()))
93  {
94  element = neighbor;
95  side = neighbor->which_neighbor_am_i(_current_elem);
96  }
97  const auto fi = _mesh.faceInfo(element, side);
98  mooseAssert(fi, "Face info must not be null.");
99  _face_infos.push_back(fi);
100  }
101  }
102  else
103  {
104  const auto fi = _mesh.faceInfo(_current_elem, _current_side);
105  mooseAssert(fi, "Face info must not be null.");
106  _face_infos.push_back(fi);
107  }
108 }
const Real & neighborVolume()
Returns the reference to the current neighbor volume.
Definition: Assembly.h:508
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.
Intermediate base class that ties together all the interfaces for getting MooseVariables with the Moo...
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:2331
InternalSideUserObject(const InputParameters &parameters)
Assembly & _assembly
Reference to the assembly object for this user object.
const Elem *const & _current_elem
pointer to the current element object
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const std::set< BoundaryID > EMPTY_BOUNDARY_IDS
Definition: MooseTypes.h:733
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:19
static InputParameters validParams()
Definition: UserObject.C:14