source: issm/trunk/src/mex/SystemMatrices/SystemMatrices.cpp@ 8910

Last change on this file since 8910 was 8910, checked in by Eric.Larour, 14 years ago

Reorganized io/ directory quite a bit.
Separated Matlab io from the other Disk related io.
Renamed WriteData to WriteMatlabData and FetchData to FetchMatlabData.
Folded WriteParams and FetchParams into FetchMatlabData and WriteMatlabData.

File size: 2.6 KB
Line 
1/*\file SystemMatrices.c
2 *\brief: build system matrices (stiffness matrix, loads vector)
3 */
4
5#include "./SystemMatrices.h"
6
7void 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 Kff = NULL;
20 Mat Kfs = NULL;
21 Vec pf = NULL;
22 Vec df = NULL;
23
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 _error_(" usage. See above");
33 }
34
35 /*Input datasets: */
36 FetchMatlabData((DataSet**)&elements,ELEMENTS);
37 FetchMatlabData((DataSet**)&nodes,NODES);
38 FetchMatlabData((DataSet**)&vertices,VERTICES);
39 FetchMatlabData((DataSet**)&loads,LOADS);
40 FetchMatlabData((DataSet**)&materials,MATERIALS);
41 FetchMatlabData(&parameters,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 FetchMatlabData(&kflag,KFLAG);
52 FetchMatlabData(&pflag,PFLAG);
53 FetchMatlabData(&penalty_kflag,PENALTYKFLAG);
54 FetchMatlabData(&penalty_pflag,PENALTYPFLAG);
55 SystemMatricesx(&Kff,&Kfs,&pf,&df,&kmax,elements,nodes,vertices,loads,materials,parameters,kflag,pflag,penalty_kflag,penalty_pflag);
56 }
57 else
58 SystemMatricesx(&Kff,&Kfs,&pf,&df,&kmax,elements,nodes,vertices,loads,materials,parameters);
59
60 /*write output datasets: */
61 WriteMatlabData(KFF,Kff);
62 WriteMatlabData(KFS,Kfs);
63 WriteMatlabData(PF,pf);
64 WriteMatlabData(DF,df);
65 WriteMatlabData(KMAX,kmax);
66
67 /*Free ressources: */
68 delete elements;
69 delete nodes;
70 delete vertices;
71 delete loads;
72 delete materials;
73 delete parameters;
74 MatFree(&Kff);
75 MatFree(&Kfs);
76 VecFree(&pf);
77 VecFree(&df);
78
79 /*end module: */
80 MODULEEND();
81}
82
83void SystemMatricesUsage(void)
84{
85 _printf_(true,"\n");
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__);
88 _printf_(true,"\n");
89}
Note: See TracBrowser for help on using the repository browser.