23 "Gets the max/min/avg nodal value of a field function "
24 "among nodal values.");
28 "operation",
"The required operation to be performed.");
32 "operation", AllowableRangeList::New({
"max",
"min",
"avg"}));
40 chi_physics::GridBasedFieldFunctionInterface(params),
41 chi_mesh::LogicalVolumeInterface(params),
42 operation_(params.GetParamValue<std::string>(
"operation"))
52 "Attempted to access invalid field"
55 const auto& grid = grid_field_function->GetSpatialDiscretization().Grid();
58 if (logical_volume_ptr_ ==
nullptr)
61 for (
const auto& cell : grid.local_cells)
66 for (
const auto& cell : grid.local_cells)
67 if (logical_volume_ptr_->Inside(cell.centroid_))
82 "Attempted to access invalid field"
85 const auto& ref_ff = *grid_field_function;
86 const auto& sdm = ref_ff.GetSpatialDiscretization();
87 const auto& grid = sdm.Grid();
89 const auto& uk_man = ref_ff.GetUnknownManager();
93 const auto field_data = ref_ff.GetGhostedFieldVector();
94 const size_t num_local_dofs =
95 ref_ff.GetSpatialDiscretization().GetNumLocalDOFs(
96 ref_ff.GetUnknownManager());
98 double local_max_value = 0.0;
99 double local_min_value = 0.0;
100 double local_accumulation = 0.0;
101 bool first_local =
true;
104 const auto& cell = grid.local_cells[cell_local_id];
105 const auto& cell_mapping = sdm.GetCellMapping(cell);
106 const size_t num_nodes = cell_mapping.NumNodes();
108 for (
size_t i = 0; i < num_nodes; ++i)
110 const int64_t imap = sdm.MapDOFLocal(cell, i, uk_man, uid, cid);
111 if (imap >= 0 and imap < num_local_dofs)
113 const double field_value = field_data[imap];
116 local_max_value = field_value;
117 local_min_value = field_value;
121 local_max_value = std::max(local_max_value, field_value);
122 local_min_value = std::min(local_min_value, field_value);
123 local_accumulation += field_value;
130 double globl_max_value;
131 MPI_Allreduce(&local_max_value,
142 double globl_min_value;
143 MPI_Allreduce(&local_min_value,
154 double globl_accumulation;
155 MPI_Allreduce(&local_accumulation,
162 const size_t num_globl_dofs =
163 ref_ff.GetSpatialDiscretization().GetNumGlobalDOFs(
164 ref_ff.GetUnknownManager());
170 const int event_code = event_context.
Code();
171 if (event_code == 32 or
174 const auto& event_params = event_context.
Parameters();
176 if (event_params.Has(
"timestep_index") and event_params.Has(
"time"))
178 const size_t index = event_params.
GetParamValue<
size_t>(
"timestep_index");
179 const double time = event_params.GetParamValue<
double>(
"time");
#define ChiLogicalErrorIf(condition, message)
#define ChiLogicalError(message)
static chi::MPI_Info & mpi
static InputParameters GetInputParameters()
std::vector< uint64_t > cell_local_ids_
AggregateNodalValuePostProcessor(const InputParameters ¶ms)
void Execute(const Event &event_context) override
const std::string operation_
const ParameterBlock & Parameters() const
T GetParamValue(const std::string ¶m_name) const
std::vector< TimeHistoryEntry > time_history_
static InputParameters GetInputParameters()
static chi::InputParameters GetInputParameters()
const LogicalVolume * GetLogicalVolume() const
FieldFunctionGridBased * GetGridBasedFieldFunction() const
static chi::InputParameters GetInputParameters()
RegisterChiObject(chi, KBAGraphPartitioner)