Skip to content

Commit fcb1a7c

Browse files
committed
Update
1 parent 15511f3 commit fcb1a7c

File tree

3 files changed

+41
-16
lines changed

3 files changed

+41
-16
lines changed

examples/PETSc/MPI_Poisson.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,34 @@ int main(int argc, char** argv)
5656
gf.save("Poisson." + std::to_string(world.rank()) + ".gf");
5757
}
5858

59+
// Vec v;
60+
// VecCreate(PETSC_COMM_WORLD, &v);
61+
62+
// size_t sz;
63+
// if (world.rank() == 0)
64+
// {
65+
// sz = 7;
66+
// }
67+
// else
68+
// {
69+
// sz = 8;
70+
// }
71+
// VecSetSizes(v, sz, 10);
72+
// VecSetFromOptions(v);
73+
74+
// std::vector<int> ghosts;
75+
// if (world.rank() == 0)
76+
// {
77+
// ghosts = { 2, 3 };
78+
// }
79+
// else
80+
// {
81+
// ghosts = { 4, 5, 6 };
82+
// }
83+
84+
// VecMPISetGhost(v, ghosts.size(), ghosts.data());
85+
86+
5987
PetscFinalize();
6088
}
6189

src/Rodin/MPI/Variational/P1/P1.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <mpi.h>
55
#include <boost/serialization/optional.hpp>
6+
#include <sys/mman.h>
67

78
#include "Rodin/MPI/Geometry/Mesh.h"
89
#include "Rodin/MPI/Variational/FiniteElementSpace.h"
@@ -179,7 +180,7 @@ namespace Rodin::Variational
179180
const auto local = mesh.getLocalIndex(0, requested[i].first);
180181
assert(local);
181182
const Index& global = requested[i].second;
182-
m_loc2glob.right.insert({ global, *local});
183+
m_loc2glob.right.insert({ global, *local });
183184
}
184185
}
185186

src/Rodin/PETSc/Variational/GridFunction.h

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)