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 "NonlinearSystem.h" 13 : 14 : // libMesh 15 : #include "libmesh/eigen_system.h" 16 : 17 : class FEProblemBase; 18 : 19 : class MooseEigenSystem : public NonlinearSystem 20 : { 21 : public: 22 : MooseEigenSystem(FEProblemBase & problem, const std::string & name); 23 : virtual ~MooseEigenSystem(); 24 : 25 : /** 26 : * Adds a kernel 27 : * @param kernel_name The type of the kernel. 28 : * @param name The name of the kernel. 29 : * @param parameters Kernel parameters. 30 : */ 31 : virtual void addKernel(const std::string & kernel_name, 32 : const std::string & name, 33 : InputParameters & parameters); 34 : 35 : /** 36 : * Mark a variable as a variable of the eigen system 37 : * @param var_name The name of the variable. 38 : */ 39 : virtual void markEigenVariable(const VariableName & var_name); 40 : 41 : /** 42 : * System or kernel tags 43 : */ 44 : enum SYSTEMTAG 45 : { 46 : ALL, 47 : EIGEN 48 : }; 49 : 50 : /** 51 : * Scale the solution vector 52 : * 53 : * @param tag System tag. 54 : * @param factor The scaling factor. 55 : */ 56 : void scaleSystemSolution(SYSTEMTAG tag, Real scaling_factor); 57 : 58 : /** 59 : * Linear combination of the solution vectors 60 : * 61 : * @param tag System tag. 62 : * @param coefficients Coefficients for current, old and older solutions. 63 : */ 64 : void combineSystemSolution(SYSTEMTAG tag, const std::vector<Real> & coefficients); 65 : 66 : /** 67 : * Initialize the solution vector with a constant value 68 : * 69 : * @param tag System tag. 70 : * @param v The value. 71 : */ 72 : void initSystemSolution(SYSTEMTAG tag, Real v); 73 : void initSystemSolutionOld(SYSTEMTAG tag, Real v); 74 : 75 : /** 76 : * Ask eigenkernels to operate on old or current solution vectors 77 : */ 78 : void eigenKernelOnOld(); 79 : void eigenKernelOnCurrent(); 80 : 81 : /** 82 : * Build DoF indices for a system 83 : */ 84 : void buildSystemDoFIndices(SYSTEMTAG tag = ALL); 85 : 86 : /** 87 : * Return if eigen kernels should be on old solution 88 : */ 89 : bool activeOnOld(); 90 : 91 : /** 92 : * Get variable names of the eigen system 93 : */ 94 135 : const std::set<VariableName> & getEigenVariableNames() const { return _eigen_var_names; } 95 : 96 : /** 97 : * Weather or not the system contains eigen kernels 98 : */ 99 : bool containsEigenKernel() const; 100 : 101 : protected: 102 : std::set<VariableName> _eigen_var_names; 103 : bool _all_eigen_vars; 104 : std::set<dof_id_type> _eigen_var_indices; 105 : 106 : bool _active_on_old; 107 : 108 : /// counter of eigen kernels 109 : unsigned int _eigen_kernel_counter; 110 : };