@@ -90,10 +90,13 @@ namespace Rodin::Variational
9090 {
9191 ierr = VecCreate (PETSC_COMM_SELF, &data);
9292 assert (ierr == PETSC_SUCCESS);
93+
9394 ierr = VecSetSizes (data, fes.getSize (), PETSC_DECIDE);
9495 assert (ierr == PETSC_SUCCESS);
96+
9597 ierr = VecSetFromOptions (data);
9698 assert (ierr == PETSC_SUCCESS);
99+
97100 ierr = VecZeroEntries (data);
98101 assert (ierr == PETSC_SUCCESS);
99102 }
@@ -239,19 +242,10 @@ for (int r = 0; r < comm.size(); ++r) {
239242 }
240243 else if constexpr (std::is_same_v<FESMeshContextType, Context::MPI>)
241244 {
242- Index local;
243- if (m_begin <= global && global < m_end)
244- {
245- local = global - m_begin;
246- }
247- else
248- {
249- const auto & fes = this ->getFiniteElementSpace ();
250- const Optional<Index> localIdx = fes.getLocalIndex (global);
251- assert (localIdx);
252- local = *localIdx;
253- }
254- return m_write.raw [local];
245+ const auto & fes = this ->getFiniteElementSpace ();
246+ const Optional<Index> localIdx = fes.getLocalIndex (global);
247+ assert (localIdx);
248+ return m_write.raw [*localIdx];
255249 }
256250 else
257251 {
@@ -431,7 +425,8 @@ for (int r = 0; r < comm.size(); ++r) {
431425 }
432426
433427 template <class NestedDerived >
434- GridFunction& projectOnCells (const FunctionBase<NestedDerived>& fn, const FlatSet<Geometry::Attribute>& attrs)
428+ GridFunction& projectOnCells (
429+ const FunctionBase<NestedDerived>& fn, const FlatSet<Geometry::Attribute>& attrs)
435430 {
436431 if constexpr (std::is_same_v<FESMeshContextType, Context::Local>)
437432 {
@@ -489,7 +484,8 @@ for (int r = 0; r < comm.size(); ++r) {
489484 shard.getMapping ({ d, i }, fn.template cast <RangeType>());
490485 for (Index local = 0 ; local < fe.getCount (); local++)
491486 {
492- const Index global = fes.getGlobalIndex (shard.getGlobalIndex ({ d, i }, local));
487+ const Index global =
488+ fes.getGlobalIndex (shard.getGlobalIndex ({ d, i }, local));
493489 this ->operator [](global) = fe.getLinearForm (local)(mapping);
494490 }
495491 }
0 commit comments