Changeset 3956
- Timestamp:
- 05/26/10 12:15:23 (15 years ago)
- Location:
- issm/trunk/src/c
- Files:
-
- 34 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/DataSet/DataSet.h
r3946 r3956 152 152 153 153 void ChangeEnum(int enumtype,int new_enumtype); 154 void PatchSize(int* ppatch_numrows,int* pnumcols, int enum_type);155 void PatchFill(int* pcount, double* patches,int patch_numcols,Parameters* parameters);156 154 157 155 /*}}}*/ -
issm/trunk/src/c/DataSet/Inputs.cpp
r3946 r3956 654 654 } 655 655 /*}}}*/ 656 /*FUNCTION Inputs::PatchSize(int* ppatch_numrows,int* pnumcols, int enum_type);{{{1*/657 void Inputs::PatchSize(int* ppatch_numrows,int* pnumcols, int enum_type){658 659 int i;660 661 vector<Object*>::iterator object;662 Input* input=NULL;663 bool found=false;664 665 int patch_numrows=0;666 int numcols=0;667 668 /*First, recover the counter patch_numrows: */669 patch_numrows=*ppatch_numrows;670 671 /*Go through all the input objects, and find the one corresponding to enum_type, if it exists: */672 for ( object=objects.begin() ; object < objects.end(); object++ ){673 674 input=(Input*)(*object);675 if (input->EnumType()==enum_type){676 found=true;677 break;678 }679 }680 681 if (!found){682 /*Ok, the input looked for does not exist. No problem. Just return a patch size of 0, and do683 * not increment the counter: */684 numcols=0;685 }686 else{687 /*We found the input, get it to tell us the size of the patch information it returns, and increment688 * the counter: */689 patch_numrows++;690 numcols=input->PatchSize();691 }692 693 /*Assign output pointers:*/694 *ppatch_numrows=patch_numrows;695 *pnumcols=numcols;696 697 }698 /*}}}*/699 /*FUNCTION Inputs::PatchFill(int* pcount, double* patches,int patch_numcols);{{{1*/700 void Inputs::PatchFill(int* pcount, double* patches,int patch_numcols,Parameters* parameters){701 702 int i;703 704 vector<Object*>::iterator object;705 Input* input=NULL;706 bool found=false;707 708 int count=0;709 710 /*First, recover the counter patch_numrows: */711 count=*pcount;712 713 /*Go through all the input objects, and find the one corresponding to enum_type, if it exists: */714 for ( object=objects.begin() ; object < objects.end(); object++ ){715 716 input=(Input*)(*object);717 if (input->EnumType()==enum_type){718 found=true;719 break;720 }721 }722 723 if (!found){724 /*Ok, the input looked for does not exist. No problem. Just return :*/725 }726 else{727 /*We found the input, get it to fill the patch, at the right position in the patches matrix: */728 input->PatchFill(patches+patch_numcols*count,parameters);729 count++;730 }731 732 /*Assign output pointers:*/733 *pcount=count;734 }735 /*}}}*/ -
issm/trunk/src/c/DataSet/Results.cpp
r3938 r3956 105 105 } 106 106 /*}}}*/ 107 -
issm/trunk/src/c/modules/InputToResultx/InputToPatches.cpp
r3938 r3956 15 15 #include "../../DataSet/DataSet.h" 16 16 17 void InputToPatches(DataSet* elements,double* patches,int patch_num rows,int patch_numcols){17 void InputToPatches(DataSet* elements,double* patches,int patch_numcols,int max_vertices,int enum_type){ 18 18 19 19 int i; … … 29 29 30 30 element=(Element*)elements->GetObjectByOffset(i); 31 element->PatchFill(&count,patches,patch_numcols );31 element->PatchFill(&count,patches,patch_numcols,max_vertices,enum_type); 32 32 33 33 } -
issm/trunk/src/c/modules/InputToResultx/InputToResultx.cpp
r3938 r3956 13 13 void InputToResultx(Result** presult,DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials,Parameters* parameters,int enum_type,int id, double time, int step){ 14 14 15 /*We are going to extract from the inputs, the results desired, and create a table 16 * of patch information, that will hold, for each element that computed the result that 17 * we desire, the id of the element, the interpolation type, the vertices ids, and the values 18 * at the nodes (could be different from the vertices). This will be used for visualization purposed. 19 * For example, we could build the following patch table, for velocities: 20 * 21 * 1 P0 1 2 4.5 NaN NaN (constant on a beam element) 22 * 2 P1 1 3 4 4.5 3.2 2.5 (linear values on a tria element) 23 * 3 P0 1 5 4 5.5 NaN NaN (contant on a tria element) 24 * ... etc ... 25 * 26 * So what do we need to build the table: the maximum number of vertices included in the table, 27 * and the maximum number of nodal values, as well as the number of rows. Once we have that, 28 * we ask the elements to fill their own row in the table, by looping on the elememnts. 29 * Finally, we include the table in a Result object, that will be used by the OutputResults 30 * module to write to disk: */ 31 15 32 int i,j,count; 16 33 … … 21 38 double* patches=NULL; //build a matrix of patch information, corresponding to the input with name enum_type 22 39 int patch_numrows,patch_numcols; 40 int max_vertices; 41 int max_nodes; 23 42 24 43 /*First, get elements*/ … … 26 45 27 46 /*Figure out size of patches matrix: */ 28 PatchesSize(elements,&patch_numrows, &patch_numcols,enum_type); 47 PatchesSize(elements,&patch_numrows, &max_vertices, &max_nodes, enum_type); 48 49 patch_numcols=1+ //element id 50 1+ //interpolation type 51 max_vertices+ //vertices 52 max_nodes; //values+ 29 53 30 54 /*Allocate matrix: */ … … 39 63 40 64 /*Now, go through elements, their inputs with the correct enum_type, and fill the patches: */ 41 InputToPatches(elements,patches,patch_numrows, patch_numcols);65 InputToPatches(elements,patches,patch_numrows,max_vertices,enum_type); 42 66 43 67 /*Create result object embedding patches: */ … … 48 72 49 73 } 74 75 76 77 -
issm/trunk/src/c/modules/InputToResultx/InputToResultx.h
r3938 r3956 12 12 13 13 /* local prototypes: */ 14 void PatchesSize(DataSet* elements,int* p patch_numrows, int* ppatch_numcols,int enum_type);15 void InputToPatches(DataSet* elements,double* patches,int patch_numrows,int patch_numcols);14 void PatchesSize(DataSet* elements,int* pnumrows, int* pnumvertices, int* pnumnodes,int enum_type); 15 void InputToPatches(DataSet* elements,double* patches,int numcols, int max_vertices, int enum_type); 16 16 17 17 #endif /* _INPUTTORESULTX_H */ -
issm/trunk/src/c/modules/InputToResultx/PatchesSize.cpp
r3938 r3956 15 15 #include "../../DataSet/DataSet.h" 16 16 17 void PatchesSize(DataSet* elements,int* p patch_numrows, int* ppatch_numcols,int enum_type){17 void PatchesSize(DataSet* elements,int* pnumrows, int* pnumvertices, int* pnumnodes,int enum_type){ 18 18 19 19 int i; 20 20 21 21 /*output: */ 22 int patch_numrows; 23 int patch_numcols; 22 int numrows; 23 int numvertices; 24 int numnodes; 24 25 25 26 /*intermediary:*/ 26 27 Element* element=NULL; 27 int count=0; 28 int numcols=0; 29 int max_numcols=0; 28 int element_numvertices; 29 int element_numnodes; 30 31 /*Go through elemnets, and each time an element holds an input with the correct enum_type, increase numrows by 1. At the 32 * same time, retrieve number of vertices this element holds, as well as number of nodes the input holds values for. 33 * Update the values of numvertices and numnodes to be the max of all the input numvertices and numnodes:*/ 34 35 numrows=0; 36 numvertices=0; 37 numnodes=0; 30 38 31 /*Go through elemnets, and each time an element holds an input with the correct enum_type, increase count by 1. At the32 * same time, retrieve size of patch that this input will output, and during the loop, figure out the max of that patch size.33 * The final count will be the number of rows in the patches array, and max_numcols will be the number of columns of the34 * p[atches array: */35 36 patch_numrows=0;37 patch_numcols=0;38 numcols=0;39 40 39 for(i=0;i<elements->Size();i++){ 41 40 42 41 element=(Element*)elements->GetObjectByOffset(i); 43 element->PatchSize(&patch_numrows,&numcols,enum_type); 44 if(numcols>patch_numcols)patch_numcols=numcols; 42 element->PatchSize(&numrows,&element_numvertices,&element_numnodes,enum_type); 43 44 if(element_numvertices>numvertices)numvertices=element_numvertices; 45 if(element_numnodes>numnodes)numnodes=element_numnodes; 45 46 46 47 } 47 48 48 49 /*Assign output pointers:*/ 49 *ppatch_numrows=patch_numrows; 50 *ppatch_numcols=patch_numcols; 50 *pnumrows=numrows; 51 *pnumvertices=numvertices; 52 *pnumnodes=numnodes; 51 53 } 52 54 -
issm/trunk/src/c/objects/Elements/Beam.cpp
r3947 r3956 842 842 } 843 843 /*}}}*/ 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*/ 845 void 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*/ 891 void 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 /*}}}*/ -
issm/trunk/src/c/objects/Elements/Beam.h
r3938 r3956 79 79 void ComputeStrainRate(Vec eps,int analysis_type,int sub_analysis_type); 80 80 void GetNodes(void** vpnodes); 81 void PatchSize(int* p patch_numrows,int* pnumcols,int enum_type);82 void PatchFill(int* pcount, double* patches,int patch_numcols);81 void PatchSize(int* pnumrows, int* pnumvertices,int* pnumnodes,int enum_type); 82 void PatchFill(int* pcount, double* patches,int numcols,int max_vertices,int enum_type); 83 83 84 84 /*}}}*/ -
issm/trunk/src/c/objects/Elements/Element.h
r3938 r3956 47 47 virtual void ComputeStrainRate(Vec eps, int analysis_type,int sub_analysis_type)=0; 48 48 virtual double MassFlux(double* segment,double* ug)=0; 49 virtual void PatchSize(int* p patch_numrows,int* pnumcols,int enum_type)=0;50 virtual void PatchFill(int* pcount, double* patches,int patch_numcols)=0;49 virtual void PatchSize(int* pnumrows, int* pnumvertices,int* pnumnodes,int enum_type)=0; 50 virtual void PatchFill(int* pcount, double* patches,int numcols,int max_vertices,int enum_type)=0; 51 51 52 52 /*Implementation: */ -
issm/trunk/src/c/objects/Elements/Penta.cpp
r3947 r3956 4732 4732 } 4733 4733 /*}}}*/ 4734 /*FUNCTION Penta::PatchSize(int* ppatch_numrows,int* pnumcols, int enum_type){{{1*/ 4735 void Penta::PatchSize(int* ppatch_numrows,int* pnumcols, int enum_type){ 4736 this->inputs->PatchSize(ppatch_numrows,pnumcols,enum_type); 4737 } 4738 /*}}}*/ 4739 /*FUNCTION Penta::PatchFill(int* pcount, double* patches,int patch_numcols);{{{1*/ 4740 void Penta::PatchFill(int* pcount, double* patches,int patch_numcols){ 4741 this->inputs->PatchFill(pcount,patches,patch_numcols,this->parameters); 4742 } 4743 /*}}}*/ 4734 /*FUNCTION Penta::PatchSize(int* pnumrows, int* pnumvertices,int* pnumnodes, int enum_type){{{1*/ 4735 void Penta::PatchSize(int* pnumrows, int* pnumvertices,int* pnumnodes, int enum_type){ 4736 4737 int i; 4738 Input *input = NULL; 4739 bool found = false; 4740 int numrows; 4741 int numvertices; 4742 int numnodes; 4743 4744 /*Recover counter: */ 4745 numrows=*pnumrows; 4746 4747 /*Go through all the input objects, and find the one corresponding to enum_type, if it exists: */ 4748 for (i=0;i<this->inputs->Size();i++){ 4749 input=(Input*)this->inputs->GetObjectByOffset(i); 4750 if (input->EnumType()==enum_type){ 4751 found=true; 4752 break; 4753 } 4754 } 4755 4756 if (!found){ 4757 /*Ok, the input looked for does not exist. No problem. Just be sure numvertices and numnodes 4758 * are 0, so that they do not increase the size of the patches array. Also, do not increase 4759 * the counter, as this element has nothing to do with results: */ 4760 numvertices=0; 4761 numnodes=0; 4762 } 4763 else{ 4764 /*Ok, we found an input with the correct enum_type. Ask it to tell us how many nodal values it 4765 * holds. : */ 4766 numnodes=input->PatchSize(); 4767 /*We know the number of vertices from this element: */ 4768 numvertices=6; 4769 /*Increase counter, because this element does hold a result in its inputs: */ 4770 numrows++; 4771 } 4772 4773 /*Assign output pointers:*/ 4774 *pnumrows=numrows; 4775 *pnumvertices=numvertices; 4776 *pnumnodes=numnodes; 4777 4778 } 4779 /*}}}*/ 4780 /*FUNCTION Penta::PatchFill(int* pcount, double* patches,int numcols,int max_vertices);{{{1*/ 4781 void Penta::PatchFill(int* pcount, double* patches,int numcols,int max_vertices,int enum_type){ 4782 4783 /*A patch is made of the following information: 4784 * element_id interpolation_type vertex_ids values. 4785 * For example: 4786 4787 1 P0 1 2 4 11 12 14 4.5 NaN NaN NaN NaN NaN 4788 2 P1 2 4 5 12 14 15 4.5 23.3 23.3 4.2 4.2 3.2 4789 3 P0 5 2 1 15 12 11 5.5 NaN NaN NaN NaN NaN 4790 4 P1 2 3 5 12 13 15 4.5 30.2 322.2 4.2 3.2 8.3 4791 ... 4792 4793 Here, we can provide: id, and vertices ids. 4794 Then go find an input with enum_type. If we find it, fill in the values at the nodal points. 4795 If we don't find an input, get out of here doing nothing, as this element is not involved in 4796 outputting results. 4797 */ 4798 4799 int i; 4800 Input *input = NULL; 4801 bool found = false; 4802 int count = 0; 4803 double *this_patch = NULL; 4804 4805 4806 /*Go through all the input objects, and find the one corresponding to enum_type, if it exists: */ 4807 for (i=0;i<this->inputs->Size();i++){ 4808 input=(Input*)this->inputs->GetObjectByOffset(i); 4809 if (input->EnumType()==enum_type){ 4810 found=true; 4811 break; 4812 } 4813 } 4814 4815 if (!found){ 4816 /*Ok, the input looked for does not exist. No problem. Just return :*/ 4817 } 4818 else{ 4819 4820 /*First, recover the patches row where we will plug in the information: */ 4821 count=*pcount; 4822 4823 /*set this_patch to point at the beginning of the patches row, where we will plug our information :*/ 4824 this_patch=patches+numcols*count; 4825 4826 /*Fill in id: */ 4827 this_patch[0]=this->id; 4828 4829 /*Fill in vertices ids: */ 4830 for(i=0;i<6;i++) this_patch[2+i]=this->nodes[i]->GetVertexId(); //vertices id start at column 3 of the patch. 4831 4832 /*We found the input, get it to fill the interpolation type, and the nodal values:*/ 4833 input->PatchFill(this_patch,max_vertices,this->parameters); 4834 4835 /*Increase counter, so that next time, we don't point to the same patches row: */ 4836 count++; 4837 4838 /*Assign output pointers:*/ 4839 *pcount=count; 4840 } 4841 } 4842 /*}}}*/ -
issm/trunk/src/c/objects/Elements/Penta.h
r3946 r3956 144 144 void GetPhi(double* phi, double* epsilon, double viscosity); 145 145 double MassFlux(double* segment,double* ug); 146 void PatchSize(int* p patch_numrows,int* pnumcols,int enum_type);147 void PatchFill(int* pcount, double* patches,int patch_numcols);146 void PatchSize(int* pnumrows, int* pnumvertices,int* pnumnodes,int enum_type); 147 void PatchFill(int* pcount, double* patches,int numcols,int max_vertices,int enum_type); 148 148 149 149 /*updates: */ -
issm/trunk/src/c/objects/Elements/Sing.cpp
r3950 r3956 606 606 } 607 607 /*}}}*/ 608 /*FUNCTION Sing::PatchSize(int* ppatch_numrows,int* pnumcols, int enum_type){{{1*/ 609 void Sing::PatchSize(int* ppatch_numrows,int* pnumcols, int enum_type){ 610 this->inputs->PatchSize(ppatch_numrows,pnumcols,enum_type); 611 } 612 /*}}}*/ 613 /*FUNCTION Sing::PatchFill(int* pcount, double* patches,int patch_numcols);{{{1*/ 614 void Sing::PatchFill(int* pcount, double* patches,int patch_numcols){ 615 this->inputs->PatchFill(pcount,patches,patch_numcols,this->parameters); 616 } 617 /*}}}*/ 608 /*FUNCTION Sing::PatchSize(int* pnumrows, int* pnumvertices,int* pnumnodes, int enum_type){{{1*/ 609 void Sing::PatchSize(int* pnumrows, int* pnumvertices,int* pnumnodes, int enum_type){ 610 611 int i; 612 Input *input = NULL; 613 bool found = false; 614 int numrows; 615 int numvertices; 616 int numnodes; 617 618 /*Recover counter: */ 619 numrows=*pnumrows; 620 621 /*Go through all the input objects, and find the one corresponding to enum_type, if it exists: */ 622 for (i=0;i<this->inputs->Size();i++){ 623 input=(Input*)this->inputs->GetObjectByOffset(i); 624 if (input->EnumType()==enum_type){ 625 found=true; 626 break; 627 } 628 } 629 630 if (!found){ 631 /*Ok, the input looked for does not exist. No problem. Just be sure numvertices and numnodes 632 * are 0, so that they do not increase the size of the patches array. Also, do not increase 633 * the counter, as this element has nothing to do with results: */ 634 numvertices=0; 635 numnodes=0; 636 } 637 else{ 638 /*Ok, we found an input with the correct enum_type. Ask it to tell us how many nodal values it 639 * holds. : */ 640 numnodes=input->PatchSize(); 641 /*We know the number of vertices from this element: */ 642 numvertices=1; 643 /*Increase counter, because this element does hold a result in its inputs: */ 644 numrows++; 645 } 646 647 /*Assign output pointers:*/ 648 *pnumrows=numrows; 649 *pnumvertices=numvertices; 650 *pnumnodes=numnodes; 651 } 652 653 /*FUNCTION Sing::PatchFill(int* pcount, double* patches,int numcols,int max_vertices,int enum_type){{{1*/ 654 void Sing::PatchFill(int* pcount, double* patches,int numcols,int max_vertices,int enum_type){ 655 656 /*A patch is made of the following information: 657 * element_id interpolation_type vertex_ids values. 658 * For example: 659 660 1 P0 1 4.5 661 2 P1 3 4.5 662 3 P0 5 5.5 663 4 P1 4 4.5 664 665 Here, we will provide the nodal values, after having processed them, can provide: id, and vertices ids. 666 Then go find an input with enum_type. If we find it, fill in the values at the nodal points. 667 If we don't find an input, get out of here doing nothing, as this element is not involved in 668 outputting results. 669 */ 670 671 int i; 672 Input *input = NULL; 673 bool found = false; 674 int count = 0; 675 Node **nodes = NULL; 676 double *this_patch = NULL; 677 678 679 /*Go through all the input objects, and find the one corresponding to enum_type, if it exists: */ 680 for (i=0;i<this->inputs->Size();i++){ 681 input=(Input*)this->inputs->GetObjectByOffset(i); 682 if (input->EnumType()==enum_type){ 683 found=true; 684 break; 685 } 686 } 687 688 if (!found){ 689 /*Ok, the input looked for does not exist. No problem. Just return :*/ 690 } 691 else{ 692 693 /*First, recover the patches row where we will plug in the information: */ 694 count=*pcount; 695 696 /*Recover nodes: */ 697 nodes=(Node**)hnodes.deliverp(); 698 699 /*set this_patch to point at the beginning of the patches row, where we will plug our information :*/ 700 this_patch=patches+numcols*count; 701 702 /*Fill in id: */ 703 this_patch[0]=this->id; 704 705 /*Fill in vertices ids: */ 706 for(i=0;i<1;i++) this_patch[2+i]=nodes[i]->GetVertexId(); //vertices id start at column 3 of the patch. 707 708 /*We found the input, get it to fill the interpolation type, and the nodal values:*/ 709 input->PatchFill(this_patch,max_vertices,this->parameters); 710 711 /*Increase counter, so that next time, we don't point to the same patches row: */ 712 count++; 713 714 /*Assign output pointers:*/ 715 *pcount=count; 716 } 717 } 718 /*}}}*/ -
issm/trunk/src/c/objects/Elements/Sing.h
r3938 r3956 78 78 void ComputeStrainRate(Vec eps,int analysis_type,int sub_analysis_type); 79 79 void GetNodes(void** vpnodes); 80 void PatchSize(int* p patch_numrows,int* pnumcols,int enum_type);81 void PatchFill(int* pcount, double* patches,int patch_numcols);80 void PatchSize(int* pnumrows, int* pnumvertices,int* pnumnodes,int enum_type); 81 void PatchFill(int* pcount, double* patches,int numcols,int max_vertices,int enum_type); 82 82 83 83 /*}}}*/ -
issm/trunk/src/c/objects/Elements/Tria.cpp
r3946 r3956 4875 4875 } 4876 4876 /*}}}*/ 4877 /*FUNCTION Tria::PatchSize(int* ppatch_numrows,int* pnumcols, int enum_type){{{1*/ 4878 void Tria::PatchSize(int* ppatch_numrows,int* pnumcols, int enum_type){ 4879 this->inputs->PatchSize(ppatch_numrows,pnumcols,enum_type); 4880 } 4881 /*}}}*/ 4882 /*FUNCTION Tria::PatchFill(int* pcount, double* patches,int patch_numcols);{{{1*/ 4883 void Tria::PatchFill(int* pcount, double* patches,int patch_numcols){ 4884 this->inputs->PatchFill(pcount,patches,patch_numcols,this->parameters); 4885 } 4886 /*}}}*/ 4877 /*FUNCTION Tria::PatchSize(int* pnumrows, int* pnumvertices,int* pnumnodes, int enum_type){{{1*/ 4878 void Tria::PatchSize(int* pnumrows, int* pnumvertices,int* pnumnodes, int enum_type){ 4879 4880 int i; 4881 Input *input = NULL; 4882 bool found = false; 4883 int numrows; 4884 int numvertices; 4885 int numnodes; 4886 4887 /*Recover counter: */ 4888 numrows=*pnumrows; 4889 4890 /*Go through all the input objects, and find the one corresponding to enum_type, if it exists: */ 4891 for (i=0;i<this->inputs->Size();i++){ 4892 input=(Input*)this->inputs->GetObjectByOffset(i); 4893 if (input->EnumType()==enum_type){ 4894 found=true; 4895 break; 4896 } 4897 } 4898 4899 if (!found){ 4900 /*Ok, the input looked for does not exist. No problem. Just be sure numvertices and numnodes 4901 * are 0, so that they do not increase the size of the patches array. Also, do not increase 4902 * the counter, as this element has nothing to do with results: */ 4903 numvertices=0; 4904 numnodes=0; 4905 } 4906 else{ 4907 /*Ok, we found an input with the correct enum_type. Ask it to tell us how many nodal values it 4908 * holds. : */ 4909 numnodes=input->PatchSize(); 4910 /*We know the number of vertices from this element: */ 4911 numvertices=3; 4912 /*Increase counter, because this element does hold a result in its inputs: */ 4913 numrows++; 4914 } 4915 4916 /*Assign output pointers:*/ 4917 *pnumrows=numrows; 4918 *pnumvertices=numvertices; 4919 *pnumnodes=numnodes; 4920 4921 } 4922 /*}}}*/ 4923 /*FUNCTION Tria::PatchFill(int* pcount, double* patches,int numcols,int max_vertices);{{{1*/ 4924 void Tria::PatchFill(int* pcount, double* patches,int numcols,int max_vertices,int enum_type){ 4925 4926 /*A patch is made of the following information: 4927 * element_id interpolation_type vertex_ids values. 4928 * For example: 4929 4930 1 P0 1 2 4 4.5 NaN NaN 4931 2 P1 2 4 5 4.5 23.3 23.3 4932 3 P0 5 2 1 5.5 NaN NaN 4933 4 P1 2 3 5 4.5 30.2 322.2 4934 ... 4935 4936 Here, we can provide: id, and vertices ids. 4937 Then go find an input with enum_type. If we find it, fill in the values at the nodal points. 4938 If we don't find an input, get out of here doing nothing, as this element is not involved in 4939 outputting results. 4940 */ 4941 4942 int i; 4943 Input *input = NULL; 4944 bool found = false; 4945 int count = 0; 4946 double *this_patch = NULL; 4947 4948 4949 /*Go through all the input objects, and find the one corresponding to enum_type, if it exists: */ 4950 for (i=0;i<this->inputs->Size();i++){ 4951 input=(Input*)this->inputs->GetObjectByOffset(i); 4952 if (input->EnumType()==enum_type){ 4953 found=true; 4954 break; 4955 } 4956 } 4957 4958 if (!found){ 4959 /*Ok, the input looked for does not exist. No problem. Just return :*/ 4960 } 4961 else{ 4962 4963 /*First, recover the patches row where we will plug in the information: */ 4964 count=*pcount; 4965 4966 /*set this_patch to point at the beginning of the patches row, where we will plug our information :*/ 4967 this_patch=patches+numcols*count; 4968 4969 /*Fill in id: */ 4970 this_patch[0]=this->id; 4971 4972 /*Fill in vertices ids: */ 4973 for(i=0;i<3;i++) this_patch[2+i]=this->nodes[i]->GetVertexId(); //vertices id start at column 3 of the patch. 4974 4975 /*We found the input, get it to fill the interpolation type, and the nodal values:*/ 4976 input->PatchFill(this_patch,max_vertices,this->parameters); 4977 4978 /*Increase counter, so that next time, we don't point to the same patches row: */ 4979 count++; 4980 4981 /*Assign output pointers:*/ 4982 *pcount=count; 4983 } 4984 } 4985 /*}}}*/ -
issm/trunk/src/c/objects/Elements/Tria.h
r3946 r3956 122 122 double GetArea(void); 123 123 double GetAreaCoordinate(double x, double y, int which_one); 124 void PatchSize(int* p patch_numrows,int* pnumcols,int enum_type);125 void PatchFill(int* pcount, double* patches,int patch_numcols);124 void PatchSize(int* pnumrows, int* pnumvertices,int* pnumnodes,int enum_type); 125 void PatchFill(int* pcount, double* patches,int numcols,int max_vertices,int enum_type); 126 126 127 127 /*}}}*/ -
issm/trunk/src/c/objects/Inputs/BeamVertexInput.cpp
r3946 r3956 223 223 /*FUNCTION BeamVertexInput::PatchSize(void);{{{1*/ 224 224 int BeamVertexInput::PatchSize(void){ 225 226 /*Return the number of nodal values this input holds, so that 227 * results can be correctl dimensionned. See InputToResultsx 228 * module for more explanations: */ 225 229 return 2; 226 230 } 227 231 /*}}}*/ 228 /*FUNCTION BeamVertexInput::PatchFill(double* patches);{{{1*/ 229 void BeamVertexInput::PatchFill(double* patches,Parameters* parameters){ 230 patches[0]=values[0]; 231 patches[1]=values[1]; 232 233 /*Now, post-processing: */ 234 ProcessResults(patches,2,this->enum_type,parameters); 235 236 } 237 /*}}}*/ 232 /*FUNCTION BeamVertexInput::PatchFill(double* patches, int max_vertices,Parameters* parameters);{{{1*/ 233 void BeamVertexInput::PatchFill(double* patches, int max_vertices,Parameters* parameters){ 234 235 /*A patch is made of the following information: 236 * element_id interpolation_type vertex_ids values. 237 * For example: 238 239 1 P0 1 2 4.5 NaN 240 2 P1 1 3 4.5 3.2 241 3 P0 1 5 5.5 NaN 242 4 P1 2 4 4.5 3.2 243 244 Here, we fill the info relevant to the input, ie interpolation_type and nodal values: */ 245 int i; 246 247 patches[1]=P1Enum; 248 for(i=0;i<2;i++)patches[2+max_vertices+i]=values[i]; //start of nodal values is at position 2+max_vertices (2 for id and interpolation_type) and max_vertices for vertices ids. 249 250 /*Now, post-processing (essentially, unit conversion): */ 251 ProcessResults(patches+2+max_vertices,2,this->enum_type,parameters); 252 253 } 254 /*}}}*/ -
issm/trunk/src/c/objects/Inputs/BeamVertexInput.h
r3946 r3956 74 74 void ChangeEnum(int newenumtype); 75 75 int PatchSize(void); 76 void PatchFill(double* patches, Parameters* parameters);76 void PatchFill(double* patches, int max_vertices,Parameters* parameters); 77 77 /*}}}*/ 78 78 -
issm/trunk/src/c/objects/Inputs/BoolInput.cpp
r3946 r3956 213 213 /*FUNCTION BoolInput::PatchSize(void);{{{1*/ 214 214 int BoolInput::PatchSize(void){ 215 216 /*Return the number of nodal values this input holds, so that 217 * results can be correctl dimensionned. See InputToResultsx 218 * module for more explanations: */ 215 219 return 1; 216 220 } 217 221 /*}}}*/ 218 /*FUNCTION BoolInput::PatchFill(double* patches);{{{1*/ 219 void BoolInput::PatchFill(double* patches,Parameters* parameters){ 220 patches[0]=(double)value; 221 222 /*Now, post-processing: */ 223 ProcessResults(patches,1,this->enum_type,parameters); 224 } 225 /*}}}*/ 222 /*FUNCTION BoolInput::PatchFill(double* patches, int max_vertices,Parameters* parameters);{{{1*/ 223 void BoolInput::PatchFill(double* patches, int max_vertices,Parameters* parameters){ 224 225 ISSMERROR(" not supported yet!"); 226 } 227 /*}}}*/ -
issm/trunk/src/c/objects/Inputs/BoolInput.h
r3946 r3956 74 74 void ChangeEnum(int newenumtype); 75 75 int PatchSize(void); 76 void PatchFill(double* patches, Parameters* parameters);76 void PatchFill(double* patches, int max_vertices,Parameters* parameters); 77 77 /*}}}*/ 78 78 -
issm/trunk/src/c/objects/Inputs/DoubleInput.cpp
r3946 r3956 223 223 /*FUNCTION DoubleInput::PatchSize(void);{{{1*/ 224 224 int DoubleInput::PatchSize(void){ 225 226 /*Return the number of nodal values this input holds, so that 227 * results can be correctl dimensionned. See InputToResultsx 228 * module for more explanations: */ 225 229 return 1; 226 230 } 227 231 /*}}}*/ 228 /*FUNCTION DoubleInput::PatchFill(double* patches);{{{1*/ 229 void DoubleInput::PatchFill(double* patches,Parameters* parameters){ 230 patches[0]=value; 231 232 /*Now, post-processing: */ 233 ProcessResults(patches,1,this->enum_type,parameters); 234 } 235 /*}}}*/ 232 /*FUNCTION DoubleInput::PatchFill(double* patches, int max_vertices,Parameters* parameters);{{{1*/ 233 void DoubleInput::PatchFill(double* patches, int max_vertices,Parameters* parameters){ 234 235 ISSMERROR(" not supported yet!"); 236 } 237 /*}}}*/ -
issm/trunk/src/c/objects/Inputs/DoubleInput.h
r3946 r3956 74 74 void ChangeEnum(int newenumtype); 75 75 int PatchSize(void); 76 void PatchFill(double* patches, Parameters* parameters);76 void PatchFill(double* patches, int max_vertices,Parameters* parameters); 77 77 /*}}}*/ 78 78 -
issm/trunk/src/c/objects/Inputs/Input.h
r3946 r3956 48 48 virtual Input* SpawnTriaInput(int* indices)=0; 49 49 virtual int PatchSize(void)=0; 50 virtual void PatchFill(double* patch es,Parameters* parameters)=0;50 virtual void PatchFill(double* patch, int max_vertices,Parameters* parameters)=0; 51 51 /*}}}*/ 52 52 -
issm/trunk/src/c/objects/Inputs/IntInput.cpp
r3946 r3956 210 210 /*FUNCTION IntInput::PatchSize(void);{{{1*/ 211 211 int IntInput::PatchSize(void){ 212 213 /*Return the number of nodal values this input holds, so that 214 * results can be correctl dimensionned. See InputToResultsx 215 * module for more explanations: */ 212 216 return 1; 213 217 } 214 218 /*}}}*/ 215 /*FUNCTION IntInput::PatchFill(double* patches);{{{1*/ 216 void IntInput::PatchFill(double* patches,Parameters* parameters){ 217 patches[0]=(double)value; 218 219 /*Now, post-processing: */ 220 ProcessResults(patches,1,this->enum_type,parameters); 221 222 } 223 /*}}}*/ 219 /*FUNCTION IntInput::PatchFill(double* patches, int max_vertices,Parameters* parameters);{{{1*/ 220 void IntInput::PatchFill(double* patches, int max_vertices,Parameters* parameters){ 221 222 ISSMERROR(" not supported yet!"); 223 } 224 /*}}}*/ -
issm/trunk/src/c/objects/Inputs/IntInput.h
r3946 r3956 74 74 void ChangeEnum(int newenumtype); 75 75 int PatchSize(void); 76 void PatchFill(double* patches, Parameters* parameters);76 void PatchFill(double* patches, int max_vertices,Parameters* parameters); 77 77 /*}}}*/ 78 78 -
issm/trunk/src/c/objects/Inputs/PentaVertexInput.cpp
r3946 r3956 872 872 /*FUNCTION PentaVertexInput::PatchSize(void);{{{1*/ 873 873 int PentaVertexInput::PatchSize(void){ 874 875 /*Return the number of nodal values this input holds, so that 876 * results can be correctl dimensionned. See InputToResultsx 877 * module for more explanations: */ 874 878 return 6; 875 879 } 876 880 /*}}}*/ 877 /*FUNCTION PentaVertexInput::PatchFill(double* patches);{{{1*/ 878 void PentaVertexInput::PatchFill(double* patches,Parameters* parameters){ 879 880 patches[0]=values[0]; 881 patches[1]=values[1]; 882 patches[2]=values[2]; 883 patches[3]=values[3]; 884 patches[4]=values[4]; 885 patches[5]=values[5]; 881 /*FUNCTION PentaVertexInput::PatchFill(double* patches, int max_vertices,Parameters* parameters);{{{1*/ 882 void PentaVertexInput::PatchFill(double* patches, int max_vertices,Parameters* parameters){ 886 883 887 /*Now, post-processing: */ 888 ProcessResults(patches,6,this->enum_type,parameters); 889 890 } 891 /*}}}*/ 884 /*A patch is made of the following information: 885 * element_id interpolation_type vertex_ids values. 886 * For example: 887 888 1 P0 1 2 4 11 12 14 4.5 NaN NaN NaN NaN NaN 889 2 P1 2 4 5 12 14 15 4.5 23.3 23.3 4.2 4.2 3.2 890 3 P0 5 2 1 15 12 11 5.5 NaN NaN NaN NaN NaN 891 4 P1 2 3 5 12 13 15 4.5 30.2 322.2 4.2 3.2 8.3 892 ... 893 894 Here, we fill the info relevant to the input, ie interpolation_type and nodal values: */ 895 896 int i; 897 898 899 patches[1]=P1Enum; 900 for(i=0;i<6;i++)patches[2+max_vertices+i]=values[i]; //start of nodal values is at position 2+max_vertices (2 for id and interpolation_type) and max_vertices for vertices ids. 901 902 /*Now, post-processing (essentially, unit conversion): */ 903 ProcessResults(patches+2+max_vertices,6,this->enum_type,parameters); 904 905 } 906 /*}}}*/ 907 908 -
issm/trunk/src/c/objects/Inputs/PentaVertexInput.h
r3946 r3956 83 83 void GetBStokes(double* B, double* xyz_list, double* gauss_coord); 84 84 int PatchSize(void); 85 void PatchFill(double* patches, Parameters* parameters);85 void PatchFill(double* patches, int max_vertices,Parameters* parameters); 86 86 /*}}}*/ 87 87 -
issm/trunk/src/c/objects/Inputs/ProcessResults.cpp
r3938 r3956 1 1 /*!\file: ProcessResults.cpp 2 * \brief: process patch that was created by an input, for results purposes.2 * \brief: process nodal_values that were created by an input. 3 3 * For example, velocities need to be in m/yr, melting rates in m/yr, etc ... 4 4 * This centralizes all post-processing of inputs when they are being output to 5 * patchedresults.5 * results. 6 6 * 7 7 */ … … 19 19 #include "../../shared/shared.h" 20 20 21 void ProcessResults(double* patch, int patch_size,int enum_type,Parameters* parameters){21 void ProcessResults(double* nodal_values, int num_nodal_values,int enum_type,Parameters* parameters){ 22 22 23 23 int i; … … 28 28 29 29 switch(enum_type){ 30 case VxEnum: for(i=0;i< patch_size;i++)patch[i]=patch[i]/yts;break;31 case VyEnum: for(i=0;i< patch_size;i++)patch[i]=patch[i]/yts;break;32 case VzEnum: for(i=0;i< patch_size;i++)patch[i]=patch[i]/yts;break;33 case MeltingRateEnum: for(i=0;i< patch_size;i++)patch[i]=patch[i]/yts;break;30 case VxEnum: for(i=0;i<num_nodal_values;i++)nodal_values[i]=nodal_values[i]/yts;break; 31 case VyEnum: for(i=0;i<num_nodal_values;i++)nodal_values[i]=nodal_values[i]/yts;break; 32 case VzEnum: for(i=0;i<num_nodal_values;i++)nodal_values[i]=nodal_values[i]/yts;break; 33 case MeltingRateEnum: for(i=0;i<num_nodal_values;i++)nodal_values[i]=nodal_values[i]/yts;break; 34 34 default: break; 35 35 } -
issm/trunk/src/c/objects/Inputs/SingVertexInput.cpp
r3946 r3956 201 201 /*FUNCTION SingVertexInput::PatchSize(void);{{{1*/ 202 202 int SingVertexInput::PatchSize(void){ 203 204 /*Return the number of nodal values this input holds, so that 205 * results can be correctl dimensionned. See InputToResultsx 206 * module for more explanations: */ 203 207 return 1; 204 208 } 205 209 /*}}}*/ 206 /*FUNCTION SingVertexInput::PatchFill(double* patches);{{{1*/ 207 void SingVertexInput::PatchFill(double* patches,Parameters* parameters){ 208 patches[0]=value; 209 210 /*Now, post-processing: */ 211 ProcessResults(patches,1,this->enum_type,parameters); 212 213 } 214 /*}}}*/ 210 /*FUNCTION SingVertexInput::PatchFill(double* patches, int max_vertices,Parameters* parameters);{{{1*/ 211 void SingVertexInput::PatchFill(double* patches, int max_vertices,Parameters* parameters){ 212 213 /*A patch is made of the following information: 214 * element_id interpolation_type vertex_ids values. 215 * For example: 216 217 1 P0 2 4.5 218 2 P1 3 4.5 219 3 P0 5 5.5 220 4 P1 4 4.5 221 222 Here, we fill the info relevant to the input, ie interpolation_type and nodal values: */ 223 int i; 224 225 patches[1]=P1Enum; 226 patches[2+max_vertices+0]=value; //start of nodal values is at position 2+max_vertices (2 for id and interpolation_type) and max_vertices for vertices ids. 227 228 /*Now, post-processing (essentially, unit conversion): */ 229 ProcessResults(patches+2+max_vertices,1,this->enum_type,parameters); 230 231 } 232 /*}}}*/ -
issm/trunk/src/c/objects/Inputs/SingVertexInput.h
r3946 r3956 73 73 void ChangeEnum(int newenumtype); 74 74 int PatchSize(void); 75 void PatchFill(double* patches, Parameters* parameters);75 void PatchFill(double* patches, int max_vertices,Parameters* parameters); 76 76 /*}}}*/ 77 77 -
issm/trunk/src/c/objects/Inputs/TriaVertexInput.cpp
r3946 r3956 446 446 /*FUNCTION TriaVertexInput::PatchSize(void);{{{1*/ 447 447 int TriaVertexInput::PatchSize(void){ 448 449 /*Return the number of nodal values this input holds, so that 450 * results can be correctl dimensionned. See InputToResultsx 451 * module for more explanations: */ 448 452 return 3; 449 453 } 450 454 /*}}}*/ 451 /*FUNCTION TriaVertexInput::PatchFill(double* patches);{{{1*/ 452 void TriaVertexInput::PatchFill(double* patches,Parameters* parameters){ 453 454 patches[0]=values[0]; 455 patches[1]=values[1]; 456 patches[2]=values[2]; 457 458 /*Now, post-processing: */ 459 ProcessResults(patches,3,this->enum_type,parameters); 460 461 462 } 463 /*}}}*/ 455 /*FUNCTION TriaVertexInput::PatchFill(double* patches, int max_vertices,Parameters* parameters);{{{1*/ 456 void TriaVertexInput::PatchFill(double* patches, int max_vertices,Parameters* parameters){ 457 458 /*A patch is made of the following information: 459 * element_id interpolation_type vertex_ids values. 460 * For example: 461 462 1 P0 1 2 4 4.5 NaN NaN 463 2 P1 2 4 5 4.5 23.3 23.3 464 3 P0 5 2 1 5.5 NaN NaN 465 4 P1 2 3 5 4.5 30.2 322.2 466 ... 467 468 Here, we fill the info relevant to the input, ie interpolation_type and nodal values: */ 469 470 int i; 471 472 patches[1]=P1Enum; 473 for(i=0;i<3;i++)patches[2+max_vertices+i]=values[i]; //start of nodal values is at position 2+max_vertices (2 for id and interpolation_type) and max_vertices for vertices ids. 474 475 /*Now, post-processing (essentially, unit conversion): */ 476 ProcessResults(patches+2+max_vertices,3,this->enum_type,parameters); 477 478 } 479 /*}}}*/ -
issm/trunk/src/c/objects/Inputs/TriaVertexInput.h
r3946 r3956 81 81 void GetJacobianInvert(double* Jinv, double* xyz_list,double* gauss); 82 82 int PatchSize(void); 83 void PatchFill(double* patches, Parameters* parameters);83 void PatchFill(double* patches, int max_vertices,Parameters* parameters); 84 84 /*}}}*/ 85 85 -
issm/trunk/src/c/objects/Node.cpp
r3948 r3956 335 335 int Node::Id(void){ return id; } 336 336 /*}}}*/ 337 /*FUNCTION Node::GetVertexId {{{2*/ 338 int Node::GetVertexId(void){ 339 340 Vertex* vertex=NULL; 341 342 vertex=(Vertex*)hvertex.delivers(); 343 return vertex->id; 344 } 345 /*}}}*/ 337 346 /*FUNCTION Node::GetVertexDof {{{2*/ 338 347 int Node::GetVertexDof(void){ -
issm/trunk/src/c/objects/Node.h
r3947 r3956 47 47 int Id(void); 48 48 int GetVertexDof(void); 49 int GetVertexId(void); 49 50 void Marshall(char** pmarshalled_dataset); 50 51 int MarshallSize();
Note:
See TracChangeset
for help on using the changeset viewer.