This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

assembly on MPI_SELF

+1 vote

I am trying to do assembly on 1 partition. After calling assembly, my coefficient vector/solution has proper size, but residual which I assemble is global. Is there any way to avoid this?

auto mesh_local = std::make_shared<Mesh>(MPI_COMM_SELF);
MeshEditor editor;
editor.open(*mesh_local, 2, 2);  


editor.init_cells(mesh->num_cells()); 
ufc::cell ufc_cell;
std::vector<std::size_t> cell_data(3);
int i = 0; 
for (CellIterator cell(*mesh); !cell.end(); ++cell)
{   
    cell_data[0] = cell->entities(0)[0];
    cell_data[1] = cell->entities(0)[1];
    cell_data[2] = cell->entities(0)[2];
    editor.add_cell(i, cell_data);      
    i++; 
}


i = 0; 
editor.init_vertices(mesh->num_vertices()); 
for (VertexIterator vertex(*mesh); !vertex.end(); ++vertex)
{
    editor.add_vertex(i, (*vertex).point());
    i++; 
 }

editor.close();



  auto V_loc = std::make_shared<MinimalSurfaceLocal::FunctionSpace>(mesh_local);

  // local BC 
  auto dirichlet_boundary_loc = std::make_shared<WholeBoundary>();
  auto g_loc  = std::make_shared<Constant>(0.0);
  auto bc_loc = std::make_shared<const dolfin::DirichletBC>(V_loc, g_loc, dirichlet_boundary_loc);
  std::vector<std::shared_ptr<const dolfin::DirichletBC>> bcs_loc = {bc_loc};
  auto u_loc = std::make_shared<Function>(V_loc);

  // local energy 
  auto Pi_loc = std::make_shared<MinimalSurfaceLocal::Form_Pi_loc>(mesh_local);
  Pi_loc->u_loc = u_loc;      

  // local gradient 
  auto F_loc = std::make_shared<MinimalSurfaceLocal::ResidualForm>(V_loc);
  F_loc->u_loc = u_loc;       

  // local hessian
  auto J_loc = std::make_shared<MinimalSurfaceLocal::JacobianForm>(V_loc, V_loc);
  J_loc->u_loc = u_loc; 

  PETScVector uu_loc; 
  assemble(uu_loc, *F_loc); 
  info(uu_loc); 
  info(*u_loc->vector()); 
asked May 30, 2016 by pepo_1 FEniCS Novice (280 points)
...