Changeset 9343 for issm/trunk/src/c/objects/IoModel.cpp
- Timestamp:
- 08/12/11 18:45:12 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/objects/IoModel.cpp
r9340 r9343 843 843 } 844 844 /*}}}*/ 845 /*FUNCTION IoModel::FetchDataToInput(Elements* elements,IoModel* iomodel,int vector_enum,int default_vector_enum,double default_value{{{1*/ 846 void IoModel::FetchDataToInput(Elements* elements,int vector_enum,int default_vector_enum,double default_value){ 847 848 849 /*intermediary: */ 850 int i; 851 bool defaulting = false; 852 bool transient = false; 853 854 FILE *fid = NULL; 855 int code = 0; 856 int vector_layout = 0; 857 int counter; 858 int nods; 859 int nel; 860 861 862 /*variables being fetched: */ 863 bool boolean; 864 int integer; 865 double scalar; 866 char *string = NULL; 867 double *doublevector = NULL; 868 int M,N; 869 870 /*First of, find the record for the enum, and get code of data type: */ 871 fid=this->SetFilePointerToData(&code, &vector_layout,vector_enum); 872 873 switch(code){ 874 case 1: //boolean constant. {{{2 875 this->FetchData(&boolean,vector_enum); 876 877 /*Add boolean constant input to all elements: */ 878 counter=0; 879 for (i=0;i<this->numberofelements;i++){ 880 if(this->my_elements[i]){ 881 Element* element=(Element*)elements->GetObjectByOffset(counter); 882 element->InputCreate((double)boolean,vector_enum,code); 883 counter++; 884 } 885 } 886 break; /*}}}*/ 887 case 2: //integer constant. {{{2 888 this->FetchData(&integer,vector_enum); 889 890 /*Add integer constant input to all elements: */ 891 counter=0; 892 for (i=0;i<this->numberofelements;i++){ 893 if(this->my_elements[i]){ 894 Element* element=(Element*)elements->GetObjectByOffset(counter); 895 element->InputCreate((double)integer,vector_enum,code); 896 counter++; 897 } 898 } 899 break; /*}}}*/ 900 case 3: //double constant. {{{2 901 this->FetchData(&scalar,vector_enum); 902 903 /*Add double constant input to all elements: */ 904 counter=0; 905 for (i=0;i<this->numberofelements;i++){ 906 if(this->my_elements[i]){ 907 Element* element=(Element*)elements->GetObjectByOffset(counter); 908 element->InputCreate(scalar,vector_enum,code); 909 counter++; 910 } 911 } 912 break; /*}}}*/ 913 case 5: //boolean vector. {{{2 914 915 /*Fetch vector:*/ 916 this->FetchData(&doublevector,&M,&N,vector_enum); //we still have a doublevector, because it might include times in transient mode 917 /*Check we got something, otherwise fetch default: */ 918 if(doublevector){ 919 defaulting=false; //we are not defaulting, because we do have a vector 920 } 921 else{ 922 /*do we have a default enum to go fetch? */ 923 if(default_vector_enum!=NoneEnum){ 924 /*yes. fetch it: */ 925 this->FetchData(&doublevector,&M,&N,default_vector_enum); 926 if(doublevector){ 927 defaulting=false; //we are not defaulting, because we do have a vector 928 } 929 else{ 930 /*even the default vector is non existent. we are defaulting to the default value: */ 931 defaulting=true; 932 } 933 } 934 else{ 935 /*we are left with the default value: */ 936 defaulting=true; 937 } 938 } 939 940 /*Create inputs:*/ 941 counter=0; 942 for (i=0;i<this->numberofelements;i++){ 943 if(this->my_elements[i]){ 944 Element* element=(Element*)elements->GetObjectByOffset(counter); 945 if(defaulting) element->InputCreate(default_value,vector_enum,code); 946 else element->InputCreate(doublevector,i,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements. 947 counter++; 948 } 949 } 950 break; /*}}}*/ 951 case 6: //int vector. {{{2 952 953 /*Fetch vector:*/ 954 this->FetchData(&doublevector,&M,&N,vector_enum); //we still have a doublevector, because it might include times in transient mode 955 /*Check we got something, otherwise fetch default: */ 956 if(doublevector){ 957 defaulting=false; //we are not defaulting, because we do have a vector 958 } 959 else{ 960 /*do we have a default enum to go fetch? */ 961 if(default_vector_enum!=NoneEnum){ 962 /*yes. fetch it: */ 963 this->FetchData(&doublevector,&M,&N,default_vector_enum); 964 if(doublevector){ 965 defaulting=false; //we are not defaulting, because we do have a vector 966 } 967 else{ 968 /*even the default vector is non existent. we are defaulting to the default value: */ 969 defaulting=true; 970 } 971 } 972 else{ 973 /*we are left with the default value: */ 974 defaulting=true; 975 } 976 } 977 978 /*Create inputs:*/ 979 counter=0; 980 for (i=0;i<this->numberofelements;i++){ 981 if(this->my_elements[i]){ 982 Element* element=(Element*)elements->GetObjectByOffset(counter); 983 if(defaulting) element->InputCreate(default_value,vector_enum,code); 984 else element->InputCreate(doublevector,i,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements. 985 counter++; 986 } 987 } 988 break; /*}}}*/ 989 case 7: //double vector. {{{2 990 991 /*Fetch vector:*/ 992 this->FetchData(&doublevector,&M,&N,vector_enum); 993 /*Check we got something, otherwise fetch default: */ 994 if(doublevector){ 995 defaulting=false; //we are not defaulting, because we do have a vector 996 } 997 else{ 998 /*do we have a default enum to go fetch? */ 999 if(default_vector_enum!=NoneEnum){ 1000 /*yes. fetch it: */ 1001 this->FetchData(&doublevector,&M,&N,default_vector_enum); 1002 if(doublevector){ 1003 defaulting=false; //we are not defaulting, because we do have a vector 1004 } 1005 else{ 1006 /*even the default vector is non existent. we are defaulting to the default value: */ 1007 defaulting=true; 1008 } 1009 } 1010 else{ 1011 /*we are left with the default value: */ 1012 defaulting=true; 1013 } 1014 } 1015 1016 /*Create inputs:*/ 1017 counter=0; 1018 for (i=0;i<this->numberofelements;i++){ 1019 if(this->my_elements[i]){ 1020 Element* element=(Element*)elements->GetObjectByOffset(counter); 1021 if(defaulting) element->InputCreate(default_value,vector_enum,code); 1022 else element->InputCreate(doublevector,i,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements. 1023 counter++; 1024 } 1025 } 1026 1027 break; /*}}}*/ 1028 default: /*{{{2*/ 1029 _error_("%s%i%s","data code ",code," not supported yet!"); 1030 break; 1031 /*}}}*/ 1032 } 1033 /*Free ressources:*/ 1034 xfree((void**)&doublevector); 1035 xfree((void**)&string); 1036 }
Note:
See TracChangeset
for help on using the changeset viewer.