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  {
305  if constexpr (MooseUtils::canBroadcast<T>::value)
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 (static_cast<int>(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 ((static_cast<int>(producer) == REPORTER_MODE_ROOT &&
387  consumer == REPORTER_MODE_DISTRIBUTED) ||
388  (static_cast<int>(producer) == REPORTER_MODE_REPLICATED &&
389  consumer == REPORTER_MODE_DISTRIBUTED) ||
390  (static_cast<int>(producer) == REPORTER_MODE_DISTRIBUTED &&
391  consumer == REPORTER_MODE_ROOT) ||
392  (static_cast<int>(producer) == REPORTER_MODE_DISTRIBUTED &&
393  consumer == REPORTER_MODE_REPLICATED))
394  mooseError("The Reporter value \"",
395  name(),
396  "\" is being produced in ",
397  producer,
398  " mode, but the ",
399  moose_object->typeAndName(),
400  " is requesting to consume it in ",
401  consumer,
402  " mode, which is not supported.");
403  }
404 
405  // Perform desired auto parallel operation
406  if (auto_operation == ReporterContext::AutoOperation::BROADCAST)
407  this->broadcast();
408 }
409 
410 template <typename T>
411 void
413 {
414  _state.copyValuesBack();
415 }
416 
417 template <typename T>
418 void
419 ReporterContext<T>::storeInfo(nlohmann::json & json) const
420 {
421  json["type"] = this->type();
422 }
423 
424 template <typename T>
425 void
426 ReporterContext<T>::store(nlohmann::json & json) const
427 {
428  nlohmann::to_json(json, this->_state.value());
429 }
430 
431 template <typename T>
433 {
434 public:
436  const MooseObject & producer,
438  : ReporterContext<T>(other, producer, state)
439  {
440  }
442  const MooseObject & producer,
444  const T & default_value)
445  : ReporterContext<T>(other, producer, state, default_value)
446  {
447  }
448 
455  virtual void declareClone(ReporterData & r_data,
456  const ReporterName & r_name,
457  const ReporterMode & mode,
458  const MooseObject & producer) const override;
465  virtual void declareVectorClone(ReporterData & r_data,
466  const ReporterName & r_name,
467  const ReporterMode & mode,
468  const MooseObject & producer) const override;
469 
470  virtual void resize(dof_id_type local_size) final;
471  virtual void clear() final;
472  virtual void vectorSum() final;
473 
474  virtual std::string contextType() const override { return MooseUtils::prettyCppType(this); }
475 };
476 
477 // Needed for compile-time checking if T is a vector.
478 template <typename>
479 struct is_std_vector : std::false_type
480 {
481 };
482 
483 template <typename T, typename A>
484 struct is_std_vector<std::vector<T, A>> : std::true_type
485 {
486 };
487 
488 template <typename T>
489 void
491 {
492  if constexpr (is_std_vector<T>::value)
493  this->_state.value().resize(size);
494  else
495  {
496  libmesh_ignore(size);
497  mooseError("Cannot resize non vector-type reporter values.");
498  }
499 }
500 template <typename T>
501 void
503 {
504  if constexpr (is_std_vector<T>::value)
505  this->_state.value().clear();
506  else
507  mooseError("Cannot clear non vector-type reporter values.");
508 }
509 
510 template <typename T>
511 void
513 {
514  // Case 1: T is a numeric type that we can sum (excluding bool)
515  if constexpr (std::is_arithmetic<T>::value && !std::is_same<T, bool>::value)
516  {
517  // Perform summation of the scalar value across all processors
518  this->comm().sum(this->_state.value());
519  return;
520  }
521  // Case 2: T is a vector type
522  else if constexpr (is_std_vector<T>::value)
523  {
524  using VectorValueType = typename T::value_type;
525 
526  // Check if the vector elements are of a numeric type
527  if constexpr (std::is_arithmetic<VectorValueType>::value &&
528  !std::is_same<VectorValueType, bool>::value)
529  {
530  // Perform summation of the vector elements across all processors
531  this->comm().sum(this->_state.value());
532  return;
533  }
534  // Check if the vector elements are also vectors
535  else if constexpr (is_std_vector<VectorValueType>::value)
536  {
537  using InnerValueType = typename VectorValueType::value_type;
538 
539  // Check if the inner vector elements are of a numeric type
540  if constexpr (std::is_arithmetic<InnerValueType>::value &&
541  !std::is_same<InnerValueType, bool>::value)
542  {
543 #ifdef DEBUG
544  auto vec_size = this->_state.value().size();
545  this->comm().max(vec_size);
546  // Assert only passes on all ranks if they are all the same size.
547  mooseAssert(this->_state.value().size() == vec_size,
548  "Reporter vector have different sizes on different ranks.");
549 #endif
550  // Iterate over each inner vector in the outer vector
551  for (auto & innerVector : this->_state.value())
552  {
553  // Get the maximum size of the inner vector across all processors
554  dof_id_type maxInnerSize = innerVector.size();
555  this->comm().max(maxInnerSize);
556 
557  // Resize the inner vector to the maximum size
558  innerVector.resize(maxInnerSize);
559 
560  // Perform summation of the inner vector elements across all processors
561  this->comm().sum(innerVector);
562  }
563  return;
564  }
565  }
566  }
567 
568  mooseError("Cannot perform sum operation on non-numeric or unsupported vector types.");
569 }
570 
574 template <typename T>
576 {
577 public:
579  const MooseObject & producer,
582  const MooseObject & producer,
584  const T & default_value);
585  virtual void finalize() override;
586  virtual std::string contextType() const override { return MooseUtils::prettyCppType(this); }
587 };
588 
589 template <typename T>
591  const MooseObject & producer,
592  ReporterState<T> & state)
593  : ReporterGeneralContext<T>(other, producer, state)
594 {
595  this->_producer_enum.clear();
597 }
598 
599 template <typename T>
601  const MooseObject & producer,
602  ReporterState<T> & state,
603  const T & default_value)
604  : ReporterGeneralContext<T>(other, producer, state, default_value)
605 {
606  this->_producer_enum.clear();
608 }
609 
610 template <typename T>
611 void
613 {
614  this->requiresConsumerModes(this->_state, {REPORTER_MODE_UNSET, REPORTER_MODE_REPLICATED});
615  this->broadcast();
616 }
617 
621 template <typename T>
623 {
624 public:
626  const MooseObject & producer,
628  const std::vector<T> & values);
630  const MooseObject & producer,
632  const T & default_value,
633  const std::vector<T> & values);
634 
635  virtual void finalize() override;
636  virtual std::string contextType() const override { return MooseUtils::prettyCppType(this); }
637 
638 private:
640  const std::vector<T> & _values;
641 };
642 
643 template <typename T>
645  const MooseObject & producer,
646  ReporterState<T> & state,
647  const std::vector<T> & values)
648  : ReporterGeneralContext<T>(other, producer, state), _values(values)
649 {
650  this->_producer_enum.clear();
652 }
653 
654 template <typename T>
656  const MooseObject & producer,
657  ReporterState<T> & state,
658  const T & default_value,
659  const std::vector<T> & values)
660  : ReporterGeneralContext<T>(other, producer, state, default_value), _values(values)
661 {
662  this->_producer_enum.clear();
664 }
665 
666 template <typename T>
667 void
669 {
670  this->requiresConsumerModes(this->_state, {REPORTER_MODE_UNSET, REPORTER_MODE_REPLICATED});
671 
672  mooseAssert(this->processor_id() == 0 ? _values.size() == this->n_processors() : true,
673  "Vector to be scattered must be sized to match the number of processors");
674  mooseAssert(
675  this->processor_id() > 0 ? _values.size() == 0 : true,
676  "Vector to be scattered must be sized to zero on processors except for the root processor");
677  this->comm().scatter(_values, this->_state.value());
678 }
679 
683 template <typename T>
685 {
686 public:
688  const MooseObject & producer,
691  const MooseObject & producer,
693  const T & default_value);
694 
695  virtual void finalize() override;
696  virtual std::string contextType() const override { return MooseUtils::prettyCppType(this); }
697 };
698 
699 template <typename T>
701  const MooseObject & producer,
702  ReporterState<T> & state)
703  : ReporterGeneralContext<T>(other, producer, state)
704 {
705  this->_producer_enum.clear();
707 }
708 
709 template <typename T>
711  const MooseObject & producer,
712  ReporterState<T> & state,
713  const T & default_value)
714  : ReporterGeneralContext<T>(other, producer, state, default_value)
715 {
716  this->_producer_enum.clear();
718 }
719 
720 template <typename T>
721 void
723 {
724  this->requiresConsumerModes(this->_state, {REPORTER_MODE_UNSET, REPORTER_MODE_ROOT});
725  this->comm().gather(0, this->_state.value());
726 }
727 
734 template <typename T>
735 class ReporterVectorContext : public ReporterContext<std::vector<T>>
736 {
737 public:
739  const MooseObject & producer,
740  ReporterState<std::vector<T>> & state);
742  const MooseObject & producer,
743  ReporterState<std::vector<T>> & state,
744  const std::vector<T> & default_value);
745 
750  virtual void declareClone(ReporterData & r_data,
751  const ReporterName & r_name,
752  const ReporterMode & mode,
753  const MooseObject & producer) const final;
754 
759  virtual void declareVectorClone(ReporterData & r_data,
760  const ReporterName & r_name,
761  const ReporterMode & mode,
762  const MooseObject & producer) const final;
763 
768  virtual void resize(dof_id_type local_size) override { this->_state.value().resize(local_size); }
769 
773  virtual void clear() override { this->_state.value().clear(); }
774 
775  virtual void vectorSum() override
776  {
777  // Case 1: T is type that we can sum
778  if constexpr (std::is_arithmetic<T>::value &&
779  !std::is_same<T, bool>::value) // We can't sum bools.
780  {
781  // Resize vector to max size
782  dof_id_type vec_size = this->_state.value().size();
783  this->comm().max(vec_size);
784  this->_state.value().resize(vec_size);
785 
786  this->comm().sum(this->_state.value());
787  return;
788  }
789  // Case 2: T is a vector
790  else if constexpr (is_std_vector<T>::value)
791  {
792  // Resize vector to max size
793  dof_id_type vec_size = this->_state.value().size();
794  this->comm().max(vec_size);
795  this->_state.value().resize(vec_size);
796 
797  using ValueType = typename T::value_type;
798  // Check if the ValueType is a vector
799  if constexpr (std::is_arithmetic<ValueType>::value && !std::is_same<ValueType, bool>::value)
800  {
801 #ifdef DEBUG
802  auto vec_size = this->_state.value().size();
803  this->comm().max(vec_size);
804  // Assert only passes on all ranks if they are all the same size.
805  mooseAssert(this->_state.value().size() == vec_size,
806  "Reporter vector have different sizes on different ranks.");
807 #endif
808  for (auto & val_vec : this->_state.value())
809  {
810  // Resize vector to max size
811  dof_id_type val_vec_size = val_vec.size();
812  this->comm().max(val_vec_size);
813  val_vec.resize(val_vec_size);
814 
815  this->comm().sum(val_vec);
816  }
817  return;
818  }
819  }
820  // If we don't perform a summing operation, error out.
821  mooseError("Cannot perform sum operation on non-numeric or unsupported vector types.");
822  }
823 
824  virtual std::string contextType() const override { return MooseUtils::prettyCppType(this); }
825 };
826 
827 template <typename T>
829  const MooseObject & producer,
830  ReporterState<std::vector<T>> & state)
831  : ReporterContext<std::vector<T>>(other, producer, state)
832 {
833 }
834 
835 template <typename T>
837  const MooseObject & producer,
838  ReporterState<std::vector<T>> & state,
839  const std::vector<T> & default_value)
840  : ReporterContext<std::vector<T>>(other, producer, state, default_value)
841 {
842 }
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:605
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:515
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:311
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:62
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:583
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)
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:57
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:525
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:542
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:594
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:572
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:104
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:45
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:1140
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