Andrew --

> My question is, am I using parallelism correctly when I write Paraview files?
> Because when I create a new File object and run the .write() method, for each time step
> it seems to create a number of VTU files equal to the number of cores used,
> as well as a PVTU file. Is this correct?

Yes, that is expected.  One .vtu per process.  A single .pvtu and a single .pvd.  Open the .pvd with Paraview.
 
> My other question is, is there a way to tell Python to only use the first core when doing
> other tasks? For example, I have a Python script in my code which writes a simple
> text file. What I really  don’t want is for Python to write to this text file 22 times when
> it only needs to do it once.

It depends on what data you want to write to the file.

There is no magic "do this task over all data, and save the result from rank 0" command in general.
One generally needs to decide on and explicitly communicate data from the processes to rank 0.
(E.g. PETSc VecScatter: https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/PetscSF/VecScatterCreateToZero.html.)

But for printing something like a scalar norm, which uses an all-to-all reduction already, you can just print on rank 0:

from firedrake import *
mesh = UnitSquareMesh(9, 9)
W = FunctionSpace(mesh, 'Lagrange', degree=1)
u = Function(W)
# do stuff to u
normu = sqrt(assemble(dot(u, u) * dx)) # every process knows normu
if mesh.comm.rank == 0:
    print('the norm is %f' % normu)

You may want to be more specific about what you want to write.  Is it a vector, e.g. a solution,
or something which is already stored on every processor?

Ed

On Mon, Apr 5, 2021 at 2:27 PM Andrew Hicks <ahick17@lsu.edu> wrote:

Dear all,

 

I am testing out using parallelism with Firedrake now that I have access to a computer with multiple cores. I have successfully used parallelism on a simple Laplace problem in 3D, and have also read the tutorial on using PETSc’s Sys.Print() function to print output and using the “with” statement to compute the L-infinity norm.

 

My question is, am I using parallelism correctly when I write Paraview files? Because when I create a new File object and run the .write() method, for each time step it seems to create a number of VTU files equal to the number of cores used, as well as a PVTU file. Is this correct?

 

My other question is, is there a way to tell Python to only use the first core when doing other tasks? For example, I have a Python script in my code which writes a simple text file. What I really  don’t want is for Python to write to this text file 22 times when it only needs to do it once.

 

Thanks for the help,

Andrew Hicks

_______________________________________________
firedrake mailing list
firedrake@imperial.ac.uk
https://mailman.ic.ac.uk/mailman/listinfo/firedrake


--
Ed Bueler
Dept of Mathematics and Statistics
University of Alaska Fairbanks
Fairbanks, AK 99775-6660
306C Chapman