Line data Source code
1 : /**********************************************************************/ 2 : /* DO NOT MODIFY THIS HEADER */ 3 : /* Swift, a Fourier spectral solver for MOOSE */ 4 : /* */ 5 : /* Copyright 2024 Battelle Energy Alliance, LLC */ 6 : /* ALL RIGHTS RESERVED */ 7 : /**********************************************************************/ 8 : 9 : #pragma once 10 : 11 : #include "TensorProblem.h" 12 : 13 : class LatticeBoltzmannStencilBase; 14 : 15 : /** 16 : * Problem object for solving lattice Boltzmann problems 17 : */ 18 : class LatticeBoltzmannProblem : public TensorProblem 19 : { 20 : public: 21 : static InputParameters validParams(); 22 : 23 : LatticeBoltzmannProblem(const InputParameters & parameters); 24 : 25 : void addTensorBoundaryCondition(const std::string & compute_name, 26 : const std::string & name, 27 : InputParameters & parameters); 28 : 29 : // setup stuff 30 : void init() override; 31 : 32 : // main loop 33 : void execute(const ExecFlagType & exec_type) override; 34 : 35 : void addStencil(const std::string & stencil_name, 36 : const std::string & name, 37 : InputParameters & parameters); 38 : 39 : const LatticeBoltzmannStencilBase & getStencil() const { return *_stencil; } 40 : 41 : const bool & isSlipEnabled() const { return _enable_slip; } 42 : 43 : const torch::Tensor & getSlipRelaxationMatrix() const { return _slip_relaxation_matrix; } 44 : 45 : const int & getTotalSteps() const { return _t_total; } 46 : 47 0 : const std::array<int64_t, 3> & getGridSize() const { return _n; } 48 : 49 : const bool & isBinaryMedia() { return _is_binary_media; } 50 : 51 0 : const torch::Tensor & getBinaryMedia() { return _binary_media; } 52 : 53 0 : const std::vector<int64_t> & getExtendedShape() { return _shape_extended; } 54 0 : const std::vector<int64_t> & getExtendedShapeQ() { return _shape_extended_to_q; } 55 : 56 : /// sets up slip model 57 : void enableSlipModel(); 58 : 59 : /// sets convergence residual 60 0 : void setSolverResidual(const Real & residual) { _convergence_residual = residual; }; 61 : 62 : /// sets tensor to a value (normally zeros) at solid nodes 63 : void maskedFillSolids(torch::Tensor & t, const Real & value); 64 : 65 : protected: 66 : /// LBM mesh/media 67 : torch::Tensor _binary_media; 68 : const bool _is_binary_media; 69 : 70 : /// 71 : std::vector<int64_t> _shape_extended; 72 : std::vector<int64_t> _shape_extended_to_q; 73 : 74 : /// LBM stencils object 75 : std::shared_ptr<LatticeBoltzmannStencilBase> _stencil; 76 : 77 : /// bc objects 78 : TensorComputeList _bcs; 79 : 80 : /// enables slip models 81 : bool _enable_slip; 82 : 83 : /// slip coefficient 84 : const Real _A_1 = 0.6; 85 : const Real _A_2 = 0.9; 86 : 87 : /// relaxation matrix as a funcion of Kn and local pore size in slip model 88 : torch::Tensor _slip_relaxation_matrix; 89 : 90 : /// used to restrict construction of lbm stencils to only one 91 : unsigned int _stencil_counter = 0; 92 : 93 : /// convergence residual 94 : Real _convergence_residual = 1; 95 : 96 : /// total number of time steps taken 97 : int _t_total = 0; 98 : 99 : /// lbm substeps 100 : const unsigned int _lbm_substeps; 101 : 102 : /// lbm convergence tolerance 103 : const Real _tolerance; 104 : 105 : public: 106 : /// LBM constants 107 : const Real _cs = 1.0 / sqrt(3.0); 108 : const Real _cs2 = _cs * _cs; 109 : const Real _cs4 = _cs2 * _cs2; 110 : };