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 "BlockRestrictable.h" 14 : #include "SetupInterface.h" 15 : #include "DependencyResolverInterface.h" 16 : #include "MooseVariableDependencyInterface.h" 17 : #include "UserObjectInterface.h" 18 : #include "Restartable.h" 19 : #include "PostprocessorInterface.h" 20 : #include "MeshChangedInterface.h" 21 : #include "OutputInterface.h" 22 : 23 : // Forward declarations 24 : class MooseMesh; 25 : class SubProblem; 26 : class FEProblemBase; 27 : class SystemBase; 28 : class Assembly; 29 : template <typename> 30 : class MooseVariableFE; 31 : typedef MooseVariableFE<Real> MooseVariable; 32 : typedef MooseVariableFE<VectorValue<Real>> VectorMooseVariable; 33 : class Adaptivity; 34 : 35 : namespace libMesh 36 : { 37 : class ErrorVector; 38 : } 39 : using libMesh::ErrorVector; 40 : 41 : class Marker : public MooseObject, 42 : public BlockRestrictable, 43 : public SetupInterface, 44 : public DependencyResolverInterface, 45 : public MooseVariableDependencyInterface, 46 : public UserObjectInterface, 47 : public Restartable, 48 : public PostprocessorInterface, 49 : public MeshChangedInterface, 50 : public OutputInterface 51 : { 52 : public: 53 : static InputParameters validParams(); 54 : 55 : Marker(const InputParameters & parameters); 56 2053 : virtual ~Marker() {} 57 : 58 : /// This mirrors the main refinement flag values in libMesh in Elem::RefinementState but adds "dont_mark" 59 : enum MarkerValue 60 : { 61 : DONT_MARK = -1, 62 : COARSEN, 63 : DO_NOTHING, 64 : REFINE 65 : }; 66 : 67 : /** 68 : * Helper function for getting the valid refinement flag states a marker can use as a MooseEnum. 69 : * @return A MooseEnum that is filled with the valid states. These are perfectly transferable to 70 : * libMesh Elem::RefinementStates. 71 : */ 72 : static MooseEnum markerStates(); 73 : 74 : /// Computes and sets the value of the refinement flag 75 : virtual void computeMarker(); 76 : 77 : bool isActive() const; 78 : 79 : /** 80 : * Is called before any element looping is started so any "global" computation can be done. 81 : */ 82 : virtual void markerSetup(); 83 : 84 : virtual const std::set<std::string> & getRequestedItems() override; 85 : 86 : virtual const std::set<std::string> & getSuppliedItems() override; 87 : 88 : protected: 89 : virtual MarkerValue computeElementMarker() = 0; 90 : 91 : /** 92 : * Get an ErrorVector that will be filled up with values corresponding to the indicator passed in. 93 : * 94 : * Note that this returns a reference... and the return value should be stored as a reference! 95 : * 96 : * @param indicator The name of the indicator to get an ErrorVector for. 97 : */ 98 : ErrorVector & getErrorVector(std::string indicator); 99 : 100 : /** 101 : * This is used to get the values of _other_ Markers. This is useful for making combo-markers 102 : * that 103 : * take multiple markers and combine them to make one. 104 : * 105 : * @param name The name of the _other_ Marker that you want to have access to. 106 : * @return A _reference_ that will hold the value of the marker in it's 0 (zeroth) position. 107 : */ 108 : const MooseArray<Real> & getMarkerValue(std::string name); 109 : 110 : SubProblem & _subproblem; 111 : FEProblemBase & _fe_problem; 112 : Adaptivity & _adaptivity; 113 : SystemBase & _sys; 114 : 115 : THREAD_ID _tid; 116 : 117 : Assembly & _assembly; 118 : 119 : /// Reference to this marker as a variable 120 : MooseVariable & _field_var; 121 : /// Pointer to the current element being considered in the marker element-based loop 122 : const Elem * const & _current_elem; 123 : 124 : /// Reference to the mesh, obtained from the subproblem 125 : MooseMesh & _mesh; 126 : 127 : /// Depend Markers 128 : std::set<std::string> _depend; 129 : std::set<std::string> _supplied; 130 : };