| [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: */
|
|---|
| [5775] | 19 | Mat Kff = NULL;
|
|---|
| 20 | Mat Kfs = NULL;
|
|---|
| 21 | Vec pf = NULL;
|
|---|
| [7391] | 22 | Vec df = NULL;
|
|---|
| 23 |
|
|---|
| [5693] | 24 | double kmax;
|
|---|
| [1] | 25 |
|
|---|
| 26 | /*Boot module: */
|
|---|
| 27 | MODULEBOOT();
|
|---|
| 28 |
|
|---|
| 29 | /*checks on arguments on the matlab side: */
|
|---|
| [5698] | 30 | if((nlhs!=NLHS) || (nrhs!=6 && nrhs!=10)){
|
|---|
| 31 | SystemMatricesUsage();
|
|---|
| [6412] | 32 | _error_(" usage. See above");
|
|---|
| [5698] | 33 | }
|
|---|
| [1] | 34 |
|
|---|
| 35 | /*Input datasets: */
|
|---|
| [4215] | 36 | FetchData((DataSet**)&elements,ELEMENTS);
|
|---|
| [4211] | 37 | FetchData((DataSet**)&nodes,NODES);
|
|---|
| [4213] | 38 | FetchData((DataSet**)&vertices,VERTICES);
|
|---|
| [4214] | 39 | FetchData((DataSet**)&loads,LOADS);
|
|---|
| [4218] | 40 | FetchData((DataSet**)&materials,MATERIALS);
|
|---|
| [2333] | 41 | FetchParams(¶meters,PARAMETERS);
|
|---|
| 42 |
|
|---|
| [4573] | 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);
|
|---|
| [5689] | 47 | materials-> Configure(elements, loads, nodes,vertices, materials,parameters);
|
|---|
| [4573] | 48 |
|
|---|
| [1] | 49 | /*!Generate internal degree of freedom numbers: */
|
|---|
| [5698] | 50 | if(nrhs==10){
|
|---|
| 51 | FetchData(&kflag,KFLAG);
|
|---|
| 52 | FetchData(&pflag,PFLAG);
|
|---|
| 53 | FetchData(&penalty_kflag,PENALTYKFLAG);
|
|---|
| 54 | FetchData(&penalty_pflag,PENALTYPFLAG);
|
|---|
| [8801] | 55 | SystemMatricesx(&Kff,&Kfs,&pf,&df,&kmax,elements,nodes,vertices,loads,materials,parameters,kflag,pflag,penalty_kflag,penalty_pflag);
|
|---|
| [5698] | 56 | }
|
|---|
| 57 | else
|
|---|
| [8801] | 58 | SystemMatricesx(&Kff,&Kfs,&pf,&df,&kmax,elements,nodes,vertices,loads,materials,parameters);
|
|---|
| [1] | 59 |
|
|---|
| 60 | /*write output datasets: */
|
|---|
| [5775] | 61 | WriteData(KFF,Kff);
|
|---|
| 62 | WriteData(KFS,Kfs);
|
|---|
| 63 | WriteData(PF,pf);
|
|---|
| [7391] | 64 | WriteData(DF,df);
|
|---|
| [5693] | 65 | WriteData(KMAX,kmax);
|
|---|
| [1] | 66 |
|
|---|
| 67 | /*Free ressources: */
|
|---|
| 68 | delete elements;
|
|---|
| 69 | delete nodes;
|
|---|
| [3445] | 70 | delete vertices;
|
|---|
| [1] | 71 | delete loads;
|
|---|
| 72 | delete materials;
|
|---|
| [2333] | 73 | delete parameters;
|
|---|
| [5775] | 74 | MatFree(&Kff);
|
|---|
| 75 | MatFree(&Kfs);
|
|---|
| 76 | VecFree(&pf);
|
|---|
| [7391] | 77 | VecFree(&df);
|
|---|
| [1] | 78 |
|
|---|
| 79 | /*end module: */
|
|---|
| 80 | MODULEEND();
|
|---|
| 81 | }
|
|---|
| 82 |
|
|---|
| 83 | void SystemMatricesUsage(void)
|
|---|
| 84 | {
|
|---|
| [6412] | 85 | _printf_(true,"\n");
|
|---|
| [8801] | 86 | _printf_(true," usage: [Kff,Kfs,pf,df,kmax] = %s(elements,nodes,vertices,loads,materials,parameters);\n",__FUNCT__);
|
|---|
| 87 | _printf_(true," usage: [Kff,Kfs,pf,df,kmax] = %s(elements,nodes,vertices,loads,materials,parameters,kflag,pflag,penalty_kflag,penalty_pflag);\n",__FUNCT__);
|
|---|
| [6412] | 88 | _printf_(true,"\n");
|
|---|
| [1] | 89 | }
|
|---|