基于GPU加速的PQ解耦型潮流算法

 2022-07-14 14:17:38

论文总字数:3146字

//生成前推回代顺序

int *eorderL = NULL;

int *eorderU = NULL;

eorderL = (int*)malloc(sizeof(int)*rowsA);

eorderU = (int*)malloc(sizeof(int)*rowsA);

struct node *nodetree = (struct node*)malloc(sizeof(struct node) * rowsA);

for (int i = 0; ilt;rowsA; i )

{

nodetree[i].i = i;

nodetree[i].level = -1;

}

for (int i = 0; ilt;rowsA; i )//寻找第0层,

{

if (h_csrRowPtrL[i] == h_csrRowPtrL[i 1])//L矩阵只有对角元的属于第0层

nodetree[i].level = 0;

}

for (int i = 0; ilt;rowsA; i )

{

if (nodetree[i].level != 0)

{

int level = nodetree[h_csrColIndL[h_csrRowPtrL[i]]].level;//第i行的层号是其非零元中最大层号加1

for (int k = h_csrRowPtrL[i] 1; klt;h_csrRowPtrL[i 1]; k )

{

int j = h_csrColIndL[k];

if (levellt;nodetree[j].level)

level = nodetree[j].level;

}

nodetree[i].level = level 1;

}

}

qsort(nodetree, rowsA, sizeof(nodetree[0]), cmp2);//按层排序,先层后节点编号

for (int i = 0; ilt;rowsA; i )

eorderL[i] = nodetree[i].i;

int nlevel_L = nodetree[rowsA - 1].level 1;//nlevel_L下三角一共有多少层

printf("\n 二、3、前推L阵的Max level=%d", nlevel_L);

//生成回代顺序

struct node *nodetreeU = (struct node*)malloc(sizeof(struct node) * rowsA);

for (int i = 0; ilt;rowsA; i )

{

nodetreeU[i].i = i;

nodetreeU[i].level = -1;

}

for (int i = rowsA - 1; i gt;= 0; i--)

{

if (h_csrRowPtrU[i 1] - h_csrRowPtrU[i] == 1)//U矩阵只有对角元的属于第0层

nodetreeU[i].level = 0;

}

for (int i = rowsA - 1; i gt;= 0; i--)

{

if (nodetreeU[i].level != 0)

{

int level = nodetreeU[h_csrColIndU[h_csrRowPtrU[i 1] - 1]].level;

for (int k = h_csrRowPtrU[i 1] - 2; kgt;h_csrRowPtrU[i]; k--)

{

int j = h_csrColIndU[k];

if (levellt;nodetreeU[j].level)

level = nodetreeU[j].level;

}

nodetreeU[i].level = level 1;

}

}

qsort(nodetreeU, rowsA, sizeof(nodetreeU[0]), cmp3);//按层排序,层数小的排在前面,相同层里面节点大的排在前面

for (int i = 0; ilt;rowsA; i )

{

eorderU[i] = nodetreeU[i].i;

}

int nlevel_U = nodetreeU[rowsA - 1].level 1;//上三角层数

printf("\n 回代U阵的Max level=%d", nlevel_U);

if (nodetreeU) { free(nodetreeU); }

if (nodetree) { free(nodetree); }

//用L,U稀疏结构构造C结构,将B填入C中,使用C进行LU分解,再使用C进行前推回代

int *h_csrRowPtrC = (int*)malloc(sizeof(int)*(rowsA 1));

int *h_csrColIndC = (int*)malloc(sizeof(int)*(nnzL nnzU));

double *h_csrvalC = (double*)malloc(sizeof(double)*(nnzL nnzU));

for (int i = 0; ilt;(nnzL nnzU); i )

{

h_csrvalC[i] = 0;

}

int j = 0;

for (int i = 0; ilt;rowsA; i )

{

h_csrRowPtrC[i] = h_csrRowPtrL[i] h_csrRowPtrU[i];

for (int k = h_csrRowPtrL[i]; klt;h_csrRowPtrL[i 1]; k )

{

h_csrColIndC[j] = h_csrColIndL[k];

j ;

}

for (int k1 = h_csrRowPtrU[i]; k1lt;h_csrRowPtrU[i 1]; k1 )

{

h_csrColIndC[j] = h_csrColIndU[k1];

j ;

}

}

h_csrRowPtrC[rowsA] = h_csrRowPtrL[rowsA] h_csrRowPtrU[rowsA];

for (int i = 0; ilt;rowsA; i )

{

int kB = h_csrRowPtrB[i];

for (int kC = h_csrRowPtrC[i]; kClt;h_csrRowPtrC[i 1]; kC )

{

if ((h_csrColIndC[kC] == h_csrColIndB[kB]) amp;amp; (kBlt;h_csrRowPtrB[i 1]))

{

h_csrvalC[kC] = h_csrd_batchB[kB];

kB ;

}

}

}

if (h_csrRowPtrB) { free(h_csrRowPtrB); }

if (h_csrColIndB) { free(h_csrColIndB); }

if (h_csrd_batchB) { free(h_csrd_batchB); }

剩余内容已隐藏,请支付后下载全文,论文总字数:3146字

您需要先支付 80元 才能查看全部内容!立即支付

该课题毕业论文、开题报告、外文翻译、程序设计、图纸设计等资料可联系客服协助查找;