1 | /*\file SystemMatrices.c
|
---|
2 | *\brief: build system matrices (stiffness matrix, loads vector)
|
---|
3 | */
|
---|
4 |
|
---|
5 | #include "./SystemMatrices.h"
|
---|
6 |
|
---|
7 | void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
|
---|
8 |
|
---|
9 | /*input datasets: */
|
---|
10 | Elements *elements = NULL;
|
---|
11 | Nodes *nodes = NULL;
|
---|
12 | Vertices *vertices = NULL;
|
---|
13 | Loads *loads = NULL;
|
---|
14 | Materials *materials = NULL;
|
---|
15 | Parameters *parameters = NULL;
|
---|
16 | bool kflag,pflag,penalty_kflag,penalty_pflag;
|
---|
17 |
|
---|
18 | /* output datasets: */
|
---|
19 | Mat Kgg = NULL;
|
---|
20 | Mat Kff = NULL;
|
---|
21 | Mat Kfs = NULL;
|
---|
22 | Vec pg = NULL;
|
---|
23 | Vec pf = NULL;
|
---|
24 | double kmax;
|
---|
25 |
|
---|
26 | /*Boot module: */
|
---|
27 | MODULEBOOT();
|
---|
28 |
|
---|
29 | /*checks on arguments on the matlab side: */
|
---|
30 | if((nlhs!=NLHS) || (nrhs!=6 && nrhs!=10)){
|
---|
31 | SystemMatricesUsage();
|
---|
32 | ISSMERROR(" usage. See above");
|
---|
33 | }
|
---|
34 |
|
---|
35 | /*Input datasets: */
|
---|
36 | FetchData((DataSet**)&elements,ELEMENTS);
|
---|
37 | FetchData((DataSet**)&nodes,NODES);
|
---|
38 | FetchData((DataSet**)&vertices,VERTICES);
|
---|
39 | FetchData((DataSet**)&loads,LOADS);
|
---|
40 | FetchData((DataSet**)&materials,MATERIALS);
|
---|
41 | FetchParams(¶meters,PARAMETERS);
|
---|
42 |
|
---|
43 | /*configure: */
|
---|
44 | elements-> Configure(elements,loads, nodes,vertices, materials,parameters);
|
---|
45 | nodes-> Configure(elements,loads, nodes,vertices, materials,parameters);
|
---|
46 | loads-> Configure(elements, loads, nodes,vertices, materials,parameters);
|
---|
47 | materials-> Configure(elements, loads, nodes,vertices, materials,parameters);
|
---|
48 |
|
---|
49 | /*!Generate internal degree of freedom numbers: */
|
---|
50 | if(nrhs==10){
|
---|
51 | FetchData(&kflag,KFLAG);
|
---|
52 | FetchData(&pflag,PFLAG);
|
---|
53 | FetchData(&penalty_kflag,PENALTYKFLAG);
|
---|
54 | FetchData(&penalty_pflag,PENALTYPFLAG);
|
---|
55 | SystemMatricesx(&Kgg,&Kff,&Kfs,&pg,&pf,&kmax,elements,nodes,vertices,loads,materials,parameters,kflag,pflag,penalty_kflag,penalty_pflag);
|
---|
56 | }
|
---|
57 | else
|
---|
58 | SystemMatricesx(&Kgg,&Kff,&Kfs,&pg,&pf,&kmax,elements,nodes,vertices,loads,materials,parameters);
|
---|
59 |
|
---|
60 | /*write output datasets: */
|
---|
61 | WriteData(KGG,Kgg);
|
---|
62 | WriteData(KFF,Kff);
|
---|
63 | WriteData(KFS,Kfs);
|
---|
64 | WriteData(PG,pg);
|
---|
65 | WriteData(PF,pf);
|
---|
66 | WriteData(KMAX,kmax);
|
---|
67 |
|
---|
68 | /*Free ressources: */
|
---|
69 | delete elements;
|
---|
70 | delete nodes;
|
---|
71 | delete vertices;
|
---|
72 | delete loads;
|
---|
73 | delete materials;
|
---|
74 | delete parameters;
|
---|
75 | MatFree(&Kgg);
|
---|
76 | MatFree(&Kff);
|
---|
77 | MatFree(&Kfs);
|
---|
78 | VecFree(&pg);
|
---|
79 | VecFree(&pf);
|
---|
80 |
|
---|
81 | /*end module: */
|
---|
82 | MODULEEND();
|
---|
83 | }
|
---|
84 |
|
---|
85 | void SystemMatricesUsage(void)
|
---|
86 | {
|
---|
87 | _printf_("\n");
|
---|
88 | _printf_(" usage: [Kgg,Kff,Kfs,pg,pf,kmax] = %s(elements,nodes,vertices,loads,materials,parameters);\n",__FUNCT__);
|
---|
89 | _printf_(" usage: [Kgg,Kff,Kfs,pg,pf,kmax] = %s(elements,nodes,vertices,loads,materials,parameters,kflag,pflag,penalty_kflag,penalty_pflag);\n",__FUNCT__);
|
---|
90 | _printf_("\n");
|
---|
91 | }
|
---|