petsc

Unable to call PETSc/MPI-based external code in parallel OpenMDAO

时光怂恿深爱的人放手 提交于 2019-12-23 02:19:39
问题 I am writing an OpenMDAO problem that calls a group of external codes in a parallel group. One of these external codes is a PETSc-based fortran FEM code. I realize this is potentially problematic since OpenMDAO also utilizes PETSc. At the moment, I'm calling the external code in a component using python's subprocess. If I run my OpenMDAO problem in serial (i.e. python2.7 omdao_problem.py), everything, including the external code, works just fine. When I try to run it in parallel, however (i.e

PETSc solving linear system with ksp guide

非 Y 不嫁゛ 提交于 2019-12-21 02:34:18
问题 I am starting use PETSc library to solve linear system of equations in parallel. I have installed all packages, build and run successfully the examples in petsc/src/ksp/ksp/examples/tutorials/ folder, for example ex.c But I couldn't understand how to fill matrices A,X an B by reading them for example from file. Here I provide the code within ex2.c file: /* Program usage: mpiexec -n <procs> ex2 [-help] [all PETSc options] */ static char help[] = "Solves a linear system in parallel with KSP.\n\

Using f2py on a Fortran code linked to PETSc

穿精又带淫゛_ 提交于 2019-12-12 04:28:26
问题 My question is related to this post: Including a compiled module in module that is wrapped with f2py (Minimum working example)? in which the poster was trying to compile a Fortran code (Test.f90) with f2py and link that to a pre-compiled library (or in my case, object, myex44f.o). The answer enabled me to compile the Fortran code and generated the python module. My problem is different from the above posters problem in that my object is linked to PETSc. When I try to import my f2py-generated

petsc4py: Creating AIJ Matrix from csc_matrix results in TypeError

时间秒杀一切 提交于 2019-12-10 10:39:33
问题 I am trying to create a petsc-matrix form an already existing csc-matrix. With this in mind I created the following example code: import numpy as np import scipy.sparse as sp import math as math from petsc4py import PETSc n=100 A = sp.csc_matrix((n,n),dtype=np.complex128) print A.shape A[1:5,:]=1+1j*5*math.pi p1=A.indptr p2=A.indices p3=A.data petsc_mat = PETSc.Mat().createAIJ(size=A.shape,csr=(p1,p2,p3)) This works perfectly well as long as the matrix only consist of real values. When the

Unable to use f2py to link large PETSc/SLEPc Fortran code

心不动则不痛 提交于 2019-12-08 09:23:53
问题 I am attempting to use f2py to create a python module for my Fortran code that uses both PETSc and SLEPc (this question is very closely related to this post, but the discussion there was unable to solve my problem--see comments at bottom of this post). The code is made up of many files and subroutines, but I only need access to the outermost main/driver function in python. The first step I took was to use the SLEPc-provided makefile template to generate all object files (the final linking

petsc4py: Creating AIJ Matrix from csc_matrix results in TypeError

随声附和 提交于 2019-12-06 14:15:50
I am trying to create a petsc-matrix form an already existing csc-matrix. With this in mind I created the following example code: import numpy as np import scipy.sparse as sp import math as math from petsc4py import PETSc n=100 A = sp.csc_matrix((n,n),dtype=np.complex128) print A.shape A[1:5,:]=1+1j*5*math.pi p1=A.indptr p2=A.indices p3=A.data petsc_mat = PETSc.Mat().createAIJ(size=A.shape,csr=(p1,p2,p3)) This works perfectly well as long as the matrix only consist of real values. When the matrix is complex running this piece of code results in a TypeError: Cannot cast array data from dtype(

PETSc solving linear system with ksp guide

戏子无情 提交于 2019-12-03 08:35:44
I am starting use PETSc library to solve linear system of equations in parallel. I have installed all packages, build and run successfully the examples in petsc/src/ksp/ksp/examples/tutorials/ folder, for example ex.c But I couldn't understand how to fill matrices A,X an B by reading them for example from file. Here I provide the code within ex2.c file: /* Program usage: mpiexec -n <procs> ex2 [-help] [all PETSc options] */ static char help[] = "Solves a linear system in parallel with KSP.\n\ Input parameters include:\n\ -random_exact_sol : use a random exact solution vector\n\ -view_exact_sol

scipy sparse matrices as an input for petsc4py

独自空忆成欢 提交于 2019-12-03 07:50:46
问题 I can't seem to find a way how to efficiently load scipy sparse matrices, e.g. csr_matrix, into a petsc4py matrix, e.g. PETSc.Mat().createAIJ . I found this thread, but I'm not able to apply it. I would also appreciate a pointer where this stuff is actually documented. The examples in the demo directory only explain a part, and I can't see any docstrings. 回答1: Your link says that to create a sparse matrix in PETSc, you should use a command like this: PETSc.Mat().createAIJ(size=(nrows,ncols),