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 "InitialConditionInterface.h" 13 : #include "MooseObject.h" 14 : #include "Coupleable.h" 15 : #include "FunctionInterface.h" 16 : #include "UserObjectInterface.h" 17 : #include "PostprocessorInterface.h" 18 : #include "Restartable.h" 19 : #include "BlockRestrictable.h" 20 : #include "DependencyResolverInterface.h" 21 : #include "BoundaryRestrictable.h" 22 : #include "MaterialPropertyInterface.h" 23 : #include "MooseTypes.h" 24 : #include "ElementIDInterface.h" 25 : 26 : class SystemBase; 27 : class MooseVariableFieldBase; 28 : namespace libMesh 29 : { 30 : class Point; 31 : } 32 : 33 : /** 34 : * InitialConditionBase serves as the abstract base class for InitialConditions and 35 : * VectorInitialConditions. Implements methods for getting user objects and dependent objects. The 36 : * template class that inherits from this class implements the meat of the initial condition 37 : * hierarchy: the `compute` method 38 : */ 39 : class InitialConditionBase : public MooseObject, 40 : public InitialConditionInterface, 41 : public BlockRestrictable, 42 : public Coupleable, 43 : public MaterialPropertyInterface, 44 : public FunctionInterface, 45 : public UserObjectInterface, 46 : public PostprocessorInterface, 47 : public BoundaryRestrictable, 48 : public DependencyResolverInterface, 49 : public Restartable, 50 : public ElementIDInterface 51 : { 52 : public: 53 : /** 54 : * Constructor 55 : * 56 : * @param parameters The parameters object holding data for the class to use. 57 : */ 58 : InitialConditionBase(const InputParameters & parameters); 59 : 60 : virtual ~InitialConditionBase(); 61 : 62 : static InputParameters validParams(); 63 : 64 : /** 65 : * retrieves the MOOSE variable that this initial condition acts upon 66 : */ 67 : virtual MooseVariableFEBase & variable() = 0; 68 : 69 : /** 70 : * getter method for dependent user objects 71 : */ 72 25451 : const std::set<UserObjectName> & getDependObjects() const { return _depend_uo; } 73 : 74 : /** 75 : * Workhorse method for projecting the initial conditions for block initial conditions 76 : */ 77 : virtual void compute() = 0; 78 : /** 79 : * Workhorse method for projecting the initial conditions for boundary restricted initial 80 : * conditions 81 : */ 82 : virtual void computeNodal(const Point & p) = 0; 83 : 84 : /** 85 : * Gets called at the beginning of the simulation before this object is asked to do its job. 86 : * Note: This method is normally inherited from SetupInterface. However in this case it makes 87 : * no sense to inherit the other virtuals available in that class so we are adding this virtual 88 : * directly to this class with out the extra inheritance. 89 : */ 90 25366 : virtual void initialSetup() {} 91 : 92 : virtual const std::set<std::string> & getRequestedItems() override; 93 : 94 : virtual const std::set<std::string> & getSuppliedItems() override; 95 : 96 : protected: 97 : /// The system object 98 : SystemBase & _sys; 99 : 100 : /// If set, UOs retrieved by this IC will not be executed before this IC 101 : const bool _ignore_uo_dependency; 102 : 103 : private: 104 : void addUserObjectDependencyHelper(const UserObject & uo) const override final; 105 : void addPostprocessorDependencyHelper(const PostprocessorName & name) const override final; 106 : 107 : /// Dependent variables 108 : std::set<std::string> _depend_vars; 109 : /// Supplied variables 110 : std::set<std::string> _supplied_vars; 111 : 112 : /// Depend UserObjects. Mutable so that the getters can be const and still add dependencies 113 : mutable std::set<UserObjectName> _depend_uo; 114 : };