14 const auto& sdm = ref_ff.GetSpatialDiscretization();
15 const auto& grid = sdm.Grid();
17 const auto& uk_man = ref_ff.GetUnknownManager();
22 const auto field_data = ref_ff.GetGhostedFieldVector();
24 double local_volume = 0.0;
25 double local_sum = 0.0;
26 double local_max = 0.0;
27 double local_min = 0.0;
30 const auto& cell = grid.local_cells[cell_local_id];
31 const auto& cell_mapping = sdm.GetCellMapping(cell);
32 const size_t num_nodes = cell_mapping.NumNodes();
33 const auto qp_data = cell_mapping.MakeVolumetricQuadraturePointData();
35 std::vector<double> node_dof_values(num_nodes, 0.0);
36 for (
size_t i=0; i<num_nodes; ++i)
38 const int64_t imap = sdm.MapDOFLocal(cell,i,uk_man,uid,cid);
39 node_dof_values[i] = field_data[imap];
44 local_max = node_dof_values.front();
45 local_min = node_dof_values.front();
48 for (
size_t i=0; i<num_nodes; ++i)
50 local_max = std::fmax(node_dof_values[i], local_max);
51 local_min = std::fmin(node_dof_values[i], local_min);
54 for (
const size_t qp : qp_data.QuadraturePointIndices())
56 double ff_value = 0.0;
57 for (
size_t j=0; j<num_nodes; ++j)
58 ff_value += qp_data.ShapeValue(j,qp) * node_dof_values[j];
60 double function_value = ff_value;
61 if (
op_type_ >= Operation::OP_SUM_LUA and
65 local_volume += qp_data.JxW(qp);
66 local_sum += function_value * qp_data.JxW(qp);
67 local_max = std::fmax(ff_value, local_max);
68 local_min = std::fmin(ff_value, local_min);
75 MPI_Allreduce(&local_sum,&global_sum,1,MPI_DOUBLE,MPI_SUM,
Chi::mpi.comm);
80 double local_data[] = {local_volume, local_sum};
81 double global_data[] = {0.0,0.0};
83 MPI_Allreduce(&local_data,&global_data,2,MPI_DOUBLE,MPI_SUM,
Chi::mpi.comm);
84 double global_volume = global_data[0];
85 double global_sum = global_data[1];
91 MPI_Allreduce(&local_max,&global_value,1,MPI_DOUBLE,MPI_MAX,
Chi::mpi.comm);
static chi::MPI_Info & mpi
std::vector< chi_physics::FieldFunctionGridBasedPtr > field_functions_
unsigned int ref_component_
double CallLuaFunction(double ff_value, int mat_id) const
std::vector< uint64_t > cell_local_ids_inside_logvol_
ff_interpolation::Operation op_type_