Line data Source code
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 : 13 : InputParameters 14 114680 : InternalSideUserObject::validParams() 15 : { 16 114680 : InputParameters params = UserObject::validParams(); 17 114680 : params += BlockRestrictable::validParams(); 18 114680 : params += TwoMaterialPropertyInterface::validParams(); 19 114680 : params += TransientInterface::validParams(); 20 : 21 : // Need one layer of ghosting 22 114680 : params.addRelationshipManager("ElementSideNeighborLayers", 23 : Moose::RelationshipManagerType::GEOMETRIC | 24 : Moose::RelationshipManagerType::ALGEBRAIC); 25 : 26 114680 : return params; 27 0 : } 28 : 29 295 : InternalSideUserObject::InternalSideUserObject(const InputParameters & parameters) 30 : : UserObject(parameters), 31 : BlockRestrictable(this), 32 : TwoMaterialPropertyInterface(this, blockIDs(), Moose::EMPTY_BOUNDARY_IDS), 33 : NeighborCoupleableMooseVariableDependencyIntermediateInterface(this, false, false), 34 : TransientInterface(this), 35 : ElementIDInterface(this), 36 590 : _mesh(_subproblem.mesh()), 37 295 : _q_point(_assembly.qPointsFace()), 38 295 : _qrule(_assembly.qRuleFace()), 39 295 : _JxW(_assembly.JxWFace()), 40 295 : _coord(_assembly.coordTransformation()), 41 295 : _normals(_assembly.normals()), 42 295 : _current_elem(_assembly.elem()), 43 295 : _current_elem_volume(_assembly.elemVolume()), 44 295 : _current_side(_assembly.side()), 45 295 : _current_side_elem(_assembly.sideElem()), 46 295 : _current_side_volume(_assembly.sideElemVolume()), 47 295 : _neighbor_elem(_assembly.neighbor()), 48 590 : _current_neighbor_volume(_assembly.neighborVolume()) 49 : { 50 295 : } 51 : 52 : const Real & 53 0 : InternalSideUserObject::getNeighborElemVolume() 54 : { 55 0 : return _assembly.neighborVolume(); 56 : } 57 : 58 : void 59 1440 : InternalSideUserObject::getFaceInfos() 60 : { 61 1440 : _face_infos.clear(); 62 : 63 : // Either the element or the (active) neighbor is a valid argument to get a face info 64 1440 : 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 1440 : if (side_neighbor) 71 : { 72 1440 : 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 1440 : if (!side_neighbor->active()) 76 0 : side_neighbor->active_family_tree_by_neighbor(candidate_neighbors, _current_elem); 77 : 78 2880 : for (const Elem * neighbor : candidate_neighbors) 79 : { 80 1440 : const Elem * element = _current_elem; 81 1440 : 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 1440 : if (_current_elem->level() < neighbor->level()) 86 : { 87 0 : element = neighbor; 88 0 : side = neighbor->which_neighbor_am_i(_current_elem); 89 : } 90 : // Then check ids 91 2880 : else if ((_current_elem->level() == neighbor->level()) && 92 1440 : (_current_elem->id() > neighbor->id())) 93 : { 94 0 : element = neighbor; 95 0 : side = neighbor->which_neighbor_am_i(_current_elem); 96 : } 97 1440 : const auto fi = _mesh.faceInfo(element, side); 98 : mooseAssert(fi, "Face info must not be null."); 99 1440 : _face_infos.push_back(fi); 100 : } 101 1440 : } 102 : else 103 : { 104 0 : const auto fi = _mesh.faceInfo(_current_elem, _current_side); 105 : mooseAssert(fi, "Face info must not be null."); 106 0 : _face_infos.push_back(fi); 107 : } 108 1440 : }