[1] | 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: */
|
---|
[5689] | 10 | Elements *elements = NULL;
|
---|
| 11 | Nodes *nodes = NULL;
|
---|
| 12 | Vertices *vertices = NULL;
|
---|
| 13 | Loads *loads = NULL;
|
---|
| 14 | Materials *materials = NULL;
|
---|
| 15 | Parameters *parameters = NULL;
|
---|
[5698] | 16 | bool kflag,pflag,penalty_kflag,penalty_pflag;
|
---|
[1] | 17 |
|
---|
| 18 | /* output datasets: */
|
---|
[5693] | 19 | Mat Kgg = NULL;
|
---|
| 20 | Vec pg = NULL;
|
---|
| 21 | double kmax;
|
---|
[1] | 22 |
|
---|
| 23 | /*Boot module: */
|
---|
| 24 | MODULEBOOT();
|
---|
| 25 |
|
---|
| 26 | /*checks on arguments on the matlab side: */
|
---|
[5698] | 27 | if((nlhs!=NLHS) || (nrhs!=6 && nrhs!=10)){
|
---|
| 28 | SystemMatricesUsage();
|
---|
| 29 | ISSMERROR(" usage. See above");
|
---|
| 30 | }
|
---|
[1] | 31 |
|
---|
| 32 | /*Input datasets: */
|
---|
[4215] | 33 | FetchData((DataSet**)&elements,ELEMENTS);
|
---|
[4211] | 34 | FetchData((DataSet**)&nodes,NODES);
|
---|
[4213] | 35 | FetchData((DataSet**)&vertices,VERTICES);
|
---|
[4214] | 36 | FetchData((DataSet**)&loads,LOADS);
|
---|
[4218] | 37 | FetchData((DataSet**)&materials,MATERIALS);
|
---|
[2333] | 38 | FetchParams(¶meters,PARAMETERS);
|
---|
| 39 |
|
---|
[4573] | 40 | /*configure: */
|
---|
| 41 | elements-> Configure(elements,loads, nodes,vertices, materials,parameters);
|
---|
| 42 | nodes-> Configure(elements,loads, nodes,vertices, materials,parameters);
|
---|
| 43 | loads-> Configure(elements, loads, nodes,vertices, materials,parameters);
|
---|
[5689] | 44 | materials-> Configure(elements, loads, nodes,vertices, materials,parameters);
|
---|
[4573] | 45 |
|
---|
[1] | 46 | /*!Generate internal degree of freedom numbers: */
|
---|
[5698] | 47 | if(nrhs==10){
|
---|
| 48 | FetchData(&kflag,KFLAG);
|
---|
| 49 | FetchData(&pflag,PFLAG);
|
---|
| 50 | FetchData(&penalty_kflag,PENALTYKFLAG);
|
---|
| 51 | FetchData(&penalty_pflag,PENALTYPFLAG);
|
---|
| 52 | SystemMatricesx(&Kgg,&pg,&kmax,elements,nodes,vertices,loads,materials,parameters,kflag,pflag,penalty_kflag,penalty_pflag);
|
---|
| 53 | }
|
---|
| 54 | else
|
---|
| 55 | SystemMatricesx(&Kgg,&pg,&kmax,elements,nodes,vertices,loads,materials,parameters);
|
---|
[1] | 56 |
|
---|
| 57 | /*write output datasets: */
|
---|
[2316] | 58 | WriteData(KGG,Kgg);
|
---|
| 59 | WriteData(PG,pg);
|
---|
[5693] | 60 | WriteData(KMAX,kmax);
|
---|
[1] | 61 |
|
---|
| 62 | /*Free ressources: */
|
---|
| 63 | delete elements;
|
---|
| 64 | delete nodes;
|
---|
[3445] | 65 | delete vertices;
|
---|
[1] | 66 | delete loads;
|
---|
| 67 | delete materials;
|
---|
[2333] | 68 | delete parameters;
|
---|
[1] | 69 | MatFree(&Kgg);
|
---|
| 70 | VecFree(&pg);
|
---|
| 71 |
|
---|
| 72 | /*end module: */
|
---|
| 73 | MODULEEND();
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | void SystemMatricesUsage(void)
|
---|
| 77 | {
|
---|
| 78 | _printf_("\n");
|
---|
[5693] | 79 | _printf_(" usage: [Kgg,pg,kmax] = %s(elements,nodes,vertices,loads,materials,parameters);\n",__FUNCT__);
|
---|
[5698] | 80 | _printf_(" usage: [Kgg,pg,kmax] = %s(elements,nodes,vertices,loads,materials,parameters,kflag,pflag,penalty_kflag,penalty_pflag);\n",__FUNCT__);
|
---|
[1] | 81 | _printf_("\n");
|
---|
| 82 | }
|
---|