Hello,
I would lito to solve indeipendently same mesh but different condition on diferent cores, and sum up a funtion value at each core. But it does not work as expected.
In the case of the following demo program 'lift-darg',
#include <dolfin.h>
#include <mpi.h>
#include "Functionals.h"
using namespace dolfin;
// Define sub domain for the dolphin
class Fish : public SubDomain
{
bool inside(const Array<double>& x, bool on_boundary) const
{
return (x[0] > DOLFIN_EPS && x[0] < (1.0 - DOLFIN_EPS) &&
x[1] > DOLFIN_EPS && x[1] < (1.0 - DOLFIN_EPS) &&
on_boundary);
}
};
int main()
{
// Read mesh from file
Mesh mesh(MPI_COMM_SELF);
HDF5File fpH5m(MPI_COMM_SELF,"./dolfin_fine.h5","r");
fpH5m.read(mesh,"mesh",false);
// Read velocity field from file
Functionals::CoefficientSpace_p Vp(mesh);
Function p(Vp);
HDF5File fpH5p(MPI_COMM_SELF,"./dolfin_fine_pressure.h5","r");
fpH5p.read(p,"p");
// Mark 'fish'
FacetFunction<std::size_t> markers(mesh, 1);
Fish fish;
fish.mark(markers, 1);
// Functionals for lift and drag
Functionals::Form_lift L(mesh, p);
Functionals::Form_drag D(mesh, p);
// Attach markers to functionals
L.ds = markers;
D.ds = markers;
// Assemble functionals over sub domain
const double lift = assemble(L);
const double drag = assemble(D);
info("Lift: %f", lift);
info("Drag: %f", drag);
}
Executing this program by "mpirun -n 2 ./myprogram", it sums up p at all process. How can I get sum at 1 process?