https://mooseframework.inl.gov
ReporterContext.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 #pragma once
10 
11 #include <iostream>
12 #include <typeinfo>
13 
14 #include "MooseError.h"
15 #include "libmesh/id_types.h"
16 #include "libmesh/parallel.h"
17 #include "libmesh/parallel_object.h"
18 
19 #include "ReporterName.h"
20 #include "ReporterMode.h"
21 #include "ReporterState.h"
22 #include "JsonIO.h"
23 #include "JsonSyntaxTree.h"
24 #include "MooseObject.h"
25 #include <type_traits>
26 
27 class ReporterData;
28 
58 {
59 public:
60  ReporterContextBase(const libMesh::ParallelObject & other, const MooseObject & producer);
61  virtual ~ReporterContextBase() = default;
62 
64  virtual const ReporterName & name() const = 0;
65 
67  // This is a helper for ReporterContext::storeInfo
68  virtual std::string type() const = 0;
69 
75  virtual std::string contextType() const = 0;
76 
78  virtual void copyValuesBack() = 0;
79 
81  virtual bool restoreState() = 0;
82 
85  virtual void storeInfo(nlohmann::json & json) const = 0;
86 
100  virtual void store(nlohmann::json & json) const = 0;
101 
103  virtual void finalize() = 0; // new ReporterContext objects should override
104 
113  void init(const ReporterMode & mode);
114 
118  const MooseObject & getProducer() const { return _producer; }
119 
124 
132  virtual void transfer(ReporterData & r_data,
133  const ReporterName & r_name,
134  unsigned int time_index = 0) const = 0;
135 
143  virtual void transferToVector(ReporterData & r_data,
144  const ReporterName & r_name,
145  dof_id_type index,
146  unsigned int time_index = 0) const = 0;
147 
156  virtual void transferFromVector(ReporterData & r_data,
157  const ReporterName & r_name,
158  dof_id_type index,
159  unsigned int time_index = 0) const = 0;
160 
170  virtual void declareClone(ReporterData & r_data,
171  const ReporterName & r_name,
172  const ReporterMode & mode,
173  const MooseObject & producer) const = 0;
174 
184  virtual void declareVectorClone(ReporterData & r_data,
185  const ReporterName & r_name,
186  const ReporterMode & mode,
187  const MooseObject & producer) const = 0;
188 
194  virtual void resize(dof_id_type local_size) = 0;
195 
199  virtual void clear() = 0;
200 
204  virtual void vectorSum() = 0;
205 
206 protected:
210  void requiresConsumerModes(const ReporterStateBase & state,
211  const std::set<ReporterMode> & modes) const;
212 
215 
218 };
219 
227 template <typename T>
229 {
230 public:
234  enum class AutoOperation
235  {
236  NONE,
237  BROADCAST
238  };
239 
241  const MooseObject & producer,
244  const MooseObject & producer,
246  const T & default_value);
247 
251  const ReporterName & name() const override final { return _state.getReporterName(); }
252 
256  const ReporterState<T> & state() const { return _state; }
257 
263  virtual std::string type() const override { return MooseUtils::prettyCppType<T>(); }
264 
268  virtual void finalize() override;
269 
276  virtual void transfer(ReporterData & r_data,
277  const ReporterName & r_name,
278  unsigned int time_index = 0) const override;
279 
286  virtual void transferToVector(ReporterData & r_data,
287  const ReporterName & r_name,
288  dof_id_type index,
289  unsigned int time_index = 0) const override;
290 
297  virtual void transferFromVector(ReporterData & r_data,
298  const ReporterName & r_name,
299  dof_id_type index,
300  unsigned int time_index = 0) const override;
301 
302 protected:
303  void broadcast()
304  {
306  this->comm().broadcast(this->_state.value());
307  else
308  mooseError("Cannot broadcast Reporter type '", MooseUtils::prettyCppType<T>(), "'");
309  }
310 
312  virtual void storeInfo(nlohmann::json & json) const override;
313 
315  virtual void store(nlohmann::json & json) const override;
316 
317  virtual std::string contextType() const override = 0;
318 
319  // The following are called by the ReporterData and are not indented for external use
320  virtual void copyValuesBack() override;
321 
323  virtual bool restoreState() override { return _state.restoreState(); }
324 
327 };
328 
329 template <typename T>
331  const MooseObject & producer,
332  ReporterState<T> & state)
333  : ReporterContextBase(other, producer), _state(state)
334 {
336 }
337 
338 template <typename T>
340  const MooseObject & producer,
341  ReporterState<T> & state,
342  const T & default_value)
343  : ReporterContext(other, producer, state)
344 {
345  _state.value() = default_value;
346 }
347 
348 template <typename T>
349 void
351 {
352  // Automatic parallel operation to perform
354 
355  // Set the default producer mode to ROOT
356  if (!_producer_enum.isValid())
357  _producer_enum.assign(REPORTER_MODE_ROOT);
358 
359  // Determine auto parallel operation to perform
360  const auto & producer = _producer_enum; // convenience
361  for (const auto & pair : _state.getConsumers())
362  {
363  const ReporterMode consumer = pair.first;
364  const MooseObject * moose_object = pair.second;
365 
366  // The following sets up the automatic operations and performs error checking for the various
367  // modes for the producer and consumer
368  //
369  // The data is correct and requires no operation for the following conditions (PRODUCER ->
370  // CONSUMER)
371  // ROOT -> ROOT
372  // REPLICATED -> REPLICATED
373  // DISTRIBUTED -> DISTRIBUTED
374  // REPLICATED -> ROOT
375 
376  // Perform broadcast in the case
377  // ROOT -> REPLICATED
378  if (producer == REPORTER_MODE_ROOT && consumer == REPORTER_MODE_REPLICATED)
380 
381  // The following are not support and create an error
382  // ROOT -> DISTRIBUTED
383  // REPLICATED -> DISTRIBUTED
384  // DISTRIBUTED -> ROOT
385  // DISTRIBUTED -> REPLICATED
386  else if ((producer == REPORTER_MODE_ROOT && consumer == REPORTER_MODE_DISTRIBUTED) ||
387  (producer == REPORTER_MODE_REPLICATED && consumer == REPORTER_MODE_DISTRIBUTED) ||
388  (producer == REPORTER_MODE_DISTRIBUTED && consumer == REPORTER_MODE_ROOT) ||
389  (producer == REPORTER_MODE_DISTRIBUTED && consumer == REPORTER_MODE_REPLICATED))
390  mooseError("The Reporter value \"",
391  name(),
392  "\" is being produced in ",
393  producer,
394  " mode, but the ",
395  moose_object->typeAndName(),
396  " is requesting to consume it in ",
397  consumer,
398  " mode, which is not supported.");
399  }
400 
401  // Perform desired auto parallel operation
402  if (auto_operation == ReporterContext::AutoOperation::BROADCAST)
403  this->broadcast();
404 }
405 
406 template <typename T>
407 void
409 {
410  _state.copyValuesBack();
411 }
412 
413 template <typename T>
414 void
415 ReporterContext<T>::storeInfo(nlohmann::json & json) const
416 {
417  json["type"] = this->type();
418 }
419 
420 template <typename T>
421 void
422 ReporterContext<T>::store(nlohmann::json & json) const
423 {
424  nlohmann::to_json(json, this->_state.value());
425 }
426 
427 template <typename T>
429 {
430 public:
432  const MooseObject & producer,
434  : ReporterContext<T>(other, producer, state)
435  {
436  }
438  const MooseObject & producer,
440  const T & default_value)
441  : ReporterContext<T>(other, producer, state, default_value)
442  {
443  }
444 
451  virtual void declareClone(ReporterData & r_data,
452  const ReporterName & r_name,
453  const ReporterMode & mode,
454  const MooseObject & producer) const override;
461  virtual void declareVectorClone(ReporterData & r_data,
462  const ReporterName & r_name,
463  const ReporterMode & mode,
464  const MooseObject & producer) const override;
465 
466  virtual void resize(dof_id_type local_size) final;
467  virtual void clear() final;
468  virtual void vectorSum() final;
469 
470  virtual std::string contextType() const override { return MooseUtils::prettyCppType(this); }
471 };
472 
473 // Needed for compile-time checking if T is a vector.
474 template <typename>
475 struct is_std_vector : std::false_type
476 {
477 };
478 
479 template <typename T, typename A>
480 struct is_std_vector<std::vector<T, A>> : std::true_type
481 {
482 };
483 
484 template <typename T>
485 void
487 {
488  if constexpr (is_std_vector<T>::value)
489  this->_state.value().resize(size);
490  else
491  {
492  libmesh_ignore(size);
493  mooseError("Cannot resize non vector-type reporter values.");
494  }
495 }
496 template <typename T>
497 void
499 {
500  if constexpr (is_std_vector<T>::value)
501  this->_state.value().clear();
502  else
503  mooseError("Cannot clear non vector-type reporter values.");
504 }
505 
506 template <typename T>
507 void
509 {
510  // Case 1: T is a numeric type that we can sum (excluding bool)
511  if constexpr (std::is_arithmetic<T>::value && !std::is_same<T, bool>::value)
512  {
513  // Perform summation of the scalar value across all processors
514  this->comm().sum(this->_state.value());
515  return;
516  }
517  // Case 2: T is a vector type
518  else if constexpr (is_std_vector<T>::value)
519  {
520  using VectorValueType = typename T::value_type;
521 
522  // Check if the vector elements are of a numeric type
523  if constexpr (std::is_arithmetic<VectorValueType>::value &&
524  !std::is_same<VectorValueType, bool>::value)
525  {
526  // Perform summation of the vector elements across all processors
527  this->comm().sum(this->_state.value());
528  return;
529  }
530  // Check if the vector elements are also vectors
531  else if constexpr (is_std_vector<VectorValueType>::value)
532  {
533  using InnerValueType = typename VectorValueType::value_type;
534 
535  // Check if the inner vector elements are of a numeric type
536  if constexpr (std::is_arithmetic<InnerValueType>::value &&
537  !std::is_same<InnerValueType, bool>::value)
538  {
539 #ifdef DEBUG
540  auto vec_size = this->_state.value().size();
541  this->comm().max(vec_size);
542  // Assert only passes on all ranks if they are all the same size.
543  mooseAssert(this->_state.value().size() == vec_size,
544  "Reporter vector have different sizes on different ranks.");
545 #endif
546  // Iterate over each inner vector in the outer vector
547  for (auto & innerVector : this->_state.value())
548  {
549  // Get the maximum size of the inner vector across all processors
550  dof_id_type maxInnerSize = innerVector.size();
551  this->comm().max(maxInnerSize);
552 
553  // Resize the inner vector to the maximum size
554  innerVector.resize(maxInnerSize);
555 
556  // Perform summation of the inner vector elements across all processors
557  this->comm().sum(innerVector);
558  }
559  return;
560  }
561  }
562  }
563 
564  mooseError("Cannot perform sum operation on non-numeric or unsupported vector types.");
565 }
566 
570 template <typename T>
572 {
573 public:
575  const MooseObject & producer,
578  const MooseObject & producer,
580  const T & default_value);
581  virtual void finalize() override;
582  virtual std::string contextType() const override { return MooseUtils::prettyCppType(this); }
583 };
584 
585 template <typename T>
587  const MooseObject & producer,
588  ReporterState<T> & state)
589  : ReporterGeneralContext<T>(other, producer, state)
590 {
591  this->_producer_enum.clear();
593 }
594 
595 template <typename T>
597  const MooseObject & producer,
598  ReporterState<T> & state,
599  const T & default_value)
600  : ReporterGeneralContext<T>(other, producer, state, default_value)
601 {
602  this->_producer_enum.clear();
604 }
605 
606 template <typename T>
607 void
609 {
610  this->requiresConsumerModes(this->_state, {REPORTER_MODE_UNSET, REPORTER_MODE_REPLICATED});
611  this->broadcast();
612 }
613 
617 template <typename T>
619 {
620 public:
622  const MooseObject & producer,
624  const std::vector<T> & values);
626  const MooseObject & producer,
628  const T & default_value,
629  const std::vector<T> & values);
630 
631  virtual void finalize() override;
632  virtual std::string contextType() const override { return MooseUtils::prettyCppType(this); }
633 
634 private:
636  const std::vector<T> & _values;
637 };
638 
639 template <typename T>
641  const MooseObject & producer,
642  ReporterState<T> & state,
643  const std::vector<T> & values)
644  : ReporterGeneralContext<T>(other, producer, state), _values(values)
645 {
646  this->_producer_enum.clear();
648 }
649 
650 template <typename T>
652  const MooseObject & producer,
653  ReporterState<T> & state,
654  const T & default_value,
655  const std::vector<T> & values)
656  : ReporterGeneralContext<T>(other, producer, state, default_value), _values(values)
657 {
658  this->_producer_enum.clear();
660 }
661 
662 template <typename T>
663 void
665 {
666  this->requiresConsumerModes(this->_state, {REPORTER_MODE_UNSET, REPORTER_MODE_REPLICATED});
667 
668  mooseAssert(this->processor_id() == 0 ? _values.size() == this->n_processors() : true,
669  "Vector to be scattered must be sized to match the number of processors");
670  mooseAssert(
671  this->processor_id() > 0 ? _values.size() == 0 : true,
672  "Vector to be scattered must be sized to zero on processors except for the root processor");
673  this->comm().scatter(_values, this->_state.value());
674 }
675 
679 template <typename T>
681 {
682 public:
684  const MooseObject & producer,
687  const MooseObject & producer,
689  const T & default_value);
690 
691  virtual void finalize() override;
692  virtual std::string contextType() const override { return MooseUtils::prettyCppType(this); }
693 };
694 
695 template <typename T>
697  const MooseObject & producer,
698  ReporterState<T> & state)
699  : ReporterGeneralContext<T>(other, producer, state)
700 {
701  this->_producer_enum.clear();
703 }
704 
705 template <typename T>
707  const MooseObject & producer,
708  ReporterState<T> & state,
709  const T & default_value)
710  : ReporterGeneralContext<T>(other, producer, state, default_value)
711 {
712  this->_producer_enum.clear();
714 }
715 
716 template <typename T>
717 void
719 {
720  this->requiresConsumerModes(this->_state, {REPORTER_MODE_UNSET, REPORTER_MODE_ROOT});
721  this->comm().gather(0, this->_state.value());
722 }
723 
730 template <typename T>
731 class ReporterVectorContext : public ReporterContext<std::vector<T>>
732 {
733 public:
735  const MooseObject & producer,
736  ReporterState<std::vector<T>> & state);
738  const MooseObject & producer,
739  ReporterState<std::vector<T>> & state,
740  const std::vector<T> & default_value);
741 
746  virtual void declareClone(ReporterData & r_data,
747  const ReporterName & r_name,
748  const ReporterMode & mode,
749  const MooseObject & producer) const final;
750 
755  virtual void declareVectorClone(ReporterData & r_data,
756  const ReporterName & r_name,
757  const ReporterMode & mode,
758  const MooseObject & producer) const final;
759 
764  virtual void resize(dof_id_type local_size) override { this->_state.value().resize(local_size); }
765 
769  virtual void clear() override { this->_state.value().clear(); }
770 
771  virtual void vectorSum() override
772  {
773  // Case 1: T is type that we can sum
774  if constexpr (std::is_arithmetic<T>::value &&
775  !std::is_same<T, bool>::value) // We can't sum bools.
776  {
777  // Resize vector to max size
778  dof_id_type vec_size = this->_state.value().size();
779  this->comm().max(vec_size);
780  this->_state.value().resize(vec_size);
781 
782  this->comm().sum(this->_state.value());
783  return;
784  }
785  // Case 2: T is a vector
786  else if constexpr (is_std_vector<T>::value)
787  {
788  // Resize vector to max size
789  dof_id_type vec_size = this->_state.value().size();
790  this->comm().max(vec_size);
791  this->_state.value().resize(vec_size);
792 
793  using ValueType = typename T::value_type;
794  // Check if the ValueType is a vector
795  if constexpr (std::is_arithmetic<ValueType>::value && !std::is_same<ValueType, bool>::value)
796  {
797 #ifdef DEBUG
798  auto vec_size = this->_state.value().size();
799  this->comm().max(vec_size);
800  // Assert only passes on all ranks if they are all the same size.
801  mooseAssert(this->_state.value().size() == vec_size,
802  "Reporter vector have different sizes on different ranks.");
803 #endif
804  for (auto & val_vec : this->_state.value())
805  {
806  // Resize vector to max size
807  dof_id_type val_vec_size = val_vec.size();
808  this->comm().max(val_vec_size);
809  val_vec.resize(val_vec_size);
810 
811  this->comm().sum(val_vec);
812  }
813  return;
814  }
815  }
816  // If we don't perform a summing operation, error out.
817  mooseError("Cannot perform sum operation on non-numeric or unsupported vector types.");
818  }
819 
820  virtual std::string contextType() const override { return MooseUtils::prettyCppType(this); }
821 };
822 
823 template <typename T>
825  const MooseObject & producer,
826  ReporterState<std::vector<T>> & state)
827  : ReporterContext<std::vector<T>>(other, producer, state)
828 {
829 }
830 
831 template <typename T>
833  const MooseObject & producer,
834  ReporterState<std::vector<T>> & state,
835  const std::vector<T> & default_value)
836  : ReporterContext<std::vector<T>>(other, producer, state, default_value)
837 {
838 }
std::string name(const ElemQuality q)
virtual void finalize() override
Perform automatic parallel communication based on the producer/consumer modes.
virtual void declareVectorClone(ReporterData &r_data, const ReporterName &r_name, const ReporterMode &mode, const MooseObject &producer) const final
This simply throws an error to avoid infinite instantiations.
Definition: ReporterData.h:592
A special version of RestartableData to aid in storing Reporter values.
virtual void storeInfo(nlohmann::json &json) const override
Output meta data to JSON, see JSONOutput.
const ReporterName & name() const override final
Return the name of the Reporter value.
void init(const ReporterMode &mode)
Initialize the producer mode.
virtual void transfer(ReporterData &r_data, const ReporterName &r_name, unsigned int time_index=0) const override
Perform type specific transfer.
Definition: ReporterData.h:502
virtual void declareVectorClone(ReporterData &r_data, const ReporterName &r_name, const ReporterMode &mode, const MooseObject &producer) const =0
Helper for declaring new vector reporter values based on this context.
ReporterGeneralContext(const libMesh::ParallelObject &other, const MooseObject &producer, ReporterState< T > &state, const T &default_value)
This context is specific for vector types of reporters, mainly for declaring a vector of the type fro...
const ReporterMode REPORTER_MODE_UNSET
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302
virtual void transferFromVector(ReporterData &r_data, const ReporterName &r_name, dof_id_type index, unsigned int time_index=0) const =0
Helper for enabling generic transfer of a vector Reporter of values to a single value.
const ReporterMode REPORTER_MODE_ROOT
virtual std::string contextType() const override=0
const ReporterState< T > & state() const
Return a reference to the ReporterState object that is storing the Reporter value.
ReporterGeneralContext(const libMesh::ParallelObject &other, const MooseObject &producer, ReporterState< T > &state)
A context that scatters the Reporter value from the root processor.
virtual ~ReporterContextBase()=default
MooseEnum designed for the ReporterContext objects to define how a ReporterValue can and is being pro...
Definition: ReporterMode.h:61
virtual std::string type() const =0
Return the type of the data stored.
ReporterVectorContext(const libMesh::ParallelObject &other, const MooseObject &producer, ReporterState< std::vector< T >> &state)
virtual void declareClone(ReporterData &r_data, const ReporterName &r_name, const ReporterMode &mode, const MooseObject &producer) const =0
Helper for declaring new reporter values based on this context.
ReporterScatterContext(const libMesh::ParallelObject &other, const MooseObject &producer, ReporterState< T > &state, const std::vector< T > &values)
virtual const ReporterName & name() const =0
Return the ReporterName that the context is associated.
void clear()
Clear all available items (i.e., create an empty MooseEnum)
Definition: ReporterMode.C:29
const std::vector< T > & _values
The values to scatter.
ReporterState< T > & _state
The state on which this context object operates.
const Parallel::Communicator & comm() const
virtual void declareVectorClone(ReporterData &r_data, const ReporterName &r_name, const ReporterMode &mode, const MooseObject &producer) const override
Declare a reporter value that is a vector of the same type as this context.
Definition: ReporterData.h:570
virtual void clear() override
Since we know that the _state value is a vector type, we can clear it.
virtual void clear()=0
Helper for clearing vector data.
ReporterContextBase(const libMesh::ParallelObject &other, const MooseObject &producer)
Custom type trait that has a value of true for types that can be broadcasted.
Definition: MooseUtils.h:1024
virtual void vectorSum() override
Helper for summing reporter value.
void libmesh_ignore(const Args &...)
virtual void transferToVector(ReporterData &r_data, const ReporterName &r_name, dof_id_type index, unsigned int time_index=0) const =0
Helper for enabling generic transfer of Reporter values to a vector.
virtual void store(nlohmann::json &json) const override
Output data to JSON, see JSONOutput.
A context that gathers the Reporter value to the root processor.
virtual std::string contextType() const =0
This is a helper class to aid with parallel communication of compute Reporter values as well as provi...
virtual void store(nlohmann::json &json) const =0
Called by JSONOutput::outputReporters to invoke storage of values for output.
ReporterContext(const libMesh::ParallelObject &other, const MooseObject &producer, ReporterState< T > &state)
const ReporterProducerEnum & getProducerModeEnum() const
Return the Reporter value produced mode.
ReporterGatherContext(const libMesh::ParallelObject &other, const MooseObject &producer, ReporterState< T > &state)
virtual void vectorSum() final
Helper for summing reporter value.
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:28
virtual void finalize()=0
Called by FEProblemBase::joinAndFinalize via ReporterData.
virtual void copyValuesBack()=0
Called by FEProblemBase::advanceState via ReporterData.
void requiresConsumerModes(const ReporterStateBase &state, const std::set< ReporterMode > &modes) const
Helper for checking whether or not the state state has only the modes modes.
virtual void resize(dof_id_type local_size) override
Since we know that the _state value is a vector type, we can resize it based on.
virtual bool restoreState()=0
Called by FEProblemBase::restoreSolutions via ReporterData.
AutoOperation
Options for automatic parallel operations to perform by the default context.
virtual std::string contextType() const override
virtual void resize(dof_id_type local_size)=0
Helper for resizing vector data.
virtual std::string contextType() const override
ReporterBroadcastContext(const libMesh::ParallelObject &other, const MooseObject &producer, ReporterState< T > &state)
The base class for storing a Reporter&#39;s state.
Definition: ReporterState.h:32
std::string typeAndName() const
Get the class&#39;s combined type and name; useful in error handling.
Definition: MooseBase.C:27
const ReporterMode REPORTER_MODE_DISTRIBUTED
virtual void transferToVector(ReporterData &r_data, const ReporterName &r_name, dof_id_type index, unsigned int time_index=0) const override
Perform type specific transfer to a vector.
Definition: ReporterData.h:512
virtual std::string contextType() const override
virtual void clear() final
Helper for clearing vector data.
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
virtual void transferFromVector(ReporterData &r_data, const ReporterName &r_name, dof_id_type index, unsigned int time_index=0) const override
Perform type specific transfer from a vector.
Definition: ReporterData.h:529
virtual void declareClone(ReporterData &r_data, const ReporterName &r_name, const ReporterMode &mode, const MooseObject &producer) const final
This simply throws an error to avoid infinite instantiations.
Definition: ReporterData.h:581
virtual void finalize() override
Perform automatic parallel communication based on the producer/consumer modes.
virtual void storeInfo(nlohmann::json &json) const =0
Called by JSONOutput::outputReporters to output meta data independent of calculated values...
virtual void copyValuesBack() override
Called by FEProblemBase::advanceState via ReporterData.
virtual void declareClone(ReporterData &r_data, const ReporterName &r_name, const ReporterMode &mode, const MooseObject &producer) const override
Declare a reporter value of same type as this context.
Definition: ReporterData.h:559
virtual void transfer(ReporterData &r_data, const ReporterName &r_name, unsigned int time_index=0) const =0
Helper for enabling generic transfer of Reporter values.
void max(const T &r, T &o, Request &req) const
virtual std::string type() const override
Return the type being stored by the associated ReporterState object.
virtual void finalize() override
Perform automatic parallel communication based on the producer/consumer modes.
void insert(const ReporterMode &mode, Args... modes)
Definition: ReporterMode.h:79
virtual void vectorSum()=0
Helper for summing reporter value.
void to_json(nlohmann::json &json, const Moose::LibtorchArtificialNeuralNet *const &network)
virtual std::string contextType() const override
virtual void finalize() override
Perform automatic parallel communication based on the producer/consumer modes.
T & value(const std::size_t time_index=0)
Return a reference to the current value or one of the old values.
virtual std::string contextType() const override
const ReporterMode REPORTER_MODE_REPLICATED
General context that is called by all Reporter values to manage the old values.
A context that broadcasts the Reporter value from the root processor.
virtual void resize(dof_id_type local_size) final
Helper for resizing vector data.
const MooseObject & getProducer() const
Return the MooseObject that produces this Reporter.
ReporterProducerEnum _producer_enum
Defines how the Reporter value can be produced and how it is being produced.
MooseEnumItem that automatically creates the ID and doesn&#39;t allow the ID to be assigned.
Definition: ReporterMode.h:44
The Reporter system is comprised of objects that can contain any number of data values.
Definition: ReporterName.h:30
std::string prettyCppType(const std::string &cpp_type)
Definition: MooseUtils.C:1246
uint8_t dof_id_type
virtual bool restoreState() override
Restore state to its old values.
const MooseObject & _producer
The MooseObject that is producing this Reporter.
This is a helper class for managing the storage of declared Reporter object values.
Definition: ReporterData.h:48