void ParGridFunction::ComputeFlux( BilinearFormIntegrator &blfi, GridFunction &flux, int wcoef, int subdomain) { ParFiniteElementSpace *ffes = dynamic_cast<ParFiniteElementSpace*>(flux.FESpace()); MFEM_VERIFY(ffes, "the flux FE space must be ParFiniteElementSpace"); Array<int> count(flux.Size()); SumFluxAndCount(blfi, flux, count, wcoef, subdomain); // Accumulate flux and counts in parallel ffes->GroupComm().Reduce<double>(flux, GroupCommunicator::Sum); ffes->GroupComm().Bcast<double>(flux); ffes->GroupComm().Reduce<int>(count, GroupCommunicator::Sum); ffes->GroupComm().Bcast<int>(count); // complete averaging for (int i = 0; i < count.Size(); i++) { if (count[i] != 0) { flux(i) /= count[i]; } } if (ffes->Nonconforming()) { // On a partially conforming flux space, project on the conforming space. // Using this code may lead to worse refinements in ex6, so we do not use // it by default. // Vector conf_flux; // flux.ConformingProject(conf_flux); // flux.ConformingProlongate(conf_flux); } }