I am receiving the following error when running with the command ``mpirun -n 3 python3 script.py
ValueError: operands could not be broadcast together with shapes (152510,4) (53972,4)
I understand the nature of the error as the shapes of the two numpy arrays are not the same. The computations run correctly in parallel however the question is, how do I make sure the array “conc” includes the data from all 3 processes, the last line of the attached script. I’ve attached a significantly redacted version of the script to just highlight the error.
from dolfin import *
import numpy as np
# Load the MeshFunction
mesh = UnitSquareMesh(10,10)
nv = mesh.num_vertices()
C = FunctionSpace(mesh, 'Lagrange', 2)
# Parameters
DBT = np.zeros(2)
DSPAS = np.zeros(5)
DPPAS = np.zeros(3)
len_DBT = DBT.shape[0]
len_DSPAS = DSPAS.shape[0]
len_DPPAS = DPPAS.shape[0]
DBT[0] = 0.2
DBT[1] = 0.24
DSPAS[0] = 50
DSPAS[1] = 100
DSPAS[2] = 140
DSPAS[3] = 200
DSPAS[4] = 250
DPPAS[0] = 200
DPPAS[1] = 500
DPPAS[2] = 1000
dt = 1.04
T = 83.2
time_pts = 8
# Load concentration data
conc_m = np.zeros((121, 10))
for k in range(len_DBT):
for l in range(len_DSPAS):
for m in range(len_DPPAS):
c = Function(C)
t = dt
time_pt = 0
conc = np.zeros((nv, time_pts))
# Time stepping loop
while t <=T+.0000000001:
if (t<10.5 and t>10.3):
vertex_values_c = c.compute_vertex_values(mesh)
conc[:, time_pt] = vertex_values_c[:]
time_pt += 1
t += dt
len_conc = conc_m.shape
print('Comp: ', np.sqrt((conc_m[:,0:4]-conc[:,0:4])**2/len_conc[0]))