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 "SideUserObject.h" 11 : #include "SubProblem.h" 12 : #include "MooseTypes.h" 13 : #include "Assembly.h" 14 : 15 : InputParameters 16 852987 : SideUserObject::validParams() 17 : { 18 852987 : InputParameters params = UserObject::validParams(); 19 852987 : params += BoundaryRestrictableRequired::validParams(); 20 852987 : params += MaterialPropertyInterface::validParams(); 21 852987 : params.addRelationshipManager("GhostLowerDElems", 22 : Moose::RelationshipManagerType::GEOMETRIC | 23 : Moose::RelationshipManagerType::ALGEBRAIC); 24 852987 : return params; 25 0 : } 26 : 27 5680 : SideUserObject::SideUserObject(const InputParameters & parameters) 28 : : UserObject(parameters), 29 : BoundaryRestrictableRequired(this, false), // false for applying to sidesets 30 : MaterialPropertyInterface(this, Moose::EMPTY_BLOCK_IDS, boundaryIDs()), 31 : CoupleableMooseVariableDependencyIntermediateInterface(this, false), 32 : TransientInterface(this), 33 : ElementIDInterface(this), 34 11360 : _mesh(_subproblem.mesh()), 35 5680 : _q_point(_assembly.qPointsFace()), 36 5680 : _qrule(_assembly.qRuleFace()), 37 5680 : _JxW(_assembly.JxWFace()), 38 5680 : _coord(_assembly.coordTransformation()), 39 5680 : _normals(_assembly.normals()), 40 5680 : _current_elem(_assembly.elem()), 41 5680 : _current_side(_assembly.side()), 42 5680 : _current_side_elem(_assembly.sideElem()), 43 5680 : _current_side_volume(_assembly.sideElemVolume()), 44 11360 : _current_boundary_id(_assembly.currentBoundaryID()) 45 : { 46 5680 : } 47 : 48 : void 49 25429 : SideUserObject::getFaceInfos() 50 : { 51 25429 : _face_infos.clear(); 52 : 53 : // Either the element or the (active) neighbor is a valid argument to get a face info 54 25429 : 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 25429 : if (side_neighbor) 61 : { 62 12226 : 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 12226 : if (!side_neighbor->active()) 66 2088 : side_neighbor->active_family_tree_by_neighbor(candidate_neighbors, _current_elem); 67 : 68 26540 : for (const Elem * neighbor : candidate_neighbors) 69 : { 70 14314 : const Elem * element = _current_elem; 71 14314 : 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 14314 : if (_current_elem->level() < neighbor->level()) 76 : { 77 4176 : element = neighbor; 78 4176 : side = neighbor->which_neighbor_am_i(_current_elem); 79 : } 80 : // Then check ids 81 15056 : else if ((_current_elem->level() == neighbor->level()) && 82 4918 : (_current_elem->id() > neighbor->id())) 83 : { 84 2507 : element = neighbor; 85 2507 : side = neighbor->which_neighbor_am_i(_current_elem); 86 : } 87 14314 : const auto fi = _mesh.faceInfo(element, side); 88 : mooseAssert(fi, "Face info must not be null."); 89 14314 : _face_infos.push_back(fi); 90 : } 91 12226 : } 92 : else 93 : { 94 13203 : const auto fi = _mesh.faceInfo(_current_elem, _current_side); 95 : mooseAssert(fi, "Face info must not be null."); 96 13203 : _face_infos.push_back(fi); 97 : } 98 25429 : }