https://mooseframework.inl.gov
NEML2BatchIndexGenerator.h
Go to the documentation of this file.
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 
14 #include <map>
15 
21 {
22 public:
24 
26 
27  void initialize() override;
28  void execute() override;
29  void threadJoin(const UserObject &) override;
30  void finalize() override;
31 
32  void meshChanged() override;
33 
35  std::size_t getBatchIndex() const { return _batch_index; }
36 
38  std::size_t getBatchIndex(dof_id_type elem_id) const;
39 
40 protected:
42  bool _outdated;
43 
45  std::size_t _batch_index;
46 
48  std::map<dof_id_type, std::size_t> _elem_to_batch_index;
49 
51  mutable std::pair<dof_id_type, std::size_t> _elem_to_batch_index_cache;
52 };
void initialize() override
Called before execute() is ever called so that data can be cleared.
std::size_t _batch_index
Highest current batch index.
std::map< dof_id_type, std::size_t > _elem_to_batch_index
Map from element IDs to batch indices.
void meshChanged() override
Called on this object when the mesh changes.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void execute() override
Execute method.
NEML2BatchIndexGenerator(const InputParameters &params)
void finalize() override
Finalize.
bool _outdated
Whether the batch index map is outdated.
std::pair< dof_id_type, std::size_t > _elem_to_batch_index_cache
cache the index for the current element
void threadJoin(const UserObject &) override
Must override.
static InputParameters validParams()
std::size_t getBatchIndex() const
Get the current batch index (in almost all cases this is the total batch size)
Base class for user-specific data.
Definition: UserObject.h:40
uint8_t dof_id_type
NEML2BatchIndexGenerator iterates over the mesh and generates a map from element ID to batch index wh...