以下是我的代码中的一个类,它解决了FEM问题。
线性方程组的系数矩阵是稀疏的,所以我使用intel mkl direct solver for sparse matrices来解决这个系统。
该类用于解决线性系统,我之前尝试过一个简单的问题,并且通过将结果与matlab进行比较,它可以很好地工作。我确信所有链接都是正确的,配置设置为x64
#pragma once
#include <iostream>
#include <mkl.h>
using namespace std;
class Solution
{
private:
int *row, *col, nelx, nely;
double *K, *b;
public:
Solution(double *x, double* xx, int* y, int* z, int ll, int nn)
{
K = x;
b = xx;
row = y;
col = z;
nelx = ll;
nely = nn;
}
double* f();
};
double* Solution::f()
{
int n = (nelx + 1)*(nely + 1) * 2, m = 868, l=1;
double *sol = new double[n];
int *perm = new int[n];
_MKL_DSS_HANDLE_t handle;
MKL_INT opt = MKL_DSS_ZERO_BASED_INDEXING;
dss_create(handle, opt);
// dss_define_structure
opt = MKL_DSS_NON_SYMMETRIC;
dss_define_structure(handle, opt, row, n, n, col, m);
// dss_reorder
opt = MKL_DSS_AUTO_ORDER;
dss_reorder(handle, opt, perm);
// dss_factor_real, dss_factor_complex
opt = MKL_DSS_POSITIVE_DEFINITE;
dss_factor_real(handle, opt, K);
// dss_solve_real, dss_solve_complex
opt = MKL_DSS_REFINEMENT_ON;
dss_solve_real(handle, opt, b, l, sol);
return sol;
}
当我将该类用于整个代码时,它在“dss_create”命令中给出了以下消息:
top88_class.exe中的0x000000007750F7E7(ntdll.dll)抛出异常: 0xC0000005:访问冲突读取位置0x00000E0111350228。
如果存在此异常的处理程序,则程序可能是安全的 继续进行。
答案 0 :(得分:0)
我弄明白了这个问题。 在另一个班级的某些宣言中有一个错误影响了这个班级,我不知道为什么。