Changeset 4055
- Timestamp:
- 06/18/10 19:24:59 (15 years ago)
- Location:
- issm/trunk/src/c
- Files:
-
- 13 added
- 5 deleted
- 85 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/DataSet/DataSet.cpp
r4053 r4055 684 684 xfree((void**)&truedofs); 685 685 xfree((void**)&alltruedofs); 686 687 }688 /*}}}*/689 /*FUNCTION DataSet::FieldExtrude{{{1*/690 void DataSet::FieldExtrude(Vec field,double* field_serial,char* field_name, int collapse){691 692 vector<Object*>::iterator object;693 Penta* penta=NULL;694 Node* node=NULL;695 696 for ( object=objects.begin() ; object < objects.end(); object++ ){697 698 if((*object)->Enum()==PentaEnum){699 700 penta=(Penta*)(*object);701 penta->FieldExtrude(field,field_serial,field_name,collapse);702 703 }704 if((*object)->Enum()==NodeEnum){705 706 node=(Node*)(*object);707 node->FieldExtrude(field,field_serial,field_name);708 709 }710 }711 686 712 687 } -
issm/trunk/src/c/DataSet/DataSet.h
r4043 r4055 80 80 void InputExtrude(int enum_type); 81 81 int DeleteObject(Object* object); 82 void FieldExtrude(Vec field,double* field_serial,char* field_name, int collapse);83 82 void OutputRifts(Vec riftproperties); 84 83 /*}}}*/ -
issm/trunk/src/c/EnumDefinitions/EnumAsString.cpp
r4051 r4055 26 26 case VerticesEnum : return "Vertices"; 27 27 case SolutionTypeEnum : return "SolutionType"; 28 case DiagnosticSolutionEnum : return "DiagnosticSolution";29 case SurfaceSlopeSolutionEnum : return "SurfaceSlopeSolution";30 case BedSlopeSolutionEnum : return "BedSlopeSolution";31 28 case AnalysisTypeEnum : return "AnalysisType"; 32 29 case SubAnalysisTypeEnum : return "SubAnalysisType"; … … 46 43 case InverseAnalysisEnum : return "InverseAnalysis"; 47 44 case ThermalAnalysisEnum : return "ThermalAnalysis"; 48 case TransientAnalysisEnum : return "TransientAnalysis"; 45 case Transient2DAnalysisEnum : return "Transient2DAnalysis"; 46 case Transient3DAnalysisEnum : return "Transient3DAnalysis"; 49 47 case SteadyAnalysisEnum : return "SteadyAnalysis"; 50 case Slope ComputeAnalysisEnum : return "SlopeComputeAnalysis";48 case SlopeAnalysisEnum : return "SlopeAnalysis"; 51 49 case BedSlopeXAnalysisEnum : return "BedSlopeXAnalysis"; 52 50 case BedSlopeYAnalysisEnum : return "BedSlopeYAnalysis"; … … 220 218 case StringExternalResultEnum : return "StringExternalResult"; 221 219 case JEnum : return "J"; 220 case RelativeEnum : return "Relative"; 221 case ResidualEnum : return "Residual"; 222 case AbsoluteEnum : return "Absolute"; 222 223 case BetaEnum : return "Beta"; 223 224 case CmGradientEnum : return "CmGradient"; … … 225 226 case CmMaxEnum : return "CmMax"; 226 227 case CmMinEnum : return "CmMin"; 228 case AdjointEnum : return "Adjoint"; 227 229 case GradientEnum : return "Gradient"; 230 case OldGradientEnum : return "OldGradient"; 228 231 case ConnectivityEnum : return "Connectivity"; 229 232 case ControlParameterEnum : return "ControlParameter"; -
issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h
r4051 r4055 22 22 /*Solution types {{{1 */ 23 23 SolutionTypeEnum, 24 DiagnosticSolutionEnum,25 SurfaceSlopeSolutionEnum,26 BedSlopeSolutionEnum,27 24 /*}}}*/ 28 25 /*Analysis types {{{1 */ … … 48 45 ThermalAnalysisEnum, 49 46 //transient 50 TransientAnalysisEnum, 47 Transient2DAnalysisEnum, 48 Transient3DAnalysisEnum, 51 49 SteadyAnalysisEnum, 52 50 //slope 53 Slope ComputeAnalysisEnum,51 SlopeAnalysisEnum, 54 52 BedSlopeXAnalysisEnum, 55 53 BedSlopeYAnalysisEnum, … … 254 252 JEnum, 255 253 /*}}}*/ 254 /*Convergence{{{1*/ 255 RelativeEnum, 256 ResidualEnum, 257 AbsoluteEnum, 258 /*}}}*/ 256 259 /*Parameters{{{1*/ 257 260 BetaEnum, … … 260 263 CmMaxEnum, 261 264 CmMinEnum, 265 AdjointEnum, 262 266 GradientEnum, 267 OldGradientEnum, 263 268 ConnectivityEnum, 264 269 ControlParameterEnum, -
issm/trunk/src/c/EnumDefinitions/StringAsEnum.cpp
r4051 r4055 24 24 else if (strcmp(name,"Vertices")==0) return VerticesEnum; 25 25 else if (strcmp(name,"SolutionType")==0) return SolutionTypeEnum; 26 else if (strcmp(name,"DiagnosticSolution")==0) return DiagnosticSolutionEnum;27 else if (strcmp(name,"SurfaceSlopeSolution")==0) return SurfaceSlopeSolutionEnum;28 else if (strcmp(name,"BedSlopeSolution")==0) return BedSlopeSolutionEnum;29 26 else if (strcmp(name,"AnalysisType")==0) return AnalysisTypeEnum; 30 27 else if (strcmp(name,"SubAnalysisType")==0) return SubAnalysisTypeEnum; … … 44 41 else if (strcmp(name,"InverseAnalysis")==0) return InverseAnalysisEnum; 45 42 else if (strcmp(name,"ThermalAnalysis")==0) return ThermalAnalysisEnum; 46 else if (strcmp(name,"TransientAnalysis")==0) return TransientAnalysisEnum; 43 else if (strcmp(name,"Transient2DAnalysis")==0) return Transient2DAnalysisEnum; 44 else if (strcmp(name,"Transient3DAnalysis")==0) return Transient3DAnalysisEnum; 47 45 else if (strcmp(name,"SteadyAnalysis")==0) return SteadyAnalysisEnum; 48 else if (strcmp(name,"Slope ComputeAnalysis")==0) return SlopeComputeAnalysisEnum;46 else if (strcmp(name,"SlopeAnalysis")==0) return SlopeAnalysisEnum; 49 47 else if (strcmp(name,"BedSlopeXAnalysis")==0) return BedSlopeXAnalysisEnum; 50 48 else if (strcmp(name,"BedSlopeYAnalysis")==0) return BedSlopeYAnalysisEnum; … … 218 216 else if (strcmp(name,"StringExternalResult")==0) return StringExternalResultEnum; 219 217 else if (strcmp(name,"J")==0) return JEnum; 218 else if (strcmp(name,"Relative")==0) return RelativeEnum; 219 else if (strcmp(name,"Residual")==0) return ResidualEnum; 220 else if (strcmp(name,"Absolute")==0) return AbsoluteEnum; 220 221 else if (strcmp(name,"Beta")==0) return BetaEnum; 221 222 else if (strcmp(name,"CmGradient")==0) return CmGradientEnum; … … 223 224 else if (strcmp(name,"CmMax")==0) return CmMaxEnum; 224 225 else if (strcmp(name,"CmMin")==0) return CmMinEnum; 226 else if (strcmp(name,"Adjoint")==0) return AdjointEnum; 225 227 else if (strcmp(name,"Gradient")==0) return GradientEnum; 228 else if (strcmp(name,"OldGradient")==0) return OldGradientEnum; 226 229 else if (strcmp(name,"Connectivity")==0) return ConnectivityEnum; 227 230 else if (strcmp(name,"ControlParameter")==0) return ControlParameterEnum; -
issm/trunk/src/c/Makefile.am
r4053 r4055 510 510 ./modules/DepthAverageInputx/DepthAverageInputx.cpp\ 511 511 ./modules/DepthAverageInputx/DepthAverageInputx.h\ 512 ./modules/ FieldExtrudex/FieldExtrudex.cpp\513 ./modules/ FieldExtrudex/FieldExtrudex.h\512 ./modules/VecExtrudex/VecExtrudex.cpp\ 513 ./modules/VecExtrudex/VecExtrudex.h\ 514 514 ./modules/InputToResultx/InputToResultx.cpp\ 515 515 ./modules/InputToResultx/InputToResultx.h\ 516 ./modules/InputConvergencex/InputConvergencex.cpp\ 517 ./modules/InputConvergencex/InputConvergencex.h\ 516 518 ./modules/ExtrudeInputx/ExtrudeInputx.cpp\ 517 519 ./modules/ExtrudeInputx/ExtrudeInputx.h\ … … 1014 1016 ./modules/DepthAverageInputx/DepthAverageInputx.cpp\ 1015 1017 ./modules/DepthAverageInputx/DepthAverageInputx.h\ 1016 ./modules/ FieldExtrudex/FieldExtrudex.cpp\1017 ./modules/ FieldExtrudex/FieldExtrudex.h\1018 ./modules/VecExtrudex/VecExtrudex.cpp\ 1019 ./modules/VecExtrudex/VecExtrudex.h\ 1018 1020 ./modules/InputToResultx/InputToResultx.cpp\ 1019 1021 ./modules/InputToResultx/InputToResultx.h\ 1022 ./modules/InputConvergencex/InputConvergencex.cpp\ 1023 ./modules/InputConvergencex/InputConvergencex.h\ 1020 1024 ./modules/ExtrudeInputx/ExtrudeInputx.cpp\ 1021 1025 ./modules/ExtrudeInputx/ExtrudeInputx.h\ … … 1030 1034 ./solutions/controlrestart.cpp\ 1031 1035 ./solutions/objectivefunctionC.cpp\ 1032 ./solutions/gradjcompute_core.cpp\ 1036 ./solutions/gradient_core.cpp\ 1037 ./solutions/adjoint_core.cpp\ 1033 1038 ./solutions/prognostic_core.cpp\ 1034 1039 ./solutions/prognostic2_core.cpp\ … … 1040 1045 ./solutions/bedslope.cpp\ 1041 1046 ./solutions/bedslope_core.cpp\ 1042 ./solutions/transient_core.cpp\ 1043 ./solutions/transient_core_2d.cpp\ 1044 ./solutions/transient_core_3d.cpp\ 1047 ./solutions/transient2d_core.cpp\ 1048 ./solutions/transient3d_core.cpp\ 1045 1049 ./solutions/steadystate_core.cpp\ 1046 1050 ./solutions/ResetBoundaryConditions.cpp\ … … 1058 1062 bin_PROGRAMS = 1059 1063 else 1060 bin_PROGRAMS = DiagnosticSolution.exe ThermalSolution.exe PrognosticSolution.exe Prognostic2Solution.exe BalancedthicknessSolution.exe Balancedthickness2Solution.exe BalancedvelocitiesSolution.exe Transient Solution.exe SteadystateSolution.exe SurfaceSlopeSolution.exe BedSlopeSolution.exe1064 bin_PROGRAMS = DiagnosticSolution.exe ThermalSolution.exe PrognosticSolution.exe Prognostic2Solution.exe BalancedthicknessSolution.exe Balancedthickness2Solution.exe BalancedvelocitiesSolution.exe Transient2DSolution.exe Transient23Solution.exe SteadystateSolution.exe SurfaceSlopeSolution.exe BedSlopeSolution.exe 1061 1065 endif 1062 1066 … … 1093 1097 BedSlopeSolution_exe_CXXFLAGS= -fPIC -D_PARALLEL_ 1094 1098 1095 TransientSolution_exe_SOURCES = solutions/transient.cpp 1096 TransientSolution_exe_CXXFLAGS= -fPIC -D_PARALLEL_ 1099 Transient2DSolution_exe_SOURCES = solutions/transient2d.cpp 1100 Transient2DSolution_exe_CXXFLAGS= -fPIC -D_PARALLEL_ 1101 1102 Transient3DSolution_exe_SOURCES = solutions/transient3d.cpp 1103 Transient3DSolution_exe_CXXFLAGS= -fPIC -D_PARALLEL_ -
issm/trunk/src/c/modules/CostFunctionx/CostFunctionx.h
r3913 r4055 10 10 11 11 /* local prototypes: */ 12 void CostFunctionx( double* pJ, DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials, Parameters* parameters, 13 int analysis_type,int sub_analysis_type); 12 void CostFunctionx( double* pJ, DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials, Parameters* parameters); 14 13 15 14 #endif /* _MISFITX_H */ -
issm/trunk/src/c/modules/DepthAverageInputx/DepthAverageInputx.cpp
r3969 r4055 10 10 #include "../../EnumDefinitions/EnumDefinitions.h" 11 11 12 void DepthAverageInputx( DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials, Parameters* parameters,int enum_type ){12 void DepthAverageInputx( DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials, Parameters* parameters,int enum_type,int average_enum_type){ 13 13 14 14 /*Intermediary*/ … … 22 22 for (i=0;i<elements->Size();i++){ 23 23 element=(Element*)elements->GetObjectByOffset(i); 24 element->DepthAverageInputAtBase(enum_type );24 element->DepthAverageInputAtBase(enum_type,average_enum_type); 25 25 } 26 26 27 27 /*Then extrude vertically the new inputs*/ 28 elements->InputExtrude(enum_type); 29 28 elements->InputExtrude(average_enum_type); 30 29 } -
issm/trunk/src/c/modules/DepthAverageInputx/DepthAverageInputx.h
r3913 r4055 9 9 10 10 /* local prototypes: */ 11 void DepthAverageInputx( DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials, Parameters* parameters,int enum_type );11 void DepthAverageInputx( DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials, Parameters* parameters,int enum_type,int average_enum_type); 12 12 13 13 #endif /* _DEPTHAVERAGEINPUTX_H */ -
issm/trunk/src/c/modules/Dux/Dux.h
r3913 r4055 10 10 11 11 /* local prototypes: */ 12 void Dux( Vec* pdu_g, DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials, Parameters* parameters, 13 int analysis_type,int sub_analysis_type); 14 12 void Dux( Vec* pdu_g, DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials, Parameters* parameters); 15 13 #endif /* _DUX_H */ 16 14 -
issm/trunk/src/c/modules/FieldDepthAveragex/FieldDepthAveragex.cpp
r3969 r4055 43 43 44 44 /*Extrude field to all nodes: */ 45 nodes->FieldExtrude(field,field_serial,fieldname,0); 45 for(i=0;i<nodes->Size();i++){ 46 node=(Node*)nodes->GetObjectByOffset(i); 47 node->VecExtrude(field,field_serial); 48 } 46 49 47 50 /*Assemble vector: */ -
issm/trunk/src/c/modules/GetSolutionFromInputsx/GetSolutionFromInputsx.h
r4013 r4055 10 10 11 11 /* local prototypes: */ 12 void GetSolutionFromInputsx( Vec* psolution, DataSet* elements,DataSet* nodes, DataSet* vertices,DataSet* loads, DataSet* materials, Parameters* parameters , int analysis_type, int sub_analysis_type);12 void GetSolutionFromInputsx( Vec* psolution, DataSet* elements,DataSet* nodes, DataSet* vertices,DataSet* loads, DataSet* materials, Parameters* parameters); 13 13 14 14 #endif /* _GETSOLUTIONFROMINPUTSXX_H */ -
issm/trunk/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.cpp
r4048 r4055 38 38 39 39 } 40 41 void GetVectorFromInputsx( double* pvector, DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials, Parameters* parameters, int NameEnum, int TypeEnum){ 42 43 /*output: */ 44 double* vector=NULL; 45 46 /*intermediary: */ 47 Vec vec_vector=NULL; 48 49 GetVectorFromInputsx( &vec_vector, elements,nodes, vertices, loads, materials, parameters, NameEnum, TypeEnum); 50 VecToMPISerial(&vector,vec_vector); 51 52 /*Free ressources:*/ 53 VecFree(&vec_vector); 54 55 /*Assign output pointers:*/ 56 *pvector=vector; 57 } -
issm/trunk/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.h
r4048 r4055 10 10 /* local prototypes: */ 11 11 void GetVectorFromInputsx( Vec* pvector, DataSet* elements,DataSet* nodes, DataSet* vertices,DataSet* loads, DataSet* materials, Parameters* parameters,int NameEnum,int TypeEnum); 12 void GetVectorFromInputsx( double* pvector, DataSet* elements,DataSet* nodes, DataSet* vertices,DataSet* loads, DataSet* materials, Parameters* parameters,int NameEnum,int TypeEnum); 12 13 13 14 #endif /* _GETVECTORFROMINPUTSXX_H */ -
issm/trunk/src/c/modules/Gradjx/Gradjx.cpp
r4053 r4055 10 10 #include "../../EnumDefinitions/EnumDefinitions.h" 11 11 12 void Gradjx( DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials, Parameters* parameters,int control_type){12 void Gradjx( Vec* pgradient, DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials, Parameters* parameters,int control_type){ 13 13 14 14 int i; 15 15 int dim; 16 17 16 int numberofvertices; 17 Vec gradient=NULL; 18 18 19 /*First, get elements and loads configured: */ 19 20 elements-> Configure(elements,loads, nodes,vertices, materials,parameters); … … 23 24 /*retrieve some parameters: */ 24 25 parameters->FindParam(&dim,DimEnum); 26 parameters->FindParam(&numberofvertices,NumberOfVerticesEnum); 25 27 26 28 /*Compute gradients: */ 27 29 for (i=0;i<elements->Size();i++){ 28 30 Element* element=(Element*)elements->GetObjectByOffset(i); 29 element->Gradj( control_type);31 element->Gradj(gradient,control_type); 30 32 } 31 33 34 /*Assemble vector: */ 35 VecAssemblyBegin(gradient); 36 VecAssemblyEnd(gradient); 37 32 38 /*Extrude if needed: */ 33 if(dim==3) ExtrudeInputx( elements,nodes, vertices, loads, materials, parameters,GradientEnum);39 if(dim==3) VecExtrudex(gradient, elements,nodes, vertices, loads, materials, parameters,0); 34 40 41 /*Assign output pointers: */ 42 *pgradient=gradient; 35 43 } -
issm/trunk/src/c/modules/Gradjx/Gradjx.h
r4047 r4055 10 10 11 11 /* local prototypes: */ 12 void Gradjx( DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials, Parameters* parameters, int control_type);12 void Gradjx(Vec* pgrad_g, DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials, Parameters* parameters, int control_type); 13 13 14 14 #endif /* _GRADJX_H */ -
issm/trunk/src/c/modules/ModelProcessorx/CreateDataSets.cpp
r4034 r4055 57 57 break; 58 58 59 case Slope ComputeAnalysisEnum:59 case SlopeAnalysisEnum: 60 60 CreateNodesSlopeCompute(pnodes, iomodel,iomodel_handle); 61 61 CreateConstraintsSlopeCompute(pconstraints,iomodel,iomodel_handle); -
issm/trunk/src/c/modules/ModelProcessorx/CreateParameters.cpp
r4034 r4055 37 37 if (iomodel->dim==2) parameters->AddObject(new IntParam(DimEnum,2)); 38 38 else parameters->AddObject(new IntParam(DimEnum,3)); 39 parameters->AddObject(new StringParam(OutputFileNameEnum,iomodel->outputfilename));40 39 parameters->AddObject(new BoolParam(IsHutterEnum,iomodel->ishutter)); 41 40 parameters->AddObject(new BoolParam(IsMacAyealPattynEnum,iomodel->ismacayealpattyn)); -
issm/trunk/src/c/modules/ModelProcessorx/SlopeCompute/CreateNodesSlopeCompute.cpp
r4025 r4055 46 46 47 47 /*Add node to nodes dataset: */ 48 nodes->AddObject(new Node(iomodel->nodecounter+i+1,i,iomodel,Slope ComputeAnalysisEnum));48 nodes->AddObject(new Node(iomodel->nodecounter+i+1,i,iomodel,SlopeAnalysisEnum)); 49 49 50 50 } -
issm/trunk/src/c/modules/OutputResultsx/OutputResultsx.cpp
r4042 r4055 15 15 #include "../../objects/objects.h" 16 16 17 void OutputResults(DataSet* elements, DataSet* loads, DataSet* nodes, DataSet* vertices, DataSet* materials, Parameters* parameters , char* filename){17 void OutputResults(DataSet* elements, DataSet* loads, DataSet* nodes, DataSet* vertices, DataSet* materials, Parameters* parameters){ 18 18 19 19 int i; 20 20 21 21 Patch* patch=NULL; 22 char* filename=NULL; 22 23 23 24 int solutiontype; … … 37 38 //Recover solutiontype which will be output to disk: 38 39 parameters->FindParam(&solutiontype,SolutionTypeEnum); 40 parameters->FindParam(&filename,OutputFileNameEnum); 39 41 40 42 //Process results to be output in the correct units … … 104 106 /*Free ressources:*/ 105 107 delete patch; 108 xfree((void**)&filename); 106 109 107 110 } -
issm/trunk/src/c/modules/OutputResultsx/OutputResultsx.h
r4042 r4055 9 9 10 10 /* local prototypes: */ 11 void OutputResults(DataSet* elements, DataSet* loads, DataSet* nodes, DataSet* vertices, DataSet* materials, Parameters* parameters , char* filename);11 void OutputResults(DataSet* elements, DataSet* loads, DataSet* nodes, DataSet* vertices, DataSet* materials, Parameters* parameters); 12 12 13 13 #endif /* _OUTPUTRESULTS_H */ -
issm/trunk/src/c/modules/UpdateGeometryx/UpdateGeometryx.cpp
r3913 r4055 11 11 #include "../../DataSet/DataSet.h" 12 12 13 void UpdateGeometryx(Vec* poutthickness,Vec* poutbed,Vec* poutsurface, 14 DataSet* elements, DataSet* nodes, DataSet* vertices,DataSet* loads, DataSet* materials, Parameters* parameters, 15 Vec vec_newthickness,Vec vec_bed,Vec vec_surface){ 13 void UpdateGeometryx( DataSet* elements, DataSet* nodes, DataSet* vertices,DataSet* loads, DataSet* materials, Parameters* parameters){ 16 14 17 15 int i; 18 16 int dof; 19 17 20 /*serialized input: */ 18 /*vectorized inputs: */ 19 Vec vec_newthickness=NULL; 20 Vec vec_bed=NULL; 21 Vec vec_surface=NULL: 21 22 double* newthickness=NULL; 22 23 double* bed=NULL; … … 24 25 25 26 /*objects: */ 26 Node* node=NULL;27 Vertex* vertex=NULL; 27 28 Object* object=NULL; 28 29 Matpar* matpar=NULL; … … 31 32 double h,b,s; 32 33 double rho_ice,rho_water; 33 34 /*output: */35 Vec outthickness=NULL;36 Vec outbed=NULL;37 Vec outsurface=NULL;38 39 /*Duplicate inputs to outputs, do not copy values!: */40 VecDuplicate(vec_newthickness,&outthickness);41 VecDuplicate(vec_bed,&outbed);42 VecDuplicate(vec_surface,&outsurface);43 34 44 35 /*First, get elements and loads configured: */ … … 49 40 parameters->Configure(elements,loads, nodes,vertices, materials,parameters); 50 41 51 /*Serialize inputs :*/ 42 /*retrieve inputs: */ 43 GetVectorFromInputsx( &vec_newthickness, elements, nodes, vertices, loads, materials, parameters, ThicknessEnum,VertexEnum); 44 GetVectorFromInputsx( &vec_bed, elements, nodes, vertices, loads, materials, parameters, ThicknessEnum,VertexEnum); 45 GetVectorFromInputsx( &vec_surface, elements, nodes, vertices, loads, materials, parameters, ThicknessEnum,VertexEnum); 46 52 47 VecToMPISerial(&newthickness,vec_newthickness); 53 48 VecToMPISerial(&bed,vec_bed); … … 67 62 rho_water=matpar->GetRhoWater(); 68 63 69 /*Go through nodes and for each node, update the thickness, bed and surface, using the64 /*Go through vertices and for each vertex, update the thickness, bed and surface, using the 70 65 * new thickness computed in the prognostic_core part of the transient solution sequence: */ 71 66 72 for(i=0;i< nodes->Size();i++){67 for(i=0;i<vertices->Size();i++){ 73 68 74 69 /*get i'th node: */ 75 node=(Node*)nodes->GetObjectByOffset(i);70 vertex=(Vertex*)vertices->GetObjectByOffset(i); 76 71 77 /*first, recover thickness, surface and bed for this node: */78 dof= node->GetDofList1();72 /*first, recover thickness, surface and bed for this vertex: */ 73 dof=vertex->GetDofList1(); 79 74 h=newthickness[dof]; 80 75 s=surface[dof]; … … 85 80 86 81 //For grids on ice sheet, the new bed remains the same, the new surface becomes bed+new_thickness. 87 if ( node->IsOnSheet()){82 if (vertex->IsOnSheet()){ 88 83 s=b+h; 89 84 } 90 85 91 86 //For grids on ice shelt, we have hydrostatic equilibrium (for now) 92 if ( node->IsOnShelf()){87 if (vertex->IsOnShelf()){ 93 88 b=-rho_ice/rho_water*h; 94 89 s=(1-rho_ice/rho_water)*h; … … 96 91 97 92 /*Ok, plug values of thickness, surafce and bed into our outputs: */ 98 VecSetValues( outthickness,1,&dof,&h,INSERT_VALUES);99 VecSetValues( outbed,1,&dof,&b,INSERT_VALUES);100 VecSetValues( outsurface,1,&dof,&s,INSERT_VALUES);93 VecSetValues(vec_newthickness,1,&dof,&h,INSERT_VALUES); 94 VecSetValues(vec_bed,1,&dof,&b,INSERT_VALUES); 95 VecSetValues(vec_surface,1,&dof,&s,INSERT_VALUES); 101 96 } 102 97 103 98 /*Assemble vectors: */ 104 VecAssemblyBegin( outthickness);105 VecAssemblyEnd( outthickness);99 VecAssemblyBegin(vec_newthickness); 100 VecAssemblyEnd(vec_newthickness); 106 101 107 VecAssemblyBegin( outbed);108 VecAssemblyEnd( outbed);102 VecAssemblyBegin(vec_bed); 103 VecAssemblyEnd(vec_bed); 109 104 110 VecAssemblyBegin(outsurface); 111 VecAssemblyEnd(outsurface); 105 VecAssemblyBegin(vec_surface); 106 VecAssemblyEnd(vec_surface); 107 108 /*Put back into inputs:*/ 109 UpdateInputsFromVectorx( elements,nodes, vertices,loads, materials, parameters,vec_newthickness,ThicknessEnum,VertexEnum); //clobber existing thickness input with new one 110 UpdateInputsFromVectorx( elements,nodes, vertices,loads, materials, parameters,vec_bed,BedEnum,VertexEnum); 111 UpdateInputsFromVectorx( elements,nodes, vertices,loads, materials, parameters,vec_surface,SurfaceEnum,VertexEnum); 112 112 113 113 /*Free ressources:*/ 114 VecFree(&vec_newthickness); 115 VecFree(&vec_bed); 116 VecFree(&vec_surface); 114 117 xfree((void**)&newthickness); 115 118 xfree((void**)&bed); 116 119 xfree((void**)&surface); 117 120 118 /*Assign output pointers: */119 *poutthickness=outthickness;120 *poutbed=outbed;121 *poutsurface=outsurface;122 121 } -
issm/trunk/src/c/modules/UpdateGeometryx/UpdateGeometryx.h
r3913 r4055 10 10 11 11 /* local prototypes: */ 12 void UpdateGeometryx(Vec* poutthickness,Vec* poutbed,Vec* poutsurface, 13 DataSet* elements, DataSet* nodes,DataSet* vertices,DataSet* loads, DataSet* materials, Parameters* parameters, 14 Vec newthickness,Vec bed,Vec surface); 12 void UpdateGeometryx(DataSet* elements, DataSet* nodes,DataSet* vertices,DataSet* loads, DataSet* materials, Parameters* parameters); 15 13 16 14 #endif /* _UPDATEGEOMETRYX_H */ -
issm/trunk/src/c/modules/modules.h
r4053 r4055 53 53 #include "./ComputePressurex/ComputePressurex.h" 54 54 #include "./ComputeStrainRatex/ComputeStrainRatex.h" 55 #include "./ FieldExtrudex/FieldExtrudex.h"55 #include "./VecExtrudex/VecExtrudex.h" 56 56 #include "./Qmux/Qmux.h" 57 57 #include "./NodeConnectivityx/NodeConnectivityx.h" … … 81 81 #include "./ScaleInputx/ScaleInputx.h" 82 82 #include "./AXPYInputx/AXPYInputx.h" 83 #include "./GetVectorFromInputsx/GetVectorFromInputsx.h" 84 #include "./InputConvergencex/InputConvergencex.h" 83 85 84 86 #endif -
issm/trunk/src/c/objects/Elements/Beam.cpp
r4050 r4055 562 562 /*}}}*/ 563 563 /*FUNCTION Beam::Gradj{{{1*/ 564 void Beam::Gradj( int control_type){564 void Beam::Gradj(Vec gradient,int control_type){ 565 565 ISSMERROR(" not supported yet!"); 566 566 } 567 567 /*}}}*/ 568 568 /*FUNCTION Beam::GradjB{{{1*/ 569 void Beam::GradjB( void){569 void Beam::GradjB(Vec gradient){ 570 570 ISSMERROR(" not supported yet!"); 571 571 } 572 572 /*}}}*/ 573 573 /*FUNCTION Beam::GradjDrag{{{1*/ 574 void Beam::GradjDrag( void){574 void Beam::GradjDrag(Vec gradient){ 575 575 ISSMERROR(" not supported yet!"); 576 576 } … … 1055 1055 } 1056 1056 /*}}}*/ 1057 /*FUNCTION Beam::InputConvergence(int* pconverged, double* eps, int* enums,int num_enums,int* criterionenums,double* criterionvalues,int num_criterionenums){{{1*/ 1058 void Beam::InputConvergence(int* pconverged,double* eps, int* enums,int num_enums,int* criterionenums,double* criterionvalues,int num_criterionenums){a 1059 1060 Input** new_inputs=NULL; 1061 Input** old_inputs=NULL; 1062 int converged=1; 1063 1064 new_inputs=(Input**)xmalloc(num_enums/2*sizeof(Input*)); //half the enums are for the new inputs 1065 old_inputs=(Input**)xmalloc(num_enums/2*sizeof(Input*)); //half the enums are for the old inputs 1066 1067 for(i=0;i<num_enums/2;i++){ 1068 new_inputs[i]=(Input*)this->inputs->GetInput(new_enums[2*i+0]); 1069 old_inputs[i]=(Input*)this->inputs->GetInput(old_enums[2*i+1]); 1070 if(!new_inputs[i])ISSMERROR("%s%s"," could not find input with enum ",EnumAsString(new_enums[2*i+0])); 1071 if(!old_inputs[i])ISSMERROR("%s%s"," could not find input with enum ",EnumAsString(old_enums[2*i+0])); 1072 } 1073 1074 /*ok, we've got the inputs (new and old), now loop throught the number of criterions and fill the eps array:*/ 1075 for(i=0;i<num_criterionenums;i++){ 1076 IsInputConverged(eps+i,new_inputs,old_inputs,num_enums/2,,criterionenums[i]); 1077 if(eps[i]>criterionvalues[i]) converged=0; 1078 } 1079 1080 /*Assign output pointers:*/ 1081 *pconverged=converged; 1082 1083 } 1084 /*}}}*/ -
issm/trunk/src/c/objects/Elements/Beam.h
r4050 r4055 62 62 void UpdateInputsFromConstant(bool constant, int name){ISSMERROR("Not implemented yet!");} 63 63 void UpdateInputsFromSolution(double* solution); 64 void DepthAverageInputAtBase(int enum_type ){ISSMERROR("not implemented yet");};64 void DepthAverageInputAtBase(int enum_type,int average_enum_type){ISSMERROR("not implemented yet");}; 65 65 void InputToResult(int enum_type,int step,double time); 66 66 void ProcessResultsUnits(void); … … 98 98 void AXPYInput(int YEnum, double scalar, int XEnum); 99 99 void ControlConstrainInput(int control_type,double cm_min, double cm_max); 100 void InputConvergence(int* enums,int num_enums,int* criterionenums,double* criterionvalues,int num_criterionenums); 100 101 101 102 /*}}}*/ … … 106 107 void GetThicknessList(double* thickness_list); 107 108 void Du(Vec); 108 void Gradj( int control_type);109 void GradjDrag( void);110 void GradjB( void);109 void Gradj(Vec gradient,int control_type); 110 void GradjDrag(Vec gradient); 111 void GradjB(Vec gradient); 111 112 double Misfit(void); 112 113 double SurfaceArea(void); -
issm/trunk/src/c/objects/Elements/Element.h
r4050 r4055 37 37 virtual void GetBedList(double* bed_list)=0; 38 38 virtual void Du(Vec du_g)=0; 39 virtual void Gradj( int control_type)=0;40 virtual void GradjDrag( void)=0;41 virtual void GradjB( void)=0;39 virtual void Gradj(Vec gradient,int control_type)=0; 40 virtual void GradjDrag(Vec gradient)=0; 41 virtual void GradjB(Vec gradient)=0; 42 42 virtual double Misfit(void)=0; 43 43 virtual double CostFunction(void)=0; 44 44 virtual double SurfaceArea(void)=0; 45 virtual void DepthAverageInputAtBase(int enum_type )=0;45 virtual void DepthAverageInputAtBase(int enum_type,int average_enum_type)=0; 46 46 virtual void ComputeBasalStress(Vec sigma_b)=0; 47 47 virtual void ComputePressure(Vec p_g)=0; … … 69 69 virtual void AXPYInput(int YEnum, double scalar, int XEnum)=0; 70 70 virtual void ControlConstrainInput(int control_type,double cm_min, double cm_max)=0; 71 virtual void InputConvergence(int* pconverged, double* eps, int* enums,int num_enums,int* criterionenums,double criterionvalues,double* criterionvalues,int num_criterionenums)=0; 72 71 73 /*Implementation: */ 72 74 -
issm/trunk/src/c/objects/Elements/Penta.cpp
r4050 r4055 658 658 659 659 } 660 else if (analysis_type==Slope ComputeAnalysisEnum){660 else if (analysis_type==SlopeAnalysisEnum){ 661 661 662 662 UpdateInputsFromSolutionSlopeCompute( solution); … … 1270 1270 else ISSMERROR("%s%i%s\n","sub_analysis: ",sub_analysis_type," not supported yet"); 1271 1271 } 1272 else if (analysis_type==Slope ComputeAnalysisEnum){1272 else if (analysis_type==SlopeAnalysisEnum){ 1273 1273 CreateKMatrixSlopeCompute( Kgg); 1274 1274 } … … 2357 2357 else ISSMERROR("%s%i%s\n","sub_analysis: ",sub_analysis_type," not supported yet"); 2358 2358 } 2359 else if (analysis_type==Slope ComputeAnalysisEnum){2359 else if (analysis_type==SlopeAnalysisEnum){ 2360 2360 CreatePVectorSlopeCompute( pg); 2361 2361 } … … 3263 3263 } 3264 3264 /*}}}*/ 3265 /*FUNCTION Penta:: FieldExtrude {{{1*/3266 void Penta:: FieldExtrude(Vec field,double* field_serial,char* field_name,int iscollapsed){3265 /*FUNCTION Penta::VecExtrude {{{1*/ 3266 void Penta::VecExtrude(Vec vector,double* vector_serial,int iscollapsed){ 3267 3267 3268 3268 /* node data: */ 3269 const int numgrids=6; 3270 int numberofdofspernode; 3269 int i; 3271 3270 Node* node=NULL; 3272 int i;3273 3271 int extrude=0; 3274 3272 … … 3296 3294 if(onbed==0)extrude=0; 3297 3295 3298 /*Go on and extrude field: */3296 /*Go on and extrude vector: */ 3299 3297 if (extrude){ 3300 3298 3301 if (strcmp(field_name,"velocity")==0){ 3302 3303 /* node data: */ 3304 const int numdof=2*numgrids; 3305 int doflist[numdof]; 3306 int nodedofs[2]; 3307 double fieldel[2]; 3308 3309 3310 GetDofList(&doflist[0],&numberofdofspernode); 3311 3312 /*this penta is a collapsed macayeal. For each node on the base of this penta, 3313 * we grab the field. Once we know the field, we follow the upper nodes, 3314 * inserting the same field value into field, until we reach the surface: */ 3315 for(i=0;i<3;i++){ 3316 3317 node=nodes[i]; //base nodes 3318 3319 /*get field for this base node: */ 3320 fieldel[0]=field_serial[doflist[numberofdofspernode*i+0]]; 3321 fieldel[1]=field_serial[doflist[numberofdofspernode*i+1]]; 3322 3323 //go throfieldn all nodes which sit on top of this node, until we reach the surface, 3324 //and plfield field in field 3325 for(;;){ 3326 3327 node->GetDofList(&nodedofs[0],&numberofdofspernode); 3328 VecSetValues(field,1,&nodedofs[0],&fieldel[0],INSERT_VALUES); 3329 VecSetValues(field,1,&nodedofs[1],&fieldel[1],INSERT_VALUES); 3330 3331 if (node->IsOnSurface())break; 3332 /*get next node: */ 3333 node=node->GetUpperNode(); 3334 } 3335 } 3336 } //if (strcmp(field_name,"velocity")==0) 3337 else if (strcmp(field_name,"gradj")==0){ 3338 3339 /* node data: */ 3340 int dof1; 3341 double fieldel; 3342 3343 /*this penta is a collapsed macayeal. For each node on the base of this penta, 3344 * we grab the field. Once we know the field, we follow the upper nodes, 3345 * inserting the same field value into field, until we reach the surface: */ 3346 for(i=0;i<3;i++){ 3347 3348 node=nodes[i]; //base nodes 3299 /* node data: */ 3300 int dof1; 3301 double vectorel; 3302 3303 /*this penta is a collapsed macayeal. For each node on the base of this penta, 3304 * we grab the vector. Once we know the vector, we follow the upper nodes, 3305 * inserting the same vector value into vector, until we reach the surface: */ 3306 for(i=0;i<3;i++){ 3307 3308 node=nodes[i]; //base nodes 3309 dof1=node->GetDofList1(); 3310 3311 /*get vector for this base node: */ 3312 vectorel=vector_serial[dof1]; 3313 3314 //go throvectorn all nodes which sit on top of this node, until we reach the surface, 3315 //and plvector vector in vector 3316 for(;;){ 3317 3349 3318 dof1=node->GetDofList1(); 3350 3351 /*get field for this base node: */ 3352 fieldel=field_serial[dof1]; 3353 3354 //go throfieldn all nodes which sit on top of this node, until we reach the surface, 3355 //and plfield field in field 3356 for(;;){ 3357 3358 dof1=node->GetDofList1(); 3359 VecSetValues(field,1,&dof1,&fieldel,INSERT_VALUES); 3360 3361 if (node->IsOnSurface())break; 3362 /*get next node: */ 3363 node=node->GetUpperNode(); 3364 } 3319 VecSetValues(vector,1,&dof1,&vectorel,INSERT_VALUES); 3320 3321 if (node->IsOnSurface())break; 3322 /*get next node: */ 3323 node=node->GetUpperNode(); 3365 3324 } 3366 3325 } 3367 else if ( 3368 (strcmp(field_name,"thickness")==0) || 3369 (strcmp(field_name,"surface")==0) || 3370 (strcmp(field_name,"bed")==0) || 3371 (strcmp(field_name,"slopex")==0) || 3372 (strcmp(field_name,"slopey")==0) 3373 ){ 3374 3375 /* node data: */ 3376 const int numdof=1*numgrids; 3377 int doflist[numdof]; 3378 int nodedofs; 3379 double fieldel; 3380 3381 GetDofList(&doflist[0],&numberofdofspernode); 3382 3383 /*this penta is on the bed. For each node on the base of this penta, 3384 * we grab the thickness. Once we know the thickness, we follow the upper nodes, 3385 * inserting the same thickness value into tg, until we reach the surface: */ 3386 for(i=0;i<3;i++){ 3387 3388 node=nodes[i]; //base nodes 3389 3390 /*get velocity for this base node: */ 3391 fieldel=field_serial[doflist[numberofdofspernode*i+0]]; 3392 3393 //go through all nodes which sit on top of this node, until we reach the surface, 3394 //and pltg fieldel in field: 3395 for(;;){ 3396 3397 node->GetDofList(&nodedofs,&numberofdofspernode); 3398 VecSetValues(field,1,&nodedofs,&fieldel,INSERT_VALUES); 3399 3400 if (node->IsOnSurface())break; 3401 /*get next node: */ 3402 node=node->GetUpperNode(); 3403 } 3404 } 3405 3406 } 3407 else ISSMERROR("%s%s%s"," field ",field_name," not supported yet!"); 3408 3409 } //if (extrude) 3326 } 3410 3327 } 3411 3328 /*}}}*/ … … 3451 3368 /*}}}*/ 3452 3369 /*FUNCTION Penta::DepthAverageInputAtBase{{{1*/ 3453 void Penta::DepthAverageInputAtBase(int enum_type ){3370 void Penta::DepthAverageInputAtBase(int enum_type,int average_enum_type){ 3454 3371 ISSMERROR("Not implemented yet (see Penta::InputExtrude and Node::FieldDepthAverageAtBase)"); 3455 3372 } … … 4555 4472 /*}}}*/ 4556 4473 /*FUNCTION Penta::Gradj {{{1*/ 4557 void Penta::Gradj( int control_type){4474 void Penta::Gradj(Vec gradient,int control_type){ 4558 4475 4559 4476 /*inputs: */ … … 4567 4484 4568 4485 if (control_type==DragCoefficientEnum){ 4569 GradjDrag( );4486 GradjDrag(gradient); 4570 4487 } 4571 4488 else if (control_type=RheologyBEnum){ 4572 GradjB( );4489 GradjB(gradient); 4573 4490 } 4574 4491 else ISSMERROR("%s%i","control type not supported yet: ",control_type); … … 4576 4493 /*}}}*/ 4577 4494 /*FUNCTION Penta::GradjDrag {{{1*/ 4578 void Penta::GradjDrag( void){4495 void Penta::GradjDrag(Vec gradient){ 4579 4496 4580 4497 int i; 4581 4498 Tria* tria=NULL; 4582 4499 TriaVertexInput* triavertexinput=NULL; 4583 double gradient[6]={0,0,0,0,0,0};4500 double temp_gradient[6]={0,0,0,0,0,0}; 4584 4501 4585 4502 /*inputs: */ … … 4611 4528 /*MacAyeal or Pattyn*/ 4612 4529 tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria. 4613 tria->GradjDrag(); 4530 tria->GradjDrag(gradient); 4531 delete tria; 4614 4532 } 4615 4533 else if (sub_analysis_type==StokesAnalysisEnum){ … … 4617 4535 /*Stokes*/ 4618 4536 tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria. 4619 tria->GradjDragStokes(); 4537 tria->GradjDragStokes(gradient); 4538 delete tria; 4620 4539 } 4621 4540 else ISSMERROR("%s%i%s\n","sub_analysis: ",sub_analysis_type," not supported yet"); 4622 4541 4623 /*Now, the tria has a GradientEnum input. Take it, and make a PentaVertexInput out of it, then delete the tria: */4624 triavertexinput=(TriaVertexInput*)tria->inputs->GetInput(GradientEnum);4625 for(i=0;i<3;i++)gradient[i]=triavertexinput->values[i];4626 this->inputs->AddInput(new PentaVertexInput(GradientEnum,&gradient[0]));4627 4628 delete tria;4629 4542 4630 4543 } 4631 4544 /*}}}*/ 4632 4545 /*FUNCTION Penta::GradjB {{{1*/ 4633 void Penta::GradjB( void){4546 void Penta::GradjB(Vec gradient){ 4634 4547 4635 4548 int i; 4636 4549 Tria* tria=NULL; 4637 4550 TriaVertexInput* triavertexinput=NULL; 4638 double gradient[6]={0,0,0,0,0,0};4639 4551 4640 4552 /*inputs: */ … … 4658 4570 * and compute gardj*/ 4659 4571 tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria (lower face). 4660 tria->GradjB(); 4572 tria->GradjB(gradient); 4573 delete tria; 4661 4574 } 4662 4575 else{ 4663 4576 /*B is a 2d field, use MacAyeal(2d) gradient even if it is Stokes or Pattyn*/ 4664 4577 tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria (lower face). 4665 tria->GradjB(); 4578 tria->GradjB(gradient); 4579 delete tria; 4666 4580 } 4667 4581 4668 /*Now, the tria has a GradientEnum input. Take it, and make a PentaVertexInput out of it, then delete the tria: */4669 triavertexinput=(TriaVertexInput*)tria->inputs->GetInput(GradientEnum);4670 for(i=0;i<3;i++)gradient[i]=triavertexinput->values[i];4671 this->inputs->AddInput(new PentaVertexInput(GradientEnum,&gradient[0]));4672 4673 delete tria;4674 4582 4675 4583 } … … 5407 5315 } 5408 5316 /*}}}*/ 5317 /*FUNCTION Penta::InputConvergence(int* pconverged, double* eps, int* enums,int num_enums,int* criterionenums,double* criterionvalues,int num_criterionenums){{{1*/ 5318 void Penta::InputConvergence(int* pconverged,double* eps, int* enums,int num_enums,int* criterionenums,double* criterionvalues,int num_criterionenums){a 5319 5320 Input** new_inputs=NULL; 5321 Input** old_inputs=NULL; 5322 int converged=1; 5323 5324 new_inputs=(Input**)xmalloc(num_enums/2*sizeof(Input*)); //half the enums are for the new inputs 5325 old_inputs=(Input**)xmalloc(num_enums/2*sizeof(Input*)); //half the enums are for the old inputs 5326 5327 for(i=0;i<num_enums/2;i++){ 5328 new_inputs[i]=(Input*)this->inputs->GetInput(new_enums[2*i+0]); 5329 old_inputs[i]=(Input*)this->inputs->GetInput(old_enums[2*i+1]); 5330 if(!new_inputs[i])ISSMERROR("%s%s"," could not find input with enum ",EnumAsString(new_enums[2*i+0])); 5331 if(!old_inputs[i])ISSMERROR("%s%s"," could not find input with enum ",EnumAsString(old_enums[2*i+0])); 5332 } 5333 5334 /*ok, we've got the inputs (new and old), now loop throught the number of criterions and fill the eps array:*/ 5335 for(i=0;i<num_criterionenums;i++){ 5336 IsInputConverged(eps+i,new_inputs,old_inputs,num_enums/2,,criterionenums[i]); 5337 if(eps[i]>criterionvalues[i]) converged=0; 5338 } 5339 5340 /*Assign output pointers:*/ 5341 *pconverged=converged; 5342 5343 } 5344 /*}}}*/ -
issm/trunk/src/c/objects/Elements/Penta.h
r4050 r4055 86 86 bool GetOnBed(); 87 87 void Du(Vec du_gg); 88 void Gradj( int control_type);89 void GradjDrag( void);90 void GradjB( void);88 void Gradj(Vec gradient,int control_type); 89 void GradjDrag(Vec gradient); 90 void GradjB(Vec gradient); 91 91 double Misfit(void); 92 92 double SurfaceArea(void); … … 110 110 void GetParameterDerivativeValue(double* p, double* p_list,double* xyz_list, double* gauss_coord); 111 111 void GetNodalFunctions(double* l1l6, double* gauss_coord); 112 void FieldExtrude(Vec field,double* field_serial,char* field_name,int iscollapsed);112 void VecExtrude(Vec vector,double* vector_serial,int iscollapsed); 113 113 void InputExtrude(int enum_type); 114 void DepthAverageInputAtBase(int enum_type );114 void DepthAverageInputAtBase(int enum_type,int average_enum_type); 115 115 void ComputeBasalStress(Vec sigma_bg); 116 116 void ComputePressure(Vec p_gg); … … 165 165 void AXPYInput(int YEnum, double scalar, int XEnum); 166 166 void ControlConstrainInput(int control_type,double cm_min, double cm_max); 167 void InputConvergence(int* enums,int num_enums,int* criterionenums,double* criterionvalues,int num_criterionenums); 167 168 void GetVectorFromInputs(Vec vector,int NameEnum); 168 169 -
issm/trunk/src/c/objects/Elements/Sing.cpp
r4050 r4055 383 383 /*}}}*/ 384 384 /*FUNCTION Sing::Gradj {{{1*/ 385 void Sing::Gradj( int control_type){385 void Sing::Gradj(Vec gradient,int control_type){ 386 386 ISSMERROR(" not supported yet!"); 387 387 } 388 388 /*}}}*/ 389 389 /*FUNCTION Sing::GradB {{{1*/ 390 void Sing::GradjB( void){390 void Sing::GradjB(Vec gradient){ 391 391 ISSMERROR(" not supported yet!"); 392 392 } 393 393 /*}}}*/ 394 394 /*FUNCTION Sing::GradjDrag {{{1*/ 395 void Sing::GradjDrag( void){395 void Sing::GradjDrag(Vec gradient){ 396 396 ISSMERROR(" not supported yet!"); 397 397 } … … 761 761 } 762 762 /*}}}*/ 763 /*FUNCTION Sing::InputConvergence(int* pconverged, double* eps, int* enums,int num_enums,int* criterionenums,double* criterionvalues,int num_criterionenums){{{1*/ 764 void Sing::InputConvergence(int* pconverged,double* eps, int* enums,int num_enums,int* criterionenums,double* criterionvalues,int num_criterionenums){a 765 766 Input** new_inputs=NULL; 767 Input** old_inputs=NULL; 768 int converged=1; 769 770 new_inputs=(Input**)xmalloc(num_enums/2*sizeof(Input*)); //half the enums are for the new inputs 771 old_inputs=(Input**)xmalloc(num_enums/2*sizeof(Input*)); //half the enums are for the old inputs 772 773 for(i=0;i<num_enums/2;i++){ 774 new_inputs[i]=(Input*)this->inputs->GetInput(new_enums[2*i+0]); 775 old_inputs[i]=(Input*)this->inputs->GetInput(old_enums[2*i+1]); 776 if(!new_inputs[i])ISSMERROR("%s%s"," could not find input with enum ",EnumAsString(new_enums[2*i+0])); 777 if(!old_inputs[i])ISSMERROR("%s%s"," could not find input with enum ",EnumAsString(old_enums[2*i+0])); 778 } 779 780 /*ok, we've got the inputs (new and old), now loop throught the number of criterions and fill the eps array:*/ 781 for(i=0;i<num_criterionenums;i++){ 782 IsInputConverged(eps+i,new_inputs,old_inputs,num_enums/2,,criterionenums[i]); 783 if(eps[i]>criterionvalues[i]) converged=0; 784 } 785 786 /*Assign output pointers:*/ 787 *pconverged=converged; 788 789 } 790 /*}}}*/ -
issm/trunk/src/c/objects/Elements/Sing.h
r4050 r4055 62 62 void UpdateInputsFromConstant(bool constant, int name){ISSMERROR("Not implemented yet!");} 63 63 void UpdateInputsFromSolution(double* solutiong); 64 void DepthAverageInputAtBase(int enum_type ){ISSMERROR("not implemented yet");};64 void DepthAverageInputAtBase(int enum_type,int average_enum_type){ISSMERROR("not implemented yet");}; 65 65 void InputToResult(int enum_type,int step,double time); 66 66 void ProcessResultsUnits(void); … … 96 96 void ScaleInput(int enum_type,double scale_factor); 97 97 void AXPYInput(int YEnum, double scalar, int XEnum); 98 void InputConvergence(int* enums,int num_enums,int* criterionenums,double* criterionvalues,int num_criterionenums); 98 99 void ControlConstrainInput(int control_type,double cm_min, double cm_max); 99 100 … … 106 107 void GetThicknessList(double* thickness_list); 107 108 void Du(Vec); 108 void Gradj( int control_type);109 void GradjDrag( void);110 void GradjB( void);109 void Gradj(Vec gradient,int control_type); 110 void GradjDrag(Vec gradient); 111 void GradjB(Vec gradient); 111 112 double Misfit(void); 112 113 double SurfaceArea(void); -
issm/trunk/src/c/objects/Elements/Tria.cpp
r4050 r4055 569 569 else ISSMERROR("%s%i%s\n","sub_analysis: ",sub_analysis_type," not supported yet"); 570 570 } 571 else if (analysis_type==Slope ComputeAnalysisEnum){571 else if (analysis_type==SlopeAnalysisEnum){ 572 572 UpdateInputsFromSolutionSlopeCompute( solution); 573 573 } … … 979 979 else ISSMERROR("%s%i%s\n","sub_analysis: ",sub_analysis_type," not supported yet"); 980 980 } 981 else if (analysis_type==Slope ComputeAnalysisEnum){981 else if (analysis_type==SlopeAnalysisEnum){ 982 982 CreateKMatrixSlopeCompute( Kgg); 983 983 } … … 2394 2394 else ISSMERROR("%s%i%s\n","sub_analysis: ",sub_analysis_type," not supported yet"); 2395 2395 } 2396 else if (analysis_type==Slope ComputeAnalysisEnum){2396 else if (analysis_type==SlopeAnalysisEnum){ 2397 2397 CreatePVectorSlopeCompute( pg); 2398 2398 } … … 4125 4125 /*}}}*/ 4126 4126 /*FUNCTION Tria::Gradj {{{1*/ 4127 void Tria::Gradj( int control_type){4127 void Tria::Gradj(Vec gradient,int control_type){ 4128 4128 4129 4129 /*inputs: */ … … 4137 4137 4138 4138 if (control_type==DragCoefficientEnum){ 4139 GradjDrag( );4139 GradjDrag(gradient); 4140 4140 } 4141 4141 else if (control_type==RheologyBEnum){ 4142 GradjB( );4142 GradjB(gradient); 4143 4143 } 4144 4144 else ISSMERROR("%s%i","control type not supported yet: ",control_type); … … 4146 4146 /*}}}*/ 4147 4147 /*FUNCTION Tria::GradjDrag {{{1*/ 4148 void Tria::GradjDrag( void){4148 void Tria::GradjDrag(Vec gradient){ 4149 4149 4150 4150 … … 4295 4295 4296 4296 4297 /*Add grade_g to the inputs of this element: */4298 this->inputs->AddInput(new TriaVertexInput(GradientEnum,&grade_g[0]));4297 /*Add grade_g to global vector gradient: */ 4298 VecSetValues(gradient,numgrids,doflist1,(const double*)grade_g,ADD_VALUES); 4299 4299 4300 4300 cleanup_and_return: … … 4308 4308 /*}}}*/ 4309 4309 /*FUNCTION Tria::GradjDragStokes {{{1*/ 4310 void Tria::GradjDragStokes( void){4310 void Tria::GradjDragStokes(Vec gradient){ 4311 4311 4312 4312 int i; … … 4465 4465 } 4466 4466 4467 /*Add grade_g to global vector gradient: */ 4468 VecSetValues(gradient,numgrids,doflist1,(const double*)grade_g,ADD_VALUES); 4469 4467 4470 /*Add grade_g to the inputs of this element: */ 4468 4471 this->inputs->AddInput(new TriaVertexInput(GradientEnum,&grade_g[0])); … … 4478 4481 /*}}}*/ 4479 4482 /*FUNCTION Tria::GradjB{{{1*/ 4480 void Tria::GradjB( void){4483 void Tria::GradjB(Vec gradient){ 4481 4484 4482 4485 int i; … … 4613 4616 } 4614 4617 4615 /*Add grade_g to the inputs of this element: */4616 this->inputs->AddInput(new TriaVertexInput(GradientEnum,&grade_g[0]));4618 /*Add grade_g to global vector gradient: */ 4619 VecSetValues(gradient,numgrids,doflist1,(const double*)grade_g,ADD_VALUES); 4617 4620 4618 4621 cleanup_and_return: … … 5014 5017 /*}}}*/ 5015 5018 /*FUNCTION Tria::DepthAverageInputAtBase {{{1*/ 5016 void Tria::DepthAverageInputAtBase(int enum_type ){5019 void Tria::DepthAverageInputAtBase(int enum_type,int average_enum_type){ 5017 5020 5018 5021 /*New input*/ … … 5026 5029 5027 5030 /*Assign new name (average)*/ 5028 switch(enum_type){ 5029 5030 case VxEnum: 5031 newinput->ChangeEnum(VxAverageEnum); 5032 break; 5033 5034 case VyEnum: 5035 newinput->ChangeEnum(VyAverageEnum); 5036 break; 5037 5038 default: 5039 ISSMERROR("enum_type: %i (%s) not suppoerted yet",enum_type,EnumAsString(enum_type)); 5040 } 5031 newinput->ChangeEnum(average_enum_type); 5041 5032 5042 5033 /*Add new input to current element*/ … … 5503 5494 } 5504 5495 /*}}}*/ 5496 /*FUNCTION Tria::InputConvergence(int* pconverged, double* eps, int* enums,int num_enums,int* criterionenums,double* criterionvalues,int num_criterionenums){{{1*/ 5497 void Tria::InputConvergence(int* pconverged,double* eps, int* enums,int num_enums,int* criterionenums,double* criterionvalues,int num_criterionenums){a 5498 5499 Input** new_inputs=NULL; 5500 Input** old_inputs=NULL; 5501 int converged=1; 5502 5503 new_inputs=(Input**)xmalloc(num_enums/2*sizeof(Input*)); //half the enums are for the new inputs 5504 old_inputs=(Input**)xmalloc(num_enums/2*sizeof(Input*)); //half the enums are for the old inputs 5505 5506 for(i=0;i<num_enums/2;i++){ 5507 new_inputs[i]=(Input*)this->inputs->GetInput(new_enums[2*i+0]); 5508 old_inputs[i]=(Input*)this->inputs->GetInput(old_enums[2*i+1]); 5509 if(!new_inputs[i])ISSMERROR("%s%s"," could not find input with enum ",EnumAsString(new_enums[2*i+0])); 5510 if(!old_inputs[i])ISSMERROR("%s%s"," could not find input with enum ",EnumAsString(old_enums[2*i+0])); 5511 } 5512 5513 /*ok, we've got the inputs (new and old), now loop throught the number of criterions and fill the eps array:*/ 5514 for(i=0;i<num_criterionenums;i++){ 5515 IsInputConverged(eps+i,new_inputs,old_inputs,num_enums/2,,criterionenums[i]); 5516 if(eps[i]>criterionvalues[i]) converged=0; 5517 } 5518 5519 /*Assign output pointers:*/ 5520 *pconverged=converged; 5521 5522 } 5523 /*}}}*/ -
issm/trunk/src/c/objects/Elements/Tria.h
r4050 r4055 55 55 int MyRank(void); 56 56 void SetClone(int* minranks); 57 void DepthAverageInputAtBase(int enum_type );57 void DepthAverageInputAtBase(int enum_type,int average_enum_type); 58 58 void* SpawnSing(int g0); 59 59 void* SpawnBeam(int g0, int g1); … … 88 88 void GetJacobian(double* J, double* xyz_list,double* gauss_l1l2l3); 89 89 void Du(Vec du_g); 90 void Gradj( int control_type);91 void GradjDrag( void);92 void GradjDragStokes( void);93 void GradjB( void);90 void Gradj(Vec gradient,int control_type); 91 void GradjDrag(Vec gradient); 92 void GradjDragStokes(Vec gradient); 93 void GradjB(Vec gradient); 94 94 void SurfaceNormal(double* surface_normal, double xyz_list[3][3]); 95 95 double Misfit(void); … … 142 142 void ScaleInput(int enum_type,double scale_factor); 143 143 void AXPYInput(int YEnum, double scalar, int XEnum); 144 void InputConvergence(int* enums,int num_enums,int* criterionenums,double* criterionvalues,int num_criterionenums); 144 145 void ControlConstrainInput(int control_type,double cm_min, double cm_max); 145 146 void GetVectorFromInputs(Vec vector,int NameEnum); -
issm/trunk/src/c/objects/FemModel.cpp
r4050 r4055 35 35 /*Dynamically allocate whatever is a list of length nummodels: */ 36 36 analysis_type_list=(int*)xmalloc(nummodels*sizeof(int)); 37 Rmg=(Mat*)xmalloc(nummodels*sizeof(Mat));38 Gmn=(Mat*)xmalloc(nummodels*sizeof(Mat));39 nodesets=(NodeSets**)xmalloc(nummodels*sizeof(NodeSets*));40 yg=(Vec*)xmalloc(nummodels*sizeof(Vec));41 ys=(Vec*)xmalloc(nummodels*sizeof(Vec));37 m_Rmg=(Mat*)xmalloc(nummodels*sizeof(Mat)); 38 m_Gmn=(Mat*)xmalloc(nummodels*sizeof(Mat)); 39 m_nodesets=(NodeSets**)xmalloc(nummodels*sizeof(NodeSets*)); 40 m_yg=(Vec*)xmalloc(nummodels*sizeof(Vec)); 41 m_ys=(Vec*)xmalloc(nummodels*sizeof(Vec)); 42 42 43 43 /*Initialize: */ 44 44 for(i=0;i<nummodels;i++)analysis_type_list[i]=analyses[i]; 45 for(i=0;i<nummodels;i++) Rmg[i]=NULL;46 for(i=0;i<nummodels;i++) Gmn[i]=NULL;47 for(i=0;i<nummodels;i++) nodesets[i]=NULL;48 for(i=0;i<nummodels;i++) yg[i]=NULL;49 for(i=0;i<nummodels;i++) ys[i]=NULL;45 for(i=0;i<nummodels;i++)m_Rmg[i]=NULL; 46 for(i=0;i<nummodels;i++)m_Gmn[i]=NULL; 47 for(i=0;i<nummodels;i++)m_nodesets[i]=NULL; 48 for(i=0;i<nummodels;i++)m_yg[i]=NULL; 49 for(i=0;i<nummodels;i++)m_ys[i]=NULL; 50 50 51 51 _printf_(" fill model with matlab workspace data\n"); … … 64 64 65 65 _printf_(" create single point constraints: \n"); 66 SpcNodesx( & yg[i], nodes,constraints,analysis_type);66 SpcNodesx( &m_yg[i], nodes,constraints,analysis_type); 67 67 68 68 _printf_(" create rigid body constraints:\n"); 69 MpcNodesx( & Rmg[i], nodes,constraints,analysis_type);69 MpcNodesx( &m_Rmg[i], nodes,constraints,analysis_type); 70 70 71 71 _printf_(" create node sets:\n"); 72 BuildNodeSetsx(& nodesets[i], nodes,analysis_type);72 BuildNodeSetsx(&m_nodesets[i], nodes,analysis_type); 73 73 74 74 _printf_(" reducing single point constraints vector:\n"); 75 Reducevectorgtosx(& ys[i], yg[i],nodesets[i]);75 Reducevectorgtosx(&m_ys[i], m_yg[i],m_nodesets[i]); 76 76 77 77 _printf_(" normalizing rigid body constraints matrix:\n"); 78 NormalizeConstraintsx(& Gmn[i], Rmg[i],nodesets[i]);78 NormalizeConstraintsx(&m_Gmn[i], m_Rmg[i],m_nodesets[i]); 79 79 80 80 _printf_(" configuring element and loads:\n"); … … 106 106 107 107 for(i=0;i<nummodels;i++){ 108 Mat temp_Rmg= Rmg[i];108 Mat temp_Rmg=m_Rmg[i]; 109 109 MatFree(&temp_Rmg); 110 Mat temp_Gmn= Gmn[i];110 Mat temp_Gmn=m_Gmn[i]; 111 111 MatFree(&temp_Gmn); 112 NodeSets* temp_nodesets= nodesets[i];113 delete nodesets;114 Vec temp_yg= yg[i];112 NodeSets* temp_nodesets=m_nodesets[i]; 113 delete temp_nodesets; 114 Vec temp_yg=m_yg[i]; 115 115 VecFree(&temp_yg); 116 Vec temp_ys= ys[i];116 Vec temp_ys=m_ys[i]; 117 117 VecFree(&temp_ys); 118 118 } 119 119 120 120 /*Delete dynamically allocated arrays: */ 121 delete Rmg;122 delete Gmn;123 delete nodesets;124 delete yg;125 delete ys;121 delete m_Rmg; 122 delete m_Gmn; 123 delete m_nodesets; 124 delete m_yg; 125 delete m_ys; 126 126 127 127 } … … 151 151 /*FUNCTION FemModel::SetCurrentAnalysis {{{1*/ 152 152 void FemModel::SetCurrentAnalysis(int analysis_type){ 153 153 154 int found=-1; 154 155 for(int i=0;i<nummodels;i++){ … … 160 161 if(found!=-1) analysis_counter=found; 161 162 else ISSMERROR("Could not find analysis_type %s in list of FemModel analyses",EnumAsString(analysis_type)); 163 164 /*activate matrices/vectors: */ 165 Rmg=m_Rmg[analysis_counter]; 166 Gmn=m_Gmn[analysis_counter]; 167 nodesets=m_nodesets[analysis_counter]; 168 yg=m_yg[analysis_counter]; 169 ys=m_ys[analysis_counter]; 170 171 } 172 /*}}}1*/ 173 /*FUNCTION FemModel::SetCurrentAnalysisAlias {{{1*/ 174 void FemModel::SetCurrentAnalysisAlias(int base_analysis_type,int real_analysis_type){ 175 int found=-1; 176 for(int i=0;i<nummodels;i++){ 177 if (analysis_type_list[i]==base_analysis_type){ 178 found=i; 179 break; 180 } 181 } 182 if(found!=-1) analysis_counter=found; 183 else ISSMERROR("Could not find alias for analysis_type %s in list of FemModel analyses",EnumAsString(base_analysis_type)); 162 184 } 163 185 /*}}}1*/ -
issm/trunk/src/c/objects/FemModel.h
r4050 r4055 40 40 DofVec* tpartition; 41 41 42 //multiple sets of matrices/vectors for each analysis_type 43 Mat* Rmg; //rigid body motions matrices 44 Mat* Gmn; 45 NodeSets** nodesets; //boundary conditions dof sets 46 Vec* yg; //boundary conditions in global g-set 47 Vec* ys; //boundary conditions, in reduced s-set 42 //multiple sets of matrices/vectors for each analysis_type. m stands for multiple 43 Mat* m_Rmg; //rigid body motions matrices 44 Mat* m_Gmn; 45 NodeSets** m_nodesets; //boundary conditions dof sets 46 Vec* m_yg; //boundary conditions in global g-set 47 Vec* m_ys; //boundary conditions, in reduced s-set 48 49 //pointers to point to sets of matrices/vectors, for a certain analysis type. activated in SetCurrentAnalysis 50 Mat Rmg; 51 Mat Gmn; 52 NodeSets* nodesets; 53 Vec yg; 54 Vec ys; 48 55 49 56 /*constructors, destructors: */ … … 56 63 /*Fem: */ 57 64 void SetCurrentAnalysis(int analysis_type); 65 void SetCurrentAnalysisAlias(int base_analysis_type,int real_analysis_type); 58 66 int GetCurrentAnalysis(void); 59 67 -
issm/trunk/src/c/objects/Inputs/BeamVertexInput.cpp
r4050 r4055 294 294 } 295 295 /*}}}*/ 296 /*FUNCTION BeamVertexInput::GetValuesPtr(double* pvalues,int* pnum_values);{{{1*/ 297 void BeamVertexInput::GetValuesPtr(double* pvalues,int* pnum_values){ 298 299 *pvalues=this->values; 300 *pnum_values=2; 301 302 } 303 /*}}}*/ -
issm/trunk/src/c/objects/Inputs/BeamVertexInput.h
r4050 r4055 78 78 void Constrain(double cm_min, double cm_max); 79 79 void GetVectorFromInputs(Vec vector,int* doflist); 80 void GetValuesPtr(double* pvalues,int* pnum_values); 80 81 /*}}}*/ 81 82 -
issm/trunk/src/c/objects/Inputs/BoolInput.cpp
r4050 r4055 256 256 } 257 257 /*}}}*/ 258 /*FUNCTION BoolInput::GetValuesPtr(double* pvalues,int* pnum_values);{{{1*/ 259 void BoolInput::GetValuesPtr(double* pvalues,int* pnum_values){ 260 261 ISSMERROR(" not supported yet!"); 262 263 } 264 /*}}}*/ -
issm/trunk/src/c/objects/Inputs/BoolInput.h
r4050 r4055 78 78 void Constrain(double cm_min, double cm_max); 79 79 void GetVectorFromInputs(Vec vector,int* doflist); 80 void GetValuesPtr(double* pvalues,int* pnum_values); 80 81 /*}}}*/ 81 82 -
issm/trunk/src/c/objects/Inputs/DoubleInput.cpp
r4050 r4055 267 267 } 268 268 /*}}}*/ 269 /*FUNCTION DoubleInput::GetValuesPtr(double* pvalues,int* pnum_values);{{{1*/ 270 void DoubleInput::GetValuesPtr(double* pvalues,int* pnum_values){ 271 272 ISSMERROR(" not supported yet!"); 273 274 } 275 /*}}}*/ -
issm/trunk/src/c/objects/Inputs/DoubleInput.h
r4050 r4055 79 79 void Constrain(double cm_min, double cm_max); 80 80 void GetVectorFromInputs(Vec vector,int* doflist); 81 void GetValuesPtr(double* pvalues,int* pnum_values); 81 82 /*}}}*/ 82 83 -
issm/trunk/src/c/objects/Inputs/Input.h
r4050 r4055 55 55 virtual void Constrain(double cm_min, double cm_max)=0; 56 56 virtual void GetVectorFromInputs(Vec vector,int* doflist)=0; 57 virtual void GetValuesPtr(double* pvalues,int* pnum_values)=0; 57 58 /*}}}*/ 58 59 -
issm/trunk/src/c/objects/Inputs/IntInput.cpp
r4050 r4055 257 257 } 258 258 /*}}}*/ 259 /*FUNCTION IntInput::GetValuesPtr(double* pvalues,int* pnum_values);{{{1*/ 260 void IntInput::GetValuesPtr(double* pvalues,int* pnum_values){ 261 262 ISSMERROR(" not supported yet!"); 263 264 } 265 /*}}}*/ -
issm/trunk/src/c/objects/Inputs/IntInput.h
r4050 r4055 78 78 void Constrain(double cm_min, double cm_max); 79 79 void GetVectorFromInputs(Vec vector,int* doflist); 80 void GetValuesPtr(double* pvalues,int* pnum_values); 80 81 /*}}}*/ 81 82 -
issm/trunk/src/c/objects/Inputs/PentaVertexInput.cpp
r4050 r4055 943 943 } 944 944 /*}}}*/ 945 /*FUNCTION PentaVertexInput::GetValuesPtr(double* pvalues,int* pnum_values);{{{1*/ 946 void PentaVertexInput::GetValuesPtr(double* pvalues,int* pnum_values){ 947 948 *pvalues=this->values; 949 *pnum_values=6; 950 951 } 952 /*}}}*/ -
issm/trunk/src/c/objects/Inputs/PentaVertexInput.h
r4050 r4055 87 87 void Constrain(double cm_min, double cm_max); 88 88 void GetVectorFromInputs(Vec vector,int* doflist); 89 void GetValuesPtr(double* pvalues,int* pnum_values); 89 90 /*}}}*/ 90 91 -
issm/trunk/src/c/objects/Inputs/SingVertexInput.cpp
r4050 r4055 258 258 259 259 } 260 /*}}}*/ 260 /2*}}}*/ 261 /*FUNCTION SingVertexInput::GetValuesPtr(double* pvalues,int* pnum_values);{{{1*/ 262 void SingVertexInput::GetValuesPtr(double* pvalues,int* pnum_values){ 263 264 *pvalues=&this->value; 265 *pnum_values=1; 266 267 } 268 /*}}}*/ -
issm/trunk/src/c/objects/Inputs/SingVertexInput.h
r4050 r4055 77 77 void Constrain(double cm_min, double cm_max); 78 78 void GetVectorFromInputs(Vec vector,int* doflist); 79 void GetValuesPtr(double* pvalues,int* pnum_values); 79 80 /*}}}*/ 80 81 -
issm/trunk/src/c/objects/Inputs/TriaVertexInput.cpp
r4050 r4055 517 517 } 518 518 /*}}}*/ 519 /*FUNCTION TriaVertexInput::GetValuesPtr(double* pvalues,int* pnum_values);{{{1*/ 520 void TriaVertexInput::GetValuesPtr(double* pvalues,int* pnum_values){ 521 522 *pvalues=this->values; 523 *pnum_values=3; 524 525 } 526 /*}}}*/ -
issm/trunk/src/c/objects/Inputs/TriaVertexInput.h
r4050 r4055 84 84 void Constrain(double cm_min, double cm_max); 85 85 void GetVectorFromInputs(Vec vector,int* doflist); 86 void GetValuesPtr(double* pvalues,int* pnum_values); 86 87 /*}}}*/ 87 88 -
issm/trunk/src/c/objects/Node.cpp
r4021 r4055 144 144 analysis_type==PrognosticAnalysisEnum || 145 145 analysis_type==MeltingAnalysisEnum || 146 analysis_type==Slope ComputeAnalysisEnum ||146 analysis_type==SlopeAnalysisEnum || 147 147 analysis_type==BalancedvelocitiesAnalysisEnum || 148 148 analysis_type==BalancedthicknessAnalysisEnum … … 668 668 } 669 669 /*}}}*/ 670 /*FUNCTION Node:: FieldExtrude {{{2*/671 void Node:: FieldExtrude(Vec field,double* field_serial,char* field_name){670 /*FUNCTION Node::VecExtrude {{{2*/ 671 void Node::VecExtrude(Vec vector,double* vector_serial){ 672 672 673 673 /* node data: */ … … 684 684 if (onbed){ 685 685 686 if (strcmp(field_name,"velocity")==0){ 687 688 /* node data: */ 689 int vertexdof; 690 int doflist[2]; 691 double fieldnode[2]; 692 693 vertexdof=GetVertexDof(); 694 695 /*get dofs for this base node velocity: we know there are two dofs in field_serial */ 696 doflist[0]=2*vertexdof; 697 doflist[1]=2*vertexdof+1; 698 699 //initilaize node 700 node=this; 701 702 /*get field for this base node: */ 703 fieldnode[0]=field_serial[doflist[0]]; 704 fieldnode[1]=field_serial[doflist[1]]; 705 706 //go through all nodes which sit on top of this node, until we reach the surface, 707 //and plfield field in field 708 for(;;){ 709 710 vertexdof=node->GetVertexDof(); 711 doflist[0]=2*vertexdof; 712 doflist[1]=2*vertexdof+1; 713 VecSetValues(field,1,&doflist[0],&fieldnode[0],INSERT_VALUES); 714 VecSetValues(field,1,&doflist[1],&fieldnode[1],INSERT_VALUES); 715 716 if (node->IsOnSurface())break; 717 /*get next node: */ 718 node=node->GetUpperNode(); 719 } 720 } //if (strcmp(field_name,"velocity")==0) 721 else if (strcmp(field_name,"gradj")==0){ 722 723 /* node data: */ 724 int dof1; 725 double fieldel; 726 727 //initilaize node and get dof1 728 node=this; 686 /* node data: */ 687 int dof1; 688 double vectorel; 689 690 //initilaize node and get dof1 691 node=this; 692 dof1=node->GetVertexDof(); 693 694 /*get vector for this base node: */ 695 vectorel=vector_serial[dof1]; 696 697 //go throvectorn all nodes which sit on top of this node, until we reach the surface, 698 //and plvector vector in vector 699 for(;;){ 700 729 701 dof1=node->GetVertexDof(); 730 731 /*get field for this base node: */ 732 fieldel=field_serial[dof1]; 733 734 //go throfieldn all nodes which sit on top of this node, until we reach the surface, 735 //and plfield field in field 736 for(;;){ 737 738 dof1=node->GetVertexDof(); 739 VecSetValues(field,1,&dof1,&fieldel,INSERT_VALUES); 740 741 if (node->IsOnSurface())break; 742 /*get next node: */ 743 node=node->GetUpperNode(); 744 } 745 } 746 else if ( 747 (strcmp(field_name,"vx")==0) || 748 (strcmp(field_name,"vy")==0) || 749 (strcmp(field_name,"thickness")==0) || 750 (strcmp(field_name,"temperature")==0) || 751 (strcmp(field_name,"surface")==0) || 752 (strcmp(field_name,"bed")==0) || 753 (strcmp(field_name,"slopex")==0) || 754 (strcmp(field_name,"slopey")==0) 755 ){ 756 757 /* node data: */ 758 int doflist; 759 int nodedofs; 760 double fieldnode; 761 762 GetDofList(&doflist,&numberofdofspernode); 763 764 //initialize node 765 node=this; 766 767 /*get field for this bed node: */ 768 fieldnode=field_serial[doflist]; 769 770 //go through all nodes which sit on top of this node, until we reach the surface, 771 //and plug fieldnode in field: 772 for(;;){ 773 774 node->GetDofList(&nodedofs,&numberofdofspernode); 775 VecSetValues(field,1,&nodedofs,&fieldnode,INSERT_VALUES); 776 777 if (node->IsOnSurface())break; 778 /*get next node: */ 779 node=node->GetUpperNode(); 780 } 781 } 782 else ISSMERROR("%s%s%s"," field ",field_name," not supported yet!"); 783 784 } //if (extrude) 702 VecSetValues(vector,1,&dof1,&vectorel,INSERT_VALUES); 703 704 if (node->IsOnSurface())break; 705 /*get next node: */ 706 node=node->GetUpperNode(); 707 } 708 } 785 709 } 786 710 /*}}}*/ -
issm/trunk/src/c/objects/Node.h
r4043 r4055 89 89 int IsOnShelf(); 90 90 int IsOnSheet(); 91 void FieldExtrude(Vec field,double* field_serial,char* field_name);91 void VecExtrude(Vec vector,double* vector_serial); 92 92 /*}}}*/ 93 93 /*FUNCTION DofObject routines {{{1*/ -
issm/trunk/src/c/shared/Dofs/DistributeNumDofs.cpp
r4021 r4055 25 25 numdofs=2; 26 26 } 27 else if (analysis_type==Slope ComputeAnalysisEnum){27 else if (analysis_type==SlopeAnalysisEnum){ 28 28 numdofs=1; 29 29 } -
issm/trunk/src/c/shared/Numerics/numerics.h
r3775 r4055 8 8 #include "./GaussPoints.h" 9 9 #include "./isnan.h" 10 class Input; 10 11 11 12 struct OptArgs; … … 18 19 void cross(double* result,double* vector1,double* vector2); 19 20 double norm(double* vector); 21 void IsInputConverged(double* peps, Input** new_inputs,Input** old_inputs,int num_inputs,int criterion_enum); 20 22 21 23 #endif //ifndef _NUMERICS_H_ -
issm/trunk/src/c/solutions/adjoint_core.cpp
r4047 r4055 20 20 char* solverstring=NULL; 21 21 bool isstokes=false; 22 bool conserve_loads=true; 22 23 23 24 /*intermediary: */ … … 38 39 39 40 /*set analysis type to compute velocity: */ 40 if(isstokes)femmodel->Set Analysis(DiagnosticAnalysisEnum,DiagnosticStokesAnalysisEnum);41 else femmodel->Set Analysis(DiagnosticAnalysisEnum,DiagnosticHorizAnalysisEnum);41 if(isstokes)femmodel->SetCurrentAnalysis(DiagnosticStokesAnalysisEnum); 42 else femmodel->SetCurrentAnalysis(DiagnosticHorizAnalysisEnum); 42 43 43 44 _printf_("%s\n"," recover solution for this stiffness and right hand side:"); 44 solver_diagnostic_nonlinear(NULL,&K_ff0,&K_fs0, NULL, femmodel,DiagnosticAnalysisEnum,sub_analysis_type);45 solver_diagnostic_nonlinear(NULL,&K_ff0,&K_fs0, femmodel,conserve_loads); 45 46 46 47 _printf_("%s\n"," buid Du, difference between observed velocity and model velocity:"); 47 Dux( du_g, femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);48 Dux(&du_g, femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters); 48 49 49 50 _printf_("%s\n"," reduce adjoint load from g-set to f-set:"); … … 66 67 67 68 /*Update inputs using adjoint solution, and same type of setup as diagnostic solution: */ 68 if(isstokes)femmodel->Set AnalysisAlias(DiagnosticAnalysisEnum,DiagnosticStokesAnalysisEnum,AdjointAnalysisEnum,NoneAnalysisEnum);69 else femmodel->Set AnalysisAlias(DiagnosticAnalysisEnum,DiagnosticHorizAnalysisEnum,AdjointAnalysisEnum,NoneAnalysisEnum);69 if(isstokes)femmodel->SetCurrentAnalysisAlias(DiagnosticStokesAnalysisEnum,AdjointAnalysisEnum); 70 else femmodel->SetCurrentAnalysisAlias(DiagnosticHorizAnalysisEnum,AdjointAnalysisEnum); 70 71 71 UpdateInputsFromSolutionx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,adjoint_g ,AdjointAnalysisEnum, NoneAnalysisEnum);72 UpdateInputsFromSolutionx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,adjoint_g); 72 73 73 74 /*Free ressources:*/ 74 char* solverstring=NULL;75 VecFree(&u g);75 xfree((void**)&solverstring); 76 VecFree(&u_g); 76 77 MatFree(&K_ff0); 77 MatFree(& MatK_fs0);78 MatFree(&K_fs0); 78 79 VecFree(&du_g); 79 80 VecFree(&du_f); -
issm/trunk/src/c/solutions/balancedthickness.cpp
r3938 r4055 22 22 char* inputfilename=NULL; 23 23 char* outputfilename=NULL; 24 bool qmu_analysis=false; 24 25 char* lockname=NULL; 25 int numberofnodes;26 26 bool waitonlock=false; 27 27 28 Model* model=NULL; 29 30 double dt; 31 double yts; 32 bool qmu_analysis; 33 34 /*Results: */ 35 Results* results=NULL; 36 Param* param=NULL; 28 /*FemModel: */ 29 FemModel* femmodel=NULL; 37 30 38 31 /*time*/ … … 40 33 double start_core, finish_core; 41 34 double start_init, finish_init; 35 36 int analyses[1]={BalancedthicknessAnalysisEnum}; 37 int solution_type=BalancedthicknessAnalysisEnum; 42 38 43 39 MODULEBOOT(); … … 66 62 fid=pfopen(inputfilename,"rb"); 67 63 68 /*Initialize model structure: */69 model=new Model();64 _printf_("create finite element model:\n"); 65 femmodel=new FemModel(fid,solution_type,analyses,1); 70 66 71 _printf_("read and create finite element model:\n"); 72 model->AddFormulation(fid,BalancedthicknessAnalysisEnum); 73 74 /*recover parameters: */ 75 model->FindParam(&waitonlock,WaitOnLockEnum); 76 model->FindParam(&qmu_analysis,QmuAnalysisEnum); 67 /*add outputfilename in parameters: */ 68 femmodel->parameters->AddObject(new StringParam(OutputFileNameEnum,outputfilename); 69 70 /*get parameters: */ 71 femmodel->parameters->FindParam(&qmu_analysis,QmuAnalysisEnum); 72 femmodel->parameters->FindParam(&control_analysis,ControlAnalysisEnum); 73 femmodel->parameters->FindParam(&waitonlock,WaitOnLockEnum); 77 74 78 75 MPI_Barrier(MPI_COMM_WORLD); finish_init=MPI_Wtime(); … … 84 81 _printf_("call computational core:\n"); 85 82 MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( ); 86 results=balancedthickness_core(model);83 balancedthickness_core(model); 87 84 MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( ); 85 86 _printf_("write results to disk:\n"); 87 OutputResults(femmodel->elements, femmodel->loads, femmodel->nodes, femmodel->vertices, femmodel->materials, femmodel->parameters, outputfilename); 88 } 88 89 89 90 } … … 95 96 #ifdef _HAVE_DAKOTA_ 96 97 MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( ); 97 Qmux( model,BalancedthicknessAnalysisEnum,NoneAnalysisEnum);98 Qmux(femmodel,BalancedthicknessAnalysisEnum,NoneAnalysisEnum); 98 99 MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( ); 99 100 #else … … 101 102 #endif 102 103 } 103 104 _printf_("write results to disk:\n");105 OutputResults(results,outputfilename);106 104 107 105 if (waitonlock>0){ … … 111 109 112 110 /*Free ressources:*/ 113 delete results; 114 delete model; 111 delete femmodel; 115 112 116 113 /*Get finish time and close*/ -
issm/trunk/src/c/solutions/balancedthickness2.cpp
r3938 r4055 23 23 char* inputfilename=NULL; 24 24 char* outputfilename=NULL; 25 bool qmu_analysis=false; 25 26 char* lockname=NULL; 26 27 bool waitonlock=false; 27 28 28 Model* model=NULL; 29 30 double dt; 31 double yts; 32 bool qmu_analysis; 33 34 /*Results: */ 35 Results* results=NULL; 36 Result* result=NULL; 37 38 Param* param=NULL; 29 /*FemModel: */ 30 FemModel* femmodel=NULL; 39 31 40 32 /*time*/ … … 42 34 double start_core, finish_core; 43 35 double start_init, finish_init; 36 37 int analyses[1]={Balancedthickness2AnalysisEnum}; 38 int solution_type=Balancedthickness2AnalysisEnum; 39 44 40 45 41 MODULEBOOT(); … … 68 64 fid=pfopen(inputfilename,"rb"); 69 65 70 /*Initialize model structure: */71 model=new Model();66 _printf_("create finite element model:\n"); 67 femmodel=new FemModel(fid,solution_type,analyses,1); 72 68 73 _printf_("read and create finite element model:\n"); 74 model->AddFormulation(fid,Balancedthickness2AnalysisEnum); 75 76 /*recover parameters: */ 77 model->FindParam(&waitonlock,WaitOnLockEnum); 78 model->FindParam(&qmu_analysis,QmuAnalysisEnum); 69 /*add outputfilename in parameters: */ 70 femmodel->parameters->AddObject(new StringParam(OutputFileNameEnum,outputfilename); 79 71 80 72 MPI_Barrier(MPI_COMM_WORLD); finish_init=MPI_Wtime(); … … 86 78 _printf_("call computational core:\n"); 87 79 MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( ); 88 results=balancedthickness2_core(model);80 balancedthickness2_core(femmodel); 89 81 MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( ); 82 83 _printf_("write results to disk:\n"); 84 OutputResults(femmodel->elements, femmodel->loads, femmodel->nodes, femmodel->vertices, femmodel->materials, femmodel->parameters, outputfilename); 90 85 91 86 } … … 97 92 #ifdef _HAVE_DAKOTA_ 98 93 MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( ); 99 Qmux( model,Balancedthickness2AnalysisEnum,NoneAnalysisEnum);94 Qmux(femmodel,Balancedthickness2AnalysisEnum,NoneAnalysisEnum); 100 95 MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( ); 101 96 #else … … 103 98 #endif 104 99 } 105 106 _printf_("write results to disk:\n");107 OutputResults(results,outputfilename);108 100 109 101 if (waitonlock>0){ … … 113 105 114 106 /*Free ressources:*/ 115 delete results; 116 delete model; 107 delete femmodel; 117 108 118 109 /*Get finish time and close*/ -
issm/trunk/src/c/solutions/balancedthickness2_core.cpp
r4043 r4055 12 12 #include "../solvers/solvers.h" 13 13 14 Results* balancedthickness2_core(Model* model){ 15 16 extern int my_rank; 17 18 /*output: */ 19 Results* results=NULL; 20 Result* result=NULL; 21 22 /*intermediary: */ 23 Vec vx_g=NULL; 24 Vec vy_g=NULL; 25 26 /*solutions: */ 27 Vec h_g=NULL; 14 void balancedthickness2_core(FemModel* femmodel){ 28 15 29 16 /*flags: */ 30 17 int verbose=0; 31 int numberofdofspernode; 32 int numberofnodes; 33 int numberofvertices; 34 int dofs[1]={1}; 18 int dim; 35 19 36 /*fem balancedthickness2 model: */ 37 FemModel* fem_p=NULL; 38 39 //initialize results: 40 results=new Results(); 41 42 fem_p=model->GetFormulation(Balancedthickness2AnalysisEnum); 43 44 //first recover parameters common to all solutions 45 model->FindParam(&verbose,VerboseEnum); 46 model->FindParam(&numberofnodes,NumberOfNodesEnum); 47 model->FindParam(&numberofvertices,NumberOfVerticesEnum); 48 model->FindParam(&numberofdofspernode,NumberOfDofsPerNodeEnum); 20 /*activate formulation: */ 21 femmodel->SetCurrentAnalysis(BalancedthicknessAnalysisEnum); 22 23 /*recover parameters: */ 24 femmodel->parameters->FindParam(&verbose,VerboseEnum); 25 femmodel->parameters->FindParam(&dim,DimEnum); 49 26 50 27 _printf_("depth averaging velocity...\n"); 51 //vx_g=inputs->Get("vx",&dofs[0],1); 52 //vy_g=inputs->Get("vy",&dofs[0],1); 53 /* NOT WORKING YET.... 54 FieldDepthAveragex(vx_g, fem_p->elements,fem_p->nodes, fem_p->vertices,fem_p->loads, fem_p->materials,fem_p->parameters,"vx"); 55 FieldDepthAveragex(vy_g, fem_p->elements,fem_p->nodes, fem_p->vertices,fem_p->loads, fem_p->materials,fem_p->parameters,"vy"); 56 */ 57 //inputs->Add("vx_average",vx_g,1,numberofvertices); 58 //inputs->Add("vy_average",vy_g,1,numberofvertices); 59 ISSMERROR("not supported yet!"); 60 28 DepthAverageInputx(femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters,VxEnum); 29 DepthAverageInputx(femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters,VyEnum); 30 if(dim==3) DepthAverageInputx(femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters,VzEnum); 31 32 61 33 _printf_("call computational core:\n"); 62 diagnostic_core_linear(&h_g,fem_p,Balancedthickness2AnalysisEnum,NoneAnalysisEnum);34 solver_linear(NULL,femmodel); 63 35 64 36 _printf_("Averaging over vertices:\n"); 65 FieldAverageOntoVerticesx(&h_g,fem_p->elements,fem_p->nodes,fem_p->vertices,fem_p->loads,fem_p->materials,fem_p->parameters); 37 ISSMERROR(" not supported yet!"); 38 //FieldAverageOntoVerticesx(&h_g,fem_p->elements,fem_p->nodes,fem_p->vertices,fem_p->loads,fem_p->materials,fem_p->parameters); 66 39 67 40 // _printf_("extrude computed thickness on all layers:\n"); 68 41 // FieldExtrudex( h_g, fem_p->elements,fem_p->nodes, fem_p->vertices,fem_p->loads, fem_p->materials,fem_p->parameters,"thickness",0); 69 42 70 /*Plug results into output dataset: */ 71 InputToResultx(&result,fem_p->elements,fem_p->nodes,fem_p->vertices, fem_p->loads, fem_p->materials,fem_p->parameters,ThicknessEnum,results->Size()+1,0,1); results->AddObject(result); 72 results->AddObject(new StringResult(results->Size()+1,AnalysisTypeEnum,0,1,EnumAsString(Balancedthickness2AnalysisEnum))); 73 74 /*Free ressources:*/ 75 VecFree(&vx_g); 76 VecFree(&vy_g); 77 VecFree(&h_g); 78 79 /*return: */ 80 return results; 43 if(verbose)_printf_("saving results:\n"); 44 InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,ThicknessEnum); 81 45 82 46 } -
issm/trunk/src/c/solutions/balancedthickness_core.cpp
r4043 r4055 12 12 #include "../solvers/solvers.h" 13 13 14 Results* balancedthickness_core(Model*model){14 void balancedthickness_core(FemModel* femmodel){ 15 15 16 extern int my_rank; 16 /*parameters: */ 17 int verbose=0; 18 int dim; 17 19 18 /*output: */ 19 Results* results=NULL; 20 Result* result=NULL; 21 22 /*intermediary: */ 23 Vec u_g=NULL; 24 25 /*solutions: */ 26 Vec h_g=NULL; 27 28 /*flags: */ 29 int verbose=0; 30 int numberofdofspernode; 31 int numberofnodes; 32 int dofs[2]={1,1}; 33 34 /*fem balancedthickness model: */ 35 FemModel* fem_p=NULL; 36 37 //initialize results: 38 results=new Results(); 39 40 /*recover fem model: */ 41 fem_p=model->GetFormulation(BalancedthicknessAnalysisEnum); 42 43 //first recover parameters common to all solutions 44 model->FindParam(&verbose,VerboseEnum); 45 model->FindParam(&numberofnodes,NumberOfNodesEnum); 46 model->FindParam(&numberofdofspernode,NumberOfDofsPerNodeEnum); 20 /*activate formulation: */ 21 femmodel->SetCurrentAnalysis(BalancedthicknessAnalysisEnum); 22 23 /*recover parameters: */ 24 femmodel->parameters->FindParam(&verbose,VerboseEnum); 25 femmodel->parameters->FindParam(&dim,DimEnum); 47 26 48 27 _printf_("depth averaging velocity...\n"); 49 //u_g=inputs->Get("velocity",&dofs[0],2); //take (vx,vy) from inputs velocity 50 //FieldDepthAveragex( u_g, fem_p->elements,fem_p->nodes, fem_p->vertices,fem_p->loads, fem_p->materials,fem_p->parameters,"velocity"); 51 //inputs->Add("velocity_average",u_g,2,numberofnodes); 52 ISSMERROR("not supported yet!"); 53 28 DepthAverageInputx(femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters,VxEnum); 29 DepthAverageInputx(femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters,VyEnum); 30 if(dim==3) DepthAverageInputx(femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters,VzEnum); 31 54 32 _printf_("call computational core:\n"); 55 diagnostic_core_linear(&h_g,fem_p,BalancedthicknessAnalysisEnum,NoneAnalysisEnum);33 solver_linear(NULL,femmodel); 56 34 57 35 _printf_("extrude computed thickness on all layers:\n"); 58 FieldExtrudex( h_g, fem_p->elements,fem_p->nodes, fem_p->vertices,fem_p->loads, fem_p->materials,fem_p->parameters,"thickness",0);36 ExtrudeInputx(femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters,ThicknessEnum); 59 37 60 /*Plug results into output dataset: */ 61 InputToResultx(&result,fem_p->elements,fem_p->nodes,fem_p->vertices, fem_p->loads, fem_p->materials,fem_p->parameters,ThicknessEnum,results->Size()+1,0,1); results->AddObject(result); 62 results->AddObject(new StringResult(results->Size()+1,AnalysisTypeEnum,0,1,EnumAsString(BalancedthicknessAnalysisEnum))); 63 64 /*Free ressources:*/ 65 VecFree(&u_g); 66 VecFree(&h_g); 67 68 /*return: */ 69 return results; 38 if(verbose)_printf_("saving results:\n"); 39 InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,ThicknessEnum); 70 40 71 41 } -
issm/trunk/src/c/solutions/balancedvelocities.cpp
r3938 r4055 23 23 char* inputfilename=NULL; 24 24 char* outputfilename=NULL; 25 bool qmu_analysis; 25 26 char* lockname=NULL; 26 int numberofnodes;27 27 bool waitonlock=false; 28 28 29 Model* model=NULL; 30 31 bool qmu_analysis; 32 33 /*Results: */ 34 Results* results=NULL; 35 Result* result=NULL; 36 Param* param=NULL; 29 /*FemModel: */ 30 FemModel* femmodel=NULL; 37 31 38 32 /*time*/ … … 40 34 double start_core, finish_core; 41 35 double start_init, finish_init; 36 37 int analyses[1]={BalancedvelocitiesAnalysisEnum}; 38 int solution_type=BalancedvelocitiesAnalysisEnum; 42 39 43 40 MODULEBOOT(); … … 66 63 fid=pfopen(inputfilename,"rb"); 67 64 68 /*Initialize model structure: */69 model=new Model();65 _printf_("create finite element model:\n"); 66 femmodel=new FemModel(fid,solution_type,analyses,1); 70 67 71 _printf_("read and create finite element model:\n"); 72 model->AddFormulation(fid,BalancedvelocitiesAnalysisEnum); 73 74 /*recover parameters: */ 75 model->FindParam(&waitonlock,WaitOnLockEnum); 76 model->FindParam(&qmu_analysis,QmuAnalysisEnum); 68 /*add outputfilename in parameters: */ 69 femmodel->parameters->AddObject(new StringParam(OutputFileNameEnum,outputfilename); 70 71 /*get parameters: */ 72 femmodel->parameters->FindParam(&qmu_analysis,QmuAnalysisEnum); 73 femmodel->parameters->FindParam(&control_analysis,ControlAnalysisEnum); 74 femmodel->parameters->FindParam(&waitonlock,WaitOnLockEnum); 77 75 78 76 MPI_Barrier(MPI_COMM_WORLD); finish_init=MPI_Wtime(); … … 84 82 _printf_("call computational core:\n"); 85 83 MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( ); 86 results=balancedvelocities_core(model);84 balancedvelocities_core(femmodel); 87 85 MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( ); 86 87 _printf_("write results to disk:\n"); 88 OutputResults(femmodel->elements, femmodel->loads, femmodel->nodes, femmodel->vertices, femmodel->materials, femmodel->parameters, outputfilename); 88 89 89 90 } … … 95 96 #ifdef _HAVE_DAKOTA_ 96 97 MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( ); 97 Qmux( model,BalancedvelocitiesAnalysisEnum,NoneAnalysisEnum);98 Qmux(femmodel,BalancedvelocitiesAnalysisEnum,NoneAnalysisEnum); 98 99 MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( ); 99 100 #else … … 101 102 #endif 102 103 } 103 104 _printf_("write results to disk:\n");105 OutputResults(results,outputfilename);106 104 107 105 if (waitonlock>0){ … … 111 109 112 110 /*Free ressources:*/ 113 delete results; 114 delete model; 111 delete femmodel; 115 112 116 113 /*Get finish time and close*/ -
issm/trunk/src/c/solutions/balancedvelocities_core.cpp
r4043 r4055 11 11 #include "../solvers/solvers.h" 12 12 13 Results* balancedvelocities_core(Model* model){ 14 15 extern int my_rank; 16 17 /*output: */ 18 Results* results=NULL; 19 Result* result=NULL; 20 21 /*intermediary: */ 22 Vec u_g=NULL; 23 24 /*solutions: */ 25 Vec v_g=NULL; 13 void balancedvelocities_core(FemModel* femmodel){ 26 14 27 15 /*flags: */ 28 16 int verbose=0; 29 int numberofdofspernode; 30 int numberofnodes; 31 int dofs[2]={1,1}; 17 int dim; 32 18 33 /*fem balancedvelocities model: */ 34 FemModel* fem_p=NULL; 35 36 //initialize results: 37 results=new Results(); 38 39 /*recover fem model: */ 40 fem_p=model->GetFormulation(BalancedvelocitiesAnalysisEnum); 41 42 //first recover parameters common to all solutions 43 model->FindParam(&verbose,VerboseEnum); 44 model->FindParam(&numberofnodes,NumberOfNodesEnum); 45 model->FindParam(&numberofdofspernode,NumberOfDofsPerNodeEnum); 19 /*activate formulation: */ 20 femmodel->SetCurrentAnalysis(BalancedvelocitiesAnalysisEnum); 21 22 /*recover parameters: */ 23 femmodel->parameters->FindParam(&verbose,VerboseEnum); 24 femmodel->parameters->FindParam(&dim,DimEnum); 46 25 47 26 _printf_("depth averaging velocity...\n"); 48 //u_g=inputs->Get("velocity",&dofs[0],2); //take (vx,vy) from inputs velocity 49 //FieldDepthAveragex( u_g, fem_p->elements,fem_p->nodes, fem_p->vertices,fem_p->loads, fem_p->materials,fem_p->parameters,"velocity"); 50 //inputs->Add("velocity_average",u_g,2,numberofnodes); 51 ISSMERROR(" not supported yet!"); 52 27 DepthAverageInputx(femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters,VxEnum); 28 DepthAverageInputx(femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters,VyEnum); 29 if(dim==3) DepthAverageInputx(femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters,VzEnum); 30 53 31 _printf_("call computational core:\n"); 54 diagnostic_core_linear(&v_g,fem_p,BalancedvelocitiesAnalysisEnum,NoneAnalysisEnum);32 solver_linear(NULL,femmodel); 55 33 56 _printf_("extrude computed thickness on all layers:\n"); 57 FieldExtrudex( v_g, fem_p->elements,fem_p->nodes, fem_p->vertices,fem_p->loads, fem_p->materials,fem_p->parameters,"thickness",0); 34 _printf_("extrude computed velocity on all layers:\n"); 35 ExtrudeInputx(femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters,VxEnum); 36 ExtrudeInputx(femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters,VyEnum); 58 37 59 /*Plug results into output dataset: */ 60 InputToResultx(&result,fem_p->elements,fem_p->nodes,fem_p->vertices, fem_p->loads, fem_p->materials,fem_p->parameters,VxEnum,results->Size()+1,0,1); results->AddObject(result); 61 InputToResultx(&result,fem_p->elements,fem_p->nodes,fem_p->vertices, fem_p->loads, fem_p->materials,fem_p->parameters,VyEnum,results->Size()+1,0,1); results->AddObject(result); 62 results->AddObject(new StringResult(results->Size()+1,AnalysisTypeEnum,0,1,EnumAsString(BalancedvelocitiesAnalysisEnum))); 38 if(verbose)_printf_("saving results:\n"); 39 InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VxEnum); 40 InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VyEnum); 63 41 64 /*Free ressources:*/65 VecFree(&u_g);66 VecFree(&v_g);67 68 /*return: */69 return results;70 42 } -
issm/trunk/src/c/solutions/bedslope.cpp
r4030 r4055 37 37 double start_init, finish_init; 38 38 39 int analyses[1]={ BedSlopeComputeAnalysisEnum};40 int solution_type= BedSlopeComputeSolutionEnum;39 int analyses[1]={SlopeAnalysisEnum}; 40 int solution_type=SlopeAnalysisEnum; 41 41 42 42 MODULEBOOT(); … … 67 67 _printf_("create finite element model, using analyses types statically defined above:\n"); 68 68 femmodel=new FemModel(fid,solution_type,analyses,1); 69 70 /*add outputfilename in parameters: */ 71 femmodel->parameters->AddObject(new StringParam(OutputFileNameEnum,outputfilename)); 69 72 70 73 /*get parameters: */ … … 83 86 84 87 _printf_("write results to disk:\n"); 85 OutputResults(femmodel ,outputfilename,DiagnosticAnalysisEnum);88 OutputResults(femmodel->elements, femmodel->loads, femmodel->nodes, femmodel->vertices, femmodel->materials, femmodel->parameters); 86 89 } 87 90 else{ … … 92 95 #ifdef _HAVE_DAKOTA_ 93 96 MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( ); 94 Qmux(femmodel, SlopeComputeAnalysisEnum,NoneAnalysisEnum);97 Qmux(femmodel,BedSlopeAnalysisEnum,NoneAnalysisEnum); 95 98 MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( ); 96 99 #else -
issm/trunk/src/c/solutions/bedslope_core.cpp
r4043 r4055 25 25 26 26 /*Call on core computations: */ 27 solver_linear(NULL,femmodel,SlopeComputeAnalysisEnum,BedSlopeXAnalysisEnum); 28 solver_linear(NULL,femmodel,SlopeComputeAnalysisEnum,BedSlopeYAnalysisEnum); 27 femmodel->SetCurrentAnalysisAlias(SlopeAnalysisEnum,BedSlopeXAnalysisEnum); 28 solver_linear(NULL,femmodel); 29 femmodel->SetCurrentAnalysisAlias(SlopeAnalysisEnum,BedSlopeYAnalysisEnum); 30 solver_linear(NULL,femmodel); 29 31 30 32 /*extrude inputs if we are in 3D: */ 31 33 if (dim==3){ 32 if(verbose)_printf_("%s\n","extruding slopein 3d...");33 InputsExtrudex( femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,BedSlopeXEnum,0);34 InputsExtrudex( femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,BedSlopeYEnum,0);34 if(verbose)_printf_("%s\n","extruding bed in 3d..."); 35 ExtrudeInputx(femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters,BedSlopeXEnum); 36 ExtrudeInputx(femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters,BedSlopeYEnum); 35 37 } 38 39 if(verbose)_printf_("saving results:\n"); 40 InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,BedSlopeXEnum); 41 InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,BedSlopeYEnum); 42 36 43 } -
issm/trunk/src/c/solutions/control_core.cpp
r4052 r4055 104 104 if (((n+1)%5)==0){ 105 105 _printf_("%s"," saving temporary results..."); 106 controlrestart(femmodel );106 controlrestart(femmodel,J); 107 107 } 108 108 } -
issm/trunk/src/c/solutions/controlrestart.cpp
r4052 r4055 7 7 #include "../EnumDefinitions/EnumDefinitions.h" 8 8 9 void controlrestart(FemModel* femmodel ){9 void controlrestart(FemModel* femmodel,double* J){ 10 10 11 char* outputfilename=NULL; 12 11 int control_type; 12 int nsteps; 13 13 14 /*retrieve output file name: */ 14 model->FindParam(&outputfilename,OutputFileNameEnum); 15 femmodel->parameters->FindParam(&control_type,ControlTypeEnum); 16 femmodel->parameters->FindParam(&nsteps,NStepsEnum); 15 17 16 18 /*we essentially want J and the parameter: */ 17 19 InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,control_type); //the parameter itself! 18 femmodel-> otherresults->AddObject(new DoubleResult(femmodel->otherresults->Size()+1,0,1,"J",J,nsteps));19 femmodel-> otherresults->AddObject(new StringResult(results->Size()+1,ControlTypeEnum,0,1,EnumAsString(control_type)));20 femmodel->results->AddObject(new DoubleVecExternalResult(femmodel->results->Size()+1,JEnum,J,nsteps,1,0)); 21 femmodel->results->AddObject(new StringExternalResult(femmodel->results->Size()+1,ControlTypeEnum,EnumAsString(control_type),1,0)); 20 22 21 23 /*write to disk: */ 22 OutputResults(femmodel->elements, femmodel->loads, femmodel->nodes, femmodel->vertices, femmodel->materials, femmodel->parameters, outputfilename); 23 24 /*Free ressources:*/ 25 xfree((void**)&outputfilename); 24 OutputResults(femmodel->elements, femmodel->loads, femmodel->nodes, femmodel->vertices, femmodel->materials, femmodel->parameters); 25 26 26 } -
issm/trunk/src/c/solutions/diagnostic.cpp
r4042 r4055 36 36 double start_init, finish_init; 37 37 38 int analyses[5]={DiagnosticHorizAnalysisEnum,DiagnosticVertAnalysisEnum,DiagnosticStokesAnalysisEnum,DiagnosticHutterAnalysisEnum,Slope ComputeAnalysisEnum};38 int analyses[5]={DiagnosticHorizAnalysisEnum,DiagnosticVertAnalysisEnum,DiagnosticStokesAnalysisEnum,DiagnosticHutterAnalysisEnum,SlopeAnalysisEnum}; 39 39 int solution_type=DiagnosticAnalysisEnum; 40 40 … … 58 58 lockname=argv[4]; 59 59 60 /*Initialize femmodel structure: */61 60 MPI_Barrier(MPI_COMM_WORLD); start_init=MPI_Wtime(); 62 61 … … 66 65 _printf_("create finite element model:\n"); 67 66 femmodel=new FemModel(fid,solution_type,analyses,5); 67 68 /*add outputfilename in parameters: */ 69 femmodel->parameters->AddObject(new StringParam(OutputFileNameEnum,outputfilename)); 68 70 69 71 /*get parameters: */ … … 94 96 95 97 _printf_("write results to disk:\n"); 96 OutputResults(femmodel->elements, femmodel->loads, femmodel->nodes, femmodel->vertices, femmodel->materials, femmodel->parameters , outputfilename);98 OutputResults(femmodel->elements, femmodel->loads, femmodel->nodes, femmodel->vertices, femmodel->materials, femmodel->parameters); 97 99 } 98 100 else{ -
issm/trunk/src/c/solutions/diagnostic_core.cpp
r4052 r4055 22 22 bool isstokes=false; 23 23 double stokesreconditioning; 24 bool conserve_loads=true; 25 bool modify_loads=true; 24 26 25 /* recover parameters: {{{1*/27 /* recover parameters:*/ 26 28 femmodel->parameters->FindParam(&verbose,VerboseEnum); 27 29 femmodel->parameters->FindParam(&dim,DimEnum); … … 31 33 femmodel->parameters->FindParam(&stokesreconditioning,StokesReconditioningEnum); 32 34 femmodel->parameters->FindParam(&qmu_analysis,QmuAnalysisEnum); 33 /*}}}*/34 35 35 36 /*for qmu analysis, reinitialize velocity so that fake sensitivities do not show up as a result of a different restart of the convergence at each trial.*/ … … 48 49 49 50 if(verbose)_printf_("%s\n"," computing hutter velocities..."); 50 solver_linear(NULL,femmodel,DiagnosticAnalysisEnum,HutterAnalysisEnum); 51 femmodel->SetCurrentAnalysis(DiagnosticHutterAnalysisEnum); 52 solver_linear(NULL,femmodel); 51 53 52 54 if (ismacayealpattyn) ResetBoundaryConditions(femmodel,DiagnosticAnalysisEnum,HorizAnalysisEnum); … … 56 58 57 59 if(verbose)_printf_("%s\n"," computing horizontal velocities..."); 58 solver_diagnostic_nonlinear(NULL,NULL,NULL,femmodel,false,DiagnosticAnalysisEnum,HorizAnalysisEnum); //false means we expose loads to changes inside the solution 60 femmodel->SetCurrentAnalysis(DiagnosticHorizAnalysisEnum); 61 solver_diagnostic_nonlinear(NULL,NULL,NULL,femmodel,modify_loads); 59 62 } 60 63 … … 63 66 64 67 if(verbose)_printf_("%s\n"," computing vertical velocities..."); 65 solver_linear(NULL,femmodel,DiagnosticAnalysisEnum,VertAnalysisEnum); 68 femmodel->SetCurrentAnalysis(DiagnosticVertAnalysisEnum); 69 solver_linear(NULL,femmodel); 66 70 67 71 if (isstokes){ … … 75 79 76 80 if(verbose)_printf_("%s\n"," computing stokes velocities and pressure ..."); 77 solver_diagnostic_nonlinear(NULL,NULL,NULL,NULL,femmodel,DiagnosticAnalysisEnum,StokesAnalysisEnum); 81 femmodel->SetCurrentAnalysis(DiagnosticStokesAnalysisEnum); 82 solver_diagnostic_nonlinear(NULL,NULL,NULL,femmodel,conserve_loads); 78 83 } 79 84 } -
issm/trunk/src/c/solutions/gradient_core.cpp
r4048 r4055 32 32 33 33 if(verbose)_printf_("%s\n"," compute gradient:"); 34 Gradjx(&gradient, femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters, control_type ,AdjointEnum);34 Gradjx(&gradient, femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters, control_type); 35 35 36 36 if(verbose)_printf_("%s\n"," retrieve old gradient:"); 37 37 GetVectorFromInputsx(&old_gradient, femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters, OldGradientEnum,VertexEnum); 38 38 39 if(control_steady)diagnostic_core( model);39 if(control_steady)diagnostic_core(femmodel); 40 40 41 41 if (step>0 && search_scalar==0){ … … 55 55 56 56 /*plug back into inputs: */ 57 UpdateInputsFromVectorx( femmodel-> elements,femmodel-> nodes, femmodel-> vertices,femmodel-> loads, femmodel-> materials, femmo el->parameters,gradient,GradientEnum,VertexEnum);58 UpdateInputsFromVectorx( femmodel-> elements,femmodel-> nodes, femmodel-> vertices,femmodel-> loads, femmodel-> materials, femmo el->parameters,old_gradient,OldGradientEnum,VertexEnum);57 UpdateInputsFromVectorx( femmodel-> elements,femmodel-> nodes, femmodel-> vertices,femmodel-> loads, femmodel-> materials, femmodel->parameters,gradient,GradientEnum,VertexEnum); 58 UpdateInputsFromVectorx( femmodel-> elements,femmodel-> nodes, femmodel-> vertices,femmodel-> loads, femmodel-> materials, femmodel->parameters,old_gradient,OldGradientEnum,VertexEnum); 59 59 60 60 /*Free ressources and return:*/ -
issm/trunk/src/c/solutions/objectivefunctionC.cpp
r4052 r4055 3 3 */ 4 4 5 #include "../modules/modules.h" 6 #include "./solutions.h" 7 #include "../EnumDefinitions/EnumDefinitions.h" 8 5 /*include files: {{{1*/ 9 6 #ifdef HAVE_CONFIG_H 10 7 #include "config.h" … … 12 9 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 13 10 #endif 11 12 #include "../toolkits/toolkits.h" 13 #include "../objects/objects.h" 14 #include "../shared/shared.h" 15 #include "../EnumDefinitions/EnumDefinitions.h" 16 #include "../solvers/solvers.h" 17 #include "./solutions.h" 18 #include "../modules/modules.h" 19 #include "../include/include.h" 20 /*}}}*/ 14 21 15 22 double objectivefunctionC(double search_scalar,OptArgs* optargs){ … … 22 29 /*parameters: */ 23 30 FemModel* femmodel=NULL; 24 int n;31 int n; 25 32 double* optscal=NULL; 26 33 double* fit=NULL; … … 29 36 int control_type; 30 37 int analysis_type; 31 int sub_analysis_type;32 38 int control_steady; 33 39 bool conserve_loads=true; 40 34 41 /*Recover finite element model: */ 35 42 femmodel=optargs->femmodel; … … 45 52 femmodel->parameters->FindParam(&control_steady,ControlSteadyEnum); 46 53 femmodel->parameters->FindParam(&analysis_type,AnalysisTypeEnum); 47 femmodel->parameters->FindParam(&sub_analysis_type,SubAnalysisTypeEnum);48 54 49 55 /*Use ControlParameterEnum input to reinitialize our input parameter: */ … … 57 63 58 64 /*Run diagnostic with updated inputs: */ 59 if(!control_steady) solver_diagnostic_nonlinear(NULL,NULL,NULL, true,femmodel,DiagnosticAnalysisEnum,sub_analysis_type); //true means we conserve loads at each diagnostic run65 if(!control_steady) solver_diagnostic_nonlinear(NULL,NULL,NULL,femmodel,conserve_loads); //true means we conserve loads at each diagnostic run 60 66 else diagnostic_core(femmodel); //We need a 3D velocity!! (vz is required for the next thermal run) 61 67 62 68 /*Compute misfit for this velocity field.*/ 63 69 UpdateInputsFromConstantx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,fit[n],FitEnum); 64 CostFunctionx( &J, femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials, femmodel->parameters ,analysis_type,sub_analysis_type);70 CostFunctionx( &J, femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials, femmodel->parameters); 65 71 66 72 /*Free ressources:*/ -
issm/trunk/src/c/solutions/prognostic.cpp
r3938 r4055 24 24 char* outputfilename=NULL; 25 25 char* lockname=NULL; 26 int numberofnodes;26 bool qmu_analysis=false; 27 27 bool waitonlock=false; 28 28 29 Model* model=NULL; 30 31 bool qmu_analysis; 32 33 /*Results: */ 34 Results* results=NULL; 35 36 Param* param=NULL; 29 /*FemModel: */ 30 FemModel* femmodel=NULL; 37 31 38 32 /*time*/ … … 40 34 double start_core, finish_core; 41 35 double start_init, finish_init; 36 37 int analyses[1]={PrognosticAnalysisEnum}; 38 int solution_type=PrognosticAnalysisEnum; 42 39 43 40 MODULEBOOT(); … … 62 59 /*Initialize model structure: */ 63 60 MPI_Barrier(MPI_COMM_WORLD); start_init=MPI_Wtime(); 64 model=new Model();65 61 66 62 /*Open handle to data on disk: */ 67 63 fid=pfopen(inputfilename,"rb"); 68 64 69 _printf_(" read andcreate finite element model:\n");70 model->AddFormulation(fid,PrognosticAnalysisEnum);65 _printf_("create finite element model:\n"); 66 femmodel=new FemModel(fid,solution_type,analyses,1); 71 67 72 /*recover parameters: */ 73 model->FindParam(&waitonlock,WaitOnLockEnum); 74 model->FindParam(&qmu_analysis,QmuAnalysisEnum); 68 /*add outputfilename in parameters: */ 69 femmodel->parameters->AddObject(new StringParam(OutputFileNameEnum,outputfilename)); 70 71 /*get parameters: */ 72 femmodel->parameters->FindParam(&qmu_analysis,QmuAnalysisEnum); 73 femmodel->parameters->FindParam(&waitonlock,WaitOnLockEnum); 74 75 75 76 76 MPI_Barrier(MPI_COMM_WORLD); finish_init=MPI_Wtime(); … … 82 82 _printf_("call computational core:\n"); 83 83 MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( ); 84 results=prognostic_core(model);84 prognostic_core(femmodel); 85 85 MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( ); 86 87 _printf_("write results to disk:\n"); 88 OutputResults(femmodel->elements, femmodel->loads, femmodel->nodes, femmodel->vertices, femmodel->materials, femmodel->parameters); 86 89 87 90 } … … 93 96 #ifdef _HAVE_DAKOTA_ 94 97 MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( ); 95 Qmux( model,PrognosticAnalysisEnum,NoneAnalysisEnum);98 Qmux(femmodel,PrognosticAnalysisEnum,NoneAnalysisEnum); 96 99 MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( ); 97 100 #else … … 101 104 102 105 103 _printf_("write results to disk:\n");104 OutputResults(results,outputfilename);105 106 106 if (waitonlock>0){ 107 107 _printf_("write lock file:\n"); … … 110 110 111 111 /*Free ressources:*/ 112 delete results; 113 delete model; 112 delete femmodel; 114 113 115 114 /*Get finish time and close*/ -
issm/trunk/src/c/solutions/prognostic2.cpp
r3938 r4055 24 24 char* outputfilename=NULL; 25 25 char* lockname=NULL; 26 int numberofnodes;26 bool qmu_analysis=false; 27 27 bool waitonlock=false; 28 28 29 Model* model=NULL; 30 31 bool qmu_analysis; 32 33 /*Results: */ 34 Results* results=NULL; 35 36 Param* param=NULL; 29 /*FemModel: */ 30 FemModel* femmodel=NULL; 37 31 38 32 /*time*/ … … 40 34 double start_core, finish_core; 41 35 double start_init, finish_init; 36 37 int analyses[1]={Prognostic2AnalysisEnum}; 38 int solution_type=Prognosti2cAnalysisEnum; 42 39 43 40 MODULEBOOT(); … … 62 59 /*Initialize model structure: */ 63 60 MPI_Barrier(MPI_COMM_WORLD); start_init=MPI_Wtime(); 64 model=new Model();65 61 66 62 /*Open handle to data on disk: */ 67 63 fid=pfopen(inputfilename,"rb"); 68 64 69 _printf_("read and create finite element model:\n"); 70 model->AddFormulation(fid,Prognostic2AnalysisEnum); 65 _printf_("create finite element model:\n"); 66 femmodel=new FemModel(fid,solution_type,analyses,1); 67 68 /*add outputfilename in parameters: */ 69 femmodel->parameters->AddObject(new StringParam(OutputFileNameEnum,outputfilename)); 71 70 72 71 /*recover parameters: */ 73 72 model->FindParam(&waitonlock,WaitOnLockEnum); 74 73 model->FindParam(&qmu_analysis,QmuAnalysisEnum); 75 model->FindParam(&numberofnodes,NumberOfNodesEnum); 74 76 75 77 76 MPI_Barrier(MPI_COMM_WORLD); finish_init=MPI_Wtime(); … … 83 82 _printf_("call computational core:\n"); 84 83 MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( ); 85 results=prognostic2_core(model);84 prognostic2_core(femmodel); 86 85 MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( ); 86 87 _printf_("write results to disk:\n"); 88 OutputResults(femmodel->elements, femmodel->loads, femmodel->nodes, femmodel->vertices, femmodel->materials, femmodel->parameters); 87 89 88 90 } … … 94 96 #ifdef _HAVE_DAKOTA_ 95 97 MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( ); 96 Qmux( model,Prognostic2AnalysisEnum,NoneAnalysisEnum);98 Qmux(femmodel,Prognostic2AnalysisEnum,NoneAnalysisEnum); 97 99 MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( ); 98 100 #else … … 100 102 #endif 101 103 } 102 103 _printf_("write results to disk:\n");104 OutputResults(results,outputfilename);105 104 106 105 if (waitonlock>0){ … … 110 109 111 110 /*Free ressources:*/ 112 delete results; 113 delete model; 111 delete femmodel; 114 112 115 113 /*Get finish time and close*/ -
issm/trunk/src/c/solutions/prognostic2_core.cpp
r4043 r4055 11 11 #include "../solvers/solvers.h" 12 12 13 Results* prognostic2_core(Model* model){ 14 15 extern int my_rank; 16 17 /*output: */ 18 Results* results=NULL; 19 Result* result=NULL; 20 21 /*intermediary: */ 22 Vec vx_g=NULL; 23 Vec vy_g=NULL; 24 25 /*solutions: */ 26 Vec h_g=NULL; 13 void prognostic2_core(FemModel* femmodel){ 27 14 28 15 /*flags: */ 29 16 int verbose=0; 30 int numberofdofspernode;31 int numberofnodes;32 int numberofvertices;33 int dofs[1]={1};34 17 35 /* fem prognostic model: */36 FemModel* fem_p=NULL;18 /*activate formulation: */ 19 femmodel->SetCurrentAnalysis(Prognostic2AnalysisEnum); 37 20 38 //initialize results: 39 results=new Results(); 40 41 /*recover fem model: */ 42 fem_p=model->GetFormulation(Prognostic2AnalysisEnum); 43 44 //first recover parameters common to all solutions 45 model->FindParam(&verbose,VerboseEnum); 46 model->FindParam(&numberofnodes,NumberOfNodesEnum); 47 model->FindParam(&numberofvertices,NumberOfVerticesEnum); 48 model->FindParam(&numberofdofspernode,NumberOfNodesEnum); 21 /*recover parameters: */ 22 femmodel->parameters->FindParam(&verbose,VerboseEnum); 49 23 50 24 _printf_("depth averaging velocity...\n"); 51 25 /*Where is it done?*/ 26 27 _printf_("call computational core:\n"); 28 solver_linear(NULL,femmodel); 52 29 53 _printf_("call computational core:\n");54 diagnostic_core_linear(&h_g,fem_p,Prognostic2AnalysisEnum,NoneAnalysisEnum);55 56 30 _printf_("Averaging over vertices:\n"); 57 FieldAverageOntoVerticesx(&h_g,fem_p->elements,fem_p->nodes,fem_p->vertices,fem_p->loads,fem_p->materials,fem_p->parameters);31 //FieldAverageOntoVerticesx(&h_g,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters); 58 32 59 33 //_printf_("extrude computed thickness on all layers:\n"); 60 34 //FieldExtrudex(h_g, fem_p->elements,fem_p->nodes, fem_p->vertices,fem_p->loads, fem_p->materials,fem_p->parameters,"thickness",0); 61 35 62 /*Plug results into output dataset: */ 63 InputToResultx(&result,fem_p->elements,fem_p->nodes,fem_p->vertices, fem_p->loads, fem_p->materials,fem_p->parameters,ThicknessEnum,results->Size()+1,0,1); results->AddObject(result); 64 results->AddObject(new StringResult(results->Size()+1,AnalysisTypeEnum,0,1,EnumAsString(Prognostic2AnalysisEnum))); 65 66 /*Free ressources:*/ 67 VecFree(&vx_g); 68 VecFree(&vy_g); 69 VecFree(&h_g); 70 71 /*return: */ 72 return results; 36 if(verbose)_printf_("saving results:\n"); 37 InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,ThicknessEnum); 73 38 74 39 } -
issm/trunk/src/c/solutions/prognostic_core.cpp
r4043 r4055 11 11 #include "../solvers/solvers.h" 12 12 13 Results* prognostic_core(Model*model){13 void prognostic_core(FemModel* femmodel){ 14 14 15 extern int my_rank; 16 17 /*output: */ 18 Results* results=NULL; 19 Result* result=NULL; 20 21 /*solutions: */ 22 Vec h_g=NULL; 23 24 /*flags: */ 15 /*parameters: */ 25 16 int verbose=0; 26 17 27 /*fem prognostic model: */ 28 FemModel* fem_p=NULL; 29 30 //initialize results 31 results=new Results(); 32 33 /*recover fem model: */ 34 fem_p=model->GetFormulation(PrognosticAnalysisEnum); ISSMASSERT(fem_p); 35 36 //first recover parameters common to all solutions 37 model->FindParam(&verbose,VerboseEnum); 18 /*activate formulation: */ 19 femmodel->SetCurrentAnalysis(PrognosticAnalysisEnum); 20 21 /*recover parameters: */ 22 femmodel->parameters->FindParam(&verbose,VerboseEnum); 38 23 39 24 _printf_("depth averaging velocity...\n"); 40 DepthAverageInputx(fem _p->elements,fem_p->nodes, fem_p->vertices,fem_p->loads, fem_p->materials,fem_p->parameters,VxEnum);41 DepthAverageInputx(fem _p->elements,fem_p->nodes, fem_p->vertices,fem_p->loads, fem_p->materials,fem_p->parameters,VyEnum);25 DepthAverageInputx(femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters,VxEnum,VxAverageEnum); 26 DepthAverageInputx(femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters,VyEnum,VyAverageEnum); 42 27 43 28 _printf_("call computational core:\n"); 44 diagnostic_core_linear(&h_g,fem_p,PrognosticAnalysisEnum,NoneAnalysisEnum);29 solver_linear(NULL,femmodel); 45 30 46 _printf_(" update inputs:\n");47 UpdateInputsFromSolutionx( fem_p->elements,fem_p->nodes, fem_p->vertices, fem_p->loads, fem_p->materials, fem_p->parameters,h_g,PrognosticAnalysisEnum,NoneAnalysisEnum);31 _printf_("extrude computed thickness on all layers:\n"); 32 ExtrudeInputx(femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters,ThicknessEnum); 48 33 49 _printf_("extrude computed thickness on all layers:\n");50 ExtrudeInputx(fem_p->elements,fem_p->nodes, fem_p->vertices,fem_p->loads, fem_p->materials,fem_p->parameters,ThicknessEnum);34 if(verbose)_printf_("saving results:\n"); 35 InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,ThicknessEnum); 51 36 52 _printf_("extract result from extruded inputs: \n"); 53 InputToResultx(&result,fem_p->elements,fem_p->nodes,fem_p->vertices, fem_p->loads, fem_p->materials,fem_p->parameters,ThicknessEnum,results->Size()+1,0,1); results->AddObject(result); 54 results->AddObject(new StringResult(results->Size()+1,AnalysisTypeEnum,0,1,EnumAsString(PrognosticAnalysisEnum))); 37 } 55 38 56 /*Free ressources:*/57 VecFree(&h_g);58 59 //return:60 return results;61 62 } -
issm/trunk/src/c/solutions/solutions.h
r4052 r4055 13 13 14 14 /*cores: */ 15 Results* prognostic_core(FemModel* femmodel);16 Results* prognostic2_core(FemModel* femmodel);17 Results* balancedthickness_core(FemModel* femmodel);18 Results* balancedthickness2_core(FemModel* femmodel);19 Results* balancedvelocities_core(FemModel* femmodel);20 Results* slopecompute_core(FemModel* femmodel);21 Results* steadystate_core(FemModel* femmodel);22 Results* transient_core(FemModel* femmodel);23 Results* transient_core_2d(FemModel* femmodel);24 Results* transient_core_3d(FemModel* femmodel);25 15 void adjoint_core(FemModel* femmodel); 26 16 void gradient_core(FemModel* femmodel,int step=0, double search_scalar=0); 27 17 void diagnostic_core(FemModel* femmodel); 28 18 void thermal_core(FemModel* femmodel); 29 void surfaceslope_core(FemModel* femfemmodel); 30 void bedslope_core(FemModel* femfemmodel); 19 void thermal_core_step(FemModel* femmodel,int step, double time); 20 void surfaceslope_core(FemModel* femmodel); 21 void bedslope_core(FemModel* femmodel); 31 22 void control_core(FemModel* femmodel); 23 void prognostic_core(FemModel* femmodel); 24 void prognostic2_core(FemModel* femmodel); 25 void balancedthickness_core(FemModel* femmodel); 26 void balancedthickness2_core(FemModel* femmodel); 27 void balancedvelocities_core(FemModel* femmodel); 28 void slopecompute_core(FemModel* femmodel); 29 void steadystate_core(FemModel* femmodel); 30 void transient2d_core(FemModel* femmodel); 31 void transient3d_core(FemModel* femmodel); 32 double objectivefunctionC(double search_scalar,OptArgs* optargs); 32 33 33 // int GradJOrth(WorkspaceParams* workspaceparams);34 //convergence: 34 35 void convergence(int* pconverged, Mat K_ff,Vec p_f,Vec u_f,Vec u_f_old,Parameters* parameters); 35 36 int controlconvergence(double* J, double* fit, double eps_cm, int n); 36 37 37 int GoldenSearch(double* psearch_scalar,double* pJ,double xa, double xb, double tolerance, int maxiter, double fit,double optscal,double (*f)(double*,double,double,FemModel*),FemModel* femfemmodel); 38 //optimization 39 int GoldenSearch(double* psearch_scalar,double* pJ,double xa, double xb, double tolerance, int maxiter, double fit,double optscal,double (*f)(double*,double,double,FemModel*),FemModel* femmodel); 40 int BrentSearch(double* psearch_scalar,double* pJ,double xa, double xb, double tolerance, int maxiter, double fit,double optscal,double (*f)(double*,double,double,FemModel*),FemModel* femmodel); 41 int GradJSearch(double* search_vector,FemModel* femmodel,int step); 38 42 39 int BrentSearch(double* psearch_scalar,double* pJ,double xa, double xb, double tolerance, int maxiter, double fit,double optscal,double (*f)(double*,double,double,FemModel*),FemModel* femfemmodel); 40 41 double objectivefunctionC(double search_scalar,OptArgs* optargs); 42 43 int GradJSearch(double* search_vector,FemModel* femfemmodel,int step); 44 //int GradJCheck(WorkspaceParams* workspaceparams,int step,int status); 45 46 //int ParameterUpdate(double* search_vector,int step, WorkspaceParams* workspaceparams,BatchParams* batchparams); 43 //diverse 47 44 void WriteLockFile(char* filename); 48 49 void stokescontrolinit(FemModel* femfemmodel); 50 void controlrestart(FemModel* femfemmodel); 51 52 void CreateFemModel(FemModel* femfemmodel,ConstDataHandle MODEL,int analysis_type,int sub_analysis_type); 53 //int BatchDebug(Mat* Kgg,Vec* pg,FemModel* femfemmodel,char* filename); 54 void ResetBoundaryConditions(FemModel* femfemmodel, int analysis_type, int sub_analysis_type); 45 void stokescontrolinit(FemModel* femmodel); 46 void controlrestart(FemModel* femmodel,double* J); 47 void ResetBoundaryConditions(FemModel* femmodel, int analysis_type, int sub_analysis_type); 55 48 56 49 #endif -
issm/trunk/src/c/solutions/steadystate.cpp
r3938 r4055 24 24 char* outputfilename=NULL; 25 25 char* lockname=NULL; 26 int numberofnodes;27 26 bool qmu_analysis=false; 28 27 bool control_analysis=false; 29 char* control_type=NULL;28 bool waitonlock=false; 30 29 31 /*Model: */ 32 Model* model=NULL; 33 FemModel* fem_dh=NULL; 34 FemModel* fem_ds=NULL; 35 36 /*Results: */ 37 Results* results=NULL; 38 39 bool waitonlock=false; 40 41 double* u_g_initial=NULL; 42 double* p_g_initial=NULL; 43 double* u_g_obs=NULL; 44 double* weights=NULL; 45 double dt; 46 BoolParam* param=NULL; 30 /*FemModel: */ 31 FemModel* femmodel=NULL; 47 32 48 33 /*time*/ … … 50 35 double start_core, finish_core; 51 36 double start_init, finish_init; 37 38 /*intermediary: */ 39 BoolParam* param=NULL; 40 41 int analyses[7]={DiagnosticHorizAnalysisEnum,DiagnosticVertAnalysisEnum,DiagnosticStokesAnalysisEnum,DiagnosticHutterAnalysisEnum,SlopeAnalysisEnum,ThermalAnalysisEnum,MeltingAnalysisEnum}; 42 int solution_type=SteadystateAnalysisEnum; 52 43 53 44 MODULEBOOT(); … … 70 61 lockname=argv[4]; 71 62 63 /*Initialize model structure: */ 64 MPI_Barrier(MPI_COMM_WORLD); start_init=MPI_Wtime(); 65 72 66 /*Open handle to data on disk: */ 73 67 fid=pfopen(inputfilename,"rb"); 74 68 75 /*Initialize model structure: */ 76 MPI_Barrier(MPI_COMM_WORLD); start_init=MPI_Wtime(); 77 model=new Model(); 69 _printf_("create finite element model:\n"); 70 femmodel=new FemModel(fid,solution_type,analyses,5); 78 71 79 _printf_("read and create finite element model:\n"); 80 81 _printf_("\n reading diagnostic horiz model data:\n"); 82 model->AddFormulation(fid,DiagnosticAnalysisEnum,HorizAnalysisEnum); 83 84 _printf_("\n reading diagnostic vert model data:\n"); 85 model->AddFormulation(fid,DiagnosticAnalysisEnum,VertAnalysisEnum); 86 87 _printf_("\n reading diagnostic stokes model data:\n"); 88 model->AddFormulation(fid,DiagnosticAnalysisEnum,StokesAnalysisEnum); 89 90 _printf_("\n reading diagnostic hutter model data:\n"); 91 model->AddFormulation(fid,DiagnosticAnalysisEnum,HutterAnalysisEnum); 92 93 _printf_("\n reading surface and bed slope computation model data:\n"); 94 model->AddFormulation(fid,SlopecomputeAnalysisEnum); 95 96 _printf_("\n read and create thermal finite element model:\n"); 97 model->AddFormulation(fid,ThermalAnalysisEnum); 98 _printf_("\n read and create melting finite element model:\n"); 99 model->AddFormulation(fid,MeltingAnalysisEnum); 72 /*add outputfilename in parameters: */ 73 femmodel->parameters->AddObject(new StringParam(OutputFileNameEnum,outputfilename)); 100 74 101 75 /*recover parameters: */ … … 113 87 _printf_("call computational core:\n"); 114 88 MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( ); 115 results=steadystate_core(model);89 steadystate_core(femmodel); 116 90 MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( ); 117 91 … … 119 93 else{ 120 94 /*change control_steady to 1 to know we are doing steadystate*/ 121 fem_dh=model->GetFormulation(DiagnosticAnalysisEnum,HorizAnalysisEnum); 122 fem_ds=model->GetFormulation(DiagnosticAnalysisEnum,StokesAnalysisEnum); 123 124 param=(BoolParam*)fem_dh->parameters->FindParamObject(ControlSteadyEnum); param->value=true; 125 param=(BoolParam*)fem_ds->parameters->FindParamObject(ControlSteadyEnum); param->value=true; 95 param=(BoolParam*)femmodel->parameters->FindParamObject(ControlSteadyEnum); param->value=true; 126 96 127 97 /*run control analysis: */ 128 98 _printf_("call computational core:\n"); 129 99 MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( ); 130 results=control_core(model);100 control_core(femmodel); 131 101 MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( ); 132 133 102 } 134 103 135 104 _printf_("write results to disk:\n"); 136 OutputResults(results,outputfilename); 105 OutputResults(femmodel->elements, femmodel->loads, femmodel->nodes, femmodel->vertices, femmodel->materials, femmodel->parameters); 106 137 107 } 138 108 else{ … … 142 112 #ifdef _HAVE_DAKOTA_ 143 113 MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( ); 144 Qmux( model,SteadystateAnalysisEnum,NoneAnalysisEnum);114 Qmux(femmodel,SteadystateAnalysisEnum,NoneAnalysisEnum); 145 115 MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( ); 146 116 #else … … 155 125 156 126 /*Free ressources */ 157 xfree((void**)&u_g_initial); 158 xfree((void**)&u_g_obs); 159 xfree((void**)&p_g_initial); 160 delete model; 161 delete results; 127 delete femmodel; 162 128 163 129 /*Get finish time and close*/ -
issm/trunk/src/c/solutions/steadystate_core.cpp
r4043 r4055 9 9 #include "./solutions.h" 10 10 #include "../modules/modules.h" 11 #include "../include/include.h" 11 12 #include "../solvers/solvers.h" 12 13 13 Results* steadystate_core(Model*model){14 void steadystate_core(FemModel* femmodel){ 14 15 15 extern int my_rank; 16 /*intermediary: */ 17 int step; 16 18 17 /*fem models: */ 18 FemModel* fem_dh=NULL; 19 FemModel* fem_dv=NULL; 20 FemModel* fem_dhu=NULL; 21 FemModel* fem_ds=NULL; 22 FemModel* fem_sl=NULL; 23 FemModel* fem_t=NULL; 24 FemModel* fem_m=NULL; 19 /*parameters: */ 20 int verbose; 21 int dim; 22 23 /* recover parameters:*/ 24 femmodel->parameters->FindParam(&verbose,VerboseEnum); 25 femmodel->parameters->FindParam(&dim,DimEnum); 25 26 26 /*output: */ 27 Results* results=NULL; 28 Results* results_thermal=NULL; 29 Results* results_diagnostic=NULL; 30 31 /*solutions: */ 32 Vec u_g=NULL; 33 Vec old_u_g=NULL; 34 Vec t_g=NULL; 35 Vec t_g_average=NULL; 36 Vec old_t_g=NULL; 37 Vec p_g=NULL; 38 Vec m_g=NULL; 39 Vec du_g=NULL; 40 Vec dt_g=NULL; 41 double ndu,nu; 42 double normdt,normt; 43 double eps_rel; 44 45 /*flags: */ 46 int verbose=0; 47 int isstokes=0; 48 int numberofnodes; 49 int ndof; 50 int converged; 51 int step; 52 53 /*recover fem models: */ 54 fem_dh=model->GetFormulation(DiagnosticAnalysisEnum,HorizAnalysisEnum); 55 fem_dv=model->GetFormulation(DiagnosticAnalysisEnum,VertAnalysisEnum); 56 fem_ds=model->GetFormulation(DiagnosticAnalysisEnum,StokesAnalysisEnum); 57 fem_dhu=model->GetFormulation(DiagnosticAnalysisEnum,HutterAnalysisEnum); 58 fem_sl=model->GetFormulation(SlopecomputeAnalysisEnum); 59 fem_t=model->GetFormulation(ThermalAnalysisEnum); 60 fem_m=model->GetFormulation(MeltingAnalysisEnum); 61 62 63 //first recover parameters common to all solutions 64 model->FindParam(&verbose,VerboseEnum); 65 model->FindParam(&numberofnodes,NumberOfNodesEnum); 66 model->FindParam(&eps_rel,EpsResEnum); 67 model->FindParam(&isstokes,IsStokesEnum); 68 69 //initialize: 70 converged=0; 27 /*intialize counters: */ 71 28 step=1; 72 73 if (isstokes)ndof=4;74 else ndof=3;75 29 76 30 for(;;){ 77 31 78 32 if(verbose)_printf_("%s%i\n"," computing temperature and velocity for step: ",step); 33 thermal_core(femmodel); 79 34 80 //first compute temperature at steady state.81 results_thermal=thermal_core(model);35 if(verbose)_printf_("%s\n","computing depth average temperature"); 36 DepthAverageInputx(femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters,TemperatureEnum,TemperatureAverageEnum); 82 37 83 //get t_g and m_g; 84 VecFree(&t_g);results_thermal->FindResult(&t_g,"t_g"); 85 VecFree(&m_g);results_thermal->FindResult(&m_g,"m_g"); 86 delete results_thermal; 38 if(verbose)_printf_("%s\n","computing new velocity"); 39 diagnostic_core(femmodel); 87 40 88 //Add temperature to inputs. 89 //compute depth averaged temperature and add to inputs 90 VecDuplicatePatch(&t_g_average,t_g); 91 FieldDepthAveragex( t_g_average, fem_t->elements,fem_t->nodes, fem_t->vertices,fem_t->loads, fem_t->materials,fem_t->parameters,"temperature"); 92 model->UpdateInputsFromVector(t_g_average,TemperatureAverageEnum,VertexEnum); 93 model->UpdateInputsFromVector(t_g,TemperatureEnum,VertexEnum); 94 VecFree(&t_g_average); //not needed anymore 95 96 //now compute diagnostic velocity using the steady state temperature. 97 results_diagnostic=diagnostic_core(model); 98 99 //get p_g and u_g 100 VecFree(&u_g);results_diagnostic->FindResult(&u_g,"u_g"); 101 VecFree(&p_g);results_diagnostic->FindResult(&p_g,"p_g"); 102 delete results_diagnostic; 103 104 //convergence? 105 if(step>1){ 106 VecDuplicatePatch(&du_g,old_u_g);VecAYPX(du_g,-1.0,u_g); 107 VecNorm(du_g,NORM_2,&ndu); VecNorm(old_u_g,NORM_2,&nu); VecFree(&du_g); 108 109 VecDuplicatePatch(&dt_g,old_t_g); VecAYPX(dt_g,-1.0,t_g); 110 VecNorm(dt_g,NORM_2,&normdt); VecNorm(old_t_g,NORM_2,&normt);VecFree(&dt_g); 111 112 if (verbose) _printf_("%-60s%g\n %s%g\n %s%g%s\n", 113 " relative convergence criterion: velocity -> norm(du)/norm(u)= ",ndu/nu*100," temperature -> norm(dt)/norm(t)=",normdt/normt*100," eps_rel: ",eps_rel*100," %"); 41 if(verbose)_printf_("%s\n","checking velocity, temperature and pressure convergence"); 42 if (step>1) if(steadystateconvergence(femmodel))goto cleanup_and_return; 114 43 115 if ((ndu/nu<=eps_rel) && (normdt/normt<=eps_rel)) converged=1; 116 else converged=0; 117 } 118 else{ 119 converged=0; 120 } 121 122 VecFree(&old_u_g);VecDuplicatePatch(&old_u_g,u_g); 123 VecFree(&old_t_g);VecDuplicatePatch(&old_t_g,t_g); 124 44 if(verbose)_printf_("%s\n","saving velocity, temperature and pressure to check for convergence at next step"); 45 DuplicateInputx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VxEnum,OldVxEnum); 46 DuplicateInputx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VyEnum,OldVyEnum); 47 if(dim==3)DuplicateInputx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VzEnum,OldVzEnum); 48 DuplicateInputx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,PressureEnum,OldPressureEnum); 49 DuplicateInputx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,TemperatureEnum,OldTemperatureEnum); 50 51 //increase counter 125 52 step++; 126 if (converged)break;127 53 } 128 54 129 /*Plug results into output dataset: */ 130 results->AddObject(new Result(results->Size()+1,0,1,"u_g",u_g)); 131 results->AddObject(new Result(results->Size()+1,0,1,"p_g",p_g)); 132 results->AddObject(new Result(results->Size()+1,0,1,"t_g",t_g)); 133 results->AddObject(new Result(results->Size()+1,0,1,"m_g",m_g)); 134 results->AddObject(new StringResult(results->Size()+1,AnalysisTypeEnum,0,1,EnumAsString(SteadyAnalysisEnum))); 135 136 137 /*Free ressource*/ 138 VecFree(&old_u_g); 139 VecFree(&old_t_g); 140 VecFree(&u_g); 141 VecFree(&p_g); 142 VecFree(&t_g); 143 VecFree(&m_g); 55 cleanup_and_return: 56 57 if(verbose)_printf_("saving results:\n"); 58 InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VxEnum); 59 InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VyEnum); 60 InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,PressureEnum); 61 if(dim==3) InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VxEnum); 144 62 } -
issm/trunk/src/c/solutions/stokescontrolinit.cpp
r4052 r4055 18 18 int isstokes=0; 19 19 double stokesreconditioning; 20 20 bool conserve_loads=true; 21 21 22 /*first recover parameters common to all solutions:*/ 22 model->FindParam(&verbose,VerboseEnum);23 model->FindParam(&isstokes,IsStokesEnum);24 model->FindParam(&stokesreconditioning,StokesReconditioningEnum);23 femmodel->parameters->FindParam(&verbose,VerboseEnum); 24 femmodel->parameters->FindParam(&isstokes,IsStokesEnum); 25 femmodel->parameters->FindParam(&stokesreconditioning,StokesReconditioningEnum); 25 26 26 27 /*if no Stokes analysis carried out, assign output and return*/ 27 if (!isstokes)femmodel->Set AnalysisType(DiagnosticAnalysisEnum,DiagnosticHorizAnalysisEnum);28 if (!isstokes)femmodel->SetCurrentAnalysis(DiagnosticHorizAnalysisEnum); 28 29 29 30 /* For Stokes inverse control method, we are going to carry out the inversion only on the Stokes part. So we need 30 * to solve the Hutter or MacAyeal/Pattyn model here, and constrain the Stokesmodel using the Hutter31 * to solve the Hutter or MacAyeal/Pattyn femmodel here, and constrain the Stokes femmodel using the Hutter 31 32 * or MacAyeal/Pattyn at the boundary. We don't want to have to do that at every inversion step, as 32 33 * it needs be done only once: */ … … 36 37 37 38 /*Run a complete diagnostic to update the Stokes spcs: */ 38 solver_diagnostic_nonlinear(NULL,NULL,NULL,femmodel,false,DiagnosticAnalysisEnum,HorizAnalysisEnum); //false means we expose loads to changes inside the solution 39 femmodel->SetCurrentAnalysis(DiagnosticHorizAnalysisEnum); 40 solver_diagnostic_nonlinear(NULL,NULL,NULL,femmodel,conserve_loads); 39 41 40 42 //vertical velocity 41 solver_linear(NULL,femmodel ,DiagnosticAnalysisEnum,VertAnalysisEnum);43 solver_linear(NULL,femmodel); 42 44 43 45 //recondition" pressure computed previously: … … 49 51 50 52 if(verbose)_printf_("%s\n"," computing stokes velocities and pressure ..."); 51 solver_diagnostic_nonlinear(NULL,NULL,NULL,NULL,femmodel,DiagnosticAnalysisEnum,StokesAnalysisEnum); 52 53 /*Assign output*/ 54 model->SetActiveFormulation(fem_ds); 53 femmodel->SetCurrentAnalysis(DiagnosticStokesAnalysisEnum); 54 solver_diagnostic_nonlinear(NULL,NULL,NULL,femmodel,conserve_loads); 55 55 } -
issm/trunk/src/c/solutions/surfaceslope.cpp
r4030 r4055 37 37 double start_init, finish_init; 38 38 39 int analyses[1]={S urfaceSlopeComputeAnalysisEnum};40 int solution_type=S urfaceSlopeComputeSolutionEnum;39 int analyses[1]={SlopeAnalysisEnum}; 40 int solution_type=SlopeAnalysisEnum; 41 41 42 42 MODULEBOOT(); … … 67 67 _printf_("create finite element model, using analyses types statically defined above:\n"); 68 68 femmodel=new FemModel(fid,solution_type,analyses,1); 69 70 /*add outputfilename in parameters: */ 71 femmodel->parameters->AddObject(new StringParam(OutputFileNameEnum,outputfilename)); 69 72 70 73 /*get parameters: */ … … 83 86 84 87 _printf_("write results to disk:\n"); 85 OutputResults(femmodel ,outputfilename,DiagnosticAnalysisEnum);88 OutputResults(femmodel->elements, femmodel->loads, femmodel->nodes, femmodel->vertices, femmodel->materials, femmodel->parameters); 86 89 } 87 90 else{ … … 92 95 #ifdef _HAVE_DAKOTA_ 93 96 MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( ); 94 Qmux(femmodel,S lopeComputeAnalysisEnum,NoneAnalysisEnum);97 Qmux(femmodel,SurfaceSlopeAnalysisEnum,NoneAnalysisEnum); 95 98 MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( ); 96 99 #else -
issm/trunk/src/c/solutions/surfaceslope_core.cpp
r4043 r4055 25 25 26 26 /*Call on core computations: */ 27 solver_linear(NULL,femmodel,SlopeComputeAnalysisEnum,SurfaceSlopeXAnalysisEnum); 28 solver_linear(NULL,femmodel,SlopeComputeAnalysisEnum,SurfaceSlopeYAnalysisEnum); 27 femmodel->SetCurrentAnalysisAlias(SlopeAnalysisEnum,SurfaceSlopeXAnalysisEnum); 28 solver_linear(NULL,femmodel); 29 femmodel->SetCurrentAnalysisAlias(SlopeAnalysisEnum,SurfaceSlopeYAnalysisEnum); 30 solver_linear(NULL,femmodel); 29 31 30 32 /*extrude inputs if we are in 3D: */ 31 33 if (dim==3){ 32 34 if(verbose)_printf_("%s\n","extruding slope in 3d..."); 33 InputsExtrudex( femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,SurfaceSlopeXEnum,0);34 InputsExtrudex( femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,SurfaceSlopeYEnum,0);35 ExtrudeInputx(femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters,SurfaceSlopeXEnum); 36 ExtrudeInputx(femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters,SurfaceSlopeYEnum); 35 37 } 38 39 if(verbose)_printf_("saving results:\n"); 40 InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,SurfaceSlopeXEnum); 41 InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,SurfaceSlopeYEnum); 42 36 43 } -
issm/trunk/src/c/solutions/thermal.cpp
r4042 r4055 68 68 femmodel=new FemModel(fid,solution_type,analyses,2); 69 69 70 /*add outputfilename in parameters: */ 71 femmodel->parameters->AddObject(new StringParam(OutputFileNameEnum,outputfilename)); 72 70 73 /*get parameters: */ 71 74 femmodel->parameters->FindParam(&qmu_analysis,QmuAnalysisEnum); … … 85 88 86 89 _printf_("write results to disk:\n"); 87 OutputResults(femmodel->elements, femmodel->loads, femmodel->nodes, femmodel->vertices, femmodel->materials, femmodel->parameters , outputfilename);90 OutputResults(femmodel->elements, femmodel->loads, femmodel->nodes, femmodel->vertices, femmodel->materials, femmodel->parameters); 88 91 89 92 } -
issm/trunk/src/c/solutions/thermal_core.cpp
r4043 r4055 42 42 time=(i+1)*dt; 43 43 44 if(verbose)_printf_("computing temperatures:\n"); 45 solver_thermal_nonlinear(NULL,NULL,femmodel,ThermalAnalysisEnum,NoneAnalysisEnum); 46 47 if(verbose)_printf_("computing melting:\n"); 48 solver_linear(NULL,femmodel,MeltingAnalysisEnum,NoneAnalysisEnum); 44 /*call thermal_core_step: */ 45 thermal_core_step(femmodel,i,time); 49 46 50 47 if(verbose)_printf_("saving results:\n"); -
issm/trunk/src/c/solvers/solver_diagnostic_nonlinear.cpp
r4029 r4055 9 9 #include "./solutions.h" 10 10 11 void solver_diagnostic_nonlinear(Vec* pug,Mat* pKff0,Mat* pKfs0, FemModel* fem,bool conserve_loads , int analysis_type,int sub_analysis_type){11 void solver_diagnostic_nonlinear(Vec* pug,Mat* pKff0,Mat* pKfs0, FemModel* fem,bool conserve_loads){ 12 12 13 13 … … 61 61 62 62 /*Start non-linear iteration using input velocity: */ 63 GetSolutionFromInputsx(&ug, fem->elements, fem->nodes, fem->vertices, fem->loads, fem->materials, fem->parameters , analysis_type, sub_analysis_type);63 GetSolutionFromInputsx(&ug, fem->elements, fem->nodes, fem->vertices, fem->loads, fem->materials, fem->parameters); 64 64 Reducevectorgtofx(&uf, ug, fem->nodesets); 65 65 … … 72 72 if (verbose) _printf_(" Generating matrices\n"); 73 73 //*Generate system matrices 74 SystemMatricesx(&Kgg, &pg,fem->elements,fem->nodes,fem->vertices,loads,fem->materials,fem->parameters,kflag,pflag ,analysis_type,sub_analysis_type);74 SystemMatricesx(&Kgg, &pg,fem->elements,fem->nodes,fem->vertices,loads,fem->materials,fem->parameters,kflag,pflag); 75 75 76 76 if (verbose) _printf_(" Generating penalty matrices\n"); 77 77 //*Generate penalty system matrices 78 PenaltySystemMatricesx(Kgg, pg,NULL,fem->elements,fem->nodes,fem->vertices,loads,fem->materials,fem->parameters,kflag,pflag ,analysis_type,sub_analysis_type);78 PenaltySystemMatricesx(Kgg, pg,NULL,fem->elements,fem->nodes,fem->vertices,loads,fem->materials,fem->parameters,kflag,pflag); 79 79 80 80 if (verbose) _printf_(" reducing matrix from g to f set\n"); … … 102 102 103 103 //Update inputs using new solution: 104 UpdateInputsFromSolutionx( fem->elements,fem->nodes, fem->vertices, fem->loads, fem->materials, fem->parameters,ug ,analysis_type, sub_analysis_type);104 UpdateInputsFromSolutionx( fem->elements,fem->nodes, fem->vertices, fem->loads, fem->materials, fem->parameters,ug); 105 105 106 106 //Deal with penalty loads 107 107 if (verbose) _printf_(" penalty constraints\n"); 108 PenaltyConstraintsx(&constraints_converged, &num_unstable_constraints, fem->elements,fem->nodes,fem->vertices,loads,fem->materials,fem->parameters ,analysis_type,sub_analysis_type);108 PenaltyConstraintsx(&constraints_converged, &num_unstable_constraints, fem->elements,fem->nodes,fem->vertices,loads,fem->materials,fem->parameters); 109 109 110 110 if(verbose)_printf_(" number of unstable constraints: %i\n",num_unstable_constraints); … … 146 146 kflag=1; pflag=0; //stiffness generation only 147 147 148 SystemMatricesx(&Kgg, &pg,fem->elements,fem->nodes,fem->vertices,loads,fem->materials,fem->parameters,kflag,pflag ,analysis_type,sub_analysis_type);148 SystemMatricesx(&Kgg, &pg,fem->elements,fem->nodes,fem->vertices,loads,fem->materials,fem->parameters,kflag,pflag); 149 149 Reducematrixfromgtofx(&Kff,&Kfs,Kgg,fem->Gmn,fem->nodesets); 150 150 MatFree(&Kgg);VecFree(&pg); -
issm/trunk/src/c/solvers/solver_linear.cpp
r4029 r4055 8 8 #include "../modules/modules.h" 9 9 10 void solver_linear(Vec* pug, FemModel* fem ,int analysis_type,int sub_analysis_type){10 void solver_linear(Vec* pug, FemModel* fem){ 11 11 12 12 /*parameters:*/ … … 33 33 //*Generate system matrices 34 34 if (verbose) _printf_(" Generating matrices\n"); 35 SystemMatricesx(&Kgg, &pg,fem->elements,fem->nodes,fem->vertices,fem->loads,fem->materials,fem->parameters,kflag,pflag ,analysis_type,sub_analysis_type);35 SystemMatricesx(&Kgg, &pg,fem->elements,fem->nodes,fem->vertices,fem->loads,fem->materials,fem->parameters,kflag,pflag); 36 36 37 37 if (verbose) _printf_(" Generating penalty matrices\n"); 38 38 //*Generate penalty system matrices 39 PenaltySystemMatricesx(Kgg, pg,NULL,fem->elements,fem->nodes,fem->vertices,fem->loads,fem->materials,fem->parameters,kflag,pflag ,analysis_type,sub_analysis_type);39 PenaltySystemMatricesx(Kgg, pg,NULL,fem->elements,fem->nodes,fem->vertices,fem->loads,fem->materials,fem->parameters,kflag,pflag); 40 40 41 41 /*!Reduce matrix from g to f size:*/ … … 56 56 57 57 //Update inputs using new solution: 58 UpdateInputsFromSolutionx( fem->elements,fem->nodes, fem->vertices, fem->loads, fem->materials, fem->parameters,ug ,analysis_type, sub_analysis_type);58 UpdateInputsFromSolutionx( fem->elements,fem->nodes, fem->vertices, fem->loads, fem->materials, fem->parameters,ug); 59 59 60 60 /*free ressources: */ -
issm/trunk/src/c/solvers/solver_thermal_nonlinear.cpp
r4029 r4055 8 8 #include "../modules/modules.h" 9 9 10 void solver_thermal_nonlinear(Vec* ptg,double* pmelting_offset,FemModel* fem ,int analysis_type,int sub_analysis_type){10 void solver_thermal_nonlinear(Vec* ptg,double* pmelting_offset,FemModel* fem){ 11 11 12 12 /*solution : */ … … 63 63 /*Compute Kgg_nopenalty and pg_nopenalty once for all: */ 64 64 if (count==1){ 65 SystemMatricesx(&Kgg_nopenalty, &pg_nopenalty,fem->elements,fem->nodes,fem->vertices,fem->loads,fem->materials,fem->parameters,kflag,pflag ,analysis_type,sub_analysis_type);65 SystemMatricesx(&Kgg_nopenalty, &pg_nopenalty,fem->elements,fem->nodes,fem->vertices,fem->loads,fem->materials,fem->parameters,kflag,pflag); 66 66 } 67 67 … … 71 71 72 72 //apply penalties each time 73 PenaltySystemMatricesx(Kgg, pg,&melting_offset,fem->elements,fem->nodes,fem->vertices,fem->loads,fem->materials,fem->parameters,kflag,pflag ,analysis_type,sub_analysis_type);73 PenaltySystemMatricesx(Kgg, pg,&melting_offset,fem->elements,fem->nodes,fem->vertices,fem->loads,fem->materials,fem->parameters,kflag,pflag); 74 74 } 75 75 else{ 76 SystemMatricesx(&Kgg, &pg,fem->elements,fem->nodes,fem->vertices,fem->loads,fem->materials,fem->parameters,kflag,pflag ,analysis_type,sub_analysis_type);76 SystemMatricesx(&Kgg, &pg,fem->elements,fem->nodes,fem->vertices,fem->loads,fem->materials,fem->parameters,kflag,pflag); 77 77 //apply penalties 78 PenaltySystemMatricesx(Kgg, pg,&melting_offset,fem->elements,fem->nodes,fem->vertices,fem->loads,fem->materials,fem->parameters,kflag,pflag ,analysis_type,sub_analysis_type);78 PenaltySystemMatricesx(Kgg, pg,&melting_offset,fem->elements,fem->nodes,fem->vertices,fem->loads,fem->materials,fem->parameters,kflag,pflag); 79 79 } 80 80 … … 108 108 //Deal with penalty loads 109 109 if (verbose) _printf_(" penalty constraints\n"); 110 PenaltyConstraintsx(&constraints_converged, &num_unstable_constraints, fem->elements,fem->nodes,fem->vertices,fem->loads,fem->materials,fem->parameters ,analysis_type,sub_analysis_type);110 PenaltyConstraintsx(&constraints_converged, &num_unstable_constraints, fem->elements,fem->nodes,fem->vertices,fem->loads,fem->materials,fem->parameters); 111 111 112 112 //Update inputs using new solution: 113 113 UpdateInputsFromVectorx( fem->elements,fem->nodes, fem->vertices, fem->loads, fem->materials, fem->parameters,tg,TemperatureEnum,VertexEnum); 114 UpdateInputsFromSolutionx(fem->elements,fem->nodes, fem->vertices, fem->loads, fem->materials, fem->parameters,tg ,analysis_type, sub_analysis_type);114 UpdateInputsFromSolutionx(fem->elements,fem->nodes, fem->vertices, fem->loads, fem->materials, fem->parameters,tg); 115 115 116 116 if (!converged){ -
issm/trunk/src/c/solvers/solvers.h
r4047 r4055 12 12 class FemModel; 13 13 14 void solver_thermal_nonlinear(Vec* ptg,double* pmelting_offset,FemModel* fem ,int analysis_type,int sub_analysis_type);15 void solver_diagnostic_nonlinear(Vec* pug,Mat* pK_ff0,Mat* pK_fs0, FemModel* fem ,bool conserve_loads,int analysis_type,int sub_analysis_type);16 void solver_linear(Vec* pug, FemModel* femmodel ,int analysis_type,int sub_analysis_type);17 void solver_adjoint(Vec* pug, FemModel* femmodel ,int analysis_type,int sub_analysis_type);14 void solver_thermal_nonlinear(Vec* ptg,double* pmelting_offset,FemModel* femmodel); 15 void solver_diagnostic_nonlinear(Vec* pug,Mat* pK_ff0,Mat* pK_fs0, FemModel* femmodel,bool conserve_loads); 16 void solver_linear(Vec* pug, FemModel* femmodel); 17 void solver_adjoint(Vec* pug, FemModel* femmodel); 18 18 19 19
Note:
See TracChangeset
for help on using the changeset viewer.