Changeset 6213
- Timestamp:
- 10/08/10 16:49:12 (14 years ago)
- Location:
- issm/trunk/src/c
- Files:
-
- 1 added
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/Container/Parameters.cpp
r4873 r6213 175 175 } 176 176 /*}}}*/ 177 /*FUNCTION Parameters::FindParam(int** pintarray,int* pM,int enum_type){{{1*/ 178 int Parameters::FindParam(int** pintarray,int* pM, int enum_type){ 179 180 /*Go through a dataset, and find a Param* object 181 *which parameter name is "name" : */ 182 183 vector<Object*>::iterator object; 184 Param* param=NULL; 185 186 int found=0; 187 188 for ( object=objects.begin() ; object < objects.end(); object++ ){ 189 190 /*Ok, this object is a parameter, recover it and ask which name it has: */ 191 param=(Param*)(*object); 192 193 if(param->EnumType()==enum_type){ 194 /*Ok, this is the one! Recover the value of this parameter: */ 195 param->GetParameterValue(pintarray,pM); 196 found=1; 197 break; 198 } 199 } 200 return found; 201 202 } 203 /*}}}*/ 177 204 /*FUNCTION Parameters::FindParam(double** pdoublearray,int* pM,int enum_type){{{1*/ 178 205 int Parameters::FindParam(double** pdoublearray,int* pM, int enum_type){ -
issm/trunk/src/c/Container/Parameters.h
r4873 r6213 31 31 int FindParam(char** pstring,int enum_type); 32 32 int FindParam(char*** pstringarray,int* pM,int enum_type); 33 int FindParam(int** pintarray,int* pM,int enum_type); 33 34 int FindParam(double** pdoublearray,int* pM,int enum_type); 34 35 int FindParam(double** pdoublearray,int* pM,int* pN,int enum_type); -
issm/trunk/src/c/Makefile.am
r6200 r6213 383 383 ./modules/ModelProcessorx/SurfaceSlope/CreateLoadsSurfaceSlope.cpp\ 384 384 ./modules/ModelProcessorx/Control/CreateParametersControl.cpp\ 385 ./modules/ModelProcessorx/Control/UpdateElementsAndMaterialsControl.cpp\ 385 386 ./modules/ModelProcessorx/Thermal/UpdateElementsThermal.cpp\ 386 387 ./modules/ModelProcessorx/Thermal/CreateNodesThermal.cpp\ … … 952 953 ./modules/ModelProcessorx/SurfaceSlope/CreateLoadsSurfaceSlope.cpp\ 953 954 ./modules/ModelProcessorx/Control/CreateParametersControl.cpp\ 955 ./modules/ModelProcessorx/Control/UpdateElementsAndMaterialsControl.cpp\ 954 956 ./modules/ModelProcessorx/Thermal/UpdateElementsThermal.cpp\ 955 957 ./modules/ModelProcessorx/Thermal/CreateNodesThermal.cpp\ -
issm/trunk/src/c/modules/ModelProcessorx/Balancedthickness/UpdateElementsBalancedthickness.cpp
r6201 r6213 37 37 } 38 38 if(iomodel->control_analysis){ 39 IoModelFetchData(&iomodel->control_type,NULL,NULL,iomodel_handle,"control_type"); 39 40 IoModelFetchData(&iomodel->thickness_obs,NULL,NULL,iomodel_handle,"thickness_obs"); 40 41 IoModelFetchData(&iomodel->weights,NULL,NULL,iomodel_handle,"weights"); … … 66 67 xfree((void**)&iomodel->thickness_obs); 67 68 xfree((void**)&iomodel->weights); 69 xfree((void**)&iomodel->control_type); 68 70 } -
issm/trunk/src/c/modules/ModelProcessorx/Control/CreateParametersControl.cpp
r6201 r6213 27 27 28 28 /*What control type?*/ 29 if (iomodel->control_type!=DragCoefficientEnum && 30 iomodel->control_type!=RheologyBbarEnum && 31 iomodel->control_type!=DhDtEnum && 32 iomodel->control_type!=VxEnum && 33 iomodel->control_type!=VyEnum 34 ) ISSMERROR("control_type %s not supported yet!",EnumToString(iomodel->control_type)); 35 36 parameters->AddObject(new IntParam(ControlTypeEnum,iomodel->control_type)); 29 IoModelFetchData(&iomodel->control_type,NULL,NULL,iomodel_handle,"control_type"); 30 parameters->AddObject(new IntVecParam(ControlTypeEnum,iomodel->control_type,iomodel->num_control_type)); 31 xfree((void**)&iomodel->control_type); 37 32 38 33 /*What solution type?*/ -
issm/trunk/src/c/modules/ModelProcessorx/CreateDataSets.cpp
r5579 r6213 18 18 void CreateDataSets(Elements** pelements,Nodes** pnodes, Vertices** pvertices, Materials** pmaterials, Constraints** pconstraints, Loads** ploads,Parameters** pparameters,IoModel* iomodel,ConstDataHandle iomodel_handle,const int solution_type,const int analysis_type,const int nummodels,int analysis_counter){ 19 19 20 bool continuous=true; 21 Elements* elements=NULL; 20 bool continuous = true; 21 Elements *elements = NULL; 22 Materials *materials = NULL; 22 23 23 24 /*Create elements, vertices and materials, independent of analysis_type: */ 24 25 CreateElementsVerticesAndMaterials(pelements, pvertices, pmaterials, iomodel,iomodel_handle,nummodels); 25 26 26 /*Recover elements , for future update: */27 /*Recover elements and materials, for future update: */ 27 28 elements=*pelements; 29 materials=*pmaterials; 28 30 29 31 /*Now, branch onto analysis dependent model generation: */ … … 102 104 } 103 105 106 /*Update Elements and Materials For Control methods*/ 107 UpdateElementsAndMaterialsControl(elements,materials,iomodel,iomodel_handle); 108 104 109 /*Generate objects that are not dependent on any analysis_type: */ 105 110 CreateParameters(pparameters,iomodel,iomodel_handle,solution_type,analysis_type,analysis_counter); -
issm/trunk/src/c/modules/ModelProcessorx/CreateElementsVerticesAndMaterials.cpp
r6201 r6213 40 40 IoModelFetchData(&iomodel->rheology_B,NULL,NULL,iomodel_handle,"rheology_B"); 41 41 IoModelFetchData(&iomodel->rheology_n,NULL,NULL,iomodel_handle,"rheology_n"); 42 IoModelFetchData(&iomodel->control_type,NULL,NULL,iomodel_handle,"control_type"); 42 43 43 44 /*Create elements and materials: */ … … 61 62 xfree((void**)&iomodel->rheology_B); 62 63 xfree((void**)&iomodel->rheology_n); 64 xfree((void**)&iomodel->control_type); 63 65 64 66 /*Add new constrant material property tgo materials, at the end: */ … … 95 97 *pvertices=vertices; 96 98 *pmaterials=materials; 97 98 99 } -
issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/UpdateElementsDiagnosticHoriz.cpp
r6201 r6213 47 47 } 48 48 if(iomodel->control_analysis){ 49 IoModelFetchData(&iomodel->control_type,NULL,NULL,iomodel_handle,"control_type"); 49 50 IoModelFetchData(&iomodel->vx_obs,NULL,NULL,iomodel_handle,"vx_obs"); 50 51 IoModelFetchData(&iomodel->vy_obs,NULL,NULL,iomodel_handle,"vy_obs"); … … 87 88 xfree((void**)&iomodel->vy_obs); 88 89 xfree((void**)&iomodel->weights); 90 xfree((void**)&iomodel->control_type); 89 91 } -
issm/trunk/src/c/modules/ModelProcessorx/ModelProcessorx.h
r5579 r6213 21 21 void CreateParametersControl(Parameters** pparameters,IoModel* iomodel,ConstDataHandle iomodel_handle,int solution_type,int analysis_type); 22 22 void CreateParametersQmu(Parameters** pparameters,IoModel* iomodel,ConstDataHandle iomodel_handle,int solution_type,int analysis_type); 23 void UpdateElementsAndMaterialsControl(Elements* elements,Materials* materials, IoModel* iomodel,ConstDataHandle iomodel_handle); 23 24 24 25 /*Creation of fem datasets: specialised drivers: */ -
issm/trunk/src/c/objects/Elements/Element.h
r6200 r6213 56 56 virtual void DeleteResults(void)=0; 57 57 virtual void Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type)=0; 58 virtual void Update(int index, IoModel* iomodel)=0; 58 59 virtual void UpdateGeometry(void)=0; 59 60 virtual void InputToResult(int enum_type,int step,double time)=0; -
issm/trunk/src/c/objects/Elements/Penta.cpp
r6212 r6213 641 641 } 642 642 if (!input) ISSMERROR("Input %s not found",EnumToString(enum_type)); 643 if (input->Enum()!=ControlInputEnum) ISSMERROR("Input %s is not a ControlInput",EnumToString(enum_type)); 643 644 644 645 this->GetDofList1(&doflist1[0]); … … 661 662 } 662 663 if (!input) ISSMERROR("Input %s not found",EnumToString(enum_type)); 664 if (input->Enum()!=ControlInputEnum) ISSMERROR("Input %s is not a ControlInput",EnumToString(enum_type)); 663 665 664 666 this->GetDofList1(&doflist1[0]); … … 959 961 960 962 /*Intermediary*/ 961 int control_type; 963 int num_controls; 964 int* control_type=NULL; 962 965 Input* input=NULL; 963 966 double cm_min,cm_max; … … 966 969 this->parameters->FindParam(&cm_min,CmMinEnum); 967 970 this->parameters->FindParam(&cm_max,CmMaxEnum); 968 this->parameters->FindParam(&control_type,ControlTypeEnum); 969 970 if(control_type==RheologyBbarEnum){ 971 if (!IsOnBed()) return; 972 input=(Input*)matice->inputs->GetInput(RheologyBEnum); ISSMASSERT(input); 973 } 974 else{ 975 input=(Input*)this->inputs->GetInput(control_type); ISSMASSERT(input); 976 } 977 978 if (input->Enum()!=ControlInputEnum) ISSMERROR("input %s is not a ControlInput",EnumToString(control_type)); 979 980 ((ControlInput*)input)->UpdateValue(scalar); 981 input->Constrain(cm_min,cm_max); 982 if (save_parameter) ((ControlInput*)input)->SaveValue(); 983 984 if(control_type==RheologyBbarEnum){ 985 this->InputExtrude(RheologyBEnum,MaterialsEnum); 986 } 971 this->parameters->FindParam(&num_controls,NumControlsEnum); 972 this->parameters->FindParam(&control_type,NULL,ControlTypeEnum); 973 974 for(int i=0;i<num_controls;i++){ 975 976 if(control_type[i]==RheologyBbarEnum){ 977 if (!IsOnBed()) return; 978 input=(Input*)matice->inputs->GetInput(RheologyBEnum); ISSMASSERT(input); 979 } 980 else{ 981 input=(Input*)this->inputs->GetInput(control_type[i]); ISSMASSERT(input); 982 } 983 984 if (input->Enum()!=ControlInputEnum) ISSMERROR("input %s is not a ControlInput",EnumToString(control_type[i])); 985 986 ((ControlInput*)input)->UpdateValue(scalar); 987 input->Constrain(cm_min,cm_max); 988 if (save_parameter) ((ControlInput*)input)->SaveValue(); 989 990 if(control_type[i]==RheologyBbarEnum){ 991 this->InputExtrude(RheologyBEnum,MaterialsEnum); 992 } 993 } 994 995 /*Clean up and return*/ 996 xfree((void**)&control_type); 987 997 } 988 998 /*}}}*/ … … 1688 1698 } 1689 1699 /*}}}*/ 1690 /*FUNCTION Penta::Update {{{1*/1700 /*FUNCTION Penta::Update(int index,IoModel* iomodel,int analysis_counter,int analysis_type) {{{1*/ 1691 1701 void Penta::Update(int index,IoModel* iomodel,int analysis_counter,int analysis_type){ 1692 1702 1693 1703 /*Intermediaries*/ 1694 IssmInt i ;1704 IssmInt i,j; 1695 1705 int penta_type; 1696 1706 int penta_node_ids[6]; … … 1729 1739 this->SetHookNodes(penta_node_ids,analysis_counter); this->nodes=NULL; //set hook to nodes, for this analysis type 1730 1740 1731 //add as many inputs per element as requested: 1732 if (iomodel->thickness) { 1733 for(i=0;i<6;i++)nodeinputs[i]=iomodel->thickness[penta_vertex_ids[i]-1]; 1734 this->inputs->AddInput(new PentaVertexInput(ThicknessEnum,nodeinputs)); 1735 } 1736 if (iomodel->surface) { 1737 for(i=0;i<6;i++)nodeinputs[i]=iomodel->surface[penta_vertex_ids[i]-1]; 1738 this->inputs->AddInput(new PentaVertexInput(SurfaceEnum,nodeinputs)); 1739 } 1740 if (iomodel->bed) { 1741 for(i=0;i<6;i++)nodeinputs[i]=iomodel->bed[penta_vertex_ids[i]-1]; 1742 this->inputs->AddInput(new PentaVertexInput(BedEnum,nodeinputs)); 1743 } 1744 if (iomodel->drag_coefficient) { 1745 for(i=0;i<6;i++)nodeinputs[i]=iomodel->drag_coefficient[penta_vertex_ids[i]-1]; 1746 this->inputs->AddInput(new PentaVertexInput(DragCoefficientEnum,nodeinputs)); 1747 1748 if (iomodel->drag_p) this->inputs->AddInput(new DoubleInput(DragPEnum,iomodel->drag_p[index])); 1749 if (iomodel->drag_q) this->inputs->AddInput(new DoubleInput(DragQEnum,iomodel->drag_q[index])); 1750 this->inputs->AddInput(new IntInput(DragTypeEnum,iomodel->drag_type)); 1751 1752 } 1753 if (iomodel->melting_rate) { 1754 for(i=0;i<6;i++)nodeinputs[i]=iomodel->melting_rate[penta_vertex_ids[i]-1]/iomodel->yts; 1755 this->inputs->AddInput(new PentaVertexInput(MeltingRateEnum,nodeinputs)); 1756 } 1757 if (iomodel->accumulation_rate) { 1758 for(i=0;i<6;i++)nodeinputs[i]=iomodel->accumulation_rate[penta_vertex_ids[i]-1]/iomodel->yts; 1759 this->inputs->AddInput(new PentaVertexInput(AccumulationRateEnum,nodeinputs)); 1760 } 1761 if (iomodel->geothermalflux) { 1762 for(i=0;i<6;i++)nodeinputs[i]=iomodel->geothermalflux[penta_vertex_ids[i]-1]; 1763 this->inputs->AddInput(new PentaVertexInput(GeothermalFluxEnum,nodeinputs)); 1764 } 1765 if (iomodel->pressure) { 1766 for(i=0;i<6;i++)nodeinputs[i]=iomodel->pressure[penta_vertex_ids[i]-1]; 1767 this->inputs->AddInput(new PentaVertexInput(PressureEnum,nodeinputs)); 1768 } 1769 if (iomodel->temperature) { 1770 for(i=0;i<6;i++)nodeinputs[i]=iomodel->temperature[penta_vertex_ids[i]-1]; 1771 this->inputs->AddInput(new PentaVertexInput(TemperatureEnum,nodeinputs)); 1772 } 1773 if (iomodel->dhdt) { 1774 for(i=0;i<6;i++)nodeinputs[i]=iomodel->dhdt[penta_vertex_ids[i]-1]/iomodel->yts; 1775 this->inputs->AddInput(new PentaVertexInput(DhDtEnum,nodeinputs)); 1776 } 1777 /*vx,vy and vz: */ 1778 if (iomodel->vx) { 1779 for(i=0;i<6;i++)nodeinputs[i]=iomodel->vx[penta_vertex_ids[i]-1]/iomodel->yts; 1780 this->inputs->AddInput(new PentaVertexInput(VxEnum,nodeinputs)); 1781 this->inputs->AddInput(new PentaVertexInput(VxOldEnum,nodeinputs)); 1782 if(iomodel->qmu_analysis)this->inputs->AddInput(new PentaVertexInput(QmuVxEnum,nodeinputs)); 1783 } 1784 if (iomodel->vy) { 1785 for(i=0;i<6;i++)nodeinputs[i]=iomodel->vy[penta_vertex_ids[i]-1]/iomodel->yts; 1786 this->inputs->AddInput(new PentaVertexInput(VyEnum,nodeinputs)); 1787 this->inputs->AddInput(new PentaVertexInput(VyOldEnum,nodeinputs)); 1788 if(iomodel->qmu_analysis)this->inputs->AddInput(new PentaVertexInput(QmuVyEnum,nodeinputs)); 1789 } 1790 if (iomodel->vz) { 1791 for(i=0;i<6;i++)nodeinputs[i]=iomodel->vz[penta_vertex_ids[i]-1]/iomodel->yts; 1792 this->inputs->AddInput(new PentaVertexInput(VzEnum,nodeinputs)); 1793 this->inputs->AddInput(new PentaVertexInput(VzOldEnum,nodeinputs)); 1794 if(iomodel->qmu_analysis)this->inputs->AddInput(new PentaVertexInput(QmuVzEnum,nodeinputs)); 1795 } 1796 if (iomodel->vx_obs) { 1797 for(i=0;i<6;i++)nodeinputs[i]=iomodel->vx_obs[penta_vertex_ids[i]-1]/iomodel->yts; 1798 this->inputs->AddInput(new PentaVertexInput(VxObsEnum,nodeinputs)); 1799 } 1800 if (iomodel->vy_obs) { 1801 for(i=0;i<6;i++)nodeinputs[i]=iomodel->vy_obs[penta_vertex_ids[i]-1]/iomodel->yts; 1802 this->inputs->AddInput(new PentaVertexInput(VyObsEnum,nodeinputs)); 1803 } 1804 if (iomodel->vz_obs) { 1805 for(i=0;i<6;i++)nodeinputs[i]=iomodel->vz_obs[penta_vertex_ids[i]-1]/iomodel->yts; 1806 this->inputs->AddInput(new PentaVertexInput(VzObsEnum,nodeinputs)); 1807 } 1808 if (iomodel->weights) { 1809 for(i=0;i<6;i++)nodeinputs[i]=iomodel->weights[penta_vertex_ids[i]-1]; 1810 this->inputs->AddInput(new PentaVertexInput(WeightsEnum,nodeinputs)); 1811 } 1812 if (iomodel->elementoniceshelf) this->inputs->AddInput(new BoolInput(ElementOnIceShelfEnum,(IssmBool)iomodel->elementoniceshelf[index])); 1813 if (iomodel->elementonbed) this->inputs->AddInput(new BoolInput(ElementOnBedEnum,(IssmBool)iomodel->elementonbed[index])); 1814 if (iomodel->elementonwater) this->inputs->AddInput(new BoolInput(ElementOnWaterEnum,(IssmBool)iomodel->elementonwater[index])); 1815 if (iomodel->elementonsurface) this->inputs->AddInput(new BoolInput(ElementOnSurfaceEnum,(IssmBool)iomodel->elementonsurface[index])); 1741 /*Fill with IoModel*/ 1742 this->Update(index,iomodel); 1816 1743 1817 1744 /*Defaults if not provided in iomodel*/ … … 1888 1815 } 1889 1816 1817 } 1818 /*}}}*/ 1819 /*FUNCTION Penta::Update(int index,IoModel* iomodel) {{{1*/ 1820 void Penta::Update(int index,IoModel* iomodel){ 1821 1822 /*Intermediaries*/ 1823 IssmInt i,j; 1824 int penta_vertex_ids[6]; 1825 double nodeinputs[6]; 1826 1827 /*Checks if debuging*/ 1828 /*{{{2*/ 1829 ISSMASSERT(iomodel->elements); 1830 /*}}}*/ 1831 1832 /*Recover vertices ids needed to initialize inputs*/ 1833 for(i=0;i<6;i++){ 1834 penta_vertex_ids[i]=(int)iomodel->elements[6*index+i]; //ids for vertices are in the elements array from Matlab 1835 } 1836 1837 //add as many inputs per element as requested: 1838 if (iomodel->thickness) { 1839 for(i=0;i<6;i++)nodeinputs[i]=iomodel->thickness[penta_vertex_ids[i]-1]; 1840 this->inputs->AddInput(new PentaVertexInput(ThicknessEnum,nodeinputs)); 1841 } 1842 if (iomodel->surface) { 1843 for(i=0;i<6;i++)nodeinputs[i]=iomodel->surface[penta_vertex_ids[i]-1]; 1844 this->inputs->AddInput(new PentaVertexInput(SurfaceEnum,nodeinputs)); 1845 } 1846 if (iomodel->bed) { 1847 for(i=0;i<6;i++)nodeinputs[i]=iomodel->bed[penta_vertex_ids[i]-1]; 1848 this->inputs->AddInput(new PentaVertexInput(BedEnum,nodeinputs)); 1849 } 1850 if (iomodel->drag_coefficient) { 1851 for(i=0;i<6;i++)nodeinputs[i]=iomodel->drag_coefficient[penta_vertex_ids[i]-1]; 1852 this->inputs->AddInput(new PentaVertexInput(DragCoefficientEnum,nodeinputs)); 1853 1854 if (iomodel->drag_p) this->inputs->AddInput(new DoubleInput(DragPEnum,iomodel->drag_p[index])); 1855 if (iomodel->drag_q) this->inputs->AddInput(new DoubleInput(DragQEnum,iomodel->drag_q[index])); 1856 this->inputs->AddInput(new IntInput(DragTypeEnum,iomodel->drag_type)); 1857 1858 } 1859 if (iomodel->melting_rate) { 1860 for(i=0;i<6;i++)nodeinputs[i]=iomodel->melting_rate[penta_vertex_ids[i]-1]/iomodel->yts; 1861 this->inputs->AddInput(new PentaVertexInput(MeltingRateEnum,nodeinputs)); 1862 } 1863 if (iomodel->accumulation_rate) { 1864 for(i=0;i<6;i++)nodeinputs[i]=iomodel->accumulation_rate[penta_vertex_ids[i]-1]/iomodel->yts; 1865 this->inputs->AddInput(new PentaVertexInput(AccumulationRateEnum,nodeinputs)); 1866 } 1867 if (iomodel->geothermalflux) { 1868 for(i=0;i<6;i++)nodeinputs[i]=iomodel->geothermalflux[penta_vertex_ids[i]-1]; 1869 this->inputs->AddInput(new PentaVertexInput(GeothermalFluxEnum,nodeinputs)); 1870 } 1871 if (iomodel->pressure) { 1872 for(i=0;i<6;i++)nodeinputs[i]=iomodel->pressure[penta_vertex_ids[i]-1]; 1873 this->inputs->AddInput(new PentaVertexInput(PressureEnum,nodeinputs)); 1874 } 1875 if (iomodel->temperature) { 1876 for(i=0;i<6;i++)nodeinputs[i]=iomodel->temperature[penta_vertex_ids[i]-1]; 1877 this->inputs->AddInput(new PentaVertexInput(TemperatureEnum,nodeinputs)); 1878 } 1879 if (iomodel->dhdt) { 1880 for(i=0;i<6;i++)nodeinputs[i]=iomodel->dhdt[penta_vertex_ids[i]-1]/iomodel->yts; 1881 this->inputs->AddInput(new PentaVertexInput(DhDtEnum,nodeinputs)); 1882 } 1883 /*vx,vy and vz: */ 1884 if (iomodel->vx) { 1885 for(i=0;i<6;i++)nodeinputs[i]=iomodel->vx[penta_vertex_ids[i]-1]/iomodel->yts; 1886 this->inputs->AddInput(new PentaVertexInput(VxEnum,nodeinputs)); 1887 this->inputs->AddInput(new PentaVertexInput(VxOldEnum,nodeinputs)); 1888 if(iomodel->qmu_analysis)this->inputs->AddInput(new PentaVertexInput(QmuVxEnum,nodeinputs)); 1889 } 1890 if (iomodel->vy) { 1891 for(i=0;i<6;i++)nodeinputs[i]=iomodel->vy[penta_vertex_ids[i]-1]/iomodel->yts; 1892 this->inputs->AddInput(new PentaVertexInput(VyEnum,nodeinputs)); 1893 this->inputs->AddInput(new PentaVertexInput(VyOldEnum,nodeinputs)); 1894 if(iomodel->qmu_analysis)this->inputs->AddInput(new PentaVertexInput(QmuVyEnum,nodeinputs)); 1895 } 1896 if (iomodel->vz) { 1897 for(i=0;i<6;i++)nodeinputs[i]=iomodel->vz[penta_vertex_ids[i]-1]/iomodel->yts; 1898 this->inputs->AddInput(new PentaVertexInput(VzEnum,nodeinputs)); 1899 this->inputs->AddInput(new PentaVertexInput(VzOldEnum,nodeinputs)); 1900 if(iomodel->qmu_analysis)this->inputs->AddInput(new PentaVertexInput(QmuVzEnum,nodeinputs)); 1901 } 1902 if (iomodel->vx_obs) { 1903 for(i=0;i<6;i++)nodeinputs[i]=iomodel->vx_obs[penta_vertex_ids[i]-1]/iomodel->yts; 1904 this->inputs->AddInput(new PentaVertexInput(VxObsEnum,nodeinputs)); 1905 } 1906 if (iomodel->vy_obs) { 1907 for(i=0;i<6;i++)nodeinputs[i]=iomodel->vy_obs[penta_vertex_ids[i]-1]/iomodel->yts; 1908 this->inputs->AddInput(new PentaVertexInput(VyObsEnum,nodeinputs)); 1909 } 1910 if (iomodel->vz_obs) { 1911 for(i=0;i<6;i++)nodeinputs[i]=iomodel->vz_obs[penta_vertex_ids[i]-1]/iomodel->yts; 1912 this->inputs->AddInput(new PentaVertexInput(VzObsEnum,nodeinputs)); 1913 } 1914 if (iomodel->weights) { 1915 for(i=0;i<6;i++)nodeinputs[i]=iomodel->weights[penta_vertex_ids[i]-1]; 1916 this->inputs->AddInput(new PentaVertexInput(WeightsEnum,nodeinputs)); 1917 } 1918 if (iomodel->elementoniceshelf) this->inputs->AddInput(new BoolInput(ElementOnIceShelfEnum,(IssmBool)iomodel->elementoniceshelf[index])); 1919 if (iomodel->elementonbed) this->inputs->AddInput(new BoolInput(ElementOnBedEnum,(IssmBool)iomodel->elementonbed[index])); 1920 if (iomodel->elementonwater) this->inputs->AddInput(new BoolInput(ElementOnWaterEnum,(IssmBool)iomodel->elementonwater[index])); 1921 if (iomodel->elementonsurface) this->inputs->AddInput(new BoolInput(ElementOnSurfaceEnum,(IssmBool)iomodel->elementonsurface[index])); 1922 1890 1923 /*Control Inputs*/ 1891 if (iomodel->control_analysis){ 1892 switch(iomodel->control_type){ 1893 case DhDtEnum: 1894 if (iomodel->dhdt){ 1895 for(i=0;i<6;i++)nodeinputs[i]=iomodel->dhdt[penta_vertex_ids[i]-1]/iomodel->yts; 1896 this->inputs->AddInput(new ControlInput(DhDtEnum,PentaVertexInputEnum,nodeinputs)); 1897 } 1898 break; 1899 case VxEnum: 1900 if (iomodel->vx){ 1901 for(i=0;i<6;i++)nodeinputs[i]=iomodel->vx[penta_vertex_ids[i]-1]/iomodel->yts; 1902 this->inputs->AddInput(new ControlInput(VxEnum,PentaVertexInputEnum,nodeinputs)); 1903 } 1904 break; 1905 case VyEnum: 1906 if (iomodel->vy){ 1907 for(i=0;i<6;i++)nodeinputs[i]=iomodel->vy[penta_vertex_ids[i]-1]/iomodel->yts; 1908 this->inputs->AddInput(new ControlInput(VyEnum,PentaVertexInputEnum,nodeinputs)); 1909 } 1910 break; 1911 case DragCoefficientEnum: 1912 if (iomodel->drag_coefficient){ 1913 for(i=0;i<6;i++)nodeinputs[i]=iomodel->drag_coefficient[penta_vertex_ids[i]-1]; 1914 this->inputs->AddInput(new ControlInput(DragCoefficientEnum,PentaVertexInputEnum,nodeinputs)); 1915 } 1916 break; 1917 case RheologyBbarEnum: 1918 /*Matice will take care of it*/ break; 1919 default: 1920 ISSMERROR("Control %s not implemented yet",EnumToString(iomodel->control_type)); 1924 if (iomodel->control_analysis && iomodel->control_type){ 1925 for(i=0;i<iomodel->num_control_type;i++){ 1926 switch((int)iomodel->control_type[i]){ 1927 case DhDtEnum: 1928 if (iomodel->dhdt){ 1929 for(j=0;j<6;j++)nodeinputs[j]=iomodel->dhdt[penta_vertex_ids[j]-1]/iomodel->yts; 1930 this->inputs->AddInput(new ControlInput(DhDtEnum,PentaVertexInputEnum,nodeinputs)); 1931 } 1932 break; 1933 case VxEnum: 1934 if (iomodel->vx){ 1935 for(j=0;j<6;j++)nodeinputs[j]=iomodel->vx[penta_vertex_ids[j]-1]/iomodel->yts; 1936 this->inputs->AddInput(new ControlInput(VxEnum,PentaVertexInputEnum,nodeinputs)); 1937 } 1938 break; 1939 case VyEnum: 1940 if (iomodel->vy){ 1941 for(j=0;j<6;j++)nodeinputs[j]=iomodel->vy[penta_vertex_ids[j]-1]/iomodel->yts; 1942 this->inputs->AddInput(new ControlInput(VyEnum,PentaVertexInputEnum,nodeinputs)); 1943 } 1944 break; 1945 case DragCoefficientEnum: 1946 if (iomodel->drag_coefficient){ 1947 for(j=0;j<6;j++)nodeinputs[j]=iomodel->drag_coefficient[penta_vertex_ids[j]-1]; 1948 this->inputs->AddInput(new ControlInput(DragCoefficientEnum,PentaVertexInputEnum,nodeinputs)); 1949 } 1950 break; 1951 case RheologyBbarEnum: 1952 /*Matice will take care of it*/ break; 1953 default: 1954 ISSMERROR("Control %s not implemented yet",EnumToString((int)iomodel->control_type[i])); 1955 } 1921 1956 } 1922 1957 } -
issm/trunk/src/c/objects/Elements/Penta.h
r6212 r6213 119 119 double SurfaceArea(void); 120 120 void Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type); 121 void Update(int index, IoModel* iomodel); 121 122 void UpdateGeometry(void); 122 123 double TimeAdapt(); -
issm/trunk/src/c/objects/Elements/Tria.cpp
r6212 r6213 641 641 } 642 642 if (!input) ISSMERROR("Input %s not found",EnumToString(enum_type)); 643 if (input->Enum()!=ControlInputEnum) ISSMERROR("Input %s is not a ControlInput",EnumToString(enum_type)); 643 644 644 645 this->GetDofList1(&doflist1[0]); … … 661 662 } 662 663 if (!input) ISSMERROR("Input %s not found",EnumToString(enum_type)); 664 if (input->Enum()!=ControlInputEnum) ISSMERROR("Input %s is not a ControlInput",EnumToString(enum_type)); 663 665 664 666 this->GetDofList1(&doflist1[0]); … … 677 679 /* Intermediaries */ 678 680 int i,j,ig; 679 int control_type; 681 int num_controls; 682 int *control_type=NULL; 680 683 double Jelem = 0; 681 684 double cm_noisedmp; … … 686 689 687 690 /*retrieve parameters and inputs*/ 688 this->parameters->FindParam(&control_type,ControlTypeEnum); 691 this->parameters->FindParam(&num_controls,NumControlsEnum); 692 this->parameters->FindParam(&control_type,NULL,ControlTypeEnum); 689 693 this->parameters->FindParam(&cm_noisedmp,CmNoiseDmpEnum); 690 694 … … 694 698 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 695 699 696 /* Start looping on the number of gaussian points: */ 697 gauss=new GaussTria(2); 698 for (ig=gauss->begin();ig<gauss->end();ig++){ 699 700 gauss->GaussPoint(ig); 701 702 GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss); 703 704 /*Add Tikhonov regularization term to misfit: 705 * 706 * WARNING: for now, the regularization is only taken into account by the gradient 707 * the misfit reflects the response only! 708 * 709 * */ 710 if (control_type==DragCoefficientEnum){ 711 Input* drag_input=inputs->GetInput(DragCoefficientEnum); ISSMASSERT(drag_input); 712 drag_input->GetParameterDerivativeValue(&dk[0],&xyz_list[0][0],gauss); 713 //Jelem+=cm_noisedmp*1/2*(pow(dk[0],2)+pow(dk[1],2))*Jdet*gauss->weight; 700 for(i=0;i<num_controls;i++){ 701 /* Start looping on the number of gaussian points: */ 702 gauss=new GaussTria(2); 703 for (ig=gauss->begin();ig<gauss->end();ig++){ 704 705 gauss->GaussPoint(ig); 706 707 GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss); 708 709 /*Add Tikhonov regularization term to misfit: 710 * 711 * WARNING: for now, the regularization is only taken into account by the gradient 712 * the misfit reflects the response only! 713 * 714 * */ 715 if (control_type[i]==DragCoefficientEnum){ 716 Input* drag_input=inputs->GetInput(DragCoefficientEnum); ISSMASSERT(drag_input); 717 drag_input->GetParameterDerivativeValue(&dk[0],&xyz_list[0][0],gauss); 718 //Jelem+=cm_noisedmp*1/2*(pow(dk[0],2)+pow(dk[1],2))*Jdet*gauss->weight; 719 } 720 else if (control_type[i]==RheologyBbarEnum){ 721 //nothing 722 } 723 else if (control_type[i]==DhDtEnum){ 724 //nothing 725 } 726 else if (control_type[i]==VxEnum){ 727 //nothing 728 } 729 else if (control_type[i]==VyEnum){ 730 //nothing 731 } 732 else{ 733 ISSMERROR("unsupported control type: %s",EnumToString(control_type[i])); 734 } 714 735 } 715 else if (control_type==RheologyBbarEnum){ 716 //nothing 717 } 718 else if (control_type==DhDtEnum){ 719 //nothing 720 } 721 else if (control_type==VxEnum){ 722 //nothing 723 } 724 else if (control_type==VyEnum){ 725 //nothing 726 } 727 else{ 728 ISSMERROR("unsupported control type: %s",EnumToString(control_type)); 729 } 730 } 731 732 /*clean-up and return: */ 733 delete gauss; 736 737 delete gauss; 738 } 739 740 /*Clean up and return*/ 741 xfree((void**)&control_type); 734 742 return Jelem; 735 743 } … … 1187 1195 1188 1196 /*Intermediary*/ 1189 int control_type; 1197 int num_controls; 1198 int* control_type=NULL; 1190 1199 Input* input=NULL; 1191 1200 double cm_min,cm_max; … … 1194 1203 this->parameters->FindParam(&cm_min,CmMinEnum); 1195 1204 this->parameters->FindParam(&cm_max,CmMaxEnum); 1196 this->parameters->FindParam(&control_type,ControlTypeEnum); 1197 1198 if(control_type==RheologyBbarEnum){ 1199 input=(Input*)matice->inputs->GetInput(control_type); ISSMASSERT(input); 1200 } 1201 else{ 1202 input=(Input*)this->inputs->GetInput(control_type); ISSMASSERT(input); 1203 } 1204 1205 if (input->Enum()!=ControlInputEnum){ 1206 ISSMERROR("input %s is not a ControlInput",EnumToString(control_type)); 1207 } 1208 1209 ((ControlInput*)input)->UpdateValue(scalar); 1210 input->Constrain(cm_min,cm_max); 1211 if (save_parameter) ((ControlInput*)input)->SaveValue(); 1205 this->parameters->FindParam(&num_controls,NumControlsEnum); 1206 this->parameters->FindParam(&control_type,NULL,ControlTypeEnum); 1207 1208 for(int i=0;i<num_controls;i++){ 1209 1210 if(control_type[i]==RheologyBbarEnum){ 1211 input=(Input*)matice->inputs->GetInput(control_type[i]); ISSMASSERT(input); 1212 } 1213 else{ 1214 input=(Input*)this->inputs->GetInput(control_type[i]); ISSMASSERT(input); 1215 } 1216 1217 if (input->Enum()!=ControlInputEnum){ 1218 ISSMERROR("input %s is not a ControlInput",EnumToString(control_type[i])); 1219 } 1220 1221 ((ControlInput*)input)->UpdateValue(scalar); 1222 input->Constrain(cm_min,cm_max); 1223 if (save_parameter) ((ControlInput*)input)->SaveValue(); 1224 1225 } 1226 1227 /*Clean up and return*/ 1228 xfree((void**)&control_type); 1212 1229 } 1213 1230 /*}}}*/ … … 2117 2134 } 2118 2135 /*}}}*/ 2119 /*FUNCTION Tria::Update {{{1*/2136 /*FUNCTION Tria::Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type){{{1*/ 2120 2137 void Tria::Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type){ //i is the element index 2121 2138 2122 2139 /*Intermediaries*/ 2123 int i ;2140 int i,j; 2124 2141 int tria_node_ids[3]; 2125 2142 int tria_vertex_ids[3]; … … 2164 2181 /*hooks: */ 2165 2182 this->SetHookNodes(tria_node_ids,analysis_counter); this->nodes=NULL; //set hook to nodes, for this analysis type 2166 2167 /*add as many inputs per element as requested:*/ 2168 if (iomodel->thickness) { 2169 for(i=0;i<3;i++)nodeinputs[i]=iomodel->thickness[tria_vertex_ids[i]-1]; 2170 this->inputs->AddInput(new TriaVertexInput(ThicknessEnum,nodeinputs)); 2171 } 2172 if (iomodel->surface) { 2173 for(i=0;i<3;i++)nodeinputs[i]=iomodel->surface[tria_vertex_ids[i]-1]; 2174 this->inputs->AddInput(new TriaVertexInput(SurfaceEnum,nodeinputs)); 2175 } 2176 if (iomodel->bed) { 2177 for(i=0;i<3;i++)nodeinputs[i]=iomodel->bed[tria_vertex_ids[i]-1]; 2178 this->inputs->AddInput(new TriaVertexInput(BedEnum,nodeinputs)); 2179 } 2180 if (iomodel->drag_coefficient) { 2181 for(i=0;i<3;i++)nodeinputs[i]=iomodel->drag_coefficient[tria_vertex_ids[i]-1]; 2182 this->inputs->AddInput(new TriaVertexInput(DragCoefficientEnum,nodeinputs)); 2183 2184 if (iomodel->drag_p) this->inputs->AddInput(new DoubleInput(DragPEnum,iomodel->drag_p[index])); 2185 if (iomodel->drag_q) this->inputs->AddInput(new DoubleInput(DragQEnum,iomodel->drag_q[index])); 2186 this->inputs->AddInput(new IntInput(DragTypeEnum,iomodel->drag_type)); 2187 } 2188 if (iomodel->thickness_obs) { 2189 for(i=0;i<3;i++)nodeinputs[i]=iomodel->thickness_obs[tria_vertex_ids[i]-1]; 2190 this->inputs->AddInput(new TriaVertexInput(ThicknessObsEnum,nodeinputs)); 2191 } 2192 if (iomodel->melting_rate) { 2193 for(i=0;i<3;i++)nodeinputs[i]=iomodel->melting_rate[tria_vertex_ids[i]-1]/iomodel->yts; 2194 this->inputs->AddInput(new TriaVertexInput(MeltingRateEnum,nodeinputs)); 2195 } 2196 if (iomodel->accumulation_rate) { 2197 for(i=0;i<3;i++)nodeinputs[i]=iomodel->accumulation_rate[tria_vertex_ids[i]-1]/iomodel->yts; 2198 this->inputs->AddInput(new TriaVertexInput(AccumulationRateEnum,nodeinputs)); 2199 } 2200 if (iomodel->geothermalflux) { 2201 for(i=0;i<3;i++)nodeinputs[i]=iomodel->geothermalflux[tria_vertex_ids[i]-1]; 2202 this->inputs->AddInput(new TriaVertexInput(GeothermalFluxEnum,nodeinputs)); 2203 } 2204 if (iomodel->dhdt){ 2205 for(i=0;i<3;i++)nodeinputs[i]=iomodel->dhdt[tria_vertex_ids[i]-1]/iomodel->yts; 2206 this->inputs->AddInput(new TriaVertexInput(DhDtEnum,nodeinputs)); 2207 } 2208 if (iomodel->pressure){ 2209 for(i=0;i<3;i++)nodeinputs[i]=iomodel->pressure[tria_vertex_ids[i]-1]; 2210 this->inputs->AddInput(new TriaVertexInput(PressureEnum,nodeinputs)); 2211 } 2212 if (iomodel->temperature) { 2213 for(i=0;i<3;i++)nodeinputs[i]=iomodel->temperature[tria_vertex_ids[i]-1]; 2214 this->inputs->AddInput(new TriaVertexInput(TemperatureEnum,nodeinputs)); 2215 } 2216 /*vx,vy and vz: */ 2217 if (iomodel->vx) { 2218 for(i=0;i<3;i++)nodeinputs[i]=iomodel->vx[tria_vertex_ids[i]-1]/iomodel->yts; 2219 this->inputs->AddInput(new TriaVertexInput(VxEnum,nodeinputs)); 2220 this->inputs->AddInput(new TriaVertexInput(VxOldEnum,nodeinputs)); 2221 if(iomodel->qmu_analysis)this->inputs->AddInput(new TriaVertexInput(QmuVxEnum,nodeinputs)); 2222 } 2223 if (iomodel->vy) { 2224 for(i=0;i<3;i++)nodeinputs[i]=iomodel->vy[tria_vertex_ids[i]-1]/iomodel->yts; 2225 this->inputs->AddInput(new TriaVertexInput(VyEnum,nodeinputs)); 2226 this->inputs->AddInput(new TriaVertexInput(VyOldEnum,nodeinputs)); 2227 if(iomodel->qmu_analysis)this->inputs->AddInput(new TriaVertexInput(QmuVyEnum,nodeinputs)); 2228 } 2229 if (iomodel->vz) { 2230 for(i=0;i<3;i++)nodeinputs[i]=iomodel->vz[tria_vertex_ids[i]-1]/iomodel->yts; 2231 this->inputs->AddInput(new TriaVertexInput(VzEnum,nodeinputs)); 2232 this->inputs->AddInput(new TriaVertexInput(VzOldEnum,nodeinputs)); 2233 if(iomodel->qmu_analysis)this->inputs->AddInput(new TriaVertexInput(QmuVzEnum,nodeinputs)); 2234 } 2235 if (iomodel->vx_obs) { 2236 for(i=0;i<3;i++)nodeinputs[i]=iomodel->vx_obs[tria_vertex_ids[i]-1]/iomodel->yts; 2237 this->inputs->AddInput(new TriaVertexInput(VxObsEnum,nodeinputs)); 2238 } 2239 if (iomodel->vy_obs) { 2240 for(i=0;i<3;i++)nodeinputs[i]=iomodel->vy_obs[tria_vertex_ids[i]-1]/iomodel->yts; 2241 this->inputs->AddInput(new TriaVertexInput(VyObsEnum,nodeinputs)); 2242 } 2243 if (iomodel->vz_obs) { 2244 for(i=0;i<3;i++)nodeinputs[i]=iomodel->vz_obs[tria_vertex_ids[i]-1]/iomodel->yts; 2245 this->inputs->AddInput(new TriaVertexInput(VzObsEnum,nodeinputs)); 2246 } 2247 if (iomodel->weights) { 2248 for(i=0;i<3;i++)nodeinputs[i]=iomodel->weights[tria_vertex_ids[i]-1]; 2249 this->inputs->AddInput(new TriaVertexInput(WeightsEnum,nodeinputs)); 2250 } 2251 if (iomodel->elementoniceshelf) this->inputs->AddInput(new BoolInput(ElementOnIceShelfEnum,(IssmBool)iomodel->elementoniceshelf[index])); 2252 if (iomodel->elementonbed) this->inputs->AddInput(new BoolInput(ElementOnBedEnum,(IssmBool)iomodel->elementonbed[index])); 2253 if (iomodel->elementonwater) this->inputs->AddInput(new BoolInput(ElementOnWaterEnum,(IssmBool)iomodel->elementonwater[index])); 2254 if (iomodel->elementonsurface) this->inputs->AddInput(new BoolInput(ElementOnSurfaceEnum,(IssmBool)iomodel->elementonsurface[index])); 2183 2184 /*Fill with IoModel*/ 2185 this->Update(index,iomodel); 2255 2186 2256 2187 /*Defaults if not provided in iomodel*/ … … 2296 2227 } 2297 2228 2298 /*Control Inputs*/2299 if (iomodel->control_analysis){2300 switch(iomodel->control_type){2301 case DhDtEnum:2302 if (iomodel->dhdt){2303 for(i=0;i<3;i++)nodeinputs[i]=iomodel->dhdt[tria_vertex_ids[i]-1]/iomodel->yts;2304 this->inputs->AddInput(new ControlInput(DhDtEnum,TriaVertexInputEnum,nodeinputs));2305 }2306 break;2307 case VxEnum:2308 if (iomodel->vx){2309 for(i=0;i<3;i++)nodeinputs[i]=iomodel->vx[tria_vertex_ids[i]-1]/iomodel->yts;2310 this->inputs->AddInput(new ControlInput(VxEnum,TriaVertexInputEnum,nodeinputs));2311 }2312 break;2313 case VyEnum:2314 if (iomodel->vy){2315 for(i=0;i<3;i++)nodeinputs[i]=iomodel->vy[tria_vertex_ids[i]-1]/iomodel->yts;2316 this->inputs->AddInput(new ControlInput(VyEnum,TriaVertexInputEnum,nodeinputs));2317 }2318 break;2319 case DragCoefficientEnum:2320 if (iomodel->drag_coefficient){2321 for(i=0;i<3;i++)nodeinputs[i]=iomodel->drag_coefficient[tria_vertex_ids[i]-1];2322 this->inputs->AddInput(new ControlInput(DragCoefficientEnum,TriaVertexInputEnum,nodeinputs));2323 }2324 break;2325 case RheologyBbarEnum:2326 /*Matice will take care of it*/ break;2327 default:2328 ISSMERROR("Control %s not implemented yet",EnumToString(iomodel->control_type));2329 }2330 2331 }2332 2333 2229 //this->parameters: we still can't point to it, it may not even exist. Configure will handle this. 2334 2230 this->parameters=NULL; 2335 2231 } 2232 /*}}}*/ 2233 /*FUNCTION Tria::Update(int index, IoModel* iomodel){{{1*/ 2234 void Tria::Update(int index, IoModel* iomodel){ //i is the element index 2235 2236 /*Intermediaries*/ 2237 int i,j; 2238 int tria_vertex_ids[3]; 2239 double nodeinputs[3]; 2240 2241 /*Checks if debuging*/ 2242 /*{{{2*/ 2243 ISSMASSERT(iomodel->elements); 2244 /*}}}*/ 2245 2246 /*Recover vertices ids needed to initialize inputs*/ 2247 for(i=0;i<3;i++){ 2248 tria_vertex_ids[i]=(int)iomodel->elements[3*index+i]; //ids for vertices are in the elements array from Matlab 2249 } 2250 2251 /*add as many inputs per element as requested:*/ 2252 if (iomodel->thickness) { 2253 for(i=0;i<3;i++)nodeinputs[i]=iomodel->thickness[tria_vertex_ids[i]-1]; 2254 this->inputs->AddInput(new TriaVertexInput(ThicknessEnum,nodeinputs)); 2255 } 2256 if (iomodel->surface) { 2257 for(i=0;i<3;i++)nodeinputs[i]=iomodel->surface[tria_vertex_ids[i]-1]; 2258 this->inputs->AddInput(new TriaVertexInput(SurfaceEnum,nodeinputs)); 2259 } 2260 if (iomodel->bed) { 2261 for(i=0;i<3;i++)nodeinputs[i]=iomodel->bed[tria_vertex_ids[i]-1]; 2262 this->inputs->AddInput(new TriaVertexInput(BedEnum,nodeinputs)); 2263 } 2264 if (iomodel->drag_coefficient) { 2265 for(i=0;i<3;i++)nodeinputs[i]=iomodel->drag_coefficient[tria_vertex_ids[i]-1]; 2266 this->inputs->AddInput(new TriaVertexInput(DragCoefficientEnum,nodeinputs)); 2267 2268 if (iomodel->drag_p) this->inputs->AddInput(new DoubleInput(DragPEnum,iomodel->drag_p[index])); 2269 if (iomodel->drag_q) this->inputs->AddInput(new DoubleInput(DragQEnum,iomodel->drag_q[index])); 2270 this->inputs->AddInput(new IntInput(DragTypeEnum,iomodel->drag_type)); 2271 } 2272 if (iomodel->thickness_obs) { 2273 for(i=0;i<3;i++)nodeinputs[i]=iomodel->thickness_obs[tria_vertex_ids[i]-1]; 2274 this->inputs->AddInput(new TriaVertexInput(ThicknessObsEnum,nodeinputs)); 2275 } 2276 if (iomodel->melting_rate) { 2277 for(i=0;i<3;i++)nodeinputs[i]=iomodel->melting_rate[tria_vertex_ids[i]-1]/iomodel->yts; 2278 this->inputs->AddInput(new TriaVertexInput(MeltingRateEnum,nodeinputs)); 2279 } 2280 if (iomodel->accumulation_rate) { 2281 for(i=0;i<3;i++)nodeinputs[i]=iomodel->accumulation_rate[tria_vertex_ids[i]-1]/iomodel->yts; 2282 this->inputs->AddInput(new TriaVertexInput(AccumulationRateEnum,nodeinputs)); 2283 } 2284 if (iomodel->geothermalflux) { 2285 for(i=0;i<3;i++)nodeinputs[i]=iomodel->geothermalflux[tria_vertex_ids[i]-1]; 2286 this->inputs->AddInput(new TriaVertexInput(GeothermalFluxEnum,nodeinputs)); 2287 } 2288 if (iomodel->dhdt){ 2289 for(i=0;i<3;i++)nodeinputs[i]=iomodel->dhdt[tria_vertex_ids[i]-1]/iomodel->yts; 2290 this->inputs->AddInput(new TriaVertexInput(DhDtEnum,nodeinputs)); 2291 } 2292 if (iomodel->pressure){ 2293 for(i=0;i<3;i++)nodeinputs[i]=iomodel->pressure[tria_vertex_ids[i]-1]; 2294 this->inputs->AddInput(new TriaVertexInput(PressureEnum,nodeinputs)); 2295 } 2296 if (iomodel->temperature) { 2297 for(i=0;i<3;i++)nodeinputs[i]=iomodel->temperature[tria_vertex_ids[i]-1]; 2298 this->inputs->AddInput(new TriaVertexInput(TemperatureEnum,nodeinputs)); 2299 } 2300 /*vx,vy and vz: */ 2301 if (iomodel->vx) { 2302 for(i=0;i<3;i++)nodeinputs[i]=iomodel->vx[tria_vertex_ids[i]-1]/iomodel->yts; 2303 this->inputs->AddInput(new TriaVertexInput(VxEnum,nodeinputs)); 2304 this->inputs->AddInput(new TriaVertexInput(VxOldEnum,nodeinputs)); 2305 if(iomodel->qmu_analysis)this->inputs->AddInput(new TriaVertexInput(QmuVxEnum,nodeinputs)); 2306 } 2307 if (iomodel->vy) { 2308 for(i=0;i<3;i++)nodeinputs[i]=iomodel->vy[tria_vertex_ids[i]-1]/iomodel->yts; 2309 this->inputs->AddInput(new TriaVertexInput(VyEnum,nodeinputs)); 2310 this->inputs->AddInput(new TriaVertexInput(VyOldEnum,nodeinputs)); 2311 if(iomodel->qmu_analysis)this->inputs->AddInput(new TriaVertexInput(QmuVyEnum,nodeinputs)); 2312 } 2313 if (iomodel->vz) { 2314 for(i=0;i<3;i++)nodeinputs[i]=iomodel->vz[tria_vertex_ids[i]-1]/iomodel->yts; 2315 this->inputs->AddInput(new TriaVertexInput(VzEnum,nodeinputs)); 2316 this->inputs->AddInput(new TriaVertexInput(VzOldEnum,nodeinputs)); 2317 if(iomodel->qmu_analysis)this->inputs->AddInput(new TriaVertexInput(QmuVzEnum,nodeinputs)); 2318 } 2319 if (iomodel->vx_obs) { 2320 for(i=0;i<3;i++)nodeinputs[i]=iomodel->vx_obs[tria_vertex_ids[i]-1]/iomodel->yts; 2321 this->inputs->AddInput(new TriaVertexInput(VxObsEnum,nodeinputs)); 2322 } 2323 if (iomodel->vy_obs) { 2324 for(i=0;i<3;i++)nodeinputs[i]=iomodel->vy_obs[tria_vertex_ids[i]-1]/iomodel->yts; 2325 this->inputs->AddInput(new TriaVertexInput(VyObsEnum,nodeinputs)); 2326 } 2327 if (iomodel->vz_obs) { 2328 for(i=0;i<3;i++)nodeinputs[i]=iomodel->vz_obs[tria_vertex_ids[i]-1]/iomodel->yts; 2329 this->inputs->AddInput(new TriaVertexInput(VzObsEnum,nodeinputs)); 2330 } 2331 if (iomodel->weights) { 2332 for(i=0;i<3;i++)nodeinputs[i]=iomodel->weights[tria_vertex_ids[i]-1]; 2333 this->inputs->AddInput(new TriaVertexInput(WeightsEnum,nodeinputs)); 2334 } 2335 if (iomodel->elementoniceshelf) this->inputs->AddInput(new BoolInput(ElementOnIceShelfEnum,(IssmBool)iomodel->elementoniceshelf[index])); 2336 if (iomodel->elementonbed) this->inputs->AddInput(new BoolInput(ElementOnBedEnum,(IssmBool)iomodel->elementonbed[index])); 2337 if (iomodel->elementonwater) this->inputs->AddInput(new BoolInput(ElementOnWaterEnum,(IssmBool)iomodel->elementonwater[index])); 2338 if (iomodel->elementonsurface) this->inputs->AddInput(new BoolInput(ElementOnSurfaceEnum,(IssmBool)iomodel->elementonsurface[index])); 2339 2340 /*Control Inputs*/ 2341 if (iomodel->control_analysis && iomodel->control_type){ 2342 for(i=0;i<iomodel->num_control_type;i++){ 2343 switch((int)iomodel->control_type[i]){ 2344 case DhDtEnum: 2345 if (iomodel->dhdt){ 2346 for(j=0;j<3;j++)nodeinputs[j]=iomodel->dhdt[tria_vertex_ids[j]-1]/iomodel->yts; 2347 this->inputs->AddInput(new ControlInput(DhDtEnum,TriaVertexInputEnum,nodeinputs)); 2348 } 2349 break; 2350 case VxEnum: 2351 if (iomodel->vx){ 2352 for(j=0;j<3;j++)nodeinputs[j]=iomodel->vx[tria_vertex_ids[j]-1]/iomodel->yts; 2353 this->inputs->AddInput(new ControlInput(VxEnum,TriaVertexInputEnum,nodeinputs)); 2354 } 2355 break; 2356 case VyEnum: 2357 if (iomodel->vy){ 2358 for(j=0;j<3;j++)nodeinputs[j]=iomodel->vy[tria_vertex_ids[j]-1]/iomodel->yts; 2359 this->inputs->AddInput(new ControlInput(VyEnum,TriaVertexInputEnum,nodeinputs)); 2360 } 2361 break; 2362 case DragCoefficientEnum: 2363 if (iomodel->drag_coefficient){ 2364 for(j=0;j<3;j++)nodeinputs[j]=iomodel->drag_coefficient[tria_vertex_ids[j]-1]; 2365 this->inputs->AddInput(new ControlInput(DragCoefficientEnum,TriaVertexInputEnum,nodeinputs)); 2366 } 2367 break; 2368 case RheologyBbarEnum: 2369 /*Matice will take care of it*/ break; 2370 default: 2371 ISSMERROR("Control %s not implemented yet",EnumToString((int)iomodel->control_type[i])); 2372 } 2373 } 2374 } 2336 2375 } 2337 2376 /*}}}*/ -
issm/trunk/src/c/objects/Elements/Tria.h
r6200 r6213 122 122 double SurfaceArea(void); 123 123 void Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type); 124 void Update(int index, IoModel* iomodel); 124 125 void UpdateGeometry(void); 125 126 double TimeAdapt(); -
issm/trunk/src/c/objects/IoModel.cpp
r6201 r6213 84 84 xfree((void**)&this->rheology_B); 85 85 xfree((void**)&this->rheology_n); 86 xfree((void**)&this->control_type); 86 87 xfree((void**)&this->cm_responses); 87 88 xfree((void**)&this->weights); … … 152 153 /*Get control parameters: */ 153 154 IoModelFetchData(&this->num_control_type,iomodel_handle,"num_control_type"); 154 IoModelFetchData(&this->control_type,iomodel_handle,"control_type");155 155 156 156 /*!Get solution parameters: */ … … 295 295 296 296 /*!solution parameters: */ 297 this->control_type=NULL; 297 298 this->cm_responses=NULL; 298 299 this->weights=NULL; -
issm/trunk/src/c/objects/IoModel.h
r6201 r6213 122 122 /*control methods: */ 123 123 int num_control_type; 124 intcontrol_type;124 double* control_type; 125 125 126 126 /*solution parameters: */ -
issm/trunk/src/c/objects/Materials/Material.h
r5320 r6213 22 22 virtual void InputDuplicate(int original_enum,int new_enum)=0; 23 23 virtual void Configure(Elements* elements)=0; 24 virtual void Update(int index, IoModel* iomodel)=0; 24 25 25 26 }; -
issm/trunk/src/c/objects/Materials/Matice.cpp
r6200 r6213 57 57 58 58 /*Control Inputs*/ 59 if (iomodel->control_analysis ){60 switch(iomodel->control_type){61 case RheologyBbarEnum:62 if (iomodel->rheology_B){63 for(i=0;i<num_vertices;i++)nodeinputs[i]=iomodel->rheology_B[int(iomodel->elements[num_vertices*index+i]-1)];64 this->inputs->AddInput(new ControlInput(RheologyBbarEnum,TriaVertexInputEnum,nodeinputs));65 }66 break;67 default:68 /*Nothing*/;59 if (iomodel->control_analysis && iomodel->control_type){ 60 for(i=0;i<iomodel->num_control_type;i++){ 61 switch((int)iomodel->control_type[i]){ 62 case RheologyBbarEnum: 63 if (iomodel->rheology_B){ 64 for(i=0;i<num_vertices;i++)nodeinputs[i]=iomodel->rheology_B[int(iomodel->elements[num_vertices*index+i]-1)]; 65 this->inputs->AddInput(new ControlInput(RheologyBbarEnum,TriaVertexInputEnum,nodeinputs)); 66 } 67 break; 68 } 69 69 } 70 70 } … … 91 91 92 92 /*Control Inputs*/ 93 if (iomodel->control_analysis){ 94 switch(iomodel->control_type){ 95 case RheologyBbarEnum: 96 if (iomodel->rheology_B){ 97 for(i=0;i<num_vertices;i++)nodeinputs[i]=iomodel->rheology_B[int(iomodel->elements[num_vertices*index+i]-1)]; 98 this->inputs->AddInput(new ControlInput(RheologyBEnum,PentaVertexInputEnum,nodeinputs)); 99 } 100 break; 93 if (iomodel->control_analysis && iomodel->control_type){ 94 for(i=0;i<iomodel->num_control_type;i++){ 95 switch((int)iomodel->control_type[i]){ 96 case RheologyBbarEnum: 97 if (iomodel->rheology_B){ 98 for(i=0;i<num_vertices;i++)nodeinputs[i]=iomodel->rheology_B[int(iomodel->elements[num_vertices*index+i]-1)]; 99 this->inputs->AddInput(new ControlInput(RheologyBEnum,PentaVertexInputEnum,nodeinputs)); 100 } 101 break; 102 } 101 103 } 102 104 } … … 246 248 247 249 return matice; 250 } 251 /*}}}*/ 252 /*FUNCTION Matice::Update{{{1*/ 253 void Matice::Update(int index, IoModel* iomodel){ 254 255 int i,j; 256 257 /*if 2d*/ 258 if(iomodel->dim==2){ 259 260 /*Intermediaries*/ 261 const int num_vertices = 3; //Tria has 3 vertices 262 double nodeinputs[num_vertices]; 263 264 /*Control Inputs*/ 265 if (iomodel->control_analysis && iomodel->control_type){ 266 for(i=0;i<iomodel->num_control_type;i++){ 267 switch((int)iomodel->control_type[i]){ 268 case RheologyBbarEnum: 269 if (iomodel->rheology_B){ 270 for(j=0;j<num_vertices;j++)nodeinputs[j]=iomodel->rheology_B[int(iomodel->elements[num_vertices*index+j]-1)]; 271 this->inputs->AddInput(new ControlInput(RheologyBbarEnum,TriaVertexInputEnum,nodeinputs)); 272 } 273 break; 274 } 275 } 276 } 277 } 278 279 /*if 3d*/ 280 else if(iomodel->dim==3){ 281 282 /*Intermediaries*/ 283 const int num_vertices = 6; //Penta has 6 vertices 284 double nodeinputs[num_vertices]; 285 286 /*Control Inputs*/ 287 if (iomodel->control_analysis && iomodel->control_type){ 288 for(i=0;i<iomodel->num_control_type;i++){ 289 switch((int)iomodel->control_type[i]){ 290 case RheologyBbarEnum: 291 if (iomodel->rheology_B){ 292 for(j=0;j<num_vertices;j++)nodeinputs[j]=iomodel->rheology_B[int(iomodel->elements[num_vertices*index+j]-1)]; 293 this->inputs->AddInput(new ControlInput(RheologyBEnum,PentaVertexInputEnum,nodeinputs)); 294 } 295 break; 296 } 297 } 298 } 299 } 300 else{ 301 ISSMERROR(" Mesh type not supported yet!"); 302 } 303 304 return; 248 305 } 249 306 /*}}}*/ -
issm/trunk/src/c/objects/Materials/Matice.h
r5358 r6213 52 52 void InputUpdateFromConstant(bool constant, int name); 53 53 void InputUpdateFromSolution(double* solution); 54 void Update(int index, IoModel* iomodel); 54 55 /*}}}*/ 55 56 /*Material virtual functions resolution: {{{1*/ -
issm/trunk/src/c/objects/Materials/Matpar.h
r5320 r6213 56 56 void InputUpdateFromConstant(bool constant, int name); 57 57 void InputUpdateFromSolution(double* solution); 58 void Update(int index, IoModel* iomodel){ISSMERROR("not implemented yet");}; 58 59 /*}}}*/ 59 60 /*Material virtual functions resolution: {{{1*/ -
issm/trunk/src/c/objects/Params/DoubleParam.cpp
r5103 r6213 129 129 } 130 130 /*}}}*/ 131 /*FUNCTION DoubleParam::GetParameterValue {{{1*/131 /*FUNCTION DoubleParam::GetParameterValue(int* pinteger){{{1*/ 132 132 void DoubleParam::GetParameterValue(int* pinteger){ 133 133 #ifdef _SERIAL_ … … 138 138 } 139 139 /*}}}*/ 140 /*FUNCTION DoubleParam::GetParameterValue {{{1*/140 /*FUNCTION DoubleParam::GetParameterValue(bool* pbool){{{1*/ 141 141 void DoubleParam::GetParameterValue(bool* pbool){ 142 142 #ifdef _SERIAL_ … … 148 148 #else 149 149 ISSMERROR("Double param of enum %i (%s) cannot return an bool",enum_type,EnumToString(enum_type)); 150 #endif 151 } 152 /*}}}*/ 153 /*FUNCTION DoubleParam::GetParameterValue(int** pintarray,int* pM){{{1*/ 154 void DoubleParam::GetParameterValue(int** pintarray,int* pM){ 155 #ifdef _SERIAL_ 156 int* output=NULL; 157 158 output=(int*)xmalloc(1*sizeof(int)); 159 *output=(int)value; 160 161 /*Assign output pointers:*/ 162 if(pM) *pM=1; 163 *pintarray=output; 164 #else 165 ISSMERROR("Double param of enum %i (%s) cannot return an array of integers",enum_type,EnumToString(enum_type)); 150 166 #endif 151 167 } -
issm/trunk/src/c/objects/Params/DoubleParam.h
r6165 r6213 52 52 void GetParameterValue(bool* pbool); 53 53 void GetParameterValue(int* pinteger); 54 void GetParameterValue(int** pintarray,int* pM) {ISSMERROR("Double param of enum %i (%s) cannot return an array of integers",enum_type,EnumToString(enum_type));}54 void GetParameterValue(int** pintarray,int* pM); 55 55 void GetParameterValue(double* pdouble){*pdouble=value;} 56 56 void GetParameterValue(char** pstring){ISSMERROR("Double param of enum %i (%s) cannot return a string",enum_type,EnumToString(enum_type));} -
issm/trunk/src/c/objects/Params/IntVecParam.cpp
r6165 r6213 36 36 } 37 37 /*}}}*/ 38 /*FUNCTION IntVecParam::IntVecParam(int enum_type,double* values,int M){{{1*/ 39 IntVecParam::IntVecParam(int in_enum_type,double* in_values, int in_M){ 40 41 enum_type=in_enum_type; 42 M=in_M; 43 44 values=(int*)xmalloc(M*sizeof(int)); 45 for(int i=0;i<in_M;i++) values[i]=(int)in_values[i]; 46 } 47 /*}}}*/ 38 48 /*FUNCTION IntVecParam::~IntVecParam(){{{1*/ 39 49 IntVecParam::~IntVecParam(){ … … 101 111 int IntVecParam::MarshallSize(){ 102 112 103 return sizeof(M) 113 return sizeof(M)+ 104 114 +M*sizeof(int) 105 115 +sizeof(enum_type)+ -
issm/trunk/src/c/objects/Params/IntVecParam.h
r6169 r6213 35 35 IntVecParam(); 36 36 IntVecParam(int enum_type,int* values,int M); 37 IntVecParam(int enum_type,double* values,int M); 37 38 ~IntVecParam(); 38 39 /*}}}*/ … … 69 70 void SetValue(char* string){ISSMERROR("IntVec param of enum %i (%s) cannot hold a string",enum_type,EnumToString(enum_type));} 70 71 void SetValue(char** stringarray,int M){ISSMERROR("IntVec param of enum %i (%s) cannot hold a string array",enum_type,EnumToString(enum_type));} 71 void SetValue(double* doublearray,int M) ;72 void SetValue(double* doublearray,int M){ISSMERROR("IntVec param of enum %i (%s) cannot hold a double mat array",enum_type,EnumToString(enum_type));} 72 73 void SetValue(double* pdoublearray,int M,int N){ISSMERROR("IntVec param of enum %i (%s) cannot hold a double mat array",enum_type,EnumToString(enum_type));} 73 74 void SetValue(Vec vec){ISSMERROR("IntVec param of enum %i (%s) cannot hold a Vec",enum_type,EnumToString(enum_type));} -
issm/trunk/src/c/solutions/control_core.cpp
r6200 r6213 18 18 /*parameters: */ 19 19 int verbose=0; 20 int control_type;20 int num_controls; 21 21 int nsteps; 22 22 double eps_cm; … … 28 28 bool qmu_analysis=false; 29 29 30 int* control_type = NULL; 30 31 double* responses=NULL; 31 32 double* optscal=NULL; … … 48 49 /*Recover parameters used throughout the solution:{{{1*/ 49 50 femmodel->parameters->FindParam(&nsteps,NStepsEnum); 50 femmodel->parameters->FindParam(&control_type,ControlTypeEnum); 51 femmodel->parameters->FindParam(&num_controls,NumControlsEnum); 52 femmodel->parameters->FindParam(&control_type,NULL,ControlTypeEnum); 51 53 femmodel->parameters->FindParam(&responses,NULL,CmResponsesEnum); 52 54 femmodel->parameters->FindParam(&optscal,NULL,OptScalEnum); … … 122 124 /*some results not computed by steadystate_core or diagnostic_core: */ 123 125 if(!qmu_analysis){ //do not save this if we are running the control core from a qmu run! 124 InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,control_type); //the parameter itself!126 for(i=0;i<num_controls;i++) InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,control_type[i]); 125 127 femmodel->results->AddObject(new DoubleVecExternalResult(femmodel->results->Size()+1,JEnum,J,nsteps,1,0)); 126 femmodel->results->AddObject(new StringExternalResult(femmodel->results->Size()+1,ControlTypeEnum,EnumToString(control_type),1,0));128 //femmodel->results->AddObject(new StringExternalResult(femmodel->results->Size()+1,ControlTypeEnum,EnumToString(control_type),1,0)); 127 129 } 128 130 129 131 cleanup_and_return: 130 132 /*Free ressources: */ 133 xfree((void**)&control_type); 131 134 xfree((void**)&responses); 132 135 xfree((void**)&optscal); -
issm/trunk/src/c/solutions/controlrestart.cpp
r5530 r6213 9 9 void controlrestart(FemModel* femmodel,double* J){ 10 10 11 int control_type; 11 int num_controls; 12 int* control_type = NULL; 12 13 int nsteps; 13 14 bool qmu_analysis=true; 14 15 15 16 /*retrieve output file name: */ 16 femmodel->parameters->FindParam(&control_type,ControlTypeEnum); 17 femmodel->parameters->FindParam(&num_controls,NumControlsEnum); 18 femmodel->parameters->FindParam(&control_type,NULL,ControlTypeEnum); 17 19 femmodel->parameters->FindParam(&nsteps,NStepsEnum); 18 20 femmodel->parameters->FindParam(&qmu_analysis,QmuAnalysisEnum); … … 22 24 if(!qmu_analysis){ 23 25 /*we essentially want J and the parameter: */ 24 InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,control_type); //the parameter itself!26 for(int i=0;i<num_controls;i++) InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,control_type[i]); 25 27 femmodel->results->AddObject(new DoubleVecExternalResult(femmodel->results->Size()+1,JEnum,J,nsteps,1,0)); 26 femmodel->results->AddObject(new StringExternalResult(femmodel->results->Size()+1,ControlTypeEnum,EnumToString(control_type),1,0));28 //femmodel->results->AddObject(new StringExternalResult(femmodel->results->Size()+1,ControlTypeEnum,EnumToString(control_type),1,0)); 27 29 28 30 /*write to disk: */ … … 30 32 } 31 33 34 /*Clean up and return*/ 35 xfree((void**)&control_type); 32 36 } -
issm/trunk/src/c/solutions/gradient_core.cpp
r6200 r6213 17 17 /*parameters: */ 18 18 bool control_steady; 19 int control_type; 19 int num_controls; 20 int* control_type=NULL; 20 21 int verbose; 21 22 … … 27 28 /*retrieve parameters:*/ 28 29 femmodel->parameters->FindParam(&control_steady,ControlSteadyEnum); 29 femmodel->parameters->FindParam(&control_type,ControlTypeEnum); 30 femmodel->parameters->FindParam(&num_controls,NumControlsEnum); 31 femmodel->parameters->FindParam(&control_type,NULL,ControlTypeEnum); 30 32 femmodel->parameters->FindParam(&verbose,VerboseEnum); 31 33 32 if(verbose)_printf_("%s\n"," compute gradient:"); 33 Gradjx(&gradient, femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters, control_type); 34 for (int i=0;i<num_controls;i++){ 34 35 35 if(control_steady)diagnostic_core(femmodel); 36 37 if (step>0 && search_scalar==0){ 38 _printf_("%s"," orthogonalization...\n"); 39 if(verbose)_printf_("%s\n"," retrieve old gradient:"); 40 ControlInputGetGradientx(&old_gradient,femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters,control_type); 41 Orthx(&new_gradient,gradient,old_gradient); 42 VecFree(&old_gradient); 36 if(verbose)_printf_(" compute gradient of J with respect to %s\n",EnumToString(control_type[i])); 37 Gradjx(&gradient, femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters, control_type[i]); 38 39 if(control_steady)diagnostic_core(femmodel); 40 41 if (step>0 && search_scalar==0){ 42 _printf_("%s"," orthogonalization...\n"); 43 ControlInputGetGradientx(&old_gradient,femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters,control_type[i]); 44 Orthx(&new_gradient,gradient,old_gradient); 45 VecFree(&old_gradient); 46 } 47 else{ 48 _printf_("%s"," normalizing directions...\n"); 49 Orthx(&new_gradient,gradient,NULL); 50 } 51 VecFree(&gradient); 52 53 /*plug back into inputs: */ 54 ControlInputSetGradientx(femmodel-> elements,femmodel-> nodes, femmodel-> vertices,femmodel-> loads, femmodel-> materials, femmodel->parameters,control_type[i],new_gradient); 55 56 /*Free ressources and return:*/ 57 VecFree(&new_gradient); 43 58 } 44 else{45 _printf_("%s"," normalizing directions...\n");46 Orthx(&new_gradient,gradient,NULL);47 }48 VecFree(&gradient);49 59 50 /*plug back into inputs: */ 51 ControlInputSetGradientx(femmodel-> elements,femmodel-> nodes, femmodel-> vertices,femmodel-> loads, femmodel-> materials, femmodel->parameters,control_type,new_gradient); 52 53 /*Free ressources and return:*/ 54 VecFree(&new_gradient); 60 /*Clean up and return*/ 61 xfree((void**)&control_type); 55 62 } -
issm/trunk/src/c/solutions/objectivefunctionC.cpp
r6200 r6213 31 31 int n; 32 32 double *optscal = NULL; 33 double *responses =NULL; 34 int control_type; 33 double *responses = NULL; 35 34 int solution_type; 36 35 int analysis_type; … … 47 46 femmodel->parameters->FindParam(&responses,NULL,CmResponsesEnum); 48 47 femmodel->parameters->FindParam(&isstokes,IsStokesEnum); 49 femmodel->parameters->FindParam(&control_type,ControlTypeEnum);50 48 femmodel->parameters->FindParam(&analysis_type,AnalysisTypeEnum); 51 49 femmodel->parameters->FindParam(&solution_type,SolutionTypeEnum);
Note:
See TracChangeset
for help on using the changeset viewer.