[petsc-users] Reading data from a file into a DM created vector

Justin Chang jychang48 at gmail.com
Thu Oct 30 15:29:27 CDT 2014


Hi all,

So I am writing an FEM code where it reads input data (e.g., auxiliary
coefficients, source terms, etc) from a text file. I have preprocessed the
data text file so that each vertex point has its corresponding data. For
instance, if my source term for a diffusion problem has a sin or cos
function of the coordinates, then this data is already tabulated and simply
needs to be fed into my PETSc program. The data text file containing both
the auxiliary data and the coordinate/connectivities will also be used to
provide the input arguments for the DMPlexCreateFromDAG() function.

Normally, I would hard-code the sin/cos functions into the source code
itself, but i want my program to be "universal" in that it can take as
input any user-defined function for not only these auxiliaries but for
other things like boundary conditions. I see that PETSc has a lot of
examples on how to read data into vectors and matrices, but I guess my
question is is there a way to project data from a text file into a vector
that has already been created with a defined DM structure?

Thanks,
Justin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20141030/46bde095/attachment.html>


More information about the petsc-users mailing list