1 /* CalculiX - A 3-dimensional finite element program */
2 /* Copyright (C) 1998-2021 Guido Dhondt */
3
4 /* This program is free software; you can redistribute it and/or */
5 /* modify it under the terms of the GNU General Public License as */
6 /* published by the Free Software Foundation(version 2); */
7 /* */
8
9 /* This program is distributed in the hope that it will be useful, */
10 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
11 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
12 /* GNU General Public License for more details. */
13
14 /* You should have received a copy of the GNU General Public License */
15 /* along with this program; if not, write to the Free Software */
16 /* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
17
18 #ifdef SGI
19
20 #include <stdio.h>
21 #include <math.h>
22 #include <stdlib.h>
23 #include "CalculiX.h"
24 #include "sgi.h"
25
26 ITG *irowsgi=NULL;
27 double *ausgi=NULL;
28
sgi_factor(double * ad,double * au,double * adb,double * aub,double * sigma,ITG * icol,ITG * irow,ITG * neq,ITG * nzs,ITG token)29 void sgi_factor(double *ad, double *au, double *adb, double *aub,
30 double *sigma,ITG *icol, ITG *irow,
31 ITG *neq, ITG *nzs, ITG token){
32
33 char *oocpath="/yatmp/scr1",*env;
34 ITG i,j,k,l,*pointers=NULL,method;
35 long long ndim;
36 double ops=0,ooclimit=2000.;
37
38 printf(" Factoring the system of equations using the sgi solver\n\n");
39
40 env=getenv("CCX_OOC_MEM");
41 if(env) ooclimit=atoi(env);
42
43 ndim=*neq+*nzs;
44
45 NNEW(pointers,ITG,*neq+1);
46 NNEW(irowsgi,ITG,ndim);
47 NNEW(ausgi,double,ndim);
48
49 k=ndim;
50 l=*nzs;
51
52 if(*sigma==0.){
53 pointers[*neq]=ndim;
54 for(i=*neq-1;i>=0;--i){
55 for(j=0;j<icol[i];++j){
56 irowsgi[--k]=irow[--l]-1;
57 ausgi[k]=au[l];
58 }
59 pointers[i]=--k;
60 irowsgi[k]=i;
61 ausgi[k]=ad[i];
62 }
63 }
64 else{
65 pointers[*neq]=ndim;
66 for(i=*neq-1;i>=0;--i){
67 for(j=0;j<icol[i];++j){
68 irowsgi[--k]=irow[--l]-1;
69 ausgi[k]=au[l]-*sigma*aub[l];
70 }
71 pointers[i]=--k;
72 irowsgi[k]=i;
73 ausgi[k]=ad[i]-*sigma*adb[i];
74 }
75 }
76
77 method=2;
78
79 DPSLDLT_Ordering(token,method);
80 DPSLDLT_Preprocess(token,*neq,pointers,irowsgi,&ndim,&ops);
81
82 if(*neq>200000){
83 printf(" The out of core solver is used\n\n");
84 DPSLDLT_OOCLimit(token,ooclimit);
85 DPSLDLT_OOCPath(token,oocpath);
86 DPSLDLT_FactorOOC(token,*neq,pointers,irowsgi,ausgi);
87 }
88 else{
89 DPSLDLT_Factor(token,*neq,pointers,irowsgi,ausgi);
90 }
91
92 SFREE(pointers);
93
94 return;
95 }
96
sgi_solve(double * b,ITG token)97 void sgi_solve(double *b,ITG token){
98
99 DPSLDLT_Solve(token,b,b);
100
101 return;
102 }
103
sgi_cleanup(ITG token)104 void sgi_cleanup(ITG token){
105
106 DPSLDLT_Destroy(token);
107 SFREE(irowsgi);
108 SFREE(ausgi);
109
110 return;
111 }
112
sgi_main(double * ad,double * au,double * adb,double * aub,double * sigma,double * b,ITG * icol,ITG * irow,ITG * neq,ITG * nzs,ITG token)113 void sgi_main(double *ad, double *au, double *adb, double *aub, double *sigma,
114 double *b, ITG *icol, ITG *irow,
115 ITG *neq, ITG *nzs, ITG token){
116
117 if(*neq==0) return;
118
119 sgi_factor(ad,au,adb,aub,sigma,icol,irow,
120 neq,nzs,token);
121
122 sgi_solve(b,token);
123
124 sgi_cleanup(token);
125
126 return;
127 }
128
129 #endif
130
131