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 #include <stdlib.h>
19 #include <math.h>
20 #include <stdio.h>
21 #include <string.h>
22 #include "CalculiX.h"
23 #include "mortar.h"
24
25 /** inserts a new nonzero matrix position into the sorted sparse matrix
26 data structure
27 *
28 * [in,out] irowp field saving the row numbers
29 * [in] i1 row number (FORTRAN convention)
30 * [in] i2 column number (FORTRAN convention)
31 * [in,out] ifree position of next free space in row,imast1,bd
32 * [in,out] nzs_ size of row,imast1,bd
33 * [in] contribution value to be saved in bd
34 * [in,out] bdp values of sparse matrix
35 **/
36
insertas_ws(ITG ** irowp,ITG * i1,ITG * i2,ITG * ifree,ITG * nzs_,double * contribution,double ** bdp)37 void insertas_ws(ITG **irowp, ITG *i1,ITG *i2, ITG *ifree, ITG *nzs_,
38 double *contribution, double **bdp){
39
40 /* inserts a new nonzero matrix position into the data structure
41 the structure is not assumed to be symmetric
42 i1: row number (FORTRAN convention)
43 i2: column number (FORTRAN convention) */
44
45 ITG idof1,*irow=NULL,nzs_old,i;
46 double *bd=NULL;
47
48 irow=*irowp;
49 bd=*bdp;
50
51 idof1 = *i1;
52
53 if(*ifree>*nzs_){
54 nzs_old=*nzs_;
55 *nzs_=(ITG)(1.5**nzs_+10);
56 RENEW(irow,ITG ,*nzs_);
57 for(i=nzs_old;i<*nzs_;i++){irow[i]=0;}
58 RENEW(bd,double,*nzs_);
59 for(i=nzs_old;i<*nzs_;i++){bd[i]=0.;}
60 }
61 irow[*ifree-1]=idof1;
62 bd[*ifree-1]=*contribution;
63 ++*ifree;
64
65 *irowp=irow;
66 *bdp=bd;
67
68 return;
69
70 }
71