Ignore:
Timestamp:
05/26/10 12:15:23 (15 years ago)
Author:
Eric.Larour
Message:

New results API

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/objects/Elements/Beam.cpp

    r3947 r3956  
    842842}
    843843/*}}}*/
    844 /*FUNCTION Beam::PatchSize(int* ppatch_numrows,int* pnumcols, int enum_type){{{1*/
    845 void  Beam::PatchSize(int* ppatch_numrows,int* pnumcols, int enum_type){
    846         this->inputs->PatchSize(ppatch_numrows,pnumcols,enum_type);
    847 }
    848 /*}}}*/
    849 /*FUNCTION Beam::PatchFill(int* pcount, double* patches,int patch_numcols);{{{1*/
    850 void  Beam::PatchFill(int* pcount, double* patches,int patch_numcols){
    851         this->inputs->PatchFill(pcount,patches,patch_numcols,this->parameters);
    852 }
    853 /*}}}*/
     844/*FUNCTION Beam::PatchSize(int* pnumrows, int* pnumvertices,int* pnumnodes, int enum_type){{{1*/
     845void  Beam::PatchSize(int* pnumrows, int* pnumvertices,int* pnumnodes, int enum_type){
     846
     847        int    i;
     848        Input *input       = NULL;
     849        bool   found       = false;
     850        int    numrows;
     851        int    numvertices;
     852        int    numnodes;
     853
     854        /*Recover counter: */
     855        numrows=*pnumrows;
     856
     857        /*Go through all the input objects, and find the one corresponding to enum_type, if it exists: */
     858        for (i=0;i<this->inputs->Size();i++){
     859                input=(Input*)this->inputs->GetObjectByOffset(i);
     860                if (input->EnumType()==enum_type){
     861                        found=true;
     862                        break;
     863                }
     864        }
     865
     866        if (!found){
     867                /*Ok, the input looked for does not exist. No problem. Just be sure numvertices and numnodes
     868                 * are 0, so that they do not increase the size of the patches array. Also, do not increase
     869                 * the counter, as this element has nothing to do with results: */
     870                numvertices=0;
     871                numnodes=0;
     872        }
     873        else{
     874                /*Ok, we found an input with the correct enum_type. Ask it to tell us how many nodal values it
     875                 * holds. : */
     876                numnodes=input->PatchSize();
     877                /*We know the number of vertices from this element: */
     878                numvertices=2;
     879                /*Increase counter, because this element does hold a result in its inputs: */
     880                numrows++;
     881        }
     882
     883        /*Assign output pointers:*/
     884        *pnumrows=numrows;
     885        *pnumvertices=numvertices;
     886        *pnumnodes=numnodes;
     887       
     888}
     889/*}}}*/
     890/*FUNCTION Beam::PatchFill(int* pcount, double* patches,int numcols,int max_vertices,int enum_type){{{1*/
     891void  Beam::PatchFill(int* pcount, double* patches,int numcols,int max_vertices,int enum_type){
     892
     893        /*A patch is made of the following information:
     894         * element_id  interpolation_type  vertex_ids    values.
     895         * For example:
     896
     897         1 P0  1 2       4.5 NaN
     898         2 P1  1 3       4.5 3.2
     899         3 P0  1 5       5.5 NaN
     900         4 P1  2 4       4.5 3.2
     901
     902         Here, we will provide the nodal values, after having processed them, can provide: id, and vertices ids.
     903         Then go find an input with enum_type. If we find it, fill in the values at the nodal points.
     904         If we don't find an input, get out of here doing nothing, as this element is not involved in
     905         outputting results.
     906         */
     907
     908        int      i;
     909        Input   *input      = NULL;
     910        bool     found      = false;
     911        int      count      = 0;
     912        Node   **nodes      = NULL;
     913        double  *this_patch = NULL;
     914
     915
     916        /*Go through all the input objects, and find the one corresponding to enum_type, if it exists: */
     917        for (i=0;i<this->inputs->Size();i++){
     918                input=(Input*)this->inputs->GetObjectByOffset(i);
     919                if (input->EnumType()==enum_type){
     920                        found=true;
     921                        break;
     922                }
     923        }
     924
     925        if (!found){
     926                /*Ok, the input looked for does not exist. No problem. Just return :*/
     927        }
     928        else{
     929               
     930                /*First, recover the patches row where we will plug in the information: */
     931                count=*pcount;
     932
     933                /*Recover nodes: */
     934                nodes=(Node**)hnodes.deliverp();
     935
     936                /*set this_patch to point at the beginning of the patches row, where we will plug our information :*/
     937                this_patch=patches+numcols*count;
     938
     939                /*Fill in id: */
     940                this_patch[0]=this->id;
     941
     942                /*Fill in vertices ids: */
     943                for(i=0;i<2;i++) this_patch[2+i]=nodes[i]->GetVertexId(); //vertices id start at column 3 of the patch.
     944
     945                /*We found the input, get it to fill the interpolation type, and the nodal values:*/
     946                input->PatchFill(this_patch,max_vertices,this->parameters);
     947               
     948                /*Increase counter, so that next time, we don't point to the same patches row: */
     949                count++;
     950
     951                /*Assign output pointers:*/
     952                *pcount=count;
     953        }
     954}
     955/*}}}*/
Note: See TracChangeset for help on using the changeset viewer.