LCOV - code coverage report
Current view: top level - include/userobjects - MDRunBase.h (source / functions) Hit Total Coverage
Test: idaholab/magpie: 5710af Lines: 2 2 100.0 %
Date: 2025-07-21 23:34:39 Functions: 0 0 -
Legend: Lines: hit not hit

          Line data    Source code
       1             : /**********************************************************************/
       2             : /*                     DO NOT MODIFY THIS HEADER                      */
       3             : /* MAGPIE - Mesoscale Atomistic Glue Program for Integrated Execution */
       4             : /*                                                                    */
       5             : /*            Copyright 2017 Battelle Energy Alliance, LLC            */
       6             : /*                        ALL RIGHTS RESERVED                         */
       7             : /**********************************************************************/
       8             : 
       9             : #pragma once
      10             : 
      11             : #include "overlap.hpp"
      12             : #include "GeneralUserObject.h"
      13             : #include "KDTree.h"
      14             : #include "libmesh/bounding_box.h"
      15             : 
      16             : class MooseMesh;
      17             : 
      18             : /**
      19             :  * Base class for molecular dynamics runs in Magpie
      20             :  */
      21             : class MDRunBase : public GeneralUserObject
      22             : {
      23             : public:
      24             :   static InputParameters validParams();
      25             : 
      26             :   MDRunBase(const InputParameters & parameters);
      27             : 
      28             :   void initialSetup() override;
      29             :   void timestepSetup() override;
      30             : 
      31             :   class MDParticles
      32             :   {
      33             :   public:
      34             :     /// particle's position
      35             :     std::vector<Point> pos;
      36             : 
      37             :     /// the id of particle in the MD calculation
      38             :     std::vector<unsigned int> id;
      39             : 
      40             :     /// the mesh element the particles are in
      41             :     std::vector<unique_id_type> elem_id;
      42             : 
      43             :     /// data attached to each particle
      44             :     std::vector<std::vector<Real>> properties;
      45             : 
      46             :     /// the size of the properties vector
      47             :     unsigned int _prop_size;
      48             : 
      49             :     /// maps property IDs to position in properties vector
      50             :     std::map<unsigned int, unsigned int> _map_props;
      51             : 
      52             :     // the index of the radius property in properties vector
      53             :     unsigned int _r_index;
      54             :   };
      55             : 
      56             :   /// access to the MDParticles
      57             :   const MDParticles & particles() const { return _md_particles; }
      58             : 
      59             :   // check if the stored particles are granular
      60          20 :   bool isGranular() const { return _granular; }
      61             : 
      62             :   /// access to the element to particle map
      63             :   void elemParticles(unique_id_type elem_id, std::vector<unsigned int> & elem_particles) const;
      64             : 
      65             :   /// access the element to granular map
      66             :   void granularElementVolumes(unique_id_type elem_id,
      67             :                               std::vector<std::pair<unsigned int, Real>> & gran_vol) const;
      68             : 
      69             :   /// access to MD particle's properties
      70             :   Real particleProperty(unsigned int j, unsigned int prop_id) const;
      71             : 
      72             :   /// accessor for md properties that are collected by this UO
      73          10 :   MultiMooseEnum properties() const { return _properties; }
      74             : 
      75             :   /// List of quantities to get from MD simulation
      76             :   static MultiMooseEnum mdParticleProperties();
      77             : 
      78             :   /// helper function to get property index in properties vector
      79             :   unsigned int propIndex(unsigned int prop_id) const;
      80             : 
      81             :   /// helper function to get property index in properties vector
      82             :   unsigned int propIndex(const std::string & prop_name) const;
      83             : 
      84             : protected:
      85             :   /// call back function to update the particle list
      86             :   virtual void updateParticleList() = 0;
      87             : 
      88             :   /// updates the KDTree object
      89             :   void updateKDTree();
      90             : 
      91             :   /// map MDParticles to elements
      92             :   void mapMDParticles();
      93             : 
      94             :   /// update candidates for
      95             :   void updateElementGranularVolumes();
      96             : 
      97             :   /// helper function to contruct hexahedron
      98             :   OVERLAP::Hexahedron overlapHex(const Elem * elem) const;
      99             : 
     100             :   /// helper function to contruct unit hexahedron
     101             :   OVERLAP::Hexahedron overlapUnitHex() const;
     102             : 
     103             :   /// helper function to contruct tetrahedron
     104             :   OVERLAP::Tetrahedron overlapTet(const Elem * elem) const;
     105             : 
     106             :   /// helper function to construct unit tetrahedron
     107             :   OVERLAP::Tetrahedron overlapUnitTet() const;
     108             : 
     109             :   /// Properties that are requested from MD simulation
     110             :   MultiMooseEnum _properties;
     111             : 
     112             :   /// do the MD particles have extent?
     113             :   bool _granular;
     114             : 
     115             :   /// The Mesh we're using
     116             :   MooseMesh & _mesh;
     117             : 
     118             :   /// dimension of the mesh
     119             :   const unsigned int _dim;
     120             : 
     121             :   /// dimension of the mesh
     122             :   const unsigned int _nproc;
     123             : 
     124             :   /// the processor bounding box of this processor
     125             :   BoundingBox _bbox;
     126             : 
     127             :   /// maximum granular radius for parallel bounding boxes
     128             :   Real _max_granular_radius;
     129             : 
     130             :   /// total number of particles
     131             :   unsigned int _n_particles = 0;
     132             : 
     133             :   /// number of local particles
     134             :   unsigned int _n_local_particles = 0;
     135             : 
     136             :   /// stores the location of
     137             :   MDParticles _md_particles;
     138             : 
     139             :   /// a map from elem unique id to particles in this element
     140             :   std::map<unique_id_type, std::vector<unsigned int>> _elem_particles;
     141             : 
     142             :   /// a map from element unique id to std::vector of pair(MD particle id, volume of gran. particle in this element)
     143             :   std::map<unique_id_type, std::vector<std::pair<unsigned int, Real>>> _elem_granular_volumes;
     144             : 
     145             :   /// A KDTree object to handle md_particles
     146             :   std::unique_ptr<KDTree> _kd_tree;
     147             : };

Generated by: LCOV version 1.14