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 "ElementUserObject.h" 13 : #include "DiscreteNucleationInserterBase.h" 14 : 15 : /** 16 : * This UserObject maintains a per QP map that indicates if a nucleus is 17 : * present or not. It effectively performs a spatial hashing of the list maintained 18 : * by the DiscreteNucleationInserter (and allows for spatially extended nuclei) 19 : */ 20 : class DiscreteNucleationMap : public ElementUserObject 21 : { 22 : public: 23 : static InputParameters validParams(); 24 : 25 : DiscreteNucleationMap(const InputParameters & parameters); 26 : 27 : virtual void initialize(); 28 : virtual void execute(); 29 : virtual void threadJoin(const UserObject & y); 30 981 : virtual void finalize() {} 31 : 32 : virtual void meshChanged(); 33 : 34 : const std::vector<Real> & nuclei(const Elem *) const; 35 : 36 21 : const DiscreteNucleationInserterBase & getInserter() const { return _inserter; } 37 : 38 21 : Real getWidth() const { return _int_width; } 39 21 : Real getPeriodic() const { return _periodic; } 40 : 41 : protected: 42 : /// Did the mesh change since the last execution of this PP? 43 : bool _mesh_changed; 44 : 45 : /// Do we need to rebuild the map during this timestep? 46 : bool _rebuild_map; 47 : 48 : /// If a timestep is repeated due to a failed solve, we don't want to rebuild 49 : /// the map. But the inserter might have made changes we didn't account for. 50 : /// This will force the next timestep to rebuild regardless of inserter's 51 : /// state. 52 : bool _force_rebuild_map = false; 53 : 54 : /// Buffer for building the per QP map 55 : std::vector<Real> _elem_map; 56 : 57 : /// Dummy map for elements without nuclei 58 : std::vector<Real> _zero_map; 59 : 60 : /// UserObject that manages nucleus insertin and deletion 61 : const DiscreteNucleationInserterBase & _inserter; 62 : 63 : /// variable number to use for minPeriodicDistance calls (i.e. use the periodicity of this variable) 64 : int _periodic; 65 : 66 : /// Nucleus interface width 67 : const Real _int_width; 68 : 69 : /// list of nuclei maintained bu the inserter object 70 : const DiscreteNucleationInserterBase::NucleusList & _nucleus_list; 71 : 72 : ///@{ Per element list with 0/1 flags indicating the presence of a nucleus 73 : using NucleusMap = std::unordered_map<dof_id_type, std::vector<Real>>; 74 : NucleusMap _nucleus_map; 75 : ///@} 76 : };