It seems that this is caused by non-ghosted values. The NumericVector only contains the solution of nodes owned by one process. But the elements (mesh cells) owned by one process may include the nodes owned by other process. In my program, the data contains 8 nodes and 6 elements. By using 2 processes, after partition, the 1st process has Node 0, 1, 2, 3, 4, and the 2nd process has Node 5, 6, 7. Also the numeric vector only contains the solution of Node 0, 1, 2, 3, 4 for 1st process, and Node 5, 6, 7 for 2nd process. But the element owned by 2nd process may contains Node 0, so there is no solution for this node in the vector of 2nd process. Then the error comes.
So how can I use ghost values in the PETSc vectors? Sorry that I am new to libmesh. > On Jun 22, 2016, at 6:31 PM, 张江 <zhangjiang.d...@gmail.com> wrote: > > Thanks. I have another problem about parallel reading the nodal values. Below > is the code. I run mpiexec -n 2 ./out , and get the error that: > > [0]PETSC ERROR: --------------------- Error Message > -------------------------------------------------------------- > [0]PETSC ERROR: application called MPI_Abort(MPI_COMM_WORLD, 59) - process 1 > Signal received > [0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html > <http://www.mcs.anl.gov/petsc/documentation/faq.html> for trouble shooting. > [0]PETSC ERROR: Petsc Release Version 3.7.2, Jun, 05, 2016 > [0]PETSC ERROR: ./parallel on a arch-darwin-c-debug named pkuvisjiang by > jiangzhang Wed Jun 22 16:58:28 2016 > [0]PETSC ERROR: Configure options --prefix=/opt/petsc-3.7.2 > --with-mpi-dir=/usr/local --download-fblaslapack > [0]PETSC ERROR: #1 User provided function() line 0 in unknown file > application called MPI_Abort(MPI_COMM_WORLD, 59) - process 0 > > int main(int argc, char** argv) > { > LibMeshInit init(argc, argv); > > UnstructuredMesh *mesh; > ExodusII_IO *exio; > EquationSystems *eqsys; > System *asys; > > unsigned int Ax_var, Ay_var, Az_var; > > mesh = new Mesh(init.comm()); > exio = new ExodusII_IO(*mesh); > exio->read("triangle_mesh_linear.e"); > mesh->allow_renumbering(false); > mesh->prepare_for_use(); > eqsys = new EquationSystems(*mesh); > > asys = &(eqsys->add_system<System>("Velocity")); > Ax_var = asys->add_variable("Vx", FIRST, LAGRANGE); > Ay_var = asys->add_variable("Vy", FIRST, LAGRANGE); > Az_var = asys->add_variable("Vz", FIRST, LAGRANGE); > > eqsys->init(); > exio->copy_nodal_solution(*asys, "Vx", "velocityX"); > exio->copy_nodal_solution(*asys, "Vy", "velocityY"); > exio->copy_nodal_solution(*asys, "Vz", "velocityZ"); > > libMesh::UniquePtr<libMesh::NumericVector<libMesh::Number> > _as = > asys->solution->clone(); > const NumericVector<Number> &as = *_as; > > MeshBase::const_node_iterator itn = mesh->local_nodes_begin(); > const MeshBase::const_node_iterator endn = mesh->local_nodes_end(); > > for (; itn != endn; itn ++) > { > Node *node = *itn; > > float A[3]; > A[0] = as( node->dof_number(asys->number(), Ax_var, 0) ); // here is ok > A[1] = as( node->dof_number(asys->number(), Ay_var, 0) ); // here is ok > A[2] = as( node->dof_number(asys->number(), Az_var, 0) ); // here is ok > } > > MeshBase::const_element_iterator it = mesh->local_elements_begin(); > const MeshBase::const_element_iterator end = mesh->local_elements_end(); > > for (; it != end; it ++) > { > Elem *elem = *it; > std::vector<NodeIdType> nodes; > for (int i=0; i<elem->n_nodes(); i++) > { > const Node& node = mesh->node(elem->node(i)); > nodes.push_back(elem->node(i)); > float A[3]; > A[0] = as( node.dof_number(asys->number(), Ax_var, 0) ); // here comes > the error > A[1] = as( node.dof_number(asys->number(), Ay_var, 0) ); // here comes > the error > A[2] = as( node.dof_number(asys->number(), Az_var, 0) ); // here comes > the error > } > } > > return 0; > } > > It is strange. Is there any wrong operation here? > > >> On Jun 22, 2016, at 2:39 PM, John Peterson <jwpeter...@gmail.com >> <mailto:jwpeter...@gmail.com>> wrote: >> >> >> >> On Wed, Jun 22, 2016 at 1:24 PM, 张江 <zhangjiang.d...@gmail.com >> <mailto:zhangjiang.d...@gmail.com>> wrote: >> Hi, >> >> I have rebuilt libmesh with PETSc. Here is an simple example that to obtain >> the nodal values. However, when I run it in parallel (mpiexec -n 2 ./out), >> there is always error that: >> >> [1]PETSC ERROR: --------------------- Error Message >> -------------------------------------------------------------- >> [1]PETSC ERROR: Signal received >> [1]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html >> <http://www.mcs.anl.gov/petsc/documentation/faq.html> for trouble shooting. >> [1]PETSC ERROR: Petsc Release Version 3.7.2, Jun, 05, 2016 >> [1]PETSC ERROR: ./parallel on a arch-darwin-c-debug named xxx by xxx Wed Jun >> 22 14:19:19 2016 >> [1]PETSC ERROR: Configure options --prefix=/opt/petsc-3.7.2 >> --with-mpi-dir=/usr/local --download-fblaslapack >> [1]PETSC ERROR: #1 User provided function() line 0 in unknown file >> >> Was the PETSc not correctly installed or not well built with libmesh >> together? >> >> Did you run "make check" after building libmesh? >> >> >> Below is the code: >> >> The error is likely that you are accessing a non-local non-ghosted value in >> the PETSc vector, but I haven't analyzed what you are doing closely. >> >> -- >> John > ------------------------------------------------------------------------------ Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San Francisco, CA to explore cutting-edge tech and listen to tech luminaries present their vision of the future. This family event has something for everyone, including kids. Get more information and register today. http://sdm.link/attshape _______________________________________________ Libmesh-users mailing list Libmesh-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libmesh-users