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 "RhieChowInterpolatorBase.h" 13 : #include "CellCenteredMapFunctor.h" 14 : #include "FaceCenteredMapFunctor.h" 15 : #include "VectorComponentFunctor.h" 16 : #include <unordered_map> 17 : #include <set> 18 : #include <unordered_set> 19 : 20 : class MooseMesh; 21 : class INSFVVelocityVariable; 22 : class INSFVPressureVariable; 23 : namespace libMesh 24 : { 25 : class Elem; 26 : class MeshBase; 27 : } 28 : 29 : /** 30 : * A user object which implements the Rhie Chow interpolation for segregated 31 : * momentum-pressure systems. 32 : */ 33 : class INSFVRhieChowInterpolatorSegregated : public RhieChowInterpolatorBase 34 : { 35 : public: 36 : static InputParameters validParams(); 37 : INSFVRhieChowInterpolatorSegregated(const InputParameters & params); 38 : 39 : /// Get the face velocity (used in advection terms) 40 : VectorValue<ADReal> getVelocity(const Moose::FV::InterpMethod m, 41 : const FaceInfo & fi, 42 : const Moose::StateArg & time, 43 : const THREAD_ID tid, 44 : bool subtract_mesh_velocity) const override; 45 : 46 : /// Initialize the container for face velocities 47 : void initFaceVelocities(); 48 : /// Update the values of the face velocities in the containers 49 : void computeFaceVelocity(); 50 : /// Update the cell values of the velocity variables 51 : void computeCellVelocity(); 52 : 53 : /// We disable this for the segregated solver 54 0 : void addToA(const libMesh::Elem * /*elem*/, 55 : unsigned int /*component*/, 56 : const ADReal & /*value*/) override 57 : { 58 0 : mooseError( 59 : "addToA function is not implemented for the RhieChow interpolation in segregated solvers."); 60 : } 61 : 62 : void meshChanged() override; 63 : void initialize() override; 64 0 : void execute() override {} 65 0 : void finalize() override {} 66 : 67 32314338 : bool segregated() const override { return true; }; 68 : 69 : /** 70 : * Update the momentum system-related information 71 : * @param momentum_systems Pointers to the momentum systems which are solved for the momentum 72 : * vector components 73 : * @param momentum_system_numbers The numbers of these systems 74 : * @param pressure_gradient_tag The tag which is associated with the pressure gradient kernels. 75 : * This is needed for separating the pressure contibution from other terms in the momentum 76 : * systems. 77 : */ 78 : void linkMomentumSystem(std::vector<NonlinearSystemBase *> momentum_systems, 79 : const std::vector<unsigned int> & momentum_system_numbers, 80 : const TagID pressure_gradient_tag); 81 : 82 : /** 83 : * Computes the inverse of the digaonal (1/A) of the system matrix plus the H/A components for the 84 : * pressure equation plus Rhie-Chow interpolation. 85 : */ 86 : void computeHbyA(bool verbose); 87 : 88 : protected: 89 : /// Populate the face values of the H/A field 90 : void populateHbyA(const std::vector<std::unique_ptr<NumericVector<Number>>> & raw_hbya, 91 : const std::vector<unsigned int> & var_nums); 92 : /** 93 : * A map functor from faces to $HbyA_{ij} = (A_{offdiag}*\mathrm{(predicted~velocity)} - 94 : * \mathrm{Source})_{ij}/A_{ij}$. So this contains the off-diagonal part of the system matrix 95 : * multiplied by the predicted velocity minus the source terms from the right hand side of the 96 : * linearized momentum predictor step. 97 : */ 98 : FaceCenteredMapFunctor<RealVectorValue, std::unordered_map<dof_id_type, RealVectorValue>> _HbyA; 99 : 100 : /** 101 : * We hold on to the cell-based HbyA vectors so that we can easily reconstruct the 102 : * cell velocities as well. This vector might be either of size 1 or DIM depending on if we 103 : * segregate the velocity components as well. 104 : */ 105 : std::vector<std::unique_ptr<NumericVector<Number>>> _HbyA_raw; 106 : 107 : /** 108 : * A map functor from element IDs to $1/A_i$. Where $A_i$ is the diagonal of the system matrix 109 : * for the momentum equation. 110 : */ 111 : CellCenteredMapFunctor<RealVectorValue, std::unordered_map<dof_id_type, RealVectorValue>> _Ainv; 112 : 113 : /// A functor for computing the (non-RC corrected) velocity 114 : std::unique_ptr<PiecewiseByBlockLambdaFunctor<ADRealVectorValue>> _vel; 115 : 116 : /** 117 : * A map functor from faces to face velocities which are used in the advection terms 118 : */ 119 : FaceCenteredMapFunctor<RealVectorValue, std::unordered_map<dof_id_type, RealVectorValue>> 120 : _face_velocity; 121 : 122 : /// Pointers to the nonlinear system(s) corresponding to the momentum equation(s) 123 : std::vector<NonlinearSystemBase *> _momentum_systems; 124 : 125 : /// Numbers of the momentum system(s) 126 : std::vector<unsigned int> _momentum_system_numbers; 127 : 128 : /// Pointers to the momentum equation implicit system(s) 129 : std::vector<libMesh::NonlinearImplicitSystem *> _momentum_implicit_systems; 130 : 131 : /// Residual tag corresponding to the pressure gradient contribution 132 : TagID _pressure_gradient_tag; 133 : };