Hi Can the matrix->zero_rows() function not be used during assembly? I get an "Object Not Initialized " error during runtime if I use the above function in assembly.
Also, I am not changing the sparsity pattern of the matrix. Because, I get the dof_indices of a particular element. The following piece of code. : elem = *el; dof_map.dof_indices(elem,dof_columns); DenseMatrix<Number> Fe; Fe.resize(dof_columns.size(),dof_columns.size()); system.matrix->add_matrix (Fe, dof_columns); The above piece of code comes in the assembly functions and I have just rewritten it in the main function for a single element. I have another question. I tried implementing the solution 2 using the following code: PetscMatrix<Number> m(system.matrix).mat() ; MatSetOption(m.mat(),MAT_NEW_NONZERO_ALLOCATION_ERR,PETSC_FALSE); This also gave me an error. Could you tell me the the correct syntax to set the right option. Thanks for helping me Vegnesh ________________________________ From: David Knezevic [david.kneze...@akselos.com] Sent: Monday, June 06, 2016 9:30 PM To: Jayaraman, Vegnesh Cc: libmesh-users@lists.sourceforge.net Subject: Re: [Libmesh-users] Using Sparse matrix functions in main function The error message "New nonzero at (1,9) caused a malloc!" is from PETSc. PETSc is trying to do you a favor by telling you that you're allocating new non-zeros in your matrix, which is slow and should be avoided. PETSc requires the number of nonzeros per row to be specified before the matrix is assembled so that it can allocate memory efficiently. libMesh handles this pre-allocation for you automatically, but libMesh assumes a standard sparsity pattern based on the finite element degrees of freedom in your system. In your case, you've added some extra "non-standard" non-zeros into the matrix, which causes the PETSc error. To get around this you can either: 1) Not allocate the "non-standard" non-zeros in the matrix. 2) Tell PETSc not to report an error when a new non-zero is detected. You can do this by setting MAT_NEW_NONZERO_ALLOCATION_ERR to PetscFalse by calling MatSetOption on the PETSc Mat object (which you can obtain from the libMesh PetscMatrix object). 3) Augment the libMesh sparsity pattern by calling augment_sparsity_pattern on a System's dof_map. This is illustrated in libMesh example miscellaneous_ex9, for example. David On Mon, Jun 6, 2016 at 10:00 PM, Jayaraman, Vegnesh <vjayr...@illinois.edu<mailto:vjayr...@illinois.edu>> wrote: Hello, I am trying to modify the entries of the system matrix in the main function. As a first test, I did the following, elem = *el; dof_map.dof_indices(elem,dof_columns); system.matrix->zero_rows(dof_columns,500.234); The above code changes the variables in system matrix. However, if I did the following, DenseMatrix<Number> Fe; Fe.resize(dof_columns.size(),dof_columns.size()); system.matrix->add_matrix (Fe, dof_columns); I get the following runtime error. [0]PETSC ERROR: --------------------- Error Message ------------------------------------ [0]PETSC ERROR: Argument out of range! [0]PETSC ERROR: New nonzero at (1,9) caused a malloc! [0]PETSC ERROR: ------------------------------------------------------------------------ [0]PETSC ERROR: Petsc Release Version 3.3.0, Patch 5, Sat Dec 1 15:10:41 CST 2012 [0]PETSC ERROR: See docs/changes/index.html for recent updates. [0]PETSC ERROR: See docs/faq.html for hints about trouble shooting. [0]PETSC ERROR: See docs/index.html for manual pages. [0]PETSC ERROR: ------------------------------------------------------------------------ [0]PETSC ERROR: ./example-opt on a arch-linu named thor by vegnesh Mon Jun 6 20:48:10 2016 [0]PETSC ERROR: Libraries linked from /home/vegnesh/codes/petsc/3.3-p5/arch-linux2-c-opt/lib [0]PETSC ERROR: Configure run at Mon Feb 8 21:38:17 2016 [0]PETSC ERROR: Configure options --with-cxx=/home/mpanesi/APPLICATIONS/openmpi/openmpi-1.6.3-gcc-4.7/bin/mpicxx --with-cc=/home/mpanesi/APPLICATIONS/openmpi/openmpi-1.6.3-gcc-4.7/bin/mpicc --with-fc=/home/mpanesi/APPLICATIONS/openmpi/openmpi-1.6.3-gcc-4.7/bin/mpif90 --with-shared-libraries --with-debugging=0 --download-f-blas-lapack=yes --download-hypre=yes --with-openmp=1 [0]PETSC ERROR: ------------------------------------------------------------------------ [0]PETSC ERROR: MatSetValues_SeqAIJ() line 346 in src/mat/impls/aij/seq/aij.c [0]PETSC ERROR: MatSetValues() line 1025 in src/mat/interface/matrix.c -------------------------------------------------------------------------- MPI_ABORT was invoked on rank 0 in communicator MPI_COMM_WORLD with errorcode 1. NOTE: invoking MPI_ABORT causes Open MPI to kill all MPI processes. You may or may not see output from other processes, depending on exactly when Open MPI kills them. I wanted to know where I am going wrong. Can add_matrix function be used only with assembly and not in main for modifying the system matrix? Similarly, I am unable to use the zero_rows function in the assemble function of the system. Thank you for helping me out Regards Vegnesh ------------------------------------------------------------------------------ What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e<https://urldefense.proofpoint.com/v2/url?u=https-3A__ad.doubleclick.net_ddm_clk_305295220-3B132659582-3Be&d=CwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=zPe16F3t4ATZWQ6J7DYOyIpTy5qL-TyGcPdDk2TVxhE&m=4T1ousVROVHYkGjhPqAoozaGxfmLVlTjs4c2bT57Tqs&s=fG1ZQ3QbM-Wqo7UQkyqziFEQ2HzVeWR20io2c0EI98c&e=> _______________________________________________ Libmesh-users mailing list Libmesh-users@lists.sourceforge.net<mailto:Libmesh-users@lists.sourceforge.net> https://lists.sourceforge.net/lists/listinfo/libmesh-users<https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.sourceforge.net_lists_listinfo_libmesh-2Dusers&d=CwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=zPe16F3t4ATZWQ6J7DYOyIpTy5qL-TyGcPdDk2TVxhE&m=4T1ousVROVHYkGjhPqAoozaGxfmLVlTjs4c2bT57Tqs&s=B-001HJs94WhQFJ5rhfhXzEeraVD4MovmrT9kleIAV8&e=> ------------------------------------------------------------------------------ What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e _______________________________________________ Libmesh-users mailing list Libmesh-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libmesh-users