LCOV - code coverage report
Current view: top level - include/utils - PolycrystalICTools.h (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31405 (292dce) with base fef103 Lines: 0 4 0.0 %
Date: 2025-09-04 07:55:36 Functions: 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 "Moose.h"
      13             : #include "libmesh/libmesh.h"
      14             : #include "InitialCondition.h"
      15             : 
      16             : namespace PolycrystalICTools
      17             : {
      18             : 
      19             : /**
      20             :  * Simple 2D block matrix indicating graph adjacency. We use a 1D
      21             :  * storage structure so that we can  pass it to PETSc easily.
      22             :  */
      23             : template <typename T>
      24             : class AdjacencyMatrix
      25             : {
      26             : public:
      27           0 :   AdjacencyMatrix(unsigned int size) : _size(size), _data(size * size) {}
      28             : 
      29           0 :   ~AdjacencyMatrix() = default;
      30             : 
      31             :   // Get rid of copy constructors
      32             :   AdjacencyMatrix(const AdjacencyMatrix & f) = delete;
      33             :   AdjacencyMatrix & operator=(const AdjacencyMatrix & f) = delete;
      34             : 
      35             :   // Use only move constructors
      36             :   AdjacencyMatrix(AdjacencyMatrix && /* f */) = default;
      37             :   AdjacencyMatrix & operator=(AdjacencyMatrix && /* f */) = default;
      38             : 
      39           0 :   T & operator()(unsigned int i, unsigned int j) { return _data[i * _size + j]; }
      40           0 :   T operator()(unsigned int i, unsigned int j) const { return _data[i * _size + j]; }
      41             : 
      42             :   std::size_t size() const { return _size; }
      43             :   T * rawDataPtr() { return _data.data(); }
      44             : 
      45             : private:
      46             :   const std::size_t _size;
      47             :   std::vector<T> _data;
      48             : };
      49             : 
      50             : std::vector<unsigned int> assignPointsToVariables(const std::vector<Point> & centerpoints,
      51             :                                                   const Real op_num,
      52             :                                                   const MooseMesh & mesh,
      53             :                                                   const MooseVariable & var);
      54             : 
      55             : unsigned int assignPointToGrain(const Point & p,
      56             :                                 const std::vector<Point> & centerpoints,
      57             :                                 const MooseMesh & mesh,
      58             :                                 const MooseVariable & var,
      59             :                                 const Real maxsize);
      60             : 
      61             : AdjacencyMatrix<Real>
      62             : buildGrainAdjacencyMatrix(const std::map<dof_id_type, unsigned int> & entity_to_grain,
      63             :                           MooseMesh & mesh,
      64             :                           const libMesh::PeriodicBoundaries * pb,
      65             :                           unsigned int n_grains,
      66             :                           bool is_elemental);
      67             : 
      68             : AdjacencyMatrix<Real>
      69             : buildElementalGrainAdjacencyMatrix(const std::map<dof_id_type, unsigned int> & element_to_grain,
      70             :                                    MooseMesh & mesh,
      71             :                                    const libMesh::PeriodicBoundaries * pb,
      72             :                                    unsigned int n_grains);
      73             : 
      74             : AdjacencyMatrix<Real>
      75             : buildNodalGrainAdjacencyMatrix(const std::map<dof_id_type, unsigned int> & node_to_grain,
      76             :                                MooseMesh & mesh,
      77             :                                const libMesh::PeriodicBoundaries * pb,
      78             :                                unsigned int n_grains);
      79             : 
      80             : std::vector<unsigned int> assignOpsToGrains(AdjacencyMatrix<Real> & adjacency_matrix,
      81             :                                             unsigned int n_grains,
      82             :                                             unsigned int n_ops,
      83             :                                             const MooseEnum & coloring_algorithm);
      84             : 
      85             : MooseEnum coloringAlgorithms();
      86             : 
      87             : std::string coloringAlgorithmDescriptions();
      88             : }

Generated by: LCOV version 1.14