/*\file InternalFront.c *\brief: build pressureload */ #include "./InternalFront.h" void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){ bool* elementonwater=NULL; int* elements=NULL; int* connectivity=NULL; int* elementconnectivity=NULL; int* front=NULL; double* front2=NULL; bool found; int numberofelements,numberofsegments; int N,M; int i,j,ii,jj,id; /*Boot module: */ MODULEBOOT(); /*checks on arguments on the matlab side: */ CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&InternalFrontUsage); /*Fetch required fields*/ FetchData(&numberofelements,mxGetAssignedField(MODEL,0,"numberofelements")); if(numberofelements<=0) _error_("No elements found in the model"); FetchData(&elements,&M,&N,mxGetAssignedField(MODEL,0,"elements")); if(M!=numberofelements || N!=3) _error_("Field 'elements' should be of size [md.numberofelements 3]"); FetchData(&elementonwater,&M,&N,mxGetAssignedField(MODEL,0,"elementonwater")); if(M!=numberofelements || N!=1) _error_("Field 'elementonwater' should be of size [md.numberofelements 1]"); FetchData(&elementconnectivity,&M,&N,mxGetAssignedField(MODEL,0,"elementconnectivity")); if(M!=numberofelements || N!=3) _error_("Field 'elementconnectivity' should be of size [md.numberofelements 3]"); /*Allocate and initialize all variables*/ numberofsegments=0; front=(int*)mxMalloc(3*numberofelements*4*sizeof(int)); /*Loop over all elements on water*/ for(i=0;i