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 : #pragma once 11 : 12 : #include "MooseObject.h" 13 : #include "SetupInterface.h" 14 : #include "Restartable.h" 15 : #include "MeshChangedInterface.h" 16 : 17 : #include "libmesh/vector_value.h" 18 : 19 : // libMesh forward declarations 20 : namespace libMesh 21 : { 22 : class Point; 23 : } 24 : 25 : namespace MooseMeshDivision 26 : { 27 : /// Invalid subdomain id to return when outside the mesh division 28 : inline unsigned int INVALID_DIVISION_INDEX = std::numeric_limits<unsigned int>::max(); 29 : } 30 : 31 : /** 32 : * Base class for MeshDivision objects. MeshDivision objects divide the mesh into a 33 : * contiguously numbered set of divisions/partitions. 34 : */ 35 : class MeshDivision : public MooseObject, public SetupInterface, public MeshChangedInterface 36 : { 37 : public: 38 : /** 39 : * Class constructor 40 : * \param parameters The input parameters for the MeshDivision 41 : */ 42 : static InputParameters validParams(); 43 : 44 : MeshDivision(const InputParameters & parameters); 45 : 46 : /** 47 : * MeshDivision destructor 48 : */ 49 : virtual ~MeshDivision(); 50 : 51 : /// Return the index of the division to which the point belongs 52 : virtual unsigned int divisionIndex(const Point & pt) const = 0; 53 : /// Return the index of the division to which the element belongs 54 : virtual unsigned int divisionIndex(const Elem & elem) const = 0; 55 : /// Return the number of divisions 56 748109 : unsigned int getNumDivisions() const { return _num_divs; } 57 : /// Returns whether the entire mesh is covered by the division of the mesh, whether every point and element has a valid division index 58 314 : bool coversEntireMesh() const { return _mesh_fully_indexed; } 59 : 60 : /// By default, meshChanged will cause a re-initialization of the necessary data members 61 0 : virtual void meshChanged() override { initialize(); } 62 : 63 : protected: 64 : /// Set the number of divisions 65 813 : void setNumDivisions(const unsigned int ndivs) { _num_divs = ndivs; } 66 : 67 : /// Set up any data members that would be necessary to obtain the division indices 68 0 : virtual void initialize() {} 69 : 70 : /// Pointer to the problem, needed to retrieve pointers to various objects 71 : const FEProblemBase * const _fe_problem; 72 : 73 : /// Mesh that is being divided 74 : const MooseMesh & _mesh; 75 : 76 : /// Whether the mesh is fully covered / indexed, all elements and points have a valid index 77 : bool _mesh_fully_indexed; 78 : 79 : private: 80 : /// Number of divisions in the division 81 : unsigned int _num_divs; 82 : };