27 "Computes the volumetric integral of a field-function as a scalar.");
32 "compute_volume_average",
34 "Flag, when true will compute the volume average of the post-processor.");
43 chi_physics::GridBasedFieldFunctionInterface(params),
44 chi_mesh::LogicalVolumeInterface(params),
45 compute_volume_average_(
46 params.GetParamValue<bool>(
"compute_volume_average"))
57 "Attempted to access invalid field"
60 const auto& grid = grid_field_function->GetSpatialDiscretization().Grid();
63 if (logical_volume_ptr_ ==
nullptr)
66 for (
const auto& cell : grid.local_cells)
71 for (
const auto& cell : grid.local_cells)
72 if (logical_volume_ptr_->Inside(cell.centroid_))
87 "Attempted to access invalid field"
90 const auto& ref_ff = *grid_field_function;
91 const auto& sdm = ref_ff.GetSpatialDiscretization();
92 const auto& grid = sdm.Grid();
94 const auto& uk_man = ref_ff.GetUnknownManager();
98 const auto field_data = ref_ff.GetGhostedFieldVector();
100 auto coord = sdm.GetSpatialWeightingFunction();
102 double local_integral = 0.0;
103 double local_volume = 0.0;
106 const auto& cell = grid.local_cells[cell_local_id];
107 const auto& cell_mapping = sdm.GetCellMapping(cell);
108 const size_t num_nodes = cell_mapping.NumNodes();
109 const auto qp_data = cell_mapping.MakeVolumetricQuadraturePointData();
111 std::vector<double> node_dof_values(num_nodes, 0.0);
112 for (
size_t i = 0; i < num_nodes; ++i)
114 const int64_t imap = sdm.MapDOFLocal(cell, i, uk_man, uid, cid);
115 node_dof_values[i] = field_data[imap];
118 for (
const size_t qp : qp_data.QuadraturePointIndices())
121 double ff_value = 0.0;
122 for (
size_t j = 0; j < num_nodes; ++j)
123 ff_value += qp_data.ShapeValue(j, qp) *
126 local_integral += ff_value * coord(qp_data.QPointXYZ(qp)) * qp_data.JxW(qp);
127 local_volume += coord(qp_data.QPointXYZ(qp)) * qp_data.JxW(qp);
131 double globl_integral;
132 MPI_Allreduce(&local_integral,
142 MPI_Allreduce(&local_volume,
152 const int event_code = event_context.
Code();
153 if (event_code == 32 or
156 const auto& event_params = event_context.
Parameters();
158 if (event_params.Has(
"timestep_index") and event_params.Has(
"time"))
160 const size_t index = event_params.
GetParamValue<
size_t>(
"timestep_index");
161 const double time = event_params.GetParamValue<
double>(
"time");
#define ChiLogicalErrorIf(condition, message)
static chi::MPI_Info & mpi
CellVolumeIntegralPostProcessor(const InputParameters ¶ms)
std::vector< uint64_t > cell_local_ids_
static InputParameters GetInputParameters()
void Execute(const Event &event_context) override
const bool compute_volume_average_
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)