LCOV - code coverage report
Current view: top level - include/postprocessors - GrainDataTracker.h (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31405 (292dce) with base fef103 Lines: 0 9 0.0 %
Date: 2025-09-04 07:55:36 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          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 "GrainTracker.h"
      13             : 
      14             : /**
      15             :  * GrainTracker derived class template to base objects on which maintain physical
      16             :  * parameters for individual grains.
      17             :  */
      18             : template <typename T>
      19             : class GrainDataTracker : public GrainTracker
      20             : {
      21             : public:
      22             :   GrainDataTracker(const InputParameters & parameters);
      23             : 
      24             :   /// return data for selected grain
      25             :   const T & getData(unsigned int grain_id) const;
      26             : 
      27             : protected:
      28             :   /// implement this method to initialize the data for the new grain
      29             :   virtual T newGrain(unsigned int new_grain_id) = 0;
      30             : 
      31             :   virtual void newGrainCreated(unsigned int new_grain_id);
      32             : 
      33             :   /// per grain data
      34             :   std::vector<T> & _grain_data;
      35             : };
      36             : 
      37             : template <typename T>
      38           0 : GrainDataTracker<T>::GrainDataTracker(const InputParameters & parameters)
      39           0 :   : GrainTracker(parameters), _grain_data(declareRestartableData<std::vector<T>>("grain_data"))
      40             : {
      41           0 : }
      42             : 
      43             : template <typename T>
      44             : const T &
      45             : GrainDataTracker<T>::getData(unsigned int grain_id) const
      46             : {
      47             :   mooseAssert(grain_id < _grain_data.size(), "Requested data for invalid grain index.");
      48           0 :   return _grain_data[grain_id];
      49             : }
      50             : 
      51             : template <typename T>
      52             : void
      53           0 : GrainDataTracker<T>::newGrainCreated(unsigned int new_grain_id)
      54             : {
      55           0 :   if (_grain_data.size() <= new_grain_id)
      56           0 :     _grain_data.resize(new_grain_id + 1);
      57             : 
      58           0 :   _grain_data[new_grain_id] = newGrain(new_grain_id);
      59           0 : }

Generated by: LCOV version 1.14