Hi David,
This is a big piece of code where I solve nonlinear equations in a 2D domain with mixed systems involving vector functions.
I'd like to run the whole code in parallel except from some lines such as saving txt files, to avoid overwriting it or saving in several files. Is there a command to select a specific process? Andrew once mentioned using op2.MPI.comm.rank. Is that a solution? How can I use it?
The error when appending the array is not such an issue as I need it only for visualisation purpose.
For instance, I want to save a 1D function h_1D
mesh_1D = IntervalMesh(Nx,Lx)
V_1D = FunctionSpace(mesh_1D, "CG", 1)
h_1D = Function(V_1D)
on a 2D surface. So I define a 2D mesh as follows
mesh_2D = RectangleMesh(Nx,1,Lx,1.0,quadrilateral=True)
V_2D = FunctionSpace(mesh_2D, "CG", 1)
h_2D = Function(V_2D)
Then, I save in Indx[i] the indices for which x_2D[i] = x_1D[i]:
Indx = []
for i in range(Nx+1):
Indx.append([item for item in range(len(mesh_2D.coordinates.dat.data[:,0])) if mesh_2D.coordinates.dat.data[item,0] == mesh_1D.coordinates.dat.data[i]])
The idea is that I can then project h_1D to the 2D mesh through h_2D:
for i in range(Nx+1):
h_2D.dat.data[Indx[i]] = h_1D.dat.data[i]
This works fine when I run the code on one core, but when running in parallel I get an index error:
File "main.py", line 932, in <listcomp>
Indx.append([item for item in range(len(mesh_2D.coordinates.dat.data[:,0])) if mesh_2D.coordinates.dat.data[item,0] == mesh_1D.coordinates.dat.data[j]])
IndexError: index 125 is out of bounds for axis 0 with size 125
File "main.py", line 970, in <module>
mesh_WM = CubeMesh(1,1,1,1.0)
File "/home/ufaserv1_i/mmfg/firedrake/firedrake/src/firedrake/firedrake/utility_meshes.py", line 749, in CubeMesh
comm=comm)
File "/home/ufaserv1_i/mmfg/firedrake/firedrake/src/firedrake/firedrake/utility_meshes.py", line 725, in BoxMesh
return mesh.Mesh(plex, reorder=reorder, distribute=distribute)
File "<decorator-gen-259>", line 2, in Mesh
File "/home/ufaserv1_i/mmfg/firedrake/firedrake/src/PyOP2/pyop2/profiling.py", line 60, in wrapper
return f(*args, **kwargs)
File "/home/ufaserv1_i/mmfg/firedrake/firedrake/src/firedrake/firedrake/mesh.py", line 1249, in Mesh
topology = MeshTopology(plex, name=name, reorder=reorder, distribute=distribute)
File "<decorator-gen-257>", line 2, in __init__
File "/home/ufaserv1_i/mmfg/firedrake/firedrake/src/PyOP2/pyop2/profiling.py", line 60, in wrapper
return f(*args, **kwargs)
File "/home/ufaserv1_i/mmfg/firedrake/firedrake/src/firedrake/firedrake/mesh.py", line 377, in __init__
raise RuntimeError("Mesh must have at least one cell on every process")
RuntimeError: Mesh must have at least one cell on every process
Dear all,
I need to run my firedrake code in parallel but some of the commands (like appending an array) can't be executed in parallel. How can I force some lines to be executed by one core only?
Thanks in advance,
Floriane
_______________________________________________ firedrake mailing list firedrake@imperial.ac.uk https://mailman.ic.ac.uk/mailman/listinfo/firedrake