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 "INSFVRhieChowInterpolator.h" 13 : #include "CellCenteredMapFunctor.h" 14 : #include <unordered_map> 15 : 16 : /** 17 : * A class that inherits the free-flow class's implementation of Rhie-Chow data gathering and adds 18 : * the ability to perform repeated interpolations and reconstructions of the porosity in order to 19 : * reduce non-physical oscillations that arise from property discontinuities in a collocated 20 : * discretization of pressure and velocity 21 : */ 22 : class PINSFVRhieChowInterpolator : public INSFVRhieChowInterpolator 23 : { 24 : public: 25 : static InputParameters validParams(); 26 : PINSFVRhieChowInterpolator(const InputParameters & params); 27 : 28 : virtual void meshChanged() override; 29 : virtual void initialize() override; 30 : virtual void execute() override; 31 : virtual void finalize() override; 32 : 33 : protected: 34 : const Moose::FunctorBase<ADReal> & epsilon(THREAD_ID tid) const override; 35 : 36 : /** 37 : * @return whether this face is geometrically relevant to us 38 : */ 39 : bool isFaceGeometricallyRelevant(const FaceInfo & fi) const; 40 : 41 : /// The thread 0 copy of the porosity functor held by the subproblem. Initially this functor 42 : /// should be provided by a functor material property or function. We then perform repeated 43 : /// interpolations and reconstructions to create the resulting smoothed field 44 : const Moose::Functor<ADReal> & _eps; 45 : 46 : /// The smoothed porosity functor/field 47 : CellCenteredMapFunctor<ADReal, std::unordered_map<dof_id_type, ADReal>> _smoothed_eps; 48 : 49 : /// All the thread copies of the problem's porosity functor 50 : std::vector<const Moose::Functor<ADReal> *> _epss; 51 : 52 : /// All the thread copies of the problem's smoothed porosity functor 53 : std::vector<const Moose::Functor<ADReal> *> _smoothed_epss; 54 : 55 : /// The number of interpolations and reconstructions that should be performed on the porosity 56 : /// functor/field. One smoothing layer corresponds to one interpolation and one reconstruction 57 : const unsigned short _smoothing_layers; 58 : 59 : /// All the face information that are "geometrically" accessible on this process. For an internal 60 : /// face, we consider it to be geometrically accessible if neither element nor neighbor is a \p 61 : /// libMesh::remote_elem. For a boundary face, we consider the face to be geometrically accessible 62 : /// if the adjoining element and all its non-null neighbors are not \p libMesh::remote_elem. This 63 : /// is due to the need to be able to perform two-term expansions which require ability to compute 64 : /// a Green-Gauss gradient 65 : std::vector<const FaceInfo *> _geometric_fi; 66 : 67 : private: 68 : /** 69 : * called during the first \p initialize() and upon \p meshChanged(), this method performs the 70 : * interpolations and reconstructions of porosity. Cannot be called in \p initialSetup() because 71 : * UOs are initialized before Functions 72 : */ 73 : void pinsfvSetup(); 74 : }; 75 : 76 : inline const Moose::FunctorBase<ADReal> & 77 119747677 : PINSFVRhieChowInterpolator::epsilon(const THREAD_ID tid) const 78 : { 79 119747677 : if (!_smoothing_layers) 80 95722357 : return *_epss[tid]; 81 : else 82 24025320 : return *_smoothed_epss[tid]; 83 : }