Changeset 19105 for issm/trunk/src
- Timestamp:
- 02/12/15 16:48:40 (10 years ago)
- Location:
- issm/trunk
- Files:
-
- 32 deleted
- 405 edited
- 235 copied
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk
- Property svn:ignore
-
old new 1 build-fw 2 build-ad 1 3 nightlylog 2 4 configure.sh
-
- Property svn:mergeinfo changed
/issm/trunk-jpl merged: 18302-18306,18308-18311,18313-18322,18326-18337,18339-18351,18353-18355,18357-18513,18515-19101
- Property svn:ignore
-
issm/trunk/src
- Property svn:mergeinfo changed
-
issm/trunk/src/c
- Property svn:ignore
-
issm/trunk/src/c/Makefile.am
r18301 r19105 1 AM_CPPFLAGS = @DAKOTAINCL@ @SHAPELIBINCL@ @PETSCINCL@ @SLEPCINCL@ @AMPIINCL@ @MPIINCL@ @METISINCL@ @CHACOINCL@ @SCOTCHINCL@ @PLAPACKINCL@ @BLASLAPACKINCL@ @MKLINCL@ @MUMPSINCL@ @TRIANGLEINCL@ @SPAIINCL@ @HYPREINCL@ @PROMETHEUSINCL@ @SUPERLUINCL@ @SPOOLESINCL@ @PASTIXINCL@ @MLINCL@ @TAOINCL@ @ADIC2INCL@ @ADOLCINCL@ @GSLINCL@ @BOOSTINCL@ @ANDROID_NDKINCL@ @METEOIOINCL@ @SNOWPACKINCL@ 1 AM_CPPFLAGS = @DAKOTAINCL@ @SHAPELIBINCL@ @PETSCINCL@ @SLEPCINCL@ @AMPIINCL@ @MPIINCL@ @METISINCL@ @CHACOINCL@ @SCOTCHINCL@ @PLAPACKINCL@ @BLASLAPACKINCL@ @MKLINCL@ @MUMPSINCL@ @TRIANGLEINCL@ @SPAIINCL@ @HYPREINCL@ @PROMETHEUSINCL@ @SUPERLUINCL@ @SPOOLESINCL@ @PASTIXINCL@ @MLINCL@ @TAOINCL@ @ADIC2INCL@ @ADOLCINCL@ @GSLINCL@ @BOOSTINCL@ @ANDROID_NDKINCL@ @METEOIOINCL@ @SNOWPACKINCL@ @PROJ4INCL@ 2 2 3 AUTOMAKE_OPTIONS = subdir-objects 3 4 … … 5 6 6 7 #Library declaration {{{ 7 lib_LIBRARIES = libISSMCore.a libISSMOverload.a 8 9 if SHAREDLIBS 10 lib_LTLIBRARIES = libISSMCore.la libISSMOverload.la libISSM.la 11 endif 8 9 lib_LTLIBRARIES = libISSMCore.la libISSMOverload.la 12 10 if WRAPPERS 13 if SHAREDLIBS14 11 lib_LTLIBRARIES += libISSMModules.la 15 endif16 lib_LIBRARIES += libISSMModules.a17 12 endif 18 13 #}}} … … 20 15 #Core sources 21 16 #Core sources{{{ 22 issm_sources = ./datastructures/DataSet.h\ 23 ./datastructures/DataSet.cpp\ 24 ./datastructures/Object.h\ 25 ./datastructures/datastructures.h\ 26 ./classes/classes.h\ 27 ./classes/gauss/Gauss.h\ 28 ./classes/gauss/GaussSeg.h\ 17 issm_sources = ./datastructures/DataSet.cpp\ 29 18 ./classes/gauss/GaussSeg.cpp\ 30 ./classes/gauss/GaussTria.h\31 19 ./classes/gauss/GaussTria.cpp\ 32 ./classes/gauss/GaussTetra.h\33 20 ./classes/gauss/GaussTetra.cpp\ 34 ./classes/gauss/GaussPenta.h\35 21 ./classes/gauss/GaussPenta.cpp\ 36 ./classes/Update.h\37 ./classes/FemModel.h\38 22 ./classes/FemModel.cpp\ 39 ./classes/Material.h\40 ./classes/Load.h\41 ./classes/Contour.h\42 ./classes/Loads/Friction.h\43 23 ./classes/Loads/Friction.cpp\ 44 ./classes/Inputs/TransientInput.h\45 24 ./classes/Inputs/TransientInput.cpp\ 46 25 ./classes/Constraints/SpcTransient.cpp\ 47 ./classes/Constraints/SpcTransient.h\48 ./classes/IndependentObject.h\49 26 ./classes/IndependentObject.cpp\ 50 ./classes/DependentObject.h\51 27 ./classes/DependentObject.cpp\ 52 ./classes/DofIndexing.h\53 28 ./classes/DofIndexing.cpp\ 54 ./classes/IoModel.h\55 29 ./classes/IoModel.cpp\ 56 ./classes/Contours.h\57 30 ./classes/Contours.cpp\ 58 ./classes/Nodes.h\59 31 ./classes/Nodes.cpp\ 60 ./classes/Vertices.h\61 32 ./classes/Vertices.cpp\ 62 ./classes/Node.h\63 33 ./classes/Node.cpp\ 64 ./classes/Segment.h\65 ./classes/Vertex.h\66 34 ./classes/Vertex.cpp\ 67 ./classes/Hook.h\68 35 ./classes/Hook.cpp\ 69 ./classes/ExternalResults/Results.h\70 36 ./classes/ExternalResults/Results.cpp\ 71 ./classes/ExternalResults/ExternalResult.h\72 ./classes/ExternalResults/GenericExternalResult.h\73 ./classes/Elements/Element.h\74 37 ./classes/Elements/Element.cpp\ 75 ./classes/Elements/Elements.h\76 38 ./classes/Elements/Elements.cpp\ 77 ./classes/Elements/ElementHook.h\78 39 ./classes/Elements/ElementHook.cpp\ 79 ./classes/Elements/Seg.h\80 40 ./classes/Elements/Seg.cpp\ 81 ./classes/Elements/SegRef.h\82 41 ./classes/Elements/SegRef.cpp\ 83 ./classes/Elements/Tria.h\84 42 ./classes/Elements/Tria.cpp\ 85 ./classes/Elements/TriaRef.h\86 43 ./classes/Elements/TriaRef.cpp\ 87 ./classes/Elements/Tetra.h\88 44 ./classes/Elements/Tetra.cpp\ 89 ./classes/Elements/TetraRef.h\90 45 ./classes/Elements/TetraRef.cpp\ 91 ./classes/Elements/Penta.h\92 46 ./classes/Elements/Penta.cpp\ 93 ./classes/Elements/PentaRef.h\94 47 ./classes/Elements/PentaRef.cpp\ 95 ./classes/Inputs/Inputs.h\96 48 ./classes/Inputs/Inputs.cpp\ 97 ./classes/Inputs/Input.h\98 ./classes/Inputs/InputLocal.h\99 ./classes/Inputs/SegInput.h\100 49 ./classes/Inputs/SegInput.cpp\ 101 ./classes/Inputs/TriaInput.h\102 50 ./classes/Inputs/TriaInput.cpp\ 103 ./classes/Inputs/BoolInput.h\104 51 ./classes/Inputs/BoolInput.cpp\ 105 ./classes/Inputs/IntInput.h\106 52 ./classes/Inputs/IntInput.cpp\ 107 ./classes/Inputs/DoubleInput.h\108 53 ./classes/Inputs/DoubleInput.cpp\ 109 ./classes/Inputs/DatasetInput.h\110 54 ./classes/Inputs/DatasetInput.cpp\ 111 ./classes/Materials/Materials.h\112 55 ./classes/Materials/Materials.cpp\ 113 ./classes/Materials/Matice.h\114 56 ./classes/Materials/Matice.cpp\ 115 ./classes/Materials/Matpar.h\116 57 ./classes/Materials/Matpar.cpp\ 117 ./classes/Constraints/Constraints.h\118 58 ./classes/Constraints/Constraints.cpp\ 119 ./classes/Constraints/Constraint.h\120 59 ./classes/Constraints/SpcStatic.cpp\ 121 ./classes/Constraints/SpcStatic.h\122 60 ./classes/Constraints/SpcDynamic.cpp\ 123 ./classes/Constraints/SpcDynamic.h\124 ./classes/Loads/Loads.h\125 61 ./classes/Loads/Loads.cpp\ 126 62 ./classes/Loads/Penpair.cpp\ 127 ./classes/Loads/Penpair.h\128 63 ./classes/Loads/Pengrid.cpp\ 129 ./classes/Loads/Pengrid.h\130 64 ./classes/Loads/Numericalflux.cpp\ 131 ./classes/Loads/Numericalflux.h\132 ./classes/matrix/matrixobjects.h\133 ./classes/matrix/ElementMatrix.h\134 65 ./classes/matrix/ElementMatrix.cpp\ 135 ./classes/matrix/ElementVector.h\136 66 ./classes/matrix/ElementVector.cpp\ 137 ./classes/Params/Parameters.h\138 67 ./classes/Params/Parameters.cpp\ 139 ./classes/Params/Param.h\140 ./classes/Params/GenericParam.h\141 68 ./classes/Params/BoolParam.cpp\ 142 ./classes/Params/BoolParam.h\143 69 ./classes/Params/IntParam.cpp\ 144 ./classes/Params/IntParam.h\145 70 ./classes/Params/IntVecParam.cpp\ 146 ./classes/Params/IntVecParam.h\147 71 ./classes/Params/IntMatParam.cpp\ 148 ./classes/Params/IntMatParam.h\149 72 ./classes/Params/DoubleParam.cpp\ 150 ./classes/Params/DoubleParam.h\151 73 ./classes/Params/FileParam.cpp\ 152 ./classes/Params/FileParam.h\153 74 ./classes/Params/StringArrayParam.cpp\ 154 ./classes/Params/StringArrayParam.h\155 75 ./classes/Params/DoubleMatParam.cpp\ 156 ./classes/Params/DoubleMatParam.h\157 76 ./classes/Params/DoubleTransientMatParam.cpp\ 158 ./classes/Params/DoubleTransientMatParam.h\159 77 ./classes/Params/DoubleMatArrayParam.cpp\ 160 ./classes/Params/DoubleMatArrayParam.h\161 78 ./classes/Params/DoubleVecParam.cpp\ 162 ./classes/Params/DoubleVecParam.h\163 79 ./classes/Params/StringParam.cpp\ 164 ./classes/Params/StringParam.h\165 ./classes/Params/MatrixParam.h\166 80 ./classes/Params/MatrixParam.cpp\ 167 ./classes/Params/VectorParam.h\168 81 ./classes/Params/VectorParam.cpp\ 169 ./classes/Params/TransientParam.h\170 82 ./classes/Params/TransientParam.cpp\ 171 ./classes/Params/DataSetParam.h\172 83 ./classes/Params/DataSetParam.cpp\ 173 ./classes/Profiler.h\174 84 ./classes/Profiler.cpp\ 175 ./shared/shared.h\176 ./shared/MemOps/MemOps.h\177 85 ./shared/MemOps/MemOps.cpp\ 178 ./shared/Matrix/matrix.h\179 86 ./shared/Matrix/MatrixUtils.cpp\ 180 ./shared/io/io.h\181 ./shared/io/Disk/diskio.h\182 87 ./shared/io/Disk/pfopen.cpp\ 183 88 ./shared/io/Disk/pfclose.cpp\ 184 89 ./shared/io/Disk/WriteLockFile.cpp\ 185 90 ./shared/io/Print/PrintfFunction.cpp\ 186 ./shared/io/Print/Print.h\187 ./shared/io/Comm/IssmComm.h\188 91 ./shared/io/Comm/IssmComm.cpp\ 189 92 ./shared/LatLong/Ll2xyx.cpp\ 190 93 ./shared/LatLong/Xy2llx.cpp\ 191 ./shared/FSanalyticals/fsanalyticals.h\192 94 ./shared/FSanalyticals/fsanalyticals.cpp\ 193 ./shared/Enum/Enum.h\194 ./shared/Enum/EnumDefinitions.h\195 95 ./shared/Enum/EnumToStringx.cpp\ 196 96 ./shared/Enum/StringToEnumx.cpp\ 197 ./shared/Numerics/numerics.h\198 ./shared/Numerics/types.h\199 ./shared/Numerics/constants.h\200 ./shared/Numerics/Verbosity.h\201 97 ./shared/Numerics/Verbosity.cpp\ 202 ./shared/Numerics/GaussPoints.h\203 98 ./shared/Numerics/GaussPoints.cpp\ 204 99 ./shared/Numerics/cross.cpp\ 205 ./shared/Numerics/isnan.h\206 100 ./shared/Numerics/isnan.cpp\ 207 101 ./shared/Numerics/cubic.cpp\ … … 209 103 ./shared/Numerics/extrema.cpp\ 210 104 ./shared/Numerics/XZvectorsToCoordinateSystem.cpp\ 211 ./shared/Numerics/OptPars.h\212 ./shared/Exceptions/exceptions.h\213 105 ./shared/Exceptions/Exceptions.cpp\ 214 106 ./shared/Sorting/binary_search.cpp\ 215 ./shared/Sorting/sorting.h\216 ./shared/Elements/elements.h\217 107 ./shared/Elements/Cuffey.cpp\ 108 ./shared/Elements/StressIntensityIntegralWeight.cpp\ 218 109 ./shared/Elements/Paterson.cpp\ 219 110 ./shared/Elements/Arrhenius.cpp\ … … 222 113 ./shared/Elements/PddSurfaceMassBalance.cpp\ 223 114 ./shared/Elements/ComputeDelta18oTemperaturePrecipitation.cpp\ 115 ./shared/Elements/ComputeMungsmTemperaturePrecipitation.cpp\ 224 116 ./shared/Elements/DrainageFunctionWaterfraction.cpp\ 225 ./shared/String/sharedstring.h\226 117 ./shared/String/DescriptorIndex.cpp\ 227 ./toolkits/metis/metisincludes.h\228 ./toolkits/issm/issmtoolkit.h\229 ./toolkits/issm/IssmToolkitUtils.h\230 118 ./toolkits/issm/IssmToolkitUtils.cpp\ 231 ./toolkits/issm/IssmAbsMat.h\232 ./toolkits/issm/IssmAbsVec.h\233 ./toolkits/issm/IssmDenseMat.h\234 ./toolkits/issm/IssmMat.h\235 ./toolkits/issm/IssmSeqVec.h\236 ./toolkits/issm/IssmVec.h\237 ./toolkits/issm/IssmSolver.h\238 119 ./toolkits/issm/IssmSolver.cpp\ 239 ./toolkits/issm/SparseRow.h\240 ./toolkits/issm/Bucket.h\241 ./toolkits/mpi/issmmpi.h\242 120 ./toolkits/mpi/issmmpi.cpp\ 243 ./toolkits/mpi/commops/commops.h\244 121 ./toolkits/mpi/commops/DetermineLocalSize.cpp\ 245 122 ./toolkits/mpi/commops/DetermineGlobalSize.cpp\ 246 123 ./toolkits/mpi/commops/DetermineRowRankFromLocalSize.cpp\ 247 124 ./toolkits/mpi/commops/GetOwnershipBoundariesFromRange.cpp\ 248 ./toolkits/adolc/adolcincludes.h\249 ./toolkits/adolc/AdolcEdf.h\250 ./toolkits/ToolkitOptions.h\251 125 ./toolkits/ToolkitOptions.cpp\ 252 ./toolkits/triangle/triangleincludes.h\253 ./toolkits/objects/toolkitobjects.h\254 ./toolkits/objects/Matrix.h\255 ./toolkits/objects/Vector.h\256 ./toolkits/objects/Solver.h\257 ./toolkitsenums.h\258 ./toolkits.h\259 ./modules/ModelProcessorx/ModelProcessorx.h\260 126 ./modules/ModelProcessorx/ModelProcessorx.cpp\ 261 127 ./modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp\ … … 271 137 ./modules/ModelProcessorx/CreateElementsVerticesAndMaterials.cpp\ 272 138 ./modules/ModelProcessorx/CreateNodes.cpp\ 273 ./modules/ParseToolkitsOptionsx/ParseToolkitsOptionsx.h\274 139 ./modules/ParseToolkitsOptionsx/ParseToolkitsOptionsx.cpp\ 275 ./modules/NodesDofx/NodesDofx.h\276 140 ./modules/NodesDofx/NodesDofx.cpp\ 277 ./modules/NodalValuex/NodalValuex.h\278 141 ./modules/NodalValuex/NodalValuex.cpp\ 279 ./modules/VerticesDofx/VerticesDofx.h\280 142 ./modules/VerticesDofx/VerticesDofx.cpp\ 281 ./modules/VertexCoordinatesx/VertexCoordinatesx.h\282 143 ./modules/VertexCoordinatesx/VertexCoordinatesx.cpp\ 283 ./modules/OutputResultsx/OutputResultsx.h\284 144 ./modules/OutputResultsx/OutputResultsx.cpp\ 285 ./modules/InputDepthAverageAtBasex/InputDepthAverageAtBasex.h\286 145 ./modules/InputDepthAverageAtBasex/InputDepthAverageAtBasex.cpp\ 287 ./modules/InputDuplicatex/InputDuplicatex.h\288 146 ./modules/InputDuplicatex/InputDuplicatex.cpp\ 289 ./modules/InputExtrudex/InputExtrudex.h\290 147 ./modules/InputExtrudex/InputExtrudex.cpp\ 291 ./modules/InputScalex/InputScalex.h\292 148 ./modules/InputScalex/InputScalex.cpp\ 293 ./modules/SurfaceAreax/SurfaceAreax.h\294 149 ./modules/SurfaceAreax/SurfaceAreax.cpp\ 295 ./modules/AllocateSystemMatricesx/AllocateSystemMatricesx.h\296 150 ./modules/AllocateSystemMatricesx/AllocateSystemMatricesx.cpp\ 297 ./modules/CreateJacobianMatrixx/CreateJacobianMatrixx.h\298 151 ./modules/CreateJacobianMatrixx/CreateJacobianMatrixx.cpp\ 299 ./modules/SystemMatricesx/SystemMatricesx.h\300 152 ./modules/SystemMatricesx/SystemMatricesx.cpp\ 301 ./modules/CreateNodalConstraintsx/CreateNodalConstraintsx.h\302 153 ./modules/CreateNodalConstraintsx/CreateNodalConstraintsx.cpp\ 303 ./modules/UpdateDynamicConstraintsx/UpdateDynamicConstraintsx.h\304 154 ./modules/UpdateDynamicConstraintsx/UpdateDynamicConstraintsx.cpp\ 305 ./modules/IoModelToConstraintsx/IoModelToConstraintsx.h\306 155 ./modules/IoModelToConstraintsx/IoModelToConstraintsx.cpp\ 307 ./modules/SetActiveNodesLSMx/SetActiveNodesLSMx.h\308 156 ./modules/SetActiveNodesLSMx/SetActiveNodesLSMx.cpp\ 309 ./modules/InputUpdateFromConstantx/InputUpdateFromConstantx.h\310 157 ./modules/InputUpdateFromConstantx/InputUpdateFromConstantx.cpp\ 311 ./modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.h\312 158 ./modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.cpp\ 313 ./modules/GetSolutionFromInputsx/GetSolutionFromInputsx.h\314 159 ./modules/GetSolutionFromInputsx/GetSolutionFromInputsx.cpp\ 315 ./modules/GetVectorFromInputsx/GetVectorFromInputsx.h\316 160 ./modules/GetVectorFromInputsx/GetVectorFromInputsx.cpp\ 317 ./modules/InputUpdateFromVectorx/InputUpdateFromVectorx.h\318 161 ./modules/InputUpdateFromVectorx/InputUpdateFromVectorx.cpp\ 319 ./modules/FloatingiceMeltingRatex/FloatingiceMeltingRatex.h\320 162 ./modules/FloatingiceMeltingRatex/FloatingiceMeltingRatex.cpp\ 321 ./modules/ConfigureObjectsx/ConfigureObjectsx.h\322 163 ./modules/ConfigureObjectsx/ConfigureObjectsx.cpp\ 323 ./modules/SpcNodesx/SpcNodesx.h\324 164 ./modules/SpcNodesx/SpcNodesx.cpp\ 325 ./modules/SurfaceMassBalancex/SurfaceMassBalancex.h\326 165 ./modules/SurfaceMassBalancex/SurfaceMassBalancex.cpp\ 327 ./modules/MeshPartitionx/MeshPartitionx.h\328 166 ./modules/Reducevectorgtofx/Reducevectorgtofx.cpp\ 329 ./modules/Reducevectorgtofx/Reducevectorgtofx.h\330 ./modules/Reduceloadx/Reduceloadx.h\331 167 ./modules/Reduceloadx/Reduceloadx.cpp\ 332 168 ./modules/ConstraintsStatex/ConstraintsStatex.cpp\ 333 ./modules/ConstraintsStatex/ConstraintsStatex.h\334 ./modules/ConstraintsStatex/ConstraintsStateLocal.h\335 ./modules/ResetConstraintsx/ResetConstraintsx.h\336 169 ./modules/ResetConstraintsx/ResetConstraintsx.cpp\ 337 ./modules/ResetFSBasalBoundaryConditionx/ResetFSBasalBoundaryConditionx.h\338 170 ./modules/ResetFSBasalBoundaryConditionx/ResetFSBasalBoundaryConditionx.cpp\ 339 171 ./modules/Solverx/Solverx.cpp\ 340 ./modules/Solverx/Solverx.h\341 172 ./modules/VecMergex/VecMergex.cpp\ 342 ./modules/VecMergex/VecMergex.h\343 173 ./modules/Mergesolutionfromftogx/Mergesolutionfromftogx.cpp\ 344 ./modules/Mergesolutionfromftogx/Mergesolutionfromftogx.h\345 174 ./cores/ProcessArguments.cpp\ 346 175 ./cores/ResetBoundaryConditions.cpp\ 347 ./cores/AnalysisConfiguration.cpp\348 176 ./cores/WrapperCorePointerFromSolutionEnum.cpp\ 349 177 ./cores/CorePointerFromSolutionEnum.cpp\ 350 178 ./cores/ad_core.cpp\ 179 ./cores/adgradient_core.cpp\ 351 180 ./main/EnvironmentInit.cpp\ 352 181 ./main/EnvironmentFinalize.cpp\ 353 ./analyses/EnumToAnalysis.h\354 182 ./analyses/EnumToAnalysis.cpp\ 355 ./analyses/Analysis.h\356 183 ./solutionsequences/solutionsequence_la.cpp\ 357 184 ./solutionsequences/solutionsequence_la_theta.cpp\ … … 359 186 ./solutionsequences/solutionsequence_nonlinear.cpp\ 360 187 ./solutionsequences/solutionsequence_newton.cpp\ 188 ./solutionsequences/solutionsequence_fct.cpp\ 361 189 ./solutionsequences/convergence.cpp\ 362 ./classes/Options/Options.h\363 190 ./classes/Options/Options.cpp\ 364 ./classes/Options/Option.h\365 ./classes/Options/GenericOption.h\366 191 ./classes/Options/OptionUtilities.cpp\ 367 ./classes/Options/OptionUtilities.h\368 192 ./classes/RiftStruct.cpp\ 369 ./classes/RiftStruct.h\370 193 ./modules/ModelProcessorx/Transient/UpdateElementsTransient.cpp \ 371 194 ./cores/transient_core.cpp\ … … 378 201 ./solutionsequences/solutionsequence_thermal_nonlinear.cpp\ 379 202 ./modules/ControlInputSetGradientx/ControlInputSetGradientx.cpp\ 380 ./modules/ControlInputSetGradientx/ControlInputSetGradientx.h\381 203 ./modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.cpp\ 382 ./modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.h\383 204 ./modules/SetControlInputsFromVectorx/SetControlInputsFromVectorx.cpp\ 384 ./modules/SetControlInputsFromVectorx/SetControlInputsFromVectorx.h\385 205 ./modules/ModelProcessorx/Control/CreateParametersControl.cpp\ 386 206 ./modules/ModelProcessorx/Control/UpdateElementsAndMaterialsControl.cpp\ 387 ./modules/InputControlUpdatex/InputControlUpdatex.h\388 207 ./modules/InputControlUpdatex/InputControlUpdatex.cpp\ 389 ./modules/SurfaceAbsVelMisfitx/SurfaceAbsVelMisfitx.h\390 208 ./modules/SurfaceAbsVelMisfitx/SurfaceAbsVelMisfitx.cpp\ 391 ./modules/SurfaceRelVelMisfitx/SurfaceRelVelMisfitx.h\392 209 ./modules/SurfaceRelVelMisfitx/SurfaceRelVelMisfitx.cpp\ 393 ./modules/SurfaceLogVelMisfitx/SurfaceLogVelMisfitx.h\394 210 ./modules/SurfaceLogVelMisfitx/SurfaceLogVelMisfitx.cpp\ 395 ./modules/SurfaceLogVxVyMisfitx/SurfaceLogVxVyMisfitx.h\396 211 ./modules/SurfaceLogVxVyMisfitx/SurfaceLogVxVyMisfitx.cpp\ 397 ./modules/SurfaceAverageVelMisfitx/SurfaceAverageVelMisfitx.h\398 212 ./modules/SurfaceAverageVelMisfitx/SurfaceAverageVelMisfitx.cpp\ 399 ./modules/ThicknessAbsMisfitx/ThicknessAbsMisfitx.h\400 213 ./modules/ThicknessAbsMisfitx/ThicknessAbsMisfitx.cpp\ 401 ./modules/Gradjx/Gradjx.h\402 214 ./modules/Gradjx/Gradjx.cpp\ 403 215 ./modules/DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.cpp\ 404 ./modules/DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.h\405 216 ./modules/ThicknessAlongGradientx/ThicknessAlongGradientx.cpp\ 406 ./modules/ThicknessAlongGradientx/ThicknessAlongGradientx.h\407 217 ./modules/ThicknessAcrossGradientx/ThicknessAcrossGradientx.cpp\ 408 ./modules/ThicknessAcrossGradientx/ThicknessAcrossGradientx.h\409 218 ./modules/RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.cpp\ 410 ./modules/RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.h\ 411 ./classes/Inputs/ControlInput.h\ 219 ./modules/RheologyBAbsGradientx/RheologyBAbsGradientx.cpp\ 412 220 ./classes/Inputs/ControlInput.cpp\ 413 221 ./shared/Numerics/BrentSearch.cpp\ 414 222 ./cores/control_core.cpp\ 415 223 ./cores/controltao_core.cpp\ 224 ./cores/controlad_core.cpp\ 416 225 ./cores/controlm1qn3_core.cpp\ 417 226 ./cores/controlvalidation_core.cpp\ … … 437 246 ./classes/Loads/Riftfront.cpp\ 438 247 ./modules/ConstraintsStatex/RiftConstraintsState.cpp\ 439 ./classes/Massfluxatgate.h \440 ./classes/Misfit.h \441 248 ./modules/ModelProcessorx/CreateOutputDefinitions.cpp\ 442 ./modules/OutputDefinitionsResponsex/OutputDefinitionsResponsex.h\443 249 ./modules/OutputDefinitionsResponsex/OutputDefinitionsResponsex.cpp\ 444 ./classes/Inputs/PentaInput.h\445 250 ./classes/Inputs/PentaInput.cpp\ 446 ./classes/Inputs/TetraInput.h\ 447 ./classes/Inputs/TetraInput.cpp\ 448 #}}} 251 ./classes/Inputs/TetraInput.cpp 252 #}}} 449 253 #DAKOTA sources {{{ 450 254 if DAKOTA 451 issm_sources += ./modules/InputUpdateFromDakotax/InputUpdateFromDakotax.h\ 452 ./modules/InputUpdateFromDakotax/InputUpdateFromDakotax.cpp\ 453 ./modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.h\ 255 issm_sources += ./modules/InputUpdateFromDakotax/InputUpdateFromDakotax.cpp\ 454 256 ./modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.cpp\ 455 ./modules/InputUpdateFromMatrixDakotax/InputUpdateFromMatrixDakotax.h\456 257 ./modules/InputUpdateFromMatrixDakotax/InputUpdateFromMatrixDakotax.cpp\ 457 258 ./modules/AverageOntoPartitionx/AverageOntoPartitionx.cpp\ 458 ./modules/AverageOntoPartitionx/AverageOntoPartitionx.h\459 259 ./modules/ModelProcessorx/Dakota/CreateParametersDakota.cpp\ 460 260 ./modules/ModelProcessorx/Dakota/UpdateElementsAndMaterialsDakota.cpp\ 461 261 ./cores/dakota_core.cpp\ 462 ./cores/DakotaSpawnCore.h\463 262 ./cores/DakotaSpawnCore.cpp 263 endif 264 #}}} 265 #BAMG sources {{{ 266 if BAMG 267 issm_sources += ./bamg/BamgGeom.cpp\ 268 ./bamg/BamgMesh.cpp\ 269 ./bamg/BamgOpts.cpp\ 270 ./bamg/CrackedEdge.cpp\ 271 ./bamg/Curve.cpp\ 272 ./bamg/Direction.cpp\ 273 ./bamg/Edge.cpp\ 274 ./bamg/GeomEdge.cpp\ 275 ./bamg/GeomSubDomain.cpp\ 276 ./bamg/GeomVertex.cpp\ 277 ./bamg/Geometry.cpp\ 278 ./bamg/ListofIntersectionTriangles.cpp\ 279 ./bamg/EigenMetric.cpp\ 280 ./bamg/Metric.cpp\ 281 ./bamg/BamgQuadtree.cpp\ 282 ./bamg/SetOfE4.cpp\ 283 ./bamg/SubDomain.cpp\ 284 ./bamg/AdjacentTriangle.cpp\ 285 ./bamg/Triangle.cpp\ 286 ./bamg/BamgVertex.cpp\ 287 ./bamg/VertexOnEdge.cpp\ 288 ./bamg/VertexOnGeom.cpp\ 289 ./bamg/VertexOnVertex.cpp\ 290 ./bamg/Mesh.cpp\ 291 ./shared/Bamg/BigPrimeNumber.cpp\ 292 ./modules/Bamgx/Bamgx.cpp\ 293 ./modules/BamgConvertMeshx/BamgConvertMeshx.cpp\ 294 ./modules/BamgTriangulatex/BamgTriangulatex.cpp 464 295 endif 465 296 #}}} … … 468 299 issm_sources += ./toolkits/petsc\ 469 300 ./toolkits/petsc/patches\ 470 ./toolkits/petsc/patches/SolverEnum.h\471 ./toolkits/petsc/patches/petscpatches.h\472 301 ./toolkits/petsc/patches/VecToMPISerial.cpp\ 473 302 ./toolkits/petsc/patches/MatToSerial.cpp\ … … 484 313 ./toolkits/petsc/patches/ISSMToPetscInsertMode.cpp\ 485 314 ./toolkits/petsc/patches/ISSMToPetscNormMode.cpp\ 486 ./toolkits/petsc/objects/petscobjects.h\487 ./toolkits/petsc/objects/PetscMat.h\488 315 ./toolkits/petsc/objects/PetscMat.cpp\ 489 ./toolkits/petsc/objects/PetscVec.h\490 316 ./toolkits/petsc/objects/PetscVec.cpp\ 491 ./toolkits/petsc/objects/PetscSolver.cpp\ 492 ./toolkits/petsc/objects/PetscSolver.h\ 493 ./toolkits/petsc/petscincludes.h 317 ./toolkits/petsc/objects/PetscSolver.cpp 494 318 endif 495 319 #}}} 496 320 #Mumps sources {{{ 497 321 if MUMPS 498 issm_sources += ./toolkits/mumps\ 499 ./toolkits/mumps/mumpsincludes.h\ 500 ./toolkits/mumps/MumpsSolve.cpp 322 issm_sources += ./toolkits/mumps/MumpsSolve.cpp 501 323 endif 502 324 #}}} 503 325 #Gsl sources {{{ 504 326 if GSL 505 issm_sources += ./toolkits/gsl\ 506 ./toolkits/gsl/gslincludes.h\ 507 ./toolkits/gsl/DenseGslSolve.cpp 327 issm_sources += ./toolkits/gsl/DenseGslSolve.cpp 328 endif 329 #}}} 330 #proj.4 sources {{{ 331 if PROJ4 332 issm_sources += ./modules/CoordinateSystemTransformx/CoordinateSystemTransformx.cpp 508 333 endif 509 334 #}}} … … 587 412 issm_sources += ./analyses/ThermalAnalysis.cpp 588 413 endif 589 if SMOOTHEDSURFACESLOPEX 590 issm_sources += ./analyses/SmoothedSurfaceSlopeXAnalysis.cpp 591 endif 592 if SMOOTHEDSURFACESLOPEY 593 issm_sources += ./analyses/SmoothedSurfaceSlopeYAnalysis.cpp 414 if SMOOTH 415 issm_sources += ./analyses/SmoothAnalysis.cpp 594 416 endif 595 417 if MESHDEFORMATION … … 598 420 if LEVELSET 599 421 issm_sources += ./analyses/LevelsetAnalysis.cpp 422 issm_sources += ./modules/Calvingx/Calvingx.cpp 600 423 endif 601 424 if EXTRAPOLATION … … 620 443 endif 621 444 #}}} 622 #Mpi sources {{{623 if MPI624 issm_sources += ./toolkits/issm/IssmMpiDenseMat.h\625 ./toolkits/issm/IssmMpiVec.h626 endif627 #}}}628 445 #Metis sources {{{ 629 446 if METIS 630 issm_sources += ./toolkits/metis/patches/metispatches.h\ 631 ./toolkits/metis/patches/METIS_PartMeshNodalPatch.cpp 447 issm_sources += ./toolkits/metis/patches/METIS_PartMeshNodalPatch.cpp 632 448 endif 633 449 #}}} … … 635 451 #Wrapper sources 636 452 #Bamg sources {{{ 637 bamg_sources = ./bamg/bamgobjects.h\ 638 ./bamg/BamgGeom.h\ 639 ./bamg/BamgGeom.cpp\ 640 ./bamg/BamgMesh.h\ 641 ./bamg/BamgMesh.cpp\ 642 ./bamg/BamgOpts.h\ 643 ./bamg/BamgOpts.cpp\ 644 ./bamg/CrackedEdge.h\ 645 ./bamg/CrackedEdge.cpp\ 646 ./bamg/Curve.h\ 647 ./bamg/Curve.cpp\ 648 ./bamg/Direction.h\ 649 ./bamg/Direction.cpp\ 650 ./bamg/DoubleAndInt.h\ 651 ./bamg/Edge.h\ 652 ./bamg/Edge.cpp\ 653 ./bamg/GeomEdge.h\ 654 ./bamg/GeomEdge.cpp\ 655 ./bamg/GeomSubDomain.h\ 656 ./bamg/GeomSubDomain.cpp\ 657 ./bamg/GeomVertex.h\ 658 ./bamg/GeomVertex.cpp\ 659 ./bamg/Geometry.cpp\ 660 ./bamg/Geometry.h\ 661 ./bamg/ListofIntersectionTriangles.cpp\ 662 ./bamg/ListofIntersectionTriangles.h\ 663 ./bamg/EigenMetric.cpp\ 664 ./bamg/Metric.cpp\ 665 ./bamg/Metric.h\ 666 ./bamg/BamgQuadtree.cpp\ 667 ./bamg/BamgQuadtree.h\ 668 ./bamg/R2.h\ 669 ./bamg/SetOfE4.cpp\ 670 ./bamg/SetOfE4.h\ 671 ./bamg/SubDomain.h\ 672 ./bamg/SubDomain.cpp\ 673 ./bamg/AdjacentTriangle.h\ 674 ./bamg/AdjacentTriangle.cpp\ 675 ./bamg/Triangle.cpp\ 676 ./bamg/det.h \ 677 ./bamg/Triangle.h\ 678 ./bamg/BamgVertex.cpp\ 679 ./bamg/BamgVertex.h\ 680 ./bamg/VertexOnEdge.h\ 681 ./bamg/VertexOnEdge.cpp\ 682 ./bamg/VertexOnGeom.h\ 683 ./bamg/VertexOnGeom.cpp\ 684 ./bamg/VertexOnVertex.h\ 685 ./bamg/VertexOnVertex.cpp\ 686 ./bamg/Mesh.cpp\ 687 ./bamg/Mesh.h\ 688 ./shared/Bamg/Abs.h \ 689 ./shared/Bamg/BigPrimeNumber.h\ 690 ./shared/Bamg/BigPrimeNumber.cpp\ 691 ./shared/Bamg/BinaryRand.h \ 692 ./shared/Bamg/Exchange.h \ 693 ./shared/Bamg/extrema.h \ 694 ./shared/Bamg/HeapSort.h \ 695 ./shared/Bamg/OppositeAngle.h \ 696 ./modules/Bamgx/Bamgx.cpp\ 697 ./modules/Bamgx/Bamgx.h\ 698 ./modules/BamgConvertMeshx/BamgConvertMeshx.cpp\ 699 ./modules/BamgConvertMeshx/BamgConvertMeshx.h\ 700 ./modules/BamgTriangulatex/BamgTriangulatex.cpp\ 701 ./modules/BamgTriangulatex/BamgTriangulatex.h 702 #}}} 703 #Kriging sources {{{ 704 if KRIGING 705 kriging_sources = ./classes/kriging/Observations.h\ 706 ./classes/kriging/Observations.cpp\ 707 ./classes/kriging/Variogram.h \ 708 ./classes/kriging/GaussianVariogram.h\ 709 ./classes/kriging/GaussianVariogram.cpp\ 710 ./classes/kriging/ExponentialVariogram.h\ 711 ./classes/kriging/ExponentialVariogram.cpp\ 712 ./classes/kriging/SphericalVariogram.h\ 713 ./classes/kriging/SphericalVariogram.cpp\ 714 ./classes/kriging/PowerVariogram.h\ 715 ./classes/kriging/PowerVariogram.cpp\ 716 ./classes/kriging/Quadtree.h\ 717 ./classes/kriging/Quadtree.cpp\ 718 ./classes/kriging/Observation.h\ 719 ./classes/kriging/Observation.cpp\ 720 ./modules/Krigingx/Krigingx.cpp\ 721 ./modules/Krigingx/Krigingx.h 722 issm_sources +=$(kriging_sources) 723 issm_sources +=./modules/Krigingx/pKrigingx.cpp 724 endif 453 725 454 #}}} 726 455 #Kml sources {{{ 727 kml_sources = ./modules/Exp2Kmlx/Exp2Kmlx.h\ 728 ./modules/Exp2Kmlx/Exp2Kmlx.cpp\ 729 ./modules/Kml2Expx/Kml2Expx.h\ 456 kml_sources = ./modules/Exp2Kmlx/Exp2Kmlx.cpp\ 730 457 ./modules/Kml2Expx/Kml2Expx.cpp\ 731 ./modules/Shp2Kmlx/Shp2Kmlx.h\732 458 ./modules/Shp2Kmlx/Shp2Kmlx.cpp\ 733 ./modules/KMLFileReadx/KMLFileReadx.h\734 459 ./modules/KMLFileReadx/KMLFileReadx.cpp\ 735 ./modules/KMLMeshWritex/KMLMeshWritex.h\736 460 ./modules/KMLMeshWritex/KMLMeshWritex.cpp\ 737 ./modules/KMLOverlayx/KMLOverlayx.h\738 461 ./modules/KMLOverlayx/KMLOverlayx.cpp\ 739 ./kml/kmlobjects.h\740 462 ./kml/KML_Attribute.cpp\ 741 ./kml/KML_Attribute.h\742 463 ./kml/KML_Comment.cpp\ 743 ./kml/KML_Comment.h\744 464 ./kml/KML_ColorStyle.cpp\ 745 ./kml/KML_ColorStyle.h\746 465 ./kml/KML_Container.cpp\ 747 ./kml/KML_Container.h\748 466 ./kml/KML_Document.cpp\ 749 ./kml/KML_Document.h\750 467 ./kml/KML_Feature.cpp\ 751 ./kml/KML_Feature.h\752 468 ./kml/KML_File.cpp\ 753 ./kml/KML_File.h\754 469 ./kml/KML_Folder.cpp\ 755 ./kml/KML_Folder.h\756 470 ./kml/KML_Geometry.cpp\ 757 ./kml/KML_Geometry.h\758 471 ./kml/KML_GroundOverlay.cpp\ 759 ./kml/KML_GroundOverlay.h\760 472 ./kml/KML_Icon.cpp\ 761 ./kml/KML_Icon.h\762 473 ./kml/KML_LatLonBox.cpp\ 763 ./kml/KML_LatLonBox.h\764 474 ./kml/KML_LinearRing.cpp\ 765 ./kml/KML_LinearRing.h\766 475 ./kml/KML_LineString.cpp\ 767 ./kml/KML_LineString.h\768 476 ./kml/KML_LineStyle.cpp\ 769 ./kml/KML_LineStyle.h\770 477 ./kml/KML_MultiGeometry.cpp\ 771 ./kml/KML_MultiGeometry.h\772 478 ./kml/KML_Object.cpp\ 773 ./kml/KML_Object.h\774 479 ./kml/KML_Overlay.cpp\ 775 ./kml/KML_Overlay.h\776 480 ./kml/KML_Point.cpp\ 777 ./kml/KML_Point.h\778 481 ./kml/KML_Placemark.cpp\ 779 ./kml/KML_Placemark.h\780 482 ./kml/KML_Polygon.cpp\ 781 ./kml/KML_Polygon.h\782 483 ./kml/KML_PolyStyle.cpp\ 783 ./kml/KML_PolyStyle.h\784 484 ./kml/KML_Style.cpp\ 785 ./kml/KML_Style.h\786 485 ./kml/KML_StyleSelector.cpp\ 787 ./kml/KML_StyleSelector.h\788 486 ./kml/KML_SubStyle.cpp\ 789 ./kml/KML_SubStyle.h\790 487 ./kml/KML_Unknown.cpp\ 791 ./kml/KML_Unknown.h\ 792 ./kml/KMLFileReadUtils.cpp\ 793 ./kml/KMLFileReadUtils.h 488 ./kml/KMLFileReadUtils.cpp 794 489 #}}} 795 490 #Modules sources{{{ 796 modules_sources= ./shared/Threads/issm_threads.h\ 797 ./shared/Threads/LaunchThread.cpp\ 491 modules_sources= ./shared/Threads/LaunchThread.cpp\ 798 492 ./shared/Threads/PartitionRange.cpp\ 799 ./shared/Exp/exp.h\800 493 ./shared/Exp/exp.cpp\ 801 ./shared/TriMesh/trimesh.h\802 494 ./shared/TriMesh/AssociateSegmentToElement.cpp\ 803 495 ./shared/TriMesh/GridInsideHole.cpp\ … … 805 497 ./shared/TriMesh/SplitMeshForRifts.cpp\ 806 498 ./shared/TriMesh/TriMeshUtils.cpp\ 807 ./modules/TriaSearchx/TriaSearchx.h\808 499 ./modules/TriaSearchx/TriaSearchx.cpp\ 809 ./modules/TriMeshx/TriMeshx.h\810 500 ./modules/TriMeshx/TriMeshx.cpp\ 811 ./modules/TriMeshProcessRiftsx/TriMeshProcessRiftsx.h\812 501 ./modules/TriMeshProcessRiftsx/TriMeshProcessRiftsx.cpp\ 813 ./modules/PointCloudFindNeighborsx/PointCloudFindNeighborsx.h\814 502 ./modules/PointCloudFindNeighborsx/PointCloudFindNeighborsx.cpp\ 815 503 ./modules/PointCloudFindNeighborsx/PointCloudFindNeighborsxt.cpp\ 816 504 ./modules/InterpFromGridToMeshx/InterpFromGridToMeshx.cpp\ 817 ./modules/InterpFromGridToMeshx/InterpFromGridToMeshx.h\818 505 ./modules/InterpFromMesh2dx/InterpFromMesh2dx.cpp\ 819 506 ./modules/InterpFromMesh2dx/InterpFromMesh2dxt.cpp\ 820 ./modules/InterpFromMesh2dx/InterpFromMesh2dx.h\821 507 ./modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp\ 822 ./modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.h\823 508 ./modules/InterpFromMeshToMesh3dx/InterpFromMeshToMesh3dx.cpp\ 824 ./modules/InterpFromMeshToMesh3dx/InterpFromMeshToMesh3dx.h\825 509 ./modules/InterpFromMeshToGridx/InterpFromMeshToGridx.cpp\ 826 ./modules/InterpFromMeshToGridx/InterpFromMeshToGridx.h\827 510 ./modules/MeshProfileIntersectionx/MeshProfileIntersectionx.cpp\ 828 ./modules/MeshProfileIntersectionx/MeshProfileIntersectionx.h\829 511 ./modules/ContourToMeshx/ContourToMeshx.cpp\ 830 512 ./modules/ContourToMeshx/ContourToMeshxt.cpp\ 831 ./modules/ContourToMeshx/ContourToMeshx.h\ 513 ./modules/ExpToLevelSetx/ExpToLevelSetx.cpp\ 514 ./modules/ExpToLevelSetx/ExpToLevelSetxt.cpp\ 832 515 ./modules/ContourToNodesx/ContourToNodesx.cpp\ 833 ./modules/ContourToNodesx/ContourToNodesx.h\834 516 ./modules/NodeConnectivityx/NodeConnectivityx.cpp\ 835 ./modules/NodeConnectivityx/NodeConnectivityx.h\836 517 ./modules/ElementConnectivityx/ElementConnectivityx.cpp\ 837 ./modules/ElementConnectivityx/ElementConnectivityx.h\ 838 ./modules/PropagateFlagsFromConnectivityx/PropagateFlagsFromConnectivityx.cpp\ 839 ./modules/PropagateFlagsFromConnectivityx/PropagateFlagsFromConnectivityx.h 518 ./modules/PropagateFlagsFromConnectivityx/PropagateFlagsFromConnectivityx.cpp 840 519 if CHACO 841 modules_sources+= ./modules/Chacox/Chacox.h\ 842 ./modules/Chacox/Chacox.cpp\ 520 modules_sources+= ./modules/Chacox/Chacox.cpp\ 843 521 ./modules/Chacox/input_parse.cpp\ 844 522 ./modules/Chacox/chaco_seconds.cpp\ … … 846 524 endif 847 525 if SCOTCH 848 modules_sources+= ./modules/Scotchx/Scotchx.cpp\ 849 ./modules/Scotchx/Scotchx.h 850 endif 851 #}}} 526 modules_sources+= ./modules/Scotchx/Scotchx.cpp 527 endif 528 #}}} 529 530 #kriging (WRAPPER and executable) 531 #Kriging sources {{{ 532 if KRIGING 533 issm_sources += ./classes/kriging/Observations.cpp\ 534 ./classes/kriging/GaussianVariogram.cpp\ 535 ./classes/kriging/ExponentialVariogram.cpp\ 536 ./classes/kriging/SphericalVariogram.cpp\ 537 ./classes/kriging/PowerVariogram.cpp\ 538 ./classes/kriging/Quadtree.cpp\ 539 ./classes/kriging/Covertree.cpp\ 540 ./classes/kriging/Observation.cpp\ 541 ./modules/Krigingx/pKrigingx.cpp 542 543 modules_sources +=./modules/Krigingx/Krigingx.cpp\ 544 ./modules/Krigingx/pKrigingx.cpp 545 endif 852 546 #}}} 853 547 #Library flags and sources {{{ 854 ALLCXXFLAGS= -fPIC -D_GNU_SOURCE -fno-omit-frame-pointer -pthread -D_CPP_ $(CXXFLAGS) $(CXXOPTFLAGS) 855 856 libISSMCore_a_SOURCES = $(issm_sources) 857 libISSMCore_a_CXXFLAGS = $(ALLCXXFLAGS) $(DAKOTAFLAGS) 858 libISSMCore_a_FFLAGS = $(AM_FFLAGS) 859 860 if SHAREDLIBS 861 libISSM_la_SOURCES = main/issm.cpp 862 libISSM_la_LIBADD = libISSMCore.la libISSMOverload.la 548 ALLCXXFLAGS= -fPIC $(CXXFLAGS) $(CXXOPTFLAGS) 863 549 864 550 libISSMCore_la_SOURCES = $(issm_sources) 865 libISSMCore_la_ LIBADD = $(PETSCLIB) $(TAOLIB) $(M1QN3LIB) $(PLAPACKLIB) $(MUMPSLIB) $(SUPERLULIB) $(SPOOLESLIB) $(SCALAPACKLIB) $(BLACSLIB) $(HYPRELIB) $(SPAILIB) $(PROMETHEUSLIB) $(PASTIXLIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MKLLIB) $(MPILIB) $(MATHLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(OSLIBS) $(GSLLIB) $(ADOLCLIB) $(AMPILIB) $(METEOIOLIB) $(SNOWPACKLIB)551 libISSMCore_la_CXXFLAGS = $(ALLCXXFLAGS) $(DAKOTAFLAGS) 866 552 libISSMCore_la_FFLAGS = $(AM_FFLAGS) 867 endif 553 554 libISSMCore_la_LIBADD = $(PETSCLIB) $(TAOLIB) $(M1QN3LIB) $(PLAPACKLIB) $(MUMPSLIB) $(SUPERLULIB) $(SPOOLESLIB) $(SCALAPACKLIB) $(BLACSLIB) $(HYPRELIB) $(SPAILIB) $(PROMETHEUSLIB) $(PASTIXLIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MKLLIB) $(MPILIB) $(MATHLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(OSLIBS) $(GSLLIB) $(ADOLCLIB) $(AMPILIB) $(METEOIOLIB) $(SNOWPACKLIB) 868 555 869 556 if WRAPPERS 870 libISSMModules_ a_SOURCES = $(modules_sources)871 libISSMModules_ a_SOURCES += $(bamg_sources)557 libISSMModules_la_SOURCES = $(modules_sources) 558 libISSMModules_la_SOURCES += $(bamg_sources) 872 559 if KRIGING 873 libISSMModules_ a_SOURCES += $(kriging_sources)560 libISSMModules_la_SOURCES += $(kriging_sources) 874 561 endif 875 562 if KML 876 libISSMModules_a_SOURCES += $(kml_sources) 877 endif 878 libISSMModules_a_CXXFLAGS = $(ALLCXXFLAGS) 879 libISSMModules_a_LIBADD = ./libISSMCore.a 880 if SHAREDLIBS 881 libISSMModules_la_SOURCES = $(libISSMModules_a_SOURCES) 563 libISSMModules_la_SOURCES += $(kml_sources) 564 endif 565 libISSMModules_la_CXXFLAGS = $(ALLCXXFLAGS) 566 if STANDALONE_LIBRARIES 567 libISSMModules_la_LIBADD = ./libISSMCore.la 568 else 569 libISSMModules_la_LIBADD = ./libISSMCore.la $(TRIANGLELIB) 882 570 endif 883 571 endif … … 888 576 AM_LDFLAGS = -avoid-version 889 577 endif 578 579 if STANDALONE_EXECUTABLES 580 issm_LDFLAGS = -static 581 endif 582 583 if STANDALONE_LIBRARIES 584 libISSMCore_la_LDFLAGS = -static 585 libISSMOverload_la_LDFLAGS = -static 586 if WRAPPERS 587 libISSMModules_la_LDFLAGS = -static 588 endif 589 endif 590 890 591 #}}} 891 592 #Overload library, to overload any non-standard symbols. {{{ 892 libISSMOverload_ a_SOURCES = ./shared/String/ApiPrintf.cpp893 894 libISSMOverload_ a_CFLAGS = -fPIC -D_C_ $(COPTFLAGS) $(CFLAGS)593 libISSMOverload_la_SOURCES = ./shared/String/ApiPrintf.cpp 594 595 libISSMOverload_la_CFLAGS = -fPIC -D_C_ $(COPTFLAGS) $(CFLAGS) 895 596 #}}} 896 597 … … 907 608 908 609 #Standard libraries 909 LDADD = ./libISSMCore.a ./libISSMOverload.a 610 LDADD = ./libISSMCore.la ./libISSMOverload.la 611 if WRAPPERS 612 LDADD += ./libISSMModules.la $(TRIANGLELIB) 613 endif 910 614 911 615 #External packages 912 LDADD += $(PETSCLIB) $(TAOLIB) $(M1QN3LIB) $(PLAPACKLIB) $(MUMPSLIB) $(SUPERLULIB) $(SPOOLESLIB) $(SCALAPACKLIB) $(BLACSLIB) $(HYPRELIB) $(SPAILIB) $(PROMETHEUSLIB) $(PASTIXLIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MKLLIB) $(MPILIB) $(MATHLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(OSLIBS) $(GSLLIB) $(AMPILIB) $(ADOLCLIB) $(MPILIB) $(METEOIOLIB) $(SNOWPACKLIB) 616 LDADD += $(PETSCLIB) $(TAOLIB) $(M1QN3LIB) $(PLAPACKLIB) $(MUMPSLIB) $(SUPERLULIB) $(SPOOLESLIB) $(SCALAPACKLIB) $(BLACSLIB) $(HYPRELIB) $(SPAILIB) $(PROMETHEUSLIB) $(PASTIXLIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MKLLIB) $(MPILIB) $(MATHLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(OSLIBS) $(GSLLIB) $(AMPILIB) $(ADOLCLIB) $(MPILIB) $(METEOIOLIB) $(SNOWPACKLIB) $(PROJ4LIB) 913 617 914 618 if FORTRAN … … 916 620 endif 917 621 918 issm_SOURCES = main/issm. h main/globals.h main/issm.cpp919 issm_CXXFLAGS= -fPIC $(CXXFLAGS) $(CXXOPTFLAGS) $(COPTFLAGS)622 issm_SOURCES = main/issm.cpp 623 issm_CXXFLAGS= -fPIC 920 624 921 625 if KRIGING 922 626 bin_PROGRAMS += kriging 923 kriging_SOURCES = main/ issm.h main/globals.h main/kriging.cpp627 kriging_SOURCES = main/kriging.cpp 924 628 kriging_CXXFLAGS= -fPIC $(CXXFLAGS) $(CXXOPTFLAGS) $(COPTFLAGS) 925 629 endif … … 927 631 #Automatic differentiation (must be done at the end) {{{ 928 632 if ADIC2 929 lib_L IBRARIES += libAD.a libISSMRose.a633 lib_LTLIBRARIES += libAD.la libISSMRose.la 930 634 931 635 #ADIC2 library, for automatic differentiation 932 636 #libAD_a_SOURCES = ./mini1.ad.c 933 libAD_ a_SOURCES =934 libAD_ a_CFLAGS = -fPIC -D_C_ $(COPTFLAGS)637 libAD_la_SOURCES = 638 libAD_la_CFLAGS = -fPIC -D_C_ $(COPTFLAGS) 935 639 936 640 #test rose preprocessing 937 641 %.r2cpp.cpp : %.cpp 938 642 testTranslator -rose:o $@ -rose:skipfinalCompileStep -DHAVE_CONFIG_H -D_C_ -I. -I../.. $(INCLUDES) $< 939 libISSMRose_ a_SOURCES = $(libISSMCore_a_SOURCES:.cpp=.r2cpp.cpp)940 libISSMRose_ a_CXXFLAGS= -fPIC -D_C_ $(CXXOPTFLAGS)643 libISSMRose_la_SOURCES = $(libISSMCore_a_SOURCES:.cpp=.r2cpp.cpp) 644 libISSMRose_la_CXXFLAGS= -fPIC -D_C_ $(CXXOPTFLAGS) 941 645 942 646 #Automatic differentiation rules: … … 950 654 issmRose_exe_CXXFLAGS= -fPIC $(CXXOPTFLAGS) $(COPTFLAGS) 951 655 LDADD += $(ADIC2LIB) 952 953 656 endif #}}} -
issm/trunk/src/c/analyses/AdjointBalancethickness2Analysis.cpp
r18301 r19105 6 6 7 7 /*Model processor*/ 8 void AdjointBalancethickness2Analysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 9 _error_("not implemented yet"); 10 }/*}}}*/ 11 void AdjointBalancethickness2Analysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 12 _error_("not implemented yet"); 13 }/*}}}*/ 14 void AdjointBalancethickness2Analysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 15 _error_("not implemented yet"); 16 }/*}}}*/ 8 17 int AdjointBalancethickness2Analysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/ 9 18 return 1; 10 19 }/*}}}*/ 20 void AdjointBalancethickness2Analysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ 21 _error_("not implemented yet"); 22 }/*}}}*/ 11 23 void AdjointBalancethickness2Analysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 12 _error_("not implemented yet");13 }/*}}}*/14 void AdjointBalancethickness2Analysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/15 _error_("not implemented yet");16 }/*}}}*/17 void AdjointBalancethickness2Analysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/18 _error_("not implemented yet");19 }/*}}}*/20 void AdjointBalancethickness2Analysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/21 _error_("not implemented yet");22 }/*}}}*/23 void AdjointBalancethickness2Analysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/24 24 _error_("not implemented yet"); 25 25 }/*}}}*/ … … 48 48 /*Intermediaries */ 49 49 int num_responses,i; 50 IssmDouble hobs,hu2,weight,Jdet; 51 IssmDouble NUMxH2,NUMyH2,DENH2; 52 IssmDouble NUMxUbar,NUMyUbar,DENUbar; 53 IssmDouble vxobs,vyobs,vxobsbar,vyobsbar,vbarobs2,vbarobs; 54 IssmDouble nux,nuy,phi,dphi[2]; 50 IssmDouble vx,vy,vel,Jdet; 51 IssmDouble surface,surfaceobs,weight; 55 52 int *responses = NULL; 56 53 IssmDouble *xyz_list = NULL; … … 68 65 element->FindParam(&num_responses,InversionNumCostFunctionsEnum); 69 66 element->FindParam(&responses,NULL,InversionCostFunctionsEnum); 70 Input* thicknessobs_input = element->GetInput(InversionThicknessObsEnum); _assert_(thicknessobs_input); 67 Input* surface_input = element->GetInput(SurfaceEnum); _assert_(surface_input); 68 Input* surfaceobs_input = element->GetInput(InversionSurfaceObsEnum); _assert_(surfaceobs_input); 71 69 Input* weights_input = element->GetInput(InversionCostFunctionsCoefficientsEnum); _assert_(weights_input); 72 Input* potential_input = element->GetInput(PotentialEnum); _assert_(potential_input); 73 Input* vxobs_input = element->GetInput(BalancethicknessVxObsEnum); _assert_(vxobs_input); 74 Input* vyobs_input = element->GetInput(BalancethicknessVyObsEnum); _assert_(vyobs_input); 75 Input* nux_input = element->GetInput(BalancethicknessNuxEnum); _assert_(nux_input); 76 Input* nuy_input = element->GetInput(BalancethicknessNuyEnum); _assert_(nuy_input); 70 Input* vx_input = element->GetInput(VxEnum); _assert_(vx_input); 71 Input* vy_input = element->GetInput(VyEnum); _assert_(vy_input); 77 72 78 73 /* Start looping on the number of gaussian points: */ … … 85 80 element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss); 86 81 87 vxobs_input->GetInputValue(&vxobs,gauss); 88 vyobs_input->GetInputValue(&vyobs,gauss); 89 nux_input->GetInputValue(&nux,gauss); 90 nuy_input->GetInputValue(&nuy,gauss); 91 potential_input->GetInputValue(&phi,gauss); 92 potential_input->GetInputDerivativeValue(&dphi[0],xyz_list,gauss); 93 thicknessobs_input->GetInputValue(&hobs,gauss); 94 95 vxobsbar = nux*vxobs; 96 vyobsbar = nuy*vyobs; 97 98 vbarobs2 = (nux*nux*vxobs*vxobs + nuy*nuy*vyobs*vyobs); 99 vbarobs = sqrt(vbarobs2); 100 hu2 = hobs*hobs*vbarobs2; 101 102 /*H^2 - Hobs^2*/ 103 NUMxH2 = 2.*dbasis[0]*dphi[0]*(dphi[0]*dphi[0] + dphi[1]*dphi[1] - hu2); 104 NUMyH2 = 2.*dbasis[1]*dphi[1]*(dphi[0]*dphi[0] + dphi[1]*dphi[1] - hu2); 105 DENH2 = vbarobs2*vbarobs2+1.e-14; 106 107 /*Ubar-Ubar_obs*/ 108 NUMxUbar = (vyobsbar*dphi[0]*dphi[1] - vxobsbar*dphi[1]*dphi[1])*vbarobs*dbasis[0]; 109 NUMyUbar = (vyobsbar*dphi[0]*dphi[0] - vxobsbar*dphi[0]*dphi[1])*vbarobs*dbasis[1]; 110 DENUbar = pow(dphi[0]*dphi[0] + dphi[1]*dphi[1],3./2.)+1.e-14; 82 surface_input->GetInputValue(&surface, gauss); 83 surfaceobs_input->GetInputValue(&surfaceobs, gauss); 111 84 112 85 /*Loop over all requested responses*/ … … 115 88 116 89 switch(responses[resp]){ 117 case Balancethickness2MisfitEnum: 118 /*J = (H^2 - Hobs^2)^2*/ 119 //for(i=0;i<numnodes;i++) pe->values[i]+=(NUMxH2+NUMyH2)/DENH2 *weight*Jdet*gauss->weight; NOT WORKING 120 /*J = phi^2*/ 121 //for(i=0;i<numnodes;i++) pe->values[i]+= phi*basis[i]*weight*Jdet*gauss->weight; OK 122 /*J = (ubar - nux*uobs)^2*/ 123 for(i=0;i<numnodes;i++) pe->values[i]+=(NUMxUbar-NUMyUbar)/DENUbar *weight*Jdet*gauss->weight; 90 case SurfaceAbsMisfitEnum: 91 for(i=0;i<numnodes;i++) pe->values[i]+=(surfaceobs-surface)*weight*Jdet*gauss->weight*basis[i]; 124 92 break; 125 93 default: … … 136 104 delete gauss; 137 105 return pe; 138 }/*}}}*/ 139 void AdjointBalancethickness2Analysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 140 _error_("not implemented yet"); 141 }/*}}}*/ 142 void AdjointBalancethickness2Analysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 106 107 }/*}}}*/ 108 void AdjointBalancethickness2Analysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 109 _error_("not implemented yet"); 110 }/*}}}*/ 111 void AdjointBalancethickness2Analysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 143 112 /*The gradient of the cost function is calculated in 2 parts. 144 113 * … … 158 127 element->FindParam(&responses,NULL,InversionCostFunctionsEnum); 159 128 160 /*Check that control_type is supported*/161 if(control_type!=BalancethicknessApparentMassbalanceEnum){162 _error_("Control "<<EnumToStringx(control_type)<<" not supported");163 }164 165 129 /*Deal with first part (partial derivative a J with respect to k)*/ 166 130 for(resp=0;resp<num_responses;resp++) switch(responses[resp]){ 167 case Balancethickness2MisfitEnum: /*Nothing, \partial J/\partial k = 0*/ break; 131 case SurfaceAbsMisfitEnum: 132 /*Nothing, \partial J/\partial k = 0*/ 133 break; 168 134 default: _error_("response " << EnumToStringx(responses[resp]) << " not supported yet"); 169 135 } … … 171 137 /*Deal with second term*/ 172 138 switch(control_type){ 173 case BalancethicknessApparentMassbalanceEnum: GradientJAdot(element,gradient,control_index); break; 139 case BalancethicknessOmegaEnum: GradientJOmega(element,gradient,control_index); break; 140 case BalancethicknessThickeningRateEnum: GradientJdHdt( element,gradient,control_index); break; 174 141 default: _error_("control type not supported yet: " << EnumToStringx(control_type)); 175 142 } … … 179 146 180 147 }/*}}}*/ 181 void AdjointBalancethickness2Analysis::GradientJAdot(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/148 void AdjointBalancethickness2Analysis::GradientJdHdt(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 182 149 183 150 /*Intermediaries*/ 184 IssmDouble Jdet,weight; 185 IssmDouble lambda; 151 IssmDouble lambda,Jdet; 186 152 IssmDouble *xyz_list= NULL; 187 153 … … 197 163 element->GetVerticesCoordinates(&xyz_list); 198 164 element->GradientIndexing(&vertexpidlist[0],control_index); 199 Input* adjoint_input = element->GetInput(AdjointEnum); _assert_(adjoint_input); 200 Input* weights_input = element->GetInput(InversionCostFunctionsCoefficientsEnum); _assert_(weights_input); 165 Input* adjoint_input = element->GetInput(AdjointEnum); _assert_(adjoint_input); 201 166 202 167 Gauss* gauss=element->NewGauss(2); … … 206 171 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 207 172 element->NodalFunctionsP1(basis,gauss); 208 weights_input->GetInputValue(&weight,gauss,Balancethickness2MisfitEnum); 173 209 174 adjoint_input->GetInputValue(&lambda,gauss); 210 175 211 176 /*Build gradient vector (actually -dJ/da): */ 212 177 for(int i=0;i<numvertices;i++){ 213 ge[i]+= - weight*Jdet*gauss->weight*basis[i]*lambda;178 ge[i]+= -Jdet*gauss->weight*basis[i]*lambda; 214 179 _assert_(!xIsNan<IssmDouble>(ge[i])); 215 180 } … … 224 189 delete gauss; 225 190 }/*}}}*/ 226 void AdjointBalancethickness2Analysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 191 void AdjointBalancethickness2Analysis::GradientJOmega(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 192 193 /*Intermediaries*/ 194 IssmDouble dlambda[2],ds[2],D0,omega,Jdet; 195 IssmDouble *xyz_list= NULL; 196 197 /*Fetch number of vertices for this finite element*/ 198 int numvertices = element->GetNumberOfVertices(); 199 200 /*Initialize some vectors*/ 201 IssmDouble* basis = xNew<IssmDouble>(numvertices); 202 IssmDouble* ge = xNewZeroInit<IssmDouble>(numvertices); 203 int* vertexpidlist = xNew<int>(numvertices); 204 205 /*Retrieve all inputs we will be needing: */ 206 element->GetVerticesCoordinates(&xyz_list); 207 element->GradientIndexing(&vertexpidlist[0],control_index); 208 Input* adjoint_input = element->GetInput(AdjointEnum); _assert_(adjoint_input); 209 Input* s_input = element->GetInput(SurfaceEnum); _assert_(s_input); 210 Input* D0_input = element->GetInput(BalancethicknessD0Enum); _assert_(D0_input); 211 Input* omega_input = element->GetInput(BalancethicknessOmegaEnum); _assert_(omega_input); 212 213 Gauss* gauss=element->NewGauss(2); 214 for(int ig=gauss->begin();ig<gauss->end();ig++){ 215 gauss->GaussPoint(ig); 216 217 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 218 element->NodalFunctionsP1(basis,gauss); 219 220 D0_input->GetInputValue(&D0,gauss); 221 omega_input->GetInputValue(&omega,gauss); 222 adjoint_input->GetInputDerivativeValue(&dlambda[0],xyz_list,gauss); 223 s_input->GetInputDerivativeValue(&ds[0],xyz_list,gauss); 224 225 /*Build gradient vector (actually -dJ/da): */ 226 for(int i=0;i<numvertices;i++){ 227 ge[i]+= -Jdet*gauss->weight*basis[i]*exp(omega)*D0*(ds[0]*dlambda[0] + ds[1]*dlambda[1]); 228 _assert_(!xIsNan<IssmDouble>(ge[i])); 229 } 230 } 231 gradient->SetValues(numvertices,vertexpidlist,ge,ADD_VAL); 232 233 /*Clean up and return*/ 234 xDelete<IssmDouble>(ge); 235 xDelete<IssmDouble>(xyz_list); 236 xDelete<IssmDouble>(basis); 237 xDelete<int>(vertexpidlist); 238 delete gauss; 239 }/*}}}*/ 240 void AdjointBalancethickness2Analysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 227 241 element->InputUpdateFromSolutionOneDof(solution,AdjointEnum); 228 242 }/*}}}*/ 229 void AdjointBalancethickness2Analysis::UpdateConstraints(FemModel* femmodel){/*{{{*/243 void AdjointBalancethickness2Analysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 230 244 /*Default, do nothing*/ 231 245 return; -
issm/trunk/src/c/analyses/AdjointBalancethickness2Analysis.h
r18301 r19105 13 13 public: 14 14 /*Model processing*/ 15 int DofsPerNode(int** doflist,int domaintype,int approximation);16 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum);17 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type);18 void CreateNodes(Nodes* nodes,IoModel* iomodel);19 15 void CreateConstraints(Constraints* constraints,IoModel* iomodel); 20 16 void CreateLoads(Loads* loads, IoModel* iomodel); 17 void CreateNodes(Nodes* nodes,IoModel* iomodel); 18 int DofsPerNode(int** doflist,int domaintype,int approximation); 19 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 20 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum); 21 21 22 22 /*Finite element Analysis*/ … … 26 26 ElementMatrix* CreateKMatrix(Element* element); 27 27 ElementVector* CreatePVector(Element* element); 28 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 29 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 30 void GradientJAdot(Element* element,Vector<IssmDouble>* gradient,int control_index); 31 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 32 void UpdateConstraints(FemModel* femmodel); 28 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 29 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 30 void GradientJdHdt(Element* element,Vector<IssmDouble>* gradient,int control_index); 31 void GradientJOmega(Element* element,Vector<IssmDouble>* gradient,int control_index); 32 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 33 void UpdateConstraints(FemModel* femmodel); 33 34 }; 34 35 #endif -
issm/trunk/src/c/analyses/AdjointBalancethicknessAnalysis.cpp
r18301 r19105 6 6 7 7 /*Model processor*/ 8 void AdjointBalancethicknessAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 9 _error_("not implemented yet"); 10 }/*}}}*/ 11 void AdjointBalancethicknessAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 12 _error_("not implemented yet"); 13 }/*}}}*/ 14 void AdjointBalancethicknessAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 15 _error_("not implemented yet"); 16 }/*}}}*/ 8 17 int AdjointBalancethicknessAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/ 9 18 return 1; 10 19 }/*}}}*/ 20 void AdjointBalancethicknessAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ 21 _error_("not implemented yet"); 22 }/*}}}*/ 11 23 void AdjointBalancethicknessAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 12 _error_("not implemented yet");13 }/*}}}*/14 void AdjointBalancethicknessAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/15 _error_("not implemented yet");16 }/*}}}*/17 void AdjointBalancethicknessAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/18 _error_("not implemented yet");19 }/*}}}*/20 void AdjointBalancethicknessAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/21 _error_("not implemented yet");22 }/*}}}*/23 void AdjointBalancethicknessAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/24 24 _error_("not implemented yet"); 25 25 }/*}}}*/ … … 147 147 return pe; 148 148 }/*}}}*/ 149 void AdjointBalancethicknessAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/150 _error_("not implemented yet"); 151 }/*}}}*/ 152 void AdjointBalancethicknessAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/149 void AdjointBalancethicknessAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 150 _error_("not implemented yet"); 151 }/*}}}*/ 152 void AdjointBalancethicknessAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 153 153 /*The gradient of the cost function is calculated in 2 parts. 154 154 * … … 196 196 197 197 }/*}}}*/ 198 void AdjointBalancethicknessAnalysis::GradientJVx(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 199 200 /*Intermediaries*/ 201 IssmDouble Jdet,weight; 202 IssmDouble thickness,Dlambda[3],dp[3]; 203 IssmDouble *xyz_list= NULL; 204 205 /*Fetch number of vertices for this finite element*/ 206 int numvertices = element->GetNumberOfVertices(); 207 208 /*Initialize some vectors*/ 209 IssmDouble* basis = xNew<IssmDouble>(numvertices); 210 IssmDouble* ge = xNewZeroInit<IssmDouble>(numvertices); 211 int* vertexpidlist = xNew<int>(numvertices); 212 213 /*Retrieve all inputs we will be needing: */ 214 element->GetVerticesCoordinates(&xyz_list); 215 element->GradientIndexing(&vertexpidlist[0],control_index); 216 Input* thickness_input = element->GetInput(ThicknessEnum); _assert_(thickness_input); 217 Input* adjoint_input = element->GetInput(AdjointEnum); _assert_(adjoint_input); 218 219 /* Start looping on the number of gaussian points: */ 220 Gauss* gauss=element->NewGauss(4); 221 for(int ig=gauss->begin();ig<gauss->end();ig++){ 222 gauss->GaussPoint(ig); 223 224 adjoint_input->GetInputDerivativeValue(&Dlambda[0],xyz_list,gauss); 225 thickness_input->GetInputValue(&thickness, gauss); 226 thickness_input->GetInputDerivativeValue(&dp[0],xyz_list,gauss); 227 228 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 229 element->NodalFunctionsP1(basis,gauss); 230 231 /*Build gradient vector (actually -dJ/dD): */ 232 for(int i=0;i<numvertices;i++){ 233 ge[i]+=thickness*Dlambda[0]*Jdet*gauss->weight*basis[i]; 234 _assert_(!xIsNan<IssmDouble>(ge[i])); 235 } 236 } 237 gradient->SetValues(numvertices,vertexpidlist,ge,ADD_VAL); 238 239 /*Clean up and return*/ 240 xDelete<IssmDouble>(xyz_list); 241 xDelete<IssmDouble>(basis); 242 xDelete<IssmDouble>(ge); 243 xDelete<int>(vertexpidlist); 244 delete gauss; 245 }/*}}}*/ 246 void AdjointBalancethicknessAnalysis::GradientJVy(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 247 248 /*Intermediaries*/ 249 IssmDouble Jdet,weight; 250 IssmDouble thickness,Dlambda[3],dp[3]; 251 IssmDouble *xyz_list= NULL; 252 253 /*Fetch number of vertices for this finite element*/ 254 int numvertices = element->GetNumberOfVertices(); 255 256 /*Initialize some vectors*/ 257 IssmDouble* basis = xNew<IssmDouble>(numvertices); 258 IssmDouble* ge = xNewZeroInit<IssmDouble>(numvertices); 259 int* vertexpidlist = xNew<int>(numvertices); 260 261 /*Retrieve all inputs we will be needing: */ 262 element->GetVerticesCoordinates(&xyz_list); 263 element->GradientIndexing(&vertexpidlist[0],control_index); 264 Input* thickness_input = element->GetInput(ThicknessEnum); _assert_(thickness_input); 265 Input* adjoint_input = element->GetInput(AdjointEnum); _assert_(adjoint_input); 266 267 /* Start looping on the number of gaussian points: */ 268 Gauss* gauss=element->NewGauss(4); 269 for(int ig=gauss->begin();ig<gauss->end();ig++){ 270 gauss->GaussPoint(ig); 271 272 adjoint_input->GetInputDerivativeValue(&Dlambda[0],xyz_list,gauss); 273 thickness_input->GetInputValue(&thickness, gauss); 274 thickness_input->GetInputDerivativeValue(&dp[0],xyz_list,gauss); 275 276 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 277 element->NodalFunctionsP1(basis,gauss); 278 279 /*Build gradient vector (actually -dJ/dvy): */ 280 for(int i=0;i<numvertices;i++){ 281 ge[i]+=thickness*Dlambda[1]*Jdet*gauss->weight*basis[i]; 282 _assert_(!xIsNan<IssmDouble>(ge[i])); 283 } 284 } 285 gradient->SetValues(numvertices,vertexpidlist,ge,ADD_VAL); 286 287 /*Clean up and return*/ 288 xDelete<IssmDouble>(xyz_list); 289 xDelete<IssmDouble>(basis); 290 xDelete<IssmDouble>(ge); 291 xDelete<int>(vertexpidlist); 292 delete gauss; 293 }/*}}}*/ 294 void AdjointBalancethicknessAnalysis::GradientJDhDt(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 198 void AdjointBalancethicknessAnalysis::GradientJDhDt(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 295 199 296 200 /*Fetch number of vertices for this finite element*/ … … 316 220 xDelete<int>(vertexpidlist); 317 221 }/*}}}*/ 318 void AdjointBalancethicknessAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 222 void AdjointBalancethicknessAnalysis::GradientJVx(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 223 224 /*Intermediaries*/ 225 IssmDouble thickness,Jdet,Dlambda[3],dp[3]; 226 IssmDouble *xyz_list= NULL; 227 228 /*Fetch number of vertices for this finite element*/ 229 int numvertices = element->GetNumberOfVertices(); 230 231 /*Initialize some vectors*/ 232 IssmDouble* basis = xNew<IssmDouble>(numvertices); 233 IssmDouble* ge = xNewZeroInit<IssmDouble>(numvertices); 234 int* vertexpidlist = xNew<int>(numvertices); 235 236 /*Retrieve all inputs we will be needing: */ 237 element->GetVerticesCoordinates(&xyz_list); 238 element->GradientIndexing(&vertexpidlist[0],control_index); 239 Input* thickness_input = element->GetInput(ThicknessEnum); _assert_(thickness_input); 240 Input* adjoint_input = element->GetInput(AdjointEnum); _assert_(adjoint_input); 241 242 /* Start looping on the number of gaussian points: */ 243 Gauss* gauss=element->NewGauss(4); 244 for(int ig=gauss->begin();ig<gauss->end();ig++){ 245 gauss->GaussPoint(ig); 246 247 adjoint_input->GetInputDerivativeValue(&Dlambda[0],xyz_list,gauss); 248 thickness_input->GetInputValue(&thickness, gauss); 249 thickness_input->GetInputDerivativeValue(&dp[0],xyz_list,gauss); 250 251 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 252 element->NodalFunctionsP1(basis,gauss); 253 254 /*Build gradient vector (actually -dJ/dD): */ 255 for(int i=0;i<numvertices;i++){ 256 ge[i]+=thickness*Dlambda[0]*Jdet*gauss->weight*basis[i]; 257 _assert_(!xIsNan<IssmDouble>(ge[i])); 258 } 259 } 260 gradient->SetValues(numvertices,vertexpidlist,ge,ADD_VAL); 261 262 /*Clean up and return*/ 263 xDelete<IssmDouble>(xyz_list); 264 xDelete<IssmDouble>(basis); 265 xDelete<IssmDouble>(ge); 266 xDelete<int>(vertexpidlist); 267 delete gauss; 268 }/*}}}*/ 269 void AdjointBalancethicknessAnalysis::GradientJVy(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 270 271 /*Intermediaries*/ 272 IssmDouble thickness,Jdet,Dlambda[3],dp[3]; 273 IssmDouble *xyz_list= NULL; 274 275 /*Fetch number of vertices for this finite element*/ 276 int numvertices = element->GetNumberOfVertices(); 277 278 /*Initialize some vectors*/ 279 IssmDouble* basis = xNew<IssmDouble>(numvertices); 280 IssmDouble* ge = xNewZeroInit<IssmDouble>(numvertices); 281 int* vertexpidlist = xNew<int>(numvertices); 282 283 /*Retrieve all inputs we will be needing: */ 284 element->GetVerticesCoordinates(&xyz_list); 285 element->GradientIndexing(&vertexpidlist[0],control_index); 286 Input* thickness_input = element->GetInput(ThicknessEnum); _assert_(thickness_input); 287 Input* adjoint_input = element->GetInput(AdjointEnum); _assert_(adjoint_input); 288 289 /* Start looping on the number of gaussian points: */ 290 Gauss* gauss=element->NewGauss(4); 291 for(int ig=gauss->begin();ig<gauss->end();ig++){ 292 gauss->GaussPoint(ig); 293 294 adjoint_input->GetInputDerivativeValue(&Dlambda[0],xyz_list,gauss); 295 thickness_input->GetInputValue(&thickness, gauss); 296 thickness_input->GetInputDerivativeValue(&dp[0],xyz_list,gauss); 297 298 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 299 element->NodalFunctionsP1(basis,gauss); 300 301 /*Build gradient vector (actually -dJ/dvy): */ 302 for(int i=0;i<numvertices;i++){ 303 ge[i]+=thickness*Dlambda[1]*Jdet*gauss->weight*basis[i]; 304 _assert_(!xIsNan<IssmDouble>(ge[i])); 305 } 306 } 307 gradient->SetValues(numvertices,vertexpidlist,ge,ADD_VAL); 308 309 /*Clean up and return*/ 310 xDelete<IssmDouble>(xyz_list); 311 xDelete<IssmDouble>(basis); 312 xDelete<IssmDouble>(ge); 313 xDelete<int>(vertexpidlist); 314 delete gauss; 315 }/*}}}*/ 316 void AdjointBalancethicknessAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 319 317 320 318 int domaintype; … … 330 328 } 331 329 }/*}}}*/ 332 void AdjointBalancethicknessAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/330 void AdjointBalancethicknessAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 333 331 /*Default, do nothing*/ 334 332 return; -
issm/trunk/src/c/analyses/AdjointBalancethicknessAnalysis.h
r18301 r19105 13 13 public: 14 14 /*Model processing*/ 15 int DofsPerNode(int** doflist,int domaintype,int approximation);16 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum);17 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type);18 void CreateNodes(Nodes* nodes,IoModel* iomodel);19 15 void CreateConstraints(Constraints* constraints,IoModel* iomodel); 20 16 void CreateLoads(Loads* loads, IoModel* iomodel); 17 void CreateNodes(Nodes* nodes,IoModel* iomodel); 18 int DofsPerNode(int** doflist,int domaintype,int approximation); 19 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 20 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum); 21 21 22 22 /*Finite element Analysis*/ … … 26 26 ElementMatrix* CreateKMatrix(Element* element); 27 27 ElementVector* CreatePVector(Element* element); 28 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element);29 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index);30 void GradientJVx(Element* element,Vector<IssmDouble>* gradient,int control_index);31 void GradientJVy(Element* element,Vector<IssmDouble>* gradient,int control_index);32 void GradientJDhDt(Element* element,Vector<IssmDouble>* gradient,int control_index);33 void InputUpdateFromSolution(IssmDouble* solution,Element* element);34 void UpdateConstraints(FemModel* femmodel);28 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 29 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 30 void GradientJDhDt(Element* element,Vector<IssmDouble>* gradient,int control_index); 31 void GradientJVx(Element* element,Vector<IssmDouble>* gradient,int control_index); 32 void GradientJVy(Element* element,Vector<IssmDouble>* gradient,int control_index); 33 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 34 void UpdateConstraints(FemModel* femmodel); 35 35 }; 36 36 #endif -
issm/trunk/src/c/analyses/AdjointHorizAnalysis.cpp
r18301 r19105 6 6 7 7 /*Model processing*/ 8 void AdjointHorizAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 9 _error_("not implemented yet"); 10 }/*}}}*/ 11 void AdjointHorizAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 12 _error_("not implemented yet"); 13 }/*}}}*/ 14 void AdjointHorizAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 15 _error_("not implemented yet"); 16 }/*}}}*/ 8 17 int AdjointHorizAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/ 9 18 _error_("not implemented"); 10 19 }/*}}}*/ 20 void AdjointHorizAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ 21 _error_("not implemented yet"); 22 }/*}}}*/ 11 23 void AdjointHorizAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 12 24 _error_("not implemented yet"); 13 25 }/*}}}*/ 14 void AdjointHorizAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/15 _error_("not implemented yet");16 }/*}}}*/17 void AdjointHorizAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/18 _error_("not implemented yet");19 }/*}}}*/20 void AdjointHorizAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/21 _error_("not implemented yet");22 }/*}}}*/23 void AdjointHorizAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/24 _error_("not implemented yet");25 }/*}}}*/26 26 27 27 /*Finite Element Analysis*/ 28 void 28 void AdjointHorizAnalysis::Core(FemModel* femmodel){/*{{{*/ 29 29 _error_("not implemented"); 30 30 }/*}}}*/ … … 42 42 case SSAApproximationEnum: 43 43 return CreateKMatrixSSA(element); 44 case L1L2ApproximationEnum: 45 return CreateKMatrixL1L2(element); 44 46 case HOApproximationEnum: 45 47 return CreateKMatrixHO(element); … … 52 54 } 53 55 }/*}}}*/ 56 ElementMatrix* AdjointHorizAnalysis::CreateKMatrixFS(Element* element){/*{{{*/ 57 58 /*Intermediaries */ 59 bool incomplete_adjoint; 60 int dim,epssize; 61 IssmDouble Jdet,mu_prime; 62 IssmDouble eps1dotdphii,eps1dotdphij,eps2dotdphii,eps2dotdphij,eps3dotdphii,eps3dotdphij; 63 IssmDouble eps1[3],eps2[3],eps3[3],epsilon[5];/* epsilon=[exx,eyy,exy,exz,eyz];*/ 64 IssmDouble *xyz_list = NULL; 65 66 /*Get problem dimension*/ 67 element->FindParam(&dim,DomainDimensionEnum); 68 if(dim==2) epssize = 3; 69 else epssize = 6; 70 71 /*Fetch number of nodes and dof for this finite element*/ 72 int vnumnodes = element->NumberofNodesVelocity(); 73 int pnumnodes = element->NumberofNodesPressure(); 74 int numdof = vnumnodes*dim + pnumnodes; 75 76 /*Initialize Jacobian with regular FS (first part of the Gateau derivative)*/ 77 element->FindParam(&incomplete_adjoint,InversionIncompleteAdjointEnum); 78 StressbalanceAnalysis* analysis = new StressbalanceAnalysis(); 79 ElementMatrix* Ke=analysis->CreateKMatrix(element); 80 delete analysis; 81 if(incomplete_adjoint) return Ke; 82 83 /*Retrieve all inputs and parameters*/ 84 element->GetVerticesCoordinates(&xyz_list); 85 Input* vx_input = element->GetInput(VxEnum);_assert_(vx_input); 86 Input* vy_input = element->GetInput(VyEnum);_assert_(vy_input); 87 Input* vz_input = NULL; 88 if(dim==3){ 89 vz_input = element->GetInput(VzEnum); 90 } 91 else{ 92 _error_("Not implemented yet"); 93 } 94 95 /*Allocate dbasis*/ 96 IssmDouble* dbasis = xNew<IssmDouble>(dim*vnumnodes); 97 98 /* Start looping on the number of gaussian points: */ 99 Gauss* gauss=element->NewGauss(5); 100 for(int ig=gauss->begin();ig<gauss->end();ig++){ 101 gauss->GaussPoint(ig); 102 103 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 104 element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss); 105 106 element->StrainRateHO(&epsilon[0],xyz_list,gauss,vx_input,vy_input); 107 element->ViscosityFSDerivativeEpsSquare(&mu_prime,&epsilon[0]); 108 eps1[0]=epsilon[0]; eps2[0]=epsilon[2]; eps3[0]=epsilon[3]; 109 eps1[1]=epsilon[2]; eps2[1]=epsilon[1]; eps3[1]=epsilon[4]; 110 eps1[2]=epsilon[3]; eps2[2]=epsilon[4]; eps3[2]= -epsilon[0] -epsilon[1]; 111 112 for(int i=0;i<vnumnodes;i++){ 113 for(int j=0;j<vnumnodes;j++){ 114 eps1dotdphii=eps1[0]*dbasis[0*vnumnodes+i]+eps1[1]*dbasis[1*vnumnodes+i]+eps1[2]*dbasis[2*vnumnodes+i]; 115 eps1dotdphij=eps1[0]*dbasis[0*vnumnodes+j]+eps1[1]*dbasis[1*vnumnodes+j]+eps1[2]*dbasis[2*vnumnodes+j]; 116 eps2dotdphii=eps2[0]*dbasis[0*vnumnodes+i]+eps2[1]*dbasis[1*vnumnodes+i]+eps2[2]*dbasis[2*vnumnodes+i]; 117 eps2dotdphij=eps2[0]*dbasis[0*vnumnodes+j]+eps2[1]*dbasis[1*vnumnodes+j]+eps2[2]*dbasis[2*vnumnodes+j]; 118 eps3dotdphii=eps3[0]*dbasis[0*vnumnodes+i]+eps3[1]*dbasis[1*vnumnodes+i]+eps3[2]*dbasis[2*vnumnodes+i]; 119 eps3dotdphij=eps3[0]*dbasis[0*vnumnodes+j]+eps3[1]*dbasis[1*vnumnodes+j]+eps3[2]*dbasis[2*vnumnodes+j]; 120 121 Ke->values[numdof*(4*i+0)+4*j+0]+=gauss->weight*Jdet*2*mu_prime*eps1dotdphij*eps1dotdphii; 122 Ke->values[numdof*(4*i+0)+4*j+1]+=gauss->weight*Jdet*2*mu_prime*eps2dotdphij*eps1dotdphii; 123 Ke->values[numdof*(4*i+0)+4*j+2]+=gauss->weight*Jdet*2*mu_prime*eps3dotdphij*eps1dotdphii; 124 125 Ke->values[numdof*(4*i+1)+4*j+0]+=gauss->weight*Jdet*2*mu_prime*eps1dotdphij*eps2dotdphii; 126 Ke->values[numdof*(4*i+1)+4*j+1]+=gauss->weight*Jdet*2*mu_prime*eps2dotdphij*eps2dotdphii; 127 Ke->values[numdof*(4*i+1)+4*j+2]+=gauss->weight*Jdet*2*mu_prime*eps3dotdphij*eps2dotdphii; 128 129 Ke->values[numdof*(4*i+2)+4*j+0]+=gauss->weight*Jdet*2*mu_prime*eps1dotdphij*eps3dotdphii; 130 Ke->values[numdof*(4*i+2)+4*j+1]+=gauss->weight*Jdet*2*mu_prime*eps2dotdphij*eps3dotdphii; 131 Ke->values[numdof*(4*i+2)+4*j+2]+=gauss->weight*Jdet*2*mu_prime*eps3dotdphij*eps3dotdphii; 132 } 133 } 134 } 135 136 /*Transform Coordinate System*/ 137 element->TransformStiffnessMatrixCoord(Ke,XYZEnum); 138 139 /*Clean up and return*/ 140 delete gauss; 141 xDelete<IssmDouble>(dbasis); 142 xDelete<IssmDouble>(xyz_list); 143 return Ke; 144 }/*}}}*/ 145 ElementMatrix* AdjointHorizAnalysis::CreateKMatrixHO(Element* element){/*{{{*/ 146 147 /*Intermediaries */ 148 bool incomplete_adjoint; 149 IssmDouble Jdet,mu_prime; 150 IssmDouble eps1dotdphii,eps1dotdphij,eps2dotdphii,eps2dotdphij; 151 IssmDouble eps1[3],eps2[3],epsilon[5];/* epsilon=[exx,eyy,exy,exz,eyz];*/ 152 IssmDouble *xyz_list = NULL; 153 154 /*Fetch number of nodes and dof for this finite element*/ 155 int numnodes = element->GetNumberOfNodes(); 156 157 /*Initialize Jacobian with regular HO (first part of the Gateau derivative)*/ 158 element->FindParam(&incomplete_adjoint,InversionIncompleteAdjointEnum); 159 StressbalanceAnalysis* analysis = new StressbalanceAnalysis(); 160 ElementMatrix* Ke=analysis->CreateKMatrix(element); 161 delete analysis; 162 if(incomplete_adjoint) return Ke; 163 164 /*Retrieve all inputs and parameters*/ 165 element->GetVerticesCoordinates(&xyz_list); 166 Input* vx_input = element->GetInput(VxEnum); _assert_(vx_input); 167 Input* vy_input = element->GetInput(VyEnum); _assert_(vy_input); 168 169 /*Allocate dbasis*/ 170 IssmDouble* dbasis = xNew<IssmDouble>(3*numnodes); 171 172 /* Start looping on the number of gaussian points: */ 173 Gauss* gauss=element->NewGauss(5); 174 for(int ig=gauss->begin();ig<gauss->end();ig++){ 175 gauss->GaussPoint(ig); 176 177 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 178 element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss); 179 180 element->StrainRateHO(&epsilon[0],xyz_list,gauss,vx_input,vy_input); 181 element->ViscosityHODerivativeEpsSquare(&mu_prime,&epsilon[0]); 182 eps1[0]=2.*epsilon[0]+epsilon[1]; eps2[0]=epsilon[2]; 183 eps1[1]=epsilon[2]; eps2[1]=epsilon[0]+2.*epsilon[1]; 184 eps1[2]=epsilon[3]; eps2[2]=epsilon[4]; 185 186 for(int i=0;i<numnodes;i++){ 187 for(int j=0;j<numnodes;j++){ 188 eps1dotdphii=eps1[0]*dbasis[0*numnodes+i]+eps1[1]*dbasis[1*numnodes+i]+eps1[2]*dbasis[2*numnodes+i]; 189 eps1dotdphij=eps1[0]*dbasis[0*numnodes+j]+eps1[1]*dbasis[1*numnodes+j]+eps1[2]*dbasis[2*numnodes+j]; 190 eps2dotdphii=eps2[0]*dbasis[0*numnodes+i]+eps2[1]*dbasis[1*numnodes+i]+eps2[2]*dbasis[2*numnodes+i]; 191 eps2dotdphij=eps2[0]*dbasis[0*numnodes+j]+eps2[1]*dbasis[1*numnodes+j]+eps2[2]*dbasis[2*numnodes+j]; 192 193 Ke->values[2*numnodes*(2*i+0)+2*j+0]+=gauss->weight*Jdet*2*mu_prime*eps1dotdphij*eps1dotdphii; 194 Ke->values[2*numnodes*(2*i+0)+2*j+1]+=gauss->weight*Jdet*2*mu_prime*eps2dotdphij*eps1dotdphii; 195 Ke->values[2*numnodes*(2*i+1)+2*j+0]+=gauss->weight*Jdet*2*mu_prime*eps1dotdphij*eps2dotdphii; 196 Ke->values[2*numnodes*(2*i+1)+2*j+1]+=gauss->weight*Jdet*2*mu_prime*eps2dotdphij*eps2dotdphii; 197 } 198 } 199 } 200 201 /*Transform Coordinate System*/ 202 element->TransformStiffnessMatrixCoord(Ke,XYEnum); 203 204 /*Clean up and return*/ 205 delete gauss; 206 xDelete<IssmDouble>(dbasis); 207 xDelete<IssmDouble>(xyz_list); 208 return Ke; 209 }/*}}}*/ 210 ElementMatrix* AdjointHorizAnalysis::CreateKMatrixL1L2(Element* element){/*{{{*/ 211 212 /*Intermediaries*/ 213 bool incomplete_adjoint; 214 215 /*Initialize Jacobian with regular L1L2 (first part of the Gateau derivative)*/ 216 StressbalanceAnalysis* analysis = new StressbalanceAnalysis(); 217 ElementMatrix* Ke=analysis->CreateKMatrix(element); 218 delete analysis; 219 220 /*return*/ 221 element->FindParam(&incomplete_adjoint,InversionIncompleteAdjointEnum); 222 if(!incomplete_adjoint){ 223 _error_("Exact adjoint not supported yet for L1L2 model"); 224 } 225 return Ke; 226 }/*}}}*/ 54 227 ElementMatrix* AdjointHorizAnalysis::CreateKMatrixSSA(Element* element){/*{{{*/ 55 228 … … 139 312 return Ke; 140 313 }/*}}}*/ 141 ElementMatrix* AdjointHorizAnalysis::CreateKMatrixHO(Element* element){/*{{{*/142 143 /*Intermediaries */144 bool incomplete_adjoint;145 IssmDouble Jdet,mu_prime;146 IssmDouble eps1dotdphii,eps1dotdphij,eps2dotdphii,eps2dotdphij;147 IssmDouble eps1[3],eps2[3],epsilon[5];/* epsilon=[exx,eyy,exy,exz,eyz];*/148 IssmDouble *xyz_list = NULL;149 150 /*Fetch number of nodes and dof for this finite element*/151 int numnodes = element->GetNumberOfNodes();152 153 /*Initialize Jacobian with regular HO (first part of the Gateau derivative)*/154 element->FindParam(&incomplete_adjoint,InversionIncompleteAdjointEnum);155 StressbalanceAnalysis* analysis = new StressbalanceAnalysis();156 ElementMatrix* Ke=analysis->CreateKMatrix(element);157 delete analysis;158 if(incomplete_adjoint) return Ke;159 160 /*Retrieve all inputs and parameters*/161 element->GetVerticesCoordinates(&xyz_list);162 Input* vx_input = element->GetInput(VxEnum); _assert_(vx_input);163 Input* vy_input = element->GetInput(VyEnum); _assert_(vy_input);164 165 /*Allocate dbasis*/166 IssmDouble* dbasis = xNew<IssmDouble>(3*numnodes);167 168 /* Start looping on the number of gaussian points: */169 Gauss* gauss=element->NewGauss(5);170 for(int ig=gauss->begin();ig<gauss->end();ig++){171 gauss->GaussPoint(ig);172 173 element->JacobianDeterminant(&Jdet,xyz_list,gauss);174 element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss);175 176 element->StrainRateHO(&epsilon[0],xyz_list,gauss,vx_input,vy_input);177 element->ViscosityHODerivativeEpsSquare(&mu_prime,&epsilon[0]);178 eps1[0]=2.*epsilon[0]+epsilon[1]; eps2[0]=epsilon[2];179 eps1[1]=epsilon[2]; eps2[1]=epsilon[0]+2.*epsilon[1];180 eps1[2]=epsilon[3]; eps2[2]=epsilon[4];181 182 for(int i=0;i<numnodes;i++){183 for(int j=0;j<numnodes;j++){184 eps1dotdphii=eps1[0]*dbasis[0*numnodes+i]+eps1[1]*dbasis[1*numnodes+i]+eps1[2]*dbasis[2*numnodes+i];185 eps1dotdphij=eps1[0]*dbasis[0*numnodes+j]+eps1[1]*dbasis[1*numnodes+j]+eps1[2]*dbasis[2*numnodes+j];186 eps2dotdphii=eps2[0]*dbasis[0*numnodes+i]+eps2[1]*dbasis[1*numnodes+i]+eps2[2]*dbasis[2*numnodes+i];187 eps2dotdphij=eps2[0]*dbasis[0*numnodes+j]+eps2[1]*dbasis[1*numnodes+j]+eps2[2]*dbasis[2*numnodes+j];188 189 Ke->values[2*numnodes*(2*i+0)+2*j+0]+=gauss->weight*Jdet*2*mu_prime*eps1dotdphij*eps1dotdphii;190 Ke->values[2*numnodes*(2*i+0)+2*j+1]+=gauss->weight*Jdet*2*mu_prime*eps2dotdphij*eps1dotdphii;191 Ke->values[2*numnodes*(2*i+1)+2*j+0]+=gauss->weight*Jdet*2*mu_prime*eps1dotdphij*eps2dotdphii;192 Ke->values[2*numnodes*(2*i+1)+2*j+1]+=gauss->weight*Jdet*2*mu_prime*eps2dotdphij*eps2dotdphii;193 }194 }195 }196 197 /*Transform Coordinate System*/198 element->TransformStiffnessMatrixCoord(Ke,XYEnum);199 200 /*Clean up and return*/201 delete gauss;202 xDelete<IssmDouble>(dbasis);203 xDelete<IssmDouble>(xyz_list);204 return Ke;205 }/*}}}*/206 ElementMatrix* AdjointHorizAnalysis::CreateKMatrixFS(Element* element){/*{{{*/207 208 /*Intermediaries */209 bool incomplete_adjoint;210 int dim,epssize;211 IssmDouble Jdet,mu_prime;212 IssmDouble eps1dotdphii,eps1dotdphij,eps2dotdphii,eps2dotdphij,eps3dotdphii,eps3dotdphij;213 IssmDouble eps1[3],eps2[3],eps3[3],epsilon[5];/* epsilon=[exx,eyy,exy,exz,eyz];*/214 IssmDouble *xyz_list = NULL;215 216 /*Get problem dimension*/217 element->FindParam(&dim,DomainDimensionEnum);218 if(dim==2) epssize = 3;219 else epssize = 6;220 221 /*Fetch number of nodes and dof for this finite element*/222 int vnumnodes = element->NumberofNodesVelocity();223 int pnumnodes = element->NumberofNodesPressure();224 int numdof = vnumnodes*dim + pnumnodes;225 226 /*Initialize Jacobian with regular FS (first part of the Gateau derivative)*/227 element->FindParam(&incomplete_adjoint,InversionIncompleteAdjointEnum);228 StressbalanceAnalysis* analysis = new StressbalanceAnalysis();229 ElementMatrix* Ke=analysis->CreateKMatrix(element);230 delete analysis;231 if(incomplete_adjoint) return Ke;232 233 /*Retrieve all inputs and parameters*/234 element->GetVerticesCoordinates(&xyz_list);235 Input* vx_input = element->GetInput(VxEnum);_assert_(vx_input);236 Input* vy_input = element->GetInput(VyEnum);_assert_(vy_input);237 Input* vz_input = NULL;238 if(dim==3){239 vz_input = element->GetInput(VzEnum);240 }241 else{242 _error_("Not implemented yet");243 }244 245 /*Allocate dbasis*/246 IssmDouble* dbasis = xNew<IssmDouble>(dim*vnumnodes);247 248 /* Start looping on the number of gaussian points: */249 Gauss* gauss=element->NewGauss(5);250 for(int ig=gauss->begin();ig<gauss->end();ig++){251 gauss->GaussPoint(ig);252 253 element->JacobianDeterminant(&Jdet,xyz_list,gauss);254 element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss);255 256 element->StrainRateHO(&epsilon[0],xyz_list,gauss,vx_input,vy_input);257 element->ViscosityFSDerivativeEpsSquare(&mu_prime,&epsilon[0]);258 eps1[0]=epsilon[0]; eps2[0]=epsilon[2]; eps3[0]=epsilon[3];259 eps1[1]=epsilon[2]; eps2[1]=epsilon[1]; eps3[1]=epsilon[4];260 eps1[2]=epsilon[3]; eps2[2]=epsilon[4]; eps3[2]= -epsilon[0] -epsilon[1];261 262 for(int i=0;i<vnumnodes;i++){263 for(int j=0;j<vnumnodes;j++){264 eps1dotdphii=eps1[0]*dbasis[0*vnumnodes+i]+eps1[1]*dbasis[1*vnumnodes+i]+eps1[2]*dbasis[2*vnumnodes+i];265 eps1dotdphij=eps1[0]*dbasis[0*vnumnodes+j]+eps1[1]*dbasis[1*vnumnodes+j]+eps1[2]*dbasis[2*vnumnodes+j];266 eps2dotdphii=eps2[0]*dbasis[0*vnumnodes+i]+eps2[1]*dbasis[1*vnumnodes+i]+eps2[2]*dbasis[2*vnumnodes+i];267 eps2dotdphij=eps2[0]*dbasis[0*vnumnodes+j]+eps2[1]*dbasis[1*vnumnodes+j]+eps2[2]*dbasis[2*vnumnodes+j];268 eps3dotdphii=eps3[0]*dbasis[0*vnumnodes+i]+eps3[1]*dbasis[1*vnumnodes+i]+eps3[2]*dbasis[2*vnumnodes+i];269 eps3dotdphij=eps3[0]*dbasis[0*vnumnodes+j]+eps3[1]*dbasis[1*vnumnodes+j]+eps3[2]*dbasis[2*vnumnodes+j];270 271 Ke->values[numdof*(4*i+0)+4*j+0]+=gauss->weight*Jdet*2*mu_prime*eps1dotdphij*eps1dotdphii;272 Ke->values[numdof*(4*i+0)+4*j+1]+=gauss->weight*Jdet*2*mu_prime*eps2dotdphij*eps1dotdphii;273 Ke->values[numdof*(4*i+0)+4*j+2]+=gauss->weight*Jdet*2*mu_prime*eps3dotdphij*eps1dotdphii;274 275 Ke->values[numdof*(4*i+1)+4*j+0]+=gauss->weight*Jdet*2*mu_prime*eps1dotdphij*eps2dotdphii;276 Ke->values[numdof*(4*i+1)+4*j+1]+=gauss->weight*Jdet*2*mu_prime*eps2dotdphij*eps2dotdphii;277 Ke->values[numdof*(4*i+1)+4*j+2]+=gauss->weight*Jdet*2*mu_prime*eps3dotdphij*eps2dotdphii;278 279 Ke->values[numdof*(4*i+2)+4*j+0]+=gauss->weight*Jdet*2*mu_prime*eps1dotdphij*eps3dotdphii;280 Ke->values[numdof*(4*i+2)+4*j+1]+=gauss->weight*Jdet*2*mu_prime*eps2dotdphij*eps3dotdphii;281 Ke->values[numdof*(4*i+2)+4*j+2]+=gauss->weight*Jdet*2*mu_prime*eps3dotdphij*eps3dotdphii;282 }283 }284 }285 286 /*Transform Coordinate System*/287 element->TransformStiffnessMatrixCoord(Ke,XYZEnum);288 289 /*Clean up and return*/290 delete gauss;291 xDelete<IssmDouble>(dbasis);292 xDelete<IssmDouble>(xyz_list);293 return Ke;294 }/*}}}*/295 314 ElementVector* AdjointHorizAnalysis::CreatePVector(Element* element){/*{{{*/ 296 315 … … 300 319 case SSAApproximationEnum: 301 320 return CreatePVectorSSA(element); 321 case L1L2ApproximationEnum: 322 return CreatePVectorL1L2(element); 302 323 case HOApproximationEnum: 303 324 return CreatePVectorHO(element); … … 316 337 317 338 /*Intermediaries */ 318 int num_responses,i,d im;339 int num_responses,i,domaintype; 319 340 IssmDouble Jdet,obs_velocity_mag,velocity_mag; 320 341 IssmDouble vx,vy,vxobs,vyobs,dux,duy,weight; … … 323 344 IssmDouble *xyz_list_top = NULL; 324 345 325 /* Get problem dimension*/326 element->FindParam(&d im,DomainDimensionEnum);346 /* Get domaintype*/ 347 element->FindParam(&domaintype,DomainTypeEnum); 327 348 328 349 /*Fetch number of nodes and dof for this finite element*/ … … 332 353 /*Prepare coordinate system list*/ 333 354 int* cs_list = xNew<int>(vnumnodes+pnumnodes); 334 if(d im==2) for(i=0;i<vnumnodes;i++) cs_list[i] = XYEnum;355 if(domaintype==Domain2DverticalEnum) for(i=0;i<vnumnodes;i++) cs_list[i] = XYEnum; 335 356 else for(i=0;i<vnumnodes;i++) cs_list[i] = XYZEnum; 336 357 for(i=0;i<pnumnodes;i++) cs_list[vnumnodes+i] = PressureEnum; … … 346 367 Input* weights_input = element->GetInput(InversionCostFunctionsCoefficientsEnum); _assert_(weights_input); 347 368 Input* vx_input = element->GetInput(VxEnum); _assert_(vx_input); 348 Input* vy_input = element->GetInput(VyEnum); _assert_(vy_input);349 369 Input* vxobs_input = element->GetInput(InversionVxObsEnum); _assert_(vxobs_input); 350 Input* vyobs_input = element->GetInput(InversionVyObsEnum); _assert_(vyobs_input); 370 Input* vy_input = NULL; 371 Input* vyobs_input = NULL; 372 if(domaintype!=Domain2DverticalEnum){ 373 vy_input = element->GetInput(VyEnum); _assert_(vy_input); 374 vyobs_input = element->GetInput(InversionVyObsEnum); _assert_(vyobs_input); 375 } 351 376 IssmDouble epsvel = 2.220446049250313e-16; 352 377 IssmDouble meanvel = 3.170979198376458e-05; /*1000 m/yr*/ … … 368 393 369 394 vx_input->GetInputValue(&vx,gauss); 370 vy_input->GetInputValue(&vy,gauss);371 395 vxobs_input->GetInputValue(&vxobs,gauss); 372 vyobs_input->GetInputValue(&vyobs,gauss); 396 if(domaintype!=Domain2DverticalEnum) { 397 vy_input->GetInputValue(&vy,gauss); 398 vyobs_input->GetInputValue(&vyobs,gauss); 399 } 373 400 374 401 /*Loop over all requested responses*/ … … 388 415 */ 389 416 for(i=0;i<vnumnodes;i++){ 390 dux=vxobs-vx;391 pe->values[i*dim+0]+=dux*weight*Jdet*gauss->weight*vbasis[i];392 if(dim==3){417 if(domaintype!=Domain2DverticalEnum){ 418 dux=vxobs-vx; 419 pe->values[i*3+0]+=dux*weight*Jdet*gauss->weight*vbasis[i]; 393 420 duy=vyobs-vy; 394 pe->values[i*dim+1]+=duy*weight*Jdet*gauss->weight*vbasis[i]; 421 pe->values[i*3+1]+=duy*weight*Jdet*gauss->weight*vbasis[i]; 422 } 423 else{ 424 dux=vxobs-vx; 425 pe->values[i*2+0]+=dux*weight*Jdet*gauss->weight*vbasis[i]; 395 426 } 396 427 } … … 409 440 */ 410 441 for(i=0;i<vnumnodes;i++){ 411 scalex=pow(meanvel/(vxobs+epsvel),2); if(vxobs==0)scalex=0; 412 scaley=pow(meanvel/(vyobs+epsvel),2); if(vyobs==0)scaley=0; 413 dux=scalex*(vxobs-vx); 414 duy=scaley*(vyobs-vy); 415 pe->values[i*dim+0]+=dux*weight*Jdet*gauss->weight*vbasis[i]; 416 pe->values[i*dim+1]+=duy*weight*Jdet*gauss->weight*vbasis[i]; 442 if(domaintype!=Domain2DverticalEnum){ 443 scalex=pow(meanvel/(vxobs+epsvel),2); if(vxobs==0)scalex=0; 444 scaley=pow(meanvel/(vyobs+epsvel),2); if(vyobs==0)scaley=0; 445 dux=scalex*(vxobs-vx); 446 duy=scaley*(vyobs-vy); 447 pe->values[i*3+0]+=dux*weight*Jdet*gauss->weight*vbasis[i]; 448 pe->values[i*3+1]+=duy*weight*Jdet*gauss->weight*vbasis[i]; 449 } 450 else{ 451 scalex=pow(meanvel/(vxobs+epsvel),2); if(vxobs==0)scalex=0; 452 dux=scalex*(vxobs-vx); 453 pe->values[i*2+0]+=dux*weight*Jdet*gauss->weight*vbasis[i]; 454 pe->values[i*2+1]+=duy*weight*Jdet*gauss->weight*vbasis[i]; 455 } 417 456 } 418 457 break; … … 430 469 */ 431 470 for(i=0;i<vnumnodes;i++){ 432 if(d im==3){471 if(domaintype!=Domain2DverticalEnum){ 433 472 velocity_mag =sqrt(vx*vx+vy*vy)+epsvel; 434 473 obs_velocity_mag=sqrt(vxobs*vxobs+vyobs*vyobs)+epsvel; … … 436 475 dux=scale*vx; 437 476 duy=scale*vy; 438 pe->values[i* dim+0]+=dux*weight*Jdet*gauss->weight*vbasis[i];439 pe->values[i* dim+1]+=duy*weight*Jdet*gauss->weight*vbasis[i];477 pe->values[i*3+0]+=dux*weight*Jdet*gauss->weight*vbasis[i]; 478 pe->values[i*3+1]+=duy*weight*Jdet*gauss->weight*vbasis[i]; 440 479 } 441 480 else{ … … 444 483 scale=-8.*meanvel*meanvel/(velocity_mag*velocity_mag)*log(velocity_mag/obs_velocity_mag); 445 484 dux=scale*vx; 446 pe->values[i* dim+0]+=dux*weight*Jdet*gauss->weight*vbasis[i];485 pe->values[i*2+0]+=dux*weight*Jdet*gauss->weight*vbasis[i]; 447 486 } 448 487 } … … 459 498 */ 460 499 for(i=0;i<vnumnodes;i++){ 461 scale=1./(S*2*sqrt(pow(vx-vxobs,2)+pow(vy-vyobs,2))+epsvel); 462 dux=scale*(vxobs-vx); 463 duy=scale*(vyobs-vy); 464 pe->values[i*dim+0]+=dux*weight*Jdet*gauss->weight*vbasis[i]; 465 pe->values[i*dim+1]+=duy*weight*Jdet*gauss->weight*vbasis[i]; 500 if (domaintype!=Domain2DverticalEnum){ 501 scale=1./(S*2*sqrt(pow(vx-vxobs,2)+pow(vy-vyobs,2))+epsvel); 502 dux=scale*(vxobs-vx); 503 duy=scale*(vyobs-vy); 504 pe->values[i*3+0]+=dux*weight*Jdet*gauss->weight*vbasis[i]; 505 pe->values[i*3+1]+=duy*weight*Jdet*gauss->weight*vbasis[i]; 506 } 507 else{ 508 scale=1./(S*2*fabs(vx-vxobs)+epsvel); 509 dux=scale*(vxobs-vx); 510 pe->values[i*2+0]+=dux*weight*Jdet*gauss->weight*vbasis[i]; 511 } 466 512 } 467 513 break; … … 477 523 */ 478 524 for(i=0;i<vnumnodes;i++){ 479 dux = - meanvel*meanvel * log((fabs(vx)+epsvel)/(fabs(vxobs)+epsvel)) / (vx+epsvel); 480 duy = - meanvel*meanvel * log((fabs(vy)+epsvel)/(fabs(vyobs)+epsvel)) / (vy+epsvel); 481 pe->values[i*dim+0]+=dux*weight*Jdet*gauss->weight*vbasis[i]; 482 pe->values[i*dim+1]+=duy*weight*Jdet*gauss->weight*vbasis[i]; 525 if(domaintype!=Domain2DverticalEnum){ 526 dux = - meanvel*meanvel * log((fabs(vx)+epsvel)/(fabs(vxobs)+epsvel)) / (vx+epsvel); 527 duy = - meanvel*meanvel * log((fabs(vy)+epsvel)/(fabs(vyobs)+epsvel)) / (vy+epsvel); 528 pe->values[i*3+0]+=dux*weight*Jdet*gauss->weight*vbasis[i]; 529 pe->values[i*3+1]+=duy*weight*Jdet*gauss->weight*vbasis[i]; 530 } 531 else{ 532 dux = - meanvel*meanvel * log((fabs(vx)+epsvel)/(fabs(vxobs)+epsvel)) / (vx+epsvel); 533 pe->values[i*2+0]+=dux*weight*Jdet*gauss->weight*vbasis[i]; 534 } 483 535 } 484 536 break; … … 515 567 return pe; 516 568 }/*}}}*/ 569 ElementVector* AdjointHorizAnalysis::CreatePVectorL1L2(Element* element){/*{{{*/ 570 571 /*Same as SSA*/ 572 return this->CreatePVectorSSA(element); 573 }/*}}}*/ 517 574 ElementVector* AdjointHorizAnalysis::CreatePVectorHO(Element* element){/*{{{*/ 518 575 … … 521 578 522 579 /*Intermediaries */ 523 int num_responses,i ;580 int num_responses,i,domaintype; 524 581 IssmDouble Jdet,obs_velocity_mag,velocity_mag; 525 582 IssmDouble vx,vy,vxobs,vyobs,dux,duy,weight; … … 527 584 int *responses = NULL; 528 585 IssmDouble *xyz_list_top = NULL; 586 587 /* Get domaintype*/ 588 element->FindParam(&domaintype,DomainTypeEnum); 529 589 530 590 /*Fetch number of nodes and dof for this finite element*/ … … 541 601 Input* weights_input = element->GetInput(InversionCostFunctionsCoefficientsEnum); _assert_(weights_input); 542 602 Input* vx_input = element->GetInput(VxEnum); _assert_(vx_input); 543 Input* vy_input = element->GetInput(VyEnum); _assert_(vy_input);544 603 Input* vxobs_input = element->GetInput(InversionVxObsEnum); _assert_(vxobs_input); 545 Input* vyobs_input = element->GetInput(InversionVyObsEnum); _assert_(vyobs_input); 604 Input* vy_input=NULL; 605 Input* vyobs_input=NULL; 606 if(domaintype!=Domain2DverticalEnum){ 607 vy_input = element->GetInput(VyEnum); _assert_(vy_input); 608 vyobs_input = element->GetInput(InversionVyObsEnum); _assert_(vyobs_input); 609 } 546 610 IssmDouble epsvel = 2.220446049250313e-16; 547 611 IssmDouble meanvel = 3.170979198376458e-05; /*1000 m/yr*/ … … 563 627 564 628 vx_input->GetInputValue(&vx,gauss); 565 vy_input->GetInputValue(&vy,gauss);566 629 vxobs_input->GetInputValue(&vxobs,gauss); 567 vyobs_input->GetInputValue(&vyobs,gauss); 568 630 if(domaintype!=Domain2DverticalEnum){ 631 vy_input->GetInputValue(&vy,gauss); 632 vyobs_input->GetInputValue(&vyobs,gauss); 633 } 569 634 /*Loop over all requested responses*/ 570 635 for(int resp=0;resp<num_responses;resp++){ … … 583 648 */ 584 649 for(i=0;i<numnodes;i++){ 585 dux=vxobs-vx; 586 duy=vyobs-vy; 587 pe->values[i*2+0]+=dux*weight*Jdet*gauss->weight*basis[i]; 588 pe->values[i*2+1]+=duy*weight*Jdet*gauss->weight*basis[i]; 650 if(domaintype!=Domain2DverticalEnum){ 651 dux=vxobs-vx; 652 duy=vyobs-vy; 653 pe->values[i*2+0]+=dux*weight*Jdet*gauss->weight*basis[i]; 654 pe->values[i*2+1]+=duy*weight*Jdet*gauss->weight*basis[i]; 655 } 656 else{ 657 dux=vxobs-vx; 658 pe->values[i]+=dux*weight*Jdet*gauss->weight*basis[i]; 659 } 589 660 } 590 661 break; … … 602 673 */ 603 674 for(i=0;i<numnodes;i++){ 604 scalex=pow(meanvel/(vxobs+epsvel),2); if(vxobs==0)scalex=0; 605 scaley=pow(meanvel/(vyobs+epsvel),2); if(vyobs==0)scaley=0; 606 dux=scalex*(vxobs-vx); 607 duy=scaley*(vyobs-vy); 608 pe->values[i*2+0]+=dux*weight*Jdet*gauss->weight*basis[i]; 609 pe->values[i*2+1]+=duy*weight*Jdet*gauss->weight*basis[i]; 675 if(domaintype!=Domain2DverticalEnum){ 676 scalex=pow(meanvel/(vxobs+epsvel),2); if(vxobs==0)scalex=0; 677 scaley=pow(meanvel/(vyobs+epsvel),2); if(vyobs==0)scaley=0; 678 dux=scalex*(vxobs-vx); 679 duy=scaley*(vyobs-vy); 680 pe->values[i*2+0]+=dux*weight*Jdet*gauss->weight*basis[i]; 681 pe->values[i*2+1]+=duy*weight*Jdet*gauss->weight*basis[i]; 682 } 683 else{ 684 scalex=pow(meanvel/(vxobs+epsvel),2); if(vxobs==0)scalex=0; 685 dux=scalex*(vxobs-vx); 686 pe->values[i]+=dux*weight*Jdet*gauss->weight*basis[i]; 687 } 610 688 } 611 689 break; … … 623 701 */ 624 702 for(i=0;i<numnodes;i++){ 625 velocity_mag =sqrt(pow(vx, 2)+pow(vy, 2))+epsvel; 626 obs_velocity_mag=sqrt(pow(vxobs,2)+pow(vyobs,2))+epsvel; 627 scale=-8*pow(meanvel,2)/pow(velocity_mag,2)*log(velocity_mag/obs_velocity_mag); 628 dux=scale*vx; 629 duy=scale*vy; 630 pe->values[i*2+0]+=dux*weight*Jdet*gauss->weight*basis[i]; 631 pe->values[i*2+1]+=duy*weight*Jdet*gauss->weight*basis[i]; 703 if(domaintype!=Domain2DverticalEnum){ 704 velocity_mag =sqrt(pow(vx, 2)+pow(vy, 2))+epsvel; 705 obs_velocity_mag=sqrt(pow(vxobs,2)+pow(vyobs,2))+epsvel; 706 scale=-8*pow(meanvel,2)/pow(velocity_mag,2)*log(velocity_mag/obs_velocity_mag); 707 dux=scale*vx; 708 duy=scale*vy; 709 pe->values[i*2+0]+=dux*weight*Jdet*gauss->weight*basis[i]; 710 pe->values[i*2+1]+=duy*weight*Jdet*gauss->weight*basis[i]; 711 } 712 else{ 713 velocity_mag =fabs(vx)+epsvel; 714 obs_velocity_mag=fabs(vxobs)+epsvel; 715 scale=-8*pow(meanvel,2)/pow(velocity_mag,2)*log(velocity_mag/obs_velocity_mag); 716 dux=scale*vx; 717 pe->values[i]+=dux*weight*Jdet*gauss->weight*basis[i]; 718 } 632 719 } 633 720 break; … … 643 730 */ 644 731 for(i=0;i<numnodes;i++){ 645 scale=1./(S*2*sqrt(pow(vx-vxobs,2)+pow(vy-vyobs,2))+epsvel); 646 dux=scale*(vxobs-vx); 647 duy=scale*(vyobs-vy); 648 pe->values[i*2+0]+=dux*weight*Jdet*gauss->weight*basis[i]; 649 pe->values[i*2+1]+=duy*weight*Jdet*gauss->weight*basis[i]; 732 if(domaintype!=Domain2DverticalEnum){ 733 scale=1./(S*2*sqrt(pow(vx-vxobs,2)+pow(vy-vyobs,2))+epsvel); 734 dux=scale*(vxobs-vx); 735 duy=scale*(vyobs-vy); 736 pe->values[i*2+0]+=dux*weight*Jdet*gauss->weight*basis[i]; 737 pe->values[i*2+1]+=duy*weight*Jdet*gauss->weight*basis[i]; 738 } 739 else{ 740 scale=1./(S*2*fabs(vx-vxobs)+epsvel); 741 dux=scale*(vxobs-vx); 742 pe->values[i]+=dux*weight*Jdet*gauss->weight*basis[i]; 743 } 650 744 } 651 745 break; … … 661 755 */ 662 756 for(i=0;i<numnodes;i++){ 663 dux = - meanvel*meanvel * log((fabs(vx)+epsvel)/(fabs(vxobs)+epsvel)) / (vx+epsvel); 664 duy = - meanvel*meanvel * log((fabs(vy)+epsvel)/(fabs(vyobs)+epsvel)) / (vy+epsvel); 665 pe->values[i*2+0]+=dux*weight*Jdet*gauss->weight*basis[i]; 666 pe->values[i*2+1]+=duy*weight*Jdet*gauss->weight*basis[i]; 757 if(domaintype!=Domain2DverticalEnum){ 758 dux = - meanvel*meanvel * log((fabs(vx)+epsvel)/(fabs(vxobs)+epsvel)) / (vx+epsvel); 759 duy = - meanvel*meanvel * log((fabs(vy)+epsvel)/(fabs(vyobs)+epsvel)) / (vy+epsvel); 760 pe->values[i*2+0]+=dux*weight*Jdet*gauss->weight*basis[i]; 761 pe->values[i*2+1]+=duy*weight*Jdet*gauss->weight*basis[i]; 762 } 763 else{ 764 dux = - meanvel*meanvel * log((fabs(vx)+epsvel)/(fabs(vxobs)+epsvel)) / (vx+epsvel); 765 pe->values[i]+=dux*weight*Jdet*gauss->weight*basis[i]; 766 } 667 767 } 668 768 break; … … 680 780 break; 681 781 case RheologyBbarAbsGradientEnum: 782 /*Nothing in P vector*/ 783 break; 784 case RheologyBAbsGradientEnum: 682 785 /*Nothing in P vector*/ 683 786 break; … … 689 792 690 793 /*Transform coordinate system*/ 691 element->TransformLoadVectorCoord(pe,XYEnum);794 if(domaintype!=Domain2DverticalEnum) element->TransformLoadVectorCoord(pe,XYEnum); 692 795 693 796 /*Clean up and return*/ … … 710 813 case Domain2DhorizontalEnum: 711 814 basalelement = element; 815 break; 816 case Domain2DverticalEnum: 817 if(!element->IsOnBase()) return NULL; 818 basalelement = element->SpawnBasalElement(); 712 819 break; 713 820 case Domain3DEnum: … … 739 846 Input* weights_input = basalelement->GetInput(InversionCostFunctionsCoefficientsEnum); _assert_(weights_input); 740 847 Input* vx_input = basalelement->GetInput(VxEnum); _assert_(vx_input); 741 Input* vy_input = basalelement->GetInput(VyEnum); _assert_(vy_input);742 848 Input* vxobs_input = basalelement->GetInput(InversionVxObsEnum); _assert_(vxobs_input); 743 Input* vyobs_input = basalelement->GetInput(InversionVyObsEnum); _assert_(vyobs_input); 849 Input* vy_input=NULL; 850 Input* vyobs_input=NULL; 851 if(domaintype!=Domain2DverticalEnum){ 852 vy_input = basalelement->GetInput(VyEnum); _assert_(vy_input); 853 vyobs_input = basalelement->GetInput(InversionVyObsEnum); _assert_(vyobs_input); 854 } 744 855 IssmDouble epsvel = 2.220446049250313e-16; 745 856 IssmDouble meanvel = 3.170979198376458e-05; /*1000 m/yr*/ … … 761 872 762 873 vx_input->GetInputValue(&vx,gauss); 763 vy_input->GetInputValue(&vy,gauss);764 874 vxobs_input->GetInputValue(&vxobs,gauss); 765 vyobs_input->GetInputValue(&vyobs,gauss); 766 875 if(domaintype!=Domain2DverticalEnum){ 876 vy_input->GetInputValue(&vy,gauss); 877 vyobs_input->GetInputValue(&vyobs,gauss); 878 } 767 879 /*Loop over all requested responses*/ 768 880 for(int resp=0;resp<num_responses;resp++){ … … 781 893 */ 782 894 for(i=0;i<numnodes;i++){ 783 dux=vxobs-vx; 784 duy=vyobs-vy; 785 pe->values[i*2+0]+=dux*weight*Jdet*gauss->weight*basis[i]; 786 pe->values[i*2+1]+=duy*weight*Jdet*gauss->weight*basis[i]; 895 if(domaintype!=Domain2DverticalEnum){ 896 dux=vxobs-vx; 897 duy=vyobs-vy; 898 pe->values[i*2+0]+=dux*weight*Jdet*gauss->weight*basis[i]; 899 pe->values[i*2+1]+=duy*weight*Jdet*gauss->weight*basis[i]; 900 } 901 else { 902 dux=vxobs-vx; 903 pe->values[i]+=dux*weight*Jdet*gauss->weight*basis[i]; 904 } 787 905 } 788 906 break; … … 800 918 */ 801 919 for(i=0;i<numnodes;i++){ 802 scalex=pow(meanvel/(vxobs+epsvel),2); if(vxobs==0)scalex=0; 803 scaley=pow(meanvel/(vyobs+epsvel),2); if(vyobs==0)scaley=0; 804 dux=scalex*(vxobs-vx); 805 duy=scaley*(vyobs-vy); 806 pe->values[i*2+0]+=dux*weight*Jdet*gauss->weight*basis[i]; 807 pe->values[i*2+1]+=duy*weight*Jdet*gauss->weight*basis[i]; 920 if(domaintype!=Domain2DverticalEnum){ 921 scalex=pow(meanvel/(vxobs+epsvel),2); if(vxobs==0)scalex=0; 922 scaley=pow(meanvel/(vyobs+epsvel),2); if(vyobs==0)scaley=0; 923 dux=scalex*(vxobs-vx); 924 duy=scaley*(vyobs-vy); 925 pe->values[i*2+0]+=dux*weight*Jdet*gauss->weight*basis[i]; 926 pe->values[i*2+1]+=duy*weight*Jdet*gauss->weight*basis[i]; 927 } 928 else{ 929 scalex=pow(meanvel/(vxobs+epsvel),2); if(vxobs==0)scalex=0; 930 dux=scalex*(vxobs-vx); 931 pe->values[i]+=dux*weight*Jdet*gauss->weight*basis[i]; 932 } 808 933 } 809 934 break; … … 821 946 */ 822 947 for(i=0;i<numnodes;i++){ 823 velocity_mag =sqrt(pow(vx, 2)+pow(vy, 2))+epsvel; 824 obs_velocity_mag=sqrt(pow(vxobs,2)+pow(vyobs,2))+epsvel; 825 scale=-8*pow(meanvel,2)/pow(velocity_mag,2)*log(velocity_mag/obs_velocity_mag); 826 dux=scale*vx; 827 duy=scale*vy; 828 pe->values[i*2+0]+=dux*weight*Jdet*gauss->weight*basis[i]; 829 pe->values[i*2+1]+=duy*weight*Jdet*gauss->weight*basis[i]; 948 if(domaintype!=Domain2DverticalEnum){ 949 velocity_mag =sqrt(pow(vx, 2)+pow(vy, 2))+epsvel; 950 obs_velocity_mag=sqrt(pow(vxobs,2)+pow(vyobs,2))+epsvel; 951 scale=-8*pow(meanvel,2)/pow(velocity_mag,2)*log(velocity_mag/obs_velocity_mag); 952 dux=scale*vx; 953 duy=scale*vy; 954 pe->values[i*2+0]+=dux*weight*Jdet*gauss->weight*basis[i]; 955 pe->values[i*2+1]+=duy*weight*Jdet*gauss->weight*basis[i]; 956 } 957 else{ 958 velocity_mag =fabs(vx)+epsvel; 959 obs_velocity_mag=fabs(vxobs)+epsvel; 960 scale=-8*pow(meanvel,2)/pow(velocity_mag,2)*log(velocity_mag/obs_velocity_mag); 961 dux=scale*vx; 962 pe->values[i]+=dux*weight*Jdet*gauss->weight*basis[i]; 963 } 830 964 } 831 965 break; … … 841 975 */ 842 976 for(i=0;i<numnodes;i++){ 843 scale=1./(S*2*sqrt(pow(vx-vxobs,2)+pow(vy-vyobs,2))+epsvel); 844 dux=scale*(vxobs-vx); 845 duy=scale*(vyobs-vy); 846 pe->values[i*2+0]+=dux*weight*Jdet*gauss->weight*basis[i]; 847 pe->values[i*2+1]+=duy*weight*Jdet*gauss->weight*basis[i]; 977 if(domaintype!=Domain2DverticalEnum){ 978 scale=1./(S*2*sqrt(pow(vx-vxobs,2)+pow(vy-vyobs,2))+epsvel); 979 dux=scale*(vxobs-vx); 980 duy=scale*(vyobs-vy); 981 pe->values[i*2+0]+=dux*weight*Jdet*gauss->weight*basis[i]; 982 pe->values[i*2+1]+=duy*weight*Jdet*gauss->weight*basis[i]; 983 } 984 else{ 985 scale=1./(S*2*fabs(vx-vxobs)+epsvel); 986 dux=scale*(vxobs-vx); 987 pe->values[i]+=dux*weight*Jdet*gauss->weight*basis[i]; 988 } 848 989 } 849 990 break; … … 859 1000 */ 860 1001 for(i=0;i<numnodes;i++){ 861 dux = - meanvel*meanvel * log((fabs(vx)+epsvel)/(fabs(vxobs)+epsvel)) / (vx+epsvel); 862 duy = - meanvel*meanvel * log((fabs(vy)+epsvel)/(fabs(vyobs)+epsvel)) / (vy+epsvel); 863 pe->values[i*2+0]+=dux*weight*Jdet*gauss->weight*basis[i]; 864 pe->values[i*2+1]+=duy*weight*Jdet*gauss->weight*basis[i]; 1002 if(domaintype!=Domain2DverticalEnum){ 1003 dux = - meanvel*meanvel * log((fabs(vx)+epsvel)/(fabs(vxobs)+epsvel)) / (vx+epsvel); 1004 duy = - meanvel*meanvel * log((fabs(vy)+epsvel)/(fabs(vyobs)+epsvel)) / (vy+epsvel); 1005 pe->values[i*2+0]+=dux*weight*Jdet*gauss->weight*basis[i]; 1006 pe->values[i*2+1]+=duy*weight*Jdet*gauss->weight*basis[i]; 1007 } 1008 else{ 1009 dux = - meanvel*meanvel * log((fabs(vx)+epsvel)/(fabs(vxobs)+epsvel)) / (vx+epsvel); 1010 pe->values[i]+=dux*weight*Jdet*gauss->weight*basis[i]; 1011 } 865 1012 } 866 1013 break; … … 878 1025 break; 879 1026 case RheologyBbarAbsGradientEnum: 1027 /*Nothing in P vector*/ 1028 break; 1029 case RheologyBAbsGradientEnum: 880 1030 /*Nothing in P vector*/ 881 1031 break; … … 887 1037 888 1038 /*Transform coordinate system*/ 889 basalelement->TransformLoadVectorCoord(pe,XYEnum);1039 if(domaintype!=Domain2DverticalEnum) basalelement->TransformLoadVectorCoord(pe,XYEnum); 890 1040 891 1041 /*Clean up and return*/ … … 897 1047 return pe; 898 1048 }/*}}}*/ 899 void AdjointHorizAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/1049 void AdjointHorizAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 900 1050 _error_("not implemented yet"); 901 1051 }/*}}}*/ 902 void AdjointHorizAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/1052 void AdjointHorizAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 903 1053 /*The gradient of the cost function is calculated in 2 parts. 904 1054 * … … 924 1074 /*Check that control_type is supported*/ 925 1075 if(control_type!=MaterialsRheologyBbarEnum && 926 control_type!=FrictionCoefficientEnum && 927 control_type!=DamageDbarEnum){ 1076 control_type!=FrictionCoefficientEnum && 1077 control_type!=FrictionAsEnum && 1078 control_type!=DamageDbarEnum && 1079 control_type!=MaterialsRheologyBEnum){ 928 1080 _error_("Control "<<EnumToStringx(control_type)<<" not supported"); 929 1081 } … … 937 1089 case SurfaceAverageVelMisfitEnum: /*Nothing, \partial J/\partial k = 0*/ break; 938 1090 case DragCoefficientAbsGradientEnum: GradientJDragGradient(element,gradient,control_index); break; 939 case RheologyBbarAbsGradientEnum: GradientJBGradient(element,gradient,control_index); break; 1091 case RheologyBbarAbsGradientEnum: GradientJBbarGradient(element,gradient,control_index); break; 1092 case RheologyBAbsGradientEnum: GradientJBGradient(element,gradient,control_index); break; 940 1093 default: _error_("response " << EnumToStringx(responses[resp]) << " not supported yet"); 941 1094 } … … 946 1099 switch(approximation){ 947 1100 case SSAApproximationEnum: GradientJDragSSA(element,gradient,control_index); break; 1101 case L1L2ApproximationEnum:GradientJDragL1L2(element,gradient,control_index); break; 948 1102 case HOApproximationEnum: GradientJDragHO( element,gradient,control_index); break; 949 1103 case FSApproximationEnum: GradientJDragFS( element,gradient,control_index); break; … … 952 1106 } 953 1107 break; 1108 case FrictionAsEnum: 1109 switch(approximation){ 1110 case SSAApproximationEnum: GradientJDragHydroSSA(element,gradient,control_index); break; 1111 case L1L2ApproximationEnum:GradientJDragHydroL1L2(element,gradient,control_index); break; 1112 case HOApproximationEnum: GradientJDragHydroHO( element,gradient,control_index); break; 1113 case FSApproximationEnum: GradientJDragHydroFS( element,gradient,control_index); break; 1114 case NoneApproximationEnum: /*Gradient is 0*/ break; 1115 default: _error_("approximation " << EnumToStringx(approximation) << " not supported yet"); 1116 } 1117 break; 954 1118 case MaterialsRheologyBbarEnum: 955 1119 switch(approximation){ 956 1120 case SSAApproximationEnum: GradientJBbarSSA(element,gradient,control_index); break; 1121 case L1L2ApproximationEnum:GradientJBbarL1L2(element,gradient,control_index); break; 957 1122 case HOApproximationEnum: GradientJBbarHO( element,gradient,control_index); break; 958 1123 case FSApproximationEnum: GradientJBbarFS( element,gradient,control_index); break; 1124 case NoneApproximationEnum: /*Gradient is 0*/ break; 1125 default: _error_("approximation " << EnumToStringx(approximation) << " not supported yet"); 1126 } 1127 break; 1128 case MaterialsRheologyBEnum: 1129 switch(approximation){ 1130 case SSAApproximationEnum: GradientJBSSA(element,gradient,control_index); break; 1131 case HOApproximationEnum: GradientJBHO( element,gradient,control_index); break; 1132 case FSApproximationEnum: GradientJBFS( element,gradient,control_index); break; 959 1133 case NoneApproximationEnum: /*Gradient is 0*/ break; 960 1134 default: _error_("approximation " << EnumToStringx(approximation) << " not supported yet"); … … 975 1149 976 1150 }/*}}}*/ 977 void AdjointHorizAnalysis::GradientJDragGradient(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 1151 void AdjointHorizAnalysis::GradientJBbarFS(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 1152 /*WARNING: We use SSA as an estimate for now*/ 1153 this->GradientJBbarSSA(element,gradient,control_index); 1154 }/*}}}*/ 1155 void AdjointHorizAnalysis::GradientJBbarGradient(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 1156 1157 /*Intermediaries*/ 1158 int domaintype; 1159 Element* basalelement; 1160 1161 /*Get basal element*/ 1162 element->FindParam(&domaintype,DomainTypeEnum); 1163 switch(domaintype){ 1164 case Domain2DhorizontalEnum: 1165 basalelement = element; 1166 break; 1167 case Domain2DverticalEnum: 1168 if(!element->IsOnBase()) return; 1169 basalelement = element->SpawnBasalElement(); 1170 break; 1171 case Domain3DEnum: 1172 if(!element->IsOnBase()) return; 1173 basalelement = element->SpawnBasalElement(); 1174 break; 1175 default: _error_("mesh "<<EnumToStringx(domaintype)<<" not supported yet"); 1176 } 1177 1178 /*Intermediaries*/ 1179 IssmDouble Jdet,weight; 1180 IssmDouble dk[3]; 1181 IssmDouble *xyz_list= NULL; 1182 1183 /*Fetch number of vertices for this finite element*/ 1184 int numvertices = basalelement->GetNumberOfVertices(); 1185 1186 /*Initialize some vectors*/ 1187 IssmDouble* dbasis = xNew<IssmDouble>(2*numvertices); 1188 IssmDouble* ge = xNewZeroInit<IssmDouble>(numvertices); 1189 int* vertexpidlist = xNew<int>(numvertices); 1190 1191 /*Retrieve all inputs we will be needing: */ 1192 basalelement->GetVerticesCoordinates(&xyz_list); 1193 basalelement->GradientIndexing(&vertexpidlist[0],control_index); 1194 Input* rheologyb_input = basalelement->GetInput(MaterialsRheologyBbarEnum); _assert_(rheologyb_input); 1195 Input* weights_input = basalelement->GetInput(InversionCostFunctionsCoefficientsEnum); _assert_(weights_input); 1196 1197 /* Start looping on the number of gaussian points: */ 1198 Gauss* gauss=basalelement->NewGauss(2); 1199 for(int ig=gauss->begin();ig<gauss->end();ig++){ 1200 gauss->GaussPoint(ig); 1201 1202 basalelement->JacobianDeterminant(&Jdet,xyz_list,gauss); 1203 basalelement->NodalFunctionsP1Derivatives(dbasis,xyz_list,gauss); 1204 weights_input->GetInputValue(&weight,gauss,RheologyBbarAbsGradientEnum); 1205 1206 /*Build alpha_complement_list: */ 1207 rheologyb_input->GetInputDerivativeValue(&dk[0],xyz_list,gauss); 1208 1209 /*Build gradje_g_gaussian vector (actually -dJ/ddrag): */ 1210 for(int i=0;i<numvertices;i++){ 1211 if(domaintype!=Domain2DverticalEnum){ 1212 ge[i]+=-weight*Jdet*gauss->weight*(dbasis[0*numvertices+i]*dk[0]+dbasis[1*numvertices+i]*dk[1]); 1213 } 1214 else{ 1215 ge[i]+=-weight*Jdet*gauss->weight*dbasis[0*numvertices+i]*dk[0]; 1216 } 1217 _assert_(!xIsNan<IssmDouble>(ge[i])); 1218 } 1219 } 1220 gradient->SetValues(numvertices,vertexpidlist,ge,ADD_VAL); 1221 1222 /*Clean up and return*/ 1223 xDelete<IssmDouble>(xyz_list); 1224 xDelete<IssmDouble>(dbasis); 1225 xDelete<IssmDouble>(ge); 1226 xDelete<int>(vertexpidlist); 1227 delete gauss; 1228 if(domaintype!=Domain2DhorizontalEnum){basalelement->DeleteMaterials(); delete basalelement;}; 1229 }/*}}}*/ 1230 void AdjointHorizAnalysis::GradientJBbarL1L2(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 1231 1232 /*Same as SSA*/ 1233 return this->GradientJBbarSSA(element,gradient,control_index); 1234 }/*}}}*/ 1235 void AdjointHorizAnalysis::GradientJBbarHO(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 1236 1237 /*WARNING: We use SSA as an estimate for now*/ 1238 this->GradientJBbarSSA(element,gradient,control_index); 1239 }/*}}}*/ 1240 void AdjointHorizAnalysis::GradientJBbarSSA(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 1241 1242 /*Intermediaries*/ 1243 int domaintype,dim; 1244 Element* basalelement; 1245 1246 /*Get basal element*/ 1247 element->FindParam(&domaintype,DomainTypeEnum); 1248 switch(domaintype){ 1249 case Domain2DhorizontalEnum: 1250 basalelement = element; 1251 dim = 2; 1252 break; 1253 case Domain2DverticalEnum: 1254 if(!element->IsOnBase()) return; 1255 basalelement = element->SpawnBasalElement(); 1256 dim = 1; 1257 break; 1258 case Domain3DEnum: 1259 if(!element->IsOnBase()) return; 1260 basalelement = element->SpawnBasalElement(); 1261 dim = 2; 1262 break; 1263 default: _error_("mesh "<<EnumToStringx(domaintype)<<" not supported yet"); 1264 } 1265 1266 /*Intermediaries*/ 1267 IssmDouble Jdet,weight; 1268 IssmDouble thickness,dmudB; 1269 IssmDouble dvx[3],dvy[3],dadjx[3],dadjy[3]; 1270 IssmDouble *xyz_list= NULL; 1271 1272 /*Fetch number of vertices for this finite element*/ 1273 int numvertices = basalelement->GetNumberOfVertices(); 1274 1275 /*Initialize some vectors*/ 1276 IssmDouble* basis = xNew<IssmDouble>(numvertices); 1277 IssmDouble* ge = xNewZeroInit<IssmDouble>(numvertices); 1278 int* vertexpidlist = xNew<int>(numvertices); 1279 1280 /*Retrieve all inputs we will be needing: */ 1281 basalelement->GetVerticesCoordinates(&xyz_list); 1282 basalelement->GradientIndexing(&vertexpidlist[0],control_index); 1283 Input* thickness_input = basalelement->GetInput(ThicknessEnum); _assert_(thickness_input); 1284 Input* vx_input = basalelement->GetInput(VxEnum); _assert_(vx_input); 1285 Input* vy_input = basalelement->GetInput(VyEnum); _assert_(vy_input); 1286 Input* adjointx_input = basalelement->GetInput(AdjointxEnum); _assert_(adjointx_input); 1287 Input* adjointy_input = basalelement->GetInput(AdjointyEnum); _assert_(adjointy_input); 1288 Input* rheologyb_input = basalelement->GetInput(MaterialsRheologyBbarEnum); _assert_(rheologyb_input); 1289 1290 /* Start looping on the number of gaussian points: */ 1291 Gauss* gauss=basalelement->NewGauss(4); 1292 for(int ig=gauss->begin();ig<gauss->end();ig++){ 1293 gauss->GaussPoint(ig); 1294 1295 thickness_input->GetInputValue(&thickness,gauss); 1296 vx_input->GetInputDerivativeValue(&dvx[0],xyz_list,gauss); 1297 vy_input->GetInputDerivativeValue(&dvy[0],xyz_list,gauss); 1298 adjointx_input->GetInputDerivativeValue(&dadjx[0],xyz_list,gauss); 1299 adjointy_input->GetInputDerivativeValue(&dadjy[0],xyz_list,gauss); 1300 1301 basalelement->dViscositydBSSA(&dmudB,dim,xyz_list,gauss,vx_input,vy_input); 1302 1303 basalelement->JacobianDeterminant(&Jdet,xyz_list,gauss); 1304 basalelement->NodalFunctionsP1(basis,gauss); 1305 1306 /*Build gradient vector (actually -dJ/dB): */ 1307 for(int i=0;i<numvertices;i++){ 1308 ge[i]+=-dmudB*thickness*( 1309 (2*dvx[0]+dvy[1])*2*dadjx[0]+(dvx[1]+dvy[0])*(dadjx[1]+dadjy[0])+(2*dvy[1]+dvx[0])*2*dadjy[1] 1310 )*Jdet*gauss->weight*basis[i]; 1311 _assert_(!xIsNan<IssmDouble>(ge[i])); 1312 } 1313 } 1314 gradient->SetValues(numvertices,vertexpidlist,ge,ADD_VAL); 1315 1316 /*Clean up and return*/ 1317 xDelete<IssmDouble>(xyz_list); 1318 xDelete<IssmDouble>(basis); 1319 xDelete<IssmDouble>(ge); 1320 xDelete<int>(vertexpidlist); 1321 delete gauss; 1322 if(domaintype!=Domain2DhorizontalEnum){basalelement->DeleteMaterials(); delete basalelement;}; 1323 }/*}}}*/ 1324 void AdjointHorizAnalysis::GradientJBFS(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 1325 /*WARNING: We use HO as an estimate for now*/ 1326 this->GradientJBHO(element,gradient,control_index); 1327 }/*}}}*/ 1328 void AdjointHorizAnalysis::GradientJBGradient(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 1329 1330 /*Intermediaries*/ 1331 int domaintype; 1332 1333 /*Get basal element*/ 1334 element->FindParam(&domaintype,DomainTypeEnum); 1335 switch(domaintype){ 1336 case Domain2DhorizontalEnum: 1337 break; 1338 case Domain2DverticalEnum: 1339 break; 1340 case Domain3DEnum: 1341 break; 1342 default: _error_("mesh "<<EnumToStringx(domaintype)<<" not supported yet"); 1343 } 1344 1345 /*Intermediaries*/ 1346 IssmDouble Jdet,weight; 1347 IssmDouble dk[3]; 1348 IssmDouble *xyz_list= NULL; 1349 1350 /*Fetch number of vertices for this finite element*/ 1351 int numvertices = element->GetNumberOfVertices(); 1352 1353 /*Initialize some vectors*/ 1354 IssmDouble* dbasis = xNew<IssmDouble>(3*numvertices); 1355 IssmDouble* ge = xNewZeroInit<IssmDouble>(numvertices); 1356 int* vertexpidlist = xNew<int>(numvertices); 1357 1358 /*Retrieve all inputs we will be needing: */ 1359 element->GetVerticesCoordinates(&xyz_list); 1360 element->GradientIndexing(&vertexpidlist[0],control_index); 1361 Input* rheology_input = element->GetInput(MaterialsRheologyBEnum); _assert_(rheology_input); 1362 Input* weights_input = element->GetInput(InversionCostFunctionsCoefficientsEnum); _assert_(weights_input); 1363 /* Start looping on the number of gaussian points: */ 1364 Gauss* gauss=element->NewGauss(2); 1365 for(int ig=gauss->begin();ig<gauss->end();ig++){ 1366 gauss->GaussPoint(ig); 1367 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 1368 element->NodalFunctionsP1Derivatives(dbasis,xyz_list,gauss); 1369 weights_input->GetInputValue(&weight,gauss,RheologyBAbsGradientEnum); 1370 1371 /*Build alpha_complement_list: */ 1372 rheology_input->GetInputDerivativeValue(&dk[0],xyz_list,gauss); 1373 1374 /*Build gradje_g_gaussian vector (actually -dJ/ddrag): */ 1375 for(int i=0;i<numvertices;i++){ 1376 if(domaintype!=Domain2DverticalEnum){ 1377 ge[i]+=-weight*Jdet*gauss->weight*(dbasis[0*numvertices+i]*dk[0]+dbasis[1*numvertices+i]*dk[1]); 1378 } 1379 else{ 1380 ge[i]+=-weight*Jdet*gauss->weight*(dbasis[0*numvertices+i]*dk[0]+dbasis[1*numvertices+i]*dk[1]+dbasis[2*numvertices+i]*dk[2]); 1381 } 1382 _assert_(!xIsNan<IssmDouble>(ge[i])); 1383 } 1384 } 1385 gradient->SetValues(numvertices,vertexpidlist,ge,ADD_VAL); 1386 1387 /*Clean up and return*/ 1388 xDelete<IssmDouble>(xyz_list); 1389 xDelete<IssmDouble>(dbasis); 1390 xDelete<IssmDouble>(ge); 1391 xDelete<int>(vertexpidlist); 1392 delete gauss; 1393 }/*}}}*/ 1394 void AdjointHorizAnalysis::GradientJBHO(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 1395 /*Intermediaries*/ 1396 int domaintype,dim; 1397 1398 /*Get domaintype*/ 1399 element->FindParam(&domaintype,DomainTypeEnum); 1400 1401 /*Intermediaries*/ 1402 IssmDouble Jdet,weight; 1403 IssmDouble thickness,dmudB; 1404 IssmDouble dvx[3],dvy[3],dadjx[3],dadjy[3]; 1405 IssmDouble *xyz_list= NULL; 1406 1407 /*Fetch number of vertices for this finite element*/ 1408 int numvertices = element->GetNumberOfVertices(); 1409 1410 /*Initialize some vectors*/ 1411 IssmDouble* basis = xNew<IssmDouble>(numvertices); 1412 IssmDouble* ge = xNewZeroInit<IssmDouble>(numvertices); 1413 int* vertexpidlist = xNew<int>(numvertices); 1414 1415 /*Retrieve all inputs we will be needing: */ 1416 element->GetVerticesCoordinates(&xyz_list); 1417 element->GradientIndexing(&vertexpidlist[0],control_index); 1418 Input* thickness_input = element->GetInput(ThicknessEnum); _assert_(thickness_input); 1419 Input* vx_input = element->GetInput(VxEnum); _assert_(vx_input); 1420 Input* vy_input = NULL; 1421 Input* adjointx_input = element->GetInput(AdjointxEnum); _assert_(adjointx_input); 1422 Input* adjointy_input = NULL; 1423 Input* rheologyb_input = element->GetInput(MaterialsRheologyBEnum); _assert_(rheologyb_input); 1424 if(domaintype!=Domain2DverticalEnum){ 1425 vy_input = element->GetInput(VyEnum); _assert_(vy_input); 1426 adjointy_input = element->GetInput(AdjointyEnum); _assert_(adjointy_input); 1427 } 1428 /* Start looping on the number of gaussian points: */ 1429 Gauss* gauss=element->NewGauss(4); 1430 for(int ig=gauss->begin();ig<gauss->end();ig++){ 1431 gauss->GaussPoint(ig); 1432 1433 thickness_input->GetInputValue(&thickness,gauss); 1434 vx_input->GetInputDerivativeValue(&dvx[0],xyz_list,gauss); 1435 adjointx_input->GetInputDerivativeValue(&dadjx[0],xyz_list,gauss); 1436 dim=2; 1437 if(domaintype!=Domain2DverticalEnum){ 1438 adjointy_input->GetInputDerivativeValue(&dadjy[0],xyz_list, gauss); 1439 vy_input->GetInputDerivativeValue(&dvy[0],xyz_list,gauss); 1440 dim=3; 1441 } 1442 1443 element->dViscositydBHO(&dmudB,dim,xyz_list,gauss,vx_input,vy_input); 1444 1445 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 1446 element->NodalFunctionsP1(basis,gauss); 1447 1448 /*Build gradient vector (actually -dJ/dB): */ 1449 for(int i=0;i<numvertices;i++){ 1450 if(domaintype!=Domain2DverticalEnum){ 1451 ge[i]+=-dmudB*thickness*( 1452 (2*dvx[0]+dvy[1])*2*dadjx[0]+(dvx[1]+dvy[0])*(dadjx[1]+dadjy[0])+(2*dvy[1]+dvx[0])*2*dadjy[1] 1453 )*Jdet*gauss->weight*basis[i]; 1454 } 1455 else{ 1456 ge[i]+=-dmudB*thickness*4*dvx[0]*dadjx[0]*Jdet*gauss->weight*basis[i]; 1457 } 1458 _assert_(!xIsNan<IssmDouble>(ge[i])); 1459 } 1460 } 1461 gradient->SetValues(numvertices,vertexpidlist,ge,ADD_VAL); 1462 1463 /*Clean up and return*/ 1464 xDelete<IssmDouble>(xyz_list); 1465 xDelete<IssmDouble>(basis); 1466 xDelete<IssmDouble>(ge); 1467 xDelete<int>(vertexpidlist); 1468 delete gauss; 1469 }/*}}}*/ 1470 void AdjointHorizAnalysis::GradientJBSSA(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 1471 1472 /*Intermediaries*/ 1473 int domaintype,dim; 1474 Element* basalelement; 1475 1476 /*Get basal element*/ 1477 element->FindParam(&domaintype,DomainTypeEnum); 1478 switch(domaintype){ 1479 case Domain2DhorizontalEnum: 1480 basalelement = element; 1481 dim = 2; 1482 break; 1483 case Domain2DverticalEnum: 1484 if(!element->IsOnBase()) return; 1485 basalelement = element->SpawnBasalElement(); 1486 dim = 1; 1487 break; 1488 case Domain3DEnum: 1489 if(!element->IsOnBase()) return; 1490 basalelement = element->SpawnBasalElement(); 1491 dim = 2; 1492 break; 1493 default: _error_("mesh "<<EnumToStringx(domaintype)<<" not supported yet"); 1494 } 1495 1496 /*Intermediaries*/ 1497 IssmDouble Jdet,weight; 1498 IssmDouble thickness,dmudB; 1499 IssmDouble dvx[3],dvy[3],dadjx[3],dadjy[3]; 1500 IssmDouble *xyz_list= NULL; 1501 1502 /*Fetch number of vertices for this finite element*/ 1503 int numvertices = basalelement->GetNumberOfVertices(); 1504 1505 /*Initialize some vectors*/ 1506 IssmDouble* basis = xNew<IssmDouble>(numvertices); 1507 IssmDouble* ge = xNewZeroInit<IssmDouble>(numvertices); 1508 int* vertexpidlist = xNew<int>(numvertices); 1509 1510 /*Retrieve all inputs we will be needing: */ 1511 basalelement->GetVerticesCoordinates(&xyz_list); 1512 basalelement->GradientIndexing(&vertexpidlist[0],control_index); 1513 Input* thickness_input = basalelement->GetInput(ThicknessEnum); _assert_(thickness_input); 1514 Input* vx_input = basalelement->GetInput(VxEnum); _assert_(vx_input); 1515 Input* vy_input = basalelement->GetInput(VyEnum); _assert_(vy_input); 1516 Input* adjointx_input = basalelement->GetInput(AdjointxEnum); _assert_(adjointx_input); 1517 Input* adjointy_input = basalelement->GetInput(AdjointyEnum); _assert_(adjointy_input); 1518 Input* rheologyb_input = basalelement->GetInput(MaterialsRheologyBEnum); _assert_(rheologyb_input); 1519 1520 /* Start looping on the number of gaussian points: */ 1521 Gauss* gauss=basalelement->NewGauss(4); 1522 for(int ig=gauss->begin();ig<gauss->end();ig++){ 1523 gauss->GaussPoint(ig); 1524 1525 thickness_input->GetInputValue(&thickness,gauss); 1526 vx_input->GetInputDerivativeValue(&dvx[0],xyz_list,gauss); 1527 vy_input->GetInputDerivativeValue(&dvy[0],xyz_list,gauss); 1528 adjointx_input->GetInputDerivativeValue(&dadjx[0],xyz_list,gauss); 1529 adjointy_input->GetInputDerivativeValue(&dadjy[0],xyz_list,gauss); 1530 1531 basalelement->dViscositydBSSA(&dmudB,dim,xyz_list,gauss,vx_input,vy_input); 1532 1533 basalelement->JacobianDeterminant(&Jdet,xyz_list,gauss); 1534 basalelement->NodalFunctionsP1(basis,gauss); 1535 1536 /*Build gradient vector (actually -dJ/dB): */ 1537 for(int i=0;i<numvertices;i++){ 1538 ge[i]+=-dmudB*thickness*( 1539 (2*dvx[0]+dvy[1])*2*dadjx[0]+(dvx[1]+dvy[0])*(dadjx[1]+dadjy[0])+(2*dvy[1]+dvx[0])*2*dadjy[1] 1540 )*Jdet*gauss->weight*basis[i]; 1541 _assert_(!xIsNan<IssmDouble>(ge[i])); 1542 } 1543 } 1544 gradient->SetValues(numvertices,vertexpidlist,ge,ADD_VAL); 1545 1546 /*Clean up and return*/ 1547 xDelete<IssmDouble>(xyz_list); 1548 xDelete<IssmDouble>(basis); 1549 xDelete<IssmDouble>(ge); 1550 xDelete<int>(vertexpidlist); 1551 delete gauss; 1552 if(domaintype!=Domain2DhorizontalEnum){basalelement->DeleteMaterials(); delete basalelement;}; 1553 }/*}}}*/ 1554 void AdjointHorizAnalysis::GradientJDragGradient(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 978 1555 979 1556 /*return if floating (gradient is 0)*/ … … 1057 1634 1058 1635 }/*}}}*/ 1059 void AdjointHorizAnalysis::GradientJBGradient(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 1636 void AdjointHorizAnalysis::GradientJDragFS(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 1637 1638 /*return if floating or not on bed (gradient is 0)*/ 1639 if(element->IsFloating()) return; 1640 if(!element->IsOnBase()) return; 1060 1641 1061 1642 /*Intermediaries*/ 1062 int domaintype,dim; 1063 Element* basalelement; 1064 1065 /*Get basal element*/ 1066 element->FindParam(&domaintype,DomainTypeEnum); 1067 switch(domaintype){ 1068 case Domain2DhorizontalEnum: 1069 basalelement = element; 1070 dim = 2; 1071 break; 1072 case Domain2DverticalEnum: 1073 if(!element->IsOnBase()) return; 1074 basalelement = element->SpawnBasalElement(); 1075 dim = 1; 1076 break; 1077 case Domain3DEnum: 1078 if(!element->IsOnBase()) return; 1079 basalelement = element->SpawnBasalElement(); 1080 dim = 2; 1081 break; 1082 default: _error_("mesh "<<EnumToStringx(domaintype)<<" not supported yet"); 1083 } 1084 1085 /*Intermediaries*/ 1643 int domaintype,dim; 1086 1644 IssmDouble Jdet,weight; 1087 IssmDouble dk[3]; 1088 IssmDouble *xyz_list= NULL; 1645 IssmDouble drag,dalpha2dk,normal[3]; 1646 IssmDouble vx,vy,vz,lambda,mu,xi; 1647 IssmDouble *xyz_list_base= NULL; 1089 1648 1090 1649 /*Fetch number of vertices for this finite element*/ 1091 int numvertices = basalelement->GetNumberOfVertices();1650 int numvertices = element->GetNumberOfVertices(); 1092 1651 1093 1652 /*Initialize some vectors*/ 1094 IssmDouble* dbasis = xNew<IssmDouble>(2*numvertices);1653 IssmDouble* basis = xNew<IssmDouble>(numvertices); 1095 1654 IssmDouble* ge = xNewZeroInit<IssmDouble>(numvertices); 1096 1655 int* vertexpidlist = xNew<int>(numvertices); 1097 1656 1657 /* get domaintype */ 1658 element->FindParam(&domaintype,DomainTypeEnum); 1659 1660 /*Build friction element, needed later: */ 1661 if(domaintype!=Domain2DverticalEnum) dim=3; 1662 else dim=2; 1663 Friction* friction=new Friction(element,dim); 1664 1098 1665 /*Retrieve all inputs we will be needing: */ 1099 basalelement->GetVerticesCoordinates(&xyz_list); 1100 basalelement->GradientIndexing(&vertexpidlist[0],control_index); 1101 Input* rheologyb_input = basalelement->GetInput(MaterialsRheologyBbarEnum); _assert_(rheologyb_input); 1102 Input* weights_input = basalelement->GetInput(InversionCostFunctionsCoefficientsEnum); _assert_(weights_input); 1666 element->GetVerticesCoordinatesBase(&xyz_list_base); 1667 element->GradientIndexing(&vertexpidlist[0],control_index); 1668 Input* vx_input = element->GetInput(VxEnum); _assert_(vx_input); 1669 Input* vy_input = element->GetInput(VyEnum); _assert_(vy_input); 1670 Input* adjointx_input = element->GetInput(AdjointxEnum); _assert_(adjointx_input); 1671 Input* adjointy_input = element->GetInput(AdjointyEnum); _assert_(adjointy_input); 1672 Input* vz_input = NULL; 1673 Input* adjointz_input = NULL; 1674 if(domaintype!=Domain2DverticalEnum){ 1675 vz_input = element->GetInput(VzEnum); _assert_(vy_input); 1676 adjointz_input = element->GetInput(AdjointzEnum); _assert_(adjointz_input); 1677 } 1678 Input* dragcoeff_input = element->GetInput(FrictionCoefficientEnum); _assert_(dragcoeff_input); 1103 1679 1104 1680 /* Start looping on the number of gaussian points: */ 1105 Gauss* gauss= basalelement->NewGauss(2);1681 Gauss* gauss=element->NewGaussBase(4); 1106 1682 for(int ig=gauss->begin();ig<gauss->end();ig++){ 1107 1683 gauss->GaussPoint(ig); 1108 1684 1109 basalelement->JacobianDeterminant(&Jdet,xyz_list,gauss); 1110 basalelement->NodalFunctionsP1Derivatives(dbasis,xyz_list,gauss); 1111 weights_input->GetInputValue(&weight,gauss,RheologyBbarAbsGradientEnum); 1112 1113 /*Build alpha_complement_list: */ 1114 rheologyb_input->GetInputDerivativeValue(&dk[0],xyz_list,gauss); 1115 1116 /*Build gradje_g_gaussian vector (actually -dJ/ddrag): */ 1117 for(int i=0;i<numvertices;i++){ 1118 if(dim==2){ 1119 ge[i]+=-weight*Jdet*gauss->weight*(dbasis[0*numvertices+i]*dk[0]+dbasis[1*numvertices+i]*dk[1]); 1685 adjointx_input->GetInputValue(&lambda, gauss); 1686 adjointy_input->GetInputValue(&mu, gauss); 1687 vx_input->GetInputValue(&vx,gauss); 1688 vy_input->GetInputValue(&vy,gauss); 1689 if(domaintype!=Domain2DverticalEnum){ 1690 adjointz_input->GetInputValue(&xi ,gauss); 1691 vz_input->GetInputValue(&vz,gauss); 1692 } 1693 dragcoeff_input->GetInputValue(&drag, gauss); 1694 1695 friction->GetAlphaComplement(&dalpha2dk,gauss); 1696 element->NormalBase(&normal[0],xyz_list_base); 1697 1698 element->JacobianDeterminantBase(&Jdet,xyz_list_base,gauss); 1699 element->NodalFunctionsP1(basis,gauss); 1700 1701 /*Build gradient vector (actually -dJ/dk): */ 1702 if(domaintype!=Domain2DverticalEnum){ 1703 for(int i=0;i<numvertices;i++){ 1704 ge[i]+=( 1705 -lambda*(2*drag*dalpha2dk*(vx - vz*normal[0]*normal[2])) 1706 -mu *(2*drag*dalpha2dk*(vy - vz*normal[1]*normal[2])) 1707 -xi *(2*drag*dalpha2dk*(-vx*normal[0]*normal[2]-vy*normal[1]*normal[2])) 1708 )*Jdet*gauss->weight*basis[i]; 1709 _assert_(!xIsNan<IssmDouble>(ge[i])); 1120 1710 } 1121 else{ 1122 ge[i]+=-weight*Jdet*gauss->weight*dbasis[0*numvertices+i]*dk[0]; 1711 } 1712 else{ 1713 for(int i=0;i<numvertices;i++){ 1714 ge[i]+=( 1715 -lambda*2*drag*dalpha2dk*vx 1716 -mu *2*drag*dalpha2dk*vy 1717 )*Jdet*gauss->weight*basis[i]; 1718 _assert_(!xIsNan<IssmDouble>(ge[i])); 1123 1719 } 1124 _assert_(!xIsNan<IssmDouble>(ge[i]));1125 1720 } 1126 1721 } … … 1128 1723 1129 1724 /*Clean up and return*/ 1130 xDelete<IssmDouble>(xyz_list );1131 xDelete<IssmDouble>( dbasis);1725 xDelete<IssmDouble>(xyz_list_base); 1726 xDelete<IssmDouble>(basis); 1132 1727 xDelete<IssmDouble>(ge); 1133 1728 xDelete<int>(vertexpidlist); 1134 1729 delete gauss; 1135 if(domaintype!=Domain2DhorizontalEnum){basalelement->DeleteMaterials(); delete basalelement;}; 1136 }/*}}}*/ 1137 void AdjointHorizAnalysis::GradientJDragSSA(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 1730 delete friction; 1731 }/*}}}*/ 1732 void AdjointHorizAnalysis::GradientJDragL1L2(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 1733 1734 /*Same as SSA*/ 1735 return this->GradientJDragSSA(element,gradient,control_index); 1736 }/*}}}*/ 1737 void AdjointHorizAnalysis::GradientJDragHO(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 1738 1739 /*return if floating or not on bed (gradient is 0)*/ 1740 if(element->IsFloating()) return; 1741 if(!element->IsOnBase()) return; 1742 1743 /*Intermediaries*/ 1744 IssmDouble Jdet,weight; 1745 IssmDouble drag,dalpha2dk; 1746 IssmDouble vx,vy,lambda,mu; 1747 IssmDouble *xyz_list_base= NULL; 1748 1749 int domaintype,dim; 1750 element->FindParam(&domaintype,DomainTypeEnum); 1751 /*Fetch number of vertices for this finite element*/ 1752 int numvertices = element->GetNumberOfVertices(); 1753 1754 /*Initialize some vectors*/ 1755 IssmDouble* basis = xNew<IssmDouble>(numvertices); 1756 IssmDouble* ge = xNewZeroInit<IssmDouble>(numvertices); 1757 int* vertexpidlist = xNew<int>(numvertices); 1758 1759 /*Build friction element, needed later: */ 1760 if(domaintype!=Domain2DverticalEnum) dim=3; 1761 else dim=2; 1762 Friction* friction=new Friction(element,dim); 1763 1764 /*Retrieve all inputs we will be needing: */ 1765 element->GetVerticesCoordinatesBase(&xyz_list_base); 1766 element->GradientIndexing(&vertexpidlist[0],control_index); 1767 Input* vx_input = element->GetInput(VxEnum); _assert_(vx_input); 1768 Input* vy_input = NULL; 1769 Input* adjointx_input = element->GetInput(AdjointxEnum); _assert_(adjointx_input); 1770 Input* adjointy_input = NULL; 1771 Input* dragcoeff_input = element->GetInput(FrictionCoefficientEnum); _assert_(dragcoeff_input); 1772 if(domaintype!=Domain2DverticalEnum){ 1773 vy_input = element->GetInput(VyEnum); _assert_(vy_input); 1774 adjointy_input = element->GetInput(AdjointyEnum); _assert_(adjointy_input); 1775 } 1776 /* Start looping on the number of gaussian points: */ 1777 Gauss* gauss=element->NewGaussBase(4); 1778 for(int ig=gauss->begin();ig<gauss->end();ig++){ 1779 gauss->GaussPoint(ig); 1780 1781 adjointx_input->GetInputValue(&lambda, gauss); 1782 vx_input->GetInputValue(&vx,gauss); 1783 if(domaintype!=Domain2DverticalEnum){ 1784 adjointy_input->GetInputValue(&mu, gauss); 1785 vy_input->GetInputValue(&vy,gauss); 1786 } 1787 dragcoeff_input->GetInputValue(&drag, gauss); 1788 1789 friction->GetAlphaComplement(&dalpha2dk,gauss); 1790 1791 element->JacobianDeterminantBase(&Jdet,xyz_list_base,gauss); 1792 element->NodalFunctionsP1(basis,gauss); 1793 1794 /*Build gradient vector (actually -dJ/dD): */ 1795 for(int i=0;i<numvertices;i++){ 1796 if(domaintype!=Domain2DverticalEnum) ge[i]+=-2.*drag*dalpha2dk*((lambda*vx+mu*vy))*Jdet*gauss->weight*basis[i]; 1797 else ge[i]+=-2.*drag*dalpha2dk*(lambda*vx)*Jdet*gauss->weight*basis[i]; 1798 _assert_(!xIsNan<IssmDouble>(ge[i])); 1799 } 1800 } 1801 gradient->SetValues(numvertices,vertexpidlist,ge,ADD_VAL); 1802 1803 /*Clean up and return*/ 1804 xDelete<IssmDouble>(xyz_list_base); 1805 xDelete<IssmDouble>(basis); 1806 xDelete<IssmDouble>(ge); 1807 xDelete<int>(vertexpidlist); 1808 delete gauss; 1809 delete friction; 1810 }/*}}}*/ 1811 void AdjointHorizAnalysis::GradientJDragSSA(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 1138 1812 1139 1813 /*return if floating (gradient is 0)*/ … … 1223 1897 if(domaintype!=Domain2DhorizontalEnum){basalelement->DeleteMaterials(); delete basalelement;}; 1224 1898 }/*}}}*/ 1225 void AdjointHorizAnalysis::GradientJDragHO(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 1899 1900 void AdjointHorizAnalysis::GradientJDragHydroFS(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 1226 1901 1227 1902 /*return if floating or not on bed (gradient is 0)*/ … … 1230 1905 1231 1906 /*Intermediaries*/ 1232 int d im=3;1907 int domaintype,dim; 1233 1908 IssmDouble Jdet,weight; 1234 IssmDouble drag,dalpha2dk ;1235 IssmDouble vx,vy, lambda,mu;1909 IssmDouble drag,dalpha2dk,normal[3]; 1910 IssmDouble vx,vy,vz,lambda,mu,xi; 1236 1911 IssmDouble *xyz_list_base= NULL; 1237 1912 … … 1244 1919 int* vertexpidlist = xNew<int>(numvertices); 1245 1920 1921 /* get domaintype */ 1922 element->FindParam(&domaintype,DomainTypeEnum); 1923 1246 1924 /*Build friction element, needed later: */ 1925 if(domaintype!=Domain2DverticalEnum) dim=3; 1926 else dim=2; 1247 1927 Friction* friction=new Friction(element,dim); 1248 1928 … … 1254 1934 Input* adjointx_input = element->GetInput(AdjointxEnum); _assert_(adjointx_input); 1255 1935 Input* adjointy_input = element->GetInput(AdjointyEnum); _assert_(adjointy_input); 1256 Input* dragcoeff_input = element->GetInput(FrictionCoefficientEnum); _assert_(dragcoeff_input); 1936 Input* vz_input = NULL; 1937 Input* adjointz_input = NULL; 1938 if(domaintype!=Domain2DverticalEnum){ 1939 vz_input = element->GetInput(VzEnum); _assert_(vy_input); 1940 adjointz_input = element->GetInput(AdjointzEnum); _assert_(adjointz_input); 1941 } 1257 1942 1258 1943 /* Start looping on the number of gaussian points: */ … … 1265 1950 vx_input->GetInputValue(&vx,gauss); 1266 1951 vy_input->GetInputValue(&vy,gauss); 1267 dragcoeff_input->GetInputValue(&drag, gauss); 1952 if(domaintype!=Domain2DverticalEnum){ 1953 adjointz_input->GetInputValue(&xi ,gauss); 1954 vz_input->GetInputValue(&vz,gauss); 1955 } 1268 1956 1269 1957 friction->GetAlphaComplement(&dalpha2dk,gauss); 1958 element->NormalBase(&normal[0],xyz_list_base); 1270 1959 1271 1960 element->JacobianDeterminantBase(&Jdet,xyz_list_base,gauss); 1272 1961 element->NodalFunctionsP1(basis,gauss); 1273 1962 1274 /*Build gradient vector (actually -dJ/dD): */ 1275 for(int i=0;i<numvertices;i++){ 1276 ge[i]+=-2.*drag*dalpha2dk*((lambda*vx+mu*vy))*Jdet*gauss->weight*basis[i]; 1277 _assert_(!xIsNan<IssmDouble>(ge[i])); 1963 /*Build gradient vector (actually -dJ/dk): */ 1964 if(domaintype!=Domain2DverticalEnum){ 1965 for(int i=0;i<numvertices;i++){ 1966 ge[i]+=( 1967 -lambda*(dalpha2dk*(vx - vz*normal[0]*normal[2])) 1968 -mu *(dalpha2dk*(vy - vz*normal[1]*normal[2])) 1969 -xi *(dalpha2dk*(-vx*normal[0]*normal[2]-vy*normal[1]*normal[2])) 1970 )*Jdet*gauss->weight*basis[i]; 1971 _assert_(!xIsNan<IssmDouble>(ge[i])); 1972 } 1973 } 1974 else{ 1975 for(int i=0;i<numvertices;i++){ 1976 ge[i]+=( 1977 -lambda*dalpha2dk*vx 1978 -mu *dalpha2dk*vy 1979 )*Jdet*gauss->weight*basis[i]; 1980 _assert_(!xIsNan<IssmDouble>(ge[i])); 1981 } 1278 1982 } 1279 1983 } … … 1288 1992 delete friction; 1289 1993 }/*}}}*/ 1290 void AdjointHorizAnalysis::GradientJDragFS(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 1994 void AdjointHorizAnalysis::GradientJDragHydroL1L2(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 1995 1996 /*Same as SSA*/ 1997 return this->GradientJDragSSA(element,gradient,control_index); 1998 }/*}}}*/ 1999 void AdjointHorizAnalysis::GradientJDragHydroHO(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 1291 2000 1292 2001 /*return if floating or not on bed (gradient is 0)*/ … … 1295 2004 1296 2005 /*Intermediaries*/ 1297 int dim=3;1298 2006 IssmDouble Jdet,weight; 1299 IssmDouble drag,dalpha2dk ,normal[3];1300 IssmDouble vx,vy, vz,lambda,mu,xi;2007 IssmDouble drag,dalpha2dk; 2008 IssmDouble vx,vy,lambda,mu; 1301 2009 IssmDouble *xyz_list_base= NULL; 1302 2010 2011 int domaintype,dim; 2012 element->FindParam(&domaintype,DomainTypeEnum); 1303 2013 /*Fetch number of vertices for this finite element*/ 1304 2014 int numvertices = element->GetNumberOfVertices(); … … 1310 2020 1311 2021 /*Build friction element, needed later: */ 2022 if(domaintype!=Domain2DverticalEnum) dim=3; 2023 else dim=2; 1312 2024 Friction* friction=new Friction(element,dim); 1313 2025 … … 1316 2028 element->GradientIndexing(&vertexpidlist[0],control_index); 1317 2029 Input* vx_input = element->GetInput(VxEnum); _assert_(vx_input); 1318 Input* vy_input = element->GetInput(VyEnum); _assert_(vy_input); 1319 Input* vz_input = element->GetInput(VzEnum); _assert_(vy_input); 2030 Input* vy_input = NULL; 1320 2031 Input* adjointx_input = element->GetInput(AdjointxEnum); _assert_(adjointx_input); 1321 Input* adjointy_input = element->GetInput(AdjointyEnum); _assert_(adjointy_input); 1322 Input* adjointz_input = element->GetInput(AdjointzEnum); _assert_(adjointz_input); 1323 Input* dragcoeff_input = element->GetInput(FrictionCoefficientEnum); _assert_(dragcoeff_input); 1324 2032 Input* adjointy_input = NULL; 2033 if(domaintype!=Domain2DverticalEnum){ 2034 vy_input = element->GetInput(VyEnum); _assert_(vy_input); 2035 adjointy_input = element->GetInput(AdjointyEnum); _assert_(adjointy_input); 2036 } 1325 2037 /* Start looping on the number of gaussian points: */ 1326 2038 Gauss* gauss=element->NewGaussBase(4); … … 1329 2041 1330 2042 adjointx_input->GetInputValue(&lambda, gauss); 1331 adjointy_input->GetInputValue(&mu, gauss);1332 adjointz_input->GetInputValue(&xi ,gauss);1333 2043 vx_input->GetInputValue(&vx,gauss); 1334 vy_input->GetInputValue(&vy,gauss); 1335 vz_input->GetInputValue(&vz,gauss); 1336 dragcoeff_input->GetInputValue(&drag, gauss); 2044 if(domaintype!=Domain2DverticalEnum){ 2045 adjointy_input->GetInputValue(&mu, gauss); 2046 vy_input->GetInputValue(&vy,gauss); 2047 } 1337 2048 1338 2049 friction->GetAlphaComplement(&dalpha2dk,gauss); 1339 element->NormalBase(&normal[0],xyz_list_base);1340 2050 1341 2051 element->JacobianDeterminantBase(&Jdet,xyz_list_base,gauss); 1342 2052 element->NodalFunctionsP1(basis,gauss); 1343 2053 1344 /*Build gradient vector (actually -dJ/d k): */2054 /*Build gradient vector (actually -dJ/dD): */ 1345 2055 for(int i=0;i<numvertices;i++){ 1346 ge[i]+=( 1347 -lambda*(2*drag*dalpha2dk*(vx - vz*normal[0]*normal[2])) 1348 -mu *(2*drag*dalpha2dk*(vy - vz*normal[1]*normal[2])) 1349 -xi *(2*drag*dalpha2dk*(-vx*normal[0]*normal[2]-vy*normal[1]*normal[2])) 1350 )*Jdet*gauss->weight*basis[i]; 2056 if(domaintype!=Domain2DverticalEnum) ge[i]+=-dalpha2dk*((lambda*vx+mu*vy))*Jdet*gauss->weight*basis[i]; 2057 else ge[i]+=-dalpha2dk*(lambda*vx)*Jdet*gauss->weight*basis[i]; 1351 2058 _assert_(!xIsNan<IssmDouble>(ge[i])); 1352 2059 } … … 1362 2069 delete friction; 1363 2070 }/*}}}*/ 1364 void AdjointHorizAnalysis::GradientJBbarSSA(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 2071 2072 void AdjointHorizAnalysis::GradientJDragHydroSSA(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 2073 2074 /*return if floating (gradient is 0)*/ 2075 if(element->IsFloating()) return; 1365 2076 1366 2077 /*Intermediaries*/ … … 1390 2101 /*Intermediaries*/ 1391 2102 IssmDouble Jdet,weight; 1392 IssmDouble thickness,dmudB; 2103 IssmDouble dalpha2dk; 2104 IssmDouble vx,vy,lambda,mu; 2105 IssmDouble *xyz_list= NULL; 2106 2107 2108 /*Fetch number of vertices for this finite element*/ 2109 int numvertices = basalelement->GetNumberOfVertices(); 2110 2111 /*Initialize some vectors*/ 2112 IssmDouble* basis = xNew<IssmDouble>(numvertices); 2113 IssmDouble* ge = xNewZeroInit<IssmDouble>(numvertices); 2114 int* vertexpidlist = xNew<int>(numvertices); 2115 2116 /*Build friction element, needed later: */ 2117 Friction* friction=new Friction(basalelement,dim); 2118 2119 /*Retrieve all inputs we will be needing: */ 2120 basalelement->GetVerticesCoordinates(&xyz_list); 2121 basalelement->GradientIndexing(&vertexpidlist[0],control_index); 2122 Input* vx_input = basalelement->GetInput(VxEnum); _assert_(vx_input); 2123 Input* vy_input = basalelement->GetInput(VyEnum); _assert_(vy_input); 2124 Input* adjointx_input = basalelement->GetInput(AdjointxEnum); _assert_(adjointx_input); 2125 Input* adjointy_input = basalelement->GetInput(AdjointyEnum); _assert_(adjointy_input); 2126 2127 2128 2129 IssmDouble q_exp; 2130 IssmDouble C_param; 2131 IssmDouble As; 2132 IssmDouble Neff; 2133 IssmDouble n; 2134 IssmDouble alpha; 2135 IssmDouble Chi,Gamma; 2136 IssmDouble vz,vmag; 2137 IssmDouble Uder; 2138 2139 /*Recover parameters: */ 2140 Input* qinput = basalelement->GetInput(FrictionQEnum); 2141 Input* cinput = basalelement->GetInput(FrictionCEnum); 2142 Input* Asinput = basalelement->GetInput(FrictionAsEnum); 2143 Input* Ninput = basalelement->GetInput(FrictionEffectivePressureEnum); 2144 Input* nInput =basalelement->GetInput(MaterialsRheologyNEnum); 2145 2146 /* Start looping on the number of gaussian points: */ 2147 Gauss* gauss=basalelement->NewGauss(4); 2148 for(int ig=gauss->begin();ig<gauss->end();ig++){ 2149 gauss->GaussPoint(ig); 2150 2151 adjointx_input->GetInputValue(&lambda, gauss); 2152 adjointy_input->GetInputValue(&mu, gauss); 2153 vx_input->GetInputValue(&vx,gauss); 2154 vy_input->GetInputValue(&vy,gauss); 2155 2156 friction->GetAlphaComplement(&dalpha2dk,gauss); 2157 2158 basalelement->JacobianDeterminant(&Jdet,xyz_list,gauss); 2159 basalelement->NodalFunctionsP1(basis,gauss); 2160 2161 /*Dealing with dalpha/du*/ 2162 qinput->GetInputValue(&q_exp,gauss); 2163 cinput->GetInputValue(&C_param,gauss); 2164 Asinput->GetInputValue(&As,gauss); 2165 Ninput->GetInputValue(&Neff,gauss); 2166 nInput->GetInputValue(&n,gauss); 2167 2168 if (q_exp==1){ 2169 alpha=1; 2170 } 2171 else{ 2172 alpha=(pow(q_exp-1,q_exp-1))/pow(q_exp,q_exp); 2173 } 2174 Chi = vmag/(pow(C_param,n)*pow(Neff,n)*As); 2175 Gamma = (Chi/(1.+alpha*pow(Chi,q_exp))); 2176 2177 Uder =Neff*C_param/(vmag*vmag*n) * 2178 (Gamma-alpha*q_exp*pow(Chi,q_exp-1.)*Gamma*Gamma* pow(Gamma,(1.-n)/n) - 2179 n* pow(Gamma,1./n)); 2180 2181 /*Build gradient vector (actually -dJ/dD): */ 2182 for(int i=0;i<numvertices;i++){ 2183 ge[i]+=-dalpha2dk*((lambda*vx+mu*vy))*Jdet*gauss->weight*basis[i]; 2184 _assert_(!xIsNan<IssmDouble>(ge[i])); 2185 } 2186 } 2187 gradient->SetValues(numvertices,vertexpidlist,ge,ADD_VAL); 2188 2189 /*Clean up and return*/ 2190 xDelete<IssmDouble>(xyz_list); 2191 xDelete<IssmDouble>(basis); 2192 xDelete<IssmDouble>(ge); 2193 xDelete<int>(vertexpidlist); 2194 delete gauss; 2195 delete friction; 2196 if(domaintype!=Domain2DhorizontalEnum){basalelement->DeleteMaterials(); delete basalelement;}; 2197 }/*}}}*/ 2198 2199 void AdjointHorizAnalysis::GradientJDSSA(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 2200 2201 /*Intermediaries*/ 2202 int domaintype,dim; 2203 Element* basalelement; 2204 2205 /*Get basal element*/ 2206 element->FindParam(&domaintype,DomainTypeEnum); 2207 switch(domaintype){ 2208 case Domain2DhorizontalEnum: 2209 basalelement = element; 2210 dim = 2; 2211 break; 2212 case Domain2DverticalEnum: 2213 if(!element->IsOnBase()) return; 2214 basalelement = element->SpawnBasalElement(); 2215 dim = 1; 2216 break; 2217 case Domain3DEnum: 2218 if(!element->IsOnBase()) return; 2219 basalelement = element->SpawnBasalElement(); 2220 dim = 2; 2221 break; 2222 default: _error_("mesh "<<EnumToStringx(domaintype)<<" not supported yet"); 2223 } 2224 2225 /*Intermediaries*/ 2226 IssmDouble Jdet,weight; 2227 IssmDouble thickness,dmudD; 1393 2228 IssmDouble dvx[3],dvy[3],dadjx[3],dadjy[3]; 1394 2229 IssmDouble *xyz_list= NULL; … … 1423 2258 adjointy_input->GetInputDerivativeValue(&dadjy[0],xyz_list,gauss); 1424 2259 1425 basalelement->dViscosityd BSSA(&dmudB,dim,xyz_list,gauss,vx_input,vy_input);2260 basalelement->dViscositydDSSA(&dmudD,dim,xyz_list,gauss,vx_input,vy_input); 1426 2261 1427 2262 basalelement->JacobianDeterminant(&Jdet,xyz_list,gauss); 1428 2263 basalelement->NodalFunctionsP1(basis,gauss); 1429 2264 1430 /*Build gradient vector (actually -dJ/dB): */1431 2265 for(int i=0;i<numvertices;i++){ 1432 ge[i]+=-dmud B*thickness*(2266 ge[i]+=-dmudD*thickness*( 1433 2267 (2*dvx[0]+dvy[1])*2*dadjx[0]+(dvx[1]+dvy[0])*(dadjx[1]+dadjy[0])+(2*dvy[1]+dvx[0])*2*dadjy[1] 1434 2268 )*Jdet*gauss->weight*basis[i]; … … 1446 2280 if(domaintype!=Domain2DhorizontalEnum){basalelement->DeleteMaterials(); delete basalelement;}; 1447 2281 }/*}}}*/ 1448 void AdjointHorizAnalysis::GradientJBbarHO(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 1449 1450 /*WARNING: We use SSA as an estimate for now*/ 1451 this->GradientJBbarSSA(element,gradient,control_index); 1452 }/*}}}*/ 1453 void AdjointHorizAnalysis::GradientJBbarFS(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 1454 /*WARNING: We use SSA as an estimate for now*/ 1455 this->GradientJBbarSSA(element,gradient,control_index); 1456 }/*}}}*/ 1457 void AdjointHorizAnalysis::GradientJDSSA(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 1458 1459 /*Intermediaries*/ 1460 int domaintype,dim; 1461 Element* basalelement; 1462 1463 /*Get basal element*/ 1464 element->FindParam(&domaintype,DomainTypeEnum); 1465 switch(domaintype){ 1466 case Domain2DhorizontalEnum: 1467 basalelement = element; 1468 dim = 2; 1469 break; 1470 case Domain2DverticalEnum: 1471 if(!element->IsOnBase()) return; 1472 basalelement = element->SpawnBasalElement(); 1473 dim = 1; 1474 break; 1475 case Domain3DEnum: 1476 if(!element->IsOnBase()) return; 1477 basalelement = element->SpawnBasalElement(); 1478 dim = 2; 1479 break; 1480 default: _error_("mesh "<<EnumToStringx(domaintype)<<" not supported yet"); 1481 } 1482 1483 /*Intermediaries*/ 1484 IssmDouble Jdet,weight; 1485 IssmDouble thickness,dmudD; 1486 IssmDouble dvx[3],dvy[3],dadjx[3],dadjy[3]; 1487 IssmDouble *xyz_list= NULL; 1488 1489 /*Fetch number of vertices for this finite element*/ 1490 int numvertices = basalelement->GetNumberOfVertices(); 1491 1492 /*Initialize some vectors*/ 1493 IssmDouble* basis = xNew<IssmDouble>(numvertices); 1494 IssmDouble* ge = xNewZeroInit<IssmDouble>(numvertices); 1495 int* vertexpidlist = xNew<int>(numvertices); 1496 1497 /*Retrieve all inputs we will be needing: */ 1498 basalelement->GetVerticesCoordinates(&xyz_list); 1499 basalelement->GradientIndexing(&vertexpidlist[0],control_index); 1500 Input* thickness_input = basalelement->GetInput(ThicknessEnum); _assert_(thickness_input); 1501 Input* vx_input = basalelement->GetInput(VxEnum); _assert_(vx_input); 1502 Input* vy_input = basalelement->GetInput(VyEnum); _assert_(vy_input); 1503 Input* adjointx_input = basalelement->GetInput(AdjointxEnum); _assert_(adjointx_input); 1504 Input* adjointy_input = basalelement->GetInput(AdjointyEnum); _assert_(adjointy_input); 1505 Input* rheologyb_input = basalelement->GetInput(MaterialsRheologyBbarEnum); _assert_(rheologyb_input); 1506 1507 /* Start looping on the number of gaussian points: */ 1508 Gauss* gauss=basalelement->NewGauss(4); 1509 for(int ig=gauss->begin();ig<gauss->end();ig++){ 1510 gauss->GaussPoint(ig); 1511 1512 thickness_input->GetInputValue(&thickness,gauss); 1513 vx_input->GetInputDerivativeValue(&dvx[0],xyz_list,gauss); 1514 vy_input->GetInputDerivativeValue(&dvy[0],xyz_list,gauss); 1515 adjointx_input->GetInputDerivativeValue(&dadjx[0],xyz_list,gauss); 1516 adjointy_input->GetInputDerivativeValue(&dadjy[0],xyz_list,gauss); 1517 1518 basalelement->dViscositydDSSA(&dmudD,dim,xyz_list,gauss,vx_input,vy_input); 1519 1520 basalelement->JacobianDeterminant(&Jdet,xyz_list,gauss); 1521 basalelement->NodalFunctionsP1(basis,gauss); 1522 1523 for(int i=0;i<numvertices;i++){ 1524 ge[i]+=-dmudD*thickness*( 1525 (2*dvx[0]+dvy[1])*2*dadjx[0]+(dvx[1]+dvy[0])*(dadjx[1]+dadjy[0])+(2*dvy[1]+dvx[0])*2*dadjy[1] 1526 )*Jdet*gauss->weight*basis[i]; 1527 _assert_(!xIsNan<IssmDouble>(ge[i])); 1528 } 1529 } 1530 gradient->SetValues(numvertices,vertexpidlist,ge,ADD_VAL); 1531 1532 /*Clean up and return*/ 1533 xDelete<IssmDouble>(xyz_list); 1534 xDelete<IssmDouble>(basis); 1535 xDelete<IssmDouble>(ge); 1536 xDelete<int>(vertexpidlist); 1537 delete gauss; 1538 if(domaintype!=Domain2DhorizontalEnum){basalelement->DeleteMaterials(); delete basalelement;}; 1539 }/*}}}*/ 1540 void AdjointHorizAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 2282 void AdjointHorizAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 1541 2283 int approximation; 1542 2284 element->GetInputValue(&approximation,ApproximationEnum); … … 1548 2290 } 1549 2291 }/*}}}*/ 1550 void AdjointHorizAnalysis::InputUpdateFromSolutionHoriz(IssmDouble* solution,Element* element){/*{{{*/ 1551 int i; 1552 int* doflist=NULL; 1553 1554 /*Fetch number of nodes and dof for this finite element*/ 1555 int numnodes = element->GetNumberOfNodes(); 1556 int numdof = numnodes*2; 1557 1558 /*Fetch dof list and allocate solution vectors*/ 1559 element->GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 1560 IssmDouble* values = xNew<IssmDouble>(numdof); 1561 IssmDouble* lambdax = xNew<IssmDouble>(numnodes); 1562 IssmDouble* lambday = xNew<IssmDouble>(numnodes); 1563 1564 /*Use the dof list to index into the solution vector: */ 1565 for(i=0;i<numdof;i++) values[i]=solution[doflist[i]]; 1566 1567 /*Transform solution in Cartesian Space*/ 1568 element->TransformSolutionCoord(&values[0],XYEnum); 1569 1570 /*Ok, we have vx and vy in values, fill in vx and vy arrays: */ 1571 for(i=0;i<numnodes;i++){ 1572 lambdax[i]=values[i*NDOF2+0]; 1573 lambday[i]=values[i*NDOF2+1]; 1574 1575 /*Check solution*/ 1576 if(xIsNan<IssmDouble>(lambdax[i])) _error_("NaN found in solution vector"); 1577 if(xIsNan<IssmDouble>(lambday[i])) _error_("NaN found in solution vector"); 1578 } 1579 1580 /*Add vx and vy as inputs to the tria element: */ 1581 element->AddInput(AdjointxEnum,lambdax,element->GetElementType()); 1582 element->AddInput(AdjointyEnum,lambday,element->GetElementType()); 1583 1584 /*Free ressources:*/ 1585 xDelete<IssmDouble>(values); 1586 xDelete<IssmDouble>(lambdax); 1587 xDelete<IssmDouble>(lambday); 1588 xDelete<int>(doflist); 1589 }/*}}}*/ 1590 void AdjointHorizAnalysis::InputUpdateFromSolutionFS(IssmDouble* solution,Element* element){/*{{{*/ 1591 int i,dim; 2292 void AdjointHorizAnalysis::InputUpdateFromSolutionFS(IssmDouble* solution,Element* element){/*{{{*/ 2293 int i,fe_FS; 1592 2294 int* vdoflist=NULL; 1593 2295 int* pdoflist=NULL; 1594 2296 IssmDouble FSreconditioning; 1595 2297 1596 element->FindParam(&dim,DomainDimensionEnum); 2298 int domaintype,dim; 2299 element->FindParam(&domaintype,DomainTypeEnum); 2300 switch(domaintype){ 2301 case Domain2DhorizontalEnum: 2302 dim = 3; 2303 break; 2304 case Domain2DverticalEnum: 2305 dim = 2; 2306 break; 2307 case Domain3DEnum: 2308 dim = 3; 2309 break; 2310 default: _error_("mesh "<<EnumToStringx(domaintype)<<" not supported yet"); 2311 } 2312 1597 2313 1598 2314 /*Fetch number of nodes and dof for this finite element*/ … … 1627 2343 /*fill in all arrays: */ 1628 2344 for(i=0;i<vnumnodes;i++){ 1629 lambdax[i] = values[i*NDOF3+0]; if(xIsNan<IssmDouble>(lambdax[i])) _error_("NaN found in solution vector"); 1630 lambday[i] = values[i*NDOF3+1]; if(xIsNan<IssmDouble>(lambday[i])) _error_("NaN found in solution vector"); 1631 lambdaz[i] = values[i*NDOF3+2]; if(xIsNan<IssmDouble>(lambdaz[i])) _error_("NaN found in solution vector"); 2345 lambdax[i] = values[i*dim+0]; if(xIsNan<IssmDouble>(lambdax[i])) _error_("NaN found in solution vector"); 2346 lambday[i] = values[i*dim+1]; if(xIsNan<IssmDouble>(lambday[i])) _error_("NaN found in solution vector"); 2347 if(dim==3){ 2348 lambdaz[i] = values[i*dim+2]; if(xIsNan<IssmDouble>(lambdaz[i])) _error_("NaN found in solution vector"); 2349 } 1632 2350 } 1633 2351 for(i=0;i<pnumnodes;i++){ … … 1642 2360 element->AddInput(AdjointxEnum,lambdax,element->VelocityInterpolation()); 1643 2361 element->AddInput(AdjointyEnum,lambday,element->VelocityInterpolation()); 1644 element->AddInput(AdjointzEnum,lambdaz,element->VelocityInterpolation()); 1645 element->AddInput(AdjointpEnum,lambdap,element->PressureInterpolation()); 2362 if(domaintype!=Domain2DverticalEnum) element->AddInput(AdjointzEnum,lambdaz,element->VelocityInterpolation()); 2363 2364 element->FindParam(&fe_FS,FlowequationFeFSEnum); 2365 if(fe_FS!=LATaylorHoodEnum && fe_FS!=LACrouzeixRaviartEnum) 2366 element->AddInput(AdjointpEnum,lambdap,element->PressureInterpolation()); 1646 2367 1647 2368 /*Free ressources:*/ … … 1655 2376 xDelete<IssmDouble>(values); 1656 2377 }/*}}}*/ 1657 void AdjointHorizAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 2378 void AdjointHorizAnalysis::InputUpdateFromSolutionHoriz(IssmDouble* solution,Element* element){/*{{{*/ 2379 int i; 2380 int* doflist=NULL; 2381 2382 int domaintype; 2383 element->FindParam(&domaintype,DomainTypeEnum); 2384 2385 /*Fetch number of nodes and dof for this finite element*/ 2386 int numnodes = element->GetNumberOfNodes(); 2387 int numdof; 2388 if(domaintype!=Domain2DverticalEnum) numdof = numnodes*2; 2389 else numdof = numnodes*1; 2390 /*Fetch dof list and allocate solution vectors*/ 2391 element->GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 2392 IssmDouble* values = xNew<IssmDouble>(numdof); 2393 IssmDouble* lambdax = xNew<IssmDouble>(numnodes); 2394 IssmDouble* lambday = xNew<IssmDouble>(numnodes); 2395 2396 /*Use the dof list to index into the solution vector: */ 2397 for(i=0;i<numdof;i++) values[i]=solution[doflist[i]]; 2398 2399 /*Transform solution in Cartesian Space*/ 2400 if(domaintype!=Domain2DverticalEnum) element->TransformSolutionCoord(&values[0],XYEnum); 2401 2402 /*Ok, we have vx and vy in values, fill in vx and vy arrays: */ 2403 for(i=0;i<numnodes;i++){ 2404 if(domaintype!=Domain2DverticalEnum){ 2405 lambdax[i]=values[i*NDOF2+0]; 2406 lambday[i]=values[i*NDOF2+1]; 2407 } 2408 else {lambdax[i]=values[i];lambday[i]=0;} 2409 /*Check solution*/ 2410 if(xIsNan<IssmDouble>(lambdax[i])) _error_("NaN found in solution vector"); 2411 if(domaintype!=Domain2DverticalEnum && xIsNan<IssmDouble>(lambday[i])) _error_("NaN found in solution vector"); 2412 } 2413 2414 /*Add vx and vy as inputs to the tria element: */ 2415 element->AddInput(AdjointxEnum,lambdax,element->GetElementType()); 2416 element->AddInput(AdjointyEnum,lambday,element->GetElementType()); 2417 2418 /*Free ressources:*/ 2419 xDelete<IssmDouble>(values); 2420 xDelete<IssmDouble>(lambdax); 2421 xDelete<IssmDouble>(lambday); 2422 xDelete<int>(doflist); 2423 }/*}}}*/ 2424 void AdjointHorizAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 1658 2425 /*Default, do nothing*/ 1659 2426 return; -
issm/trunk/src/c/analyses/AdjointHorizAnalysis.h
r18301 r19105 13 13 public: 14 14 /*Model processing*/ 15 int DofsPerNode(int** doflist,int domaintype,int approximation);16 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum);17 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type);18 void CreateNodes(Nodes* nodes,IoModel* iomodel);19 15 void CreateConstraints(Constraints* constraints,IoModel* iomodel); 20 16 void CreateLoads(Loads* loads, IoModel* iomodel); 17 void CreateNodes(Nodes* nodes,IoModel* iomodel); 18 int DofsPerNode(int** doflist,int domaintype,int approximation); 19 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 20 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum); 21 21 22 22 /*Finite element Analysis*/ … … 25 25 ElementMatrix* CreateJacobianMatrix(Element* element); 26 26 ElementMatrix* CreateKMatrix(Element* element); 27 ElementMatrix* CreateKMatrixFS(Element* element); 28 ElementMatrix* CreateKMatrixHO(Element* element); 29 ElementMatrix* CreateKMatrixL1L2(Element* element); 27 30 ElementMatrix* CreateKMatrixSSA(Element* element); 28 ElementMatrix* CreateKMatrixHO(Element* element);29 ElementMatrix* CreateKMatrixFS(Element* element);30 31 ElementVector* CreatePVector(Element* element); 32 ElementVector* CreatePVectorFS(Element* element); 33 ElementVector* CreatePVectorL1L2(Element* element); 34 ElementVector* CreatePVectorHO(Element* element); 31 35 ElementVector* CreatePVectorSSA(Element* element); 32 ElementVector* CreatePVectorHO(Element* element); 33 ElementVector* CreatePVectorFS(Element* element); 34 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 35 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 36 void GradientJDragGradient(Element* element,Vector<IssmDouble>* gradient,int control_index); 37 void GradientJBGradient(Element* element,Vector<IssmDouble>* gradient,int control_index); 38 void GradientJDragSSA(Element* element,Vector<IssmDouble>* gradient,int control_index); 39 void GradientJDragHO(Element* element,Vector<IssmDouble>* gradient,int control_index); 40 void GradientJDragFS(Element* element,Vector<IssmDouble>* gradient,int control_index); 41 void GradientJBbarSSA(Element* element,Vector<IssmDouble>* gradient,int control_index); 42 void GradientJBbarHO(Element* element,Vector<IssmDouble>* gradient,int control_index); 43 void GradientJBbarFS(Element* element,Vector<IssmDouble>* gradient,int control_index); 44 void GradientJDSSA(Element* element,Vector<IssmDouble>* gradient,int control_index); 45 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 46 void UpdateConstraints(FemModel* femmodel); 47 void InputUpdateFromSolutionHoriz(IssmDouble* solution,Element* element); 48 void InputUpdateFromSolutionFS(IssmDouble* solution,Element* element); 36 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 37 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 38 void GradientJBbarFS(Element* element,Vector<IssmDouble>* gradient,int control_index); 39 void GradientJBbarGradient(Element* element,Vector<IssmDouble>* gradient,int control_index); 40 void GradientJBbarL1L2(Element* element,Vector<IssmDouble>* gradient,int control_index); 41 void GradientJBbarHO(Element* element,Vector<IssmDouble>* gradient,int control_index); 42 void GradientJBbarSSA(Element* element,Vector<IssmDouble>* gradient,int control_index); 43 void GradientJBFS(Element* element,Vector<IssmDouble>* gradient,int control_index); 44 void GradientJBGradient(Element* element,Vector<IssmDouble>* gradient,int control_index); 45 void GradientJBHO(Element* element,Vector<IssmDouble>* gradient,int control_index); 46 void GradientJBSSA(Element* element,Vector<IssmDouble>* gradient,int control_index); 47 void GradientJDragFS(Element* element,Vector<IssmDouble>* gradient,int control_index); 48 void GradientJDragGradient(Element* element,Vector<IssmDouble>* gradient,int control_index); 49 void GradientJDragL1L2(Element* element,Vector<IssmDouble>* gradient,int control_index); 50 void GradientJDragHO(Element* element,Vector<IssmDouble>* gradient,int control_index); 51 void GradientJDragSSA(Element* element,Vector<IssmDouble>* gradient,int control_index); 52 void GradientJDragHydroFS(Element* element,Vector<IssmDouble>* gradient,int control_index); 53 void GradientJDragHydroL1L2(Element* element,Vector<IssmDouble>* gradient,int control_index); 54 void GradientJDragHydroHO(Element* element,Vector<IssmDouble>* gradient,int control_index); 55 void GradientJDragHydroSSA(Element* element,Vector<IssmDouble>* gradient,int control_index); 56 void GradientJDSSA(Element* element,Vector<IssmDouble>* gradient,int control_index); 57 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 58 void InputUpdateFromSolutionFS(IssmDouble* solution,Element* element); 59 void InputUpdateFromSolutionHoriz(IssmDouble* solution,Element* element); 60 void UpdateConstraints(FemModel* femmodel); 49 61 }; 50 62 #endif -
issm/trunk/src/c/analyses/Analysis.h
r18301 r19105 26 26 27 27 /*Model processing*/ 28 virtual int DofsPerNode(int** doflist,int domaintype,int approximation)=0;29 virtual void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum)=0;30 virtual void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type)=0;31 virtual void CreateNodes(Nodes* nodes,IoModel* iomodel)=0;32 28 virtual void CreateConstraints(Constraints* constraints,IoModel* iomodel)=0; 33 29 virtual void CreateLoads(Loads* loads, IoModel* iomodel)=0; 30 virtual void CreateNodes(Nodes* nodes,IoModel* iomodel)=0; 31 virtual int DofsPerNode(int** doflist,int domaintype,int approximation)=0; 32 virtual void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type)=0; 33 virtual void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum)=0; 34 34 35 35 /*Finite element Analysis*/ … … 39 39 virtual ElementMatrix* CreateKMatrix(Element* element)=0; 40 40 virtual ElementVector* CreatePVector(Element* element)=0; 41 virtual void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element)=0;42 virtual void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index)=0;43 virtual void InputUpdateFromSolution(IssmDouble* solution,Element* element)=0;44 virtual void UpdateConstraints(FemModel* femmodel)=0;41 virtual void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element)=0; 42 virtual void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index)=0; 43 virtual void InputUpdateFromSolution(IssmDouble* solution,Element* element)=0; 44 virtual void UpdateConstraints(FemModel* femmodel)=0; 45 45 }; 46 46 #endif -
issm/trunk/src/c/analyses/Balancethickness2Analysis.cpp
r18301 r19105 6 6 7 7 /*Model processing*/ 8 void Balancethickness2Analysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 9 10 11 int finiteelement = P1Enum; 12 IoModelToConstraintsx(constraints,iomodel,BalancethicknessSpcthicknessEnum,Balancethickness2AnalysisEnum,finiteelement); 13 14 }/*}}}*/ 15 void Balancethickness2Analysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 16 17 }/*}}}*/ 18 void Balancethickness2Analysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 19 20 int finiteelement = P1Enum; 21 ::CreateNodes(nodes,iomodel,Balancethickness2AnalysisEnum,finiteelement); 22 }/*}}}*/ 8 23 int Balancethickness2Analysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/ 9 24 return 1; 10 25 }/*}}}*/ 11 void Balancethickness2Analysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/12 }/*}}}*/13 26 void Balancethickness2Analysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ 14 27 15 28 /*Finite element type*/ 16 29 int finiteelement = P1Enum; 30 31 /*Load variables in element*/ 32 iomodel->FetchDataToInput(elements,ThicknessEnum); 33 iomodel->FetchDataToInput(elements,SurfaceEnum); 34 iomodel->FetchDataToInput(elements,BaseEnum); 35 iomodel->FetchDataToInput(elements,MaskIceLevelsetEnum); 36 iomodel->FetchDataToInput(elements,BasalforcingsGroundediceMeltingRateEnum); 37 iomodel->FetchDataToInput(elements,SurfaceforcingsMassBalanceEnum); 38 iomodel->FetchDataToInput(elements,BalancethicknessThickeningRateEnum); 39 iomodel->FetchDataToInput(elements,BalancethicknessOmegaEnum); 17 40 18 41 /*Update elements: */ … … 22 45 Element* element=(Element*)elements->GetObjectByOffset(counter); 23 46 element->Update(i,iomodel,analysis_counter,analysis_type,finiteelement); 47 24 48 counter++; 25 49 } 26 50 } 27 51 28 iomodel->FetchDataToInput(elements,BalancethicknessApparentMassbalanceEnum); 29 iomodel->FetchDataToInput(elements,BalancethicknessNuxEnum); 30 iomodel->FetchDataToInput(elements,BalancethicknessNuyEnum); 31 iomodel->FetchDataToInput(elements,BalancethicknessVxObsEnum); 32 iomodel->FetchDataToInput(elements,BalancethicknessVyObsEnum); 33 iomodel->FetchDataToInput(elements,BalancethicknessThicknessObsEnum); 34 iomodel->FetchDataToInput(elements,MeshVertexonboundaryEnum); 35 iomodel->FetchDataToInput(elements,MaskIceLevelsetEnum); 36 }/*}}}*/ 37 void Balancethickness2Analysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 38 39 int finiteelement = P1Enum; 40 ::CreateNodes(nodes,iomodel,Balancethickness2AnalysisEnum,finiteelement); 41 }/*}}}*/ 42 void Balancethickness2Analysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 43 44 45 int finiteelement = P1Enum; 46 IoModelToConstraintsx(constraints,iomodel,BalancethicknessSpcpotentialEnum,Balancethickness2AnalysisEnum,finiteelement); 47 48 }/*}}}*/ 49 void Balancethickness2Analysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 50 52 }/*}}}*/ 53 void Balancethickness2Analysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 51 54 }/*}}}*/ 52 55 … … 59 62 return NULL; 60 63 }/*}}}*/ 64 void Balancethickness2Analysis::CreateD0(Element* element){/*{{{*/ 65 66 /*Intermediaries */ 67 IssmDouble Gamma,h,mu0,ds[2],Cmu,B,k,s,b,normds; 68 const int n = 3; 69 const IssmDouble Hstar = 500.; 70 const IssmDouble Lstar = 500.e+3; 71 IssmDouble *xyz_list = NULL; 72 73 /*Fetch number of vertices and allocate output*/ 74 int numnodes = element->GetNumberOfNodes(); 75 IssmDouble* D0 = xNew<IssmDouble>(numnodes); 76 77 /*retrieve what we need: */ 78 element->GetVerticesCoordinates(&xyz_list); 79 Input* surfaceslopex_input = element->GetInput(SurfaceSlopeXEnum); 80 Input* surfaceslopey_input = element->GetInput(SurfaceSlopeYEnum); 81 Input* surface_input = element->GetInput(SurfaceEnum); _assert_(surface_input); 82 Input* B_input = element->GetInput(MaterialsRheologyBEnum); _assert_(B_input); 83 IssmDouble rhog = element->GetMaterialParameter(MaterialsRhoIceEnum)*element->GetMaterialParameter(ConstantsGEnum); 84 85 /*Calculate damage evolution source term: */ 86 Gauss* gauss=element->NewGauss(); 87 for (int i=0;i<numnodes;i++){ 88 gauss->GaussNode(element->GetElementType(),i); 89 90 B_input->GetInputValue(&B,gauss); 91 if(surfaceslopex_input && surfaceslopey_input){ 92 surfaceslopex_input->GetInputValue(&ds[0],gauss); 93 surfaceslopey_input->GetInputValue(&ds[1],gauss); 94 } 95 else{ 96 surface_input->GetInputDerivativeValue(&ds[0],xyz_list,gauss); 97 } 98 99 /*check slopes*/ 100 normds = sqrt(ds[0]*ds[0]+ds[1]*ds[1]); 101 if (normds==0.){ 102 _error_("surface slope is zero"); 103 } 104 if(normds<1.e-5){ 105 ds[0] = ds[0]/normds*1.e+5; 106 ds[1] = ds[1]/normds*1.e+5; 107 normds = 1.e-5; 108 } 109 110 mu0 = pow(2.,(1-3*n)/(2.*n)) * B; 111 Gamma = pow(rhog,n) * pow(Hstar,2*(n+1)) * pow(Hstar/Lstar,2*(n+1)) * 1./pow(mu0,n); 112 113 D0[i] = Gamma*pow(ds[0]*ds[0]+ds[1]*ds[1],(n-1)/2)/(n+2); 114 } 115 116 /*Add input*/ 117 element->AddInput(BalancethicknessD0Enum,D0,element->GetElementType()); 118 //if(surfaceslopex_input && surfaceslopey_input){ 119 // element->DeleteInput(SurfaceSlopeXEnum); 120 // element->DeleteInput(SurfaceSlopeYEnum); 121 //} 122 123 /*Clean up and return*/ 124 xDelete<IssmDouble>(D0); 125 xDelete<IssmDouble>(xyz_list); 126 delete gauss; 127 }/*}}}*/ 61 128 ElementMatrix* Balancethickness2Analysis::CreateJacobianMatrix(Element* element){/*{{{*/ 62 129 _error_("Not implemented"); … … 65 132 66 133 /*Intermediaries */ 67 IssmDouble Jdet,D_scalar;134 IssmDouble Jdet,D0,omega; 68 135 IssmDouble* xyz_list = NULL; 69 136 … … 77 144 /*Retrieve all inputs and parameters*/ 78 145 element->GetVerticesCoordinates(&xyz_list); 146 Input* omega_input = element->GetInput(BalancethicknessOmegaEnum); _assert_(omega_input); 147 Input* D0_input = element->GetInput(BalancethicknessD0Enum); 148 if(!D0_input){ 149 this->CreateD0(element); 150 D0_input = element->GetInput(BalancethicknessD0Enum); _assert_(D0_input); 151 } 79 152 80 153 /* Start looping on the number of gaussian points: */ … … 84 157 element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss); 85 158 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 159 D0_input->GetInputValue(&D0,gauss); 160 omega_input->GetInputValue(&omega,gauss); 86 161 87 162 for(int i=0;i<numnodes;i++){ 88 163 for(int j=0;j<numnodes;j++){ 89 Ke->values[i*numnodes+j] += gauss->weight*Jdet*(dbasis[0*numnodes+i]*dbasis[0*numnodes+j] + dbasis[1*numnodes+i]*dbasis[1*numnodes+j]);164 Ke->values[i*numnodes+j] += D0*exp(omega)*gauss->weight*Jdet*(dbasis[0*numnodes+i]*dbasis[0*numnodes+j] + dbasis[1*numnodes+i]*dbasis[1*numnodes+j]); 90 165 } 91 166 } … … 100 175 ElementVector* Balancethickness2Analysis::CreatePVector(Element* element){/*{{{*/ 101 176 102 /*compute all load vectors for this element*/103 ElementVector* pe1=CreatePVectorVolume(element);104 ElementVector* pe2=CreatePVectorBoundary(element);105 ElementVector* pe =new ElementVector(pe1,pe2);106 107 /*clean-up and return*/108 delete pe1;109 delete pe2;110 return pe;111 }/*}}}*/112 ElementVector* Balancethickness2Analysis::CreatePVectorVolume(Element* element){/*{{{*/113 114 177 /*Intermediaries */ 115 IssmDouble adot,Jdet;178 IssmDouble dhdt,mb,ms,Jdet; 116 179 IssmDouble* xyz_list = NULL; 117 180 … … 125 188 /*Retrieve all inputs and parameters*/ 126 189 element->GetVerticesCoordinates(&xyz_list); 127 Input* adot_input = element->GetInput(BalancethicknessApparentMassbalanceEnum); _assert_(adot_input); 190 Input* ms_input = element->GetInput(SurfaceforcingsMassBalanceEnum); _assert_(ms_input); 191 Input* mb_input = element->GetInput(BasalforcingsGroundediceMeltingRateEnum); _assert_(mb_input); 192 Input* dhdt_input = element->GetInput(BalancethicknessThickeningRateEnum); _assert_(dhdt_input); 128 193 129 194 /* Start looping on the number of gaussian points: */ … … 134 199 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 135 200 element->NodalFunctions(basis,gauss); 136 adot_input->GetInputValue(&adot,gauss); 137 138 for(int i=0;i<numnodes;i++) pe->values[i]+=Jdet*gauss->weight*adot*basis[i]; 201 202 ms_input->GetInputValue(&ms,gauss); 203 mb_input->GetInputValue(&mb,gauss); 204 dhdt_input->GetInputValue(&dhdt,gauss); 205 206 for(int i=0;i<numnodes;i++) pe->values[i]+=Jdet*gauss->weight*( 207 (ms-mb-dhdt)*basis[i] 208 ); 139 209 } 140 210 … … 145 215 return pe; 146 216 }/*}}}*/ 147 ElementVector* Balancethickness2Analysis::CreatePVectorBoundary(Element* element){/*{{{*/ 148 149 /*If no front, return NULL*/ 150 if(!element->IsFaceOnBoundary()) return NULL; 217 void Balancethickness2Analysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 218 element->GetSolutionFromInputsOneDof(solution,SurfaceEnum); 219 }/*}}}*/ 220 void Balancethickness2Analysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 221 _error_("Not implemented yet"); 222 }/*}}}*/ 223 void Balancethickness2Analysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 151 224 152 225 /*Intermediaries*/ 153 IssmDouble Jdet,thickness,vx,vy;154 IssmDouble *xyz_list = NULL;155 IssmDouble *xyz_list_front = NULL; 156 IssmDouble normal[2];157 158 /*Fetch number of nodes for this finite element*/ 159 int numnodes = element->GetNumberOfNodes();160 161 /*Initialize Element vector and other vectors*/162 ElementVector* pe = element->NewElementVector();163 IssmDouble* basis = xNew<IssmDouble>(numnodes);226 IssmDouble ds[2],s,b,D; 227 IssmDouble* xyz_list = NULL; 228 229 //element->InputUpdateFromSolutionOneDof(solution,ThicknessEnum); 230 element->InputUpdateFromSolutionOneDof(solution,SurfaceEnum); 231 232 /*Fetch number of vertices and allocate velocity vectors*/ 233 int numvertices = element->GetNumberOfVertices(); 234 IssmDouble* vel_list = xNew<IssmDouble>(numvertices); 235 IssmDouble* vx_list = xNew<IssmDouble>(numvertices); 236 IssmDouble* vy_list = xNew<IssmDouble>(numvertices); 164 237 165 238 /*Retrieve all inputs and parameters*/ 166 Input* thickness_input = element->GetInput(BalancethicknessThicknessObsEnum); _assert_(thickness_input); 167 Input* vx_input = element->GetInput(BalancethicknessVxObsEnum); _assert_(vx_input); 168 Input* vy_input = element->GetInput(BalancethicknessVyObsEnum); _assert_(vy_input); 169 170 element->GetVerticesCoordinates(&xyz_list); 171 element->GetIcefrontCoordinates(&xyz_list_front,xyz_list,MaskIceLevelsetEnum); 172 element->NormalSection(&normal[0],xyz_list_front); 173 174 /*Start looping on Gaussian points*/ 175 Gauss* gauss=element->NewGauss(xyz_list,xyz_list_front,3); 176 for(int ig=gauss->begin();ig<gauss->end();ig++){ 177 178 gauss->GaussPoint(ig); 179 thickness_input->GetInputValue(&thickness,gauss); 180 vx_input->GetInputValue(&vx,gauss); 181 vy_input->GetInputValue(&vy,gauss); 182 element->JacobianDeterminantSurface(&Jdet,xyz_list_front,gauss); 183 element->NodalFunctions(basis,gauss); 184 185 for(int i=0;i<numnodes;i++) pe->values[i] += Jdet*gauss->weight*thickness*(vx*normal[0] + vy*normal[1])*basis[i]; 186 } 187 188 /*Clean up and return*/ 189 xDelete<IssmDouble>(xyz_list); 190 xDelete<IssmDouble>(xyz_list_front); 191 xDelete<IssmDouble>(basis); 192 delete gauss; 193 return pe; 194 }/*}}}*/ 195 void Balancethickness2Analysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 196 _error_("not implemented yet"); 197 }/*}}}*/ 198 void Balancethickness2Analysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 199 _error_("Not implemented yet"); 200 }/*}}}*/ 201 void Balancethickness2Analysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 202 203 /*Intermediaries */ 204 int Hinterpolation; 205 IssmDouble vx,vy,vbar,nux,nuy,normdphi,dphi[2]; 206 IssmDouble* xyz_list = NULL; 207 int * doflist = NULL; 208 209 /*Fetch number of nodes and dof for this finite element*/ 210 int numnodes = element->GetNumberOfNodes(); 211 int numvertices = element->GetNumberOfVertices(); 212 213 /*Fetch dof list and allocate solution vector*/ 214 element->GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 215 IssmDouble* values = xNew<IssmDouble>(numnodes); 216 IssmDouble* thickness_list = xNew<IssmDouble>(numvertices); 217 IssmDouble* vx_list = xNew<IssmDouble>(numvertices); 218 IssmDouble* vy_list = xNew<IssmDouble>(numvertices); 219 220 /*Use the dof list to index into the solution vector: */ 221 for(int i=0;i<numnodes;i++){ 222 values[i]=solution[doflist[i]]; 223 224 /*Check solution*/ 225 if(xIsNan<IssmDouble>(values[i])) _error_("NaN found in solution vector"); 226 } 227 228 element->AddInput(PotentialEnum,values,element->GetElementType()); 229 230 /*Retrieve all inputs and parameters*/ 231 element->GetVerticesCoordinates(&xyz_list); 232 Input* potential_input = element->GetInput(PotentialEnum); _assert_(potential_input); 233 Input* vx_input = element->GetInput(BalancethicknessVxObsEnum); _assert_(vx_input); 234 Input* vy_input = element->GetInput(BalancethicknessVyObsEnum); _assert_(vy_input); 235 Input* nux_input = element->GetInput(BalancethicknessNuxEnum); _assert_(nux_input); 236 Input* nuy_input = element->GetInput(BalancethicknessNuyEnum); _assert_(nuy_input); 237 238 switch(element->GetElementType()){ 239 case P1Enum: Hinterpolation = P0Enum; break; 240 default: _error_("not implemented"); 241 } 242 239 element->GetVerticesCoordinates(&xyz_list); 240 Input* D_input = element->GetInput(BalancethicknessDiffusionCoefficientEnum); 241 Input* H_input = element->GetInput(ThicknessEnum); _assert_(H_input); 242 Input* s_input = element->GetInput(SurfaceEnum); _assert_(s_input); 243 Input* b_input = element->GetInput(BaseEnum); _assert_(b_input); 244 245 /*Calculate velocities*/ 243 246 Gauss* gauss=element->NewGauss(); 244 for (int iv=0;iv<1;iv++){ 245 gauss->GaussNode(Hinterpolation,iv);//P0 Only for now 246 247 vx_input->GetInputValue(&vx,gauss); 248 vy_input->GetInputValue(&vy,gauss); 249 nux_input->GetInputValue(&nux,gauss); 250 nuy_input->GetInputValue(&nuy,gauss); 251 potential_input->GetInputDerivativeValue(&dphi[0],xyz_list,gauss); 252 253 vx = vx*nux; vy = vy*nuy; 254 vbar = sqrt(vx*vx + vy*vy) + 1.e-10; 255 normdphi = sqrt(dphi[0]*dphi[0] + dphi[1]*dphi[1]); 256 257 thickness_list[iv] = normdphi/vbar; 258 vx_list[iv] = -1./thickness_list[iv] * dphi[0]; 259 vy_list[iv] = -1./thickness_list[iv] * dphi[1]; 260 } 261 element->AddInput(ThicknessEnum,thickness_list,Hinterpolation); 262 element->AddInput(VxEnum,vx_list,Hinterpolation); 263 element->AddInput(VyEnum,vy_list,Hinterpolation); 264 265 /*Clean up and return*/ 266 delete gauss; 267 xDelete<int>(doflist); 268 xDelete<IssmDouble>(xyz_list); 269 xDelete<IssmDouble>(values); 270 xDelete<IssmDouble>(thickness_list); 247 for(int iv=0;iv<numvertices;iv++){ 248 gauss->GaussVertex(iv); 249 250 if(D_input){ 251 D_input->GetInputValue(&D,gauss); 252 } 253 else{ 254 D = 0.; 255 } 256 b_input->GetInputValue(&b,gauss); 257 s_input->GetInputValue(&s,gauss); 258 s_input->GetInputDerivativeValue(&ds[0],xyz_list,gauss); 259 260 vx_list[iv] = -1./(s-b)*D*ds[0]; 261 vy_list[iv] = -1./(s-b)*D*ds[1]; 262 vel_list[iv] = sqrt(pow(vx_list[iv],2) + pow(vy_list[iv],2)); 263 } 264 265 /*Add vx and vy as inputs to the tria element: */ 266 element->AddInput(VxEnum,vx_list,P1Enum); 267 element->AddInput(VyEnum,vy_list,P1Enum); 268 element->AddInput(VelEnum,vel_list,P1Enum); 269 270 /*Free ressources:*/ 271 delete gauss; 272 xDelete<IssmDouble>(vy_list); 271 273 xDelete<IssmDouble>(vx_list); 272 xDelete<IssmDouble>(vy_list); 273 }/*}}}*/ 274 void Balancethickness2Analysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 274 xDelete<IssmDouble>(vel_list); 275 xDelete<IssmDouble>(xyz_list); 276 }/*}}}*/ 277 void Balancethickness2Analysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 275 278 /*Default, do nothing*/ 276 279 return; -
issm/trunk/src/c/analyses/Balancethickness2Analysis.h
r18301 r19105 13 13 public: 14 14 /*Model processing*/ 15 int DofsPerNode(int** doflist,int domaintype,int approximation);16 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum);17 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type);18 void CreateNodes(Nodes* nodes,IoModel* iomodel);19 15 void CreateConstraints(Constraints* constraints,IoModel* iomodel); 20 16 void CreateLoads(Loads* loads, IoModel* iomodel); 17 void CreateNodes(Nodes* nodes,IoModel* iomodel); 18 int DofsPerNode(int** doflist,int domaintype,int approximation); 19 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 20 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum); 21 21 22 22 /*Finite element Analysis*/ 23 23 void Core(FemModel* femmodel); 24 24 ElementVector* CreateDVector(Element* element); 25 void CreateD0(Element* element); 25 26 ElementMatrix* CreateJacobianMatrix(Element* element); 26 27 ElementMatrix* CreateKMatrix(Element* element); 27 28 ElementVector* CreatePVector(Element* element); 28 ElementVector* CreatePVectorVolume(Element* element); 29 ElementVector* CreatePVectorBoundary(Element* element); 30 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 31 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 32 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 33 void UpdateConstraints(FemModel* femmodel); 29 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 30 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 31 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 32 void UpdateConstraints(FemModel* femmodel); 34 33 }; 35 34 #endif -
issm/trunk/src/c/analyses/BalancethicknessAnalysis.cpp
r18301 r19105 6 6 7 7 /*Model processing*/ 8 void BalancethicknessAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 9 10 /*Fetch parameters: */ 11 int stabilization; 12 iomodel->Constant(&stabilization,BalancethicknessStabilizationEnum); 13 14 /*Do not add constraints in DG*/ 15 if(stabilization!=3){ 16 IoModelToConstraintsx(constraints,iomodel,BalancethicknessSpcthicknessEnum,BalancethicknessAnalysisEnum,P1Enum); 17 } 18 19 }/*}}}*/ 20 void BalancethicknessAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 21 22 /*Intermediary*/ 23 int element; 24 int stabilization; 25 26 /*Fetch parameters: */ 27 iomodel->Constant(&stabilization,BalancethicknessStabilizationEnum); 28 29 /*Loads only in DG*/ 30 if (stabilization==3){ 31 32 /*Get faces and elements*/ 33 CreateFaces(iomodel); 34 iomodel->FetchData(1,ThicknessEnum); 35 36 /*First load data:*/ 37 for(int i=0;i<iomodel->numberoffaces;i++){ 38 39 /*Get left and right elements*/ 40 element=iomodel->faces[4*i+2]-1; //faces are [node1 node2 elem1 elem2] 41 42 /*Now, if this element is not in the partition, pass: */ 43 if(!iomodel->my_elements[element]) continue; 44 45 /* Add load */ 46 loads->AddObject(new Numericalflux(iomodel->loadcounter+i+1,i,i,iomodel,BalancethicknessAnalysisEnum)); 47 } 48 49 /*Free data: */ 50 iomodel->DeleteData(1,ThicknessEnum); 51 } 52 }/*}}}*/ 53 void BalancethicknessAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 54 55 int stabilization; 56 iomodel->Constant(&stabilization,BalancethicknessStabilizationEnum); 57 58 /*Check in 3d*/ 59 if(stabilization==3 && iomodel->domaintype==Domain3DEnum) _error_("DG 3d not implemented yet"); 60 61 /*First fetch data: */ 62 if(iomodel->domaintype==Domain3DEnum) iomodel->FetchData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 63 if(stabilization!=3){ 64 ::CreateNodes(nodes,iomodel,BalancethicknessAnalysisEnum,P1Enum); 65 } 66 else{ 67 ::CreateNodes(nodes,iomodel,BalancethicknessAnalysisEnum,P1DGEnum); 68 } 69 iomodel->DeleteData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 70 }/*}}}*/ 8 71 int BalancethicknessAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/ 9 72 return 1; 10 }/*}}}*/11 void BalancethicknessAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/12 parameters->AddObject(iomodel->CopyConstantObject(BalancethicknessStabilizationEnum));13 73 }/*}}}*/ 14 74 void BalancethicknessAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ … … 50 110 } 51 111 }/*}}}*/ 52 void BalancethicknessAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 53 54 int stabilization; 55 iomodel->Constant(&stabilization,BalancethicknessStabilizationEnum); 56 57 /*Check in 3d*/ 58 if(stabilization==3 && iomodel->domaintype==Domain3DEnum) _error_("DG 3d not implemented yet"); 59 60 /*First fetch data: */ 61 if(iomodel->domaintype==Domain3DEnum) iomodel->FetchData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 62 if(stabilization!=3){ 63 ::CreateNodes(nodes,iomodel,BalancethicknessAnalysisEnum,P1Enum); 64 } 65 else{ 66 ::CreateNodes(nodes,iomodel,BalancethicknessAnalysisEnum,P1DGEnum); 67 } 68 iomodel->DeleteData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 69 }/*}}}*/ 70 void BalancethicknessAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 71 72 /*Fetch parameters: */ 73 int stabilization; 74 iomodel->Constant(&stabilization,BalancethicknessStabilizationEnum); 75 76 /*Do not add constraints in DG*/ 77 if(stabilization!=3){ 78 IoModelToConstraintsx(constraints,iomodel,BalancethicknessSpcthicknessEnum,BalancethicknessAnalysisEnum,P1Enum); 79 } 80 81 }/*}}}*/ 82 void BalancethicknessAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 83 84 /*Intermediary*/ 85 int element; 86 int stabilization; 87 88 /*Fetch parameters: */ 89 iomodel->Constant(&stabilization,BalancethicknessStabilizationEnum); 90 91 /*Loads only in DG*/ 92 if (stabilization==3){ 93 94 /*Get faces and elements*/ 95 CreateFaces(iomodel); 96 iomodel->FetchData(1,ThicknessEnum); 97 98 /*First load data:*/ 99 for(int i=0;i<iomodel->numberoffaces;i++){ 100 101 /*Get left and right elements*/ 102 element=iomodel->faces[4*i+2]-1; //faces are [node1 node2 elem1 elem2] 103 104 /*Now, if this element is not in the partition, pass: */ 105 if(!iomodel->my_elements[element]) continue; 106 107 /* Add load */ 108 loads->AddObject(new Numericalflux(iomodel->loadcounter+i+1,i,i,iomodel,BalancethicknessAnalysisEnum)); 109 } 110 111 /*Free data: */ 112 iomodel->DeleteData(1,ThicknessEnum); 113 } 112 void BalancethicknessAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 113 parameters->AddObject(iomodel->CopyConstantObject(BalancethicknessStabilizationEnum)); 114 114 }/*}}}*/ 115 115 … … 421 421 return pe; 422 422 }/*}}}*/ 423 void BalancethicknessAnalysis::GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/423 void BalancethicknessAnalysis::GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 424 424 /*Compute B matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2. 425 425 * For node i, Bi can be expressed in the actual coordinate system … … 448 448 xDelete<IssmDouble>(basis); 449 449 }/*}}}*/ 450 void BalancethicknessAnalysis::GetBprime(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/450 void BalancethicknessAnalysis::GetBprime(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 451 451 /*Compute B' matrix. B'=[B1' B2' B3'] where Bi' is of size 3*NDOF2. 452 452 * For node i, Bi' can be expressed in the actual coordinate system … … 476 476 477 477 }/*}}}*/ 478 void BalancethicknessAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/478 void BalancethicknessAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 479 479 _error_("not implemented yet"); 480 480 }/*}}}*/ 481 void BalancethicknessAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/481 void BalancethicknessAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 482 482 /* WARNING: this gradient is valid for Soft balance thickness only */ 483 483 … … 595 595 596 596 }/*}}}*/ 597 void BalancethicknessAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/597 void BalancethicknessAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 598 598 599 599 int domaintype; … … 609 609 } 610 610 }/*}}}*/ 611 void BalancethicknessAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/611 void BalancethicknessAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 612 612 /*Default, do nothing*/ 613 613 return; -
issm/trunk/src/c/analyses/BalancethicknessAnalysis.h
r18301 r19105 13 13 public: 14 14 /*Model processing*/ 15 int DofsPerNode(int** doflist,int domaintype,int approximation);16 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum);17 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type);18 void CreateNodes(Nodes* nodes,IoModel* iomodel);19 15 void CreateConstraints(Constraints* constraints,IoModel* iomodel); 20 16 void CreateLoads(Loads* loads, IoModel* iomodel); 17 void CreateNodes(Nodes* nodes,IoModel* iomodel); 18 int DofsPerNode(int** doflist,int domaintype,int approximation); 19 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 20 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum); 21 21 22 22 /*Finite element Analysis*/ … … 30 30 ElementVector* CreatePVectorCG(Element* element); 31 31 ElementVector* CreatePVectorDG(Element* element); 32 void GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss);33 void GetBprime(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss);34 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element);35 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index);36 void InputUpdateFromSolution(IssmDouble* solution,Element* element);37 void UpdateConstraints(FemModel* femmodel);32 void GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss); 33 void GetBprime(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss); 34 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 35 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 36 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 37 void UpdateConstraints(FemModel* femmodel); 38 38 }; 39 39 #endif -
issm/trunk/src/c/analyses/BalancevelocityAnalysis.cpp
r18301 r19105 6 6 7 7 /*Model processing*/ 8 void BalancevelocityAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 9 10 /*No constraints for now*/ 11 //IoModelToConstraintsx(constraints,iomodel,BalancethicknessSpcthicknessEnum,BalancevelocityAnalysisEnum,P1Enum); 12 }/*}}}*/ 13 void BalancevelocityAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 14 15 /*No loads*/ 16 }/*}}}*/ 17 void BalancevelocityAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 18 19 /*Check in 3d*/ 20 if(iomodel->domaintype==Domain3DEnum) _error_("DG 3d not implemented yet"); 21 22 /*First fetch data: */ 23 ::CreateNodes(nodes,iomodel,BalancevelocityAnalysisEnum,P1Enum); 24 }/*}}}*/ 8 25 int BalancevelocityAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/ 9 26 return 1; 10 }/*}}}*/11 void BalancevelocityAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/12 27 }/*}}}*/ 13 28 void BalancevelocityAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ … … 38 53 } 39 54 }/*}}}*/ 40 void BalancevelocityAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 41 42 /*Check in 3d*/ 43 if(iomodel->domaintype==Domain3DEnum) _error_("DG 3d not implemented yet"); 44 45 /*First fetch data: */ 46 ::CreateNodes(nodes,iomodel,BalancevelocityAnalysisEnum,P1Enum); 47 }/*}}}*/ 48 void BalancevelocityAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 49 50 /*No constraints for now*/ 51 //IoModelToConstraintsx(constraints,iomodel,BalancethicknessSpcthicknessEnum,BalancevelocityAnalysisEnum,P1Enum); 52 }/*}}}*/ 53 void BalancevelocityAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 54 55 /*No loads*/ 55 void BalancevelocityAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 56 56 }/*}}}*/ 57 57 … … 95 95 96 96 /*Get vector N for all nodes and build HNx and HNy*/ 97 element->GetInputListOnNodes(Nx, SurfaceSlopeXEnum);98 element->GetInputListOnNodes(Ny, SurfaceSlopeYEnum);97 element->GetInputListOnNodes(Nx,DrivingStressXEnum); 98 element->GetInputListOnNodes(Ny,DrivingStressYEnum); 99 99 element->GetInputListOnNodes(H,ThicknessEnum); 100 100 for(int i=0;i<numnodes;i++){ … … 190 190 191 191 /*Get vector N for all nodes*/ 192 basalelement->GetInputListOnNodes(Nx, SurfaceSlopeXEnum);193 basalelement->GetInputListOnNodes(Ny, SurfaceSlopeYEnum);192 basalelement->GetInputListOnNodes(Nx,DrivingStressXEnum); 193 basalelement->GetInputListOnNodes(Ny,DrivingStressYEnum); 194 194 basalelement->GetInputListOnNodes(H,ThicknessEnum); 195 195 for(int i=0;i<numnodes;i++){ … … 238 238 return pe; 239 239 }/*}}}*/ 240 void BalancevelocityAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/240 void BalancevelocityAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 241 241 _error_("not implemented yet"); 242 242 }/*}}}*/ 243 void BalancevelocityAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/243 void BalancevelocityAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 244 244 _error_("Not implemented yet"); 245 245 }/*}}}*/ 246 void BalancevelocityAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/246 void BalancevelocityAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 247 247 248 248 int domaintype; … … 258 258 } 259 259 }/*}}}*/ 260 void BalancevelocityAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/260 void BalancevelocityAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 261 261 /*Default, do nothing*/ 262 262 return; -
issm/trunk/src/c/analyses/BalancevelocityAnalysis.h
r18301 r19105 13 13 public: 14 14 /*Model processing*/ 15 int DofsPerNode(int** doflist,int domaintype,int approximation);16 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum);17 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type);18 void CreateNodes(Nodes* nodes,IoModel* iomodel);19 15 void CreateConstraints(Constraints* constraints,IoModel* iomodel); 20 16 void CreateLoads(Loads* loads, IoModel* iomodel); 17 void CreateNodes(Nodes* nodes,IoModel* iomodel); 18 int DofsPerNode(int** doflist,int domaintype,int approximation); 19 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 20 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum); 21 21 22 22 /*Finite element Analysis*/ … … 26 26 ElementMatrix* CreateKMatrix(Element* element); 27 27 ElementVector* CreatePVector(Element* element); 28 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element);29 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index);30 void InputUpdateFromSolution(IssmDouble* solution,Element* element);31 void UpdateConstraints(FemModel* femmodel);28 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 29 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 30 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 31 void UpdateConstraints(FemModel* femmodel); 32 32 }; 33 33 #endif -
issm/trunk/src/c/analyses/DamageEvolutionAnalysis.cpp
r18301 r19105 6 6 7 7 /*Model processing*/ 8 void DamageEvolutionAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 9 10 int finiteelement; 11 iomodel->Constant(&finiteelement,DamageElementinterpEnum); 12 13 IoModelToConstraintsx(constraints,iomodel,DamageSpcdamageEnum,DamageEvolutionAnalysisEnum,finiteelement); 14 15 }/*}}}*/ 16 void DamageEvolutionAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 17 18 /*Nothing for now*/ 19 20 }/*}}}*/ 21 void DamageEvolutionAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 22 23 int finiteelement; 24 25 iomodel->Constant(&finiteelement,DamageElementinterpEnum); 26 ::CreateNodes(nodes,iomodel,DamageEvolutionAnalysisEnum,finiteelement); 27 }/*}}}*/ 8 28 int DamageEvolutionAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/ 9 29 return 1; 30 }/*}}}*/ 31 void DamageEvolutionAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ 32 33 int finiteelement; 34 bool islevelset; 35 36 iomodel->Constant(&finiteelement,DamageElementinterpEnum); 37 iomodel->Constant(&islevelset,TransientIslevelsetEnum); 38 39 /*Update elements: */ 40 int counter=0; 41 for(int i=0;i<iomodel->numberofelements;i++){ 42 if(iomodel->my_elements[i]){ 43 Element* element=(Element*)elements->GetObjectByOffset(counter); 44 element->Update(i,iomodel,analysis_counter,analysis_type,finiteelement); 45 counter++; 46 } 47 } 48 49 /*What input do I need to run my damage evolution model?*/ 50 iomodel->FetchDataToInput(elements,VxEnum); 51 iomodel->FetchDataToInput(elements,VyEnum); 52 if(iomodel->domaintype==Domain3DEnum) iomodel->FetchDataToInput(elements,VzEnum); 53 iomodel->FetchDataToInput(elements,DamageDEnum); 54 iomodel->FetchDataToInput(elements,MaskIceLevelsetEnum); 55 iomodel->FetchDataToInput(elements,PressureEnum); 56 57 if(islevelset){ 58 iomodel->FetchDataToInput(elements,IceMaskNodeActivationEnum); 59 } 60 10 61 }/*}}}*/ 11 62 void DamageEvolutionAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ … … 45 96 46 97 }/*}}}*/ 47 void DamageEvolutionAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/48 49 int finiteelement;50 51 iomodel->Constant(&finiteelement,DamageElementinterpEnum);52 53 /*Update elements: */54 int counter=0;55 for(int i=0;i<iomodel->numberofelements;i++){56 if(iomodel->my_elements[i]){57 Element* element=(Element*)elements->GetObjectByOffset(counter);58 element->Update(i,iomodel,analysis_counter,analysis_type,finiteelement);59 counter++;60 }61 }62 63 /*What input do I need to run my damage evolution model?*/64 iomodel->FetchDataToInput(elements,VxEnum);65 iomodel->FetchDataToInput(elements,VyEnum);66 if(iomodel->domaintype==Domain3DEnum) iomodel->FetchDataToInput(elements,VzEnum);67 iomodel->FetchDataToInput(elements,DamageDEnum);68 iomodel->FetchDataToInput(elements,MaskIceLevelsetEnum);69 iomodel->FetchDataToInput(elements,PressureEnum);70 71 }/*}}}*/72 void DamageEvolutionAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/73 74 int finiteelement;75 76 iomodel->Constant(&finiteelement,DamageElementinterpEnum);77 78 if(iomodel->domaintype!=Domain2DhorizontalEnum) iomodel->FetchData(1,MeshVertexonbaseEnum);79 ::CreateNodes(nodes,iomodel,DamageEvolutionAnalysisEnum,finiteelement);80 iomodel->DeleteData(1,MeshVertexonbaseEnum);81 }/*}}}*/82 void DamageEvolutionAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/83 84 int finiteelement;85 iomodel->Constant(&finiteelement,DamageElementinterpEnum);86 87 IoModelToConstraintsx(constraints,iomodel,DamageSpcdamageEnum,DamageEvolutionAnalysisEnum,finiteelement);88 89 }/*}}}*/90 void DamageEvolutionAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/91 92 /*Nothing for now*/93 94 }/*}}}*/95 98 96 99 /*Finite Element Analysis*/ … … 98 101 _error_("not implemented"); 99 102 }/*}}}*/ 100 ElementVector* DamageEvolutionAnalysis::CreateDVector(Element* element){/*{{{*/ 101 /*Default, return NULL*/ 102 return NULL; 103 }/*}}}*/ 104 ElementMatrix* DamageEvolutionAnalysis::CreateJacobianMatrix(Element* element){/*{{{*/ 105 _error_("Not implemented"); 106 }/*}}}*/ 107 ElementMatrix* DamageEvolutionAnalysis::CreateKMatrix(Element* element){/*{{{*/ 108 109 /* Check if ice in element */ 110 if(!element->IsIceInElement()) return NULL; 111 112 /*Intermediaries*/ 113 Element* basalelement; 114 int domaintype,dim; 115 int stabilization; 116 IssmDouble Jdet,dt,D_scalar,h; 117 IssmDouble vel,vx,vy,dvxdx,dvydy,dvx[2],dvy[2]; 118 IssmDouble *xyz_list = NULL; 119 120 /*Get problem dimension and basal element*/ 121 element->FindParam(&domaintype,DomainTypeEnum); 122 switch(domaintype){ 123 case Domain2DhorizontalEnum: 124 basalelement = element; 125 dim = 2; 126 break; 127 case Domain3DEnum: 128 if(!element->IsOnBase()) return NULL; 129 basalelement = element->SpawnBasalElement(); 130 dim = 2; 131 break; 132 default: _error_("mesh "<<EnumToStringx(domaintype)<<" not supported yet"); 133 } 134 135 /*Fetch number of nodes and dof for this finite element*/ 136 int numnodes = basalelement->GetNumberOfNodes(); 137 138 /*Initialize Element vector*/ 139 ElementMatrix* Ke = basalelement->NewElementMatrix(); 140 IssmDouble* basis = xNew<IssmDouble>(numnodes); 141 IssmDouble* B = xNew<IssmDouble>(dim*numnodes); 142 IssmDouble* Bprime = xNew<IssmDouble>(dim*numnodes); 143 IssmDouble* D = xNewZeroInit<IssmDouble>(dim*dim); 144 145 /*Retrieve all inputs and parameters*/ 146 basalelement->GetVerticesCoordinates(&xyz_list); 147 basalelement->FindParam(&dt,TimesteppingTimeStepEnum); 148 basalelement->FindParam(&stabilization,DamageStabilizationEnum); 149 Input* vxaverage_input=NULL; 150 Input* vyaverage_input=NULL; 151 if(domaintype==Domain2DhorizontalEnum){ 152 vxaverage_input=basalelement->GetInput(VxEnum); _assert_(vxaverage_input); 153 vyaverage_input=basalelement->GetInput(VyEnum); _assert_(vyaverage_input); 154 } 155 else{ 156 if(dim==1){ 157 vxaverage_input=element->GetInput(VxEnum); _assert_(vxaverage_input); 158 } 159 if(dim==2){ 160 vxaverage_input=element->GetInput(VxAverageEnum); _assert_(vxaverage_input); 161 vyaverage_input=element->GetInput(VyAverageEnum); _assert_(vyaverage_input); 162 } 163 } 164 h=basalelement->CharacteristicLength(); 165 166 /* Start looping on the number of gaussian points: */ 167 Gauss* gauss=basalelement->NewGauss(2); 168 for(int ig=gauss->begin();ig<gauss->end();ig++){ 169 gauss->GaussPoint(ig); 170 171 basalelement->JacobianDeterminant(&Jdet,xyz_list,gauss); 172 basalelement->NodalFunctions(basis,gauss); 173 174 vxaverage_input->GetInputValue(&vx,gauss); 175 vxaverage_input->GetInputDerivativeValue(&dvx[0],xyz_list,gauss); 176 if(dim==2){ 177 vyaverage_input->GetInputValue(&vy,gauss); 178 vyaverage_input->GetInputDerivativeValue(&dvy[0],xyz_list,gauss); 179 } 180 181 D_scalar=gauss->weight*Jdet; 182 TripleMultiply(basis,1,numnodes,1, 183 &D_scalar,1,1,0, 184 basis,1,numnodes,0, 185 &Ke->values[0],1); 186 187 GetB(B,basalelement,dim,xyz_list,gauss); 188 GetBprime(Bprime,basalelement,dim,xyz_list,gauss); 189 190 dvxdx=dvx[0]; 191 if(dim==2) dvydy=dvy[1]; 192 D_scalar=dt*gauss->weight*Jdet; 193 194 D[0*dim+0]=D_scalar*dvxdx; 195 if(dim==2) D[1*dim+1]=D_scalar*dvydy; 196 197 TripleMultiply(B,dim,numnodes,1, 198 D,dim,dim,0, 199 B,dim,numnodes,0, 200 &Ke->values[0],1); 201 202 D[0*dim+0]=D_scalar*vx; 203 if(dim==2) D[1*dim+1]=D_scalar*vy; 204 205 TripleMultiply(B,dim,numnodes,1, 206 D,dim,dim,0, 207 Bprime,dim,numnodes,0, 208 &Ke->values[0],1); 209 210 if(stabilization==2){ 211 if(dim==1){ 212 vel=fabs(vx)+1.e-8; 213 D[0]=h/(2.0*vel)*vx*vx; 214 } 215 else{ 216 /*Streamline upwinding*/ 217 vel=sqrt(vx*vx+vy*vy)+1.e-8; 218 D[0*dim+0]=h/(2.0*vel)*vx*vx; 219 D[1*dim+0]=h/(2.0*vel)*vy*vx; 220 D[0*dim+1]=h/(2.0*vel)*vx*vy; 221 D[1*dim+1]=h/(2.0*vel)*vy*vy; 222 } 223 } 224 else if(stabilization==1){ 225 vxaverage_input->GetInputAverage(&vx); 226 if(dim==2) vyaverage_input->GetInputAverage(&vy); 227 D[0*dim+0]=h/2.0*fabs(vx); 228 if(dim==2) D[1*dim+1]=h/2.0*fabs(vy); 229 } 230 if(stabilization==1 || stabilization==2){ 231 if(dim==1) D[0]=D_scalar*D[0]; 232 else{ 233 D[0*dim+0]=D_scalar*D[0*dim+0]; 234 D[1*dim+0]=D_scalar*D[1*dim+0]; 235 D[0*dim+1]=D_scalar*D[0*dim+1]; 236 D[1*dim+1]=D_scalar*D[1*dim+1]; 237 } 238 239 TripleMultiply(Bprime,dim,numnodes,1, 240 D,dim,dim,0, 241 Bprime,dim,numnodes,0, 242 &Ke->values[0],1); 243 } 244 245 } 246 247 /*Clean up and return*/ 248 xDelete<IssmDouble>(xyz_list); 249 xDelete<IssmDouble>(basis); 250 xDelete<IssmDouble>(B); 251 xDelete<IssmDouble>(Bprime); 252 xDelete<IssmDouble>(D); 253 delete gauss; 254 if(domaintype!=Domain2DhorizontalEnum){basalelement->DeleteMaterials(); delete basalelement;}; 255 return Ke; 256 }/*}}}*/ 257 ElementVector* DamageEvolutionAnalysis::CreatePVector(Element* element){/*{{{*/ 258 259 /* Check if ice in element */ 260 if(!element->IsIceInElement()) return NULL; 261 262 /*Intermediaries*/ 263 int domaintype,damagelaw; 264 Element* basalelement; 265 IssmDouble Jdet,dt; 266 IssmDouble f,damage; 267 IssmDouble* xyz_list = NULL; 268 269 /*Get basal element*/ 270 element->FindParam(&domaintype,DomainTypeEnum); 271 switch(domaintype){ 272 case Domain2DhorizontalEnum: 273 basalelement = element; 274 break; 275 case Domain3DEnum: 276 if(!element->IsOnBase()) return NULL; 277 basalelement = element->SpawnBasalElement(); 278 break; 279 default: _error_("mesh "<<EnumToStringx(domaintype)<<" not supported yet"); 280 } 281 282 283 /*Fetch number of nodes and dof for this finite element*/ 284 int numnodes = basalelement->GetNumberOfNodes(); 285 286 /*Initialize Element vector and other vectors*/ 287 ElementVector* pe = basalelement->NewElementVector(); 288 IssmDouble* basis = xNew<IssmDouble>(numnodes); 289 290 /*Retrieve all inputs and parameters*/ 291 basalelement->GetVerticesCoordinates(&xyz_list); 292 basalelement->FindParam(&dt,TimesteppingTimeStepEnum); 293 basalelement->FindParam(&damagelaw,DamageLawEnum); 294 if(damagelaw==1 | damagelaw==2){ 295 this->CreateDamageFInputPralong(basalelement); 296 } 297 else if(damagelaw==3){ 298 this->CreateDamageFInputExp(basalelement); 299 } 300 Input* damaged_input = basalelement->GetInput(DamageDEnum); _assert_(damaged_input); 301 Input* damagef_input = basalelement->GetInput(DamageFEnum); _assert_(damagef_input); 302 303 304 /* Start looping on the number of gaussian points: */ 305 Gauss* gauss=basalelement->NewGauss(2); 306 for(int ig=gauss->begin();ig<gauss->end();ig++){ 307 gauss->GaussPoint(ig); 308 309 basalelement->JacobianDeterminant(&Jdet,xyz_list,gauss); 310 basalelement->NodalFunctions(basis,gauss); 311 312 damaged_input->GetInputValue(&damage,gauss); 313 damagef_input->GetInputValue(&f,gauss); 314 315 for(int i=0;i<numnodes;i++){ 316 pe->values[i]+=Jdet*gauss->weight*(damage+dt*f)*basis[i]; 317 } 318 } 319 320 /*Clean up and return*/ 321 xDelete<IssmDouble>(xyz_list); 322 xDelete<IssmDouble>(basis); 323 if(domaintype!=Domain2DhorizontalEnum){basalelement->DeleteMaterials(); delete basalelement;}; 324 delete gauss; 325 return pe; 326 }/*}}}*/ 327 void DamageEvolutionAnalysis::GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 328 /*Compute B matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2. 329 * For node i, Bi can be expressed in the actual coordinate system 330 * by: 331 * Bi=[ N ] 332 * [ N ] 333 * where N is the finiteelement function for node i. 334 * 335 * We assume B_prog has been allocated already, of size: 2x(NDOF1*numnodes) 336 */ 337 338 /*Fetch number of nodes for this finite element*/ 339 int numnodes = element->GetNumberOfNodes(); 340 341 /*Get nodal functions*/ 342 IssmDouble* basis=xNew<IssmDouble>(numnodes); 343 element->NodalFunctions(basis,gauss); 344 345 /*Build B: */ 346 for(int i=0;i<numnodes;i++){ 347 for(int j=0;j<dim;j++){ 348 B[numnodes*j+i] = basis[i]; 349 } 350 } 351 352 /*Clean-up*/ 353 xDelete<IssmDouble>(basis); 354 }/*}}}*/ 355 void DamageEvolutionAnalysis::GetBprime(IssmDouble* Bprime,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 356 /*Compute B' matrix. B'=[B1' B2' B3'] where Bi' is of size 3*NDOF2. 357 * For node i, Bi' can be expressed in the actual coordinate system 358 * by: 359 * Bi_prime=[ dN/dx ] 360 * [ dN/dy ] 361 * where N is the finiteelement function for node i. 362 * 363 * We assume B' has been allocated already, of size: 3x(NDOF2*numnodes) 364 */ 365 366 /*Fetch number of nodes for this finite element*/ 367 int numnodes = element->GetNumberOfNodes(); 368 369 /*Get nodal functions derivatives*/ 370 IssmDouble* dbasis=xNew<IssmDouble>(dim*numnodes); 371 element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss); 372 373 /*Build B': */ 374 for(int i=0;i<numnodes;i++){ 375 for(int j=0;j<dim;j++){ 376 Bprime[numnodes*j+i] = dbasis[j*numnodes+i]; 377 } 378 } 379 380 /*Clean-up*/ 381 xDelete<IssmDouble>(dbasis); 382 383 }/*}}}*/ 384 void DamageEvolutionAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 385 _error_("not implemented yet"); 386 }/*}}}*/ 387 void DamageEvolutionAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 388 _error_("Not implemented yet"); 389 }/*}}}*/ 390 void DamageEvolutionAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 391 392 int domaintype; 393 IssmDouble max_damage; 394 int *doflist = NULL; 395 Element* basalelement=NULL; 396 397 element->FindParam(&domaintype,DomainTypeEnum); 398 if(domaintype!=Domain2DhorizontalEnum){ 399 if(!element->IsOnBase()) return; 400 basalelement=element->SpawnBasalElement(); 401 } 402 else{ 403 basalelement = element; 404 } 405 /*Fetch number of nodes and dof for this finite element*/ 406 int numnodes = basalelement->GetNumberOfNodes(); 407 408 /*Fetch dof list and allocate solution vector*/ 409 basalelement->GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 410 IssmDouble* newdamage = xNew<IssmDouble>(numnodes); 411 412 /*Get user-supplied max_damage: */ 413 basalelement->FindParam(&max_damage,DamageMaxDamageEnum); 414 415 /*Use the dof list to index into the solution vector: */ 416 for(int i=0;i<numnodes;i++){ 417 newdamage[i]=solution[doflist[i]]; 418 /*Check solution*/ 419 if(xIsNan<IssmDouble>(newdamage[i])) _error_("NaN found in solution vector"); 420 /*Enforce D < max_damage and D > 0 */ 421 if(newdamage[i]>max_damage) newdamage[i]=max_damage; 422 else if(newdamage[i]<0.) newdamage[i]=0.; 423 } 424 425 /*Get all inputs and parameters*/ 426 if(domaintype==Domain2DhorizontalEnum){ 427 basalelement->AddInput(DamageDbarEnum,newdamage,element->GetElementType()); 428 } 429 else{ 430 basalelement->AddBasalInput(DamageDEnum,newdamage,element->GetElementType()); 431 } 432 433 /*Free ressources:*/ 434 xDelete<IssmDouble>(newdamage); 435 xDelete<int>(doflist); 436 if(domaintype!=Domain2DhorizontalEnum){basalelement->DeleteMaterials(); delete basalelement;}; 437 }/*}}}*/ 438 void DamageEvolutionAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 439 /*Default, do nothing*/ 440 return; 441 }/*}}}*/ 442 443 /*Intermediaries*/ 444 void DamageEvolutionAnalysis::CreateDamageFInputPralong(Element* element){/*{{{*/ 445 446 /*Intermediaries */ 447 IssmDouble c1,c2,c3,healing,stress_threshold; 448 IssmDouble s_xx,s_xy,s_yy,s1,s2,stmp; 449 IssmDouble J2s,Chi,Psi,PosPsi,NegPsi; 450 IssmDouble damage,tau_xx,tau_xy,tau_yy; 451 int equivstress,domaintype,damagelaw; 452 453 /*Fetch number of vertices and allocate output*/ 454 int numnodes = element->GetNumberOfNodes(); 455 IssmDouble* f = xNew<IssmDouble>(numnodes); 456 457 /*retrieve parameters:*/ 458 element->FindParam(&c1,DamageC1Enum); 459 element->FindParam(&c2,DamageC2Enum); 460 element->FindParam(&c3,DamageC3Enum); 461 element->FindParam(&healing,DamageHealingEnum); 462 element->FindParam(&stress_threshold,DamageStressThresholdEnum); 463 element->FindParam(&domaintype,DomainTypeEnum); 464 element->FindParam(&damagelaw,DamageLawEnum); 465 466 /*Compute stress tensor: */ 467 element->ComputeDeviatoricStressTensor(); 468 469 /*retrieve what we need: */ 470 Input* tau_xx_input = element->GetInput(DeviatoricStressxxEnum); _assert_(tau_xx_input); 471 Input* tau_xy_input = element->GetInput(DeviatoricStressxyEnum); _assert_(tau_xy_input); 472 Input* tau_yy_input = element->GetInput(DeviatoricStressyyEnum); _assert_(tau_yy_input); 473 Input* damage_input = NULL; 474 if(domaintype==Domain2DhorizontalEnum){ 475 damage_input = element->GetInput(DamageDbarEnum); _assert_(damage_input); 476 } 477 else{ 478 damage_input = element->GetInput(DamageDEnum); _assert_(damage_input); 479 } 480 481 /*retrieve the desired type of equivalent stress*/ 482 element->FindParam(&equivstress,DamageEquivStressEnum); 483 484 /*Calculate damage evolution source term: */ 485 Gauss* gauss=element->NewGauss(); 486 for (int i=0;i<numnodes;i++){ 487 gauss->GaussNode(element->GetElementType(),i); 488 489 damage_input->GetInputValue(&damage,gauss); 490 tau_xx_input->GetInputValue(&tau_xx,gauss); 491 tau_xy_input->GetInputValue(&tau_xy,gauss); 492 tau_yy_input->GetInputValue(&tau_yy,gauss); 493 494 /*Calculate effective stress components*/ 495 s_xx=tau_xx/(1.-damage); 496 s_xy=tau_xy/(1.-damage); 497 s_yy=tau_yy/(1.-damage); 498 499 /*Calculate principal effective stresses*/ 500 s1=(s_xx+s_yy)/2.+sqrt(pow((s_xx-s_yy)/2.,2)+pow(s_xy,2)); 501 s2=(s_xx+s_yy)/2.-sqrt(pow((s_xx-s_yy)/2.,2)+pow(s_xy,2)); 502 if(fabs(s2)>fabs(s1)){stmp=s2; s2=s1; s1=stmp;} 503 504 if(equivstress==0){ /* von Mises */ 505 Chi=sqrt(s1*s1-s1*s2+s2*s2); 506 } 507 else if(equivstress==1){ /* max principal stress */ 508 Chi=s1; 509 } 510 Psi=Chi-stress_threshold; 511 NegPsi=max(-Chi,0.); /* healing only for compressive stresses */ 512 513 if(damagelaw==1){ 514 PosPsi=max(Psi,0.); 515 f[i]= c1*(pow(PosPsi,c2) - healing*pow(NegPsi,c2))*pow((1./(1.-damage)),c3); 516 } 517 else if(damagelaw==2){ 518 PosPsi=max(Psi,1.); 519 f[i]= c1*(pow(log10(PosPsi),c2) - healing*pow(NegPsi,c2))*pow((1./(1.-damage)),c3); 520 } 521 else _error_("damage law not supported"); 522 } 523 524 /*Add input*/ 525 element->AddInput(DamageFEnum,f,element->GetElementType()); 526 527 /*Clean up and return*/ 528 xDelete<IssmDouble>(f); 529 delete gauss; 530 }/*}}}*/ 531 void DamageEvolutionAnalysis::CreateDamageFInputExp(Element* element){/*{{{*/ 103 void DamageEvolutionAnalysis::CreateDamageFInputExp(Element* element){/*{{{*/ 532 104 533 105 /*Intermediaries */ … … 600 172 delete gauss; 601 173 }/*}}}*/ 174 void DamageEvolutionAnalysis::CreateDamageFInputPralong(Element* element){/*{{{*/ 175 176 /*Intermediaries */ 177 IssmDouble c1,c2,c3,healing,stress_threshold; 178 IssmDouble s_xx,s_xy,s_xz,s_yy,s_yz,s_zz,s1,s2,s3,stmp; 179 IssmDouble J2s,Chi,Psi,PosPsi,NegPsi; 180 IssmDouble damage,tau_xx,tau_xy,tau_xz,tau_yy,tau_yz,tau_zz,stressMaxPrincipal; 181 int equivstress,domaintype,damagelaw,dim; 182 183 /*Fetch number of vertices and allocate output*/ 184 int numnodes = element->GetNumberOfNodes(); 185 IssmDouble* f = xNew<IssmDouble>(numnodes); 186 187 /*retrieve parameters:*/ 188 element->FindParam(&c1,DamageC1Enum); 189 element->FindParam(&c2,DamageC2Enum); 190 element->FindParam(&c3,DamageC3Enum); 191 element->FindParam(&healing,DamageHealingEnum); 192 element->FindParam(&stress_threshold,DamageStressThresholdEnum); 193 element->FindParam(&domaintype,DomainTypeEnum); 194 element->FindParam(&damagelaw,DamageLawEnum); 195 196 /*Get problem dimension*/ 197 switch(domaintype){ 198 case Domain2DhorizontalEnum: dim = 2; break; 199 case Domain3DEnum: dim = 3; break; 200 default: _error_("not implemented"); 201 } 202 /*Compute stress tensor and Stress Max Principal: */ 203 element->ComputeDeviatoricStressTensor(); 204 if(dim==3){ 205 /*Only works in 3d because the pressure is defined*/ 206 element->StressMaxPrincipalCreateInput(); 207 } 208 /*retrieve what we need: */ 209 Input* tau_xx_input = element->GetInput(DeviatoricStressxxEnum); _assert_(tau_xx_input); 210 Input* tau_xy_input = element->GetInput(DeviatoricStressxyEnum); _assert_(tau_xy_input); 211 Input* tau_yy_input = element->GetInput(DeviatoricStressyyEnum); _assert_(tau_yy_input); 212 Input* tau_xz_input = NULL; 213 Input* tau_yz_input = NULL; 214 Input* tau_zz_input = NULL; 215 Input* stressMaxPrincipal_input = NULL; 216 if(dim==3){ 217 tau_xz_input = element->GetInput(DeviatoricStressxzEnum); _assert_(tau_xz_input); 218 tau_yz_input = element->GetInput(DeviatoricStressyzEnum); _assert_(tau_yz_input); 219 tau_zz_input = element->GetInput(DeviatoricStresszzEnum); _assert_(tau_zz_input); 220 stressMaxPrincipal_input = element->GetInput(StressMaxPrincipalEnum); _assert_(stressMaxPrincipal_input); 221 } 222 Input* damage_input = NULL; 223 if(domaintype==Domain2DhorizontalEnum){ 224 damage_input = element->GetInput(DamageDbarEnum); _assert_(damage_input); 225 } 226 else{ 227 damage_input = element->GetInput(DamageDEnum); _assert_(damage_input); 228 } 229 230 /*retrieve the desired type of equivalent stress*/ 231 element->FindParam(&equivstress,DamageEquivStressEnum); 232 233 /*Calculate damage evolution source term: */ 234 Gauss* gauss=element->NewGauss(); 235 for (int i=0;i<numnodes;i++){ 236 gauss->GaussNode(element->GetElementType(),i); 237 238 damage_input->GetInputValue(&damage,gauss); 239 tau_xx_input->GetInputValue(&tau_xx,gauss); 240 tau_xy_input->GetInputValue(&tau_xy,gauss); 241 tau_yy_input->GetInputValue(&tau_yy,gauss); 242 if(dim==3){ 243 tau_xz_input->GetInputValue(&tau_xz,gauss); 244 tau_yz_input->GetInputValue(&tau_yz,gauss); 245 tau_zz_input->GetInputValue(&tau_zz,gauss); 246 } 247 /*Calculate effective stress components*/ 248 s_xx=tau_xx/(1.-damage); 249 s_xy=tau_xy/(1.-damage); 250 s_yy=tau_yy/(1.-damage); 251 if(dim==3){ 252 s_xz=tau_xz/(1.-damage); 253 s_yz=tau_yz/(1.-damage); 254 s_zz=tau_zz/(1.-damage); 255 } 256 /*Calculate principal effective stresses*/ 257 if(dim==2){ 258 s1=(s_xx+s_yy)/2.+sqrt(pow((s_xx-s_yy)/2.,2)+pow(s_xy,2)); 259 s2=(s_xx+s_yy)/2.-sqrt(pow((s_xx-s_yy)/2.,2)+pow(s_xy,2)); 260 if(fabs(s2)>fabs(s1)){stmp=s2; s2=s1; s1=stmp;} 261 262 if(equivstress==0){ /* von Mises */ 263 Chi=sqrt(s1*s1-s1*s2+s2*s2); 264 } 265 else if(equivstress==1){ /* max principal stress */ 266 Chi=s1; 267 } 268 Psi=Chi-stress_threshold; 269 NegPsi=max(-Chi,0.); /* healing only for compressive stresses */ 270 271 if(damagelaw==1){ 272 PosPsi=max(Psi,0.); 273 f[i]= c1*(pow(PosPsi,c2) - healing*pow(NegPsi,c2))*pow((1./(1.-damage)),c3); 274 } 275 else if(damagelaw==2){ 276 PosPsi=max(Psi,1.); 277 f[i]= c1*(pow(log10(PosPsi),c2) - healing*pow(NegPsi,c2))*pow((1./(1.-damage)),c3); 278 } 279 else _error_("damage law not supported"); 280 } 281 else{ 282 if(equivstress==1){/* max principal stress */ 283 stressMaxPrincipal_input->GetInputValue(&stressMaxPrincipal,gauss); 284 Chi=stressMaxPrincipal/(1.-damage); 285 } 286 else if(equivstress==0){/* von Mises */ 287 Chi=sqrt(((s_xx-s_yy)*(s_xx-s_yy)+(s_yy-s_zz)*(s_yy-s_zz)+(s_zz-s_xx)*(s_zz-s_xx)+6.*(s_xy*s_xy+s_yz*s_yz+s_xz*s_xz))/2.); 288 } 289 Psi=Chi-stress_threshold; 290 NegPsi=max(-Chi,0.); /* healing only for compressive stresses */ 291 if(damagelaw==1){ 292 PosPsi=max(Psi,0.); 293 f[i]= c1*(pow(PosPsi,c2) - healing*pow(NegPsi,c2))*pow((1./(1.-damage)),c3); 294 } 295 else if(damagelaw==2){ 296 PosPsi=max(Psi,1.); 297 f[i]= c1*(pow(log10(PosPsi),c2) - healing*pow(NegPsi,c2))*pow((1./(1.-damage)),c3); 298 } 299 else _error_("damage law not supported"); 300 } 301 } 302 /*Add input*/ 303 element->AddInput(DamageFEnum,f,element->GetElementType()); 304 305 /*Clean up and return*/ 306 xDelete<IssmDouble>(f); 307 delete gauss; 308 }/*}}}*/ 309 ElementVector* DamageEvolutionAnalysis::CreateDVector(Element* element){/*{{{*/ 310 /*Default, return NULL*/ 311 return NULL; 312 }/*}}}*/ 313 ElementMatrix* DamageEvolutionAnalysis::CreateJacobianMatrix(Element* element){/*{{{*/ 314 _error_("Not implemented"); 315 }/*}}}*/ 316 ElementMatrix* DamageEvolutionAnalysis::CreateKMatrix(Element* element){/*{{{*/ 317 318 /* Check if ice in element */ 319 if(!element->IsIceInElement()) return NULL; 320 /*Intermediaries*/ 321 int domaintype,dim; 322 int stabilization; 323 IssmDouble Jdet,dt,D_scalar,h,hx,hy,hz; 324 IssmDouble vel,vx,vy,vz,dvxdx,dvydy,dvzdz,dvx[3],dvy[3],dvz[3]; 325 IssmDouble *xyz_list = NULL; 326 327 /*Get problem dimension*/ 328 element->FindParam(&domaintype,DomainTypeEnum); 329 switch(domaintype){ 330 case Domain2DhorizontalEnum: dim = 2; break; 331 case Domain3DEnum: dim = 3; break; 332 default: _error_("Not implemented yet"); 333 } 334 335 /*Fetch number of nodes and dof for this finite element*/ 336 int numnodes = element->GetNumberOfNodes(); 337 338 /*Initialize Element vector*/ 339 ElementMatrix* Ke = element->NewElementMatrix(); 340 IssmDouble* basis = xNew<IssmDouble>(numnodes); 341 IssmDouble* B = xNew<IssmDouble>(dim*numnodes); 342 IssmDouble* Bprime = xNew<IssmDouble>(dim*numnodes); 343 IssmDouble* D = xNewZeroInit<IssmDouble>(dim*dim); 344 345 /*Retrieve all inputs and parameters*/ 346 element->GetVerticesCoordinates(&xyz_list); 347 element->FindParam(&dt,TimesteppingTimeStepEnum); 348 element->FindParam(&stabilization,DamageStabilizationEnum); 349 Input* vx_input = element->GetInput(VxEnum); _assert_(vx_input); 350 Input* vy_input = element->GetInput(VyEnum); _assert_(vy_input); 351 Input* vz_input = NULL; 352 if(dim==3){ 353 vz_input=element->GetInput(VzEnum); _assert_(vz_input); 354 } 355 356 if(dim==2) h=element->CharacteristicLength(); 357 358 /* Start looping on the number of gaussian points: */ 359 Gauss* gauss=element->NewGauss(2); 360 for(int ig=gauss->begin();ig<gauss->end();ig++){ 361 gauss->GaussPoint(ig); 362 363 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 364 element->NodalFunctions(basis,gauss); 365 366 vx_input->GetInputValue(&vx,gauss); 367 vx_input->GetInputDerivativeValue(&dvx[0],xyz_list,gauss); 368 vy_input->GetInputValue(&vy,gauss); 369 vy_input->GetInputDerivativeValue(&dvy[0],xyz_list,gauss); 370 371 if(dim==3){ 372 vz_input->GetInputValue(&vz,gauss); 373 vz_input->GetInputDerivativeValue(&dvz[0],xyz_list,gauss); 374 } 375 376 D_scalar=gauss->weight*Jdet; 377 TripleMultiply(basis,1,numnodes,1, 378 &D_scalar,1,1,0, 379 basis,1,numnodes,0, 380 &Ke->values[0],1); 381 382 GetB(B,element,dim,xyz_list,gauss); 383 GetBprime(Bprime,element,dim,xyz_list,gauss); 384 385 dvxdx=dvx[0]; 386 dvydy=dvy[1]; 387 if(dim==3) dvzdz=dvz[2]; 388 D_scalar=dt*gauss->weight*Jdet; 389 390 D[0*dim+0]=D_scalar*dvxdx; 391 D[1*dim+1]=D_scalar*dvydy; 392 if(dim==3) D[2*dim+2]=D_scalar*dvzdz; 393 394 TripleMultiply(B,dim,numnodes,1, 395 D,dim,dim,0, 396 B,dim,numnodes,0, 397 &Ke->values[0],1); 398 399 D[0*dim+0]=D_scalar*vx; 400 D[1*dim+1]=D_scalar*vy; 401 if(dim==3) D[2*dim+2]=D_scalar*vz; 402 403 TripleMultiply(B,dim,numnodes,1, 404 D,dim,dim,0, 405 Bprime,dim,numnodes,0, 406 &Ke->values[0],1); 407 408 if(stabilization==2){ 409 if(dim==3){ 410 vel=sqrt(vx*vx+vy*vy+vz*vz)+1.e-8; 411 D[0*dim+0]=h/(2.0*vel)*vx*vx; 412 D[1*dim+0]=h/(2.0*vel)*vy*vx; 413 D[2*dim+0]=h/(2.0*vel)*vz*vx; 414 D[0*dim+1]=h/(2.0*vel)*vx*vy; 415 D[1*dim+1]=h/(2.0*vel)*vy*vy; 416 D[2*dim+1]=h/(2.0*vel)*vy*vz; 417 D[0*dim+2]=h/(2.0*vel)*vx*vz; 418 D[1*dim+2]=h/(2.0*vel)*vy*vz; 419 D[2*dim+2]=h/(2.0*vel)*vz*vz; 420 } 421 else{ 422 /*Streamline upwinding*/ 423 vel=sqrt(vx*vx+vy*vy)+1.e-8; 424 D[0*dim+0]=h/(2.0*vel)*vx*vx; 425 D[1*dim+0]=h/(2.0*vel)*vy*vx; 426 D[0*dim+1]=h/(2.0*vel)*vx*vy; 427 D[1*dim+1]=h/(2.0*vel)*vy*vy; 428 } 429 } 430 else if(stabilization==1){ 431 if(dim==2){ 432 vx_input->GetInputAverage(&vx); 433 vy_input->GetInputAverage(&vy); 434 D[0*dim+0]=h/2.0*fabs(vx); 435 D[1*dim+1]=h/2.0*fabs(vy); 436 } 437 else if(dim==3){ 438 element->ElementSizes(&hx,&hy,&hz); 439 vel=sqrt(vx*vx + vy*vy + vz*vz)+1.e-14; 440 h=sqrt( pow(hx*vx/vel,2) + pow(hy*vy/vel,2) + pow(hz*vz/vel,2)); 441 D[0*dim+0]=h/(2.*vel)*fabs(vx*vx); D[0*dim+1]=h/(2.*vel)*fabs(vx*vy); D[0*dim+2]=h/(2.*vel)*fabs(vx*vz); 442 D[1*dim+0]=h/(2.*vel)*fabs(vy*vx); D[1*dim+1]=h/(2.*vel)*fabs(vy*vy); D[1*dim+2]=h/(2.*vel)*fabs(vy*vz); 443 D[2*dim+0]=h/(2.*vel)*fabs(vz*vx); D[2*dim+1]=h/(2.*vel)*fabs(vz*vy); D[2*dim+2]=h/(2.*vel)*fabs(vz*vz); 444 } 445 } 446 if(stabilization==1 || stabilization==2){ 447 if(dim==2){ 448 D[0*dim+0]=D_scalar*D[0*dim+0]; 449 D[1*dim+0]=D_scalar*D[1*dim+0]; 450 D[0*dim+1]=D_scalar*D[0*dim+1]; 451 D[1*dim+1]=D_scalar*D[1*dim+1]; 452 } 453 else if(dim==3){ 454 D[0*dim+0]=D_scalar*D[0*dim+0]; 455 D[1*dim+0]=D_scalar*D[1*dim+0]; 456 D[2*dim+0]=D_scalar*D[2*dim+0]; 457 D[0*dim+1]=D_scalar*D[0*dim+1]; 458 D[1*dim+1]=D_scalar*D[1*dim+1]; 459 D[2*dim+1]=D_scalar*D[2*dim+1]; 460 D[0*dim+2]=D_scalar*D[0*dim+2]; 461 D[1*dim+2]=D_scalar*D[1*dim+2]; 462 D[2*dim+2]=D_scalar*D[2*dim+2]; 463 } 464 TripleMultiply(Bprime,dim,numnodes,1, 465 D,dim,dim,0, 466 Bprime,dim,numnodes,0, 467 &Ke->values[0],1); 468 } 469 470 } 471 472 /*Clean up and return*/ 473 xDelete<IssmDouble>(xyz_list); 474 xDelete<IssmDouble>(basis); 475 xDelete<IssmDouble>(B); 476 xDelete<IssmDouble>(Bprime); 477 xDelete<IssmDouble>(D); 478 delete gauss; 479 return Ke; 480 }/*}}}*/ 481 ElementVector* DamageEvolutionAnalysis::CreatePVector(Element* element){/*{{{*/ 482 483 /* Check if ice in element */ 484 if(!element->IsIceInElement()) return NULL; 485 486 /*Intermediaries*/ 487 int domaintype,damagelaw; 488 IssmDouble Jdet,dt; 489 IssmDouble f,damage; 490 IssmDouble* xyz_list = NULL; 491 /*Get element*/ 492 element->FindParam(&domaintype,DomainTypeEnum); 493 494 /*Fetch number of nodes and dof for this finite element*/ 495 int numnodes = element->GetNumberOfNodes(); 496 497 /*Initialize Element vector and other vectors*/ 498 ElementVector* pe = element->NewElementVector(); 499 IssmDouble* basis = xNew<IssmDouble>(numnodes); 500 501 /*Retrieve all inputs and parameters*/ 502 element->GetVerticesCoordinates(&xyz_list); 503 element->FindParam(&dt,TimesteppingTimeStepEnum); 504 element->FindParam(&damagelaw,DamageLawEnum); 505 switch(damagelaw){ 506 case 1: 507 this->CreateDamageFInputPralong(element); 508 break; 509 case 2: 510 this->CreateDamageFInputPralong(element); 511 break; 512 case 3: 513 this->CreateDamageFInputExp(element); 514 break; 515 default: 516 _error_("not implemented yet"); 517 } 518 519 Input* damaged_input = NULL; 520 Input* damagef_input = element->GetInput(DamageFEnum); _assert_(damagef_input); 521 if(domaintype==Domain2DhorizontalEnum){ 522 damaged_input = element->GetInput(DamageDbarEnum); _assert_(damaged_input); 523 } 524 else{ 525 damaged_input = element->GetInput(DamageDEnum); _assert_(damaged_input); 526 } 527 528 529 /* Start looping on the number of gaussian points: */ 530 Gauss* gauss=element->NewGauss(2); 531 for(int ig=gauss->begin();ig<gauss->end();ig++){ 532 gauss->GaussPoint(ig); 533 534 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 535 element->NodalFunctions(basis,gauss); 536 537 damaged_input->GetInputValue(&damage,gauss); 538 damagef_input->GetInputValue(&f,gauss); 539 540 for(int i=0;i<numnodes;i++){ 541 pe->values[i]+=Jdet*gauss->weight*(damage+dt*f)*basis[i]; 542 } 543 } 544 /*Clean up and return*/ 545 xDelete<IssmDouble>(xyz_list); 546 xDelete<IssmDouble>(basis); 547 delete gauss; 548 return pe; 549 }/*}}}*/ 550 void DamageEvolutionAnalysis::GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 551 /*Compute B matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2. 552 * For node i, Bi can be expressed in the actual coordinate system 553 * by: 554 * Bi=[ N ] 555 * [ N ] 556 * where N is the finiteelement function for node i. 557 * 558 * We assume B_prog has been allocated already, of size: 2x(NDOF1*numnodes) 559 */ 560 561 /*Fetch number of nodes for this finite element*/ 562 int numnodes = element->GetNumberOfNodes(); 563 564 /*Get nodal functions*/ 565 IssmDouble* basis=xNew<IssmDouble>(numnodes); 566 element->NodalFunctions(basis,gauss); 567 568 /*Build B: */ 569 for(int i=0;i<numnodes;i++){ 570 for(int j=0;j<dim;j++){ 571 B[numnodes*j+i] = basis[i]; 572 } 573 } 574 575 /*Clean-up*/ 576 xDelete<IssmDouble>(basis); 577 }/*}}}*/ 578 void DamageEvolutionAnalysis::GetBprime(IssmDouble* Bprime,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 579 /*Compute B' matrix. B'=[B1' B2' B3'] where Bi' is of size 3*NDOF2. 580 * For node i, Bi' can be expressed in the actual coordinate system 581 * by: 582 * Bi_prime=[ dN/dx ] 583 * [ dN/dy ] 584 * where N is the finiteelement function for node i. 585 * 586 * We assume B' has been allocated already, of size: 3x(NDOF2*numnodes) 587 */ 588 589 /*Fetch number of nodes for this finite element*/ 590 int numnodes = element->GetNumberOfNodes(); 591 592 /*Get nodal functions derivatives*/ 593 IssmDouble* dbasis=xNew<IssmDouble>(dim*numnodes); 594 element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss); 595 596 /*Build B': */ 597 for(int i=0;i<numnodes;i++){ 598 for(int j=0;j<dim;j++){ 599 Bprime[numnodes*j+i] = dbasis[j*numnodes+i]; 600 } 601 } 602 603 /*Clean-up*/ 604 xDelete<IssmDouble>(dbasis); 605 606 }/*}}}*/ 607 void DamageEvolutionAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 608 _error_("not implemented yet"); 609 }/*}}}*/ 610 void DamageEvolutionAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 611 _error_("Not implemented yet"); 612 }/*}}}*/ 613 void DamageEvolutionAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 614 615 int domaintype; 616 IssmDouble max_damage; 617 int *doflist = NULL; 618 619 element->FindParam(&domaintype,DomainTypeEnum); 620 621 /*Fetch number of nodes and dof for this finite element*/ 622 int numnodes = element->GetNumberOfNodes(); 623 624 /*Fetch dof list and allocate solution vector*/ 625 element->GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 626 IssmDouble* newdamage = xNew<IssmDouble>(numnodes); 627 628 /*Get user-supplied max_damage: */ 629 element->FindParam(&max_damage,DamageMaxDamageEnum); 630 631 /*Use the dof list to index into the solution vector: */ 632 for(int i=0;i<numnodes;i++){ 633 newdamage[i]=solution[doflist[i]]; 634 /*Check solution*/ 635 if(xIsNan<IssmDouble>(newdamage[i])) _error_("NaN found in solution vector"); 636 /*Enforce D < max_damage and D > 0 */ 637 if(newdamage[i]>max_damage) newdamage[i]=max_damage; 638 else if(newdamage[i]<0.) newdamage[i]=0.; 639 } 640 641 /*Get all inputs and parameters*/ 642 if(domaintype==Domain2DhorizontalEnum){ 643 element->AddInput(DamageDbarEnum,newdamage,element->GetElementType()); 644 } 645 else{ 646 element->AddInput(DamageDEnum,newdamage,element->GetElementType()); 647 } 648 649 /*Free ressources:*/ 650 xDelete<IssmDouble>(newdamage); 651 xDelete<int>(doflist); 652 }/*}}}*/ 653 void DamageEvolutionAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 654 /*Default, do nothing*/ 655 bool islevelset; 656 femmodel->parameters->FindParam(&islevelset,TransientIslevelsetEnum); 657 if(islevelset){ 658 SetActiveNodesLSMx(femmodel); 659 } 660 return; 661 }/*}}}*/ -
issm/trunk/src/c/analyses/DamageEvolutionAnalysis.h
r18301 r19105 13 13 public: 14 14 /*Model processing*/ 15 int DofsPerNode(int** doflist,int domaintype,int approximation);16 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum);17 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type);18 void CreateNodes(Nodes* nodes,IoModel* iomodel);19 15 void CreateConstraints(Constraints* constraints,IoModel* iomodel); 20 16 void CreateLoads(Loads* loads, IoModel* iomodel); 17 void CreateNodes(Nodes* nodes,IoModel* iomodel); 18 int DofsPerNode(int** doflist,int domaintype,int approximation); 19 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 20 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum); 21 21 22 22 /*Finite element Analysis*/ 23 23 void Core(FemModel* femmodel); 24 void CreateDamageFInputExp(Element* element); 25 void CreateDamageFInputPralong(Element* element); 24 26 ElementVector* CreateDVector(Element* element); 25 27 ElementMatrix* CreateJacobianMatrix(Element* element); 26 28 ElementMatrix* CreateKMatrix(Element* element); 27 29 ElementVector* CreatePVector(Element* element); 28 void GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 29 void GetBprime(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 30 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 31 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 32 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 33 void UpdateConstraints(FemModel* femmodel); 34 35 /*Intermediaries*/ 36 void CreateDamageFInputPralong(Element* element); 37 void CreateDamageFInputExp(Element* element); 30 void GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 31 void GetBprime(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 32 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 33 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 34 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 35 void UpdateConstraints(FemModel* femmodel); 38 36 }; 39 37 #endif -
issm/trunk/src/c/analyses/DepthAverageAnalysis.cpp
r18301 r19105 6 6 7 7 /*Model processing*/ 8 void DepthAverageAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 9 }/*}}}*/ 10 void DepthAverageAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 11 }/*}}}*/ 12 void DepthAverageAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 13 14 ::CreateNodes(nodes,iomodel,DepthAverageAnalysisEnum,P1Enum); 15 16 }/*}}}*/ 8 17 int DepthAverageAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/ 9 18 return 1; 10 }/*}}}*/11 void DepthAverageAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/12 19 }/*}}}*/ 13 20 void DepthAverageAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ … … 26 33 } 27 34 }/*}}}*/ 28 void DepthAverageAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 29 30 ::CreateNodes(nodes,iomodel,DepthAverageAnalysisEnum,P1Enum); 31 32 }/*}}}*/ 33 void DepthAverageAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 34 }/*}}}*/ 35 void DepthAverageAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 35 void DepthAverageAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 36 36 }/*}}}*/ 37 37 … … 137 137 return pe; 138 138 }/*}}}*/ 139 void DepthAverageAnalysis::GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/139 void DepthAverageAnalysis::GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 140 140 /* Compute B matrix. B=[dh1/dz dh2/dz dh3/dz dh4/dz dh5/dz dh6/dz]; 141 141 where hi is the interpolation function for node i.*/ … … 157 157 } 158 158 /*}}}*/ 159 void DepthAverageAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/159 void DepthAverageAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 160 160 _error_("not implemented yet"); 161 161 }/*}}}*/ 162 void DepthAverageAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/162 void DepthAverageAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 163 163 _error_("Not implemented yet"); 164 164 }/*}}}*/ 165 void DepthAverageAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/165 void DepthAverageAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 166 166 167 167 int inputenum; … … 169 169 element->InputUpdateFromSolutionOneDof(solution,inputenum); 170 170 }/*}}}*/ 171 void DepthAverageAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/171 void DepthAverageAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 172 172 /*Default, do nothing*/ 173 173 return; -
issm/trunk/src/c/analyses/DepthAverageAnalysis.h
r18301 r19105 13 13 public: 14 14 /*Model processing*/ 15 int DofsPerNode(int** doflist,int domaintype,int approximation);16 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum);17 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type);18 void CreateNodes(Nodes* nodes,IoModel* iomodel);19 15 void CreateConstraints(Constraints* constraints,IoModel* iomodel); 20 16 void CreateLoads(Loads* loads, IoModel* iomodel); 17 void CreateNodes(Nodes* nodes,IoModel* iomodel); 18 int DofsPerNode(int** doflist,int domaintype,int approximation); 19 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 20 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum); 21 21 22 22 /*Finite element Analysis*/ … … 26 26 ElementMatrix* CreateKMatrix(Element* element); 27 27 ElementVector* CreatePVector(Element* element); 28 void GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss);29 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element);30 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index);31 void InputUpdateFromSolution(IssmDouble* solution,Element* element);32 void UpdateConstraints(FemModel* femmodel);28 void GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 29 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 30 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 31 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 32 void UpdateConstraints(FemModel* femmodel); 33 33 }; 34 34 #endif -
issm/trunk/src/c/analyses/EnthalpyAnalysis.cpp
r18301 r19105 4 4 #include "../shared/shared.h" 5 5 #include "../modules/modules.h" 6 #include "../solutionsequences/solutionsequences.h" 6 7 7 8 /*Model processing*/ 9 void EnthalpyAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 10 11 /*Intermediary*/ 12 int count; 13 int M,N; 14 bool spcpresent = false; 15 IssmDouble heatcapacity; 16 IssmDouble referencetemperature; 17 18 /*Output*/ 19 IssmDouble *spcvector = NULL; 20 IssmDouble* times=NULL; 21 IssmDouble* values=NULL; 22 23 /*Fetch parameters: */ 24 iomodel->Constant(&heatcapacity,MaterialsHeatcapacityEnum); 25 iomodel->Constant(&referencetemperature,ConstantsReferencetemperatureEnum); 26 27 /*return if 2d mesh*/ 28 if(iomodel->domaintype==Domain2DhorizontalEnum) return; 29 30 /*Fetch data: */ 31 iomodel->FetchData(&spcvector,&M,&N,ThermalSpctemperatureEnum); 32 33 //FIX ME: SHOULD USE IOMODELCREATECONSTRAINTS 34 /*Transient or static?:*/ 35 if(M==iomodel->numberofvertices){ 36 /*static: just create Constraints objects*/ 37 count=0; 38 39 for(int i=0;i<iomodel->numberofvertices;i++){ 40 /*keep only this partition's nodes:*/ 41 if((iomodel->my_vertices[i])){ 42 43 if (!xIsNan<IssmDouble>(spcvector[i])){ 44 45 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,0,heatcapacity*(spcvector[i]-referencetemperature),EnthalpyAnalysisEnum)); 46 count++; 47 48 } 49 } 50 } 51 } 52 else if (M==(iomodel->numberofvertices+1)){ 53 /*transient: create transient SpcTransient objects. Same logic, except we need to retrieve 54 * various times and values to initialize an SpcTransient object: */ 55 count=0; 56 57 /*figure out times: */ 58 times=xNew<IssmDouble>(N); 59 for(int j=0;j<N;j++){ 60 times[j]=spcvector[(M-1)*N+j]; 61 } 62 63 /*Create constraints from x,y,z: */ 64 for(int i=0;i<iomodel->numberofvertices;i++){ 65 66 /*keep only this partition's nodes:*/ 67 if((iomodel->my_vertices[i])){ 68 69 /*figure out times and values: */ 70 values=xNew<IssmDouble>(N); 71 spcpresent=false; 72 for(int j=0;j<N;j++){ 73 values[j]=heatcapacity*(spcvector[i*N+j]-referencetemperature); 74 if(!xIsNan<IssmDouble>(values[j]))spcpresent=true; //NaN means no spc by default 75 } 76 77 if(spcpresent){ 78 constraints->AddObject(new SpcTransient(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,0,N,times,values,EnthalpyAnalysisEnum)); 79 count++; 80 } 81 xDelete<IssmDouble>(values); 82 } 83 } 84 } 85 else{ 86 _error_("Size of field " << EnumToStringx(ThermalSpctemperatureEnum) << " not supported"); 87 } 88 89 /*Free ressources:*/ 90 iomodel->DeleteData(spcvector,ThermalSpctemperatureEnum); 91 xDelete<IssmDouble>(times); 92 xDelete<IssmDouble>(values); 93 }/*}}}*/ 94 void EnthalpyAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 95 96 /*No loads */ 97 }/*}}}*/ 98 void EnthalpyAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 99 100 if(iomodel->domaintype==Domain3DEnum) iomodel->FetchData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 101 ::CreateNodes(nodes,iomodel,EnthalpyAnalysisEnum,P1Enum); 102 iomodel->DeleteData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 103 }/*}}}*/ 8 104 int EnthalpyAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/ 9 105 return 1; 10 }/*}}}*/11 void EnthalpyAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/12 13 int numoutputs;14 char** requestedoutputs = NULL;15 16 parameters->AddObject(iomodel->CopyConstantObject(ThermalStabilizationEnum));17 parameters->AddObject(iomodel->CopyConstantObject(ThermalIsenthalpyEnum));18 parameters->AddObject(iomodel->CopyConstantObject(ThermalIsdynamicbasalspcEnum));19 parameters->AddObject(iomodel->CopyConstantObject(FrictionLawEnum));20 21 iomodel->FetchData(&requestedoutputs,&numoutputs,ThermalRequestedOutputsEnum);22 parameters->AddObject(new IntParam(ThermalNumRequestedOutputsEnum,numoutputs));23 if(numoutputs)parameters->AddObject(new StringArrayParam(ThermalRequestedOutputsEnum,requestedoutputs,numoutputs));24 iomodel->DeleteData(&requestedoutputs,numoutputs,ThermalRequestedOutputsEnum);25 106 }/*}}}*/ 26 107 void EnthalpyAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ … … 62 143 iomodel->FetchDataToInput(elements,MeshVertexonsurfaceEnum); 63 144 } 64 iomodel->FetchDataToInput(elements,FlowequationElementEquationEnum);65 145 iomodel->FetchDataToInput(elements,MaterialsRheologyBEnum); 66 146 iomodel->FetchDataToInput(elements,MaterialsRheologyNEnum); … … 94 174 iomodel->FetchDataToInput(elements,FrictionMEnum); 95 175 break; 176 case 3: 177 iomodel->FetchDataToInput(elements,FrictionCEnum); 178 iomodel->FetchDataToInput(elements,FrictionAsEnum); 179 iomodel->FetchDataToInput(elements,FrictionQEnum); 180 iomodel->FetchDataToInput(elements,FrictionEffectivePressureEnum); 181 break; 182 case 4: 183 iomodel->FetchDataToInput(elements,FrictionCoefficientEnum); 184 iomodel->FetchDataToInput(elements,FrictionPEnum); 185 iomodel->FetchDataToInput(elements,FrictionQEnum); 186 iomodel->FetchDataToInput(elements,PressureEnum); 187 iomodel->FetchDataToInput(elements,TemperatureEnum); 188 break; 189 case 5: 190 iomodel->FetchDataToInput(elements,FrictionCoefficientEnum); 191 iomodel->FetchDataToInput(elements,FrictionPEnum); 192 iomodel->FetchDataToInput(elements,FrictionQEnum); 193 iomodel->FetchDataToInput(elements,FrictionWaterLayerEnum); 194 break; 195 case 6: 196 iomodel->FetchDataToInput(elements,FrictionCEnum); 197 iomodel->FetchDataToInput(elements,FrictionMEnum); 198 iomodel->FetchDataToInput(elements,PressureEnum); 199 iomodel->FetchDataToInput(elements,TemperatureEnum); 200 break; 96 201 default: 97 202 _error_("not supported"); … … 100 205 iomodel->DeleteData(3,TemperatureEnum,WaterfractionEnum,PressureEnum); 101 206 }/*}}}*/ 102 void EnthalpyAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 103 104 if(iomodel->domaintype==Domain3DEnum) iomodel->FetchData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 105 ::CreateNodes(nodes,iomodel,EnthalpyAnalysisEnum,P1Enum); 106 iomodel->DeleteData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 107 }/*}}}*/ 108 void EnthalpyAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 207 void EnthalpyAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 208 209 int numoutputs; 210 char** requestedoutputs = NULL; 211 212 parameters->AddObject(iomodel->CopyConstantObject(ThermalStabilizationEnum)); 213 parameters->AddObject(iomodel->CopyConstantObject(ThermalMaxiterEnum)); 214 parameters->AddObject(iomodel->CopyConstantObject(ThermalReltolEnum)); 215 parameters->AddObject(iomodel->CopyConstantObject(ThermalIsenthalpyEnum)); 216 parameters->AddObject(iomodel->CopyConstantObject(ThermalIsdynamicbasalspcEnum)); 217 parameters->AddObject(iomodel->CopyConstantObject(FrictionLawEnum)); 218 219 iomodel->FetchData(&requestedoutputs,&numoutputs,ThermalRequestedOutputsEnum); 220 parameters->AddObject(new IntParam(ThermalNumRequestedOutputsEnum,numoutputs)); 221 if(numoutputs)parameters->AddObject(new StringArrayParam(ThermalRequestedOutputsEnum,requestedoutputs,numoutputs)); 222 iomodel->DeleteData(&requestedoutputs,numoutputs,ThermalRequestedOutputsEnum); 223 224 /*Deal with friction parameters*/ 225 int frictionlaw; 226 iomodel->Constant(&frictionlaw,FrictionLawEnum); 227 if(frictionlaw==4 || frictionlaw==6) parameters->AddObject(iomodel->CopyConstantObject(FrictionGammaEnum)); 228 }/*}}}*/ 229 230 /*Finite Element Analysis*/ 231 void EnthalpyAnalysis::ApplyBasalConstraints(IssmDouble* serial_spc,Element* element){/*{{{*/ 232 233 /* Check if ice in element */ 234 if(!element->IsIceInElement()) return; 235 236 /* Only update Constraints at the base of grounded ice*/ 237 if(!(element->IsOnBase()) || element->IsFloating()) return; 109 238 110 239 /*Intermediary*/ 111 int count; 112 int M,N; 113 bool spcpresent = false; 114 IssmDouble heatcapacity; 115 IssmDouble referencetemperature; 116 117 /*Output*/ 118 IssmDouble *spcvector = NULL; 119 IssmDouble* times=NULL; 120 IssmDouble* values=NULL; 121 122 /*Fetch parameters: */ 123 iomodel->Constant(&heatcapacity,MaterialsHeatcapacityEnum); 124 iomodel->Constant(&referencetemperature,ConstantsReferencetemperatureEnum); 125 126 /*return if 2d mesh*/ 127 if(iomodel->domaintype==Domain2DhorizontalEnum) return; 128 129 /*Fetch data: */ 130 iomodel->FetchData(&spcvector,&M,&N,ThermalSpctemperatureEnum); 131 132 //FIX ME: SHOULD USE IOMODELCREATECONSTRAINTS 133 /*Transient or static?:*/ 134 if(M==iomodel->numberofvertices){ 135 /*static: just create Constraints objects*/ 136 count=0; 137 138 for(int i=0;i<iomodel->numberofvertices;i++){ 139 /*keep only this partition's nodes:*/ 140 if((iomodel->my_vertices[i])){ 141 142 if (!xIsNan<IssmDouble>(spcvector[i])){ 143 144 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,0,heatcapacity*(spcvector[i]-referencetemperature),EnthalpyAnalysisEnum)); 145 count++; 146 147 } 240 bool isdynamicbasalspc; 241 int numindices; 242 int *indices = NULL; 243 Node* node = NULL; 244 IssmDouble pressure; 245 246 /*Check wether dynamic basal boundary conditions are activated */ 247 element->FindParam(&isdynamicbasalspc,ThermalIsdynamicbasalspcEnum); 248 if(!isdynamicbasalspc) return; 249 250 /*Get parameters and inputs: */ 251 Input* pressure_input = element->GetInput(PressureEnum); _assert_(pressure_input); 252 253 /*Fetch indices of basal & surface nodes for this finite element*/ 254 Penta *penta = (Penta *) element; // TODO: add Basal-/SurfaceNodeIndices to element.h, and change this to Element* 255 penta->BasalNodeIndices(&numindices,&indices,element->GetElementType()); 256 257 GaussPenta* gauss=new GaussPenta(); 258 for(int i=0;i<numindices;i++){ 259 gauss->GaussNode(element->GetElementType(),indices[i]); 260 261 pressure_input->GetInputValue(&pressure,gauss); 262 263 /*apply or release spc*/ 264 node=element->GetNode(indices[i]); 265 if(serial_spc[node->Sid()]==1.){ 266 pressure_input->GetInputValue(&pressure, gauss); 267 node->ApplyConstraint(0,PureIceEnthalpy(element,pressure)); 268 } 269 else 270 node->DofInFSet(0); 271 } 272 273 /*Free ressources:*/ 274 xDelete<int>(indices); 275 delete gauss; 276 }/*}}}*/ 277 void EnthalpyAnalysis::ComputeBasalMeltingrate(FemModel* femmodel){/*{{{*/ 278 /*Compute basal melting rates: */ 279 for(int i=0;i<femmodel->elements->Size();i++){ 280 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 281 ComputeBasalMeltingrate(element); 282 } 283 }/*}}}*/ 284 void EnthalpyAnalysis::ComputeBasalMeltingrate(Element* element){/*{{{*/ 285 /*Calculate the basal melt rates of the enthalpy model after Aschwanden 2012*/ 286 /* melting rate is positive when melting, negative when refreezing*/ 287 288 /* Check if ice in element */ 289 if(!element->IsIceInElement()) return; 290 291 /* Only compute melt rates at the base of grounded ice*/ 292 if(!element->IsOnBase() || element->IsFloating()) return; 293 294 /* Intermediaries */ 295 bool converged; 296 const int dim=3; 297 int i,is,state; 298 int vertexdown,vertexup,numvertices,numsegments; 299 int enthalpy_enum; 300 IssmDouble vec_heatflux[dim],normal_base[dim],d1enthalpy[dim],d1pressure[dim]; 301 IssmDouble basalfriction,alpha2,geothermalflux,heatflux; 302 IssmDouble dt,yts; 303 IssmDouble melting_overshoot,lambda; 304 IssmDouble vx,vy,vz; 305 IssmDouble *xyz_list = NULL; 306 IssmDouble *xyz_list_base = NULL; 307 int *pairindices = NULL; 308 309 /*Fetch parameters*/ 310 element->GetVerticesCoordinates(&xyz_list); 311 element->GetVerticesCoordinatesBase(&xyz_list_base); 312 element->GetInputValue(&converged,ConvergedEnum); 313 element->FindParam(&dt,TimesteppingTimeStepEnum); 314 element->FindParam(&yts, ConstantsYtsEnum); 315 316 if(dt==0. && !converged) enthalpy_enum=EnthalpyPicardEnum; 317 else enthalpy_enum=EnthalpyEnum; 318 319 IssmDouble latentheat = element->GetMaterialParameter(MaterialsLatentheatEnum); 320 IssmDouble rho_ice = element->GetMaterialParameter(MaterialsRhoIceEnum); 321 IssmDouble rho_water = element->GetMaterialParameter(MaterialsRhoFreshwaterEnum); 322 IssmDouble beta = element->GetMaterialParameter(MaterialsBetaEnum); 323 IssmDouble kappa = EnthalpyDiffusionParameterVolume(element,enthalpy_enum); _assert_(kappa>=0.); 324 IssmDouble kappa_mix; 325 326 /*retrieve inputs*/ 327 Input* enthalpy_input = element->GetInput(enthalpy_enum); _assert_(enthalpy_input); 328 Input* pressure_input = element->GetInput(PressureEnum); _assert_(pressure_input); 329 Input* geothermalflux_input = element->GetInput(BasalforcingsGeothermalfluxEnum); _assert_(geothermalflux_input); 330 Input* vx_input = element->GetInput(VxEnum); _assert_(vx_input); 331 Input* vy_input = element->GetInput(VyEnum); _assert_(vy_input); 332 Input* vz_input = element->GetInput(VzEnum); _assert_(vz_input); 333 334 /*Build friction element, needed later: */ 335 Friction* friction=new Friction(element,dim); 336 337 /******** MELTING RATES ************************************//*{{{*/ 338 element->NormalBase(&normal_base[0],xyz_list_base); 339 element->VerticalSegmentIndices(&pairindices,&numsegments); 340 IssmDouble* meltingrate_enthalpy = xNew<IssmDouble>(numsegments); 341 IssmDouble* heating = xNew<IssmDouble>(numsegments); 342 343 numvertices=element->GetNumberOfVertices(); 344 IssmDouble* enthalpies = xNew<IssmDouble>(numvertices); 345 IssmDouble* pressures = xNew<IssmDouble>(numvertices); 346 IssmDouble* watercolumns = xNew<IssmDouble>(numvertices); 347 IssmDouble* basalmeltingrates = xNew<IssmDouble>(numvertices); 348 element->GetInputListOnVertices(enthalpies,enthalpy_enum); 349 element->GetInputListOnVertices(pressures,PressureEnum); 350 element->GetInputListOnVertices(watercolumns,WatercolumnEnum); 351 element->GetInputListOnVertices(basalmeltingrates,BasalforcingsGroundediceMeltingRateEnum); 352 353 Gauss* gauss=element->NewGauss(); 354 for(is=0;is<numsegments;is++){ 355 vertexdown = pairindices[is*2+0]; 356 vertexup = pairindices[is*2+1]; 357 gauss->GaussVertex(vertexdown); 358 359 state=GetThermalBasalCondition(element, enthalpies[vertexdown], enthalpies[vertexup], pressures[vertexdown], pressures[vertexup], watercolumns[vertexdown], basalmeltingrates[vertexdown]); 360 switch (state) { 361 case 0: 362 // cold, dry base: apply basal surface forcing 363 for(i=0;i<3;i++) vec_heatflux[i]=0.; 364 break; 365 case 1: case 2: case 3: 366 // case 1 : cold, wet base: keep at pressure melting point 367 // case 2: temperate, thin refreezing base: release spc 368 // case 3: temperate, thin melting base: set spc 369 enthalpy_input->GetInputDerivativeValue(&d1enthalpy[0],xyz_list,gauss); 370 for(i=0;i<3;i++) vec_heatflux[i]=-kappa*d1enthalpy[i]; 371 break; 372 case 4: 373 // temperate, thick melting base: set grad H*n=0 374 kappa_mix=GetWetIceConductivity(element, enthalpies[vertexdown], pressures[vertexdown]); 375 pressure_input->GetInputDerivativeValue(&d1pressure[0],xyz_list,gauss); 376 for(i=0;i<3;i++) vec_heatflux[i]=kappa_mix*beta*d1pressure[i]; 377 break; 378 default: 379 _printf0_(" unknown thermal basal state found!"); 380 } 381 if(state==0) meltingrate_enthalpy[is]=0.; 382 else{ 383 /*heat flux along normal*/ 384 heatflux=0.; 385 for(i=0;i<3;i++) heatflux+=(vec_heatflux[i])*normal_base[i]; 386 387 /*basal friction*/ 388 friction->GetAlpha2(&alpha2,gauss); 389 vx_input->GetInputValue(&vx,gauss); vy_input->GetInputValue(&vy,gauss); vz_input->GetInputValue(&vz,gauss); 390 basalfriction=alpha2*(vx*vx + vy*vy + vz*vz); 391 geothermalflux_input->GetInputValue(&geothermalflux,gauss); 392 /* -Mb= Fb-(q-q_geo)/((1-w)*L*rho), and (1-w)*rho=rho_ice, cf Aschwanden 2012, eqs.1, 2, 66*/ 393 heating[is]=(heatflux+basalfriction+geothermalflux); 394 meltingrate_enthalpy[is]=heating[is]/(latentheat*rho_ice); // m/s water equivalent 395 } 396 }/*}}}*/ 397 398 /******** UPDATE MELTINGRATES AND WATERCOLUMN **************//*{{{*/ 399 for(is=0;is<numsegments;is++){ 400 vertexdown = pairindices[is*2+0]; 401 vertexup = pairindices[is*2+1]; 402 if(dt!=0.){ 403 if(watercolumns[vertexdown]+meltingrate_enthalpy[is]*dt<0.){ // prevent too much freeze on 404 lambda = -watercolumns[vertexdown]/(dt*meltingrate_enthalpy[is]); _assert_(lambda>=0.); _assert_(lambda<1.); 405 watercolumns[vertexdown]=0.; 406 basalmeltingrates[vertexdown]=lambda*meltingrate_enthalpy[is]; // restrict freeze on only to size of watercolumn 407 enthalpies[vertexdown]+=(1.-lambda)*dt/yts*meltingrate_enthalpy[is]*latentheat*rho_ice; // use rest of energy to cool down base: dE=L*m, m=(1-lambda)*meltingrate*rho_ice 148 408 } 149 } 150 } 151 else if (M==(iomodel->numberofvertices+1)){ 152 /*transient: create transient SpcTransient objects. Same logic, except we need to retrieve 153 * various times and values to initialize an SpcTransient object: */ 154 count=0; 155 156 /*figure out times: */ 157 times=xNew<IssmDouble>(N); 158 for(int j=0;j<N;j++){ 159 times[j]=spcvector[(M-1)*N+j]; 160 } 161 162 /*Create constraints from x,y,z: */ 163 for(int i=0;i<iomodel->numberofvertices;i++){ 164 165 /*keep only this partition's nodes:*/ 166 if((iomodel->my_vertices[i])){ 167 168 /*figure out times and values: */ 169 values=xNew<IssmDouble>(N); 170 spcpresent=false; 171 for(int j=0;j<N;j++){ 172 values[j]=heatcapacity*(spcvector[i*N+j]-referencetemperature); 173 if(!xIsNan<IssmDouble>(values[j]))spcpresent=true; //NaN means no spc by default 174 } 175 176 if(spcpresent){ 177 constraints->AddObject(new SpcTransient(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,0,N,times,values,EnthalpyAnalysisEnum)); 178 count++; 179 } 180 xDelete<IssmDouble>(values); 409 else{ 410 basalmeltingrates[vertexdown]=meltingrate_enthalpy[is]; 411 watercolumns[vertexdown]+=dt*meltingrate_enthalpy[is]; 181 412 } 182 413 } 183 } 184 else{ 185 _error_("Size of field " << EnumToStringx(ThermalSpctemperatureEnum) << " not supported"); 186 } 187 188 /*Free ressources:*/ 189 iomodel->DeleteData(spcvector,ThermalSpctemperatureEnum); 190 xDelete<IssmDouble>(times); 191 xDelete<IssmDouble>(values); 192 }/*}}}*/ 193 void EnthalpyAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 194 195 /*No loads */ 196 }/*}}}*/ 197 198 /*Finite Element Analysis*/ 199 void EnthalpyAnalysis::Core(FemModel* femmodel){/*{{{*/ 200 _error_("not implemented"); 414 else{ 415 basalmeltingrates[vertexdown]=meltingrate_enthalpy[is]; 416 if(watercolumns[vertexdown]+meltingrate_enthalpy[is]<0.) 417 watercolumns[vertexdown]=0.; 418 else 419 watercolumns[vertexdown]+=meltingrate_enthalpy[is]; 420 } 421 basalmeltingrates[vertexdown]*=rho_water/rho_ice; // convert meltingrate from water to ice equivalent 422 _assert_(watercolumns[vertexdown]>=0.); 423 }/*}}}*/ 424 425 /*feed updated variables back into model*/ 426 if(dt!=0.){ 427 element->AddInput(enthalpy_enum,enthalpies,P1Enum); //TODO: distinguis for steadystate and transient run 428 element->AddInput(WatercolumnEnum,watercolumns,P1Enum); 429 } 430 element->AddInput(BasalforcingsGroundediceMeltingRateEnum,basalmeltingrates,P1Enum); 431 432 /*Clean up and return*/ 433 delete gauss; 434 delete friction; 435 xDelete<int>(pairindices); 436 xDelete<IssmDouble>(enthalpies); 437 xDelete<IssmDouble>(pressures); 438 xDelete<IssmDouble>(watercolumns); 439 xDelete<IssmDouble>(basalmeltingrates); 440 xDelete<IssmDouble>(meltingrate_enthalpy); 441 xDelete<IssmDouble>(heating); 442 xDelete<IssmDouble>(xyz_list); 443 xDelete<IssmDouble>(xyz_list_base); 444 }/*}}}*/ 445 void EnthalpyAnalysis::Core(FemModel* femmodel){/*{{{*/ 446 if(VerboseSolution()) _printf0_(" computing enthalpy\n"); 447 femmodel->SetCurrentConfiguration(EnthalpyAnalysisEnum); 448 solutionsequence_thermal_nonlinear(femmodel); 449 450 /*transfer enthalpy to enthalpy picard for the next step: */ 451 InputDuplicatex(femmodel,EnthalpyEnum,EnthalpyPicardEnum); 452 453 IssmDouble dt; 454 femmodel->parameters->FindParam(&dt,TimesteppingTimeStepEnum); 455 if(dt==0.) ComputeBasalMeltingrate(femmodel); 456 else PostProcessing(femmodel); 457 201 458 }/*}}}*/ 202 459 ElementVector* EnthalpyAnalysis::CreateDVector(Element* element){/*{{{*/ … … 316 573 vel=sqrt(vx*vx + vy*vy + vz*vz)+1.e-14; 317 574 h=sqrt( pow(hx*vx/vel,2) + pow(hy*vy/vel,2) + pow(hz*vz/vel,2)); 318 K[0][0]=h/(2.*vel)* vx*vx; K[0][1]=h/(2.*vel)*vx*vy; K[0][2]=h/(2.*vel)*vx*vz;319 K[1][0]=h/(2.*vel)* vy*vx; K[1][1]=h/(2.*vel)*vy*vy; K[1][2]=h/(2.*vel)*vy*vz;320 K[2][0]=h/(2.*vel)* vz*vx; K[2][1]=h/(2.*vel)*vz*vy; K[2][2]=h/(2.*vel)*vz*vz;575 K[0][0]=h/(2.*vel)*fabs(vx*vx); K[0][1]=h/(2.*vel)*fabs(vx*vy); K[0][2]=h/(2.*vel)*fabs(vx*vz); 576 K[1][0]=h/(2.*vel)*fabs(vy*vx); K[1][1]=h/(2.*vel)*fabs(vy*vy); K[1][2]=h/(2.*vel)*fabs(vy*vz); 577 K[2][0]=h/(2.*vel)*fabs(vz*vx); K[2][1]=h/(2.*vel)*fabs(vz*vy); K[2][2]=h/(2.*vel)*fabs(vz*vz); 321 578 for(int i=0;i<3;i++) for(int j=0;j<3;j++) K[i][j] = D_scalar*K[i][j]; 322 579 … … 549 806 if(!element->IsOnBase() || element->IsFloating()) return NULL; 550 807 551 IssmDouble dt,Jdet,enthalpy,pressure,watercolumn,geothermalflux,vx,vy,vz; 552 IssmDouble enthalpyup,pressureup,alpha2,scalar,basalfriction,heatflux; 808 bool isdynamicbasalspc; 809 int i, state; 810 IssmDouble dt,Jdet,scalar; 811 IssmDouble enthalpy, enthalpyup, pressure, pressureup, watercolumn, meltingrate; 812 IssmDouble vx,vy,vz; 813 IssmDouble alpha2,basalfriction,geothermalflux,heatflux; 553 814 IssmDouble *xyz_list_base = NULL; 554 815 … … 563 824 element->GetVerticesCoordinatesBase(&xyz_list_base); 564 825 element->FindParam(&dt,TimesteppingTimeStepEnum); 826 element->FindParam(&isdynamicbasalspc,ThermalIsdynamicbasalspcEnum); 565 827 Input* vx_input = element->GetInput(VxEnum); _assert_(vx_input); 566 828 Input* vy_input = element->GetInput(VyEnum); _assert_(vy_input); 567 829 Input* vz_input = element->GetInput(VzEnum); _assert_(vz_input); 568 Input* enthalpy_input = element->GetInput(EnthalpyPicardEnum); _assert_(enthalpy_input); 569 Input* pressure_input = element->GetInput(PressureEnum); _assert_(pressure_input); 830 Input* enthalpy_input = element->GetInput(EnthalpyPicardEnum); _assert_(enthalpy_input); 831 Input* pressure_input = element->GetInput(PressureEnum); _assert_(pressure_input); 832 Input* watercolumn_input = element->GetInput(WatercolumnEnum); _assert_(watercolumn_input); 833 Input* meltingrate_input = element->GetInput(BasalforcingsGroundediceMeltingRateEnum); _assert_(meltingrate_input); 570 834 Input* geothermalflux_input = element->GetInput(BasalforcingsGeothermalfluxEnum); _assert_(geothermalflux_input); 571 Input* watercolumn_input = element->GetInput(WatercolumnEnum); _assert_(watercolumn_input); 572 IssmDouble rho_ice = element->GetMaterialParameter(MaterialsRhoIceEnum); 573 IssmDouble heatcapacity = element->GetMaterialParameter(MaterialsHeatcapacityEnum); 835 IssmDouble rho_ice = element->GetMaterialParameter(MaterialsRhoIceEnum); 574 836 575 837 /*Build friction element, needed later: */ … … 577 839 578 840 /* Start looping on the number of gaussian points: */ 579 Gauss* gauss =element->NewGaussBase(2);580 Gauss* gaussup =element->NewGaussTop(2);841 Gauss* gauss=element->NewGaussBase(2); 842 Gauss* gaussup=element->NewGaussTop(2); 581 843 for(int ig=gauss->begin();ig<gauss->end();ig++){ 582 844 gauss->GaussPoint(ig); 845 gaussup->GaussPoint(ig); 583 846 584 847 element->JacobianDeterminantBase(&Jdet,xyz_list_base,gauss); 585 848 element->NodalFunctions(basis,gauss); 586 849 587 enthalpy_input->GetInputValue(&enthalpy,gauss); 588 pressure_input->GetInputValue(&pressure,gauss); 589 watercolumn_input->GetInputValue(&watercolumn,gauss); 590 591 if((watercolumn<=0.) && (enthalpy<PureIceEnthalpy(element,pressure))){ 592 /* the above check is equivalent to 593 NOT [(watercolumn>0.) AND (enthalpy<PIE)] AND (enthalpy<PIE)*/ 594 geothermalflux_input->GetInputValue(&geothermalflux,gauss); 595 596 friction->GetAlpha2(&alpha2,gauss); 597 vx_input->GetInputValue(&vx,gauss); 598 vy_input->GetInputValue(&vy,gauss); 599 vz_input->GetInputValue(&vz,gauss); 600 basalfriction = alpha2*(vx*vx + vy*vy + vz*vz); 601 heatflux = (basalfriction+geothermalflux)/(rho_ice); 602 603 scalar = gauss->weight*Jdet*heatflux; 604 if(dt!=0.) scalar=dt*scalar; 605 606 for(int i=0;i<numnodes;i++) pe->values[i]+=scalar*basis[i]; 607 } 608 else if(enthalpy >= PureIceEnthalpy(element,pressure)){ 609 /* check positive thickness of temperate basal ice layer */ 850 if(isdynamicbasalspc){ 851 enthalpy_input->GetInputValue(&enthalpy,gauss); 610 852 enthalpy_input->GetInputValue(&enthalpyup,gaussup); 853 pressure_input->GetInputValue(&pressure,gauss); 611 854 pressure_input->GetInputValue(&pressureup,gaussup); 612 if(enthalpyup >= PureIceEnthalpy(element,pressureup)){ 613 // do nothing, set grad enthalpy*n=0. 614 } 615 else{ 616 // only base temperate, set Dirichlet BCs in Penta::UpdateBasalConstraintsEnthalpy() 617 } 618 } 619 else{ 620 // base cold, but watercolumn positive. Set base to pressure melting point enthalpy 855 watercolumn_input->GetInputValue(&watercolumn,gauss); 856 meltingrate_input->GetInputValue(&meltingrate,gauss); 857 state=GetThermalBasalCondition(element, enthalpy, enthalpyup, pressure, pressureup, watercolumn, meltingrate); 858 } 859 else 860 state=0; 861 862 switch (state) { 863 case 0: 864 // cold, dry base: apply basal surface forcing 865 geothermalflux_input->GetInputValue(&geothermalflux,gauss); 866 friction->GetAlpha2(&alpha2,gauss); 867 vx_input->GetInputValue(&vx,gauss); 868 vy_input->GetInputValue(&vy,gauss); 869 vz_input->GetInputValue(&vz,gauss); 870 basalfriction=alpha2*(vx*vx+vy*vy+vz*vz); 871 heatflux=(basalfriction+geothermalflux)/(rho_ice); 872 scalar=gauss->weight*Jdet*heatflux; 873 if(dt!=0.) scalar=dt*scalar; 874 for(i=0;i<numnodes;i++) 875 pe->values[i]+=scalar*basis[i]; 876 break; 877 case 1: 878 // cold, wet base: keep at pressure melting point 879 break; 880 case 2: 881 // temperate, thin refreezing base: release spc 882 break; 883 case 3: 884 // temperate, thin melting base: set spc 885 break; 886 case 4: 887 // temperate, thick melting base: set grad H*n=0 888 for(i=0;i<numnodes;i++) 889 pe->values[i]+=0.; 890 break; 891 default: 892 _printf0_(" unknown thermal basal state found!"); 621 893 } 622 894 } … … 639 911 if(!element->IsOnBase() || !element->IsFloating()) return NULL; 640 912 641 IssmDouble h_pmp,dt,Jdet,scalar_ocean,pressure;913 IssmDouble Hpmp,dt,Jdet,scalar_ocean,pressure; 642 914 IssmDouble *xyz_list_base = NULL; 643 915 … … 669 941 670 942 pressure_input->GetInputValue(&pressure,gauss); 671 h_pmp=element->PureIceEnthalpy(pressure);672 673 scalar_ocean=gauss->weight*Jdet*rho_water*mixed_layer_capacity*thermal_exchange_vel* h_pmp/(heatcapacity*rho_ice);943 Hpmp=element->PureIceEnthalpy(pressure); 944 945 scalar_ocean=gauss->weight*Jdet*rho_water*mixed_layer_capacity*thermal_exchange_vel*Hpmp/(heatcapacity*rho_ice); 674 946 if(reCast<bool,IssmDouble>(dt)) scalar_ocean=dt*scalar_ocean; 675 947 … … 683 955 return pe; 684 956 }/*}}}*/ 685 void EnthalpyAnalysis::GetBConduct(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 686 /*Compute B matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1. 687 * For node i, Bi' can be expressed in the actual coordinate system 688 * by: 689 * Bi_conduct=[ dh/dx ] 690 * [ dh/dy ] 691 * [ dh/dz ] 692 * where h is the interpolation function for node i. 693 * 694 * We assume B has been allocated already, of size: 3x(NDOF1*numnodes) 695 */ 696 697 /*Fetch number of nodes for this finite element*/ 698 int numnodes = element->GetNumberOfNodes(); 699 700 /*Get nodal functions derivatives*/ 701 IssmDouble* dbasis=xNew<IssmDouble>(3*numnodes); 702 element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss); 703 704 /*Build B: */ 705 for(int i=0;i<numnodes;i++){ 706 B[numnodes*0+i] = dbasis[0*numnodes+i]; 707 B[numnodes*1+i] = dbasis[1*numnodes+i]; 708 B[numnodes*2+i] = dbasis[2*numnodes+i]; 709 } 710 711 /*Clean-up*/ 712 xDelete<IssmDouble>(dbasis); 713 }/*}}}*/ 714 void EnthalpyAnalysis::GetBAdvec(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 715 /*Compute B matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1. 716 * For node i, Bi' can be expressed in the actual coordinate system 717 * by: 718 * Bi_advec =[ h ] 719 * [ h ] 720 * [ h ] 721 * where h is the interpolation function for node i. 722 * 723 * We assume B has been allocated already, of size: 3x(NDOF1*NUMNODESP1) 724 */ 725 726 /*Fetch number of nodes for this finite element*/ 727 int numnodes = element->GetNumberOfNodes(); 728 729 /*Get nodal functions*/ 730 IssmDouble* basis=xNew<IssmDouble>(numnodes); 731 element->NodalFunctions(basis,gauss); 732 733 /*Build B: */ 734 for(int i=0;i<numnodes;i++){ 735 B[numnodes*0+i] = basis[i]; 736 B[numnodes*1+i] = basis[i]; 737 B[numnodes*2+i] = basis[i]; 738 } 739 740 /*Clean-up*/ 741 xDelete<IssmDouble>(basis); 742 }/*}}}*/ 743 void EnthalpyAnalysis::GetBAdvecprime(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 744 /*Compute B matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1. 745 * For node i, Bi' can be expressed in the actual coordinate system 746 * by: 747 * Biprime_advec=[ dh/dx ] 748 * [ dh/dy ] 749 * [ dh/dz ] 750 * where h is the interpolation function for node i. 751 * 752 * We assume B has been allocated already, of size: 3x(NDOF1*numnodes) 753 */ 754 755 /*Fetch number of nodes for this finite element*/ 756 int numnodes = element->GetNumberOfNodes(); 757 758 /*Get nodal functions derivatives*/ 759 IssmDouble* dbasis=xNew<IssmDouble>(3*numnodes); 760 element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss); 761 762 /*Build B: */ 763 for(int i=0;i<numnodes;i++){ 764 B[numnodes*0+i] = dbasis[0*numnodes+i]; 765 B[numnodes*1+i] = dbasis[1*numnodes+i]; 766 B[numnodes*2+i] = dbasis[2*numnodes+i]; 767 } 768 769 /*Clean-up*/ 770 xDelete<IssmDouble>(dbasis); 771 }/*}}}*/ 772 void EnthalpyAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 773 element->GetSolutionFromInputsOneDof(solution,EnthalpyEnum); 774 }/*}}}*/ 775 void EnthalpyAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 776 _error_("Not implemented yet"); 777 }/*}}}*/ 778 void EnthalpyAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 779 780 bool converged; 781 int i,rheology_law; 782 IssmDouble B_average,s_average,T_average=0.,P_average=0.; 783 int *doflist = NULL; 784 IssmDouble *xyz_list = NULL; 785 786 /*Fetch number of nodes and dof for this finite element*/ 787 int numnodes = element->GetNumberOfNodes(); 788 789 /*Fetch dof list and allocate solution vector*/ 790 element->GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 791 IssmDouble* values = xNew<IssmDouble>(numnodes); 792 IssmDouble* pressure = xNew<IssmDouble>(numnodes); 793 IssmDouble* surface = xNew<IssmDouble>(numnodes); 794 IssmDouble* B = xNew<IssmDouble>(numnodes); 795 IssmDouble* temperature = xNew<IssmDouble>(numnodes); 796 IssmDouble* waterfraction = xNew<IssmDouble>(numnodes); 797 798 /*Use the dof list to index into the solution vector: */ 799 for(i=0;i<numnodes;i++){ 800 values[i]=solution[doflist[i]]; 801 802 /*Check solution*/ 803 if(xIsNan<IssmDouble>(values[i])) _error_("NaN found in solution vector"); 804 } 805 806 /*Get all inputs and parameters*/ 807 element->GetInputValue(&converged,ConvergedEnum); 808 element->GetInputListOnNodes(&pressure[0],PressureEnum); 809 if(converged){ 810 for(i=0;i<numnodes;i++){ 811 element->EnthalpyToThermal(&temperature[i],&waterfraction[i],values[i],pressure[i]); 812 if(waterfraction[i]<0.) _error_("Negative water fraction found in solution vector"); 813 //if(waterfraction[i]>1.) _error_("Water fraction >1 found in solution vector"); 814 } 815 element->AddInput(EnthalpyEnum,values,element->GetElementType()); 816 element->AddInput(WaterfractionEnum,waterfraction,element->GetElementType()); 817 element->AddInput(TemperatureEnum,temperature,element->GetElementType()); 818 819 /*Update Rheology only if converged (we must make sure that the temperature is below melting point 820 * otherwise the rheology could be negative*/ 821 element->FindParam(&rheology_law,MaterialsRheologyLawEnum); 822 element->GetInputListOnNodes(&surface[0],SurfaceEnum); 823 switch(rheology_law){ 824 case NoneEnum: 825 /*Do nothing: B is not temperature dependent*/ 826 break; 827 case CuffeyEnum: 828 for(i=0;i<numnodes;i++) B[i]=Cuffey(temperature[i]); 829 element->AddInput(MaterialsRheologyBEnum,&B[0],element->GetElementType()); 830 break; 831 case PatersonEnum: 832 for(i=0;i<numnodes;i++) B[i]=Paterson(temperature[i]); 833 element->AddInput(MaterialsRheologyBEnum,&B[0],element->GetElementType()); 834 break; 835 case ArrheniusEnum: 836 element->GetVerticesCoordinates(&xyz_list); 837 for(i=0;i<numnodes;i++) B[i]=Arrhenius(temperature[i],surface[i]-xyz_list[i*3+2],element->GetMaterialParameter(MaterialsRheologyNEnum)); 838 element->AddInput(MaterialsRheologyBEnum,&B[0],element->GetElementType()); 839 break; 840 case LliboutryDuvalEnum: 841 for(i=0;i<numnodes;i++) B[i]=LliboutryDuval(values[i],pressure[i],element->GetMaterialParameter(MaterialsRheologyNEnum),element->GetMaterialParameter(MaterialsBetaEnum),element->GetMaterialParameter(ConstantsReferencetemperatureEnum),element->GetMaterialParameter(MaterialsHeatcapacityEnum),element->GetMaterialParameter(MaterialsLatentheatEnum)); 842 element->AddInput(MaterialsRheologyBEnum,&B[0],element->GetElementType()); 843 break; 844 default: _error_("Rheology law " << EnumToStringx(rheology_law) << " not supported yet"); 845 } 846 } 847 else{ 848 element->AddInput(EnthalpyPicardEnum,values,element->GetElementType()); 849 } 850 851 /*Free ressources:*/ 852 xDelete<IssmDouble>(values); 853 xDelete<IssmDouble>(pressure); 854 xDelete<IssmDouble>(surface); 855 xDelete<IssmDouble>(B); 856 xDelete<IssmDouble>(temperature); 857 xDelete<IssmDouble>(waterfraction); 858 xDelete<IssmDouble>(xyz_list); 859 xDelete<int>(doflist); 860 }/*}}}*/ 861 void EnthalpyAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 862 863 bool islevelset; 864 femmodel->parameters->FindParam(&islevelset,TransientIslevelsetEnum); 865 if(islevelset){ 866 SetActiveNodesLSMx(femmodel); 867 } 868 return; 869 }/*}}}*/ 870 871 /*Modules*/ 872 void EnthalpyAnalysis::PostProcessing(FemModel* femmodel){/*{{{*/ 873 874 /*Intermediaries*/ 875 int solution_type, i; 876 bool computebasalmeltingrates=true; 877 bool isdrainage=true; 878 bool updatebasalconstraints=true; 879 880 if(isdrainage){ 881 /*Drain excess water fraction in ice column: */ 882 for(i=0;i<femmodel->elements->Size();i++){ 883 Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i)); 884 DrainWaterfractionIcecolumn(element); 885 } 886 } 887 888 if(computebasalmeltingrates){ 889 /*Compute basal melting rates: */ 890 for(i=0;i<femmodel->elements->Size();i++){ 891 Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i)); 892 ComputeBasalMeltingrate(element); 893 } 894 } 895 896 if(updatebasalconstraints){ 897 /*Update basal dirichlet BCs for enthalpy in transient runs: */ 898 femmodel->parameters->FindParam(&solution_type,SolutionTypeEnum); 899 if(solution_type==TransientSolutionEnum){ 900 for(i=0;i<femmodel->elements->Size();i++){ 901 Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i)); 902 UpdateBasalConstraints(element); 903 } 904 } 905 } 906 }/*}}}*/ 907 void EnthalpyAnalysis::ComputeBasalMeltingrate(Element* element){/*{{{*/ 908 /*Calculate the basal melt rates of the enthalpy model after Aschwanden 2012*/ 909 /* melting rate is positive when melting, negative when refreezing*/ 910 911 /* Check if ice in element */ 912 if(!element->IsIceInElement()) return; 913 914 /* Only compute melt rates at the base of grounded ice*/ 915 if(!element->IsOnBase() || element->IsFloating()) return; 916 917 /* Intermediaries */ 918 const int dim=3; 919 int i,is,vertexdown,vertexup,numvertices,numsegments; 920 IssmDouble heatflux; 921 IssmDouble vec_heatflux[dim],normal_base[dim],d1enthalpy[dim]; 922 IssmDouble basalfriction,alpha2; 923 IssmDouble dt,yts; 924 IssmDouble melting_overshoot,lambda; 925 IssmDouble geothermalflux; 926 IssmDouble vx,vy,vz; 927 IssmDouble *xyz_list = NULL; 928 IssmDouble *xyz_list_base = NULL; 929 int *pairindices = NULL; 930 931 /*Fetch parameters and inputs */ 932 element->GetVerticesCoordinates(&xyz_list); 933 element->GetVerticesCoordinatesBase(&xyz_list_base); 934 IssmDouble latentheat = element->GetMaterialParameter(MaterialsLatentheatEnum); 935 IssmDouble rho_ice = element->GetMaterialParameter(MaterialsRhoIceEnum); 936 IssmDouble rho_water = element->GetMaterialParameter(MaterialsRhoFreshwaterEnum); 937 Input* enthalpy_input = element->GetInput(EnthalpyEnum); _assert_(enthalpy_input); 938 Input* geothermalflux_input = element->GetInput(BasalforcingsGeothermalfluxEnum); _assert_(geothermalflux_input); 939 Input* vx_input = element->GetInput(VxEnum); _assert_(vx_input); 940 Input* vy_input = element->GetInput(VyEnum); _assert_(vy_input); 941 Input* vz_input = element->GetInput(VzEnum); _assert_(vz_input); 942 IssmDouble kappa=EnthalpyDiffusionParameterVolume(element,EnthalpyEnum); _assert_(kappa>=0.); 943 element->NormalBase(&normal_base[0],xyz_list_base); 944 element->VerticalSegmentIndices(&pairindices,&numsegments); 945 IssmDouble* meltingrate_enthalpy = xNew<IssmDouble>(numsegments); 946 IssmDouble* heating = xNew<IssmDouble>(numsegments); 947 948 /*Build friction element, needed later: */ 949 Friction* friction=new Friction(element,dim); 950 951 /******** MELTING RATES ************************************/ 952 numvertices=element->GetNumberOfVertices(); 953 IssmDouble* enthalpy = xNew<IssmDouble>(numvertices); 954 IssmDouble* pressure = xNew<IssmDouble>(numvertices); 955 IssmDouble* watercolumn = xNew<IssmDouble>(numvertices); 956 IssmDouble* basalmeltingrate = xNew<IssmDouble>(numvertices); 957 element->GetInputListOnVertices(enthalpy,EnthalpyEnum); 958 element->GetInputListOnVertices(pressure,PressureEnum); 959 element->GetInputListOnVertices(watercolumn,WatercolumnEnum); 960 element->GetInputListOnVertices(basalmeltingrate,BasalforcingsGroundediceMeltingRateEnum); 961 962 Gauss* gauss=element->NewGauss(); 963 964 for(int is=0;is<numsegments;is++){ 965 vertexdown = pairindices[is*2+0]; 966 vertexup = pairindices[is*2+1]; 967 gauss->GaussVertex(vertexdown); 968 969 bool checkpositivethickness=true; 970 _assert_(watercolumn[vertexdown]>=0.); 971 972 /*Calculate basal meltingrate after Fig.5 of A.Aschwanden 2012*/ 973 meltingrate_enthalpy[is]=0.; 974 heating[is]=0.; 975 if((watercolumn[vertexdown]>0.) && (enthalpy[vertexdown]<PureIceEnthalpy(element,pressure[vertexdown]))){ 976 /*ensure that no ice is at T<Tm(p), if water layer present*/ 977 enthalpy[vertexdown]=element->PureIceEnthalpy(pressure[vertexdown]); 978 } 979 else if(enthalpy[vertexdown]<element->PureIceEnthalpy(pressure[vertexdown])){ 980 /*cold base: set q*n=q_geo*n+frictionheating as Neumann BC in Penta::CreatePVectorEnthalpySheet*/ 981 checkpositivethickness=false; // cold base, skip next test 982 } 983 else{/*we have a temperate base, go to next test*/} 984 985 if(checkpositivethickness){ 986 /*From here on all basal ice is temperate. Check for positive thickness of layer of temperate ice. */ 987 bool istemperatelayer=false; 988 if(enthalpy[vertexup]>=element->PureIceEnthalpy(pressure[vertexup])) istemperatelayer=true; 989 if(istemperatelayer) for(i=0;i<dim;i++) vec_heatflux[i]=0.; // TODO: add -k*nabla T_pmp 990 else{ 991 enthalpy_input->GetInputDerivativeValue(&d1enthalpy[0],xyz_list,gauss); 992 for(i=0;i<3;i++) vec_heatflux[i]=-kappa*d1enthalpy[i]; 993 } 994 995 /*heat flux along normal*/ 996 heatflux=0.; 997 for(i=0;i<3;i++) heatflux+=(vec_heatflux[i])*normal_base[i]; 998 999 /*basal friction*/ 1000 friction->GetAlpha2(&alpha2,gauss); 1001 vx_input->GetInputValue(&vx,gauss); 1002 vy_input->GetInputValue(&vy,gauss); 1003 vz_input->GetInputValue(&vz,gauss); 1004 basalfriction=alpha2*(vx*vx + vy*vy + vz*vz); 1005 1006 geothermalflux_input->GetInputValue(&geothermalflux,gauss); 1007 /* -Mb= Fb-(q-q_geo)/((1-w)*L*rho), and (1-w)*rho=rho_ice, cf Aschwanden 2012, eqs.1, 2, 66*/ 1008 heating[is]=(heatflux+basalfriction+geothermalflux); 1009 meltingrate_enthalpy[is]=heating[is]/(latentheat*rho_ice); // m/s water equivalent 1010 } 1011 } 1012 /******** UPDATE MELTINGRATES AND WATERCOLUMN **************/ 1013 element->FindParam(&dt,TimesteppingTimeStepEnum); 1014 for(is=0;is<numsegments;is++){ 1015 vertexdown = pairindices[is*2+0]; 1016 vertexup = pairindices[is*2+1]; 1017 if(dt!=0.){ 1018 if(watercolumn[vertexdown]+meltingrate_enthalpy[is]*dt<0.){ // prevent too much freeze on 1019 lambda = -watercolumn[vertexdown]/(dt*meltingrate_enthalpy[is]); _assert_(lambda>=0.); _assert_(lambda<1.); 1020 watercolumn[vertexdown]=0.; 1021 basalmeltingrate[vertexdown]=lambda*meltingrate_enthalpy[is]; // restrict freeze on only to size of watercolumn 1022 enthalpy[vertexdown]+=(1.-lambda)*meltingrate_enthalpy[is]*dt*latentheat; // use rest of energy to cool down base 1023 } 1024 else{ 1025 basalmeltingrate[vertexdown]=meltingrate_enthalpy[is]; 1026 watercolumn[vertexdown]+=dt*meltingrate_enthalpy[is]; 1027 } 1028 } 1029 else{ 1030 basalmeltingrate[vertexdown]=meltingrate_enthalpy[is]; 1031 watercolumn[vertexdown]+=meltingrate_enthalpy[is]; 1032 } 1033 basalmeltingrate[vertexdown]*=rho_water/rho_ice; // convert meltingrate from water to ice equivalent 1034 _assert_(watercolumn[vertexdown]>=0.); 1035 } 1036 1037 /*feed updated variables back into model*/ 1038 element->AddInput(EnthalpyEnum,enthalpy,P1Enum); 1039 element->AddInput(WatercolumnEnum,watercolumn,P1Enum); 1040 element->AddInput(BasalforcingsGroundediceMeltingRateEnum,basalmeltingrate,P1Enum); 1041 1042 /*Clean up and return*/ 1043 delete gauss; 1044 delete friction; 1045 xDelete<int>(pairindices); 1046 xDelete<IssmDouble>(enthalpy); 1047 xDelete<IssmDouble>(pressure); 1048 xDelete<IssmDouble>(watercolumn); 1049 xDelete<IssmDouble>(basalmeltingrate); 1050 xDelete<IssmDouble>(meltingrate_enthalpy); 1051 xDelete<IssmDouble>(heating); 1052 xDelete<IssmDouble>(xyz_list); 1053 xDelete<IssmDouble>(xyz_list_base); 1054 }/*}}}*/ 1055 void EnthalpyAnalysis::DrainWaterfractionIcecolumn(Element* element){/*{{{*/ 1056 1057 /* Check if ice in element */ 1058 if(!element->IsIceInElement()) return; 1059 1060 /* Only drain waterfraction of ice column from element at base*/ 1061 if(!element->IsOnBase()) return; //FIXME: allow freeze on for floating elements 1062 1063 /* Intermediaries*/ 1064 int is, numvertices, numsegments; 1065 int *pairindices = NULL; 1066 1067 numvertices=element->GetNumberOfVertices(); 1068 element->VerticalSegmentIndices(&pairindices,&numsegments); 1069 1070 IssmDouble* watercolumn = xNew<IssmDouble>(numvertices); 1071 IssmDouble* drainrate_column = xNew<IssmDouble>(numsegments); 1072 IssmDouble* drainrate_element = xNew<IssmDouble>(numsegments); 1073 1074 element->GetInputListOnVertices(watercolumn,WatercolumnEnum); 1075 1076 for(is=0;is<numsegments;is++) drainrate_column[is]=0.; 1077 Element* elementi = element; 1078 for(;;){ 1079 for(is=0;is<numsegments;is++) drainrate_element[is]=0.; 1080 DrainWaterfraction(elementi,drainrate_element); // TODO: make sure every vertex is only drained once 1081 for(is=0;is<numsegments;is++) drainrate_column[is]+=drainrate_element[is]; 1082 1083 if(elementi->IsOnSurface()) break; 1084 elementi=elementi->GetUpperElement(); 1085 } 1086 /* add drained water to water column*/ 1087 for(is=0;is<numsegments;is++) watercolumn[is]+=drainrate_column[is]; 1088 /* Feed updated water column back into model */ 1089 element->AddInput(WatercolumnEnum,watercolumn,P1Enum); 1090 1091 xDelete<int>(pairindices); 1092 xDelete<IssmDouble>(drainrate_column); 1093 xDelete<IssmDouble>(drainrate_element); 1094 xDelete<IssmDouble>(watercolumn); 1095 }/*}}}*/ 1096 void EnthalpyAnalysis::DrainWaterfraction(Element* element, IssmDouble* pdrainrate_element){/*{{{*/ 957 void EnthalpyAnalysis::DrainWaterfraction(FemModel* femmodel){/*{{{*/ 958 /*Drain excess water fraction in ice column: */ 959 for(int i=0;i<femmodel->elements->Size();i++){ 960 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 961 DrainWaterfractionIcecolumn(element); 962 } 963 }/*}}}*/ 964 void EnthalpyAnalysis::DrainWaterfraction(Element* element, IssmDouble* pdrainrate_element){/*{{{*/ 1097 965 1098 966 /* Check if ice in element */ … … 1156 1024 xDelete<IssmDouble>(deltawaterfractions); 1157 1025 }/*}}}*/ 1158 void EnthalpyAnalysis::UpdateBasalConstraints(Element* element){/*{{{*/1026 void EnthalpyAnalysis::DrainWaterfractionIcecolumn(Element* element){/*{{{*/ 1159 1027 1160 1028 /* Check if ice in element */ 1161 1029 if(!element->IsIceInElement()) return; 1162 1030 1163 /* Only update Constraints at the base of grounded ice*/ 1164 if(!(element->IsOnBase()) || element->IsFloating()) return; 1165 1166 /*Intermediary*/ 1167 bool isdynamicbasalspc,setspc; 1168 int numindices, numindicesup; 1169 IssmDouble pressure, pressureup; 1170 IssmDouble h_pmp, enthalpy, enthalpyup; 1171 IssmDouble watercolumn; 1172 int *indices = NULL, *indicesup = NULL; 1173 Node* node = NULL; 1174 1175 /*Check wether dynamic basal boundary conditions are activated */ 1176 element->FindParam(&isdynamicbasalspc,ThermalIsdynamicbasalspcEnum); 1177 if(!isdynamicbasalspc) return; 1178 1179 /*Fetch indices of basal & surface nodes for this finite element*/ 1180 Penta *penta = (Penta *) element; // TODO: add Basal-/SurfaceNodeIndices to element.h, and change this to Element* 1181 penta->BasalNodeIndices(&numindices,&indices,element->GetElementType()); 1182 penta->SurfaceNodeIndices(&numindicesup,&indicesup,element->GetElementType()); 1183 _assert_(numindices==numindicesup); 1184 1185 /*Get parameters and inputs: */ 1186 Input* pressure_input=element->GetInput(PressureEnum); _assert_(pressure_input); 1187 Input* enthalpy_input=element->GetInput(EnthalpyEnum); _assert_(enthalpy_input); 1188 Input* watercolumn_input=element->GetInput(WatercolumnEnum); _assert_(watercolumn_input); 1189 1190 /*if there is a temperate layer of zero thickness, set spc enthalpy=h_pmp at that node*/ 1191 GaussPenta* gauss=new GaussPenta(); 1192 GaussPenta* gaussup=new GaussPenta(); 1193 for(int i=0;i<numindices;i++){ 1194 gauss->GaussNode(element->GetElementType(),indices[i]); 1195 gaussup->GaussNode(element->GetElementType(),indicesup[i]); 1196 1197 /*Check wether there is a temperate layer at the base or not */ 1198 /*check if node is temperate, else continue*/ 1199 enthalpy_input->GetInputValue(&enthalpy, gauss); 1200 pressure_input->GetInputValue(&pressure, gauss); 1201 watercolumn_input->GetInputValue(&watercolumn,gauss); 1202 h_pmp=PureIceEnthalpy(element,pressure); 1203 if (enthalpy>=h_pmp){ 1204 /*check if upper node is temperate, too. 1205 if yes, then we have a temperate layer of positive thickness and reset the spc. 1206 if not, apply dirichlet BC.*/ 1207 enthalpy_input->GetInputValue(&enthalpyup, gaussup); 1208 pressure_input->GetInputValue(&pressureup, gaussup); 1209 setspc=((enthalpyup<PureIceEnthalpy(element,pressureup)) && (watercolumn>=0.))?true:false; 1210 } 1211 else 1212 setspc = false; 1213 1214 node=element->GetNode(indices[i]); 1215 if(setspc) 1216 node->ApplyConstraint(0,h_pmp); /*apply spc*/ 1217 else 1218 node->DofInFSet(0); /*remove spc*/ 1219 } 1220 1221 /*Free ressources:*/ 1222 xDelete<int>(indices); 1223 xDelete<int>(indicesup); 1224 delete gauss; 1225 delete gaussup; 1226 }/*}}}*/ 1227 1228 /*Intermediaries*/ 1229 IssmDouble EnthalpyAnalysis::EnthalpyDiffusionParameter(Element* element,IssmDouble enthalpy,IssmDouble pressure){/*{{{*/ 1031 /* Only drain waterfraction of ice column from element at base*/ 1032 if(!element->IsOnBase()) return; //FIXME: allow freeze on for floating elements 1033 1034 /* Intermediaries*/ 1035 int is, numvertices, numsegments; 1036 int *pairindices = NULL; 1037 1038 numvertices=element->GetNumberOfVertices(); 1039 element->VerticalSegmentIndices(&pairindices,&numsegments); 1040 1041 IssmDouble* watercolumn = xNew<IssmDouble>(numvertices); 1042 IssmDouble* drainrate_column = xNew<IssmDouble>(numsegments); 1043 IssmDouble* drainrate_element = xNew<IssmDouble>(numsegments); 1044 1045 element->GetInputListOnVertices(watercolumn,WatercolumnEnum); 1046 1047 for(is=0;is<numsegments;is++) drainrate_column[is]=0.; 1048 Element* elementi = element; 1049 for(;;){ 1050 for(is=0;is<numsegments;is++) drainrate_element[is]=0.; 1051 DrainWaterfraction(elementi,drainrate_element); // TODO: make sure every vertex is only drained once 1052 for(is=0;is<numsegments;is++) drainrate_column[is]+=drainrate_element[is]; 1053 1054 if(elementi->IsOnSurface()) break; 1055 elementi=elementi->GetUpperElement(); 1056 } 1057 /* add drained water to water column*/ 1058 for(is=0;is<numsegments;is++) watercolumn[is]+=drainrate_column[is]; 1059 /* Feed updated water column back into model */ 1060 element->AddInput(WatercolumnEnum,watercolumn,P1Enum); 1061 1062 xDelete<int>(pairindices); 1063 xDelete<IssmDouble>(drainrate_column); 1064 xDelete<IssmDouble>(drainrate_element); 1065 xDelete<IssmDouble>(watercolumn); 1066 }/*}}}*/ 1067 IssmDouble EnthalpyAnalysis::EnthalpyDiffusionParameter(Element* element,IssmDouble enthalpy,IssmDouble pressure){/*{{{*/ 1230 1068 1231 1069 IssmDouble heatcapacity = element->GetMaterialParameter(MaterialsHeatcapacityEnum); … … 1240 1078 } 1241 1079 }/*}}}*/ 1242 IssmDouble EnthalpyAnalysis::EnthalpyDiffusionParameterVolume(Element* element,int enthalpy_enum){/*{{{*/1080 IssmDouble EnthalpyAnalysis::EnthalpyDiffusionParameterVolume(Element* element,int enthalpy_enum){/*{{{*/ 1243 1081 1244 1082 int iv; … … 1295 1133 return kappa; 1296 1134 }/*}}}*/ 1297 IssmDouble EnthalpyAnalysis::PureIceEnthalpy(Element* element,IssmDouble pressure){/*{{{*/ 1135 void EnthalpyAnalysis::GetBAdvec(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 1136 /*Compute B matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1. 1137 * For node i, Bi' can be expressed in the actual coordinate system 1138 * by: 1139 * Bi_advec =[ h ] 1140 * [ h ] 1141 * [ h ] 1142 * where h is the interpolation function for node i. 1143 * 1144 * We assume B has been allocated already, of size: 3x(NDOF1*NUMNODESP1) 1145 */ 1146 1147 /*Fetch number of nodes for this finite element*/ 1148 int numnodes = element->GetNumberOfNodes(); 1149 1150 /*Get nodal functions*/ 1151 IssmDouble* basis=xNew<IssmDouble>(numnodes); 1152 element->NodalFunctions(basis,gauss); 1153 1154 /*Build B: */ 1155 for(int i=0;i<numnodes;i++){ 1156 B[numnodes*0+i] = basis[i]; 1157 B[numnodes*1+i] = basis[i]; 1158 B[numnodes*2+i] = basis[i]; 1159 } 1160 1161 /*Clean-up*/ 1162 xDelete<IssmDouble>(basis); 1163 }/*}}}*/ 1164 void EnthalpyAnalysis::GetBAdvecprime(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 1165 /*Compute B matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1. 1166 * For node i, Bi' can be expressed in the actual coordinate system 1167 * by: 1168 * Biprime_advec=[ dh/dx ] 1169 * [ dh/dy ] 1170 * [ dh/dz ] 1171 * where h is the interpolation function for node i. 1172 * 1173 * We assume B has been allocated already, of size: 3x(NDOF1*numnodes) 1174 */ 1175 1176 /*Fetch number of nodes for this finite element*/ 1177 int numnodes = element->GetNumberOfNodes(); 1178 1179 /*Get nodal functions derivatives*/ 1180 IssmDouble* dbasis=xNew<IssmDouble>(3*numnodes); 1181 element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss); 1182 1183 /*Build B: */ 1184 for(int i=0;i<numnodes;i++){ 1185 B[numnodes*0+i] = dbasis[0*numnodes+i]; 1186 B[numnodes*1+i] = dbasis[1*numnodes+i]; 1187 B[numnodes*2+i] = dbasis[2*numnodes+i]; 1188 } 1189 1190 /*Clean-up*/ 1191 xDelete<IssmDouble>(dbasis); 1192 }/*}}}*/ 1193 void EnthalpyAnalysis::GetBasalConstraints(Vector<IssmDouble>* vec_spc,Element* element){/*{{{*/ 1194 1195 /* Check if ice in element */ 1196 if(!element->IsIceInElement()) return; 1197 1198 /* Only update Constraints at the base of grounded ice*/ 1199 if(!(element->IsOnBase()) || element->IsFloating()) return; 1200 1201 /*Intermediary*/ 1202 bool isdynamicbasalspc; 1203 IssmDouble dt; 1204 1205 /*Check wether dynamic basal boundary conditions are activated */ 1206 element->FindParam(&isdynamicbasalspc,ThermalIsdynamicbasalspcEnum); 1207 if(!isdynamicbasalspc) return; 1208 1209 element->FindParam(&dt,TimesteppingTimeStepEnum); 1210 if(dt==0.){ 1211 GetBasalConstraintsSteadystate(vec_spc,element); 1212 } 1213 else{ 1214 GetBasalConstraintsTransient(vec_spc,element); 1215 } 1216 }/*}}}*/ 1217 void EnthalpyAnalysis::GetBasalConstraintsSteadystate(Vector<IssmDouble>* vec_spc,Element* element){/*{{{*/ 1218 1219 /* Check if ice in element */ 1220 if(!element->IsIceInElement()) return; 1221 1222 /* Only update Constraints at the base of grounded ice*/ 1223 if(!(element->IsOnBase()) || element->IsFloating()) return; 1224 1225 /*Intermediary*/ 1226 int numindices, numindicesup, state; 1227 int *indices = NULL, *indicesup = NULL; 1228 IssmDouble enthalpy, enthalpyup, pressure, pressureup, watercolumn, meltingrate; 1229 1230 /*Get parameters and inputs: */ 1231 Input* enthalpy_input = element->GetInput(EnthalpyPicardEnum); _assert_(enthalpy_input); 1232 Input* pressure_input = element->GetInput(PressureEnum); _assert_(pressure_input); 1233 Input* watercolumn_input = element->GetInput(WatercolumnEnum); _assert_(watercolumn_input); 1234 Input* meltingrate_input = element->GetInput(BasalforcingsGroundediceMeltingRateEnum); _assert_(meltingrate_input); 1235 1236 /*Fetch indices of basal & surface nodes for this finite element*/ 1237 Penta *penta = (Penta *) element; // TODO: add Basal-/SurfaceNodeIndices to element.h, and change this to Element* 1238 penta->BasalNodeIndices(&numindices,&indices,element->GetElementType()); 1239 penta->SurfaceNodeIndices(&numindicesup,&indicesup,element->GetElementType()); _assert_(numindices==numindicesup); 1240 1241 GaussPenta* gauss=new GaussPenta(); 1242 GaussPenta* gaussup=new GaussPenta(); 1243 for(int i=0;i<numindices;i++){ 1244 gauss->GaussNode(element->GetElementType(),indices[i]); 1245 gaussup->GaussNode(element->GetElementType(),indicesup[i]); 1246 1247 enthalpy_input->GetInputValue(&enthalpy,gauss); 1248 enthalpy_input->GetInputValue(&enthalpyup,gaussup); 1249 pressure_input->GetInputValue(&pressure,gauss); 1250 pressure_input->GetInputValue(&pressureup,gaussup); 1251 watercolumn_input->GetInputValue(&watercolumn,gauss); 1252 meltingrate_input->GetInputValue(&meltingrate,gauss); 1253 1254 state=GetThermalBasalCondition(element, enthalpy, enthalpyup, pressure, pressureup, watercolumn, meltingrate); 1255 switch (state) { 1256 case 0: 1257 // cold, dry base: apply basal surface forcing 1258 vec_spc->SetValue(element->nodes[i]->Sid(),0.,INS_VAL); 1259 break; 1260 case 1: 1261 // cold, wet base: keep at pressure melting point 1262 vec_spc->SetValue(element->nodes[i]->Sid(),1.,INS_VAL); 1263 break; 1264 case 2: 1265 // temperate, thin refreezing base: release spc 1266 vec_spc->SetValue(element->nodes[i]->Sid(),0.,INS_VAL); 1267 break; 1268 case 3: 1269 // temperate, thin melting base: set spc 1270 vec_spc->SetValue(element->nodes[i]->Sid(),1.,INS_VAL); 1271 break; 1272 case 4: 1273 // temperate, thick melting base: s 1274 vec_spc->SetValue(element->nodes[i]->Sid(),1.,INS_VAL); 1275 break; 1276 default: 1277 _printf0_(" unknown thermal basal state found!"); 1278 } 1279 } 1280 1281 /*Free ressources:*/ 1282 xDelete<int>(indices); 1283 xDelete<int>(indicesup); 1284 delete gauss; 1285 delete gaussup; 1286 }/*}}}*/ 1287 void EnthalpyAnalysis::GetBasalConstraintsTransient(Vector<IssmDouble>* vec_spc,Element* element){/*{{{*/ 1288 1289 /* Check if ice in element */ 1290 if(!element->IsIceInElement()) return; 1291 1292 /* Only update Constraints at the base of grounded ice*/ 1293 if(!(element->IsOnBase()) || element->IsFloating()) return; 1294 1295 /*Intermediary*/ 1296 int numindices, numindicesup, state; 1297 int *indices = NULL, *indicesup = NULL; 1298 IssmDouble enthalpy, enthalpyup, pressure, pressureup, watercolumn, meltingrate; 1299 1300 /*Get parameters and inputs: */ 1301 Input* enthalpy_input = element->GetInput(EnthalpyEnum); _assert_(enthalpy_input); //TODO: check EnthalpyPicard? 1302 Input* pressure_input = element->GetInput(PressureEnum); _assert_(pressure_input); 1303 Input* watercolumn_input = element->GetInput(WatercolumnEnum); _assert_(watercolumn_input); 1304 Input* meltingrate_input = element->GetInput(BasalforcingsGroundediceMeltingRateEnum); _assert_(meltingrate_input); 1305 1306 /*Fetch indices of basal & surface nodes for this finite element*/ 1307 Penta *penta = (Penta *) element; // TODO: add Basal-/SurfaceNodeIndices to element.h, and change this to Element* 1308 penta->BasalNodeIndices(&numindices,&indices,element->GetElementType()); 1309 penta->SurfaceNodeIndices(&numindicesup,&indicesup,element->GetElementType()); _assert_(numindices==numindicesup); 1310 1311 GaussPenta* gauss=new GaussPenta(); 1312 GaussPenta* gaussup=new GaussPenta(); 1313 1314 for(int i=0;i<numindices;i++){ 1315 gauss->GaussNode(element->GetElementType(),indices[i]); 1316 gaussup->GaussNode(element->GetElementType(),indicesup[i]); 1317 1318 enthalpy_input->GetInputValue(&enthalpy,gauss); 1319 enthalpy_input->GetInputValue(&enthalpyup,gaussup); 1320 pressure_input->GetInputValue(&pressure,gauss); 1321 pressure_input->GetInputValue(&pressureup,gaussup); 1322 watercolumn_input->GetInputValue(&watercolumn,gauss); 1323 meltingrate_input->GetInputValue(&meltingrate,gauss); 1324 1325 state=GetThermalBasalCondition(element, enthalpy, enthalpyup, pressure, pressureup, watercolumn, meltingrate); 1326 1327 switch (state) { 1328 case 0: 1329 // cold, dry base: apply basal surface forcing 1330 vec_spc->SetValue(element->nodes[i]->Sid(),0.,INS_VAL); 1331 break; 1332 case 1: 1333 // cold, wet base: keep at pressure melting point 1334 vec_spc->SetValue(element->nodes[i]->Sid(),1.,INS_VAL); 1335 break; 1336 case 2: 1337 // temperate, thin refreezing base: release spc 1338 vec_spc->SetValue(element->nodes[i]->Sid(),0.,INS_VAL); 1339 break; 1340 case 3: 1341 // temperate, thin melting base: set spc 1342 vec_spc->SetValue(element->nodes[i]->Sid(),1.,INS_VAL); 1343 break; 1344 case 4: 1345 // temperate, thick melting base: set grad H*n=0 1346 vec_spc->SetValue(element->nodes[i]->Sid(),0.,INS_VAL); 1347 break; 1348 default: 1349 _printf0_(" unknown thermal basal state found!"); 1350 } 1351 1352 } 1353 1354 /*Free ressources:*/ 1355 xDelete<int>(indices); 1356 xDelete<int>(indicesup); 1357 delete gauss; 1358 delete gaussup; 1359 }/*}}}*/ 1360 void EnthalpyAnalysis::GetBConduct(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 1361 /*Compute B matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1. 1362 * For node i, Bi' can be expressed in the actual coordinate system 1363 * by: 1364 * Bi_conduct=[ dh/dx ] 1365 * [ dh/dy ] 1366 * [ dh/dz ] 1367 * where h is the interpolation function for node i. 1368 * 1369 * We assume B has been allocated already, of size: 3x(NDOF1*numnodes) 1370 */ 1371 1372 /*Fetch number of nodes for this finite element*/ 1373 int numnodes = element->GetNumberOfNodes(); 1374 1375 /*Get nodal functions derivatives*/ 1376 IssmDouble* dbasis=xNew<IssmDouble>(3*numnodes); 1377 element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss); 1378 1379 /*Build B: */ 1380 for(int i=0;i<numnodes;i++){ 1381 B[numnodes*0+i] = dbasis[0*numnodes+i]; 1382 B[numnodes*1+i] = dbasis[1*numnodes+i]; 1383 B[numnodes*2+i] = dbasis[2*numnodes+i]; 1384 } 1385 1386 /*Clean-up*/ 1387 xDelete<IssmDouble>(dbasis); 1388 }/*}}}*/ 1389 void EnthalpyAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 1390 element->GetSolutionFromInputsOneDof(solution,EnthalpyEnum); 1391 }/*}}}*/ 1392 int EnthalpyAnalysis::GetThermalBasalCondition(Element* element, IssmDouble enthalpy, IssmDouble enthalpyup, IssmDouble pressure, IssmDouble pressureup, IssmDouble watercolumn, IssmDouble meltingrate){/*{{{*/ 1393 1394 /* Check if ice in element */ 1395 if(!element->IsIceInElement()) return -1; 1396 1397 /* Only update Constraints at the base of grounded ice*/ 1398 if(!(element->IsOnBase())) return -1; 1399 1400 /*Intermediary*/ 1401 int state=-1; 1402 IssmDouble dt; 1403 1404 /*Get parameters and inputs: */ 1405 element->FindParam(&dt,TimesteppingTimeStepEnum); 1406 1407 if(enthalpy<PureIceEnthalpy(element,pressure)){ 1408 if(watercolumn<=0.) state=0; // cold, dry base 1409 else state=1; // cold, wet base (refreezing) 1410 } 1411 else{ 1412 if(enthalpyup<PureIceEnthalpy(element,pressureup)){ 1413 if((dt==0.) && (meltingrate<0.)) state=2; // refreezing temperate base (non-physical, only for steadystate solver) 1414 else state=3; // temperate base, but no temperate layer 1415 } 1416 else state=4; // temperate layer with positive thickness 1417 } 1418 1419 _assert_(state>=0); 1420 return state; 1421 }/*}}}*/ 1422 IssmDouble EnthalpyAnalysis::GetWetIceConductivity(Element* element, IssmDouble enthalpy, IssmDouble pressure){/*{{{*/ 1423 1424 IssmDouble temperature, waterfraction; 1425 IssmDouble kappa_w = 0.6; // thermal conductivity of water (in W/m/K) 1426 IssmDouble kappa_i = element->GetMaterialParameter(MaterialsThermalconductivityEnum); 1427 element->EnthalpyToThermal(&temperature, &waterfraction, enthalpy, pressure); 1428 1429 return (1.-waterfraction)*kappa_i + waterfraction*kappa_w; 1430 }/*}}}*/ 1431 void EnthalpyAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 1432 _error_("Not implemented yet"); 1433 }/*}}}*/ 1434 void EnthalpyAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 1435 1436 bool converged; 1437 int i,rheology_law; 1438 IssmDouble B_average,s_average,T_average=0.,P_average=0.; 1439 int *doflist = NULL; 1440 IssmDouble *xyz_list = NULL; 1441 1442 /*Fetch number of nodes and dof for this finite element*/ 1443 int numnodes = element->GetNumberOfNodes(); 1444 1445 /*Fetch dof list and allocate solution vector*/ 1446 element->GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 1447 IssmDouble* values = xNew<IssmDouble>(numnodes); 1448 IssmDouble* pressure = xNew<IssmDouble>(numnodes); 1449 IssmDouble* surface = xNew<IssmDouble>(numnodes); 1450 IssmDouble* B = xNew<IssmDouble>(numnodes); 1451 IssmDouble* temperature = xNew<IssmDouble>(numnodes); 1452 IssmDouble* waterfraction = xNew<IssmDouble>(numnodes); 1453 1454 /*Use the dof list to index into the solution vector: */ 1455 for(i=0;i<numnodes;i++){ 1456 values[i]=solution[doflist[i]]; 1457 1458 /*Check solution*/ 1459 if(xIsNan<IssmDouble>(values[i])) _error_("NaN found in solution vector"); 1460 } 1461 1462 /*Get all inputs and parameters*/ 1463 element->GetInputValue(&converged,ConvergedEnum); 1464 element->GetInputListOnNodes(&pressure[0],PressureEnum); 1465 if(converged){ 1466 for(i=0;i<numnodes;i++){ 1467 element->EnthalpyToThermal(&temperature[i],&waterfraction[i],values[i],pressure[i]); 1468 if(waterfraction[i]<0.) _error_("Negative water fraction found in solution vector"); 1469 //if(waterfraction[i]>1.) _error_("Water fraction >1 found in solution vector"); 1470 } 1471 element->AddInput(EnthalpyEnum,values,element->GetElementType()); 1472 element->AddInput(WaterfractionEnum,waterfraction,element->GetElementType()); 1473 element->AddInput(TemperatureEnum,temperature,element->GetElementType()); 1474 1475 /*Update Rheology only if converged (we must make sure that the temperature is below melting point 1476 * otherwise the rheology could be negative*/ 1477 element->FindParam(&rheology_law,MaterialsRheologyLawEnum); 1478 element->GetInputListOnNodes(&surface[0],SurfaceEnum); 1479 switch(rheology_law){ 1480 case NoneEnum: 1481 /*Do nothing: B is not temperature dependent*/ 1482 break; 1483 case CuffeyEnum: 1484 for(i=0;i<numnodes;i++) B[i]=Cuffey(temperature[i]); 1485 element->AddInput(MaterialsRheologyBEnum,&B[0],element->GetElementType()); 1486 break; 1487 case PatersonEnum: 1488 for(i=0;i<numnodes;i++) B[i]=Paterson(temperature[i]); 1489 element->AddInput(MaterialsRheologyBEnum,&B[0],element->GetElementType()); 1490 break; 1491 case ArrheniusEnum: 1492 element->GetVerticesCoordinates(&xyz_list); 1493 for(i=0;i<numnodes;i++) B[i]=Arrhenius(temperature[i],surface[i]-xyz_list[i*3+2],element->GetMaterialParameter(MaterialsRheologyNEnum)); 1494 element->AddInput(MaterialsRheologyBEnum,&B[0],element->GetElementType()); 1495 break; 1496 case LliboutryDuvalEnum: 1497 for(i=0;i<numnodes;i++) B[i]=LliboutryDuval(values[i],pressure[i],element->GetMaterialParameter(MaterialsRheologyNEnum),element->GetMaterialParameter(MaterialsBetaEnum),element->GetMaterialParameter(ConstantsReferencetemperatureEnum),element->GetMaterialParameter(MaterialsHeatcapacityEnum),element->GetMaterialParameter(MaterialsLatentheatEnum)); 1498 element->AddInput(MaterialsRheologyBEnum,&B[0],element->GetElementType()); 1499 break; 1500 default: _error_("Rheology law " << EnumToStringx(rheology_law) << " not supported yet"); 1501 } 1502 } 1503 else{ 1504 element->AddInput(EnthalpyPicardEnum,values,element->GetElementType()); 1505 } 1506 1507 /*Free ressources:*/ 1508 xDelete<IssmDouble>(values); 1509 xDelete<IssmDouble>(pressure); 1510 xDelete<IssmDouble>(surface); 1511 xDelete<IssmDouble>(B); 1512 xDelete<IssmDouble>(temperature); 1513 xDelete<IssmDouble>(waterfraction); 1514 xDelete<IssmDouble>(xyz_list); 1515 xDelete<int>(doflist); 1516 }/*}}}*/ 1517 void EnthalpyAnalysis::PostProcessing(FemModel* femmodel){/*{{{*/ 1518 1519 /*Intermediaries*/ 1520 bool computebasalmeltingrates=true; 1521 bool drainicecolumn=true; 1522 bool isdynamicbasalspc; 1523 IssmDouble dt; 1524 1525 femmodel->parameters->FindParam(&isdynamicbasalspc,ThermalIsdynamicbasalspcEnum); 1526 femmodel->parameters->FindParam(&dt,TimesteppingTimeStepEnum); 1527 1528 //TODO: use dt to decide what to do 1529 if(drainicecolumn) DrainWaterfraction(femmodel); 1530 if(computebasalmeltingrates) ComputeBasalMeltingrate(femmodel); 1531 if(isdynamicbasalspc) UpdateBasalConstraints(femmodel); 1532 1533 }/*}}}*/ 1534 IssmDouble EnthalpyAnalysis::PureIceEnthalpy(Element* element,IssmDouble pressure){/*{{{*/ 1298 1535 1299 1536 IssmDouble heatcapacity = element->GetMaterialParameter(MaterialsHeatcapacityEnum); … … 1302 1539 return heatcapacity*(TMeltingPoint(element,pressure)-referencetemperature); 1303 1540 }/*}}}*/ 1304 IssmDouble EnthalpyAnalysis::TMeltingPoint(Element* element,IssmDouble pressure){/*{{{*/1541 IssmDouble EnthalpyAnalysis::TMeltingPoint(Element* element,IssmDouble pressure){/*{{{*/ 1305 1542 1306 1543 IssmDouble meltingpoint = element->GetMaterialParameter(MaterialsMeltingpointEnum); … … 1309 1546 return meltingpoint-beta*pressure; 1310 1547 }/*}}}*/ 1548 void EnthalpyAnalysis::UpdateBasalConstraints(FemModel* femmodel){/*{{{*/ 1549 1550 /*Update basal dirichlet BCs for enthalpy: */ 1551 Vector<IssmDouble>* spc = NULL; 1552 IssmDouble* serial_spc = NULL; 1553 1554 spc=new Vector<IssmDouble>(femmodel->nodes->NumberOfNodes(EnthalpyAnalysisEnum)); 1555 /*First create a vector to figure out what elements should be constrained*/ 1556 for(int i=0;i<femmodel->elements->Size();i++){ 1557 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 1558 GetBasalConstraints(spc,element); 1559 } 1560 1561 /*Assemble and serialize*/ 1562 spc->Assemble(); 1563 serial_spc=spc->ToMPISerial(); 1564 delete spc; 1565 1566 /*Then update basal constraints nodes accordingly*/ 1567 for(int i=0;i<femmodel->elements->Size();i++){ 1568 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 1569 ApplyBasalConstraints(serial_spc,element); 1570 } 1571 1572 femmodel->UpdateConstraintsx(); 1573 1574 /*Delete*/ 1575 xDelete<IssmDouble>(serial_spc); 1576 }/*}}}*/ 1577 void EnthalpyAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 1578 1579 bool islevelset; 1580 femmodel->parameters->FindParam(&islevelset,TransientIslevelsetEnum); 1581 if(islevelset){ 1582 SetActiveNodesLSMx(femmodel); 1583 } 1584 return; 1585 }/*}}}*/ -
issm/trunk/src/c/analyses/EnthalpyAnalysis.h
r18301 r19105 8 8 /*Headers*/ 9 9 #include "./Analysis.h" 10 #include "../classes/classes.h" 10 11 11 12 class EnthalpyAnalysis: public Analysis{ … … 13 14 public: 14 15 /*Model processing*/ 15 int DofsPerNode(int** doflist,int domaintype,int approximation);16 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum);17 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type);18 void CreateNodes(Nodes* nodes,IoModel* iomodel);19 16 void CreateConstraints(Constraints* constraints,IoModel* iomodel); 20 17 void CreateLoads(Loads* loads, IoModel* iomodel); 18 void CreateNodes(Nodes* nodes,IoModel* iomodel); 19 int DofsPerNode(int** doflist,int domaintype,int approximation); 20 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 21 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum); 21 22 22 23 /*Finite element Analysis*/ 23 void Core(FemModel* femmodel); 24 ElementVector* CreateDVector(Element* element); 25 ElementMatrix* CreateJacobianMatrix(Element* element); 26 ElementMatrix* CreateKMatrix(Element* element); 27 ElementMatrix* CreateKMatrixVolume(Element* element); 28 ElementMatrix* CreateKMatrixShelf(Element* element); 29 ElementVector* CreatePVector(Element* element); 30 ElementVector* CreatePVectorVolume(Element* element); 31 ElementVector* CreatePVectorSheet(Element* element); 32 ElementVector* CreatePVectorShelf(Element* element); 33 void GetBConduct(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss); 34 void GetBAdvec(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss); 35 void GetBAdvecprime(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss); 36 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 37 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 38 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 39 void UpdateConstraints(FemModel* femmodel); 40 41 /*Modules*/ 42 static void PostProcessing(FemModel* femmodel); 43 static void ComputeBasalMeltingrate(Element* element); 44 static void DrainWaterfractionIcecolumn(Element* element); 45 static void DrainWaterfraction(Element* element, IssmDouble* pdrainrate_element); 46 static void UpdateBasalConstraints(Element* element); 47 48 /*Intermediaries*/ 24 static void ApplyBasalConstraints(IssmDouble* serial_spc,Element* element); 25 static void ComputeBasalMeltingrate(FemModel* femmodel); 26 static void ComputeBasalMeltingrate(Element* element); 27 void Core(FemModel* femmodel); 28 ElementVector* CreateDVector(Element* element); 29 ElementMatrix* CreateJacobianMatrix(Element* element); 30 ElementMatrix* CreateKMatrix(Element* element); 31 ElementMatrix* CreateKMatrixVolume(Element* element); 32 ElementMatrix* CreateKMatrixShelf(Element* element); 33 ElementVector* CreatePVector(Element* element); 34 ElementVector* CreatePVectorVolume(Element* element); 35 ElementVector* CreatePVectorSheet(Element* element); 36 ElementVector* CreatePVectorShelf(Element* element); 37 static void DrainWaterfraction(FemModel* femmodel); 38 static void DrainWaterfraction(Element* element, IssmDouble* pdrainrate_element); 39 static void DrainWaterfractionIcecolumn(Element* element); 49 40 static IssmDouble EnthalpyDiffusionParameter(Element* element,IssmDouble enthalpy,IssmDouble pressure); 50 41 static IssmDouble EnthalpyDiffusionParameterVolume(Element* element,int enthalpy_enum); 42 void GetBAdvec(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss); 43 void GetBAdvecprime(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss); 44 static void GetBasalConstraints(Vector<IssmDouble>* vec_spc,Element* element); 45 static void GetBasalConstraintsSteadystate(Vector<IssmDouble>* vec_spc,Element* element); 46 static void GetBasalConstraintsTransient(Vector<IssmDouble>* vec_spc,Element* element); 47 void GetBConduct(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss); 48 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 49 static int GetThermalBasalCondition(Element* element, IssmDouble enthalpy, IssmDouble enthalpy_up, IssmDouble pressure, IssmDouble pressure_up, IssmDouble watercolumn, IssmDouble meltingrate); 50 static IssmDouble GetWetIceConductivity(Element* element, IssmDouble enthalpy, IssmDouble pressure); 51 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 52 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 53 static void PostProcessing(FemModel* femmodel); 51 54 static IssmDouble PureIceEnthalpy(Element* element,IssmDouble pressure); 52 55 static IssmDouble TMeltingPoint(Element* element,IssmDouble pressure); 56 static void UpdateBasalConstraints(FemModel* femmodel); 57 void UpdateConstraints(FemModel* femmodel); 53 58 }; 54 59 #endif -
issm/trunk/src/c/analyses/EnumToAnalysis.cpp
r18301 r19105 86 86 case DepthAverageAnalysisEnum : return new DepthAverageAnalysis(); 87 87 #endif 88 #ifdef _HAVE_SMOOTHEDSURFACESLOPEX_ 89 case SmoothedSurfaceSlopeXAnalysisEnum : return new SmoothedSurfaceSlopeXAnalysis(); 90 #endif 91 #ifdef _HAVE_SMOOTHEDSURFACESLOPEY_ 92 case SmoothedSurfaceSlopeYAnalysisEnum : return new SmoothedSurfaceSlopeYAnalysis(); 88 #ifdef _HAVE_SMOOTH_ 89 case SmoothAnalysisEnum : return new SmoothAnalysis(); 93 90 #endif 94 91 #ifdef _HAVE_THERMAL_ -
issm/trunk/src/c/analyses/ExtrapolationAnalysis.cpp
r18301 r19105 6 6 #include "../solutionsequences/solutionsequences.h" 7 7 8 int ExtrapolationAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/ 8 void ExtrapolationAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 9 // do nothing for now 10 return; 11 } 12 /*}}}*/ 13 void ExtrapolationAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 14 // do nothing for now 15 return; 16 }/*}}}*/ 17 void ExtrapolationAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 18 int finiteelement=P1Enum; 19 if(iomodel->domaintype!=Domain2DhorizontalEnum) iomodel->FetchData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 20 ::CreateNodes(nodes,iomodel,ExtrapolationAnalysisEnum,finiteelement); 21 iomodel->DeleteData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 22 } 23 /*}}}*/ 24 int ExtrapolationAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/ 9 25 return 1; 10 }11 /*}}}*/12 void ExtrapolationAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/13 //do nothing for now14 return;15 26 } 16 27 /*}}}*/ … … 36 47 } 37 48 /*}}}*/ 38 void ExtrapolationAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 39 int finiteelement=P1Enum; 40 if(iomodel->domaintype!=Domain2DhorizontalEnum) iomodel->FetchData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 41 ::CreateNodes(nodes,iomodel,ExtrapolationAnalysisEnum,finiteelement); 42 iomodel->DeleteData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 43 } 44 /*}}}*/ 45 void ExtrapolationAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 46 // do nothing for now 49 void ExtrapolationAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 50 //do nothing for now 47 51 return; 48 52 } 49 53 /*}}}*/ 50 void ExtrapolationAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/51 // do nothing for now52 return;53 }/*}}}*/54 54 55 55 /*Finite element Analysis*/ 56 void ExtrapolationAnalysis::Core(FemModel* femmodel){/*{{{*/56 void ExtrapolationAnalysis::Core(FemModel* femmodel){/*{{{*/ 57 57 58 58 /* Intermediaries */ … … 237 237 return pe; 238 238 }/*}}}*/ 239 void ExtrapolationAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 239 void ExtrapolationAnalysis::GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 240 /*Compute B matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2. 241 * For node i, Bi can be expressed in the actual coordinate system 242 * by: 243 * Bi=[ N ] 244 * [ N ] 245 * where N is the finiteelement function for node i. 246 * 247 * We assume B_prog has been allocated already, of size: 2x(NDOF1*numnodes) 248 */ 249 250 /*Fetch number of nodes for this finite element*/ 251 int numnodes = element->GetNumberOfNodes(); 252 253 /*Get nodal functions*/ 254 IssmDouble* basis=xNew<IssmDouble>(numnodes); 255 element->NodalFunctions(basis,gauss); 256 257 /*Build B: */ 258 for(int i=0;i<numnodes;i++){ 259 B[numnodes*0+i] = basis[i]; 260 B[numnodes*1+i] = basis[i]; 261 } 262 263 /*Clean-up*/ 264 xDelete<IssmDouble>(basis); 265 }/*}}}*/ 266 void ExtrapolationAnalysis::GetBprime(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 267 /*Compute B' matrix. B'=[B1' B2' B3'] where Bi' is of size 3*NDOF2. 268 * For node i, Bi' can be expressed in the actual coordinate system 269 * by: 270 * Bi_prime=[ dN/dx ] 271 * [ dN/dy ] 272 * where N is the finiteelement function for node i. 273 * 274 * We assume B' has been allocated already, of size: 3x(NDOF2*numnodes) 275 */ 276 277 /*Fetch number of nodes for this finite element*/ 278 int numnodes = element->GetNumberOfNodes(); 279 280 /*Get nodal functions derivatives*/ 281 IssmDouble* dbasis=xNew<IssmDouble>(2*numnodes); 282 element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss); 283 284 /*Build B': */ 285 for(int i=0;i<numnodes;i++){ 286 Bprime[numnodes*0+i] = dbasis[0*numnodes+i]; 287 Bprime[numnodes*1+i] = dbasis[1*numnodes+i]; 288 } 289 290 /*Clean-up*/ 291 xDelete<IssmDouble>(dbasis); 292 293 }/*}}}*/ 294 void ExtrapolationAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 240 295 _error_("not implemented yet"); 241 296 }/*}}}*/ 242 void ExtrapolationAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/297 void ExtrapolationAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 243 298 _error_("Not implemented yet"); 244 299 }/*}}}*/ 245 void ExtrapolationAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/300 void ExtrapolationAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 246 301 247 302 int domaintype, extrapolationvariable; … … 258 313 } 259 314 }/*}}}*/ 260 void ExtrapolationAnalysis::GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 261 /*Compute B matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2. 262 * For node i, Bi can be expressed in the actual coordinate system 263 * by: 264 * Bi=[ N ] 265 * [ N ] 266 * where N is the finiteelement function for node i. 267 * 268 * We assume B_prog has been allocated already, of size: 2x(NDOF1*numnodes) 269 */ 270 271 /*Fetch number of nodes for this finite element*/ 272 int numnodes = element->GetNumberOfNodes(); 273 274 /*Get nodal functions*/ 275 IssmDouble* basis=xNew<IssmDouble>(numnodes); 276 element->NodalFunctions(basis,gauss); 277 278 /*Build B: */ 279 for(int i=0;i<numnodes;i++){ 280 B[numnodes*0+i] = basis[i]; 281 B[numnodes*1+i] = basis[i]; 282 } 283 284 /*Clean-up*/ 285 xDelete<IssmDouble>(basis); 286 }/*}}}*/ 287 void ExtrapolationAnalysis::GetBprime(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 288 /*Compute B' matrix. B'=[B1' B2' B3'] where Bi' is of size 3*NDOF2. 289 * For node i, Bi' can be expressed in the actual coordinate system 290 * by: 291 * Bi_prime=[ dN/dx ] 292 * [ dN/dy ] 293 * where N is the finiteelement function for node i. 294 * 295 * We assume B' has been allocated already, of size: 3x(NDOF2*numnodes) 296 */ 297 298 /*Fetch number of nodes for this finite element*/ 299 int numnodes = element->GetNumberOfNodes(); 300 301 /*Get nodal functions derivatives*/ 302 IssmDouble* dbasis=xNew<IssmDouble>(2*numnodes); 303 element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss); 304 305 /*Build B': */ 306 for(int i=0;i<numnodes;i++){ 307 Bprime[numnodes*0+i] = dbasis[0*numnodes+i]; 308 Bprime[numnodes*1+i] = dbasis[1*numnodes+i]; 309 } 310 311 /*Clean-up*/ 312 xDelete<IssmDouble>(dbasis); 313 314 }/*}}}*/ 315 void ExtrapolationAnalysis::SetConstraintsOnIce(Element* element){/*{{{*/ 315 void ExtrapolationAnalysis::SetConstraintsOnIce(Element* element){/*{{{*/ 316 316 317 317 int numnodes=element->GetNumberOfNodes(); … … 347 347 delete gauss; 348 348 }/*}}}*/ 349 void ExtrapolationAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/349 void ExtrapolationAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 350 350 351 351 for(int i=0;i<femmodel->elements->Size();i++){ 352 Element* element= dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));352 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 353 353 this->SetConstraintsOnIce(element); 354 354 } -
issm/trunk/src/c/analyses/ExtrapolationAnalysis.h
r18301 r19105 13 13 public: 14 14 /*Model processing*/ 15 int DofsPerNode(int** doflist,int domaintype,int approximation);16 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum);17 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type);18 void CreateNodes(Nodes* nodes,IoModel* iomodel);19 15 void CreateConstraints(Constraints* constraints,IoModel* iomodel); 20 16 void CreateLoads(Loads* loads, IoModel* iomodel); 17 void CreateNodes(Nodes* nodes,IoModel* iomodel); 18 int DofsPerNode(int** doflist,int domaintype,int approximation); 19 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 20 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum); 21 21 22 22 /*Finite element Analysis*/ … … 26 26 ElementMatrix* CreateKMatrix(Element* element); 27 27 ElementVector* CreatePVector(Element* element); 28 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element);29 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index);30 void InputUpdateFromSolution(IssmDouble* solution,Element* element);31 void UpdateConstraints(FemModel* femmodel);32 void GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss);33 void GetBprime(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss);34 void SetConstraintsOnIce(Element* element);28 void GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss); 29 void GetBprime(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss); 30 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 31 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 32 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 33 void SetConstraintsOnIce(Element* element); 34 void UpdateConstraints(FemModel* femmodel); 35 35 }; 36 36 #endif -
issm/trunk/src/c/analyses/ExtrudeFromBaseAnalysis.cpp
r18301 r19105 6 6 7 7 /*Model processing*/ 8 void ExtrudeFromBaseAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 9 }/*}}}*/ 10 void ExtrudeFromBaseAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 11 }/*}}}*/ 12 void ExtrudeFromBaseAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 13 14 ::CreateNodes(nodes,iomodel,ExtrudeFromBaseAnalysisEnum,P1Enum); 15 16 }/*}}}*/ 8 17 int ExtrudeFromBaseAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/ 9 18 return 1; 10 }/*}}}*/11 void ExtrudeFromBaseAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/12 19 }/*}}}*/ 13 20 void ExtrudeFromBaseAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ … … 26 33 } 27 34 }/*}}}*/ 28 void ExtrudeFromBaseAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 29 30 ::CreateNodes(nodes,iomodel,ExtrudeFromBaseAnalysisEnum,P1Enum); 31 32 }/*}}}*/ 33 void ExtrudeFromBaseAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 34 }/*}}}*/ 35 void ExtrudeFromBaseAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 35 void ExtrudeFromBaseAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 36 36 }/*}}}*/ 37 37 … … 61 61 return Ke; 62 62 }/*}}}*/ 63 ElementMatrix* ExtrudeFromBaseAnalysis::CreateKMatrixBed(Element* element){/*{{{*/ 64 65 if(!element->IsOnBase()) return NULL; 66 67 /*Intermediaries */ 68 int dim; 69 IssmDouble Jdet,D,normal[3]; 70 IssmDouble *xyz_list_base = NULL; 71 72 /*Get dimension*/ 73 element->FindParam(&dim,DomainDimensionEnum); 74 75 /*Fetch number of nodes and dof for this finite element*/ 76 int numnodes = element->GetNumberOfNodes(); 77 78 /*Initialize Element vector and other vectors*/ 79 ElementMatrix* Ke = element->NewElementMatrix(); 80 IssmDouble* basis = xNew<IssmDouble>(numnodes); 81 82 /*Retrieve all inputs and parameters*/ 83 element->GetVerticesCoordinatesBase(&xyz_list_base); 84 element->NormalBase(&normal[0],xyz_list_base); 85 86 /* Start looping on the number of gaussian points: */ 87 Gauss* gauss=element->NewGaussBase(2); 88 for(int ig=gauss->begin();ig<gauss->end();ig++){ 89 gauss->GaussPoint(ig); 90 91 element->JacobianDeterminantBase(&Jdet,xyz_list_base,gauss); 92 element->NodalFunctions(basis,gauss); 93 D = - gauss->weight*Jdet*normal[dim-1]; 94 95 TripleMultiply(basis,1,numnodes,1, 96 &D,1,1,0, 97 basis,1,numnodes,0, 98 &Ke->values[0],1); 99 } 100 101 /*Clean up and return*/ 102 xDelete<IssmDouble>(xyz_list_base); 103 xDelete<IssmDouble>(basis); 104 delete gauss; 105 return Ke; 106 } 107 /*}}}*/ 108 ElementMatrix* ExtrudeFromBaseAnalysis::CreateKMatrixSurface(Element* element){/*{{{*/ 109 110 if(!element->IsOnSurface()) return NULL; 111 112 /*Intermediaries */ 113 int dim; 114 IssmDouble Jdet,D,normal[3]; 115 IssmDouble *xyz_list_top = NULL; 116 117 /*Get dimension*/ 118 element->FindParam(&dim,DomainDimensionEnum); 119 120 /*Fetch number of nodes and dof for this finite element*/ 121 int numnodes = element->GetNumberOfNodes(); 122 123 /*Initialize Element vector and other vectors*/ 124 ElementMatrix* Ke = element->NewElementMatrix(); 125 IssmDouble* basis = xNew<IssmDouble>(numnodes); 126 127 /*Retrieve all inputs and parameters*/ 128 element->GetVerticesCoordinatesTop(&xyz_list_top); 129 element->NormalTop(&normal[0],xyz_list_top); 130 131 /* Start looping on the number of gaussian points: */ 132 Gauss* gauss=element->NewGaussTop(2); 133 for(int ig=gauss->begin();ig<gauss->end();ig++){ 134 gauss->GaussPoint(ig); 135 136 element->JacobianDeterminantTop(&Jdet,xyz_list_top,gauss); 137 element->NodalFunctions(basis,gauss); 138 D = - gauss->weight*Jdet*normal[dim-1]; 139 140 TripleMultiply(basis,1,numnodes,1, 141 &D,1,1,0, 142 basis,1,numnodes,0, 143 &Ke->values[0],1); 144 } 145 146 /*Clean up and return*/ 147 xDelete<IssmDouble>(xyz_list_top); 148 xDelete<IssmDouble>(basis); 149 delete gauss; 150 return Ke; 151 } 152 /*}}}*/ 63 153 ElementMatrix* ExtrudeFromBaseAnalysis::CreateKMatrixVolume(Element* element){/*{{{*/ 64 154 … … 106 196 } 107 197 /*}}}*/ 108 ElementMatrix* ExtrudeFromBaseAnalysis::CreateKMatrixSurface(Element* element){/*{{{*/109 110 if(!element->IsOnSurface()) return NULL;111 112 /*Intermediaries */113 int dim;114 IssmDouble Jdet,D,normal[3];115 IssmDouble *xyz_list_top = NULL;116 117 /*Get dimension*/118 element->FindParam(&dim,DomainDimensionEnum);119 120 /*Fetch number of nodes and dof for this finite element*/121 int numnodes = element->GetNumberOfNodes();122 123 /*Initialize Element vector and other vectors*/124 ElementMatrix* Ke = element->NewElementMatrix();125 IssmDouble* basis = xNew<IssmDouble>(numnodes);126 127 /*Retrieve all inputs and parameters*/128 element->GetVerticesCoordinatesTop(&xyz_list_top);129 element->NormalTop(&normal[0],xyz_list_top);130 131 /* Start looping on the number of gaussian points: */132 Gauss* gauss=element->NewGaussTop(2);133 for(int ig=gauss->begin();ig<gauss->end();ig++){134 gauss->GaussPoint(ig);135 136 element->JacobianDeterminantTop(&Jdet,xyz_list_top,gauss);137 element->NodalFunctions(basis,gauss);138 D = - gauss->weight*Jdet*normal[dim-1];139 140 TripleMultiply(basis,1,numnodes,1,141 &D,1,1,0,142 basis,1,numnodes,0,143 &Ke->values[0],1);144 }145 146 /*Clean up and return*/147 xDelete<IssmDouble>(xyz_list_top);148 xDelete<IssmDouble>(basis);149 delete gauss;150 return Ke;151 }152 /*}}}*/153 ElementMatrix* ExtrudeFromBaseAnalysis::CreateKMatrixBed(Element* element){/*{{{*/154 155 if(!element->IsOnBase()) return NULL;156 157 /*Intermediaries */158 int dim;159 IssmDouble Jdet,D,normal[3];160 IssmDouble *xyz_list_base = NULL;161 162 /*Get dimension*/163 element->FindParam(&dim,DomainDimensionEnum);164 165 /*Fetch number of nodes and dof for this finite element*/166 int numnodes = element->GetNumberOfNodes();167 168 /*Initialize Element vector and other vectors*/169 ElementMatrix* Ke = element->NewElementMatrix();170 IssmDouble* basis = xNew<IssmDouble>(numnodes);171 172 /*Retrieve all inputs and parameters*/173 element->GetVerticesCoordinatesBase(&xyz_list_base);174 element->NormalBase(&normal[0],xyz_list_base);175 176 /* Start looping on the number of gaussian points: */177 Gauss* gauss=element->NewGaussBase(2);178 for(int ig=gauss->begin();ig<gauss->end();ig++){179 gauss->GaussPoint(ig);180 181 element->JacobianDeterminantBase(&Jdet,xyz_list_base,gauss);182 element->NodalFunctions(basis,gauss);183 D = - gauss->weight*Jdet*normal[dim-1];184 185 TripleMultiply(basis,1,numnodes,1,186 &D,1,1,0,187 basis,1,numnodes,0,188 &Ke->values[0],1);189 }190 191 /*Clean up and return*/192 xDelete<IssmDouble>(xyz_list_base);193 xDelete<IssmDouble>(basis);194 delete gauss;195 return Ke;196 }197 /*}}}*/198 198 ElementVector* ExtrudeFromBaseAnalysis::CreatePVector(Element* element){/*{{{*/ 199 199 return NULL; 200 200 }/*}}}*/ 201 void ExtrudeFromBaseAnalysis::GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/201 void ExtrudeFromBaseAnalysis::GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 202 202 /* Compute B matrix. B=[dh1/dz dh2/dz dh3/dz dh4/dz dh5/dz dh6/dz]; 203 203 where hi is the interpolation function for node i.*/ … … 219 219 } 220 220 /*}}}*/ 221 void ExtrudeFromBaseAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/221 void ExtrudeFromBaseAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 222 222 _error_("not implemented yet"); 223 223 }/*}}}*/ 224 void ExtrudeFromBaseAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/224 void ExtrudeFromBaseAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 225 225 _error_("Not implemented yet"); 226 226 }/*}}}*/ 227 void ExtrudeFromBaseAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/227 void ExtrudeFromBaseAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 228 228 229 229 int inputenum; … … 231 231 element->InputUpdateFromSolutionOneDof(solution,inputenum); 232 232 }/*}}}*/ 233 void ExtrudeFromBaseAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/233 void ExtrudeFromBaseAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 234 234 /*Default, do nothing*/ 235 235 return; -
issm/trunk/src/c/analyses/ExtrudeFromBaseAnalysis.h
r18301 r19105 13 13 public: 14 14 /*Model processing*/ 15 int DofsPerNode(int** doflist,int domaintype,int approximation);16 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum);17 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type);18 void CreateNodes(Nodes* nodes,IoModel* iomodel);19 15 void CreateConstraints(Constraints* constraints,IoModel* iomodel); 20 16 void CreateLoads(Loads* loads, IoModel* iomodel); 17 void CreateNodes(Nodes* nodes,IoModel* iomodel); 18 int DofsPerNode(int** doflist,int domaintype,int approximation); 19 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 20 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum); 21 21 22 22 /*Finite element Analysis*/ … … 25 25 ElementMatrix* CreateJacobianMatrix(Element* element); 26 26 ElementMatrix* CreateKMatrix(Element* element); 27 ElementMatrix* CreateKMatrixBed(Element* element); 28 ElementMatrix* CreateKMatrixSurface(Element* element); 27 29 ElementMatrix* CreateKMatrixVolume(Element* element); 28 ElementMatrix* CreateKMatrixSurface(Element* element);29 ElementMatrix* CreateKMatrixBed(Element* element);30 30 ElementVector* CreatePVector(Element* element); 31 void GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss);32 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element);33 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index);34 void InputUpdateFromSolution(IssmDouble* solution,Element* element);35 void UpdateConstraints(FemModel* femmodel);31 void GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 32 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 33 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 34 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 35 void UpdateConstraints(FemModel* femmodel); 36 36 }; 37 37 #endif -
issm/trunk/src/c/analyses/ExtrudeFromTopAnalysis.cpp
r18301 r19105 6 6 7 7 /*Model processing*/ 8 void ExtrudeFromTopAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 9 }/*}}}*/ 10 void ExtrudeFromTopAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 11 }/*}}}*/ 12 void ExtrudeFromTopAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 13 14 ::CreateNodes(nodes,iomodel,ExtrudeFromTopAnalysisEnum,P1Enum); 15 16 }/*}}}*/ 8 17 int ExtrudeFromTopAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/ 9 18 return 1; 10 }/*}}}*/11 void ExtrudeFromTopAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/12 19 }/*}}}*/ 13 20 void ExtrudeFromTopAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ … … 26 33 } 27 34 }/*}}}*/ 28 void ExtrudeFromTopAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 29 30 ::CreateNodes(nodes,iomodel,ExtrudeFromTopAnalysisEnum,P1Enum); 31 32 }/*}}}*/ 33 void ExtrudeFromTopAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 34 }/*}}}*/ 35 void ExtrudeFromTopAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 35 void ExtrudeFromTopAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 36 36 }/*}}}*/ 37 37 … … 199 199 return NULL; 200 200 }/*}}}*/ 201 void ExtrudeFromTopAnalysis::GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/201 void ExtrudeFromTopAnalysis::GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 202 202 /* Compute B matrix. B=[dh1/dz dh2/dz dh3/dz dh4/dz dh5/dz dh6/dz]; 203 203 where hi is the interpolation function for node i.*/ … … 219 219 } 220 220 /*}}}*/ 221 void ExtrudeFromTopAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/221 void ExtrudeFromTopAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 222 222 _error_("not implemented yet"); 223 223 }/*}}}*/ 224 void ExtrudeFromTopAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/224 void ExtrudeFromTopAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 225 225 _error_("Not implemented yet"); 226 226 }/*}}}*/ 227 void ExtrudeFromTopAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/227 void ExtrudeFromTopAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 228 228 229 229 int inputenum; … … 231 231 element->InputUpdateFromSolutionOneDof(solution,inputenum); 232 232 }/*}}}*/ 233 void ExtrudeFromTopAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/233 void ExtrudeFromTopAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 234 234 /*Default, do nothing*/ 235 235 return; -
issm/trunk/src/c/analyses/ExtrudeFromTopAnalysis.h
r18301 r19105 13 13 public: 14 14 /*Model processing*/ 15 int DofsPerNode(int** doflist,int domaintype,int approximation);16 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum);17 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type);18 void CreateNodes(Nodes* nodes,IoModel* iomodel);19 15 void CreateConstraints(Constraints* constraints,IoModel* iomodel); 20 16 void CreateLoads(Loads* loads, IoModel* iomodel); 17 void CreateNodes(Nodes* nodes,IoModel* iomodel); 18 int DofsPerNode(int** doflist,int domaintype,int approximation); 19 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 20 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum); 21 21 22 22 /*Finite element Analysis*/ … … 25 25 ElementMatrix* CreateJacobianMatrix(Element* element); 26 26 ElementMatrix* CreateKMatrix(Element* element); 27 ElementMatrix* CreateKMatrixBed(Element* element); 28 ElementMatrix* CreateKMatrixSurface(Element* element); 27 29 ElementMatrix* CreateKMatrixVolume(Element* element); 28 ElementMatrix* CreateKMatrixSurface(Element* element);29 ElementMatrix* CreateKMatrixBed(Element* element);30 30 ElementVector* CreatePVector(Element* element); 31 void GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss);32 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element);33 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index);34 void InputUpdateFromSolution(IssmDouble* solution,Element* element);35 void UpdateConstraints(FemModel* femmodel);31 void GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 32 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 33 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 34 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 35 void UpdateConstraints(FemModel* femmodel); 36 36 }; 37 37 #endif -
issm/trunk/src/c/analyses/FreeSurfaceBaseAnalysis.cpp
r18301 r19105 6 6 7 7 /*Model processing*/ 8 void FreeSurfaceBaseAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 9 }/*}}}*/ 10 void FreeSurfaceBaseAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 11 12 /*Intermediaries*/ 13 int penpair_ids[2]; 14 int count=0; 15 int numvertex_pairing; 16 17 /*Create Penpair for vertex_pairing: */ 18 IssmDouble *vertex_pairing=NULL; 19 IssmDouble *nodeonbase=NULL; 20 iomodel->FetchData(&vertex_pairing,&numvertex_pairing,NULL,MasstransportVertexPairingEnum); 21 if(iomodel->domaintype!=Domain2DhorizontalEnum) iomodel->FetchData(&nodeonbase,NULL,NULL,MeshVertexonbaseEnum); 22 for(int i=0;i<numvertex_pairing;i++){ 23 24 if(iomodel->my_vertices[reCast<int>(vertex_pairing[2*i+0])-1]){ 25 26 /*In debugging mode, check that the second node is in the same cpu*/ 27 _assert_(iomodel->my_vertices[reCast<int>(vertex_pairing[2*i+1])-1]); 28 29 /*Skip if one of the two is not on the bed*/ 30 if(iomodel->domaintype!=Domain2DhorizontalEnum){ 31 if(!(reCast<bool>(nodeonbase[reCast<int>(vertex_pairing[2*i+0])-1])) || !(reCast<bool>(nodeonbase[reCast<int>(vertex_pairing[2*i+1])-1]))) continue; 32 } 33 34 /*Get node ids*/ 35 penpair_ids[0]=iomodel->nodecounter+reCast<int>(vertex_pairing[2*i+0]); 36 penpair_ids[1]=iomodel->nodecounter+reCast<int>(vertex_pairing[2*i+1]); 37 38 /*Create Load*/ 39 loads->AddObject(new Penpair( 40 iomodel->loadcounter+count+1, 41 &penpair_ids[0], 42 FreeSurfaceBaseAnalysisEnum)); 43 count++; 44 } 45 } 46 47 /*free ressources: */ 48 iomodel->DeleteData(vertex_pairing,MasstransportVertexPairingEnum); 49 iomodel->DeleteData(nodeonbase,MeshVertexonbaseEnum); 50 }/*}}}*/ 51 void FreeSurfaceBaseAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 52 53 if(iomodel->domaintype!=Domain2DhorizontalEnum) iomodel->FetchData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 54 ::CreateNodes(nodes,iomodel,FreeSurfaceBaseAnalysisEnum,P1Enum); 55 iomodel->DeleteData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 56 }/*}}}*/ 8 57 int FreeSurfaceBaseAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/ 9 58 return 1; 10 }/*}}}*/11 void FreeSurfaceBaseAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/12 59 }/*}}}*/ 13 60 void FreeSurfaceBaseAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ … … 43 90 } 44 91 }/*}}}*/ 45 void FreeSurfaceBaseAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 46 47 if(iomodel->domaintype!=Domain2DhorizontalEnum) iomodel->FetchData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 48 ::CreateNodes(nodes,iomodel,FreeSurfaceBaseAnalysisEnum,P1Enum); 49 iomodel->DeleteData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 50 }/*}}}*/ 51 void FreeSurfaceBaseAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 52 }/*}}}*/ 53 void FreeSurfaceBaseAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 54 55 /*Intermediaries*/ 56 int penpair_ids[2]; 57 int count=0; 58 int numvertex_pairing; 59 60 /*Create Penpair for vertex_pairing: */ 61 IssmDouble *vertex_pairing=NULL; 62 IssmDouble *nodeonbase=NULL; 63 iomodel->FetchData(&vertex_pairing,&numvertex_pairing,NULL,MasstransportVertexPairingEnum); 64 if(iomodel->domaintype!=Domain2DhorizontalEnum) iomodel->FetchData(&nodeonbase,NULL,NULL,MeshVertexonbaseEnum); 65 for(int i=0;i<numvertex_pairing;i++){ 66 67 if(iomodel->my_vertices[reCast<int>(vertex_pairing[2*i+0])-1]){ 68 69 /*In debugging mode, check that the second node is in the same cpu*/ 70 _assert_(iomodel->my_vertices[reCast<int>(vertex_pairing[2*i+1])-1]); 71 72 /*Skip if one of the two is not on the bed*/ 73 if(iomodel->domaintype!=Domain2DhorizontalEnum){ 74 if(!(reCast<bool>(nodeonbase[reCast<int>(vertex_pairing[2*i+0])-1])) || !(reCast<bool>(nodeonbase[reCast<int>(vertex_pairing[2*i+1])-1]))) continue; 75 } 76 77 /*Get node ids*/ 78 penpair_ids[0]=iomodel->nodecounter+reCast<int>(vertex_pairing[2*i+0]); 79 penpair_ids[1]=iomodel->nodecounter+reCast<int>(vertex_pairing[2*i+1]); 80 81 /*Create Load*/ 82 loads->AddObject(new Penpair( 83 iomodel->loadcounter+count+1, 84 &penpair_ids[0], 85 FreeSurfaceBaseAnalysisEnum)); 86 count++; 87 } 88 } 89 90 /*free ressources: */ 91 iomodel->DeleteData(vertex_pairing,MasstransportVertexPairingEnum); 92 iomodel->DeleteData(nodeonbase,MeshVertexonbaseEnum); 92 void FreeSurfaceBaseAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 93 93 }/*}}}*/ 94 94 … … 304 304 305 305 }/*}}}*/ 306 void FreeSurfaceBaseAnalysis::GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/306 void FreeSurfaceBaseAnalysis::GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 307 307 /*Compute B matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2. 308 308 * For node i, Bi can be expressed in the actual coordinate system … … 332 332 xDelete<IssmDouble>(basis); 333 333 }/*}}}*/ 334 void FreeSurfaceBaseAnalysis::GetBprime(IssmDouble* Bprime,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/334 void FreeSurfaceBaseAnalysis::GetBprime(IssmDouble* Bprime,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 335 335 /*Compute B' matrix. B'=[B1' B2' B3'] where Bi' is of size 3*NDOF2. 336 336 * For node i, Bi' can be expressed in the actual coordinate system … … 361 361 362 362 }/*}}}*/ 363 void FreeSurfaceBaseAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/363 void FreeSurfaceBaseAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 364 364 _error_("not implemented yet"); 365 365 }/*}}}*/ 366 void FreeSurfaceBaseAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/366 void FreeSurfaceBaseAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 367 367 _error_("Not implemented yet"); 368 368 }/*}}}*/ 369 void FreeSurfaceBaseAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/369 void FreeSurfaceBaseAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 370 370 element->InputUpdateFromSolutionOneDof(solution,BaseEnum); 371 371 }/*}}}*/ 372 void FreeSurfaceBaseAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/372 void FreeSurfaceBaseAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 373 373 374 374 /*Intermediary*/ … … 377 377 for(int i=0;i<femmodel->elements->Size();i++){ 378 378 379 Element* element= dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));379 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 380 380 if(!element->IsOnBase()) continue; 381 381 -
issm/trunk/src/c/analyses/FreeSurfaceBaseAnalysis.h
r18301 r19105 13 13 public: 14 14 /*Model processing*/ 15 int DofsPerNode(int** doflist,int domaintype,int approximation);16 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum);17 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type);18 void CreateNodes(Nodes* nodes,IoModel* iomodel);19 15 void CreateConstraints(Constraints* constraints,IoModel* iomodel); 20 16 void CreateLoads(Loads* loads, IoModel* iomodel); 17 void CreateNodes(Nodes* nodes,IoModel* iomodel); 18 int DofsPerNode(int** doflist,int domaintype,int approximation); 19 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 20 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum); 21 21 22 22 /*Finite element Analysis*/ … … 26 26 ElementMatrix* CreateKMatrix(Element* element); 27 27 ElementVector* CreatePVector(Element* element); 28 void GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss);29 void GetBprime(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss);30 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element);31 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index);32 void InputUpdateFromSolution(IssmDouble* solution,Element* element);33 void UpdateConstraints(FemModel* femmodel);28 void GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 29 void GetBprime(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 30 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 31 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 32 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 33 void UpdateConstraints(FemModel* femmodel); 34 34 }; 35 35 #endif -
issm/trunk/src/c/analyses/FreeSurfaceTopAnalysis.cpp
r18301 r19105 6 6 7 7 /*Model processing*/ 8 void FreeSurfaceTopAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 9 }/*}}}*/ 10 void FreeSurfaceTopAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 11 12 /*Intermediaries*/ 13 int penpair_ids[2]; 14 int count=0; 15 int numvertex_pairing; 16 17 /*Create Penpair for vertex_pairing: */ 18 IssmDouble *vertex_pairing=NULL; 19 IssmDouble *nodeonsurface=NULL; 20 iomodel->FetchData(&vertex_pairing,&numvertex_pairing,NULL,MasstransportVertexPairingEnum); 21 if(iomodel->domaintype!=Domain2DhorizontalEnum) iomodel->FetchData(&nodeonsurface,NULL,NULL,MeshVertexonsurfaceEnum); 22 for(int i=0;i<numvertex_pairing;i++){ 23 24 if(iomodel->my_vertices[reCast<int>(vertex_pairing[2*i+0])-1]){ 25 26 /*In debugging mode, check that the second node is in the same cpu*/ 27 _assert_(iomodel->my_vertices[reCast<int>(vertex_pairing[2*i+1])-1]); 28 29 /*Skip if one of the two is not on the bed*/ 30 if(iomodel->domaintype!=Domain2DhorizontalEnum){ 31 if(!(reCast<bool>(nodeonsurface[reCast<int>(vertex_pairing[2*i+0])-1])) || !(reCast<bool>(nodeonsurface[reCast<int>(vertex_pairing[2*i+1])-1]))) continue; 32 } 33 34 /*Get node ids*/ 35 penpair_ids[0]=iomodel->nodecounter+reCast<int>(vertex_pairing[2*i+0]); 36 penpair_ids[1]=iomodel->nodecounter+reCast<int>(vertex_pairing[2*i+1]); 37 38 /*Create Load*/ 39 loads->AddObject(new Penpair( 40 iomodel->loadcounter+count+1, 41 &penpair_ids[0], 42 FreeSurfaceTopAnalysisEnum)); 43 count++; 44 } 45 } 46 47 /*free ressources: */ 48 iomodel->DeleteData(vertex_pairing,MasstransportVertexPairingEnum); 49 iomodel->DeleteData(nodeonsurface,MeshVertexonsurfaceEnum); 50 }/*}}}*/ 51 void FreeSurfaceTopAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 52 53 if(iomodel->domaintype!=Domain2DhorizontalEnum) iomodel->FetchData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 54 ::CreateNodes(nodes,iomodel,FreeSurfaceTopAnalysisEnum,P1Enum); 55 iomodel->DeleteData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 56 }/*}}}*/ 8 57 int FreeSurfaceTopAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/ 9 58 return 1; 10 }/*}}}*/11 void FreeSurfaceTopAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/12 59 }/*}}}*/ 13 60 void FreeSurfaceTopAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ … … 51 98 } 52 99 }/*}}}*/ 53 void FreeSurfaceTopAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 54 55 if(iomodel->domaintype!=Domain2DhorizontalEnum) iomodel->FetchData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 56 ::CreateNodes(nodes,iomodel,FreeSurfaceTopAnalysisEnum,P1Enum); 57 iomodel->DeleteData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 58 }/*}}}*/ 59 void FreeSurfaceTopAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 60 }/*}}}*/ 61 void FreeSurfaceTopAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 62 63 /*Intermediaries*/ 64 int penpair_ids[2]; 65 int count=0; 66 int numvertex_pairing; 67 68 /*Create Penpair for vertex_pairing: */ 69 IssmDouble *vertex_pairing=NULL; 70 IssmDouble *nodeonsurface=NULL; 71 iomodel->FetchData(&vertex_pairing,&numvertex_pairing,NULL,MasstransportVertexPairingEnum); 72 if(iomodel->domaintype!=Domain2DhorizontalEnum) iomodel->FetchData(&nodeonsurface,NULL,NULL,MeshVertexonsurfaceEnum); 73 for(int i=0;i<numvertex_pairing;i++){ 74 75 if(iomodel->my_vertices[reCast<int>(vertex_pairing[2*i+0])-1]){ 76 77 /*In debugging mode, check that the second node is in the same cpu*/ 78 _assert_(iomodel->my_vertices[reCast<int>(vertex_pairing[2*i+1])-1]); 79 80 /*Skip if one of the two is not on the bed*/ 81 if(iomodel->domaintype!=Domain2DhorizontalEnum){ 82 if(!(reCast<bool>(nodeonsurface[reCast<int>(vertex_pairing[2*i+0])-1])) || !(reCast<bool>(nodeonsurface[reCast<int>(vertex_pairing[2*i+1])-1]))) continue; 83 } 84 85 /*Get node ids*/ 86 penpair_ids[0]=iomodel->nodecounter+reCast<int>(vertex_pairing[2*i+0]); 87 penpair_ids[1]=iomodel->nodecounter+reCast<int>(vertex_pairing[2*i+1]); 88 89 /*Create Load*/ 90 loads->AddObject(new Penpair( 91 iomodel->loadcounter+count+1, 92 &penpair_ids[0], 93 FreeSurfaceTopAnalysisEnum)); 94 count++; 95 } 96 } 97 98 /*free ressources: */ 99 iomodel->DeleteData(vertex_pairing,MasstransportVertexPairingEnum); 100 iomodel->DeleteData(nodeonsurface,MeshVertexonsurfaceEnum); 100 void FreeSurfaceTopAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 101 101 }/*}}}*/ 102 102 … … 307 307 308 308 }/*}}}*/ 309 void FreeSurfaceTopAnalysis::GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/309 void FreeSurfaceTopAnalysis::GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 310 310 /*Compute B matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2. 311 311 * For node i, Bi can be expressed in the actual coordinate system … … 335 335 xDelete<IssmDouble>(basis); 336 336 }/*}}}*/ 337 void FreeSurfaceTopAnalysis::GetBprime(IssmDouble* Bprime,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/337 void FreeSurfaceTopAnalysis::GetBprime(IssmDouble* Bprime,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 338 338 /*Compute B' matrix. B'=[B1' B2' B3'] where Bi' is of size 3*NDOF2. 339 339 * For node i, Bi' can be expressed in the actual coordinate system … … 364 364 365 365 }/*}}}*/ 366 void FreeSurfaceTopAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/366 void FreeSurfaceTopAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 367 367 _error_("not implemented yet"); 368 368 }/*}}}*/ 369 void FreeSurfaceTopAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/369 void FreeSurfaceTopAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 370 370 _error_("Not implemented yet"); 371 371 }/*}}}*/ 372 void FreeSurfaceTopAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/372 void FreeSurfaceTopAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 373 373 374 374 element->InputUpdateFromSolutionOneDof(solution,SurfaceEnum); 375 375 }/*}}}*/ 376 void FreeSurfaceTopAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/376 void FreeSurfaceTopAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 377 377 /*Default, do nothing*/ 378 378 return; -
issm/trunk/src/c/analyses/FreeSurfaceTopAnalysis.h
r18301 r19105 13 13 public: 14 14 /*Model processing*/ 15 int DofsPerNode(int** doflist,int domaintype,int approximation);16 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum);17 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type);18 void CreateNodes(Nodes* nodes,IoModel* iomodel);19 15 void CreateConstraints(Constraints* constraints,IoModel* iomodel); 20 16 void CreateLoads(Loads* loads, IoModel* iomodel); 17 void CreateNodes(Nodes* nodes,IoModel* iomodel); 18 int DofsPerNode(int** doflist,int domaintype,int approximation); 19 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 20 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum); 21 21 22 22 /*Finite element Analysis*/ … … 26 26 ElementMatrix* CreateKMatrix(Element* element); 27 27 ElementVector* CreatePVector(Element* element); 28 void GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss);29 void GetBprime(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss);30 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element);31 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index);32 void InputUpdateFromSolution(IssmDouble* solution,Element* element);33 void UpdateConstraints(FemModel* femmodel);28 void GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 29 void GetBprime(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 30 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 31 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 32 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 33 void UpdateConstraints(FemModel* femmodel); 34 34 }; 35 35 #endif -
issm/trunk/src/c/analyses/GiaAnalysis.cpp
r18301 r19105 6 6 7 7 /*Model processing*/ 8 void GiaAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 9 /*No constraints*/ 10 }/*}}}*/ 11 void GiaAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 12 /*No loads*/ 13 }/*}}}*/ 14 void GiaAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 15 ::CreateNodes(nodes,iomodel,GiaAnalysisEnum,P1Enum); 16 }/*}}}*/ 8 17 int GiaAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/ 9 18 return 1; 10 }/*}}}*/11 void GiaAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/12 19 }/*}}}*/ 13 20 void GiaAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ … … 27 34 iomodel->FetchDataToInput(elements,GiaLithosphereThicknessEnum); 28 35 }/*}}}*/ 29 void GiaAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 30 ::CreateNodes(nodes,iomodel,GiaAnalysisEnum,P1Enum); 31 }/*}}}*/ 32 void GiaAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 33 /*No constraints*/ 34 }/*}}}*/ 35 void GiaAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 36 /*No loads*/ 36 void GiaAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 37 37 }/*}}}*/ 38 38 … … 54 54 _error_("not implemented yet"); 55 55 }/*}}}*/ 56 void GiaAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/56 void GiaAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 57 57 _error_("not implemented yet"); 58 58 }/*}}}*/ 59 void GiaAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/59 void GiaAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 60 60 _error_("Not implemented yet"); 61 61 }/*}}}*/ 62 void GiaAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/62 void GiaAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 63 63 _error_("not implemented yet"); 64 64 }/*}}}*/ 65 void GiaAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/65 void GiaAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 66 66 /*Default, do nothing*/ 67 67 return; -
issm/trunk/src/c/analyses/GiaAnalysis.h
r18301 r19105 13 13 public: 14 14 /*Model processing*/ 15 int DofsPerNode(int** doflist,int domaintype,int approximation);16 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum);17 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type);18 void CreateNodes(Nodes* nodes,IoModel* iomodel);19 15 void CreateConstraints(Constraints* constraints,IoModel* iomodel); 20 16 void CreateLoads(Loads* loads, IoModel* iomodel); 17 void CreateNodes(Nodes* nodes,IoModel* iomodel); 18 int DofsPerNode(int** doflist,int domaintype,int approximation); 19 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 20 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum); 21 21 22 22 /*Finite element Analysis*/ … … 26 26 ElementMatrix* CreateKMatrix(Element* element); 27 27 ElementVector* CreatePVector(Element* element); 28 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element);29 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index);30 void InputUpdateFromSolution(IssmDouble* solution,Element* element);31 void UpdateConstraints(FemModel* femmodel);28 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 29 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 30 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 31 void UpdateConstraints(FemModel* femmodel); 32 32 }; 33 33 #endif -
issm/trunk/src/c/analyses/HydrologyDCEfficientAnalysis.cpp
r18301 r19105 12 12 13 13 int hydrology_model; 14 int eplflip_lock; 15 int eplthickcomp; 14 16 bool isefficientlayer; 15 16 17 /*retrieve some parameters: */ 17 18 iomodel->Constant(&hydrology_model,HydrologyModelEnum); … … 22 23 /*Do we want an efficient layer*/ 23 24 iomodel->Constant(&isefficientlayer,HydrologydcIsefficientlayerEnum); 25 26 /*If not return*/ 24 27 if(!isefficientlayer) return; 25 28 26 /*Nothing for now*/ 29 /*If yes, initialize a flip flop counter*/ 30 iomodel->FetchData(&eplflip_lock,HydrologydcEplflipLockEnum); 31 parameters->AddObject(new IntParam(HydrologydcEplflipLockEnum,eplflip_lock)); 32 33 iomodel->FetchData(&eplthickcomp,HydrologydcEplThickCompEnum); 34 parameters->AddObject(new IntParam(HydrologydcEplThickCompEnum,eplthickcomp)); 35 36 27 37 }/*}}}*/ 28 38 void HydrologyDCEfficientAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ … … 55 65 iomodel->FetchDataToInput(elements,HydrologydcEplInitialThicknessEnum); 56 66 iomodel->FetchDataToInput(elements,HydrologydcEplMaxThicknessEnum); 57 iomodel->FetchDataToInput(elements,HydrologydcSedimentTransmitivityEnum);58 67 iomodel->FetchDataToInput(elements,HydrologydcEplThicknessEnum); 59 if(iomodel->domaintype!=Domain2DhorizontalEnum){68 if(iomodel->domaintype!=Domain2DhorizontalEnum){ 60 69 iomodel->FetchDataToInput(elements,MeshVertexonbaseEnum); 61 70 iomodel->FetchDataToInput(elements,MeshVertexonsurfaceEnum); 62 71 } 63 64 }/*}}}*/ 72 }/*}}}*/ 73 65 74 void HydrologyDCEfficientAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 66 75 … … 79 88 iomodel->DeleteData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 80 89 }/*}}}*/ 90 81 91 void HydrologyDCEfficientAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 82 92 … … 92 102 93 103 IoModelToConstraintsx(constraints,iomodel,HydrologydcSpceplHeadEnum,HydrologyDCEfficientAnalysisEnum,P1Enum); 94 95 }/*}}}*/ 104 }/*}}}*/ 105 96 106 void HydrologyDCEfficientAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 97 107 /*Nothing for now*/ 108 }/*}}}*/ 109 110 void HydrologyDCEfficientAnalysis::InitZigZagCounter(FemModel* femmodel){/*{{{*/ 111 int* eplzigzag_counter =NULL; 112 113 eplzigzag_counter=xNewZeroInit<int>(femmodel->nodes->Size()); 114 femmodel->parameters->AddObject(new IntVecParam(EplZigZagCounterEnum,eplzigzag_counter,femmodel->nodes->Size())); 115 xDelete<int>(eplzigzag_counter); 116 }/*}}}*/ 117 118 void HydrologyDCEfficientAnalysis::ResetCounter(FemModel* femmodel){/*{{{*/ 119 120 int* eplzigzag_counter=NULL; 121 Element* element=NULL; 122 123 femmodel->parameters->FindParam(&eplzigzag_counter,NULL,EplZigZagCounterEnum); 124 for(int i=0;i<femmodel->nodes->Size();i++){ 125 126 eplzigzag_counter[i]=0; 127 } 128 femmodel->parameters->SetParam(eplzigzag_counter,femmodel->nodes->Size(),EplZigZagCounterEnum); 129 xDelete<int>(eplzigzag_counter); 98 130 }/*}}}*/ 99 131 … … 102 134 _error_("not implemented"); 103 135 }/*}}}*/ 136 104 137 ElementVector* HydrologyDCEfficientAnalysis::CreateDVector(Element* element){/*{{{*/ 105 138 /*Default, return NULL*/ 106 139 return NULL; 107 140 }/*}}}*/ 141 108 142 ElementMatrix* HydrologyDCEfficientAnalysis::CreateJacobianMatrix(Element* element){/*{{{*/ 109 143 _error_("Not implemented"); 110 144 }/*}}}*/ 145 111 146 ElementMatrix* HydrologyDCEfficientAnalysis::CreateKMatrix(Element* element){/*{{{*/ 112 147 … … 140 175 return NULL; 141 176 } 177 142 178 /* Intermediaries */ 143 179 IssmDouble D_scalar,Jdet,dt; … … 158 194 basalelement->GetVerticesCoordinates(&xyz_list); 159 195 basalelement->FindParam(&dt,TimesteppingTimeStepEnum); 160 Input* thickness_input = basalelement->GetInput(HydrologydcEplThicknessEnum); _assert_(thickness_input); 196 197 Input* epl_thick_input = basalelement->GetInput(HydrologydcEplThicknessEnum); _assert_(epl_thick_input); 161 198 Input* sed_head_input = basalelement->GetInput(SedimentHeadEnum); 162 199 Input* epl_head_input = basalelement->GetInput(EplHeadEnum); 163 Input* sed_trans_input = basalelement->GetInput(HydrologydcSedimentTransmitivityEnum);164 Input* residual_input = basalelement->GetInput(SedimentHeadResidualEnum);200 Input* thick_input = basalelement->GetInput(ThicknessEnum); 201 Input* base_input = basalelement->GetInput(BaseEnum); 165 202 166 203 IssmDouble epl_specificstoring = EplSpecificStoring(basalelement); … … 172 209 gauss ->GaussPoint(ig); 173 210 basalelement ->JacobianDeterminant(&Jdet,xyz_list,gauss); 174 thickness_input ->GetInputValue(&epl_thickness,gauss);211 epl_thick_input ->GetInputValue(&epl_thickness,gauss); 175 212 176 213 /*Diffusivity*/ … … 194 231 &Ke->values[0],1); 195 232 233 196 234 /*Transfer EPL part*/ 197 transfer=GetHydrologyKMatrixTransfer(basalelement,gauss, thickness_input,sed_head_input,epl_head_input,sed_trans_input,residual_input);198 D_scalar= transfer*gauss->weight*Jdet*dt;235 transfer=GetHydrologyKMatrixTransfer(basalelement,gauss,sed_head_input,epl_head_input,thick_input,base_input); 236 D_scalar=dt*transfer*gauss->weight*Jdet; 199 237 TripleMultiply(basis,numnodes,1,0, 200 238 &D_scalar,1,1,0, … … 211 249 if(domaintype!=Domain2DhorizontalEnum){basalelement->DeleteMaterials(); delete basalelement;}; 212 250 return Ke; 213 214 }/*}}}*/ 251 }/*}}}*/ 252 215 253 ElementVector* HydrologyDCEfficientAnalysis::CreatePVector(Element* element){/*{{{*/ 216 254 … … 266 304 basalelement->FindParam(&dt,TimesteppingTimeStepEnum); 267 305 268 Input* thickness_input = basalelement->GetInput(HydrologydcEplThicknessEnum); _assert_(thickness_input); 269 Input* sed_head_input = basalelement->GetInput(SedimentHeadEnum); 270 Input* epl_head_input = basalelement->GetInput(EplHeadEnum); 271 Input* sed_trans_input = basalelement->GetInput(HydrologydcSedimentTransmitivityEnum); 272 Input* residual_input = basalelement->GetInput(SedimentHeadResidualEnum); _assert_(residual_input); 306 Input* epl_thick_input = basalelement->GetInput(HydrologydcEplThicknessEnum); _assert_(epl_thick_input); 307 Input* sed_head_input = basalelement->GetInput(SedimentHeadEnum); 308 Input* epl_head_input = basalelement->GetInput(EplHeadEnum); 309 Input* thick_input = basalelement->GetInput(ThicknessEnum); 310 Input* base_input = basalelement->GetInput(BaseEnum); 311 Input* residual_input = basalelement->GetInput(SedimentHeadResidualEnum); _assert_(residual_input); 273 312 if(dt!= 0.){old_wh_input = basalelement->GetInput(EplHeadOldEnum); _assert_(old_wh_input);} 274 313 … … 286 325 if(dt!=0.){ 287 326 old_wh_input ->GetInputValue(&water_head,gauss); 288 thickness_input ->GetInputValue(&epl_thickness,gauss);327 epl_thick_input ->GetInputValue(&epl_thickness,gauss); 289 328 290 329 /*Dealing with the epl part of the transfer term*/ 291 transfer=GetHydrologyPVectorTransfer(basalelement,gauss, thickness_input,sed_head_input,epl_head_input,sed_trans_input,residual_input);292 scalar = Jdet*gauss->weight*((water_head*epl_specificstoring*epl_thickness)+( transfer*dt));330 transfer=GetHydrologyPVectorTransfer(basalelement,gauss,sed_head_input,epl_head_input,thick_input,base_input); 331 scalar = Jdet*gauss->weight*((water_head*epl_specificstoring*epl_thickness)+(dt*transfer)); 293 332 for(int i=0;i<numnodes;i++)pe->values[i]+=scalar*basis[i]; 294 333 } … … 314 353 return pe; 315 354 }/*}}}*/ 355 316 356 void HydrologyDCEfficientAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 317 357 element->GetSolutionFromInputsOneDof(solution,EplHeadEnum); 318 358 }/*}}}*/ 359 319 360 void HydrologyDCEfficientAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 320 361 _error_("Not implemented yet"); 321 362 }/*}}}*/ 363 322 364 void HydrologyDCEfficientAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 323 365 366 bool active_element; 324 367 int domaintype,i; 325 368 Element* basalelement=NULL; … … 342 385 343 386 /*Fetch dof list and allocate solution vector*/ 387 IssmDouble* sedhead = xNew<IssmDouble>(numnodes); 388 IssmDouble* eplHeads = xNew<IssmDouble>(numnodes); 389 344 390 basalelement->GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 345 IssmDouble* eplHeads = xNew<IssmDouble>(numnodes); 391 basalelement->GetInputListOnVertices(&sedhead[0],SedimentHeadEnum); 392 393 Input* active_element_input=basalelement->GetInput(HydrologydcMaskEplactiveEltEnum); _assert_(active_element_input); 394 active_element_input->GetInputValue(&active_element); 346 395 347 396 /*Use the dof list to index into the solution vector: */ … … 355 404 /*Free ressources:*/ 356 405 xDelete<IssmDouble>(eplHeads); 406 xDelete<IssmDouble>(sedhead); 357 407 xDelete<int>(doflist); 358 408 if(domaintype!=Domain2DhorizontalEnum){basalelement->DeleteMaterials(); delete basalelement;}; 359 409 } /*}}}*/ 410 360 411 void HydrologyDCEfficientAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 361 412 /*Default, do nothing*/ … … 372 423 return rho_freshwater*g*epl_porosity*(water_compressibility+(epl_compressibility/epl_porosity)); 373 424 }/*}}}*/ 425 374 426 IssmDouble HydrologyDCEfficientAnalysis::SedimentStoring(Element* element){/*{{{*/ 375 427 IssmDouble rho_freshwater = element->GetMaterialParameter(MaterialsRhoFreshwaterEnum); … … 381 433 return rho_freshwater*g*sediment_porosity*sediment_thickness*(water_compressibility+(sediment_compressibility/sediment_porosity)); 382 434 }/*}}}*/ 383 IssmDouble HydrologyDCEfficientAnalysis::GetHydrologyKMatrixTransfer(Element* element, Gauss* gauss, Input* epl_thick_input, Input* sed_head_input, Input* epl_head_input, Input* sed_trans_input, Input* residual_input){/*{{{*/ 384 435 436 IssmDouble HydrologyDCEfficientAnalysis::GetHydrologyKMatrixTransfer(Element* element, Gauss* gauss, Input* sed_head_input, Input* epl_head_input, Input* thick_input, Input* base_input){/*{{{*/ 437 385 438 int transfermethod; 386 IssmDouble epl_thickness; 387 IssmDouble epl_head,sed_head; 388 IssmDouble sediment_transmitivity; 389 IssmDouble leakage,residual,transfer; 390 391 IssmDouble sediment_thickness = element->GetMaterialParameter(HydrologydcSedimentThicknessEnum); 392 IssmDouble sediment_storing = SedimentStoring(element); 393 IssmDouble epl_specificstoring = EplSpecificStoring(element); 439 IssmDouble hmax; 440 IssmDouble epl_head,sediment_head; 441 IssmDouble leakage,transfer; 442 IssmDouble continuum, factor; 443 HydrologyDCInefficientAnalysis* inefanalysis = NULL; 394 444 395 445 element->FindParam(&transfermethod,HydrologydcTransferFlagEnum); 446 396 447 /*Switch between the different transfer methods cases*/ 397 448 switch(transfermethod){ … … 401 452 break; 402 453 case 1: 403 _assert_( epl_thick_input);404 _assert_( sed_head_input);405 _assert_(epl_head_input);406 _assert_(sed_trans_input);407 _assert_(residual_input);408 /* get input */409 epl_thick_input->GetInputValue(&epl_thickness,gauss); 410 sed_head_input->GetInputValue(&sed _head,gauss);454 _assert_(sed_head_input); 455 _assert_(epl_head_input); 456 457 inefanalysis = new HydrologyDCInefficientAnalysis(); 458 hmax = inefanalysis->GetHydrologyDCInefficientHmax(element,gauss,thick_input,base_input); 459 delete inefanalysis; 460 461 sed_head_input->GetInputValue(&sediment_head,gauss); 411 462 epl_head_input->GetInputValue(&epl_head,gauss); 412 sed_trans_input->GetInputValue(&sediment_transmitivity,gauss);413 residual_input->GetInputValue(&residual,gauss);414 463 element->FindParam(&leakage,HydrologydcLeakageFactorEnum); 415 transfer=(sediment_transmitivity)/(sediment_thickness*leakage); 416 /* if(epl_head>sed_head){ */ 417 /* if(residual>0.0){ */ 418 /* transfer=0.0; */ 419 /* } */ 420 /* else{ */ 421 /* transfer=(sediment_transmitivity)/(sediment_thickness*leakage); */ 422 /* //transfer=(epl_specificstoring*epl_thickness*sediment_transmitivity)/(sediment_thickness*leakage); */ 423 /* } */ 424 /* } */ 425 /* else{ */ 426 /* transfer=(sediment_transmitivity)/(sediment_thickness*leakage); */ 427 /* //transfer=(sediment_storing*sediment_transmitivity)/(sediment_thickness*leakage); */ 428 /* } */ 464 465 //Computing continuum function to apply to transfer term, transfer is null only if 466 // epl_head>sediment_head AND sediment_head>h_max 467 continuum=((1.0/(1.0+exp(-20.0*(sediment_head-epl_head)))))+(1.0/(1.0+exp(-20.0*(hmax-sediment_head)))); 468 factor=min(continuum,1.0); 469 transfer=leakage*factor; 429 470 break; 430 471 default: 431 472 _error_("no case higher than 1 for the Transfer method"); 432 473 } 433 434 474 return transfer; 435 475 }/*}}}*/ 436 IssmDouble HydrologyDCEfficientAnalysis::GetHydrologyPVectorTransfer(Element* element, Gauss* gauss, Input* epl_thick_input, Input* sed_head_input, Input* epl_head_input, Input* sed_trans_input, Input* residual_input){/*{{{*/ 476 477 IssmDouble HydrologyDCEfficientAnalysis::GetHydrologyPVectorTransfer(Element* element, Gauss* gauss, Input* sed_head_input, Input* epl_head_input, Input* thick_input, Input* base_input){/*{{{*/ 437 478 438 479 int transfermethod; 439 IssmDouble epl_thickness;480 IssmDouble hmax; 440 481 IssmDouble epl_head,sediment_head; 441 IssmDouble sediment_transmitivity; 442 IssmDouble leakage,residual,transfer; 443 444 IssmDouble sediment_thickness = element->GetMaterialParameter(HydrologydcSedimentThicknessEnum); 445 IssmDouble sediment_storing = SedimentStoring(element); 446 IssmDouble epl_specificstoring = EplSpecificStoring(element); 482 IssmDouble leakage,transfer; 483 IssmDouble continuum, factor; 484 485 HydrologyDCInefficientAnalysis* inefanalysis = NULL; 447 486 448 487 element->FindParam(&transfermethod,HydrologydcTransferFlagEnum); 488 449 489 /*Switch between the different transfer methods cases*/ 450 490 switch(transfermethod){ … … 454 494 break; 455 495 case 1: 456 _assert_( epl_thick_input);457 _assert_( sed_head_input);458 _assert_(epl_head_input); 459 _assert_(sed_trans_input);460 _assert_(residual_input);461 /* get input */462 epl_thick_input->GetInputValue(&epl_thickness,gauss);496 _assert_(sed_head_input); 497 _assert_(epl_head_input); 498 499 inefanalysis = new HydrologyDCInefficientAnalysis(); 500 hmax = inefanalysis->GetHydrologyDCInefficientHmax(element,gauss,thick_input,base_input); 501 delete inefanalysis; 502 463 503 sed_head_input->GetInputValue(&sediment_head,gauss); 464 504 epl_head_input->GetInputValue(&epl_head,gauss); 465 sed_trans_input->GetInputValue(&sediment_transmitivity,gauss);466 residual_input->GetInputValue(&residual,gauss);467 505 element->FindParam(&leakage,HydrologydcLeakageFactorEnum); 468 transfer=(sediment_transmitivity*sediment_head)/(sediment_thickness*leakage); 469 /* if(epl_head>sediment_head){ */ 470 /* if(residual>0.0){ */ 471 /* transfer=0.0; */ 472 /* } */ 473 /* else{ */ 474 /* transfer=(sediment_transmitivity*sediment_head)/(sediment_thickness*leakage); */ 475 /* //transfer=(epl_specificstoring*epl_thickness*sediment_transmitivity*sediment_head)/(sediment_thickness*leakage); */ 476 /* } */ 477 /* } */ 478 /* else{ */ 479 /* transfer=(sediment_transmitivity*sediment_head)/(sediment_thickness*leakage); */ 480 /* //transfer=(sediment_storing*sediment_transmitivity*sediment_head)/(sediment_thickness*leakage); */ 481 /* } */ 506 507 //Computing continuum function to apply to transfer term, transfer is null only if 508 // epl_head>sediment_head AND sediment_head>h_max 509 continuum=((1.0/(1.0+exp(-20.0*(sediment_head-epl_head)))))+(1.0/(1.0+exp(-20.0*(hmax-sediment_head)))); 510 factor=min(continuum,1.0); 511 transfer=sediment_head*leakage*factor; 512 482 513 break; 483 514 default: 484 515 _error_("no case higher than 1 for the Transfer method"); 485 516 } 517 486 518 return transfer; 487 519 }/*}}}*/ … … 490 522 491 523 bool active_element; 524 int iseplthickcomp; 492 525 int domaintype; 493 526 IssmDouble dt,A,B; … … 495 528 IssmDouble EPL_N; 496 529 530 497 531 femmodel->parameters->FindParam(&domaintype,DomainTypeEnum); 498 532 … … 500 534 501 535 Element* element=(Element*)femmodel->elements->GetObjectByOffset(j); 536 element->parameters->FindParam(&iseplthickcomp,HydrologydcEplThickCompEnum); 537 if(iseplthickcomp==0) return; 502 538 503 539 switch(domaintype){ 504 540 case Domain2DhorizontalEnum: 505 if(!element->IsOnBase()) return; 541 if(!element->IsOnBase()) return; 506 542 B = element->GetMaterialParameter(MaterialsRheologyBbarEnum); 507 543 break; … … 512 548 _error_("not Implemented Yet"); 513 549 } 514 550 515 551 int numnodes = element->GetNumberOfNodes(); 516 552 IssmDouble* thickness = xNew<IssmDouble>(numnodes); … … 544 580 element->GetInputListOnVertices(&ice_thickness[0],ThicknessEnum); 545 581 element->GetInputListOnVertices(&bed[0],BaseEnum); 546 582 547 583 if(!active_element){ 548 584 … … 556 592 557 593 /*Compute first the effective pressure in the EPL*/ 558 EPL_N=gravity*((rho_ice*ice_thickness[i])-(rho_water* (eplhead[i]-bed[i])));594 EPL_N=gravity*((rho_ice*ice_thickness[i])-(rho_water*max(0.0,(eplhead[i]-bed[i])))); 559 595 if(EPL_N<0.0)EPL_N=0.0; 560 596 /*Get then the square of the gradient of EPL heads*/ 561 EPLgrad2 = (epl_slopeX[i] +epl_slopeY[i])*(epl_slopeX[i]+epl_slopeY[i]);597 EPLgrad2 = (epl_slopeX[i]*epl_slopeX[i])+(epl_slopeY[i]*epl_slopeY[i]); 562 598 563 599 /*And proceed to the real thing*/ 564 thickness[i] = old_thickness[i]*(1+((rho_water*gravity*dt)/(rho_ice*latentheat))*epl_conductivity*EPLgrad2-2.0*(A*dt/(pow(n,n)))*(pow(EPL_N,n))); 600 thickness[i] = old_thickness[i]*(1.0+((rho_water*gravity*dt)/(rho_ice*latentheat))*epl_conductivity*EPLgrad2- 601 (2.0*(A*dt/(pow(n,n)))*(pow(EPL_N,n)))); 565 602 566 603 /*Take care of otherthikening*/ … … 579 616 xDelete<IssmDouble>(bed); 580 617 } 581 } 582 /*}}}*/ 618 }/*}}}*/ 619 583 620 void HydrologyDCEfficientAnalysis::GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 584 621 /*Compute B matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2. … … 608 645 xDelete<IssmDouble>(dbasis); 609 646 }/*}}}*/ 610 void HydrologyDCEfficientAnalysis::HydrologyEPLGetMask(Vector<IssmDouble>* vec_mask,Element* element){ 647 648 void HydrologyDCEfficientAnalysis::HydrologyEPLGetMask(Vector<IssmDouble>* vec_mask, Vector<IssmDouble>* recurence, int* eplzigzag_counter, Element* element){ 611 649 612 650 bool active_element; … … 615 653 IssmDouble h_max; 616 654 IssmDouble sedheadmin; 617 Element* basalelement=NULL;655 Element* basalelement=NULL; 618 656 619 657 /*Get basal element*/ … … 629 667 default: _error_("mesh "<<EnumToStringx(domaintype)<<" not supported yet"); 630 668 } 631 632 669 /*Intermediaries*/ 633 634 670 int numnodes =basalelement->GetNumberOfNodes(); 635 671 IssmDouble* epl_thickness =xNew<IssmDouble>(numnodes); … … 638 674 IssmDouble* eplhead =xNew<IssmDouble>(numnodes); 639 675 IssmDouble* residual =xNew<IssmDouble>(numnodes); 640 641 IssmDouble init_thick = basalelement->GetMaterialParameter(HydrologydcEplInitialThicknessEnum); 676 677 IssmDouble init_thick =basalelement->GetMaterialParameter(HydrologydcEplInitialThicknessEnum); 678 IssmDouble colapse_thick =basalelement->GetMaterialParameter(HydrologydcEplColapseThicknessEnum); 642 679 643 680 Input* active_element_input=basalelement->GetInput(HydrologydcMaskEplactiveEltEnum); _assert_(active_element_input); … … 653 690 sedheadmin=sedhead[0]; 654 691 for(i=1;i<numnodes;i++) if(sedhead[i]<=sedheadmin)sedheadmin=sedhead[i]; 655 656 692 for(i=0;i<numnodes;i++){ 657 /*Activate EPL if residual is >0 */ 693 /*If node is now closed bring its thickness back to initial*/ 694 if (old_active[i]==0.){ 695 epl_thickness[i]=init_thick; 696 } 697 698 /*Now starting to look at the activations*/ 658 699 if(residual[i]>0.){ 659 700 vec_mask->SetValue(basalelement->nodes[i]->Sid(),1.,INS_VAL); 660 }661 662 /*If mask was already one, keep one */701 if(old_active[i]==0.) recurence->SetValue(basalelement->nodes[i]->Sid(),1.,INS_VAL); 702 } 703 /*If mask was already one, keep one or colapse*/ 663 704 else if(old_active[i]>0.){ 664 705 vec_mask->SetValue(basalelement->nodes[i]->Sid(),1.,INS_VAL); 665 /*If epl thickness gets under 10-3 initialthickness, close the layer*/666 if(epl_thickness[i]< 0.001*init_thick){706 /*If epl thickness gets under colapse thickness, close the layer*/ 707 if(epl_thickness[i]<colapse_thick){ 667 708 vec_mask->SetValue(basalelement->nodes[i]->Sid(),0.,INS_VAL); 668 epl_thickness[i]=init_thick;709 recurence->SetValue(basalelement->nodes[i]->Sid(),1.,INS_VAL); 669 710 } 670 711 } … … 673 714 if(eplhead[i]>=h_max && active_element){ 674 715 for(j=0;j<numnodes;j++){ 675 if(old_active[j]>0.){676 vec_mask->SetValue(basalelement->nodes[i]->Sid(),1.,INS_VAL);677 }678 716 /*Increase of the domain is on the downstream node in term of sediment head*/ 679 717 if(sedhead[j] == sedheadmin){ 680 718 vec_mask->SetValue(basalelement->nodes[j]->Sid(),1.,INS_VAL); 719 if(old_active[i]==0.) recurence->SetValue(basalelement->nodes[i]->Sid(),1.,INS_VAL); 681 720 } 682 721 } 683 722 } 684 723 } 724 basalelement->AddInput(HydrologydcEplThicknessEnum,epl_thickness,basalelement->GetElementType()); 725 685 726 if(domaintype!=Domain2DhorizontalEnum){basalelement->DeleteMaterials(); delete basalelement;}; 686 727 xDelete<IssmDouble>(epl_thickness); … … 691 732 } 692 733 /*}}}*/ 734 693 735 void HydrologyDCEfficientAnalysis::HydrologyEPLGetActive(Vector<IssmDouble>* active_vec, Element* element){ 694 736 /*Constants*/ 695 696 737 int domaintype; 697 738 Element* basalelement=NULL; … … 713 754 IssmDouble flag = 0.; 714 755 IssmDouble* active = xNew<IssmDouble>(numnodes); 715 756 757 /*Pass the activity mask from elements to nodes*/ 716 758 basalelement->GetInputListOnVertices(&active[0],HydrologydcMaskEplactiveNodeEnum); 759 bool active_element; 760 Input* active_element_input=basalelement->GetInput(HydrologydcMaskEplactiveEltEnum); _assert_(active_element_input); 761 active_element_input->GetInputValue(&active_element); 717 762 718 763 for(int i=0;i<numnodes;i++) flag+=active[i]; 719 764 765 /*If any node is active all the node in the element are active*/ 720 766 if(flag>0.){ 721 767 for(int i=0;i<numnodes;i++){ 722 768 active_vec->SetValue(basalelement->nodes[i]->Sid(),1.,INS_VAL); 723 769 } 770 } 771 /*If the element is active all its nodes are active*/ 772 else if(active_element){ 773 for(int i=0;i<numnodes;i++){ 774 active_vec->SetValue(basalelement->nodes[i]->Sid(),1.,INS_VAL); 775 } 724 776 } 725 777 else{ -
issm/trunk/src/c/analyses/HydrologyDCEfficientAnalysis.h
r18301 r19105 20 20 void CreateConstraints(Constraints* constraints,IoModel* iomodel); 21 21 void CreateLoads(Loads* loads, IoModel* iomodel); 22 22 void InitZigZagCounter(FemModel* femmodel); 23 void ResetCounter(FemModel* femmodel); 24 23 25 /*Finite element Analysis*/ 24 26 void Core(FemModel* femmodel); … … 36 38 IssmDouble EplSpecificStoring(Element* element); 37 39 IssmDouble SedimentStoring(Element* element); 38 IssmDouble GetHydrologyKMatrixTransfer(Element* element, Gauss* gauss, Input* epl_thick_input, Input* sed_head_input, Input* epl_head_input, Input* sed_trans_input, Input* residual_input);39 IssmDouble GetHydrologyPVectorTransfer(Element* element, Gauss* gauss, Input* epl_thick_input, Input* sed_head_input, Input* epl_head_input, Input* sed_trans_input, Input* residual_input);40 void HydrologyEPLGetMask(Vector<IssmDouble>* vec_mask, Element* element);40 IssmDouble GetHydrologyKMatrixTransfer(Element* element, Gauss* gauss, Input* sed_head_input, Input* epl_head_input, Input* thick_input, Input* base_input); 41 IssmDouble GetHydrologyPVectorTransfer(Element* element, Gauss* gauss, Input* sed_head_input, Input* epl_head_input, Input* thick_input, Input* base_input); 42 void HydrologyEPLGetMask(Vector<IssmDouble>* vec_mask, Vector<IssmDouble>* recurence, int* eplzigzag_counter, Element* element); 41 43 void HydrologyEPLGetActive(Vector<IssmDouble>* active_vec, Element* element); 42 44 void GetHydrologyDCInefficientHmax(IssmDouble* ph_max,Element* element, Node* innode); -
issm/trunk/src/c/analyses/HydrologyDCInefficientAnalysis.cpp
r18301 r19105 10 10 return 1; 11 11 }/*}}}*/ 12 12 13 void HydrologyDCInefficientAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 13 14 … … 55 56 parameters->AddObject(new IntParam(HydrologydcPenaltyLockEnum,penalty_lock)); 56 57 parameters->AddObject(new IntParam(HydrologydcMaxIterEnum,hydro_maxiter)); 57 58 }/*}}}*/ 58 }/*}}}*/ 59 59 60 void HydrologyDCInefficientAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ 60 61 61 62 bool isefficientlayer; 63 bool element_active; 62 64 int hydrology_model; 63 65 64 66 /*Fetch data needed: */ 65 67 iomodel->Constant(&hydrology_model,HydrologyModelEnum); … … 93 95 } 94 96 95 if(isefficientlayer)iomodel->FetchDataToInput(elements,HydrologydcMaskEplactiveNodeEnum); 96 }/*}}}*/ 97 if(isefficientlayer){ 98 iomodel->FetchDataToInput(elements,HydrologydcMaskEplactiveNodeEnum); 99 } 100 }/*}}}*/ 101 97 102 void HydrologyDCInefficientAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 98 103 … … 108 113 iomodel->DeleteData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 109 114 }/*}}}*/ 115 110 116 void HydrologyDCInefficientAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 111 117 … … 117 123 IoModelToConstraintsx(constraints,iomodel,HydrologydcSpcsedimentHeadEnum,HydrologyDCInefficientAnalysisEnum,P1Enum); 118 124 }/*}}}*/ 125 119 126 void HydrologyDCInefficientAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 120 127 … … 148 155 _error_("not implemented"); 149 156 }/*}}}*/ 157 150 158 ElementVector* HydrologyDCInefficientAnalysis::CreateDVector(Element* element){/*{{{*/ 151 159 /*Default, return NULL*/ 152 160 return NULL; 153 161 }/*}}}*/ 162 154 163 ElementMatrix* HydrologyDCInefficientAnalysis::CreateJacobianMatrix(Element* element){/*{{{*/ 155 164 _error_("Not implemented"); 156 165 }/*}}}*/ 166 157 167 ElementMatrix* HydrologyDCInefficientAnalysis::CreateKMatrix(Element* element){/*{{{*/ 158 168 … … 197 207 basalelement ->FindParam(&dt,TimesteppingTimeStepEnum); 198 208 basalelement ->FindParam(&isefficientlayer,HydrologydcIsefficientlayerEnum); 199 200 Input* epl_thick_input = basalelement->GetInput(HydrologydcEplThicknessEnum); 201 Input* sed_head_input = basalelement->GetInput(SedimentHeadEnum); 202 Input* epl_head_input = basalelement->GetInput(EplHeadEnum); 203 Input* thickness_input = basalelement->GetInput(ThicknessEnum); 204 Input* base_input = basalelement->GetInput(BaseEnum); 205 Input* SedTrans_input = basalelement->GetInput(HydrologydcSedimentTransmitivityEnum); _assert_(SedTrans_input); 209 Input* SedTrans_input = basalelement->GetInput(HydrologydcSedimentTransmitivityEnum); _assert_(SedTrans_input); 210 Input* sed_head_input = basalelement->GetInput(SedimentHeadEnum); 211 Input* epl_head_input = basalelement->GetInput(EplHeadEnum); 212 Input* thick_input = basalelement->GetInput(ThicknessEnum); 213 Input* base_input = basalelement->GetInput(BaseEnum); 214 206 215 IssmDouble sediment_storing = SedimentStoring(basalelement); 207 216 /*Transfer related Inputs*/ … … 240 249 active_element_input->GetInputValue(&active_element); 241 250 if(active_element){ 242 transfer=GetHydrologyKMatrixTransfer(basalelement,gauss, epl_thick_input,sed_head_input,epl_head_input,SedTrans_input,thickness_input,base_input);251 transfer=GetHydrologyKMatrixTransfer(basalelement,gauss,sed_head_input,epl_head_input,thick_input,base_input); 243 252 basalelement->NodalFunctions(&basis[0],gauss); 244 D_scalar= transfer*gauss->weight*Jdet*dt;253 D_scalar=dt*transfer*gauss->weight*Jdet; 245 254 TripleMultiply(basis,numnodes,1,0, 246 255 &D_scalar,1,1,0, … … 259 268 return Ke; 260 269 }/*}}}*/ 270 261 271 ElementVector* HydrologyDCInefficientAnalysis::CreatePVector(Element* element){/*{{{*/ 262 272 … … 301 311 basalelement->FindParam(&isefficientlayer,HydrologydcIsefficientlayerEnum); 302 312 303 Input* epl_thick_input = basalelement->GetInput(HydrologydcEplThicknessEnum); 304 Input* sed_head_input = basalelement->GetInput(SedimentHeadEnum); 305 Input* epl_head_input = basalelement->GetInput(EplHeadEnum); 306 Input* sed_trans_input = basalelement->GetInput(HydrologydcSedimentTransmitivityEnum); 307 Input* thickness_input = basalelement->GetInput(ThicknessEnum); 308 Input* base_input = basalelement->GetInput(BaseEnum); 309 Input* water_input = basalelement->GetInput(BasalforcingsGroundediceMeltingRateEnum); _assert_(water_input); 313 Input* sed_head_input = basalelement->GetInput(SedimentHeadEnum); 314 Input* epl_head_input = basalelement->GetInput(EplHeadEnum); 315 Input* water_input = basalelement->GetInput(BasalforcingsGroundediceMeltingRateEnum); _assert_(water_input); 316 Input* thick_input = basalelement->GetInput(ThicknessEnum); 317 Input* base_input = basalelement->GetInput(BaseEnum); 310 318 if(dt!= 0.){old_wh_input = basalelement->GetInput(SedimentHeadOldEnum); _assert_(old_wh_input);} 311 319 … … 327 335 /*Loading term*/ 328 336 water_input->GetInputValue(&water_load,gauss); 329 330 337 scalar = Jdet*gauss->weight*(water_load); 331 332 338 if(dt!=0.) scalar = scalar*dt; 333 339 for(int i=0;i<numnodes;i++){ … … 342 348 active_element_input->GetInputValue(&active_element); 343 349 if(active_element){ 344 transfer=GetHydrologyPVectorTransfer(basalelement,gauss, epl_thick_input,sed_head_input,epl_head_input,sed_trans_input,thickness_input,base_input);350 transfer=GetHydrologyPVectorTransfer(basalelement,gauss,sed_head_input,epl_head_input,thick_input,base_input); 345 351 } 346 352 else{ … … 363 369 return pe; 364 370 }/*}}}*/ 371 365 372 void HydrologyDCInefficientAnalysis::GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 366 373 /*Compute B matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2. … … 390 397 xDelete<IssmDouble>(dbasis); 391 398 }/*}}}*/ 399 392 400 void HydrologyDCInefficientAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 393 401 element->GetSolutionFromInputsOneDof(solution,SedimentHeadEnum); 394 402 }/*}}}*/ 403 395 404 void HydrologyDCInefficientAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 396 405 _error_("Not implemented yet"); 397 406 }/*}}}*/ 407 398 408 void HydrologyDCInefficientAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 399 409 … … 456 466 residual[i] = 0.; 457 467 } 458 pressure[i]=(rho_ice*g*thickness[i])-(rho_freshwater*g*(min(h_max,values[i])-base[i])); 468 //adding base in min to take into account heads under bed wich don't change N 469 pressure[i]=(rho_ice*g*thickness[i])-(rho_freshwater*g*(max((min(h_max,values[i])-base[i]),0.0))); 459 470 } 460 471 xDelete<IssmDouble>(thickness); … … 474 485 if(domaintype!=Domain2DhorizontalEnum){basalelement->DeleteMaterials(); delete basalelement;}; 475 486 }/*}}}*/ 487 476 488 void HydrologyDCInefficientAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 477 489 /*Default, do nothing*/ … … 536 548 return h_max; 537 549 }/*}}}*/ 550 538 551 void HydrologyDCInefficientAnalysis::GetHydrologyDCInefficientHmax(IssmDouble* ph_max,Element* element, Node* innode){/*{{{*/ 539 552 … … 571 584 } 572 585 /*}}}*/ 573 IssmDouble HydrologyDCInefficientAnalysis::GetHydrologyKMatrixTransfer(Element* element, Gauss* gauss, Input* epl_thick_input, Input* sed_head_input, Input* epl_head_input, Input* sed_trans_input, Input* thickness_input, Input* base_input){/*{{{*/ 586 587 IssmDouble HydrologyDCInefficientAnalysis::GetHydrologyKMatrixTransfer(Element* element, Gauss* gauss, Input* sed_head_input, Input* epl_head_input, Input* thick_input, Input* base_input){/*{{{*/ 574 588 575 589 int transfermethod; 576 IssmDouble epl_thickness; 577 IssmDouble epl_head,sed_head; 578 IssmDouble sediment_transmitivity; 579 IssmDouble leakage,h_max,transfer; 580 581 IssmDouble sediment_thickness = element->GetMaterialParameter(HydrologydcSedimentThicknessEnum); 582 IssmDouble sediment_storing = SedimentStoring(element); 583 IssmDouble epl_specificstoring = EplSpecificStoring(element); 584 590 IssmDouble hmax; 591 IssmDouble epl_head,sediment_head; 592 IssmDouble leakage,transfer; 593 IssmDouble continuum, factor; 594 585 595 element->FindParam(&transfermethod,HydrologydcTransferFlagEnum); 596 586 597 /*Switch between the different transfer methods cases*/ 587 598 switch(transfermethod){ … … 591 602 break; 592 603 case 1: 593 594 _assert_(epl_thick_input);595 604 _assert_(sed_head_input); 596 605 _assert_(epl_head_input); 597 _assert_(sed_trans_input); 598 _assert_(thickness_input); 599 _assert_(base_input); 600 601 epl_thick_input->GetInputValue(&epl_thickness,gauss); 602 sed_head_input->GetInputValue(&sed_head,gauss); 606 607 sed_head_input->GetInputValue(&sediment_head,gauss); 603 608 epl_head_input->GetInputValue(&epl_head,gauss); 604 sed_trans_input->GetInputValue(&sediment_transmitivity,gauss);605 609 element->FindParam(&leakage,HydrologydcLeakageFactorEnum); 606 607 transfer=(sediment_transmitivity)/(sediment_thickness*leakage); 608 609 /* if(epl_head>sed_head){ */ 610 /* h_max=GetHydrologyDCInefficientHmax(element,gauss,thickness_input,base_input); */ 611 /* if(sed_head>=h_max){ */ 612 /* transfer=0.0; */ 613 /* } */ 614 /* else{ */ 615 /* transfer=(sediment_transmitivity)/(sediment_thickness*leakage); */ 616 /* //transfer=(epl_specificstoring*epl_thickness*sediment_transmitivity)/(sediment_thickness*leakage); */ 617 /* } */ 618 /* } */ 619 /* else{ */ 620 /* transfer=(sediment_transmitivity)/(sediment_thickness*leakage); */ 621 /* //transfer=(sediment_storing*sediment_transmitivity)/(sediment_thickness*leakage); */ 622 /* } */ 623 610 611 hmax=GetHydrologyDCInefficientHmax(element, gauss, thick_input, base_input); 612 613 //Computing continuum function to apply to transfer term, transfer is null only if 614 //epl_head>sediment_head AND sediment_head>h_max 615 continuum=((1.0/(1.0+exp(-20.0*(sediment_head-epl_head)))))+(1.0/(1.0+exp(-20.0*(hmax-sediment_head)))); 616 factor=min(continuum,1.0); 617 transfer=leakage*factor; 618 624 619 break; 625 620 default: 626 621 _error_("no case higher than 1 for the Transfer method"); 627 622 } 628 629 623 return transfer; 630 624 }/*}}}*/ 631 625 632 IssmDouble HydrologyDCInefficientAnalysis::GetHydrologyPVectorTransfer(Element* element, Gauss* gauss, Input* epl_thick_input, Input* sed_head_input, Input* epl_head_input, Input* sed_trans_input, Input* thickness_input, Input* base_input){/*{{{*/626 IssmDouble HydrologyDCInefficientAnalysis::GetHydrologyPVectorTransfer(Element* element, Gauss* gauss, Input* sed_head_input, Input* epl_head_input, Input* thick_input, Input* base_input){/*{{{*/ 633 627 634 628 int transfermethod; 635 IssmDouble epl_thickness;629 IssmDouble hmax; 636 630 IssmDouble epl_head,sediment_head; 637 IssmDouble sediment_transmitivity; 638 IssmDouble leakage,h_max,transfer; 639 640 IssmDouble sediment_thickness = element->GetMaterialParameter(HydrologydcSedimentThicknessEnum); 641 IssmDouble sediment_storing = SedimentStoring(element); 642 IssmDouble epl_specificstoring = EplSpecificStoring(element); 643 631 IssmDouble leakage,transfer; 632 IssmDouble continuum, factor; 633 644 634 element->FindParam(&transfermethod,HydrologydcTransferFlagEnum); 635 645 636 /*Switch between the different transfer methods cases*/ 646 637 switch(transfermethod){ … … 650 641 break; 651 642 case 1: 652 653 _assert_(epl_thick_input);654 643 _assert_(sed_head_input); 655 644 _assert_(epl_head_input); 656 _assert_(sed_trans_input); 657 _assert_(thickness_input); 658 _assert_(base_input); 659 660 epl_thick_input->GetInputValue(&epl_thickness,gauss); 645 661 646 sed_head_input->GetInputValue(&sediment_head,gauss); 662 647 epl_head_input->GetInputValue(&epl_head,gauss); 663 sed_trans_input->GetInputValue(&sediment_transmitivity,gauss);664 665 648 element->FindParam(&leakage,HydrologydcLeakageFactorEnum); 666 transfer=(sediment_transmitivity*epl_head)/(sediment_thickness*leakage); 667 /* if(epl_head>sediment_head){ */ 668 /* h_max=GetHydrologyDCInefficientHmax(element,gauss,thickness_input,base_input); */ 669 /* if(sediment_head>=h_max){ */ 670 /* transfer=0.0; */ 671 /* } */ 672 /* else{ */ 673 /* transfer=(sediment_transmitivity*epl_head)/(sediment_thickness*leakage); */ 674 /* //transfer=(epl_specificstoring*epl_thickness*sediment_transmitivity*epl_head)/(sediment_thickness*leakage); */ 675 /* } */ 676 /* } */ 677 /* else{ */ 678 /* transfer=(sediment_transmitivity*epl_head)/(sediment_thickness*leakage); */ 679 /* //transfer=(sediment_storing*sediment_transmitivity*epl_head)/(sediment_thickness*leakage); */ 680 /* } */ 649 650 hmax=GetHydrologyDCInefficientHmax(element, gauss, thick_input, base_input); 651 652 //Computing continuum function to apply to transfer term, transfer is null only if 653 //epl_head>sediment_head AND sediment_head>h_max 654 continuum=((1.0/(1.0+exp(-20.0*(sediment_head-epl_head)))))+(1.0/(1.0+exp(-20.0*(hmax-sediment_head)))); 655 factor=min(continuum,1.0); 656 transfer=epl_head*leakage*factor; 681 657 break; 682 658 default: … … 692 668 693 669 for(int i=0;i<femmodel->elements->Size();i++){ 694 element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i)); 695 696 int numvertices = element->GetNumberOfVertices(); 697 Input* node_mask_input = element->GetInput(HydrologydcMaskEplactiveNodeEnum); 698 if(node_mask_input->Max()>0.) { 670 element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 671 Input* node_mask_input = element->GetInput(HydrologydcMaskEplactiveNodeEnum); _assert_(node_mask_input); 672 673 if(node_mask_input->Max()>0.){ 699 674 element_active = true; 700 675 } … … 705 680 } 706 681 }/*}}}*/ 707 -
issm/trunk/src/c/analyses/HydrologyDCInefficientAnalysis.h
r18301 r19105 38 38 IssmDouble GetHydrologyDCInefficientHmax(Element* element, Gauss* gauss, Input* thickness_input, Input* base_input); 39 39 void GetHydrologyDCInefficientHmax(IssmDouble* ph_max,Element* element, Node* innode); 40 IssmDouble GetHydrologyKMatrixTransfer(Element* element, Gauss* gauss, Input* epl_thick_input, Input* sed_head_input, Input* epl_head_input, Input* sed_trans_input, Input* thickness_input, Input* base_input);41 IssmDouble GetHydrologyPVectorTransfer(Element* element, Gauss* gauss, Input* epl_thick_input, Input* sed_head_input, Input* epl_head_input, Input* sed_trans_input, Input* thickness_input, Input* base_input);40 IssmDouble GetHydrologyKMatrixTransfer(Element* element, Gauss* gauss, Input* sed_head_input, Input* epl_head_input, Input* thick_input, Input* base_input); 41 IssmDouble GetHydrologyPVectorTransfer(Element* element, Gauss* gauss, Input* sed_head_input, Input* epl_head_input, Input* thick_input, Input* base_input); 42 42 void ElementizeEplMask(FemModel* femmodel); 43 43 }; -
issm/trunk/src/c/analyses/HydrologyShreveAnalysis.cpp
r18301 r19105 6 6 7 7 /*Model processing*/ 8 void HydrologyShreveAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 9 10 /*retrieve some parameters: */ 11 int hydrology_model; 12 iomodel->Constant(&hydrology_model,HydrologyModelEnum); 13 14 if(hydrology_model!=HydrologyshreveEnum) return; 15 16 IoModelToConstraintsx(constraints,iomodel,HydrologyshreveSpcwatercolumnEnum,HydrologyShreveAnalysisEnum,P1Enum); 17 18 }/*}}}*/ 19 void HydrologyShreveAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 20 /*No loads*/ 21 }/*}}}*/ 22 void HydrologyShreveAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 23 24 /*Fetch parameters: */ 25 int hydrology_model; 26 iomodel->Constant(&hydrology_model,HydrologyModelEnum); 27 28 /*Now, do we really want Shreve?*/ 29 if(hydrology_model!=HydrologyshreveEnum) return; 30 31 if(iomodel->domaintype==Domain3DEnum) iomodel->FetchData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 32 ::CreateNodes(nodes,iomodel,HydrologyShreveAnalysisEnum,P1Enum); 33 iomodel->DeleteData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 34 }/*}}}*/ 8 35 int HydrologyShreveAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/ 9 36 return 1; 10 }/*}}}*/11 void HydrologyShreveAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/12 13 /*retrieve some parameters: */14 int hydrology_model;15 iomodel->Constant(&hydrology_model,HydrologyModelEnum);16 17 /*Now, do we really want Shreve?*/18 if(hydrology_model!=HydrologyshreveEnum) return;19 20 parameters->AddObject(new IntParam(HydrologyModelEnum,hydrology_model));21 parameters->AddObject(iomodel->CopyConstantObject(HydrologyshreveStabilizationEnum));22 23 37 }/*}}}*/ 24 38 void HydrologyShreveAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ … … 55 69 elements->InputDuplicate(WatercolumnEnum,WaterColumnOldEnum); 56 70 }/*}}}*/ 57 void HydrologyShreveAnalysis:: CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/58 59 /* Fetchparameters: */71 void HydrologyShreveAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 72 73 /*retrieve some parameters: */ 60 74 int hydrology_model; 61 75 iomodel->Constant(&hydrology_model,HydrologyModelEnum); … … 64 78 if(hydrology_model!=HydrologyshreveEnum) return; 65 79 66 if(iomodel->domaintype==Domain3DEnum) iomodel->FetchData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 67 ::CreateNodes(nodes,iomodel,HydrologyShreveAnalysisEnum,P1Enum); 68 iomodel->DeleteData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 69 }/*}}}*/ 70 void HydrologyShreveAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 71 72 /*retrieve some parameters: */ 73 int hydrology_model; 74 iomodel->Constant(&hydrology_model,HydrologyModelEnum); 75 76 if(hydrology_model!=HydrologyshreveEnum) return; 77 78 IoModelToConstraintsx(constraints,iomodel,HydrologyshreveSpcwatercolumnEnum,HydrologyShreveAnalysisEnum,P1Enum); 79 80 }/*}}}*/ 81 void HydrologyShreveAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 82 /*No loads*/ 80 parameters->AddObject(new IntParam(HydrologyModelEnum,hydrology_model)); 81 parameters->AddObject(iomodel->CopyConstantObject(HydrologyshreveStabilizationEnum)); 82 83 83 }/*}}}*/ 84 84 … … 90 90 /*Default, return NULL*/ 91 91 return NULL; 92 }/*}}}*/ 93 void HydrologyShreveAnalysis::CreateHydrologyWaterVelocityInput(Element* element){/*{{{*/ 94 95 /*Intermediaries*/ 96 IssmDouble dsdx,dsdy,dbdx,dbdy,w; 97 98 /*Retrieve all inputs and parameters*/ 99 IssmDouble rho_ice = element->GetMaterialParameter(MaterialsRhoIceEnum); 100 IssmDouble rho_water = element->GetMaterialParameter(MaterialsRhoSeawaterEnum); 101 IssmDouble g = element->GetMaterialParameter(ConstantsGEnum); 102 IssmDouble mu_water = element->GetMaterialParameter(MaterialsMuWaterEnum); 103 Input* surfaceslopex_input = element->GetInput(SurfaceSlopeXEnum); _assert_(surfaceslopex_input); 104 Input* surfaceslopey_input = element->GetInput(SurfaceSlopeYEnum); _assert_(surfaceslopey_input); 105 Input* bedslopex_input = element->GetInput(BedSlopeXEnum); _assert_(bedslopex_input); 106 Input* bedslopey_input = element->GetInput(BedSlopeYEnum); _assert_(bedslopey_input); 107 Input* watercolumn_input = element->GetInput(WatercolumnEnum); _assert_(watercolumn_input); 108 109 /*Fetch number of vertices and allocate output*/ 110 int numvertices = element->GetNumberOfVertices(); 111 IssmDouble* vx = xNew<IssmDouble>(numvertices); 112 IssmDouble* vy = xNew<IssmDouble>(numvertices); 113 114 Gauss* gauss=element->NewGauss(); 115 for(int iv=0;iv<numvertices;iv++){ 116 gauss->GaussVertex(iv); 117 surfaceslopex_input->GetInputValue(&dsdx,gauss); 118 surfaceslopey_input->GetInputValue(&dsdy,gauss); 119 bedslopex_input->GetInputValue(&dbdx,gauss); 120 bedslopey_input->GetInputValue(&dbdy,gauss); 121 watercolumn_input->GetInputValue(&w,gauss); 122 123 /* Water velocity x and y components */ 124 vx[iv]= - w*w/(12 * mu_water)*(rho_ice*g*dsdx+(rho_water-rho_ice)*g*dbdx); 125 vy[iv]= - w*w/(12 * mu_water)*(rho_ice*g*dsdy+(rho_water-rho_ice)*g*dbdy); 126 } 127 128 /*clean-up*/ 129 delete gauss; 130 131 /*Add to inputs*/ 132 element->AddInput(HydrologyWaterVxEnum,vx,P1Enum); 133 element->AddInput(HydrologyWaterVyEnum,vy,P1Enum); 134 xDelete<IssmDouble>(vx); 135 xDelete<IssmDouble>(vy); 92 136 }/*}}}*/ 93 137 ElementMatrix* HydrologyShreveAnalysis::CreateJacobianMatrix(Element* element){/*{{{*/ … … 234 278 return pe; 235 279 }/*}}}*/ 236 void HydrologyShreveAnalysis::GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/280 void HydrologyShreveAnalysis::GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 237 281 /*Compute B matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2. 238 282 * For node i, Bi can be expressed in the actual coordinate system … … 261 305 xDelete<IssmDouble>(basis); 262 306 }/*}}}*/ 263 void HydrologyShreveAnalysis::GetBprime(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/307 void HydrologyShreveAnalysis::GetBprime(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 264 308 /*Compute B' matrix. B'=[B1' B2' B3'] where Bi' is of size 3*NDOF2. 265 309 * For node i, Bi' can be expressed in the actual coordinate system … … 289 333 290 334 }/*}}}*/ 291 void HydrologyShreveAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/335 void HydrologyShreveAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 292 336 element->GetSolutionFromInputsOneDof(solution,WatercolumnEnum); 293 337 }/*}}}*/ 294 void HydrologyShreveAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/338 void HydrologyShreveAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 295 339 _error_("Not implemented yet"); 296 340 }/*}}}*/ 297 void HydrologyShreveAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/341 void HydrologyShreveAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 298 342 299 343 /*Intermediary*/ … … 321 365 xDelete<int>(doflist); 322 366 }/*}}}*/ 323 void HydrologyShreveAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/367 void HydrologyShreveAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 324 368 /*Default, do nothing*/ 325 369 return; 326 370 }/*}}}*/ 327 328 /*Intermediaries*/329 void HydrologyShreveAnalysis::CreateHydrologyWaterVelocityInput(Element* element){/*{{{*/330 331 /*Intermediaries*/332 IssmDouble dsdx,dsdy,dbdx,dbdy,w;333 334 /*Retrieve all inputs and parameters*/335 IssmDouble rho_ice = element->GetMaterialParameter(MaterialsRhoIceEnum);336 IssmDouble rho_water = element->GetMaterialParameter(MaterialsRhoSeawaterEnum);337 IssmDouble g = element->GetMaterialParameter(ConstantsGEnum);338 IssmDouble mu_water = element->GetMaterialParameter(MaterialsMuWaterEnum);339 Input* surfaceslopex_input = element->GetInput(SurfaceSlopeXEnum); _assert_(surfaceslopex_input);340 Input* surfaceslopey_input = element->GetInput(SurfaceSlopeYEnum); _assert_(surfaceslopey_input);341 Input* bedslopex_input = element->GetInput(BedSlopeXEnum); _assert_(bedslopex_input);342 Input* bedslopey_input = element->GetInput(BedSlopeYEnum); _assert_(bedslopey_input);343 Input* watercolumn_input = element->GetInput(WatercolumnEnum); _assert_(watercolumn_input);344 345 /*Fetch number of vertices and allocate output*/346 int numvertices = element->GetNumberOfVertices();347 IssmDouble* vx = xNew<IssmDouble>(numvertices);348 IssmDouble* vy = xNew<IssmDouble>(numvertices);349 350 Gauss* gauss=element->NewGauss();351 for(int iv=0;iv<numvertices;iv++){352 gauss->GaussVertex(iv);353 surfaceslopex_input->GetInputValue(&dsdx,gauss);354 surfaceslopey_input->GetInputValue(&dsdy,gauss);355 bedslopex_input->GetInputValue(&dbdx,gauss);356 bedslopey_input->GetInputValue(&dbdy,gauss);357 watercolumn_input->GetInputValue(&w,gauss);358 359 /* Water velocity x and y components */360 vx[iv]= - w*w/(12 * mu_water)*(rho_ice*g*dsdx+(rho_water-rho_ice)*g*dbdx);361 vy[iv]= - w*w/(12 * mu_water)*(rho_ice*g*dsdy+(rho_water-rho_ice)*g*dbdy);362 }363 364 /*clean-up*/365 delete gauss;366 367 /*Add to inputs*/368 element->AddInput(HydrologyWaterVxEnum,vx,P1Enum);369 element->AddInput(HydrologyWaterVyEnum,vy,P1Enum);370 xDelete<IssmDouble>(vx);371 xDelete<IssmDouble>(vy);372 }/*}}}*/373 374 371 375 372 -
issm/trunk/src/c/analyses/HydrologyShreveAnalysis.h
r18301 r19105 13 13 public: 14 14 /*Model processing*/ 15 int DofsPerNode(int** doflist,int domaintype,int approximation);16 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum);17 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type);18 void CreateNodes(Nodes* nodes,IoModel* iomodel);19 15 void CreateConstraints(Constraints* constraints,IoModel* iomodel); 20 16 void CreateLoads(Loads* loads, IoModel* iomodel); 17 void CreateNodes(Nodes* nodes,IoModel* iomodel); 18 int DofsPerNode(int** doflist,int domaintype,int approximation); 19 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 20 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum); 21 21 22 22 /*Finite element Analysis*/ 23 23 void Core(FemModel* femmodel); 24 24 ElementVector* CreateDVector(Element* element); 25 void CreateHydrologyWaterVelocityInput(Element* element); 25 26 ElementMatrix* CreateJacobianMatrix(Element* element); 26 27 ElementMatrix* CreateKMatrix(Element* element); 27 28 ElementVector* CreatePVector(Element* element); 28 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 29 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 30 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 31 void UpdateConstraints(FemModel* femmodel); 32 33 /*Intermediaries*/ 34 void GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss); 35 void GetBprime(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss); 36 void CreateHydrologyWaterVelocityInput(Element* element); 29 void GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss); 30 void GetBprime(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss); 31 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 32 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 33 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 34 void UpdateConstraints(FemModel* femmodel); 37 35 }; 38 36 #endif -
issm/trunk/src/c/analyses/L2ProjectionBaseAnalysis.cpp
r18301 r19105 6 6 7 7 /*Model processing*/ 8 void L2ProjectionBaseAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 9 10 /*No constraints*/ 11 }/*}}}*/ 12 void L2ProjectionBaseAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 13 14 /*No loads*/ 15 }/*}}}*/ 16 void L2ProjectionBaseAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 17 18 if(iomodel->domaintype==Domain3DEnum){ 19 iomodel->FetchData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 20 } 21 else if(iomodel->domaintype==Domain2DverticalEnum){ 22 iomodel->FetchData(1,MeshVertexonbaseEnum); 23 } 24 ::CreateNodes(nodes,iomodel,L2ProjectionBaseAnalysisEnum,P1Enum); 25 iomodel->DeleteData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 26 }/*}}}*/ 8 27 int L2ProjectionBaseAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/ 9 28 return 1; 10 }/*}}}*/11 void L2ProjectionBaseAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/12 29 }/*}}}*/ 13 30 void L2ProjectionBaseAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ … … 31 48 } 32 49 }/*}}}*/ 33 void L2ProjectionBaseAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 34 35 if(iomodel->domaintype==Domain3DEnum){ 36 iomodel->FetchData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 37 } 38 else if(iomodel->domaintype==Domain2DverticalEnum){ 39 iomodel->FetchData(1,MeshVertexonbaseEnum); 40 } 41 ::CreateNodes(nodes,iomodel,L2ProjectionBaseAnalysisEnum,P1Enum); 42 iomodel->DeleteData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 43 }/*}}}*/ 44 void L2ProjectionBaseAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 45 46 /*No constraints*/ 47 }/*}}}*/ 48 void L2ProjectionBaseAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 49 50 /*No loads*/ 50 void L2ProjectionBaseAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 51 51 }/*}}}*/ 52 52 … … 93 93 94 94 /*Initialize Element vector*/ 95 ElementMatrix* Ke = basalelement->NewElementMatrix( NoneApproximationEnum);95 ElementMatrix* Ke = basalelement->NewElementMatrix(); 96 96 IssmDouble* basis = xNew<IssmDouble>(numnodes); 97 97 … … 196 196 return pe; 197 197 }/*}}}*/ 198 void L2ProjectionBaseAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/198 void L2ProjectionBaseAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 199 199 _error_("not implemented yet"); 200 200 }/*}}}*/ 201 void L2ProjectionBaseAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/201 void L2ProjectionBaseAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 202 202 _error_("Not implemented yet"); 203 203 }/*}}}*/ 204 void L2ProjectionBaseAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/204 void L2ProjectionBaseAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 205 205 206 206 int inputenum,domaintype,elementtype; … … 225 225 } 226 226 }/*}}}*/ 227 void L2ProjectionBaseAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/227 void L2ProjectionBaseAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 228 228 /*Default, do nothing*/ 229 229 return; -
issm/trunk/src/c/analyses/L2ProjectionBaseAnalysis.h
r18301 r19105 13 13 public: 14 14 /*Model processing*/ 15 int DofsPerNode(int** doflist,int domaintype,int approximation);16 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum);17 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type);18 void CreateNodes(Nodes* nodes,IoModel* iomodel);19 15 void CreateConstraints(Constraints* constraints,IoModel* iomodel); 20 16 void CreateLoads(Loads* loads, IoModel* iomodel); 17 void CreateNodes(Nodes* nodes,IoModel* iomodel); 18 int DofsPerNode(int** doflist,int domaintype,int approximation); 19 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 20 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum); 21 21 22 22 /*Finite element Analysis*/ … … 26 26 ElementMatrix* CreateKMatrix(Element* element); 27 27 ElementVector* CreatePVector(Element* element); 28 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element);29 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index);30 void InputUpdateFromSolution(IssmDouble* solution,Element* element);31 void UpdateConstraints(FemModel* femmodel);28 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 29 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 30 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 31 void UpdateConstraints(FemModel* femmodel); 32 32 }; 33 33 #endif -
issm/trunk/src/c/analyses/L2ProjectionEPLAnalysis.cpp
r18301 r19105 6 6 7 7 /*Model processing*/ 8 void L2ProjectionEPLAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 9 10 /*No constraints*/ 11 }/*}}}*/ 12 void L2ProjectionEPLAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 13 14 /*No loads*/ 15 }/*}}}*/ 16 void L2ProjectionEPLAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 17 /*Now, do we really want DC?*/ 18 int hydrology_model; 19 iomodel->Constant(&hydrology_model,HydrologyModelEnum); 20 if(hydrology_model!=HydrologydcEnum) return; 21 22 /*Do we want an efficient layer*/ 23 bool isefficientlayer; 24 iomodel->Constant(&isefficientlayer,HydrologydcIsefficientlayerEnum); 25 if(!isefficientlayer) return; 26 27 if(iomodel->domaintype==Domain3DEnum){ 28 iomodel->FetchData(1,MeshVertexonbaseEnum); 29 } 30 else if(iomodel->domaintype==Domain2DverticalEnum){ 31 iomodel->FetchData(1,MeshVertexonbaseEnum); 32 } 33 ::CreateNodes(nodes,iomodel,L2ProjectionEPLAnalysisEnum,P1Enum); 34 iomodel->DeleteData(1,MeshVertexonbaseEnum); 35 }/*}}}*/ 8 36 int L2ProjectionEPLAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/ 9 37 return 1; 10 }/*}}}*/11 void L2ProjectionEPLAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/12 38 }/*}}}*/ 13 39 void L2ProjectionEPLAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ … … 41 67 } 42 68 }/*}}}*/ 43 void L2ProjectionEPLAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 44 /*Now, do we really want DC?*/ 45 int hydrology_model; 46 iomodel->Constant(&hydrology_model,HydrologyModelEnum); 47 if(hydrology_model!=HydrologydcEnum) return; 48 49 /*Do we want an efficient layer*/ 50 bool isefficientlayer; 51 iomodel->Constant(&isefficientlayer,HydrologydcIsefficientlayerEnum); 52 if(!isefficientlayer) return; 53 54 if(iomodel->domaintype==Domain3DEnum){ 55 iomodel->FetchData(1,MeshVertexonbaseEnum); 56 } 57 else if(iomodel->domaintype==Domain2DverticalEnum){ 58 iomodel->FetchData(1,MeshVertexonbaseEnum); 59 } 60 ::CreateNodes(nodes,iomodel,L2ProjectionEPLAnalysisEnum,P1Enum); 61 iomodel->DeleteData(1,MeshVertexonbaseEnum); 62 }/*}}}*/ 63 void L2ProjectionEPLAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 64 65 /*No constraints*/ 66 }/*}}}*/ 67 void L2ProjectionEPLAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 68 69 /*No loads*/ 69 void L2ProjectionEPLAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 70 70 }/*}}}*/ 71 71 … … 226 226 return pe; 227 227 }/*}}}*/ 228 void L2ProjectionEPLAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/228 void L2ProjectionEPLAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 229 229 _error_("not implemented yet"); 230 230 }/*}}}*/ 231 void L2ProjectionEPLAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/231 void L2ProjectionEPLAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 232 232 _error_("Not implemented yet"); 233 233 }/*}}}*/ 234 void L2ProjectionEPLAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/234 void L2ProjectionEPLAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 235 235 int inputenum,domaintype; 236 236 … … 250 250 } 251 251 }/*}}}*/ 252 void L2ProjectionEPLAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/252 void L2ProjectionEPLAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 253 253 /*Default, do nothing*/ 254 254 return; -
issm/trunk/src/c/analyses/L2ProjectionEPLAnalysis.h
r18301 r19105 13 13 public: 14 14 /*Model processing*/ 15 int DofsPerNode(int** doflist,int domaintype,int approximation);16 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum);17 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type);18 void CreateNodes(Nodes* nodes,IoModel* iomodel);19 15 void CreateConstraints(Constraints* constraints,IoModel* iomodel); 20 16 void CreateLoads(Loads* loads, IoModel* iomodel); 17 void CreateNodes(Nodes* nodes,IoModel* iomodel); 18 int DofsPerNode(int** doflist,int domaintype,int approximation); 19 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 20 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum); 21 21 22 22 /*Finite element Analysis*/ … … 26 26 ElementMatrix* CreateKMatrix(Element* element); 27 27 ElementVector* CreatePVector(Element* element); 28 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element);29 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index);30 void InputUpdateFromSolution(IssmDouble* solution,Element* element);31 void UpdateConstraints(FemModel* femmodel);28 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 29 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 30 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 31 void UpdateConstraints(FemModel* femmodel); 32 32 }; 33 33 #endif -
issm/trunk/src/c/analyses/LevelsetAnalysis.h
r18301 r19105 13 13 public: 14 14 /*Model processing*/ 15 int DofsPerNode(int** doflist,int domaintype,int approximation);16 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum);17 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type);18 void CreateNodes(Nodes* nodes,IoModel* iomodel);19 15 void CreateConstraints(Constraints* constraints,IoModel* iomodel); 20 16 void CreateLoads(Loads* loads, IoModel* iomodel); 17 void CreateNodes(Nodes* nodes,IoModel* iomodel); 18 int DofsPerNode(int** doflist,int domaintype,int approximation); 19 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 20 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum); 21 21 22 22 /*Finite element Analysis*/ … … 26 26 ElementMatrix* CreateKMatrix(Element* element); 27 27 ElementVector* CreatePVector(Element* element); 28 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element);29 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index);30 void InputUpdateFromSolution(IssmDouble* solution,Element* element);31 void UpdateConstraints(FemModel* femmodel);32 void GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss);33 void GetBprime(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss);34 void SetDistanceOnIntersectedElements(FemModel* femmodel);35 void SetDistanceToZeroLevelsetElement(Vector<IssmDouble>* vec_signed_dist, Element* element);36 IssmDouble GetDistanceToStraight(IssmDouble* q, IssmDouble* s0, IssmDouble* s1);28 void GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss); 29 void GetBprime(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss); 30 IssmDouble GetDistanceToStraight(IssmDouble* q, IssmDouble* s0, IssmDouble* s1); 31 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 32 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 33 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 34 void SetDistanceOnIntersectedElements(FemModel* femmodel); 35 void SetDistanceToZeroLevelsetElement(Vector<IssmDouble>* vec_signed_dist, Element* element); 36 void UpdateConstraints(FemModel* femmodel); 37 37 }; 38 38 #endif -
issm/trunk/src/c/analyses/LsfReinitializationAnalysis.cpp
r18301 r19105 10 10 11 11 /*Model processing*/ 12 void LsfReinitializationAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 13 /* Do nothing for now */ 14 }/*}}}*/ 15 void LsfReinitializationAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 16 /* Do nothing for now */ 17 }/*}}}*/ 18 void LsfReinitializationAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 19 int finiteelement=P1Enum; 20 if(iomodel->domaintype!=Domain2DhorizontalEnum) iomodel->FetchData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 21 ::CreateNodes(nodes,iomodel,LsfReinitializationAnalysisEnum,finiteelement); 22 iomodel->DeleteData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 23 }/*}}}*/ 12 24 int LsfReinitializationAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/ 13 25 return 1; 14 }/*}}}*/15 void LsfReinitializationAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/16 /* Do nothing for now */17 26 }/*}}}*/ 18 27 void LsfReinitializationAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ … … 34 43 iomodel->FetchDataToInput(elements,MaskIceLevelsetEnum); 35 44 }/*}}}*/ 36 void LsfReinitializationAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 37 int finiteelement=P1Enum; 38 if(iomodel->domaintype!=Domain2DhorizontalEnum) iomodel->FetchData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 39 ::CreateNodes(nodes,iomodel,LsfReinitializationAnalysisEnum,finiteelement); 40 iomodel->DeleteData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 41 }/*}}}*/ 42 void LsfReinitializationAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 45 void LsfReinitializationAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 43 46 /* Do nothing for now */ 44 47 }/*}}}*/ 45 void LsfReinitializationAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/46 /* Do nothing for now */47 }/*}}}*/48 48 49 49 /*Finite element Analysis*/ 50 void LsfReinitializationAnalysis::Core(FemModel* femmodel){/*{{{*/50 void LsfReinitializationAnalysis::Core(FemModel* femmodel){/*{{{*/ 51 51 52 52 /*parameters: */ … … 249 249 return pe; 250 250 }/*}}}*/ 251 void LsfReinitializationAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 251 void LsfReinitializationAnalysis::GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 252 /*Compute B matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2. 253 * For node i, Bi can be expressed in the actual coordinate system 254 * by: 255 * Bi=[ N ] 256 * [ N ] 257 * where N is the finiteelement function for node i. 258 * 259 * We assume B_prog has been allocated already, of size: 2x(NDOF1*numnodes) 260 */ 261 262 /*Fetch number of nodes for this finite element*/ 263 int numnodes = element->GetNumberOfNodes(); 264 265 /*Get nodal functions*/ 266 IssmDouble* basis=xNew<IssmDouble>(numnodes); 267 element->NodalFunctions(basis,gauss); 268 269 /*Build B: */ 270 for(int i=0;i<numnodes;i++){ 271 B[numnodes*0+i] = basis[i]; 272 B[numnodes*1+i] = basis[i]; 273 } 274 275 /*Clean-up*/ 276 xDelete<IssmDouble>(basis); 277 }/*}}}*/ 278 void LsfReinitializationAnalysis::GetBprime(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 279 /*Compute B' matrix. B'=[B1' B2' B3'] where Bi' is of size 3*NDOF2. 280 * For node i, Bi' can be expressed in the actual coordinate system 281 * by: 282 * Bi_prime=[ dN/dx ] 283 * [ dN/dy ] 284 * where N is the finiteelement function for node i. 285 * 286 * We assume B' has been allocated already, of size: 3x(NDOF2*numnodes) 287 */ 288 289 /*Fetch number of nodes for this finite element*/ 290 int numnodes = element->GetNumberOfNodes(); 291 292 /*Get nodal functions derivatives*/ 293 IssmDouble* dbasis=xNew<IssmDouble>(2*numnodes); 294 element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss); 295 296 /*Build B': */ 297 for(int i=0;i<numnodes;i++){ 298 Bprime[numnodes*0+i] = dbasis[0*numnodes+i]; 299 Bprime[numnodes*1+i] = dbasis[1*numnodes+i]; 300 } 301 302 /*Clean-up*/ 303 xDelete<IssmDouble>(dbasis); 304 305 }/*}}}*/ 306 IssmDouble LsfReinitializationAnalysis::GetDistanceToStraight(IssmDouble* q, IssmDouble* s0, IssmDouble* s1){/*{{{*/ 307 // returns distance d of point q to straight going through points s0, s1 308 // d=|a x b|/|b| 309 // with a=q-s0, b=s1-s0 310 311 /* Intermediaries */ 312 const int dim=2; 313 int i; 314 IssmDouble a[dim], b[dim]; 315 IssmDouble norm_b; 316 317 for(i=0;i<dim;i++){ 318 a[i]=q[i]-s0[i]; 319 b[i]=s1[i]-s0[i]; 320 } 321 322 norm_b=0.; 323 for(i=0;i<dim;i++) 324 norm_b+=b[i]*b[i]; 325 norm_b=sqrt(norm_b); 326 _assert_(norm_b>0.); 327 328 return fabs(a[0]*b[1]-a[1]*b[0])/norm_b; 329 }/*}}}*/ 330 void LsfReinitializationAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 252 331 253 332 IssmDouble lsf; … … 284 363 285 364 }/*}}}*/ 286 void LsfReinitializationAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/365 void LsfReinitializationAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 287 366 _error_("Not implemented yet"); 288 367 }/*}}}*/ 289 void LsfReinitializationAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/368 void LsfReinitializationAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 290 369 291 370 int domaintype; … … 301 380 } 302 381 }/*}}}*/ 303 void LsfReinitializationAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 304 /* Do nothing for now */ 305 }/*}}}*/ 306 void LsfReinitializationAnalysis::GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 307 /*Compute B matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2. 308 * For node i, Bi can be expressed in the actual coordinate system 309 * by: 310 * Bi=[ N ] 311 * [ N ] 312 * where N is the finiteelement function for node i. 313 * 314 * We assume B_prog has been allocated already, of size: 2x(NDOF1*numnodes) 315 */ 316 317 /*Fetch number of nodes for this finite element*/ 318 int numnodes = element->GetNumberOfNodes(); 319 320 /*Get nodal functions*/ 321 IssmDouble* basis=xNew<IssmDouble>(numnodes); 322 element->NodalFunctions(basis,gauss); 323 324 /*Build B: */ 325 for(int i=0;i<numnodes;i++){ 326 B[numnodes*0+i] = basis[i]; 327 B[numnodes*1+i] = basis[i]; 328 } 329 330 /*Clean-up*/ 331 xDelete<IssmDouble>(basis); 332 }/*}}}*/ 333 void LsfReinitializationAnalysis::GetBprime(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 334 /*Compute B' matrix. B'=[B1' B2' B3'] where Bi' is of size 3*NDOF2. 335 * For node i, Bi' can be expressed in the actual coordinate system 336 * by: 337 * Bi_prime=[ dN/dx ] 338 * [ dN/dy ] 339 * where N is the finiteelement function for node i. 340 * 341 * We assume B' has been allocated already, of size: 3x(NDOF2*numnodes) 342 */ 343 344 /*Fetch number of nodes for this finite element*/ 345 int numnodes = element->GetNumberOfNodes(); 346 347 /*Get nodal functions derivatives*/ 348 IssmDouble* dbasis=xNew<IssmDouble>(2*numnodes); 349 element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss); 350 351 /*Build B': */ 352 for(int i=0;i<numnodes;i++){ 353 Bprime[numnodes*0+i] = dbasis[0*numnodes+i]; 354 Bprime[numnodes*1+i] = dbasis[1*numnodes+i]; 355 } 356 357 /*Clean-up*/ 358 xDelete<IssmDouble>(dbasis); 359 360 }/*}}}*/ 361 362 /* Other */ 363 void LsfReinitializationAnalysis::SetReinitSPCs(FemModel* femmodel){/*{{{*/ 382 bool LsfReinitializationAnalysis::ReinitConvergence(Vector<IssmDouble>* lsfg,Vector<IssmDouble>* lsfg_old,IssmDouble reltol){/*{{{*/ 383 384 /*Output*/ 385 bool converged = true; 386 387 /*Intermediary*/ 388 Vector<IssmDouble>* dlsfg = NULL; 389 IssmDouble norm_dlsf,norm_lsf; 390 391 /*compute norm(du)/norm(u)*/ 392 dlsfg=lsfg_old->Duplicate(); lsfg_old->Copy(dlsfg); dlsfg->AYPX(lsfg,-1.0); 393 norm_dlsf=dlsfg->Norm(NORM_TWO); norm_lsf=lsfg_old->Norm(NORM_TWO); 394 if (xIsNan<IssmDouble>(norm_dlsf) || xIsNan<IssmDouble>(norm_lsf)) _error_("convergence criterion is NaN!"); 395 if((norm_dlsf/norm_lsf)<reltol){ 396 if(VerboseConvergence()) _printf0_("\n"<<setw(50)<<left<<" Velocity convergence: norm(du)/norm(u)"<<norm_dlsf/norm_lsf*100<<" < "<<reltol*100<<" %\n"); 397 } 398 else{ 399 if(VerboseConvergence()) _printf0_("\n"<<setw(50)<<left<<" Velocity convergence: norm(du)/norm(u)"<<norm_dlsf/norm_lsf*100<<" > "<<reltol*100<<" %\n"); 400 converged=false; 401 } 402 403 /*Cleanup*/ 404 delete dlsfg; 405 406 return converged; 407 }/*}}}*/ 408 void LsfReinitializationAnalysis::SetDistanceOnIntersectedElements(FemModel* femmodel){/*{{{*/ 409 410 /* Intermediaries */ 411 int i; 412 IssmDouble dmaxp,dmaxm,val; 413 Element* element; 414 415 /*Initialize vector with number of vertices*/ 416 int numvertices=femmodel->vertices->NumberOfVertices(); 417 418 Vector<IssmDouble>* vec_dist_zerolevelset = NULL; 419 GetVectorFromInputsx(&vec_dist_zerolevelset, femmodel, MaskIceLevelsetEnum, VertexPIdEnum); 420 421 /* set distance on elements intersected by zero levelset */ 422 for(i=0;i<femmodel->elements->Size();i++){ 423 element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 424 if(element->IsZeroLevelset(MaskIceLevelsetEnum)){ 425 SetDistanceToZeroLevelsetElement(vec_dist_zerolevelset, element); 426 } 427 } 428 vec_dist_zerolevelset->Assemble(); 429 430 /* Get maximum distance to interface along vertices */ 431 dmaxp=0.; dmaxm=0.; 432 for(i=0;i<numvertices;i++){ 433 vec_dist_zerolevelset->GetValue(&val,i); 434 if((val>0.) && (val>dmaxp)) 435 dmaxp=val; 436 else if((val<0.) && (val<dmaxm)) 437 dmaxm=val; 438 } 439 //wait until all values are computed 440 441 /* set all none intersected vertices to max/min distance */ 442 for(i=0;i<numvertices;i++){ 443 vec_dist_zerolevelset->GetValue(&val,i); 444 if(val==1.) //FIXME: improve check 445 vec_dist_zerolevelset->SetValue(i,3.*dmaxp,INS_VAL); 446 else if(val==-1.) 447 vec_dist_zerolevelset->SetValue(i,3.*dmaxm,INS_VAL); 448 } 449 450 /*Assemble vector and serialize */ 451 vec_dist_zerolevelset->Assemble(); 452 IssmDouble* dist_zerolevelset=vec_dist_zerolevelset->ToMPISerial(); 453 InputUpdateFromVectorx(femmodel,dist_zerolevelset,MaskIceLevelsetEnum,VertexSIdEnum); 454 455 /*Clean up and return*/ 456 delete vec_dist_zerolevelset; 457 delete dist_zerolevelset; 458 459 }/*}}}*/ 460 void LsfReinitializationAnalysis::SetDistanceToZeroLevelsetElement(Vector<IssmDouble>* vec_signed_dist, Element* element){/*{{{*/ 461 462 if(!element->IsZeroLevelset(MaskIceLevelsetEnum)) 463 return; 464 465 /* Intermediaries */ 466 int dim=3; 467 int i,d; 468 IssmDouble dist,lsf_old; 469 470 int numvertices=element->GetNumberOfVertices(); 471 472 IssmDouble* lsf = xNew<IssmDouble>(numvertices); 473 IssmDouble* sign_lsf = xNew<IssmDouble>(numvertices); 474 IssmDouble* signed_dist = xNew<IssmDouble>(numvertices); 475 IssmDouble* s0 = xNew<IssmDouble>(dim); 476 IssmDouble* s1 = xNew<IssmDouble>(dim); 477 IssmDouble* v = xNew<IssmDouble>(dim); 478 IssmDouble* xyz_list = NULL; 479 IssmDouble* xyz_list_zero = NULL; 480 481 /* retrieve inputs and parameters */ 482 element->GetVerticesCoordinates(&xyz_list); 483 element->GetInputListOnVertices(lsf,MaskIceLevelsetEnum); 484 485 /* get sign of levelset function */ 486 for(i=0;i<numvertices;i++) 487 sign_lsf[i]=(lsf[i]>=0.?1.:-1.); 488 489 element->ZeroLevelsetCoordinates(&xyz_list_zero, xyz_list, MaskIceLevelsetEnum); 490 for(i=0;i<dim;i++){ 491 s0[i]=xyz_list_zero[0+i]; 492 s1[i]=xyz_list_zero[3+i]; 493 } 494 495 /* get signed_distance of vertices to zero levelset straight */ 496 for(i=0;i<numvertices;i++){ 497 for(d=0;d<dim;d++) 498 v[d]=xyz_list[dim*i+d]; 499 dist=GetDistanceToStraight(&v[0],&s0[0],&s1[0]); 500 signed_dist[i]=sign_lsf[i]*dist; 501 } 502 503 /* insert signed_distance into vec_signed_dist, if computed distance is smaller */ 504 for(i=0;i<numvertices;i++){ 505 vec_signed_dist->GetValue(&lsf_old, element->vertices[i]->Sid()); 506 /* initial lsf values are +-1. Update those fields or if distance to interface smaller.*/ 507 if(fabs(lsf_old)==1. || fabs(signed_dist[i])<fabs(lsf_old)) 508 vec_signed_dist->SetValue(element->vertices[i]->Sid(),signed_dist[i],INS_VAL); 509 } 510 511 xDelete<IssmDouble>(lsf); 512 xDelete<IssmDouble>(sign_lsf); 513 xDelete<IssmDouble>(signed_dist); 514 xDelete<IssmDouble>(s0); 515 xDelete<IssmDouble>(s1); 516 xDelete<IssmDouble>(v); 517 518 }/*}}}*/ 519 void LsfReinitializationAnalysis::SetReinitSPCs(FemModel* femmodel){/*{{{*/ 364 520 365 521 int i,k, numnodes; … … 369 525 /* deactivate all spcs */ 370 526 for(i=0;i<femmodel->elements->Size();i++){ 371 element= dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));527 element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 372 528 for(k=0;k<element->GetNumberOfNodes();k++){ 373 529 node=element->GetNode(k); … … 382 538 /* reactivate spcs on elements intersected by zero levelset */ 383 539 for(i=0;i<femmodel->elements->Size();i++){ 384 element= dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));540 element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 385 541 if(element->IsZeroLevelset(MaskIceLevelsetEnum)){ 386 542 /*iterate over nodes and set spc */ … … 399 555 400 556 }/*}}}*/ 401 void LsfReinitializationAnalysis::SetDistanceOnIntersectedElements(FemModel* femmodel){/*{{{*/ 402 403 /* Intermediaries */ 404 int i; 405 IssmDouble dmaxp,dmaxm,val; 406 Element* element; 407 408 /*Initialize vector with number of vertices*/ 409 int numvertices=femmodel->vertices->NumberOfVertices(); 410 411 Vector<IssmDouble>* vec_dist_zerolevelset = NULL; 412 GetVectorFromInputsx(&vec_dist_zerolevelset, femmodel, MaskIceLevelsetEnum, VertexEnum); 413 414 /* set distance on elements intersected by zero levelset */ 415 for(i=0;i<femmodel->elements->Size();i++){ 416 element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i)); 417 if(element->IsZeroLevelset(MaskIceLevelsetEnum)){ 418 SetDistanceToZeroLevelsetElement(vec_dist_zerolevelset, element); 419 } 420 } 421 vec_dist_zerolevelset->Assemble(); 422 423 /* Get maximum distance to interface along vertices */ 424 dmaxp=0.; dmaxm=0.; 425 for(i=0;i<numvertices;i++){ 426 vec_dist_zerolevelset->GetValue(&val,i); 427 if((val>0.) && (val>dmaxp)) 428 dmaxp=val; 429 else if((val<0.) && (val<dmaxm)) 430 dmaxm=val; 431 } 432 //wait until all values are computed 433 434 /* set all none intersected vertices to max/min distance */ 435 for(i=0;i<numvertices;i++){ 436 vec_dist_zerolevelset->GetValue(&val,i); 437 if(val==1.) //FIXME: improve check 438 vec_dist_zerolevelset->SetValue(i,3.*dmaxp,INS_VAL); 439 else if(val==-1.) 440 vec_dist_zerolevelset->SetValue(i,3.*dmaxm,INS_VAL); 441 } 442 443 /*Assemble vector and serialize */ 444 vec_dist_zerolevelset->Assemble(); 445 IssmDouble* dist_zerolevelset=vec_dist_zerolevelset->ToMPISerial(); 446 InputUpdateFromVectorx(femmodel,dist_zerolevelset,MaskIceLevelsetEnum,VertexSIdEnum); 447 448 /*Clean up and return*/ 449 delete vec_dist_zerolevelset; 450 delete dist_zerolevelset; 451 452 }/*}}}*/ 453 void LsfReinitializationAnalysis::SetDistanceToZeroLevelsetElement(Vector<IssmDouble>* vec_signed_dist, Element* element){/*{{{*/ 454 455 if(!element->IsZeroLevelset(MaskIceLevelsetEnum)) 456 return; 457 458 /* Intermediaries */ 459 int dim=3; 460 int i,d; 461 IssmDouble dist,lsf_old; 462 463 int numvertices=element->GetNumberOfVertices(); 464 465 IssmDouble* lsf = xNew<IssmDouble>(numvertices); 466 IssmDouble* sign_lsf = xNew<IssmDouble>(numvertices); 467 IssmDouble* signed_dist = xNew<IssmDouble>(numvertices); 468 IssmDouble* s0 = xNew<IssmDouble>(dim); 469 IssmDouble* s1 = xNew<IssmDouble>(dim); 470 IssmDouble* v = xNew<IssmDouble>(dim); 471 IssmDouble* xyz_list = NULL; 472 IssmDouble* xyz_list_zero = NULL; 473 474 /* retrieve inputs and parameters */ 475 element->GetVerticesCoordinates(&xyz_list); 476 element->GetInputListOnVertices(lsf,MaskIceLevelsetEnum); 477 478 /* get sign of levelset function */ 479 for(i=0;i<numvertices;i++) 480 sign_lsf[i]=(lsf[i]>=0.?1.:-1.); 481 482 element->ZeroLevelsetCoordinates(&xyz_list_zero, xyz_list, MaskIceLevelsetEnum); 483 for(i=0;i<dim;i++){ 484 s0[i]=xyz_list_zero[0+i]; 485 s1[i]=xyz_list_zero[3+i]; 486 } 487 488 /* get signed_distance of vertices to zero levelset straight */ 489 for(i=0;i<numvertices;i++){ 490 for(d=0;d<dim;d++) 491 v[d]=xyz_list[dim*i+d]; 492 dist=GetDistanceToStraight(&v[0],&s0[0],&s1[0]); 493 signed_dist[i]=sign_lsf[i]*dist; 494 } 495 496 /* insert signed_distance into vec_signed_dist, if computed distance is smaller */ 497 for(i=0;i<numvertices;i++){ 498 vec_signed_dist->GetValue(&lsf_old, element->vertices[i]->Sid()); 499 /* initial lsf values are +-1. Update those fields or if distance to interface smaller.*/ 500 if(fabs(lsf_old)==1. || fabs(signed_dist[i])<fabs(lsf_old)) 501 vec_signed_dist->SetValue(element->vertices[i]->Sid(),signed_dist[i],INS_VAL); 502 } 503 504 xDelete<IssmDouble>(lsf); 505 xDelete<IssmDouble>(sign_lsf); 506 xDelete<IssmDouble>(signed_dist); 507 xDelete<IssmDouble>(s0); 508 xDelete<IssmDouble>(s1); 509 xDelete<IssmDouble>(v); 510 511 }/*}}}*/ 512 IssmDouble LsfReinitializationAnalysis::GetDistanceToStraight(IssmDouble* q, IssmDouble* s0, IssmDouble* s1){/*{{{*/ 513 // returns distance d of point q to straight going through points s0, s1 514 // d=|a x b|/|b| 515 // with a=q-s0, b=s1-s0 516 517 /* Intermediaries */ 518 const int dim=2; 519 int i; 520 IssmDouble a[dim], b[dim]; 521 IssmDouble norm_b; 522 523 for(i=0;i<dim;i++){ 524 a[i]=q[i]-s0[i]; 525 b[i]=s1[i]-s0[i]; 526 } 527 528 norm_b=0.; 529 for(i=0;i<dim;i++) 530 norm_b+=b[i]*b[i]; 531 norm_b=sqrt(norm_b); 532 _assert_(norm_b>0.); 533 534 return fabs(a[0]*b[1]-a[1]*b[0])/norm_b; 535 }/*}}}*/ 536 bool LsfReinitializationAnalysis::ReinitConvergence(Vector<IssmDouble>* lsfg,Vector<IssmDouble>* lsfg_old,IssmDouble reltol){/*{{{*/ 537 538 /*Output*/ 539 bool converged = true; 540 541 /*Intermediary*/ 542 Vector<IssmDouble>* dlsfg = NULL; 543 IssmDouble norm_dlsf,norm_lsf; 544 545 /*compute norm(du)/norm(u)*/ 546 dlsfg=lsfg_old->Duplicate(); lsfg_old->Copy(dlsfg); dlsfg->AYPX(lsfg,-1.0); 547 norm_dlsf=dlsfg->Norm(NORM_TWO); norm_lsf=lsfg_old->Norm(NORM_TWO); 548 if (xIsNan<IssmDouble>(norm_dlsf) || xIsNan<IssmDouble>(norm_lsf)) _error_("convergence criterion is NaN!"); 549 if((norm_dlsf/norm_lsf)<reltol){ 550 if(VerboseConvergence()) _printf0_("\n"<<setw(50)<<left<<" Velocity convergence: norm(du)/norm(u)"<<norm_dlsf/norm_lsf*100<<" < "<<reltol*100<<" %\n"); 551 } 552 else{ 553 if(VerboseConvergence()) _printf0_("\n"<<setw(50)<<left<<" Velocity convergence: norm(du)/norm(u)"<<norm_dlsf/norm_lsf*100<<" > "<<reltol*100<<" %\n"); 554 converged=false; 555 } 556 557 /*Cleanup*/ 558 delete dlsfg; 559 560 return converged; 561 }/*}}}*/ 557 void LsfReinitializationAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 558 /* Do nothing for now */ 559 }/*}}}*/ -
issm/trunk/src/c/analyses/LsfReinitializationAnalysis.h
r18301 r19105 13 13 public: 14 14 /*Model processing*/ 15 int DofsPerNode(int** doflist,int domaintype,int approximation);16 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum);17 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type);18 void CreateNodes(Nodes* nodes,IoModel* iomodel);19 15 void CreateConstraints(Constraints* constraints,IoModel* iomodel); 20 16 void CreateLoads(Loads* loads, IoModel* iomodel); 17 void CreateNodes(Nodes* nodes,IoModel* iomodel); 18 int DofsPerNode(int** doflist,int domaintype,int approximation); 19 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 20 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum); 21 21 22 22 /*Finite element Analysis*/ … … 26 26 ElementMatrix* CreateKMatrix(Element* element); 27 27 ElementVector* CreatePVector(Element* element); 28 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 29 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 30 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 31 void UpdateConstraints(FemModel* femmodel); 32 void GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss); 33 void GetBprime(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss); 34 35 /* Other */ 36 void SetReinitSPCs(FemModel* femmodel); 37 void SetDistanceOnIntersectedElements(FemModel* femmodel); 38 void SetDistanceToZeroLevelsetElement(Vector<IssmDouble>* vec_dist, Element* element); 39 IssmDouble GetDistanceToStraight(IssmDouble* q, IssmDouble* s0, IssmDouble* s1); 40 bool ReinitConvergence(Vector<IssmDouble>* lsfg,Vector<IssmDouble>* lsfg_old,IssmDouble reltol); 28 void GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss); 29 void GetBprime(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss); 30 IssmDouble GetDistanceToStraight(IssmDouble* q, IssmDouble* s0, IssmDouble* s1); 31 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 32 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 33 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 34 bool ReinitConvergence(Vector<IssmDouble>* lsfg,Vector<IssmDouble>* lsfg_old,IssmDouble reltol); 35 void SetDistanceOnIntersectedElements(FemModel* femmodel); 36 void SetDistanceToZeroLevelsetElement(Vector<IssmDouble>* vec_dist, Element* element); 37 void SetReinitSPCs(FemModel* femmodel); 38 void UpdateConstraints(FemModel* femmodel); 41 39 }; 42 40 #endif -
issm/trunk/src/c/analyses/MasstransportAnalysis.cpp
r18301 r19105 6 6 7 7 /*Model processing*/ 8 void MasstransportAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 9 10 /*Fetch parameters: */ 11 int stabilization; 12 iomodel->Constant(&stabilization,MasstransportStabilizationEnum); 13 14 /*Do not add constraints in DG, they are weakly imposed*/ 15 if(stabilization!=3){ 16 IoModelToConstraintsx(constraints,iomodel,MasstransportSpcthicknessEnum,MasstransportAnalysisEnum,P1Enum); 17 } 18 19 /*FCT, constraints are imposed using penalties*/ 20 if(stabilization==4){ 21 constraints->ActivatePenaltyMethod(MasstransportAnalysisEnum); 22 } 23 }/*}}}*/ 24 void MasstransportAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 25 26 /*Intermediaries*/ 27 int element; 28 int penpair_ids[2]; 29 int count=0; 30 int stabilization; 31 int numvertex_pairing; 32 33 /*Fetch parameters: */ 34 iomodel->Constant(&stabilization,MasstransportStabilizationEnum); 35 36 /*Loads only in DG*/ 37 if (stabilization==3){ 38 39 /*Get faces and elements*/ 40 CreateFaces(iomodel); 41 iomodel->FetchData(1,ThicknessEnum); 42 43 /*First load data:*/ 44 for(int i=0;i<iomodel->numberoffaces;i++){ 45 46 /*Get left and right elements*/ 47 element=iomodel->faces[4*i+2]-1; //faces are [node1 node2 elem1 elem2] 48 49 /*Now, if this element is not in the partition, pass: */ 50 if(!iomodel->my_elements[element]) continue; 51 52 /* Add load */ 53 loads->AddObject(new Numericalflux(iomodel->loadcounter+i+1,i,i,iomodel,MasstransportAnalysisEnum)); 54 } 55 56 /*Free data: */ 57 iomodel->DeleteData(1,ThicknessEnum); 58 } 59 60 /*Create Penpair for vertex_pairing: */ 61 IssmDouble *vertex_pairing=NULL; 62 IssmDouble *nodeonbase=NULL; 63 iomodel->FetchData(&vertex_pairing,&numvertex_pairing,NULL,MasstransportVertexPairingEnum); 64 if(iomodel->domaintype!=Domain2DhorizontalEnum) iomodel->FetchData(&nodeonbase,NULL,NULL,MeshVertexonbaseEnum); 65 66 for(int i=0;i<numvertex_pairing;i++){ 67 68 if(iomodel->my_vertices[reCast<int>(vertex_pairing[2*i+0])-1]){ 69 70 /*In debugging mode, check that the second node is in the same cpu*/ 71 _assert_(iomodel->my_vertices[reCast<int>(vertex_pairing[2*i+1])-1]); 72 73 /*Skip if one of the two is not on the bed*/ 74 if(iomodel->domaintype!=Domain2DhorizontalEnum){ 75 if(!(reCast<bool>(nodeonbase[reCast<int>(vertex_pairing[2*i+0])-1])) || !(reCast<bool>(nodeonbase[reCast<int>(vertex_pairing[2*i+1])-1]))) continue; 76 } 77 78 /*Get node ids*/ 79 penpair_ids[0]=iomodel->nodecounter+reCast<int>(vertex_pairing[2*i+0]); 80 penpair_ids[1]=iomodel->nodecounter+reCast<int>(vertex_pairing[2*i+1]); 81 82 /*Create Load*/ 83 loads->AddObject(new Penpair( 84 iomodel->loadcounter+count+1, 85 &penpair_ids[0], 86 MasstransportAnalysisEnum)); 87 count++; 88 } 89 } 90 91 /*free ressources: */ 92 iomodel->DeleteData(vertex_pairing,MasstransportVertexPairingEnum); 93 iomodel->DeleteData(nodeonbase,MeshVertexonbaseEnum); 94 95 }/*}}}*/ 96 void MasstransportAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 97 98 /*Fetch parameters: */ 99 int stabilization; 100 iomodel->Constant(&stabilization,MasstransportStabilizationEnum); 101 102 /*Check in 3d*/ 103 if(stabilization==3 && iomodel->domaintype==Domain3DEnum) _error_("DG 3d not implemented yet"); 104 105 /*Create Nodes either DG or CG depending on stabilization*/ 106 if(iomodel->domaintype!=Domain2DhorizontalEnum) iomodel->FetchData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 107 if(stabilization!=3){ 108 ::CreateNodes(nodes,iomodel,MasstransportAnalysisEnum,P1Enum); 109 } 110 else{ 111 ::CreateNodes(nodes,iomodel,MasstransportAnalysisEnum,P1DGEnum); 112 } 113 iomodel->DeleteData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 114 }/*}}}*/ 8 115 int MasstransportAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/ 9 116 return 1; 10 117 }/*}}}*/ 11 void MasstransportAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/12 13 int numoutputs;14 char** requestedoutputs = NULL;15 16 parameters->AddObject(iomodel->CopyConstantObject(FlowequationIsFSEnum));17 18 parameters->AddObject(iomodel->CopyConstantObject(MasstransportIsfreesurfaceEnum));19 parameters->AddObject(iomodel->CopyConstantObject(MasstransportHydrostaticAdjustmentEnum));20 parameters->AddObject(iomodel->CopyConstantObject(MasstransportStabilizationEnum));21 parameters->AddObject(iomodel->CopyConstantObject(MasstransportMinThicknessEnum));22 parameters->AddObject(iomodel->CopyConstantObject(MasstransportPenaltyFactorEnum));23 24 iomodel->FetchData(&requestedoutputs,&numoutputs,MasstransportRequestedOutputsEnum);25 parameters->AddObject(new IntParam(MasstransportNumRequestedOutputsEnum,numoutputs));26 if(numoutputs)parameters->AddObject(new StringArrayParam(MasstransportRequestedOutputsEnum,requestedoutputs,numoutputs));27 iomodel->DeleteData(&requestedoutputs,numoutputs,MasstransportRequestedOutputsEnum);28 29 }/*}}}*/30 118 void MasstransportAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ 31 119 32 120 int stabilization,finiteelement,smb_model; 33 121 bool dakota_analysis; 34 bool isdelta18o ;122 bool isdelta18o,ismungsm; 35 123 bool isgroundingline; 36 124 bool islevelset; … … 72 160 iomodel->FetchDataToInput(elements,MasstransportSpcthicknessEnum); //for DG, we need the spc in the element 73 161 } 162 if(stabilization==4){ 163 iomodel->FetchDataToInput(elements,MasstransportSpcthicknessEnum); //for FCT, we need the spc in the element (penlaties) 164 } 74 165 75 166 if(iomodel->domaintype!=Domain2DhorizontalEnum){ … … 88 179 case SMBpddEnum: 89 180 iomodel->Constant(&isdelta18o,SurfaceforcingsIsdelta18oEnum); 181 iomodel->Constant(&ismungsm,SurfaceforcingsIsmungsmEnum); 90 182 iomodel->FetchDataToInput(elements,ThermalSpctemperatureEnum); 91 if(isdelta18o ){183 if(isdelta18o || ismungsm){ 92 184 iomodel->FetchDataToInput(elements,SurfaceforcingsTemperaturesLgmEnum); 93 185 iomodel->FetchDataToInput(elements,SurfaceforcingsTemperaturesPresentdayEnum); 94 186 iomodel->FetchDataToInput(elements,SurfaceforcingsPrecipitationsPresentdayEnum); 187 iomodel->FetchDataToInput(elements,SurfaceforcingsPrecipitationsLgmEnum); 95 188 } 96 189 else{ 97 190 iomodel->FetchDataToInput(elements,SurfaceforcingsPrecipitationEnum); 98 191 iomodel->FetchDataToInput(elements,SurfaceforcingsMonthlytemperaturesEnum); 99 192 } 193 100 194 break; 101 195 case SMBgradientsEnum: … … 124 218 125 219 }/*}}}*/ 126 void MasstransportAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 127 128 /*Fetch parameters: */ 129 int stabilization; 130 iomodel->Constant(&stabilization,MasstransportStabilizationEnum); 131 132 /*Check in 3d*/ 133 if(stabilization==3 && iomodel->domaintype==Domain3DEnum) _error_("DG 3d not implemented yet"); 134 135 /*Create Nodes either DG or CG depending on stabilization*/ 136 if(iomodel->domaintype!=Domain2DhorizontalEnum) iomodel->FetchData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 137 if(stabilization!=3){ 138 ::CreateNodes(nodes,iomodel,MasstransportAnalysisEnum,P1Enum); 139 } 140 else{ 141 ::CreateNodes(nodes,iomodel,MasstransportAnalysisEnum,P1DGEnum); 142 } 143 iomodel->DeleteData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 144 }/*}}}*/ 145 void MasstransportAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 146 147 /*Fetch parameters: */ 148 int stabilization; 149 iomodel->Constant(&stabilization,MasstransportStabilizationEnum); 150 151 /*Do not add constraints in DG, they are weakly imposed*/ 152 if(stabilization!=3){ 153 IoModelToConstraintsx(constraints,iomodel,MasstransportSpcthicknessEnum,MasstransportAnalysisEnum,P1Enum); 154 } 155 }/*}}}*/ 156 void MasstransportAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 157 158 /*Intermediaries*/ 159 int element; 160 int penpair_ids[2]; 161 int count=0; 162 int stabilization; 163 int numvertex_pairing; 164 165 /*Fetch parameters: */ 166 iomodel->Constant(&stabilization,MasstransportStabilizationEnum); 167 168 /*Loads only in DG*/ 169 if (stabilization==3){ 170 171 /*Get faces and elements*/ 172 CreateFaces(iomodel); 173 iomodel->FetchData(1,ThicknessEnum); 174 175 /*First load data:*/ 176 for(int i=0;i<iomodel->numberoffaces;i++){ 177 178 /*Get left and right elements*/ 179 element=iomodel->faces[4*i+2]-1; //faces are [node1 node2 elem1 elem2] 180 181 /*Now, if this element is not in the partition, pass: */ 182 if(!iomodel->my_elements[element]) continue; 183 184 /* Add load */ 185 loads->AddObject(new Numericalflux(iomodel->loadcounter+i+1,i,i,iomodel,MasstransportAnalysisEnum)); 186 } 187 188 /*Free data: */ 189 iomodel->DeleteData(1,ThicknessEnum); 190 } 191 192 /*Create Penpair for vertex_pairing: */ 193 IssmDouble *vertex_pairing=NULL; 194 IssmDouble *nodeonbase=NULL; 195 iomodel->FetchData(&vertex_pairing,&numvertex_pairing,NULL,MasstransportVertexPairingEnum); 196 if(iomodel->domaintype!=Domain2DhorizontalEnum) iomodel->FetchData(&nodeonbase,NULL,NULL,MeshVertexonbaseEnum); 197 198 for(int i=0;i<numvertex_pairing;i++){ 199 200 if(iomodel->my_vertices[reCast<int>(vertex_pairing[2*i+0])-1]){ 201 202 /*In debugging mode, check that the second node is in the same cpu*/ 203 _assert_(iomodel->my_vertices[reCast<int>(vertex_pairing[2*i+1])-1]); 204 205 /*Skip if one of the two is not on the bed*/ 206 if(iomodel->domaintype!=Domain2DhorizontalEnum){ 207 if(!(reCast<bool>(nodeonbase[reCast<int>(vertex_pairing[2*i+0])-1])) || !(reCast<bool>(nodeonbase[reCast<int>(vertex_pairing[2*i+1])-1]))) continue; 208 } 209 210 /*Get node ids*/ 211 penpair_ids[0]=iomodel->nodecounter+reCast<int>(vertex_pairing[2*i+0]); 212 penpair_ids[1]=iomodel->nodecounter+reCast<int>(vertex_pairing[2*i+1]); 213 214 /*Create Load*/ 215 loads->AddObject(new Penpair( 216 iomodel->loadcounter+count+1, 217 &penpair_ids[0], 218 MasstransportAnalysisEnum)); 219 count++; 220 } 221 } 222 223 /*free ressources: */ 224 iomodel->DeleteData(vertex_pairing,MasstransportVertexPairingEnum); 225 iomodel->DeleteData(nodeonbase,MeshVertexonbaseEnum); 220 void MasstransportAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 221 222 int numoutputs; 223 char** requestedoutputs = NULL; 224 225 parameters->AddObject(iomodel->CopyConstantObject(FlowequationIsFSEnum)); 226 parameters->AddObject(iomodel->CopyConstantObject(MasstransportIsfreesurfaceEnum)); 227 parameters->AddObject(iomodel->CopyConstantObject(MasstransportHydrostaticAdjustmentEnum)); 228 parameters->AddObject(iomodel->CopyConstantObject(MasstransportStabilizationEnum)); 229 parameters->AddObject(iomodel->CopyConstantObject(MasstransportMinThicknessEnum)); 230 parameters->AddObject(iomodel->CopyConstantObject(MasstransportPenaltyFactorEnum)); 231 232 iomodel->FetchData(&requestedoutputs,&numoutputs,MasstransportRequestedOutputsEnum); 233 parameters->AddObject(new IntParam(MasstransportNumRequestedOutputsEnum,numoutputs)); 234 if(numoutputs)parameters->AddObject(new StringArrayParam(MasstransportRequestedOutputsEnum,requestedoutputs,numoutputs)); 235 iomodel->DeleteData(&requestedoutputs,numoutputs,MasstransportRequestedOutputsEnum); 226 236 227 237 }/*}}}*/ … … 362 372 &Ke->values[0],1); 363 373 364 if(stabilization==2){ 365 if(dim==1){ 366 vel=fabs(vx)+1.e-8; 367 D[0]=h/(2*vel)*vx*vx; 368 } 369 else{ 370 /*Streamline upwinding*/ 371 vel=sqrt(vx*vx+vy*vy)+1.e-8; 372 D[0*dim+0]=h/(2*vel)*vx*vx; 373 D[1*dim+0]=h/(2*vel)*vy*vx; 374 D[0*dim+1]=h/(2*vel)*vx*vy; 375 D[1*dim+1]=h/(2*vel)*vy*vy; 376 } 377 } 378 else if(stabilization==1){ 379 /*SSA*/ 380 vxaverage_input->GetInputAverage(&vx); 381 if(dim==2) vyaverage_input->GetInputAverage(&vy); 382 D[0*dim+0]=h/2.0*fabs(vx); 383 if(dim==2) D[1*dim+1]=h/2.0*fabs(vy); 374 switch(stabilization){ 375 case 0: 376 /*Nothing to be onde*/ 377 break; 378 case 1: 379 /*SSA*/ 380 vxaverage_input->GetInputAverage(&vx); 381 if(dim==2) vyaverage_input->GetInputAverage(&vy); 382 D[0*dim+0]=h/2.0*fabs(vx); 383 if(dim==2) D[1*dim+1]=h/2.0*fabs(vy); 384 break; 385 case 2: 386 if(dim==1){ 387 vel=fabs(vx)+1.e-8; 388 D[0]=h/(2*vel)*vx*vx; 389 } 390 else{ 391 /*Streamline upwinding*/ 392 vel=sqrt(vx*vx+vy*vy)+1.e-8; 393 D[0*dim+0]=h/(2*vel)*vx*vx; 394 D[1*dim+0]=h/(2*vel)*vy*vx; 395 D[0*dim+1]=h/(2*vel)*vx*vy; 396 D[1*dim+1]=h/(2*vel)*vy*vy; 397 } 398 break; 399 default: 400 _error_("Stabilization "<<stabilization<<" not supported yet"); 384 401 } 385 402 if(stabilization==1 || stabilization==2){ … … 611 628 return pe; 612 629 }/*}}}*/ 613 void MasstransportAnalysis::GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/630 void MasstransportAnalysis::GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 614 631 /*Compute B matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2. 615 632 * For node i, Bi can be expressed in the actual coordinate system … … 639 656 xDelete<IssmDouble>(basis); 640 657 }/*}}}*/ 641 void MasstransportAnalysis::GetBprime(IssmDouble* Bprime,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/658 void MasstransportAnalysis::GetBprime(IssmDouble* Bprime,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 642 659 /*Compute B' matrix. B'=[B1' B2' B3'] where Bi' is of size 3*NDOF2. 643 660 * For node i, Bi' can be expressed in the actual coordinate system … … 668 685 669 686 }/*}}}*/ 670 void MasstransportAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/671 _error_("not implemented yet");672 }/*}}}*/ 673 void MasstransportAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/687 void MasstransportAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 688 element->GetSolutionFromInputsOneDof(solution,ThicknessEnum); 689 }/*}}}*/ 690 void MasstransportAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 674 691 _error_("Not implemented yet"); 675 692 }/*}}}*/ 676 void MasstransportAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/693 void MasstransportAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 677 694 678 695 int i,hydroadjustment,domaintype; … … 758 775 if(domaintype!=Domain2DhorizontalEnum){basalelement->DeleteMaterials(); delete basalelement;}; 759 776 }/*}}}*/ 760 void MasstransportAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/777 void MasstransportAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 761 778 762 779 bool islevelset; … … 767 784 return; 768 785 }/*}}}*/ 786 787 /*Flux Correction Transport*/ 788 ElementMatrix* MasstransportAnalysis::CreateFctKMatrix(Element* element){/*{{{*/ 789 790 /* Check if ice in element */ 791 if(!element->IsIceInElement()) return NULL; 792 793 /*Intermediaries */ 794 IssmDouble Jdet; 795 IssmDouble vx,vy; 796 IssmDouble* xyz_list = NULL; 797 798 /*Fetch number of nodes and dof for this finite element*/ 799 int numnodes = element->GetNumberOfNodes(); 800 int dim = 2; 801 802 /*Initialize Element vector and other vectors*/ 803 ElementMatrix* Ke = element->NewElementMatrix(); 804 IssmDouble* B = xNew<IssmDouble>(dim*numnodes); 805 IssmDouble* Bprime = xNew<IssmDouble>(dim*numnodes); 806 IssmDouble* D = xNewZeroInit<IssmDouble>(dim*dim); 807 808 /*Retrieve all inputs and parameters*/ 809 element->GetVerticesCoordinates(&xyz_list); 810 Input* vxaverage_input=element->GetInput(VxEnum); _assert_(vxaverage_input); 811 Input* vyaverage_input=element->GetInput(VyEnum); _assert_(vyaverage_input); 812 813 /* Start looping on the number of gaussian points: */ 814 Gauss* gauss=element->NewGauss(2); 815 for(int ig=gauss->begin();ig<gauss->end();ig++){ 816 gauss->GaussPoint(ig); 817 818 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 819 GetB(B,element,dim,xyz_list,gauss); 820 GetBprime(Bprime,element,dim,xyz_list,gauss); 821 vxaverage_input->GetInputValue(&vx,gauss); 822 vyaverage_input->GetInputValue(&vy,gauss); 823 824 D[0*dim+0] = -gauss->weight*vx*Jdet; 825 D[1*dim+1] = -gauss->weight*vy*Jdet; 826 827 TripleMultiply(B,dim,numnodes,1, 828 D,dim,dim,0, 829 Bprime,dim,numnodes,0, 830 &Ke->values[0],1); 831 832 } 833 834 /*Clean up and return*/ 835 xDelete<IssmDouble>(xyz_list); 836 xDelete<IssmDouble>(B); 837 xDelete<IssmDouble>(Bprime); 838 xDelete<IssmDouble>(D); 839 delete gauss; 840 return Ke; 841 }/*}}}*/ 842 ElementMatrix* MasstransportAnalysis::CreateMassMatrix(Element* element){/*{{{*/ 843 844 /* Check if ice in element */ 845 if(!element->IsIceInElement()) return NULL; 846 847 /*Intermediaries*/ 848 IssmDouble D,Jdet; 849 IssmDouble* xyz_list = NULL; 850 851 /*Fetch number of nodes and dof for this finite element*/ 852 int numnodes = element->GetNumberOfNodes(); 853 854 /*Initialize Element vector and other vectors*/ 855 ElementMatrix* Me = element->NewElementMatrix(); 856 IssmDouble* basis = xNew<IssmDouble>(numnodes); 857 858 /*Retrieve all inputs and parameters*/ 859 element->GetVerticesCoordinates(&xyz_list); 860 861 /* Start looping on the number of gaussian points: */ 862 Gauss* gauss=element->NewGauss(2); 863 for(int ig=gauss->begin();ig<gauss->end();ig++){ 864 gauss->GaussPoint(ig); 865 866 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 867 element->NodalFunctions(basis,gauss); 868 869 D=gauss->weight*Jdet; 870 TripleMultiply(basis,1,numnodes,1, 871 &D,1,1,0, 872 basis,1,numnodes,0, 873 &Me->values[0],1); 874 } 875 876 /*Clean up and return*/ 877 xDelete<IssmDouble>(xyz_list); 878 xDelete<IssmDouble>(basis); 879 delete gauss; 880 return Me; 881 }/*}}}*/ 882 void MasstransportAnalysis::FctKMatrix(Matrix<IssmDouble>** pKff,Matrix<IssmDouble>** pKfs,FemModel* femmodel){/*{{{*/ 883 884 /*Output*/ 885 Matrix<IssmDouble>* Kff = NULL; 886 Matrix<IssmDouble>* Kfs = NULL; 887 888 /*Initialize Jacobian Matrix*/ 889 AllocateSystemMatricesx(&Kff,&Kfs,NULL,NULL,femmodel); 890 891 /*Create and assemble matrix*/ 892 for(int i=0;i<femmodel->elements->Size();i++){ 893 Element* element = xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 894 ElementMatrix* Ke = this->CreateFctKMatrix(element); 895 if(Ke) Ke->AddToGlobal(Kff,Kfs); 896 delete Ke; 897 } 898 Kff->Assemble(); 899 Kfs->Assemble(); 900 901 /*Assign output pointer*/ 902 *pKff=Kff; 903 if(pKfs){ 904 *pKfs=Kfs; 905 } 906 else{ 907 delete Kfs; 908 } 909 }/*}}}*/ 910 void MasstransportAnalysis::LumpedMassMatrix(Vector<IssmDouble>** pMlff,FemModel* femmodel){/*{{{*/ 911 912 /*Intermediaries*/ 913 int configuration_type; 914 915 /*Initialize Lumped mass matrix (actually we just save its diagonal)*/ 916 femmodel->parameters->FindParam(&configuration_type,ConfigurationTypeEnum); 917 int fsize = femmodel->nodes->NumberOfDofs(configuration_type,FsetEnum); 918 int flocalsize = femmodel->nodes->NumberOfDofsLocal(configuration_type,FsetEnum); 919 Vector<IssmDouble>* Mlff = new Vector<IssmDouble>(flocalsize,fsize); 920 921 /*Create and assemble matrix*/ 922 for(int i=0;i<femmodel->elements->Size();i++){ 923 Element* element = xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 924 ElementMatrix* MLe = this->CreateMassMatrix(element); 925 if(MLe){ 926 MLe->Lump(); 927 MLe->AddDiagonalToGlobal(Mlff); 928 } 929 delete MLe; 930 } 931 Mlff->Assemble(); 932 933 /*Assign output pointer*/ 934 *pMlff=Mlff; 935 }/*}}}*/ 936 void MasstransportAnalysis::MassMatrix(Matrix<IssmDouble>** pMff,FemModel* femmodel){/*{{{*/ 937 938 /*Initialize Mass matrix*/ 939 Matrix<IssmDouble> *Mff = NULL; 940 AllocateSystemMatricesx(&Mff,NULL,NULL,NULL,femmodel); 941 942 /*Create and assemble matrix*/ 943 for(int i=0;i<femmodel->elements->Size();i++){ 944 Element* element = xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 945 ElementMatrix* MLe = this->CreateMassMatrix(element); 946 if(MLe){ 947 MLe->AddToGlobal(Mff); 948 } 949 delete MLe; 950 } 951 Mff->Assemble(); 952 953 /*Assign output pointer*/ 954 *pMff=Mff; 955 }/*}}}*/ -
issm/trunk/src/c/analyses/MasstransportAnalysis.h
r18301 r19105 13 13 public: 14 14 /*Model processing*/ 15 int DofsPerNode(int** doflist,int domaintype,int approximation);16 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum);17 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type);18 void CreateNodes(Nodes* nodes,IoModel* iomodel);19 15 void CreateConstraints(Constraints* constraints,IoModel* iomodel); 20 16 void CreateLoads(Loads* loads, IoModel* iomodel); 17 void CreateNodes(Nodes* nodes,IoModel* iomodel); 18 int DofsPerNode(int** doflist,int domaintype,int approximation); 19 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 20 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum); 21 21 22 22 /*Finite element Analysis*/ … … 30 30 ElementVector* CreatePVectorCG(Element* element); 31 31 ElementVector* CreatePVectorDG(Element* element); 32 void GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 33 void GetBprime(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 34 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 35 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 36 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 37 void UpdateConstraints(FemModel* femmodel); 32 void GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 33 void GetBprime(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 34 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 35 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 36 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 37 void UpdateConstraints(FemModel* femmodel); 38 39 /*FCT*/ 40 ElementMatrix* CreateFctKMatrix(Element* element); 41 ElementMatrix* CreateMassMatrix(Element* element); 42 void FctKMatrix(Matrix<IssmDouble>** pKff,Matrix<IssmDouble>** pKfs,FemModel* femmodel); 43 void LumpedMassMatrix(Vector<IssmDouble>** pMLff,FemModel* femmodel); 44 void MassMatrix(Matrix<IssmDouble>** pMff,FemModel* femmodel); 38 45 }; 39 46 #endif -
issm/trunk/src/c/analyses/MeltingAnalysis.cpp
r18301 r19105 6 6 7 7 /*Model processing*/ 8 int MeltingAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/9 return 1;10 }/*}}}*/11 void MeltingAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/12 parameters->AddObject(iomodel->CopyConstantObject(FrictionLawEnum));13 }/*}}}*/14 void MeltingAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/15 16 int frictionlaw;17 18 /*Now, is the model 3d? otherwise, do nothing: */19 if(iomodel->domaintype==Domain2DhorizontalEnum)return;20 21 /*Update elements: */22 int counter=0;23 for(int i=0;i<iomodel->numberofelements;i++){24 if(iomodel->my_elements[i]){25 Element* element=(Element*)elements->GetObjectByOffset(counter);26 element->Update(i,iomodel,analysis_counter,analysis_type,P1Enum);27 counter++;28 }29 }30 31 iomodel->Constant(&frictionlaw,FrictionLawEnum);32 33 /*Create inputs: */34 iomodel->FetchDataToInput(elements,ThicknessEnum);35 iomodel->FetchDataToInput(elements,SurfaceEnum);36 iomodel->FetchDataToInput(elements,BaseEnum);37 iomodel->FetchDataToInput(elements,MaskIceLevelsetEnum);38 if(iomodel->domaintype!=Domain2DhorizontalEnum){39 iomodel->FetchDataToInput(elements,MeshVertexonbaseEnum);40 iomodel->FetchDataToInput(elements,MeshVertexonsurfaceEnum);41 }42 iomodel->FetchDataToInput(elements,FlowequationElementEquationEnum);43 iomodel->FetchDataToInput(elements,MaterialsRheologyBEnum);44 iomodel->FetchDataToInput(elements,MaterialsRheologyNEnum);45 iomodel->FetchDataToInput(elements,BasalforcingsGroundediceMeltingRateEnum);46 iomodel->FetchDataToInput(elements,PressureEnum);47 48 /*Friction law variables*/49 switch(frictionlaw){50 case 1:51 iomodel->FetchDataToInput(elements,FrictionCoefficientEnum);52 iomodel->FetchDataToInput(elements,FrictionPEnum);53 iomodel->FetchDataToInput(elements,FrictionQEnum);54 break;55 case 2:56 iomodel->FetchDataToInput(elements,FrictionCEnum);57 iomodel->FetchDataToInput(elements,FrictionMEnum);58 break;59 default:60 _error_("not supported");61 }62 }/*}}}*/63 void MeltingAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/64 65 if(iomodel->domaintype==Domain3DEnum) iomodel->FetchData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum);66 ::CreateNodes(nodes,iomodel,MeltingAnalysisEnum,P1Enum);67 iomodel->DeleteData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum);68 }/*}}}*/69 8 void MeltingAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 70 9 /*No Constraints*/ … … 88 27 iomodel->DeleteData(1,MeshVertexonbaseEnum); 89 28 29 }/*}}}*/ 30 void MeltingAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 31 32 if(iomodel->domaintype==Domain3DEnum) iomodel->FetchData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 33 ::CreateNodes(nodes,iomodel,MeltingAnalysisEnum,P1Enum); 34 iomodel->DeleteData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 35 }/*}}}*/ 36 int MeltingAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/ 37 return 1; 38 }/*}}}*/ 39 void MeltingAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ 40 41 int frictionlaw; 42 43 /*Now, is the model 3d? otherwise, do nothing: */ 44 if(iomodel->domaintype==Domain2DhorizontalEnum)return; 45 46 /*Update elements: */ 47 int counter=0; 48 for(int i=0;i<iomodel->numberofelements;i++){ 49 if(iomodel->my_elements[i]){ 50 Element* element=(Element*)elements->GetObjectByOffset(counter); 51 element->Update(i,iomodel,analysis_counter,analysis_type,P1Enum); 52 counter++; 53 } 54 } 55 56 /*Create inputs: */ 57 iomodel->FetchDataToInput(elements,ThicknessEnum); 58 iomodel->FetchDataToInput(elements,SurfaceEnum); 59 iomodel->FetchDataToInput(elements,BaseEnum); 60 iomodel->FetchDataToInput(elements,MaskIceLevelsetEnum); 61 if(iomodel->domaintype!=Domain2DhorizontalEnum){ 62 iomodel->FetchDataToInput(elements,MeshVertexonbaseEnum); 63 iomodel->FetchDataToInput(elements,MeshVertexonsurfaceEnum); 64 } 65 iomodel->FetchDataToInput(elements,PressureEnum); 66 }/*}}}*/ 67 void MeltingAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 90 68 }/*}}}*/ 91 69 … … 148 126 return NULL; 149 127 }/*}}}*/ 150 void MeltingAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/128 void MeltingAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 151 129 _error_("not implemented yet"); 152 130 }/*}}}*/ 153 void MeltingAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/131 void MeltingAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 154 132 _error_("Not implemented yet"); 155 133 }/*}}}*/ 156 void MeltingAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/134 void MeltingAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 157 135 element->InputUpdateFromSolutionOneDof(solution,BasalforcingsGroundediceMeltingRateEnum); 158 136 }/*}}}*/ 159 void MeltingAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/137 void MeltingAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 160 138 /*Default, do nothing*/ 161 139 return; -
issm/trunk/src/c/analyses/MeltingAnalysis.h
r18301 r19105 13 13 public: 14 14 /*Model processing*/ 15 int DofsPerNode(int** doflist,int domaintype,int approximation);16 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum);17 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type);18 void CreateNodes(Nodes* nodes,IoModel* iomodel);19 15 void CreateConstraints(Constraints* constraints,IoModel* iomodel); 20 16 void CreateLoads(Loads* loads, IoModel* iomodel); 17 void CreateNodes(Nodes* nodes,IoModel* iomodel); 18 int DofsPerNode(int** doflist,int domaintype,int approximation); 19 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 20 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum); 21 21 22 22 /*Finite element Analysis*/ … … 26 26 ElementMatrix* CreateKMatrix(Element* element); 27 27 ElementVector* CreatePVector(Element* element); 28 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element);29 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index);30 void InputUpdateFromSolution(IssmDouble* solution,Element* element);31 void UpdateConstraints(FemModel* femmodel);28 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 29 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 30 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 31 void UpdateConstraints(FemModel* femmodel); 32 32 }; 33 33 #endif -
issm/trunk/src/c/analyses/MeshdeformationAnalysis.cpp
r18301 r19105 6 6 7 7 /*Model processing*/ 8 int MeshdeformationAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/ 9 _error_("not implemented"); 10 }/*}}}*/ 11 void MeshdeformationAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 8 void MeshdeformationAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 12 9 _error_("not implemented yet"); 13 10 }/*}}}*/ 14 void MeshdeformationAnalysis:: UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/11 void MeshdeformationAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 15 12 _error_("not implemented yet"); 16 13 }/*}}}*/ … … 18 15 _error_("not implemented yet"); 19 16 }/*}}}*/ 20 void MeshdeformationAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 17 int MeshdeformationAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/ 18 _error_("not implemented"); 19 }/*}}}*/ 20 void MeshdeformationAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ 21 21 _error_("not implemented yet"); 22 22 }/*}}}*/ 23 void MeshdeformationAnalysis:: CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/23 void MeshdeformationAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 24 24 _error_("not implemented yet"); 25 25 }/*}}}*/ … … 42 42 _error_("not implemented yet"); 43 43 }/*}}}*/ 44 void MeshdeformationAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/44 void MeshdeformationAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 45 45 _error_("not implemented yet"); 46 46 }/*}}}*/ 47 void MeshdeformationAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/47 void MeshdeformationAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 48 48 _error_("Not implemented yet"); 49 49 }/*}}}*/ 50 void MeshdeformationAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/50 void MeshdeformationAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 51 51 _error_("not implemented yet"); 52 52 }/*}}}*/ 53 void MeshdeformationAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/53 void MeshdeformationAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 54 54 /*Default, do nothing*/ 55 55 return; -
issm/trunk/src/c/analyses/MeshdeformationAnalysis.h
r18301 r19105 13 13 public: 14 14 /*Model processing*/ 15 int DofsPerNode(int** doflist,int domaintype,int approximation);16 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum);17 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type);18 void CreateNodes(Nodes* nodes,IoModel* iomodel);19 15 void CreateConstraints(Constraints* constraints,IoModel* iomodel); 20 16 void CreateLoads(Loads* loads, IoModel* iomodel); 17 void CreateNodes(Nodes* nodes,IoModel* iomodel); 18 int DofsPerNode(int** doflist,int domaintype,int approximation); 19 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 20 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum); 21 21 22 22 /*Finite element Analysis*/ … … 26 26 ElementMatrix* CreateKMatrix(Element* element); 27 27 ElementVector* CreatePVector(Element* element); 28 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element);29 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index);30 void InputUpdateFromSolution(IssmDouble* solution,Element* element);31 void UpdateConstraints(FemModel* femmodel);28 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 29 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 30 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 31 void UpdateConstraints(FemModel* femmodel); 32 32 }; 33 33 #endif -
issm/trunk/src/c/analyses/StressbalanceAnalysis.cpp
r18301 r19105 11 11 12 12 /*Model processing*/ 13 void StressbalanceAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 14 15 /*Intermediary*/ 16 int i,j; 17 int count,finiteelement; 18 IssmDouble g; 19 IssmDouble rho_ice; 20 IssmDouble FSreconditioning; 21 bool isSIA,isSSA,isL1L2,isHO,isFS,iscoupling; 22 bool spcpresent = false; 23 int Mx,Nx; 24 int My,Ny; 25 int Mz,Nz; 26 IssmDouble *spcvx = NULL; 27 IssmDouble *spcvy = NULL; 28 IssmDouble *spcvz = NULL; 29 IssmDouble *nodeonSSA = NULL; 30 IssmDouble *nodeonHO = NULL; 31 IssmDouble *nodeonFS = NULL; 32 IssmDouble *nodeonbase = NULL; 33 IssmDouble *groundedice_ls = NULL; 34 IssmDouble *vertices_type = NULL; 35 IssmDouble *surface = NULL; 36 IssmDouble *z = NULL; 37 IssmDouble *timesx=NULL; 38 IssmDouble *timesy=NULL; 39 IssmDouble *timesz=NULL; 40 IssmDouble* values=NULL; 41 42 /*Fetch parameters: */ 43 iomodel->Constant(&g,ConstantsGEnum); 44 iomodel->Constant(&rho_ice,MaterialsRhoIceEnum); 45 iomodel->Constant(&FSreconditioning,StressbalanceFSreconditioningEnum); 46 iomodel->Constant(&isSIA,FlowequationIsSIAEnum); 47 iomodel->Constant(&isSSA,FlowequationIsSSAEnum); 48 iomodel->Constant(&isL1L2,FlowequationIsL1L2Enum); 49 iomodel->Constant(&isHO,FlowequationIsHOEnum); 50 iomodel->Constant(&isFS,FlowequationIsFSEnum); 51 52 /*Now, is the flag macayaealHO on? otherwise, do nothing: */ 53 if(!isSSA && !isHO && !isFS && !isL1L2) return; 54 55 /*Do we have coupling*/ 56 if((isSIA?1.:0.) + (isSSA?1.:0.) + (isL1L2?1.:0.) + (isHO?1.:0.) + (isFS?1.:0.) >1.) 57 iscoupling = true; 58 else 59 iscoupling = false; 60 61 /*If no coupling, call Regular IoModelToConstraintsx, else, use P1 elements only*/ 62 if(!iscoupling){ 63 64 /*Get finite element type*/ 65 if(isSSA) iomodel->Constant(&finiteelement,FlowequationFeSSAEnum); 66 else if(isL1L2) finiteelement = P1Enum; 67 else if(isHO) iomodel->Constant(&finiteelement,FlowequationFeHOEnum); 68 else if(isFS){ iomodel->Constant(&finiteelement,FlowequationFeFSEnum); 69 /*Deduce velocity interpolation from finite element*/ 70 switch(finiteelement){ 71 case P1P1Enum : finiteelement = P1Enum; break; 72 case P1P1GLSEnum : finiteelement = P1Enum; break; 73 case MINIcondensedEnum : finiteelement = P1bubbleEnum; break; 74 case MINIEnum : finiteelement = P1bubbleEnum; break; 75 case TaylorHoodEnum : finiteelement = P2Enum; break; 76 case XTaylorHoodEnum : finiteelement = P2Enum; break; 77 case LATaylorHoodEnum : finiteelement = P2Enum; break; 78 case LACrouzeixRaviartEnum : finiteelement = P2bubbleEnum; break; 79 case OneLayerP4zEnum : finiteelement = P2xP4Enum; break; 80 case CrouzeixRaviartEnum : finiteelement = P2bubbleEnum; break; 81 default: _error_("finite element "<<EnumToStringx(finiteelement)<<" not supported"); 82 } 83 } 84 else{ 85 _error_("model not supported yet"); 86 } 87 88 if(isFS){ 89 90 /*Constraint at the bedrock interface (v.n = vz = 0) (Coordinates will be updated according to the bed slope)*/ 91 iomodel->FetchData(&vertices_type,NULL,NULL,FlowequationVertexEquationEnum); 92 iomodel->FetchData(&nodeonFS,NULL,NULL,FlowequationBorderFSEnum); 93 iomodel->FetchData(&nodeonbase,NULL,NULL,MeshVertexonbaseEnum); 94 iomodel->FetchData(&groundedice_ls,NULL,NULL,MaskGroundediceLevelsetEnum); 95 if(iomodel->domaintype==Domain3DEnum){ 96 iomodel->FetchData(&spcvz,&Mz,&Nz,StressbalanceSpcvzEnum); 97 } 98 else if (iomodel->domaintype==Domain2DverticalEnum){ 99 iomodel->FetchData(&spcvz,&Mz,&Nz,StressbalanceSpcvyEnum); 100 } 101 else{ 102 _error_("not supported yet"); 103 } 104 if(iomodel->domaintype==Domain3DEnum){ 105 IoModelToConstraintsx(constraints,iomodel,StressbalanceSpcvxEnum,StressbalanceAnalysisEnum,finiteelement,0); 106 IoModelToConstraintsx(constraints,iomodel,StressbalanceSpcvyEnum,StressbalanceAnalysisEnum,finiteelement,1); 107 IoModelToConstraintsx(constraints,iomodel,spcvz,Mz,Nz,StressbalanceAnalysisEnum,finiteelement,2); 108 iomodel->DeleteData(spcvz,StressbalanceSpcvzEnum); 109 } 110 else if (iomodel->domaintype==Domain2DverticalEnum){ 111 IoModelToConstraintsx(constraints,iomodel,StressbalanceSpcvxEnum,StressbalanceAnalysisEnum,finiteelement,0); 112 IoModelToConstraintsx(constraints,iomodel,spcvz,Mz,Nz,StressbalanceAnalysisEnum,finiteelement,1); 113 iomodel->DeleteData(spcvz,StressbalanceSpcvyEnum); 114 } 115 else{ 116 _error_("not supported yet"); 117 } 118 iomodel->DeleteData(vertices_type,FlowequationVertexEquationEnum); 119 iomodel->DeleteData(nodeonFS,FlowequationBorderFSEnum); 120 iomodel->DeleteData(nodeonbase,MeshVertexonbaseEnum); 121 iomodel->DeleteData(groundedice_ls,MaskGroundediceLevelsetEnum); 122 123 /*Pressure spc*/ 124 count = constraints->Size(); 125 iomodel->FetchData(&vertices_type,NULL,NULL,FlowequationVertexEquationEnum); 126 iomodel->FetchData(&surface,NULL,NULL,SurfaceEnum); 127 iomodel->FetchData(&z,NULL,NULL,MeshZEnum); 128 switch(finiteelement){ 129 case P1Enum: 130 for(i=0;i<iomodel->numberofvertices;i++){ 131 if(iomodel->my_vertices[i]){ 132 if(reCast<int,IssmDouble>(vertices_type[i])==NoneApproximationEnum){ 133 constraints->AddObject(new SpcStatic(count+1,iomodel->nodecounter+iomodel->numberofvertices+iomodel->numberofelements+i+1,0,g*rho_ice*(surface[i]-z[i])/FSreconditioning,StressbalanceAnalysisEnum)); 134 count++; 135 } 136 } 137 } 138 break; 139 case P1bubbleEnum: 140 for(i=0;i<iomodel->numberofvertices;i++){ 141 if(iomodel->my_vertices[i]){ 142 if(reCast<int,IssmDouble>(vertices_type[i])==NoneApproximationEnum){ 143 constraints->AddObject(new SpcStatic(count+1,iomodel->nodecounter+iomodel->numberofvertices+iomodel->numberofelements+i+1,0,g*rho_ice*(surface[i]-z[i])/FSreconditioning,StressbalanceAnalysisEnum)); 144 count++; 145 } 146 } 147 } 148 break; 149 case P2Enum: 150 for(i=0;i<iomodel->numberofvertices;i++){ 151 if(iomodel->my_vertices[i]){ 152 if(reCast<int,IssmDouble>(vertices_type[i])==NoneApproximationEnum){ 153 constraints->AddObject(new SpcStatic(count+1,iomodel->nodecounter+iomodel->numberofvertices+iomodel->numberofedges+i+1,0,g*rho_ice*(surface[i]-z[i])/FSreconditioning,StressbalanceAnalysisEnum)); 154 count++; 155 } 156 } 157 } 158 break; 159 case P2bubbleEnum: 160 for(i=0;i<iomodel->numberofvertices;i++){ 161 if(iomodel->my_vertices[i]){ 162 if(reCast<int,IssmDouble>(vertices_type[i])==NoneApproximationEnum){ 163 constraints->AddObject(new SpcStatic(count+1,iomodel->nodecounter+iomodel->numberofvertices+iomodel->numberofedges+iomodel->numberofelements+iomodel->numberoffaces+i+1,0,g*rho_ice*(surface[i]-z[i])/FSreconditioning,StressbalanceAnalysisEnum)); 164 count++; 165 } 166 } 167 } 168 break; 169 case P2xP4Enum: 170 //Nothing yet 171 break; 172 default: 173 _error_("not implemented yet"); 174 } 175 iomodel->DeleteData(vertices_type,FlowequationVertexEquationEnum); 176 iomodel->DeleteData(surface,SurfaceEnum); 177 iomodel->DeleteData(z,MeshZEnum); 178 } 179 else{ 180 IoModelToConstraintsx(constraints,iomodel,StressbalanceSpcvxEnum,StressbalanceAnalysisEnum,finiteelement,0); 181 if(iomodel->domaintype!=Domain2DverticalEnum){ 182 IoModelToConstraintsx(constraints,iomodel,StressbalanceSpcvyEnum,StressbalanceAnalysisEnum,finiteelement,1); 183 } 184 } 185 186 return; 187 } 188 189 /*Constraints: fetch data: */ 190 iomodel->FetchData(&spcvx,&Mx,&Nx,StressbalanceSpcvxEnum); 191 iomodel->FetchData(&spcvy,&My,&Ny,StressbalanceSpcvyEnum); 192 iomodel->FetchData(&spcvz,&Mz,&Nz,StressbalanceSpcvzEnum); 193 iomodel->FetchData(&nodeonSSA,NULL,NULL,FlowequationBorderSSAEnum); 194 if(iomodel->domaintype==Domain3DEnum)iomodel->FetchData(&nodeonHO,NULL,NULL,FlowequationBorderHOEnum); 195 if(iomodel->domaintype==Domain3DEnum)iomodel->FetchData(&nodeonFS,NULL,NULL,FlowequationBorderFSEnum); 196 if(iomodel->domaintype==Domain3DEnum)iomodel->FetchData(&nodeonbase,NULL,NULL,MeshVertexonbaseEnum); 197 if(iomodel->domaintype==Domain3DEnum)iomodel->FetchData(&groundedice_ls,NULL,NULL,MaskGroundediceLevelsetEnum); 198 iomodel->FetchData(&vertices_type,NULL,NULL,FlowequationVertexEquationEnum); 199 iomodel->FetchData(&surface,NULL,NULL,SurfaceEnum); 200 iomodel->FetchData(&z,NULL,NULL,MeshZEnum); 201 202 /*Initialize counter: */ 203 count=0; 204 205 /*figure out times: */ 206 timesx=xNew<IssmDouble>(Nx); 207 for(j=0;j<Nx;j++){ 208 timesx[j]=spcvx[(Mx-1)*Nx+j]; 209 } 210 /*figure out times: */ 211 timesy=xNew<IssmDouble>(Ny); 212 for(j=0;j<Ny;j++){ 213 timesy[j]=spcvy[(My-1)*Ny+j]; 214 } 215 /*figure out times: */ 216 timesz=xNew<IssmDouble>(Nz); 217 for(j=0;j<Nz;j++){ 218 timesz[j]=spcvz[(Mz-1)*Nz+j]; 219 } 220 221 /*Create spcs from x,y,z, as well as the spc values on those spcs: */ 222 for(i=0;i<iomodel->numberofvertices;i++){ 223 if(iomodel->my_vertices[i]){ 224 225 /*Start with adding spcs of coupling: zero at the border SSA/HO for the appropriate dofs*/ 226 if(reCast<int,IssmDouble>(vertices_type[i]==SSAHOApproximationEnum)){ 227 /*If grionSSA, spc HO dofs: 3 & 4*/ 228 if (reCast<int,IssmDouble>(nodeonHO[i])){ 229 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,0,0,StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 230 count++; 231 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,0,StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 232 count++; 233 if (!xIsNan<IssmDouble>(spcvx[i])){ 234 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,spcvx[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 235 count++; 236 } 237 if (!xIsNan<IssmDouble>(spcvy[i])){ 238 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,3,spcvy[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 239 count++; 240 } 241 242 } 243 else if (reCast<int,IssmDouble>(nodeonSSA[i])){ 244 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,0,StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 245 count++; 246 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,3,0,StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 247 count++; 248 if (!xIsNan<IssmDouble>(spcvx[i])){ 249 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,0,spcvx[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 250 count++; 251 } 252 if (!xIsNan<IssmDouble>(spcvy[i])){ 253 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,spcvy[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 254 count++; 255 } 256 257 } 258 else _error_("if vertices_type is SSAHO, you shoud have nodeonHO or nodeonSSA"); 259 } 260 /*Also add spcs of coupling: zero at the border HO/FS for the appropriate dofs*/ 261 else if (reCast<int,IssmDouble>(vertices_type[i])==HOFSApproximationEnum){ 262 /*If grion,HO spc FS dofs: 3 4 & 5*/ 263 if (reCast<int,IssmDouble>(nodeonHO[i])){ 264 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,0,StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 265 count++; 266 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,3,0,StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 267 count++; 268 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,4,0,StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 269 count++; 270 if (!xIsNan<IssmDouble>(spcvx[i])){ 271 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,0,spcvx[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 272 count++; 273 } 274 if (!xIsNan<IssmDouble>(spcvy[i])){ 275 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,spcvy[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 276 count++; 277 } 278 279 } 280 else if (reCast<int,IssmDouble>(nodeonFS[i])){ //spc HO nodes: 1 & 2 281 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,0,0,StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 282 count++; 283 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,0,StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 284 count++; 285 if (!xIsNan<IssmDouble>(spcvx[i])){ 286 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,spcvx[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 287 count++; 288 } 289 if (!xIsNan<IssmDouble>(spcvy[i])){ 290 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,3,spcvy[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 291 count++; 292 } 293 if (!xIsNan<IssmDouble>(spcvz[i])){ 294 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,4,spcvz[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 295 count++; 296 } 297 } 298 else _error_("if vertices_type is HOFS, you shoud have nodeonHO or nodeonFS"); 299 } 300 /*Also add spcs of coupling: zero at the border HO/FS for the appropriate dofs*/ 301 else if (reCast<int,IssmDouble>(vertices_type[i])==SSAFSApproximationEnum){ 302 /*If grion,HO spc FS dofs: 3 4 & 5*/ 303 if (reCast<int,IssmDouble>(nodeonSSA[i])){ 304 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,0,StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 305 count++; 306 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,3,0,StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 307 count++; 308 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,4,0,StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 309 count++; 310 if (!xIsNan<IssmDouble>(spcvx[i])){ 311 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,0,spcvx[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 312 count++; 313 } 314 if (!xIsNan<IssmDouble>(spcvy[i])){ 315 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,spcvy[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 316 count++; 317 } 318 319 } 320 else if (reCast<int,IssmDouble>(nodeonFS[i])){ //spc SSA nodes: 1 & 2 321 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,0,0,StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 322 count++; 323 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,0,StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 324 count++; 325 if (!xIsNan<IssmDouble>(spcvx[i])){ 326 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,spcvx[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 327 count++; 328 } 329 if (!xIsNan<IssmDouble>(spcvy[i])){ 330 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,3,spcvy[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 331 count++; 332 } 333 if (!xIsNan<IssmDouble>(spcvz[i])){ 334 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,4,spcvz[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 335 count++; 336 } 337 } 338 else _error_("if vertices_type is SSAFS, you shoud have nodeonSSA or nodeonFS"); 339 } 340 /*Now add the regular spcs*/ 341 else{ 342 if (Mx==iomodel->numberofvertices && !xIsNan<IssmDouble>(spcvx[i])){ 343 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,0,spcvx[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 344 count++; 345 346 } 347 else if (Mx==iomodel->numberofvertices+1) { 348 /*figure out times and values: */ 349 values=xNew<IssmDouble>(Nx); 350 spcpresent=false; 351 for(j=0;j<Nx;j++){ 352 values[j]=spcvx[i*Nx+j]; 353 if(!xIsNan<IssmDouble>(values[j]))spcpresent=true; //NaN means no spc by default 354 } 355 356 if(spcpresent){ 357 constraints->AddObject(new SpcTransient(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,0,Nx,timesx,values,StressbalanceAnalysisEnum)); 358 count++; 359 } 360 xDelete<IssmDouble>(values); 361 } 362 else if (vertices_type[i]==SIAApproximationEnum){ 363 constraints->AddObject(new SpcDynamic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,0,StressbalanceAnalysisEnum)); 364 count++; 365 } 366 367 if (My==iomodel->numberofvertices && !xIsNan<IssmDouble>(spcvy[i])){ 368 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,spcvy[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vy. 369 count++; 370 } 371 else if (My==iomodel->numberofvertices+1){ 372 /*figure out times and values: */ 373 values=xNew<IssmDouble>(Ny); 374 spcpresent=false; 375 for(j=0;j<Ny;j++){ 376 values[j]=spcvy[i*Ny+j]; 377 if(!xIsNan<IssmDouble>(values[j]))spcpresent=true; //NaN means no spc by default 378 } 379 if(spcpresent){ 380 constraints->AddObject(new SpcTransient(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,Ny,timesy,values,StressbalanceAnalysisEnum)); 381 count++; 382 } 383 xDelete<IssmDouble>(values); 384 } 385 else if (vertices_type[i]==SIAApproximationEnum){ 386 constraints->AddObject(new SpcDynamic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,StressbalanceAnalysisEnum)); 387 count++; 388 } 389 390 if (reCast<int,IssmDouble>(vertices_type[i])==FSApproximationEnum || (reCast<int,IssmDouble>(vertices_type[i])==NoneApproximationEnum)){ 391 if (Mz==iomodel->numberofvertices && !xIsNan<IssmDouble>(spcvz[i])){ 392 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,spcvz[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 2 to vy 393 count++; 394 } 395 else if (Mz==iomodel->numberofvertices+1){ 396 /*figure out times and values: */ 397 values=xNew<IssmDouble>(Nz); 398 spcpresent=false; 399 for(j=0;j<Nz;j++){ 400 values[j]=spcvz[i*Nz+j]; 401 if(!xIsNan<IssmDouble>(values[j]))spcpresent=true; //NaN means no spc by default 402 } 403 if(spcpresent){ 404 constraints->AddObject(new SpcTransient(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,Nz,timesz,values,StressbalanceAnalysisEnum)); 405 count++; 406 } 407 xDelete<IssmDouble>(values); 408 } 409 410 } 411 if (reCast<int,IssmDouble>(vertices_type[i])==NoneApproximationEnum){ 412 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+iomodel->numberofvertices+i+1,0,g*rho_ice*(surface[i]-z[i])/FSreconditioning,StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 2 to vy 413 count++; 414 } 415 } 416 } 417 } 418 419 /*Free data: */ 420 iomodel->DeleteData(spcvx,StressbalanceSpcvxEnum); 421 iomodel->DeleteData(spcvy,StressbalanceSpcvyEnum); 422 iomodel->DeleteData(spcvz,StressbalanceSpcvzEnum); 423 iomodel->DeleteData(nodeonSSA,FlowequationBorderSSAEnum); 424 if(iomodel->domaintype==Domain3DEnum)iomodel->DeleteData(nodeonHO,FlowequationBorderHOEnum); 425 if(iomodel->domaintype==Domain3DEnum)iomodel->DeleteData(nodeonFS,FlowequationBorderFSEnum); 426 if(iomodel->domaintype==Domain3DEnum)iomodel->DeleteData(nodeonbase,MeshVertexonbaseEnum); 427 if(iomodel->domaintype==Domain3DEnum)iomodel->DeleteData(groundedice_ls,MaskGroundediceLevelsetEnum); 428 iomodel->DeleteData(vertices_type,FlowequationVertexEquationEnum); 429 iomodel->DeleteData(surface,SurfaceEnum); 430 iomodel->DeleteData(z,MeshZEnum); 431 432 /*Free resources:*/ 433 xDelete<IssmDouble>(timesx); 434 xDelete<IssmDouble>(timesy); 435 xDelete<IssmDouble>(timesz); 436 xDelete<IssmDouble>(values); 437 438 }/*}}}*/ 439 void StressbalanceAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 440 441 /*Intermediary*/ 442 const int RIFTINFOSIZE = 12; 443 int i; 444 int count; 445 int penpair_ids[2]; 446 bool isSSA,isL1L2,isHO,isFS; 447 int numpenalties,numrifts,numriftsegments; 448 IssmDouble *riftinfo = NULL; 449 IssmDouble *penalties = NULL; 450 int assert_int; 451 452 /*Fetch parameters: */ 453 iomodel->Constant(&isL1L2,FlowequationIsL1L2Enum); 454 iomodel->Constant(&isFS,FlowequationIsFSEnum); 455 iomodel->Constant(&isSSA,FlowequationIsSSAEnum); 456 iomodel->Constant(&isHO,FlowequationIsHOEnum); 457 iomodel->Constant(&numrifts,RiftsNumriftsEnum); 458 459 /*Now, is the flag macayaealHO on? otherwise, do nothing: */ 460 if(!isSSA && !isHO && !isFS && !isL1L2) return; 461 462 /*Initialize counter: */ 463 count=0; 464 465 /*Create Penpair for penalties: */ 466 iomodel->FetchData(&penalties,&numpenalties,NULL,StressbalanceVertexPairingEnum); 467 468 for(i=0;i<numpenalties;i++){ 469 470 if(iomodel->my_vertices[reCast<int,IssmDouble>(penalties[2*i+0]-1)]){ 471 472 /*In debugging mode, check that the second node is in the same cpu*/ 473 assert_int=iomodel->my_vertices[reCast<int,IssmDouble>(penalties[2*i+1]-1)]; _assert_(assert_int); 474 475 /*Get node ids*/ 476 penpair_ids[0]=iomodel->nodecounter+reCast<int,IssmDouble>(penalties[2*i+0]); 477 penpair_ids[1]=iomodel->nodecounter+reCast<int,IssmDouble>(penalties[2*i+1]); 478 479 /*Create Load*/ 480 loads->AddObject(new Penpair(iomodel->loadcounter+count+1,&penpair_ids[0],StressbalanceAnalysisEnum)); 481 count++; 482 } 483 } 484 485 /*free ressources: */ 486 iomodel->DeleteData(penalties,StressbalanceVertexPairingEnum); 487 488 /*Create Riffront loads for rifts: */ 489 if(numrifts){ 490 iomodel->FetchData(&riftinfo,&numriftsegments,NULL,RiftsRiftstructEnum); 491 iomodel->FetchData(5,RiftsRiftstructEnum,ThicknessEnum,BaseEnum,SurfaceEnum,MaskGroundediceLevelsetEnum); 492 for(i=0;i<numriftsegments;i++){ 493 if(iomodel->my_elements[reCast<int,IssmDouble>(*(riftinfo+RIFTINFOSIZE*i+2))-1]){ 494 loads->AddObject(new Riftfront(iomodel->loadcounter+count+1,i,iomodel,StressbalanceAnalysisEnum)); 495 count++; 496 } 497 } 498 iomodel->DeleteData(5,RiftsRiftstructEnum,ThicknessEnum,BaseEnum,SurfaceEnum,MaskGroundediceLevelsetEnum); 499 xDelete<IssmDouble>(riftinfo); 500 } 501 }/*}}}*/ 502 void StressbalanceAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 503 504 /*Intermediary*/ 505 bool isSSA,isL1L2,isHO,isFS,iscoupling; 506 int finiteelement=-1,approximation=-1; 507 508 /*Fetch parameters: */ 509 iomodel->Constant(&isSSA,FlowequationIsSSAEnum); 510 iomodel->Constant(&isL1L2,FlowequationIsL1L2Enum); 511 iomodel->Constant(&isHO,FlowequationIsHOEnum); 512 iomodel->Constant(&isFS,FlowequationIsFSEnum); 513 514 /*Now, check that we have non SIA elements */ 515 if(!isSSA & !isL1L2 & !isHO & !isFS) return; 516 517 /*Do we have coupling*/ 518 if( (isSSA?1.:0.) + (isL1L2?1.:0.) + (isHO?1.:0.) + (isFS?1.:0.) >1.) 519 iscoupling = true; 520 else 521 iscoupling = false; 522 523 /*If no coupling, call Regular CreateNodes, else, use P1 elements only*/ 524 if(!iscoupling){ 525 526 /*Get finite element type*/ 527 if(isSSA){ 528 approximation=SSAApproximationEnum; 529 iomodel->Constant(&finiteelement,FlowequationFeSSAEnum); 530 } 531 else if(isL1L2){ 532 approximation = L1L2ApproximationEnum; 533 finiteelement = P1Enum; 534 } 535 else if(isHO){ 536 approximation = HOApproximationEnum; 537 iomodel->Constant(&finiteelement,FlowequationFeHOEnum); 538 } 539 else if(isFS){ 540 approximation = FSApproximationEnum; 541 iomodel->Constant(&finiteelement,FlowequationFeFSEnum); 542 } 543 iomodel->FetchData(3,FlowequationBorderSSAEnum,FlowequationVertexEquationEnum,StressbalanceReferentialEnum); 544 if(iomodel->domaintype!=Domain2DhorizontalEnum) iomodel->FetchData(3,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum,FlowequationBorderFSEnum); 545 ::CreateNodes(nodes,iomodel,StressbalanceAnalysisEnum,finiteelement,approximation); 546 iomodel->DeleteData(6,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum,FlowequationBorderSSAEnum,FlowequationBorderFSEnum, 547 FlowequationVertexEquationEnum,StressbalanceReferentialEnum); 548 } 549 else{ 550 /*Coupling: we are going to create P1 Elements only*/ 551 552 Node* node = NULL; 553 int lid=0; 554 if(!nodes) nodes = new Nodes(); 555 556 iomodel->FetchData(6,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum,FlowequationBorderSSAEnum,FlowequationBorderFSEnum, 557 FlowequationVertexEquationEnum,StressbalanceReferentialEnum); 558 if(isFS){ 559 /*P1+ velocity*/ 560 for(int i=0;i<iomodel->numberofvertices;i++){ 561 if(iomodel->my_vertices[i]){ 562 approximation=reCast<int>(iomodel->Data(FlowequationVertexEquationEnum)[i]); 563 if(approximation==FSApproximationEnum) approximation=FSvelocityEnum; 564 nodes->AddObject(new Node(iomodel->nodecounter+i+1,i,lid++,i,iomodel,StressbalanceAnalysisEnum,approximation)); 565 } 566 } 567 for(int i=0;i<iomodel->numberofelements;i++){ 568 if(iomodel->my_elements[i]){ 569 node = new Node(iomodel->nodecounter+iomodel->numberofvertices+i+1,iomodel->numberofvertices+i,lid++,0,iomodel,StressbalanceAnalysisEnum,FSvelocityEnum); 570 node->Deactivate(); 571 nodes->AddObject(node); 572 } 573 } 574 /*P1 pressure*/ 575 for(int i=0;i<iomodel->numberofvertices;i++){ 576 if(iomodel->my_vertices[i]){ 577 approximation=reCast<int>(iomodel->Data(FlowequationVertexEquationEnum)[i]); 578 node = new Node(iomodel->nodecounter+iomodel->numberofvertices+iomodel->numberofelements+i+1,iomodel->numberofvertices+iomodel->numberofelements+i,lid++,i,iomodel,StressbalanceAnalysisEnum,FSpressureEnum); 579 if(approximation==HOApproximationEnum || approximation==SSAApproximationEnum){ 580 node->Deactivate(); 581 } 582 nodes->AddObject(node); 583 } 584 } 585 } 586 else{ 587 for(int i=0;i<iomodel->numberofvertices;i++){ 588 if(iomodel->my_vertices[i]){ 589 nodes->AddObject(new Node(iomodel->nodecounter+i+1,i,lid++,i,iomodel,StressbalanceAnalysisEnum,reCast<int>(iomodel->Data(FlowequationVertexEquationEnum)[i]))); 590 } 591 } 592 } 593 iomodel->DeleteData(6,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum,FlowequationBorderSSAEnum,FlowequationBorderFSEnum, 594 FlowequationVertexEquationEnum,StressbalanceReferentialEnum); 595 } 596 }/*}}}*/ 13 597 int StressbalanceAnalysis::DofsPerNode(int** pdoftype,int domaintype,int approximation){/*{{{*/ 14 598 … … 84 668 return numdofs; 85 669 }/*}}}*/ 670 void StressbalanceAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ 671 672 /*Intermediaries*/ 673 int materials_type,finiteelement,fe_FS; 674 int approximation,frictionlaw; 675 int* finiteelement_list=NULL; 676 bool isSSA,isL1L2,isHO,isFS,iscoupling; 677 bool control_analysis; 678 bool dakota_analysis; 679 bool islevelset; 680 bool isdamage; 681 682 /*Fetch constants needed: */ 683 iomodel->Constant(&isSSA,FlowequationIsSSAEnum); 684 iomodel->Constant(&isL1L2,FlowequationIsL1L2Enum); 685 iomodel->Constant(&isHO,FlowequationIsHOEnum); 686 iomodel->Constant(&isFS,FlowequationIsFSEnum); 687 iomodel->Constant(&control_analysis,InversionIscontrolEnum); 688 iomodel->Constant(&dakota_analysis,QmuIsdakotaEnum); 689 iomodel->Constant(&materials_type,MaterialsEnum); 690 iomodel->Constant(&islevelset,TransientIslevelsetEnum); 691 iomodel->Constant(&frictionlaw,FrictionLawEnum); 692 693 /*return if no processing required*/ 694 if(!isSSA & !isL1L2 & !isHO & !isFS) return; 695 696 /*Fetch data needed and allocate vectors: */ 697 iomodel->FetchData(1,FlowequationElementEquationEnum); 698 finiteelement_list=xNewZeroInit<int>(iomodel->numberofelements); 699 700 /*Do we have coupling*/ 701 if( (isSSA?1.:0.) + (isL1L2?1.:0.) + (isHO?1.:0.) + (isFS?1.:0.) >1.) 702 iscoupling = true; 703 else 704 iscoupling = false; 705 706 /*is damage mechanics being used?*/ 707 if(materials_type==MaticeEnum) isdamage = false; 708 else if(materials_type==MatdamageiceEnum) isdamage = true; 709 else _error_("Material type not recognized"); 710 711 /*Get finite element type*/ 712 if(!iscoupling){ 713 if(isSSA) iomodel->Constant(&finiteelement,FlowequationFeSSAEnum); 714 else if(isL1L2) finiteelement = P1Enum; 715 else if(isHO) iomodel->Constant(&finiteelement,FlowequationFeHOEnum); 716 else if(isFS) iomodel->Constant(&finiteelement,FlowequationFeFSEnum); 717 for(int i=0;i<iomodel->numberofelements;i++){ 718 finiteelement_list[i]=finiteelement; 719 } 720 } 721 else{ 722 if(isFS){ 723 for(int i=0;i<iomodel->numberofelements;i++){ 724 approximation=reCast<int>(iomodel->Data(FlowequationElementEquationEnum)[i]); 725 if(approximation==FSApproximationEnum || approximation==HOFSApproximationEnum || approximation==SSAFSApproximationEnum){ 726 finiteelement_list[i]=MINIcondensedEnum; 727 } 728 else{ 729 finiteelement_list[i]=P1Enum; 730 } 731 } 732 } 733 else{ 734 finiteelement = P1Enum; 735 for(int i=0;i<iomodel->numberofelements;i++){ 736 finiteelement_list[i]=finiteelement; 737 } 738 } 739 } 740 741 /*Update elements: */ 742 int counter=0; 743 for(int i=0;i<iomodel->numberofelements;i++){ 744 if(iomodel->my_elements[i]){ 745 Element* element=(Element*)elements->GetObjectByOffset(counter); 746 element->Update(i,iomodel,analysis_counter,analysis_type,finiteelement_list[i]); 747 counter++; 748 } 749 } 750 751 /*Create inputs: */ 752 iomodel->FetchDataToInput(elements,ThicknessEnum); 753 iomodel->FetchDataToInput(elements,SurfaceEnum); 754 iomodel->FetchDataToInput(elements,BaseEnum); 755 iomodel->FetchDataToInput(elements,MaskIceLevelsetEnum); 756 iomodel->FetchDataToInput(elements,MaskGroundediceLevelsetEnum); 757 iomodel->FetchDataToInput(elements,MaterialsRheologyBEnum); 758 iomodel->FetchDataToInput(elements,MaterialsRheologyNEnum); 759 iomodel->FetchDataToInput(elements,VxEnum,0.); 760 iomodel->FetchDataToInput(elements,VyEnum,0.); 761 iomodel->FetchDataToInput(elements,LoadingforceXEnum); 762 iomodel->FetchDataToInput(elements,LoadingforceYEnum); 763 #ifdef LATERALFRICTION 764 iomodel->FetchDataToInput(elements,MeshVertexonboundaryEnum); 765 #endif 766 if(isdamage)iomodel->FetchDataToInput(elements,DamageDEnum); 767 768 if(iomodel->domaintype!=Domain2DhorizontalEnum){ 769 iomodel->FetchDataToInput(elements,MeshVertexonbaseEnum); 770 iomodel->FetchDataToInput(elements,MeshVertexonsurfaceEnum); 771 } 772 if(iomodel->domaintype==Domain3DEnum){ 773 iomodel->FetchDataToInput(elements,FlowequationBorderFSEnum); 774 iomodel->FetchDataToInput(elements,LoadingforceZEnum); 775 iomodel->FetchDataToInput(elements,VzEnum,0.); 776 } 777 if(isFS){ 778 iomodel->FetchDataToInput(elements,PressureEnum,0.); 779 iomodel->FetchDataToInput(elements,BasalforcingsFloatingiceMeltingRateEnum,0.); 780 } 781 if(islevelset){ 782 iomodel->FetchDataToInput(elements,IceMaskNodeActivationEnum); 783 } 784 /*LATH parameters*/ 785 iomodel->Constant(&fe_FS,FlowequationFeFSEnum); 786 if(fe_FS==LATaylorHoodEnum || fe_FS==LACrouzeixRaviartEnum){ 787 InputUpdateFromConstantx(elements,0.,SigmaNNEnum); 788 } 789 790 /*Friction law variables*/ 791 switch(frictionlaw){ 792 case 1: 793 iomodel->FetchDataToInput(elements,FrictionCoefficientEnum); 794 iomodel->FetchDataToInput(elements,FrictionPEnum); 795 iomodel->FetchDataToInput(elements,FrictionQEnum); 796 break; 797 case 2: 798 iomodel->FetchDataToInput(elements,FrictionCEnum); 799 iomodel->FetchDataToInput(elements,FrictionMEnum); 800 break; 801 case 3: 802 iomodel->FetchDataToInput(elements,FrictionCEnum); 803 iomodel->FetchDataToInput(elements,FrictionAsEnum); 804 iomodel->FetchDataToInput(elements,FrictionQEnum); 805 iomodel->FetchDataToInput(elements,FrictionEffectivePressureEnum); 806 break; 807 case 4: 808 iomodel->FetchDataToInput(elements,FrictionCoefficientEnum); 809 iomodel->FetchDataToInput(elements,FrictionPEnum); 810 iomodel->FetchDataToInput(elements,FrictionQEnum); 811 iomodel->FetchDataToInput(elements,PressureEnum); 812 iomodel->FetchDataToInput(elements,TemperatureEnum); 813 break; 814 case 5: 815 iomodel->FetchDataToInput(elements,FrictionCoefficientEnum); 816 iomodel->FetchDataToInput(elements,FrictionPEnum); 817 iomodel->FetchDataToInput(elements,FrictionQEnum); 818 iomodel->FetchDataToInput(elements,FrictionWaterLayerEnum); 819 break; 820 case 6: 821 iomodel->FetchDataToInput(elements,FrictionCEnum); 822 iomodel->FetchDataToInput(elements,FrictionMEnum); 823 iomodel->FetchDataToInput(elements,PressureEnum); 824 iomodel->FetchDataToInput(elements,TemperatureEnum); 825 break; 826 default: 827 _error_("not supported"); 828 } 829 830 #ifdef _HAVE_ANDROID_ 831 elements->InputDuplicate(FrictionCoefficientEnum,AndroidFrictionCoefficientEnum); 832 #endif 833 834 /*Free data: */ 835 iomodel->DeleteData(1,FlowequationElementEquationEnum); 836 xDelete<int>(finiteelement_list); 837 }/*}}}*/ 86 838 void StressbalanceAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 87 839 … … 112 864 /*XTH LATH parameters*/ 113 865 iomodel->Constant(&fe_FS,FlowequationFeFSEnum); 114 if(fe_FS==XTaylorHoodEnum || fe_FS==LATaylorHoodEnum ){866 if(fe_FS==XTaylorHoodEnum || fe_FS==LATaylorHoodEnum || fe_FS==LACrouzeixRaviartEnum){ 115 867 parameters->AddObject(iomodel->CopyConstantObject(AugmentedLagrangianREnum)); 116 868 parameters->AddObject(iomodel->CopyConstantObject(AugmentedLagrangianRlambdaEnum)); … … 130 882 iomodel->DeleteData(&requestedoutputs,numoutputs,StressbalanceRequestedOutputsEnum); 131 883 132 }/*}}}*/ 133 void StressbalanceAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ 134 135 /*Intermediaries*/ 136 int materials_type,finiteelement,fe_FS; 137 int approximation,frictionlaw; 138 int* finiteelement_list=NULL; 139 bool isSSA,isL1L2,isHO,isFS,iscoupling; 140 bool control_analysis; 141 bool dakota_analysis; 142 bool islevelset; 143 bool isdamage; 144 145 /*Fetch constants needed: */ 146 iomodel->Constant(&isSSA,FlowequationIsSSAEnum); 147 iomodel->Constant(&isL1L2,FlowequationIsL1L2Enum); 148 iomodel->Constant(&isHO,FlowequationIsHOEnum); 149 iomodel->Constant(&isFS,FlowequationIsFSEnum); 150 iomodel->Constant(&control_analysis,InversionIscontrolEnum); 151 iomodel->Constant(&dakota_analysis,QmuIsdakotaEnum); 152 iomodel->Constant(&materials_type,MaterialsEnum); 153 iomodel->Constant(&islevelset,TransientIslevelsetEnum); 884 /*Deal with friction parameters*/ 885 int frictionlaw; 154 886 iomodel->Constant(&frictionlaw,FrictionLawEnum); 155 156 /*return if no processing required*/ 157 if(!isSSA & !isL1L2 & !isHO & !isFS) return; 158 159 /*Fetch data needed and allocate vectors: */ 160 iomodel->FetchData(1,FlowequationElementEquationEnum); 161 finiteelement_list=xNewZeroInit<int>(iomodel->numberofelements); 162 163 /*Do we have coupling*/ 164 if( (isSSA?1.:0.) + (isL1L2?1.:0.) + (isHO?1.:0.) + (isFS?1.:0.) >1.) 165 iscoupling = true; 166 else 167 iscoupling = false; 168 169 /*is damage mechanics being used?*/ 170 if(materials_type==MaticeEnum) isdamage = false; 171 else if(materials_type==MatdamageiceEnum) isdamage = true; 172 else _error_("Material type not recognized"); 173 174 /*Get finite element type*/ 175 if(!iscoupling){ 176 if(isSSA) iomodel->Constant(&finiteelement,FlowequationFeSSAEnum); 177 else if(isL1L2) finiteelement = P1Enum; 178 else if(isHO) iomodel->Constant(&finiteelement,FlowequationFeHOEnum); 179 else if(isFS) iomodel->Constant(&finiteelement,FlowequationFeFSEnum); 180 for(int i=0;i<iomodel->numberofelements;i++){ 181 finiteelement_list[i]=finiteelement; 182 } 183 } 184 else{ 185 if(isFS){ 186 for(int i=0;i<iomodel->numberofelements;i++){ 187 approximation=reCast<int>(iomodel->Data(FlowequationElementEquationEnum)[i]); 188 if(approximation==FSApproximationEnum || approximation==HOFSApproximationEnum || approximation==SSAFSApproximationEnum){ 189 finiteelement_list[i]=MINIcondensedEnum; 190 } 191 else{ 192 finiteelement_list[i]=P1Enum; 193 } 194 } 195 } 196 else{ 197 finiteelement = P1Enum; 198 for(int i=0;i<iomodel->numberofelements;i++){ 199 finiteelement_list[i]=finiteelement; 200 } 201 } 202 } 203 204 /*Update elements: */ 205 int counter=0; 206 for(int i=0;i<iomodel->numberofelements;i++){ 207 if(iomodel->my_elements[i]){ 208 Element* element=(Element*)elements->GetObjectByOffset(counter); 209 element->Update(i,iomodel,analysis_counter,analysis_type,finiteelement_list[i]); 210 counter++; 211 } 212 } 213 214 /*Create inputs: */ 215 iomodel->FetchDataToInput(elements,ThicknessEnum); 216 iomodel->FetchDataToInput(elements,SurfaceEnum); 217 iomodel->FetchDataToInput(elements,BaseEnum); 218 iomodel->FetchDataToInput(elements,MaskIceLevelsetEnum); 219 iomodel->FetchDataToInput(elements,MaskGroundediceLevelsetEnum); 220 iomodel->FetchDataToInput(elements,MaterialsRheologyBEnum); 221 iomodel->FetchDataToInput(elements,MaterialsRheologyNEnum); 222 iomodel->FetchDataToInput(elements,VxEnum,0.); 223 iomodel->FetchDataToInput(elements,VyEnum,0.); 224 iomodel->FetchDataToInput(elements,LoadingforceXEnum); 225 iomodel->FetchDataToInput(elements,LoadingforceYEnum); 226 #ifdef LATERALFRICTION 227 iomodel->FetchDataToInput(elements,MeshVertexonboundaryEnum); 228 #endif 229 if(isdamage)iomodel->FetchDataToInput(elements,DamageDEnum); 230 231 if(iomodel->domaintype!=Domain2DhorizontalEnum){ 232 iomodel->FetchDataToInput(elements,MeshVertexonbaseEnum); 233 iomodel->FetchDataToInput(elements,MeshVertexonsurfaceEnum); 234 } 235 if(iomodel->domaintype==Domain3DEnum){ 236 iomodel->FetchDataToInput(elements,FlowequationBorderFSEnum); 237 iomodel->FetchDataToInput(elements,LoadingforceZEnum); 238 iomodel->FetchDataToInput(elements,VzEnum,0.); 239 } 240 if(isFS){ 241 iomodel->FetchDataToInput(elements,PressureEnum,0.); 242 iomodel->FetchDataToInput(elements,BasalforcingsFloatingiceMeltingRateEnum,0.); 243 } 244 if(islevelset){ 245 iomodel->FetchDataToInput(elements,IceMaskNodeActivationEnum); 246 } 247 /*LATH parameters*/ 248 iomodel->Constant(&fe_FS,FlowequationFeFSEnum); 249 if(fe_FS==LATaylorHoodEnum){ 250 iomodel->FetchDataToInput(elements,PressureEnum,0.); 251 InputUpdateFromConstantx(elements,0.,SigmaNNEnum); 252 } 253 254 /*Friction law variables*/ 255 switch(frictionlaw){ 256 case 1: 257 iomodel->FetchDataToInput(elements,FrictionCoefficientEnum); 258 iomodel->FetchDataToInput(elements,FrictionPEnum); 259 iomodel->FetchDataToInput(elements,FrictionQEnum); 260 break; 261 case 2: 262 iomodel->FetchDataToInput(elements,FrictionCEnum); 263 iomodel->FetchDataToInput(elements,FrictionMEnum); 264 break; 265 default: 266 _error_("not supported"); 267 } 268 269 #ifdef _HAVE_ANDROID_ 270 elements->InputDuplicate(FrictionCoefficientEnum,AndroidFrictionCoefficientEnum); 271 #endif 272 273 /*Free data: */ 274 iomodel->DeleteData(1,FlowequationElementEquationEnum); 275 xDelete<int>(finiteelement_list); 276 }/*}}}*/ 277 void StressbalanceAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 278 279 /*Intermediary*/ 280 bool isSSA,isL1L2,isHO,isFS,iscoupling; 281 int finiteelement=-1,approximation=-1; 282 283 /*Fetch parameters: */ 284 iomodel->Constant(&isSSA,FlowequationIsSSAEnum); 285 iomodel->Constant(&isL1L2,FlowequationIsL1L2Enum); 286 iomodel->Constant(&isHO,FlowequationIsHOEnum); 287 iomodel->Constant(&isFS,FlowequationIsFSEnum); 288 289 /*Now, check that we have non SIA elements */ 290 if(!isSSA & !isL1L2 & !isHO & !isFS) return; 291 292 /*Do we have coupling*/ 293 if( (isSSA?1.:0.) + (isL1L2?1.:0.) + (isHO?1.:0.) + (isFS?1.:0.) >1.) 294 iscoupling = true; 295 else 296 iscoupling = false; 297 298 /*If no coupling, call Regular CreateNodes, else, use P1 elements only*/ 299 if(!iscoupling){ 300 301 /*Get finite element type*/ 302 if(isSSA){ 303 approximation=SSAApproximationEnum; 304 iomodel->Constant(&finiteelement,FlowequationFeSSAEnum); 305 } 306 else if(isL1L2){ 307 approximation = L1L2ApproximationEnum; 308 finiteelement = P1Enum; 309 } 310 else if(isHO){ 311 approximation = HOApproximationEnum; 312 iomodel->Constant(&finiteelement,FlowequationFeHOEnum); 313 } 314 else if(isFS){ 315 approximation = FSApproximationEnum; 316 iomodel->Constant(&finiteelement,FlowequationFeFSEnum); 317 } 318 iomodel->FetchData(3,FlowequationBorderSSAEnum,FlowequationVertexEquationEnum,StressbalanceReferentialEnum); 319 if(iomodel->domaintype!=Domain2DhorizontalEnum) iomodel->FetchData(3,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum,FlowequationBorderFSEnum); 320 ::CreateNodes(nodes,iomodel,StressbalanceAnalysisEnum,finiteelement,approximation); 321 iomodel->DeleteData(6,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum,FlowequationBorderSSAEnum,FlowequationBorderFSEnum, 322 FlowequationVertexEquationEnum,StressbalanceReferentialEnum); 323 } 324 else{ 325 /*Coupling: we are going to create P1 Elements only*/ 326 327 Node* node = NULL; 328 int lid=0; 329 if(!nodes) nodes = new Nodes(); 330 331 iomodel->FetchData(6,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum,FlowequationBorderSSAEnum,FlowequationBorderFSEnum, 332 FlowequationVertexEquationEnum,StressbalanceReferentialEnum); 333 if(isFS){ 334 /*P1+ velocity*/ 335 for(int i=0;i<iomodel->numberofvertices;i++){ 336 if(iomodel->my_vertices[i]){ 337 approximation=reCast<int>(iomodel->Data(FlowequationVertexEquationEnum)[i]); 338 if(approximation==FSApproximationEnum) approximation=FSvelocityEnum; 339 nodes->AddObject(new Node(iomodel->nodecounter+i+1,i,lid++,i,iomodel,StressbalanceAnalysisEnum,approximation)); 340 } 341 } 342 for(int i=0;i<iomodel->numberofelements;i++){ 343 if(iomodel->my_elements[i]){ 344 node = new Node(iomodel->nodecounter+iomodel->numberofvertices+i+1,iomodel->numberofvertices+i,lid++,0,iomodel,StressbalanceAnalysisEnum,FSvelocityEnum); 345 node->Deactivate(); 346 nodes->AddObject(node); 347 } 348 } 349 /*P1 pressure*/ 350 for(int i=0;i<iomodel->numberofvertices;i++){ 351 if(iomodel->my_vertices[i]){ 352 approximation=reCast<int>(iomodel->Data(FlowequationVertexEquationEnum)[i]); 353 node = new Node(iomodel->nodecounter+iomodel->numberofvertices+iomodel->numberofelements+i+1,iomodel->numberofvertices+iomodel->numberofelements+i,lid++,i,iomodel,StressbalanceAnalysisEnum,FSpressureEnum); 354 if(approximation==HOApproximationEnum || approximation==SSAApproximationEnum){ 355 node->Deactivate(); 356 } 357 nodes->AddObject(node); 358 } 359 } 360 } 361 else{ 362 for(int i=0;i<iomodel->numberofvertices;i++){ 363 if(iomodel->my_vertices[i]){ 364 nodes->AddObject(new Node(iomodel->nodecounter+i+1,i,lid++,i,iomodel,StressbalanceAnalysisEnum,reCast<int>(iomodel->Data(FlowequationVertexEquationEnum)[i]))); 365 } 366 } 367 } 368 iomodel->DeleteData(6,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum,FlowequationBorderSSAEnum,FlowequationBorderFSEnum, 369 FlowequationVertexEquationEnum,StressbalanceReferentialEnum); 370 } 371 }/*}}}*/ 372 void StressbalanceAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 373 374 /*Intermediary*/ 375 int i,j; 376 int count,finiteelement; 377 IssmDouble g; 378 IssmDouble rho_ice; 379 IssmDouble FSreconditioning; 380 bool isSIA,isSSA,isL1L2,isHO,isFS,iscoupling; 381 bool spcpresent = false; 382 int Mx,Nx; 383 int My,Ny; 384 int Mz,Nz; 385 IssmDouble *spcvx = NULL; 386 IssmDouble *spcvy = NULL; 387 IssmDouble *spcvz = NULL; 388 IssmDouble *nodeonSSA = NULL; 389 IssmDouble *nodeonHO = NULL; 390 IssmDouble *nodeonFS = NULL; 391 IssmDouble *nodeonbase = NULL; 392 IssmDouble *groundedice_ls = NULL; 393 IssmDouble *vertices_type = NULL; 394 IssmDouble *surface = NULL; 395 IssmDouble *z = NULL; 396 IssmDouble *timesx=NULL; 397 IssmDouble *timesy=NULL; 398 IssmDouble *timesz=NULL; 399 IssmDouble* values=NULL; 400 401 /*Fetch parameters: */ 402 iomodel->Constant(&g,ConstantsGEnum); 403 iomodel->Constant(&rho_ice,MaterialsRhoIceEnum); 404 iomodel->Constant(&FSreconditioning,StressbalanceFSreconditioningEnum); 405 iomodel->Constant(&isSIA,FlowequationIsSIAEnum); 406 iomodel->Constant(&isSSA,FlowequationIsSSAEnum); 407 iomodel->Constant(&isL1L2,FlowequationIsL1L2Enum); 408 iomodel->Constant(&isHO,FlowequationIsHOEnum); 409 iomodel->Constant(&isFS,FlowequationIsFSEnum); 410 411 /*Now, is the flag macayaealHO on? otherwise, do nothing: */ 412 if(!isSSA && !isHO && !isFS && !isL1L2) return; 413 414 /*Do we have coupling*/ 415 if((isSIA?1.:0.) + (isSSA?1.:0.) + (isL1L2?1.:0.) + (isHO?1.:0.) + (isFS?1.:0.) >1.) 416 iscoupling = true; 417 else 418 iscoupling = false; 419 420 /*If no coupling, call Regular IoModelToConstraintsx, else, use P1 elements only*/ 421 if(!iscoupling){ 422 423 /*Get finite element type*/ 424 if(isSSA) iomodel->Constant(&finiteelement,FlowequationFeSSAEnum); 425 else if(isL1L2) finiteelement = P1Enum; 426 else if(isHO) iomodel->Constant(&finiteelement,FlowequationFeHOEnum); 427 else if(isFS){ iomodel->Constant(&finiteelement,FlowequationFeFSEnum); 428 /*Deduce velocity interpolation from finite element*/ 429 switch(finiteelement){ 430 case P1P1Enum : finiteelement = P1Enum; break; 431 case P1P1GLSEnum : finiteelement = P1Enum; break; 432 case MINIcondensedEnum : finiteelement = P1bubbleEnum; break; 433 case MINIEnum : finiteelement = P1bubbleEnum; break; 434 case TaylorHoodEnum : finiteelement = P2Enum; break; 435 case XTaylorHoodEnum : finiteelement = P2Enum; break; 436 case LATaylorHoodEnum : finiteelement = P2Enum; break; 437 case OneLayerP4zEnum : finiteelement = P2xP4Enum; break; 438 case CrouzeixRaviartEnum : finiteelement = P2bubbleEnum; break; 439 default: _error_("finite element "<<EnumToStringx(finiteelement)<<" not supported"); 440 } 441 } 442 else{ 443 _error_("model not supported yet"); 444 } 445 446 if(isFS){ 447 448 /*Constraint at the bedrock interface (v.n = vz = 0) (Coordinates will be updated according to the bed slope)*/ 449 iomodel->FetchData(&vertices_type,NULL,NULL,FlowequationVertexEquationEnum); 450 iomodel->FetchData(&nodeonFS,NULL,NULL,FlowequationBorderFSEnum); 451 iomodel->FetchData(&nodeonbase,NULL,NULL,MeshVertexonbaseEnum); 452 iomodel->FetchData(&groundedice_ls,NULL,NULL,MaskGroundediceLevelsetEnum); 453 if(iomodel->domaintype==Domain3DEnum){ 454 iomodel->FetchData(&spcvz,&Mz,&Nz,StressbalanceSpcvzEnum); 455 } 456 else if (iomodel->domaintype==Domain2DverticalEnum){ 457 iomodel->FetchData(&spcvz,&Mz,&Nz,StressbalanceSpcvyEnum); 458 } 459 else{ 460 _error_("not supported yet"); 461 } 462 if(iomodel->domaintype==Domain3DEnum){ 463 IoModelToConstraintsx(constraints,iomodel,StressbalanceSpcvxEnum,StressbalanceAnalysisEnum,finiteelement,0); 464 IoModelToConstraintsx(constraints,iomodel,StressbalanceSpcvyEnum,StressbalanceAnalysisEnum,finiteelement,1); 465 IoModelToConstraintsx(constraints,iomodel,spcvz,Mz,Nz,StressbalanceAnalysisEnum,finiteelement,2); 466 iomodel->DeleteData(spcvz,StressbalanceSpcvzEnum); 467 } 468 else if (iomodel->domaintype==Domain2DverticalEnum){ 469 IoModelToConstraintsx(constraints,iomodel,StressbalanceSpcvxEnum,StressbalanceAnalysisEnum,finiteelement,0); 470 IoModelToConstraintsx(constraints,iomodel,spcvz,Mz,Nz,StressbalanceAnalysisEnum,finiteelement,1); 471 iomodel->DeleteData(spcvz,StressbalanceSpcvyEnum); 472 } 473 else{ 474 _error_("not supported yet"); 475 } 476 iomodel->DeleteData(vertices_type,FlowequationVertexEquationEnum); 477 iomodel->DeleteData(nodeonFS,FlowequationBorderFSEnum); 478 iomodel->DeleteData(nodeonbase,MeshVertexonbaseEnum); 479 iomodel->DeleteData(groundedice_ls,MaskGroundediceLevelsetEnum); 480 481 /*Pressure spc*/ 482 count = constraints->Size(); 483 iomodel->FetchData(&vertices_type,NULL,NULL,FlowequationVertexEquationEnum); 484 iomodel->FetchData(&surface,NULL,NULL,SurfaceEnum); 485 iomodel->FetchData(&z,NULL,NULL,MeshZEnum); 486 switch(finiteelement){ 487 case P1Enum: 488 for(i=0;i<iomodel->numberofvertices;i++){ 489 if(iomodel->my_vertices[i]){ 490 if(reCast<int,IssmDouble>(vertices_type[i])==NoneApproximationEnum){ 491 constraints->AddObject(new SpcStatic(count+1,iomodel->nodecounter+iomodel->numberofvertices+iomodel->numberofelements+i+1,0,g*rho_ice*(surface[i]-z[i])/FSreconditioning,StressbalanceAnalysisEnum)); 492 count++; 493 } 494 } 495 } 496 break; 497 case P1bubbleEnum: 498 for(i=0;i<iomodel->numberofvertices;i++){ 499 if(iomodel->my_vertices[i]){ 500 if(reCast<int,IssmDouble>(vertices_type[i])==NoneApproximationEnum){ 501 constraints->AddObject(new SpcStatic(count+1,iomodel->nodecounter+iomodel->numberofvertices+iomodel->numberofelements+i+1,0,g*rho_ice*(surface[i]-z[i])/FSreconditioning,StressbalanceAnalysisEnum)); 502 count++; 503 } 504 } 505 } 506 break; 507 case P2Enum: 508 for(i=0;i<iomodel->numberofvertices;i++){ 509 if(iomodel->my_vertices[i]){ 510 if(reCast<int,IssmDouble>(vertices_type[i])==NoneApproximationEnum){ 511 constraints->AddObject(new SpcStatic(count+1,iomodel->nodecounter+iomodel->numberofvertices+iomodel->numberofedges+i+1,0,g*rho_ice*(surface[i]-z[i])/FSreconditioning,StressbalanceAnalysisEnum)); 512 count++; 513 } 514 } 515 } 516 break; 517 case P2bubbleEnum: 518 for(i=0;i<iomodel->numberofvertices;i++){ 519 if(iomodel->my_vertices[i]){ 520 if(reCast<int,IssmDouble>(vertices_type[i])==NoneApproximationEnum){ 521 constraints->AddObject(new SpcStatic(count+1,iomodel->nodecounter+iomodel->numberofvertices+iomodel->numberofedges+iomodel->numberofelements+iomodel->numberoffaces+i+1,0,g*rho_ice*(surface[i]-z[i])/FSreconditioning,StressbalanceAnalysisEnum)); 522 count++; 523 } 524 } 525 } 526 break; 527 case P2xP4Enum: 528 //Nothing yet 529 break; 530 default: 531 _error_("not implemented yet"); 532 } 533 iomodel->DeleteData(vertices_type,FlowequationVertexEquationEnum); 534 iomodel->DeleteData(surface,SurfaceEnum); 535 iomodel->DeleteData(z,MeshZEnum); 536 } 537 else{ 538 IoModelToConstraintsx(constraints,iomodel,StressbalanceSpcvxEnum,StressbalanceAnalysisEnum,finiteelement,0); 539 if(iomodel->domaintype!=Domain2DverticalEnum){ 540 IoModelToConstraintsx(constraints,iomodel,StressbalanceSpcvyEnum,StressbalanceAnalysisEnum,finiteelement,1); 541 } 542 } 543 544 return; 545 } 546 547 /*Constraints: fetch data: */ 548 iomodel->FetchData(&spcvx,&Mx,&Nx,StressbalanceSpcvxEnum); 549 iomodel->FetchData(&spcvy,&My,&Ny,StressbalanceSpcvyEnum); 550 iomodel->FetchData(&spcvz,&Mz,&Nz,StressbalanceSpcvzEnum); 551 iomodel->FetchData(&nodeonSSA,NULL,NULL,FlowequationBorderSSAEnum); 552 if(iomodel->domaintype==Domain3DEnum)iomodel->FetchData(&nodeonHO,NULL,NULL,FlowequationBorderHOEnum); 553 if(iomodel->domaintype==Domain3DEnum)iomodel->FetchData(&nodeonFS,NULL,NULL,FlowequationBorderFSEnum); 554 if(iomodel->domaintype==Domain3DEnum)iomodel->FetchData(&nodeonbase,NULL,NULL,MeshVertexonbaseEnum); 555 if(iomodel->domaintype==Domain3DEnum)iomodel->FetchData(&groundedice_ls,NULL,NULL,MaskGroundediceLevelsetEnum); 556 iomodel->FetchData(&vertices_type,NULL,NULL,FlowequationVertexEquationEnum); 557 iomodel->FetchData(&surface,NULL,NULL,SurfaceEnum); 558 iomodel->FetchData(&z,NULL,NULL,MeshZEnum); 559 560 /*Initialize counter: */ 561 count=0; 562 563 /*figure out times: */ 564 timesx=xNew<IssmDouble>(Nx); 565 for(j=0;j<Nx;j++){ 566 timesx[j]=spcvx[(Mx-1)*Nx+j]; 567 } 568 /*figure out times: */ 569 timesy=xNew<IssmDouble>(Ny); 570 for(j=0;j<Ny;j++){ 571 timesy[j]=spcvy[(My-1)*Ny+j]; 572 } 573 /*figure out times: */ 574 timesz=xNew<IssmDouble>(Nz); 575 for(j=0;j<Nz;j++){ 576 timesz[j]=spcvz[(Mz-1)*Nz+j]; 577 } 578 579 /*Create spcs from x,y,z, as well as the spc values on those spcs: */ 580 for(i=0;i<iomodel->numberofvertices;i++){ 581 if(iomodel->my_vertices[i]){ 582 583 /*Start with adding spcs of coupling: zero at the border SSA/HO for the appropriate dofs*/ 584 if(reCast<int,IssmDouble>(vertices_type[i]==SSAHOApproximationEnum)){ 585 /*If grionSSA, spc HO dofs: 3 & 4*/ 586 if (reCast<int,IssmDouble>(nodeonHO[i])){ 587 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,0,0,StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 588 count++; 589 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,0,StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 590 count++; 591 if (!xIsNan<IssmDouble>(spcvx[i])){ 592 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,spcvx[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 593 count++; 594 } 595 if (!xIsNan<IssmDouble>(spcvy[i])){ 596 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,3,spcvy[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 597 count++; 598 } 599 600 } 601 else if (reCast<int,IssmDouble>(nodeonSSA[i])){ 602 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,0,StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 603 count++; 604 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,3,0,StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 605 count++; 606 if (!xIsNan<IssmDouble>(spcvx[i])){ 607 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,0,spcvx[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 608 count++; 609 } 610 if (!xIsNan<IssmDouble>(spcvy[i])){ 611 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,spcvy[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 612 count++; 613 } 614 615 } 616 else _error_("if vertices_type is SSAHO, you shoud have nodeonHO or nodeonSSA"); 617 } 618 /*Also add spcs of coupling: zero at the border HO/FS for the appropriate dofs*/ 619 else if (reCast<int,IssmDouble>(vertices_type[i])==HOFSApproximationEnum){ 620 /*If grion,HO spc FS dofs: 3 4 & 5*/ 621 if (reCast<int,IssmDouble>(nodeonHO[i])){ 622 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,0,StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 623 count++; 624 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,3,0,StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 625 count++; 626 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,4,0,StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 627 count++; 628 if (!xIsNan<IssmDouble>(spcvx[i])){ 629 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,0,spcvx[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 630 count++; 631 } 632 if (!xIsNan<IssmDouble>(spcvy[i])){ 633 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,spcvy[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 634 count++; 635 } 636 637 } 638 else if (reCast<int,IssmDouble>(nodeonFS[i])){ //spc HO nodes: 1 & 2 639 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,0,0,StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 640 count++; 641 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,0,StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 642 count++; 643 if (!xIsNan<IssmDouble>(spcvx[i])){ 644 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,spcvx[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 645 count++; 646 } 647 if (!xIsNan<IssmDouble>(spcvy[i])){ 648 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,3,spcvy[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 649 count++; 650 } 651 if (!xIsNan<IssmDouble>(spcvz[i])){ 652 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,4,spcvz[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 653 count++; 654 } 655 } 656 else _error_("if vertices_type is HOFS, you shoud have nodeonHO or nodeonFS"); 657 } 658 /*Also add spcs of coupling: zero at the border HO/FS for the appropriate dofs*/ 659 else if (reCast<int,IssmDouble>(vertices_type[i])==SSAFSApproximationEnum){ 660 /*If grion,HO spc FS dofs: 3 4 & 5*/ 661 if (reCast<int,IssmDouble>(nodeonSSA[i])){ 662 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,0,StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 663 count++; 664 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,3,0,StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 665 count++; 666 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,4,0,StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 667 count++; 668 if (!xIsNan<IssmDouble>(spcvx[i])){ 669 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,0,spcvx[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 670 count++; 671 } 672 if (!xIsNan<IssmDouble>(spcvy[i])){ 673 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,spcvy[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 674 count++; 675 } 676 677 } 678 else if (reCast<int,IssmDouble>(nodeonFS[i])){ //spc SSA nodes: 1 & 2 679 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,0,0,StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 680 count++; 681 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,0,StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 682 count++; 683 if (!xIsNan<IssmDouble>(spcvx[i])){ 684 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,spcvx[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 685 count++; 686 } 687 if (!xIsNan<IssmDouble>(spcvy[i])){ 688 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,3,spcvy[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 689 count++; 690 } 691 if (!xIsNan<IssmDouble>(spcvz[i])){ 692 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,4,spcvz[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 693 count++; 694 } 695 } 696 else _error_("if vertices_type is SSAFS, you shoud have nodeonSSA or nodeonFS"); 697 } 698 /*Now add the regular spcs*/ 699 else{ 700 if (Mx==iomodel->numberofvertices && !xIsNan<IssmDouble>(spcvx[i])){ 701 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,0,spcvx[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 702 count++; 703 704 } 705 else if (Mx==iomodel->numberofvertices+1) { 706 /*figure out times and values: */ 707 values=xNew<IssmDouble>(Nx); 708 spcpresent=false; 709 for(j=0;j<Nx;j++){ 710 values[j]=spcvx[i*Nx+j]; 711 if(!xIsNan<IssmDouble>(values[j]))spcpresent=true; //NaN means no spc by default 712 } 713 714 if(spcpresent){ 715 constraints->AddObject(new SpcTransient(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,0,Nx,timesx,values,StressbalanceAnalysisEnum)); 716 count++; 717 } 718 xDelete<IssmDouble>(values); 719 } 720 else if (vertices_type[i]==SIAApproximationEnum){ 721 constraints->AddObject(new SpcDynamic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,0,StressbalanceAnalysisEnum)); 722 count++; 723 } 724 725 if (My==iomodel->numberofvertices && !xIsNan<IssmDouble>(spcvy[i])){ 726 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,spcvy[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vy. 727 count++; 728 } 729 else if (My==iomodel->numberofvertices+1){ 730 /*figure out times and values: */ 731 values=xNew<IssmDouble>(Ny); 732 spcpresent=false; 733 for(j=0;j<Ny;j++){ 734 values[j]=spcvy[i*Ny+j]; 735 if(!xIsNan<IssmDouble>(values[j]))spcpresent=true; //NaN means no spc by default 736 } 737 if(spcpresent){ 738 constraints->AddObject(new SpcTransient(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,Ny,timesy,values,StressbalanceAnalysisEnum)); 739 count++; 740 } 741 xDelete<IssmDouble>(values); 742 } 743 else if (vertices_type[i]==SIAApproximationEnum){ 744 constraints->AddObject(new SpcDynamic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,StressbalanceAnalysisEnum)); 745 count++; 746 } 747 748 if (reCast<int,IssmDouble>(vertices_type[i])==FSApproximationEnum || (reCast<int,IssmDouble>(vertices_type[i])==NoneApproximationEnum)){ 749 if (Mz==iomodel->numberofvertices && !xIsNan<IssmDouble>(spcvz[i])){ 750 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,spcvz[i],StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 2 to vy 751 count++; 752 } 753 else if (Mz==iomodel->numberofvertices+1){ 754 /*figure out times and values: */ 755 values=xNew<IssmDouble>(Nz); 756 spcpresent=false; 757 for(j=0;j<Nz;j++){ 758 values[j]=spcvz[i*Nz+j]; 759 if(!xIsNan<IssmDouble>(values[j]))spcpresent=true; //NaN means no spc by default 760 } 761 if(spcpresent){ 762 constraints->AddObject(new SpcTransient(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,Nz,timesz,values,StressbalanceAnalysisEnum)); 763 count++; 764 } 765 xDelete<IssmDouble>(values); 766 } 767 768 } 769 if (reCast<int,IssmDouble>(vertices_type[i])==NoneApproximationEnum){ 770 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+iomodel->numberofvertices+i+1,0,g*rho_ice*(surface[i]-z[i])/FSreconditioning,StressbalanceAnalysisEnum)); //add count'th spc, on node i+1, setting dof 2 to vy 771 count++; 772 } 773 } 774 } 775 } 776 777 /*Free data: */ 778 iomodel->DeleteData(spcvx,StressbalanceSpcvxEnum); 779 iomodel->DeleteData(spcvy,StressbalanceSpcvyEnum); 780 iomodel->DeleteData(spcvz,StressbalanceSpcvzEnum); 781 iomodel->DeleteData(nodeonSSA,FlowequationBorderSSAEnum); 782 if(iomodel->domaintype==Domain3DEnum)iomodel->DeleteData(nodeonHO,FlowequationBorderHOEnum); 783 if(iomodel->domaintype==Domain3DEnum)iomodel->DeleteData(nodeonFS,FlowequationBorderFSEnum); 784 if(iomodel->domaintype==Domain3DEnum)iomodel->DeleteData(nodeonbase,MeshVertexonbaseEnum); 785 if(iomodel->domaintype==Domain3DEnum)iomodel->DeleteData(groundedice_ls,MaskGroundediceLevelsetEnum); 786 iomodel->DeleteData(vertices_type,FlowequationVertexEquationEnum); 787 iomodel->DeleteData(surface,SurfaceEnum); 788 iomodel->DeleteData(z,MeshZEnum); 789 790 /*Free resources:*/ 791 xDelete<IssmDouble>(timesx); 792 xDelete<IssmDouble>(timesy); 793 xDelete<IssmDouble>(timesz); 794 xDelete<IssmDouble>(values); 795 796 }/*}}}*/ 797 void StressbalanceAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 798 799 /*Intermediary*/ 800 const int RIFTINFOSIZE = 12; 801 int i; 802 int count; 803 int penpair_ids[2]; 804 bool isSSA,isL1L2,isHO,isFS; 805 int numpenalties,numrifts,numriftsegments; 806 IssmDouble *riftinfo = NULL; 807 IssmDouble *penalties = NULL; 808 int assert_int; 809 810 /*Fetch parameters: */ 811 iomodel->Constant(&isL1L2,FlowequationIsL1L2Enum); 812 iomodel->Constant(&isFS,FlowequationIsFSEnum); 813 iomodel->Constant(&isSSA,FlowequationIsSSAEnum); 814 iomodel->Constant(&isHO,FlowequationIsHOEnum); 815 iomodel->Constant(&numrifts,RiftsNumriftsEnum); 816 817 /*Now, is the flag macayaealHO on? otherwise, do nothing: */ 818 if(!isSSA && !isHO && !isFS && !isL1L2) return; 819 820 /*Initialize counter: */ 821 count=0; 822 823 /*Create Penpair for penalties: */ 824 iomodel->FetchData(&penalties,&numpenalties,NULL,StressbalanceVertexPairingEnum); 825 826 for(i=0;i<numpenalties;i++){ 827 828 if(iomodel->my_vertices[reCast<int,IssmDouble>(penalties[2*i+0]-1)]){ 829 830 /*In debugging mode, check that the second node is in the same cpu*/ 831 assert_int=iomodel->my_vertices[reCast<int,IssmDouble>(penalties[2*i+1]-1)]; _assert_(assert_int); 832 833 /*Get node ids*/ 834 penpair_ids[0]=iomodel->nodecounter+reCast<int,IssmDouble>(penalties[2*i+0]); 835 penpair_ids[1]=iomodel->nodecounter+reCast<int,IssmDouble>(penalties[2*i+1]); 836 837 /*Create Load*/ 838 loads->AddObject(new Penpair(iomodel->loadcounter+count+1,&penpair_ids[0],StressbalanceAnalysisEnum)); 839 count++; 840 } 841 } 842 843 /*free ressources: */ 844 iomodel->DeleteData(penalties,StressbalanceVertexPairingEnum); 845 846 /*Create Riffront loads for rifts: */ 847 if(numrifts){ 848 iomodel->FetchData(&riftinfo,&numriftsegments,NULL,RiftsRiftstructEnum); 849 iomodel->FetchData(5,RiftsRiftstructEnum,ThicknessEnum,BaseEnum,SurfaceEnum,MaskGroundediceLevelsetEnum); 850 for(i=0;i<numriftsegments;i++){ 851 if(iomodel->my_elements[reCast<int,IssmDouble>(*(riftinfo+RIFTINFOSIZE*i+2))-1]){ 852 loads->AddObject(new Riftfront(iomodel->loadcounter+count+1,i,iomodel,StressbalanceAnalysisEnum)); 853 count++; 854 } 855 } 856 iomodel->DeleteData(5,RiftsRiftstructEnum,ThicknessEnum,BaseEnum,SurfaceEnum,MaskGroundediceLevelsetEnum); 857 xDelete<IssmDouble>(riftinfo); 858 } 887 if(frictionlaw==4 || frictionlaw==6) parameters->AddObject(iomodel->CopyConstantObject(FrictionGammaEnum)); 888 859 889 }/*}}}*/ 860 890 … … 882 912 if (fe_FS==XTaylorHoodEnum) 883 913 solutionsequence_la_theta(femmodel); 884 else if (fe_FS==LATaylorHoodEnum )914 else if (fe_FS==LATaylorHoodEnum || fe_FS==LACrouzeixRaviartEnum) 885 915 solutionsequence_la(femmodel); 886 916 else if(newton>0) … … 997 1027 } 998 1028 }/*}}}*/ 999 void StressbalanceAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/1029 void StressbalanceAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 1000 1030 1001 1031 int approximation; … … 1018 1048 } 1019 1049 }/*}}}*/ 1020 void StressbalanceAnalysis::GetSolutionFromInputsHoriz(Vector<IssmDouble>* solution,Element* element){/*{{{*/1050 void StressbalanceAnalysis::GetSolutionFromInputsHoriz(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 1021 1051 1022 1052 IssmDouble vx,vy; … … 1068 1098 xDelete<int>(doflist); 1069 1099 }/*}}}*/ 1070 void StressbalanceAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/1100 void StressbalanceAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 1071 1101 _error_("Not implemented yet"); 1072 1102 }/*}}}*/ 1073 void StressbalanceAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/1103 void StressbalanceAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 1074 1104 1075 1105 int approximation; … … 1103 1133 } 1104 1134 }/*}}}*/ 1105 void StressbalanceAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/1135 void StressbalanceAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 1106 1136 /*Default, do nothing*/ 1107 1137 bool islevelset; … … 1451 1481 Bprime,bsize,numdof,0, 1452 1482 &Ke->values[0],1); 1453 1454 for(int i=0;i<bsize*numdof;i++) if(B[i]==1.) _error_("STREAM");1455 for(int i=0;i<bsize*numdof;i++) if(Bprime[i]==1.) _error_("STREAM");1456 1483 } 1457 1484 … … 1541 1568 element->NodalFunctions(basis, gauss); 1542 1569 1543 thickness_input->GetInputValue(&thickness,gauss); 1570 thickness_input->GetInputValue(&thickness,gauss); _assert_(thickness>0); 1544 1571 surface_input->GetInputDerivativeValue(&slope[0],xyz_list,gauss); 1545 1572 … … 1598 1625 IssmDouble gravity = element->GetMaterialParameter(ConstantsGEnum); 1599 1626 element->GetVerticesCoordinates(&xyz_list); 1600 //element->ZeroLevelsetCoordinates(&xyz_list_front,xyz_list,MaskIceLevelsetEnum);1601 1627 element->GetIcefrontCoordinates(&xyz_list_front,xyz_list,MaskIceLevelsetEnum); 1602 1628 element->NormalSection(&normal[0],xyz_list_front); … … 1634 1660 return pe; 1635 1661 }/*}}}*/ 1636 void StressbalanceAnalysis::GetBSSA(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/1662 void StressbalanceAnalysis::GetBSSA(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 1637 1663 /*Compute B matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2. 1638 1664 * For node i, Bi can be expressed in the actual coordinate system … … 1674 1700 xDelete<IssmDouble>(dbasis); 1675 1701 }/*}}}*/ 1676 void StressbalanceAnalysis::GetBSSAFriction(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/1702 void StressbalanceAnalysis::GetBSSAFriction(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 1677 1703 /*Compute B matrix. B=[B1 B2 B3] where Bi is square and of size 2. 1678 1704 * For node i, Bi can be expressed in the actual coordinate system … … 1711 1737 xDelete<IssmDouble>(basis); 1712 1738 }/*}}}*/ 1713 void StressbalanceAnalysis::GetBSSAprime(IssmDouble* Bprime,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/1739 void StressbalanceAnalysis::GetBSSAprime(IssmDouble* Bprime,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 1714 1740 /*Compute B' matrix. B'=[B1' B2' B3'] where Bi' is of size 3*NDOF2. 1715 1741 * For node i, Bi' can be expressed in the actual coordinate system … … 1751 1777 xDelete<IssmDouble>(dbasis); 1752 1778 }/*}}}*/ 1753 void StressbalanceAnalysis::InputUpdateFromSolutionSSA(IssmDouble* solution,Element* element){/*{{{*/1779 void StressbalanceAnalysis::InputUpdateFromSolutionSSA(IssmDouble* solution,Element* element){/*{{{*/ 1754 1780 1755 1781 int i,dim,domaintype; … … 2050 2076 IssmDouble gravity = element->GetMaterialParameter(ConstantsGEnum); 2051 2077 element->GetVerticesCoordinates(&xyz_list); 2052 element-> ZeroLevelsetCoordinates(&xyz_list_front,xyz_list,MaskIceLevelsetEnum);2078 element->GetIcefrontCoordinates(&xyz_list_front,xyz_list,MaskIceLevelsetEnum); 2053 2079 element->NormalSection(&normal[0],xyz_list_front); 2054 2080 … … 2085 2111 return pe; 2086 2112 }/*}}}*/ 2087 void StressbalanceAnalysis::InputUpdateFromSolutionL1L2(IssmDouble* solution,Element* element){/*{{{*/2113 void StressbalanceAnalysis::InputUpdateFromSolutionL1L2(IssmDouble* solution,Element* element){/*{{{*/ 2088 2114 2089 2115 int i,dim,domaintype; … … 2260 2286 return Ke; 2261 2287 }/*}}}*/ 2288 ElementMatrix* StressbalanceAnalysis::CreateKMatrixHOFriction(Element* element){/*{{{*/ 2289 2290 /* Check if ice in element */ 2291 if(!element->IsIceInElement()) return NULL; 2292 2293 if(element->IsFloating() || !element->IsOnBase()) return NULL; 2294 2295 /*Intermediaries*/ 2296 int dim; 2297 bool mainlyfloating; 2298 int migration_style,point1; 2299 IssmDouble alpha2,Jdet,fraction1,fraction2; 2300 IssmDouble gllevelset,phi=1.; 2301 IssmDouble *xyz_list_base = NULL; 2302 Gauss* gauss = NULL; 2303 2304 /*Get problem dimension*/ 2305 element->FindParam(&dim,DomainDimensionEnum); 2306 2307 /*Fetch number of nodes and dof for this finite element*/ 2308 int numnodes = element->GetNumberOfNodes(); 2309 int numdof = numnodes*(dim-1); 2310 2311 /*Initialize Element matrix and vectors*/ 2312 ElementMatrix* Ke = element->NewElementMatrix(HOApproximationEnum); 2313 IssmDouble* B = xNew<IssmDouble>((dim-1)*numdof); 2314 IssmDouble* D = xNewZeroInit<IssmDouble>((dim-1)*(dim-1)); 2315 2316 /*Retrieve all inputs and parameters*/ 2317 element->GetVerticesCoordinatesBase(&xyz_list_base); 2318 element->FindParam(&migration_style,GroundinglineMigrationEnum); 2319 Input* gllevelset_input = NULL; 2320 2321 /*build friction object, used later on: */ 2322 Friction* friction=new Friction(element,2); 2323 2324 /*Recover portion of element that is grounded*/ 2325 if(migration_style==SubelementMigrationEnum) phi=element->GetGroundedPortion(xyz_list_base); 2326 if(migration_style==SubelementMigration2Enum){ 2327 gllevelset_input=element->GetInput(MaskGroundediceLevelsetEnum); _assert_(gllevelset_input); 2328 element->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating); 2329 //gauss = element->NewGauss(point1,fraction1,fraction2,mainlyfloating,2); 2330 gauss=element->NewGaussBase(2); 2331 } 2332 else{ 2333 gauss=element->NewGaussBase(2); 2334 } 2335 2336 /* Start looping on the number of gaussian points: */ 2337 for(int ig=gauss->begin();ig<gauss->end();ig++){ 2338 gauss->GaussPoint(ig); 2339 2340 friction->GetAlpha2(&alpha2,gauss); 2341 if(migration_style==SubelementMigrationEnum) alpha2=phi*alpha2; 2342 if(migration_style==SubelementMigration2Enum){ 2343 gllevelset_input->GetInputValue(&gllevelset, gauss); 2344 if(gllevelset<0.) alpha2=0.; 2345 } 2346 2347 this->GetBHOFriction(B,element,dim,xyz_list_base,gauss); 2348 element->JacobianDeterminantBase(&Jdet,xyz_list_base,gauss); 2349 for(int i=0;i<dim-1;i++) D[i*(dim-1)+i]=alpha2*gauss->weight*Jdet; 2350 2351 TripleMultiply(B,dim-1,numdof,1, 2352 D,dim-1,dim-1,0, 2353 B,dim-1,numdof,0, 2354 &Ke->values[0],1); 2355 } 2356 2357 /*Transform Coordinate System*/ 2358 if(dim==3) element->TransformStiffnessMatrixCoord(Ke,XYEnum); 2359 2360 /*Clean up and return*/ 2361 delete gauss; 2362 delete friction; 2363 xDelete<IssmDouble>(xyz_list_base); 2364 xDelete<IssmDouble>(B); 2365 xDelete<IssmDouble>(D); 2366 return Ke; 2367 }/*}}}*/ 2262 2368 ElementMatrix* StressbalanceAnalysis::CreateKMatrixHOViscous(Element* element){/*{{{*/ 2263 2369 … … 2332 2438 return Ke; 2333 2439 }/*}}}*/ 2334 ElementMatrix* StressbalanceAnalysis::CreateKMatrixHOFriction(Element* element){/*{{{*/2335 2336 /* Check if ice in element */2337 if(!element->IsIceInElement()) return NULL;2338 2339 if(element->IsFloating() || !element->IsOnBase()) return NULL;2340 2341 /*Intermediaries*/2342 int dim;2343 bool mainlyfloating;2344 int migration_style,point1;2345 IssmDouble alpha2,Jdet,fraction1,fraction2;2346 IssmDouble gllevelset,phi=1.;2347 IssmDouble *xyz_list_base = NULL;2348 Gauss* gauss = NULL;2349 2350 /*Get problem dimension*/2351 element->FindParam(&dim,DomainDimensionEnum);2352 2353 /*Fetch number of nodes and dof for this finite element*/2354 int numnodes = element->GetNumberOfNodes();2355 int numdof = numnodes*(dim-1);2356 2357 /*Initialize Element matrix and vectors*/2358 ElementMatrix* Ke = element->NewElementMatrix(HOApproximationEnum);2359 IssmDouble* B = xNew<IssmDouble>((dim-1)*numdof);2360 IssmDouble* D = xNewZeroInit<IssmDouble>((dim-1)*(dim-1));2361 2362 /*Retrieve all inputs and parameters*/2363 element->GetVerticesCoordinatesBase(&xyz_list_base);2364 element->FindParam(&migration_style,GroundinglineMigrationEnum);2365 Input* gllevelset_input = NULL;2366 2367 /*build friction object, used later on: */2368 Friction* friction=new Friction(element,2);2369 2370 /*Recover portion of element that is grounded*/2371 if(migration_style==SubelementMigrationEnum) phi=element->GetGroundedPortion(xyz_list_base);2372 if(migration_style==SubelementMigration2Enum){2373 gllevelset_input=element->GetInput(MaskGroundediceLevelsetEnum); _assert_(gllevelset_input);2374 element->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating);2375 //gauss = element->NewGauss(point1,fraction1,fraction2,mainlyfloating,2);2376 gauss=element->NewGaussBase(2);2377 }2378 else{2379 gauss=element->NewGaussBase(2);2380 }2381 2382 /* Start looping on the number of gaussian points: */2383 for(int ig=gauss->begin();ig<gauss->end();ig++){2384 gauss->GaussPoint(ig);2385 2386 friction->GetAlpha2(&alpha2,gauss);2387 if(migration_style==SubelementMigrationEnum) alpha2=phi*alpha2;2388 if(migration_style==SubelementMigration2Enum){2389 gllevelset_input->GetInputValue(&gllevelset, gauss);2390 if(gllevelset<0.) alpha2=0.;2391 }2392 2393 this->GetBHOFriction(B,element,dim,xyz_list_base,gauss);2394 element->JacobianDeterminantBase(&Jdet,xyz_list_base,gauss);2395 for(int i=0;i<dim-1;i++) D[i*(dim-1)+i]=alpha2*gauss->weight*Jdet;2396 2397 TripleMultiply(B,dim-1,numdof,1,2398 D,dim-1,dim-1,0,2399 B,dim-1,numdof,0,2400 &Ke->values[0],1);2401 }2402 2403 /*Transform Coordinate System*/2404 if(dim==3) element->TransformStiffnessMatrixCoord(Ke,XYEnum);2405 2406 /*Clean up and return*/2407 delete gauss;2408 delete friction;2409 xDelete<IssmDouble>(xyz_list_base);2410 xDelete<IssmDouble>(B);2411 xDelete<IssmDouble>(D);2412 return Ke;2413 }/*}}}*/2414 2440 #ifdef FSANALYTICAL 2415 2441 ElementVector* StressbalanceAnalysis::CreatePVectorHO(Element* element){/*{{{*/ … … 2568 2594 IssmDouble gravity = element->GetMaterialParameter(ConstantsGEnum); 2569 2595 element->GetVerticesCoordinates(&xyz_list); 2570 element-> ZeroLevelsetCoordinates(&xyz_list_front,xyz_list,MaskIceLevelsetEnum);2596 element->GetIcefrontCoordinates(&xyz_list_front,xyz_list,MaskIceLevelsetEnum); 2571 2597 element->NormalSection(&normal[0],xyz_list_front); 2572 2598 … … 2607 2633 return pe; 2608 2634 }/*}}}*/ 2609 void StressbalanceAnalysis::GetBHO(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/2635 void StressbalanceAnalysis::GetBHO(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 2610 2636 /*Compute B matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF2. 2611 2637 * For node i, Bi can be expressed in the actual coordinate system … … 2656 2682 xDelete<IssmDouble>(dbasis); 2657 2683 }/*}}}*/ 2658 void StressbalanceAnalysis::GetBHOprime(IssmDouble* Bprime,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 2684 void StressbalanceAnalysis::GetBHOFriction(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 2685 /*Compute B matrix. B=[B1 B2 B3] where Bi is square and of size 2. 2686 * For node i, Bi can be expressed in the actual coordinate system 2687 * by: 2688 * 3D 2D 2689 * Bi=[ N 0 ] Bi=N 2690 * [ 0 N ] 2691 * where N is the finiteelement function for node i. 2692 * 2693 * We assume B has been allocated already, of size: 2 x (numdof*numnodes) 2694 */ 2695 2696 /*Fetch number of nodes for this finite element*/ 2697 int numnodes = element->GetNumberOfNodes(); 2698 2699 /*Get nodal functions derivatives*/ 2700 IssmDouble* basis=xNew<IssmDouble>(numnodes); 2701 element->NodalFunctions(basis,gauss); 2702 2703 /*Build L: */ 2704 if(dim==3){ 2705 for(int i=0;i<numnodes;i++){ 2706 B[2*numnodes*0+2*i+0] = basis[i]; 2707 B[2*numnodes*0+2*i+1] = 0.; 2708 B[2*numnodes*1+2*i+0] = 0.; 2709 B[2*numnodes*1+2*i+1] = basis[i]; 2710 } 2711 } 2712 else{ 2713 for(int i=0;i<numnodes;i++){ 2714 B[i] = basis[i]; 2715 } 2716 } 2717 2718 /*Clean-up*/ 2719 xDelete<IssmDouble>(basis); 2720 }/*}}}*/ 2721 void StressbalanceAnalysis::GetBHOprime(IssmDouble* Bprime,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 2659 2722 /*Compute B' matrix. B'=[B1' B2' B3'] where Bi' is of size 3*NDOF2. 2660 2723 * For node i, Bi' can be expressed in the actual coordinate system … … 2701 2764 xDelete<IssmDouble>(dbasis); 2702 2765 }/*}}}*/ 2703 void StressbalanceAnalysis::GetBHOFriction(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 2704 /*Compute B matrix. B=[B1 B2 B3] where Bi is square and of size 2. 2705 * For node i, Bi can be expressed in the actual coordinate system 2706 * by: 2707 * 3D 2D 2708 * Bi=[ N 0 ] Bi=N 2709 * [ 0 N ] 2710 * where N is the finiteelement function for node i. 2711 * 2712 * We assume B has been allocated already, of size: 2 x (numdof*numnodes) 2713 */ 2714 2715 /*Fetch number of nodes for this finite element*/ 2716 int numnodes = element->GetNumberOfNodes(); 2717 2718 /*Get nodal functions derivatives*/ 2719 IssmDouble* basis=xNew<IssmDouble>(numnodes); 2720 element->NodalFunctions(basis,gauss); 2721 2722 /*Build L: */ 2723 if(dim==3){ 2724 for(int i=0;i<numnodes;i++){ 2725 B[2*numnodes*0+2*i+0] = basis[i]; 2726 B[2*numnodes*0+2*i+1] = 0.; 2727 B[2*numnodes*1+2*i+0] = 0.; 2728 B[2*numnodes*1+2*i+1] = basis[i]; 2729 } 2730 } 2731 else{ 2732 for(int i=0;i<numnodes;i++){ 2733 B[i] = basis[i]; 2734 } 2735 } 2736 2737 /*Clean-up*/ 2738 xDelete<IssmDouble>(basis); 2739 }/*}}}*/ 2740 void StressbalanceAnalysis::InputUpdateFromSolutionHO(IssmDouble* solution,Element* element){/*{{{*/ 2766 void StressbalanceAnalysis::InputUpdateFromSolutionHO(IssmDouble* solution,Element* element){/*{{{*/ 2741 2767 2742 2768 int i,dim; … … 2941 2967 if(fe_FS==XTaylorHoodEnum) 2942 2968 Ke1=CreateKMatrixFSViscousXTH(element); 2943 else if(fe_FS==LATaylorHoodEnum )2944 Ke1=CreateKMatrixFSViscousLA TH(element);2969 else if(fe_FS==LATaylorHoodEnum || fe_FS==LACrouzeixRaviartEnum) 2970 Ke1=CreateKMatrixFSViscousLA(element); 2945 2971 else 2946 2972 Ke1=CreateKMatrixFSViscous(element); … … 2956 2982 return Ke; 2957 2983 }/*}}}*/ 2958 ElementMatrix* StressbalanceAnalysis::CreateKMatrixFSViscousLATH(Element* element){/*{{{*/ 2984 ElementMatrix* StressbalanceAnalysis::CreateKMatrixFSShelf(Element* element){/*{{{*/ 2985 2986 if(!element->IsFloating() || !element->IsOnBase()) return NULL; 2987 2988 /*If on not water or not FS, skip stiffness: */ 2989 int approximation,shelf_dampening; 2990 element->GetInputValue(&approximation,ApproximationEnum); 2991 if(approximation!=FSApproximationEnum && approximation!=SSAFSApproximationEnum && approximation!=HOFSApproximationEnum) return NULL; 2992 element->FindParam(&shelf_dampening,StressbalanceShelfDampeningEnum); 2993 if(shelf_dampening==0) return NULL; 2994 2995 /*Intermediaries*/ 2996 bool mainlyfloating; 2997 int j,i,dim; 2998 IssmDouble Jdet,slope2,scalar,dt; 2999 IssmDouble slope[3]; 3000 IssmDouble *xyz_list_base = NULL; 3001 IssmDouble *xyz_list = NULL; 3002 Gauss* gauss = NULL; 3003 3004 /*Get problem dimension*/ 3005 element->FindParam(&dim,DomainDimensionEnum); 3006 3007 /*Fetch number of nodes and dof for this finite element*/ 3008 int vnumnodes = element->NumberofNodesVelocity(); 3009 int pnumnodes = element->NumberofNodesPressure(); 3010 int numdof = vnumnodes*dim + pnumnodes; 3011 3012 /*Initialize Element matrix and vectors*/ 3013 ElementMatrix* Ke = element->NewElementMatrix(FSvelocityEnum); 3014 IssmDouble* vbasis = xNew<IssmDouble>(vnumnodes); 3015 3016 /*Retrieve all inputs and parameters*/ 3017 element->GetVerticesCoordinatesBase(&xyz_list_base); 3018 element->GetVerticesCoordinates(&xyz_list); 3019 element->FindParam(&dt,TimesteppingTimeStepEnum); 3020 if(dt==0) dt=1.e+5; 3021 IssmDouble rho_water = element->GetMaterialParameter(MaterialsRhoSeawaterEnum); 3022 IssmDouble gravity = element->GetMaterialParameter(ConstantsGEnum); 3023 Input* surface_input = element->GetInput(SurfaceEnum); _assert_(surface_input); 3024 3025 /* Start looping on the number of gaussian points: */ 3026 gauss=element->NewGaussBase(3); 3027 for(int ig=gauss->begin();ig<gauss->end();ig++){ 3028 gauss->GaussPoint(ig); 3029 3030 surface_input->GetInputDerivativeValue(&slope[0],xyz_list,gauss); 3031 element->NodalFunctionsVelocity(vbasis,gauss); 3032 element->JacobianDeterminantBase(&Jdet,xyz_list_base,gauss); 3033 if(dim==2) slope2=slope[0]*slope[0]; 3034 else if(dim==3) slope2=slope[0]*slope[0]+slope[1]*slope[1]; 3035 scalar = rho_water*gravity*sqrt(1+slope2)*gauss->weight*Jdet*dt; 3036 for(i=0;i<vnumnodes;i++){ 3037 for(j=0;j<vnumnodes;j++){ 3038 Ke->values[numdof*((i+1)*dim-1)+(j+1)*dim-1] += scalar*vbasis[i]*vbasis[j]; 3039 } 3040 } 3041 } 3042 3043 /*DO NOT Transform Coordinate System: this stiffness matrix is already expressed in tangential coordinates*/ 3044 3045 /*Clean up and return*/ 3046 delete gauss; 3047 xDelete<IssmDouble>(xyz_list_base); 3048 xDelete<IssmDouble>(xyz_list); 3049 xDelete<IssmDouble>(vbasis); 3050 return Ke; 3051 }/*}}}*/ 3052 ElementMatrix* StressbalanceAnalysis::CreateKMatrixFSViscous(Element* element){/*{{{*/ 3053 3054 /*Intermediaries*/ 3055 int i,dim,epssize; 3056 IssmDouble viscosity,FSreconditioning,Jdet; 3057 IssmDouble *xyz_list = NULL; 3058 3059 /*Get problem dimension*/ 3060 element->FindParam(&dim,DomainDimensionEnum); 3061 if(dim==2) epssize = 3; 3062 else epssize = 6; 3063 3064 /*Fetch number of nodes and dof for this finite element*/ 3065 int vnumnodes = element->NumberofNodesVelocity(); 3066 int pnumnodes = element->NumberofNodesPressure(); 3067 int numdof = vnumnodes*dim + pnumnodes; 3068 int bsize = epssize + 2; 3069 3070 /*Prepare coordinate system list*/ 3071 int* cs_list = xNew<int>(vnumnodes+pnumnodes); 3072 if(dim==2) for(i=0;i<vnumnodes;i++) cs_list[i] = XYEnum; 3073 else for(i=0;i<vnumnodes;i++) cs_list[i] = XYZEnum; 3074 for(i=0;i<pnumnodes;i++) cs_list[vnumnodes+i] = PressureEnum; 3075 3076 /*Initialize Element matrix and vectors*/ 3077 ElementMatrix* Ke = element->NewElementMatrix(FSvelocityEnum); 3078 IssmDouble* B = xNew<IssmDouble>(bsize*numdof); 3079 IssmDouble* Bprime = xNew<IssmDouble>(bsize*numdof); 3080 IssmDouble* D = xNewZeroInit<IssmDouble>(bsize*bsize); 3081 3082 /*Retrieve all inputs and parameters*/ 3083 element->GetVerticesCoordinates(&xyz_list); 3084 element->FindParam(&FSreconditioning,StressbalanceFSreconditioningEnum); 3085 Input* vx_input=element->GetInput(VxEnum); _assert_(vx_input); 3086 Input* vy_input=element->GetInput(VyEnum); _assert_(vy_input); 3087 Input* vz_input; 3088 if(dim==3){vz_input=element->GetInput(VzEnum); _assert_(vz_input);} 3089 3090 /* Start looping on the number of gaussian points: */ 3091 Gauss* gauss = element->NewGauss(5); 3092 for(int ig=gauss->begin();ig<gauss->end();ig++){ 3093 gauss->GaussPoint(ig); 3094 3095 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 3096 this->GetBFS(B,element,dim,xyz_list,gauss); 3097 this->GetBFSprime(Bprime,element,dim,xyz_list,gauss); 3098 3099 element->ViscosityFS(&viscosity,dim,xyz_list,gauss,vx_input,vy_input,vz_input); 3100 for(i=0;i<epssize;i++) D[i*bsize+i] = + 2.*viscosity*gauss->weight*Jdet; 3101 for(i=epssize;i<bsize;i++) D[i*bsize+i] = - FSreconditioning*gauss->weight*Jdet; 3102 3103 TripleMultiply(B,bsize,numdof,1, 3104 D,bsize,bsize,0, 3105 Bprime,bsize,numdof,0, 3106 &Ke->values[0],1); 3107 } 3108 3109 /*Transform Coordinate System*/ 3110 element->TransformStiffnessMatrixCoord(Ke,cs_list); 3111 3112 /*Clean up and return*/ 3113 delete gauss; 3114 xDelete<IssmDouble>(xyz_list); 3115 xDelete<IssmDouble>(D); 3116 xDelete<IssmDouble>(Bprime); 3117 xDelete<IssmDouble>(B); 3118 xDelete<int>(cs_list); 3119 return Ke; 3120 }/*}}}*/ 3121 ElementMatrix* StressbalanceAnalysis::CreateKMatrixFSViscousLA(Element* element){/*{{{*/ 2959 3122 2960 3123 /*Intermediaries*/ … … 3028 3191 } 3029 3192 3030 if(element->IsOnBase()){ 3193 /*The pressure augmentation should not be transformed*/ 3194 MatrixMultiply(BtBUzawa,pnumdof,numdof,1, 3195 BtBUzawa,pnumdof,numdof,0, 3196 &Ke->values[0],1); 3197 3198 if(element->IsOnBase() && 0){ 3031 3199 element->FindParam(&rl,AugmentedLagrangianRlambdaEnum); 3032 3200 element->GetVerticesCoordinatesBase(&xyz_list_base); … … 3068 3236 /*Transform Coordinate System*/ 3069 3237 element->TransformStiffnessMatrixCoord(Ke,cs_list); 3070 3071 /*The pressure augmentation should not be transformed*/3072 MatrixMultiply(BtBUzawa,pnumdof,numdof,1,3073 BtBUzawa,pnumdof,numdof,0,3074 &Ke->values[0],1);3075 3238 3076 3239 /*Clean up and return*/ … … 3155 3318 return Ke; 3156 3319 }/*}}}*/ 3157 ElementMatrix* StressbalanceAnalysis::CreateKMatrixFSViscous(Element* element){/*{{{*/3158 3159 /*Intermediaries*/3160 int i,dim,epssize;3161 IssmDouble viscosity,FSreconditioning,Jdet;3162 IssmDouble *xyz_list = NULL;3163 3164 /*Get problem dimension*/3165 element->FindParam(&dim,DomainDimensionEnum);3166 if(dim==2) epssize = 3;3167 else epssize = 6;3168 3169 /*Fetch number of nodes and dof for this finite element*/3170 int vnumnodes = element->NumberofNodesVelocity();3171 int pnumnodes = element->NumberofNodesPressure();3172 int numdof = vnumnodes*dim + pnumnodes;3173 int bsize = epssize + 2;3174 3175 /*Prepare coordinate system list*/3176 int* cs_list = xNew<int>(vnumnodes+pnumnodes);3177 if(dim==2) for(i=0;i<vnumnodes;i++) cs_list[i] = XYEnum;3178 else for(i=0;i<vnumnodes;i++) cs_list[i] = XYZEnum;3179 for(i=0;i<pnumnodes;i++) cs_list[vnumnodes+i] = PressureEnum;3180 3181 /*Initialize Element matrix and vectors*/3182 ElementMatrix* Ke = element->NewElementMatrix(FSvelocityEnum);3183 IssmDouble* B = xNew<IssmDouble>(bsize*numdof);3184 IssmDouble* Bprime = xNew<IssmDouble>(bsize*numdof);3185 IssmDouble* D = xNewZeroInit<IssmDouble>(bsize*bsize);3186 3187 /*Retrieve all inputs and parameters*/3188 element->GetVerticesCoordinates(&xyz_list);3189 element->FindParam(&FSreconditioning,StressbalanceFSreconditioningEnum);3190 Input* vx_input=element->GetInput(VxEnum); _assert_(vx_input);3191 Input* vy_input=element->GetInput(VyEnum); _assert_(vy_input);3192 Input* vz_input;3193 if(dim==3){vz_input=element->GetInput(VzEnum); _assert_(vz_input);}3194 3195 /* Start looping on the number of gaussian points: */3196 Gauss* gauss = element->NewGauss(5);3197 for(int ig=gauss->begin();ig<gauss->end();ig++){3198 gauss->GaussPoint(ig);3199 3200 element->JacobianDeterminant(&Jdet,xyz_list,gauss);3201 this->GetBFS(B,element,dim,xyz_list,gauss);3202 this->GetBFSprime(Bprime,element,dim,xyz_list,gauss);3203 3204 element->ViscosityFS(&viscosity,dim,xyz_list,gauss,vx_input,vy_input,vz_input);3205 for(i=0;i<epssize;i++) D[i*bsize+i] = + 2.*viscosity*gauss->weight*Jdet;3206 for(i=epssize;i<bsize;i++) D[i*bsize+i] = - FSreconditioning*gauss->weight*Jdet;3207 3208 TripleMultiply(B,bsize,numdof,1,3209 D,bsize,bsize,0,3210 Bprime,bsize,numdof,0,3211 &Ke->values[0],1);3212 }3213 3214 /*Transform Coordinate System*/3215 element->TransformStiffnessMatrixCoord(Ke,cs_list);3216 3217 /*Clean up and return*/3218 delete gauss;3219 xDelete<IssmDouble>(xyz_list);3220 xDelete<IssmDouble>(D);3221 xDelete<IssmDouble>(Bprime);3222 xDelete<IssmDouble>(B);3223 xDelete<int>(cs_list);3224 return Ke;3225 }/*}}}*/3226 ElementMatrix* StressbalanceAnalysis::CreateKMatrixFSShelf(Element* element){/*{{{*/3227 3228 if(!element->IsFloating() || !element->IsOnBase()) return NULL;3229 3230 /*If on not water or not FS, skip stiffness: */3231 int approximation,shelf_dampening;3232 element->GetInputValue(&approximation,ApproximationEnum);3233 if(approximation!=FSApproximationEnum && approximation!=SSAFSApproximationEnum && approximation!=HOFSApproximationEnum) return NULL;3234 element->FindParam(&shelf_dampening,StressbalanceShelfDampeningEnum);3235 if(shelf_dampening==0) return NULL;3236 3237 /*Intermediaries*/3238 bool mainlyfloating;3239 int j,i,dim;3240 IssmDouble Jdet,slope2,scalar,dt;3241 IssmDouble slope[3];3242 IssmDouble *xyz_list_base = NULL;3243 IssmDouble *xyz_list = NULL;3244 Gauss* gauss = NULL;3245 3246 /*Get problem dimension*/3247 element->FindParam(&dim,DomainDimensionEnum);3248 3249 /*Fetch number of nodes and dof for this finite element*/3250 int vnumnodes = element->NumberofNodesVelocity();3251 int pnumnodes = element->NumberofNodesPressure();3252 int numdof = vnumnodes*dim + pnumnodes;3253 3254 /*Initialize Element matrix and vectors*/3255 ElementMatrix* Ke = element->NewElementMatrix(FSvelocityEnum);3256 IssmDouble* vbasis = xNew<IssmDouble>(vnumnodes);3257 3258 /*Retrieve all inputs and parameters*/3259 element->GetVerticesCoordinatesBase(&xyz_list_base);3260 element->GetVerticesCoordinates(&xyz_list);3261 element->FindParam(&dt,TimesteppingTimeStepEnum);3262 if(dt==0) dt=1.e+5;3263 IssmDouble rho_water = element->GetMaterialParameter(MaterialsRhoSeawaterEnum);3264 IssmDouble gravity = element->GetMaterialParameter(ConstantsGEnum);3265 Input* surface_input = element->GetInput(SurfaceEnum); _assert_(surface_input);3266 3267 /* Start looping on the number of gaussian points: */3268 gauss=element->NewGaussBase(3);3269 for(int ig=gauss->begin();ig<gauss->end();ig++){3270 gauss->GaussPoint(ig);3271 3272 surface_input->GetInputDerivativeValue(&slope[0],xyz_list,gauss);3273 element->NodalFunctionsVelocity(vbasis,gauss);3274 element->JacobianDeterminantBase(&Jdet,xyz_list_base,gauss);3275 if(dim==2) slope2=slope[0]*slope[0];3276 else if(dim==3) slope2=slope[0]*slope[0]+slope[1]*slope[1];3277 scalar = rho_water*gravity*sqrt(1+slope2)*gauss->weight*Jdet*dt;3278 for(i=0;i<vnumnodes;i++){3279 for(j=0;j<vnumnodes;j++){3280 Ke->values[numdof*((i+1)*dim-1)+(j+1)*dim-1] += scalar*vbasis[i]*vbasis[j];3281 }3282 }3283 }3284 3285 /*DO NOT Transform Coordinate System: this stiffness matrix is already expressed in tangential coordinates*/3286 3287 /*Clean up and return*/3288 delete gauss;3289 xDelete<IssmDouble>(xyz_list_base);3290 xDelete<IssmDouble>(xyz_list);3291 xDelete<IssmDouble>(vbasis);3292 return Ke;3293 }/*}}}*/3294 3320 #ifdef FSANALYTICAL 3295 3321 ElementMatrix* StressbalanceAnalysis::CreateKMatrixFSFriction(Element* element){/*{{{*/ … … 3376 3402 3377 3403 /*clean-up and return*/ 3404 return pe; 3405 }/*}}}*/ 3406 ElementVector* StressbalanceAnalysis::CreatePVectorFSFriction(Element* element){/*{{{*/ 3407 3408 if(!element->IsOnBase()) return NULL; 3409 3410 /*Intermediaries*/ 3411 int dim; 3412 IssmDouble alpha2,Jdet; 3413 IssmDouble bed_normal[3]; 3414 IssmDouble *xyz_list_base = NULL; 3415 Gauss* gauss = NULL; 3416 3417 /*Get problem dimension*/ 3418 element->FindParam(&dim,DomainDimensionEnum); 3419 3420 /*Fetch number of nodes and dof for this finite element*/ 3421 int vnumnodes = element->NumberofNodesVelocity(); 3422 3423 /*Initialize Element matrix and vectors*/ 3424 ElementVector* pe = element->NewElementVector(FSvelocityEnum); 3425 IssmDouble* vbasis = xNew<IssmDouble>(vnumnodes); 3426 3427 /*Retrieve all inputs and parameters*/ 3428 element->GetVerticesCoordinatesBase(&xyz_list_base); 3429 Input* alpha2_input=element->GetInput(FrictionCoefficientEnum); _assert_(alpha2_input); 3430 3431 /* Start looping on the number of gaussian points: */ 3432 gauss=element->NewGaussBase(3); 3433 for(int ig=gauss->begin();ig<gauss->end();ig++){ 3434 gauss->GaussPoint(ig); 3435 3436 alpha2_input->GetInputValue(&alpha2, gauss); 3437 element->JacobianDeterminantBase(&Jdet,xyz_list_base,gauss); 3438 element->NodalFunctionsVelocity(vbasis,gauss); 3439 element->NormalBase(&bed_normal[0],xyz_list_base); 3440 3441 for(int i=0;i<vnumnodes;i++){ 3442 pe->values[i*dim+0] += - alpha2*gauss->weight*Jdet*vbasis[i]*bed_normal[1]; 3443 pe->values[i*dim+1] += alpha2*gauss->weight*Jdet*vbasis[i]*bed_normal[0]; 3444 if(dim==3){ 3445 pe->values[i*dim+2]+= alpha2*gauss->weight*Jdet*vbasis[i]; 3446 } 3447 } 3448 3449 } 3450 3451 /*DO NOT Transform Coordinate System: this stiffness matrix is already expressed in tangential coordinates*/ 3452 3453 /*Clean up and return*/ 3454 delete gauss; 3455 xDelete<IssmDouble>(xyz_list_base); 3456 xDelete<IssmDouble>(vbasis); 3457 return pe; 3458 }/*}}}*/ 3459 ElementVector* StressbalanceAnalysis::CreatePVectorFSStress(Element* element){/*{{{*/ 3460 3461 if(!element->IsOnBase()) return NULL; 3462 3463 /*Intermediaries*/ 3464 int dim; 3465 IssmDouble sigmann,sigmant,Jdet,bedslope,beta; 3466 IssmDouble *xyz_list_base = NULL; 3467 Gauss* gauss = NULL; 3468 3469 /*Get problem dimension*/ 3470 element->FindParam(&dim,DomainDimensionEnum); 3471 3472 /*Fetch number of nodes and dof for this finite element*/ 3473 int vnumnodes = element->NumberofNodesVelocity(); 3474 3475 /*Initialize Element matrix and vectors*/ 3476 ElementVector* pe = element->NewElementVector(FSvelocityEnum); 3477 IssmDouble* vbasis = xNew<IssmDouble>(vnumnodes); 3478 3479 /*Retrieve all inputs and parameters*/ 3480 element->GetVerticesCoordinatesBase(&xyz_list_base); 3481 Input* sigmann_input=element->GetInput(VzEnum); _assert_(sigmann_input); 3482 Input* sigmant_input=element->GetInput(TemperatureEnum); _assert_(sigmant_input); 3483 Input* bedslope_input=element->GetInput(BedSlopeXEnum); _assert_(bedslope_input); 3484 3485 /* Start looping on the number of gaussian points: */ 3486 gauss=element->NewGaussBase(3); 3487 for(int ig=gauss->begin();ig<gauss->end();ig++){ 3488 gauss->GaussPoint(ig); 3489 3490 sigmann_input->GetInputValue(&sigmann, gauss); 3491 sigmant_input->GetInputValue(&sigmant, gauss); 3492 bedslope_input->GetInputValue(&bedslope, gauss); 3493 element->JacobianDeterminantBase(&Jdet,xyz_list_base,gauss); 3494 element->NodalFunctionsVelocity(vbasis,gauss); 3495 3496 beta=sqrt(1+bedslope*bedslope); 3497 for(int i=0;i<vnumnodes;i++){ 3498 pe->values[i*dim+0] += - (1./beta)*(-bedslope*sigmann + sigmant)*gauss->weight*Jdet*vbasis[i]; 3499 pe->values[i*dim+1] += - (1./beta)*(sigmann + bedslope*sigmant)*gauss->weight*Jdet*vbasis[i]; 3500 if(dim==3){ 3501 //pe->values[i*dim+2]+= alpha2*gauss->weight*Jdet*vbasis[i]; 3502 _error_("3d not supported yet"); 3503 } 3504 } 3505 3506 } 3507 3508 /*DO NOT Transform Coordinate System: this stiffness matrix is already expressed in tangential coordinates*/ 3509 3510 /*Clean up and return*/ 3511 delete gauss; 3512 xDelete<IssmDouble>(xyz_list_base); 3513 xDelete<IssmDouble>(vbasis); 3378 3514 return pe; 3379 3515 }/*}}}*/ … … 3444 3580 return pe3; 3445 3581 } 3446 else if(fe_FS==LATaylorHoodEnum ){3447 ElementVector* pe2=CreatePVectorFSViscousLA TH(element);3582 else if(fe_FS==LATaylorHoodEnum || fe_FS==LACrouzeixRaviartEnum){ 3583 ElementVector* pe2=CreatePVectorFSViscousLA(element); 3448 3584 ElementVector* pe3 = new ElementVector(pe,pe2); 3449 3585 delete pe; … … 3451 3587 return pe3; 3452 3588 } 3453 return pe;3454 }/*}}}*/3455 ElementVector* StressbalanceAnalysis::CreatePVectorFSFriction(Element* element){/*{{{*/3456 3457 if(!element->IsOnBase()) return NULL;3458 3459 /*Intermediaries*/3460 int dim;3461 IssmDouble alpha2,Jdet;3462 IssmDouble bed_normal[3];3463 IssmDouble *xyz_list_base = NULL;3464 Gauss* gauss = NULL;3465 3466 /*Get problem dimension*/3467 element->FindParam(&dim,DomainDimensionEnum);3468 3469 /*Fetch number of nodes and dof for this finite element*/3470 int vnumnodes = element->NumberofNodesVelocity();3471 3472 /*Initialize Element matrix and vectors*/3473 ElementVector* pe = element->NewElementVector(FSvelocityEnum);3474 IssmDouble* vbasis = xNew<IssmDouble>(vnumnodes);3475 3476 /*Retrieve all inputs and parameters*/3477 element->GetVerticesCoordinatesBase(&xyz_list_base);3478 Input* alpha2_input=element->GetInput(FrictionCoefficientEnum); _assert_(alpha2_input);3479 3480 /* Start looping on the number of gaussian points: */3481 gauss=element->NewGaussBase(3);3482 for(int ig=gauss->begin();ig<gauss->end();ig++){3483 gauss->GaussPoint(ig);3484 3485 alpha2_input->GetInputValue(&alpha2, gauss);3486 element->JacobianDeterminantBase(&Jdet,xyz_list_base,gauss);3487 element->NodalFunctionsVelocity(vbasis,gauss);3488 element->NormalBase(&bed_normal[0],xyz_list_base);3489 3490 for(int i=0;i<vnumnodes;i++){3491 pe->values[i*dim+0] += - alpha2*gauss->weight*Jdet*vbasis[i]*bed_normal[1];3492 pe->values[i*dim+1] += alpha2*gauss->weight*Jdet*vbasis[i]*bed_normal[0];3493 if(dim==3){3494 pe->values[i*dim+2]+= alpha2*gauss->weight*Jdet*vbasis[i];3495 }3496 }3497 3498 }3499 3500 /*DO NOT Transform Coordinate System: this stiffness matrix is already expressed in tangential coordinates*/3501 3502 /*Clean up and return*/3503 delete gauss;3504 xDelete<IssmDouble>(xyz_list_base);3505 xDelete<IssmDouble>(vbasis);3506 return pe;3507 }/*}}}*/3508 ElementVector* StressbalanceAnalysis::CreatePVectorFSStress(Element* element){/*{{{*/3509 3510 if(!element->IsOnBase()) return NULL;3511 3512 /*Intermediaries*/3513 int dim;3514 IssmDouble sigmann,sigmant,Jdet,bedslope,beta;3515 IssmDouble *xyz_list_base = NULL;3516 Gauss* gauss = NULL;3517 3518 /*Get problem dimension*/3519 element->FindParam(&dim,DomainDimensionEnum);3520 3521 /*Fetch number of nodes and dof for this finite element*/3522 int vnumnodes = element->NumberofNodesVelocity();3523 3524 /*Initialize Element matrix and vectors*/3525 ElementVector* pe = element->NewElementVector(FSvelocityEnum);3526 IssmDouble* vbasis = xNew<IssmDouble>(vnumnodes);3527 3528 /*Retrieve all inputs and parameters*/3529 element->GetVerticesCoordinatesBase(&xyz_list_base);3530 Input* sigmann_input=element->GetInput(VzEnum); _assert_(sigmann_input);3531 Input* sigmant_input=element->GetInput(TemperatureEnum); _assert_(sigmant_input);3532 Input* bedslope_input=element->GetInput(BedSlopeXEnum); _assert_(bedslope_input);3533 3534 /* Start looping on the number of gaussian points: */3535 gauss=element->NewGaussBase(3);3536 for(int ig=gauss->begin();ig<gauss->end();ig++){3537 gauss->GaussPoint(ig);3538 3539 sigmann_input->GetInputValue(&sigmann, gauss);3540 sigmant_input->GetInputValue(&sigmant, gauss);3541 bedslope_input->GetInputValue(&bedslope, gauss);3542 element->JacobianDeterminantBase(&Jdet,xyz_list_base,gauss);3543 element->NodalFunctionsVelocity(vbasis,gauss);3544 3545 beta=sqrt(1+bedslope*bedslope);3546 for(int i=0;i<vnumnodes;i++){3547 pe->values[i*dim+0] += - (1./beta)*(-bedslope*sigmann + sigmant)*gauss->weight*Jdet*vbasis[i];3548 pe->values[i*dim+1] += - (1./beta)*(sigmann + bedslope*sigmant)*gauss->weight*Jdet*vbasis[i];3549 if(dim==3){3550 //pe->values[i*dim+2]+= alpha2*gauss->weight*Jdet*vbasis[i];3551 _error_("3d not supported yet");3552 }3553 }3554 3555 }3556 3557 /*DO NOT Transform Coordinate System: this stiffness matrix is already expressed in tangential coordinates*/3558 3559 /*Clean up and return*/3560 delete gauss;3561 xDelete<IssmDouble>(xyz_list_base);3562 xDelete<IssmDouble>(vbasis);3563 3589 return pe; 3564 3590 }/*}}}*/ … … 3668 3694 delete pe4; 3669 3695 } 3670 else if(fe_FS==LATaylorHoodEnum ){3696 else if(fe_FS==LATaylorHoodEnum || fe_FS==LACrouzeixRaviartEnum){ 3671 3697 ElementVector* pe1=CreatePVectorFSViscous(element); 3672 3698 ElementVector* pe2=CreatePVectorFSShelf(element); 3673 3699 ElementVector* pe3=CreatePVectorFSFront(element); 3674 3700 ElementVector* petemp =new ElementVector(pe1,pe2,pe3); 3675 ElementVector* pe4=CreatePVectorFSViscousLA TH(element);3701 ElementVector* pe4=CreatePVectorFSViscousLA(element); 3676 3702 pe = new ElementVector(petemp,pe4); 3677 3703 delete pe1; … … 3764 3790 }/*}}}*/ 3765 3791 #endif 3792 ElementVector* StressbalanceAnalysis::CreatePVectorFSFront(Element* element){/*{{{*/ 3793 3794 /*If no front, return NULL*/ 3795 if(!element->IsIcefront()) return NULL; 3796 3797 /*Intermediaries*/ 3798 int i,dim; 3799 IssmDouble Jdet,pressure,surface,z; 3800 IssmDouble normal[3]; 3801 IssmDouble *xyz_list = NULL; 3802 IssmDouble *xyz_list_front = NULL; 3803 Gauss *gauss = NULL; 3804 3805 /*Make sure current element is floating*/ 3806 if(!element->IsFloating()) return NULL; 3807 3808 /*Get problem dimension*/ 3809 element->FindParam(&dim,DomainDimensionEnum); 3810 3811 /*Fetch number of nodes and dof for this finite element*/ 3812 int vnumnodes = element->NumberofNodesVelocity(); 3813 int pnumnodes = element->NumberofNodesPressure(); 3814 int numvertices = element->GetNumberOfVertices(); 3815 3816 /*Prepare coordinate system list*/ 3817 int* cs_list = xNew<int>(vnumnodes+pnumnodes); 3818 if(dim==2) for(i=0;i<vnumnodes;i++) cs_list[i] = XYEnum; 3819 else for(i=0;i<vnumnodes;i++) cs_list[i] = XYZEnum; 3820 for(i=0;i<pnumnodes;i++) cs_list[vnumnodes+i] = PressureEnum; 3821 3822 /*Initialize vectors*/ 3823 ElementVector* pe = element->NewElementVector(FSvelocityEnum); 3824 IssmDouble* vbasis = xNew<IssmDouble>(vnumnodes); 3825 3826 /*Retrieve all inputs and parameters*/ 3827 element->GetVerticesCoordinates(&xyz_list); 3828 element->GetIcefrontCoordinates(&xyz_list_front,xyz_list,MaskIceLevelsetEnum); 3829 element->NormalSection(&normal[0],xyz_list_front); 3830 Input* surface_input = element->GetInput(SurfaceEnum); _assert_(surface_input); 3831 IssmDouble rho_water = element->GetMaterialParameter(MaterialsRhoSeawaterEnum); 3832 IssmDouble gravity = element->GetMaterialParameter(ConstantsGEnum); 3833 3834 /*Initialize gauss points*/ 3835 IssmDouble zmax=xyz_list[0*3+(dim-1)]; for(int i=1;i<numvertices;i++) if(xyz_list[i*3+(dim-1)]>zmax) zmax=xyz_list[i*3+(dim-1)]; 3836 IssmDouble zmin=xyz_list[0*3+(dim-1)]; for(int i=1;i<numvertices;i++) if(xyz_list[i*3+(dim-1)]<zmin) zmin=xyz_list[i*3+(dim-1)]; 3837 if(zmax>0. && zmin<0.) gauss=element->NewGauss(xyz_list,xyz_list_front,3,30);//refined in vertical because of the sea level discontinuity 3838 else gauss=element->NewGauss(xyz_list,xyz_list_front,3,3); 3839 3840 /* Start looping on the number of gaussian points: */ 3841 for(int ig=gauss->begin();ig<gauss->end();ig++){ 3842 gauss->GaussPoint(ig); 3843 3844 element->JacobianDeterminantSurface(&Jdet,xyz_list_front,gauss); 3845 element->NodalFunctionsVelocity(vbasis,gauss); 3846 surface_input->GetInputValue(&surface,gauss); 3847 if(dim==3) z=element->GetZcoord(xyz_list,gauss); 3848 else z=element->GetYcoord(xyz_list,gauss); 3849 pressure = rho_water*gravity*min(0.,z);//0 if the gaussian point is above water level 3850 3851 for (int i=0;i<vnumnodes;i++){ 3852 pe->values[dim*i+0]+= pressure*Jdet*gauss->weight*normal[0]*vbasis[i]; 3853 pe->values[dim*i+1]+= pressure*Jdet*gauss->weight*normal[1]*vbasis[i]; 3854 if(dim==3) pe->values[dim*i+2]+= pressure*Jdet*gauss->weight*normal[2]*vbasis[i]; 3855 } 3856 } 3857 3858 /*Transform coordinate system*/ 3859 element->TransformLoadVectorCoord(pe,cs_list); 3860 3861 /*Clean up and return*/ 3862 delete gauss; 3863 xDelete<int>(cs_list); 3864 xDelete<IssmDouble>(vbasis); 3865 xDelete<IssmDouble>(xyz_list); 3866 xDelete<IssmDouble>(xyz_list_front); 3867 return pe; 3868 }/*}}}*/ 3869 ElementVector* StressbalanceAnalysis::CreatePVectorFSShelf(Element* element){/*{{{*/ 3870 3871 int i,dim; 3872 IssmDouble Jdet,water_pressure,bed; 3873 IssmDouble normal[3]; 3874 IssmDouble *xyz_list_base = NULL; 3875 3876 /*Get basal element*/ 3877 if(!element->IsOnBase() || !element->IsFloating()) return NULL; 3878 3879 /*Get problem dimension*/ 3880 element->FindParam(&dim,DomainDimensionEnum); 3881 3882 /*Fetch number of nodes and dof for this finite element*/ 3883 int vnumnodes = element->NumberofNodesVelocity(); 3884 int pnumnodes = element->NumberofNodesPressure(); 3885 3886 /*Prepare coordinate system list*/ 3887 int* cs_list = xNew<int>(vnumnodes+pnumnodes); 3888 if(dim==2) for(i=0;i<vnumnodes;i++) cs_list[i] = XYEnum; 3889 else for(i=0;i<vnumnodes;i++) cs_list[i] = XYZEnum; 3890 for(i=0;i<pnumnodes;i++) cs_list[vnumnodes+i] = PressureEnum; 3891 3892 /*Initialize vectors*/ 3893 ElementVector* pe = element->NewElementVector(FSvelocityEnum); 3894 IssmDouble* vbasis = xNew<IssmDouble>(vnumnodes); 3895 3896 /*Retrieve all inputs and parameters*/ 3897 element->GetVerticesCoordinatesBase(&xyz_list_base); 3898 Input* base_input=element->GetInput(BaseEnum); _assert_(base_input); 3899 IssmDouble rho_water=element->GetMaterialParameter(MaterialsRhoSeawaterEnum); 3900 IssmDouble gravity =element->GetMaterialParameter(ConstantsGEnum); 3901 3902 /* Start looping on the number of gaussian points: */ 3903 Gauss* gauss=element->NewGaussBase(5); 3904 for(int ig=gauss->begin();ig<gauss->end();ig++){ 3905 gauss->GaussPoint(ig); 3906 3907 element->JacobianDeterminantBase(&Jdet,xyz_list_base,gauss); 3908 element->NodalFunctionsVelocity(vbasis,gauss); 3909 3910 element->NormalBase(&normal[0],xyz_list_base); 3911 _assert_(normal[dim-1]<0.); 3912 base_input->GetInputValue(&bed, gauss); 3913 water_pressure=gravity*rho_water*bed; 3914 3915 for(i=0;i<vnumnodes;i++){ 3916 pe->values[i*dim+0] += water_pressure*gauss->weight*Jdet*vbasis[i]*normal[0]; 3917 pe->values[i*dim+1] += water_pressure*gauss->weight*Jdet*vbasis[i]*normal[1]; 3918 if(dim==3){ 3919 pe->values[i*dim+2]+=water_pressure*gauss->weight*Jdet*vbasis[i]*normal[2]; 3920 } 3921 } 3922 } 3923 3924 /*Transform coordinate system*/ 3925 element->TransformLoadVectorCoord(pe,cs_list); 3926 3927 /* shelf dampening*/ 3928 int shelf_dampening; 3929 element->FindParam(&shelf_dampening,StressbalanceShelfDampeningEnum); 3930 if(shelf_dampening) { 3931 Input* mb_input=element->GetInput(BasalforcingsFloatingiceMeltingRateEnum); _assert_(mb_input); 3932 IssmDouble dt,mb,normal_b; 3933 element->FindParam(&dt,TimesteppingTimeStepEnum); 3934 for(int ig=gauss->begin();ig<gauss->end();ig++){ 3935 gauss->GaussPoint(ig); 3936 element->JacobianDeterminantBase(&Jdet,xyz_list_base,gauss); 3937 element->NodalFunctionsVelocity(vbasis,gauss); 3938 element->NormalBase(&normal[0],xyz_list_base); 3939 if (dim==2) normal_b=normal[1]; 3940 else if (dim==3) normal_b=sqrt(normal[0]*normal[0]+normal[1]*normal[1]); 3941 mb_input->GetInputValue(&mb, gauss); 3942 for(i=0;i<vnumnodes;i++){ 3943 pe->values[i*dim+1] += dt*rho_water*gravity*mb*gauss->weight*Jdet*vbasis[i]*normal_b; 3944 } 3945 } 3946 } 3947 3948 /*Clean up and return*/ 3949 delete gauss; 3950 xDelete<int>(cs_list); 3951 xDelete<IssmDouble>(vbasis); 3952 xDelete<IssmDouble>(xyz_list_base); 3953 return pe; 3954 }/*}}}*/ 3955 ElementVector* StressbalanceAnalysis::CreatePVectorFSViscousLA(Element* element){/*{{{*/ 3956 3957 int i,dim; 3958 IssmDouble Jdet,pressure; 3959 IssmDouble bed_normal[3]; 3960 IssmDouble *xyz_list = NULL; 3961 IssmDouble *xyz_list_base = NULL; 3962 Gauss* gauss = NULL; 3963 3964 /*Get problem dimension*/ 3965 element->FindParam(&dim,DomainDimensionEnum); 3966 3967 /*Fetch number of nodes and dof for this finite element*/ 3968 int numnodes = element->GetNumberOfNodes(); 3969 3970 /*Prepare coordinate system list*/ 3971 int* cs_list = xNew<int>(numnodes); 3972 if(dim==2) for(i=0;i<numnodes;i++) cs_list[i] = XYEnum; 3973 else for(i=0;i<numnodes;i++) cs_list[i] = XYZEnum; 3974 3975 /*Initialize vectors*/ 3976 ElementVector* pe = element->NewElementVector(FSvelocityEnum); 3977 IssmDouble* dbasis = xNew<IssmDouble>(3*numnodes); 3978 3979 /*Retrieve all inputs and parameters*/ 3980 element->GetVerticesCoordinates(&xyz_list); 3981 3982 /*Get pressure and sigmann*/ 3983 Input* pressure_input=element->GetInput(PressureEnum); _assert_(pressure_input); 3984 Input* sigmann_input =element->GetInput(SigmaNNEnum); _assert_(sigmann_input); 3985 3986 gauss=element->NewGauss(5); 3987 for(int ig=gauss->begin();ig<gauss->end();ig++){ 3988 gauss->GaussPoint(ig); 3989 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 3990 3991 pressure_input->GetInputValue(&pressure, gauss); 3992 element->NodalFunctionsDerivativesVelocity(dbasis,xyz_list,gauss); 3993 3994 for(i=0;i<numnodes;i++){ 3995 pe->values[i*dim+0] += pressure*gauss->weight*Jdet*dbasis[0*numnodes+i]; 3996 pe->values[i*dim+1] += pressure*gauss->weight*Jdet*dbasis[1*numnodes+i]; 3997 if(dim==3) pe->values[i*dim+2]+= pressure*gauss->weight*Jdet*dbasis[2*numnodes+i]; 3998 } 3999 } 4000 4001 if(element->IsOnBase() && 0){ 4002 IssmDouble sigmann; 4003 IssmDouble* vbasis = xNew<IssmDouble>(numnodes); 4004 4005 element->GetVerticesCoordinatesBase(&xyz_list_base); 4006 element->NormalBase(&bed_normal[0],xyz_list_base); 4007 4008 delete gauss; 4009 gauss=element->NewGaussBase(5); 4010 for(int ig=gauss->begin();ig<gauss->end();ig++){ 4011 gauss->GaussPoint(ig); 4012 4013 element->JacobianDeterminantBase(&Jdet,xyz_list_base,gauss); 4014 element->NodalFunctionsVelocity(vbasis,gauss); 4015 sigmann_input->GetInputValue(&sigmann, gauss); 4016 4017 for(i=0;i<numnodes;i++){ 4018 pe->values[i*dim+0] += + sigmann*bed_normal[0]*gauss->weight*Jdet*vbasis[i]; 4019 pe->values[i*dim+1] += + sigmann*bed_normal[1]*gauss->weight*Jdet*vbasis[i]; 4020 if(dim==3) pe->values[i*dim+2] += + sigmann*bed_normal[2]*gauss->weight*Jdet*vbasis[i]; 4021 } 4022 } 4023 xDelete<IssmDouble>(xyz_list_base); 4024 xDelete<IssmDouble>(vbasis); 4025 } 4026 4027 /*Transform coordinate system*/ 4028 element->TransformLoadVectorCoord(pe,cs_list); 4029 4030 /*Clean up and return*/ 4031 delete gauss; 4032 xDelete<int>(cs_list); 4033 xDelete<IssmDouble>(xyz_list); 4034 xDelete<IssmDouble>(dbasis); 4035 return pe; 4036 }/*}}}*/ 3766 4037 ElementVector* StressbalanceAnalysis::CreatePVectorFSViscousXTH(Element* element){/*{{{*/ 3767 4038 … … 3936 4207 return pe; 3937 4208 }/*}}}*/ 3938 ElementVector* StressbalanceAnalysis::CreatePVectorFSViscousLATH(Element* element){/*{{{*/ 3939 3940 int i,dim; 3941 IssmDouble Jdet,r,pressure; 3942 IssmDouble bed_normal[3]; 3943 IssmDouble *xyz_list = NULL; 3944 IssmDouble *xyz_list_base = NULL; 3945 Gauss* gauss = NULL; 3946 3947 /*Get problem dimension*/ 3948 element->FindParam(&dim,DomainDimensionEnum); 3949 3950 /*Fetch number of nodes and dof for this finite element*/ 3951 int numnodes = element->GetNumberOfNodes(); 3952 3953 /*Prepare coordinate system list*/ 3954 int* cs_list = xNew<int>(numnodes); 3955 if(dim==2) for(i=0;i<numnodes;i++) cs_list[i] = XYEnum; 3956 else for(i=0;i<numnodes;i++) cs_list[i] = XYZEnum; 3957 3958 /*Initialize vectors*/ 3959 ElementVector* pe = element->NewElementVector(FSvelocityEnum); 3960 IssmDouble* dbasis = xNew<IssmDouble>(3*numnodes); 3961 3962 /*Retrieve all inputs and parameters*/ 3963 element->FindParam(&r,AugmentedLagrangianREnum); 3964 element->GetVerticesCoordinates(&xyz_list); 3965 3966 /*Get pressure and sigmann*/ 3967 Input* pressure_input=element->GetInput(PressureEnum); _assert_(pressure_input); 3968 Input* sigmann_input =element->GetInput(SigmaNNEnum); _assert_(sigmann_input); 3969 3970 gauss=element->NewGauss(5); 3971 for(int ig=gauss->begin();ig<gauss->end();ig++){ 3972 gauss->GaussPoint(ig); 3973 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 3974 3975 pressure_input->GetInputValue(&pressure, gauss); 3976 element->NodalFunctionsDerivativesVelocity(dbasis,xyz_list,gauss); 3977 3978 for(i=0;i<numnodes;i++){ 3979 pe->values[i*dim+0] += pressure*gauss->weight*Jdet*dbasis[0*numnodes+i]; 3980 pe->values[i*dim+1] += pressure*gauss->weight*Jdet*dbasis[1*numnodes+i]; 3981 if(dim==3) pe->values[i*dim+2]+= pressure*gauss->weight*Jdet*dbasis[2*numnodes+i]; 3982 } 3983 } 3984 3985 if(element->IsOnBase()){ 3986 IssmDouble sigmann; 3987 IssmDouble* vbasis = xNew<IssmDouble>(numnodes); 3988 3989 element->GetVerticesCoordinatesBase(&xyz_list_base); 3990 element->NormalBase(&bed_normal[0],xyz_list_base); 3991 3992 delete gauss; 3993 gauss=element->NewGaussBase(5); 3994 for(int ig=gauss->begin();ig<gauss->end();ig++){ 3995 gauss->GaussPoint(ig); 3996 3997 element->JacobianDeterminantBase(&Jdet,xyz_list_base,gauss); 3998 element->NodalFunctionsVelocity(vbasis,gauss); 3999 sigmann_input->GetInputValue(&sigmann, gauss); 4000 4001 for(i=0;i<numnodes;i++){ 4002 pe->values[i*dim+0] += + sigmann*bed_normal[0]*gauss->weight*Jdet*vbasis[i]; 4003 pe->values[i*dim+1] += + sigmann*bed_normal[1]*gauss->weight*Jdet*vbasis[i]; 4004 if(dim==3) pe->values[i*dim+2] += + sigmann*bed_normal[2]*gauss->weight*Jdet*vbasis[i]; 4005 } 4006 } 4007 xDelete<IssmDouble>(xyz_list_base); 4008 xDelete<IssmDouble>(vbasis); 4009 } 4010 4011 /*Transform coordinate system*/ 4012 //element->TransformLoadVectorCoord(pe,cs_list); Do not transform augmentation 4013 4014 /*Clean up and return*/ 4015 delete gauss; 4016 xDelete<int>(cs_list); 4017 xDelete<IssmDouble>(xyz_list); 4018 xDelete<IssmDouble>(dbasis); 4019 return pe; 4020 }/*}}}*/ 4021 ElementVector* StressbalanceAnalysis::CreatePVectorFSShelf(Element* element){/*{{{*/ 4022 4023 int i,dim; 4024 IssmDouble Jdet,water_pressure,bed; 4025 IssmDouble normal[3]; 4026 IssmDouble *xyz_list_base = NULL; 4027 4028 /*Get basal element*/ 4029 if(!element->IsOnBase() || !element->IsFloating()) return NULL; 4030 4031 /*Get problem dimension*/ 4032 element->FindParam(&dim,DomainDimensionEnum); 4033 4034 /*Fetch number of nodes and dof for this finite element*/ 4035 int vnumnodes = element->NumberofNodesVelocity(); 4036 int pnumnodes = element->NumberofNodesPressure(); 4037 4038 /*Prepare coordinate system list*/ 4039 int* cs_list = xNew<int>(vnumnodes+pnumnodes); 4040 if(dim==2) for(i=0;i<vnumnodes;i++) cs_list[i] = XYEnum; 4041 else for(i=0;i<vnumnodes;i++) cs_list[i] = XYZEnum; 4042 for(i=0;i<pnumnodes;i++) cs_list[vnumnodes+i] = PressureEnum; 4043 4044 /*Initialize vectors*/ 4045 ElementVector* pe = element->NewElementVector(FSvelocityEnum); 4046 IssmDouble* vbasis = xNew<IssmDouble>(vnumnodes); 4047 4048 /*Retrieve all inputs and parameters*/ 4049 element->GetVerticesCoordinatesBase(&xyz_list_base); 4050 Input* base_input=element->GetInput(BaseEnum); _assert_(base_input); 4051 IssmDouble rho_water=element->GetMaterialParameter(MaterialsRhoSeawaterEnum); 4052 IssmDouble gravity =element->GetMaterialParameter(ConstantsGEnum); 4053 4054 /* Start looping on the number of gaussian points: */ 4055 Gauss* gauss=element->NewGaussBase(5); 4056 for(int ig=gauss->begin();ig<gauss->end();ig++){ 4057 gauss->GaussPoint(ig); 4058 4059 element->JacobianDeterminantBase(&Jdet,xyz_list_base,gauss); 4060 element->NodalFunctionsVelocity(vbasis,gauss); 4061 4062 element->NormalBase(&normal[0],xyz_list_base); 4063 _assert_(normal[dim-1]<0.); 4064 base_input->GetInputValue(&bed, gauss); 4065 water_pressure=gravity*rho_water*bed; 4066 4067 for(i=0;i<vnumnodes;i++){ 4068 pe->values[i*dim+0] += water_pressure*gauss->weight*Jdet*vbasis[i]*normal[0]; 4069 pe->values[i*dim+1] += water_pressure*gauss->weight*Jdet*vbasis[i]*normal[1]; 4070 if(dim==3){ 4071 pe->values[i*dim+2]+=water_pressure*gauss->weight*Jdet*vbasis[i]*normal[2]; 4072 } 4073 } 4074 } 4075 4076 /*Transform coordinate system*/ 4077 element->TransformLoadVectorCoord(pe,cs_list); 4078 4079 /* shelf dampening*/ 4080 int shelf_dampening; 4081 element->FindParam(&shelf_dampening,StressbalanceShelfDampeningEnum); 4082 if(shelf_dampening) { 4083 Input* mb_input=element->GetInput(BasalforcingsFloatingiceMeltingRateEnum); _assert_(mb_input); 4084 IssmDouble dt,mb,normal_b; 4085 element->FindParam(&dt,TimesteppingTimeStepEnum); 4086 for(int ig=gauss->begin();ig<gauss->end();ig++){ 4087 gauss->GaussPoint(ig); 4088 element->JacobianDeterminantBase(&Jdet,xyz_list_base,gauss); 4089 element->NodalFunctionsVelocity(vbasis,gauss); 4090 element->NormalBase(&normal[0],xyz_list_base); 4091 if (dim==2) normal_b=normal[1]; 4092 else if (dim==3) normal_b=sqrt(normal[0]*normal[0]+normal[1]*normal[1]); 4093 mb_input->GetInputValue(&mb, gauss); 4094 for(i=0;i<vnumnodes;i++){ 4095 pe->values[i*dim+1] += dt*rho_water*gravity*mb*gauss->weight*Jdet*vbasis[i]*normal_b; 4096 } 4097 } 4098 } 4099 4100 /*Clean up and return*/ 4101 delete gauss; 4102 xDelete<int>(cs_list); 4103 xDelete<IssmDouble>(vbasis); 4104 xDelete<IssmDouble>(xyz_list_base); 4105 return pe; 4106 }/*}}}*/ 4107 ElementVector* StressbalanceAnalysis::CreatePVectorFSFront(Element* element){/*{{{*/ 4108 4109 /*If no front, return NULL*/ 4110 if(!element->IsIcefront()) return NULL; 4111 4112 /*Intermediaries*/ 4113 int i,dim; 4114 IssmDouble Jdet,pressure,surface,z; 4115 IssmDouble normal[3]; 4116 IssmDouble *xyz_list = NULL; 4117 IssmDouble *xyz_list_front = NULL; 4118 Gauss *gauss = NULL; 4119 4120 /*Make sure current element is floating*/ 4121 if(!element->IsFloating()) return NULL; 4122 4123 /*Get problem dimension*/ 4124 element->FindParam(&dim,DomainDimensionEnum); 4125 4126 /*Fetch number of nodes and dof for this finite element*/ 4127 int vnumnodes = element->NumberofNodesVelocity(); 4128 int pnumnodes = element->NumberofNodesPressure(); 4129 int numvertices = element->GetNumberOfVertices(); 4130 4131 /*Prepare coordinate system list*/ 4132 int* cs_list = xNew<int>(vnumnodes+pnumnodes); 4133 if(dim==2) for(i=0;i<vnumnodes;i++) cs_list[i] = XYEnum; 4134 else for(i=0;i<vnumnodes;i++) cs_list[i] = XYZEnum; 4135 for(i=0;i<pnumnodes;i++) cs_list[vnumnodes+i] = PressureEnum; 4136 4137 /*Initialize vectors*/ 4138 ElementVector* pe = element->NewElementVector(FSvelocityEnum); 4139 IssmDouble* vbasis = xNew<IssmDouble>(vnumnodes); 4140 4141 /*Retrieve all inputs and parameters*/ 4142 element->GetVerticesCoordinates(&xyz_list); 4143 element->ZeroLevelsetCoordinates(&xyz_list_front,xyz_list,MaskIceLevelsetEnum); 4144 element->NormalSection(&normal[0],xyz_list_front); 4145 Input* surface_input = element->GetInput(SurfaceEnum); _assert_(surface_input); 4146 IssmDouble rho_water = element->GetMaterialParameter(MaterialsRhoSeawaterEnum); 4147 IssmDouble gravity = element->GetMaterialParameter(ConstantsGEnum); 4148 4149 /*Initialize gauss points*/ 4150 IssmDouble zmax=xyz_list[0*3+(dim-1)]; for(int i=1;i<numvertices;i++) if(xyz_list[i*3+(dim-1)]>zmax) zmax=xyz_list[i*3+(dim-1)]; 4151 IssmDouble zmin=xyz_list[0*3+(dim-1)]; for(int i=1;i<numvertices;i++) if(xyz_list[i*3+(dim-1)]<zmin) zmin=xyz_list[i*3+(dim-1)]; 4152 if(zmax>0. && zmin<0.) gauss=element->NewGauss(xyz_list,xyz_list_front,3,30);//refined in vertical because of the sea level discontinuity 4153 else gauss=element->NewGauss(xyz_list,xyz_list_front,3,3); 4154 4155 /* Start looping on the number of gaussian points: */ 4156 for(int ig=gauss->begin();ig<gauss->end();ig++){ 4157 gauss->GaussPoint(ig); 4158 4159 element->JacobianDeterminantSurface(&Jdet,xyz_list_front,gauss); 4160 element->NodalFunctionsVelocity(vbasis,gauss); 4161 surface_input->GetInputValue(&surface,gauss); 4162 if(dim==3) z=element->GetZcoord(xyz_list,gauss); 4163 else z=element->GetYcoord(xyz_list,gauss); 4164 pressure = rho_water*gravity*min(0.,z);//0 if the gaussian point is above water level 4165 4166 for (int i=0;i<vnumnodes;i++){ 4167 pe->values[dim*i+0]+= pressure*Jdet*gauss->weight*normal[0]*vbasis[i]; 4168 pe->values[dim*i+1]+= pressure*Jdet*gauss->weight*normal[1]*vbasis[i]; 4169 if(dim==3) pe->values[dim*i+2]+= pressure*Jdet*gauss->weight*normal[2]*vbasis[i]; 4170 } 4171 } 4172 4173 /*Transform coordinate system*/ 4174 element->TransformLoadVectorCoord(pe,cs_list); 4175 4176 /*Clean up and return*/ 4177 delete gauss; 4178 xDelete<int>(cs_list); 4179 xDelete<IssmDouble>(vbasis); 4180 xDelete<IssmDouble>(xyz_list); 4181 xDelete<IssmDouble>(xyz_list_front); 4182 return pe; 4183 }/*}}}*/ 4184 void StressbalanceAnalysis::GetBFS(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 4209 void StressbalanceAnalysis::GetBFS(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 4185 4210 /*Compute B matrix. B=[Bv1 Bv2 ... Bp1 Bp2 ...] where Bvi is of size 3*NDOF3. 4186 4211 * For node i, Bvi can be expressed in the actual coordinate system … … 4294 4319 xDelete<IssmDouble>(pbasis); 4295 4320 }/*}}}*/ 4296 void StressbalanceAnalysis::GetBFSprime(IssmDouble* Bprime,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 4321 void StressbalanceAnalysis::GetBFSFriction(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 4322 /* Compute L matrix. L=[L1 L2 L3] where Li is square and of size numdof. 4323 * For node i, Li can be expressed in the actual coordinate system 4324 * by in 3d 4325 * Li=[ h 0 0 0 ] 4326 * [ 0 h 0 0 ] 4327 * in 2d: 4328 * Li=[ h 0 0 ] 4329 * where h is the interpolation function for node i. 4330 */ 4331 4332 /*Fetch number of nodes for this finite element*/ 4333 int pnumnodes = element->NumberofNodesPressure(); 4334 int vnumnodes = element->NumberofNodesVelocity(); 4335 int pnumdof = pnumnodes; 4336 int vnumdof = vnumnodes*dim; 4337 4338 /*Get nodal functions derivatives*/ 4339 IssmDouble* vbasis=xNew<IssmDouble>(vnumnodes); 4340 element->NodalFunctionsVelocity(vbasis,gauss); 4341 4342 /*Build B: */ 4343 if(dim==3){ 4344 for(int i=0;i<vnumnodes;i++){ 4345 B[(vnumdof+pnumdof)*0+3*i+0] = vbasis[i]; 4346 B[(vnumdof+pnumdof)*0+3*i+1] = 0.; 4347 B[(vnumdof+pnumdof)*0+3*i+2] = 0.; 4348 4349 B[(vnumdof+pnumdof)*1+3*i+0] = 0.; 4350 B[(vnumdof+pnumdof)*1+3*i+1] = vbasis[i]; 4351 B[(vnumdof+pnumdof)*1+3*i+2] = 0.; 4352 4353 B[(vnumdof+pnumdof)*2+3*i+0] = 0.; 4354 B[(vnumdof+pnumdof)*2+3*i+1] = 0.; 4355 B[(vnumdof+pnumdof)*2+3*i+2] = vbasis[i]; 4356 } 4357 for(int i=0;i<pnumnodes;i++){ 4358 B[(vnumdof+pnumdof)*0+i+vnumdof+0] = 0.; 4359 B[(vnumdof+pnumdof)*1+i+vnumdof+0] = 0.; 4360 B[(vnumdof+pnumdof)*2+i+vnumdof+0] = 0.; 4361 } 4362 } 4363 else{ 4364 for(int i=0;i<vnumnodes;i++){ 4365 B[(vnumdof+pnumdof)*0+2*i+0] = vbasis[i]; 4366 B[(vnumdof+pnumdof)*0+2*i+1] = 0.; 4367 4368 B[(vnumdof+pnumdof)*1+2*i+0] = 0.; 4369 B[(vnumdof+pnumdof)*1+2*i+1] = vbasis[i]; 4370 } 4371 4372 for(int i=0;i<pnumnodes;i++){ 4373 B[(vnumdof+pnumdof)*0+i+vnumdof+0] = 0.; 4374 B[(vnumdof+pnumdof)*1+i+vnumdof+0] = 0.; 4375 } 4376 } 4377 4378 /*Clean-up*/ 4379 xDelete<IssmDouble>(vbasis); 4380 }/*}}}*/ 4381 void StressbalanceAnalysis::GetBFSprime(IssmDouble* Bprime,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 4297 4382 /* Compute B' matrix. B'=[B1' B2' B3' B4' B5' B6' Bb'] where Bi' is of size 3*NDOF2. 4298 4383 * For node i, Bi' can be expressed in the actual coordinate system … … 4407 4492 xDelete<IssmDouble>(pbasis); 4408 4493 }/*}}}*/ 4409 void StressbalanceAnalysis::GetBFSvel(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 4494 void StressbalanceAnalysis::GetBFSprimeUzawa(IssmDouble* Bprime,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 4495 /* Compute B' matrix. B'=[B1' B2' B3' B4' B5' B6'] where Bi' is of size 3*NDOF2. 4496 * For node i, Bi' can be expressed in the actual coordinate system 4497 * by: 4498 * Bvi' = [ dphi/dx dphi/dy ] 4499 * 4500 * In 3d 4501 * Bvi=[ dh/dx dh/dy dh/dz ] 4502 * where phi is the finiteelement function for node i. 4503 */ 4504 4505 /*Fetch number of nodes for this finite element*/ 4506 int vnumnodes = element->NumberofNodesVelocity(); 4507 4508 /*Get nodal functions derivatives*/ 4509 IssmDouble* vdbasis=xNew<IssmDouble>(dim*vnumnodes); 4510 element->NodalFunctionsDerivativesVelocity(vdbasis,xyz_list,gauss); 4511 4512 /*Build B_prime: */ 4513 if(dim==2){ 4514 for(int i=0;i<vnumnodes;i++){ 4515 Bprime[dim*i+0] = vdbasis[0*vnumnodes+i]; 4516 Bprime[dim*i+1] = vdbasis[1*vnumnodes+i]; 4517 } 4518 } 4519 else{ 4520 for(int i=0;i<vnumnodes;i++){ 4521 Bprime[dim*i+0] = vdbasis[0*vnumnodes+i]; 4522 Bprime[dim*i+1] = vdbasis[1*vnumnodes+i]; 4523 Bprime[dim*i+2] = vdbasis[2*vnumnodes+i]; 4524 } 4525 } 4526 4527 /*Clean up*/ 4528 xDelete<IssmDouble>(vdbasis); 4529 }/*}}}*/ 4530 void StressbalanceAnalysis::GetBFSprimevel(IssmDouble* Bprime,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 4531 /* Compute B' matrix. B'=[B1' B2' B3' B4' B5' B6' Bb'] where Bi' is of size 3*NDOF2. 4532 * For node i, Bi' can be expressed in the actual coordinate system 4533 * by: 4534 * Bvi' = [ dphi/dx 0 ] 4535 * [ 0 dphi/dy ] 4536 * [ dphi/dy dphi/dx ] 4537 * 4538 * In 3d 4539 * Bvi=[ dh/dx 0 0 ] 4540 * [ 0 dh/dy 0 ] 4541 * [ 0 0 dh/dz ] 4542 * [ dh/dy dh/dx 0 ] 4543 * [ dh/dz 0 dh/dx ] 4544 * [ 0 dh/dz dh/dy ] 4545 * where phi is the finiteelement function for node i. 4546 * In 3d: 4547 */ 4548 4549 /*Fetch number of nodes for this finite element*/ 4550 int vnumnodes = element->NumberofNodesVelocity(); 4551 4552 /*Get nodal functions derivatives*/ 4553 IssmDouble* vdbasis=xNew<IssmDouble>(dim*vnumnodes); 4554 element->NodalFunctionsDerivativesVelocity(vdbasis,xyz_list,gauss); 4555 4556 /*Build B_prime: */ 4557 if(dim==2){ 4558 for(int i=0;i<vnumnodes;i++){ 4559 Bprime[(dim*vnumnodes)*0+dim*i+0] = vdbasis[0*vnumnodes+i]; 4560 Bprime[(dim*vnumnodes)*0+dim*i+1] = 0.; 4561 Bprime[(dim*vnumnodes)*1+dim*i+0] = 0.; 4562 Bprime[(dim*vnumnodes)*1+dim*i+1] = vdbasis[1*vnumnodes+i]; 4563 Bprime[(dim*vnumnodes)*2+dim*i+0] = vdbasis[1*vnumnodes+i]; 4564 Bprime[(dim*vnumnodes)*2+dim*i+1] = vdbasis[0*vnumnodes+i]; 4565 } 4566 } 4567 else{ 4568 for(int i=0;i<vnumnodes;i++){ 4569 Bprime[(dim*vnumnodes)*0+dim*i+0] = vdbasis[0*vnumnodes+i]; 4570 Bprime[(dim*vnumnodes)*0+dim*i+1] = 0.; 4571 Bprime[(dim*vnumnodes)*0+dim*i+2] = 0.; 4572 Bprime[(dim*vnumnodes)*1+dim*i+0] = 0.; 4573 Bprime[(dim*vnumnodes)*1+dim*i+1] = vdbasis[1*vnumnodes+i]; 4574 Bprime[(dim*vnumnodes)*1+dim*i+2] = 0.; 4575 Bprime[(dim*vnumnodes)*2+dim*i+0] = 0.; 4576 Bprime[(dim*vnumnodes)*2+dim*i+1] = 0.; 4577 Bprime[(dim*vnumnodes)*2+dim*i+2] = vdbasis[2*vnumnodes+i]; 4578 Bprime[(dim*vnumnodes)*3+dim*i+0] = vdbasis[1*vnumnodes+i]; 4579 Bprime[(dim*vnumnodes)*3+dim*i+1] = vdbasis[0*vnumnodes+i]; 4580 Bprime[(dim*vnumnodes)*3+dim*i+2] = 0.; 4581 Bprime[(dim*vnumnodes)*4+dim*i+0] = vdbasis[2*vnumnodes+i]; 4582 Bprime[(dim*vnumnodes)*4+dim*i+1] = 0.; 4583 Bprime[(dim*vnumnodes)*4+dim*i+2] = vdbasis[0*vnumnodes+i]; 4584 Bprime[(dim*vnumnodes)*5+dim*i+0] = 0.; 4585 Bprime[(dim*vnumnodes)*5+dim*i+1] = vdbasis[2*vnumnodes+i]; 4586 Bprime[(dim*vnumnodes)*5+dim*i+2] = vdbasis[1*vnumnodes+i]; 4587 } 4588 } 4589 4590 /*Clean up*/ 4591 xDelete<IssmDouble>(vdbasis); 4592 }/*}}}*/ 4593 void StressbalanceAnalysis::GetBFSUzawa(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 4594 /*Compute B matrix. B=[Bp1 Bp2 ...] where Bpi=phi_pi. 4595 */ 4596 4597 /*Fetch number of nodes for this finite element*/ 4598 int pnumnodes; 4599 if(dim==2) pnumnodes=3; 4600 else pnumnodes=6; 4601 //int pnumnodes = element->NumberofNodes(P1Enum); 4602 4603 /*Get nodal functions derivatives*/ 4604 IssmDouble* basis =xNew<IssmDouble>(pnumnodes); 4605 element->NodalFunctionsP1(basis,gauss); 4606 4607 /*Build B: */ 4608 for(int i=0;i<pnumnodes;i++){ 4609 B[i] = basis[i]; 4610 } 4611 4612 /*Clean up*/ 4613 xDelete<IssmDouble>(basis); 4614 }/*}}}*/ 4615 void StressbalanceAnalysis::GetBFSvel(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 4410 4616 /*Compute B matrix. B=[Bv1 Bv2 ... Bp1 Bp2 ...] where Bvi is of size 3*NDOF3. 4411 4617 * For node i, Bvi can be expressed in the actual coordinate system … … 4471 4677 xDelete<IssmDouble>(vdbasis); 4472 4678 }/*}}}*/ 4473 void StressbalanceAnalysis::GetBFSprimevel(IssmDouble* Bprime,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 4474 /* Compute B' matrix. B'=[B1' B2' B3' B4' B5' B6' Bb'] where Bi' is of size 3*NDOF2. 4475 * For node i, Bi' can be expressed in the actual coordinate system 4476 * by: 4477 * Bvi' = [ dphi/dx 0 ] 4478 * [ 0 dphi/dy ] 4479 * [ dphi/dy dphi/dx ] 4480 * 4481 * In 3d 4482 * Bvi=[ dh/dx 0 0 ] 4483 * [ 0 dh/dy 0 ] 4484 * [ 0 0 dh/dz ] 4485 * [ dh/dy dh/dx 0 ] 4486 * [ dh/dz 0 dh/dx ] 4487 * [ 0 dh/dz dh/dy ] 4488 * where phi is the finiteelement function for node i. 4489 * In 3d: 4490 */ 4491 4492 /*Fetch number of nodes for this finite element*/ 4493 int vnumnodes = element->NumberofNodesVelocity(); 4494 4495 /*Get nodal functions derivatives*/ 4496 IssmDouble* vdbasis=xNew<IssmDouble>(dim*vnumnodes); 4497 element->NodalFunctionsDerivativesVelocity(vdbasis,xyz_list,gauss); 4498 4499 /*Build B_prime: */ 4500 if(dim==2){ 4501 for(int i=0;i<vnumnodes;i++){ 4502 Bprime[(dim*vnumnodes)*0+dim*i+0] = vdbasis[0*vnumnodes+i]; 4503 Bprime[(dim*vnumnodes)*0+dim*i+1] = 0.; 4504 Bprime[(dim*vnumnodes)*1+dim*i+0] = 0.; 4505 Bprime[(dim*vnumnodes)*1+dim*i+1] = vdbasis[1*vnumnodes+i]; 4506 Bprime[(dim*vnumnodes)*2+dim*i+0] = vdbasis[1*vnumnodes+i]; 4507 Bprime[(dim*vnumnodes)*2+dim*i+1] = vdbasis[0*vnumnodes+i]; 4508 } 4509 } 4510 else{ 4511 for(int i=0;i<vnumnodes;i++){ 4512 Bprime[(dim*vnumnodes)*0+dim*i+0] = vdbasis[0*vnumnodes+i]; 4513 Bprime[(dim*vnumnodes)*0+dim*i+1] = 0.; 4514 Bprime[(dim*vnumnodes)*0+dim*i+2] = 0.; 4515 Bprime[(dim*vnumnodes)*1+dim*i+0] = 0.; 4516 Bprime[(dim*vnumnodes)*1+dim*i+1] = vdbasis[1*vnumnodes+i]; 4517 Bprime[(dim*vnumnodes)*1+dim*i+2] = 0.; 4518 Bprime[(dim*vnumnodes)*2+dim*i+0] = 0.; 4519 Bprime[(dim*vnumnodes)*2+dim*i+1] = 0.; 4520 Bprime[(dim*vnumnodes)*2+dim*i+2] = vdbasis[2*vnumnodes+i]; 4521 Bprime[(dim*vnumnodes)*3+dim*i+0] = vdbasis[1*vnumnodes+i]; 4522 Bprime[(dim*vnumnodes)*3+dim*i+1] = vdbasis[0*vnumnodes+i]; 4523 Bprime[(dim*vnumnodes)*3+dim*i+2] = 0.; 4524 Bprime[(dim*vnumnodes)*4+dim*i+0] = vdbasis[2*vnumnodes+i]; 4525 Bprime[(dim*vnumnodes)*4+dim*i+1] = 0.; 4526 Bprime[(dim*vnumnodes)*4+dim*i+2] = vdbasis[0*vnumnodes+i]; 4527 Bprime[(dim*vnumnodes)*5+dim*i+0] = 0.; 4528 Bprime[(dim*vnumnodes)*5+dim*i+1] = vdbasis[2*vnumnodes+i]; 4529 Bprime[(dim*vnumnodes)*5+dim*i+2] = vdbasis[1*vnumnodes+i]; 4530 } 4531 } 4532 4533 /*Clean up*/ 4534 xDelete<IssmDouble>(vdbasis); 4535 }/*}}}*/ 4536 void StressbalanceAnalysis::GetBFSUzawa(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 4537 /*Compute B matrix. B=[Bp1 Bp2 ...] where Bpi=phi_pi. 4538 */ 4539 4540 /*Fetch number of nodes for this finite element*/ 4541 int pnumnodes; 4542 if(dim==2) pnumnodes=3; 4543 else pnumnodes=6; 4544 //int pnumnodes = element->NumberofNodes(P1Enum); 4545 4546 /*Get nodal functions derivatives*/ 4547 IssmDouble* basis =xNew<IssmDouble>(pnumnodes); 4548 element->NodalFunctionsP1(basis,gauss); 4549 4550 /*Build B: */ 4551 for(int i=0;i<pnumnodes;i++){ 4552 B[i] = basis[i]; 4553 } 4554 4555 /*Clean up*/ 4556 xDelete<IssmDouble>(basis); 4557 }/*}}}*/ 4558 void StressbalanceAnalysis::GetBFSprimeUzawa(IssmDouble* Bprime,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 4559 /* Compute B' matrix. B'=[B1' B2' B3' B4' B5' B6'] where Bi' is of size 3*NDOF2. 4560 * For node i, Bi' can be expressed in the actual coordinate system 4561 * by: 4562 * Bvi' = [ dphi/dx dphi/dy ] 4563 * 4564 * In 3d 4565 * Bvi=[ dh/dx dh/dy dh/dz ] 4566 * where phi is the finiteelement function for node i. 4567 */ 4568 4569 /*Fetch number of nodes for this finite element*/ 4570 int vnumnodes = element->NumberofNodesVelocity(); 4571 4572 /*Get nodal functions derivatives*/ 4573 IssmDouble* vdbasis=xNew<IssmDouble>(dim*vnumnodes); 4574 element->NodalFunctionsDerivativesVelocity(vdbasis,xyz_list,gauss); 4575 4576 /*Build B_prime: */ 4577 if(dim==2){ 4578 for(int i=0;i<vnumnodes;i++){ 4579 Bprime[dim*i+0] = vdbasis[0*vnumnodes+i]; 4580 Bprime[dim*i+1] = vdbasis[1*vnumnodes+i]; 4581 } 4582 } 4583 else{ 4584 for(int i=0;i<vnumnodes;i++){ 4585 Bprime[dim*i+0] = vdbasis[0*vnumnodes+i]; 4586 Bprime[dim*i+1] = vdbasis[1*vnumnodes+i]; 4587 Bprime[dim*i+2] = vdbasis[2*vnumnodes+i]; 4588 } 4589 } 4590 4591 /*Clean up*/ 4592 xDelete<IssmDouble>(vdbasis); 4593 }/*}}}*/ 4594 void StressbalanceAnalysis::GetBFSFriction(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 4595 /* Compute L matrix. L=[L1 L2 L3] where Li is square and of size numdof. 4596 * For node i, Li can be expressed in the actual coordinate system 4597 * by in 3d 4598 * Li=[ h 0 0 0 ] 4599 * [ 0 h 0 0 ] 4600 * in 2d: 4601 * Li=[ h 0 0 ] 4602 * where h is the interpolation function for node i. 4603 */ 4604 4605 /*Fetch number of nodes for this finite element*/ 4606 int pnumnodes = element->NumberofNodesPressure(); 4607 int vnumnodes = element->NumberofNodesVelocity(); 4608 int pnumdof = pnumnodes; 4609 int vnumdof = vnumnodes*dim; 4610 4611 /*Get nodal functions derivatives*/ 4612 IssmDouble* vbasis=xNew<IssmDouble>(vnumnodes); 4613 element->NodalFunctionsVelocity(vbasis,gauss); 4614 4615 /*Build B: */ 4616 if(dim==3){ 4617 for(int i=0;i<vnumnodes;i++){ 4618 B[(vnumdof+pnumdof)*0+3*i+0] = vbasis[i]; 4619 B[(vnumdof+pnumdof)*0+3*i+1] = 0.; 4620 B[(vnumdof+pnumdof)*0+3*i+2] = 0.; 4621 4622 B[(vnumdof+pnumdof)*1+3*i+0] = 0.; 4623 B[(vnumdof+pnumdof)*1+3*i+1] = vbasis[i]; 4624 B[(vnumdof+pnumdof)*1+3*i+2] = 0.; 4625 4626 B[(vnumdof+pnumdof)*2+3*i+0] = 0.; 4627 B[(vnumdof+pnumdof)*2+3*i+1] = 0.; 4628 B[(vnumdof+pnumdof)*2+3*i+2] = vbasis[i]; 4629 } 4630 for(int i=0;i<pnumnodes;i++){ 4631 B[(vnumdof+pnumdof)*0+i+vnumdof+0] = 0.; 4632 B[(vnumdof+pnumdof)*1+i+vnumdof+0] = 0.; 4633 B[(vnumdof+pnumdof)*2+i+vnumdof+0] = 0.; 4634 } 4635 } 4636 else{ 4637 for(int i=0;i<vnumnodes;i++){ 4638 B[(vnumdof+pnumdof)*0+2*i+0] = vbasis[i]; 4639 B[(vnumdof+pnumdof)*0+2*i+1] = 0.; 4640 4641 B[(vnumdof+pnumdof)*1+2*i+0] = 0.; 4642 B[(vnumdof+pnumdof)*1+2*i+1] = vbasis[i]; 4643 } 4644 4645 for(int i=0;i<pnumnodes;i++){ 4646 B[(vnumdof+pnumdof)*0+i+vnumdof+0] = 0.; 4647 B[(vnumdof+pnumdof)*1+i+vnumdof+0] = 0.; 4648 } 4649 } 4650 4651 /*Clean-up*/ 4652 xDelete<IssmDouble>(vbasis); 4653 }/*}}}*/ 4654 void StressbalanceAnalysis::GetCFS(IssmDouble* C,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 4679 void StressbalanceAnalysis::GetCFS(IssmDouble* C,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 4655 4680 /*Compute C matrix. C=[Cp1 Cp2 ...] where: 4656 4681 * Cpi=[phi phi]. … … 4673 4698 xDelete<IssmDouble>(basis); 4674 4699 }/*}}}*/ 4675 void StressbalanceAnalysis::GetCFSprime(IssmDouble* Cprime,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/4700 void StressbalanceAnalysis::GetCFSprime(IssmDouble* Cprime,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 4676 4701 /* Compute C' matrix. C'=[C1' C2' ...] 4677 4702 * Ci' = [ phi 0 ] … … 4721 4746 xDelete<IssmDouble>(vbasis); 4722 4747 }/*}}}*/ 4723 void StressbalanceAnalysis::GetSolutionFromInputsFS(Vector<IssmDouble>* solution,Element* element){/*{{{*/4748 void StressbalanceAnalysis::GetSolutionFromInputsFS(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 4724 4749 4725 4750 int* vdoflist=NULL; … … 4784 4809 xDelete<IssmDouble>(vvalues); 4785 4810 }/*}}}*/ 4786 void StressbalanceAnalysis::InitializeXTH(Elements* elements,Parameters* parameters){/*{{{*/4811 void StressbalanceAnalysis::InitializeXTH(Elements* elements,Parameters* parameters){/*{{{*/ 4787 4812 4788 4813 /*Intermediaries*/ … … 4796 4821 4797 4822 for(int i=0;i<elements->Size();i++){ 4798 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));4823 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 4799 4824 4800 4825 /*Get inputs and parameters*/ … … 4863 4888 4864 4889 }/*}}}*/ 4865 void StressbalanceAnalysis::InputUpdateFromSolutionFS(IssmDouble* solution,Element* element){/*{{{*/4890 void StressbalanceAnalysis::InputUpdateFromSolutionFS(IssmDouble* solution,Element* element){/*{{{*/ 4866 4891 4867 4892 bool results_on_nodes; … … 4953 4978 xDelete<int>(cs_list); 4954 4979 }/*}}}*/ 4955 void StressbalanceAnalysis::InputUpdateFromSolutionFSXTH_d(Elements* elements,Parameters* parameters){/*{{{*/4980 void StressbalanceAnalysis::InputUpdateFromSolutionFSXTH_d(Elements* elements,Parameters* parameters){/*{{{*/ 4956 4981 4957 4982 /*Intermediaries*/ … … 4970 4995 4971 4996 for(int i=0;i<elements->Size();i++){ 4972 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));4997 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 4973 4998 4974 4999 /*Get inputs and parameters*/ … … 5166 5191 } 5167 5192 }/*}}}*/ 5168 void StressbalanceAnalysis::InputUpdateFromSolutionFSXTH_tau(Elements* elements,Parameters* parameters){/*{{{*/5193 void StressbalanceAnalysis::InputUpdateFromSolutionFSXTH_tau(Elements* elements,Parameters* parameters){/*{{{*/ 5169 5194 5170 5195 /*Intermediaries*/ … … 5183 5208 5184 5209 for(int i=0;i<elements->Size();i++){ 5185 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));5210 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 5186 5211 5187 5212 /*Get inputs and parameters*/ … … 5302 5327 5303 5328 /*Coupling (Tiling)*/ 5304 ElementMatrix* StressbalanceAnalysis::CreateKMatrixSSA3d(Element* element){/*{{{*/5305 5306 /*compute all stiffness matrices for this element*/5307 ElementMatrix* Ke1=CreateKMatrixSSA3dViscous(element);5308 ElementMatrix* Ke2=CreateKMatrixSSA3dFriction(element);5309 ElementMatrix* Ke =new ElementMatrix(Ke1,Ke2);5310 5311 /*clean-up and return*/5312 delete Ke1;5313 delete Ke2;5314 return Ke;5315 }/*}}}*/5316 ElementMatrix* StressbalanceAnalysis::CreateKMatrixSSA3dFriction(Element* element){/*{{{*/5317 5318 /*Initialize Element matrix and return if necessary*/5319 if(element->IsFloating() || !element->IsOnBase()) return NULL;5320 5321 /*Build a tria element using the 3 nodes of the base of the penta. Then use5322 * the tria functionality to build a friction stiffness matrix on these 35323 * nodes: */5324 Element* basalelement = element->SpawnBasalElement();5325 ElementMatrix* Ke=CreateKMatrixSSAFriction(basalelement);5326 basalelement->DeleteMaterials(); delete basalelement;5327 5328 /*clean-up and return*/5329 return Ke;5330 }/*}}}*/5331 ElementMatrix* StressbalanceAnalysis::CreateKMatrixSSA3dViscous(Element* element){/*{{{*/5332 5333 /*Constants*/5334 const int numdof2d=2*3;5335 5336 /*Intermediaries */5337 int i,j,approximation;5338 int dim=3;5339 IssmDouble Jdet,viscosity,oldviscosity,newviscosity,viscosity_overshoot;5340 IssmDouble epsilon[5],oldepsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/5341 IssmDouble epsilons[6]; //6 for FS5342 IssmDouble B[3][numdof2d];5343 IssmDouble Bprime[3][numdof2d];5344 IssmDouble D[3][3]= {0.0}; // material matrix, simple scalar matrix.5345 IssmDouble D_scalar;5346 IssmDouble Ke_gg[numdof2d][numdof2d]={0.0};5347 IssmDouble *xyz_list = NULL;5348 5349 /*Find penta on bed as this is a SSA elements: */5350 Element* pentabase=element->GetBasalElement();5351 Element* basaltria=pentabase->SpawnBasalElement();5352 5353 /*Initialize Element matrix*/5354 ElementMatrix* Ke=basaltria->NewElementMatrix(SSAApproximationEnum);5355 element->GetInputValue(&approximation,ApproximationEnum);5356 5357 /*Retrieve all inputs and parameters*/5358 element->GetVerticesCoordinates(&xyz_list);5359 element->FindParam(&viscosity_overshoot,StressbalanceViscosityOvershootEnum);5360 Input* vx_input =element->GetInput(VxEnum); _assert_(vx_input);5361 Input* vy_input =element->GetInput(VyEnum); _assert_(vy_input);5362 Input* vxold_input=element->GetInput(VxPicardEnum); _assert_(vxold_input);5363 Input* vyold_input=element->GetInput(VyPicardEnum); _assert_(vyold_input);5364 Input* vz_input =element->GetInput(VzEnum); _assert_(vz_input);5365 5366 /* Start looping on the number of gaussian points: */5367 Gauss* gauss=element->NewGauss(5);5368 Gauss* gauss_tria=new GaussTria();5369 for(int ig=gauss->begin();ig<gauss->end();ig++){5370 5371 gauss->GaussPoint(ig);5372 gauss->SynchronizeGaussBase(gauss_tria);5373 5374 element->JacobianDeterminant(&Jdet, xyz_list,gauss);5375 this->GetBSSA(&B[0][0],basaltria,2,xyz_list, gauss_tria);5376 this->GetBSSAprime(&Bprime[0][0],basaltria,2,xyz_list, gauss_tria);5377 5378 if(approximation==SSAHOApproximationEnum){5379 element->ViscosityHO(&viscosity,dim,xyz_list,gauss,vx_input,vy_input);5380 element->ViscosityHO(&oldviscosity,dim,xyz_list,gauss,vxold_input,vyold_input);5381 newviscosity=viscosity+viscosity_overshoot*(viscosity-oldviscosity);5382 }5383 else if (approximation==SSAFSApproximationEnum){5384 element->ViscosityFS(&newviscosity,dim,xyz_list,gauss,vx_input,vy_input,vz_input);5385 }5386 else _error_("approximation " << approximation << " (" << EnumToStringx(approximation) << ") not supported yet");5387 5388 D_scalar=2*newviscosity*gauss->weight*Jdet;5389 for (i=0;i<3;i++) D[i][i]=D_scalar;5390 5391 TripleMultiply( &B[0][0],3,numdof2d,1,5392 &D[0][0],3,3,0,5393 &Bprime[0][0],3,numdof2d,0,5394 &Ke_gg[0][0],1);5395 5396 }5397 for(i=0;i<numdof2d;i++) for(j=0;j<numdof2d;j++) Ke->values[i*numdof2d+j]+=Ke_gg[i][j];5398 5399 /*Transform Coordinate System*/5400 basaltria->TransformStiffnessMatrixCoord(Ke,XYEnum);5401 5402 /*Clean up and return*/5403 xDelete<IssmDouble>(xyz_list);5404 delete basaltria->material;5405 delete basaltria;5406 delete gauss_tria;5407 delete gauss;5408 return Ke;5409 5410 }/*}}}*/5411 ElementMatrix* StressbalanceAnalysis::CreateKMatrixHOFS(Element* element){/*{{{*/5412 5413 /*compute all stiffness matrices for this element*/5414 ElementMatrix* Ke1=CreateKMatrixFS(element);5415 int indices[3]={18,19,20};5416 Ke1->StaticCondensation(3,&indices[0]);5417 int init = element->FiniteElement();5418 element->SetTemporaryElementType(P1Enum); // P1 needed for HO5419 ElementMatrix* Ke2=CreateKMatrixHO(element);5420 element->SetTemporaryElementType(init); // P1 needed for HO5421 ElementMatrix* Ke3=CreateKMatrixCouplingHOFS(element);5422 ElementMatrix* Ke =new ElementMatrix(Ke1,Ke2,Ke3);5423 5424 /*clean-up and return*/5425 delete Ke1;5426 delete Ke2;5427 delete Ke3;5428 return Ke;5429 }/*}}}*/5430 ElementMatrix* StressbalanceAnalysis::CreateKMatrixSSAHO(Element* element){/*{{{*/5431 5432 /*compute all stiffness matrices for this element*/5433 ElementMatrix* Ke1=CreateKMatrixSSA3d(element);5434 ElementMatrix* Ke2=CreateKMatrixHO(element);5435 ElementMatrix* Ke3=CreateKMatrixCouplingSSAHO(element);5436 ElementMatrix* Ke =new ElementMatrix(Ke1,Ke2,Ke3);5437 5438 /*clean-up and return*/5439 delete Ke1;5440 delete Ke2;5441 delete Ke3;5442 return Ke;5443 }/*}}}*/5444 ElementMatrix* StressbalanceAnalysis::CreateKMatrixSSAFS(Element* element){/*{{{*/5445 5446 /*compute all stiffness matrices for this element*/5447 ElementMatrix* Ke1=CreateKMatrixFS(element);5448 int indices[3]={18,19,20};5449 Ke1->StaticCondensation(3,&indices[0]);5450 int init = element->FiniteElement();5451 element->SetTemporaryElementType(P1Enum);5452 ElementMatrix* Ke2=CreateKMatrixSSA3d(element);5453 element->SetTemporaryElementType(init);5454 ElementMatrix* Ke3=CreateKMatrixCouplingSSAFS(element);5455 ElementMatrix* Ke =new ElementMatrix(Ke1,Ke2,Ke3);5456 5457 /*clean-up and return*/5458 delete Ke1;5459 delete Ke2;5460 delete Ke3;5461 return Ke;5462 }/*}}}*/5463 5329 ElementMatrix* StressbalanceAnalysis::CreateKMatrixCouplingHOFS(Element* element){/*{{{*/ 5464 5330 … … 5526 5392 delete Ke2; 5527 5393 return Ke; 5528 }/*}}}*/5529 ElementMatrix* StressbalanceAnalysis::CreateKMatrixCouplingSSAHO(Element* element){/*{{{*/5530 5531 /*compute all stiffness matrices for this element*/5532 ElementMatrix* Ke1=CreateKMatrixCouplingSSAHOViscous(element);5533 ElementMatrix* Ke2=CreateKMatrixCouplingSSAHOFriction(element);5534 ElementMatrix* Ke=new ElementMatrix(Ke1,Ke2);5535 5536 /*clean-up and return*/5537 delete Ke1;5538 delete Ke2;5539 return Ke;5540 }/*}}}*/5541 ElementMatrix* StressbalanceAnalysis::CreateKMatrixCouplingSSAHOFriction(Element* element){/*{{{*/5542 5543 if(element->IsFloating() || !element->IsOnBase()) return NULL;5544 5545 /*Constants*/5546 int numnodes = element->GetNumberOfNodes();5547 int numdof = 2*numnodes;5548 int numdoftotal = 4*numnodes;5549 5550 /*Intermediaries */5551 int i,j;5552 IssmDouble Jdet2d,alpha2;5553 IssmDouble *xyz_list_tria = NULL;5554 IssmDouble* L = xNewZeroInit<IssmDouble>(2*numdof);5555 IssmDouble DL[2][2] = {{ 0,0 },{0,0}}; //for basal drag5556 IssmDouble DL_scalar;5557 IssmDouble* Ke_gg = xNewZeroInit<IssmDouble>(numdof*numdof);5558 Node **node_list = xNew<Node*>(2*numnodes);5559 int* cs_list = xNew<int>(2*numnodes);5560 5561 /*Initialize Element matrix and return if necessary*/5562 ElementMatrix* Ke1=element->NewElementMatrix(SSAApproximationEnum);5563 ElementMatrix* Ke2=element->NewElementMatrix(HOApproximationEnum);5564 ElementMatrix* Ke=new ElementMatrix(Ke1,Ke2);5565 delete Ke1; delete Ke2;5566 5567 /*Prepare node list*/5568 for(i=0;i<numnodes;i++){5569 node_list[i+0*numnodes] = element->GetNode(i);5570 node_list[i+1*numnodes] = element->GetNode(i);5571 cs_list[i+0*numnodes] = XYEnum;5572 cs_list[i+1*numnodes] = XYEnum;5573 }5574 5575 /*retrieve inputs :*/5576 element->GetVerticesCoordinatesBase(&xyz_list_tria);5577 5578 /*build friction object, used later on: */5579 Friction* friction=new Friction(element,2);5580 5581 /* Start looping on the number of gaussian points: */5582 Gauss* gauss=element->NewGaussBase(2);5583 for(int ig=gauss->begin();ig<gauss->end();ig++){5584 5585 gauss->GaussPoint(ig);5586 5587 /*Friction: */5588 friction->GetAlpha2(&alpha2,gauss);5589 element->JacobianDeterminantBase(&Jdet2d, xyz_list_tria,gauss);5590 this->GetBHOFriction(L,element,3,xyz_list_tria,gauss);5591 5592 DL_scalar=alpha2*gauss->weight*Jdet2d;5593 for (i=0;i<2;i++) DL[i][i]=DL_scalar;5594 5595 /* Do the triple producte tL*D*L: */5596 TripleMultiply( L,2,numdof,1,5597 &DL[0][0],2,2,0,5598 L,2,numdof,0,5599 Ke_gg,1);5600 }5601 5602 for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[i*numdoftotal+(numdof+j)]+=Ke_gg[i*numdof+j];5603 for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[(i+numdof)*numdoftotal+j]+=Ke_gg[i*numdof+j];5604 5605 /*Transform Coordinate System*/5606 element->TransformStiffnessMatrixCoord(Ke,node_list,2*numnodes,cs_list);5607 5608 /*Clean up and return*/5609 delete gauss;5610 delete friction;5611 xDelete<int>(cs_list);5612 xDelete<Node*>(node_list);5613 xDelete<IssmDouble>(xyz_list_tria);5614 xDelete<IssmDouble>(Ke_gg);5615 xDelete<IssmDouble>(L);5616 return Ke;5617 }/*}}}*/5618 ElementMatrix* StressbalanceAnalysis::CreateKMatrixCouplingSSAHOViscous(Element* element){/*{{{*/5619 5620 /*Constants*/5621 int numnodes = element->GetNumberOfNodes();5622 int numdofm = 1 *numnodes; //*2/25623 int numdofp = 2 *numnodes;5624 int numdoftotal = 2 *2 *numnodes;//2 dof per nodes and 2 sets of nodes for HO and SSA5625 5626 /*Intermediaries */5627 int i,j;5628 IssmDouble Jdet,viscosity,oldviscosity,newviscosity,viscosity_overshoot; //viscosity5629 IssmDouble *xyz_list = NULL;5630 IssmDouble* B = xNew<IssmDouble>(3*numdofp);5631 IssmDouble* Bprime = xNew<IssmDouble>(3*numdofm);5632 IssmDouble D[3][3]={0.0}; // material matrix, simple scalar matrix.5633 IssmDouble D_scalar;5634 IssmDouble* Ke_gg = xNewZeroInit<IssmDouble>(numdofp*numdofm);5635 Node **node_list = xNew<Node*>(2*numnodes);5636 int* cs_list= xNew<int>(2*numnodes);5637 5638 /*Find penta on bed as HO must be coupled to the dofs on the bed: */5639 Element* pentabase=element->GetBasalElement();5640 Element* basaltria=pentabase->SpawnBasalElement();5641 5642 /*prepare node list*/5643 for(i=0;i<numnodes;i++){5644 node_list[i+0*numnodes] = pentabase->GetNode(i);5645 node_list[i+1*numnodes] = element ->GetNode(i);5646 cs_list[i+0*numnodes] = XYEnum;5647 cs_list[i+1*numnodes] = XYEnum;5648 }5649 5650 /*Initialize Element matrix*/5651 ElementMatrix* Ke1= pentabase->NewElementMatrix(SSAApproximationEnum);5652 ElementMatrix* Ke2= element ->NewElementMatrix(HOApproximationEnum);5653 ElementMatrix* Ke =new ElementMatrix(Ke1,Ke2);5654 delete Ke1; delete Ke2;5655 5656 /* Get node coordinates and dof list: */5657 element->GetVerticesCoordinates(&xyz_list);5658 element->FindParam(&viscosity_overshoot,StressbalanceViscosityOvershootEnum);5659 Input* vx_input =element->GetInput(VxEnum); _assert_(vx_input);5660 Input* vy_input =element->GetInput(VyEnum); _assert_(vy_input);5661 Input* vxold_input=element->GetInput(VxPicardEnum); _assert_(vxold_input);5662 Input* vyold_input=element->GetInput(VyPicardEnum); _assert_(vyold_input);5663 5664 /* Start looping on the number of gaussian points: */5665 Gauss* gauss=element->NewGauss(5);5666 Gauss* gauss_tria=new GaussTria();5667 for(int ig=gauss->begin();ig<gauss->end();ig++){5668 5669 gauss->GaussPoint(ig);5670 gauss->SynchronizeGaussBase(gauss_tria);5671 5672 element->JacobianDeterminant(&Jdet, xyz_list,gauss);5673 this->GetBSSAHO(B, element,xyz_list, gauss);5674 this->GetBSSAprime(Bprime,basaltria,2,xyz_list, gauss_tria);5675 element->ViscosityHO(&viscosity,3,xyz_list,gauss,vx_input,vy_input);5676 element->ViscosityHO(&oldviscosity,3,xyz_list,gauss,vxold_input,vyold_input);5677 5678 newviscosity=viscosity+viscosity_overshoot*(viscosity-oldviscosity);5679 D_scalar=2*newviscosity*gauss->weight*Jdet;5680 for (i=0;i<3;i++) D[i][i]=D_scalar;5681 5682 TripleMultiply( B,3,numdofp,1,5683 &D[0][0],3,3,0,5684 Bprime,3,numdofm,0,5685 Ke_gg,1);5686 }5687 for(i=0;i<numdofp;i++) for(j=0;j<numdofm;j++) Ke->values[(i+2*numdofm)*numdoftotal+j]+=Ke_gg[i*numdofm+j];5688 for(i=0;i<numdofm;i++) for(j=0;j<numdofp;j++) Ke->values[i*numdoftotal+(j+2*numdofm)]+=Ke_gg[j*numdofm+i];5689 5690 /*Transform Coordinate System*/5691 element->TransformStiffnessMatrixCoord(Ke,node_list,2*numnodes,cs_list);5692 5693 /*Clean-up and return*/5694 basaltria->DeleteMaterials(); delete basaltria;5695 5696 delete gauss;5697 delete gauss_tria;5698 xDelete<IssmDouble>(B);5699 xDelete<IssmDouble>(Bprime);5700 xDelete<IssmDouble>(Ke_gg);5701 xDelete<IssmDouble>(xyz_list);5702 xDelete<Node*>(node_list);5703 xDelete<int>(cs_list);5704 return Ke;5705 5706 5394 }/*}}}*/ 5707 5395 ElementMatrix* StressbalanceAnalysis::CreateKMatrixCouplingSSAFS(Element* element){/*{{{*/ … … 5945 5633 5946 5634 }/*}}}*/ 5947 ElementVector* StressbalanceAnalysis::CreatePVectorSSAHO(Element* element){/*{{{*/ 5635 ElementMatrix* StressbalanceAnalysis::CreateKMatrixCouplingSSAHO(Element* element){/*{{{*/ 5636 5637 /*compute all stiffness matrices for this element*/ 5638 ElementMatrix* Ke1=CreateKMatrixCouplingSSAHOViscous(element); 5639 ElementMatrix* Ke2=CreateKMatrixCouplingSSAHOFriction(element); 5640 ElementMatrix* Ke=new ElementMatrix(Ke1,Ke2); 5641 5642 /*clean-up and return*/ 5643 delete Ke1; 5644 delete Ke2; 5645 return Ke; 5646 }/*}}}*/ 5647 ElementMatrix* StressbalanceAnalysis::CreateKMatrixCouplingSSAHOFriction(Element* element){/*{{{*/ 5648 5649 if(element->IsFloating() || !element->IsOnBase()) return NULL; 5650 5651 /*Constants*/ 5652 int numnodes = element->GetNumberOfNodes(); 5653 int numdof = 2*numnodes; 5654 int numdoftotal = 4*numnodes; 5655 5656 /*Intermediaries */ 5657 int i,j; 5658 IssmDouble Jdet2d,alpha2; 5659 IssmDouble *xyz_list_tria = NULL; 5660 IssmDouble* L = xNewZeroInit<IssmDouble>(2*numdof); 5661 IssmDouble DL[2][2] = {{ 0,0 },{0,0}}; //for basal drag 5662 IssmDouble DL_scalar; 5663 IssmDouble* Ke_gg = xNewZeroInit<IssmDouble>(numdof*numdof); 5664 Node **node_list = xNew<Node*>(2*numnodes); 5665 int* cs_list = xNew<int>(2*numnodes); 5666 5667 /*Initialize Element matrix and return if necessary*/ 5668 ElementMatrix* Ke1=element->NewElementMatrix(SSAApproximationEnum); 5669 ElementMatrix* Ke2=element->NewElementMatrix(HOApproximationEnum); 5670 ElementMatrix* Ke=new ElementMatrix(Ke1,Ke2); 5671 delete Ke1; delete Ke2; 5672 5673 /*Prepare node list*/ 5674 for(i=0;i<numnodes;i++){ 5675 node_list[i+0*numnodes] = element->GetNode(i); 5676 node_list[i+1*numnodes] = element->GetNode(i); 5677 cs_list[i+0*numnodes] = XYEnum; 5678 cs_list[i+1*numnodes] = XYEnum; 5679 } 5680 5681 /*retrieve inputs :*/ 5682 element->GetVerticesCoordinatesBase(&xyz_list_tria); 5683 5684 /*build friction object, used later on: */ 5685 Friction* friction=new Friction(element,2); 5686 5687 /* Start looping on the number of gaussian points: */ 5688 Gauss* gauss=element->NewGaussBase(2); 5689 for(int ig=gauss->begin();ig<gauss->end();ig++){ 5690 5691 gauss->GaussPoint(ig); 5692 5693 /*Friction: */ 5694 friction->GetAlpha2(&alpha2,gauss); 5695 element->JacobianDeterminantBase(&Jdet2d, xyz_list_tria,gauss); 5696 this->GetBHOFriction(L,element,3,xyz_list_tria,gauss); 5697 5698 DL_scalar=alpha2*gauss->weight*Jdet2d; 5699 for (i=0;i<2;i++) DL[i][i]=DL_scalar; 5700 5701 /* Do the triple producte tL*D*L: */ 5702 TripleMultiply( L,2,numdof,1, 5703 &DL[0][0],2,2,0, 5704 L,2,numdof,0, 5705 Ke_gg,1); 5706 } 5707 5708 for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[i*numdoftotal+(numdof+j)]+=Ke_gg[i*numdof+j]; 5709 for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[(i+numdof)*numdoftotal+j]+=Ke_gg[i*numdof+j]; 5710 5711 /*Transform Coordinate System*/ 5712 element->TransformStiffnessMatrixCoord(Ke,node_list,2*numnodes,cs_list); 5713 5714 /*Clean up and return*/ 5715 delete gauss; 5716 delete friction; 5717 xDelete<int>(cs_list); 5718 xDelete<Node*>(node_list); 5719 xDelete<IssmDouble>(xyz_list_tria); 5720 xDelete<IssmDouble>(Ke_gg); 5721 xDelete<IssmDouble>(L); 5722 return Ke; 5723 }/*}}}*/ 5724 ElementMatrix* StressbalanceAnalysis::CreateKMatrixCouplingSSAHOViscous(Element* element){/*{{{*/ 5725 5726 /*Constants*/ 5727 int numnodes = element->GetNumberOfNodes(); 5728 int numdofm = 1 *numnodes; //*2/2 5729 int numdofp = 2 *numnodes; 5730 int numdoftotal = 2 *2 *numnodes;//2 dof per nodes and 2 sets of nodes for HO and SSA 5731 5732 /*Intermediaries */ 5733 int i,j; 5734 IssmDouble Jdet,viscosity,oldviscosity,newviscosity,viscosity_overshoot; //viscosity 5735 IssmDouble *xyz_list = NULL; 5736 IssmDouble* B = xNew<IssmDouble>(3*numdofp); 5737 IssmDouble* Bprime = xNew<IssmDouble>(3*numdofm); 5738 IssmDouble D[3][3]={0.0}; // material matrix, simple scalar matrix. 5739 IssmDouble D_scalar; 5740 IssmDouble* Ke_gg = xNewZeroInit<IssmDouble>(numdofp*numdofm); 5741 Node **node_list = xNew<Node*>(2*numnodes); 5742 int* cs_list= xNew<int>(2*numnodes); 5743 5744 /*Find penta on bed as HO must be coupled to the dofs on the bed: */ 5745 Element* pentabase=element->GetBasalElement(); 5746 Element* basaltria=pentabase->SpawnBasalElement(); 5747 5748 /*prepare node list*/ 5749 for(i=0;i<numnodes;i++){ 5750 node_list[i+0*numnodes] = pentabase->GetNode(i); 5751 node_list[i+1*numnodes] = element ->GetNode(i); 5752 cs_list[i+0*numnodes] = XYEnum; 5753 cs_list[i+1*numnodes] = XYEnum; 5754 } 5755 5756 /*Initialize Element matrix*/ 5757 ElementMatrix* Ke1= pentabase->NewElementMatrix(SSAApproximationEnum); 5758 ElementMatrix* Ke2= element ->NewElementMatrix(HOApproximationEnum); 5759 ElementMatrix* Ke =new ElementMatrix(Ke1,Ke2); 5760 delete Ke1; delete Ke2; 5761 5762 /* Get node coordinates and dof list: */ 5763 element->GetVerticesCoordinates(&xyz_list); 5764 element->FindParam(&viscosity_overshoot,StressbalanceViscosityOvershootEnum); 5765 Input* vx_input =element->GetInput(VxEnum); _assert_(vx_input); 5766 Input* vy_input =element->GetInput(VyEnum); _assert_(vy_input); 5767 Input* vxold_input=element->GetInput(VxPicardEnum); _assert_(vxold_input); 5768 Input* vyold_input=element->GetInput(VyPicardEnum); _assert_(vyold_input); 5769 5770 /* Start looping on the number of gaussian points: */ 5771 Gauss* gauss=element->NewGauss(5); 5772 Gauss* gauss_tria=new GaussTria(); 5773 for(int ig=gauss->begin();ig<gauss->end();ig++){ 5774 5775 gauss->GaussPoint(ig); 5776 gauss->SynchronizeGaussBase(gauss_tria); 5777 5778 element->JacobianDeterminant(&Jdet, xyz_list,gauss); 5779 this->GetBSSAHO(B, element,xyz_list, gauss); 5780 this->GetBSSAprime(Bprime,basaltria,2,xyz_list, gauss_tria); 5781 element->ViscosityHO(&viscosity,3,xyz_list,gauss,vx_input,vy_input); 5782 element->ViscosityHO(&oldviscosity,3,xyz_list,gauss,vxold_input,vyold_input); 5783 5784 newviscosity=viscosity+viscosity_overshoot*(viscosity-oldviscosity); 5785 D_scalar=2*newviscosity*gauss->weight*Jdet; 5786 for (i=0;i<3;i++) D[i][i]=D_scalar; 5787 5788 TripleMultiply( B,3,numdofp,1, 5789 &D[0][0],3,3,0, 5790 Bprime,3,numdofm,0, 5791 Ke_gg,1); 5792 } 5793 for(i=0;i<numdofp;i++) for(j=0;j<numdofm;j++) Ke->values[(i+2*numdofm)*numdoftotal+j]+=Ke_gg[i*numdofm+j]; 5794 for(i=0;i<numdofm;i++) for(j=0;j<numdofp;j++) Ke->values[i*numdoftotal+(j+2*numdofm)]+=Ke_gg[j*numdofm+i]; 5795 5796 /*Transform Coordinate System*/ 5797 element->TransformStiffnessMatrixCoord(Ke,node_list,2*numnodes,cs_list); 5798 5799 /*Clean-up and return*/ 5800 basaltria->DeleteMaterials(); delete basaltria; 5801 5802 delete gauss; 5803 delete gauss_tria; 5804 xDelete<IssmDouble>(B); 5805 xDelete<IssmDouble>(Bprime); 5806 xDelete<IssmDouble>(Ke_gg); 5807 xDelete<IssmDouble>(xyz_list); 5808 xDelete<Node*>(node_list); 5809 xDelete<int>(cs_list); 5810 return Ke; 5811 5812 }/*}}}*/ 5813 ElementMatrix* StressbalanceAnalysis::CreateKMatrixHOFS(Element* element){/*{{{*/ 5814 5815 /*compute all stiffness matrices for this element*/ 5816 ElementMatrix* Ke1=CreateKMatrixFS(element); 5817 int indices[3]={18,19,20}; 5818 Ke1->StaticCondensation(3,&indices[0]); 5819 int init = element->FiniteElement(); 5820 element->SetTemporaryElementType(P1Enum); // P1 needed for HO 5821 ElementMatrix* Ke2=CreateKMatrixHO(element); 5822 element->SetTemporaryElementType(init); // P1 needed for HO 5823 ElementMatrix* Ke3=CreateKMatrixCouplingHOFS(element); 5824 ElementMatrix* Ke =new ElementMatrix(Ke1,Ke2,Ke3); 5825 5826 /*clean-up and return*/ 5827 delete Ke1; 5828 delete Ke2; 5829 delete Ke3; 5830 return Ke; 5831 }/*}}}*/ 5832 ElementMatrix* StressbalanceAnalysis::CreateKMatrixSSAFS(Element* element){/*{{{*/ 5833 5834 /*compute all stiffness matrices for this element*/ 5835 ElementMatrix* Ke1=CreateKMatrixFS(element); 5836 int indices[3]={18,19,20}; 5837 Ke1->StaticCondensation(3,&indices[0]); 5838 int init = element->FiniteElement(); 5839 element->SetTemporaryElementType(P1Enum); 5840 ElementMatrix* Ke2=CreateKMatrixSSA3d(element); 5841 element->SetTemporaryElementType(init); 5842 ElementMatrix* Ke3=CreateKMatrixCouplingSSAFS(element); 5843 ElementMatrix* Ke =new ElementMatrix(Ke1,Ke2,Ke3); 5844 5845 /*clean-up and return*/ 5846 delete Ke1; 5847 delete Ke2; 5848 delete Ke3; 5849 return Ke; 5850 }/*}}}*/ 5851 ElementMatrix* StressbalanceAnalysis::CreateKMatrixSSAHO(Element* element){/*{{{*/ 5852 5853 /*compute all stiffness matrices for this element*/ 5854 ElementMatrix* Ke1=CreateKMatrixSSA3d(element); 5855 ElementMatrix* Ke2=CreateKMatrixHO(element); 5856 ElementMatrix* Ke3=CreateKMatrixCouplingSSAHO(element); 5857 ElementMatrix* Ke =new ElementMatrix(Ke1,Ke2,Ke3); 5858 5859 /*clean-up and return*/ 5860 delete Ke1; 5861 delete Ke2; 5862 delete Ke3; 5863 return Ke; 5864 }/*}}}*/ 5865 ElementMatrix* StressbalanceAnalysis::CreateKMatrixSSA3d(Element* element){/*{{{*/ 5866 5867 /*compute all stiffness matrices for this element*/ 5868 ElementMatrix* Ke1=CreateKMatrixSSA3dViscous(element); 5869 ElementMatrix* Ke2=CreateKMatrixSSA3dFriction(element); 5870 ElementMatrix* Ke =new ElementMatrix(Ke1,Ke2); 5871 5872 /*clean-up and return*/ 5873 delete Ke1; 5874 delete Ke2; 5875 return Ke; 5876 }/*}}}*/ 5877 ElementMatrix* StressbalanceAnalysis::CreateKMatrixSSA3dFriction(Element* element){/*{{{*/ 5878 5879 /*Initialize Element matrix and return if necessary*/ 5880 if(element->IsFloating() || !element->IsOnBase()) return NULL; 5881 5882 /*Build a tria element using the 3 nodes of the base of the penta. Then use 5883 * the tria functionality to build a friction stiffness matrix on these 3 5884 * nodes: */ 5885 Element* basalelement = element->SpawnBasalElement(); 5886 ElementMatrix* Ke=CreateKMatrixSSAFriction(basalelement); 5887 basalelement->DeleteMaterials(); delete basalelement; 5888 5889 /*clean-up and return*/ 5890 return Ke; 5891 }/*}}}*/ 5892 ElementMatrix* StressbalanceAnalysis::CreateKMatrixSSA3dViscous(Element* element){/*{{{*/ 5893 5894 /*Constants*/ 5895 const int numdof2d=2*3; 5896 5897 /*Intermediaries */ 5898 int i,j,approximation; 5899 int dim=3; 5900 IssmDouble Jdet,viscosity,oldviscosity,newviscosity,viscosity_overshoot; 5901 IssmDouble epsilon[5],oldepsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/ 5902 IssmDouble epsilons[6]; //6 for FS 5903 IssmDouble B[3][numdof2d]; 5904 IssmDouble Bprime[3][numdof2d]; 5905 IssmDouble D[3][3]= {0.0}; // material matrix, simple scalar matrix. 5906 IssmDouble D_scalar; 5907 IssmDouble Ke_gg[numdof2d][numdof2d]={0.0}; 5908 IssmDouble *xyz_list = NULL; 5909 5910 /*Find penta on bed as this is a SSA elements: */ 5911 Element* pentabase=element->GetBasalElement(); 5912 Element* basaltria=pentabase->SpawnBasalElement(); 5913 5914 /*Initialize Element matrix*/ 5915 ElementMatrix* Ke=basaltria->NewElementMatrix(SSAApproximationEnum); 5916 element->GetInputValue(&approximation,ApproximationEnum); 5917 5918 /*Retrieve all inputs and parameters*/ 5919 element->GetVerticesCoordinates(&xyz_list); 5920 element->FindParam(&viscosity_overshoot,StressbalanceViscosityOvershootEnum); 5921 Input* vx_input =element->GetInput(VxEnum); _assert_(vx_input); 5922 Input* vy_input =element->GetInput(VyEnum); _assert_(vy_input); 5923 Input* vxold_input=element->GetInput(VxPicardEnum); _assert_(vxold_input); 5924 Input* vyold_input=element->GetInput(VyPicardEnum); _assert_(vyold_input); 5925 Input* vz_input =element->GetInput(VzEnum); _assert_(vz_input); 5926 5927 /* Start looping on the number of gaussian points: */ 5928 Gauss* gauss=element->NewGauss(5); 5929 Gauss* gauss_tria=new GaussTria(); 5930 for(int ig=gauss->begin();ig<gauss->end();ig++){ 5931 5932 gauss->GaussPoint(ig); 5933 gauss->SynchronizeGaussBase(gauss_tria); 5934 5935 element->JacobianDeterminant(&Jdet, xyz_list,gauss); 5936 this->GetBSSA(&B[0][0],basaltria,2,xyz_list, gauss_tria); 5937 this->GetBSSAprime(&Bprime[0][0],basaltria,2,xyz_list, gauss_tria); 5938 5939 if(approximation==SSAHOApproximationEnum){ 5940 element->ViscosityHO(&viscosity,dim,xyz_list,gauss,vx_input,vy_input); 5941 element->ViscosityHO(&oldviscosity,dim,xyz_list,gauss,vxold_input,vyold_input); 5942 newviscosity=viscosity+viscosity_overshoot*(viscosity-oldviscosity); 5943 } 5944 else if (approximation==SSAFSApproximationEnum){ 5945 element->ViscosityFS(&newviscosity,dim,xyz_list,gauss,vx_input,vy_input,vz_input); 5946 } 5947 else _error_("approximation " << approximation << " (" << EnumToStringx(approximation) << ") not supported yet"); 5948 5949 D_scalar=2*newviscosity*gauss->weight*Jdet; 5950 for (i=0;i<3;i++) D[i][i]=D_scalar; 5951 5952 TripleMultiply( &B[0][0],3,numdof2d,1, 5953 &D[0][0],3,3,0, 5954 &Bprime[0][0],3,numdof2d,0, 5955 &Ke_gg[0][0],1); 5956 5957 } 5958 for(i=0;i<numdof2d;i++) for(j=0;j<numdof2d;j++) Ke->values[i*numdof2d+j]+=Ke_gg[i][j]; 5959 5960 /*Transform Coordinate System*/ 5961 basaltria->TransformStiffnessMatrixCoord(Ke,XYEnum); 5962 5963 /*Clean up and return*/ 5964 xDelete<IssmDouble>(xyz_list); 5965 delete basaltria->material; 5966 delete basaltria; 5967 delete gauss_tria; 5968 delete gauss; 5969 return Ke; 5970 5971 }/*}}}*/ 5972 ElementVector* StressbalanceAnalysis::CreatePVectorCouplingHOFS(Element* element){/*{{{*/ 5948 5973 5949 5974 /*compute all load vectors for this element*/ 5950 ElementVector* pe1=CreatePVector SSA(element);5951 ElementVector* pe2=CreatePVector HO(element);5975 ElementVector* pe1=CreatePVectorCouplingHOFSViscous(element); 5976 ElementVector* pe2=CreatePVectorCouplingHOFSFriction(element); 5952 5977 ElementVector* pe =new ElementVector(pe1,pe2); 5953 5978 … … 5955 5980 delete pe1; 5956 5981 delete pe2; 5982 return pe; 5983 }/*}}}*/ 5984 ElementVector* StressbalanceAnalysis::CreatePVectorCouplingHOFSFriction(Element* element){/*{{{*/ 5985 5986 /*Intermediaries*/ 5987 int i,approximation; 5988 int dim=3; 5989 IssmDouble Jdet,Jdet2d,FSreconditioning; 5990 IssmDouble bed_normal[3]; 5991 IssmDouble viscosity, w, alpha2_gauss; 5992 IssmDouble dw[3]; 5993 IssmDouble *xyz_list_tria = NULL; 5994 IssmDouble *xyz_list = NULL; 5995 IssmDouble basis[6]; //for the six nodes of the penta 5996 5997 /*Initialize Element vector and return if necessary*/ 5998 if(!element->IsOnBase() || element->IsFloating()) return NULL; 5999 element->GetInputValue(&approximation,ApproximationEnum); 6000 if(approximation!=HOFSApproximationEnum) return NULL; 6001 6002 int vnumnodes = element->NumberofNodesVelocity(); 6003 int pnumnodes = element->NumberofNodesPressure(); 6004 int numnodes = vnumnodes+pnumnodes; 6005 6006 /*Prepare coordinate system list*/ 6007 int* cs_list = xNew<int>(vnumnodes+pnumnodes); 6008 Node **node_list = xNew<Node*>(vnumnodes+pnumnodes); 6009 for(i=0;i<vnumnodes;i++){ 6010 cs_list[i] = XYZEnum; 6011 node_list[i] = element->GetNode(i); 6012 } 6013 for(i=0;i<pnumnodes;i++){ 6014 cs_list[vnumnodes+i] = PressureEnum; 6015 node_list[vnumnodes+i] = element->GetNode(vnumnodes+i); 6016 } 6017 6018 ElementVector* pe=element->NewElementVector(FSvelocityEnum); 6019 6020 /*Retrieve all inputs and parameters*/ 6021 element->GetVerticesCoordinates(&xyz_list); 6022 element->GetVerticesCoordinatesBase(&xyz_list_tria); 6023 element->FindParam(&FSreconditioning,StressbalanceFSreconditioningEnum); 6024 Input* vx_input= element->GetInput(VxEnum); _assert_(vx_input); 6025 Input* vy_input= element->GetInput(VyEnum); _assert_(vy_input); 6026 Input* vz_input= element->GetInput(VzEnum); _assert_(vz_input); 6027 Input* vzHO_input=element->GetInput(VzHOEnum); _assert_(vzHO_input); 6028 6029 /*build friction object, used later on: */ 6030 Friction* friction=new Friction(element,3); 6031 6032 /* Start looping on the number of gauss 2d (nodes on the bedrock) */ 6033 Gauss* gauss=element->NewGaussBase(2); 6034 for(int ig=gauss->begin();ig<gauss->end();ig++){ 6035 6036 gauss->GaussPoint(ig); 6037 6038 element->JacobianDeterminantBase(&Jdet2d,xyz_list_tria,gauss); 6039 element->NodalFunctionsP1(basis, gauss); 6040 6041 vzHO_input->GetInputValue(&w, gauss); 6042 vzHO_input->GetInputDerivativeValue(&dw[0],xyz_list,gauss); 6043 6044 element->NormalBase(&bed_normal[0],xyz_list_tria); 6045 element->ViscosityFS(&viscosity,dim,xyz_list,gauss,vx_input,vy_input,vz_input); 6046 friction->GetAlpha2(&alpha2_gauss,gauss); 6047 6048 for(i=0;i<3;i++){ 6049 pe->values[i*3+0]+=Jdet2d*gauss->weight*(alpha2_gauss*w*bed_normal[0]*bed_normal[2]+2*viscosity*dw[2]*bed_normal[0])*basis[i]; 6050 pe->values[i*3+1]+=Jdet2d*gauss->weight*(alpha2_gauss*w*bed_normal[1]*bed_normal[2]+2*viscosity*dw[2]*bed_normal[1])*basis[i]; 6051 pe->values[i*3+2]+=Jdet2d*gauss->weight*2*viscosity*(dw[0]*bed_normal[0]+dw[1]*bed_normal[1]+dw[2]*bed_normal[2])*basis[i]; 6052 } 6053 } 6054 6055 /*Transform coordinate system*/ 6056 element->TransformLoadVectorCoord(pe,node_list,vnumnodes+pnumnodes,cs_list); 6057 6058 /*Clean up and return*/ 6059 xDelete<int>(cs_list); 6060 xDelete<Node*>(node_list); 6061 xDelete<IssmDouble>(xyz_list); 6062 xDelete<IssmDouble>(xyz_list_tria); 6063 delete gauss; 6064 delete friction; 6065 return pe; 6066 }/*}}}*/ 6067 ElementVector* StressbalanceAnalysis::CreatePVectorCouplingHOFSViscous(Element* element){/*{{{*/ 6068 6069 /*Intermediaries */ 6070 int i,approximation; 6071 int dim=3; 6072 IssmDouble viscosity,Jdet,FSreconditioning; 6073 IssmDouble dw[3]; 6074 IssmDouble *xyz_list = NULL; 6075 IssmDouble basis[6]; //for the six nodes of the penta 6076 IssmDouble dbasis[3][6]; //for the six nodes of the penta 6077 6078 /*Initialize Element vector and return if necessary*/ 6079 element->GetInputValue(&approximation,ApproximationEnum); 6080 if(approximation!=HOFSApproximationEnum) return NULL; 6081 int vnumnodes = element->NumberofNodesVelocity(); 6082 int pnumnodes = element->NumberofNodesPressure(); 6083 6084 /*Prepare coordinate system list*/ 6085 int* cs_list = xNew<int>(vnumnodes+pnumnodes); 6086 Node **node_list = xNew<Node*>(vnumnodes+pnumnodes); 6087 for(i=0;i<vnumnodes;i++){ 6088 cs_list[i] = XYZEnum; 6089 node_list[i] = element->GetNode(i); 6090 } 6091 for(i=0;i<pnumnodes;i++){ 6092 cs_list[vnumnodes+i] = PressureEnum; 6093 node_list[vnumnodes+i] = element->GetNode(vnumnodes+i); 6094 } 6095 ElementVector* pe = element->NewElementVector(FSvelocityEnum); 6096 6097 /*Retrieve all inputs and parameters*/ 6098 element->GetVerticesCoordinates(&xyz_list); 6099 element->FindParam(&FSreconditioning,StressbalanceFSreconditioningEnum); 6100 Input* vx_input =element->GetInput(VxEnum); _assert_(vx_input); 6101 Input* vy_input =element->GetInput(VyEnum); _assert_(vy_input); 6102 Input* vz_input =element->GetInput(VzEnum); _assert_(vz_input); 6103 Input* vzHO_input=element->GetInput(VzHOEnum); _assert_(vzHO_input); 6104 6105 /* Start looping on the number of gaussian points: */ 6106 Gauss* gauss=element->NewGauss(5); 6107 for(int ig=gauss->begin();ig<gauss->end();ig++){ 6108 6109 gauss->GaussPoint(ig); 6110 6111 element->JacobianDeterminant(&Jdet, xyz_list,gauss); 6112 element->NodalFunctionsP1(&basis[0],gauss); 6113 element->NodalFunctionsP1Derivatives(&dbasis[0][0],xyz_list,gauss); 6114 6115 element->ViscosityFS(&viscosity,dim,xyz_list,gauss,vx_input,vy_input,vz_input); 6116 vzHO_input->GetInputDerivativeValue(&dw[0],xyz_list,gauss); 6117 6118 for(i=0;i<6;i++){ 6119 pe->values[i*3+0]+=-Jdet*gauss->weight*viscosity*dw[0]*dbasis[2][i]; 6120 pe->values[i*3+1]+=-Jdet*gauss->weight*viscosity*dw[1]*dbasis[2][i]; 6121 pe->values[i*3+2]+=-Jdet*gauss->weight*viscosity*(dw[0]*dbasis[0][i]+dw[1]*dbasis[1][i]+2*dw[2]*dbasis[2][i]); 6122 pe->values[3*vnumnodes+i]+=Jdet*gauss->weight*FSreconditioning*dw[2]*basis[i]; 6123 } 6124 } 6125 6126 /*Transform coordinate system*/ 6127 element->TransformLoadVectorCoord(pe,node_list,vnumnodes+pnumnodes,cs_list); 6128 6129 /*Clean up and return*/ 6130 xDelete<int>(cs_list); 6131 xDelete<Node*>(node_list); 6132 xDelete<IssmDouble>(xyz_list); 6133 delete gauss; 6134 return pe; 6135 }/*}}}*/ 6136 ElementVector* StressbalanceAnalysis::CreatePVectorCouplingSSAFS(Element* element){/*{{{*/ 6137 6138 /*compute all load vectors for this element*/ 6139 ElementVector* pe1=CreatePVectorCouplingSSAFSViscous(element); 6140 ElementVector* pe2=CreatePVectorCouplingSSAFSFriction(element); 6141 ElementVector* pe =new ElementVector(pe1,pe2); 6142 6143 /*clean-up and return*/ 6144 delete pe1; 6145 delete pe2; 6146 return pe; 6147 }/*}}}*/ 6148 ElementVector* StressbalanceAnalysis::CreatePVectorCouplingSSAFSFriction(Element* element){/*{{{*/ 6149 6150 /*Intermediaries*/ 6151 int i,j,approximation; 6152 int dim=3; 6153 IssmDouble Jdet,Jdet2d,FSreconditioning; 6154 IssmDouble bed_normal[3]; 6155 IssmDouble viscosity, w, alpha2_gauss; 6156 IssmDouble dw[3]; 6157 IssmDouble basis[6]; //for the six nodes of the penta 6158 IssmDouble *xyz_list_tria = NULL; 6159 IssmDouble *xyz_list = NULL; 6160 6161 /*Initialize Element vector and return if necessary*/ 6162 if(!element->IsOnBase() || element->IsFloating()) return NULL; 6163 element->GetInputValue(&approximation,ApproximationEnum); 6164 if(approximation!=SSAFSApproximationEnum) return NULL; 6165 int vnumnodes = element->NumberofNodesVelocity(); 6166 int pnumnodes = element->NumberofNodesPressure(); 6167 6168 /*Prepare coordinate system list*/ 6169 int* cs_list = xNew<int>(vnumnodes+pnumnodes); 6170 Node **node_list = xNew<Node*>(vnumnodes+pnumnodes); 6171 for(i=0;i<vnumnodes;i++){ 6172 cs_list[i] = XYZEnum; 6173 node_list[i] = element->GetNode(i); 6174 } 6175 for(i=0;i<pnumnodes;i++){ 6176 cs_list[vnumnodes+i] = PressureEnum; 6177 node_list[vnumnodes+i] = element->GetNode(vnumnodes+i); 6178 } 6179 ElementVector* pe=element->NewElementVector(FSvelocityEnum); 6180 6181 /*Retrieve all inputs and parameters*/ 6182 element->GetVerticesCoordinates(&xyz_list); 6183 element->GetVerticesCoordinatesBase(&xyz_list_tria); 6184 element->FindParam(&FSreconditioning,StressbalanceFSreconditioningEnum); 6185 Input* vx_input= element->GetInput(VxEnum); _assert_(vx_input); 6186 Input* vy_input= element->GetInput(VyEnum); _assert_(vy_input); 6187 Input* vz_input= element->GetInput(VzEnum); _assert_(vz_input); 6188 Input* vzSSA_input=element->GetInput(VzSSAEnum); _assert_(vzSSA_input); 6189 6190 /*build friction object, used later on: */ 6191 Friction* friction=new Friction(element,3); 6192 6193 /* Start looping on the number of gauss 2d (nodes on the bedrock) */ 6194 Gauss* gauss=element->NewGaussBase(2); 6195 for(int ig=gauss->begin();ig<gauss->end();ig++){ 6196 6197 gauss->GaussPoint(ig); 6198 6199 element->JacobianDeterminantBase(&Jdet2d,xyz_list_tria,gauss); 6200 element->NodalFunctionsP1(basis, gauss); 6201 6202 vzSSA_input->GetInputValue(&w, gauss); 6203 vzSSA_input->GetInputDerivativeValue(&dw[0],xyz_list,gauss); 6204 6205 element->NormalBase(&bed_normal[0],xyz_list_tria); 6206 element->ViscosityFS(&viscosity,dim,xyz_list,gauss,vx_input,vy_input,vz_input); 6207 friction->GetAlpha2(&alpha2_gauss,gauss); 6208 6209 for(i=0;i<3;i++){ 6210 pe->values[i*3+0]+=Jdet2d*gauss->weight*(alpha2_gauss*w*bed_normal[0]*bed_normal[2]+2*viscosity*dw[2]*bed_normal[0])*basis[i]; 6211 pe->values[i*3+1]+=Jdet2d*gauss->weight*(alpha2_gauss*w*bed_normal[1]*bed_normal[2]+2*viscosity*dw[2]*bed_normal[1])*basis[i]; 6212 pe->values[i*3+2]+=Jdet2d*gauss->weight*2*viscosity*(dw[0]*bed_normal[0]+dw[1]*bed_normal[1]+dw[2]*bed_normal[2])*basis[i]; 6213 } 6214 } 6215 6216 /*Transform coordinate system*/ 6217 element->TransformLoadVectorCoord(pe,node_list,vnumnodes+pnumnodes,cs_list); 6218 6219 /*Clean up and return*/ 6220 xDelete<int>(cs_list); 6221 xDelete<IssmDouble>(xyz_list); 6222 xDelete<IssmDouble>(xyz_list_tria); 6223 xDelete<Node*>(node_list); 6224 delete gauss; 6225 delete friction; 6226 return pe; 6227 }/*}}}*/ 6228 ElementVector* StressbalanceAnalysis::CreatePVectorCouplingSSAFSViscous(Element* element){/*{{{*/ 6229 6230 /*Intermediaries */ 6231 int i,approximation; 6232 IssmDouble viscosity,Jdet,FSreconditioning; 6233 IssmDouble dw[3]; 6234 IssmDouble *xyz_list = NULL; 6235 IssmDouble basis[6]; //for the six nodes of the penta 6236 IssmDouble dbasis[3][6]; //for the six nodes of the penta 6237 6238 /*Initialize Element vector and return if necessary*/ 6239 element->GetInputValue(&approximation,ApproximationEnum); 6240 if(approximation!=SSAFSApproximationEnum) return NULL; 6241 int vnumnodes = element->NumberofNodesVelocity(); 6242 int pnumnodes = element->NumberofNodesPressure(); 6243 6244 /*Prepare coordinate system list*/ 6245 int* cs_list = xNew<int>(vnumnodes+pnumnodes); 6246 Node **node_list = xNew<Node*>(vnumnodes+pnumnodes); 6247 for(i=0;i<vnumnodes;i++){ 6248 cs_list[i] = XYZEnum; 6249 node_list[i] = element->GetNode(i); 6250 } 6251 for(i=0;i<pnumnodes;i++){ 6252 cs_list[vnumnodes+i] = PressureEnum; 6253 node_list[vnumnodes+i] = element->GetNode(vnumnodes+i); 6254 } 6255 ElementVector* pe=element->NewElementVector(FSvelocityEnum); 6256 6257 /*Retrieve all inputs and parameters*/ 6258 element->GetVerticesCoordinates(&xyz_list); 6259 element->FindParam(&FSreconditioning,StressbalanceFSreconditioningEnum); 6260 Input* vx_input =element->GetInput(VxEnum); _assert_(vx_input); 6261 Input* vy_input =element->GetInput(VyEnum); _assert_(vy_input); 6262 Input* vz_input =element->GetInput(VzEnum); _assert_(vz_input); 6263 Input* vzSSA_input=element->GetInput(VzSSAEnum); _assert_(vzSSA_input); 6264 6265 /* Start looping on the number of gaussian points: */ 6266 Gauss* gauss=element->NewGauss(5); 6267 for(int ig=gauss->begin();ig<gauss->end();ig++){ 6268 6269 gauss->GaussPoint(ig); 6270 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 6271 element->NodalFunctionsP1(&basis[0], gauss); 6272 element->NodalFunctionsP1Derivatives(&dbasis[0][0],xyz_list, gauss); 6273 6274 vzSSA_input->GetInputDerivativeValue(&dw[0],xyz_list,gauss); 6275 element->ViscosityFS(&viscosity,3,xyz_list,gauss,vx_input,vy_input,vz_input); 6276 6277 for(i=0;i<6;i++){ 6278 pe->values[i*3+0]+=-Jdet*gauss->weight*viscosity*dw[0]*dbasis[2][i]; 6279 pe->values[i*3+1]+=-Jdet*gauss->weight*viscosity*dw[1]*dbasis[2][i]; 6280 pe->values[i*3+2]+=-Jdet*gauss->weight*viscosity*(dw[0]*dbasis[0][i]+dw[1]*dbasis[1][i]+2*dw[2]*dbasis[2][i]); 6281 pe->values[3*vnumnodes+i]+=Jdet*gauss->weight*FSreconditioning*dw[2]*basis[i]; 6282 } 6283 } 6284 6285 /*Transform coordinate system*/ 6286 element->TransformLoadVectorCoord(pe,node_list,vnumnodes+pnumnodes,cs_list); 6287 6288 /*Clean up and return*/ 6289 xDelete<int>(cs_list); 6290 xDelete<Node*>(node_list); 6291 xDelete<IssmDouble>(xyz_list); 6292 delete gauss; 6293 return pe; 6294 }/*}}}*/ 6295 ElementVector* StressbalanceAnalysis::CreatePVectorHOFS(Element* element){/*{{{*/ 6296 6297 /*compute all load vectors for this element*/ 6298 int init = element->FiniteElement(); 6299 element->SetTemporaryElementType(P1Enum); 6300 ElementVector* pe1=CreatePVectorHO(element); 6301 element->SetTemporaryElementType(init); 6302 ElementVector* pe2=CreatePVectorFS(element); 6303 int indices[3]={18,19,20}; 6304 element->SetTemporaryElementType(MINIcondensedEnum); 6305 ElementMatrix* Ke = CreateKMatrixFS(element); 6306 element->SetTemporaryElementType(init); 6307 pe2->StaticCondensation(Ke,3,&indices[0]); 6308 delete Ke; 6309 ElementVector* pe3=CreatePVectorCouplingHOFS(element); 6310 ElementVector* pe =new ElementVector(pe1,pe2,pe3); 6311 6312 /*clean-up and return*/ 6313 delete pe1; 6314 delete pe2; 6315 delete pe3; 5957 6316 return pe; 5958 6317 }/*}}}*/ … … 5980 6339 return pe; 5981 6340 }/*}}}*/ 5982 ElementVector* StressbalanceAnalysis::CreatePVector HOFS(Element* element){/*{{{*/6341 ElementVector* StressbalanceAnalysis::CreatePVectorSSAHO(Element* element){/*{{{*/ 5983 6342 5984 6343 /*compute all load vectors for this element*/ 5985 int init = element->FiniteElement(); 5986 element->SetTemporaryElementType(P1Enum); 5987 ElementVector* pe1=CreatePVectorHO(element); 5988 element->SetTemporaryElementType(init); 5989 ElementVector* pe2=CreatePVectorFS(element); 5990 int indices[3]={18,19,20}; 5991 element->SetTemporaryElementType(MINIcondensedEnum); 5992 ElementMatrix* Ke = CreateKMatrixFS(element); 5993 element->SetTemporaryElementType(init); 5994 pe2->StaticCondensation(Ke,3,&indices[0]); 5995 delete Ke; 5996 ElementVector* pe3=CreatePVectorCouplingHOFS(element); 5997 ElementVector* pe =new ElementVector(pe1,pe2,pe3); 5998 5999 /*clean-up and return*/ 6000 delete pe1; 6001 delete pe2; 6002 delete pe3; 6003 return pe; 6004 }/*}}}*/ 6005 ElementVector* StressbalanceAnalysis::CreatePVectorCouplingHOFS(Element* element){/*{{{*/ 6006 6007 /*compute all load vectors for this element*/ 6008 ElementVector* pe1=CreatePVectorCouplingHOFSViscous(element); 6009 ElementVector* pe2=CreatePVectorCouplingHOFSFriction(element); 6344 ElementVector* pe1=CreatePVectorSSA(element); 6345 ElementVector* pe2=CreatePVectorHO(element); 6010 6346 ElementVector* pe =new ElementVector(pe1,pe2); 6011 6347 … … 6015 6351 return pe; 6016 6352 }/*}}}*/ 6017 ElementVector* StressbalanceAnalysis::CreatePVectorCouplingHOFSFriction(Element* element){/*{{{*/ 6018 6019 /*Intermediaries*/ 6020 int i,approximation; 6021 int dim=3; 6022 IssmDouble Jdet,Jdet2d,FSreconditioning; 6023 IssmDouble bed_normal[3]; 6024 IssmDouble viscosity, w, alpha2_gauss; 6025 IssmDouble dw[3]; 6026 IssmDouble *xyz_list_tria = NULL; 6027 IssmDouble *xyz_list = NULL; 6028 IssmDouble basis[6]; //for the six nodes of the penta 6029 6030 /*Initialize Element vector and return if necessary*/ 6031 if(!element->IsOnBase() || element->IsFloating()) return NULL; 6032 element->GetInputValue(&approximation,ApproximationEnum); 6033 if(approximation!=HOFSApproximationEnum) return NULL; 6034 6035 int vnumnodes = element->NumberofNodesVelocity(); 6036 int pnumnodes = element->NumberofNodesPressure(); 6037 int numnodes = vnumnodes+pnumnodes; 6038 6039 /*Prepare coordinate system list*/ 6040 int* cs_list = xNew<int>(vnumnodes+pnumnodes); 6041 Node **node_list = xNew<Node*>(vnumnodes+pnumnodes); 6042 for(i=0;i<vnumnodes;i++){ 6043 cs_list[i] = XYZEnum; 6044 node_list[i] = element->GetNode(i); 6045 } 6046 for(i=0;i<pnumnodes;i++){ 6047 cs_list[vnumnodes+i] = PressureEnum; 6048 node_list[vnumnodes+i] = element->GetNode(vnumnodes+i); 6049 } 6050 6051 ElementVector* pe=element->NewElementVector(FSvelocityEnum); 6052 6053 /*Retrieve all inputs and parameters*/ 6054 element->GetVerticesCoordinates(&xyz_list); 6055 element->GetVerticesCoordinatesBase(&xyz_list_tria); 6056 element->FindParam(&FSreconditioning,StressbalanceFSreconditioningEnum); 6057 Input* vx_input= element->GetInput(VxEnum); _assert_(vx_input); 6058 Input* vy_input= element->GetInput(VyEnum); _assert_(vy_input); 6059 Input* vz_input= element->GetInput(VzEnum); _assert_(vz_input); 6060 Input* vzHO_input=element->GetInput(VzHOEnum); _assert_(vzHO_input); 6061 6062 /*build friction object, used later on: */ 6063 Friction* friction=new Friction(element,3); 6064 6065 /* Start looping on the number of gauss 2d (nodes on the bedrock) */ 6066 Gauss* gauss=element->NewGaussBase(2); 6067 for(int ig=gauss->begin();ig<gauss->end();ig++){ 6068 6069 gauss->GaussPoint(ig); 6070 6071 element->JacobianDeterminantBase(&Jdet2d,xyz_list_tria,gauss); 6072 element->NodalFunctionsP1(basis, gauss); 6073 6074 vzHO_input->GetInputValue(&w, gauss); 6075 vzHO_input->GetInputDerivativeValue(&dw[0],xyz_list,gauss); 6076 6077 element->NormalBase(&bed_normal[0],xyz_list_tria); 6078 element->ViscosityFS(&viscosity,dim,xyz_list,gauss,vx_input,vy_input,vz_input); 6079 friction->GetAlpha2(&alpha2_gauss,gauss); 6080 6081 for(i=0;i<3;i++){ 6082 pe->values[i*3+0]+=Jdet2d*gauss->weight*(alpha2_gauss*w*bed_normal[0]*bed_normal[2]+2*viscosity*dw[2]*bed_normal[0])*basis[i]; 6083 pe->values[i*3+1]+=Jdet2d*gauss->weight*(alpha2_gauss*w*bed_normal[1]*bed_normal[2]+2*viscosity*dw[2]*bed_normal[1])*basis[i]; 6084 pe->values[i*3+2]+=Jdet2d*gauss->weight*2*viscosity*(dw[0]*bed_normal[0]+dw[1]*bed_normal[1]+dw[2]*bed_normal[2])*basis[i]; 6085 } 6086 } 6087 6088 /*Transform coordinate system*/ 6089 element->TransformLoadVectorCoord(pe,node_list,vnumnodes+pnumnodes,cs_list); 6090 6091 /*Clean up and return*/ 6092 xDelete<int>(cs_list); 6093 xDelete<Node*>(node_list); 6094 xDelete<IssmDouble>(xyz_list); 6095 xDelete<IssmDouble>(xyz_list_tria); 6096 delete gauss; 6097 delete friction; 6098 return pe; 6099 }/*}}}*/ 6100 ElementVector* StressbalanceAnalysis::CreatePVectorCouplingHOFSViscous(Element* element){/*{{{*/ 6101 6102 /*Intermediaries */ 6103 int i,approximation; 6104 int dim=3; 6105 IssmDouble viscosity,Jdet,FSreconditioning; 6106 IssmDouble dw[3]; 6107 IssmDouble *xyz_list = NULL; 6108 IssmDouble basis[6]; //for the six nodes of the penta 6109 IssmDouble dbasis[3][6]; //for the six nodes of the penta 6110 6111 /*Initialize Element vector and return if necessary*/ 6112 element->GetInputValue(&approximation,ApproximationEnum); 6113 if(approximation!=HOFSApproximationEnum) return NULL; 6114 int vnumnodes = element->NumberofNodesVelocity(); 6115 int pnumnodes = element->NumberofNodesPressure(); 6116 6117 /*Prepare coordinate system list*/ 6118 int* cs_list = xNew<int>(vnumnodes+pnumnodes); 6119 Node **node_list = xNew<Node*>(vnumnodes+pnumnodes); 6120 for(i=0;i<vnumnodes;i++){ 6121 cs_list[i] = XYZEnum; 6122 node_list[i] = element->GetNode(i); 6123 } 6124 for(i=0;i<pnumnodes;i++){ 6125 cs_list[vnumnodes+i] = PressureEnum; 6126 node_list[vnumnodes+i] = element->GetNode(vnumnodes+i); 6127 } 6128 ElementVector* pe = element->NewElementVector(FSvelocityEnum); 6129 6130 /*Retrieve all inputs and parameters*/ 6131 element->GetVerticesCoordinates(&xyz_list); 6132 element->FindParam(&FSreconditioning,StressbalanceFSreconditioningEnum); 6133 Input* vx_input =element->GetInput(VxEnum); _assert_(vx_input); 6134 Input* vy_input =element->GetInput(VyEnum); _assert_(vy_input); 6135 Input* vz_input =element->GetInput(VzEnum); _assert_(vz_input); 6136 Input* vzHO_input=element->GetInput(VzHOEnum); _assert_(vzHO_input); 6137 6138 /* Start looping on the number of gaussian points: */ 6139 Gauss* gauss=element->NewGauss(5); 6140 for(int ig=gauss->begin();ig<gauss->end();ig++){ 6141 6142 gauss->GaussPoint(ig); 6143 6144 element->JacobianDeterminant(&Jdet, xyz_list,gauss); 6145 element->NodalFunctionsP1(&basis[0],gauss); 6146 element->NodalFunctionsP1Derivatives(&dbasis[0][0],xyz_list,gauss); 6147 6148 element->ViscosityFS(&viscosity,dim,xyz_list,gauss,vx_input,vy_input,vz_input); 6149 vzHO_input->GetInputDerivativeValue(&dw[0],xyz_list,gauss); 6150 6151 for(i=0;i<6;i++){ 6152 pe->values[i*3+0]+=-Jdet*gauss->weight*viscosity*dw[0]*dbasis[2][i]; 6153 pe->values[i*3+1]+=-Jdet*gauss->weight*viscosity*dw[1]*dbasis[2][i]; 6154 pe->values[i*3+2]+=-Jdet*gauss->weight*viscosity*(dw[0]*dbasis[0][i]+dw[1]*dbasis[1][i]+2*dw[2]*dbasis[2][i]); 6155 pe->values[3*vnumnodes+i]+=Jdet*gauss->weight*FSreconditioning*dw[2]*basis[i]; 6156 } 6157 } 6158 6159 /*Transform coordinate system*/ 6160 element->TransformLoadVectorCoord(pe,node_list,vnumnodes+pnumnodes,cs_list); 6161 6162 /*Clean up and return*/ 6163 xDelete<int>(cs_list); 6164 xDelete<Node*>(node_list); 6165 xDelete<IssmDouble>(xyz_list); 6166 delete gauss; 6167 return pe; 6168 }/*}}}*/ 6169 ElementVector* StressbalanceAnalysis::CreatePVectorCouplingSSAFS(Element* element){/*{{{*/ 6170 6171 /*compute all load vectors for this element*/ 6172 ElementVector* pe1=CreatePVectorCouplingSSAFSViscous(element); 6173 ElementVector* pe2=CreatePVectorCouplingSSAFSFriction(element); 6174 ElementVector* pe =new ElementVector(pe1,pe2); 6175 6176 /*clean-up and return*/ 6177 delete pe1; 6178 delete pe2; 6179 return pe; 6180 }/*}}}*/ 6181 ElementVector* StressbalanceAnalysis::CreatePVectorCouplingSSAFSFriction(Element* element){/*{{{*/ 6182 6183 /*Intermediaries*/ 6184 int i,j,approximation; 6185 int dim=3; 6186 IssmDouble Jdet,Jdet2d,FSreconditioning; 6187 IssmDouble bed_normal[3]; 6188 IssmDouble viscosity, w, alpha2_gauss; 6189 IssmDouble dw[3]; 6190 IssmDouble basis[6]; //for the six nodes of the penta 6191 IssmDouble *xyz_list_tria = NULL; 6192 IssmDouble *xyz_list = NULL; 6193 6194 /*Initialize Element vector and return if necessary*/ 6195 if(!element->IsOnBase() || element->IsFloating()) return NULL; 6196 element->GetInputValue(&approximation,ApproximationEnum); 6197 if(approximation!=SSAFSApproximationEnum) return NULL; 6198 int vnumnodes = element->NumberofNodesVelocity(); 6199 int pnumnodes = element->NumberofNodesPressure(); 6200 6201 /*Prepare coordinate system list*/ 6202 int* cs_list = xNew<int>(vnumnodes+pnumnodes); 6203 Node **node_list = xNew<Node*>(vnumnodes+pnumnodes); 6204 for(i=0;i<vnumnodes;i++){ 6205 cs_list[i] = XYZEnum; 6206 node_list[i] = element->GetNode(i); 6207 } 6208 for(i=0;i<pnumnodes;i++){ 6209 cs_list[vnumnodes+i] = PressureEnum; 6210 node_list[vnumnodes+i] = element->GetNode(vnumnodes+i); 6211 } 6212 ElementVector* pe=element->NewElementVector(FSvelocityEnum); 6213 6214 /*Retrieve all inputs and parameters*/ 6215 element->GetVerticesCoordinates(&xyz_list); 6216 element->GetVerticesCoordinatesBase(&xyz_list_tria); 6217 element->FindParam(&FSreconditioning,StressbalanceFSreconditioningEnum); 6218 Input* vx_input= element->GetInput(VxEnum); _assert_(vx_input); 6219 Input* vy_input= element->GetInput(VyEnum); _assert_(vy_input); 6220 Input* vz_input= element->GetInput(VzEnum); _assert_(vz_input); 6221 Input* vzSSA_input=element->GetInput(VzSSAEnum); _assert_(vzSSA_input); 6222 6223 /*build friction object, used later on: */ 6224 Friction* friction=new Friction(element,3); 6225 6226 /* Start looping on the number of gauss 2d (nodes on the bedrock) */ 6227 Gauss* gauss=element->NewGaussBase(2); 6228 for(int ig=gauss->begin();ig<gauss->end();ig++){ 6229 6230 gauss->GaussPoint(ig); 6231 6232 element->JacobianDeterminantBase(&Jdet2d,xyz_list_tria,gauss); 6233 element->NodalFunctionsP1(basis, gauss); 6234 6235 vzSSA_input->GetInputValue(&w, gauss); 6236 vzSSA_input->GetInputDerivativeValue(&dw[0],xyz_list,gauss); 6237 6238 element->NormalBase(&bed_normal[0],xyz_list_tria); 6239 element->ViscosityFS(&viscosity,dim,xyz_list,gauss,vx_input,vy_input,vz_input); 6240 friction->GetAlpha2(&alpha2_gauss,gauss); 6241 6242 for(i=0;i<3;i++){ 6243 pe->values[i*3+0]+=Jdet2d*gauss->weight*(alpha2_gauss*w*bed_normal[0]*bed_normal[2]+2*viscosity*dw[2]*bed_normal[0])*basis[i]; 6244 pe->values[i*3+1]+=Jdet2d*gauss->weight*(alpha2_gauss*w*bed_normal[1]*bed_normal[2]+2*viscosity*dw[2]*bed_normal[1])*basis[i]; 6245 pe->values[i*3+2]+=Jdet2d*gauss->weight*2*viscosity*(dw[0]*bed_normal[0]+dw[1]*bed_normal[1]+dw[2]*bed_normal[2])*basis[i]; 6246 } 6247 } 6248 6249 /*Transform coordinate system*/ 6250 element->TransformLoadVectorCoord(pe,node_list,vnumnodes+pnumnodes,cs_list); 6251 6252 /*Clean up and return*/ 6253 xDelete<int>(cs_list); 6254 xDelete<IssmDouble>(xyz_list); 6255 xDelete<IssmDouble>(xyz_list_tria); 6256 xDelete<Node*>(node_list); 6257 delete gauss; 6258 delete friction; 6259 return pe; 6260 }/*}}}*/ 6261 ElementVector* StressbalanceAnalysis::CreatePVectorCouplingSSAFSViscous(Element* element){/*{{{*/ 6262 6263 /*Intermediaries */ 6264 int i,approximation; 6265 IssmDouble viscosity,Jdet,FSreconditioning; 6266 IssmDouble dw[3]; 6267 IssmDouble *xyz_list = NULL; 6268 IssmDouble basis[6]; //for the six nodes of the penta 6269 IssmDouble dbasis[3][6]; //for the six nodes of the penta 6270 6271 /*Initialize Element vector and return if necessary*/ 6272 element->GetInputValue(&approximation,ApproximationEnum); 6273 if(approximation!=SSAFSApproximationEnum) return NULL; 6274 int vnumnodes = element->NumberofNodesVelocity(); 6275 int pnumnodes = element->NumberofNodesPressure(); 6276 6277 /*Prepare coordinate system list*/ 6278 int* cs_list = xNew<int>(vnumnodes+pnumnodes); 6279 Node **node_list = xNew<Node*>(vnumnodes+pnumnodes); 6280 for(i=0;i<vnumnodes;i++){ 6281 cs_list[i] = XYZEnum; 6282 node_list[i] = element->GetNode(i); 6283 } 6284 for(i=0;i<pnumnodes;i++){ 6285 cs_list[vnumnodes+i] = PressureEnum; 6286 node_list[vnumnodes+i] = element->GetNode(vnumnodes+i); 6287 } 6288 ElementVector* pe=element->NewElementVector(FSvelocityEnum); 6289 6290 /*Retrieve all inputs and parameters*/ 6291 element->GetVerticesCoordinates(&xyz_list); 6292 element->FindParam(&FSreconditioning,StressbalanceFSreconditioningEnum); 6293 Input* vx_input =element->GetInput(VxEnum); _assert_(vx_input); 6294 Input* vy_input =element->GetInput(VyEnum); _assert_(vy_input); 6295 Input* vz_input =element->GetInput(VzEnum); _assert_(vz_input); 6296 Input* vzSSA_input=element->GetInput(VzSSAEnum); _assert_(vzSSA_input); 6297 6298 /* Start looping on the number of gaussian points: */ 6299 Gauss* gauss=element->NewGauss(5); 6300 for(int ig=gauss->begin();ig<gauss->end();ig++){ 6301 6302 gauss->GaussPoint(ig); 6303 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 6304 element->NodalFunctionsP1(&basis[0], gauss); 6305 element->NodalFunctionsP1Derivatives(&dbasis[0][0],xyz_list, gauss); 6306 6307 vzSSA_input->GetInputDerivativeValue(&dw[0],xyz_list,gauss); 6308 element->ViscosityFS(&viscosity,3,xyz_list,gauss,vx_input,vy_input,vz_input); 6309 6310 for(i=0;i<6;i++){ 6311 pe->values[i*3+0]+=-Jdet*gauss->weight*viscosity*dw[0]*dbasis[2][i]; 6312 pe->values[i*3+1]+=-Jdet*gauss->weight*viscosity*dw[1]*dbasis[2][i]; 6313 pe->values[i*3+2]+=-Jdet*gauss->weight*viscosity*(dw[0]*dbasis[0][i]+dw[1]*dbasis[1][i]+2*dw[2]*dbasis[2][i]); 6314 pe->values[3*vnumnodes+i]+=Jdet*gauss->weight*FSreconditioning*dw[2]*basis[i]; 6315 } 6316 } 6317 6318 /*Transform coordinate system*/ 6319 element->TransformLoadVectorCoord(pe,node_list,vnumnodes+pnumnodes,cs_list); 6320 6321 /*Clean up and return*/ 6322 xDelete<int>(cs_list); 6323 xDelete<Node*>(node_list); 6324 xDelete<IssmDouble>(xyz_list); 6325 delete gauss; 6326 return pe; 6327 }/*}}}*/ 6328 void StressbalanceAnalysis::GetBSSAHO(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 6329 /*Compute B matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 3*NDOF2. 6330 * For node i, Bi can be expressed in the actual coordinate system 6353 void StressbalanceAnalysis::GetBprimeSSAFS(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 6354 /*Compute Bprime matrix. Bprime=[Bprime1 Bprime2 Bprime3 Bprime4 Bprime5 Bprime6] where Bprimei is of size 5*NDOF2. 6355 * For node i, Bprimei can be expressed in the actual coordinate system 6331 6356 * by: 6332 * B i=[ dh/dx 0]6333 * [ 0 dh/dy]6334 * [ 1/2*dh/dy 1/2*dh/dx]6357 * Bprimei=[ 2*dh/dx dh/dy 0 0 ] 6358 * [ dh/dx 2*dh/dy 0 0 ] 6359 * [ dh/dy dh/dx 0 0 ] 6335 6360 * where h is the interpolation function for node i. 6336 6361 * 6337 * We assume B has been allocated already, of size: 5x(NDOF2*NUMNODESP1)6362 * We assume Bprime has been allocated already, of size: 5x(NDOF2*NUMNODESP1) 6338 6363 */ 6339 6364 6365 int i; 6366 IssmDouble dbasismini[3][7]; 6367 6368 /*Get dbasis in actual coordinate system: */ 6369 element->NodalFunctionsMINIDerivatives(&dbasismini[0][0],xyz_list, gauss); 6370 6371 /*Build Bprime: */ 6372 for(i=0;i<6;i++){ 6373 Bprime[(3*7+6)*0+3*i+0] = 2.*dbasismini[0][i]; 6374 Bprime[(3*7+6)*0+3*i+1] = dbasismini[1][i]; 6375 Bprime[(3*7+6)*0+3*i+2] = 0.; 6376 Bprime[(3*7+6)*1+3*i+0] = dbasismini[0][i]; 6377 Bprime[(3*7+6)*1+3*i+1] = 2.*dbasismini[1][i]; 6378 Bprime[(3*7+6)*1+3*i+2] = 0.; 6379 Bprime[(3*7+6)*2+3*i+0] = dbasismini[1][i]; 6380 Bprime[(3*7+6)*2+3*i+1] = dbasismini[0][i]; 6381 Bprime[(3*7+6)*2+3*i+2] = 0.; 6382 } 6383 6384 for(i=0;i<1;i++){ //Add zeros for the bubble function 6385 Bprime[(3*7+6)*0+3*(6+i)+0] = 0.; 6386 Bprime[(3*7+6)*0+3*(6+i)+1] = 0.; 6387 Bprime[(3*7+6)*0+3*(6+i)+2] = 0.; 6388 Bprime[(3*7+6)*1+3*(6+i)+0] = 0.; 6389 Bprime[(3*7+6)*1+3*(6+i)+1] = 0.; 6390 Bprime[(3*7+6)*1+3*(6+i)+2] = 0.; 6391 Bprime[(3*7+6)*2+3*(6+i)+0] = 0.; 6392 Bprime[(3*7+6)*2+3*(6+i)+1] = 0.; 6393 Bprime[(3*7+6)*2+3*(6+i)+2] = 0.; 6394 } 6395 6396 for(i=0;i<6;i++){ //last column not for the bubble function 6397 Bprime[(3*7+6)*0+7*3+i] = 0.; 6398 Bprime[(3*7+6)*1+7*3+i] = 0.; 6399 Bprime[(3*7+6)*2+7*3+i] = 0.; 6400 } 6401 }/*}}}*/ 6402 void StressbalanceAnalysis::GetBprimeSSAFSTria(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 6403 /*Compute Bprime matrix. Bprime=[Bprime1 Bprime2 Bprime3] where Bprimei is of size 3*NDOF2. 6404 * For node i, Bprimei can be expressed in the actual coordinate system 6405 * by: 6406 * Bprimei=[ dN/dx 0 ] 6407 * [ 0 dN/dy ] 6408 * [ dN/dy dN/dx ] 6409 N [ dN/dx dN/dy ] 6410 * where N is the finiteelement function for node i. 6411 * 6412 * We assume Bprime has been allocated already, of size: 3x(NDOF2*numnodes) 6413 */ 6414 6415 /*Fetch number of nodes for this finite element*/ 6340 6416 int numnodes = element->GetNumberOfNodes(); 6341 IssmDouble* dbasis=xNew<IssmDouble>(3*numnodes); 6342 6343 /*Get dbasis in actual coordinate system: */6417 6418 /*Get nodal functions*/ 6419 IssmDouble* dbasis=xNew<IssmDouble>(2*numnodes); 6344 6420 element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss); 6345 6421 6346 /*Build B : */6422 /*Build Bprime: */ 6347 6423 for(int i=0;i<numnodes;i++){ 6348 B[2*numnodes*0+2*i+0] = dbasis[0*numnodes+i]; 6349 B[2*numnodes*0+2*i+1] = 0.; 6350 B[2*numnodes*1+2*i+0] = 0.; 6351 B[2*numnodes*1+2*i+1] = dbasis[1*numnodes+i]; 6352 B[2*numnodes*2+2*i+0] = .5*dbasis[1*numnodes+i]; 6353 B[2*numnodes*2+2*i+1] = .5*dbasis[0*numnodes+i]; 6424 Bprime[2*numnodes*0+2*i+0] = dbasis[0*numnodes+i]; 6425 Bprime[2*numnodes*0+2*i+1] = 0.; 6426 Bprime[2*numnodes*1+2*i+0] = 0.; 6427 Bprime[2*numnodes*1+2*i+1] = dbasis[1*numnodes+i]; 6428 Bprime[2*numnodes*2+2*i+0] = dbasis[1*numnodes+i]; 6429 Bprime[2*numnodes*2+2*i+1] = dbasis[0*numnodes+i]; 6430 Bprime[2*numnodes*3+2*i+0] = dbasis[0*numnodes+i]; 6431 Bprime[2*numnodes*3+2*i+1] = dbasis[1*numnodes+i]; 6354 6432 } 6355 6433 … … 6357 6435 xDelete<IssmDouble>(dbasis); 6358 6436 }/*}}}*/ 6359 void StressbalanceAnalysis::GetBSSAFS(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/6437 void StressbalanceAnalysis::GetBSSAFS(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 6360 6438 /*Compute B matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF2. 6361 6439 * For node i, Bi can be expressed in the actual coordinate system … … 6415 6493 } 6416 6494 }/*}}}*/ 6417 void StressbalanceAnalysis::GetBprimeSSAFS(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 6418 /*Compute Bprime matrix. Bprime=[Bprime1 Bprime2 Bprime3 Bprime4 Bprime5 Bprime6] where Bprimei is of size 5*NDOF2. 6419 * For node i, Bprimei can be expressed in the actual coordinate system 6420 * by: 6421 * Bprimei=[ 2*dh/dx dh/dy 0 0 ] 6422 * [ dh/dx 2*dh/dy 0 0 ] 6423 * [ dh/dy dh/dx 0 0 ] 6424 * where h is the interpolation function for node i. 6425 * 6426 * We assume Bprime has been allocated already, of size: 5x(NDOF2*NUMNODESP1) 6427 */ 6428 6429 int i; 6430 IssmDouble dbasismini[3][7]; 6431 6432 /*Get dbasis in actual coordinate system: */ 6433 element->NodalFunctionsMINIDerivatives(&dbasismini[0][0],xyz_list, gauss); 6434 6435 /*Build Bprime: */ 6436 for(i=0;i<6;i++){ 6437 Bprime[(3*7+6)*0+3*i+0] = 2.*dbasismini[0][i]; 6438 Bprime[(3*7+6)*0+3*i+1] = dbasismini[1][i]; 6439 Bprime[(3*7+6)*0+3*i+2] = 0.; 6440 Bprime[(3*7+6)*1+3*i+0] = dbasismini[0][i]; 6441 Bprime[(3*7+6)*1+3*i+1] = 2.*dbasismini[1][i]; 6442 Bprime[(3*7+6)*1+3*i+2] = 0.; 6443 Bprime[(3*7+6)*2+3*i+0] = dbasismini[1][i]; 6444 Bprime[(3*7+6)*2+3*i+1] = dbasismini[0][i]; 6445 Bprime[(3*7+6)*2+3*i+2] = 0.; 6446 } 6447 6448 for(i=0;i<1;i++){ //Add zeros for the bubble function 6449 Bprime[(3*7+6)*0+3*(6+i)+0] = 0.; 6450 Bprime[(3*7+6)*0+3*(6+i)+1] = 0.; 6451 Bprime[(3*7+6)*0+3*(6+i)+2] = 0.; 6452 Bprime[(3*7+6)*1+3*(6+i)+0] = 0.; 6453 Bprime[(3*7+6)*1+3*(6+i)+1] = 0.; 6454 Bprime[(3*7+6)*1+3*(6+i)+2] = 0.; 6455 Bprime[(3*7+6)*2+3*(6+i)+0] = 0.; 6456 Bprime[(3*7+6)*2+3*(6+i)+1] = 0.; 6457 Bprime[(3*7+6)*2+3*(6+i)+2] = 0.; 6458 } 6459 6460 for(i=0;i<6;i++){ //last column not for the bubble function 6461 Bprime[(3*7+6)*0+7*3+i] = 0.; 6462 Bprime[(3*7+6)*1+7*3+i] = 0.; 6463 Bprime[(3*7+6)*2+7*3+i] = 0.; 6464 } 6465 }/*}}}*/ 6466 void StressbalanceAnalysis::GetBSSAFSTria(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 6495 void StressbalanceAnalysis::GetBSSAFSTria(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 6467 6496 /*Compute B matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2. 6468 6497 * For node i, Bi can be expressed in the actual coordinate system … … 6496 6525 xDelete<IssmDouble>(dbasis); 6497 6526 }/*}}}*/ 6498 void StressbalanceAnalysis::GetBprimeSSAFSTria(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/6499 /*Compute B prime matrix. Bprime=[Bprime1 Bprime2 Bprime3] where Bprimei is of size 3*NDOF2.6500 * For node i, B primei can be expressed in the actual coordinate system6527 void StressbalanceAnalysis::GetBSSAHO(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 6528 /*Compute B matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 3*NDOF2. 6529 * For node i, Bi can be expressed in the actual coordinate system 6501 6530 * by: 6502 * Bprimei=[ dN/dx 0 ] 6503 * [ 0 dN/dy ] 6504 * [ dN/dy dN/dx ] 6505 N [ dN/dx dN/dy ] 6506 * where N is the finiteelement function for node i. 6531 * Bi=[ dh/dx 0 ] 6532 * [ 0 dh/dy ] 6533 * [ 1/2*dh/dy 1/2*dh/dx ] 6534 * where h is the interpolation function for node i. 6507 6535 * 6508 * We assume B prime has been allocated already, of size: 3x(NDOF2*numnodes)6536 * We assume B has been allocated already, of size: 5x(NDOF2*NUMNODESP1) 6509 6537 */ 6510 6538 6511 /*Fetch number of nodes for this finite element*/6512 6539 int numnodes = element->GetNumberOfNodes(); 6513 6514 /*Get nodal functions*/ 6515 IssmDouble* dbasis=xNew<IssmDouble>(2*numnodes);6540 IssmDouble* dbasis=xNew<IssmDouble>(3*numnodes); 6541 6542 /*Get dbasis in actual coordinate system: */ 6516 6543 element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss); 6517 6544 6518 /*Build B prime: */6545 /*Build B: */ 6519 6546 for(int i=0;i<numnodes;i++){ 6520 Bprime[2*numnodes*0+2*i+0] = dbasis[0*numnodes+i]; 6521 Bprime[2*numnodes*0+2*i+1] = 0.; 6522 Bprime[2*numnodes*1+2*i+0] = 0.; 6523 Bprime[2*numnodes*1+2*i+1] = dbasis[1*numnodes+i]; 6524 Bprime[2*numnodes*2+2*i+0] = dbasis[1*numnodes+i]; 6525 Bprime[2*numnodes*2+2*i+1] = dbasis[0*numnodes+i]; 6526 Bprime[2*numnodes*3+2*i+0] = dbasis[0*numnodes+i]; 6527 Bprime[2*numnodes*3+2*i+1] = dbasis[1*numnodes+i]; 6547 B[2*numnodes*0+2*i+0] = dbasis[0*numnodes+i]; 6548 B[2*numnodes*0+2*i+1] = 0.; 6549 B[2*numnodes*1+2*i+0] = 0.; 6550 B[2*numnodes*1+2*i+1] = dbasis[1*numnodes+i]; 6551 B[2*numnodes*2+2*i+0] = .5*dbasis[1*numnodes+i]; 6552 B[2*numnodes*2+2*i+1] = .5*dbasis[0*numnodes+i]; 6528 6553 } 6529 6554 … … 6531 6556 xDelete<IssmDouble>(dbasis); 6532 6557 }/*}}}*/ 6533 void StressbalanceAnalysis::GetLSSAFS(IssmDouble* LFS,Element* element,Gauss* gauss_in){/*{{{*/ 6534 /* 6535 * Compute L matrix. L=[L1 L2 L3] where Li is square and of size numdof. 6536 * For node i, Li can be expressed in the actual coordinate system 6558 void StressbalanceAnalysis::GetLprimeFSSSA(IssmDouble* LprimeFS,Element* element,IssmDouble* xyz_list,Gauss* gauss_in){/*{{{*/ 6559 /* Compute Lprime matrix. Lprime=[Lp1 Lp2 Lp3] where Lpi is square and of size numdof. 6560 * For node i, Lpi can be expressed in the actual coordinate system 6537 6561 * by: 6538 * Li=[ h 0 ] 6539 * [ 0 h ] 6540 * [ h 0 ] 6541 * [ 0 h ] 6542 * [ h 0 ] 6543 * [ 0 h ] 6544 * [ h 0 ] 6545 * [ 0 h ] 6562 * Lpi=[ h 0 ] 6563 * [ 0 h ] 6564 * [ h 0 ] 6565 * [ 0 h ] 6546 6566 * where h is the interpolation function for node i. 6547 6567 */ 6548 6549 6568 int num_dof=2; 6550 6569 IssmDouble basis[3]; … … 6552 6571 /*Cast gauss to GaussPenta*/ 6553 6572 _assert_(gauss_in->Enum()==GaussPentaEnum); 6554 GaussPenta* gauss = dynamic_cast<GaussPenta*>(gauss_in);6573 GaussPenta* gauss = xDynamicCast<GaussPenta*>(gauss_in); 6555 6574 6556 6575 /*Get basis in actual coordinate system: */ … … 6559 6578 basis[2]=gauss->coord3*(1-gauss->coord4)/2.0; 6560 6579 6561 /*Build L FS: */6580 /*Build LprimeFS: */ 6562 6581 for(int i=0;i<3;i++){ 6563 LFS[num_dof*3*0+num_dof*i+0] = basis[i]; 6564 LFS[num_dof*3*0+num_dof*i+1] = 0; 6565 LFS[num_dof*3*1+num_dof*i+0] = 0; 6566 LFS[num_dof*3*1+num_dof*i+1] = basis[i]; 6567 LFS[num_dof*3*2+num_dof*i+0] = basis[i]; 6568 LFS[num_dof*3*2+num_dof*i+1] = 0; 6569 LFS[num_dof*3*3+num_dof*i+0] = 0; 6570 LFS[num_dof*3*3+num_dof*i+1] = basis[i]; 6571 LFS[num_dof*3*4+num_dof*i+0] = basis[i]; 6572 LFS[num_dof*3*4+num_dof*i+1] = 0; 6573 LFS[num_dof*3*5+num_dof*i+0] = 0; 6574 LFS[num_dof*3*5+num_dof*i+1] = basis[i]; 6575 LFS[num_dof*3*6+num_dof*i+0] = basis[i]; 6576 LFS[num_dof*3*6+num_dof*i+1] = 0; 6577 LFS[num_dof*3*7+num_dof*i+0] = 0; 6578 LFS[num_dof*3*7+num_dof*i+1] = basis[i]; 6579 } 6580 }/*}}}*/ 6581 void StressbalanceAnalysis::GetLprimeSSAFS(IssmDouble* LprimeFS,Element* element,IssmDouble* xyz_list,Gauss* gauss_in){/*{{{*/ 6582 LprimeFS[num_dof*3*0+num_dof*i+0] = basis[i]; 6583 LprimeFS[num_dof*3*0+num_dof*i+1] = 0.; 6584 LprimeFS[num_dof*3*1+num_dof*i+0] = 0.; 6585 LprimeFS[num_dof*3*1+num_dof*i+1] = basis[i]; 6586 LprimeFS[num_dof*3*2+num_dof*i+0] = basis[i]; 6587 LprimeFS[num_dof*3*2+num_dof*i+1] = 0.; 6588 LprimeFS[num_dof*3*3+num_dof*i+0] = 0.; 6589 LprimeFS[num_dof*3*3+num_dof*i+1] = basis[i]; 6590 } 6591 }/*}}}*/ 6592 void StressbalanceAnalysis::GetLprimeSSAFS(IssmDouble* LprimeFS,Element* element,IssmDouble* xyz_list,Gauss* gauss_in){/*{{{*/ 6582 6593 /* Compute Lprime matrix. Lprime=[Lp1 Lp2 Lp3] where Lpi is square and of size numdof. 6583 6594 * For node i, Lpi can be expressed in the actual coordinate system … … 6601 6612 /*Cast gauss to GaussPenta*/ 6602 6613 _assert_(gauss_in->Enum()==GaussPentaEnum); 6603 GaussPenta* gauss = dynamic_cast<GaussPenta*>(gauss_in);6614 GaussPenta* gauss = xDynamicCast<GaussPenta*>(gauss_in); 6604 6615 6605 6616 /*Get basis in actual coordinate system: */ … … 6684 6695 } 6685 6696 }/*}}}*/ 6686 void StressbalanceAnalysis::GetLFSSSA(IssmDouble* LFS,Element* element,Gauss* gauss_in){/*{{{*/6697 void StressbalanceAnalysis::GetLFSSSA(IssmDouble* LFS,Element* element,Gauss* gauss_in){/*{{{*/ 6687 6698 /* Compute L matrix. L=[L1 L2 L3] where Li is square and of size numdof. 6688 6699 * For node i, Li can be expressed in the actual coordinate system … … 6700 6711 /*Cast gauss to GaussPenta*/ 6701 6712 _assert_(gauss_in->Enum()==GaussPentaEnum); 6702 GaussPenta* gauss = dynamic_cast<GaussPenta*>(gauss_in);6713 GaussPenta* gauss = xDynamicCast<GaussPenta*>(gauss_in); 6703 6714 6704 6715 /*Get basis in actual coordinate system: */ … … 6723 6734 } 6724 6735 }/*}}}*/ 6725 void StressbalanceAnalysis::GetLprimeFSSSA(IssmDouble* LprimeFS,Element* element,IssmDouble* xyz_list,Gauss* gauss_in){/*{{{*/ 6726 /* Compute Lprime matrix. Lprime=[Lp1 Lp2 Lp3] where Lpi is square and of size numdof. 6727 * For node i, Lpi can be expressed in the actual coordinate system 6736 void StressbalanceAnalysis::GetLSSAFS(IssmDouble* LFS,Element* element,Gauss* gauss_in){/*{{{*/ 6737 /* 6738 * Compute L matrix. L=[L1 L2 L3] where Li is square and of size numdof. 6739 * For node i, Li can be expressed in the actual coordinate system 6728 6740 * by: 6729 * Lpi=[ h 0 ] 6730 * [ 0 h ] 6731 * [ h 0 ] 6732 * [ 0 h ] 6741 * Li=[ h 0 ] 6742 * [ 0 h ] 6743 * [ h 0 ] 6744 * [ 0 h ] 6745 * [ h 0 ] 6746 * [ 0 h ] 6747 * [ h 0 ] 6748 * [ 0 h ] 6733 6749 * where h is the interpolation function for node i. 6734 6750 */ 6751 6735 6752 int num_dof=2; 6736 6753 IssmDouble basis[3]; … … 6738 6755 /*Cast gauss to GaussPenta*/ 6739 6756 _assert_(gauss_in->Enum()==GaussPentaEnum); 6740 GaussPenta* gauss = dynamic_cast<GaussPenta*>(gauss_in);6757 GaussPenta* gauss = xDynamicCast<GaussPenta*>(gauss_in); 6741 6758 6742 6759 /*Get basis in actual coordinate system: */ … … 6745 6762 basis[2]=gauss->coord3*(1-gauss->coord4)/2.0; 6746 6763 6747 /*Build L primeFS: */6764 /*Build LFS: */ 6748 6765 for(int i=0;i<3;i++){ 6749 LprimeFS[num_dof*3*0+num_dof*i+0] = basis[i]; 6750 LprimeFS[num_dof*3*0+num_dof*i+1] = 0.; 6751 LprimeFS[num_dof*3*1+num_dof*i+0] = 0.; 6752 LprimeFS[num_dof*3*1+num_dof*i+1] = basis[i]; 6753 LprimeFS[num_dof*3*2+num_dof*i+0] = basis[i]; 6754 LprimeFS[num_dof*3*2+num_dof*i+1] = 0.; 6755 LprimeFS[num_dof*3*3+num_dof*i+0] = 0.; 6756 LprimeFS[num_dof*3*3+num_dof*i+1] = basis[i]; 6757 } 6758 }/*}}}*/ 6759 void StressbalanceAnalysis::InputUpdateFromSolutionHOFS(IssmDouble* solution,Element* element){/*{{{*/ 6766 LFS[num_dof*3*0+num_dof*i+0] = basis[i]; 6767 LFS[num_dof*3*0+num_dof*i+1] = 0; 6768 LFS[num_dof*3*1+num_dof*i+0] = 0; 6769 LFS[num_dof*3*1+num_dof*i+1] = basis[i]; 6770 LFS[num_dof*3*2+num_dof*i+0] = basis[i]; 6771 LFS[num_dof*3*2+num_dof*i+1] = 0; 6772 LFS[num_dof*3*3+num_dof*i+0] = 0; 6773 LFS[num_dof*3*3+num_dof*i+1] = basis[i]; 6774 LFS[num_dof*3*4+num_dof*i+0] = basis[i]; 6775 LFS[num_dof*3*4+num_dof*i+1] = 0; 6776 LFS[num_dof*3*5+num_dof*i+0] = 0; 6777 LFS[num_dof*3*5+num_dof*i+1] = basis[i]; 6778 LFS[num_dof*3*6+num_dof*i+0] = basis[i]; 6779 LFS[num_dof*3*6+num_dof*i+1] = 0; 6780 LFS[num_dof*3*7+num_dof*i+0] = 0; 6781 LFS[num_dof*3*7+num_dof*i+1] = basis[i]; 6782 } 6783 }/*}}}*/ 6784 void StressbalanceAnalysis::InputUpdateFromSolutionHOFS(IssmDouble* solution,Element* element){/*{{{*/ 6760 6785 6761 6786 int i; … … 6854 6879 xDelete<int>(cs_list); 6855 6880 }/*}}}*/ 6856 void StressbalanceAnalysis::InputUpdateFromSolutionSSAFS(IssmDouble* solution,Element* element){/*{{{*/6881 void StressbalanceAnalysis::InputUpdateFromSolutionSSAFS(IssmDouble* solution,Element* element){/*{{{*/ 6857 6882 6858 6883 int i; … … 6960 6985 xDelete<int>(cs_list); 6961 6986 }/*}}}*/ 6962 void StressbalanceAnalysis::InputUpdateFromSolutionSSAHO(IssmDouble* solution,Element* element){/*{{{*/6987 void StressbalanceAnalysis::InputUpdateFromSolutionSSAHO(IssmDouble* solution,Element* element){/*{{{*/ 6963 6988 6964 6989 int i,domaintype; -
issm/trunk/src/c/analyses/StressbalanceAnalysis.h
r18301 r19105 13 13 public: 14 14 /*Model processing*/ 15 int DofsPerNode(int** doflist,int domaintype,int approximation);16 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum);17 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type);18 void CreateNodes(Nodes* nodes,IoModel* iomodel);19 15 void CreateConstraints(Constraints* constraints,IoModel* iomodel); 20 16 void CreateLoads(Loads* loads, IoModel* iomodel); 17 void CreateNodes(Nodes* nodes,IoModel* iomodel); 18 int DofsPerNode(int** doflist,int domaintype,int approximation); 19 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 20 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum); 21 21 22 22 /*Finite element Analysis*/ … … 26 26 ElementMatrix* CreateKMatrix(Element* element); 27 27 ElementVector* CreatePVector(Element* element); 28 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element);29 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index);30 void GetSolutionFromInputsHoriz(Vector<IssmDouble>* solution,Element* element);31 void InputUpdateFromSolution(IssmDouble* solution,Element* element);32 void UpdateConstraints(FemModel* femmodel);28 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 29 void GetSolutionFromInputsHoriz(Vector<IssmDouble>* solution,Element* element); 30 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 31 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 32 void UpdateConstraints(FemModel* femmodel); 33 33 34 34 /*SSA*/ 35 35 ElementMatrix* CreateJacobianMatrixSSA(Element* element); 36 36 ElementMatrix* CreateKMatrixSSA(Element* element); 37 ElementMatrix* CreateKMatrixSSAViscous(Element* element);38 37 ElementMatrix* CreateKMatrixSSAFriction(Element* element); 39 38 ElementMatrix* CreateKMatrixSSALateralFriction(Element* element); 39 ElementMatrix* CreateKMatrixSSAViscous(Element* element); 40 40 ElementVector* CreatePVectorSSA(Element* element); 41 ElementVector* CreatePVectorSSAFront(Element* element); 41 42 ElementVector* CreatePVectorSSADrivingStress(Element* element); 42 ElementVector* CreatePVectorSSAFront(Element* element); 43 void GetBSSA(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 44 void GetBSSAprime(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 45 void GetBSSAFriction(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 46 void InputUpdateFromSolutionSSA(IssmDouble* solution,Element* element); 43 void GetBSSA(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 44 void GetBSSAFriction(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 45 void GetBSSAprime(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 46 void InputUpdateFromSolutionSSA(IssmDouble* solution,Element* element); 47 47 /*L1L2*/ 48 48 ElementMatrix* CreateKMatrixL1L2(Element* element); 49 ElementMatrix* CreateKMatrixL1L2Friction(Element* element); 49 50 ElementMatrix* CreateKMatrixL1L2Viscous(Element* element); 50 ElementMatrix* CreateKMatrixL1L2Friction(Element* element);51 51 ElementVector* CreatePVectorL1L2(Element* element); 52 ElementVector* CreatePVectorL1L2Front(Element* element); 52 53 ElementVector* CreatePVectorL1L2DrivingStress(Element* element); 53 ElementVector* CreatePVectorL1L2Front(Element* element); 54 void InputUpdateFromSolutionL1L2(IssmDouble* solution,Element* element); 54 void InputUpdateFromSolutionL1L2(IssmDouble* solution,Element* element); 55 55 /*HO*/ 56 56 ElementMatrix* CreateJacobianMatrixHO(Element* element); 57 57 ElementMatrix* CreateKMatrixHO(Element* element); 58 ElementMatrix* CreateKMatrixHOFriction(Element* element); 58 59 ElementMatrix* CreateKMatrixHOViscous(Element* element); 59 ElementMatrix* CreateKMatrixHOFriction(Element* element);60 60 ElementVector* CreatePVectorHO(Element* element); 61 ElementVector* CreatePVectorHOFront(Element* element); 61 62 ElementVector* CreatePVectorHODrivingStress(Element* element); 62 ElementVector* CreatePVectorHOFront(Element* element); 63 void GetBHO(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 64 void GetBHOprime(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 65 void GetBHOFriction(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 66 void InputUpdateFromSolutionHO(IssmDouble* solution,Element* element); 63 void GetBHO(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 64 void GetBHOFriction(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 65 void GetBHOprime(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 66 void InputUpdateFromSolutionHO(IssmDouble* solution,Element* element); 67 67 /*FS*/ 68 68 ElementVector* CreateDVectorFS(Element* element); 69 69 ElementMatrix* CreateJacobianMatrixFS(Element* element); 70 70 ElementMatrix* CreateKMatrixFS(Element* element); 71 ElementMatrix* CreateKMatrixFSViscousLATH(Element* element);72 ElementMatrix* CreateKMatrixFSViscousXTH(Element* element);73 ElementMatrix* CreateKMatrixFSViscous(Element* element);74 71 ElementMatrix* CreateKMatrixFSFriction(Element* element); 75 72 ElementMatrix* CreateKMatrixFSShelf(Element* element); 73 ElementMatrix* CreateKMatrixFSViscous(Element* element); 74 ElementMatrix* CreateKMatrixFSViscousLA(Element* element); 75 ElementMatrix* CreateKMatrixFSViscousXTH(Element* element); 76 76 ElementVector* CreatePVectorFS(Element* element); 77 ElementVector* CreatePVectorFSFriction(Element* element); 78 ElementVector* CreatePVectorFSFront(Element* element); 79 ElementVector* CreatePVectorFSShelf(Element* element); 80 ElementVector* CreatePVectorFSStress(Element* element); 77 81 ElementVector* CreatePVectorFSViscous(Element* element); 78 ElementVector* CreatePVectorFSViscousLA TH(Element* element);82 ElementVector* CreatePVectorFSViscousLA(Element* element); 79 83 ElementVector* CreatePVectorFSViscousXTH(Element* element); 80 ElementVector* CreatePVectorFSShelf(Element* element); 81 ElementVector* CreatePVectorFSFront(Element* element); 82 ElementVector* CreatePVectorFSFriction(Element* element); 83 ElementVector* CreatePVectorFSStress(Element* element); 84 void GetBFS(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 85 void GetBFSprime(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 86 void GetBFSvel(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 87 void GetBFSprimevel(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 88 void GetBFSFriction(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 89 void GetBFSUzawa(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 90 void GetBFSprimeUzawa(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 91 void GetCFS(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 92 void GetCFSprime(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 93 void GetSolutionFromInputsFS(Vector<IssmDouble>* solution,Element* element); 94 void InputUpdateFromSolutionFS(IssmDouble* solution,Element* element); 95 void InputUpdateFromSolutionFSXTH_d(Elements* elements,Parameters* parameters); 96 void InputUpdateFromSolutionFSXTH_tau(Elements* elements,Parameters* parameters); 97 void InitializeXTH(Elements* elements,Parameters* parameters); 84 void GetBFS(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 85 void GetBFSFriction(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 86 void GetBFSprime(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 87 void GetBFSprimeUzawa(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 88 void GetBFSprimevel(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 89 void GetBFSUzawa(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 90 void GetBFSvel(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 91 void GetCFS(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 92 void GetCFSprime(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss); 93 void GetSolutionFromInputsFS(Vector<IssmDouble>* solution,Element* element); 94 void InitializeXTH(Elements* elements,Parameters* parameters); 95 void InputUpdateFromSolutionFS(IssmDouble* solution,Element* element); 96 void InputUpdateFromSolutionFSXTH_d(Elements* elements,Parameters* parameters); 97 void InputUpdateFromSolutionFSXTH_tau(Elements* elements,Parameters* parameters); 98 98 /*Coupling*/ 99 ElementMatrix* CreateKMatrixCouplingHOFS(Element* element); 100 ElementMatrix* CreateKMatrixCouplingSSAFS(Element* element); 101 ElementMatrix* CreateKMatrixCouplingSSAFSFriction(Element* element); 102 ElementMatrix* CreateKMatrixCouplingSSAFSViscous(Element* element); 103 ElementMatrix* CreateKMatrixCouplingSSAHO(Element* element); 104 ElementMatrix* CreateKMatrixCouplingSSAHOFriction(Element* element); 105 ElementMatrix* CreateKMatrixCouplingSSAHOViscous(Element* element); 106 ElementMatrix* CreateKMatrixHOFS(Element* element); 107 ElementMatrix* CreateKMatrixSSAFS(Element* element); 108 ElementMatrix* CreateKMatrixSSAHO(Element* element); 99 109 ElementMatrix* CreateKMatrixSSA3d(Element* element); 100 110 ElementMatrix* CreateKMatrixSSA3dFriction(Element* element); 101 111 ElementMatrix* CreateKMatrixSSA3dViscous(Element* element); 102 ElementMatrix* CreateKMatrixHOFS(Element* element); 103 ElementMatrix* CreateKMatrixSSAHO(Element* element); 104 ElementMatrix* CreateKMatrixSSAFS(Element* element); 105 ElementMatrix* CreateKMatrixCouplingHOFS(Element* element); 106 ElementMatrix* CreateKMatrixCouplingSSAHO(Element* element); 107 ElementMatrix* CreateKMatrixCouplingSSAHOFriction(Element* element); 108 ElementMatrix* CreateKMatrixCouplingSSAHOViscous(Element* element); 109 ElementMatrix* CreateKMatrixCouplingSSAFS(Element* element); 110 ElementMatrix* CreateKMatrixCouplingSSAFSFriction(Element* element); 111 ElementMatrix* CreateKMatrixCouplingSSAFSViscous(Element* element); 112 ElementVector* CreatePVectorSSAFS(Element* element); 112 113 ElementVector* CreatePVectorSSAHO(Element* element); 113 ElementVector* CreatePVectorSSAFS(Element* element);114 114 ElementVector* CreatePVectorCouplingSSAFS(Element* element); 115 115 ElementVector* CreatePVectorCouplingSSAFSFriction(Element* element); … … 119 119 ElementVector* CreatePVectorCouplingHOFSFriction(Element* element); 120 120 ElementVector* CreatePVectorCouplingHOFSViscous(Element* element); 121 void GetBSSAHO(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss);122 void GetBSSAFS(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss);123 void GetBprimeSSAFS(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss);124 void GetBSSAFSTria(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss);125 void GetBprimeSSAFSTria(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss);126 void GetLFSSSA(IssmDouble* L,Element* element,Gauss* gauss);127 void GetLSSAFS(IssmDouble* L,Element* element,Gauss* gauss);128 void GetLprimeFSSSA(IssmDouble* Lprime,Element* element,IssmDouble* xyz_list,Gauss* gauss);129 void GetLprimeSSAFS(IssmDouble* Lprime,Element* element,IssmDouble* xyz_list,Gauss* gauss);130 void InputUpdateFromSolutionHOFS(IssmDouble* solution,Element* element);131 void InputUpdateFromSolutionSSAFS(IssmDouble* solution,Element* element);132 void InputUpdateFromSolutionSSAHO(IssmDouble* solution,Element* element);121 void GetBprimeSSAFS(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss); 122 void GetBprimeSSAFSTria(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss); 123 void GetBSSAFS(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss); 124 void GetBSSAFSTria(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss); 125 void GetBSSAHO(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss); 126 void GetLFSSSA(IssmDouble* L,Element* element,Gauss* gauss); 127 void GetLprimeFSSSA(IssmDouble* Lprime,Element* element,IssmDouble* xyz_list,Gauss* gauss); 128 void GetLprimeSSAFS(IssmDouble* Lprime,Element* element,IssmDouble* xyz_list,Gauss* gauss); 129 void GetLSSAFS(IssmDouble* L,Element* element,Gauss* gauss); 130 void InputUpdateFromSolutionHOFS(IssmDouble* solution,Element* element); 131 void InputUpdateFromSolutionSSAFS(IssmDouble* solution,Element* element); 132 void InputUpdateFromSolutionSSAHO(IssmDouble* solution,Element* element); 133 133 }; 134 134 #endif -
issm/trunk/src/c/analyses/StressbalanceSIAAnalysis.cpp
r18301 r19105 7 7 8 8 /*Model processing*/ 9 int StressbalanceSIAAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/10 return 2;11 }/*}}}*/12 void StressbalanceSIAAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/13 14 /*No specific parameters*/15 16 }/*}}}*/17 void StressbalanceSIAAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/18 19 /*Fetch data needed: */20 bool isSIA;21 bool islevelset;22 iomodel->Constant(&isSIA,FlowequationIsSIAEnum);23 iomodel->Constant(&islevelset,TransientIslevelsetEnum);24 25 /*Now, is the flag SIA on? otherwise, do nothing: */26 if (!isSIA)return;27 28 iomodel->FetchData(1,FlowequationElementEquationEnum);29 30 /*Update elements: */31 int counter=0;32 for(int i=0;i<iomodel->numberofelements;i++){33 if(iomodel->my_elements[i]){34 Element* element=(Element*)elements->GetObjectByOffset(counter);35 element->Update(i,iomodel,analysis_counter,analysis_type,P1Enum);36 counter++;37 }38 }39 40 iomodel->FetchDataToInput(elements,ThicknessEnum);41 iomodel->FetchDataToInput(elements,FrictionCoefficientEnum);42 iomodel->FetchDataToInput(elements,MaskGroundediceLevelsetEnum);43 if(islevelset){44 iomodel->FetchDataToInput(elements,IceMaskNodeActivationEnum);45 if(iomodel->domaintype!=Domain2DhorizontalEnum)46 iomodel->FetchDataToInput(elements,MeshVertexonbaseEnum); // required for updating active nodes47 }48 49 /*Free data: */50 iomodel->DeleteData(1,FlowequationElementEquationEnum);51 }/*}}}*/52 void StressbalanceSIAAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/53 54 /*Intermediaries*/55 bool isSIA;56 Node* node = NULL;57 58 /*Fetch parameters: */59 iomodel->Constant(&isSIA,FlowequationIsSIAEnum);60 61 /*Now, is the flag isSIA on? otherwise, do nothing: */62 if(!isSIA) return;63 64 /*First create nodes*/65 int lid=0;66 iomodel->FetchData(4,FlowequationBorderSSAEnum,FlowequationBorderFSEnum,FlowequationVertexEquationEnum,StressbalanceReferentialEnum);67 if(iomodel->domaintype!=Domain2DhorizontalEnum){68 iomodel->FetchData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum);69 }70 71 for(int i=0;i<iomodel->numberofvertices;i++){72 if(iomodel->my_vertices[i]){73 74 /*Create new node if is in this processor's partition*/75 node = new Node(iomodel->nodecounter+i+1,i,lid++,i,iomodel,StressbalanceSIAAnalysisEnum,reCast<int>(iomodel->Data(FlowequationVertexEquationEnum)[i]));76 77 /*Deactivate node if not SIA*/78 if(reCast<int>(iomodel->Data(FlowequationVertexEquationEnum)[i])!=SIAApproximationEnum){79 node->Deactivate();80 }81 82 /*Add to Nodes dataset*/83 nodes->AddObject(node);84 }85 }86 87 iomodel->DeleteData(6,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum,FlowequationBorderSSAEnum,FlowequationBorderFSEnum,88 FlowequationVertexEquationEnum,StressbalanceReferentialEnum);89 90 }/*}}}*/91 9 void StressbalanceSIAAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 92 10 … … 142 60 143 61 /*No loads*/ 62 63 }/*}}}*/ 64 void StressbalanceSIAAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 65 66 /*Intermediaries*/ 67 bool isSIA; 68 Node* node = NULL; 69 70 /*Fetch parameters: */ 71 iomodel->Constant(&isSIA,FlowequationIsSIAEnum); 72 73 /*Now, is the flag isSIA on? otherwise, do nothing: */ 74 if(!isSIA) return; 75 76 /*First create nodes*/ 77 int lid=0; 78 iomodel->FetchData(4,FlowequationBorderSSAEnum,FlowequationBorderFSEnum,FlowequationVertexEquationEnum,StressbalanceReferentialEnum); 79 if(iomodel->domaintype!=Domain2DhorizontalEnum){ 80 iomodel->FetchData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 81 } 82 83 for(int i=0;i<iomodel->numberofvertices;i++){ 84 if(iomodel->my_vertices[i]){ 85 86 /*Create new node if is in this processor's partition*/ 87 node = new Node(iomodel->nodecounter+i+1,i,lid++,i,iomodel,StressbalanceSIAAnalysisEnum,reCast<int>(iomodel->Data(FlowequationVertexEquationEnum)[i])); 88 89 /*Deactivate node if not SIA*/ 90 if(reCast<int>(iomodel->Data(FlowequationVertexEquationEnum)[i])!=SIAApproximationEnum){ 91 node->Deactivate(); 92 } 93 94 /*Add to Nodes dataset*/ 95 nodes->AddObject(node); 96 } 97 } 98 99 iomodel->DeleteData(6,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum,FlowequationBorderSSAEnum,FlowequationBorderFSEnum, 100 FlowequationVertexEquationEnum,StressbalanceReferentialEnum); 101 102 }/*}}}*/ 103 int StressbalanceSIAAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/ 104 return 2; 105 }/*}}}*/ 106 void StressbalanceSIAAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ 107 108 /*Fetch data needed: */ 109 bool isSIA; 110 bool islevelset; 111 iomodel->Constant(&isSIA,FlowequationIsSIAEnum); 112 iomodel->Constant(&islevelset,TransientIslevelsetEnum); 113 114 /*Now, is the flag SIA on? otherwise, do nothing: */ 115 if (!isSIA)return; 116 117 iomodel->FetchData(1,FlowequationElementEquationEnum); 118 119 /*Update elements: */ 120 int counter=0; 121 for(int i=0;i<iomodel->numberofelements;i++){ 122 if(iomodel->my_elements[i]){ 123 Element* element=(Element*)elements->GetObjectByOffset(counter); 124 element->Update(i,iomodel,analysis_counter,analysis_type,P1Enum); 125 counter++; 126 } 127 } 128 129 iomodel->FetchDataToInput(elements,ThicknessEnum); 130 iomodel->FetchDataToInput(elements,FrictionCoefficientEnum); 131 iomodel->FetchDataToInput(elements,MaskGroundediceLevelsetEnum); 132 if(islevelset){ 133 iomodel->FetchDataToInput(elements,IceMaskNodeActivationEnum); 134 if(iomodel->domaintype!=Domain2DhorizontalEnum) 135 iomodel->FetchDataToInput(elements,MeshVertexonbaseEnum); // required for updating active nodes 136 } 137 138 /*Free data: */ 139 iomodel->DeleteData(1,FlowequationElementEquationEnum); 140 }/*}}}*/ 141 void StressbalanceSIAAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 142 143 /*No specific parameters*/ 144 144 145 145 }/*}}}*/ … … 461 461 462 462 }/*}}}*/ 463 void StressbalanceSIAAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/463 void StressbalanceSIAAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 464 464 465 465 IssmDouble vx,vy; … … 494 494 xDelete<IssmDouble>(values); 495 495 }/*}}}*/ 496 void StressbalanceSIAAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/496 void StressbalanceSIAAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 497 497 _error_("Not implemented yet"); 498 498 }/*}}}*/ 499 void StressbalanceSIAAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/499 void StressbalanceSIAAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 500 500 501 501 int i,domaintype; … … 581 581 xDelete<int>(doflist); 582 582 }/*}}}*/ 583 void StressbalanceSIAAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/583 void StressbalanceSIAAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 584 584 585 585 bool islevelset; -
issm/trunk/src/c/analyses/StressbalanceSIAAnalysis.h
r18301 r19105 13 13 public: 14 14 /*Model processing*/ 15 int DofsPerNode(int** doflist,int domaintype,int approximation);16 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum);17 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type);18 void CreateNodes(Nodes* nodes,IoModel* iomodel);19 15 void CreateConstraints(Constraints* constraints,IoModel* iomodel); 20 16 void CreateLoads(Loads* loads, IoModel* iomodel); 17 void CreateNodes(Nodes* nodes,IoModel* iomodel); 18 int DofsPerNode(int** doflist,int domaintype,int approximation); 19 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 20 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum); 21 21 22 22 /*Finite element Analysis*/ … … 30 30 ElementVector* CreatePVector2D(Element* element); 31 31 ElementVector* CreatePVector3D(Element* element); 32 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element);33 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index);34 void InputUpdateFromSolution(IssmDouble* solution,Element* element);35 void UpdateConstraints(FemModel* femmodel);32 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 33 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 34 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 35 void UpdateConstraints(FemModel* femmodel); 36 36 }; 37 37 #endif -
issm/trunk/src/c/analyses/StressbalanceVerticalAnalysis.cpp
r18301 r19105 7 7 8 8 /*Model processing*/ 9 int StressbalanceVerticalAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/10 return 1;11 }/*}}}*/12 void StressbalanceVerticalAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/13 14 /*No specific parameters*/15 16 }/*}}}*/17 void StressbalanceVerticalAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/18 19 /*return if not 3d mesh*/20 if(iomodel->domaintype!=Domain3DEnum) return;21 22 /*Update elements: */23 int counter=0;24 for(int i=0;i<iomodel->numberofelements;i++){25 if(iomodel->my_elements[i]){26 Element* element=(Element*)elements->GetObjectByOffset(counter);27 element->Update(i,iomodel,analysis_counter,analysis_type,P1Enum);28 counter++;29 }30 }31 32 iomodel->FetchDataToInput(elements,ThicknessEnum);33 iomodel->FetchDataToInput(elements,SurfaceEnum);34 iomodel->FetchDataToInput(elements,BaseEnum);35 iomodel->FetchDataToInput(elements,MaskIceLevelsetEnum);36 if(iomodel->domaintype!=Domain2DhorizontalEnum){37 iomodel->FetchDataToInput(elements,MeshVertexonbaseEnum);38 iomodel->FetchDataToInput(elements,MeshVertexonsurfaceEnum);39 }40 iomodel->FetchDataToInput(elements,BasalforcingsGroundediceMeltingRateEnum);41 iomodel->FetchDataToInput(elements,BasalforcingsFloatingiceMeltingRateEnum);42 iomodel->FetchDataToInput(elements,VxEnum,0.);43 iomodel->FetchDataToInput(elements,VyEnum,0.);44 }/*}}}*/45 void StressbalanceVerticalAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/46 47 /*return if not 3d mesh*/48 if(iomodel->domaintype!=Domain3DEnum) return;49 50 iomodel->FetchData(3,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum,FlowequationVertexEquationEnum);51 ::CreateNodes(nodes,iomodel,StressbalanceVerticalAnalysisEnum,P1Enum);52 iomodel->DeleteData(3,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum,FlowequationVertexEquationEnum);53 }/*}}}*/54 9 void StressbalanceVerticalAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 55 10 … … 98 53 99 54 }/*}}}*/ 55 void StressbalanceVerticalAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 56 57 /*return if not 3d mesh*/ 58 if(iomodel->domaintype!=Domain3DEnum) return; 59 60 iomodel->FetchData(3,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum,FlowequationVertexEquationEnum); 61 ::CreateNodes(nodes,iomodel,StressbalanceVerticalAnalysisEnum,P1Enum); 62 iomodel->DeleteData(3,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum,FlowequationVertexEquationEnum); 63 }/*}}}*/ 64 int StressbalanceVerticalAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/ 65 return 1; 66 }/*}}}*/ 67 void StressbalanceVerticalAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ 68 69 /*return if not 3d mesh*/ 70 if(iomodel->domaintype!=Domain3DEnum) return; 71 72 /*Update elements: */ 73 int counter=0; 74 for(int i=0;i<iomodel->numberofelements;i++){ 75 if(iomodel->my_elements[i]){ 76 Element* element=(Element*)elements->GetObjectByOffset(counter); 77 element->Update(i,iomodel,analysis_counter,analysis_type,P1Enum); 78 counter++; 79 } 80 } 81 82 iomodel->FetchDataToInput(elements,ThicknessEnum); 83 iomodel->FetchDataToInput(elements,SurfaceEnum); 84 iomodel->FetchDataToInput(elements,BaseEnum); 85 iomodel->FetchDataToInput(elements,MaskIceLevelsetEnum); 86 if(iomodel->domaintype!=Domain2DhorizontalEnum){ 87 iomodel->FetchDataToInput(elements,MeshVertexonbaseEnum); 88 iomodel->FetchDataToInput(elements,MeshVertexonsurfaceEnum); 89 } 90 iomodel->FetchDataToInput(elements,BasalforcingsGroundediceMeltingRateEnum); 91 iomodel->FetchDataToInput(elements,BasalforcingsFloatingiceMeltingRateEnum); 92 iomodel->FetchDataToInput(elements,VxEnum,0.); 93 iomodel->FetchDataToInput(elements,VyEnum,0.); 94 }/*}}}*/ 95 void StressbalanceVerticalAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 96 97 /*No specific parameters*/ 98 99 }/*}}}*/ 100 100 101 101 /*Finite Element Analysis*/ … … 125 125 return Ke; 126 126 127 }/*}}}*/ 128 ElementMatrix* StressbalanceVerticalAnalysis::CreateKMatrixSurface(Element* element){/*{{{*/ 129 130 131 if(!element->IsOnSurface()) return NULL; 132 133 /*Intermediaries*/ 134 IssmDouble D,Jdet,normal[3]; 135 IssmDouble *xyz_list = NULL; 136 137 /*Fetch number of nodes and dof for this finite element*/ 138 int numnodes = element->GetNumberOfNodes(); 139 140 /*Initialize Element matrix and vectors*/ 141 ElementMatrix* Ke = element->NewElementMatrix(NoneApproximationEnum); 142 IssmDouble* basis = xNew<IssmDouble>(numnodes); 143 144 /*Retrieve all inputs and parameters*/ 145 element->GetVerticesCoordinatesTop(&xyz_list); 146 147 /* Start looping on the number of gaussian points: */ 148 Gauss* gauss = element->NewGaussTop(2); 149 element->NormalTop(&normal[0],xyz_list); 150 for(int ig=gauss->begin();ig<gauss->end();ig++){ 151 gauss->GaussPoint(ig); 152 153 element->JacobianDeterminantTop(&Jdet,xyz_list,gauss); 154 element->NodalFunctions(basis,gauss); 155 D = -gauss->weight*Jdet*normal[2]; 156 157 TripleMultiply( basis,1,numnodes,1, 158 &D,1,1,0, 159 basis,1,numnodes,0, 160 &Ke->values[0],1); 161 } 162 163 /*Clean up and return*/ 164 delete gauss; 165 xDelete<IssmDouble>(xyz_list); 166 xDelete<IssmDouble>(basis); 167 return Ke; 127 168 }/*}}}*/ 128 169 ElementMatrix* StressbalanceVerticalAnalysis::CreateKMatrixVolume(Element* element){/*{{{*/ … … 167 208 168 209 }/*}}}*/ 169 ElementMatrix* StressbalanceVerticalAnalysis::CreateKMatrixSurface(Element* element){/*{{{*/170 171 172 if(!element->IsOnSurface()) return NULL;173 174 /*Intermediaries*/175 IssmDouble D,Jdet,normal[3];176 IssmDouble *xyz_list = NULL;177 178 /*Fetch number of nodes and dof for this finite element*/179 int numnodes = element->GetNumberOfNodes();180 181 /*Initialize Element matrix and vectors*/182 ElementMatrix* Ke = element->NewElementMatrix(NoneApproximationEnum);183 IssmDouble* basis = xNew<IssmDouble>(numnodes);184 185 /*Retrieve all inputs and parameters*/186 element->GetVerticesCoordinatesTop(&xyz_list);187 188 /* Start looping on the number of gaussian points: */189 Gauss* gauss = element->NewGaussTop(2);190 element->NormalTop(&normal[0],xyz_list);191 for(int ig=gauss->begin();ig<gauss->end();ig++){192 gauss->GaussPoint(ig);193 194 element->JacobianDeterminantTop(&Jdet,xyz_list,gauss);195 element->NodalFunctions(basis,gauss);196 D = -gauss->weight*Jdet*normal[2];197 198 TripleMultiply( basis,1,numnodes,1,199 &D,1,1,0,200 basis,1,numnodes,0,201 &Ke->values[0],1);202 }203 204 /*Clean up and return*/205 delete gauss;206 xDelete<IssmDouble>(xyz_list);207 xDelete<IssmDouble>(basis);208 return Ke;209 }/*}}}*/210 210 ElementVector* StressbalanceVerticalAnalysis::CreatePVector(Element* element){/*{{{*/ 211 211 … … 218 218 delete pe1; 219 219 delete pe2; 220 return pe;221 }/*}}}*/222 ElementVector* StressbalanceVerticalAnalysis::CreatePVectorVolume(Element* element){/*{{{*/223 224 /*Intermediaries*/225 int approximation;226 IssmDouble Jdet,dudx,dvdy,dwdz;227 IssmDouble du[3],dv[3],dw[3];228 IssmDouble* xyz_list = NULL;229 230 /*Fetch number of nodes for this finite element*/231 int numnodes = element->GetNumberOfNodes();232 233 /*Initialize Element vector and basis functions*/234 ElementVector* pe = element->NewElementVector();235 IssmDouble* basis = xNew<IssmDouble>(numnodes);236 237 /*Retrieve all inputs and parameters*/238 element->GetVerticesCoordinates(&xyz_list);239 element->GetInputValue(&approximation,ApproximationEnum);240 Input* vx_input=element->GetInput(VxEnum); _assert_(vx_input);241 Input* vy_input=element->GetInput(VyEnum); _assert_(vy_input);242 Input* vzFS_input=NULL;243 if(approximation==HOFSApproximationEnum || approximation==SSAFSApproximationEnum){244 vzFS_input=element->GetInput(VzFSEnum); _assert_(vzFS_input);245 }246 247 /* Start looping on the number of gaussian points: */248 Gauss* gauss=element->NewGauss(2);249 for(int ig=gauss->begin();ig<gauss->end();ig++){250 gauss->GaussPoint(ig);251 252 element->JacobianDeterminant(&Jdet,xyz_list,gauss);253 element->NodalFunctions(basis,gauss);254 255 vx_input->GetInputDerivativeValue(&du[0],xyz_list,gauss);256 vy_input->GetInputDerivativeValue(&dv[0],xyz_list,gauss);257 if(approximation==HOFSApproximationEnum || approximation==SSAFSApproximationEnum){258 vzFS_input->GetInputDerivativeValue(&dw[0],xyz_list,gauss);259 dwdz=dw[2];260 }261 else dwdz=0;262 dudx=du[0];263 dvdy=dv[1];264 265 for(int i=0;i<numnodes;i++) pe->values[i] += (dudx+dvdy+dwdz)*Jdet*gauss->weight*basis[i];266 }267 268 /*Clean up and return*/269 delete gauss;270 xDelete<IssmDouble>(basis);271 xDelete<IssmDouble>(xyz_list);272 220 return pe; 273 221 }/*}}}*/ … … 338 286 return pe; 339 287 }/*}}}*/ 340 void StressbalanceVerticalAnalysis::GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 288 ElementVector* StressbalanceVerticalAnalysis::CreatePVectorVolume(Element* element){/*{{{*/ 289 290 /*Intermediaries*/ 291 int approximation; 292 IssmDouble Jdet,dudx,dvdy,dwdz; 293 IssmDouble du[3],dv[3],dw[3]; 294 IssmDouble* xyz_list = NULL; 295 296 /*Fetch number of nodes for this finite element*/ 297 int numnodes = element->GetNumberOfNodes(); 298 299 /*Initialize Element vector and basis functions*/ 300 ElementVector* pe = element->NewElementVector(); 301 IssmDouble* basis = xNew<IssmDouble>(numnodes); 302 303 /*Retrieve all inputs and parameters*/ 304 element->GetVerticesCoordinates(&xyz_list); 305 element->GetInputValue(&approximation,ApproximationEnum); 306 Input* vx_input=element->GetInput(VxEnum); _assert_(vx_input); 307 Input* vy_input=element->GetInput(VyEnum); _assert_(vy_input); 308 Input* vzFS_input=NULL; 309 if(approximation==HOFSApproximationEnum || approximation==SSAFSApproximationEnum){ 310 vzFS_input=element->GetInput(VzFSEnum); _assert_(vzFS_input); 311 } 312 313 /* Start looping on the number of gaussian points: */ 314 Gauss* gauss=element->NewGauss(2); 315 for(int ig=gauss->begin();ig<gauss->end();ig++){ 316 gauss->GaussPoint(ig); 317 318 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 319 element->NodalFunctions(basis,gauss); 320 321 vx_input->GetInputDerivativeValue(&du[0],xyz_list,gauss); 322 vy_input->GetInputDerivativeValue(&dv[0],xyz_list,gauss); 323 if(approximation==HOFSApproximationEnum || approximation==SSAFSApproximationEnum){ 324 vzFS_input->GetInputDerivativeValue(&dw[0],xyz_list,gauss); 325 dwdz=dw[2]; 326 } 327 else dwdz=0; 328 dudx=du[0]; 329 dvdy=dv[1]; 330 331 for(int i=0;i<numnodes;i++) pe->values[i] += (dudx+dvdy+dwdz)*Jdet*gauss->weight*basis[i]; 332 } 333 334 /*Clean up and return*/ 335 delete gauss; 336 xDelete<IssmDouble>(basis); 337 xDelete<IssmDouble>(xyz_list); 338 return pe; 339 }/*}}}*/ 340 void StressbalanceVerticalAnalysis::GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 341 341 /* Compute B matrix. B=[dh1/dz dh2/dz dh3/dz dh4/dz dh5/dz dh6/dz]; 342 342 where hi is the interpolation function for node i.*/ … … 357 357 xDelete<IssmDouble>(dbasis); 358 358 }/*}}}*/ 359 void StressbalanceVerticalAnalysis::GetBprime(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/359 void StressbalanceVerticalAnalysis::GetBprime(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 360 360 361 361 element->NodalFunctions(Bprime,gauss); 362 362 363 363 }/*}}}*/ 364 void StressbalanceVerticalAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/364 void StressbalanceVerticalAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 365 365 element->GetSolutionFromInputsOneDof(solution,VzEnum); 366 366 }/*}}}*/ 367 void StressbalanceVerticalAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/367 void StressbalanceVerticalAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 368 368 _error_("Not implemented yet"); 369 369 }/*}}}*/ 370 void StressbalanceVerticalAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/370 void StressbalanceVerticalAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 371 371 372 372 int numnodes = element->GetNumberOfNodes(); … … 481 481 xDelete<int>(doflist); 482 482 }/*}}}*/ 483 void StressbalanceVerticalAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/483 void StressbalanceVerticalAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 484 484 /*Default, do nothing*/ 485 485 return; -
issm/trunk/src/c/analyses/StressbalanceVerticalAnalysis.h
r18301 r19105 13 13 public: 14 14 /*Model processing*/ 15 int DofsPerNode(int** doflist,int domaintype,int approximation);16 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum);17 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type);18 void CreateNodes(Nodes* nodes,IoModel* iomodel);19 15 void CreateConstraints(Constraints* constraints,IoModel* iomodel); 20 16 void CreateLoads(Loads* loads, IoModel* iomodel); 17 void CreateNodes(Nodes* nodes,IoModel* iomodel); 18 int DofsPerNode(int** doflist,int domaintype,int approximation); 19 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 20 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum); 21 21 22 22 /*Finite element Analysis*/ … … 25 25 ElementMatrix* CreateJacobianMatrix(Element* element); 26 26 ElementMatrix* CreateKMatrix(Element* element); 27 ElementMatrix* CreateKMatrixSurface(Element* element); 27 28 ElementMatrix* CreateKMatrixVolume(Element* element); 28 ElementMatrix* CreateKMatrixSurface(Element* element);29 29 ElementVector* CreatePVector(Element* element); 30 ElementVector* CreatePVectorBase(Element* element); 30 31 ElementVector* CreatePVectorVolume(Element* element); 31 ElementVector* CreatePVectorBase(Element* element); 32 void GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss); 33 void GetBprime(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss); 34 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 35 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 36 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 37 void UpdateConstraints(FemModel* femmodel); 32 void GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss); 33 void GetBprime(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss); 34 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 35 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 36 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 37 void UpdateConstraints(FemModel* femmodel); 38 38 }; 39 39 #endif -
issm/trunk/src/c/analyses/ThermalAnalysis.cpp
r18301 r19105 6 6 7 7 /*Model processing*/ 8 void ThermalAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 9 10 /*Only 3d mesh supported*/ 11 int finiteelement = P1Enum; 12 if(iomodel->domaintype==Domain3DEnum){ 13 IoModelToConstraintsx(constraints,iomodel,ThermalSpctemperatureEnum,ThermalAnalysisEnum,finiteelement); 14 } 15 16 }/*}}}*/ 17 void ThermalAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 18 19 if(iomodel->domaintype==Domain2DhorizontalEnum) _error_("2d meshes not supported yet"); 20 21 /*create penalties for nodes: no node can have a temperature over the melting point*/ 22 iomodel->FetchData(1,ThermalSpctemperatureEnum); 23 CreateSingleNodeToElementConnectivity(iomodel); 24 25 for(int i=0;i<iomodel->numberofvertices;i++){ 26 27 /*keep only this partition's nodes:*/ 28 if(iomodel->my_vertices[i]){ 29 if (xIsNan<IssmDouble>(iomodel->Data(ThermalSpctemperatureEnum)[i])){ //No penalty applied on spc nodes! 30 loads->AddObject(new Pengrid(iomodel->loadcounter+i+1,i,iomodel,ThermalAnalysisEnum)); 31 } 32 } 33 } 34 iomodel->DeleteData(1,ThermalSpctemperatureEnum); 35 36 }/*}}}*/ 37 void ThermalAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 38 39 int finiteelement = P1Enum; 40 if(iomodel->domaintype==Domain3DEnum) iomodel->FetchData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 41 ::CreateNodes(nodes,iomodel,ThermalAnalysisEnum,finiteelement); 42 iomodel->DeleteData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 43 }/*}}}*/ 8 44 int ThermalAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/ 9 45 return 1; 10 }/*}}}*/11 void ThermalAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/12 13 int numoutputs;14 char** requestedoutputs = NULL;15 16 parameters->AddObject(iomodel->CopyConstantObject(ThermalMaxiterEnum));17 parameters->AddObject(iomodel->CopyConstantObject(ThermalStabilizationEnum));18 parameters->AddObject(iomodel->CopyConstantObject(ThermalPenaltyFactorEnum));19 parameters->AddObject(iomodel->CopyConstantObject(ThermalPenaltyThresholdEnum));20 parameters->AddObject(iomodel->CopyConstantObject(ThermalPenaltyLockEnum));21 parameters->AddObject(iomodel->CopyConstantObject(ThermalIsenthalpyEnum));22 parameters->AddObject(iomodel->CopyConstantObject(ThermalIsdynamicbasalspcEnum));23 parameters->AddObject(iomodel->CopyConstantObject(FrictionLawEnum));24 25 iomodel->FetchData(&requestedoutputs,&numoutputs,ThermalRequestedOutputsEnum);26 parameters->AddObject(new IntParam(ThermalNumRequestedOutputsEnum,numoutputs));27 if(numoutputs)parameters->AddObject(new StringArrayParam(ThermalRequestedOutputsEnum,requestedoutputs,numoutputs));28 iomodel->DeleteData(&requestedoutputs,numoutputs,ThermalRequestedOutputsEnum);29 30 46 }/*}}}*/ 31 47 void ThermalAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ … … 61 77 iomodel->FetchDataToInput(elements,MeshVertexonsurfaceEnum); 62 78 } 63 iomodel->FetchDataToInput(elements,FlowequationElementEquationEnum);64 79 iomodel->FetchDataToInput(elements,MeshVertexonbaseEnum); 65 80 iomodel->FetchDataToInput(elements,MeshVertexonsurfaceEnum); … … 90 105 iomodel->FetchDataToInput(elements,FrictionMEnum); 91 106 break; 107 case 3: 108 iomodel->FetchDataToInput(elements,FrictionCEnum); 109 iomodel->FetchDataToInput(elements,FrictionAsEnum); 110 iomodel->FetchDataToInput(elements,FrictionQEnum); 111 iomodel->FetchDataToInput(elements,FrictionEffectivePressureEnum); 112 break; 113 case 4: 114 iomodel->FetchDataToInput(elements,FrictionCoefficientEnum); 115 iomodel->FetchDataToInput(elements,FrictionPEnum); 116 iomodel->FetchDataToInput(elements,FrictionQEnum); 117 iomodel->FetchDataToInput(elements,PressureEnum); 118 iomodel->FetchDataToInput(elements,TemperatureEnum); 119 break; 120 case 5: 121 iomodel->FetchDataToInput(elements,FrictionCoefficientEnum); 122 iomodel->FetchDataToInput(elements,FrictionPEnum); 123 iomodel->FetchDataToInput(elements,FrictionQEnum); 124 iomodel->FetchDataToInput(elements,FrictionWaterLayerEnum); 125 break; 126 case 6: 127 iomodel->FetchDataToInput(elements,FrictionCEnum); 128 iomodel->FetchDataToInput(elements,FrictionMEnum); 129 iomodel->FetchDataToInput(elements,PressureEnum); 130 iomodel->FetchDataToInput(elements,TemperatureEnum); 131 break; 92 132 default: 93 133 _error_("not supported"); 94 134 } 95 135 }/*}}}*/ 96 void ThermalAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 97 98 int finiteelement = P1Enum; 99 if(iomodel->domaintype==Domain3DEnum) iomodel->FetchData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 100 ::CreateNodes(nodes,iomodel,ThermalAnalysisEnum,finiteelement); 101 iomodel->DeleteData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum); 102 }/*}}}*/ 103 void ThermalAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 104 105 /*Only 3d mesh supported*/ 106 int finiteelement = P1Enum; 107 if(iomodel->domaintype==Domain3DEnum){ 108 IoModelToConstraintsx(constraints,iomodel,ThermalSpctemperatureEnum,ThermalAnalysisEnum,finiteelement); 109 } 110 111 }/*}}}*/ 112 void ThermalAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 113 114 if(iomodel->domaintype==Domain2DhorizontalEnum) _error_("2d meshes not supported yet"); 115 116 /*create penalties for nodes: no node can have a temperature over the melting point*/ 117 iomodel->FetchData(1,ThermalSpctemperatureEnum); 118 CreateSingleNodeToElementConnectivity(iomodel); 119 120 for(int i=0;i<iomodel->numberofvertices;i++){ 121 122 /*keep only this partition's nodes:*/ 123 if(iomodel->my_vertices[i]){ 124 if (xIsNan<IssmDouble>(iomodel->Data(ThermalSpctemperatureEnum)[i])){ //No penalty applied on spc nodes! 125 loads->AddObject(new Pengrid(iomodel->loadcounter+i+1,i,iomodel,ThermalAnalysisEnum)); 126 } 127 } 128 } 129 iomodel->DeleteData(1,ThermalSpctemperatureEnum); 130 136 void ThermalAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 137 138 int numoutputs; 139 char** requestedoutputs = NULL; 140 141 parameters->AddObject(iomodel->CopyConstantObject(ThermalMaxiterEnum)); 142 parameters->AddObject(iomodel->CopyConstantObject(ThermalStabilizationEnum)); 143 parameters->AddObject(iomodel->CopyConstantObject(ThermalPenaltyFactorEnum)); 144 parameters->AddObject(iomodel->CopyConstantObject(ThermalPenaltyThresholdEnum)); 145 parameters->AddObject(iomodel->CopyConstantObject(ThermalPenaltyLockEnum)); 146 parameters->AddObject(iomodel->CopyConstantObject(ThermalIsenthalpyEnum)); 147 parameters->AddObject(iomodel->CopyConstantObject(ThermalIsdynamicbasalspcEnum)); 148 parameters->AddObject(iomodel->CopyConstantObject(FrictionLawEnum)); 149 150 iomodel->FetchData(&requestedoutputs,&numoutputs,ThermalRequestedOutputsEnum); 151 parameters->AddObject(new IntParam(ThermalNumRequestedOutputsEnum,numoutputs)); 152 if(numoutputs)parameters->AddObject(new StringArrayParam(ThermalRequestedOutputsEnum,requestedoutputs,numoutputs)); 153 iomodel->DeleteData(&requestedoutputs,numoutputs,ThermalRequestedOutputsEnum); 154 155 /*Deal with friction parameters*/ 156 int frictionlaw; 157 iomodel->Constant(&frictionlaw,FrictionLawEnum); 158 if(frictionlaw==4 || frictionlaw==6) parameters->AddObject(iomodel->CopyConstantObject(FrictionGammaEnum)); 131 159 }/*}}}*/ 132 160 … … 155 183 delete Ke1; 156 184 delete Ke2; 185 return Ke; 186 }/*}}}*/ 187 ElementMatrix* ThermalAnalysis::CreateKMatrixShelf(Element* element){/*{{{*/ 188 189 /* Check if ice in element */ 190 if(!element->IsIceInElement()) return NULL; 191 192 /*Initialize Element matrix and return if necessary*/ 193 if(!element->IsOnBase() || !element->IsFloating()) return NULL; 194 195 IssmDouble dt,Jdet,D; 196 IssmDouble *xyz_list_base = NULL; 197 198 /*Get basal element*/ 199 if(!element->IsOnBase() || !element->IsFloating()) return NULL; 200 201 /*Fetch number of nodes for this finite element*/ 202 int numnodes = element->GetNumberOfNodes(); 203 204 /*Initialize vectors*/ 205 ElementMatrix* Ke = element->NewElementMatrix(); 206 IssmDouble* basis = xNew<IssmDouble>(numnodes); 207 208 /*Retrieve all inputs and parameters*/ 209 element->GetVerticesCoordinatesBase(&xyz_list_base); 210 element->FindParam(&dt,TimesteppingTimeStepEnum); 211 IssmDouble gravity = element->GetMaterialParameter(ConstantsGEnum); 212 IssmDouble rho_water = element->GetMaterialParameter(MaterialsRhoSeawaterEnum); 213 IssmDouble rho_ice = element->GetMaterialParameter(MaterialsRhoIceEnum); 214 IssmDouble heatcapacity = element->GetMaterialParameter(MaterialsHeatcapacityEnum); 215 IssmDouble mixed_layer_capacity= element->GetMaterialParameter(MaterialsMixedLayerCapacityEnum); 216 IssmDouble thermal_exchange_vel= element->GetMaterialParameter(MaterialsThermalExchangeVelocityEnum); 217 218 /* Start looping on the number of gaussian points: */ 219 Gauss* gauss=element->NewGaussBase(2); 220 for(int ig=gauss->begin();ig<gauss->end();ig++){ 221 gauss->GaussPoint(ig); 222 223 element->JacobianDeterminantBase(&Jdet,xyz_list_base,gauss); 224 element->NodalFunctions(basis,gauss); 225 226 D=gauss->weight*Jdet*rho_water*mixed_layer_capacity*thermal_exchange_vel/(heatcapacity*rho_ice); 227 if(reCast<bool,IssmDouble>(dt)) D=dt*D; 228 TripleMultiply(basis,numnodes,1,0, 229 &D,1,1,0, 230 basis,1,numnodes,0, 231 &Ke->values[0],1); 232 233 } 234 235 /*Clean up and return*/ 236 delete gauss; 237 xDelete<IssmDouble>(basis); 238 xDelete<IssmDouble>(xyz_list_base); 157 239 return Ke; 158 240 }/*}}}*/ … … 290 372 return Ke; 291 373 }/*}}}*/ 292 Element Matrix* ThermalAnalysis::CreateKMatrixShelf(Element* element){/*{{{*/293 374 ElementVector* ThermalAnalysis::CreatePVector(Element* element){/*{{{*/ 375 294 376 /* Check if ice in element */ 295 377 if(!element->IsIceInElement()) return NULL; 296 378 297 /*Initialize Element matrix and return if necessary*/ 298 if(!element->IsOnBase() || !element->IsFloating()) return NULL; 299 300 IssmDouble dt,Jdet,D; 379 /*compute all load vectors for this element*/ 380 ElementVector* pe1=CreatePVectorVolume(element); 381 ElementVector* pe2=CreatePVectorSheet(element); 382 ElementVector* pe3=CreatePVectorShelf(element); 383 ElementVector* pe =new ElementVector(pe1,pe2,pe3); 384 385 /*clean-up and return*/ 386 delete pe1; 387 delete pe2; 388 delete pe3; 389 return pe; 390 }/*}}}*/ 391 ElementVector* ThermalAnalysis::CreatePVectorSheet(Element* element){/*{{{*/ 392 393 /* Check if ice in element */ 394 if(!element->IsIceInElement()) return NULL; 395 396 /* Geothermal flux on ice sheet base and basal friction */ 397 if(!element->IsOnBase() || element->IsFloating()) return NULL; 398 399 IssmDouble dt,Jdet,geothermalflux,vx,vy,vz; 400 IssmDouble alpha2,scalar,basalfriction,heatflux; 301 401 IssmDouble *xyz_list_base = NULL; 302 402 303 /*Get basal element*/304 if(!element->IsOnBase() || !element->IsFloating()) return NULL;305 306 403 /*Fetch number of nodes for this finite element*/ 307 404 int numnodes = element->GetNumberOfNodes(); 308 405 309 406 /*Initialize vectors*/ 310 Element Matrix* Ke = element->NewElementMatrix();407 ElementVector* pe = element->NewElementVector(); 311 408 IssmDouble* basis = xNew<IssmDouble>(numnodes); 312 409 … … 314 411 element->GetVerticesCoordinatesBase(&xyz_list_base); 315 412 element->FindParam(&dt,TimesteppingTimeStepEnum); 413 Input* vx_input = element->GetInput(VxEnum); _assert_(vx_input); 414 Input* vy_input = element->GetInput(VyEnum); _assert_(vy_input); 415 Input* vz_input = element->GetInput(VzEnum); _assert_(vz_input); 416 Input* geothermalflux_input = element->GetInput(BasalforcingsGeothermalfluxEnum); _assert_(geothermalflux_input); 417 IssmDouble rho_ice = element->GetMaterialParameter(MaterialsRhoIceEnum); 418 IssmDouble heatcapacity = element->GetMaterialParameter(MaterialsHeatcapacityEnum); 419 420 /*Build friction element, needed later: */ 421 Friction* friction=new Friction(element,3); 422 423 /* Start looping on the number of gaussian points: */ 424 Gauss* gauss = element->NewGaussBase(2); 425 for(int ig=gauss->begin();ig<gauss->end();ig++){ 426 gauss->GaussPoint(ig); 427 428 element->JacobianDeterminantBase(&Jdet,xyz_list_base,gauss); 429 element->NodalFunctions(basis,gauss); 430 431 geothermalflux_input->GetInputValue(&geothermalflux,gauss); 432 friction->GetAlpha2(&alpha2,gauss); 433 vx_input->GetInputValue(&vx,gauss); 434 vy_input->GetInputValue(&vy,gauss); 435 vz_input->GetInputValue(&vz,gauss); 436 vz = 0.;//FIXME 437 basalfriction = alpha2*(vx*vx + vy*vy + vz*vz); 438 heatflux = (basalfriction+geothermalflux)/(rho_ice*heatcapacity); 439 440 scalar = gauss->weight*Jdet*heatflux; 441 if(dt!=0.) scalar=dt*scalar; 442 443 for(int i=0;i<numnodes;i++) pe->values[i]+=scalar*basis[i]; 444 } 445 446 /*Clean up and return*/ 447 delete gauss; 448 delete friction; 449 xDelete<IssmDouble>(basis); 450 xDelete<IssmDouble>(xyz_list_base); 451 return pe; 452 }/*}}}*/ 453 ElementVector* ThermalAnalysis::CreatePVectorShelf(Element* element){/*{{{*/ 454 455 /* Check if ice in element */ 456 if(!element->IsIceInElement()) return NULL; 457 458 IssmDouble t_pmp,dt,Jdet,scalar_ocean,pressure; 459 IssmDouble *xyz_list_base = NULL; 460 461 /*Get basal element*/ 462 if(!element->IsOnBase() || !element->IsFloating()) return NULL; 463 464 /*Fetch number of nodes for this finite element*/ 465 int numnodes = element->GetNumberOfNodes(); 466 467 /*Initialize vectors*/ 468 ElementVector* pe = element->NewElementVector(); 469 IssmDouble* basis = xNew<IssmDouble>(numnodes); 470 471 /*Retrieve all inputs and parameters*/ 472 element->GetVerticesCoordinatesBase(&xyz_list_base); 473 element->FindParam(&dt,TimesteppingTimeStepEnum); 474 Input* pressure_input=element->GetInput(PressureEnum); _assert_(pressure_input); 316 475 IssmDouble gravity = element->GetMaterialParameter(ConstantsGEnum); 317 476 IssmDouble rho_water = element->GetMaterialParameter(MaterialsRhoSeawaterEnum); … … 329 488 element->NodalFunctions(basis,gauss); 330 489 331 D=gauss->weight*Jdet*rho_water*mixed_layer_capacity*thermal_exchange_vel/(heatcapacity*rho_ice);332 if(reCast<bool,IssmDouble>(dt)) D=dt*D;333 TripleMultiply(basis,numnodes,1,0, 334 &D,1,1,0,335 basis,1,numnodes,0,336 &Ke->values[0],1); 337 490 pressure_input->GetInputValue(&pressure,gauss); 491 t_pmp=element->TMeltingPoint(pressure); 492 493 scalar_ocean=gauss->weight*Jdet*rho_water*mixed_layer_capacity*thermal_exchange_vel*(t_pmp)/(heatcapacity*rho_ice); 494 if(reCast<bool,IssmDouble>(dt)) scalar_ocean=dt*scalar_ocean; 495 496 for(int i=0;i<numnodes;i++) pe->values[i]+=scalar_ocean*basis[i]; 338 497 } 339 498 … … 342 501 xDelete<IssmDouble>(basis); 343 502 xDelete<IssmDouble>(xyz_list_base); 344 return Ke;345 }/*}}}*/346 ElementVector* ThermalAnalysis::CreatePVector(Element* element){/*{{{*/347 348 /* Check if ice in element */349 if(!element->IsIceInElement()) return NULL;350 351 /*compute all load vectors for this element*/352 ElementVector* pe1=CreatePVectorVolume(element);353 ElementVector* pe2=CreatePVectorSheet(element);354 ElementVector* pe3=CreatePVectorShelf(element);355 ElementVector* pe =new ElementVector(pe1,pe2,pe3);356 357 /*clean-up and return*/358 delete pe1;359 delete pe2;360 delete pe3;361 503 return pe; 362 504 }/*}}}*/ … … 443 585 444 586 }/*}}}*/ 445 ElementVector* ThermalAnalysis::CreatePVectorSheet(Element* element){/*{{{*/446 447 /* Check if ice in element */448 if(!element->IsIceInElement()) return NULL;449 450 /* Geothermal flux on ice sheet base and basal friction */451 if(!element->IsOnBase() || element->IsFloating()) return NULL;452 453 IssmDouble dt,Jdet,geothermalflux,vx,vy,vz;454 IssmDouble alpha2,scalar,basalfriction,heatflux;455 IssmDouble *xyz_list_base = NULL;587 void ThermalAnalysis::GetBAdvec(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 588 /*Compute B matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1. 589 * For node i, Bi' can be expressed in the actual coordinate system 590 * by: 591 * Bi_advec =[ h ] 592 * [ h ] 593 * [ h ] 594 * where h is the interpolation function for node i. 595 * 596 * We assume B has been allocated already, of size: 3x(NDOF1*NUMNODESP1) 597 */ 456 598 457 599 /*Fetch number of nodes for this finite element*/ 458 600 int numnodes = element->GetNumberOfNodes(); 459 601 460 /*Initialize vectors*/ 461 ElementVector* pe = element->NewElementVector(); 462 IssmDouble* basis = xNew<IssmDouble>(numnodes); 463 464 /*Retrieve all inputs and parameters*/ 465 element->GetVerticesCoordinatesBase(&xyz_list_base); 466 element->FindParam(&dt,TimesteppingTimeStepEnum); 467 Input* vx_input = element->GetInput(VxEnum); _assert_(vx_input); 468 Input* vy_input = element->GetInput(VyEnum); _assert_(vy_input); 469 Input* vz_input = element->GetInput(VzEnum); _assert_(vz_input); 470 Input* geothermalflux_input = element->GetInput(BasalforcingsGeothermalfluxEnum); _assert_(geothermalflux_input); 471 IssmDouble rho_ice = element->GetMaterialParameter(MaterialsRhoIceEnum); 472 IssmDouble heatcapacity = element->GetMaterialParameter(MaterialsHeatcapacityEnum); 473 474 /*Build friction element, needed later: */ 475 Friction* friction=new Friction(element,3); 476 477 /* Start looping on the number of gaussian points: */ 478 Gauss* gauss = element->NewGaussBase(2); 479 for(int ig=gauss->begin();ig<gauss->end();ig++){ 480 gauss->GaussPoint(ig); 481 482 element->JacobianDeterminantBase(&Jdet,xyz_list_base,gauss); 483 element->NodalFunctions(basis,gauss); 484 485 geothermalflux_input->GetInputValue(&geothermalflux,gauss); 486 friction->GetAlpha2(&alpha2,gauss); 487 vx_input->GetInputValue(&vx,gauss); 488 vy_input->GetInputValue(&vy,gauss); 489 vz_input->GetInputValue(&vz,gauss); 490 vz = 0.;//FIXME 491 basalfriction = alpha2*(vx*vx + vy*vy + vz*vz); 492 heatflux = (basalfriction+geothermalflux)/(rho_ice*heatcapacity); 493 494 scalar = gauss->weight*Jdet*heatflux; 495 if(dt!=0.) scalar=dt*scalar; 496 497 for(int i=0;i<numnodes;i++) pe->values[i]+=scalar*basis[i]; 498 } 499 500 /*Clean up and return*/ 501 delete gauss; 502 delete friction; 602 /*Get nodal functions*/ 603 IssmDouble* basis=xNew<IssmDouble>(numnodes); 604 element->NodalFunctions(basis,gauss); 605 606 /*Build B: */ 607 for(int i=0;i<numnodes;i++){ 608 B[numnodes*0+i] = basis[i]; 609 B[numnodes*1+i] = basis[i]; 610 B[numnodes*2+i] = basis[i]; 611 } 612 613 /*Clean-up*/ 503 614 xDelete<IssmDouble>(basis); 504 xDelete<IssmDouble>(xyz_list_base); 505 return pe; 506 }/*}}}*/ 507 ElementVector* ThermalAnalysis::CreatePVectorShelf(Element* element){/*{{{*/ 508 509 /* Check if ice in element */ 510 if(!element->IsIceInElement()) return NULL; 511 512 IssmDouble t_pmp,dt,Jdet,scalar_ocean,pressure; 513 IssmDouble *xyz_list_base = NULL; 514 515 /*Get basal element*/ 516 if(!element->IsOnBase() || !element->IsFloating()) return NULL; 615 }/*}}}*/ 616 void ThermalAnalysis::GetBAdvecprime(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 617 /*Compute B matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1. 618 * For node i, Bi' can be expressed in the actual coordinate system 619 * by: 620 * Biprime_advec=[ dh/dx ] 621 * [ dh/dy ] 622 * [ dh/dz ] 623 * where h is the interpolation function for node i. 624 * 625 * We assume B has been allocated already, of size: 3x(NDOF1*numnodes) 626 */ 517 627 518 628 /*Fetch number of nodes for this finite element*/ 519 629 int numnodes = element->GetNumberOfNodes(); 520 630 521 /*Initialize vectors*/ 522 ElementVector* pe = element->NewElementVector(); 523 IssmDouble* basis = xNew<IssmDouble>(numnodes); 524 525 /*Retrieve all inputs and parameters*/ 526 element->GetVerticesCoordinatesBase(&xyz_list_base); 527 element->FindParam(&dt,TimesteppingTimeStepEnum); 528 Input* pressure_input=element->GetInput(PressureEnum); _assert_(pressure_input); 529 IssmDouble gravity = element->GetMaterialParameter(ConstantsGEnum); 530 IssmDouble rho_water = element->GetMaterialParameter(MaterialsRhoSeawaterEnum); 531 IssmDouble rho_ice = element->GetMaterialParameter(MaterialsRhoIceEnum); 532 IssmDouble heatcapacity = element->GetMaterialParameter(MaterialsHeatcapacityEnum); 533 IssmDouble mixed_layer_capacity= element->GetMaterialParameter(MaterialsMixedLayerCapacityEnum); 534 IssmDouble thermal_exchange_vel= element->GetMaterialParameter(MaterialsThermalExchangeVelocityEnum); 535 536 /* Start looping on the number of gaussian points: */ 537 Gauss* gauss=element->NewGaussBase(2); 538 for(int ig=gauss->begin();ig<gauss->end();ig++){ 539 gauss->GaussPoint(ig); 540 541 element->JacobianDeterminantBase(&Jdet,xyz_list_base,gauss); 542 element->NodalFunctions(basis,gauss); 543 544 pressure_input->GetInputValue(&pressure,gauss); 545 t_pmp=element->TMeltingPoint(pressure); 546 547 scalar_ocean=gauss->weight*Jdet*rho_water*mixed_layer_capacity*thermal_exchange_vel*(t_pmp)/(heatcapacity*rho_ice); 548 if(reCast<bool,IssmDouble>(dt)) scalar_ocean=dt*scalar_ocean; 549 550 for(int i=0;i<numnodes;i++) pe->values[i]+=scalar_ocean*basis[i]; 551 } 552 553 /*Clean up and return*/ 554 delete gauss; 555 xDelete<IssmDouble>(basis); 556 xDelete<IssmDouble>(xyz_list_base); 557 return pe; 558 }/*}}}*/ 559 void ThermalAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 560 element->GetSolutionFromInputsOneDof(solution,TemperatureEnum); 561 }/*}}}*/ 562 void ThermalAnalysis::GetBConduct(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 631 /*Get nodal functions derivatives*/ 632 IssmDouble* dbasis=xNew<IssmDouble>(3*numnodes); 633 element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss); 634 635 /*Build B: */ 636 for(int i=0;i<numnodes;i++){ 637 B[numnodes*0+i] = dbasis[0*numnodes+i]; 638 B[numnodes*1+i] = dbasis[1*numnodes+i]; 639 B[numnodes*2+i] = dbasis[2*numnodes+i]; 640 } 641 642 /*Clean-up*/ 643 xDelete<IssmDouble>(dbasis); 644 }/*}}}*/ 645 void ThermalAnalysis::GetBConduct(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 563 646 /*Compute B matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1. 564 647 * For node i, Bi' can be expressed in the actual coordinate system … … 589 672 xDelete<IssmDouble>(dbasis); 590 673 }/*}}}*/ 591 void ThermalAnalysis::GetBAdvec(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 592 /*Compute B matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1. 593 * For node i, Bi' can be expressed in the actual coordinate system 594 * by: 595 * Bi_advec =[ h ] 596 * [ h ] 597 * [ h ] 598 * where h is the interpolation function for node i. 599 * 600 * We assume B has been allocated already, of size: 3x(NDOF1*NUMNODESP1) 601 */ 602 603 /*Fetch number of nodes for this finite element*/ 604 int numnodes = element->GetNumberOfNodes(); 605 606 /*Get nodal functions*/ 607 IssmDouble* basis=xNew<IssmDouble>(numnodes); 608 element->NodalFunctions(basis,gauss); 609 610 /*Build B: */ 611 for(int i=0;i<numnodes;i++){ 612 B[numnodes*0+i] = basis[i]; 613 B[numnodes*1+i] = basis[i]; 614 B[numnodes*2+i] = basis[i]; 615 } 616 617 /*Clean-up*/ 618 xDelete<IssmDouble>(basis); 619 }/*}}}*/ 620 void ThermalAnalysis::GetBAdvecprime(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 621 /*Compute B matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1. 622 * For node i, Bi' can be expressed in the actual coordinate system 623 * by: 624 * Biprime_advec=[ dh/dx ] 625 * [ dh/dy ] 626 * [ dh/dz ] 627 * where h is the interpolation function for node i. 628 * 629 * We assume B has been allocated already, of size: 3x(NDOF1*numnodes) 630 */ 631 632 /*Fetch number of nodes for this finite element*/ 633 int numnodes = element->GetNumberOfNodes(); 634 635 /*Get nodal functions derivatives*/ 636 IssmDouble* dbasis=xNew<IssmDouble>(3*numnodes); 637 element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss); 638 639 /*Build B: */ 640 for(int i=0;i<numnodes;i++){ 641 B[numnodes*0+i] = dbasis[0*numnodes+i]; 642 B[numnodes*1+i] = dbasis[1*numnodes+i]; 643 B[numnodes*2+i] = dbasis[2*numnodes+i]; 644 } 645 646 /*Clean-up*/ 647 xDelete<IssmDouble>(dbasis); 648 }/*}}}*/ 649 void ThermalAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 674 void ThermalAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 675 element->GetSolutionFromInputsOneDof(solution,TemperatureEnum); 676 }/*}}}*/ 677 void ThermalAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 650 678 _error_("Not implemented yet"); 651 679 }/*}}}*/ 652 void ThermalAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/680 void ThermalAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 653 681 654 682 bool converged; … … 730 758 xDelete<int>(doflist); 731 759 }/*}}}*/ 732 void ThermalAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/760 void ThermalAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 733 761 734 762 bool islevelset; -
issm/trunk/src/c/analyses/ThermalAnalysis.h
r18301 r19105 13 13 public: 14 14 /*Model processing*/ 15 int DofsPerNode(int** doflist,int domaintype,int approximation);16 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum);17 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type);18 void CreateNodes(Nodes* nodes,IoModel* iomodel);19 15 void CreateConstraints(Constraints* constraints,IoModel* iomodel); 20 16 void CreateLoads(Loads* loads, IoModel* iomodel); 17 void CreateNodes(Nodes* nodes,IoModel* iomodel); 18 int DofsPerNode(int** doflist,int domaintype,int approximation); 19 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 20 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum); 21 21 22 22 /*Finite element Analysis*/ … … 25 25 ElementMatrix* CreateJacobianMatrix(Element* element); 26 26 ElementMatrix* CreateKMatrix(Element* element); 27 ElementMatrix* CreateKMatrixShelf(Element* element); 27 28 ElementMatrix* CreateKMatrixVolume(Element* element); 28 ElementMatrix* CreateKMatrixShelf(Element* element);29 29 ElementVector* CreatePVector(Element* element); 30 ElementVector* CreatePVectorVolume(Element* element);31 30 ElementVector* CreatePVectorSheet(Element* element); 32 31 ElementVector* CreatePVectorShelf(Element* element); 33 void GetBConduct(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss); 34 void GetBAdvec(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss); 35 void GetBAdvecprime(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss); 36 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 37 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 38 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 39 void UpdateConstraints(FemModel* femmodel); 32 ElementVector* CreatePVectorVolume(Element* element); 33 void GetBAdvec(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss); 34 void GetBAdvecprime(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss); 35 void GetBConduct(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss); 36 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 37 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 38 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 39 void UpdateConstraints(FemModel* femmodel); 40 40 }; 41 41 #endif -
issm/trunk/src/c/analyses/UzawaPressureAnalysis.cpp
r18301 r19105 6 6 7 7 /*Model processing*/ 8 void UzawaPressureAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 9 return; 10 }/*}}}*/ 11 void UzawaPressureAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 12 return; 13 }/*}}}*/ 14 void UzawaPressureAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 15 16 int finiteelement; 17 int fe_FS; 18 19 iomodel->Constant(&fe_FS,FlowequationFeFSEnum); 20 if(fe_FS==LATaylorHoodEnum) finiteelement = P1Enum; 21 else if(fe_FS==LACrouzeixRaviartEnum) finiteelement = P1DGEnum; 22 else _error_("solution not supported yet"); 23 24 ::CreateNodes(nodes,iomodel,UzawaPressureAnalysisEnum,finiteelement); 25 }/*}}}*/ 8 26 int UzawaPressureAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/ 9 27 return 1; 10 28 }/*}}}*/ 11 void UzawaPressureAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/12 13 parameters->AddObject(iomodel->CopyConstantObject(AugmentedLagrangianRhopEnum));14 parameters->AddObject(iomodel->CopyConstantObject(AugmentedLagrangianRholambdaEnum));15 }/*}}}*/16 29 void UzawaPressureAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ 17 30 18 31 /*Update elements: */ 19 int finiteelement = P1Enum;32 int finiteelement; 20 33 int counter=0; 34 int fe_FS; 35 36 iomodel->Constant(&fe_FS,FlowequationFeFSEnum); 37 if(fe_FS==LATaylorHoodEnum) finiteelement = P1Enum; 38 else if(fe_FS==LACrouzeixRaviartEnum) finiteelement = P1DGEnum; 39 else _error_("solution not supported yet"); 40 21 41 for(int i=0;i<iomodel->numberofelements;i++){ 22 42 if(iomodel->my_elements[i]){ … … 33 53 InputUpdateFromConstantx(elements,0.,SigmaNNEnum); 34 54 }/*}}}*/ 35 void UzawaPressureAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 36 37 int finiteelement = P1Enum; 38 ::CreateNodes(nodes,iomodel,UzawaPressureAnalysisEnum,finiteelement); 39 }/*}}}*/ 40 void UzawaPressureAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 41 return; 42 }/*}}}*/ 43 void UzawaPressureAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 44 return; 55 void UzawaPressureAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 56 57 parameters->AddObject(iomodel->CopyConstantObject(AugmentedLagrangianRhopEnum)); 58 parameters->AddObject(iomodel->CopyConstantObject(AugmentedLagrangianRholambdaEnum)); 45 59 }/*}}}*/ 46 60 … … 67 81 IssmDouble* M = xNew<IssmDouble>(numnodes); 68 82 83 IssmDouble connectivity; 69 84 /*Retrieve all inputs and parameters*/ 70 85 element->GetVerticesCoordinates(&xyz_list); 71 72 Gauss* gauss = element->NewGauss(5); 73 for(int ig=gauss->begin();ig<gauss->end();ig++){ 74 gauss->GaussPoint(ig); 75 76 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 77 this->GetM(M,element,gauss); 78 D_scalar=gauss->weight*Jdet; 79 TripleMultiply(M,1,numnodes,1, 80 &D_scalar,1,1,0, 81 M,1,numnodes,0, 82 &Ke->values[0],1); 86 int numvertices = element->GetNumberOfVertices(); 87 88 //Gauss* gauss = element->NewGauss(5); 89 //for(int ig=gauss->begin();ig<gauss->end();ig++){ 90 // gauss->GaussPoint(ig); 91 92 // element->JacobianDeterminant(&Jdet,xyz_list,gauss); 93 // this->GetM(M,element,gauss); 94 // D_scalar=gauss->weight*Jdet; 95 // //TripleMultiply(M,1,numnodes,1, 96 // // &D_scalar,1,1,0, 97 // // M,1,numnodes,0, 98 // // &Ke->values[0],1); 99 100 //} 101 for(int iv=0;iv<numvertices;iv++){ 102 connectivity=(IssmDouble)element->VertexConnectivity(iv); 103 Ke->values[iv*numvertices+iv]=1./connectivity; 83 104 } 84 105 85 106 /*Clean up and return*/ 86 delete gauss;107 //delete gauss; 87 108 xDelete<IssmDouble>(xyz_list); 88 109 xDelete<IssmDouble>(M); … … 143 164 return pe; 144 165 }/*}}}*/ 145 void UzawaPressureAnalysis::GetM(IssmDouble* M,Element* element,Gauss* gauss){/*{{{*/166 void UzawaPressureAnalysis::GetM(IssmDouble* M,Element* element,Gauss* gauss){/*{{{*/ 146 167 /*Compute B matrix. M=[M1 M2 M3] */ 147 168 … … 161 182 xDelete<IssmDouble>(basis); 162 183 }/*}}}*/ 163 void UzawaPressureAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/184 void UzawaPressureAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 164 185 _error_("not implemented yet"); 165 186 }/*}}}*/ 166 void UzawaPressureAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/187 void UzawaPressureAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 167 188 _error_("Not implemented yet"); 168 189 }/*}}}*/ 169 void UzawaPressureAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/190 void UzawaPressureAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 170 191 171 192 int dim; … … 176 197 /*Fetch number of nodes and dof for this finite element*/ 177 198 int numnodes = element->GetNumberOfNodes(); 178 int numnodessigma = element->GetNumberOfNodes(P2Enum); 199 int numnodessigma; 200 if(element->element_type==P1Enum) numnodessigma=element->GetNumberOfNodes(P2Enum); 201 else if(element->element_type==P1DGEnum) numnodessigma=element->GetNumberOfNodes(P2Enum); 202 else _error_("finite element not supported yet"); 179 203 180 204 element->FindParam(&dim,DomainDimensionEnum); … … 185 209 IssmDouble* valueslambda = xNewZeroInit<IssmDouble>(numnodessigma); 186 210 IssmDouble* pressure = xNew<IssmDouble>(numnodes); 187 Input* sigmann_input = element->GetInput(SigmaNNEnum); _assert_(sigmann_input);188 211 Input* vx_input = element->GetInput(VxEnum); _assert_(vx_input); 189 212 Input* vy_input = element->GetInput(VyEnum); _assert_(vy_input); … … 199 222 200 223 /*Now compute sigmann if on base*/ 201 if(element->IsOnBase()){ 224 if(element->IsOnBase() && 0){ 225 Input* sigmann_input = element->GetInput(SigmaNNEnum); _assert_(sigmann_input); 202 226 if(dim==3) _error_("not implemented yet"); 203 227 … … 263 287 xDelete<IssmDouble>(xyz_list_base); 264 288 xDelete<IssmDouble>(basis); 265 } 266 element->AddInput(SigmaNNEnum,valueslambda,P2Enum); 289 290 element->AddInput(SigmaNNEnum,valueslambda,P2Enum); 291 } 267 292 268 293 /*Free ressources:*/ … … 272 297 xDelete<int>(doflist); 273 298 }/*}}}*/ 274 void UzawaPressureAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/299 void UzawaPressureAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 275 300 /*Default, do nothing*/ 276 301 return; -
issm/trunk/src/c/analyses/UzawaPressureAnalysis.h
r18301 r19105 13 13 public: 14 14 /*Model processing*/ 15 int DofsPerNode(int** doflist,int domaintype,int approximation);16 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum);17 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type);18 void CreateNodes(Nodes* nodes,IoModel* iomodel);19 15 void CreateConstraints(Constraints* constraints,IoModel* iomodel); 20 16 void CreateLoads(Loads* loads, IoModel* iomodel); 17 void CreateNodes(Nodes* nodes,IoModel* iomodel); 18 int DofsPerNode(int** doflist,int domaintype,int approximation); 19 void UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 20 void UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum); 21 21 22 22 /*Finite element Analysis*/ … … 26 26 ElementMatrix* CreateKMatrix(Element* element); 27 27 ElementVector* CreatePVector(Element* element); 28 void GetM(IssmDouble* M,Element* element,Gauss* gauss);29 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element);30 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index);31 void InputUpdateFromSolution(IssmDouble* solution,Element* element);32 void UpdateConstraints(FemModel* femmodel);28 void GetM(IssmDouble* M,Element* element,Gauss* gauss); 29 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 30 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); 31 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 32 void UpdateConstraints(FemModel* femmodel); 33 33 }; 34 34 #endif -
issm/trunk/src/c/analyses/analyses.h
r18301 r19105 32 32 #include "./MeltingAnalysis.h" 33 33 #include "./MeshdeformationAnalysis.h" 34 #include "./SmoothedSurfaceSlopeXAnalysis.h" 35 #include "./SmoothedSurfaceSlopeYAnalysis.h" 34 #include "./SmoothAnalysis.h" 36 35 #include "./StressbalanceAnalysis.h" 37 36 #include "./StressbalanceSIAAnalysis.h" -
issm/trunk/src/c/bamg/BamgMesh.cpp
r18301 r19105 5 5 BamgMesh::BamgMesh(){/*{{{*/ 6 6 7 this->VerticesSize[0]=0, this->VerticesSize[1]=0; this->Vertices=NULL; 7 this->VerticesSize[0]=0, this->VerticesSize[1]=0; this->Vertices=NULL; this->PreviousNumbering = NULL; 8 8 this->EdgesSize[0]=0, this->EdgesSize[1]=0; this->Edges=NULL; 9 9 this->TrianglesSize[0]=0, this->TrianglesSize[1]=0; this->Triangles=NULL; … … 30 30 31 31 xDelete<double>(this->Vertices); 32 xDelete<double>(this->PreviousNumbering); 32 33 xDelete<double>(this->Edges); 33 34 xDelete<double>(this->Triangles); -
issm/trunk/src/c/bamg/BamgMesh.h
r12821 r19105 11 11 int VerticesSize[2]; 12 12 double* Vertices; 13 double* PreviousNumbering; 13 14 int EdgesSize[2]; 14 15 double* Edges; -
issm/trunk/src/c/bamg/BamgVertex.cpp
r18301 r19105 10 10 namespace bamg { 11 11 12 /*Constructor/Destructor*/ 13 BamgVertex::BamgVertex(){ /*{{{*/ 14 this->PreviousNumber = 0; 15 }/*}}}*/ 16 12 17 /*Methods*/ 13 18 void BamgVertex::Echo(void){/*{{{*/ … … 17 22 _printf_(" Euclidean coordinates r.x: " << r.x << ", r.y: " << r.y << "\n"); 18 23 _printf_(" ReferenceNumber = " << ReferenceNumber << "\n"); 24 _printf_(" PreviousNumber = " << PreviousNumber << "\n"); 19 25 m.Echo(); 20 26 -
issm/trunk/src/c/bamg/BamgVertex.h
r15066 r19105 23 23 Metric m; 24 24 long ReferenceNumber; 25 long PreviousNumber; 25 26 Direction DirOfSearch; 26 27 short IndexInTriangle; // the vertex number in triangle; varies between 0 and 2 in t … … 42 43 43 44 /*methods (No constructor and no destructors...)*/ 45 BamgVertex(); 44 46 double Smoothing(Mesh & ,const Mesh & ,Triangle * & ,double =1); 45 47 void MetricFromHessian(const double Hxx,const double Hyx, const double Hyy, const double smin,const double smax,const double s,const double err,BamgOpts* bamgopts); -
issm/trunk/src/c/bamg/Mesh.cpp
r18301 r19105 227 227 /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/Triangles)*/ 228 228 229 //if(vertices) delete [] vertices;230 if 231 if 232 if 233 //if (orderedvertices)delete [] orderedvertices;234 if 235 if 236 if 237 if 238 if 239 240 if (&Gh){229 if(vertices) delete [] vertices; 230 if(edges) delete [] edges; 231 if(triangles) delete [] triangles; 232 if(quadtree) delete quadtree; 233 if(orderedvertices) delete [] orderedvertices; 234 if(subdomains) delete [] subdomains; 235 if(VerticesOnGeomEdge) delete [] VerticesOnGeomEdge; 236 if(VerticesOnGeomVertex) delete [] VerticesOnGeomVertex; 237 if(VertexOnBThVertex) delete [] VertexOnBThVertex; 238 if(VertexOnBThEdge) delete [] VertexOnBThEdge; 239 240 if(&Gh){ 241 241 if (Gh.NbRef>0) Gh.NbRef--; 242 242 else if (Gh.NbRef==0) delete &Gh; 243 243 } 244 if (&BTh && (&BTh != this)){244 if(&BTh && (&BTh != this)){ 245 245 if (BTh.NbRef>0) BTh.NbRef--; 246 246 else if (BTh.NbRef==0) delete &BTh; … … 571 571 bamgmesh->VerticesSize[0]=nbv; 572 572 bamgmesh->VerticesSize[1]=3; 573 if 573 if(nbv){ 574 574 bamgmesh->Vertices=xNew<double>(3*nbv); 575 bamgmesh->PreviousNumbering=xNew<double>(nbv); 575 576 for (i=0;i<nbv;i++){ 576 577 bamgmesh->Vertices[i*3+0]=vertices[i].r.x; 577 578 bamgmesh->Vertices[i*3+1]=vertices[i].r.y; 578 579 bamgmesh->Vertices[i*3+2]=vertices[i].GetReferenceNumber(); 580 bamgmesh->PreviousNumbering[i]=vertices[i].PreviousNumber; 579 581 } 580 582 } … … 2726 2728 2727 2729 /*Allocate if maxnbv_in>0*/ 2728 if (maxnbv_in){2730 if(maxnbv_in){ 2729 2731 vertices=new BamgVertex[maxnbv]; 2730 2732 _assert_(vertices); … … 2734 2736 _assert_(triangles); 2735 2737 } 2736 else 2738 else{ 2737 2739 vertices=NULL; 2738 2740 orderedvertices=NULL; … … 2907 2909 // for all the new point 2908 2910 long iv=nbvold; 2909 for 2911 for(i=nbvold;i<nbv;i++){ 2910 2912 BamgVertex &vi=*orderedvertices[i]; 2911 2913 vi.i=R2ToI2(vi.r); … … 2914 2916 vi.m.Box(hx,hy); 2915 2917 Icoor1 hi=(Icoor1) (hx*coefIcoor),hj=(Icoor1) (hy*coefIcoor); 2916 if 2918 if(!quadtree->ToClose(vi,seuil,hi,hj)){ 2917 2919 // a good new point 2918 2920 BamgVertex &vj = vertices[iv]; … … 2928 2930 Triangle *tcvj=TriangleFindFromCoord(vj.i,det3); 2929 2931 if (tcvj && !tcvj->link){ 2932 _printf_("While trying to add the following point:\n"); 2933 vj.Echo(); 2934 _printf_("BAMG determined that it was inside the following triangle, which probably lies outside of the geometric domain\n"); 2930 2935 tcvj->Echo(); 2931 2936 _error_("problem inserting point in InsertNewPoints (tcvj=" << tcvj << " and tcvj->link=" << tcvj->link << ")"); … … 2935 2940 NbSwap += vj.Optim(1); 2936 2941 iv++; 2942 } 2943 else{ 2944 vi.PreviousNumber = 0; 2937 2945 } 2938 2946 } … … 3141 3149 3142 3150 /*First, insert old points if requested*/ 3143 if 3151 if(KeepVertices && (&Bh != this) && (nbv+Bh.nbv< maxnbv)){ 3144 3152 if (verbose>5) _printf_(" Inserting initial mesh points\n"); 3145 for (i=0;i<Bh.nbv;i++){ 3153 bool pointsoutside = false; 3154 for(i=0;i<Bh.nbv;i++){ 3146 3155 BamgVertex &bv=Bh[i]; 3147 if (!bv.GeomEdgeHook){ 3148 vertices[nbv].r = bv.r; 3156 /*Do not insert if the point is outside*/ 3157 long long det3[3]; 3158 Triangle* tcvj=TriangleFindFromCoord(bv.i,det3); 3159 if(tcvj->det<0 || !tcvj->link){ 3160 pointsoutside = true; 3161 continue; 3162 } 3163 IssmDouble area_1=((bv.r.x -(*tcvj)(2)->r.x)*((*tcvj)(1)->r.y-(*tcvj)(2)->r.y) 3164 - (bv.r.y -(*tcvj)(2)->r.y)*((*tcvj)(1)->r.x-(*tcvj)(2)->r.x)); 3165 IssmDouble area_2=(((*tcvj)(0)->r.x -(*tcvj)(2)->r.x)*(bv.r.y -(*tcvj)(2)->r.y) 3166 - ((*tcvj)(0)->r.y -(*tcvj)(2)->r.y)*(bv.r.x -(*tcvj)(2)->r.x)); 3167 IssmDouble area_3 =((bv.r.x -(*tcvj)(1)->r.x)*((*tcvj)(0)->r.y-(*tcvj)(1)->r.y) 3168 - (bv.r.y -(*tcvj)(1)->r.y)*((*tcvj)(0)->r.x-(*tcvj)(1)->r.x)); 3169 if(area_1<0 || area_2<0 || area_3<0){ 3170 pointsoutside = true; 3171 continue; 3172 } 3173 if(!bv.GeomEdgeHook){ 3174 vertices[nbv].r = bv.r; 3175 vertices[nbv].PreviousNumber = i+1; 3149 3176 vertices[nbv++].m = bv.m; 3150 3177 } 3151 3178 } 3179 if(pointsoutside) _printf_("WARNING: One or more points of the initial mesh fall outside of the geometric boundary\n"); 3152 3180 Bh.CreateSingleVertexToTriangleConnectivity(); 3153 3181 InsertNewPoints(nbvold,NbTSwap,bamgopts->random); 3154 } 3182 } 3155 3183 else Bh.CreateSingleVertexToTriangleConnectivity(); 3156 3184 -
issm/trunk/src/c/bamg/R2.h
r15194 r19105 19 19 P2 (R a,R b) :x(a),y(b) {} 20 20 P2 (P2 A,P2 B) : x(B.x-A.x),y(B.y-A.y) {} 21 void Echo() {21 void Echo() const{ 22 22 printf("Member of P2:\n"); 23 printf(" x: %g or %i\n",x,x);24 printf(" y: %g or %i\n",y,y);23 std::cout<<" x: "<<x<<std::endl; 24 std::cout<<" y: "<<y<<std::endl; 25 25 } 26 26 //operators -
issm/trunk/src/c/classes/Constraints/Constraint.h
r15067 r19105 20 20 21 21 virtual ~Constraint(){}; 22 virtual void ActivatePenaltyMethod(void)=0; 22 23 virtual void ConstrainNode(Nodes* nodes,Parameters* parameters)=0; 23 24 virtual bool InAnalysis(int analysis_type)=0; 25 virtual void PenaltyDofAndValue(int* dof,IssmDouble* value,Nodes* nodes,Parameters* parameters)=0; 24 26 25 27 }; -
issm/trunk/src/c/classes/Constraints/Constraints.cpp
r18301 r19105 12 12 13 13 #include "./Constraints.h" 14 #include "./Constraint.h" 14 15 #include "../../shared/shared.h" 15 16 #include "../../toolkits/toolkits.h" … … 19 20 20 21 /*Numerics: */ 21 int Constraints::NumberOfConstraints(void){/*{{{*/ 22 void Constraints::ActivatePenaltyMethod(int in_analysis){/*{{{*/ 23 24 for(int i=0;i<this->Size();i++){ 25 Constraint* constraint=(Constraint*)this->GetObjectByOffset(i); 26 if(constraint->InAnalysis(in_analysis)){ 27 constraint->ActivatePenaltyMethod(); 28 } 29 } 30 31 } 32 /*}}}*/ 33 int Constraints::NumberOfConstraints(void){/*{{{*/ 22 34 23 35 int localconstraints; -
issm/trunk/src/c/classes/Constraints/Constraints.h
r18301 r19105 27 27 28 28 /*numerics*/ 29 int NumberOfConstraints(void); 29 void ActivatePenaltyMethod(int in_analysis); 30 int NumberOfConstraints(void); 30 31 31 32 }; -
issm/trunk/src/c/classes/Constraints/SpcDynamic.cpp
r18301 r19105 20 20 SpcDynamic::SpcDynamic(int spc_sid,int spc_nodeid, int spc_dof,int spc_analysis_type){/*{{{*/ 21 21 22 sid=spc_sid; 23 nodeid=spc_nodeid; 24 dof=spc_dof; 25 value=0; 26 analysis_type=spc_analysis_type; 27 isset=false; 22 sid = spc_sid; 23 nodeid = spc_nodeid; 24 dof = spc_dof; 25 value = 0; 26 analysis_type = spc_analysis_type; 27 isset = false; 28 penalty = false; 28 29 29 30 return; … … 36 37 37 38 /*Object virtual functions definitions:*/ 38 void SpcDynamic::Echo(void){/*{{{*/39 40 _printf_("SpcDynamic:\n");41 _printf_(" sid: " << sid << "\n");42 _printf_(" nodeid: " << nodeid << "\n");43 _printf_(" dof: " << dof << "\n");44 _printf_(" value: " << value << "\n");45 _printf_(" isset: " <<(isset?"true":"false") << "\n");46 _printf_(" analysis_type: " << EnumToStringx(analysis_type) << "\n");47 return;48 }49 /*}}}*/50 void SpcDynamic::DeepEcho(void){/*{{{*/51 52 this->Echo();53 return;54 }55 /*}}}*/56 int SpcDynamic::Id(void){ return sid; }/*{{{*/57 /*}}}*/58 int SpcDynamic::ObjectEnum(void){/*{{{*/59 60 return SpcDynamicEnum;61 62 }63 /*}}}*/64 39 Object* SpcDynamic::copy() {/*{{{*/ 65 40 … … 76 51 } 77 52 /*}}}*/ 53 void SpcDynamic::DeepEcho(void){/*{{{*/ 54 55 this->Echo(); 56 return; 57 } 58 /*}}}*/ 59 void SpcDynamic::Echo(void){/*{{{*/ 60 61 _printf_("SpcDynamic:\n"); 62 _printf_(" sid: " << sid << "\n"); 63 _printf_(" nodeid: " << nodeid << "\n"); 64 _printf_(" dof: " << dof << "\n"); 65 _printf_(" value: " << value << "\n"); 66 _printf_(" isset: " <<(isset?"true":"false") << "\n"); 67 _printf_(" analysis_type: " << EnumToStringx(analysis_type) << "\n"); 68 return; 69 } 70 /*}}}*/ 71 int SpcDynamic::Id(void){ return sid; }/*{{{*/ 72 /*}}}*/ 73 int SpcDynamic::ObjectEnum(void){/*{{{*/ 74 75 return SpcDynamicEnum; 76 77 } 78 /*}}}*/ 78 79 79 80 /*Constraint virtual functions definitions: */ 80 bool SpcDynamic::InAnalysis(int in_analysis_type){/*{{{*/ 81 if (in_analysis_type==this->analysis_type) return true; 82 else return false; 81 void SpcDynamic::ActivatePenaltyMethod(void){/*{{{*/ 82 this->penalty = true; 83 83 } 84 84 /*}}}*/ … … 98 98 } 99 99 /*}}}*/ 100 bool SpcDynamic::InAnalysis(int in_analysis_type){/*{{{*/ 101 if (in_analysis_type==this->analysis_type) return true; 102 else return false; 103 } 104 /*}}}*/ 100 105 101 106 /*SpcDynamic functions*/ 102 int SpcDynamic::GetDof(){/*{{{*/107 int SpcDynamic::GetDof(){/*{{{*/ 103 108 return dof; 104 109 } 105 110 /*}}}*/ 106 int SpcDynamic::GetNodeId(){/*{{{*/111 int SpcDynamic::GetNodeId(){/*{{{*/ 107 112 108 113 return nodeid; … … 115 120 } 116 121 /*}}}*/ 117 void SpcDynamic::SetDynamicConstraint(Nodes* nodes,IssmDouble* yg_serial){/*{{{*/122 void SpcDynamic::SetDynamicConstraint(Nodes* nodes,IssmDouble* yg_serial){/*{{{*/ 118 123 119 124 int pos; -
issm/trunk/src/c/classes/Constraints/SpcDynamic.h
r15067 r19105 14 14 15 15 private: 16 int sid; /*! id, to track it*/ 17 int nodeid; /*!node id*/ 18 int dof; /*!component*/ 19 IssmDouble value; /*value*/ 20 bool isset; 21 int analysis_type; 16 int sid; /*! id, to track it */ 17 int nodeid; /*!node id */ 18 int dof; /*!component */ 19 IssmDouble value; /*value */ 20 bool isset; 21 int analysis_type; 22 bool penalty; /*Is this a penalty constraint */ 22 23 23 24 public: 24 25 25 /*SpcDynamic constructors, destructors :{{{*/26 /*SpcDynamic constructors, destructors*/ 26 27 SpcDynamic(); 27 28 SpcDynamic(int sid,int nodeid, int dof,int analysis_type); 28 29 ~SpcDynamic(); 29 /*}}}*/ 30 /*Object virtual functions definitions:{{{ */ 31 void Echo(); 32 void DeepEcho(); 33 int Id(); 34 int ObjectEnum(); 35 Object* copy(); 36 /*}}}*/ 37 /*Constraint virtual functions definitions: {{{*/ 38 void ConstrainNode(Nodes* nodes,Parameters* parameters); 39 bool InAnalysis(int analysis_type); 40 /*}}}*/ 41 /*SpcDynamic management:{{{ */ 42 int GetNodeId(); 43 int GetDof(); 30 31 /*Object virtual functions definitions*/ 32 Object *copy(); 33 void DeepEcho(); 34 void Echo(); 35 int Id(); 36 int ObjectEnum(); 37 38 /*Constraint virtual functions definitions*/ 39 void ActivatePenaltyMethod(void); 40 void ConstrainNode(Nodes* nodes,Parameters* parameters); 41 bool InAnalysis(int analysis_type); 42 void PenaltyDofAndValue(int* dof,IssmDouble* value,Nodes* nodes,Parameters* parameters){_error_("not implemented yet");}; 43 44 /*SpcDynamic management*/ 45 int GetDof(); 46 int GetNodeId(); 44 47 IssmDouble GetValue(); 45 void SetDynamicConstraint(Nodes* nodes,IssmDouble *yg_serial); 46 /*}}}*/ 48 void SetDynamicConstraint(Nodes *nodes,IssmDouble *yg_serial); 47 49 48 50 }; -
issm/trunk/src/c/classes/Constraints/SpcStatic.cpp
r18301 r19105 25 25 value = spc_value; 26 26 analysis_type = spc_analysis_type; 27 penalty = false; 27 28 28 29 return; … … 35 36 36 37 /*Object virtual functions definitions:*/ 37 void SpcStatic::Echo(void){/*{{{*/38 39 _printf_("SpcStatic:\n");40 _printf_(" sid: " << sid << "\n");41 _printf_(" nodeid: " << nodeid << "\n");42 _printf_(" dof: " << dof << "\n");43 _printf_(" value: " << value << "\n");44 _printf_(" analysis_type: " << EnumToStringx(analysis_type) << "\n");45 return;46 }47 /*}}}*/48 void SpcStatic::DeepEcho(void){/*{{{*/49 50 _printf_("SpcStatic:\n");51 _printf_(" sid: " << sid << "\n");52 _printf_(" nodeid: " << nodeid << "\n");53 _printf_(" dof: " << dof << "\n");54 _printf_(" value: " << value << "\n");55 _printf_(" analysis_type: " << EnumToStringx(analysis_type) << "\n");56 return;57 }58 /*}}}*/59 int SpcStatic::Id(void){ return sid; }/*{{{*/60 /*}}}*/61 int SpcStatic::ObjectEnum(void){/*{{{*/62 63 return SpcStaticEnum;64 65 }66 /*}}}*/67 38 Object* SpcStatic::copy() {/*{{{*/ 68 39 … … 78 49 } 79 50 /*}}}*/ 51 void SpcStatic::DeepEcho(void){/*{{{*/ 52 53 _printf_("SpcStatic:\n"); 54 _printf_(" sid: " << sid << "\n"); 55 _printf_(" nodeid: " << nodeid << "\n"); 56 _printf_(" dof: " << dof << "\n"); 57 _printf_(" value: " << value << "\n"); 58 _printf_(" analysis_type: " << EnumToStringx(analysis_type) << "\n"); 59 return; 60 } 61 /*}}}*/ 62 void SpcStatic::Echo(void){/*{{{*/ 63 64 _printf_("SpcStatic:\n"); 65 _printf_(" sid: " << sid << "\n"); 66 _printf_(" nodeid: " << nodeid << "\n"); 67 _printf_(" dof: " << dof << "\n"); 68 _printf_(" value: " << value << "\n"); 69 _printf_(" analysis_type: " << EnumToStringx(analysis_type) << "\n"); 70 return; 71 } 72 /*}}}*/ 73 int SpcStatic::Id(void){ return sid; }/*{{{*/ 74 /*}}}*/ 75 int SpcStatic::ObjectEnum(void){/*{{{*/ 76 77 return SpcStaticEnum; 78 79 } 80 /*}}}*/ 80 81 81 82 /*Constraint virtual functions definitions: */ 82 bool SpcStatic::InAnalysis(int in_analysis_type){/*{{{*/ 83 if (in_analysis_type==this->analysis_type) return true; 84 else return false; 83 void SpcStatic::ActivatePenaltyMethod(void){/*{{{*/ 84 this->penalty = true; 85 85 } 86 86 /*}}}*/ … … 98 98 } 99 99 /*}}}*/ 100 bool SpcStatic::InAnalysis(int in_analysis_type){/*{{{*/ 101 if (in_analysis_type==this->analysis_type) return true; 102 else return false; 103 } 104 /*}}}*/ 100 105 101 106 /*SpcStatic functions*/ 102 int SpcStatic::GetDof(){/*{{{*/107 int SpcStatic::GetDof(){/*{{{*/ 103 108 return dof; 104 109 } 105 110 /*}}}*/ 106 int SpcStatic::GetNodeId(){/*{{{*/111 int SpcStatic::GetNodeId(){/*{{{*/ 107 112 108 113 return nodeid; -
issm/trunk/src/c/classes/Constraints/SpcStatic.h
r15067 r19105 14 14 15 15 private: 16 int sid; /*! id, to track it*/ 17 int nodeid; /*!node id*/ 18 int dof; /*!component*/ 19 IssmDouble value; /*value*/ 20 int analysis_type; 16 int sid; /*! id, to track it */ 17 int nodeid; /*!node id */ 18 int dof; /*!component */ 19 IssmDouble value; /*value */ 20 int analysis_type; 21 bool penalty; /*Is this a penalty constraint */ 21 22 22 23 public: … … 35 36 /*}}}*/ 36 37 /*Constraint virtual functions definitions: {{{*/ 38 void ActivatePenaltyMethod(void); 37 39 void ConstrainNode(Nodes* nodes,Parameters* parameters); 38 40 bool InAnalysis(int analysis_type); 41 void PenaltyDofAndValue(int* dof,IssmDouble* value,Nodes* nodes,Parameters* parameters){_error_("not implemented yet");}; 39 42 /*}}}*/ 40 43 /*SpcStatic management:{{{ */ -
issm/trunk/src/c/classes/Constraints/SpcTransient.cpp
r18301 r19105 15 15 /*SpcTransient constructors and destructor*/ 16 16 SpcTransient::SpcTransient(){/*{{{*/ 17 sid=-1; 18 nodeid=-1; 19 dof=-1; 20 values=NULL; 21 times=NULL; 22 nsteps=-1; 23 analysis_type=-1; 17 penalty = false; 18 sid = -1; 19 nodeid = -1; 20 dof = -1; 21 values = NULL; 22 times = NULL; 23 nsteps = -1; 24 analysis_type = -1; 24 25 return; 25 26 } … … 27 28 SpcTransient::SpcTransient(int spc_sid,int spc_nodeid, int spc_dof,int spc_nsteps, IssmDouble* spc_times, IssmDouble* spc_values,int spc_analysis_type){/*{{{*/ 28 29 29 sid=spc_sid; 30 nodeid=spc_nodeid; 31 dof=spc_dof; 32 nsteps=spc_nsteps; 30 penalty = false; 31 sid = spc_sid; 32 nodeid = spc_nodeid; 33 dof = spc_dof; 34 nsteps = spc_nsteps; 33 35 if(spc_nsteps){ 34 values =xNew<IssmDouble>(spc_nsteps);35 times =xNew<IssmDouble>(spc_nsteps);36 values = xNew<IssmDouble>(spc_nsteps); 37 times = xNew<IssmDouble>(spc_nsteps); 36 38 xMemCpy<IssmDouble>(values,spc_values,nsteps); 37 39 xMemCpy<IssmDouble>(times,spc_times,nsteps); … … 49 51 50 52 /*Object virtual functions definitions:*/ 51 void SpcTransient::Echo(void){/*{{{*/ 53 Object* SpcTransient::copy() {/*{{{*/ 54 return new SpcTransient(sid,nodeid,dof,nsteps,times,values,analysis_type); 55 } 56 /*}}}*/ 57 void SpcTransient::DeepEcho(void){/*{{{*/ 58 this->Echo(); 59 } 60 /*}}}*/ 61 void SpcTransient::Echo(void){/*{{{*/ 52 62 53 63 int i; … … 65 75 } 66 76 /*}}}*/ 67 void SpcTransient::DeepEcho(void){/*{{{*/ 68 this->Echo(); 69 } 70 /*}}}*/ 71 int SpcTransient::Id(void){ return sid; }/*{{{*/ 72 /*}}}*/ 73 int SpcTransient::ObjectEnum(void){/*{{{*/ 77 int SpcTransient::Id(void){/*{{{*/ 78 return sid; 79 } 80 /*}}}*/ 81 int SpcTransient::ObjectEnum(void){/*{{{*/ 74 82 75 83 return SpcTransientEnum; … … 77 85 } 78 86 /*}}}*/ 79 Object* SpcTransient::copy() {/*{{{*/80 return new SpcTransient(sid,nodeid,dof,nsteps,times,values,analysis_type);81 }82 /*}}}*/83 87 84 88 /*Constraint virtual functions definitions:*/ 85 bool SpcTransient::InAnalysis(int in_analysis_type){/*{{{*/ 86 87 if (in_analysis_type==this->analysis_type) return true; 88 else return false; 89 void SpcTransient::ActivatePenaltyMethod(void){/*{{{*/ 90 this->penalty = true; 89 91 } 90 92 /*}}}*/ … … 101 103 node=(Node*)nodes->GetObjectById(NULL,nodeid); 102 104 103 if( node){ //in case the spc is dealing with a node on another cpu105 if(!this->penalty && node){ //in case the spc is dealing with a node on another cpu 104 106 105 107 /*Retrieve time in parameters: */ … … 130 132 /*Apply or relax constraint: */ 131 133 if(xIsNan<IssmDouble>(value)){ 132 printf("-------------- file: SpcTransient.cpp line: %i\n",__LINE__);133 134 node->RelaxConstraint(dof); 134 135 } … … 137 138 } 138 139 /*}}}*/ 140 bool SpcTransient::InAnalysis(int in_analysis_type){/*{{{*/ 141 142 if (in_analysis_type==this->analysis_type) return true; 143 else return false; 144 } 145 /*}}}*/ 146 void SpcTransient::PenaltyDofAndValue(int* pdof,IssmDouble* pvalue,Nodes* nodes,Parameters* parameters){/*{{{*/ 147 148 if(!this->penalty) _error_("cannot return dof and value for non penalty constraint"); 149 150 Node *node = NULL; 151 IssmDouble time = 0.; 152 int i,gdof; 153 IssmDouble alpha = -1.; 154 IssmDouble value; 155 bool found = false; 156 157 /*Chase through nodes and find the node to which this SpcTransient applys: */ 158 node=(Node*)nodes->GetObjectById(NULL,nodeid); 159 160 if(node){ //in case the spc is dealing with a node on another cpu 161 162 /*Retrieve time in parameters: */ 163 parameters->FindParam(&time,TimeEnum); 164 165 /*Now, go fetch value for this time: */ 166 if (time<=times[0]){ 167 value=values[0]; 168 found=true; 169 } 170 else if (time>=times[nsteps-1]){ 171 value=values[nsteps-1]; 172 found=true; 173 } 174 else{ 175 for(i=0;i<nsteps-1;i++){ 176 if (times[i]<=time && time<times[i+1]){ 177 alpha=(time-times[i])/(times[i+1]-times[i]); 178 value=(1-alpha)*values[i]+alpha*values[i+1]; 179 found=true; 180 break; 181 } 182 } 183 } 184 if(!found)_error_("could not find time segment for constraint"); 185 186 /*Get gdof */ 187 gdof = node->GetDof(dof,GsetEnum); 188 if(xIsNan<IssmDouble>(value)){ 189 gdof = -1; 190 } 191 } 192 else{ 193 value = NAN; 194 gdof = -1; 195 } 196 197 /*Assign output pointers*/ 198 *pdof = gdof; 199 *pvalue = value; 200 } 201 /*}}}*/ 139 202 140 203 /*SpcTransient functions*/ 141 int SpcTransient::GetDof(){/*{{{*/204 int SpcTransient::GetDof(){/*{{{*/ 142 205 return dof; 143 206 } 144 207 /*}}}*/ 145 int SpcTransient::GetNodeId(){/*{{{*/208 int SpcTransient::GetNodeId(){/*{{{*/ 146 209 147 210 return nodeid; -
issm/trunk/src/c/classes/Constraints/SpcTransient.h
r15067 r19105 14 14 15 15 private: 16 int sid; /*! id, to track it*/ 17 int nodeid; /*!node id*/ 18 int dof; /*!component*/ 19 IssmDouble* values; /*different values in time*/ 20 IssmDouble* times; /*different time steps*/ 21 int nsteps; /*number of time steps*/ 22 int analysis_type; 16 int sid; /* id, to track it */ 17 int nodeid; /*node id */ 18 int dof; /*component */ 19 IssmDouble *values; /*different values in time */ 20 IssmDouble *times; /*different time steps */ 21 int nsteps; /*number of time steps */ 22 int analysis_type; 23 bool penalty; /*Is this a penalty constraint */ 23 24 24 25 public: … … 30 31 /*}}}*/ 31 32 /*Object virtual functions definitions:{{{ */ 32 void Echo();33 void DeepEcho();34 int Id();35 int ObjectEnum();36 33 Object* copy(); 34 void DeepEcho(); 35 void Echo(); 36 int Id(); 37 int ObjectEnum(); 37 38 /*}}}*/ 38 39 /*Constraint virtual functions definitions: {{{*/ 40 void ActivatePenaltyMethod(void); 39 41 void ConstrainNode(Nodes* nodes,Parameters* parameters); 40 42 bool InAnalysis(int analysis_type); 43 void PenaltyDofAndValue(int* dof,IssmDouble* value,Nodes* nodes,Parameters* parameters); 41 44 /*}}}*/ 42 45 /*SpcTransient management:{{{ */ 43 int GetNodeId();44 int GetDof();46 int GetDof(); 47 int GetNodeId(); 45 48 IssmDouble GetValue(); 46 49 /*}}}*/ -
issm/trunk/src/c/classes/Definition.h
r16560 r19105 13 13 virtual ~Definition(){}; 14 14 virtual char* Name()=0; 15 virtual int DefinitionEnum()=0; 15 16 virtual IssmDouble Response(FemModel*)=0; 16 17 -
issm/trunk/src/c/classes/Elements/Element.cpp
r18301 r19105 183 183 IssmDouble* eps_xz = xNew<IssmDouble>(numvertices); 184 184 IssmDouble* eps_yz = xNew<IssmDouble>(numvertices); 185 IssmDouble* eps_ef = xNew<IssmDouble>(numvertices); 185 186 186 187 /* Start looping on the number of vertices: */ … … 200 201 eps_yy[iv]=epsilon[1]; 201 202 eps_xy[iv]=epsilon[2]; 203 /* eps_eff^2 = 1/2 ( exx^2 + eyy^2 + 2*exy^2 )*/ 204 eps_ef[iv] = 1./sqrt(2.)*sqrt(epsilon[0]*epsilon[0] + epsilon[1]*epsilon[1] + 2.*epsilon[2]*epsilon[2]); 202 205 } 203 206 else{ … … 209 212 eps_xz[iv]=epsilon[4]; 210 213 eps_yz[iv]=epsilon[5]; 214 /* eps_eff^2 = exx^2 + eyy^2 + exy^2 + exz^2 + eyz^2 + exx*eyy */ 215 eps_ef[iv] = sqrt(epsilon[0]*epsilon[0] + epsilon[1]*epsilon[1] + epsilon[3]*epsilon[3] + epsilon[4]*epsilon[4] + epsilon[5]*epsilon[5] + epsilon[0]*epsilon[1]); 211 216 } 212 217 } … … 219 224 this->AddInput(StrainRateyzEnum,eps_yz,P1Enum); 220 225 this->AddInput(StrainRatezzEnum,eps_zz,P1Enum); 226 this->AddInput(StrainRateeffectiveEnum,eps_ef,P1Enum); 221 227 222 228 /*Clean up and return*/ … … 306 312 } 307 313 /*}}}*/ 308 void Element::DeleteMaterials(void){/*{{{*/309 delete this->material;310 }/*}}}*/311 314 void Element::DeepEcho(void){/*{{{*/ 312 315 … … 343 346 } 344 347 /*}}}*/ 345 void Element::Echo(void){/*{{{*/ 346 _printf_(EnumToStringx(this->ObjectEnum())<<" element:\n"); 347 _printf_(" id : "<<this->id <<"\n"); 348 _printf_(" sid: "<<this->sid<<"\n"); 349 if(vertices){ 350 int numvertices = this->GetNumberOfVertices(); 351 for(int i=0;i<numvertices;i++) vertices[i]->Echo(); 352 } 353 else _printf_("vertices = NULL\n"); 354 355 if(nodes){ 356 int numnodes = this->GetNumberOfNodes(); 357 for(int i=0;i<numnodes;i++) { 358 _printf_("nodes[" << i << "] = " << nodes[i]); 359 nodes[i]->Echo(); 360 } 361 } 362 else _printf_("nodes = NULL\n"); 363 364 if (material) material->Echo(); 365 else _printf_("material = NULL\n"); 366 367 if (matpar) matpar->Echo(); 368 else _printf_("matpar = NULL\n"); 369 370 _printf_(" parameters\n"); 371 if (parameters) parameters->Echo(); 372 else _printf_("parameters = NULL\n"); 373 374 _printf_(" inputs\n"); 375 if (inputs) inputs->Echo(); 376 else _printf_("inputs=NULL\n"); 377 } 378 /*}}}*/ 348 void Element::DeleteInput(int input_enum){/*{{{*/ 349 350 inputs->DeleteInput(input_enum); 351 352 } 353 /*}}}*/ 354 void Element::DeleteMaterials(void){/*{{{*/ 355 delete this->material; 356 }/*}}}*/ 379 357 IssmDouble Element::Divergence(void){/*{{{*/ 380 358 /*Compute element divergence*/ … … 419 397 return divergence; 420 398 }/*}}}*/ 399 void Element::dViscositydBFS(IssmDouble* pdmudB,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vz_input){/*{{{*/ 400 401 /*Intermediaries*/ 402 IssmDouble dmudB; 403 IssmDouble epsilon3d[6];/* epsilon=[exx,eyy,exy,exy,exz,eyz]; */ 404 IssmDouble epsilon2d[3];/* epsilon=[exx,eyy,exy]; */ 405 IssmDouble eps_eff; 406 IssmDouble eps0=1.e-27; 407 408 if(dim==3){ 409 /* eps_eff^2 = exx^2 + eyy^2 + exy^2 + exz^2 + eyz^2 + exx*eyy */ 410 this->StrainRateFS(&epsilon3d[0],xyz_list,gauss,vx_input,vy_input,vz_input); 411 eps_eff = sqrt(epsilon3d[0]*epsilon3d[0] + epsilon3d[1]*epsilon3d[1] + epsilon3d[3]*epsilon3d[3] + epsilon3d[4]*epsilon3d[4] + epsilon3d[5]*epsilon3d[5] + epsilon3d[0]*epsilon3d[1]+eps0*eps0); 412 } 413 else{ 414 /* eps_eff^2 = 1/2 ( exx^2 + eyy^2 + 2*exy^2 )*/ 415 this->StrainRateSSA(&epsilon2d[0],xyz_list,gauss,vx_input,vy_input); 416 eps_eff = 1./sqrt(2.)*sqrt(epsilon2d[0]*epsilon2d[0] + epsilon2d[1]*epsilon2d[1] + 2.*epsilon2d[2]*epsilon2d[2]); 417 } 418 /*Get viscosity*/ 419 material->GetViscosity_B(&dmudB,eps_eff); 420 421 /*Assign output pointer*/ 422 *pdmudB=dmudB; 423 424 } 425 /*}}}*/ 426 void Element::dViscositydBHO(IssmDouble* pdmudB,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input){/*{{{*/ 427 428 /*Intermediaries*/ 429 IssmDouble dmudB; 430 IssmDouble epsilon3d[5];/* epsilon=[exx,eyy,exy,exy,exz,eyz]; */ 431 IssmDouble epsilon2d[2];/* epsilon=[exx,eyy,exy]; */ 432 IssmDouble eps_eff; 433 IssmDouble eps0=1.e-27; 434 435 if(dim==3){ 436 /* eps_eff^2 = exx^2 + eyy^2 + exy^2 + exz^2 + eyz^2 + exx*eyy */ 437 this->StrainRateHO(&epsilon3d[0],xyz_list,gauss,vx_input,vy_input); 438 eps_eff = sqrt(epsilon3d[0]*epsilon3d[0] + epsilon3d[1]*epsilon3d[1] + epsilon3d[2]*epsilon3d[2] + epsilon3d[3]*epsilon3d[3] + epsilon3d[4]*epsilon3d[4] + epsilon3d[0]*epsilon3d[1]+eps0*eps0); 439 } 440 else{ 441 /* eps_eff^2 = 1/2 ( exx^2 + eyy^2 + 2*exy^2 )*/ 442 this->StrainRateHO2dvertical(&epsilon2d[0],xyz_list,gauss,vx_input,vy_input); 443 eps_eff = 1./sqrt(2.)*sqrt(epsilon2d[0]*epsilon2d[0] + 2.*epsilon2d[1]*epsilon2d[1] + eps0*eps0); 444 } 445 /*Get viscosity*/ 446 material->GetViscosity_B(&dmudB,eps_eff); 447 448 /*Assign output pointer*/ 449 *pdmudB=dmudB; 450 451 } 452 /*}}}*/ 421 453 void Element::dViscositydBSSA(IssmDouble* pdmudB,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input){/*{{{*/ 422 454 … … 473 505 } 474 506 /*}}}*/ 475 void Element::ThermalToEnthalpy(IssmDouble* penthalpy,IssmDouble temperature,IssmDouble waterfraction,IssmDouble pressure){/*{{{*/ 476 matpar->ThermalToEnthalpy(penthalpy,temperature,waterfraction,pressure); 507 void Element::Echo(void){/*{{{*/ 508 _printf_(EnumToStringx(this->ObjectEnum())<<" element:\n"); 509 _printf_(" id : "<<this->id <<"\n"); 510 _printf_(" sid: "<<this->sid<<"\n"); 511 if(vertices){ 512 int numvertices = this->GetNumberOfVertices(); 513 for(int i=0;i<numvertices;i++) vertices[i]->Echo(); 514 } 515 else _printf_("vertices = NULL\n"); 516 517 if(nodes){ 518 int numnodes = this->GetNumberOfNodes(); 519 for(int i=0;i<numnodes;i++) { 520 _printf_("nodes[" << i << "] = " << nodes[i]); 521 nodes[i]->Echo(); 522 } 523 } 524 else _printf_("nodes = NULL\n"); 525 526 if (material) material->Echo(); 527 else _printf_("material = NULL\n"); 528 529 if (matpar) matpar->Echo(); 530 else _printf_("matpar = NULL\n"); 531 532 _printf_(" parameters\n"); 533 if (parameters) parameters->Echo(); 534 else _printf_("parameters = NULL\n"); 535 536 _printf_(" inputs\n"); 537 if (inputs) inputs->Echo(); 538 else _printf_("inputs=NULL\n"); 539 } 540 /*}}}*/ 541 IssmDouble Element::EnthalpyDiffusionParameter(IssmDouble enthalpy,IssmDouble pressure){/*{{{*/ 542 return matpar->GetEnthalpyDiffusionParameter(enthalpy,pressure); 543 }/*}}}*/ 544 IssmDouble Element::EnthalpyDiffusionParameterVolume(int numvertices,IssmDouble* enthalpy,IssmDouble* pressure){/*{{{*/ 545 return matpar->GetEnthalpyDiffusionParameterVolume(numvertices,enthalpy,pressure); 477 546 }/*}}}*/ 478 547 void Element::EnthalpyToThermal(IssmDouble* ptemperature,IssmDouble* pwaterfraction,IssmDouble enthalpy,IssmDouble pressure){/*{{{*/ 479 548 matpar->EnthalpyToThermal(ptemperature,pwaterfraction,enthalpy,pressure); 480 }/*}}}*/481 IssmDouble Element::EnthalpyDiffusionParameter(IssmDouble enthalpy,IssmDouble pressure){/*{{{*/482 return matpar->GetEnthalpyDiffusionParameter(enthalpy,pressure);483 }/*}}}*/484 IssmDouble Element::EnthalpyDiffusionParameterVolume(int numvertices,IssmDouble* enthalpy,IssmDouble* pressure){/*{{{*/485 return matpar->GetEnthalpyDiffusionParameterVolume(numvertices,enthalpy,pressure);486 549 }/*}}}*/ 487 550 void Element::FindParam(bool* pvalue,int paramenum){/*{{{*/ … … 520 583 } 521 584 /*}}}*/ 585 void Element::GetDofListPressure(int** pdoflist,int setenum){/*{{{*/ 586 587 /*Fetch number of nodes and dof for this finite element*/ 588 int vnumnodes = this->NumberofNodesVelocity(); 589 int pnumnodes = this->NumberofNodesPressure(); 590 591 /*First, figure out size of doflist and create it: */ 592 int numberofdofs=0; 593 for(int i=vnumnodes;i<vnumnodes+pnumnodes;i++) numberofdofs+=nodes[i]->GetNumberOfDofs(FSApproximationEnum,setenum); 594 595 /*Allocate output*/ 596 int* doflist=xNew<int>(numberofdofs); 597 598 /*Populate: */ 599 int count=0; 600 for(int i=vnumnodes;i<vnumnodes+pnumnodes;i++){ 601 nodes[i]->GetDofList(doflist+count,FSApproximationEnum,setenum); 602 count+=nodes[i]->GetNumberOfDofs(FSApproximationEnum,setenum); 603 } 604 605 /*Assign output pointers:*/ 606 *pdoflist=doflist; 607 } 608 /*}}}*/ 522 609 void Element::GetDofListVelocity(int** pdoflist,int setenum){/*{{{*/ 523 610 … … 543 630 } 544 631 /*}}}*/ 545 void Element::GetDofListPressure(int** pdoflist,int setenum){/*{{{*/ 546 547 /*Fetch number of nodes and dof for this finite element*/ 548 int vnumnodes = this->NumberofNodesVelocity(); 549 int pnumnodes = this->NumberofNodesPressure(); 550 551 /*First, figure out size of doflist and create it: */ 552 int numberofdofs=0; 553 for(int i=vnumnodes;i<vnumnodes+pnumnodes;i++) numberofdofs+=nodes[i]->GetNumberOfDofs(FSApproximationEnum,setenum); 554 555 /*Allocate output*/ 556 int* doflist=xNew<int>(numberofdofs); 557 558 /*Populate: */ 559 int count=0; 560 for(int i=vnumnodes;i<vnumnodes+pnumnodes;i++){ 561 nodes[i]->GetDofList(doflist+count,FSApproximationEnum,setenum); 562 count+=nodes[i]->GetNumberOfDofs(FSApproximationEnum,setenum); 563 } 564 565 /*Assign output pointers:*/ 566 *pdoflist=doflist; 567 } 568 /*}}}*/ 632 Input* Element::GetInput(int inputenum){/*{{{*/ 633 return inputs->GetInput(inputenum); 634 }/*}}}*/ 635 void Element::GetInputListOnNodes(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue){/*{{{*/ 636 637 _assert_(pvalue); 638 639 Input *input = this->GetInput(enumtype); 640 int numnodes = this->GetNumberOfNodes(); 641 642 /* Start looping on the number of vertices: */ 643 if(input){ 644 Gauss* gauss=this->NewGauss(); 645 for(int iv=0;iv<numnodes;iv++){ 646 gauss->GaussNode(this->FiniteElement(),iv); 647 input->GetInputValue(&pvalue[iv],gauss); 648 } 649 delete gauss; 650 } 651 else{ 652 for(int iv=0;iv<numnodes;iv++) pvalue[iv]=defaultvalue; 653 } 654 } 655 /*}}}*/ 656 void Element::GetInputListOnNodes(IssmDouble* pvalue,int enumtype){/*{{{*/ 657 658 _assert_(pvalue); 659 660 int numnodes = this->GetNumberOfNodes(); 661 Input *input = this->GetInput(enumtype); 662 if(!input) _error_("Input " << EnumToStringx(enumtype) << " not found in element"); 663 664 /* Start looping on the number of vertices: */ 665 Gauss* gauss=this->NewGauss(); 666 for(int iv=0;iv<numnodes;iv++){ 667 gauss->GaussNode(this->FiniteElement(),iv); 668 input->GetInputValue(&pvalue[iv],gauss); 669 } 670 delete gauss; 671 } 672 /*}}}*/ 673 void Element::GetInputListOnNodesVelocity(IssmDouble* pvalue,int enumtype){/*{{{*/ 674 675 _assert_(pvalue); 676 677 int numnodes = this->NumberofNodesVelocity(); 678 Input *input = this->GetInput(enumtype); 679 if(!input) _error_("Input " << EnumToStringx(enumtype) << " not found in element"); 680 681 /* Start looping on the number of vertices: */ 682 Gauss* gauss=this->NewGauss(); 683 for(int iv=0;iv<numnodes;iv++){ 684 gauss->GaussNode(this->VelocityInterpolation(),iv); 685 input->GetInputValue(&pvalue[iv],gauss); 686 } 687 delete gauss; 688 } 689 /*}}}*/ 690 void Element::GetInputListOnVertices(IssmDouble* pvalue,int enumtype){/*{{{*/ 691 692 /*Recover input*/ 693 Input* input=this->GetInput(enumtype); 694 if (!input) _error_("Input " << EnumToStringx(enumtype) << " not found in element"); 695 696 /*Fetch number vertices for this element*/ 697 int numvertices = this->GetNumberOfVertices(); 698 699 /*Checks in debugging mode*/ 700 _assert_(pvalue); 701 702 /* Start looping on the number of vertices: */ 703 Gauss*gauss=this->NewGauss(); 704 for(int iv=0;iv<numvertices;iv++){ 705 gauss->GaussVertex(iv); 706 input->GetInputValue(&pvalue[iv],gauss); 707 } 708 709 /*clean-up*/ 710 delete gauss; 711 } 712 /*}}}*/ 713 void Element::GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue){/*{{{*/ 714 715 /*Recover input*/ 716 Input* input=this->GetInput(enumtype); 717 718 /*Checks in debugging mode*/ 719 _assert_(pvalue); 720 721 /*Fetch number vertices for this element*/ 722 int numvertices = this->GetNumberOfVertices(); 723 724 /* Start looping on the number of vertices: */ 725 if (input){ 726 Gauss* gauss=this->NewGauss(); 727 for (int iv=0;iv<numvertices;iv++){ 728 gauss->GaussVertex(iv); 729 input->GetInputValue(&pvalue[iv],gauss); 730 } 731 delete gauss; 732 } 733 else{ 734 for(int iv=0;iv<numvertices;iv++) pvalue[iv]=defaultvalue; 735 } 736 } 737 /*}}}*/ 738 void Element::GetInputLocalMinMaxOnNodes(IssmDouble* min,IssmDouble* max,IssmDouble* ug){/*{{{*/ 739 740 741 /*Get number of nodes for this element*/ 742 int numnodes = this->GetNumberOfNodes(); 743 744 /*Some checks to avoid segmentation faults*/ 745 _assert_(ug); 746 _assert_(numnodes>0); 747 _assert_(nodes); 748 749 /*Get element minimum/maximum*/ 750 IssmDouble input_min = ug[nodes[0]->GetDof(0,GsetEnum)]; 751 IssmDouble input_max = input_min; 752 for(int i=1;i<numnodes;i++){ 753 if(ug[nodes[i]->GetDof(0,GsetEnum)] < input_min) input_min = ug[nodes[i]->GetDof(0,GsetEnum)]; 754 if(ug[nodes[i]->GetDof(0,GsetEnum)] > input_max) input_max = ug[nodes[i]->GetDof(0,GsetEnum)]; 755 } 756 757 758 /*Second loop to reassign min and max with local extrema*/ 759 for(int i=0;i<numnodes;i++){ 760 if(min[nodes[i]->GetDof(0,GsetEnum)]>input_min) min[nodes[i]->GetDof(0,GsetEnum)] = input_min; 761 if(max[nodes[i]->GetDof(0,GsetEnum)]<input_max) max[nodes[i]->GetDof(0,GsetEnum)] = input_max; 762 } 763 } 764 /*}}}*/ 765 void Element::GetInputValue(bool* pvalue,int inputenum){/*{{{*/ 766 767 Input* input=inputs->GetInput(inputenum); 768 if(!input) _error_("Input " << EnumToStringx(inputenum) << " not found in element"); 769 input->GetInputValue(pvalue); 770 771 }/*}}}*/ 772 void Element::GetInputValue(int* pvalue,int inputenum){/*{{{*/ 773 774 Input* input=inputs->GetInput(inputenum); 775 if(!input) _error_("Input " << EnumToStringx(inputenum) << " not found in element"); 776 input->GetInputValue(pvalue); 777 778 }/*}}}*/ 779 void Element::GetInputValue(IssmDouble* pvalue,int inputenum){/*{{{*/ 780 781 Input* input=inputs->GetInput(inputenum); 782 if(!input) _error_("Input " << EnumToStringx(inputenum) << " not found in element"); 783 input->GetInputValue(pvalue); 784 785 }/*}}}*/ 786 void Element::GetInputValue(IssmDouble* pvalue,Gauss* gauss,int inputenum){/*{{{*/ 787 788 Input* input=inputs->GetInput(inputenum); 789 if(!input) _error_("Input " << EnumToStringx(inputenum) << " not found in element"); 790 input->GetInputValue(pvalue,gauss); 791 792 }/*}}}*/ 569 793 IssmDouble Element::GetMaterialParameter(int enum_in){/*{{{*/ 570 794 … … 581 805 } 582 806 }/*}}}*/ 807 void Element::GetNodesLidList(int* lidlist){/*{{{*/ 808 809 _assert_(lidlist); 810 _assert_(nodes); 811 int numnodes = this->GetNumberOfNodes(); 812 for(int i=0;i<numnodes;i++){ 813 lidlist[i]=nodes[i]->Lid(); 814 } 815 } 816 /*}}}*/ 817 void Element::GetNodesSidList(int* sidlist){/*{{{*/ 818 819 _assert_(sidlist); 820 _assert_(nodes); 821 int numnodes = this->GetNumberOfNodes(); 822 for(int i=0;i<numnodes;i++){ 823 sidlist[i]=nodes[i]->Sid(); 824 } 825 } 826 /*}}}*/ 583 827 void Element::GetPhi(IssmDouble* phi, IssmDouble* epsilon, IssmDouble viscosity){/*{{{*/ 584 828 /*Compute deformational heating from epsilon and viscosity */ … … 618 862 } 619 863 /*}}}*/ 620 Input* Element::GetInput(int inputenum){/*{{{*/ 621 return inputs->GetInput(inputenum); 622 }/*}}}*/ 623 void Element::GetInputListOnVertices(IssmDouble* pvalue,int enumtype){/*{{{*/ 624 625 /*Recover input*/ 626 Input* input=this->GetInput(enumtype); 627 if (!input) _error_("Input " << EnumToStringx(enumtype) << " not found in element"); 628 629 /*Fetch number vertices for this element*/ 630 int numvertices = this->GetNumberOfVertices(); 631 632 /*Checks in debugging mode*/ 633 _assert_(pvalue); 634 635 /* Start looping on the number of vertices: */ 636 Gauss*gauss=this->NewGauss(); 637 for(int iv=0;iv<numvertices;iv++){ 638 gauss->GaussVertex(iv); 639 input->GetInputValue(&pvalue[iv],gauss); 640 } 641 642 /*clean-up*/ 643 delete gauss; 644 } 645 /*}}}*/ 646 void Element::GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue){/*{{{*/ 647 648 /*Recover input*/ 649 Input* input=this->GetInput(enumtype); 650 651 /*Checks in debugging mode*/ 652 _assert_(pvalue); 653 654 /*Fetch number vertices for this element*/ 655 int numvertices = this->GetNumberOfVertices(); 656 657 /* Start looping on the number of vertices: */ 658 if (input){ 659 Gauss* gauss=this->NewGauss(); 660 for (int iv=0;iv<numvertices;iv++){ 661 gauss->GaussVertex(iv); 662 input->GetInputValue(&pvalue[iv],gauss); 663 } 664 delete gauss; 665 } 666 else{ 667 for(int iv=0;iv<numvertices;iv++) pvalue[iv]=defaultvalue; 668 } 669 } 670 /*}}}*/ 671 void Element::GetInputListOnNodes(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue){/*{{{*/ 672 673 _assert_(pvalue); 674 675 Input *input = this->GetInput(enumtype); 676 int numnodes = this->GetNumberOfNodes(); 677 678 /* Start looping on the number of vertices: */ 679 if(input){ 680 Gauss* gauss=this->NewGauss(); 681 for(int iv=0;iv<numnodes;iv++){ 682 gauss->GaussNode(this->FiniteElement(),iv); 683 input->GetInputValue(&pvalue[iv],gauss); 684 } 685 delete gauss; 686 } 687 else{ 688 for(int iv=0;iv<numnodes;iv++) pvalue[iv]=defaultvalue; 689 } 690 } 691 /*}}}*/ 692 void Element::GetInputListOnNodes(IssmDouble* pvalue,int enumtype){/*{{{*/ 693 694 _assert_(pvalue); 695 696 int numnodes = this->GetNumberOfNodes(); 697 Input *input = this->GetInput(enumtype); 698 if(!input) _error_("Input " << EnumToStringx(enumtype) << " not found in element"); 699 700 /* Start looping on the number of vertices: */ 701 Gauss* gauss=this->NewGauss(); 702 for(int iv=0;iv<numnodes;iv++){ 703 gauss->GaussNode(this->FiniteElement(),iv); 704 input->GetInputValue(&pvalue[iv],gauss); 705 } 706 delete gauss; 707 } 708 /*}}}*/ 709 void Element::GetInputListOnNodesVelocity(IssmDouble* pvalue,int enumtype){/*{{{*/ 710 711 _assert_(pvalue); 712 713 int numnodes = this->NumberofNodesVelocity(); 714 Input *input = this->GetInput(enumtype); 715 if(!input) _error_("Input " << EnumToStringx(enumtype) << " not found in element"); 716 717 /* Start looping on the number of vertices: */ 718 Gauss* gauss=this->NewGauss(); 719 for(int iv=0;iv<numnodes;iv++){ 720 gauss->GaussNode(this->VelocityInterpolation(),iv); 721 input->GetInputValue(&pvalue[iv],gauss); 722 } 723 delete gauss; 724 } 725 /*}}}*/ 726 void Element::GetInputValue(bool* pvalue,int inputenum){/*{{{*/ 727 728 Input* input=inputs->GetInput(inputenum); 729 if(!input) _error_("Input " << EnumToStringx(inputenum) << " not found in element"); 730 input->GetInputValue(pvalue); 731 732 }/*}}}*/ 733 void Element::GetInputValue(int* pvalue,int inputenum){/*{{{*/ 734 735 Input* input=inputs->GetInput(inputenum); 736 if(!input) _error_("Input " << EnumToStringx(inputenum) << " not found in element"); 737 input->GetInputValue(pvalue); 738 739 }/*}}}*/ 740 void Element::GetInputValue(IssmDouble* pvalue,int inputenum){/*{{{*/ 741 742 Input* input=inputs->GetInput(inputenum); 743 if(!input) _error_("Input " << EnumToStringx(inputenum) << " not found in element"); 744 input->GetInputValue(pvalue); 745 746 }/*}}}*/ 747 void Element::GetInputValue(IssmDouble* pvalue,Gauss* gauss,int inputenum){/*{{{*/ 748 749 Input* input=inputs->GetInput(inputenum); 750 if(!input) _error_("Input " << EnumToStringx(inputenum) << " not found in element"); 751 input->GetInputValue(pvalue,gauss); 752 753 }/*}}}*/ 754 void Element::GetNodesSidList(int* sidlist){/*{{{*/ 755 756 _assert_(sidlist); 757 _assert_(nodes); 758 int numnodes = this->GetNumberOfNodes(); 759 for(int i=0;i<numnodes;i++){ 760 sidlist[i]=nodes[i]->Sid(); 761 } 762 } 763 /*}}}*/ 764 void Element::GetNodesLidList(int* lidlist){/*{{{*/ 765 766 _assert_(lidlist); 767 _assert_(nodes); 768 int numnodes = this->GetNumberOfNodes(); 769 for(int i=0;i<numnodes;i++){ 770 lidlist[i]=nodes[i]->Lid(); 771 } 772 } 773 /*}}}*/ 774 void Element::GetVectorFromInputs(Vector<IssmDouble>* vector,int input_enum){/*{{{*/ 864 /* void Element::GetVectorFromInputs(Vector<IssmDouble>* vector,int input_enum){/\*{{{*\/ */ 865 866 /* /\*Fetch number vertices for this element and allocate arrays*\/ */ 867 /* int numvertices = this->GetNumberOfVertices(); */ 868 /* int* vertexpidlist = xNew<int>(numvertices); */ 869 /* IssmDouble* values = xNew<IssmDouble>(numvertices); */ 870 871 /* /\*Fill in values*\/ */ 872 /* this->GetVertexPidList(vertexpidlist); */ 873 /* this->GetInputListOnVertices(values,input_enum); */ 874 /* vector->SetValues(numvertices,vertexpidlist,values,INS_VAL); */ 875 876 /* /\*Clean up*\/ */ 877 /* xDelete<int>(vertexpidlist); */ 878 /* xDelete<IssmDouble>(values); */ 879 880 /* } */ 881 /* /\*}}}*\/ */ 882 void Element::GetVectorFromInputs(Vector<IssmDouble>* vector,int input_enum,int type){/*{{{*/ 775 883 776 884 /*Fetch number vertices for this element and allocate arrays*/ 777 int numvertices = this->GetNumberOfVertices(); 778 int* vertexpidlist = xNew<int>(numvertices); 779 IssmDouble* values = xNew<IssmDouble>(numvertices); 780 781 /*Fill in values*/ 782 this->GetVertexPidList(vertexpidlist); 783 this->GetInputListOnVertices(values,input_enum); 784 vector->SetValues(numvertices,vertexpidlist,values,INS_VAL); 785 885 int numvertices = this->GetNumberOfVertices(); 886 int numnodes = this->GetNumberOfNodes(); 887 int* doflist = NULL; 888 IssmDouble* values = NULL; 889 890 switch(type){ 891 case VertexPIdEnum: 892 doflist = xNew<int>(numvertices); 893 values = xNew<IssmDouble>(numvertices); 894 /*Fill in values*/ 895 this->GetVertexPidList(doflist); 896 this->GetInputListOnVertices(values,input_enum); 897 vector->SetValues(numvertices,doflist,values,INS_VAL); 898 break; 899 case VertexSIdEnum: 900 doflist = xNew<int>(numvertices); 901 values = xNew<IssmDouble>(numvertices); 902 /*Fill in values*/ 903 this->GetVerticesSidList(doflist); 904 this->GetInputListOnVertices(values,input_enum); 905 vector->SetValues(numvertices,doflist,values,INS_VAL); 906 break; 907 case NodesEnum: 908 doflist = xNew<int>(numnodes); 909 values = xNew<IssmDouble>(numnodes); 910 /*Fill in values*/ 911 this->GetInputListOnNodes(values,input_enum); 912 this->GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 913 vector->SetValues(numnodes,doflist,values,INS_VAL); 914 break; 915 case NodeSIdEnum: 916 doflist = xNew<int>(numnodes); 917 values = xNew<IssmDouble>(numnodes); 918 /*Fill in values*/ 919 this->GetNodesSidList(doflist); 920 this->GetInputListOnNodes(values,input_enum); 921 vector->SetValues(numnodes,doflist,values,INS_VAL); 922 break; 923 default: 924 _error_("type " << type << " (" << EnumToStringx(type) << ") not implemented yet"); 925 } 926 786 927 /*Clean up*/ 787 xDelete<int>( vertexpidlist);928 xDelete<int>(doflist); 788 929 xDelete<IssmDouble>(values); 789 930 … … 795 936 for(int i=0;i<numvertices;i++) pidlist[i]=vertices[i]->Pid(); 796 937 938 } 939 /*}}}*/ 940 void Element::GetVerticesConnectivityList(int* connectivity){/*{{{*/ 941 942 int numvertices = this->GetNumberOfVertices(); 943 for(int i=0;i<numvertices;i++) connectivity[i]=this->vertices[i]->Connectivity(); 797 944 } 798 945 /*}}}*/ … … 812 959 } 813 960 /*}}}*/ 814 void Element::GetVerticesConnectivityList(int* connectivity){/*{{{*/815 816 int numvertices = this->GetNumberOfVertices();817 for(int i=0;i<numvertices;i++) connectivity[i]=this->vertices[i]->Connectivity();818 }819 /*}}}*/820 961 IssmDouble Element::GetXcoord(IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 821 962 … … 863 1004 return z; 864 1005 }/*}}}*/ 865 void Element::GradientIndexing(int* indexing,int control_index ){/*{{{*/1006 void Element::GradientIndexing(int* indexing,int control_index,bool onsid){/*{{{*/ 866 1007 867 1008 /*Get number of controls*/ … … 873 1014 874 1015 /*get gradient indices*/ 875 for(int i=0;i<numvertices;i++){ 876 indexing[i]=num_controls*this->vertices[i]->Pid() + control_index; 1016 if(onsid){ 1017 for(int i=0;i<numvertices;i++){ 1018 indexing[i]=num_controls*this->vertices[i]->Sid() + control_index; 1019 } 1020 } 1021 else{ 1022 for(int i=0;i<numvertices;i++){ 1023 indexing[i]=num_controls*this->vertices[i]->Pid() + control_index; 1024 } 877 1025 } 878 1026 … … 1003 1151 parameters->FindParam(&migration_style,GroundinglineMigrationEnum); 1004 1152 1005 if(migration_style==SubelementMigrationEnum || migration_style==SubelementMigration2Enum || migration_style==ContactEnum){ //Floating if all nodes are floating1153 if(migration_style==SubelementMigrationEnum || migration_style==SubelementMigration2Enum){ //Floating if all nodes are floating 1006 1154 if(this->inputs->Max(MaskGroundediceLevelsetEnum) <= 0.) shelf=true; 1007 1155 else shelf=false; 1008 1156 } 1009 else if(migration_style==NoneEnum || migration_style==AggressiveMigrationEnum || migration_style==SoftMigrationEnum){ //Floating if all nodes are floating 1157 else if(migration_style==ContactEnum){ 1158 if(this->inputs->Max(MaskGroundediceLevelsetEnum) > 0.) shelf=false; 1159 else shelf=true; 1160 } 1161 else if(migration_style==NoneEnum || migration_style==AggressiveMigrationEnum || migration_style==SoftMigrationEnum || migration_style==GroundingOnlyEnum){ //Floating if all nodes are floating 1010 1162 if(this->inputs->Min(MaskGroundediceLevelsetEnum) > 0.) shelf=false; 1011 1163 else shelf=true; … … 1026 1178 name==BedEnum || 1027 1179 name==BalancethicknessThickeningRateEnum || 1028 name==Balancethickness ApparentMassbalanceEnum ||1180 name==BalancethicknessOmegaEnum || 1029 1181 name==SigmaNNEnum || 1030 1182 name==SurfaceSlopeXEnum || … … 1053 1205 name==WatercolumnEnum || 1054 1206 name==FrictionCoefficientEnum || 1207 name==FrictionAsEnum || 1055 1208 name==MaskGroundediceLevelsetEnum || 1056 1209 name==MaskIceLevelsetEnum || … … 1059 1212 name==LevelsetfunctionSlopeYEnum || 1060 1213 name==LevelsetfunctionPicardEnum || 1061 name==MasstransportCalvingrateEnum ||1214 //name==CalvingCalvingrateEnum || 1062 1215 name==GradientEnum || 1063 1216 name==OldGradientEnum || … … 1072 1225 name==SedimentHeadOldEnum || 1073 1226 name==EplHeadOldEnum || 1227 name==StressIntensityFactorEnum || 1228 name==StrainRateparallelEnum || 1229 name==StrainRateperpendicularEnum || 1074 1230 name==HydrologydcEplThicknessOldEnum || 1075 1231 name==HydrologydcEplInitialThicknessEnum || … … 1103 1259 1104 1260 this->AddInput(BasalforcingsFloatingiceMeltingRateEnum,values,P1Enum); 1105 1106 }/*}}}*/ 1261 xDelete<IssmDouble>(base); 1262 xDelete<IssmDouble>(values); 1263 1264 }/*}}}*/ 1265 void Element::MigrateGroundingLine(IssmDouble* phi_ungrounding){/*{{{*/ 1266 1267 int numvertices = this->GetNumberOfVertices(); 1268 int i,migration_style; 1269 IssmDouble bed_hydro,yts; 1270 IssmDouble rho_water,rho_ice,density; 1271 IssmDouble* melting = xNew<IssmDouble>(numvertices); 1272 IssmDouble* phi = xNew<IssmDouble>(numvertices); 1273 IssmDouble* h = xNew<IssmDouble>(numvertices); 1274 IssmDouble* s = xNew<IssmDouble>(numvertices); 1275 IssmDouble* b = xNew<IssmDouble>(numvertices); 1276 IssmDouble* r = xNew<IssmDouble>(numvertices); 1277 1278 /*Recover info at the vertices: */ 1279 parameters->FindParam(&migration_style,GroundinglineMigrationEnum); 1280 parameters->FindParam(&yts,ConstantsYtsEnum); 1281 GetInputListOnVertices(&h[0],ThicknessEnum); 1282 GetInputListOnVertices(&s[0],SurfaceEnum); 1283 GetInputListOnVertices(&b[0],BaseEnum); 1284 GetInputListOnVertices(&r[0],BedEnum); 1285 GetInputListOnVertices(&phi[0],MaskGroundediceLevelsetEnum); 1286 rho_water = matpar->GetMaterialParameter(MaterialsRhoSeawaterEnum); 1287 rho_ice = matpar->GetMaterialParameter(MaterialsRhoIceEnum); 1288 density = rho_ice/rho_water; 1289 1290 /*go through vertices, and update inputs, considering them to be TriaVertex type: */ 1291 for(i=0;i<numvertices;i++){ 1292 /* Contact FS*/ 1293 if(migration_style == ContactEnum && phi_ungrounding[vertices[i]->Pid()]<10){ 1294 phi[i]=phi_ungrounding[vertices[i]->Pid()]; 1295 if(phi[i]>=0.) b[i]=r[i]; 1296 } 1297 else if(migration_style == GroundingOnlyEnum && b[i]<r[i]) b[i]=r[i]; 1298 /*Ice shelf: if bed below bathymetry, impose it at the bathymetry and update surface, elso do nothing */ 1299 else if(phi[i]<=0.){ 1300 if(b[i]<=r[i]){ 1301 b[i] = r[i]; 1302 s[i] = b[i]+h[i]; 1303 } 1304 } 1305 /*Ice sheet: if hydrostatic bed above bathymetry, ice sheet starts to unground, elso do nothing */ 1306 /*Change only if AggressiveMigration or if the ice sheet is in contact with the ocean*/ 1307 else{ // phi>0 1308 bed_hydro=-density*h[i]; 1309 if (bed_hydro>r[i]){ 1310 /*Unground only if the element is connected to the ice shelf*/ 1311 if(migration_style==AggressiveMigrationEnum || migration_style==SubelementMigrationEnum || migration_style==SubelementMigration2Enum){ 1312 s[i] = (1-density)*h[i]; 1313 b[i] = -density*h[i]; 1314 } 1315 else if(migration_style==SoftMigrationEnum && phi_ungrounding[vertices[i]->Pid()]<0.){ 1316 s[i] = (1-density)*h[i]; 1317 b[i] = -density*h[i]; 1318 } 1319 else{ 1320 if(migration_style!=SoftMigrationEnum && migration_style!=ContactEnum && migration_style!=GroundingOnlyEnum) _error_("Error: migration should be Aggressive, Soft, Subelement, Contact or GroundingOnly"); 1321 } 1322 } 1323 } 1324 } 1325 1326 /*Recalculate phi*/ 1327 for(i=0;i<numvertices;i++){ 1328 if(migration_style==SoftMigrationEnum){ 1329 bed_hydro=-density*h[i]; 1330 if(phi[i]<0. || bed_hydro<=r[i] || phi_ungrounding[vertices[i]->Pid()]<0.){ 1331 phi[i]=h[i]+r[i]/density; 1332 } 1333 } 1334 else if(migration_style!=ContactEnum) phi[i]=h[i]+r[i]/density; 1335 else{ 1336 /*do nothing*/ 1337 } 1338 } 1339 this->AddInput(MaskGroundediceLevelsetEnum,&phi[0],P1Enum); 1340 1341 /*Update inputs*/ 1342 this->AddInput(SurfaceEnum,&s[0],P1Enum); 1343 this->AddInput(BaseEnum,&b[0],P1Enum); 1344 1345 /*Delete*/ 1346 xDelete<IssmDouble>(melting); 1347 xDelete<IssmDouble>(phi); 1348 xDelete<IssmDouble>(r); 1349 xDelete<IssmDouble>(b); 1350 xDelete<IssmDouble>(s); 1351 xDelete<IssmDouble>(h); 1352 1353 } 1354 /*}}}*/ 1355 ElementMatrix* Element::NewElementMatrix(int approximation_enum){/*{{{*/ 1356 return new ElementMatrix(nodes,this->GetNumberOfNodes(),this->parameters,approximation_enum); 1357 } 1358 /*}}}*/ 1359 ElementMatrix* Element::NewElementMatrixCoupling(int number_nodes,int approximation_enum){/*{{{*/ 1360 return new ElementMatrix(nodes,number_nodes,this->parameters,approximation_enum); 1361 } 1362 /*}}}*/ 1107 1363 ElementVector* Element::NewElementVector(int approximation_enum){/*{{{*/ 1108 1364 return new ElementVector(nodes,this->GetNumberOfNodes(),this->parameters,approximation_enum); 1109 }1110 /*}}}*/1111 ElementMatrix* Element::NewElementMatrix(int approximation_enum){/*{{{*/1112 return new ElementMatrix(nodes,this->GetNumberOfNodes(),this->parameters,approximation_enum);1113 }1114 /*}}}*/1115 ElementMatrix* Element::NewElementMatrixCoupling(int number_nodes,int approximation_enum){/*{{{*/1116 return new ElementMatrix(nodes,number_nodes,this->parameters,approximation_enum);1117 1365 } 1118 1366 /*}}}*/ … … 1129 1377 case ViscousHeatingEnum: 1130 1378 this->ViscousHeatingCreateInput(); 1379 input=this->inputs->GetInput(output_enum); 1380 break; 1381 case StressMaxPrincipalEnum: 1382 this->StressMaxPrincipalCreateInput(); 1131 1383 input=this->inputs->GetInput(output_enum); 1132 1384 break; … … 1146 1398 case StrainRateyzEnum: 1147 1399 case StrainRatezzEnum: 1400 case StrainRateeffectiveEnum: 1148 1401 this->ComputeStrainRate(); 1149 1402 input=this->inputs->GetInput(output_enum); … … 1166 1419 input=this->inputs->GetInput(output_enum); 1167 1420 break; 1421 case StressIntensityFactorEnum: 1422 this->StressIntensityFactor(); 1423 input=this->inputs->GetInput(output_enum); 1424 break; 1425 case CalvingratexEnum: 1426 case CalvingrateyEnum: 1427 case CalvingCalvingrateEnum: 1428 this->StrainRateparallel(); 1429 this->StrainRateperpendicular(); 1430 int calvinglaw; 1431 this->FindParam(&calvinglaw,CalvingLawEnum); 1432 switch(calvinglaw){ 1433 case DefaultCalvingEnum: 1434 //do nothing 1435 break; 1436 case CalvingLevermannEnum: 1437 this->CalvingRateLevermann(); 1438 break; 1439 case CalvingPiEnum: 1440 this->CalvingRatePi(); 1441 break; 1442 default: 1443 _error_("Calving law "<<EnumToStringx(calvinglaw)<<" not supported yet"); 1444 } 1445 input=this->inputs->GetInput(output_enum); 1446 break; 1447 case StrainRateparallelEnum: 1448 this->StrainRateparallel(); 1449 input=this->inputs->GetInput(output_enum); 1450 break; 1451 case StrainRateperpendicularEnum: 1452 this->StrainRateperpendicular(); 1453 input=this->inputs->GetInput(output_enum); 1454 break; 1168 1455 default: 1169 1456 _error_("input "<<EnumToStringx(output_enum)<<" not found in element"); … … 1172 1459 1173 1460 /*Assign output pointer*/ 1461 _assert_(input); 1174 1462 *pinterpolation = input->GetResultInterpolation(); 1175 1463 *pnodesperelement = input->GetResultNumberOfNodes(); 1176 1464 }/*}}}*/ 1465 void Element::ResultToPatch(IssmDouble* values,int nodesperelement,int output_enum){/*{{{*/ 1466 1467 Input* input=this->inputs->GetInput(output_enum); 1468 if(!input) _error_("input "<<EnumToStringx(output_enum)<<" not found in element"); 1469 1470 input->ResultToPatch(values,nodesperelement,this->Sid()); 1471 1472 } /*}}}*/ 1177 1473 void Element::ResultToVector(Vector<IssmDouble>* vector,int output_enum){/*{{{*/ 1178 1474 … … 1222 1518 _error_("interpolation "<<EnumToStringx(input->GetResultInterpolation())<<" not supported yet"); 1223 1519 } 1224 } /*}}}*/1225 void Element::ResultToPatch(IssmDouble* values,int nodesperelement,int output_enum){/*{{{*/1226 1227 Input* input=this->inputs->GetInput(output_enum);1228 if(!input) _error_("input "<<EnumToStringx(output_enum)<<" not found in element");1229 1230 input->ResultToPatch(values,nodesperelement,this->Sid());1231 1232 1520 } /*}}}*/ 1233 1521 void Element::SetwiseNodeConnectivity(int* pd_nz,int* po_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum){/*{{{*/ … … 1307 1595 } 1308 1596 /*}}}*/ 1309 IssmDouble Element::TMeltingPoint(IssmDouble pressure){/*{{{*/1310 _assert_(matpar);1311 return this->matpar->TMeltingPoint(pressure);1312 }/*}}}*/ 1313 void Element::ViscousHeatingCreateInput(void){/*{{{*/1597 void Element::StrainRateFS(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vz_input){/*{{{*/ 1598 /*Compute the 3d Strain Rate (6 components): 1599 * 1600 * epsilon=[exx eyy ezz exy exz eyz] 1601 */ 1314 1602 1315 1603 /*Intermediaries*/ 1316 IssmDouble phi; 1317 IssmDouble viscosity; 1318 IssmDouble epsilon[6]; 1319 IssmDouble thickness; 1604 IssmDouble dvx[3]; 1605 IssmDouble dvy[3]; 1606 IssmDouble dvz[3]; 1607 1608 /*Check that both inputs have been found*/ 1609 if (!vx_input || !vy_input || !vz_input){ 1610 _error_("Input missing. Here are the input pointers we have for vx: " << vx_input << ", vy: " << vy_input << ", vz: " << vz_input << "\n"); 1611 } 1612 1613 /*Get strain rate assuming that epsilon has been allocated*/ 1614 vx_input->GetInputDerivativeValue(&dvx[0],xyz_list,gauss); 1615 vy_input->GetInputDerivativeValue(&dvy[0],xyz_list,gauss); 1616 vz_input->GetInputDerivativeValue(&dvz[0],xyz_list,gauss); 1617 epsilon[0] = dvx[0]; 1618 epsilon[1] = dvy[1]; 1619 epsilon[2] = dvz[2]; 1620 epsilon[3] = 0.5*(dvx[1] + dvy[0]); 1621 epsilon[4] = 0.5*(dvx[2] + dvz[0]); 1622 epsilon[5] = 0.5*(dvy[2] + dvz[1]); 1623 1624 }/*}}}*/ 1625 void Element::StrainRateHO(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input){/*{{{*/ 1626 /*Compute the 3d Blatter/HOStrain Rate (5 components): 1627 * 1628 * epsilon=[exx eyy exy exz eyz] 1629 * 1630 * with exz=1/2 du/dz 1631 * eyz=1/2 dv/dz 1632 * 1633 * the contribution of vz is neglected 1634 */ 1635 1636 /*Intermediaries*/ 1637 IssmDouble dvx[3]; 1638 IssmDouble dvy[3]; 1639 1640 /*Check that both inputs have been found*/ 1641 if (!vx_input || !vy_input){ 1642 _error_("Input missing. Here are the input pointers we have for vx: " << vx_input << ", vy: " << vy_input << "\n"); 1643 } 1644 1645 /*Get strain rate assuming that epsilon has been allocated*/ 1646 vx_input->GetInputDerivativeValue(&dvx[0],xyz_list,gauss); 1647 vy_input->GetInputDerivativeValue(&dvy[0],xyz_list,gauss); 1648 epsilon[0] = dvx[0]; 1649 epsilon[1] = dvy[1]; 1650 epsilon[2] = 0.5*(dvx[1] + dvy[0]); 1651 epsilon[3] = 0.5*dvx[2]; 1652 epsilon[4] = 0.5*dvy[2]; 1653 1654 }/*}}}*/ 1655 void Element::StrainRateHO2dvertical(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input){/*{{{*/ 1656 /*Compute the 2d Blatter/HOStrain Rate (2 components): 1657 * 1658 * epsilon=[exx exz] 1659 * 1660 * with exz=1/2 du/dz 1661 * 1662 * the contribution of vz is neglected 1663 */ 1664 1665 /*Intermediaries*/ 1666 IssmDouble dvx[3]; 1667 1668 /*Check that both inputs have been found*/ 1669 if (!vx_input){ 1670 _error_("Input missing. Here are the input pointers we have for vx: " << vx_input <<"\n"); 1671 } 1672 1673 /*Get strain rate assuming that epsilon has been allocated*/ 1674 vx_input->GetInputDerivativeValue(&dvx[0],xyz_list,gauss); 1675 epsilon[0] = dvx[0]; 1676 epsilon[1] = 0.5*dvx[1]; 1677 1678 }/*}}}*/ 1679 void Element::StrainRateSSA(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input){/*{{{*/ 1680 1681 /*Intermediaries*/ 1682 IssmDouble dvx[3]; 1683 IssmDouble dvy[3]; 1684 1685 /*Check that both inputs have been found*/ 1686 if(!vx_input || !vy_input){ 1687 _error_("Input missing. Here are the input pointers we have for vx: " << vx_input << ", vy: " << vy_input << "\n"); 1688 } 1689 1690 /*Get strain rate assuming that epsilon has been allocated*/ 1691 vx_input->GetInputDerivativeValue(&dvx[0],xyz_list,gauss); 1692 vy_input->GetInputDerivativeValue(&dvy[0],xyz_list,gauss); 1693 epsilon[0] = dvx[0]; 1694 epsilon[1] = dvy[1]; 1695 epsilon[2] = 0.5*(dvx[1] + dvy[0]); 1696 1697 }/*}}}*/ 1698 void Element::StrainRateSSA1d(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input){/*{{{*/ 1699 1700 /*Intermediaries*/ 1701 IssmDouble dvx[3]; 1702 1703 /*Check that both inputs have been found*/ 1704 if (!vx_input){ 1705 _error_("Input missing. Here are the input pointers we have for vx: " << vx_input << "\n"); 1706 } 1707 1708 /*Get strain rate assuming that epsilon has been allocated*/ 1709 vx_input->GetInputDerivativeValue(&dvx[0],xyz_list,gauss); 1710 *epsilon = dvx[0]; 1711 1712 }/*}}}*/ 1713 void Element::StressMaxPrincipalCreateInput(void){/*{{{*/ 1714 1715 /*Intermediaries*/ 1320 1716 IssmDouble *xyz_list = NULL; 1717 IssmDouble sigma_xx,sigma_yy,sigma_zz,sigma_xy,sigma_xz,sigma_yz; 1718 IssmDouble a,b,c,d,x[3],max; 1719 int dim,numroots; 1720 1721 /*First: get stress tensor*/ 1722 this->ComputeStressTensor(); 1723 1724 /*Get domain dimension*/ 1725 this->FindParam(&dim,DomainDimensionEnum); 1321 1726 1322 1727 /*Fetch number vertices and allocate memory*/ 1323 int numvertices 1324 IssmDouble* viscousheating= xNew<IssmDouble>(numvertices);1728 int numvertices = this->GetNumberOfVertices(); 1729 IssmDouble* maxprincipal = xNew<IssmDouble>(numvertices); 1325 1730 1326 1731 /*Retrieve all inputs and parameters*/ 1327 1732 this->GetVerticesCoordinatesBase(&xyz_list); 1328 Input* vx_input = this->GetInput(VxEnum); _assert_(vx_input); 1329 Input* vy_input = this->GetInput(VyEnum); _assert_(vy_input); 1330 Input* vz_input = this->GetInput(VzEnum); _assert_(vz_input); 1331 Input* thickness_input = this->GetInput(ThicknessEnum); _assert_(thickness_input); 1733 Input* sigma_xx_input = this->GetInput(StressTensorxxEnum); _assert_(sigma_xx_input); 1734 Input* sigma_yy_input = this->GetInput(StressTensoryyEnum); _assert_(sigma_yy_input); 1735 Input* sigma_xy_input = this->GetInput(StressTensorxyEnum); _assert_(sigma_xy_input); 1736 Input* sigma_xz_input = NULL; 1737 Input* sigma_yz_input = NULL; 1738 Input* sigma_zz_input = NULL; 1739 if(dim==3){ 1740 sigma_xz_input = this->GetInput(StressTensorxzEnum); _assert_(sigma_xz_input); 1741 sigma_yz_input = this->GetInput(StressTensoryzEnum); _assert_(sigma_yz_input); 1742 sigma_zz_input = this->GetInput(StressTensorzzEnum); _assert_(sigma_zz_input); 1743 } 1332 1744 1333 1745 /*loop over vertices: */ … … 1336 1748 gauss->GaussVertex(iv); 1337 1749 1338 thickness_input->GetInputValue(&thickness,gauss); 1339 1340 this->StrainRateFS(&epsilon[0],xyz_list,gauss,vx_input,vy_input,vz_input); 1341 this->ViscosityFS(&viscosity,3,xyz_list,gauss,vx_input,vy_input,vz_input); 1342 this->GetPhi(&phi,&epsilon[0],viscosity); 1343 1344 viscousheating[iv]=phi*thickness; 1345 } 1346 1347 /*Create PentaVertex input, which will hold the basal friction:*/ 1348 this->AddInput(ViscousHeatingEnum,viscousheating,P1Enum); 1750 sigma_xx_input->GetInputValue(&sigma_xx,gauss); 1751 sigma_yy_input->GetInputValue(&sigma_yy,gauss); 1752 sigma_xy_input->GetInputValue(&sigma_xy,gauss); 1753 if(dim==3){ 1754 sigma_xz_input->GetInputValue(&sigma_xz,gauss); 1755 sigma_yz_input->GetInputValue(&sigma_yz,gauss); 1756 sigma_zz_input->GetInputValue(&sigma_zz,gauss); 1757 } 1758 1759 if(dim==2){ 1760 a = 0.; 1761 b = 1.; 1762 c = -sigma_yy -sigma_xx; 1763 d = sigma_xx*sigma_yy - sigma_xy*sigma_xy; 1764 } 1765 else{ 1766 a = -1.; 1767 b = sigma_xx+sigma_yy+sigma_zz; 1768 c = -sigma_xx*sigma_yy -sigma_xx*sigma_zz -sigma_yy*sigma_zz + sigma_xy*sigma_xy +sigma_xz*sigma_xz +sigma_yz*sigma_yz; 1769 d = sigma_xx*sigma_yy*sigma_zz - sigma_xx*sigma_yz*sigma_yz -sigma_yy*sigma_xz*sigma_xz - sigma_zz*sigma_xy*sigma_xy + 2.*sigma_xy*sigma_xz*sigma_yz; 1770 } 1771 1772 /*Get roots of polynomials*/ 1773 cubic(a,b,c,d,x,&numroots); 1774 1775 /*Initialize maximum eigne value*/ 1776 if(numroots>0){ 1777 max = fabs(x[0]); 1778 } 1779 else{ 1780 _error_("No eigen value found"); 1781 } 1782 1783 /*Get max*/ 1784 for(int i=1;i<numroots;i++){ 1785 if(fabs(x[i])>max) max = fabs(x[i]); 1786 } 1787 1788 maxprincipal[iv]=max; 1789 } 1790 1791 /*Create input*/ 1792 this->AddInput(StressMaxPrincipalEnum,maxprincipal,P1Enum); 1349 1793 1350 1794 /*Clean up and return*/ 1351 xDelete<IssmDouble>( viscousheating);1795 xDelete<IssmDouble>(maxprincipal); 1352 1796 delete gauss; 1353 1797 } 1354 1798 /*}}}*/ 1799 void Element::ThermalToEnthalpy(IssmDouble* penthalpy,IssmDouble temperature,IssmDouble waterfraction,IssmDouble pressure){/*{{{*/ 1800 matpar->ThermalToEnthalpy(penthalpy,temperature,waterfraction,pressure); 1801 }/*}}}*/ 1802 IssmDouble Element::TMeltingPoint(IssmDouble pressure){/*{{{*/ 1803 _assert_(matpar); 1804 return this->matpar->TMeltingPoint(pressure); 1805 }/*}}}*/ 1806 void Element::TransformInvStiffnessMatrixCoord(ElementMatrix* Ke,int transformenum){/*{{{*/ 1807 1808 /*All nodes have the same Coordinate System*/ 1809 int numnodes = this->GetNumberOfNodes(); 1810 int* cs_array = xNew<int>(numnodes); 1811 for(int i=0;i<numnodes;i++) cs_array[i]=transformenum; 1812 1813 /*Call core*/ 1814 TransformInvStiffnessMatrixCoord(Ke,this->nodes,numnodes,cs_array); 1815 1816 /*Clean-up*/ 1817 xDelete<int>(cs_array); 1818 }/*}}}*/ 1819 void Element::TransformInvStiffnessMatrixCoord(ElementMatrix* Ke,Node** nodes_list,int numnodes,int* cs_array){/*{{{*/ 1820 1821 int i,j; 1822 int numdofs = 0; 1823 IssmDouble *transform = NULL; 1824 IssmDouble *values = NULL; 1825 1826 /*Get total number of dofs*/ 1827 for(i=0;i<numnodes;i++){ 1828 switch(cs_array[i]){ 1829 case PressureEnum: numdofs+=1; break; 1830 case XYEnum: numdofs+=2; break; 1831 case XYZEnum: numdofs+=3; break; 1832 default: _error_("Coordinate system " << EnumToStringx(cs_array[i]) << " not supported yet"); 1833 } 1834 } 1835 1836 /*Copy current stiffness matrix*/ 1837 values=xNew<IssmDouble>(Ke->nrows*Ke->ncols); 1838 for(i=0;i<Ke->nrows;i++) for(j=0;j<Ke->ncols;j++) values[i*Ke->ncols+j]=Ke->values[i*Ke->ncols+j]; 1839 1840 /*Get Coordinate Systems transform matrix*/ 1841 CoordinateSystemTransform(&transform,nodes_list,numnodes,cs_array); 1842 1843 /*Transform matrix: R*Ke*R^T */ 1844 TripleMultiply(transform,numdofs,numdofs,0, 1845 values,Ke->nrows,Ke->ncols,0, 1846 transform,numdofs,numdofs,1, 1847 &Ke->values[0],0); 1848 1849 /*Free Matrix*/ 1850 xDelete<IssmDouble>(transform); 1851 xDelete<IssmDouble>(values); 1852 }/*}}}*/ 1853 void Element::TransformLoadVectorCoord(ElementVector* pe,int transformenum){/*{{{*/ 1854 1855 /*All nodes have the same Coordinate System*/ 1856 int numnodes = this->GetNumberOfNodes(); 1857 int* cs_array = xNew<int>(numnodes); 1858 for(int i=0;i<numnodes;i++) cs_array[i]=transformenum; 1859 1860 /*Call core*/ 1861 this->TransformLoadVectorCoord(pe,this->nodes,numnodes,cs_array); 1862 1863 /*Clean-up*/ 1864 xDelete<int>(cs_array); 1865 }/*}}}*/ 1866 void Element::TransformLoadVectorCoord(ElementVector* pe,int* cs_array){/*{{{*/ 1867 1868 this->TransformLoadVectorCoord(pe,this->nodes,this->GetNumberOfNodes(),cs_array); 1869 1870 }/*}}}*/ 1871 void Element::TransformLoadVectorCoord(ElementVector* pe,Node** nodes_list,int numnodes,int* cs_array){/*{{{*/ 1872 1873 int i; 1874 int numdofs = 0; 1875 IssmDouble *transform = NULL; 1876 IssmDouble *values = NULL; 1877 1878 /*Get total number of dofs*/ 1879 for(i=0;i<numnodes;i++){ 1880 switch(cs_array[i]){ 1881 case PressureEnum: numdofs+=1; break; 1882 case XYEnum: numdofs+=2; break; 1883 case XYZEnum: numdofs+=3; break; 1884 default: _error_("Coordinate system " << EnumToStringx(cs_array[i]) << " not supported yet"); 1885 } 1886 } 1887 1888 /*Copy current load vector*/ 1889 values=xNew<IssmDouble>(pe->nrows); 1890 for(i=0;i<pe->nrows;i++) values[i]=pe->values[i]; 1891 1892 /*Get Coordinate Systems transform matrix*/ 1893 CoordinateSystemTransform(&transform,nodes_list,numnodes,cs_array); 1894 1895 /*Transform matrix: R^T*pe */ 1896 MatrixMultiply(transform,numdofs,numdofs,1, 1897 values,pe->nrows,1,0, 1898 &pe->values[0],0); 1899 1900 /*Free Matrices*/ 1901 xDelete<IssmDouble>(transform); 1902 xDelete<IssmDouble>(values); 1903 }/*}}}*/ 1904 void Element::TransformSolutionCoord(IssmDouble* values,int transformenum){/*{{{*/ 1905 1906 /*All nodes have the same Coordinate System*/ 1907 int numnodes = this->GetNumberOfNodes(); 1908 int* cs_array = xNew<int>(numnodes); 1909 for(int i=0;i<numnodes;i++) cs_array[i]=transformenum; 1910 1911 /*Call core*/ 1912 this->TransformSolutionCoord(values,this->nodes,numnodes,cs_array); 1913 1914 /*Clean-up*/ 1915 xDelete<int>(cs_array); 1916 }/*}}}*/ 1917 void Element::TransformSolutionCoord(IssmDouble* values,int* transformenum_list){/*{{{*/ 1918 this->TransformSolutionCoord(values,this->nodes,this->GetNumberOfNodes(),transformenum_list); 1919 }/*}}}*/ 1920 void Element::TransformSolutionCoord(IssmDouble* values,int numnodes,int transformenum){/*{{{*/ 1921 1922 /*All nodes have the same Coordinate System*/ 1923 int* cs_array = xNew<int>(numnodes); 1924 for(int i=0;i<numnodes;i++) cs_array[i]=transformenum; 1925 1926 /*Call core*/ 1927 this->TransformSolutionCoord(values,this->nodes,numnodes,cs_array); 1928 1929 /*Clean-up*/ 1930 xDelete<int>(cs_array); 1931 }/*}}}*/ 1932 void Element::TransformSolutionCoord(IssmDouble* solution,int numnodes,int* cs_array){/*{{{*/ 1933 this->TransformSolutionCoord(solution,this->nodes,numnodes,cs_array); 1934 }/*}}}*/ 1935 void Element::TransformSolutionCoord(IssmDouble* values,Node** nodes_list,int numnodes,int transformenum){/*{{{*/ 1936 /*NOT NEEDED*/ 1937 /*All nodes have the same Coordinate System*/ 1938 int* cs_array = xNew<int>(numnodes); 1939 for(int i=0;i<numnodes;i++) cs_array[i]=transformenum; 1940 1941 /*Call core*/ 1942 this->TransformSolutionCoord(values,nodes_list,numnodes,cs_array); 1943 1944 /*Clean-up*/ 1945 xDelete<int>(cs_array); 1946 }/*}}}*/ 1947 void Element::TransformSolutionCoord(IssmDouble* solution,Node** nodes_list,int numnodes,int* cs_array){/*{{{*/ 1948 1949 int i; 1950 int numdofs = 0; 1951 IssmDouble *transform = NULL; 1952 IssmDouble *values = NULL; 1953 1954 /*Get total number of dofs*/ 1955 for(i=0;i<numnodes;i++){ 1956 switch(cs_array[i]){ 1957 case PressureEnum: numdofs+=1; break; 1958 case XYEnum: numdofs+=2; break; 1959 case XYZEnum: numdofs+=3; break; 1960 default: _error_("Coordinate system " << EnumToStringx(cs_array[i]) << " not supported yet"); 1961 } 1962 } 1963 1964 /*Copy current solution vector*/ 1965 values=xNew<IssmDouble>(numdofs); 1966 for(i=0;i<numdofs;i++) values[i]=solution[i]; 1967 1968 /*Get Coordinate Systems transform matrix*/ 1969 CoordinateSystemTransform(&transform,nodes_list,numnodes,cs_array); 1970 1971 /*Transform matrix: R*U */ 1972 MatrixMultiply(transform,numdofs,numdofs,0, 1973 values,numdofs,1,0, 1974 &solution[0],0); 1975 1976 /*Free Matrices*/ 1977 xDelete<IssmDouble>(transform); 1978 xDelete<IssmDouble>(values); 1979 }/*}}}*/ 1980 void Element::TransformStiffnessMatrixCoord(ElementMatrix* Ke,int transformenum){/*{{{*/ 1981 1982 /*All nodes have the same Coordinate System*/ 1983 int numnodes = this->GetNumberOfNodes(); 1984 int* cs_array = xNew<int>(numnodes); 1985 for(int i=0;i<numnodes;i++) cs_array[i]=transformenum; 1986 1987 /*Call core*/ 1988 this->TransformStiffnessMatrixCoord(Ke,this->nodes,numnodes,cs_array); 1989 1990 /*Clean-up*/ 1991 xDelete<int>(cs_array); 1992 }/*}}}*/ 1993 void Element::TransformStiffnessMatrixCoord(ElementMatrix* Ke,int* transformenum_list){/*{{{*/ 1994 this->TransformStiffnessMatrixCoord(Ke,this->nodes,this->GetNumberOfNodes(),transformenum_list); 1995 }/*}}}*/ 1996 void Element::TransformStiffnessMatrixCoord(ElementMatrix* Ke,Node** nodes_list,int numnodes,int* cs_array){/*{{{*/ 1997 1998 int numdofs = 0; 1999 IssmDouble *transform = NULL; 2000 IssmDouble *values = NULL; 2001 2002 /*Get total number of dofs*/ 2003 for(int i=0;i<numnodes;i++){ 2004 switch(cs_array[i]){ 2005 case PressureEnum: numdofs+=1; break; 2006 case XYEnum: numdofs+=2; break; 2007 case XYZEnum: numdofs+=3; break; 2008 default: _error_("Coordinate system " << EnumToStringx(cs_array[i]) << " not supported yet"); 2009 } 2010 } 2011 2012 /*Copy current stiffness matrix*/ 2013 values=xNew<IssmDouble>(Ke->nrows*Ke->ncols); 2014 for(int i=0;i<Ke->nrows*Ke->ncols;i++) values[i]=Ke->values[i]; 2015 2016 /*Get Coordinate Systems transform matrix*/ 2017 CoordinateSystemTransform(&transform,nodes_list,numnodes,cs_array); 2018 2019 /*Transform matrix: R^T*Ke*R */ 2020 TripleMultiply(transform,numdofs,numdofs,1, 2021 values,Ke->nrows,Ke->ncols,0, 2022 transform,numdofs,numdofs,0, 2023 &Ke->values[0],0); 2024 2025 /*Free Matrix*/ 2026 xDelete<IssmDouble>(transform); 2027 xDelete<IssmDouble>(values); 2028 }/*}}}*/ 1355 2029 void Element::ViscosityFS(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vz_input){/*{{{*/ 1356 2030 /*The effective strain rate is defined in Paterson 3d Ed p 91 eq 9, … … 1392 2066 } 1393 2067 /*}}}*/ 2068 void Element::ViscosityFSDerivativeEpsSquare(IssmDouble* pmu_prime,IssmDouble* epsilon){/*{{{*/ 2069 this->material->GetViscosityDerivativeEpsSquare(pmu_prime,epsilon); 2070 }/*}}}*/ 2071 void Element::ViscosityHO(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input){/*{{{*/ 2072 2073 /*Intermediaries*/ 2074 IssmDouble viscosity; 2075 IssmDouble epsilon3d[5];/* epsilon=[exx,eyy,exy,exz,eyz];*/ 2076 IssmDouble epsilon2d[2];/* epsilon=[exx,exy]; */ 2077 IssmDouble eps_eff; 2078 2079 if(dim==3){ 2080 /* eps_eff^2 = exx^2 + eyy^2 + exy^2 + exz^2 + eyz^2 + exx*eyy */ 2081 this->StrainRateHO(&epsilon3d[0],xyz_list,gauss,vx_input,vy_input); 2082 eps_eff = sqrt(epsilon3d[0]*epsilon3d[0] + epsilon3d[1]*epsilon3d[1] + epsilon3d[2]*epsilon3d[2] + epsilon3d[3]*epsilon3d[3] + epsilon3d[4]*epsilon3d[4] + epsilon3d[0]*epsilon3d[1]); 2083 } 2084 else{ 2085 /* eps_eff^2 = 1/2 (exx^2 + 2*exy^2 )*/ 2086 this->StrainRateHO2dvertical(&epsilon2d[0],xyz_list,gauss,vx_input,vy_input); 2087 eps_eff = 1./sqrt(2.)*sqrt(epsilon2d[0]*epsilon2d[0] + 2.*epsilon2d[1]*epsilon2d[1]); 2088 } 2089 2090 /*Get viscosity*/ 2091 material->GetViscosity(&viscosity,eps_eff); 2092 2093 /*Assign output pointer*/ 2094 *pviscosity=viscosity; 2095 }/*}}}*/ 2096 void Element::ViscosityHODerivativeEpsSquare(IssmDouble* pmu_prime,IssmDouble* epsilon){/*{{{*/ 2097 this->material->GetViscosityDerivativeEpsSquare(pmu_prime,epsilon); 2098 }/*}}}*/ 1394 2099 void Element::ViscosityL1L2(IssmDouble* pviscosity,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* surface_input){/*{{{*/ 1395 2100 /*Compute the L1L2 viscosity … … 1422 2127 surface_input->GetInputDerivativeValue(&slope[0],xyz_list,gauss); 1423 2128 z=this->GetZcoord(xyz_list,gauss); 1424 tau_perp = matpar->Get RhoIce() * matpar->GetG() * fabs(s-z)*sqrt(slope[0]*slope[0]+slope[1]*slope[1]);2129 tau_perp = matpar->GetMaterialParameter(MaterialsRhoIceEnum) * matpar->GetMaterialParameter(ConstantsGEnum) * fabs(s-z)*sqrt(slope[0]*slope[0]+slope[1]*slope[1]); 1425 2130 1426 2131 /* Get eps_b*/ … … 1450 2155 /*Assign output pointer*/ 1451 2156 *pviscosity = viscosity; 1452 }/*}}}*/1453 void Element::ViscosityHO(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input){/*{{{*/1454 1455 /*Intermediaries*/1456 IssmDouble viscosity;1457 IssmDouble epsilon3d[5];/* epsilon=[exx,eyy,exy,exz,eyz];*/1458 IssmDouble epsilon2d[2];/* epsilon=[exx,exy]; */1459 IssmDouble eps_eff;1460 1461 if(dim==3){1462 /* eps_eff^2 = exx^2 + eyy^2 + exy^2 + exz^2 + eyz^2 + exx*eyy */1463 this->StrainRateHO(&epsilon3d[0],xyz_list,gauss,vx_input,vy_input);1464 eps_eff = sqrt(epsilon3d[0]*epsilon3d[0] + epsilon3d[1]*epsilon3d[1] + epsilon3d[2]*epsilon3d[2] + epsilon3d[3]*epsilon3d[3] + epsilon3d[4]*epsilon3d[4] + epsilon3d[0]*epsilon3d[1]);1465 }1466 else{1467 /* eps_eff^2 = 1/2 (exx^2 + 2*exy^2 )*/1468 this->StrainRateHO2dvertical(&epsilon2d[0],xyz_list,gauss,vx_input,vy_input);1469 eps_eff = 1./sqrt(2.)*sqrt(epsilon2d[0]*epsilon2d[0] + 2.*epsilon2d[1]*epsilon2d[1]);1470 }1471 1472 /*Get viscosity*/1473 material->GetViscosity(&viscosity,eps_eff);1474 1475 /*Assign output pointer*/1476 *pviscosity=viscosity;1477 2157 }/*}}}*/ 1478 2158 void Element::ViscositySSA(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input){/*{{{*/ … … 1504 2184 this->material->GetViscosity2dDerivativeEpsSquare(pmu_prime,epsilon); 1505 2185 }/*}}}*/ 1506 void Element::ViscosityHODerivativeEpsSquare(IssmDouble* pmu_prime,IssmDouble* epsilon){/*{{{*/ 1507 this->material->GetViscosityDerivativeEpsSquare(pmu_prime,epsilon); 1508 }/*}}}*/ 1509 void Element::ViscosityFSDerivativeEpsSquare(IssmDouble* pmu_prime,IssmDouble* epsilon){/*{{{*/ 1510 this->material->GetViscosityDerivativeEpsSquare(pmu_prime,epsilon); 1511 }/*}}}*/ 1512 void Element::StrainRateFS(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vz_input){/*{{{*/ 1513 /*Compute the 3d Strain Rate (6 components): 1514 * 1515 * epsilon=[exx eyy ezz exy exz eyz] 1516 */ 2186 void Element::ViscousHeatingCreateInput(void){/*{{{*/ 1517 2187 1518 2188 /*Intermediaries*/ 1519 IssmDouble dvx[3]; 1520 IssmDouble dvy[3]; 1521 IssmDouble dvz[3]; 1522 1523 /*Check that both inputs have been found*/ 1524 if (!vx_input || !vy_input || !vz_input){ 1525 _error_("Input missing. Here are the input pointers we have for vx: " << vx_input << ", vy: " << vy_input << ", vz: " << vz_input << "\n"); 1526 } 1527 1528 /*Get strain rate assuming that epsilon has been allocated*/ 1529 vx_input->GetInputDerivativeValue(&dvx[0],xyz_list,gauss); 1530 vy_input->GetInputDerivativeValue(&dvy[0],xyz_list,gauss); 1531 vz_input->GetInputDerivativeValue(&dvz[0],xyz_list,gauss); 1532 epsilon[0] = dvx[0]; 1533 epsilon[1] = dvy[1]; 1534 epsilon[2] = dvz[2]; 1535 epsilon[3] = 0.5*(dvx[1] + dvy[0]); 1536 epsilon[4] = 0.5*(dvx[2] + dvz[0]); 1537 epsilon[5] = 0.5*(dvy[2] + dvz[1]); 1538 1539 }/*}}}*/ 1540 void Element::StrainRateHO(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input){/*{{{*/ 1541 /*Compute the 3d Blatter/HOStrain Rate (5 components): 1542 * 1543 * epsilon=[exx eyy exy exz eyz] 1544 * 1545 * with exz=1/2 du/dz 1546 * eyz=1/2 dv/dz 1547 * 1548 * the contribution of vz is neglected 1549 */ 1550 1551 /*Intermediaries*/ 1552 IssmDouble dvx[3]; 1553 IssmDouble dvy[3]; 1554 1555 /*Check that both inputs have been found*/ 1556 if (!vx_input || !vy_input){ 1557 _error_("Input missing. Here are the input pointers we have for vx: " << vx_input << ", vy: " << vy_input << "\n"); 1558 } 1559 1560 /*Get strain rate assuming that epsilon has been allocated*/ 1561 vx_input->GetInputDerivativeValue(&dvx[0],xyz_list,gauss); 1562 vy_input->GetInputDerivativeValue(&dvy[0],xyz_list,gauss); 1563 epsilon[0] = dvx[0]; 1564 epsilon[1] = dvy[1]; 1565 epsilon[2] = 0.5*(dvx[1] + dvy[0]); 1566 epsilon[3] = 0.5*dvx[2]; 1567 epsilon[4] = 0.5*dvy[2]; 1568 1569 }/*}}}*/ 1570 void Element::StrainRateHO2dvertical(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input){/*{{{*/ 1571 /*Compute the 2d Blatter/HOStrain Rate (2 components): 1572 * 1573 * epsilon=[exx exz] 1574 * 1575 * with exz=1/2 du/dz 1576 * 1577 * the contribution of vz is neglected 1578 */ 1579 1580 /*Intermediaries*/ 1581 IssmDouble dvx[3]; 1582 1583 /*Check that both inputs have been found*/ 1584 if (!vx_input){ 1585 _error_("Input missing. Here are the input pointers we have for vx: " << vx_input <<"\n"); 1586 } 1587 1588 /*Get strain rate assuming that epsilon has been allocated*/ 1589 vx_input->GetInputDerivativeValue(&dvx[0],xyz_list,gauss); 1590 epsilon[0] = dvx[0]; 1591 epsilon[1] = 0.5*dvx[1]; 1592 1593 }/*}}}*/ 1594 void Element::StrainRateSSA(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input){/*{{{*/ 1595 1596 /*Intermediaries*/ 1597 IssmDouble dvx[3]; 1598 IssmDouble dvy[3]; 1599 1600 /*Check that both inputs have been found*/ 1601 if(!vx_input || !vy_input){ 1602 _error_("Input missing. Here are the input pointers we have for vx: " << vx_input << ", vy: " << vy_input << "\n"); 1603 } 1604 1605 /*Get strain rate assuming that epsilon has been allocated*/ 1606 vx_input->GetInputDerivativeValue(&dvx[0],xyz_list,gauss); 1607 vy_input->GetInputDerivativeValue(&dvy[0],xyz_list,gauss); 1608 epsilon[0] = dvx[0]; 1609 epsilon[1] = dvy[1]; 1610 epsilon[2] = 0.5*(dvx[1] + dvy[0]); 1611 1612 }/*}}}*/ 1613 void Element::StrainRateSSA1d(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input){/*{{{*/ 1614 1615 /*Intermediaries*/ 1616 IssmDouble dvx[3]; 1617 1618 /*Check that both inputs have been found*/ 1619 if (!vx_input){ 1620 _error_("Input missing. Here are the input pointers we have for vx: " << vx_input << "\n"); 1621 } 1622 1623 /*Get strain rate assuming that epsilon has been allocated*/ 1624 vx_input->GetInputDerivativeValue(&dvx[0],xyz_list,gauss); 1625 *epsilon = dvx[0]; 1626 1627 }/*}}}*/ 1628 void Element::TransformInvStiffnessMatrixCoord(ElementMatrix* Ke,int transformenum){/*{{{*/ 1629 1630 /*All nodes have the same Coordinate System*/ 1631 int numnodes = this->GetNumberOfNodes(); 1632 int* cs_array = xNew<int>(numnodes); 1633 for(int i=0;i<numnodes;i++) cs_array[i]=transformenum; 1634 1635 /*Call core*/ 1636 TransformInvStiffnessMatrixCoord(Ke,this->nodes,numnodes,cs_array); 1637 1638 /*Clean-up*/ 1639 xDelete<int>(cs_array); 1640 }/*}}}*/ 1641 void Element::TransformInvStiffnessMatrixCoord(ElementMatrix* Ke,Node** nodes_list,int numnodes,int* cs_array){/*{{{*/ 1642 1643 int i,j; 1644 int numdofs = 0; 1645 IssmDouble *transform = NULL; 1646 IssmDouble *values = NULL; 1647 1648 /*Get total number of dofs*/ 1649 for(i=0;i<numnodes;i++){ 1650 switch(cs_array[i]){ 1651 case PressureEnum: numdofs+=1; break; 1652 case XYEnum: numdofs+=2; break; 1653 case XYZEnum: numdofs+=3; break; 1654 default: _error_("Coordinate system " << EnumToStringx(cs_array[i]) << " not supported yet"); 1655 } 1656 } 1657 1658 /*Copy current stiffness matrix*/ 1659 values=xNew<IssmDouble>(Ke->nrows*Ke->ncols); 1660 for(i=0;i<Ke->nrows;i++) for(j=0;j<Ke->ncols;j++) values[i*Ke->ncols+j]=Ke->values[i*Ke->ncols+j]; 1661 1662 /*Get Coordinate Systems transform matrix*/ 1663 CoordinateSystemTransform(&transform,nodes_list,numnodes,cs_array); 1664 1665 /*Transform matrix: R*Ke*R^T */ 1666 TripleMultiply(transform,numdofs,numdofs,0, 1667 values,Ke->nrows,Ke->ncols,0, 1668 transform,numdofs,numdofs,1, 1669 &Ke->values[0],0); 1670 1671 /*Free Matrix*/ 1672 xDelete<IssmDouble>(transform); 1673 xDelete<IssmDouble>(values); 1674 }/*}}}*/ 1675 void Element::TransformLoadVectorCoord(ElementVector* pe,int transformenum){/*{{{*/ 1676 1677 /*All nodes have the same Coordinate System*/ 1678 int numnodes = this->GetNumberOfNodes(); 1679 int* cs_array = xNew<int>(numnodes); 1680 for(int i=0;i<numnodes;i++) cs_array[i]=transformenum; 1681 1682 /*Call core*/ 1683 this->TransformLoadVectorCoord(pe,this->nodes,numnodes,cs_array); 1684 1685 /*Clean-up*/ 1686 xDelete<int>(cs_array); 1687 }/*}}}*/ 1688 void Element::TransformLoadVectorCoord(ElementVector* pe,int* cs_array){/*{{{*/ 1689 1690 this->TransformLoadVectorCoord(pe,this->nodes,this->GetNumberOfNodes(),cs_array); 1691 1692 }/*}}}*/ 1693 void Element::TransformLoadVectorCoord(ElementVector* pe,Node** nodes_list,int numnodes,int* cs_array){/*{{{*/ 1694 1695 int i; 1696 int numdofs = 0; 1697 IssmDouble *transform = NULL; 1698 IssmDouble *values = NULL; 1699 1700 /*Get total number of dofs*/ 1701 for(i=0;i<numnodes;i++){ 1702 switch(cs_array[i]){ 1703 case PressureEnum: numdofs+=1; break; 1704 case XYEnum: numdofs+=2; break; 1705 case XYZEnum: numdofs+=3; break; 1706 default: _error_("Coordinate system " << EnumToStringx(cs_array[i]) << " not supported yet"); 1707 } 1708 } 1709 1710 /*Copy current load vector*/ 1711 values=xNew<IssmDouble>(pe->nrows); 1712 for(i=0;i<pe->nrows;i++) values[i]=pe->values[i]; 1713 1714 /*Get Coordinate Systems transform matrix*/ 1715 CoordinateSystemTransform(&transform,nodes_list,numnodes,cs_array); 1716 1717 /*Transform matrix: R^T*pe */ 1718 MatrixMultiply(transform,numdofs,numdofs,1, 1719 values,pe->nrows,1,0, 1720 &pe->values[0],0); 1721 1722 /*Free Matrices*/ 1723 xDelete<IssmDouble>(transform); 1724 xDelete<IssmDouble>(values); 1725 }/*}}}*/ 1726 void Element::TransformSolutionCoord(IssmDouble* values,int transformenum){/*{{{*/ 1727 1728 /*All nodes have the same Coordinate System*/ 1729 int numnodes = this->GetNumberOfNodes(); 1730 int* cs_array = xNew<int>(numnodes); 1731 for(int i=0;i<numnodes;i++) cs_array[i]=transformenum; 1732 1733 /*Call core*/ 1734 this->TransformSolutionCoord(values,this->nodes,numnodes,cs_array); 1735 1736 /*Clean-up*/ 1737 xDelete<int>(cs_array); 1738 }/*}}}*/ 1739 void Element::TransformSolutionCoord(IssmDouble* values,int* transformenum_list){/*{{{*/ 1740 this->TransformSolutionCoord(values,this->nodes,this->GetNumberOfNodes(),transformenum_list); 1741 }/*}}}*/ 1742 void Element::TransformSolutionCoord(IssmDouble* values,int numnodes,int transformenum){/*{{{*/ 1743 1744 /*All nodes have the same Coordinate System*/ 1745 int* cs_array = xNew<int>(numnodes); 1746 for(int i=0;i<numnodes;i++) cs_array[i]=transformenum; 1747 1748 /*Call core*/ 1749 this->TransformSolutionCoord(values,this->nodes,numnodes,cs_array); 1750 1751 /*Clean-up*/ 1752 xDelete<int>(cs_array); 1753 }/*}}}*/ 1754 void Element::TransformSolutionCoord(IssmDouble* solution,int numnodes,int* cs_array){/*{{{*/ 1755 this->TransformSolutionCoord(solution,this->nodes,numnodes,cs_array); 1756 }/*}}}*/ 1757 void Element::TransformSolutionCoord(IssmDouble* values,Node** nodes_list,int numnodes,int transformenum){/*{{{*/ 1758 /*NOT NEEDED*/ 1759 /*All nodes have the same Coordinate System*/ 1760 int* cs_array = xNew<int>(numnodes); 1761 for(int i=0;i<numnodes;i++) cs_array[i]=transformenum; 1762 1763 /*Call core*/ 1764 this->TransformSolutionCoord(values,nodes_list,numnodes,cs_array); 1765 1766 /*Clean-up*/ 1767 xDelete<int>(cs_array); 1768 }/*}}}*/ 1769 void Element::TransformSolutionCoord(IssmDouble* solution,Node** nodes_list,int numnodes,int* cs_array){/*{{{*/ 1770 1771 int i; 1772 int numdofs = 0; 1773 IssmDouble *transform = NULL; 1774 IssmDouble *values = NULL; 1775 1776 /*Get total number of dofs*/ 1777 for(i=0;i<numnodes;i++){ 1778 switch(cs_array[i]){ 1779 case PressureEnum: numdofs+=1; break; 1780 case XYEnum: numdofs+=2; break; 1781 case XYZEnum: numdofs+=3; break; 1782 default: _error_("Coordinate system " << EnumToStringx(cs_array[i]) << " not supported yet"); 1783 } 1784 } 1785 1786 /*Copy current solution vector*/ 1787 values=xNew<IssmDouble>(numdofs); 1788 for(i=0;i<numdofs;i++) values[i]=solution[i]; 1789 1790 /*Get Coordinate Systems transform matrix*/ 1791 CoordinateSystemTransform(&transform,nodes_list,numnodes,cs_array); 1792 1793 /*Transform matrix: R*U */ 1794 MatrixMultiply(transform,numdofs,numdofs,0, 1795 values,numdofs,1,0, 1796 &solution[0],0); 1797 1798 /*Free Matrices*/ 1799 xDelete<IssmDouble>(transform); 1800 xDelete<IssmDouble>(values); 1801 }/*}}}*/ 1802 void Element::TransformStiffnessMatrixCoord(ElementMatrix* Ke,int transformenum){/*{{{*/ 1803 1804 /*All nodes have the same Coordinate System*/ 1805 int numnodes = this->GetNumberOfNodes(); 1806 int* cs_array = xNew<int>(numnodes); 1807 for(int i=0;i<numnodes;i++) cs_array[i]=transformenum; 1808 1809 /*Call core*/ 1810 this->TransformStiffnessMatrixCoord(Ke,this->nodes,numnodes,cs_array); 1811 1812 /*Clean-up*/ 1813 xDelete<int>(cs_array); 1814 }/*}}}*/ 1815 void Element::TransformStiffnessMatrixCoord(ElementMatrix* Ke,int* transformenum_list){/*{{{*/ 1816 this->TransformStiffnessMatrixCoord(Ke,this->nodes,this->GetNumberOfNodes(),transformenum_list); 1817 }/*}}}*/ 1818 void Element::TransformStiffnessMatrixCoord(ElementMatrix* Ke,Node** nodes_list,int numnodes,int* cs_array){/*{{{*/ 1819 1820 int numdofs = 0; 1821 IssmDouble *transform = NULL; 1822 IssmDouble *values = NULL; 1823 1824 /*Get total number of dofs*/ 1825 for(int i=0;i<numnodes;i++){ 1826 switch(cs_array[i]){ 1827 case PressureEnum: numdofs+=1; break; 1828 case XYEnum: numdofs+=2; break; 1829 case XYZEnum: numdofs+=3; break; 1830 default: _error_("Coordinate system " << EnumToStringx(cs_array[i]) << " not supported yet"); 1831 } 1832 } 1833 1834 /*Copy current stiffness matrix*/ 1835 values=xNew<IssmDouble>(Ke->nrows*Ke->ncols); 1836 for(int i=0;i<Ke->nrows*Ke->ncols;i++) values[i]=Ke->values[i]; 1837 1838 /*Get Coordinate Systems transform matrix*/ 1839 CoordinateSystemTransform(&transform,nodes_list,numnodes,cs_array); 1840 1841 /*Transform matrix: R^T*Ke*R */ 1842 TripleMultiply(transform,numdofs,numdofs,1, 1843 values,Ke->nrows,Ke->ncols,0, 1844 transform,numdofs,numdofs,0, 1845 &Ke->values[0],0); 1846 1847 /*Free Matrix*/ 1848 xDelete<IssmDouble>(transform); 1849 xDelete<IssmDouble>(values); 1850 }/*}}}*/ 2189 IssmDouble phi; 2190 IssmDouble viscosity; 2191 IssmDouble epsilon[6]; 2192 IssmDouble thickness; 2193 IssmDouble *xyz_list = NULL; 2194 2195 /*Fetch number vertices and allocate memory*/ 2196 int numvertices = this->GetNumberOfVertices(); 2197 IssmDouble* viscousheating = xNew<IssmDouble>(numvertices); 2198 2199 /*Retrieve all inputs and parameters*/ 2200 this->GetVerticesCoordinatesBase(&xyz_list); 2201 Input* vx_input = this->GetInput(VxEnum); _assert_(vx_input); 2202 Input* vy_input = this->GetInput(VyEnum); _assert_(vy_input); 2203 Input* vz_input = this->GetInput(VzEnum); _assert_(vz_input); 2204 Input* thickness_input = this->GetInput(ThicknessEnum); _assert_(thickness_input); 2205 2206 /*loop over vertices: */ 2207 Gauss* gauss=this->NewGauss(); 2208 for (int iv=0;iv<numvertices;iv++){ 2209 gauss->GaussVertex(iv); 2210 2211 thickness_input->GetInputValue(&thickness,gauss); 2212 2213 this->StrainRateFS(&epsilon[0],xyz_list,gauss,vx_input,vy_input,vz_input); 2214 this->ViscosityFS(&viscosity,3,xyz_list,gauss,vx_input,vy_input,vz_input); 2215 this->GetPhi(&phi,&epsilon[0],viscosity); 2216 2217 viscousheating[iv]=phi*thickness; 2218 } 2219 2220 /*Create PentaVertex input, which will hold the basal friction:*/ 2221 this->AddInput(ViscousHeatingEnum,viscousheating,P1Enum); 2222 2223 /*Clean up and return*/ 2224 xDelete<IssmDouble>(viscousheating); 2225 delete gauss; 2226 } 2227 /*}}}*/ -
issm/trunk/src/c/classes/Elements/Element.h
r18301 r19105 56 56 57 57 /*Functions*/ 58 void AddInput(Input* input_in); 59 /* bool AllActive(void); */ 60 /* bool AnyActive(void); */ 61 void ComputeNewDamage(); 62 void ComputeStrainRate(); 63 void CoordinateSystemTransform(IssmDouble** ptransform,Node** nodes,int numnodes,int* cs_array); 64 void Echo(); 65 void DeepEcho(); 66 void DeleteMaterials(void); 67 void dViscositydBSSA(IssmDouble* pdmudB,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input); 68 void dViscositydDSSA(IssmDouble* pdmudB,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input); 69 IssmDouble Divergence(void); 70 void ThermalToEnthalpy(IssmDouble* penthalpy,IssmDouble temperature,IssmDouble waterfraction,IssmDouble pressure); 71 void EnthalpyToThermal(IssmDouble* ptemperature,IssmDouble* pwaterfraction,IssmDouble enthalpy,IssmDouble pressure); 72 IssmDouble EnthalpyDiffusionParameter(IssmDouble enthalpy,IssmDouble pressure); 73 IssmDouble EnthalpyDiffusionParameterVolume(int numvertices,IssmDouble* enthalpy,IssmDouble* pressure); 74 void FindParam(bool* pvalue,int paramenum); 75 void FindParam(int* pvalue,int paramenum); 76 void FindParam(IssmDouble* pvalue,int paramenum); 77 void FindParam(int** pvalues,int* psize,int paramenum); 78 void GetDofList(int** pdoflist,int approximation_enum,int setenum); 79 void GetDofListVelocity(int** pdoflist,int setenum); 80 void GetDofListPressure(int** pdoflist,int setenum); 81 Input* GetInput(int inputenum); 82 void GetInputListOnNodes(IssmDouble* pvalue,int enumtype); 83 void GetInputListOnNodes(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue); 84 void GetInputListOnNodesVelocity(IssmDouble* pvalue,int enumtype); 85 void GetInputListOnVertices(IssmDouble* pvalue,int enumtype); 86 void GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue); 87 void GetInputValue(bool* pvalue,int enum_type); 88 void GetInputValue(int* pvalue,int enum_type); 89 void GetInputValue(IssmDouble* pvalue,int enum_type); 90 void GetInputValue(IssmDouble* pvalue,Gauss* gauss,int enum_type); 91 IssmDouble GetMaterialParameter(int enum_in); 92 void GetNodesSidList(int* sidlist); 93 void GetNodesLidList(int* lidlist); 94 void GetPhi(IssmDouble* phi, IssmDouble* epsilon, IssmDouble viscosity); 95 void GetVectorFromInputs(Vector<IssmDouble>* vector, int name_enum); 96 void GetVertexPidList(int* pidlist); 97 void GetVerticesCoordinates(IssmDouble** xyz_list); 98 void GetVerticesSidList(int* sidlist); 99 void GetVerticesConnectivityList(int* connectivitylist); 100 IssmDouble GetXcoord(IssmDouble* xyz_list,Gauss* gauss); 101 IssmDouble GetYcoord(IssmDouble* xyz_list,Gauss* gauss); 102 IssmDouble GetZcoord(IssmDouble* xyz_list,Gauss* gauss); 103 void GradientIndexing(int* indexing,int control_index); 104 bool HasNodeOnBase(); 105 bool HasNodeOnSurface(); 106 int Id(); 107 int Sid(); 108 void InputChangeName(int enum_type,int enum_type_old); 109 void InputCreate(IssmDouble* vector,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code); 110 void InputDuplicate(int original_enum,int new_enum); 111 void InputUpdateFromConstant(IssmDouble constant, int name); 112 void InputUpdateFromConstant(int constant, int name); 113 void InputUpdateFromConstant(bool constant, int name); 114 bool IsIceInElement(); 115 bool IsInput(int name); 116 bool IsFloating(); 117 void LinearFloatingiceMeltingRate(); 118 ElementVector* NewElementVector(int approximation_enum=NoneApproximationEnum); 119 ElementMatrix* NewElementMatrix(int approximation_enum=NoneApproximationEnum); 120 ElementMatrix* NewElementMatrixCoupling(int number_nodes,int approximation_enum=NoneApproximationEnum); 121 IssmDouble PureIceEnthalpy(IssmDouble pressure); 122 void ResultInterpolation(int* pinterpolation,int*nodesperelement,int output_enum); 123 void ResultToVector(Vector<IssmDouble>* vector,int output_enum); 124 void ResultToPatch(IssmDouble* values,int nodesperelement,int output_enum); 125 void SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum); 126 void StrainRateSSA(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input); 127 void StrainRateSSA1d(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input); 128 void StrainRateHO(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input); 129 void StrainRateHO2dvertical(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input); 130 void StrainRateFS(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vz_input); 131 IssmDouble TMeltingPoint(IssmDouble pressure); 132 void TransformInvStiffnessMatrixCoord(ElementMatrix* Ke,int cs_enum); 133 void TransformInvStiffnessMatrixCoord(ElementMatrix* Ke,Node** nodes,int numnodes,int cs_enum); 134 void TransformInvStiffnessMatrixCoord(ElementMatrix* Ke,Node** nodes,int numnodes,int* cs_array); 135 void TransformLoadVectorCoord(ElementVector* pe,int cs_enum); 136 void TransformLoadVectorCoord(ElementVector* pe,int* cs_array); 137 void TransformLoadVectorCoord(ElementVector* pe,Node** nodes,int numnodes,int cs_enum); 138 void TransformLoadVectorCoord(ElementVector* pe,Node** nodes,int numnodes,int* cs_array); 139 void TransformSolutionCoord(IssmDouble* solution,int cs_enum); 140 void TransformSolutionCoord(IssmDouble* solution,int* cs_array); 141 void TransformSolutionCoord(IssmDouble* solution,int numnodes,int cs_enum); 142 void TransformSolutionCoord(IssmDouble* solution,int numnodes,int* cs_array); 143 void TransformSolutionCoord(IssmDouble* solution,Node** nodes,int numnodes,int cs_enum); 144 void TransformSolutionCoord(IssmDouble* solution,Node** nodes,int numnodes,int* cs_array); 145 void TransformStiffnessMatrixCoord(ElementMatrix* Ke,int cs_enum); 146 void TransformStiffnessMatrixCoord(ElementMatrix* Ke,int* cs_array); 147 void TransformStiffnessMatrixCoord(ElementMatrix* Ke,Node** nodes,int numnodes,int cs_enum); 148 void TransformStiffnessMatrixCoord(ElementMatrix* Ke,Node** nodes,int numnodes,int* cs_array); 149 void ViscousHeatingCreateInput(void); 150 void ViscosityFS(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vz_input); 151 void ViscosityHO(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input); 152 void ViscosityL1L2(IssmDouble* pviscosity,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* surf); 153 void ViscositySSA(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input); 154 void ViscositySSADerivativeEpsSquare(IssmDouble* pmu_prime,IssmDouble* epsilon); 155 void ViscosityHODerivativeEpsSquare(IssmDouble* pmu_prime,IssmDouble* epsilon); 156 void ViscosityFSDerivativeEpsSquare(IssmDouble* pmu_prime,IssmDouble* epsilon); 157 void TransformLoadVectorCoord(ElementVector* pe,int numnodes,int transformenum){_error_("not implemented yet");};/*Tiling only*/ 158 void TransformLoadVectorCoord(ElementVector* pe,int numnodes,int* transformenum_list){_error_("not implemented yet");};/*Tiling only*/ 159 void TransformStiffnessMatrixCoord(ElementMatrix* Ke,int numnodes,int* transformenum_list){_error_("not implemented yet");};/*Tiling only*/ 58 void AddInput(Input* input_in); 59 /*bool AllActive(void);*/ 60 /*bool AnyActive(void);*/ 61 void ComputeNewDamage(); 62 void ComputeStrainRate(); 63 void CoordinateSystemTransform(IssmDouble** ptransform,Node** nodes,int numnodes,int* cs_array); 64 void Echo(); 65 void DeepEcho(); 66 void DeleteInput(int input_enum); 67 void DeleteMaterials(void); 68 IssmDouble Divergence(void); 69 void dViscositydBFS(IssmDouble* pdmudB,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vz_input); 70 void dViscositydBHO(IssmDouble* pdmudB,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input); 71 void dViscositydBSSA(IssmDouble* pdmudB,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input); 72 void dViscositydDSSA(IssmDouble* pdmudB,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input); 73 IssmDouble EnthalpyDiffusionParameter(IssmDouble enthalpy,IssmDouble pressure); 74 IssmDouble EnthalpyDiffusionParameterVolume(int numvertices,IssmDouble* enthalpy,IssmDouble* pressure); 75 void EnthalpyToThermal(IssmDouble* ptemperature,IssmDouble* pwaterfraction,IssmDouble enthalpy,IssmDouble pressure); 76 void FindParam(bool* pvalue,int paramenum); 77 void FindParam(int* pvalue,int paramenum); 78 void FindParam(IssmDouble* pvalue,int paramenum); 79 void FindParam(int** pvalues,int* psize,int paramenum); 80 void GetDofList(int** pdoflist,int approximation_enum,int setenum); 81 void GetDofListPressure(int** pdoflist,int setenum); 82 void GetDofListVelocity(int** pdoflist,int setenum); 83 Input* GetInput(int inputenum); 84 void GetInputListOnNodes(IssmDouble* pvalue,int enumtype); 85 void GetInputListOnNodes(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue); 86 void GetInputListOnNodesVelocity(IssmDouble* pvalue,int enumtype); 87 void GetInputListOnVertices(IssmDouble* pvalue,int enumtype); 88 void GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue); 89 void GetInputLocalMinMaxOnNodes(IssmDouble* min,IssmDouble* max,IssmDouble* ug); 90 void GetInputValue(bool* pvalue,int enum_type); 91 void GetInputValue(int* pvalue,int enum_type); 92 void GetInputValue(IssmDouble* pvalue,int enum_type); 93 void GetInputValue(IssmDouble* pvalue,Gauss* gauss,int enum_type); 94 IssmDouble GetMaterialParameter(int enum_in); 95 void GetNodesLidList(int* lidlist); 96 void GetNodesSidList(int* sidlist); 97 void GetPhi(IssmDouble* phi, IssmDouble* epsilon, IssmDouble viscosity); 98 void GetVectorFromInputs(Vector<IssmDouble>* vector, int name_enum, int type); 99 void GetVertexPidList(int* pidlist); 100 void GetVerticesConnectivityList(int* connectivitylist); 101 void GetVerticesCoordinates(IssmDouble** xyz_list); 102 void GetVerticesSidList(int* sidlist); 103 IssmDouble GetXcoord(IssmDouble* xyz_list,Gauss* gauss); 104 IssmDouble GetYcoord(IssmDouble* xyz_list,Gauss* gauss); 105 IssmDouble GetZcoord(IssmDouble* xyz_list,Gauss* gauss); 106 void GradientIndexing(int* indexing,int control_index,bool onsid=false); 107 bool HasNodeOnBase(); 108 bool HasNodeOnSurface(); 109 int Id(); 110 void InputChangeName(int enum_type,int enum_type_old); 111 void InputCreate(IssmDouble* vector,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code); 112 void InputDuplicate(int original_enum,int new_enum); 113 void InputUpdateFromConstant(IssmDouble constant, int name); 114 void InputUpdateFromConstant(int constant, int name); 115 void InputUpdateFromConstant(bool constant, int name); 116 bool IsFloating(); 117 bool IsIceInElement(); 118 bool IsInput(int name); 119 void LinearFloatingiceMeltingRate(); 120 void MigrateGroundingLine(IssmDouble* sheet_ungrounding); 121 ElementMatrix* NewElementMatrix(int approximation_enum=NoneApproximationEnum); 122 ElementMatrix* NewElementMatrixCoupling(int number_nodes,int approximation_enum=NoneApproximationEnum); 123 ElementVector* NewElementVector(int approximation_enum=NoneApproximationEnum); 124 IssmDouble PureIceEnthalpy(IssmDouble pressure); 125 void ResultInterpolation(int* pinterpolation,int*nodesperelement,int output_enum); 126 void ResultToPatch(IssmDouble* values,int nodesperelement,int output_enum); 127 void ResultToVector(Vector<IssmDouble>* vector,int output_enum); 128 void SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum); 129 int Sid(); 130 void StrainRateFS(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vz_input); 131 void StrainRateHO(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input); 132 void StrainRateHO2dvertical(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input); 133 void StrainRateSSA(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input); 134 void StrainRateSSA1d(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input); 135 void StressMaxPrincipalCreateInput(void); 136 void ThermalToEnthalpy(IssmDouble* penthalpy,IssmDouble temperature,IssmDouble waterfraction,IssmDouble pressure); 137 IssmDouble TMeltingPoint(IssmDouble pressure); 138 void TransformInvStiffnessMatrixCoord(ElementMatrix* Ke,int cs_enum); 139 void TransformInvStiffnessMatrixCoord(ElementMatrix* Ke,Node** nodes,int numnodes,int cs_enum); 140 void TransformInvStiffnessMatrixCoord(ElementMatrix* Ke,Node** nodes,int numnodes,int* cs_array); 141 void TransformLoadVectorCoord(ElementVector* pe,int cs_enum); 142 void TransformLoadVectorCoord(ElementVector* pe,int* cs_array); 143 void TransformLoadVectorCoord(ElementVector* pe,Node** nodes,int numnodes,int cs_enum); 144 void TransformLoadVectorCoord(ElementVector* pe,Node** nodes,int numnodes,int* cs_array); 145 void TransformLoadVectorCoord(ElementVector* pe,int numnodes,int transformenum){_error_("not implemented yet");};/*Tiling only*/ 146 void TransformLoadVectorCoord(ElementVector* pe,int numnodes,int* transformenum_list){_error_("not implemented yet");};/*Tiling only*/ 147 void TransformSolutionCoord(IssmDouble* solution,int cs_enum); 148 void TransformSolutionCoord(IssmDouble* solution,int* cs_array); 149 void TransformSolutionCoord(IssmDouble* solution,int numnodes,int cs_enum); 150 void TransformSolutionCoord(IssmDouble* solution,int numnodes,int* cs_array); 151 void TransformSolutionCoord(IssmDouble* solution,Node** nodes,int numnodes,int cs_enum); 152 void TransformSolutionCoord(IssmDouble* solution,Node** nodes,int numnodes,int* cs_array); 153 void TransformStiffnessMatrixCoord(ElementMatrix* Ke,int cs_enum); 154 void TransformStiffnessMatrixCoord(ElementMatrix* Ke,int* cs_array); 155 void TransformStiffnessMatrixCoord(ElementMatrix* Ke,Node** nodes,int numnodes,int cs_enum); 156 void TransformStiffnessMatrixCoord(ElementMatrix* Ke,Node** nodes,int numnodes,int* cs_array); 157 void TransformStiffnessMatrixCoord(ElementMatrix* Ke,int numnodes,int* transformenum_list){_error_("not implemented yet");};/*Tiling only*/ 158 void ViscosityFS(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vz_input); 159 void ViscosityFSDerivativeEpsSquare(IssmDouble* pmu_prime,IssmDouble* epsilon); 160 void ViscosityHO(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input); 161 void ViscosityHODerivativeEpsSquare(IssmDouble* pmu_prime,IssmDouble* epsilon); 162 void ViscosityL1L2(IssmDouble* pviscosity,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* surf); 163 void ViscositySSA(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input); 164 void ViscositySSADerivativeEpsSquare(IssmDouble* pmu_prime,IssmDouble* epsilon); 165 void ViscousHeatingCreateInput(void); 160 166 161 167 /*Virtual functions*/ 162 168 virtual void AddBasalInput(int input_enum, IssmDouble* values, int interpolation_enum)=0; 163 169 virtual void AddInput(int input_enum, IssmDouble* values, int interpolation_enum)=0; 170 virtual void AverageOntoPartition(Vector<IssmDouble>* partition_contributions,Vector<IssmDouble>* partition_areas,IssmDouble* vertex_response,IssmDouble* qmu_part)=0; 171 virtual void CalvingRateLevermann(void)=0; 172 virtual void CalvingRatePi(void)=0; 173 virtual void CalvingRateDev(void){_error_("not implemented yet");}; 164 174 virtual IssmDouble CharacteristicLength(void)=0; 175 virtual void ComputeBasalStress(Vector<IssmDouble>* sigma_b)=0; 176 virtual void ComputeDeviatoricStressTensor(void)=0; 177 virtual void ComputeSigmaNN(void)=0; 178 virtual void ComputeStressTensor(void)=0; 165 179 virtual void Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters)=0; 180 virtual void ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index)=0; 181 virtual void ControlToVectors(Vector<IssmPDouble>* vector_control, Vector<IssmPDouble>* vector_gradient,int control_enum)=0; 182 virtual void Delta18oParameterization(void)=0; 183 virtual void MungsmtpParameterization(void)=0; 184 virtual void ElementResponse(IssmDouble* presponse,int response_enum)=0; 185 virtual void ElementSizes(IssmDouble* phx,IssmDouble* phy,IssmDouble* phz)=0; 186 virtual int FiniteElement(void)=0; 187 virtual void FSContactMigration(Vector<IssmDouble>* vertexgrounded,Vector<IssmDouble>* vertexfloating)=0; 188 virtual Element* GetBasalElement(void)=0; 189 virtual int GetElementType(void)=0; 190 virtual void GetGroundedPart(int* point1,IssmDouble* fraction1,IssmDouble* fraction2, bool* mainlyfloating)=0; 191 virtual IssmDouble GetGroundedPortion(IssmDouble* xyz_list)=0; 192 virtual void GetIcefrontCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum)=0; 193 virtual void GetInputValue(IssmDouble* pvalue,Node* node,int enumtype)=0; 194 virtual void GetLevelCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum,IssmDouble level)=0; 195 virtual void GetLevelsetPositivePart(int* point1,IssmDouble* fraction1,IssmDouble* fraction2, bool* mainlynegative,IssmDouble* levelsetvalues)=0; 196 virtual Node* GetNode(int node_number)=0; 197 virtual int GetNodeIndex(Node* node)=0; 198 virtual int GetNumberOfNodes(void)=0; 199 virtual int GetNumberOfNodes(int enum_type)=0; 200 virtual int GetNumberOfVertices(void)=0; 201 virtual void GetSolutionFromInputsOneDof(Vector<IssmDouble>* solution,int solutionenum)=0; 202 virtual Element* GetUpperElement(void)=0; 203 virtual void GetVectorFromControlInputs(Vector<IssmDouble>* gradient,int control_enum,int control_index,const char* data,bool onsid)=0; 204 virtual void GetVerticesCoordinatesBase(IssmDouble** xyz_list)=0; 205 virtual void GetVerticesCoordinatesTop(IssmDouble** xyz_list)=0; 206 virtual IssmDouble IceMass(void)=0; 207 virtual IssmDouble IceVolume(void)=0; 208 virtual IssmDouble IceVolumeAboveFloatation(void)=0; 209 virtual void InputControlUpdate(IssmDouble scalar,bool save_parameter)=0; 210 virtual void InputDepthAverageAtBase(int enum_type,int average_enum_type)=0; 211 virtual void InputExtrude(int input_enum,int start)=0; 212 virtual void InputScale(int enum_type,IssmDouble scale_factor)=0; 213 virtual void InputUpdateFromSolutionOneDofCollapsed(IssmDouble* solution,int inputenum)=0; 214 virtual void InputUpdateFromSolutionOneDof(IssmDouble* solution,int inputenum)=0; 215 virtual bool IsFaceOnBoundary(void)=0; 216 virtual bool IsIcefront(void)=0; 217 virtual bool IsNodeOnShelfFromFlags(IssmDouble* flags)=0; 218 virtual bool IsOnBase()=0; 219 virtual bool IsOnSurface()=0; 220 virtual bool IsZeroLevelset(int levelset_enum)=0; 221 virtual void JacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss)=0; 222 virtual void JacobianDeterminantBase(IssmDouble* Jdet,IssmDouble* xyz_list_base,Gauss* gauss)=0; 223 virtual void JacobianDeterminantLine(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss)=0; 224 virtual void JacobianDeterminantSurface(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss)=0; 225 virtual void JacobianDeterminantTop(IssmDouble* Jdet,IssmDouble* xyz_list_base,Gauss* gauss)=0; 226 virtual IssmDouble Masscon(IssmDouble* levelset)=0; 227 virtual IssmDouble MassFlux(IssmDouble* segment)=0; 228 virtual IssmDouble MassFlux(IssmDouble x1,IssmDouble y1, IssmDouble x2, IssmDouble y2,int segment_id)=0; 229 virtual IssmDouble MinEdgeLength(IssmDouble* xyz_list)=0; 230 virtual IssmDouble Misfit(int modelenum,int observationenum,int weightsenum)=0; 231 virtual IssmDouble MisfitArea(int weightsenum)=0; 232 virtual Gauss* NewGauss(void)=0; 233 virtual Gauss* NewGauss(int order)=0; 234 virtual Gauss* NewGauss(IssmDouble* xyz_list, IssmDouble* xyz_list_front,int order)=0; 235 virtual Gauss* NewGauss(IssmDouble* xyz_list, IssmDouble* xyz_list_front,int order_horiz,int order_vert)=0; 236 virtual Gauss* NewGauss(int point1,IssmDouble fraction1,IssmDouble fraction2,bool mainlyfloating,int order)=0; 237 virtual Gauss* NewGaussBase(int order)=0; 238 virtual Gauss* NewGaussLine(int vertex1,int vertex2,int order)=0; 239 virtual Gauss* NewGaussTop(int order)=0; 240 virtual void NodalFunctions(IssmDouble* basis,Gauss* gauss)=0; 241 virtual void NodalFunctionsDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss)=0; 242 virtual void NodalFunctionsDerivativesVelocity(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss)=0; 243 virtual void NodalFunctionsMINIDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss)=0; 244 virtual void NodalFunctionsPressure(IssmDouble* basis, Gauss* gauss)=0; 245 virtual void NodalFunctionsP1(IssmDouble* basis,Gauss* gauss)=0; 246 virtual void NodalFunctionsP1Derivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss)=0; 247 virtual void NodalFunctionsP2(IssmDouble* basis,Gauss* gauss)=0; 248 virtual void NodalFunctionsVelocity(IssmDouble* basis, Gauss* gauss)=0; 249 virtual void NodalFunctionsTensor(IssmDouble* basis, Gauss* gauss)=0; 250 virtual int NodalValue(IssmDouble* pvalue, int index, int natureofdataenum)=0; 251 virtual void NormalBase(IssmDouble* normal,IssmDouble* xyz_list)=0; 252 virtual void NormalSection(IssmDouble* normal,IssmDouble* xyz_list)=0; 253 virtual void NormalTop(IssmDouble* normal,IssmDouble* xyz_list)=0; 254 virtual int NumberofNodesPressure(void)=0; 255 virtual int NumberofNodesVelocity(void)=0; 256 virtual void PositiveDegreeDay(IssmDouble* pdds,IssmDouble* pds,IssmDouble signorm,bool ismungsm)=0; 257 virtual void PotentialUngrounding(Vector<IssmDouble>* potential_sheet_ungrounding)=0; 258 virtual int PressureInterpolation()=0; 259 virtual void ReduceMatrices(ElementMatrix* Ke,ElementVector* pe)=0; 260 virtual void ResetFSBasalBoundaryCondition()=0; 261 virtual void ResetHooks()=0; 262 virtual void SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index)=0; 166 263 virtual void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Materials* materials,Parameters* parameters)=0; 167 virtual void ResetHooks()=0; 168 virtual void ElementSizes(IssmDouble* phx,IssmDouble* phy,IssmDouble* phz)=0; 169 170 virtual int FiniteElement(void)=0; 171 virtual IssmDouble MinEdgeLength(IssmDouble* xyz_list)=0; 172 virtual void NodalFunctions(IssmDouble* basis,Gauss* gauss)=0; 173 virtual void NodalFunctionsP1(IssmDouble* basis,Gauss* gauss)=0; 174 virtual void NodalFunctionsP2(IssmDouble* basis,Gauss* gauss)=0; 175 virtual void NodalFunctionsVelocity(IssmDouble* basis, Gauss* gauss)=0; 176 virtual void NodalFunctionsPressure(IssmDouble* basis, Gauss* gauss)=0; 177 virtual void NodalFunctionsTensor(IssmDouble* basis, Gauss* gauss)=0; 178 virtual void NodalFunctionsDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss)=0; 179 virtual void NodalFunctionsP1Derivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss)=0; 180 virtual void NodalFunctionsMINIDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss)=0; 181 virtual void NodalFunctionsDerivativesVelocity(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss)=0; 182 virtual void NormalSection(IssmDouble* normal,IssmDouble* xyz_list)=0; 183 virtual void NormalTop(IssmDouble* normal,IssmDouble* xyz_list)=0; 184 virtual void NormalBase(IssmDouble* normal,IssmDouble* xyz_list)=0; 185 186 virtual Element* GetUpperElement(void)=0; 187 virtual Element* GetBasalElement(void)=0; 188 189 virtual void JacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss)=0; 190 virtual void JacobianDeterminantLine(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss)=0; 191 virtual void JacobianDeterminantSurface(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss)=0; 192 virtual void JacobianDeterminantBase(IssmDouble* Jdet,IssmDouble* xyz_list_base,Gauss* gauss)=0; 193 virtual void JacobianDeterminantTop(IssmDouble* Jdet,IssmDouble* xyz_list_base,Gauss* gauss)=0; 194 virtual void GetSolutionFromInputsOneDof(Vector<IssmDouble>* solution,int solutionenum)=0; 195 virtual int GetNodeIndex(Node* node)=0; 196 virtual int GetNumberOfNodes(void)=0; 197 virtual int GetNumberOfNodes(int enum_type)=0; 198 virtual int GetNumberOfVertices(void)=0; 199 200 virtual bool IsNodeOnShelfFromFlags(IssmDouble* flags)=0; 201 virtual bool IsOnBase()=0; 202 virtual bool IsOnSurface()=0; 203 virtual void GetGroundedPart(int* point1,IssmDouble* fraction1,IssmDouble* fraction2, bool* mainlyfloating)=0; 204 virtual IssmDouble GetGroundedPortion(IssmDouble* xyz_list)=0; 205 virtual void GetInputValue(IssmDouble* pvalue,Node* node,int enumtype)=0; 206 virtual Node* GetNode(int node_number)=0; 207 virtual void GetVerticesCoordinatesBase(IssmDouble** xyz_list)=0; 208 virtual void GetVerticesCoordinatesTop(IssmDouble** xyz_list)=0; 209 210 virtual int GetElementType(void)=0; 211 212 virtual IssmDouble SurfaceArea(void)=0; 213 virtual void InputDepthAverageAtBase(int enum_type,int average_enum_type)=0; 214 virtual void ComputeSigmaNN(void)=0; 215 virtual void ComputeBasalStress(Vector<IssmDouble>* sigma_b)=0; 216 virtual void ComputeStressTensor(void)=0; 217 virtual void ComputeDeviatoricStressTensor(void)=0; 218 219 virtual void Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type,int finite_element)=0; 220 virtual void InputExtrude(int input_enum)=0; 221 virtual void InputUpdateFromSolutionOneDofCollapsed(IssmDouble* solution,int inputenum)=0; 222 virtual void InputUpdateFromSolutionOneDof(IssmDouble* solution,int inputenum)=0; 223 224 virtual int NodalValue(IssmDouble* pvalue, int index, int natureofdataenum)=0; 225 virtual int NumberofNodesVelocity(void)=0; 226 virtual int NumberofNodesPressure(void)=0; 227 virtual Gauss* NewGauss(void)=0; 228 virtual Gauss* NewGauss(int order)=0; 229 virtual Gauss* NewGauss(IssmDouble* xyz_list, IssmDouble* xyz_list_front,int order)=0; 230 virtual Gauss* NewGauss(IssmDouble* xyz_list, IssmDouble* xyz_list_front,int order_horiz,int order_vert)=0; 231 virtual Gauss* NewGauss(int point1,IssmDouble fraction1,IssmDouble fraction2,bool mainlyfloating,int order)=0; 232 virtual Gauss* NewGaussBase(int order)=0; 233 virtual Gauss* NewGaussLine(int vertex1,int vertex2,int order)=0; 234 virtual Gauss* NewGaussTop(int order)=0; 235 236 virtual void InputScale(int enum_type,IssmDouble scale_factor)=0; 237 virtual IssmDouble TimeAdapt()=0; 238 virtual void PositiveDegreeDay(IssmDouble* pdds,IssmDouble* pds,IssmDouble signorm)=0; 239 virtual void Delta18oParameterization(void)=0; 264 virtual void SetTemporaryElementType(int element_type_in)=0; 240 265 virtual Element* SpawnBasalElement(void)=0; 241 266 virtual Element* SpawnTopElement(void)=0; 242 virtual void ReduceMatrices(ElementMatrix* Ke,ElementVector* pe)=0;243 virtual void ResetFSBasalBoundaryCondition()=0;244 virtual void SetTemporaryElementType(int element_type_in)=0;245 267 virtual IssmDouble StabilizationParameter(IssmDouble u, IssmDouble v, IssmDouble w, IssmDouble diameter, IssmDouble kappa)=0; 246 virtual void ValueP1OnGauss(IssmDouble* pvalue,IssmDouble* values,Gauss* gauss)=0; 247 virtual void ValueP1DerivativesOnGauss(IssmDouble* dvalue,IssmDouble* values,IssmDouble* xyz_list,Gauss* gauss)=0; 248 virtual void ViscousHeating(IssmDouble* pphi,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vz_input)=0; 249 250 virtual int VelocityInterpolation()=0; 251 virtual int PressureInterpolation()=0; 252 virtual int TensorInterpolation()=0; 253 virtual bool IsZeroLevelset(int levelset_enum)=0; 254 virtual bool IsIcefront(void)=0; 255 virtual bool IsFaceOnBoundary(void)=0; 256 virtual void ZeroLevelsetCoordinates(IssmDouble** pxyz_zero,IssmDouble* xyz_list,int levelsetenum)=0; 257 virtual void GetIcefrontCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum)=0; 258 virtual void GetLevelCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum,IssmDouble level)=0; 259 260 virtual void AverageOntoPartition(Vector<IssmDouble>* partition_contributions,Vector<IssmDouble>* partition_areas,IssmDouble* vertex_response,IssmDouble* qmu_part)=0; 261 virtual IssmDouble MassFlux(IssmDouble* segment)=0; 262 virtual IssmDouble MassFlux(IssmDouble x1,IssmDouble y1, IssmDouble x2, IssmDouble y2,int segment_id)=0; 263 virtual void ElementResponse(IssmDouble* presponse,int response_enum)=0; 264 virtual IssmDouble IceVolume(void)=0; 265 virtual IssmDouble IceVolumeAboveFloatation(void)=0; 268 virtual void StrainRateparallel(void)=0; 269 virtual void StrainRateperpendicular(void)=0; 270 virtual void StressIntensityFactor(void)=0; 271 virtual IssmDouble SurfaceArea(void)=0; 272 virtual int TensorInterpolation()=0; 273 virtual IssmDouble TimeAdapt()=0; 266 274 virtual IssmDouble TotalSmb(void)=0; 267 virtual IssmDouble Misfit(int modelenum,int observationenum,int weightsenum)=0; 268 virtual IssmDouble MisfitArea(int weightsenum)=0; 269 virtual int VertexConnectivity(int vertexindex)=0; 270 virtual void VerticalSegmentIndices(int** pindices,int* pnumseg)=0; 275 virtual void Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type,int finite_element)=0; 276 virtual void UpdateConstraintsExtrudeFromBase(void)=0; 277 virtual void UpdateConstraintsExtrudeFromTop(void)=0; 278 virtual int UpdatePotentialUngrounding(IssmDouble* potential_sheet_ungrounding,Vector<IssmDouble>* vec_nodes_on_iceshelf,IssmDouble* nodes_on_iceshelf)=0; 279 virtual void ValueP1DerivativesOnGauss(IssmDouble* dvalue,IssmDouble* values,IssmDouble* xyz_list,Gauss* gauss)=0; 280 virtual void ValueP1OnGauss(IssmDouble* pvalue,IssmDouble* values,Gauss* gauss)=0; 281 virtual int VelocityInterpolation()=0; 282 virtual int VertexConnectivity(int vertexindex)=0; 283 virtual void VerticalSegmentIndices(int** pindices,int* pnumseg)=0; 284 virtual void ViscousHeating(IssmDouble* pphi,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vz_input)=0; 285 virtual void ZeroLevelsetCoordinates(IssmDouble** pxyz_zero,IssmDouble* xyz_list,int levelsetenum)=0; 271 286 272 287 #ifdef _HAVE_GIA_ 273 virtual void GiaDeflection(Vector<IssmDouble>* wg,Vector<IssmDouble>* dwgdt,IssmDouble* x,IssmDouble* y)=0;288 virtual void GiaDeflection(Vector<IssmDouble>* wg,Vector<IssmDouble>* dwgdt,IssmDouble* x,IssmDouble* y)=0; 274 289 #endif 275 276 virtual void ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index)=0;277 virtual void ControlToVectors(Vector<IssmPDouble>* vector_control, Vector<IssmPDouble>* vector_gradient,int control_enum)=0;278 virtual void GetVectorFromControlInputs(Vector<IssmDouble>* gradient,int control_enum,int control_index,const char* data)=0;279 virtual void SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index)=0;280 virtual void InputControlUpdate(IssmDouble scalar,bool save_parameter)=0;281 282 virtual void UpdateConstraintsExtrudeFromBase(void)=0;283 virtual void UpdateConstraintsExtrudeFromTop(void)=0;284 285 virtual void MigrateGroundingLine(IssmDouble* sheet_ungrounding)=0;286 virtual void FSContactMigration(Vector<IssmDouble>* vertexgrounded,Vector<IssmDouble>* vertexfloating)=0;287 virtual void PotentialUngrounding(Vector<IssmDouble>* potential_sheet_ungrounding)=0;288 virtual int UpdatePotentialUngrounding(IssmDouble* potential_sheet_ungrounding,Vector<IssmDouble>* vec_nodes_on_iceshelf,IssmDouble* nodes_on_iceshelf)=0;289 290 290 }; 291 291 #endif -
issm/trunk/src/c/classes/Elements/ElementHook.cpp
r18301 r19105 75 75 /*}}}*/ 76 76 77 void ElementHook::InitHookNeighbors(int* element_ids){/*{{{*/ 78 this->hneighbors=new Hook(element_ids,2); 79 } 80 /*}}}*/ 77 81 void ElementHook::SetHookNodes(int* node_ids,int numnodes,int analysis_counter){/*{{{*/ 78 82 if(this->hnodes) this->hnodes[analysis_counter]= new Hook(node_ids,numnodes); 79 83 } 80 84 /*}}}*/ 81 void ElementHook::InitHookNeighbors(int* element_ids){/*{{{*/ 82 this->hneighbors=new Hook(element_ids,2); 85 void ElementHook::SpawnSegHook(ElementHook* triahook,int index1,int index2){/*{{{*/ 86 87 triahook->numanalyses=this->numanalyses; 88 89 int indices[2]; 90 indices[0]=index1; 91 indices[1]=index2; 92 93 /*Spawn nodes hook*/ 94 triahook->hnodes=new Hook*[this->numanalyses]; 95 for(int i=0;i<this->numanalyses;i++){ 96 /*Do not do anything if Hook is empty*/ 97 if (!this->hnodes[i] || this->hnodes[i]->GetNum()==0){ 98 triahook->hnodes[i]=NULL; 99 } 100 else{ 101 triahook->hnodes[i]=this->hnodes[i]->Spawn(indices,2); 102 } 103 } 104 105 /*do not spawn hmaterial. material will be taken care of by Tria*/ 106 triahook->hmaterial=NULL; 107 triahook->hvertices=(Hook*)this->hvertices->Spawn(indices,2); 108 triahook->hmatpar=(Hook*)this->hmatpar->copy(); 83 109 } 84 110 /*}}}*/ … … 111 137 } 112 138 /*}}}*/ 113 void ElementHook::SpawnSegHook(ElementHook* triahook,int index1,int index2){/*{{{*/114 115 triahook->numanalyses=this->numanalyses;116 117 int indices[2];118 indices[0]=index1;119 indices[1]=index2;120 121 /*Spawn nodes hook*/122 triahook->hnodes=new Hook*[this->numanalyses];123 for(int i=0;i<this->numanalyses;i++){124 /*Do not do anything if Hook is empty*/125 if (!this->hnodes[i] || this->hnodes[i]->GetNum()==0){126 triahook->hnodes[i]=NULL;127 }128 else{129 triahook->hnodes[i]=this->hnodes[i]->Spawn(indices,2);130 }131 }132 133 /*do not spawn hmaterial. material will be taken care of by Tria*/134 triahook->hmaterial=NULL;135 triahook->hvertices=(Hook*)this->hvertices->Spawn(indices,2);136 triahook->hmatpar=(Hook*)this->hmatpar->copy();137 }138 /*}}}*/ -
issm/trunk/src/c/classes/Elements/ElementHook.h
r17806 r19105 24 24 ~ElementHook(); 25 25 26 void InitHookNeighbors(int* element_ids); //3d only 26 27 void SetHookNodes(int* node_ids,int numnodes,int analysis_counter); 28 void SpawnSegHook(ElementHook* triahook,int ndex1,int index2); //2d only 27 29 void SpawnTriaHook(ElementHook* triahook,int index1,int index2,int index3); //3d only 28 void SpawnSegHook(ElementHook* triahook,int ndex1,int index2); //2d only29 void InitHookNeighbors(int* element_ids); //3d only30 30 }; 31 31 -
issm/trunk/src/c/classes/Elements/Elements.cpp
r18301 r19105 41 41 for ( object=objects.begin() ; object < objects.end(); object++ ){ 42 42 43 element= dynamic_cast<Element*>((*object));43 element=xDynamicCast<Element*>((*object)); 44 44 element->Configure(elements,loads,nodes,vertices,materials,parameters); 45 45 … … 55 55 for ( object=objects.begin() ; object < objects.end(); object++ ){ 56 56 57 element= dynamic_cast<Element*>((*object));57 element=xDynamicCast<Element*>((*object)); 58 58 element->SetCurrentConfiguration(elements,loads,nodes,materials,parameters); 59 59 … … 69 69 for ( object=objects.begin() ; object < objects.end(); object++ ){ 70 70 71 element= dynamic_cast<Element*>((*object));71 element=xDynamicCast<Element*>((*object)); 72 72 element->ResetHooks(); 73 73 … … 85 85 for(int i=0;i<this->Size();i++){ 86 86 87 Element* element= dynamic_cast<Element*>(this->GetObjectByOffset(i));87 Element* element=xDynamicCast<Element*>(this->GetObjectByOffset(i)); 88 88 numnodes=element->GetNumberOfNodes(); 89 89 if(numnodes>max)max=numnodes; … … 111 111 112 112 for(int i=0;i<this->Size();i++){ 113 Element* element= dynamic_cast<Element*>(this->GetObjectByOffset(i));113 Element* element=xDynamicCast<Element*>(this->GetObjectByOffset(i)); 114 114 element->InputDuplicate(input_enum,output_enum); 115 115 } -
issm/trunk/src/c/classes/Elements/Penta.cpp
r18301 r19105 125 125 126 126 /*Other*/ 127 void Penta::AddInput(int input_enum,IssmDouble* values, int interpolation_enum){/*{{{*/128 129 _assert_(this->inputs);130 this->inputs->AddInput(new PentaInput(input_enum,values,interpolation_enum));131 }132 /*}}}*/133 127 void Penta::AddBasalInput(int input_enum,IssmDouble* values, int interpolation_enum){/*{{{*/ 134 128 … … 154 148 else _error_("not implemented yet"); 155 149 } 150 } 151 /*}}}*/ 152 void Penta::AddInput(int input_enum,IssmDouble* values, int interpolation_enum){/*{{{*/ 153 154 _assert_(this->inputs); 155 this->inputs->AddInput(new PentaInput(input_enum,values,interpolation_enum)); 156 } 157 /*}}}*/ 158 void Penta::AverageOntoPartition(Vector<IssmDouble>* partition_contributions,Vector<IssmDouble>* partition_areas,IssmDouble* vertex_response,IssmDouble* qmu_part){/*{{{*/ 159 _error_("Not supported yet!"); 160 } 161 /*}}}*/ 162 void Penta::CalvingRateLevermann(){/*{{{*/ 163 164 IssmDouble xyz_list[NUMVERTICES][3]; 165 GaussPenta* gauss=NULL; 166 IssmDouble vx,vy,vel; 167 IssmDouble strainparallel; 168 IssmDouble propcoeff; 169 IssmDouble strainperpendicular; 170 IssmDouble calvingratex[NUMVERTICES]; 171 IssmDouble calvingratey[NUMVERTICES]; 172 IssmDouble calvingrate[NUMVERTICES]; 173 174 175 /* Get node coordinates and dof list: */ 176 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 177 178 /*Retrieve all inputs and parameters we will need*/ 179 Input* vx_input=inputs->GetInput(VxEnum); _assert_(vx_input); 180 Input* vy_input=inputs->GetInput(VyEnum); _assert_(vy_input); 181 Input* strainparallel_input=inputs->GetInput(StrainRateparallelEnum); _assert_(strainparallel_input); 182 Input* strainperpendicular_input=inputs->GetInput(StrainRateperpendicularEnum); _assert_(strainperpendicular_input); 183 Input* levermanncoeff_input=inputs->GetInput(CalvinglevermannCoeffEnum); _assert_(levermanncoeff_input); 184 185 /* Start looping on the number of vertices: */ 186 gauss=new GaussPenta(); 187 for (int iv=0;iv<NUMVERTICES;iv++){ 188 gauss->GaussVertex(iv); 189 190 /* Get the value we need*/ 191 vx_input->GetInputValue(&vx,gauss); 192 vy_input->GetInputValue(&vy,gauss); 193 vel=vx*vx+vy*vy; 194 strainparallel_input->GetInputValue(&strainparallel,gauss); 195 strainperpendicular_input->GetInputValue(&strainperpendicular,gauss); 196 levermanncoeff_input->GetInputValue(&propcoeff,gauss); 197 198 /*Calving rate proportionnal to the positive product of the strain rate along the ice flow direction and the strain rate perpendicular to the ice flow */ 199 calvingrate[iv]=propcoeff*strainparallel*strainperpendicular; 200 if(calvingrate[iv]<0){ 201 calvingrate[iv]=0; 202 } 203 calvingratex[iv]=calvingrate[iv]*vx/(sqrt(vel)+1.e-14); 204 calvingratey[iv]=calvingrate[iv]*vy/(sqrt(vel)+1.e-14); 205 } 206 207 /*Add input*/ 208 this->inputs->AddInput(new PentaInput(CalvingratexEnum,&calvingratex[0],P1Enum)); 209 this->inputs->AddInput(new PentaInput(CalvingrateyEnum,&calvingratey[0],P1Enum)); 210 this->inputs->AddInput(new PentaInput(CalvingCalvingrateEnum,&calvingrate[0],P1Enum)); 211 212 /*Clean up and return*/ 213 delete gauss; 214 215 } 216 /*}}}*/ 217 void Penta::CalvingRatePi(){/*{{{*/ 218 219 IssmDouble xyz_list[NUMVERTICES][3]; 220 GaussPenta* gauss=NULL; 221 IssmDouble vx,vy,vel; 222 IssmDouble strainparallel; 223 IssmDouble sxx; 224 IssmDouble sxy; 225 IssmDouble syy; 226 IssmDouble sigVM; 227 IssmDouble thickness; 228 IssmDouble base; 229 IssmDouble hAB; 230 IssmDouble propcoeff; 231 IssmDouble calvingratex[NUMVERTICES]; 232 IssmDouble calvingratey[NUMVERTICES]; 233 IssmDouble calvingrate[NUMVERTICES]; 234 235 236 /* Get node coordinates and dof list: */ 237 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 238 239 /*Retrieve all inputs and parameters we will need*/ 240 Input* vx_input=inputs->GetInput(VxEnum); _assert_(vx_input); 241 Input* vy_input=inputs->GetInput(VyEnum); _assert_(vy_input); 242 Input* strainparallel_input=inputs->GetInput(StrainRateparallelEnum); _assert_(strainparallel_input); 243 Input* sxx_input=inputs->GetInput(DeviatoricStressxxEnum); _assert_(sxx_input); 244 Input* sxy_input=inputs->GetInput(DeviatoricStressxyEnum); _assert_(sxy_input); 245 Input* syy_input=inputs->GetInput(DeviatoricStressyyEnum); _assert_(syy_input); 246 Input* thickness_input=inputs->GetInput(ThicknessEnum); _assert_(thickness_input); 247 Input* base_input=inputs->GetInput(BaseEnum); _assert_(base_input); 248 Input* picoeff_input=inputs->GetInput(CalvingpiCoeffEnum); _assert_(picoeff_input); 249 250 /* Start looping on the number of vertices: */ 251 gauss=new GaussPenta(); 252 for (int iv=0;iv<NUMVERTICES;iv++){ 253 gauss->GaussVertex(iv); 254 255 /* Get the value we need*/ 256 vx_input->GetInputValue(&vx,gauss); 257 vy_input->GetInputValue(&vy,gauss); 258 vel=vx*vx+vy*vy; 259 strainparallel_input->GetInputValue(&strainparallel,gauss); 260 sxx_input->GetInputValue(&sxx,gauss); 261 sxy_input->GetInputValue(&sxy,gauss); 262 syy_input->GetInputValue(&syy,gauss); 263 thickness_input->GetInputValue(&thickness,gauss); 264 base_input->GetInputValue(&base,gauss); 265 picoeff_input->GetInputValue(&propcoeff,gauss); 266 267 /* Computing sigma Von Mises*/ 268 sigVM=sqrt(sxx*sxx+syy*syy+3*sxy*sxy-sxx*syy); 269 270 /* Computing heigth above buoyancy*/ 271 hAB=thickness+1028/920*base; 272 273 /*Calving rate for Pi criterion proportionnal to the product of the strain rate along the ice flow direction and the Von Mises stress and the square of the glacier width (hardcoded) divided by the height above buoyancy and the max of the ice velocity power 3 and the ice density (ignored here)*/ 274 calvingrate[iv]=propcoeff*strainparallel*sigVM*25.e6/hAB/1e9; 275 if(calvingrate[iv]<0){ 276 calvingrate[iv]=0; 277 } 278 calvingratex[iv]=calvingrate[iv]*vx/(sqrt(vel)+1.e-6); 279 calvingratey[iv]=calvingrate[iv]*vy/(sqrt(vel)+1.e-6); 280 } 281 282 /*Add input*/ 283 this->inputs->AddInput(new PentaInput(CalvingratexEnum,&calvingratex[0],P1Enum)); 284 this->inputs->AddInput(new PentaInput(CalvingrateyEnum,&calvingratey[0],P1Enum)); 285 this->inputs->AddInput(new PentaInput(CalvingCalvingrateEnum,&calvingrate[0],P1Enum)); 286 287 /*Clean up and return*/ 288 delete gauss; 289 156 290 } 157 291 /*}}}*/ … … 193 327 194 328 /*recovre material parameters: */ 195 rho_ice=matpar->Get RhoIce();196 gravity=matpar->Get G();329 rho_ice=matpar->GetMaterialParameter(MaterialsRhoIceEnum); 330 gravity=matpar->GetMaterialParameter(ConstantsGEnum); 197 331 198 332 /* Get node coordinates and dof list: */ … … 243 377 } 244 378 /*}}}*/ 379 void Penta::ComputeDeviatoricStressTensor(){/*{{{*/ 380 381 IssmDouble xyz_list[NUMVERTICES][3]; 382 IssmDouble viscosity; 383 IssmDouble epsilon[6]; /* epsilon=[exx,eyy,exy];*/ 384 IssmDouble tau_xx[NUMVERTICES]; 385 IssmDouble tau_yy[NUMVERTICES]; 386 IssmDouble tau_zz[NUMVERTICES]; 387 IssmDouble tau_xy[NUMVERTICES]; 388 IssmDouble tau_xz[NUMVERTICES]; 389 IssmDouble tau_yz[NUMVERTICES]; 390 GaussPenta* gauss=NULL; 391 392 /* Get node coordinates and dof list: */ 393 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 394 395 /*Retrieve all inputs we will be needing: */ 396 Input* vx_input=inputs->GetInput(VxEnum); _assert_(vx_input); 397 Input* vy_input=inputs->GetInput(VyEnum); _assert_(vy_input); 398 Input* vz_input=inputs->GetInput(VzEnum); _assert_(vz_input); 399 400 /* Start looping on the number of vertices: */ 401 gauss=new GaussPenta(); 402 for (int iv=0;iv<NUMVERTICES;iv++){ 403 gauss->GaussVertex(iv); 404 405 /*Compute strain rate viscosity and pressure: */ 406 this->StrainRateFS(&epsilon[0],&xyz_list[0][0],gauss,vx_input,vy_input,vz_input); 407 this->ViscosityFS(&viscosity,3,&xyz_list[0][0],gauss,vx_input,vy_input,vz_input); 408 409 /*Compute Stress*/ 410 tau_xx[iv]=2*viscosity*epsilon[0]; // tau = nu eps 411 tau_yy[iv]=2*viscosity*epsilon[1]; 412 tau_zz[iv]=2*viscosity*epsilon[2]; 413 tau_xy[iv]=2*viscosity*epsilon[3]; 414 tau_xz[iv]=2*viscosity*epsilon[4]; 415 tau_yz[iv]=2*viscosity*epsilon[5]; 416 } 417 418 /*Add Stress tensor components into inputs*/ 419 this->inputs->AddInput(new PentaInput(DeviatoricStressxxEnum,&tau_xx[0],P1Enum)); 420 this->inputs->AddInput(new PentaInput(DeviatoricStressxyEnum,&tau_xy[0],P1Enum)); 421 this->inputs->AddInput(new PentaInput(DeviatoricStressxzEnum,&tau_xz[0],P1Enum)); 422 this->inputs->AddInput(new PentaInput(DeviatoricStressyyEnum,&tau_yy[0],P1Enum)); 423 this->inputs->AddInput(new PentaInput(DeviatoricStressyzEnum,&tau_yz[0],P1Enum)); 424 this->inputs->AddInput(new PentaInput(DeviatoricStresszzEnum,&tau_zz[0],P1Enum)); 425 426 /*Clean up and return*/ 427 delete gauss; 428 } 429 /*}}}*/ 245 430 void Penta::ComputeStressTensor(){/*{{{*/ 246 431 247 IssmDouble 248 IssmDouble 249 IssmDouble 250 IssmDouble 251 IssmDouble 252 IssmDouble 253 IssmDouble 254 IssmDouble 255 IssmDouble 432 IssmDouble xyz_list[NUMVERTICES][3]; 433 IssmDouble pressure,viscosity; 434 IssmDouble epsilon[6]; /* epsilon=[exx,eyy,exy];*/ 435 IssmDouble sigma_xx[NUMVERTICES]; 436 IssmDouble sigma_yy[NUMVERTICES]; 437 IssmDouble sigma_zz[NUMVERTICES]; 438 IssmDouble sigma_xy[NUMVERTICES]; 439 IssmDouble sigma_xz[NUMVERTICES]; 440 IssmDouble sigma_yz[NUMVERTICES]; 256 441 GaussPenta* gauss=NULL; 257 442 … … 296 481 } 297 482 /*}}}*/ 298 void Penta::ComputeDeviatoricStressTensor(){/*{{{*/299 300 IssmDouble xyz_list[NUMVERTICES][3];301 IssmDouble viscosity;302 IssmDouble epsilon[6]; /* epsilon=[exx,eyy,exy];*/303 IssmDouble tau_xx[NUMVERTICES];304 IssmDouble tau_yy[NUMVERTICES];305 IssmDouble tau_zz[NUMVERTICES];306 IssmDouble tau_xy[NUMVERTICES];307 IssmDouble tau_xz[NUMVERTICES];308 IssmDouble tau_yz[NUMVERTICES];309 GaussPenta* gauss=NULL;310 311 /* Get node coordinates and dof list: */312 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES);313 314 /*Retrieve all inputs we will be needing: */315 Input* vx_input=inputs->GetInput(VxEnum); _assert_(vx_input);316 Input* vy_input=inputs->GetInput(VyEnum); _assert_(vy_input);317 Input* vz_input=inputs->GetInput(VzEnum); _assert_(vz_input);318 319 /* Start looping on the number of vertices: */320 gauss=new GaussPenta();321 for (int iv=0;iv<NUMVERTICES;iv++){322 gauss->GaussVertex(iv);323 324 /*Compute strain rate viscosity and pressure: */325 this->StrainRateFS(&epsilon[0],&xyz_list[0][0],gauss,vx_input,vy_input,vz_input);326 this->ViscosityFS(&viscosity,3,&xyz_list[0][0],gauss,vx_input,vy_input,vz_input);327 328 /*Compute Stress*/329 tau_xx[iv]=2*viscosity*epsilon[0]; // tau = nu eps330 tau_yy[iv]=2*viscosity*epsilon[1];331 tau_zz[iv]=2*viscosity*epsilon[2];332 tau_xy[iv]=2*viscosity*epsilon[3];333 tau_xz[iv]=2*viscosity*epsilon[4];334 tau_yz[iv]=2*viscosity*epsilon[5];335 }336 337 /*Add Stress tensor components into inputs*/338 this->inputs->AddInput(new PentaInput(StressTensorxxEnum,&tau_xx[0],P1Enum));339 this->inputs->AddInput(new PentaInput(StressTensorxyEnum,&tau_xy[0],P1Enum));340 this->inputs->AddInput(new PentaInput(StressTensorxzEnum,&tau_xz[0],P1Enum));341 this->inputs->AddInput(new PentaInput(StressTensoryyEnum,&tau_yy[0],P1Enum));342 this->inputs->AddInput(new PentaInput(StressTensoryzEnum,&tau_yz[0],P1Enum));343 this->inputs->AddInput(new PentaInput(StressTensorzzEnum,&tau_zz[0],P1Enum));344 345 /*Clean up and return*/346 delete gauss;347 }348 /*}}}*/349 483 void Penta::Configure(Elements* elementsin, Loads* loadsin, Nodes* nodesin,Vertices* verticesin, Materials* materialsin, Parameters* parametersin){/*{{{*/ 350 484 … … 380 514 } 381 515 /*}}}*/ 516 void Penta::ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index){/*{{{*/ 517 518 int vertexpidlist[NUMVERTICES]; 519 IssmDouble grad_list[NUMVERTICES]; 520 Input* grad_input=NULL; 521 Input* input=NULL; 522 523 if(enum_type==MaterialsRheologyBbarEnum){ 524 input=(Input*)inputs->GetInput(MaterialsRheologyBEnum); 525 } 526 else if(enum_type==DamageDbarEnum){ 527 input=(Input*)inputs->GetInput(DamageDEnum); 528 } 529 else{ 530 input=inputs->GetInput(enum_type); 531 } 532 if (!input) _error_("Input " << EnumToStringx(enum_type) << " not found"); 533 if (input->ObjectEnum()!=ControlInputEnum) _error_("Input " << EnumToStringx(enum_type) << " is not a ControlInput"); 534 535 GradientIndexing(&vertexpidlist[0],control_index); 536 for(int i=0;i<NUMVERTICES;i++) grad_list[i]=gradient[vertexpidlist[i]]; 537 grad_input=new PentaInput(GradientEnum,grad_list,P1Enum); 538 ((ControlInput*)input)->SetGradient(grad_input); 539 540 }/*}}}*/ 541 void Penta::ControlToVectors(Vector<IssmPDouble>* vector_control, Vector<IssmPDouble>* vector_gradient,int control_enum){/*{{{*/ 542 543 Input* input=NULL; 544 545 if(control_enum==MaterialsRheologyBbarEnum){ 546 input=(Input*)inputs->GetInput(MaterialsRheologyBEnum); 547 } 548 else if(control_enum==DamageDbarEnum){ 549 input=(Input*)inputs->GetInput(DamageDEnum); 550 } 551 else{ 552 input=inputs->GetInput(control_enum); 553 } 554 if (!input) _error_("Input " << EnumToStringx(control_enum) << " not found"); 555 if (input->ObjectEnum()!=ControlInputEnum) _error_("Input " << EnumToStringx(control_enum) << " is not a ControlInput"); 556 557 int sidlist[NUMVERTICES]; 558 int connectivity[NUMVERTICES]; 559 IssmPDouble values[NUMVERTICES]; 560 IssmPDouble gradients[NUMVERTICES]; 561 IssmDouble value,gradient; 562 563 this->GetVerticesConnectivityList(&connectivity[0]); 564 this->GetVerticesSidList(&sidlist[0]); 565 566 GaussPenta* gauss=new GaussPenta(); 567 for (int iv=0;iv<NUMVERTICES;iv++){ 568 gauss->GaussVertex(iv); 569 570 ((ControlInput*)input)->GetInputValue(&value,gauss); 571 ((ControlInput*)input)->GetGradientValue(&gradient,gauss); 572 573 values[iv] = reCast<IssmPDouble>(value)/reCast<IssmPDouble>(connectivity[iv]); 574 gradients[iv] = reCast<IssmPDouble>(gradient)/reCast<IssmPDouble>(connectivity[iv]); 575 } 576 delete gauss; 577 578 vector_control->SetValues(NUMVERTICES,&sidlist[0],&values[0],ADD_VAL); 579 vector_gradient->SetValues(NUMVERTICES,&sidlist[0],&gradients[0],ADD_VAL); 580 581 }/*}}}*/ 382 582 void Penta::Delta18oParameterization(void){/*{{{*/ 383 583 … … 408 608 input2->GetInputValue(&TemperaturesLgm[iv][month],gauss,month/12.*yts); 409 609 input3->GetInputValue(&PrecipitationsPresentday[iv][month],gauss,month/12.*yts); 410 PrecipitationsPresentday[iv][month]=PrecipitationsPresentday[iv][month]/yts; // converion in m/sec411 610 } 412 611 } … … 447 646 this->inputs->AddInput(NewPrecipitationInput); 448 647 449 this->InputExtrude(SurfaceforcingsMonthlytemperaturesEnum );450 this->InputExtrude(SurfaceforcingsPrecipitationEnum );648 this->InputExtrude(SurfaceforcingsMonthlytemperaturesEnum,-1); 649 this->InputExtrude(SurfaceforcingsPrecipitationEnum,-1); 451 650 452 651 /*clean-up*/ … … 454 653 } 455 654 /*}}}*/ 655 void Penta::MungsmtpParameterization(void){/*{{{*/ 656 /*Are we on the base? If not, return*/ 657 if(!IsOnBase()) return; 658 659 int i; 660 IssmDouble monthlytemperatures[NUMVERTICES][12],monthlyprec[NUMVERTICES][12]; 661 IssmDouble TemperaturesPresentday[NUMVERTICES][12],TemperaturesLgm[NUMVERTICES][12]; 662 IssmDouble PrecipitationsPresentday[NUMVERTICES][12],PrecipitationsLgm[NUMVERTICES][12]; 663 IssmDouble tmp[NUMVERTICES]; 664 IssmDouble TdiffTime,PfacTime; 665 IssmDouble time,yts; 666 this->parameters->FindParam(&time,TimeEnum); 667 this->parameters->FindParam(&yts,ConstantsYtsEnum); 668 669 /*Recover present day temperature and precipitation*/ 670 Input* input=inputs->GetInput(SurfaceforcingsTemperaturesPresentdayEnum); _assert_(input); 671 Input* input2=inputs->GetInput(SurfaceforcingsTemperaturesLgmEnum); _assert_(input2); 672 Input* input3=inputs->GetInput(SurfaceforcingsPrecipitationsPresentdayEnum); _assert_(input3); 673 Input* input4=inputs->GetInput(SurfaceforcingsPrecipitationsLgmEnum); _assert_(input4); 674 GaussPenta* gauss=new GaussPenta(); 675 for(int month=0;month<12;month++) { 676 for(int iv=0;iv<NUMVERTICES;iv++) { 677 gauss->GaussVertex(iv); 678 input->GetInputValue(&TemperaturesPresentday[iv][month],gauss,month/12.*yts); 679 input2->GetInputValue(&TemperaturesLgm[iv][month],gauss,month/12.*yts); 680 input3->GetInputValue(&PrecipitationsPresentday[iv][month],gauss,month/12.*yts); 681 input4->GetInputValue(&PrecipitationsLgm[iv][month],gauss,month/12.*yts); 682 } 683 } 684 685 /*Recover interpolation parameters at time t*/ 686 this->parameters->FindParam(&TdiffTime,SurfaceforcingsTdiffEnum,time); 687 this->parameters->FindParam(&PfacTime,SurfaceforcingsPfacEnum,time); 688 689 /*Compute the temperature and precipitation*/ 690 for(int iv=0;iv<NUMVERTICES;iv++){ 691 ComputeMungsmTemperaturePrecipitation(TdiffTime,PfacTime, 692 &PrecipitationsLgm[iv][0],&PrecipitationsPresentday[iv][0], 693 &TemperaturesLgm[iv][0], &TemperaturesPresentday[iv][0], 694 &monthlytemperatures[iv][0], &monthlyprec[iv][0]); 695 } 696 697 /*Update inputs*/ 698 TransientInput* NewTemperatureInput = new TransientInput(SurfaceforcingsMonthlytemperaturesEnum); 699 TransientInput* NewPrecipitationInput = new TransientInput(SurfaceforcingsPrecipitationEnum); 700 for (int imonth=0;imonth<12;imonth++) { 701 for(i=0;i<NUMVERTICES;i++) tmp[i]=monthlytemperatures[i][imonth]; 702 PentaInput* newmonthinput1 = new PentaInput(SurfaceforcingsMonthlytemperaturesEnum,&tmp[0],P1Enum); 703 NewTemperatureInput->AddTimeInput(newmonthinput1,time+imonth/12.*yts); 704 705 for(i=0;i<NUMVERTICES;i++) tmp[i]=monthlyprec[i][imonth]; 706 PentaInput* newmonthinput2 = new PentaInput(SurfaceforcingsPrecipitationEnum,&tmp[0],P1Enum); 707 NewPrecipitationInput->AddTimeInput(newmonthinput2,time+imonth/12.*yts); 708 } 709 NewTemperatureInput->Configure(this->parameters); 710 NewPrecipitationInput->Configure(this->parameters); 711 712 this->inputs->AddInput(NewTemperatureInput); 713 this->inputs->AddInput(NewPrecipitationInput); 714 715 this->InputExtrude(SurfaceforcingsMonthlytemperaturesEnum,-1); 716 this->InputExtrude(SurfaceforcingsPrecipitationEnum,-1); 717 718 /*clean-up*/ 719 delete gauss; 720 } 721 /*}}}*/ 722 void Penta::ElementResponse(IssmDouble* presponse,int response_enum){/*{{{*/ 723 724 switch(response_enum){ 725 case MaterialsRheologyBbarEnum: 726 *presponse=this->material->GetBbar(); 727 break; 728 case DamageDbarEnum: 729 *presponse=this->material->GetDbar(); 730 break; 731 case VelEnum: 732 { 733 734 /*Get input:*/ 735 IssmDouble vel; 736 Input* vel_input; 737 738 vel_input=this->inputs->GetInput(VelEnum); _assert_(vel_input); 739 vel_input->GetInputAverage(&vel); 740 741 /*Assign output pointers:*/ 742 *presponse=vel; 743 } 744 break; 745 default: 746 _error_("Response type " << EnumToStringx(response_enum) << " not supported yet!"); 747 } 748 749 } 750 /*}}}*/ 751 void Penta::ElementSizes(IssmDouble* hx,IssmDouble* hy,IssmDouble* hz){/*{{{*/ 752 753 IssmDouble xyz_list[NUMVERTICES][3]; 754 IssmDouble xmin,ymin,zmin; 755 IssmDouble xmax,ymax,zmax; 756 757 /*Get xyz list: */ 758 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 759 xmin=xyz_list[0][0]; xmax=xyz_list[0][0]; 760 ymin=xyz_list[0][1]; ymax=xyz_list[0][1]; 761 zmin=xyz_list[0][2]; zmax=xyz_list[0][2]; 762 763 for(int i=1;i<NUMVERTICES;i++){ 764 if(xyz_list[i][0]<xmin) xmin=xyz_list[i][0]; 765 if(xyz_list[i][0]>xmax) xmax=xyz_list[i][0]; 766 if(xyz_list[i][1]<ymin) ymin=xyz_list[i][1]; 767 if(xyz_list[i][1]>ymax) ymax=xyz_list[i][1]; 768 if(xyz_list[i][2]<zmin) zmin=xyz_list[i][2]; 769 if(xyz_list[i][2]>zmax) zmax=xyz_list[i][2]; 770 } 771 772 *hx=xmax-xmin; 773 *hy=ymax-ymin; 774 *hz=zmax-zmin; 775 } 776 /*}}}*/ 456 777 int Penta::FiniteElement(void){/*{{{*/ 457 778 return this->element_type; … … 462 783 if(!IsOnBase()) return; 463 784 464 /*Intermediaries*/ 465 IssmDouble* xyz_list = NULL; 466 IssmDouble pressure,water_pressure,sigma_nn,viscosity,bed,base; 467 IssmDouble bed_normal[3]; 468 IssmDouble epsilon[6]; /* epsilon=[exx eyy ezz exy exz eyz];*/ 469 IssmDouble surface=0,value=0; 470 bool grounded; 471 472 /* Get node coordinates and dof list: */ 473 GetVerticesCoordinates(&xyz_list); 474 475 /*Retrieve all inputs we will be needing: */ 476 Input* pressure_input = inputs->GetInput(PressureEnum); _assert_(pressure_input); 477 Input* base_input = inputs->GetInput(BaseEnum); _assert_(base_input); 478 Input* bed_input = inputs->GetInput(BedEnum); _assert_(bed_input); 479 Input* vx_input = inputs->GetInput(VxEnum); _assert_(vx_input); 480 Input* vy_input = inputs->GetInput(VyEnum); _assert_(vy_input); 481 Input* vz_input = inputs->GetInput(VzEnum); _assert_(vz_input); 482 483 /*Create gauss point in the middle of the basal edge*/ 484 Gauss* gauss=NewGaussBase(1); 485 gauss->GaussPoint(0); 486 487 if(!IsFloating()){ 488 /*Check for basal force only if grounded and touching GL*/ 489 if(this->inputs->Min(MaskGroundediceLevelsetEnum)==0.){ 785 int approximation; 786 inputs->GetInputValue(&approximation,ApproximationEnum); 787 if(approximation==HOApproximationEnum || approximation==SSAApproximationEnum || approximation==SSAHOApproximationEnum){ 788 for(int i=0;i<NUMVERTICES;i++){ 789 vertexgrounded->SetValue(vertices[i]->Pid(),+9999.,INS_VAL); 790 vertexfloating->SetValue(vertices[i]->Pid(),+9999.,INS_VAL); 791 } 792 } 793 else { 794 /*Intermediaries*/ 795 IssmDouble* xyz_list = NULL; 796 IssmDouble pressure,water_pressure,sigma_nn,viscosity,bed,base; 797 IssmDouble bed_normal[3]; 798 IssmDouble epsilon[6]; /* epsilon=[exx eyy ezz exy exz eyz];*/ 799 IssmDouble surface=0,value=0; 800 bool grounded; 801 802 /* Get node coordinates and dof list: */ 803 GetVerticesCoordinates(&xyz_list); 804 805 /*Retrieve all inputs we will be needing: */ 806 Input* pressure_input = inputs->GetInput(PressureEnum); _assert_(pressure_input); 807 Input* base_input = inputs->GetInput(BaseEnum); _assert_(base_input); 808 Input* bed_input = inputs->GetInput(BedEnum); _assert_(bed_input); 809 Input* vx_input = inputs->GetInput(VxEnum); _assert_(vx_input); 810 Input* vy_input = inputs->GetInput(VyEnum); _assert_(vy_input); 811 Input* vz_input = inputs->GetInput(VzEnum); _assert_(vz_input); 812 813 /*Create gauss point in the middle of the basal edge*/ 814 Gauss* gauss=NewGaussBase(1); 815 gauss->GaussPoint(0); 816 817 if(!IsFloating()){ 818 /*Check for basal force only if grounded and touching GL*/ 490 819 this->StrainRateFS(&epsilon[0],xyz_list,gauss,vx_input,vy_input,vz_input); 491 820 this->ViscosityFS(&viscosity,3,xyz_list,gauss,vx_input,vy_input,vz_input); … … 509 838 510 839 /*Compute water pressure*/ 511 IssmDouble rho_ice = matpar->Get RhoIce();512 IssmDouble rho_water = matpar->Get RhoWater();513 IssmDouble gravity = matpar->Get G();840 IssmDouble rho_ice = matpar->GetMaterialParameter(MaterialsRhoIceEnum); 841 IssmDouble rho_water = matpar->GetMaterialParameter(MaterialsRhoSeawaterEnum); 842 IssmDouble gravity = matpar->GetMaterialParameter(ConstantsGEnum); 514 843 water_pressure=gravity*rho_water*base; 515 844 … … 519 848 } 520 849 else{ 521 grounded=true; 522 } 523 } 524 else{ 525 /*Check for basal elevation if floating*/ 526 base_input->GetInputValue(&base, gauss); 527 bed_input->GetInputValue(&bed, gauss); 528 if (base<bed) grounded=true; 529 else grounded=false; 530 } 531 for(int i=0;i<NUMVERTICES;i++){ 532 if(grounded) vertexgrounded->SetValue(vertices[i]->Pid(),+1.,INS_VAL); 533 else vertexfloating->SetValue(vertices[i]->Pid(),+1.,INS_VAL); 534 } 535 536 /*clean up*/ 537 delete gauss; 538 xDelete<IssmDouble>(xyz_list); 539 } 540 /*}}}*/ 541 int Penta::ObjectEnum(void){/*{{{*/ 542 543 return PentaEnum; 544 850 /*Check for basal elevation if floating*/ 851 base_input->GetInputValue(&base, gauss); 852 bed_input->GetInputValue(&bed, gauss); 853 if(base<bed) grounded=true; 854 else grounded=false; 855 } 856 for(int i=0;i<NUMVERTICES;i++){ 857 if(grounded) vertexgrounded->SetValue(vertices[i]->Pid(),+1.,INS_VAL); 858 else vertexfloating->SetValue(vertices[i]->Pid(),+1.,INS_VAL); 859 } 860 861 /*clean up*/ 862 delete gauss; 863 xDelete<IssmDouble>(xyz_list); 864 } 545 865 } 546 866 /*}}}*/ … … 580 900 } 581 901 /*}}}*/ 582 Penta* Penta::GetUpperPenta(void){/*{{{*/ 583 584 Penta* upper_penta=NULL; 585 586 upper_penta=(Penta*)verticalneighbors[1]; //first one (0) under, second one (1) above 587 588 return upper_penta; 902 Element* Penta::GetBasalElement(void){/*{{{*/ 903 904 /*Output*/ 905 Element* element=this->GetBasalPenta(); 906 return element; 907 } 908 /*}}}*/ 909 Penta* Penta::GetBasalPenta(void){/*{{{*/ 910 911 /*Output*/ 912 Penta* penta=NULL; 913 914 /*Go through all pentas till the bed is reached*/ 915 penta=this; 916 for(;;){ 917 /*Stop if we have reached the surface, else, take lower penta*/ 918 if (penta->IsOnBase()) break; 919 920 /* get lower Penta*/ 921 penta=penta->GetLowerPenta(); 922 _assert_(penta->Id()!=this->id); 923 } 924 925 /*return output*/ 926 return penta; 927 } 928 /*}}}*/ 929 int Penta::GetElementType(){/*{{{*/ 930 931 /*return PentaRef field*/ 932 return this->element_type; 933 } 934 /*}}}*/ 935 void Penta::GetGroundedPart(int* point1,IssmDouble* fraction1,IssmDouble* fraction2, bool* mainlyfloating){/*{{{*/ 936 /*Computeportion of the element that is grounded*/ 937 938 bool floating=true; 939 int point; 940 const IssmPDouble epsilon= 1.e-15; 941 IssmDouble gl[NUMVERTICES]; 942 IssmDouble f1,f2; 943 944 /*Recover parameters and values*/ 945 GetInputListOnVertices(&gl[0],MaskGroundediceLevelsetEnum); 946 947 /*Be sure that values are not zero*/ 948 if(gl[0]==0.) gl[0]=gl[0]+epsilon; 949 if(gl[1]==0.) gl[1]=gl[1]+epsilon; 950 if(gl[2]==0.) gl[2]=gl[2]+epsilon; 951 952 /*Check that not all nodes are grounded or floating*/ 953 if(gl[0]>0 && gl[1]>0 && gl[2]>0){ // All grounded 954 point=0; 955 f1=1.; 956 f2=1.; 957 } 958 else if(gl[0]<0 && gl[1]<0 && gl[2]<0){ //All floating 959 point=0; 960 f1=0.; 961 f2=0.; 962 } 963 else{ 964 if(gl[0]*gl[1]*gl[2]<0) floating=false; 965 966 if(gl[0]*gl[1]>0){ //Nodes 0 and 1 are similar, so points must be found on segment 0-2 and 1-2 967 point=2; 968 f1=gl[2]/(gl[2]-gl[0]); 969 f2=gl[2]/(gl[2]-gl[1]); 970 } 971 else if(gl[1]*gl[2]>0){ //Nodes 1 and 2 are similar, so points must be found on segment 0-1 and 0-2 972 point=0; 973 f1=gl[0]/(gl[0]-gl[1]); 974 f2=gl[0]/(gl[0]-gl[2]); 975 } 976 else if(gl[0]*gl[2]>0){ //Nodes 0 and 2 are similar, so points must be found on segment 1-0 and 1-2 977 point=1; 978 f1=gl[1]/(gl[1]-gl[2]); 979 f2=gl[1]/(gl[1]-gl[0]); 980 } 981 } 982 *point1=point; 983 *fraction1=f1; 984 *fraction2=f2; 985 *mainlyfloating=floating; 986 } 987 /*}}}*/ 988 IssmDouble Penta::GetGroundedPortion(IssmDouble* xyz_list){/*{{{*/ 989 /*Computeportion of the element that is grounded*/ 990 991 bool mainlyfloating = true; 992 const IssmPDouble epsilon= 1.e-15; 993 IssmDouble phi,s1,s2,area_init,area_grounded; 994 IssmDouble gl[NUMVERTICES]; 995 IssmDouble xyz_bis[NUMVERTICES2D][3]; 996 997 /*Recover parameters and values*/ 998 GetInputListOnVertices(&gl[0],MaskGroundediceLevelsetEnum); 999 1000 /*Be sure that values are not zero*/ 1001 if(gl[0]==0.) gl[0]=gl[0]+epsilon; 1002 if(gl[1]==0.) gl[1]=gl[1]+epsilon; 1003 if(gl[2]==0.) gl[2]=gl[2]+epsilon; 1004 1005 /*Check that not all nodes are grounded or floating*/ 1006 if(gl[0]>0 && gl[1]>0 && gl[2]>0){ // All grounded 1007 phi=1; 1008 } 1009 else if(gl[0]<0 && gl[1]<0 && gl[2]<0){ //All floating 1010 phi=0; 1011 } 1012 else{ 1013 /*Figure out if two nodes are floating or grounded*/ 1014 if(gl[0]*gl[1]*gl[2]>0) mainlyfloating=false; 1015 1016 if(gl[0]*gl[1]>0){ //Nodes 0 and 1 are similar, so points must be found on segment 0-2 and 1-2 1017 /*Coordinates of point 2: same as initial point 2*/ 1018 xyz_bis[2][0]=xyz_list[3*2+0]; 1019 xyz_bis[2][1]=xyz_list[3*2+1]; 1020 xyz_bis[2][2]=xyz_list[3*2+2]; 1021 1022 /*Portion of the segments*/ 1023 s1=gl[2]/(gl[2]-gl[1]); 1024 s2=gl[2]/(gl[2]-gl[0]); 1025 1026 /*New point 1*/ 1027 xyz_bis[1][0]=xyz_list[3*2+0]+s1*(xyz_list[3*1+0]-xyz_list[3*2+0]); 1028 xyz_bis[1][1]=xyz_list[3*2+1]+s1*(xyz_list[3*1+1]-xyz_list[3*2+1]); 1029 xyz_bis[1][2]=xyz_list[3*2+2]+s1*(xyz_list[3*1+2]-xyz_list[3*2+2]); 1030 1031 /*New point 0*/ 1032 xyz_bis[0][0]=xyz_list[3*2+0]+s2*(xyz_list[3*0+0]-xyz_list[3*2+0]); 1033 xyz_bis[0][1]=xyz_list[3*2+1]+s2*(xyz_list[3*0+1]-xyz_list[3*2+1]); 1034 xyz_bis[0][2]=xyz_list[3*2+2]+s2*(xyz_list[3*0+2]-xyz_list[3*2+2]); 1035 } 1036 else if(gl[1]*gl[2]>0){ //Nodes 1 and 2 are similar, so points must be found on segment 0-1 and 0-2 1037 /*Coordinates of point 0: same as initial point 2*/ 1038 xyz_bis[0][0]=*(xyz_list+3*0+0); 1039 xyz_bis[0][1]=*(xyz_list+3*0+1); 1040 xyz_bis[0][2]=*(xyz_list+3*0+2); 1041 1042 /*Portion of the segments*/ 1043 s1=gl[0]/(gl[0]-gl[1]); 1044 s2=gl[0]/(gl[0]-gl[2]); 1045 1046 /*New point 1*/ 1047 xyz_bis[1][0]=*(xyz_list+3*0+0)+s1*(*(xyz_list+3*1+0)-*(xyz_list+3*0+0)); 1048 xyz_bis[1][1]=*(xyz_list+3*0+1)+s1*(*(xyz_list+3*1+1)-*(xyz_list+3*0+1)); 1049 xyz_bis[1][2]=*(xyz_list+3*0+2)+s1*(*(xyz_list+3*1+2)-*(xyz_list+3*0+2)); 1050 1051 /*New point 2*/ 1052 xyz_bis[2][0]=*(xyz_list+3*0+0)+s2*(*(xyz_list+3*2+0)-*(xyz_list+3*0+0)); 1053 xyz_bis[2][1]=*(xyz_list+3*0+1)+s2*(*(xyz_list+3*2+1)-*(xyz_list+3*0+1)); 1054 xyz_bis[2][2]=*(xyz_list+3*0+2)+s2*(*(xyz_list+3*2+2)-*(xyz_list+3*0+2)); 1055 } 1056 else if(gl[0]*gl[2]>0){ //Nodes 0 and 2 are similar, so points must be found on segment 1-0 and 1-2 1057 /*Coordinates of point 1: same as initial point 2*/ 1058 xyz_bis[1][0]=*(xyz_list+3*1+0); 1059 xyz_bis[1][1]=*(xyz_list+3*1+1); 1060 xyz_bis[1][2]=*(xyz_list+3*1+2); 1061 1062 /*Portion of the segments*/ 1063 s1=gl[1]/(gl[1]-gl[0]); 1064 s2=gl[1]/(gl[1]-gl[2]); 1065 1066 /*New point 0*/ 1067 xyz_bis[0][0]=*(xyz_list+3*1+0)+s1*(*(xyz_list+3*0+0)-*(xyz_list+3*1+0)); 1068 xyz_bis[0][1]=*(xyz_list+3*1+1)+s1*(*(xyz_list+3*0+1)-*(xyz_list+3*1+1)); 1069 xyz_bis[0][2]=*(xyz_list+3*1+2)+s1*(*(xyz_list+3*0+2)-*(xyz_list+3*1+2)); 1070 1071 /*New point 2*/ 1072 xyz_bis[2][0]=*(xyz_list+3*1+0)+s2*(*(xyz_list+3*2+0)-*(xyz_list+3*1+0)); 1073 xyz_bis[2][1]=*(xyz_list+3*1+1)+s2*(*(xyz_list+3*2+1)-*(xyz_list+3*1+1)); 1074 xyz_bis[2][2]=*(xyz_list+3*1+2)+s2*(*(xyz_list+3*2+2)-*(xyz_list+3*1+2)); 1075 } 1076 1077 /*Compute fraction of grounded element*/ 1078 GetTriaJacobianDeterminant(&area_init, xyz_list,NULL); 1079 GetTriaJacobianDeterminant(&area_grounded, &xyz_bis[0][0],NULL); 1080 if(mainlyfloating==true) area_grounded=area_init-area_grounded; 1081 phi=area_grounded/area_init; 1082 } 1083 1084 if(phi>1. || phi<0.) _error_("Error. Problem with portion of grounded element: value should be between 0 and 1"); 1085 1086 return phi; 1087 } 1088 /*}}}*/ 1089 void Penta::GetIcefrontCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum){/*{{{*/ 1090 1091 /* Intermediaries */ 1092 const int dim=3; 1093 int i, dir,nrfrontnodes; 1094 IssmDouble levelset[NUMVERTICES]; 1095 1096 /*Recover parameters and values*/ 1097 GetInputListOnVertices(&levelset[0],levelsetenum); 1098 1099 int* indicesfront = xNew<int>(NUMVERTICES); 1100 /* Get basal nodes where there is no ice */ 1101 nrfrontnodes=0; 1102 for(i=0;i<NUMVERTICES2D;i++){ 1103 if(levelset[i]>=0.){ 1104 indicesfront[nrfrontnodes]=i; 1105 nrfrontnodes++; 1106 } 1107 } 1108 _assert_(nrfrontnodes==2); 1109 1110 /* arrange order of basal frontnodes such that they are oriented counterclockwise */ 1111 if((NUMVERTICES2D+indicesfront[0]-indicesfront[1])%NUMVERTICES2D!=NUMVERTICES2D-1){ 1112 int index=indicesfront[0]; 1113 indicesfront[0]=indicesfront[1]; 1114 indicesfront[1]=index; 1115 } 1116 1117 IssmDouble* xyz_front = xNew<IssmDouble>(2*dim*nrfrontnodes); 1118 /* Return basal and top front nodes */ 1119 for(i=0;i<nrfrontnodes;i++){ 1120 for(dir=0;dir<dim;dir++){ 1121 int ind1=i*dim+dir, ind2=(2*nrfrontnodes-1-i)*dim+dir; // vertex structure front segment: base0, base1, top1, top0 1122 xyz_front[ind1]=xyz_list[dim*indicesfront[i]+dir]; 1123 xyz_front[ind2]=xyz_list[dim*(indicesfront[i]+NUMVERTICES2D)+dir]; 1124 } 1125 } 1126 1127 *pxyz_front=xyz_front; 1128 1129 xDelete<int>(indicesfront); 1130 }/*}}}*/ 1131 void Penta::GetInputValue(IssmDouble* pvalue,Node* node,int enumtype){/*{{{*/ 1132 1133 Input* input=inputs->GetInput(enumtype); 1134 if(!input) _error_("No input of type " << EnumToStringx(enumtype) << " found in tria"); 1135 1136 GaussPenta* gauss=new GaussPenta(); 1137 gauss->GaussVertex(this->GetNodeIndex(node)); 1138 1139 input->GetInputValue(pvalue,gauss); 1140 delete gauss; 589 1141 } 590 1142 /*}}}*/ … … 596 1148 597 1149 return lower_penta; 1150 } 1151 /*}}}*/ 1152 Node* Penta::GetNode(int node_number){/*{{{*/ 1153 _assert_(node_number>=0); 1154 _assert_(node_number<this->NumberofNodes(this->element_type)); 1155 return this->nodes[node_number]; 1156 } 1157 /*}}}*/ 1158 int Penta::GetNodeIndex(Node* node){/*{{{*/ 1159 1160 _assert_(nodes); 1161 int numnodes = this->NumberofNodes(this->element_type); 1162 1163 for(int i=0;i<numnodes;i++){ 1164 if(node==nodes[i]) return i; 1165 } 1166 _error_("Node provided not found among element nodes"); 1167 1168 } 1169 /*}}}*/ 1170 int Penta::GetNumberOfNodes(void){/*{{{*/ 1171 return this->NumberofNodes(this->element_type); 1172 } 1173 /*}}}*/ 1174 int Penta::GetNumberOfNodes(int enum_type){/*{{{*/ 1175 return this->NumberofNodes(enum_type); 1176 } 1177 /*}}}*/ 1178 int Penta::GetNumberOfVertices(void){/*{{{*/ 1179 return NUMVERTICES; 1180 } 1181 /*}}}*/ 1182 void Penta::GetSolutionFromInputsOneDof(Vector<IssmDouble>* solution, int enum_type){/*{{{*/ 1183 1184 const int numdof=NDOF1*NUMVERTICES; 1185 1186 int i; 1187 int* doflist=NULL; 1188 IssmDouble values[numdof]; 1189 IssmDouble enum_value; 1190 GaussPenta *gauss=NULL; 1191 1192 /*Get dof list: */ 1193 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 1194 Input* enum_input=inputs->GetInput(enum_type); _assert_(enum_input); 1195 1196 gauss=new GaussPenta(); 1197 for(i=0;i<NUMVERTICES;i++){ 1198 /*Recover temperature*/ 1199 gauss->GaussVertex(i); 1200 enum_input->GetInputValue(&enum_value,gauss); 1201 values[i]=enum_value; 1202 } 1203 1204 /*Add value to global vector*/ 1205 solution->SetValues(numdof,doflist,values,INS_VAL); 1206 1207 /*Free ressources:*/ 1208 delete gauss; 1209 xDelete<int>(doflist); 598 1210 } 599 1211 /*}}}*/ … … 618 1230 } 619 1231 /*}}}*/ 620 Penta* Penta::GetBasalPenta(void){/*{{{*/621 622 /*Output*/623 Penta* penta=NULL;624 625 /*Go through all pentas till the bed is reached*/626 penta=this;627 for(;;){628 /*Stop if we have reached the surface, else, take lower penta*/629 if (penta->IsOnBase()) break;630 631 /* get lower Penta*/632 penta=penta->GetLowerPenta();633 _assert_(penta->Id()!=this->id);634 }635 636 /*return output*/637 return penta;638 }639 /*}}}*/640 1232 Element* Penta::GetUpperElement(void){/*{{{*/ 641 1233 … … 645 1237 } 646 1238 /*}}}*/ 647 Element* Penta::GetBasalElement(void){/*{{{*/ 648 649 /*Output*/ 650 Element* element=this->GetBasalPenta(); 651 return element; 652 } 653 /*}}}*/ 654 void Penta::GetGroundedPart(int* point1,IssmDouble* fraction1,IssmDouble* fraction2, bool* mainlyfloating){/*{{{*/ 655 /*Computeportion of the element that is grounded*/ 656 657 bool floating=true; 658 int point; 659 const IssmPDouble epsilon= 1.e-15; 660 IssmDouble gl[NUMVERTICES]; 661 IssmDouble f1,f2; 662 663 /*Recover parameters and values*/ 664 GetInputListOnVertices(&gl[0],MaskGroundediceLevelsetEnum); 665 666 /*Be sure that values are not zero*/ 667 if(gl[0]==0.) gl[0]=gl[0]+epsilon; 668 if(gl[1]==0.) gl[1]=gl[1]+epsilon; 669 if(gl[2]==0.) gl[2]=gl[2]+epsilon; 670 671 /*Check that not all nodes are grounded or floating*/ 672 if(gl[0]>0 && gl[1]>0 && gl[2]>0){ // All grounded 673 point=0; 674 f1=1.; 675 f2=1.; 676 } 677 else if(gl[0]<0 && gl[1]<0 && gl[2]<0){ //All floating 678 point=0; 679 f1=0.; 680 f2=0.; 681 } 682 else{ 683 if(gl[0]*gl[1]*gl[2]<0) floating=false; 684 685 if(gl[0]*gl[1]>0){ //Nodes 0 and 1 are similar, so points must be found on segment 0-2 and 1-2 686 point=2; 687 f1=gl[2]/(gl[2]-gl[0]); 688 f2=gl[2]/(gl[2]-gl[1]); 689 } 690 else if(gl[1]*gl[2]>0){ //Nodes 1 and 2 are similar, so points must be found on segment 0-1 and 0-2 691 point=0; 692 f1=gl[0]/(gl[0]-gl[1]); 693 f2=gl[0]/(gl[0]-gl[2]); 694 } 695 else if(gl[0]*gl[2]>0){ //Nodes 0 and 2 are similar, so points must be found on segment 1-0 and 1-2 696 point=1; 697 f1=gl[1]/(gl[1]-gl[2]); 698 f2=gl[1]/(gl[1]-gl[0]); 699 } 700 } 701 *point1=point; 702 *fraction1=f1; 703 *fraction2=f2; 704 *mainlyfloating=floating; 705 } 706 /*}}}*/ 707 IssmDouble Penta::GetGroundedPortion(IssmDouble* xyz_list){/*{{{*/ 708 /*Computeportion of the element that is grounded*/ 709 710 bool mainlyfloating = true; 711 const IssmPDouble epsilon= 1.e-15; 712 IssmDouble phi,s1,s2,area_init,area_grounded; 713 IssmDouble gl[NUMVERTICES]; 714 IssmDouble xyz_bis[NUMVERTICES2D][3]; 715 716 /*Recover parameters and values*/ 717 GetInputListOnVertices(&gl[0],MaskGroundediceLevelsetEnum); 718 719 /*Be sure that values are not zero*/ 720 if(gl[0]==0.) gl[0]=gl[0]+epsilon; 721 if(gl[1]==0.) gl[1]=gl[1]+epsilon; 722 if(gl[2]==0.) gl[2]=gl[2]+epsilon; 723 724 /*Check that not all nodes are grounded or floating*/ 725 if(gl[0]>0 && gl[1]>0 && gl[2]>0){ // All grounded 726 phi=1; 727 } 728 else if(gl[0]<0 && gl[1]<0 && gl[2]<0){ //All floating 729 phi=0; 730 } 731 else{ 732 /*Figure out if two nodes are floating or grounded*/ 733 if(gl[0]*gl[1]*gl[2]>0) mainlyfloating=false; 734 735 if(gl[0]*gl[1]>0){ //Nodes 0 and 1 are similar, so points must be found on segment 0-2 and 1-2 736 /*Coordinates of point 2: same as initial point 2*/ 737 xyz_bis[2][0]=xyz_list[3*2+0]; 738 xyz_bis[2][1]=xyz_list[3*2+1]; 739 xyz_bis[2][2]=xyz_list[3*2+2]; 740 741 /*Portion of the segments*/ 742 s1=gl[2]/(gl[2]-gl[1]); 743 s2=gl[2]/(gl[2]-gl[0]); 744 745 /*New point 1*/ 746 xyz_bis[1][0]=xyz_list[3*2+0]+s1*(xyz_list[3*1+0]-xyz_list[3*2+0]); 747 xyz_bis[1][1]=xyz_list[3*2+1]+s1*(xyz_list[3*1+1]-xyz_list[3*2+1]); 748 xyz_bis[1][2]=xyz_list[3*2+2]+s1*(xyz_list[3*1+2]-xyz_list[3*2+2]); 749 750 /*New point 0*/ 751 xyz_bis[0][0]=xyz_list[3*2+0]+s2*(xyz_list[3*0+0]-xyz_list[3*2+0]); 752 xyz_bis[0][1]=xyz_list[3*2+1]+s2*(xyz_list[3*0+1]-xyz_list[3*2+1]); 753 xyz_bis[0][2]=xyz_list[3*2+2]+s2*(xyz_list[3*0+2]-xyz_list[3*2+2]); 754 } 755 else if(gl[1]*gl[2]>0){ //Nodes 1 and 2 are similar, so points must be found on segment 0-1 and 0-2 756 /*Coordinates of point 0: same as initial point 2*/ 757 xyz_bis[0][0]=*(xyz_list+3*0+0); 758 xyz_bis[0][1]=*(xyz_list+3*0+1); 759 xyz_bis[0][2]=*(xyz_list+3*0+2); 760 761 /*Portion of the segments*/ 762 s1=gl[0]/(gl[0]-gl[1]); 763 s2=gl[0]/(gl[0]-gl[2]); 764 765 /*New point 1*/ 766 xyz_bis[1][0]=*(xyz_list+3*0+0)+s1*(*(xyz_list+3*1+0)-*(xyz_list+3*0+0)); 767 xyz_bis[1][1]=*(xyz_list+3*0+1)+s1*(*(xyz_list+3*1+1)-*(xyz_list+3*0+1)); 768 xyz_bis[1][2]=*(xyz_list+3*0+2)+s1*(*(xyz_list+3*1+2)-*(xyz_list+3*0+2)); 769 770 /*New point 2*/ 771 xyz_bis[2][0]=*(xyz_list+3*0+0)+s2*(*(xyz_list+3*2+0)-*(xyz_list+3*0+0)); 772 xyz_bis[2][1]=*(xyz_list+3*0+1)+s2*(*(xyz_list+3*2+1)-*(xyz_list+3*0+1)); 773 xyz_bis[2][2]=*(xyz_list+3*0+2)+s2*(*(xyz_list+3*2+2)-*(xyz_list+3*0+2)); 774 } 775 else if(gl[0]*gl[2]>0){ //Nodes 0 and 2 are similar, so points must be found on segment 1-0 and 1-2 776 /*Coordinates of point 1: same as initial point 2*/ 777 xyz_bis[1][0]=*(xyz_list+3*1+0); 778 xyz_bis[1][1]=*(xyz_list+3*1+1); 779 xyz_bis[1][2]=*(xyz_list+3*1+2); 780 781 /*Portion of the segments*/ 782 s1=gl[1]/(gl[1]-gl[0]); 783 s2=gl[1]/(gl[1]-gl[2]); 784 785 /*New point 0*/ 786 xyz_bis[0][0]=*(xyz_list+3*1+0)+s1*(*(xyz_list+3*0+0)-*(xyz_list+3*1+0)); 787 xyz_bis[0][1]=*(xyz_list+3*1+1)+s1*(*(xyz_list+3*0+1)-*(xyz_list+3*1+1)); 788 xyz_bis[0][2]=*(xyz_list+3*1+2)+s1*(*(xyz_list+3*0+2)-*(xyz_list+3*1+2)); 789 790 /*New point 2*/ 791 xyz_bis[2][0]=*(xyz_list+3*1+0)+s2*(*(xyz_list+3*2+0)-*(xyz_list+3*1+0)); 792 xyz_bis[2][1]=*(xyz_list+3*1+1)+s2*(*(xyz_list+3*2+1)-*(xyz_list+3*1+1)); 793 xyz_bis[2][2]=*(xyz_list+3*1+2)+s2*(*(xyz_list+3*2+2)-*(xyz_list+3*1+2)); 794 } 795 796 /*Compute fraction of grounded element*/ 797 GetTriaJacobianDeterminant(&area_init, xyz_list,NULL); 798 GetTriaJacobianDeterminant(&area_grounded, &xyz_bis[0][0],NULL); 799 if(mainlyfloating==true) area_grounded=area_init-area_grounded; 800 phi=area_grounded/area_init; 801 } 802 803 if(phi>1. || phi<0.) _error_("Error. Problem with portion of grounded element: value should be between 0 and 1"); 804 805 return phi; 806 } 807 /*}}}*/ 808 int Penta::GetElementType(){/*{{{*/ 809 810 /*return PentaRef field*/ 811 return this->element_type; 812 } 813 /*}}}*/ 814 void Penta::ElementSizes(IssmDouble* hx,IssmDouble* hy,IssmDouble* hz){/*{{{*/ 815 816 IssmDouble xyz_list[NUMVERTICES][3]; 817 IssmDouble xmin,ymin,zmin; 818 IssmDouble xmax,ymax,zmax; 819 820 /*Get xyz list: */ 821 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 822 xmin=xyz_list[0][0]; xmax=xyz_list[0][0]; 823 ymin=xyz_list[0][1]; ymax=xyz_list[0][1]; 824 zmin=xyz_list[0][2]; zmax=xyz_list[0][2]; 825 826 for(int i=1;i<NUMVERTICES;i++){ 827 if(xyz_list[i][0]<xmin) xmin=xyz_list[i][0]; 828 if(xyz_list[i][0]>xmax) xmax=xyz_list[i][0]; 829 if(xyz_list[i][1]<ymin) ymin=xyz_list[i][1]; 830 if(xyz_list[i][1]>ymax) ymax=xyz_list[i][1]; 831 if(xyz_list[i][2]<zmin) zmin=xyz_list[i][2]; 832 if(xyz_list[i][2]>zmax) zmax=xyz_list[i][2]; 833 } 834 835 *hx=xmax-xmin; 836 *hy=ymax-ymin; 837 *hz=zmax-zmin; 838 } 839 /*}}}*/ 840 int Penta::GetNodeIndex(Node* node){/*{{{*/ 841 842 _assert_(nodes); 843 int numnodes = this->NumberofNodes(this->element_type); 844 845 for(int i=0;i<numnodes;i++){ 846 if(node==nodes[i]) return i; 847 } 848 _error_("Node provided not found among element nodes"); 849 850 } 851 /*}}}*/ 852 int Penta::GetNumberOfNodes(void){/*{{{*/ 853 return this->NumberofNodes(this->element_type); 854 } 855 /*}}}*/ 856 int Penta::GetNumberOfNodes(int enum_type){/*{{{*/ 857 return this->NumberofNodes(enum_type); 858 } 859 /*}}}*/ 860 int Penta::GetNumberOfVertices(void){/*{{{*/ 861 return NUMVERTICES; 862 } 863 /*}}}*/ 864 Node* Penta::GetNode(int node_number){/*{{{*/ 865 _assert_(node_number>=0); 866 _assert_(node_number<this->NumberofNodes(this->element_type)); 867 return this->nodes[node_number]; 868 } 869 /*}}}*/ 870 void Penta::GetInputValue(IssmDouble* pvalue,Node* node,int enumtype){/*{{{*/ 871 872 Input* input=inputs->GetInput(enumtype); 873 if(!input) _error_("No input of type " << EnumToStringx(enumtype) << " found in tria"); 874 875 GaussPenta* gauss=new GaussPenta(); 876 gauss->GaussVertex(this->GetNodeIndex(node)); 877 878 input->GetInputValue(pvalue,gauss); 879 delete gauss; 1239 Penta* Penta::GetUpperPenta(void){/*{{{*/ 1240 1241 Penta* upper_penta=NULL; 1242 1243 upper_penta=(Penta*)verticalneighbors[1]; //first one (0) under, second one (1) above 1244 1245 return upper_penta; 1246 } 1247 /*}}}*/ 1248 void Penta::GetVectorFromControlInputs(Vector<IssmDouble>* vector,int control_enum,int control_index,const char* data,bool onsid){/*{{{*/ 1249 1250 int vertexidlist[NUMVERTICES]; 1251 1252 /*Get out if this is not an element input*/ 1253 if(!IsInput(control_enum)) return; 1254 1255 /*Prepare index list*/ 1256 GradientIndexing(&vertexidlist[0],control_index,onsid); 1257 1258 /*Get input (either in element or material)*/ 1259 if(control_enum==MaterialsRheologyBbarEnum) control_enum=MaterialsRheologyBEnum; 1260 Input* input=inputs->GetInput(control_enum); 1261 if(!input) _error_("Input " << EnumToStringx(control_enum) << " not found in element"); 1262 1263 /*Check that it is a ControlInput*/ 1264 if (input->ObjectEnum()!=ControlInputEnum){ 1265 _error_("input " << EnumToStringx(control_enum) << " is not a ControlInput"); 1266 } 1267 1268 ((ControlInput*)input)->GetVectorFromInputs(vector,&vertexidlist[0],data); 880 1269 } 881 1270 /*}}}*/ … … 898 1287 899 1288 }/*}}}*/ 900 void Penta::NormalSection(IssmDouble* normal,IssmDouble* xyz_list){/*{{{*/ 901 902 /*Build unit outward pointing vector*/ 903 IssmDouble AB[3]; 904 IssmDouble AC[3]; 905 IssmDouble norm; 906 907 AB[0]=xyz_list[1*3+0] - xyz_list[0*3+0]; 908 AB[1]=xyz_list[1*3+1] - xyz_list[0*3+1]; 909 AB[2]=xyz_list[1*3+2] - xyz_list[0*3+2]; 910 AC[0]=xyz_list[2*3+0] - xyz_list[0*3+0]; 911 AC[1]=xyz_list[2*3+1] - xyz_list[0*3+1]; 912 AC[2]=xyz_list[2*3+2] - xyz_list[0*3+2]; 913 914 cross(normal,AB,AC); 915 norm=sqrt(normal[0]*normal[0]+normal[1]*normal[1]+normal[2]*normal[2]); 916 917 for(int i=0;i<3;i++) normal[i]=normal[i]/norm; 918 } 919 /*}}}*/ 920 IssmDouble Penta::StabilizationParameter(IssmDouble u, IssmDouble v, IssmDouble w, IssmDouble diameter, IssmDouble kappa){/*{{{*/ 921 /*Compute stabilization parameter*/ 922 /*kappa=thermalconductivity/(rho_ice*hearcapacity) for thermal model*/ 923 /*kappa=enthalpydiffusionparameter for enthalpy model*/ 924 925 IssmDouble normu; 926 IssmDouble tau_parameter; 927 928 normu=pow(pow(u,2)+pow(v,2)+pow(w,2),0.5); 929 if(normu*diameter/(3*2*kappa)<1){ 930 tau_parameter=pow(diameter,2)/(3*2*2*kappa); 931 } 932 else tau_parameter=diameter/(2*normu); 933 934 return tau_parameter; 935 } 936 /*}}}*/ 937 void Penta::ZeroLevelsetCoordinates(IssmDouble** pxyz_zero,IssmDouble* xyz_list,int levelsetenum){/*{{{*/ 938 /*Compute portion of the element that is grounded*/ 939 940 int normal_orientation=0; 941 IssmDouble s1,s2; 942 IssmDouble levelset[NUMVERTICES]; 943 IssmDouble* xyz_zero = xNew<IssmDouble>(4*3); 944 945 /*Recover parameters and values*/ 946 GetInputListOnVertices(&levelset[0],levelsetenum); 947 948 if(levelset[0]*levelset[1]>0.){ //Nodes 0 and 1 are similar, so points must be found on segment 0-2 and 1-2 949 /*Portion of the segments*/ 950 s1=levelset[2]/(levelset[2]-levelset[1]); 951 s2=levelset[2]/(levelset[2]-levelset[0]); 952 953 if(levelset[2]<0.) normal_orientation=1; //orientation of quadrangle at base and top, depending on distribution of levelsetfunction 954 /*New point 1*/ 955 xyz_zero[3*normal_orientation+0]=xyz_list[2*3+0]+s1*(xyz_list[1*3+0]-xyz_list[2*3+0]); 956 xyz_zero[3*normal_orientation+1]=xyz_list[2*3+1]+s1*(xyz_list[1*3+1]-xyz_list[2*3+1]); 957 xyz_zero[3*normal_orientation+2]=xyz_list[2*3+2]+s1*(xyz_list[1*3+2]-xyz_list[2*3+2]); 958 959 /*New point 0*/ 960 xyz_zero[3*(1-normal_orientation)+0]=xyz_list[2*3+0]+s2*(xyz_list[0*3+0]-xyz_list[2*3+0]); 961 xyz_zero[3*(1-normal_orientation)+1]=xyz_list[2*3+1]+s2*(xyz_list[0*3+1]-xyz_list[2*3+1]); 962 xyz_zero[3*(1-normal_orientation)+2]=xyz_list[2*3+2]+s2*(xyz_list[0*3+2]-xyz_list[2*3+2]); 963 964 /*New point 3*/ 965 xyz_zero[3*(2+1-normal_orientation)+0]=xyz_list[5*3+0]+s1*(xyz_list[4*3+0]-xyz_list[5*3+0]); 966 xyz_zero[3*(2+1-normal_orientation)+1]=xyz_list[5*3+1]+s1*(xyz_list[4*3+1]-xyz_list[5*3+1]); 967 xyz_zero[3*(2+1-normal_orientation)+2]=xyz_list[5*3+2]+s1*(xyz_list[4*3+2]-xyz_list[5*3+2]); 968 969 /*New point 4*/ 970 xyz_zero[3*(2+normal_orientation)+0]=xyz_list[5*3+0]+s2*(xyz_list[3*3+0]-xyz_list[5*3+0]); 971 xyz_zero[3*(2+normal_orientation)+1]=xyz_list[5*3+1]+s2*(xyz_list[3*3+1]-xyz_list[5*3+1]); 972 xyz_zero[3*(2+normal_orientation)+2]=xyz_list[5*3+2]+s2*(xyz_list[3*3+2]-xyz_list[5*3+2]); 973 } 974 else if(levelset[1]*levelset[2]>0.){ //Nodes 1 and 2 are similar, so points must be found on segment 0-1 and 0-2 975 /*Portion of the segments*/ 976 s1=levelset[0]/(levelset[0]-levelset[2]); 977 s2=levelset[0]/(levelset[0]-levelset[1]); 978 979 if(levelset[0]<0.) normal_orientation=1; 980 /*New point 1*/ 981 xyz_zero[3*normal_orientation+0]=xyz_list[0*3+0]+s1*(xyz_list[2*3+0]-xyz_list[0*3+0]); 982 xyz_zero[3*normal_orientation+1]=xyz_list[0*3+1]+s1*(xyz_list[2*3+1]-xyz_list[0*3+1]); 983 xyz_zero[3*normal_orientation+2]=xyz_list[0*3+2]+s1*(xyz_list[2*3+2]-xyz_list[0*3+2]); 984 985 /*New point 2*/ 986 xyz_zero[3*(1-normal_orientation)+0]=xyz_list[0*3+0]+s2*(xyz_list[1*3+0]-xyz_list[0*3+0]); 987 xyz_zero[3*(1-normal_orientation)+1]=xyz_list[0*3+1]+s2*(xyz_list[1*3+1]-xyz_list[0*3+1]); 988 xyz_zero[3*(1-normal_orientation)+2]=xyz_list[0*3+2]+s2*(xyz_list[1*3+2]-xyz_list[0*3+2]); 989 990 /*New point 3*/ 991 xyz_zero[3*(2+1-normal_orientation)+0]=xyz_list[3*3+0]+s1*(xyz_list[5*3+0]-xyz_list[3*3+0]); 992 xyz_zero[3*(2+1-normal_orientation)+1]=xyz_list[3*3+1]+s1*(xyz_list[5*3+1]-xyz_list[3*3+1]); 993 xyz_zero[3*(2+1-normal_orientation)+2]=xyz_list[3*3+2]+s1*(xyz_list[5*3+2]-xyz_list[3*3+2]); 994 995 /*New point 4*/ 996 xyz_zero[3*(2+normal_orientation)+0]=xyz_list[3*3+0]+s2*(xyz_list[4*3+0]-xyz_list[3*3+0]); 997 xyz_zero[3*(2+normal_orientation)+1]=xyz_list[3*3+1]+s2*(xyz_list[4*3+1]-xyz_list[3*3+1]); 998 xyz_zero[3*(2+normal_orientation)+2]=xyz_list[3*3+2]+s2*(xyz_list[4*3+2]-xyz_list[3*3+2]); 999 } 1000 else if(levelset[0]*levelset[2]>0.){ //Nodes 0 and 2 are similar, so points must be found on segment 1-0 and 1-2 1001 /*Portion of the segments*/ 1002 s1=levelset[1]/(levelset[1]-levelset[0]); 1003 s2=levelset[1]/(levelset[1]-levelset[2]); 1004 1005 if(levelset[1]<0.) normal_orientation=1; 1006 /*New point 0*/ 1007 xyz_zero[3*normal_orientation+0]=xyz_list[1*3+0]+s1*(xyz_list[0*3+0]-xyz_list[1*3+0]); 1008 xyz_zero[3*normal_orientation+1]=xyz_list[1*3+1]+s1*(xyz_list[0*3+1]-xyz_list[1*3+1]); 1009 xyz_zero[3*normal_orientation+2]=xyz_list[1*3+2]+s1*(xyz_list[0*3+2]-xyz_list[1*3+2]); 1010 1011 /*New point 2*/ 1012 xyz_zero[3*(1-normal_orientation)+0]=xyz_list[1*3+0]+s2*(xyz_list[2*3+0]-xyz_list[1*3+0]); 1013 xyz_zero[3*(1-normal_orientation)+1]=xyz_list[1*3+1]+s2*(xyz_list[2*3+1]-xyz_list[1*3+1]); 1014 xyz_zero[3*(1-normal_orientation)+2]=xyz_list[1*3+2]+s2*(xyz_list[2*3+2]-xyz_list[1*3+2]); 1015 1016 /*New point 3*/ 1017 xyz_zero[3*(2+1-normal_orientation)+0]=xyz_list[4*3+0]+s1*(xyz_list[3*3+0]-xyz_list[4*3+0]); 1018 xyz_zero[3*(2+1-normal_orientation)+1]=xyz_list[4*3+1]+s1*(xyz_list[3*3+1]-xyz_list[4*3+1]); 1019 xyz_zero[3*(2+1-normal_orientation)+2]=xyz_list[4*3+2]+s1*(xyz_list[3*3+2]-xyz_list[4*3+2]); 1020 1021 /*New point 4*/ 1022 xyz_zero[3*(2+normal_orientation)+0]=xyz_list[4*3+0]+s2*(xyz_list[5*3+0]-xyz_list[4*3+0]); 1023 xyz_zero[3*(2+normal_orientation)+1]=xyz_list[4*3+1]+s2*(xyz_list[5*3+1]-xyz_list[4*3+1]); 1024 xyz_zero[3*(2+normal_orientation)+2]=xyz_list[4*3+2]+s2*(xyz_list[5*3+2]-xyz_list[4*3+2]); 1025 } 1026 else if(levelset[0]==0. && levelset[1]==0.){ //front is on point 0 and 1 1027 xyz_zero[3*0+0]=xyz_list[0*3+0]; 1028 xyz_zero[3*0+1]=xyz_list[0*3+1]; 1029 xyz_zero[3*0+2]=xyz_list[0*3+2]; 1030 1031 /*New point 2*/ 1032 xyz_zero[3*1+0]=xyz_list[1*3+0]; 1033 xyz_zero[3*1+1]=xyz_list[1*3+1]; 1034 xyz_zero[3*1+2]=xyz_list[1*3+2]; 1035 1036 /*New point 3*/ 1037 xyz_zero[3*2+0]=xyz_list[4*3+0]; 1038 xyz_zero[3*2+1]=xyz_list[4*3+1]; 1039 xyz_zero[3*2+2]=xyz_list[4*3+2]; 1040 1041 /*New point 4*/ 1042 xyz_zero[3*3+0]=xyz_list[3*3+0]; 1043 xyz_zero[3*3+1]=xyz_list[3*3+1]; 1044 xyz_zero[3*3+2]=xyz_list[3*3+2]; 1045 } 1046 else if(levelset[0]==0. && levelset[2]==0.){ //front is on point 0 and 1 1047 xyz_zero[3*0+0]=xyz_list[2*3+0]; 1048 xyz_zero[3*0+1]=xyz_list[2*3+1]; 1049 xyz_zero[3*0+2]=xyz_list[2*3+2]; 1050 1051 /*New point 2*/ 1052 xyz_zero[3*1+0]=xyz_list[0*3+0]; 1053 xyz_zero[3*1+1]=xyz_list[0*3+1]; 1054 xyz_zero[3*1+2]=xyz_list[0*3+2]; 1055 1056 /*New point 3*/ 1057 xyz_zero[3*2+0]=xyz_list[3*3+0]; 1058 xyz_zero[3*2+1]=xyz_list[3*3+1]; 1059 xyz_zero[3*2+2]=xyz_list[3*3+2]; 1060 1061 /*New point 4*/ 1062 xyz_zero[3*3+0]=xyz_list[5*3+0]; 1063 xyz_zero[3*3+1]=xyz_list[5*3+1]; 1064 xyz_zero[3*3+2]=xyz_list[5*3+2]; 1065 } 1066 else if(levelset[1]==0. && levelset[2]==0.){ //front is on point 0 and 1 1067 xyz_zero[3*0+0]=xyz_list[1*3+0]; 1068 xyz_zero[3*0+1]=xyz_list[1*3+1]; 1069 xyz_zero[3*0+2]=xyz_list[1*3+2]; 1070 1071 /*New point 2*/ 1072 xyz_zero[3*1+0]=xyz_list[2*3+0]; 1073 xyz_zero[3*1+1]=xyz_list[2*3+1]; 1074 xyz_zero[3*1+2]=xyz_list[2*3+2]; 1075 1076 /*New point 3*/ 1077 xyz_zero[3*2+0]=xyz_list[5*3+0]; 1078 xyz_zero[3*2+1]=xyz_list[5*3+1]; 1079 xyz_zero[3*2+2]=xyz_list[5*3+2]; 1080 1081 /*New point 4*/ 1082 xyz_zero[3*3+0]=xyz_list[4*3+0]; 1083 xyz_zero[3*3+1]=xyz_list[4*3+1]; 1084 xyz_zero[3*3+2]=xyz_list[4*3+2]; 1085 } 1086 else _error_("Case not covered"); 1087 1088 /*Assign output pointer*/ 1089 *pxyz_zero= xyz_zero; 1289 IssmDouble Penta::IceMass(void){/*{{{*/ 1290 1291 IssmDouble rho_ice; 1292 1293 if(!IsIceInElement())return 0.; //do not contribute to the volume of the ice! 1294 1295 /*recover ice density: */ 1296 rho_ice=matpar->GetMaterialParameter(MaterialsRhoIceEnum); 1297 1298 return rho_ice*this->IceVolume(); 1299 } 1300 /*}}}*/ 1301 IssmDouble Penta::IceVolume(void){/*{{{*/ 1302 1303 /*The volume of a troncated prism is base * 1/3 sum(length of edges)*/ 1304 IssmDouble base,height; 1305 IssmDouble xyz_list[NUMVERTICES][3]; 1306 1307 if(!IsIceInElement())return 0; 1308 1309 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 1310 1311 /*First calculate the area of the base (cross section triangle) 1312 * http://en.wikipedia.org/wiki/Pentangle 1313 * base = 1/2 abs((xA-xC)(yB-yA)-(xA-xB)(yC-yA))*/ 1314 base = 1./2.*fabs((xyz_list[0][0]-xyz_list[2][0])*(xyz_list[1][1]-xyz_list[0][1]) - (xyz_list[0][0]-xyz_list[1][0])*(xyz_list[2][1]-xyz_list[0][1])); 1315 1316 /*Now get the average height*/ 1317 height = 1./3.*((xyz_list[3][2]-xyz_list[0][2])+(xyz_list[4][2]-xyz_list[1][2])+(xyz_list[5][2]-xyz_list[2][2])); 1318 1319 /*Return: */ 1320 return base*height; 1321 } 1322 /*}}}*/ 1323 IssmDouble Penta::IceVolumeAboveFloatation(void){/*{{{*/ 1324 1325 /*Volume above floatation: H + rho_water/rho_ice*bathymetry for nodes on the bed*/ 1326 IssmDouble rho_ice,rho_water; 1327 IssmDouble base,bed,surface,bathymetry; 1328 IssmDouble xyz_list[NUMVERTICES][3]; 1329 1330 if(!IsIceInElement() || IsFloating() || !IsOnBase())return 0; 1331 1332 rho_ice=matpar->GetMaterialParameter(MaterialsRhoIceEnum); 1333 rho_water=matpar->GetMaterialParameter(MaterialsRhoSeawaterEnum); 1334 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 1335 1336 /*First calculate the area of the base (cross section triangle) 1337 * http://en.wikipedia.org/wiki/Pentangle 1338 * base = 1/2 abs((xA-xC)(yB-yA)-(xA-xB)(yC-yA))*/ 1339 base = 1./2.*fabs((xyz_list[0][0]-xyz_list[2][0])*(xyz_list[1][1]-xyz_list[0][1]) - (xyz_list[0][0]-xyz_list[1][0])*(xyz_list[2][1]-xyz_list[0][1])); 1340 1341 /*Now get the average height above floatation*/ 1342 Input* surface_input = inputs->GetInput(SurfaceEnum); _assert_(surface_input); 1343 Input* base_input = inputs->GetInput(BaseEnum); _assert_(base_input); 1344 Input* bed_input = inputs->GetInput(BedEnum); _assert_(bed_input); 1345 surface_input->GetInputAverage(&surface); 1346 base_input->GetInputAverage(&bed); 1347 bed_input->GetInputAverage(&bathymetry); 1348 1349 /*Return: */ 1350 return base*(surface - bed + min( rho_water/rho_ice * bathymetry, 0.) ); 1351 } 1352 /*}}}*/ 1353 void Penta::InputControlUpdate(IssmDouble scalar,bool save_parameter){/*{{{*/ 1354 1355 /*Intermediary*/ 1356 int num_controls; 1357 int* control_type=NULL; 1358 Input* input=NULL; 1359 1360 /*retrieve some parameters: */ 1361 this->parameters->FindParam(&num_controls,InversionNumControlParametersEnum); 1362 this->parameters->FindParam(&control_type,NULL,InversionControlParametersEnum); 1363 1364 for(int i=0;i<num_controls;i++){ 1365 1366 if(control_type[i]==MaterialsRheologyBbarEnum){ 1367 if (!IsOnBase()) goto cleanup_and_return; 1368 input=(Input*)this->inputs->GetInput(MaterialsRheologyBEnum); _assert_(input); 1369 } 1370 else if(control_type[i]==DamageDbarEnum){ 1371 if (!IsOnBase()) goto cleanup_and_return; 1372 input=(Input*)this->inputs->GetInput(DamageDEnum); _assert_(input); 1373 } 1374 else{ 1375 input=(Input*)this->inputs->GetInput(control_type[i]); _assert_(input); 1376 } 1377 if(input->ObjectEnum()!=ControlInputEnum) _error_("input " << EnumToStringx(control_type[i]) << " is not a ControlInput"); 1378 1379 ((ControlInput*)input)->UpdateValue(scalar); 1380 ((ControlInput*)input)->Constrain(); 1381 if (save_parameter) ((ControlInput*)input)->SaveValue(); 1382 1383 if(control_type[i]==MaterialsRheologyBbarEnum){ 1384 this->InputExtrude(MaterialsRheologyBEnum,-1); 1385 } 1386 else if(control_type[i]==DamageDbarEnum){ 1387 this->InputExtrude(DamageDEnum,-1); 1388 } 1389 } 1390 1391 /*Clean up and return*/ 1392 cleanup_and_return: 1393 xDelete<int>(control_type); 1090 1394 } 1091 1395 /*}}}*/ … … 1191 1495 } 1192 1496 /*}}}*/ 1193 void Penta::InputExtrude(int enum_type){/*{{{*/ 1194 1195 /*Are we on the base, not on the surface?:*/ 1196 if(!IsOnBase()) return; 1497 void Penta::InputExtrude(int enum_type,int start){/*{{{*/ 1498 1499 _assert_(start==-1 || start==+1); 1500 1501 /*Are we on the the boundary we want to be?*/ 1502 if(start==-1 && !IsOnBase()) return; 1503 if(start==+1 && !IsOnSurface()) return; 1197 1504 1198 1505 /*Step1: Get and Extrude original input: */ 1199 1506 Input* base_input=(Input*)this->inputs->GetInput(enum_type); 1200 1507 if(!base_input) _error_("could not find input with enum " << EnumToStringx(enum_type)); 1201 base_input->Extrude( );1508 base_input->Extrude(start); 1202 1509 1203 1510 /*Stop if there is only one layer of element*/ 1204 if(this->IsOnSurface()) return; 1511 if(start==-1 && this->IsOnSurface()) return; 1512 if(start==+1 && this->IsOnBase()) return; 1205 1513 1206 1514 /*Step 2: this input has been extruded for this element, now follow the upper element*/ 1207 1515 Penta* penta=this; 1208 1516 for(;;){ 1209 /* get upper Penta*/ 1210 penta=penta->GetUpperPenta(); 1517 /*get upper/lower Penta*/ 1518 if(start==-1) penta=penta->GetUpperPenta(); 1519 else penta=penta->GetLowerPenta(); 1211 1520 _assert_(penta->Id()!=this->id); 1212 1521 … … 1215 1524 penta->inputs->AddInput((Input*)copy); 1216 1525 1217 /*Stop if we have reached the surface*/ 1218 if(penta->IsOnSurface()) break; 1526 /*Stop if we have reached the surface/base*/ 1527 if(start==-1 && penta->IsOnSurface()) break; 1528 if(start==+1 && penta->IsOnBase()) break; 1219 1529 } 1220 1530 } … … 1277 1587 case ThicknessEnum: 1278 1588 case FrictionCoefficientEnum: 1589 case FrictionAsEnum: 1590 case MaterialsRheologyBEnum: 1279 1591 if(iomodel->Data(control)){ 1280 1592 for(j=0;j<NUMVERTICES;j++)nodeinputs[j]=iomodel->Data(control)[penta_vertex_ids[j]-1]; … … 1452 1764 } 1453 1765 /*}}}*/ 1766 bool Penta::IsIcefront(void){/*{{{*/ 1767 1768 bool isicefront; 1769 int i,nrice; 1770 IssmDouble ls[NUMVERTICES]; 1771 1772 /*Retrieve all inputs and parameters*/ 1773 GetInputListOnVertices(&ls[0],MaskIceLevelsetEnum); 1774 1775 /* If only one vertex has ice, there is an ice front here */ 1776 isicefront=false; 1777 if(IsIceInElement()){ 1778 nrice=0; 1779 for(i=0;i<NUMVERTICES2D;i++) 1780 if(ls[i]<0.) nrice++; 1781 if(nrice==1) isicefront= true; 1782 } 1783 return isicefront; 1784 }/*}}}*/ 1785 bool Penta::IsNodeOnShelfFromFlags(IssmDouble* flags){/*{{{*/ 1786 1787 int i; 1788 bool shelf=false; 1789 1790 for(i=0;i<NUMVERTICES;i++){ 1791 if (flags[vertices[i]->Pid()]<0.){ 1792 shelf=true; 1793 break; 1794 } 1795 } 1796 return shelf; 1797 } 1798 /*}}}*/ 1454 1799 bool Penta::IsOnBase(void){/*{{{*/ 1455 1800 … … 1488 1833 } 1489 1834 /*}}}*/ 1490 bool Penta::IsNodeOnShelfFromFlags(IssmDouble* flags){/*{{{*/ 1491 1492 int i; 1493 bool shelf=false; 1494 1495 for(i=0;i<NUMVERTICES;i++){ 1496 if (flags[vertices[i]->Pid()]<0.){ 1497 shelf=true; 1498 break; 1499 } 1500 } 1501 return shelf; 1835 bool Penta::IsZeroLevelset(int levelset_enum){/*{{{*/ 1836 1837 bool iszerols; 1838 IssmDouble ls[NUMVERTICES]; 1839 1840 /*Retrieve all inputs and parameters*/ 1841 GetInputListOnVertices(&ls[0],levelset_enum); 1842 1843 /*If the level set has always same sign, there is no ice front here*/ 1844 iszerols = false; 1845 if(IsIceInElement()){ 1846 if(ls[0]*ls[1]<0. || ls[0]*ls[2]<0. || (ls[0]*ls[1]*ls[2]==0. && ls[0]*ls[1]+ls[0]*ls[2]+ls[1]*ls[2]<=0.)){ 1847 iszerols = true; 1848 } 1849 } 1850 return iszerols; 1502 1851 } 1503 1852 /*}}}*/ … … 1523 1872 } 1524 1873 /*}}}*/ 1874 void Penta::JacobianDeterminantSurface(IssmDouble* pJdet,IssmDouble* xyz_list_quad,Gauss* gauss){/*{{{*/ 1875 1876 _assert_(gauss->Enum()==GaussPentaEnum); 1877 this->GetQuadJacobianDeterminant(pJdet,xyz_list_quad,(GaussPenta*)gauss); 1878 1879 } 1880 /*}}}*/ 1525 1881 void Penta::JacobianDeterminantTop(IssmDouble* pJdet,IssmDouble* xyz_list_top,Gauss* gauss){/*{{{*/ 1526 1882 … … 1530 1886 } 1531 1887 /*}}}*/ 1532 void Penta::JacobianDeterminantSurface(IssmDouble* pJdet,IssmDouble* xyz_list_quad,Gauss* gauss){/*{{{*/ 1533 1534 _assert_(gauss->Enum()==GaussPentaEnum); 1535 this->GetQuadJacobianDeterminant(pJdet,xyz_list_quad,(GaussPenta*)gauss); 1536 1888 IssmDouble Penta::MassFlux(IssmDouble* segment){/*{{{*/ 1889 1890 IssmDouble mass_flux=0; 1891 1892 if(!IsOnBase()) return mass_flux; 1893 1894 /*Depth Averaging Vx and Vy*/ 1895 this->InputDepthAverageAtBase(VxEnum,VxAverageEnum); 1896 this->InputDepthAverageAtBase(VyEnum,VyAverageEnum); 1897 1898 /*Spawn Tria element from the base of the Penta: */ 1899 Tria* tria=(Tria*)SpawnTria(0,1,2); 1900 mass_flux=tria->MassFlux(segment); 1901 delete tria->material; delete tria; 1902 1903 /*Delete Vx and Vy averaged*/ 1904 this->inputs->DeleteInput(VxAverageEnum); 1905 this->inputs->DeleteInput(VyAverageEnum); 1906 1907 /*clean up and return*/ 1908 return mass_flux; 1909 } 1910 /*}}}*/ 1911 IssmDouble Penta::MassFlux(IssmDouble x1, IssmDouble y1, IssmDouble x2, IssmDouble y2,int segment_id){/*{{{*/ 1912 1913 IssmDouble mass_flux=0; 1914 1915 if(!IsOnBase()) return mass_flux; 1916 1917 /*Depth Averaging Vx and Vy*/ 1918 this->InputDepthAverageAtBase(VxEnum,VxAverageEnum); 1919 this->InputDepthAverageAtBase(VyEnum,VyAverageEnum); 1920 1921 /*Spawn Tria element from the base of the Penta: */ 1922 Tria* tria=(Tria*)SpawnTria(0,1,2); 1923 mass_flux=tria->MassFlux(x1,y1,x2,y2,segment_id); 1924 delete tria->material; delete tria; 1925 1926 /*Delete Vx and Vy averaged*/ 1927 this->inputs->DeleteInput(VxAverageEnum); 1928 this->inputs->DeleteInput(VyAverageEnum); 1929 1930 /*clean up and return*/ 1931 return mass_flux; 1537 1932 } 1538 1933 /*}}}*/ … … 1556 1951 1557 1952 return minlength; 1953 } 1954 /*}}}*/ 1955 Gauss* Penta::NewGauss(void){/*{{{*/ 1956 return new GaussPenta(); 1957 } 1958 /*}}}*/ 1959 Gauss* Penta::NewGauss(int order){/*{{{*/ 1960 return new GaussPenta(order,order); 1961 } 1962 /*}}}*/ 1963 Gauss* Penta::NewGauss(IssmDouble* xyz_list, IssmDouble* xyz_list_front,int order_horiz,int order_vert){/*{{{*/ 1964 1965 IssmDouble area_coordinates[4][3]; 1966 1967 GetAreaCoordinates(&area_coordinates[0][0],xyz_list_front,xyz_list,4); 1968 1969 return new GaussPenta(area_coordinates,order_horiz,order_vert); 1970 } 1971 /*}}}*/ 1972 Gauss* Penta::NewGaussBase(int order){/*{{{*/ 1973 return new GaussPenta(0,1,2,order); 1974 } 1975 /*}}}*/ 1976 Gauss* Penta::NewGaussLine(int vertex1,int vertex2,int order){/*{{{*/ 1977 return new GaussPenta(vertex1,vertex2,order); 1978 } 1979 /*}}}*/ 1980 Gauss* Penta::NewGaussTop(int order){/*{{{*/ 1981 return new GaussPenta(3,4,5,order); 1982 } 1983 /*}}}*/ 1984 void Penta::NodalFunctions(IssmDouble* basis, Gauss* gauss){/*{{{*/ 1985 1986 _assert_(gauss->Enum()==GaussPentaEnum); 1987 this->GetNodalFunctions(basis,(GaussPenta*)gauss,this->element_type); 1988 1989 } 1990 /*}}}*/ 1991 void Penta::NodalFunctionsDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 1992 1993 _assert_(gauss->Enum()==GaussPentaEnum); 1994 this->GetNodalFunctionsDerivatives(dbasis,xyz_list,(GaussPenta*)gauss,this->element_type); 1995 1996 } 1997 /*}}}*/ 1998 void Penta::NodalFunctionsDerivativesVelocity(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 1999 2000 _assert_(gauss->Enum()==GaussPentaEnum); 2001 this->GetNodalFunctionsDerivatives(dbasis,xyz_list,(GaussPenta*)gauss,this->VelocityInterpolation()); 2002 2003 } 2004 /*}}}*/ 2005 void Penta::NodalFunctionsMINIDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 2006 2007 _assert_(gauss->Enum()==GaussPentaEnum); 2008 this->GetNodalFunctionsDerivatives(dbasis,xyz_list,(GaussPenta*)gauss,P1bubbleEnum); 2009 2010 } 2011 /*}}}*/ 2012 void Penta::NodalFunctionsPressure(IssmDouble* basis, Gauss* gauss){/*{{{*/ 2013 2014 _assert_(gauss->Enum()==GaussPentaEnum); 2015 this->GetNodalFunctions(basis,(GaussPenta*)gauss,this->PressureInterpolation()); 2016 2017 } 2018 /*}}}*/ 2019 void Penta::NodalFunctionsP1(IssmDouble* basis, Gauss* gauss){/*{{{*/ 2020 2021 _assert_(gauss->Enum()==GaussPentaEnum); 2022 this->GetNodalFunctions(basis,(GaussPenta*)gauss,P1Enum); 2023 2024 } 2025 /*}}}*/ 2026 void Penta::NodalFunctionsP1Derivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 2027 2028 _assert_(gauss->Enum()==GaussPentaEnum); 2029 this->GetNodalFunctionsDerivatives(dbasis,xyz_list,(GaussPenta*)gauss,P1Enum); 2030 2031 } 2032 /*}}}*/ 2033 void Penta::NodalFunctionsP2(IssmDouble* basis, Gauss* gauss){/*{{{*/ 2034 2035 _assert_(gauss->Enum()==GaussPentaEnum); 2036 this->GetNodalFunctions(basis,(GaussPenta*)gauss,P2Enum); 2037 2038 } 2039 /*}}}*/ 2040 void Penta::NodalFunctionsVelocity(IssmDouble* basis, Gauss* gauss){/*{{{*/ 2041 2042 _assert_(gauss->Enum()==GaussPentaEnum); 2043 this->GetNodalFunctions(basis,(GaussPenta*)gauss,this->VelocityInterpolation()); 2044 2045 } 2046 /*}}}*/ 2047 void Penta::NodalFunctionsTensor(IssmDouble* basis, Gauss* gauss){/*{{{*/ 2048 2049 _assert_(gauss->Enum()==GaussPentaEnum); 2050 this->GetNodalFunctions(basis,(GaussPenta*)gauss,this->TensorInterpolation()); 2051 1558 2052 } 1559 2053 /*}}}*/ … … 1589 2083 } 1590 2084 /*}}}*/ 1591 Gauss* Penta::NewGauss(void){/*{{{*/1592 return new GaussPenta();1593 }1594 /*}}}*/1595 Gauss* Penta::NewGauss(int order){/*{{{*/1596 return new GaussPenta(order,order);1597 }1598 /*}}}*/1599 Gauss* Penta::NewGauss(IssmDouble* xyz_list, IssmDouble* xyz_list_front,int order_horiz,int order_vert){/*{{{*/1600 1601 IssmDouble area_coordinates[4][3];1602 1603 GetAreaCoordinates(&area_coordinates[0][0],xyz_list_front,xyz_list,4);1604 1605 return new GaussPenta(area_coordinates,order_horiz,order_vert);1606 }1607 /*}}}*/1608 Gauss* Penta::NewGaussBase(int order){/*{{{*/1609 return new GaussPenta(0,1,2,order);1610 }1611 /*}}}*/1612 Gauss* Penta::NewGaussLine(int vertex1,int vertex2,int order){/*{{{*/1613 return new GaussPenta(vertex1,vertex2,order);1614 }1615 /*}}}*/1616 Gauss* Penta::NewGaussTop(int order){/*{{{*/1617 return new GaussPenta(3,4,5,order);1618 }1619 /*}}}*/1620 void Penta::NodalFunctions(IssmDouble* basis, Gauss* gauss){/*{{{*/1621 1622 _assert_(gauss->Enum()==GaussPentaEnum);1623 this->GetNodalFunctions(basis,(GaussPenta*)gauss,this->element_type);1624 1625 }1626 /*}}}*/1627 void Penta::NodalFunctionsP1(IssmDouble* basis, Gauss* gauss){/*{{{*/1628 1629 _assert_(gauss->Enum()==GaussPentaEnum);1630 this->GetNodalFunctions(basis,(GaussPenta*)gauss,P1Enum);1631 1632 }1633 /*}}}*/1634 void Penta::NodalFunctionsP2(IssmDouble* basis, Gauss* gauss){/*{{{*/1635 1636 _assert_(gauss->Enum()==GaussPentaEnum);1637 this->GetNodalFunctions(basis,(GaussPenta*)gauss,P2Enum);1638 1639 }1640 /*}}}*/1641 void Penta::NodalFunctionsDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/1642 1643 _assert_(gauss->Enum()==GaussPentaEnum);1644 this->GetNodalFunctionsDerivatives(dbasis,xyz_list,(GaussPenta*)gauss,this->element_type);1645 1646 }1647 /*}}}*/1648 void Penta::NodalFunctionsP1Derivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/1649 1650 _assert_(gauss->Enum()==GaussPentaEnum);1651 this->GetNodalFunctionsDerivatives(dbasis,xyz_list,(GaussPenta*)gauss,P1Enum);1652 1653 }1654 /*}}}*/1655 void Penta::NodalFunctionsMINIDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/1656 1657 _assert_(gauss->Enum()==GaussPentaEnum);1658 this->GetNodalFunctionsDerivatives(dbasis,xyz_list,(GaussPenta*)gauss,P1bubbleEnum);1659 1660 }1661 /*}}}*/1662 void Penta::NodalFunctionsDerivativesVelocity(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/1663 1664 _assert_(gauss->Enum()==GaussPentaEnum);1665 this->GetNodalFunctionsDerivatives(dbasis,xyz_list,(GaussPenta*)gauss,this->VelocityInterpolation());1666 1667 }1668 /*}}}*/1669 void Penta::NodalFunctionsVelocity(IssmDouble* basis, Gauss* gauss){/*{{{*/1670 1671 _assert_(gauss->Enum()==GaussPentaEnum);1672 this->GetNodalFunctions(basis,(GaussPenta*)gauss,this->VelocityInterpolation());1673 1674 }1675 /*}}}*/1676 void Penta::NodalFunctionsPressure(IssmDouble* basis, Gauss* gauss){/*{{{*/1677 1678 _assert_(gauss->Enum()==GaussPentaEnum);1679 this->GetNodalFunctions(basis,(GaussPenta*)gauss,this->PressureInterpolation());1680 1681 }1682 /*}}}*/1683 void Penta::NodalFunctionsTensor(IssmDouble* basis, Gauss* gauss){/*{{{*/1684 1685 _assert_(gauss->Enum()==GaussPentaEnum);1686 this->GetNodalFunctions(basis,(GaussPenta*)gauss,this->TensorInterpolation());1687 1688 }1689 /*}}}*/1690 2085 void Penta::NormalBase(IssmDouble* bed_normal,IssmDouble* xyz_list){/*{{{*/ 1691 2086 … … 1710 2105 } 1711 2106 /*}}}*/ 2107 void Penta::NormalSection(IssmDouble* normal,IssmDouble* xyz_list){/*{{{*/ 2108 2109 /*Build unit outward pointing vector*/ 2110 IssmDouble AB[3]; 2111 IssmDouble AC[3]; 2112 IssmDouble norm; 2113 2114 AB[0]=xyz_list[1*3+0] - xyz_list[0*3+0]; 2115 AB[1]=xyz_list[1*3+1] - xyz_list[0*3+1]; 2116 AB[2]=xyz_list[1*3+2] - xyz_list[0*3+2]; 2117 AC[0]=xyz_list[2*3+0] - xyz_list[0*3+0]; 2118 AC[1]=xyz_list[2*3+1] - xyz_list[0*3+1]; 2119 AC[2]=xyz_list[2*3+2] - xyz_list[0*3+2]; 2120 2121 cross(normal,AB,AC); 2122 norm=sqrt(normal[0]*normal[0]+normal[1]*normal[1]+normal[2]*normal[2]); 2123 2124 for(int i=0;i<3;i++) normal[i]=normal[i]/norm; 2125 } 2126 /*}}}*/ 1712 2127 void Penta::NormalTop(IssmDouble* top_normal,IssmDouble* xyz_list){/*{{{*/ 1713 2128 … … 1740 2155 } 1741 2156 /*}}}*/ 1742 void Penta::PositiveDegreeDay(IssmDouble* pdds,IssmDouble* pds,IssmDouble signorm){/*{{{*/ 1743 2157 int Penta::ObjectEnum(void){/*{{{*/ 2158 2159 return PentaEnum; 2160 2161 } 2162 /*}}}*/ 2163 void Penta::PositiveDegreeDay(IssmDouble* pdds,IssmDouble* pds,IssmDouble signorm,bool ismungsm){/*{{{*/ 2164 2165 int i; 1744 2166 IssmDouble agd[NUMVERTICES]; // surface mass balance 1745 2167 IssmDouble monthlytemperatures[NUMVERTICES][12],monthlyprec[NUMVERTICES][12]; 1746 IssmDouble h[NUMVERTICES],s[NUMVERTICES]; // ,b 1747 IssmDouble rho_water,rho_ice,desfac,s0p; 2168 IssmDouble tmp[NUMVERTICES]; 2169 IssmDouble h[NUMVERTICES],s[NUMVERTICES]; 2170 IssmDouble rho_water,rho_ice,desfac,s0p,s0t,rlaps,rlapslgm; 2171 IssmDouble PfacTime,TdiffTime,sealevTime; 2172 2173 /*Get material parameters :*/ 2174 rho_water=matpar->GetMaterialParameter(MaterialsRhoSeawaterEnum); 2175 rho_ice=matpar->GetMaterialParameter(MaterialsRhoIceEnum); 2176 2177 /*Get some pdd parameters*/ 2178 desfac=matpar->GetMaterialParameter(SurfaceforcingsDesfacEnum); 2179 s0p=matpar->GetMaterialParameter(SurfaceforcingsS0pEnum); 2180 s0t=matpar->GetMaterialParameter(SurfaceforcingsS0tEnum); 2181 rlaps=matpar->GetMaterialParameter(SurfaceforcingsRlapsEnum); 2182 rlapslgm=matpar->GetMaterialParameter(SurfaceforcingsRlapslgmEnum); 1748 2183 1749 2184 /*Recover monthly temperatures and precipitation*/ … … 1754 2189 this->parameters->FindParam(&time,TimeEnum); 1755 2190 this->parameters->FindParam(&yts,ConstantsYtsEnum); 2191 1756 2192 for(int month=0;month<12;month++) { 1757 2193 for(int iv=0;iv<NUMVERTICES;iv++) { … … 1760 2196 monthlytemperatures[iv][month]=monthlytemperatures[iv][month]-273.15; // conversion from Kelvin to celcius 1761 2197 input2->GetInputValue(&monthlyprec[iv][month],gauss,time+month/12.*yts); 1762 monthlyprec[iv][month]=monthlyprec[iv][month]*yts; // convertion to m/yr1763 2198 } 1764 2199 } 1765 2200 2201 /*Recover Pfac, Tdiff and sealev at time t: 2202 This parameters are used to interpolate the temperature 2203 and precipitaton between PD and LGM when ismungsm==1 */ 2204 if (ismungsm==1){ 2205 this->parameters->FindParam(&TdiffTime,SurfaceforcingsTdiffEnum,time); 2206 this->parameters->FindParam(&sealevTime,SurfaceforcingsSealevEnum,time); 2207 } 2208 else { 2209 TdiffTime=0; 2210 sealevTime=0; 2211 } 2212 1766 2213 /*Recover info at the vertices: */ 1767 2214 GetInputListOnVertices(&h[0],ThicknessEnum); 1768 GetInputListOnVertices(&s[0],SurfaceEnum); 1769 1770 /*Get material parameters :*/ 1771 rho_ice=matpar->GetRhoIce(); 1772 rho_water=matpar->GetRhoFreshwater(); 1773 1774 /*Get desertification effect parameters*/ 1775 desfac=matpar->GetDesFac(); 1776 s0p=matpar->GetS0p(); 2215 GetInputListOnVertices(&s[0],SurfaceEnum); 2216 1777 2217 1778 2218 /*measure the surface mass balance*/ 1779 2219 for (int iv = 0; iv < NUMVERTICES; iv++){ 1780 agd[iv]=PddSurfaceMassBlance(&monthlytemperatures[iv][0], &monthlyprec[iv][0], pdds, pds, 1781 signorm, yts, h[iv], s[iv], rho_ice, rho_water, desfac, s0p); 2220 agd[iv]=PddSurfaceMassBalance(&monthlytemperatures[iv][0], &monthlyprec[iv][0], 2221 pdds,pds, signorm, yts, h[iv], s[iv], 2222 desfac, s0t, s0p,rlaps,rlapslgm,TdiffTime,sealevTime, 2223 rho_water,rho_ice); 1782 2224 } 1783 2225 1784 2226 /*Update inputs*/ 2227 // TransientInput* NewTemperatureInput = new TransientInput(SurfaceforcingsMonthlytemperaturesEnum); 2228 // TransientInput* NewPrecipitationInput = new TransientInput(SurfaceforcingsPrecipitationEnum); 2229 // for (int imonth=0;imonth<12;imonth++) { 2230 // for(i=0;i<NUMVERTICES;i++) tmp[i]=monthlytemperatures[i][imonth]; 2231 // PentaInput* newmonthinput1 = new PentaInput(SurfaceforcingsMonthlytemperaturesEnum,&tmp[0],P1Enum); 2232 // NewTemperatureInput->AddTimeInput(newmonthinput1,time+imonth/12.*yts); 2233 // 2234 // for(i=0;i<NUMVERTICES;i++) tmp[i]=monthlyprec[i][imonth]; 2235 // PentaInput* newmonthinput2 = new PentaInput(SurfaceforcingsPrecipitationEnum,&tmp[0],P1Enum); 2236 // NewPrecipitationInput->AddTimeInput(newmonthinput2,time+imonth/12.*yts); 2237 // } 2238 // NewTemperatureInput->Configure(this->parameters); 2239 // NewPrecipitationInput->Configure(this->parameters); 2240 2241 2242 1785 2243 this->inputs->AddInput(new PentaInput(SurfaceforcingsMassBalanceEnum,&agd[0],P1Enum)); 1786 //this->inputs->AddInput(new PentaVertexInput(ThermalSpcTemperatureEnum,&Tsurf[0])); 1787 this->InputExtrude(SurfaceforcingsMassBalanceEnum); 1788 1789 /*clean-up*/ 1790 delete gauss; 2244 // this->inputs->AddInput(NewTemperatureInput); 2245 // this->inputs->AddInput(NewPrecipitationInput); 2246 // //this->inputs->AddInput(new PentaVertexInput(ThermalSpcTemperatureEnum,&Tsurf[0])); 2247 this->InputExtrude(SurfaceforcingsMassBalanceEnum,-1); 2248 // this->InputExtrude(SurfaceforcingsMonthlytemperaturesEnum,-1); 2249 // this->InputExtrude(SurfaceforcingsPrecipitationEnum,-1); 2250 2251 /*clean-up*/ 2252 delete gauss; 2253 } 2254 /*}}}*/ 2255 void Penta::PotentialUngrounding(Vector<IssmDouble>* potential_ungrounding){/*{{{*/ 2256 2257 IssmDouble h[NUMVERTICES],r[NUMVERTICES],gl[NUMVERTICES]; 2258 IssmDouble bed_hydro; 2259 IssmDouble rho_water,rho_ice,density; 2260 2261 /*material parameters: */ 2262 rho_water=matpar->GetMaterialParameter(MaterialsRhoSeawaterEnum); 2263 rho_ice=matpar->GetMaterialParameter(MaterialsRhoIceEnum); 2264 density=rho_ice/rho_water; 2265 GetInputListOnVertices(&h[0],ThicknessEnum); 2266 GetInputListOnVertices(&r[0],BedEnum); 2267 GetInputListOnVertices(&gl[0],MaskGroundediceLevelsetEnum); 2268 2269 /*go through vertices, and figure out which ones are on the ice sheet, and want to unground: */ 2270 for(int i=0;i<NUMVERTICES;i++){ 2271 /*Find if grounded vertices want to start floating*/ 2272 if (gl[i]>0.){ 2273 bed_hydro=-density*h[i]; 2274 if(bed_hydro>r[i]){ 2275 /*Vertex that could potentially unground, flag it*/ 2276 potential_ungrounding->SetValue(vertices[i]->Pid(),1,INS_VAL); 2277 } 2278 } 2279 } 2280 } 2281 /*}}}*/ 2282 int Penta::PressureInterpolation(void){/*{{{*/ 2283 return PentaRef::PressureInterpolation(this->element_type); 1791 2284 } 1792 2285 /*}}}*/ … … 1909 2402 } 1910 2403 /*}}}*/ 1911 void Penta::SetClone(int* minranks){/*{{{*/1912 1913 _error_("not implemented yet");1914 }1915 /*}}}*/1916 void Penta::SetCurrentConfiguration(Elements* elementsin, Loads* loadsin, Nodes* nodesin, Materials* materialsin, Parameters* parametersin){/*{{{*/1917 1918 /*go into parameters and get the analysis_counter: */1919 int analysis_counter;1920 parametersin->FindParam(&analysis_counter,AnalysisCounterEnum);1921 1922 /*Get Element type*/1923 this->element_type=this->element_type_list[analysis_counter];1924 1925 /*Pick up nodes*/1926 if(this->hnodes[analysis_counter]) this->nodes=(Node**)this->hnodes[analysis_counter]->deliverp();1927 else this->nodes=NULL;1928 1929 }1930 /*}}}*/1931 2404 void Penta::ResetHooks(){/*{{{*/ 1932 2405 … … 1947 2420 } 1948 2421 /*}}}*/ 2422 void Penta::SetClone(int* minranks){/*{{{*/ 2423 2424 _error_("not implemented yet"); 2425 } 2426 /*}}}*/ 2427 void Penta::SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index){/*{{{*/ 2428 2429 IssmDouble values[NUMVERTICES]; 2430 int vertexpidlist[NUMVERTICES],control_init; 2431 2432 /*Specific case for depth averaged quantities*/ 2433 control_init=control_enum; 2434 if(control_enum==MaterialsRheologyBbarEnum){ 2435 control_enum=MaterialsRheologyBEnum; 2436 if(!IsOnBase()) return; 2437 } 2438 if(control_enum==DamageDbarEnum){ 2439 control_enum=DamageDEnum; 2440 if(!IsOnBase()) return; 2441 } 2442 2443 /*Get out if this is not an element input*/ 2444 if(!IsInput(control_enum)) return; 2445 2446 /*Prepare index list*/ 2447 GradientIndexing(&vertexpidlist[0],control_index); 2448 2449 /*Get values on vertices*/ 2450 for(int i=0;i<NUMVERTICES;i++){ 2451 values[i]=vector[vertexpidlist[i]]; 2452 } 2453 Input* new_input = new PentaInput(control_enum,values,P1Enum); 2454 Input* input=(Input*)this->inputs->GetInput(control_enum); _assert_(input); 2455 if(input->ObjectEnum()!=ControlInputEnum){ 2456 _error_("input " << EnumToStringx(control_enum) << " is not a ControlInput"); 2457 } 2458 2459 ((ControlInput*)input)->SetInput(new_input); 2460 2461 if(control_init==MaterialsRheologyBbarEnum){ 2462 this->InputExtrude(control_enum,-1); 2463 } 2464 if(control_init==DamageDbarEnum){ 2465 this->InputExtrude(control_enum,-1); 2466 } 2467 } 2468 /*}}}*/ 2469 void Penta::SetCurrentConfiguration(Elements* elementsin, Loads* loadsin, Nodes* nodesin, Materials* materialsin, Parameters* parametersin){/*{{{*/ 2470 2471 /*go into parameters and get the analysis_counter: */ 2472 int analysis_counter; 2473 parametersin->FindParam(&analysis_counter,AnalysisCounterEnum); 2474 2475 /*Get Element type*/ 2476 this->element_type=this->element_type_list[analysis_counter]; 2477 2478 /*Pick up nodes*/ 2479 if(this->hnodes[analysis_counter]) this->nodes=(Node**)this->hnodes[analysis_counter]->deliverp(); 2480 else this->nodes=NULL; 2481 2482 } 2483 /*}}}*/ 1949 2484 void Penta::SetTemporaryElementType(int element_type_in){/*{{{*/ 1950 2485 this->element_type=element_type_in; 2486 } 2487 /*}}}*/ 2488 Element* Penta::SpawnBasalElement(void){/*{{{*/ 2489 2490 _assert_(this->IsOnBase()); 2491 2492 this->InputDepthAverageAtBase(MaterialsRheologyBEnum,MaterialsRheologyBbarEnum); 2493 if(this->material->IsDamage())this->InputDepthAverageAtBase(DamageDEnum,DamageDbarEnum); 2494 if(this->inputs->GetInput(VxEnum)) this->InputDepthAverageAtBase(VxEnum,VxAverageEnum); 2495 if(this->inputs->GetInput(VyEnum)) this->InputDepthAverageAtBase(VyEnum,VyAverageEnum); 2496 if(this->inputs->GetInput(CalvingratexEnum)) this->InputDepthAverageAtBase(CalvingratexEnum,CalvingratexAverageEnum); 2497 if(this->inputs->GetInput(CalvingrateyEnum)) this->InputDepthAverageAtBase(CalvingrateyEnum,CalvingrateyAverageEnum); 2498 Tria* tria=(Tria*)SpawnTria(0,1,2); 2499 this->inputs->DeleteInput(MaterialsRheologyBbarEnum); 2500 this->inputs->DeleteInput(DamageDbarEnum); 2501 this->inputs->DeleteInput(VxAverageEnum); 2502 this->inputs->DeleteInput(VyAverageEnum); 2503 this->inputs->DeleteInput(CalvingratexAverageEnum); 2504 this->inputs->DeleteInput(CalvingrateyAverageEnum); 2505 2506 return tria; 2507 } 2508 /*}}}*/ 2509 Element* Penta::SpawnTopElement(void){/*{{{*/ 2510 2511 _assert_(this->IsOnSurface()); 2512 2513 Tria* tria=(Tria*)SpawnTria(3,4,5); 2514 2515 return tria; 1951 2516 } 1952 2517 /*}}}*/ … … 1964 2529 tria->parameters=this->parameters; 1965 2530 tria->element_type=P1Enum; //Only P1 CG for now (TO BE CHANGED) 1966 this->SpawnTriaHook( dynamic_cast<ElementHook*>(tria),index1,index2,index3);2531 this->SpawnTriaHook(xDynamicCast<ElementHook*>(tria),index1,index2,index3); 1967 2532 1968 2533 /*Spawn material*/ … … 1978 2543 } 1979 2544 /*}}}*/ 1980 Element* Penta::SpawnBasalElement(void){/*{{{*/ 1981 1982 _assert_(this->IsOnBase()); 1983 1984 this->InputDepthAverageAtBase(MaterialsRheologyBEnum,MaterialsRheologyBbarEnum); 1985 if(this->material->IsDamage())this->InputDepthAverageAtBase(DamageDEnum,DamageDbarEnum); 1986 if(this->inputs->GetInput(VxEnum)) this->InputDepthAverageAtBase(VxEnum,VxAverageEnum); 1987 if(this->inputs->GetInput(VyEnum)) this->InputDepthAverageAtBase(VyEnum,VyAverageEnum); 1988 Tria* tria=(Tria*)SpawnTria(0,1,2); 1989 this->inputs->DeleteInput(MaterialsRheologyBbarEnum); 1990 this->inputs->DeleteInput(DamageDbarEnum); 1991 this->inputs->DeleteInput(VxAverageEnum); 1992 this->inputs->DeleteInput(VyAverageEnum); 1993 1994 return tria; 1995 } 1996 /*}}}*/ 1997 Element* Penta::SpawnTopElement(void){/*{{{*/ 1998 1999 _assert_(this->IsOnSurface()); 2000 2001 Tria* tria=(Tria*)SpawnTria(3,4,5); 2002 2003 return tria; 2545 IssmDouble Penta::StabilizationParameter(IssmDouble u, IssmDouble v, IssmDouble w, IssmDouble diameter, IssmDouble kappa){/*{{{*/ 2546 /*Compute stabilization parameter*/ 2547 /*kappa=thermalconductivity/(rho_ice*hearcapacity) for thermal model*/ 2548 /*kappa=enthalpydiffusionparameter for enthalpy model*/ 2549 2550 IssmDouble normu; 2551 IssmDouble tau_parameter; 2552 2553 normu=pow(pow(u,2)+pow(v,2)+pow(w,2),0.5); 2554 if(normu*diameter/(3*2*kappa)<1){ 2555 tau_parameter=pow(diameter,2)/(3*2*2*kappa); 2556 } 2557 else tau_parameter=diameter/(2*normu); 2558 2559 return tau_parameter; 2560 } 2561 /*}}}*/ 2562 void Penta::StrainRateparallel(){/*{{{*/ 2563 2564 IssmDouble *xyz_list = NULL; 2565 IssmDouble epsilon[6]; 2566 GaussPenta* gauss=NULL; 2567 IssmDouble vx,vy,vel; 2568 IssmDouble strainxx; 2569 IssmDouble strainxy; 2570 IssmDouble strainyy; 2571 IssmDouble strainparallel[NUMVERTICES]; 2572 2573 /* Get node coordinates and dof list: */ 2574 this->GetVerticesCoordinates(&xyz_list); 2575 2576 /*Retrieve all inputs we will need*/ 2577 Input* vx_input=inputs->GetInput(VxEnum); _assert_(vx_input); 2578 Input* vy_input=inputs->GetInput(VyEnum); _assert_(vy_input); 2579 Input* vz_input=inputs->GetInput(VzEnum); _assert_(vz_input); 2580 2581 /* Start looping on the number of vertices: */ 2582 gauss=new GaussPenta(); 2583 for (int iv=0;iv<NUMVERTICES;iv++){ 2584 gauss->GaussVertex(iv); 2585 2586 /* Get the value we need*/ 2587 vx_input->GetInputValue(&vx,gauss); 2588 vy_input->GetInputValue(&vy,gauss); 2589 vel=vx*vx+vy*vy; 2590 2591 /*Compute strain rate and viscosity: */ 2592 this->StrainRateFS(&epsilon[0],xyz_list,gauss,vx_input,vy_input,vz_input); 2593 strainxx=epsilon[0]; 2594 strainyy=epsilon[1]; 2595 strainxy=epsilon[3]; 2596 2597 /*strainparallel= Strain rate along the ice flow direction */ 2598 strainparallel[iv]=(vx*vx*(strainxx)+vy*vy*(strainyy)+2*vy*vx*strainxy)/(vel+1.e-14); 2599 } 2600 2601 /*Add input*/ 2602 this->inputs->AddInput(new PentaInput(StrainRateparallelEnum,&strainparallel[0],P1Enum)); 2603 2604 /*Clean up and return*/ 2605 delete gauss; 2606 xDelete<IssmDouble>(xyz_list); 2607 } 2608 /*}}}*/ 2609 void Penta::StrainRateperpendicular(){/*{{{*/ 2610 2611 IssmDouble *xyz_list = NULL; 2612 IssmDouble epsilon[6]; 2613 GaussPenta* gauss=NULL; 2614 IssmDouble vx,vy,vel; 2615 IssmDouble strainxx; 2616 IssmDouble strainxy; 2617 IssmDouble strainyy; 2618 IssmDouble strainperpendicular[NUMVERTICES]; 2619 2620 /* Get node coordinates and dof list: */ 2621 this->GetVerticesCoordinates(&xyz_list); 2622 2623 /*Retrieve all inputs we will need*/ 2624 Input* vx_input=inputs->GetInput(VxEnum); _assert_(vx_input); 2625 Input* vy_input=inputs->GetInput(VyEnum); _assert_(vy_input); 2626 Input* vz_input=inputs->GetInput(VzEnum); _assert_(vz_input); 2627 2628 /* Start looping on the number of vertices: */ 2629 gauss=new GaussPenta(); 2630 for (int iv=0;iv<NUMVERTICES;iv++){ 2631 gauss->GaussVertex(iv); 2632 2633 /* Get the value we need*/ 2634 vx_input->GetInputValue(&vx,gauss); 2635 vy_input->GetInputValue(&vy,gauss); 2636 vel=vx*vx+vy*vy; 2637 2638 /*Compute strain rate and viscosity: */ 2639 this->StrainRateFS(&epsilon[0],xyz_list,gauss,vx_input,vy_input,vz_input); 2640 strainxx=epsilon[0]; 2641 strainyy=epsilon[1]; 2642 strainxy=epsilon[3]; 2643 2644 /*strainperpendicular= Strain rate perpendicular to the ice flow direction */ 2645 strainperpendicular[iv]=(vx*vx*(strainyy)+vy*vy*(strainxx)-2*vy*vx*strainxy)/(vel+1.e-14); 2646 } 2647 2648 /*Add input*/ 2649 this->inputs->AddInput(new PentaInput(StrainRateperpendicularEnum,&strainperpendicular[0],P1Enum)); 2650 2651 /*Clean up and return*/ 2652 delete gauss; 2653 xDelete<IssmDouble>(xyz_list); 2654 } 2655 /*}}}*/ 2656 void Penta::StressIntensityFactor(){/*{{{*/ 2657 2658 /* Check if we are on the base */ 2659 if(!IsOnBase()) return; 2660 2661 IssmDouble ki[6]={0.}; 2662 IssmDouble const_grav=9.81; 2663 IssmDouble rho_ice=900; 2664 IssmDouble rho_water=1000; 2665 IssmDouble Jdet[3]; 2666 IssmDouble pressure,vx,vy,vel,deviaxx,deviaxy,deviayy,water_depth,prof,stress_xx,thickness; 2667 2668 Penta* penta=this; 2669 for(;;){ 2670 2671 IssmDouble xyz_list[NUMVERTICES][3]; 2672 /* Get node coordinates and dof list: */ 2673 ::GetVerticesCoordinates(&xyz_list[0][0],penta->vertices,NUMVERTICES); 2674 2675 ///*Compute the Jacobian for the vertical integration*/ 2676 Jdet[0]=(xyz_list[3][2]-xyz_list[0][2])*0.5; 2677 Jdet[1]=(xyz_list[4][2]-xyz_list[1][2])*0.5; 2678 Jdet[2]=(xyz_list[5][2]-xyz_list[2][2])*0.5; 2679 2680 /*Retrieve all inputs we will need*/ 2681 Input* vx_input=inputs->GetInput(VxEnum); _assert_(vx_input); 2682 Input* vy_input=inputs->GetInput(VyEnum); _assert_(vy_input); 2683 Input* vel_input=inputs->GetInput(VelEnum); _assert_(vel_input); 2684 Input* pressure_input=inputs->GetInput(PressureEnum); _assert_(pressure_input); 2685 Input* deviaxx_input=inputs->GetInput(DeviatoricStressxxEnum); _assert_(deviaxx_input); 2686 Input* deviaxy_input=inputs->GetInput(DeviatoricStressxyEnum); _assert_(deviaxy_input); 2687 Input* deviayy_input=inputs->GetInput(DeviatoricStressyyEnum); _assert_(deviayy_input); 2688 Input* surface_input=inputs->GetInput(SurfaceEnum); _assert_(surface_input); 2689 Input* thickness_input=inputs->GetInput(ThicknessEnum); _assert_(thickness_input); 2690 2691 /* Start looping on the number of 2D vertices: */ 2692 for(int ig=0;ig<3;ig++){ 2693 GaussPenta* gauss=new GaussPenta(ig,3+ig,11); 2694 for (int iv=gauss->begin();iv<gauss->end();iv++){ 2695 gauss->GaussPoint(iv); 2696 2697 /* Get the value we need*/ 2698 pressure_input->GetInputValue(&pressure,gauss); 2699 vx_input->GetInputValue(&vx,gauss); 2700 vy_input->GetInputValue(&vy,gauss); 2701 vel_input->GetInputValue(&vel,gauss); 2702 deviaxx_input->GetInputValue(&deviaxx,gauss); 2703 deviaxy_input->GetInputValue(&deviaxy,gauss); 2704 deviayy_input->GetInputValue(&deviayy,gauss); 2705 surface_input->GetInputValue(&water_depth,gauss); 2706 thickness_input->GetInputValue(&thickness,gauss); 2707 prof=water_depth-penta->GetZcoord(&xyz_list[0][0],gauss); 2708 2709 /*stress_xx= Deviatoric stress along the ice flow direction plus cryostatic pressure */ 2710 stress_xx=(vx*vx*(deviaxx)+vy*vy*(deviayy)+2*vy*vx*deviaxy)/(vel*vel+1.e-6); 2711 2712 if(prof<water_depth&prof<thickness){ 2713 /* Compute the local stress intensity factor*/ 2714 ki[ig]+=Jdet[ig]*gauss->weight*stress_xx*StressIntensityIntegralWeight(prof,min(water_depth,thickness),thickness); 2715 } 2716 } 2717 delete gauss; 2718 } 2719 2720 /*Stop if we have reached the surface/base*/ 2721 if(penta->IsOnSurface()) break; 2722 2723 /*get upper Penta*/ 2724 penta=penta->GetUpperPenta(); 2725 _assert_(penta->Id()!=this->id); 2726 } 2727 2728 /*Add input*/ 2729 this->inputs->AddInput(new PentaInput(StressIntensityFactorEnum,&ki[0],P1Enum)); 2730 this->InputExtrude(StressIntensityFactorEnum,-1); 2004 2731 } 2005 2732 /*}}}*/ … … 2083 2810 return dt; 2084 2811 }/*}}}*/ 2812 IssmDouble Penta::TotalSmb(void){/*{{{*/ 2813 2814 /*The smb[Gt yr-1] of one element is area[m2] * smb [ m ice yr^-1] * rho_ice [kg m-3] / 1e+10^12 */ 2815 IssmDouble base,smb,rho_ice; 2816 IssmDouble Total_Smb=0; 2817 IssmDouble xyz_list[NUMVERTICES][3]; 2818 2819 /*Get material parameters :*/ 2820 rho_ice=matpar->GetMaterialParameter(MaterialsRhoIceEnum); 2821 2822 if(!IsIceInElement() || !IsOnSurface()) return 0.; 2823 2824 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 2825 2826 /*First calculate the area of the base (cross section triangle) 2827 * http://en.wikipedia.org/wiki/Triangle 2828 * base = 1/2 abs((xA-xC)(yB-yA)-(xA-xB)(yC-yA))*/ 2829 base = 1./2. * fabs((xyz_list[0][0]-xyz_list[2][0])*(xyz_list[1][1]-xyz_list[0][1]) - (xyz_list[0][0]-xyz_list[1][0])*(xyz_list[2][1]-xyz_list[0][1])); 2830 2831 /*Now get the average SMB over the element*/ 2832 Input* smb_input = inputs->GetInput(SurfaceforcingsMassBalanceEnum); _assert_(smb_input); 2833 2834 smb_input->GetInputAverage(&smb); 2835 Total_Smb=rho_ice*base*smb;// smb on element in kg s-1 2836 2837 /*Return: */ 2838 return Total_Smb; 2839 } 2840 /*}}}*/ 2085 2841 void Penta::Update(int index,IoModel* iomodel,int analysis_counter,int analysis_type,int finiteelement_type){ /*{{{*/ 2086 2842 … … 2091 2847 IssmDouble yts; 2092 2848 bool dakota_analysis; 2093 bool isFS;2094 2849 int numnodes; 2095 2850 int* penta_node_ids = NULL; … … 2098 2853 iomodel->Constant(&yts,ConstantsYtsEnum); 2099 2854 iomodel->Constant(&dakota_analysis,QmuIsdakotaEnum); 2100 iomodel->Constant(&isFS,FlowequationIsFSEnum);2101 2855 2102 2856 /*Checks if debuging*/ … … 2413 3167 penta_node_ids[24]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->numberofedges+iomodel->numberoffaces+iomodel->numberofelements+6*index+6; 2414 3168 break; 3169 case LACrouzeixRaviartEnum: 3170 numnodes = 19; 3171 penta_node_ids = xNew<int>(numnodes); 3172 penta_node_ids[ 0]=iomodel->nodecounter+iomodel->elements[6*index+0]; 3173 penta_node_ids[ 1]=iomodel->nodecounter+iomodel->elements[6*index+1]; 3174 penta_node_ids[ 2]=iomodel->nodecounter+iomodel->elements[6*index+2]; 3175 penta_node_ids[ 3]=iomodel->nodecounter+iomodel->elements[6*index+3]; 3176 penta_node_ids[ 4]=iomodel->nodecounter+iomodel->elements[6*index+4]; 3177 penta_node_ids[ 5]=iomodel->nodecounter+iomodel->elements[6*index+5]; 3178 penta_node_ids[ 6]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->elementtoedgeconnectivity[9*index+0]+1; 3179 penta_node_ids[ 7]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->elementtoedgeconnectivity[9*index+1]+1; 3180 penta_node_ids[ 8]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->elementtoedgeconnectivity[9*index+2]+1; 3181 penta_node_ids[ 9]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->elementtoedgeconnectivity[9*index+3]+1; 3182 penta_node_ids[10]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->elementtoedgeconnectivity[9*index+4]+1; 3183 penta_node_ids[11]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->elementtoedgeconnectivity[9*index+5]+1; 3184 penta_node_ids[12]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->elementtoedgeconnectivity[9*index+6]+1; 3185 penta_node_ids[13]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->elementtoedgeconnectivity[9*index+7]+1; 3186 penta_node_ids[14]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->elementtoedgeconnectivity[9*index+8]+1; 3187 penta_node_ids[15]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->numberofedges+iomodel->elementtofaceconnectivity[5*index+2]+1; 3188 penta_node_ids[16]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->numberofedges+iomodel->elementtofaceconnectivity[5*index+3]+1; 3189 penta_node_ids[17]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->numberofedges+iomodel->elementtofaceconnectivity[5*index+4]+1; 3190 penta_node_ids[18]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->numberofedges+iomodel->numberoffaces+index+1; 3191 break; 2415 3192 default: 2416 3193 _error_("Finite element "<<EnumToStringx(finiteelement_type)<<" not supported yet"); … … 2428 3205 2429 3206 case StressbalanceAnalysisEnum: 3207 _assert_(iomodel->Data(FlowequationElementEquationEnum)); 2430 3208 2431 3209 if(*(iomodel->Data(FlowequationElementEquationEnum)+index)==HOFSApproximationEnum){ … … 2509 3287 } 2510 3288 /*}}}*/ 3289 int Penta::UpdatePotentialUngrounding(IssmDouble* vertices_potentially_ungrounding,Vector<IssmDouble>* vec_nodes_on_iceshelf,IssmDouble* nodes_on_iceshelf){/*{{{*/ 3290 3291 int i; 3292 int nflipped=0; 3293 3294 /*Go through nodes, and whoever is on the potential_ungrounding, ends up in nodes_on_iceshelf: */ 3295 for(i=0;i<NUMVERTICES;i++){ 3296 if (reCast<bool,IssmDouble>(vertices_potentially_ungrounding[vertices[i]->Pid()])){ 3297 vec_nodes_on_iceshelf->SetValue(vertices[i]->Pid(),-1.,INS_VAL); 3298 3299 /*If node was not on ice shelf, we flipped*/ 3300 if(nodes_on_iceshelf[vertices[i]->Pid()]>=0.){ 3301 nflipped++; 3302 } 3303 } 3304 } 3305 return nflipped; 3306 } 3307 /*}}}*/ 3308 void Penta::ValueP1DerivativesOnGauss(IssmDouble* dvalue,IssmDouble* values,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 3309 PentaRef::GetInputDerivativeValue(dvalue,values,xyz_list,gauss,P1Enum); 3310 } 3311 /*}}}*/ 2511 3312 void Penta::ValueP1OnGauss(IssmDouble* pvalue,IssmDouble* values,Gauss* gauss){/*{{{*/ 2512 3313 PentaRef::GetInputValue(pvalue,values,gauss,P1Enum); 2513 3314 } 2514 3315 /*}}}*/ 2515 void Penta::ValueP1DerivativesOnGauss(IssmDouble* dvalue,IssmDouble* values,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/2516 PentaRef::GetInputDerivativeValue(dvalue,values,xyz_list,gauss,P1Enum);3316 int Penta::VelocityInterpolation(void){/*{{{*/ 3317 return PentaRef::VelocityInterpolation(this->element_type); 2517 3318 } 2518 3319 /*}}}*/ … … 2551 3352 } 2552 3353 /*}}}*/ 2553 int Penta::VelocityInterpolation(void){/*{{{*/ 2554 return PentaRef::VelocityInterpolation(this->element_type); 2555 } 2556 /*}}}*/ 2557 int Penta::PressureInterpolation(void){/*{{{*/ 2558 return PentaRef::PressureInterpolation(this->element_type); 2559 } 2560 /*}}}*/ 2561 bool Penta::IsZeroLevelset(int levelset_enum){/*{{{*/ 2562 2563 bool iszerols; 2564 IssmDouble ls[NUMVERTICES]; 2565 2566 /*Retrieve all inputs and parameters*/ 2567 GetInputListOnVertices(&ls[0],levelset_enum); 2568 2569 /*If the level set has always same sign, there is no ice front here*/ 2570 iszerols = false; 2571 if(IsIceInElement()){ 2572 if(ls[0]*ls[1]<0. || ls[0]*ls[2]<0. || (ls[0]*ls[1]*ls[2]==0. && ls[0]*ls[1]+ls[0]*ls[2]+ls[1]*ls[2]<=0.)){ 2573 iszerols = true; 2574 } 2575 } 2576 return iszerols; 2577 } 2578 /*}}}*/ 2579 bool Penta::IsIcefront(void){/*{{{*/ 2580 2581 bool isicefront; 2582 int i,nrice; 2583 IssmDouble ls[NUMVERTICES]; 2584 2585 /*Retrieve all inputs and parameters*/ 2586 GetInputListOnVertices(&ls[0],MaskIceLevelsetEnum); 2587 2588 /* If only one vertex has ice, there is an ice front here */ 2589 isicefront=false; 2590 if(IsIceInElement()){ 2591 nrice=0; 2592 for(i=0;i<NUMVERTICES2D;i++) 2593 if(ls[i]<0.) nrice++; 2594 if(nrice==1) isicefront= true; 2595 } 2596 return isicefront; 2597 }/*}}}*/ 2598 void Penta::AverageOntoPartition(Vector<IssmDouble>* partition_contributions,Vector<IssmDouble>* partition_areas,IssmDouble* vertex_response,IssmDouble* qmu_part){/*{{{*/ 2599 _error_("Not supported yet!"); 2600 } 2601 /*}}}*/ 2602 IssmDouble Penta::IceVolume(void){/*{{{*/ 2603 2604 /*The volume of a troncated prism is base * 1/3 sum(length of edges)*/ 2605 IssmDouble base,height; 2606 IssmDouble xyz_list[NUMVERTICES][3]; 2607 2608 if(!IsIceInElement())return 0; 2609 2610 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 2611 2612 /*First calculate the area of the base (cross section triangle) 2613 * http://en.wikipedia.org/wiki/Pentangle 2614 * base = 1/2 abs((xA-xC)(yB-yA)-(xA-xB)(yC-yA))*/ 2615 base = 1./2.*fabs((xyz_list[0][0]-xyz_list[2][0])*(xyz_list[1][1]-xyz_list[0][1]) - (xyz_list[0][0]-xyz_list[1][0])*(xyz_list[2][1]-xyz_list[0][1])); 2616 2617 /*Now get the average height*/ 2618 height = 1./3.*((xyz_list[3][2]-xyz_list[0][2])+(xyz_list[4][2]-xyz_list[1][2])+(xyz_list[5][2]-xyz_list[2][2])); 2619 2620 /*Return: */ 2621 return base*height; 2622 } 2623 /*}}}*/ 2624 IssmDouble Penta::IceVolumeAboveFloatation(void){/*{{{*/ 2625 2626 /*Volume above floatation: H + rho_water/rho_ice*bathymetry for nodes on the bed*/ 2627 IssmDouble rho_ice,rho_water; 2628 IssmDouble base,bed,surface,bathymetry; 2629 IssmDouble xyz_list[NUMVERTICES][3]; 2630 2631 if(!IsIceInElement() || IsFloating() || !IsOnBase())return 0; 2632 2633 rho_ice=matpar->GetRhoIce(); 2634 rho_water=matpar->GetRhoWater(); 2635 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 2636 2637 /*First calculate the area of the base (cross section triangle) 2638 * http://en.wikipedia.org/wiki/Pentangle 2639 * base = 1/2 abs((xA-xC)(yB-yA)-(xA-xB)(yC-yA))*/ 2640 base = 1./2.*fabs((xyz_list[0][0]-xyz_list[2][0])*(xyz_list[1][1]-xyz_list[0][1]) - (xyz_list[0][0]-xyz_list[1][0])*(xyz_list[2][1]-xyz_list[0][1])); 2641 2642 /*Now get the average height above floatation*/ 2643 Input* surface_input = inputs->GetInput(SurfaceEnum); _assert_(surface_input); 2644 Input* base_input = inputs->GetInput(BaseEnum); _assert_(base_input); 2645 Input* bed_input = inputs->GetInput(BedEnum); _assert_(bed_input); 2646 surface_input->GetInputAverage(&surface); 2647 base_input->GetInputAverage(&bed); 2648 bed_input->GetInputAverage(&bathymetry); 2649 2650 /*Return: */ 2651 return base*(surface - bed + min( rho_water/rho_ice * bathymetry, 0.) ); 2652 } 2653 /*}}}*/ 2654 IssmDouble Penta::MassFlux( IssmDouble* segment){/*{{{*/ 2655 2656 IssmDouble mass_flux=0; 2657 2658 if(!IsOnBase()) return mass_flux; 2659 2660 /*Depth Averaging Vx and Vy*/ 2661 this->InputDepthAverageAtBase(VxEnum,VxAverageEnum); 2662 this->InputDepthAverageAtBase(VyEnum,VyAverageEnum); 2663 2664 /*Spawn Tria element from the base of the Penta: */ 2665 Tria* tria=(Tria*)SpawnTria(0,1,2); 2666 mass_flux=tria->MassFlux(segment); 2667 delete tria->material; delete tria; 2668 2669 /*Delete Vx and Vy averaged*/ 2670 this->inputs->DeleteInput(VxAverageEnum); 2671 this->inputs->DeleteInput(VyAverageEnum); 2672 2673 /*clean up and return*/ 2674 return mass_flux; 2675 } 2676 /*}}}*/ 2677 IssmDouble Penta::MassFlux( IssmDouble x1, IssmDouble y1, IssmDouble x2, IssmDouble y2,int segment_id){/*{{{*/ 2678 2679 IssmDouble mass_flux=0; 2680 2681 if(!IsOnBase()) return mass_flux; 2682 2683 /*Depth Averaging Vx and Vy*/ 2684 this->InputDepthAverageAtBase(VxEnum,VxAverageEnum); 2685 this->InputDepthAverageAtBase(VyEnum,VyAverageEnum); 2686 2687 /*Spawn Tria element from the base of the Penta: */ 2688 Tria* tria=(Tria*)SpawnTria(0,1,2); 2689 mass_flux=tria->MassFlux(x1,y1,x2,y2,segment_id); 2690 delete tria->material; delete tria; 2691 2692 /*Delete Vx and Vy averaged*/ 2693 this->inputs->DeleteInput(VxAverageEnum); 2694 this->inputs->DeleteInput(VyAverageEnum); 2695 2696 /*clean up and return*/ 2697 return mass_flux; 2698 } 2699 /*}}}*/ 2700 void Penta::ElementResponse(IssmDouble* presponse,int response_enum){/*{{{*/ 2701 2702 switch(response_enum){ 2703 case MaterialsRheologyBbarEnum: 2704 *presponse=this->material->GetBbar(); 2705 break; 2706 case DamageDbarEnum: 2707 *presponse=this->material->GetDbar(); 2708 break; 2709 case VelEnum: 2710 { 2711 2712 /*Get input:*/ 2713 IssmDouble vel; 2714 Input* vel_input; 2715 2716 vel_input=this->inputs->GetInput(VelEnum); _assert_(vel_input); 2717 vel_input->GetInputAverage(&vel); 2718 2719 /*Assign output pointers:*/ 2720 *presponse=vel; 2721 } 2722 break; 2723 default: 2724 _error_("Response type " << EnumToStringx(response_enum) << " not supported yet!"); 2725 } 2726 2727 } 2728 /*}}}*/ 2729 IssmDouble Penta::TotalSmb(void){/*{{{*/ 2730 2731 /*The smb[Gt yr-1] of one element is area[m2] * smb [ m ice yr^-1] * rho_ice [kg m-3] / 1e+10^12 */ 2732 IssmDouble base,smb,rho_ice; 2733 IssmDouble Total_Smb=0; 2734 IssmDouble xyz_list[NUMVERTICES][3]; 2735 2736 /*Get material parameters :*/ 2737 rho_ice=matpar->GetRhoIce(); 2738 2739 if(!IsIceInElement() || !IsOnSurface()) return 0.; 2740 2741 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 2742 2743 /*First calculate the area of the base (cross section triangle) 2744 * http://en.wikipedia.org/wiki/Triangle 2745 * base = 1/2 abs((xA-xC)(yB-yA)-(xA-xB)(yC-yA))*/ 2746 base = 1./2. * fabs((xyz_list[0][0]-xyz_list[2][0])*(xyz_list[1][1]-xyz_list[0][1]) - (xyz_list[0][0]-xyz_list[1][0])*(xyz_list[2][1]-xyz_list[0][1])); 2747 2748 /*Now get the average SMB over the element*/ 2749 Input* smb_input = inputs->GetInput(SurfaceforcingsMassBalanceEnum); _assert_(smb_input); 2750 2751 smb_input->GetInputAverage(&smb); 2752 Total_Smb=rho_ice*base*smb;// smb on element in kg s-1 2753 2754 /*Return: */ 2755 return Total_Smb; 3354 void Penta::ZeroLevelsetCoordinates(IssmDouble** pxyz_zero,IssmDouble* xyz_list,int levelsetenum){/*{{{*/ 3355 /*Compute portion of the element that is grounded*/ 3356 3357 int normal_orientation=0; 3358 IssmDouble s1,s2; 3359 IssmDouble levelset[NUMVERTICES]; 3360 IssmDouble* xyz_zero = xNew<IssmDouble>(4*3); 3361 3362 /*Recover parameters and values*/ 3363 GetInputListOnVertices(&levelset[0],levelsetenum); 3364 3365 if(levelset[0]*levelset[1]>0.){ //Nodes 0 and 1 are similar, so points must be found on segment 0-2 and 1-2 3366 /*Portion of the segments*/ 3367 s1=levelset[2]/(levelset[2]-levelset[1]); 3368 s2=levelset[2]/(levelset[2]-levelset[0]); 3369 3370 if(levelset[2]<0.) normal_orientation=1; //orientation of quadrangle at base and top, depending on distribution of levelsetfunction 3371 /*New point 1*/ 3372 xyz_zero[3*normal_orientation+0]=xyz_list[2*3+0]+s1*(xyz_list[1*3+0]-xyz_list[2*3+0]); 3373 xyz_zero[3*normal_orientation+1]=xyz_list[2*3+1]+s1*(xyz_list[1*3+1]-xyz_list[2*3+1]); 3374 xyz_zero[3*normal_orientation+2]=xyz_list[2*3+2]+s1*(xyz_list[1*3+2]-xyz_list[2*3+2]); 3375 3376 /*New point 0*/ 3377 xyz_zero[3*(1-normal_orientation)+0]=xyz_list[2*3+0]+s2*(xyz_list[0*3+0]-xyz_list[2*3+0]); 3378 xyz_zero[3*(1-normal_orientation)+1]=xyz_list[2*3+1]+s2*(xyz_list[0*3+1]-xyz_list[2*3+1]); 3379 xyz_zero[3*(1-normal_orientation)+2]=xyz_list[2*3+2]+s2*(xyz_list[0*3+2]-xyz_list[2*3+2]); 3380 3381 /*New point 3*/ 3382 xyz_zero[3*(2+1-normal_orientation)+0]=xyz_list[5*3+0]+s1*(xyz_list[4*3+0]-xyz_list[5*3+0]); 3383 xyz_zero[3*(2+1-normal_orientation)+1]=xyz_list[5*3+1]+s1*(xyz_list[4*3+1]-xyz_list[5*3+1]); 3384 xyz_zero[3*(2+1-normal_orientation)+2]=xyz_list[5*3+2]+s1*(xyz_list[4*3+2]-xyz_list[5*3+2]); 3385 3386 /*New point 4*/ 3387 xyz_zero[3*(2+normal_orientation)+0]=xyz_list[5*3+0]+s2*(xyz_list[3*3+0]-xyz_list[5*3+0]); 3388 xyz_zero[3*(2+normal_orientation)+1]=xyz_list[5*3+1]+s2*(xyz_list[3*3+1]-xyz_list[5*3+1]); 3389 xyz_zero[3*(2+normal_orientation)+2]=xyz_list[5*3+2]+s2*(xyz_list[3*3+2]-xyz_list[5*3+2]); 3390 } 3391 else if(levelset[1]*levelset[2]>0.){ //Nodes 1 and 2 are similar, so points must be found on segment 0-1 and 0-2 3392 /*Portion of the segments*/ 3393 s1=levelset[0]/(levelset[0]-levelset[2]); 3394 s2=levelset[0]/(levelset[0]-levelset[1]); 3395 3396 if(levelset[0]<0.) normal_orientation=1; 3397 /*New point 1*/ 3398 xyz_zero[3*normal_orientation+0]=xyz_list[0*3+0]+s1*(xyz_list[2*3+0]-xyz_list[0*3+0]); 3399 xyz_zero[3*normal_orientation+1]=xyz_list[0*3+1]+s1*(xyz_list[2*3+1]-xyz_list[0*3+1]); 3400 xyz_zero[3*normal_orientation+2]=xyz_list[0*3+2]+s1*(xyz_list[2*3+2]-xyz_list[0*3+2]); 3401 3402 /*New point 2*/ 3403 xyz_zero[3*(1-normal_orientation)+0]=xyz_list[0*3+0]+s2*(xyz_list[1*3+0]-xyz_list[0*3+0]); 3404 xyz_zero[3*(1-normal_orientation)+1]=xyz_list[0*3+1]+s2*(xyz_list[1*3+1]-xyz_list[0*3+1]); 3405 xyz_zero[3*(1-normal_orientation)+2]=xyz_list[0*3+2]+s2*(xyz_list[1*3+2]-xyz_list[0*3+2]); 3406 3407 /*New point 3*/ 3408 xyz_zero[3*(2+1-normal_orientation)+0]=xyz_list[3*3+0]+s1*(xyz_list[5*3+0]-xyz_list[3*3+0]); 3409 xyz_zero[3*(2+1-normal_orientation)+1]=xyz_list[3*3+1]+s1*(xyz_list[5*3+1]-xyz_list[3*3+1]); 3410 xyz_zero[3*(2+1-normal_orientation)+2]=xyz_list[3*3+2]+s1*(xyz_list[5*3+2]-xyz_list[3*3+2]); 3411 3412 /*New point 4*/ 3413 xyz_zero[3*(2+normal_orientation)+0]=xyz_list[3*3+0]+s2*(xyz_list[4*3+0]-xyz_list[3*3+0]); 3414 xyz_zero[3*(2+normal_orientation)+1]=xyz_list[3*3+1]+s2*(xyz_list[4*3+1]-xyz_list[3*3+1]); 3415 xyz_zero[3*(2+normal_orientation)+2]=xyz_list[3*3+2]+s2*(xyz_list[4*3+2]-xyz_list[3*3+2]); 3416 } 3417 else if(levelset[0]*levelset[2]>0.){ //Nodes 0 and 2 are similar, so points must be found on segment 1-0 and 1-2 3418 /*Portion of the segments*/ 3419 s1=levelset[1]/(levelset[1]-levelset[0]); 3420 s2=levelset[1]/(levelset[1]-levelset[2]); 3421 3422 if(levelset[1]<0.) normal_orientation=1; 3423 /*New point 0*/ 3424 xyz_zero[3*normal_orientation+0]=xyz_list[1*3+0]+s1*(xyz_list[0*3+0]-xyz_list[1*3+0]); 3425 xyz_zero[3*normal_orientation+1]=xyz_list[1*3+1]+s1*(xyz_list[0*3+1]-xyz_list[1*3+1]); 3426 xyz_zero[3*normal_orientation+2]=xyz_list[1*3+2]+s1*(xyz_list[0*3+2]-xyz_list[1*3+2]); 3427 3428 /*New point 2*/ 3429 xyz_zero[3*(1-normal_orientation)+0]=xyz_list[1*3+0]+s2*(xyz_list[2*3+0]-xyz_list[1*3+0]); 3430 xyz_zero[3*(1-normal_orientation)+1]=xyz_list[1*3+1]+s2*(xyz_list[2*3+1]-xyz_list[1*3+1]); 3431 xyz_zero[3*(1-normal_orientation)+2]=xyz_list[1*3+2]+s2*(xyz_list[2*3+2]-xyz_list[1*3+2]); 3432 3433 /*New point 3*/ 3434 xyz_zero[3*(2+1-normal_orientation)+0]=xyz_list[4*3+0]+s1*(xyz_list[3*3+0]-xyz_list[4*3+0]); 3435 xyz_zero[3*(2+1-normal_orientation)+1]=xyz_list[4*3+1]+s1*(xyz_list[3*3+1]-xyz_list[4*3+1]); 3436 xyz_zero[3*(2+1-normal_orientation)+2]=xyz_list[4*3+2]+s1*(xyz_list[3*3+2]-xyz_list[4*3+2]); 3437 3438 /*New point 4*/ 3439 xyz_zero[3*(2+normal_orientation)+0]=xyz_list[4*3+0]+s2*(xyz_list[5*3+0]-xyz_list[4*3+0]); 3440 xyz_zero[3*(2+normal_orientation)+1]=xyz_list[4*3+1]+s2*(xyz_list[5*3+1]-xyz_list[4*3+1]); 3441 xyz_zero[3*(2+normal_orientation)+2]=xyz_list[4*3+2]+s2*(xyz_list[5*3+2]-xyz_list[4*3+2]); 3442 } 3443 else if(levelset[0]==0. && levelset[1]==0.){ //front is on point 0 and 1 3444 xyz_zero[3*0+0]=xyz_list[0*3+0]; 3445 xyz_zero[3*0+1]=xyz_list[0*3+1]; 3446 xyz_zero[3*0+2]=xyz_list[0*3+2]; 3447 3448 /*New point 2*/ 3449 xyz_zero[3*1+0]=xyz_list[1*3+0]; 3450 xyz_zero[3*1+1]=xyz_list[1*3+1]; 3451 xyz_zero[3*1+2]=xyz_list[1*3+2]; 3452 3453 /*New point 3*/ 3454 xyz_zero[3*2+0]=xyz_list[4*3+0]; 3455 xyz_zero[3*2+1]=xyz_list[4*3+1]; 3456 xyz_zero[3*2+2]=xyz_list[4*3+2]; 3457 3458 /*New point 4*/ 3459 xyz_zero[3*3+0]=xyz_list[3*3+0]; 3460 xyz_zero[3*3+1]=xyz_list[3*3+1]; 3461 xyz_zero[3*3+2]=xyz_list[3*3+2]; 3462 } 3463 else if(levelset[0]==0. && levelset[2]==0.){ //front is on point 0 and 1 3464 xyz_zero[3*0+0]=xyz_list[2*3+0]; 3465 xyz_zero[3*0+1]=xyz_list[2*3+1]; 3466 xyz_zero[3*0+2]=xyz_list[2*3+2]; 3467 3468 /*New point 2*/ 3469 xyz_zero[3*1+0]=xyz_list[0*3+0]; 3470 xyz_zero[3*1+1]=xyz_list[0*3+1]; 3471 xyz_zero[3*1+2]=xyz_list[0*3+2]; 3472 3473 /*New point 3*/ 3474 xyz_zero[3*2+0]=xyz_list[3*3+0]; 3475 xyz_zero[3*2+1]=xyz_list[3*3+1]; 3476 xyz_zero[3*2+2]=xyz_list[3*3+2]; 3477 3478 /*New point 4*/ 3479 xyz_zero[3*3+0]=xyz_list[5*3+0]; 3480 xyz_zero[3*3+1]=xyz_list[5*3+1]; 3481 xyz_zero[3*3+2]=xyz_list[5*3+2]; 3482 } 3483 else if(levelset[1]==0. && levelset[2]==0.){ //front is on point 0 and 1 3484 xyz_zero[3*0+0]=xyz_list[1*3+0]; 3485 xyz_zero[3*0+1]=xyz_list[1*3+1]; 3486 xyz_zero[3*0+2]=xyz_list[1*3+2]; 3487 3488 /*New point 2*/ 3489 xyz_zero[3*1+0]=xyz_list[2*3+0]; 3490 xyz_zero[3*1+1]=xyz_list[2*3+1]; 3491 xyz_zero[3*1+2]=xyz_list[2*3+2]; 3492 3493 /*New point 3*/ 3494 xyz_zero[3*2+0]=xyz_list[5*3+0]; 3495 xyz_zero[3*2+1]=xyz_list[5*3+1]; 3496 xyz_zero[3*2+2]=xyz_list[5*3+2]; 3497 3498 /*New point 4*/ 3499 xyz_zero[3*3+0]=xyz_list[4*3+0]; 3500 xyz_zero[3*3+1]=xyz_list[4*3+1]; 3501 xyz_zero[3*3+2]=xyz_list[4*3+2]; 3502 } 3503 else _error_("Case not covered"); 3504 3505 /*Assign output pointer*/ 3506 *pxyz_zero= xyz_zero; 2756 3507 } 2757 3508 /*}}}*/ … … 2763 3514 /*}}}*/ 2764 3515 #endif 2765 2766 void Penta::ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index){/*{{{*/2767 2768 int vertexpidlist[NUMVERTICES];2769 IssmDouble grad_list[NUMVERTICES];2770 Input* grad_input=NULL;2771 Input* input=NULL;2772 2773 if(enum_type==MaterialsRheologyBbarEnum){2774 input=(Input*)inputs->GetInput(MaterialsRheologyBEnum);2775 }2776 else if(enum_type==DamageDbarEnum){2777 input=(Input*)inputs->GetInput(DamageDEnum);2778 }2779 else{2780 input=inputs->GetInput(enum_type);2781 }2782 if (!input) _error_("Input " << EnumToStringx(enum_type) << " not found");2783 if (input->ObjectEnum()!=ControlInputEnum) _error_("Input " << EnumToStringx(enum_type) << " is not a ControlInput");2784 2785 GradientIndexing(&vertexpidlist[0],control_index);2786 for(int i=0;i<NUMVERTICES;i++) grad_list[i]=gradient[vertexpidlist[i]];2787 grad_input=new PentaInput(GradientEnum,grad_list,P1Enum);2788 ((ControlInput*)input)->SetGradient(grad_input);2789 2790 }/*}}}*/2791 void Penta::ControlToVectors(Vector<IssmPDouble>* vector_control, Vector<IssmPDouble>* vector_gradient,int control_enum){/*{{{*/2792 2793 Input* input=NULL;2794 2795 if(control_enum==MaterialsRheologyBbarEnum){2796 input=(Input*)inputs->GetInput(MaterialsRheologyBEnum);2797 }2798 else if(control_enum==DamageDbarEnum){2799 input=(Input*)inputs->GetInput(DamageDEnum);2800 }2801 else{2802 input=inputs->GetInput(control_enum);2803 }2804 if (!input) _error_("Input " << EnumToStringx(control_enum) << " not found");2805 if (input->ObjectEnum()!=ControlInputEnum) _error_("Input " << EnumToStringx(control_enum) << " is not a ControlInput");2806 2807 int sidlist[NUMVERTICES];2808 int connectivity[NUMVERTICES];2809 IssmPDouble values[NUMVERTICES];2810 IssmPDouble gradients[NUMVERTICES];2811 IssmDouble value,gradient;2812 2813 this->GetVerticesConnectivityList(&connectivity[0]);2814 this->GetVerticesSidList(&sidlist[0]);2815 2816 GaussPenta* gauss=new GaussPenta();2817 for (int iv=0;iv<NUMVERTICES;iv++){2818 gauss->GaussVertex(iv);2819 2820 ((ControlInput*)input)->GetInputValue(&value,gauss);2821 ((ControlInput*)input)->GetGradientValue(&gradient,gauss);2822 2823 values[iv] = reCast<IssmPDouble>(value)/reCast<IssmPDouble>(connectivity[iv]);2824 gradients[iv] = reCast<IssmPDouble>(gradient)/reCast<IssmPDouble>(connectivity[iv]);2825 }2826 delete gauss;2827 2828 vector_control->SetValues(NUMVERTICES,&sidlist[0],&values[0],ADD_VAL);2829 vector_gradient->SetValues(NUMVERTICES,&sidlist[0],&gradients[0],ADD_VAL);2830 2831 }/*}}}*/2832 void Penta::InputControlUpdate(IssmDouble scalar,bool save_parameter){/*{{{*/2833 2834 /*Intermediary*/2835 int num_controls;2836 int* control_type=NULL;2837 Input* input=NULL;2838 2839 /*retrieve some parameters: */2840 this->parameters->FindParam(&num_controls,InversionNumControlParametersEnum);2841 this->parameters->FindParam(&control_type,NULL,InversionControlParametersEnum);2842 2843 for(int i=0;i<num_controls;i++){2844 2845 if(control_type[i]==MaterialsRheologyBbarEnum){2846 if (!IsOnBase()) goto cleanup_and_return;2847 input=(Input*)this->inputs->GetInput(MaterialsRheologyBEnum); _assert_(input);2848 }2849 else if(control_type[i]==DamageDbarEnum){2850 if (!IsOnBase()) goto cleanup_and_return;2851 input=(Input*)this->inputs->GetInput(DamageDEnum); _assert_(input);2852 }2853 else{2854 input=(Input*)this->inputs->GetInput(control_type[i]); _assert_(input);2855 }2856 if(input->ObjectEnum()!=ControlInputEnum) _error_("input " << EnumToStringx(control_type[i]) << " is not a ControlInput");2857 2858 ((ControlInput*)input)->UpdateValue(scalar);2859 ((ControlInput*)input)->Constrain();2860 if (save_parameter) ((ControlInput*)input)->SaveValue();2861 2862 if(control_type[i]==MaterialsRheologyBbarEnum){2863 this->InputExtrude(MaterialsRheologyBEnum);2864 }2865 else if(control_type[i]==DamageDbarEnum){2866 this->InputExtrude(DamageDEnum);2867 }2868 }2869 2870 /*Clean up and return*/2871 cleanup_and_return:2872 xDelete<int>(control_type);2873 }2874 /*}}}*/2875 void Penta::GetVectorFromControlInputs(Vector<IssmDouble>* vector,int control_enum,int control_index,const char* data){/*{{{*/2876 2877 int vertexpidlist[NUMVERTICES];2878 2879 /*Get out if this is not an element input*/2880 if(!IsInput(control_enum)) return;2881 2882 /*Prepare index list*/2883 GradientIndexing(&vertexpidlist[0],control_index);2884 2885 /*Get input (either in element or material)*/2886 if(control_enum==MaterialsRheologyBbarEnum) control_enum=MaterialsRheologyBEnum;2887 Input* input=inputs->GetInput(control_enum);2888 if(!input) _error_("Input " << EnumToStringx(control_enum) << " not found in element");2889 2890 /*Check that it is a ControlInput*/2891 if (input->ObjectEnum()!=ControlInputEnum){2892 _error_("input " << EnumToStringx(control_enum) << " is not a ControlInput");2893 }2894 2895 ((ControlInput*)input)->GetVectorFromInputs(vector,&vertexpidlist[0],data);2896 }2897 /*}}}*/2898 void Penta::SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index){/*{{{*/2899 2900 IssmDouble values[NUMVERTICES];2901 int vertexpidlist[NUMVERTICES],control_init;2902 2903 /*Specific case for depth averaged quantities*/2904 control_init=control_enum;2905 if(control_enum==MaterialsRheologyBbarEnum){2906 control_enum=MaterialsRheologyBEnum;2907 if(!IsOnBase()) return;2908 }2909 if(control_enum==DamageDbarEnum){2910 control_enum=DamageDEnum;2911 if(!IsOnBase()) return;2912 }2913 2914 /*Get out if this is not an element input*/2915 if(!IsInput(control_enum)) return;2916 2917 /*Prepare index list*/2918 GradientIndexing(&vertexpidlist[0],control_index);2919 2920 /*Get values on vertices*/2921 for(int i=0;i<NUMVERTICES;i++){2922 values[i]=vector[vertexpidlist[i]];2923 }2924 Input* new_input = new PentaInput(control_enum,values,P1Enum);2925 Input* input=(Input*)this->inputs->GetInput(control_enum); _assert_(input);2926 if(input->ObjectEnum()!=ControlInputEnum){2927 _error_("input " << EnumToStringx(control_enum) << " is not a ControlInput");2928 }2929 2930 ((ControlInput*)input)->SetInput(new_input);2931 2932 if(control_init==MaterialsRheologyBbarEnum){2933 this->InputExtrude(control_enum);2934 }2935 if(control_init==DamageDbarEnum){2936 this->InputExtrude(control_enum);2937 }2938 }2939 /*}}}*/2940 3516 2941 3517 #ifdef _HAVE_DAKOTA_ … … 2982 3558 /*hydrostatic equilibrium: */ 2983 3559 IssmDouble rho_ice,rho_water,di; 2984 rho_ice=this->matpar->Get RhoIce();2985 rho_water=this->matpar->Get RhoWater();3560 rho_ice=this->matpar->GetMaterialParameter(MaterialsRhoIceEnum); 3561 rho_water=this->matpar->GetMaterialParameter(MaterialsRhoSeawaterEnum); 2986 3562 2987 3563 di=rho_ice/rho_water; … … 3079 3655 /*}}}*/ 3080 3656 #endif 3081 void Penta::GetSolutionFromInputsOneDof(Vector<IssmDouble>* solution, int enum_type){/*{{{*/3082 3083 const int numdof=NDOF1*NUMVERTICES;3084 3085 int i;3086 int* doflist=NULL;3087 IssmDouble values[numdof];3088 IssmDouble enum_value;3089 GaussPenta *gauss=NULL;3090 3091 /*Get dof list: */3092 GetDofList(&doflist,NoneApproximationEnum,GsetEnum);3093 Input* enum_input=inputs->GetInput(enum_type); _assert_(enum_input);3094 3095 gauss=new GaussPenta();3096 for(i=0;i<NUMVERTICES;i++){3097 /*Recover temperature*/3098 gauss->GaussVertex(i);3099 enum_input->GetInputValue(&enum_value,gauss);3100 values[i]=enum_value;3101 }3102 3103 /*Add value to global vector*/3104 solution->SetValues(numdof,doflist,values,INS_VAL);3105 3106 /*Free ressources:*/3107 delete gauss;3108 xDelete<int>(doflist);3109 }3110 /*}}}*/3111 void Penta::MigrateGroundingLine(IssmDouble* phi_ungrounding){/*{{{*/3112 3113 int i,migration_style;3114 IssmDouble bed_hydro,yts;3115 IssmDouble rho_water,rho_ice,density;3116 IssmDouble h[NUMVERTICES],s[NUMVERTICES],b[NUMVERTICES],r[NUMVERTICES];3117 IssmDouble melting[NUMVERTICES],phi[NUMVERTICES];3118 3119 if(!IsOnBase()) return;3120 3121 /*Recover info at the vertices: */3122 parameters->FindParam(&migration_style,GroundinglineMigrationEnum);3123 parameters->FindParam(&yts,ConstantsYtsEnum);3124 GetInputListOnVertices(&h[0],ThicknessEnum);3125 GetInputListOnVertices(&s[0],SurfaceEnum);3126 GetInputListOnVertices(&b[0],BaseEnum);3127 GetInputListOnVertices(&r[0],BedEnum);3128 GetInputListOnVertices(&phi[0],MaskGroundediceLevelsetEnum);3129 rho_water = matpar->GetRhoWater();3130 rho_ice = matpar->GetRhoIce();3131 density = rho_ice/rho_water;3132 3133 /*go through vertices, and update inputs, considering them to be PentaVertex type: */3134 for(i=0;i<NUMVERTICES;i++){3135 /*Ice shelf: if bed below bathymetry, impose it at the bathymetry and update surface, elso do nothing */3136 if(phi[i]<=0){3137 if(b[i]<=r[i]){3138 b[i] = r[i];3139 s[i] = b[i]+h[i];3140 }3141 }3142 /*Ice sheet: if hydrostatic bed above bathymetry, ice sheet starts to unground, elso do nothing */3143 /*Change only if AggressiveMigration or if the ice sheet is in contact with the ocean*/3144 else{3145 bed_hydro=-density*h[i];3146 if(bed_hydro>r[i]){3147 /*Unground only if the element is connected to the ice shelf*/3148 if(migration_style==AggressiveMigrationEnum || migration_style==SubelementMigrationEnum || migration_style==SubelementMigration2Enum){3149 s[i] = (1-density)*h[i];3150 b[i] = -density*h[i];3151 }3152 else if(migration_style==SoftMigrationEnum && phi_ungrounding[vertices[i]->Pid()]<0.){3153 s[i] = (1-density)*h[i];3154 b[i] = -density*h[i];3155 }3156 else{3157 if(migration_style!=SoftMigrationEnum) _error_("Error: migration should be Aggressive, Soft or Subelement");3158 }3159 }3160 }3161 }3162 3163 /*Recalculate phi*/3164 for(i=0;i<NUMVERTICES;i++){3165 if(migration_style==SoftMigrationEnum){3166 bed_hydro=-density*h[i];3167 if(phi[i]<0. || bed_hydro<=r[i] || phi_ungrounding[vertices[i]->Pid()]<0.){3168 phi[i]=h[i]+r[i]/density;3169 }3170 }3171 else phi[i]=h[i]+r[i]/density;3172 }3173 this->inputs->AddInput(new PentaInput(MaskGroundediceLevelsetEnum,&phi[0],P1Enum));3174 this->InputExtrude(MaskGroundediceLevelsetEnum);3175 3176 /*Update inputs*/3177 this->inputs->AddInput(new PentaInput(SurfaceEnum,&s[0],P1Enum));3178 this->inputs->AddInput(new PentaInput(BaseEnum,&b[0],P1Enum));3179 3180 /*Extrude inputs*/3181 this->InputExtrude(SurfaceEnum);3182 this->InputExtrude(BaseEnum);3183 }3184 /*}}}*/3185 void Penta::PotentialUngrounding(Vector<IssmDouble>* potential_ungrounding){/*{{{*/3186 3187 IssmDouble h[NUMVERTICES],r[NUMVERTICES],gl[NUMVERTICES];3188 IssmDouble bed_hydro;3189 IssmDouble rho_water,rho_ice,density;3190 3191 /*material parameters: */3192 rho_water=matpar->GetRhoWater();3193 rho_ice=matpar->GetRhoIce();3194 density=rho_ice/rho_water;3195 GetInputListOnVertices(&h[0],ThicknessEnum);3196 GetInputListOnVertices(&r[0],BedEnum);3197 GetInputListOnVertices(&gl[0],MaskGroundediceLevelsetEnum);3198 3199 /*go through vertices, and figure out which ones are on the ice sheet, and want to unground: */3200 for(int i=0;i<NUMVERTICES;i++){3201 /*Find if grounded vertices want to start floating*/3202 if (gl[i]>0.){3203 bed_hydro=-density*h[i];3204 if(bed_hydro>r[i]){3205 /*Vertex that could potentially unground, flag it*/3206 potential_ungrounding->SetValue(vertices[i]->Pid(),1,INS_VAL);3207 }3208 }3209 }3210 }3211 /*}}}*/3212 int Penta::UpdatePotentialUngrounding(IssmDouble* vertices_potentially_ungrounding,Vector<IssmDouble>* vec_nodes_on_iceshelf,IssmDouble* nodes_on_iceshelf){/*{{{*/3213 3214 int i;3215 int nflipped=0;3216 3217 /*Go through nodes, and whoever is on the potential_ungrounding, ends up in nodes_on_iceshelf: */3218 for(i=0;i<NUMVERTICES;i++){3219 if (reCast<bool,IssmDouble>(vertices_potentially_ungrounding[vertices[i]->Pid()])){3220 vec_nodes_on_iceshelf->SetValue(vertices[i]->Pid(),-1.,INS_VAL);3221 3222 /*If node was not on ice shelf, we flipped*/3223 if(nodes_on_iceshelf[vertices[i]->Pid()]>=0.){3224 nflipped++;3225 }3226 }3227 }3228 return nflipped;3229 }3230 /*}}}*/ -
issm/trunk/src/c/classes/Elements/Penta.h
r18301 r19105 43 43 int ObjectEnum(); 44 44 /*}}}*/ 45 /*Update virtual functions definitions: {{{*/ 46 void InputUpdateFromVector(IssmDouble* vector, int name, int type); 47 #ifdef _HAVE_DAKOTA_ 48 void InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type); 49 void InputUpdateFromMatrixDakota(IssmDouble* matrix, int nows, int ncols, int name, int type); 50 #endif 51 void InputUpdateFromIoModel(int index, IoModel* iomodel); 52 /*}}}*/ 53 /*Element virtual functions definitions: {{{*/ 54 IssmDouble CharacteristicLength(void){_error_("not implemented yet");}; 55 void ComputeBasalStress(Vector<IssmDouble>* sigma_b); 56 void ComputeSigmaNN(){_error_("not implemented yet");}; 57 void ComputeStressTensor(); 58 void ComputeDeviatoricStressTensor(); 59 void Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 60 void ElementSizes(IssmDouble* hx,IssmDouble* hy,IssmDouble* hz); 61 int FiniteElement(void); 62 void FSContactMigration(Vector<IssmDouble>* vertexgrounded,Vector<IssmDouble>* vertexfloating); 63 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Materials* materials,Parameters* parameters); 64 void ResetHooks(); 65 void Delta18oParameterization(void); 66 Penta* GetUpperPenta(void); 67 Penta* GetLowerPenta(void); 68 Penta* GetSurfacePenta(void); 69 Penta* GetBasalPenta(void); 70 Element* GetUpperElement(void); 71 Element* GetBasalElement(void); 72 void GetGroundedPart(int* point1,IssmDouble* fraction1, IssmDouble* fraction2,bool* mainlyfloating); 73 IssmDouble GetGroundedPortion(IssmDouble* xyz_list); 74 int GetNodeIndex(Node* node); 75 int GetNumberOfNodes(void); 76 int GetNumberOfNodes(int enum_type); 77 int GetNumberOfVertices(void); 78 void GetSolutionFromInputsOneDof(Vector<IssmDouble>* solution,int enum_type); 79 void GetVerticesCoordinatesBase(IssmDouble** pxyz_list); 80 void GetVerticesCoordinatesTop(IssmDouble** pxyz_list); 81 82 void InputDepthAverageAtBase(int enum_type,int average_enum_type); 83 void InputScale(int enum_type,IssmDouble scale_factor); 84 int NumberofNodesVelocity(void); 85 int NumberofNodesPressure(void); 86 int VelocityInterpolation(); 87 int PressureInterpolation(); 88 int TensorInterpolation(){_error_("not implemented yet");}; 89 bool IsZeroLevelset(int levelset_enum); 90 bool IsIcefront(void); 91 bool IsFaceOnBoundary(void){_error_("not implemented yet");}; 92 void ZeroLevelsetCoordinates(IssmDouble** pxyz_zero,IssmDouble* xyz_list,int levelsetenum); 93 void GetIcefrontCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum){_error_("not implemented yet");}; 94 void GetLevelCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum,IssmDouble level){_error_("not implemented yet");}; 95 void PositiveDegreeDay(IssmDouble* pdds,IssmDouble* pds,IssmDouble signorm); 96 void ReduceMatrices(ElementMatrix* Ke,ElementVector* pe); 97 void ResetFSBasalBoundaryCondition(void); 98 void SetTemporaryElementType(int element_type_in); 99 Element* SpawnBasalElement(void); 100 Element* SpawnTopElement(void); 101 IssmDouble SurfaceArea(void); 102 void Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type,int finitelement); 103 int NodalValue(IssmDouble* pvalue, int index, int natureofdataenum); 104 IssmDouble TimeAdapt(); 105 void ValueP1OnGauss(IssmDouble* pvalue,IssmDouble* values,Gauss* gauss); 106 void ValueP1DerivativesOnGauss(IssmDouble* dvalue,IssmDouble* values,IssmDouble* xyz_list,Gauss* gauss); 107 int VertexConnectivity(int vertexindex); 108 void VerticalSegmentIndices(int** pindices,int* pnumseg); 109 void ViscousHeating(IssmDouble* pphi,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vz_input); 110 111 void AverageOntoPartition(Vector<IssmDouble>* partition_contributions,Vector<IssmDouble>* partition_areas,IssmDouble* vertex_response,IssmDouble* qmu_part); 112 IssmDouble IceVolume(void); 113 IssmDouble IceVolumeAboveFloatation(void); 114 IssmDouble TotalSmb(void); 115 IssmDouble MassFlux(IssmDouble* segment); 116 IssmDouble MassFlux(IssmDouble x1,IssmDouble y1, IssmDouble x2, IssmDouble y2,int segment_id); 117 void ElementResponse(IssmDouble* presponse,int response_enum); 118 119 #ifdef _HAVE_GIA_ 120 void GiaDeflection(Vector<IssmDouble>* wg,Vector<IssmDouble>* dwgdt,IssmDouble* x,IssmDouble* y); 121 #endif 122 123 void GetVectorFromControlInputs(Vector<IssmDouble>* gradient,int control_enum,int control_index,const char* data); 124 void SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index); 125 void ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index); 126 void ControlToVectors(Vector<IssmPDouble>* vector_control, Vector<IssmPDouble>* vector_gradient,int control_enum); 127 void InputControlUpdate(IssmDouble scalar,bool save_parameter); 128 IssmDouble Misfit(int modelenum,int observationenum,int weightsenum){_error_("not implemented yet");}; 129 IssmDouble MisfitArea(int weightsenum){_error_("not implemented yet");}; 130 131 void MigrateGroundingLine(IssmDouble* sheet_ungrounding); 132 void PotentialUngrounding(Vector<IssmDouble>* potential_sheet_ungrounding); 133 int UpdatePotentialUngrounding(IssmDouble* potential_sheet_ungrounding,Vector<IssmDouble>* vec_nodes_on_iceshelf,IssmDouble* nodes_on_iceshelf); 134 /*}}}*/ 135 /*Penta specific routines:{{{*/ 45 /*Penta routines:{{{*/ 136 46 void AddBasalInput(int input_enum, IssmDouble* values, int interpolation_enum); 137 47 void AddInput(int input_enum, IssmDouble* values, int interpolation_enum); 138 void NormalBase(IssmDouble* bed_normal, IssmDouble* xyz_list); 139 void NormalSection(IssmDouble* normal,IssmDouble* xyz_list); 140 void NormalTop(IssmDouble* bed_normal, IssmDouble* xyz_list); 48 void AverageOntoPartition(Vector<IssmDouble>* partition_contributions,Vector<IssmDouble>* partition_areas,IssmDouble* vertex_response,IssmDouble* qmu_part); 49 IssmDouble CharacteristicLength(void){_error_("not implemented yet");}; 50 void CalvingRateLevermann(); 51 void CalvingRatePi(); 52 void ComputeBasalStress(Vector<IssmDouble>* sigma_b); 53 void ComputeDeviatoricStressTensor(); 54 void ComputeSigmaNN(){_error_("not implemented yet");}; 55 void ComputeStressTensor(); 56 void Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 57 void ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index); 58 void ControlToVectors(Vector<IssmPDouble>* vector_control, Vector<IssmPDouble>* vector_gradient,int control_enum); 141 59 ElementMatrix* CreateBasalMassMatrix(void); 60 void Delta18oParameterization(void); 61 void MungsmtpParameterization(void); 62 void ElementResponse(IssmDouble* presponse,int response_enum); 63 void ElementSizes(IssmDouble* hx,IssmDouble* hy,IssmDouble* hz); 64 int FiniteElement(void); 65 void FSContactMigration(Vector<IssmDouble>* vertexgrounded,Vector<IssmDouble>* vertexfloating); 142 66 void GetAreaCoordinates(IssmDouble *area_coordinates,IssmDouble* xyz_zero,IssmDouble* xyz_list,int numpoints); 67 Element* GetBasalElement(void); 68 Penta* GetBasalPenta(void); 143 69 int GetElementType(void); 70 void GetGroundedPart(int* point1,IssmDouble* fraction1, IssmDouble* fraction2,bool* mainlyfloating); 71 IssmDouble GetGroundedPortion(IssmDouble* xyz_list); 72 void GetIcefrontCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum); 144 73 void GetInputValue(IssmDouble* pvalue,Node* node,int enumtype); 74 void GetLevelCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum,IssmDouble level){_error_("not implemented yet");}; 75 void GetLevelsetPositivePart(int* point1,IssmDouble* fraction1,IssmDouble* fraction2, bool* mainlynegative,IssmDouble* levelsetvalues){_error_("not implemented yet");}; 145 76 Node* GetNode(int node_number); 146 void InputExtrude(int enum_type); 77 int GetNodeIndex(Node* node); 78 int GetNumberOfNodes(void); 79 int GetNumberOfNodes(int enum_type); 80 int GetNumberOfVertices(void); 81 Penta* GetLowerPenta(void); 82 void GetSolutionFromInputsOneDof(Vector<IssmDouble>* solution,int enum_type); 83 Penta* GetSurfacePenta(void); 84 Element* GetUpperElement(void); 85 Penta* GetUpperPenta(void); 86 void GetVectorFromControlInputs(Vector<IssmDouble>* gradient,int control_enum,int control_index,const char* data,bool onsid); 87 void GetVerticesCoordinatesBase(IssmDouble** pxyz_list); 88 void GetVerticesCoordinatesTop(IssmDouble** pxyz_list); 89 IssmDouble IceMass(void); 90 IssmDouble IceVolume(void); 91 IssmDouble IceVolumeAboveFloatation(void); 92 void InputControlUpdate(IssmDouble scalar,bool save_parameter); 93 void InputDepthAverageAtBase(int enum_type,int average_enum_type); 94 void InputExtrude(int enum_type,int start); 95 void InputScale(int enum_type,IssmDouble scale_factor); 96 void InputUpdateFromIoModel(int index, IoModel* iomodel); 147 97 void InputUpdateFromSolutionOneDof(IssmDouble* solutiong,int enum_type); 148 98 void InputUpdateFromSolutionOneDofCollapsed(IssmDouble* solutiong,int enum_type); 99 void InputUpdateFromVector(IssmDouble* vector, int name, int type); 100 bool IsFaceOnBoundary(void){_error_("not implemented yet");}; 101 bool IsIcefront(void); 102 bool IsNodeOnShelfFromFlags(IssmDouble* flags); 103 bool IsOnBase(void); 149 104 bool IsOnSurface(void); 150 bool IsOnBase(void); 151 bool IsNodeOnShelfFromFlags(IssmDouble* flags); 105 bool IsZeroLevelset(int levelset_enum); 152 106 void JacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss); 107 void JacobianDeterminantBase(IssmDouble* pJdet,IssmDouble* xyz_list_base,Gauss* gauss); 153 108 void JacobianDeterminantLine(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss); 154 109 void JacobianDeterminantSurface(IssmDouble* pJdet, IssmDouble* xyz_list,Gauss* gauss); 155 void JacobianDeterminantBase(IssmDouble* pJdet,IssmDouble* xyz_list_base,Gauss* gauss);156 110 void JacobianDeterminantTop(IssmDouble* pJdet,IssmDouble* xyz_list_base,Gauss* gauss); 111 IssmDouble Masscon(IssmDouble* levelset){_error_("not implemented yet");}; 112 IssmDouble MassFlux(IssmDouble* segment); 113 IssmDouble MassFlux(IssmDouble x1,IssmDouble y1, IssmDouble x2, IssmDouble y2,int segment_id); 114 IssmDouble MinEdgeLength(IssmDouble* xyz_list); 115 IssmDouble Misfit(int modelenum,int observationenum,int weightsenum){_error_("not implemented yet");}; 116 IssmDouble MisfitArea(int weightsenum){_error_("not implemented yet");}; 157 117 Gauss* NewGauss(void); 158 118 Gauss* NewGauss(int order); … … 164 124 Gauss* NewGaussTop(int order); 165 125 void NodalFunctions(IssmDouble* basis,Gauss* gauss); 126 void NodalFunctionsDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss); 127 void NodalFunctionsDerivativesVelocity(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss); 128 void NodalFunctionsMINIDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss); 129 void NodalFunctionsPressure(IssmDouble* basis,Gauss* gauss); 166 130 void NodalFunctionsP1(IssmDouble* basis,Gauss* gauss); 131 void NodalFunctionsP1Derivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss); 167 132 void NodalFunctionsP2(IssmDouble* basis,Gauss* gauss); 168 void NodalFunctionsDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss); 169 void NodalFunctionsP1Derivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss); 170 void NodalFunctionsMINIDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss); 171 void NodalFunctionsDerivativesVelocity(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss); 133 void NodalFunctionsTensor(IssmDouble* basis,Gauss* gauss); 172 134 void NodalFunctionsVelocity(IssmDouble* basis,Gauss* gauss); 173 void NodalFunctionsPressure(IssmDouble* basis,Gauss* gauss); 174 void NodalFunctionsTensor(IssmDouble* basis,Gauss* gauss); 175 IssmDouble MinEdgeLength(IssmDouble* xyz_list); 135 void NormalBase(IssmDouble* bed_normal, IssmDouble* xyz_list); 136 void NormalSection(IssmDouble* normal,IssmDouble* xyz_list); 137 void NormalTop(IssmDouble* bed_normal, IssmDouble* xyz_list); 138 int NodalValue(IssmDouble* pvalue, int index, int natureofdataenum); 139 int NumberofNodesPressure(void); 140 int NumberofNodesVelocity(void); 141 void PositiveDegreeDay(IssmDouble* pdds,IssmDouble* pds,IssmDouble signorm,bool ismungsm); 142 void PotentialUngrounding(Vector<IssmDouble>* potential_sheet_ungrounding); 143 int PressureInterpolation(); 144 void ReduceMatrices(ElementMatrix* Ke,ElementVector* pe); 145 void ResetFSBasalBoundaryCondition(void); 146 void ResetHooks(); 176 147 void SetClone(int* minranks); 148 void SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index); 149 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Materials* materials,Parameters* parameters); 150 void SetTemporaryElementType(int element_type_in); 151 Element* SpawnBasalElement(void); 152 Element* SpawnTopElement(void); 177 153 Tria* SpawnTria(int index1,int index2,int index3); 178 154 IssmDouble StabilizationParameter(IssmDouble u, IssmDouble v, IssmDouble w, IssmDouble diameter, IssmDouble kappa); 179 155 void StressIntensityFactor(); 156 void StrainRateparallel(); 157 void StrainRateperpendicular(); 158 IssmDouble SurfaceArea(void); 159 int TensorInterpolation(){_error_("not implemented yet");}; 160 IssmDouble TimeAdapt(); 161 IssmDouble TotalSmb(void); 162 void Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type,int finitelement); 180 163 void UpdateConstraintsExtrudeFromBase(void); 181 164 void UpdateConstraintsExtrudeFromTop(void); 165 int UpdatePotentialUngrounding(IssmDouble* potential_sheet_ungrounding,Vector<IssmDouble>* vec_nodes_on_iceshelf,IssmDouble* nodes_on_iceshelf); 166 void ValueP1DerivativesOnGauss(IssmDouble* dvalue,IssmDouble* values,IssmDouble* xyz_list,Gauss* gauss); 167 void ValueP1OnGauss(IssmDouble* pvalue,IssmDouble* values,Gauss* gauss); 168 int VelocityInterpolation(); 169 int VertexConnectivity(int vertexindex); 170 void VerticalSegmentIndices(int** pindices,int* pnumseg); 171 void ViscousHeating(IssmDouble* pphi,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vz_input); 172 void ZeroLevelsetCoordinates(IssmDouble** pxyz_zero,IssmDouble* xyz_list,int levelsetenum); 173 174 #ifdef _HAVE_DAKOTA_ 175 void InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type); 176 void InputUpdateFromMatrixDakota(IssmDouble* matrix, int nows, int ncols, int name, int type); 177 #endif 178 179 #ifdef _HAVE_GIA_ 180 void GiaDeflection(Vector<IssmDouble>* wg,Vector<IssmDouble>* dwgdt,IssmDouble* x,IssmDouble* y); 181 #endif 182 182 /*}}}*/ 183 183 }; -
issm/trunk/src/c/classes/Elements/PentaRef.cpp
r18301 r19105 1 /*!\file PentaRef.c 1 /*!\file PentaRef.cpp 2 2 * \brief: implementation of the PentaRef object 3 3 */ … … 26 26 #define NUMNODESP2b 19 27 27 #define NUMNODESP2xP4 30 28 #define NUMNODESMAX 30 28 29 29 30 /*Object constructors and destructor*/ … … 36 37 37 38 /*Reference Element numerics*/ 39 void PentaRef::BasalNodeIndices(int* pnumindices,int** pindices,int finiteelement){/*{{{*/ 40 41 /*Output*/ 42 int numindices; 43 int* indices = NULL; 44 45 switch(finiteelement){ 46 case P1Enum: case P1DGEnum: 47 numindices = 3; 48 indices = xNew<int>(numindices); 49 indices[0] = 0; 50 indices[1] = 1; 51 indices[2] = 2; 52 break; 53 case P1bubbleEnum: case P1bubblecondensedEnum: 54 numindices = 3; 55 indices = xNew<int>(numindices); 56 indices[0] = 0; 57 indices[1] = 1; 58 indices[2] = 2; 59 break; 60 case P2xP1Enum: 61 numindices = 6; 62 indices = xNew<int>(numindices); 63 indices[0] = 0; 64 indices[1] = 1; 65 indices[2] = 2; 66 indices[3] = 6; 67 indices[4] = 7; 68 indices[5] = 8; 69 break; 70 case P1xP2Enum: 71 numindices = 3; 72 indices = xNew<int>(numindices); 73 indices[0] = 0; 74 indices[1] = 1; 75 indices[2] = 2; 76 break; 77 case P1xP3Enum: 78 numindices = 3; 79 indices = xNew<int>(numindices); 80 indices[0] = 0; 81 indices[1] = 1; 82 indices[2] = 2; 83 break; 84 case P2Enum: 85 numindices = 6; 86 indices = xNew<int>(numindices); 87 indices[0] = 0; 88 indices[1] = 1; 89 indices[2] = 2; 90 indices[3] = 9; 91 indices[4] = 10; 92 indices[5] = 11; 93 break; 94 case P2bubbleEnum: 95 numindices = 6; 96 indices = xNew<int>(numindices); 97 indices[0] = 0; 98 indices[1] = 1; 99 indices[2] = 2; 100 indices[3] = 9; 101 indices[4] = 10; 102 indices[5] = 11; 103 break; 104 case P2xP4Enum: 105 numindices = 6; 106 indices = xNew<int>(numindices); 107 indices[0] = 0; 108 indices[1] = 1; 109 indices[2] = 2; 110 indices[3] = 9; 111 indices[4] = 10; 112 indices[5] = 11; 113 break; 114 default: 115 _error_("Element type "<<EnumToStringx(finiteelement)<<" not supported yet"); 116 } 117 118 /*Assign output pointer*/ 119 *pnumindices = numindices; 120 *pindices = indices; 121 } 122 /*}}}*/ 123 void PentaRef::GetInputDerivativeValue(IssmDouble* p, IssmDouble* plist,IssmDouble* xyz_list, Gauss* gauss,int finiteelement){/*{{{*/ 124 /*From node values of parameter p (p_list[0], p_list[1], p_list[2], 125 * p_list[3], p_list[4] and p_list[4]), return parameter derivative value at 126 * gaussian point specified by gauss_coord: 127 * dp/dx=p_list[0]*dh1/dx+p_list[1]*dh2/dx+p_list[2]*dh3/dx+p_list[3]*dh4/dx+p_list[4]*dh5/dx+p_list[5]*dh6/dx; 128 * dp/dy=p_list[0]*dh1/dy+p_list[1]*dh2/dy+p_list[2]*dh3/dy+p_list[3]*dh4/dy+p_list[4]*dh5/dy+p_list[5]*dh6/dy; 129 * dp/dz=p_list[0]*dh1/dz+p_list[1]*dh2/dz+p_list[2]*dh3/dz+p_list[3]*dh4/dz+p_list[4]*dh5/dz+p_list[5]*dh6/dz; 130 * 131 * p is a vector of size 3x1 already allocated. 132 * 133 * WARNING: For a significant gain in performance, it is better to use 134 * static memory allocation instead of dynamic. 135 */ 136 137 /*Allocate derivatives of basis functions*/ 138 IssmDouble dbasis[3*NUMNODESMAX]; 139 140 /*Fetch number of nodes for this finite element*/ 141 int numnodes = this->NumberofNodes(finiteelement); 142 _assert_(numnodes<=NUMNODESMAX); 143 144 /*Get basis functions derivatives at this point*/ 145 GetNodalFunctionsDerivatives(&dbasis[0],xyz_list,gauss,finiteelement); 146 147 /*Calculate parameter for this Gauss point*/ 148 IssmDouble dpx=0.; 149 IssmDouble dpy=0.; 150 IssmDouble dpz=0.; 151 for(int i=0;i<numnodes;i++) dpx += dbasis[0*numnodes+i]*plist[i]; 152 for(int i=0;i<numnodes;i++) dpy += dbasis[1*numnodes+i]*plist[i]; 153 for(int i=0;i<numnodes;i++) dpz += dbasis[2*numnodes+i]*plist[i]; 154 155 /*Assign values*/ 156 p[0]=dpx; 157 p[1]=dpy; 158 p[2]=dpz; 159 } 160 /*}}}*/ 161 void PentaRef::GetInputValue(IssmDouble* pvalue,IssmDouble* plist,Gauss* gauss,int finiteelement){/*{{{*/ 162 /* WARNING: For a significant gain in performance, it is better to use 163 * static memory allocation instead of dynamic.*/ 164 165 /*Allocate basis functions*/ 166 IssmDouble basis[NUMNODESMAX]; 167 168 /*Fetch number of nodes for this finite element*/ 169 int numnodes = this->NumberofNodes(finiteelement); 170 _assert_(numnodes<=NUMNODESMAX); 171 172 /*Get basis functions at this point*/ 173 GetNodalFunctions(&basis[0],gauss,finiteelement); 174 175 /*Calculate parameter for this Gauss point*/ 176 IssmDouble value =0.; 177 for(int i=0;i<numnodes;i++) value += basis[i]*plist[i]; 178 179 /*Assign output pointer*/ 180 *pvalue = value; 181 } 182 /*}}}*/ 38 183 void PentaRef::GetJacobian(IssmDouble* J, IssmDouble* xyz_list,Gauss* gauss_in){/*{{{*/ 39 184 /*The Jacobian is constant over the element, discard the gaussian points. … … 48 193 /*Cast gauss to GaussPenta*/ 49 194 _assert_(gauss_in->Enum()==GaussPentaEnum); 50 GaussPenta* gauss = dynamic_cast<GaussPenta*>(gauss_in);195 GaussPenta* gauss = xDynamicCast<GaussPenta*>(gauss_in); 51 196 52 197 /*Figure out xi,eta and zi (parametric coordinates), for this gaussian point: */ … … 106 251 } 107 252 /*}}}*/ 108 void PentaRef::GetTriaJacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss){/*{{{*/109 /*The Jacobian determinant is constant over the element, discard the gaussian points.110 * J is assumed to have been allocated of size NDOF2xNDOF2.*/111 112 IssmDouble x1=xyz_list[3*0+0];113 IssmDouble y1=xyz_list[3*0+1];114 IssmDouble z1=xyz_list[3*0+2];115 IssmDouble x2=xyz_list[3*1+0];116 IssmDouble y2=xyz_list[3*1+1];117 IssmDouble z2=xyz_list[3*1+2];118 IssmDouble x3=xyz_list[3*2+0];119 IssmDouble y3=xyz_list[3*2+1];120 IssmDouble z3=xyz_list[3*2+2];121 122 /*Jdet = norm( AB ^ AC ) / (2 * area of the reference triangle), with areaRef=sqrt(3) */123 *Jdet=SQRT3/6.*pow(pow(((y2-y1)*(z3-z1)-(z2-z1)*(y3-y1)),2)+pow(((z2-z1)*(x3-x1)-(x2-x1)*(z3-z1)),2)+pow(((x2-x1)*(y3-y1)-(y2-y1)*(x3-x1)),2),0.5);124 if(*Jdet<0) _error_("negative jacobian determinant!");125 }126 /*}}}*/127 void PentaRef::GetSegmentJacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss){/*{{{*/128 /*The Jacobian determinant is constant over the element, discard the gaussian points.129 * J is assumed to have been allocated of size NDOF2xNDOF2.*/130 131 IssmDouble x1=xyz_list[3*0+0];132 IssmDouble y1=xyz_list[3*0+1];133 IssmDouble z1=xyz_list[3*0+2];134 IssmDouble x2=xyz_list[3*1+0];135 IssmDouble y2=xyz_list[3*1+1];136 IssmDouble z2=xyz_list[3*1+2];137 138 *Jdet=.5*sqrt(pow(x2-x1,2) + pow(y2-y1,2) + pow(z2-z1,2));139 if(*Jdet<0) _error_("negative jacobian determinant!");140 141 }142 /*}}}*/143 253 void PentaRef::GetJacobianInvert(IssmDouble* Jinv, IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 144 254 … … 160 270 /*Cast gauss to GaussPenta*/ 161 271 _assert_(gauss_in->Enum()==GaussPentaEnum); 162 GaussPenta* gauss = dynamic_cast<GaussPenta*>(gauss_in);272 GaussPenta* gauss = xDynamicCast<GaussPenta*>(gauss_in); 163 273 164 274 /*Get current coordinates in reference element*/ … … 365 475 /*Cast gauss to GaussPenta*/ 366 476 _assert_(gauss_in->Enum()==GaussPentaEnum); 367 GaussPenta* gauss = dynamic_cast<GaussPenta*>(gauss_in);477 GaussPenta* gauss = xDynamicCast<GaussPenta*>(gauss_in); 368 478 369 479 /*Get current coordinates in reference element*/ … … 885 995 } 886 996 /*}}}*/ 887 void PentaRef::GetInputValue(IssmDouble* pvalue,IssmDouble* plist,Gauss* gauss,int finiteelement){/*{{{*/ 888 889 /*Output*/ 890 IssmDouble value =0.; 891 892 /*Fetch number of nodes for this finite element*/ 893 int numnodes = this->NumberofNodes(finiteelement); 894 895 /*Get nodal functions*/ 896 IssmDouble* basis=xNew<IssmDouble>(numnodes); 897 GetNodalFunctions(basis, gauss,finiteelement); 898 899 /*Calculate parameter for this Gauss point*/ 900 for(int i=0;i<numnodes;i++) value += basis[i]*plist[i]; 901 902 /*Assign output pointer*/ 903 xDelete<IssmDouble>(basis); 904 *pvalue = value; 905 906 } 907 /*}}}*/ 908 void PentaRef::GetInputDerivativeValue(IssmDouble* p, IssmDouble* plist,IssmDouble* xyz_list, Gauss* gauss,int finiteelement){/*{{{*/ 909 /*From node values of parameter p (p_list[0], p_list[1], p_list[2], 910 * p_list[3], p_list[4] and p_list[4]), return parameter derivative value at 911 * gaussian point specified by gauss_coord: 912 * dp/dx=p_list[0]*dh1/dx+p_list[1]*dh2/dx+p_list[2]*dh3/dx+p_list[3]*dh4/dx+p_list[4]*dh5/dx+p_list[5]*dh6/dx; 913 * dp/dy=p_list[0]*dh1/dy+p_list[1]*dh2/dy+p_list[2]*dh3/dy+p_list[3]*dh4/dy+p_list[4]*dh5/dy+p_list[5]*dh6/dy; 914 * dp/dz=p_list[0]*dh1/dz+p_list[1]*dh2/dz+p_list[2]*dh3/dz+p_list[3]*dh4/dz+p_list[4]*dh5/dz+p_list[5]*dh6/dz; 915 * 916 * p is a vector of size 3x1 already allocated. 917 */ 918 919 /*Output*/ 920 IssmDouble dpx=0.; 921 IssmDouble dpy=0.; 922 IssmDouble dpz=0.; 923 924 /*Fetch number of nodes for this finite element*/ 925 int numnodes = this->NumberofNodes(finiteelement); 926 927 /*Get nodal functions derivatives*/ 928 IssmDouble* dbasis=xNew<IssmDouble>(3*numnodes); 929 GetNodalFunctionsDerivatives(dbasis,xyz_list,gauss,finiteelement); 930 931 /*Calculate parameter for this Gauss point*/ 932 for(int i=0;i<numnodes;i++) dpx += dbasis[0*numnodes+i]*plist[i]; 933 for(int i=0;i<numnodes;i++) dpy += dbasis[1*numnodes+i]*plist[i]; 934 for(int i=0;i<numnodes;i++) dpz += dbasis[2*numnodes+i]*plist[i]; 935 936 /*Assign values*/ 937 xDelete<IssmDouble>(dbasis); 938 p[0]=dpx; 939 p[1]=dpy; 940 p[2]=dpz; 941 997 void PentaRef::GetSegmentJacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 998 /*The Jacobian determinant is constant over the element, discard the gaussian points. 999 * J is assumed to have been allocated of size NDOF2xNDOF2.*/ 1000 1001 IssmDouble x1=xyz_list[3*0+0]; 1002 IssmDouble y1=xyz_list[3*0+1]; 1003 IssmDouble z1=xyz_list[3*0+2]; 1004 IssmDouble x2=xyz_list[3*1+0]; 1005 IssmDouble y2=xyz_list[3*1+1]; 1006 IssmDouble z2=xyz_list[3*1+2]; 1007 1008 *Jdet=.5*sqrt(pow(x2-x1,2) + pow(y2-y1,2) + pow(z2-z1,2)); 1009 if(*Jdet<0) _error_("negative jacobian determinant!"); 1010 1011 } 1012 /*}}}*/ 1013 void PentaRef::GetTriaJacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 1014 /*The Jacobian determinant is constant over the element, discard the gaussian points. 1015 * J is assumed to have been allocated of size NDOF2xNDOF2.*/ 1016 1017 IssmDouble x1=xyz_list[3*0+0]; 1018 IssmDouble y1=xyz_list[3*0+1]; 1019 IssmDouble z1=xyz_list[3*0+2]; 1020 IssmDouble x2=xyz_list[3*1+0]; 1021 IssmDouble y2=xyz_list[3*1+1]; 1022 IssmDouble z2=xyz_list[3*1+2]; 1023 IssmDouble x3=xyz_list[3*2+0]; 1024 IssmDouble y3=xyz_list[3*2+1]; 1025 IssmDouble z3=xyz_list[3*2+2]; 1026 1027 /*Jdet = norm( AB ^ AC ) / (2 * area of the reference triangle), with areaRef=sqrt(3) */ 1028 *Jdet=SQRT3/6.*pow(pow(((y2-y1)*(z3-z1)-(z2-z1)*(y3-y1)),2)+pow(((z2-z1)*(x3-x1)-(x2-x1)*(z3-z1)),2)+pow(((x2-x1)*(y3-y1)-(y2-y1)*(x3-x1)),2),0.5); 1029 if(*Jdet<0) _error_("negative jacobian determinant!"); 942 1030 } 943 1031 /*}}}*/ … … 966 1054 case OneLayerP4zEnum: return NUMNODESP2xP4+NUMNODESP1; 967 1055 case CrouzeixRaviartEnum: return NUMNODESP2b+NUMNODESP1; 1056 case LACrouzeixRaviartEnum: return NUMNODESP2b; 968 1057 default: _error_("Element type "<<EnumToStringx(finiteelement)<<" not supported yet"); 969 1058 } … … 972 1061 } 973 1062 /*}}}*/ 974 int PentaRef:: VelocityInterpolation(int fe_stokes){/*{{{*/1063 int PentaRef::PressureInterpolation(int fe_stokes){/*{{{*/ 975 1064 976 1065 switch(fe_stokes){ 977 case P1P1Enum: return P1Enum; 978 case P1P1GLSEnum: return P1Enum; 979 case MINIcondensedEnum: return P1bubbleEnum; 980 case MINIEnum: return P1bubbleEnum; 981 case TaylorHoodEnum: return P2Enum; 982 case LATaylorHoodEnum: return P2Enum; 983 case OneLayerP4zEnum: return P2xP4Enum; 984 case CrouzeixRaviartEnum:return P2bubbleEnum; 1066 case P1P1Enum: return P1Enum; 1067 case P1P1GLSEnum: return P1Enum; 1068 case MINIcondensedEnum: return P1Enum; 1069 case MINIEnum: return P1Enum; 1070 case TaylorHoodEnum: return P1Enum; 1071 case LATaylorHoodEnum: return NoneEnum; 1072 case OneLayerP4zEnum: return P1Enum; 1073 case CrouzeixRaviartEnum: return P1DGEnum; 1074 case LACrouzeixRaviartEnum: return NoneEnum; 985 1075 default: _error_("Element type "<<EnumToStringx(fe_stokes)<<" not supported yet"); 986 1076 } 987 1077 988 1078 return -1; 989 }990 /*}}}*/991 int PentaRef::PressureInterpolation(int fe_stokes){/*{{{*/992 993 switch(fe_stokes){994 case P1P1Enum: return P1Enum;995 case P1P1GLSEnum: return P1Enum;996 case MINIcondensedEnum: return P1Enum;997 case MINIEnum: return P1Enum;998 case TaylorHoodEnum: return P1Enum;999 case LATaylorHoodEnum: return NoneEnum;1000 case OneLayerP4zEnum: return P1Enum;1001 case CrouzeixRaviartEnum:return P1DGEnum;1002 default: _error_("Element type "<<EnumToStringx(fe_stokes)<<" not supported yet");1003 }1004 1005 return -1;1006 }1007 /*}}}*/1008 int PentaRef::TensorInterpolation(int fe_stokes){/*{{{*/1009 1010 switch(fe_stokes){1011 case XTaylorHoodEnum: return P1DGEnum;1012 default: _error_("Element type "<<EnumToStringx(fe_stokes)<<" not supported yet");1013 }1014 1015 return -1;1016 }1017 /*}}}*/1018 void PentaRef::BasalNodeIndices(int* pnumindices,int** pindices,int finiteelement){/*{{{*/1019 1020 /*Output*/1021 int numindices;1022 int* indices = NULL;1023 1024 switch(finiteelement){1025 case P1Enum: case P1DGEnum:1026 numindices = 3;1027 indices = xNew<int>(numindices);1028 indices[0] = 0;1029 indices[1] = 1;1030 indices[2] = 2;1031 break;1032 case P1bubbleEnum: case P1bubblecondensedEnum:1033 numindices = 3;1034 indices = xNew<int>(numindices);1035 indices[0] = 0;1036 indices[1] = 1;1037 indices[2] = 2;1038 break;1039 case P2xP1Enum:1040 numindices = 6;1041 indices = xNew<int>(numindices);1042 indices[0] = 0;1043 indices[1] = 1;1044 indices[2] = 2;1045 indices[3] = 6;1046 indices[4] = 7;1047 indices[5] = 8;1048 break;1049 case P1xP2Enum:1050 numindices = 3;1051 indices = xNew<int>(numindices);1052 indices[0] = 0;1053 indices[1] = 1;1054 indices[2] = 2;1055 break;1056 case P1xP3Enum:1057 numindices = 3;1058 indices = xNew<int>(numindices);1059 indices[0] = 0;1060 indices[1] = 1;1061 indices[2] = 2;1062 break;1063 case P2Enum:1064 numindices = 6;1065 indices = xNew<int>(numindices);1066 indices[0] = 0;1067 indices[1] = 1;1068 indices[2] = 2;1069 indices[3] = 9;1070 indices[4] = 10;1071 indices[5] = 11;1072 break;1073 case P2bubbleEnum:1074 numindices = 6;1075 indices = xNew<int>(numindices);1076 indices[0] = 0;1077 indices[1] = 1;1078 indices[2] = 2;1079 indices[3] = 9;1080 indices[4] = 10;1081 indices[5] = 11;1082 break;1083 case P2xP4Enum:1084 numindices = 6;1085 indices = xNew<int>(numindices);1086 indices[0] = 0;1087 indices[1] = 1;1088 indices[2] = 2;1089 indices[3] = 9;1090 indices[4] = 10;1091 indices[5] = 11;1092 break;1093 default:1094 _error_("Element type "<<EnumToStringx(finiteelement)<<" not supported yet");1095 }1096 1097 /*Assign output pointer*/1098 *pnumindices = numindices;1099 *pindices = indices;1100 1079 } 1101 1080 /*}}}*/ … … 1157 1136 } 1158 1137 /*}}}*/ 1138 int PentaRef::TensorInterpolation(int fe_stokes){/*{{{*/ 1139 1140 switch(fe_stokes){ 1141 case XTaylorHoodEnum: return P1DGEnum; 1142 default: _error_("Element type "<<EnumToStringx(fe_stokes)<<" not supported yet"); 1143 } 1144 1145 return -1; 1146 } 1147 /*}}}*/ 1148 int PentaRef::VelocityInterpolation(int fe_stokes){/*{{{*/ 1149 1150 switch(fe_stokes){ 1151 case P1P1Enum: return P1Enum; 1152 case P1P1GLSEnum: return P1Enum; 1153 case MINIcondensedEnum: return P1bubbleEnum; 1154 case MINIEnum: return P1bubbleEnum; 1155 case TaylorHoodEnum: return P2Enum; 1156 case LATaylorHoodEnum: return P2Enum; 1157 case OneLayerP4zEnum: return P2xP4Enum; 1158 case CrouzeixRaviartEnum: return P2bubbleEnum; 1159 case LACrouzeixRaviartEnum: return P2bubbleEnum; 1160 default: _error_("Element type "<<EnumToStringx(fe_stokes)<<" not supported yet"); 1161 } 1162 1163 return -1; 1164 } 1165 /*}}}*/ -
issm/trunk/src/c/classes/Elements/PentaRef.h
r18301 r19105 15 15 16 16 /*Numerics*/ 17 void BasalNodeIndices(int* pnumindices,int** pindices,int finiteelement); 18 void GetInputDerivativeValue(IssmDouble* pvalues, IssmDouble* plist,IssmDouble* xyz_list, Gauss* gauss,int finiteelement); 19 void GetInputValue(IssmDouble* pvalue,IssmDouble* plist, Gauss* gauss,int finiteelement); 20 void GetJacobian(IssmDouble* J, IssmDouble* xyz_list,Gauss* gauss); 21 void GetJacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss); 22 void GetJacobianInvert(IssmDouble* Jinv, IssmDouble* xyz_list,Gauss* gauss); 23 void GetLprimeFSSSA(IssmDouble* LprimeFSSSA, IssmDouble* xyz_list, Gauss* gauss); 17 24 void GetNodalFunctions(IssmDouble* basis, Gauss* gauss,int finiteelement); 18 25 void GetNodalFunctionsDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss,int finiteelement); 19 26 void GetNodalFunctionsDerivativesReference(IssmDouble* dbasis,Gauss* gauss,int finiteelement); 20 27 void GetQuadJacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss); 21 void GetJacobian(IssmDouble* J, IssmDouble* xyz_list,Gauss* gauss); 22 void GetJacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss); 28 void GetSegmentJacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss); 23 29 void GetTriaJacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss); 24 void GetSegmentJacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss); 25 void GetJacobianInvert(IssmDouble* Jinv, IssmDouble* xyz_list,Gauss* gauss); 26 void GetLprimeFSSSA(IssmDouble* LprimeFSSSA, IssmDouble* xyz_list, Gauss* gauss); 27 void GetInputValue(IssmDouble* pvalue,IssmDouble* plist, Gauss* gauss,int finiteelement); 28 void GetInputDerivativeValue(IssmDouble* pvalues, IssmDouble* plist,IssmDouble* xyz_list, Gauss* gauss,int finiteelement); 29 30 void BasalNodeIndices(int* pnumindices,int** pindices,int finiteelement); 30 int NumberofNodes(int finiteelement); 31 int PressureInterpolation(int fe_stokes); 31 32 void SurfaceNodeIndices(int* pnumindices,int** pindices,int finiteelement); 32 int NumberofNodes(int finiteelement);33 int TensorInterpolation(int fe_stokes); 33 34 int VelocityInterpolation(int fe_stokes); 34 int PressureInterpolation(int fe_stokes);35 int TensorInterpolation(int fe_stokes);36 35 }; 37 36 #endif -
issm/trunk/src/c/classes/Elements/Seg.cpp
r18301 r19105 68 68 } 69 69 /*}}}*/ 70 int Seg::ObjectEnum(void){/*{{{*/71 72 return SegEnum;73 74 }75 /*}}}*/76 70 void Seg::GetIcefrontCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum){/*{{{*/ 77 71 … … 102 96 *pxyz_front=xyz_front; 103 97 }/*}}}*/ 104 void Seg::NodalFunctionsP1(IssmDouble* basis, Gauss* gauss){/*{{{*/105 106 _assert_(gauss->Enum()==GaussSegEnum);107 this->GetNodalFunctions(basis,(GaussSeg*)gauss,P1Enum);108 109 }110 /*}}}*/111 void Seg::NodalFunctionsP2(IssmDouble* basis, Gauss* gauss){/*{{{*/112 113 _assert_(gauss->Enum()==GaussSegEnum);114 this->GetNodalFunctions(basis,(GaussSeg*)gauss,P2Enum);115 116 }117 /*}}}*/118 98 int Seg::GetNumberOfNodes(void){/*{{{*/ 119 99 return this->NumberofNodes(this->element_type); … … 205 185 } 206 186 /*}}}*/ 187 void Seg::NodalFunctionsP1(IssmDouble* basis, Gauss* gauss){/*{{{*/ 188 189 _assert_(gauss->Enum()==GaussSegEnum); 190 this->GetNodalFunctions(basis,(GaussSeg*)gauss,P1Enum); 191 192 } 193 /*}}}*/ 194 void Seg::NodalFunctionsP2(IssmDouble* basis, Gauss* gauss){/*{{{*/ 195 196 _assert_(gauss->Enum()==GaussSegEnum); 197 this->GetNodalFunctions(basis,(GaussSeg*)gauss,P2Enum); 198 199 } 200 /*}}}*/ 207 201 void Seg::NormalSection(IssmDouble* normal,IssmDouble* xyz_list_front){/*{{{*/ 208 202 … … 218 212 } 219 213 /*}}}*/ 214 int Seg::ObjectEnum(void){/*{{{*/ 215 216 return SegEnum; 217 218 } 219 /*}}}*/ -
issm/trunk/src/c/classes/Elements/Seg.h
r18301 r19105 39 39 Object *copy(); 40 40 /*}}}*/ 41 /*Update virtual functions resolution: {{{*/42 void InputUpdateFromSolutionOneDofCollapsed(IssmDouble* solution,int inputenum){_error_("not implemented yet");};43 void InputUpdateFromSolutionOneDof(IssmDouble* solution,int inputenum){_error_("not implemented yet");};44 void InputUpdateFromVector(IssmDouble* vector, int name, int type){_error_("not implemented yet");};45 #ifdef _HAVE_DAKOTA_46 void InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){_error_("not implemented yet");};47 void InputUpdateFromMatrixDakota(IssmDouble* matrix, int nows, int ncols, int name, int type){_error_("not implemented yet");};48 #endif49 void InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("not implemented yet");};50 /*}}}*/51 41 /*Element virtual functions definitions: {{{*/ 52 42 void AddBasalInput(int input_enum, IssmDouble* values, int interpolation_enum){_error_("not implemented yet");}; 53 43 void AddInput(int input_enum, IssmDouble* values, int interpolation_enum){_error_("not implemented yet");}; 44 void AverageOntoPartition(Vector<IssmDouble>* partition_contributions,Vector<IssmDouble>* partition_areas,IssmDouble* vertex_response,IssmDouble* qmu_part){_error_("not implemented yet");}; 45 void CalvingRateLevermann(void){_error_("not implemented yet");}; 54 46 IssmDouble CharacteristicLength(void); 55 47 void ComputeBasalStress(Vector<IssmDouble>* sigma_b){_error_("not implemented yet");}; 48 void ComputeDeviatoricStressTensor(){_error_("not implemented yet");}; 56 49 void ComputeSigmaNN(){_error_("not implemented yet");}; 57 50 void ComputeStressTensor(){_error_("not implemented yet");}; 58 void C omputeDeviatoricStressTensor(){_error_("not implemented yet");};51 void CalvingRatePi(void){_error_("not implemented yet");}; 59 52 void Configure(Elements* elements,Loads* loads,Nodes* nodesin,Vertices* verticesin,Materials* materials,Parameters* parameters){_error_("not implemented yet");}; 60 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Materials* materials,Parameters* parameters){_error_("not implemented yet");};61 void ResetHooks(){_error_("not implemented yet");};53 void ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index){_error_("not implemented yet");}; 54 void ControlToVectors(Vector<IssmPDouble>* vector_control, Vector<IssmPDouble>* vector_gradient,int control_enum){_error_("not implemented yet");}; 62 55 void Delta18oParameterization(void){_error_("not implemented yet");}; 56 void MungsmtpParameterization(void){_error_("not implemented yet");}; 57 void ElementResponse(IssmDouble* presponse,int response_enum){_error_("not implemented yet");}; 63 58 void ElementSizes(IssmDouble* hx,IssmDouble* hy,IssmDouble* hz){_error_("not implemented yet");}; 64 59 void FSContactMigration(Vector<IssmDouble>* vertexgrounded,Vector<IssmDouble>* vertexfloating){_error_("not implemented yet");}; 65 60 int FiniteElement(void); 66 Element* GetUpperElement(void){_error_("not implemented yet");};67 61 Element* GetBasalElement(void){_error_("not implemented yet");}; 62 int GetElementType(void){_error_("not implemented yet");}; 63 void GetGroundedPart(int* point1,IssmDouble* fraction1, IssmDouble* fraction2,bool* mainlyfloating){_error_("not implemented yet");}; 64 IssmDouble GetGroundedPortion(IssmDouble* xyz_list){_error_("not implemented yet");}; 65 void GetIcefrontCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum); 66 void GetInputValue(IssmDouble* pvalue,Node* node,int enumtype){_error_("not implemented yet");}; 67 void GetLevelCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum,IssmDouble level){_error_("not implemented");}; 68 void GetLevelsetPositivePart(int* point1,IssmDouble* fraction1,IssmDouble* fraction2, bool* mainlynegative,IssmDouble* levelsetvalues){_error_("not implemented yet");}; 69 Node* GetNode(int node_number){_error_("Not implemented");}; 68 70 int GetNodeIndex(Node* node){_error_("not implemented yet");}; 69 71 int GetNumberOfNodes(void); 70 72 int GetNumberOfNodes(int enum_type){_error_("not implemented yet");}; 71 73 int GetNumberOfVertices(void); 74 void GetSolutionFromInputsOneDof(Vector<IssmDouble>* solution,int enum_type){_error_("not implemented yet");}; 75 Element* GetUpperElement(void){_error_("not implemented yet");}; 76 void GetVectorFromControlInputs(Vector<IssmDouble>* gradient,int control_enum,int control_index,const char* data,bool onsid){_error_("not implemented yet");}; 72 77 void GetVerticesCoordinates(IssmDouble** pxyz_list); 73 78 void GetVerticesCoordinatesBase(IssmDouble** pxyz_list){_error_("not implemented yet");}; 74 79 void GetVerticesCoordinatesTop(IssmDouble** pxyz_list){_error_("not implemented yet");}; 80 IssmDouble IceMass(void){_error_("not implemented yet");}; 81 IssmDouble IceVolume(void){_error_("not implemented yet");}; 82 IssmDouble IceVolumeAboveFloatation(void){_error_("not implemented yet");}; 83 void InputControlUpdate(IssmDouble scalar,bool save_parameter){_error_("not implemented yet");}; 84 void InputDepthAverageAtBase(int enum_type,int average_enum_type){_error_("not implemented yet");}; 85 void InputExtrude(int enum_type,int start){_error_("not implemented"); /*For penta only*/}; 86 void InputScale(int enum_type,IssmDouble scale_factor){_error_("not implemented yet");}; 87 void InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("not implemented yet");}; 88 void InputUpdateFromSolutionOneDof(IssmDouble* solution,int inputenum){_error_("not implemented yet");}; 89 void InputUpdateFromSolutionOneDofCollapsed(IssmDouble* solution,int inputenum){_error_("not implemented yet");}; 90 void InputUpdateFromVector(IssmDouble* vector, int name, int type){_error_("not implemented yet");}; 91 bool IsFaceOnBoundary(void){_error_("not implemented yet");}; 92 bool IsIcefront(void); 93 bool IsNodeOnShelfFromFlags(IssmDouble* flags){_error_("not implemented yet");}; 75 94 bool IsOnBase(){_error_("not implemented yet");}; 76 95 bool IsOnSurface(){_error_("not implemented yet");}; 77 bool Is NodeOnShelfFromFlags(IssmDouble* flags){_error_("not implemented yet");};96 bool IsZeroLevelset(int levelset_enum){_error_("not implemented");}; 78 97 void JacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss); 98 void JacobianDeterminantBase(IssmDouble* pJdet,IssmDouble* xyz_list_base,Gauss* gauss){_error_("not implemented yet");}; 79 99 void JacobianDeterminantLine(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");}; 80 100 void JacobianDeterminantSurface(IssmDouble* pJdet, IssmDouble* xyz_list,Gauss* gauss); 81 void JacobianDeterminantBase(IssmDouble* pJdet,IssmDouble* xyz_list_base,Gauss* gauss){_error_("not implemented yet");};82 101 void JacobianDeterminantTop(IssmDouble* pJdet,IssmDouble* xyz_list_base,Gauss* gauss){_error_("not implemented yet");}; 102 IssmDouble Masscon(IssmDouble* levelset){_error_("not implemented yet");}; 103 IssmDouble MassFlux(IssmDouble* segment){_error_("not implemented yet");}; 104 IssmDouble MassFlux(IssmDouble x1,IssmDouble y1, IssmDouble x2, IssmDouble y2,int segment_id){_error_("not implemented yet");} 105 void MaterialUpdateFromTemperature(void){_error_("not implemented yet");}; 83 106 IssmDouble MinEdgeLength(IssmDouble* xyz_list){_error_("not implemented yet");}; 84 void NodalFunctions(IssmDouble* basis,Gauss* gauss); 85 void NodalFunctionsP1(IssmDouble* basis,Gauss* gauss); 86 void NodalFunctionsP2(IssmDouble* basis,Gauss* gauss); 87 void NodalFunctionsVelocity(IssmDouble* basis,Gauss* gauss){_error_("not implemented yet");}; 88 void NodalFunctionsPressure(IssmDouble* basis,Gauss* gauss){_error_("not implemented yet");}; 89 void NodalFunctionsTensor(IssmDouble* basis,Gauss* gauss){_error_("not implemented yet");}; 90 void NodalFunctionsDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss); 91 void NodalFunctionsP1Derivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");}; 92 void NodalFunctionsMINIDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");}; 93 void NodalFunctionsDerivativesVelocity(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");}; 94 void NormalSection(IssmDouble* normal,IssmDouble* xyz_list); 95 void NormalTop(IssmDouble* normal,IssmDouble* xyz_list){_error_("not implemented yet");}; 96 void NormalBase(IssmDouble* normal,IssmDouble* xyz_list){_error_("not implemented yet");}; 97 int NumberofNodesVelocity(void){_error_("not implemented yet");}; 98 int NumberofNodesPressure(void){_error_("not implemented yet");}; 99 Element* SpawnBasalElement(void){_error_("not implemented yet");}; 100 Element* SpawnTopElement(void){_error_("not implemented yet");}; 101 IssmDouble StabilizationParameter(IssmDouble u, IssmDouble v, IssmDouble w, IssmDouble diameter, IssmDouble kappa){_error_("not implemented yet");}; 102 int PressureInterpolation(void){_error_("not implemented yet");}; 103 void ValueP1OnGauss(IssmDouble* pvalue,IssmDouble* values,Gauss* gauss){_error_("not implemented yet");}; 104 void ValueP1DerivativesOnGauss(IssmDouble* dvalue,IssmDouble* values,IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");}; 105 int VelocityInterpolation(void){_error_("not implemented yet");}; 106 int TensorInterpolation(void){_error_("not implemented yet");}; 107 void GetGroundedPart(int* point1,IssmDouble* fraction1, IssmDouble* fraction2,bool* mainlyfloating){_error_("not implemented yet");}; 108 IssmDouble GetGroundedPortion(IssmDouble* xyz_list){_error_("not implemented yet");}; 109 void GetInputValue(IssmDouble* pvalue,Node* node,int enumtype){_error_("not implemented yet");}; 110 Node* GetNode(int node_number){_error_("Not implemented");}; 111 int GetElementType(void){_error_("not implemented yet");}; 107 IssmDouble Misfit(int modelenum,int observationenum,int weightsenum){_error_("not implemented yet");}; 108 IssmDouble MisfitArea(int weightsenum){_error_("not implemented yet");}; 112 109 Gauss* NewGauss(void); 113 110 Gauss* NewGauss(int order); … … 118 115 Gauss* NewGaussLine(int vertex1,int vertex2,int order){_error_("not implemented yet");}; 119 116 Gauss* NewGaussTop(int order){_error_("not implemented yet");}; 117 int NodalValue(IssmDouble* pvalue, int index, int natureofdataenum){_error_("not implemented yet");}; 118 void NodalFunctions(IssmDouble* basis,Gauss* gauss); 119 void NodalFunctionsDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss); 120 void NodalFunctionsDerivativesVelocity(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");}; 121 void NodalFunctionsMINIDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");}; 122 void NodalFunctionsPressure(IssmDouble* basis,Gauss* gauss){_error_("not implemented yet");}; 123 void NodalFunctionsP1(IssmDouble* basis,Gauss* gauss); 124 void NodalFunctionsP1Derivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");}; 125 void NodalFunctionsP2(IssmDouble* basis,Gauss* gauss); 126 void NodalFunctionsTensor(IssmDouble* basis,Gauss* gauss){_error_("not implemented yet");}; 127 void NodalFunctionsVelocity(IssmDouble* basis,Gauss* gauss){_error_("not implemented yet");}; 128 void NormalBase(IssmDouble* normal,IssmDouble* xyz_list){_error_("not implemented yet");}; 129 void NormalSection(IssmDouble* normal,IssmDouble* xyz_list); 130 void NormalTop(IssmDouble* normal,IssmDouble* xyz_list){_error_("not implemented yet");}; 131 int NumberofNodesPressure(void){_error_("not implemented yet");}; 132 int NumberofNodesVelocity(void){_error_("not implemented yet");}; 133 void PositiveDegreeDay(IssmDouble* pdds,IssmDouble* pds,IssmDouble signorm,bool ismungsm){_error_("not implemented yet");}; 134 void PotentialUngrounding(Vector<IssmDouble>* potential_sheet_ungrounding){_error_("not implemented yet");}; 135 int PressureInterpolation(void){_error_("not implemented yet");}; 136 void ReduceMatrices(ElementMatrix* Ke,ElementVector* pe){_error_("not implemented yet");}; 137 void ResetFSBasalBoundaryCondition(void){_error_("not implemented yet");}; 138 void ResetHooks(){_error_("not implemented yet");}; 139 void SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index){_error_("not implemented yet");}; 140 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Materials* materials,Parameters* parameters){_error_("not implemented yet");}; 141 void SetTemporaryElementType(int element_type_in){_error_("not implemented yet");}; 142 Element* SpawnBasalElement(void){_error_("not implemented yet");}; 143 Element* SpawnTopElement(void){_error_("not implemented yet");}; 144 IssmDouble StabilizationParameter(IssmDouble u, IssmDouble v, IssmDouble w, IssmDouble diameter, IssmDouble kappa){_error_("not implemented yet");}; 145 void StrainRateparallel(void){_error_("not implemented yet");}; 146 void StrainRateperpendicular(void){_error_("not implemented yet");}; 147 void StressIntensityFactor(void){_error_("not implemented yet");}; 148 IssmDouble SurfaceArea(void){_error_("not implemented yet");}; 149 int TensorInterpolation(void){_error_("not implemented yet");}; 150 IssmDouble TimeAdapt(){_error_("not implemented yet");}; 151 IssmDouble TotalSmb(void){_error_("not implemented yet");}; 152 void Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type,int finitelement){_error_("not implemented yet");}; 153 void UpdateConstraintsExtrudeFromBase(){_error_("not implemented");}; 154 void UpdateConstraintsExtrudeFromTop(){_error_("not implemented");}; 155 int UpdatePotentialUngrounding(IssmDouble* vertices_potentially_ungrounding,Vector<IssmDouble>* vec_nodes_on_iceshelf,IssmDouble* nodes_on_iceshelf){_error_("not implemented yet");}; 156 void ValueP1DerivativesOnGauss(IssmDouble* dvalue,IssmDouble* values,IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");}; 157 void ValueP1OnGauss(IssmDouble* pvalue,IssmDouble* values,Gauss* gauss){_error_("not implemented yet");}; 158 int VelocityInterpolation(void){_error_("not implemented yet");}; 120 159 int VertexConnectivity(int vertexindex){_error_("not implemented yet");}; 121 160 void VerticalSegmentIndices(int** pindices,int* pnumseg){_error_("not implemented yet");}; 122 161 void ViscousHeating(IssmDouble* pphi,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vz_input){_error_("not implemented yet");}; 123 bool IsZeroLevelset(int levelset_enum){_error_("not implemented");};124 bool IsIcefront(void);125 bool IsFaceOnBoundary(void){_error_("not implemented yet");};126 162 void ZeroLevelsetCoordinates(IssmDouble** pxyz_zero,IssmDouble* xyz_list,int levelsetenum){_error_("not implemented");}; 127 void GetIcefrontCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum);128 void GetLevelCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum,IssmDouble level){_error_("not implemented");};129 130 void GetSolutionFromInputsOneDof(Vector<IssmDouble>* solution,int enum_type){_error_("not implemented yet");};131 void InputDepthAverageAtBase(int enum_type,int average_enum_type){_error_("not implemented yet");};132 void InputExtrude(int enum_type){_error_("not implemented"); /*For penta only*/};133 void InputScale(int enum_type,IssmDouble scale_factor){_error_("not implemented yet");};134 void MaterialUpdateFromTemperature(void){_error_("not implemented yet");};135 int NodalValue(IssmDouble* pvalue, int index, int natureofdataenum){_error_("not implemented yet");};136 void PositiveDegreeDay(IssmDouble* pdds,IssmDouble* pds,IssmDouble signorm){_error_("not implemented yet");};137 void ResetFSBasalBoundaryCondition(void){_error_("not implemented yet");};138 void ReduceMatrices(ElementMatrix* Ke,ElementVector* pe){_error_("not implemented yet");};139 void SetTemporaryElementType(int element_type_in){_error_("not implemented yet");};140 IssmDouble SurfaceArea(void){_error_("not implemented yet");};141 void Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type,int finitelement){_error_("not implemented yet");};142 IssmDouble TimeAdapt(){_error_("not implemented yet");};143 void UpdateConstraintsExtrudeFromBase(){_error_("not implemented");};144 void UpdateConstraintsExtrudeFromTop(){_error_("not implemented");};145 146 void AverageOntoPartition(Vector<IssmDouble>* partition_contributions,Vector<IssmDouble>* partition_areas,IssmDouble* vertex_response,IssmDouble* qmu_part){_error_("not implemented yet");};147 IssmDouble IceVolume(void){_error_("not implemented yet");};148 IssmDouble IceVolumeAboveFloatation(void){_error_("not implemented yet");};149 IssmDouble TotalSmb(void){_error_("not implemented yet");};150 IssmDouble MassFlux(IssmDouble* segment){_error_("not implemented yet");};151 IssmDouble MassFlux(IssmDouble x1,IssmDouble y1, IssmDouble x2, IssmDouble y2,int segment_id){_error_("not implemented yet");}152 void ElementResponse(IssmDouble* presponse,int response_enum){_error_("not implemented yet");};153 IssmDouble Misfit(int modelenum,int observationenum,int weightsenum){_error_("not implemented yet");};154 IssmDouble MisfitArea(int weightsenum){_error_("not implemented yet");};155 163 156 164 #ifdef _HAVE_GIA_ 157 void GiaDeflection(Vector<IssmDouble>* wg,Vector<IssmDouble>* dwgdt,IssmDouble* x,IssmDouble* y){_error_("not implemented yet");};165 void GiaDeflection(Vector<IssmDouble>* wg,Vector<IssmDouble>* dwgdt,IssmDouble* x,IssmDouble* y){_error_("not implemented yet");}; 158 166 #endif 159 167 160 void GetVectorFromControlInputs(Vector<IssmDouble>* gradient,int control_enum,int control_index,const char* data){_error_("not implemented yet");}; 161 void SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index){_error_("not implemented yet");}; 162 void ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index){_error_("not implemented yet");}; 163 void ControlToVectors(Vector<IssmPDouble>* vector_control, Vector<IssmPDouble>* vector_gradient,int control_enum){_error_("not implemented yet");}; 164 void InputControlUpdate(IssmDouble scalar,bool save_parameter){_error_("not implemented yet");}; 165 166 void PotentialUngrounding(Vector<IssmDouble>* potential_sheet_ungrounding){_error_("not implemented yet");}; 167 void MigrateGroundingLine(IssmDouble* sheet_ungrounding){_error_("not implemented yet");}; 168 int UpdatePotentialUngrounding(IssmDouble* vertices_potentially_ungrounding,Vector<IssmDouble>* vec_nodes_on_iceshelf,IssmDouble* nodes_on_iceshelf){_error_("not implemented yet");}; 168 #ifdef _HAVE_DAKOTA_ 169 void InputUpdateFromMatrixDakota(IssmDouble* matrix, int nows, int ncols, int name, int type){_error_("not implemented yet");}; 170 void InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){_error_("not implemented yet");}; 171 #endif 169 172 /*}}}*/ 170 173 }; -
issm/trunk/src/c/classes/Elements/SegRef.cpp
r18301 r19105 18 18 #define NUMNODESP0 1 19 19 #define NUMNODESP1 2 20 #define NUMNODESMAX 2 20 21 21 22 /*Object constructors and destructor*/ … … 28 29 29 30 /*Reference Element numerics*/ 31 void SegRef::GetInputDerivativeValue(IssmDouble* p, IssmDouble* plist,IssmDouble* xyz_list, GaussSeg* gauss,int finiteelement){/*{{{*/ 32 33 /*From node values of parameter p (plist[0],plist[1]), return parameter derivative value at gaussian 34 * point specified by gauss_basis: 35 * dp/dx=plist[0]*dh1/dx+plist[1]*dh2/dx 36 * 37 * p is a vector already allocated. 38 * 39 * WARNING: For a significant gain in performance, it is better to use 40 * static memory allocation instead of dynamic. 41 */ 42 43 /*Allocate derivatives of basis functions*/ 44 IssmDouble dbasis[1*NUMNODESMAX]; 45 46 /*Fetch number of nodes for this finite element*/ 47 int numnodes = this->NumberofNodes(finiteelement); 48 _assert_(numnodes<=NUMNODESMAX); 49 50 /*Get basis functions derivatives at this point*/ 51 GetNodalFunctionsDerivatives(&dbasis[0],xyz_list,gauss,finiteelement); 52 53 /*Calculate parameter for this Gauss point*/ 54 IssmDouble dpx=0.; 55 for(int i=0;i<numnodes;i++) dpx += dbasis[0*numnodes+i]*plist[i]; 56 57 /*Assign values*/ 58 p[0]=dpx; 59 } 60 /*}}}*/ 61 void SegRef::GetInputValue(IssmDouble* p, IssmDouble* plist, GaussSeg* gauss,int finiteelement){/*{{{*/ 62 /* WARNING: For a significant gain in performance, it is better to use 63 * static memory allocation instead of dynamic.*/ 64 65 /*Allocate basis functions*/ 66 IssmDouble basis[NUMNODESMAX]; 67 68 /*Fetch number of nodes for this finite element*/ 69 int numnodes = this->NumberofNodes(finiteelement); 70 _assert_(numnodes<=NUMNODESMAX); 71 72 /*Get basis functions at this point*/ 73 GetNodalFunctions(&basis[0],gauss,finiteelement); 74 75 /*Calculate parameter for this Gauss point*/ 76 IssmDouble value =0.; 77 for(int i=0;i<numnodes;i++) value += basis[i]*plist[i]; 78 79 /*Assign output pointer*/ 80 *p = value; 81 } 82 /*}}}*/ 83 void SegRef::GetJacobian(IssmDouble* J, IssmDouble* xyz_list,GaussSeg* gauss){/*{{{*/ 84 /*The Jacobian is constant over the element, discard the gaussian points. 85 * J is assumed to have been allocated of size 1*/ 86 87 IssmDouble x1=xyz_list[3*0+0]; 88 IssmDouble x2=xyz_list[3*1+0]; 89 90 *J=.5*fabs(x2-x1); 91 } 92 /*}}}*/ 93 void SegRef::GetJacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,GaussSeg* gauss){/*{{{*/ 94 /*The Jacobian determinant is constant over the element, discard the gaussian points. 95 * J is assumed to have been allocated of size NDOF2xNDOF2.*/ 96 97 /*Call Jacobian routine to get the jacobian:*/ 98 GetJacobian(Jdet, xyz_list, gauss); 99 if(*Jdet<0) _error_("negative jacobian determinant!"); 100 101 } 102 /*}}}*/ 103 void SegRef::GetJacobianInvert(IssmDouble* Jinv, IssmDouble* xyz_list,GaussSeg* gauss){/*{{{*/ 104 105 /*Jacobian*/ 106 IssmDouble J; 107 108 /*Call Jacobian routine to get the jacobian:*/ 109 GetJacobian(&J, xyz_list, gauss); 110 111 /*Invert Jacobian matrix: */ 112 *Jinv = 1./J; 113 } 114 /*}}}*/ 30 115 void SegRef::GetNodalFunctions(IssmDouble* basis,GaussSeg* gauss,int finiteelement){/*{{{*/ 31 116 /*This routine returns the values of the nodal functions at the gaussian point.*/ … … 108 193 } 109 194 /*}}}*/ 110 void SegRef::GetInputDerivativeValue(IssmDouble* p, IssmDouble* plist,IssmDouble* xyz_list, GaussSeg* gauss,int finiteelement){/*{{{*/111 112 /*From node values of parameter p (plist[0],plist[1]), return parameter derivative value at gaussian113 * point specified by gauss_basis:114 * dp/dx=plist[0]*dh1/dx+plist[1]*dh2/dx115 *116 * p is a vector already allocated.117 */118 119 /*Output*/120 IssmDouble dpx = 0.;121 122 /*Fetch number of nodes for this finite element*/123 int numnodes = this->NumberofNodes(finiteelement);124 125 /*Get nodal functions derivatives*/126 IssmDouble* dbasis=xNew<IssmDouble>(1*numnodes);127 GetNodalFunctionsDerivatives(dbasis,xyz_list,gauss,finiteelement);128 129 /*Calculate parameter for this Gauss point*/130 for(int i=0;i<numnodes;i++) dpx += dbasis[i]*plist[i];131 132 /*Assign values*/133 xDelete<IssmDouble>(dbasis);134 *p=dpx;135 136 }137 /*}}}*/138 void SegRef::GetInputValue(IssmDouble* p, IssmDouble* plist, GaussSeg* gauss,int finiteelement){/*{{{*/139 140 /*Output*/141 IssmDouble value =0.;142 143 /*Fetch number of nodes for this finite element*/144 int numnodes = this->NumberofNodes(finiteelement);145 146 /*Get nodal functions*/147 IssmDouble* basis=xNew<IssmDouble>(numnodes);148 GetNodalFunctions(basis, gauss,finiteelement);149 150 /*Calculate parameter for this Gauss point*/151 for(int i=0;i<numnodes;i++) value += basis[i]*plist[i];152 153 /*Assign output pointer*/154 xDelete<IssmDouble>(basis);155 *p = value;156 }157 /*}}}*/158 void SegRef::GetJacobian(IssmDouble* J, IssmDouble* xyz_list,GaussSeg* gauss){/*{{{*/159 /*The Jacobian is constant over the element, discard the gaussian points.160 * J is assumed to have been allocated of size 1*/161 162 IssmDouble x1=xyz_list[3*0+0];163 IssmDouble x2=xyz_list[3*1+0];164 165 *J=.5*fabs(x2-x1);166 }167 /*}}}*/168 void SegRef::GetJacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,GaussSeg* gauss){/*{{{*/169 /*The Jacobian determinant is constant over the element, discard the gaussian points.170 * J is assumed to have been allocated of size NDOF2xNDOF2.*/171 172 /*Call Jacobian routine to get the jacobian:*/173 GetJacobian(Jdet, xyz_list, gauss);174 if(*Jdet<0) _error_("negative jacobian determinant!");175 176 }177 /*}}}*/178 void SegRef::GetJacobianInvert(IssmDouble* Jinv, IssmDouble* xyz_list,GaussSeg* gauss){/*{{{*/179 180 /*Jacobian*/181 IssmDouble J;182 183 /*Call Jacobian routine to get the jacobian:*/184 GetJacobian(&J, xyz_list, gauss);185 186 /*Invert Jacobian matrix: */187 *Jinv = 1./J;188 }189 /*}}}*/190 195 int SegRef::NumberofNodes(int finiteelement){/*{{{*/ 191 196 -
issm/trunk/src/c/classes/Elements/SegRef.h
r18301 r19105 16 16 ~SegRef(); 17 17 18 void GetInputDerivativeValue(IssmDouble* p, IssmDouble* plist,IssmDouble* xyz_list, GaussSeg* gauss,int finiteelement); 19 void GetInputValue(IssmDouble* p, IssmDouble* plist, GaussSeg* gauss,int finiteelement); 18 20 void GetJacobian(IssmDouble* J, IssmDouble* xyz_list,GaussSeg* gauss); 19 21 void GetJacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,GaussSeg* gauss); … … 22 24 void GetNodalFunctionsDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list, GaussSeg* gauss,int finiteelement); 23 25 void GetNodalFunctionsDerivativesReference(IssmDouble* dbasis,GaussSeg* gauss,int finiteelement); 24 void GetInputDerivativeValue(IssmDouble* p, IssmDouble* plist,IssmDouble* xyz_list, GaussSeg* gauss,int finiteelement);25 void GetInputValue(IssmDouble* p, IssmDouble* plist, GaussSeg* gauss,int finiteelement);26 26 int NumberofNodes(int finiteelement); 27 27 }; -
issm/trunk/src/c/classes/Elements/Tetra.cpp
r18301 r19105 104 104 /*}}}*/ 105 105 106 int Tetra::FiniteElement(void){/*{{{*/107 return this->element_type;108 } /*}}}*/109 int Tetra::ObjectEnum(void){/*{{{*/110 111 return TetraEnum;112 113 }/*}}}*/114 106 void Tetra::AddInput(int input_enum,IssmDouble* values, int interpolation_enum){/*{{{*/ 115 107 … … 196 188 } 197 189 /*}}}*/ 190 void Tetra::FaceOnFrontIndices(int* pindex1,int* pindex2,int* pindex3){/*{{{*/ 191 192 IssmDouble values[NUMVERTICES]; 193 int indices[4][3] = {{0,1,2},{0,3,1},{1,3,2},{0,2,3}}; 194 195 /*Retrieve all inputs and parameters*/ 196 GetInputListOnVertices(&values[0],MaskIceLevelsetEnum); 197 198 for(int i=0;i<4;i++){ 199 if(values[indices[i][0]] == 0. && values[indices[i][1]] == 0. && values[indices[i][2]] == 0.){ 200 *pindex1 = indices[i][0]; 201 *pindex2 = indices[i][1]; 202 *pindex3 = indices[i][2]; 203 return; 204 } 205 } 206 207 _error_("Could not find 3 vertices on bed"); 208 } 209 /*}}}*/ 198 210 void Tetra::FaceOnSurfaceIndices(int* pindex1,int* pindex2,int* pindex3){/*{{{*/ 199 211 … … 216 228 } 217 229 /*}}}*/ 218 void Tetra::FaceOnFrontIndices(int* pindex1,int* pindex2,int* pindex3){/*{{{*/ 219 220 IssmDouble values[NUMVERTICES]; 221 int indices[4][3] = {{0,1,2},{0,3,1},{1,3,2},{0,2,3}}; 222 223 /*Retrieve all inputs and parameters*/ 224 GetInputListOnVertices(&values[0],MaskIceLevelsetEnum); 225 226 for(int i=0;i<4;i++){ 227 if(values[indices[i][0]] == 0. && values[indices[i][1]] == 0. && values[indices[i][2]] == 0.){ 228 *pindex1 = indices[i][0]; 229 *pindex2 = indices[i][1]; 230 *pindex3 = indices[i][2]; 231 return; 232 } 233 } 234 235 _error_("Could not find 3 vertices on bed"); 236 } 237 /*}}}*/ 230 int Tetra::FiniteElement(void){/*{{{*/ 231 return this->element_type; 232 } /*}}}*/ 238 233 int Tetra::GetElementType(){/*{{{*/ 239 234 … … 475 470 } 476 471 /*}}}*/ 477 bool Tetra::IsOnBase(){/*{{{*/478 return HasFaceOnBase();479 }480 /*}}}*/481 bool Tetra::IsOnSurface(){/*{{{*/482 return HasFaceOnSurface();483 }484 /*}}}*/485 472 bool Tetra::IsIcefront(void){/*{{{*/ 486 473 … … 497 484 return false; 498 485 }/*}}}*/ 486 bool Tetra::IsOnBase(){/*{{{*/ 487 return HasFaceOnBase(); 488 } 489 /*}}}*/ 490 bool Tetra::IsOnSurface(){/*{{{*/ 491 return HasFaceOnSurface(); 492 } 493 /*}}}*/ 499 494 void Tetra::JacobianDeterminant(IssmDouble* pJdet,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 500 495 … … 504 499 } 505 500 /*}}}*/ 501 void Tetra::JacobianDeterminantBase(IssmDouble* pJdet,IssmDouble* xyz_list_base,Gauss* gauss){/*{{{*/ 502 503 _assert_(gauss->Enum()==GaussTetraEnum); 504 this->GetJacobianDeterminantFace(pJdet,xyz_list_base,(GaussTetra*)gauss); 505 506 } 507 /*}}}*/ 506 508 void Tetra::JacobianDeterminantSurface(IssmDouble* pJdet,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 507 509 508 510 _assert_(gauss->Enum()==GaussTetraEnum); 509 511 this->GetJacobianDeterminantFace(pJdet,xyz_list,(GaussTetra*)gauss); 510 511 }512 /*}}}*/513 void Tetra::JacobianDeterminantBase(IssmDouble* pJdet,IssmDouble* xyz_list_base,Gauss* gauss){/*{{{*/514 515 _assert_(gauss->Enum()==GaussTetraEnum);516 this->GetJacobianDeterminantFace(pJdet,xyz_list_base,(GaussTetra*)gauss);517 512 518 513 } … … 561 556 } 562 557 /*}}}*/ 558 void Tetra::NodalFunctionsDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 559 560 _assert_(gauss->Enum()==GaussTetraEnum); 561 this->GetNodalFunctionsDerivatives(dbasis,xyz_list,(GaussTetra*)gauss,this->element_type); 562 563 } 564 /*}}}*/ 565 void Tetra::NodalFunctionsDerivativesVelocity(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 566 567 _assert_(gauss->Enum()==GaussTetraEnum); 568 this->GetNodalFunctionsDerivatives(dbasis,xyz_list,(GaussTetra*)gauss,this->VelocityInterpolation()); 569 570 } 571 /*}}}*/ 572 void Tetra::NodalFunctionsPressure(IssmDouble* basis, Gauss* gauss){/*{{{*/ 573 574 _assert_(gauss->Enum()==GaussTetraEnum); 575 this->GetNodalFunctions(basis,(GaussTetra*)gauss,this->PressureInterpolation()); 576 577 } 578 /*}}}*/ 579 void Tetra::NodalFunctionsTensor(IssmDouble* basis, Gauss* gauss){/*{{{*/ 580 581 _assert_(gauss->Enum()==GaussTetraEnum); 582 this->GetNodalFunctions(basis,(GaussTetra*)gauss,this->TensorInterpolation()); 583 584 } 585 /*}}}*/ 563 586 void Tetra::NodalFunctionsVelocity(IssmDouble* basis, Gauss* gauss){/*{{{*/ 564 587 … … 568 591 } 569 592 /*}}}*/ 570 void Tetra::NodalFunctionsPressure(IssmDouble* basis, Gauss* gauss){/*{{{*/ 571 572 _assert_(gauss->Enum()==GaussTetraEnum); 573 this->GetNodalFunctions(basis,(GaussTetra*)gauss,this->PressureInterpolation()); 574 575 } 576 /*}}}*/ 577 void Tetra::NodalFunctionsTensor(IssmDouble* basis, Gauss* gauss){/*{{{*/ 578 579 _assert_(gauss->Enum()==GaussTetraEnum); 580 this->GetNodalFunctions(basis,(GaussTetra*)gauss,this->TensorInterpolation()); 581 582 } 583 /*}}}*/ 584 void Tetra::NodalFunctionsDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 585 586 _assert_(gauss->Enum()==GaussTetraEnum); 587 this->GetNodalFunctionsDerivatives(dbasis,xyz_list,(GaussTetra*)gauss,this->element_type); 588 589 } 590 /*}}}*/ 591 void Tetra::NodalFunctionsDerivativesVelocity(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 592 593 _assert_(gauss->Enum()==GaussTetraEnum); 594 this->GetNodalFunctionsDerivatives(dbasis,xyz_list,(GaussTetra*)gauss,this->VelocityInterpolation()); 595 593 void Tetra::NormalBase(IssmDouble* bed_normal,IssmDouble* xyz_list){/*{{{*/ 594 595 IssmDouble v13[3],v23[3]; 596 IssmDouble normal[3]; 597 IssmDouble normal_norm; 598 599 for(int i=0;i<3;i++){ 600 v13[i]=xyz_list[0*3+i]-xyz_list[2*3+i]; 601 v23[i]=xyz_list[1*3+i]-xyz_list[2*3+i]; 602 } 603 604 normal[0]=v13[1]*v23[2]-v13[2]*v23[1]; 605 normal[1]=v13[2]*v23[0]-v13[0]*v23[2]; 606 normal[2]=v13[0]*v23[1]-v13[1]*v23[0]; 607 normal_norm=sqrt(normal[0]*normal[0]+ normal[1]*normal[1]+ normal[2]*normal[2]); 608 609 /*Bed normal is opposite to surface normal*/ 610 bed_normal[0]=-normal[0]/normal_norm; 611 bed_normal[1]=-normal[1]/normal_norm; 612 bed_normal[2]=-normal[2]/normal_norm; 613 614 _assert_(bed_normal[2]<0.); 596 615 } 597 616 /*}}}*/ … … 616 635 } 617 636 /*}}}*/ 618 void Tetra::Normal Base(IssmDouble* bed_normal,IssmDouble* xyz_list){/*{{{*/637 void Tetra::NormalTop(IssmDouble* top_normal,IssmDouble* xyz_list){/*{{{*/ 619 638 620 639 IssmDouble v13[3],v23[3]; … … 632 651 normal_norm=sqrt(normal[0]*normal[0]+ normal[1]*normal[1]+ normal[2]*normal[2]); 633 652 634 /*Bed normal is opposite to surface normal*/635 bed_normal[0]=-normal[0]/normal_norm;636 bed_normal[1]=-normal[1]/normal_norm;637 bed_normal[2]=-normal[2]/normal_norm;638 639 _assert_(bed_normal[2]<0.);640 }641 /*}}}*/642 void Tetra::NormalTop(IssmDouble* top_normal,IssmDouble* xyz_list){/*{{{*/643 644 IssmDouble v13[3],v23[3];645 IssmDouble normal[3];646 IssmDouble normal_norm;647 648 for(int i=0;i<3;i++){649 v13[i]=xyz_list[0*3+i]-xyz_list[2*3+i];650 v23[i]=xyz_list[1*3+i]-xyz_list[2*3+i];651 }652 653 normal[0]=v13[1]*v23[2]-v13[2]*v23[1];654 normal[1]=v13[2]*v23[0]-v13[0]*v23[2];655 normal[2]=v13[0]*v23[1]-v13[1]*v23[0];656 normal_norm=sqrt(normal[0]*normal[0]+ normal[1]*normal[1]+ normal[2]*normal[2]);657 658 653 top_normal[0]=normal[0]/normal_norm; 659 654 top_normal[1]=normal[1]/normal_norm; … … 668 663 int Tetra::NumberofNodesVelocity(void){/*{{{*/ 669 664 return TetraRef::NumberofNodes(this->VelocityInterpolation()); 665 } 666 /*}}}*/ 667 int Tetra::ObjectEnum(void){/*{{{*/ 668 669 return TetraEnum; 670 671 }/*}}}*/ 672 int Tetra::PressureInterpolation(void){/*{{{*/ 673 return TetraRef::PressureInterpolation(this->element_type); 670 674 } 671 675 /*}}}*/ … … 764 768 } 765 769 /*}}}*/ 766 void Tetra::SetCurrentConfiguration(Elements* elementsin, Loads* loadsin, Nodes* nodesin, Materials* materialsin, Parameters* parametersin){/*{{{*/767 768 /*go into parameters and get the analysis_counter: */769 int analysis_counter;770 parametersin->FindParam(&analysis_counter,AnalysisCounterEnum);771 772 /*Get Element type*/773 this->element_type=this->element_type_list[analysis_counter];774 775 /*Pick up nodes*/776 if(this->hnodes[analysis_counter]) this->nodes=(Node**)this->hnodes[analysis_counter]->deliverp();777 else this->nodes=NULL;778 779 }780 /*}}}*/781 770 void Tetra::ResetHooks(){/*{{{*/ 782 771 … … 795 784 } 796 785 /*}}}*/ 786 void Tetra::SetCurrentConfiguration(Elements* elementsin, Loads* loadsin, Nodes* nodesin, Materials* materialsin, Parameters* parametersin){/*{{{*/ 787 788 /*go into parameters and get the analysis_counter: */ 789 int analysis_counter; 790 parametersin->FindParam(&analysis_counter,AnalysisCounterEnum); 791 792 /*Get Element type*/ 793 this->element_type=this->element_type_list[analysis_counter]; 794 795 /*Pick up nodes*/ 796 if(this->hnodes[analysis_counter]) this->nodes=(Node**)this->hnodes[analysis_counter]->deliverp(); 797 else this->nodes=NULL; 798 799 } 800 /*}}}*/ 797 801 Element* Tetra::SpawnBasalElement(void){/*{{{*/ 798 802 … … 824 828 tria->parameters=this->parameters; 825 829 tria->element_type=P1Enum; //Only P1 CG for now (TO BE CHANGED) 826 this->SpawnTriaHook( dynamic_cast<ElementHook*>(tria),index1,index2,index3);830 this->SpawnTriaHook(xDynamicCast<ElementHook*>(tria),index1,index2,index3); 827 831 828 832 /*Spawn material*/ … … 836 840 /*Return new Tria*/ 837 841 return tria; 842 } 843 /*}}}*/ 844 int Tetra::TensorInterpolation(void){/*{{{*/ 845 return TetraRef::TensorInterpolation(this->element_type); 838 846 } 839 847 /*}}}*/ … … 981 989 } 982 990 /*}}}*/ 983 int Tetra::PressureInterpolation(void){/*{{{*/984 return TetraRef::PressureInterpolation(this->element_type);985 }986 /*}}}*/987 int Tetra::TensorInterpolation(void){/*{{{*/988 return TetraRef::TensorInterpolation(this->element_type);989 }990 /*}}}*/991 991 void Tetra::ZeroLevelsetCoordinates(IssmDouble** pxyz_zero,IssmDouble* xyz_list,int levelsetenum){/*{{{*/ 992 992 /*Compute portion of the element that is grounded*/ -
issm/trunk/src/c/classes/Elements/Tetra.h
r18301 r19105 39 39 Object *copy(); 40 40 /*}}}*/ 41 /*Update virtual functions resolution: {{{*/42 void InputUpdateFromSolutionOneDofCollapsed(IssmDouble* solution,int inputenum){_error_("not implemented yet");};43 void InputUpdateFromSolutionOneDof(IssmDouble* solution,int inputenum);44 void InputUpdateFromVector(IssmDouble* vector, int name, int type){_error_("not implemented yet");};45 #ifdef _HAVE_DAKOTA_46 void InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){_error_("not implemented yet");};47 void InputUpdateFromMatrixDakota(IssmDouble* matrix, int nows, int ncols, int name, int type){_error_("not implemented yet");};48 #endif49 void InputUpdateFromIoModel(int index, IoModel* iomodel);50 /*}}}*/51 41 /*Element virtual functions definitions: {{{*/ 52 42 void AddBasalInput(int input_enum, IssmDouble* values, int interpolation_enum){_error_("not implemented yet");}; 53 43 void AddInput(int input_enum, IssmDouble* values, int interpolation_enum); 44 void AverageOntoPartition(Vector<IssmDouble>* partition_contributions,Vector<IssmDouble>* partition_areas,IssmDouble* vertex_response,IssmDouble* qmu_part){_error_("not implemented yet");}; 45 void CalvingRateLevermann(void){_error_("not implemented yet");}; 54 46 IssmDouble CharacteristicLength(void){_error_("not implemented yet");}; 55 47 void ComputeBasalStress(Vector<IssmDouble>* sigma_b){_error_("not implemented yet");}; … … 57 49 void ComputeStressTensor(){_error_("not implemented yet");}; 58 50 void ComputeDeviatoricStressTensor(){_error_("not implemented yet");}; 51 void CalvingRatePi(void){_error_("not implemented yet");}; 59 52 void Configure(Elements* elements,Loads* loads,Nodes* nodesin,Vertices* verticesin,Materials* materials,Parameters* parameters); 60 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Materials* materials,Parameters* parameters);61 void ResetHooks();53 void ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index){_error_("not implemented yet");}; 54 void ControlToVectors(Vector<IssmPDouble>* vector_control, Vector<IssmPDouble>* vector_gradient,int control_enum){_error_("not implemented yet");}; 62 55 void Delta18oParameterization(void){_error_("not implemented yet");}; 56 void MungsmtpParameterization(void){_error_("not implemented yet");}; 57 IssmDouble DragCoefficientAbsGradient(void){_error_("not implemented yet");}; 58 void ElementResponse(IssmDouble* presponse,int response_enum){_error_("not implemented yet");}; 63 59 void ElementSizes(IssmDouble* hx,IssmDouble* hy,IssmDouble* hz); 60 void FaceOnBaseIndices(int* pindex1,int* pindex2,int* pindex3); 64 61 void FaceOnFrontIndices(int* pindex1,int* pindex2,int* pindex3); 65 void FaceOnBaseIndices(int* pindex1,int* pindex2,int* pindex3);66 62 void FaceOnSurfaceIndices(int* pindex1,int* pindex2,int* pindex3); 63 int FiniteElement(void); 67 64 void FSContactMigration(Vector<IssmDouble>* vertexgrounded,Vector<IssmDouble>* vertexfloating){_error_("not implemented yet");}; 68 int FiniteElement(void);69 Element* GetUpperElement(void){_error_("not implemented yet");};70 65 Element* GetBasalElement(void){_error_("not implemented yet");}; 66 int GetElementType(void); 67 void GetGroundedPart(int* point1,IssmDouble* fraction1, IssmDouble* fraction2,bool* mainlyfloating){_error_("not implemented yet");}; 68 IssmDouble GetGroundedPortion(IssmDouble* xyz_list){_error_("not implemented yet");}; 69 void GetIcefrontCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum){_error_("not implemented yet");}; 70 void GetInputValue(IssmDouble* pvalue,Node* node,int enumtype); 71 void GetLevelCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum,IssmDouble level){_error_("not implemented yet");}; 72 void GetLevelsetPositivePart(int* point1,IssmDouble* fraction1,IssmDouble* fraction2, bool* mainlynegative,IssmDouble* levelsetvalues){_error_("not implemented yet");}; 73 Node* GetNode(int node_number){_error_("Not implemented");}; 71 74 int GetNodeIndex(Node* node); 72 75 int GetNumberOfNodes(void); 73 76 int GetNumberOfNodes(int enum_type){_error_("not implemented yet");}; 74 77 int GetNumberOfVertices(void); 78 void GetSolutionFromInputsOneDof(Vector<IssmDouble>* solution,int enum_type){_error_("not implemented yet");}; 79 Element* GetUpperElement(void){_error_("not implemented yet");}; 80 void GetVectorFromControlInputs(Vector<IssmDouble>* gradient,int control_enum,int control_index,const char* data,bool onsid){_error_("not implemented yet");}; 75 81 void GetVerticesCoordinatesBase(IssmDouble** pxyz_list); 76 82 void GetVerticesCoordinatesTop(IssmDouble** pxyz_list); 83 void GradientIndexing(int* indexing,int control_index){_error_("not implemented yet");}; 77 84 bool HasFaceOnBase(); 78 85 bool HasFaceOnSurface(); 86 IssmDouble IceMass(void){_error_("not implemented yet");}; 87 IssmDouble IceVolume(void){_error_("not implemented yet");}; 88 IssmDouble IceVolumeAboveFloatation(void){_error_("not implemented yet");}; 89 bool IsFaceOnBoundary(void){_error_("not implemented yet");}; 90 bool IsIcefront(void); 91 bool IsNodeOnShelfFromFlags(IssmDouble* flags){_error_("not implemented yet");}; 79 92 bool IsOnBase(); 80 93 bool IsOnSurface(); 81 bool IsNodeOnShelfFromFlags(IssmDouble* flags){_error_("not implemented yet");}; 94 bool IsZeroLevelset(int levelset_enum){_error_("not implemented");}; 95 void InputControlUpdate(IssmDouble scalar,bool save_parameter){_error_("not implemented yet");}; 96 void InputDepthAverageAtBase(int enum_type,int average_enum_type){_error_("not implemented yet");}; 97 void InputExtrude(int enum_type,int start){_error_("not implemented"); /*For penta only*/}; 98 void InputScale(int enum_type,IssmDouble scale_factor){_error_("not implemented yet");}; 99 void InputUpdateFromIoModel(int index, IoModel* iomodel); 100 void InputUpdateFromSolutionOneDof(IssmDouble* solution,int inputenum); 101 void InputUpdateFromSolutionOneDofCollapsed(IssmDouble* solution,int inputenum){_error_("not implemented yet");}; 102 void InputUpdateFromVector(IssmDouble* vector, int name, int type){_error_("not implemented yet");}; 82 103 void JacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss); 104 void JacobianDeterminantBase(IssmDouble* pJdet,IssmDouble* xyz_list_base,Gauss* gauss); 83 105 void JacobianDeterminantLine(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");}; 84 106 void JacobianDeterminantSurface(IssmDouble* pJdet, IssmDouble* xyz_list,Gauss* gauss); 85 void JacobianDeterminantBase(IssmDouble* pJdet,IssmDouble* xyz_list_base,Gauss* gauss);86 107 void JacobianDeterminantTop(IssmDouble* pJdet,IssmDouble* xyz_list_base,Gauss* gauss); 108 IssmDouble Masscon(IssmDouble* levelset){_error_("not implemented yet");}; 109 IssmDouble MassFlux(IssmDouble* segment){_error_("not implemented yet");}; 110 IssmDouble MassFlux(IssmDouble x1,IssmDouble y1, IssmDouble x2, IssmDouble y2,int segment_id){_error_("not implemented yet");} 111 void MaterialUpdateFromTemperature(void){_error_("not implemented yet");}; 87 112 IssmDouble MinEdgeLength(IssmDouble* xyz_list){_error_("not implemented yet");}; 88 void NodalFunctions(IssmDouble* basis,Gauss* gauss); 89 void NodalFunctionsP1(IssmDouble* basis,Gauss* gauss){_error_("not implemented yet");}; 90 void NodalFunctionsP2(IssmDouble* basis,Gauss* gauss){_error_("not implemented yet");}; 91 void NodalFunctionsVelocity(IssmDouble* basis,Gauss* gauss); 92 void NodalFunctionsPressure(IssmDouble* basis,Gauss* gauss); 93 void NodalFunctionsTensor(IssmDouble* basis,Gauss* gauss); 94 void NodalFunctionsDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss); 95 void NodalFunctionsP1Derivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");}; 96 void NodalFunctionsMINIDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");}; 97 void NodalFunctionsDerivativesVelocity(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss); 98 void NormalSection(IssmDouble* normal,IssmDouble* xyz_list); 99 void NormalTop(IssmDouble* normal,IssmDouble* xyz_list); 100 void NormalBase(IssmDouble* normal,IssmDouble* xyz_list); 101 int NumberofNodesVelocity(void); 102 int NumberofNodesPressure(void); 103 Element* SpawnBasalElement(void); 104 Element* SpawnTopElement(void); 105 Tria* SpawnTria(int index1,int index2,int index3); 106 IssmDouble StabilizationParameter(IssmDouble u, IssmDouble v, IssmDouble w, IssmDouble diameter, IssmDouble kappa){_error_("not implemented yet");}; 107 int PressureInterpolation(void); 108 void ValueP1OnGauss(IssmDouble* pvalue,IssmDouble* values,Gauss* gauss); 109 void ValueP1DerivativesOnGauss(IssmDouble* dvalue,IssmDouble* values,IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");}; 110 int VelocityInterpolation(void); 111 int TensorInterpolation(void); 112 void GetGroundedPart(int* point1,IssmDouble* fraction1, IssmDouble* fraction2,bool* mainlyfloating){_error_("not implemented yet");}; 113 IssmDouble GetGroundedPortion(IssmDouble* xyz_list){_error_("not implemented yet");}; 114 void GetInputValue(IssmDouble* pvalue,Node* node,int enumtype); 115 Node* GetNode(int node_number){_error_("Not implemented");}; 116 int GetElementType(void); 113 IssmDouble Misfit(int modelenum,int observationenum,int weightsenum){_error_("not implemented yet");}; 114 IssmDouble MisfitArea(int weightsenum){_error_("not implemented yet");}; 117 115 Gauss* NewGauss(void); 118 116 Gauss* NewGauss(int order); … … 123 121 Gauss* NewGaussLine(int vertex1,int vertex2,int order){_error_("not implemented yet");}; 124 122 Gauss* NewGaussTop(int order); 123 void NodalFunctions(IssmDouble* basis,Gauss* gauss); 124 void NodalFunctionsDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss); 125 void NodalFunctionsDerivativesVelocity(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss); 126 void NodalFunctionsMINIDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");}; 127 void NodalFunctionsPressure(IssmDouble* basis,Gauss* gauss); 128 void NodalFunctionsP1(IssmDouble* basis,Gauss* gauss){_error_("not implemented yet");}; 129 void NodalFunctionsP1Derivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");}; 130 void NodalFunctionsP2(IssmDouble* basis,Gauss* gauss){_error_("not implemented yet");}; 131 void NodalFunctionsTensor(IssmDouble* basis,Gauss* gauss); 132 void NodalFunctionsVelocity(IssmDouble* basis,Gauss* gauss); 133 int NodalValue(IssmDouble* pvalue, int index, int natureofdataenum){_error_("not implemented yet");}; 134 void NormalBase(IssmDouble* normal,IssmDouble* xyz_list); 135 void NormalSection(IssmDouble* normal,IssmDouble* xyz_list); 136 void NormalTop(IssmDouble* normal,IssmDouble* xyz_list); 137 int NumberofNodesPressure(void); 138 int NumberofNodesVelocity(void); 139 void PositiveDegreeDay(IssmDouble* pdds,IssmDouble* pds,IssmDouble signorm,bool ismungsm){_error_("not implemented yet");}; 140 void PotentialUngrounding(Vector<IssmDouble>* potential_sheet_ungrounding){_error_("not implemented yet");}; 141 int PressureInterpolation(void); 142 void ResetFSBasalBoundaryCondition(void); 143 void ResetHooks(); 144 void ReduceMatrices(ElementMatrix* Ke,ElementVector* pe); 145 void SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index){_error_("not implemented yet");}; 146 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Materials* materials,Parameters* parameters); 147 void SetTemporaryElementType(int element_type_in){_error_("not implemented yet");}; 148 Element* SpawnBasalElement(void); 149 Element* SpawnTopElement(void); 150 Tria* SpawnTria(int index1,int index2,int index3); 151 IssmDouble StabilizationParameter(IssmDouble u, IssmDouble v, IssmDouble w, IssmDouble diameter, IssmDouble kappa){_error_("not implemented yet");}; 152 void StrainRateparallel(void){_error_("not implemented yet");}; 153 void StrainRateperpendicular(void){_error_("not implemented yet");}; 154 void StressIntensityFactor(void){_error_("not implemented yet");}; 155 IssmDouble SurfaceArea(void){_error_("not implemented yet");}; 156 int TensorInterpolation(void); 157 IssmDouble TimeAdapt(){_error_("not implemented yet");}; 158 IssmDouble TotalSmb(void){_error_("not implemented yet");}; 159 void Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type,int finitelement); 160 void UpdateConstraintsExtrudeFromBase(){_error_("not implemented");}; 161 void UpdateConstraintsExtrudeFromTop(){_error_("not implemented");}; 162 int UpdatePotentialUngrounding(IssmDouble* vertices_potentially_ungrounding,Vector<IssmDouble>* vec_nodes_on_iceshelf,IssmDouble* nodes_on_iceshelf){_error_("not implemented yet");}; 163 void ValueP1DerivativesOnGauss(IssmDouble* dvalue,IssmDouble* values,IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");}; 164 void ValueP1OnGauss(IssmDouble* pvalue,IssmDouble* values,Gauss* gauss); 165 int VelocityInterpolation(void); 125 166 int VertexConnectivity(int vertexindex){_error_("not implemented yet");}; 126 167 void VerticalSegmentIndices(int** pindices,int* pnumseg){_error_("not implemented yet");}; 127 168 void ViscousHeating(IssmDouble* pphi,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vz_input); 128 bool IsZeroLevelset(int levelset_enum){_error_("not implemented");};129 bool IsIcefront(void);130 bool IsFaceOnBoundary(void){_error_("not implemented yet");};131 169 void ZeroLevelsetCoordinates(IssmDouble** pxyz_zero,IssmDouble* xyz_list,int levelsetenum); 132 void GetIcefrontCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum){_error_("not implemented yet");};133 void GetLevelCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum,IssmDouble level){_error_("not implemented yet");};134 void GetSolutionFromInputsOneDof(Vector<IssmDouble>* solution,int enum_type){_error_("not implemented yet");};135 void InputDepthAverageAtBase(int enum_type,int average_enum_type){_error_("not implemented yet");};136 void InputExtrude(int enum_type){_error_("not implemented"); /*For penta only*/};137 void InputScale(int enum_type,IssmDouble scale_factor){_error_("not implemented yet");};138 void MaterialUpdateFromTemperature(void){_error_("not implemented yet");};139 int NodalValue(IssmDouble* pvalue, int index, int natureofdataenum){_error_("not implemented yet");};140 void PositiveDegreeDay(IssmDouble* pdds,IssmDouble* pds,IssmDouble signorm){_error_("not implemented yet");};141 void ResetFSBasalBoundaryCondition(void);142 void ReduceMatrices(ElementMatrix* Ke,ElementVector* pe);143 void SetTemporaryElementType(int element_type_in){_error_("not implemented yet");};144 IssmDouble SurfaceArea(void){_error_("not implemented yet");};145 void Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type,int finitelement);146 IssmDouble TimeAdapt(){_error_("not implemented yet");};147 void UpdateConstraintsExtrudeFromBase(){_error_("not implemented");};148 void UpdateConstraintsExtrudeFromTop(){_error_("not implemented");};149 150 void AverageOntoPartition(Vector<IssmDouble>* partition_contributions,Vector<IssmDouble>* partition_areas,IssmDouble* vertex_response,IssmDouble* qmu_part){_error_("not implemented yet");};151 IssmDouble IceVolume(void){_error_("not implemented yet");};152 IssmDouble IceVolumeAboveFloatation(void){_error_("not implemented yet");};153 IssmDouble TotalSmb(void){_error_("not implemented yet");};154 IssmDouble MassFlux(IssmDouble* segment){_error_("not implemented yet");};155 IssmDouble MassFlux(IssmDouble x1,IssmDouble y1, IssmDouble x2, IssmDouble y2,int segment_id){_error_("not implemented yet");}156 void ElementResponse(IssmDouble* presponse,int response_enum){_error_("not implemented yet");};157 IssmDouble Misfit(int modelenum,int observationenum,int weightsenum){_error_("not implemented yet");};158 IssmDouble MisfitArea(int weightsenum){_error_("not implemented yet");};159 170 160 171 #ifdef _HAVE_GIA_ 161 void GiaDeflection(Vector<IssmDouble>* wg,Vector<IssmDouble>* dwgdt,IssmDouble* x,IssmDouble* y){_error_("not implemented yet");};172 void GiaDeflection(Vector<IssmDouble>* wg,Vector<IssmDouble>* dwgdt,IssmDouble* x,IssmDouble* y){_error_("not implemented yet");}; 162 173 #endif 163 174 164 IssmDouble DragCoefficientAbsGradient(void){_error_("not implemented yet");}; 165 void GradientIndexing(int* indexing,int control_index){_error_("not implemented yet");}; 166 void GetVectorFromControlInputs(Vector<IssmDouble>* gradient,int control_enum,int control_index,const char* data){_error_("not implemented yet");}; 167 void SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index){_error_("not implemented yet");}; 168 void ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index){_error_("not implemented yet");}; 169 void ControlToVectors(Vector<IssmPDouble>* vector_control, Vector<IssmPDouble>* vector_gradient,int control_enum){_error_("not implemented yet");}; 170 void InputControlUpdate(IssmDouble scalar,bool save_parameter){_error_("not implemented yet");}; 171 172 void PotentialUngrounding(Vector<IssmDouble>* potential_sheet_ungrounding){_error_("not implemented yet");}; 173 void MigrateGroundingLine(IssmDouble* sheet_ungrounding){_error_("not implemented yet");}; 174 int UpdatePotentialUngrounding(IssmDouble* vertices_potentially_ungrounding,Vector<IssmDouble>* vec_nodes_on_iceshelf,IssmDouble* nodes_on_iceshelf){_error_("not implemented yet");}; 175 #ifdef _HAVE_DAKOTA_ 176 void InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){_error_("not implemented yet");}; 177 void InputUpdateFromMatrixDakota(IssmDouble* matrix, int nows, int ncols, int name, int type){_error_("not implemented yet");}; 178 #endif 175 179 /*}}}*/ 176 180 }; -
issm/trunk/src/c/classes/Elements/TetraRef.cpp
r18301 r19105 20 20 #define NUMNODESP1b 5 21 21 #define NUMNODESP2 10 22 #define NUMNODESMAX 10 22 23 23 24 /*Object constructors and destructor*/ … … 30 31 31 32 /*Reference Element numerics*/ 33 void TetraRef::GetInputDerivativeValue(IssmDouble* p, IssmDouble* plist,IssmDouble* xyz_list, GaussTetra* gauss,int finiteelement){/*{{{*/ 34 /*From node values of parameter p (p_list[0], p_list[1], p_list[2], 35 * p_list[3], p_list[4] and p_list[4]), return parameter derivative value at 36 * gaussian point specified by gauss_coord: 37 * dp/dx=p_list[0]*dh1/dx+p_list[1]*dh2/dx+p_list[2]*dh3/dx+p_list[3]*dh4/dx+p_list[4]*dh5/dx+p_list[5]*dh6/dx; 38 * dp/dy=p_list[0]*dh1/dy+p_list[1]*dh2/dy+p_list[2]*dh3/dy+p_list[3]*dh4/dy+p_list[4]*dh5/dy+p_list[5]*dh6/dy; 39 * dp/dz=p_list[0]*dh1/dz+p_list[1]*dh2/dz+p_list[2]*dh3/dz+p_list[3]*dh4/dz+p_list[4]*dh5/dz+p_list[5]*dh6/dz; 40 * 41 * p is a vector of size 3x1 already allocated. 42 * 43 * WARNING: For a significant gain in performance, it is better to use 44 * static memory allocation instead of dynamic. 45 */ 46 47 /*Allocate derivatives of basis functions*/ 48 IssmDouble dbasis[3*NUMNODESMAX]; 49 50 /*Fetch number of nodes for this finite element*/ 51 int numnodes = this->NumberofNodes(finiteelement); 52 _assert_(numnodes<=NUMNODESMAX); 53 54 /*Get basis functions derivatives at this point*/ 55 GetNodalFunctionsDerivatives(&dbasis[0],xyz_list,gauss,finiteelement); 56 57 /*Calculate parameter for this Gauss point*/ 58 IssmDouble dpx=0.; 59 IssmDouble dpy=0.; 60 IssmDouble dpz=0.; 61 for(int i=0;i<numnodes;i++) dpx += dbasis[0*numnodes+i]*plist[i]; 62 for(int i=0;i<numnodes;i++) dpy += dbasis[1*numnodes+i]*plist[i]; 63 for(int i=0;i<numnodes;i++) dpz += dbasis[2*numnodes+i]*plist[i]; 64 65 /*Assign values*/ 66 p[0]=dpx; 67 p[1]=dpy; 68 p[2]=dpz; 69 } 70 /*}}}*/ 71 void TetraRef::GetInputValue(IssmDouble* p, IssmDouble* plist, Gauss* gauss,int finiteelement){/*{{{*/ 72 /* WARNING: For a significant gain in performance, it is better to use 73 * static memory allocation instead of dynamic.*/ 74 75 /*Allocate basis functions*/ 76 IssmDouble basis[NUMNODESMAX]; 77 78 /*Fetch number of nodes for this finite element*/ 79 int numnodes = this->NumberofNodes(finiteelement); 80 _assert_(numnodes<=NUMNODESMAX); 81 82 /*Get basis functions at this point*/ 83 GetNodalFunctions(&basis[0],gauss,finiteelement); 84 85 /*Calculate parameter for this Gauss point*/ 86 IssmDouble value =0.; 87 for(int i=0;i<numnodes;i++) value += basis[i]*plist[i]; 88 89 /*Assign output pointer*/ 90 *p = value; 91 } 92 /*}}}*/ 93 void TetraRef::GetJacobian(IssmDouble* J, IssmDouble* xyz_list,GaussTetra* gauss){/*{{{*/ 94 /*The Jacobian is constant over the element, discard the gaussian points. 95 * J is assumed to have been allocated of size 1*/ 96 97 IssmDouble x1=xyz_list[3*0+0]; 98 IssmDouble x2=xyz_list[3*1+0]; 99 IssmDouble x3=xyz_list[3*2+0]; 100 IssmDouble x4=xyz_list[3*3+0]; 101 102 IssmDouble y1=xyz_list[3*0+1]; 103 IssmDouble y2=xyz_list[3*1+1]; 104 IssmDouble y3=xyz_list[3*2+1]; 105 IssmDouble y4=xyz_list[3*3+1]; 106 107 IssmDouble z1=xyz_list[3*0+2]; 108 IssmDouble z2=xyz_list[3*1+2]; 109 IssmDouble z3=xyz_list[3*2+2]; 110 IssmDouble z4=xyz_list[3*3+2]; 111 112 J[NDOF3*0+0] = x2-x1; 113 J[NDOF3*0+1] = y2-y1; 114 J[NDOF3*0+2] = z2-z1; 115 116 J[NDOF3*1+0] = x3-x1; 117 J[NDOF3*1+1] = y3-y1; 118 J[NDOF3*1+2] = z3-z1; 119 120 J[NDOF3*2+0] = x4-x1; 121 J[NDOF3*2+1] = y4-y1; 122 J[NDOF3*2+2] = z4-z1; 123 } 124 /*}}}*/ 125 void TetraRef::GetJacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,GaussTetra* gauss){/*{{{*/ 126 /*The Jacobian determinant is constant over the element, discard the gaussian points. 127 * J is assumed to have been allocated of size NDOF2xNDOF2.*/ 128 IssmDouble J[3][3]; 129 130 /*Call Jacobian routine to get the jacobian:*/ 131 GetJacobian(&J[0][0],xyz_list, gauss); 132 133 /*Get Determinant*/ 134 Matrix3x3Determinant(Jdet,&J[0][0]); 135 if(*Jdet<0) _error_("negative jacobian determinant!"); 136 137 } 138 /*}}}*/ 139 void TetraRef::GetJacobianDeterminantFace(IssmDouble* Jdet, IssmDouble* xyz_list,GaussTetra* gauss){/*{{{*/ 140 /*The Jacobian determinant is constant over the element, discard the gaussian points. 141 * J is assumed to have been allocated of size NDOF2xNDOF2.*/ 142 143 IssmDouble x1=xyz_list[3*0+0]; 144 IssmDouble y1=xyz_list[3*0+1]; 145 IssmDouble z1=xyz_list[3*0+2]; 146 IssmDouble x2=xyz_list[3*1+0]; 147 IssmDouble y2=xyz_list[3*1+1]; 148 IssmDouble z2=xyz_list[3*1+2]; 149 IssmDouble x3=xyz_list[3*2+0]; 150 IssmDouble y3=xyz_list[3*2+1]; 151 IssmDouble z3=xyz_list[3*2+2]; 152 153 /*Jdet = norm( AB ^ AC ) / (2 * area of the reference triangle), with areaRef=sqrt(3) */ 154 *Jdet=SQRT3/6.*pow(pow(((y2-y1)*(z3-z1)-(z2-z1)*(y3-y1)),2)+pow(((z2-z1)*(x3-x1)-(x2-x1)*(z3-z1)),2)+pow(((x2-x1)*(y3-y1)-(y2-y1)*(x3-x1)),2),0.5); 155 if(*Jdet<0) _error_("negative jacobian determinant!"); 156 } 157 /*}}}*/ 158 void TetraRef::GetJacobianInvert(IssmDouble* Jinv, IssmDouble* xyz_list,GaussTetra* gauss){/*{{{*/ 159 160 /*Jacobian*/ 161 IssmDouble J[3][3]; 162 163 /*Call Jacobian routine to get the jacobian:*/ 164 GetJacobian(&J[0][0], xyz_list, gauss); 165 166 /*Invert Jacobian matrix: */ 167 Matrix3x3Invert(Jinv,&J[0][0]); 168 } 169 /*}}}*/ 32 170 void TetraRef::GetNodalFunctions(IssmDouble* basis,Gauss* gauss_in,int finiteelement){/*{{{*/ 33 171 /*This routine returns the values of the nodal functions at the gaussian point.*/ … … 37 175 /*Cast gauss to GaussTetra*/ 38 176 _assert_(gauss_in->Enum()==GaussTetraEnum); 39 GaussTetra* gauss = dynamic_cast<GaussTetra*>(gauss_in);177 GaussTetra* gauss = xDynamicCast<GaussTetra*>(gauss_in); 40 178 41 179 switch(finiteelement){ … … 206 344 } 207 345 208 }209 /*}}}*/210 void TetraRef::GetInputDerivativeValue(IssmDouble* p, IssmDouble* plist,IssmDouble* xyz_list, GaussTetra* gauss,int finiteelement){/*{{{*/211 /*From node values of parameter p (p_list[0], p_list[1], p_list[2],212 * p_list[3], p_list[4] and p_list[4]), return parameter derivative value at213 * gaussian point specified by gauss_coord:214 * dp/dx=p_list[0]*dh1/dx+p_list[1]*dh2/dx+p_list[2]*dh3/dx+p_list[3]*dh4/dx+p_list[4]*dh5/dx+p_list[5]*dh6/dx;215 * dp/dy=p_list[0]*dh1/dy+p_list[1]*dh2/dy+p_list[2]*dh3/dy+p_list[3]*dh4/dy+p_list[4]*dh5/dy+p_list[5]*dh6/dy;216 * dp/dz=p_list[0]*dh1/dz+p_list[1]*dh2/dz+p_list[2]*dh3/dz+p_list[3]*dh4/dz+p_list[4]*dh5/dz+p_list[5]*dh6/dz;217 *218 * p is a vector of size 3x1 already allocated.219 */220 221 /*Output*/222 IssmDouble dpx=0.;223 IssmDouble dpy=0.;224 IssmDouble dpz=0.;225 226 /*Fetch number of nodes for this finite element*/227 int numnodes = this->NumberofNodes(finiteelement);228 229 /*Get nodal functions derivatives*/230 IssmDouble* dbasis=xNew<IssmDouble>(3*numnodes);231 GetNodalFunctionsDerivatives(dbasis,xyz_list,gauss,finiteelement);232 233 /*Calculate parameter for this Gauss point*/234 for(int i=0;i<numnodes;i++) dpx += dbasis[0*numnodes+i]*plist[i];235 for(int i=0;i<numnodes;i++) dpy += dbasis[1*numnodes+i]*plist[i];236 for(int i=0;i<numnodes;i++) dpz += dbasis[2*numnodes+i]*plist[i];237 238 /*Assign values*/239 xDelete<IssmDouble>(dbasis);240 p[0]=dpx;241 p[1]=dpy;242 p[2]=dpz;243 }244 /*}}}*/245 void TetraRef::GetInputValue(IssmDouble* p, IssmDouble* plist, Gauss* gauss,int finiteelement){/*{{{*/246 247 /*Output*/248 IssmDouble value =0.;249 250 /*Fetch number of nodes for this finite element*/251 int numnodes = this->NumberofNodes(finiteelement);252 253 /*Get nodal functions*/254 IssmDouble* basis=xNew<IssmDouble>(numnodes);255 GetNodalFunctions(basis, gauss,finiteelement);256 257 /*Calculate parameter for this Gauss point*/258 for(int i=0;i<numnodes;i++) value += basis[i]*plist[i];259 260 /*Assign output pointer*/261 xDelete<IssmDouble>(basis);262 *p = value;263 }264 /*}}}*/265 void TetraRef::GetJacobian(IssmDouble* J, IssmDouble* xyz_list,GaussTetra* gauss){/*{{{*/266 /*The Jacobian is constant over the element, discard the gaussian points.267 * J is assumed to have been allocated of size 1*/268 269 IssmDouble x1=xyz_list[3*0+0];270 IssmDouble x2=xyz_list[3*1+0];271 IssmDouble x3=xyz_list[3*2+0];272 IssmDouble x4=xyz_list[3*3+0];273 274 IssmDouble y1=xyz_list[3*0+1];275 IssmDouble y2=xyz_list[3*1+1];276 IssmDouble y3=xyz_list[3*2+1];277 IssmDouble y4=xyz_list[3*3+1];278 279 IssmDouble z1=xyz_list[3*0+2];280 IssmDouble z2=xyz_list[3*1+2];281 IssmDouble z3=xyz_list[3*2+2];282 IssmDouble z4=xyz_list[3*3+2];283 284 J[NDOF3*0+0] = x2-x1;285 J[NDOF3*0+1] = y2-y1;286 J[NDOF3*0+2] = z2-z1;287 288 J[NDOF3*1+0] = x3-x1;289 J[NDOF3*1+1] = y3-y1;290 J[NDOF3*1+2] = z3-z1;291 292 J[NDOF3*2+0] = x4-x1;293 J[NDOF3*2+1] = y4-y1;294 J[NDOF3*2+2] = z4-z1;295 }296 /*}}}*/297 void TetraRef::GetJacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,GaussTetra* gauss){/*{{{*/298 /*The Jacobian determinant is constant over the element, discard the gaussian points.299 * J is assumed to have been allocated of size NDOF2xNDOF2.*/300 IssmDouble J[3][3];301 302 /*Call Jacobian routine to get the jacobian:*/303 GetJacobian(&J[0][0],xyz_list, gauss);304 305 /*Get Determinant*/306 Matrix3x3Determinant(Jdet,&J[0][0]);307 if(*Jdet<0) _error_("negative jacobian determinant!");308 309 }310 /*}}}*/311 void TetraRef::GetJacobianDeterminantFace(IssmDouble* Jdet, IssmDouble* xyz_list,GaussTetra* gauss){/*{{{*/312 /*The Jacobian determinant is constant over the element, discard the gaussian points.313 * J is assumed to have been allocated of size NDOF2xNDOF2.*/314 315 IssmDouble x1=xyz_list[3*0+0];316 IssmDouble y1=xyz_list[3*0+1];317 IssmDouble z1=xyz_list[3*0+2];318 IssmDouble x2=xyz_list[3*1+0];319 IssmDouble y2=xyz_list[3*1+1];320 IssmDouble z2=xyz_list[3*1+2];321 IssmDouble x3=xyz_list[3*2+0];322 IssmDouble y3=xyz_list[3*2+1];323 IssmDouble z3=xyz_list[3*2+2];324 325 /*Jdet = norm( AB ^ AC ) / (2 * area of the reference triangle), with areaRef=sqrt(3) */326 *Jdet=SQRT3/6.*pow(pow(((y2-y1)*(z3-z1)-(z2-z1)*(y3-y1)),2)+pow(((z2-z1)*(x3-x1)-(x2-x1)*(z3-z1)),2)+pow(((x2-x1)*(y3-y1)-(y2-y1)*(x3-x1)),2),0.5);327 if(*Jdet<0) _error_("negative jacobian determinant!");328 }329 /*}}}*/330 void TetraRef::GetJacobianInvert(IssmDouble* Jinv, IssmDouble* xyz_list,GaussTetra* gauss){/*{{{*/331 332 /*Jacobian*/333 IssmDouble J[3][3];334 335 /*Call Jacobian routine to get the jacobian:*/336 GetJacobian(&J[0][0], xyz_list, gauss);337 338 /*Invert Jacobian matrix: */339 Matrix3x3Invert(Jinv,&J[0][0]);340 346 } 341 347 /*}}}*/ … … 362 368 } 363 369 /*}}}*/ 370 int TetraRef::PressureInterpolation(int fe_stokes){/*{{{*/ 371 372 switch(fe_stokes){ 373 case P1P1Enum: return P1Enum; 374 case P1P1GLSEnum: return P1Enum; 375 case MINIcondensedEnum: return P1Enum; 376 case MINIEnum: return P1Enum; 377 case TaylorHoodEnum: return P1Enum; 378 case LATaylorHoodEnum: return NoneEnum; 379 case XTaylorHoodEnum: return P1Enum; 380 default: _error_("Element type "<<EnumToStringx(fe_stokes)<<" not supported yet"); 381 } 382 383 return -1; 384 }/*}}}*/ 385 int TetraRef::TensorInterpolation(int fe_stokes){/*{{{*/ 386 /*This routine returns the values of the nodal functions at the gaussian point.*/ 387 388 switch(fe_stokes){ 389 case XTaylorHoodEnum: return P1DGEnum; 390 default: _error_("Element type "<<EnumToStringx(fe_stokes)<<" not supported yet"); 391 } 392 } 393 /*}}}*/ 364 394 int TetraRef::VelocityInterpolation(int fe_stokes){/*{{{*/ 365 395 … … 378 408 } 379 409 /*}}}*/ 380 int TetraRef::PressureInterpolation(int fe_stokes){/*{{{*/381 382 switch(fe_stokes){383 case P1P1Enum: return P1Enum;384 case P1P1GLSEnum: return P1Enum;385 case MINIcondensedEnum: return P1Enum;386 case MINIEnum: return P1Enum;387 case TaylorHoodEnum: return P1Enum;388 case LATaylorHoodEnum: return NoneEnum;389 case XTaylorHoodEnum: return P1Enum;390 default: _error_("Element type "<<EnumToStringx(fe_stokes)<<" not supported yet");391 }392 393 return -1;394 }/*}}}*/395 int TetraRef::TensorInterpolation(int fe_stokes){/*{{{*/396 /*This routine returns the values of the nodal functions at the gaussian point.*/397 398 switch(fe_stokes){399 case XTaylorHoodEnum: return P1DGEnum;400 default: _error_("Element type "<<EnumToStringx(fe_stokes)<<" not supported yet");401 }402 }403 /*}}}*/ -
issm/trunk/src/c/classes/Elements/TetraRef.h
r18301 r19105 16 16 ~TetraRef(); 17 17 18 void GetInputDerivativeValue(IssmDouble* p, IssmDouble* plist,IssmDouble* xyz_list, GaussTetra* gauss,int finiteelement); 19 void GetInputValue(IssmDouble* p, IssmDouble* plist, Gauss* gauss,int finiteelement); 18 20 void GetJacobian(IssmDouble* J, IssmDouble* xyz_list,GaussTetra* gauss); 19 21 void GetJacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,GaussTetra* gauss); … … 23 25 void GetNodalFunctionsDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list, GaussTetra* gauss,int finiteelement); 24 26 void GetNodalFunctionsDerivativesReference(IssmDouble* dbasis,GaussTetra* gauss,int finiteelement); 25 void GetInputDerivativeValue(IssmDouble* p, IssmDouble* plist,IssmDouble* xyz_list, GaussTetra* gauss,int finiteelement);26 void GetInputValue(IssmDouble* p, IssmDouble* plist, Gauss* gauss,int finiteelement);27 28 27 int NumberofNodes(int finiteelement); 29 int VelocityInterpolation(int fe_stokes);30 28 int PressureInterpolation(int fe_stokes); 31 29 int TensorInterpolation(int fe_stokes); 30 int VelocityInterpolation(int fe_stokes); 32 31 }; 33 32 #endif -
issm/trunk/src/c/classes/Elements/Tria.cpp
r18301 r19105 12 12 #include <stdio.h> 13 13 #include <string.h> 14 #include <math.h> 14 15 #include "../classes.h" 15 16 #include "../../shared/shared.h" … … 155 156 } 156 157 /*}}}*/ 158 void Tria::AverageOntoPartition(Vector<IssmDouble>* partition_contributions,Vector<IssmDouble>* partition_areas,IssmDouble* vertex_response,IssmDouble* qmu_part){/*{{{*/ 159 160 bool already = false; 161 int i,j; 162 int partition[NUMVERTICES]; 163 int offsetsid[NUMVERTICES]; 164 int offsetdof[NUMVERTICES]; 165 IssmDouble area; 166 IssmDouble mean; 167 168 /*First, get the area: */ 169 area=this->GetArea(); 170 171 /*Figure out the average for this element: */ 172 this->GetVerticesSidList(&offsetsid[0]); 173 this->GetVertexPidList(&offsetdof[0]); 174 mean=0; 175 for(i=0;i<NUMVERTICES;i++){ 176 partition[i]=reCast<int>(qmu_part[offsetsid[i]]); 177 mean=mean+1.0/NUMVERTICES*vertex_response[offsetdof[i]]; 178 } 179 180 /*Add contribution: */ 181 for(i=0;i<NUMVERTICES;i++){ 182 already=false; 183 for(j=0;j<i;j++){ 184 if (partition[i]==partition[j]){ 185 already=true; 186 break; 187 } 188 } 189 if(!already){ 190 partition_contributions->SetValue(partition[i],mean*area,ADD_VAL); 191 partition_areas->SetValue(partition[i],area,ADD_VAL); 192 }; 193 } 194 } 195 /*}}}*/ 196 void Tria::CalvingRateLevermann(){/*{{{*/ 197 198 IssmDouble xyz_list[NUMVERTICES][3]; 199 GaussTria* gauss=NULL; 200 IssmDouble vx,vy,vel; 201 IssmDouble strainparallel; 202 IssmDouble propcoeff; 203 IssmDouble strainperpendicular; 204 IssmDouble calvingratex[NUMVERTICES]; 205 IssmDouble calvingratey[NUMVERTICES]; 206 IssmDouble calvingrate[NUMVERTICES]; 207 208 209 /* Get node coordinates and dof list: */ 210 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 211 212 /*Retrieve all inputs and parameters we will need*/ 213 Input* vx_input=inputs->GetInput(VxEnum); _assert_(vx_input); 214 Input* vy_input=inputs->GetInput(VyEnum); _assert_(vy_input); 215 Input* strainparallel_input=inputs->GetInput(StrainRateparallelEnum); _assert_(strainparallel_input); 216 Input* strainperpendicular_input=inputs->GetInput(StrainRateperpendicularEnum); _assert_(strainperpendicular_input); 217 Input* levermanncoeff_input=inputs->GetInput(CalvinglevermannCoeffEnum); _assert_(levermanncoeff_input); 218 219 /* Start looping on the number of vertices: */ 220 gauss=new GaussTria(); 221 for (int iv=0;iv<NUMVERTICES;iv++){ 222 gauss->GaussVertex(iv); 223 224 /* Get the value we need*/ 225 vx_input->GetInputValue(&vx,gauss); 226 vy_input->GetInputValue(&vy,gauss); 227 vel=vx*vx+vy*vy; 228 strainparallel_input->GetInputValue(&strainparallel,gauss); 229 strainperpendicular_input->GetInputValue(&strainperpendicular,gauss); 230 levermanncoeff_input->GetInputValue(&propcoeff,gauss); 231 232 /*Calving rate proportionnal to the positive product of the strain rate along the ice flow direction and the strain rate perpendicular to the ice flow */ 233 calvingrate[iv]=propcoeff*strainparallel*strainperpendicular; 234 if(calvingrate[iv]<0){ 235 calvingrate[iv]=0; 236 } 237 calvingratex[iv]=calvingrate[iv]*vx/(sqrt(vel)+1.e-14); 238 calvingratey[iv]=calvingrate[iv]*vy/(sqrt(vel)+1.e-14); 239 } 240 241 /*Add input*/ 242 this->inputs->AddInput(new TriaInput(CalvingratexEnum,&calvingratex[0],P1Enum)); 243 this->inputs->AddInput(new TriaInput(CalvingrateyEnum,&calvingratey[0],P1Enum)); 244 this->inputs->AddInput(new TriaInput(CalvingCalvingrateEnum,&calvingrate[0],P1Enum)); 245 246 /*Clean up and return*/ 247 delete gauss; 248 249 } 250 /*}}}*/ 251 void Tria::CalvingRatePi(){/*{{{*/ 252 253 IssmDouble xyz_list[NUMVERTICES][3]; 254 GaussTria* gauss=NULL; 255 IssmDouble vx,vy,vel; 256 IssmDouble strainparallel; 257 IssmDouble sxx; 258 IssmDouble sxy; 259 IssmDouble syy; 260 IssmDouble sigVM; 261 IssmDouble thickness; 262 IssmDouble base; 263 IssmDouble hAB; 264 IssmDouble propcoeff; 265 IssmDouble calvingratex[NUMVERTICES]; 266 IssmDouble calvingratey[NUMVERTICES]; 267 IssmDouble calvingrate[NUMVERTICES]; 268 269 270 /* Get node coordinates and dof list: */ 271 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 272 273 /*Retrieve all inputs and parameters we will need*/ 274 Input* vx_input=inputs->GetInput(VxEnum); _assert_(vx_input); 275 Input* vy_input=inputs->GetInput(VyEnum); _assert_(vy_input); 276 Input* strainparallel_input=inputs->GetInput(StrainRateparallelEnum); _assert_(strainparallel_input); 277 Input* sxx_input=inputs->GetInput(DeviatoricStressxxEnum); _assert_(sxx_input); 278 Input* sxy_input=inputs->GetInput(DeviatoricStressxyEnum); _assert_(sxy_input); 279 Input* syy_input=inputs->GetInput(DeviatoricStressyyEnum); _assert_(syy_input); 280 Input* thickness_input=inputs->GetInput(ThicknessEnum); _assert_(thickness_input); 281 Input* base_input=inputs->GetInput(BaseEnum); _assert_(base_input); 282 Input* picoeff_input=inputs->GetInput(CalvingpiCoeffEnum); _assert_(picoeff_input); 283 284 285 286 /* Start looping on the number of vertices: */ 287 gauss=new GaussTria(); 288 for (int iv=0;iv<NUMVERTICES;iv++){ 289 gauss->GaussVertex(iv); 290 291 /* Get the value we need*/ 292 vx_input->GetInputValue(&vx,gauss); 293 vy_input->GetInputValue(&vy,gauss); 294 vel=vx*vx+vy*vy; 295 strainparallel_input->GetInputValue(&strainparallel,gauss); 296 sxx_input->GetInputValue(&sxx,gauss); 297 sxy_input->GetInputValue(&sxy,gauss); 298 syy_input->GetInputValue(&syy,gauss); 299 thickness_input->GetInputValue(&thickness,gauss); 300 base_input->GetInputValue(&base,gauss); 301 picoeff_input->GetInputValue(&propcoeff,gauss); 302 303 /* Computing sigma Von Mises*/ 304 sigVM=sqrt(sxx*sxx+syy*syy+3*sxy*sxy-sxx*syy); 305 306 /* Computing heigth above buoyancy*/ 307 hAB=thickness+1028/920*base; 308 309 /*Calving rate for Pi criterion proportionnal to the product of the strain rate along the ice flow direction and the Von Mises stress and the square of the glacier width (hardcoded) divided by the height above buoyancy and the max of the ice velocity power 3 and the ice density (ignored here)*/ 310 311 calvingrate[iv]=propcoeff*strainparallel*sigVM*25.e6/hAB/1e9; 312 if(calvingrate[iv]<0){ 313 calvingrate[iv]=0; 314 } 315 calvingrate[iv]=pow(calvingrate[iv],0.3); 316 calvingratex[iv]=calvingrate[iv]*vx/(sqrt(vel)+1.e-14); 317 calvingratey[iv]=calvingrate[iv]*vy/(sqrt(vel)+1.e-14); 318 } 319 320 /*Add input*/ 321 this->inputs->AddInput(new TriaInput(CalvingratexEnum,&calvingratex[0],P1Enum)); 322 this->inputs->AddInput(new TriaInput(CalvingrateyEnum,&calvingratey[0],P1Enum)); 323 this->inputs->AddInput(new TriaInput(CalvingCalvingrateEnum,&calvingrate[0],P1Enum)); 324 325 /*Clean up and return*/ 326 delete gauss; 327 328 } 329 /*}}}*/ 330 void Tria::CalvingRateDev(){/*{{{*/ 331 332 IssmDouble xyz_list[NUMVERTICES][3]; 333 IssmDouble epsilon[3]; /* epsilon=[exx,eyy,exy];*/ 334 IssmDouble calvingratex[NUMVERTICES]; 335 IssmDouble calvingratey[NUMVERTICES]; 336 IssmDouble calvingrate[NUMVERTICES]; 337 IssmDouble lambda1,lambda2,ex,ey,vx,vy,vel; 338 339 /* Get node coordinates and dof list: */ 340 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 341 342 /*Retrieve all inputs and parameters we will need*/ 343 Input* vx_input=inputs->GetInput(VxEnum); _assert_(vx_input); 344 Input* vy_input=inputs->GetInput(VyEnum); _assert_(vy_input); 345 346 /* Start looping on the number of vertices: */ 347 GaussTria* gauss=new GaussTria(); 348 for(int iv=0;iv<NUMVERTICES;iv++){ 349 gauss->GaussVertex(iv); 350 351 /*Get velocity components and thickness*/ 352 vx_input->GetInputValue(&vx,gauss); 353 vy_input->GetInputValue(&vy,gauss); 354 vel=sqrt(vx*vx+vy*vy)+1.e-14; 355 356 /*Compute strain rate and viscosity: */ 357 this->StrainRateSSA(&epsilon[0],&xyz_list[0][0],gauss,vx_input,vy_input); 358 359 /*Get Eigen values*/ 360 Matrix2x2Eigen(&lambda1,&lambda2,&ex,&ey,epsilon[0],epsilon[2],epsilon[1]); 361 _assert_(!xIsNan<IssmDouble>(lambda1)); 362 _assert_(!xIsNan<IssmDouble>(lambda2)); 363 364 /*Process Eigen values (only account for extension)*/ 365 lambda1 = max(lambda1,0.); 366 lambda2 = max(lambda2,0.); 367 368 /*Assign values*/ 369 calvingratex[iv]=vx*pow(lambda1 + lambda2,1./3.)*3.e+2; 370 calvingratey[iv]=vy*pow(lambda1 + lambda2,1./3.)*3.e+2; 371 calvingrate[iv]=sqrt(calvingratex[iv]*calvingratex[iv] + calvingratey[iv]*calvingratey[iv]); 372 } 373 374 /*Add input*/ 375 this->inputs->AddInput(new TriaInput(CalvingratexEnum,&calvingratex[0],P1Enum)); 376 this->inputs->AddInput(new TriaInput(CalvingrateyEnum,&calvingratey[0],P1Enum)); 377 this->inputs->AddInput(new TriaInput(CalvingCalvingrateEnum,&calvingrate[0],P1Enum)); 378 379 /*Clean up and return*/ 380 delete gauss; 381 } 382 /*}}}*/ 157 383 IssmDouble Tria::CharacteristicLength(void){/*{{{*/ 158 384 … … 164 390 } 165 391 /*}}}*/ 392 void Tria::ComputeDeviatoricStressTensor(){/*{{{*/ 393 394 IssmDouble xyz_list[NUMVERTICES][3]; 395 IssmDouble viscosity; 396 IssmDouble epsilon[3]; /* epsilon=[exx,eyy,exy];*/ 397 IssmDouble tau_xx[NUMVERTICES]; 398 IssmDouble tau_yy[NUMVERTICES]; 399 IssmDouble tau_zz[NUMVERTICES]={0,0,0}; 400 IssmDouble tau_xy[NUMVERTICES]; 401 IssmDouble tau_xz[NUMVERTICES]={0,0,0}; 402 IssmDouble tau_yz[NUMVERTICES]={0,0,0}; 403 GaussTria* gauss=NULL; 404 int domaintype,dim=2; 405 406 /* Get node coordinates and dof list: */ 407 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 408 409 /*Retrieve all inputs we will be needing: */ 410 this->FindParam(&domaintype,DomainTypeEnum); 411 if(domaintype!=Domain2DhorizontalEnum) _error_("deviatoric stress tensor calculation not implemented for mesh of type " <<EnumToStringx(domaintype)); 412 Input* vx_input=inputs->GetInput(VxEnum); _assert_(vx_input); 413 Input* vy_input=inputs->GetInput(VyEnum); _assert_(vy_input); 414 415 /* Start looping on the number of vertices: */ 416 gauss=new GaussTria(); 417 for (int iv=0;iv<NUMVERTICES;iv++){ 418 gauss->GaussVertex(iv); 419 420 /*Compute strain rate and viscosity: */ 421 this->StrainRateSSA(&epsilon[0],&xyz_list[0][0],gauss,vx_input,vy_input); 422 this->ViscositySSA(&viscosity,dim,&xyz_list[0][0],gauss,vx_input,vy_input); 423 424 /*Compute Stress*/ 425 tau_xx[iv]=2*viscosity*epsilon[0]; // tau = nu eps 426 tau_yy[iv]=2*viscosity*epsilon[1]; 427 tau_xy[iv]=2*viscosity*epsilon[2]; 428 } 429 430 /*Add Stress tensor components into inputs*/ 431 this->inputs->AddInput(new TriaInput(DeviatoricStressxxEnum,&tau_xx[0],P1Enum)); 432 this->inputs->AddInput(new TriaInput(DeviatoricStressxyEnum,&tau_xy[0],P1Enum)); 433 this->inputs->AddInput(new TriaInput(DeviatoricStressxzEnum,&tau_xz[0],P1Enum)); 434 this->inputs->AddInput(new TriaInput(DeviatoricStressyyEnum,&tau_yy[0],P1Enum)); 435 this->inputs->AddInput(new TriaInput(DeviatoricStressyzEnum,&tau_yz[0],P1Enum)); 436 this->inputs->AddInput(new TriaInput(DeviatoricStresszzEnum,&tau_zz[0],P1Enum)); 437 438 /*Clean up and return*/ 439 delete gauss; 440 } 441 /*}}}*/ 166 442 void Tria::ComputeSigmaNN(){/*{{{*/ 167 443 168 444 if(!IsOnBase()){ 169 IssmDouble sigma_nn =0;170 this->inputs->AddInput(new TriaInput(SigmaNNEnum,&sigma_nn ,P0Enum));445 IssmDouble sigma_nn[3]={0.}; 446 this->inputs->AddInput(new TriaInput(SigmaNNEnum,&sigma_nn[0],P1Enum)); 171 447 return; 172 448 } … … 174 450 IssmDouble* xyz_list=NULL; 175 451 IssmDouble *xyz_list_base=NULL; 176 IssmDouble pressure,viscosity,sigma_nn; 452 IssmDouble pressure,viscosity; 453 IssmDouble sigma_nn[3]; 177 454 IssmDouble sigma_xx,sigma_xy,sigma_yy; 178 455 IssmDouble epsilon[3]; /* epsilon=[exx,eyy,exy];*/ … … 192 469 193 470 /* Start looping on the number of vertices: */ 194 Gauss* gauss=NewGaussBase(1); 195 gauss->GaussPoint(0); 196 197 /*Compute strain rate viscosity and pressure: */ 198 this->StrainRateSSA(&epsilon[0],xyz_list,gauss,vx_input,vy_input); 199 this->ViscosityFS(&viscosity,dim,xyz_list,gauss,vx_input,vy_input,NULL); 200 pressure_input->GetInputValue(&pressure,gauss); 201 202 /*Compute Stress*/ 203 sigma_xx=2*viscosity*epsilon[0]-pressure; // sigma = nu eps - pressure 204 sigma_yy=2*viscosity*epsilon[1]-pressure; 205 sigma_xy=2*viscosity*epsilon[2]; 206 207 /*Get normal vector to the bed */ 208 NormalBase(&base_normal[0],xyz_list_base); 209 210 /*Compute sigma_nn*/ 211 sigma_nn=sigma_xx*base_normal[0]*base_normal[0] + 2*sigma_xy*base_normal[0]*base_normal[1] + sigma_yy*base_normal[1]*base_normal[1]; 471 Gauss* gauss = this->NewGauss(); 472 for(int i=0;i<NUMVERTICES;i++){ 473 gauss->GaussNode(P1Enum,i); 474 475 /*Compute strain rate viscosity and pressure: */ 476 this->StrainRateSSA(&epsilon[0],xyz_list,gauss,vx_input,vy_input); 477 this->ViscosityFS(&viscosity,dim,xyz_list,gauss,vx_input,vy_input,NULL); 478 pressure_input->GetInputValue(&pressure,gauss); 479 480 /*Compute Stress*/ 481 sigma_xx=2*viscosity*epsilon[0]-pressure; // sigma = nu eps - pressure 482 sigma_yy=2*viscosity*epsilon[1]-pressure; 483 sigma_xy=2*viscosity*epsilon[2]; 484 485 /*Get normal vector to the bed */ 486 NormalBase(&base_normal[0],xyz_list_base); 487 488 /*Compute sigma_nn*/ 489 sigma_nn[i]=sigma_xx*base_normal[0]*base_normal[0] + 2*sigma_xy*base_normal[0]*base_normal[1] + sigma_yy*base_normal[1]*base_normal[1]; 490 } 212 491 213 492 /*Add Stress tensor components into inputs*/ 214 this->inputs->AddInput(new TriaInput(SigmaNNEnum,&sigma_nn ,P0Enum));493 this->inputs->AddInput(new TriaInput(SigmaNNEnum,&sigma_nn[0],P1Enum)); 215 494 216 495 /*Clean up and return*/ … … 273 552 } 274 553 /*}}}*/ 275 void Tria::ComputeDeviatoricStressTensor(){/*{{{*/276 277 IssmDouble xyz_list[NUMVERTICES][3];278 IssmDouble viscosity;279 IssmDouble epsilon[3]; /* epsilon=[exx,eyy,exy];*/280 IssmDouble tau_xx[NUMVERTICES];281 IssmDouble tau_yy[NUMVERTICES];282 IssmDouble tau_zz[NUMVERTICES]={0,0,0};283 IssmDouble tau_xy[NUMVERTICES];284 IssmDouble tau_xz[NUMVERTICES]={0,0,0};285 IssmDouble tau_yz[NUMVERTICES]={0,0,0};286 GaussTria* gauss=NULL;287 int domaintype,dim=2;288 289 /* Get node coordinates and dof list: */290 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES);291 292 /*Retrieve all inputs we will be needing: */293 this->FindParam(&domaintype,DomainTypeEnum);294 if(domaintype!=Domain2DhorizontalEnum) _error_("deviatoric stress tensor calculation not implemented for mesh of type " <<EnumToStringx(domaintype));295 Input* vx_input=inputs->GetInput(VxEnum); _assert_(vx_input);296 Input* vy_input=inputs->GetInput(VyEnum); _assert_(vy_input);297 298 /* Start looping on the number of vertices: */299 gauss=new GaussTria();300 for (int iv=0;iv<NUMVERTICES;iv++){301 gauss->GaussVertex(iv);302 303 /*Compute strain rate and viscosity: */304 this->StrainRateSSA(&epsilon[0],&xyz_list[0][0],gauss,vx_input,vy_input);305 this->ViscositySSA(&viscosity,dim,&xyz_list[0][0],gauss,vx_input,vy_input);306 307 /*Compute Stress*/308 tau_xx[iv]=2*viscosity*epsilon[0]; // tau = nu eps309 tau_yy[iv]=2*viscosity*epsilon[1];310 tau_xy[iv]=2*viscosity*epsilon[2];311 }312 313 /*Add Stress tensor components into inputs*/314 this->inputs->AddInput(new TriaInput(DeviatoricStressxxEnum,&tau_xx[0],P1Enum));315 this->inputs->AddInput(new TriaInput(DeviatoricStressxyEnum,&tau_xy[0],P1Enum));316 this->inputs->AddInput(new TriaInput(DeviatoricStressxzEnum,&tau_xz[0],P1Enum));317 this->inputs->AddInput(new TriaInput(DeviatoricStressyyEnum,&tau_yy[0],P1Enum));318 this->inputs->AddInput(new TriaInput(DeviatoricStressyzEnum,&tau_yz[0],P1Enum));319 this->inputs->AddInput(new TriaInput(DeviatoricStresszzEnum,&tau_zz[0],P1Enum));320 321 /*Clean up and return*/322 delete gauss;323 }324 /*}}}*/325 554 void Tria::Configure(Elements* elementsin, Loads* loadsin,Nodes* nodesin,Vertices *verticesin,Materials* materialsin, Parameters* parametersin){/*{{{*/ 326 555 … … 358 587 } 359 588 /*}}}*/ 589 void Tria::ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index){/*{{{*/ 590 591 int vertexpidlist[NUMVERTICES]; 592 IssmDouble grad_list[NUMVERTICES]; 593 Input* grad_input=NULL; 594 595 Input* input=inputs->GetInput(enum_type); 596 if (!input) _error_("Input " << EnumToStringx(enum_type) << " not found"); 597 if (input->ObjectEnum()!=ControlInputEnum) _error_("Input " << EnumToStringx(enum_type) << " is not a ControlInput"); 598 599 GradientIndexing(&vertexpidlist[0],control_index); 600 for(int i=0;i<NUMVERTICES;i++) grad_list[i]=gradient[vertexpidlist[i]]; 601 grad_input=new TriaInput(GradientEnum,grad_list,P1Enum); 602 603 ((ControlInput*)input)->SetGradient(grad_input); 604 605 }/*}}}*/ 606 void Tria::ControlToVectors(Vector<IssmPDouble>* vector_control, Vector<IssmPDouble>* vector_gradient,int control_enum){/*{{{*/ 607 608 Input* input=inputs->GetInput(control_enum); 609 if (!input) _error_("Input " << EnumToStringx(control_enum) << " not found"); 610 if (input->ObjectEnum()!=ControlInputEnum) _error_("Input " << EnumToStringx(control_enum) << " is not a ControlInput"); 611 612 int sidlist[NUMVERTICES]; 613 int connectivity[NUMVERTICES]; 614 IssmPDouble values[NUMVERTICES]; 615 IssmPDouble gradients[NUMVERTICES]; 616 IssmDouble value,gradient; 617 618 this->GetVerticesConnectivityList(&connectivity[0]); 619 this->GetVerticesSidList(&sidlist[0]); 620 621 GaussTria* gauss=new GaussTria(); 622 for (int iv=0;iv<NUMVERTICES;iv++){ 623 gauss->GaussVertex(iv); 624 625 ((ControlInput*)input)->GetInputValue(&value,gauss); 626 ((ControlInput*)input)->GetGradientValue(&gradient,gauss); 627 628 values[iv] = reCast<IssmPDouble>(value)/reCast<IssmPDouble>(connectivity[iv]); 629 gradients[iv] = reCast<IssmPDouble>(gradient)/reCast<IssmPDouble>(connectivity[iv]); 630 } 631 delete gauss; 632 633 vector_control->SetValues(NUMVERTICES,&sidlist[0],&values[0],ADD_VAL); 634 vector_gradient->SetValues(NUMVERTICES,&sidlist[0],&gradients[0],ADD_VAL); 635 636 }/*}}}*/ 360 637 void Tria::Delta18oParameterization(void){/*{{{*/ 361 638 … … 385 662 input2->GetInputValue(&TemperaturesLgm[iv][month],gauss,month/12.*yts); 386 663 input3->GetInputValue(&PrecipitationsPresentday[iv][month],gauss,month/12.*yts); 387 PrecipitationsPresentday[iv][month]=PrecipitationsPresentday[iv][month]/yts; // converion in m/sec388 664 } 389 665 } … … 428 704 } 429 705 /*}}}*/ 706 void Tria::MungsmtpParameterization(void){/*{{{*/ 707 /*Are we on the base? If not, return*/ 708 if(!IsOnBase()) return; 709 710 int i; 711 IssmDouble monthlytemperatures[NUMVERTICES][12],monthlyprec[NUMVERTICES][12]; 712 IssmDouble TemperaturesPresentday[NUMVERTICES][12],TemperaturesLgm[NUMVERTICES][12]; 713 IssmDouble PrecipitationsPresentday[NUMVERTICES][12],PrecipitationsLgm[NUMVERTICES][12]; 714 IssmDouble tmp[NUMVERTICES]; 715 IssmDouble TdiffTime,PfacTime; 716 IssmDouble time,yts; 717 this->parameters->FindParam(&time,TimeEnum); 718 this->parameters->FindParam(&yts,ConstantsYtsEnum); 719 720 /*Recover present day temperature and precipitation*/ 721 Input* input=inputs->GetInput(SurfaceforcingsTemperaturesPresentdayEnum); _assert_(input); 722 Input* input2=inputs->GetInput(SurfaceforcingsTemperaturesLgmEnum); _assert_(input2); 723 Input* input3=inputs->GetInput(SurfaceforcingsPrecipitationsPresentdayEnum); _assert_(input3); 724 Input* input4=inputs->GetInput(SurfaceforcingsPrecipitationsLgmEnum); _assert_(input4); 725 GaussTria* gauss=new GaussTria(); 726 for(int month=0;month<12;month++) { 727 for(int iv=0;iv<NUMVERTICES;iv++) { 728 gauss->GaussVertex(iv); 729 input->GetInputValue(&TemperaturesPresentday[iv][month],gauss,month/12.*yts); 730 input2->GetInputValue(&TemperaturesLgm[iv][month],gauss,month/12.*yts); 731 input3->GetInputValue(&PrecipitationsPresentday[iv][month],gauss,month/12.*yts); 732 input4->GetInputValue(&PrecipitationsLgm[iv][month],gauss,month/12.*yts); 733 } 734 } 735 736 /*Recover interpolation parameters at time t*/ 737 this->parameters->FindParam(&TdiffTime,SurfaceforcingsTdiffEnum,time); 738 this->parameters->FindParam(&PfacTime,SurfaceforcingsPfacEnum,time); 739 740 /*Compute the temperature and precipitation*/ 741 for(int iv=0;iv<NUMVERTICES;iv++){ 742 ComputeMungsmTemperaturePrecipitation(TdiffTime,PfacTime, 743 &PrecipitationsLgm[iv][0],&PrecipitationsPresentday[iv][0], 744 &TemperaturesLgm[iv][0], &TemperaturesPresentday[iv][0], 745 &monthlytemperatures[iv][0], &monthlyprec[iv][0]); 746 } 747 748 /*Update inputs*/ 749 TransientInput* NewTemperatureInput = new TransientInput(SurfaceforcingsMonthlytemperaturesEnum); 750 TransientInput* NewPrecipitationInput = new TransientInput(SurfaceforcingsPrecipitationEnum); 751 for (int imonth=0;imonth<12;imonth++) { 752 for(i=0;i<NUMVERTICES;i++) tmp[i]=monthlytemperatures[i][imonth]; 753 TriaInput* newmonthinput1 = new TriaInput(SurfaceforcingsMonthlytemperaturesEnum,&tmp[0],P1Enum); 754 NewTemperatureInput->AddTimeInput(newmonthinput1,time+imonth/12.*yts); 755 756 for(i=0;i<NUMVERTICES;i++) tmp[i]=monthlyprec[i][imonth]; 757 TriaInput* newmonthinput2 = new TriaInput(SurfaceforcingsPrecipitationEnum,&tmp[0],P1Enum); 758 NewPrecipitationInput->AddTimeInput(newmonthinput2,time+imonth/12.*yts); 759 } 760 NewTemperatureInput->Configure(this->parameters); 761 NewPrecipitationInput->Configure(this->parameters); 762 763 this->inputs->AddInput(NewTemperatureInput); 764 this->inputs->AddInput(NewPrecipitationInput); 765 766 /*clean-up*/ 767 delete gauss; 768 } 769 /*}}}*/ 770 int Tria::EdgeOnBaseIndex(void){/*{{{*/ 771 772 IssmDouble values[NUMVERTICES]; 773 int indices[3][2] = {{1,2},{2,0},{0,1}}; 774 775 /*Retrieve all inputs and parameters*/ 776 GetInputListOnVertices(&values[0],MeshVertexonbaseEnum); 777 778 for(int i=0;i<3;i++){ 779 if(values[indices[i][0]] == 1. && values[indices[i][1]] == 1.){ 780 return i; 781 } 782 } 783 784 _printf_("list of vertices on bed: "<<values[0]<<" "<<values[1]<<" "<<values[2]); 785 _error_("Could not find 2 vertices on bed"); 786 } 787 /*}}}*/ 788 void Tria::EdgeOnBaseIndices(int* pindex1,int* pindex2){/*{{{*/ 789 790 IssmDouble values[NUMVERTICES]; 791 int indices[3][2] = {{1,2},{2,0},{0,1}}; 792 793 /*Retrieve all inputs and parameters*/ 794 GetInputListOnVertices(&values[0],MeshVertexonbaseEnum); 795 796 for(int i=0;i<3;i++){ 797 if(values[indices[i][0]] == 1. && values[indices[i][1]] == 1.){ 798 *pindex1 = indices[i][0]; 799 *pindex2 = indices[i][1]; 800 return; 801 } 802 } 803 804 _printf_("list of vertices on bed: "<<values[0]<<" "<<values[1]<<" "<<values[2]); 805 _error_("Could not find 2 vertices on bed"); 806 } 807 /*}}}*/ 808 int Tria::EdgeOnSurfaceIndex(void){/*{{{*/ 809 810 IssmDouble values[NUMVERTICES]; 811 int indices[3][2] = {{1,2},{2,0},{0,1}}; 812 813 /*Retrieve all inputs and parameters*/ 814 GetInputListOnVertices(&values[0],MeshVertexonsurfaceEnum); 815 816 for(int i=0;i<3;i++){ 817 if(values[indices[i][0]] == 1. && values[indices[i][1]] == 1.){ 818 return i; 819 } 820 } 821 822 _printf_("list of vertices on surface: "<<values[0]<<" "<<values[1]<<" "<<values[2]); 823 _error_("Could not find 2 vertices on surface"); 824 } 825 /*}}}*/ 826 void Tria::EdgeOnSurfaceIndices(int* pindex1,int* pindex2){/*{{{*/ 827 828 IssmDouble values[NUMVERTICES]; 829 int indices[3][2] = {{1,2},{2,0},{0,1}}; 830 831 /*Retrieve all inputs and parameters*/ 832 GetInputListOnVertices(&values[0],MeshVertexonsurfaceEnum); 833 834 for(int i=0;i<3;i++){ 835 if(values[indices[i][0]] == 1. && values[indices[i][1]] == 1.){ 836 *pindex1 = indices[i][0]; 837 *pindex2 = indices[i][1]; 838 return; 839 } 840 } 841 842 _printf_("list of vertices on surface: "<<values[0]<<" "<<values[1]<<" "<<values[2]); 843 _error_("Could not find 2 vertices on surface"); 844 } 845 /*}}}*/ 846 void Tria::ElementResponse(IssmDouble* presponse,int response_enum){/*{{{*/ 847 848 switch(response_enum){ 849 case MaterialsRheologyBbarEnum: 850 *presponse=this->material->GetBbar(); 851 break; 852 853 case VelEnum:{ 854 855 /*Get input:*/ 856 IssmDouble vel; 857 Input* vel_input; 858 859 vel_input=this->inputs->GetInput(VelEnum); _assert_(vel_input); 860 vel_input->GetInputAverage(&vel); 861 862 /*Assign output pointers:*/ 863 *presponse=vel;} 864 break; 865 default: 866 _error_("Response type " << EnumToStringx(response_enum) << " not supported yet!"); 867 } 868 869 } 870 /*}}}*/ 430 871 void Tria::ElementSizes(IssmDouble* hx,IssmDouble* hy,IssmDouble* hz){/*{{{*/ 431 872 … … 455 896 } 456 897 /*}}}*/ 457 int Tria::ObjectEnum(void){/*{{{*/ 458 459 return TriaEnum; 460 898 void Tria::FSContactMigration(Vector<IssmDouble>* vertexgrounded,Vector<IssmDouble>* vertexfloating){/*{{{*/ 899 900 if(!IsOnBase()) return; 901 902 int approximation; 903 inputs->GetInputValue(&approximation,ApproximationEnum); 904 905 if(approximation==HOApproximationEnum || approximation==SSAApproximationEnum || approximation==SSAHOApproximationEnum){ 906 for(int i=0;i<NUMVERTICES;i++){ 907 vertexgrounded->SetValue(vertices[i]->Pid(),+9999.,INS_VAL); 908 vertexfloating->SetValue(vertices[i]->Pid(),+9999.,INS_VAL); 909 } 910 } 911 else{ 912 /*Intermediaries*/ 913 IssmDouble* xyz_list = NULL; 914 IssmDouble* xyz_list_base = NULL; 915 IssmDouble pressure,water_pressure,sigma_nn,viscosity,bed,base; 916 IssmDouble bed_normal[2]; 917 IssmDouble epsilon[3]; /* epsilon=[exx,eyy,exy];*/ 918 IssmDouble surface=0,value=0; 919 bool grounded; 920 921 /* Get node coordinates and dof list: */ 922 GetVerticesCoordinates(&xyz_list); 923 GetVerticesCoordinatesBase(&xyz_list_base); 924 925 /*Retrieve all inputs we will be needing: */ 926 Input* pressure_input = inputs->GetInput(PressureEnum); _assert_(pressure_input); 927 Input* base_input = inputs->GetInput(BaseEnum); _assert_(base_input); 928 Input* bed_input = inputs->GetInput(BedEnum); _assert_(bed_input); 929 Input* vx_input = inputs->GetInput(VxEnum); _assert_(vx_input); 930 Input* vy_input = inputs->GetInput(VyEnum); _assert_(vy_input); 931 932 /*Create gauss point in the middle of the basal edge*/ 933 Gauss* gauss=NewGaussBase(1); 934 gauss->GaussPoint(0); 935 936 if(!IsFloating()){ 937 /*Check for basal force only if grounded and touching GL*/ 938 // if(this->inputs->Min(MaskGroundediceLevelsetEnum)==0.){ 939 this->StrainRateSSA(&epsilon[0],xyz_list,gauss,vx_input,vy_input); 940 this->ViscosityFS(&viscosity,2,xyz_list,gauss,vx_input,vy_input,NULL); 941 pressure_input->GetInputValue(&pressure, gauss); 942 base_input->GetInputValue(&base, gauss); 943 944 /*Compute Stress*/ 945 IssmDouble sigma_xx=2.*viscosity*epsilon[0]-pressure; 946 IssmDouble sigma_yy=2.*viscosity*epsilon[1]-pressure; 947 IssmDouble sigma_xy=2.*viscosity*epsilon[2]; 948 949 /*Get normal vector to the bed */ 950 NormalBase(&bed_normal[0],xyz_list_base); 951 952 /*basalforce*/ 953 sigma_nn = sigma_xx*bed_normal[0]*bed_normal[0] + sigma_yy*bed_normal[1]*bed_normal[1] + 2.*sigma_xy*bed_normal[0]*bed_normal[1]; 954 955 /*Compute water pressure*/ 956 IssmDouble rho_ice = matpar->GetMaterialParameter(MaterialsRhoIceEnum); 957 IssmDouble rho_water = matpar->GetMaterialParameter(MaterialsRhoSeawaterEnum); 958 IssmDouble gravity = matpar->GetMaterialParameter(ConstantsGEnum); 959 water_pressure=gravity*rho_water*base; 960 961 /*Compare basal stress to water pressure and determine whether it should ground*/ 962 if (sigma_nn<water_pressure) grounded=true; 963 else grounded=false; 964 } 965 else{ 966 /*Check for basal elevation if floating*/ 967 base_input->GetInputValue(&base, gauss); 968 bed_input->GetInputValue(&bed, gauss); 969 if(base<bed) grounded=true; 970 else grounded=false; 971 } 972 for(int i=0;i<NUMVERTICES;i++){ 973 if(grounded) vertexgrounded->SetValue(vertices[i]->Pid(),+1.,INS_VAL); 974 else vertexfloating->SetValue(vertices[i]->Pid(),+1.,INS_VAL); 975 } 976 977 /*clean up*/ 978 delete gauss; 979 xDelete<IssmDouble>(xyz_list); 980 xDelete<IssmDouble>(xyz_list_base); 981 } 461 982 } 462 983 /*}}}*/ … … 476 997 } 477 998 /*}}}*/ 999 IssmDouble Tria::GetAreaIce(void){/*{{{*/ 1000 1001 /*return area of element covered by ice*/ 1002 /*Intermediaries*/ 1003 int numiceverts; 1004 IssmDouble area_fraction; 1005 IssmDouble s[2]; // s:fraction of intersected triangle edges that lie inside ice 1006 int* indices=NULL; 1007 1008 this->GetLevelsetIntersection(&indices, &numiceverts, s, MaskIceLevelsetEnum, 0.); 1009 1010 switch (numiceverts){ 1011 case 0: // no vertex has ice: element is ice free 1012 area_fraction=0.; 1013 break; 1014 case 1: // one vertex has ice: get area of triangle 1015 area_fraction=s[0]*s[1]; 1016 break; 1017 case 2: // two vertices have ice: get area of quadrangle 1018 area_fraction=s[0]+s[1]-s[0]*s[1]; 1019 break; 1020 case NUMVERTICES: // all vertices have ice: return triangle area 1021 area_fraction=1.; 1022 break; 1023 default: 1024 _error_("Wrong number of ice vertices in Tria::GetAreaIce!"); 1025 break; 1026 } 1027 _assert_((area_fraction>=0.) && (area_fraction<=1.)); 1028 1029 xDelete<int>(indices); 1030 return area_fraction*this->GetArea(); 1031 }/*}}}*/ 478 1032 void Tria::GetAreaCoordinates(IssmDouble* area_coordinates,IssmDouble* xyz_zero,IssmDouble* xyz_list,int numpoints){/*{{{*/ 479 1033 /*Computeportion of the element that is grounded*/ … … 689 1243 } 690 1244 /*}}}*/ 691 void Tria::GetVerticesCoordinatesBase(IssmDouble** pxyz_list){/*{{{*/692 693 int indices[2];694 IssmDouble xyz_list[NUMVERTICES][3];695 696 /*Element XYZ list*/697 ::GetVerticesCoordinates(&xyz_list[0][0],this->vertices,NUMVERTICES);698 699 /*Allocate Output*/700 IssmDouble* xyz_list_edge = xNew<IssmDouble>(2*3);701 this->EdgeOnBaseIndices(&indices[0],&indices[1]);702 for(int i=0;i<2;i++) for(int j=0;j<2;j++) xyz_list_edge[i*3+j]=xyz_list[indices[i]][j];703 704 /*Assign output pointer*/705 *pxyz_list = xyz_list_edge;706 707 }/*}}}*/708 void Tria::GetVerticesCoordinatesTop(IssmDouble** pxyz_list){/*{{{*/709 710 int indices[2];711 IssmDouble xyz_list[NUMVERTICES][3];712 713 /*Element XYZ list*/714 ::GetVerticesCoordinates(&xyz_list[0][0],this->vertices,NUMVERTICES);715 716 /*Allocate Output*/717 IssmDouble* xyz_list_edge = xNew<IssmDouble>(2*3);718 this->EdgeOnSurfaceIndices(&indices[0],&indices[1]);719 for(int i=0;i<2;i++) for(int j=0;j<2;j++) xyz_list_edge[i*3+j]=xyz_list[indices[i]][j];720 721 /*Assign output pointer*/722 *pxyz_list = xyz_list_edge;723 724 }/*}}}*/725 void Tria::NormalSection(IssmDouble* normal,IssmDouble* xyz_list){/*{{{*/726 727 /*Build unit outward pointing vector*/728 IssmDouble vector[2];729 IssmDouble norm;730 731 vector[0]=xyz_list[1*3+0] - xyz_list[0*3+0];732 vector[1]=xyz_list[1*3+1] - xyz_list[0*3+1];733 734 norm=sqrt(vector[0]*vector[0] + vector[1]*vector[1]);735 736 normal[0]= + vector[1]/norm;737 normal[1]= - vector[0]/norm;738 }739 /*}}}*/740 void Tria::ZeroLevelsetCoordinates(IssmDouble** pxyz_zero,IssmDouble* xyz_list,int levelsetenum){/*{{{*/741 742 int normal_orientation=0;743 IssmDouble s1,s2;744 IssmDouble levelset[NUMVERTICES];745 746 /*Recover parameters and values*/747 IssmDouble* xyz_zero = xNew<IssmDouble>(2*3);748 GetInputListOnVertices(&levelset[0],levelsetenum);749 750 if(levelset[0]*levelset[1]>0.){ //Nodes 0 and 1 are similar, so points must be found on segment 0-2 and 1-2751 /*Portion of the segments*/752 s1=levelset[2]/(levelset[2]-levelset[1]);753 s2=levelset[2]/(levelset[2]-levelset[0]);754 755 if(levelset[2]<0.) normal_orientation=1; //orientation of quadrangle depending on distribution of levelsetfunction756 /*New point 1*/757 xyz_zero[3*normal_orientation+0]=xyz_list[2*3+0]+s1*(xyz_list[1*3+0]-xyz_list[2*3+0]);758 xyz_zero[3*normal_orientation+1]=xyz_list[2*3+1]+s1*(xyz_list[1*3+1]-xyz_list[2*3+1]);759 xyz_zero[3*normal_orientation+2]=xyz_list[2*3+2]+s1*(xyz_list[1*3+2]-xyz_list[2*3+2]);760 761 /*New point 0*/762 xyz_zero[3*(1-normal_orientation)+0]=xyz_list[2*3+0]+s2*(xyz_list[0*3+0]-xyz_list[2*3+0]);763 xyz_zero[3*(1-normal_orientation)+1]=xyz_list[2*3+1]+s2*(xyz_list[0*3+1]-xyz_list[2*3+1]);764 xyz_zero[3*(1-normal_orientation)+2]=xyz_list[2*3+2]+s2*(xyz_list[0*3+2]-xyz_list[2*3+2]);765 }766 else if(levelset[1]*levelset[2]>0.){ //Nodes 1 and 2 are similar, so points must be found on segment 0-1 and 0-2767 /*Portion of the segments*/768 s1=levelset[0]/(levelset[0]-levelset[2]);769 s2=levelset[0]/(levelset[0]-levelset[1]);770 771 if(levelset[0]<0.) normal_orientation=1;772 /*New point 1*/773 xyz_zero[3*normal_orientation+0]=xyz_list[0*3+0]+s1*(xyz_list[2*3+0]-xyz_list[0*3+0]);774 xyz_zero[3*normal_orientation+1]=xyz_list[0*3+1]+s1*(xyz_list[2*3+1]-xyz_list[0*3+1]);775 xyz_zero[3*normal_orientation+2]=xyz_list[0*3+2]+s1*(xyz_list[2*3+2]-xyz_list[0*3+2]);776 777 /*New point 2*/778 xyz_zero[3*(1-normal_orientation)+0]=xyz_list[0*3+0]+s2*(xyz_list[1*3+0]-xyz_list[0*3+0]);779 xyz_zero[3*(1-normal_orientation)+1]=xyz_list[0*3+1]+s2*(xyz_list[1*3+1]-xyz_list[0*3+1]);780 xyz_zero[3*(1-normal_orientation)+2]=xyz_list[0*3+2]+s2*(xyz_list[1*3+2]-xyz_list[0*3+2]);781 }782 else if(levelset[0]*levelset[2]>0.){ //Nodes 0 and 2 are similar, so points must be found on segment 1-0 and 1-2783 /*Portion of the segments*/784 s1=levelset[1]/(levelset[1]-levelset[0]);785 s2=levelset[1]/(levelset[1]-levelset[2]);786 787 if(levelset[1]<0.) normal_orientation=1;788 /*New point 0*/789 xyz_zero[3*normal_orientation+0]=xyz_list[1*3+0]+s1*(xyz_list[0*3+0]-xyz_list[1*3+0]);790 xyz_zero[3*normal_orientation+1]=xyz_list[1*3+1]+s1*(xyz_list[0*3+1]-xyz_list[1*3+1]);791 xyz_zero[3*normal_orientation+2]=xyz_list[1*3+2]+s1*(xyz_list[0*3+2]-xyz_list[1*3+2]);792 793 /*New point 2*/794 xyz_zero[3*(1-normal_orientation)+0]=xyz_list[1*3+0]+s2*(xyz_list[2*3+0]-xyz_list[1*3+0]);795 xyz_zero[3*(1-normal_orientation)+1]=xyz_list[1*3+1]+s2*(xyz_list[2*3+1]-xyz_list[1*3+1]);796 xyz_zero[3*(1-normal_orientation)+2]=xyz_list[1*3+2]+s2*(xyz_list[2*3+2]-xyz_list[1*3+2]);797 }798 else if(levelset[0]==0. && levelset[1]==0.){ //front is on point 0 and 1799 xyz_zero[3*0+0]=xyz_list[0*3+0];800 xyz_zero[3*0+1]=xyz_list[0*3+1];801 xyz_zero[3*0+2]=xyz_list[0*3+2];802 803 /*New point 2*/804 xyz_zero[3*1+0]=xyz_list[1*3+0];805 xyz_zero[3*1+1]=xyz_list[1*3+1];806 xyz_zero[3*1+2]=xyz_list[1*3+2];807 }808 else if(levelset[0]==0. && levelset[2]==0.){ //front is on point 0 and 1809 xyz_zero[3*0+0]=xyz_list[2*3+0];810 xyz_zero[3*0+1]=xyz_list[2*3+1];811 xyz_zero[3*0+2]=xyz_list[2*3+2];812 813 /*New point 2*/814 xyz_zero[3*1+0]=xyz_list[0*3+0];815 xyz_zero[3*1+1]=xyz_list[0*3+1];816 xyz_zero[3*1+2]=xyz_list[0*3+2];817 }818 else if(levelset[1]==0. && levelset[2]==0.){ //front is on point 0 and 1819 xyz_zero[3*0+0]=xyz_list[1*3+0];820 xyz_zero[3*0+1]=xyz_list[1*3+1];821 xyz_zero[3*0+2]=xyz_list[1*3+2];822 823 /*New point 2*/824 xyz_zero[3*1+0]=xyz_list[2*3+0];825 xyz_zero[3*1+1]=xyz_list[2*3+1];826 xyz_zero[3*1+2]=xyz_list[2*3+2];827 }828 else _error_("Case not covered");829 830 /*Assign output pointer*/831 *pxyz_zero= xyz_zero;832 }833 /*}}}*/834 1245 void Tria::GetIcefrontCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum){/*{{{*/ 835 1246 … … 872 1283 xDelete<int>(indicesfront); 873 1284 }/*}}}*/ 1285 void Tria::GetInputValue(IssmDouble* pvalue,Node* node,int enumtype){/*{{{*/ 1286 1287 Input* input=inputs->GetInput(enumtype); 1288 if(!input) _error_("No input of type " << EnumToStringx(enumtype) << " found in tria"); 1289 1290 GaussTria* gauss=new GaussTria(); 1291 gauss->GaussVertex(this->GetNodeIndex(node)); 1292 1293 input->GetInputValue(pvalue,gauss); 1294 delete gauss; 1295 } 1296 /*}}}*/ 874 1297 void Tria::GetLevelCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum,IssmDouble level){/*{{{*/ 875 1298 … … 912 1335 xDelete<int>(indicesfront); 913 1336 }/*}}}*/ 1337 void Tria::GetLevelsetIntersection(int** pindices, int* pnumiceverts, IssmDouble* fraction, int levelset_enum, IssmDouble level){/*{{{*/ 1338 1339 /* GetLevelsetIntersection computes: 1340 * 1. indices of element, sorted in [iceverts, noiceverts] in counterclockwise fashion, 1341 * 2. fraction of intersected triangle edges intersected by levelset, lying below level*/ 1342 1343 /*Intermediaries*/ 1344 int i, numiceverts, numnoiceverts; 1345 int ind0, ind1, lastindex; 1346 int indices_ice[NUMVERTICES],indices_noice[NUMVERTICES]; 1347 IssmDouble lsf[NUMVERTICES]; 1348 int* indices = xNew<int>(NUMVERTICES); 1349 1350 /*Retrieve all inputs and parameters*/ 1351 GetInputListOnVertices(&lsf[0],levelset_enum); 1352 1353 /* Determine distribution of ice over element. 1354 * Exploit: ice/no-ice parts are connected, so find starting vertex of segment*/ 1355 lastindex=0; 1356 for(i=0;i<NUMVERTICES;i++){ // go backwards along vertices, and check for sign change 1357 ind0=(NUMVERTICES-i)%NUMVERTICES; 1358 ind1=(ind0-1+NUMVERTICES)%NUMVERTICES; 1359 if((lsf[ind0]-level)*(lsf[ind1]-level)<=0.){ // levelset has been crossed, find last index belonging to segment 1360 if(lsf[ind1]==level) //if levelset intersects 2nd vertex, choose this vertex as last 1361 lastindex=ind1; 1362 else 1363 lastindex=ind0; 1364 break; 1365 } 1366 } 1367 1368 numiceverts=0; 1369 numnoiceverts=0; 1370 for(i=0;i<NUMVERTICES;i++){ 1371 ind0=(lastindex+i)%NUMVERTICES; 1372 if(lsf[i]<=level){ 1373 indices_ice[numiceverts]=i; 1374 numiceverts++; 1375 } 1376 else{ 1377 indices_noice[numnoiceverts]=i; 1378 numnoiceverts++; 1379 } 1380 } 1381 //merge indices 1382 for(i=0;i<numiceverts;i++){indices[i]=indices_ice[i];} 1383 for(i=0;i<numnoiceverts;i++){indices[numiceverts+i]=indices_noice[i];} 1384 1385 switch (numiceverts){ 1386 case 0: // no vertex has ice: element is ice free, no intersection 1387 for(i=0;i<2;i++) 1388 fraction[i]=0.; 1389 break; 1390 case 1: // one vertex has ice: 1391 for(i=0;i<2;i++){ 1392 fraction[i]=(level-lsf[indices[0]])/(lsf[indices[numiceverts+i]]-lsf[indices[0]]); 1393 } 1394 break; 1395 case 2: // two vertices have ice: fraction is computed from first ice vertex to last in CCW fashion 1396 for(i=0;i<2;i++){ 1397 fraction[i]=(level-lsf[indices[i]])/(lsf[indices[numiceverts]]-lsf[indices[i]]); 1398 } 1399 break; 1400 case NUMVERTICES: // all vertices have ice: return triangle area 1401 for(i=0;i<2;i++) 1402 fraction[i]=1.; 1403 break; 1404 default: 1405 _error_("Wrong number of ice vertices in Tria::GetLevelsetIntersection!"); 1406 break; 1407 } 1408 1409 *pindices=indices; 1410 *pnumiceverts=numiceverts; 1411 } 1412 /*}}}*/ 1413 void Tria::GetLevelsetPositivePart(int* point1,IssmDouble* fraction1,IssmDouble* fraction2, bool* mainlynegative,IssmDouble* gl){/*{{{*/ 1414 1415 /*Computeportion of the element that has a positive levelset*/ 1416 1417 bool negative=true; 1418 int point; 1419 const IssmPDouble epsilon= 1.e-15; 1420 IssmDouble f1,f2; 1421 1422 /*Be sure that values are not zero*/ 1423 if(gl[0]==0.) gl[0]=gl[0]+epsilon; 1424 if(gl[1]==0.) gl[1]=gl[1]+epsilon; 1425 if(gl[2]==0.) gl[2]=gl[2]+epsilon; 1426 1427 /*Check that not all nodes are positive or negative*/ 1428 if(gl[0]>0 && gl[1]>0 && gl[2]>0){ // All positive 1429 point=0; 1430 f1=1.; 1431 f2=1.; 1432 } 1433 else if(gl[0]<0 && gl[1]<0 && gl[2]<0){ //All negative 1434 point=0; 1435 f1=0.; 1436 f2=0.; 1437 } 1438 else{ 1439 if(gl[0]*gl[1]*gl[2]<0) negative=false; 1440 1441 if(gl[0]*gl[1]>0){ //Nodes 0 and 1 are similar, so points must be found on segment 0-2 and 1-2 1442 point=2; 1443 f1=gl[2]/(gl[2]-gl[0]); 1444 f2=gl[2]/(gl[2]-gl[1]); 1445 } 1446 else if(gl[1]*gl[2]>0){ //Nodes 1 and 2 are similar, so points must be found on segment 0-1 and 0-2 1447 point=0; 1448 f1=gl[0]/(gl[0]-gl[1]); 1449 f2=gl[0]/(gl[0]-gl[2]); 1450 } 1451 else if(gl[0]*gl[2]>0){ //Nodes 0 and 2 are similar, so points must be found on segment 1-0 and 1-2 1452 point=1; 1453 f1=gl[1]/(gl[1]-gl[2]); 1454 f2=gl[1]/(gl[1]-gl[0]); 1455 } 1456 } 1457 *point1=point; 1458 *fraction1=f1; 1459 *fraction2=f2; 1460 *mainlynegative=negative; 1461 } 1462 /*}}}*/ 1463 Node* Tria::GetNode(int node_number){/*{{{*/ 1464 _assert_(node_number>=0); 1465 _assert_(node_number<this->NumberofNodes(this->element_type)); 1466 return this->nodes[node_number]; 1467 1468 }/*}}}*/ 914 1469 int Tria::GetNodeIndex(Node* node){/*{{{*/ 915 1470 … … 935 1490 } 936 1491 /*}}}*/ 937 void Tria::GetInputValue(IssmDouble* pvalue,Node* node,int enumtype){/*{{{*/ 938 939 Input* input=inputs->GetInput(enumtype); 940 if(!input) _error_("No input of type " << EnumToStringx(enumtype) << " found in tria"); 941 1492 void Tria::GetSolutionFromInputsOneDof(Vector<IssmDouble>* solution, int enum_type){/*{{{*/ 1493 1494 int *doflist = NULL; 1495 IssmDouble value; 1496 1497 /*Fetch number of nodes for this finite element*/ 1498 int numnodes = this->NumberofNodes(this->element_type); 1499 1500 /*Fetch dof list and allocate solution vector*/ 1501 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 1502 IssmDouble* values = xNew<IssmDouble>(numnodes); 1503 1504 /*Get inputs*/ 1505 Input* enum_input=inputs->GetInput(enum_type); _assert_(enum_input); 1506 1507 /*Ok, we have the values, fill in the array: */ 942 1508 GaussTria* gauss=new GaussTria(); 943 gauss->GaussVertex(this->GetNodeIndex(node)); 944 945 input->GetInputValue(pvalue,gauss); 1509 for(int i=0;i<numnodes;i++){ 1510 gauss->GaussNode(this->element_type,i); 1511 1512 enum_input->GetInputValue(&value,gauss); 1513 values[i]=value; 1514 } 1515 1516 solution->SetValues(numnodes,doflist,values,INS_VAL); 1517 1518 /*Free ressources:*/ 1519 xDelete<int>(doflist); 1520 xDelete<IssmDouble>(values); 946 1521 delete gauss; 947 1522 } 948 1523 /*}}}*/ 949 Node* Tria::GetNode(int node_number){/*{{{*/ 950 _assert_(node_number>=0); 951 _assert_(node_number<this->NumberofNodes(this->element_type)); 952 return this->nodes[node_number]; 1524 void Tria::GetVectorFromControlInputs(Vector<IssmDouble>* vector,int control_enum,int control_index,const char* data,bool onsid){/*{{{*/ 1525 1526 int vertexidlist[NUMVERTICES]; 1527 Input *input=NULL; 1528 1529 /*Get out if this is not an element input*/ 1530 if(!IsInput(control_enum)) return; 1531 1532 /*Prepare index list*/ 1533 GradientIndexing(&vertexidlist[0],control_index,onsid); 1534 1535 /*Get input (either in element or material)*/ 1536 input=(Input*)this->inputs->GetInput(control_enum); _assert_(input); 1537 1538 /*Check that it is a ControlInput*/ 1539 if (input->ObjectEnum()!=ControlInputEnum){ 1540 _error_("input " << EnumToStringx(control_enum) << " is not a ControlInput"); 1541 } 1542 1543 ((ControlInput*)input)->GetVectorFromInputs(vector,&vertexidlist[0],data); 1544 } 1545 /*}}}*/ 1546 void Tria::GetVerticesCoordinatesBase(IssmDouble** pxyz_list){/*{{{*/ 1547 1548 int indices[2]; 1549 IssmDouble xyz_list[NUMVERTICES][3]; 1550 1551 /*Element XYZ list*/ 1552 ::GetVerticesCoordinates(&xyz_list[0][0],this->vertices,NUMVERTICES); 1553 1554 /*Allocate Output*/ 1555 IssmDouble* xyz_list_edge = xNew<IssmDouble>(2*3); 1556 this->EdgeOnBaseIndices(&indices[0],&indices[1]); 1557 for(int i=0;i<2;i++) for(int j=0;j<2;j++) xyz_list_edge[i*3+j]=xyz_list[indices[i]][j]; 1558 1559 /*Assign output pointer*/ 1560 *pxyz_list = xyz_list_edge; 953 1561 954 1562 }/*}}}*/ 1563 void Tria::GetVerticesCoordinatesTop(IssmDouble** pxyz_list){/*{{{*/ 1564 1565 int indices[2]; 1566 IssmDouble xyz_list[NUMVERTICES][3]; 1567 1568 /*Element XYZ list*/ 1569 ::GetVerticesCoordinates(&xyz_list[0][0],this->vertices,NUMVERTICES); 1570 1571 /*Allocate Output*/ 1572 IssmDouble* xyz_list_edge = xNew<IssmDouble>(2*3); 1573 this->EdgeOnSurfaceIndices(&indices[0],&indices[1]); 1574 for(int i=0;i<2;i++) for(int j=0;j<2;j++) xyz_list_edge[i*3+j]=xyz_list[indices[i]][j]; 1575 1576 /*Assign output pointer*/ 1577 *pxyz_list = xyz_list_edge; 1578 1579 }/*}}}*/ 1580 bool Tria::HasEdgeOnBase(){/*{{{*/ 1581 1582 IssmDouble values[NUMVERTICES]; 1583 IssmDouble sum; 1584 1585 /*Retrieve all inputs and parameters*/ 1586 GetInputListOnVertices(&values[0],MeshVertexonbaseEnum); 1587 sum = values[0]+values[1]+values[2]; 1588 1589 _assert_(sum==0. || sum==1. || sum==2.); 1590 1591 if(sum==3.) _error_("Two edges on bed not supported yet..."); 1592 1593 if(sum>1.){ 1594 return true; 1595 } 1596 else{ 1597 return false; 1598 } 1599 } 1600 /*}}}*/ 1601 bool Tria::HasEdgeOnSurface(){/*{{{*/ 1602 1603 IssmDouble values[NUMVERTICES]; 1604 IssmDouble sum; 1605 1606 /*Retrieve all inputs and parameters*/ 1607 GetInputListOnVertices(&values[0],MeshVertexonsurfaceEnum); 1608 sum = values[0]+values[1]+values[2]; 1609 1610 _assert_(sum==0. || sum==1. || sum==2.); 1611 1612 if(sum==3.) _error_("Two edges on surface not supported yet..."); 1613 1614 if(sum>1.){ 1615 return true; 1616 } 1617 else{ 1618 return false; 1619 } 1620 } 1621 /*}}}*/ 1622 IssmDouble Tria::IceMass(void){/*{{{*/ 1623 1624 IssmDouble rho_ice; 1625 1626 if(!IsIceInElement())return 0.; //do not contribute to the volume of the ice! 1627 1628 /*recover ice density: */ 1629 rho_ice=matpar->GetMaterialParameter(MaterialsRhoIceEnum); 1630 1631 return rho_ice*this->IceVolume(); 1632 } 1633 /*}}}*/ 1634 IssmDouble Tria::IceVolume(void){/*{{{*/ 1635 1636 /*The volume of a truncated prism is area_base * 1/numedges sum(length of edges)*/ 1637 1638 /*Intermediaries*/ 1639 int i, numiceverts; 1640 IssmDouble area_base,surface,base,Haverage; 1641 IssmDouble Haux[NUMVERTICES], surfaces[NUMVERTICES], bases[NUMVERTICES]; 1642 IssmDouble s[2]; // s:fraction of intersected triangle edges, that lies inside ice 1643 int* indices=NULL; 1644 IssmDouble* H=NULL; 1645 1646 if(!IsIceInElement())return 0.; 1647 1648 int domaintype; 1649 parameters->FindParam(&domaintype,DomainTypeEnum); 1650 1651 if(false && IsIcefront()){ 1652 area_base=this->GetAreaIce(); 1653 //Assumption: linear ice thickness profile on element. 1654 //Hence ice thickness at intersection of levelset function with triangle edge is linear interpolation of ice thickness at vertices. 1655 this->GetLevelsetIntersection(&indices, &numiceverts, s, MaskIceLevelsetEnum, 0.); 1656 GetInputListOnVertices(&surfaces[0],SurfaceEnum); 1657 GetInputListOnVertices(&bases[0],BaseEnum); 1658 for(i=0;i<NUMVERTICES;i++) Haux[i]= surfaces[indices[i]]-bases[indices[i]]; //sort thicknesses in ice/noice 1659 int numthk=numiceverts+2; 1660 H=xNew<IssmDouble>(numthk); 1661 switch(numiceverts){ 1662 case 1: // average over triangle 1663 H[0]=Haux[0]; 1664 H[1]=Haux[0]+s[0]*(Haux[1]-Haux[0]); 1665 H[2]=Haux[0]+s[1]*(Haux[2]-Haux[0]); 1666 break; 1667 case 2: // average over quadrangle 1668 H[0]=Haux[0]; 1669 H[1]=Haux[1]; 1670 H[2]=Haux[0]+s[0]*(Haux[2]-Haux[0]); 1671 H[3]=Haux[1]+s[1]*(Haux[2]-Haux[1]); 1672 break; 1673 default: 1674 _error_("Number of ice covered vertices wrong in Tria::IceVolume()"); 1675 break; 1676 } 1677 Haverage=0.; 1678 for(i=0;i<numthk;i++) Haverage+=H[i]; 1679 Haverage/=IssmDouble(numthk); 1680 } 1681 else{ 1682 /*First get back the area of the base*/ 1683 area_base=this->GetArea(); 1684 1685 /*Now get the average height*/ 1686 Input* surface_input = inputs->GetInput(SurfaceEnum); _assert_(surface_input); 1687 Input* base_input = inputs->GetInput(BaseEnum); _assert_(base_input); 1688 surface_input->GetInputAverage(&surface); 1689 base_input->GetInputAverage(&base); 1690 Haverage=surface-base; 1691 } 1692 1693 /*Cleanup & return: */ 1694 xDelete<int>(indices); 1695 xDelete<IssmDouble>(H); 1696 1697 if(domaintype==Domain2DverticalEnum){ 1698 return area_base; 1699 } 1700 else{ 1701 return area_base*Haverage; 1702 } 1703 } 1704 /*}}}*/ 1705 IssmDouble Tria::IceVolumeAboveFloatation(void){/*{{{*/ 1706 1707 /*The volume above floatation: H + rho_water/rho_ice * bathymetry */ 1708 IssmDouble rho_ice,rho_water; 1709 IssmDouble base,surface,bed,bathymetry; 1710 IssmDouble xyz_list[NUMVERTICES][3]; 1711 1712 if(!IsIceInElement() || IsFloating())return 0; 1713 1714 rho_ice=matpar->GetMaterialParameter(MaterialsRhoIceEnum); 1715 rho_water=matpar->GetMaterialParameter(MaterialsRhoSeawaterEnum); 1716 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 1717 1718 /*First calculate the area of the base (cross section triangle) 1719 * http://en.wikipedia.org/wiki/Triangle 1720 * base = 1/2 abs((xA-xC)(yB-yA)-(xA-xB)(yC-yA))*/ 1721 base = 1./2. * fabs((xyz_list[0][0]-xyz_list[2][0])*(xyz_list[1][1]-xyz_list[0][1]) - (xyz_list[0][0]-xyz_list[1][0])*(xyz_list[2][1]-xyz_list[0][1])); 1722 1723 /*Now get the average height and bathymetry*/ 1724 Input* surface_input = inputs->GetInput(SurfaceEnum); _assert_(surface_input); 1725 Input* base_input = inputs->GetInput(BaseEnum); _assert_(base_input); 1726 Input* bed_input = inputs->GetInput(BedEnum); _assert_(bed_input); 1727 surface_input->GetInputAverage(&surface); 1728 base_input->GetInputAverage(&bed); 1729 bed_input->GetInputAverage(&bathymetry); 1730 1731 /*Return: */ 1732 return base*(surface-bed+min(rho_water/rho_ice*bathymetry,0.)); 1733 } 1734 /*}}}*/ 1735 void Tria::InputControlUpdate(IssmDouble scalar,bool save_parameter){/*{{{*/ 1736 1737 /*Intermediary*/ 1738 int num_controls; 1739 int* control_type=NULL; 1740 Input* input=NULL; 1741 1742 /*retrieve some parameters: */ 1743 this->parameters->FindParam(&num_controls,InversionNumControlParametersEnum); 1744 this->parameters->FindParam(&control_type,NULL,InversionControlParametersEnum); 1745 1746 for(int i=0;i<num_controls;i++){ 1747 input=(Input*)this->inputs->GetInput(control_type[i]); _assert_(input); 1748 if (input->ObjectEnum()!=ControlInputEnum){ 1749 _error_("input " << EnumToStringx(control_type[i]) << " is not a ControlInput"); 1750 } 1751 1752 ((ControlInput*)input)->UpdateValue(scalar); 1753 ((ControlInput*)input)->Constrain(); 1754 if (save_parameter) ((ControlInput*)input)->SaveValue(); 1755 1756 } 1757 1758 /*Clean up and return*/ 1759 xDelete<int>(control_type); 1760 } 1761 /*}}}*/ 955 1762 void Tria::InputDepthAverageAtBase(int enum_type,int average_enum_type){/*{{{*/ 956 1763 … … 1031 1838 /*No yts conversion*/ 1032 1839 case ThicknessEnum: 1840 case BalancethicknessOmegaEnum: 1033 1841 case FrictionCoefficientEnum: 1034 case BalancethicknessNuxEnum:1035 case BalancethicknessNuyEnum:1842 case FrictionAsEnum: 1843 case MaterialsRheologyBEnum: 1036 1844 if(iomodel->Data(control)){ 1037 1845 for(j=0;j<NUMVERTICES;j++)nodeinputs[j]=iomodel->Data(control)[tria_vertex_ids[j]-1]; … … 1135 1943 1136 1944 case NodesEnum: 1137 1138 1945 /*Get number of nodes and dof list: */ 1139 1946 numnodes = this->NumberofNodes(this->element_type); … … 1149 1956 1150 1957 case NodeSIdEnum: 1151 1152 1958 /*Get number of nodes and dof list: */ 1153 1959 numnodes = this->NumberofNodes(this->element_type); … … 1169 1975 xDelete<IssmDouble>(values); 1170 1976 1977 } 1978 /*}}}*/ 1979 bool Tria::IsFaceOnBoundary(void){/*{{{*/ 1980 1981 IssmDouble values[NUMVERTICES]; 1982 IssmDouble sum; 1983 1984 /*Retrieve all inputs and parameters*/ 1985 GetInputListOnVertices(&values[0],MeshVertexonboundaryEnum); 1986 sum = values[0]+values[1]+values[2]; 1987 1988 _assert_(sum==0. || sum==1. || sum==2.); 1989 1990 if(sum==3.) _error_("Two edges on boundary not supported yet..."); 1991 1992 if(sum>1.){ 1993 return true; 1994 } 1995 else{ 1996 return false; 1997 } 1998 }/*}}}*/ 1999 bool Tria::IsIcefront(void){/*{{{*/ 2000 2001 bool isicefront; 2002 int i,nrice; 2003 IssmDouble ls[NUMVERTICES]; 2004 2005 /*Retrieve all inputs and parameters*/ 2006 GetInputListOnVertices(&ls[0],MaskIceLevelsetEnum); 2007 2008 /* If only one vertex has ice, there is an ice front here */ 2009 isicefront=false; 2010 if(IsIceInElement()){ 2011 nrice=0; 2012 for(i=0;i<NUMVERTICES;i++) 2013 if(ls[i]<0.) nrice++; 2014 if(nrice==1) isicefront= true; 2015 } 2016 return isicefront; 2017 }/*}}}*/ 2018 bool Tria::IsNodeOnShelfFromFlags(IssmDouble* flags){/*{{{*/ 2019 2020 int i; 2021 bool shelf=false; 2022 2023 for(i=0;i<NUMVERTICES;i++){ 2024 if (flags[vertices[i]->Pid()]<0.){ 2025 shelf=true; 2026 break; 2027 } 2028 } 2029 return shelf; 1171 2030 } 1172 2031 /*}}}*/ … … 1197 2056 } 1198 2057 /*}}}*/ 2058 bool Tria::IsZeroLevelset(int levelset_enum){/*{{{*/ 2059 2060 bool iszerols; 2061 IssmDouble ls[NUMVERTICES]; 2062 2063 /*Retrieve all inputs and parameters*/ 2064 GetInputListOnVertices(&ls[0],levelset_enum); 2065 2066 /*If the level set is awlays <0, there is no ice front here*/ 2067 iszerols= false; 2068 if(IsIceInElement()){ 2069 if(ls[0]*ls[1]<0. || ls[0]*ls[2]<0. || (ls[0]*ls[1]*ls[2]==0. && ls[0]*ls[1]+ls[0]*ls[2]+ls[1]*ls[2]<=0.)){ 2070 iszerols = true; 2071 } 2072 } 2073 2074 return iszerols; 2075 } 2076 /*}}}*/ 1199 2077 void Tria::JacobianDeterminant(IssmDouble* pJdet,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 1200 2078 … … 1225 2103 } 1226 2104 /*}}}*/ 1227 bool Tria::HasEdgeOnBase(){/*{{{*/ 1228 1229 IssmDouble values[NUMVERTICES]; 1230 IssmDouble sum; 1231 1232 /*Retrieve all inputs and parameters*/ 1233 GetInputListOnVertices(&values[0],MeshVertexonbaseEnum); 1234 sum = values[0]+values[1]+values[2]; 1235 1236 _assert_(sum==0. || sum==1. || sum==2.); 1237 1238 if(sum==3.) _error_("Two edges on bed not supported yet..."); 1239 1240 if(sum>1.){ 1241 return true; 1242 } 1243 else{ 1244 return false; 1245 } 1246 } 1247 /*}}}*/ 1248 bool Tria::HasEdgeOnSurface(){/*{{{*/ 1249 1250 IssmDouble values[NUMVERTICES]; 1251 IssmDouble sum; 1252 1253 /*Retrieve all inputs and parameters*/ 1254 GetInputListOnVertices(&values[0],MeshVertexonsurfaceEnum); 1255 sum = values[0]+values[1]+values[2]; 1256 1257 _assert_(sum==0. || sum==1. || sum==2.); 1258 1259 if(sum==3.) _error_("Two edges on surface not supported yet..."); 1260 1261 if(sum>1.){ 1262 return true; 1263 } 1264 else{ 1265 return false; 1266 } 1267 } 1268 /*}}}*/ 1269 void Tria::EdgeOnBaseIndices(int* pindex1,int* pindex2){/*{{{*/ 1270 1271 IssmDouble values[NUMVERTICES]; 1272 int indices[3][2] = {{1,2},{2,0},{0,1}}; 1273 1274 /*Retrieve all inputs and parameters*/ 1275 GetInputListOnVertices(&values[0],MeshVertexonbaseEnum); 1276 1277 for(int i=0;i<3;i++){ 1278 if(values[indices[i][0]] == 1. && values[indices[i][1]] == 1.){ 1279 *pindex1 = indices[i][0]; 1280 *pindex2 = indices[i][1]; 1281 return; 1282 } 1283 } 1284 1285 _printf_("list of vertices on bed: "<<values[0]<<" "<<values[1]<<" "<<values[2]); 1286 _error_("Could not find 2 vertices on bed"); 1287 } 1288 /*}}}*/ 1289 void Tria::EdgeOnSurfaceIndices(int* pindex1,int* pindex2){/*{{{*/ 1290 1291 IssmDouble values[NUMVERTICES]; 1292 int indices[3][2] = {{1,2},{2,0},{0,1}}; 1293 1294 /*Retrieve all inputs and parameters*/ 1295 GetInputListOnVertices(&values[0],MeshVertexonsurfaceEnum); 1296 1297 for(int i=0;i<3;i++){ 1298 if(values[indices[i][0]] == 1. && values[indices[i][1]] == 1.){ 1299 *pindex1 = indices[i][0]; 1300 *pindex2 = indices[i][1]; 1301 return; 1302 } 1303 } 1304 1305 _printf_("list of vertices on surface: "<<values[0]<<" "<<values[1]<<" "<<values[2]); 1306 _error_("Could not find 2 vertices on surface"); 1307 } 1308 /*}}}*/ 1309 int Tria::EdgeOnBaseIndex(void){/*{{{*/ 1310 1311 IssmDouble values[NUMVERTICES]; 1312 int indices[3][2] = {{1,2},{2,0},{0,1}}; 1313 1314 /*Retrieve all inputs and parameters*/ 1315 GetInputListOnVertices(&values[0],MeshVertexonbaseEnum); 1316 1317 for(int i=0;i<3;i++){ 1318 if(values[indices[i][0]] == 1. && values[indices[i][1]] == 1.){ 1319 return i; 1320 } 1321 } 1322 1323 _printf_("list of vertices on bed: "<<values[0]<<" "<<values[1]<<" "<<values[2]); 1324 _error_("Could not find 2 vertices on bed"); 1325 } 1326 /*}}}*/ 1327 int Tria::EdgeOnSurfaceIndex(void){/*{{{*/ 1328 1329 IssmDouble values[NUMVERTICES]; 1330 int indices[3][2] = {{1,2},{2,0},{0,1}}; 1331 1332 /*Retrieve all inputs and parameters*/ 1333 GetInputListOnVertices(&values[0],MeshVertexonsurfaceEnum); 1334 1335 for(int i=0;i<3;i++){ 1336 if(values[indices[i][0]] == 1. && values[indices[i][1]] == 1.){ 1337 return i; 1338 } 1339 } 1340 1341 _printf_("list of vertices on surface: "<<values[0]<<" "<<values[1]<<" "<<values[2]); 1342 _error_("Could not find 2 vertices on surface"); 1343 } 1344 /*}}}*/ 1345 void Tria::FSContactMigration(Vector<IssmDouble>* vertexgrounded,Vector<IssmDouble>* vertexfloating){/*{{{*/ 1346 1347 if(!IsOnBase()) return; 1348 1349 /*Intermediaries*/ 1350 IssmDouble* xyz_list = NULL; 1351 IssmDouble* xyz_list_base = NULL; 1352 IssmDouble pressure,water_pressure,sigma_nn,viscosity,bed,base; 1353 IssmDouble bed_normal[2]; 1354 IssmDouble epsilon[3]; /* epsilon=[exx,eyy,exy];*/ 1355 IssmDouble surface=0,value=0; 1356 bool grounded; 2105 IssmDouble Tria::Masscon(IssmDouble* levelset){ /*{{{*/ 2106 2107 2108 /*intermediary: */ 2109 IssmDouble* values=NULL; 2110 Input* thickness_input=NULL; 2111 IssmDouble thickness; 2112 IssmDouble weight; 2113 IssmDouble Jdet; 2114 IssmDouble volume; 2115 IssmDouble rho_ice; 2116 IssmDouble* xyz_list=NULL; 2117 int point1; 2118 IssmDouble fraction1,fraction2; 2119 bool mainlynegative=true; 2120 2121 /*Output:*/ 2122 volume=0; 1357 2123 1358 2124 /* Get node coordinates and dof list: */ 1359 2125 GetVerticesCoordinates(&xyz_list); 1360 GetVerticesCoordinatesBase(&xyz_list_base); 2126 2127 /*Retrieve inputs required:*/ 2128 thickness_input=this->GetInput(ThicknessEnum); _assert_(thickness_input); 2129 2130 /*Retrieve material parameters: */ 2131 rho_ice=matpar->GetMaterialParameter(MaterialsRhoIceEnum); 2132 2133 /*Retrieve values of the levelset defining the masscon: */ 2134 values = xNew<IssmDouble>(NUMVERTICES); 2135 for(int i=0;i<NUMVERTICES;i++){ 2136 values[i]=levelset[this->vertices[i]->Sid()]; 2137 } 2138 2139 /*Ok, use the level set values to figure out where we put our gaussian points:*/ 2140 this->GetLevelsetPositivePart(&point1,&fraction1,&fraction2,&mainlynegative,values); 2141 Gauss* gauss = this->NewGauss(point1,fraction1,fraction2,mainlynegative,4); 2142 2143 volume=0; 2144 2145 for(int ig=gauss->begin();ig<gauss->end();ig++){ 2146 gauss->GaussPoint(ig); 2147 2148 this->JacobianDeterminant(&Jdet,xyz_list,gauss); 2149 thickness_input->GetInputValue(&thickness, gauss); 2150 2151 volume+=thickness*gauss->weight*Jdet; 2152 } 2153 2154 /* clean up and Return: */ 2155 xDelete<IssmDouble>(xyz_list); 2156 xDelete<IssmDouble>(values); 2157 delete gauss; 2158 return rho_ice*volume; 2159 } 2160 /*}}}*/ 2161 IssmDouble Tria::MassFlux(IssmDouble x1, IssmDouble y1, IssmDouble x2, IssmDouble y2,int segment_id){/*{{{*/ 2162 2163 int domaintype; 2164 IssmDouble mass_flux=0.; 2165 IssmDouble xyz_list[NUMVERTICES][3]; 2166 IssmDouble normal[2]; 2167 IssmDouble length,rho_ice; 2168 IssmDouble h1,h2; 2169 IssmDouble vx1,vx2,vy1,vy2; 2170 GaussTria* gauss_1=NULL; 2171 GaussTria* gauss_2=NULL; 2172 2173 /*Get material parameters :*/ 2174 rho_ice=matpar->GetMaterialParameter(MaterialsRhoIceEnum); 2175 2176 /*First off, check that this segment belongs to this element: */ 2177 if (segment_id!=this->id)_error_("error message: segment with id " << segment_id << " does not belong to element with id:" << this->id); 2178 2179 /*Get xyz list: */ 2180 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 2181 2182 /*get area coordinates of 0 and 1 locations: */ 2183 gauss_1=new GaussTria(); 2184 gauss_1->GaussFromCoords(x1,y1,&xyz_list[0][0]); 2185 gauss_2=new GaussTria(); 2186 gauss_2->GaussFromCoords(x2,y2,&xyz_list[0][0]); 2187 2188 normal[0]=cos(atan2(x1-x2,y2-y1)); 2189 normal[1]=sin(atan2(x1-x2,y2-y1)); 2190 2191 length=sqrt(pow(x2-x1,2)+pow(y2-y1,2)); 2192 2193 Input* thickness_input=inputs->GetInput(ThicknessEnum); _assert_(thickness_input); 2194 this->parameters->FindParam(&domaintype,DomainTypeEnum); 2195 Input* vx_input=NULL; 2196 Input* vy_input=NULL; 2197 if(domaintype==Domain2DhorizontalEnum){ 2198 vx_input=inputs->GetInput(VxEnum); _assert_(vx_input); 2199 vy_input=inputs->GetInput(VyEnum); _assert_(vy_input); 2200 } 2201 else{ 2202 vx_input=inputs->GetInput(VxAverageEnum); _assert_(vx_input); 2203 vy_input=inputs->GetInput(VyAverageEnum); _assert_(vy_input); 2204 } 2205 2206 thickness_input->GetInputValue(&h1, gauss_1); 2207 thickness_input->GetInputValue(&h2, gauss_2); 2208 vx_input->GetInputValue(&vx1,gauss_1); 2209 vx_input->GetInputValue(&vx2,gauss_2); 2210 vy_input->GetInputValue(&vy1,gauss_1); 2211 vy_input->GetInputValue(&vy2,gauss_2); 2212 2213 mass_flux= rho_ice*length*( 2214 (ONETHIRD*(h1-h2)*(vx1-vx2)+0.5*h2*(vx1-vx2)+0.5*(h1-h2)*vx2+h2*vx2)*normal[0]+ 2215 (ONETHIRD*(h1-h2)*(vy1-vy2)+0.5*h2*(vy1-vy2)+0.5*(h1-h2)*vy2+h2*vy2)*normal[1] 2216 ); 2217 2218 /*clean up and return:*/ 2219 delete gauss_1; 2220 delete gauss_2; 2221 return mass_flux; 2222 } 2223 /*}}}*/ 2224 IssmDouble Tria::MassFlux(IssmDouble* segment){/*{{{*/ 2225 2226 int domaintype; 2227 IssmDouble mass_flux=0.; 2228 IssmDouble xyz_list[NUMVERTICES][3]; 2229 IssmDouble normal[2]; 2230 IssmDouble length,rho_ice; 2231 IssmDouble x1,y1,x2,y2,h1,h2; 2232 IssmDouble vx1,vx2,vy1,vy2; 2233 GaussTria* gauss_1=NULL; 2234 GaussTria* gauss_2=NULL; 2235 2236 /*Get material parameters :*/ 2237 rho_ice=matpar->GetMaterialParameter(MaterialsRhoIceEnum); 2238 2239 /*First off, check that this segment belongs to this element: */ 2240 if (reCast<int>(*(segment+4))!=this->id)_error_("error message: segment with id " << reCast<int>(*(segment+4)) << " does not belong to element with id:" << this->id); 2241 2242 /*Recover segment node locations: */ 2243 x1=*(segment+0); y1=*(segment+1); x2=*(segment+2); y2=*(segment+3); 2244 2245 /*Get xyz list: */ 2246 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 2247 2248 /*get area coordinates of 0 and 1 locations: */ 2249 gauss_1=new GaussTria(); 2250 gauss_1->GaussFromCoords(x1,y1,&xyz_list[0][0]); 2251 gauss_2=new GaussTria(); 2252 gauss_2->GaussFromCoords(x2,y2,&xyz_list[0][0]); 2253 2254 normal[0]=cos(atan2(x1-x2,y2-y1)); 2255 normal[1]=sin(atan2(x1-x2,y2-y1)); 2256 2257 length=sqrt(pow(x2-x1,2)+pow(y2-y1,2)); 2258 2259 Input* thickness_input=inputs->GetInput(ThicknessEnum); _assert_(thickness_input); 2260 this->parameters->FindParam(&domaintype,DomainTypeEnum); 2261 Input* vx_input=NULL; 2262 Input* vy_input=NULL; 2263 if(domaintype==Domain2DhorizontalEnum){ 2264 vx_input=inputs->GetInput(VxEnum); _assert_(vx_input); 2265 vy_input=inputs->GetInput(VyEnum); _assert_(vy_input); 2266 } 2267 else{ 2268 vx_input=inputs->GetInput(VxAverageEnum); _assert_(vx_input); 2269 vy_input=inputs->GetInput(VyAverageEnum); _assert_(vy_input); 2270 } 2271 2272 thickness_input->GetInputValue(&h1, gauss_1); 2273 thickness_input->GetInputValue(&h2, gauss_2); 2274 vx_input->GetInputValue(&vx1,gauss_1); 2275 vx_input->GetInputValue(&vx2,gauss_2); 2276 vy_input->GetInputValue(&vy1,gauss_1); 2277 vy_input->GetInputValue(&vy2,gauss_2); 2278 2279 mass_flux= rho_ice*length*( 2280 (ONETHIRD*(h1-h2)*(vx1-vx2)+0.5*h2*(vx1-vx2)+0.5*(h1-h2)*vx2+h2*vx2)*normal[0]+ 2281 (ONETHIRD*(h1-h2)*(vy1-vy2)+0.5*h2*(vy1-vy2)+0.5*(h1-h2)*vy2+h2*vy2)*normal[1] 2282 ); 2283 2284 /*clean up and return:*/ 2285 delete gauss_1; 2286 delete gauss_2; 2287 return mass_flux; 2288 } 2289 /*}}}*/ 2290 IssmDouble Tria::Misfit(int modelenum,int observationenum,int weightsenum){/*{{{*/ 2291 2292 /*Intermediaries*/ 2293 IssmDouble model,observation,weight; 2294 IssmDouble Jdet; 2295 IssmDouble Jelem = 0; 2296 IssmDouble xyz_list[NUMVERTICES][3]; 2297 GaussTria *gauss = NULL; 2298 2299 /*If on water, return 0: */ 2300 if(!IsIceInElement())return 0; 1361 2301 1362 2302 /*Retrieve all inputs we will be needing: */ 1363 Input* pressure_input = inputs->GetInput(PressureEnum); _assert_(pressure_input); 1364 Input* base_input = inputs->GetInput(BaseEnum); _assert_(base_input); 1365 Input* bed_input = inputs->GetInput(BedEnum); _assert_(bed_input); 1366 Input* vx_input = inputs->GetInput(VxEnum); _assert_(vx_input); 1367 Input* vy_input = inputs->GetInput(VyEnum); _assert_(vy_input); 1368 1369 /*Create gauss point in the middle of the basal edge*/ 1370 Gauss* gauss=NewGaussBase(1); 1371 gauss->GaussPoint(0); 1372 1373 if(!IsFloating()){ 1374 /*Check for basal force only if grounded and touching GL*/ 1375 if(this->inputs->Min(MaskGroundediceLevelsetEnum)==0.){ 1376 this->StrainRateSSA(&epsilon[0],xyz_list,gauss,vx_input,vy_input); 1377 this->ViscosityFS(&viscosity,2,xyz_list,gauss,vx_input,vy_input,NULL); 1378 pressure_input->GetInputValue(&pressure, gauss); 1379 base_input->GetInputValue(&base, gauss); _assert_(base<0.); 1380 1381 /*Compute Stress*/ 1382 IssmDouble sigma_xx=2.*viscosity*epsilon[0]-pressure; 1383 IssmDouble sigma_yy=2.*viscosity*epsilon[1]-pressure; 1384 IssmDouble sigma_xy=2.*viscosity*epsilon[2]; 1385 1386 /*Get normal vector to the bed */ 1387 NormalBase(&bed_normal[0],xyz_list_base); 1388 1389 /*basalforce*/ 1390 sigma_nn = sigma_xx*bed_normal[0]*bed_normal[0] + sigma_yy*bed_normal[1]*bed_normal[1] + 2.*sigma_xy*bed_normal[0]*bed_normal[1]; 1391 1392 /*Compute water pressure*/ 1393 IssmDouble rho_ice = matpar->GetRhoIce(); 1394 IssmDouble rho_water = matpar->GetRhoWater(); 1395 IssmDouble gravity = matpar->GetG(); 1396 water_pressure=gravity*rho_water*base; 1397 1398 /*Compare basal stress to water pressure and determine whether it should ground*/ 1399 if (sigma_nn<water_pressure) grounded=true; 1400 else grounded=false; 1401 } 1402 else{ 1403 grounded=true; 1404 } 1405 } 1406 else{ 1407 /*Check for basal elevation if floating*/ 1408 base_input->GetInputValue(&base, gauss); 1409 bed_input->GetInputValue(&bed, gauss); 1410 if (base<bed) grounded=true; 1411 else grounded=false; 1412 } 1413 for(int i=0;i<NUMVERTICES;i++){ 1414 if(grounded) vertexgrounded->SetValue(vertices[i]->Pid(),+1.,INS_VAL); 1415 else vertexfloating->SetValue(vertices[i]->Pid(),+1.,INS_VAL); 1416 } 1417 1418 /*clean up*/ 2303 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 2304 Input* model_input=inputs->GetInput(modelenum); _assert_(model_input); 2305 Input* observation_input=inputs->GetInput(observationenum);_assert_(observation_input); 2306 Input* weights_input =inputs->GetInput(weightsenum); _assert_(weights_input); 2307 2308 /* Start looping on the number of gaussian points: */ 2309 gauss=new GaussTria(2); 2310 for(int ig=gauss->begin();ig<gauss->end();ig++){ 2311 2312 gauss->GaussPoint(ig); 2313 2314 /* Get Jacobian determinant: */ 2315 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss); 2316 2317 /*Get parameters at gauss point*/ 2318 model_input->GetInputValue(&model,gauss); 2319 observation_input->GetInputValue(&observation,gauss); 2320 weights_input->GetInputValue(&weight,gauss); 2321 2322 /*compute misfit between model and observation */ 2323 Jelem+=0.5*(model-observation)*(model-observation)*Jdet*weight*gauss->weight; 2324 } 2325 2326 /* clean up and Return: */ 1419 2327 delete gauss; 1420 xDelete<IssmDouble>(xyz_list); 1421 xDelete<IssmDouble>(xyz_list_base); 1422 } 1423 /*}}}*/ 1424 bool Tria::IsNodeOnShelfFromFlags(IssmDouble* flags){/*{{{*/ 1425 1426 int i; 1427 bool shelf=false; 1428 1429 for(i=0;i<NUMVERTICES;i++){ 1430 if (flags[vertices[i]->Pid()]<0.){ 1431 shelf=true; 1432 break; 1433 } 1434 } 1435 return shelf; 2328 return Jelem; 2329 } 2330 /*}}}*/ 2331 IssmDouble Tria::MisfitArea(int weightsenum){/*{{{*/ 2332 2333 /*Intermediaries*/ 2334 IssmDouble weight; 2335 IssmDouble Jdet; 2336 IssmDouble Jelem = 0; 2337 IssmDouble xyz_list[NUMVERTICES][3]; 2338 GaussTria *gauss = NULL; 2339 2340 /*If on water, return 0: */ 2341 if(!IsIceInElement())return 0; 2342 2343 /*Retrieve all inputs we will be needing: */ 2344 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 2345 Input* weights_input =inputs->GetInput(weightsenum); _assert_(weights_input); 2346 2347 /* Start looping on the number of gaussian points: */ 2348 gauss=new GaussTria(2); 2349 for(int ig=gauss->begin();ig<gauss->end();ig++){ 2350 2351 gauss->GaussPoint(ig); 2352 2353 /* Get Jacobian determinant: */ 2354 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss); 2355 2356 /*Get parameters at gauss point*/ 2357 weights_input->GetInputValue(&weight,gauss); 2358 2359 /*compute misfit between model and observation */ 2360 Jelem+=Jdet*weight*gauss->weight; 2361 } 2362 2363 /* clean up and Return: */ 2364 delete gauss; 2365 return Jelem; 1436 2366 } 1437 2367 /*}}}*/ … … 1484 2414 } 1485 2415 /*}}}*/ 2416 void Tria::NodalFunctionsDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 2417 2418 _assert_(gauss->Enum()==GaussTriaEnum); 2419 this->GetNodalFunctionsDerivatives(dbasis,xyz_list,(GaussTria*)gauss,this->element_type); 2420 2421 } 2422 /*}}}*/ 2423 void Tria::NodalFunctionsDerivativesVelocity(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 2424 2425 _assert_(gauss->Enum()==GaussTriaEnum); 2426 this->GetNodalFunctionsDerivatives(dbasis,xyz_list,(GaussTria*)gauss,this->VelocityInterpolation()); 2427 2428 } 2429 /*}}}*/ 2430 void Tria::NodalFunctionsPressure(IssmDouble* basis, Gauss* gauss){/*{{{*/ 2431 2432 _assert_(gauss->Enum()==GaussTriaEnum); 2433 this->GetNodalFunctions(basis,(GaussTria*)gauss,this->PressureInterpolation()); 2434 2435 } 2436 /*}}}*/ 1486 2437 void Tria::NodalFunctionsP1(IssmDouble* basis, Gauss* gauss){/*{{{*/ 1487 2438 … … 1491 2442 } 1492 2443 /*}}}*/ 2444 void Tria::NodalFunctionsP1Derivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 2445 2446 _assert_(gauss->Enum()==GaussTriaEnum); 2447 this->GetNodalFunctionsDerivatives(dbasis,xyz_list,(GaussTria*)gauss,P1Enum); 2448 2449 } 2450 /*}}}*/ 1493 2451 void Tria::NodalFunctionsP2(IssmDouble* basis, Gauss* gauss){/*{{{*/ 1494 2452 … … 1498 2456 } 1499 2457 /*}}}*/ 1500 void Tria::NodalFunctions Derivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/2458 void Tria::NodalFunctionsTensor(IssmDouble* basis, Gauss* gauss){/*{{{*/ 1501 2459 1502 2460 _assert_(gauss->Enum()==GaussTriaEnum); 1503 this->GetNodalFunctionsDerivatives(dbasis,xyz_list,(GaussTria*)gauss,this->element_type); 1504 1505 } 1506 /*}}}*/ 1507 void Tria::NodalFunctionsP1Derivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 1508 1509 _assert_(gauss->Enum()==GaussTriaEnum); 1510 this->GetNodalFunctionsDerivatives(dbasis,xyz_list,(GaussTria*)gauss,P1Enum); 1511 1512 } 1513 /*}}}*/ 1514 void Tria::NodalFunctionsDerivativesVelocity(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 1515 1516 _assert_(gauss->Enum()==GaussTriaEnum); 1517 this->GetNodalFunctionsDerivatives(dbasis,xyz_list,(GaussTria*)gauss,this->VelocityInterpolation()); 2461 this->GetNodalFunctions(basis,(GaussTria*)gauss,this->TensorInterpolation()); 1518 2462 1519 2463 } … … 1523 2467 _assert_(gauss->Enum()==GaussTriaEnum); 1524 2468 this->GetNodalFunctions(basis,(GaussTria*)gauss,this->VelocityInterpolation()); 1525 1526 }1527 /*}}}*/1528 void Tria::NodalFunctionsPressure(IssmDouble* basis, Gauss* gauss){/*{{{*/1529 1530 _assert_(gauss->Enum()==GaussTriaEnum);1531 this->GetNodalFunctions(basis,(GaussTria*)gauss,this->PressureInterpolation());1532 1533 }1534 /*}}}*/1535 void Tria::NodalFunctionsTensor(IssmDouble* basis, Gauss* gauss){/*{{{*/1536 1537 _assert_(gauss->Enum()==GaussTriaEnum);1538 this->GetNodalFunctions(basis,(GaussTria*)gauss,this->TensorInterpolation());1539 2469 1540 2470 } … … 1588 2518 } 1589 2519 /*}}}*/ 2520 void Tria::NormalSection(IssmDouble* normal,IssmDouble* xyz_list){/*{{{*/ 2521 2522 /*Build unit outward pointing vector*/ 2523 IssmDouble vector[2]; 2524 IssmDouble norm; 2525 2526 vector[0]=xyz_list[1*3+0] - xyz_list[0*3+0]; 2527 vector[1]=xyz_list[1*3+1] - xyz_list[0*3+1]; 2528 2529 norm=sqrt(vector[0]*vector[0] + vector[1]*vector[1]); 2530 2531 normal[0]= + vector[1]/norm; 2532 normal[1]= - vector[0]/norm; 2533 } 2534 /*}}}*/ 1590 2535 void Tria::NormalTop(IssmDouble* top_normal,IssmDouble* xyz_list){/*{{{*/ 1591 2536 … … 1606 2551 } 1607 2552 /*}}}*/ 1608 int Tria::VelocityInterpolation(void){/*{{{*/ 1609 return TriaRef::VelocityInterpolation(this->element_type); 2553 int Tria::ObjectEnum(void){/*{{{*/ 2554 2555 return TriaEnum; 2556 1610 2557 } 1611 2558 /*}}}*/ … … 1614 2561 } 1615 2562 /*}}}*/ 1616 int Tria::TensorInterpolation(void){/*{{{*/1617 return TriaRef::TensorInterpolation(this->element_type);1618 }1619 /*}}}*/1620 2563 int Tria::NumberofNodesPressure(void){/*{{{*/ 1621 2564 return TriaRef::NumberofNodes(this->PressureInterpolation()); … … 1626 2569 } 1627 2570 /*}}}*/ 1628 void Tria::PositiveDegreeDay(IssmDouble* pdds,IssmDouble* pds,IssmDouble signorm){/*{{{*/ 1629 2571 void Tria::PositiveDegreeDay(IssmDouble* pdds,IssmDouble* pds,IssmDouble signorm,bool ismungsm){/*{{{*/ 2572 2573 int i; 1630 2574 IssmDouble agd[NUMVERTICES]; // surface mass balance 1631 2575 IssmDouble monthlytemperatures[NUMVERTICES][12],monthlyprec[NUMVERTICES][12]; 2576 IssmDouble tmp[NUMVERTICES]; 1632 2577 IssmDouble h[NUMVERTICES],s[NUMVERTICES]; 1633 IssmDouble rho_water,rho_ice,desfac,s0p; 1634 1635 /*Recover monthly temperatures and precipitation*/ 2578 IssmDouble rho_water,rho_ice,desfac,s0p,s0t,rlaps,rlapslgm; 2579 IssmDouble PfacTime,TdiffTime,sealevTime; 2580 2581 /*Get material parameters :*/ 2582 rho_water=matpar->GetMaterialParameter(MaterialsRhoSeawaterEnum); 2583 rho_ice=matpar->GetMaterialParameter(MaterialsRhoIceEnum); 2584 2585 /*Get some pdd parameters*/ 2586 desfac=matpar->GetMaterialParameter(SurfaceforcingsDesfacEnum); 2587 s0p=matpar->GetMaterialParameter(SurfaceforcingsS0pEnum); 2588 s0t=matpar->GetMaterialParameter(SurfaceforcingsS0tEnum); 2589 rlaps=matpar->GetMaterialParameter(SurfaceforcingsRlapsEnum); 2590 rlapslgm=matpar->GetMaterialParameter(SurfaceforcingsRlapslgmEnum); 2591 2592 /*Recover monthly temperatures and precipitation and Present day and LGm ones*/ 1636 2593 Input* input=inputs->GetInput(SurfaceforcingsMonthlytemperaturesEnum); _assert_(input); 1637 2594 Input* input2=inputs->GetInput(SurfaceforcingsPrecipitationEnum); _assert_(input2); … … 1640 2597 this->parameters->FindParam(&time,TimeEnum); 1641 2598 this->parameters->FindParam(&yts,ConstantsYtsEnum); 2599 2600 1642 2601 for(int month=0;month<12;month++) { 1643 2602 for(int iv=0;iv<NUMVERTICES;iv++) { … … 1646 2605 monthlytemperatures[iv][month]=monthlytemperatures[iv][month]-273.15; // conversion from Kelvin to celcius 1647 2606 input2->GetInputValue(&monthlyprec[iv][month],gauss,time+month/12.*yts); 1648 monthlyprec[iv][month]=monthlyprec[iv][month]*yts; // convertion in m/y1649 2607 } 1650 2608 } 2609 2610 /*Recover Pfac, Tdiff and sealev at time t: 2611 This parameters are used to interpolate the temperature 2612 and precipitaton between PD and LGM when ismungsm==1 */ 2613 if (ismungsm==1){ 2614 this->parameters->FindParam(&TdiffTime,SurfaceforcingsTdiffEnum,time); 2615 this->parameters->FindParam(&sealevTime,SurfaceforcingsSealevEnum,time); 2616 } 2617 else { 2618 TdiffTime=0; 2619 sealevTime=0; 2620 } 1651 2621 1652 2622 /*Recover info at the vertices: */ 1653 2623 GetInputListOnVertices(&h[0],ThicknessEnum); 1654 2624 GetInputListOnVertices(&s[0],SurfaceEnum); 1655 1656 /*Get material parameters :*/ 1657 rho_ice=matpar->GetRhoIce(); 1658 rho_water=matpar->GetRhoFreshwater(); 1659 1660 /*Get desertification effect parameters*/ 1661 desfac=matpar->GetDesFac(); 1662 s0p=matpar->GetS0p(); 1663 2625 1664 2626 /*measure the surface mass balance*/ 1665 for (int iv = 0; iv<NUMVERTICES; iv++){ 1666 agd[iv]=PddSurfaceMassBlance(&monthlytemperatures[iv][0], &monthlyprec[iv][0], pdds, pds, signorm, yts, h[iv], s[iv], rho_ice, rho_water, desfac, s0p); 2627 for (int iv = 0; iv<NUMVERTICES; iv++){ 2628 agd[iv]=PddSurfaceMassBalance(&monthlytemperatures[iv][0], &monthlyprec[iv][0], 2629 pdds, pds, signorm, yts, h[iv], s[iv], 2630 desfac, s0t, s0p,rlaps,rlapslgm,TdiffTime,sealevTime, 2631 rho_water,rho_ice); 1667 2632 } 1668 2633 1669 2634 /*Update inputs*/ 2635 // TransientInput* NewTemperatureInput = new TransientInput(SurfaceforcingsMonthlytemperaturesEnum); 2636 // TransientInput* NewPrecipitationInput = new TransientInput(SurfaceforcingsPrecipitationEnum); 2637 // for (int imonth=0;imonth<12;imonth++) { 2638 // for(i=0;i<NUMVERTICES;i++) tmp[i]=monthlytemperatures[i][imonth]; 2639 // TriaInput* newmonthinput1 = new TriaInput(SurfaceforcingsMonthlytemperaturesEnum,&tmp[0],P1Enum); 2640 // NewTemperatureInput->AddTimeInput(newmonthinput1,time+imonth/12.*yts); 2641 // 2642 // for(i=0;i<NUMVERTICES;i++) tmp[i]=monthlyprec[i][imonth]; 2643 // TriaInput* newmonthinput2 = new TriaInput(SurfaceforcingsPrecipitationEnum,&tmp[0],P1Enum); 2644 // NewPrecipitationInput->AddTimeInput(newmonthinput2,time+imonth/12.*yts); 2645 // } 2646 // NewTemperatureInput->Configure(this->parameters); 2647 // NewPrecipitationInput->Configure(this->parameters); 2648 2649 1670 2650 this->inputs->AddInput(new TriaInput(SurfaceforcingsMassBalanceEnum,&agd[0],P1Enum)); 2651 // this->inputs->AddInput(NewTemperatureInput); 2652 // this->inputs->AddInput(NewPrecipitationInput); 1671 2653 // this->inputs->AddInput(new TriaVertexInput(ThermalSpcTemperatureEnum,&Tsurf[0])); 2654 2655 //this->InputExtrude(SurfaceforcingsMassBalanceEnum,-1); 2656 // this->InputExtrude(SurfaceforcingsMonthlytemperaturesEnum,-1); 2657 // this->InputExtrude(SurfaceforcingsPrecipitationEnum,-1); 1672 2658 1673 2659 /*clean-up*/ 1674 2660 delete gauss; 2661 } 2662 /*}}}*/ 2663 void Tria::PotentialUngrounding(Vector<IssmDouble>* potential_ungrounding){/*{{{*/ 2664 2665 IssmDouble h[NUMVERTICES],r[NUMVERTICES],gl[NUMVERTICES]; 2666 IssmDouble bed_hydro; 2667 IssmDouble rho_water,rho_ice,density; 2668 2669 /*material parameters: */ 2670 rho_water=matpar->GetMaterialParameter(MaterialsRhoSeawaterEnum); 2671 rho_ice=matpar->GetMaterialParameter(MaterialsRhoIceEnum); 2672 density=rho_ice/rho_water; 2673 GetInputListOnVertices(&h[0],ThicknessEnum); 2674 GetInputListOnVertices(&r[0],BedEnum); 2675 GetInputListOnVertices(&gl[0],MaskGroundediceLevelsetEnum); 2676 2677 /*go through vertices, and figure out which ones are grounded and want to unground: */ 2678 for(int i=0;i<NUMVERTICES;i++){ 2679 /*Find if grounded vertices want to start floating*/ 2680 if (gl[i]>0.){ 2681 bed_hydro=-density*h[i]; 2682 if(bed_hydro>r[i]){ 2683 /*Vertex that could potentially unground, flag it*/ 2684 potential_ungrounding->SetValue(vertices[i]->Pid(),1,INS_VAL); 2685 } 2686 } 2687 } 1675 2688 } 1676 2689 /*}}}*/ … … 1726 2739 if(!HasNodeOnBase() || approximation!=FSApproximationEnum) return; 1727 2740 1728 //printf("element number %i \n",this->id);1729 2741 /*Get inputs*/ 1730 2742 Input* slope_input=inputs->GetInput(BedSlopeXEnum); _assert_(slope_input); … … 1747 2759 xz_plane[1]=sin(theta); xz_plane[4]=0.; 1748 2760 xz_plane[2]=0.; xz_plane[5]=1.; 2761 1749 2762 if(groundedice>=0){ 1750 2763 this->nodes[i]->DofInSSet(1); //vy … … 1785 2798 } 1786 2799 /*}}}*/ 1787 Seg* Tria::SpawnSeg(int index1,int index2){/*{{{*/ 1788 2800 void Tria::SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index){/*{{{*/ 2801 2802 IssmDouble values[NUMVERTICES]; 2803 int vertexpidlist[NUMVERTICES],control_init; 2804 2805 2806 /*Get Domain type*/ 2807 int domaintype; 2808 parameters->FindParam(&domaintype,DomainTypeEnum); 2809 2810 /*Specific case for depth averaged quantities*/ 2811 control_init=control_enum; 2812 if(domaintype==Domain2DverticalEnum){ 2813 if(control_enum==MaterialsRheologyBbarEnum){ 2814 control_enum=MaterialsRheologyBEnum; 2815 if(!IsOnBase()) return; 2816 } 2817 if(control_enum==DamageDbarEnum){ 2818 control_enum=DamageDEnum; 2819 if(!IsOnBase()) return; 2820 } 2821 } 2822 2823 /*Get out if this is not an element input*/ 2824 if(!IsInput(control_enum)) return; 2825 2826 /*Prepare index list*/ 2827 GradientIndexing(&vertexpidlist[0],control_index); 2828 2829 /*Get values on vertices*/ 2830 for(int i=0;i<NUMVERTICES;i++){ 2831 values[i]=vector[vertexpidlist[i]]; 2832 } 2833 Input* new_input = new TriaInput(control_enum,values,P1Enum); 2834 Input* input = (Input*)this->inputs->GetInput(control_enum); _assert_(input); 2835 if(input->ObjectEnum()!=ControlInputEnum){ 2836 _error_("input " << EnumToStringx(control_enum) << " is not a ControlInput"); 2837 } 2838 2839 ((ControlInput*)input)->SetInput(new_input); 2840 } 2841 /*}}}*/ 2842 void Tria::SetCurrentConfiguration(Elements* elementsin, Loads* loadsin, Nodes* nodesin, Materials* materialsin, Parameters* parametersin){/*{{{*/ 2843 2844 /*go into parameters and get the analysis_counter: */ 1789 2845 int analysis_counter; 1790 1791 /*go into parameters and get the analysis_counter: */ 1792 this->parameters->FindParam(&analysis_counter,AnalysisCounterEnum); 1793 1794 /*Create Seg*/ 1795 Seg* seg=new Seg(); 1796 seg->id=this->id; 1797 seg->inputs=(Inputs*)this->inputs->SpawnSegInputs(index1,index2); 1798 seg->parameters=this->parameters; 1799 seg->element_type=P1Enum; //Only P1 CG for now (TO BE CHANGED) 1800 this->SpawnSegHook(dynamic_cast<ElementHook*>(seg),index1,index2); 1801 1802 /*Spawn material*/ 1803 seg->material=(Material*)this->material->copy2(seg); 1804 1805 /*recover nodes, material and matpar: */ 1806 seg->nodes = (Node**)seg->hnodes[analysis_counter]->deliverp(); 1807 seg->vertices = (Vertex**)seg->hvertices->deliverp(); 1808 seg->matpar = (Matpar*)seg->hmatpar->delivers(); 1809 1810 /*Return new Seg*/ 1811 return seg; 2846 parametersin->FindParam(&analysis_counter,AnalysisCounterEnum); 2847 2848 /*Get Element type*/ 2849 if(this->element_type_list) this->element_type=this->element_type_list[analysis_counter]; 2850 2851 /*Pick up nodes*/ 2852 if(this->hnodes && this->hnodes[analysis_counter]){ 2853 this->nodes=(Node**)this->hnodes[analysis_counter]->deliverp(); 2854 } 2855 1812 2856 } 1813 2857 /*}}}*/ … … 1830 2874 } 1831 2875 /*}}}*/ 2876 Seg* Tria::SpawnSeg(int index1,int index2){/*{{{*/ 2877 2878 int analysis_counter; 2879 2880 /*go into parameters and get the analysis_counter: */ 2881 this->parameters->FindParam(&analysis_counter,AnalysisCounterEnum); 2882 2883 /*Create Seg*/ 2884 Seg* seg=new Seg(); 2885 seg->id=this->id; 2886 seg->inputs=(Inputs*)this->inputs->SpawnSegInputs(index1,index2); 2887 seg->parameters=this->parameters; 2888 seg->element_type=P1Enum; //Only P1 CG for now (TO BE CHANGED) 2889 this->SpawnSegHook(xDynamicCast<ElementHook*>(seg),index1,index2); 2890 2891 /*Spawn material*/ 2892 seg->material=(Material*)this->material->copy2(seg); 2893 2894 /*recover nodes, material and matpar: */ 2895 seg->nodes = (Node**)seg->hnodes[analysis_counter]->deliverp(); 2896 seg->vertices = (Vertex**)seg->hvertices->deliverp(); 2897 seg->matpar = (Matpar*)seg->hmatpar->delivers(); 2898 2899 /*Return new Seg*/ 2900 return seg; 2901 } 2902 /*}}}*/ 1832 2903 Element* Tria::SpawnTopElement(void){/*{{{*/ 1833 2904 … … 1848 2919 } 1849 2920 /*}}}*/ 1850 void Tria::SetCurrentConfiguration(Elements* elementsin, Loads* loadsin, Nodes* nodesin, Materials* materialsin, Parameters* parametersin){/*{{{*/ 1851 1852 /*go into parameters and get the analysis_counter: */ 1853 int analysis_counter; 1854 parametersin->FindParam(&analysis_counter,AnalysisCounterEnum); 1855 1856 /*Get Element type*/ 1857 if(this->element_type_list) this->element_type=this->element_type_list[analysis_counter]; 1858 1859 /*Pick up nodes*/ 1860 if(this->hnodes && this->hnodes[analysis_counter]){ 1861 this->nodes=(Node**)this->hnodes[analysis_counter]->deliverp(); 1862 } 1863 2921 void Tria::StrainRateparallel(){/*{{{*/ 2922 2923 IssmDouble *xyz_list = NULL; 2924 IssmDouble epsilon[3]; 2925 GaussTria* gauss=NULL; 2926 IssmDouble vx,vy,vel; 2927 IssmDouble strainxx; 2928 IssmDouble strainxy; 2929 IssmDouble strainyy; 2930 IssmDouble strainparallel[NUMVERTICES]; 2931 2932 /* Get node coordinates and dof list: */ 2933 this->GetVerticesCoordinates(&xyz_list); 2934 2935 /*Retrieve all inputs we will need*/ 2936 Input* vx_input=inputs->GetInput(VxEnum); _assert_(vx_input); 2937 Input* vy_input=inputs->GetInput(VyEnum); _assert_(vy_input); 2938 2939 /* Start looping on the number of vertices: */ 2940 gauss=new GaussTria(); 2941 for (int iv=0;iv<NUMVERTICES;iv++){ 2942 gauss->GaussVertex(iv); 2943 2944 /* Get the value we need*/ 2945 vx_input->GetInputValue(&vx,gauss); 2946 vy_input->GetInputValue(&vy,gauss); 2947 vel=vx*vx+vy*vy; 2948 2949 /*Compute strain rate viscosity and pressure: */ 2950 this->StrainRateSSA(&epsilon[0],xyz_list,gauss,vx_input,vy_input); 2951 strainxx=epsilon[0]; 2952 strainyy=epsilon[1]; 2953 strainxy=epsilon[2]; 2954 2955 /*strainparallel= Strain rate along the ice flow direction */ 2956 strainparallel[iv]=(vx*vx*(strainxx)+vy*vy*(strainyy)+2*vy*vx*strainxy)/(vel+1.e-14); 2957 } 2958 2959 /*Add input*/ 2960 this->inputs->AddInput(new TriaInput(StrainRateparallelEnum,&strainparallel[0],P1Enum)); 2961 2962 /*Clean up and return*/ 2963 delete gauss; 2964 xDelete<IssmDouble>(xyz_list); 2965 } 2966 /*}}}*/ 2967 void Tria::StrainRateperpendicular(){/*{{{*/ 2968 2969 IssmDouble *xyz_list = NULL; 2970 GaussTria* gauss=NULL; 2971 IssmDouble epsilon[3]; 2972 IssmDouble vx,vy,vel; 2973 IssmDouble strainxx; 2974 IssmDouble strainxy; 2975 IssmDouble strainyy; 2976 IssmDouble strainperpendicular[NUMVERTICES]; 2977 2978 /* Get node coordinates and dof list: */ 2979 this->GetVerticesCoordinates(&xyz_list); 2980 2981 /*Retrieve all inputs we will need*/ 2982 Input* vx_input=inputs->GetInput(VxEnum); _assert_(vx_input); 2983 Input* vy_input=inputs->GetInput(VyEnum); _assert_(vy_input); 2984 2985 /* Start looping on the number of vertices: */ 2986 gauss=new GaussTria(); 2987 for (int iv=0;iv<NUMVERTICES;iv++){ 2988 gauss->GaussVertex(iv); 2989 2990 /* Get the value we need*/ 2991 vx_input->GetInputValue(&vx,gauss); 2992 vy_input->GetInputValue(&vy,gauss); 2993 vel=vx*vx+vy*vy; 2994 2995 /*Compute strain rate viscosity and pressure: */ 2996 this->StrainRateSSA(&epsilon[0],xyz_list,gauss,vx_input,vy_input); 2997 strainxx=epsilon[0]; 2998 strainyy=epsilon[1]; 2999 strainxy=epsilon[2]; 3000 3001 /*strainperpendicular= Strain rate perpendicular to the ice flow direction */ 3002 strainperpendicular[iv]=(vx*vx*(strainyy)+vy*vy*(strainxx)-2*vy*vx*strainxy)/(vel+1.e-14); 3003 } 3004 3005 /*Add input*/ 3006 this->inputs->AddInput(new TriaInput(StrainRateperpendicularEnum,&strainperpendicular[0],P1Enum)); 3007 3008 /*Clean up and return*/ 3009 delete gauss; 3010 xDelete<IssmDouble>(xyz_list); 1864 3011 } 1865 3012 /*}}}*/ … … 1889 3036 /*Return: */ 1890 3037 return S; 3038 } 3039 /*}}}*/ 3040 int Tria::TensorInterpolation(void){/*{{{*/ 3041 return TriaRef::TensorInterpolation(this->element_type); 1891 3042 } 1892 3043 /*}}}*/ … … 1930 3081 1931 3082 return dt; 3083 } 3084 /*}}}*/ 3085 IssmDouble Tria::TotalSmb(void){/*{{{*/ 3086 3087 /*The smb[kg yr-1] of one element is area[m2] * smb [kg m^-2 yr^-1]*/ 3088 IssmDouble base,smb,rho_ice; 3089 IssmDouble Total_Smb=0; 3090 IssmDouble xyz_list[NUMVERTICES][3]; 3091 3092 /*Get material parameters :*/ 3093 rho_ice=matpar->GetMaterialParameter(MaterialsRhoIceEnum); 3094 3095 if(!IsIceInElement())return 0; 3096 3097 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 3098 3099 /*First calculate the area of the base (cross section triangle) 3100 * http://en.wikipedia.org/wiki/Triangle 3101 * base = 1/2 abs((xA-xC)(yB-yA)-(xA-xB)(yC-yA))*/ 3102 base = 1./2. * fabs((xyz_list[0][0]-xyz_list[2][0])*(xyz_list[1][1]-xyz_list[0][1]) - (xyz_list[0][0]-xyz_list[1][0])*(xyz_list[2][1]-xyz_list[0][1])); // area of element in m2 3103 3104 /*Now get the average SMB over the element*/ 3105 Input* smb_input = inputs->GetInput(SurfaceforcingsMassBalanceEnum); _assert_(smb_input); 3106 smb_input->GetInputAverage(&smb); // average smb on element in m ice s-1 3107 Total_Smb=rho_ice*base*smb; // smb on element in kg s-1 3108 3109 /*Return: */ 3110 return Total_Smb; 1932 3111 } 1933 3112 /*}}}*/ … … 2052 3231 tria_node_ids[9]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->numberofedges+iomodel->numberofelements+3*index+3; 2053 3232 break; 3233 case LACrouzeixRaviartEnum: 3234 numnodes = 7; 3235 tria_node_ids = xNew<int>(numnodes); 3236 tria_node_ids[0]=iomodel->nodecounter+iomodel->elements[3*index+0]; 3237 tria_node_ids[1]=iomodel->nodecounter+iomodel->elements[3*index+1]; 3238 tria_node_ids[2]=iomodel->nodecounter+iomodel->elements[3*index+2]; 3239 tria_node_ids[3]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->elementtoedgeconnectivity[3*index+0]+1; 3240 tria_node_ids[4]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->elementtoedgeconnectivity[3*index+1]+1; 3241 tria_node_ids[5]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->elementtoedgeconnectivity[3*index+2]+1; 3242 tria_node_ids[6]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->numberofedges+index+1; 3243 break; 2054 3244 default: 2055 3245 _error_("Finite element "<<EnumToStringx(finiteelement_type)<<" not supported yet"); … … 2110 3300 } 2111 3301 /*}}}*/ 3302 int Tria::UpdatePotentialUngrounding(IssmDouble* vertices_potentially_ungrounding,Vector<IssmDouble>* vec_nodes_on_iceshelf,IssmDouble* nodes_on_iceshelf){/*{{{*/ 3303 3304 int i; 3305 int nflipped=0; 3306 3307 /*Go through nodes, and whoever is on the potential_ungrounding, ends up in nodes_on_iceshelf: */ 3308 for(i=0;i<3;i++){ 3309 if (reCast<bool>(vertices_potentially_ungrounding[vertices[i]->Pid()])){ 3310 vec_nodes_on_iceshelf->SetValue(vertices[i]->Pid(),-1.,INS_VAL); 3311 3312 /*If node was not on ice shelf, we flipped*/ 3313 if(nodes_on_iceshelf[vertices[i]->Pid()]>=0.){ 3314 nflipped++; 3315 } 3316 } 3317 } 3318 return nflipped; 3319 } 3320 /*}}}*/ 3321 void Tria::ValueP1DerivativesOnGauss(IssmDouble* dvalue,IssmDouble* values,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 3322 TriaRef::GetInputDerivativeValue(dvalue,values,xyz_list,gauss,P1Enum); 3323 } 3324 /*}}}*/ 2112 3325 void Tria::ValueP1OnGauss(IssmDouble* pvalue,IssmDouble* values,Gauss* gauss){/*{{{*/ 2113 3326 TriaRef::GetInputValue(pvalue,values,gauss,P1Enum); 2114 3327 } 2115 3328 /*}}}*/ 2116 void Tria::ValueP1DerivativesOnGauss(IssmDouble* dvalue,IssmDouble* values,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/2117 TriaRef::GetInputDerivativeValue(dvalue,values,xyz_list,gauss,P1Enum);3329 int Tria::VelocityInterpolation(void){/*{{{*/ 3330 return TriaRef::VelocityInterpolation(this->element_type); 2118 3331 } 2119 3332 /*}}}*/ … … 2123 3336 } 2124 3337 /*}}}*/ 2125 bool Tria::IsZeroLevelset(int levelset_enum){/*{{{*/ 2126 2127 bool iszerols; 2128 IssmDouble ls[NUMVERTICES]; 2129 2130 /*Retrieve all inputs and parameters*/ 2131 GetInputListOnVertices(&ls[0],levelset_enum); 2132 2133 /*If the level set is awlays <0, there is no ice front here*/ 2134 iszerols= false; 2135 if(IsIceInElement()){ 2136 if(ls[0]*ls[1]<0. || ls[0]*ls[2]<0. || (ls[0]*ls[1]*ls[2]==0. && ls[0]*ls[1]+ls[0]*ls[2]+ls[1]*ls[2]<=0.)){ 2137 iszerols = true; 2138 } 2139 } 2140 2141 return iszerols; 2142 } 2143 /*}}}*/ 2144 bool Tria::IsIcefront(void){/*{{{*/ 2145 2146 bool isicefront; 2147 int i,nrice; 2148 IssmDouble ls[NUMVERTICES]; 2149 2150 /*Retrieve all inputs and parameters*/ 2151 GetInputListOnVertices(&ls[0],MaskIceLevelsetEnum); 2152 2153 /* If only one vertex has ice, there is an ice front here */ 2154 isicefront=false; 2155 if(IsIceInElement()){ 2156 nrice=0; 2157 for(i=0;i<NUMVERTICES;i++) 2158 if(ls[i]<0.) nrice++; 2159 if(nrice==1) isicefront= true; 2160 } 2161 return isicefront; 2162 }/*}}}*/ 2163 bool Tria::IsFaceOnBoundary(void){/*{{{*/ 2164 2165 IssmDouble values[NUMVERTICES]; 2166 IssmDouble sum; 2167 2168 /*Retrieve all inputs and parameters*/ 2169 GetInputListOnVertices(&values[0],MeshVertexonboundaryEnum); 2170 sum = values[0]+values[1]+values[2]; 2171 2172 _assert_(sum==0. || sum==1. || sum==2.); 2173 2174 if(sum==3.) _error_("Two edges on boundary not supported yet..."); 2175 2176 if(sum>1.){ 2177 return true; 2178 } 2179 else{ 2180 return false; 2181 } 2182 }/*}}}*/ 2183 void Tria::AverageOntoPartition(Vector<IssmDouble>* partition_contributions,Vector<IssmDouble>* partition_areas,IssmDouble* vertex_response,IssmDouble* qmu_part){/*{{{*/ 2184 2185 bool already = false; 2186 int i,j; 2187 int partition[NUMVERTICES]; 2188 int offsetsid[NUMVERTICES]; 2189 int offsetdof[NUMVERTICES]; 2190 IssmDouble area; 2191 IssmDouble mean; 2192 2193 /*First, get the area: */ 2194 area=this->GetArea(); 2195 2196 /*Figure out the average for this element: */ 2197 this->GetVerticesSidList(&offsetsid[0]); 2198 this->GetVertexPidList(&offsetdof[0]); 2199 mean=0; 2200 for(i=0;i<NUMVERTICES;i++){ 2201 partition[i]=reCast<int>(qmu_part[offsetsid[i]]); 2202 mean=mean+1.0/NUMVERTICES*vertex_response[offsetdof[i]]; 2203 } 2204 2205 /*Add contribution: */ 2206 for(i=0;i<NUMVERTICES;i++){ 2207 already=false; 2208 for(j=0;j<i;j++){ 2209 if (partition[i]==partition[j]){ 2210 already=true; 2211 break; 3338 void Tria::ZeroLevelsetCoordinates(IssmDouble** pxyz_zero,IssmDouble* xyz_list,int levelsetenum){/*{{{*/ 3339 /* Return coordinates where levelset intersects element edges. 3340 * Attention: In case that no intersection exists, NULL pointer is returned.*/ 3341 3342 /*Intermediaries*/ 3343 const int dim=3; 3344 int numiceverts; 3345 int i, n, e, counter; 3346 IssmDouble s[2]; 3347 int* indices=NULL; 3348 IssmDouble* xyz_zero=NULL; 3349 3350 this->GetLevelsetIntersection(&indices, &numiceverts, s, MaskIceLevelsetEnum, 0.); 3351 3352 //TODO: check if for 2 iceverts front segment is oriented in CCW way 3353 3354 if(numiceverts>0) xyz_zero=xNew<IssmDouble>(2*dim); 3355 if((numiceverts>0)&&(numiceverts<NUMVERTICES)){ 3356 counter=0; 3357 for(i=0;i<numiceverts;i++){ // iterate over ice vertices 3358 for(n=numiceverts;n<NUMVERTICES;n++){ // iterate over no-ice vertices 3359 for(e=0;e<dim;e++){ // spatial direction 3360 int ind_ice =dim*indices[i]+e; 3361 int ind_noice =dim*indices[n]+e; 3362 int ind =dim*counter+e; 3363 xyz_zero[ind]=xyz_list[ind_ice]+s[counter]*(xyz_list[ind_noice]-xyz_list[ind_ice]); 3364 } 3365 counter++; 2212 3366 } 2213 3367 } 2214 if(!already){ 2215 partition_contributions->SetValue(partition[i],mean*area,ADD_VAL); 2216 partition_areas->SetValue(partition[i],area,ADD_VAL); 2217 }; 2218 } 2219 } 2220 /*}}}*/ 2221 IssmDouble Tria::IceVolume(void){/*{{{*/ 2222 2223 /*The volume of a troncated prism is base * 1/3 sum(length of edges)*/ 2224 IssmDouble base,surface,bed; 2225 IssmDouble xyz_list[NUMVERTICES][3]; 2226 2227 if(!IsIceInElement())return 0; 2228 2229 /*First get back the area of the base*/ 2230 base=this->GetArea(); 2231 2232 /*Now get the average height*/ 2233 Input* surface_input = inputs->GetInput(SurfaceEnum); _assert_(surface_input); 2234 Input* base_input = inputs->GetInput(BaseEnum); _assert_(base_input); 2235 surface_input->GetInputAverage(&surface); 2236 base_input->GetInputAverage(&bed); 2237 2238 /*Return: */ 2239 int domaintype; 2240 parameters->FindParam(&domaintype,DomainTypeEnum); 2241 if(domaintype==Domain2DverticalEnum){ 2242 return base; 2243 } 2244 else{ 2245 return base*(surface-bed); 2246 } 2247 } 2248 /*}}}*/ 2249 IssmDouble Tria::IceVolumeAboveFloatation(void){/*{{{*/ 2250 2251 /*The volume above floatation: H + rho_water/rho_ice * bathymetry */ 2252 IssmDouble rho_ice,rho_water; 2253 IssmDouble base,surface,bed,bathymetry; 2254 IssmDouble xyz_list[NUMVERTICES][3]; 2255 2256 if(!IsIceInElement() || IsFloating())return 0; 2257 2258 rho_ice=matpar->GetRhoIce(); 2259 rho_water=matpar->GetRhoWater(); 2260 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 2261 2262 /*First calculate the area of the base (cross section triangle) 2263 * http://en.wikipedia.org/wiki/Triangle 2264 * base = 1/2 abs((xA-xC)(yB-yA)-(xA-xB)(yC-yA))*/ 2265 base = 1./2. * fabs((xyz_list[0][0]-xyz_list[2][0])*(xyz_list[1][1]-xyz_list[0][1]) - (xyz_list[0][0]-xyz_list[1][0])*(xyz_list[2][1]-xyz_list[0][1])); 2266 2267 /*Now get the average height and bathymetry*/ 2268 Input* surface_input = inputs->GetInput(SurfaceEnum); _assert_(surface_input); 2269 Input* base_input = inputs->GetInput(BaseEnum); _assert_(base_input); 2270 Input* bed_input = inputs->GetInput(BedEnum); _assert_(bed_input); 2271 surface_input->GetInputAverage(&surface); 2272 base_input->GetInputAverage(&bed); 2273 bed_input->GetInputAverage(&bathymetry); 2274 2275 /*Return: */ 2276 return base*(surface-bed+min(rho_water/rho_ice*bathymetry,0.)); 2277 } 2278 /*}}}*/ 2279 IssmDouble Tria::MassFlux( IssmDouble x1, IssmDouble y1, IssmDouble x2, IssmDouble y2,int segment_id){/*{{{*/ 2280 2281 int domaintype; 2282 IssmDouble mass_flux=0.; 2283 IssmDouble xyz_list[NUMVERTICES][3]; 2284 IssmDouble normal[2]; 2285 IssmDouble length,rho_ice; 2286 IssmDouble h1,h2; 2287 IssmDouble vx1,vx2,vy1,vy2; 2288 GaussTria* gauss_1=NULL; 2289 GaussTria* gauss_2=NULL; 2290 2291 /*Get material parameters :*/ 2292 rho_ice=matpar->GetRhoIce(); 2293 2294 /*First off, check that this segment belongs to this element: */ 2295 if (segment_id!=this->id)_error_("error message: segment with id " << segment_id << " does not belong to element with id:" << this->id); 2296 2297 /*Get xyz list: */ 2298 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 2299 2300 /*get area coordinates of 0 and 1 locations: */ 2301 gauss_1=new GaussTria(); 2302 gauss_1->GaussFromCoords(x1,y1,&xyz_list[0][0]); 2303 gauss_2=new GaussTria(); 2304 gauss_2->GaussFromCoords(x2,y2,&xyz_list[0][0]); 2305 2306 normal[0]=cos(atan2(x1-x2,y2-y1)); 2307 normal[1]=sin(atan2(x1-x2,y2-y1)); 2308 2309 length=sqrt(pow(x2-x1,2)+pow(y2-y1,2)); 2310 2311 Input* thickness_input=inputs->GetInput(ThicknessEnum); _assert_(thickness_input); 2312 this->parameters->FindParam(&domaintype,DomainTypeEnum); 2313 Input* vx_input=NULL; 2314 Input* vy_input=NULL; 2315 if(domaintype==Domain2DhorizontalEnum){ 2316 vx_input=inputs->GetInput(VxEnum); _assert_(vx_input); 2317 vy_input=inputs->GetInput(VyEnum); _assert_(vy_input); 2318 } 2319 else{ 2320 vx_input=inputs->GetInput(VxAverageEnum); _assert_(vx_input); 2321 vy_input=inputs->GetInput(VyAverageEnum); _assert_(vy_input); 2322 } 2323 2324 thickness_input->GetInputValue(&h1, gauss_1); 2325 thickness_input->GetInputValue(&h2, gauss_2); 2326 vx_input->GetInputValue(&vx1,gauss_1); 2327 vx_input->GetInputValue(&vx2,gauss_2); 2328 vy_input->GetInputValue(&vy1,gauss_1); 2329 vy_input->GetInputValue(&vy2,gauss_2); 2330 2331 mass_flux= rho_ice*length*( 2332 (ONETHIRD*(h1-h2)*(vx1-vx2)+0.5*h2*(vx1-vx2)+0.5*(h1-h2)*vx2+h2*vx2)*normal[0]+ 2333 (ONETHIRD*(h1-h2)*(vy1-vy2)+0.5*h2*(vy1-vy2)+0.5*(h1-h2)*vy2+h2*vy2)*normal[1] 2334 ); 2335 2336 /*clean up and return:*/ 2337 delete gauss_1; 2338 delete gauss_2; 2339 return mass_flux; 2340 } 2341 /*}}}*/ 2342 IssmDouble Tria::MassFlux( IssmDouble* segment){/*{{{*/ 2343 2344 int domaintype; 2345 IssmDouble mass_flux=0.; 2346 IssmDouble xyz_list[NUMVERTICES][3]; 2347 IssmDouble normal[2]; 2348 IssmDouble length,rho_ice; 2349 IssmDouble x1,y1,x2,y2,h1,h2; 2350 IssmDouble vx1,vx2,vy1,vy2; 2351 GaussTria* gauss_1=NULL; 2352 GaussTria* gauss_2=NULL; 2353 2354 /*Get material parameters :*/ 2355 rho_ice=matpar->GetRhoIce(); 2356 2357 /*First off, check that this segment belongs to this element: */ 2358 if (reCast<int>(*(segment+4))!=this->id)_error_("error message: segment with id " << reCast<int>(*(segment+4)) << " does not belong to element with id:" << this->id); 2359 2360 /*Recover segment node locations: */ 2361 x1=*(segment+0); y1=*(segment+1); x2=*(segment+2); y2=*(segment+3); 2362 2363 /*Get xyz list: */ 2364 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 2365 2366 /*get area coordinates of 0 and 1 locations: */ 2367 gauss_1=new GaussTria(); 2368 gauss_1->GaussFromCoords(x1,y1,&xyz_list[0][0]); 2369 gauss_2=new GaussTria(); 2370 gauss_2->GaussFromCoords(x2,y2,&xyz_list[0][0]); 2371 2372 normal[0]=cos(atan2(x1-x2,y2-y1)); 2373 normal[1]=sin(atan2(x1-x2,y2-y1)); 2374 2375 length=sqrt(pow(x2-x1,2)+pow(y2-y1,2)); 2376 2377 Input* thickness_input=inputs->GetInput(ThicknessEnum); _assert_(thickness_input); 2378 this->parameters->FindParam(&domaintype,DomainTypeEnum); 2379 Input* vx_input=NULL; 2380 Input* vy_input=NULL; 2381 if(domaintype==Domain2DhorizontalEnum){ 2382 vx_input=inputs->GetInput(VxEnum); _assert_(vx_input); 2383 vy_input=inputs->GetInput(VyEnum); _assert_(vy_input); 2384 } 2385 else{ 2386 vx_input=inputs->GetInput(VxAverageEnum); _assert_(vx_input); 2387 vy_input=inputs->GetInput(VyAverageEnum); _assert_(vy_input); 2388 } 2389 2390 thickness_input->GetInputValue(&h1, gauss_1); 2391 thickness_input->GetInputValue(&h2, gauss_2); 2392 vx_input->GetInputValue(&vx1,gauss_1); 2393 vx_input->GetInputValue(&vx2,gauss_2); 2394 vy_input->GetInputValue(&vy1,gauss_1); 2395 vy_input->GetInputValue(&vy2,gauss_2); 2396 2397 mass_flux= rho_ice*length*( 2398 (ONETHIRD*(h1-h2)*(vx1-vx2)+0.5*h2*(vx1-vx2)+0.5*(h1-h2)*vx2+h2*vx2)*normal[0]+ 2399 (ONETHIRD*(h1-h2)*(vy1-vy2)+0.5*h2*(vy1-vy2)+0.5*(h1-h2)*vy2+h2*vy2)*normal[1] 2400 ); 2401 2402 /*clean up and return:*/ 2403 delete gauss_1; 2404 delete gauss_2; 2405 return mass_flux; 2406 } 2407 /*}}}*/ 2408 void Tria::ElementResponse(IssmDouble* presponse,int response_enum){/*{{{*/ 2409 2410 switch(response_enum){ 2411 case MaterialsRheologyBbarEnum: 2412 *presponse=this->material->GetBbar(); 2413 break; 2414 2415 case VelEnum:{ 2416 2417 /*Get input:*/ 2418 IssmDouble vel; 2419 Input* vel_input; 2420 2421 vel_input=this->inputs->GetInput(VelEnum); _assert_(vel_input); 2422 vel_input->GetInputAverage(&vel); 2423 2424 /*Assign output pointers:*/ 2425 *presponse=vel;} 2426 break; 2427 default: 2428 _error_("Response type " << EnumToStringx(response_enum) << " not supported yet!"); 2429 } 2430 2431 } 2432 /*}}}*/ 2433 IssmDouble Tria::TotalSmb(void){/*{{{*/ 2434 2435 /*The smb[kg yr-1] of one element is area[m2] * smb [kg m^-2 yr^-1]*/ 2436 IssmDouble base,smb,rho_ice; 2437 IssmDouble Total_Smb=0; 2438 IssmDouble xyz_list[NUMVERTICES][3]; 2439 2440 /*Get material parameters :*/ 2441 rho_ice=matpar->GetRhoIce(); 2442 2443 if(!IsIceInElement())return 0; 2444 2445 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 2446 2447 /*First calculate the area of the base (cross section triangle) 2448 * http://en.wikipedia.org/wiki/Triangle 2449 * base = 1/2 abs((xA-xC)(yB-yA)-(xA-xB)(yC-yA))*/ 2450 base = 1./2. * fabs((xyz_list[0][0]-xyz_list[2][0])*(xyz_list[1][1]-xyz_list[0][1]) - (xyz_list[0][0]-xyz_list[1][0])*(xyz_list[2][1]-xyz_list[0][1])); // area of element in m2 2451 2452 /*Now get the average SMB over the element*/ 2453 Input* smb_input = inputs->GetInput(SurfaceforcingsMassBalanceEnum); _assert_(smb_input); 2454 smb_input->GetInputAverage(&smb); // average smb on element in m ice s-1 2455 Total_Smb=rho_ice*base*smb; // smb on element in kg s-1 2456 2457 /*Return: */ 2458 return Total_Smb; 2459 } 2460 /*}}}*/ 2461 IssmDouble Tria::MisfitArea(int weightsenum){/*{{{*/ 2462 2463 /*Intermediaries*/ 2464 IssmDouble weight; 2465 IssmDouble Jdet; 2466 IssmDouble Jelem = 0; 2467 IssmDouble xyz_list[NUMVERTICES][3]; 2468 GaussTria *gauss = NULL; 2469 2470 /*If on water, return 0: */ 2471 if(!IsIceInElement())return 0; 2472 2473 /*Retrieve all inputs we will be needing: */ 2474 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 2475 Input* weights_input =inputs->GetInput(weightsenum); _assert_(weights_input); 2476 2477 /* Start looping on the number of gaussian points: */ 2478 gauss=new GaussTria(2); 2479 for(int ig=gauss->begin();ig<gauss->end();ig++){ 2480 2481 gauss->GaussPoint(ig); 2482 2483 /* Get Jacobian determinant: */ 2484 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss); 2485 2486 /*Get parameters at gauss point*/ 2487 weights_input->GetInputValue(&weight,gauss); 2488 2489 /*compute misfit between model and observation */ 2490 Jelem+=Jdet*weight*gauss->weight; 2491 } 2492 2493 /* clean up and Return: */ 2494 delete gauss; 2495 return Jelem; 2496 } 2497 /*}}}*/ 2498 IssmDouble Tria::Misfit(int modelenum,int observationenum,int weightsenum){/*{{{*/ 2499 2500 /*Intermediaries*/ 2501 IssmDouble model,observation,weight; 2502 IssmDouble Jdet; 2503 IssmDouble Jelem = 0; 2504 IssmDouble xyz_list[NUMVERTICES][3]; 2505 GaussTria *gauss = NULL; 2506 2507 /*If on water, return 0: */ 2508 if(!IsIceInElement())return 0; 2509 2510 /*Retrieve all inputs we will be needing: */ 2511 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 2512 Input* model_input=inputs->GetInput(modelenum); _assert_(model_input); 2513 Input* observation_input=inputs->GetInput(observationenum);_assert_(observation_input); 2514 Input* weights_input =inputs->GetInput(weightsenum); _assert_(weights_input); 2515 2516 /* Start looping on the number of gaussian points: */ 2517 gauss=new GaussTria(2); 2518 for(int ig=gauss->begin();ig<gauss->end();ig++){ 2519 2520 gauss->GaussPoint(ig); 2521 2522 /* Get Jacobian determinant: */ 2523 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss); 2524 2525 /*Get parameters at gauss point*/ 2526 model_input->GetInputValue(&model,gauss); 2527 observation_input->GetInputValue(&observation,gauss); 2528 weights_input->GetInputValue(&weight,gauss); 2529 2530 /*compute misfit between model and observation */ 2531 Jelem+=0.5*(model-observation)*(model-observation)*Jdet*weight*gauss->weight; 2532 } 2533 2534 /* clean up and Return: */ 2535 delete gauss; 2536 return Jelem; 3368 } 3369 else if(numiceverts==NUMVERTICES){ //NUMVERTICES ice vertices: calving front lies on element edge 3370 IssmDouble lsf[NUMVERTICES]; 3371 this->GetInputListOnVertices(&lsf[0],MaskIceLevelsetEnum); 3372 counter=0; 3373 for(i=0;i<NUMVERTICES;i++){ 3374 if(lsf[indices[i]]==0.){ 3375 for(e=0;e<dim;e++) xyz_zero[dim*counter+e]=xyz_list[dim*indices[i]+e]; 3376 counter++; 3377 } 3378 if(counter==2) break; 3379 } 3380 } 3381 _assert_(counter==2); 3382 3383 /*Cleanup & return*/ 3384 xDelete<int>(indices); 3385 *pxyz_zero=xyz_zero; 2537 3386 } 2538 3387 /*}}}*/ … … 2591 3440 2592 3441 /*recover material parameters: */ 2593 lithosphere_shear_modulus=matpar->Get LithosphereShearModulus();2594 lithosphere_density=matpar->Get LithosphereDensity();2595 mantle_shear_modulus=matpar->GetMa ntleShearModulus();2596 mantle_density=matpar->GetMa ntleDensity();2597 rho_ice=matpar->Get RhoIce();3442 lithosphere_shear_modulus=matpar->GetMaterialParameter(MaterialsLithosphereShearModulusEnum); 3443 lithosphere_density=matpar->GetMaterialParameter(MaterialsLithosphereDensityEnum); 3444 mantle_shear_modulus=matpar->GetMaterialParameter(MaterialsMantleShearModulusEnum); 3445 mantle_density=matpar->GetMaterialParameter(MaterialsMantleDensityEnum); 3446 rho_ice=matpar->GetMaterialParameter(MaterialsRhoIceEnum); 2598 3447 2599 3448 /*pull thickness averages: */ … … 2666 3515 #endif 2667 3516 2668 void Tria::InputControlUpdate(IssmDouble scalar,bool save_parameter){/*{{{*/2669 2670 /*Intermediary*/2671 int num_controls;2672 int* control_type=NULL;2673 Input* input=NULL;2674 2675 /*retrieve some parameters: */2676 this->parameters->FindParam(&num_controls,InversionNumControlParametersEnum);2677 this->parameters->FindParam(&control_type,NULL,InversionControlParametersEnum);2678 2679 for(int i=0;i<num_controls;i++){2680 input=(Input*)this->inputs->GetInput(control_type[i]); _assert_(input);2681 if (input->ObjectEnum()!=ControlInputEnum){2682 _error_("input " << EnumToStringx(control_type[i]) << " is not a ControlInput");2683 }2684 2685 ((ControlInput*)input)->UpdateValue(scalar);2686 ((ControlInput*)input)->Constrain();2687 if (save_parameter) ((ControlInput*)input)->SaveValue();2688 2689 }2690 2691 /*Clean up and return*/2692 xDelete<int>(control_type);2693 }2694 /*}}}*/2695 void Tria::ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index){/*{{{*/2696 2697 int vertexpidlist[NUMVERTICES];2698 IssmDouble grad_list[NUMVERTICES];2699 Input* grad_input=NULL;2700 2701 Input* input=inputs->GetInput(enum_type);2702 if (!input) _error_("Input " << EnumToStringx(enum_type) << " not found");2703 if (input->ObjectEnum()!=ControlInputEnum) _error_("Input " << EnumToStringx(enum_type) << " is not a ControlInput");2704 2705 GradientIndexing(&vertexpidlist[0],control_index);2706 for(int i=0;i<NUMVERTICES;i++) grad_list[i]=gradient[vertexpidlist[i]];2707 grad_input=new TriaInput(GradientEnum,grad_list,P1Enum);2708 2709 ((ControlInput*)input)->SetGradient(grad_input);2710 2711 }/*}}}*/2712 void Tria::ControlToVectors(Vector<IssmPDouble>* vector_control, Vector<IssmPDouble>* vector_gradient,int control_enum){/*{{{*/2713 2714 Input* input=inputs->GetInput(control_enum);2715 if (!input) _error_("Input " << EnumToStringx(control_enum) << " not found");2716 if (input->ObjectEnum()!=ControlInputEnum) _error_("Input " << EnumToStringx(control_enum) << " is not a ControlInput");2717 2718 int sidlist[NUMVERTICES];2719 int connectivity[NUMVERTICES];2720 IssmPDouble values[NUMVERTICES];2721 IssmPDouble gradients[NUMVERTICES];2722 IssmDouble value,gradient;2723 2724 this->GetVerticesConnectivityList(&connectivity[0]);2725 this->GetVerticesSidList(&sidlist[0]);2726 2727 GaussTria* gauss=new GaussTria();2728 for (int iv=0;iv<NUMVERTICES;iv++){2729 gauss->GaussVertex(iv);2730 2731 ((ControlInput*)input)->GetInputValue(&value,gauss);2732 ((ControlInput*)input)->GetGradientValue(&gradient,gauss);2733 2734 values[iv] = reCast<IssmPDouble>(value)/reCast<IssmPDouble>(connectivity[iv]);2735 gradients[iv] = reCast<IssmPDouble>(gradient)/reCast<IssmPDouble>(connectivity[iv]);2736 }2737 delete gauss;2738 2739 vector_control->SetValues(NUMVERTICES,&sidlist[0],&values[0],ADD_VAL);2740 vector_gradient->SetValues(NUMVERTICES,&sidlist[0],&gradients[0],ADD_VAL);2741 2742 }/*}}}*/2743 void Tria::GetVectorFromControlInputs(Vector<IssmDouble>* vector,int control_enum,int control_index,const char* data){/*{{{*/2744 2745 int vertexpidlist[NUMVERTICES];2746 Input *input=NULL;2747 2748 /*Get out if this is not an element input*/2749 if(!IsInput(control_enum)) return;2750 2751 /*Prepare index list*/2752 GradientIndexing(&vertexpidlist[0],control_index);2753 2754 /*Get input (either in element or material)*/2755 input=(Input*)this->inputs->GetInput(control_enum); _assert_(input);2756 2757 /*Check that it is a ControlInput*/2758 if (input->ObjectEnum()!=ControlInputEnum){2759 _error_("input " << EnumToStringx(control_enum) << " is not a ControlInput");2760 }2761 2762 ((ControlInput*)input)->GetVectorFromInputs(vector,&vertexpidlist[0],data);2763 }2764 /*}}}*/2765 void Tria::SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index){/*{{{*/2766 2767 IssmDouble values[NUMVERTICES];2768 int vertexpidlist[NUMVERTICES],control_init;2769 2770 2771 /*Get Domain type*/2772 int domaintype;2773 parameters->FindParam(&domaintype,DomainTypeEnum);2774 2775 /*Specific case for depth averaged quantities*/2776 control_init=control_enum;2777 if(domaintype==Domain2DverticalEnum){2778 if(control_enum==MaterialsRheologyBbarEnum){2779 control_enum=MaterialsRheologyBEnum;2780 if(!IsOnBase()) return;2781 }2782 if(control_enum==DamageDbarEnum){2783 control_enum=DamageDEnum;2784 if(!IsOnBase()) return;2785 }2786 }2787 2788 /*Get out if this is not an element input*/2789 if(!IsInput(control_enum)) return;2790 2791 /*Prepare index list*/2792 GradientIndexing(&vertexpidlist[0],control_index);2793 2794 /*Get values on vertices*/2795 for(int i=0;i<NUMVERTICES;i++){2796 values[i]=vector[vertexpidlist[i]];2797 }2798 Input* new_input = new TriaInput(control_enum,values,P1Enum);2799 Input* input = (Input*)this->inputs->GetInput(control_enum); _assert_(input);2800 if(input->ObjectEnum()!=ControlInputEnum){2801 _error_("input " << EnumToStringx(control_enum) << " is not a ControlInput");2802 }2803 2804 ((ControlInput*)input)->SetInput(new_input);2805 }2806 /*}}}*/2807 void Tria::GetSolutionFromInputsOneDof(Vector<IssmDouble>* solution, int enum_type){/*{{{*/2808 2809 int *doflist = NULL;2810 IssmDouble value;2811 2812 /*Fetch number of nodes for this finite element*/2813 int numnodes = this->NumberofNodes(this->element_type);2814 2815 /*Fetch dof list and allocate solution vector*/2816 GetDofList(&doflist,NoneApproximationEnum,GsetEnum);2817 IssmDouble* values = xNew<IssmDouble>(numnodes);2818 2819 /*Get inputs*/2820 Input* enum_input=inputs->GetInput(enum_type); _assert_(enum_input);2821 2822 /*Ok, we have the values, fill in the array: */2823 GaussTria* gauss=new GaussTria();2824 for(int i=0;i<numnodes;i++){2825 gauss->GaussNode(this->element_type,i);2826 2827 enum_input->GetInputValue(&value,gauss);2828 values[i]=value;2829 }2830 2831 solution->SetValues(numnodes,doflist,values,INS_VAL);2832 2833 /*Free ressources:*/2834 xDelete<int>(doflist);2835 xDelete<IssmDouble>(values);2836 delete gauss;2837 }2838 /*}}}*/2839 2840 3517 #ifdef _HAVE_DAKOTA_ 3518 void Tria::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type){/*{{{*/ 3519 3520 int i,t,row; 3521 IssmDouble time; 3522 TransientInput *transientinput = NULL; 3523 IssmDouble values[3]; 3524 3525 /*Check that name is an element input*/ 3526 if (!IsInput(name)) return; 3527 3528 switch(type){ 3529 3530 case VertexEnum: 3531 /*Create transient input: */ 3532 for(t=0;t<ncols;t++){ //ncols is the number of times 3533 3534 /*create input values: */ 3535 for(i=0;i<3;i++){ 3536 row=this->vertices[i]->Sid(); 3537 values[i]=matrix[ncols*row+t]; 3538 } 3539 3540 /*time:*/ 3541 time=matrix[(nrows-1)*ncols+t]; 3542 3543 if(t==0) transientinput=new TransientInput(name); 3544 transientinput->AddTimeInput(new TriaInput(name,values,P1Enum),time); 3545 transientinput->Configure(parameters); 3546 } 3547 this->inputs->AddInput(transientinput); 3548 break; 3549 3550 default: 3551 _error_("type " << type << " (" << EnumToStringx(type) << ") not implemented yet"); 3552 } 3553 3554 } 3555 /*}}}*/ 2841 3556 void Tria::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){/*{{{*/ 2842 3557 … … 2877 3592 /*hydrostatic equilibrium: */ 2878 3593 IssmDouble rho_ice,rho_water,di; 2879 rho_ice = this->matpar->Get RhoIce();2880 rho_water = this->matpar->Get RhoWater();3594 rho_ice = this->matpar->GetMaterialParameter(MaterialsRhoIceEnum); 3595 rho_water = this->matpar->GetMaterialParameter(MaterialsRhoSeawaterEnum); 2881 3596 di = rho_ice/rho_water; 2882 3597 … … 2930 3645 } 2931 3646 /*}}}*/ 2932 void Tria::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type){/*{{{*/2933 2934 int i,t,row;2935 IssmDouble time;2936 TransientInput *transientinput = NULL;2937 IssmDouble values[3];2938 2939 /*Check that name is an element input*/2940 if (!IsInput(name)) return;2941 2942 switch(type){2943 2944 case VertexEnum:2945 /*Create transient input: */2946 for(t=0;t<ncols;t++){ //ncols is the number of times2947 2948 /*create input values: */2949 for(i=0;i<3;i++){2950 row=this->vertices[i]->Sid();2951 values[i]=matrix[ncols*row+t];2952 }2953 2954 /*time:*/2955 time=matrix[(nrows-1)*ncols+t];2956 2957 if(t==0) transientinput=new TransientInput(name);2958 transientinput->AddTimeInput(new TriaInput(name,values,P1Enum),time);2959 transientinput->Configure(parameters);2960 }2961 this->inputs->AddInput(transientinput);2962 break;2963 2964 default:2965 _error_("type " << type << " (" << EnumToStringx(type) << ") not implemented yet");2966 }2967 2968 }2969 /*}}}*/2970 3647 #endif 2971 2972 void Tria::MigrateGroundingLine(IssmDouble* phi_ungrounding){/*{{{*/2973 2974 int i,migration_style;2975 bool groundedelement = false;2976 IssmDouble bed_hydro,yts;2977 IssmDouble rho_water,rho_ice,density;2978 IssmDouble melting[NUMVERTICES],phi[NUMVERTICES];;2979 IssmDouble h[NUMVERTICES],s[NUMVERTICES],b[NUMVERTICES],r[NUMVERTICES];2980 2981 /*Recover info at the vertices: */2982 parameters->FindParam(&migration_style,GroundinglineMigrationEnum);2983 parameters->FindParam(&yts,ConstantsYtsEnum);2984 GetInputListOnVertices(&h[0],ThicknessEnum);2985 GetInputListOnVertices(&s[0],SurfaceEnum);2986 GetInputListOnVertices(&b[0],BaseEnum);2987 GetInputListOnVertices(&r[0],BedEnum);2988 GetInputListOnVertices(&phi[0],MaskGroundediceLevelsetEnum);2989 rho_water = matpar->GetRhoWater();2990 rho_ice = matpar->GetRhoIce();2991 density = rho_ice/rho_water;2992 2993 if(migration_style == ContactEnum){2994 for(i = 0;i < NUMVERTICES;i++) phi[i] = phi_ungrounding[vertices[i]->Pid()];2995 this->inputs->AddInput(new TriaInput(MaskGroundediceLevelsetEnum,&phi[0],P1Enum));2996 2997 /*go through vertices, and update inputs, considering them to be TriaVertex type: */2998 for(i = 0;i < NUMVERTICES;i++){2999 /*Ice shelf: if bed below bathymetry, impose it at the bathymetry and update surface, elso do nothing */3000 if(phi[i] >= 0.){3001 b[i] = r[i];3002 }3003 }3004 3005 /*Update inputs*/3006 this->inputs->AddInput(new TriaInput(BaseEnum,&b[0],P1Enum));3007 return;3008 }3009 3010 this->inputs->AddInput(new TriaInput(MaskGroundediceLevelsetEnum,&phi[0],P1Enum));3011 3012 /*go through vertices, and update inputs, considering them to be TriaVertex type: */3013 for(i=0;i<NUMVERTICES;i++){3014 /*Ice shelf: if bed below bathymetry, impose it at the bathymetry and update surface, elso do nothing */3015 if(phi[i]<=0.){3016 if(b[i]<=r[i]){3017 b[i] = r[i];3018 s[i] = b[i]+h[i];3019 }3020 }3021 /*Ice sheet: if hydrostatic bed above bathymetry, ice sheet starts to unground, elso do nothing */3022 /*Change only if AggressiveMigration or if the ice sheet is in contact with the ocean*/3023 else{ // phi>03024 bed_hydro=-density*h[i];3025 if (bed_hydro>r[i]){3026 /*Unground only if the element is connected to the ice shelf*/3027 if(migration_style==AggressiveMigrationEnum || migration_style==SubelementMigrationEnum || migration_style==SubelementMigration2Enum){3028 s[i] = (1-density)*h[i];3029 b[i] = -density*h[i];3030 }3031 else if(migration_style==SoftMigrationEnum && phi_ungrounding[vertices[i]->Pid()]<0.){3032 s[i] = (1-density)*h[i];3033 b[i] = -density*h[i];3034 }3035 else{3036 if(migration_style!=SoftMigrationEnum) _error_("Error: migration should be Aggressive, Soft or Subelement");3037 }3038 }3039 }3040 }3041 3042 /*Recalculate phi*/3043 for(i=0;i<NUMVERTICES;i++){3044 if(migration_style==SoftMigrationEnum){3045 bed_hydro=-density*h[i];3046 if(phi[i]<0. || bed_hydro<=r[i] || phi_ungrounding[vertices[i]->Pid()]<0.){3047 phi[i]=h[i]+r[i]/density;3048 }3049 }3050 else phi[i]=h[i]+r[i]/density;3051 }3052 this->inputs->AddInput(new TriaInput(MaskGroundediceLevelsetEnum,&phi[0],P1Enum));3053 3054 /*Update inputs*/3055 this->inputs->AddInput(new TriaInput(SurfaceEnum,&s[0],P1Enum));3056 this->inputs->AddInput(new TriaInput(BaseEnum,&b[0],P1Enum));3057 3058 }3059 /*}}}*/3060 void Tria::PotentialUngrounding(Vector<IssmDouble>* potential_ungrounding){/*{{{*/3061 3062 IssmDouble h[NUMVERTICES],r[NUMVERTICES],gl[NUMVERTICES];3063 IssmDouble bed_hydro;3064 IssmDouble rho_water,rho_ice,density;3065 3066 /*material parameters: */3067 rho_water=matpar->GetRhoWater();3068 rho_ice=matpar->GetRhoIce();3069 density=rho_ice/rho_water;3070 GetInputListOnVertices(&h[0],ThicknessEnum);3071 GetInputListOnVertices(&r[0],BedEnum);3072 GetInputListOnVertices(&gl[0],MaskGroundediceLevelsetEnum);3073 3074 /*go through vertices, and figure out which ones are grounded and want to unground: */3075 for(int i=0;i<NUMVERTICES;i++){3076 /*Find if grounded vertices want to start floating*/3077 if (gl[i]>0.){3078 bed_hydro=-density*h[i];3079 if(bed_hydro>r[i]){3080 /*Vertex that could potentially unground, flag it*/3081 potential_ungrounding->SetValue(vertices[i]->Pid(),1,INS_VAL);3082 }3083 }3084 }3085 }3086 /*}}}*/3087 int Tria::UpdatePotentialUngrounding(IssmDouble* vertices_potentially_ungrounding,Vector<IssmDouble>* vec_nodes_on_iceshelf,IssmDouble* nodes_on_iceshelf){/*{{{*/3088 3089 int i;3090 int nflipped=0;3091 3092 /*Go through nodes, and whoever is on the potential_ungrounding, ends up in nodes_on_iceshelf: */3093 for(i=0;i<3;i++){3094 if (reCast<bool>(vertices_potentially_ungrounding[vertices[i]->Pid()])){3095 vec_nodes_on_iceshelf->SetValue(vertices[i]->Pid(),-1.,INS_VAL);3096 3097 /*If node was not on ice shelf, we flipped*/3098 if(nodes_on_iceshelf[vertices[i]->Pid()]>=0.){3099 nflipped++;3100 }3101 }3102 }3103 return nflipped;3104 }3105 /*}}}*/ -
issm/trunk/src/c/classes/Elements/Tria.h
r18301 r19105 42 42 /*}}}*/ 43 43 /*Update virtual functions resolution: {{{*/ 44 void InputUpdateFromVector(IssmDouble* vector, int name, int type);45 44 #ifdef _HAVE_DAKOTA_ 45 void InputUpdateFromMatrixDakota(IssmDouble* matrix, int nows, int ncols, int name, int type); 46 46 void InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type); 47 void InputUpdateFromMatrixDakota(IssmDouble* matrix, int nows, int ncols, int name, int type);48 47 #endif 49 48 void InputUpdateFromIoModel(int index, IoModel* iomodel); 49 void InputUpdateFromVector(IssmDouble* vector, int name, int type); 50 50 /*}}}*/ 51 51 /*Element virtual functions definitions: {{{*/ 52 void AverageOntoPartition(Vector<IssmDouble>* partition_contributions,Vector<IssmDouble>* partition_areas,IssmDouble* vertex_response,IssmDouble* qmu_part); 53 void CalvingRateLevermann(); 54 void CalvingRatePi(); 55 void CalvingRateDev(); 52 56 IssmDouble CharacteristicLength(void); 53 57 void ComputeBasalStress(Vector<IssmDouble>* sigma_b); 58 void ComputeDeviatoricStressTensor(); 54 59 void ComputeSigmaNN(); 55 60 void ComputeStressTensor(); 56 void ComputeDeviatoricStressTensor();57 61 void ComputeSurfaceNormalVelocity(); 58 62 void Configure(Elements* elements,Loads* loads,Nodes* nodesin,Vertices* verticesin,Materials* materials,Parameters* parameters); 59 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Materials* materials,Parameters* parameters);60 void ResetHooks();63 void ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index); 64 void ControlToVectors(Vector<IssmPDouble>* vector_control, Vector<IssmPDouble>* vector_gradient,int control_enum); 61 65 void Delta18oParameterization(void); 66 void MungsmtpParameterization(void); 67 int EdgeOnBaseIndex(); 68 void EdgeOnBaseIndices(int* pindex1,int* pindex); 69 int EdgeOnSurfaceIndex(); 70 void EdgeOnSurfaceIndices(int* pindex1,int* pindex); 71 void ElementResponse(IssmDouble* presponse,int response_enum); 62 72 void ElementSizes(IssmDouble* hx,IssmDouble* hy,IssmDouble* hz); 73 int FiniteElement(void); 63 74 void FSContactMigration(Vector<IssmDouble>* vertexgrounded,Vector<IssmDouble>* vertexfloating); 64 int FiniteElement(void);65 Element* GetUpperElement(void){_error_("not implemented yet");};66 75 Element* GetBasalElement(void){_error_("not implemented yet");}; 76 void GetLevelsetPositivePart(int* point1,IssmDouble* fraction1,IssmDouble* fraction2, bool* mainlynegative,IssmDouble* levelsetvalues); 67 77 void GetGroundedPart(int* point1,IssmDouble* fraction1, IssmDouble* fraction2,bool* mainlyfloating); 68 78 IssmDouble GetGroundedPortion(IssmDouble* xyz_list); 79 void GetIcefrontCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum); 80 void GetLevelCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum,IssmDouble level); 69 81 int GetNodeIndex(Node* node); 70 82 int GetNumberOfNodes(void); 71 83 int GetNumberOfNodes(int enum_type); 72 84 int GetNumberOfVertices(void); 85 void GetSolutionFromInputsOneDof(Vector<IssmDouble>* solution,int enum_type); 86 Element* GetUpperElement(void){_error_("not implemented yet");}; 87 void GetVectorFromControlInputs(Vector<IssmDouble>* gradient,int control_enum,int control_index,const char* data,bool onsid); 88 void GetVerticesCoordinatesBase(IssmDouble** pxyz_list); 89 void GetVerticesCoordinatesTop(IssmDouble** pxyz_list); 90 bool HasEdgeOnBase(); 91 bool HasEdgeOnSurface(); 92 IssmDouble IceMass(void); 93 IssmDouble IceVolume(void); 94 IssmDouble IceVolumeAboveFloatation(void); 95 void InputControlUpdate(IssmDouble scalar,bool save_parameter); 96 void InputDepthAverageAtBase(int enum_type,int average_enum_type); 97 void InputExtrude(int enum_type,int start){_error_("not implemented"); /*For penta only*/}; 98 void InputScale(int enum_type,IssmDouble scale_factor); 99 bool IsFaceOnBoundary(void); 100 bool IsIcefront(void); 101 bool IsNodeOnShelfFromFlags(IssmDouble* flags); 73 102 bool IsOnBase(); 74 103 bool IsOnSurface(); 75 bool HasEdgeOnBase(); 76 bool HasEdgeOnSurface(); 77 void EdgeOnSurfaceIndices(int* pindex1,int* pindex); 78 void EdgeOnBaseIndices(int* pindex1,int* pindex); 79 int EdgeOnBaseIndex(); 80 int EdgeOnSurfaceIndex(); 81 bool IsNodeOnShelfFromFlags(IssmDouble* flags); 104 bool IsZeroLevelset(int levelset_enum); 105 IssmDouble Masscon(IssmDouble* levelset); 106 IssmDouble MassFlux(IssmDouble* segment); 107 IssmDouble MassFlux(IssmDouble x1,IssmDouble y1, IssmDouble x2, IssmDouble y2,int segment_id); 108 void MaterialUpdateFromTemperature(void){_error_("not implemented yet");}; 109 IssmDouble Misfit(int modelenum,int observationenum,int weightsenum); 110 IssmDouble MisfitArea(int weightsenum); 111 int NodalValue(IssmDouble* pvalue, int index, int natureofdataenum); 112 int NumberofNodesPressure(void); 82 113 int NumberofNodesVelocity(void); 83 int NumberofNodesPressure(void); 84 void GetSolutionFromInputsOneDof(Vector<IssmDouble>* solution,int enum_type); 85 void GetVerticesCoordinatesBase(IssmDouble** pxyz_list); 86 void GetVerticesCoordinatesTop(IssmDouble** pxyz_list); 87 void InputDepthAverageAtBase(int enum_type,int average_enum_type); 88 void InputExtrude(int enum_type){_error_("not implemented"); /*For penta only*/}; 89 void InputScale(int enum_type,IssmDouble scale_factor); 90 void MaterialUpdateFromTemperature(void){_error_("not implemented yet");}; 91 int NodalValue(IssmDouble* pvalue, int index, int natureofdataenum); 92 void PositiveDegreeDay(IssmDouble* pdds,IssmDouble* pds,IssmDouble signorm); 114 void PositiveDegreeDay(IssmDouble* pdds,IssmDouble* pds,IssmDouble signorm,bool ismungsm); 115 void PotentialUngrounding(Vector<IssmDouble>* potential_sheet_ungrounding); 116 int PressureInterpolation(); 93 117 void ReduceMatrices(ElementMatrix* Ke,ElementVector* pe); 94 118 void ResetFSBasalBoundaryCondition(void); 119 void ResetHooks(); 120 void SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index); 121 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Materials* materials,Parameters* parameters); 95 122 Element* SpawnBasalElement(void); 96 123 Element* SpawnTopElement(void); 124 void StrainRateparallel(); 125 void StrainRateperpendicular(); 126 void StressIntensityFactor(void){_error_("not implemented yet");}; 127 IssmDouble SurfaceArea(void); 128 int TensorInterpolation(); 129 IssmDouble TimeAdapt(); 130 IssmDouble TotalSmb(void); 131 void Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type,int finitelement); 132 int UpdatePotentialUngrounding(IssmDouble* vertices_potentially_ungrounding,Vector<IssmDouble>* vec_nodes_on_iceshelf,IssmDouble* nodes_on_iceshelf); 133 void ValueP1DerivativesOnGauss(IssmDouble* dvalue,IssmDouble* values,IssmDouble* xyz_list,Gauss* gauss); 134 void ValueP1OnGauss(IssmDouble* pvalue,IssmDouble* values,Gauss* gauss); 97 135 int VelocityInterpolation(); 98 int PressureInterpolation();99 int TensorInterpolation();100 IssmDouble SurfaceArea(void);101 void Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type,int finitelement);102 IssmDouble TimeAdapt();103 void ValueP1OnGauss(IssmDouble* pvalue,IssmDouble* values,Gauss* gauss);104 void ValueP1DerivativesOnGauss(IssmDouble* dvalue,IssmDouble* values,IssmDouble* xyz_list,Gauss* gauss);105 136 int VertexConnectivity(int vertexindex); 106 137 void VerticalSegmentIndices(int** pindices,int* pnumseg){_error_("not implemented yet");}; 107 138 void ZeroLevelsetCoordinates(IssmDouble** pxyz_zero,IssmDouble* xyz_list,int levelsetenum); 108 void GetIcefrontCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum);109 void GetLevelCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum,IssmDouble level);110 bool IsZeroLevelset(int levelset_enum);111 bool IsIcefront(void);112 bool IsFaceOnBoundary(void);113 114 void AverageOntoPartition(Vector<IssmDouble>* partition_contributions,Vector<IssmDouble>* partition_areas,IssmDouble* vertex_response,IssmDouble* qmu_part);115 IssmDouble IceVolume(void);116 IssmDouble IceVolumeAboveFloatation(void);117 IssmDouble TotalSmb(void);118 IssmDouble MassFlux(IssmDouble* segment);119 IssmDouble MassFlux(IssmDouble x1,IssmDouble y1, IssmDouble x2, IssmDouble y2,int segment_id);120 void ElementResponse(IssmDouble* presponse,int response_enum);121 IssmDouble Misfit(int modelenum,int observationenum,int weightsenum);122 IssmDouble MisfitArea(int weightsenum);123 139 124 140 #ifdef _HAVE_GIA_ 125 141 void GiaDeflection(Vector<IssmDouble>* wg,Vector<IssmDouble>* dwgdt,IssmDouble* x,IssmDouble* y); 126 142 #endif 127 128 void GetVectorFromControlInputs(Vector<IssmDouble>* gradient,int control_enum,int control_index,const char* data);129 void SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index);130 void ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index);131 void ControlToVectors(Vector<IssmPDouble>* vector_control, Vector<IssmPDouble>* vector_gradient,int control_enum);132 void InputControlUpdate(IssmDouble scalar,bool save_parameter);133 134 void PotentialUngrounding(Vector<IssmDouble>* potential_sheet_ungrounding);135 void MigrateGroundingLine(IssmDouble* sheet_ungrounding);136 int UpdatePotentialUngrounding(IssmDouble* vertices_potentially_ungrounding,Vector<IssmDouble>* vec_nodes_on_iceshelf,IssmDouble* nodes_on_iceshelf);137 138 143 /*}}}*/ 139 144 /*Tria specific routines:{{{*/ … … 141 146 void AddInput(int input_enum, IssmDouble* values, int interpolation_enum); 142 147 IssmDouble GetArea(void); 148 IssmDouble GetAreaIce(void); 143 149 void GetAreaCoordinates(IssmDouble *area_coordinates,IssmDouble* xyz_zero,IssmDouble* xyz_list,int numpoints); 150 void GetLevelsetIntersection(int** pindices, int* pnumiceverts, IssmDouble* fraction, int levelset_enum, IssmDouble level); 144 151 int GetElementType(void); 145 void NormalSection(IssmDouble* normal,IssmDouble* xyz_list);146 void NormalTop(IssmDouble* normal,IssmDouble* xyz_list);147 void NormalBase(IssmDouble* normal,IssmDouble* xyz_list);148 152 void GetInputValue(IssmDouble* pvalue,Node* node,int enumtype); 149 153 void GetMaterialInputValue(IssmDouble* pvalue,Node* node,int enumtype); … … 152 156 void InputUpdateFromSolutionOneDofCollapsed(IssmDouble* solution,int enum_type){_error_("not implemented yet");}; 153 157 void JacobianDeterminant(IssmDouble* pJdet, IssmDouble* xyz_list,Gauss* gauss); 158 void JacobianDeterminantBase(IssmDouble* pJdet,IssmDouble* xyz_list_base,Gauss* gauss); 154 159 void JacobianDeterminantLine(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");}; 155 160 void JacobianDeterminantSurface(IssmDouble* pJdet, IssmDouble* xyz_list,Gauss* gauss); 156 void JacobianDeterminantBase(IssmDouble* pJdet,IssmDouble* xyz_list_base,Gauss* gauss);157 161 void JacobianDeterminantTop(IssmDouble* pJdet,IssmDouble* xyz_list_base,Gauss* gauss); 158 162 IssmDouble MinEdgeLength(IssmDouble* xyz_list){_error_("not implemented yet");}; … … 166 170 Gauss* NewGaussTop(int order); 167 171 void NodalFunctions(IssmDouble* basis,Gauss* gauss); 172 void NodalFunctionsDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss); 173 void NodalFunctionsDerivativesVelocity(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss); 174 void NodalFunctionsMINIDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");}; 175 void NodalFunctionsPressure(IssmDouble* basis,Gauss* gauss); 168 176 void NodalFunctionsP1(IssmDouble* basis,Gauss* gauss); 177 void NodalFunctionsP1Derivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss); 169 178 void NodalFunctionsP2(IssmDouble* basis,Gauss* gauss); 170 void NodalFunctionsDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss); 171 void NodalFunctionsP1Derivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss); 172 void NodalFunctionsMINIDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");}; 173 void NodalFunctionsDerivativesVelocity(IssmDouble* dbasis,IssmDouble* xyz_list,Gauss* gauss); 179 void NodalFunctionsTensor(IssmDouble* basis,Gauss* gauss); 174 180 void NodalFunctionsVelocity(IssmDouble* basis,Gauss* gauss); 175 void NodalFunctionsPressure(IssmDouble* basis,Gauss* gauss); 176 void NodalFunctionsTensor(IssmDouble* basis,Gauss* gauss); 181 void NormalBase(IssmDouble* normal,IssmDouble* xyz_list); 182 void NormalSection(IssmDouble* normal,IssmDouble* xyz_list); 183 void NormalTop(IssmDouble* normal,IssmDouble* xyz_list); 177 184 void SetClone(int* minranks); 178 185 void SetTemporaryElementType(int element_type_in){_error_("not implemented yet");}; 179 186 Seg* SpawnSeg(int index1,int index2); 180 187 IssmDouble StabilizationParameter(IssmDouble u, IssmDouble v, IssmDouble w, IssmDouble diameter, IssmDouble kappa){_error_("not implemented yet");}; 188 void UpdateConstraintsExtrudeFromBase(void); 189 void UpdateConstraintsExtrudeFromTop(void); 181 190 void ViscousHeating(IssmDouble* pphi,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vz_input){_error_("not implemented yet");}; 182 183 void UpdateConstraintsExtrudeFromBase(void);184 void UpdateConstraintsExtrudeFromTop(void);185 191 /*}}}*/ 186 192 -
issm/trunk/src/c/classes/Elements/TriaRef.cpp
r18301 r19105 21 21 #define NUMNODESP2 6 22 22 #define NUMNODESP2b 7 23 #define NUMNODESMAX 7 23 24 24 25 /*Object constructors and destructor*/ … … 31 32 32 33 /*Reference Element numerics*/ 33 void TriaRef::GetSegmentBFlux(IssmDouble* B,Gauss* gauss, int index1,int index2,int finiteelement){/*{{{*/ 34 /*Compute B matrix. B=[phi1 phi2 -phi3 -phi4] 34 void TriaRef::GetInputDerivativeValue(IssmDouble* p, IssmDouble* plist,IssmDouble* xyz_list, Gauss* gauss,int finiteelement){/*{{{*/ 35 /*From node values of parameter p (plist[0],plist[1],plist[2]), return parameter derivative value at gaussian 36 * point specified by gauss_basis: 37 * dp/dx=plist[0]*dh1/dx+plist[1]*dh2/dx+plist[2]*dh3/dx 38 * dp/dx=plist[0]*dh1/dx+plist[1]*dh2/dx+plist[2]*dh3/dx 35 39 * 36 * and phi1=phi3 phi2=phi440 * p is a vector already allocated. 37 41 * 38 * We assume B has been allocated already, of size: 1x4 42 * WARNING: For a significant gain in performance, it is better to use 43 * static memory allocation instead of dynamic. 39 44 */ 45 46 /*Allocate derivatives of basis functions*/ 47 IssmDouble dbasis[2*NUMNODESMAX]; 40 48 41 49 /*Fetch number of nodes for this finite element*/ 42 50 int numnodes = this->NumberofNodes(finiteelement); 43 44 /*Get nodal functions*/ 45 IssmDouble* basis=xNew<IssmDouble>(numnodes); 46 GetNodalFunctions(basis,gauss,finiteelement); 47 48 /*Build B for this segment*/ 49 B[0] = +basis[index1]; 50 B[1] = +basis[index2]; 51 B[2] = -basis[index1]; 52 B[3] = -basis[index2]; 53 54 /*Clean-up*/ 55 xDelete<IssmDouble>(basis); 56 } 57 /*}}}*/ 58 void TriaRef::GetSegmentBprimeFlux(IssmDouble* Bprime,Gauss* gauss, int index1,int index2,int finiteelement){/*{{{*/ 59 /*Compute Bprime matrix. Bprime=[phi1 phi2 phi3 phi4] 60 * 61 * and phi1=phi3 phi2=phi4 62 * 63 * We assume Bprime has been allocated already, of size: 1x4 64 */ 51 _assert_(numnodes<=NUMNODESMAX); 52 53 /*Get basis functions derivatives at this point*/ 54 GetNodalFunctionsDerivatives(&dbasis[0],xyz_list,gauss,finiteelement); 55 56 /*Calculate parameter for this Gauss point*/ 57 IssmDouble dpx=0.; 58 IssmDouble dpy=0.; 59 for(int i=0;i<numnodes;i++) dpx += dbasis[0*numnodes+i]*plist[i]; 60 for(int i=0;i<numnodes;i++) dpy += dbasis[1*numnodes+i]*plist[i]; 61 62 /*Assign values*/ 63 p[0]=dpx; 64 p[1]=dpy; 65 66 } 67 /*}}}*/ 68 void TriaRef::GetInputValue(IssmDouble* p, IssmDouble* plist, Gauss* gauss,int finiteelement){/*{{{*/ 69 /* WARNING: For a significant gain in performance, it is better to use 70 * static memory allocation instead of dynamic.*/ 71 72 /*Allocate basis functions*/ 73 IssmDouble basis[NUMNODESMAX]; 65 74 66 75 /*Fetch number of nodes for this finite element*/ 67 76 int numnodes = this->NumberofNodes(finiteelement); 68 69 /*Get nodal functions*/ 70 IssmDouble* basis=xNew<IssmDouble>(numnodes); 71 GetNodalFunctions(basis,gauss,finiteelement); 72 73 /*Build B'*/ 74 Bprime[0] = basis[index1]; 75 Bprime[1] = basis[index2]; 76 Bprime[2] = basis[index1]; 77 Bprime[3] = basis[index2]; 78 79 /*Clean-up*/ 80 xDelete<IssmDouble>(basis); 77 _assert_(numnodes<=NUMNODESMAX); 78 79 /*Get basis functions at this point*/ 80 GetNodalFunctions(&basis[0],gauss,finiteelement); 81 82 /*Calculate parameter for this Gauss point*/ 83 IssmDouble value =0.; 84 for(int i=0;i<numnodes;i++) value += basis[i]*plist[i]; 85 86 /*Assign output pointer*/ 87 *p = value; 81 88 } 82 89 /*}}}*/ … … 98 105 } 99 106 /*}}}*/ 100 void TriaRef::GetSegmentJacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss){/*{{{*/101 /*The Jacobian determinant is constant over the element, discard the gaussian points.102 * J is assumed to have been allocated*/103 104 IssmDouble x1 = xyz_list[3*0+0];105 IssmDouble y1 = xyz_list[3*0+1];106 IssmDouble x2 = xyz_list[3*1+0];107 IssmDouble y2 = xyz_list[3*1+1];108 109 *Jdet = .5*sqrt(pow(x2-x1,2) + pow(y2-y1,2));110 if(*Jdet<0) _error_("negative jacobian determinant!");111 112 }113 /*}}}*/114 107 void TriaRef::GetJacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 115 108 /*The Jacobian determinant is constant over the element, discard the gaussian points. … … 146 139 /*Cast gauss to GaussTria*/ 147 140 _assert_(gauss_in->Enum()==GaussTriaEnum); 148 GaussTria* gauss = dynamic_cast<GaussTria*>(gauss_in);141 GaussTria* gauss = xDynamicCast<GaussTria*>(gauss_in); 149 142 150 143 switch(finiteelement){ … … 194 187 } 195 188 /*}}}*/ 196 void TriaRef::GetSegmentNodalFunctions(IssmDouble* basis,Gauss* gauss,int index1,int index2,int finiteelement){/*{{{*/197 /*This routine returns the values of the nodal functions at the gaussian point.*/198 199 _assert_(index1>=0 && index1<3);200 _assert_(index2>=0 && index2<3);201 202 /*Fetch number of nodes for this finite element*/203 int numnodes = this->NumberofNodes(finiteelement);204 205 /*Get nodal functions*/206 IssmDouble* triabasis=xNew<IssmDouble>(numnodes);207 GetNodalFunctions(triabasis,gauss,finiteelement);208 209 switch(finiteelement){210 case P1Enum: case P1DGEnum:211 basis[0]=triabasis[index1];212 basis[1]=triabasis[index2];213 xDelete<IssmDouble>(triabasis);214 return;215 case P1bubbleEnum: case P1bubblecondensedEnum:216 basis[0]=triabasis[index1];217 basis[1]=triabasis[index2];218 xDelete<IssmDouble>(triabasis);219 return;220 case P2Enum:221 _assert_(index2<index1);222 basis[0]=triabasis[index1];223 basis[1]=triabasis[index2];224 basis[2]=triabasis[3+index2-1];225 xDelete<IssmDouble>(triabasis);226 return;227 default:228 _error_("Element type "<<EnumToStringx(finiteelement)<<" not supported yet");229 }230 231 /*Clean up*/232 xDelete<IssmDouble>(triabasis);233 }234 /*}}}*/235 189 void TriaRef::GetNodalFunctionsDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list, Gauss* gauss,int finiteelement){/*{{{*/ 236 190 … … 271 225 /*Cast gauss to GaussTria*/ 272 226 _assert_(gauss_in->Enum()==GaussTriaEnum); 273 GaussTria* gauss = dynamic_cast<GaussTria*>(gauss_in);227 GaussTria* gauss = xDynamicCast<GaussTria*>(gauss_in); 274 228 275 229 switch(finiteelement){ … … 353 307 } 354 308 /*}}}*/ 355 void TriaRef::GetInputDerivativeValue(IssmDouble* p, IssmDouble* plist,IssmDouble* xyz_list, Gauss* gauss,int finiteelement){/*{{{*/ 356 357 /*From node values of parameter p (plist[0],plist[1],plist[2]), return parameter derivative value at gaussian 358 * point specified by gauss_basis: 359 * dp/dx=plist[0]*dh1/dx+plist[1]*dh2/dx+plist[2]*dh3/dx 360 * dp/dx=plist[0]*dh1/dx+plist[1]*dh2/dx+plist[2]*dh3/dx 309 void TriaRef::GetSegmentBFlux(IssmDouble* B,Gauss* gauss, int index1,int index2,int finiteelement){/*{{{*/ 310 /*Compute B matrix. B=[phi1 phi2 -phi3 -phi4] 361 311 * 362 * p is a vector already allocated. 312 * and phi1=phi3 phi2=phi4 313 * 314 * We assume B has been allocated already, of size: 1x4 363 315 */ 364 365 /*Output*/366 IssmDouble dpx=0.;367 IssmDouble dpy=0.;368 316 369 317 /*Fetch number of nodes for this finite element*/ 370 318 int numnodes = this->NumberofNodes(finiteelement); 371 319 372 /*Get nodal functions derivatives*/ 373 IssmDouble* dbasis=xNew<IssmDouble>(2*numnodes); 374 GetNodalFunctionsDerivatives(dbasis,xyz_list,gauss,finiteelement); 375 376 /*Calculate parameter for this Gauss point*/ 377 for(int i=0;i<numnodes;i++) dpx += dbasis[0*numnodes+i]*plist[i]; 378 for(int i=0;i<numnodes;i++) dpy += dbasis[1*numnodes+i]*plist[i]; 379 380 /*Assign values*/ 381 xDelete<IssmDouble>(dbasis); 382 p[0]=dpx; 383 p[1]=dpy; 384 385 } 386 /*}}}*/ 387 void TriaRef::GetInputValue(IssmDouble* p, IssmDouble* plist, Gauss* gauss,int finiteelement){/*{{{*/ 388 389 /*Output*/ 390 IssmDouble value =0.; 320 /*Get nodal functions*/ 321 IssmDouble* basis=xNew<IssmDouble>(numnodes); 322 GetNodalFunctions(basis,gauss,finiteelement); 323 324 /*Build B for this segment*/ 325 B[0] = +basis[index1]; 326 B[1] = +basis[index2]; 327 B[2] = -basis[index1]; 328 B[3] = -basis[index2]; 329 330 /*Clean-up*/ 331 xDelete<IssmDouble>(basis); 332 } 333 /*}}}*/ 334 void TriaRef::GetSegmentBprimeFlux(IssmDouble* Bprime,Gauss* gauss, int index1,int index2,int finiteelement){/*{{{*/ 335 /*Compute Bprime matrix. Bprime=[phi1 phi2 phi3 phi4] 336 * 337 * and phi1=phi3 phi2=phi4 338 * 339 * We assume Bprime has been allocated already, of size: 1x4 340 */ 391 341 392 342 /*Fetch number of nodes for this finite element*/ … … 395 345 /*Get nodal functions*/ 396 346 IssmDouble* basis=xNew<IssmDouble>(numnodes); 397 GetNodalFunctions(basis, gauss,finiteelement); 398 399 /*Calculate parameter for this Gauss point*/ 400 for(int i=0;i<numnodes;i++) value += basis[i]*plist[i]; 401 402 /*Assign output pointer*/ 347 GetNodalFunctions(basis,gauss,finiteelement); 348 349 /*Build B'*/ 350 Bprime[0] = basis[index1]; 351 Bprime[1] = basis[index2]; 352 Bprime[2] = basis[index1]; 353 Bprime[3] = basis[index2]; 354 355 /*Clean-up*/ 403 356 xDelete<IssmDouble>(basis); 404 *p = value; 405 } 406 /*}}}*/ 407 int TriaRef::NumberofNodes(int finiteelement){/*{{{*/ 357 } 358 /*}}}*/ 359 void TriaRef::GetSegmentJacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 360 /*The Jacobian determinant is constant over the element, discard the gaussian points. 361 * J is assumed to have been allocated*/ 362 363 IssmDouble x1 = xyz_list[3*0+0]; 364 IssmDouble y1 = xyz_list[3*0+1]; 365 IssmDouble x2 = xyz_list[3*1+0]; 366 IssmDouble y2 = xyz_list[3*1+1]; 367 368 *Jdet = .5*sqrt(pow(x2-x1,2) + pow(y2-y1,2)); 369 if(*Jdet<0) _error_("negative jacobian determinant!"); 370 371 } 372 /*}}}*/ 373 void TriaRef::GetSegmentNodalFunctions(IssmDouble* basis,Gauss* gauss,int index1,int index2,int finiteelement){/*{{{*/ 374 /*This routine returns the values of the nodal functions at the gaussian point.*/ 375 376 _assert_(index1>=0 && index1<3); 377 _assert_(index2>=0 && index2<3); 378 379 /*Fetch number of nodes for this finite element*/ 380 int numnodes = this->NumberofNodes(finiteelement); 381 382 /*Get nodal functions*/ 383 IssmDouble* triabasis=xNew<IssmDouble>(numnodes); 384 GetNodalFunctions(triabasis,gauss,finiteelement); 408 385 409 386 switch(finiteelement){ 410 case NoneEnum: return 0; 411 case P0Enum: return NUMNODESP0; 412 case P1Enum: return NUMNODESP1; 413 case P1DGEnum: return NUMNODESP1; 414 case P1bubbleEnum: return NUMNODESP1b; 415 case P1bubblecondensedEnum: return NUMNODESP1b; 416 case P2Enum: return NUMNODESP2; 417 case P2bubbleEnum: return NUMNODESP2b; 418 case P2bubblecondensedEnum: return NUMNODESP2b; 419 case P1P1Enum: return NUMNODESP1*2; 420 case P1P1GLSEnum: return NUMNODESP1*2; 421 case MINIcondensedEnum: return NUMNODESP1b+NUMNODESP1; 422 case MINIEnum: return NUMNODESP1b+NUMNODESP1; 423 case TaylorHoodEnum: return NUMNODESP2+NUMNODESP1; 424 case LATaylorHoodEnum: return NUMNODESP2; 425 case XTaylorHoodEnum: return NUMNODESP2+NUMNODESP1; 426 case CrouzeixRaviartEnum: return NUMNODESP2b+NUMNODESP1; 427 default: _error_("Element type "<<EnumToStringx(finiteelement)<<" not supported yet"); 428 } 429 430 return -1; 431 } 432 /*}}}*/ 433 int TriaRef::VelocityInterpolation(int fe_stokes){/*{{{*/ 434 435 switch(fe_stokes){ 436 case P1P1Enum: return P1Enum; 437 case P1P1GLSEnum: return P1Enum; 438 case MINIcondensedEnum: return P1bubbleEnum; 439 case MINIEnum: return P1bubbleEnum; 440 case TaylorHoodEnum: return P2Enum; 441 case LATaylorHoodEnum: return P2Enum; 442 case XTaylorHoodEnum: return P2Enum; 443 case CrouzeixRaviartEnum:return P2bubbleEnum; 444 default: _error_("Element type "<<EnumToStringx(fe_stokes)<<" not supported yet"); 445 } 446 447 return -1; 448 } 449 /*}}}*/ 450 int TriaRef::PressureInterpolation(int fe_stokes){/*{{{*/ 451 452 switch(fe_stokes){ 453 case P1P1Enum: return P1Enum; 454 case P1P1GLSEnum: return P1Enum; 455 case MINIcondensedEnum: return P1Enum; 456 case MINIEnum: return P1Enum; 457 case TaylorHoodEnum: return P1Enum; 458 case LATaylorHoodEnum: return NoneEnum; 459 case XTaylorHoodEnum: return P1Enum; 460 case CrouzeixRaviartEnum: return P1DGEnum; 461 default: _error_("Element type "<<EnumToStringx(fe_stokes)<<" not supported yet"); 462 } 463 464 return -1; 465 } 466 /*}}}*/ 467 int TriaRef::TensorInterpolation(int fe_stokes){/*{{{*/ 468 /*This routine returns the values of the nodal functions at the gaussian point.*/ 469 470 switch(fe_stokes){ 471 case XTaylorHoodEnum: return P1DGEnum; 472 default: _error_("Element type "<<EnumToStringx(fe_stokes)<<" not supported yet"); 473 } 387 case P1Enum: case P1DGEnum: 388 basis[0]=triabasis[index1]; 389 basis[1]=triabasis[index2]; 390 xDelete<IssmDouble>(triabasis); 391 return; 392 case P1bubbleEnum: case P1bubblecondensedEnum: 393 basis[0]=triabasis[index1]; 394 basis[1]=triabasis[index2]; 395 xDelete<IssmDouble>(triabasis); 396 return; 397 case P2Enum: 398 _assert_(index2<index1); 399 basis[0]=triabasis[index1]; 400 basis[1]=triabasis[index2]; 401 basis[2]=triabasis[3+index2-1]; 402 xDelete<IssmDouble>(triabasis); 403 return; 404 default: 405 _error_("Element type "<<EnumToStringx(finiteelement)<<" not supported yet"); 406 } 407 408 /*Clean up*/ 409 xDelete<IssmDouble>(triabasis); 474 410 } 475 411 /*}}}*/ … … 533 469 } 534 470 /*}}}*/ 471 int TriaRef::NumberofNodes(int finiteelement){/*{{{*/ 472 473 switch(finiteelement){ 474 case NoneEnum: return 0; 475 case P0Enum: return NUMNODESP0; 476 case P1Enum: return NUMNODESP1; 477 case P1DGEnum: return NUMNODESP1; 478 case P1bubbleEnum: return NUMNODESP1b; 479 case P1bubblecondensedEnum: return NUMNODESP1b; 480 case P2Enum: return NUMNODESP2; 481 case P2bubbleEnum: return NUMNODESP2b; 482 case P2bubblecondensedEnum: return NUMNODESP2b; 483 case P1P1Enum: return NUMNODESP1*2; 484 case P1P1GLSEnum: return NUMNODESP1*2; 485 case MINIcondensedEnum: return NUMNODESP1b+NUMNODESP1; 486 case MINIEnum: return NUMNODESP1b+NUMNODESP1; 487 case TaylorHoodEnum: return NUMNODESP2+NUMNODESP1; 488 case LATaylorHoodEnum: return NUMNODESP2; 489 case XTaylorHoodEnum: return NUMNODESP2+NUMNODESP1; 490 case CrouzeixRaviartEnum: return NUMNODESP2b+NUMNODESP1; 491 case LACrouzeixRaviartEnum: return NUMNODESP2b; 492 default: _error_("Element type "<<EnumToStringx(finiteelement)<<" not supported yet"); 493 } 494 495 return -1; 496 } 497 /*}}}*/ 498 int TriaRef::PressureInterpolation(int fe_stokes){/*{{{*/ 499 500 switch(fe_stokes){ 501 case P1P1Enum: return P1Enum; 502 case P1P1GLSEnum: return P1Enum; 503 case MINIcondensedEnum: return P1Enum; 504 case MINIEnum: return P1Enum; 505 case TaylorHoodEnum: return P1Enum; 506 case LATaylorHoodEnum: return NoneEnum; 507 case XTaylorHoodEnum: return P1Enum; 508 case CrouzeixRaviartEnum: return P1DGEnum; 509 case LACrouzeixRaviartEnum: return NoneEnum; 510 default: _error_("Element type "<<EnumToStringx(fe_stokes)<<" not supported yet"); 511 } 512 513 return -1; 514 } 515 /*}}}*/ 516 int TriaRef::TensorInterpolation(int fe_stokes){/*{{{*/ 517 /*This routine returns the values of the nodal functions at the gaussian point.*/ 518 519 switch(fe_stokes){ 520 case XTaylorHoodEnum: return P1DGEnum; 521 default: _error_("Element type "<<EnumToStringx(fe_stokes)<<" not supported yet"); 522 } 523 } 524 /*}}}*/ 525 int TriaRef::VelocityInterpolation(int fe_stokes){/*{{{*/ 526 527 switch(fe_stokes){ 528 case P1P1Enum: return P1Enum; 529 case P1P1GLSEnum: return P1Enum; 530 case MINIcondensedEnum: return P1bubbleEnum; 531 case MINIEnum: return P1bubbleEnum; 532 case TaylorHoodEnum: return P2Enum; 533 case LATaylorHoodEnum: return P2Enum; 534 case XTaylorHoodEnum: return P2Enum; 535 case CrouzeixRaviartEnum: return P2bubbleEnum; 536 case LACrouzeixRaviartEnum: return P2bubbleEnum; 537 default: _error_("Element type "<<EnumToStringx(fe_stokes)<<" not supported yet"); 538 } 539 540 return -1; 541 } 542 /*}}}*/ -
issm/trunk/src/c/classes/Elements/TriaRef.h
r18301 r19105 16 16 17 17 /*Numerics*/ 18 void GetInputDerivativeValue(IssmDouble* pp, IssmDouble* plist,IssmDouble* xyz_list, Gauss* gauss,int finiteelement); 19 void GetInputValue(IssmDouble* pp, IssmDouble* plist, Gauss* gauss,int finiteelement); 18 20 void GetJacobian(IssmDouble* J, IssmDouble* xyz_list,Gauss* gauss); 19 void GetSegmentJacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss);20 21 void GetJacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss); 21 22 void GetJacobianInvert(IssmDouble* Jinv, IssmDouble* xyz_list,Gauss* gauss); 22 23 void GetNodalFunctions(IssmDouble* basis,Gauss* gauss,int finiteelement); 23 void GetSegmentNodalFunctions(IssmDouble* basis,Gauss* gauss, int index1,int index2,int finiteelement); 24 void GetNodalFunctionsDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list, Gauss* gauss,int finiteelement); 25 void GetNodalFunctionsDerivativesReference(IssmDouble* dbasis,Gauss* gauss,int finiteelement); 24 26 void GetSegmentBFlux(IssmDouble* B,Gauss* gauss, int index1,int index2,int finiteelement); 25 27 void GetSegmentBprimeFlux(IssmDouble* Bprime,Gauss* gauss, int index1,int index2,int finiteelement); 26 void GetNodalFunctionsDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list, Gauss* gauss,int finiteelement); 27 void GetNodalFunctionsDerivativesReference(IssmDouble* dbasis,Gauss* gauss,int finiteelement); 28 void GetInputValue(IssmDouble* pp, IssmDouble* plist, Gauss* gauss,int finiteelement); 29 void GetInputDerivativeValue(IssmDouble* pp, IssmDouble* plist,IssmDouble* xyz_list, Gauss* gauss,int finiteelement); 30 28 void GetSegmentJacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss); 29 void GetSegmentNodalFunctions(IssmDouble* basis,Gauss* gauss, int index1,int index2,int finiteelement); 31 30 void NodeOnEdgeIndices(int* pnumindices,int** pindices,int index,int finiteelement); 32 31 int NumberofNodes(int finiteelement); 33 int VelocityInterpolation(int fe_stokes);34 32 int PressureInterpolation(int fe_stokes); 35 33 int TensorInterpolation(int fe_stokes); 34 int VelocityInterpolation(int fe_stokes); 36 35 }; 37 36 #endif -
issm/trunk/src/c/classes/ExternalResults/ExternalResult.h
r16560 r19105 28 28 virtual int GetStep(void)=0; 29 29 virtual double GetValue(void)=0; 30 virtual int GetResultEnum(void)=0; 30 31 }; 31 32 #endif -
issm/trunk/src/c/classes/ExternalResults/GenericExternalResult.h
r17806 r19105 160 160 return name; 161 161 } /*}}}*/ 162 int GetResultEnum(void){ /*{{{*/ 163 return StringToEnumx(this->result_name,false); 164 } /*}}}*/ 162 165 int GetStep(void){ /*{{{*/ 163 166 return this->step; 164 167 } /*}}}*/ 165 IssmPDouble GetValue(void){ /*{{{*/168 double GetValue(void){ /*{{{*/ 166 169 /*Only supported by IssmPDouble result, error out by default*/ 167 170 _error_("not supported for this type of result"); 168 return 0.; 171 } /*}}}*/ 172 double* GetValues(void){ /*{{{*/ 173 /*Only supported by IssmPDouble* result, error out by default*/ 174 _error_("not supported for this type of result"); 169 175 } /*}}}*/ 170 176 }; … … 367 373 return DoubleMatExternalResultEnum; 368 374 } /*}}}*/ 375 template <> inline double* GenericExternalResult<IssmPDouble*>::GetValues(void){ /*{{{*/ 376 return value; 377 } /*}}}*/ 369 378 370 379 /*Specific instantiations for IssmDouble*: */ -
issm/trunk/src/c/classes/ExternalResults/Results.cpp
r18301 r19105 41 41 42 42 for(int i=0;i<this->Size();i++){ 43 ExternalResult* result= dynamic_cast<ExternalResult*>(this->GetObjectByOffset(i));43 ExternalResult* result=xDynamicCast<ExternalResult*>(this->GetObjectByOffset(i)); 44 44 result->WriteData(fid,io_gather); 45 45 } … … 57 57 58 58 for(int i=0;i<this->Size();i++){ 59 ExternalResult* result= dynamic_cast<ExternalResult*>(this->GetObjectByOffset(i));59 ExternalResult* result=xDynamicCast<ExternalResult*>(this->GetObjectByOffset(i)); 60 60 61 61 if(result->GetStep()==in_result->GetStep()){ … … 81 81 82 82 for(int i=0;i<this->Size();i++){ 83 ExternalResult* result= dynamic_cast<ExternalResult*>(this->GetObjectByOffset(i));83 ExternalResult* result=xDynamicCast<ExternalResult*>(this->GetObjectByOffset(i)); 84 84 85 85 if(result->GetStep()==result_step){ … … 94 94 } 95 95 /*}}}*/ 96 ExternalResult* Results::FindResult(int result_enum){/*{{{*/ 97 98 for(int i=0;i<this->Size();i++){ 99 ExternalResult* result=xDynamicCast<ExternalResult*>(this->GetObjectByOffset(i)); 100 101 if(result->GetResultEnum()==result_enum){ 102 return result; 103 } 104 } 105 return NULL; 106 } 107 /*}}}*/ -
issm/trunk/src/c/classes/ExternalResults/Results.h
r16560 r19105 22 22 /*Mehthos*/ 23 23 int AddResult(ExternalResult* result); 24 ExternalResult* FindResult(int result_enum); 24 25 int DeleteResult(int result_enum,int result_step); 25 26 void Write(Parameters* parameters); -
issm/trunk/src/c/classes/FemModel.cpp
r18301 r19105 43 43 44 44 /*Object constructors and destructor*/ 45 FemModel::FemModel(int argc,char** argv,ISSM_MPI_Comm incomm ){/*{{{*/45 FemModel::FemModel(int argc,char** argv,ISSM_MPI_Comm incomm,bool trace){/*{{{*/ 46 46 47 47 /*configuration: */ 48 int* analyses=NULL;49 int numanalyses;50 48 int solution_type; 51 49 int ierr; … … 75 73 ProcessArguments(&solution_type,&binfilename,&outbinfilename,&petscfilename,&lockfilename,&rootpath,argc,argv); 76 74 77 /*out of solution_type, figure out types of analyses needed in the femmodel: */78 AnalysisConfiguration(&analyses,&numanalyses,solution_type);79 80 75 /*Create femmodel from input files: */ 81 76 profiler->Tag(StartInit); 82 this->InitFromFiles(rootpath,binfilename,outbinfilename,petscfilename,lockfilename,solution_type, analyses,numanalyses);77 this->InitFromFiles(rootpath,binfilename,outbinfilename,petscfilename,lockfilename,solution_type,trace,NULL); 83 78 profiler->Tag(FinishInit); 84 79 85 80 /*Free resources */ 86 xDelete<int>(analyses);87 81 xDelete<char>(lockfilename); 88 82 xDelete<char>(binfilename); … … 93 87 } 94 88 /*}}}*/ 95 FemModel::FemModel(char* rootpath, char* inputfilename, char* outputfilename, char* toolkitsfilename, char* lockfilename, const int in_solution_type,const int* analyses,const int nummodels){/*{{{*/ 96 97 /*Call InitFromFiles. This constructor is just a wrapper: */ 98 this->InitFromFiles(rootpath, inputfilename, outputfilename, toolkitsfilename, lockfilename, in_solution_type,analyses,nummodels); 89 FemModel::FemModel(char* rootpath, char* inputfilename, char* outputfilename, char* toolkitsfilename, char* lockfilename, ISSM_MPI_Comm incomm, int solution_type,IssmPDouble* X){ /*{{{*/ 90 91 bool traceon=true; 92 this->profiler=NULL; /*avoid leak, as we are not using the profiler ever in ad control run. */ 93 94 /*Store the communicator, but do not set it as a global variable, as this has already 95 * been done by the FemModel that called this copy constructor: */ 96 this->comm=incomm; 97 this->SetStaticComm(); 98 99 /*Create femmodel from input files, with trace activated: */ 100 this->InitFromFiles(rootpath,inputfilename,outputfilename,toolkitsfilename,lockfilename,solution_type,traceon,X); 99 101 100 102 } … … 111 113 112 114 /*Delete all the datasets: */ 113 xDelete<int>(analysis_type_list);114 xDelete<char>(outbinfilename);115 xDelete<char>(lockfilename);116 delete elements;117 delete nodes;118 delete vertices;119 delete constraints;120 delete loads;121 delete materials;122 delete parameters;123 delete results;115 if(analysis_type_list)xDelete<int>(analysis_type_list); 116 if(outbinfilename)xDelete<char>(outbinfilename); 117 if(lockfilename)xDelete<char>(lockfilename); 118 if(elements)delete elements; 119 if(nodes)delete nodes; 120 if(vertices)delete vertices; 121 if(constraints)delete constraints; 122 if(loads)delete loads; 123 if(materials)delete materials; 124 if(parameters)delete parameters; 125 if(results)delete results; 124 126 125 127 /*Now delete: */ 126 delete profiler; 127 128 if(profiler)delete profiler; 128 129 } 129 130 /*}}}*/ … … 141 142 } 142 143 /*}}}*/ 143 void FemModel::InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* toolkitsfilename, char* lockfilename, const int in_solution_type, const int* analyses,const int nummodels){/*{{{*/144 void FemModel::InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* toolkitsfilename, char* lockfilename, const int in_solution_type,bool trace,IssmPDouble* X){/*{{{*/ 144 145 145 146 /*intermediary*/ … … 154 155 my_rank=IssmComm::GetRank(); 155 156 156 /*Open input file on cpu 0: */157 if(my_rank==0) IOMODEL = pfopen0(inputfilename ,"rb");158 159 /*Open toolkits file: */160 toolkitsoptionsfid=pfopen(toolkitsfilename,"r");161 162 157 /*Initialize internal data: */ 163 this->nummodels = nummodels;164 158 this->solution_type = in_solution_type; 165 159 this->analysis_counter = nummodels-1; //point to last analysis_type carried out. 166 160 this->results = new Results(); //not initialized by CreateDataSets 167 168 /*Dynamically allocate whatever is a list of length nummodels: */ 169 analysis_type_list=xNew<int>(nummodels); 170 171 /*Initialize: */ 172 for(i=0;i<nummodels;i++)analysis_type_list[i]=analyses[i]; 161 /*Open input file on cpu 0 and create IoModel */ 162 if(my_rank==0) IOMODEL = pfopen0(inputfilename ,"rb"); 163 IoModel* iomodel = new IoModel(IOMODEL,trace,X); 164 165 /*Figure out what analyses are activated for this solution*/ 166 SolutionAnalysesList(&this->analysis_type_list,&this->nummodels,iomodel,this->solution_type); 167 168 /*Open toolkits file: */ 169 toolkitsoptionsfid=pfopen(toolkitsfilename,"r"); 173 170 174 171 /*create datasets for all analyses*/ 175 ModelProcessorx(&this->elements,&this->nodes,&this->vertices,&this->materials,&this->constraints,&this->loads,&this->parameters, IOMODEL,toolkitsoptionsfid,rootpath,this->solution_type,nummodels,analyses);172 ModelProcessorx(&this->elements,&this->nodes,&this->vertices,&this->materials,&this->constraints,&this->loads,&this->parameters,iomodel,toolkitsoptionsfid,rootpath,this->solution_type,this->nummodels,this->analysis_type_list); 176 173 177 174 /*do the post-processing of the datasets to get an FemModel that can actually run analyses: */ … … 201 198 pfclose(toolkitsoptionsfid,toolkitsfilename); 202 199 203 /*Open output file once for all and add output file name and filedescriptor to parameters*/200 /*Open output file once for all and add output file descriptor to parameters*/ 204 201 output_fid=pfopen(outputfilename,"wb"); 202 this->parameters->SetParam(output_fid,OutputFilePointerEnum); 203 204 /*Now save all of these file names into parameters, you never know when you might need them: */ 205 this->parameters->AddObject(new StringParam(ToolkitsFileNameEnum,toolkitsfilename)); 206 this->parameters->AddObject(new StringParam(RootPathEnum,rootpath)); 207 this->parameters->AddObject(new StringParam(InputFileNameEnum,inputfilename)); 205 208 this->parameters->AddObject(new StringParam(OutputFileNameEnum,outputfilename)); 206 this->parameters->SetParam(output_fid,OutputFilePointerEnum);207 208 /*Save lock file name for later: */209 209 this->parameters->AddObject(new StringParam(LockFileNameEnum,lockfilename)); 210 210 211 } 212 /*}}}*/ 211 /*Clean up*/ 212 delete iomodel; 213 }/*}}}*/ 213 214 void FemModel::CleanUp(void){/*{{{*/ 214 215 … … 238 239 _printf0_(" "<<setw(40)<<left<<"Core solution elapsed time:"<<profiler->DeltaTime(StartCore,FinishCore) << "\n"); 239 240 _printf0_("\n"); 240 _printf0_(" Total elapsed time: "241 _printf0_(" Total elapsed time: " 241 242 <<profiler->DeltaTimeModHour(Start,Finish)<<" hrs " 242 243 <<profiler->DeltaTimeModMin(Start,Finish)<<" min " … … 324 325 WrapperCorePointerFromSolutionEnum(&solutioncore,this->parameters,solution_type); 325 326 326 /*run solut oin core: */327 /*run solution core: */ 327 328 profiler->Tag(StartCore); 328 329 solutioncore(this); … … 412 413 } 413 414 /*}}}*/ 415 void FemModel::SolutionAnalysesList(int** panalyses,int* pnumanalyses,IoModel* iomodel,int solutiontype){/*{{{*/ 416 417 /*output: */ 418 int numanalyses = 0; 419 int* analyses=NULL; 420 421 /*Intermediaries*/ 422 const int MAXANALYSES = 30; 423 int analyses_temp[MAXANALYSES]; 424 425 /*Analyses lists*/ 426 switch(solutiontype){ 427 428 case StressbalanceSolutionEnum:{ 429 bool isSIA,isFS; 430 int fe_FS; 431 iomodel->Constant(&fe_FS,FlowequationFeFSEnum); 432 iomodel->Constant(&isSIA,FlowequationIsSIAEnum); 433 iomodel->Constant(&isFS,FlowequationIsFSEnum); 434 analyses_temp[numanalyses++]=StressbalanceAnalysisEnum; 435 analyses_temp[numanalyses++]=StressbalanceVerticalAnalysisEnum; 436 if(isSIA){ 437 analyses_temp[numanalyses++]=StressbalanceSIAAnalysisEnum; 438 } 439 analyses_temp[numanalyses++]=L2ProjectionBaseAnalysisEnum; 440 analyses_temp[numanalyses++]=ExtrudeFromBaseAnalysisEnum; 441 analyses_temp[numanalyses++]=DepthAverageAnalysisEnum; 442 if(fe_FS==LATaylorHoodEnum || fe_FS==LACrouzeixRaviartEnum){ 443 analyses_temp[numanalyses++]=UzawaPressureAnalysisEnum; 444 } 445 } 446 break; 447 448 case SteadystateSolutionEnum:{ 449 bool isSIA,isenthalpy; 450 iomodel->Constant(&isSIA,FlowequationIsSIAEnum); 451 iomodel->Constant(&isenthalpy,ThermalIsenthalpyEnum); 452 analyses_temp[numanalyses++]=StressbalanceAnalysisEnum; 453 analyses_temp[numanalyses++]=StressbalanceVerticalAnalysisEnum; 454 if(isSIA){ 455 analyses_temp[numanalyses++]=StressbalanceSIAAnalysisEnum; 456 } 457 if(isenthalpy){ 458 analyses_temp[numanalyses++]=EnthalpyAnalysisEnum; 459 } 460 else{ 461 analyses_temp[numanalyses++]=ThermalAnalysisEnum; 462 analyses_temp[numanalyses++]=MeltingAnalysisEnum; 463 } 464 analyses_temp[numanalyses++]=L2ProjectionBaseAnalysisEnum; 465 } 466 break; 467 468 case ThermalSolutionEnum:{ 469 bool isenthalpy; 470 iomodel->Constant(&isenthalpy,ThermalIsenthalpyEnum); 471 if(isenthalpy){ 472 analyses_temp[numanalyses++]=EnthalpyAnalysisEnum; 473 } 474 else{ 475 analyses_temp[numanalyses++]=ThermalAnalysisEnum; 476 analyses_temp[numanalyses++]=MeltingAnalysisEnum; 477 } 478 } 479 break; 480 481 case HydrologySolutionEnum: 482 analyses_temp[numanalyses++]=HydrologyShreveAnalysisEnum; 483 analyses_temp[numanalyses++]=HydrologyDCInefficientAnalysisEnum; 484 analyses_temp[numanalyses++]=HydrologyDCEfficientAnalysisEnum; 485 analyses_temp[numanalyses++]=L2ProjectionBaseAnalysisEnum; 486 analyses_temp[numanalyses++]=L2ProjectionEPLAnalysisEnum; 487 break; 488 489 case MasstransportSolutionEnum: 490 analyses_temp[numanalyses++]=MasstransportAnalysisEnum; 491 break; 492 493 case BalancethicknessSolutionEnum: 494 analyses_temp[numanalyses++]=BalancethicknessAnalysisEnum; 495 break; 496 497 case Balancethickness2SolutionEnum: 498 analyses_temp[numanalyses++]=L2ProjectionBaseAnalysisEnum; 499 analyses_temp[numanalyses++]=SmoothAnalysisEnum; 500 analyses_temp[numanalyses++]=Balancethickness2AnalysisEnum; 501 break; 502 503 case BalancethicknessSoftSolutionEnum: 504 analyses_temp[numanalyses++]=BalancethicknessAnalysisEnum; 505 break; 506 507 case BalancevelocitySolutionEnum: 508 analyses_temp[numanalyses++]=BalancevelocityAnalysisEnum; 509 analyses_temp[numanalyses++]=SmoothAnalysisEnum; 510 break; 511 512 case SurfaceSlopeSolutionEnum: 513 analyses_temp[numanalyses++]=L2ProjectionBaseAnalysisEnum; 514 break; 515 516 case BedSlopeSolutionEnum: 517 analyses_temp[numanalyses++]=L2ProjectionBaseAnalysisEnum; 518 break; 519 520 case GiaSolutionEnum: 521 analyses_temp[numanalyses++]=GiaAnalysisEnum; 522 break; 523 524 case DamageEvolutionSolutionEnum: 525 analyses_temp[numanalyses++]=DamageEvolutionAnalysisEnum; 526 break; 527 528 case TransientSolutionEnum:{ 529 bool isSIA,isFS,isthermal,isenthalpy,ismasstransport,isgroundingline,isstressbalance,islevelset,ishydrology,isdamage; 530 iomodel->Constant(&isSIA,FlowequationIsSIAEnum); 531 iomodel->Constant(&isFS,FlowequationIsFSEnum); 532 iomodel->Constant(&isthermal,TransientIsthermalEnum); 533 iomodel->Constant(&isenthalpy,ThermalIsenthalpyEnum); 534 iomodel->Constant(&islevelset,TransientIslevelsetEnum); 535 iomodel->Constant(&ismasstransport,TransientIsmasstransportEnum); 536 iomodel->Constant(&isstressbalance,TransientIsstressbalanceEnum); 537 iomodel->Constant(&isgroundingline,TransientIsgroundinglineEnum); 538 iomodel->Constant(&isdamage,TransientIsdamageevolutionEnum); 539 iomodel->Constant(&ishydrology,TransientIshydrologyEnum); 540 if(isstressbalance){ 541 int fe_FS; 542 iomodel->Constant(&fe_FS,FlowequationFeFSEnum); 543 analyses_temp[numanalyses++]=StressbalanceAnalysisEnum; 544 analyses_temp[numanalyses++]=StressbalanceVerticalAnalysisEnum; 545 if(isSIA){ 546 analyses_temp[numanalyses++]=StressbalanceSIAAnalysisEnum; 547 } 548 analyses_temp[numanalyses++]=DepthAverageAnalysisEnum; 549 if(fe_FS==LATaylorHoodEnum || fe_FS==LACrouzeixRaviartEnum){ 550 analyses_temp[numanalyses++]=UzawaPressureAnalysisEnum; 551 } 552 } 553 if(isthermal && iomodel->domaintype==Domain3DEnum){ 554 if(isenthalpy){ 555 analyses_temp[numanalyses++]=EnthalpyAnalysisEnum; 556 } 557 else{ 558 analyses_temp[numanalyses++]=ThermalAnalysisEnum; 559 analyses_temp[numanalyses++]=MeltingAnalysisEnum; 560 } 561 } 562 if(ismasstransport || isgroundingline){ 563 analyses_temp[numanalyses++]=MasstransportAnalysisEnum; 564 } 565 if(islevelset){ 566 analyses_temp[numanalyses++]=LevelsetAnalysisEnum; 567 analyses_temp[numanalyses++]=ExtrapolationAnalysisEnum; 568 analyses_temp[numanalyses++]=LsfReinitializationAnalysisEnum; 569 } 570 if(ishydrology){ 571 analyses_temp[numanalyses++]=HydrologyShreveAnalysisEnum; 572 analyses_temp[numanalyses++]=HydrologyDCInefficientAnalysisEnum; 573 analyses_temp[numanalyses++]=HydrologyDCEfficientAnalysisEnum; 574 analyses_temp[numanalyses++]=L2ProjectionEPLAnalysisEnum; 575 } 576 if(isdamage){ 577 analyses_temp[numanalyses++]=DamageEvolutionAnalysisEnum; 578 } 579 580 if(iomodel->domaintype==Domain2DverticalEnum || iomodel->domaintype==Domain3DEnum){ 581 analyses_temp[numanalyses++]=ExtrudeFromBaseAnalysisEnum; 582 analyses_temp[numanalyses++]=ExtrudeFromTopAnalysisEnum; 583 analyses_temp[numanalyses++]=FreeSurfaceBaseAnalysisEnum; 584 analyses_temp[numanalyses++]=FreeSurfaceTopAnalysisEnum; 585 } 586 analyses_temp[numanalyses++]=L2ProjectionBaseAnalysisEnum; 587 } 588 break; 589 590 default: 591 _error_("solution type: " << EnumToStringx(solutiontype) << " not supported yet!"); 592 break; 593 } 594 595 /*Copy analyses from temp to output*/ 596 _assert_(numanalyses<MAXANALYSES); 597 analyses=xNew<int>(numanalyses); 598 for(int i=0;i<numanalyses;i++) analyses[i]=analyses_temp[i]; 599 600 /*Assign output pointers:*/ 601 if(pnumanalyses) *pnumanalyses=numanalyses; 602 if(panalyses) *panalyses=analyses; 603 else xDelete<int>(analyses); 604 }/*}}}*/ 414 605 415 606 /*Modules:*/ … … 420 611 421 612 /*get vertex vectors for bed and thickness: */ 422 GetVectorFromInputsx(&surface ,this, SurfaceEnum,Vertex Enum);423 GetVectorFromInputsx(&bed ,this, BaseEnum, VertexEnum);613 GetVectorFromInputsx(&surface ,this, SurfaceEnum,VertexPIdEnum); 614 GetVectorFromInputsx(&bed ,this, BaseEnum, VertexPIdEnum); 424 615 425 616 /*Allocate vector*/ … … 477 668 } 478 669 /*}}}*/ 670 void FemModel::ElementOperationx(void (Element::*function)(void)){ /*{{{*/ 671 672 for(int i=0;i<elements->Size();i++){ 673 Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i)); 674 (element->*function)(); 675 } 676 677 } 678 /*}}}*/ 479 679 void FemModel::Responsex(IssmDouble* responses,const char* response_descriptor){/*{{{*/ 480 680 … … 489 689 490 690 case DivergenceEnum: this->Divergencex(responses); break; 691 case MaxDivergenceEnum: this->MaxDivergencex(responses); break; 692 case IceMassEnum: this->IceMassx(responses); break; 491 693 case IceVolumeEnum: this->IceVolumex(responses); break; 492 694 case IceVolumeAboveFloatationEnum: this->IceVolumeAboveFloatationx(responses); break; … … 515 717 case DragCoefficientAbsGradientEnum:DragCoefficientAbsGradientx(responses, elements,nodes, vertices, loads, materials, parameters); break; 516 718 case BalancethicknessMisfitEnum: BalancethicknessMisfitx(responses); break; 517 case Balancethickness2MisfitEnum: Balancethickness2Misfitx(responses); break;518 719 case TotalSmbEnum: this->TotalSmbx(responses); break; 519 720 case MaterialsRheologyBbarEnum: this->ElementResponsex(responses,MaterialsRheologyBbarEnum); break; … … 559 760 } 560 761 else{ 561 switch(output_enum){ 562 563 /*Scalar output*/ 564 case DivergenceEnum: this->Divergencex(&double_result); break; 565 case IceVolumeEnum: this->IceVolumex(&double_result); break; 566 case IceVolumeAboveFloatationEnum: this->IceVolumeAboveFloatationx(&double_result); break; 567 case MinVelEnum: this->MinVelx(&double_result); break; 568 case MaxVelEnum: this->MaxVelx(&double_result); break; 569 case MinVxEnum: this->MinVxx(&double_result); break; 570 case MaxVxEnum: this->MaxVxx(&double_result); break; 571 case MaxAbsVxEnum: this->MaxAbsVxx(&double_result); break; 572 case MinVyEnum: this->MinVyx(&double_result); break; 573 case MaxVyEnum: this->MaxVyx(&double_result); break; 574 case MaxAbsVyEnum: this->MaxAbsVyx(&double_result); break; 575 case MinVzEnum: this->MinVzx(&double_result); break; 576 case MaxVzEnum: this->MaxVzx(&double_result); break; 577 case MaxAbsVzEnum: this->MaxAbsVzx(&double_result); break; 578 case MassFluxEnum: this->MassFluxx(&double_result); break; 579 case TotalSmbEnum: this->TotalSmbx(&double_result); break; 762 /*last chance for the output definition, if the enum is one of Outputdefinition[1-10]Enum:*/ 763 if(output_enum>=Outputdefinition1Enum && output_enum <=Outputdefinition10Enum){ 764 double_result = OutputDefinitionsResponsex(this,output_enum); 765 if(save_results){ 766 results->AddResult(new GenericExternalResult<IssmPDouble>(results->Size()+1,output_string,reCast<IssmPDouble>(double_result),step,time)); 767 continue; 768 } 769 } 770 else{ 771 switch(output_enum){ 772 773 /*Scalar output*/ 774 case DivergenceEnum: this->Divergencex(&double_result); break; 775 case MaxDivergenceEnum: this->MaxDivergencex(&double_result); break; 776 case IceMassEnum: this->IceMassx(&double_result); break; 777 case IceVolumeEnum: this->IceVolumex(&double_result); break; 778 case IceVolumeAboveFloatationEnum: this->IceVolumeAboveFloatationx(&double_result); break; 779 case MinVelEnum: this->MinVelx(&double_result); break; 780 case MaxVelEnum: this->MaxVelx(&double_result); break; 781 case MinVxEnum: this->MinVxx(&double_result); break; 782 case MaxVxEnum: this->MaxVxx(&double_result); break; 783 case MaxAbsVxEnum: this->MaxAbsVxx(&double_result); break; 784 case MinVyEnum: this->MinVyx(&double_result); break; 785 case MaxVyEnum: this->MaxVyx(&double_result); break; 786 case MaxAbsVyEnum: this->MaxAbsVyx(&double_result); break; 787 case MinVzEnum: this->MinVzx(&double_result); break; 788 case MaxVzEnum: this->MaxVzx(&double_result); break; 789 case MaxAbsVzEnum: this->MaxAbsVzx(&double_result); break; 790 case MassFluxEnum: this->MassFluxx(&double_result); break; 791 case TotalSmbEnum: this->TotalSmbx(&double_result); break; 580 792 581 793 /*Scalar control output*/ … … 590 802 case ThicknessAcrossGradientEnum: ThicknessAcrossGradientx(&double_result,elements,nodes,vertices,loads,materials,parameters); break; 591 803 case RheologyBbarAbsGradientEnum: RheologyBbarAbsGradientx(&double_result,elements,nodes,vertices,loads,materials,parameters); break; 804 case RheologyBAbsGradientEnum: RheologyBAbsGradientx(&double_result,elements,nodes,vertices,loads,materials,parameters); break; 592 805 case DragCoefficientAbsGradientEnum:DragCoefficientAbsGradientx(&double_result,elements,nodes,vertices,loads,materials,parameters); break; 593 806 case BalancethicknessMisfitEnum: BalancethicknessMisfitx(&double_result); break; 594 case Balancethickness2MisfitEnum: Balancethickness2Misfitx(&double_result); break; 595 596 /*Vector */ 597 default: 598 599 /*Vector layout*/ 600 int interpolation,nodesperelement,size; 601 int rank_interpolation=-1,rank_nodesperelement=-1; 602 603 /*Get interpolation (and compute input if necessary)*/ 604 for(int j=0;j<elements->Size();j++){ 605 Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(j)); 606 element->ResultInterpolation(&rank_interpolation,&rank_nodesperelement,output_enum); 607 } 608 609 /*Broadcast for cpus that do not have any elements*/ 610 ISSM_MPI_Reduce(&rank_interpolation,&interpolation,1,ISSM_MPI_INT,ISSM_MPI_MAX,0,IssmComm::GetComm()); 611 ISSM_MPI_Reduce(&rank_nodesperelement,&nodesperelement,1,ISSM_MPI_INT,ISSM_MPI_MAX,0,IssmComm::GetComm()); 612 ISSM_MPI_Bcast(&interpolation,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 613 ISSM_MPI_Bcast(&nodesperelement,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 614 615 if(results_on_nodes){ 616 617 /*Allocate matrices*/ 618 int nbe = this->elements->NumberOfElements(); 619 IssmDouble* values = xNewZeroInit<IssmDouble>(nbe*nodesperelement); 620 IssmDouble* allvalues = xNew<IssmDouble>(nbe*nodesperelement); 621 622 /*Fill-in matrix*/ 807 case SurfaceAbsMisfitEnum: SurfaceAbsMisfitx(&double_result); break; 808 809 /*Vector */ 810 default: 811 812 /*Vector layout*/ 813 int interpolation,nodesperelement,size; 814 int rank_interpolation=-1,rank_nodesperelement=-1; 815 816 /*Get interpolation (and compute input if necessary)*/ 623 817 for(int j=0;j<elements->Size();j++){ 624 Element* element= dynamic_cast<Element*>(this->elements->GetObjectByOffset(j));625 element->Result ToPatch(values,nodesperelement,output_enum);818 Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(j)); 819 element->ResultInterpolation(&rank_interpolation,&rank_nodesperelement,output_enum); 626 820 } 627 821 628 /*Gather from all cpus*/ 629 ISSM_MPI_Allreduce((void*)values,(void*)allvalues,nbe*nodesperelement,ISSM_MPI_PDOUBLE,ISSM_MPI_SUM,IssmComm::GetComm()); 630 xDelete<IssmDouble>(values); 631 632 if(save_results)results->AddResult(new GenericExternalResult<IssmDouble*>(results->Size()+1,output_enum,allvalues,nbe,nodesperelement,step,time)); 633 xDelete<IssmDouble>(allvalues); 634 635 } 636 else{ 637 638 /*Allocate vector depending on interpolation*/ 639 switch(interpolation){ 640 case P0Enum: size = this->elements->NumberOfElements(); break; 641 case P1Enum: size = this->vertices->NumberOfVertices(); break; 642 default: _error_("Interpolation "<<EnumToStringx(interpolation)<<" not supported yet"); 822 /*Broadcast for cpus that do not have any elements*/ 823 ISSM_MPI_Reduce(&rank_interpolation,&interpolation,1,ISSM_MPI_INT,ISSM_MPI_MAX,0,IssmComm::GetComm()); 824 ISSM_MPI_Reduce(&rank_nodesperelement,&nodesperelement,1,ISSM_MPI_INT,ISSM_MPI_MAX,0,IssmComm::GetComm()); 825 ISSM_MPI_Bcast(&interpolation,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 826 ISSM_MPI_Bcast(&nodesperelement,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 827 828 if(results_on_nodes){ 829 830 /*Allocate matrices*/ 831 int nbe = this->elements->NumberOfElements(); 832 IssmDouble* values = xNewZeroInit<IssmDouble>(nbe*nodesperelement); 833 IssmDouble* allvalues = xNew<IssmDouble>(nbe*nodesperelement); 834 835 /*Fill-in matrix*/ 836 for(int j=0;j<elements->Size();j++){ 837 Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(j)); 838 element->ResultToPatch(values,nodesperelement,output_enum); 839 } 840 841 /*Gather from all cpus*/ 842 ISSM_MPI_Allreduce((void*)values,(void*)allvalues,nbe*nodesperelement,ISSM_MPI_PDOUBLE,ISSM_MPI_SUM,IssmComm::GetComm()); 843 xDelete<IssmDouble>(values); 844 845 if(save_results)results->AddResult(new GenericExternalResult<IssmDouble*>(results->Size()+1,output_enum,allvalues,nbe,nodesperelement,step,time)); 846 xDelete<IssmDouble>(allvalues); 643 847 644 848 } 645 Vector<IssmDouble> *vector_result = new Vector<IssmDouble>(size); 646 647 /*Fill in vector*/ 648 for(int j=0;j<elements->Size();j++){ 649 Element* element=(Element*)elements->GetObjectByOffset(j); 650 element->ResultToVector(vector_result,output_enum); 849 else{ 850 851 /*Allocate vector depending on interpolation*/ 852 switch(interpolation){ 853 case P0Enum: size = this->elements->NumberOfElements(); break; 854 case P1Enum: size = this->vertices->NumberOfVertices(); break; 855 default: _error_("Interpolation "<<EnumToStringx(interpolation)<<" not supported yet"); 856 857 } 858 Vector<IssmDouble> *vector_result = new Vector<IssmDouble>(size); 859 860 /*Fill in vector*/ 861 for(int j=0;j<elements->Size();j++){ 862 Element* element=(Element*)elements->GetObjectByOffset(j); 863 element->ResultToVector(vector_result,output_enum); 864 } 865 vector_result->Assemble(); 866 867 if(save_results)results->AddResult(new GenericExternalResult<Vector<IssmDouble>*>(results->Size()+1,output_enum,vector_result,step,time)); 651 868 } 652 vector_result->Assemble(); 653 654 if(save_results)results->AddResult(new GenericExternalResult<Vector<IssmDouble>*>(results->Size()+1,output_enum,vector_result,step,time)); 655 } 656 isvec = true; 657 break; 658 } 869 isvec = true; 870 break; 871 } 872 } 873 659 874 } 660 875 … … 739 954 740 955 for (i=1;i<elements->Size();i++){ 741 element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));956 element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 742 957 dt=element->TimeAdapt(); 743 958 if(dt<min_dt)min_dt=dt; … … 756 971 757 972 for(int i=0;i<elements->Size();i++){ 758 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));973 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 759 974 element->UpdateConstraintsExtrudeFromBase(); 760 975 } … … 765 980 766 981 for(int i=0;i<elements->Size();i++){ 767 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));982 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 768 983 element->UpdateConstraintsExtrudeFromTop(); 769 984 } … … 839 1054 maxabsvx=-INFINITY; 840 1055 for(i=0;i<this->elements->Size();i++){ 841 Element* element= dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));1056 Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i)); 842 1057 element_maxabsvx=element->inputs->MaxAbs(VxEnum); 843 1058 if(element_maxabsvx>maxabsvx) maxabsvx=element_maxabsvx; … … 863 1078 maxabsvy=-INFINITY; 864 1079 for(i=0;i<this->elements->Size();i++){ 865 Element* element= dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));1080 Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i)); 866 1081 element_maxabsvy=element->inputs->MaxAbs(VyEnum); 867 1082 if(element_maxabsvy>maxabsvy) maxabsvy=element_maxabsvy; … … 887 1102 maxabsvz=-INFINITY; 888 1103 for(i=0;i<this->elements->Size();i++){ 889 Element* element= dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));1104 Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i)); 890 1105 element_maxabsvz=element->inputs->MaxAbs(VzEnum); 891 1106 if(element_maxabsvz>maxabsvz) maxabsvz=element_maxabsvz; … … 911 1126 maxvel=-INFINITY; 912 1127 for(i=0;i<this->elements->Size();i++){ 913 Element* element= dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));1128 Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i)); 914 1129 element_maxvel = element->inputs->Max(VelEnum); 915 1130 if(element_maxvel>maxvel) maxvel=element_maxvel; … … 935 1150 maxvx=-INFINITY; 936 1151 for(i=0;i<this->elements->Size();i++){ 937 Element* element= dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));1152 Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i)); 938 1153 element_maxvx = element->inputs->Max(VxEnum); 939 1154 if(element_maxvx>maxvx) maxvx=element_maxvx; … … 959 1174 maxvy=-INFINITY; 960 1175 for(i=0;i<this->elements->Size();i++){ 961 Element* element= dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));1176 Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i)); 962 1177 element_maxvy = element->inputs->Max(VyEnum); 963 1178 if(element_maxvy>maxvy) maxvy=element_maxvy; … … 983 1198 maxvz=-INFINITY; 984 1199 for(i=0;i<this->elements->Size();i++){ 985 Element* element= dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));1200 Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i)); 986 1201 element_maxvz = element->inputs->Max(VzEnum); 987 1202 if(element_maxvz>maxvz) maxvz=element_maxvz; … … 1007 1222 minvel=INFINITY; 1008 1223 for(i=0;i<this->elements->Size();i++){ 1009 Element* element= dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));1224 Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i)); 1010 1225 element_minvel = element->inputs->Min(VelEnum); 1011 1226 if(element_minvel<minvel) minvel=element_minvel; … … 1031 1246 minvx=INFINITY; 1032 1247 for(i=0;i<this->elements->Size();i++){ 1033 Element* element= dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));1248 Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i)); 1034 1249 element_minvx = element->inputs->Min(VxEnum); 1035 1250 if(element_minvx<minvx) minvx=element_minvx; … … 1055 1270 minvy=INFINITY; 1056 1271 for(i=0;i<this->elements->Size();i++){ 1057 Element* element= dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));1272 Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i)); 1058 1273 element_minvy = element->inputs->Min(VyEnum); 1059 1274 if(element_minvy<minvy) minvy=element_minvy; … … 1079 1294 minvz=INFINITY; 1080 1295 for(i=0;i<this->elements->Size();i++){ 1081 Element* element= dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));1296 Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i)); 1082 1297 element_minvz = element->inputs->Min(VzEnum); 1083 1298 if(element_minvz<minvz) minvz=element_minvz; … … 1099 1314 1100 1315 for(int i=0;i<this->elements->Size();i++){ 1101 Element* element= dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));1316 Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i)); 1102 1317 local_smb+=element->TotalSmb(); 1103 1318 } … … 1115 1330 1116 1331 for(int i=0;i<this->elements->Size();i++){ 1117 Element* element= dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));1332 Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i)); 1118 1333 local_divergence+=element->Divergence(); 1119 1334 } … … 1125 1340 1126 1341 }/*}}}*/ 1342 void FemModel::MaxDivergencex(IssmDouble* pdiv){/*{{{*/ 1343 1344 IssmDouble local_divergence; 1345 IssmDouble node_max_divergence; 1346 IssmDouble max_divergence = -INFINITY; 1347 1348 for(int i=0;i<this->elements->Size();i++){ 1349 Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i)); 1350 local_divergence=element->Divergence(); 1351 if(fabs(local_divergence)>max_divergence) max_divergence=fabs(local_divergence); 1352 } 1353 ISSM_MPI_Reduce(&max_divergence,&node_max_divergence,1,ISSM_MPI_DOUBLE,ISSM_MPI_MAX,0,IssmComm::GetComm() ); 1354 ISSM_MPI_Bcast(&node_max_divergence,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 1355 max_divergence=node_max_divergence; 1356 1357 /*Assign output pointers: */ 1358 *pdiv=max_divergence; 1359 1360 }/*}}}*/ 1361 void FemModel::GetInputLocalMinMaxOnNodesx(IssmDouble** pmin,IssmDouble** pmax,IssmDouble* ug){/*{{{*/ 1362 1363 /*Get vector sizes for current configuration*/ 1364 int configuration_type; 1365 this->parameters->FindParam(&configuration_type,ConfigurationTypeEnum); 1366 int numnodes = this->nodes->NumberOfNodes(configuration_type); 1367 1368 /*Initialize output vectors*/ 1369 IssmDouble* uLmin_local = xNew<IssmDouble>(numnodes); 1370 IssmDouble* uLmax_local = xNew<IssmDouble>(numnodes); 1371 IssmDouble* uLmin = xNew<IssmDouble>(numnodes); 1372 IssmDouble* uLmax = xNew<IssmDouble>(numnodes); 1373 for(int i=0;i<numnodes;i++){ 1374 uLmin_local[i] = +1.e+50; 1375 uLmax_local[i] = -1.e+50; 1376 } 1377 1378 for(int i=0;i<this->elements->Size();i++){ 1379 Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i)); 1380 element->GetInputLocalMinMaxOnNodes(uLmin_local,uLmax_local,ug); 1381 } 1382 1383 /*Synchronize all CPUs*/ 1384 ISSM_MPI_Allreduce((void*)uLmin_local,(void*)uLmin,numnodes,ISSM_MPI_DOUBLE,ISSM_MPI_MIN,IssmComm::GetComm()); 1385 ISSM_MPI_Allreduce((void*)uLmax_local,(void*)uLmax,numnodes,ISSM_MPI_DOUBLE,ISSM_MPI_MAX,IssmComm::GetComm()); 1386 xDelete<IssmDouble>(uLmin_local); 1387 xDelete<IssmDouble>(uLmax_local); 1388 1389 /*Assign output pointers: */ 1390 *pmin=uLmin; 1391 *pmax=uLmax; 1392 1393 }/*}}}*/ 1394 void FemModel::IceMassx(IssmDouble* pM){/*{{{*/ 1395 1396 IssmDouble local_ice_mass = 0; 1397 IssmDouble total_ice_mass; 1398 1399 for(int i=0;i<this->elements->Size();i++){ 1400 Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i)); 1401 local_ice_mass+=element->IceMass(); 1402 } 1403 ISSM_MPI_Reduce(&local_ice_mass,&total_ice_mass,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() ); 1404 ISSM_MPI_Bcast(&total_ice_mass,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 1405 1406 /*Assign output pointers: */ 1407 *pM=total_ice_mass; 1408 1409 }/*}}}*/ 1127 1410 void FemModel::IceVolumex(IssmDouble* pV){/*{{{*/ 1128 1411 … … 1131 1414 1132 1415 for(int i=0;i<this->elements->Size();i++){ 1133 Element* element= dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));1416 Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i)); 1134 1417 local_ice_volume+=element->IceVolume(); 1135 1418 } … … 1147 1430 1148 1431 for(int i=0;i<this->elements->Size();i++){ 1149 Element* element= dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));1432 Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i)); 1150 1433 local_ice_volume_af+=element->IceVolumeAboveFloatation(); 1151 1434 } … … 1172 1455 /*now, go through our elements, and retrieve the one with this id: index: */ 1173 1456 for(int i=0;i<this->elements->Size();i++){ 1174 element= dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));1457 element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i)); 1175 1458 if (element->Id()==index){ 1176 1459 found=1; … … 1210 1493 /*Compute Misfit: */ 1211 1494 for(int i=0;i<elements->Size();i++){ 1212 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));1495 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 1213 1496 1214 1497 /*If on water, return 0: */ … … 1265 1548 1266 1549 }/*}}}*/ 1267 void FemModel:: Balancethickness2Misfitx(IssmDouble* presponse){/*{{{*/1550 void FemModel::SurfaceAbsMisfitx(IssmDouble* presponse){/*{{{*/ 1268 1551 1269 1552 /*output: */ … … 1271 1554 IssmDouble J_sum; 1272 1555 1273 IssmDouble weight,thicknessobs,thickness,potential; 1274 IssmDouble vx,vy,vxbar,vybar,vxobs,vyobs,vxbarobs,vybarobs,nux,nuy; 1556 IssmDouble surface,surfaceobs,weight; 1275 1557 IssmDouble Jdet; 1276 1558 IssmDouble* xyz_list = NULL; … … 1278 1560 /*Compute Misfit: */ 1279 1561 for(int i=0;i<elements->Size();i++){ 1280 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));1562 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 1281 1563 1282 1564 /*If on water, return 0: */ … … 1285 1567 /* Get node coordinates*/ 1286 1568 element->GetVerticesCoordinates(&xyz_list); 1287 Input* weights_input =element->GetInput(InversionCostFunctionsCoefficientsEnum); _assert_(weights_input); 1288 Input* thickness_input =element->GetInput(ThicknessEnum); _assert_(thickness_input); 1289 Input* thicknessobs_input=element->GetInput(InversionThicknessObsEnum); _assert_(thicknessobs_input); 1290 Input* potential_input =element->GetInput(PotentialEnum); _assert_(potential_input); 1291 Input* vxobs_input =element->GetInput(BalancethicknessVxObsEnum); _assert_(vxobs_input); 1292 Input* vyobs_input =element->GetInput(BalancethicknessVyObsEnum); _assert_(vyobs_input); 1293 Input* vx_input =element->GetInput(VxEnum); _assert_(vx_input); 1294 Input* vy_input =element->GetInput(VyEnum); _assert_(vy_input); 1295 Input* nux_input = element->GetInput(BalancethicknessNuxEnum); _assert_(nux_input); 1296 Input* nuy_input = element->GetInput(BalancethicknessNuyEnum); _assert_(nuy_input); 1297 1298 /* Start looping on the number of gaussian points: */ 1299 Gauss* gauss=element->NewGauss(2); 1300 for(int ig=gauss->begin();ig<gauss->end();ig++){ 1301 1302 gauss->GaussPoint(ig); 1303 1304 /* Get Jacobian determinant: */ 1305 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 1306 1307 /*Get all parameters at gaussian point*/ 1308 weights_input->GetInputValue(&weight,gauss,Balancethickness2MisfitEnum); 1309 thickness_input->GetInputValue(&thickness,gauss); 1310 thicknessobs_input->GetInputValue(&thicknessobs,gauss); 1311 potential_input->GetInputValue(&potential,gauss); 1312 vxobs_input->GetInputValue(&vxobs,gauss); 1313 vyobs_input->GetInputValue(&vyobs,gauss); 1314 vx_input->GetInputValue(&vxbar,gauss); 1315 vy_input->GetInputValue(&vybar,gauss); 1316 nux_input->GetInputValue(&nux,gauss); 1317 nuy_input->GetInputValue(&nuy,gauss); 1318 1319 vxbarobs = nux*vxobs; 1320 vybarobs = nuy*vyobs; 1321 1322 /*J = (H^2 - Hobs^2)^2*/ 1323 //J +=0.5*(thickness*thickness - thicknessobs*thicknessobs)*(thickness*thickness - thicknessobs*thicknessobs)*weight*Jdet*gauss->weight; 1324 /*J = phi^2*/ 1325 //J +=.5*potential*potential*weight*Jdet*gauss->weight; OK 1326 /*J = (ubar - nux*uobs)^2*/ 1327 J +=0.5*((vxbarobs - vxbar)*(vxbarobs - vxbar) + (vybarobs - vybar)*(vybarobs - vybar))*weight*Jdet*gauss->weight; 1328 } 1329 1330 /*clean up and Return: */ 1331 xDelete<IssmDouble>(xyz_list); 1332 delete gauss; 1569 1570 /*Retrieve all inputs we will be needing: */ 1571 Input* weights_input =element->GetInput(InversionCostFunctionsCoefficientsEnum); _assert_(weights_input); 1572 Input* surface_input =element->GetInput(SurfaceEnum); _assert_(surface_input); 1573 Input* surfaceobs_input=element->GetInput(InversionSurfaceObsEnum); _assert_(surfaceobs_input); 1574 1575 /* Start looping on the number of gaussian points: */ 1576 Gauss* gauss=element->NewGauss(2); 1577 for(int ig=gauss->begin();ig<gauss->end();ig++){ 1578 1579 gauss->GaussPoint(ig); 1580 1581 /* Get Jacobian determinant: */ 1582 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 1583 1584 /*Get all parameters at gaussian point*/ 1585 weights_input->GetInputValue(&weight,gauss,SurfaceAbsMisfitEnum); 1586 surface_input->GetInputValue(&surface,gauss); 1587 surfaceobs_input->GetInputValue(&surfaceobs,gauss); 1588 1589 /*Compute SurfaceAbsMisfitEnum*/ 1590 J+=0.5*(surface-surfaceobs)*(surface-surfaceobs)*weight*Jdet*gauss->weight; 1591 } 1592 delete gauss; 1593 xDelete<IssmDouble>(xyz_list); 1333 1594 } 1334 1595 … … 1355 1616 /*Compute Misfit: */ 1356 1617 for(int i=0;i<elements->Size();i++){ 1357 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));1618 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 1358 1619 1359 1620 /*If on water, return 0: */ … … 1377 1638 1378 1639 /*Get all parameters at gaussian point*/ 1379 weights_input->GetInputValue(&weight,gauss,ThicknessAbs MisfitEnum);1640 weights_input->GetInputValue(&weight,gauss,ThicknessAbsGradientEnum); 1380 1641 thickness_input->GetInputDerivativeValue(&dp[0],xyz_list,gauss); 1381 1642 … … 1478 1739 /*Clean up and return*/ 1479 1740 xDelete<int>(control_type); 1741 } 1742 /*}}}*/ 1743 void FemModel::StressIntensityFactorx(){/*{{{*/ 1744 1745 /*Update input for basal element only*/ 1746 for(int i=0;i<elements->Size();i++){ 1747 Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i)); 1748 element->StressIntensityFactor(); 1749 } 1750 } 1751 /*}}}*/ 1752 void FemModel::CalvingRateLevermannx(){/*{{{*/ 1753 1754 for(int i=0;i<elements->Size();i++){ 1755 Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i)); 1756 element->CalvingRateLevermann(); 1757 } 1758 } 1759 /*}}}*/ 1760 void FemModel::CalvingRatePix(){/*{{{*/ 1761 1762 for(int i=0;i<elements->Size();i++){ 1763 Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i)); 1764 element->CalvingRatePi(); 1765 } 1766 } 1767 /*}}}*/ 1768 void FemModel::CalvingRateDevx(){/*{{{*/ 1769 1770 for(int i=0;i<elements->Size();i++){ 1771 Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i)); 1772 element->CalvingRateDev(); 1773 } 1774 } 1775 /*}}}*/ 1776 void FemModel::StrainRateparallelx(){/*{{{*/ 1777 1778 for(int i=0;i<elements->Size();i++){ 1779 Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i)); 1780 element->StrainRateparallel(); 1781 } 1782 } 1783 /*}}}*/ 1784 void FemModel::StrainRateperpendicularx(){/*{{{*/ 1785 1786 for(int i=0;i<elements->Size();i++){ 1787 Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i)); 1788 element->StrainRateperpendicular(); 1789 } 1790 } 1791 /*}}}*/ 1792 void FemModel::DeviatoricStressx(){/*{{{*/ 1793 1794 for(int i=0;i<elements->Size();i++){ 1795 Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i)); 1796 element->ComputeDeviatoricStressTensor(); 1797 } 1480 1798 } 1481 1799 /*}}}*/ … … 1513 1831 1514 1832 /*this response was scaled. pick up the response from the inputs: */ 1515 GetVectorFromInputsx(&vertex_response,this, StringToEnumx(root),Vertex Enum);1833 GetVectorFromInputsx(&vertex_response,this, StringToEnumx(root),VertexPIdEnum); 1516 1834 1517 1835 /*Now, average it onto the partition nodes: */ … … 1586 1904 /*Go through elements, and add contribution from each element to the deflection vector wg:*/ 1587 1905 for(int i=0;i<elements->Size();i++){ 1588 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));1906 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 1589 1907 element->GiaDeflection(wg,dwgdt, x,y); 1590 1908 } … … 1592 1910 /*}}}*/ 1593 1911 #endif 1594 void FemModel::HydrologyEPLupdateDomainx(void){ /*{{{*/ 1595 1596 Vector<IssmDouble>* mask = NULL; 1597 IssmDouble* serial_mask = NULL; 1598 Vector<IssmDouble>* active = NULL; 1599 IssmDouble* serial_active = NULL; 1912 void FemModel::HydrologyEPLupdateDomainx(IssmDouble* pEplcount){ /*{{{*/ 1913 1914 Vector<IssmDouble>* mask = NULL; 1915 Vector<IssmDouble>* recurence = NULL; 1916 Vector<IssmDouble>* active = NULL; 1917 IssmDouble* serial_mask = NULL; 1918 IssmDouble* serial_rec = NULL; 1919 IssmDouble* serial_active = NULL; 1920 IssmDouble* old_active = NULL; 1921 int* eplzigzag_counter = NULL; 1922 int eplflip_lock; 1600 1923 1601 1924 HydrologyDCEfficientAnalysis* effanalysis = new HydrologyDCEfficientAnalysis(); 1925 HydrologyDCInefficientAnalysis* inefanalysis = new HydrologyDCInefficientAnalysis(); 1926 1602 1927 /*Step 1: update mask, the mask might be extended by residual and/or using downstream sediment head*/ 1603 mask=new Vector<IssmDouble>(nodes->NumberOfNodes(HydrologyDCEfficientAnalysisEnum)); 1604 1928 mask=new Vector<IssmDouble>(this->nodes->NumberOfNodes(HydrologyDCEfficientAnalysisEnum)); 1929 recurence=new Vector<IssmDouble>(this->nodes->NumberOfNodes(HydrologyDCEfficientAnalysisEnum)); 1930 this->parameters->FindParam(&eplzigzag_counter,NULL,EplZigZagCounterEnum); 1931 this->parameters->FindParam(&eplflip_lock,HydrologydcEplflipLockEnum); 1932 GetVectorFromInputsx(&old_active,this,HydrologydcMaskEplactiveNodeEnum,NodeSIdEnum); 1933 1605 1934 for (int i=0;i<elements->Size();i++){ 1606 Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 1607 effanalysis->HydrologyEPLGetMask(mask,element); 1608 } 1609 1935 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 1936 effanalysis->HydrologyEPLGetMask(mask,recurence,eplzigzag_counter,element); 1937 } 1938 /*check for changes and increment zigzag counter, change the mask if necessary*/ 1939 recurence->Assemble(); 1940 serial_rec=recurence->ToMPISerial(); 1941 for (int i=0;i<nodes->Size();i++){ 1942 Node* node=xDynamicCast<Node*>(nodes->GetObjectByOffset(i)); 1943 if(serial_rec[node->Sid()]==1.)eplzigzag_counter[node->Lid()] ++; 1944 if(eplzigzag_counter[node->Lid()]>eplflip_lock & eplflip_lock!=0){ 1945 mask->SetValue(node->Sid(),old_active[node->Sid()],INS_VAL); 1946 } 1947 } 1948 1949 1950 this->parameters->SetParam(eplzigzag_counter,this->nodes->Size(),EplZigZagCounterEnum); 1610 1951 /*Assemble and serialize*/ 1611 1952 mask->Assemble(); 1612 serial_mask=mask->ToMPISerial(); 1953 serial_mask=mask->ToMPISerial(); 1954 1955 xDelete<int>(eplzigzag_counter); 1956 xDelete<IssmDouble>(serial_rec); 1957 xDelete<IssmDouble>(old_active); 1613 1958 delete mask; 1959 delete recurence; 1614 1960 1615 1961 /*Update Mask*/ 1616 1962 InputUpdateFromVectorx(this,serial_mask,HydrologydcMaskEplactiveNodeEnum,NodeSIdEnum); 1617 1963 xDelete<IssmDouble>(serial_mask); 1618 1964 inefanalysis->ElementizeEplMask(this); 1619 1965 /*Step 2: update node activity. If one element is connected to mask=1, all nodes are active*/ 1620 1966 active=new Vector<IssmDouble>(nodes->NumberOfNodes(HydrologyDCEfficientAnalysisEnum)); 1621 1967 for (int i=0;i<elements->Size();i++){ 1622 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));1968 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 1623 1969 effanalysis->HydrologyEPLGetActive(active,element); 1624 1970 } … … 1632 1978 int counter =0; 1633 1979 for (int i=0;i<nodes->Size();i++){ 1634 Node* node= dynamic_cast<Node*>(nodes->GetObjectByOffset(i));1980 Node* node=xDynamicCast<Node*>(nodes->GetObjectByOffset(i)); 1635 1981 if(node->InAnalysis(HydrologyDCEfficientAnalysisEnum)){ 1636 1982 if(serial_active[node->Sid()]==1.){ 1637 1983 node->Activate(); 1638 counter++;1984 if(!node->IsClone()) counter++; 1639 1985 } 1640 1986 else{ … … 1645 1991 xDelete<IssmDouble>(serial_active); 1646 1992 delete effanalysis; 1993 delete inefanalysis; 1647 1994 int sum_counter; 1648 1995 ISSM_MPI_Reduce(&counter,&sum_counter,1,ISSM_MPI_INT,ISSM_MPI_SUM,0,IssmComm::GetComm() ); 1649 1996 ISSM_MPI_Bcast(&sum_counter,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 1650 1997 counter=sum_counter; 1998 *pEplcount = counter; 1651 1999 if(VerboseSolution()) _printf0_(" Number of active nodes in EPL layer: "<< counter <<"\n"); 1652 2000 … … 1656 2004 } 1657 2005 /*}}}*/ 1658 void FemModel::UpdateConstraintsL2ProjectionEPLx( void){ /*{{{*/2006 void FemModel::UpdateConstraintsL2ProjectionEPLx(IssmDouble* pL2count){ /*{{{*/ 1659 2007 1660 2008 Vector<IssmDouble>* active = NULL; … … 1665 2013 active=new Vector<IssmDouble>(nodes->NumberOfNodes(HydrologyDCEfficientAnalysisEnum)); 1666 2014 for (int i=0;i<elements->Size();i++){ 1667 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));2015 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 1668 2016 effanalysis->HydrologyEPLGetActive(active,element); 1669 2017 } … … 1678 2026 int counter =0; 1679 2027 for (int i=0;i<nodes->Size();i++){ 1680 Node* node= dynamic_cast<Node*>(nodes->GetObjectByOffset(i));2028 Node* node=xDynamicCast<Node*>(nodes->GetObjectByOffset(i)); 1681 2029 if(node->InAnalysis(L2ProjectionEPLAnalysisEnum)){ 1682 2030 if(serial_active[node->Sid()]==1.){ 1683 2031 node->Activate(); 1684 counter++;2032 if(!node->IsClone()) counter++; 1685 2033 } 1686 2034 else{ … … 1694 2042 ISSM_MPI_Bcast(&sum_counter,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 1695 2043 counter=sum_counter; 2044 *pL2count = counter; 1696 2045 if(VerboseSolution()) _printf0_(" Number of active nodes L2 Projection: "<< counter <<"\n"); 1697 1698 /*Update dof indexings*/ 1699 this->UpdateConstraintsx(); 1700 } 1701 /*}}}*/ 2046 } 2047 /*}}}*/ -
issm/trunk/src/c/classes/FemModel.h
r18301 r19105 46 46 47 47 /*constructors, destructors: */ 48 FemModel(int argc,char** argv,ISSM_MPI_Comm comm_init );49 FemModel(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int solution_type,const int* analyses,const int nummodels);48 FemModel(int argc,char** argv,ISSM_MPI_Comm comm_init,bool trace=false); 49 FemModel(char* rootpath, char* inputfilename, char* outputfilename, char* toolkitsfilename, char* lockfilename, ISSM_MPI_Comm incomm, int solution_type,IssmPDouble* X); 50 50 ~FemModel(); 51 51 … … 53 53 void Echo(); 54 54 FemModel* copy(); 55 void InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int solution_type,const int* analyses,const int nummodels); 55 void InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int solution_type,bool trace,IssmPDouble* X=NULL); 56 void SolutionAnalysesList(int** panalyses,int* pnumanalyses,IoModel* iomodel,int solutiontype); 56 57 void CleanUp(void); 57 58 void Solve(void); … … 61 62 62 63 /*Modules*/ 64 void ElementOperationx(void (Element::*function)(void)); 65 void GetInputLocalMinMaxOnNodesx(IssmDouble** pmin,IssmDouble** pmax,IssmDouble* ug); 63 66 void MassFluxx(IssmDouble* presponse); 64 67 void MaxAbsVxx(IssmDouble* presponse); … … 75 78 void TotalSmbx(IssmDouble* pSmb); 76 79 void Divergencex(IssmDouble* pdiv); 80 void MaxDivergencex(IssmDouble* pdiv); 81 void IceMassx(IssmDouble* pV); 77 82 void IceVolumex(IssmDouble* pV); 78 83 void IceVolumeAboveFloatationx(IssmDouble* pV); 79 84 void ElementResponsex(IssmDouble* presponse,int response_enum); 80 85 void BalancethicknessMisfitx(IssmDouble* pV); 81 void Balancethickness2Misfitx(IssmDouble* pV); 86 void StressIntensityFactorx(); 87 void StrainRateparallelx(); 88 void StrainRateperpendicularx(); 89 void DeviatoricStressx(); 90 void CalvingRateLevermannx(); 91 void CalvingRatePix(); 92 void CalvingRateDevx(); 82 93 #ifdef _HAVE_DAKOTA_ 83 94 void DakotaResponsesx(double* d_responses,char** responses_descriptors,int numresponsedescriptors,int d_numresponses); … … 91 102 void CostFunctionx(IssmDouble* pJ,IssmDouble** pJlist,int* pn); 92 103 void ThicknessAbsGradientx( IssmDouble* pJ); 104 void SurfaceAbsMisfitx( IssmDouble* pJ); 93 105 #ifdef _HAVE_GIA_ 94 106 void Deflection(Vector<IssmDouble>* wg,Vector<IssmDouble>* dwgdt, IssmDouble* x, IssmDouble* y); … … 99 111 void UpdateConstraintsExtrudeFromBasex(); 100 112 void UpdateConstraintsExtrudeFromTopx(); 101 void HydrologyEPLupdateDomainx(void); 102 // void HydrologyEPLThicknessx(void); 103 void UpdateConstraintsL2ProjectionEPLx(void); 113 void HydrologyEPLupdateDomainx(IssmDouble* pEplcount); 114 void UpdateConstraintsL2ProjectionEPLx(IssmDouble* pL2count); 104 115 }; 105 116 -
issm/trunk/src/c/classes/Hook.cpp
r18301 r19105 168 168 /*Now, for this->objects that did not get resolved, and for which we have no offset, chase them in the dataset, by id: */ 169 169 if(this->objects[i]==NULL){ 170 this->objects[i]= dynamic_cast<Object*>(dataset->GetObjectById(this->offsets+i,this->ids[i])); //remember the offset for later on.170 this->objects[i]=xDynamicCast<Object*>(dataset->GetObjectById(this->offsets+i,this->ids[i])); //remember the offset for later on. 171 171 /*check the id is correct!: */ 172 172 if (this->objects[i]->Id()!=this->ids[i]) _error_("wrong id: " << this->objects[i]->Id() << " vs " << this->ids[i] << " in resolved pointer!"); -
issm/trunk/src/c/classes/IndependentObject.cpp
r18301 r19105 70 70 71 71 /*IndependentObject methods: */ 72 void IndependentObject::FetchIndependent(IoModel* iomodel ){/*{{{*/72 void IndependentObject::FetchIndependent(IoModel* iomodel,int* pXcount,IssmPDouble* X){ /*{{{*/ 73 73 74 74 int my_rank; 75 75 FILE* fid=NULL; 76 int Xcount=0; 76 77 77 78 /*recover my_rank:*/ 78 79 my_rank=IssmComm::GetRank(); 80 81 /*recover Xcount if X is not NULL:*/ 82 if(X)Xcount=*pXcount; 79 83 80 84 #ifdef _HAVE_ADOLC_ //cannot come here unless you are running AD mode, from DeclaredIndependents: … … 98 102 if(fread(&pscalar,sizeof(IssmPDouble),1,fid)!=1)_error_("could not read scalar "); 99 103 100 /*Now, before we even broadcast this to other nodes, declare the scalar as an independent variable!: */ 101 scalar<<=pscalar; 104 /*Now, before we even broadcast this to other nodes, declare the scalar as an independent variable!. If we 105 *have been supplied an X vector, use it instead of what we just read: */ 106 if(X){ 107 scalar<<=X[Xcount]; 108 } 109 else{ 110 scalar<<=pscalar; 111 } 102 112 } 103 113 … … 113 123 iomodel->independents[name]=true; 114 124 125 /*increment offset into X vector, now that we have read 1 value:*/ 126 Xcount++; *pXcount=Xcount; 127 115 128 //finally, record the number of independents: 116 129 this->numberofindependents=1; … … 150 163 if(fread(buffer,M*N*sizeof(IssmPDouble),1,fid)!=1) _error_("could not read matrix "); 151 164 152 /*Now, before we even broadcast this to other nodes, declare the whole matrix as a independent variable!: */ 153 for (int i=0;i<M*N;++i) matrix[i]<<=buffer[i]; /*we use the <<= ADOLC overloaded operator to declare the independency*/ 165 /*Now, before we even broadcast this to other nodes, declare the whole matrix as a independent variable! 166 If we have been supplied an X vector, use it instead of what we just read: */ 167 if(X){ 168 for (int i=0;i<M*N;i++) matrix[i]<<=X[Xcount+i]; /*<<= ADOLC overloaded operator to declare independent*/ 169 } 170 else{ 171 for (int i=0;i<M*N;i++) matrix[i]<<=buffer[i]; 172 } 154 173 } 155 174 ISSM_MPI_Bcast(matrix,M*N,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); … … 165 184 iomodel->independents[name]=true; 166 185 186 187 /*increment offset into X vector, now that we have read M*N values:*/ 188 Xcount+=M*N; *pXcount=Xcount; 189 167 190 //Finally, record the number of independents created: 168 191 this->numberofindependents=M*N; … … 180 203 /*}}}*/ 181 204 void IndependentObject::FillIndependents(IssmDouble** data, IssmDouble* xp){/*{{{*/ 182 183 int i;184 205 185 206 /*Branch according to the type of variable: */ … … 189 210 else if(type==1){ /* vector:*/ 190 211 IssmDouble* values=data[name]; 191 for(i=0;i<this->numberofindependents;i++){ 192 xp[i]=values[i]; 193 } 212 for(int i=0;i<this->numberofindependents;i++) xp[i]=values[i]; 194 213 } 195 214 else _error_("should not have a type of " << type); -
issm/trunk/src/c/classes/IndependentObject.h
r15396 r19105 33 33 /*}}}*/ 34 34 /*IndependentObject methods: {{{*/ 35 void FetchIndependent(IoModel* iomodel );35 void FetchIndependent(IoModel* iomodel,int* pXcount,IssmPDouble* X); 36 36 int NumIndependents(void); 37 37 void FillIndependents(IssmDouble** data, IssmDouble* xp); -
issm/trunk/src/c/classes/Inputs/BoolInput.cpp
r18301 r19105 133 133 } 134 134 /*}}}*/ 135 void BoolInput::Extrude( void){/*{{{*/135 void BoolInput::Extrude(int start){/*{{{*/ 136 136 137 137 /*do nothing*/ -
issm/trunk/src/c/classes/Inputs/BoolInput.h
r17806 r19105 64 64 void AXPY(Input* xinput,IssmDouble scalar); 65 65 void Constrain(IssmDouble cm_min, IssmDouble cm_max){_error_("Constrain not implemented for booleans");}; 66 void Extrude( void);66 void Extrude(int start); 67 67 void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");}; 68 68 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist); -
issm/trunk/src/c/classes/Inputs/ControlInput.cpp
r18301 r19105 87 87 output->control_id=this->control_id; 88 88 89 if(values) output->values = dynamic_cast<Input*>(this->values->copy());90 if(savedvalues) output->savedvalues = dynamic_cast<Input*>(this->savedvalues->copy());91 if(minvalues) output->minvalues = dynamic_cast<Input*>(this->minvalues->copy());92 if(maxvalues) output->maxvalues = dynamic_cast<Input*>(this->maxvalues->copy());93 if(gradient) output->gradient = dynamic_cast<Input*>(this->gradient->copy());89 if(values) output->values = xDynamicCast<Input*>(this->values->copy()); 90 if(savedvalues) output->savedvalues = xDynamicCast<Input*>(this->savedvalues->copy()); 91 if(minvalues) output->minvalues = xDynamicCast<Input*>(this->minvalues->copy()); 92 if(maxvalues) output->maxvalues = xDynamicCast<Input*>(this->maxvalues->copy()); 93 if(gradient) output->gradient = xDynamicCast<Input*>(this->gradient->copy()); 94 94 95 95 return output; … … 121 121 values->Constrain(min,max); 122 122 }/*}}}*/ 123 void ControlInput::Extrude( void){/*{{{*/124 values->Extrude( );125 savedvalues->Extrude( );123 void ControlInput::Extrude(int start){/*{{{*/ 124 values->Extrude(start); 125 savedvalues->Extrude(start); 126 126 //gradient->Extrude(); 127 127 }/*}}}*/ … … 234 234 235 235 if(savedvalues) delete this->savedvalues; 236 this->savedvalues= dynamic_cast<Input*>(this->values->copy());236 this->savedvalues=xDynamicCast<Input*>(this->values->copy()); 237 237 }/*}}}*/ 238 238 void ControlInput::UpdateValue(IssmDouble scalar){/*{{{*/ … … 241 241 242 242 if(values) delete this->values; 243 this->values= dynamic_cast<Input*>(this->savedvalues->copy());243 this->values=xDynamicCast<Input*>(this->savedvalues->copy()); 244 244 this->values->AXPY(gradient,scalar); 245 245 }/*}}}*/ -
issm/trunk/src/c/classes/Inputs/ControlInput.h
r18301 r19105 72 72 IssmDouble Min(void); 73 73 IssmDouble MinAbs(void){_error_("not implemented yet");}; 74 void Extrude( void);74 void Extrude(int start); 75 75 void VerticallyIntegrate(Input* thickness_input); 76 76 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist,const char* data); -
issm/trunk/src/c/classes/Inputs/DatasetInput.cpp
r18301 r19105 81 81 outinput=new DatasetInput(); 82 82 outinput->enum_type=this->enum_type; 83 outinput->inputs= dynamic_cast<Inputs*>(this->inputs->SpawnTriaInputs(index1,index2,index3));83 outinput->inputs=xDynamicCast<Inputs*>(this->inputs->SpawnTriaInputs(index1,index2,index3)); 84 84 outinput->numids=this->numids; 85 85 outinput->ids=xNew<int>(this->numids); … … 98 98 outinput=new DatasetInput(); 99 99 outinput->enum_type=this->enum_type; 100 outinput->inputs= dynamic_cast<Inputs*>(this->inputs->SpawnSegInputs(index1,index2));100 outinput->inputs=xDynamicCast<Inputs*>(this->inputs->SpawnSegInputs(index1,index2)); 101 101 outinput->numids=this->numids; 102 102 outinput->ids=xNew<int>(this->numids); … … 157 157 if(offset<0) _error_("Could not find input of id "<<id ); 158 158 159 Input* input= dynamic_cast<Input*>(this->inputs->GetObjectByOffset(offset));159 Input* input=xDynamicCast<Input*>(this->inputs->GetObjectByOffset(offset)); 160 160 input->GetInputValue(pvalue,gauss); 161 161 } -
issm/trunk/src/c/classes/Inputs/DatasetInput.h
r17806 r19105 68 68 IssmDouble Min(void){_error_("not implemented yet");}; 69 69 IssmDouble MinAbs(void){_error_("not implemented yet");}; 70 void Extrude( void){_error_("not implemented yet");};70 void Extrude(int start){_error_("not implemented yet");}; 71 71 void VerticallyIntegrate(Input* thickness_input){_error_("not implemented yet");}; 72 72 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){_error_("not implemented yet");}; -
issm/trunk/src/c/classes/Inputs/DoubleInput.h
r17806 r19105 67 67 IssmDouble Min(void); 68 68 IssmDouble MinAbs(void); 69 void Extrude( void){_error_("not supported yet");};69 void Extrude(int start){_error_("not supported yet");}; 70 70 void VerticallyIntegrate(Input* thickness_input); 71 71 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist); -
issm/trunk/src/c/classes/Inputs/Input.h
r17806 r19105 51 51 virtual void Constrain(IssmDouble cm_min, IssmDouble cm_max)=0; 52 52 virtual void VerticallyIntegrate(Input* thickness_input)=0; 53 virtual void Extrude( )=0;53 virtual void Extrude(int start)=0; 54 54 virtual void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist)=0; 55 55 -
issm/trunk/src/c/classes/Inputs/Inputs.cpp
r18301 r19105 38 38 for ( object=objects.begin() ; object < objects.end(); object++ ){ 39 39 40 input= dynamic_cast<Input*>(*object);40 input=xDynamicCast<Input*>(*object); 41 41 if (input->InstanceEnum()==enum_type){ 42 42 found=true; … … 65 65 for ( object=objects.begin() ; object < objects.end(); object++ ){ 66 66 67 input= dynamic_cast<Input*>(*object);67 input=xDynamicCast<Input*>(*object); 68 68 if (input->InstanceEnum()==enum_type){ 69 69 found=true; … … 92 92 for ( object=objects.begin() ; object < objects.end(); object++ ){ 93 93 94 input= dynamic_cast<Input*>(*object);94 input=xDynamicCast<Input*>(*object); 95 95 if (input->InstanceEnum()==enum_type){ 96 96 found=true; … … 119 119 for ( object=objects.begin() ; object < objects.end(); object++ ){ 120 120 121 input= dynamic_cast<Input*>(*object);121 input=xDynamicCast<Input*>(*object); 122 122 if (input->InstanceEnum()==enum_type){ 123 123 found=true; … … 150 150 for ( object=objects.begin() ; object < objects.end(); object++ ){ 151 151 152 input= dynamic_cast<Input*>(*object);152 input=xDynamicCast<Input*>(*object); 153 153 154 154 if (input->InstanceEnum()==in_input->InstanceEnum()){ … … 171 171 /*Delete existing input of newenumtype if it exists*/ 172 172 for ( object=objects.begin() ; object < objects.end(); object++ ){ 173 input= dynamic_cast<Input*>(*object);173 input=xDynamicCast<Input*>(*object); 174 174 175 175 if (input->InstanceEnum()==newenumtype){ … … 182 182 for ( object=objects.begin() ; object < objects.end(); object++ ){ 183 183 184 input= dynamic_cast<Input*>(*object);184 input=xDynamicCast<Input*>(*object); 185 185 186 186 if (input->InstanceEnum()==oldenumtype){ … … 194 194 195 195 /*Find x and y inputs: */ 196 Input* constrain_input= dynamic_cast<Input*>(this->GetInput(constrain_enum));196 Input* constrain_input=xDynamicCast<Input*>(this->GetInput(constrain_enum)); 197 197 198 198 /*some checks: */ … … 209 209 210 210 /*Get input*/ 211 Input* input= dynamic_cast<Input*>(this->GetInput(enumtype));211 Input* input=xDynamicCast<Input*>(this->GetInput(enumtype)); 212 212 213 213 /*Apply ContrainMin: */ … … 229 229 230 230 /*Get input*/ 231 Input* input= dynamic_cast<Input*>(this->GetInput(enumtype));231 Input* input=xDynamicCast<Input*>(this->GetInput(enumtype)); 232 232 233 233 /*Apply ContrainMin: */ … … 249 249 250 250 /*Get input*/ 251 Input* input= dynamic_cast<Input*>(this->GetInput(enumtype));251 Input* input=xDynamicCast<Input*>(this->GetInput(enumtype)); 252 252 253 253 /*Apply ContrainMin: */ … … 269 269 270 270 /*Get input*/ 271 Input* input= dynamic_cast<Input*>(this->GetInput(enumtype));271 Input* input=xDynamicCast<Input*>(this->GetInput(enumtype)); 272 272 273 273 /*Apply ContrainMin: */ … … 289 289 290 290 /*Get input*/ 291 Input* input= dynamic_cast<Input*>(this->GetInput(enumtype));291 Input* input=xDynamicCast<Input*>(this->GetInput(enumtype)); 292 292 293 293 /*Apply ContrainMin: */ … … 310 310 for ( object=objects.begin() ; object < objects.end(); object++ ){ 311 311 312 input= dynamic_cast<Input*>(*object);312 input=xDynamicCast<Input*>(*object); 313 313 314 314 if (input->InstanceEnum()==enum_name){ … … 326 326 for ( object=objects.begin() ; object < objects.end(); object++ ){ 327 327 328 input= dynamic_cast<Input*>(*object);328 input=xDynamicCast<Input*>(*object); 329 329 330 330 if (input->InstanceEnum()==enum_type){ … … 341 341 342 342 /*Make a copy of the original input: */ 343 Input* original= dynamic_cast<Input*>(this->GetInput(original_enum));343 Input* original=xDynamicCast<Input*>(this->GetInput(original_enum)); 344 344 if(!original)_error_("could not find input with enum: " << EnumToStringx(original_enum)); 345 Input* copy= dynamic_cast<Input*>(original->copy());345 Input* copy=xDynamicCast<Input*>(original->copy()); 346 346 347 347 /*Change copy enum to reinitialized_enum: */ … … 349 349 350 350 /*Add copy into inputs, it will wipe off the one already there: */ 351 this->AddInput( dynamic_cast<Input*>(copy));351 this->AddInput(xDynamicCast<Input*>(copy)); 352 352 } 353 353 /*}}}*/ … … 366 366 367 367 /*Create new input*/ 368 inputin= dynamic_cast<Input*>(*object);368 inputin=xDynamicCast<Input*>(*object); 369 369 inputout=inputin->SpawnTriaInput(index1,index2,index3); 370 370 … … 391 391 392 392 /*Create new input*/ 393 inputin= dynamic_cast<Input*>(*object);393 inputin=xDynamicCast<Input*>(*object); 394 394 inputout=inputin->SpawnSegInput(index1,index2); 395 395 … … 405 405 406 406 /*Find x and y inputs: */ 407 Input* xinput= dynamic_cast<Input*>(this->GetInput(inputx_enum));408 Input* yinput= dynamic_cast<Input*>(this->GetInput(inputy_enum));407 Input* xinput=xDynamicCast<Input*>(this->GetInput(inputx_enum)); 408 Input* yinput=xDynamicCast<Input*>(this->GetInput(inputy_enum)); 409 409 410 410 /*some checks: */ … … 423 423 for ( object=objects.begin() ; object < objects.end(); object++ ){ 424 424 425 input= dynamic_cast<Input*>(*object);425 input=xDynamicCast<Input*>(*object); 426 426 input->Configure(parameters); 427 427 -
issm/trunk/src/c/classes/Inputs/IntInput.h
r17806 r19105 68 68 IssmDouble Min(void){_error_("Min not implemented for integers");}; 69 69 IssmDouble MinAbs(void){_error_("Min not implemented for integers");}; 70 void Extrude( void){_error_("not supported yet");};70 void Extrude(int start){_error_("not supported yet");}; 71 71 void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");}; 72 72 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist); -
issm/trunk/src/c/classes/Inputs/PentaInput.cpp
r18301 r19105 291 291 } 292 292 /*}}}*/ 293 void PentaInput::Extrude( void){/*{{{*/293 void PentaInput::Extrude(int start){/*{{{*/ 294 294 295 295 switch(this->interpolation_type){ 296 296 case P1Enum: 297 for(int i=0;i<3;i++) this->values[3+i]=this->values[i]; 297 if(start==-1){ 298 for(int i=0;i<3;i++) this->values[3+i]=this->values[i]; 299 } 300 else{ 301 for(int i=0;i<3;i++) this->values[i] =this->values[3+i]; 302 } 298 303 break; 299 304 default: -
issm/trunk/src/c/classes/Inputs/PentaInput.h
r18301 r19105 68 68 IssmDouble Min(void); 69 69 IssmDouble MinAbs(void); 70 void Extrude( void);70 void Extrude(int start); 71 71 void VerticallyIntegrate(Input* thickness_input); 72 72 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist); -
issm/trunk/src/c/classes/Inputs/SegInput.h
r18301 r19105 69 69 IssmDouble Min(void); 70 70 IssmDouble MinAbs(void){_error_("not implemented yet");}; 71 void Extrude( void){_error_("not supported yet");};71 void Extrude(int start){_error_("not supported yet");}; 72 72 void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");}; 73 73 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){_error_("not implemented yet");}; -
issm/trunk/src/c/classes/Inputs/TetraInput.h
r18301 r19105 69 69 IssmDouble Min(void); 70 70 IssmDouble MinAbs(void); 71 void Extrude( void){_error_("not supported yet");};71 void Extrude(int start){_error_("not supported yet");}; 72 72 void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");}; 73 73 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist); -
issm/trunk/src/c/classes/Inputs/TransientInput.cpp
r18301 r19105 345 345 } 346 346 /*}}}*/ 347 void TransientInput::Extrude( void){/*{{{*/347 void TransientInput::Extrude(int start){/*{{{*/ 348 348 349 349 for(int i=0;i<this->numtimesteps;i++){ 350 ((Input*)this->inputs->GetObjectByOffset(i))->Extrude( );350 ((Input*)this->inputs->GetObjectByOffset(i))->Extrude(start); 351 351 } 352 352 } -
issm/trunk/src/c/classes/Inputs/TransientInput.h
r17806 r19105 42 42 Input* SpawnTriaInput(int index1,int index2,int index3); 43 43 Input* SpawnSegInput(int index1,int index2); 44 Input* PointwiseDivide(Input* forcingB){_error_("not implemented yet");};45 Input* PointwiseMin(Input* forcingB){_error_("not implemented yet");};46 Input* PointwiseMax(Input* forcingB){_error_("not implemented yet");};44 Input* PointwiseDivide(Input* input_in){_error_("not implemented yet");}; 45 Input* PointwiseMin(Input* input_in){_error_("not implemented yet");}; 46 Input* PointwiseMax(Input* input_in){_error_("not implemented yet");}; 47 47 int GetResultInterpolation(void); 48 48 int GetResultNumberOfNodes(void); … … 73 73 IssmDouble Min(void); 74 74 IssmDouble MinAbs(void); 75 void Extrude( void);75 void Extrude(int start); 76 76 void VerticallyIntegrate(Input* thickness_forcing){_error_("not supported yet");}; 77 77 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist); -
issm/trunk/src/c/classes/Inputs/TriaInput.h
r18301 r19105 49 49 void GetInputValue(bool* pvalue){_error_("not implemented yet");} 50 50 void GetInputValue(int* pvalue){_error_("not implemented yet");} 51 void GetInputValue(IssmDouble* pvalue){_error_("not implemented yet ");}51 void GetInputValue(IssmDouble* pvalue){_error_("not implemented yet (Input is "<<EnumToStringx(this->enum_type)<<")");}//{_error_("not implemented yet");} 52 52 void GetInputValue(IssmDouble* pvalue,Gauss* gauss); 53 53 void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");}; … … 69 69 IssmDouble Min(void); 70 70 IssmDouble MinAbs(void); 71 void Extrude( void){_error_("not supported yet");};71 void Extrude(int start){_error_("not supported yet");}; 72 72 void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");}; 73 73 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist); -
issm/trunk/src/c/classes/IoModel.cpp
r18301 r19105 50 50 } 51 51 /*}}}*/ 52 IoModel::IoModel(FILE* iomodel_handle){/*{{{*/ 53 52 IoModel::IoModel(FILE* iomodel_handle,bool trace,IssmPDouble* X){/*{{{*/ 53 54 bool autodiff=false; 55 bool iscontrol=false; 56 54 57 /*First, keep track of the file handle: */ 55 58 this->fid=iomodel_handle; … … 65 68 *and prevent them from being erased during successive calls to iomodel->FetchConstants, iomodel->FetchData and 66 69 iomodel->DeleteData:*/ 67 this->StartTrace( );68 this->DeclareIndependents( );70 this->StartTrace(trace); 71 this->DeclareIndependents(trace,X); 69 72 70 73 /*Initialize and read constants:*/ 71 74 this->constants=new Parameters(); 72 75 this->FetchConstants(); /*this routine goes through the input file, and fetches bools, ints, IssmDoubles and strings only, nothing memory intensive*/ 76 77 /*Now some very specific piece of logic. We want to know whether we are going to carry out an autodiff run. There are 78 *several cases: either trace is true (which bypasses the isautodiff choice), or trace is false but isautodiff is on, in which 79 *case two cases are possible: are we running a control method or not? To make things simpler, we are going to pin down everyting 80 *on isautodiff. By the way, we could not do this before we had the constants dataset initialized! {{{*/ 81 this->constants->FindParam(&autodiff,AutodiffIsautodiffEnum); 82 this->constants->FindParam(&iscontrol,InversionIscontrolEnum); 83 84 if(trace)autodiff=true; 85 else{ 86 if(autodiff && !iscontrol) autodiff=true; 87 else autodiff=false; 88 } 89 this->constants->SetParam(autodiff,AutodiffIsautodiffEnum); 90 /*}}}*/ 73 91 74 92 /*Initialize permanent data: */ … … 108 126 109 127 /*checks in debugging mode*/ 110 #if def _ISSM_DEBUG_128 #if defined(_ISSM_DEBUG_) && !defined(_HAVE_ADOLC_) 111 129 if(this->data){ 112 130 for(int i=0;i<MaximumNumberOfDefinitionsEnum;i++){ … … 259 277 260 278 /*Find constant*/ 261 Param* param= dynamic_cast<Param*>(this->constants->FindParamObject(constant_enum));279 Param* param=xDynamicCast<Param*>(this->constants->FindParamObject(constant_enum)); 262 280 if(!param) _error_("Constant " << EnumToStringx(constant_enum) << " not found in iomodel"); 263 281 264 return dynamic_cast<Param*>(param->copy());282 return xDynamicCast<Param*>(param->copy()); 265 283 } 266 284 /*}}}*/ … … 273 291 } 274 292 /*}}}*/ 275 void IoModel::StartTrace( void){/*{{{*/293 void IoModel::StartTrace(bool trace){/*{{{*/ 276 294 277 295 bool autodiff = false; 296 bool iscontrol = false; 278 297 bool keep=false; 279 298 IssmDouble gcTriggerRatio; … … 287 306 288 307 this->FetchData(&autodiff,AutodiffIsautodiffEnum); 289 if(autodiff){ 290 308 this->FetchData(&iscontrol,InversionIscontrolEnum); 309 310 if(trace || (autodiff && !iscontrol)){ 291 311 #ifdef _HAVE_ADOLC_ 292 312 /*Retrieve parameters: */ … … 311 331 } 312 332 /*}}}*/ 313 void IoModel::DeclareIndependents( void){/*{{{*/333 void IoModel::DeclareIndependents(bool trace,IssmPDouble* X){/*{{{*/ 314 334 315 335 int i; 316 336 bool autodiff = false; 337 bool iscontrol = false; 317 338 int num_independent_objects; 339 int Xcount=0; 318 340 319 341 int *names = NULL; … … 327 349 328 350 this->FetchData(&autodiff,AutodiffIsautodiffEnum); 329 if(autodiff){ 351 this->FetchData(&iscontrol,InversionIscontrolEnum); 352 353 if(trace || (autodiff && !iscontrol)){ 330 354 331 355 #ifdef _HAVE_ADOLC_ … … 348 372 349 373 /*now go fetch the independent variable: */ 350 independent_object->FetchIndependent(this ); //supply the pointer to iomodel.374 independent_object->FetchIndependent(this,&Xcount,X); //supply the pointer to iomodel. 351 375 } 352 376 xDelete<int>(names); … … 1229 1253 } 1230 1254 /*}}}*/ 1255 void IoModel::FetchMultipleData(IssmDouble** pvector, int* pnum_instances,int data_enum){/*{{{*/ 1256 1257 int num_instances; 1258 fpos_t* file_positions=NULL; 1259 1260 /*output: */ 1261 IssmDouble* vector=NULL; 1262 1263 /*intermediary: */ 1264 IssmPDouble scalar; 1265 int *codes = NULL; 1266 int code; 1267 1268 /*recover my_rank:*/ 1269 int my_rank=IssmComm::GetRank(); 1270 1271 /*Get file pointers to beginning of the data (multiple instances of it): */ 1272 file_positions=this->SetFilePointersToData(&codes,NULL,&num_instances,data_enum); 1273 1274 if(num_instances){ 1275 1276 /*Allocate vector :*/ 1277 vector=xNew<IssmDouble>(num_instances); 1278 1279 for(int i=0;i<num_instances;i++){ 1280 1281 if(my_rank==0){ 1282 code=codes[i]; 1283 1284 if(code!=3)_error_("expecting a double for enum " << EnumToStringx(data_enum)); 1285 1286 /*We have to read a double from disk: */ 1287 fsetpos(fid,file_positions+i); 1288 if(my_rank==0){ 1289 if(fread(&scalar,sizeof(IssmPDouble),1,fid)!=1) _error_("could not read scalar "); 1290 } 1291 } 1292 ISSM_MPI_Bcast(&scalar,1,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm()); 1293 1294 /*Assign: */ 1295 vector[i]=scalar; 1296 } 1297 } 1298 1299 /*Free ressources:*/ 1300 xDelete<fpos_t>(file_positions); 1301 xDelete<int>(codes); 1302 1303 /*Assign output pointers: */ 1304 *pvector=vector; 1305 *pnum_instances=num_instances; 1306 } 1307 /*}}}*/ 1231 1308 void IoModel::FetchMultipleData(IssmDouble*** pmatrices,int** pmdims,int** pndims, int* pnumrecords,int data_enum){/*{{{*/ 1232 1309 … … 1455 1532 1456 1533 for(int i=0;i<elements->Size();i++){ 1457 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));1534 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 1458 1535 if(!doublearray) element->AddInput(vector_enum,&default_value,P0Enum); 1459 1536 else element->InputCreate(doublearray,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements. … … 1485 1562 this->FetchData(&boolean,vector_enum); 1486 1563 for(i=0;i<elements->Size();i++){ 1487 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));1564 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 1488 1565 element->InputUpdateFromConstant(boolean,vector_enum); 1489 1566 } … … 1492 1569 this->FetchData(&integer,vector_enum); 1493 1570 for(i=0;i<elements->Size();i++){ 1494 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));1571 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 1495 1572 element->InputUpdateFromConstant(integer,vector_enum); 1496 1573 } … … 1499 1576 this->FetchData(&scalar,vector_enum); 1500 1577 for(i=0;i<elements->Size();i++){ 1501 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));1578 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 1502 1579 element->InputUpdateFromConstant(scalar,vector_enum); 1503 1580 } … … 1507 1584 if(!doublearray) _error_(EnumToStringx(vector_enum)<<" not found in binary file"); 1508 1585 for(i=0;i<elements->Size();i++){ 1509 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));1586 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 1510 1587 element->InputCreate(doublearray,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements. 1511 1588 } … … 1515 1592 if(!doublearray) _error_(EnumToStringx(vector_enum)<<" not found in binary file"); 1516 1593 for(i=0;i<elements->Size();i++){ 1517 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));1594 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 1518 1595 element->InputCreate(doublearray,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements. 1519 1596 } … … 1523 1600 if(!doublearray) _error_(EnumToStringx(vector_enum)<<" not found in binary file"); 1524 1601 for(i=0;i<elements->Size();i++){ 1525 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));1602 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 1526 1603 element->InputCreate(doublearray,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements. 1527 1604 } -
issm/trunk/src/c/classes/IoModel.h
r17989 r19105 59 59 ~IoModel(); 60 60 IoModel(); 61 IoModel(FILE* iomodel_handle );61 IoModel(FILE* iomodel_handle,bool trace,IssmPDouble* X); 62 62 63 63 /*Input/Output*/ … … 85 85 void FetchMultipleData(int*** pmatrices,int** pmdims,int** pndims, int* pnumrecords,int data_enum); 86 86 void FetchMultipleData(int** pvector, int* pnum_instances,int data_enum); 87 void FetchMultipleData(IssmDouble** pvector, int* pnum_instances,int data_enum); 87 88 void FetchData(Option **poption,int data_enum); 88 89 void FetchData(int num,...); … … 92 93 FILE* SetFilePointerToData(int* pcode,int* pvector_type, int data_enum); 93 94 fpos_t* SetFilePointersToData(int** pcodes,int** pvector_types, int* pnum_instances, int data_enum); 94 void DeclareIndependents( void);95 void StartTrace( void);95 void DeclareIndependents(bool trace,IssmPDouble* X); 96 void StartTrace(bool trace); 96 97 void FetchIndependent(int dependent_enum); 97 98 }; -
issm/trunk/src/c/classes/Loads/Friction.cpp
r18301 r19105 40 40 } 41 41 /*}}}*/ 42 void Friction::GetAlpha 2(IssmDouble* palpha2, Gauss* gauss){/*{{{*/42 void Friction::GetAlphaComplement(IssmDouble* palpha_complement, Gauss* gauss){/*{{{*/ 43 43 44 44 switch(this->law){ 45 45 case 1: 46 GetAlpha2Viscous(palpha2,gauss); 47 break; 48 case 2: 49 GetAlpha2Weertman(palpha2,gauss); 50 break; 51 default: 52 _error_("not supported"); 53 } 54 55 }/*}}}*/ 56 void Friction::GetAlpha2Viscous(IssmDouble* palpha2, Gauss* gauss){/*{{{*/ 57 58 /*This routine calculates the basal friction coefficient 59 alpha2= drag^2 * Neff ^r * | vel | ^(s-1), with Neff=rho_ice*g*thickness+rho_ice*g*bed, r=q/p and s=1/p**/ 46 GetAlphaViscousComplement(palpha_complement,gauss); 47 break; 48 case 3: 49 GetAlphaHydroComplement(palpha_complement,gauss); 50 break; 51 default: 52 _error_("not supported"); 53 } 54 55 }/*}}}*/ 56 57 void Friction::GetAlphaViscousComplement(IssmDouble* palpha_complement, Gauss* gauss){/*{{{*/ 58 59 /* FrictionGetAlpha2 computes alpha2= drag^2 * Neff ^r * vel ^s, with Neff=rho_ice*g*thickness+rho_ice*g*bed, r=q/p and s=1/p. 60 * FrictionGetAlphaComplement is used in control methods on drag, and it computes: 61 * alpha_complement= Neff ^r * vel ^s*/ 60 62 61 63 /*diverse: */ 62 64 IssmDouble r,s; 63 IssmDouble drag_p, drag_q; 65 IssmDouble vx,vy,vz,vmag; 66 IssmDouble drag_p,drag_q; 64 67 IssmDouble Neff; 65 IssmDouble thickness,bed;66 IssmDouble vx,vy,vz,vmag;67 68 IssmDouble drag_coefficient; 68 IssmDouble alpha2; 69 IssmDouble bed,thickness; 70 IssmDouble alpha_complement; 69 71 70 72 /*Recover parameters: */ … … 86 88 if(Neff<0)Neff=0; 87 89 88 switch(dim){ 89 case 1: 90 element->GetInputValue(&vx,gauss,VxEnum); 91 vmag=sqrt(vx*vx); 92 break; 93 case 2: 94 element->GetInputValue(&vx,gauss,VxEnum); 95 element->GetInputValue(&vy,gauss,VyEnum); 96 vmag=sqrt(vx*vx+vy*vy); 97 break; 98 case 3: 99 element->GetInputValue(&vx,gauss,VxEnum); 100 element->GetInputValue(&vy,gauss,VyEnum); 101 element->GetInputValue(&vz,gauss,VzEnum); 102 vmag=sqrt(vx*vx+vy*vy+vz*vz); 103 break; 104 default: 105 _error_("not supported"); 106 } 107 108 /*Check to prevent dividing by zero if vmag==0*/ 109 if(vmag==0. && (s-1.)<0.) alpha2=0.; 110 else alpha2=drag_coefficient*drag_coefficient*pow(Neff,r)*pow(vmag,(s-1.)); 90 //We need the velocity magnitude to evaluate the basal stress: 91 switch(dim){ 92 case 1: 93 element->GetInputValue(&vx,gauss,VxEnum); 94 vmag=sqrt(vx*vx); 95 break; 96 case 2: 97 element->GetInputValue(&vx,gauss,VxEnum); 98 element->GetInputValue(&vy,gauss,VyEnum); 99 vmag=sqrt(vx*vx+vy*vy); 100 break; 101 case 3: 102 element->GetInputValue(&vx,gauss,VxEnum); 103 element->GetInputValue(&vy,gauss,VyEnum); 104 element->GetInputValue(&vz,gauss,VzEnum); 105 vmag=sqrt(vx*vx+vy*vy+vz*vz); 106 break; 107 default: 108 _error_("not supported"); 109 } 110 111 /*Check to prevent dividing by zero if vmag==0*/ 112 if(vmag==0. && (s-1.)<0.) alpha_complement=0.; 113 else alpha_complement=pow(Neff,r)*pow(vmag,(s-1));_assert_(!xIsNan<IssmDouble>(alpha_complement)); 114 115 /*Assign output pointers:*/ 116 *palpha_complement=alpha_complement; 117 } 118 /*}}}*/ 119 void Friction::GetAlphaHydroComplement(IssmDouble* palpha_complement, Gauss* gauss){/*{{{*/ 120 121 /*diverse: */ 122 IssmDouble q_exp; 123 IssmDouble C_param; 124 IssmDouble As; 125 IssmDouble Neff; 126 IssmDouble n; 127 IssmDouble alpha; 128 IssmDouble Chi,Gamma; 129 IssmDouble vx,vy,vz,vmag; 130 IssmDouble alpha_complement; 131 132 /*Recover parameters: */ 133 element->GetInputValue(&q_exp,FrictionQEnum); 134 element->GetInputValue(&C_param,FrictionCEnum); 135 136 element->GetInputValue(&As,gauss,FrictionAsEnum); 137 element->GetInputValue(&Neff,gauss,FrictionEffectivePressureEnum); 138 element->GetInputValue(&n,gauss,MaterialsRheologyNEnum); 139 140 if(Neff<0)Neff=0; 141 142 //We need the velocity magnitude to evaluate the basal stress: 143 switch(dim){ 144 case 1: 145 element->GetInputValue(&vx,gauss,VxEnum); 146 vmag=sqrt(vx*vx); 147 break; 148 case 2: 149 element->GetInputValue(&vx,gauss,VxEnum); 150 element->GetInputValue(&vy,gauss,VyEnum); 151 vmag=sqrt(vx*vx+vy*vy); 152 break; 153 case 3: 154 element->GetInputValue(&vx,gauss,VxEnum); 155 element->GetInputValue(&vy,gauss,VyEnum); 156 element->GetInputValue(&vz,gauss,VzEnum); 157 vmag=sqrt(vx*vx+vy*vy+vz*vz); 158 break; 159 default: 160 _error_("not supported"); 161 } 162 // vmag=100./(3600.*24.*365.); 163 164 if (q_exp==1){ 165 alpha=1; 166 } 167 else{ 168 alpha=(pow(q_exp-1,q_exp-1))/pow(q_exp,q_exp); 169 } 170 Chi = vmag/(pow(C_param,n)*pow(Neff,n)*As); 171 Gamma = (Chi/(1.+alpha*pow(Chi,q_exp))); 172 /*Check to prevent dividing by zero if vmag==0*/ 173 if(vmag==0.) alpha_complement=0.; 174 else if(Neff==0.) alpha_complement=0.; 175 else alpha_complement=-(C_param*Neff/(n*vmag)) * 176 pow(Gamma,((1.-n)/n)) * 177 (Gamma/As - (alpha*q_exp*pow(Chi,q_exp-1.)* Gamma * Gamma/As)); 178 179 _assert_(!xIsNan<IssmDouble>(alpha_complement)); 180 /*Assign output pointers:*/ 181 *palpha_complement=alpha_complement; 182 } 183 /*}}}*/ 184 void Friction::GetAlpha2(IssmDouble* palpha2, Gauss* gauss){/*{{{*/ 185 186 switch(this->law){ 187 case 1: 188 GetAlpha2Viscous(palpha2,gauss); 189 break; 190 case 2: 191 GetAlpha2Weertman(palpha2,gauss); 192 break; 193 case 3: 194 GetAlpha2Hydro(palpha2,gauss); 195 break; 196 case 4: 197 GetAlpha2Temp(palpha2,gauss); 198 break; 199 case 5: 200 GetAlpha2WaterLayer(palpha2,gauss); 201 break; 202 case 6: 203 GetAlpha2WeertmanTemp(palpha2,gauss); 204 break; 205 default: 206 _error_("not supported"); 207 } 208 209 }/*}}}*/ 210 void Friction::GetAlpha2Hydro(IssmDouble* palpha2, Gauss* gauss){/*{{{*/ 211 212 /*This routine calculates the basal friction coefficient 213 Based on Gagliardini 2007, needs a good effective pressure computation 214 Not tested so far so use at your own risks 215 alpha2= NeffC[Chi/(1+alpha*Chi^q)]^(1/n)*1/vel with 216 -Chi=|vel|/(C^n*Neff^n*As) 217 -alpha=(q-1)^(q-1)/q^q **/ 218 219 /*diverse: */ 220 IssmDouble q_exp; 221 IssmDouble C_param; 222 IssmDouble As; 223 224 IssmDouble Neff; 225 IssmDouble n; 226 227 IssmDouble alpha; 228 IssmDouble Chi,Gamma; 229 230 IssmDouble vx,vy,vz,vmag; 231 IssmDouble alpha2; 232 233 /*Recover parameters: */ 234 element->GetInputValue(&q_exp,FrictionQEnum); 235 element->GetInputValue(&C_param,FrictionCEnum); 236 element->GetInputValue(&As,gauss,FrictionAsEnum); 237 238 element->GetInputValue(&Neff,gauss,FrictionEffectivePressureEnum); 239 element->GetInputValue(&n,gauss,MaterialsRheologyNEnum); 240 241 if(Neff<0)Neff=0; 242 243 switch(dim){ 244 case 1: 245 element->GetInputValue(&vx,gauss,VxEnum); 246 vmag=sqrt(vx*vx); 247 break; 248 case 2: 249 element->GetInputValue(&vx,gauss,VxEnum); 250 element->GetInputValue(&vy,gauss,VyEnum); 251 vmag=sqrt(vx*vx+vy*vy); 252 break; 253 case 3: 254 element->GetInputValue(&vx,gauss,VxEnum); 255 element->GetInputValue(&vy,gauss,VyEnum); 256 element->GetInputValue(&vz,gauss,VzEnum); 257 vmag=sqrt(vx*vx+vy*vy+vz*vz); 258 break; 259 default: 260 _error_("not supported"); 261 } 262 263 // vmag=100./(3600.*24.*365.); 264 //compute alpha and Chi coefficients: */ 265 if (q_exp==1){ 266 alpha=1; 267 } 268 else{ 269 alpha=(pow(q_exp-1,q_exp-1))/pow(q_exp,q_exp); 270 } 271 Chi=vmag/(pow(C_param,n)*pow(Neff,n)*As); 272 Gamma=(Chi/(1. + alpha * pow(Chi,q_exp))); 273 /*Check to prevent dividing by zero if vmag==0*/ 274 if(vmag==0.) alpha2=0.; 275 else if (Neff==0) alpha2=0.0; 276 else alpha2=Neff * C_param * pow(Gamma,1./n) * 1/vmag; 277 111 278 _assert_(!xIsNan<IssmDouble>(alpha2)); 112 113 /*Assign output pointers:*/ 114 *palpha2=alpha2; 115 }/*}}}*/ 116 void Friction::GetAlpha2Weertman(IssmDouble* palpha2, Gauss* gauss){/*{{{*/ 117 118 /*This routine calculates the basal friction coefficient alpha2= C^-1/m |v|^(1/m-1) */ 119 120 /*diverse: */ 121 IssmDouble C,m; 122 IssmDouble vx,vy,vz,vmag; 123 IssmDouble alpha2; 124 125 /*Recover parameters: */ 126 element->GetInputValue(&C,gauss,FrictionCEnum); 127 element->GetInputValue(&m,FrictionMEnum); 128 129 switch(dim){ 130 case 1: 131 element->GetInputValue(&vx,gauss,VxEnum); 132 vmag=sqrt(vx*vx); 133 break; 134 case 2: 135 element->GetInputValue(&vx,gauss,VxEnum); 136 element->GetInputValue(&vy,gauss,VyEnum); 137 vmag=sqrt(vx*vx+vy*vy); 138 break; 139 case 3: 140 element->GetInputValue(&vx,gauss,VxEnum); 141 element->GetInputValue(&vy,gauss,VyEnum); 142 element->GetInputValue(&vz,gauss,VzEnum); 143 vmag=sqrt(vx*vx+vy*vy+vz*vz); 144 break; 145 default: 146 _error_("not supported"); 147 } 148 149 /*Check to prevent dividing by zero if vmag==0*/ 150 if(vmag==0. && (1./m-1.)<0.) alpha2=0.; 151 else alpha2=pow(C,-1./m)*pow(vmag,(1./m-1.)); 152 _assert_(!xIsNan<IssmDouble>(alpha2)); 153 154 /*Assign output pointers:*/ 155 *palpha2=alpha2; 156 }/*}}}*/ 157 void Friction::GetAlphaComplement(IssmDouble* palpha_complement, Gauss* gauss){/*{{{*/ 158 159 /* FrictionGetAlpha2 computes alpha2= drag^2 * Neff ^r * vel ^s, with Neff=rho_ice*g*thickness+rho_ice*g*bed, r=q/p and s=1/p. 160 * FrictionGetAlphaComplement is used in control methods on drag, and it computes: 161 * alpha_complement= Neff ^r * vel ^s*/ 162 163 if(this->law!=1)_error_("not supported"); 279 /*Assign output pointers:*/ 280 *palpha2=alpha2; 281 }/*}}}*/ 282 void Friction::GetAlpha2Temp(IssmDouble* palpha2, Gauss* gauss){/*{{{*/ 283 /*Here, we want to parameterize the friction as a function of temperature 284 * 285 * alpha2 = alpha2_viscous * 1/f(T) 286 * 287 * where f(T) = exp((T-Tpmp)/gamma) 288 */ 289 290 /*Intermediaries: */ 291 IssmDouble f,T,pressure,Tpmp,gamma; 292 IssmDouble alpha2; 293 294 /*Get viscous part*/ 295 this->GetAlpha2Viscous(&alpha2,gauss); 296 297 /*Get pressure melting point (Tpmp) for local pressure and get current temperature*/ 298 element->GetInputValue(&T,gauss,TemperatureEnum); 299 element->GetInputValue(&pressure,gauss,PressureEnum); 300 Tpmp = element->TMeltingPoint(pressure); 301 302 /*Compute scaling parameter*/ 303 element->parameters->FindParam(&gamma,FrictionGammaEnum); 304 alpha2 = alpha2 / exp((T-Tpmp)/gamma); 305 306 /*Assign output pointers:*/ 307 *palpha2=alpha2; 308 }/*}}}*/ 309 void Friction::GetAlpha2Viscous(IssmDouble* palpha2, Gauss* gauss){/*{{{*/ 310 311 /*This routine calculates the basal friction coefficient 312 alpha2= drag^2 * Neff ^r * | vel | ^(s-1), with Neff=rho_ice*g*thickness+rho_ice*g*bed, r=q/p and s=1/p**/ 164 313 165 314 /*diverse: */ 166 315 IssmDouble r,s; 167 IssmDouble vx,vy,vz,vmag; 168 IssmDouble drag_p,drag_q; 316 IssmDouble drag_p, drag_q; 169 317 IssmDouble Neff; 318 IssmDouble thickness,bed; 319 IssmDouble vx,vy,vz,vmag; 170 320 IssmDouble drag_coefficient; 171 IssmDouble bed,thickness; 172 IssmDouble alpha_complement; 321 IssmDouble alpha2; 173 322 174 323 /*Recover parameters: */ … … 190 339 if(Neff<0)Neff=0; 191 340 192 //We need the velocity magnitude to evaluate the basal stress: 193 switch(dim){ 194 case 1: 195 element->GetInputValue(&vx,gauss,VxEnum); 196 vmag=sqrt(vx*vx); 197 break; 198 case 2: 199 element->GetInputValue(&vx,gauss,VxEnum); 200 element->GetInputValue(&vy,gauss,VyEnum); 201 vmag=sqrt(vx*vx+vy*vy); 202 break; 203 case 3: 204 element->GetInputValue(&vx,gauss,VxEnum); 205 element->GetInputValue(&vy,gauss,VyEnum); 206 element->GetInputValue(&vz,gauss,VzEnum); 207 vmag=sqrt(vx*vx+vy*vy+vz*vz); 208 break; 209 default: 210 _error_("not supported"); 211 } 212 213 /*Check to prevent dividing by zero if vmag==0*/ 214 if(vmag==0. && (s-1.)<0.) alpha_complement=0.; 215 else alpha_complement=pow(Neff,r)*pow(vmag,(s-1));_assert_(!xIsNan<IssmDouble>(alpha_complement)); 216 217 /*Assign output pointers:*/ 218 *palpha_complement=alpha_complement; 219 } 220 /*}}}*/ 341 switch(dim){ 342 case 1: 343 element->GetInputValue(&vx,gauss,VxEnum); 344 vmag=sqrt(vx*vx); 345 break; 346 case 2: 347 element->GetInputValue(&vx,gauss,VxEnum); 348 element->GetInputValue(&vy,gauss,VyEnum); 349 vmag=sqrt(vx*vx+vy*vy); 350 break; 351 case 3: 352 element->GetInputValue(&vx,gauss,VxEnum); 353 element->GetInputValue(&vy,gauss,VyEnum); 354 element->GetInputValue(&vz,gauss,VzEnum); 355 vmag=sqrt(vx*vx+vy*vy+vz*vz); 356 break; 357 default: 358 _error_("not supported"); 359 } 360 361 /*Check to prevent dividing by zero if vmag==0*/ 362 if(vmag==0. && (s-1.)<0.) alpha2=0.; 363 else alpha2=drag_coefficient*drag_coefficient*pow(Neff,r)*pow(vmag,(s-1.)); 364 _assert_(!xIsNan<IssmDouble>(alpha2)); 365 366 /*Assign output pointers:*/ 367 *palpha2=alpha2; 368 }/*}}}*/ 369 void Friction::GetAlpha2WaterLayer(IssmDouble* palpha2, Gauss* gauss){/*{{{*/ 370 371 /*This routine calculates the basal friction coefficient 372 alpha2= drag^2 * Neff ^r * | vel | ^(s-1), with Neff=rho_ice*g*thickness+rho_ice*g*bed, r=q/p and s=1/p**/ 373 374 /*diverse: */ 375 IssmDouble r,s; 376 IssmDouble drag_p, drag_q; 377 IssmDouble Neff; 378 IssmDouble thickness,bed; 379 IssmDouble vx,vy,vz,vmag; 380 IssmDouble drag_coefficient,water_layer; 381 IssmDouble alpha2; 382 383 /*Recover parameters: */ 384 element->GetInputValue(&drag_p,FrictionPEnum); 385 element->GetInputValue(&drag_q,FrictionQEnum); 386 element->GetInputValue(&thickness, gauss,ThicknessEnum); 387 element->GetInputValue(&bed, gauss,BaseEnum); 388 element->GetInputValue(&drag_coefficient, gauss,FrictionCoefficientEnum); 389 element->GetInputValue(&water_layer, gauss,FrictionWaterLayerEnum); 390 IssmDouble rho_water = element->GetMaterialParameter(MaterialsRhoSeawaterEnum); 391 IssmDouble rho_ice = element->GetMaterialParameter(MaterialsRhoIceEnum); 392 IssmDouble gravity = element->GetMaterialParameter(ConstantsGEnum); 393 394 //compute r and q coefficients: */ 395 r=drag_q/drag_p; 396 s=1./drag_p; 397 398 //From bed and thickness, compute effective pressure when drag is viscous: 399 if(bed>0) bed=0; 400 Neff=gravity*(rho_ice*thickness+rho_water*(bed-water_layer)); 401 if(Neff<0) Neff=0; 402 403 switch(dim){ 404 case 1: 405 element->GetInputValue(&vx,gauss,VxEnum); 406 vmag=sqrt(vx*vx); 407 break; 408 case 2: 409 element->GetInputValue(&vx,gauss,VxEnum); 410 element->GetInputValue(&vy,gauss,VyEnum); 411 vmag=sqrt(vx*vx+vy*vy); 412 break; 413 case 3: 414 element->GetInputValue(&vx,gauss,VxEnum); 415 element->GetInputValue(&vy,gauss,VyEnum); 416 element->GetInputValue(&vz,gauss,VzEnum); 417 vmag=sqrt(vx*vx+vy*vy+vz*vz); 418 break; 419 default: 420 _error_("not supported"); 421 } 422 423 /*Check to prevent dividing by zero if vmag==0*/ 424 if(vmag==0. && (s-1.)<0.) alpha2=0.; 425 else alpha2=drag_coefficient*drag_coefficient*pow(Neff,r)*pow(vmag,(s-1.)); 426 _assert_(!xIsNan<IssmDouble>(alpha2)); 427 428 /*Assign output pointers:*/ 429 *palpha2=alpha2; 430 }/*}}}*/ 431 void Friction::GetAlpha2Weertman(IssmDouble* palpha2, Gauss* gauss){/*{{{*/ 432 433 /*This routine calculates the basal friction coefficient alpha2= C^-1/m |v|^(1/m-1) */ 434 435 /*diverse: */ 436 IssmDouble C,m; 437 IssmDouble vx,vy,vz,vmag; 438 IssmDouble alpha2; 439 440 /*Recover parameters: */ 441 element->GetInputValue(&C,gauss,FrictionCEnum); 442 element->GetInputValue(&m,FrictionMEnum); 443 444 switch(dim){ 445 case 1: 446 element->GetInputValue(&vx,gauss,VxEnum); 447 vmag=sqrt(vx*vx); 448 break; 449 case 2: 450 element->GetInputValue(&vx,gauss,VxEnum); 451 element->GetInputValue(&vy,gauss,VyEnum); 452 vmag=sqrt(vx*vx+vy*vy); 453 break; 454 case 3: 455 element->GetInputValue(&vx,gauss,VxEnum); 456 element->GetInputValue(&vy,gauss,VyEnum); 457 element->GetInputValue(&vz,gauss,VzEnum); 458 vmag=sqrt(vx*vx+vy*vy+vz*vz); 459 break; 460 default: 461 _error_("not supported"); 462 } 463 464 /*Check to prevent dividing by zero if vmag==0*/ 465 if(vmag==0. && (1./m-1.)<0.) alpha2=0.; 466 else alpha2=pow(C,-1./m)*pow(vmag,(1./m-1.)); 467 _assert_(!xIsNan<IssmDouble>(alpha2)); 468 469 /*Assign output pointers:*/ 470 *palpha2=alpha2; 471 }/*}}}*/ 472 void Friction::GetAlpha2WeertmanTemp(IssmDouble* palpha2, Gauss* gauss){/*{{{*/ 473 /*Here, we want to parameterize the friction as a function of temperature 474 * 475 * alpha2 = alpha2_weertman * 1/f(T) 476 * 477 * where f(T) = exp((T-Tpmp)/gamma) 478 */ 479 480 /*Intermediaries: */ 481 IssmDouble f,T,pressure,Tpmp,gamma; 482 IssmDouble alpha2; 483 484 /*Get viscous part*/ 485 this->GetAlpha2Weertman(&alpha2,gauss); 486 487 /*Get pressure melting point (Tpmp) for local pressure and get current temperature*/ 488 element->GetInputValue(&T,gauss,TemperatureEnum); 489 element->GetInputValue(&pressure,gauss,PressureEnum); 490 Tpmp = element->TMeltingPoint(pressure); 491 492 /*Compute scaling parameter*/ 493 element->parameters->FindParam(&gamma,FrictionGammaEnum); 494 alpha2 = alpha2 / exp((T-Tpmp)/gamma); 495 496 /*Assign output pointers:*/ 497 *palpha2=alpha2; 498 }/*}}}*/ -
issm/trunk/src/c/classes/Loads/Friction.h
r17989 r19105 29 29 30 30 void Echo(void); 31 void GetAlphaComplement(IssmDouble* alpha_complement,Gauss* gauss); 32 void GetAlphaViscousComplement(IssmDouble* alpha_complement,Gauss* gauss); 33 void GetAlphaHydroComplement(IssmDouble* alpha_complement,Gauss* gauss); 31 34 void GetAlpha2(IssmDouble* palpha2,Gauss* gauss); 35 void GetAlpha2Hydro(IssmDouble* palpha2,Gauss* gauss); 36 void GetAlpha2Temp(IssmDouble* palpha2,Gauss* gauss); 32 37 void GetAlpha2Viscous(IssmDouble* palpha2,Gauss* gauss); 38 void GetAlpha2WaterLayer(IssmDouble* palpha2,Gauss* gauss); 33 39 void GetAlpha2Weertman(IssmDouble* palpha2,Gauss* gauss); 34 void GetAlpha Complement(IssmDouble* alpha_complement,Gauss* gauss);40 void GetAlpha2WeertmanTemp(IssmDouble* palpha2,Gauss* gauss); 35 41 }; 36 42 -
issm/trunk/src/c/classes/Loads/Load.h
r18301 r19105 26 26 virtual ~Load(){}; 27 27 virtual void Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters)=0; 28 virtual void ResetHooks()=0; 29 virtual bool IsPenalty(void)=0; 30 virtual int GetNumberOfNodes(void)=0; 31 virtual void GetNodesSidList(int* sidlist)=0; 32 virtual void GetNodesLidList(int* lidlist)=0; 33 virtual void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters)=0; 28 virtual void CreateJacobianMatrix(Matrix<IssmDouble>* Jff)=0; 34 29 virtual void CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs)=0; 35 30 virtual void CreatePVector(Vector<IssmDouble>* pf)=0; 36 virtual void CreateJacobianMatrix(Matrix<IssmDouble>* Jff)=0; 31 virtual void GetNodesLidList(int* lidlist)=0; 32 virtual void GetNodesSidList(int* sidlist)=0; 33 virtual int GetNumberOfNodes(void)=0; 34 virtual bool InAnalysis(int analysis_type)=0; 35 virtual bool IsPenalty(void)=0; 37 36 virtual void PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax)=0; 38 37 virtual void PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs, IssmDouble kmax)=0; 39 38 virtual void PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax)=0; 40 virtual bool InAnalysis(int analysis_type)=0; 39 virtual void ResetHooks()=0; 40 virtual void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters)=0; 41 41 virtual void SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum)=0; 42 42 }; -
issm/trunk/src/c/classes/Loads/Loads.cpp
r18301 r19105 41 41 for ( object=objects.begin() ; object < objects.end(); object++ ){ 42 42 43 load= dynamic_cast<Load*>(*object);43 load=xDynamicCast<Load*>(*object); 44 44 load->Configure(elements,loads,nodes,vertices,materials,parameters); 45 46 }47 48 }49 /*}}}*/50 void Loads::ResetHooks(){/*{{{*/51 52 vector<Object*>::iterator object;53 Load* load=NULL;54 55 for ( object=objects.begin() ; object < objects.end(); object++ ){56 57 load=dynamic_cast<Load*>((*object));58 load->ResetHooks();59 45 60 46 } … … 70 56 for(int i=0;i<this->Size();i++){ 71 57 72 Load* load= dynamic_cast<Load*>(this->GetObjectByOffset(i));58 Load* load=xDynamicCast<Load*>(this->GetObjectByOffset(i)); 73 59 if (load->InAnalysis(analysis_type)){ 74 60 if(load->IsPenalty()) ispenalty++; … … 86 72 } 87 73 /*}}}*/ 88 int Loads::MaxNumNodes(int analysis_type){/*{{{*/74 int Loads::MaxNumNodes(int analysis_type){/*{{{*/ 89 75 90 76 int max=0; … … 95 81 for(int i=0;i<this->Size();i++){ 96 82 97 Load* load= dynamic_cast<Load*>(this->GetObjectByOffset(i));83 Load* load=xDynamicCast<Load*>(this->GetObjectByOffset(i)); 98 84 if (load->InAnalysis(analysis_type)){ 99 85 numnodes=load->GetNumberOfNodes(); … … 109 95 } 110 96 /*}}}*/ 111 int Loads::NumberOfLoads(void){/*{{{*/97 int Loads::NumberOfLoads(void){/*{{{*/ 112 98 113 99 int localloads; … … 124 110 } 125 111 /*}}}*/ 126 int Loads::NumberOfLoads(int analysis_type){/*{{{*/112 int Loads::NumberOfLoads(int analysis_type){/*{{{*/ 127 113 128 114 int localloads = 0; … … 132 118 for(int i=0;i<this->Size();i++){ 133 119 134 Load* load= dynamic_cast<Load*>(this->GetObjectByOffset(i));120 Load* load=xDynamicCast<Load*>(this->GetObjectByOffset(i)); 135 121 136 122 /*Check that this load corresponds to our analysis currently being carried out: */ … … 145 131 } 146 132 /*}}}*/ 147 int Loads::Size(void){/*{{{*/133 void Loads::ResetHooks(){/*{{{*/ 148 134 149 return this->DataSet::Size(); 150 } 151 /*}}}*/ 152 int Loads::Size(int analysis_type){/*{{{*/ 135 vector<Object*>::iterator object; 136 Load* load=NULL; 153 137 154 int localloads = 0;138 for ( object=objects.begin() ; object < objects.end(); object++ ){ 155 139 156 /*Get number of local loads*/157 for(int i=0;i<this->Size();i++){140 load=xDynamicCast<Load*>((*object)); 141 load->ResetHooks(); 158 142 159 Load* load=dynamic_cast<Load*>(this->GetObjectByOffset(i));160 161 /*Check that this load corresponds to our analysis currently being carried out: */162 if (load->InAnalysis(analysis_type)) localloads++;163 143 } 164 144 165 return localloads;166 145 } 167 146 /*}}}*/ … … 173 152 for ( object=objects.begin() ; object < objects.end(); object++ ){ 174 153 175 load= dynamic_cast<Load*>(*object);154 load=xDynamicCast<Load*>(*object); 176 155 load->SetCurrentConfiguration(elements,loads,nodes,vertices,materials,parameters); 177 156 … … 180 159 } 181 160 /*}}}*/ 161 int Loads::Size(void){/*{{{*/ 162 163 return this->DataSet::Size(); 164 } 165 /*}}}*/ 166 int Loads::Size(int analysis_type){/*{{{*/ 167 168 int localloads = 0; 169 170 /*Get number of local loads*/ 171 for(int i=0;i<this->Size();i++){ 172 173 Load* load=xDynamicCast<Load*>(this->GetObjectByOffset(i)); 174 175 /*Check that this load corresponds to our analysis currently being carried out: */ 176 if (load->InAnalysis(analysis_type)) localloads++; 177 } 178 179 return localloads; 180 } 181 /*}}}*/ -
issm/trunk/src/c/classes/Loads/Loads.h
r18301 r19105 24 24 /*numerics*/ 25 25 void Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters); 26 void ResetHooks();27 26 bool IsPenalty(int analysis); 28 27 int MaxNumNodes(int analysis); 29 28 int NumberOfLoads(void); 30 29 int NumberOfLoads(int analysis); 30 void ResetHooks(); 31 31 void SetCurrentConfiguration(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters); 32 32 int Size(int analysis); -
issm/trunk/src/c/classes/Loads/Numericalflux.cpp
r18301 r19105 131 131 132 132 /*Object virtual functions definitions:*/ 133 void Numericalflux::Echo(void){/*{{{*/ 134 _printf_("Numericalflux:\n"); 135 _printf_(" id: " << id << "\n"); 136 _printf_(" analysis_type: " << EnumToStringx(analysis_type) << "\n"); 137 _printf_(" flux_type: " << this->flux_type<< "\n"); 138 hnodes->Echo(); 139 hvertices->Echo(); 140 helement->Echo(); 141 _printf_(" parameters: " << parameters << "\n"); 142 } 143 /*}}}*/ 144 void Numericalflux::DeepEcho(void){/*{{{*/ 133 Object* Numericalflux::copy() {/*{{{*/ 134 135 Numericalflux* numericalflux=NULL; 136 137 numericalflux=new Numericalflux(); 138 139 /*copy fields: */ 140 numericalflux->id=this->id; 141 numericalflux->analysis_type=this->analysis_type; 142 numericalflux->flux_type=this->flux_type; 143 144 /*point parameters: */ 145 numericalflux->parameters=this->parameters; 146 147 /*now deal with hooks and objects: */ 148 numericalflux->hnodes = (Hook*)this->hnodes->copy(); 149 numericalflux->hvertices = (Hook*)this->hvertices->copy(); 150 numericalflux->helement = (Hook*)this->helement->copy(); 151 152 /*corresponding fields*/ 153 numericalflux->nodes = (Node**)numericalflux->hnodes->deliverp(); 154 numericalflux->vertices = (Vertex**)numericalflux->hvertices->deliverp(); 155 numericalflux->element = (Element*)numericalflux->helement->delivers(); 156 157 return numericalflux; 158 } 159 /*}}}*/ 160 void Numericalflux::DeepEcho(void){/*{{{*/ 145 161 146 162 _printf_("Numericalflux:\n"); … … 158 174 } 159 175 /*}}}*/ 160 int Numericalflux::Id(void){/*{{{*/ 176 void Numericalflux::Echo(void){/*{{{*/ 177 _printf_("Numericalflux:\n"); 178 _printf_(" id: " << id << "\n"); 179 _printf_(" analysis_type: " << EnumToStringx(analysis_type) << "\n"); 180 _printf_(" flux_type: " << this->flux_type<< "\n"); 181 hnodes->Echo(); 182 hvertices->Echo(); 183 helement->Echo(); 184 _printf_(" parameters: " << parameters << "\n"); 185 } 186 /*}}}*/ 187 int Numericalflux::Id(void){/*{{{*/ 161 188 return id; 162 189 } 163 190 /*}}}*/ 164 int Numericalflux::ObjectEnum(void){/*{{{*/191 int Numericalflux::ObjectEnum(void){/*{{{*/ 165 192 166 193 return NumericalfluxEnum; 167 194 168 }169 /*}}}*/170 Object* Numericalflux::copy() {/*{{{*/171 172 Numericalflux* numericalflux=NULL;173 174 numericalflux=new Numericalflux();175 176 /*copy fields: */177 numericalflux->id=this->id;178 numericalflux->analysis_type=this->analysis_type;179 numericalflux->flux_type=this->flux_type;180 181 /*point parameters: */182 numericalflux->parameters=this->parameters;183 184 /*now deal with hooks and objects: */185 numericalflux->hnodes = (Hook*)this->hnodes->copy();186 numericalflux->hvertices = (Hook*)this->hvertices->copy();187 numericalflux->helement = (Hook*)this->helement->copy();188 189 /*corresponding fields*/190 numericalflux->nodes = (Node**)numericalflux->hnodes->deliverp();191 numericalflux->vertices = (Vertex**)numericalflux->hvertices->deliverp();192 numericalflux->element = (Element*)numericalflux->helement->delivers();193 194 return numericalflux;195 195 } 196 196 /*}}}*/ … … 212 212 /*point parameters to real dataset: */ 213 213 this->parameters=parametersin; 214 }215 /*}}}*/216 void Numericalflux::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){/*{{{*/217 218 }219 /*}}}*/220 void Numericalflux::ResetHooks(){/*{{{*/221 222 this->nodes=NULL;223 this->vertices=NULL;224 this->element=NULL;225 this->parameters=NULL;226 227 /*Get Element type*/228 this->hnodes->reset();229 this->hvertices->reset();230 this->helement->reset();231 232 214 } 233 215 /*}}}*/ … … 291 273 } 292 274 /*}}}*/ 275 void Numericalflux::GetNodesLidList(int* lidlist){/*{{{*/ 276 277 _assert_(lidlist); 278 _assert_(nodes); 279 280 switch(this->flux_type){ 281 case InternalEnum: 282 for(int i=0;i<NUMNODES_INTERNAL;i++) lidlist[i]=nodes[i]->Lid(); 283 return; 284 case BoundaryEnum: 285 for(int i=0;i<NUMNODES_BOUNDARY;i++) lidlist[i]=nodes[i]->Lid(); 286 return; 287 default: 288 _error_("Numericalflux type " << EnumToStringx(this->flux_type) << " not supported yet"); 289 } 290 } 291 /*}}}*/ 293 292 void Numericalflux::GetNodesSidList(int* sidlist){/*{{{*/ 294 293 … … 308 307 } 309 308 /*}}}*/ 310 void Numericalflux::GetNodesLidList(int* lidlist){/*{{{*/311 312 _assert_(lidlist);313 _assert_(nodes);314 315 switch(this->flux_type){316 case InternalEnum:317 for(int i=0;i<NUMNODES_INTERNAL;i++) lidlist[i]=nodes[i]->Lid();318 return;319 case BoundaryEnum:320 for(int i=0;i<NUMNODES_BOUNDARY;i++) lidlist[i]=nodes[i]->Lid();321 return;322 default:323 _error_("Numericalflux type " << EnumToStringx(this->flux_type) << " not supported yet");324 }325 }326 /*}}}*/327 309 int Numericalflux::GetNumberOfNodes(void){/*{{{*/ 328 310 … … 338 320 } 339 321 /*}}}*/ 340 bool Numericalflux::IsPenalty(void){/*{{{*/341 return false;342 }343 /*}}}*/344 void Numericalflux::PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs,IssmDouble kmax){/*{{{*/345 346 /*No stiffness loads applied, do nothing: */347 return;348 349 }350 /*}}}*/351 void Numericalflux::PenaltyCreatePVector(Vector<IssmDouble>* pf,IssmDouble kmax){/*{{{*/352 353 /*No penalty loads applied, do nothing: */354 return;355 356 }357 /*}}}*/358 322 bool Numericalflux::InAnalysis(int in_analysis_type){/*{{{*/ 359 323 if (in_analysis_type==this->analysis_type) return true; 360 324 else return false; 325 } 326 /*}}}*/ 327 bool Numericalflux::IsPenalty(void){/*{{{*/ 328 return false; 329 } 330 /*}}}*/ 331 void Numericalflux::PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs,IssmDouble kmax){/*{{{*/ 332 333 /*No stiffness loads applied, do nothing: */ 334 return; 335 336 } 337 /*}}}*/ 338 void Numericalflux::PenaltyCreatePVector(Vector<IssmDouble>* pf,IssmDouble kmax){/*{{{*/ 339 340 /*No penalty loads applied, do nothing: */ 341 return; 342 343 } 344 /*}}}*/ 345 void Numericalflux::ResetHooks(){/*{{{*/ 346 347 this->nodes=NULL; 348 this->vertices=NULL; 349 this->element=NULL; 350 this->parameters=NULL; 351 352 /*Get Element type*/ 353 this->hnodes->reset(); 354 this->hvertices->reset(); 355 this->helement->reset(); 356 357 } 358 /*}}}*/ 359 void Numericalflux::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){/*{{{*/ 360 361 361 } 362 362 /*}}}*/ … … 417 417 418 418 /*Numericalflux management*/ 419 ElementMatrix* Numericalflux::CreateKMatrixAdjointBalancethickness(void){/*{{{*/ 420 421 switch(this->flux_type){ 422 case InternalEnum: 423 return CreateKMatrixAdjointBalancethicknessInternal(); 424 case BoundaryEnum: 425 return CreateKMatrixAdjointBalancethicknessBoundary(); 426 default: 427 _error_("type not supported yet"); 428 } 429 } 430 /*}}}*/ 431 ElementMatrix* Numericalflux::CreateKMatrixAdjointBalancethicknessBoundary(void){/*{{{*/ 432 433 ElementMatrix* Ke=CreateKMatrixBalancethicknessBoundary(); 434 if(Ke) Ke->Transpose(); 435 return Ke; 436 } 437 /*}}}*/ 438 ElementMatrix* Numericalflux::CreateKMatrixAdjointBalancethicknessInternal(void){/*{{{*/ 439 440 ElementMatrix* Ke=CreateKMatrixBalancethicknessInternal(); 441 if (Ke) Ke->Transpose(); 442 return Ke; 443 } 444 /*}}}*/ 445 ElementMatrix* Numericalflux::CreateKMatrixBalancethickness(void){/*{{{*/ 446 447 switch(this->flux_type){ 448 case InternalEnum: 449 return CreateKMatrixBalancethicknessInternal(); 450 case BoundaryEnum: 451 return CreateKMatrixBalancethicknessBoundary(); 452 default: 453 _error_("type not supported yet"); 454 } 455 } 456 /*}}}*/ 457 ElementMatrix* Numericalflux::CreateKMatrixBalancethicknessBoundary(void){/*{{{*/ 458 459 /* constants*/ 460 const int numdof=NDOF1*NUMNODES_BOUNDARY; 461 462 /* Intermediaries*/ 463 int i,j,ig,index1,index2; 464 IssmDouble DL,Jdet,vx,vy,mean_vx,mean_vy,UdotN; 465 IssmDouble xyz_list[NUMVERTICES][3]; 466 IssmDouble normal[2]; 467 IssmDouble L[numdof]; 468 IssmDouble Ke_g[numdof][numdof]; 469 GaussTria *gauss; 470 471 /*Initialize Element matrix and return if necessary*/ 472 ElementMatrix* Ke = NULL; 473 Tria* tria=(Tria*)element; 474 if(!tria->IsIceInElement()) return NULL; 475 476 /*Retrieve all inputs and parameters*/ 477 GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 478 Input* vxaverage_input=tria->inputs->GetInput(VxEnum); 479 Input* vyaverage_input=tria->inputs->GetInput(VyEnum); 480 GetNormal(&normal[0],xyz_list); 481 482 /*Check wether it is an inflow or outflow BC (0 is the middle of the segment)*/ 483 index1=tria->GetNodeIndex(nodes[0]); 484 index2=tria->GetNodeIndex(nodes[1]); 485 486 gauss=new GaussTria(); 487 gauss->GaussEdgeCenter(index1,index2); 488 vxaverage_input->GetInputValue(&mean_vx,gauss); 489 vyaverage_input->GetInputValue(&mean_vy,gauss); 490 delete gauss; 491 492 UdotN=mean_vx*normal[0]+mean_vy*normal[1]; 493 if (UdotN<=0){ 494 return NULL; /*(u,n)<0 -> inflow, PenaltyCreatePVector will take care of it*/ 495 } 496 else{ 497 Ke=new ElementMatrix(nodes,NUMNODES_BOUNDARY,this->parameters); 498 } 499 500 /* Start looping on the number of gaussian points: */ 501 gauss=new GaussTria(index1,index2,2); 502 for(ig=gauss->begin();ig<gauss->end();ig++){ 503 504 gauss->GaussPoint(ig); 505 506 tria->GetSegmentNodalFunctions(&L[0],gauss,index1,index2,tria->FiniteElement()); 507 508 vxaverage_input->GetInputValue(&vx,gauss); 509 vyaverage_input->GetInputValue(&vy,gauss); 510 UdotN=vx*normal[0]+vy*normal[1]; 511 tria->GetSegmentJacobianDeterminant(&Jdet,&xyz_list[0][0],gauss); 512 DL=gauss->weight*Jdet*UdotN; 513 514 TripleMultiply(&L[0],1,numdof,1, 515 &DL,1,1,0, 516 &L[0],1,numdof,0, 517 &Ke_g[0][0],0); 518 519 for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[i*numdof+j]+=Ke_g[i][j]; 520 } 521 522 /*Clean up and return*/ 523 delete gauss; 524 return Ke; 525 } 526 /*}}}*/ 527 ElementMatrix* Numericalflux::CreateKMatrixBalancethicknessInternal(void){/*{{{*/ 528 529 /* constants*/ 530 const int numdof=NDOF1*NUMNODES_INTERNAL; 531 532 /* Intermediaries*/ 533 int i,j,ig,index1,index2; 534 IssmDouble DL1,DL2,Jdet,vx,vy,UdotN; 535 IssmDouble xyz_list[NUMVERTICES][3]; 536 IssmDouble normal[2]; 537 IssmDouble B[numdof]; 538 IssmDouble Bprime[numdof]; 539 IssmDouble Ke_g1[numdof][numdof]; 540 IssmDouble Ke_g2[numdof][numdof]; 541 GaussTria *gauss; 542 543 /*Initialize Element matrix and return if necessary*/ 544 Tria* tria=(Tria*)element; 545 if(!tria->IsIceInElement()) return NULL; 546 ElementMatrix* Ke=new ElementMatrix(nodes,NUMNODES_INTERNAL,this->parameters); 547 548 /*Retrieve all inputs and parameters*/ 549 GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 550 Input* vxaverage_input=tria->inputs->GetInput(VxEnum); 551 Input* vyaverage_input=tria->inputs->GetInput(VyEnum); 552 GetNormal(&normal[0],xyz_list); 553 554 /* Start looping on the number of gaussian points: */ 555 index1=tria->GetNodeIndex(nodes[0]); 556 index2=tria->GetNodeIndex(nodes[1]); 557 gauss=new GaussTria(index1,index2,2); 558 for(ig=gauss->begin();ig<gauss->end();ig++){ 559 560 gauss->GaussPoint(ig); 561 562 tria->GetSegmentBFlux(&B[0],gauss,index1,index2,tria->FiniteElement()); 563 tria->GetSegmentBprimeFlux(&Bprime[0],gauss,index1,index2,tria->FiniteElement()); 564 565 vxaverage_input->GetInputValue(&vx,gauss); 566 vyaverage_input->GetInputValue(&vy,gauss); 567 UdotN=vx*normal[0]+vy*normal[1]; 568 tria->GetSegmentJacobianDeterminant(&Jdet,&xyz_list[0][0],gauss); 569 DL1=gauss->weight*Jdet*UdotN/2; 570 DL2=gauss->weight*Jdet*fabs(UdotN)/2; 571 572 TripleMultiply(&B[0],1,numdof,1, 573 &DL1,1,1,0, 574 &Bprime[0],1,numdof,0, 575 &Ke_g1[0][0],0); 576 TripleMultiply(&B[0],1,numdof,1, 577 &DL2,1,1,0, 578 &B[0],1,numdof,0, 579 &Ke_g2[0][0],0); 580 581 for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[i*numdof+j]+=Ke_g1[i][j]; 582 for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[i*numdof+j]+=Ke_g2[i][j]; 583 } 584 585 /*Clean up and return*/ 586 delete gauss; 587 return Ke; 588 } 589 /*}}}*/ 419 590 ElementMatrix* Numericalflux::CreateKMatrixMasstransport(void){/*{{{*/ 420 591 … … 427 598 _error_("type not supported yet"); 428 599 } 600 } 601 /*}}}*/ 602 ElementMatrix* Numericalflux::CreateKMatrixMasstransportBoundary(void){/*{{{*/ 603 604 /* constants*/ 605 const int numdof=NDOF1*NUMNODES_BOUNDARY; 606 607 /* Intermediaries*/ 608 int i,j,ig,index1,index2; 609 IssmDouble DL,Jdet,dt,vx,vy,mean_vx,mean_vy,UdotN; 610 IssmDouble xyz_list[NUMVERTICES][3]; 611 IssmDouble normal[2]; 612 IssmDouble L[numdof]; 613 IssmDouble Ke_g[numdof][numdof]; 614 GaussTria *gauss; 615 616 /*Initialize Element matrix and return if necessary*/ 617 ElementMatrix* Ke = NULL; 618 Tria* tria=(Tria*)element; 619 if(!tria->IsIceInElement()) return NULL; 620 621 /*Retrieve all inputs and parameters*/ 622 GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 623 parameters->FindParam(&dt,TimesteppingTimeStepEnum); 624 Input* vxaverage_input=tria->inputs->GetInput(VxEnum); _assert_(vxaverage_input); 625 Input* vyaverage_input=tria->inputs->GetInput(VyEnum); _assert_(vyaverage_input); 626 GetNormal(&normal[0],xyz_list); 627 628 /*Check wether it is an inflow or outflow BC (0 is the middle of the segment)*/ 629 index1=tria->GetNodeIndex(nodes[0]); 630 index2=tria->GetNodeIndex(nodes[1]); 631 632 gauss=new GaussTria(); 633 gauss->GaussEdgeCenter(index1,index2); 634 vxaverage_input->GetInputValue(&mean_vx,gauss); 635 vyaverage_input->GetInputValue(&mean_vy,gauss); 636 delete gauss; 637 638 UdotN=mean_vx*normal[0]+mean_vy*normal[1]; 639 if (UdotN<=0){ 640 return NULL; /*(u,n)<0 -> inflow, PenaltyCreatePVector will take care of it*/ 641 } 642 else{ 643 Ke=new ElementMatrix(nodes,NUMNODES_BOUNDARY,this->parameters); 644 } 645 646 /* Start looping on the number of gaussian points: */ 647 gauss=new GaussTria(index1,index2,2); 648 for(ig=gauss->begin();ig<gauss->end();ig++){ 649 650 gauss->GaussPoint(ig); 651 652 tria->GetSegmentNodalFunctions(&L[0],gauss,index1,index2,tria->FiniteElement()); 653 654 vxaverage_input->GetInputValue(&vx,gauss); 655 vyaverage_input->GetInputValue(&vy,gauss); 656 UdotN=vx*normal[0]+vy*normal[1]; 657 tria->GetSegmentJacobianDeterminant(&Jdet,&xyz_list[0][0],gauss); 658 DL=gauss->weight*Jdet*dt*UdotN; 659 660 TripleMultiply(&L[0],1,numdof,1, 661 &DL,1,1,0, 662 &L[0],1,numdof,0, 663 &Ke_g[0][0],0); 664 665 for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[i*numdof+j]+=Ke_g[i][j]; 666 } 667 668 /*Clean up and return*/ 669 delete gauss; 670 return Ke; 429 671 } 430 672 /*}}}*/ … … 493 735 } 494 736 /*}}}*/ 495 ElementMatrix* Numericalflux::CreateKMatrixMasstransportBoundary(void){/*{{{*/ 496 497 /* constants*/ 498 const int numdof=NDOF1*NUMNODES_BOUNDARY; 499 500 /* Intermediaries*/ 501 int i,j,ig,index1,index2; 502 IssmDouble DL,Jdet,dt,vx,vy,mean_vx,mean_vy,UdotN; 503 IssmDouble xyz_list[NUMVERTICES][3]; 504 IssmDouble normal[2]; 505 IssmDouble L[numdof]; 506 IssmDouble Ke_g[numdof][numdof]; 507 GaussTria *gauss; 508 509 /*Initialize Element matrix and return if necessary*/ 510 ElementMatrix* Ke = NULL; 511 Tria* tria=(Tria*)element; 512 if(!tria->IsIceInElement()) return NULL; 513 514 /*Retrieve all inputs and parameters*/ 515 GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 516 parameters->FindParam(&dt,TimesteppingTimeStepEnum); 517 Input* vxaverage_input=tria->inputs->GetInput(VxEnum); _assert_(vxaverage_input); 518 Input* vyaverage_input=tria->inputs->GetInput(VyEnum); _assert_(vyaverage_input); 519 GetNormal(&normal[0],xyz_list); 520 521 /*Check wether it is an inflow or outflow BC (0 is the middle of the segment)*/ 522 index1=tria->GetNodeIndex(nodes[0]); 523 index2=tria->GetNodeIndex(nodes[1]); 524 525 gauss=new GaussTria(); 526 gauss->GaussEdgeCenter(index1,index2); 527 vxaverage_input->GetInputValue(&mean_vx,gauss); 528 vyaverage_input->GetInputValue(&mean_vy,gauss); 529 delete gauss; 530 531 UdotN=mean_vx*normal[0]+mean_vy*normal[1]; 532 if (UdotN<=0){ 533 return NULL; /*(u,n)<0 -> inflow, PenaltyCreatePVector will take care of it*/ 534 } 535 else{ 536 Ke=new ElementMatrix(nodes,NUMNODES_BOUNDARY,this->parameters); 537 } 538 539 /* Start looping on the number of gaussian points: */ 540 gauss=new GaussTria(index1,index2,2); 541 for(ig=gauss->begin();ig<gauss->end();ig++){ 542 543 gauss->GaussPoint(ig); 544 545 tria->GetSegmentNodalFunctions(&L[0],gauss,index1,index2,tria->FiniteElement()); 546 547 vxaverage_input->GetInputValue(&vx,gauss); 548 vyaverage_input->GetInputValue(&vy,gauss); 549 UdotN=vx*normal[0]+vy*normal[1]; 550 tria->GetSegmentJacobianDeterminant(&Jdet,&xyz_list[0][0],gauss); 551 DL=gauss->weight*Jdet*dt*UdotN; 552 553 TripleMultiply(&L[0],1,numdof,1, 554 &DL,1,1,0, 555 &L[0],1,numdof,0, 556 &Ke_g[0][0],0); 557 558 for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[i*numdof+j]+=Ke_g[i][j]; 559 } 560 561 /*Clean up and return*/ 562 delete gauss; 563 return Ke; 564 } 565 /*}}}*/ 566 ElementMatrix* Numericalflux::CreateKMatrixBalancethickness(void){/*{{{*/ 567 568 switch(this->flux_type){ 569 case InternalEnum: 570 return CreateKMatrixBalancethicknessInternal(); 571 case BoundaryEnum: 572 return CreateKMatrixBalancethicknessBoundary(); 573 default: 574 _error_("type not supported yet"); 575 } 576 } 577 /*}}}*/ 578 ElementMatrix* Numericalflux::CreateKMatrixBalancethicknessInternal(void){/*{{{*/ 579 580 /* constants*/ 581 const int numdof=NDOF1*NUMNODES_INTERNAL; 582 583 /* Intermediaries*/ 584 int i,j,ig,index1,index2; 585 IssmDouble DL1,DL2,Jdet,vx,vy,UdotN; 586 IssmDouble xyz_list[NUMVERTICES][3]; 587 IssmDouble normal[2]; 588 IssmDouble B[numdof]; 589 IssmDouble Bprime[numdof]; 590 IssmDouble Ke_g1[numdof][numdof]; 591 IssmDouble Ke_g2[numdof][numdof]; 592 GaussTria *gauss; 593 594 /*Initialize Element matrix and return if necessary*/ 595 Tria* tria=(Tria*)element; 596 if(!tria->IsIceInElement()) return NULL; 597 ElementMatrix* Ke=new ElementMatrix(nodes,NUMNODES_INTERNAL,this->parameters); 598 599 /*Retrieve all inputs and parameters*/ 600 GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 601 Input* vxaverage_input=tria->inputs->GetInput(VxEnum); 602 Input* vyaverage_input=tria->inputs->GetInput(VyEnum); 603 GetNormal(&normal[0],xyz_list); 604 605 /* Start looping on the number of gaussian points: */ 606 index1=tria->GetNodeIndex(nodes[0]); 607 index2=tria->GetNodeIndex(nodes[1]); 608 gauss=new GaussTria(index1,index2,2); 609 for(ig=gauss->begin();ig<gauss->end();ig++){ 610 611 gauss->GaussPoint(ig); 612 613 tria->GetSegmentBFlux(&B[0],gauss,index1,index2,tria->FiniteElement()); 614 tria->GetSegmentBprimeFlux(&Bprime[0],gauss,index1,index2,tria->FiniteElement()); 615 616 vxaverage_input->GetInputValue(&vx,gauss); 617 vyaverage_input->GetInputValue(&vy,gauss); 618 UdotN=vx*normal[0]+vy*normal[1]; 619 tria->GetSegmentJacobianDeterminant(&Jdet,&xyz_list[0][0],gauss); 620 DL1=gauss->weight*Jdet*UdotN/2; 621 DL2=gauss->weight*Jdet*fabs(UdotN)/2; 622 623 TripleMultiply(&B[0],1,numdof,1, 624 &DL1,1,1,0, 625 &Bprime[0],1,numdof,0, 626 &Ke_g1[0][0],0); 627 TripleMultiply(&B[0],1,numdof,1, 628 &DL2,1,1,0, 629 &B[0],1,numdof,0, 630 &Ke_g2[0][0],0); 631 632 for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[i*numdof+j]+=Ke_g1[i][j]; 633 for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[i*numdof+j]+=Ke_g2[i][j]; 634 } 635 636 /*Clean up and return*/ 637 delete gauss; 638 return Ke; 639 } 640 /*}}}*/ 641 ElementMatrix* Numericalflux::CreateKMatrixBalancethicknessBoundary(void){/*{{{*/ 642 643 /* constants*/ 644 const int numdof=NDOF1*NUMNODES_BOUNDARY; 645 646 /* Intermediaries*/ 647 int i,j,ig,index1,index2; 648 IssmDouble DL,Jdet,vx,vy,mean_vx,mean_vy,UdotN; 649 IssmDouble xyz_list[NUMVERTICES][3]; 650 IssmDouble normal[2]; 651 IssmDouble L[numdof]; 652 IssmDouble Ke_g[numdof][numdof]; 653 GaussTria *gauss; 654 655 /*Initialize Element matrix and return if necessary*/ 656 ElementMatrix* Ke = NULL; 657 Tria* tria=(Tria*)element; 658 if(!tria->IsIceInElement()) return NULL; 659 660 /*Retrieve all inputs and parameters*/ 661 GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 662 Input* vxaverage_input=tria->inputs->GetInput(VxEnum); 663 Input* vyaverage_input=tria->inputs->GetInput(VyEnum); 664 GetNormal(&normal[0],xyz_list); 665 666 /*Check wether it is an inflow or outflow BC (0 is the middle of the segment)*/ 667 index1=tria->GetNodeIndex(nodes[0]); 668 index2=tria->GetNodeIndex(nodes[1]); 669 670 gauss=new GaussTria(); 671 gauss->GaussEdgeCenter(index1,index2); 672 vxaverage_input->GetInputValue(&mean_vx,gauss); 673 vyaverage_input->GetInputValue(&mean_vy,gauss); 674 delete gauss; 675 676 UdotN=mean_vx*normal[0]+mean_vy*normal[1]; 677 if (UdotN<=0){ 678 return NULL; /*(u,n)<0 -> inflow, PenaltyCreatePVector will take care of it*/ 679 } 680 else{ 681 Ke=new ElementMatrix(nodes,NUMNODES_BOUNDARY,this->parameters); 682 } 683 684 /* Start looping on the number of gaussian points: */ 685 gauss=new GaussTria(index1,index2,2); 686 for(ig=gauss->begin();ig<gauss->end();ig++){ 687 688 gauss->GaussPoint(ig); 689 690 tria->GetSegmentNodalFunctions(&L[0],gauss,index1,index2,tria->FiniteElement()); 691 692 vxaverage_input->GetInputValue(&vx,gauss); 693 vyaverage_input->GetInputValue(&vy,gauss); 694 UdotN=vx*normal[0]+vy*normal[1]; 695 tria->GetSegmentJacobianDeterminant(&Jdet,&xyz_list[0][0],gauss); 696 DL=gauss->weight*Jdet*UdotN; 697 698 TripleMultiply(&L[0],1,numdof,1, 699 &DL,1,1,0, 700 &L[0],1,numdof,0, 701 &Ke_g[0][0],0); 702 703 for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[i*numdof+j]+=Ke_g[i][j]; 704 } 705 706 /*Clean up and return*/ 707 delete gauss; 708 return Ke; 709 } 710 /*}}}*/ 711 ElementMatrix* Numericalflux::CreateKMatrixAdjointBalancethickness(void){/*{{{*/ 712 713 switch(this->flux_type){ 714 case InternalEnum: 715 return CreateKMatrixAdjointBalancethicknessInternal(); 716 case BoundaryEnum: 717 return CreateKMatrixAdjointBalancethicknessBoundary(); 718 default: 719 _error_("type not supported yet"); 720 } 721 } 722 /*}}}*/ 723 ElementMatrix* Numericalflux::CreateKMatrixAdjointBalancethicknessInternal(void){/*{{{*/ 724 725 ElementMatrix* Ke=CreateKMatrixBalancethicknessInternal(); 726 if (Ke) Ke->Transpose(); 727 return Ke; 728 } 729 /*}}}*/ 730 ElementMatrix* Numericalflux::CreateKMatrixAdjointBalancethicknessBoundary(void){/*{{{*/ 731 732 ElementMatrix* Ke=CreateKMatrixBalancethicknessBoundary(); 733 if(Ke) Ke->Transpose(); 734 return Ke; 735 } 736 /*}}}*/ 737 ElementVector* Numericalflux::CreatePVectorMasstransport(void){/*{{{*/ 738 739 switch(this->flux_type){ 740 case InternalEnum: 741 return CreatePVectorMasstransportInternal(); 742 case BoundaryEnum: 743 return CreatePVectorMasstransportBoundary(); 744 default: 745 _error_("type not supported yet"); 746 } 747 } 748 /*}}}*/ 749 ElementVector* Numericalflux::CreatePVectorMasstransportInternal(void){/*{{{*/ 750 751 /*Nothing added to PVector*/ 737 ElementVector* Numericalflux::CreatePVectorAdjointBalancethickness(void){/*{{{*/ 738 739 /*No PVector for the Adjoint*/ 752 740 return NULL; 753 754 }755 /*}}}*/756 ElementVector* Numericalflux::CreatePVectorMasstransportBoundary(void){/*{{{*/757 758 /* constants*/759 const int numdof=NDOF1*NUMNODES_BOUNDARY;760 761 /* Intermediaries*/762 int i,ig,index1,index2;763 IssmDouble DL,Jdet,dt,vx,vy,mean_vx,mean_vy,UdotN,thickness;764 IssmDouble xyz_list[NUMVERTICES][3];765 IssmDouble normal[2];766 IssmDouble L[numdof];767 GaussTria *gauss;768 769 /*Initialize Load Vector and return if necessary*/770 ElementVector* pe = NULL;771 Tria* tria=(Tria*)element;772 if(!tria->IsIceInElement()) return NULL;773 774 /*Retrieve all inputs and parameters*/775 GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES);776 parameters->FindParam(&dt,TimesteppingTimeStepEnum);777 Input* vxaverage_input =tria->inputs->GetInput(VxEnum); _assert_(vxaverage_input);778 Input* vyaverage_input =tria->inputs->GetInput(VyEnum); _assert_(vyaverage_input);779 Input* spcthickness_input=tria->inputs->GetInput(MasstransportSpcthicknessEnum); _assert_(spcthickness_input);780 GetNormal(&normal[0],xyz_list);781 782 /*Check wether it is an inflow or outflow BC (0 is the middle of the segment)*/783 index1=tria->GetNodeIndex(nodes[0]);784 index2=tria->GetNodeIndex(nodes[1]);785 786 gauss=new GaussTria();787 gauss->GaussEdgeCenter(index1,index2);788 vxaverage_input->GetInputValue(&mean_vx,gauss);789 vyaverage_input->GetInputValue(&mean_vy,gauss);790 delete gauss;791 792 UdotN=mean_vx*normal[0]+mean_vy*normal[1];793 if (UdotN>0){794 return NULL; /*(u,n)>0 -> outflow, PenaltyCreateKMatrix will take care of it*/795 }796 else{797 pe=new ElementVector(nodes,NUMNODES_BOUNDARY,this->parameters);798 }799 800 /* Start looping on the number of gaussian points: */801 gauss=new GaussTria(index1,index2,2);802 for(ig=gauss->begin();ig<gauss->end();ig++){803 804 gauss->GaussPoint(ig);805 806 tria->GetSegmentNodalFunctions(&L[0],gauss,index1,index2,tria->FiniteElement());807 808 vxaverage_input->GetInputValue(&vx,gauss);809 vyaverage_input->GetInputValue(&vy,gauss);810 spcthickness_input->GetInputValue(&thickness,gauss);811 if(xIsNan<IssmDouble>(thickness)) _error_("Cannot weakly apply constraint because NaN was provided");812 813 UdotN=vx*normal[0]+vy*normal[1];814 tria->GetSegmentJacobianDeterminant(&Jdet,&xyz_list[0][0],gauss);815 DL= - gauss->weight*Jdet*dt*UdotN*thickness;816 817 for(i=0;i<numdof;i++) pe->values[i] += DL*L[i];818 }819 820 /*Clean up and return*/821 delete gauss;822 return pe;823 741 } 824 742 /*}}}*/ … … 833 751 _error_("type not supported yet"); 834 752 } 835 }836 /*}}}*/837 ElementVector* Numericalflux::CreatePVectorBalancethicknessInternal(void){/*{{{*/838 839 /*Nothing added to PVector*/840 return NULL;841 842 753 } 843 754 /*}}}*/ … … 908 819 } 909 820 /*}}}*/ 910 ElementVector* Numericalflux::CreatePVector AdjointBalancethickness(void){/*{{{*/911 912 /*No PVector for the Adjoint*/821 ElementVector* Numericalflux::CreatePVectorBalancethicknessInternal(void){/*{{{*/ 822 823 /*Nothing added to PVector*/ 913 824 return NULL; 914 } 915 /*}}}*/ 916 void Numericalflux:: GetNormal(IssmDouble* normal,IssmDouble xyz_list[4][3]){/*{{{*/ 825 826 } 827 /*}}}*/ 828 ElementVector* Numericalflux::CreatePVectorMasstransport(void){/*{{{*/ 829 830 switch(this->flux_type){ 831 case InternalEnum: 832 return CreatePVectorMasstransportInternal(); 833 case BoundaryEnum: 834 return CreatePVectorMasstransportBoundary(); 835 default: 836 _error_("type not supported yet"); 837 } 838 } 839 /*}}}*/ 840 ElementVector* Numericalflux::CreatePVectorMasstransportBoundary(void){/*{{{*/ 841 842 /* constants*/ 843 const int numdof=NDOF1*NUMNODES_BOUNDARY; 844 845 /* Intermediaries*/ 846 int i,ig,index1,index2; 847 IssmDouble DL,Jdet,dt,vx,vy,mean_vx,mean_vy,UdotN,thickness; 848 IssmDouble xyz_list[NUMVERTICES][3]; 849 IssmDouble normal[2]; 850 IssmDouble L[numdof]; 851 GaussTria *gauss; 852 853 /*Initialize Load Vector and return if necessary*/ 854 ElementVector* pe = NULL; 855 Tria* tria=(Tria*)element; 856 if(!tria->IsIceInElement()) return NULL; 857 858 /*Retrieve all inputs and parameters*/ 859 GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 860 parameters->FindParam(&dt,TimesteppingTimeStepEnum); 861 Input* vxaverage_input =tria->inputs->GetInput(VxEnum); _assert_(vxaverage_input); 862 Input* vyaverage_input =tria->inputs->GetInput(VyEnum); _assert_(vyaverage_input); 863 Input* spcthickness_input=tria->inputs->GetInput(MasstransportSpcthicknessEnum); _assert_(spcthickness_input); 864 GetNormal(&normal[0],xyz_list); 865 866 /*Check wether it is an inflow or outflow BC (0 is the middle of the segment)*/ 867 index1=tria->GetNodeIndex(nodes[0]); 868 index2=tria->GetNodeIndex(nodes[1]); 869 870 gauss=new GaussTria(); 871 gauss->GaussEdgeCenter(index1,index2); 872 vxaverage_input->GetInputValue(&mean_vx,gauss); 873 vyaverage_input->GetInputValue(&mean_vy,gauss); 874 delete gauss; 875 876 UdotN=mean_vx*normal[0]+mean_vy*normal[1]; 877 if (UdotN>0){ 878 return NULL; /*(u,n)>0 -> outflow, PenaltyCreateKMatrix will take care of it*/ 879 } 880 else{ 881 pe=new ElementVector(nodes,NUMNODES_BOUNDARY,this->parameters); 882 } 883 884 /* Start looping on the number of gaussian points: */ 885 gauss=new GaussTria(index1,index2,2); 886 for(ig=gauss->begin();ig<gauss->end();ig++){ 887 888 gauss->GaussPoint(ig); 889 890 tria->GetSegmentNodalFunctions(&L[0],gauss,index1,index2,tria->FiniteElement()); 891 892 vxaverage_input->GetInputValue(&vx,gauss); 893 vyaverage_input->GetInputValue(&vy,gauss); 894 spcthickness_input->GetInputValue(&thickness,gauss); 895 if(xIsNan<IssmDouble>(thickness)) _error_("Cannot weakly apply constraint because NaN was provided"); 896 897 UdotN=vx*normal[0]+vy*normal[1]; 898 tria->GetSegmentJacobianDeterminant(&Jdet,&xyz_list[0][0],gauss); 899 DL= - gauss->weight*Jdet*dt*UdotN*thickness; 900 901 for(i=0;i<numdof;i++) pe->values[i] += DL*L[i]; 902 } 903 904 /*Clean up and return*/ 905 delete gauss; 906 return pe; 907 } 908 /*}}}*/ 909 ElementVector* Numericalflux::CreatePVectorMasstransportInternal(void){/*{{{*/ 910 911 /*Nothing added to PVector*/ 912 return NULL; 913 914 } 915 /*}}}*/ 916 void Numericalflux::GetNormal(IssmDouble* normal,IssmDouble xyz_list[4][3]){/*{{{*/ 917 917 918 918 /*Build unit outward pointing vector*/ -
issm/trunk/src/c/classes/Loads/Numericalflux.h
r18301 r19105 40 40 /*}}}*/ 41 41 /*Object virtual functions definitions:{{{ */ 42 Object *copy(); 43 void DeepEcho(); 42 44 void Echo(); 43 void DeepEcho();44 45 int Id(); 45 46 int ObjectEnum(); 46 Object *copy();47 47 /*}}}*/ 48 48 /*Update virtual functions resolution: {{{*/ 49 void InputUpdateFromVector(IssmDouble* vector, int name, int type){/*Do nothing*/}50 void InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type){/*Do nothing*/}51 void InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){/*Do nothing*/}52 49 void InputUpdateFromConstant(IssmDouble constant, int name){/*Do nothing*/}; 53 50 void InputUpdateFromConstant(int constant, int name){/*Do nothing*/}; 54 51 void InputUpdateFromConstant(bool constant, int name){_error_("Not implemented yet!");} 55 52 void InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("not implemented yet");}; 53 void InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type){/*Do nothing*/} 54 void InputUpdateFromVector(IssmDouble* vector, int name, int type){/*Do nothing*/} 55 void InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){/*Do nothing*/} 56 56 /*}}}*/ 57 57 /*Load virtual functions definitions: {{{*/ 58 58 void Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 59 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 60 void ResetHooks(); 59 void CreateJacobianMatrix(Matrix<IssmDouble>* Jff){_error_("Not implemented yet");}; 61 60 void CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs); 62 61 void CreatePVector(Vector<IssmDouble>* pf); 62 void GetNodesLidList(int* lidlist); 63 63 void GetNodesSidList(int* sidlist); 64 void GetNodesLidList(int* lidlist);65 64 int GetNumberOfNodes(void); 66 void CreateJacobianMatrix(Matrix<IssmDouble>* Jff){_error_("Not implemented yet");};65 bool InAnalysis(int analysis_type); 67 66 bool IsPenalty(void); 68 67 void PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax){_error_("Not implemented yet");}; 69 68 void PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* kfs, IssmDouble kmax); 70 69 void PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax); 70 void ResetHooks(); 71 71 void SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum); 72 bool InAnalysis(int analysis_type);72 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 73 73 /*}}}*/ 74 74 /*Numericalflux management:{{{*/ 75 ElementMatrix* CreateKMatrixAdjointBalancethickness(void); 76 ElementMatrix* CreateKMatrixAdjointBalancethicknessBoundary(void); 77 ElementMatrix* CreateKMatrixAdjointBalancethicknessInternal(void); 78 ElementMatrix* CreateKMatrixBalancethickness(void); 79 ElementMatrix* CreateKMatrixBalancethicknessBoundary(void); 80 ElementMatrix* CreateKMatrixBalancethicknessInternal(void); 81 ElementMatrix* CreateKMatrixMasstransport(void); 82 ElementMatrix* CreateKMatrixMasstransportBoundary(void); 83 ElementMatrix* CreateKMatrixMasstransportInternal(void); 84 ElementVector* CreatePVectorAdjointBalancethickness(void); 85 ElementVector* CreatePVectorBalancethickness(void); 86 ElementVector* CreatePVectorBalancethicknessBoundary(void); 87 ElementVector* CreatePVectorBalancethicknessInternal(void); 88 ElementVector* CreatePVectorMasstransport(void); 89 ElementVector* CreatePVectorMasstransportBoundary(void); 90 ElementVector* CreatePVectorMasstransportInternal(void); 75 91 void GetNormal(IssmDouble* normal,IssmDouble xyz_list[4][3]); 76 ElementMatrix* CreateKMatrixMasstransport(void);77 ElementMatrix* CreateKMatrixMasstransportInternal(void);78 ElementMatrix* CreateKMatrixMasstransportBoundary(void);79 ElementMatrix* CreateKMatrixBalancethickness(void);80 ElementMatrix* CreateKMatrixBalancethicknessInternal(void);81 ElementMatrix* CreateKMatrixBalancethicknessBoundary(void);82 ElementMatrix* CreateKMatrixAdjointBalancethickness(void);83 ElementMatrix* CreateKMatrixAdjointBalancethicknessInternal(void);84 ElementMatrix* CreateKMatrixAdjointBalancethicknessBoundary(void);85 ElementVector* CreatePVectorMasstransport(void);86 ElementVector* CreatePVectorMasstransportInternal(void);87 ElementVector* CreatePVectorMasstransportBoundary(void);88 ElementVector* CreatePVectorBalancethickness(void);89 ElementVector* CreatePVectorBalancethicknessInternal(void);90 ElementVector* CreatePVectorBalancethicknessBoundary(void);91 ElementVector* CreatePVectorAdjointBalancethickness(void);92 92 /*}}}*/ 93 93 -
issm/trunk/src/c/classes/Loads/Pengrid.cpp
r18301 r19105 81 81 82 82 /*Object virtual functions definitions:*/ 83 void Pengrid::Echo(void){/*{{{*/ 84 this->DeepEcho(); 85 } 86 /*}}}*/ 87 void Pengrid::DeepEcho(void){/*{{{*/ 83 Object* Pengrid::copy() {/*{{{*/ 84 85 Pengrid* pengrid=NULL; 86 87 pengrid=new Pengrid(); 88 89 /*copy fields: */ 90 pengrid->id=this->id; 91 pengrid->analysis_type=this->analysis_type; 92 93 /*point parameters: */ 94 pengrid->parameters=this->parameters; 95 96 /*now deal with hooks and objects: */ 97 pengrid->hnode=(Hook*)this->hnode->copy(); 98 pengrid->hmatpar=(Hook*)this->hmatpar->copy(); 99 pengrid->helement=(Hook*)this->helement->copy(); 100 101 /*corresponding fields*/ 102 pengrid->node =(Node*)pengrid->hnode->delivers(); 103 pengrid->matpar =(Matpar*)pengrid->hmatpar->delivers(); 104 pengrid->element=(Element*)pengrid->helement->delivers(); 105 106 //let's not forget internals 107 pengrid->active=this->active=0; 108 pengrid->zigzag_counter=this->zigzag_counter=0; 109 110 return pengrid; 111 112 } 113 /*}}}*/ 114 void Pengrid::DeepEcho(void){/*{{{*/ 88 115 89 116 _printf_("Pengrid:\n"); … … 99 126 } 100 127 /*}}}*/ 101 int Pengrid::Id(void){ return id; }/*{{{*/ 102 /*}}}*/ 103 int Pengrid::ObjectEnum(void){/*{{{*/ 128 void Pengrid::Echo(void){/*{{{*/ 129 this->DeepEcho(); 130 } 131 /*}}}*/ 132 int Pengrid::Id(void){ return id; }/*{{{*/ 133 /*}}}*/ 134 int Pengrid::ObjectEnum(void){/*{{{*/ 104 135 105 136 return PengridEnum; 106 }107 /*}}}*/108 Object* Pengrid::copy() {/*{{{*/109 110 Pengrid* pengrid=NULL;111 112 pengrid=new Pengrid();113 114 /*copy fields: */115 pengrid->id=this->id;116 pengrid->analysis_type=this->analysis_type;117 118 /*point parameters: */119 pengrid->parameters=this->parameters;120 121 /*now deal with hooks and objects: */122 pengrid->hnode=(Hook*)this->hnode->copy();123 pengrid->hmatpar=(Hook*)this->hmatpar->copy();124 pengrid->helement=(Hook*)this->helement->copy();125 126 /*corresponding fields*/127 pengrid->node =(Node*)pengrid->hnode->delivers();128 pengrid->matpar =(Matpar*)pengrid->hmatpar->delivers();129 pengrid->element=(Element*)pengrid->helement->delivers();130 131 //let's not forget internals132 pengrid->active=this->active=0;133 pengrid->zigzag_counter=this->zigzag_counter=0;134 135 return pengrid;136 137 137 } 138 138 /*}}}*/ … … 154 154 /*point parameters to real dataset: */ 155 155 this->parameters=parametersin; 156 }157 /*}}}*/158 void Pengrid::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){/*{{{*/159 160 }161 /*}}}*/162 void Pengrid::ResetHooks(){/*{{{*/163 164 this->node=NULL;165 this->element=NULL;166 this->matpar=NULL;167 this->parameters=NULL;168 169 /*Get Element type*/170 this->hnode->reset();171 this->helement->reset();172 this->hmatpar->reset();173 174 156 } 175 157 /*}}}*/ … … 203 185 } 204 186 /*}}}*/ 187 void Pengrid::GetNodesLidList(int* lidlist){/*{{{*/ 188 189 _assert_(lidlist); 190 _assert_(node); 191 192 lidlist[0]=node->Lid(); 193 } 194 /*}}}*/ 205 195 void Pengrid::GetNodesSidList(int* sidlist){/*{{{*/ 206 196 … … 211 201 } 212 202 /*}}}*/ 213 void Pengrid::GetNodesLidList(int* lidlist){/*{{{*/214 215 _assert_(lidlist);216 _assert_(node);217 218 lidlist[0]=node->Lid();219 }220 /*}}}*/221 203 int Pengrid::GetNumberOfNodes(void){/*{{{*/ 222 204 223 205 return NUMVERTICES; 206 } 207 /*}}}*/ 208 bool Pengrid::InAnalysis(int in_analysis_type){/*{{{*/ 209 if (in_analysis_type==this->analysis_type)return true; 210 else return false; 211 } 212 /*}}}*/ 213 bool Pengrid::IsPenalty(void){/*{{{*/ 214 return true; 224 215 } 225 216 /*}}}*/ … … 282 273 } 283 274 /*}}}*/ 284 bool Pengrid::InAnalysis(int in_analysis_type){/*{{{*/ 285 if (in_analysis_type==this->analysis_type)return true; 286 else return false; 287 } 288 /*}}}*/ 289 bool Pengrid::IsPenalty(void){/*{{{*/ 290 return true; 275 void Pengrid::ResetHooks(){/*{{{*/ 276 277 this->node=NULL; 278 this->element=NULL; 279 this->matpar=NULL; 280 this->parameters=NULL; 281 282 /*Get Element type*/ 283 this->hnode->reset(); 284 this->helement->reset(); 285 this->hmatpar->reset(); 286 287 } 288 /*}}}*/ 289 void Pengrid::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){/*{{{*/ 290 291 291 } 292 292 /*}}}*/ … … 343 343 344 344 /*Update virtual functions definitions:*/ 345 void Pengrid::InputUpdateFromVector(IssmDouble* vector, int name, int type){/*{{{*/346 /*Nothing updated yet*/347 }348 /*}}}*/349 void Pengrid::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type){/*{{{*/350 /*Nothing updated yet*/351 }352 /*}}}*/353 void Pengrid::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){/*{{{*/354 /*Nothing updated yet*/355 }356 /*}}}*/357 345 void Pengrid::InputUpdateFromConstant(IssmDouble constant, int name){/*{{{*/ 358 346 /*Nothing*/ … … 374 362 } 375 363 /*}}}*/ 364 void Pengrid::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type){/*{{{*/ 365 /*Nothing updated yet*/ 366 } 367 /*}}}*/ 368 void Pengrid::InputUpdateFromVector(IssmDouble* vector, int name, int type){/*{{{*/ 369 /*Nothing updated yet*/ 370 } 371 /*}}}*/ 372 void Pengrid::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){/*{{{*/ 373 /*Nothing updated yet*/ 374 } 375 /*}}}*/ 376 376 377 377 /*Pengrid management:*/ 378 void Pengrid::ConstraintActivate(int* punstable){/*{{{*/378 void Pengrid::ConstraintActivate(int* punstable){/*{{{*/ 379 379 380 380 int analysis_type; … … 404 404 } 405 405 /*}}}*/ 406 void Pengrid::ConstraintActivateThermal(int* punstable){/*{{{*/ 407 408 // The penalty is stable if it doesn't change during to successive iterations. 409 IssmDouble pressure; 410 IssmDouble temperature; 411 IssmDouble t_pmp; 412 int new_active; 413 int unstable=0; 414 int penalty_lock; 415 416 /*recover pointers: */ 417 Penta* penta=(Penta*)element; 418 419 /*check that pengrid is not a clone (penalty to be added only once)*/ 420 if (node->IsClone()){ 421 unstable=0; 422 *punstable=unstable; 423 return; 424 } 425 426 //First recover pressure and temperature values, using the element: */ 427 penta->GetInputValue(&pressure,node,PressureEnum); 428 penta->GetInputValue(&temperature,node,TemperaturePicardEnum); 429 430 //Recover our data: 431 parameters->FindParam(&penalty_lock,ThermalPenaltyLockEnum); 432 433 //Compute pressure melting point 434 t_pmp=matpar->TMeltingPoint(pressure); 435 436 //Figure out if temperature is over melting_point, in which case, this penalty needs to be activated. 437 438 if (temperature>t_pmp){ 439 new_active=1; 440 } 441 else{ 442 new_active=0; 443 } 444 445 //Figure out stability of this penalty 446 if (active==new_active){ 447 unstable=0; 448 } 449 else{ 450 unstable=1; 451 if(penalty_lock)zigzag_counter++; 452 } 453 454 /*If penalty keeps zigzagging more than 5 times: */ 455 if(penalty_lock){ 456 if(zigzag_counter>penalty_lock){ 457 unstable=0; 458 active=1; 459 } 460 } 461 462 //Set penalty flag 463 active=new_active; 464 465 //*Assign output pointers:*/ 466 *punstable=unstable; 467 } 468 /*}}}*/ 469 ElementMatrix* Pengrid::PenaltyCreateKMatrixMelting(IssmDouble kmax){/*{{{*/ 470 471 IssmDouble pressure,temperature,t_pmp; 472 IssmDouble penalty_factor; 473 474 Penta* penta=(Penta*)element; 475 476 /*check that pengrid is not a clone (penalty to be added only once)*/ 477 if (node->IsClone()) return NULL; 478 ElementMatrix* Ke=new ElementMatrix(&node,1,this->parameters); 479 480 /*Retrieve all parameters*/ 481 penta->GetInputValue(&pressure,node,PressureEnum); 482 penta->GetInputValue(&temperature,node,TemperatureEnum); 483 parameters->FindParam(&penalty_factor,ThermalPenaltyFactorEnum); 484 485 /*Compute pressure melting point*/ 486 t_pmp=matpar->GetMeltingPoint()-matpar->GetBeta()*pressure; 487 488 /*Add penalty load*/ 489 if (temperature<t_pmp){ //If T<Tpmp, there must be no melting. Therefore, melting should be constrained to 0 when T<Tpmp, instead of using spcs, use penalties 490 Ke->values[0]=kmax*pow(10.,penalty_factor); 491 } 492 493 /*Clean up and return*/ 494 return Ke; 495 } 496 /*}}}*/ 497 ElementMatrix* Pengrid::PenaltyCreateKMatrixThermal(IssmDouble kmax){/*{{{*/ 498 499 IssmDouble penalty_factor; 500 501 /*Initialize Element matrix and return if necessary*/ 502 if(!this->active) return NULL; 503 ElementMatrix* Ke=new ElementMatrix(&node,NUMVERTICES,this->parameters); 504 505 /*recover parameters: */ 506 parameters->FindParam(&penalty_factor,ThermalPenaltyFactorEnum); 507 508 Ke->values[0]=kmax*pow(10.,penalty_factor); 509 510 /*Clean up and return*/ 511 return Ke; 512 } 513 /*}}}*/ 514 ElementVector* Pengrid::PenaltyCreatePVectorMelting(IssmDouble kmax){/*{{{*/ 515 516 IssmDouble pressure; 517 IssmDouble temperature; 518 IssmDouble melting_offset; 519 IssmDouble t_pmp; 520 IssmDouble dt,penalty_factor; 521 522 /*recover pointers: */ 523 Penta* penta=(Penta*)element; 524 525 /*check that pengrid is not a clone (penalty to be added only once)*/ 526 if (node->IsClone()) return NULL; 527 ElementVector* pe=new ElementVector(&node,NUMVERTICES,this->parameters); 528 529 /*Retrieve all parameters*/ 530 penta->GetInputValue(&pressure,node,PressureEnum); 531 penta->GetInputValue(&temperature,node,TemperatureEnum); 532 parameters->FindParam(&melting_offset,MeltingOffsetEnum); 533 parameters->FindParam(&dt,TimesteppingTimeStepEnum); 534 parameters->FindParam(&penalty_factor,ThermalPenaltyFactorEnum); 535 536 /*Compute pressure melting point*/ 537 t_pmp=matpar->GetMeltingPoint()-matpar->GetBeta()*pressure; 538 539 /*Add penalty load 540 This time, the penalty must have the same value as the one used for the thermal computation 541 so that the corresponding melting can be computed correctly 542 In the thermal computation, we used kmax=melting_offset, and the same penalty_factor*/ 543 if (temperature<t_pmp){ //%no melting 544 pe->values[0]=0; 545 } 546 else{ 547 if (reCast<bool>(dt)) pe->values[0]=melting_offset*pow(10.,penalty_factor)*(temperature-t_pmp)/dt; 548 else pe->values[0]=melting_offset*pow(10.,penalty_factor)*(temperature-t_pmp); 549 } 550 551 /*Clean up and return*/ 552 return pe; 553 } 554 /*}}}*/ 555 ElementVector* Pengrid::PenaltyCreatePVectorThermal(IssmDouble kmax){/*{{{*/ 556 557 IssmDouble pressure; 558 IssmDouble t_pmp; 559 IssmDouble penalty_factor; 560 561 Penta* penta=(Penta*)element; 562 563 /*Initialize Element matrix and return if necessary*/ 564 if(!this->active) return NULL; 565 ElementVector* pe=new ElementVector(&node,1,this->parameters); 566 567 /*Retrieve all parameters*/ 568 penta->GetInputValue(&pressure,node,PressureEnum); 569 parameters->FindParam(&penalty_factor,ThermalPenaltyFactorEnum); 570 571 /*Compute pressure melting point*/ 572 t_pmp=matpar->GetMeltingPoint()-matpar->GetBeta()*pressure; 573 574 pe->values[0]=kmax*pow(10.,penalty_factor)*t_pmp; 575 576 /*Clean up and return*/ 577 return pe; 578 } 579 /*}}}*/ 580 void Pengrid::ConstraintActivateHydrologyDCInefficient(int* punstable){/*{{{*/ 406 void Pengrid::ConstraintActivateHydrologyDCInefficient(int* punstable){/*{{{*/ 581 407 582 408 // The penalty is stable if it doesn't change during two consecutive iterations. … … 638 464 } 639 465 /*}}}*/ 466 void Pengrid::ConstraintActivateThermal(int* punstable){/*{{{*/ 467 468 // The penalty is stable if it doesn't change during to successive iterations. 469 IssmDouble pressure; 470 IssmDouble temperature; 471 IssmDouble t_pmp; 472 int new_active; 473 int unstable=0; 474 int penalty_lock; 475 476 /*recover pointers: */ 477 Penta* penta=(Penta*)element; 478 479 /*check that pengrid is not a clone (penalty to be added only once)*/ 480 if (node->IsClone()){ 481 unstable=0; 482 *punstable=unstable; 483 return; 484 } 485 486 //First recover pressure and temperature values, using the element: */ 487 penta->GetInputValue(&pressure,node,PressureEnum); 488 penta->GetInputValue(&temperature,node,TemperaturePicardEnum); 489 490 //Recover our data: 491 parameters->FindParam(&penalty_lock,ThermalPenaltyLockEnum); 492 493 //Compute pressure melting point 494 t_pmp=matpar->TMeltingPoint(pressure); 495 496 //Figure out if temperature is over melting_point, in which case, this penalty needs to be activated. 497 498 if (temperature>t_pmp){ 499 new_active=1; 500 } 501 else{ 502 new_active=0; 503 } 504 505 //Figure out stability of this penalty 506 if (active==new_active){ 507 unstable=0; 508 } 509 else{ 510 unstable=1; 511 if(penalty_lock)zigzag_counter++; 512 } 513 514 /*If penalty keeps zigzagging more than 5 times: */ 515 if(penalty_lock){ 516 if(zigzag_counter>penalty_lock){ 517 unstable=0; 518 active=1; 519 } 520 } 521 522 //Set penalty flag 523 active=new_active; 524 525 //*Assign output pointers:*/ 526 *punstable=unstable; 527 } 528 /*}}}*/ 529 ElementVector* Pengrid::CreatePVectorHydrologyDCInefficient(void){/*{{{*/ 530 531 IssmDouble moulin_load,dt; 532 533 /*Initialize Element matrix*/ 534 ElementVector* pe=new ElementVector(&node,1,this->parameters); 535 536 this->element->GetInputValue(&moulin_load,node,HydrologydcBasalMoulinInputEnum); 537 parameters->FindParam(&dt,TimesteppingTimeStepEnum); 538 539 if(dt!=0.0) pe->values[0]=moulin_load*dt; 540 541 /*Clean up and return*/ 542 return pe; 543 } 544 /*}}}*/ 640 545 ElementMatrix* Pengrid::PenaltyCreateKMatrixHydrologyDCInefficient(IssmDouble kmax){/*{{{*/ 641 546 IssmDouble penalty_factor; … … 647 552 if(!this->active) return NULL; 648 553 ElementMatrix* Ke=new ElementMatrix(&node,NUMVERTICES,this->parameters); 554 555 Ke->values[0]=kmax*pow(10.,penalty_factor); 556 557 /*Clean up and return*/ 558 return Ke; 559 } 560 /*}}}*/ 561 ElementMatrix* Pengrid::PenaltyCreateKMatrixMelting(IssmDouble kmax){/*{{{*/ 562 563 IssmDouble pressure,temperature,t_pmp; 564 IssmDouble penalty_factor; 565 566 Penta* penta=(Penta*)element; 567 568 /*check that pengrid is not a clone (penalty to be added only once)*/ 569 if (node->IsClone()) return NULL; 570 ElementMatrix* Ke=new ElementMatrix(&node,1,this->parameters); 571 572 /*Retrieve all parameters*/ 573 penta->GetInputValue(&pressure,node,PressureEnum); 574 penta->GetInputValue(&temperature,node,TemperatureEnum); 575 parameters->FindParam(&penalty_factor,ThermalPenaltyFactorEnum); 576 577 /*Compute pressure melting point*/ 578 t_pmp=matpar->GetMaterialParameter(MaterialsMeltingpointEnum)-matpar->GetMaterialParameter(MaterialsBetaEnum)*pressure; 579 580 /*Add penalty load*/ 581 if (temperature<t_pmp){ //If T<Tpmp, there must be no melting. Therefore, melting should be constrained to 0 when T<Tpmp, instead of using spcs, use penalties 582 Ke->values[0]=kmax*pow(10.,penalty_factor); 583 } 584 585 /*Clean up and return*/ 586 return Ke; 587 } 588 /*}}}*/ 589 ElementMatrix* Pengrid::PenaltyCreateKMatrixThermal(IssmDouble kmax){/*{{{*/ 590 591 IssmDouble penalty_factor; 592 593 /*Initialize Element matrix and return if necessary*/ 594 if(!this->active) return NULL; 595 ElementMatrix* Ke=new ElementMatrix(&node,NUMVERTICES,this->parameters); 596 597 /*recover parameters: */ 598 parameters->FindParam(&penalty_factor,ThermalPenaltyFactorEnum); 649 599 650 600 Ke->values[0]=kmax*pow(10.,penalty_factor); … … 678 628 } 679 629 /*}}}*/ 680 ElementVector* Pengrid::CreatePVectorHydrologyDCInefficient(void){/*{{{*/ 681 682 IssmDouble moulin_load,dt; 683 684 /*Initialize Element matrix*/ 685 ElementVector* pe=new ElementVector(&node,1,this->parameters); 686 687 this->element->GetInputValue(&moulin_load,node,HydrologydcBasalMoulinInputEnum); 630 ElementVector* Pengrid::PenaltyCreatePVectorMelting(IssmDouble kmax){/*{{{*/ 631 632 IssmDouble pressure; 633 IssmDouble temperature; 634 IssmDouble melting_offset; 635 IssmDouble t_pmp; 636 IssmDouble dt,penalty_factor; 637 638 /*recover pointers: */ 639 Penta* penta=(Penta*)element; 640 641 /*check that pengrid is not a clone (penalty to be added only once)*/ 642 if (node->IsClone()) return NULL; 643 ElementVector* pe=new ElementVector(&node,NUMVERTICES,this->parameters); 644 645 /*Retrieve all parameters*/ 646 penta->GetInputValue(&pressure,node,PressureEnum); 647 penta->GetInputValue(&temperature,node,TemperatureEnum); 648 parameters->FindParam(&melting_offset,MeltingOffsetEnum); 688 649 parameters->FindParam(&dt,TimesteppingTimeStepEnum); 689 690 if(dt!=0.0) pe->values[0]=moulin_load*dt; 650 parameters->FindParam(&penalty_factor,ThermalPenaltyFactorEnum); 651 652 /*Compute pressure melting point*/ 653 t_pmp=matpar->GetMaterialParameter(MaterialsMeltingpointEnum)-matpar->GetMaterialParameter(MaterialsBetaEnum)*pressure; 654 655 /*Add penalty load 656 This time, the penalty must have the same value as the one used for the thermal computation 657 so that the corresponding melting can be computed correctly 658 In the thermal computation, we used kmax=melting_offset, and the same penalty_factor*/ 659 if (temperature<t_pmp){ //%no melting 660 pe->values[0]=0; 661 } 662 else{ 663 if (reCast<bool>(dt)) pe->values[0]=melting_offset*pow(10.,penalty_factor)*(temperature-t_pmp)/dt; 664 else pe->values[0]=melting_offset*pow(10.,penalty_factor)*(temperature-t_pmp); 665 } 691 666 692 667 /*Clean up and return*/ 693 668 return pe; 694 } 695 /*}}}*/ 696 void Pengrid::ResetConstraint(void){/*{{{*/ 669 } 670 /*}}}*/ 671 ElementVector* Pengrid::PenaltyCreatePVectorThermal(IssmDouble kmax){/*{{{*/ 672 673 IssmDouble pressure; 674 IssmDouble t_pmp; 675 IssmDouble penalty_factor; 676 677 Penta* penta=(Penta*)element; 678 679 /*Initialize Element matrix and return if necessary*/ 680 if(!this->active) return NULL; 681 ElementVector* pe=new ElementVector(&node,1,this->parameters); 682 683 /*Retrieve all parameters*/ 684 penta->GetInputValue(&pressure,node,PressureEnum); 685 parameters->FindParam(&penalty_factor,ThermalPenaltyFactorEnum); 686 687 /*Compute pressure melting point*/ 688 t_pmp=matpar->GetMaterialParameter(MaterialsMeltingpointEnum)-matpar->GetMaterialParameter(MaterialsBetaEnum)*pressure; 689 690 pe->values[0]=kmax*pow(10.,penalty_factor)*t_pmp; 691 692 /*Clean up and return*/ 693 return pe; 694 } 695 /*}}}*/ 696 void Pengrid::ResetConstraint(void){/*{{{*/ 697 697 active = 0; 698 698 zigzag_counter = 0; -
issm/trunk/src/c/classes/Loads/Penpair.cpp
r18301 r19105 45 45 46 46 /*Object virtual functions definitions:*/ 47 void Penpair::Echo(void){/*{{{*/ 47 Object* Penpair::copy() {/*{{{*/ 48 49 Penpair* penpair=NULL; 50 51 penpair=new Penpair(); 52 53 /*copy fields: */ 54 penpair->id=this->id; 55 penpair->analysis_type=this->analysis_type; 56 57 /*now deal with hooks and objects: */ 58 penpair->hnodes=(Hook*)this->hnodes->copy(); 59 penpair->nodes =(Node**)penpair->hnodes->deliverp(); 60 61 /*point parameters: */ 62 penpair->parameters=this->parameters; 63 64 return penpair; 65 66 } 67 /*}}}*/ 68 void Penpair::DeepEcho(void){/*{{{*/ 69 70 _printf_("Penpair:\n"); 71 _printf_(" id: " << id << "\n"); 72 _printf_(" analysis_type: " << EnumToStringx(analysis_type) << "\n"); 73 hnodes->DeepEcho(); 74 75 return; 76 } 77 /*}}}*/ 78 void Penpair::Echo(void){/*{{{*/ 48 79 49 80 _printf_("Penpair:\n"); … … 55 86 } 56 87 /*}}}*/ 57 void Penpair::DeepEcho(void){/*{{{*/ 58 59 _printf_("Penpair:\n"); 60 _printf_(" id: " << id << "\n"); 61 _printf_(" analysis_type: " << EnumToStringx(analysis_type) << "\n"); 62 hnodes->DeepEcho(); 63 64 return; 65 } 66 /*}}}*/ 67 int Penpair::Id(void){ return id; }/*{{{*/ 68 /*}}}*/ 69 int Penpair::ObjectEnum(void){/*{{{*/ 88 int Penpair::Id(void){ return id; }/*{{{*/ 89 /*}}}*/ 90 int Penpair::ObjectEnum(void){/*{{{*/ 70 91 71 92 return PenpairEnum; 72 }73 /*}}}*/74 Object* Penpair::copy() {/*{{{*/75 76 Penpair* penpair=NULL;77 78 penpair=new Penpair();79 80 /*copy fields: */81 penpair->id=this->id;82 penpair->analysis_type=this->analysis_type;83 84 /*now deal with hooks and objects: */85 penpair->hnodes=(Hook*)this->hnodes->copy();86 penpair->nodes =(Node**)penpair->hnodes->deliverp();87 88 /*point parameters: */89 penpair->parameters=this->parameters;90 91 return penpair;92 93 93 } 94 94 /*}}}*/ … … 109 109 } 110 110 /*}}}*/ 111 void Penpair::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){/*{{{*/ 112 113 } 114 /*}}}*/ 115 void Penpair::ResetHooks(){/*{{{*/ 116 117 this->nodes=NULL; 118 this->parameters=NULL; 119 120 /*Get Element type*/ 121 this->hnodes->reset(); 122 111 void Penpair::CreateJacobianMatrix(Matrix<IssmDouble>* Jff){/*{{{*/ 112 this->CreateKMatrix(Jff,NULL); 123 113 } 124 114 /*}}}*/ … … 137 127 } 138 128 /*}}}*/ 139 void Penpair::CreateJacobianMatrix(Matrix<IssmDouble>* Jff){/*{{{*/140 this->CreateKMatrix(Jff,NULL);141 }142 /*}}}*/143 129 void Penpair::GetNodesSidList(int* sidlist){/*{{{*/ 144 130 … … 162 148 } 163 149 /*}}}*/ 150 bool Penpair::InAnalysis(int in_analysis_type){/*{{{*/ 151 if (in_analysis_type==this->analysis_type)return true; 152 else return false; 153 } 154 /*}}}*/ 164 155 bool Penpair::IsPenalty(void){/*{{{*/ 165 156 return true; 157 } 158 /*}}}*/ 159 void Penpair::PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax){/*{{{*/ 160 this->PenaltyCreateKMatrix(Jff,NULL,kmax); 166 161 } 167 162 /*}}}*/ … … 196 191 } 197 192 /*}}}*/ 198 void Penpair::PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax){/*{{{*/ 199 this->PenaltyCreateKMatrix(Jff,NULL,kmax); 200 } 201 /*}}}*/ 202 bool Penpair::InAnalysis(int in_analysis_type){/*{{{*/ 203 if (in_analysis_type==this->analysis_type)return true; 204 else return false; 193 void Penpair::ResetHooks(){/*{{{*/ 194 195 this->nodes=NULL; 196 this->parameters=NULL; 197 198 /*Get Element type*/ 199 this->hnodes->reset(); 200 201 } 202 /*}}}*/ 203 void Penpair::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){/*{{{*/ 204 205 205 } 206 206 /*}}}*/ … … 279 279 280 280 /*Penpair management:*/ 281 ElementMatrix* Penpair::PenaltyCreateKMatrixMasstransport(IssmDouble kmax){/*{{{*/ 282 283 const int numdof=NUMVERTICES*NDOF1; 284 IssmDouble penalty_factor; 285 286 /*Initialize Element vector and return if necessary*/ 287 ElementMatrix* Ke=new ElementMatrix(nodes,NUMVERTICES,this->parameters); 288 289 /*recover parameters: */ 290 parameters->FindParam(&penalty_factor,MasstransportPenaltyFactorEnum); 291 292 //Create elementary matrix: add penalty to 293 Ke->values[0*numdof+0]=+kmax*pow(10.,penalty_factor); 294 Ke->values[0*numdof+1]=-kmax*pow(10.,penalty_factor); 295 Ke->values[1*numdof+0]=-kmax*pow(10.,penalty_factor); 296 Ke->values[1*numdof+1]=+kmax*pow(10.,penalty_factor); 297 298 /*Clean up and return*/ 299 return Ke; 300 } 301 /*}}}*/ 302 ElementMatrix* Penpair::PenaltyCreateKMatrixStressbalanceFS(IssmDouble kmax){/*{{{*/ 303 304 const int numdof=NUMVERTICES*NDOF3; 305 IssmDouble penalty_offset; 306 307 /*Initialize Element vector and return if necessary*/ 308 ElementMatrix* Ke=new ElementMatrix(nodes,NUMVERTICES,this->parameters); 309 310 /*recover parameters: */ 311 parameters->FindParam(&penalty_offset,StressbalancePenaltyFactorEnum); 312 313 //Create elementary matrix: add penalty to 314 Ke->values[0*numdof+0]=+kmax*pow(10.,penalty_offset); 315 Ke->values[0*numdof+3]=-kmax*pow(10.,penalty_offset); 316 Ke->values[3*numdof+0]=-kmax*pow(10.,penalty_offset); 317 Ke->values[3*numdof+3]=+kmax*pow(10.,penalty_offset); 318 319 Ke->values[1*numdof+1]=+kmax*pow(10.,penalty_offset); 320 Ke->values[1*numdof+4]=-kmax*pow(10.,penalty_offset); 321 Ke->values[4*numdof+1]=-kmax*pow(10.,penalty_offset); 322 Ke->values[4*numdof+4]=+kmax*pow(10.,penalty_offset); 323 324 Ke->values[2*numdof+2]=+kmax*pow(10.,penalty_offset); 325 Ke->values[2*numdof+5]=-kmax*pow(10.,penalty_offset); 326 Ke->values[5*numdof+2]=-kmax*pow(10.,penalty_offset); 327 Ke->values[5*numdof+5]=+kmax*pow(10.,penalty_offset); 328 329 /*Clean up and return*/ 330 return Ke; 331 } 332 /*}}}*/ 281 333 ElementMatrix* Penpair::PenaltyCreateKMatrixStressbalanceHoriz(IssmDouble kmax){/*{{{*/ 282 334 … … 338 390 } 339 391 /*}}}*/ 340 ElementMatrix* Penpair::PenaltyCreateKMatrixStressbalanceFS(IssmDouble kmax){/*{{{*/341 342 const int numdof=NUMVERTICES*NDOF3;343 IssmDouble penalty_offset;344 345 /*Initialize Element vector and return if necessary*/346 ElementMatrix* Ke=new ElementMatrix(nodes,NUMVERTICES,this->parameters);347 348 /*recover parameters: */349 parameters->FindParam(&penalty_offset,StressbalancePenaltyFactorEnum);350 351 //Create elementary matrix: add penalty to352 Ke->values[0*numdof+0]=+kmax*pow(10.,penalty_offset);353 Ke->values[0*numdof+3]=-kmax*pow(10.,penalty_offset);354 Ke->values[3*numdof+0]=-kmax*pow(10.,penalty_offset);355 Ke->values[3*numdof+3]=+kmax*pow(10.,penalty_offset);356 357 Ke->values[1*numdof+1]=+kmax*pow(10.,penalty_offset);358 Ke->values[1*numdof+4]=-kmax*pow(10.,penalty_offset);359 Ke->values[4*numdof+1]=-kmax*pow(10.,penalty_offset);360 Ke->values[4*numdof+4]=+kmax*pow(10.,penalty_offset);361 362 Ke->values[2*numdof+2]=+kmax*pow(10.,penalty_offset);363 Ke->values[2*numdof+5]=-kmax*pow(10.,penalty_offset);364 Ke->values[5*numdof+2]=-kmax*pow(10.,penalty_offset);365 Ke->values[5*numdof+5]=+kmax*pow(10.,penalty_offset);366 367 /*Clean up and return*/368 return Ke;369 }370 /*}}}*/371 ElementMatrix* Penpair::PenaltyCreateKMatrixMasstransport(IssmDouble kmax){/*{{{*/372 373 const int numdof=NUMVERTICES*NDOF1;374 IssmDouble penalty_factor;375 376 /*Initialize Element vector and return if necessary*/377 ElementMatrix* Ke=new ElementMatrix(nodes,NUMVERTICES,this->parameters);378 379 /*recover parameters: */380 parameters->FindParam(&penalty_factor,MasstransportPenaltyFactorEnum);381 382 //Create elementary matrix: add penalty to383 Ke->values[0*numdof+0]=+kmax*pow(10.,penalty_factor);384 Ke->values[0*numdof+1]=-kmax*pow(10.,penalty_factor);385 Ke->values[1*numdof+0]=-kmax*pow(10.,penalty_factor);386 Ke->values[1*numdof+1]=+kmax*pow(10.,penalty_factor);387 388 /*Clean up and return*/389 return Ke;390 }391 /*}}}*/ -
issm/trunk/src/c/classes/Loads/Penpair.h
r18301 r19105 31 31 /*}}}*/ 32 32 /*Object virtual functions definitions:{{{ */ 33 void Echo();34 void DeepEcho();35 int Id();36 int ObjectEnum();37 33 Object* copy(); 34 void DeepEcho(); 35 void Echo(); 36 int Id(); 37 int ObjectEnum(); 38 38 /*}}}*/ 39 39 /*Update virtual functions resolution: {{{*/ 40 void InputUpdateFromVector(IssmDouble* vector, int name, int type);41 void InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrow, int ncols,int name, int type){_error_("Not implemented yet!");}42 void InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){_error_("Not implemented yet!");}43 40 void InputUpdateFromConstant(IssmDouble constant, int name); 44 41 void InputUpdateFromConstant(int constant, int name); 45 42 void InputUpdateFromConstant(bool constant, int name); 46 43 void InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("not implemented yet");}; 44 void InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrow, int ncols,int name, int type){_error_("Not implemented yet!");} 45 void InputUpdateFromVector(IssmDouble* vector, int name, int type); 46 void InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){_error_("Not implemented yet!");} 47 47 /*}}}*/ 48 48 /*Load virtual functions definitions: {{{*/ 49 49 void Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 50 void CreateJacobianMatrix(Matrix<IssmDouble>* Jff); 51 void CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs); 52 void CreatePVector(Vector<IssmDouble>* pf); 53 void GetNodesLidList(int* lidlist); 54 void GetNodesSidList(int* sidlist); 55 int GetNumberOfNodes(void); 56 bool InAnalysis(int analysis_type); 57 bool IsPenalty(void); 58 void PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax); 59 void PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff,Matrix<IssmDouble>* Kfs,IssmDouble kmax); 60 void PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax); 50 61 void ResetHooks(); 51 62 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 52 void CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs);53 void CreatePVector(Vector<IssmDouble>* pf);54 void CreateJacobianMatrix(Matrix<IssmDouble>* Jff);55 void GetNodesSidList(int* sidlist);56 void GetNodesLidList(int* lidlist);57 int GetNumberOfNodes(void);58 bool IsPenalty(void);59 void PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff,Matrix<IssmDouble>* Kfs,IssmDouble kmax);60 void PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax);61 void PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax);62 63 void SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum); 63 bool InAnalysis(int analysis_type);64 64 /*}}}*/ 65 65 /*Penpair management: {{{*/ 66 ElementMatrix* PenaltyCreateKMatrixMasstransport(IssmDouble kmax); 67 ElementMatrix* PenaltyCreateKMatrixStressbalanceFS(IssmDouble kmax); 66 68 ElementMatrix* PenaltyCreateKMatrixStressbalanceHoriz(IssmDouble kmax); 67 69 ElementMatrix* PenaltyCreateKMatrixStressbalanceSSAHO(IssmDouble kmax); 68 ElementMatrix* PenaltyCreateKMatrixStressbalanceFS(IssmDouble kmax);69 ElementMatrix* PenaltyCreateKMatrixMasstransport(IssmDouble kmax);70 70 /*}}}*/ 71 71 }; -
issm/trunk/src/c/classes/Loads/Riftfront.cpp
r18301 r19105 108 108 109 109 /*Object virtual functions definitions:*/ 110 void Riftfront::Echo(void){/*{{{*/ 110 Object* Riftfront::copy() {/*{{{*/ 111 112 Riftfront* riftfront=NULL; 113 114 riftfront=new Riftfront(); 115 116 /*copy fields: */ 117 riftfront->id=this->id; 118 riftfront->analysis_type=this->analysis_type; 119 riftfront->type=this->type; 120 riftfront->fill=this->fill; 121 riftfront->friction=this->friction; 122 riftfront->fractionincrement=this->fractionincrement; 123 riftfront->shelf=this->shelf; 124 125 /*point parameters: */ 126 riftfront->parameters=this->parameters; 127 128 /*now deal with hooks and objects: */ 129 riftfront->hnodes=(Hook*)this->hnodes->copy(); 130 riftfront->helements=(Hook*)this->helements->copy(); 131 riftfront->hmatpar=(Hook*)this->hmatpar->copy(); 132 133 /*corresponding fields*/ 134 riftfront->nodes =(Node**)riftfront->hnodes->deliverp(); 135 riftfront->elements=(Element**)riftfront->helements->deliverp(); 136 riftfront->matpar =(Matpar*)riftfront->hmatpar->delivers(); 137 138 /*internal data: */ 139 riftfront->penalty_lock=this->penalty_lock; 140 riftfront->active=this->active; 141 riftfront->frozen=this->frozen; 142 riftfront->state=this->state; 143 riftfront->counter=this->counter; 144 riftfront->prestable=this->prestable; 145 riftfront->material_converged=this->material_converged; 146 riftfront->normal[0]=this->normal[0]; 147 riftfront->normal[1]=this->normal[1]; 148 riftfront->length=this->length; 149 riftfront->fraction=this->fraction; 150 151 return riftfront; 152 153 } 154 /*}}}*/ 155 void Riftfront::DeepEcho(void){/*{{{*/ 156 157 _printf_("Riftfront:\n"); 158 _printf_(" id: " << id << "\n"); 159 _printf_(" analysis_type: " << EnumToStringx(analysis_type) << "\n"); 160 hnodes->DeepEcho(); 161 helements->DeepEcho(); 162 hmatpar->DeepEcho(); 163 _printf_(" parameters\n"); 164 if(parameters)parameters->DeepEcho(); 165 } 166 /*}}}*/ 167 void Riftfront::Echo(void){/*{{{*/ 111 168 112 169 _printf_("Riftfront:\n"); … … 134 191 } 135 192 /*}}}*/ 136 void Riftfront::DeepEcho(void){/*{{{*/ 137 138 _printf_("Riftfront:\n"); 139 _printf_(" id: " << id << "\n"); 140 _printf_(" analysis_type: " << EnumToStringx(analysis_type) << "\n"); 141 hnodes->DeepEcho(); 142 helements->DeepEcho(); 143 hmatpar->DeepEcho(); 144 _printf_(" parameters\n"); 145 if(parameters)parameters->DeepEcho(); 146 } 147 /*}}}*/ 148 int Riftfront::Id(void){ return id; }/*{{{*/ 149 /*}}}*/ 150 int Riftfront::ObjectEnum(void){/*{{{*/ 193 int Riftfront::Id(void){ return id; }/*{{{*/ 194 /*}}}*/ 195 int Riftfront::ObjectEnum(void){/*{{{*/ 151 196 152 197 return RiftfrontEnum; 153 154 }155 /*}}}*/156 Object* Riftfront::copy() {/*{{{*/157 158 Riftfront* riftfront=NULL;159 160 riftfront=new Riftfront();161 162 /*copy fields: */163 riftfront->id=this->id;164 riftfront->analysis_type=this->analysis_type;165 riftfront->type=this->type;166 riftfront->fill=this->fill;167 riftfront->friction=this->friction;168 riftfront->fractionincrement=this->fractionincrement;169 riftfront->shelf=this->shelf;170 171 /*point parameters: */172 riftfront->parameters=this->parameters;173 174 /*now deal with hooks and objects: */175 riftfront->hnodes=(Hook*)this->hnodes->copy();176 riftfront->helements=(Hook*)this->helements->copy();177 riftfront->hmatpar=(Hook*)this->hmatpar->copy();178 179 /*corresponding fields*/180 riftfront->nodes =(Node**)riftfront->hnodes->deliverp();181 riftfront->elements=(Element**)riftfront->helements->deliverp();182 riftfront->matpar =(Matpar*)riftfront->hmatpar->delivers();183 184 /*internal data: */185 riftfront->penalty_lock=this->penalty_lock;186 riftfront->active=this->active;187 riftfront->frozen=this->frozen;188 riftfront->state=this->state;189 riftfront->counter=this->counter;190 riftfront->prestable=this->prestable;191 riftfront->material_converged=this->material_converged;192 riftfront->normal[0]=this->normal[0];193 riftfront->normal[1]=this->normal[1];194 riftfront->length=this->length;195 riftfront->fraction=this->fraction;196 197 return riftfront;198 198 199 199 } … … 234 234 } 235 235 /*}}}*/ 236 void Riftfront::ResetHooks(){/*{{{*/ 237 238 this->nodes=NULL; 239 this->elements=NULL; 240 this->matpar=NULL; 241 this->parameters=NULL; 242 243 /*Get Element type*/ 244 this->hnodes->reset(); 245 this->helements->reset(); 246 this->hmatpar->reset(); 247 236 void Riftfront::CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs){/*{{{*/ 237 /*do nothing: */ 238 return; 239 } 240 /*}}}*/ 241 void Riftfront::CreatePVector(Vector<IssmDouble>* pf){/*{{{*/ 242 /*do nothing: */ 243 return; 244 } 245 /*}}}*/ 246 void Riftfront::GetNodesLidList(int* lidlist){/*{{{*/ 247 248 _assert_(lidlist); 249 _assert_(nodes); 250 251 for(int i=0;i<NUMVERTICES;i++) lidlist[i]=nodes[i]->Lid(); 252 } 253 /*}}}*/ 254 void Riftfront::GetNodesSidList(int* sidlist){/*{{{*/ 255 256 _assert_(sidlist); 257 _assert_(nodes); 258 259 for(int i=0;i<NUMVERTICES;i++) sidlist[i]=nodes[i]->Sid(); 260 } 261 /*}}}*/ 262 int Riftfront::GetNumberOfNodes(void){/*{{{*/ 263 264 return NUMVERTICES; 265 } 266 /*}}}*/ 267 bool Riftfront::InAnalysis(int in_analysis_type){/*{{{*/ 268 if (in_analysis_type==this->analysis_type) return true; 269 else return false; 248 270 } 249 271 /*}}}*/ 250 272 bool Riftfront::IsPenalty(void){/*{{{*/ 251 273 return true; 252 }253 /*}}}*/254 void Riftfront::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){/*{{{*/255 256 274 } 257 275 /*}}}*/ … … 306 324 } 307 325 /*}}}*/ 308 void Riftfront::CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs){/*{{{*/ 309 /*do nothing: */ 310 return; 311 } 312 /*}}}*/ 313 void Riftfront::CreatePVector(Vector<IssmDouble>* pf){/*{{{*/ 314 /*do nothing: */ 315 return; 316 } 317 /*}}}*/ 318 void Riftfront::GetNodesSidList(int* sidlist){/*{{{*/ 319 320 _assert_(sidlist); 321 _assert_(nodes); 322 323 for(int i=0;i<NUMVERTICES;i++) sidlist[i]=nodes[i]->Sid(); 324 } 325 /*}}}*/ 326 void Riftfront::GetNodesLidList(int* lidlist){/*{{{*/ 327 328 _assert_(lidlist); 329 _assert_(nodes); 330 331 for(int i=0;i<NUMVERTICES;i++) lidlist[i]=nodes[i]->Lid(); 332 } 333 /*}}}*/ 334 int Riftfront::GetNumberOfNodes(void){/*{{{*/ 335 336 return NUMVERTICES; 337 } 338 /*}}}*/ 339 bool Riftfront::InAnalysis(int in_analysis_type){/*{{{*/ 340 if (in_analysis_type==this->analysis_type) return true; 341 else return false; 326 void Riftfront::ResetHooks(){/*{{{*/ 327 328 this->nodes=NULL; 329 this->elements=NULL; 330 this->matpar=NULL; 331 this->parameters=NULL; 332 333 /*Get Element type*/ 334 this->hnodes->reset(); 335 this->helements->reset(); 336 this->hmatpar->reset(); 337 338 } 339 /*}}}*/ 340 void Riftfront::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){/*{{{*/ 341 342 342 } 343 343 /*}}}*/ … … 505 505 506 506 /*Get some inputs: */ 507 rho_ice=matpar->Get RhoIce();508 rho_water=matpar->Get RhoWater();509 gravity=matpar->Get G();507 rho_ice=matpar->GetMaterialParameter(MaterialsRhoIceEnum); 508 rho_water=matpar->GetMaterialParameter(MaterialsRhoSeawaterEnum); 509 gravity=matpar->GetMaterialParameter(ConstantsGEnum); 510 510 tria1->GetInputValue(&h[0],nodes[0],ThicknessEnum); 511 511 tria2->GetInputValue(&h[1],nodes[1],ThicknessEnum); -
issm/trunk/src/c/classes/Loads/Riftfront.h
r18301 r19105 57 57 /*}}}*/ 58 58 /*Object virtual functions definitions:{{{ */ 59 void Echo();60 void DeepEcho();61 int Id();62 int ObjectEnum();63 Object* copy();59 Object* copy(); 60 void DeepEcho(); 61 void Echo(); 62 int Id(); 63 int ObjectEnum(); 64 64 /*}}}*/ 65 65 /*Update virtual functions resolution: {{{*/ 66 void InputUpdateFromVector(IssmDouble* vector, int name, int type);67 void InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows,int ncols, int name, int type){_error_("Not implemented yet!");}68 void InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){_error_("Not implemented yet!");}69 66 void InputUpdateFromConstant(IssmDouble constant, int name); 70 67 void InputUpdateFromConstant(int constant, int name){_error_("Not implemented yet!");} 71 68 void InputUpdateFromConstant(bool constant, int name); 72 69 void InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("not implemented yet");}; 70 void InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows,int ncols, int name, int type){_error_("Not implemented yet!");} 71 void InputUpdateFromVector(IssmDouble* vector, int name, int type); 72 void InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){_error_("Not implemented yet!");} 73 73 /*}}}*/ 74 74 /*Load virtual functions definitions: {{{*/ 75 75 void Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 76 void ResetHooks(); 77 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 76 void CreateJacobianMatrix(Matrix<IssmDouble>* Jff){_error_("Not implemented yet");}; 78 77 void CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs); 79 78 void CreatePVector(Vector<IssmDouble>* pf); 80 void CreateJacobianMatrix(Matrix<IssmDouble>* Jff){_error_("Not implemented yet");};79 void GetNodesLidList(int* lidlist); 81 80 void GetNodesSidList(int* sidlist); 82 void GetNodesLidList(int* lidlist);83 81 int GetNumberOfNodes(void); 82 bool InAnalysis(int analysis_type); 84 83 bool IsPenalty(void); 85 84 void PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax){_error_("Not implemented yet");}; 86 85 void PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* kfs, IssmDouble kmax); 87 86 void PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax); 87 void ResetHooks(); 88 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 88 89 void SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum); 89 bool InAnalysis(int analysis_type);90 90 /*}}}*/ 91 91 /*Riftfront specific routines: {{{*/ 92 int Constrain(int* punstable); 93 void FreezeConstraints(void); 94 bool IsFrozen(void); 92 95 ElementMatrix* PenaltyCreateKMatrixStressbalanceHoriz(IssmDouble kmax); 93 96 ElementVector* PenaltyCreatePVectorStressbalanceHoriz(IssmDouble kmax); 94 int Constrain(int* punstable);95 void FreezeConstraints(void);96 bool IsFrozen(void);97 97 /*}}}*/ 98 98 }; -
issm/trunk/src/c/classes/Massfluxatgate.h
r18301 r19105 20 20 public: 21 21 22 int definitionenum; 22 23 char* name; 23 24 int numsegments; … … 30 31 /*Massfluxatgate constructors, destructors :*/ 31 32 Massfluxatgate(){/*{{{*/ 33 this->definitionenum = -1; 32 34 this->name = 0; 33 35 this->numsegments = 0; … … 35 37 } 36 38 /*}}}*/ 37 Massfluxatgate(char* in_name, int in_ numsegments, doubletype* in_segments) {/*{{{*/39 Massfluxatgate(char* in_name, int in_definitionenum, int in_numsegments, doubletype* in_segments) {/*{{{*/ 38 40 39 41 int i; 42 43 this->definitionenum=in_definitionenum; 40 44 41 45 this->name = xNew<char>(strlen(in_name)+1); … … 61 65 } 62 66 /*}}}*/ 63 Massfluxatgate(char* in_name, int in_ numsegments, doubletype* in_x1, doubletype* in_y1, doubletype* in_x2, doubletype* in_y2,int* in_elements){/*{{{*/67 Massfluxatgate(char* in_name, int in_definitionenum, int in_numsegments, doubletype* in_x1, doubletype* in_y1, doubletype* in_x2, doubletype* in_y2,int* in_elements){/*{{{*/ 64 68 69 this->definitionenum=in_definitionenum; 65 70 this->name = xNew<char>(strlen(in_name)+1); 66 71 xMemCpy<char>(this->name,in_name,strlen(in_name)+1); … … 90 95 /*Object virtual function resolutoin: */ 91 96 void Echo(void){/*{{{*/ 92 _printf_(" Massfluxatgate: " << name << " \n");97 _printf_(" Massfluxatgate: " << name << " " << this->definitionenum << "\n"); 93 98 _printf_(" numsegments: " << numsegments << "\n"); 94 99 if(numsegments){ … … 113 118 /*}}}*/ 114 119 Object* copy() {/*{{{*/ 115 return new Massfluxatgate(this->name,this-> numsegments,this->x1,this->y1,this->x2,this->y2,this->elements);120 return new Massfluxatgate(this->name,this->definitionenum,this->numsegments,this->x1,this->y1,this->x2,this->y2,this->elements); 116 121 } 117 122 /*}}}*/ … … 123 128 124 129 return name2; 130 } 131 /*}}}*/ 132 int DefinitionEnum(){/*{{{*/ 133 134 return this->definitionenum; 125 135 } 126 136 /*}}}*/ -
issm/trunk/src/c/classes/Materials/Material.h
r18301 r19105 25 25 virtual Material* copy2(Element* element)=0; 26 26 virtual void Configure(Elements* elements)=0; 27 virtual IssmDouble GetA()=0; 28 virtual IssmDouble GetAbar()=0; 29 virtual IssmDouble GetB()=0; 30 virtual IssmDouble GetBbar()=0; 31 virtual IssmDouble GetD()=0; 32 virtual IssmDouble GetDbar()=0; 33 virtual IssmDouble GetN()=0; 27 34 virtual void GetViscosity(IssmDouble* pviscosity,IssmDouble epseff)=0; 28 virtual void GetViscosity_B(IssmDouble* pviscosity,IssmDouble epseff)=0;29 virtual void GetViscosity_D(IssmDouble* pviscosity,IssmDouble epseff)=0;30 35 virtual void GetViscosityBar(IssmDouble* pviscosity,IssmDouble epseff)=0; 31 36 virtual void GetViscosityComplement(IssmDouble* pviscosity_complement, IssmDouble* pepsilon)=0; 32 37 virtual void GetViscosityDComplement(IssmDouble* pviscosity_complement, IssmDouble* pepsilon)=0; 33 38 virtual void GetViscosityDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* pepsilon)=0; 39 virtual void GetViscosity_B(IssmDouble* pviscosity,IssmDouble epseff)=0; 40 virtual void GetViscosity_D(IssmDouble* pviscosity,IssmDouble epseff)=0; 34 41 virtual void GetViscosity2dDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* pepsilon)=0; 35 virtual IssmDouble GetA()=0;36 virtual IssmDouble GetAbar()=0;37 virtual IssmDouble GetB()=0;38 virtual IssmDouble GetBbar()=0;39 virtual IssmDouble GetN()=0;40 virtual IssmDouble GetD()=0;41 virtual IssmDouble GetDbar()=0;42 42 virtual bool IsDamage()=0; 43 43 virtual void ResetHooks()=0; -
issm/trunk/src/c/classes/Materials/Materials.cpp
r18301 r19105 37 37 for ( object=objects.begin() ; object < objects.end(); object++ ){ 38 38 39 material= dynamic_cast<Material*>(*object);39 material=xDynamicCast<Material*>(*object); 40 40 material->Configure(elements); 41 41 … … 51 51 for ( object=objects.begin() ; object < objects.end(); object++ ){ 52 52 53 material= dynamic_cast<Material*>((*object));53 material=xDynamicCast<Material*>((*object)); 54 54 material->ResetHooks(); 55 55 -
issm/trunk/src/c/classes/Materials/Matice.cpp
r18301 r19105 64 64 65 65 /*Object virtual functions definitions:*/ 66 void Matice::Echo(void){/*{{{*/ 67 68 _printf_("Matice:\n"); 69 _printf_(" mid: " << mid << "\n"); 70 _printf_(" element:\n"); 71 helement->Echo(); 72 } 73 /*}}}*/ 74 void Matice::DeepEcho(void){/*{{{*/ 66 Object* Matice::copy() {/*{{{*/ 67 68 /*Output*/ 69 Matice* matice=NULL; 70 71 /*Initialize output*/ 72 matice=new Matice(); 73 74 /*copy fields: */ 75 matice->mid=this->mid; 76 matice->helement=(Hook*)this->helement->copy(); 77 matice->element =(Element*)this->helement->delivers(); 78 matice->isdamaged = this->isdamaged; 79 80 return matice; 81 } 82 /*}}}*/ 83 Material* Matice::copy2(Element* element_in) {/*{{{*/ 84 85 /*Output*/ 86 Matice* matice=NULL; 87 88 /*Initialize output*/ 89 matice=new Matice(); 90 91 /*copy fields: */ 92 matice->mid=this->mid; 93 matice->helement=(Hook*)this->helement->copy(); 94 matice->element =element_in; 95 matice->isdamaged = this->isdamaged; 96 97 return matice; 98 } 99 /*}}}*/ 100 void Matice::DeepEcho(void){/*{{{*/ 75 101 76 102 _printf_("Matice:\n"); … … 80 106 } 81 107 /*}}}*/ 82 int Matice::Id(void){ return mid; }/*{{{*/ 83 /*}}}*/ 84 int Matice::ObjectEnum(void){/*{{{*/ 108 void Matice::Echo(void){/*{{{*/ 109 110 _printf_("Matice:\n"); 111 _printf_(" mid: " << mid << "\n"); 112 _printf_(" element:\n"); 113 helement->Echo(); 114 } 115 /*}}}*/ 116 int Matice::Id(void){ return mid; }/*{{{*/ 117 /*}}}*/ 118 int Matice::ObjectEnum(void){/*{{{*/ 85 119 86 120 return MaticeEnum; 87 121 88 }89 /*}}}*/90 Object* Matice::copy() {/*{{{*/91 92 /*Output*/93 Matice* matice=NULL;94 95 /*Initialize output*/96 matice=new Matice();97 98 /*copy fields: */99 matice->mid=this->mid;100 matice->helement=(Hook*)this->helement->copy();101 matice->element =(Element*)this->helement->delivers();102 matice->isdamaged = this->isdamaged;103 104 return matice;105 }106 /*}}}*/107 Material* Matice::copy2(Element* element_in) {/*{{{*/108 109 /*Output*/110 Matice* matice=NULL;111 112 /*Initialize output*/113 matice=new Matice();114 115 /*copy fields: */116 matice->mid=this->mid;117 matice->helement=(Hook*)this->helement->copy();118 matice->element =element_in;119 matice->isdamaged = this->isdamaged;120 121 return matice;122 122 } 123 123 /*}}}*/ -
issm/trunk/src/c/classes/Materials/Matpar.cpp
r18301 r19105 20 20 21 21 bool isefficientlayer; 22 int hydrology_model,smb_model ;22 int hydrology_model,smb_model,materials_type; 23 23 iomodel->Constant(&hydrology_model,HydrologyModelEnum); 24 24 iomodel->Constant(&smb_model,SurfaceforcingsEnum); 25 iomodel->Constant(&materials_type,MaterialsEnum); 25 26 26 27 this->mid = matpar_mid; 27 iomodel->Constant(&this->rho_ice,MaterialsRhoIceEnum); 28 iomodel->Constant(&this->rho_water,MaterialsRhoSeawaterEnum); 29 iomodel->Constant(&this->rho_freshwater,MaterialsRhoFreshwaterEnum); 30 iomodel->Constant(&this->mu_water,MaterialsMuWaterEnum); 31 iomodel->Constant(&this->heatcapacity,MaterialsHeatcapacityEnum); 32 iomodel->Constant(&this->thermalconductivity,MaterialsThermalconductivityEnum); 33 iomodel->Constant(&this->temperateiceconductivity,MaterialsTemperateiceconductivityEnum); 34 iomodel->Constant(&this->latentheat,MaterialsLatentheatEnum); 35 iomodel->Constant(&this->beta,MaterialsBetaEnum); 36 iomodel->Constant(&this->meltingpoint,MaterialsMeltingpointEnum); 37 iomodel->Constant(&this->referencetemperature,ConstantsReferencetemperatureEnum); 38 iomodel->Constant(&this->mixed_layer_capacity,MaterialsMixedLayerCapacityEnum); 39 iomodel->Constant(&this->thermal_exchange_velocity,MaterialsThermalExchangeVelocityEnum); 40 iomodel->Constant(&this->g,ConstantsGEnum); 41 42 switch(smb_model){ 43 case SMBEnum: 44 /*Nothing to add*/ 45 break; 46 case SMBpddEnum: 47 iomodel->Constant(&this->desfac,SurfaceforcingsDesfacEnum); 48 iomodel->Constant(&this->s0p,SurfaceforcingsS0pEnum); 49 break; 50 case SMBgradientsEnum: 51 /*Nothing to add*/ 52 break; 53 case SMBhenningEnum: 54 /*Nothing to add*/ 55 break; 56 case SMBcomponentsEnum: 57 /*Nothing to add*/ 58 break; 59 case SMBmeltcomponentsEnum: 60 /*Nothing to add*/ 28 29 switch(materials_type){ 30 case MaticeEnum: 31 case MatdamageiceEnum: 32 iomodel->Constant(&this->rho_ice,MaterialsRhoIceEnum); 33 iomodel->Constant(&this->rho_water,MaterialsRhoSeawaterEnum); 34 iomodel->Constant(&this->rho_freshwater,MaterialsRhoFreshwaterEnum); 35 iomodel->Constant(&this->mu_water,MaterialsMuWaterEnum); 36 iomodel->Constant(&this->heatcapacity,MaterialsHeatcapacityEnum); 37 iomodel->Constant(&this->thermalconductivity,MaterialsThermalconductivityEnum); 38 iomodel->Constant(&this->temperateiceconductivity,MaterialsTemperateiceconductivityEnum); 39 iomodel->Constant(&this->latentheat,MaterialsLatentheatEnum); 40 iomodel->Constant(&this->beta,MaterialsBetaEnum); 41 iomodel->Constant(&this->meltingpoint,MaterialsMeltingpointEnum); 42 iomodel->Constant(&this->referencetemperature,ConstantsReferencetemperatureEnum); 43 iomodel->Constant(&this->mixed_layer_capacity,MaterialsMixedLayerCapacityEnum); 44 iomodel->Constant(&this->thermal_exchange_velocity,MaterialsThermalExchangeVelocityEnum); 45 iomodel->Constant(&this->g,ConstantsGEnum); 46 47 switch(smb_model){ 48 case SMBEnum: 49 /*Nothing to add*/ 50 break; 51 case SMBpddEnum: 52 iomodel->Constant(&this->desfac,SurfaceforcingsDesfacEnum); 53 iomodel->Constant(&this->s0p,SurfaceforcingsS0pEnum); 54 iomodel->Constant(&this->s0t,SurfaceforcingsS0tEnum); 55 iomodel->Constant(&this->rlaps,SurfaceforcingsRlapsEnum); 56 iomodel->Constant(&this->rlapslgm,SurfaceforcingsRlapslgmEnum); 57 break; 58 case SMBgradientsEnum: 59 /*Nothing to add*/ 60 break; 61 case SMBhenningEnum: 62 /*Nothing to add*/ 63 break; 64 case SMBcomponentsEnum: 65 /*Nothing to add*/ 66 break; 67 case SMBmeltcomponentsEnum: 68 /*Nothing to add*/ 69 break; 70 default: 71 _error_("Surface mass balance model "<<EnumToStringx(smb_model)<<" not supported yet"); 72 } 73 if(hydrology_model==HydrologydcEnum){ 74 iomodel->Constant(&this->sediment_compressibility,HydrologydcSedimentCompressibilityEnum); 75 iomodel->Constant(&this->sediment_porosity,HydrologydcSedimentPorosityEnum); 76 iomodel->Constant(&this->sediment_thickness,HydrologydcSedimentThicknessEnum); 77 iomodel->Constant(&this->water_compressibility,HydrologydcWaterCompressibilityEnum); 78 iomodel->Constant(&isefficientlayer,HydrologydcIsefficientlayerEnum); 79 80 if(isefficientlayer){ 81 iomodel->Constant(&this->epl_compressibility,HydrologydcEplCompressibilityEnum); 82 iomodel->Constant(&this->epl_porosity,HydrologydcEplPorosityEnum); 83 iomodel->Constant(&this->epl_init_thickness,HydrologydcEplInitialThicknessEnum); 84 iomodel->Constant(&this->epl_colapse_thickness,HydrologydcEplColapseThicknessEnum); 85 iomodel->Constant(&this->epl_max_thickness,HydrologydcEplMaxThicknessEnum); 86 iomodel->Constant(&this->epl_conductivity,HydrologydcEplConductivityEnum); 87 } 88 } 89 else if(hydrology_model==HydrologyshreveEnum){ 90 /*Nothing to add*/ 91 } 92 else{ 93 _error_("Hydrology model "<<EnumToStringx(hydrology_model)<<" not supported yet"); 94 } 95 96 /*gia: */ 97 iomodel->Constant(&this->lithosphere_shear_modulus,MaterialsLithosphereShearModulusEnum); 98 iomodel->Constant(&this->lithosphere_density,MaterialsLithosphereDensityEnum); 99 iomodel->Constant(&this->mantle_shear_modulus,MaterialsMantleShearModulusEnum); 100 iomodel->Constant(&this->mantle_density,MaterialsMantleDensityEnum); 61 101 break; 62 102 default: 63 _error_("Surface mass balance model "<<EnumToStringx(smb_model)<<" not supported yet"); 64 } 65 if(hydrology_model==HydrologydcEnum){ 66 iomodel->Constant(&this->sediment_compressibility,HydrologydcSedimentCompressibilityEnum); 67 iomodel->Constant(&this->sediment_porosity,HydrologydcSedimentPorosityEnum); 68 iomodel->Constant(&this->sediment_thickness,HydrologydcSedimentThicknessEnum); 69 iomodel->Constant(&this->water_compressibility,HydrologydcWaterCompressibilityEnum); 70 iomodel->Constant(&isefficientlayer,HydrologydcIsefficientlayerEnum); 71 72 if(isefficientlayer){ 73 iomodel->Constant(&this->epl_compressibility,HydrologydcEplCompressibilityEnum); 74 iomodel->Constant(&this->epl_porosity,HydrologydcEplPorosityEnum); 75 iomodel->Constant(&this->epl_init_thickness,HydrologydcEplInitialThicknessEnum); 76 iomodel->Constant(&this->epl_max_thickness,HydrologydcEplMaxThicknessEnum); 77 iomodel->Constant(&this->epl_conductivity,HydrologydcEplConductivityEnum); 78 } 79 } 80 else if(hydrology_model==HydrologyshreveEnum){ 81 /*Nothing to add*/ 82 } 83 else{ 84 _error_("Hydrology model "<<EnumToStringx(hydrology_model)<<" not supported yet"); 85 } 86 87 /*gia: */ 88 iomodel->Constant(&this->lithosphere_shear_modulus,MaterialsLithosphereShearModulusEnum); 89 iomodel->Constant(&this->lithosphere_density,MaterialsLithosphereDensityEnum); 90 iomodel->Constant(&this->mantle_shear_modulus,MaterialsMantleShearModulusEnum); 91 iomodel->Constant(&this->mantle_density,MaterialsMantleDensityEnum); 103 _error_("Material "<< EnumToStringx(materials_type) <<" not supported yet"); 104 } 92 105 } 93 106 /*}}}*/ … … 118 131 _printf_(" desfac: " << desfac << "\n"); 119 132 _printf_(" s0p: " << s0p << "\n"); 133 _printf_(" s0t: " << s0t << "\n"); 134 _printf_(" rlaps: " << rlaps << "\n"); 135 _printf_(" rlapslgm: " << rlapslgm << "\n"); 120 136 return; 121 137 } … … 160 176 matpar->desfac=this->desfac; 161 177 matpar->s0p=this->s0p; 178 matpar->s0t=this->s0t; 179 matpar->rlaps=this->rlaps; 180 matpar->rlapslgm=this->rlapslgm; 162 181 163 182 matpar->sediment_compressibility=this->sediment_compressibility; … … 169 188 matpar->epl_porosity=this->epl_porosity; 170 189 matpar->epl_init_thickness=this->epl_init_thickness; 190 matpar->epl_colapse_thickness=this->epl_colapse_thickness; 171 191 matpar->epl_max_thickness=this->epl_max_thickness; 172 192 matpar->epl_conductivity=this->epl_conductivity; … … 245 265 this->s0p=constant; 246 266 break; 267 case SurfaceforcingsS0tEnum: 268 this->s0t=constant; 269 break; 270 case SurfaceforcingsRlapsEnum: 271 this->rlaps=constant; 272 break; 273 case SurfaceforcingsRlapslgmEnum: 274 this->rlapslgm=constant; 275 break; 247 276 default: 248 277 break; … … 261 290 262 291 /*Matpar management: */ 263 void Matpar::Configure(Elements* elementsin){/*{{{*/292 void Matpar::Configure(Elements* elementsin){/*{{{*/ 264 293 265 294 /*nothing done yet!*/ 266 295 296 } 297 /*}}}*/ 298 void Matpar::EnthalpyToThermal(IssmDouble* ptemperature,IssmDouble* pwaterfraction,IssmDouble enthalpy,IssmDouble pressure){/*{{{*/ 299 300 /*Ouput*/ 301 IssmDouble temperature,waterfraction; 302 303 if(enthalpy<PureIceEnthalpy(pressure)){ 304 temperature=referencetemperature+enthalpy/heatcapacity; 305 waterfraction=0.; 306 } 307 else{ 308 temperature=TMeltingPoint(pressure); 309 waterfraction=(enthalpy-PureIceEnthalpy(pressure))/latentheat; 310 } 311 312 /*Assign output pointers:*/ 313 *pwaterfraction=waterfraction; 314 *ptemperature=temperature; 315 } 316 /*}}}*/ 317 IssmDouble Matpar::GetEnthalpyDiffusionParameter(IssmDouble enthalpy,IssmDouble pressure){/*{{{*/ 318 if (enthalpy<PureIceEnthalpy(pressure)) 319 return thermalconductivity/heatcapacity; 320 else 321 return temperateiceconductivity/heatcapacity; 322 } 323 /*}}}*/ 324 IssmDouble Matpar::GetEnthalpyDiffusionParameterVolume(int numvertices,IssmDouble* enthalpy,IssmDouble* pressure){/*{{{*/ 325 326 int iv; 327 IssmDouble lambda; // fraction of cold ice 328 IssmDouble kappa,kappa_c,kappa_t; //enthalpy conductivities 329 IssmDouble Hc,Ht; 330 IssmDouble* PIE = xNew<IssmDouble>(numvertices); 331 IssmDouble* dHpmp = xNew<IssmDouble>(numvertices); 332 333 for(iv=0; iv<numvertices; iv++){ 334 PIE[iv]=PureIceEnthalpy(pressure[iv]); 335 dHpmp[iv]=enthalpy[iv]-PIE[iv]; 336 } 337 338 bool allequalsign=true; 339 if(dHpmp[0]<0) 340 for(iv=1; iv<numvertices;iv++) allequalsign=(allequalsign && (dHpmp[iv]<0)); 341 else 342 for(iv=1; iv<numvertices;iv++) allequalsign=(allequalsign && (dHpmp[iv]>=0)); 343 344 if(allequalsign){ 345 kappa=GetEnthalpyDiffusionParameter(enthalpy[0], pressure[0]); 346 } 347 else { 348 /* return harmonic mean of thermal conductivities, weighted by fraction of cold/temperate ice, 349 cf Patankar 1980, pp44 */ 350 kappa_c=GetEnthalpyDiffusionParameter(PureIceEnthalpy(0.)-1.,0.); 351 kappa_t=GetEnthalpyDiffusionParameter(PureIceEnthalpy(0.)+1.,0.); 352 Hc=0.; Ht=0.; 353 for(iv=0; iv<numvertices;iv++){ 354 if(enthalpy[iv]<PIE[iv]) 355 Hc+=(PIE[iv]-enthalpy[iv]); 356 else 357 Ht+=(enthalpy[iv]-PIE[iv]); 358 } 359 _assert_((Hc+Ht)>0.); 360 lambda = Hc/(Hc+Ht); 361 kappa = 1./(lambda/kappa_c + (1.-lambda)/kappa_t); 362 } 363 364 /*Clean up and return*/ 365 xDelete<IssmDouble>(PIE); 366 xDelete<IssmDouble>(dHpmp); 367 return kappa; 267 368 } 268 369 /*}}}*/ … … 271 372 switch(enum_in){ 272 373 case MaterialsRhoIceEnum: return this->rho_ice; 273 case MaterialsRhoSeawaterEnum: 374 case MaterialsRhoSeawaterEnum: return this->rho_water; 274 375 case MaterialsRhoFreshwaterEnum: return this->rho_freshwater; 275 376 case MaterialsMuWaterEnum: return this->mu_water; … … 290 391 case HydrologydcEplConductivityEnum: return this->epl_conductivity; 291 392 case HydrologydcEplInitialThicknessEnum: return this->epl_init_thickness; 393 case HydrologydcEplColapseThicknessEnum: return this->epl_colapse_thickness; 292 394 case HydrologydcEplMaxThicknessEnum: return this->epl_max_thickness; 293 395 case HydrologydcWaterCompressibilityEnum: return this->water_compressibility; 294 396 case ConstantsGEnum: return this->g; 397 case SurfaceforcingsDesfacEnum: return this->desfac; 398 case SurfaceforcingsS0pEnum: return this->s0p; 399 case SurfaceforcingsS0tEnum: return this->s0t; 400 case SurfaceforcingsRlapsEnum: return this->rlaps; 401 case SurfaceforcingsRlapslgmEnum: return this->rlapslgm; 402 case MaterialsLithosphereShearModulusEnum: return this->lithosphere_shear_modulus; 403 case MaterialsLithosphereDensityEnum: return this->lithosphere_density; 404 case MaterialsMantleDensityEnum: return this->mantle_density; 405 case MaterialsMantleShearModulusEnum: return this->mantle_shear_modulus; 295 406 default: _error_("Enum "<<EnumToStringx(enum_in)<<" not supported yet"); 296 407 } … … 298 409 } 299 410 /*}}}*/ 300 IssmDouble Matpar::GetBeta(){/*{{{*/ 301 return beta; 302 } 303 /*}}}*/ 304 IssmDouble Matpar::GetG(){/*{{{*/ 305 return g; 306 } 307 /*}}}*/ 308 IssmDouble Matpar::GetMeltingPoint(){/*{{{*/ 309 return meltingpoint; 310 } 311 /*}}}*/ 312 IssmDouble Matpar::GetRhoIce(){/*{{{*/ 313 314 return rho_ice; 315 } 316 /*}}}*/ 317 IssmDouble Matpar::GetRhoWater(){/*{{{*/ 318 return rho_water; 319 } 320 /*}}}*/ 321 IssmDouble Matpar::GetRhoFreshwater(){/*{{{*/ 322 return rho_freshwater; 323 } 324 /*}}}*/ 325 IssmDouble Matpar::GetDesFac(){/*{{{*/ 326 return desfac; 327 } 328 /*}}}*/ 329 IssmDouble Matpar::GetS0p(){/*{{{*/ 330 return s0p; 411 IssmDouble Matpar::PureIceEnthalpy(IssmDouble pressure){/*{{{*/ 412 return heatcapacity*(TMeltingPoint(pressure)-referencetemperature); 413 } 414 /*}}}*/ 415 void Matpar::ResetHooks(){/*{{{*/ 416 417 //Nothing to be done 418 return; 419 } 420 /*}}}*/ 421 void Matpar::ThermalToEnthalpy(IssmDouble * penthalpy,IssmDouble temperature,IssmDouble waterfraction,IssmDouble pressure){/*{{{*/ 422 423 /*Ouput*/ 424 IssmDouble enthalpy; 425 426 if(temperature<TMeltingPoint(pressure)){ 427 enthalpy=heatcapacity*(temperature-referencetemperature); 428 } 429 else{ 430 enthalpy=PureIceEnthalpy(pressure)+latentheat*waterfraction; 431 } 432 433 /*Assign output pointers:*/ 434 *penthalpy=enthalpy; 331 435 } 332 436 /*}}}*/ … … 335 439 } 336 440 /*}}}*/ 337 IssmDouble Matpar::PureIceEnthalpy(IssmDouble pressure){/*{{{*/338 return heatcapacity*(TMeltingPoint(pressure)-referencetemperature);339 }340 /*}}}*/341 IssmDouble Matpar::GetEnthalpyDiffusionParameter(IssmDouble enthalpy,IssmDouble pressure){/*{{{*/342 if (enthalpy<PureIceEnthalpy(pressure))343 return thermalconductivity/heatcapacity;344 else345 return temperateiceconductivity/heatcapacity;346 }347 /*}}}*/348 IssmDouble Matpar::GetEnthalpyDiffusionParameterVolume(int numvertices,IssmDouble* enthalpy,IssmDouble* pressure){/*{{{*/349 350 int iv;351 IssmDouble lambda; // fraction of cold ice352 IssmDouble kappa,kappa_c,kappa_t; //enthalpy conductivities353 IssmDouble Hc,Ht;354 IssmDouble* PIE = xNew<IssmDouble>(numvertices);355 IssmDouble* dHpmp = xNew<IssmDouble>(numvertices);356 357 for(iv=0; iv<numvertices; iv++){358 PIE[iv]=PureIceEnthalpy(pressure[iv]);359 dHpmp[iv]=enthalpy[iv]-PIE[iv];360 }361 362 bool allequalsign=true;363 if(dHpmp[0]<0)364 for(iv=1; iv<numvertices;iv++) allequalsign=(allequalsign && (dHpmp[iv]<0));365 else366 for(iv=1; iv<numvertices;iv++) allequalsign=(allequalsign && (dHpmp[iv]>=0));367 368 if(allequalsign){369 kappa=GetEnthalpyDiffusionParameter(enthalpy[0], pressure[0]);370 }371 else {372 /* return harmonic mean of thermal conductivities, weighted by fraction of cold/temperate ice,373 cf Patankar 1980, pp44 */374 kappa_c=GetEnthalpyDiffusionParameter(PureIceEnthalpy(0.)-1.,0.);375 kappa_t=GetEnthalpyDiffusionParameter(PureIceEnthalpy(0.)+1.,0.);376 Hc=0.; Ht=0.;377 for(iv=0; iv<numvertices;iv++){378 if(enthalpy[iv]<PIE[iv])379 Hc+=(PIE[iv]-enthalpy[iv]);380 else381 Ht+=(enthalpy[iv]-PIE[iv]);382 }383 _assert_((Hc+Ht)>0.);384 lambda = Hc/(Hc+Ht);385 kappa = 1./(lambda/kappa_c + (1.-lambda)/kappa_t);386 }387 388 /*Clean up and return*/389 xDelete<IssmDouble>(PIE);390 xDelete<IssmDouble>(dHpmp);391 return kappa;392 }393 /*}}}*/394 void Matpar::EnthalpyToThermal(IssmDouble* ptemperature,IssmDouble* pwaterfraction,IssmDouble enthalpy,IssmDouble pressure){/*{{{*/395 396 /*Ouput*/397 IssmDouble temperature,waterfraction;398 399 if(enthalpy<PureIceEnthalpy(pressure)){400 temperature=referencetemperature+enthalpy/heatcapacity;401 waterfraction=0.;402 }403 else{404 temperature=TMeltingPoint(pressure);405 waterfraction=(enthalpy-PureIceEnthalpy(pressure))/latentheat;406 }407 408 /*Assign output pointers:*/409 *pwaterfraction=waterfraction;410 *ptemperature=temperature;411 }412 /*}}}*/413 void Matpar::ThermalToEnthalpy(IssmDouble * penthalpy,IssmDouble temperature,IssmDouble waterfraction,IssmDouble pressure){/*{{{*/414 415 /*Ouput*/416 IssmDouble enthalpy;417 418 if(temperature<TMeltingPoint(pressure)){419 enthalpy=heatcapacity*(temperature-referencetemperature);420 }421 else{422 enthalpy=PureIceEnthalpy(pressure)+latentheat*waterfraction;423 }424 425 /*Assign output pointers:*/426 *penthalpy=enthalpy;427 }428 /*}}}*/429 IssmDouble Matpar::GetLithosphereShearModulus(){ /*{{{*/430 return lithosphere_shear_modulus;431 }432 /*}}}*/433 IssmDouble Matpar::GetLithosphereDensity(){ /*{{{*/434 return lithosphere_density;435 }436 /*}}}*/437 IssmDouble Matpar::GetMantleDensity(){ /*{{{*/438 return mantle_density;439 }440 /*}}}*/441 IssmDouble Matpar::GetMantleShearModulus(){ /*{{{*/442 return mantle_shear_modulus;443 }444 /*}}}*/445 void Matpar::ResetHooks(){/*{{{*/446 447 //Nothing to be done448 return;449 }450 /*}}}*/ -
issm/trunk/src/c/classes/Materials/Matpar.h
r18301 r19105 30 30 IssmDouble thermal_exchange_velocity; 31 31 IssmDouble g; 32 IssmDouble omega; 32 33 IssmDouble desfac; 33 34 IssmDouble s0p; 35 IssmDouble s0t; 36 IssmDouble rlaps; 37 IssmDouble rlapslgm; 34 38 35 39 /*hydrology Dual Porous Continuum: */ … … 42 46 IssmDouble epl_porosity; 43 47 IssmDouble epl_init_thickness; 48 IssmDouble epl_colapse_thickness; 44 49 IssmDouble epl_max_thickness; 45 50 IssmDouble epl_conductivity; … … 50 55 IssmDouble mantle_shear_modulus; 51 56 IssmDouble mantle_density; 57 58 /*Sea ice*/ 59 IssmDouble poisson; 60 IssmDouble young_modulus; 61 IssmDouble ridging_exponent; 62 IssmDouble cohesion; 63 IssmDouble internal_friction_coef; 64 IssmDouble compression_coef; 65 IssmDouble traction_coef; 66 IssmDouble time_relaxation_stress; 67 IssmDouble time_relaxation_damage; 52 68 53 69 public: … … 94 110 /*}}}*/ 95 111 /*Numerics: {{{*/ 96 IssmDouble GetG(); 97 IssmDouble GetRhoIce(); 98 IssmDouble GetRhoWater(); 99 IssmDouble GetRhoFreshwater(); 100 IssmDouble GetBeta(); 101 IssmDouble GetMeltingPoint(); 102 IssmDouble TMeltingPoint(IssmDouble pressure); 103 IssmDouble PureIceEnthalpy(IssmDouble pressure); 112 void EnthalpyToThermal(IssmDouble* ptemperature,IssmDouble* pwaterfraction,IssmDouble enthalpy,IssmDouble pressure); 104 113 IssmDouble GetEnthalpyDiffusionParameter(IssmDouble enthalpy,IssmDouble pressure); 105 114 IssmDouble GetEnthalpyDiffusionParameterVolume(int numvertices,IssmDouble* enthalpy,IssmDouble* pressure); 106 IssmDouble GetLithosphereShearModulus(); 107 IssmDouble GetLithosphereDensity(); 108 IssmDouble GetMantleShearModulus(); 109 IssmDouble GetMantleDensity(); 110 void EnthalpyToThermal(IssmDouble* ptemperature,IssmDouble* pwaterfraction,IssmDouble enthalpy,IssmDouble pressure); 115 IssmDouble GetMaterialParameter(int in_enum); 116 IssmDouble PureIceEnthalpy(IssmDouble pressure); 111 117 void ThermalToEnthalpy(IssmDouble* penthalpy,IssmDouble temperature,IssmDouble waterfraction,IssmDouble pressure); 112 IssmDouble GetDesFac(); 113 IssmDouble GetS0p(); 114 IssmDouble GetMaterialParameter(int in_enum); 118 IssmDouble TMeltingPoint(IssmDouble pressure); 115 119 /*}}}*/ 116 120 -
issm/trunk/src/c/classes/Misfit.h
r18301 r19105 15 15 #include "../modules/SurfaceAreax/SurfaceAreax.h" 16 16 #include "../classes/Params/Parameters.h" 17 #include "../classes/Inputs/Input.h" 18 #include "../classes/gauss/Gauss.h" 17 19 /*}}}*/ 20 IssmDouble OutputDefinitionsResponsex(FemModel* femmodel,int output_enum); 18 21 19 22 class Misfit: public Object, public Definition{ … … 21 24 public: 22 25 26 int definitionenum; 23 27 char* name; 24 28 int model_enum; … … 26 30 int weights_enum; 27 31 char* timeinterpolation; 32 bool local; 28 33 29 34 IssmDouble misfit; //value carried over in time. … … 33 38 Misfit(){/*{{{*/ 34 39 40 this->definitionenum = -1; 35 41 this->name = NULL; 36 42 this->model_enum = UNDEF; … … 38 44 this->weights_enum = UNDEF; 39 45 this->timeinterpolation=NULL; 46 this->local=true; 40 47 this->misfit=0; 41 48 this->lock=0; … … 43 50 } 44 51 /*}}}*/ 45 Misfit(char* in_name, int in_ model_enum, int in_observation_enum, char* in_timeinterpolation, int in_weights_enum){/*{{{*/52 Misfit(char* in_name, int in_definitionenum, int in_model_enum, int in_observation_enum, char* in_timeinterpolation, bool in_local, int in_weights_enum){/*{{{*/ 46 53 54 this->definitionenum=in_definitionenum; 47 55 this->name = xNew<char>(strlen(in_name)+1); 48 56 xMemCpy<char>(this->name,in_name,strlen(in_name)+1); … … 54 62 this->observation_enum=in_observation_enum; 55 63 this->weights_enum=in_weights_enum; 64 this->local=in_local; 56 65 57 66 this->misfit=0; … … 68 77 /*Object virtual function resolutoin: */ 69 78 void Echo(void){/*{{{*/ 70 _printf_(" Misfit: " << name << " \n");79 _printf_(" Misfit: " << name << " " << this->definitionenum << "\n"); 71 80 _printf_(" model_enum: " << model_enum << " " << EnumToStringx(model_enum) << "\n"); 72 81 _printf_(" observation_enum: " << observation_enum << " " << EnumToStringx(observation_enum) << "\n"); 73 82 _printf_(" weights_enum: " << weights_enum << " " << EnumToStringx(weights_enum) << "\n"); 74 83 _printf_(" timeinterpolation: " << timeinterpolation << "\n"); 84 _printf_(" local: " << local << "\n"); 75 85 } 76 86 /*}}}*/ … … 88 98 /*}}}*/ 89 99 Object* copy() {/*{{{*/ 90 Misfit* mf = new Misfit(this->name,this-> model_enum,this->observation_enum,this->timeinterpolation,this->weights_enum);100 Misfit* mf = new Misfit(this->name,this->definitionenum, this->model_enum,this->observation_enum,this->timeinterpolation,this->local,this->weights_enum); 91 101 mf->misfit=this->misfit; 92 102 mf->lock=this->lock; … … 103 113 } 104 114 /*}}}*/ 115 int DefinitionEnum(){/*{{{*/ 116 117 return this->definitionenum; 118 } 119 /*}}}*/ 105 120 IssmDouble Response(FemModel* femmodel){/*{{{*/ 106 107 int i; 108 IssmDouble misfit_t=0.; 109 IssmDouble all_misfit_t=0.; 121 122 /*diverse: */ 123 IssmDouble time,starttime,finaltime; 110 124 IssmDouble dt; 111 IssmDouble area_t=0.; 112 IssmDouble all_area_t; 113 IssmDouble time,starttime,finaltime; 114 125 126 /*recover time parameters: */ 115 127 femmodel->parameters->FindParam(&starttime,TimesteppingStartTimeEnum); 116 128 femmodel->parameters->FindParam(&finaltime,TimesteppingFinalTimeEnum); 117 129 femmodel->parameters->FindParam(&time,TimeEnum); 118 119 /*If we are locked, return time average: */120 if(this->lock)return misfit/(time-starttime);121 122 123 for(i=0;i<femmodel->elements->Size();i++){124 Element* element=(Element*)femmodel->elements->GetObjectByOffset(i);125 misfit_t+=element->Misfit(model_enum,observation_enum,weights_enum);126 area_t+=element->MisfitArea(weights_enum);127 }128 129 ISSM_MPI_Allreduce ( (void*)&misfit_t,(void*)&all_misfit_t,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm());130 ISSM_MPI_Allreduce ( (void*)&area_t,(void*)&all_area_t,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm());131 area_t=all_area_t;132 misfit_t=all_misfit_t;133 134 /*Divide by surface area if not nill!: */135 if (area_t!=0) misfit_t=misfit_t/area_t;136 137 /*Recover delta_t: */138 130 femmodel->parameters->FindParam(&dt,TimesteppingTimeStepEnum); 139 131 140 /*Add this time's contribution to curent misfit: */ 141 misfit+=dt*misfit_t; 132 if (this->local){ /*local computation: {{{*/ 142 133 143 /*Do we lock? i.e. are we at final_time? :*/ 144 if(time==finaltime)this->lock=1; 134 int i; 135 IssmDouble misfit_t=0.; 136 IssmDouble all_misfit_t=0.; 137 IssmDouble area_t=0.; 138 IssmDouble all_area_t; 145 139 146 /*What we return is the value of misfit / time: */ 147 return misfit/(time-starttime); 140 141 /*If we are locked, return time average: */ 142 if(this->lock)return misfit/(time-starttime); 143 144 for(i=0;i<femmodel->elements->Size();i++){ 145 Element* element=(Element*)femmodel->elements->GetObjectByOffset(i); 146 misfit_t+=element->Misfit(model_enum,observation_enum,weights_enum); 147 area_t+=element->MisfitArea(weights_enum); 148 } 149 150 ISSM_MPI_Allreduce ( (void*)&misfit_t,(void*)&all_misfit_t,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm()); 151 ISSM_MPI_Allreduce ( (void*)&area_t,(void*)&all_area_t,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm()); 152 area_t=all_area_t; 153 misfit_t=all_misfit_t; 154 155 /*Divide by surface area if not nill!: */ 156 if (area_t!=0) misfit_t=misfit_t/area_t; 157 158 /*Add this time's contribution to curent misfit: */ 159 misfit+=dt*misfit_t; 160 161 /*Do we lock? i.e. are we at final_time? :*/ 162 if(time==finaltime)this->lock=1; 163 164 /*What we return is the value of misfit / time: */ 165 return misfit/(time-starttime); 166 } /*}}}*/ 167 else{ /*global computation: {{{ */ 168 169 IssmDouble model, observation; 170 171 /*If we are locked, return time average: */ 172 if(this->lock)return misfit/(time-starttime); 173 174 /*First, the global model response: */ 175 model=OutputDefinitionsResponsex(femmodel,this->model_enum); 176 /*Now, the observation is buried inside the elements, go fish it in the first element (cludgy, needs fixing): */ 177 Element* element=(Element*)femmodel->elements->GetObjectByOffset(0); _assert_(element); 178 Input* input = element->GetInput(observation_enum); _assert_(input); 179 input->GetInputAverage(&observation); 180 181 /*Add this time's contribution to curent misfit: */ 182 misfit+=dt*(model-observation); 183 184 /*Do we lock? i.e. are we at final_time? :*/ 185 if(time==finaltime)this->lock=1; 186 187 /*What we return is the value of misfit / time: */ 188 return misfit/(time-starttime); 189 } /*}}}*/ 190 148 191 } 149 192 /*}}}*/ -
issm/trunk/src/c/classes/Node.cpp
r18301 r19105 94 94 analysis_enum==BalancethicknessAnalysisEnum || 95 95 analysis_enum==HydrologyDCInefficientAnalysisEnum || 96 analysis_enum==DamageEvolutionAnalysisEnum ||97 96 analysis_enum==HydrologyDCEfficientAnalysisEnum || 98 97 analysis_enum==LevelsetAnalysisEnum || -
issm/trunk/src/c/classes/Nodes.cpp
r18301 r19105 49 49 /*Go through objects, and distribute dofs locally, from 0 to numberofdofsperobject*/ 50 50 for(i=0;i<this->Size();i++){ 51 Node* node= dynamic_cast<Node*>(this->GetObjectByOffset(i));51 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i)); 52 52 53 53 /*Check that this node corresponds to our analysis currently being carried out: */ … … 72 72 for(i=0;i<this->Size();i++){ 73 73 /*Check that this node corresponds to our analysis currently being carried out: */ 74 Node* node= dynamic_cast<Node*>(this->GetObjectByOffset(i));74 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i)); 75 75 if (node->InAnalysis(analysis_type)){ 76 76 node->OffsetDofs(dofcount,setenum); … … 89 89 90 90 for(i=0;i<this->Size();i++){ 91 Node* node= dynamic_cast<Node*>(this->GetObjectByOffset(i));91 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i)); 92 92 if (node->InAnalysis(analysis_type)){ 93 93 node->ShowTrueDofs(truedofs,maxdofspernode,setenum);//give maxdofspernode, column size, so that nodes can index into truedofs … … 99 99 /* Now every cpu knows the true dofs of everyone else that is not a clone*/ 100 100 for(i=0;i<this->Size();i++){ 101 Node* node= dynamic_cast<Node*>(this->GetObjectByOffset(i));101 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i)); 102 102 if (node->InAnalysis(analysis_type)){ 103 103 node->UpdateCloneDofs(alltruedofs,maxdofspernode,setenum); … … 107 107 /*Update indexingupdateflag*/ 108 108 for(i=0;i<this->Size();i++){ 109 Node* node= dynamic_cast<Node*>(this->GetObjectByOffset(i));109 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i)); 110 110 if (node->InAnalysis(analysis_type)){ 111 111 node->ReindexingDone(); … … 148 148 for(i=0;i<this->Size();i++){ 149 149 150 Node* node= dynamic_cast<Node*>(this->GetObjectByOffset(i));150 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i)); 151 151 152 152 /*Check that this node corresponds to our analysis currently being carried out: */ … … 172 172 for(int i=0;i<this->Size();i++){ 173 173 174 Node* node= dynamic_cast<Node*>(this->GetObjectByOffset(i));174 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i)); 175 175 176 176 /*Check that this node corresponds to our analysis currently being carried out: */ … … 197 197 if(!sorted){ 198 198 for(int i=0;i<this->Size();i++){ 199 Node* node= dynamic_cast<Node*>(this->GetObjectByOffset(i));199 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i)); 200 200 id=node->Id(); 201 201 if(id>max)max=id; … … 207 207 } 208 208 else{ 209 Node* node= dynamic_cast<Node*>(this->GetObjectByOffset(this->Size()-1));209 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(this->Size()-1)); 210 210 max = node->Id(); 211 211 } … … 238 238 for(int i=0;i<this->Size();i++){ 239 239 240 Node* node= dynamic_cast<Node*>(this->GetObjectByOffset(i));240 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i)); 241 241 242 242 /*Check that this node corresponds to our analysis currently being carried out: */ … … 262 262 /*Now go through all nodes, and get how many dofs they own, unless they are clone nodes: */ 263 263 for(int i=0;i<this->Size();i++){ 264 Node* node= dynamic_cast<Node*>(this->GetObjectByOffset(i));264 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i)); 265 265 266 266 /*Ok, this object is a node, ask it to plug values into partition: */ … … 284 284 for(i=0;i<this->Size();i++){ 285 285 286 Node* node= dynamic_cast<Node*>(this->GetObjectByOffset(i));286 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i)); 287 287 288 288 /*Check that this node corresponds to our analysis currently being carried out: */ … … 316 316 for(int i=0;i<this->Size();i++){ 317 317 318 Node* node= dynamic_cast<Node*>(this->GetObjectByOffset(i));318 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i)); 319 319 320 320 /*Check that this node corresponds to our analysis currently being carried out: */ … … 335 335 for(int i=0;i<this->Size();i++){ 336 336 337 Node* node= dynamic_cast<Node*>(this->GetObjectByOffset(i));337 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i)); 338 338 339 339 /*Check that this node corresponds to our analysis currently being carried out: */ -
issm/trunk/src/c/classes/Options/GenericOption.h
r15104 r19105 132 132 /*}}}*/ 133 133 134 /*Special destructors when there is a pointer*/ 135 template <> inline GenericOption<char*>::~GenericOption(){ /*{{{*/ 136 137 if(name) xDelete<char>(name); 138 if(size) xDelete<int>(size); 139 if(value) xDelete<char>(value); 140 } 141 /*}}}*/ 142 134 143 #endif /* _OPTIONOBJECT_H */ -
issm/trunk/src/c/classes/Options/Options.cpp
r18301 r19105 52 52 for(object=objects.begin();object<objects.end();object++){ 53 53 54 option= dynamic_cast<Option*>(*object);54 option=xDynamicCast<Option*>(*object); 55 55 if (!strcmp(option->Name(),name)){ 56 56 _error_("Options \"" << name << "\" found multiple times"); … … 73 73 for ( object=objects.begin() ; object < objects.end(); object++ ){ 74 74 75 option=dynamic_cast<Option*>(*object); 75 option=xDynamicCast<Option*>(*object); 76 //option=(Option*)(*object); //C-like cast 77 /*There is a crash on some machines (Einar Olason) that needs to be fixed*/ 78 if(!option){ 79 _printf_("The dynamic_cast from Object* to Option* is failing.\n"); 80 _printf_("\n"); 81 _printf_("A quick qorkaround consists of using a C-like cast\n"); 82 _printf_("\n"); 83 _printf_("Open Options.cpp and change the dynamic_cast in Options::GetOption by a C-like cast\n"); 84 //_printf_("Open Options.h and replace the dynamic_cast of all the Get functions to C-like cats\n"); 85 _printf_("\n"); 86 _error_("Make the fix above and recompile ISSM"); 87 } 88 76 89 if (!strncmp(name,option->Name(),strlen(option->Name()))){ 77 90 -
issm/trunk/src/c/classes/Options/Options.h
r15104 r19105 26 26 27 27 /*Get option*/ 28 GenericOption<OptionType>* genericoption= dynamic_cast<GenericOption<OptionType>*>(GetOption(name));28 GenericOption<OptionType>* genericoption=xDynamicCast<GenericOption<OptionType>*>(GetOption(name)); 29 29 30 30 /*If the pointer is not NULL, the option has been found*/ … … 41 41 42 42 /*Get option*/ 43 GenericOption<OptionType>* genericoption= dynamic_cast<GenericOption<OptionType>*>(GetOption(name));43 GenericOption<OptionType>* genericoption=xDynamicCast<GenericOption<OptionType>*>(GetOption(name)); 44 44 45 45 /*If the pointer is not NULL, the option has been found*/ … … 57 57 58 58 /*Get option*/ 59 GenericOption<OptionType>* genericoption= dynamic_cast<GenericOption<OptionType>*>(GetOption(name));59 GenericOption<OptionType>* genericoption=xDynamicCast<GenericOption<OptionType>*>(GetOption(name)); 60 60 61 61 /*If the pointer is not NULL, the option has been found*/ … … 72 72 73 73 /*Get option*/ 74 GenericOption<OptionType>* genericoption= dynamic_cast<GenericOption<OptionType>*>(GetOption(name));74 GenericOption<OptionType>* genericoption=xDynamicCast<GenericOption<OptionType>*>(GetOption(name)); 75 75 76 76 /*If the pointer is not NULL, the option has been found*/ … … 92 92 93 93 /*Get option*/ 94 GenericOption<char*>* genericoption= dynamic_cast<GenericOption<char*>*>(GetOption(name));94 GenericOption<char*>* genericoption=xDynamicCast<GenericOption<char*>*>(GetOption(name)); 95 95 96 96 /*If the pointer is not NULL, the option has been found*/ -
issm/trunk/src/c/classes/Params/Parameters.cpp
r18301 r19105 57 57 58 58 for ( object=objects.begin() ; object < objects.end(); object++ ){ 59 param= dynamic_cast<Param*>(*object);59 param=xDynamicCast<Param*>(*object); 60 60 if(param->InstanceEnum()==enum_type) return true; 61 61 } … … 70 70 for ( object=objects.begin() ; object < objects.end(); object++ ){ 71 71 72 param= dynamic_cast<Param*>(*object);72 param=xDynamicCast<Param*>(*object); 73 73 if(param->InstanceEnum()==enum_type){ 74 74 param->GetParameterValue(pbool); … … 86 86 for ( object=objects.begin() ; object < objects.end(); object++ ){ 87 87 88 param= dynamic_cast<Param*>(*object);88 param=xDynamicCast<Param*>(*object); 89 89 if(param->InstanceEnum()==enum_type){ 90 90 param->GetParameterValue(pinteger); … … 102 102 for ( object=objects.begin() ; object < objects.end(); object++ ){ 103 103 104 param= dynamic_cast<Param*>(*object);104 param=xDynamicCast<Param*>(*object); 105 105 if(param->InstanceEnum()==enum_type){ 106 106 param->GetParameterValue(pscalar); … … 118 118 for ( object=objects.begin() ; object < objects.end(); object++ ){ 119 119 120 param= dynamic_cast<Param*>(*object);120 param=xDynamicCast<Param*>(*object); 121 121 if(param->InstanceEnum()==enum_type){ 122 122 param->GetParameterValue(pscalar,time); … … 134 134 for ( object=objects.begin() ; object < objects.end(); object++ ){ 135 135 136 param= dynamic_cast<Param*>(*object);136 param=xDynamicCast<Param*>(*object); 137 137 if(param->InstanceEnum()==enum_type){ 138 138 param->GetParameterValue(pstring); … … 151 151 for ( object=objects.begin() ; object < objects.end(); object++ ){ 152 152 153 param= dynamic_cast<Param*>(*object);153 param=xDynamicCast<Param*>(*object); 154 154 if(param->InstanceEnum()==enum_type){ 155 155 param->GetParameterValue(pstringarray,pM); … … 168 168 for ( object=objects.begin() ; object < objects.end(); object++ ){ 169 169 170 param= dynamic_cast<Param*>(*object);170 param=xDynamicCast<Param*>(*object); 171 171 if(param->InstanceEnum()==enum_type){ 172 172 param->GetParameterValue(pintarray,pM); … … 185 185 for ( object=objects.begin() ; object < objects.end(); object++ ){ 186 186 187 param= dynamic_cast<Param*>(*object);187 param=xDynamicCast<Param*>(*object); 188 188 if(param->InstanceEnum()==enum_type){ 189 189 param->GetParameterValue(pintarray,pM,pN); … … 202 202 for ( object=objects.begin() ; object < objects.end(); object++ ){ 203 203 204 param= dynamic_cast<Param*>(*object);204 param=xDynamicCast<Param*>(*object); 205 205 if(param->InstanceEnum()==enum_type){ 206 206 param->GetParameterValue(pIssmDoublearray,pM); … … 219 219 for ( object=objects.begin() ; object < objects.end(); object++ ){ 220 220 221 param= dynamic_cast<Param*>(*object);221 param=xDynamicCast<Param*>(*object); 222 222 if(param->InstanceEnum()==enum_type){ 223 223 param->GetParameterValue(pIssmDoublearray,pM,pN); … … 236 236 for ( object=objects.begin() ; object < objects.end(); object++ ){ 237 237 238 param= dynamic_cast<Param*>(*object);238 param=xDynamicCast<Param*>(*object); 239 239 if(param->InstanceEnum()==enum_type){ 240 240 param->GetParameterValue(parray,pM,pmdims_array,pndims_array); … … 252 252 for ( object=objects.begin() ; object < objects.end(); object++ ){ 253 253 254 param= dynamic_cast<Param*>(*object);254 param=xDynamicCast<Param*>(*object); 255 255 if(param->InstanceEnum()==enum_type){ 256 256 param->GetParameterValue(pvec); … … 269 269 for ( object=objects.begin() ; object < objects.end(); object++ ){ 270 270 271 param= dynamic_cast<Param*>(*object);271 param=xDynamicCast<Param*>(*object); 272 272 if(param->InstanceEnum()==enum_type){ 273 273 param->GetParameterValue(pmat); … … 286 286 for ( object=objects.begin() ; object < objects.end(); object++ ){ 287 287 288 param= dynamic_cast<Param*>(*object);288 param=xDynamicCast<Param*>(*object); 289 289 if(param->InstanceEnum()==enum_type){ 290 290 param->GetParameterValue(pfid); … … 303 303 for ( object=objects.begin() ; object < objects.end(); object++ ){ 304 304 305 param= dynamic_cast<Param*>(*object);305 param=xDynamicCast<Param*>(*object); 306 306 if(param->InstanceEnum()==enum_type){ 307 307 param->GetParameterValue(pdataset); … … 318 318 319 319 /*first, figure out if the param has already been created: */ 320 param= dynamic_cast<Param*>(this->FindParamObject(enum_type));320 param=xDynamicCast<Param*>(this->FindParamObject(enum_type)); 321 321 322 322 if(param) param->SetValue(boolean); //already exists, just set it. … … 329 329 330 330 /*first, figure out if the param has already been created: */ 331 param= dynamic_cast<Param*>(this->FindParamObject(enum_type));331 param=xDynamicCast<Param*>(this->FindParamObject(enum_type)); 332 332 333 333 if(param) param->SetValue(integer); //already exists, just set it. … … 340 340 341 341 /*first, figure out if the param has already been created: */ 342 param= dynamic_cast<Param*>(this->FindParamObject(enum_type));342 param=xDynamicCast<Param*>(this->FindParamObject(enum_type)); 343 343 344 344 if(param) param->SetValue(scalar); //already exists, just set it. … … 351 351 352 352 /*first, figure out if the param has already been created: */ 353 param= dynamic_cast<Param*>(this->FindParamObject(enum_type));353 param=xDynamicCast<Param*>(this->FindParamObject(enum_type)); 354 354 355 355 if(param) param->SetValue(string); //already exists, just set it. … … 362 362 363 363 /*first, figure out if the param has already been created: */ 364 param= dynamic_cast<Param*>(this->FindParamObject(enum_type));364 param=xDynamicCast<Param*>(this->FindParamObject(enum_type)); 365 365 366 366 if(param) param->SetValue(stringarray,M); //already exists, just set it. … … 373 373 374 374 /*first, figure out if the param has already been created: */ 375 param= dynamic_cast<Param*>(this->FindParamObject(enum_type));375 param=xDynamicCast<Param*>(this->FindParamObject(enum_type)); 376 376 377 377 if(param) param->SetValue(IssmDoublearray,M); //already exists, just set it. … … 384 384 385 385 /*first, figure out if the param has already been created: */ 386 param= dynamic_cast<Param*>(this->FindParamObject(enum_type));386 param=xDynamicCast<Param*>(this->FindParamObject(enum_type)); 387 387 388 388 if(param) param->SetValue(IssmDoublearray,M,N); //already exists, just set it. … … 395 395 396 396 /*first, figure out if the param has already been created: */ 397 param= dynamic_cast<Param*>(this->FindParamObject(enum_type));397 param=xDynamicCast<Param*>(this->FindParamObject(enum_type)); 398 398 399 399 if(param) param->SetValue(intarray,M); //already exists, just set it. … … 406 406 407 407 /*first, figure out if the param has already been created: */ 408 param= dynamic_cast<Param*>(this->FindParamObject(enum_type));408 param=xDynamicCast<Param*>(this->FindParamObject(enum_type)); 409 409 410 410 if(param) param->SetValue(intarray,M,N); //already exists, just set it. … … 417 417 418 418 /*first, figure out if the param has already been created: */ 419 param= dynamic_cast<Param*>(this->FindParamObject(enum_type));419 param=xDynamicCast<Param*>(this->FindParamObject(enum_type)); 420 420 421 421 if(param) param->SetValue(vector); //already exists, just set it. … … 428 428 429 429 /*first, figure out if the param has already been created: */ 430 param= dynamic_cast<Param*>(this->FindParamObject(enum_type));430 param=xDynamicCast<Param*>(this->FindParamObject(enum_type)); 431 431 432 432 if(param) param->SetValue(matrix); //already exists, just set it. … … 439 439 440 440 /*first, figure out if the param has already been created: */ 441 param= dynamic_cast<Param*>(this->FindParamObject(enum_type));441 param=xDynamicCast<Param*>(this->FindParamObject(enum_type)); 442 442 443 443 if(param) param->SetValue(fid); //already exists, just set it. … … 450 450 451 451 /*first, figure out if the param has already been created: */ 452 param= dynamic_cast<Param*>(this->FindParamObject(enum_type));452 param=xDynamicCast<Param*>(this->FindParamObject(enum_type)); 453 453 454 454 if(param) param->SetValue(dataset); //already exists, just set it. … … 464 464 for ( object=objects.begin() ; object < objects.end(); object++ ){ 465 465 466 param= dynamic_cast<Param*>(*object);466 param=xDynamicCast<Param*>(*object); 467 467 if(param->InstanceEnum()==enum_type){ 468 468 return (*object); -
issm/trunk/src/c/classes/Vertex.cpp
r18301 r19105 32 32 this->domaintype = iomodel->domaintype; 33 33 34 _assert_(iomodel->Data(BaseEnum) && iomodel->Data(ThicknessEnum) && iomodel->numbernodetoelementconnectivity);35 34 switch(iomodel->domaintype){ 36 35 case Domain3DEnum: 37 case Domain2DhorizontalEnum:36 _assert_(iomodel->Data(BaseEnum) && iomodel->Data(ThicknessEnum)); 38 37 this->sigma = (iomodel->Data(MeshZEnum)[i]-iomodel->Data(BaseEnum)[i])/(iomodel->Data(ThicknessEnum)[i]); 39 38 break; 39 case Domain2DhorizontalEnum: 40 this->sigma = 0.; 41 break; 40 42 case Domain2DverticalEnum: 43 _assert_(iomodel->Data(BaseEnum) && iomodel->Data(ThicknessEnum)); 41 44 this->sigma = (iomodel->Data(MeshYEnum)[i]-iomodel->Data(BaseEnum)[i])/(iomodel->Data(ThicknessEnum)[i]); 42 45 break; 43 46 } 44 47 48 _assert_(iomodel->numbernodetoelementconnectivity); 45 49 this->connectivity = iomodel->numbernodetoelementconnectivity[i]; 46 50 -
issm/trunk/src/c/classes/Vertices.cpp
r18301 r19105 52 52 /*Go through objects, and distribute pids locally, from 0 to numberofpidsperobject*/ 53 53 for (i=0;i<this->Size();i++){ 54 Vertex* vertex= dynamic_cast<Vertex*>(this->GetObjectByOffset(i));54 Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i)); 55 55 vertex->DistributePids(&pidcount); 56 56 } … … 72 72 } 73 73 for (i=0;i<this->Size();i++){ 74 Vertex* vertex= dynamic_cast<Vertex*>(this->GetObjectByOffset(i));74 Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i)); 75 75 vertex->OffsetPids(pidcount); 76 76 } … … 82 82 alltruepids=xNewZeroInit<int>(numberofobjects); 83 83 for (i=0;i<this->Size();i++){ 84 Vertex* vertex= dynamic_cast<Vertex*>(this->GetObjectByOffset(i));84 Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i)); 85 85 vertex->ShowTruePids(truepids); 86 86 } … … 89 89 /* Now every cpu knows the true pids of everyone else that is not a clone*/ 90 90 for(i=0;i<this->Size();i++){ 91 Vertex* vertex= dynamic_cast<Vertex*>(this->GetObjectByOffset(i));91 Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i)); 92 92 vertex->UpdateClonePids(alltruepids); 93 93 } … … 128 128 for(i=0;i<this->Size();i++){ 129 129 /*For this object, decide whether it is a clone: */ 130 Vertex* vertex= dynamic_cast<Vertex*>(this->GetObjectByOffset(i));130 Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i)); 131 131 vertex->SetClone(minranks); 132 132 } … … 145 145 146 146 for(i=0;i<this->Size();i++){ 147 Vertex* vertex= dynamic_cast<Vertex*>(this->GetObjectByOffset(i));147 Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i)); 148 148 sid=vertex->Sid(); 149 149 if (sid>max_sid)max_sid=sid; … … 172 172 for(int i=0;i<this->Size();i++){ 173 173 /*Plug rank into ranks, according to id: */ 174 Vertex* vertex= dynamic_cast<Vertex*>(this->GetObjectByOffset(i));174 Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i)); 175 175 sid=vertex->Sid(); 176 176 ranks[sid]=my_rank; … … 202 202 203 203 /*let vertex fill matrix: */ 204 Vertex* vertex= dynamic_cast<Vertex*>(this->GetObjectByOffset(i));204 Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i)); 205 205 vertex->ToXYZ(xyz); 206 206 } -
issm/trunk/src/c/classes/classes.h
r17806 r19105 19 19 #include "./Massfluxatgate.h" 20 20 #include "./Misfit.h" 21 #include "./Masscon.h" 22 #include "./Massconaxpby.h" 21 23 22 24 /*Constraints: */ -
issm/trunk/src/c/classes/gauss/GaussPenta.cpp
r18301 r19105 8 8 #include "../../shared/Exceptions/exceptions.h" 9 9 #include "../../shared/MemOps/MemOps.h" 10 #include "../../shared/Numerics/recast.h" 10 11 #include "../../shared/Enum/Enum.h" 11 12 #include "../../shared/Numerics/GaussPoints.h" … … 750 751 751 752 _assert_(gauss->Enum()==GaussTriaEnum); 752 GaussTria* gauss_tria = dynamic_cast<GaussTria*>(gauss);753 GaussTria* gauss_tria = xDynamicCast<GaussTria*>(gauss); 753 754 754 755 gauss_tria->coord1=this->coord1; -
issm/trunk/src/c/classes/kriging/Observation.cpp
r18301 r19105 4 4 5 5 #include <stdlib.h> 6 #include <cmath> 7 #include <utility> 6 8 #include "../classes.h" 7 9 … … 23 25 } 24 26 /*}}}*/ 27 Observation::Observation(double x_in, double y_in,double value_in){ 28 this->x = x_in; 29 this->y = y_in; 30 this->value = value_in; 31 32 this->xi = 0; 33 this->yi = 0; 34 this->index = 0; 35 this->weight = 0.; 36 } 25 37 Observation::~Observation(){/*{{{*/ 26 38 return; … … 59 71 } 60 72 /*}}}*/ 73 74 /*Covertree*/ 75 void Observation::print(void) const{/*{{{*/ 76 77 _printf_("Observation\n"); 78 _printf_(" x : " << this->x << "\n"); 79 _printf_(" y : " << this->y << "\n"); 80 _printf_(" value : " << this->value << "\n"); 81 } 82 /*}}}*/ 83 double Observation::distance(const Observation& ob) const 84 { 85 return std::sqrt( (std::pow( (ob.x - this->x), 2 ) + std::pow((ob.y - this->y), 2) )); 86 } 87 88 bool Observation::operator==(const Observation& ob) const 89 { 90 return (ob.x == this->x && ob.y == this->y && ob.value == this->value); 91 } 92 93 void Observation::WriteXYObs(const Observation& ob, double* px, double* py, double* pobs){ 94 *px = ob.x; 95 *py = ob.y; 96 *pobs = ob.value; 97 } -
issm/trunk/src/c/classes/kriging/Observation.h
r18301 r19105 20 20 Observation(); 21 21 Observation(double x_in,double y_in,int xi_in,int yi_in,int index_in,double value_in); 22 Observation(double x_in,double y_in,double value_in); 22 23 ~Observation(); 23 24 24 25 /*Object virtual functions definitions*/ 26 double distance(const Observation& ob) const; 27 25 28 void Echo(); 29 void print() const; 26 30 void DeepEcho() {_error_("Not implemented yet"); }; 27 31 int Id() {_error_("Not implemented yet"); }; 28 32 int ObjectEnum(){_error_("Not implemented yet"); }; 33 bool operator==(const Observation& ob) const; 29 34 Object *copy(); 30 35 31 36 /*Management*/ 37 void WriteXYObs(const Observation& ob, double* px, double* py, double* pobs); 32 38 void WriteXYObs(double* px,double* py,double* pobs); 33 39 }; -
issm/trunk/src/c/classes/kriging/Observations.cpp
r18301 r19105 23 23 24 24 #include "./Quadtree.h" 25 #include "./Covertree.h" 25 26 #include "./Variogram.h" 26 27 #include "../../toolkits/toolkits.h" … … 31 32 /*Object constructors and destructor*/ 32 33 Observations::Observations(){/*{{{*/ 33 this->quadtree = NULL; 34 this->treetype = 0; 35 this->quadtree = NULL; 36 this->covertree = NULL; 34 37 return; 35 38 } 36 39 /*}}}*/ 37 40 Observations::Observations(IssmPDouble* observations_list,IssmPDouble* x,IssmPDouble* y,int n,Options* options){/*{{{*/ 41 42 /*Check that there are observations*/ 43 if(n<=0) _error_("No observation found"); 44 45 /*Get tree type (FIXME)*/ 46 IssmDouble dtree = 0.; 47 options->Get(&dtree,"treetype",1.); 48 this->treetype = reCast<int>(dtree); 49 switch(this->treetype){ 50 case 1: 51 this->covertree = NULL; 52 this->InitQuadtree(observations_list,x,y,n,options); 53 break; 54 case 2: 55 this->quadtree = NULL; 56 this->InitCovertree(observations_list,x,y,n,options); 57 break; 58 default: 59 _error_("Tree type "<<this->treetype<<" not supported yet (1: quadtree, 2: covertree)"); 60 } 61 62 63 64 } 65 /*}}}*/ 66 Observations::~Observations(){/*{{{*/ 67 switch(this->treetype){ 68 case 1: 69 delete this->quadtree; 70 break; 71 case 2: 72 delete this->covertree; 73 break; 74 default: 75 _error_("Tree type "<<this->treetype<<" not supported yet (1: quadtree, 2: covertree)"); 76 } 77 return; 78 } 79 /*}}}*/ 80 81 /*Initialize data structures*/ 82 void Observations::InitQuadtree(IssmPDouble* observations_list,IssmPDouble* x,IssmPDouble* y,int n,Options* options){/*{{{*/ 38 83 39 84 /*Intermediaries*/ … … 44 89 Observation *observation = NULL; 45 90 46 /*Check that observations is not empty*/47 if(n==0) _error_("No observation found");91 /*Checks*/ 92 _assert_(n); 48 93 49 94 /*Get extrema*/ … … 89 134 this->quadtree->ClosestObs(&index,x[i],y[i]); 90 135 if(index>=0){ 91 observation= dynamic_cast<Observation*>(this->GetObjectByOffset(index));136 observation=xDynamicCast<Observation*>(this->GetObjectByOffset(index)); 92 137 if(pow(observation->x-x[i],2)+pow(observation->y-y[i],2) < minspacing) continue; 93 138 } … … 110 155 } 111 156 /*}}}*/ 112 Observations::~Observations(){/*{{{*/ 113 delete quadtree; 114 return; 157 void Observations::InitCovertree(IssmPDouble* observations_list,IssmPDouble* x,IssmPDouble* y,int n,Options* options){/*{{{*/ 158 159 int maxdepth = 20; 160 _printf0_("Generating covertree with a maximum depth " << maxdepth <<"... "); 161 this->covertree=new Covertree(maxdepth); 162 163 for(int i=0;i<n;i++){ 164 this->covertree->insert(Observation(x[i],y[i],observations_list[i])); 165 } 166 _printf0_("done\n"); 115 167 } 116 168 /*}}}*/ … … 131 183 this->quadtree->ClosestObs(&index,x_interp,y_interp); 132 184 if(index>=0){ 133 observation= dynamic_cast<Observation*>(this->GetObjectByOffset(index));185 observation=xDynamicCast<Observation*>(this->GetObjectByOffset(index)); 134 186 hmin = sqrt((observation->x-x_interp)*(observation->x-x_interp) + (observation->y-y_interp)*(observation->y-y_interp)); 135 187 if(hmin<radius) radius=hmin; … … 139 191 this->quadtree->RangeSearch(&indices,&nobs,x_interp,y_interp,radius); 140 192 for (i=0;i<nobs;i++){ 141 observation= dynamic_cast<Observation*>(this->GetObjectByOffset(indices[i]));193 observation=xDynamicCast<Observation*>(this->GetObjectByOffset(indices[i])); 142 194 h2 = (observation->x-x_interp)*(observation->x-x_interp) + (observation->y-y_interp)*(observation->y-y_interp); 143 195 if(i==0){ … … 155 207 /*Assign output pointer*/ 156 208 if(nobs || hmin==radius){ 157 observation= dynamic_cast<Observation*>(this->GetObjectByOffset(index));209 observation=xDynamicCast<Observation*>(this->GetObjectByOffset(index)); 158 210 *px = observation->x; 159 211 *py = observation->y; … … 183 235 }/*}}}*/ 184 236 void Observations::ObservationList(IssmPDouble **px,IssmPDouble **py,IssmPDouble **pobs,int* pnobs,IssmPDouble x_interp,IssmPDouble y_interp,IssmPDouble radius,int maxdata){/*{{{*/ 237 238 if(this->treetype==2){ 239 this->ObservationList2(px,py,pobs,pnobs,x_interp,y_interp,radius,maxdata); 240 return; 241 } 185 242 186 243 /*Output and Intermediaries*/ … … 210 267 nobs = 0; 211 268 for(i=0;i<tempnobs;i++){ 212 observation= dynamic_cast<Observation*>(this->GetObjectByOffset(tempindices[i]));269 observation=xDynamicCast<Observation*>(this->GetObjectByOffset(tempindices[i])); 213 270 h2 = (observation->x-x_interp)*(observation->x-x_interp) + (observation->y-y_interp)*(observation->y-y_interp); 214 271 … … 252 309 /*Loop over all observations and fill in x, y and obs*/ 253 310 for(i=0;i<nobs;i++){ 254 observation= dynamic_cast<Observation*>(this->GetObjectByOffset(indices[i]));311 observation=xDynamicCast<Observation*>(this->GetObjectByOffset(indices[i])); 255 312 observation->WriteXYObs(&x[i],&y[i],&obs[i]); 256 313 } … … 280 337 obs = xNew<IssmPDouble>(nobs); 281 338 for(int i=0;i<this->Size();i++){ 282 observation= dynamic_cast<Observation*>(this->GetObjectByOffset(i));339 observation=xDynamicCast<Observation*>(this->GetObjectByOffset(i)); 283 340 observation->WriteXYObs(&x[i],&y[i],&obs[i]); 284 341 } … … 510 567 void Observations::QuadtreeColoring(IssmPDouble* A,IssmPDouble *x,IssmPDouble *y,int n){/*{{{*/ 511 568 569 if(this->treetype!=1) _error_("Tree type is not quadtree"); 512 570 int xi,yi,level; 513 571 … … 532 590 533 591 for(i=0;i<this->Size();i++){ 534 observation1= dynamic_cast<Observation*>(this->GetObjectByOffset(i));592 observation1=xDynamicCast<Observation*>(this->GetObjectByOffset(i)); 535 593 536 594 for(j=i+1;j<this->Size();j++){ 537 observation2= dynamic_cast<Observation*>(this->GetObjectByOffset(j));595 observation2=xDynamicCast<Observation*>(this->GetObjectByOffset(j)); 538 596 539 597 distance=sqrt(pow(observation1->x - observation2->x,2) + pow(observation1->y - observation2->y,2)); … … 558 616 xDelete<IssmPDouble>(counter); 559 617 }/*}}}*/ 618 619 void Observations::ObservationList2(double **px,double **py,double **pobs,int* pnobs,double x_interp,double y_interp,double radius,int maxdata){/*{{{*/ 620 621 622 double *x = NULL; 623 double *y = NULL; 624 double *obs = NULL; 625 Observation observation=Observation(x_interp,y_interp,0.); 626 std::vector<Observation> kNN; 627 628 kNN=(this->covertree->kNearestNeighbors(observation, maxdata)); 629 //cout << "kNN's size: " << kNN.size() << " (maxdata = " <<maxdata<<")"<<endl; 630 631 //kNN is sort from closest to farthest neighbor 632 //searches for the first neighbor that is out of radius 633 //deletes and resizes the kNN vector 634 vector<Observation>::iterator it; 635 if(radius>0.){ 636 for (it = kNN.begin(); it != kNN.end(); ++it) { 637 //(*it).print(); 638 //cout << "\n" << (*it).distance(observation) << endl; 639 if ((*it).distance(observation) > radius) { 640 break; 641 } 642 } 643 kNN.erase(it, kNN.end()); 644 } 645 646 /*Allocate vectors*/ 647 x = new double[kNN.size()]; 648 y = new double[kNN.size()]; 649 obs = new double[kNN.size()]; 650 651 /*Loop over all observations and fill in x, y and obs*/ 652 int i = 0; 653 for(it = kNN.begin(); it != kNN.end(); ++it) { 654 (*it).WriteXYObs((*it), &x[i], &y[i], &obs[i]); 655 i++; 656 } 657 658 *px=x; 659 *py=y; 660 *pobs=obs; 661 *pnobs = kNN.size(); 662 }/*}}}*/ -
issm/trunk/src/c/classes/kriging/Observations.h
r15396 r19105 3 3 4 4 class Quadtree; 5 class Covertree; 5 6 class Variogram; 6 7 class Options; … … 16 17 17 18 private: 18 Quadtree* quadtree; 19 int treetype; 20 Quadtree* quadtree; 21 Covertree* covertree; 19 22 20 23 public: … … 24 27 Observations(IssmDouble* observations_list,IssmDouble* x,IssmDouble* y,int n,Options* options); 25 28 ~Observations(); 29 30 /*Initialize data structures*/ 31 void InitQuadtree(IssmDouble* observations_list,IssmDouble* x,IssmDouble* y,int n,Options* options); 32 void InitCovertree(IssmDouble* observations_list,IssmDouble* x,IssmDouble* y,int n,Options* options); 26 33 27 34 /*Methods*/ … … 34 41 void ObservationList(IssmDouble **px,IssmDouble **py,IssmDouble **pobs,int* pnobs); 35 42 void ObservationList(IssmDouble **px,IssmDouble **py,IssmDouble **pobs,int* pnobs,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius,int maxdata); 43 void ObservationList2(IssmDouble **px,IssmDouble **py,IssmDouble **pobs,int* pnobs,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius,int maxdata); 36 44 void QuadtreeColoring(IssmDouble* A,IssmDouble *x,IssmDouble *y,int n); 37 45 void Variomap(IssmDouble* gamma,IssmDouble *x,int n); -
issm/trunk/src/c/classes/kriging/krigingobjects.h
r15396 r19105 13 13 #include "./PowerVariogram.h" 14 14 #include "./Quadtree.h" 15 #include "./Covertree.h" 15 16 #include "./Observation.h" 16 17 #include "./Observations.h" -
issm/trunk/src/c/classes/matrix/ElementMatrix.cpp
r18301 r19105 329 329 } 330 330 /*}}}*/ 331 void ElementMatrix::AddDiagonalToGlobal(Vector<IssmDouble>* pf){/*{{{*/ 332 333 IssmDouble* localvalues=NULL; 334 335 /*Check that pf is not NULL*/ 336 _assert_(pf); 337 338 /*In debugging mode, check consistency (no NaN, and values not too big)*/ 339 this->CheckConsistency(); 340 341 if(this->dofsymmetrical){ 342 /*only use row dofs to add values into global matrices: */ 343 344 if(this->row_fsize){ 345 /*first, retrieve values that are in the f-set from the g-set values matrix: */ 346 localvalues=xNew<IssmDouble>(this->row_fsize); 347 for(int i=0;i<this->row_fsize;i++){ 348 localvalues[i] = this->values[this->ncols*this->row_flocaldoflist[i]+ this->row_flocaldoflist[i]]; 349 } 350 351 /*add local values into global matrix, using the fglobaldoflist: */ 352 pf->SetValues(this->row_fsize,this->row_fglobaldoflist,localvalues,ADD_VAL); 353 354 /*Free ressources:*/ 355 xDelete<IssmDouble>(localvalues); 356 } 357 } 358 else{ 359 _error_("non dofsymmetrical matrix AddToGlobal routine not support yet!"); 360 } 361 362 } 363 /*}}}*/ 331 364 void ElementMatrix::CheckConsistency(void){/*{{{*/ 332 365 /*Check element matrix values, only in debugging mode*/ … … 339 372 } 340 373 #endif 374 } 375 /*}}}*/ 376 void ElementMatrix::Lump(void){/*{{{*/ 377 378 if(!dofsymmetrical) _error_("not supported yet"); 379 380 for(int i=0;i<this->nrows;i++){ 381 for(int j=0;j<this->ncols;j++){ 382 if(i!=j){ 383 this->values[i*this->ncols+i] += this->values[i*this->ncols+j]; 384 this->values[i*this->ncols+j] = 0.; 385 } 386 } 387 } 388 389 return; 341 390 } 342 391 /*}}}*/ -
issm/trunk/src/c/classes/matrix/ElementMatrix.h
r16560 r19105 60 60 void AddToGlobal(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs); 61 61 void AddToGlobal(Matrix<IssmDouble>* Jff); 62 void AddDiagonalToGlobal(Vector<IssmDouble>* pf); 62 63 void Echo(void); 63 64 void CheckConsistency(void); 64 65 void StaticCondensation(int numindices,int* indices); 66 void Lump(void); 65 67 void Transpose(void); 66 68 void Init(ElementMatrix* Ke); -
issm/trunk/src/c/cores/WrapperCorePointerFromSolutionEnum.cpp
r18301 r19105 47 47 case 2: solutioncore=controlm1qn3_core; break; 48 48 case 3: solutioncore=controlvalidation_core; break; 49 case 4: solutioncore=controlad_core; break; 49 50 default: _error_("control type not supported"); 50 51 } -
issm/trunk/src/c/cores/ad_core.cpp
r16518 r19105 28 28 bool isautodiff = false; 29 29 char *driver = NULL; 30 size_t tape_stats[1 1];30 size_t tape_stats[15]; 31 31 32 32 /*state variables: */ … … 45 45 /*First, stop tracing: */ 46 46 trace_off(); 47 48 /*retrieve parameters: */49 femmodel->parameters->FindParam(&num_dependents,AutodiffNumDependentsEnum);50 femmodel->parameters->FindParam(&num_independents,AutodiffNumIndependentsEnum);51 52 /*if no dependents, no point in running a driver: */53 if(!(num_dependents*num_independents)) return;54 55 /*for adolc to run in parallel, we 0 out on rank~=0:*/56 if (my_rank!=0){57 num_dependents=0; num_independents=0;58 }59 47 60 48 /*Print tape statistics so that user can kill this run if something is off already:*/ 61 tapestats(my_rank,tape_stats); //reading of tape statistics62 if(VerboseAutodiff()){49 if(VerboseAutodiff()){ /*{{{*/ 50 tapestats(my_rank,tape_stats); //reading of tape statistics 63 51 int commSize=IssmComm::GetSize(); 64 52 int *sstats=new int[7]; … … 99 87 } 100 88 delete [] sstats; 89 } /*}}}*/ 90 91 /*retrieve parameters: */ 92 femmodel->parameters->FindParam(&num_dependents,AutodiffNumDependentsEnum); 93 femmodel->parameters->FindParam(&num_independents,AutodiffNumIndependentsEnum); 94 95 /*if no dependents, no point in running a driver: */ 96 if(!(num_dependents*num_independents)) return; 97 98 /*for adolc to run in parallel, we 0 out on rank~=0:*/ 99 if (my_rank!=0){ 100 num_dependents=0; num_independents=0; 101 101 } 102 102 103 103 /*retrieve state variable: */ 104 104 femmodel->parameters->FindParam(&axp,&dummy,AutodiffXpEnum); … … 111 111 112 112 /*get the EDF pointer:*/ 113 ext_diff_fct *anEDF_for_solverx_p= dynamic_cast<GenericParam<Adolc_edf> * >(femmodel->parameters->FindParamObject(AdolcParamEnum))->GetParameterValue().myEDF_for_solverx_p;113 ext_diff_fct *anEDF_for_solverx_p=xDynamicCast<GenericParam<Adolc_edf> * >(femmodel->parameters->FindParamObject(AdolcParamEnum))->GetParameterValue().myEDF_for_solverx_p; 114 114 115 115 /*Branch according to AD driver: */ … … 258 258 /*call driver: */ 259 259 fos_reverse(my_rank,num_dependents,num_independents, aWeightVector, weightVectorTimesJac ); 260 if(VerboseAutodiff())_printf0_(" done with fos_reverse\n");261 260 262 261 /*add to results*/ -
issm/trunk/src/c/cores/adjointstressbalance_core.cpp
r17989 r19105 16 16 bool save_results; 17 17 bool conserve_loads = true; 18 int fe_FS; 18 19 19 20 /*retrieve parameters:*/ 20 21 femmodel->parameters->FindParam(&isFS,FlowequationIsFSEnum); 21 22 femmodel->parameters->FindParam(&save_results,SaveResultsEnum); 23 femmodel->parameters->FindParam(&fe_FS,FlowequationFeFSEnum); 22 24 23 25 /*Compute velocities*/ 24 26 if(VerboseSolution()) _printf0_(" computing velocities\n"); 25 27 femmodel->SetCurrentConfiguration(StressbalanceAnalysisEnum); 26 solutionsequence_nonlinear(femmodel,conserve_loads); 28 29 if(VerboseSolution()) _printf0_(" computing velocities\n"); 30 femmodel->SetCurrentConfiguration(StressbalanceAnalysisEnum); 31 if(isFS){ 32 if (fe_FS==LATaylorHoodEnum || fe_FS==LACrouzeixRaviartEnum) 33 solutionsequence_la(femmodel); 34 else 35 solutionsequence_nonlinear(femmodel,conserve_loads); 36 } 37 else{ 38 solutionsequence_nonlinear(femmodel,conserve_loads); 39 } 27 40 28 41 /*Call SurfaceAreax, because some it might be needed by PVector*/ … … 37 50 if(save_results || true){ 38 51 if(VerboseSolution()) _printf0_(" saving results\n"); 39 if (isFS){ 40 //int outputs[4] = {AdjointxEnum,AdjointyEnum,AdjointzEnum,AdjointpEnum}; 41 //femmodel->RequestedOutputsx(&femmodel->results,&outputs[0],4); 42 int outputs[3] = {AdjointxEnum,AdjointyEnum,AdjointpEnum}; 43 femmodel->RequestedOutputsx(&femmodel->results,&outputs[0],3); 52 if(isFS){ 53 if(fe_FS==LATaylorHoodEnum || fe_FS==LACrouzeixRaviartEnum){ 54 int outputs[2] = {AdjointxEnum,AdjointyEnum}; 55 femmodel->RequestedOutputsx(&femmodel->results,&outputs[0],2); 56 } 57 else{ 58 int outputs[3] = {AdjointxEnum,AdjointyEnum,AdjointpEnum}; 59 femmodel->RequestedOutputsx(&femmodel->results,&outputs[0],3); 60 } 44 61 } 45 62 else{ -
issm/trunk/src/c/cores/balancethickness2_core.cpp
r17989 r19105 13 13 14 14 /*parameters: */ 15 bool save_results; 16 17 /*activate formulation: */ 18 femmodel->SetCurrentConfiguration(Balancethickness2AnalysisEnum); 15 bool save_results; 16 IssmDouble l = 3.; 19 17 20 18 /*recover parameters: */ 21 19 femmodel->parameters->FindParam(&save_results,SaveResultsEnum); 22 20 21 if(VerboseSolution()) _printf0_("computing smooth surface slopes:\n"); 22 //femmodel->parameters->SetParam(l,SmoothThicknessMultiplierEnum); 23 //femmodel->SetCurrentConfiguration(SmoothAnalysisEnum); 24 //femmodel->parameters->SetParam(SurfaceSlopeXEnum,InputToSmoothEnum); 25 //solutionsequence_linear(femmodel); 26 //femmodel->parameters->SetParam(SurfaceSlopeYEnum,InputToSmoothEnum); 27 //solutionsequence_linear(femmodel); 28 surfaceslope_core(femmodel); 29 23 30 if(VerboseSolution()) _printf0_("call computational core:\n"); 31 femmodel->SetCurrentConfiguration(Balancethickness2AnalysisEnum); 24 32 solutionsequence_linear(femmodel); 33 //solutionsequence_nonlinear(femmodel,false); 25 34 26 35 if(save_results){ 27 36 if(VerboseSolution()) _printf0_(" saving results\n"); 28 int outputs[4] = {ThicknessEnum,PotentialEnum,VxEnum,VyEnum}; 29 femmodel->RequestedOutputsx(&femmodel->results,&outputs[0],4); 37 const int numoutputs = 6; 38 int outputs[numoutputs] = {SurfaceEnum,SurfaceSlopeXEnum,SurfaceSlopeYEnum,VxEnum,VyEnum,VelEnum}; 39 //const int numoutputs = 4; 40 //int outputs[numoutputs] = {SurfaceEnum,VxEnum,VyEnum,VelEnum}; 41 femmodel->RequestedOutputsx(&femmodel->results,&outputs[0],numoutputs); 30 42 } 31 43 -
issm/trunk/src/c/cores/balancevelocity_core.cpp
r16529 r19105 13 13 14 14 /*parameters: */ 15 bool save_results; 15 bool save_results; 16 IssmDouble l = 8.; 16 17 17 18 /*recover parameters: */ 18 19 femmodel->parameters->FindParam(&save_results,SaveResultsEnum); 19 20 20 if(VerboseSolution()) _printf0_("computing smoothed slopes:\n"); 21 femmodel->SetCurrentConfiguration(SmoothedSurfaceSlopeXAnalysisEnum); 21 if(VerboseSolution()) _printf0_("computing smooth driving stress:\n"); 22 femmodel->parameters->SetParam(l,SmoothThicknessMultiplierEnum); 23 femmodel->SetCurrentConfiguration(SmoothAnalysisEnum); 24 femmodel->parameters->SetParam(DrivingStressXEnum,InputToSmoothEnum); 22 25 solutionsequence_linear(femmodel); 23 femmodel-> SetCurrentConfiguration(SmoothedSurfaceSlopeYAnalysisEnum);26 femmodel->parameters->SetParam(DrivingStressYEnum,InputToSmoothEnum); 24 27 solutionsequence_linear(femmodel); 25 //surfaceslope_core(femmodel);26 28 27 29 if(VerboseSolution()) _printf0_("call computational core:\n"); … … 31 33 if(save_results){ 32 34 if(VerboseSolution()) _printf0_(" saving results\n"); 33 int outputs[3] = { SurfaceSlopeXEnum,SurfaceSlopeYEnum,VelEnum};35 int outputs[3] = {DrivingStressXEnum,DrivingStressYEnum,VelEnum}; 34 36 femmodel->RequestedOutputsx(&femmodel->results,&outputs[0],3); 35 37 } -
issm/trunk/src/c/cores/controlm1qn3_core.cpp
r18301 r19105 11 11 #include "../solutionsequences/solutionsequences.h" 12 12 13 #if defined (_HAVE_M1QN3_) 13 #if defined (_HAVE_M1QN3_) & !defined(_HAVE_ADOLC_) 14 14 /*m1qn3 prototypes*/ 15 15 extern "C" void *ctonbe_; // DIS mode : Conversion … … 32 32 double f,dxmin,gttol; 33 33 int maxsteps,maxiter; 34 int intn,num_controls,solution_type; 34 int intn,numberofvertices,num_controls,solution_type; 35 IssmDouble *scaling_factors = NULL; 35 36 IssmDouble *X = NULL; 36 37 IssmDouble *G = NULL; … … 43 44 femmodel->parameters->FindParam(&dxmin,InversionDxminEnum); 44 45 femmodel->parameters->FindParam(>tol,InversionGttolEnum); 46 femmodel->parameters->FindParam(&scaling_factors,NULL,InversionControlScalingFactorsEnum); 45 47 femmodel->parameters->SetParam(false,SaveResultsEnum); 48 numberofvertices=femmodel->vertices->NumberOfVertices(); 46 49 47 50 /*Initialize M1QN3 parameters*/ … … 60 63 61 64 /*Optimization criterions*/ 62 long niter= long(maxsteps); /*Maximum number of iterations*/63 long nsim= long(maxiter);/*Maximum number of function calls*/65 long niter = long(maxsteps); /*Maximum number of iterations*/ 66 long nsim = long(maxiter);/*Maximum number of function calls*/ 64 67 65 68 /*Get initial guess*/ … … 69 72 Xpetsc->GetSize(&intn); 70 73 delete Xpetsc; 74 _assert_(intn==numberofvertices*num_controls); 71 75 72 76 /*Get problem dimension and initialize gradient and initial guess*/ 73 77 long n = long(intn); 74 78 G = xNew<double>(n); 79 80 /*Scale control for M1QN3*/ 81 for(int i=0;i<numberofvertices;i++){ 82 for(int c=0;c<num_controls;c++){ 83 int index = num_controls*i+c; 84 X[index] = X[index]/scaling_factors[c]; 85 } 86 } 75 87 76 88 /*Allocate m1qn3 working arrays (see doc)*/ … … 81 93 if(VerboseControl())_printf0_(" Computing initial solution\n"); 82 94 _printf0_("\n"); 83 _printf0_("Cost function f(x) | List of contributions\n"); 84 _printf0_("_____________________________________________\n"); 85 indic = 0; //no adjoint required 95 _printf0_("Cost function f(x) | Gradient norm |g(x)| | List of contributions\n"); 96 _printf0_("____________________________________________________________________\n"); 97 98 /*Initialize Gradient and cost function of M1QN3*/ 99 indic = 4; //adjoint and gradient required 86 100 simul(&indic,&n,X,&f,G,izs,rzs,(void*)femmodel); 87 double f1=f; 88 89 indic = 4; //adjoint and gradient required 101 102 /*Estimation of the expected decrease in f during the first iteration*/ 103 double df1=f; 104 105 /*Call M1QN3 solver*/ 90 106 m1qn3_(costfuncion,prosca,&ctonbe_,&ctcabe_, 91 &n,X,&f,G,&dxmin,& f1,107 &n,X,&f,G,&dxmin,&df1, 92 108 >tol,normtype,&impres,&io,imode,&omode,&niter,&nsim,iz,dz,&ndz, 93 109 &reverse,&indic,izs,rzs,(void*)femmodel); … … 105 121 } 106 122 107 /*Get solution*/ 123 /*Constrain solution vector*/ 124 IssmDouble *XL = NULL; 125 IssmDouble *XU = NULL; 126 GetVectorFromControlInputsx(&XL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"lowerbound"); 127 GetVectorFromControlInputsx(&XU,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"upperbound"); 128 for(int i=0;i<numberofvertices;i++){ 129 for(int c=0;c<num_controls;c++){ 130 int index = num_controls*i+c; 131 X[index] = X[index]*scaling_factors[c]; 132 if(X[index]>XU[index]) X[index]=XU[index]; 133 if(X[index]<XL[index]) X[index]=XL[index]; 134 } 135 } 108 136 SetControlInputsFromVectorx(femmodel,X); 109 137 ControlInputSetGradientx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,G); … … 122 150 xDelete<double>(X); 123 151 xDelete<double>(dz); 152 xDelete<double>(XU); 153 xDelete<double>(XL); 154 xDelete<double>(scaling_factors); 124 155 } 125 156 … … 132 163 133 164 /*Recover number of cost functions responses*/ 134 int num_responses; 165 int num_responses,num_controls,numberofvertices; 166 IssmDouble* scaling_factors = NULL; 135 167 femmodel->parameters->FindParam(&num_responses,InversionNumCostFunctionsEnum); 168 femmodel->parameters->FindParam(&num_controls,InversionNumControlParametersEnum); 169 femmodel->parameters->FindParam(&scaling_factors,NULL,InversionControlScalingFactorsEnum); 170 numberofvertices=femmodel->vertices->NumberOfVertices(); 136 171 137 172 /*Constrain input vector*/ … … 140 175 GetVectorFromControlInputsx(&XL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"lowerbound"); 141 176 GetVectorFromControlInputsx(&XU,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"upperbound"); 142 for(long i=0;i<*n;i++){ 143 if(X[i]>XU[i]) X[i]=XU[i]; 144 if(X[i]<XL[i]) X[i]=XL[i]; 177 for(int i=0;i<numberofvertices;i++){ 178 for(int c=0;c<num_controls;c++){ 179 int index = num_controls*i+c; 180 X[index] = X[index]*scaling_factors[c]; 181 if(X[index]>XU[index]) X[index]=XU[index]; 182 if(X[index]<XL[index]) X[index]=XL[index]; 183 } 145 184 } 146 185 … … 162 201 _printf0_("f(x) = "<<setw(12)<<setprecision(7)<<*pf<<" | "); 163 202 164 /*Retrieve objective functions independently*/ 165 for(int i=0;i<num_responses;i++) _printf0_(" "<<setw(12)<<setprecision(7)<<Jlist[i]); 166 _printf0_("\n"); 167 xDelete<IssmDouble>(Jlist); 168 169 if(indic==0){ 203 if(*indic==0){ 170 204 /*dry run, no gradient required*/ 205 206 /*Retrieve objective functions independently*/ 207 _printf0_(" N/A |\n"); 208 for(int i=0;i<num_responses;i++) _printf0_(" "<<setw(12)<<setprecision(7)<<Jlist[i]); 209 _printf0_("\n"); 210 211 xDelete<IssmDouble>(Jlist); 171 212 xDelete<IssmDouble>(XU); 172 213 xDelete<IssmDouble>(XL); … … 185 226 186 227 /*Constrain Gradient*/ 187 for(long i=0;i<*n;i++){ 188 if(X[i]>=XU[i]) G[i]=0.; 189 if(X[i]<=XL[i]) G[i]=0.; 190 } 228 IssmDouble Gnorm = 0.; 229 for(int i=0;i<numberofvertices;i++){ 230 for(int c=0;c<num_controls;c++){ 231 int index = num_controls*i+c; 232 if(X[index]>=XU[index]) G[index]=0.; 233 if(X[index]<=XL[index]) G[index]=0.; 234 G[index] = G[index]*scaling_factors[c]; 235 X[index] = X[index]/scaling_factors[c]; 236 Gnorm += G[index]*G[index]; 237 } 238 } 239 Gnorm = sqrt(Gnorm); 240 241 /*Print info*/ 242 _printf0_(" "<<setw(12)<<setprecision(7)<<Gnorm<<" |"); 243 for(int i=0;i<num_responses;i++) _printf0_(" "<<setw(12)<<setprecision(7)<<Jlist[i]); 244 _printf0_("\n"); 191 245 192 246 /*Clean-up and return*/ 247 xDelete<IssmDouble>(Jlist); 193 248 xDelete<IssmDouble>(XU); 194 249 xDelete<IssmDouble>(XL); 250 xDelete<IssmDouble>(scaling_factors); 195 251 } 196 252 -
issm/trunk/src/c/cores/controltao_core.cpp
r18301 r19105 129 129 TaoFinalize(); 130 130 #endif 131 G->pvector->vector = NULL; 132 delete G; 131 133 } 132 134 -
issm/trunk/src/c/cores/controlvalidation_core.cpp
r18301 r19105 12 12 13 13 int solution_type,n; 14 IssmDouble j0,j; 14 int num_responses; 15 IssmDouble j0,j,yts; 15 16 IssmDouble Ialpha,exponent,alpha; 17 IssmDouble* scaling_factors = NULL; 18 IssmDouble* jlist = NULL; 16 19 IssmDouble *G = NULL; 17 20 IssmDouble *X = NULL; … … 25 28 femmodel->parameters->FindParam(&solution_type,SolutionTypeEnum); 26 29 femmodel->parameters->SetParam(false,SaveResultsEnum); 30 femmodel->parameters->FindParam(&num_responses,InversionNumCostFunctionsEnum); 31 femmodel->parameters->FindParam(&yts,ConstantsYtsEnum); 32 femmodel->parameters->FindParam(&scaling_factors,NULL,InversionControlScalingFactorsEnum); 27 33 28 34 /*Get initial guess*/ … … 33 39 delete Xpetsc; 34 40 35 /*Allocate Gradient and current vector*/ 36 G = xNew<IssmDouble>(n); 41 /*Allocate current vector*/ 37 42 X = xNew<IssmDouble>(n); 38 43 … … 45 50 if(VerboseControl()) _printf0_(" Compute Adjoint\n"); 46 51 adjointcore(femmodel); 52 47 53 if(VerboseControl()) _printf0_(" Compute Initial cost function\n"); 48 femmodel->CostFunctionx(&j0,NULL,NULL); 54 femmodel->CostFunctionx(&j0,&jlist,NULL); 55 _printf0_("Initial cost function J(x) = "<<setw(12)<<setprecision(7)<<j0<<"\n"); 56 xDelete<IssmDouble>(jlist); 57 49 58 if(VerboseControl()) _printf0_(" Compute Gradient\n"); 50 59 Gradjx(&G,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters); 51 60 for(int i=0;i<n;i++) G[i] = -G[i]; 52 61 53 /*Range of tests*/54 IssmDouble exp0 = 0.;55 IssmDouble incr = -0.2;56 IssmDouble exp1 = -10.;57 int num = reCast<int,IssmDouble>((exp1-exp0)/incr);58 59 62 /*Allocate output*/ 63 int num = 26; 60 64 IssmDouble* output = xNew<IssmDouble>(2*num); 61 65 … … 65 69 for(int m=0;m<num;m++){ 66 70 67 /*Calculate alpha = 10^-exponent*/68 exponent = exp0+m*incr;69 alpha = pow(10.,exponent);70 71 71 /*Create new vector*/ 72 for(int i=0;i<n;i++) X[i] = X0[i] + alpha; 72 alpha = pow(2.,-m); 73 for(int i=0;i<n;i++) X[i] = X0[i] + alpha*scaling_factors[0]; 73 74 74 75 /*Calculate j(k+alpha delta k) */ … … 78 79 79 80 IssmDouble Den = 0.; 80 for(int i=0;i<n;i++) Den += alpha * G[i] * 1.;81 for(int i=0;i<n;i++) Den += alpha* G[i] * scaling_factors[0]; 81 82 Ialpha = fabs((j - j0)/Den - 1.); 82 83 … … 95 96 femmodel->results->AddObject(new GenericExternalResult<IssmPDouble*>(femmodel->results->Size()+1,JEnum,output,num,2,1,0)); 96 97 #endif 98 ControlInputSetGradientx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,G); 99 femmodel->OutputControlsx(&femmodel->results); 97 100 98 101 /*Clean up and return*/ 102 xDelete<IssmDouble>(output); 99 103 xDelete<IssmDouble>(G); 100 104 xDelete<IssmDouble>(X); -
issm/trunk/src/c/cores/cores.h
r18301 r19105 29 29 void controltao_core(FemModel* femmodel); 30 30 void controlm1qn3_core(FemModel* femmodel); 31 void controlad_core(FemModel* femmodel); 31 32 void controlvalidation_core(FemModel* femmodel); 32 33 void masstransport_core(FemModel* femmodel); … … 42 43 void dakota_core(FemModel* femmodel); 43 44 void ad_core(FemModel* femmodel); 45 void adgradient_core(FemModel* femmodel); 44 46 void dummy_core(FemModel* femmodel); 45 47 void gia_core(FemModel* femmodel); … … 57 59 58 60 //solution configuration 59 void AnalysisConfiguration(int** pcores,int* pnumcores, int solutiontype);60 61 void CorePointerFromSolutionEnum(void (**psolutioncore)(FemModel*),Parameters* parameters,int solutiontype); 61 62 void WrapperCorePointerFromSolutionEnum(void (**psolutioncore)(FemModel*),Parameters* parameters,int solutiontype,bool nodakotacore=false); -
issm/trunk/src/c/cores/damage_core.cpp
r18301 r19105 34 34 femmodel->RequestedOutputsx(&femmodel->results,requested_outputs,numoutputs); 35 35 } 36 36 37 37 /*Free resources:*/ 38 38 if(numoutputs){ -
issm/trunk/src/c/cores/extrudefrombase_core.cpp
r17989 r19105 27 27 if(elementtype==PentaEnum){ 28 28 int inputenum; femmodel->parameters->FindParam(&inputenum,InputToExtrudeEnum); 29 InputExtrudex(femmodel,inputenum );29 InputExtrudex(femmodel,inputenum,-1); 30 30 } 31 31 else{ -
issm/trunk/src/c/cores/extrudefromtop_core.cpp
r16518 r19105 12 12 void extrudefromtop_core(FemModel* femmodel){ 13 13 14 /*Intermediaries*/ 15 int elementtype,domaintype; 16 14 17 if(VerboseSolution()) _printf0_("extruding solution from top...\n"); 15 18 16 /*Call on core computations: */ 17 femmodel->SetCurrentConfiguration(ExtrudeFromTopAnalysisEnum); 18 femmodel->UpdateConstraintsExtrudeFromTopx(); 19 solutionsequence_linear(femmodel); 19 /*Get parameters*/ 20 femmodel->parameters->FindParam(&domaintype,DomainTypeEnum); 21 femmodel->parameters->FindParam(&elementtype,MeshElementtypeEnum); 20 22 23 /*If this is a 2D horizontal domain, return (no need to extrude)*/ 24 if(domaintype==Domain2DhorizontalEnum) return; 25 26 /*Special method for Penta, otherwise call solution sequence*/ 27 if(elementtype==PentaEnum){ 28 int inputenum; femmodel->parameters->FindParam(&inputenum,InputToExtrudeEnum); 29 InputExtrudex(femmodel,inputenum,+1); 30 } 31 else{ 32 /*Call on core computations: */ 33 femmodel->SetCurrentConfiguration(ExtrudeFromTopAnalysisEnum); 34 femmodel->UpdateConstraintsExtrudeFromTopx(); 35 solutionsequence_linear(femmodel); 36 } 21 37 } -
issm/trunk/src/c/cores/masstransport_core.cpp
r18301 r19105 16 16 bool save_results; 17 17 bool isFS,isfreesurface,dakota_analysis; 18 int solution_type ;18 int solution_type,stabilization; 19 19 char** requested_outputs = NULL; 20 20 … … 29 29 femmodel->parameters->FindParam(&domaintype,DomainTypeEnum); 30 30 femmodel->parameters->FindParam(&numoutputs,MasstransportNumRequestedOutputsEnum); 31 femmodel->parameters->FindParam(&stabilization,MasstransportStabilizationEnum); 31 32 if(numoutputs) femmodel->parameters->FindParam(&requested_outputs,&numoutputs,MasstransportRequestedOutputsEnum); 32 33 … … 49 50 else{ 50 51 if(VerboseSolution()) _printf0_(" call computational core\n"); 51 solutionsequence_linear(femmodel); 52 if(stabilization==4){ 53 solutionsequence_fct(femmodel); 54 } 55 else{ 56 solutionsequence_linear(femmodel); 57 } 52 58 femmodel->parameters->SetParam(ThicknessEnum,InputToExtrudeEnum); 53 59 extrudefrombase_core(femmodel); -
issm/trunk/src/c/cores/thermal_core.cpp
r18301 r19105 28 28 29 29 if(isenthalpy){ 30 31 if(VerboseSolution()) _printf0_(" computing enthalpy\n"); 32 femmodel->SetCurrentConfiguration(EnthalpyAnalysisEnum); 33 solutionsequence_nonlinear(femmodel,true); 34 35 /*transfer enthalpy to enthalpy picard for the next step: */ 36 InputDuplicatex(femmodel,EnthalpyEnum,EnthalpyPicardEnum); 37 38 if(solution_type!=SteadystateSolutionEnum){ 39 /*Post process*/ 40 enthalpy_analysis = new EnthalpyAnalysis(); 41 enthalpy_analysis->PostProcessing(femmodel); 42 delete enthalpy_analysis; 43 } 30 enthalpy_analysis = new EnthalpyAnalysis(); 31 enthalpy_analysis->Core(femmodel); 32 delete enthalpy_analysis; 44 33 } 45 34 else{ -
issm/trunk/src/c/cores/transient_core.cpp
r18301 r19105 21 21 /*parameters: */ 22 22 IssmDouble starttime,finaltime,dt,yts; 23 bool isstressbalance,ismasstransport,isFS,isthermal,isgroundingline,isgia,islevelset,isdamageevolution,ishydrology ;23 bool isstressbalance,ismasstransport,isFS,isthermal,isgroundingline,isgia,islevelset,isdamageevolution,ishydrology,iscalving; 24 24 bool save_results,dakota_analysis; 25 25 bool time_adapt=false; … … 53 53 femmodel->parameters->FindParam(&ishydrology,TransientIshydrologyEnum); 54 54 femmodel->parameters->FindParam(&isFS,FlowequationIsFSEnum); 55 femmodel->parameters->FindParam(&iscalving,TransientIscalvingEnum); 55 56 if(isgroundingline) femmodel->parameters->FindParam(&groundingline_migration,GroundinglineMigrationEnum); 56 57 femmodel->parameters->FindParam(&numoutputs,TransientNumRequestedOutputsEnum); … … 101 102 102 103 if(islevelset){ 103 if(VerboseSolution()) _printf0_(" computing movement of ice boundaries\n"); 104 if(iscalving) Calvingx(femmodel); 105 if(VerboseSolution()) _printf0_(" computing levelset transport\n"); 104 106 /* smoothen slope of lsf for computation of normal on ice domain*/ 105 107 levelsetfunctionslope_core(femmodel); … … 107 109 /* extrapolate velocities onto domain with no ice */ 108 110 Analysis* extanalysis = new ExtrapolationAnalysis(); 109 const int nvars= 2;110 int vars[nvars] = {VxEnum, VyEnum };111 const int nvars=3; 112 int vars[nvars] = {VxEnum, VyEnum, ThicknessEnum}; 111 113 for(int iv=0;iv<nvars;iv++){ 112 114 femmodel->parameters->SetParam(vars[iv],ExtrapolationVariableEnum); … … 139 141 GroundinglineMigrationx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters); 140 142 141 if(groundingline_migration==ContactEnum){ 142 femmodel->parameters->SetParam(MaskGroundediceLevelsetEnum,InputToExtrudeEnum); 143 extrudefrombase_core(femmodel); 144 femmodel->parameters->SetParam(BaseEnum,InputToExtrudeEnum); 145 extrudefrombase_core(femmodel); 146 } 143 femmodel->parameters->SetParam(MaskGroundediceLevelsetEnum,InputToExtrudeEnum); 144 extrudefrombase_core(femmodel); 145 femmodel->parameters->SetParam(BaseEnum,InputToExtrudeEnum); 146 extrudefrombase_core(femmodel); 147 femmodel->parameters->SetParam(SurfaceEnum,InputToExtrudeEnum); 148 extrudefrombase_core(femmodel); 149 147 150 if(save_results){ 148 151 int outputs[3] = {SurfaceEnum,BaseEnum,MaskGroundediceLevelsetEnum}; -
issm/trunk/src/c/main/kriging.cpp
r16560 r19105 58 58 results->AddObject(new GenericExternalResult<double*>(results->Size()+1,1,error,ninterp,1,1,0)); 59 59 for(int i=0;i<results->Size();i++){ 60 ExternalResult* result= dynamic_cast<ExternalResult*>(results->GetObjectByOffset(i));60 ExternalResult* result=xDynamicCast<ExternalResult*>(results->GetObjectByOffset(i)); 61 61 result->WriteData(output_fid,1); 62 62 } -
issm/trunk/src/c/modules
-
Property svn:ignore
set to
.deps
-
Property svn:ignore
set to
-
issm/trunk/src/c/modules/AllocateSystemMatricesx/AllocateSystemMatricesx.cpp
r16560 r19105 134 134 k=0; 135 135 for(i=0;i<femmodel->elements->Size();i++){ 136 element = dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));136 element = xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 137 137 lidlist = xNew<int>(element->GetNumberOfNodes()); 138 138 element->GetNodesLidList(lidlist); … … 157 157 k=0; 158 158 for(i=0;i<femmodel->loads->Size();i++){ 159 load = dynamic_cast<Load*>(femmodel->loads->GetObjectByOffset(i));159 load = xDynamicCast<Load*>(femmodel->loads->GetObjectByOffset(i)); 160 160 if(!load->InAnalysis(configuration_type)) continue; 161 161 lidlist = xNew<int>(load->GetNumberOfNodes()); … … 190 190 /*Create connectivity vector*/ 191 191 for(i=0;i<femmodel->nodes->Size();i++){ 192 Node* node= dynamic_cast<Node*>(femmodel->nodes->GetObjectByOffset(i));192 Node* node=xDynamicCast<Node*>(femmodel->nodes->GetObjectByOffset(i)); 193 193 if(node->InAnalysis(configuration_type)){ 194 194 … … 214 214 for(j=head_e[node->Lid()];j!=-1;j=next_e[j]){ 215 215 offset=count2offset_e[j]; 216 element= dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(offset));216 element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(offset)); 217 217 element->SetwiseNodeConnectivity(&d_nz,&o_nz,node,flags,flagsindices,set1enum,set2enum); 218 218 if(node->IsClone()){ … … 226 226 for(j=head_l[node->Lid()];j!=-1;j=next_l[j]){ 227 227 offset=count2offset_l[j]; 228 load= dynamic_cast<Load*>(femmodel->loads->GetObjectByOffset(offset));228 load=xDynamicCast<Load*>(femmodel->loads->GetObjectByOffset(offset)); 229 229 load->SetwiseNodeConnectivity(&d_nz,&o_nz,node,flags,flagsindices,set1enum,set2enum); 230 230 if(node->IsClone()){ … … 256 256 o_nnz=xNew<int>(m); 257 257 for(i=0;i<femmodel->nodes->Size();i++){ 258 Node* node= dynamic_cast<Node*>(femmodel->nodes->GetObjectByOffset(i));258 Node* node=xDynamicCast<Node*>(femmodel->nodes->GetObjectByOffset(i)); 259 259 if(node->InAnalysis(configuration_type) && !node->IsClone()){ 260 260 for(j=0;j<node->indexing.fsize;j++){ -
issm/trunk/src/c/modules/AverageOntoPartitionx/AverageOntoPartitionx.cpp
r16560 r19105 41 41 /*loop on each element, and add contribution of the element to the partition (surface weighted average): */ 42 42 for(int i=0;i<elements->Size();i++){ 43 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));43 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 44 44 element->AverageOntoPartition(partition_contributions,partition_areas,vertex_response,qmu_part); 45 45 } -
issm/trunk/src/c/modules/ConfigureObjectsx/ConfigureObjectsx.cpp
r16560 r19105 24 24 if(VerboseMProcessor()) _printf0_(" Configuring elements...\n"); 25 25 for(i=0;i<elements->Size();i++){ 26 element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));26 element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 27 27 element->Configure(elements,loads,nodes,vertices,materials,parameters); 28 28 } -
issm/trunk/src/c/modules/CreateJacobianMatrixx/CreateJacobianMatrixx.cpp
r17806 r19105 29 29 /*Create and assemble matrix*/ 30 30 for(i=0;i<femmodel->elements->Size();i++){ 31 element= dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));31 element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 32 32 ElementMatrix* Je = analysis->CreateJacobianMatrix(element); 33 33 if(Je) Je->AddToGlobal(Jff); -
issm/trunk/src/c/modules/DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.cpp
r17989 r19105 16 16 /*Compute Misfit: */ 17 17 for(int i=0;i<elements->Size();i++){ 18 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));18 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 19 19 J+=DragCoefficientAbsGradient(element); 20 20 } -
issm/trunk/src/c/modules/FloatingiceMeltingRatex
- Property svn:ignore
-
old new 1 1 .deps 2 .dirstamp
-
- Property svn:ignore
-
issm/trunk/src/c/modules/FloatingiceMeltingRatex/FloatingiceMeltingRatex.cpp
r18093 r19105 33 33 34 34 for(int i=0;i<femmodel->elements->Size();i++){ 35 Element* element= dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));35 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 36 36 element->LinearFloatingiceMeltingRate(); 37 37 } -
issm/trunk/src/c/modules/GetSolutionFromInputsx/GetSolutionFromInputsx.cpp
r17806 r19105 32 32 Analysis* analysis = EnumToAnalysis(analysisenum); 33 33 for(int i=0;i<femmodel->elements->Size();i++){ 34 Element* element= dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));34 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 35 35 analysis->GetSolutionFromInputs(solution,element); 36 36 } -
issm/trunk/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.cpp
r15396 r19105 7 7 #include "../../toolkits/toolkits.h" 8 8 9 void GetVectorFromControlInputsx(Vector<IssmDouble>** pvector, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,const char* data ){9 void GetVectorFromControlInputsx(Vector<IssmDouble>** pvector, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,const char* data,bool onsid){ 10 10 11 11 int num_controls; … … 23 23 for(int j=0;j<elements->Size();j++){ 24 24 Element* element=(Element*)elements->GetObjectByOffset(j); 25 element->GetVectorFromControlInputs(vector,control_type[i],i,data );25 element->GetVectorFromControlInputs(vector,control_type[i],i,data,onsid); 26 26 } 27 27 } … … 34 34 } 35 35 36 void GetVectorFromControlInputsx( IssmDouble** pvector, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters, const char* data ){36 void GetVectorFromControlInputsx( IssmDouble** pvector, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters, const char* data,bool onsid){ 37 37 38 38 /*output: */ … … 42 42 Vector<IssmDouble>* vec_vector=NULL; 43 43 44 GetVectorFromControlInputsx( &vec_vector, elements,nodes, vertices, loads, materials, parameters,data );44 GetVectorFromControlInputsx( &vec_vector, elements,nodes, vertices, loads, materials, parameters,data,onsid); 45 45 vector=vec_vector->ToMPISerial(); 46 46 -
issm/trunk/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.h
r15396 r19105 8 8 9 9 /* local prototypes: */ 10 void GetVectorFromControlInputsx( Vector<IssmDouble>** pvector, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials, Parameters* parameters,const char* data="value" );11 void GetVectorFromControlInputsx( IssmDouble** pvector, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials, Parameters* parameters,const char* data="value" );10 void GetVectorFromControlInputsx( Vector<IssmDouble>** pvector, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials, Parameters* parameters,const char* data="value",bool onsid=false); 11 void GetVectorFromControlInputsx( IssmDouble** pvector, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials, Parameters* parameters,const char* data="value",bool onsid=false); 12 12 13 13 #endif /* _GETVECTORFROMCONTROLINPUTSXX_H */ -
issm/trunk/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.cpp
r17806 r19105 7 7 #include "../../toolkits/toolkits.h" 8 8 9 void GetVectorFromInputsx( 9 void GetVectorFromInputsx(Vector<IssmDouble>** pvector,FemModel* femmodel,int name,int type){ 10 10 11 11 int i; 12 12 Vector<IssmDouble>* vector=NULL; 13 13 14 if(type==VertexEnum){ 15 16 /*Allocate vector*/ 14 switch(type){ 15 case VertexPIdEnum: case VertexSIdEnum: 17 16 vector=new Vector<IssmDouble>(femmodel->vertices->NumberOfVertices()); 18 19 /*Look up in elements*/20 for(i=0;i<femmodel->elements->Size();i++){21 Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));22 element->GetVectorFromInputs(vector,name);23 }17 break; 18 case NodesEnum:case NodeSIdEnum: 19 vector=new Vector<IssmDouble>(femmodel->nodes->NumberOfNodes()); 20 break; 21 default: 22 _error_("vector type: " << EnumToStringx(type) << " not supported yet!"); 24 23 } 25 else{ 26 _error_("vector type: " << EnumToStringx(type) << " not supported yet!"); 24 /*Look up in elements*/ 25 for(i=0;i<femmodel->elements->Size();i++){ 26 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 27 element->GetVectorFromInputs(vector,name,type); 27 28 } 28 29 -
issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp
r18301 r19105 15 15 Element *element = NULL; 16 16 17 if(VerboseModule()) _printf0_(" Migrating grounding line\n");18 17 19 18 /*retrieve parameters: */ … … 22 21 23 22 if(migration_style==NoneEnum) return; 23 24 if(VerboseModule()) _printf0_(" Migrating grounding line\n"); 24 25 25 26 /*Set toolkit to default*/ … … 39 40 case SubelementMigrationEnum: 40 41 case SubelementMigration2Enum: 42 case GroundingOnlyEnum: 41 43 /*Nothing additional to do here, MigrateGroundingLine takes care of everything*/ 42 44 break; … … 47 49 /*Migrate grounding line : */ 48 50 for(int i=0;i<elements->Size();i++){ 49 element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));51 element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 50 52 element->MigrateGroundingLine(phi_ungrounding); 51 53 } … … 72 74 /*Fill vector vertices_potentially_floating: */ 73 75 for(int i=0;i<elements->Size();i++){ 74 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));76 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 75 77 element->FSContactMigration(vertexgrounded,vertexfloating); 76 78 } … … 81 83 serial_vertexgrounded=vertexgrounded->ToMPISerial(); 82 84 serial_vertexfloating=vertexfloating->ToMPISerial(); 83 84 /*find vertices on GL */85 85 for(int i=0;i<numberofvertices;i++){ 86 if(serial_vertexgrounded[i]==1. && serial_vertexfloating[i]==1.){ 87 phi[i]=0.; 88 } 89 else if(serial_vertexgrounded[i]==1.){ 90 phi[i]=1.; 91 } 92 else if(serial_vertexfloating[i]==1.){ 93 phi[i]=-1.; 94 } 95 else{ 96 phi[i]=9999.; 97 } 86 if (serial_vertexgrounded[i]==1. && serial_vertexfloating[i]==1.) phi[i]=0.; 87 else if (serial_vertexgrounded[i]==1) phi[i]=1; 88 else if (serial_vertexfloating[i]==1) phi[i]=-1; 89 else if (serial_vertexgrounded[i]>10) phi[i]=9999; 90 else phi[i]=-9999; 98 91 } 99 92 … … 120 113 /*Fill vector vertices_potentially_floating: */ 121 114 for(i=0;i<elements->Size();i++){ 122 element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));115 element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 123 116 element->PotentialUngrounding(vec_vertices_potentially_ungrounding); 124 117 } … … 148 141 vec_phi=new Vector<IssmDouble>(vertices->NumberOfVertices()); 149 142 for(i=0;i<elements->Size();i++){ 150 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));151 element->GetVectorFromInputs(vec_phi,MaskGroundediceLevelsetEnum );143 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 144 element->GetVectorFromInputs(vec_phi,MaskGroundediceLevelsetEnum,VertexPIdEnum); 152 145 } 153 146 vec_phi->Assemble(); … … 162 155 /*Figure out if any of the nodes of the element will be floating -> elements neighbouting the floating ice*/ 163 156 for(i=0;i<elements->Size();i++){ 164 element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));157 element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 165 158 vec_elements_neighboring_floatingice->SetValue(element->Sid(),element->IsNodeOnShelfFromFlags(phi)?1.0:0.0,INS_VAL); 166 159 } … … 173 166 local_nflipped=0; 174 167 for(i=0;i<elements->Size();i++){ 175 element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));168 element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 176 169 if(reCast<int,IssmDouble>(elements_neighboring_floatingce[element->Sid()])){ 177 170 local_nflipped+=element->UpdatePotentialUngrounding(vertices_potentially_ungrounding,vec_phi,phi); -
issm/trunk/src/c/modules/InputControlUpdatex/InputControlUpdatex.cpp
r15396 r19105 12 12 /*Go through elemnets, and ask to carry out the operation on inputs: */ 13 13 for(int i=0;i<elements->Size();i++){ 14 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));14 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 15 15 element->InputControlUpdate(scalar,save_parameter); 16 16 } -
issm/trunk/src/c/modules/InputDepthAverageAtBasex/InputDepthAverageAtBasex.cpp
r17862 r19105 10 10 void InputDepthAverageAtBasex(FemModel* femmodel,int original_enum, int new_enum){ 11 11 for(int i=0;i<femmodel->elements->Size();i++){ 12 Element* element= dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));12 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 13 13 element->InputDepthAverageAtBase(original_enum,new_enum); 14 14 } -
issm/trunk/src/c/modules/InputDuplicatex/InputDuplicatex.cpp
r17806 r19105 11 11 /*Go through elemnets, and ask to reinitialie the input: */ 12 12 for(int i=0;i<femmodel->elements->Size();i++){ 13 Element* element= dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));13 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 14 14 element->InputDuplicate(original_enum,new_enum); 15 15 } -
issm/trunk/src/c/modules/InputExtrudex/InputExtrudex.cpp
r17862 r19105 8 8 #include "../../toolkits/toolkits.h" 9 9 10 void InputExtrudex(FemModel* femmodel,int input_enum ){10 void InputExtrudex(FemModel* femmodel,int input_enum,int start){ 11 11 for(int i=0;i<femmodel->elements->Size();i++){ 12 Element* element= dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));13 element->InputExtrude(input_enum );12 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 13 element->InputExtrude(input_enum,start); 14 14 } 15 15 } -
issm/trunk/src/c/modules/InputExtrudex/InputExtrudex.h
r17862 r19105 9 9 10 10 /* local prototypes: */ 11 void InputExtrudex(FemModel* femmodel,int input_enum );11 void InputExtrudex(FemModel* femmodel,int input_enum,int start); 12 12 13 13 #endif /* _INPUTDUPLICATEX_H */ -
issm/trunk/src/c/modules/InputScalex/InputScalex.cpp
r15396 r19105 15 15 /*Go through elemnets, and ask to reinitialie the input: */ 16 16 for(i=0;i<elements->Size();i++){ 17 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));17 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 18 18 element->InputScale(enum_type,scale_factor); 19 19 } -
issm/trunk/src/c/modules/InputUpdateFromConstantx/InputUpdateFromConstantx.cpp
r16560 r19105 14 14 /*Elements and loads drive the update: */ 15 15 for(i=0;i<femmodel->elements->Size();i++){ 16 Element* element= dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));16 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 17 17 element->InputUpdateFromConstant(constant,name); 18 18 } … … 35 35 /*Elements and loads drive the update: */ 36 36 for(i=0;i<femmodel->elements->Size();i++){ 37 Element* element= dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));37 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 38 38 element->InputUpdateFromConstant(constant,name); 39 39 } … … 56 56 /*Elements and loads drive the update: */ 57 57 for(i=0;i<femmodel->elements->Size();i++){ 58 Element* element= dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));58 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 59 59 element->InputUpdateFromConstant(constant,name); 60 60 } … … 78 78 /*Elements and loads drive the update: */ 79 79 for(i=0;i<elements->Size();i++){ 80 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));80 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 81 81 element->InputUpdateFromConstant(constant,name); 82 82 } -
issm/trunk/src/c/modules/InputUpdateFromMatrixDakotax/InputUpdateFromMatrixDakotax.cpp
r16137 r19105 20 20 /*Update elements, nodes, loads and materials from inputs: */ 21 21 for(i=0;i<femmodel->elements->Size();i++){ 22 Element* element= dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));22 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 23 23 element->InputUpdateFromMatrixDakota(matrix,nrows,ncols,name,type); 24 24 } -
issm/trunk/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.cpp
r18301 r19105 30 30 Analysis* analysis = EnumToAnalysis(analysisenum); 31 31 for(int i=0;i<femmodel->elements->Size();i++){ 32 Element* element= dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));32 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 33 33 analysis->InputUpdateFromSolution(solution,element); 34 34 } -
issm/trunk/src/c/modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.cpp
r16137 r19105 22 22 /*Update elements, nodes, loads and materials from inputs: */ 23 23 for(i=0;i<femmodel->elements->Size();i++){ 24 Element* element= dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));24 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 25 25 element->InputUpdateFromVectorDakota(vector,name,type); 26 26 } -
issm/trunk/src/c/modules/InputUpdateFromVectorx/InputUpdateFromVectorx.cpp
r16137 r19105 20 20 /*Update elements, nodes, loads and materials from inputs: */ 21 21 for(i=0;i<femmodel->elements->Size();i++){ 22 Element* element= dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));22 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 23 23 element->InputUpdateFromVector(vector,name,type); 24 24 } -
issm/trunk/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp
r16560 r19105 49 49 50 50 /*read background mesh*/ 51 Mesh Th(index_data,x_data,y_data,nods_data,nels_data);51 Mesh* Th=new Mesh(index_data,x_data,y_data,nods_data,nels_data); 52 52 53 53 /*Get reference number (for subdomains)*/ 54 long* reft = xNew<long>(Th .nbt);55 Th .TriangleReferenceList(reft);56 Th .CreateSingleVertexToTriangleConnectivity();54 long* reft = xNew<long>(Th->nbt); 55 Th->TriangleReferenceList(reft); 56 Th->CreateSingleVertexToTriangleConnectivity(); 57 57 58 58 /*Get domain boundaries*/ … … 79 79 /*Get current point coordinates*/ 80 80 r.x=x_interp[i]; r.y=y_interp[i]; 81 I2 I=Th .R2ToI2(r);81 I2 I=Th->R2ToI2(r); 82 82 83 83 /*Find triangle holding r/I*/ 84 Triangle &tb=*Th .TriangleFindFromCoord(I,dete);84 Triangle &tb=*Th->TriangleFindFromCoord(I,dete); 85 85 86 86 /*point inside convex*/ … … 92 92 areacoord[2]= (double) dete[2]/tb.det; 93 93 /*3 vertices of the triangle*/ 94 i0=Th .GetId(tb[0]);95 i1=Th .GetId(tb[1]);96 i2=Th .GetId(tb[2]);94 i0=Th->GetId(tb[0]); 95 i1=Th->GetId(tb[1]); 96 i2=Th->GetId(tb[2]); 97 97 /*triangle number*/ 98 it=Th .GetId(tb);98 it=Th->GetId(tb); 99 99 100 100 /*Inside convex but outside mesh*/ … … 120 120 areacoord[OppositeVertex[k]] = 1 - aa -bb; 121 121 //3 vertices of the triangle 122 i0=Th .GetId(tc[0]);123 i1=Th .GetId(tc[1]);124 i2=Th .GetId(tc[2]);122 i0=Th->GetId(tc[0]); 123 i1=Th->GetId(tc[1]); 124 i2=Th->GetId(tc[2]); 125 125 //triangle number 126 it=Th .GetId(tc);126 it=Th->GetId(tc); 127 127 } 128 128 } … … 145 145 146 146 /*clean-up and return*/ 147 delete Th; 147 148 xDelete<long>(reft); 148 149 *pdata_interp=data_interp; -
issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshProfileIntersectionx.cpp
r16560 r19105 129 129 ysegment[0]=yc[i]; 130 130 ysegment[1]=yc[i+1]; 131 ElementSegment(segments_dataset,el, xnodes,ynodes,xsegment,ysegment); 132 } 133 }/*}}}*/ 134 void ElementSegment(DataSet* segments_dataset,int el,double* xnodes,double* ynodes,double* xsegment,double* ysegment){/*{{{*/ 131 /*if (el==318 && i==9){ 132 _printf_("contour: " << i << " " << xsegment[0] << " " << ysegment[0] << " " << xsegment[1] << " " << ysegment[1] 133 << " " << xnodes[0] << " " << xnodes[1] << " " << xnodes[2] << " " << ynodes[0] << " " << ynodes[1] << " " << 134 ynodes[2] << "\n"); 135 }*/ 136 ElementSegment(segments_dataset,el, i, xnodes,ynodes,xsegment,ysegment); 137 } 138 }/*}}}*/ 139 void ElementSegment(DataSet* segments_dataset,int el, int contouri, double* xnodes,double* ynodes,double* xsegment,double* ysegment){/*{{{*/ 135 140 136 141 /*We have a tria element (xnodes,ynodes) and a segment (xsegment,ysegment). Find whether they intersect. … … 159 164 edge3=SegmentIntersect(&gamma1,&gamma2, xel,yel,xsegment,ysegment); 160 165 161 /*edge can be either IntersectEnum (one iand only one intersection between the edge and the segment), ColinearEnum (edge and segment are collinear) and SeparateEnum (no intersection): */ 166 /*edge can be either IntersectEnum (one and only one intersection between the edge and the segment), ColinearEnum (edge and segment are collinear) and SeparateEnum (no intersection): */ 167 168 /*if (el==318 && contouri==9){ 169 _printf_(edge1 << " " << edge2 << " " << edge3 << " " << alpha1 << " " << alpha2 << " " << beta1 << " " << beta2 << " " << gamma1 << " " << gamma2 << " " << xsegment[0] << " " << xsegment[1] << " " << ysegment[0] << " " << ysegment[1] << " " << xnodes[0] << " " << xnodes[1] << " " << xnodes[2] << " " << ynodes[0] << " " << ynodes[1] << " " << ynodes[2]); 170 171 _printf_("Bool" << (edge1==IntersectEnum) || (edge2==IntersectEnum) || (edge3==IntersectEnum)); 172 }*/ 162 173 163 174 if( (edge1==IntersectEnum) && (edge2==IntersectEnum) && (edge3==IntersectEnum) ){ 164 /*This case is impossible: */ 165 _error_("error: a line cannot go through 3 different vertices!"); 175 176 /*This can only be the case if the segment intersected through one vertex, meaning a pair from alpha1, beta1 or gamma1 is 0:*/ 177 if (alpha1!=0 && alpha1!=1){ 178 /*The vertex opposite edge 1 was intersected:*/ 179 xfinal[0]=xsegment[0]+alpha1*(xsegment[1]-xsegment[0]); 180 yfinal[0]=ysegment[0]+alpha1*(ysegment[1]-ysegment[0]); 181 xfinal[1]=xnodes[2]; 182 yfinal[1]=ynodes[2]; 183 } 184 else if (beta1!=0 && beta1!=1){ 185 /*The vertex opposite edge 2 was intersected:*/ 186 xfinal[0]=xsegment[0]+beta1*(xsegment[1]-xsegment[0]); 187 yfinal[0]=ysegment[0]+beta1*(ysegment[1]-ysegment[0]); 188 xfinal[1]=xnodes[0]; 189 yfinal[1]=ynodes[0]; 190 } 191 else if (gamma1!=0 && gamma1!=1){ 192 /*The vertex opposite edge 3 was intersected:*/ 193 xfinal[0]=xsegment[0]+gamma1*(xsegment[1]-xsegment[0]); 194 yfinal[0]=ysegment[0]+gamma1*(ysegment[1]-ysegment[0]); 195 xfinal[1]=xnodes[1]; 196 yfinal[1]=ynodes[1]; 197 } 198 segments_dataset->AddObject(new Segment<double>(el+1,xfinal[0],yfinal[0],xfinal[1],yfinal[1])); 199 200 201 /*This case is impossible: not quite! */ 202 //_printf_(alpha1 << " " << alpha2 << " " << beta1 << " " << beta2 << " " << gamma1 << " " << gamma2 << " " << xsegment[0] << " " << xsegment[1] << " " << ysegment[0] << " " << ysegment[1] << " " << xnodes[0] << " " << xnodes[1] << " " << xnodes[2] << " " << ynodes[0] << " " << ynodes[1] << " " << ynodes[2]); 203 /* _error_("error: a line cannot go through 3 different vertices!");*/ 166 204 } 167 205 else if( ((edge1==IntersectEnum) && (edge2==IntersectEnum)) || ((edge2==IntersectEnum) && (edge3==IntersectEnum)) || ((edge3==IntersectEnum) && (edge1==IntersectEnum)) ){ … … 187 225 } 188 226 else if( (edge1==IntersectEnum) || (edge2==IntersectEnum) || (edge3==IntersectEnum) ){ 227 228 /*if (el==318 && contouri==9){ 229 _printf_("hello" << " NodeInElement 0 " << (NodeInElement(xnodes,ynodes,xsegment[0],ysegment[0])) << " NodeInElement 1 " << (NodeInElement(xnodes,ynodes,xsegment[1],ysegment[1]))); 230 }*/ 189 231 190 232 /*segment intersect only 1 edge. Figure out where the first point in the segment is, inside or outside the element, … … 196 238 if(edge3==IntersectEnum){coord2=gamma1;} 197 239 } 198 else {240 else if (NodeInElement(xnodes,ynodes,xsegment[1],ysegment[1])){ 199 241 if(edge1==IntersectEnum){coord1=alpha1;} 200 242 if(edge2==IntersectEnum){coord1=beta1;} 201 243 if(edge3==IntersectEnum){coord1=gamma1;} 202 244 coord2=1.0; 245 } 246 else{ 247 double tolerance=1e-10; 248 /*Ok, we have an issue here. Probably one of the segments' end is on a vertex, within a certain tolerance!*/ 249 if (IsIdenticalNode(xnodes[0],ynodes[0],xsegment[0],ysegment[0],tolerance) || 250 IsIdenticalNode(xnodes[1],ynodes[1],xsegment[0],ysegment[0],tolerance) || 251 IsIdenticalNode(xnodes[2],ynodes[2],xsegment[0],ysegment[0],tolerance)){ 252 253 /*ok, segments[0] is common to one of our vertices: */ 254 //if (el==318 && contouri==9){ _printf_("ok1" << "\n"); } 255 coord1=0; 256 if(edge1==IntersectEnum){coord2=alpha1;} 257 if(edge2==IntersectEnum){coord2=beta1;} 258 if(edge3==IntersectEnum){coord2=gamma1;} 259 } 260 else if (IsIdenticalNode(xnodes[0],ynodes[0],xsegment[1],ysegment[1],tolerance) || 261 IsIdenticalNode(xnodes[1],ynodes[1],xsegment[1],ysegment[1],tolerance) || 262 IsIdenticalNode(xnodes[2],ynodes[2],xsegment[1],ysegment[1],tolerance)){ 263 264 /*ok, segments[1] is common to one of our vertices: */ 265 //if (el==318 && contouri==9){ _printf_("ok2" << "\n"); } 266 if(edge1==IntersectEnum){coord1=alpha1;} 267 if(edge2==IntersectEnum){coord1=beta1;} 268 if(edge3==IntersectEnum){coord1=gamma1;} 269 coord2=1.0; 270 } 203 271 } 204 272 … … 344 412 return IntersectEnum; 345 413 }/*}}}*/ 414 bool IsIdenticalNode(double x1, double y1, double x2, double y2, double tolerance){ /*{{{*/ 415 416 if (sqrt(pow(x1-x2,2.0) + pow(y1-y2,2))<tolerance)return true; 417 else return false; 418 419 }/*}}}*/ -
issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshProfileIntersectionx.h
r15396 r19105 13 13 void MeshSegmentsIntersection(double** psegments, int* pnumsegs,int* index, double* x, double* y, int nel, int nods, double* xc, double* yc, int numnodes); 14 14 void ElementSegmentsIntersection(DataSet* segments_dataset,int el, double* xnodes,double* ynodes,double* xc,double* yc,int numnodes); 15 void ElementSegment(DataSet* segments_dataset,int el, double* xnodes,double* ynodes,double* xsegment,double* ysegment);15 void ElementSegment(DataSet* segments_dataset,int el,int contouri, double* xnodes,double* ynodes,double* xsegment,double* ysegment); 16 16 int SegmentIntersect(double* palpha, double* pbeta, double* x1, double* y1, double* x2, double* y2); 17 17 bool NodeInElement(double* xnodes, double* ynodes, double x, double y); 18 bool IsIdenticalNode(double x1, double y1, double x2, double y2, double tolerance); 18 19 19 20 #endif /* _MESHPROFILEINTERSECTIONX_H */ -
issm/trunk/src/c/modules/ModelProcessorx/Autodiff/CreateParametersAutodiff.cpp
r16560 r19105 115 115 parameters->AddObject(new DataSetParam(AutodiffIndependentObjectsEnum,iomodel->independent_objects)); 116 116 /*}}}*/ 117 118 #endif119 }120 121 #ifdef _HAVE_ADOLC_122 117 /*initialize a placeholder to store solver pointers: {{{*/ 123 118 GenericParam<Adolc_edf> *theAdolcEDF_p=new GenericParam<Adolc_edf>(AdolcParamEnum); … … 159 154 /*}}}*/ 160 155 #endif 161 156 } 162 157 } -
issm/trunk/src/c/modules/ModelProcessorx/Control/CreateParametersControl.cpp
r18301 r19105 13 13 int inversiontype; 14 14 int nsteps; 15 int num_control _type;16 int num_c m_responses;15 int num_controls; 16 int num_costfunc; 17 17 int *control_type = NULL; 18 18 int *maxiter = NULL; … … 20 20 IssmDouble *cm_jump = NULL; 21 21 IssmDouble *optscal = NULL; 22 IssmDouble *control_scaling_factors = NULL; 22 23 23 24 /*retrieve some parameters: */ … … 30 31 parameters->AddObject(iomodel->CopyConstantObject(InversionNumControlParametersEnum)); 31 32 parameters->AddObject(iomodel->CopyConstantObject(InversionNumCostFunctionsEnum)); 32 parameters->AddObject(iomodel->CopyConstantObject(InversionIncompleteAdjointEnum));33 33 34 34 /*What solution type?*/ … … 41 41 42 42 /*Now, recover fit, optscal and maxiter as vectors: */ 43 iomodel->FetchData(&control_type,NULL,&num_control _type,InversionControlParametersEnum);44 iomodel->FetchData(&cm_responses,NULL,&num_c m_responses,InversionCostFunctionsEnum);45 parameters->AddObject(new IntVecParam(InversionControlParametersEnum,control_type,num_control _type));46 parameters->AddObject(new IntVecParam(InversionCostFunctionsEnum,cm_responses,num_c m_responses));43 iomodel->FetchData(&control_type,NULL,&num_controls,InversionControlParametersEnum); 44 iomodel->FetchData(&cm_responses,NULL,&num_costfunc,InversionCostFunctionsEnum); 45 parameters->AddObject(new IntVecParam(InversionControlParametersEnum,control_type,num_controls)); 46 parameters->AddObject(new IntVecParam(InversionCostFunctionsEnum,cm_responses,num_costfunc)); 47 47 48 48 /*Inversion type specifics*/ 49 49 switch(inversiontype){ 50 50 case 0:/*Brent Search*/ 51 parameters->AddObject(iomodel->CopyConstantObject(InversionIncompleteAdjointEnum)); 51 52 parameters->AddObject(iomodel->CopyConstantObject(InversionNstepsEnum)); 52 53 parameters->AddObject(iomodel->CopyConstantObject(InversionCostFunctionThresholdEnum)); … … 54 55 iomodel->FetchData(&optscal,NULL,NULL,InversionGradientScalingEnum); 55 56 iomodel->FetchData(&maxiter,NULL,NULL,InversionMaxiterPerStepEnum); 56 parameters->AddObject(new DoubleMatParam(InversionGradientScalingEnum,optscal,nsteps,num_control _type));57 parameters->AddObject(new DoubleMatParam(InversionGradientScalingEnum,optscal,nsteps,num_controls)); 57 58 parameters->AddObject(new DoubleVecParam(InversionStepThresholdEnum,cm_jump,nsteps)); 58 59 parameters->AddObject(new IntVecParam(InversionMaxiterPerStepEnum,maxiter,nsteps)); 59 60 break; 60 61 case 1:/*TAO*/ 62 parameters->AddObject(iomodel->CopyConstantObject(InversionIncompleteAdjointEnum)); 61 63 parameters->AddObject(iomodel->CopyConstantObject(InversionFatolEnum)); 62 64 parameters->AddObject(iomodel->CopyConstantObject(InversionFrtolEnum)); … … 69 71 break; 70 72 case 2:/*M1QN3*/ 73 parameters->AddObject(iomodel->CopyConstantObject(InversionIncompleteAdjointEnum)); 71 74 parameters->AddObject(iomodel->CopyConstantObject(InversionDxminEnum)); 72 75 parameters->AddObject(iomodel->CopyConstantObject(InversionGttolEnum)); 73 76 parameters->AddObject(iomodel->CopyConstantObject(InversionMaxstepsEnum)); 74 77 parameters->AddObject(iomodel->CopyConstantObject(InversionMaxiterEnum)); 78 iomodel->FetchData(&control_scaling_factors,NULL,NULL,InversionControlScalingFactorsEnum); 79 parameters->AddObject(new DoubleVecParam(InversionControlScalingFactorsEnum,control_scaling_factors,num_controls)); 75 80 break; 76 81 case 3:/*Validation*/ 82 parameters->AddObject(iomodel->CopyConstantObject(InversionIncompleteAdjointEnum)); 83 iomodel->FetchData(&control_scaling_factors,NULL,NULL,InversionControlScalingFactorsEnum); 84 parameters->AddObject(new DoubleVecParam(InversionControlScalingFactorsEnum,control_scaling_factors,num_controls)); 85 break; 86 case 4:/*M1QN3 AD*/ 87 parameters->AddObject(iomodel->CopyConstantObject(InversionDxminEnum)); 88 parameters->AddObject(iomodel->CopyConstantObject(InversionGttolEnum)); 89 parameters->AddObject(iomodel->CopyConstantObject(InversionMaxstepsEnum)); 90 parameters->AddObject(iomodel->CopyConstantObject(InversionMaxiterEnum)); 91 iomodel->FetchData(&control_scaling_factors,NULL,NULL,InversionControlScalingFactorsEnum); 92 parameters->AddObject(new DoubleVecParam(InversionControlScalingFactorsEnum,control_scaling_factors,num_controls)); 77 93 break; 78 94 default: … … 84 100 xDelete<int>(cm_responses); 85 101 xDelete<int>(maxiter); 102 xDelete<IssmDouble>(control_scaling_factors); 86 103 iomodel->DeleteData(cm_jump,InversionStepThresholdEnum); 87 104 iomodel->DeleteData(optscal,InversionGradientScalingEnum); -
issm/trunk/src/c/modules/ModelProcessorx/Control/UpdateElementsAndMaterialsControl.cpp
r18301 r19105 12 12 13 13 /*Intermediary*/ 14 int control ;14 int control,cost_function,domaintype; 15 15 Element *element = NULL; 16 16 Material *material = NULL; 17 int num_control_type ;17 int num_control_type,num_cost_functions; 18 18 bool control_analysis; 19 19 … … 23 23 24 24 /*Now, return if no control*/ 25 if (!control_analysis) return; 26 27 /*Fetch data needed: */ 28 iomodel->FetchDataToInput(elements,InversionVxObsEnum,0.); 29 iomodel->FetchDataToInput(elements,InversionVyObsEnum,0.); 30 iomodel->FetchDataToInput(elements,InversionThicknessObsEnum,0.); 25 if(!control_analysis) return; 31 26 32 27 iomodel->FetchData(5,InversionControlParametersEnum,InversionCostFunctionsEnum,InversionCostFunctionsCoefficientsEnum,InversionMinParametersEnum,InversionMaxParametersEnum); 28 29 /*Fetch Observations */ 30 iomodel->Constant(&num_cost_functions,InversionNumCostFunctionsEnum); 31 iomodel->Constant(&domaintype,DomainTypeEnum); 32 for(int i=0;i<num_cost_functions;i++){ 33 cost_function= reCast<int,IssmDouble>(iomodel->Data(InversionCostFunctionsEnum)[i]); 34 if( cost_function==ThicknessAbsMisfitEnum) iomodel->FetchDataToInput(elements,InversionThicknessObsEnum); 35 else if(cost_function==SurfaceAbsMisfitEnum) iomodel->FetchDataToInput(elements,InversionSurfaceObsEnum); 36 else if(cost_function==SurfaceAbsVelMisfitEnum 37 || cost_function==SurfaceRelVelMisfitEnum 38 || cost_function==SurfaceLogVelMisfitEnum 39 || cost_function==SurfaceLogVxVyMisfitEnum 40 || cost_function==SurfaceAverageVelMisfitEnum){ 41 iomodel->FetchDataToInput(elements,InversionVxObsEnum); 42 if (domaintype!=Domain2DverticalEnum) iomodel->FetchDataToInput(elements,InversionVyObsEnum); 43 } 44 } 33 45 34 46 for(int i=0;i<num_control_type;i++){ … … 36 48 switch(control){ 37 49 /*List of supported controls*/ 38 50 case BalancethicknessThickeningRateEnum: 39 51 case VxEnum: 40 52 case VyEnum: 41 53 case ThicknessEnum: 42 case FrictionCoefficientEnum: 43 case BalancethicknessNuxEnum: 44 case BalancethicknessNuyEnum: 45 case BalancethicknessApparentMassbalanceEnum: 54 case FrictionCoefficientEnum: 55 case FrictionAsEnum: 56 case BalancethicknessApparentMassbalanceEnum: 57 case BalancethicknessOmegaEnum: 58 case MaterialsRheologyBEnum: 46 59 iomodel->FetchData(1,control); 47 60 break; -
issm/trunk/src/c/modules/ModelProcessorx/CreateNodes.cpp
r18301 r19105 533 533 } 534 534 break; 535 case LACrouzeixRaviartEnum: 536 _assert_(approximation==FSApproximationEnum); 537 /*P2b velocity*/ 538 EdgesPartitioning(&my_edges,iomodel); 539 for(i=0;i<iomodel->numberofvertices;i++){ 540 if(iomodel->my_vertices[i]){ 541 nodes->AddObject(new Node(id0+i+1,i,lid++,i,iomodel,analysis,FSvelocityEnum)); 542 } 543 } 544 for(i=0;i<iomodel->numberofedges;i++){ 545 if(my_edges[i]){ 546 nodes->AddObject(new Node(id0+iomodel->numberofvertices+i+1,iomodel->numberofvertices+i,lid++,0,iomodel,analysis,FSvelocityEnum)); 547 } 548 } 549 id0 = id0+iomodel->numberofvertices+iomodel->numberofedges; 550 if(iomodel->meshelementtype==PentaEnum){ 551 FacesPartitioning(&my_faces,iomodel); 552 for(i=0;i<iomodel->numberoffaces;i++){ 553 if(iomodel->faces[i*iomodel->facescols+2]==2){/*Vertical quads*/ 554 if(my_faces[i]){ 555 node = new Node(id0+i+1,iomodel->numberofvertices+iomodel->numberofedges+i,lid++,0,iomodel,analysis,FSvelocityEnum); 556 nodes->AddObject(node); 557 } 558 } 559 else if(iomodel->faces[i*iomodel->facescols+2]==1){/*Triangular base/top*/ 560 /*Nothing*/ 561 } 562 else{ 563 _error_("not supported"); 564 } 565 } 566 id0 = id0+iomodel->numberoffaces; 567 } 568 for(i=0;i<iomodel->numberofelements;i++){ 569 if(iomodel->my_elements[i]){ 570 nodes->AddObject(new Node(id0+i+1,id0-iomodel->nodecounter+i,lid++,0,iomodel,analysis,FSvelocityEnum)); 571 } 572 } 573 574 /*No pressure*/ 575 break; 535 576 536 577 default: -
issm/trunk/src/c/modules/ModelProcessorx/CreateOutputDefinitions.cpp
r17806 r19105 28 28 29 29 /*massfluxatgate variables: */ 30 int numgates;30 int temp,numgates; 31 31 char **gatenames = NULL; 32 int *gatedefinitionenums = NULL; 32 33 IssmDouble **gatesegments = NULL; 33 34 int *gatesegments_M = NULL; … … 36 37 /*Fetch segments and names: */ 37 38 iomodel->FetchMultipleData(&gatenames,&numgates,MassfluxatgateNameEnum); 38 iomodel->FetchMultipleData(&gatesegments,&gatesegments_M,NULL,&numgates,MassfluxatgateSegmentsEnum); 39 iomodel->FetchMultipleData(&gatedefinitionenums,&temp,MassfluxatgateDefinitionenumEnum); _assert_(temp==numgates); 40 iomodel->FetchMultipleData(&gatesegments,&gatesegments_M,NULL,&temp,MassfluxatgateSegmentsEnum);_assert_(temp==numgates); 39 41 40 42 for(j=0;j<numgates;j++){ 41 output_definitions->AddObject(new Massfluxatgate<IssmDouble>(gatenames[j],gate segments_M[j],gatesegments[j]));43 output_definitions->AddObject(new Massfluxatgate<IssmDouble>(gatenames[j],gatedefinitionenums[j],gatesegments_M[j],gatesegments[j])); 42 44 } 43 45 /*Free ressources:*/ … … 49 51 xDelete<IssmDouble*>(gatesegments); 50 52 xDelete<int>(gatesegments_M); 53 xDelete<int>(gatedefinitionenums); 51 54 /*}}}*/ 52 55 } … … 57 60 int nummisfits; 58 61 char** misfit_name_s = NULL; 62 int* misfit_definitionenums_s = NULL; 59 63 int* misfit_model_enum_s = NULL; 60 64 IssmDouble** misfit_observation_s = NULL; … … 62 66 int* misfit_observation_M_s = NULL; 63 67 int* misfit_observation_N_s = NULL; 68 int* misfit_local_s = NULL; 64 69 char** misfit_timeinterpolation_s = NULL; 65 70 IssmDouble** misfit_weights_s = NULL; … … 70 75 /*Fetch name, model_enum, observation, observation_enum, etc ... (see src/m/classes/misfit.m): */ 71 76 iomodel->FetchMultipleData(&misfit_name_s,&nummisfits,MisfitNameEnum); 77 iomodel->FetchMultipleData(&misfit_definitionenums_s,&nummisfits,MisfitDefinitionenumEnum); 72 78 iomodel->FetchMultipleData(&misfit_model_enum_s,&nummisfits,MisfitModelEnumEnum); 73 79 iomodel->FetchMultipleData(&misfit_observation_s,&misfit_observation_M_s,&misfit_observation_N_s,&nummisfits,MisfitObservationEnum); 74 80 iomodel->FetchMultipleData(&misfit_observation_enum_s,&nummisfits,MisfitObservationEnumEnum); 75 81 iomodel->FetchMultipleData(&misfit_timeinterpolation_s,&nummisfits,MisfitTimeinterpolationEnum); 82 iomodel->FetchMultipleData(&misfit_local_s,&nummisfits,MisfitLocalEnum); 76 83 iomodel->FetchMultipleData(&misfit_weights_s,&misfit_weights_M_s,&misfit_weights_N_s,&nummisfits,MisfitWeightsEnum); 77 84 iomodel->FetchMultipleData(&misfit_weights_enum_s,&nummisfits,MisfitWeightsEnumEnum); … … 80 87 81 88 /*First create a misfit object for that specific enum (misfit_model_enum_s[j]):*/ 82 output_definitions->AddObject(new Misfit(misfit_name_s[j],misfit_ model_enum_s[j],misfit_observation_enum_s[j],misfit_timeinterpolation_s[j],misfit_weights_enum_s[j]));89 output_definitions->AddObject(new Misfit(misfit_name_s[j],misfit_definitionenums_s[j],misfit_model_enum_s[j],misfit_observation_enum_s[j],misfit_timeinterpolation_s[j],(bool)misfit_local_s[j],misfit_weights_enum_s[j])); 83 90 84 91 /*Now, for this particular misfit object, make sure we plug into the elements: the observation, and the weights.*/ 85 92 for(i=0;i<elements->Size();i++){ 86 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));93 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 87 94 element->InputCreate(misfit_observation_s[j], iomodel,misfit_observation_M_s[j],misfit_observation_N_s[j],1,misfit_observation_enum_s[j],7); 88 95 element->InputCreate(misfit_weights_s[j], iomodel,misfit_weights_M_s[j],misfit_weights_N_s[j],1,misfit_weights_enum_s[j],7); … … 103 110 xDelete<char*>(misfit_name_s); 104 111 xDelete<int>(misfit_model_enum_s); 112 xDelete<int>(misfit_definitionenums_s); 105 113 xDelete<IssmDouble*>(misfit_observation_s); 106 114 xDelete<int>(misfit_observation_enum_s); 107 115 xDelete<int>(misfit_observation_M_s); 108 116 xDelete<int>(misfit_observation_N_s); 117 xDelete<int>(misfit_local_s); 109 118 xDelete<char*>(misfit_timeinterpolation_s); 110 119 xDelete<IssmDouble*>(misfit_weights_s); … … 114 123 /*}}}*/ 115 124 } 116 125 else if (output_definition_enums[i]==MassconEnum){ 126 /*Deal with masscons: {{{*/ 127 128 /*masscon variables: */ 129 int nummasscons; 130 char** masscon_name_s = NULL; 131 int* masscon_definitionenum_s = NULL; 132 IssmDouble** masscon_levelset_s = NULL; 133 int* masscon_levelset_M_s = NULL; 134 int* masscon_levelset_N_s = NULL; 135 136 /*Fetch name and levelset, etc ... (see src/m/classes/masscon.m): */ 137 iomodel->FetchMultipleData(&masscon_name_s,&nummasscons,MassconNameEnum); 138 iomodel->FetchMultipleData(&masscon_definitionenum_s,&nummasscons,MassconDefinitionenumEnum); 139 iomodel->FetchMultipleData(&masscon_levelset_s,&masscon_levelset_M_s,&masscon_levelset_N_s,&nummasscons,MassconLevelsetEnum); 140 for(j=0;j<nummasscons;j++){ 141 142 /*Create a masscon object: */ 143 output_definitions->AddObject(new Masscon(masscon_name_s[j],masscon_definitionenum_s[j],masscon_levelset_s[j],masscon_levelset_M_s[j])); 144 145 } 146 147 /*Free ressources:*/ 148 for(j=0;j<nummasscons;j++){ 149 char* string=NULL; 150 IssmDouble* matrix = NULL; 151 152 string = masscon_name_s[j]; xDelete<char>(string); 153 matrix = masscon_levelset_s[j]; xDelete<IssmDouble>(matrix); 154 } 155 xDelete<char*>(masscon_name_s); 156 xDelete<IssmDouble*>(masscon_levelset_s); 157 xDelete<int>(masscon_levelset_M_s); 158 xDelete<int>(masscon_levelset_N_s); 159 xDelete<int>(masscon_definitionenum_s); 160 /*}}}*/ 161 } 162 else if (output_definition_enums[i]==MassconaxpbyEnum){ 163 /*Deal with masscon combinations: {{{*/ 164 165 /*masscon variables: */ 166 char** masscon_name_s = NULL; 167 int* masscon_definitionenum_s = NULL; 168 char** masscon_namex_s = NULL; 169 char** masscon_namey_s = NULL; 170 IssmDouble* masscon_alpha_s = NULL; 171 IssmDouble* masscon_beta_s = NULL; 172 int num; 173 174 /*Fetch names and multiplicators, etc ... (see src/m/classes/masscon_axpby.m): */ 175 iomodel->FetchMultipleData(&masscon_name_s,&num,MassconaxpbyNameEnum); 176 iomodel->FetchMultipleData(&masscon_definitionenum_s,&num,MassconaxpbyDefinitionenumEnum); 177 iomodel->FetchMultipleData(&masscon_namex_s,&num,MassconaxpbyNamexEnum); 178 iomodel->FetchMultipleData(&masscon_namey_s,&num,MassconaxpbyNameyEnum); 179 iomodel->FetchMultipleData(&masscon_alpha_s,&num,MassconaxpbyAlphaEnum); 180 iomodel->FetchMultipleData(&masscon_beta_s,&num,MassconaxpbyBetaEnum); 181 for(j=0;j<num;j++){ 182 183 /*Create a masscon axpyb object: */ 184 output_definitions->AddObject(new Massconaxpby(masscon_name_s[j],masscon_definitionenum_s[j],masscon_namex_s[j],masscon_namey_s[j],masscon_alpha_s[j],masscon_beta_s[j])); 185 186 } 187 188 /*Free ressources:*/ 189 for(j=0;j<num;j++){ 190 char* string=NULL; 191 string = masscon_name_s[j]; xDelete<char>(string); 192 string = masscon_namex_s[j]; xDelete<char>(string); 193 string = masscon_namey_s[j]; xDelete<char>(string); 194 } 195 xDelete<char*>(masscon_name_s); 196 xDelete<char*>(masscon_namex_s); 197 xDelete<char*>(masscon_namey_s); 198 xDelete<int>(masscon_definitionenum_s); 199 xDelete<IssmDouble>(masscon_alpha_s); 200 xDelete<IssmDouble>(masscon_beta_s); 201 /*}}}*/ 202 } 117 203 else _error_("output definition enum " << output_definition_enums[i] << "not supported yet!"); 118 204 } -
issm/trunk/src/c/modules/ModelProcessorx/CreateParameters.cpp
r18301 r19105 22 22 char** requestedoutputs = NULL; 23 23 IssmDouble time; 24 bool isdelta18o ;24 bool isdelta18o,ismungsm; 25 25 26 26 /*parameters for mass flux:*/ … … 37 37 int count; 38 38 39 IssmDouble *temp = NULL; 40 IssmDouble yts; 41 int N,M; 42 39 43 /*Make sure current dataset is empty*/ 40 44 _assert_(parameters->Size()==0); … … 43 47 parameters->AddObject(iomodel->CopyConstantObject(DomainTypeEnum)); 44 48 parameters->AddObject(iomodel->CopyConstantObject(DomainDimensionEnum)); 45 parameters->AddObject(iomodel->CopyConstantObject(MeshElementtypeEnum));46 49 parameters->AddObject(iomodel->CopyConstantObject(SettingsOutputFrequencyEnum)); 47 parameters->AddObject(iomodel->CopyConstantObject(SteadystateReltolEnum));48 parameters->AddObject(iomodel->CopyConstantObject(SteadystateMaxiterEnum));49 50 parameters->AddObject(iomodel->CopyConstantObject(ConstantsYtsEnum)); 50 51 parameters->AddObject(iomodel->CopyConstantObject(TimesteppingStartTimeEnum)); … … 57 58 parameters->AddObject(iomodel->CopyConstantObject(DebugProfilingEnum)); 58 59 parameters->AddObject(iomodel->CopyConstantObject(MeshAverageVertexConnectivityEnum)); 59 parameters->AddObject(iomodel->CopyConstantObject(ConstantsReferencetemperatureEnum));60 60 parameters->AddObject(iomodel->CopyConstantObject(SettingsWaitonlockEnum)); 61 61 parameters->AddObject(iomodel->CopyConstantObject(MeshNumberofelementsEnum)); … … 63 63 parameters->AddObject(iomodel->CopyConstantObject(SettingsResultsOnNodesEnum)); 64 64 parameters->AddObject(iomodel->CopyConstantObject(SettingsIoGatherEnum)); 65 parameters->AddObject(iomodel->CopyConstantObject(GroundinglineMigrationEnum));66 parameters->AddObject(iomodel->CopyConstantObject(TransientIsstressbalanceEnum));67 parameters->AddObject(iomodel->CopyConstantObject(TransientIsmasstransportEnum));68 parameters->AddObject(iomodel->CopyConstantObject(TransientIsthermalEnum));69 parameters->AddObject(iomodel->CopyConstantObject(TransientIsgroundinglineEnum));70 parameters->AddObject(iomodel->CopyConstantObject(TransientIsgiaEnum));71 parameters->AddObject(iomodel->CopyConstantObject(TransientIslevelsetEnum));72 parameters->AddObject(iomodel->CopyConstantObject(TransientIsdamageevolutionEnum));73 parameters->AddObject(iomodel->CopyConstantObject(TransientIshydrologyEnum));74 parameters->AddObject(iomodel->CopyConstantObject(MaterialsRheologyLawEnum));75 65 parameters->AddObject(iomodel->CopyConstantObject(AutodiffIsautodiffEnum)); 76 66 parameters->AddObject(iomodel->CopyConstantObject(QmuIsdakotaEnum)); 77 67 parameters->AddObject(iomodel->CopyConstantObject(InversionIscontrolEnum)); 78 68 parameters->AddObject(iomodel->CopyConstantObject(InversionTypeEnum)); 79 parameters->AddObject(iomodel->CopyConstantObject(GiaCrossSectionShapeEnum)); 80 81 /*For stress balance only*/ 82 parameters->AddObject(iomodel->CopyConstantObject(FlowequationIsFSEnum)); 83 parameters->AddObject(iomodel->CopyConstantObject(StressbalanceRiftPenaltyThresholdEnum)); 84 parameters->AddObject(iomodel->CopyConstantObject(StressbalanceMaxiterEnum)); 85 parameters->AddObject(iomodel->CopyConstantObject(StressbalanceRestolEnum)); 86 parameters->AddObject(iomodel->CopyConstantObject(StressbalanceReltolEnum)); 87 parameters->AddObject(iomodel->CopyConstantObject(StressbalanceAbstolEnum)); 88 if(iomodel->domaintype==Domain3DEnum) 89 parameters->AddObject(iomodel->CopyConstantObject(MeshNumberoflayersEnum)); 69 parameters->AddObject(iomodel->CopyConstantObject(CalvingLawEnum)); 70 {/*This is specific to ice...*/ 71 parameters->AddObject(iomodel->CopyConstantObject(MeshElementtypeEnum)); 72 parameters->AddObject(iomodel->CopyConstantObject(SteadystateReltolEnum)); 73 parameters->AddObject(iomodel->CopyConstantObject(SteadystateMaxiterEnum)); 74 parameters->AddObject(iomodel->CopyConstantObject(ConstantsReferencetemperatureEnum)); 75 parameters->AddObject(iomodel->CopyConstantObject(GroundinglineMigrationEnum)); 76 parameters->AddObject(iomodel->CopyConstantObject(TransientIsstressbalanceEnum)); 77 parameters->AddObject(iomodel->CopyConstantObject(TransientIsmasstransportEnum)); 78 parameters->AddObject(iomodel->CopyConstantObject(TransientIsthermalEnum)); 79 parameters->AddObject(iomodel->CopyConstantObject(TransientIsgroundinglineEnum)); 80 parameters->AddObject(iomodel->CopyConstantObject(TransientIsgiaEnum)); 81 parameters->AddObject(iomodel->CopyConstantObject(TransientIslevelsetEnum)); 82 parameters->AddObject(iomodel->CopyConstantObject(TransientIsdamageevolutionEnum)); 83 parameters->AddObject(iomodel->CopyConstantObject(TransientIshydrologyEnum)); 84 parameters->AddObject(iomodel->CopyConstantObject(TransientIscalvingEnum)); 85 parameters->AddObject(iomodel->CopyConstantObject(MaterialsRheologyLawEnum)); 86 parameters->AddObject(iomodel->CopyConstantObject(GiaCrossSectionShapeEnum)); 87 88 /*For stress balance only*/ 89 parameters->AddObject(iomodel->CopyConstantObject(FlowequationIsFSEnum)); 90 parameters->AddObject(iomodel->CopyConstantObject(StressbalanceRiftPenaltyThresholdEnum)); 91 parameters->AddObject(iomodel->CopyConstantObject(StressbalanceMaxiterEnum)); 92 parameters->AddObject(iomodel->CopyConstantObject(StressbalanceRestolEnum)); 93 parameters->AddObject(iomodel->CopyConstantObject(StressbalanceReltolEnum)); 94 parameters->AddObject(iomodel->CopyConstantObject(StressbalanceAbstolEnum)); 95 if(iomodel->domaintype==Domain3DEnum) 96 parameters->AddObject(iomodel->CopyConstantObject(MeshNumberoflayersEnum)); 97 } 90 98 91 99 /*Surface mass balance parameters*/ … … 98 106 case SMBpddEnum: 99 107 parameters->AddObject(iomodel->CopyConstantObject(SurfaceforcingsIsdelta18oEnum)); 108 parameters->AddObject(iomodel->CopyConstantObject(SurfaceforcingsIsmungsmEnum)); 100 109 parameters->AddObject(iomodel->CopyConstantObject(SurfaceforcingsDesfacEnum)); 101 110 parameters->AddObject(iomodel->CopyConstantObject(SurfaceforcingsS0pEnum)); 111 parameters->AddObject(iomodel->CopyConstantObject(SurfaceforcingsS0tEnum)); 112 parameters->AddObject(iomodel->CopyConstantObject(SurfaceforcingsRlapsEnum)); 113 parameters->AddObject(iomodel->CopyConstantObject(SurfaceforcingsRlapslgmEnum)); 102 114 iomodel->Constant(&isdelta18o,SurfaceforcingsIsdelta18oEnum); 115 iomodel->Constant(&ismungsm,SurfaceforcingsIsmungsmEnum); 116 117 if(ismungsm){ 118 iomodel->FetchData(&temp,&N,&M,SurfaceforcingsPfacEnum); _assert_(N==2); 119 for(i=0;i<M;i++) temp[M+i]=temp[M+i]; 120 parameters->AddObject(new TransientParam(SurfaceforcingsPfacEnum,&temp[0],&temp[M],M)); 121 iomodel->DeleteData(temp,SurfaceforcingsPfacEnum); 122 123 iomodel->FetchData(&temp,&N,&M,SurfaceforcingsTdiffEnum); _assert_(N==2); 124 for(i=0;i<M;i++) temp[M+i]=temp[M+i]; 125 parameters->AddObject(new TransientParam(SurfaceforcingsTdiffEnum,&temp[0],&temp[M],M)); 126 iomodel->DeleteData(temp,SurfaceforcingsTdiffEnum); 127 128 iomodel->FetchData(&temp,&N,&M,SurfaceforcingsSealevEnum); _assert_(N==2); 129 for(i=0;i<M;i++) temp[M+i]=temp[M+i]; 130 parameters->AddObject(new TransientParam(SurfaceforcingsSealevEnum,&temp[0],&temp[M],M)); 131 iomodel->DeleteData(temp,SurfaceforcingsSealevEnum); 132 } 133 103 134 if(isdelta18o){ 104 IssmDouble *temp = NULL;105 IssmDouble yts;106 int N,M;107 135 iomodel->Constant(&yts,ConstantsYtsEnum); 136 108 137 iomodel->FetchData(&temp,&N,&M,SurfaceforcingsDelta18oEnum); _assert_(N==2); 109 138 for(i=0;i<M;i++) temp[M+i]=yts*temp[M+i]; -
issm/trunk/src/c/modules/ModelProcessorx/ModelProcessorx.cpp
r17806 r19105 13 13 #include "./ModelProcessorx.h" 14 14 15 void ModelProcessorx(Elements** pelements, Nodes** pnodes, Vertices** pvertices, Materials** pmaterials, Constraints** pconstraints, Loads** ploads, Parameters** pparameters, FILE* IOMODEL,FILE* toolkitfile, char* rootpath,const int solution_enum,const int nummodels,const int* analysis_enum_list){15 void ModelProcessorx(Elements** pelements, Nodes** pnodes, Vertices** pvertices, Materials** pmaterials, Constraints** pconstraints, Loads** ploads, Parameters** pparameters,IoModel* iomodel,FILE* toolkitfile, char* rootpath,const int solution_enum,const int nummodels,const int* analysis_enum_list){ 16 16 17 17 int i,analysis_enum,verbose; 18 bool isthermal,ismasstransport,isstressbalance,isgroundingline,isenthalpy,islevelset,isdamage,ishydrology;19 18 20 19 /*Initialize datasets*/ … … 27 26 Parameters *parameters = new Parameters(); 28 27 29 /*Initialize IoModel from input file*/30 IoModel* iomodel = new IoModel(IOMODEL);31 32 28 /*Fetch parameters: */ 33 29 iomodel->Constant(&verbose,VerboseEnum); 34 iomodel->Constant(&isthermal,TransientIsthermalEnum);35 iomodel->Constant(&isenthalpy,ThermalIsenthalpyEnum);36 iomodel->Constant(&islevelset,TransientIslevelsetEnum);37 iomodel->Constant(&ismasstransport,TransientIsmasstransportEnum);38 iomodel->Constant(&isstressbalance,TransientIsstressbalanceEnum);39 iomodel->Constant(&isgroundingline,TransientIsgroundinglineEnum);40 iomodel->Constant(&isdamage,TransientIsdamageevolutionEnum);41 iomodel->Constant(&ishydrology,TransientIshydrologyEnum);42 43 30 SetVerbosityLevel(verbose); 44 31 … … 58 45 analysis_enum=analysis_enum_list[i]; 59 46 parameters->AddObject(new IntParam(AnalysisCounterEnum,i)); 60 61 /*Hack for trasient runs (FIXME: to be improved)*/62 if(solution_enum==TransientSolutionEnum && analysis_enum==ThermalAnalysisEnum && iomodel->domaintype==Domain2DhorizontalEnum) continue;63 if(solution_enum==TransientSolutionEnum && analysis_enum==MeltingAnalysisEnum && iomodel->domaintype==Domain2DhorizontalEnum) continue;64 if(solution_enum==TransientSolutionEnum && analysis_enum==EnthalpyAnalysisEnum && iomodel->domaintype==Domain2DhorizontalEnum) continue;65 if(solution_enum==TransientSolutionEnum && analysis_enum==ThermalAnalysisEnum && isthermal==false) continue;66 if(solution_enum==TransientSolutionEnum && analysis_enum==MeltingAnalysisEnum && isthermal==false) continue;67 if(solution_enum==TransientSolutionEnum && analysis_enum==EnthalpyAnalysisEnum && isthermal==false) continue;68 if(solution_enum==TransientSolutionEnum && analysis_enum==ThermalAnalysisEnum && isenthalpy==true) continue;69 if(solution_enum==TransientSolutionEnum && analysis_enum==MeltingAnalysisEnum && isenthalpy==true) continue;70 if(solution_enum==TransientSolutionEnum && analysis_enum==EnthalpyAnalysisEnum && isenthalpy==false) continue;71 if(solution_enum==TransientSolutionEnum && analysis_enum==MasstransportAnalysisEnum && ismasstransport==false && isgroundingline==false) continue;72 if(solution_enum==TransientSolutionEnum && analysis_enum==StressbalanceAnalysisEnum && isstressbalance==false) continue;73 if(solution_enum==TransientSolutionEnum && analysis_enum==StressbalanceVerticalAnalysisEnum && isstressbalance==false) continue;74 if(solution_enum==TransientSolutionEnum && analysis_enum==StressbalanceSIAAnalysisEnum && isstressbalance==false) continue;75 if(solution_enum==SteadystateSolutionEnum && analysis_enum==ThermalAnalysisEnum && isenthalpy==true) continue;76 if(solution_enum==SteadystateSolutionEnum && analysis_enum==MeltingAnalysisEnum && isenthalpy==true) continue;77 if(solution_enum==SteadystateSolutionEnum && analysis_enum==EnthalpyAnalysisEnum && isenthalpy==false) continue;78 if(solution_enum==TransientSolutionEnum && analysis_enum==LevelsetAnalysisEnum && islevelset==false) continue;79 if(solution_enum==TransientSolutionEnum && analysis_enum==ExtrapolationAnalysisEnum && islevelset==false) continue;80 if(solution_enum==TransientSolutionEnum && analysis_enum==LsfReinitializationAnalysisEnum && islevelset==false) continue;81 if(solution_enum==TransientSolutionEnum && analysis_enum==HydrologyShreveAnalysisEnum && ishydrology==false) continue;82 if(solution_enum==TransientSolutionEnum && analysis_enum==HydrologyDCEfficientAnalysisEnum && ishydrology==false) continue;83 if(solution_enum==TransientSolutionEnum && analysis_enum==HydrologyDCInefficientAnalysisEnum && ishydrology==false) continue;84 if(solution_enum==TransientSolutionEnum && analysis_enum==DamageEvolutionAnalysisEnum && isdamage==false) continue;85 47 86 48 if(VerboseMProcessor()) _printf0_(" creating datasets for analysis " << EnumToStringx(analysis_enum) << "\n"); … … 128 90 if(VerboseMProcessor()) _printf0_(" done with model processor \n"); 129 91 130 /*Free resources:*/131 delete iomodel;132 133 92 /*Assign output pointers:*/ 134 93 *pelements = elements; -
issm/trunk/src/c/modules/ModelProcessorx/ModelProcessorx.h
r17989 r19105 9 9 #include "../../analyses/analyses.h" 10 10 11 void ModelProcessorx(Elements** pelements, Nodes** pnodes, Vertices** pvertices, Materials** pmaterials, Constraints** pconstraints, Loads** ploads, Parameters** pparameters, FILE* iomodel_handle,FILE* toolkitfile, char* rootpath,const int solution_type,const int nummodels,const int* analysis_type_listh);11 void ModelProcessorx(Elements** pelements, Nodes** pnodes, Vertices** pvertices, Materials** pmaterials, Constraints** pconstraints, Loads** ploads, Parameters** pparameters,IoModel* iomodel,FILE* toolkitfile, char* rootpath,const int solution_type,const int nummodels,const int* analysis_type_listh); 12 12 13 13 /*Creation of fem datasets: general drivers*/ -
issm/trunk/src/c/modules/ModelProcessorx/NodesPartitioning.cpp
r17806 r19105 65 65 66 66 /*First: add all the nodes of all the elements belonging to this cpu*/ 67 if(iomodel->domaintype==Domain2DhorizontalEnum ){67 if(iomodel->domaintype==Domain2DhorizontalEnum || iomodel->domaintype==Domain2DverticalEnum){ 68 68 for (i=0;i<iomodel->numberofelements;i++){ 69 69 if (my_elements[i]){ … … 83 83 CreateFaces(iomodel); 84 84 85 /*!All elements have been partitioned above, only create elements for this CPU: */ 86 for(int i=0;i<iomodel->numberoffaces;i++){ 85 if(iomodel->domaintype==Domain2DhorizontalEnum){ 86 /*!All elements have been partitioned above, only create elements for this CPU: */ 87 for(int i=0;i<iomodel->numberoffaces;i++){ 87 88 88 /*Get left and right elements*/89 e1=iomodel->faces[4*i+2]-1; //faces are [node1 node2 elem1 elem2]90 e2=iomodel->faces[4*i+3]-1; //faces are [node1 node2 elem1 elem2]89 /*Get left and right elements*/ 90 e1=iomodel->faces[4*i+2]-1; //faces are [node1 node2 elem1 elem2] 91 e2=iomodel->faces[4*i+3]-1; //faces are [node1 node2 elem1 elem2] 91 92 92 /* 1) If the element e1 is in the current partition93 * 2) and if the face of the element is shared by another element (internal face)94 * 3) and if this element is not in the same partition:95 * we must clone the nodes on this partition so that the loads (Numericalflux)96 * will have access to their properties (dofs,...)*/97 if(my_elements[e1] && e2!=-2 && !my_elements[e2]){93 /* 1) If the element e1 is in the current partition 94 * 2) and if the face of the element is shared by another element (internal face) 95 * 3) and if this element is not in the same partition: 96 * we must clone the nodes on this partition so that the loads (Numericalflux) 97 * will have access to their properties (dofs,...)*/ 98 if(my_elements[e1] && e2!=-2 && !my_elements[e2]){ 98 99 99 /*1: Get vertices ids*/100 i1=iomodel->faces[4*i+0];101 i2=iomodel->faces[4*i+1];100 /*1: Get vertices ids*/ 101 i1=iomodel->faces[4*i+0]; 102 i2=iomodel->faces[4*i+1]; 102 103 103 /*2: Get the column where these ids are located in the index*/104 pos=UNDEF;105 for(int j=0;j<3;j++){106 if(iomodel->elements[3*e2+j]==i1) pos=j;107 }104 /*2: Get the column where these ids are located in the index*/ 105 pos=UNDEF; 106 for(int j=0;j<3;j++){ 107 if(iomodel->elements[3*e2+j]==i1) pos=j; 108 } 108 109 109 /*3: We have the id of the elements and the position of the vertices in the index 110 * we can now create the corresponding nodes:*/ 111 if(pos==0){ 112 my_nodes[e2*3+0]=true; 113 my_nodes[e2*3+2]=true; 114 } 115 else if(pos==1){ 116 my_nodes[e2*3+1]=true; 117 my_nodes[e2*3+0]=true; 118 } 119 else if(pos==2){ 120 my_nodes[e2*3+2]=true; 121 my_nodes[e2*3+1]=true; 122 } 123 else{ 124 _error_("Problem in faces creation"); 110 /*3: We have the id of the elements and the position of the vertices in the index 111 * we can now create the corresponding nodes:*/ 112 if(pos==0){ 113 my_nodes[e2*3+0]=true; 114 my_nodes[e2*3+2]=true; 115 } 116 else if(pos==1){ 117 my_nodes[e2*3+1]=true; 118 my_nodes[e2*3+0]=true; 119 } 120 else if(pos==2){ 121 my_nodes[e2*3+2]=true; 122 my_nodes[e2*3+1]=true; 123 } 124 else{ 125 _error_("Problem in faces creation"); 126 } 125 127 } 126 128 } -
issm/trunk/src/c/modules/NodalValuex/NodalValuex.cpp
r16560 r19105 20 20 *element, figure out if they hold the vertex, and the data. If so, return it: */ 21 21 for(int i=0;i<elements->Size();i++){ 22 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));22 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 23 23 found=element->NodalValue(&value,index,natureofdataenum); 24 24 if(found){ -
issm/trunk/src/c/modules/OutputDefinitionsResponsex/OutputDefinitionsResponsex.cpp
r17806 r19105 10 10 IssmDouble OutputDefinitionsResponsex(FemModel* femmodel,const char* output_string){ 11 11 12 Definition *definition = NULL;13 DataSet *output_definitions = NULL;14 IssmDouble return_value;15 16 12 /*Ok, go find the output definitions dataset in the parameters, where our responses are hiding: */ 17 output_definitions=((DataSetParam*)femmodel->parameters->FindParamObject(OutputdefinitionEnum))->value;13 DataSet* output_definitions=((DataSetParam*)femmodel->parameters->FindParamObject(OutputdefinitionEnum))->value; 18 14 19 15 /*Now, go through the output definitions, and retrieve the object which corresponds to our requested response, output_string: */ 20 16 for(int i=0;i<output_definitions->Size();i++){ 21 17 22 definition=dynamic_cast<Definition*>(output_definitions->GetObjectByOffset(i)); 18 //Definition* definition=xDynamicCast<Definition*>(output_definitions->GetObjectByOffset(i)); 19 Definition* definition=dynamic_cast<Definition*>(output_definitions->GetObjectByOffset(i)); 23 20 24 21 char* name = definition->Name(); 25 if 22 if(strcmp(name,output_string)==0){ 26 23 27 24 /*This is the object that we have been chasing for. compute the response and return: */ 28 return_value=definition->Response(femmodel);25 IssmDouble return_value=definition->Response(femmodel); 29 26 30 27 /*cleanup: */ … … 41 38 42 39 } 40 41 IssmDouble OutputDefinitionsResponsex(FemModel* femmodel,int output_enum){ 42 43 /*Ok, go find the output definitions dataset in the parameters, where our responses are hiding: */ 44 DataSet* output_definitions=((DataSetParam*)femmodel->parameters->FindParamObject(OutputdefinitionEnum))->value; 45 46 /*Now, go through the output definitions, and retrieve the object which corresponds to our requested response, output_enum: */ 47 for(int i=0;i<output_definitions->Size();i++){ 48 49 //Definition* definition=xDynamicCast<Definition*>(output_definitions->GetObjectByOffset(i)); 50 Definition* definition=dynamic_cast<Definition*>(output_definitions->GetObjectByOffset(i)); 51 52 int en = definition->DefinitionEnum(); 53 if(en==output_enum){ 54 55 /*This is the object that we have been chasing for. compute the response and return: */ 56 IssmDouble return_value=definition->Response(femmodel); 57 58 /*return:*/ 59 return return_value; 60 } 61 } 62 63 /*If we are here, did not find the definition for this response, not good!: */ 64 _error_("Could not find the response for output definition " << output_enum << " because could not find the definition itself!"); 65 66 } -
issm/trunk/src/c/modules/OutputDefinitionsResponsex/OutputDefinitionsResponsex.h
r16470 r19105 9 9 /* local prototypes: */ 10 10 IssmDouble OutputDefinitionsResponsex(FemModel* femmodel,const char* output_string); 11 IssmDouble OutputDefinitionsResponsex(FemModel* femmodel,int output_enum); 11 12 12 13 #endif /* _OUTPUTDEFINITIONSRESPONSEXX_H */ -
issm/trunk/src/c/modules/ResetFSBasalBoundaryConditionx/ResetFSBasalBoundaryConditionx.cpp
r17322 r19105 12 12 13 13 for (int i=0;i<elements->Size();i++){ 14 element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));14 element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 15 15 element->ResetFSBasalBoundaryCondition(); 16 16 } -
issm/trunk/src/c/modules/RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.cpp
r17989 r19105 16 16 /*Compute Misfit: */ 17 17 for(int i=0;i<elements->Size();i++){ 18 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));18 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 19 19 J+=RheologyBbarAbsGradient(element); 20 20 } -
issm/trunk/src/c/modules/SetActiveNodesLSMx/SetActiveNodesLSMx.cpp
r17700 r19105 22 22 23 23 for(i=0;i<elements->Size();i++){ 24 Element *element = dynamic_cast<Element*>(elements->GetObjectByOffset(i));24 Element *element = xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 25 25 int numnodes = element->GetNumberOfNodes(); 26 26 IssmDouble *mask = xNew<IssmDouble>(numnodes); … … 59 59 analysis_type==BalancethicknessAnalysisEnum || 60 60 analysis_type==HydrologyDCInefficientAnalysisEnum || 61 analysis_type==DamageEvolutionAnalysisEnum ||61 //analysis_type==DamageEvolutionAnalysisEnum || 62 62 analysis_type==HydrologyDCEfficientAnalysisEnum || 63 63 analysis_type==LevelsetAnalysisEnum || … … 104 104 /*Fill vector with values: */ 105 105 for(i=0;i<femmodel->elements->Size();i++){ 106 Element* element= dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));106 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 107 107 SetMaskOfIceElement(vec_mask_ice, element); 108 108 } … … 115 115 /*Clean up and return*/ 116 116 delete vec_mask_ice; 117 delete mask_ice;117 xDelete<IssmDouble>(mask_ice); 118 118 119 119 }/*}}}*/ -
issm/trunk/src/c/modules/SurfaceAbsVelMisfitx/SurfaceAbsVelMisfitx.cpp
r17989 r19105 16 16 /*Compute Misfit: */ 17 17 for(int i=0;i<elements->Size();i++){ 18 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));18 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 19 19 J+=SurfaceAbsVelMisfit(element); 20 20 } -
issm/trunk/src/c/modules/SurfaceAreax/SurfaceAreax.cpp
r16137 r19105 20 20 /*Compute gradients: */ 21 21 for(int i=0;i<femmodel->elements->Size();i++){ 22 element= dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));22 element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 23 23 S+=element->SurfaceArea(); 24 24 } -
issm/trunk/src/c/modules/SurfaceAverageVelMisfitx/SurfaceAverageVelMisfitx.cpp
r17989 r19105 17 17 /*Compute Misfit: */ 18 18 for(int i=0;i<femmodel->elements->Size();i++){ 19 Element* element= dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));19 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 20 20 J+=SurfaceAverageVelMisfit(element); 21 21 } -
issm/trunk/src/c/modules/SurfaceLogVelMisfitx/SurfaceLogVelMisfitx.cpp
r17989 r19105 16 16 /*Compute Misfit: */ 17 17 for(int i=0;i<elements->Size();i++){ 18 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));18 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 19 19 J+=SurfaceLogVelMisfit(element); 20 20 } -
issm/trunk/src/c/modules/SurfaceLogVxVyMisfitx/SurfaceLogVxVyMisfitx.cpp
r17989 r19105 16 16 /*Compute Misfit: */ 17 17 for(int i=0;i<elements->Size();i++){ 18 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));18 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 19 19 J+=SurfaceLogVxVyMisfit(element); 20 20 } -
issm/trunk/src/c/modules/SurfaceMassBalancex/SurfaceMassBalancex.cpp
r18301 r19105 11 11 /*Intermediaties*/ 12 12 int smb_model; 13 bool isdelta18o ;13 bool isdelta18o,ismungsm; 14 14 15 15 /*First, get SMB model from parameters*/ … … 23 23 case SMBpddEnum: 24 24 femmodel->parameters->FindParam(&isdelta18o,SurfaceforcingsIsdelta18oEnum); 25 femmodel->parameters->FindParam(&ismungsm,SurfaceforcingsIsmungsmEnum); 25 26 if(isdelta18o){ 26 if(VerboseSolution()) _printf0_(" call Delta18oParamet rization module\n");27 if(VerboseSolution()) _printf0_(" call Delta18oParameterization module\n"); 27 28 Delta18oParameterizationx(femmodel); 29 } 30 if(ismungsm){ 31 if(VerboseSolution()) _printf0_(" call MungsmtpParameterization module\n"); 32 MungsmtpParameterizationx(femmodel); 28 33 } 29 34 if(VerboseSolution()) _printf0_(" call positive degree day module\n"); … … 31 36 break; 32 37 case SMBgradientsEnum: 33 if(VerboseSolution())_printf _(" call smb gradients module\n");38 if(VerboseSolution())_printf0_(" call smb gradients module\n"); 34 39 SmbGradientsx(femmodel); 35 40 break; 36 41 case SMBhenningEnum: 37 if(VerboseSolution())_printf _(" call smb Henning module\n");42 if(VerboseSolution())_printf0_(" call smb Henning module\n"); 38 43 SmbHenningx(femmodel); 39 44 break; 40 45 case SMBcomponentsEnum: 41 if(VerboseSolution())_printf _(" call smb Components module\n");46 if(VerboseSolution())_printf0_(" call smb Components module\n"); 42 47 SmbComponentsx(femmodel); 43 48 break; 44 49 case SMBmeltcomponentsEnum: 45 if(VerboseSolution())_printf _(" call smb Melt Components module\n");50 if(VerboseSolution())_printf0_(" call smb Melt Components module\n"); 46 51 SmbMeltComponentsx(femmodel); 47 52 break; … … 64 69 /*Loop over all the elements of this partition*/ 65 70 for(int i=0;i<femmodel->elements->Size();i++){ 66 Element* element= dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));71 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 67 72 68 73 /*Allocate all arrays*/ … … 85 90 86 91 /*Get material parameters :*/ 87 rho_ice=element->matpar->Get RhoIce();88 rho_water=element->matpar->Get RhoFreshwater();92 rho_ice=element->matpar->GetMaterialParameter(MaterialsRhoIceEnum); 93 rho_water=element->matpar->GetMaterialParameter(MaterialsRhoFreshwaterEnum); 89 94 90 95 // loop over all vertices … … 113 118 114 119 for(int i=0;i<femmodel->elements->Size();i++){ 115 Element* element= dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));120 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 116 121 element->Delta18oParameterization(); 122 } 123 124 }/*}}}*/ 125 void MungsmtpParameterizationx(FemModel* femmodel){/*{{{*/ 126 127 for(int i=0;i<femmodel->elements->Size();i++){ 128 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 129 element->MungsmtpParameterization(); 117 130 } 118 131 … … 144 157 IssmDouble tstar; // monthly mean surface temp 145 158 159 bool ismungsm; 160 146 161 IssmDouble *pdds = NULL; 147 162 IssmDouble *pds = NULL; … … 150 165 pdds=xNew<IssmDouble>(NPDMAX+1); 151 166 pds=xNew<IssmDouble>(NPDCMAX+1); 167 168 // Get ismungsm parameter 169 femmodel->parameters->FindParam(&ismungsm,SurfaceforcingsIsmungsmEnum); 152 170 153 171 /* initialize PDD (creation of a lookup table)*/ … … 204 222 205 223 for(i=0;i<femmodel->elements->Size();i++){ 206 element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i)); 207 element->PositiveDegreeDay(pdds,pds,signorm); 208 } 209 224 element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 225 element->PositiveDegreeDay(pdds,pds,signorm,ismungsm); 226 } 210 227 /*free ressouces: */ 211 228 xDelete<IssmDouble>(pdds); … … 234 251 /*Loop over all the elements of this partition*/ 235 252 for(int i=0;i<femmodel->elements->Size();i++){ 236 Element* element= dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));253 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 237 254 238 255 /*Get reference SMB (uncorrected) and allocate all arrays*/ … … 263 280 } 264 281 265 /* Compute smb including anomaly, 266 correct for number of seconds in a year [s/yr]*/ 267 smb = smb + anomaly*yts; 268 282 /* Compute smb including anomaly, 283 correct for number of seconds in a year [s/yr]*/ 284 smb = smb/yts + anomaly; 285 286 269 287 /*Update array accordingly*/ 270 288 smblist[v] = smb; … … 292 310 /*Loop over all the elements of this partition*/ 293 311 for(int i=0;i<femmodel->elements->Size();i++){ 294 Element* element= dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));312 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 295 313 296 314 /*Allocate all arrays*/ … … 333 351 /*Loop over all the elements of this partition*/ 334 352 for(int i=0;i<femmodel->elements->Size();i++){ 335 Element* element= dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));353 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 336 354 337 355 /*Allocate all arrays*/ -
issm/trunk/src/c/modules/SurfaceMassBalancex/SurfaceMassBalancex.h
r18301 r19105 12 12 void SmbGradientsx(FemModel* femmodel); 13 13 void Delta18oParameterizationx(FemModel* femmodel); 14 void MungsmtpParameterizationx(FemModel* femmodel); 14 15 void PositiveDegreeDayx(FemModel* femmodel); 15 16 void SmbHenningx(FemModel* femmodel); -
issm/trunk/src/c/modules/SurfaceRelVelMisfitx/SurfaceRelVelMisfitx.cpp
r17989 r19105 16 16 /*Compute Misfit: */ 17 17 for(int i=0;i<elements->Size();i++){ 18 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));18 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 19 19 J+=SurfaceRelVelMisfit(element); 20 20 } -
issm/trunk/src/c/modules/SystemMatricesx/SystemMatricesx.cpp
r17806 r19105 31 31 Analysis* analysis = EnumToAnalysis(analysisenum); 32 32 33 /*Check if there are penalties*/ 34 bool ispenalty = femmodel->loads->IsPenalty(configuration_type); 35 33 36 /*First, we might need to do a dry run to get kmax if penalties are employed*/ 34 if( femmodel->loads->IsPenalty(configuration_type)){37 if(ispenalty){ 35 38 36 39 /*Allocate Kff_temp*/ … … 40 43 /*Get complete stiffness matrix without penalties*/ 41 44 for (i=0;i<femmodel->elements->Size();i++){ 42 element= dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));45 element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 43 46 ElementMatrix* Ke = analysis->CreateKMatrix(element); 44 47 ElementVector* pe = analysis->CreatePVector(element); … … 50 53 51 54 for (i=0;i<femmodel->loads->Size();i++){ 52 load= dynamic_cast<Load*>(femmodel->loads->GetObjectByOffset(i));55 load=xDynamicCast<Load*>(femmodel->loads->GetObjectByOffset(i)); 53 56 if(load->InAnalysis(configuration_type)) load->CreateKMatrix(Kff_temp,NULL); 54 57 } … … 71 74 /*Fill stiffness matrix and load vector from elements*/ 72 75 for (i=0;i<femmodel->elements->Size();i++){ 73 element= dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));76 element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 74 77 ElementMatrix* Ke = analysis->CreateKMatrix(element); 75 78 ElementVector* pe = analysis->CreatePVector(element); … … 85 88 /*Fill stiffness matrix and load vector from loads*/ 86 89 for(i=0;i<femmodel->loads->Size();i++){ 87 load= dynamic_cast<Load*>(femmodel->loads->GetObjectByOffset(i));90 load=xDynamicCast<Load*>(femmodel->loads->GetObjectByOffset(i)); 88 91 if(load->InAnalysis(configuration_type)){ 89 92 load->CreateKMatrix(Kff,Kfs); … … 93 96 94 97 /*Now deal with penalties (only in loads)*/ 95 if( femmodel->loads->IsPenalty(configuration_type)){98 if(ispenalty){ 96 99 for (i=0;i<femmodel->loads->Size();i++){ 97 load= dynamic_cast<Load*>(femmodel->loads->GetObjectByOffset(i));100 load=xDynamicCast<Load*>(femmodel->loads->GetObjectByOffset(i)); 98 101 if(load->InAnalysis(configuration_type)){ 99 102 load->PenaltyCreateKMatrix(Kff,Kfs,kmax); … … 106 109 if(pdf){ 107 110 for(i=0;i<femmodel->elements->Size();i++){ 108 element= dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));111 element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 109 112 ElementVector* de=analysis->CreateDVector(element); 110 113 if(de) de->InsertIntoGlobal(df); -
issm/trunk/src/c/modules/ThicknessAbsMisfitx/ThicknessAbsMisfitx.cpp
r17989 r19105 16 16 /*Compute Misfit: */ 17 17 for(int i=0;i<elements->Size();i++){ 18 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));18 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 19 19 J+=ThicknessAbsMisfit(element); 20 20 } -
issm/trunk/src/c/modules/ThicknessAcrossGradientx/ThicknessAcrossGradientx.cpp
r17989 r19105 16 16 /*Compute Misfit: */ 17 17 for(int i=0;i<elements->Size();i++){ 18 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));18 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 19 19 J+=ThicknessAcrossGradient(element); 20 20 } -
issm/trunk/src/c/modules/ThicknessAlongGradientx/ThicknessAlongGradientx.cpp
r17989 r19105 16 16 /*Compute Misfit: */ 17 17 for(int i=0;i<elements->Size();i++){ 18 Element* element= dynamic_cast<Element*>(elements->GetObjectByOffset(i));18 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 19 19 J+=ThicknessAlongGradient(element); 20 20 } -
issm/trunk/src/c/modules/modules.h
r18301 r19105 12 12 #include "./BamgConvertMeshx/BamgConvertMeshx.h" 13 13 #include "./BamgTriangulatex/BamgTriangulatex.h" 14 #include "./Calvingx/Calvingx.h" 14 15 #include "./Chacox/Chacox.h" 15 16 #include "./ConfigureObjectsx/ConfigureObjectsx.h" … … 20 21 #include "./CreateJacobianMatrixx/CreateJacobianMatrixx.h" 21 22 #include "./DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.h" 23 #include "./ExpToLevelSetx/ExpToLevelSetx.h" 22 24 #include "./ElementConnectivityx/ElementConnectivityx.h" 23 25 #include "./GetSolutionFromInputsx/GetSolutionFromInputsx.h" … … 76 78 #include "./ResetFSBasalBoundaryConditionx/ResetFSBasalBoundaryConditionx.h" 77 79 #include "./RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.h" 80 #include "./RheologyBAbsGradientx/RheologyBAbsGradientx.h" 78 81 #include "./Scotchx/Scotchx.h" 79 82 #include "./Shp2Kmlx/Shp2Kmlx.h" -
issm/trunk/src/c/shared/Elements/ComputeDelta18oTemperaturePrecipitation.cpp
r16560 r19105 17 17 IssmDouble glacialindex; // used to vary present day temperature 18 18 19 glacialindex = 0.;//(Delta18oTime-Delta18oPresent-delta18oLapseRate*(Delta18oSurfaceTime-Delta18oSurfacePresent))20 // /(Delta18oLgm-Delta18oPresent-delta18oLapseRate*(Delta18oSurfaceLgm-Delta18oSurfacePresent));19 glacialindex = (Delta18oTime-Delta18oPresent-delta18oLapseRate*(Delta18oSurfaceTime-Delta18oSurfacePresent)) 20 /(Delta18oLgm-Delta18oPresent-delta18oLapseRate*(Delta18oSurfaceLgm-Delta18oSurfacePresent)); // Tarasov 2004 paper 21 21 22 for (int imonth = 0; imonth<12; imonth++){ 22 for (int imonth = 0; imonth<12; imonth++){ 23 23 monthlytemperaturestmp[imonth] = glacialindex*TemperaturesLgm[imonth] + (1.-glacialindex)*TemperaturesPresentday[imonth]; 24 //monthlyprectmp[imonth] = 1.5*pow(2,((monthlytemperaturestmp[imonth]-273.15-0)/10)); //equation from rob's paper25 24 monthlyprectmp[imonth] = PrecipitationsPresentday[imonth]; 26 25 … … 29 28 *(monthlyprecout+imonth) = monthlyprectmp[imonth]; 30 29 } 31 // printf(" tempera %f\n",monthlytemperaturestmp[1]);32 30 } -
issm/trunk/src/c/shared/Elements/PddSurfaceMassBalance.cpp
r15396 r19105 1 1 /* file: PddSurfaceMassBlance.cpp 2 2 Calculating the surface mass balance using the positive degree day method. 3 Updating the precipitation and temperature to the new elevation 3 4 */ 4 5 … … 6 7 #include "../Numerics/numerics.h" 7 8 8 IssmDouble PddSurfaceMassBlance(IssmDouble* monthlytemperatures, IssmDouble* monthlyprec, IssmDouble* pdds, IssmDouble* pds, IssmDouble signorm, IssmDouble yts, IssmDouble h, IssmDouble s, IssmDouble rho_ice, IssmDouble rho_water, IssmDouble desfac, IssmDouble s0p){ 9 IssmDouble PddSurfaceMassBalance(IssmDouble* monthlytemperatures, IssmDouble* monthlyprec, 10 IssmDouble* pdds, IssmDouble* pds, IssmDouble signorm, 11 IssmDouble yts, IssmDouble h, IssmDouble s, IssmDouble desfac, 12 IssmDouble s0t,IssmDouble s0p, IssmDouble rlaps,IssmDouble rlapslgm, 13 IssmDouble TdiffTime,IssmDouble sealevTime, 14 IssmDouble rho_water,IssmDouble rho_ice){ 9 15 10 16 // output: … … 20 26 IssmDouble sconv; //rhow_rain/rhoi / 12 months 21 27 22 IssmDouble lapser=6.5, sealev=0.; // lapse rate. degrees per meter. 7.5 lev's 99 paper, 9 Marshall 99 paper 23 // IssmDouble desfac = 0.5; // desert elevation factor 24 // IssmDouble s0p=0.; // should be set to elevation from precip source 25 IssmDouble s0t=0.; // should be set to elevation from temperature source 28 //IssmDouble sealev=0.; // degrees per meter. 7.5 lev's 99 paper, 9 Marshall 99 paper 29 //IssmDouble Pfac=0.5,Tdiff=0.5; 30 IssmDouble rtlaps; 31 // IssmDouble lapser=6.5 // lapse rate 32 // IssmDouble desfac = 0.3; // desert elevation factor 33 // IssmDouble s0p=0.; // should be set to elevation from precip source 34 // IssmDouble s0t=0.; // should be set to elevation from temperature source 26 35 IssmDouble st; // elevation between altitude of the temp record and current altitude 27 36 IssmDouble sp; // elevation between altitude of the prec record and current altitude 37 IssmDouble deselcut=1.0; 28 38 29 39 // PDD and PD constants and variables … … 35 45 IssmDouble pddt, pd; // pd: snow/precip fraction, precipitation falling as snow 36 46 37 IssmDouble q, qmpt; // q is desert/elev. fact, hnpfac is huybrect fact, and pd is normal dist.38 IssmDouble qm = 0.; 39 IssmDouble qmt = 0.; 40 IssmDouble qmp = 0.; 47 IssmDouble q, qmpt; // q is desert/elev. fact, hnpfac is huybrect fact, and pd is normal dist. 48 IssmDouble qm = 0.; // snow part of the precipitation 49 IssmDouble qmt = 0.; // precipitation without desertification effect adjustment 50 IssmDouble qmp = 0.; // desertification taken into account 41 51 IssmDouble pdd = 0.; 42 52 IssmDouble frzndd = 0.; … … 68 78 69 79 // seasonal loop 70 for (iqj = 0; iqj < 12; iqj++){ 71 imonth = ismon[iqj]; 72 73 st=(s-s0t)/1000.; 74 tstar = monthlytemperatures[imonth] - lapser *max(st,sealev); 75 Tsurf = tstar*deltm+Tsurf; 80 for (iqj = 0; iqj < 12; iqj++){ 81 imonth = ismon[iqj]; 82 83 /*********compute lapse rate ****************/ 84 st=(s-s0t)/1000.; 85 rtlaps=TdiffTime*rlapslgm + (1.-TdiffTime)*rlaps; // lapse rate 86 87 /*********compute Surface temperature *******/ 88 monthlytemperatures[imonth]=monthlytemperatures[imonth] - rtlaps *max(st,sealevTime*0.001); 89 tstar = monthlytemperatures[imonth]; 90 Tsurf = tstar*deltm+Tsurf; 76 91 77 92 /*********compute PD ****************/ … … 83 98 84 99 /******exp des/elev precip reduction*******/ 85 sp=(s-s0p)/1000. ; // deselev effect is wrt chng in topo100 sp=(s-s0p)/1000.-deselcut; // deselev effect is wrt chng in topo 86 101 if (sp>0.0){q = exp(-desfac*sp);} 87 102 else {q = 1.0;} 88 103 89 qmt= qmt + monthlyprec[imonth]*sconv; //*sconv to convert in m of ice equivalent per month 104 qmt= qmt + monthlyprec[imonth]*sconv; //*sconv to convert in m of ice equivalent per month 90 105 qmpt= q*monthlyprec[imonth]*sconv; 91 106 qmp= qmp + qmpt; … … 95 110 // ndd(month)=-(tstar-pdd(month)) since ndd+pdd gives expectation of 96 111 // gaussian=T_m, so ndd=-(Tsurf-pdd) 97 if (iqj>5 && 112 if (iqj>5 && iqj<9){ Tsum=Tsum+tstar;} 98 113 99 114 if (tstar >= siglim) {pdd = pdd + tstar*deltm;} … … 103 118 frzndd = frzndd - (tstar-pddsig)*deltm;} 104 119 else{frzndd = frzndd - tstar*deltm; } 120 121 /*Assign output pointer*/ 122 *(monthlytemperatures+imonth) = monthlytemperatures[imonth]; 123 *(monthlyprec+imonth) = monthlyprec[imonth]; 105 124 } // end of seasonal loop 106 125 //****************************************************************** -
issm/trunk/src/c/shared/Elements/elements.h
r17806 r19105 13 13 IssmDouble LliboutryDuval(IssmDouble enthalpy, IssmDouble pressure, IssmDouble n, IssmDouble betaCC, IssmDouble referencetemperature, IssmDouble heatcapacity, IssmDouble latentheat); 14 14 // IssmDouble LliboutryDuval(IssmDouble temperature, IssmDouble waterfraction, IssmDouble depth,IssmDouble n); 15 IssmDouble PddSurfaceMassBlance(IssmDouble* monthlytemperatures, IssmDouble* monthlyprec, IssmDouble* pdds, IssmDouble* pds, 16 IssmDouble signorm, IssmDouble yts, IssmDouble h, IssmDouble s, 17 IssmDouble rho_ice, IssmDouble rho_water, IssmDouble desfac, IssmDouble s0p); 15 IssmDouble PddSurfaceMassBalance(IssmDouble* monthlytemperatures, IssmDouble* monthlyprec, 16 IssmDouble* pdds, IssmDouble* pds,IssmDouble signorm, IssmDouble yts, 17 IssmDouble h, IssmDouble s, IssmDouble desfac,IssmDouble s0t, 18 IssmDouble s0p, IssmDouble rlaps, IssmDouble rlapslgm, 19 IssmDouble TdiffTime,IssmDouble sealevTime, 20 IssmDouble rho_water, IssmDouble rho_ice); 18 21 void ComputeDelta18oTemperaturePrecipitation(IssmDouble Delta18oSurfacePresent, IssmDouble Delta18oSurfaceLgm, IssmDouble Delta18oSurfaceTime, 19 IssmDouble Delta18oPresent, IssmDouble Delta18oLgm, IssmDouble Delta18oTime, 20 IssmDouble* PrecipitationsPresentday, 21 IssmDouble* TemperaturesLgm, IssmDouble* TemperaturesPresentday, 22 IssmDouble* monthlytemperaturesout, IssmDouble* monthlyprecout); 22 IssmDouble Delta18oPresent, IssmDouble Delta18oLgm, IssmDouble Delta18oTime, 23 IssmDouble* PrecipitationsPresentday, 24 IssmDouble* TemperaturesLgm, IssmDouble* TemperaturesPresentday, 25 IssmDouble* monthlytemperaturesout, IssmDouble* monthlyprecout); 26 void ComputeMungsmTemperaturePrecipitation(IssmDouble TdiffTime, IssmDouble PfacTime, 27 IssmDouble* PrecipitationsLgm,IssmDouble* PrecipitationsPresentday, 28 IssmDouble* TemperaturesLgm, IssmDouble* TemperaturesPresentday, 29 IssmDouble* monthlytemperaturesout, IssmDouble* monthlyprecout); 23 30 IssmDouble DrainageFunctionWaterfraction(IssmDouble waterfraction, IssmDouble dt=0.); 31 IssmDouble StressIntensityIntegralWeight(IssmDouble depth, IssmDouble water_depth, IssmDouble thickness); 24 32 25 33 /*Print arrays*/ -
issm/trunk/src/c/shared/Enum/EnumDefinitions.h
r18301 r19105 50 50 BaseEnum, 51 51 ConstantsGEnum, 52 ConstantsOmegaEnum, 52 53 ConstantsReferencetemperatureEnum, 53 54 ConstantsYtsEnum, … … 87 88 FlowequationFeFSEnum, 88 89 FlowequationVertexEquationEnum, 90 FrictionAsEnum, 89 91 FrictionCoefficientEnum, 90 92 FrictionPEnum, … … 93 95 FrictionCEnum, 94 96 FrictionLawEnum, 97 FrictionGammaEnum, 98 FrictionWaterLayerEnum, 99 FrictionEffectivePressureEnum, 95 100 GeometryHydrostaticRatioEnum, 96 101 HydrologyModelEnum, … … 107 112 EplHeadSlopeXEnum, 108 113 EplHeadSlopeYEnum, 114 EplZigZagCounterEnum, 109 115 HydrologydcMaxIterEnum, 110 116 HydrologydcRelTolEnum, … … 121 127 HydrologydcEplPorosityEnum, 122 128 HydrologydcEplInitialThicknessEnum, 129 HydrologydcEplColapseThicknessEnum, 123 130 HydrologydcEplMaxThicknessEnum, 124 131 HydrologydcEplThicknessEnum, 125 132 HydrologydcEplThicknessOldEnum, 133 HydrologydcEplThickCompEnum, 126 134 HydrologydcEplConductivityEnum, 127 135 HydrologydcIsefficientlayerEnum, … … 132 140 HydrologydcPenaltyFactorEnum, 133 141 HydrologydcPenaltyLockEnum, 142 HydrologydcEplflipLockEnum, 134 143 HydrologydcBasalMoulinInputEnum, 135 144 HydrologyLayerEnum, … … 139 148 IndependentObjectEnum, 140 149 InversionControlParametersEnum, 150 InversionControlScalingFactorsEnum, 141 151 InversionCostFunctionThresholdEnum, 142 152 InversionCostFunctionsCoefficientsEnum, … … 163 173 InversionStepThresholdEnum, 164 174 InversionThicknessObsEnum, 175 InversionSurfaceObsEnum, 165 176 InversionVxObsEnum, 166 177 InversionVyObsEnum, … … 198 209 DamageEvolutionNumRequestedOutputsEnum, 199 210 DamageEvolutionRequestedOutputsEnum, 211 DamageEnum, 200 212 NewDamageEnum, 213 StressIntensityFactorEnum, 214 CalvingLawEnum, 215 CalvingCalvingrateEnum, 216 CalvingMeltingrateEnum, 217 CalvingLevermannEnum, 218 CalvingPiEnum, 219 CalvingDevEnum, 220 DefaultCalvingEnum, 221 CalvingRequestedOutputsEnum, 222 CalvinglevermannCoeffEnum, 223 CalvinglevermannMeltingrateEnum, 224 CalvingpiCoeffEnum, 225 CalvingpiMeltingrateEnum, 226 CalvingratexEnum, 227 CalvingrateyEnum, 228 CalvingratexAverageEnum, 229 CalvingrateyAverageEnum, 230 StrainRateparallelEnum, 231 StrainRateperpendicularEnum, 232 StrainRateeffectiveEnum, 201 233 MaterialsRhoIceEnum, 202 234 MaterialsRhoSeawaterEnum, … … 238 270 MasstransportPenaltyFactorEnum, 239 271 MasstransportSpcthicknessEnum, 240 MasstransportCalvingrateEnum,241 272 MasstransportStabilizationEnum, 242 273 MasstransportVertexPairingEnum, … … 271 302 ThermalIsenthalpyEnum, 272 303 ThermalIsdynamicbasalspcEnum, 304 ThermalReltolEnum, 273 305 ThermalMaxiterEnum, 274 306 ThermalPenaltyFactorEnum, … … 295 327 TransientIsdamageevolutionEnum, 296 328 TransientIshydrologyEnum, 329 TransientIscalvingEnum, 297 330 TransientNumRequestedOutputsEnum, 298 331 TransientRequestedOutputsEnum, … … 301 334 BalancethicknessApparentMassbalanceEnum, 302 335 Balancethickness2MisfitEnum, 303 BalancethicknessNuxEnum, 304 BalancethicknessNuyEnum, 305 BalancethicknessVxObsEnum, 306 BalancethicknessVyObsEnum, 307 BalancethicknessThicknessObsEnum, 336 BalancethicknessDiffusionCoefficientEnum, 337 BalancethicknessCmuEnum, 338 BalancethicknessOmegaEnum, 339 BalancethicknessD0Enum, 308 340 /*}}}*/ 309 341 /*Surfaceforcings{{{*/ … … 315 347 SurfaceforcingsDelta18oSurfaceEnum, 316 348 SurfaceforcingsIsdelta18oEnum, 349 SurfaceforcingsIsmungsmEnum, 317 350 SurfaceforcingsPrecipitationsPresentdayEnum, 351 SurfaceforcingsPrecipitationsLgmEnum, 318 352 SurfaceforcingsTemperaturesPresentdayEnum, 319 353 SurfaceforcingsTemperaturesLgmEnum, … … 321 355 SurfaceforcingsDesfacEnum, 322 356 SurfaceforcingsS0pEnum, 357 SurfaceforcingsS0tEnum, 358 SurfaceforcingsRlapsEnum, 359 SurfaceforcingsRlapslgmEnum, 360 SurfaceforcingsPfacEnum, 361 SurfaceforcingsTdiffEnum, 362 SurfaceforcingsSealevEnum, 323 363 SMBgradientsEnum, 324 364 SurfaceforcingsMonthlytemperaturesEnum, … … 383 423 SteadystateSolutionEnum, 384 424 SurfaceSlopeSolutionEnum, 385 SmoothedSurfaceSlopeXAnalysisEnum, 386 SmoothedSurfaceSlopeYAnalysisEnum, 425 SmoothAnalysisEnum, 387 426 ThermalAnalysisEnum, 388 427 ThermalSolutionEnum, … … 394 433 MeshdeformationAnalysisEnum, 395 434 LevelsetAnalysisEnum, 435 LevelsetStabilizationEnum, 396 436 ExtrapolationAnalysisEnum, 397 437 LsfReinitializationAnalysisEnum, … … 443 483 InputToL2ProjectEnum, 444 484 InputToDepthaverageEnum, 485 InputToSmoothEnum, 486 SmoothThicknessMultiplierEnum, 445 487 IntParamEnum, 446 488 IntVecParamEnum, … … 457 499 ProfilerEnum, 458 500 MatrixParamEnum, 501 MassconEnum, 502 MassconNameEnum, 503 MassconDefinitionenumEnum, 504 MassconLevelsetEnum, 505 MassconaxpbyEnum, 506 MassconaxpbyNameEnum, 507 MassconaxpbyDefinitionenumEnum, 508 MassconaxpbyNamexEnum, 509 MassconaxpbyNameyEnum, 510 MassconaxpbyAlphaEnum, 511 MassconaxpbyBetaEnum, 459 512 NodeSIdEnum, 460 513 VectorParamEnum, … … 524 577 TemperaturePicardEnum, 525 578 ThicknessAbsMisfitEnum, 579 SurfaceAbsMisfitEnum, 526 580 VelEnum, 527 581 VelocityEnum, … … 547 601 IntMatParamEnum, 548 602 RheologyBbarAbsGradientEnum, 603 RheologyBAbsGradientEnum, 549 604 DragCoefficientAbsGradientEnum, 550 605 TransientInputEnum, … … 555 610 HydrologyWaterVxEnum, 556 611 HydrologyWaterVyEnum, 612 DrivingStressXEnum, 613 DrivingStressYEnum, 557 614 SigmaNNEnum, 558 615 StressTensorEnum, … … 563 620 StressTensoryzEnum, 564 621 StressTensorzzEnum, 622 StressMaxPrincipalEnum, 565 623 DeviatoricStressEnum, 566 624 DeviatoricStressxxEnum, … … 578 636 StrainRatezzEnum, 579 637 DivergenceEnum, 638 MaxDivergenceEnum, 580 639 GiaCrossSectionShapeEnum, 581 640 GiadWdtEnum, … … 604 663 OneLayerP4zEnum, 605 664 CrouzeixRaviartEnum, 665 LACrouzeixRaviartEnum, 606 666 /*}}}*/ 607 667 /*Results{{{*/ … … 619 679 /*Output Definitions{{{*/ 620 680 OutputdefinitionEnum, 681 Outputdefinition1Enum, 682 Outputdefinition2Enum, 683 Outputdefinition3Enum, 684 Outputdefinition4Enum, 685 Outputdefinition5Enum, 686 Outputdefinition6Enum, 687 Outputdefinition7Enum, 688 Outputdefinition8Enum, 689 Outputdefinition9Enum, 690 Outputdefinition10Enum, 691 Outputdefinition11Enum, 692 Outputdefinition12Enum, 693 Outputdefinition13Enum, 694 Outputdefinition14Enum, 695 Outputdefinition15Enum, 696 Outputdefinition16Enum, 697 Outputdefinition17Enum, 698 Outputdefinition18Enum, 699 Outputdefinition19Enum, 700 Outputdefinition20Enum, 701 Outputdefinition21Enum, 702 Outputdefinition22Enum, 703 Outputdefinition23Enum, 704 Outputdefinition24Enum, 705 Outputdefinition25Enum, 706 Outputdefinition26Enum, 707 Outputdefinition27Enum, 708 Outputdefinition28Enum, 709 Outputdefinition29Enum, 710 Outputdefinition30Enum, 711 Outputdefinition31Enum, 712 Outputdefinition32Enum, 713 Outputdefinition33Enum, 714 Outputdefinition34Enum, 715 Outputdefinition35Enum, 716 Outputdefinition36Enum, 717 Outputdefinition37Enum, 718 Outputdefinition38Enum, 719 Outputdefinition39Enum, 720 Outputdefinition40Enum, 721 Outputdefinition41Enum, 722 Outputdefinition42Enum, 723 Outputdefinition43Enum, 724 Outputdefinition44Enum, 725 Outputdefinition45Enum, 726 Outputdefinition46Enum, 727 Outputdefinition47Enum, 728 Outputdefinition48Enum, 729 Outputdefinition49Enum, 730 Outputdefinition50Enum, 731 Outputdefinition51Enum, 732 Outputdefinition52Enum, 733 Outputdefinition53Enum, 734 Outputdefinition54Enum, 735 Outputdefinition55Enum, 736 Outputdefinition56Enum, 737 Outputdefinition57Enum, 738 Outputdefinition58Enum, 739 Outputdefinition59Enum, 740 Outputdefinition60Enum, 741 Outputdefinition61Enum, 742 Outputdefinition62Enum, 743 Outputdefinition63Enum, 744 Outputdefinition64Enum, 745 Outputdefinition65Enum, 746 Outputdefinition66Enum, 747 Outputdefinition67Enum, 748 Outputdefinition68Enum, 749 Outputdefinition69Enum, 750 Outputdefinition70Enum, 751 Outputdefinition71Enum, 752 Outputdefinition72Enum, 753 Outputdefinition73Enum, 754 Outputdefinition74Enum, 755 Outputdefinition75Enum, 756 Outputdefinition76Enum, 757 Outputdefinition77Enum, 758 Outputdefinition78Enum, 759 Outputdefinition79Enum, 760 Outputdefinition80Enum, 761 Outputdefinition81Enum, 762 Outputdefinition82Enum, 763 Outputdefinition83Enum, 764 Outputdefinition84Enum, 765 Outputdefinition85Enum, 766 Outputdefinition86Enum, 767 Outputdefinition87Enum, 768 Outputdefinition88Enum, 769 Outputdefinition89Enum, 770 Outputdefinition90Enum, 771 Outputdefinition91Enum, 772 Outputdefinition92Enum, 773 Outputdefinition93Enum, 774 Outputdefinition94Enum, 775 Outputdefinition95Enum, 776 Outputdefinition96Enum, 777 Outputdefinition97Enum, 778 Outputdefinition98Enum, 779 Outputdefinition99Enum, 780 Outputdefinition100Enum, 621 781 OutputdefinitionListEnum, 622 782 MassfluxatgateEnum, 623 783 MassfluxatgateNameEnum, 784 MassfluxatgateDefinitionenumEnum, 624 785 MassfluxatgateSegmentsEnum, 625 786 MisfitNameEnum, 787 MisfitDefinitionenumEnum, 626 788 MisfitModelEnumEnum, 627 789 MisfitObservationEnum, 628 790 MisfitObservationEnumEnum, 791 MisfitLocalEnum, 629 792 MisfitTimeinterpolationEnum, 630 793 MisfitWeightsEnum, … … 632 795 SurfaceObservationEnum, 633 796 WeightsSurfaceObservationEnum, 797 VxObsEnum, 798 WeightsVxObsEnum, 799 VyObsEnum, 800 WeightsVyObsEnum, 634 801 /*}}}*/ 635 802 /*Responses{{{*/ … … 645 812 MaxVzEnum, 646 813 MaxAbsVzEnum, 814 IceMassEnum, 647 815 IceVolumeEnum, 648 816 IceVolumeAboveFloatationEnum, … … 665 833 SubelementMigration2Enum, 666 834 ContactEnum, 835 GroundingOnlyEnum, 667 836 MaskGroundediceLevelsetEnum, 668 837 /*}}}*/ … … 693 862 OldGradientEnum, 694 863 OutputFilePointerEnum, 864 ToolkitsFileNameEnum, 865 RootPathEnum, 695 866 OutputFileNameEnum, 867 InputFileNameEnum, 696 868 LockFileNameEnum, 697 869 ToolkitsOptionsAnalysesEnum, -
issm/trunk/src/c/shared/Enum/EnumToStringx.cpp
r18301 r19105 58 58 case BaseEnum : return "Base"; 59 59 case ConstantsGEnum : return "ConstantsG"; 60 case ConstantsOmegaEnum : return "ConstantsOmega"; 60 61 case ConstantsReferencetemperatureEnum : return "ConstantsReferencetemperature"; 61 62 case ConstantsYtsEnum : return "ConstantsYts"; … … 95 96 case FlowequationFeFSEnum : return "FlowequationFeFS"; 96 97 case FlowequationVertexEquationEnum : return "FlowequationVertexEquation"; 98 case FrictionAsEnum : return "FrictionAs"; 97 99 case FrictionCoefficientEnum : return "FrictionCoefficient"; 98 100 case FrictionPEnum : return "FrictionP"; … … 101 103 case FrictionCEnum : return "FrictionC"; 102 104 case FrictionLawEnum : return "FrictionLaw"; 105 case FrictionGammaEnum : return "FrictionGamma"; 106 case FrictionWaterLayerEnum : return "FrictionWaterLayer"; 107 case FrictionEffectivePressureEnum : return "FrictionEffectivePressure"; 103 108 case GeometryHydrostaticRatioEnum : return "GeometryHydrostaticRatio"; 104 109 case HydrologyModelEnum : return "HydrologyModel"; … … 115 120 case EplHeadSlopeXEnum : return "EplHeadSlopeX"; 116 121 case EplHeadSlopeYEnum : return "EplHeadSlopeY"; 122 case EplZigZagCounterEnum : return "EplZigZagCounter"; 117 123 case HydrologydcMaxIterEnum : return "HydrologydcMaxIter"; 118 124 case HydrologydcRelTolEnum : return "HydrologydcRelTol"; … … 129 135 case HydrologydcEplPorosityEnum : return "HydrologydcEplPorosity"; 130 136 case HydrologydcEplInitialThicknessEnum : return "HydrologydcEplInitialThickness"; 137 case HydrologydcEplColapseThicknessEnum : return "HydrologydcEplColapseThickness"; 131 138 case HydrologydcEplMaxThicknessEnum : return "HydrologydcEplMaxThickness"; 132 139 case HydrologydcEplThicknessEnum : return "HydrologydcEplThickness"; 133 140 case HydrologydcEplThicknessOldEnum : return "HydrologydcEplThicknessOld"; 141 case HydrologydcEplThickCompEnum : return "HydrologydcEplThickComp"; 134 142 case HydrologydcEplConductivityEnum : return "HydrologydcEplConductivity"; 135 143 case HydrologydcIsefficientlayerEnum : return "HydrologydcIsefficientlayer"; … … 140 148 case HydrologydcPenaltyFactorEnum : return "HydrologydcPenaltyFactor"; 141 149 case HydrologydcPenaltyLockEnum : return "HydrologydcPenaltyLock"; 150 case HydrologydcEplflipLockEnum : return "HydrologydcEplflipLock"; 142 151 case HydrologydcBasalMoulinInputEnum : return "HydrologydcBasalMoulinInput"; 143 152 case HydrologyLayerEnum : return "HydrologyLayer"; … … 147 156 case IndependentObjectEnum : return "IndependentObject"; 148 157 case InversionControlParametersEnum : return "InversionControlParameters"; 158 case InversionControlScalingFactorsEnum : return "InversionControlScalingFactors"; 149 159 case InversionCostFunctionThresholdEnum : return "InversionCostFunctionThreshold"; 150 160 case InversionCostFunctionsCoefficientsEnum : return "InversionCostFunctionsCoefficients"; … … 171 181 case InversionStepThresholdEnum : return "InversionStepThreshold"; 172 182 case InversionThicknessObsEnum : return "InversionThicknessObs"; 183 case InversionSurfaceObsEnum : return "InversionSurfaceObs"; 173 184 case InversionVxObsEnum : return "InversionVxObs"; 174 185 case InversionVyObsEnum : return "InversionVyObs"; … … 206 217 case DamageEvolutionNumRequestedOutputsEnum : return "DamageEvolutionNumRequestedOutputs"; 207 218 case DamageEvolutionRequestedOutputsEnum : return "DamageEvolutionRequestedOutputs"; 219 case DamageEnum : return "Damage"; 208 220 case NewDamageEnum : return "NewDamage"; 221 case StressIntensityFactorEnum : return "StressIntensityFactor"; 222 case CalvingLawEnum : return "CalvingLaw"; 223 case CalvingCalvingrateEnum : return "CalvingCalvingrate"; 224 case CalvingMeltingrateEnum : return "CalvingMeltingrate"; 225 case CalvingLevermannEnum : return "CalvingLevermann"; 226 case CalvingPiEnum : return "CalvingPi"; 227 case CalvingDevEnum : return "CalvingDev"; 228 case DefaultCalvingEnum : return "DefaultCalving"; 229 case CalvingRequestedOutputsEnum : return "CalvingRequestedOutputs"; 230 case CalvinglevermannCoeffEnum : return "CalvinglevermannCoeff"; 231 case CalvinglevermannMeltingrateEnum : return "CalvinglevermannMeltingrate"; 232 case CalvingpiCoeffEnum : return "CalvingpiCoeff"; 233 case CalvingpiMeltingrateEnum : return "CalvingpiMeltingrate"; 234 case CalvingratexEnum : return "Calvingratex"; 235 case CalvingrateyEnum : return "Calvingratey"; 236 case CalvingratexAverageEnum : return "CalvingratexAverage"; 237 case CalvingrateyAverageEnum : return "CalvingrateyAverage"; 238 case StrainRateparallelEnum : return "StrainRateparallel"; 239 case StrainRateperpendicularEnum : return "StrainRateperpendicular"; 240 case StrainRateeffectiveEnum : return "StrainRateeffective"; 209 241 case MaterialsRhoIceEnum : return "MaterialsRhoIce"; 210 242 case MaterialsRhoSeawaterEnum : return "MaterialsRhoSeawater"; … … 246 278 case MasstransportPenaltyFactorEnum : return "MasstransportPenaltyFactor"; 247 279 case MasstransportSpcthicknessEnum : return "MasstransportSpcthickness"; 248 case MasstransportCalvingrateEnum : return "MasstransportCalvingrate";249 280 case MasstransportStabilizationEnum : return "MasstransportStabilization"; 250 281 case MasstransportVertexPairingEnum : return "MasstransportVertexPairing"; … … 279 310 case ThermalIsenthalpyEnum : return "ThermalIsenthalpy"; 280 311 case ThermalIsdynamicbasalspcEnum : return "ThermalIsdynamicbasalspc"; 312 case ThermalReltolEnum : return "ThermalReltol"; 281 313 case ThermalMaxiterEnum : return "ThermalMaxiter"; 282 314 case ThermalPenaltyFactorEnum : return "ThermalPenaltyFactor"; … … 303 335 case TransientIsdamageevolutionEnum : return "TransientIsdamageevolution"; 304 336 case TransientIshydrologyEnum : return "TransientIshydrology"; 337 case TransientIscalvingEnum : return "TransientIscalving"; 305 338 case TransientNumRequestedOutputsEnum : return "TransientNumRequestedOutputs"; 306 339 case TransientRequestedOutputsEnum : return "TransientRequestedOutputs"; … … 309 342 case BalancethicknessApparentMassbalanceEnum : return "BalancethicknessApparentMassbalance"; 310 343 case Balancethickness2MisfitEnum : return "Balancethickness2Misfit"; 311 case BalancethicknessNuxEnum : return "BalancethicknessNux"; 312 case BalancethicknessNuyEnum : return "BalancethicknessNuy"; 313 case BalancethicknessVxObsEnum : return "BalancethicknessVxObs"; 314 case BalancethicknessVyObsEnum : return "BalancethicknessVyObs"; 315 case BalancethicknessThicknessObsEnum : return "BalancethicknessThicknessObs"; 344 case BalancethicknessDiffusionCoefficientEnum : return "BalancethicknessDiffusionCoefficient"; 345 case BalancethicknessCmuEnum : return "BalancethicknessCmu"; 346 case BalancethicknessOmegaEnum : return "BalancethicknessOmega"; 347 case BalancethicknessD0Enum : return "BalancethicknessD0"; 316 348 case SurfaceforcingsEnum : return "Surfaceforcings"; 317 349 case SMBEnum : return "SMB"; … … 321 353 case SurfaceforcingsDelta18oSurfaceEnum : return "SurfaceforcingsDelta18oSurface"; 322 354 case SurfaceforcingsIsdelta18oEnum : return "SurfaceforcingsIsdelta18o"; 355 case SurfaceforcingsIsmungsmEnum : return "SurfaceforcingsIsmungsm"; 323 356 case SurfaceforcingsPrecipitationsPresentdayEnum : return "SurfaceforcingsPrecipitationsPresentday"; 357 case SurfaceforcingsPrecipitationsLgmEnum : return "SurfaceforcingsPrecipitationsLgm"; 324 358 case SurfaceforcingsTemperaturesPresentdayEnum : return "SurfaceforcingsTemperaturesPresentday"; 325 359 case SurfaceforcingsTemperaturesLgmEnum : return "SurfaceforcingsTemperaturesLgm"; … … 327 361 case SurfaceforcingsDesfacEnum : return "SurfaceforcingsDesfac"; 328 362 case SurfaceforcingsS0pEnum : return "SurfaceforcingsS0p"; 363 case SurfaceforcingsS0tEnum : return "SurfaceforcingsS0t"; 364 case SurfaceforcingsRlapsEnum : return "SurfaceforcingsRlaps"; 365 case SurfaceforcingsRlapslgmEnum : return "SurfaceforcingsRlapslgm"; 366 case SurfaceforcingsPfacEnum : return "SurfaceforcingsPfac"; 367 case SurfaceforcingsTdiffEnum : return "SurfaceforcingsTdiff"; 368 case SurfaceforcingsSealevEnum : return "SurfaceforcingsSealev"; 329 369 case SMBgradientsEnum : return "SMBgradients"; 330 370 case SurfaceforcingsMonthlytemperaturesEnum : return "SurfaceforcingsMonthlytemperatures"; … … 386 426 case SteadystateSolutionEnum : return "SteadystateSolution"; 387 427 case SurfaceSlopeSolutionEnum : return "SurfaceSlopeSolution"; 388 case SmoothedSurfaceSlopeXAnalysisEnum : return "SmoothedSurfaceSlopeXAnalysis"; 389 case SmoothedSurfaceSlopeYAnalysisEnum : return "SmoothedSurfaceSlopeYAnalysis"; 428 case SmoothAnalysisEnum : return "SmoothAnalysis"; 390 429 case ThermalAnalysisEnum : return "ThermalAnalysis"; 391 430 case ThermalSolutionEnum : return "ThermalSolution"; … … 397 436 case MeshdeformationAnalysisEnum : return "MeshdeformationAnalysis"; 398 437 case LevelsetAnalysisEnum : return "LevelsetAnalysis"; 438 case LevelsetStabilizationEnum : return "LevelsetStabilization"; 399 439 case ExtrapolationAnalysisEnum : return "ExtrapolationAnalysis"; 400 440 case LsfReinitializationAnalysisEnum : return "LsfReinitializationAnalysis"; … … 440 480 case InputToL2ProjectEnum : return "InputToL2Project"; 441 481 case InputToDepthaverageEnum : return "InputToDepthaverage"; 482 case InputToSmoothEnum : return "InputToSmooth"; 483 case SmoothThicknessMultiplierEnum : return "SmoothThicknessMultiplier"; 442 484 case IntParamEnum : return "IntParam"; 443 485 case IntVecParamEnum : return "IntVecParam"; … … 454 496 case ProfilerEnum : return "Profiler"; 455 497 case MatrixParamEnum : return "MatrixParam"; 498 case MassconEnum : return "Masscon"; 499 case MassconNameEnum : return "MassconName"; 500 case MassconDefinitionenumEnum : return "MassconDefinitionenum"; 501 case MassconLevelsetEnum : return "MassconLevelset"; 502 case MassconaxpbyEnum : return "Massconaxpby"; 503 case MassconaxpbyNameEnum : return "MassconaxpbyName"; 504 case MassconaxpbyDefinitionenumEnum : return "MassconaxpbyDefinitionenum"; 505 case MassconaxpbyNamexEnum : return "MassconaxpbyNamex"; 506 case MassconaxpbyNameyEnum : return "MassconaxpbyNamey"; 507 case MassconaxpbyAlphaEnum : return "MassconaxpbyAlpha"; 508 case MassconaxpbyBetaEnum : return "MassconaxpbyBeta"; 456 509 case NodeSIdEnum : return "NodeSId"; 457 510 case VectorParamEnum : return "VectorParam"; … … 515 568 case TemperaturePicardEnum : return "TemperaturePicard"; 516 569 case ThicknessAbsMisfitEnum : return "ThicknessAbsMisfit"; 570 case SurfaceAbsMisfitEnum : return "SurfaceAbsMisfit"; 517 571 case VelEnum : return "Vel"; 518 572 case VelocityEnum : return "Velocity"; … … 538 592 case IntMatParamEnum : return "IntMatParam"; 539 593 case RheologyBbarAbsGradientEnum : return "RheologyBbarAbsGradient"; 594 case RheologyBAbsGradientEnum : return "RheologyBAbsGradient"; 540 595 case DragCoefficientAbsGradientEnum : return "DragCoefficientAbsGradient"; 541 596 case TransientInputEnum : return "TransientInput"; … … 546 601 case HydrologyWaterVxEnum : return "HydrologyWaterVx"; 547 602 case HydrologyWaterVyEnum : return "HydrologyWaterVy"; 603 case DrivingStressXEnum : return "DrivingStressX"; 604 case DrivingStressYEnum : return "DrivingStressY"; 548 605 case SigmaNNEnum : return "SigmaNN"; 549 606 case StressTensorEnum : return "StressTensor"; … … 554 611 case StressTensoryzEnum : return "StressTensoryz"; 555 612 case StressTensorzzEnum : return "StressTensorzz"; 613 case StressMaxPrincipalEnum : return "StressMaxPrincipal"; 556 614 case DeviatoricStressEnum : return "DeviatoricStress"; 557 615 case DeviatoricStressxxEnum : return "DeviatoricStressxx"; … … 569 627 case StrainRatezzEnum : return "StrainRatezz"; 570 628 case DivergenceEnum : return "Divergence"; 629 case MaxDivergenceEnum : return "MaxDivergence"; 571 630 case GiaCrossSectionShapeEnum : return "GiaCrossSectionShape"; 572 631 case GiadWdtEnum : return "GiadWdt"; … … 593 652 case OneLayerP4zEnum : return "OneLayerP4z"; 594 653 case CrouzeixRaviartEnum : return "CrouzeixRaviart"; 654 case LACrouzeixRaviartEnum : return "LACrouzeixRaviart"; 595 655 case SaveResultsEnum : return "SaveResults"; 596 656 case BoolExternalResultEnum : return "BoolExternalResult"; … … 604 664 case WaterColumnOldEnum : return "WaterColumnOld"; 605 665 case OutputdefinitionEnum : return "Outputdefinition"; 666 case Outputdefinition1Enum : return "Outputdefinition1"; 667 case Outputdefinition2Enum : return "Outputdefinition2"; 668 case Outputdefinition3Enum : return "Outputdefinition3"; 669 case Outputdefinition4Enum : return "Outputdefinition4"; 670 case Outputdefinition5Enum : return "Outputdefinition5"; 671 case Outputdefinition6Enum : return "Outputdefinition6"; 672 case Outputdefinition7Enum : return "Outputdefinition7"; 673 case Outputdefinition8Enum : return "Outputdefinition8"; 674 case Outputdefinition9Enum : return "Outputdefinition9"; 675 case Outputdefinition10Enum : return "Outputdefinition10"; 676 case Outputdefinition11Enum : return "Outputdefinition11"; 677 case Outputdefinition12Enum : return "Outputdefinition12"; 678 case Outputdefinition13Enum : return "Outputdefinition13"; 679 case Outputdefinition14Enum : return "Outputdefinition14"; 680 case Outputdefinition15Enum : return "Outputdefinition15"; 681 case Outputdefinition16Enum : return "Outputdefinition16"; 682 case Outputdefinition17Enum : return "Outputdefinition17"; 683 case Outputdefinition18Enum : return "Outputdefinition18"; 684 case Outputdefinition19Enum : return "Outputdefinition19"; 685 case Outputdefinition20Enum : return "Outputdefinition20"; 686 case Outputdefinition21Enum : return "Outputdefinition21"; 687 case Outputdefinition22Enum : return "Outputdefinition22"; 688 case Outputdefinition23Enum : return "Outputdefinition23"; 689 case Outputdefinition24Enum : return "Outputdefinition24"; 690 case Outputdefinition25Enum : return "Outputdefinition25"; 691 case Outputdefinition26Enum : return "Outputdefinition26"; 692 case Outputdefinition27Enum : return "Outputdefinition27"; 693 case Outputdefinition28Enum : return "Outputdefinition28"; 694 case Outputdefinition29Enum : return "Outputdefinition29"; 695 case Outputdefinition30Enum : return "Outputdefinition30"; 696 case Outputdefinition31Enum : return "Outputdefinition31"; 697 case Outputdefinition32Enum : return "Outputdefinition32"; 698 case Outputdefinition33Enum : return "Outputdefinition33"; 699 case Outputdefinition34Enum : return "Outputdefinition34"; 700 case Outputdefinition35Enum : return "Outputdefinition35"; 701 case Outputdefinition36Enum : return "Outputdefinition36"; 702 case Outputdefinition37Enum : return "Outputdefinition37"; 703 case Outputdefinition38Enum : return "Outputdefinition38"; 704 case Outputdefinition39Enum : return "Outputdefinition39"; 705 case Outputdefinition40Enum : return "Outputdefinition40"; 706 case Outputdefinition41Enum : return "Outputdefinition41"; 707 case Outputdefinition42Enum : return "Outputdefinition42"; 708 case Outputdefinition43Enum : return "Outputdefinition43"; 709 case Outputdefinition44Enum : return "Outputdefinition44"; 710 case Outputdefinition45Enum : return "Outputdefinition45"; 711 case Outputdefinition46Enum : return "Outputdefinition46"; 712 case Outputdefinition47Enum : return "Outputdefinition47"; 713 case Outputdefinition48Enum : return "Outputdefinition48"; 714 case Outputdefinition49Enum : return "Outputdefinition49"; 715 case Outputdefinition50Enum : return "Outputdefinition50"; 716 case Outputdefinition51Enum : return "Outputdefinition51"; 717 case Outputdefinition52Enum : return "Outputdefinition52"; 718 case Outputdefinition53Enum : return "Outputdefinition53"; 719 case Outputdefinition54Enum : return "Outputdefinition54"; 720 case Outputdefinition55Enum : return "Outputdefinition55"; 721 case Outputdefinition56Enum : return "Outputdefinition56"; 722 case Outputdefinition57Enum : return "Outputdefinition57"; 723 case Outputdefinition58Enum : return "Outputdefinition58"; 724 case Outputdefinition59Enum : return "Outputdefinition59"; 725 case Outputdefinition60Enum : return "Outputdefinition60"; 726 case Outputdefinition61Enum : return "Outputdefinition61"; 727 case Outputdefinition62Enum : return "Outputdefinition62"; 728 case Outputdefinition63Enum : return "Outputdefinition63"; 729 case Outputdefinition64Enum : return "Outputdefinition64"; 730 case Outputdefinition65Enum : return "Outputdefinition65"; 731 case Outputdefinition66Enum : return "Outputdefinition66"; 732 case Outputdefinition67Enum : return "Outputdefinition67"; 733 case Outputdefinition68Enum : return "Outputdefinition68"; 734 case Outputdefinition69Enum : return "Outputdefinition69"; 735 case Outputdefinition70Enum : return "Outputdefinition70"; 736 case Outputdefinition71Enum : return "Outputdefinition71"; 737 case Outputdefinition72Enum : return "Outputdefinition72"; 738 case Outputdefinition73Enum : return "Outputdefinition73"; 739 case Outputdefinition74Enum : return "Outputdefinition74"; 740 case Outputdefinition75Enum : return "Outputdefinition75"; 741 case Outputdefinition76Enum : return "Outputdefinition76"; 742 case Outputdefinition77Enum : return "Outputdefinition77"; 743 case Outputdefinition78Enum : return "Outputdefinition78"; 744 case Outputdefinition79Enum : return "Outputdefinition79"; 745 case Outputdefinition80Enum : return "Outputdefinition80"; 746 case Outputdefinition81Enum : return "Outputdefinition81"; 747 case Outputdefinition82Enum : return "Outputdefinition82"; 748 case Outputdefinition83Enum : return "Outputdefinition83"; 749 case Outputdefinition84Enum : return "Outputdefinition84"; 750 case Outputdefinition85Enum : return "Outputdefinition85"; 751 case Outputdefinition86Enum : return "Outputdefinition86"; 752 case Outputdefinition87Enum : return "Outputdefinition87"; 753 case Outputdefinition88Enum : return "Outputdefinition88"; 754 case Outputdefinition89Enum : return "Outputdefinition89"; 755 case Outputdefinition90Enum : return "Outputdefinition90"; 756 case Outputdefinition91Enum : return "Outputdefinition91"; 757 case Outputdefinition92Enum : return "Outputdefinition92"; 758 case Outputdefinition93Enum : return "Outputdefinition93"; 759 case Outputdefinition94Enum : return "Outputdefinition94"; 760 case Outputdefinition95Enum : return "Outputdefinition95"; 761 case Outputdefinition96Enum : return "Outputdefinition96"; 762 case Outputdefinition97Enum : return "Outputdefinition97"; 763 case Outputdefinition98Enum : return "Outputdefinition98"; 764 case Outputdefinition99Enum : return "Outputdefinition99"; 765 case Outputdefinition100Enum : return "Outputdefinition100"; 606 766 case OutputdefinitionListEnum : return "OutputdefinitionList"; 607 767 case MassfluxatgateEnum : return "Massfluxatgate"; 608 768 case MassfluxatgateNameEnum : return "MassfluxatgateName"; 769 case MassfluxatgateDefinitionenumEnum : return "MassfluxatgateDefinitionenum"; 609 770 case MassfluxatgateSegmentsEnum : return "MassfluxatgateSegments"; 610 771 case MisfitNameEnum : return "MisfitName"; 772 case MisfitDefinitionenumEnum : return "MisfitDefinitionenum"; 611 773 case MisfitModelEnumEnum : return "MisfitModelEnum"; 612 774 case MisfitObservationEnum : return "MisfitObservation"; 613 775 case MisfitObservationEnumEnum : return "MisfitObservationEnum"; 776 case MisfitLocalEnum : return "MisfitLocal"; 614 777 case MisfitTimeinterpolationEnum : return "MisfitTimeinterpolation"; 615 778 case MisfitWeightsEnum : return "MisfitWeights"; … … 617 780 case SurfaceObservationEnum : return "SurfaceObservation"; 618 781 case WeightsSurfaceObservationEnum : return "WeightsSurfaceObservation"; 782 case VxObsEnum : return "VxObs"; 783 case WeightsVxObsEnum : return "WeightsVxObs"; 784 case VyObsEnum : return "VyObs"; 785 case WeightsVyObsEnum : return "WeightsVyObs"; 619 786 case MinVelEnum : return "MinVel"; 620 787 case MaxVelEnum : return "MaxVel"; … … 628 795 case MaxVzEnum : return "MaxVz"; 629 796 case MaxAbsVzEnum : return "MaxAbsVz"; 797 case IceMassEnum : return "IceMass"; 630 798 case IceVolumeEnum : return "IceVolume"; 631 799 case IceVolumeAboveFloatationEnum : return "IceVolumeAboveFloatation"; … … 644 812 case SubelementMigration2Enum : return "SubelementMigration2"; 645 813 case ContactEnum : return "Contact"; 814 case GroundingOnlyEnum : return "GroundingOnly"; 646 815 case MaskGroundediceLevelsetEnum : return "MaskGroundediceLevelset"; 647 816 case GaussSegEnum : return "GaussSeg"; … … 666 835 case OldGradientEnum : return "OldGradient"; 667 836 case OutputFilePointerEnum : return "OutputFilePointer"; 837 case ToolkitsFileNameEnum : return "ToolkitsFileName"; 838 case RootPathEnum : return "RootPath"; 668 839 case OutputFileNameEnum : return "OutputFileName"; 840 case InputFileNameEnum : return "InputFileName"; 669 841 case LockFileNameEnum : return "LockFileName"; 670 842 case ToolkitsOptionsAnalysesEnum : return "ToolkitsOptionsAnalyses"; -
issm/trunk/src/c/shared/Enum/StringToEnumx.cpp
r18301 r19105 58 58 else if (strcmp(name,"Base")==0) return BaseEnum; 59 59 else if (strcmp(name,"ConstantsG")==0) return ConstantsGEnum; 60 else if (strcmp(name,"ConstantsOmega")==0) return ConstantsOmegaEnum; 60 61 else if (strcmp(name,"ConstantsReferencetemperature")==0) return ConstantsReferencetemperatureEnum; 61 62 else if (strcmp(name,"ConstantsYts")==0) return ConstantsYtsEnum; … … 95 96 else if (strcmp(name,"FlowequationFeFS")==0) return FlowequationFeFSEnum; 96 97 else if (strcmp(name,"FlowequationVertexEquation")==0) return FlowequationVertexEquationEnum; 98 else if (strcmp(name,"FrictionAs")==0) return FrictionAsEnum; 97 99 else if (strcmp(name,"FrictionCoefficient")==0) return FrictionCoefficientEnum; 98 100 else if (strcmp(name,"FrictionP")==0) return FrictionPEnum; … … 101 103 else if (strcmp(name,"FrictionC")==0) return FrictionCEnum; 102 104 else if (strcmp(name,"FrictionLaw")==0) return FrictionLawEnum; 105 else if (strcmp(name,"FrictionGamma")==0) return FrictionGammaEnum; 106 else if (strcmp(name,"FrictionWaterLayer")==0) return FrictionWaterLayerEnum; 107 else if (strcmp(name,"FrictionEffectivePressure")==0) return FrictionEffectivePressureEnum; 103 108 else if (strcmp(name,"GeometryHydrostaticRatio")==0) return GeometryHydrostaticRatioEnum; 104 109 else if (strcmp(name,"HydrologyModel")==0) return HydrologyModelEnum; … … 115 120 else if (strcmp(name,"EplHeadSlopeX")==0) return EplHeadSlopeXEnum; 116 121 else if (strcmp(name,"EplHeadSlopeY")==0) return EplHeadSlopeYEnum; 122 else if (strcmp(name,"EplZigZagCounter")==0) return EplZigZagCounterEnum; 117 123 else if (strcmp(name,"HydrologydcMaxIter")==0) return HydrologydcMaxIterEnum; 118 124 else if (strcmp(name,"HydrologydcRelTol")==0) return HydrologydcRelTolEnum; … … 129 135 else if (strcmp(name,"HydrologydcEplPorosity")==0) return HydrologydcEplPorosityEnum; 130 136 else if (strcmp(name,"HydrologydcEplInitialThickness")==0) return HydrologydcEplInitialThicknessEnum; 137 else if (strcmp(name,"HydrologydcEplColapseThickness")==0) return HydrologydcEplColapseThicknessEnum; 131 138 else if (strcmp(name,"HydrologydcEplMaxThickness")==0) return HydrologydcEplMaxThicknessEnum; 132 else if (strcmp(name,"HydrologydcEplThickness")==0) return HydrologydcEplThicknessEnum; 139 else stage=2; 140 } 141 if(stage==2){ 142 if (strcmp(name,"HydrologydcEplThickness")==0) return HydrologydcEplThicknessEnum; 133 143 else if (strcmp(name,"HydrologydcEplThicknessOld")==0) return HydrologydcEplThicknessOldEnum; 144 else if (strcmp(name,"HydrologydcEplThickComp")==0) return HydrologydcEplThickCompEnum; 134 145 else if (strcmp(name,"HydrologydcEplConductivity")==0) return HydrologydcEplConductivityEnum; 135 146 else if (strcmp(name,"HydrologydcIsefficientlayer")==0) return HydrologydcIsefficientlayerEnum; … … 137 148 else if (strcmp(name,"HydrologydcSedimentlimit")==0) return HydrologydcSedimentlimitEnum; 138 149 else if (strcmp(name,"HydrologydcTransferFlag")==0) return HydrologydcTransferFlagEnum; 139 else stage=2; 140 } 141 if(stage==2){ 142 if (strcmp(name,"HydrologydcLeakageFactor")==0) return HydrologydcLeakageFactorEnum; 150 else if (strcmp(name,"HydrologydcLeakageFactor")==0) return HydrologydcLeakageFactorEnum; 143 151 else if (strcmp(name,"HydrologydcPenaltyFactor")==0) return HydrologydcPenaltyFactorEnum; 144 152 else if (strcmp(name,"HydrologydcPenaltyLock")==0) return HydrologydcPenaltyLockEnum; 153 else if (strcmp(name,"HydrologydcEplflipLock")==0) return HydrologydcEplflipLockEnum; 145 154 else if (strcmp(name,"HydrologydcBasalMoulinInput")==0) return HydrologydcBasalMoulinInputEnum; 146 155 else if (strcmp(name,"HydrologyLayer")==0) return HydrologyLayerEnum; … … 150 159 else if (strcmp(name,"IndependentObject")==0) return IndependentObjectEnum; 151 160 else if (strcmp(name,"InversionControlParameters")==0) return InversionControlParametersEnum; 161 else if (strcmp(name,"InversionControlScalingFactors")==0) return InversionControlScalingFactorsEnum; 152 162 else if (strcmp(name,"InversionCostFunctionThreshold")==0) return InversionCostFunctionThresholdEnum; 153 163 else if (strcmp(name,"InversionCostFunctionsCoefficients")==0) return InversionCostFunctionsCoefficientsEnum; … … 174 184 else if (strcmp(name,"InversionStepThreshold")==0) return InversionStepThresholdEnum; 175 185 else if (strcmp(name,"InversionThicknessObs")==0) return InversionThicknessObsEnum; 186 else if (strcmp(name,"InversionSurfaceObs")==0) return InversionSurfaceObsEnum; 176 187 else if (strcmp(name,"InversionVxObs")==0) return InversionVxObsEnum; 177 188 else if (strcmp(name,"InversionVyObs")==0) return InversionVyObsEnum; … … 209 220 else if (strcmp(name,"DamageEvolutionNumRequestedOutputs")==0) return DamageEvolutionNumRequestedOutputsEnum; 210 221 else if (strcmp(name,"DamageEvolutionRequestedOutputs")==0) return DamageEvolutionRequestedOutputsEnum; 222 else if (strcmp(name,"Damage")==0) return DamageEnum; 211 223 else if (strcmp(name,"NewDamage")==0) return NewDamageEnum; 224 else if (strcmp(name,"StressIntensityFactor")==0) return StressIntensityFactorEnum; 225 else if (strcmp(name,"CalvingLaw")==0) return CalvingLawEnum; 226 else if (strcmp(name,"CalvingCalvingrate")==0) return CalvingCalvingrateEnum; 227 else if (strcmp(name,"CalvingMeltingrate")==0) return CalvingMeltingrateEnum; 228 else if (strcmp(name,"CalvingLevermann")==0) return CalvingLevermannEnum; 229 else if (strcmp(name,"CalvingPi")==0) return CalvingPiEnum; 230 else if (strcmp(name,"CalvingDev")==0) return CalvingDevEnum; 231 else if (strcmp(name,"DefaultCalving")==0) return DefaultCalvingEnum; 232 else if (strcmp(name,"CalvingRequestedOutputs")==0) return CalvingRequestedOutputsEnum; 233 else if (strcmp(name,"CalvinglevermannCoeff")==0) return CalvinglevermannCoeffEnum; 234 else if (strcmp(name,"CalvinglevermannMeltingrate")==0) return CalvinglevermannMeltingrateEnum; 235 else if (strcmp(name,"CalvingpiCoeff")==0) return CalvingpiCoeffEnum; 236 else if (strcmp(name,"CalvingpiMeltingrate")==0) return CalvingpiMeltingrateEnum; 237 else if (strcmp(name,"Calvingratex")==0) return CalvingratexEnum; 238 else if (strcmp(name,"Calvingratey")==0) return CalvingrateyEnum; 239 else if (strcmp(name,"CalvingratexAverage")==0) return CalvingratexAverageEnum; 240 else if (strcmp(name,"CalvingrateyAverage")==0) return CalvingrateyAverageEnum; 241 else if (strcmp(name,"StrainRateparallel")==0) return StrainRateparallelEnum; 242 else if (strcmp(name,"StrainRateperpendicular")==0) return StrainRateperpendicularEnum; 243 else if (strcmp(name,"StrainRateeffective")==0) return StrainRateeffectiveEnum; 212 244 else if (strcmp(name,"MaterialsRhoIce")==0) return MaterialsRhoIceEnum; 213 245 else if (strcmp(name,"MaterialsRhoSeawater")==0) return MaterialsRhoSeawaterEnum; … … 228 260 else if (strcmp(name,"MeshNumberofelements")==0) return MeshNumberofelementsEnum; 229 261 else if (strcmp(name,"MeshNumberoflayers")==0) return MeshNumberoflayersEnum; 230 else if (strcmp(name,"MeshNumberofvertices2d")==0) return MeshNumberofvertices2dEnum; 262 else stage=3; 263 } 264 if(stage==3){ 265 if (strcmp(name,"MeshNumberofvertices2d")==0) return MeshNumberofvertices2dEnum; 231 266 else if (strcmp(name,"MeshNumberofvertices")==0) return MeshNumberofverticesEnum; 232 267 else if (strcmp(name,"MeshUpperelements")==0) return MeshUpperelementsEnum; … … 249 284 else if (strcmp(name,"MasstransportPenaltyFactor")==0) return MasstransportPenaltyFactorEnum; 250 285 else if (strcmp(name,"MasstransportSpcthickness")==0) return MasstransportSpcthicknessEnum; 251 else if (strcmp(name,"MasstransportCalvingrate")==0) return MasstransportCalvingrateEnum;252 286 else if (strcmp(name,"MasstransportStabilization")==0) return MasstransportStabilizationEnum; 253 287 else if (strcmp(name,"MasstransportVertexPairing")==0) return MasstransportVertexPairingEnum; … … 260 294 else if (strcmp(name,"QmuNumberofpartitions")==0) return QmuNumberofpartitionsEnum; 261 295 else if (strcmp(name,"QmuNumberofresponses")==0) return QmuNumberofresponsesEnum; 262 else stage=3; 263 } 264 if(stage==3){ 265 if (strcmp(name,"QmuPartition")==0) return QmuPartitionEnum; 296 else if (strcmp(name,"QmuPartition")==0) return QmuPartitionEnum; 266 297 else if (strcmp(name,"QmuResponsedescriptors")==0) return QmuResponsedescriptorsEnum; 267 298 else if (strcmp(name,"QmuVariabledescriptors")==0) return QmuVariabledescriptorsEnum; … … 285 316 else if (strcmp(name,"ThermalIsenthalpy")==0) return ThermalIsenthalpyEnum; 286 317 else if (strcmp(name,"ThermalIsdynamicbasalspc")==0) return ThermalIsdynamicbasalspcEnum; 318 else if (strcmp(name,"ThermalReltol")==0) return ThermalReltolEnum; 287 319 else if (strcmp(name,"ThermalMaxiter")==0) return ThermalMaxiterEnum; 288 320 else if (strcmp(name,"ThermalPenaltyFactor")==0) return ThermalPenaltyFactorEnum; … … 309 341 else if (strcmp(name,"TransientIsdamageevolution")==0) return TransientIsdamageevolutionEnum; 310 342 else if (strcmp(name,"TransientIshydrology")==0) return TransientIshydrologyEnum; 343 else if (strcmp(name,"TransientIscalving")==0) return TransientIscalvingEnum; 311 344 else if (strcmp(name,"TransientNumRequestedOutputs")==0) return TransientNumRequestedOutputsEnum; 312 345 else if (strcmp(name,"TransientRequestedOutputs")==0) return TransientRequestedOutputsEnum; … … 315 348 else if (strcmp(name,"BalancethicknessApparentMassbalance")==0) return BalancethicknessApparentMassbalanceEnum; 316 349 else if (strcmp(name,"Balancethickness2Misfit")==0) return Balancethickness2MisfitEnum; 317 else if (strcmp(name,"BalancethicknessNux")==0) return BalancethicknessNuxEnum; 318 else if (strcmp(name,"BalancethicknessNuy")==0) return BalancethicknessNuyEnum; 319 else if (strcmp(name,"BalancethicknessVxObs")==0) return BalancethicknessVxObsEnum; 320 else if (strcmp(name,"BalancethicknessVyObs")==0) return BalancethicknessVyObsEnum; 321 else if (strcmp(name,"BalancethicknessThicknessObs")==0) return BalancethicknessThicknessObsEnum; 350 else if (strcmp(name,"BalancethicknessDiffusionCoefficient")==0) return BalancethicknessDiffusionCoefficientEnum; 351 else if (strcmp(name,"BalancethicknessCmu")==0) return BalancethicknessCmuEnum; 352 else if (strcmp(name,"BalancethicknessOmega")==0) return BalancethicknessOmegaEnum; 353 else if (strcmp(name,"BalancethicknessD0")==0) return BalancethicknessD0Enum; 322 354 else if (strcmp(name,"Surfaceforcings")==0) return SurfaceforcingsEnum; 323 355 else if (strcmp(name,"SMB")==0) return SMBEnum; … … 327 359 else if (strcmp(name,"SurfaceforcingsDelta18oSurface")==0) return SurfaceforcingsDelta18oSurfaceEnum; 328 360 else if (strcmp(name,"SurfaceforcingsIsdelta18o")==0) return SurfaceforcingsIsdelta18oEnum; 361 else if (strcmp(name,"SurfaceforcingsIsmungsm")==0) return SurfaceforcingsIsmungsmEnum; 329 362 else if (strcmp(name,"SurfaceforcingsPrecipitationsPresentday")==0) return SurfaceforcingsPrecipitationsPresentdayEnum; 363 else if (strcmp(name,"SurfaceforcingsPrecipitationsLgm")==0) return SurfaceforcingsPrecipitationsLgmEnum; 330 364 else if (strcmp(name,"SurfaceforcingsTemperaturesPresentday")==0) return SurfaceforcingsTemperaturesPresentdayEnum; 331 365 else if (strcmp(name,"SurfaceforcingsTemperaturesLgm")==0) return SurfaceforcingsTemperaturesLgmEnum; … … 333 367 else if (strcmp(name,"SurfaceforcingsDesfac")==0) return SurfaceforcingsDesfacEnum; 334 368 else if (strcmp(name,"SurfaceforcingsS0p")==0) return SurfaceforcingsS0pEnum; 369 else if (strcmp(name,"SurfaceforcingsS0t")==0) return SurfaceforcingsS0tEnum; 370 else if (strcmp(name,"SurfaceforcingsRlaps")==0) return SurfaceforcingsRlapsEnum; 371 else if (strcmp(name,"SurfaceforcingsRlapslgm")==0) return SurfaceforcingsRlapslgmEnum; 372 else if (strcmp(name,"SurfaceforcingsPfac")==0) return SurfaceforcingsPfacEnum; 373 else if (strcmp(name,"SurfaceforcingsTdiff")==0) return SurfaceforcingsTdiffEnum; 374 else if (strcmp(name,"SurfaceforcingsSealev")==0) return SurfaceforcingsSealevEnum; 335 375 else if (strcmp(name,"SMBgradients")==0) return SMBgradientsEnum; 336 376 else if (strcmp(name,"SurfaceforcingsMonthlytemperatures")==0) return SurfaceforcingsMonthlytemperaturesEnum; … … 343 383 else if (strcmp(name,"SurfaceforcingsAccumulation")==0) return SurfaceforcingsAccumulationEnum; 344 384 else if (strcmp(name,"SurfaceforcingsEvaporation")==0) return SurfaceforcingsEvaporationEnum; 345 else if (strcmp(name,"SurfaceforcingsRunoff")==0) return SurfaceforcingsRunoffEnum; 385 else stage=4; 386 } 387 if(stage==4){ 388 if (strcmp(name,"SurfaceforcingsRunoff")==0) return SurfaceforcingsRunoffEnum; 346 389 else if (strcmp(name,"SMBmeltcomponents")==0) return SMBmeltcomponentsEnum; 347 390 else if (strcmp(name,"SurfaceforcingsMelt")==0) return SurfaceforcingsMeltEnum; … … 383 426 else if (strcmp(name,"MeltingAnalysis")==0) return MeltingAnalysisEnum; 384 427 else if (strcmp(name,"MasstransportAnalysis")==0) return MasstransportAnalysisEnum; 385 else stage=4; 386 } 387 if(stage==4){ 388 if (strcmp(name,"MasstransportSolution")==0) return MasstransportSolutionEnum; 428 else if (strcmp(name,"MasstransportSolution")==0) return MasstransportSolutionEnum; 389 429 else if (strcmp(name,"FreeSurfaceBaseAnalysis")==0) return FreeSurfaceBaseAnalysisEnum; 390 430 else if (strcmp(name,"FreeSurfaceTopAnalysis")==0) return FreeSurfaceTopAnalysisEnum; … … 395 435 else if (strcmp(name,"SteadystateSolution")==0) return SteadystateSolutionEnum; 396 436 else if (strcmp(name,"SurfaceSlopeSolution")==0) return SurfaceSlopeSolutionEnum; 397 else if (strcmp(name,"SmoothedSurfaceSlopeXAnalysis")==0) return SmoothedSurfaceSlopeXAnalysisEnum; 398 else if (strcmp(name,"SmoothedSurfaceSlopeYAnalysis")==0) return SmoothedSurfaceSlopeYAnalysisEnum; 437 else if (strcmp(name,"SmoothAnalysis")==0) return SmoothAnalysisEnum; 399 438 else if (strcmp(name,"ThermalAnalysis")==0) return ThermalAnalysisEnum; 400 439 else if (strcmp(name,"ThermalSolution")==0) return ThermalSolutionEnum; … … 406 445 else if (strcmp(name,"MeshdeformationAnalysis")==0) return MeshdeformationAnalysisEnum; 407 446 else if (strcmp(name,"LevelsetAnalysis")==0) return LevelsetAnalysisEnum; 447 else if (strcmp(name,"LevelsetStabilization")==0) return LevelsetStabilizationEnum; 408 448 else if (strcmp(name,"ExtrapolationAnalysis")==0) return ExtrapolationAnalysisEnum; 409 449 else if (strcmp(name,"LsfReinitializationAnalysis")==0) return LsfReinitializationAnalysisEnum; … … 449 489 else if (strcmp(name,"InputToL2Project")==0) return InputToL2ProjectEnum; 450 490 else if (strcmp(name,"InputToDepthaverage")==0) return InputToDepthaverageEnum; 491 else if (strcmp(name,"InputToSmooth")==0) return InputToSmoothEnum; 492 else if (strcmp(name,"SmoothThicknessMultiplier")==0) return SmoothThicknessMultiplierEnum; 451 493 else if (strcmp(name,"IntParam")==0) return IntParamEnum; 452 494 else if (strcmp(name,"IntVecParam")==0) return IntVecParamEnum; … … 463 505 else if (strcmp(name,"Profiler")==0) return ProfilerEnum; 464 506 else if (strcmp(name,"MatrixParam")==0) return MatrixParamEnum; 507 else if (strcmp(name,"Masscon")==0) return MassconEnum; 508 else stage=5; 509 } 510 if(stage==5){ 511 if (strcmp(name,"MassconName")==0) return MassconNameEnum; 512 else if (strcmp(name,"MassconDefinitionenum")==0) return MassconDefinitionenumEnum; 513 else if (strcmp(name,"MassconLevelset")==0) return MassconLevelsetEnum; 514 else if (strcmp(name,"Massconaxpby")==0) return MassconaxpbyEnum; 515 else if (strcmp(name,"MassconaxpbyName")==0) return MassconaxpbyNameEnum; 516 else if (strcmp(name,"MassconaxpbyDefinitionenum")==0) return MassconaxpbyDefinitionenumEnum; 517 else if (strcmp(name,"MassconaxpbyNamex")==0) return MassconaxpbyNamexEnum; 518 else if (strcmp(name,"MassconaxpbyNamey")==0) return MassconaxpbyNameyEnum; 519 else if (strcmp(name,"MassconaxpbyAlpha")==0) return MassconaxpbyAlphaEnum; 520 else if (strcmp(name,"MassconaxpbyBeta")==0) return MassconaxpbyBetaEnum; 465 521 else if (strcmp(name,"NodeSId")==0) return NodeSIdEnum; 466 522 else if (strcmp(name,"VectorParam")==0) return VectorParamEnum; … … 506 562 else if (strcmp(name,"Internal")==0) return InternalEnum; 507 563 else if (strcmp(name,"MassFlux")==0) return MassFluxEnum; 508 else stage=5; 509 } 510 if(stage==5){ 511 if (strcmp(name,"MeltingOffset")==0) return MeltingOffsetEnum; 564 else if (strcmp(name,"MeltingOffset")==0) return MeltingOffsetEnum; 512 565 else if (strcmp(name,"Misfit")==0) return MisfitEnum; 513 566 else if (strcmp(name,"Pressure")==0) return PressureEnum; … … 527 580 else if (strcmp(name,"TemperaturePicard")==0) return TemperaturePicardEnum; 528 581 else if (strcmp(name,"ThicknessAbsMisfit")==0) return ThicknessAbsMisfitEnum; 582 else if (strcmp(name,"SurfaceAbsMisfit")==0) return SurfaceAbsMisfitEnum; 529 583 else if (strcmp(name,"Vel")==0) return VelEnum; 530 584 else if (strcmp(name,"Velocity")==0) return VelocityEnum; … … 550 604 else if (strcmp(name,"IntMatParam")==0) return IntMatParamEnum; 551 605 else if (strcmp(name,"RheologyBbarAbsGradient")==0) return RheologyBbarAbsGradientEnum; 606 else if (strcmp(name,"RheologyBAbsGradient")==0) return RheologyBAbsGradientEnum; 552 607 else if (strcmp(name,"DragCoefficientAbsGradient")==0) return DragCoefficientAbsGradientEnum; 553 608 else if (strcmp(name,"TransientInput")==0) return TransientInputEnum; … … 558 613 else if (strcmp(name,"HydrologyWaterVx")==0) return HydrologyWaterVxEnum; 559 614 else if (strcmp(name,"HydrologyWaterVy")==0) return HydrologyWaterVyEnum; 615 else if (strcmp(name,"DrivingStressX")==0) return DrivingStressXEnum; 616 else if (strcmp(name,"DrivingStressY")==0) return DrivingStressYEnum; 560 617 else if (strcmp(name,"SigmaNN")==0) return SigmaNNEnum; 561 618 else if (strcmp(name,"StressTensor")==0) return StressTensorEnum; … … 566 623 else if (strcmp(name,"StressTensoryz")==0) return StressTensoryzEnum; 567 624 else if (strcmp(name,"StressTensorzz")==0) return StressTensorzzEnum; 625 else if (strcmp(name,"StressMaxPrincipal")==0) return StressMaxPrincipalEnum; 568 626 else if (strcmp(name,"DeviatoricStress")==0) return DeviatoricStressEnum; 569 627 else if (strcmp(name,"DeviatoricStressxx")==0) return DeviatoricStressxxEnum; … … 571 629 else if (strcmp(name,"DeviatoricStressxz")==0) return DeviatoricStressxzEnum; 572 630 else if (strcmp(name,"DeviatoricStressyy")==0) return DeviatoricStressyyEnum; 573 else if (strcmp(name,"DeviatoricStressyz")==0) return DeviatoricStressyzEnum; 631 else stage=6; 632 } 633 if(stage==6){ 634 if (strcmp(name,"DeviatoricStressyz")==0) return DeviatoricStressyzEnum; 574 635 else if (strcmp(name,"DeviatoricStresszz")==0) return DeviatoricStresszzEnum; 575 636 else if (strcmp(name,"StrainRate")==0) return StrainRateEnum; … … 581 642 else if (strcmp(name,"StrainRatezz")==0) return StrainRatezzEnum; 582 643 else if (strcmp(name,"Divergence")==0) return DivergenceEnum; 644 else if (strcmp(name,"MaxDivergence")==0) return MaxDivergenceEnum; 583 645 else if (strcmp(name,"GiaCrossSectionShape")==0) return GiaCrossSectionShapeEnum; 584 646 else if (strcmp(name,"GiadWdt")==0) return GiadWdtEnum; … … 605 667 else if (strcmp(name,"OneLayerP4z")==0) return OneLayerP4zEnum; 606 668 else if (strcmp(name,"CrouzeixRaviart")==0) return CrouzeixRaviartEnum; 669 else if (strcmp(name,"LACrouzeixRaviart")==0) return LACrouzeixRaviartEnum; 607 670 else if (strcmp(name,"SaveResults")==0) return SaveResultsEnum; 608 671 else if (strcmp(name,"BoolExternalResult")==0) return BoolExternalResultEnum; … … 616 679 else if (strcmp(name,"WaterColumnOld")==0) return WaterColumnOldEnum; 617 680 else if (strcmp(name,"Outputdefinition")==0) return OutputdefinitionEnum; 681 else if (strcmp(name,"Outputdefinition1")==0) return Outputdefinition1Enum; 682 else if (strcmp(name,"Outputdefinition2")==0) return Outputdefinition2Enum; 683 else if (strcmp(name,"Outputdefinition3")==0) return Outputdefinition3Enum; 684 else if (strcmp(name,"Outputdefinition4")==0) return Outputdefinition4Enum; 685 else if (strcmp(name,"Outputdefinition5")==0) return Outputdefinition5Enum; 686 else if (strcmp(name,"Outputdefinition6")==0) return Outputdefinition6Enum; 687 else if (strcmp(name,"Outputdefinition7")==0) return Outputdefinition7Enum; 688 else if (strcmp(name,"Outputdefinition8")==0) return Outputdefinition8Enum; 689 else if (strcmp(name,"Outputdefinition9")==0) return Outputdefinition9Enum; 690 else if (strcmp(name,"Outputdefinition10")==0) return Outputdefinition10Enum; 691 else if (strcmp(name,"Outputdefinition11")==0) return Outputdefinition11Enum; 692 else if (strcmp(name,"Outputdefinition12")==0) return Outputdefinition12Enum; 693 else if (strcmp(name,"Outputdefinition13")==0) return Outputdefinition13Enum; 694 else if (strcmp(name,"Outputdefinition14")==0) return Outputdefinition14Enum; 695 else if (strcmp(name,"Outputdefinition15")==0) return Outputdefinition15Enum; 696 else if (strcmp(name,"Outputdefinition16")==0) return Outputdefinition16Enum; 697 else if (strcmp(name,"Outputdefinition17")==0) return Outputdefinition17Enum; 698 else if (strcmp(name,"Outputdefinition18")==0) return Outputdefinition18Enum; 699 else if (strcmp(name,"Outputdefinition19")==0) return Outputdefinition19Enum; 700 else if (strcmp(name,"Outputdefinition20")==0) return Outputdefinition20Enum; 701 else if (strcmp(name,"Outputdefinition21")==0) return Outputdefinition21Enum; 702 else if (strcmp(name,"Outputdefinition22")==0) return Outputdefinition22Enum; 703 else if (strcmp(name,"Outputdefinition23")==0) return Outputdefinition23Enum; 704 else if (strcmp(name,"Outputdefinition24")==0) return Outputdefinition24Enum; 705 else if (strcmp(name,"Outputdefinition25")==0) return Outputdefinition25Enum; 706 else if (strcmp(name,"Outputdefinition26")==0) return Outputdefinition26Enum; 707 else if (strcmp(name,"Outputdefinition27")==0) return Outputdefinition27Enum; 708 else if (strcmp(name,"Outputdefinition28")==0) return Outputdefinition28Enum; 709 else if (strcmp(name,"Outputdefinition29")==0) return Outputdefinition29Enum; 710 else if (strcmp(name,"Outputdefinition30")==0) return Outputdefinition30Enum; 711 else if (strcmp(name,"Outputdefinition31")==0) return Outputdefinition31Enum; 712 else if (strcmp(name,"Outputdefinition32")==0) return Outputdefinition32Enum; 713 else if (strcmp(name,"Outputdefinition33")==0) return Outputdefinition33Enum; 714 else if (strcmp(name,"Outputdefinition34")==0) return Outputdefinition34Enum; 715 else if (strcmp(name,"Outputdefinition35")==0) return Outputdefinition35Enum; 716 else if (strcmp(name,"Outputdefinition36")==0) return Outputdefinition36Enum; 717 else if (strcmp(name,"Outputdefinition37")==0) return Outputdefinition37Enum; 718 else if (strcmp(name,"Outputdefinition38")==0) return Outputdefinition38Enum; 719 else if (strcmp(name,"Outputdefinition39")==0) return Outputdefinition39Enum; 720 else if (strcmp(name,"Outputdefinition40")==0) return Outputdefinition40Enum; 721 else if (strcmp(name,"Outputdefinition41")==0) return Outputdefinition41Enum; 722 else if (strcmp(name,"Outputdefinition42")==0) return Outputdefinition42Enum; 723 else if (strcmp(name,"Outputdefinition43")==0) return Outputdefinition43Enum; 724 else if (strcmp(name,"Outputdefinition44")==0) return Outputdefinition44Enum; 725 else if (strcmp(name,"Outputdefinition45")==0) return Outputdefinition45Enum; 726 else if (strcmp(name,"Outputdefinition46")==0) return Outputdefinition46Enum; 727 else if (strcmp(name,"Outputdefinition47")==0) return Outputdefinition47Enum; 728 else if (strcmp(name,"Outputdefinition48")==0) return Outputdefinition48Enum; 729 else if (strcmp(name,"Outputdefinition49")==0) return Outputdefinition49Enum; 730 else if (strcmp(name,"Outputdefinition50")==0) return Outputdefinition50Enum; 731 else if (strcmp(name,"Outputdefinition51")==0) return Outputdefinition51Enum; 732 else if (strcmp(name,"Outputdefinition52")==0) return Outputdefinition52Enum; 733 else if (strcmp(name,"Outputdefinition53")==0) return Outputdefinition53Enum; 734 else if (strcmp(name,"Outputdefinition54")==0) return Outputdefinition54Enum; 735 else if (strcmp(name,"Outputdefinition55")==0) return Outputdefinition55Enum; 736 else if (strcmp(name,"Outputdefinition56")==0) return Outputdefinition56Enum; 737 else if (strcmp(name,"Outputdefinition57")==0) return Outputdefinition57Enum; 738 else if (strcmp(name,"Outputdefinition58")==0) return Outputdefinition58Enum; 739 else if (strcmp(name,"Outputdefinition59")==0) return Outputdefinition59Enum; 740 else if (strcmp(name,"Outputdefinition60")==0) return Outputdefinition60Enum; 741 else if (strcmp(name,"Outputdefinition61")==0) return Outputdefinition61Enum; 742 else if (strcmp(name,"Outputdefinition62")==0) return Outputdefinition62Enum; 743 else if (strcmp(name,"Outputdefinition63")==0) return Outputdefinition63Enum; 744 else if (strcmp(name,"Outputdefinition64")==0) return Outputdefinition64Enum; 745 else if (strcmp(name,"Outputdefinition65")==0) return Outputdefinition65Enum; 746 else if (strcmp(name,"Outputdefinition66")==0) return Outputdefinition66Enum; 747 else if (strcmp(name,"Outputdefinition67")==0) return Outputdefinition67Enum; 748 else if (strcmp(name,"Outputdefinition68")==0) return Outputdefinition68Enum; 749 else if (strcmp(name,"Outputdefinition69")==0) return Outputdefinition69Enum; 750 else if (strcmp(name,"Outputdefinition70")==0) return Outputdefinition70Enum; 751 else if (strcmp(name,"Outputdefinition71")==0) return Outputdefinition71Enum; 752 else if (strcmp(name,"Outputdefinition72")==0) return Outputdefinition72Enum; 753 else if (strcmp(name,"Outputdefinition73")==0) return Outputdefinition73Enum; 754 else stage=7; 755 } 756 if(stage==7){ 757 if (strcmp(name,"Outputdefinition74")==0) return Outputdefinition74Enum; 758 else if (strcmp(name,"Outputdefinition75")==0) return Outputdefinition75Enum; 759 else if (strcmp(name,"Outputdefinition76")==0) return Outputdefinition76Enum; 760 else if (strcmp(name,"Outputdefinition77")==0) return Outputdefinition77Enum; 761 else if (strcmp(name,"Outputdefinition78")==0) return Outputdefinition78Enum; 762 else if (strcmp(name,"Outputdefinition79")==0) return Outputdefinition79Enum; 763 else if (strcmp(name,"Outputdefinition80")==0) return Outputdefinition80Enum; 764 else if (strcmp(name,"Outputdefinition81")==0) return Outputdefinition81Enum; 765 else if (strcmp(name,"Outputdefinition82")==0) return Outputdefinition82Enum; 766 else if (strcmp(name,"Outputdefinition83")==0) return Outputdefinition83Enum; 767 else if (strcmp(name,"Outputdefinition84")==0) return Outputdefinition84Enum; 768 else if (strcmp(name,"Outputdefinition85")==0) return Outputdefinition85Enum; 769 else if (strcmp(name,"Outputdefinition86")==0) return Outputdefinition86Enum; 770 else if (strcmp(name,"Outputdefinition87")==0) return Outputdefinition87Enum; 771 else if (strcmp(name,"Outputdefinition88")==0) return Outputdefinition88Enum; 772 else if (strcmp(name,"Outputdefinition89")==0) return Outputdefinition89Enum; 773 else if (strcmp(name,"Outputdefinition90")==0) return Outputdefinition90Enum; 774 else if (strcmp(name,"Outputdefinition91")==0) return Outputdefinition91Enum; 775 else if (strcmp(name,"Outputdefinition92")==0) return Outputdefinition92Enum; 776 else if (strcmp(name,"Outputdefinition93")==0) return Outputdefinition93Enum; 777 else if (strcmp(name,"Outputdefinition94")==0) return Outputdefinition94Enum; 778 else if (strcmp(name,"Outputdefinition95")==0) return Outputdefinition95Enum; 779 else if (strcmp(name,"Outputdefinition96")==0) return Outputdefinition96Enum; 780 else if (strcmp(name,"Outputdefinition97")==0) return Outputdefinition97Enum; 781 else if (strcmp(name,"Outputdefinition98")==0) return Outputdefinition98Enum; 782 else if (strcmp(name,"Outputdefinition99")==0) return Outputdefinition99Enum; 783 else if (strcmp(name,"Outputdefinition100")==0) return Outputdefinition100Enum; 618 784 else if (strcmp(name,"OutputdefinitionList")==0) return OutputdefinitionListEnum; 619 785 else if (strcmp(name,"Massfluxatgate")==0) return MassfluxatgateEnum; 620 786 else if (strcmp(name,"MassfluxatgateName")==0) return MassfluxatgateNameEnum; 787 else if (strcmp(name,"MassfluxatgateDefinitionenum")==0) return MassfluxatgateDefinitionenumEnum; 621 788 else if (strcmp(name,"MassfluxatgateSegments")==0) return MassfluxatgateSegmentsEnum; 622 789 else if (strcmp(name,"MisfitName")==0) return MisfitNameEnum; 790 else if (strcmp(name,"MisfitDefinitionenum")==0) return MisfitDefinitionenumEnum; 623 791 else if (strcmp(name,"MisfitModelEnum")==0) return MisfitModelEnumEnum; 624 792 else if (strcmp(name,"MisfitObservation")==0) return MisfitObservationEnum; 625 793 else if (strcmp(name,"MisfitObservationEnum")==0) return MisfitObservationEnumEnum; 794 else if (strcmp(name,"MisfitLocal")==0) return MisfitLocalEnum; 626 795 else if (strcmp(name,"MisfitTimeinterpolation")==0) return MisfitTimeinterpolationEnum; 627 796 else if (strcmp(name,"MisfitWeights")==0) return MisfitWeightsEnum; … … 629 798 else if (strcmp(name,"SurfaceObservation")==0) return SurfaceObservationEnum; 630 799 else if (strcmp(name,"WeightsSurfaceObservation")==0) return WeightsSurfaceObservationEnum; 631 else stage=6; 632 } 633 if(stage==6){ 634 if (strcmp(name,"MinVel")==0) return MinVelEnum; 800 else if (strcmp(name,"VxObs")==0) return VxObsEnum; 801 else if (strcmp(name,"WeightsVxObs")==0) return WeightsVxObsEnum; 802 else if (strcmp(name,"VyObs")==0) return VyObsEnum; 803 else if (strcmp(name,"WeightsVyObs")==0) return WeightsVyObsEnum; 804 else if (strcmp(name,"MinVel")==0) return MinVelEnum; 635 805 else if (strcmp(name,"MaxVel")==0) return MaxVelEnum; 636 806 else if (strcmp(name,"MinVx")==0) return MinVxEnum; … … 643 813 else if (strcmp(name,"MaxVz")==0) return MaxVzEnum; 644 814 else if (strcmp(name,"MaxAbsVz")==0) return MaxAbsVzEnum; 815 else if (strcmp(name,"IceMass")==0) return IceMassEnum; 645 816 else if (strcmp(name,"IceVolume")==0) return IceVolumeEnum; 646 817 else if (strcmp(name,"IceVolumeAboveFloatation")==0) return IceVolumeAboveFloatationEnum; … … 659 830 else if (strcmp(name,"SubelementMigration2")==0) return SubelementMigration2Enum; 660 831 else if (strcmp(name,"Contact")==0) return ContactEnum; 832 else if (strcmp(name,"GroundingOnly")==0) return GroundingOnlyEnum; 661 833 else if (strcmp(name,"MaskGroundediceLevelset")==0) return MaskGroundediceLevelsetEnum; 662 834 else if (strcmp(name,"GaussSeg")==0) return GaussSegEnum; … … 681 853 else if (strcmp(name,"OldGradient")==0) return OldGradientEnum; 682 854 else if (strcmp(name,"OutputFilePointer")==0) return OutputFilePointerEnum; 855 else if (strcmp(name,"ToolkitsFileName")==0) return ToolkitsFileNameEnum; 856 else if (strcmp(name,"RootPath")==0) return RootPathEnum; 683 857 else if (strcmp(name,"OutputFileName")==0) return OutputFileNameEnum; 858 else if (strcmp(name,"InputFileName")==0) return InputFileNameEnum; 684 859 else if (strcmp(name,"LockFileName")==0) return LockFileNameEnum; 685 860 else if (strcmp(name,"ToolkitsOptionsAnalyses")==0) return ToolkitsOptionsAnalysesEnum; … … 700 875 else if (strcmp(name,"Dense")==0) return DenseEnum; 701 876 else if (strcmp(name,"MpiDense")==0) return MpiDenseEnum; 702 else if (strcmp(name,"MpiSparse")==0) return MpiSparseEnum; 877 else stage=8; 878 } 879 if(stage==8){ 880 if (strcmp(name,"MpiSparse")==0) return MpiSparseEnum; 703 881 else if (strcmp(name,"Seq")==0) return SeqEnum; 704 882 else if (strcmp(name,"Mpi")==0) return MpiEnum; … … 720 898 else if (strcmp(name,"LevelsetfunctionPicard")==0) return LevelsetfunctionPicardEnum; 721 899 else if (strcmp(name,"MaximumNumberOfDefinitions")==0) return MaximumNumberOfDefinitionsEnum; 722 else stage= 7;900 else stage=9; 723 901 } 724 902 /*If we reach this point, the string provided has not been found*/ -
issm/trunk/src/c/shared/Enum/Synchronize.sh
r17989 r19105 74 74 if test \"x$" toupper($1)"\" = \"xyes\"; then\n\ 75 75 HAVE_" toupper($1)"=yes\n\ 76 AC_DEFINE([_HAVE_" toupper($1)"_],[1],[with " $1" capability])\n\76 AC_DEFINE([_HAVE_" toupper($1)"_],[1],[with " $1" capability])\n\ 77 77 fi\n\ 78 78 AM_CONDITIONAL([" toupper($1)"], [test x$HAVE_" toupper($1)" = xyes])\n\ -
issm/trunk/src/c/shared/FSanalyticals/fsanalyticals.cpp
r18301 r19105 51 51 z=y; 52 52 return 32.0/5.0*pow(PI, 2)*sin(8*PI*z); 53 case 13: 54 z=y; 55 return 8.0*pow(PI, 2)*pow(x, 2)*(z - 2)*sin(4*PI*x*z) - 4.0*PI*x*cos(4*PI*x*z) + 16.0*pow(PI, 2)*pow(z, 2)*(z - 2)*sin(4*PI*x*z) - 0.25*PI*((16*pow(PI, 2)*x*z*(PI*x*z - PI*x)*cos(4*PI*x*z) + 4*pow(PI, 2)*x*z*(8*pow(PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(PI, 2)*pow(x, 2)*z - 1)*sin(4*PI*x*z) + 4*pow(PI, 2)*x*z*sin(4*PI*x*z) - 4*PI*x*(-PI*z + PI)*sin(4*PI*x*z) - 16*PI*x*(pow(PI, 2)*x*pow(z, 2) - 2*pow(PI, 2)*x*z)*cos(4*PI*x*z) - 16*PI*z*(pow(PI, 2)*pow(x, 2)*z - pow(PI, 2)*pow(x, 2))*cos(4*PI*x*z) + 4*PI*(PI*x*z - PI*x)*sin(4*PI*x*z) - 8*(pow(PI, 2)*x*z - pow(PI, 2)*x)*sin(4*PI*x*z) - PI*(8*pow(PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(PI, 2)*pow(x, 2)*z - 1)*cos(4*PI*x*z) - PI*cos(4*PI*x*z))/(pow(PI, 3)*pow(x, 3)) + 3*(-4*PI*x*(PI*x*z - PI*x)*sin(4*PI*x*z) + PI*x*(8*pow(PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(PI, 2)*pow(x, 2)*z - 1)*cos(4*PI*x*z) + PI*x*cos(4*PI*x*z) + 4*(pow(PI, 2)*pow(x, 2)*z - pow(PI, 2)*pow(x, 2))*sin(4*PI*x*z))/(pow(PI, 3)*pow(x, 4))) + 4*PI*sin(4*PI*z)*cos(4*PI*x); 56 case 14: 57 z=y; 58 return 8.0*pow(2, 1.0L/3.0L)*pow(M_PI, 2)*pow(z, 2)*(z - 2)*sin(4*M_PI*x*z)/pow(4.0*pow(M_PI, 2)*pow(z, 2)*pow(z - 2, 2)*pow(cos(4*M_PI*x*z), 2) + (1.0L/2.0L)*pow(2.0*M_PI*x*(z - 2)*cos(4*M_PI*x*z) - 0.0625*M_PI*(16*sin(4*M_PI*x)/(M_PI*pow(x, 2)) + 4*(8*pow(M_PI, 2)*pow(x, 2) + 1)*cos(4*M_PI*x)/(pow(M_PI, 2)*pow(x, 3)) + 4*(-4*M_PI*z*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) + M_PI*z*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - (-M_PI*z + M_PI)*cos(4*M_PI*x*z) + 4*(pow(M_PI, 2)*x*pow(z, 2) - 2*pow(M_PI, 2)*x*z)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 3)) - 3*(8*pow(M_PI, 2)*pow(x, 2) + 1)*sin(4*M_PI*x)/(pow(M_PI, 3)*pow(x, 4)) - 3*(4*(M_PI*x*z - M_PI*x)*cos(4*M_PI*x*z) + (8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 4))) + 0.5*sin(4*M_PI*x*z) + (2.0L/5.0L)*M_PI*cos(4*M_PI*x), 2) + pow(M_PI*x*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) - 0.25*M_PI*x*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - 0.25*M_PI*x*cos(4*M_PI*x*z) - (pow(M_PI, 2)*pow(x, 2)*z - pow(M_PI, 2)*pow(x, 2))*sin(4*M_PI*x*z), 2)/(pow(M_PI, 4)*pow(x, 6)), 1.0L/3.0L) - 0.0266666666666667*pow(2, 1.0L/3.0L)*M_PI*z*(z - 2)*(800.0*pow(M_PI, 3)*pow(z, 3)*pow(z - 2, 2)*sin(4*M_PI*x*z)*cos(4*M_PI*x*z) - (-10.0*M_PI*x*(z - 2)*cos(4*M_PI*x*z) + 0.3125*M_PI*(16*sin(4*M_PI*x)/(M_PI*pow(x, 2)) + 4*(8*pow(M_PI, 2)*pow(x, 2) + 1)*cos(4*M_PI*x)/(pow(M_PI, 2)*pow(x, 3)) + 4*(-4*M_PI*z*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) + M_PI*z*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - (-M_PI*z + M_PI)*cos(4*M_PI*x*z) + 4*(pow(M_PI, 2)*x*pow(z, 2) - 2*pow(M_PI, 2)*x*z)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 3)) - 3*(8*pow(M_PI, 2)*pow(x, 2) + 1)*sin(4*M_PI*x)/(pow(M_PI, 3)*pow(x, 4)) - 3*(4*(M_PI*x*z - M_PI*x)*cos(4*M_PI*x*z) + (8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 4))) - 2.5*sin(4*M_PI*x*z) - 2*M_PI*cos(4*M_PI*x))*(40.0*pow(M_PI, 2)*x*z*(z - 2)*sin(4*M_PI*x*z) - 10.0*M_PI*z*cos(4*M_PI*x*z) - 10.0*M_PI*(z - 2)*cos(4*M_PI*x*z) + 1.25*M_PI*(32*cos(4*M_PI*x)/pow(x, 2) - 4*(8*pow(M_PI, 2)*pow(x, 2) + 1)*sin(4*M_PI*x)/(M_PI*pow(x, 3)) - 4*(4*pow(M_PI, 2)*pow(z, 2)*(M_PI*x*z - M_PI*x)*cos(4*M_PI*x*z) + pow(M_PI, 2)*pow(z, 2)*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*sin(4*M_PI*x*z) - 2*M_PI*z*(-M_PI*z + M_PI)*sin(4*M_PI*x*z) - 8*M_PI*z*(pow(M_PI, 2)*x*pow(z, 2) - 2*pow(M_PI, 2)*x*z)*cos(4*M_PI*x*z) - (pow(M_PI, 2)*pow(z, 2) - 2*pow(M_PI, 2)*z)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 3)) - 20*sin(4*M_PI*x)/(M_PI*pow(x, 3)) - 6*(8*pow(M_PI, 2)*pow(x, 2) + 1)*cos(4*M_PI*x)/(pow(M_PI, 2)*pow(x, 4)) - 6*(-4*M_PI*z*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) + M_PI*z*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - (-M_PI*z + M_PI)*cos(4*M_PI*x*z) + 4*(pow(M_PI, 2)*x*pow(z, 2) - 2*pow(M_PI, 2)*x*z)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 4)) + 3*(8*pow(M_PI, 2)*pow(x, 2) + 1)*sin(4*M_PI*x)/(pow(M_PI, 3)*pow(x, 5)) + 3*(4*(M_PI*x*z - M_PI*x)*cos(4*M_PI*x*z) + (8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 5))) + 8*pow(M_PI, 2)*sin(4*M_PI*x)) - (50*M_PI*x*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) - 12.5*M_PI*x*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - 12.5*M_PI*x*cos(4*M_PI*x*z) - 50*(pow(M_PI, 2)*pow(x, 2)*z - pow(M_PI, 2)*pow(x, 2))*sin(4*M_PI*x*z))*(4*pow(M_PI, 2)*x*z*(M_PI*x*z - M_PI*x)*cos(4*M_PI*x*z) + pow(M_PI, 2)*x*z*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*sin(4*M_PI*x*z) + pow(M_PI, 2)*x*z*sin(4*M_PI*x*z) - M_PI*x*(-M_PI*z + M_PI)*sin(4*M_PI*x*z) - 4.0*M_PI*x*(pow(M_PI, 2)*x*pow(z, 2) - 2*pow(M_PI, 2)*x*z)*cos(4*M_PI*x*z) - 4*M_PI*z*(pow(M_PI, 2)*pow(x, 2)*z - pow(M_PI, 2)*pow(x, 2))*cos(4*M_PI*x*z) + M_PI*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) - 2*(pow(M_PI, 2)*x*z - pow(M_PI, 2)*x)*sin(4*M_PI*x*z) - 0.25*M_PI*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - 0.25*M_PI*cos(4*M_PI*x*z))/(pow(M_PI, 4)*pow(x, 6)) + 150*pow(M_PI*x*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) - 0.25*M_PI*x*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - 0.25*M_PI*x*cos(4*M_PI*x*z) - (pow(M_PI, 2)*pow(x, 2)*z - pow(M_PI, 2)*pow(x, 2))*sin(4*M_PI*x*z), 2)/(pow(M_PI, 4)*pow(x, 7)))*cos(4*M_PI*x*z)/pow(4.0*pow(M_PI, 2)*pow(z, 2)*pow(z - 2, 2)*pow(cos(4*M_PI*x*z), 2) + (1.0L/2.0L)*pow(2.0*M_PI*x*(z - 2)*cos(4*M_PI*x*z) - 0.0625*M_PI*(16*sin(4*M_PI*x)/(M_PI*pow(x, 2)) + 4*(8*pow(M_PI, 2)*pow(x, 2) + 1)*cos(4*M_PI*x)/(pow(M_PI, 2)*pow(x, 3)) + 4*(-4*M_PI*z*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) + M_PI*z*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - (-M_PI*z + M_PI)*cos(4*M_PI*x*z) + 4*(pow(M_PI, 2)*x*pow(z, 2) - 2*pow(M_PI, 2)*x*z)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 3)) - 3*(8*pow(M_PI, 2)*pow(x, 2) + 1)*sin(4*M_PI*x)/(pow(M_PI, 3)*pow(x, 4)) - 3*(4*(M_PI*x*z - M_PI*x)*cos(4*M_PI*x*z) + (8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 4))) + 0.5*sin(4*M_PI*x*z) + (2.0L/5.0L)*M_PI*cos(4*M_PI*x), 2) + pow(M_PI*x*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) - 0.25*M_PI*x*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - 0.25*M_PI*x*cos(4*M_PI*x*z) - (pow(M_PI, 2)*pow(x, 2)*z - pow(M_PI, 2)*pow(x, 2))*sin(4*M_PI*x*z), 2)/(pow(M_PI, 4)*pow(x, 6)), 4.0L/3.0L) + (1.0L/10.0L)*pow(2, 1.0L/3.0L)*(40.0*pow(M_PI, 2)*pow(x, 2)*(z - 2)*sin(4*M_PI*x*z) - 20.0*M_PI*x*cos(4*M_PI*x*z) - 1.25*M_PI*((16*pow(M_PI, 2)*x*z*(M_PI*x*z - M_PI*x)*cos(4*M_PI*x*z) + 4*pow(M_PI, 2)*x*z*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*sin(4*M_PI*x*z) + 4*pow(M_PI, 2)*x*z*sin(4*M_PI*x*z) - 4*M_PI*x*(-M_PI*z + M_PI)*sin(4*M_PI*x*z) - 16*M_PI*x*(pow(M_PI, 2)*x*pow(z, 2) - 2*pow(M_PI, 2)*x*z)*cos(4*M_PI*x*z) - 16*M_PI*z*(pow(M_PI, 2)*pow(x, 2)*z - pow(M_PI, 2)*pow(x, 2))*cos(4*M_PI*x*z) + 4*M_PI*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) - 8*(pow(M_PI, 2)*x*z - pow(M_PI, 2)*x)*sin(4*M_PI*x*z) - M_PI*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - M_PI*cos(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 3)) + 3*(-4*M_PI*x*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) + M_PI*x*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) + M_PI*x*cos(4*M_PI*x*z) + 4*(pow(M_PI, 2)*pow(x, 2)*z - pow(M_PI, 2)*pow(x, 2))*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 4))))/pow(4.0*pow(M_PI, 2)*pow(z, 2)*pow(z - 2, 2)*pow(cos(4*M_PI*x*z), 2) + (1.0L/2.0L)*pow(2.0*M_PI*x*(z - 2)*cos(4*M_PI*x*z) - 0.0625*M_PI*(16*sin(4*M_PI*x)/(M_PI*pow(x, 2)) + 4*(8*pow(M_PI, 2)*pow(x, 2) + 1)*cos(4*M_PI*x)/(pow(M_PI, 2)*pow(x, 3)) + 4*(-4*M_PI*z*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) + M_PI*z*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - (-M_PI*z + M_PI)*cos(4*M_PI*x*z) + 4*(pow(M_PI, 2)*x*pow(z, 2) - 2*pow(M_PI, 2)*x*z)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 3)) - 3*(8*pow(M_PI, 2)*pow(x, 2) + 1)*sin(4*M_PI*x)/(pow(M_PI, 3)*pow(x, 4)) - 3*(4*(M_PI*x*z - M_PI*x)*cos(4*M_PI*x*z) + (8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 4))) + 0.5*sin(4*M_PI*x*z) + (2.0L/5.0L)*M_PI*cos(4*M_PI*x), 2) + pow(M_PI*x*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) - 0.25*M_PI*x*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - 0.25*M_PI*x*cos(4*M_PI*x*z) - (pow(M_PI, 2)*pow(x, 2)*z - pow(M_PI, 2)*pow(x, 2))*sin(4*M_PI*x*z), 2)/(pow(M_PI, 4)*pow(x, 6)), 1.0L/3.0L) + 4*M_PI*sin(4*M_PI*z)*cos(4*M_PI*x) + (1.0L/150.0L)*pow(2, 1.0L/3.0L)*(-10.0*M_PI*x*(z - 2)*cos(4*M_PI*x*z) + 0.3125*M_PI*(16*sin(4*M_PI*x)/(M_PI*pow(x, 2)) + 4*(8*pow(M_PI, 2)*pow(x, 2) + 1)*cos(4*M_PI*x)/(pow(M_PI, 2)*pow(x, 3)) + 4*(-4*M_PI*z*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) + M_PI*z*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - (-M_PI*z + M_PI)*cos(4*M_PI*x*z) + 4*(pow(M_PI, 2)*x*pow(z, 2) - 2*pow(M_PI, 2)*x*z)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 3)) - 3*(8*pow(M_PI, 2)*pow(x, 2) + 1)*sin(4*M_PI*x)/(pow(M_PI, 3)*pow(x, 4)) - 3*(4*(M_PI*x*z - M_PI*x)*cos(4*M_PI*x*z) + (8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 4))) - 2.5*sin(4*M_PI*x*z) - 2*M_PI*cos(4*M_PI*x))*(160.0*pow(M_PI, 3)*x*pow(z, 2)*pow(z - 2, 2)*sin(4*M_PI*x*z)*cos(4*M_PI*x*z) - 40.0*pow(M_PI, 2)*pow(z, 2)*(z - 2)*pow(cos(4*M_PI*x*z), 2) - 40.0*pow(M_PI, 2)*z*pow(z - 2, 2)*pow(cos(4*M_PI*x*z), 2) + (-8.0*pow(M_PI, 2)*pow(x, 2)*(z - 2)*sin(4*M_PI*x*z) + 4.0*M_PI*x*cos(4*M_PI*x*z) + 0.25*M_PI*((16*pow(M_PI, 2)*x*z*(M_PI*x*z - M_PI*x)*cos(4*M_PI*x*z) + 4*pow(M_PI, 2)*x*z*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*sin(4*M_PI*x*z) + 4*pow(M_PI, 2)*x*z*sin(4*M_PI*x*z) - 4*M_PI*x*(-M_PI*z + M_PI)*sin(4*M_PI*x*z) - 16*M_PI*x*(pow(M_PI, 2)*x*pow(z, 2) - 2*pow(M_PI, 2)*x*z)*cos(4*M_PI*x*z) - 16*M_PI*z*(pow(M_PI, 2)*pow(x, 2)*z - pow(M_PI, 2)*pow(x, 2))*cos(4*M_PI*x*z) + 4*M_PI*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) - 8*(pow(M_PI, 2)*x*z - pow(M_PI, 2)*x)*sin(4*M_PI*x*z) - M_PI*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - M_PI*cos(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 3)) + 3*(-4*M_PI*x*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) + M_PI*x*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) + M_PI*x*cos(4*M_PI*x*z) + 4*(pow(M_PI, 2)*pow(x, 2)*z - pow(M_PI, 2)*pow(x, 2))*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 4))))*(-10.0*M_PI*x*(z - 2)*cos(4*M_PI*x*z) + 0.3125*M_PI*(16*sin(4*M_PI*x)/(M_PI*pow(x, 2)) + 4*(8*pow(M_PI, 2)*pow(x, 2) + 1)*cos(4*M_PI*x)/(pow(M_PI, 2)*pow(x, 3)) + 4*(-4*M_PI*z*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) + M_PI*z*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - (-M_PI*z + M_PI)*cos(4*M_PI*x*z) + 4*(pow(M_PI, 2)*x*pow(z, 2) - 2*pow(M_PI, 2)*x*z)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 3)) - 3*(8*pow(M_PI, 2)*pow(x, 2) + 1)*sin(4*M_PI*x)/(pow(M_PI, 3)*pow(x, 4)) - 3*(4*(M_PI*x*z - M_PI*x)*cos(4*M_PI*x*z) + (8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 4))) - 2.5*sin(4*M_PI*x*z) - 2*M_PI*cos(4*M_PI*x)) - (10*M_PI*x*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) - 2.5*M_PI*x*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - 2.5*M_PI*x*cos(4*M_PI*x*z) - 10*(pow(M_PI, 2)*pow(x, 2)*z - pow(M_PI, 2)*pow(x, 2))*sin(4*M_PI*x*z))*(4*pow(M_PI, 2)*pow(x, 2)*(M_PI*x*z - M_PI*x)*cos(4*M_PI*x*z) + pow(M_PI, 2)*pow(x, 2)*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*sin(4*M_PI*x*z) + pow(M_PI, 2)*pow(x, 2)*sin(4*M_PI*x*z) - 8.0*M_PI*x*(pow(M_PI, 2)*pow(x, 2)*z - pow(M_PI, 2)*pow(x, 2))*cos(4*M_PI*x*z))/(pow(M_PI, 4)*pow(x, 6)))/pow(4.0*pow(M_PI, 2)*pow(z, 2)*pow(z - 2, 2)*pow(cos(4*M_PI*x*z), 2) + (1.0L/2.0L)*pow(2.0*M_PI*x*(z - 2)*cos(4*M_PI*x*z) - 0.0625*M_PI*(16*sin(4*M_PI*x)/(M_PI*pow(x, 2)) + 4*(8*pow(M_PI, 2)*pow(x, 2) + 1)*cos(4*M_PI*x)/(pow(M_PI, 2)*pow(x, 3)) + 4*(-4*M_PI*z*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) + M_PI*z*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - (-M_PI*z + M_PI)*cos(4*M_PI*x*z) + 4*(pow(M_PI, 2)*x*pow(z, 2) - 2*pow(M_PI, 2)*x*z)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 3)) - 3*(8*pow(M_PI, 2)*pow(x, 2) + 1)*sin(4*M_PI*x)/(pow(M_PI, 3)*pow(x, 4)) - 3*(4*(M_PI*x*z - M_PI*x)*cos(4*M_PI*x*z) + (8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 4))) + 0.5*sin(4*M_PI*x*z) + (2.0L/5.0L)*M_PI*cos(4*M_PI*x), 2) + pow(M_PI*x*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) - 0.25*M_PI*x*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - 0.25*M_PI*x*cos(4*M_PI*x*z) - (pow(M_PI, 2)*pow(x, 2)*z - pow(M_PI, 2)*pow(x, 2))*sin(4*M_PI*x*z), 2)/(pow(M_PI, 4)*pow(x, 6)), 4.0L/3.0L); 53 59 case 21: 54 60 z=y; 55 return z - 4.0L/3.0L*pow(2, 1.0L/3.0L)*(pow(x, 2)*z*(x - 1)*(z - 1)*(2*z - 1) + x*z*pow(x - 1, 2)*(z - 1)*(2*z - 1))*(4*(pow(x, 2)*z*(x - 1)*(z - 1)*(2*z - 1) + x*z*pow(x - 1, 2)*(z - 1)*(2*z - 1))*(pow(x, 2)*z*(z - 1)*(2*z - 1) + 4*x*z*(x - 1)*(z - 1)*(2*z - 1) + z*pow(x - 1, 2)*(z - 1)*(2*z - 1)) + 4*(2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - 3*pow(z, 2)*(6*pow(x, 2) - 6*x + 1) + z*(6*pow(x, 2) - 6*x + 1))*(2*pow(z, 3)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 3*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) + z*(2*pow(x, 3) - 3*pow(x, 2) + x)) + (2*pow(x, 2)*z*pow(x - 1, 2)*(z - 1) + pow(x, 2)*z*pow(x - 1, 2)*(2*z - 1) + pow(x, 2)*pow(x - 1, 2)*(z - 1)*(2*z - 1) - pow(z, 4)*(6*pow(x, 2) - 6*x + 1) + 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - pow(z, 2)*(6*pow(x, 2) - 6*x + 1))*(2*pow(x, 2)*z*(x - 1)*(z - 1) + pow(x, 2)*z*(x - 1)*(2*z - 1) + pow(x, 2)*(x - 1)*(z - 1)*(2*z - 1) + 2*x*z*pow(x - 1, 2)*(z - 1) + x*z*pow(x - 1, 2)*(2*z - 1) + x*pow(x - 1, 2)*(z - 1)*(2*z - 1) - 3*pow(z, 4)*(2*x - 1) + 6*pow(z, 3)*(2*x - 1) - 3*pow(z, 2)*(2*x - 1)))/pow(4*pow(pow(x, 2)*z*(x - 1)*(z - 1)*(2*z - 1) + x*z*pow(x - 1, 2)*(z - 1)*(2*z - 1), 2) + 4*pow(2*pow(z, 3)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 3*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) + z*(2*pow(x, 3) - 3*pow(x, 2) + x), 2) + (1.0L/2.0L)*pow(2*pow(x, 2)*z*pow(x - 1, 2)*(z - 1) + pow(x, 2)*z*pow(x - 1, 2)*(2*z - 1) + pow(x, 2)*pow(x - 1, 2)*(z - 1)*(2*z - 1) - pow(z, 4)*(6*pow(x, 2) - 6*x + 1) + 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - pow(z, 2)*(6*pow(x, 2) - 6*x + 1), 2), 4.0L/3.0L) - 1.0L/3.0L*pow(2, 1.0L/3.0L)*(4*(pow(x, 2)*z*(x - 1)*(z - 1)*(2*z - 1) + x*z*pow(x - 1, 2)*(z - 1)*(2*z - 1))*(2*pow(x, 2)*z*(x - 1)*(z - 1) + pow(x, 2)*z*(x - 1)*(2*z - 1) + pow(x, 2)*(x - 1)*(z - 1)*(2*z - 1) + 2*x*z*pow(x - 1, 2)*(z - 1) + x*z*pow(x - 1, 2)*(2*z - 1) + x*pow(x - 1, 2)*(z - 1)*(2*z - 1)) + 4*(2*pow(z, 3)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 3*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) + z*(2*pow(x, 3) - 3*pow(x, 2) + x))*(2*pow(x, 3) - 3*pow(x, 2) + x + 6*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 6*z*(2*pow(x, 3) - 3*pow(x, 2) + x)) + (2*pow(x, 2)*z*pow(x - 1, 2) + 2*pow(x, 2)*pow(x - 1, 2)*(z - 1) + pow(x, 2)*pow(x - 1, 2)*(2*z - 1) - 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) + 3*pow(z, 2)*(6*pow(x, 2) - 6*x + 1) - z*(6*pow(x, 2) - 6*x + 1))*(2*pow(x, 2)*z*pow(x - 1, 2)*(z - 1) + pow(x, 2)*z*pow(x - 1, 2)*(2*z - 1) + pow(x, 2)*pow(x - 1, 2)*(z - 1)*(2*z - 1) - pow(z, 4)*(6*pow(x, 2) - 6*x + 1) + 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - pow(z, 2)*(6*pow(x, 2) - 6*x + 1)))*(2*pow(x, 2)*z*pow(x - 1, 2)*(z - 1) + pow(x, 2)*z*pow(x - 1, 2)*(2*z - 1) + pow(x, 2)*pow(x - 1, 2)*(z - 1)*(2*z - 1) - pow(z, 4)*(6*pow(x, 2) - 6*x + 1) + 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - pow(z, 2)*(6*pow(x, 2) - 6*x + 1))/pow(4*pow(pow(x, 2)*z*(x - 1)*(z - 1)*(2*z - 1) + x*z*pow(x - 1, 2)*(z - 1)*(2*z - 1), 2) + 4*pow(2*pow(z, 3)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 3*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) + z*(2*pow(x, 3) - 3*pow(x, 2) + x), 2) + (1.0L/2.0L)*pow(2*pow(x, 2)*z*pow(x - 1, 2)*(z - 1) + pow(x, 2)*z*pow(x - 1, 2)*(2*z - 1) + pow(x, 2)*pow(x - 1, 2)*(z - 1)*(2*z - 1) - pow(z, 4)*(6*pow(x, 2) - 6*x + 1) + 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - pow(z, 2)*(6*pow(x, 2) - 6*x + 1), 2), 4.0L/3.0L) + 2*pow(2, 1.0L/3.0L)*(pow(x, 2)*z*(z - 1)*(2*z - 1) + 4*x*z*(x - 1)*(z - 1)*(2*z - 1) + z*pow(x - 1, 2)*(z - 1)*(2*z - 1))/pow(4*pow(pow(x, 2)*z*(x - 1)*(z - 1)*(2*z - 1) + x*z*pow(x - 1, 2)*(z - 1)*(2*z - 1), 2) + 4*pow(2*pow(z, 3)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 3*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) + z*(2*pow(x, 3) - 3*pow(x, 2) + x), 2) + (1.0L/2.0L)*pow(2*pow(x, 2)*z*pow(x - 1, 2)*(z - 1) + pow(x, 2)*z*pow(x - 1, 2)*(2*z - 1) + pow(x, 2)*pow(x - 1, 2)*(z - 1)*(2*z - 1) - pow(z, 4)*(6*pow(x, 2) - 6*x + 1) + 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - pow(z, 2)*(6*pow(x, 2) - 6*x + 1), 2), 1.0L/3.0L) - 1.0L/2.0L + pow(2, 1.0L/3.0L)*(2*pow(x, 2)*z*pow(x - 1, 2) + 2*pow(x, 2)*pow(x - 1, 2)*(z - 1) + pow(x, 2)*pow(x - 1, 2)*(2*z - 1) - 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) + 3*pow(z, 2)*(6*pow(x, 2) - 6*x + 1) - z*(6*pow(x, 2) - 6*x + 1))/pow(4*pow(pow(x, 2)*z*(x - 1)*(z - 1)*(2*z - 1) + x*z*pow(x - 1, 2)*(z - 1)*(2*z - 1), 2) + 4*pow(2*pow(z, 3)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 3*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) + z*(2*pow(x, 3) - 3*pow(x, 2) + x), 2) + (1.0L/2.0L)*pow(2*pow(x, 2)*z*pow(x - 1, 2)*(z - 1) + pow(x, 2)*z*pow(x - 1, 2)*(2*z - 1) + pow(x, 2)*pow(x - 1, 2)*(z - 1)*(2*z - 1) - pow(z, 4)*(6*pow(x, 2) - 6*x + 1) + 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - pow(z, 2)*(6*pow(x, 2) - 6*x + 1), 2), 1.0L/3.0L); 61 return z - 4.0L/3.0L*pow(2, 1.0L/3.0L)*(pow(x, 2)*z*(x - 1)*(z - 1)*(2*z - 1) + x*z*pow(x - 1, 2)*(z - 1)*(2*z - 1))*(4*(pow(x, 2)*z*(x - 1)*(z - 1)*(2*z - 1) + x*z*pow(x - 1, 2)*(z - 1)*(2*z - 1))*(pow(x, 2)*z*(z - 1)*(2*z - 1) + 4*x*z*(x - 1)*(z - 1)*(2*z - 1) + z*pow(x - 1, 2)*(z - 1)*(2*z - 1)) + 4*(2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - 3*pow(z, 2)*(6*pow(x, 2) - 6*x + 1) + z*(6*pow(x, 2) - 6*x + 1))*(2*pow(z, 3)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 3*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) + z*(2*pow(x, 3) - 3*pow(x, 2) + x)) + (2*pow(x, 2)*z*pow(x - 1, 2)*(z - 1) + pow(x, 2)*z*pow(x - 1, 2)*(2*z - 1) + pow(x, 2)*pow(x - 1, 2)*(z - 1)*(2*z - 1) - pow(z, 4)*(6*pow(x, 2) - 6*x + 1) + 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - pow(z, 2)*(6*pow(x, 2) - 6*x + 1))*(2*pow(x, 2)*z*(x - 1)*(z - 1) + pow(x, 2)*z*(x - 1)*(2*z - 1) + pow(x, 2)*(x - 1)*(z - 1)*(2*z - 1) + 2*x*z*pow(x - 1, 2)*(z - 1) + x*z*pow(x - 1, 2)*(2*z - 1) + x*pow(x - 1, 2)*(z - 1)*(2*z - 1) - 3*pow(z, 4)*(2*x - 1) + 6*pow(z, 3)*(2*x - 1) - 3*pow(z, 2)*(2*x - 1)))/pow(4*pow(pow(x, 2)*z*(x - 1)*(z - 1)*(2*z - 1) + x*z*pow(x - 1, 2)*(z - 1)*(2*z - 1), 2) + 4*pow(2*pow(z, 3)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 3*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) + z*(2*pow(x, 3) - 3*pow(x, 2) + x), 2) + (1.0L/2.0L)*pow(2*pow(x, 2)*z*pow(x - 1, 2)*(z - 1) + pow(x, 2)*z*pow(x - 1, 2)*(2*z - 1) + pow(x, 2)*pow(x - 1, 2)*(z - 1)*(2*z - 1) - pow(z, 4)*(6*pow(x, 2) - 6*x + 1) + 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - pow(z, 2)*(6*pow(x, 2) - 6*x + 1), 2), 4.0L/3.0L) - 1.0L/3.0L*pow(2, 1.0L/3.0L)*(4*(pow(x, 2)*z*(x - 1)*(z - 1)*(2*z - 1) + x*z*pow(x - 1, 2)*(z - 1)*(2*z - 1))*(2*pow(x, 2)*z*(x - 1)*(z - 1) + pow(x, 2)*z*(x - 1)*(2*z - 1) + pow(x, 2)*(x - 1)*(z - 1)*(2*z - 1) + 2*x*z*pow(x - 1, 2)*(z - 1) + x*z*pow(x - 1, 2)*(2*z - 1) + x*pow(x - 1, 2)*(z - 1)*(2*z - 1)) + 4*(2*pow(z, 3)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 3*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) + z*(2*pow(x, 3) - 3*pow(x, 2) + x))*(2*pow(x, 3) - 3*pow(x, 2) + x + 6*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 6*z*(2*pow(x, 3) - 3*pow(x, 2) + x)) + (2*pow(x, 2)*z*pow(x - 1, 2) + 2*pow(x, 2)*pow(x - 1, 2)*(z - 1) + pow(x, 2)*pow(x - 1, 2)*(2*z - 1) - 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) + 3*pow(z, 2)*(6*pow(x, 2) - 6*x + 1) - z*(6*pow(x, 2) - 6*x + 1))*(2*pow(x, 2)*z*pow(x - 1, 2)*(z - 1) + pow(x, 2)*z*pow(x - 1, 2)*(2*z - 1) + pow(x, 2)*pow(x - 1, 2)*(z - 1)*(2*z - 1) - pow(z, 4)*(6*pow(x, 2) - 6*x + 1) + 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - pow(z, 2)*(6*pow(x, 2) - 6*x + 1)))*(2*pow(x, 2)*z*pow(x - 1, 2)*(z - 1) + pow(x, 2)*z*pow(x - 1, 2)*(2*z - 1) + pow(x, 2)*pow(x - 1, 2)*(z - 1)*(2*z - 1) - pow(z, 4)*(6*pow(x, 2) - 6*x + 1) + 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - pow(z, 2)*(6*pow(x, 2) - 6*x + 1))/pow(4*pow(pow(x, 2)*z*(x - 1)*(z - 1)*(2*z - 1) + x*z*pow(x - 1, 2)*(z - 1)*(2*z - 1), 2) + 4*pow(2*pow(z, 3)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 3*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) + z*(2*pow(x, 3) - 3*pow(x, 2) + x), 2) + (1.0L/2.0L)*pow(2*pow(x, 2)*z*pow(x - 1, 2)*(z - 1) + pow(x, 2)*z*pow(x - 1, 2)*(2*z - 1) + pow(x, 2)*pow(x - 1, 2)*(z - 1)*(2*z - 1) - pow(z, 4)*(6*pow(x, 2) - 6*x + 1) + 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - pow(z, 2)*(6*pow(x, 2) - 6*x + 1), 2), 4.0L/3.0L) + 2*pow(2, 1.0L/3.0L)*(pow(x, 2)*z*(z - 1)*(2*z - 1) + 4*x*z*(x - 1)*(z - 1)*(2*z - 1) + z*pow(x - 1, 2)*(z - 1)*(2*z - 1))/pow(4*pow(pow(x, 2)*z*(x - 1)*(z - 1)*(2*z - 1) + x*z*pow(x - 1, 2)*(z - 1)*(2*z - 1), 2) + 4*pow(2*pow(z, 3)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 3*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) + z*(2*pow(x, 3) - 3*pow(x, 2) + x), 2) + (1.0L/2.0L)*pow(2*pow(x, 2)*z*pow(x - 1, 2)*(z - 1) + pow(x, 2)*z*pow(x - 1, 2)*(2*z - 1) + pow(x, 2)*pow(x - 1, 2)*(z - 1)*(2*z - 1) - pow(z, 4)*(6*pow(x, 2) - 6*x + 1) + 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - pow(z, 2)*(6*pow(x, 2) - 6*x + 1), 2), 1.0L/3.0L) - 0.5 + pow(2, 1.0L/3.0L)*(2*pow(x, 2)*z*pow(x - 1, 2) + 2*pow(x, 2)*pow(x - 1, 2)*(z - 1) + pow(x, 2)*pow(x - 1, 2)*(2*z - 1) - 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) + 3*pow(z, 2)*(6*pow(x, 2) - 6*x + 1) - z*(6*pow(x, 2) - 6*x + 1))/pow(4*pow(pow(x, 2)*z*(x - 1)*(z - 1)*(2*z - 1) + x*z*pow(x - 1, 2)*(z - 1)*(2*z - 1), 2) + 4*pow(2*pow(z, 3)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 3*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) + z*(2*pow(x, 3) - 3*pow(x, 2) + x), 2) + (1.0L/2.0L)*pow(2*pow(x, 2)*z*pow(x - 1, 2)*(z - 1) + pow(x, 2)*z*pow(x - 1, 2)*(2*z - 1) + pow(x, 2)*pow(x - 1, 2)*(z - 1)*(2*z - 1) - pow(z, 4)*(6*pow(x, 2) - 6*x + 1) + 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - pow(z, 2)*(6*pow(x, 2) - 6*x + 1), 2), 1.0L/3.0L); 62 case 22: 63 z=y; 64 return -2*pow(2, 1.0L/3.0L)*(pow(x, 2)*z*pow(z - 2, 2) + 4*x*z*(x - 2)*pow(z - 2, 2) + z*pow(x - 2, 2)*pow(z - 2, 2))/pow(8*pow(x, 8) - 64*pow(x, 7) + 192*pow(x, 6) - 256*pow(x, 5) + 128*pow(x, 4) + (1.0L/2.0L)*pow(z, 8)*(9*pow(x, 4) - 36*pow(x, 3) + 48*pow(x, 2) - 24*x + 4) - 16.0L/3.0L*pow(z, 7)*(9*pow(x, 4) - 36*pow(x, 3) + 48*pow(x, 2) - 24*x + 4) + (1.0L/9.0L)*pow(z, 6)*(207*pow(x, 6) - 1242*pow(x, 5) + 4518*pow(x, 4) - 9792*pow(x, 3) + 10536*pow(x, 2) - 4800*x + 800) - 8.0L/3.0L*pow(z, 5)*(69*pow(x, 6) - 414*pow(x, 5) + 1050*pow(x, 4) - 1440*pow(x, 3) + 1080*pow(x, 2) - 384*x + 64) + (1.0L/6.0L)*pow(z, 4)*(27*pow(x, 8) - 216*pow(x, 7) + 3984*pow(x, 6) - 20880*pow(x, 5) + 45952*pow(x, 4) - 48640*pow(x, 3) + 24256*pow(x, 2) - 4608*x + 768) - 8.0L/3.0L*pow(z, 3)*(9*pow(x, 8) - 72*pow(x, 7) + 504*pow(x, 6) - 2016*pow(x, 5) + 3920*pow(x, 4) - 3590*pow(x, 3) + 1298*pow(x, 2) - 12*x) + 4*pow(z, 2)*(11*pow(x, 8) - 88*pow(x, 7) + 368*pow(x, 6) - 976*pow(x, 5) + 1536*pow(x, 4) - 1296*pow(x, 3) + 496*pow(x, 2) - 32*x) - 32*z*(pow(x, 8) - 8*pow(x, 7) + 24*pow(x, 6) - 32*pow(x, 5) + 16*pow(x, 4) - 2*pow(x, 3) + 6*pow(x, 2) - 4*x) + 2, 1.0L/3.0L) + (2.0L/9.0L)*pow(2, 1.0L/3.0L)*(2*pow(x, 2)*z*(x - 2)*pow(z - 2, 2) + 2*x*z*pow(x - 2, 2)*pow(z - 2, 2) + 1)*(96*pow(x, 7) - 672*pow(x, 6) + 1728*pow(x, 5) - 1920*pow(x, 4) + 768*pow(x, 3) + 9*pow(z, 8)*(3*pow(x, 3) - 9*pow(x, 2) + 8*x - 2) - 96*pow(z, 7)*(3*pow(x, 3) - 9*pow(x, 2) + 8*x - 2) + pow(z, 6)*(207*pow(x, 5) - 1035*pow(x, 4) + 3012*pow(x, 3) - 4896*pow(x, 2) + 3512*x - 800) - 24*pow(z, 5)*(69*pow(x, 5) - 345*pow(x, 4) + 700*pow(x, 3) - 720*pow(x, 2) + 360*x - 64) + 2*pow(z, 4)*(27*pow(x, 7) - 189*pow(x, 6) + 2988*pow(x, 5) - 13050*pow(x, 4) + 22976*pow(x, 3) - 18240*pow(x, 2) + 6064*x - 576) - 8*pow(z, 3)*(36*pow(x, 7) - 252*pow(x, 6) + 1512*pow(x, 5) - 5040*pow(x, 4) + 7840*pow(x, 3) - 5385*pow(x, 2) + 1298*x - 6) + 48*pow(z, 2)*(11*pow(x, 7) - 77*pow(x, 6) + 276*pow(x, 5) - 610*pow(x, 4) + 768*pow(x, 3) - 486*pow(x, 2) + 124*x - 4) - 96*z*(4*pow(x, 7) - 28*pow(x, 6) + 72*pow(x, 5) - 80*pow(x, 4) + 32*pow(x, 3) - 3*pow(x, 2) + 6*x - 2))/pow(8*pow(x, 8) - 64*pow(x, 7) + 192*pow(x, 6) - 256*pow(x, 5) + 128*pow(x, 4) + (1.0L/2.0L)*pow(z, 8)*(9*pow(x, 4) - 36*pow(x, 3) + 48*pow(x, 2) - 24*x + 4) - 16.0L/3.0L*pow(z, 7)*(9*pow(x, 4) - 36*pow(x, 3) + 48*pow(x, 2) - 24*x + 4) + (1.0L/9.0L)*pow(z, 6)*(207*pow(x, 6) - 1242*pow(x, 5) + 4518*pow(x, 4) - 9792*pow(x, 3) + 10536*pow(x, 2) - 4800*x + 800) - 8.0L/3.0L*pow(z, 5)*(69*pow(x, 6) - 414*pow(x, 5) + 1050*pow(x, 4) - 1440*pow(x, 3) + 1080*pow(x, 2) - 384*x + 64) + (1.0L/6.0L)*pow(z, 4)*(27*pow(x, 8) - 216*pow(x, 7) + 3984*pow(x, 6) - 20880*pow(x, 5) + 45952*pow(x, 4) - 48640*pow(x, 3) + 24256*pow(x, 2) - 4608*x + 768) - 8.0L/3.0L*pow(z, 3)*(9*pow(x, 8) - 72*pow(x, 7) + 504*pow(x, 6) - 2016*pow(x, 5) + 3920*pow(x, 4) - 3590*pow(x, 3) + 1298*pow(x, 2) - 12*x) + 4*pow(z, 2)*(11*pow(x, 8) - 88*pow(x, 7) + 368*pow(x, 6) - 976*pow(x, 5) + 1536*pow(x, 4) - 1296*pow(x, 3) + 496*pow(x, 2) - 32*x) - 32*z*(pow(x, 8) - 8*pow(x, 7) + 24*pow(x, 6) - 32*pow(x, 5) + 16*pow(x, 4) - 2*pow(x, 3) + 6*pow(x, 2) - 4*x) + 2, 4.0L/3.0L) - pow(2, 1.0L/3.0L)*(pow(x, 2)*z*pow(x - 2, 2) + 2*pow(x, 2)*pow(x - 2, 2)*(z - 2) - 2*pow(z, 3)*(3*pow(x, 2) - 6*x + 2) + 8*pow(z, 2)*(3*pow(x, 2) - 6*x + 2) - 8*z*(3*pow(x, 2) - 6*x + 2))/pow(8*pow(x, 8) - 64*pow(x, 7) + 192*pow(x, 6) - 256*pow(x, 5) + 128*pow(x, 4) + (1.0L/2.0L)*pow(z, 8)*(9*pow(x, 4) - 36*pow(x, 3) + 48*pow(x, 2) - 24*x + 4) - 16.0L/3.0L*pow(z, 7)*(9*pow(x, 4) - 36*pow(x, 3) + 48*pow(x, 2) - 24*x + 4) + (1.0L/9.0L)*pow(z, 6)*(207*pow(x, 6) - 1242*pow(x, 5) + 4518*pow(x, 4) - 9792*pow(x, 3) + 10536*pow(x, 2) - 4800*x + 800) - 8.0L/3.0L*pow(z, 5)*(69*pow(x, 6) - 414*pow(x, 5) + 1050*pow(x, 4) - 1440*pow(x, 3) + 1080*pow(x, 2) - 384*x + 64) + (1.0L/6.0L)*pow(z, 4)*(27*pow(x, 8) - 216*pow(x, 7) + 3984*pow(x, 6) - 20880*pow(x, 5) + 45952*pow(x, 4) - 48640*pow(x, 3) + 24256*pow(x, 2) - 4608*x + 768) - 8.0L/3.0L*pow(z, 3)*(9*pow(x, 8) - 72*pow(x, 7) + 504*pow(x, 6) - 2016*pow(x, 5) + 3920*pow(x, 4) - 3590*pow(x, 3) + 1298*pow(x, 2) - 12*x) + 4*pow(z, 2)*(11*pow(x, 8) - 88*pow(x, 7) + 368*pow(x, 6) - 976*pow(x, 5) + 1536*pow(x, 4) - 1296*pow(x, 3) + 496*pow(x, 2) - 32*x) - 32*z*(pow(x, 8) - 8*pow(x, 7) + 24*pow(x, 6) - 32*pow(x, 5) + 16*pow(x, 4) - 2*pow(x, 3) + 6*pow(x, 2) - 4*x) + 2, 1.0L/3.0L) - 1.0L/27.0L*pow(2, 1.0L/3.0L)*(6*pow(x, 2)*z*pow(x - 2, 2)*(z - 2) + 3*pow(x, 2)*pow(x - 2, 2)*pow(z - 2, 2) - 3*pow(z, 4)*(3*pow(x, 2) - 6*x + 2) + 16*pow(z, 3)*(3*pow(x, 2) - 6*x + 2) - 24*pow(z, 2)*(3*pow(x, 2) - 6*x + 2))*(48*pow(x, 8) - 384*pow(x, 7) + 1152*pow(x, 6) - 1536*pow(x, 5) + 768*pow(x, 4) - 96*pow(x, 3) + 288*pow(x, 2) - 192*x - 6*pow(z, 7)*(9*pow(x, 4) - 36*pow(x, 3) + 48*pow(x, 2) - 24*x + 4) + 56*pow(z, 6)*(9*pow(x, 4) - 36*pow(x, 3) + 48*pow(x, 2) - 24*x + 4) - pow(z, 5)*(207*pow(x, 6) - 1242*pow(x, 5) + 4518*pow(x, 4) - 9792*pow(x, 3) + 10536*pow(x, 2) - 4800*x + 800) + 20*pow(z, 4)*(69*pow(x, 6) - 414*pow(x, 5) + 1050*pow(x, 4) - 1440*pow(x, 3) + 1080*pow(x, 2) - 384*x + 64) - pow(z, 3)*(27*pow(x, 8) - 216*pow(x, 7) + 3984*pow(x, 6) - 20880*pow(x, 5) + 45952*pow(x, 4) - 48640*pow(x, 3) + 24256*pow(x, 2) - 4608*x + 768) + 12*pow(z, 2)*(9*pow(x, 8) - 72*pow(x, 7) + 504*pow(x, 6) - 2016*pow(x, 5) + 3920*pow(x, 4) - 3590*pow(x, 3) + 1298*pow(x, 2) - 12*x) - 12*z*(11*pow(x, 8) - 88*pow(x, 7) + 368*pow(x, 6) - 976*pow(x, 5) + 1536*pow(x, 4) - 1296*pow(x, 3) + 496*pow(x, 2) - 32*x))/pow(8*pow(x, 8) - 64*pow(x, 7) + 192*pow(x, 6) - 256*pow(x, 5) + 128*pow(x, 4) + (1.0L/2.0L)*pow(z, 8)*(9*pow(x, 4) - 36*pow(x, 3) + 48*pow(x, 2) - 24*x + 4) - 16.0L/3.0L*pow(z, 7)*(9*pow(x, 4) - 36*pow(x, 3) + 48*pow(x, 2) - 24*x + 4) + (1.0L/9.0L)*pow(z, 6)*(207*pow(x, 6) - 1242*pow(x, 5) + 4518*pow(x, 4) - 9792*pow(x, 3) + 10536*pow(x, 2) - 4800*x + 800) - 8.0L/3.0L*pow(z, 5)*(69*pow(x, 6) - 414*pow(x, 5) + 1050*pow(x, 4) - 1440*pow(x, 3) + 1080*pow(x, 2) - 384*x + 64) + (1.0L/6.0L)*pow(z, 4)*(27*pow(x, 8) - 216*pow(x, 7) + 3984*pow(x, 6) - 20880*pow(x, 5) + 45952*pow(x, 4) - 48640*pow(x, 3) + 24256*pow(x, 2) - 4608*x + 768) - 8.0L/3.0L*pow(z, 3)*(9*pow(x, 8) - 72*pow(x, 7) + 504*pow(x, 6) - 2016*pow(x, 5) + 3920*pow(x, 4) - 3590*pow(x, 3) + 1298*pow(x, 2) - 12*x) + 4*pow(z, 2)*(11*pow(x, 8) - 88*pow(x, 7) + 368*pow(x, 6) - 976*pow(x, 5) + 1536*pow(x, 4) - 1296*pow(x, 3) + 496*pow(x, 2) - 32*x) - 32*z*(pow(x, 8) - 8*pow(x, 7) + 24*pow(x, 6) - 32*pow(x, 5) + 16*pow(x, 4) - 2*pow(x, 3) + 6*pow(x, 2) - 4*x) + 2, 4.0L/3.0L) + 4*M_PI*cos(4*M_PI*x + (1.0L/3.0L)*M_PI); 56 65 case 24: 57 66 return 2*pow(2, 1.0L/3.0L)*pow(PI, 2)*pow(p, 2)*sin(PI*p*y)*sin(PI*p*z)*cos(PI*p*x)/pow(6*pow(PI, 2)*pow(p, 2)*pow(sin(PI*p*x), 2)*pow(sin(PI*p*y), 2)*pow(sin(PI*p*z), 2) + (1.0L/2.0L)*pow(-2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*z)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*z)*cos(PI*p*x), 2) + (1.0L/2.0L)*pow(pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*x)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*x)*cos(PI*p*z), 2) + (1.0L/2.0L)*pow(pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*y)*cos(PI*p*x) - 2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*y)*cos(PI*p*z), 2), 1.0L/3.0L) - 2.0L/3.0L*pow(2, 1.0L/3.0L)*PI*p*(12*pow(PI, 3)*pow(p, 3)*sin(PI*p*x)*pow(sin(PI*p*y), 2)*pow(sin(PI*p*z), 2)*cos(PI*p*x) - (-2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*z)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*z)*cos(PI*p*x))*(pow(PI, 2)*pow(p, 2)*(cos(PI*p*y) - 1)*sin(PI*p*x)*sin(PI*p*z) - 2*pow(PI, 2)*pow(p, 2)*sin(PI*p*x)*sin(PI*p*z)*cos(PI*p*y)) + (pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*x)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*x)*cos(PI*p*z))*(pow(PI, 3)*pow(p, 3)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*cos(PI*p*x)*cos(PI*p*y) + pow(PI, 2)*pow(p, 2)*(cos(PI*p*y) - 1)*cos(PI*p*x)*cos(PI*p*z)) - (pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*y)*cos(PI*p*x) - 2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*y)*cos(PI*p*z))*(pow(PI, 3)*pow(p, 3)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*x)*sin(PI*p*y) - 2*pow(PI, 2)*pow(p, 2)*sin(PI*p*x)*sin(PI*p*y)*cos(PI*p*z)))*sin(PI*p*x)*sin(PI*p*y)*sin(PI*p*z)/pow(6*pow(PI, 2)*pow(p, 2)*pow(sin(PI*p*x), 2)*pow(sin(PI*p*y), 2)*pow(sin(PI*p*z), 2) + (1.0L/2.0L)*pow(-2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*z)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*z)*cos(PI*p*x), 2) + (1.0L/2.0L)*pow(pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*x)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*x)*cos(PI*p*z), 2) + (1.0L/2.0L)*pow(pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*y)*cos(PI*p*x) - 2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*y)*cos(PI*p*z), 2), 4.0L/3.0L) + PI*q*sin(PI*q*y)*sin(PI*q*z)*cos(PI*q*x) - 1.0L/6.0L*pow(2, 1.0L/3.0L)*(-2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*z)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*z)*cos(PI*p*x))*(12*pow(PI, 3)*pow(p, 3)*pow(sin(PI*p*x), 2)*sin(PI*p*y)*pow(sin(PI*p*z), 2)*cos(PI*p*y) + (-2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*z)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*z)*cos(PI*p*x))*(2*pow(PI, 2)*pow(p, 2)*(cos(PI*p*x) - 1)*sin(PI*p*y)*sin(PI*p*z) - pow(PI, 2)*pow(p, 2)*sin(PI*p*y)*sin(PI*p*z)*cos(PI*p*x)) - (pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*x)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*x)*cos(PI*p*z))*(pow(PI, 3)*pow(p, 3)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*x)*sin(PI*p*y) + pow(PI, 2)*pow(p, 2)*sin(PI*p*x)*sin(PI*p*y)*cos(PI*p*z)) + (pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*y)*cos(PI*p*x) - 2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*y)*cos(PI*p*z))*(pow(PI, 3)*pow(p, 3)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*cos(PI*p*x)*cos(PI*p*y) - 2*pow(PI, 2)*pow(p, 2)*(cos(PI*p*x) - 1)*cos(PI*p*y)*cos(PI*p*z)))/pow(6*pow(PI, 2)*pow(p, 2)*pow(sin(PI*p*x), 2)*pow(sin(PI*p*y), 2)*pow(sin(PI*p*z), 2) + (1.0L/2.0L)*pow(-2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*z)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*z)*cos(PI*p*x), 2) + (1.0L/2.0L)*pow(pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*x)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*x)*cos(PI*p*z), 2) + (1.0L/2.0L)*pow(pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*y)*cos(PI*p*x) - 2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*y)*cos(PI*p*z), 2), 4.0L/3.0L) - 1.0L/6.0L*pow(2, 1.0L/3.0L)*(pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*y)*cos(PI*p*x) - 2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*y)*cos(PI*p*z))*(12*pow(PI, 3)*pow(p, 3)*pow(sin(PI*p*x), 2)*pow(sin(PI*p*y), 2)*sin(PI*p*z)*cos(PI*p*z) + (-2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*z)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*z)*cos(PI*p*x))*(-2*pow(PI, 2)*pow(p, 2)*(cos(PI*p*x) - 1)*cos(PI*p*y)*cos(PI*p*z) + pow(PI, 2)*pow(p, 2)*(cos(PI*p*y) - 1)*cos(PI*p*x)*cos(PI*p*z)) - (pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*x)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*x)*cos(PI*p*z))*(pow(PI, 2)*pow(p, 2)*(cos(PI*p*y) - 1)*sin(PI*p*x)*sin(PI*p*z) + pow(PI, 2)*pow(p, 2)*sin(PI*p*x)*sin(PI*p*z)*cos(PI*p*y)) + (pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*y)*cos(PI*p*x) - 2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*y)*cos(PI*p*z))*(2*pow(PI, 2)*pow(p, 2)*(cos(PI*p*x) - 1)*sin(PI*p*y)*sin(PI*p*z) - pow(PI, 2)*pow(p, 2)*sin(PI*p*y)*sin(PI*p*z)*cos(PI*p*x)))/pow(6*pow(PI, 2)*pow(p, 2)*pow(sin(PI*p*x), 2)*pow(sin(PI*p*y), 2)*pow(sin(PI*p*z), 2) + (1.0L/2.0L)*pow(-2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*z)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*z)*cos(PI*p*x), 2) + (1.0L/2.0L)*pow(pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*x)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*x)*cos(PI*p*z), 2) + (1.0L/2.0L)*pow(pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*y)*cos(PI*p*x) - 2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*y)*cos(PI*p*z), 2), 4.0L/3.0L) + pow(2, 1.0L/3.0L)*(2*pow(PI, 2)*pow(p, 2)*(cos(PI*p*x) - 1)*sin(PI*p*y)*sin(PI*p*z) - pow(PI, 2)*pow(p, 2)*sin(PI*p*y)*sin(PI*p*z)*cos(PI*p*x))/pow(6*pow(PI, 2)*pow(p, 2)*pow(sin(PI*p*x), 2)*pow(sin(PI*p*y), 2)*pow(sin(PI*p*z), 2) + (1.0L/2.0L)*pow(-2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*z)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*z)*cos(PI*p*x), 2) + (1.0L/2.0L)*pow(pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*x)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*x)*cos(PI*p*z), 2) + (1.0L/2.0L)*pow(pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*y)*cos(PI*p*x) - 2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*y)*cos(PI*p*z), 2), 1.0L/3.0L); … … 99 108 z=y; 100 109 return 32.0/5.0*pow(PI, 2)*sin(8*PI*x) - 100; 110 case 13: 111 z=y; 112 return 8.0*pow(PI, 2)*x*z*(z - 2)*sin(4*PI*x*z) - 2.0*PI*z*cos(4*PI*x*z) - 2.0*PI*(z - 2)*cos(4*PI*x*z) + 0.25*PI*(32*cos(4*PI*x)/pow(x, 2) - 4*(8*pow(PI, 2)*pow(x, 2) + 1)*sin(4*PI*x)/(PI*pow(x, 3)) - 4*(4*pow(PI, 2)*pow(z, 2)*(PI*x*z - PI*x)*cos(4*PI*x*z) + pow(PI, 2)*pow(z, 2)*(8*pow(PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(PI, 2)*pow(x, 2)*z - 1)*sin(4*PI*x*z) - 2*PI*z*(-PI*z + PI)*sin(4*PI*x*z) - 8*PI*z*(pow(PI, 2)*x*pow(z, 2) - 2*pow(PI, 2)*x*z)*cos(4*PI*x*z) - (pow(PI, 2)*pow(z, 2) - 2*pow(PI, 2)*z)*sin(4*PI*x*z))/(pow(PI, 3)*pow(x, 3)) - 20*sin(4*PI*x)/(PI*pow(x, 3)) - 6*(8*pow(PI, 2)*pow(x, 2) + 1)*cos(4*PI*x)/(pow(PI, 2)*pow(x, 4)) - 6*(-4*PI*z*(PI*x*z - PI*x)*sin(4*PI*x*z) + PI*z*(8*pow(PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(PI, 2)*pow(x, 2)*z - 1)*cos(4*PI*x*z) - (-PI*z + PI)*cos(4*PI*x*z) + 4*(pow(PI, 2)*x*pow(z, 2) - 2*pow(PI, 2)*x*z)*sin(4*PI*x*z))/(pow(PI, 3)*pow(x, 4)) + 3*(8*pow(PI, 2)*pow(x, 2) + 1)*sin(4*PI*x)/(pow(PI, 3)*pow(x, 5)) + 3*(4*(PI*x*z - PI*x)*cos(4*PI*x*z) + (8*pow(PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(PI, 2)*pow(x, 2)*z - 1)*sin(4*PI*x*z))/(pow(PI, 3)*pow(x, 5))) + 4*PI*sin(4*PI*x)*cos(4*PI*z) + (8.0L/5.0L)*pow(PI, 2)*sin(4*PI*x) + 2*(-4.0*pow(PI, 2)*pow(x, 2)*(PI*x*z - PI*x)*cos(4*PI*x*z) - 1.0*pow(PI, 2)*pow(x, 2)*(8*pow(PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(PI, 2)*pow(x, 2)*z - 1)*sin(4*PI*x*z) - 1.0*pow(PI, 2)*pow(x, 2)*sin(4*PI*x*z) + 8.0*PI*x*(pow(PI, 2)*pow(x, 2)*z - pow(PI, 2)*pow(x, 2))*cos(4*PI*x*z))/(pow(PI, 2)*pow(x, 3)); 113 case 14: 114 z=y; 115 return 4*M_PI*sin(4*M_PI*x)*cos(4*M_PI*z) + (1.0L/10.0L)*pow(2, 1.0L/3.0L)*(40.0*pow(M_PI, 2)*x*z*(z - 2)*sin(4*M_PI*x*z) - 10.0*M_PI*z*cos(4*M_PI*x*z) - 10.0*M_PI*(z - 2)*cos(4*M_PI*x*z) + 1.25*M_PI*(32*cos(4*M_PI*x)/pow(x, 2) - 4*(8*pow(M_PI, 2)*pow(x, 2) + 1)*sin(4*M_PI*x)/(M_PI*pow(x, 3)) - 4*(4*pow(M_PI, 2)*pow(z, 2)*(M_PI*x*z - M_PI*x)*cos(4*M_PI*x*z) + pow(M_PI, 2)*pow(z, 2)*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*sin(4*M_PI*x*z) - 2*M_PI*z*(-M_PI*z + M_PI)*sin(4*M_PI*x*z) - 8*M_PI*z*(pow(M_PI, 2)*x*pow(z, 2) - 2*pow(M_PI, 2)*x*z)*cos(4*M_PI*x*z) - (pow(M_PI, 2)*pow(z, 2) - 2*pow(M_PI, 2)*z)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 3)) - 20*sin(4*M_PI*x)/(M_PI*pow(x, 3)) - 6*(8*pow(M_PI, 2)*pow(x, 2) + 1)*cos(4*M_PI*x)/(pow(M_PI, 2)*pow(x, 4)) - 6*(-4*M_PI*z*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) + M_PI*z*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - (-M_PI*z + M_PI)*cos(4*M_PI*x*z) + 4*(pow(M_PI, 2)*x*pow(z, 2) - 2*pow(M_PI, 2)*x*z)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 4)) + 3*(8*pow(M_PI, 2)*pow(x, 2) + 1)*sin(4*M_PI*x)/(pow(M_PI, 3)*pow(x, 5)) + 3*(4*(M_PI*x*z - M_PI*x)*cos(4*M_PI*x*z) + (8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 5))) + 8*pow(M_PI, 2)*sin(4*M_PI*x))/pow(4.0*pow(M_PI, 2)*pow(z, 2)*pow(z - 2, 2)*pow(cos(4*M_PI*x*z), 2) + (1.0L/2.0L)*pow(2.0*M_PI*x*(z - 2)*cos(4*M_PI*x*z) - 0.0625*M_PI*(16*sin(4*M_PI*x)/(M_PI*pow(x, 2)) + 4*(8*pow(M_PI, 2)*pow(x, 2) + 1)*cos(4*M_PI*x)/(pow(M_PI, 2)*pow(x, 3)) + 4*(-4*M_PI*z*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) + M_PI*z*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - (-M_PI*z + M_PI)*cos(4*M_PI*x*z) + 4*(pow(M_PI, 2)*x*pow(z, 2) - 2*pow(M_PI, 2)*x*z)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 3)) - 3*(8*pow(M_PI, 2)*pow(x, 2) + 1)*sin(4*M_PI*x)/(pow(M_PI, 3)*pow(x, 4)) - 3*(4*(M_PI*x*z - M_PI*x)*cos(4*M_PI*x*z) + (8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 4))) + 0.5*sin(4*M_PI*x*z) + (2.0L/5.0L)*M_PI*cos(4*M_PI*x), 2) + pow(M_PI*x*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) - 0.25*M_PI*x*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - 0.25*M_PI*x*cos(4*M_PI*x*z) - (pow(M_PI, 2)*pow(x, 2)*z - pow(M_PI, 2)*pow(x, 2))*sin(4*M_PI*x*z), 2)/(pow(M_PI, 4)*pow(x, 6)), 1.0L/3.0L) + (1.0L/750.0L)*pow(2, 1.0L/3.0L)*(-10.0*M_PI*x*(z - 2)*cos(4*M_PI*x*z) + 0.3125*M_PI*(16*sin(4*M_PI*x)/(M_PI*pow(x, 2)) + 4*(8*pow(M_PI, 2)*pow(x, 2) + 1)*cos(4*M_PI*x)/(pow(M_PI, 2)*pow(x, 3)) + 4*(-4*M_PI*z*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) + M_PI*z*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - (-M_PI*z + M_PI)*cos(4*M_PI*x*z) + 4*(pow(M_PI, 2)*x*pow(z, 2) - 2*pow(M_PI, 2)*x*z)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 3)) - 3*(8*pow(M_PI, 2)*pow(x, 2) + 1)*sin(4*M_PI*x)/(pow(M_PI, 3)*pow(x, 4)) - 3*(4*(M_PI*x*z - M_PI*x)*cos(4*M_PI*x*z) + (8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 4))) - 2.5*sin(4*M_PI*x*z) - 2*M_PI*cos(4*M_PI*x))*(800.0*pow(M_PI, 3)*pow(z, 3)*pow(z - 2, 2)*sin(4*M_PI*x*z)*cos(4*M_PI*x*z) - (-10.0*M_PI*x*(z - 2)*cos(4*M_PI*x*z) + 0.3125*M_PI*(16*sin(4*M_PI*x)/(M_PI*pow(x, 2)) + 4*(8*pow(M_PI, 2)*pow(x, 2) + 1)*cos(4*M_PI*x)/(pow(M_PI, 2)*pow(x, 3)) + 4*(-4*M_PI*z*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) + M_PI*z*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - (-M_PI*z + M_PI)*cos(4*M_PI*x*z) + 4*(pow(M_PI, 2)*x*pow(z, 2) - 2*pow(M_PI, 2)*x*z)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 3)) - 3*(8*pow(M_PI, 2)*pow(x, 2) + 1)*sin(4*M_PI*x)/(pow(M_PI, 3)*pow(x, 4)) - 3*(4*(M_PI*x*z - M_PI*x)*cos(4*M_PI*x*z) + (8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 4))) - 2.5*sin(4*M_PI*x*z) - 2*M_PI*cos(4*M_PI*x))*(40.0*pow(M_PI, 2)*x*z*(z - 2)*sin(4*M_PI*x*z) - 10.0*M_PI*z*cos(4*M_PI*x*z) - 10.0*M_PI*(z - 2)*cos(4*M_PI*x*z) + 1.25*M_PI*(32*cos(4*M_PI*x)/pow(x, 2) - 4*(8*pow(M_PI, 2)*pow(x, 2) + 1)*sin(4*M_PI*x)/(M_PI*pow(x, 3)) - 4*(4*pow(M_PI, 2)*pow(z, 2)*(M_PI*x*z - M_PI*x)*cos(4*M_PI*x*z) + pow(M_PI, 2)*pow(z, 2)*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*sin(4*M_PI*x*z) - 2*M_PI*z*(-M_PI*z + M_PI)*sin(4*M_PI*x*z) - 8*M_PI*z*(pow(M_PI, 2)*x*pow(z, 2) - 2*pow(M_PI, 2)*x*z)*cos(4*M_PI*x*z) - (pow(M_PI, 2)*pow(z, 2) - 2*pow(M_PI, 2)*z)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 3)) - 20*sin(4*M_PI*x)/(M_PI*pow(x, 3)) - 6*(8*pow(M_PI, 2)*pow(x, 2) + 1)*cos(4*M_PI*x)/(pow(M_PI, 2)*pow(x, 4)) - 6*(-4*M_PI*z*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) + M_PI*z*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - (-M_PI*z + M_PI)*cos(4*M_PI*x*z) + 4*(pow(M_PI, 2)*x*pow(z, 2) - 2*pow(M_PI, 2)*x*z)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 4)) + 3*(8*pow(M_PI, 2)*pow(x, 2) + 1)*sin(4*M_PI*x)/(pow(M_PI, 3)*pow(x, 5)) + 3*(4*(M_PI*x*z - M_PI*x)*cos(4*M_PI*x*z) + (8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 5))) + 8*pow(M_PI, 2)*sin(4*M_PI*x)) - (50*M_PI*x*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) - 12.5*M_PI*x*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - 12.5*M_PI*x*cos(4*M_PI*x*z) - 50*(pow(M_PI, 2)*pow(x, 2)*z - pow(M_PI, 2)*pow(x, 2))*sin(4*M_PI*x*z))*(4*pow(M_PI, 2)*x*z*(M_PI*x*z - M_PI*x)*cos(4*M_PI*x*z) + pow(M_PI, 2)*x*z*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*sin(4*M_PI*x*z) + pow(M_PI, 2)*x*z*sin(4*M_PI*x*z) - M_PI*x*(-M_PI*z + M_PI)*sin(4*M_PI*x*z) - 4.0*M_PI*x*(pow(M_PI, 2)*x*pow(z, 2) - 2*pow(M_PI, 2)*x*z)*cos(4*M_PI*x*z) - 4*M_PI*z*(pow(M_PI, 2)*pow(x, 2)*z - pow(M_PI, 2)*pow(x, 2))*cos(4*M_PI*x*z) + M_PI*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) - 2*(pow(M_PI, 2)*x*z - pow(M_PI, 2)*x)*sin(4*M_PI*x*z) - 0.25*M_PI*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - 0.25*M_PI*cos(4*M_PI*x*z))/(pow(M_PI, 4)*pow(x, 6)) + 150*pow(M_PI*x*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) - 0.25*M_PI*x*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - 0.25*M_PI*x*cos(4*M_PI*x*z) - (pow(M_PI, 2)*pow(x, 2)*z - pow(M_PI, 2)*pow(x, 2))*sin(4*M_PI*x*z), 2)/(pow(M_PI, 4)*pow(x, 7)))/pow(4.0*pow(M_PI, 2)*pow(z, 2)*pow(z - 2, 2)*pow(cos(4*M_PI*x*z), 2) + (1.0L/2.0L)*pow(2.0*M_PI*x*(z - 2)*cos(4*M_PI*x*z) - 0.0625*M_PI*(16*sin(4*M_PI*x)/(M_PI*pow(x, 2)) + 4*(8*pow(M_PI, 2)*pow(x, 2) + 1)*cos(4*M_PI*x)/(pow(M_PI, 2)*pow(x, 3)) + 4*(-4*M_PI*z*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) + M_PI*z*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - (-M_PI*z + M_PI)*cos(4*M_PI*x*z) + 4*(pow(M_PI, 2)*x*pow(z, 2) - 2*pow(M_PI, 2)*x*z)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 3)) - 3*(8*pow(M_PI, 2)*pow(x, 2) + 1)*sin(4*M_PI*x)/(pow(M_PI, 3)*pow(x, 4)) - 3*(4*(M_PI*x*z - M_PI*x)*cos(4*M_PI*x*z) + (8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 4))) + 0.5*sin(4*M_PI*x*z) + (2.0L/5.0L)*M_PI*cos(4*M_PI*x), 2) + pow(M_PI*x*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) - 0.25*M_PI*x*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - 0.25*M_PI*x*cos(4*M_PI*x*z) - (pow(M_PI, 2)*pow(x, 2)*z - pow(M_PI, 2)*pow(x, 2))*sin(4*M_PI*x*z), 2)/(pow(M_PI, 4)*pow(x, 6)), 4.0L/3.0L) - pow(2, 1.0L/3.0L)*(4.0*pow(M_PI, 2)*pow(x, 2)*(M_PI*x*z - M_PI*x)*cos(4*M_PI*x*z) + pow(M_PI, 2)*pow(x, 2)*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*sin(4*M_PI*x*z) + pow(M_PI, 2)*pow(x, 2)*sin(4*M_PI*x*z) - 8.0*M_PI*x*(pow(M_PI, 2)*pow(x, 2)*z - pow(M_PI, 2)*pow(x, 2))*cos(4*M_PI*x*z))/(pow(M_PI, 2)*pow(x, 3)*pow(4.0*pow(M_PI, 2)*pow(z, 2)*pow(z - 2, 2)*pow(cos(4*M_PI*x*z), 2) + (1.0L/2.0L)*pow(2.0*M_PI*x*(z - 2)*cos(4*M_PI*x*z) - 0.0625*M_PI*(16*sin(4*M_PI*x)/(M_PI*pow(x, 2)) + 4*(8*pow(M_PI, 2)*pow(x, 2) + 1)*cos(4*M_PI*x)/(pow(M_PI, 2)*pow(x, 3)) + 4*(-4*M_PI*z*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) + M_PI*z*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - (-M_PI*z + M_PI)*cos(4*M_PI*x*z) + 4*(pow(M_PI, 2)*x*pow(z, 2) - 2*pow(M_PI, 2)*x*z)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 3)) - 3*(8*pow(M_PI, 2)*pow(x, 2) + 1)*sin(4*M_PI*x)/(pow(M_PI, 3)*pow(x, 4)) - 3*(4*(M_PI*x*z - M_PI*x)*cos(4*M_PI*x*z) + (8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 4))) + 0.5*sin(4*M_PI*x*z) + (2.0L/5.0L)*M_PI*cos(4*M_PI*x), 2) + pow(M_PI*x*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) - 0.25*M_PI*x*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - 0.25*M_PI*x*cos(4*M_PI*x*z) - (pow(M_PI, 2)*pow(x, 2)*z - pow(M_PI, 2)*pow(x, 2))*sin(4*M_PI*x*z), 2)/(pow(M_PI, 4)*pow(x, 6)), 1.0L/3.0L)) - 1.0L/15.0L*pow(2, 1.0L/3.0L)*(M_PI*x*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) - 0.25*M_PI*x*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - 0.25*M_PI*x*cos(4*M_PI*x*z) + (-1.0*pow(M_PI, 2)*pow(x, 2)*z + pow(M_PI, 2)*pow(x, 2))*sin(4*M_PI*x*z))*(160.0*pow(M_PI, 3)*x*pow(z, 2)*pow(z - 2, 2)*sin(4*M_PI*x*z)*cos(4*M_PI*x*z) - 40.0*pow(M_PI, 2)*pow(z, 2)*(z - 2)*pow(cos(4*M_PI*x*z), 2) - 40.0*pow(M_PI, 2)*z*pow(z - 2, 2)*pow(cos(4*M_PI*x*z), 2) + (-8.0*pow(M_PI, 2)*pow(x, 2)*(z - 2)*sin(4*M_PI*x*z) + 4.0*M_PI*x*cos(4*M_PI*x*z) + 0.25*M_PI*((16*pow(M_PI, 2)*x*z*(M_PI*x*z - M_PI*x)*cos(4*M_PI*x*z) + 4*pow(M_PI, 2)*x*z*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*sin(4*M_PI*x*z) + 4*pow(M_PI, 2)*x*z*sin(4*M_PI*x*z) - 4*M_PI*x*(-M_PI*z + M_PI)*sin(4*M_PI*x*z) - 16*M_PI*x*(pow(M_PI, 2)*x*pow(z, 2) - 2*pow(M_PI, 2)*x*z)*cos(4*M_PI*x*z) - 16*M_PI*z*(pow(M_PI, 2)*pow(x, 2)*z - pow(M_PI, 2)*pow(x, 2))*cos(4*M_PI*x*z) + 4*M_PI*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) - 8*(pow(M_PI, 2)*x*z - pow(M_PI, 2)*x)*sin(4*M_PI*x*z) - M_PI*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - M_PI*cos(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 3)) + 3*(-4*M_PI*x*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) + M_PI*x*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) + M_PI*x*cos(4*M_PI*x*z) + 4*(pow(M_PI, 2)*pow(x, 2)*z - pow(M_PI, 2)*pow(x, 2))*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 4))))*(-10.0*M_PI*x*(z - 2)*cos(4*M_PI*x*z) + 0.3125*M_PI*(16*sin(4*M_PI*x)/(M_PI*pow(x, 2)) + 4*(8*pow(M_PI, 2)*pow(x, 2) + 1)*cos(4*M_PI*x)/(pow(M_PI, 2)*pow(x, 3)) + 4*(-4*M_PI*z*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) + M_PI*z*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - (-M_PI*z + M_PI)*cos(4*M_PI*x*z) + 4*(pow(M_PI, 2)*x*pow(z, 2) - 2*pow(M_PI, 2)*x*z)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 3)) - 3*(8*pow(M_PI, 2)*pow(x, 2) + 1)*sin(4*M_PI*x)/(pow(M_PI, 3)*pow(x, 4)) - 3*(4*(M_PI*x*z - M_PI*x)*cos(4*M_PI*x*z) + (8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 4))) - 2.5*sin(4*M_PI*x*z) - 2*M_PI*cos(4*M_PI*x)) - (10*M_PI*x*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) - 2.5*M_PI*x*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - 2.5*M_PI*x*cos(4*M_PI*x*z) - 10*(pow(M_PI, 2)*pow(x, 2)*z - pow(M_PI, 2)*pow(x, 2))*sin(4*M_PI*x*z))*(4*pow(M_PI, 2)*pow(x, 2)*(M_PI*x*z - M_PI*x)*cos(4*M_PI*x*z) + pow(M_PI, 2)*pow(x, 2)*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*sin(4*M_PI*x*z) + pow(M_PI, 2)*pow(x, 2)*sin(4*M_PI*x*z) - 8.0*M_PI*x*(pow(M_PI, 2)*pow(x, 2)*z - pow(M_PI, 2)*pow(x, 2))*cos(4*M_PI*x*z))/(pow(M_PI, 4)*pow(x, 6)))/(pow(M_PI, 2)*pow(x, 3)*pow(4.0*pow(M_PI, 2)*pow(z, 2)*pow(z - 2, 2)*pow(cos(4*M_PI*x*z), 2) + (1.0L/2.0L)*pow(2.0*M_PI*x*(z - 2)*cos(4*M_PI*x*z) - 0.0625*M_PI*(16*sin(4*M_PI*x)/(M_PI*pow(x, 2)) + 4*(8*pow(M_PI, 2)*pow(x, 2) + 1)*cos(4*M_PI*x)/(pow(M_PI, 2)*pow(x, 3)) + 4*(-4*M_PI*z*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) + M_PI*z*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - (-M_PI*z + M_PI)*cos(4*M_PI*x*z) + 4*(pow(M_PI, 2)*x*pow(z, 2) - 2*pow(M_PI, 2)*x*z)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 3)) - 3*(8*pow(M_PI, 2)*pow(x, 2) + 1)*sin(4*M_PI*x)/(pow(M_PI, 3)*pow(x, 4)) - 3*(4*(M_PI*x*z - M_PI*x)*cos(4*M_PI*x*z) + (8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*sin(4*M_PI*x*z))/(pow(M_PI, 3)*pow(x, 4))) + 0.5*sin(4*M_PI*x*z) + (2.0L/5.0L)*M_PI*cos(4*M_PI*x), 2) + pow(M_PI*x*(M_PI*x*z - M_PI*x)*sin(4*M_PI*x*z) - 0.25*M_PI*x*(8*pow(M_PI, 2)*pow(x, 2)*pow(z, 2) - 16*pow(M_PI, 2)*pow(x, 2)*z - 1)*cos(4*M_PI*x*z) - 0.25*M_PI*x*cos(4*M_PI*x*z) - (pow(M_PI, 2)*pow(x, 2)*z - pow(M_PI, 2)*pow(x, 2))*sin(4*M_PI*x*z), 2)/(pow(M_PI, 4)*pow(x, 6)), 4.0L/3.0L)); 101 116 case 21: 102 117 z=y; 103 return x + (4.0L/3.0L)*pow(2, 1.0L/3.0L)*(2*pow(z, 3)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 3*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) + z*(2*pow(x, 3) - 3*pow(x, 2) + x))*(4*(pow(x, 2)*z*(x - 1)*(z - 1)*(2*z - 1) + x*z*pow(x - 1, 2)*(z - 1)*(2*z - 1))*(2*pow(x, 2)*z*(x - 1)*(z - 1) + pow(x, 2)*z*(x - 1)*(2*z - 1) + pow(x, 2)*(x - 1)*(z - 1)*(2*z - 1) + 2*x*z*pow(x - 1, 2)*(z - 1) + x*z*pow(x - 1, 2)*(2*z - 1) + x*pow(x - 1, 2)*(z - 1)*(2*z - 1)) + 4*(2*pow(z, 3)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 3*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) + z*(2*pow(x, 3) - 3*pow(x, 2) + x))*(2*pow(x, 3) - 3*pow(x, 2) + x + 6*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 6*z*(2*pow(x, 3) - 3*pow(x, 2) + x)) + (2*pow(x, 2)*z*pow(x - 1, 2) + 2*pow(x, 2)*pow(x - 1, 2)*(z - 1) + pow(x, 2)*pow(x - 1, 2)*(2*z - 1) - 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) + 3*pow(z, 2)*(6*pow(x, 2) - 6*x + 1) - z*(6*pow(x, 2) - 6*x + 1))*(2*pow(x, 2)*z*pow(x - 1, 2)*(z - 1) + pow(x, 2)*z*pow(x - 1, 2)*(2*z - 1) + pow(x, 2)*pow(x - 1, 2)*(z - 1)*(2*z - 1) - pow(z, 4)*(6*pow(x, 2) - 6*x + 1) + 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - pow(z, 2)*(6*pow(x, 2) - 6*x + 1)))/pow(4*pow(pow(x, 2)*z*(x - 1)*(z - 1)*(2*z - 1) + x*z*pow(x - 1, 2)*(z - 1)*(2*z - 1), 2) + 4*pow(2*pow(z, 3)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 3*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) + z*(2*pow(x, 3) - 3*pow(x, 2) + x), 2) + (1.0L/2.0L)*pow(2*pow(x, 2)*z*pow(x - 1, 2)*(z - 1) + pow(x, 2)*z*pow(x - 1, 2)*(2*z - 1) + pow(x, 2)*pow(x - 1, 2)*(z - 1)*(2*z - 1) - pow(z, 4)*(6*pow(x, 2) - 6*x + 1) + 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - pow(z, 2)*(6*pow(x, 2) - 6*x + 1), 2), 4.0L/3.0L) - 1.0L/3.0L*pow(2, 1.0L/3.0L)*(4*(pow(x, 2)*z*(x - 1)*(z - 1)*(2*z - 1) + x*z*pow(x - 1, 2)*(z - 1)*(2*z - 1))*(pow(x, 2)*z*(z - 1)*(2*z - 1) + 4*x*z*(x - 1)*(z - 1)*(2*z - 1) + z*pow(x - 1, 2)*(z - 1)*(2*z - 1)) + 4*(2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - 3*pow(z, 2)*(6*pow(x, 2) - 6*x + 1) + z*(6*pow(x, 2) - 6*x + 1))*(2*pow(z, 3)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 3*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) + z*(2*pow(x, 3) - 3*pow(x, 2) + x)) + (2*pow(x, 2)*z*pow(x - 1, 2)*(z - 1) + pow(x, 2)*z*pow(x - 1, 2)*(2*z - 1) + pow(x, 2)*pow(x - 1, 2)*(z - 1)*(2*z - 1) - pow(z, 4)*(6*pow(x, 2) - 6*x + 1) + 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - pow(z, 2)*(6*pow(x, 2) - 6*x + 1))*(2*pow(x, 2)*z*(x - 1)*(z - 1) + pow(x, 2)*z*(x - 1)*(2*z - 1) + pow(x, 2)*(x - 1)*(z - 1)*(2*z - 1) + 2*x*z*pow(x - 1, 2)*(z - 1) + x*z*pow(x - 1, 2)*(2*z - 1) + x*pow(x - 1, 2)*(z - 1)*(2*z - 1) - 3*pow(z, 4)*(2*x - 1) + 6*pow(z, 3)*(2*x - 1) - 3*pow(z, 2)*(2*x - 1)))*(2*pow(x, 2)*z*pow(x - 1, 2)*(z - 1) + pow(x, 2)*z*pow(x - 1, 2)*(2*z - 1) + pow(x, 2)*pow(x - 1, 2)*(z - 1)*(2*z - 1) - pow(z, 4)*(6*pow(x, 2) - 6*x + 1) + 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - pow(z, 2)*(6*pow(x, 2) - 6*x + 1))/pow(4*pow(pow(x, 2)*z*(x - 1)*(z - 1)*(2*z - 1) + x*z*pow(x - 1, 2)*(z - 1)*(2*z - 1), 2) + 4*pow(2*pow(z, 3)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 3*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) + z*(2*pow(x, 3) - 3*pow(x, 2) + x), 2) + (1.0L/2.0L)*pow(2*pow(x, 2)*z*pow(x - 1, 2)*(z - 1) + pow(x, 2)*z*pow(x - 1, 2)*(2*z - 1) + pow(x, 2)*pow(x - 1, 2)*(z - 1)*(2*z - 1) - pow(z, 4)*(6*pow(x, 2) - 6*x + 1) + 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - pow(z, 2)*(6*pow(x, 2) - 6*x + 1), 2), 4.0L/3.0L) - 1.0L/2.0L - 2*pow(2, 1.0L/3.0L)*(2*pow(x, 3) - 3*pow(x, 2) + x + 6*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 6*z*(2*pow(x, 3) - 3*pow(x, 2) + x))/pow(4*pow(pow(x, 2)*z*(x - 1)*(z - 1)*(2*z - 1) + x*z*pow(x - 1, 2)*(z - 1)*(2*z - 1), 2) + 4*pow(2*pow(z, 3)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 3*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) + z*(2*pow(x, 3) - 3*pow(x, 2) + x), 2) + (1.0L/2.0L)*pow(2*pow(x, 2)*z*pow(x - 1, 2)*(z - 1) + pow(x, 2)*z*pow(x - 1, 2)*(2*z - 1) + pow(x, 2)*pow(x - 1, 2)*(z - 1)*(2*z - 1) - pow(z, 4)*(6*pow(x, 2) - 6*x + 1) + 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - pow(z, 2)*(6*pow(x, 2) - 6*x + 1), 2), 1.0L/3.0L) + pow(2, 1.0L/3.0L)*(2*pow(x, 2)*z*(x - 1)*(z - 1) + pow(x, 2)*z*(x - 1)*(2*z - 1) + pow(x, 2)*(x - 1)*(z - 1)*(2*z - 1) + 2*x*z*pow(x - 1, 2)*(z - 1) + x*z*pow(x - 1, 2)*(2*z - 1) + x*pow(x - 1, 2)*(z - 1)*(2*z - 1) - 3*pow(z, 4)*(2*x - 1) + 6*pow(z, 3)*(2*x - 1) - 3*pow(z, 2)*(2*x - 1))/pow(4*pow(pow(x, 2)*z*(x - 1)*(z - 1)*(2*z - 1) + x*z*pow(x - 1, 2)*(z - 1)*(2*z - 1), 2) + 4*pow(2*pow(z, 3)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 3*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) + z*(2*pow(x, 3) - 3*pow(x, 2) + x), 2) + (1.0L/2.0L)*pow(2*pow(x, 2)*z*pow(x - 1, 2)*(z - 1) + pow(x, 2)*z*pow(x - 1, 2)*(2*z - 1) + pow(x, 2)*pow(x - 1, 2)*(z - 1)*(2*z - 1) - pow(z, 4)*(6*pow(x, 2) - 6*x + 1) + 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - pow(z, 2)*(6*pow(x, 2) - 6*x + 1), 2), 1.0L/3.0L); 118 return x + (4.0L/3.0L)*pow(2, 1.0L/3.0L)*(2*pow(z, 3)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 3*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) + z*(2*pow(x, 3) - 3*pow(x, 2) + x))*(4*(pow(x, 2)*z*(x - 1)*(z - 1)*(2*z - 1) + x*z*pow(x - 1, 2)*(z - 1)*(2*z - 1))*(2*pow(x, 2)*z*(x - 1)*(z - 1) + pow(x, 2)*z*(x - 1)*(2*z - 1) + pow(x, 2)*(x - 1)*(z - 1)*(2*z - 1) + 2*x*z*pow(x - 1, 2)*(z - 1) + x*z*pow(x - 1, 2)*(2*z - 1) + x*pow(x - 1, 2)*(z - 1)*(2*z - 1)) + 4*(2*pow(z, 3)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 3*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) + z*(2*pow(x, 3) - 3*pow(x, 2) + x))*(2*pow(x, 3) - 3*pow(x, 2) + x + 6*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 6*z*(2*pow(x, 3) - 3*pow(x, 2) + x)) + (2*pow(x, 2)*z*pow(x - 1, 2) + 2*pow(x, 2)*pow(x - 1, 2)*(z - 1) + pow(x, 2)*pow(x - 1, 2)*(2*z - 1) - 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) + 3*pow(z, 2)*(6*pow(x, 2) - 6*x + 1) - z*(6*pow(x, 2) - 6*x + 1))*(2*pow(x, 2)*z*pow(x - 1, 2)*(z - 1) + pow(x, 2)*z*pow(x - 1, 2)*(2*z - 1) + pow(x, 2)*pow(x - 1, 2)*(z - 1)*(2*z - 1) - pow(z, 4)*(6*pow(x, 2) - 6*x + 1) + 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - pow(z, 2)*(6*pow(x, 2) - 6*x + 1)))/pow(4*pow(pow(x, 2)*z*(x - 1)*(z - 1)*(2*z - 1) + x*z*pow(x - 1, 2)*(z - 1)*(2*z - 1), 2) + 4*pow(2*pow(z, 3)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 3*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) + z*(2*pow(x, 3) - 3*pow(x, 2) + x), 2) + (1.0L/2.0L)*pow(2*pow(x, 2)*z*pow(x - 1, 2)*(z - 1) + pow(x, 2)*z*pow(x - 1, 2)*(2*z - 1) + pow(x, 2)*pow(x - 1, 2)*(z - 1)*(2*z - 1) - pow(z, 4)*(6*pow(x, 2) - 6*x + 1) + 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - pow(z, 2)*(6*pow(x, 2) - 6*x + 1), 2), 4.0L/3.0L) - 1.0L/3.0L*pow(2, 1.0L/3.0L)*(4*(pow(x, 2)*z*(x - 1)*(z - 1)*(2*z - 1) + x*z*pow(x - 1, 2)*(z - 1)*(2*z - 1))*(pow(x, 2)*z*(z - 1)*(2*z - 1) + 4*x*z*(x - 1)*(z - 1)*(2*z - 1) + z*pow(x - 1, 2)*(z - 1)*(2*z - 1)) + 4*(2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - 3*pow(z, 2)*(6*pow(x, 2) - 6*x + 1) + z*(6*pow(x, 2) - 6*x + 1))*(2*pow(z, 3)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 3*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) + z*(2*pow(x, 3) - 3*pow(x, 2) + x)) + (2*pow(x, 2)*z*pow(x - 1, 2)*(z - 1) + pow(x, 2)*z*pow(x - 1, 2)*(2*z - 1) + pow(x, 2)*pow(x - 1, 2)*(z - 1)*(2*z - 1) - pow(z, 4)*(6*pow(x, 2) - 6*x + 1) + 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - pow(z, 2)*(6*pow(x, 2) - 6*x + 1))*(2*pow(x, 2)*z*(x - 1)*(z - 1) + pow(x, 2)*z*(x - 1)*(2*z - 1) + pow(x, 2)*(x - 1)*(z - 1)*(2*z - 1) + 2*x*z*pow(x - 1, 2)*(z - 1) + x*z*pow(x - 1, 2)*(2*z - 1) + x*pow(x - 1, 2)*(z - 1)*(2*z - 1) - 3*pow(z, 4)*(2*x - 1) + 6*pow(z, 3)*(2*x - 1) - 3*pow(z, 2)*(2*x - 1)))*(2*pow(x, 2)*z*pow(x - 1, 2)*(z - 1) + pow(x, 2)*z*pow(x - 1, 2)*(2*z - 1) + pow(x, 2)*pow(x - 1, 2)*(z - 1)*(2*z - 1) - pow(z, 4)*(6*pow(x, 2) - 6*x + 1) + 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - pow(z, 2)*(6*pow(x, 2) - 6*x + 1))/pow(4*pow(pow(x, 2)*z*(x - 1)*(z - 1)*(2*z - 1) + x*z*pow(x - 1, 2)*(z - 1)*(2*z - 1), 2) + 4*pow(2*pow(z, 3)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 3*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) + z*(2*pow(x, 3) - 3*pow(x, 2) + x), 2) + (1.0L/2.0L)*pow(2*pow(x, 2)*z*pow(x - 1, 2)*(z - 1) + pow(x, 2)*z*pow(x - 1, 2)*(2*z - 1) + pow(x, 2)*pow(x - 1, 2)*(z - 1)*(2*z - 1) - pow(z, 4)*(6*pow(x, 2) - 6*x + 1) + 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - pow(z, 2)*(6*pow(x, 2) - 6*x + 1), 2), 4.0L/3.0L) - 0.5 - 2*pow(2, 1.0L/3.0L)*(2*pow(x, 3) - 3*pow(x, 2) + x + 6*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 6*z*(2*pow(x, 3) - 3*pow(x, 2) + x))/pow(4*pow(pow(x, 2)*z*(x - 1)*(z - 1)*(2*z - 1) + x*z*pow(x - 1, 2)*(z - 1)*(2*z - 1), 2) + 4*pow(2*pow(z, 3)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 3*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) + z*(2*pow(x, 3) - 3*pow(x, 2) + x), 2) + (1.0L/2.0L)*pow(2*pow(x, 2)*z*pow(x - 1, 2)*(z - 1) + pow(x, 2)*z*pow(x - 1, 2)*(2*z - 1) + pow(x, 2)*pow(x - 1, 2)*(z - 1)*(2*z - 1) - pow(z, 4)*(6*pow(x, 2) - 6*x + 1) + 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - pow(z, 2)*(6*pow(x, 2) - 6*x + 1), 2), 1.0L/3.0L) + pow(2, 1.0L/3.0L)*(2*pow(x, 2)*z*(x - 1)*(z - 1) + pow(x, 2)*z*(x - 1)*(2*z - 1) + pow(x, 2)*(x - 1)*(z - 1)*(2*z - 1) + 2*x*z*pow(x - 1, 2)*(z - 1) + x*z*pow(x - 1, 2)*(2*z - 1) + x*pow(x - 1, 2)*(z - 1)*(2*z - 1) - 3*pow(z, 4)*(2*x - 1) + 6*pow(z, 3)*(2*x - 1) - 3*pow(z, 2)*(2*x - 1))/pow(4*pow(pow(x, 2)*z*(x - 1)*(z - 1)*(2*z - 1) + x*z*pow(x - 1, 2)*(z - 1)*(2*z - 1), 2) + 4*pow(2*pow(z, 3)*(2*pow(x, 3) - 3*pow(x, 2) + x) - 3*pow(z, 2)*(2*pow(x, 3) - 3*pow(x, 2) + x) + z*(2*pow(x, 3) - 3*pow(x, 2) + x), 2) + (1.0L/2.0L)*pow(2*pow(x, 2)*z*pow(x - 1, 2)*(z - 1) + pow(x, 2)*z*pow(x - 1, 2)*(2*z - 1) + pow(x, 2)*pow(x - 1, 2)*(z - 1)*(2*z - 1) - pow(z, 4)*(6*pow(x, 2) - 6*x + 1) + 2*pow(z, 3)*(6*pow(x, 2) - 6*x + 1) - pow(z, 2)*(6*pow(x, 2) - 6*x + 1), 2), 1.0L/3.0L); 119 case 22: 120 z=y; 121 return (2.0L/9.0L)*pow(2, 1.0L/3.0L)*(4*pow(z, 3)*(pow(x, 3) - 3*pow(x, 2) + 2*x) - 16*pow(z, 2)*(pow(x, 3) - 3*pow(x, 2) + 2*x) + 16*z*(pow(x, 3) - 3*pow(x, 2) + 2*x) + 1)*(48*pow(x, 8) - 384*pow(x, 7) + 1152*pow(x, 6) - 1536*pow(x, 5) + 768*pow(x, 4) - 96*pow(x, 3) + 288*pow(x, 2) - 192*x - 6*pow(z, 7)*(9*pow(x, 4) - 36*pow(x, 3) + 48*pow(x, 2) - 24*x + 4) + 56*pow(z, 6)*(9*pow(x, 4) - 36*pow(x, 3) + 48*pow(x, 2) - 24*x + 4) - pow(z, 5)*(207*pow(x, 6) - 1242*pow(x, 5) + 4518*pow(x, 4) - 9792*pow(x, 3) + 10536*pow(x, 2) - 4800*x + 800) + 20*pow(z, 4)*(69*pow(x, 6) - 414*pow(x, 5) + 1050*pow(x, 4) - 1440*pow(x, 3) + 1080*pow(x, 2) - 384*x + 64) - pow(z, 3)*(27*pow(x, 8) - 216*pow(x, 7) + 3984*pow(x, 6) - 20880*pow(x, 5) + 45952*pow(x, 4) - 48640*pow(x, 3) + 24256*pow(x, 2) - 4608*x + 768) + 12*pow(z, 2)*(9*pow(x, 8) - 72*pow(x, 7) + 504*pow(x, 6) - 2016*pow(x, 5) + 3920*pow(x, 4) - 3590*pow(x, 3) + 1298*pow(x, 2) - 12*x) - 12*z*(11*pow(x, 8) - 88*pow(x, 7) + 368*pow(x, 6) - 976*pow(x, 5) + 1536*pow(x, 4) - 1296*pow(x, 3) + 496*pow(x, 2) - 32*x))/pow(8*pow(x, 8) - 64*pow(x, 7) + 192*pow(x, 6) - 256*pow(x, 5) + 128*pow(x, 4) + (1.0L/2.0L)*pow(z, 8)*(9*pow(x, 4) - 36*pow(x, 3) + 48*pow(x, 2) - 24*x + 4) - 16.0L/3.0L*pow(z, 7)*(9*pow(x, 4) - 36*pow(x, 3) + 48*pow(x, 2) - 24*x + 4) + (1.0L/9.0L)*pow(z, 6)*(207*pow(x, 6) - 1242*pow(x, 5) + 4518*pow(x, 4) - 9792*pow(x, 3) + 10536*pow(x, 2) - 4800*x + 800) - 8.0L/3.0L*pow(z, 5)*(69*pow(x, 6) - 414*pow(x, 5) + 1050*pow(x, 4) - 1440*pow(x, 3) + 1080*pow(x, 2) - 384*x + 64) + (1.0L/6.0L)*pow(z, 4)*(27*pow(x, 8) - 216*pow(x, 7) + 3984*pow(x, 6) - 20880*pow(x, 5) + 45952*pow(x, 4) - 48640*pow(x, 3) + 24256*pow(x, 2) - 4608*x + 768) - 8.0L/3.0L*pow(z, 3)*(9*pow(x, 8) - 72*pow(x, 7) + 504*pow(x, 6) - 2016*pow(x, 5) + 3920*pow(x, 4) - 3590*pow(x, 3) + 1298*pow(x, 2) - 12*x) + 4*pow(z, 2)*(11*pow(x, 8) - 88*pow(x, 7) + 368*pow(x, 6) - 976*pow(x, 5) + 1536*pow(x, 4) - 1296*pow(x, 3) + 496*pow(x, 2) - 32*x) - 32*z*(pow(x, 8) - 8*pow(x, 7) + 24*pow(x, 6) - 32*pow(x, 5) + 16*pow(x, 4) - 2*pow(x, 3) + 6*pow(x, 2) - 4*x) + 2, 4.0L/3.0L) + 4*pow(2, 1.0L/3.0L)*(4*pow(x, 3) - 12*pow(x, 2) + 8*x + 3*pow(z, 2)*(pow(x, 3) - 3*pow(x, 2) + 2*x) - 8*z*(pow(x, 3) - 3*pow(x, 2) + 2*x))/pow(8*pow(x, 8) - 64*pow(x, 7) + 192*pow(x, 6) - 256*pow(x, 5) + 128*pow(x, 4) + (1.0L/2.0L)*pow(z, 8)*(9*pow(x, 4) - 36*pow(x, 3) + 48*pow(x, 2) - 24*x + 4) - 16.0L/3.0L*pow(z, 7)*(9*pow(x, 4) - 36*pow(x, 3) + 48*pow(x, 2) - 24*x + 4) + (1.0L/9.0L)*pow(z, 6)*(207*pow(x, 6) - 1242*pow(x, 5) + 4518*pow(x, 4) - 9792*pow(x, 3) + 10536*pow(x, 2) - 4800*x + 800) - 8.0L/3.0L*pow(z, 5)*(69*pow(x, 6) - 414*pow(x, 5) + 1050*pow(x, 4) - 1440*pow(x, 3) + 1080*pow(x, 2) - 384*x + 64) + (1.0L/6.0L)*pow(z, 4)*(27*pow(x, 8) - 216*pow(x, 7) + 3984*pow(x, 6) - 20880*pow(x, 5) + 45952*pow(x, 4) - 48640*pow(x, 3) + 24256*pow(x, 2) - 4608*x + 768) - 8.0L/3.0L*pow(z, 3)*(9*pow(x, 8) - 72*pow(x, 7) + 504*pow(x, 6) - 2016*pow(x, 5) + 3920*pow(x, 4) - 3590*pow(x, 3) + 1298*pow(x, 2) - 12*x) + 4*pow(z, 2)*(11*pow(x, 8) - 88*pow(x, 7) + 368*pow(x, 6) - 976*pow(x, 5) + 1536*pow(x, 4) - 1296*pow(x, 3) + 496*pow(x, 2) - 32*x) - 32*z*(pow(x, 8) - 8*pow(x, 7) + 24*pow(x, 6) - 32*pow(x, 5) + 16*pow(x, 4) - 2*pow(x, 3) + 6*pow(x, 2) - 4*x) + 2, 1.0L/3.0L) + (1.0L/27.0L)*pow(2, 1.0L/3.0L)*(6*pow(x, 2)*z*pow(x - 2, 2)*(z - 2) + 3*pow(x, 2)*pow(x - 2, 2)*pow(z - 2, 2) - 3*pow(z, 4)*(3*pow(x, 2) - 6*x + 2) + 16*pow(z, 3)*(3*pow(x, 2) - 6*x + 2) - 24*pow(z, 2)*(3*pow(x, 2) - 6*x + 2))*(96*pow(x, 7) - 672*pow(x, 6) + 1728*pow(x, 5) - 1920*pow(x, 4) + 768*pow(x, 3) + 9*pow(z, 8)*(3*pow(x, 3) - 9*pow(x, 2) + 8*x - 2) - 96*pow(z, 7)*(3*pow(x, 3) - 9*pow(x, 2) + 8*x - 2) + pow(z, 6)*(207*pow(x, 5) - 1035*pow(x, 4) + 3012*pow(x, 3) - 4896*pow(x, 2) + 3512*x - 800) - 24*pow(z, 5)*(69*pow(x, 5) - 345*pow(x, 4) + 700*pow(x, 3) - 720*pow(x, 2) + 360*x - 64) + 2*pow(z, 4)*(27*pow(x, 7) - 189*pow(x, 6) + 2988*pow(x, 5) - 13050*pow(x, 4) + 22976*pow(x, 3) - 18240*pow(x, 2) + 6064*x - 576) - 8*pow(z, 3)*(36*pow(x, 7) - 252*pow(x, 6) + 1512*pow(x, 5) - 5040*pow(x, 4) + 7840*pow(x, 3) - 5385*pow(x, 2) + 1298*x - 6) + 48*pow(z, 2)*(11*pow(x, 7) - 77*pow(x, 6) + 276*pow(x, 5) - 610*pow(x, 4) + 768*pow(x, 3) - 486*pow(x, 2) + 124*x - 4) - 96*z*(4*pow(x, 7) - 28*pow(x, 6) + 72*pow(x, 5) - 80*pow(x, 4) + 32*pow(x, 3) - 3*pow(x, 2) + 6*x - 2))/pow(8*pow(x, 8) - 64*pow(x, 7) + 192*pow(x, 6) - 256*pow(x, 5) + 128*pow(x, 4) + (1.0L/2.0L)*pow(z, 8)*(9*pow(x, 4) - 36*pow(x, 3) + 48*pow(x, 2) - 24*x + 4) - 16.0L/3.0L*pow(z, 7)*(9*pow(x, 4) - 36*pow(x, 3) + 48*pow(x, 2) - 24*x + 4) + (1.0L/9.0L)*pow(z, 6)*(207*pow(x, 6) - 1242*pow(x, 5) + 4518*pow(x, 4) - 9792*pow(x, 3) + 10536*pow(x, 2) - 4800*x + 800) - 8.0L/3.0L*pow(z, 5)*(69*pow(x, 6) - 414*pow(x, 5) + 1050*pow(x, 4) - 1440*pow(x, 3) + 1080*pow(x, 2) - 384*x + 64) + (1.0L/6.0L)*pow(z, 4)*(27*pow(x, 8) - 216*pow(x, 7) + 3984*pow(x, 6) - 20880*pow(x, 5) + 45952*pow(x, 4) - 48640*pow(x, 3) + 24256*pow(x, 2) - 4608*x + 768) - 8.0L/3.0L*pow(z, 3)*(9*pow(x, 8) - 72*pow(x, 7) + 504*pow(x, 6) - 2016*pow(x, 5) + 3920*pow(x, 4) - 3590*pow(x, 3) + 1298*pow(x, 2) - 12*x) + 4*pow(z, 2)*(11*pow(x, 8) - 88*pow(x, 7) + 368*pow(x, 6) - 976*pow(x, 5) + 1536*pow(x, 4) - 1296*pow(x, 3) + 496*pow(x, 2) - 32*x) - 32*z*(pow(x, 8) - 8*pow(x, 7) + 24*pow(x, 6) - 32*pow(x, 5) + 16*pow(x, 4) - 2*pow(x, 3) + 6*pow(x, 2) - 4*x) + 2, 4.0L/3.0L) - pow(2, 1.0L/3.0L)*(2*pow(x, 2)*z*(x - 2)*(z - 2) + pow(x, 2)*(x - 2)*pow(z - 2, 2) + 2*x*z*pow(x - 2, 2)*(z - 2) + x*pow(x - 2, 2)*pow(z - 2, 2) - 3*pow(z, 4)*(x - 1) + 16*pow(z, 3)*(x - 1) - 24*pow(z, 2)*(x - 1))/pow(8*pow(x, 8) - 64*pow(x, 7) + 192*pow(x, 6) - 256*pow(x, 5) + 128*pow(x, 4) + (1.0L/2.0L)*pow(z, 8)*(9*pow(x, 4) - 36*pow(x, 3) + 48*pow(x, 2) - 24*x + 4) - 16.0L/3.0L*pow(z, 7)*(9*pow(x, 4) - 36*pow(x, 3) + 48*pow(x, 2) - 24*x + 4) + (1.0L/9.0L)*pow(z, 6)*(207*pow(x, 6) - 1242*pow(x, 5) + 4518*pow(x, 4) - 9792*pow(x, 3) + 10536*pow(x, 2) - 4800*x + 800) - 8.0L/3.0L*pow(z, 5)*(69*pow(x, 6) - 414*pow(x, 5) + 1050*pow(x, 4) - 1440*pow(x, 3) + 1080*pow(x, 2) - 384*x + 64) + (1.0L/6.0L)*pow(z, 4)*(27*pow(x, 8) - 216*pow(x, 7) + 3984*pow(x, 6) - 20880*pow(x, 5) + 45952*pow(x, 4) - 48640*pow(x, 3) + 24256*pow(x, 2) - 4608*x + 768) - 8.0L/3.0L*pow(z, 3)*(9*pow(x, 8) - 72*pow(x, 7) + 504*pow(x, 6) - 2016*pow(x, 5) + 3920*pow(x, 4) - 3590*pow(x, 3) + 1298*pow(x, 2) - 12*x) + 4*pow(z, 2)*(11*pow(x, 8) - 88*pow(x, 7) + 368*pow(x, 6) - 976*pow(x, 5) + 1536*pow(x, 4) - 1296*pow(x, 3) + 496*pow(x, 2) - 32*x) - 32*z*(pow(x, 8) - 8*pow(x, 7) + 24*pow(x, 6) - 32*pow(x, 5) + 16*pow(x, 4) - 2*pow(x, 3) + 6*pow(x, 2) - 4*x) + 2, 1.0L/3.0L) - 10; 104 122 case 24: 105 123 return -pow(2, 1.0L/3.0L)*pow(PI, 2)*pow(p, 2)*sin(PI*p*x)*sin(PI*p*z)*cos(PI*p*y)/pow(6*pow(PI, 2)*pow(p, 2)*pow(sin(PI*p*x), 2)*pow(sin(PI*p*y), 2)*pow(sin(PI*p*z), 2) + (1.0L/2.0L)*pow(-2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*z)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*z)*cos(PI*p*x), 2) + (1.0L/2.0L)*pow(pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*x)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*x)*cos(PI*p*z), 2) + (1.0L/2.0L)*pow(pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*y)*cos(PI*p*x) - 2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*y)*cos(PI*p*z), 2), 1.0L/3.0L) + (1.0L/3.0L)*pow(2, 1.0L/3.0L)*PI*p*(12*pow(PI, 3)*pow(p, 3)*pow(sin(PI*p*x), 2)*sin(PI*p*y)*pow(sin(PI*p*z), 2)*cos(PI*p*y) + (-2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*z)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*z)*cos(PI*p*x))*(2*pow(PI, 2)*pow(p, 2)*(cos(PI*p*x) - 1)*sin(PI*p*y)*sin(PI*p*z) - pow(PI, 2)*pow(p, 2)*sin(PI*p*y)*sin(PI*p*z)*cos(PI*p*x)) - (pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*x)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*x)*cos(PI*p*z))*(pow(PI, 3)*pow(p, 3)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*x)*sin(PI*p*y) + pow(PI, 2)*pow(p, 2)*sin(PI*p*x)*sin(PI*p*y)*cos(PI*p*z)) + (pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*y)*cos(PI*p*x) - 2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*y)*cos(PI*p*z))*(pow(PI, 3)*pow(p, 3)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*cos(PI*p*x)*cos(PI*p*y) - 2*pow(PI, 2)*pow(p, 2)*(cos(PI*p*x) - 1)*cos(PI*p*y)*cos(PI*p*z)))*sin(PI*p*x)*sin(PI*p*y)*sin(PI*p*z)/pow(6*pow(PI, 2)*pow(p, 2)*pow(sin(PI*p*x), 2)*pow(sin(PI*p*y), 2)*pow(sin(PI*p*z), 2) + (1.0L/2.0L)*pow(-2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*z)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*z)*cos(PI*p*x), 2) + (1.0L/2.0L)*pow(pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*x)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*x)*cos(PI*p*z), 2) + (1.0L/2.0L)*pow(pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*y)*cos(PI*p*x) - 2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*y)*cos(PI*p*z), 2), 4.0L/3.0L) + PI*q*sin(PI*q*x)*sin(PI*q*z)*cos(PI*q*y) - 1.0L/6.0L*pow(2, 1.0L/3.0L)*(-2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*z)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*z)*cos(PI*p*x))*(12*pow(PI, 3)*pow(p, 3)*sin(PI*p*x)*pow(sin(PI*p*y), 2)*pow(sin(PI*p*z), 2)*cos(PI*p*x) - (-2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*z)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*z)*cos(PI*p*x))*(pow(PI, 2)*pow(p, 2)*(cos(PI*p*y) - 1)*sin(PI*p*x)*sin(PI*p*z) - 2*pow(PI, 2)*pow(p, 2)*sin(PI*p*x)*sin(PI*p*z)*cos(PI*p*y)) + (pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*x)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*x)*cos(PI*p*z))*(pow(PI, 3)*pow(p, 3)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*cos(PI*p*x)*cos(PI*p*y) + pow(PI, 2)*pow(p, 2)*(cos(PI*p*y) - 1)*cos(PI*p*x)*cos(PI*p*z)) - (pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*y)*cos(PI*p*x) - 2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*y)*cos(PI*p*z))*(pow(PI, 3)*pow(p, 3)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*x)*sin(PI*p*y) - 2*pow(PI, 2)*pow(p, 2)*sin(PI*p*x)*sin(PI*p*y)*cos(PI*p*z)))/pow(6*pow(PI, 2)*pow(p, 2)*pow(sin(PI*p*x), 2)*pow(sin(PI*p*y), 2)*pow(sin(PI*p*z), 2) + (1.0L/2.0L)*pow(-2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*z)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*z)*cos(PI*p*x), 2) + (1.0L/2.0L)*pow(pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*x)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*x)*cos(PI*p*z), 2) + (1.0L/2.0L)*pow(pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*y)*cos(PI*p*x) - 2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*y)*cos(PI*p*z), 2), 4.0L/3.0L) - 1.0L/6.0L*pow(2, 1.0L/3.0L)*(pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*x)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*x)*cos(PI*p*z))*(12*pow(PI, 3)*pow(p, 3)*pow(sin(PI*p*x), 2)*pow(sin(PI*p*y), 2)*sin(PI*p*z)*cos(PI*p*z) + (-2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*z)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*z)*cos(PI*p*x))*(-2*pow(PI, 2)*pow(p, 2)*(cos(PI*p*x) - 1)*cos(PI*p*y)*cos(PI*p*z) + pow(PI, 2)*pow(p, 2)*(cos(PI*p*y) - 1)*cos(PI*p*x)*cos(PI*p*z)) - (pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*x)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*x)*cos(PI*p*z))*(pow(PI, 2)*pow(p, 2)*(cos(PI*p*y) - 1)*sin(PI*p*x)*sin(PI*p*z) + pow(PI, 2)*pow(p, 2)*sin(PI*p*x)*sin(PI*p*z)*cos(PI*p*y)) + (pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*y)*cos(PI*p*x) - 2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*y)*cos(PI*p*z))*(2*pow(PI, 2)*pow(p, 2)*(cos(PI*p*x) - 1)*sin(PI*p*y)*sin(PI*p*z) - pow(PI, 2)*pow(p, 2)*sin(PI*p*y)*sin(PI*p*z)*cos(PI*p*x)))/pow(6*pow(PI, 2)*pow(p, 2)*pow(sin(PI*p*x), 2)*pow(sin(PI*p*y), 2)*pow(sin(PI*p*z), 2) + (1.0L/2.0L)*pow(-2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*z)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*z)*cos(PI*p*x), 2) + (1.0L/2.0L)*pow(pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*x)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*x)*cos(PI*p*z), 2) + (1.0L/2.0L)*pow(pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*y)*cos(PI*p*x) - 2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*y)*cos(PI*p*z), 2), 4.0L/3.0L) - 1.0L/2.0L*pow(2, 1.0L/3.0L)*(pow(PI, 2)*pow(p, 2)*(cos(PI*p*y) - 1)*sin(PI*p*x)*sin(PI*p*z) - 2*pow(PI, 2)*pow(p, 2)*sin(PI*p*x)*sin(PI*p*z)*cos(PI*p*y))/pow(6*pow(PI, 2)*pow(p, 2)*pow(sin(PI*p*x), 2)*pow(sin(PI*p*y), 2)*pow(sin(PI*p*z), 2) + (1.0L/2.0L)*pow(-2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*z)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*z)*cos(PI*p*x), 2) + (1.0L/2.0L)*pow(pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*x)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*x)*cos(PI*p*z), 2) + (1.0L/2.0L)*pow(pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*y)*cos(PI*p*x) - 2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*y)*cos(PI*p*z), 2), 1.0L/3.0L) - 1.0L/2.0L*pow(2, 1.0L/3.0L)*(pow(PI, 2)*pow(p, 2)*(cos(PI*p*y) - 1)*sin(PI*p*x)*sin(PI*p*z) + pow(PI, 2)*pow(p, 2)*sin(PI*p*x)*sin(PI*p*z)*cos(PI*p*y))/pow(6*pow(PI, 2)*pow(p, 2)*pow(sin(PI*p*x), 2)*pow(sin(PI*p*y), 2)*pow(sin(PI*p*z), 2) + (1.0L/2.0L)*pow(-2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*z)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*z)*cos(PI*p*x), 2) + (1.0L/2.0L)*pow(pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*x)*cos(PI*p*y) + PI*p*(cos(PI*p*y) - 1)*sin(PI*p*x)*cos(PI*p*z), 2) + (1.0L/2.0L)*pow(pow(PI, 2)*pow(p, 2)*(cos(PI*p*z)/(PI*p) - 1/(PI*p))*sin(PI*p*y)*cos(PI*p*x) - 2*PI*p*(cos(PI*p*x) - 1)*sin(PI*p*y)*cos(PI*p*z), 2), 1.0L/3.0L); … … 118 136 119 137 switch(testid){ 120 case 1: case 2: case 7: case 8: case 11: case 12: case 1 8: case 21:138 case 1: case 2: case 7: case 8: case 11: case 12: case 13: case 14: case 18: case 21: case 22: 121 139 return 0.; 122 140 case 3: … … 144 162 145 163 switch(testid){ 146 case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: case 21:164 case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 21: case 22: 147 165 return 0.; 148 166 case 18: -
issm/trunk/src/c/shared/Matrix/MatrixUtils.cpp
r18301 r19105 333 333 334 334 }/*}}}*/ 335 void Matrix2x2Eigen(IssmDouble* plambda1,IssmDouble* plambda2,IssmDouble* pvx, IssmDouble* pvy,IssmDouble a11, IssmDouble a21,IssmDouble a22){/*{{{*/ 336 /*From symetric matrix (a11,a21;a21,a22), get eigen values lambda1 and lambda2 and one eigen vector v*/ 337 338 /*Output*/ 339 IssmDouble lambda1,lambda2; 340 IssmDouble vx,vy; 341 342 /*To get the eigen values, we must solve the following equation: 343 * | a11 - lambda a21 | 344 * det | | = 0 345 * | a21 a22-lambda | 346 * 347 * We have to solve the following polynom: 348 * lamda^2 + ( -a11 -a22)*lambda + (a11*a22-a21*a21) = 0*/ 349 350 /*Compute polynom determinant*/ 351 IssmDouble b=-a11-a22; 352 IssmDouble delta=b*b - 4*(a11*a22-a21*a21); 353 354 /*Compute norm of M to avoid round off errors*/ 355 IssmDouble normM=a11*a11 + a22*a22 + a21*a21; 356 357 /*1: normM too small: eigen values = 0*/ 358 if(normM<1.e-30){ 359 lambda1=0.; 360 lambda2=0.; 361 vx=1.; 362 vy=0.; 363 } 364 /*2: delta is small -> double root*/ 365 else if (delta < 1.e-5*normM){ 366 lambda1=-b/2.; 367 lambda2=-b/2.; 368 vx=1.; 369 vy=0.; 370 } 371 /*3: general case -> two roots*/ 372 else{ 373 delta = sqrt(delta); 374 lambda1 = (-b-delta)/2.; 375 lambda2 = (-b+delta)/2.; 376 377 /*Now, one must find the eigen vectors. For that we use the following property of the inner product 378 * <Ax,y> = <x,tAy> 379 * Here, M'(M-lambda*Id) is symmetrical, which gives: 380 * ∀(x,y)∈R²xR² <M'x,y> = <M'y,x> 381 * And we have the following: 382 * if y∈Ker(M'), ∀x∈R² <M'x,y> = <x,M'y> = 0 383 * We have shown that 384 * Im(M') ⊥ Ker(M') 385 * 386 * To find the eigen vectors of M, we only have to find two vectors 387 * of the image of M' and take their perpendicular as long as they are 388 * not 0. 389 * To do that, we take the images (1,0) and (0,1): 390 * x1 = (a11 - lambda) x2 = a21 391 * y1 = a21 y2 = (a22-lambda) 392 * 393 * We take the vector that has the larger norm and take its perpendicular.*/ 394 395 IssmDouble norm1 = (a11-lambda1)*(a11-lambda1) + a21*a21; 396 IssmDouble norm2 = a21*a21 + (a22-lambda1)*(a22-lambda1); 397 398 if(norm2<norm1){ 399 norm1=sqrt(norm1); 400 vx = - a21/norm1; 401 vy = (a11-lambda1)/norm1; 402 } 403 else{ 404 norm2=sqrt(norm2); 405 vx = - (a22-lambda1)/norm2; 406 vy = a21/norm2; 407 } 408 } 409 410 /*Assign output*/ 411 *plambda1 = lambda1; 412 *plambda2 = lambda2; 413 *pvx = vx; 414 *pvy = vy; 415 416 417 }/*}}}*/ 335 418 336 419 void Matrix3x3Determinant(IssmDouble* Adet,IssmDouble* A){/*{{{*/ -
issm/trunk/src/c/shared/Matrix/matrix.h
r18301 r19105 14 14 void Matrix2x2Invert(IssmDouble* Ainv, IssmDouble* A); 15 15 void Matrix2x2Determinant(IssmDouble* Adet,IssmDouble* A); 16 void Matrix2x2Eigen(IssmDouble* plambda1,IssmDouble* plambda2,IssmDouble* pvx, IssmDouble* pvy,IssmDouble a11, IssmDouble a21,IssmDouble a22); 16 17 17 18 void Matrix3x3Invert(IssmDouble* Ainv, IssmDouble* A); -
issm/trunk/src/c/shared/Numerics/numerics.h
r18301 r19105 33 33 void cross(IssmDouble *result,IssmDouble*vector1,IssmDouble*vector2); 34 34 void XZvectorsToCoordinateSystem(IssmDouble *T,IssmDouble*xzvectors); 35 int cubic(IssmDouble a, IssmDouble b, IssmDouble c, IssmDouble d, double X[3], int *num);35 int cubic(IssmDouble a, IssmDouble b, IssmDouble c, IssmDouble d,IssmDouble X[3], int *num); 36 36 37 37 int NewtonSolveDnorm(IssmDouble* pdnorm,IssmDouble c1,IssmDouble c2,IssmDouble c3,IssmDouble n,IssmDouble dnorm); -
issm/trunk/src/c/shared/Numerics/recast.h
r15396 r19105 40 40 #endif 41 41 42 /*Morlighem's change: we do not want dynamic_casts because of performance 43 * issue, so for now, we just use C-like cast*/ 44 template<class To,class From> To xDynamicCast(const From& from) { 45 46 /*C-like cast (fast but not safe)*/ 47 return (To) from; 48 49 /*C++ dynamic_cast, poor performance but safer*/ 50 //return dynamic_cast<To>(from); 51 } 52 42 53 #endif -
issm/trunk/src/c/solutionsequences/convergence.cpp
r16137 r19105 7 7 #include "../shared/shared.h" 8 8 9 void convergence(bool* pconverged, Matrix<IssmDouble>* Kff,Vector<IssmDouble>* pf,Vector<IssmDouble>* uf,Vector<IssmDouble>* old_uf, Parameters* parameters){9 void convergence(bool* pconverged, Matrix<IssmDouble>* Kff,Vector<IssmDouble>* pf,Vector<IssmDouble>* uf,Vector<IssmDouble>* old_uf,IssmDouble eps_res,IssmDouble eps_rel,IssmDouble eps_abs){ 10 10 11 11 /*output*/ … … 23 23 IssmDouble nF; 24 24 IssmDouble solver_residue,res; 25 26 /*convergence options*/ 27 IssmDouble eps_res; 28 IssmDouble eps_rel; 29 IssmDouble eps_abs; 30 IssmDouble yts; 25 int analysis_type; 31 26 32 27 if(VerboseModule()) _printf0_(" checking convergence\n"); … … 38 33 return; 39 34 } 40 41 /*get convergence options*/42 parameters->FindParam(&eps_res,StressbalanceRestolEnum);43 parameters->FindParam(&eps_rel,StressbalanceReltolEnum);44 parameters->FindParam(&eps_abs,StressbalanceAbstolEnum);45 parameters->FindParam(&yts,ConstantsYtsEnum);46 35 47 36 /*Display solver caracteristics*/ … … 130 119 //print 131 120 if (!xIsNan<IssmDouble>(eps_abs)){ 132 if ((nduinf *yts)<eps_abs){133 if(VerboseConvergence()) _printf0_(setw(50) << left << " Convergence criterion: max(du)" << nduinf *yts << " < " << eps_abs << " m/yr\n");121 if ((nduinf)<eps_abs){ 122 if(VerboseConvergence()) _printf0_(setw(50) << left << " Convergence criterion: max(du)" << nduinf << " < " << eps_abs << "\n"); 134 123 } 135 124 else{ 136 if(VerboseConvergence()) _printf0_(setw(50) << left << " Convergence criterion: max(du)" << nduinf *yts << " > " << eps_abs << " m/yr\n");125 if(VerboseConvergence()) _printf0_(setw(50) << left << " Convergence criterion: max(du)" << nduinf << " > " << eps_abs << "\n"); 137 126 converged=false; 138 127 } 139 128 } 140 else _printf0_(setw(50) << left << " Convergence criterion: max(du)" << nduinf *yts << " m/yr\n");129 else _printf0_(setw(50) << left << " Convergence criterion: max(du)" << nduinf << "\n"); 141 130 142 131 } -
issm/trunk/src/c/solutionsequences/solutionsequence_hydro_nonlinear.cpp
r17806 r19105 46 46 IssmDouble ndu_sed,nu_sed; 47 47 IssmDouble ndu_epl,nu_epl; 48 48 IssmDouble ThickCount,L2Count; 49 49 50 /*Recover parameters: */ 50 51 femmodel->SetCurrentConfiguration(HydrologyDCInefficientAnalysisEnum); … … 69 70 /*Initialize the element mask*/ 70 71 inefanalysis->ElementizeEplMask(femmodel); 72 effanalysis->InitZigZagCounter(femmodel); 71 73 } 72 74 /*The real computation starts here, outermost loop is on the two layer system*/ … … 90 92 femmodel->parameters->SetParam(HydrologySedimentEnum,HydrologyLayerEnum); 91 93 92 /*Reset constraint on the ZigZag Lock , this thing doesn't work, it have to disapear*/94 /*Reset constraint on the ZigZag Lock*/ 93 95 ResetConstraintsx(femmodel); 94 96 95 /* {{{*//*Treating the sediment*/97 /*{{{*//*Treating the sediment*/ 96 98 for(;;){ 97 99 sedconverged=false; 98 100 uf_sed_sub_iter=uf_sed->Duplicate();_assert_(uf_sed_sub_iter); 99 101 uf_sed->Copy(uf_sed_sub_iter); 100 /* {{{*//*Loop on the sediment layer to deal with the penalization*/102 /*{{{*//*Loop on the sediment layer to deal with the penalization*/ 101 103 for(;;){ 102 /* {{{ *//*Core of the computation*/104 /*{{{*/ /*Core of the computation*/ 103 105 if(VerboseSolution()) _printf0_("Building Sediment Matrix...\n"); 104 106 SystemMatricesx(&Kff,&Kfs,&pf,&df,&sediment_kmax,femmodel); … … 112 114 InputUpdateFromSolutionx(femmodel,ug_sed); 113 115 ConstraintsStatex(&constraints_converged,&num_unstable_constraints,femmodel); 114 /* }}}*/116 /*}}}*/ 115 117 if (!sedconverged){ 116 118 if(VerboseConvergence()) _printf0_(" # Sediment unstable constraints = " << num_unstable_constraints << "\n"); … … 125 127 } 126 128 127 /* }}} *//*End of the sediment penalization loop*/ 128 /*Update EPL mask*/ 129 if(isefficientlayer){ 130 inefanalysis->ElementizeEplMask(femmodel); 131 } 129 /*}}}*//*End of the sediment penalization loop*/ 132 130 sedconverged=false; 133 131 … … 155 153 } 156 154 } 157 /* }}}*//*End of the global sediment loop*/158 /* {{{*//*Now dealing with the EPL in the same way*/155 /*}}}*//*End of the global sediment loop*/ 156 /*{{{*//*Now dealing with the EPL in the same way*/ 159 157 if(isefficientlayer){ 160 158 femmodel->SetCurrentConfiguration(HydrologyDCEfficientAnalysisEnum); 161 159 /*updating mask*/ 162 femmodel->HydrologyEPLupdateDomainx(); 160 femmodel->HydrologyEPLupdateDomainx(&ThickCount); 161 inefanalysis->ElementizeEplMask(femmodel); 163 162 InputUpdateFromConstantx(femmodel,true,ResetPenaltiesEnum); 164 163 InputUpdateFromConstantx(femmodel,false,ConvergedEnum); … … 169 168 ug_epl_sub_iter=ug_epl->Duplicate();_assert_(ug_epl_sub_iter); 170 169 ug_epl->Copy(ug_epl_sub_iter); 171 /* {{{*//*Retrieve the EPL head slopes and compute EPL Thickness*/170 /*{{{*//*Retrieve the EPL head slopes and compute EPL Thickness*/ 172 171 if(VerboseSolution()) _printf0_("computing EPL Head slope...\n"); 172 //inefanalysis->ElementizeEplMask(femmodel); 173 femmodel->SetCurrentConfiguration(L2ProjectionEPLAnalysisEnum); 174 femmodel->UpdateConstraintsL2ProjectionEPLx(&L2Count); 173 175 inefanalysis->ElementizeEplMask(femmodel); 174 femmodel->SetCurrentConfiguration(L2ProjectionEPLAnalysisEnum);175 femmodel->UpdateConstraintsL2ProjectionEPLx();176 176 femmodel->parameters->SetParam(EplHeadSlopeXEnum,InputToL2ProjectEnum); 177 177 solutionsequence_linear(femmodel); 178 178 femmodel->parameters->SetParam(EplHeadSlopeYEnum,InputToL2ProjectEnum); 179 179 solutionsequence_linear(femmodel); 180 180 181 femmodel->SetCurrentConfiguration(HydrologyDCEfficientAnalysisEnum); 181 182 182 effanalysis->ComputeEPLThickness(femmodel); 183 184 183 //updating mask after the computation of the epl thickness (Allow to close too thin EPL) 185 femmodel->HydrologyEPLupdateDomainx( );184 femmodel->HydrologyEPLupdateDomainx(&ThickCount); 186 185 inefanalysis->ElementizeEplMask(femmodel); 187 /* }}}*/186 /*}}}*/ 188 187 189 188 if(VerboseSolution()) _printf0_("Building EPL Matrix...\n"); … … 215 214 _error_(" maximum number of EPL iterations (" << hydro_maxiter << ") exceeded"); 216 215 } 216 //If there is some colapse go through sediment again 217 if(ThickCount<L2Count)eplconverged=true; 217 218 eplcount++; 218 219 … … 222 223 InputUpdateFromConstantx(femmodel,eplconverged,ConvergedEnum); 223 224 InputUpdateFromSolutionx(femmodel,ug_epl); 225 effanalysis->ResetCounter(femmodel); 224 226 break; 225 227 } 226 228 } 227 229 } 228 /* }}}*/ /*End of the global EPL loop*/229 230 /* {{{*/ /*Now dealing with the convergence of the whole system*/230 /*}}}*/ /*End of the global EPL loop*/ 231 232 /*{{{*/ /*Now dealing with the convergence of the whole system*/ 231 233 if(!hydroconverged){ 232 234 //compute norm(du)/norm(u) … … 268 270 if(hydroconverged)break; 269 271 } 270 /* }}}*/272 /*}}}*/ 271 273 if(isefficientlayer)InputUpdateFromSolutionx(femmodel,ug_epl); 272 274 femmodel->SetCurrentConfiguration(HydrologyDCInefficientAnalysisEnum); -
issm/trunk/src/c/solutionsequences/solutionsequence_la.cpp
r18301 r19105 39 39 40 40 /*Convergence criterion*/ 41 int count = 0; 42 Vector<IssmDouble>* vel = NULL; 43 Vector<IssmDouble>* vel_old = NULL; 44 GetVectorFromInputsx(&vel,femmodel,VxEnum,VertexEnum); 45 GetVectorFromInputsx(&pug,femmodel,PressureEnum,VertexEnum); 41 int count = 0; 42 int count_local = 0; 43 Vector<IssmDouble>* vel = NULL; 44 Vector<IssmDouble>* vel_old = NULL; 45 Vector<IssmDouble>* vel_old_local = NULL; 46 GetVectorFromInputsx(&vel,femmodel,VxEnum,VertexPIdEnum); 47 GetVectorFromInputsx(&pug,femmodel,PressureEnum,VertexPIdEnum); 46 48 47 49 while(true){ … … 49 51 50 52 /*save pointer to old velocity*/ 51 delete vel_old;vel_old=vel ;53 delete vel_old;vel_old=vel->Duplicate(); vel->Copy(vel_old); 52 54 delete pug_old;pug_old=pug; 53 55 pressure_converged=false; vel_converged=false; 54 56 55 /*Solve KU=F*/ 56 femmodel->SetCurrentConfiguration(StressbalanceAnalysisEnum); 57 femmodel->parameters->FindParam(&configuration_type,ConfigurationTypeEnum); 58 SystemMatricesx(&Kff,&Kfs,&pf,&df,NULL,femmodel); 59 CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type); 60 Reduceloadx(pf, Kfs, ys); delete Kfs; 61 Solverx(&uf, Kff, pf, NULL, df, femmodel->parameters); 62 delete Kff; delete pf; delete df; 63 Mergesolutionfromftogx(&ug, uf,ys,femmodel->nodes,femmodel->parameters);delete uf; delete ys; 57 while(true){ 58 count_local++; 59 delete vel_old_local;vel_old_local=vel; 60 /*Solve KU=F*/ 61 femmodel->SetCurrentConfiguration(StressbalanceAnalysisEnum); 62 femmodel->parameters->FindParam(&configuration_type,ConfigurationTypeEnum); 63 SystemMatricesx(&Kff,&Kfs,&pf,&df,NULL,femmodel); 64 CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type); 65 Reduceloadx(pf, Kfs, ys); delete Kfs; 66 Solverx(&uf, Kff, pf, NULL, df, femmodel->parameters); 67 delete Kff; delete pf; delete df; 68 Mergesolutionfromftogx(&ug, uf,ys,femmodel->nodes,femmodel->parameters);delete uf; delete ys; 64 69 65 /*Update solution*/ 66 InputUpdateFromSolutionx(femmodel,ug); delete ug; 67 GetVectorFromInputsx(&vel,femmodel,VxEnum,VertexEnum); 70 /*Update solution*/ 71 InputUpdateFromSolutionx(femmodel,ug); delete ug; 72 GetVectorFromInputsx(&vel,femmodel,VxEnum,VertexPIdEnum); 73 /*Check for convergence*/ 74 Vector<IssmDouble>* dvel_local=vel_old_local->Duplicate(); vel_old_local->Copy(dvel_local); dvel_local->AYPX(vel,-1.0); 75 IssmDouble ndu=dvel_local->Norm(NORM_TWO); delete dvel_local; 76 IssmDouble nu =vel_old_local->Norm(NORM_TWO); 77 if (xIsNan<IssmDouble>(ndu) || xIsNan<IssmDouble>(nu)) _error_("convergence criterion is NaN!"); 78 if((ndu/nu)<eps_rel){ 79 if(VerboseConvergence()) _printf0_(setw(50) << left << " Convergence criterion: norm(du)/norm(u)" << ndu/nu*100 << " < " << eps_rel*100 << " %\n"); 80 break; 81 } 82 else{ 83 if(VerboseConvergence()) _printf0_(setw(50) << left << " Convergence criterion: norm(du)/norm(u)" << ndu/nu*100 << " > " << eps_rel*100 << " %\n"); 84 } 85 if(count_local>=max_nonlinear_iterations){ 86 _printf0_(" maximum number of nonlinear iterations (" << max_nonlinear_iterations << ") exceeded\n"); 87 break; 88 } 89 } 90 count_local=0; 68 91 69 92 femmodel->SetCurrentConfiguration(UzawaPressureAnalysisEnum); … … 78 101 /*Update solution*/ 79 102 InputUpdateFromSolutionx(femmodel,pug); delete pug; 80 GetVectorFromInputsx(&pug,femmodel,PressureEnum,Vertex Enum);103 GetVectorFromInputsx(&pug,femmodel,PressureEnum,VertexPIdEnum); 81 104 82 105 /*Check for convergence*/ 83 Vector<IssmDouble>* dvel=vel_old ->Duplicate(); vel_old->Copy(dvel); dvel->AYPX(vel,-1.0);106 Vector<IssmDouble>* dvel=vel_old_local->Duplicate(); vel_old_local->Copy(dvel); dvel->AYPX(vel,-1.0); 84 107 IssmDouble ndu=dvel->Norm(NORM_TWO); delete dvel; 85 IssmDouble nu =vel_old ->Norm(NORM_TWO);108 IssmDouble nu =vel_old_local->Norm(NORM_TWO); 86 109 if (xIsNan<IssmDouble>(ndu) || xIsNan<IssmDouble>(nu)) _error_("convergence criterion is NaN!"); 87 110 if((ndu/nu)<eps_rel){ … … 119 142 delete vel; 120 143 delete vel_old; 144 delete vel_old_local; 121 145 delete stressanalysis; 122 146 delete pressureanalysis; -
issm/trunk/src/c/solutionsequences/solutionsequence_la_theta.cpp
r17806 r19105 41 41 Vector<IssmDouble>* vx = NULL; 42 42 Vector<IssmDouble>* vx_old = NULL; 43 GetVectorFromInputsx(&vx,femmodel,VxEnum,Vertex Enum);43 GetVectorFromInputsx(&vx,femmodel,VxEnum,VertexPIdEnum); 44 44 45 45 while(true){ … … 69 69 analysis->InputUpdateFromSolutionFSXTH_d( femmodel->elements,femmodel->parameters); 70 70 analysis->InputUpdateFromSolutionFSXTH_tau(femmodel->elements,femmodel->parameters); 71 GetVectorFromInputsx(&vx,femmodel,VxEnum,Vertex Enum);71 GetVectorFromInputsx(&vx,femmodel,VxEnum,VertexPIdEnum); 72 72 73 73 /*Check for convergence*/ -
issm/trunk/src/c/solutionsequences/solutionsequence_newton.cpp
r17989 r19105 30 30 /*parameters:*/ 31 31 int max_nonlinear_iterations; 32 int configuration_type; 32 int configuration_type; 33 IssmDouble eps_res,eps_rel,eps_abs; 33 34 34 35 /*Recover parameters: */ … … 36 37 femmodel->parameters->FindParam(&configuration_type,ConfigurationTypeEnum); 37 38 femmodel->parameters->FindParam(&newton,StressbalanceIsnewtonEnum); 39 femmodel->parameters->FindParam(&eps_res,StressbalanceRestolEnum); 40 femmodel->parameters->FindParam(&eps_rel,StressbalanceReltolEnum); 41 femmodel->parameters->FindParam(&eps_abs,StressbalanceAbstolEnum); 38 42 femmodel->UpdateConstraintsx(); 39 43 … … 83 87 84 88 /*Check convergence*/ 85 convergence(&converged,Kff,pf,uf,old_uf, femmodel->parameters);89 convergence(&converged,Kff,pf,uf,old_uf,eps_res,eps_rel,eps_abs); 86 90 delete Kff; delete pf; 87 91 if(converged==true){ -
issm/trunk/src/c/solutionsequences/solutionsequence_nonlinear.cpp
r17806 r19105 31 31 int max_nonlinear_iterations; 32 32 int configuration_type; 33 IssmDouble eps_res,eps_rel,eps_abs; 34 33 35 34 36 /*Recover parameters: */ 35 37 femmodel->parameters->FindParam(&min_mechanical_constraints,StressbalanceRiftPenaltyThresholdEnum); 36 38 femmodel->parameters->FindParam(&max_nonlinear_iterations,StressbalanceMaxiterEnum); 39 femmodel->parameters->FindParam(&eps_res,StressbalanceRestolEnum); 40 femmodel->parameters->FindParam(&eps_rel,StressbalanceReltolEnum); 41 femmodel->parameters->FindParam(&eps_abs,StressbalanceAbstolEnum); 37 42 femmodel->parameters->FindParam(&configuration_type,ConfigurationTypeEnum); 38 43 femmodel->UpdateConstraintsx(); … … 66 71 Mergesolutionfromftogx(&ug, uf,ys,femmodel->nodes,femmodel->parameters);delete ys; 67 72 68 convergence(&converged,Kff,pf,uf,old_uf, femmodel->parameters); delete Kff; delete pf; delete df;73 convergence(&converged,Kff,pf,uf,old_uf,eps_res,eps_rel,eps_abs); delete Kff; delete pf; delete df; 69 74 InputUpdateFromConstantx(femmodel,converged,ConvergedEnum); 70 75 InputUpdateFromSolutionx(femmodel,ug); -
issm/trunk/src/c/solutionsequences/solutionsequence_stokescoupling_nonlinear.cpp
r16137 r19105 33 33 int max_nonlinear_iterations; 34 34 int configuration_type; 35 IssmDouble eps_res,eps_rel,eps_abs; 35 36 36 37 /*Recover parameters: */ 37 38 femmodel->parameters->FindParam(&min_mechanical_constraints,StressbalanceRiftPenaltyThresholdEnum); 38 39 femmodel->parameters->FindParam(&max_nonlinear_iterations,StressbalanceMaxiterEnum); 40 femmodel->parameters->FindParam(&eps_res,StressbalanceRestolEnum); 41 femmodel->parameters->FindParam(&eps_rel,StressbalanceReltolEnum); 42 femmodel->parameters->FindParam(&eps_abs,StressbalanceAbstolEnum); 39 43 femmodel->UpdateConstraintsx(); 40 44 … … 68 72 InputUpdateFromSolutionx(femmodel,ug_horiz); 69 73 70 convergence(&converged,Kff_horiz,pf_horiz,uf_horiz,old_uf_horiz, femmodel->parameters); delete Kff_horiz; delete pf_horiz; delete df_horiz;74 convergence(&converged,Kff_horiz,pf_horiz,uf_horiz,old_uf_horiz,eps_res,eps_rel,eps_abs); delete Kff_horiz; delete pf_horiz; delete df_horiz; 71 75 72 76 /*Second compute vertical velocity: */ -
issm/trunk/src/c/solutionsequences/solutionsequence_thermal_nonlinear.cpp
r17806 r19105 3 3 */ 4 4 5 #include "./solutionsequences.h" 5 6 #include "../toolkits/toolkits.h" 6 7 #include "../classes/classes.h" … … 24 25 25 26 bool converged; 27 bool isenthalpy, isdynamicbasalspc; 26 28 int constraints_converged; 27 29 int num_unstable_constraints; … … 32 34 /*parameters:*/ 33 35 int configuration_type; 36 IssmDouble eps_rel; 34 37 35 38 /*Recover parameters: */ 36 femmodel->parameters->FindParam(& thermal_penalty_threshold,ThermalPenaltyThresholdEnum);39 femmodel->parameters->FindParam(&isenthalpy,ThermalIsenthalpyEnum); 37 40 femmodel->parameters->FindParam(&configuration_type,ConfigurationTypeEnum); 38 41 femmodel->parameters->FindParam(&thermal_maxiter,ThermalMaxiterEnum); 39 42 43 converged=false; 44 InputUpdateFromConstantx(femmodel,converged,ConvergedEnum); 45 46 if(isenthalpy){ 47 femmodel->parameters->FindParam(&isdynamicbasalspc,ThermalIsdynamicbasalspcEnum); 48 femmodel->parameters->FindParam(&eps_rel,ThermalReltolEnum); 49 femmodel->UpdateConstraintsx(); 50 51 //Update the solution to make sure that tf and tf_old are similar (for next step in transient or steadystate) 52 GetSolutionFromInputsx(&tg,femmodel); 53 Reducevectorgtofx(&tf, tg, femmodel->nodes,femmodel->parameters); 54 InputUpdateFromSolutionx(femmodel,tg); 55 } 56 else{ 57 femmodel->parameters->FindParam(&thermal_penalty_threshold,ThermalPenaltyThresholdEnum); 58 InputUpdateFromConstantx(femmodel,true,ResetPenaltiesEnum); 59 femmodel->UpdateConstraintsx(); 60 } 61 40 62 count=1; 41 converged=false; 63 64 for(;;){ 65 delete tf_old;tf_old=tf; 42 66 43 InputUpdateFromConstantx(femmodel,true,ResetPenaltiesEnum); 44 InputUpdateFromConstantx(femmodel,false,ConvergedEnum); 45 femmodel->UpdateConstraintsx(); 46 47 for(;;){ 48 49 delete tf_old; tf_old=tf; 50 SystemMatricesx(&Kff, &Kfs, &pf,&df, &melting_offset,femmodel); 67 if(isenthalpy){ 68 SystemMatricesx(&Kff,&Kfs,&pf,&df,NULL,femmodel); 69 /*Update old solution, such that sizes of tf_old and tf are comparable*/ 70 if(isdynamicbasalspc){ 71 delete tf_old; 72 Reducevectorgtofx(&tf_old, tg, femmodel->nodes,femmodel->parameters); 73 } 74 } 75 else SystemMatricesx(&Kff, &Kfs, &pf,&df, &melting_offset,femmodel); 76 delete tg; 51 77 CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type); 52 78 Reduceloadx(pf, Kfs, ys); delete Kfs; 53 Solverx(&tf, Kff, pf,tf_old, df, femmodel->parameters); 54 delete Kff;delete pf;delete tg; delete df; 79 Solverx(&tf, Kff, pf, tf_old, df, femmodel->parameters); 55 80 Mergesolutionfromftogx(&tg, tf,ys,femmodel->nodes,femmodel->parameters); delete ys; 81 if(isenthalpy){ 82 convergence(&converged,Kff,pf,tf,tf_old,0.05,eps_rel,NAN); 83 InputUpdateFromConstantx(femmodel,converged,ConvergedEnum); 84 } 85 delete Kff; delete pf; delete df; 56 86 InputUpdateFromSolutionx(femmodel,tg); 87 ConstraintsStatex(&constraints_converged,&num_unstable_constraints,femmodel); 88 if(VerboseConvergence()) _printf0_(" number of unstable constraints: " << num_unstable_constraints << "\n"); 57 89 58 ConstraintsStatex(&constraints_converged,&num_unstable_constraints,femmodel); 90 if(isenthalpy){ // enthalpy method 91 IssmDouble dt; 92 femmodel->parameters->FindParam(&dt,TimesteppingTimeStepEnum); 59 93 60 if (!converged){61 if(VerboseConvergence()) _printf0_(" #unstable constraints = " << num_unstable_constraints << "\n");62 if (num_unstable_constraints <= thermal_penalty_threshold)converged=true;63 if (count>=thermal_maxiter){94 count++; 95 bool max_iteration_state=false; 96 if(count>=thermal_maxiter){ 97 _printf0_(" maximum number of nonlinear iterations (" << thermal_maxiter << ") exceeded\n"); 64 98 converged=true; 65 _printf0_(" maximum number of iterations (" << thermal_maxiter << ") exceeded\n"); 99 InputUpdateFromConstantx(femmodel,converged,ConvergedEnum); 100 InputUpdateFromSolutionx(femmodel,tg); 101 max_iteration_state=true; 102 } 103 if(converged==true){ 104 int step; IssmDouble time; 105 femmodel->parameters->FindParam(&time,TimeEnum); 106 femmodel->parameters->FindParam(&step,StepEnum); 107 femmodel->results->AddObject(new GenericExternalResult<bool>(femmodel->results->Size()+1, MaxIterationConvergenceFlagEnum, max_iteration_state, step, time)); 108 break; 109 } 110 else if(dt==0.){ 111 EnthalpyAnalysis::ComputeBasalMeltingrate(femmodel); 112 EnthalpyAnalysis::UpdateBasalConstraints(femmodel); 66 113 } 67 114 } 68 count++; 69 70 InputUpdateFromConstantx(femmodel,converged,ConvergedEnum); 71 72 if(converged)break; 115 else{ // dry ice method 116 if(!converged){ 117 if(num_unstable_constraints<=thermal_penalty_threshold) converged=true; 118 if(count>=thermal_maxiter){ 119 converged=true; 120 _printf0_(" maximum number of iterations (" << thermal_maxiter << ") exceeded\n"); 121 } 122 } 123 count++; 124 InputUpdateFromConstantx(femmodel,converged,ConvergedEnum); 125 if(converged)break; 126 } 73 127 } 74 128 75 InputUpdateFromSolutionx(femmodel,tg); 76 femmodel->parameters->SetParam(melting_offset,MeltingOffsetEnum); 129 if(isenthalpy){ 130 if(VerboseConvergence()) _printf0_("\n total number of iterations: " << count-1 << "\n"); 131 } 132 else{ 133 InputUpdateFromSolutionx(femmodel,tg); 134 femmodel->parameters->SetParam(melting_offset,MeltingOffsetEnum); 135 } 77 136 78 137 /*Free ressources: */ -
issm/trunk/src/c/solutionsequences/solutionsequences.h
r18301 r19105 16 16 void solutionsequence_nonlinear(FemModel* femmodel,bool conserve_loads); 17 17 void solutionsequence_newton(FemModel* femmodel); 18 void solutionsequence_fct(FemModel* femmodel); 18 19 void solutionsequence_FScoupling_nonlinear(FemModel* femmodel,bool conserve_loads); 19 20 void solutionsequence_linear(FemModel* femmodel); … … 23 24 24 25 /*convergence*/ 25 void convergence(bool* pconverged, Matrix<IssmDouble>* K_ff,Vector<IssmDouble>* p_f,Vector<IssmDouble>* u_f,Vector<IssmDouble>* u_f_old, Parameters* parameters);26 void convergence(bool* pconverged, Matrix<IssmDouble>* K_ff,Vector<IssmDouble>* p_f,Vector<IssmDouble>* u_f,Vector<IssmDouble>* u_f_old,IssmDouble eps_res,IssmDouble eps_rel,IssmDouble eps_abs); 26 27 27 28 #endif -
issm/trunk/src/c/toolkits/gsl/DenseGslSolve.cpp
r17806 r19105 235 235 IssmPDouble* pdoubleEDFout=xNew<IssmPDouble>(n); // provide space to transfer outputs during call_ext_fct 236 236 // call the wrapped solver through the registry entry we retrieve from parameters 237 call_ext_fct( dynamic_cast<GenericParam<Adolc_edf> * >(parameters->FindParamObject(AdolcParamEnum))->GetParameterValue().myEDF_for_solverx_p,237 call_ext_fct(xDynamicCast<GenericParam<Adolc_edf> * >(parameters->FindParamObject(AdolcParamEnum))->GetParameterValue().myEDF_for_solverx_p, 238 238 n*(n+1), pdoubleEDFin, adoubleEDFin, 239 239 n, pdoubleEDFout,X); -
issm/trunk/src/c/toolkits/mumps/MpiDenseMumpsSolve.cpp
r16560 r19105 244 244 IssmPDouble *passiveSol=xNew<IssmPDouble>(n); 245 245 IssmDouble *sol=xNew<IssmDouble>(n); 246 call_ext_fct( dynamic_cast<GenericParam<Adolc_edf> * >(parameters->FindParamObject(AdolcParamEnum))->GetParameterValue().myEDF_for_solverx_p,246 call_ext_fct(xDynamicCast<GenericParam<Adolc_edf> * >(parameters->FindParamObject(AdolcParamEnum))->GetParameterValue().myEDF_for_solverx_p, 247 247 packedDimsSparseArrLength, packedDimsSparseArr, 248 248 local_nnz+n, passivePack_A_rhs, pack_A_rhs, -
issm/trunk/src/c/toolkits/mumps/MumpsSolve.cpp
r17989 r19105 324 324 IssmPDouble *passiveSol=xNew<IssmPDouble>(n); 325 325 IssmDouble *sol=xNew<IssmDouble>(n); 326 call_ext_fct( dynamic_cast<GenericParam<Adolc_edf> * >(parameters->FindParamObject(AdolcParamEnum))->GetParameterValue().myEDF_for_solverx_p,326 call_ext_fct(xDynamicCast<GenericParam<Adolc_edf> * >(parameters->FindParamObject(AdolcParamEnum))->GetParameterValue().myEDF_for_solverx_p, 327 327 packedDimsSparseArrLength, packedDimsSparseArr, 328 328 local_nnz+n, passivePack_A_rhs, pack_A_rhs, -
issm/trunk/src/dox/issm.dox
r18301 r19105 47 47 </th> 48 48 <tr> 49 <th bgcolor=#FFFFFF style="text-align:left;"> C++ </th><td bgcolor=#FFFFFF style="text-align:right;">4 53</td><td bgcolor=#FFFFFF style="text-align:right;">15861</td><td bgcolor=#FFFFFF style="text-align:right;">18188</td><td bgcolor=#FFFFFF style="text-align:right;">68849</td><td bgcolor=#FFFFFF style="text-align:right;">102898</td>49 <th bgcolor=#FFFFFF style="text-align:left;"> C++ </th><td bgcolor=#FFFFFF style="text-align:right;">445</td><td bgcolor=#FFFFFF style="text-align:right;">15967</td><td bgcolor=#FFFFFF style="text-align:right;">16145</td><td bgcolor=#FFFFFF style="text-align:right;">70397</td><td bgcolor=#FFFFFF style="text-align:right;">102509</td> 50 50 </tr> 51 51 <tr> 52 <th bgcolor=#C6E2FF style="text-align:left;"> MATLAB </th><td bgcolor=#C6E2FF style="text-align:right;">1 378</td><td bgcolor=#C6E2FF style="text-align:right;">8341</td><td bgcolor=#C6E2FF style="text-align:right;">16259</td><td bgcolor=#C6E2FF style="text-align:right;">38645</td><td bgcolor=#C6E2FF style="text-align:right;">63245</td>52 <th bgcolor=#C6E2FF style="text-align:left;"> MATLAB </th><td bgcolor=#C6E2FF style="text-align:right;">1422</td><td bgcolor=#C6E2FF style="text-align:right;">8497</td><td bgcolor=#C6E2FF style="text-align:right;">16638</td><td bgcolor=#C6E2FF style="text-align:right;">39538</td><td bgcolor=#C6E2FF style="text-align:right;">64673</td> 53 53 </tr> 54 54 <tr> 55 <th bgcolor=#FFFFFF style="text-align:left;"> C/C++ Header </th><td bgcolor=#FFFFFF style="text-align:right;">4 21</td><td bgcolor=#FFFFFF style="text-align:right;">3504</td><td bgcolor=#FFFFFF style="text-align:right;">3753</td><td bgcolor=#FFFFFF style="text-align:right;">15489</td><td bgcolor=#FFFFFF style="text-align:right;">22746</td>55 <th bgcolor=#FFFFFF style="text-align:left;"> C/C++ Header </th><td bgcolor=#FFFFFF style="text-align:right;">411</td><td bgcolor=#FFFFFF style="text-align:right;">3443</td><td bgcolor=#FFFFFF style="text-align:right;">3528</td><td bgcolor=#FFFFFF style="text-align:right;">15243</td><td bgcolor=#FFFFFF style="text-align:right;">22214</td> 56 56 </tr> 57 57 <tr> 58 <th bgcolor=#C6E2FF style="text-align:left;"> m4 </th><td bgcolor=#C6E2FF style="text-align:right;"> 9</td><td bgcolor=#C6E2FF style="text-align:right;">1588</td><td bgcolor=#C6E2FF style="text-align:right;">151</td><td bgcolor=#C6E2FF style="text-align:right;">11565</td><td bgcolor=#C6E2FF style="text-align:right;">13304</td>58 <th bgcolor=#C6E2FF style="text-align:left;"> m4 </th><td bgcolor=#C6E2FF style="text-align:right;">8</td><td bgcolor=#C6E2FF style="text-align:right;">1036</td><td bgcolor=#C6E2FF style="text-align:right;">149</td><td bgcolor=#C6E2FF style="text-align:right;">9756</td><td bgcolor=#C6E2FF style="text-align:right;">10941</td> 59 59 </tr> 60 60 <tr> 61 <th bgcolor=#FFFFFF style="text-align:left;"> Python </th><td bgcolor=#FFFFFF style="text-align:right;">144</td><td bgcolor=#FFFFFF style="text-align:right;">2330</td><td bgcolor=#FFFFFF style="text-align:right;">2559</td><td bgcolor=#FFFFFF style="text-align:right;">9348</td><td bgcolor=#FFFFFF style="text-align:right;">14237</td> 62 </tr> 63 <tr> 64 <th bgcolor=#C6E2FF style="text-align:left;"> XML </th><td bgcolor=#C6E2FF style="text-align:right;">4</td><td bgcolor=#C6E2FF style="text-align:right;">160</td><td bgcolor=#C6E2FF style="text-align:right;">92</td><td bgcolor=#C6E2FF style="text-align:right;">3075</td><td bgcolor=#C6E2FF style="text-align:right;">3327</td> 65 </tr> 66 <tr> 67 <th bgcolor=#FFFFFF style="text-align:left;"> Java </th><td bgcolor=#FFFFFF style="text-align:right;">18</td><td bgcolor=#FFFFFF style="text-align:right;">719</td><td bgcolor=#FFFFFF style="text-align:right;">891</td><td bgcolor=#FFFFFF style="text-align:right;">2321</td><td bgcolor=#FFFFFF style="text-align:right;">3931</td> 61 <th bgcolor=#FFFFFF style="text-align:left;"> Python </th><td bgcolor=#FFFFFF style="text-align:right;">151</td><td bgcolor=#FFFFFF style="text-align:right;">2421</td><td bgcolor=#FFFFFF style="text-align:right;">2623</td><td bgcolor=#FFFFFF style="text-align:right;">9733</td><td bgcolor=#FFFFFF style="text-align:right;">14777</td> 68 62 </tr> 69 63 <tr> … … 71 65 </tr> 72 66 <tr> 73 <th bgcolor=#FFFFFF style="text-align:left;"> Bourne Shell </th><td bgcolor=#FFFFFF style="text-align:right;"> 3</td><td bgcolor=#FFFFFF style="text-align:right;">61</td><td bgcolor=#FFFFFF style="text-align:right;">88</td><td bgcolor=#FFFFFF style="text-align:right;">266</td><td bgcolor=#FFFFFF style="text-align:right;">415</td>67 <th bgcolor=#FFFFFF style="text-align:left;"> Bourne Shell </th><td bgcolor=#FFFFFF style="text-align:right;">2</td><td bgcolor=#FFFFFF style="text-align:right;">59</td><td bgcolor=#FFFFFF style="text-align:right;">84</td><td bgcolor=#FFFFFF style="text-align:right;">262</td><td bgcolor=#FFFFFF style="text-align:right;">405</td> 74 68 </tr> 75 69 <tr> 76 <th bgcolor=#C6E2FF style="text-align:left;"> XSD </th><td bgcolor=#C6E2FF style="text-align:right;">2</td><td bgcolor=#C6E2FF style="text-align:right;">30</td><td bgcolor=#C6E2FF style="text-align:right;">36</td><td bgcolor=#C6E2FF style="text-align:right;">229</td><td bgcolor=#C6E2FF style="text-align:right;">295</td> 77 </tr> 78 <tr> 79 <th bgcolor=#FFFFFF style="text-align:left;"> Perl </th><td bgcolor=#FFFFFF style="text-align:right;">1</td><td bgcolor=#FFFFFF style="text-align:right;">6</td><td bgcolor=#FFFFFF style="text-align:right;">9</td><td bgcolor=#FFFFFF style="text-align:right;">196</td><td bgcolor=#FFFFFF style="text-align:right;">211</td> 80 </tr> 81 <tr> 82 <th bgcolor=#C6E2FF style="text-align:left;"> Ant </th><td bgcolor=#C6E2FF style="text-align:right;">1</td><td bgcolor=#C6E2FF style="text-align:right;">16</td><td bgcolor=#C6E2FF style="text-align:right;">7</td><td bgcolor=#C6E2FF style="text-align:right;">103</td><td bgcolor=#C6E2FF style="text-align:right;">126</td> 83 </tr> 84 <tr> 85 <th bgcolor=#FFFFFF style="text-align:left;"> SUM: </th><td bgcolor=#FFFFFF style="text-align:right;">2441</td><td bgcolor=#FFFFFF style="text-align:right;">32620</td><td bgcolor=#FFFFFF style="text-align:right;">42335</td><td bgcolor=#FFFFFF style="text-align:right;">150451</td><td bgcolor=#FFFFFF style="text-align:right;">225406</td> 70 <th bgcolor=#C6E2FF style="text-align:left;"> SUM: </th><td bgcolor=#C6E2FF style="text-align:right;">2446</td><td bgcolor=#C6E2FF style="text-align:right;">31427</td><td bgcolor=#C6E2FF style="text-align:right;">39469</td><td bgcolor=#C6E2FF style="text-align:right;">145294</td><td bgcolor=#C6E2FF style="text-align:right;">216190</td> 86 71 </tr> 87 72 </table> -
issm/trunk/src/m/classes/SMB.m
r17806 r19105 9 9 end 10 10 methods 11 function createxml( obj,fid) % {{{11 function createxml(self,fid) % {{{ 12 12 fprintf(fid, '\n\n'); 13 13 fprintf(fid, '%s\n', '<!-- surfaceforcings(SMB) -->'); 14 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n','<parameter key ="mass_balance" type="',class( obj.mass_balance),'" default="',obj.mass_balance,'">',' <section name="surfaceforcings(SMB)" />',' <help> surface mass balance [m/yr ice eq] </help>','</parameter>');14 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n','<parameter key ="mass_balance" type="',class(self.mass_balance),'" default="',self.mass_balance,'">',' <section name="surfaceforcings(SMB)" />',' <help> surface mass balance [m/yr ice eq] </help>','</parameter>'); 15 15 16 16 end % }}} 17 function obj= SMB(varargin) % {{{17 function self = SMB(varargin) % {{{ 18 18 switch nargin 19 19 case 0 … … 35 35 36 36 end % }}} 37 function md = checkconsistency( obj,md,solution,analyses) % {{{37 function md = checkconsistency(self,md,solution,analyses) % {{{ 38 38 39 39 if ismember(MasstransportAnalysisEnum(),analyses), 40 md = checkfield(md,'fieldname','surfaceforcings.mass_balance',' forcing',1,'NaN',1);40 md = checkfield(md,'fieldname','surfaceforcings.mass_balance','timeseries',1,'NaN',1); 41 41 end 42 42 if ismember(BalancethicknessAnalysisEnum(),analyses), … … 44 44 end 45 45 end % }}} 46 function disp( obj) % {{{46 function disp(self) % {{{ 47 47 disp(sprintf(' surface forcings parameters:')); 48 fielddisplay( obj,'mass_balance','surface mass balance [m/yr ice eq]');48 fielddisplay(self,'mass_balance','surface mass balance [m/yr ice eq]'); 49 49 end % }}} 50 function marshall( obj,md,fid) % {{{50 function marshall(self,md,fid) % {{{ 51 51 52 52 yts=365.0*24.0*3600.0; 53 53 54 54 WriteData(fid,'enum',SurfaceforcingsEnum(),'data',SMBEnum(),'format','Integer'); 55 WriteData(fid,'object', obj,'class','surfaceforcings','fieldname','mass_balance','format','DoubleMat','mattype',1,'scale',1./yts,'forcinglength',md.mesh.numberofvertices+1);55 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','mass_balance','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1); 56 56 end % }}} 57 57 end -
issm/trunk/src/m/classes/SMB.py
r17806 r19105 38 38 39 39 if MasstransportAnalysisEnum() in analyses: 40 md = checkfield(md,'fieldname','surfaceforcings.mass_balance',' forcing',1,'NaN',1)40 md = checkfield(md,'fieldname','surfaceforcings.mass_balance','timeseries',1,'NaN',1) 41 41 42 42 if BalancethicknessAnalysisEnum() in analyses: … … 50 50 51 51 WriteData(fid,'enum',SurfaceforcingsEnum(),'data',SMBEnum(),'format','Integer'); 52 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','mass_balance','format','DoubleMat','mattype',1,'scale',1./yts,' forcinglength',md.mesh.numberofvertices+1)52 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','mass_balance','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1) 53 53 # }}} -
issm/trunk/src/m/classes/SMBcomponents.m
r18301 r19105 11 11 end 12 12 methods 13 function obj= SMBcomponents(varargin) % {{{13 function self = SMBcomponents(varargin) % {{{ 14 14 switch nargin 15 15 case 0 … … 41 41 42 42 end % }}} 43 function md = checkconsistency( obj,md,solution,analyses) % {{{43 function md = checkconsistency(self,md,solution,analyses) % {{{ 44 44 45 45 if ismember(MasstransportAnalysisEnum(),analyses), 46 md = checkfield(md,'fieldname','surfaceforcings.accumulation',' forcing',1,'NaN',1);46 md = checkfield(md,'fieldname','surfaceforcings.accumulation','timeseries',1,'NaN',1); 47 47 end 48 48 if ismember(BalancethicknessAnalysisEnum(),analyses), … … 50 50 end 51 51 if ismember(MasstransportAnalysisEnum(),analyses), 52 md = checkfield(md,'fieldname','surfaceforcings.runoff',' forcing',1,'NaN',1);52 md = checkfield(md,'fieldname','surfaceforcings.runoff','timeseries',1,'NaN',1); 53 53 end 54 54 if ismember(BalancethicknessAnalysisEnum(),analyses), … … 56 56 end 57 57 if ismember(MasstransportAnalysisEnum(),analyses), 58 md = checkfield(md,'fieldname','surfaceforcings.evaporation',' forcing',1,'NaN',1);58 md = checkfield(md,'fieldname','surfaceforcings.evaporation','timeseries',1,'NaN',1); 59 59 end 60 60 if ismember(BalancethicknessAnalysisEnum(),analyses), … … 62 62 end 63 63 end % }}} 64 function disp( obj) % {{{64 function disp(self) % {{{ 65 65 disp(sprintf(' surface forcings parameters (SMB=accumulation-runoff-evaporation) :')); 66 fielddisplay( obj,'accumulation','accumulated snow [m/yr ice eq]');67 fielddisplay( obj,'runoff','amount of ice melt lost from the ice column [m/yr ice eq]');68 fielddisplay( obj,'evaporation','amount of ice lost to evaporative processes [m/yr ice eq]');66 fielddisplay(self,'accumulation','accumulated snow [m/yr ice eq]'); 67 fielddisplay(self,'runoff','amount of ice melt lost from the ice column [m/yr ice eq]'); 68 fielddisplay(self,'evaporation','amount of ice lost to evaporative processes [m/yr ice eq]'); 69 69 end % }}} 70 function marshall( obj,md,fid) % {{{70 function marshall(self,md,fid) % {{{ 71 71 72 72 yts=365.0*24.0*3600.0; 73 73 74 74 WriteData(fid,'enum',SurfaceforcingsEnum(),'data',SMBcomponentsEnum(),'format','Integer'); 75 WriteData(fid,'object', obj,'class','surfaceforcings','fieldname','accumulation','format','DoubleMat','mattype',1,'scale',1./yts,'forcinglength',md.mesh.numberofvertices+1);76 WriteData(fid,'object', obj,'class','surfaceforcings','fieldname','runoff','format','DoubleMat','mattype',1,'scale',1./yts,'forcinglength',md.mesh.numberofvertices+1);77 WriteData(fid,'object', obj,'class','surfaceforcings','fieldname','evaporation','format','DoubleMat','mattype',1,'scale',1./yts,'forcinglength',md.mesh.numberofvertices+1);75 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','accumulation','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1); 76 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','runoff','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1); 77 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','evaporation','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1); 78 78 end % }}} 79 79 end -
issm/trunk/src/m/classes/SMBcomponents.py
r18301 r19105 51 51 52 52 if MasstransportAnalysisEnum() in analyses: 53 md = checkfield(md,'fieldname','surfaceforcings.accumulation',' forcing',1,'NaN',1)53 md = checkfield(md,'fieldname','surfaceforcings.accumulation','timeseries',1,'NaN',1) 54 54 55 55 if BalancethicknessAnalysisEnum() in analyses: … … 57 57 58 58 if MasstransportAnalysisEnum() in analyses: 59 md = checkfield(md,'fieldname','surfaceforcings.runoff',' forcing',1,'NaN',1)59 md = checkfield(md,'fieldname','surfaceforcings.runoff','timeseries',1,'NaN',1) 60 60 61 61 if BalancethicknessAnalysisEnum() in analyses: … … 63 63 64 64 if MasstransportAnalysisEnum() in analyses: 65 md = checkfield(md,'fieldname','surfaceforcings.evaporation',' forcing',1,'NaN',1)65 md = checkfield(md,'fieldname','surfaceforcings.evaporation','timeseries',1,'NaN',1) 66 66 67 67 if BalancethicknessAnalysisEnum() in analyses: … … 75 75 76 76 WriteData(fid,'enum',SurfaceforcingsEnum(),'data',SMBcomponentsEnum(),'format','Integer'); 77 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','accumulation','format','DoubleMat','mattype',1,'scale',1./yts,' forcinglength',md.mesh.numberofvertices+1)78 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','runoff','format','DoubleMat','mattype',1,'scale',1./yts,' forcinglength',md.mesh.numberofvertices+1)79 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','evaporation','format','DoubleMat','mattype',1,'scale',1./yts,' forcinglength',md.mesh.numberofvertices+1)77 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','accumulation','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1) 78 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','runoff','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1) 79 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','evaporation','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1) 80 80 # }}} -
issm/trunk/src/m/classes/SMBgradients.m
r18301 r19105 12 12 end 13 13 methods 14 function obj= SMBgradients(varargin) % {{{14 function self = SMBgradients(varargin) % {{{ 15 15 switch nargin 16 16 case 0 17 obj=setdefaultparameters(obj);17 self=setdefaultparameters(self); 18 18 otherwise 19 19 error('constructor not supported'); … … 30 30 31 31 end % }}} 32 function obj = setdefaultparameters(obj) % {{{32 function self = setdefaultparameters(self) % {{{ 33 33 34 34 %Nothing for now 35 35 36 36 end % }}} 37 function md = checkconsistency( obj,md,solution,analyses) % {{{37 function md = checkconsistency(self,md,solution,analyses) % {{{ 38 38 39 39 if ismember(MasstransportAnalysisEnum(),analyses), 40 md = checkfield(md,'fieldname','surfaceforcings.href',' forcing',1,'NaN',1);41 md = checkfield(md,'fieldname','surfaceforcings.smbref',' forcing',1,'NaN',1);42 md = checkfield(md,'fieldname','surfaceforcings.b_pos',' forcing',1,'NaN',1);43 md = checkfield(md,'fieldname','surfaceforcings.b_neg',' forcing',1,'NaN',1);40 md = checkfield(md,'fieldname','surfaceforcings.href','timeseries',1,'NaN',1); 41 md = checkfield(md,'fieldname','surfaceforcings.smbref','timeseries',1,'NaN',1); 42 md = checkfield(md,'fieldname','surfaceforcings.b_pos','timeseries',1,'NaN',1); 43 md = checkfield(md,'fieldname','surfaceforcings.b_neg','timeseries',1,'NaN',1); 44 44 end 45 45 end % }}} 46 function disp( obj) % {{{46 function disp(self) % {{{ 47 47 disp(sprintf(' surface forcings parameters:')); 48 48 49 49 disp(sprintf('\n SMB gradients parameters:')); 50 fielddisplay( obj,'href',' reference elevation from which deviation is used to calculate SMB adjustment in smb gradients method [m]');51 fielddisplay( obj,'smbref',' reference smb from which deviation is calculated in smb gradients method [mm/yr water equiv]');52 fielddisplay( obj,'b_pos',' slope of hs - smb regression line for accumulation regime required if smb gradients is activated');53 fielddisplay( obj,'b_neg',' slope of hs - smb regression line for ablation regime required if smb gradients is activated');50 fielddisplay(self,'href',' reference elevation from which deviation is used to calculate SMB adjustment in smb gradients method [m]'); 51 fielddisplay(self,'smbref',' reference smb from which deviation is calculated in smb gradients method [mm/yr water equiv]'); 52 fielddisplay(self,'b_pos',' slope of hs - smb regression line for accumulation regime required if smb gradients is activated'); 53 fielddisplay(self,'b_neg',' slope of hs - smb regression line for ablation regime required if smb gradients is activated'); 54 54 55 55 end % }}} 56 function marshall( obj,md,fid) % {{{56 function marshall(self,md,fid) % {{{ 57 57 58 58 yts=365.0*24.0*3600.0; 59 59 60 60 WriteData(fid,'enum',SurfaceforcingsEnum(),'data',SMBgradientsEnum(),'format','Integer'); 61 WriteData(fid,'object', obj,'class','surfaceforcings','fieldname','href','format','DoubleMat','mattype',1,'forcinglength',md.mesh.numberofvertices+1);62 WriteData(fid,'object', obj,'class','surfaceforcings','fieldname','smbref','format','DoubleMat','mattype',1,'scale',1./yts,'forcinglength',md.mesh.numberofvertices+1);63 WriteData(fid,'object', obj,'class','surfaceforcings','fieldname','b_pos','format','DoubleMat','mattype',1,'scale',1./yts,'forcinglength',md.mesh.numberofvertices+1);64 WriteData(fid,'object', obj,'class','surfaceforcings','fieldname','b_neg','format','DoubleMat','mattype',1,'scale',1./yts,'forcinglength',md.mesh.numberofvertices+1);61 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','href','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1); 62 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','smbref','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1); 63 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','b_pos','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1); 64 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','b_neg','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1); 65 65 66 66 end % }}} -
issm/trunk/src/m/classes/SMBgradients.py
r17806 r19105 44 44 45 45 if MasstransportAnalysisEnum() in analyses: 46 md = checkfield(md,'fieldname','surfaceforcings.href',' forcing',1,'NaN',1)47 md = checkfield(md,'fieldname','surfaceforcings.smbref',' forcing',1,'NaN',1)48 md = checkfield(md,'fieldname','surfaceforcings.b_pos',' forcing',1,'NaN',1)49 md = checkfield(md,'fieldname','surfaceforcings.b_neg',' forcing',1,'NaN',1)46 md = checkfield(md,'fieldname','surfaceforcings.href','timeseries',1,'NaN',1) 47 md = checkfield(md,'fieldname','surfaceforcings.smbref','timeseries',1,'NaN',1) 48 md = checkfield(md,'fieldname','surfaceforcings.b_pos','timeseries',1,'NaN',1) 49 md = checkfield(md,'fieldname','surfaceforcings.b_neg','timeseries',1,'NaN',1) 50 50 51 51 return md … … 56 56 57 57 WriteData(fid,'enum',SurfaceforcingsEnum(),'data',SMBgradientsEnum(),'format','Integer'); 58 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','href','format','DoubleMat','mattype',1,' forcinglength',md.mesh.numberofvertices+1)59 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','smbref','format','DoubleMat','mattype',1,'scale',1./yts,' forcinglength',md.mesh.numberofvertices+1)60 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','b_pos','format','DoubleMat','mattype',1,'scale',1./yts,' forcinglength',md.mesh.numberofvertices+1)61 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','b_neg','format','DoubleMat','mattype',1,'scale',1./yts,' forcinglength',md.mesh.numberofvertices+1)58 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','href','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1) 59 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','smbref','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1) 60 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','b_pos','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1) 61 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','b_neg','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1) 62 62 # }}} -
issm/trunk/src/m/classes/SMBhenning.m
r17806 r19105 9 9 end 10 10 methods 11 function obj= SMBhenning(varargin) % {{{11 function self = SMBhenning(varargin) % {{{ 12 12 switch nargin 13 13 case 0 … … 29 29 30 30 end % }}} 31 function md = checkconsistency( obj,md,solution,analyses) % {{{31 function md = checkconsistency(self,md,solution,analyses) % {{{ 32 32 33 33 if ismember(MasstransportAnalysisEnum(),analyses), 34 md = checkfield(md,'fieldname','surfaceforcings.smbref',' forcing',1,'NaN',1);34 md = checkfield(md,'fieldname','surfaceforcings.smbref','timeseries',1,'NaN',1); 35 35 end 36 36 if ismember(BalancethicknessAnalysisEnum(),analyses), … … 38 38 end 39 39 end % }}} 40 function disp( obj) % {{{40 function disp(self) % {{{ 41 41 disp(sprintf(' surface forcings parameters:')); 42 fielddisplay( obj,'smbref','reference smb from which deviation is calculated [m/yr ice eq]');42 fielddisplay(self,'smbref','reference smb from which deviation is calculated [m/yr ice eq]'); 43 43 end % }}} 44 function marshall( obj,md,fid) % {{{44 function marshall(self,md,fid) % {{{ 45 45 46 46 yts=365.0*24.0*3600.0; 47 47 48 48 WriteData(fid,'enum',SurfaceforcingsEnum(),'data',SMBhenningEnum(),'format','Integer'); 49 WriteData(fid,'object', obj,'class','surfaceforcings','fieldname','smbref','format','DoubleMat','mattype',1,'scale',1./yts,'forcinglength',md.mesh.numberofvertices+1);49 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','smbref','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1); 50 50 end % }}} 51 51 end -
issm/trunk/src/m/classes/SMBmeltcomponents.m
r18301 r19105 12 12 end 13 13 methods 14 function obj= SMBmeltcomponents(varargin) % {{{14 function self = SMBmeltcomponents(varargin) % {{{ 15 15 switch nargin 16 16 case 0 … … 47 47 48 48 end % }}} 49 function md = checkconsistency( obj,md,solution,analyses) % {{{49 function md = checkconsistency(self,md,solution,analyses) % {{{ 50 50 51 51 if ismember(MasstransportAnalysisEnum(),analyses), 52 md = checkfield(md,'fieldname','surfaceforcings.accumulation',' forcing',1,'NaN',1);52 md = checkfield(md,'fieldname','surfaceforcings.accumulation','timeseries',1,'NaN',1); 53 53 end 54 54 if ismember(BalancethicknessAnalysisEnum(),analyses), … … 56 56 end 57 57 if ismember(MasstransportAnalysisEnum(),analyses), 58 md = checkfield(md,'fieldname','surfaceforcings.evaporation',' forcing',1,'NaN',1);58 md = checkfield(md,'fieldname','surfaceforcings.evaporation','timeseries',1,'NaN',1); 59 59 end 60 60 if ismember(BalancethicknessAnalysisEnum(),analyses), … … 62 62 end 63 63 if ismember(MasstransportAnalysisEnum(),analyses), 64 md = checkfield(md,'fieldname','surfaceforcings.refreeze',' forcing',1,'NaN',1);64 md = checkfield(md,'fieldname','surfaceforcings.refreeze','timeseries',1,'NaN',1); 65 65 end 66 66 if ismember(BalancethicknessAnalysisEnum(),analyses), … … 68 68 end 69 69 if ismember(MasstransportAnalysisEnum(),analyses), 70 md = checkfield(md,'fieldname','surfaceforcings.melt',' forcing',1,'NaN',1);70 md = checkfield(md,'fieldname','surfaceforcings.melt','timeseries',1,'NaN',1); 71 71 end 72 72 if ismember(BalancethicknessAnalysisEnum(),analyses), … … 74 74 end 75 75 end % }}} 76 function disp( obj) % {{{76 function disp(self) % {{{ 77 77 disp(sprintf(' surface forcings parameters with melt (SMB=accumulation-evaporation-melt+refreeze) :')); 78 fielddisplay( obj,'accumulation','accumulated snow [m/yr ice eq]');79 fielddisplay( obj,'evaporation','amount of ice lost to evaporative processes [m/yr ice eq]');80 fielddisplay( obj,'melt','amount of ice melt in ice column [m/yr ice eq]');81 fielddisplay( obj,'refreeze','amount of ice melt refrozen in ice column [m/yr ice eq]');78 fielddisplay(self,'accumulation','accumulated snow [m/yr ice eq]'); 79 fielddisplay(self,'evaporation','amount of ice lost to evaporative processes [m/yr ice eq]'); 80 fielddisplay(self,'melt','amount of ice melt in ice column [m/yr ice eq]'); 81 fielddisplay(self,'refreeze','amount of ice melt refrozen in ice column [m/yr ice eq]'); 82 82 end % }}} 83 function marshall( obj,md,fid) % {{{83 function marshall(self,md,fid) % {{{ 84 84 85 85 yts=365.0*24.0*3600.0; 86 86 87 87 WriteData(fid,'enum',SurfaceforcingsEnum(),'data',SMBmeltcomponentsEnum(),'format','Integer'); 88 WriteData(fid,'object', obj,'class','surfaceforcings','fieldname','accumulation','format','DoubleMat','mattype',1,'scale',1./yts,'forcinglength',md.mesh.numberofvertices+1);89 WriteData(fid,'object', obj,'class','surfaceforcings','fieldname','evaporation','format','DoubleMat','mattype',1,'scale',1./yts,'forcinglength',md.mesh.numberofvertices+1);90 WriteData(fid,'object', obj,'class','surfaceforcings','fieldname','melt','format','DoubleMat','mattype',1,'scale',1./yts,'forcinglength',md.mesh.numberofvertices+1);91 WriteData(fid,'object', obj,'class','surfaceforcings','fieldname','refreeze','format','DoubleMat','mattype',1,'scale',1./yts,'forcinglength',md.mesh.numberofvertices+1);88 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','accumulation','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1); 89 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','evaporation','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1); 90 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','melt','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1); 91 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','refreeze','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1); 92 92 end % }}} 93 93 end -
issm/trunk/src/m/classes/SMBmeltcomponents.py
r18301 r19105 57 57 58 58 if MasstransportAnalysisEnum() in analyses: 59 md = checkfield(md,'fieldname','surfaceforcings.accumulation',' forcing',1,'NaN',1)59 md = checkfield(md,'fieldname','surfaceforcings.accumulation','timeseries',1,'NaN',1) 60 60 61 61 if BalancethicknessAnalysisEnum() in analyses: … … 63 63 64 64 if MasstransportAnalysisEnum() in analyses: 65 md = checkfield(md,'fieldname','surfaceforcings.melt',' forcing',1,'NaN',1)65 md = checkfield(md,'fieldname','surfaceforcings.melt','timeseries',1,'NaN',1) 66 66 67 67 if BalancethicknessAnalysisEnum() in analyses: … … 69 69 70 70 if MasstransportAnalysisEnum() in analyses: 71 md = checkfield(md,'fieldname','surfaceforcings.refreeze',' forcing',1,'NaN',1)71 md = checkfield(md,'fieldname','surfaceforcings.refreeze','timeseries',1,'NaN',1) 72 72 73 73 if BalancethicknessAnalysisEnum() in analyses: … … 75 75 76 76 if MasstransportAnalysisEnum() in analyses: 77 md = checkfield(md,'fieldname','surfaceforcings.evaporation',' forcing',1,'NaN',1)77 md = checkfield(md,'fieldname','surfaceforcings.evaporation','timeseries',1,'NaN',1) 78 78 79 79 if BalancethicknessAnalysisEnum() in analyses: … … 87 87 88 88 WriteData(fid,'enum',SurfaceforcingsEnum(),'data',SMBmeltcomponentsEnum(),'format','Integer'); 89 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','accumulation','format','DoubleMat','mattype',1,'scale',1./yts,' forcinglength',md.mesh.numberofvertices+1)90 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','evaporation','format','DoubleMat','mattype',1,'scale',1./yts,' forcinglength',md.mesh.numberofvertices+1)91 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','melt','format','DoubleMat','mattype',1,'scale',1./yts,' forcinglength',md.mesh.numberofvertices+1)92 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','refreeze','format','DoubleMat','mattype',1,'scale',1./yts,' forcinglength',md.mesh.numberofvertices+1)89 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','accumulation','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1) 90 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','evaporation','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1) 91 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','melt','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1) 92 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','refreeze','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1) 93 93 # }}} -
issm/trunk/src/m/classes/SMBpdd.m
r17806 r19105 8 8 precipitation = NaN; 9 9 monthlytemperatures = NaN; 10 desfac = 0 .5;10 desfac = 0; 11 11 s0p = 0; 12 s0t = 0; 13 rlaps = 0; 14 rlapslgm = 0; 15 Pfac = NaN; 16 Tdiff = NaN; 17 sealev = NaN; 12 18 isdelta18o = 0; 19 ismungsm = 0; 13 20 delta18o = NaN; 14 21 delta18o_surface = NaN; … … 16 23 temperatures_lgm = NaN; 17 24 precipitations_presentday = NaN; 25 precipitations_lgm = NaN; 18 26 end 19 27 methods 20 function obj= SMBpdd(varargin) % {{{28 function self = SMBpdd(varargin) % {{{ 21 29 switch nargin 22 30 case 0 23 obj=setdefaultparameters(obj);31 self=setdefaultparameters(self); 24 32 otherwise 25 33 error('constructor not supported'); … … 27 35 end % }}} 28 36 function self = extrude(self,md) % {{{ 29 30 self.precipitation=project3d(md,'vector',self.precipitation,'type','node'); 31 self.monthlytemperatures=project3d(md,'vector',self.monthlytemperatures,'type','node'); 37 if(self.isdelta18o==0 & self.ismungsm==0),self.precipitation=project3d(md,'vector',self.precipitation,'type','node');end 38 if(self.isdelta18o==0 & self.ismungsm==0),self.monthlytemperatures=project3d(md,'vector',self.monthlytemperatures,'type','node');end 32 39 if(self.isdelta18o),self.temperatures_lgm=project3d(md,'vector',self.temperatures_lgm,'type','node');end 33 40 if(self.isdelta18o),self.temperatures_presentday=project3d(md,'vector',self.temperatures_presentday,'type','node');end 34 41 if(self.isdelta18o),self.precipitations_presentday=project3d(md,'vector',self.precipitations_presentday,'type','node');end 35 42 if(self.isdelta18o),self.precipitations_lgm=project3d(md,'vector',self.precipitations_lgm,'type','node');end 43 if(self.ismungsm),self.temperatures_lgm=project3d(md,'vector',self.temperatures_lgm,'type','node');end 44 if(self.ismungsm),self.temperatures_presentday=project3d(md,'vector',self.temperatures_presentday,'type','node');end 45 if(self.ismungsm),self.precipitations_presentday=project3d(md,'vector',self.precipitations_presentday,'type','node');end 46 if(self.ismungsm),self.precipitations_lgm=project3d(md,'vector',self.precipitations_lgm,'type','node');end 36 47 37 48 end % }}} 38 49 function self = initialize(self,md) % {{{ 39 40 if isnan(self.precipitation),41 self.precipitation=zeros(md.mesh.numberofvertices,1);42 disp(' no SMBpdd.precipitation specified: values set as zero');43 end50 51 % if isnan(self.precipitation), 52 % self.precipitation=zeros(md.mesh.numberofvertices,1); 53 % disp(' no SMBpdd.precipitation specified: values set as zero'); 54 % end 44 55 45 56 end % }}} 46 function obj = setdefaultparameters(obj) % {{{57 function self = setdefaultparameters(self) % {{{ 47 58 48 obj.isdelta18o = 0; 49 obj.desfac = 0.5; 50 obj.s0p = 0; 59 self.isdelta18o = 0; 60 self.ismungsm = 0; 61 self.desfac = 0.5; 62 self.s0p = 0; 63 self.s0t = 0; 64 self.rlaps = 6.5; 65 self.rlapslgm = 6.5; 66 51 67 end % }}} 52 function md = checkconsistency( obj,md,solution,analyses) % {{{68 function md = checkconsistency(self,md,solution,analyses) % {{{ 53 69 54 70 if ismember(MasstransportAnalysisEnum(),analyses), 55 71 md = checkfield(md,'fieldname','surfaceforcings.desfac','<=',1,'numel',1); 56 72 md = checkfield(md,'fieldname','surfaceforcings.s0p','>=',0,'numel',1); 57 if(obj.isdelta18o==0) 58 md = checkfield(md,'fieldname','surfaceforcings.monthlytemperatures','forcing',1,'NaN',1); 59 md = checkfield(md,'fieldname','surfaceforcings.precipitation','forcing',1,'NaN',1); 60 else 73 md = checkfield(md,'fieldname','surfaceforcings.s0t','>=',0,'numel',1); 74 md = checkfield(md,'fieldname','surfaceforcings.rlaps','>=',0,'numel',1); 75 md = checkfield(md,'fieldname','surfaceforcings.rlapslgm','>=',0,'numel',1); 76 if(self.isdelta18o==0 & self.ismungsm==0) 77 md = checkfield(md,'fieldname','surfaceforcings.monthlytemperatures','timeseries',1,'NaN',1); 78 md = checkfield(md,'fieldname','surfaceforcings.precipitation','timeseries',1,'NaN',1); 79 elseif(self.isdelta18o==1) 61 80 md = checkfield(md,'fieldname','surfaceforcings.delta18o','NaN',1); 62 81 md = checkfield(md,'fieldname','surfaceforcings.delta18o_surface','NaN',1); … … 64 83 md = checkfield(md,'fieldname','surfaceforcings.temperatures_lgm','size',[md.mesh.numberofvertices+1 12],'NaN',1); 65 84 md = checkfield(md,'fieldname','surfaceforcings.precipitations_presentday','size',[md.mesh.numberofvertices+1 12],'NaN',1); 85 md = checkfield(md,'fieldname','surfaceforcings.precipitations_lgm','size',[md.mesh.numberofvertices+1 12],'NaN',1); 86 md = checkfield(md,'fieldname','surfaceforcings.Tdiff','NaN',1); 87 md = checkfield(md,'fieldname','surfaceforcings.sealev','NaN',1); 88 elseif(self.ismungsm==1) 89 md = checkfield(md,'fieldname','surfaceforcings.temperatures_presentday','size',[md.mesh.numberofvertices+1 12],'NaN',1); 90 md = checkfield(md,'fieldname','surfaceforcings.temperatures_lgm','size',[md.mesh.numberofvertices+1 12],'NaN',1); 91 md = checkfield(md,'fieldname','surfaceforcings.precipitations_presentday','size',[md.mesh.numberofvertices+1 12],'NaN',1); 92 md = checkfield(md,'fieldname','surfaceforcings.precipitations_lgm','size',[md.mesh.numberofvertices+1 12],'NaN',1); 93 md = checkfield(md,'fieldname','surfaceforcings.Pfac','NaN',1,'size',[2,NaN]); 94 md = checkfield(md,'fieldname','surfaceforcings.Tdiff','NaN',1); 95 md = checkfield(md,'fieldname','surfaceforcings.sealev','NaN',1); 66 96 end 67 97 end 68 98 end % }}} 69 function disp( obj) % {{{99 function disp(self) % {{{ 70 100 disp(sprintf(' surface forcings parameters:')); 71 101 72 102 disp(sprintf('\n PDD and deltaO18 parameters:')); 73 fielddisplay(obj,'isdelta18o','is temperature and precipitation delta18o parametrisation activated (0 or 1, default is 0)'); 74 fielddisplay(obj,'desfac','desertification elevation factor (between 0 and 1, default is 0.5) [m]'); 75 fielddisplay(obj,'s0p','should be set to elevation from precip source (between 0 and a few 1000s m, default is 0) [m]'); 76 fielddisplay(obj,'monthlytemperatures','monthly surface temperatures [K], required if pdd is activated and delta18o not activated'); 77 fielddisplay(obj,'precipitation','surface precipitation [m/yr water eq]'); 78 fielddisplay(obj,'temperatures_presentday','monthly present day surface temperatures [K], required if pdd is activated and delta18o activated'); 79 fielddisplay(obj,'temperatures_lgm','monthly LGM surface temperatures [K], required if pdd is activated and delta18o activated'); 80 fielddisplay(obj,'precipitations_presentday','monthly surface precipitation [m/yr water eq], required if pdd is activated and delta18o activated'); 81 fielddisplay(obj,'delta18o','delta18o, required if pdd is activated and delta18o activated'); 82 fielddisplay(obj,'delta18o_surface','surface elevation of the delta18o site, required if pdd is activated and delta18o activated'); 83 103 fielddisplay(self,'isdelta18o','is temperature and precipitation delta18o parametrisation activated (0 or 1, default is 0)'); 104 fielddisplay(self,'ismungsm','is temperature and precipitation mungsm parametrisation activated (0 or 1, default is 0)'); 105 fielddisplay(self,'desfac','desertification elevation factor (between 0 and 1, default is 0.5) [m]'); 106 fielddisplay(self,'s0p','should be set to elevation from precip source (between 0 and a few 1000s m, default is 0) [m]'); 107 fielddisplay(self,'s0t','should be set to elevation from temperature source (between 0 and a few 1000s m, default is 0) [m]'); 108 fielddisplay(self,'rlaps','present day lapse rate [degree/km]'); 109 fielddisplay(self,'rlapslgm','LGM lapse rate [degree/km]'); 110 if(self.isdelta18o==0 & self.ismungsm==0) 111 fielddisplay(self,'monthlytemperatures',['monthly surface temperatures [K], required if pdd is activated and delta18o not activated']); 112 fielddisplay(self,'precipitation',['monthly surface precipitation [m/yr water eq], required if pdd is activated and delta18o or mungsm not activated']); 113 elseif(self.isdelta18o==1) 114 fielddisplay(self,'delta18o','delta18o, required if pdd is activated and delta18o activated'); 115 fielddisplay(self,'delta18o_surface','surface elevation of the delta18o site, required if pdd is activated and delta18o activated'); 116 fielddisplay(self,'temperatures_presentday','monthly present day surface temperatures [K], required if delta18o/mungsm is activated'); 117 fielddisplay(self,'temperatures_lgm','monthly LGM surface temperatures [K], required if delta18o or mungsm is activated'); 118 fielddisplay(self,'precipitations_presentday','monthly surface precipitation [m/yr water eq], required if delta18o or mungsm is activated'); 119 fielddisplay(self,'precipitations_lgm','monthly surface precipitation [m/yr water eq], required if delta18o or mungsm is activated'); 120 fielddisplay(self,'Tdiff','time interpolation parameter for temperature, 1D(year), required if mungsm is activated'); 121 fielddisplay(self,'sealev','sea level [m], 1D(year), required if mungsm is activated'); 122 elseif(self.ismungsm==1) 123 fielddisplay(self,'temperatures_presentday','monthly present day surface temperatures [K], required if delta18o/mungsm is activated'); 124 fielddisplay(self,'temperatures_lgm','monthly LGM surface temperatures [K], required if delta18o or mungsm is activated'); 125 fielddisplay(self,'precipitations_presentday','monthly surface precipitation [m/yr water eq], required if delta18o or mungsm is activated'); 126 fielddisplay(self,'precipitations_lgm','monthly surface precipitation [m/yr water eq], required if delta18o or mungsm is activated'); 127 fielddisplay(self,'Pfac','time interpolation parameter for precipitation, 1D(year), required if mungsm is activated'); 128 fielddisplay(self,'Tdiff','time interpolation parameter for temperature, 1D(year), required if mungsm is activated'); 129 fielddisplay(self,'sealev','sea level [m], 1D(year), required if mungsm is activated'); 130 end 84 131 end % }}} 85 function marshall( obj,md,fid) % {{{132 function marshall(self,md,fid) % {{{ 86 133 87 134 yts=365.0*24.0*3600.0; … … 89 136 WriteData(fid,'enum',SurfaceforcingsEnum(),'data',SMBpddEnum(),'format','Integer'); 90 137 91 WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','precipitation','format','DoubleMat','mattype',1,'scale',1./yts,'forcinglength',md.mesh.numberofvertices+1); 92 WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','desfac','format','Double'); 93 WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','s0p','format','Double'); 94 WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','isdelta18o','format','Boolean'); 95 if obj.isdelta18o 96 WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','temperatures_presentday','format','DoubleMat','mattype',1); 97 WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','temperatures_lgm','format','DoubleMat','mattype',1); 98 WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','precipitations_presentday','format','DoubleMat','mattype',1); 99 WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','delta18o_surface','format','DoubleMat','mattype',1); 100 WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','delta18o','format','DoubleMat','mattype',1); 101 else 102 WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','monthlytemperatures','format','DoubleMat','mattype',1,'forcinglength',md.mesh.numberofvertices+1); 138 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','isdelta18o','format','Boolean'); 139 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','ismungsm','format','Boolean'); 140 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','desfac','format','Double'); 141 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','s0p','format','Double'); 142 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','s0t','format','Double'); 143 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','rlaps','format','Double'); 144 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','rlapslgm','format','Double'); 145 146 if(self.isdelta18o==0 & self.ismungsm==0) 147 %WriteData(fid,'object',self,'class','surfaceforcings','fieldname','monthlytemperatures','format','DoubleMat','mattype',1); 148 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','monthlytemperatures','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1); 149 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','precipitation','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1); 150 elseif self.isdelta18o 151 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','temperatures_presentday','format','DoubleMat','mattype',1); 152 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','temperatures_lgm','format','DoubleMat','mattype',1); 153 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','precipitations_presentday','format','DoubleMat','mattype',1); 154 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','precipitations_lgm','format','DoubleMat','mattype',1); 155 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','delta18o_surface','format','DoubleMat','mattype',1); 156 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','delta18o','format','DoubleMat','mattype',1); 157 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','Tdiff','format','DoubleMat','mattype',1); 158 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','sealev','format','DoubleMat','mattype',1); 159 elseif self.ismungsm 160 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','temperatures_presentday','format','DoubleMat','mattype',1); 161 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','temperatures_lgm','format','DoubleMat','mattype',1); 162 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','precipitations_presentday','format','DoubleMat','mattype',1); 163 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','precipitations_lgm','format','DoubleMat','mattype',1); 164 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','Pfac','format','DoubleMat','mattype',1); 165 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','Tdiff','format','DoubleMat','mattype',1); 166 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','sealev','format','DoubleMat','mattype',1); 103 167 end 104 168 end % }}} -
issm/trunk/src/m/classes/SMBpdd.py
r17806 r19105 19 19 self.desfac = 0. 20 20 self.s0p = 0. 21 self.s0t = 0. 22 self.rlaps = 0. 23 self.rlapslgm = 0. 24 self.Pfac = float('NaN') 25 self.Tdiff = float('NaN') 26 self.sealev = float('NaN') 21 27 self.isdelta18o = 0 28 self.ismungsm = 0 22 29 self.delta18o = float('NaN') 23 30 self.delta18o_surface = float('NaN') … … 25 32 self.temperatures_lgm = float('NaN') 26 33 self.precipitations_presentday = float('NaN') 34 self.precipitations_lgm = float('NaN') 27 35 28 36 #set defaults … … 32 40 string=" surface forcings parameters:" 33 41 34 string="%s\n%s"%(string,fielddisplay(self,'precipitation','surface precipitation [m/yr water eq]')) 42 string="%s\n%s"%(string,fielddisplay(self,'isdelta18o','is temperature and precipitation delta18o parametrisation activated (0 or 1, default is 0)')) 43 string="%s\n%s"%(string,fielddisplay(self,'ismungsm','is temperature and precipitation mungsm parametrisation activated (0 or 1, default is 0)')) 35 44 string="%s\n%s"%(string,fielddisplay(self,'desfac','desertification elevation factor (between 0 and 1, default is 0.5) [m]')) 36 string="%s\n%s"%(string,fielddisplay(self,'isdelta18o','is temperature and precipitation delta18o parametrisation activated (0 or 1, default is 0)'))37 45 string="%s\n%s"%(string,fielddisplay(self,'s0p','should be set to elevation from precip source (between 0 and a few 1000s m, default is 0) [m]')) 38 string="%s\n%s"%(string,fielddisplay(self,'monthlytemperatures','monthly surface temperatures [K], required if pdd is activated and delta18o not activated')) 39 string="%s\n%s"%(string,fielddisplay(self,'temperatures_presentday','monthly present day surface temperatures [K], required if pdd is activated and delta18o activated')) 40 string="%s\n%s"%(string,fielddisplay(self,'temperatures_lgm','monthly LGM surface temperatures [K], required if pdd is activated and delta18o activated')) 41 string="%s\n%s"%(string,fielddisplay(self,'precipitations_presentday','monthly surface precipitation [m/yr water eq], required if pdd is activated and delta18o activated')) 42 string="%s\n%s"%(string,fielddisplay(self,'delta18o','delta18o, required if pdd is activated and delta18o activated')) 43 string="%s\n%s"%(string,fielddisplay(self,'delta18o_surface','surface elevation of the delta18o site, required if pdd is activated and delta18o activated')) 44 46 string="%s\n%s"%(string,fielddisplay(self,'s0t','should be set to elevation from temperature source (between 0 and a few 1000s m, default is 0) [m]')) 47 string="%s\n%s"%(string,fielddisplay(self,'rlaps','present day lapse rate [degree/km]')) 48 string="%s\n%s"%(string,fielddisplay(self,'rlapslgm','LGM lapse rate [degree/km]')) 49 if not (self.isdelta18o and self.ismungsm): 50 string="%s\n%s"%(string,fielddisplay(self,'monthlytemperatures',['monthly surface temperatures [K], required if pdd is activated and delta18o not activated'])) 51 string="%s\n%s"%(string,fielddisplay(self,'precipitation',['monthly surface precipitation [m/yr water eq], required if pdd is activated and delta18o or mungsm not activated'])) 52 if self.isdelta18o: 53 string="%s\n%s"%(string,fielddisplay(self,'delta18o','delta18o, required if pdd is activated and delta18o activated')) 54 string="%s\n%s"%(string,fielddisplay(self,'delta18o_surface','surface elevation of the delta18o site, required if pdd is activated and delta18o activated')) 55 string="%s\n%s"%(string,fielddisplay(self,'temperatures_presentday','monthly present day surface temperatures [K], required if delta18o/mungsm is activated')) 56 string="%s\n%s"%(string,fielddisplay(self,'temperatures_lgm','monthly LGM surface temperatures [K], required if delta18o or mungsm is activated')) 57 string="%s\n%s"%(string,fielddisplay(self,'precipitations_presentday','monthly surface precipitation [m/yr water eq], required if delta18o or mungsm is activated')) 58 string="%s\n%s"%(string,fielddisplay(self,'precipitations_lgm','monthly surface precipitation [m/yr water eq], required if delta18o or mungsm is activated')) 59 string="%s\n%s"%(string,fielddisplay(self,'Tdiff','time interpolation parameter for temperature, 1D(year), required if mungsm is activated')) 60 string="%s\n%s"%(string,fielddisplay(self,'sealev','sea level [m], 1D(year), required if mungsm is activated')) 61 if self.ismungsm: 62 string="%s\n%s"%(string,fielddisplay(self,'temperatures_presentday','monthly present day surface temperatures [K], required if delta18o/mungsm is activated')) 63 string="%s\n%s"%(string,fielddisplay(self,'temperatures_lgm','monthly LGM surface temperatures [K], required if delta18o or mungsm is activated')) 64 string="%s\n%s"%(string,fielddisplay(self,'precipitations_presentday','monthly surface precipitation [m/yr water eq], required if delta18o or mungsm is activated')) 65 string="%s\n%s"%(string,fielddisplay(self,'precipitations_lgm','monthly surface precipitation [m/yr water eq], required if delta18o or mungsm is activated')) 66 string="%s\n%s"%(string,fielddisplay(self,'Pfac','time interpolation parameter for precipitation, 1D(year), required if mungsm is activated')) 67 string="%s\n%s"%(string,fielddisplay(self,'Tdiff','time interpolation parameter for temperature, 1D(year), required if mungsm is activated')) 68 string="%s\n%s"%(string,fielddisplay(self,'sealev','sea level [m], 1D(year), required if mungsm is activated')) 45 69 return string 46 70 #}}} 47 71 def extrude(self,md): # {{{ 48 72 49 self.precipitation=project3d(md,'vector',self.precipitation,'type','node'); 50 self.monthlytemperatures=project3d(md,'vector',self.monthlytemperatures,'type','node'); 73 if not (self.isdelta18o and self.ismungsm): 74 self.precipitation=project3d(md,'vector',self.precipitation,'type','node') 75 self.monthlytemperatures=project3d(md,'vector',self.monthlytemperatures,'type','node') 51 76 if self.isdelta18o: self.temperatures_lgm=project3d(md,'vector',self.temperatures_lgm,'type','node') 52 77 if self.isdelta18o: self.temperatures_presentday=project3d(md,'vector',self.temperatures_presentday,'type','node') 53 78 if self.isdelta18o: self.precipitations_presentday=project3d(md,'vector',self.precipitations_presentday,'type','node') 79 if self.isdelta18o: self.precipitations_lgm=project3d(md,'vector',self.precipitations_lgm,'type','node') 80 if self.ismungsm: self.temperatures_lgm=project3d(md,'vector',self.temperatures_lgm,'type','node') 81 if self.ismungsm: self.temperatures_presentday=project3d(md,'vector',self.temperatures_presentday,'type','node') 82 if self.ismungsm: self.precipitations_presentday=project3d(md,'vector',self.precipitations_presentday,'type','node') 83 if self.ismungsm: self.precipitations_lgm=project3d(md,'vector',self.precipitations_lgm,'type','node') 54 84 return self 55 85 #}}} 56 86 def initialize(self,md): # {{{ 57 87 58 if numpy.all(numpy.isnan(self.precipitation)):59 self.precipitation=numpy.zeros((md.mesh.numberofvertices,1))60 print " no SMBpdd.precipitation specified: values set as zero"61 62 return self88 # if numpy.all(numpy.isnan(self.precipitation)): 89 # self.precipitation=numpy.zeros((md.mesh.numberofvertices,1)) 90 # print " no SMBpdd.precipitation specified: values set as zero" 91 # 92 return self 63 93 #}}} 64 94 def setdefaultparameters(self): # {{{ 65 95 66 96 #pdd method not used in default mode 67 97 self.isdelta18o = 0 98 self.ismungsm = 0 68 99 self.desfac = 0.5 69 100 self.s0p = 0. 101 self.s0t = 0. 102 self.rlaps = 6.5 103 self.rlapslgm = 6.5 70 104 71 105 return self … … 74 108 75 109 if MasstransportAnalysisEnum() in analyses: 76 md = checkfield(md,'fieldname','surfaceforcings.desfac','<=',1,'numel',[1]); 77 md = checkfield(md,'fieldname','surfaceforcings.s0p','>=',0,'numel',[1]); 78 if not self.isdelta18o: 79 md = checkfield(md,'fieldname','surfaceforcings.monthlytemperatures','forcing',1,'NaN',1) 80 md = checkfield(md,'fieldname','surfaceforcings.precipitation','forcing',1,'NaN',1) 81 else: 110 md = checkfield(md,'fieldname','surfaceforcings.desfac','<=',1,'numel',[1]) 111 md = checkfield(md,'fieldname','surfaceforcings.s0p','>=',0,'numel',[1]) 112 md = checkfield(md,'fieldname','surfaceforcings.s0t','>=',0,'numel',[1]) 113 md = checkfield(md,'fieldname','surfaceforcings.rlaps','>=',0,'numel',[1]) 114 md = checkfield(md,'fieldname','surfaceforcings.rlapslgm','>=',0,'numel',[1]) 115 116 if (self.isdelta18o==0 and self.ismungsm==0): 117 md = checkfield(md,'fieldname','surfaceforcings.monthlytemperatures','NaN',1) 118 md = checkfield(md,'fieldname','surfaceforcings.precipitation','NaN',1) 119 elif self.isdelta18o: 82 120 md = checkfield(md,'fieldname','surfaceforcings.delta18o','NaN',1) 83 121 md = checkfield(md,'fieldname','surfaceforcings.delta18o_surface','NaN',1) … … 85 123 md = checkfield(md,'fieldname','surfaceforcings.temperatures_lgm','size',[md.mesh.numberofvertices+1,12],'NaN',1) 86 124 md = checkfield(md,'fieldname','surfaceforcings.precipitations_presentday','size',[md.mesh.numberofvertices+1,12],'NaN',1) 125 md = checkfield(md,'fieldname','surfaceforcings.precipitations_lgm','size',[md.mesh.numberofvertices+1,12],'NaN',1) 126 md = checkfield(md,'fieldname','surfaceforcings.Tdiff','NaN',1,'size',[2,numpy.nan]) 127 md = checkfield(md,'fieldname','surfaceforcings.sealev','NaN',1,'size',[2,numpy.nan]) 128 elif self.ismungsm: 129 md = checkfield(md,'fieldname','surfaceforcings.temperatures_presentday','size',[md.mesh.numberofvertices+1,12],'NaN',1) 130 md = checkfield(md,'fieldname','surfaceforcings.temperatures_lgm','size',[md.mesh.numberofvertices+1,12],'NaN',1) 131 md = checkfield(md,'fieldname','surfaceforcings.precipitations_presentday','size',[md.mesh.numberofvertices+1,12],'NaN',1) 132 md = checkfield(md,'fieldname','surfaceforcings.precipitations_lgm','size',[md.mesh.numberofvertices+1,12],'NaN',1) 133 md = checkfield(md,'fieldname','surfaceforcings.Pfac','NaN',1,'size',[2,numpy.nan]) 134 md = checkfield(md,'fieldname','surfaceforcings.Tdiff','NaN',1,'size',[2,numpy.nan]) 135 md = checkfield(md,'fieldname','surfaceforcings.sealev','NaN',1,'size',[2,numpy.nan]) 87 136 88 137 return md … … 92 141 yts=365.0*24.0*3600.0 93 142 94 WriteData(fid,'enum',SurfaceforcingsEnum(),'data',SMBpddEnum(),'format','Integer') ;143 WriteData(fid,'enum',SurfaceforcingsEnum(),'data',SMBpddEnum(),'format','Integer') 95 144 96 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','precipitation','format','DoubleMat','mattype',1,'scale',1./yts,'forcinglength',md.mesh.numberofvertices+1)97 145 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','isdelta18o','format','Boolean') 98 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','desfac','format','Double'); 99 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','s0p','format','Double'); 100 if self.isdelta18o: 146 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','ismungsm','format','Boolean') 147 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','desfac','format','Double') 148 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','s0p','format','Double') 149 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','s0t','format','Double') 150 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','rlaps','format','Double') 151 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','rlapslgm','format','Double') 152 153 if (self.isdelta18o==0 and self.ismungsm==0): 154 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','monthlytemperatures','format','DoubleMat','mattype',1) 155 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','precipitation','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1) 156 elif self.isdelta18o: 101 157 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','temperatures_presentday','format','DoubleMat','mattype',1) 102 158 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','temperatures_lgm','format','DoubleMat','mattype',1) 103 159 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','precipitations_presentday','format','DoubleMat','mattype',1) 160 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','precipitations_lgm','format','DoubleMat','mattype',1) 104 161 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','delta18o_surface','format','DoubleMat','mattype',1) 105 162 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','delta18o','format','DoubleMat','mattype',1) 106 else: 107 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','monthlytemperatures','format','DoubleMat','mattype',1,'forcinglength',md.mesh.numberofvertices+1) 163 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','Tdiff','format','DoubleMat','mattype',1) 164 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','sealev','format','DoubleMat','mattype',1) 165 elif self.ismungsm: 166 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','temperatures_presentday','format','DoubleMat','mattype',1) 167 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','temperatures_lgm','format','DoubleMat','mattype',1) 168 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','precipitations_presentday','format','DoubleMat','mattype',1) 169 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','precipitations_lgm','format','DoubleMat','mattype',1) 170 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','Pfac','format','DoubleMat','mattype',1) 171 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','Tdiff','format','DoubleMat','mattype',1) 172 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','sealev','format','DoubleMat','mattype',1) 108 173 # }}} -
issm/trunk/src/m/classes/autodiff.m
r17806 r19105 20 20 %}}} 21 21 methods 22 function createxml( obj,fid) % {{{22 function createxml(self,fid) % {{{ 23 23 fprintf(fid, '<!-- autodiff -->\n'); 24 24 25 25 % automatic differentiation parameters 26 26 fprintf(fid,'%s\n%s\n%s\n','<frame key="1" label="automatic differentiation parameters">','<section name="autodiff" />'); 27 fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n%s\n',' <parameter key ="isautodiff" type="',class( obj.isautodiff),'" optional="false">',' <section name="autodiff" />',' <option value="',convert2str(obj.isautodiff),'" type="string" default="true"></option>',' <help> indicates if the automatic differentiation is activated </help>',' </parameter>');27 fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n%s\n',' <parameter key ="isautodiff" type="',class(self.isautodiff),'" optional="false">',' <section name="autodiff" />',' <option value="',convert2str(self.isautodiff),'" type="string" default="true"></option>',' <help> indicates if the automatic differentiation is activated </help>',' </parameter>'); 28 28 29 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="dependents" type="',class( obj.dependents),'" default="',convert2str(obj.dependents),'">',' <section name="autodiff" />',' <help> list of dependent variables </help>',' </parameter>');30 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="independents" type="',class( obj.independents),'" default="',convert2str(obj.independents),'">',' <section name="autodiff" />',' <help> list of independent variables </help>',' </parameter>');31 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="driver" type="',class( obj.driver),'" default="',convert2str(obj.driver),'">',' <section name="autodiff" />',' <help> ADOLC driver (''fos_forward'' or ''fov_forward'') </help>',' </parameter>');32 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="obufsize" type="',class( obj.obufsize),'" default="',convert2str(obj.obufsize),'">',' <section name="autodiff" />',' <help> Number of operations per buffer (==OBUFSIZE in usrparms.h) </help>',' </parameter>');33 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="lbufsize" type="',class( obj.lbufsize),'" default="',convert2str(obj.lbufsize),'">',' <section name="autodiff" />',' <help> Number of locations per buffer (==LBUFSIZE in usrparms.h) </help>',' </parameter>');34 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="cbufsize" type="',class( obj.cbufsize),'" default="',convert2str(obj.cbufsize),'">',' <section name="autodiff" />',' <help> Number of values per buffer (==CBUFSIZE in usrparms.h) </help>',' </parameter>');35 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="tbufsize" type="',class( obj.tbufsize),'" default="',convert2str(obj.tbufsize),'">',' <section name="autodiff" />',' <help> Number of taylors per buffer (&lt;=TBUFSIZE in usrparms.h) </help>',' </parameter>');36 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="gcTriggerRatio" type="',class( obj.gcTriggerRatio),'" default="',convert2str(obj.gcTriggerRatio),'">',' <section name="autodiff" />',' <help> free location block sorting/consolidation triggered if the ratio between allocated and used locations exceeds gcTriggerRatio </help>',' </parameter>');37 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="gcTriggerRatio" type="',class( obj.gcTriggerRatio),'" default="',convert2str(obj.gcTriggerRatio),'">',' <section name="autodiff" />',' <help> free location block sorting/consolidation triggered if the allocated locations exceed gcTriggerMaxSize </help>',' </parameter>');29 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="dependents" type="',class(self.dependents),'" default="',convert2str(self.dependents),'">',' <section name="autodiff" />',' <help> list of dependent variables </help>',' </parameter>'); 30 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="independents" type="',class(self.independents),'" default="',convert2str(self.independents),'">',' <section name="autodiff" />',' <help> list of independent variables </help>',' </parameter>'); 31 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="driver" type="',class(self.driver),'" default="',convert2str(self.driver),'">',' <section name="autodiff" />',' <help> ADOLC driver (''fos_forward'' or ''fov_forward'') </help>',' </parameter>'); 32 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="obufsize" type="',class(self.obufsize),'" default="',convert2str(self.obufsize),'">',' <section name="autodiff" />',' <help> Number of operations per buffer (==OBUFSIZE in usrparms.h) </help>',' </parameter>'); 33 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="lbufsize" type="',class(self.lbufsize),'" default="',convert2str(self.lbufsize),'">',' <section name="autodiff" />',' <help> Number of locations per buffer (==LBUFSIZE in usrparms.h) </help>',' </parameter>'); 34 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="cbufsize" type="',class(self.cbufsize),'" default="',convert2str(self.cbufsize),'">',' <section name="autodiff" />',' <help> Number of values per buffer (==CBUFSIZE in usrparms.h) </help>',' </parameter>'); 35 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="tbufsize" type="',class(self.tbufsize),'" default="',convert2str(self.tbufsize),'">',' <section name="autodiff" />',' <help> Number of taylors per buffer (&lt;=TBUFSIZE in usrparms.h) </help>',' </parameter>'); 36 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="gcTriggerRatio" type="',class(self.gcTriggerRatio),'" default="',convert2str(self.gcTriggerRatio),'">',' <section name="autodiff" />',' <help> free location block sorting/consolidation triggered if the ratio between allocated and used locations exceeds gcTriggerRatio </help>',' </parameter>'); 37 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="gcTriggerRatio" type="',class(self.gcTriggerRatio),'" default="',convert2str(self.gcTriggerRatio),'">',' <section name="autodiff" />',' <help> free location block sorting/consolidation triggered if the allocated locations exceed gcTriggerMaxSize </help>',' </parameter>'); 38 38 39 39 fprintf(fid,'%s\n%s\n','</frame>'); 40 40 41 41 end % }}} 42 function obj= autodiff(varargin) % {{{42 function self = autodiff(varargin) % {{{ 43 43 switch nargin 44 44 case 0 45 obj=setdefaultparameters(obj);45 self=setdefaultparameters(self); 46 46 otherwise 47 47 error('constructor not supported'); 48 48 end 49 49 end % }}} 50 function obj = setdefaultparameters(obj) % {{{51 obj.obufsize = 524288;52 obj.lbufsize = 524288;53 obj.cbufsize = 524288;54 obj.tbufsize = 524288;55 obj.gcTriggerRatio=2.0;56 obj.gcTriggerMaxSize=65536;57 end % }}} 58 function md = checkconsistency( obj,md,solution,analyses) % {{{50 function self = setdefaultparameters(self) % {{{ 51 self.obufsize = 524288; 52 self.lbufsize = 524288; 53 self.cbufsize = 524288; 54 self.tbufsize = 524288; 55 self.gcTriggerRatio=2.0; 56 self.gcTriggerMaxSize=65536; 57 end % }}} 58 function md = checkconsistency(self,md,solution,analyses) % {{{ 59 59 60 60 %Early return 61 if ~ obj.isautodiff, return; end61 if ~self.isautodiff, return; end 62 62 63 63 %Driver value: … … 73 73 74 74 %go through our dependents and independents and check consistency: 75 for i=1:numel( obj.dependents),76 dep= obj.dependents{i};75 for i=1:numel(self.dependents), 76 dep=self.dependents{i}; 77 77 md=checkconsistency(dep,md,solution,analyses); 78 78 end 79 for i=1:numel( obj.independents),80 indep= obj.independents{i};81 md=checkconsistency(indep,md,i,solution,analyses, obj.driver);82 end 83 84 end % }}} 85 function disp( obj) % {{{79 for i=1:numel(self.independents), 80 indep=self.independents{i}; 81 md=checkconsistency(indep,md,i,solution,analyses,self.driver); 82 end 83 84 end % }}} 85 function disp(self) % {{{ 86 86 disp(sprintf(' automatic differentiation parameters:')); 87 fielddisplay( obj,'isautodiff','indicates if the automatic differentiation is activated');88 fielddisplay( obj,'dependents','list of dependent variables');89 fielddisplay( obj,'independents','list of independent variables');90 fielddisplay( obj,'driver','ADOLC driver (''fos_forward'' or ''fov_forward'')');91 fielddisplay( obj,'obufsize','Number of operations per buffer (==OBUFSIZE in usrparms.h)');92 fielddisplay( obj,'lbufsize','Number of locations per buffer (==LBUFSIZE in usrparms.h)');93 fielddisplay( obj,'cbufsize','Number of values per buffer (==CBUFSIZE in usrparms.h)');94 fielddisplay( obj,'tbufsize','Number of taylors per buffer (<=TBUFSIZE in usrparms.h)');95 fielddisplay( obj,'gcTriggerRatio','free location block sorting/consolidation triggered if the ratio between allocated and used locations exceeds gcTriggerRatio');96 fielddisplay( obj,'gcTriggerMaxSize','free location block sorting/consolidation triggered if the allocated locations exceed gcTriggerMaxSize');97 end % }}} 98 function marshall( obj,md,fid) % {{{99 100 WriteData(fid,'object', obj,'fieldname','isautodiff','format','Boolean');101 WriteData(fid,'object', obj,'fieldname','driver','format','String');87 fielddisplay(self,'isautodiff','indicates if the automatic differentiation is activated'); 88 fielddisplay(self,'dependents','list of dependent variables'); 89 fielddisplay(self,'independents','list of independent variables'); 90 fielddisplay(self,'driver','ADOLC driver (''fos_forward'' or ''fov_forward'')'); 91 fielddisplay(self,'obufsize','Number of operations per buffer (==OBUFSIZE in usrparms.h)'); 92 fielddisplay(self,'lbufsize','Number of locations per buffer (==LBUFSIZE in usrparms.h)'); 93 fielddisplay(self,'cbufsize','Number of values per buffer (==CBUFSIZE in usrparms.h)'); 94 fielddisplay(self,'tbufsize','Number of taylors per buffer (<=TBUFSIZE in usrparms.h)'); 95 fielddisplay(self,'gcTriggerRatio','free location block sorting/consolidation triggered if the ratio between allocated and used locations exceeds gcTriggerRatio'); 96 fielddisplay(self,'gcTriggerMaxSize','free location block sorting/consolidation triggered if the allocated locations exceed gcTriggerMaxSize'); 97 end % }}} 98 function marshall(self,md,fid) % {{{ 99 100 WriteData(fid,'object',self,'fieldname','isautodiff','format','Boolean'); 101 WriteData(fid,'object',self,'fieldname','driver','format','String'); 102 102 103 103 %early return 104 if ~ obj.isautodiff,104 if ~self.isautodiff, 105 105 WriteData(fid,'data',false,'enum',AutodiffMassFluxSegmentsPresentEnum(),'format','Boolean'); 106 106 WriteData(fid,'data',false,'enum',AutodiffKeepEnum(),'format','Boolean'); … … 109 109 110 110 %buffer sizes {{{ 111 WriteData(fid,'object', obj,'fieldname','obufsize','format','Double');112 WriteData(fid,'object', obj,'fieldname','lbufsize','format','Double');113 WriteData(fid,'object', obj,'fieldname','cbufsize','format','Double');114 WriteData(fid,'object', obj,'fieldname','tbufsize','format','Double');115 WriteData(fid,'object', obj,'fieldname','gcTriggerRatio','format','Double');116 WriteData(fid,'object', obj,'fieldname','gcTriggerMaxSize','format','Double');111 WriteData(fid,'object',self,'fieldname','obufsize','format','Double'); 112 WriteData(fid,'object',self,'fieldname','lbufsize','format','Double'); 113 WriteData(fid,'object',self,'fieldname','cbufsize','format','Double'); 114 WriteData(fid,'object',self,'fieldname','tbufsize','format','Double'); 115 WriteData(fid,'object',self,'fieldname','gcTriggerRatio','format','Double'); 116 WriteData(fid,'object',self,'fieldname','gcTriggerMaxSize','format','Double'); 117 117 %}}} 118 118 %process dependent variables {{{ 119 num_dependent_objects=numel( obj.dependents);119 num_dependent_objects=numel(self.dependents); 120 120 WriteData(fid,'data',num_dependent_objects,'enum',AutodiffNumDependentObjectsEnum(),'format','Integer'); 121 121 … … 126 126 127 127 for i=1:num_dependent_objects, 128 dep= obj.dependents{i};128 dep=self.dependents{i}; 129 129 130 130 names{i}=dep.name; … … 138 138 %}}} 139 139 %process independent variables {{{ 140 num_independent_objects=numel( obj.independents);140 num_independent_objects=numel(self.independents); 141 141 WriteData(fid,'data',num_independent_objects,'enum',AutodiffNumIndependentObjectsEnum(),'format','Integer'); 142 142 … … 146 146 147 147 for i=1:num_independent_objects, 148 indep= obj.independents{i};148 indep=self.independents{i}; 149 149 150 150 names(i)=StringToEnum(indep.name); … … 156 156 %}}} 157 157 %if driver is fos_forward, build index: {{{ 158 if strcmpi( obj.driver,'fos_forward'),158 if strcmpi(self.driver,'fos_forward'), 159 159 index=0; 160 160 161 161 for i=1:num_independent_objects, 162 indep= obj.independents{i};162 indep=self.independents{i}; 163 163 if ~isnan(indep.fos_forward_index), 164 164 index=index+indep.fos_forward_index; … … 177 177 %}}} 178 178 %if driver is fos_reverse, build index: {{{ 179 if strcmpi( obj.driver,'fos_reverse'),179 if strcmpi(self.driver,'fos_reverse'), 180 180 index=0; 181 181 182 182 for i=1:num_dependent_objects, 183 dep= obj.dependents{i};183 dep=self.dependents{i}; 184 184 if ~isnan(dep.fos_reverse_index), 185 185 index=index+dep.fos_reverse_index; … … 198 198 %}}} 199 199 %if driver is fov_forward, build indices: {{{ 200 if strcmpi( obj.driver,'fov_forward'),200 if strcmpi(self.driver,'fov_forward'), 201 201 indices=0; 202 202 203 203 for i=1:num_independent_objects, 204 indep= obj.independents{i};204 indep=self.independents{i}; 205 205 if ~isempty(indep.fos_forward_index), 206 206 indices=indices+indep.fov_forward_indices; … … 221 221 mass_flux_segments=cell(0,1); 222 222 for i=1:num_dependent_objects, 223 dep= obj.dependents{i};223 dep=self.dependents{i}; 224 224 if strcmpi(dep.name,'MassFlux'), 225 225 mass_flux_segments{end+1,1}=dep.segments; … … 244 244 % 245 245 246 if length( obj.driver)<=3,246 if length(self.driver)<=3, 247 247 keep=false; %there is no "_reverse" string within the driver string: 248 248 else 249 if strncmpi( obj.driver(4:end),'_reverse',8),249 if strncmpi(self.driver(4:end),'_reverse',8), 250 250 keep=true; 251 251 else -
issm/trunk/src/m/classes/balancethickness.m
r17989 r19105 9 9 thickening_rate = NaN; 10 10 stabilization = 0; 11 12 omega = NaN; 11 13 end 12 14 methods 13 function createxml(obj,fid) % {{{ 14 fprintf(fid, '\n\n'); 15 fprintf(fid, '%s\n', '<!-- balancethickness -->'); 16 17 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="spcthickness" type="', class(obj.spcthickness),'" default="', convert2str(obj.spcthickness),'">', ' <section name="balancethickness" />',' <help> thickness constraints (NaN means no constraint) [m] </help>','</parameter>'); 18 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="thickening_rate" type="', class(obj.thickening_rate),'" default="', convert2str(obj.thickening_rate),'">', ' <section name="balancethickness" />',' <help> ice thickening rate used in the mass conservation (dh/dt) [m/yr] </help>','</parameter>'); 19 20 % balancethickness drop-down (1,2, or 3) 21 fprintf(fid,'%s\n%s\n%s\n', '<parameter key ="stabilization" type="alternative" optional="false">',' <section name="balancethickness" />',' <help> 0: None, 1: SU, 2: SSAs artificial diffusivity, 3:DG </help>'); 22 fprintf(fid,'%s\n',' <option value="1" type="string" default="true"> </option>'); 23 fprintf(fid,'%s\n',' <option value="2" type="string" default="false"> </option>'); 24 fprintf(fid,'%s\n%s\n',' <option value="3" type="string" default="false"> </option>','</parameter>'); 25 26 end % }}} 27 function obj = balancethickness(varargin) % {{{ 15 function self = balancethickness(varargin) % {{{ 28 16 switch nargin 29 17 case 0 30 obj=setdefaultparameters(obj);18 self=setdefaultparameters(self); 31 19 otherwise 32 20 error('constructor not supported'); 33 21 end 34 22 end % }}} 35 function obj = setdefaultparameters(obj) % {{{23 function self = setdefaultparameters(self) % {{{ 36 24 37 25 %Type of stabilization used 38 obj.stabilization=1;26 self.stabilization=1; 39 27 40 28 end % }}} 41 function md = checkconsistency( obj,md,solution,analyses) % {{{29 function md = checkconsistency(self,md,solution,analyses) % {{{ 42 30 %Early return 43 31 if solution~=BalancethicknessSolutionEnum(), return; end … … 46 34 md = checkfield(md,'fieldname','balancethickness.thickening_rate','size',[md.mesh.numberofvertices 1],'NaN',1); 47 35 md = checkfield(md,'fieldname','balancethickness.stabilization','size',[1 1],'values',[0 1 2 3]); 36 37 %md = checkfield(md,'fieldname','balancethickness.omega','size',[md.mesh.numberofvertices 1],'NaN',1,'>=',0); 48 38 end % }}} 49 function disp( obj) % {{{39 function disp(self) % {{{ 50 40 disp(sprintf(' balance thickness solution parameters:')); 51 41 52 fielddisplay( obj,'spcthickness','thickness constraints (NaN means no constraint) [m]');53 fielddisplay( obj,'thickening_rate','ice thickening rate used in the mass conservation (dh/dt) [m/yr]');54 fielddisplay( obj,'stabilization','0: None, 1: SU, 2: SSA''s artificial diffusivity, 3:DG');42 fielddisplay(self,'spcthickness','thickness constraints (NaN means no constraint) [m]'); 43 fielddisplay(self,'thickening_rate','ice thickening rate used in the mass conservation (dh/dt) [m/yr]'); 44 fielddisplay(self,'stabilization','0: None, 1: SU, 2: SSA''s artificial diffusivity, 3:DG'); 55 45 56 46 end % }}} 57 function marshall( obj,md,fid) % {{{47 function marshall(self,md,fid) % {{{ 58 48 59 49 yts=365.0*24.0*3600.0; 60 50 61 WriteData(fid,'object',obj,'fieldname','spcthickness','format','DoubleMat','mattype',1); 62 WriteData(fid,'object',obj,'fieldname','thickening_rate','format','DoubleMat','mattype',1,'scale',1./yts); 63 WriteData(fid,'object',obj,'fieldname','stabilization','format','Integer'); 51 WriteData(fid,'object',self,'fieldname','spcthickness','format','DoubleMat','mattype',1); 52 WriteData(fid,'object',self,'fieldname','thickening_rate','format','DoubleMat','mattype',1,'scale',1./yts); 53 WriteData(fid,'object',self,'fieldname','stabilization','format','Integer'); 54 55 WriteData(fid,'object',self,'fieldname','omega','format','DoubleMat','mattype',1); 64 56 end % }}} 65 57 end -
issm/trunk/src/m/classes/bamgmesh.m
r12706 r19105 23 23 CrackedVertices=[]; 24 24 CrackedEdges=[]; 25 PreviousNumbering=[]; 25 26 % }}} 26 27 end -
issm/trunk/src/m/classes/basalforcings.m
r18301 r19105 11 11 end 12 12 methods 13 function createxml(obj,fid) % {{{ 14 fprintf(fid, '\n\n'); 15 fprintf(fid, '%s\n', '<!-- basalforcings -->'); 16 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="melting_rate" type="', class(obj.melting_rate),'" default="', num2str(obj.melting_rate),'">', ' <section name="basalforcings" />',' <help> basal melting rate (positive if melting) [m/yr] </help>','</parameter>'); 17 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n', '<parameter key ="geothermalflux" type="', class(obj.geothermalflux),'" default="', num2str(obj.geothermalflux),'">', ' <section name="basalforcings" />',' <help> geothermal heat flux [W/m^2] </help>','</parameter>'); 18 19 end % }}} 20 function obj = basalforcings(varargin) % {{{ 13 function createxml(self,fid) % {{{ 14 fprintf(fid, '\n\n'); 15 fprintf(fid, '%s\n', '<!-- basalforcings -->'); 16 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="melting_rate" type="', class(self.melting_rate),'" default="', num2str(self.melting_rate),'">', ' <section name="basalforcings" />',' <help> basal melting rate (positive if melting) [m/yr] </help>','</parameter>'); 17 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n', '<parameter key ="geothermalflux" type="', class(self.geothermalflux),'" default="', num2str(self.geothermalflux),'">', ' <section name="basalforcings" />',' <help> geothermal heat flux [W/m^2] </help>','</parameter>'); 18 19 end % }}} 20 function self = extrude(self,md) % {{{ 21 self.groundedice_melting_rate=project3d(md,'vector',self.groundedice_melting_rate,'type','node','layer',1); 22 self.floatingice_melting_rate=project3d(md,'vector',self.floatingice_melting_rate,'type','node','layer',1); 23 self.geothermalflux=project3d(md,'vector',self.geothermalflux,'type','node','layer',1); %bedrock only gets geothermal flux 24 end % }}} 25 function self = basalforcings(varargin) % {{{ 21 26 switch nargin 22 27 case 0 23 obj=setdefaultparameters(obj);28 self=setdefaultparameters(self); 24 29 otherwise 25 30 error('constructor not supported'); … … 39 44 40 45 end % }}} 41 function obj = setdefaultparameters(obj) % {{{46 function self = setdefaultparameters(self) % {{{ 42 47 43 48 end % }}} 44 function md = checkconsistency( obj,md,solution,analyses) % {{{49 function md = checkconsistency(self,md,solution,analyses) % {{{ 45 50 46 51 if ismember(MasstransportAnalysisEnum(),analyses) & ~(solution==TransientSolutionEnum() & md.transient.ismasstransport==0), 47 md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,' forcing',1);48 md = checkfield(md,'fieldname','basalforcings.floatingice_melting_rate','NaN',1,' forcing',1);52 md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'timeseries',1); 53 md = checkfield(md,'fieldname','basalforcings.floatingice_melting_rate','NaN',1,'timeseries',1); 49 54 end 50 55 if ismember(BalancethicknessAnalysisEnum(),analyses), … … 53 58 end 54 59 if ismember(ThermalAnalysisEnum(),analyses) & ~(solution==TransientSolutionEnum() & md.transient.isthermal==0), 55 md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,' forcing',1);56 md = checkfield(md,'fieldname','basalforcings.floatingice_melting_rate','NaN',1,' forcing',1);57 md = checkfield(md,'fieldname','basalforcings.geothermalflux','NaN',1,' forcing',1,'>=',0);60 md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'timeseries',1); 61 md = checkfield(md,'fieldname','basalforcings.floatingice_melting_rate','NaN',1,'timeseries',1); 62 md = checkfield(md,'fieldname','basalforcings.geothermalflux','NaN',1,'timeseries',1,'>=',0); 58 63 end 59 64 end % }}} 60 function disp( obj) % {{{65 function disp(self) % {{{ 61 66 disp(sprintf(' basal forcings parameters:')); 62 67 63 fielddisplay( obj,'groundedice_melting_rate','basal melting rate (positive if melting) [m/yr]');64 fielddisplay( obj,'floatingice_melting_rate','basal melting rate (positive if melting) [m/yr]');65 fielddisplay( obj,'geothermalflux','geothermal heat flux [W/m^2]');68 fielddisplay(self,'groundedice_melting_rate','basal melting rate (positive if melting) [m/yr]'); 69 fielddisplay(self,'floatingice_melting_rate','basal melting rate (positive if melting) [m/yr]'); 70 fielddisplay(self,'geothermalflux','geothermal heat flux [W/m^2]'); 66 71 67 72 end % }}} 68 function marshall( obj,md,fid) % {{{73 function marshall(self,md,fid) % {{{ 69 74 70 75 yts=365.0*24.0*3600.0; 71 76 72 77 WriteData(fid,'enum',BasalforcingsEnum(),'data',FloatingMeltRateEnum(),'format','Integer'); 73 WriteData(fid,'object', obj,'fieldname','groundedice_melting_rate','format','DoubleMat','mattype',1,'scale',1./yts,'forcinglength',md.mesh.numberofvertices+1)74 WriteData(fid,'object', obj,'fieldname','floatingice_melting_rate','format','DoubleMat','mattype',1,'scale',1./yts,'forcinglength',md.mesh.numberofvertices+1)75 WriteData(fid,'object', obj,'fieldname','geothermalflux','format','DoubleMat','mattype',1,'forcinglength',md.mesh.numberofvertices+1);78 WriteData(fid,'object',self,'fieldname','groundedice_melting_rate','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1) 79 WriteData(fid,'object',self,'fieldname','floatingice_melting_rate','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1) 80 WriteData(fid,'object',self,'fieldname','geothermalflux','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1); 76 81 end % }}} 77 82 end -
issm/trunk/src/m/classes/basalforcings.py
r18301 r19105 1 1 from fielddisplay import fielddisplay 2 from project3d import project3d 2 3 from EnumDefinitions import * 3 4 from checkfield import checkfield … … 30 31 return string 31 32 #}}} 33 def extrude(self,md): # {{{ 34 self.groundedice_melting_rate=project3d(md,'vector',self.groundedice_melting_rate,'type','node','layer',1) 35 self.floatingice_melting_rate=project3d(md,'vector',self.floatingice_melting_rate,'type','node','layer',1) 36 self.geothermalflux=project3d(md,'vector',self.geothermalflux,'type','node','layer',1) #bedrock only gets geothermal flux 37 return self 38 #}}} 32 39 def initialize(self,md): # {{{ 33 40 … … 48 55 49 56 if MasstransportAnalysisEnum() in analyses and not (solution==TransientSolutionEnum() and not md.transient.ismasstransport): 50 md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,' forcing',1)51 md = checkfield(md,'fieldname','basalforcings.floatingice_melting_rate','NaN',1,' forcing',1)57 md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'timeseries',1) 58 md = checkfield(md,'fieldname','basalforcings.floatingice_melting_rate','NaN',1,'timeseries',1) 52 59 53 60 if BalancethicknessAnalysisEnum() in analyses: … … 56 63 57 64 if ThermalAnalysisEnum() in analyses and not (solution==TransientSolutionEnum() and not md.transient.isthermal): 58 md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,' forcing',1)59 md = checkfield(md,'fieldname','basalforcings.floatingice_melting_rate','NaN',1,' forcing',1)60 md = checkfield(md,'fieldname','basalforcings.geothermalflux','NaN',1,' forcing',1,'>=',0)65 md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'timeseries',1) 66 md = checkfield(md,'fieldname','basalforcings.floatingice_melting_rate','NaN',1,'timeseries',1) 67 md = checkfield(md,'fieldname','basalforcings.geothermalflux','NaN',1,'timeseries',1,'>=',0) 61 68 62 69 return md … … 67 74 68 75 WriteData(fid,'enum',BasalforcingsEnum(),'data',FloatingMeltRateEnum(),'format','Integer'); 69 WriteData(fid,'object',self,'fieldname','groundedice_melting_rate','format','DoubleMat','mattype',1,'scale',1./yts,' forcinglength',md.mesh.numberofvertices+1)70 WriteData(fid,'object',self,'fieldname','floatingice_melting_rate','format','DoubleMat','mattype',1,'scale',1./yts,' forcinglength',md.mesh.numberofvertices+1)71 WriteData(fid,'object',self,'fieldname','geothermalflux','format','DoubleMat','mattype',1,' forcinglength',md.mesh.numberofvertices+1)76 WriteData(fid,'object',self,'fieldname','groundedice_melting_rate','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1) 77 WriteData(fid,'object',self,'fieldname','floatingice_melting_rate','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1) 78 WriteData(fid,'object',self,'fieldname','geothermalflux','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1) 72 79 # }}} -
issm/trunk/src/m/classes/clusters/acenet.m
r17806 r19105 9 9 properties (SetAccess=public) 10 10 % {{{ 11 name='glacdyn.ace-net.ca'12 %name='placentia.ace-net.ca'11 %name='glacdyn.ace-net.ca' 12 name='placentia.ace-net.ca' 13 13 %name='brasdor.ace-net.ca' 14 14 login='klemorza'; … … 19 19 % codepath='/usr/local/issm-r11321/bin'; % this one is for issm on acenet global 20 20 codepath='/home/klemorza/issm/trunk-jpl/bin'; % this one is for issm on my acenet directory 21 executionpath='/home/klemorza/issm/trunk-jpl/execution'; 21 %executionpath='/home/klemorza/issm/trunk-jpl/execution'; 22 %executionpath='/home/klemorza/scratch/issmres.dir'; 23 executionpath='/net/glacdyn-data/glacdyn/1/klemorza/issm.dir'; 22 24 %}}} 23 25 end … … 50 52 51 53 available_queues={'debug','shortq','longq'}; 52 queue_requirements_time=[ 60*1 60*3 60*17];54 queue_requirements_time=[48*1 48*2 48*5]; 53 55 queue_requirements_np=[32 128 256]; 54 56 … … 66 68 fprintf(fid,'#$ -cwd\n'); 67 69 fprintf(fid,'#$ -N issm\n'); 68 fprintf(fid,'#$ -l h_rt=96:0:0\n'); 70 %fprintf(fid,'#$ -l h_rt=25:00:0\n'); 71 %fprintf(fid,'#$ -l h_rt=47:59:00\n'); 72 %fprintf(fid,'#$ -l h_rt=72:00:0\n'); 73 fprintf(fid,'#$ -l h_rt=96:00:0\n'); 74 fprintf(fid,'#$ -l h_vmem=4G\n'); 69 75 fprintf(fid,'#$ -pe ompi* %i\n',cluster.np); 70 76 fprintf(fid,'#$ -j y\n'); 77 fprintf(fid,'#$ -l h=cl27*|cl28*|cl29*|cl30*|cl31*|cl320|cl267|cl268|cl269|cl338 \n'); 78 %fprintf(fid,'#$ -l h=cl338 \n'); 79 %fprintf(fid,'#$ -pe openmp 20 \n'); 80 %fprintf(fid,'#$ -q !tarasov.q\n'); % 81 fprintf(fid,'#$ -pe openmp 8\n'); 71 82 fprintf(fid,'module purge\n'); 72 fprintf(fid,'module load gcc openmpi/gcc\n'); 73 fprintf(fid,'module load issm\n'); 74 fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME 75 fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n'); %FIXME 83 %fprintf(fid,'module load gcc openmpi/gcc\n'); 84 %fprintf(fid,'module unload openmpi\n'); 85 fprintf(fid,'module load intel/12.1.7.367\n'); 86 fprintf(fid,'module load openmpi/intel/1.2.9\n'); 87 88 fprintf(fid,'module load gsl\n'); 89 %fprintf(fid,'module load issm\n'); 90 fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME 91 fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n'); %FIXME 76 92 fprintf(fid,'\n'); 77 fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s 2> %s.errlog >%s.outlog ',... 78 cluster.np,cluster.codepath,EnumToString(solution),[cluster.executionpath '/' dirname],modelname,modelname,modelname); 93 fprintf(fid,'mpiexec %s/issm.exe %s %s %s 2> %s.errlog >%s.outlog\n',... 94 cluster.codepath,EnumToString(solution),[cluster.executionpath '/' dirname],modelname,modelname,modelname); 95 %fprintf(fid,'echo $HOSTNAME >>%s.outlog',modelname); 79 96 fclose(fid); 80 97 … … 95 112 disp('launching solution sequence on remote cluster'); 96 113 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ... 97 ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz 114 ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz && qsub ' modelname '.queue ']; 98 115 issmssh(cluster.name,cluster.login,cluster.port,launchcommand); 99 116 end %}}} -
issm/trunk/src/m/classes/clusters/discover.m
r17806 r19105 58 58 function md = checkconsistency(cluster,md,solution,analyses) % {{{ 59 59 60 available_queues={'general_long','general',' general_small','debug'};61 queue_requirements_time=[24*60 12*60 12*6060];62 queue_requirements_np=[516 1024 1632];60 available_queues={'general_long','general','debug'}; 61 queue_requirements_time=[24*60 12*60 60]; 62 queue_requirements_np=[516 1024 32]; 63 63 64 64 QueueRequirements(available_queues,queue_requirements_time,queue_requirements_np,cluster.queue,cluster.np,cluster.time) 65 65 66 if ( strcmpi(cluster.queue,'general') & cluster.cpuspernode*cluster.numnodes < 17)67 md = checkmessage(md,'cpus must be greater than 17 for general queue');68 end69 66 %now, check cluster.cpuspernode according to processor type 70 if ( strcmpi(cluster.processor,' neha')),71 if ((cluster.cpuspernode> 8) | (cluster.cpuspernode<1)),72 md = checkmessage(md,'cpuspernode should be between 1 and 8 for ''neha'' processors');67 if ( strcmpi(cluster.processor,'sand')), 68 if ((cluster.cpuspernode>16 ) | (cluster.cpuspernode<1)), 69 md = checkmessage(md,'cpuspernode should be between 1 and 16 for ''sand'' processors'); 73 70 end 74 71 elseif strcmpi(cluster.processor,'west'), … … 77 74 end 78 75 else 79 md = checkmessage(md,'unknown processor type, should be '' neha'' or ''west'' ');76 md = checkmessage(md,'unknown processor type, should be ''sand'' or ''west'' '); 80 77 end 81 78 … … 100 97 fprintf(fid,'#PBS -l select=%i:mpiprocs=%i:proc=%s\n',cluster.numnodes,cluster.cpuspernode,cluster.processor); 101 98 fprintf(fid,'#PBS -l walltime=%i:00\n',cluster.time); %SLURM walltime is in minutes: 102 fprintf(fid,'#PBS -q %s \n',cluster.queue); 99 if ~strcmp(cluster.queue,'general'), 100 fprintf(fid,'#PBS -q %s \n',cluster.queue); 101 end 103 102 fprintf(fid,'#PBS -W group_list=s1010\n'); 104 103 fprintf(fid,'#PBS -m e\n'); -
issm/trunk/src/m/classes/clusters/generic.m
r18301 r19105 24 24 end 25 25 methods 26 function createxml( obj,fid) % {{{26 function createxml(self,fid) % {{{ 27 27 fprintf(fid, '\n\n'); 28 28 fprintf(fid, '%s\n', '<!-- generic -->'); 29 29 30 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="name" type="',class( obj.name),'" default="',convert2str(obj.name),'">', ' <section name="cluster" />',' <help> N/A </help>','</parameter>');31 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="login" type="',class( obj.login),'" default="',convert2str(obj.login),'">', ' <section name="cluster" />',' <help> N/A </help>','</parameter>');32 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="np" type="',class( obj.np),'" default="',convert2str(obj.np),'">', ' <section name="cluster" />',' <help> N/A </help>','</parameter>');33 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="port" type="',class( obj.port),'" default="',convert2str(obj.port),'">', ' <section name="cluster" />',' <help> N/A </help>','</parameter>');34 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="codepath" type="',class( obj.codepath),'" default="',convert2str(obj.codepath),'">', ' <section name="cluster" />',' <help> N/A </help>','</parameter>');30 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="name" type="',class(self.name),'" default="',convert2str(self.name),'">', ' <section name="cluster" />',' <help> N/A </help>','</parameter>'); 31 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="login" type="',class(self.login),'" default="',convert2str(self.login),'">', ' <section name="cluster" />',' <help> N/A </help>','</parameter>'); 32 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="np" type="',class(self.np),'" default="',convert2str(self.np),'">', ' <section name="cluster" />',' <help> N/A </help>','</parameter>'); 33 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="port" type="',class(self.port),'" default="',convert2str(self.port),'">', ' <section name="cluster" />',' <help> N/A </help>','</parameter>'); 34 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="codepath" type="',class(self.codepath),'" default="',convert2str(self.codepath),'">', ' <section name="cluster" />',' <help> N/A </help>','</parameter>'); 35 35 36 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="executionpath" type="',class( obj.executionpath),'" default="',convert2str(obj.executionpath),'">', ' <section name="cluster" />',' <help> N/A </help>','</parameter>');37 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="etcpath" type="',class( obj.etcpath),'" default="',convert2str(obj.etcpath),'">', ' <section name="cluster" />',' <help> N/A </help>','</parameter>');38 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="valgrind" type="',class( obj.valgrind),'" default="',convert2str(obj.valgrind),'">', ' <section name="cluster" />',' <help> N/A </help>','</parameter>');39 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="valgrindlib" type="',class( obj.valgrindlib),'" default="',convert2str(obj.valgrindlib),'">', ' <section name="cluster" />',' <help> N/A </help>','</parameter>');40 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="valgrindsup" type="',class( obj.valgrindsup),'" default="',convert2str(obj.valgrindsup),'">', ' <section name="cluster" />',' <help> N/A </help>','</parameter>');41 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n', '<parameter key ="verbose" type="',class( obj.verbose),'" default="',convert2str(obj.verbose),'">', ' <section name="cluster" />',' <help> N/A </help>','</parameter>');36 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="executionpath" type="',class(self.executionpath),'" default="',convert2str(self.executionpath),'">', ' <section name="cluster" />',' <help> N/A </help>','</parameter>'); 37 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="etcpath" type="',class(self.etcpath),'" default="',convert2str(self.etcpath),'">', ' <section name="cluster" />',' <help> N/A </help>','</parameter>'); 38 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="valgrind" type="',class(self.valgrind),'" default="',convert2str(self.valgrind),'">', ' <section name="cluster" />',' <help> N/A </help>','</parameter>'); 39 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="valgrindlib" type="',class(self.valgrindlib),'" default="',convert2str(self.valgrindlib),'">', ' <section name="cluster" />',' <help> N/A </help>','</parameter>'); 40 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="valgrindsup" type="',class(self.valgrindsup),'" default="',convert2str(self.valgrindsup),'">', ' <section name="cluster" />',' <help> N/A </help>','</parameter>'); 41 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n', '<parameter key ="verbose" type="',class(self.verbose),'" default="',convert2str(self.verbose),'">', ' <section name="cluster" />',' <help> N/A </help>','</parameter>'); 42 42 43 43 end % }}} 44 44 function cluster=generic(varargin) % {{{ 45 46 %Change the defaults if ispc 47 if ispc, 48 cluster.codepath = [issmdir() '\bin']; 49 cluster.etcpath = [issmdir() '\etc']; 50 cluster.executionpath = [issmdir() '\execution']; 51 end 45 52 46 53 %use provided options to change fields -
issm/trunk/src/m/classes/clusters/greenplanet.m
r17806 r19105 9 9 properties (SetAccess=public) 10 10 % {{{ 11 name ='greenplanet'12 login ='';13 numnodes =20;14 cpuspernode =8;15 port =8000;16 queue ='c6145';17 codepath ='';18 executionpath ='';19 interactive =0;20 time =24*60;21 memory =2;11 name = 'greenplanet' 12 login = ''; 13 numnodes = 20; 14 cpuspernode = 8; 15 port = 8000; 16 queue = 'c6145'; 17 codepath = ''; 18 executionpath = ''; 19 interactive = 0; 20 time = 24*60; 21 memory = 2; 22 22 end 23 23 properties (SetAccess=private) … … 87 87 fprintf(fid,'#PBS -o %s.outlog \n',modelname); 88 88 fprintf(fid,'#PBS -e %s.errlog \n\n',modelname); 89 %fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,dirname); 89 fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME 90 fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n'); %FIXME 91 fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,modelname); 90 92 fprintf(fid,'mpiexec -np %i %s/kriging.exe %s %s\n',cluster.np,cluster.codepath,[cluster.executionpath '/' modelname],modelname); 91 93 if ~io_gather, %concatenate the output files: -
issm/trunk/src/m/classes/clusters/pfe.m
r16560 r19105 16 16 queue = 'long'; 17 17 time = 12*60; 18 processor = ' neh';18 processor = 'wes'; 19 19 codepath = ''; 20 20 executionpath = ''; … … 126 126 fprintf(fid,'#PBS -W group_list=%s\n',cluster.grouplist); 127 127 fprintf(fid,'#PBS -m e\n'); 128 fprintf(fid,'#PBS -o %s.outlog \n', modelname);129 fprintf(fid,'#PBS -e %s.errlog \n\n', modelname);128 fprintf(fid,'#PBS -o %s.outlog \n',[cluster.executionpath '/' dirname '/' modelname]); 129 fprintf(fid,'#PBS -e %s.errlog \n\n',[cluster.executionpath '/' dirname '/' modelname]); 130 130 fprintf(fid,'. /usr/share/modules/init/bash\n\n'); 131 fprintf(fid,'module load comp-intel/201 3.1.117\n');132 fprintf(fid,'module load mpi-sgi/mpt.2. 06rp16\n');131 fprintf(fid,'module load comp-intel/2015.0.090\n'); 132 fprintf(fid,'module load mpi-sgi/mpt.2.11r13\n'); 133 133 fprintf(fid,'export PATH="$PATH:."\n\n'); 134 134 fprintf(fid,'export MPI_GROUP_MAX=64\n\n'); … … 136 136 fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n'); %FIXME 137 137 fprintf(fid,'cd %s/%s/\n\n',cluster.executionpath,dirname); 138 fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,EnumToString(solution),[cluster.executionpath '/' dirname],modelname); 138 if ~isvalgrind, 139 fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,EnumToString(solution),[cluster.executionpath '/' dirname],modelname); 140 else 141 fprintf(fid,'mpiexec -np %i valgrind --leak-check=full %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,EnumToString(solution),[cluster.executionpath '/' dirname],modelname); 142 end 139 143 if ~io_gather, %concatenate the output files: 140 144 fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname); … … 179 183 fprintf(fid,'#PBS -e %s.errlog \n\n',modelname); 180 184 fprintf(fid,'. /usr/share/modules/init/bash\n\n'); 181 fprintf(fid,'module load comp-intel/201 3.1.117\n');182 fprintf(fid,'module load mpi-sgi/mpt.2. 06rp16\n');185 fprintf(fid,'module load comp-intel/2015.0.090\n'); 186 fprintf(fid,'module load mpi-sgi/mpt.2.11r13\n'); 183 187 fprintf(fid,'export PATH="$PATH:."\n'); 184 188 fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME … … 210 214 end 211 215 end %}}} 216 function BuildOceanQueueScript(np,cluster,modelname) % {{{ 217 218 %write queuing script 219 fid=fopen([modelname '.queue'],'w'); 220 fprintf(fid,'#PBS -S /bin/bash\n'); 221 fprintf(fid,'#PBS -l select=1:ncpus=%i:model=%s\n',np,cluster.processor); 222 fprintf(fid,'#PBS -l walltime=%i\n',cluster.time); %walltime is in seconds. 223 fprintf(fid,'#PBS -q %s \n',cluster.queue); 224 fprintf(fid,'#PBS -W group_list=%s\n',cluster.grouplist); 225 fprintf(fid,'#PBS -m e\n'); 226 fprintf(fid,'#PBS -o %s.outlog \n',modelname); 227 fprintf(fid,'#PBS -e %s.errlog \n\n',modelname); 228 fprintf(fid,'. /usr/share/modules/init/bash\n\n'); 229 fprintf(fid,'module load comp-intel/2015.0.090\n'); 230 fprintf(fid,'module load test/mpt.2.11r8\n'); 231 fprintf(fid,'module load netcdf/4.0\n'); 232 fprintf(fid,'module load mpi-mvapich2/1.4.1/gcc\n'); 233 fprintf(fid,'module load gcc/4.4.4\n'); 234 fprintf(fid,'export PATH="$PATH:."\n'); 235 fprintf(fid,'export MPI_GROUP_MAX=64\n\n'); 236 fprintf(fid,['cd ' pwd() ' \n\n']); 237 fprintf(fid,'mpiexec -np %i ./mitgcmuv\n',np); 238 % if ~io_gather, %concatenate the output files: 239 % fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname); 240 % end 241 fclose(fid); 242 243 end %}}} 212 244 function LaunchQueueJob(cluster,modelname,dirname,filelist)% {{{ 213 245 -
issm/trunk/src/m/classes/constants.m
r17806 r19105 6 6 classdef constants 7 7 properties (SetAccess=public) 8 g = 0; 9 yts = 0; 10 referencetemperature = 0; 8 g = 0.; 9 omega = 0.; 10 yts = 0.; 11 referencetemperature = 0.; 11 12 end 12 13 methods 13 function createxml( obj,fid) % {{{14 function createxml(self,fid) % {{{ 14 15 fprintf(fid, '\n\n'); 15 16 fprintf(fid, '%s\n', '<!-- constants -->'); 16 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="g" type="',class( obj.g),'" default="',num2str(obj.g),'">',' <section name="constants" />',' <help> gravitational acceleration [m/s^2] </help>','</parameter>');17 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="yts" type="',class( obj.yts),'" default="',num2str(obj.yts),'">',' <section name="constants" />',' <help> number of seconds in a year [s/yr] </help>','</parameter>');18 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n','<parameter key ="referencetemperature" type="',class( obj.referencetemperature),'" default="',num2str(obj.referencetemperature),'">',' <section name="constants" />',' <help> reference temperature used in the enthalpy model [K] </help>','</parameter>');17 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="g" type="',class(self.g),'" default="',num2str(self.g),'">',' <section name="constants" />',' <help> gravitational acceleration [m/s^2] </help>','</parameter>'); 18 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="yts" type="',class(self.yts),'" default="',num2str(self.yts),'">',' <section name="constants" />',' <help> number of seconds in a year [s/yr] </help>','</parameter>'); 19 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n','<parameter key ="referencetemperature" type="',class(self.referencetemperature),'" default="',num2str(self.referencetemperature),'">',' <section name="constants" />',' <help> reference temperature used in the enthalpy model [K] </help>','</parameter>'); 19 20 end % }}} 20 function obj= constants(varargin) % {{{21 function self = constants(varargin) % {{{ 21 22 switch nargin 22 23 case 0 23 obj=setdefaultparameters(obj);24 self=setdefaultparameters(self); 24 25 otherwise 25 26 error('constructor not supported'); 26 27 end 27 28 end % }}} 28 function obj = setdefaultparameters(obj) % {{{29 function self = setdefaultparameters(self) % {{{ 29 30 30 31 %acceleration due to gravity (m/s^2) 31 obj.g=9.81; 32 self.g=9.81; 33 34 %Earth's rotation speed 35 self.omega = 7.292*1e-5; 32 36 33 37 %converstion from year to seconds 34 obj.yts=365*24*3600;38 self.yts=365*24*3600; 35 39 36 40 %the reference temperature for enthalpy model (cf Aschwanden) 37 obj.referencetemperature=223.15;41 self.referencetemperature=223.15; 38 42 39 43 end % }}} 40 function md = checkconsistency( obj,md,solution,analyses) % {{{44 function md = checkconsistency(self,md,solution,analyses) % {{{ 41 45 42 % md = checkfield(md,'fieldname','constants.g','>',0,'size',[1 1]); 46 md = checkfield(md,'fieldname','constants.g','>=',0,'size',[1 1]); %We allow 0 for validation tests 47 md = checkfield(md,'fieldname','constants.omega','>=',0,'size',[1 1]); 43 48 md = checkfield(md,'fieldname','constants.yts','>',0,'size',[1 1]); 44 49 md = checkfield(md,'fieldname','constants.referencetemperature','size',[1 1]); 45 50 46 51 end % }}} 47 function disp( obj) % {{{52 function disp(self) % {{{ 48 53 disp(sprintf(' constants parameters:')); 49 54 50 fielddisplay(obj,'g','gravitational acceleration [m/s^2]'); 51 fielddisplay(obj,'yts','number of seconds in a year [s/yr]'); 52 fielddisplay(obj,'referencetemperature','reference temperature used in the enthalpy model [K]'); 55 fielddisplay(self,'g','gravitational acceleration [m/s^2]'); 56 fielddisplay(self,'omega','angular velocity of Earth [rad/s]'); 57 fielddisplay(self,'yts','number of seconds in a year [s/yr]'); 58 fielddisplay(self,'referencetemperature','reference temperature used in the enthalpy model [K]'); 53 59 54 60 end % }}} 55 function marshall(obj,md,fid) % {{{ 56 WriteData(fid,'object',obj,'fieldname','g','format','Double'); 57 WriteData(fid,'object',obj,'fieldname','yts','format','Double'); 58 WriteData(fid,'object',obj,'fieldname','referencetemperature','format','Double'); 61 function marshall(self,md,fid) % {{{ 62 WriteData(fid,'object',self,'fieldname','g','format','Double'); 63 WriteData(fid,'object',self,'fieldname','omega','format','Double'); 64 WriteData(fid,'object',self,'fieldname','yts','format','Double'); 65 WriteData(fid,'object',self,'fieldname','referencetemperature','format','Double'); 59 66 end % }}} 60 67 end -
issm/trunk/src/m/classes/damage.m
r18301 r19105 32 32 end 33 33 methods 34 function createxml( obj,fid) % {{{34 function createxml(self,fid) % {{{ 35 35 fprintf(fid, '\n\n'); 36 36 fprintf(fid, '%s\n', '<!-- damage -->'); 37 37 fprintf(fid, '%s\n', '<!-- Note: this class depends on different input of law -->'); 38 38 39 %fprintf(fid,'%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="law" type="logical"', '" default="', num2str( obj.law),'">', ' <section name="damage" />',' <help> damage law (string) from {"undamaged","pralong"} </help>','</parameter>');39 %fprintf(fid,'%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="law" type="logical"', '" default="', num2str(self.law),'">', ' <section name="damage" />',' <help> damage law (string) from {"undamaged","pralong"} </help>','</parameter>'); 40 40 % drop-down 41 41 fprintf(fid,'%s%s%s%s%s\n\t%s\n','<parameter key ="law" type="','alternative','" optional="','false','">','<section name="damage" />'); … … 49 49 fprintf(fid,'\t%s%s%s%s%s\n\t\t%s\n','<option value="pralong" type="','string','" default="','false','">','<help> law = pralong </help>'); 50 50 51 fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n', '<parameter key ="stress_threshold" type="',class( obj.stress_threshold),'" default="',num2str(obj.stress_threshold),'">','<help> damage stress threshold [Pa] </help>','</parameter>');52 fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n', '<parameter key ="c1" type="', class( obj.c1),'" default="', num2str(obj.c1),'">', '<help> damage parameter 1 </help>','</parameter>');53 fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n', '<parameter key ="c2" type="', class( obj.c2),'" default="', num2str(obj.c2),'">','<help> damage parameter 2 </help>','</parameter>');54 fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n', '<parameter key ="c3" type="', class( obj.c3),'" default="', num2str(obj.c3),'">','<help> damage parameter 3 [W/m^2] </help>','</parameter>');55 fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n', '<parameter key ="c4" type="', class( obj.c4),'" default="', num2str(obj.c4),'">','<help> damage parameter 4 </help>','</parameter>');56 fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n', '<parameter key ="healing" type="', class( obj.healing),'" default="', num2str(obj.healing),'">','<help> damage healing parameter 1 </help>','</parameter>');57 fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n', '<parameter key ="equiv_stress" type="', class( obj.equiv_stress),'" default="',convert2str(obj.equiv_stress),'">','<help> 0: von Mises </help>','</parameter>');58 fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n', '<parameter key ="requested_outputs" type="', class( obj.requested_outputs),'" default="',convert2str(obj.requested_outputs),'">','<help> additional outputs requested </help>','</parameter>');51 fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n', '<parameter key ="stress_threshold" type="',class(self.stress_threshold),'" default="',num2str(self.stress_threshold),'">','<help> damage stress threshold [Pa] </help>','</parameter>'); 52 fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n', '<parameter key ="c1" type="', class(self.c1),'" default="', num2str(self.c1),'">', '<help> damage parameter 1 </help>','</parameter>'); 53 fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n', '<parameter key ="c2" type="', class(self.c2),'" default="', num2str(self.c2),'">','<help> damage parameter 2 </help>','</parameter>'); 54 fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n', '<parameter key ="c3" type="', class(self.c3),'" default="', num2str(self.c3),'">','<help> damage parameter 3 [W/m^2] </help>','</parameter>'); 55 fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n', '<parameter key ="c4" type="', class(self.c4),'" default="', num2str(self.c4),'">','<help> damage parameter 4 </help>','</parameter>'); 56 fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n', '<parameter key ="healing" type="', class(self.healing),'" default="', num2str(self.healing),'">','<help> damage healing parameter 1 </help>','</parameter>'); 57 fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n', '<parameter key ="equiv_stress" type="', class(self.equiv_stress),'" default="',convert2str(self.equiv_stress),'">','<help> 0: von Mises </help>','</parameter>'); 58 fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n', '<parameter key ="requested_outputs" type="', class(self.requested_outputs),'" default="',convert2str(self.requested_outputs),'">','<help> additional outputs requested </help>','</parameter>'); 59 59 60 60 … … 67 67 68 68 69 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="D" type="', class( obj.D),'" default="', num2str(obj.D),'">', ' <section name="damage" />',' <help> damage tensor (scalar) </help>','</parameter>');70 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="law" type="', class( obj.law),'" default="', num2str(obj.law),'">', ' <section name="damage" />',' <help> damage law (string) from {"undamaged","pralong"} </help>','</parameter>');71 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="spcdamage" type="', class( obj.spcdamage),'" default="', num2str(obj.spcdamage),'">', ' <section name="damage" />',' <help> damage constraints (NaN means no constraint) </help>','</parameter>');72 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="max_damage" type="', class( obj.max_damage),'" default="', num2str(obj.max_damage),'">', ' <section name="damage" />',' <help> maximum possible damage (0&lt;=max_damage&lt;1) </help>','</parameter>');69 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="D" type="', class(self.D),'" default="', num2str(self.D),'">', ' <section name="damage" />',' <help> damage tensor (scalar) </help>','</parameter>'); 70 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="law" type="', class(self.law),'" default="', num2str(self.law),'">', ' <section name="damage" />',' <help> damage law (string) from {"undamaged","pralong"} </help>','</parameter>'); 71 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="spcdamage" type="', class(self.spcdamage),'" default="', num2str(self.spcdamage),'">', ' <section name="damage" />',' <help> damage constraints (NaN means no constraint) </help>','</parameter>'); 72 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="max_damage" type="', class(self.max_damage),'" default="', num2str(self.max_damage),'">', ' <section name="damage" />',' <help> maximum possible damage (0&lt;=max_damage&lt;1) </help>','</parameter>'); 73 73 74 74 % stabilization (0,1, or 2) drop-down … … 79 79 fprintf(fid, '%s\n','</parameter>'); 80 80 81 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="maxiter" type="', class(obj.maxiter),'" default="', num2str(obj.maxiter),'">', ' <section name="damage" />',' <help> maximum number of non linear iterations </help>','</parameter>'); 82 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="penalty_lock" type="', class(obj.penalty_lock),'" default="', num2str(obj.penalty_lock),'">', ' <section name="damage" />',' <help> stabilize unstable damage constraints that keep zigzagging after n iteration (default is 0, no stabilization) </help>','</parameter>'); 83 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="penalty_threshold" type="', class(obj.penalty_threshold),'" default="', num2str(obj.penalty_threshold),'">', ' <section name="damage" />',' <help> threshold to declare convergence of damage evolution solution (default is 0) </help>','</parameter>'); 84 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="penalty_factor" type="', class(obj.penalty_factor),'" default="', num2str(obj.penalty_factor),'">', ' <section name="damage" />',' <help> scaling exponent (default is 3) </help>','</parameter>'); 85 86 end % }}} 87 88 function obj = damage(varargin) % {{{ 81 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="maxiter" type="', class(self.maxiter),'" default="', num2str(self.maxiter),'">', ' <section name="damage" />',' <help> maximum number of non linear iterations </help>','</parameter>'); 82 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="penalty_lock" type="', class(self.penalty_lock),'" default="', num2str(self.penalty_lock),'">', ' <section name="damage" />',' <help> stabilize unstable damage constraints that keep zigzagging after n iteration (default is 0, no stabilization) </help>','</parameter>'); 83 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="penalty_threshold" type="', class(self.penalty_threshold),'" default="', num2str(self.penalty_threshold),'">', ' <section name="damage" />',' <help> threshold to declare convergence of damage evolution solution (default is 0) </help>','</parameter>'); 84 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="penalty_factor" type="', class(self.penalty_factor),'" default="', num2str(self.penalty_factor),'">', ' <section name="damage" />',' <help> scaling exponent (default is 3) </help>','</parameter>'); 85 86 end % }}} 87 function self = damage(varargin) % {{{ 89 88 switch nargin 90 89 case 0 91 obj=setdefaultparameters(obj);90 self=setdefaultparameters(self); 92 91 case 1 93 92 inputstruct=varargin{1}; … … 97 96 fieldname = list1{i}; 98 97 if ismember(fieldname,list2), 99 obj.(fieldname) = inputstruct.(fieldname);98 self.(fieldname) = inputstruct.(fieldname); 100 99 end 101 100 end … … 104 103 end 105 104 end % }}} 106 function obj = setdefaultparameters(obj) % {{{ 105 function self = extrude(self,md) % {{{ 106 self.D=project3d(md,'vector',self.D,'type','node'); 107 self.spcdamage=project3d(md,'vector',self.spcdamage,'type','node'); 108 end % }}} 109 function self = setdefaultparameters(self) % {{{ 107 110 108 111 %damage parameters: 109 obj.isdamage=0;110 obj.D=0;111 obj.law=0;112 113 obj.max_damage=1-1e-5; %if damage reaches 1, solve becomes singular, as viscosity becomes nil112 self.isdamage=0; 113 self.D=0; 114 self.law=0; 115 116 self.max_damage=1-1e-5; %if damage reaches 1, solve becomes singular, as viscosity becomes nil 114 117 115 118 %Type of stabilization used 116 obj.stabilization=2;119 self.stabilization=2; 117 120 118 121 %Maximum number of iterations 119 obj.maxiter=100;122 self.maxiter=100; 120 123 121 124 %finite element interpolation 122 obj.elementinterp='P1';125 self.elementinterp='P1'; 123 126 124 127 %factor used to compute the values of the penalties: kappa=max(stiffness matrix)*10^penalty_factor 125 obj.penalty_factor=3;128 self.penalty_factor=3; 126 129 127 130 %stabilize unstable damage constraints that keep zigzagging after n iteration (default is 0, no stabilization) 128 obj.penalty_lock=0;131 self.penalty_lock=0; 129 132 130 133 %threshold to declare convergence of thermal solution (default is 0) 131 obj.penalty_threshold=0;134 self.penalty_threshold=0; 132 135 133 136 %damage evolution parameters 134 obj.stress_threshold=0;135 obj.healing=0;136 obj.c1=0;137 obj.c2=0;138 obj.c3=0;139 obj.c4=0;140 obj.equiv_stress=0;137 self.stress_threshold=0; 138 self.healing=0; 139 self.c1=0; 140 self.c2=0; 141 self.c3=0; 142 self.c4=0; 143 self.equiv_stress=0; 141 144 142 145 %output default: 143 obj.requested_outputs={'default'};144 145 end % }}} 146 function md = checkconsistency( obj,md,solution,analyses) % {{{146 self.requested_outputs={'default'}; 147 148 end % }}} 149 function md = checkconsistency(self,md,solution,analyses) % {{{ 147 150 148 151 md = checkfield(md,'fieldname','damage.isdamage','values',[1,0]); 149 if obj.isdamage,152 if self.isdamage, 150 153 md = checkfield(md,'fieldname','damage.law','numel',[1],'values',[0,1,2]); 151 md = checkfield(md,'fieldname','damage.D','>=',0,'<=', obj.max_damage,'size',[md.mesh.numberofvertices 1]);152 md = checkfield(md,'fieldname','damage.spcdamage',' forcing',1);154 md = checkfield(md,'fieldname','damage.D','>=',0,'<=',self.max_damage,'size',[md.mesh.numberofvertices 1]); 155 md = checkfield(md,'fieldname','damage.spcdamage','timeseries',1); 153 156 md = checkfield(md,'fieldname','damage.max_damage','<',1,'>=',0); 154 157 md = checkfield(md,'fieldname','damage.stabilization','numel',[1],'values',[0 1 2]); … … 166 169 md = checkfield(md,'fieldname','damage.equiv_stress','numel',[1],'values',[0 1]); 167 170 md = checkfield(md,'fieldname','damage.requested_outputs','stringrow',1); 168 elseif ( obj.law~=0),171 elseif (self.law~=0), 169 172 if (solution==DamageEvolutionSolutionEnum), 170 173 error('Invalid evolution law (md.damage.law) for a damage solution'); … … 180 183 end 181 184 end % }}} 182 function disp( obj) % {{{185 function disp(self) % {{{ 183 186 disp(sprintf(' Damage:\n')); 184 187 185 fielddisplay( obj,'isdamage','is damage mechanics being used? {true,false}');186 if obj.isdamage,187 fielddisplay( obj,'law','damage law {''0: undamaged'',''1: pralong''}');188 fielddisplay( obj,'D','damage tensor (scalar)');189 fielddisplay( obj,'spcdamage','damage constraints (NaN means no constraint)');190 fielddisplay( obj,'max_damage','maximum possible damage (0<=max_damage<1)');188 fielddisplay(self,'isdamage','is damage mechanics being used? {true,false}'); 189 if self.isdamage, 190 fielddisplay(self,'law','damage law {''0: undamaged'',''1: pralong''}'); 191 fielddisplay(self,'D','damage tensor (scalar)'); 192 fielddisplay(self,'spcdamage','damage constraints (NaN means no constraint)'); 193 fielddisplay(self,'max_damage','maximum possible damage (0<=max_damage<1)'); 191 194 192 fielddisplay( obj,'stabilization','0: no, 1: artificial_diffusivity, 2: SUPG');193 fielddisplay( obj,'maxiter','maximum number of non linear iterations');194 fielddisplay( obj,'elementinterp','interpolation scheme for finite elements {''P1'',''P2''}');195 fielddisplay( obj,'penalty_lock','stabilize unstable damage constraints that keep zigzagging after n iteration (default is 0, no stabilization)');196 fielddisplay( obj,'penalty_threshold','threshold to declare convergence of damage evolution solution (default is 0)');197 fielddisplay( obj,'penalty_factor','scaling exponent (default is 3)');198 fielddisplay( obj,'c1','damage parameter 1');199 fielddisplay( obj,'c2','damage parameter 2');200 fielddisplay( obj,'c3','damage parameter 3');201 fielddisplay( obj,'c4','damage parameter 4');202 fielddisplay( obj,'healing','damage healing parameter');203 fielddisplay( obj,'stress_threshold','damage stress threshold [Pa]');204 fielddisplay( obj,'equiv_stress','0: von Mises, 1: max principal');205 fielddisplay( obj,'requested_outputs','additional outputs requested');206 end 207 208 end % }}} 209 function marshall( obj,md,fid) % {{{210 211 WriteData(fid,'object', obj,'fieldname','isdamage','format','Boolean');212 if obj.isdamage,213 WriteData(fid,'object', obj,'fieldname','law','format','Integer');214 WriteData(fid,'object', obj,'fieldname','D','format','DoubleMat','mattype',1);215 WriteData(fid,'object', obj,'fieldname','spcdamage','format','DoubleMat','mattype',1,'forcinglength',md.mesh.numberofvertices+1);216 WriteData(fid,'object', obj,'fieldname','max_damage','format','Double');217 218 WriteData(fid,'object', obj,'fieldname','stabilization','format','Integer');219 WriteData(fid,'object', obj,'fieldname','maxiter','format','Integer');220 WriteData(fid,'enum',DamageElementinterpEnum(),'data',StringToEnum( obj.elementinterp),'format','Integer');221 WriteData(fid,'object', obj,'fieldname','penalty_threshold','format','Integer');222 WriteData(fid,'object', obj,'fieldname','penalty_lock','format','Integer');223 WriteData(fid,'object', obj,'fieldname','penalty_factor','format','Double');224 WriteData(fid,'object', obj,'fieldname','c1','format','Double');225 WriteData(fid,'object', obj,'fieldname','c2','format','Double');226 WriteData(fid,'object', obj,'fieldname','c3','format','Double');227 WriteData(fid,'object', obj,'fieldname','c4','format','Double');228 WriteData(fid,'object', obj,'fieldname','stress_threshold','format','Double');229 WriteData(fid,'object', obj,'fieldname','healing','format','Double');230 WriteData(fid,'object', obj,'fieldname','equiv_stress','format','Integer');195 fielddisplay(self,'stabilization','0: no, 1: artificial_diffusivity, 2: SUPG'); 196 fielddisplay(self,'maxiter','maximum number of non linear iterations'); 197 fielddisplay(self,'elementinterp','interpolation scheme for finite elements {''P1'',''P2''}'); 198 fielddisplay(self,'penalty_lock','stabilize unstable damage constraints that keep zigzagging after n iteration (default is 0, no stabilization)'); 199 fielddisplay(self,'penalty_threshold','threshold to declare convergence of damage evolution solution (default is 0)'); 200 fielddisplay(self,'penalty_factor','scaling exponent (default is 3)'); 201 fielddisplay(self,'c1','damage parameter 1'); 202 fielddisplay(self,'c2','damage parameter 2'); 203 fielddisplay(self,'c3','damage parameter 3'); 204 fielddisplay(self,'c4','damage parameter 4'); 205 fielddisplay(self,'healing','damage healing parameter'); 206 fielddisplay(self,'stress_threshold','damage stress threshold [Pa]'); 207 fielddisplay(self,'equiv_stress','0: von Mises, 1: max principal'); 208 fielddisplay(self,'requested_outputs','additional outputs requested'); 209 end 210 211 end % }}} 212 function marshall(self,md,fid) % {{{ 213 214 WriteData(fid,'object',self,'fieldname','isdamage','format','Boolean'); 215 if self.isdamage, 216 WriteData(fid,'object',self,'fieldname','law','format','Integer'); 217 WriteData(fid,'object',self,'fieldname','D','format','DoubleMat','mattype',1); 218 WriteData(fid,'object',self,'fieldname','spcdamage','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1); 219 WriteData(fid,'object',self,'fieldname','max_damage','format','Double'); 220 221 WriteData(fid,'object',self,'fieldname','stabilization','format','Integer'); 222 WriteData(fid,'object',self,'fieldname','maxiter','format','Integer'); 223 WriteData(fid,'enum',DamageElementinterpEnum(),'data',StringToEnum(self.elementinterp),'format','Integer'); 224 WriteData(fid,'object',self,'fieldname','penalty_threshold','format','Integer'); 225 WriteData(fid,'object',self,'fieldname','penalty_lock','format','Integer'); 226 WriteData(fid,'object',self,'fieldname','penalty_factor','format','Double'); 227 WriteData(fid,'object',self,'fieldname','c1','format','Double'); 228 WriteData(fid,'object',self,'fieldname','c2','format','Double'); 229 WriteData(fid,'object',self,'fieldname','c3','format','Double'); 230 WriteData(fid,'object',self,'fieldname','c4','format','Double'); 231 WriteData(fid,'object',self,'fieldname','stress_threshold','format','Double'); 232 WriteData(fid,'object',self,'fieldname','healing','format','Double'); 233 WriteData(fid,'object',self,'fieldname','equiv_stress','format','Integer'); 231 234 end 232 235 233 236 %process requested outputs 234 outputs = obj.requested_outputs;237 outputs = self.requested_outputs; 235 238 pos = find(ismember(outputs,'default')); 236 239 if ~isempty(pos), 237 240 outputs(pos) = []; %remove 'default' from outputs 238 outputs = [outputs defaultoutputs( obj,md)]; %add defaults239 end 240 if obj.isdamage,241 outputs = [outputs defaultoutputs(self,md)]; %add defaults 242 end 243 if self.isdamage, 241 244 WriteData(fid,'data',outputs,'enum',DamageEvolutionRequestedOutputsEnum,'format','StringArray'); 242 245 end -
issm/trunk/src/m/classes/damage.py
r18301 r19105 1 1 from fielddisplay import fielddisplay 2 from project3d import project3d 2 3 from EnumDefinitions import * 3 4 from StringToEnum import StringToEnum … … 74 75 return s 75 76 # }}} 77 def extrude(self,md): # {{{ 78 self.D=project3d(md,'vector',self.D,'type','node') 79 self.spcdamage=project3d(md,'vector',self.spcdamage,'type','node') 80 return self 81 #}}} 76 82 def setdefaultparameters(self): # {{{ 77 83 … … 131 137 md = checkfield(md,'fieldname','damage.max_damage','<',1,'>=',0) 132 138 md = checkfield(md,'fieldname','damage.law','numel',[1],'values',[0,1,2,3]) 133 md = checkfield(md,'fieldname','damage.spcdamage',' forcing',1)139 md = checkfield(md,'fieldname','damage.spcdamage','timeseries',1) 134 140 md = checkfield(md,'fieldname','damage.stabilization','numel',[1],'values',[0,1,2]) 135 141 md = checkfield(md,'fieldname','damage.maxiter','>=0',0) … … 159 165 WriteData(fid,'object',self,'fieldname','D','format','DoubleMat','mattype',1) 160 166 WriteData(fid,'object',self,'fieldname','law','format','Integer') 161 WriteData(fid,'object',self,'fieldname','spcdamage','format','DoubleMat','mattype',1,' forcinglength',md.mesh.numberofvertices+1)167 WriteData(fid,'object',self,'fieldname','spcdamage','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1) 162 168 WriteData(fid,'object',self,'fieldname','max_damage','format','Double') 163 169 WriteData(fid,'object',self,'fieldname','stabilization','format','Integer') -
issm/trunk/src/m/classes/debug.m
r17989 r19105 11 11 end 12 12 methods 13 function createxml( obj,fid) % {{{13 function createxml(self,fid) % {{{ 14 14 fprintf(fid, '\n\n'); 15 15 fprintf(fid, '%s\n', '<!-- Debug -->'); … … 20 20 fprintf(fid,'%s\n%s\n',' <option value="1" type="string" default="false"> </option>','</parameter>'); 21 21 22 fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n%s\n', '<parameter key ="gprof" type="', class( obj.gprof),'" optional="false">', ' <section name="debug" />',' <option value="',convert2str(obj.gprof),'" type="string" default="true"></option>',' <help> use gnu-profiler to find out where the time is spent </help>','</parameter>');23 fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n', '<parameter key ="profiling" type="', class( obj.profiling),'" optional="false">', ' <section name="debug" />',' <option value="',convert2str(obj.profiling),'" type="string" default="true"></option>',' <help> enables profiling (memory, flops, time) </help>','</parameter>');22 fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n%s\n', '<parameter key ="gprof" type="', class(self.gprof),'" optional="false">', ' <section name="debug" />',' <option value="',convert2str(self.gprof),'" type="string" default="true"></option>',' <help> use gnu-profiler to find out where the time is spent </help>','</parameter>'); 23 fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n', '<parameter key ="profiling" type="', class(self.profiling),'" optional="false">', ' <section name="debug" />',' <option value="',convert2str(self.profiling),'" type="string" default="true"></option>',' <help> enables profiling (memory, flops, time) </help>','</parameter>'); 24 24 end % }}} 25 function obj= debug(varargin) % {{{25 function self = debug(varargin) % {{{ 26 26 switch nargin 27 27 case 0 28 obj=setdefaultparameters(obj);28 self=setdefaultparameters(self); 29 29 otherwise 30 30 error('constructor not supported'); 31 31 end 32 32 end % }}} 33 function obj = setdefaultparameters(obj) % {{{33 function self = setdefaultparameters(self) % {{{ 34 34 35 35 end % }}} 36 function disp( obj) % {{{36 function disp(self) % {{{ 37 37 disp(sprintf(' debug parameters:')); 38 38 39 fielddisplay( obj,'valgrind','use Valgrind to debug (0 or 1)');40 fielddisplay( obj,'gprof','use gnu-profiler to find out where the time is spent');41 fielddisplay( obj,'profiling','enables profiling (memory, flops, time)');39 fielddisplay(self,'valgrind','use Valgrind to debug (0 or 1)'); 40 fielddisplay(self,'gprof','use gnu-profiler to find out where the time is spent'); 41 fielddisplay(self,'profiling','enables profiling (memory, flops, time)'); 42 42 43 43 end % }}} 44 function marshall( obj,md,fid) % {{{45 WriteData(fid,'object', obj,'fieldname','profiling','format','Boolean');44 function marshall(self,md,fid) % {{{ 45 WriteData(fid,'object',self,'fieldname','profiling','format','Boolean'); 46 46 end % }}} 47 47 end -
issm/trunk/src/m/classes/dependent.m
r13975 r19105 15 15 end 16 16 methods 17 function obj= dependent(varargin) % {{{17 function self = dependent(varargin) % {{{ 18 18 19 19 %use provided options to change fields 20 20 options=pairoptions(varargin{:}); 21 21 22 obj.name=getfieldvalue(options,'name','');23 obj.type=getfieldvalue(options,'type','');24 obj.exp=getfieldvalue(options,'exp','');25 obj.segments=getfieldvalue(options,'segments',[]);26 obj.index=getfieldvalue(options,'index',-1);27 obj.nods=getfieldvalue(options,'nods',0);22 self.name=getfieldvalue(options,'name',''); 23 self.type=getfieldvalue(options,'type',''); 24 self.exp=getfieldvalue(options,'exp',''); 25 self.segments=getfieldvalue(options,'segments',[]); 26 self.index=getfieldvalue(options,'index',-1); 27 self.nods=getfieldvalue(options,'nods',0); 28 28 29 29 %if name is mass flux: 30 if strcmpi( obj.name,'MassFlux'),30 if strcmpi(self.name,'MassFlux'), 31 31 %make sure that we supplied a file and that it exists! 32 if exist( obj.exp)~=2,32 if exist(self.exp)~=2, 33 33 error('dependent checkconsistency: specified ''exp'' file does not exist!'); 34 34 end 35 35 %process the file and retrieve segments 36 36 mesh=getfieldvalue(options,'mesh'); 37 obj.segments=MeshProfileIntersection(mesh.elements,mesh.x,mesh.y,obj.exp);37 self.segments=MeshProfileIntersection(mesh.elements,mesh.x,mesh.y,self.exp); 38 38 end 39 39 end 40 40 %}}} 41 function obj = setdefaultparameters(obj) % {{{41 function self = setdefaultparameters(self) % {{{ 42 42 %do nothing 43 43 end % }}} 44 function md = checkconsistency( obj,md,solution,analyses) % {{{45 if strcmpi( obj.name,'MassFlux'),46 if isempty( obj.segments),44 function md = checkconsistency(self,md,solution,analyses) % {{{ 45 if strcmpi(self.name,'MassFlux'), 46 if isempty(self.segments), 47 47 error('dependent checkconsistency error: need segments to compute this dependent response'); 48 48 end 49 if obj.index<=0,49 if self.index<=0, 50 50 error('dependent checkconsistency error: index for segments should be >=1'); 51 51 end 52 52 end 53 if ~isnan( obj.fos_reverse_index),53 if ~isnan(self.fos_reverse_index), 54 54 if ~strcmpi(driver,'fos_reverse'), 55 55 error('cannot declare a dependent with a fos_reverse_index when the driver is not fos_reverse!'); 56 56 end 57 if obj.nods==0,57 if self.nods==0, 58 58 error('dependent checkconsistency error: nods should be set to the size of the independent variable'); 59 59 end … … 61 61 62 62 end % }}} 63 function disp( obj) % {{{63 function disp(self) % {{{ 64 64 disp(sprintf(' dependent variable:')); 65 65 66 fielddisplay( obj,'name','variable name (must match corresponding Enum)');67 fielddisplay( obj,'type','type of variable (''vertex'' or ''scalar'')');66 fielddisplay(self,'name','variable name (must match corresponding Enum)'); 67 fielddisplay(self,'type','type of variable (''vertex'' or ''scalar'')'); 68 68 69 if ~isnan( obj.fos_reverse_index),70 fielddisplay( obj,'fos_reverse_index','index for fos_reverse driver of ADOLC');69 if ~isnan(self.fos_reverse_index), 70 fielddisplay(self,'fos_reverse_index','index for fos_reverse driver of ADOLC'); 71 71 end 72 if ~isempty( obj.exp),73 fielddisplay( obj,'exp','file needed to compute dependent variable');74 fielddisplay( obj,'segments','mass flux segments');72 if ~isempty(self.exp), 73 fielddisplay(self,'exp','file needed to compute dependent variable'); 74 fielddisplay(self,'segments','mass flux segments'); 75 75 end 76 76 77 77 end % }}} 78 function scalar=typetoscalar( obj) % {{{79 if strcmpi( obj.type,'scalar'),78 function scalar=typetoscalar(self) % {{{ 79 if strcmpi(self.type,'scalar'), 80 80 scalar=0; 81 elseif strcmpi( obj.type,'vertex'),81 elseif strcmpi(self.type,'vertex'), 82 82 scalar=1; 83 83 end -
issm/trunk/src/m/classes/flaim.m
r17806 r19105 21 21 end 22 22 methods 23 function createxml( obj,fid) % {{{23 function createxml(self,fid) % {{{ 24 24 fprintf(fid, '<!-- flaim -->\n'); 25 25 26 26 % Input 27 27 fprintf(fid,'%s\n%s\n%s\n','<frame key="1" label="Input:">','<section name="flaim" />'); 28 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="targets" type="',class( obj.targets),'" default="',convert2str(obj.targets),'">',' <section name="flaim" />',' <help> name of kml output targets file </help>',' </parameter>');29 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="tracks" type="',class( obj.tracks),'" default="',convert2str(obj.tracks),'">',' <section name="flaim" />',' <help> name of kml input tracks file </help>',' </parameter>');30 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="flightreqs" type="',class( obj.flightreqs),'" default="',convert2str(obj.flightreqs),'">',' <section name="flaim" />',' <help> structure of kml flight requirements (not used yet) </help>',' </parameter>');31 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="criterion" type="',class( obj.criterion),'" default="',convert2str(obj.criterion),'">',' <section name="flaim" />',' <help> element or nodal criterion for flight path evaluation (metric) </help>',' </parameter>');28 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="targets" type="',class(self.targets),'" default="',convert2str(self.targets),'">',' <section name="flaim" />',' <help> name of kml output targets file </help>',' </parameter>'); 29 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="tracks" type="',class(self.tracks),'" default="',convert2str(self.tracks),'">',' <section name="flaim" />',' <help> name of kml input tracks file </help>',' </parameter>'); 30 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="flightreqs" type="',class(self.flightreqs),'" default="',convert2str(self.flightreqs),'">',' <section name="flaim" />',' <help> structure of kml flight requirements (not used yet) </help>',' </parameter>'); 31 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="criterion" type="',class(self.criterion),'" default="',convert2str(self.criterion),'">',' <section name="flaim" />',' <help> element or nodal criterion for flight path evaluation (metric) </help>',' </parameter>'); 32 32 fprintf(fid,'%s\n%s\n','</frame>'); 33 33 34 34 % Arguments 35 35 fprintf(fid,'%s\n%s\n%s\n','<frame key="2" label="Arguments:">','<section name="flaim" />'); 36 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="gridsatequator" type="',class( obj.gridsatequator),'" default="',convert2str(obj.gridsatequator),'">',' <section name="flaim" />',' <help> number of grids at equator (determines resolution) </help>',' </parameter>');37 fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n%s\n',' <parameter key ="usevalueordering" type="',class( obj.usevalueordering),'" optional="false">',' <section name="flaim" />',' <option value="',convert2str(obj.usevalueordering),'" type="string" default="true"></option>',' <help> flag to consider target values for flight path evaluation </help>',' </parameter>');38 fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n%s\n',' <parameter key ="split_antimeridian" type="',class( obj.split_antimeridian),'" optional="false">',' <section name="flaim" />',' <option value="',convert2str(obj.split_antimeridian),'" type="string" default="true"></option>',' <help> flag to split polygons on the antimeridian </help>',' </parameter>');36 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="gridsatequator" type="',class(self.gridsatequator),'" default="',convert2str(self.gridsatequator),'">',' <section name="flaim" />',' <help> number of grids at equator (determines resolution) </help>',' </parameter>'); 37 fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n%s\n',' <parameter key ="usevalueordering" type="',class(self.usevalueordering),'" optional="false">',' <section name="flaim" />',' <option value="',convert2str(self.usevalueordering),'" type="string" default="true"></option>',' <help> flag to consider target values for flight path evaluation </help>',' </parameter>'); 38 fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n%s\n',' <parameter key ="split_antimeridian" type="',class(self.split_antimeridian),'" optional="false">',' <section name="flaim" />',' <option value="',convert2str(self.split_antimeridian),'" type="string" default="true"></option>',' <help> flag to split polygons on the antimeridian </help>',' </parameter>'); 39 39 fprintf(fid,'%s\n%s\n','</frame>'); 40 40 41 41 % Optimization 42 42 fprintf(fid,'%s\n%s\n%s\n','<frame key="3" label="Optimization:">','<section name="flaim" />'); 43 fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n%s\n',' <parameter key ="path_optimize" type="',class( obj.path_optimize),'" optional="false">',' <section name="flaim" />',' <option value="',convert2str(obj.path_optimize),'" type="string" default="true"></option>',' <help> optimize? (default false) </help>',' </parameter>');44 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="opt_ndir" type="',class( obj.opt_ndir),'" default="',convert2str(obj.opt_ndir),'">',' <section name="flaim" />',' <help> number of directions to test when moving a point. If this value = 1, a random direction is tested. A value > 1 results in directions equally spaced from [0, 2*PI] being tested. For example, 4 would result in directions [0, PI/2, PI, 3PI/2] </help>',' </parameter>');45 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="opt_dist" type="',class( obj.opt_dist),'" default="',convert2str(obj.opt_dist),'">',' <section name="flaim" />',' <help> specifies the distance in km (default 25) to move a randomly selected path point on each iteration </help>',' </parameter>');46 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="opt_niter" type="',class( obj.opt_niter),'" default="',convert2str(obj.opt_niter),'">',' <section name="flaim" />',' <help> number of iterations (default 30,000) to run for flightplan optimization, i.e. the number of times to randomly select a point and move it. </help>',' </parameter>');43 fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n%s\n',' <parameter key ="path_optimize" type="',class(self.path_optimize),'" optional="false">',' <section name="flaim" />',' <option value="',convert2str(self.path_optimize),'" type="string" default="true"></option>',' <help> optimize? (default false) </help>',' </parameter>'); 44 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="opt_ndir" type="',class(self.opt_ndir),'" default="',convert2str(self.opt_ndir),'">',' <section name="flaim" />',' <help> number of directions to test when moving a point. If this value = 1, a random direction is tested. A value > 1 results in directions equally spaced from [0, 2*PI] being tested. For example, 4 would result in directions [0, PI/2, PI, 3PI/2] </help>',' </parameter>'); 45 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="opt_dist" type="',class(self.opt_dist),'" default="',convert2str(self.opt_dist),'">',' <section name="flaim" />',' <help> specifies the distance in km (default 25) to move a randomly selected path point on each iteration </help>',' </parameter>'); 46 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="opt_niter" type="',class(self.opt_niter),'" default="',convert2str(self.opt_niter),'">',' <section name="flaim" />',' <help> number of iterations (default 30,000) to run for flightplan optimization, i.e. the number of times to randomly select a point and move it. </help>',' </parameter>'); 47 47 fprintf(fid,'%s\n%s\n','</frame>'); 48 48 49 49 % Output 50 50 fprintf(fid,'%s\n%s\n%s\n','<frame key="4" label="Output:">','<section name="flaim" />'); 51 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="solution" type="',class( obj.solution),'" default="',convert2str(obj.solution),'">',' <section name="flaim" />',' <help> name of kml solution file </help>',' </parameter>');52 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="quality" type="',class( obj.quality),'" default="',convert2str(obj.quality),'">',' <section name="flaim" />',' <help> quality of kml solution </help>',' </parameter>');51 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="solution" type="',class(self.solution),'" default="',convert2str(self.solution),'">',' <section name="flaim" />',' <help> name of kml solution file </help>',' </parameter>'); 52 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="quality" type="',class(self.quality),'" default="',convert2str(self.quality),'">',' <section name="flaim" />',' <help> quality of kml solution </help>',' </parameter>'); 53 53 fprintf(fid,'%s\n%s\n','</frame>'); 54 54 55 55 end % }}} 56 function obj= flaim(varargin) % {{{56 function self = flaim(varargin) % {{{ 57 57 switch nargin 58 58 case 0 59 obj=setdefaultparameters(obj);59 self=setdefaultparameters(self); 60 60 otherwise 61 61 error('constructor not supported'); 62 62 end 63 63 end % }}} 64 function obj = setdefaultparameters(obj) % {{{64 function self = setdefaultparameters(self) % {{{ 65 65 66 66 end % }}} 67 function md = checkconsistency( obj,md,solution,analyses) % {{{67 function md = checkconsistency(self,md,solution,analyses) % {{{ 68 68 69 69 %Early return … … 78 78 79 79 end % }}} 80 function disp( obj) % {{{80 function disp(self) % {{{ 81 81 82 82 disp(sprintf(' FLAIM - Flight Line Adaptation using Ice sheet Modeling:')); 83 83 84 84 disp(sprintf('\n Input:')); 85 fielddisplay( obj,'targets' ,'name of kml output targets file ');86 fielddisplay( obj,'tracks' ,'name of kml input tracks file ');87 fielddisplay( obj,'flightreqs' ,'structure of kml flight requirements (not used yet)');88 fielddisplay( obj,'criterion' ,'element or nodal criterion for flight path evaluation (metric)');85 fielddisplay(self,'targets' ,'name of kml output targets file '); 86 fielddisplay(self,'tracks' ,'name of kml input tracks file '); 87 fielddisplay(self,'flightreqs' ,'structure of kml flight requirements (not used yet)'); 88 fielddisplay(self,'criterion' ,'element or nodal criterion for flight path evaluation (metric)'); 89 89 90 90 disp(sprintf('\n Arguments:')); 91 fielddisplay( obj,'gridsatequator' ,'number of grids at equator (determines resolution)');92 fielddisplay( obj,'usevalueordering' ,'flag to consider target values for flight path evaluation');93 fielddisplay( obj,'split_antimeridian' ,'flag to split polygons on the antimeridian');91 fielddisplay(self,'gridsatequator' ,'number of grids at equator (determines resolution)'); 92 fielddisplay(self,'usevalueordering' ,'flag to consider target values for flight path evaluation'); 93 fielddisplay(self,'split_antimeridian' ,'flag to split polygons on the antimeridian'); 94 94 95 95 disp(sprintf('\n Optimization:')); 96 fielddisplay( obj,'path_optimize' ,'optimize? (default false)');97 fielddisplay( obj,'opt_ndir' ,{'number of directions to test when moving a point. If this value = 1, a random direction is tested.',...96 fielddisplay(self,'path_optimize' ,'optimize? (default false)'); 97 fielddisplay(self,'opt_ndir' ,{'number of directions to test when moving a point. If this value = 1, a random direction is tested.',... 98 98 'A value > 1 results in directions equally spaced from [0, 2*PI] being tested.',... 99 99 'For example, 4 would result in directions [0, PI/2, PI, 3PI/2].'}); 100 fielddisplay( obj,'opt_dist' ,'specifies the distance in km (default 25) to move a randomly selected path point on each iteration');101 fielddisplay( obj,'opt_niter' ,{'number of iterations (default 30,000) to run for flightplan optimization',...100 fielddisplay(self,'opt_dist' ,'specifies the distance in km (default 25) to move a randomly selected path point on each iteration'); 101 fielddisplay(self,'opt_niter' ,{'number of iterations (default 30,000) to run for flightplan optimization',... 102 102 'i.e. the number of times to randomly select a point and move it.'}); 103 103 104 104 disp(sprintf('\n Output:')); 105 fielddisplay( obj,'solution' ,'name of kml solution file');106 fielddisplay( obj,'quality' ,'quality of kml solution');105 fielddisplay(self,'solution' ,'name of kml solution file'); 106 fielddisplay(self,'quality' ,'quality of kml solution'); 107 107 end % }}} 108 108 end -
issm/trunk/src/m/classes/flowequation.m
r18301 r19105 26 26 end 27 27 methods (Static) 28 function obj = loadobj(obj) % {{{28 function self = loadobj(self) % {{{ 29 29 % This function is directly called by matlab when a model object is 30 30 % loaded. If the input is a struct it is an old version of this class and … … 44 44 end 45 45 46 if isstruct( obj)46 if isstruct(self) 47 47 disp('Recovering flowequation from older version'); 48 objstruct = obj;49 obj= structtoobj(flowequation(),objstruct);48 objstruct = self; 49 self = structtoobj(flowequation(),objstruct); 50 50 51 51 %2013 July 23rd 52 if isfield(objstruct,'ishutter'), obj.isSIA = objstruct.ishutter; end;53 if isfield(objstruct,'ismacayeal'), obj.isSSA = objstruct.ismacayeal; end;54 if isfield(objstruct,'ispattyn'), obj.isHO = objstruct.ispattyn; end;55 if isfield(objstruct,'isstokes'), obj.isFS = objstruct.isstokes; end;56 if isfield(objstruct,'bordermacayeal'), obj.borderSSA = objstruct.bordermacayeal; end;57 if isfield(objstruct,'borderpattyn'), obj.borderHO = objstruct.borderpattyn; end;58 if isfield(objstruct,'borderstokes'), obj.borderFS = objstruct.borderstokes; end;52 if isfield(objstruct,'ishutter'), self.isSIA = objstruct.ishutter; end; 53 if isfield(objstruct,'ismacayeal'), self.isSSA = objstruct.ismacayeal; end; 54 if isfield(objstruct,'ispattyn'), self.isHO = objstruct.ispattyn; end; 55 if isfield(objstruct,'isstokes'), self.isFS = objstruct.isstokes; end; 56 if isfield(objstruct,'bordermacayeal'),self.borderSSA = objstruct.bordermacayeal; end; 57 if isfield(objstruct,'borderpattyn'), self.borderHO = objstruct.borderpattyn; end; 58 if isfield(objstruct,'borderstokes'), self.borderFS = objstruct.borderstokes; end; 59 59 end 60 60 … … 62 62 end 63 63 methods 64 function createxml( obj,fid) % {{{64 function createxml(self,fid) % {{{ 65 65 fprintf(fid, '\n\n'); 66 66 fprintf(fid, '%s\n', '<!-- flowequation -->'); 67 67 fprintf(fid,'%s\n%s\n%s\n','<frame key="1" label="Flow equation parameters">','<section name="flowequation" />'); 68 68 69 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="isSIA" type="', class( obj.isSIA),'" default="', convert2str(obj.isSIA),'">', ' <section name="flowequation" />',' <help> is the Shallow Ice Approximation (SIA) used ? </help>','</parameter>');70 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="isSSA" type="', class( obj.isSSA),'" default="', convert2str(obj.isSSA),'">', ' <section name="flowequation" />',' <help> is the Shelfy-Stream Approximation (SSA) used ? </help>','</parameter>');71 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="isL1L2" type="', class( obj.isL1L2),'" default="', convert2str(obj.isL1L2),'">', ' <section name="flowequation" />',' <help> is the L1L2 approximation used ? </help>','</parameter>');72 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="isHO" type="', class( obj.isHO),'" default="', convert2str(obj.isHO),'">', ' <section name="flowequation" />',' <help> is the Higher-Order (HO) approximation used ? </help>','</parameter>');73 74 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="isFS" type="', class( obj.isFS),'" default="', convert2str(obj.isFS),'">', ' <section name="flowequation" />',' <help> are the Full-FS (FS) equations used ? </help>','</parameter>');69 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="isSIA" type="', class(self.isSIA),'" default="', convert2str(self.isSIA),'">', ' <section name="flowequation" />',' <help> is the Shallow Ice Approximation (SIA) used ? </help>','</parameter>'); 70 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="isSSA" type="', class(self.isSSA),'" default="', convert2str(self.isSSA),'">', ' <section name="flowequation" />',' <help> is the Shelfy-Stream Approximation (SSA) used ? </help>','</parameter>'); 71 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="isL1L2" type="', class(self.isL1L2),'" default="', convert2str(self.isL1L2),'">', ' <section name="flowequation" />',' <help> is the L1L2 approximation used ? </help>','</parameter>'); 72 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="isHO" type="', class(self.isHO),'" default="', convert2str(self.isHO),'">', ' <section name="flowequation" />',' <help> is the Higher-Order (HO) approximation used ? </help>','</parameter>'); 73 74 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="isFS" type="', class(self.isFS),'" default="', convert2str(self.isFS),'">', ' <section name="flowequation" />',' <help> are the Full-FS (FS) equations used ? </help>','</parameter>'); 75 75 76 76 % fe_SSA drop-down (P1, P1bubble, P1bubblecondensed, P2) … … 98 98 fprintf(fid,'%s\n%s\n',' <option value="TaylorHood" type="string" default="false"> </option>','</parameter>'); 99 99 100 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="vertex_equation" type="', class( obj.vertex_equation),'" default="', convert2str(obj.vertex_equation),'">', ' <section name="flowequation" />',' <help> flow equation for each vertex </help>','</parameter>');101 102 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="element_equation" type="', class( obj.element_equation),'" default="', convert2str(obj.element_equation),'">', ' <section name="flowequation" />',' <help> flow equation for each element </help>','</parameter>');103 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="borderSSA" type="', class( obj.borderSSA),'" default="', convert2str(obj.borderSSA),'">', ' <section name="flowequation" />',' <help> vertices on SSAs border (for tiling) </help>','</parameter>');104 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="borderHO" type="', class( obj.borderHO),'" default="', convert2str(obj.borderHO),'">', ' <section name="flowequation" />',' <help> vertices on HOs border (for tiling) </help>','</parameter>');105 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n', '<parameter key ="borderFS" type="', class( obj.borderFS),'" default="', convert2str(obj.borderFS),'">', ' <section name="flowequation" />',' <help> vertices on FS border (for tiling) </help>','</parameter>');100 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="vertex_equation" type="', class(self.vertex_equation),'" default="', convert2str(self.vertex_equation),'">', ' <section name="flowequation" />',' <help> flow equation for each vertex </help>','</parameter>'); 101 102 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="element_equation" type="', class(self.element_equation),'" default="', convert2str(self.element_equation),'">', ' <section name="flowequation" />',' <help> flow equation for each element </help>','</parameter>'); 103 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="borderSSA" type="', class(self.borderSSA),'" default="', convert2str(self.borderSSA),'">', ' <section name="flowequation" />',' <help> vertices on SSAs border (for tiling) </help>','</parameter>'); 104 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="borderHO" type="', class(self.borderHO),'" default="', convert2str(self.borderHO),'">', ' <section name="flowequation" />',' <help> vertices on HOs border (for tiling) </help>','</parameter>'); 105 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n', '<parameter key ="borderFS" type="', class(self.borderFS),'" default="', convert2str(self.borderFS),'">', ' <section name="flowequation" />',' <help> vertices on FS border (for tiling) </help>','</parameter>'); 106 106 107 107 fprintf(fid,'%s\n%s\n','</frame>'); 108 108 end % }}} 109 function obj = flowequation(varargin) % {{{ 109 function self = extrude(self,md) % {{{ 110 self.element_equation=project3d(md,'vector',self.element_equation,'type','element'); 111 self.vertex_equation=project3d(md,'vector',self.vertex_equation,'type','node'); 112 self.borderSSA=project3d(md,'vector',self.borderSSA,'type','node'); 113 self.borderHO=project3d(md,'vector',self.borderHO,'type','node'); 114 self.borderFS=project3d(md,'vector',self.borderFS,'type','node'); 115 end % }}} 116 function self = flowequation(varargin) % {{{ 110 117 switch nargin 111 118 case 0 112 obj=setdefaultparameters(obj);119 self=setdefaultparameters(self); 113 120 otherwise 114 121 error('constructor not supported'); 115 122 end 116 123 end % }}} 117 function obj = setdefaultparameters(obj) % {{{124 function self = setdefaultparameters(self) % {{{ 118 125 119 126 %P1 for SSA 120 obj.fe_SSA= 'P1';127 self.fe_SSA= 'P1'; 121 128 122 129 %P1 for HO 123 obj.fe_HO= 'P1';130 self.fe_HO= 'P1'; 124 131 125 132 %MINI condensed element for FS by default 126 obj.fe_FS = 'MINIcondensed'; 127 end % }}} 128 function md = checkconsistency(obj,md,solution,analyses) % {{{ 129 130 if ismember(StressbalanceAnalysisEnum(),analyses), 131 132 md = checkfield(md,'fieldname','flowequation.isSIA','numel',[1],'values',[0 1]); 133 md = checkfield(md,'fieldname','flowequation.isSSA','numel',[1],'values',[0 1]); 134 md = checkfield(md,'fieldname','flowequation.isL1L2','numel',[1],'values',[0 1]); 135 md = checkfield(md,'fieldname','flowequation.isHO','numel',[1],'values',[0 1]); 136 md = checkfield(md,'fieldname','flowequation.isFS','numel',[1],'values',[0 1]); 137 md = checkfield(md,'fieldname','flowequation.fe_SSA','values',{'P1','P1bubble','P1bubblecondensed','P2','P2bubble'}); 138 md = checkfield(md,'fieldname','flowequation.fe_HO' ,'values',{'P1','P1bubble','P1bubblecondensed','P1xP2','P2xP1','P2','P2bubble','P1xP3','P2xP4'}); 139 md = checkfield(md,'fieldname','flowequation.fe_FS' ,'values',{'P1P1','P1P1GLS','MINIcondensed','MINI','TaylorHood','LATaylorHood','XTaylorHood','OneLayerP4z','CrouzeixRaviart'}); 140 md = checkfield(md,'fieldname','flowequation.augmented_lagrangian_r','numel',[1],'>',0.); 141 md = checkfield(md,'fieldname','flowequation.augmented_lagrangian_rlambda','numel',[1],'>',0.); 142 md = checkfield(md,'fieldname','flowequation.augmented_lagrangian_rhop','numel',[1],'>',0.); 143 md = checkfield(md,'fieldname','flowequation.augmented_lagrangian_rholambda','numel',[1],'>',0.); 144 md = checkfield(md,'fieldname','flowequation.XTH_theta','numel',[1],'>=',0.,'<',0.5); 145 md = checkfield(md,'fieldname','flowequation.borderSSA','size',[md.mesh.numberofvertices 1],'values',[0 1]); 146 md = checkfield(md,'fieldname','flowequation.borderHO','size',[md.mesh.numberofvertices 1],'values',[0 1]); 147 md = checkfield(md,'fieldname','flowequation.borderFS','size',[md.mesh.numberofvertices 1],'values',[0 1]); 148 if strcmp(domaintype(md.mesh),'2Dhorizontal') 149 md = checkfield(md,'fieldname','flowequation.vertex_equation','size',[md.mesh.numberofvertices 1],'values',[1:2]); 150 md = checkfield(md,'fieldname','flowequation.element_equation','size',[md.mesh.numberofelements 1],'values',[1:2]); 151 elseif strcmp(domaintype(md.mesh),'2Dvertical') 152 md = checkfield(md,'fieldname','flowequation.vertex_equation','size',[md.mesh.numberofvertices 1],'values',[2,4,5]); 153 md = checkfield(md,'fieldname','flowequation.element_equation','size',[md.mesh.numberofelements 1],'values',[2,4,5]); 154 elseif strcmp(domaintype(md.mesh),'3D'), 155 md = checkfield(md,'fieldname','flowequation.vertex_equation','size',[md.mesh.numberofvertices 1],'values',[0:8]); 156 md = checkfield(md,'fieldname','flowequation.element_equation','size',[md.mesh.numberofelements 1],'values',[0:8]); 157 else 158 error('Case not supported yet'); 159 end 160 if ~(obj.isSIA || obj.isSSA || obj.isL1L2 || obj.isHO || obj.isFS), 161 md = checkmessage(md,['no element types set for this model']); 162 end 133 self.fe_FS = 'MINIcondensed'; 134 end % }}} 135 function md = checkconsistency(self,md,solution,analyses) % {{{ 136 137 138 %Early return 139 if (~ismember(StressbalanceAnalysisEnum(),analyses) & ~ismember(StressbalanceSIAAnalysisEnum(),analyses)) | (solution==TransientSolutionEnum() & md.transient.isstressbalance==0), return; end 140 141 md = checkfield(md,'fieldname','flowequation.isSIA','numel',[1],'values',[0 1]); 142 md = checkfield(md,'fieldname','flowequation.isSSA','numel',[1],'values',[0 1]); 143 md = checkfield(md,'fieldname','flowequation.isL1L2','numel',[1],'values',[0 1]); 144 md = checkfield(md,'fieldname','flowequation.isHO','numel',[1],'values',[0 1]); 145 md = checkfield(md,'fieldname','flowequation.isFS','numel',[1],'values',[0 1]); 146 md = checkfield(md,'fieldname','flowequation.fe_SSA','values',{'P1','P1bubble','P1bubblecondensed','P2','P2bubble'}); 147 md = checkfield(md,'fieldname','flowequation.fe_HO' ,'values',{'P1','P1bubble','P1bubblecondensed','P1xP2','P2xP1','P2','P2bubble','P1xP3','P2xP4'}); 148 md = checkfield(md,'fieldname','flowequation.fe_FS' ,'values',{'P1P1','P1P1GLS','MINIcondensed','MINI','TaylorHood','LATaylorHood','XTaylorHood','OneLayerP4z','CrouzeixRaviart','LACrouzeixRaviart'}); 149 md = checkfield(md,'fieldname','flowequation.augmented_lagrangian_r','numel',[1],'>',0.); 150 md = checkfield(md,'fieldname','flowequation.augmented_lagrangian_rlambda','numel',[1],'>',0.); 151 md = checkfield(md,'fieldname','flowequation.augmented_lagrangian_rhop','numel',[1],'>',0.); 152 md = checkfield(md,'fieldname','flowequation.augmented_lagrangian_rholambda','numel',[1],'>',0.); 153 md = checkfield(md,'fieldname','flowequation.XTH_theta','numel',[1],'>=',0.,'<',0.5); 154 md = checkfield(md,'fieldname','flowequation.borderSSA','size',[md.mesh.numberofvertices 1],'values',[0 1]); 155 md = checkfield(md,'fieldname','flowequation.borderHO','size',[md.mesh.numberofvertices 1],'values',[0 1]); 156 md = checkfield(md,'fieldname','flowequation.borderFS','size',[md.mesh.numberofvertices 1],'values',[0 1]); 157 if strcmp(domaintype(md.mesh),'2Dhorizontal') 158 md = checkfield(md,'fieldname','flowequation.vertex_equation','size',[md.mesh.numberofvertices 1],'values',[1:2]); 159 md = checkfield(md,'fieldname','flowequation.element_equation','size',[md.mesh.numberofelements 1],'values',[1:2]); 160 elseif strcmp(domaintype(md.mesh),'3Dsurface') 161 md = checkfield(md,'fieldname','flowequation.vertex_equation','size',[md.mesh.numberofvertices 1],'values',[1:2]); 162 md = checkfield(md,'fieldname','flowequation.element_equation','size',[md.mesh.numberofelements 1],'values',[1:2]); 163 elseif strcmp(domaintype(md.mesh),'2Dvertical') 164 md = checkfield(md,'fieldname','flowequation.vertex_equation','size',[md.mesh.numberofvertices 1],'values',[2,4,5]); 165 md = checkfield(md,'fieldname','flowequation.element_equation','size',[md.mesh.numberofelements 1],'values',[2,4,5]); 166 elseif strcmp(domaintype(md.mesh),'3D'), 167 md = checkfield(md,'fieldname','flowequation.vertex_equation','size',[md.mesh.numberofvertices 1],'values',[0:8]); 168 md = checkfield(md,'fieldname','flowequation.element_equation','size',[md.mesh.numberofelements 1],'values',[0:8]); 169 else 170 error('Case not supported yet'); 171 end 172 if ~(self.isSIA || self.isSSA || self.isL1L2 || self.isHO || self.isFS), 173 md = checkmessage(md,['no element types set for this model']); 163 174 end 164 175 if ismember(StressbalanceSIAAnalysisEnum(),analyses), 165 if any( obj.element_equation==1),166 if( obj.vertex_equation & md.mask.groundedice_levelset<0.),176 if any(self.element_equation==1), 177 if(self.vertex_equation & md.mask.groundedice_levelset<0.), 167 178 disp(sprintf('\n !!! Warning: SIA''s model is not consistent on ice shelves !!!\n')); 168 179 end … … 171 182 172 183 end % }}} 173 function disp( obj) % {{{184 function disp(self) % {{{ 174 185 disp(sprintf(' flow equation parameters:')); 175 186 176 fielddisplay( obj,'isSIA','is the Shallow Ice Approximation (SIA) used ?');177 fielddisplay( obj,'isSSA','is the Shelfy-Stream Approximation (SSA) used ?');178 fielddisplay( obj,'isL1L2','is the L1L2 approximation used ?');179 fielddisplay( obj,'isHO','is the Higher-Order (HO) approximation used ?');180 fielddisplay( obj,'isFS','are the Full-FS (FS) equations used ?');181 fielddisplay( obj,'fe_SSA','Finite Element for SSA ''P1'', ''P1bubble'' ''P1bubblecondensed'' ''P2''');182 fielddisplay( obj,'fe_HO', 'Finite Element for HO ''P1'' ''P1bubble'' ''P1bubblecondensed'' ''P1xP2'' ''P2xP1'' ''P2''');183 fielddisplay( obj,'fe_FS', 'Finite Element for FS ''P1P1'' (debugging only) ''P1P1GLS'' ''MINIcondensed'' ''MINI'' ''TaylorHood'' ''XTaylorHood''');184 fielddisplay( obj,'vertex_equation','flow equation for each vertex');185 fielddisplay( obj,'element_equation','flow equation for each element');186 fielddisplay( obj,'borderSSA','vertices on SSA''s border (for tiling)');187 fielddisplay( obj,'borderHO','vertices on HO''s border (for tiling)');188 fielddisplay( obj,'borderFS','vertices on FS'' border (for tiling)');189 190 end % }}} 191 function marshall( obj,md,fid) % {{{192 WriteData(fid,'object', obj,'fieldname','isSIA','format','Boolean');193 WriteData(fid,'object', obj,'fieldname','isSSA','format','Boolean');194 WriteData(fid,'object', obj,'fieldname','isL1L2','format','Boolean');195 WriteData(fid,'object', obj,'fieldname','isHO','format','Boolean');196 WriteData(fid,'object', obj,'fieldname','isFS','format','Boolean');197 WriteData(fid,'enum',FlowequationFeSSAEnum(),'data',StringToEnum( obj.fe_SSA),'format','Integer');198 WriteData(fid,'enum',FlowequationFeHOEnum() ,'data',StringToEnum( obj.fe_HO) ,'format','Integer');199 WriteData(fid,'enum',FlowequationFeFSEnum() ,'data',StringToEnum( obj.fe_FS) ,'format','Integer');200 WriteData(fid,'enum',AugmentedLagrangianREnum(),'data', obj.augmented_lagrangian_r ,'format','Double');201 WriteData(fid,'enum',AugmentedLagrangianRhopEnum(),'data', obj.augmented_lagrangian_rhop ,'format','Double');202 WriteData(fid,'enum',AugmentedLagrangianRlambdaEnum(),'data', obj.augmented_lagrangian_rlambda ,'format','Double');203 WriteData(fid,'enum',AugmentedLagrangianRholambdaEnum(),'data', obj.augmented_lagrangian_rholambda ,'format','Double');204 WriteData(fid,'enum',AugmentedLagrangianThetaEnum() ,'data', obj.XTH_theta ,'format','Double');205 WriteData(fid,'object', obj,'fieldname','borderSSA','format','DoubleMat','mattype',1);206 WriteData(fid,'object', obj,'fieldname','borderHO','format','DoubleMat','mattype',1);207 WriteData(fid,'object', obj,'fieldname','borderFS','format','DoubleMat','mattype',1);187 fielddisplay(self,'isSIA','is the Shallow Ice Approximation (SIA) used ?'); 188 fielddisplay(self,'isSSA','is the Shelfy-Stream Approximation (SSA) used ?'); 189 fielddisplay(self,'isL1L2','is the L1L2 approximation used ?'); 190 fielddisplay(self,'isHO','is the Higher-Order (HO) approximation used ?'); 191 fielddisplay(self,'isFS','are the Full-FS (FS) equations used ?'); 192 fielddisplay(self,'fe_SSA','Finite Element for SSA ''P1'', ''P1bubble'' ''P1bubblecondensed'' ''P2'''); 193 fielddisplay(self,'fe_HO', 'Finite Element for HO ''P1'' ''P1bubble'' ''P1bubblecondensed'' ''P1xP2'' ''P2xP1'' ''P2'''); 194 fielddisplay(self,'fe_FS', 'Finite Element for FS ''P1P1'' (debugging only) ''P1P1GLS'' ''MINIcondensed'' ''MINI'' ''TaylorHood'' ''XTaylorHood'''); 195 fielddisplay(self,'vertex_equation','flow equation for each vertex'); 196 fielddisplay(self,'element_equation','flow equation for each element'); 197 fielddisplay(self,'borderSSA','vertices on SSA''s border (for tiling)'); 198 fielddisplay(self,'borderHO','vertices on HO''s border (for tiling)'); 199 fielddisplay(self,'borderFS','vertices on FS'' border (for tiling)'); 200 201 end % }}} 202 function marshall(self,md,fid) % {{{ 203 WriteData(fid,'object',self,'fieldname','isSIA','format','Boolean'); 204 WriteData(fid,'object',self,'fieldname','isSSA','format','Boolean'); 205 WriteData(fid,'object',self,'fieldname','isL1L2','format','Boolean'); 206 WriteData(fid,'object',self,'fieldname','isHO','format','Boolean'); 207 WriteData(fid,'object',self,'fieldname','isFS','format','Boolean'); 208 WriteData(fid,'enum',FlowequationFeSSAEnum(),'data',StringToEnum(self.fe_SSA),'format','Integer'); 209 WriteData(fid,'enum',FlowequationFeHOEnum() ,'data',StringToEnum(self.fe_HO) ,'format','Integer'); 210 WriteData(fid,'enum',FlowequationFeFSEnum() ,'data',StringToEnum(self.fe_FS) ,'format','Integer'); 211 WriteData(fid,'enum',AugmentedLagrangianREnum(),'data',self.augmented_lagrangian_r ,'format','Double'); 212 WriteData(fid,'enum',AugmentedLagrangianRhopEnum(),'data',self.augmented_lagrangian_rhop ,'format','Double'); 213 WriteData(fid,'enum',AugmentedLagrangianRlambdaEnum(),'data',self.augmented_lagrangian_rlambda ,'format','Double'); 214 WriteData(fid,'enum',AugmentedLagrangianRholambdaEnum(),'data',self.augmented_lagrangian_rholambda ,'format','Double'); 215 WriteData(fid,'enum',AugmentedLagrangianThetaEnum() ,'data',self.XTH_theta ,'format','Double'); 216 WriteData(fid,'object',self,'fieldname','borderSSA','format','DoubleMat','mattype',1); 217 WriteData(fid,'object',self,'fieldname','borderHO','format','DoubleMat','mattype',1); 218 WriteData(fid,'object',self,'fieldname','borderFS','format','DoubleMat','mattype',1); 208 219 %convert approximations to enums 209 data= obj.vertex_equation;220 data=self.vertex_equation; 210 221 pos=find(data==0); data(pos,end)=NoneApproximationEnum(); 211 222 pos=find(data==1); data(pos,end)=SIAApproximationEnum(); … … 219 230 pos=find(data==8); data(pos,end)=SSAFSApproximationEnum(); 220 231 WriteData(fid,'data',data,'enum',FlowequationVertexEquationEnum(),'format','DoubleMat','mattype',1); 221 data= obj.element_equation;232 data=self.element_equation; 222 233 pos=find(data==0); data(pos,end)=NoneApproximationEnum(); 223 234 pos=find(data==1); data(pos,end)=SIAApproximationEnum(); -
issm/trunk/src/m/classes/flowequation.py
r18301 r19105 1 1 import numpy 2 2 import copy 3 from project3d import project3d 3 4 from fielddisplay import fielddisplay 4 5 from EnumDefinitions import * … … 58 59 return string 59 60 #}}} 61 def extrude(self,md): # {{{ 62 self.element_equation=project3d(md,'vector',self.element_equation,'type','element') 63 self.vertex_equation=project3d(md,'vector',self.vertex_equation,'type','node') 64 self.borderSSA=project3d(md,'vector',self.borderSSA,'type','node') 65 self.borderHO=project3d(md,'vector',self.borderHO,'type','node') 66 self.borderFS=project3d(md,'vector',self.borderFS,'type','node') 67 return self 68 #}}} 60 69 def setdefaultparameters(self): # {{{ 61 70 … … 73 82 def checkconsistency(self,md,solution,analyses): # {{{ 74 83 75 if StressbalanceAnalysisEnum() in analyses: 76 md = checkfield(md,'fieldname','flowequation.isSIA','numel',[1],'values',[0,1]) 77 md = checkfield(md,'fieldname','flowequation.isSSA','numel',[1],'values',[0,1]) 78 md = checkfield(md,'fieldname','flowequation.isL1L2','numel',[1],'values',[0,1]) 79 md = checkfield(md,'fieldname','flowequation.isHO','numel',[1],'values',[0,1]) 80 md = checkfield(md,'fieldname','flowequation.isFS','numel',[1],'values',[0,1]) 81 md = checkfield(md,'fieldname','flowequation.fe_SSA','values',['P1','P1bubble','P1bubblecondensed','P2','P2bubble']) 82 md = checkfield(md,'fieldname','flowequation.fe_HO' ,'values',['P1','P1bubble','P1bubblecondensed','P1xP2','P2xP1','P2','P2bubble','P1xP3','P2xP4']) 83 md = checkfield(md,'fieldname','flowequation.fe_FS' ,'values',['P1P1','P1P1GLS','MINIcondensed','MINI','TaylorHood','XTaylorHood','OneLayerP4z','CrouzeixRaviart']) 84 md = checkfield(md,'fieldname','flowequation.borderSSA','size',[md.mesh.numberofvertices],'values',[0,1]) 85 md = checkfield(md,'fieldname','flowequation.borderHO','size',[md.mesh.numberofvertices],'values',[0,1]) 86 md = checkfield(md,'fieldname','flowequation.borderFS','size',[md.mesh.numberofvertices],'values',[0,1]) 87 md = checkfield(md,'fieldname','flowequation.augmented_lagrangian_r','numel',[1],'>',0.) 88 md = checkfield(md,'fieldname','flowequation.augmented_lagrangian_rhop','numel',[1],'>',0.) 89 md = checkfield(md,'fieldname','flowequation.augmented_lagrangian_rlambda','numel',[1],'>',0.) 90 md = checkfield(md,'fieldname','flowequation.augmented_lagrangian_rholambda','numel',[1],'>',0.) 91 md = checkfield(md,'fieldname','flowequation.XTH_theta','numel',[1],'>=',0.,'<',.5) 92 if m.strcmp(md.mesh.domaintype(),'2Dhorizontal'): 93 md = checkfield(md,'fieldname','flowequation.vertex_equation','size',[md.mesh.numberofvertices],'values',[1,2]) 94 md = checkfield(md,'fieldname','flowequation.element_equation','size',[md.mesh.numberofelements],'values',[1,2]) 95 elif m.strcmp(md.mesh.domaintype(),'3D'): 96 md = checkfield(md,'fieldname','flowequation.vertex_equation','size',[md.mesh.numberofvertices],'values',numpy.arange(0,8+1)) 97 md = checkfield(md,'fieldname','flowequation.element_equation','size',[md.mesh.numberofelements],'values',numpy.arange(0,8+1)) 98 else: 99 raise RuntimeError('mesh type not supported yet') 100 if not (self.isSIA or self.isSSA or self.isL1L2 or self.isHO or self.isFS): 101 md.checkmessage("no element types set for this model") 84 #Early return 85 if (StressbalanceAnalysisEnum() not in analyses and StressbalanceSIAAnalysisEnum() not in analyses) or (solution==TransientSolutionEnum() and not md.transient.isstressbalance): 86 return md 87 88 md = checkfield(md,'fieldname','flowequation.isSIA','numel',[1],'values',[0,1]) 89 md = checkfield(md,'fieldname','flowequation.isSSA','numel',[1],'values',[0,1]) 90 md = checkfield(md,'fieldname','flowequation.isL1L2','numel',[1],'values',[0,1]) 91 md = checkfield(md,'fieldname','flowequation.isHO','numel',[1],'values',[0,1]) 92 md = checkfield(md,'fieldname','flowequation.isFS','numel',[1],'values',[0,1]) 93 md = checkfield(md,'fieldname','flowequation.fe_SSA','values',['P1','P1bubble','P1bubblecondensed','P2','P2bubble']) 94 md = checkfield(md,'fieldname','flowequation.fe_HO' ,'values',['P1','P1bubble','P1bubblecondensed','P1xP2','P2xP1','P2','P2bubble','P1xP3','P2xP4']) 95 md = checkfield(md,'fieldname','flowequation.fe_FS' ,'values',['P1P1','P1P1GLS','MINIcondensed','MINI','TaylorHood','XTaylorHood','OneLayerP4z','CrouzeixRaviart']) 96 md = checkfield(md,'fieldname','flowequation.borderSSA','size',[md.mesh.numberofvertices],'values',[0,1]) 97 md = checkfield(md,'fieldname','flowequation.borderHO','size',[md.mesh.numberofvertices],'values',[0,1]) 98 md = checkfield(md,'fieldname','flowequation.borderFS','size',[md.mesh.numberofvertices],'values',[0,1]) 99 md = checkfield(md,'fieldname','flowequation.augmented_lagrangian_r','numel',[1],'>',0.) 100 md = checkfield(md,'fieldname','flowequation.augmented_lagrangian_rhop','numel',[1],'>',0.) 101 md = checkfield(md,'fieldname','flowequation.augmented_lagrangian_rlambda','numel',[1],'>',0.) 102 md = checkfield(md,'fieldname','flowequation.augmented_lagrangian_rholambda','numel',[1],'>',0.) 103 md = checkfield(md,'fieldname','flowequation.XTH_theta','numel',[1],'>=',0.,'<',.5) 104 if m.strcmp(md.mesh.domaintype(),'2Dhorizontal'): 105 md = checkfield(md,'fieldname','flowequation.vertex_equation','size',[md.mesh.numberofvertices],'values',[1,2]) 106 md = checkfield(md,'fieldname','flowequation.element_equation','size',[md.mesh.numberofelements],'values',[1,2]) 107 elif m.strcmp(md.mesh.domaintype(),'3D'): 108 md = checkfield(md,'fieldname','flowequation.vertex_equation','size',[md.mesh.numberofvertices],'values',numpy.arange(0,8+1)) 109 md = checkfield(md,'fieldname','flowequation.element_equation','size',[md.mesh.numberofelements],'values',numpy.arange(0,8+1)) 110 else: 111 raise RuntimeError('mesh type not supported yet') 112 if not (self.isSIA or self.isSSA or self.isL1L2 or self.isHO or self.isFS): 113 md.checkmessage("no element types set for this model") 102 114 103 115 if StressbalanceSIAAnalysisEnum() in analyses: -
issm/trunk/src/m/classes/friction.m
r17989 r19105 11 11 end 12 12 methods 13 function createxml(obj,fid) % {{{ 14 fprintf(fid, '\n\n'); 15 fprintf(fid, '%s\n', '<!-- Friction: Sigma= drag^2 * Neff ^r * u ^s, with Neff=rho_ice*g*thickness+rho_water*g*bed, r=q/p and s=1/p -->'); 16 fprintf(fid,'%s\n%s\n%s\n','<frame key="1" label="Friction: Sigma= drag^2 * Neff ^r * u ^s, with Neff=rho_ice*g*thickness+rho_water*g*bed, r=q/p and s=1/p">','<section name="friction" />'); 17 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="coefficient" type="', class(obj.coefficient),'" default="', convert2str(obj.coefficient),'">', ' <section name="friction" />',' <help> friction coefficient [SI] </help>','</parameter>'); 18 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="p" type="', class(obj.p),'" default="', convert2str(obj.p),'">', ' <section name="friction" />',' <help> p exponent </help>','</parameter>'); 19 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n', '<parameter key ="q" type="', class(obj.q),'" default="', convert2str(obj.q),'">', ' <section name="friction" />',' <help> q exponent </help>','</parameter>'); 20 fprintf(fid,'%s\n%s\n','</frame>'); 21 end % }}} 22 function obj = friction(varargin) % {{{ 13 function createxml(self,fid) % {{{ 14 fprintf(fid, '\n\n'); 15 fprintf(fid, '%s\n', '<!-- Friction: Sigma= drag^2 * Neff ^r * u ^s, with Neff=rho_ice*g*thickness+rho_water*g*bed, r=q/p and s=1/p -->'); 16 fprintf(fid,'%s\n%s\n%s\n','<frame key="1" label="Friction: Sigma= drag^2 * Neff ^r * u ^s, with Neff=rho_ice*g*thickness+rho_water*g*bed, r=q/p and s=1/p">','<section name="friction" />'); 17 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="coefficient" type="', class(self.coefficient),'" default="', convert2str(self.coefficient),'">', ' <section name="friction" />',' <help> friction coefficient [SI] </help>','</parameter>'); 18 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="p" type="', class(self.p),'" default="', convert2str(self.p),'">', ' <section name="friction" />',' <help> p exponent </help>','</parameter>'); 19 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n', '<parameter key ="q" type="', class(self.q),'" default="', convert2str(self.q),'">', ' <section name="friction" />',' <help> q exponent </help>','</parameter>'); 20 fprintf(fid,'%s\n%s\n','</frame>'); 21 end % }}} 22 function self = extrude(self,md) % {{{ 23 self.coefficient=project3d(md,'vector',self.coefficient,'type','node','layer',1); 24 self.p=project3d(md,'vector',self.p,'type','element'); 25 self.q=project3d(md,'vector',self.q,'type','element'); 26 end % }}} 27 function self = friction(varargin) % {{{ 23 28 switch nargin 24 29 case 0 25 obj=setdefaultparameters(obj);30 self=setdefaultparameters(self); 26 31 otherwise 27 32 error('constructor not supported'); 28 33 end 29 34 end % }}} 30 function obj = setdefaultparameters(obj) % {{{35 function self = setdefaultparameters(self) % {{{ 31 36 32 37 end % }}} 33 function md = checkconsistency( obj,md,solution,analyses) % {{{38 function md = checkconsistency(self,md,solution,analyses) % {{{ 34 39 35 40 %Early return 36 41 if ~ismember(StressbalanceAnalysisEnum(),analyses) & ~ismember(ThermalAnalysisEnum(),analyses), return; end 37 md = checkfield(md,'fieldname','friction.coefficient',' forcing',1,'NaN',1);42 md = checkfield(md,'fieldname','friction.coefficient','timeseries',1,'NaN',1); 38 43 md = checkfield(md,'fieldname','friction.q','NaN',1,'size',[md.mesh.numberofelements 1]); 39 44 md = checkfield(md,'fieldname','friction.p','NaN',1,'size',[md.mesh.numberofelements 1]); 40 45 end % }}} 41 function disp( obj) % {{{46 function disp(self) % {{{ 42 47 disp(sprintf('Basal shear stress parameters: Sigma_b = coefficient^2 * Neff ^r * |u_b|^(s-1) * u_b\n(effective stress Neff=rho_ice*g*thickness+rho_water*g*bed, r=q/p and s=1/p)')); 43 fielddisplay( obj,'coefficient','friction coefficient [SI]');44 fielddisplay( obj,'p','p exponent');45 fielddisplay( obj,'q','q exponent');48 fielddisplay(self,'coefficient','friction coefficient [SI]'); 49 fielddisplay(self,'p','p exponent'); 50 fielddisplay(self,'q','q exponent'); 46 51 end % }}} 47 function marshall( obj,md,fid) % {{{52 function marshall(self,md,fid) % {{{ 48 53 yts=365.0*24.0*3600.0; 49 54 50 55 WriteData(fid,'enum',FrictionLawEnum,'data',1,'format','Integer'); 51 WriteData(fid,'object', obj,'fieldname','coefficient','format','DoubleMat','mattype',1,'forcinglength',md.mesh.numberofvertices+1);52 %WriteData(fid,'object', obj,'fieldname','coefficient','format','DoubleMat','mattype',1);53 WriteData(fid,'object', obj,'fieldname','p','format','DoubleMat','mattype',2);54 WriteData(fid,'object', obj,'fieldname','q','format','DoubleMat','mattype',2);56 WriteData(fid,'object',self,'fieldname','coefficient','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1); 57 %WriteData(fid,'object',self,'fieldname','coefficient','format','DoubleMat','mattype',1); 58 WriteData(fid,'object',self,'fieldname','p','format','DoubleMat','mattype',2); 59 WriteData(fid,'object',self,'fieldname','q','format','DoubleMat','mattype',2); 55 60 56 61 -
issm/trunk/src/m/classes/friction.py
r17989 r19105 1 1 from fielddisplay import fielddisplay 2 from project3d import project3d 2 3 from EnumDefinitions import * 3 4 from checkfield import checkfield … … 29 30 return string 30 31 #}}} 32 def extrude(self,md): # {{{ 33 self.coefficient=project3d(md,'vector',self.coefficient,'type','node','layer',1) 34 self.p=project3d(md,'vector',self.p,'type','element') 35 self.q=project3d(md,'vector',self.q,'type','element') 36 return self 37 #}}} 31 38 def setdefaultparameters(self): # {{{ 32 39 return self … … 38 45 return md 39 46 40 md = checkfield(md,'fieldname','friction.coefficient',' forcing',1,'NaN',1)47 md = checkfield(md,'fieldname','friction.coefficient','timeseries',1,'NaN',1) 41 48 md = checkfield(md,'fieldname','friction.q','NaN',1,'size',[md.mesh.numberofelements]) 42 49 md = checkfield(md,'fieldname','friction.p','NaN',1,'size',[md.mesh.numberofelements]) -
issm/trunk/src/m/classes/frictionweertman.m
r17989 r19105 10 10 end 11 11 methods 12 function createxml(obj,fid) % {{{13 14 15 16 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="coefficient" type="', class(obj.coefficient),'" default="', convert2str(obj.coefficient),'">', ' <section name="frictionweertman" />',' <help> frictionweertman coefficient [SI] </help>','</parameter>');17 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="p" type="', class(obj.p),'" default="', convert2str(obj.p),'">', ' <section name="frictionweertman" />',' <help> p exponent </help>','</parameter>');18 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n', '<parameter key ="q" type="', class(obj.q),'" default="', convert2str(obj.q),'">', ' <section name="frictionweertman" />',' <help> q exponent </help>','</parameter>');19 20 21 function obj= frictionweertman(varargin) % {{{12 function createxml(self,fid) % {{{ 13 fprintf(fid, '\n\n'); 14 fprintf(fid, '%s\n', '<!-- Friction: Sigma= drag^2 * Neff ^r * u ^s, with Neff=rho_ice*g*thickness+rho_water*g*bed, r=q/p and s=1/p -->'); 15 fprintf(fid,'%s\n%s\n%s\n','<frame key="1" label="Friction: Sigma= drag^2 * Neff ^r * u ^s, with Neff=rho_ice*g*thickness+rho_water*g*bed, r=q/p and s=1/p">','<section name="frictionweertman" />'); 16 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="coefficient" type="', class(self.coefficient),'" default="', convert2str(self.coefficient),'">', ' <section name="frictionweertman" />',' <help> frictionweertman coefficient [SI] </help>','</parameter>'); 17 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="p" type="', class(self.p),'" default="', convert2str(self.p),'">', ' <section name="frictionweertman" />',' <help> p exponent </help>','</parameter>'); 18 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n', '<parameter key ="q" type="', class(self.q),'" default="', convert2str(self.q),'">', ' <section name="frictionweertman" />',' <help> q exponent </help>','</parameter>'); 19 fprintf(fid,'%s\n%s\n','</frame>'); 20 end % }}} 21 function self = frictionweertman(varargin) % {{{ 22 22 switch nargin 23 23 case 0 24 obj=setdefaultparameters(obj);24 self=setdefaultparameters(self); 25 25 otherwise 26 26 error('constructor not supported'); 27 27 end 28 28 end % }}} 29 function obj = setdefaultparameters(obj) % {{{ 29 function self = extrude(self,md) % {{{ 30 md.friction.C=project3d(md,'vector',md.friction.C,'type','node','layer',1); 31 md.friction.m=project3d(md,'vector',md.friction.m,'type','element'); 32 end % }}} 33 function self = setdefaultparameters(self) % {{{ 30 34 31 35 end % }}} 32 function md = checkconsistency( obj,md,solution,analyses) % {{{36 function md = checkconsistency(self,md,solution,analyses) % {{{ 33 37 34 38 %Early return 35 39 if ~ismember(StressbalanceAnalysisEnum(),analyses) & ~ismember(ThermalAnalysisEnum(),analyses), return; end 36 md = checkfield(md,'fieldname','friction weertman.C','forcing',1,'NaN',1);37 md = checkfield(md,'fieldname','friction weertman.m','NaN',1,'size',[md.mesh.numberofelements 1]);40 md = checkfield(md,'fieldname','friction.C','timeseries',1,'NaN',1); 41 md = checkfield(md,'fieldname','friction.m','NaN',1,'size',[md.mesh.numberofelements 1]); 38 42 end % }}} 39 function disp(obj) % {{{ 40 disp(sprintf('Weertman sliding law parameters: Sigma_b = C^2 * |u_b|^(1/m-1) * u_b')); 41 fielddisplay(obj,'coefficient','friction coefficient [SI]'); 42 fielddisplay(obj,'m','m exponent'); 43 function disp(self) % {{{ 44 disp('Weertman sliding law parameters:'); 45 disp(' Weertman''s sliding law reads:'); 46 disp(' v_b = C * Sigma_b^m'); 47 disp(' In ISSM, this law is rewritten as:'); 48 disp(' Sigma_b = C^(-1/m) * |u_b|^(1/m-1) u_b'); 49 disp(' '); 50 fielddisplay(self,'C','friction coefficient [SI]'); 51 fielddisplay(self,'m','m exponent'); 43 52 end % }}} 44 function marshall( obj,md,fid) % {{{53 function marshall(self,md,fid) % {{{ 45 54 yts=365.0*24.0*3600.0; 46 55 47 WriteData(fid,'enum',FrictionLawEnum,'data', 1,'format','Integer');48 WriteData(fid,'class','friction','object', obj,'fieldname','C','format','DoubleMat','mattype',1,'forcinglength',md.mesh.numberofvertices+1);49 WriteData(fid,'class','friction','object', obj,'fieldname','m','format','DoubleMat','mattype',2);56 WriteData(fid,'enum',FrictionLawEnum,'data',2,'format','Integer'); 57 WriteData(fid,'class','friction','object',self,'fieldname','C','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1); 58 WriteData(fid,'class','friction','object',self,'fieldname','m','format','DoubleMat','mattype',2); 50 59 51 60 -
issm/trunk/src/m/classes/frictionweertman.py
r17989 r19105 1 1 from fielddisplay import fielddisplay 2 from project3d import project3d 2 3 from EnumDefinitions import * 3 4 from checkfield import checkfield … … 21 22 #}}} 22 23 def __repr__(self): # {{{ 23 string="Weertman sliding law parameters: Sigma_b = C^ 2* |u_b|^(1/m-1) * u_b"24 string="Weertman sliding law parameters: Sigma_b = C^(-1/m) * |u_b|^(1/m-1) * u_b" 24 25 25 26 string="%s\n%s"%(string,fielddisplay(self,"C","friction coefficient [SI]")) … … 36 37 return md 37 38 38 md = checkfield(md,'fieldname','friction.C',' forcing',1,'NaN',1)39 md = checkfield(md,'fieldname','friction.C','timeseries',1,'NaN',1) 39 40 md = checkfield(md,'fieldname','friction.m','NaN',1,'size',[md.mesh.numberofelements]) 40 41 -
issm/trunk/src/m/classes/geometry.m
r17989 r19105 13 13 end 14 14 methods (Static) 15 function obj = loadobj(obj) % {{{15 function self = loadobj(self) % {{{ 16 16 % This function is directly called by matlab when a model object is 17 17 % loaded. Update old properties here 18 18 19 19 %2014 March 26th 20 if isstruct( obj),20 if isstruct(self), 21 21 disp('WARNING: updating geometry'); 22 22 disp(' md.geometry.bed is now md.geometry.base'); 23 23 disp(' md.geometry.bathymetry is now md.geometry.bed'); 24 obj2 =obj;25 obj=geometry();26 obj.surface = obj2.surface;27 obj.thickness = obj2.thickness;28 obj.base = obj2.bed;29 obj.bed = obj2.bathymetry;24 obj2 = self; 25 self = geometry(); 26 self.surface = obj2.surface; 27 self.thickness = obj2.thickness; 28 self.base = obj2.bed; 29 self.bed = obj2.bathymetry; 30 30 end 31 31 … … 33 33 end 34 34 methods 35 %function createxml(obj,fid) 36 function createxml(obj, fid)% {{{ 37 fprintf(fid, '\n\n'); 38 fprintf(fid, '%s\n', '<!-- geometry -->'); 39 fprintf(fid,'%s\n%s\n%s\n','<frame key="1" label="Geometry parameters">','<section name="geometry" />'); 35 function createxml(self, fid)% {{{ 36 fprintf(fid, '\n\n'); 37 fprintf(fid, '%s\n', '<!-- geometry -->'); 38 fprintf(fid,'%s\n%s\n%s\n','<frame key="1" label="Geometry parameters">','<section name="geometry" />'); 40 39 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="surface" type="','path','" optional="','false','">',' <section name="geometry" />',' <help> surface elevation [m] </help>','</parameter>'); 41 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="thickness" type="','path','" optional="','false','">',' <section name="geometry" />',' <help> ice thickness [m] </help>','</parameter>'); 42 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="bed" type="','path','" optional="','false','">',' <section name="geometry" />',' <help> bed elevation [m] </help>','</parameter>'); 43 %fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="bathymetry" type="',class(obj.bathymetry),'" default="',convert2str(obj.bathymetry),'">',' <section name="geometry" />',' <help> bathymetry elevation [m] </help>','</parameter>'); 44 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n','<parameter key ="hydrostatic_ratio" type="',class(obj.hydrostatic_ratio),'" default="',convert2str(obj.hydrostatic_ratio),'">',' <section name="geometry" />',' <help> coefficient for ice shelves; thickness correction: hydrostatic_ratio H_obs+ (1-hydrostatic_ratio) H_hydro </help>','</parameter>'); 45 fprintf(fid,'%s\n%s\n','</frame>'); 46 end % }}} 47 function obj = geometry(varargin) % {{{ 40 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="thickness" type="','path','" optional="','false','">',' <section name="geometry" />',' <help> ice thickness [m] </help>','</parameter>'); 41 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="bed" type="','path','" optional="','false','">',' <section name="geometry" />',' <help> bed elevation [m] </help>','</parameter>'); 42 %fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="bathymetry" type="',class(self.bathymetry),'" default="',convert2str(self.bathymetry),'">',' <section name="geometry" />',' <help> bathymetry elevation [m] </help>','</parameter>'); 43 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n','<parameter key ="hydrostatic_ratio" type="',class(self.hydrostatic_ratio),'" default="',convert2str(self.hydrostatic_ratio),'">',' <section name="geometry" />',' <help> coefficient for ice shelves; thickness correction: hydrostatic_ratio H_obs+ (1-hydrostatic_ratio) H_hydro </help>','</parameter>'); 44 fprintf(fid,'%s\n%s\n','</frame>'); 45 end % }}} 46 function self = extrude(self,md) % {{{ 47 self.surface=project3d(md,'vector',self.surface,'type','node'); 48 self.thickness=project3d(md,'vector',self.thickness,'type','node'); 49 self.hydrostatic_ratio=project3d(md,'vector',self.hydrostatic_ratio,'type','node'); 50 self.base=project3d(md,'vector',self.base,'type','node'); 51 self.bed=project3d(md,'vector',self.bed,'type','node'); 52 end % }}} 53 function self = geometry(varargin) % {{{ 48 54 switch nargin 49 55 case 0 50 obj=setdefaultparameters(obj);56 self=setdefaultparameters(self); 51 57 otherwise 52 58 error('constructor not supported'); 53 59 end 54 60 end % }}} 55 function obj = setdefaultparameters(obj) % {{{61 function self = setdefaultparameters(self) % {{{ 56 62 57 63 end % }}} 58 function md = checkconsistency( obj,md,solution,analyses) % {{{64 function md = checkconsistency(self,md,solution,analyses) % {{{ 59 65 60 66 if (solution==TransientSolutionEnum() & md.transient.isgia) | (solution==GiaSolutionEnum()), 61 md = checkfield(md,'fieldname','geometry.thickness',' forcing',1,'NaN',1,'>=',0);67 md = checkfield(md,'fieldname','geometry.thickness','timeseries',1,'NaN',1,'>=',0); 62 68 else 63 69 md = checkfield(md,'fieldname','geometry.surface' ,'NaN',1,'size',[md.mesh.numberofvertices 1]); 64 70 md = checkfield(md,'fieldname','geometry.base' ,'NaN',1,'size',[md.mesh.numberofvertices 1]); 65 71 md = checkfield(md,'fieldname','geometry.thickness','NaN',1,'size',[md.mesh.numberofvertices 1],'>',0); 66 if any(( obj.thickness-obj.surface+obj.base)>10^-9),72 if any((self.thickness-self.surface+self.base)>10^-9), 67 73 md = checkmessage(md,['equality thickness=surface-base violated']); 68 74 end … … 72 78 end 73 79 end % }}} 74 function disp( obj) % {{{80 function disp(self) % {{{ 75 81 disp(sprintf(' geometry parameters:')); 76 82 77 fielddisplay( obj,'surface','ice upper surface elevation [m]');78 fielddisplay( obj,'thickness','ice thickness [m]');79 fielddisplay( obj,'base','ice base elevation [m]');80 fielddisplay( obj,'bed','bed elevation [m]');83 fielddisplay(self,'surface','ice upper surface elevation [m]'); 84 fielddisplay(self,'thickness','ice thickness [m]'); 85 fielddisplay(self,'base','ice base elevation [m]'); 86 fielddisplay(self,'bed','bed elevation [m]'); 81 87 82 88 end % }}} 83 function marshall( obj,md,fid) % {{{84 WriteData(fid,'data', obj.surface,'format','DoubleMat','mattype',1,'enum',SurfaceEnum());85 WriteData(fid,'data', obj.thickness,'format','DoubleMat','mattype',1,'enum',ThicknessEnum(),'forcinglength',md.mesh.numberofvertices+1);86 WriteData(fid,'data', obj.base,'format','DoubleMat','mattype',1,'enum',BaseEnum());87 WriteData(fid,'data', obj.bed,'format','DoubleMat','mattype',1,'enum',BedEnum());88 WriteData(fid,'object', obj,'fieldname','hydrostatic_ratio','format','DoubleMat','mattype',1);89 function marshall(self,md,fid) % {{{ 90 WriteData(fid,'data',self.surface,'format','DoubleMat','mattype',1,'enum',SurfaceEnum()); 91 WriteData(fid,'data',self.thickness,'format','DoubleMat','mattype',1,'enum',ThicknessEnum(),'timeserieslength',md.mesh.numberofvertices+1); 92 WriteData(fid,'data',self.base,'format','DoubleMat','mattype',1,'enum',BaseEnum()); 93 WriteData(fid,'data',self.bed,'format','DoubleMat','mattype',1,'enum',BedEnum()); 94 WriteData(fid,'object',self,'fieldname','hydrostatic_ratio','format','DoubleMat','mattype',1); 89 95 end % }}} 90 96 end -
issm/trunk/src/m/classes/geometry.py
r17806 r19105 1 from project3d import project3d 1 2 from fielddisplay import fielddisplay 2 3 from EnumDefinitions import * … … 32 33 return string 33 34 #}}} 35 def extrude(self,md): # {{{ 36 self.surface=project3d(md,'vector',self.surface,'type','node') 37 self.thickness=project3d(md,'vector',self.thickness,'type','node') 38 self.hydrostatic_ratio=project3d(md,'vector',self.hydrostatic_ratio,'type','node') 39 self.base=project3d(md,'vector',self.base,'type','node') 40 self.bed=project3d(md,'vector',self.bed,'type','node') 41 return self 42 #}}} 34 43 def setdefaultparameters(self): # {{{ 35 44 return self … … 39 48 md = checkfield(md,'fieldname','geometry.surface' ,'NaN',1,'size',[md.mesh.numberofvertices]) 40 49 md = checkfield(md,'fieldname','geometry.base' ,'NaN',1,'size',[md.mesh.numberofvertices]) 41 md = checkfield(md,'fieldname','geometry.thickness','NaN',1,'size',[md.mesh.numberofvertices],'>',0,' forcing',1)50 md = checkfield(md,'fieldname','geometry.thickness','NaN',1,'size',[md.mesh.numberofvertices],'>',0,'timeseries',1) 42 51 if any((self.thickness-self.surface+self.base)>10**-9): 43 52 md.checkmessage("equality thickness=surface-base violated") … … 49 58 def marshall(self,md,fid): # {{{ 50 59 WriteData(fid,'data',self.surface,'format','DoubleMat','mattype',1,'enum',SurfaceEnum()) 51 WriteData(fid,'data',self.thickness,'format','DoubleMat','mattype',1,'enum',ThicknessEnum(),' forcinglength',md.mesh.numberofvertices+1)60 WriteData(fid,'data',self.thickness,'format','DoubleMat','mattype',1,'enum',ThicknessEnum(),'timeserieslength',md.mesh.numberofvertices+1) 52 61 WriteData(fid,'data',self.base,'format','DoubleMat','mattype',1,'enum',BaseEnum()) 53 62 WriteData(fid,'data',self.bed,'format','DoubleMat','mattype',1,'enum',BedEnum()) -
issm/trunk/src/m/classes/gia.m
r17989 r19105 11 11 end 12 12 methods 13 function createxml(obj,fid) % {{{ 14 fprintf(fid, '<!-- gia -->\n'); 15 16 % gia solution parameters 17 fprintf(fid,'%s\n%s\n%s\n','<frame key="1" label="gia parameters">','<section name="gia" />'); 18 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="mantle_viscosity" type="',class(obj.mantle_viscosity),'" default="',convert2str(obj.mantle_viscosity),'">',' <section name="gia" />',' <help> mantle viscosity[Pa s] </help>',' </parameter>'); 19 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="lithosphere_thickness" type="',class(obj.lithosphere_thickness),'" default="',convert2str(obj.lithosphere_thickness),'">',' <section name="gia" />',' <help> lithosphere thickness (km) </help>',' </parameter>'); 20 %cross_section_shape drop-down (1 o r 2) 21 fprintf(fid,'%s\n%s\n%s\n%s\n',' <parameter key ="cross_section_shape" type="alternative" optional="false">',' <section name="gia" />',' <help> 1: square-edged (default). 2: elliptical. See iedge in GiaDeflectionCore </help>'); 22 fprintf(fid,'%s\n',' <option value="1" type="string" default="true"> </option>'); 23 fprintf(fid,'%s\n%s\n',' <option value="2" type="string" default="false"> </option>','</parameter>'); 24 25 fprintf(fid,'%s\n%s\n','</frame>'); 26 27 end % }}} 28 function obj = gia(varargin) % {{{ 13 function createxml(self,fid) % {{{ 14 fprintf(fid, '<!-- gia -->\n'); 15 16 % gia solution parameters 17 fprintf(fid,'%s\n%s\n%s\n','<frame key="1" label="gia parameters">','<section name="gia" />'); 18 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="mantle_viscosity" type="',class(self.mantle_viscosity),'" default="',convert2str(self.mantle_viscosity),'">',' <section name="gia" />',' <help> mantle viscosity[Pa s] </help>',' </parameter>'); 19 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="lithosphere_thickness" type="',class(self.lithosphere_thickness),'" default="',convert2str(self.lithosphere_thickness),'">',' <section name="gia" />',' <help> lithosphere thickness (km) </help>',' </parameter>'); 20 %cross_section_shape drop-down (1 o r 2) 21 fprintf(fid,'%s\n%s\n%s\n%s\n',' <parameter key ="cross_section_shape" type="alternative" optional="false">',' <section name="gia" />',' <help> 1: square-edged (default). 2: elliptical. See iedge in GiaDeflectionCore </help>'); 22 fprintf(fid,'%s\n',' <option value="1" type="string" default="true"> </option>'); 23 fprintf(fid,'%s\n%s\n',' <option value="2" type="string" default="false"> </option>','</parameter>'); 24 25 fprintf(fid,'%s\n%s\n','</frame>'); 26 27 end % }}} 28 function self = extrude(self,md) % {{{ 29 self.mantle_viscosity=project3d(md,'vector',self.mantle_viscosity,'type','node'); 30 self.lithosphere_thickness=project3d(md,'vector',self.lithosphere_thickness,'type','node'); 31 end % }}} 32 function self = gia(varargin) % {{{ 29 33 switch nargin 30 34 case 0 31 obj=setdefaultparameters(obj);35 self=setdefaultparameters(self); 32 36 otherwise 33 37 error('constructor not supported'); 34 38 end 35 39 end % }}} 36 function obj = setdefaultparameters(obj) % {{{37 obj.cross_section_shape=1; %square as default (see iedge in GiaDeflectionCorex)40 function self = setdefaultparameters(self) % {{{ 41 self.cross_section_shape=1; %square as default (see iedge in GiaDeflectionCorex) 38 42 end % }}} 39 function md = checkconsistency( obj,md,solution,analyses) % {{{43 function md = checkconsistency(self,md,solution,analyses) % {{{ 40 44 41 45 if ~ismember(GiaAnalysisEnum(),analyses), return; end … … 60 64 61 65 end % }}} 62 function disp( obj) % {{{66 function disp(self) % {{{ 63 67 disp(sprintf(' gia parameters:')); 64 68 65 fielddisplay( obj,'mantle_viscosity','mantle viscosity[Pa s]');66 fielddisplay( obj,'lithosphere_thickness','lithosphere thickness (km)');67 fielddisplay( obj,'cross_section_shape','1: square-edged (default). 2: elliptical. See iedge in GiaDeflectionCore');69 fielddisplay(self,'mantle_viscosity','mantle viscosity[Pa s]'); 70 fielddisplay(self,'lithosphere_thickness','lithosphere thickness (km)'); 71 fielddisplay(self,'cross_section_shape','1: square-edged (default). 2: elliptical. See iedge in GiaDeflectionCore'); 68 72 69 73 end % }}} 70 function marshall( obj,md,fid) % {{{71 WriteData(fid,'object', obj,'fieldname','mantle_viscosity','format','DoubleMat','mattype',1);72 WriteData(fid,'object', obj,'fieldname','lithosphere_thickness','format','DoubleMat','mattype',1,'scale',10^3); %from km to m73 WriteData(fid,'object', obj,'fieldname','cross_section_shape','format','Integer');74 function marshall(self,md,fid) % {{{ 75 WriteData(fid,'object',self,'fieldname','mantle_viscosity','format','DoubleMat','mattype',1); 76 WriteData(fid,'object',self,'fieldname','lithosphere_thickness','format','DoubleMat','mattype',1,'scale',10^3); %from km to m 77 WriteData(fid,'object',self,'fieldname','cross_section_shape','format','Integer'); 74 78 end % }}} 75 79 end -
issm/trunk/src/m/classes/gia.py
r17806 r19105 1 1 from fielddisplay import fielddisplay 2 from project3d import project3d 2 3 from EnumDefinitions import * 3 4 from checkfield import checkfield … … 30 31 return string 31 32 #}}} 33 def extrude(self,md): # {{{ 34 self.mantle_viscosity=project3d(md,'vector',self.mantle_viscosity,'type','node') 35 self.lithosphere_thickness=project3d(md,'vector',self.lithosphere_thickness,'type','node') 36 return self 37 #}}} 32 38 def setdefaultparameters(self): # {{{ 33 39 -
issm/trunk/src/m/classes/groundingline.m
r18301 r19105 9 9 end 10 10 methods 11 function createxml(obj,fid) % {{{ 12 fprintf(fid, '\n\n'); 13 fprintf(fid, '%s\n', '<!-- groundingline -->'); 14 15 % Convergence criteria 16 fprintf(fid,'%s\n%s\n%s\n','<frame key="1" label="Grounding line migration parameters">','<section name="groundingline" />'); 17 18 % migration (SoftMigration, AggressiveMigration, or None)drop-down 19 fprintf(fid,'%s\n%s\n%s\n%s\n','<parameter key ="migration" type="alternative" optional="false">',' <section name="groundingline" />',' <help> type of grounding line migration: "SoftMigration","AggressiveMigration" or "None" </help>'); 20 fprintf(fid,'%s\n',' <option value="SoftMigration" type="string" default="true"> </option>'); 21 fprintf(fid,'%s\n',' <option value="AggressiveMigration" type="string" default="false"> </option>'); 22 fprintf(fid, '%s\n%s\n',' <option value="None" type="string" default="false"></option>','</parameter>'); 11 function createxml(self,fid) % {{{ 12 fprintf(fid, '\n\n'); 13 fprintf(fid, '%s\n', '<!-- groundingline -->'); 23 14 24 fprintf(fid,'%s\n%s\n','</frame>'); 25 end % }}} 26 function obj = groundingline(varargin) % {{{ 15 % Convergence criteria 16 fprintf(fid,'%s\n%s\n%s\n','<frame key="1" label="Grounding line migration parameters">','<section name="groundingline" />'); 17 18 % migration (SoftMigration, AggressiveMigration, or None)drop-down 19 fprintf(fid,'%s\n%s\n%s\n%s\n','<parameter key ="migration" type="alternative" optional="false">',' <section name="groundingline" />',' <help> type of grounding line migration: "SoftMigration","AggressiveMigration" or "None" </help>'); 20 fprintf(fid,'%s\n',' <option value="SoftMigration" type="string" default="true"> </option>'); 21 fprintf(fid,'%s\n',' <option value="AggressiveMigration" type="string" default="false"> </option>'); 22 fprintf(fid, '%s\n%s\n',' <option value="None" type="string" default="false"></option>','</parameter>'); 23 24 fprintf(fid,'%s\n%s\n','</frame>'); 25 end % }}} 26 function self = groundingline(varargin) % {{{ 27 27 switch nargin 28 28 case 0 29 obj=setdefaultparameters(obj);29 self=setdefaultparameters(self); 30 30 otherwise 31 31 error('constructor not supported'); 32 32 end 33 33 end % }}} 34 function obj = setdefaultparameters(obj) % {{{34 function self = setdefaultparameters(self) % {{{ 35 35 36 36 %Type of migration 37 obj.migration='None';37 self.migration='None'; 38 38 39 39 end % }}} 40 function md = checkconsistency( obj,md,solution,analyses) % {{{40 function md = checkconsistency(self,md,solution,analyses) % {{{ 41 41 42 md = checkfield(md,'fieldname','groundingline.migration','values',{'None' 'AggressiveMigration' 'SoftMigration' 'SubelementMigration' 'SubelementMigration2' 'Contact' 'None' });42 md = checkfield(md,'fieldname','groundingline.migration','values',{'None' 'AggressiveMigration' 'SoftMigration' 'SubelementMigration' 'SubelementMigration2' 'Contact' 'None' 'GroundingOnly'}); 43 43 44 if ~strcmp( obj.migration,'None'),44 if ~strcmp(self.migration,'None'), 45 45 if isnan(md.geometry.bed), 46 46 md = checkmessage(md,['requesting grounding line migration, but bathymetry is absent!']); … … 48 48 pos=find(md.mask.groundedice_levelset>0.); 49 49 if any(abs(md.geometry.base(pos)-md.geometry.bed(pos))>10^-10), 50 md = checkmessage(md,['ba thymetrynot equal to bed on grounded ice!']);50 md = checkmessage(md,['base not equal to bed on grounded ice!']); 51 51 end 52 52 if any(md.geometry.bed - md.geometry.base > 10^-9), 53 md = checkmessage(md,['b athymetry superior to bedon floating ice!']);53 md = checkmessage(md,['bed superior to base on floating ice!']); 54 54 end 55 55 end 56 56 57 57 end % }}} 58 function disp( obj) % {{{58 function disp(self) % {{{ 59 59 disp(sprintf(' grounding line migration parameters:')); 60 fielddisplay( obj,'migration','type of grounding line migration: ''SoftMigration'',''AggressiveMigration'' or ''None''');60 fielddisplay(self,'migration','type of grounding line migration: ''SoftMigration'',''AggressiveMigration'',''SubelementMigration'',''SubelementMigration2'' or ''None'''); 61 61 62 62 end % }}} 63 function marshall( obj,md,fid) % {{{64 WriteData(fid,'data',StringToEnum( obj.migration),'enum',GroundinglineMigrationEnum(),'format','Integer');63 function marshall(self,md,fid) % {{{ 64 WriteData(fid,'data',StringToEnum(self.migration),'enum',GroundinglineMigrationEnum(),'format','Integer'); 65 65 end % }}} 66 66 end -
issm/trunk/src/m/classes/groundingline.py
r18301 r19105 37 37 def checkconsistency(self,md,solution,analyses): # {{{ 38 38 39 md = checkfield(md,'fieldname','groundingline.migration','values',['None','AggressiveMigration','SoftMigration','SubelementMigration','SubelementMigration2','Contact' ])39 md = checkfield(md,'fieldname','groundingline.migration','values',['None','AggressiveMigration','SoftMigration','SubelementMigration','SubelementMigration2','Contact','GroundingOnly']) 40 40 41 41 if not m.strcmp(self.migration,'None'): … … 44 44 pos=numpy.nonzero(md.mask.groundedice_levelset>0.)[0] 45 45 if any(numpy.abs(md.geometry.base[pos]-md.geometry.bed[pos])>10**-10): 46 md.checkmessage("ba thymetrynot equal to bed on grounded ice!")46 md.checkmessage("base not equal to bed on grounded ice!") 47 47 if any(md.geometry.bed - md.geometry.base > 10**-9): 48 md.checkmessage("b athymetry superior to bedon floating ice!")48 md.checkmessage("bed superior to base on floating ice!") 49 49 50 50 return md -
issm/trunk/src/m/classes/hydrologydc.m
r17806 r19105 30 30 epl_porosity = 0; 31 31 epl_initial_thickness = 0; 32 epl_max_thickness = 0; 32 epl_colapse_thickness = 0; 33 epl_thick_comp = 0; 34 epl_max_thickness = 0; 33 35 epl_conductivity = 0; 36 eplflip_lock = 0; 34 37 end 35 38 methods 36 % {{{ function obj = hydrologydc(varargin) 37 function obj = hydrologydc(varargin) 39 function self = extrude(self,md) % {{{ 40 self.spcsediment_head=project3d(md,'vector',self.spcsediment_head,'type','node','layer',1); 41 self.mask_eplactive_node=project3d(md,'vector',self.mask_eplactive_node,'type','node','layer',1); 42 self.sediment_transmitivity=project3d(md,'vector',self.sediment_transmitivity,'type','node','layer',1); 43 self.basal_moulin_input=project3d(md,'vector',self.basal_moulin_input,'type','node','layer',1); 44 if(self.isefficientlayer==1); 45 self.spcepl_head=project3d(md,'vector',self.spcepl_head,'type','node','layer',1); 46 end 47 end % }}} 48 % {{{ function self = hydrologydc(varargin) 49 function self = hydrologydc(varargin) 38 50 switch nargin 39 51 case 0 40 obj=setdefaultparameters(obj);52 self=setdefaultparameters(self); 41 53 otherwise 42 54 error('constructor not supported'); 43 55 end 44 56 end 45 57 % }}} … … 51 63 52 64 end % }}} 53 % {{{ function obj = setdefaultparameters(obj) 54 function obj = setdefaultparameters(obj) 55 56 %Parameters from de Fleurian 2014 57 obj.water_compressibility = 5.04e-10; 58 obj.isefficientlayer = 1; 59 obj.penalty_factor = 3; 60 obj.rel_tol = 1.0e-06; 61 obj.max_iter = 100; 62 obj.sedimentlimit_flag = 0; 63 obj.sedimentlimit = 0; 64 obj.transfer_flag = 0; 65 obj.leakage_factor = 10.0; 66 67 obj.sediment_compressibility = 1.0e-08; 68 obj.sediment_porosity = 0.4; 69 obj.sediment_thickness = 20.0; 70 obj.sediment_transmitivity = 8.0e-04; 71 72 obj.epl_compressibility = 1.0e-08; 73 obj.epl_porosity = 0.4; 74 obj.epl_initial_thickness = 1.0; 75 obj.epl_max_thickness = 5.0; 76 obj.epl_conductivity = 8.0e-02; 77 78 end 79 % }}} 80 % {{{ function md = checkconsistency(obj,md,solution,analyses) 81 function md = checkconsistency(obj,md,solution,analyses) 82 %Early return 65 % {{{ function self = setdefaultparameters(self) 66 function self = setdefaultparameters(self) 67 68 %Parameters from de Fleurian 2014 69 self.water_compressibility = 5.04e-10; 70 self.isefficientlayer = 1; 71 self.penalty_factor = 3; 72 self.penalty_lock = 0; 73 self.rel_tol = 1.0e-06; 74 self.max_iter = 100; 75 self.sedimentlimit_flag = 0; 76 self.sedimentlimit = 0; 77 self.transfer_flag = 0; 78 self.leakage_factor = 10.0; 79 80 self.sediment_compressibility = 1.0e-08; 81 self.sediment_porosity = 0.4; 82 self.sediment_thickness = 20.0; 83 self.sediment_transmitivity = 8.0e-04; 84 85 self.epl_compressibility = 1.0e-08; 86 self.epl_porosity = 0.4; 87 self.epl_initial_thickness = 1.0; 88 self.epl_colapse_thickness = 1.0e-3; 89 self.epl_thick_comp = 1; 90 self.epl_max_thickness = 5.0; 91 self.epl_conductivity = 8.0e-02; 92 self.eplflip_lock = 0; 93 end 94 % }}} 95 % {{{ function md = checkconsistency(self,md,solution,analyses) 96 function md = checkconsistency(self,md,solution,analyses) 97 %Early return 83 98 if ~ismember(HydrologyDCInefficientAnalysisEnum(),analyses) & ~ismember(HydrologyDCEfficientAnalysisEnum(),analyses), 84 99 return; … … 88 103 md = checkfield(md,'fieldname','hydrology.isefficientlayer','numel',[1],'values',[0 1]); 89 104 md = checkfield(md,'fieldname','hydrology.penalty_factor','>',0,'numel',1); 105 md = checkfield(md,'fieldname','hydrology.penalty_lock','>=',0,'numel',1); 90 106 md = checkfield(md,'fieldname','hydrology.rel_tol','>',0,'numel',1); 91 107 md = checkfield(md,'fieldname','hydrology.max_iter','>',0,'numel',1); 92 108 md = checkfield(md,'fieldname','hydrology.sedimentlimit_flag','numel',[1],'values',[0 1 2 3]); 93 109 md = checkfield(md,'fieldname','hydrology.transfer_flag','numel',[1],'values',[0 1]); 94 if obj.sedimentlimit_flag==1,110 if self.sedimentlimit_flag==1, 95 111 md = checkfield(md,'fieldname','hydrology.sedimentlimit','>',0,'numel',1); 96 97 if obj.transfer_flag==1,112 end 113 if self.transfer_flag==1, 98 114 md = checkfield(md,'fieldname','hydrology.leakage_factor','>',0,'numel',1); 99 100 md = checkfield(md,'fieldname','hydrology.basal_moulin_input','NaN',1,' forcing',1);101 102 md = checkfield(md,'fieldname','hydrology.spcsediment_head',' forcing',1);115 end 116 md = checkfield(md,'fieldname','hydrology.basal_moulin_input','NaN',1,'timeseries',1); 117 118 md = checkfield(md,'fieldname','hydrology.spcsediment_head','timeseries',1); 103 119 md = checkfield(md,'fieldname','hydrology.sediment_compressibility','>',0,'numel',1); 104 120 md = checkfield(md,'fieldname','hydrology.sediment_porosity','>',0,'numel',1); … … 106 122 md = checkfield(md,'fieldname','hydrology.sediment_transmitivity','>=',0,'size',[md.mesh.numberofvertices 1]); 107 123 108 if obj.isefficientlayer==1,109 md = checkfield(md,'fieldname','hydrology.spcepl_head',' forcing',1);124 if self.isefficientlayer==1, 125 md = checkfield(md,'fieldname','hydrology.spcepl_head','timeseries',1); 110 126 md = checkfield(md,'fieldname','hydrology.mask_eplactive_node','size',[md.mesh.numberofvertices 1],'values',[0 1]); 111 127 md = checkfield(md,'fieldname','hydrology.epl_compressibility','>',0,'numel',1); 112 128 md = checkfield(md,'fieldname','hydrology.epl_porosity','>',0,'numel',1); 113 129 md = checkfield(md,'fieldname','hydrology.epl_initial_thickness','>',0,'numel',1); 130 md = checkfield(md,'fieldname','hydrology.epl_colapse_thickness','>',0,'numel',1); 131 md = checkfield(md,'fieldname','hydrology.epl_thick_comp','numel',[1],'values',[0 1]); 114 132 md = checkfield(md,'fieldname','hydrology.epl_max_thickness','>',0,'numel',1); 115 133 md = checkfield(md,'fieldname','hydrology.epl_conductivity','>',0,'numel',1); 116 end 117 end 118 % }}} 119 % {{{ function disp(obj) 120 function disp(obj) 134 md = checkfield(md,'fieldname','hydrology.eplflip_lock','>=',0,'numel',1); 135 if (self.epl_colapse_thickness>self.epl_initial_thickness), 136 md = checkmessage(md,'Colapsing thickness for EPL larger than initial thickness'); 137 end 138 end 139 end 140 % }}} 141 % {{{ function disp(self) 142 function disp(self) 121 143 disp(sprintf(' hydrology Dual Porous Continuum Equivalent parameters:')); 122 144 disp(sprintf(' - general parameters')); 123 fielddisplay( obj,'water_compressibility','compressibility of water [Pa^-1]');124 fielddisplay( obj,'isefficientlayer','do we use an efficient drainage system [1: true; 0: false]');125 fielddisplay( obj,'penalty_factor','exponent of the value used in the penalisation method [dimensionless]');126 fielddisplay( obj,'penalty_lock','stabilize unstable constraints that keep zigzagging after n iteration (default is 0, no stabilization)');127 fielddisplay( obj,'rel_tol','tolerance of the nonlinear iteration for the transfer between layers [dimensionless]');128 fielddisplay( obj,'max_iter','maximum number of nonlinear iteration');129 fielddisplay( obj,'sedimentlimit_flag','what kind of upper limit is applied for the inefficient layer');145 fielddisplay(self,'water_compressibility','compressibility of water [Pa^-1]'); 146 fielddisplay(self,'isefficientlayer','do we use an efficient drainage system [1: true; 0: false]'); 147 fielddisplay(self,'penalty_factor','exponent of the value used in the penalisation method [dimensionless]'); 148 fielddisplay(self,'penalty_lock','stabilize unstable constraints that keep zigzagging after n iteration (default is 0, no stabilization)'); 149 fielddisplay(self,'rel_tol','tolerance of the nonlinear iteration for the transfer between layers [dimensionless]'); 150 fielddisplay(self,'max_iter','maximum number of nonlinear iteration'); 151 fielddisplay(self,'sedimentlimit_flag','what kind of upper limit is applied for the inefficient layer'); 130 152 disp(sprintf('%55s 0: no limit',' ')); 131 153 disp(sprintf('%55s 1: user defined: %s',' ','sedimentlimit')); 132 154 disp(sprintf('%55s 2: hydrostatic pressure',' ')); 133 155 disp(sprintf('%55s 3: normal stress',' ')); 134 if obj.sedimentlimit_flag==1,135 fielddisplay( obj,'sedimentlimit','user defined upper limit for the inefficient layer [m]');136 137 fielddisplay( obj,'transfer_flag',['what kind of transfer method is applied between the layers']);156 if self.sedimentlimit_flag==1, 157 fielddisplay(self,'sedimentlimit','user defined upper limit for the inefficient layer [m]'); 158 end 159 fielddisplay(self,'transfer_flag',['what kind of transfer method is applied between the layers']); 138 160 disp(sprintf('%55s 0: no transfer',' ')); 139 161 disp(sprintf('%55s 1: constant leakage factor: %s',' ','leakage_factor')); 140 if obj.transfer_flag==1,141 fielddisplay( obj,'leakage_factor','user defined leakage factor [m]');142 143 fielddisplay( obj,'basal_moulin_input','Figure out what it is');162 if self.transfer_flag==1, 163 fielddisplay(self,'leakage_factor','user defined leakage factor [m]'); 164 end 165 fielddisplay(self,'basal_moulin_input','water flux at a given point [m3 s-1]'); 144 166 disp(sprintf(' - for the sediment layer')); 145 fielddisplay( obj,'spcsediment_head','sediment water head constraints (NaN means no constraint) [m above MSL]');146 fielddisplay( obj,'sediment_compressibility','sediment compressibility [Pa^-1]');147 fielddisplay( obj,'sediment_porosity','sediment [dimensionless]');148 fielddisplay( obj,'sediment_thickness','sediment thickness [m]');149 fielddisplay( obj,'sediment_transmitivity','sediment transmitivity [m^2/s]');150 151 if obj.isefficientlayer==1,167 fielddisplay(self,'spcsediment_head','sediment water head constraints (NaN means no constraint) [m above MSL]'); 168 fielddisplay(self,'sediment_compressibility','sediment compressibility [Pa^-1]'); 169 fielddisplay(self,'sediment_porosity','sediment [dimensionless]'); 170 fielddisplay(self,'sediment_thickness','sediment thickness [m]'); 171 fielddisplay(self,'sediment_transmitivity','sediment transmitivity [m^2/s]'); 172 173 if self.isefficientlayer==1, 152 174 disp(sprintf(' - for the epl layer')); 153 fielddisplay(obj,'spcepl_head','epl water head constraints (NaN means no constraint) [m above MSL]'); 154 fielddisplay(obj,'mask_eplactive_node','active (1) or not (0) EPL'); 155 fielddisplay(obj,'epl_compressibility','epl compressibility [Pa^-1]'); 156 fielddisplay(obj,'epl_porosity','epl [dimensionless]'); 157 fielddisplay(obj,'epl_initial_thickness','epl initial thickness [m]'); 158 fielddisplay(obj,'epl_max_thickness','epl maximal thickness [m]'); 159 fielddisplay(obj,'epl_conductivity','epl conductivity [m^2/s]'); 160 end 161 162 end 163 % }}} 164 % {{{ function marshall(obj,md,fid) 165 function marshall(obj,md,fid) 175 fielddisplay(self,'spcepl_head','epl water head constraints (NaN means no constraint) [m above MSL]'); 176 fielddisplay(self,'mask_eplactive_node','active (1) or not (0) EPL'); 177 fielddisplay(self,'epl_compressibility','epl compressibility [Pa^-1]'); 178 fielddisplay(self,'epl_porosity','epl [dimensionless]'); 179 fielddisplay(self,'epl_initial_thickness','epl initial thickness [m]'); 180 fielddisplay(self,'epl_colapse_thickness','epl colapsing thickness [m]'); 181 fielddisplay(self,'epl_thick_comp','epl thickness computation flag'); 182 fielddisplay(self,'epl_max_thickness','epl maximal thickness [m]'); 183 fielddisplay(self,'epl_conductivity','epl conductivity [m^2/s]'); 184 fielddisplay(self,'eplflip_lock','lock the epl activation to avoid fli-floping (default is 0, no stabilization)'); 185 end 186 187 end 188 % }}} 189 % {{{ function marshall(self,md,fid) 190 function marshall(self,md,fid) 166 191 WriteData(fid,'enum',HydrologyModelEnum(),'data',HydrologydcEnum(),'format','Integer'); 167 WriteData(fid,'object',obj,'fieldname','water_compressibility','format','Double'); 168 WriteData(fid,'object',obj,'fieldname','isefficientlayer','format','Boolean'); 169 WriteData(fid,'object',obj,'fieldname','penalty_factor','format','Double'); 170 WriteData(fid,'object',obj,'fieldname','penalty_lock','format','Integer'); 171 WriteData(fid,'object',obj,'fieldname','rel_tol','format','Double'); 172 WriteData(fid,'object',obj,'fieldname','max_iter','format','Integer'); 173 WriteData(fid,'object',obj,'fieldname','sedimentlimit_flag','format','Integer'); 174 WriteData(fid,'object',obj,'fieldname','transfer_flag','format','Integer'); 175 if obj.sedimentlimit_flag==1, 176 WriteData(fid,'object',obj,'fieldname','sedimentlimit','format','Double'); 177 end 178 if obj.transfer_flag==1, 179 WriteData(fid,'object',obj,'fieldname','leakage_factor','format','Double'); 180 end 181 WriteData(fid,'object',obj,'fieldname','basal_moulin_input','format','DoubleMat','mattype',1,'forcinglength',md.mesh.numberofvertices+1) 182 183 WriteData(fid,'object',obj,'fieldname','spcsediment_head','format','DoubleMat','mattype',1,'forcinglength',md.mesh.numberofvertices+1); 184 WriteData(fid,'object',obj,'fieldname','sediment_compressibility','format','Double'); 185 WriteData(fid,'object',obj,'fieldname','sediment_porosity','format','Double'); 186 WriteData(fid,'object',obj,'fieldname','sediment_thickness','format','Double'); 187 WriteData(fid,'object',obj,'fieldname','sediment_transmitivity','format','DoubleMat','mattype',1'); 188 189 if obj.isefficientlayer==1, 190 WriteData(fid,'object',obj,'fieldname','spcepl_head','format','DoubleMat','mattype',1,'forcinglength',md.mesh.numberofvertices+1); 191 WriteData(fid,'object',obj,'fieldname','mask_eplactive_node','format','DoubleMat','mattype',1); 192 WriteData(fid,'object',obj,'fieldname','epl_compressibility','format','Double'); 193 WriteData(fid,'object',obj,'fieldname','epl_porosity','format','Double'); 194 WriteData(fid,'object',obj,'fieldname','epl_initial_thickness','format','Double'); 195 WriteData(fid,'object',obj,'fieldname','epl_max_thickness','format','Double'); 196 WriteData(fid,'object',obj,'fieldname','epl_conductivity','format','Double'); 197 end 198 end 199 % }}} 200 end 192 WriteData(fid,'object',self,'fieldname','water_compressibility','format','Double'); 193 WriteData(fid,'object',self,'fieldname','isefficientlayer','format','Boolean'); 194 WriteData(fid,'object',self,'fieldname','penalty_factor','format','Double'); 195 WriteData(fid,'object',self,'fieldname','penalty_lock','format','Integer'); 196 WriteData(fid,'object',self,'fieldname','rel_tol','format','Double'); 197 WriteData(fid,'object',self,'fieldname','max_iter','format','Integer'); 198 WriteData(fid,'object',self,'fieldname','sedimentlimit_flag','format','Integer'); 199 WriteData(fid,'object',self,'fieldname','transfer_flag','format','Integer'); 200 if self.sedimentlimit_flag==1, 201 WriteData(fid,'object',self,'fieldname','sedimentlimit','format','Double'); 202 end 203 if self.transfer_flag==1, 204 WriteData(fid,'object',self,'fieldname','leakage_factor','format','Double'); 205 end 206 WriteData(fid,'object',self,'fieldname','basal_moulin_input','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1) 207 208 WriteData(fid,'object',self,'fieldname','spcsediment_head','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1); 209 WriteData(fid,'object',self,'fieldname','sediment_compressibility','format','Double'); 210 WriteData(fid,'object',self,'fieldname','sediment_porosity','format','Double'); 211 WriteData(fid,'object',self,'fieldname','sediment_thickness','format','Double'); 212 WriteData(fid,'object',self,'fieldname','sediment_transmitivity','format','DoubleMat','mattype',1'); 213 214 if self.isefficientlayer==1, 215 WriteData(fid,'object',self,'fieldname','spcepl_head','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1); 216 WriteData(fid,'object',self,'fieldname','mask_eplactive_node','format','DoubleMat','mattype',1); 217 WriteData(fid,'object',self,'fieldname','epl_compressibility','format','Double'); 218 WriteData(fid,'object',self,'fieldname','epl_porosity','format','Double'); 219 WriteData(fid,'object',self,'fieldname','epl_initial_thickness','format','Double'); 220 WriteData(fid,'object',self,'fieldname','epl_colapse_thickness','format','Double'); 221 WriteData(fid,'object',self,'fieldname','epl_thick_comp','format','Integer'); 222 WriteData(fid,'object',self,'fieldname','epl_max_thickness','format','Double'); 223 WriteData(fid,'object',self,'fieldname','epl_conductivity','format','Double'); 224 WriteData(fid,'object',self,'fieldname','eplflip_lock','format','Integer'); 225 end 226 end 227 % }}} 228 end 201 229 end -
issm/trunk/src/m/classes/hydrologydc.py
r17806 r19105 1 import numpy 2 from project3d import project3d 1 3 from fielddisplay import fielddisplay 2 4 from EnumDefinitions import * … … 5 7 6 8 class hydrologydc(object): 7 8 9 10 11 12 13 14 9 """ 10 Hydrologydc class definition 11 12 Usage: 13 hydrologydc=hydrologydc(); 14 """ 15 16 def __init__(self): # {{{ 15 17 self.water_compressibility = 0 16 18 self.isefficientlayer = 0 … … 23 25 self.transfer_flag = 0 24 26 self.leakage_factor = 0 27 self.basal_moulin_input = float('NaN') 25 28 26 29 self.spcsediment_head = float('NaN') … … 36 39 self.epl_porosity = 0 37 40 self.epl_initial_thickness = 0 41 self.epl_colapse_thickness = 0 42 self.epl_thick_comp = 0 43 self.epl_max_thickness = 0 38 44 self.epl_conductivity = 0 39 45 self.eplflip_lock = 0 46 40 47 #set defaults 41 48 self.setdefaultparameters() 42 #}}} 43 49 #}}} 44 50 def __repr__(self): # {{{ 45 string=' hydrology Dual Porous Continuum Equivalent parameters:' 46 string=' - general parameters' 47 string="%s\n%s"%(string,fielddisplay(self,'water_compressibility','compressibility of water [Pa^-1]')) 48 string="%s\n%s"%(string,fielddisplay(self,'isefficientlayer','do we use an efficient drainage system [1: true 0: false]')) 49 string="%s\n%s"%(string,fielddisplay(self,'penalty_factor','exponent of the value used in the penalisation method [dimensionless]')) 50 string="%s\n%s"%(string,fielddisplay(self,'penalty_lock','stabilize unstable constraints that keep zigzagging after n iteration (default is 0, no stabilization)')) 51 string="%s\n%s"%(string,fielddisplay(self,'rel_tol','tolerance of the nonlinear iteration for the transfer between layers [dimensionless]')) 52 string="%s\n%s"%(string,fielddisplay(self,'max_iter','maximum number of nonlinear iteration')) 53 string="%s\n%s"%(string,fielddisplay(self,'sedimentlimit_flag','what kind of upper limit is applied for the inefficient layer')) 54 string='%55s 0: no limit',' ' 55 string='%55s 1: user defined: %s',' ','sedimentlimit' 56 string='%55s 2: hydrostatic pressure',' ' 57 string='%55s 3: normal stress',' ' 58 59 if self.sedimentlimit_flag==1: 60 string="%s\n%s"%(string,fielddisplay(self,'sedimentlimit','user defined upper limit for the inefficient layer [m]')) 61 string="%s\n%s"%(string,fielddisplay(self,'transfer_flag',['what kind of transfer method is applied between the layers'])) 62 string='%55s 0: no transfer',' ' 63 string='%55s 1: constant leakage factor: %s',' ','leakage_factor' 64 65 if self.transfer_flag is 1: 66 string="%s\n%s"%(string,fielddisplay(self,'leakage_factor','user defined leakage factor [m]')) 67 string=' - for the sediment layer' 68 string="%s\n%s"%(string,fielddisplay(self,'spcsediment_head','sediment water head constraints (NaN means no constraint) [m above MSL]')) 69 string="%s\n%s"%(string,fielddisplay(self,'sediment_compressibility','sediment compressibility [Pa^-1]')) 70 string="%s\n%s"%(string,fielddisplay(self,'sediment_porosity','sediment [dimensionless]')) 71 string="%s\n%s"%(string,fielddisplay(self,'sediment_thickness','sediment thickness [m]')) 72 string="%s\n%s"%(string,fielddisplay(self,'sediment_transmitivity','sediment transmitivity [m^2/s]')) 73 74 if self.isefficientlayer==1: 75 string=' - for the epl layer' 76 string="%s\n%s"%(string,fielddisplay(self,'spcepl_head','epl water head constraints (NaN means no constraint) [m above MSL]')) 77 string="%s\n%s"%(string,fielddisplay(self,'mask_eplactive_node','active (1) or not (0) EPL')) 78 string="%s\n%s"%(string,fielddisplay(self,'epl_compressibility','epl compressibility [Pa^-1]')) 79 string="%s\n%s"%(string,fielddisplay(self,'epl_porosity','epl [dimensionless]')) 80 string="%s\n%s"%(string,fielddisplay(self,'epl_initial_thickness','epl initial thickness [m]')) 81 string="%s\n%s"%(string,fielddisplay(self,'epl_conductivity','epl conductivity [m^2/s]')) 82 83 #}}} 84 def setdefaultparameters(self): #{{{ 85 86 #Parameters from de Fleurian 2014 87 self.water_compressibility = 5.04e-10 88 self.isefficientlayer = 1 89 self.penalty_factor = 3 90 self.rel_tol = 1.0e-06 91 self.max_iter = 100 92 self.sedimentlimit_flag = 0 93 self.sedimentlimit = 0 94 self.transfer_flag = 0 95 self.leakage_factor = 10.0 96 97 self.sediment_compressibility = 1.0e-08 98 self.sediment_porosity = 0.4 99 self.sediment_thickness = 20.0 100 self.sediment_transmitivity = 8.0e-04 101 102 self.epl_compressibility = 1.0e-08 103 self.epl_porosity = 0.4 104 self.epl_initial_thickness = 1.0 105 self.epl_conductivity = 8.0e-02 106 107 return self 108 # }}} 109 110 def checkconsistency(self,md,solution,analyses): #{{{ 111 112 #Early return 113 if HydrologyDCInefficientAnalysisEnum() not in analyses: 114 return md 115 116 md = checkfield(md,'fieldname','hydrology.water_compressibility','>',0,'numel',1) 117 md = checkfield(md,'fieldname','hydrology.isefficientlayer','numel',[1],'values',[0 1]) 118 md = checkfield(md,'fieldname','hydrology.penalty_factor','>',0,'numel',1) 119 md = checkfield(md,'fieldname','hydrology.rel_tol','>',0,'numel',1) 120 md = checkfield(md,'fieldname','hydrology.max_iter','>',0,'numel',1) 121 md = checkfield(md,'fieldname','hydrology.sedimentlimit_flag','numel',[1],'values',[0 1 2 3]) 122 md = checkfield(md,'fieldname','hydrology.transfer_flag','numel',[1],'values',[0 1]) 123 124 if self.sedimentlimit_flag==1: 125 md = checkfield(md,'fieldname','hydrology.sedimentlimit','>',0,'numel',1) 126 127 if self.transfer_flag==1: 128 md = checkfield(md,'fieldname','hydrology.leakage_factor','>',0,'numel',1) 129 130 md = checkfield(md,'fieldname','hydrology.spcsediment_head','forcing',1) 131 md = checkfield(md,'fieldname','hydrology.sediment_compressibility','>',0,'numel',1) 132 md = checkfield(md,'fieldname','hydrology.sediment_porosity','>',0,'numel',1) 133 md = checkfield(md,'fieldname','hydrology.sediment_thickness','>',0,'numel',1) 134 md = checkfield(md,'fieldname','hydrology.sediment_transmitivity','>=',0,'size',[md.mesh.numberofvertices 1]) 135 if self.isefficientlayer==1: 136 md = checkfield(md,'fieldname','hydrology.spcepl_head','forcing',1) 137 md = checkfield(md,'fieldname','hydrology.mask_eplactive_node','size',[md.mesh.numberofvertices 1],'values',[0 1]) 138 md = checkfield(md,'fieldname','hydrology.epl_compressibility','>',0,'numel',1) 139 md = checkfield(md,'fieldname','hydrology.epl_porosity','>',0,'numel',1) 140 md = checkfield(md,'fieldname','hydrology.epl_initial_thickness','>',0,'numel',1) 141 md = checkfield(md,'fieldname','hydrology.epl_conductivity','>',0,'numel',1) 142 143 # }}} 144 def marshall(self,md,fid): #{{{ 145 WriteData(fid,'enum',HydrologyModelEnum(),'data',HydrologydcEnum(),'format','Integer') 146 WriteData(fid,'object',self,'fieldname','water_compressibility','format','Double') 147 WriteData(fid,'object',self,'fieldname','isefficientlayer','format','Boolean') 148 WriteData(fid,'object',self,'fieldname','penalty_factor','format','Double') 149 WriteData(fid,'object',self,'fieldname','penalty_lock','format','Integer') 150 WriteData(fid,'object',self,'fieldname','rel_tol','format','Double') 151 WriteData(fid,'object',self,'fieldname','max_iter','format','Integer') 152 WriteData(fid,'object',self,'fieldname','sedimentlimit_flag','format','Integer') 153 WriteData(fid,'object',self,'fieldname','transfer_flag','format','Integer') 154 155 if self.sedimentlimit_flag==1: 156 WriteData(fid,'object',self,'fieldname','sedimentlimit','format','Double') 157 158 if self.transfer_flag==1: 159 WriteData(fid,'object',self,'fieldname','leakage_factor','format','Double') 160 161 WriteData(fid,'object',self,'fieldname','spcsediment_head','format','DoubleMat','mattype',1,'forcinglength',md.mesh.numberofvertices+1) 162 WriteData(fid,'object',self,'fieldname','sediment_compressibility','format','Double') 163 WriteData(fid,'object',self,'fieldname','sediment_porosity','format','Double') 164 WriteData(fid,'object',self,'fieldname','sediment_thickness','format','Double') 165 WriteData(fid,'object',self,'fieldname','sediment_transmitivity','format','DoubleMat','mattype',1) 166 167 if self.isefficientlayer==1: 168 WriteData(fid,'object',self,'fieldname','spcepl_head','format','DoubleMat','mattype',1,'forcinglength',md.mesh.numberofvertices+1) 169 WriteData(fid,'object',self,'fieldname','mask_eplactive_node','format','DoubleMat','mattype',1) 170 WriteData(fid,'object',self,'fieldname','epl_compressibility','format','Double') 171 WriteData(fid,'object',self,'fieldname','epl_porosity','format','Double') 172 WriteData(fid,'object',self,'fieldname','epl_initial_thickness','format','Double') 173 WriteData(fid,'object',self,'fieldname','epl_conductivity','format','Double') 174 # }}} 175 51 string=' hydrology Dual Porous Continuum Equivalent parameters:' 52 string=' - general parameters' 53 string="%s\n%s"%(string,fielddisplay(self,'water_compressibility','compressibility of water [Pa^-1]')) 54 string="%s\n%s"%(string,fielddisplay(self,'isefficientlayer','do we use an efficient drainage system [1: true 0: false]')) 55 string="%s\n%s"%(string,fielddisplay(self,'penalty_factor','exponent of the value used in the penalisation method [dimensionless]')) 56 string="%s\n%s"%(string,fielddisplay(self,'penalty_lock','stabilize unstable constraints that keep zigzagging after n iteration (default is 0, no stabilization)')) 57 string="%s\n%s"%(string,fielddisplay(self,'rel_tol','tolerance of the nonlinear iteration for the transfer between layers [dimensionless]')) 58 string="%s\n%s"%(string,fielddisplay(self,'max_iter','maximum number of nonlinear iteration')) 59 string="%s\n%s"%(string,fielddisplay(self,'basal_moulin_input','water flux at a given point [m3 s-1]')) 60 string="%s\n%s"%(string,fielddisplay(self,'sedimentlimit_flag','what kind of upper limit is applied for the inefficient layer')) 61 string="%s\n\t\t%s"%(string,'0: no limit') 62 string="%s\n\t\t%s"%(string,'1: user defined sedimentlimit') 63 string="%s\n\t\t%s"%(string,'2: hydrostatic pressure') 64 string="%s\n\t\t%s"%(string,'3: normal stress') 65 66 if self.sedimentlimit_flag==1: 67 string="%s\n%s"%(string,fielddisplay(self,'sedimentlimit','user defined upper limit for the inefficient layer [m]')) 68 69 string="%s\n%s"%(string,fielddisplay(self,'transfer_flag','what kind of transfer method is applied between the layers')) 70 string="%s\n\t\t%s"%(string,'0: no transfer') 71 string="%s\n\t\t%s"%(string,'1: constant leakage factor: leakage_factor') 72 73 if self.transfer_flag is 1: 74 string="%s\n%s"%(string,fielddisplay(self,'leakage_factor','user defined leakage factor [m]')) 75 76 string="%s\n%s"%(string,' - for the sediment layer') 77 string="%s\n%s"%(string,fielddisplay(self,'spcsediment_head','sediment water head constraints (NaN means no constraint) [m above MSL]')) 78 string="%s\n%s"%(string,fielddisplay(self,'sediment_compressibility','sediment compressibility [Pa^-1]')) 79 string="%s\n%s"%(string,fielddisplay(self,'sediment_porosity','sediment [dimensionless]')) 80 string="%s\n%s"%(string,fielddisplay(self,'sediment_thickness','sediment thickness [m]')) 81 string="%s\n%s"%(string,fielddisplay(self,'sediment_transmitivity','sediment transmitivity [m^2/s]')) 82 83 if self.isefficientlayer==1: 84 string="%s\n%s"%(string,' - for the epl layer') 85 string="%s\n%s"%(string,fielddisplay(self,'spcepl_head','epl water head constraints (NaN means no constraint) [m above MSL]')) 86 string="%s\n%s"%(string,fielddisplay(self,'mask_eplactive_node','active (1) or not (0) EPL')) 87 string="%s\n%s"%(string,fielddisplay(self,'epl_compressibility','epl compressibility [Pa^-1]')) 88 string="%s\n%s"%(string,fielddisplay(self,'epl_porosity','epl [dimensionless]')) 89 string="%s\n%s"%(string,fielddisplay(self,'epl_max_thickness','epl initial thickness [m]')) 90 string="%s\n%s"%(string,fielddisplay(self,'epl_initial_thickness','epl initial thickness [m]')) 91 string="%s\n%s"%(string,fielddisplay(self,'epl_colapse_thickness','epl colapsing thickness [m]')) 92 string="%s\n%s"%(string,fielddisplay(self,'epl_thick_comp','epl thickness computation flag')) 93 string="%s\n%s"%(string,fielddisplay(self,'epl_conductivity','epl conductivity [m^2/s]')) 94 string="%s\n%s"%(string,fielddisplay(self,'eplflip_lock','lock epl activity to avoid flip-floping (default is 0, no stabilization)')) 95 return string 96 #}}} 97 def extrude(self,md): # {{{ 98 self.spcsediment_head=project3d(md,'vector',self.spcsediment_head,'type','node','layer',1) 99 self.spcepl_head=project3d(md,'vector',self.spcepl_head,'type','node','layer',1) 100 self.mask_eplactive_node=project3d(md,'vector',self.mask_eplactive_node,'type','node','layer',1) 101 self.sediment_transmitivity=project3d(md,'vector',self.sediment_transmitivity,'type','node','layer',1) 102 self.basal_moulin_input=project3d(md,'vector',self.basal_moulin_input,'type','node','layer',1) 103 if self.isefficientlayer==1 : 104 self.spcepl_head=project3d(md,'vector',self.spcepl_head,'type','node','layer',1) 105 return self 106 #}}} 107 def setdefaultparameters(self): #{{{ 108 109 #Parameters from de Fleurian 2014 110 self.water_compressibility = 5.04e-10 111 self.isefficientlayer = 1 112 self.penalty_factor = 3 113 self.penalty_lock = 0 114 self.rel_tol = 1.0e-06 115 self.max_iter = 100 116 self.sedimentlimit_flag = 0 117 self.sedimentlimit = 0 118 self.transfer_flag = 0 119 self.leakage_factor = 10.0 120 121 self.sediment_compressibility = 1.0e-08 122 self.sediment_porosity = 0.4 123 self.sediment_thickness = 20.0 124 self.sediment_transmitivity = 8.0e-04 125 126 self.epl_compressibility = 1.0e-08 127 self.epl_porosity = 0.4 128 self.epl_initial_thickness = 1.0 129 self.epl_colapse_thickness = 1.0e-3 130 self.epl_thick_comp = 1 131 self.epl_max_thickness = 5.0 132 self.epl_conductivity = 8.0e-02 133 self.eplflip_lock = 0 134 135 return self 136 # }}} 137 def initialize(self,md): # {{{ 138 if numpy.all(numpy.isnan(self.basal_moulin_input)): 139 self.basal_moulin_input=numpy.zeros((md.mesh.numberofvertices,1)) 140 print" no hydrology.basal_moulin_input specified: values set as zero" 141 142 return self 143 # }}} 144 def checkconsistency(self,md,solution,analyses): #{{{ 145 146 #Early return 147 if HydrologyDCInefficientAnalysisEnum() not in analyses and HydrologyDCEfficientAnalysisEnum() not in analyses: 148 return md 149 150 md = checkfield(md,'fieldname','hydrology.water_compressibility','numel',[1],'>',0.) 151 md = checkfield(md,'fieldname','hydrology.isefficientlayer','numel',[1],'values',[0,1]) 152 md = checkfield(md,'fieldname','hydrology.penalty_factor','>',0.,'numel',[1]) 153 md = checkfield(md,'fieldname','hydrology.penalty_lock','>=',0.,'numel',[1]) 154 md = checkfield(md,'fieldname','hydrology.rel_tol','>',0.,'numel',[1]) 155 md = checkfield(md,'fieldname','hydrology.max_iter','>',0.,'numel',[1]) 156 md = checkfield(md,'fieldname','hydrology.sedimentlimit_flag','numel',[1],'values',[0,1,2,3]) 157 md = checkfield(md,'fieldname','hydrology.transfer_flag','numel',[1],'values',[0,1]) 158 159 if self.sedimentlimit_flag==1: 160 md = checkfield(md,'fieldname','hydrology.sedimentlimit','>',0.,'numel',[1]) 161 162 if self.transfer_flag==1: 163 md = checkfield(md,'fieldname','hydrology.leakage_factor','>',0.,'numel',[1]) 164 165 md = checkfield(md,'fieldname','hydrology.basal_moulin_input','NaN',1,'timeseries',1) 166 md = checkfield(md,'fieldname','hydrology.spcsediment_head','timeseries',1) 167 md = checkfield(md,'fieldname','hydrology.sediment_compressibility','>',0.,'numel',[1]) 168 md = checkfield(md,'fieldname','hydrology.sediment_porosity','>',0.,'numel',[1]) 169 md = checkfield(md,'fieldname','hydrology.sediment_thickness','>',0.,'numel',[1]) 170 md = checkfield(md,'fieldname','hydrology.sediment_transmitivity','>=',0,'size',[md.mesh.numberofvertices,1]) 171 if self.isefficientlayer==1: 172 md = checkfield(md,'fieldname','hydrology.spcepl_head','timeseries',1) 173 md = checkfield(md,'fieldname','hydrology.mask_eplactive_node','size',[md.mesh.numberofvertices,1],'values',[0,1]) 174 md = checkfield(md,'fieldname','hydrology.epl_compressibility','>',0.,'numel',[1]) 175 md = checkfield(md,'fieldname','hydrology.epl_porosity','>',0.,'numel',[1]) 176 md = checkfield(md,'fieldname','hydrology.epl_max_thickness','numel',[1],'>',0.) 177 md = checkfield(md,'fieldname','hydrology.epl_initial_thickness','numel',[1],'>',0.) 178 md = checkfield(md,'fieldname','hydrology.epl_colapse_thickness','numel',[1],'>',0.) 179 md = checkfield(md,'fieldname','hydrology.epl_thick_comp','numel',[1],'values',[0,1]) 180 md = checkfield(md,'fieldname','hydrology.eplflip_lock','>=',0.,'numel',[1]) 181 if self.epl_colapse_thickness > self.epl_initial_thickness: 182 md.checkmessage('Colapsing thickness for EPL larger than initial thickness') 183 md = checkfield(md,'fieldname','hydrology.epl_conductivity','numel',[1],'>',0.) 184 # }}} 185 def marshall(self,md,fid): #{{{ 186 WriteData(fid,'enum',HydrologyModelEnum(),'data',HydrologydcEnum(),'format','Integer') 187 WriteData(fid,'object',self,'fieldname','water_compressibility','format','Double') 188 WriteData(fid,'object',self,'fieldname','isefficientlayer','format','Boolean') 189 WriteData(fid,'object',self,'fieldname','penalty_factor','format','Double') 190 WriteData(fid,'object',self,'fieldname','penalty_lock','format','Integer') 191 WriteData(fid,'object',self,'fieldname','rel_tol','format','Double') 192 WriteData(fid,'object',self,'fieldname','max_iter','format','Integer') 193 WriteData(fid,'object',self,'fieldname','sedimentlimit_flag','format','Integer') 194 WriteData(fid,'object',self,'fieldname','transfer_flag','format','Integer') 195 if self.sedimentlimit_flag==1: 196 WriteData(fid,'object',self,'fieldname','sedimentlimit','format','Double') 197 198 if self.transfer_flag==1: 199 WriteData(fid,'object',self,'fieldname','leakage_factor','format','Double') 200 201 WriteData(fid,'object',self,'fieldname','basal_moulin_input','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1) 202 WriteData(fid,'object',self,'fieldname','spcsediment_head','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1) 203 WriteData(fid,'object',self,'fieldname','sediment_compressibility','format','Double') 204 WriteData(fid,'object',self,'fieldname','sediment_porosity','format','Double') 205 WriteData(fid,'object',self,'fieldname','sediment_thickness','format','Double') 206 WriteData(fid,'object',self,'fieldname','sediment_transmitivity','format','DoubleMat','mattype',1) 207 208 if self.isefficientlayer==1: 209 WriteData(fid,'object',self,'fieldname','spcepl_head','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1) 210 WriteData(fid,'object',self,'fieldname','mask_eplactive_node','format','DoubleMat','mattype',1) 211 WriteData(fid,'object',self,'fieldname','epl_compressibility','format','Double') 212 WriteData(fid,'object',self,'fieldname','epl_porosity','format','Double') 213 WriteData(fid,'object',self,'fieldname','epl_max_thickness','format','Double') 214 WriteData(fid,'object',self,'fieldname','epl_initial_thickness','format','Double') 215 WriteData(fid,'object',self,'fieldname','epl_colapse_thickness','format','Double') 216 WriteData(fid,'object',self,'fieldname','epl_thick_comp','format','Integer') 217 WriteData(fid,'object',self,'fieldname','epl_conductivity','format','Double') 218 WriteData(fid,'object',self,'fieldname','eplflip_lock','format','Integer') 219 # }}} -
issm/trunk/src/m/classes/hydrologyshreve.m
r17989 r19105 10 10 end 11 11 methods 12 function createxml(obj,fid) % {{{ 13 fprintf(fid, '\n\n'); 14 fprintf(fid, '%s\n', '<!-- Hydrology -->'); 15 16 % Convergence criteria 17 fprintf(fid,'%s\n%s\n%s\n','<frame key="1" label="Hydrologyshreve solution parameters">','<section name="hydrologyshreve" />'); 18 19 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="spcwatercolumn" type="', class(obj.spcwatercolumn),'" default="', convert2str(obj.spcwatercolumn),'">', ' <section name="hydrologyshreve" />',' <help> water thickness constraints (NaN means no constraint) [m] </help>','</parameter>'); 20 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="stabilization" type="', class(obj.stabilization),'" default="', convert2str(obj.stabilization),'">', ' <section name="hydrologyshreve" />',' <help> artificial diffusivity (default is 1). can be more than 1 to increase diffusivity. </help>','</parameter>'); 21 fprintf(fid,'%s\n%s\n','</frame>'); 22 end % }}} 23 function obj = hydrologyshreve(varargin) % {{{ 12 function createxml(self,fid) % {{{ 13 fprintf(fid, '\n\n'); 14 fprintf(fid, '%s\n', '<!-- Hydrology -->'); 15 16 % Convergence criteria 17 fprintf(fid,'%s\n%s\n%s\n','<frame key="1" label="Hydrologyshreve solution parameters">','<section name="hydrologyshreve" />'); 18 19 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="spcwatercolumn" type="', class(self.spcwatercolumn),'" default="', convert2str(self.spcwatercolumn),'">', ' <section name="hydrologyshreve" />',' <help> water thickness constraints (NaN means no constraint) [m] </help>','</parameter>'); 20 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="stabilization" type="', class(self.stabilization),'" default="', convert2str(self.stabilization),'">', ' <section name="hydrologyshreve" />',' <help> artificial diffusivity (default is 1). can be more than 1 to increase diffusivity. </help>','</parameter>'); 21 fprintf(fid,'%s\n%s\n','</frame>'); 22 end % }}} 23 function self = extrude(self,md) % {{{ 24 end % }}} 25 function self = hydrologyshreve(varargin) % {{{ 24 26 switch nargin 25 27 case 0 26 obj=setdefaultparameters(obj);28 self=setdefaultparameters(self); 27 29 case 1 28 obj=structtoobj(obj,varargin{1});30 self=structtoobj(self,varargin{1}); 29 31 otherwise 30 32 error('constructor not supported'); 31 33 end 32 34 end % }}} 33 function obj = setdefaultparameters(obj) % {{{35 function self = setdefaultparameters(self) % {{{ 34 36 35 37 %Type of stabilization to use 0:nothing 1:artificial_diffusivity 36 obj.stabilization=1;38 self.stabilization=1; 37 39 end % }}} 38 function md = checkconsistency( obj,md,solution,analyses) % {{{40 function md = checkconsistency(self,md,solution,analyses) % {{{ 39 41 40 42 %Early return … … 43 45 end 44 46 45 md = checkfield(md,'fieldname','hydrology.spcwatercolumn',' forcing',1);47 md = checkfield(md,'fieldname','hydrology.spcwatercolumn','timeseries',1); 46 48 md = checkfield(md,'fieldname','hydrology.stabilization','>=',0); 47 49 end % }}} 48 function disp( obj) % {{{50 function disp(self) % {{{ 49 51 disp(sprintf(' hydrologyshreve solution parameters:')); 50 fielddisplay( obj,'spcwatercolumn','water thickness constraints (NaN means no constraint) [m]');51 fielddisplay( obj,'stabilization','artificial diffusivity (default is 1). can be more than 1 to increase diffusivity.');52 fielddisplay(self,'spcwatercolumn','water thickness constraints (NaN means no constraint) [m]'); 53 fielddisplay(self,'stabilization','artificial diffusivity (default is 1). can be more than 1 to increase diffusivity.'); 52 54 53 55 end % }}} 54 function marshall( obj,md,fid) % {{{56 function marshall(self,md,fid) % {{{ 55 57 WriteData(fid,'enum',HydrologyModelEnum(),'data',HydrologyshreveEnum(),'format','Integer'); 56 WriteData(fid,'object', obj,'fieldname','spcwatercolumn','format','DoubleMat','mattype',1,'forcinglength',md.mesh.numberofvertices+1);57 WriteData(fid,'object', obj,'fieldname','stabilization','format','Double');58 WriteData(fid,'object',self,'fieldname','spcwatercolumn','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1); 59 WriteData(fid,'object',self,'fieldname','stabilization','format','Double'); 58 60 end % }}} 59 61 end -
issm/trunk/src/m/classes/hydrologyshreve.py
r17989 r19105 27 27 return string 28 28 #}}} 29 def extrude(self,md): # {{{ 30 return self 31 #}}} 29 32 def setdefaultparameters(self): # {{{ 30 33 … … 40 43 return md 41 44 42 md = checkfield(md,'fieldname','hydrology.spcwatercolumn',' forcing',1)45 md = checkfield(md,'fieldname','hydrology.spcwatercolumn','timeseries',1) 43 46 md = checkfield(md,'fieldname','hydrology.stabilization','>=',0) 44 47 … … 47 50 def marshall(self,md,fid): # {{{ 48 51 WriteData(fid,'enum',HydrologyModelEnum(),'data',HydrologyshreveEnum(),'format','Integer'); 49 WriteData(fid,'object',self,'fieldname','spcwatercolumn','format','DoubleMat','mattype',1,' forcinglength',md.mesh.numberofvertices+1)52 WriteData(fid,'object',self,'fieldname','spcwatercolumn','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1) 50 53 WriteData(fid,'object',self,'fieldname','stabilization','format','Double') 51 54 # }}} -
issm/trunk/src/m/classes/independent.m
r17806 r19105 13 13 end 14 14 methods 15 function obj= independent(varargin) % {{{15 function self = independent(varargin) % {{{ 16 16 17 17 %use provided options to change fields … … 19 19 20 20 %OK get other fields 21 obj=AssignObjectFields(pairoptions(varargin{:}),obj);21 self=AssignObjectFields(pairoptions(varargin{:}),self); 22 22 23 23 end 24 24 %}}} 25 function obj = setdefaultparameters(obj) % {{{25 function self = setdefaultparameters(self) % {{{ 26 26 %do nothing 27 27 28 28 end % }}} 29 function md = checkconsistency( obj,md,i,solution,analyses,driver) % {{{30 if ~isnan( obj.fos_forward_index),29 function md = checkconsistency(self,md,i,solution,analyses,driver) % {{{ 30 if ~isnan(self.fos_forward_index), 31 31 if ~strcmpi(driver,'fos_forward'), 32 32 error('cannot declare an independent with a fos_forward_index when the driver is not fos_forward!'); 33 33 end 34 if obj.nods==0,34 if self.nods==0, 35 35 error('independent checkconsistency error: nods should be set to the size of the independent variable'); 36 36 end 37 37 end 38 38 39 if ~isempty( obj.fov_forward_indices),39 if ~isempty(self.fov_forward_indices), 40 40 if ~strcmpi(driver,'fov_forward'), 41 41 error('cannot declare an independent with fov_forward_indices when the driver is not fov_forward!'); 42 42 end 43 if obj.nods==0,43 if self.nods==0, 44 44 error('independent checkconsistency error: nods should be set to the size of the independent variable'); 45 45 end 46 md = checkfield(md,'fieldname',['autodiff.independents{' num2str(i) '}.fov_forward_indices'],'>=',1,'<=', obj.nods,'size',[NaN 1]);46 md = checkfield(md,'fieldname',['autodiff.independents{' num2str(i) '}.fov_forward_indices'],'>=',1,'<=',self.nods,'size',[NaN 1]); 47 47 end 48 48 49 49 end % }}} 50 function disp( obj) % {{{50 function disp(self) % {{{ 51 51 disp(sprintf(' independent variable:')); 52 52 53 fielddisplay(obj,'name','variable name (must match corresponding Enum)'); 54 fielddisplay(obj,'type','type of variable (''vertex'' or ''scalar'')'); 55 if ~isnan(obj.fos_forward_index), 56 fielddisplay(obj,'fos_forward_index','index for fos_foward driver of ADOLC'); 53 fielddisplay(self,'name','variable name (must match corresponding Enum)'); 54 fielddisplay(self,'type','type of variable (''vertex'' or ''scalar'')'); 55 fielddisplay(self,'nods','size of dependent variables'); 56 if ~isnan(self.fos_forward_index), 57 fielddisplay(self,'fos_forward_index','index for fos_foward driver of ADOLC'); 57 58 end 58 if ~isnan( obj.fov_forward_indices),59 fielddisplay( obj,'fov_forward_indices','indices for fov_foward driver of ADOLC');59 if ~isnan(self.fov_forward_indices), 60 fielddisplay(self,'fov_forward_indices','indices for fov_foward driver of ADOLC'); 60 61 end 61 62 end % }}} 62 function scalartype=typetoscalar( obj) % {{{63 if strcmpi( obj.type,'scalar'),63 function scalartype=typetoscalar(self) % {{{ 64 if strcmpi(self.type,'scalar'), 64 65 scalartype=0; 65 elseif strcmpi( obj.type,'vertex'),66 elseif strcmpi(self.type,'vertex'), 66 67 scalartype=1; 67 elseif strcmpi( obj.type,'matrix'),68 elseif strcmpi(self.type,'matrix'), 68 69 scalartype=1; 69 else error([ obj.type ' not supported yet!']);70 else error([self.type ' not supported yet!']); 70 71 end 71 72 end % }}} -
issm/trunk/src/m/classes/initialization.m
r17806 r19105 19 19 end 20 20 methods 21 function createxml(obj,fid) % {{{ 22 fprintf(fid, '\n\n'); 23 fprintf(fid, '%s\n', '<!-- initialization -->'); 24 fprintf(fid,'%s\n%s\n%s\n','<frame key="1" label="Initial field values">','<section name="initialization" />'); 25 26 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="vx" type="',class(obj.vx),'" default="',obj.vx,'">',' <section name="initialization" />',' <help> x component of velocity [m/yr] </help>','</parameter>'); 27 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="vy" type="',class(obj.vy),'" default="',obj.vy,'">',' <section name="initialization" />',' <help> y component of velocity [m/yr] </help>','</parameter>'); 28 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="vz" type="',class(obj.vz),'" default="',obj.vz,'">',' <section name="initialization" />',' <help> z component of velocity [m/yr] </help>','</parameter>'); 29 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="vel" type="',class(obj.vel),'" default="',obj.vel,'">',' <section name="initialization" />',' <help> velocity norm [m/yr] </help>','</parameter>'); 30 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="pressure" type="',class(obj.pressure),'" default="',obj.pressure,'">',' <section name="initialization" />',' <help> pressure field [Pa] </help>','</parameter>'); 31 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="temperature" type="',class(obj.temperature),'" default="',obj.temperature,'">',' <section name="initialization" />',' <help> fraction of water in the ice </help>','</parameter>'); 32 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="waterfraction" type="',class(obj.waterfraction),'" default="',obj.waterfraction,'">',' <section name="initialization" />',' <help> ice thickness [m] </help>','</parameter>'); 33 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="sediment_head" type="',class(obj.sediment_head),'" default="',obj.sediment_head,'">',' <section name="initialization" />',' <help> sediment water head of subglacial system [m] </help>','</parameter>'); 34 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="epl_head" type="',class(obj.epl_head),'" default="',obj.epl_head,'">',' <section name="initialization" />',' <help> epl water head of subglacial system [m] </help>','</parameter>'); 35 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n','<parameter key ="watercolumn" type="',class(obj.watercolumn),'" default="',obj.watercolumn,'">',' <section name="initialization" />',' <help> thickness of subglacial water [m] </help>','</parameter>'); 36 fprintf(fid,'%s\n%s\n','</frame>'); 37 end % }}} 38 function obj = initialization(varargin) % {{{ 21 function createxml(self,fid) % {{{ 22 fprintf(fid, '\n\n'); 23 fprintf(fid, '%s\n', '<!-- initialization -->'); 24 fprintf(fid,'%s\n%s\n%s\n','<frame key="1" label="Initial field values">','<section name="initialization" />'); 25 26 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="vx" type="',class(self.vx),'" default="',self.vx,'">',' <section name="initialization" />',' <help> x component of velocity [m/yr] </help>','</parameter>'); 27 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="vy" type="',class(self.vy),'" default="',self.vy,'">',' <section name="initialization" />',' <help> y component of velocity [m/yr] </help>','</parameter>'); 28 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="vz" type="',class(self.vz),'" default="',self.vz,'">',' <section name="initialization" />',' <help> z component of velocity [m/yr] </help>','</parameter>'); 29 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="vel" type="',class(self.vel),'" default="',self.vel,'">',' <section name="initialization" />',' <help> velocity norm [m/yr] </help>','</parameter>'); 30 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="pressure" type="',class(self.pressure),'" default="',self.pressure,'">',' <section name="initialization" />',' <help> pressure field [Pa] </help>','</parameter>'); 31 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="temperature" type="',class(self.temperature),'" default="',self.temperature,'">',' <section name="initialization" />',' <help> fraction of water in the ice </help>','</parameter>'); 32 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="waterfraction" type="',class(self.waterfraction),'" default="',self.waterfraction,'">',' <section name="initialization" />',' <help> ice thickness [m] </help>','</parameter>'); 33 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="sediment_head" type="',class(self.sediment_head),'" default="',self.sediment_head,'">',' <section name="initialization" />',' <help> sediment water head of subglacial system [m] </help>','</parameter>'); 34 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="epl_head" type="',class(self.epl_head),'" default="',self.epl_head,'">',' <section name="initialization" />',' <help> epl water head of subglacial system [m] </help>','</parameter>'); 35 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n','<parameter key ="watercolumn" type="',class(self.watercolumn),'" default="',self.watercolumn,'">',' <section name="initialization" />',' <help> thickness of subglacial water [m] </help>','</parameter>'); 36 fprintf(fid,'%s\n%s\n','</frame>'); 37 end % }}} 38 function self = extrude(self,md) % {{{ 39 self.vx=project3d(md,'vector',self.vx,'type','node'); 40 self.vy=project3d(md,'vector',self.vy,'type','node'); 41 self.vz=project3d(md,'vector',self.vz,'type','node'); 42 self.vel=project3d(md,'vector',self.vel,'type','node'); 43 self.temperature=project3d(md,'vector',self.temperature,'type','node'); 44 self.waterfraction=project3d(md,'vector',self.waterfraction,'type','node'); 45 self.watercolumn=project3d(md,'vector',self.watercolumn,'type','node','layer',1); 46 self.sediment_head=project3d(md,'vector',self.sediment_head,'type','node','layer',1); 47 self.epl_head=project3d(md,'vector',self.epl_head,'type','node','layer',1); 48 self.epl_thickness=project3d(md,'vector',self.epl_thickness,'type','node','layer',1); 49 50 %Lithostatic pressure by default 51 self.pressure=md.constants.g*md.materials.rho_ice*(md.geometry.surface-md.mesh.z); 52 end % }}} 53 function self = initialization(varargin) % {{{ 39 54 switch nargin 40 55 case 0 41 obj=setdefaultparameters(obj);56 self=setdefaultparameters(self); 42 57 otherwise 43 58 error('constructor not supported'); 44 59 end 45 60 end % }}} 46 function obj = setdefaultparameters(obj) % {{{61 function self = setdefaultparameters(self) % {{{ 47 62 48 63 end % }}} 49 function md = checkconsistency( obj,md,solution,analyses) % {{{64 function md = checkconsistency(self,md,solution,analyses) % {{{ 50 65 if ismember(StressbalanceAnalysisEnum(),analyses) 51 66 if ~(isnan(md.initialization.vx) | isnan(md.initialization.vy)), … … 73 88 end 74 89 md = checkfield(md,'fieldname','initialization.pressure','NaN',1,'size',[md.mesh.numberofvertices 1]); 90 md = checkfield(md,'fieldname','initialization.temperature','NaN',1,'size',[md.mesh.numberofvertices 1]); 75 91 end 76 92 if (ismember(EnthalpyAnalysisEnum(),analyses) & md.thermal.isenthalpy) … … 91 107 if isa(md.hydrology,'hydrologydc'), 92 108 if md.hydrology.isefficientlayer==1, 93 md = checkfield(md,'fieldname', ... 94 'initialization.epl_head','NaN',1,'size',[md.mesh.numberofvertices 1]); 109 md = checkfield(md,'fieldname','initialization.epl_head','NaN',1,'size',[md.mesh.numberofvertices 1]); 95 110 md = checkfield(md,'fieldname','initialization.epl_thickness','NaN',1,'size',[md.mesh.numberofvertices 1]); 96 111 end … … 98 113 end 99 114 end % }}} 100 function disp( obj) % {{{115 function disp(self) % {{{ 101 116 disp(sprintf(' initial field values:')); 102 117 103 fielddisplay( obj,'vx','x component of velocity [m/yr]');104 fielddisplay( obj,'vy','y component of velocity [m/yr]');105 fielddisplay( obj,'vz','z component of velocity [m/yr]');106 fielddisplay( obj,'vel','velocity norm [m/yr]');107 fielddisplay( obj,'pressure','pressure field [Pa]');108 fielddisplay( obj,'temperature','temperature [K]');109 fielddisplay( obj,'waterfraction','fraction of water in the ice');110 fielddisplay( obj,'sediment_head','sediment water head of subglacial system [m]');111 fielddisplay( obj,'epl_head','epl water head of subglacial system [m]');112 fielddisplay( obj,'epl_thickness','epl layer thickness [m]');113 fielddisplay( obj,'watercolumn','thickness of subglacial water [m]');118 fielddisplay(self,'vx','x component of velocity [m/yr]'); 119 fielddisplay(self,'vy','y component of velocity [m/yr]'); 120 fielddisplay(self,'vz','z component of velocity [m/yr]'); 121 fielddisplay(self,'vel','velocity norm [m/yr]'); 122 fielddisplay(self,'pressure','pressure field [Pa]'); 123 fielddisplay(self,'temperature','temperature [K]'); 124 fielddisplay(self,'waterfraction','fraction of water in the ice'); 125 fielddisplay(self,'sediment_head','sediment water head of subglacial system [m]'); 126 fielddisplay(self,'epl_head','epl water head of subglacial system [m]'); 127 fielddisplay(self,'epl_thickness','epl layer thickness [m]'); 128 fielddisplay(self,'watercolumn','thickness of subglacial water [m]'); 114 129 115 130 end % }}} 116 function marshall( obj,md,fid) % {{{131 function marshall(self,md,fid) % {{{ 117 132 118 133 yts=365.0*24.0*3600.0; 119 134 120 WriteData(fid,'data', obj.vx,'format','DoubleMat','mattype',1,'enum',VxEnum,'scale',1./yts);121 WriteData(fid,'data', obj.vy,'format','DoubleMat','mattype',1,'enum',VyEnum,'scale',1./yts);122 WriteData(fid,'data', obj.vz,'format','DoubleMat','mattype',1,'enum',VzEnum,'scale',1./yts);123 WriteData(fid,'data', obj.pressure,'format','DoubleMat','mattype',1,'enum',PressureEnum);124 WriteData(fid,'data', obj.temperature,'format','DoubleMat','mattype',1,'enum',TemperatureEnum);125 WriteData(fid,'data', obj.waterfraction,'format','DoubleMat','mattype',1,'enum',WaterfractionEnum);126 WriteData(fid,'data', obj.sediment_head,'format','DoubleMat','mattype',1,'enum',SedimentHeadEnum);127 WriteData(fid,'data', obj.epl_head,'format','DoubleMat','mattype',1,'enum',EplHeadEnum);128 WriteData(fid,'data', obj.epl_thickness,'format','DoubleMat','mattype',1,'enum',HydrologydcEplThicknessEnum);129 WriteData(fid,'data', obj.watercolumn,'format','DoubleMat','mattype',1,'enum',WatercolumnEnum);135 WriteData(fid,'data',self.vx,'format','DoubleMat','mattype',1,'enum',VxEnum,'scale',1./yts); 136 WriteData(fid,'data',self.vy,'format','DoubleMat','mattype',1,'enum',VyEnum,'scale',1./yts); 137 WriteData(fid,'data',self.vz,'format','DoubleMat','mattype',1,'enum',VzEnum,'scale',1./yts); 138 WriteData(fid,'data',self.pressure,'format','DoubleMat','mattype',1,'enum',PressureEnum); 139 WriteData(fid,'data',self.temperature,'format','DoubleMat','mattype',1,'enum',TemperatureEnum); 140 WriteData(fid,'data',self.waterfraction,'format','DoubleMat','mattype',1,'enum',WaterfractionEnum); 141 WriteData(fid,'data',self.sediment_head,'format','DoubleMat','mattype',1,'enum',SedimentHeadEnum); 142 WriteData(fid,'data',self.epl_head,'format','DoubleMat','mattype',1,'enum',EplHeadEnum); 143 WriteData(fid,'data',self.epl_thickness,'format','DoubleMat','mattype',1,'enum',HydrologydcEplThicknessEnum); 144 WriteData(fid,'data',self.watercolumn,'format','DoubleMat','mattype',1,'enum',WatercolumnEnum); 130 145 131 146 if md.thermal.isenthalpy, 132 147 tpmp = md.materials.meltingpoint - md.materials.beta*md.initialization.pressure; 133 pos = find(md.initialization.temperature> tpmp);148 pos = find(md.initialization.temperature>=tpmp); 134 149 enthalpy = md.materials.heatcapacity*(md.initialization.temperature-md.constants.referencetemperature); 135 enthalpy(pos) = md.materials.heatcapacity* tpmp(pos) - md.constants.referencetemperature+ md.materials.latentheat*md.initialization.waterfraction(pos);150 enthalpy(pos) = md.materials.heatcapacity*(tpmp(pos) - md.constants.referencetemperature) + md.materials.latentheat*md.initialization.waterfraction(pos); 136 151 WriteData(fid,'data',enthalpy,'format','DoubleMat','mattype',1,'enum',EnthalpyEnum()); 137 152 end -
issm/trunk/src/m/classes/initialization.py
r17806 r19105 1 1 import numpy 2 from project3d import project3d 2 3 from fielddisplay import fielddisplay 3 4 from EnumDefinitions import * … … 9 10 """ 10 11 INITIALIZATION class definition 11 12 13 12 13 Usage: 14 initialization=initialization(); 14 15 """ 15 16 16 17 def __init__(self): # {{{ 17 18 18 19 self.vx = float('NaN') 19 20 self.vy = float('NaN') … … 24 25 self.waterfraction = float('NaN') 25 26 self.watercolumn = float('NaN') 26 self.sediment_head = float('NaN') 27 self.sediment_head = float('NaN') 28 self.epl_head = float('NaN') 29 self.epl_thickness = float('NaN') 27 30 28 31 #set defaults … … 32 35 def __repr__(self): # {{{ 33 36 string=' initial field values:' 34 35 37 string="%s\n%s"%(string,fielddisplay(self,'vx','x component of velocity [m/yr]')) 36 38 string="%s\n%s"%(string,fielddisplay(self,'vy','y component of velocity [m/yr]')) … … 42 44 string="%s\n%s"%(string,fielddisplay(self,'watercolumn','thickness of subglacial water [m]')) 43 45 string="%s\n%s"%(string,fielddisplay(self,'sediment_head','sediment water head of subglacial system [m]')) 46 string="%s\n%s"%(string,fielddisplay(self,'epl_head','epl water head of subglacial system [m]')) 47 string="%s\n%s"%(string,fielddisplay(self,'epl_thickness','thickness of the epl [m]')) 44 48 45 49 return string 46 50 #}}} 51 def extrude(self,md): # {{{ 52 self.vx=project3d(md,'vector',self.vx,'type','node') 53 self.vy=project3d(md,'vector',self.vy,'type','node') 54 self.vz=project3d(md,'vector',self.vz,'type','node') 55 self.vel=project3d(md,'vector',self.vel,'type','node') 56 self.temperature=project3d(md,'vector',self.temperature,'type','node') 57 self.waterfraction=project3d(md,'vector',self.waterfraction,'type','node') 58 self.watercolumn=project3d(md,'vector',self.watercolumn,'type','node') 59 self.sediment_head=project3d(md,'vector',self.sediment_head,'type','node','layer',1) 60 self.epl_head=project3d(md,'vector',self.epl_head,'type','node','layer',1) 61 self.epl_thickness=project3d(md,'vector',self.epl_thickness,'type','node','layer',1) 62 63 #Lithostatic pressure by default 64 self.pressure=md.constants.g*md.materials.rho_ice*(md.geometry.surface-md.mesh.z.reshape(-1,1)) 65 return self 66 #}}} 47 67 def setdefaultparameters(self): # {{{ 48 68 return self … … 66 86 md = checkfield(md,'fieldname','initialization.vx','NaN',1,'size',[md.mesh.numberofvertices]) 67 87 md = checkfield(md,'fieldname','initialization.vy','NaN',1,'size',[md.mesh.numberofvertices]) 88 md = checkfield(md,'fieldname','initialization.temperature','NaN',1,'size',[md.mesh.numberofvertices]) 68 89 if md.mesh.dimension()==3: 69 90 md = checkfield(md,'fieldname','initialization.vz','NaN',1,'size',[md.mesh.numberofvertices]) 70 91 md = checkfield(md,'fieldname','initialization.pressure','NaN',1,'size',[md.mesh.numberofvertices]) 71 if (EnthalpyAnalysisEnum() in analyses and md.thermal.isenthalpy):72 md = checkfield(md,'fieldname','initialization.waterfraction','>=',0,'size',[md.mesh.numberofvertices])73 md = checkfield(md,'fieldname','initialization.watercolumn' ,'>=',0,'size',[md.mesh.numberofvertices])92 if (EnthalpyAnalysisEnum() in analyses and md.thermal.isenthalpy): 93 md = checkfield(md,'fieldname','initialization.waterfraction','>=',0,'size',[md.mesh.numberofvertices]) 94 md = checkfield(md,'fieldname','initialization.watercolumn' ,'>=',0,'size',[md.mesh.numberofvertices]) 74 95 if HydrologyShreveAnalysisEnum() in analyses: 75 md = checkfield(md,'fieldname','initialization.watercolumn','NaN',1,'size',[md.mesh.numberofvertices]) 96 if hasattr(md.hydrology,'hydrologyshreve'): 97 md = checkfield(md,'fieldname','initialization.watercolumn','NaN',1,'size',[md.mesh.numberofvertices]) 98 if HydrologyDCInefficientAnalysisEnum() in analyses: 99 if hasattr(md.hydrology,'hydrologydc'): 100 md = checkfield(md,'fieldname','initialization.sediment_head','NaN',1,'size',[md.mesh.numberofvertices,1]) 101 if HydrologyDCEfficientAnalysisEnum() in analyses: 102 if hasattr(md.hydrology,'hydrologydc'): 103 if md.hydrology.isefficientlayer==1: 104 md = checkfield(md,'fieldname','initialization.epl_head','NaN',1,'size',[md.mesh.numberofvertices,1]) 105 md = checkfield(md,'fieldname','initialization.epl_thickness','NaN',1,'size',[md.mesh.numberofvertices,1]) 106 76 107 return md 77 108 # }}} … … 88 119 WriteData(fid,'data',self.watercolumn,'format','DoubleMat','mattype',1,'enum',WatercolumnEnum()) 89 120 WriteData(fid,'data',self.sediment_head,'format','DoubleMat','mattype',1,'enum',SedimentHeadEnum()) 121 WriteData(fid,'data',self.epl_head,'format','DoubleMat','mattype',1,'enum',EplHeadEnum()) 122 WriteData(fid,'data',self.epl_thickness,'format','DoubleMat','mattype',1,'enum',HydrologydcEplThicknessEnum()) 90 123 124 91 125 if md.thermal.isenthalpy: 92 126 tpmp = md.materials.meltingpoint - md.materials.beta*md.initialization.pressure; -
issm/trunk/src/m/classes/inversion.m
r18301 r19105 23 23 vel_obs = NaN 24 24 thickness_obs = NaN 25 surface_obs = NaN 25 26 end 26 27 methods 27 function createxml( obj,fid) % {{{28 function createxml(self,fid) % {{{ 28 29 fprintf(fid, '<!-- inversion -->\n'); 29 30 30 31 % inversion parameters 31 32 fprintf(fid,'%s\n%s\n%s\n','<frame key="1" label="inversion parameters">','<section name="inversion" />'); 32 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="iscontrol" type="',class( obj.iscontrol),'" default="',convert2str(obj.iscontrol),'">',' <section name="inversion" />',' <help> is inversion activated? </help>',' </parameter>');33 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="iscontrol" type="',class(self.iscontrol),'" default="',convert2str(self.iscontrol),'">',' <section name="inversion" />',' <help> is inversion activated? </help>',' </parameter>'); 33 34 34 35 % incompleteadjoing drop-down (0 or 1) … … 37 38 fprintf(fid,'%s\n%s\n',' <option value="1" type="string" default="false"> </option>','</parameter>'); 38 39 39 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="control_parameters" type="',class( obj.control_parameters),'" default="',convert2str(obj.control_parameters),'">',' <section name="inversion" />',' <help> ex: {''FrictionCoefficient''}, or {''MaterialsRheologyBbar''} </help>',' </parameter>');40 41 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="nsteps" type="',class( obj.nsteps),'" default="',convert2str(obj.nsteps),'">',' <section name="inversion" />',' <help> number of optimization searches </help>',' </parameter>');42 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="cost_functions" type="',class( obj.cost_functions),'" default="',convert2str(obj.cost_functions),'">',' <section name="inversion" />',' <help> indicate the type of response for each optimization step </help>',' </parameter>');43 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="cost_functions_coefficients" type="',class( obj.cost_functions_coefficients),'" default="',convert2str(obj.cost_functions_coefficients),'">',' <section name="inversion" />',' <help> cost_functions_coefficients applied to the misfit of each vertex and for each control_parameter </help>',' </parameter>');44 45 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="cost_function_threshold" type="',class( obj.cost_function_threshold),'" default="',convert2str(obj.cost_function_threshold),'">',' <section name="inversion" />',' <help> misfit convergence criterion. Default is 1%, NaN if not applied </help>',' </parameter>');46 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="maxiter_per_step" type="',class( obj.maxiter_per_step),'" default="',convert2str(obj.maxiter_per_step),'">',' <section name="inversion" />',' <help> maximum iterations during each optimization step </help>',' </parameter>');47 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="gradient_scaling" type="',class( obj.gradient_scaling),'" default="',convert2str(obj.gradient_scaling),'">',' <section name="inversion" />',' <help> scaling factor on gradient direction during optimization, for each optimization step </help>',' </parameter>');48 49 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="step_threshold" type="',class( obj.step_threshold),'" default="',convert2str(obj.step_threshold),'">',' <section name="inversion" />',' <help> decrease threshold for misfit, default is 30% </help>',' </parameter>');50 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="min_parameters" type="',class( obj.min_parameters),'" default="',convert2str(obj.min_parameters),'">',' <section name="inversion" />',' <help> absolute minimum acceptable value of the inversed parameter on each vertex </help>',' </parameter>');51 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="max_parameters" type="',class( obj.max_parameters),'" default="',convert2str(obj.max_parameters),'">',' <section name="inversion" />',' <help> absolute maximum acceptable value of the inversed parameter on each vertex </help>',' </parameter>');52 53 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vx_obs" type="',class( obj.vx_obs),'" default="',convert2str(obj.vx_obs),'">',' <section name="inversion" />',' <help> observed velocity x component [m/yr] </help>',' </parameter>');54 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vy_obs" type="',class( obj.vy_obs),'" default="',convert2str(obj.vy_obs),'">',' <section name="inversion" />',' <help> observed velocity y component [m/yr] </help>',' </parameter>');55 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vel_obs" type="',class( obj.vel_obs),'" default="',convert2str(obj.vel_obs),'">',' <section name="inversion" />',' <help> observed velocity magnitude [m/yr] </help>',' </parameter>');56 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="thickness_obs" type="',class( obj.thickness_obs),'" default="',convert2str(obj.thickness_obs),'">',' <section name="inversion" />',' <help> observed thickness [m]) </help>',' </parameter>');40 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="control_parameters" type="',class(self.control_parameters),'" default="',convert2str(self.control_parameters),'">',' <section name="inversion" />',' <help> ex: {''FrictionCoefficient''}, or {''MaterialsRheologyBbar''} </help>',' </parameter>'); 41 42 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="nsteps" type="',class(self.nsteps),'" default="',convert2str(self.nsteps),'">',' <section name="inversion" />',' <help> number of optimization searches </help>',' </parameter>'); 43 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="cost_functions" type="',class(self.cost_functions),'" default="',convert2str(self.cost_functions),'">',' <section name="inversion" />',' <help> indicate the type of response for each optimization step </help>',' </parameter>'); 44 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="cost_functions_coefficients" type="',class(self.cost_functions_coefficients),'" default="',convert2str(self.cost_functions_coefficients),'">',' <section name="inversion" />',' <help> cost_functions_coefficients applied to the misfit of each vertex and for each control_parameter </help>',' </parameter>'); 45 46 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="cost_function_threshold" type="',class(self.cost_function_threshold),'" default="',convert2str(self.cost_function_threshold),'">',' <section name="inversion" />',' <help> misfit convergence criterion. Default is 1%, NaN if not applied </help>',' </parameter>'); 47 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="maxiter_per_step" type="',class(self.maxiter_per_step),'" default="',convert2str(self.maxiter_per_step),'">',' <section name="inversion" />',' <help> maximum iterations during each optimization step </help>',' </parameter>'); 48 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="gradient_scaling" type="',class(self.gradient_scaling),'" default="',convert2str(self.gradient_scaling),'">',' <section name="inversion" />',' <help> scaling factor on gradient direction during optimization, for each optimization step </help>',' </parameter>'); 49 50 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="step_threshold" type="',class(self.step_threshold),'" default="',convert2str(self.step_threshold),'">',' <section name="inversion" />',' <help> decrease threshold for misfit, default is 30% </help>',' </parameter>'); 51 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="min_parameters" type="',class(self.min_parameters),'" default="',convert2str(self.min_parameters),'">',' <section name="inversion" />',' <help> absolute minimum acceptable value of the inversed parameter on each vertex </help>',' </parameter>'); 52 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="max_parameters" type="',class(self.max_parameters),'" default="',convert2str(self.max_parameters),'">',' <section name="inversion" />',' <help> absolute maximum acceptable value of the inversed parameter on each vertex </help>',' </parameter>'); 53 54 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vx_obs" type="',class(self.vx_obs),'" default="',convert2str(self.vx_obs),'">',' <section name="inversion" />',' <help> observed velocity x component [m/yr] </help>',' </parameter>'); 55 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vy_obs" type="',class(self.vy_obs),'" default="',convert2str(self.vy_obs),'">',' <section name="inversion" />',' <help> observed velocity y component [m/yr] </help>',' </parameter>'); 56 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vel_obs" type="',class(self.vel_obs),'" default="',convert2str(self.vel_obs),'">',' <section name="inversion" />',' <help> observed velocity magnitude [m/yr] </help>',' </parameter>'); 57 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="thickness_obs" type="',class(self.thickness_obs),'" default="',convert2str(self.thickness_obs),'">',' <section name="inversion" />',' <help> observed thickness [m]) </help>',' </parameter>'); 57 58 58 59 fprintf(fid,'%s\n%s\n','</frame>'); … … 74 75 75 76 end % }}} 76 function obj= inversion(varargin) % {{{77 function self = inversion(varargin) % {{{ 77 78 switch nargin 78 79 case 0 79 obj=setdefaultparameters(obj);80 self=setdefaultparameters(self); 80 81 case 1 81 obj=structtoobj(inversion(),varargin{1});82 self =structtoobj(inversion(),varargin{1}); 82 83 otherwise 83 84 error('constructor not supported'); 84 85 end 85 86 end % }}} 86 function obj = setdefaultparameters(obj) % {{{ 87 function self = extrude(self,md) % {{{ 88 self.vx_obs=project3d(md,'vector',self.vx_obs,'type','node'); 89 self.vy_obs=project3d(md,'vector',self.vy_obs,'type','node'); 90 self.vel_obs=project3d(md,'vector',self.vel_obs,'type','node'); 91 self.thickness_obs=project3d(md,'vector',self.thickness_obs,'type','node'); 92 if numel(self.cost_functions_coefficients)>1,self.cost_functions_coefficients=project3d(md,'vector',self.cost_functions_coefficients,'type','node');end; 93 if numel(self.min_parameters)>1,self.min_parameters=project3d(md,'vector',self.min_parameters,'type','node');end; 94 if numel(self.max_parameters)>1,self.max_parameters=project3d(md,'vector',self.max_parameters,'type','node');end; 95 end % }}} 96 function self = setdefaultparameters(self) % {{{ 87 97 88 98 %default is incomplete adjoint for now 89 obj.incomplete_adjoint=1;99 self.incomplete_adjoint=1; 90 100 91 101 %parameter to be inferred by control methods (only 92 102 %drag and B are supported yet) 93 obj.control_parameters={'FrictionCoefficient'};103 self.control_parameters={'FrictionCoefficient'}; 94 104 95 105 %number of steps in the control methods 96 obj.nsteps=20;106 self.nsteps=20; 97 107 98 108 %maximum number of iteration in the optimization algorithm for 99 109 %each step 100 obj.maxiter_per_step=20*ones(obj.nsteps,1);110 self.maxiter_per_step=20*ones(self.nsteps,1); 101 111 102 112 %the inversed parameter is updated as follows: … … 105 115 %inversed parameter (10^8 for B, 50 for drag) and can be decreased 106 116 %after the first iterations 107 obj.gradient_scaling=50*ones(obj.nsteps,1);117 self.gradient_scaling=50*ones(self.nsteps,1); 108 118 109 119 %several responses can be used: 110 obj.cost_functions=101;120 self.cost_functions=101; 111 121 112 122 %step_threshold is used to speed up control method. When 113 %misfit(1)/misfit(0) < obj.step_threshold, we go directly to123 %misfit(1)/misfit(0) < self.step_threshold, we go directly to 114 124 %the next step 115 obj.step_threshold=.7*ones(obj.nsteps,1); %30 per cent decrement.125 self.step_threshold=.7*ones(self.nsteps,1); %30 per cent decrement. 116 126 117 127 %cost_function_threshold is a criteria to stop the control methods. 118 128 %if J[n]-J[n-1]/J[n] < criteria, the control run stops 119 129 %NaN if not applied 120 obj.cost_function_threshold=NaN; %not activated121 122 end % }}} 123 function md = checkconsistency( obj,md,solution,analyses) % {{{130 self.cost_function_threshold=NaN; %not activated 131 132 end % }}} 133 function md = checkconsistency(self,md,solution,analyses) % {{{ 124 134 125 135 %Early return 126 if ~ obj.iscontrol, return; end136 if ~self.iscontrol, return; end 127 137 128 138 num_controls=numel(md.inversion.control_parameters); … … 131 141 md = checkfield(md,'fieldname','inversion.iscontrol','values',[0 1]); 132 142 md = checkfield(md,'fieldname','inversion.incomplete_adjoint','values',[0 1]); 133 md = checkfield(md,'fieldname','inversion.control_parameters','cell',1,'values',... 134 {'BalancethicknessThickeningRate' 'FrictionCoefficient' 'MaterialsRheologyBbar' 'DamageDbar' 'Vx' 'Vy' 'Thickness' 'BalancethicknessNux' 'BalancethicknessNuy' 'BalancethicknessApparentMassbalance'}); 143 md = checkfield(md,'fieldname','inversion.control_parameters','cell',1,'values',supportedcontrols()); 135 144 md = checkfield(md,'fieldname','inversion.nsteps','numel',1,'>=',0); 136 145 md = checkfield(md,'fieldname','inversion.maxiter_per_step','size',[md.inversion.nsteps 1],'>=',0); 137 146 md = checkfield(md,'fieldname','inversion.step_threshold','size',[md.inversion.nsteps 1]); 138 md = checkfield(md,'fieldname','inversion.cost_functions','size',[1 num_costfunc],'values', [101:105 201 501:507]);147 md = checkfield(md,'fieldname','inversion.cost_functions','size',[1 num_costfunc],'values',supportedcostfunctions()); 139 148 md = checkfield(md,'fieldname','inversion.cost_functions_coefficients','size',[md.mesh.numberofvertices num_costfunc],'>=',0); 140 149 md = checkfield(md,'fieldname','inversion.gradient_scaling','size',[md.inversion.nsteps num_controls]); … … 144 153 %Only SSA, HO and FS are supported right now 145 154 if solution==StressbalanceSolutionEnum() 146 if ~(md.flowequation.isSSA || md.flowequation.isHO || md.flowequation.isFS ),155 if ~(md.flowequation.isSSA || md.flowequation.isHO || md.flowequation.isFS || md.flowequation.isL1L2), 147 156 md = checkmessage(md,['inversion can only be performed for SSA, HO or FS ice flow models']); 148 157 end … … 158 167 end 159 168 end % }}} 160 function disp( obj) % {{{169 function disp(self) % {{{ 161 170 disp(sprintf(' inversion parameters:')); 162 fielddisplay(obj,'iscontrol','is inversion activated?'); 163 fielddisplay(obj,'incomplete_adjoint','1: linear viscosity, 0: non-linear viscosity'); 164 fielddisplay(obj,'control_parameters','ex: {''FrictionCoefficient''}, or {''MaterialsRheologyBbar''}'); 165 fielddisplay(obj,'nsteps','number of optimization searches'); 166 fielddisplay(obj,'cost_functions','indicate the type of response for each optimization step'); 167 fielddisplay(obj,'cost_functions_coefficients','cost_functions_coefficients applied to the misfit of each vertex and for each control_parameter'); 168 fielddisplay(obj,'cost_function_threshold','misfit convergence criterion. Default is 1%, NaN if not applied'); 169 fielddisplay(obj,'maxiter_per_step','maximum iterations during each optimization step'); 170 fielddisplay(obj,'gradient_scaling','scaling factor on gradient direction during optimization, for each optimization step'); 171 fielddisplay(obj,'step_threshold','decrease threshold for misfit, default is 30%'); 172 fielddisplay(obj,'min_parameters','absolute minimum acceptable value of the inversed parameter on each vertex'); 173 fielddisplay(obj,'max_parameters','absolute maximum acceptable value of the inversed parameter on each vertex'); 174 fielddisplay(obj,'vx_obs','observed velocity x component [m/yr]'); 175 fielddisplay(obj,'vy_obs','observed velocity y component [m/yr]'); 176 fielddisplay(obj,'vel_obs','observed velocity magnitude [m/yr]'); 177 fielddisplay(obj,'thickness_obs','observed thickness [m]'); 171 fielddisplay(self,'iscontrol','is inversion activated?'); 172 fielddisplay(self,'incomplete_adjoint','1: linear viscosity, 0: non-linear viscosity'); 173 fielddisplay(self,'control_parameters','ex: {''FrictionCoefficient''}, or {''MaterialsRheologyBbar''}'); 174 fielddisplay(self,'nsteps','number of optimization searches'); 175 fielddisplay(self,'cost_functions','indicate the type of response for each optimization step'); 176 fielddisplay(self,'cost_functions_coefficients','cost_functions_coefficients applied to the misfit of each vertex and for each control_parameter'); 177 fielddisplay(self,'cost_function_threshold','misfit convergence criterion. Default is 1%, NaN if not applied'); 178 fielddisplay(self,'maxiter_per_step','maximum iterations during each optimization step'); 179 fielddisplay(self,'gradient_scaling','scaling factor on gradient direction during optimization, for each optimization step'); 180 fielddisplay(self,'step_threshold','decrease threshold for misfit, default is 30%'); 181 fielddisplay(self,'min_parameters','absolute minimum acceptable value of the inversed parameter on each vertex'); 182 fielddisplay(self,'max_parameters','absolute maximum acceptable value of the inversed parameter on each vertex'); 183 fielddisplay(self,'vx_obs','observed velocity x component [m/yr]'); 184 fielddisplay(self,'vy_obs','observed velocity y component [m/yr]'); 185 fielddisplay(self,'vel_obs','observed velocity magnitude [m/yr]'); 186 fielddisplay(self,'thickness_obs','observed thickness [m]'); 187 fielddisplay(self,'surface_obs','observed surface elevation [m]'); 178 188 disp('Available cost functions:'); 179 189 disp(' 101: SurfaceAbsVelMisfit'); … … 187 197 disp(' 503: ThicknessAbsGradient'); 188 198 end % }}} 189 function marshall( obj,md,fid) % {{{199 function marshall(self,md,fid) % {{{ 190 200 191 201 yts=365.0*24.0*3600.0; 192 202 193 203 WriteData(fid,'enum',InversionTypeEnum(),'data',0,'format','Integer'); 194 WriteData(fid,'object', obj,'fieldname','iscontrol','format','Boolean');195 WriteData(fid,'object', obj,'fieldname','incomplete_adjoint','format','Boolean');196 if ~ obj.iscontrol, return; end197 WriteData(fid,'object', obj,'fieldname','nsteps','format','Integer');198 WriteData(fid,'object', obj,'fieldname','maxiter_per_step','format','IntMat','mattype',3);199 WriteData(fid,'object', obj,'fieldname','cost_functions_coefficients','format','DoubleMat','mattype',1);200 WriteData(fid,'object', obj,'fieldname','gradient_scaling','format','DoubleMat','mattype',3);201 WriteData(fid,'object', obj,'fieldname','cost_function_threshold','format','Double');202 WriteData(fid,'object', obj,'fieldname','min_parameters','format','DoubleMat','mattype',3);203 WriteData(fid,'object', obj,'fieldname','max_parameters','format','DoubleMat','mattype',3);204 WriteData(fid,'object', obj,'fieldname','step_threshold','format','DoubleMat','mattype',3);205 WriteData(fid,'object', obj,'fieldname','vx_obs','format','DoubleMat','mattype',1,'scale',1./yts);206 WriteData(fid,'object', obj,'fieldname','vy_obs','format','DoubleMat','mattype',1,'scale',1./yts);207 WriteData(fid,'object', obj,'fieldname','vz_obs','format','DoubleMat','mattype',1,'scale',1./yts);208 if(numel( obj.thickness_obs)==md.mesh.numberofelements),204 WriteData(fid,'object',self,'fieldname','iscontrol','format','Boolean'); 205 WriteData(fid,'object',self,'fieldname','incomplete_adjoint','format','Boolean'); 206 if ~self.iscontrol, return; end 207 WriteData(fid,'object',self,'fieldname','nsteps','format','Integer'); 208 WriteData(fid,'object',self,'fieldname','maxiter_per_step','format','IntMat','mattype',3); 209 WriteData(fid,'object',self,'fieldname','cost_functions_coefficients','format','DoubleMat','mattype',1); 210 WriteData(fid,'object',self,'fieldname','gradient_scaling','format','DoubleMat','mattype',3); 211 WriteData(fid,'object',self,'fieldname','cost_function_threshold','format','Double'); 212 WriteData(fid,'object',self,'fieldname','min_parameters','format','DoubleMat','mattype',3); 213 WriteData(fid,'object',self,'fieldname','max_parameters','format','DoubleMat','mattype',3); 214 WriteData(fid,'object',self,'fieldname','step_threshold','format','DoubleMat','mattype',3); 215 WriteData(fid,'object',self,'fieldname','vx_obs','format','DoubleMat','mattype',1,'scale',1./yts); 216 WriteData(fid,'object',self,'fieldname','vy_obs','format','DoubleMat','mattype',1,'scale',1./yts); 217 WriteData(fid,'object',self,'fieldname','vz_obs','format','DoubleMat','mattype',1,'scale',1./yts); 218 if(numel(self.thickness_obs)==md.mesh.numberofelements), 209 219 mattype=2; 210 220 else 211 221 mattype=1; 212 222 end 213 WriteData(fid,'object',obj,'class','inversion','fieldname','thickness_obs','format','DoubleMat','mattype',mattype); 223 WriteData(fid,'object',self,'class','inversion','fieldname','thickness_obs','format','DoubleMat','mattype',mattype); 224 WriteData(fid,'object',self,'class','inversion','fieldname','surface_obs','format','DoubleMat','mattype',mattype); 214 225 215 226 216 227 %process control parameters 217 num_control_parameters=numel( obj.control_parameters);228 num_control_parameters=numel(self.control_parameters); 218 229 data=zeros(1,num_control_parameters); 219 230 for i=1:num_control_parameters, 220 data(i)=StringToEnum( obj.control_parameters{i});231 data(i)=StringToEnum(self.control_parameters{i}); 221 232 end 222 233 WriteData(fid,'data',data,'enum',InversionControlParametersEnum(),'format','DoubleMat','mattype',3); … … 224 235 225 236 %process cost functions 226 num_cost_functions=size(obj.cost_functions,2); 227 data=obj.cost_functions; 228 pos=find(obj.cost_functions==101); data(pos)=SurfaceAbsVelMisfitEnum(); 229 pos=find(obj.cost_functions==102); data(pos)=SurfaceRelVelMisfitEnum(); 230 pos=find(obj.cost_functions==103); data(pos)=SurfaceLogVelMisfitEnum(); 231 pos=find(obj.cost_functions==104); data(pos)=SurfaceLogVxVyMisfitEnum(); 232 pos=find(obj.cost_functions==105); data(pos)=SurfaceAverageVelMisfitEnum(); 233 pos=find(obj.cost_functions==201); data(pos)=ThicknessAbsMisfitEnum(); 234 pos=find(obj.cost_functions==501); data(pos)=DragCoefficientAbsGradientEnum(); 235 pos=find(obj.cost_functions==502); data(pos)=RheologyBbarAbsGradientEnum(); 236 pos=find(obj.cost_functions==503); data(pos)=ThicknessAbsGradientEnum(); 237 pos=find(obj.cost_functions==504); data(pos)=ThicknessAlongGradientEnum(); 238 pos=find(obj.cost_functions==505); data(pos)=ThicknessAcrossGradientEnum(); 239 pos=find(obj.cost_functions==506); data(pos)=BalancethicknessMisfitEnum(); 240 pos=find(obj.cost_functions==507); data(pos)=Balancethickness2MisfitEnum(); 237 num_cost_functions=size(self.cost_functions,2); 238 data=marshallcostfunctions(self.cost_functions); 241 239 WriteData(fid,'data',data,'enum',InversionCostFunctionsEnum(),'format','DoubleMat','mattype',3); 242 240 WriteData(fid,'data',num_cost_functions,'enum',InversionNumCostFunctionsEnum(),'format','Integer'); -
issm/trunk/src/m/classes/inversion.py
r17989 r19105 1 1 import numpy 2 import copy 2 from project3d import project3d 3 3 from fielddisplay import fielddisplay 4 4 from EnumDefinitions import * … … 6 6 from checkfield import checkfield 7 7 from WriteData import WriteData 8 from supportedcontrols import supportedcontrols 9 from supportedcostfunctions import supportedcostfunctions 10 from marshallcostfunctions import marshallcostfunctions 8 11 9 12 class inversion(object): … … 33 36 self.vel_obs = float('NaN') 34 37 self.thickness_obs = float('NaN') 38 self.surface_obs = float('NaN') 35 39 36 40 #set defaults … … 56 60 string="%s\n%s"%(string,fielddisplay(self,'vel_obs','observed velocity magnitude [m/yr]')) 57 61 string="%s\n%s"%(string,fielddisplay(self,'thickness_obs','observed thickness [m]')) 62 string="%s\n%s"%(string,fielddisplay(self,'surface_obs','observed surface elevation [m]')) 58 63 string="%s\n%s"%(string,'Available cost functions:') 59 64 string="%s\n%s"%(string,' 101: SurfaceAbsVelMisfit') … … 68 73 return string 69 74 #}}} 75 def extrude(self,md): # {{{ 76 self.vx_obs=project3d(md,'vector',self.vx_obs,'type','node') 77 self.vy_obs=project3d(md,'vector',self.vy_obs,'type','node') 78 self.vel_obs=project3d(md,'vector',self.vel_obs,'type','node') 79 self.thickness_obs=project3d(md,'vector',self.thickness_obs,'type','node') 80 if not numpy.any(numpy.isnan(self.cost_functions_coefficients)): 81 self.cost_functions_coefficients=project3d(md,'vector',self.cost_functions_coefficients,'type','node') 82 if not numpy.any(numpy.isnan(self.min_parameters)): 83 self.min_parameters=project3d(md,'vector',self.min_parameters,'type','node') 84 if not numpy.any(numpy.isnan(self.max_parameters)): 85 self.max_parameters=project3d(md,'vector',self.max_parameters,'type','node') 86 return self 87 #}}} 70 88 def setdefaultparameters(self): # {{{ 71 89 … … 117 135 md = checkfield(md,'fieldname','inversion.iscontrol','values',[0,1]) 118 136 md = checkfield(md,'fieldname','inversion.incomplete_adjoint','values',[0,1]) 119 md = checkfield(md,'fieldname','inversion.control_parameters','cell',1,'values', ['BalancethicknessThickeningRate','FrictionCoefficient','MaterialsRheologyBbar','DamageDbar','Vx','Vy'])137 md = checkfield(md,'fieldname','inversion.control_parameters','cell',1,'values',supportedcontrols()) 120 138 md = checkfield(md,'fieldname','inversion.nsteps','numel',[1],'>=',0) 121 139 md = checkfield(md,'fieldname','inversion.maxiter_per_step','size',[md.inversion.nsteps],'>=',0) 122 140 md = checkfield(md,'fieldname','inversion.step_threshold','size',[md.inversion.nsteps]) 123 md = checkfield(md,'fieldname','inversion.cost_functions','size',[num_costfunc],'values', [101,102,103,104,105,201,501,502,503,504,505])141 md = checkfield(md,'fieldname','inversion.cost_functions','size',[num_costfunc],'values',supportedcostfunctions()) 124 142 md = checkfield(md,'fieldname','inversion.cost_functions_coefficients','size',[md.mesh.numberofvertices,num_costfunc],'>=',0) 125 143 md = checkfield(md,'fieldname','inversion.gradient_scaling','size',[md.inversion.nsteps,num_controls]) … … 129 147 #Only SSA, HO and FS are supported right now 130 148 if solution==StressbalanceSolutionEnum(): 131 if not (md.flowequation.isSSA or md.flowequation.isHO or md.flowequation.isFS ):149 if not (md.flowequation.isSSA or md.flowequation.isHO or md.flowequation.isFS or md.flowequation.isL1L2): 132 150 md.checkmessage("'inversion can only be performed for SSA, HO or FS ice flow models"); 133 151 … … 161 179 WriteData(fid,'object',self,'fieldname','vz_obs','format','DoubleMat','mattype',1,'scale',1./yts) 162 180 WriteData(fid,'object',self,'fieldname','thickness_obs','format','DoubleMat','mattype',1) 181 WriteData(fid,'object',self,'fieldname','surface_obs','format','DoubleMat','mattype',1) 163 182 164 183 #process control parameters … … 170 189 #process cost functions 171 190 num_cost_functions=numpy.size(self.cost_functions) 172 data=copy.deepcopy(self.cost_functions) 173 pos=[i for i,x in enumerate(self.cost_functions) if x==101]; 174 for i in pos: data[i]=SurfaceAbsVelMisfitEnum() 175 pos=[i for i,x in enumerate(self.cost_functions) if x==102]; 176 for i in pos: data[i]=SurfaceRelVelMisfitEnum() 177 pos=[i for i,x in enumerate(self.cost_functions) if x==103]; 178 for i in pos: data[i]=SurfaceLogVelMisfitEnum() 179 pos=[i for i,x in enumerate(self.cost_functions) if x==104]; 180 for i in pos: data[i]=SurfaceLogVxVyMisfitEnum() 181 pos=[i for i,x in enumerate(self.cost_functions) if x==105]; 182 for i in pos: data[i]=SurfaceAverageVelMisfitEnum() 183 pos=[i for i,x in enumerate(self.cost_functions) if x==201]; 184 for i in pos: data[i]=ThicknessAbsMisfitEnum() 185 pos=[i for i,x in enumerate(self.cost_functions) if x==501]; 186 for i in pos: data[i]=DragCoefficientAbsGradientEnum() 187 pos=[i for i,x in enumerate(self.cost_functions) if x==502]; 188 for i in pos: data[i]=RheologyBbarAbsGradientEnum() 189 pos=[i for i,x in enumerate(self.cost_functions) if x==503]; 190 for i in pos: data[i]=ThicknessAbsGradientEnum() 191 pos=[i for i,x in enumerate(self.cost_functions) if x==504]; 192 for i in pos: data[i]=ThicknessAlongGradientEnum() 193 pos=[i for i,x in enumerate(self.cost_functions) if x==505]; 194 for i in pos: data[i]=ThicknessAcrossGradientEnum() 191 data=marshallcostfunctions(self.cost_functions) 195 192 WriteData(fid,'data',numpy.array(data).reshape(1,-1),'enum',InversionCostFunctionsEnum(),'format','DoubleMat','mattype',3) 196 193 WriteData(fid,'data',num_cost_functions,'enum',InversionNumCostFunctionsEnum(),'format','Integer') -
issm/trunk/src/m/classes/inversionvalidation.m
r18301 r19105 9 9 incomplete_adjoint = 0 10 10 control_parameters = NaN 11 control_scaling_factors = NaN 11 12 cost_functions = NaN 12 13 cost_functions_coefficients = NaN … … 18 19 vel_obs = NaN 19 20 thickness_obs = NaN 21 surface_obs = NaN 20 22 end 21 23 methods 22 function obj = inversionvalidation(varargin) % {{{ 24 function self = extrude(self,md) % {{{ 25 self.vx_obs=project3d(md,'vector',self.vx_obs,'type','node'); 26 self.vy_obs=project3d(md,'vector',self.vy_obs,'type','node'); 27 self.vel_obs=project3d(md,'vector',self.vel_obs,'type','node'); 28 self.thickness_obs=project3d(md,'vector',self.thickness_obs,'type','node'); 29 if numel(self.cost_functions_coefficients)>1,self.cost_functions_coefficients=project3d(md,'vector',self.cost_functions_coefficients,'type','node');end; 30 if numel(self.min_parameters)>1,self.min_parameters=project3d(md,'vector',self.min_parameters,'type','node');end; 31 if numel(self.max_parameters)>1,self.max_parameters=project3d(md,'vector',self.max_parameters,'type','node');end; 32 end % }}} 33 function self = inversionvalidation(varargin) % {{{ 23 34 switch nargin 24 35 case 0 25 obj=setdefaultparameters(obj);36 self=setdefaultparameters(self); 26 37 case 1 27 obj=structtoobj(inversionvalidation(),varargin{1});38 self=structtoobj(inversionvalidation(),varargin{1}); 28 39 otherwise 29 40 error('constructor not supported'); … … 39 50 self.control_parameters={'FrictionCoefficient'}; 40 51 52 %Scaling factor for each control 53 self.control_scaling_factors=1; 54 41 55 %several responses can be used: 42 56 self.cost_functions=101; 43 57 end % }}} 44 function md = checkconsistency( obj,md,solution,analyses) % {{{58 function md = checkconsistency(self,md,solution,analyses) % {{{ 45 59 46 60 %Early return 47 if ~ obj.iscontrol, return; end61 if ~self.iscontrol, return; end 48 62 49 63 num_controls=numel(md.inversion.control_parameters); … … 52 66 md = checkfield(md,'fieldname','inversion.iscontrol','values',[0 1]); 53 67 md = checkfield(md,'fieldname','inversion.incomplete_adjoint','values',[0 1]); 54 md = checkfield(md,'fieldname','inversion.control_parameters','cell',1,'values', ...55 {'BalancethicknessThickeningRate' 'FrictionCoefficient' 'MaterialsRheologyBbar' 'MaterialsRheologyZbar' 'Vx' 'Vy' 'Thickness' 'BalancethicknessApparentMassbalance'});56 md = checkfield(md,'fieldname','inversion.cost_functions','size',[1 num_costfunc],'values', [101:105 201 501:507]);68 md = checkfield(md,'fieldname','inversion.control_parameters','cell',1,'values',supportedcontrols()); 69 md = checkfield(md,'fieldname','inversion.control_scaling_factors','size',[1 num_controls],'>',0,'NaN',1); 70 md = checkfield(md,'fieldname','inversion.cost_functions','size',[1 num_costfunc],'values',supportedcostfunctions()); 57 71 md = checkfield(md,'fieldname','inversion.cost_functions_coefficients','size',[md.mesh.numberofvertices num_costfunc],'>=',0); 58 72 md = checkfield(md,'fieldname','inversion.min_parameters','size',[md.mesh.numberofvertices num_controls]); … … 70 84 end 71 85 end % }}} 72 function disp( obj) % {{{86 function disp(self) % {{{ 73 87 disp(sprintf(' inversionvalidation parameters:')); 74 fielddisplay(obj,'iscontrol','is inversion activated?'); 75 fielddisplay(obj,'incomplete_adjoint','1: linear viscosity, 0: non-linear viscosity'); 76 fielddisplay(obj,'control_parameters','ex: {''FrictionCoefficient''}, or {''MaterialsRheologyBbar''}'); 77 fielddisplay(obj,'cost_functions','indicate the type of response for each optimization step'); 78 fielddisplay(obj,'cost_functions_coefficients','cost_functions_coefficients applied to the misfit of each vertex and for each control_parameter'); 79 fielddisplay(obj,'min_parameters','absolute minimum acceptable value of the inversed parameter on each vertex'); 80 fielddisplay(obj,'max_parameters','absolute maximum acceptable value of the inversed parameter on each vertex'); 81 fielddisplay(obj,'vx_obs','observed velocity x component [m/yr]'); 82 fielddisplay(obj,'vy_obs','observed velocity y component [m/yr]'); 83 fielddisplay(obj,'vel_obs','observed velocity magnitude [m/yr]'); 84 fielddisplay(obj,'thickness_obs','observed thickness [m]'); 88 fielddisplay(self,'iscontrol','is inversion activated?'); 89 fielddisplay(self,'incomplete_adjoint','1: linear viscosity, 0: non-linear viscosity'); 90 fielddisplay(self,'control_parameters','ex: {''FrictionCoefficient''}, or {''MaterialsRheologyBbar''}'); 91 fielddisplay(self,'control_scaling_factors','order of magnitude of each control (useful for multi-parameter optimization)'); 92 fielddisplay(self,'cost_functions','indicate the type of response for each optimization step'); 93 fielddisplay(self,'cost_functions_coefficients','cost_functions_coefficients applied to the misfit of each vertex and for each control_parameter'); 94 fielddisplay(self,'min_parameters','absolute minimum acceptable value of the inversed parameter on each vertex'); 95 fielddisplay(self,'max_parameters','absolute maximum acceptable value of the inversed parameter on each vertex'); 96 fielddisplay(self,'vx_obs','observed velocity x component [m/yr]'); 97 fielddisplay(self,'vy_obs','observed velocity y component [m/yr]'); 98 fielddisplay(self,'vel_obs','observed velocity magnitude [m/yr]'); 99 fielddisplay(self,'thickness_obs','observed thickness [m]'); 100 fielddisplay(self,'surface_obs','observed surface elevation [m]'); 85 101 disp('Available cost functions:'); 86 102 disp(' 101: SurfaceAbsVelMisfit'); … … 94 110 disp(' 503: ThicknessAbsGradient'); 95 111 end % }}} 96 function marshall( obj,md,fid) % {{{112 function marshall(self,md,fid) % {{{ 97 113 98 114 yts=365.0*24.0*3600.0; 99 115 100 WriteData(fid,'object', obj,'class','inversion','fieldname','iscontrol','format','Boolean');116 WriteData(fid,'object',self,'class','inversion','fieldname','iscontrol','format','Boolean'); 101 117 WriteData(fid,'enum',InversionTypeEnum(),'data',3,'format','Integer'); 102 if ~obj.iscontrol, return; end 103 WriteData(fid,'object',obj,'class','inversion','fieldname','incomplete_adjoint','format','Boolean'); 104 WriteData(fid,'object',obj,'class','inversion','fieldname','cost_functions_coefficients','format','DoubleMat','mattype',1); 105 WriteData(fid,'object',obj,'class','inversion','fieldname','min_parameters','format','DoubleMat','mattype',3); 106 WriteData(fid,'object',obj,'class','inversion','fieldname','max_parameters','format','DoubleMat','mattype',3); 107 WriteData(fid,'object',obj,'class','inversion','fieldname','vx_obs','format','DoubleMat','mattype',1,'scale',1./yts); 108 WriteData(fid,'object',obj,'class','inversion','fieldname','vy_obs','format','DoubleMat','mattype',1,'scale',1./yts); 109 WriteData(fid,'object',obj,'class','inversion','fieldname','vz_obs','format','DoubleMat','mattype',1,'scale',1./yts); 110 if(numel(obj.thickness_obs)==md.mesh.numberofelements), 118 if ~self.iscontrol, return; end 119 WriteData(fid,'object',self,'class','inversion','fieldname','incomplete_adjoint','format','Boolean'); 120 WriteData(fid,'object',self,'class','inversion','fieldname','control_scaling_factors','format','DoubleMat','mattype',3); 121 WriteData(fid,'object',self,'class','inversion','fieldname','cost_functions_coefficients','format','DoubleMat','mattype',1); 122 WriteData(fid,'object',self,'class','inversion','fieldname','min_parameters','format','DoubleMat','mattype',3); 123 WriteData(fid,'object',self,'class','inversion','fieldname','max_parameters','format','DoubleMat','mattype',3); 124 WriteData(fid,'object',self,'class','inversion','fieldname','vx_obs','format','DoubleMat','mattype',1,'scale',1./yts); 125 WriteData(fid,'object',self,'class','inversion','fieldname','vy_obs','format','DoubleMat','mattype',1,'scale',1./yts); 126 WriteData(fid,'object',self,'class','inversion','fieldname','vz_obs','format','DoubleMat','mattype',1,'scale',1./yts); 127 if(numel(self.thickness_obs)==md.mesh.numberofelements), 111 128 mattype=2; 112 129 else 113 130 mattype=1; 114 131 end 115 WriteData(fid,'object',obj,'class','inversion','fieldname','thickness_obs','format','DoubleMat','mattype',mattype); 132 WriteData(fid,'object',self,'class','inversion','fieldname','thickness_obs','format','DoubleMat','mattype',mattype); 133 WriteData(fid,'object',self,'class','inversion','fieldname','surface_obs','format','DoubleMat','mattype',mattype); 116 134 117 135 %process control parameters 118 num_control_parameters=numel( obj.control_parameters);136 num_control_parameters=numel(self.control_parameters); 119 137 data=zeros(1,num_control_parameters); 120 138 for i=1:num_control_parameters, 121 data(i)=StringToEnum( obj.control_parameters{i});139 data(i)=StringToEnum(self.control_parameters{i}); 122 140 end 123 141 WriteData(fid,'data',data,'enum',InversionControlParametersEnum(),'format','DoubleMat','mattype',3); … … 125 143 126 144 %process cost functions 127 num_cost_functions=size(obj.cost_functions,2); 128 data=obj.cost_functions; 129 pos=find(obj.cost_functions==101); data(pos)=SurfaceAbsVelMisfitEnum(); 130 pos=find(obj.cost_functions==102); data(pos)=SurfaceRelVelMisfitEnum(); 131 pos=find(obj.cost_functions==103); data(pos)=SurfaceLogVelMisfitEnum(); 132 pos=find(obj.cost_functions==104); data(pos)=SurfaceLogVxVyMisfitEnum(); 133 pos=find(obj.cost_functions==105); data(pos)=SurfaceAverageVelMisfitEnum(); 134 pos=find(obj.cost_functions==201); data(pos)=ThicknessAbsMisfitEnum(); 135 pos=find(obj.cost_functions==501); data(pos)=DragCoefficientAbsGradientEnum(); 136 pos=find(obj.cost_functions==502); data(pos)=RheologyBbarAbsGradientEnum(); 137 pos=find(obj.cost_functions==503); data(pos)=ThicknessAbsGradientEnum(); 138 pos=find(obj.cost_functions==504); data(pos)=ThicknessAlongGradientEnum(); 139 pos=find(obj.cost_functions==505); data(pos)=ThicknessAcrossGradientEnum(); 140 pos=find(obj.cost_functions==506); data(pos)=BalancethicknessMisfitEnum(); 141 pos=find(obj.cost_functions==507); data(pos)=Balancethickness2MisfitEnum(); 145 num_cost_functions=size(self.cost_functions,2); 146 data=marshallcostfunctions(self.cost_functions); 142 147 WriteData(fid,'data',data,'enum',InversionCostFunctionsEnum(),'format','DoubleMat','mattype',3); 143 148 WriteData(fid,'data',num_cost_functions,'enum',InversionNumCostFunctionsEnum(),'format','Integer'); -
issm/trunk/src/m/classes/linearbasalforcings.m
r18301 r19105 13 13 end 14 14 methods 15 function createxml( obj,fid) % {{{15 function createxml(self,fid) % {{{ 16 16 fprintf(fid, '\n\n'); 17 17 fprintf(fid, '%s\n', '<!-- basalforcings -->'); 18 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="melting_rate" type="', class( obj.melting_rate),'" default="', num2str(obj.melting_rate),'">', ' <section name="basalforcings" />',' <help> basal melting rate (positive if melting) [m/yr] </help>','</parameter>');19 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n', '<parameter key ="geothermalflux" type="', class( obj.geothermalflux),'" default="', num2str(obj.geothermalflux),'">', ' <section name="basalforcings" />',' <help> geothermal heat flux [W/m^2] </help>','</parameter>');18 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="melting_rate" type="', class(self.melting_rate),'" default="', num2str(self.melting_rate),'">', ' <section name="basalforcings" />',' <help> basal melting rate (positive if melting) [m/yr] </help>','</parameter>'); 19 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n', '<parameter key ="geothermalflux" type="', class(self.geothermalflux),'" default="', num2str(self.geothermalflux),'">', ' <section name="basalforcings" />',' <help> geothermal heat flux [W/m^2] </help>','</parameter>'); 20 20 21 21 end % }}} 22 function obj= linearbasalforcings(varargin) % {{{22 function self = linearbasalforcings(varargin) % {{{ 23 23 switch nargin 24 24 case 0 25 obj=setdefaultparameters(obj);25 self=setdefaultparameters(self); 26 26 case 1 27 obj=structtoobj(linearbasalforcings(),varargin{1});27 self=structtoobj(linearbasalforcings(),varargin{1}); 28 28 otherwise 29 29 error('constructor not supported'); … … 38 38 39 39 end % }}} 40 function obj = setdefaultparameters(obj) % {{{40 function self = setdefaultparameters(self) % {{{ 41 41 42 42 %default values for melting parameterization 43 obj.deepwater_melting_rate = 50;44 obj.deepwater_elevation = -800;45 obj.upperwater_elevation = -400;43 self.deepwater_melting_rate = 50; 44 self.deepwater_elevation = -800; 45 self.upperwater_elevation = -400; 46 46 47 47 end % }}} 48 function md = checkconsistency( obj,md,solution,analyses) % {{{48 function md = checkconsistency(self,md,solution,analyses) % {{{ 49 49 50 50 if ismember(MasstransportAnalysisEnum(),analyses) & ~(solution==TransientSolutionEnum() & md.transient.ismasstransport==0), 51 md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,' forcing',1);51 md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'timeseries',1); 52 52 md = checkfield(md,'fieldname','basalforcings.deepwater_melting_rate','>=',0,'numel',1); 53 53 md = checkfield(md,'fieldname','basalforcings.deepwater_elevation','<','basalforcings.upperwater_elevation','numel',1); … … 61 61 end 62 62 if ismember(ThermalAnalysisEnum(),analyses) & ~(solution==TransientSolutionEnum() & md.transient.isthermal==0), 63 md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,' forcing',1);63 md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'timeseries',1); 64 64 md = checkfield(md,'fieldname','basalforcings.deepwater_melting_rate','>=',0,'numel',1); 65 65 md = checkfield(md,'fieldname','basalforcings.deepwater_elevation','<','basalforcings.upperwater_elevation','numel',1); 66 66 md = checkfield(md,'fieldname','basalforcings.upperwater_elevation','<',0,'numel',1); 67 md = checkfield(md,'fieldname','basalforcings.geothermalflux','NaN',1,' forcing',1,'>=',0);67 md = checkfield(md,'fieldname','basalforcings.geothermalflux','NaN',1,'timeseries',1,'>=',0); 68 68 end 69 69 end % }}} 70 function disp( obj) % {{{70 function disp(self) % {{{ 71 71 disp(sprintf(' basal forcings parameters:')); 72 72 73 fielddisplay( obj,'groundedice_melting_rate','basal melting rate (positive if melting) [m/yr]');74 fielddisplay( obj,'deepwater_melting_rate','basal melting rate (positive if melting applied for floating ice whith base < deepwater_elevation) [m/yr]');75 fielddisplay( obj,'deepwater_elevation','elevation of ocean deepwater [m]');76 fielddisplay( obj,'upperwater_elevation','elevation of ocean upperwater [m]');77 fielddisplay( obj,'geothermalflux','geothermal heat flux [W/m^2]');73 fielddisplay(self,'groundedice_melting_rate','basal melting rate (positive if melting) [m/yr]'); 74 fielddisplay(self,'deepwater_melting_rate','basal melting rate (positive if melting applied for floating ice whith base < deepwater_elevation) [m/yr]'); 75 fielddisplay(self,'deepwater_elevation','elevation of ocean deepwater [m]'); 76 fielddisplay(self,'upperwater_elevation','elevation of ocean upperwater [m]'); 77 fielddisplay(self,'geothermalflux','geothermal heat flux [W/m^2]'); 78 78 79 79 end % }}} 80 function marshall( obj,md,fid) % {{{80 function marshall(self,md,fid) % {{{ 81 81 82 82 yts=365.0*24.0*3600.0; … … 87 87 floatingice_melting_rate(pos)=md.basalforcings.deepwater_melting_rate*(md.geometry.base(pos)-md.basalforcings.upperwater_elevation)/(md.basalforcings.deepwater_elevation-md.basalforcings.upperwater_elevation); 88 88 WriteData(fid,'enum',BasalforcingsEnum(),'data',LinearFloatingMeltRateEnum(),'format','Integer'); 89 WriteData(fid,'data',floatingice_melting_rate,'format','DoubleMat','enum',BasalforcingsFloatingiceMeltingRateEnum(),'mattype',1,'scale',1./yts,' forcinglength',md.mesh.numberofvertices+1)90 WriteData(fid,'object', obj,'fieldname','groundedice_melting_rate','format','DoubleMat','enum',BasalforcingsGroundediceMeltingRateEnum(),'mattype',1,'scale',1./yts,'forcinglength',md.mesh.numberofvertices+1)91 WriteData(fid,'object', obj,'fieldname','geothermalflux','enum',BasalforcingsGeothermalfluxEnum(),'format','DoubleMat','mattype',1,'forcinglength',md.mesh.numberofvertices+1);92 WriteData(fid,'object', obj,'fieldname','deepwater_melting_rate','format','Double','enum',BasalforcingsDeepwaterMeltingRateEnum(),'scale',1./yts)93 WriteData(fid,'object', obj,'fieldname','deepwater_elevation','format','Double','enum',BasalforcingsDeepwaterElevationEnum())94 WriteData(fid,'object', obj,'fieldname','upperwater_elevation','format','Double','enum',BasalforcingsUpperwaterElevationEnum())89 WriteData(fid,'data',floatingice_melting_rate,'format','DoubleMat','enum',BasalforcingsFloatingiceMeltingRateEnum(),'mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1) 90 WriteData(fid,'object',self,'fieldname','groundedice_melting_rate','format','DoubleMat','enum',BasalforcingsGroundediceMeltingRateEnum(),'mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1) 91 WriteData(fid,'object',self,'fieldname','geothermalflux','enum',BasalforcingsGeothermalfluxEnum(),'format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1); 92 WriteData(fid,'object',self,'fieldname','deepwater_melting_rate','format','Double','enum',BasalforcingsDeepwaterMeltingRateEnum(),'scale',1./yts) 93 WriteData(fid,'object',self,'fieldname','deepwater_elevation','format','Double','enum',BasalforcingsDeepwaterElevationEnum()) 94 WriteData(fid,'object',self,'fieldname','upperwater_elevation','format','Double','enum',BasalforcingsUpperwaterElevationEnum()) 95 95 end % }}} 96 96 end -
issm/trunk/src/m/classes/linearbasalforcings.py
r18301 r19105 69 69 70 70 if MasstransportAnalysisEnum() in analyses and not (solution==TransientSolutionEnum() and not md.transient.ismasstransport): 71 md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,' forcing',1)71 md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'timeseries',1) 72 72 md = checkfield(md,'fieldname','basalforcings.deepwater_melting_rate','>=',0); 73 73 md = checkfield(md,'fieldname','basalforcings.deepwater_elevation','<',md.basalforcings.upperwater_elevation); … … 81 81 82 82 if ThermalAnalysisEnum() in analyses and not (solution==TransientSolutionEnum() and not md.transient.isthermal): 83 md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,' forcing',1)83 md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'timeseries',1) 84 84 md = checkfield(md,'fieldname','basalforcings.deepwater_melting_rate','>=',0); 85 85 md = checkfield(md,'fieldname','basalforcings.deepwater_elevation','<',md.basalforcings.upperwater_elevation); 86 86 md = checkfield(md,'fieldname','basalforcings.upperwater_elevation','<',0); 87 md = checkfield(md,'fieldname','basalforcings.geothermalflux','NaN',1,' forcing',1,'>=',0)87 md = checkfield(md,'fieldname','basalforcings.geothermalflux','NaN',1,'timeseries',1,'>=',0) 88 88 89 89 return md … … 100 100 101 101 WriteData(fid,'enum',BasalforcingsEnum(),'data',LinearFloatingMeltRateEnum(),'format','Integer'); 102 WriteData(fid,'object',self,'fieldname','groundedice_melting_rate','enum',BasalforcingsGroundediceMeltingRateEnum(),'format','DoubleMat','mattype',1,'scale',1./yts,' forcinglength',md.mesh.numberofvertices+1)103 WriteData(fid,'data',floatingice_melting_rate,'enum',BasalforcingsFloatingiceMeltingRateEnum(),'format','DoubleMat','mattype',1,'scale',1./yts,' forcinglength',md.mesh.numberofvertices+1)104 WriteData(fid,'object',self,'fieldname','geothermalflux','enum',BasalforcingsGeothermalfluxEnum(),'format','DoubleMat','mattype',1,' forcinglength',md.mesh.numberofvertices+1)102 WriteData(fid,'object',self,'fieldname','groundedice_melting_rate','enum',BasalforcingsGroundediceMeltingRateEnum(),'format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1) 103 WriteData(fid,'data',floatingice_melting_rate,'enum',BasalforcingsFloatingiceMeltingRateEnum(),'format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1) 104 WriteData(fid,'object',self,'fieldname','geothermalflux','enum',BasalforcingsGeothermalfluxEnum(),'format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1) 105 105 WriteData(fid,'object',self,'fieldname','deepwater_melting_rate','enum',BasalforcingsDeepwaterMeltingRateEnum(),'format','Double','scale',1./yts) 106 106 WriteData(fid,'object',self,'fieldname','deepwater_elevation','enum',BasalforcingsDeepwaterElevationEnum(),'format','Double') -
issm/trunk/src/m/classes/m1qn3inversion.m
r18301 r19105 9 9 incomplete_adjoint = 0 10 10 control_parameters = NaN 11 control_scaling_factors = NaN 11 12 maxsteps = 0 12 13 maxiter = 0 13 dxmin = 0 ;14 gttol = 0 ;14 dxmin = 0 15 gttol = 0 15 16 cost_functions = NaN 16 17 cost_functions_coefficients = NaN … … 22 23 vel_obs = NaN 23 24 thickness_obs = NaN 25 surface_obs = NaN 24 26 25 27 end 26 28 methods 27 function obj= m1qn3inversion(varargin) % {{{29 function self = m1qn3inversion(varargin) % {{{ 28 30 switch nargin 29 31 case 0 30 obj=setdefaultparameters(obj);32 self=setdefaultparameters(self); 31 33 case 1 32 obj=structtoobj(m1qn3inversion(),varargin{1});34 self=structtoobj(m1qn3inversion(),varargin{1}); 33 35 otherwise 34 36 error('constructor not supported'); 35 37 end 38 end % }}} 39 function self = extrude(self,md) % {{{ 40 self.vx_obs=project3d(md,'vector',self.vx_obs,'type','node'); 41 self.vy_obs=project3d(md,'vector',self.vy_obs,'type','node'); 42 self.vel_obs=project3d(md,'vector',self.vel_obs,'type','node'); 43 self.thickness_obs=project3d(md,'vector',self.thickness_obs,'type','node'); 44 if numel(self.cost_functions_coefficients)>1,self.cost_functions_coefficients=project3d(md,'vector',self.cost_functions_coefficients,'type','node');end; 45 if numel(self.min_parameters)>1,self.min_parameters=project3d(md,'vector',self.min_parameters,'type','node');end; 46 if numel(self.max_parameters)>1,self.max_parameters=project3d(md,'vector',self.max_parameters,'type','node');end; 36 47 end % }}} 37 48 function self = setdefaultparameters(self) % {{{ … … 43 54 %drag and B are supported yet) 44 55 self.control_parameters={'FrictionCoefficient'}; 56 57 %Scaling factor for each control 58 self.control_scaling_factors=1; 45 59 46 60 %number of iterations … … 56 70 57 71 end % }}} 58 function md = checkconsistency( obj,md,solution,analyses) % {{{72 function md = checkconsistency(self,md,solution,analyses) % {{{ 59 73 60 74 %Early return 61 if ~ obj.iscontrol, return; end75 if ~self.iscontrol, return; end 62 76 63 77 if ~IssmConfig('_HAVE_M1QN3_'), 64 78 md = checkmessage(md,['M1QN3 has not been installed, ISSM needs to be reconfigured and recompiled with M1QN3']); 65 79 end 66 67 80 num_controls=numel(md.inversion.control_parameters); 68 81 num_costfunc=size(md.inversion.cost_functions,2); … … 70 83 md = checkfield(md,'fieldname','inversion.iscontrol','values',[0 1]); 71 84 md = checkfield(md,'fieldname','inversion.incomplete_adjoint','values',[0 1]); 72 md = checkfield(md,'fieldname','inversion.control_parameters','cell',1,'values', ...73 {'BalancethicknessThickeningRate' 'FrictionCoefficient' 'MaterialsRheologyBbar' 'MaterialsRheologyZbar' 'Vx' 'Vy' 'Thickness' 'BalancethicknessApparentMassbalance'});85 md = checkfield(md,'fieldname','inversion.control_parameters','cell',1,'values',supportedcontrols()); 86 md = checkfield(md,'fieldname','inversion.control_scaling_factors','size',[1 num_controls],'>',0,'NaN',1); 74 87 md = checkfield(md,'fieldname','inversion.maxsteps','numel',1,'>=',0); 75 88 md = checkfield(md,'fieldname','inversion.maxiter','numel',1,'>=',0); 76 89 md = checkfield(md,'fieldname','inversion.dxmin','numel',1,'>',0); 77 90 md = checkfield(md,'fieldname','inversion.gttol','numel',1,'>',0); 78 md = checkfield(md,'fieldname','inversion.cost_functions','size',[1 num_costfunc],'values', [101:105 201 501:507]);91 md = checkfield(md,'fieldname','inversion.cost_functions','size',[1 num_costfunc],'values',supportedcostfunctions()); 79 92 md = checkfield(md,'fieldname','inversion.cost_functions_coefficients','size',[md.mesh.numberofvertices num_costfunc],'>=',0); 80 93 md = checkfield(md,'fieldname','inversion.min_parameters','size',[md.mesh.numberofvertices num_controls]); … … 83 96 if solution==BalancethicknessSolutionEnum() 84 97 md = checkfield(md,'fieldname','inversion.thickness_obs','size',[md.mesh.numberofvertices 1],'NaN',1); 98 md = checkfield(md,'fieldname','inversion.surface_obs','size',[md.mesh.numberofvertices 1],'NaN',1); 85 99 elseif solution==BalancethicknessSoftSolutionEnum() 86 100 md = checkfield(md,'fieldname','inversion.thickness_obs','size',[md.mesh.numberofvertices 1],'NaN',1); … … 92 106 end 93 107 end % }}} 94 function disp( obj) % {{{108 function disp(self) % {{{ 95 109 disp(sprintf(' m1qn3inversion parameters:')); 96 fielddisplay(obj,'iscontrol','is inversion activated?'); 97 fielddisplay(obj,'incomplete_adjoint','1: linear viscosity, 0: non-linear viscosity'); 98 fielddisplay(obj,'control_parameters','ex: {''FrictionCoefficient''}, or {''MaterialsRheologyBbar''}'); 99 fielddisplay(obj,'maxsteps','maximum number of iterations (gradient computation)'); 100 fielddisplay(obj,'maxiter','maximum number of Function evaluation (forward run)'); 101 fielddisplay(obj,'dxmin','convergence criterion: two points less than dxmin from eachother (sup-norm) are considered identical'); 102 fielddisplay(obj,'gttol','convergence criterion: ||g(X)||/||g(X0)|| (g(X0): gradient at initial guess X0)'); 103 fielddisplay(obj,'cost_functions','indicate the type of response for each optimization step'); 104 fielddisplay(obj,'cost_functions_coefficients','cost_functions_coefficients applied to the misfit of each vertex and for each control_parameter'); 105 fielddisplay(obj,'min_parameters','absolute minimum acceptable value of the inversed parameter on each vertex'); 106 fielddisplay(obj,'max_parameters','absolute maximum acceptable value of the inversed parameter on each vertex'); 107 fielddisplay(obj,'vx_obs','observed velocity x component [m/yr]'); 108 fielddisplay(obj,'vy_obs','observed velocity y component [m/yr]'); 109 fielddisplay(obj,'vel_obs','observed velocity magnitude [m/yr]'); 110 fielddisplay(obj,'thickness_obs','observed thickness [m]'); 110 fielddisplay(self,'iscontrol','is inversion activated?'); 111 fielddisplay(self,'incomplete_adjoint','1: linear viscosity, 0: non-linear viscosity'); 112 fielddisplay(self,'control_parameters','ex: {''FrictionCoefficient''}, or {''MaterialsRheologyBbar''}'); 113 fielddisplay(self,'control_scaling_factors','order of magnitude of each control (useful for multi-parameter optimization)'); 114 fielddisplay(self,'maxsteps','maximum number of iterations (gradient computation)'); 115 fielddisplay(self,'maxiter','maximum number of Function evaluation (forward run)'); 116 fielddisplay(self,'dxmin','convergence criterion: two points less than dxmin from eachother (sup-norm) are considered identical'); 117 fielddisplay(self,'gttol','convergence criterion: ||g(X)||/||g(X0)|| (g(X0): gradient at initial guess X0)'); 118 fielddisplay(self,'cost_functions','indicate the type of response for each optimization step'); 119 fielddisplay(self,'cost_functions_coefficients','cost_functions_coefficients applied to the misfit of each vertex and for each control_parameter'); 120 fielddisplay(self,'min_parameters','absolute minimum acceptable value of the inversed parameter on each vertex'); 121 fielddisplay(self,'max_parameters','absolute maximum acceptable value of the inversed parameter on each vertex'); 122 fielddisplay(self,'vx_obs','observed velocity x component [m/yr]'); 123 fielddisplay(self,'vy_obs','observed velocity y component [m/yr]'); 124 fielddisplay(self,'vel_obs','observed velocity magnitude [m/yr]'); 125 fielddisplay(self,'thickness_obs','observed thickness [m]'); 126 fielddisplay(self,'surface_obs','observed surface elevation [m]'); 111 127 disp('Available cost functions:'); 112 128 disp(' 101: SurfaceAbsVelMisfit'); … … 120 136 disp(' 503: ThicknessAbsGradient'); 121 137 end % }}} 122 function marshall( obj,md,fid) % {{{138 function marshall(self,md,fid) % {{{ 123 139 124 140 yts=365.0*24.0*3600.0; 125 141 126 WriteData(fid,'object', obj,'class','inversion','fieldname','iscontrol','format','Boolean');142 WriteData(fid,'object',self,'class','inversion','fieldname','iscontrol','format','Boolean'); 127 143 WriteData(fid,'enum',InversionTypeEnum(),'data',2,'format','Integer'); 128 if ~obj.iscontrol, return; end 129 WriteData(fid,'object',obj,'class','inversion','fieldname','incomplete_adjoint','format','Boolean'); 130 WriteData(fid,'object',obj,'class','inversion','fieldname','maxsteps','format','Integer'); 131 WriteData(fid,'object',obj,'class','inversion','fieldname','maxiter','format','Integer'); 132 WriteData(fid,'object',obj,'class','inversion','fieldname','dxmin','format','Double'); 133 WriteData(fid,'object',obj,'class','inversion','fieldname','gttol','format','Double'); 134 WriteData(fid,'object',obj,'class','inversion','fieldname','cost_functions_coefficients','format','DoubleMat','mattype',1); 135 WriteData(fid,'object',obj,'class','inversion','fieldname','min_parameters','format','DoubleMat','mattype',3); 136 WriteData(fid,'object',obj,'class','inversion','fieldname','max_parameters','format','DoubleMat','mattype',3); 137 WriteData(fid,'object',obj,'class','inversion','fieldname','vx_obs','format','DoubleMat','mattype',1,'scale',1./yts); 138 WriteData(fid,'object',obj,'class','inversion','fieldname','vy_obs','format','DoubleMat','mattype',1,'scale',1./yts); 139 WriteData(fid,'object',obj,'class','inversion','fieldname','vz_obs','format','DoubleMat','mattype',1,'scale',1./yts); 140 if(numel(obj.thickness_obs)==md.mesh.numberofelements), 144 if ~self.iscontrol, return; end 145 WriteData(fid,'object',self,'class','inversion','fieldname','incomplete_adjoint','format','Boolean'); 146 WriteData(fid,'object',self,'class','inversion','fieldname','control_scaling_factors','format','DoubleMat','mattype',3); 147 WriteData(fid,'object',self,'class','inversion','fieldname','maxsteps','format','Integer'); 148 WriteData(fid,'object',self,'class','inversion','fieldname','maxiter','format','Integer'); 149 WriteData(fid,'object',self,'class','inversion','fieldname','dxmin','format','Double'); 150 WriteData(fid,'object',self,'class','inversion','fieldname','gttol','format','Double'); 151 WriteData(fid,'object',self,'class','inversion','fieldname','cost_functions_coefficients','format','DoubleMat','mattype',1); 152 WriteData(fid,'object',self,'class','inversion','fieldname','min_parameters','format','DoubleMat','mattype',3); 153 WriteData(fid,'object',self,'class','inversion','fieldname','max_parameters','format','DoubleMat','mattype',3); 154 WriteData(fid,'object',self,'class','inversion','fieldname','vx_obs','format','DoubleMat','mattype',1,'scale',1./yts); 155 WriteData(fid,'object',self,'class','inversion','fieldname','vy_obs','format','DoubleMat','mattype',1,'scale',1./yts); 156 WriteData(fid,'object',self,'class','inversion','fieldname','vz_obs','format','DoubleMat','mattype',1,'scale',1./yts); 157 if(numel(self.thickness_obs)==md.mesh.numberofelements), 141 158 mattype=2; 142 159 else 143 160 mattype=1; 144 161 end 145 WriteData(fid,'object',obj,'class','inversion','fieldname','thickness_obs','format','DoubleMat','mattype',mattype); 162 WriteData(fid,'object',self,'class','inversion','fieldname','thickness_obs','format','DoubleMat','mattype',mattype); 163 WriteData(fid,'object',self,'class','inversion','fieldname','surface_obs','format','DoubleMat','mattype',mattype); 146 164 147 165 %process control parameters 148 num_control_parameters=numel( obj.control_parameters);166 num_control_parameters=numel(self.control_parameters); 149 167 data=zeros(1,num_control_parameters); 150 168 for i=1:num_control_parameters, 151 data(i)=StringToEnum( obj.control_parameters{i});169 data(i)=StringToEnum(self.control_parameters{i}); 152 170 end 153 171 WriteData(fid,'data',data,'enum',InversionControlParametersEnum(),'format','DoubleMat','mattype',3); … … 155 173 156 174 %process cost functions 157 num_cost_functions=size(obj.cost_functions,2); 158 data=obj.cost_functions; 159 pos=find(obj.cost_functions==101); data(pos)=SurfaceAbsVelMisfitEnum(); 160 pos=find(obj.cost_functions==102); data(pos)=SurfaceRelVelMisfitEnum(); 161 pos=find(obj.cost_functions==103); data(pos)=SurfaceLogVelMisfitEnum(); 162 pos=find(obj.cost_functions==104); data(pos)=SurfaceLogVxVyMisfitEnum(); 163 pos=find(obj.cost_functions==105); data(pos)=SurfaceAverageVelMisfitEnum(); 164 pos=find(obj.cost_functions==201); data(pos)=ThicknessAbsMisfitEnum(); 165 pos=find(obj.cost_functions==501); data(pos)=DragCoefficientAbsGradientEnum(); 166 pos=find(obj.cost_functions==502); data(pos)=RheologyBbarAbsGradientEnum(); 167 pos=find(obj.cost_functions==503); data(pos)=ThicknessAbsGradientEnum(); 168 pos=find(obj.cost_functions==504); data(pos)=ThicknessAlongGradientEnum(); 169 pos=find(obj.cost_functions==505); data(pos)=ThicknessAcrossGradientEnum(); 170 pos=find(obj.cost_functions==506); data(pos)=BalancethicknessMisfitEnum(); 171 pos=find(obj.cost_functions==507); data(pos)=Balancethickness2MisfitEnum(); 175 num_cost_functions=size(self.cost_functions,2); 176 data=marshallcostfunctions(self.cost_functions); 172 177 WriteData(fid,'data',data,'enum',InversionCostFunctionsEnum(),'format','DoubleMat','mattype',3); 173 178 WriteData(fid,'data',num_cost_functions,'enum',InversionNumCostFunctionsEnum(),'format','Integer'); -
issm/trunk/src/m/classes/m1qn3inversion.py
r17989 r19105 1 1 import numpy 2 import copy 2 from project3d import project3d 3 3 from fielddisplay import fielddisplay 4 4 from EnumDefinitions import * … … 6 6 from checkfield import checkfield 7 7 from WriteData import WriteData 8 from supportedcontrols import supportedcontrols 9 from supportedcostfunctions import supportedcostfunctions 10 from marshallcostfunctions import marshallcostfunctions 8 11 9 12 class m1qn3inversion(object): … … 22 25 self.incomplete_adjoint = 0 23 26 self.control_parameters = float('NaN') 27 self.control_scaling_factors = float('NaN') 24 28 self.maxsteps = 0 25 29 self.maxiter = 0 … … 41 45 print 'converting inversion to m1qn3inversion' 42 46 inv=args[0] 47 #first call setdefaultparameters: 48 self.setdefaultparameters() 49 50 #then go fish whatever is available in the inversion object provided to the constructor 43 51 self.iscontrol = inv.iscontrol 44 52 self.incomplete_adjoint = inv.incomplete_adjoint … … 62 70 string="%s\n%s"%(string,fielddisplay(self,'incomplete_adjoint','1: linear viscosity, 0: non-linear viscosity')) 63 71 string="%s\n%s"%(string,fielddisplay(self,'control_parameters','ex: [''FrictionCoefficient''], or [''MaterialsRheologyBbar'']')) 72 string="%s\n%s"%(string,fielddisplay(self,'control_scaling_factors','order of magnitude of each control (useful for multi-parameter optimization)')) 64 73 string="%s\n%s"%(string,fielddisplay(self,'maxsteps','maximum number of iterations (gradient computation)')) 65 74 string="%s\n%s"%(string,fielddisplay(self,'maxiter','maximum number of Function evaluation (forward run)')) … … 86 95 return string 87 96 #}}} 97 def extrude(self,md): # {{{ 98 self.vx_obs=project3d(md,'vector',self.vx_obs,'type','node') 99 self.vy_obs=project3d(md,'vector',self.vy_obs,'type','node') 100 self.vel_obs=project3d(md,'vector',self.vel_obs,'type','node') 101 self.thickness_obs=project3d(md,'vector',self.thickness_obs,'type','node') 102 if not numpy.any(numpy.isnan(self.cost_functions_coefficients)): 103 self.cost_functions_coefficients=project3d(md,'vector',self.cost_functions_coefficients,'type','node') 104 if not numpy.any(numpy.isnan(self.min_parameters)): 105 self.min_parameters=project3d(md,'vector',self.min_parameters,'type','node') 106 if not numpy.any(numpy.isnan(self.max_parameters)): 107 self.max_parameters=project3d(md,'vector',self.max_parameters,'type','node') 108 return self 109 #}}} 88 110 def setdefaultparameters(self): # {{{ 89 111 … … 94 116 #drag and B are supported yet) 95 117 self.control_parameters='FrictionCoefficient' 118 119 #Scaling factor for each control 120 self.control_scaling_factors=1 96 121 97 122 #number of iterations … … 119 144 md = checkfield(md,'fieldname','inversion.iscontrol','values',[0,1]) 120 145 md = checkfield(md,'fieldname','inversion.incomplete_adjoint','values',[0,1]) 121 md = checkfield(md,'fieldname','inversion.control_parameters','cell',1,'values',['BalancethicknessThickeningRate','FrictionCoefficient','MaterialsRheologyBbar','DamageDbar','Vx','Vy','Thickness']) 146 md = checkfield(md,'fieldname','inversion.control_parameters','cell',1,'values',supportedcontrols()) 147 md = checkfield(md,'fieldname','inversion.control_scaling_factors','size',[num_controls],'>',0,'NaN',1) 122 148 md = checkfield(md,'fieldname','inversion.maxsteps','numel',[1],'>=',0) 123 149 md = checkfield(md,'fieldname','inversion.maxiter','numel',[1],'>=',0) 124 150 md = checkfield(md,'fieldname','inversion.dxmin','numel',[1],'>',0.) 125 151 md = checkfield(md,'fieldname','inversion.gttol','numel',[1],'>',0.) 126 md = checkfield(md,'fieldname','inversion.cost_functions','size',[num_costfunc],'values', [101,102,103,104,105,201,501,502,503,504,505])152 md = checkfield(md,'fieldname','inversion.cost_functions','size',[num_costfunc],'values',supportedcostfunctions()) 127 153 md = checkfield(md,'fieldname','inversion.cost_functions_coefficients','size',[md.mesh.numberofvertices,num_costfunc],'>=',0) 128 154 md = checkfield(md,'fieldname','inversion.min_parameters','size',[md.mesh.numberofvertices,num_controls]) … … 146 172 return 147 173 WriteData(fid,'object',self,'class','inversion','fieldname','incomplete_adjoint','format','Boolean') 174 WriteData(fid,'object',self,'class','inversion','fieldname','control_scaling_factors','format','DoubleMat','mattype',3) 148 175 WriteData(fid,'object',self,'class','inversion','fieldname','maxsteps','format','Integer') 149 176 WriteData(fid,'object',self,'class','inversion','fieldname','maxiter','format','Integer') … … 166 193 #process cost functions 167 194 num_cost_functions=numpy.size(self.cost_functions) 168 data=copy.deepcopy(self.cost_functions) 169 pos=[i for i,x in enumerate(self.cost_functions) if x==101]; 170 for i in pos: data[i]=SurfaceAbsVelMisfitEnum() 171 pos=[i for i,x in enumerate(self.cost_functions) if x==102]; 172 for i in pos: data[i]=SurfaceRelVelMisfitEnum() 173 pos=[i for i,x in enumerate(self.cost_functions) if x==103]; 174 for i in pos: data[i]=SurfaceLogVelMisfitEnum() 175 pos=[i for i,x in enumerate(self.cost_functions) if x==104]; 176 for i in pos: data[i]=SurfaceLogVxVyMisfitEnum() 177 pos=[i for i,x in enumerate(self.cost_functions) if x==105]; 178 for i in pos: data[i]=SurfaceAverageVelMisfitEnum() 179 pos=[i for i,x in enumerate(self.cost_functions) if x==201]; 180 for i in pos: data[i]=ThicknessAbsMisfitEnum() 181 pos=[i for i,x in enumerate(self.cost_functions) if x==501]; 182 for i in pos: data[i]=DragCoefficientAbsGradientEnum() 183 pos=[i for i,x in enumerate(self.cost_functions) if x==502]; 184 for i in pos: data[i]=RheologyBbarAbsGradientEnum() 185 pos=[i for i,x in enumerate(self.cost_functions) if x==503]; 186 for i in pos: data[i]=ThicknessAbsGradientEnum() 187 pos=[i for i,x in enumerate(self.cost_functions) if x==504]; 188 for i in pos: data[i]=ThicknessAlongGradientEnum() 189 pos=[i for i,x in enumerate(self.cost_functions) if x==505]; 190 for i in pos: data[i]=ThicknessAcrossGradientEnum() 195 data=marshallcostfunctions(self.cost_functions) 191 196 WriteData(fid,'data',numpy.array(data).reshape(1,-1),'enum',InversionCostFunctionsEnum(),'format','DoubleMat','mattype',3) 192 197 WriteData(fid,'data',num_cost_functions,'enum',InversionNumCostFunctionsEnum(),'format','Integer') -
issm/trunk/src/m/classes/mask.m
r18301 r19105 10 10 end 11 11 methods (Static) 12 function obj = loadobj(obj) % {{{12 function self = loadobj(self) % {{{ 13 13 % This function is directly called by matlab when a model object is 14 14 % loaded. Update old properties here 15 15 16 16 %2014 February 5th 17 if numel( obj.ice_levelset)>1 & all(obj.ice_levelset>=0),17 if numel(self.ice_levelset)>1 & all(self.ice_levelset>=0), 18 18 disp('WARNING: md.mask.ice_levelset>=0, you probably need to change the sign of this levelset'); 19 19 end … … 22 22 end 23 23 methods 24 function createxml(obj,fid) % {{{25 26 27 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="groundedice_levelset" type="',class( obj.groundedice_levelset),'" default="',obj.groundedice_levelset,'">',' <section name="mask" />',' <help> is ice grounded ? grounded ice if > 0, grounding line position if = 0, floating ice if &lt; 0 </help>','</parameter>');28 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n','<parameter key ="ice_levelset" type="',class(obj.ice_levelset),'" default="',obj.ice_levelset,'">',' <section name="mask" />',' <help> presence of ice if > 0, icefront position if = 0, no ice if &lt; 0 </help>','</parameter>');24 function createxml(self,fid) % {{{ 25 fprintf(fid, '\n\n'); 26 fprintf(fid, '%s\n', '<!-- mask -->'); 27 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="groundedice_levelset" type="',class(self.groundedice_levelset),'" default="',self.groundedice_levelset,'">',' <section name="mask" />',' <help> is ice grounded ? grounded ice if > 0, grounding line position if = 0, floating ice if &lt; 0 </help>','</parameter>'); 28 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n','<parameter key ="ice_levelset" type="',class(self.ice_levelset),'" default="',self.ice_levelset,'">',' <section name="mask" />',' <help> presence of ice if > 0, icefront position if = 0, no ice if &lt; 0 </help>','</parameter>'); 29 29 end % }}} 30 function obj = mask(varargin) % {{{ 30 function self = extrude(self,md) % {{{ 31 self.groundedice_levelset=project3d(md,'vector',self.groundedice_levelset,'type','node'); 32 self.ice_levelset=project3d(md,'vector',self.ice_levelset,'type','node'); 33 end % }}} 34 function self = mask(varargin) % {{{ 31 35 switch nargin 32 36 case 0 33 obj=setdefaultparameters(obj);37 self=setdefaultparameters(self); 34 38 otherwise 35 39 error('constructor not supported'); 36 40 end 37 41 end % }}} 38 function obj = setdefaultparameters(obj) % {{{42 function self = setdefaultparameters(self) % {{{ 39 43 40 44 end % }}} 41 function md = checkconsistency( obj,md,solution,analyses) % {{{45 function md = checkconsistency(self,md,solution,analyses) % {{{ 42 46 43 47 md = checkfield(md,'fieldname','mask.groundedice_levelset','size',[md.mesh.numberofvertices 1]); … … 50 54 warning('no ice front provided'); 51 55 end 56 icefront=sum(md.mask.ice_levelset(md.mesh.elements)==0,2); 57 if (max(icefront)==3 & strcmp(elementtype(md.mesh),'Tria')) | (max(icefront==6) & strcmp(elementtype(md.mesh),'Penta')), 58 error('At least one element has all nodes on ice front, change md.mask.ice_levelset to fix it') 59 end 52 60 end % }}} 53 function disp( obj) % {{{61 function disp(self) % {{{ 54 62 disp(sprintf(' masks:')); 55 63 56 fielddisplay( obj,'groundedice_levelset','is ice grounded ? grounded ice if > 0, grounding line position if = 0, floating ice if < 0');57 fielddisplay( obj,'ice_levelset','presence of ice if < 0, icefront position if = 0, no ice if > 0');64 fielddisplay(self,'groundedice_levelset','is ice grounded ? grounded ice if > 0, grounding line position if = 0, floating ice if < 0'); 65 fielddisplay(self,'ice_levelset','presence of ice if < 0, icefront position if = 0, no ice if > 0'); 58 66 end % }}} 59 function marshall( obj,md,fid) % {{{60 WriteData(fid,'object', obj,'fieldname','groundedice_levelset','format','DoubleMat','mattype',1);61 WriteData(fid,'object', obj,'fieldname','ice_levelset','format','DoubleMat','mattype',1);67 function marshall(self,md,fid) % {{{ 68 WriteData(fid,'object',self,'fieldname','groundedice_levelset','format','DoubleMat','mattype',1); 69 WriteData(fid,'object',self,'fieldname','ice_levelset','format','DoubleMat','mattype',1); 62 70 63 71 % get mask of vertices of elements with ice -
issm/trunk/src/m/classes/mask.py
r18301 r19105 1 1 import numpy 2 2 from fielddisplay import fielddisplay 3 from project3d import project3d 3 4 from EnumDefinitions import * 4 5 from checkfield import checkfield … … 28 29 return string 29 30 #}}} 31 def extrude(self,md): # {{{ 32 self.ice_levelset=project3d(md,'vector',self.ice_levelset,'type','node') 33 self.groundedice_levelset=project3d(md,'vector',self.groundedice_levelset,'type','node') 34 return self 35 #}}} 30 36 def setdefaultparameters(self): # {{{ 31 37 return self … … 37 43 if numpy.sum(isice)==0: 38 44 raise TypeError("no ice present in the domain") 45 46 icefront=numpy.sum(md.mask.ice_levelset[md.mesh.elements-1]==0,axis=1) 47 if (max(icefront)==3 and m.strcmp(md.mesh.elementtype(),'Tria')) or (max(icefront==6) and m.strcmp(md.mesh.elementtype(),'Penta')): 48 raise TypeError("At least one element has all nodes on ice front, change md.mask.ice_levelset to fix it") 39 49 40 50 return md -
issm/trunk/src/m/classes/massfluxatgate.m
r16560 r19105 3 3 % Usage: 4 4 % massfluxatgate=massfluxatgate(); 5 % massfluxatgate=massfluxatgate(' GateName','PathToExpFile');5 % massfluxatgate=massfluxatgate('name','GateName','definitionname',Outputdefinition1Enum,'profilename','PathToExpFile'); 6 6 7 7 classdef massfluxatgate 8 8 properties (SetAccess=public) 9 9 %massfluxatgate 10 name = ''; 11 profilename = ''; 10 name = ''; 11 definitionenum = 0; 12 profilename = ''; 12 13 end 13 14 properties (SetAccess=private) 14 segments 15 segments = NaN; 15 16 end 16 17 methods 17 function obj= massfluxatgate(varargin) % {{{18 switch nargin19 case 020 obj=setdefaultparameters(obj);21 case 122 obj.name=varargin{1};23 case 2 24 obj.name=varargin{1};25 obj.profilename=varargin{2};26 otherwise27 error('constructor not supported');18 function self = massfluxatgate(varargin) % {{{ 19 if nargin==0, 20 self=setdefaultparameters(self); 21 else 22 %use provided options to change fields 23 options=pairoptions(varargin{:}); 24 25 %get name 26 self.name=getfieldvalue(options,'name',''); 27 self.definitionenum=getfieldvalue(options,'definitionenum'); 28 self.profilename=getfieldvalue(options,'profilename'); 28 29 end 29 30 end % }}} 30 function obj = setdefaultparameters(obj) % {{{31 function self = setdefaultparameters(self) % {{{ 31 32 end % }}} 32 function md = checkconsistency( obj,md,solution,analyses) % {{{33 function md = checkconsistency(self,md,solution,analyses) % {{{ 33 34 34 if ~ischar( obj.name),35 if ~ischar(self.name), 35 36 error('massfluxatgate error message: ''name'' field should be a string!'); 36 37 end 37 if ~ischar( obj.profilename),38 if ~ischar(self.profilename), 38 39 error('massfluxatgate error message: ''profilename'' field should be a string!'); 39 40 end 41 42 md = checkfield(md,'field',self.definitionenum,'values',[Outputdefinition1Enum():Outputdefinition100Enum()]); 40 43 41 44 %check the profilename points to a file!: 42 if exist( obj.profilename,'file')~=2,45 if exist(self.profilename,'file')~=2, 43 46 error('massfluxatgate error message: file name for profile corresponding to gate does not point to a legitimate file on disk!'); 44 47 end 45 48 end % }}} 46 function disp( obj) % {{{49 function disp(self) % {{{ 47 50 disp(sprintf(' Massfluxatgate:\n')); 48 51 49 fielddisplay(obj,'name','identifier for this massfluxatgate response'); 50 fielddisplay(obj,'profilename','name of file (shapefile or argus file) defining a profile (or gate)'); 52 fielddisplay(self,'name','identifier for this massfluxatgate response'); 53 fielddisplay(self,'profilename','name of file (shapefile or argus file) defining a profile (or gate)'); 54 fielddisplay(self,'definitionenum','enum that identifies this output definition uniquely, from Outputdefinition[1-10]Enum'); 51 55 52 56 end % }}} 53 function marshall( obj,md,fid) % {{{57 function marshall(self,md,fid) % {{{ 54 58 55 59 %before marshalling, we need to create the segments out of the profilename: 56 obj.segments=MeshProfileIntersection(md.mesh.elements,md.mesh.x,md.mesh.y,obj.profilename);60 self.segments=MeshProfileIntersection(md.mesh.elements,md.mesh.x,md.mesh.y,self.profilename); 57 61 58 62 %ok, marshall name and segments: 59 WriteData(fid,'object',obj,'fieldname','name','format','String'); 60 WriteData(fid,'object',obj,'fieldname','segments','format','DoubleMat','mattype',1); 63 WriteData(fid,'object',self,'fieldname','name','format','String'); 64 WriteData(fid,'object',self,'fieldname','definitionenum','format','Integer'); 65 WriteData(fid,'object',self,'fieldname','segments','format','DoubleMat','mattype',1); 61 66 62 67 end % }}} -
issm/trunk/src/m/classes/massfluxatgate.py
r17806 r19105 1 1 from fielddisplay import fielddisplay 2 2 from EnumDefinitions import * 3 from pairoptions import pairoptions 3 4 from checkfield import checkfield 4 5 from WriteData import WriteData … … 14 15 """ 15 16 16 def __init__(self,name,profilename): # {{{ 17 self.name = name 18 self.profilename = profilename 19 self.segments = float('NaN') 17 def __init__(self,*args): # {{{ 18 19 self.name = '' 20 self.definitionenum = 0 21 self.profilename = '' 22 self.segments = float('NaN') 23 24 #set defaults 25 self.setdefaultparameters() 26 27 #use provided options to change fields 28 options=pairoptions(*args) 29 30 #OK get other fields 31 self=options.AssignObjectFields(self) 20 32 21 33 #}}} … … 24 36 string=" Massfluxatgate:" 25 37 string="%s\n%s"%(string,fielddisplay(self,'name','identifier for this massfluxatgate response')) 38 string="%s\n%s"%(string,fielddisplay(self,'definitionenum','enum that identifies this output definition uniquely, from Outputdefinition[1-10]Enum')) 26 39 string="%s\n%s"%(string,fielddisplay(self,'profilename','name of file (shapefile or argus file) defining a profile (or gate)')) 27 40 return string … … 37 50 if not isinstance(self.profilename, basestring): 38 51 raise RuntimeError("massfluxatgate error message: 'profilename' field should be a string!") 52 53 md = checkfield(md,'field',self.definitionenum,'values',[Outputdefinition1Enum(),Outputdefinition2Enum(),Outputdefinition3Enum(),Outputdefinition4Enum(),Outputdefinition5Enum(),Outputdefinition6Enum(),Outputdefinition7Enum(),Outputdefinition8Enum(),Outputdefinition9Enum(),Outputdefinition10Enum()]) 39 54 40 55 #check the profilename points to a file!: … … 51 66 #ok, marshall name and segments: 52 67 WriteData(fid,'object',self,'fieldname','name','format','String') 68 WriteData(fid,'object',self,'fieldname','definitionenum','format','Integer') 53 69 WriteData(fid,'object',self,'fieldname','segments','format','DoubleMat','mattype',1) 54 70 -
issm/trunk/src/m/classes/masstransport.m
r17989 r19105 7 7 properties (SetAccess=public) 8 8 spcthickness = NaN; 9 calvingrate = NaN;10 9 isfreesurface = 0; 11 10 min_thickness = 0; … … 17 16 end 18 17 methods (Static) 19 function obj = loadobj(obj) % {{{18 function self = loadobj(self) % {{{ 20 19 % This function is directly called by matlab when a model object is 21 20 % loaded. If the input is a struct it is an old version of this class and … … 35 34 end 36 35 37 if isstruct( obj)36 if isstruct(self) 38 37 disp('Recovering masstransport from older version'); 39 objstruct = obj; 40 obj = structtoobj(masstransport(),objstruct); 38 self = structtoobj(masstransport(),self); 41 39 end 42 40 end% }}} 43 41 end 44 42 methods 45 function createxml(obj,fid) % {{{ 46 fprintf(fid, '<!-- masstransport -->\n'); 47 48 % Masstransport solution parameters 49 fprintf(fid,'%s\n%s\n%s\n','<frame key="1" label="Masstransport solution parameters">','<section name="masstransport" />'); 50 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="spcthickness" type="',class(obj.spcthickness),'" default="',convert2str(obj.spcthickness),'">',' <section name="masstransport" />',' <help> thickness constraints (NaN means no constraint) [m] </help>',' </parameter>'); 51 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="calvingrate" type="',class(obj.calvingrate),'" default="',convert2str(obj.calvingrate),'">',' <section name="masstransport" />',' <help> calving rate at given location [m/a] </help>',' </parameter>'); 52 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="isfreesurface" type="',class(obj.isfreesurface),'" default="',convert2str(obj.isfreesurface),'">',' <section name="masstransport" />',' <help> do we use free surfaces (FS only) are mass conservation </help>',' </parameter>'); 53 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="min_thickness" type="',class(obj.min_thickness),'" default="',convert2str(obj.min_thickness),'">',' <section name="masstransport" />',' <help> minimum ice thickness allowed [m] </help>',' </parameter>'); 54 55 % hydrostatic_adjustment drop-down (incremental or absolute ) 56 fprintf(fid,'%s\n%s\n%s\n%s\n',' <parameter key ="hydrostatic_adjustment" type="alternative" optional ="false">',' <section name="masstransport" />',' <help> adjustment of ice shelves surface and bed elevations: ''Incremental'' or ''Absolute'' </help>'); 57 fprintf(fid,'%s\n',' <option value="Incremental" type="string" default="true"> </option>'); 58 fprintf(fid,'%s\n%s\n',' <option value="Absolute" type="string" default="false"> </option>','</parameter>'); 59 60 %stabilization drop-down (0, 1, 2, or 3) 61 fprintf(fid,'%s\n%s\n%s\n%s\n',' <parameter key ="stabilization" type="alternative" optional="false">',' <section name="masstransport" />',' <help> 0: no, 1: artificial_diffusivity, 2: streamline upwinding, 3: discontinuous Galerkin </help>'); 62 fprintf(fid,'%s\n',' <option value="0" type="string" default="true"> </option>'); 63 fprintf(fid,'%s\n',' <option value="1" type="string" default="false"> </option>'); 64 fprintf(fid,'%s\n',' <option value="2" type="string" default="false"> </option>'); 65 fprintf(fid,'%s\n%s\n',' <option value="3" type="string" default="false"> </option>','</parameter>'); 66 67 fprintf(fid,'%s\n%s\n','</frame>'); 68 69 %Penalty options 70 fprintf(fid,'%s\n%s\n%s\n','<frame key="2" label="Penalty options">','<section name="masstransport" />'); 71 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vertex_pairing" type="',class(obj.vertex_pairing),'" default="',convert2str(obj.vertex_pairing),'">',' <section name="masstransport" />',' <help> offset used by penalties: penalty = Kmax*10^offset </help>',' </parameter>'); 72 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="penalty_factor" type="',class(obj.penalty_factor),'" default="',convert2str(obj.penalty_factor),'">',' <section name="masstransport" />',' <help> pairs of vertices that are penalized </help>',' </parameter>'); 73 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="requested_outputs" type="',class(obj.requested_outputs),'" default="',convert2str(obj.requested_outputs),'">',' <section name="masstransport" />',' <help> additional outputs requested </help>',' </parameter>'); 74 fprintf(fid,'%s\n%s\n','</frame>'); 75 76 end % }}} 77 function obj = masstransport(varargin) % {{{ 43 function self = masstransport(varargin) % {{{ 78 44 switch nargin 79 45 case 0 80 obj=setdefaultparameters(obj);46 self=setdefaultparameters(self); 81 47 case 1 82 48 inputstruct=varargin{1}; … … 86 52 fieldname = list1{i}; 87 53 if ismember(fieldname,list2), 88 obj.(fieldname) = inputstruct.(fieldname);54 self.(fieldname) = inputstruct.(fieldname); 89 55 end 90 56 end … … 93 59 end 94 60 end % }}} 61 function self = extrude(self,md) % {{{ 62 self.spcthickness=project3d(md,'vector',self.spcthickness,'type','node'); 63 end % }}} 95 64 function list = defaultoutputs(self,md) % {{{ 96 65 … … 98 67 99 68 end % }}} 100 function obj = setdefaultparameters(obj) % {{{69 function self = setdefaultparameters(self) % {{{ 101 70 102 71 %Type of stabilization to use 0:nothing 1:artificial_diffusivity 3:Discontinuous Galerkin 103 obj.stabilization=1;72 self.stabilization=1; 104 73 105 74 %Factor applied to compute the penalties kappa=max(stiffness matrix)*10^penalty_factor 106 obj.penalty_factor=3;75 self.penalty_factor=3; 107 76 108 77 %Minimum ice thickness that can be used 109 obj.min_thickness=1;78 self.min_thickness=1; 110 79 111 80 %Hydrostatic adjustment 112 obj.hydrostatic_adjustment='Absolute';81 self.hydrostatic_adjustment='Absolute'; 113 82 114 83 %default output 115 obj.requested_outputs={'default'};84 self.requested_outputs={'default'}; 116 85 end % }}} 117 function md = checkconsistency( obj,md,solution,analyses) % {{{86 function md = checkconsistency(self,md,solution,analyses) % {{{ 118 87 119 88 %Early return 120 89 if ~ismember(MasstransportAnalysisEnum(),analyses) | (solution==TransientSolutionEnum() & md.transient.ismasstransport==0), return; end 121 90 122 md = checkfield(md,'fieldname','masstransport.spcthickness','forcing',1); 123 if(ismember(LevelsetAnalysisEnum(), analyses) & md.transient.islevelset) 124 md = checkfield(md,'fieldname','masstransport.calvingrate','NaN',1,'size',[md.mesh.numberofvertices 1],'>=',0); 125 end 126 91 md = checkfield(md,'fieldname','masstransport.spcthickness','timeseries',1); 127 92 md = checkfield(md,'fieldname','masstransport.isfreesurface','values',[0 1]); 128 93 md = checkfield(md,'fieldname','masstransport.hydrostatic_adjustment','values',{'Absolute' 'Incremental'}); 129 md = checkfield(md,'fieldname','masstransport.stabilization','values',[0 1 2 3 ]);94 md = checkfield(md,'fieldname','masstransport.stabilization','values',[0 1 2 3 4]); 130 95 md = checkfield(md,'fieldname','masstransport.min_thickness','>',0); 131 96 md = checkfield(md,'fieldname','masstransport.requested_outputs','stringrow',1); 132 97 133 98 end % }}} 134 function disp( obj) % {{{99 function disp(self) % {{{ 135 100 disp(sprintf(' Masstransport solution parameters:')); 136 fielddisplay(obj,'spcthickness','thickness constraints (NaN means no constraint) [m]'); 137 fielddisplay(obj,'calvingrate','calving rate at given location [m/a]'); 138 fielddisplay(obj,'isfreesurface','do we use free surfaces (FS only) are mass conservation'); 139 fielddisplay(obj,'min_thickness','minimum ice thickness allowed [m]'); 140 fielddisplay(obj,'hydrostatic_adjustment','adjustment of ice shelves surface and bed elevations: ''Incremental'' or ''Absolute'' '); 141 fielddisplay(obj,'stabilization','0: no, 1: artificial_diffusivity, 2: streamline upwinding, 3: discontinuous Galerkin'); 101 fielddisplay(self,'spcthickness','thickness constraints (NaN means no constraint) [m]'); 102 fielddisplay(self,'isfreesurface','do we use free surfaces (FS only) are mass conservation'); 103 fielddisplay(self,'min_thickness','minimum ice thickness allowed [m]'); 104 fielddisplay(self,'hydrostatic_adjustment','adjustment of ice shelves surface and bed elevations: ''Incremental'' or ''Absolute'' '); 105 fielddisplay(self,'stabilization','0: no, 1: artificial_diffusivity, 2: streamline upwinding, 3: discontinuous Galerkin, 4: Flux Correction Transport'); 142 106 143 107 disp(sprintf('\n %s','Penalty options:')); 144 fielddisplay( obj,'penalty_factor','offset used by penalties: penalty = Kmax*10^offset');145 fielddisplay( obj,'vertex_pairing','pairs of vertices that are penalized');146 fielddisplay( obj,'requested_outputs','additional outputs requested');108 fielddisplay(self,'penalty_factor','offset used by penalties: penalty = Kmax*10^offset'); 109 fielddisplay(self,'vertex_pairing','pairs of vertices that are penalized'); 110 fielddisplay(self,'requested_outputs','additional outputs requested'); 147 111 148 112 end % }}} 149 function marshall( obj,md,fid) % {{{113 function marshall(self,md,fid) % {{{ 150 114 151 115 yts=365.*24.*3600.; 152 116 153 WriteData(fid,'object',obj,'fieldname','spcthickness','format','DoubleMat','mattype',1,'forcinglength',md.mesh.numberofvertices+1); 154 WriteData(fid,'object',obj,'fieldname','calvingrate','format','DoubleMat','mattype',1,'forcinglength',md.mesh.numberofvertices+1,'scale',1./yts); 155 WriteData(fid,'object',obj,'fieldname','isfreesurface','format','Boolean'); 156 WriteData(fid,'object',obj,'fieldname','min_thickness','format','Double'); 157 WriteData(fid,'data',StringToEnum(obj.hydrostatic_adjustment),'format','Integer','enum',MasstransportHydrostaticAdjustmentEnum()); 158 WriteData(fid,'object',obj,'fieldname','stabilization','format','Integer'); 159 WriteData(fid,'object',obj,'fieldname','vertex_pairing','format','DoubleMat','mattype',3); 160 WriteData(fid,'object',obj,'fieldname','penalty_factor','format','Double'); 117 WriteData(fid,'object',self,'fieldname','spcthickness','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1); 118 WriteData(fid,'object',self,'fieldname','isfreesurface','format','Boolean'); 119 WriteData(fid,'object',self,'fieldname','min_thickness','format','Double'); 120 WriteData(fid,'data',StringToEnum(self.hydrostatic_adjustment),'format','Integer','enum',MasstransportHydrostaticAdjustmentEnum()); 121 WriteData(fid,'object',self,'fieldname','stabilization','format','Integer'); 122 WriteData(fid,'object',self,'fieldname','vertex_pairing','format','DoubleMat','mattype',3); 123 WriteData(fid,'object',self,'fieldname','penalty_factor','format','Double'); 161 124 162 125 %process requested outputs 163 outputs = obj.requested_outputs;126 outputs = self.requested_outputs; 164 127 pos = find(ismember(outputs,'default')); 165 128 if ~isempty(pos), 166 129 outputs(pos) = []; %remove 'default' from outputs 167 outputs = [outputs defaultoutputs( obj,md)]; %add defaults130 outputs = [outputs defaultoutputs(self,md)]; %add defaults 168 131 end 169 132 WriteData(fid,'data',outputs,'enum',MasstransportRequestedOutputsEnum,'format','StringArray'); -
issm/trunk/src/m/classes/masstransport.py
r17806 r19105 1 1 from fielddisplay import fielddisplay 2 from project3d import project3d 2 3 from EnumDefinitions import * 3 4 from StringToEnum import StringToEnum … … 15 16 def __init__(self): # {{{ 16 17 self.spcthickness = float('NaN') 17 self.calvingrate = float('NaN')18 18 self.isfreesurface = 0 19 self.min_thickness = 0 19 self.min_thickness = 0. 20 20 self.hydrostatic_adjustment = 0 21 21 self.stabilization = 0 … … 31 31 string=' Masstransport solution parameters:' 32 32 string="%s\n%s"%(string,fielddisplay(self,'spcthickness','thickness constraints (NaN means no constraint) [m]')) 33 string="%s\n%s"%(string,fielddisplay(self,'calvingrate','calving rate at given location [m/a]'))34 33 string="%s\n%s"%(string,fielddisplay(self,'isfreesurface','do we use free surfaces (FS only) are mass conservation')) 35 34 string="%s\n%s"%(string,fielddisplay(self,'min_thickness','minimum ice thickness allowed [m]')) 36 35 string="%s\n%s"%(string,fielddisplay(self,'hydrostatic_adjustment','adjustment of ice shelves surface and bed elevations: ''Incremental'' or ''Absolute'' ')) 37 string="%s\n%s"%(string,fielddisplay(self,'stabilization','0: no, 1: artificial_diffusivity, 2: streamline upwinding, 3: discontinuous Galerkin '))36 string="%s\n%s"%(string,fielddisplay(self,'stabilization','0: no, 1: artificial_diffusivity, 2: streamline upwinding, 3: discontinuous Galerkin, 4: Flux Correction Transport')) 38 37 string="%s\n%s"%(string,fielddisplay(self,'requested_outputs','additional outputs requested')) 39 38 40 39 return string 41 40 #}}} 41 def extrude(self,md): # {{{ 42 self.spcthickness=project3d(md,'vector',self.spcthickness,'type','node') 43 return self 44 #}}} 42 45 def defaultoutputs(self,md): # {{{ 43 46 … … 46 49 #}}} 47 50 def setdefaultparameters(self): # {{{ 48 51 49 52 #Type of stabilization to use 0:nothing 1:artificial_diffusivity 3:Discontinuous Galerkin 50 53 self.stabilization=1 … … 69 72 return md 70 73 71 md = checkfield(md,'fieldname','masstransport.spcthickness','forcing',1) 72 if LevelsetAnalysisEnum() in analyses and md.transient.islevelset: 73 md = checkfield(md,'fieldname','masstransport.calvingrate','NaN',1,'size',[md.mesh.numberofvertices],'>=',0) 74 md = checkfield(md,'fieldname','masstransport.spcthickness','timeseries',1) 74 75 md = checkfield(md,'fieldname','masstransport.isfreesurface','values',[0,1]) 75 76 md = checkfield(md,'fieldname','masstransport.hydrostatic_adjustment','values',['Absolute','Incremental']) 76 md = checkfield(md,'fieldname','masstransport.stabilization','values',[0,1,2,3 ])77 md = checkfield(md,'fieldname','masstransport.stabilization','values',[0,1,2,3,4]) 77 78 md = checkfield(md,'fieldname','masstransport.min_thickness','>',0) 78 79 md = checkfield(md,'fieldname','masstransport.requested_outputs','stringrow',1) … … 84 85 yts=365.*24.*3600. 85 86 86 WriteData(fid,'object',self,'fieldname','spcthickness','format','DoubleMat','mattype',1,'forcinglength',md.mesh.numberofvertices+1) 87 WriteData(fid,'object',self,'fieldname','calvingrate','format','DoubleMat','mattype',1,'forcinglength',md.mesh.numberofvertices+1,'scale',1./yts) 87 WriteData(fid,'object',self,'fieldname','spcthickness','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1) 88 88 WriteData(fid,'object',self,'fieldname','isfreesurface','format','Boolean') 89 89 WriteData(fid,'object',self,'fieldname','min_thickness','format','Double') -
issm/trunk/src/m/classes/matdamageice.m
r17989 r19105 30 30 end 31 31 methods 32 function createxml( obj,fid) % {{{32 function createxml(self,fid) % {{{ 33 33 fprintf(fid, '\n\n'); 34 34 fprintf(fid, '<!-- materials -->\n'); 35 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="rho_ice" type="',class(obj.rho_ice),'" default="',convert2str(obj.rho_ice),'">',' <section name="materials" />',' <help> ice density [kg/m^3] </help>','</parameter>'); 36 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="rho_water" type="',class(obj.rho_water),'" default="',convert2str(obj.rho_water),'">',' <section name="materials" />',' <help> ocean water density [kg/m^3] </help>','</parameter>'); 37 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="rho_freshwater" type="',class(obj.rho_freshwater),'" default="',convert2str(obj.rho_freshwater),'">',' <section name="materials" />',' <help> fresh water density [kg/m^3] </help>','</parameter>'); 38 39 40 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="mu_water" type="',class(obj.mu_water),'" default="',convert2str(obj.mu_water),'">',' <section name="materials" />',' <help> water viscosity [N s/m^2] </help>','</parameter>'); 41 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="heatcapacity" type="',class(obj.heatcapacity),'" default="',convert2str(obj.heatcapacity),'">',' <section name="materials" />',' <help> heat capacity [J/kg/K] </help>','</parameter>'); 42 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="latentheat" type="',class(obj.latentheat),'" default="',convert2str(obj.latentheat),'">',' <section name="materials" />',' <help> latent heat of fusion [J/kg] </help>','</parameter>'); 43 44 45 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="thermalconductivity" type="',class(obj.thermalconductivity),'" default="',convert2str(obj.thermalconductivity),'">',' <section name="materials" />',' <help> ice thermal conductivity [W/m/K] </help>','</parameter>'); 46 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="temperateiceconductivity" type="',class(obj.temperateiceconductivity),'" default="',convert2str(obj.temperateiceconductivity),'">',' <section name="materials" />',' <help> temperate ice thermal conductivity [W/m/K] </help>','</parameter>'); 47 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="meltingpoint" type="',class(obj.meltingpoint),'" default="',convert2str(obj.meltingpoint),'">',' <section name="materials" />',' <help> melting point of ice at 1atm in K </help>','</parameter>'); 48 49 50 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="beta" type="',class(obj.beta),'" default="',convert2str(obj.beta),'">',' <section name="materials" />',' <help> rate of change of melting point with pressure [K/Pa] </help>','</parameter>'); 51 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="mixed_layer_capacity" type="',class(obj.mixed_layer_capacity),'" default="',convert2str(obj.mixed_layer_capacity),'">',' <section name="materials" />',' <help> mixed layer capacity [W/kg/K] </help>','</parameter>'); 52 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="thermal_exchange_velocity" type="',class(obj.thermal_exchange_velocity),'" default="',convert2str(obj.thermal_exchange_velocity),'">',' <section name="materials" />',' <help> thermal exchange velocity [m/s] </help>','</parameter>'); 53 54 55 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="rheology_B" type="',class(obj.rheology_B),'" default="',convert2str(obj.rheology_B),'">',' <section name="materials" />',' <help> flow law parameter [Pa/s^(1/n)] </help>','</parameter>'); 56 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="rheology_n" type="',class(obj.rheology_n),'" default="',convert2str(obj.rheology_n),'">',' <section name="materials" />',' <help> Glens flow law exponent </help>','</parameter>'); 57 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="rheology_law" type="',class(obj.rheology_law),'" default="',convert2str(obj.rheology_law),'">',' <section name="materials" />',' <help> law for the temperature dependance of the rheology: "None", "Paterson", "Arrhenius" or "LliboutryDuval" </help>','</parameter>'); 58 59 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="lithosphere_shear_modulus" type="',class(obj.lithosphere_shear_modulus),'" default="',convert2str(obj.lithosphere_shear_modulus),'">',' <section name="materials" />',' <help> Lithosphere shear modulus [Pa] </help>','</parameter>'); 60 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="lithosphere_density" type="',class(obj.lithosphere_density),'" default="',convert2str(obj.lithosphere_density),'">',' <section name="materials" />',' <help> Lithosphere density [g/cm^-3] </help>','</parameter>'); 61 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="mantle_shear_modulus" type="',class(obj.mantle_shear_modulus),'" default="',convert2str(obj.mantle_shear_modulus),'">',' <section name="materials" />',' <help> Mantle shear modulus [Pa] </help>','</parameter>'); 62 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="mantle_density" type="',class(obj.mantle_density),'" default="',convert2str(obj.mantle_density),'">',' <section name="materials" />',' <help> Mantle density [g/cm^-3] </help>','</parameter>'); 63 64 65 end % }}} 66 function obj = matdamageice(varargin) % {{{ 35 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="rho_ice" type="',class(self.rho_ice),'" default="',convert2str(self.rho_ice),'">',' <section name="materials" />',' <help> ice density [kg/m^3] </help>','</parameter>'); 36 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="rho_water" type="',class(self.rho_water),'" default="',convert2str(self.rho_water),'">',' <section name="materials" />',' <help> ocean water density [kg/m^3] </help>','</parameter>'); 37 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="rho_freshwater" type="',class(self.rho_freshwater),'" default="',convert2str(self.rho_freshwater),'">',' <section name="materials" />',' <help> fresh water density [kg/m^3] </help>','</parameter>'); 38 39 40 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="mu_water" type="',class(self.mu_water),'" default="',convert2str(self.mu_water),'">',' <section name="materials" />',' <help> water viscosity [N s/m^2] </help>','</parameter>'); 41 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="heatcapacity" type="',class(self.heatcapacity),'" default="',convert2str(self.heatcapacity),'">',' <section name="materials" />',' <help> heat capacity [J/kg/K] </help>','</parameter>'); 42 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="latentheat" type="',class(self.latentheat),'" default="',convert2str(self.latentheat),'">',' <section name="materials" />',' <help> latent heat of fusion [J/kg] </help>','</parameter>'); 43 44 45 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="thermalconductivity" type="',class(self.thermalconductivity),'" default="',convert2str(self.thermalconductivity),'">',' <section name="materials" />',' <help> ice thermal conductivity [W/m/K] </help>','</parameter>'); 46 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="temperateiceconductivity" type="',class(self.temperateiceconductivity),'" default="',convert2str(self.temperateiceconductivity),'">',' <section name="materials" />',' <help> temperate ice thermal conductivity [W/m/K] </help>','</parameter>'); 47 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="meltingpoint" type="',class(self.meltingpoint),'" default="',convert2str(self.meltingpoint),'">',' <section name="materials" />',' <help> melting point of ice at 1atm in K </help>','</parameter>'); 48 49 50 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="beta" type="',class(self.beta),'" default="',convert2str(self.beta),'">',' <section name="materials" />',' <help> rate of change of melting point with pressure [K/Pa] </help>','</parameter>'); 51 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="mixed_layer_capacity" type="',class(self.mixed_layer_capacity),'" default="',convert2str(self.mixed_layer_capacity),'">',' <section name="materials" />',' <help> mixed layer capacity [W/kg/K] </help>','</parameter>'); 52 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="thermal_exchange_velocity" type="',class(self.thermal_exchange_velocity),'" default="',convert2str(self.thermal_exchange_velocity),'">',' <section name="materials" />',' <help> thermal exchange velocity [m/s] </help>','</parameter>'); 53 54 55 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="rheology_B" type="',class(self.rheology_B),'" default="',convert2str(self.rheology_B),'">',' <section name="materials" />',' <help> flow law parameter [Pa/s^(1/n)] </help>','</parameter>'); 56 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="rheology_n" type="',class(self.rheology_n),'" default="',convert2str(self.rheology_n),'">',' <section name="materials" />',' <help> Glens flow law exponent </help>','</parameter>'); 57 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="rheology_law" type="',class(self.rheology_law),'" default="',convert2str(self.rheology_law),'">',' <section name="materials" />',' <help> law for the temperature dependance of the rheology: "None", "Paterson", "Arrhenius" or "LliboutryDuval" </help>','</parameter>'); 58 59 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="lithosphere_shear_modulus" type="',class(self.lithosphere_shear_modulus),'" default="',convert2str(self.lithosphere_shear_modulus),'">',' <section name="materials" />',' <help> Lithosphere shear modulus [Pa] </help>','</parameter>'); 60 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="lithosphere_density" type="',class(self.lithosphere_density),'" default="',convert2str(self.lithosphere_density),'">',' <section name="materials" />',' <help> Lithosphere density [g/cm^-3] </help>','</parameter>'); 61 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="mantle_shear_modulus" type="',class(self.mantle_shear_modulus),'" default="',convert2str(self.mantle_shear_modulus),'">',' <section name="materials" />',' <help> Mantle shear modulus [Pa] </help>','</parameter>'); 62 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="mantle_density" type="',class(self.mantle_density),'" default="',convert2str(self.mantle_density),'">',' <section name="materials" />',' <help> Mantle density [g/cm^-3] </help>','</parameter>'); 63 64 65 end % }}} 66 function self = extrude(self,md) % {{{ 67 self.rheology_B=project3d(md,'vector',self.rheology_B,'type','node'); 68 self.rheology_n=project3d(md,'vector',self.rheology_n,'type','element'); 69 end % }}} 70 function self = matdamageice(varargin) % {{{ 67 71 switch nargin 68 72 case 0 69 obj=setdefaultparameters(obj);73 self=setdefaultparameters(self); 70 74 case 1 71 75 inputstruct=varargin{1}; … … 75 79 fieldname = list1{i}; 76 80 if ismember(fieldname,list2), 77 obj.(fieldname) = inputstruct.(fieldname);81 self.(fieldname) = inputstruct.(fieldname); 78 82 end 79 83 end … … 82 86 end 83 87 end % }}} 84 function obj = setdefaultparameters(obj) % {{{88 function self = setdefaultparameters(self) % {{{ 85 89 86 90 %ice density (kg/m^3) 87 obj.rho_ice=917.;91 self.rho_ice=917.; 88 92 89 93 %ocean water density (kg/m^3) 90 obj.rho_water=1023.;94 self.rho_water=1023.; 91 95 92 96 %fresh water density (kg/m^3) 93 obj.rho_freshwater=1000.;97 self.rho_freshwater=1000.; 94 98 95 99 %water viscosity (N.s/m^2) 96 obj.mu_water=0.001787;100 self.mu_water=0.001787; 97 101 98 102 %ice heat capacity cp (J/kg/K) 99 obj.heatcapacity=2093.;103 self.heatcapacity=2093.; 100 104 101 105 %ice latent heat of fusion L (J/kg) 102 obj.latentheat=3.34*10^5;106 self.latentheat=3.34*10^5; 103 107 104 108 %ice thermal conductivity (W/m/K) 105 obj.thermalconductivity=2.4;109 self.thermalconductivity=2.4; 106 110 107 111 %wet ice thermal conductivity (W/m/K) 108 obj.temperateiceconductivity=.24;112 self.temperateiceconductivity=.24; 109 113 110 114 %the melting point of ice at 1 atmosphere of pressure in K 111 obj.meltingpoint=273.15;115 self.meltingpoint=273.15; 112 116 113 117 %rate of change of melting point with pressure (K/Pa) 114 obj.beta=9.8*10^-8;118 self.beta=9.8*10^-8; 115 119 116 120 %mixed layer (ice-water interface) heat capacity (J/kg/K) 117 obj.mixed_layer_capacity=3974.;121 self.mixed_layer_capacity=3974.; 118 122 119 123 %thermal exchange velocity (ice-water interface) (m/s) 120 obj.thermal_exchange_velocity=1.00*10^-4;124 self.thermal_exchange_velocity=1.00*10^-4; 121 125 122 126 %Rheology law: what is the temperature dependence of B with T 123 127 %available: none, paterson and arrhenius 124 obj.rheology_law='Paterson';128 self.rheology_law='Paterson'; 125 129 126 130 % GIA: 127 obj.lithosphere_shear_modulus = 6.7*10^10; % (Pa)128 obj.lithosphere_density = 3.32; % (g/cm^-3)129 obj.mantle_shear_modulus = 1.45*10^11; % (Pa)130 obj.mantle_density = 3.34; % (g/cm^-3)131 132 end % }}} 133 function md = checkconsistency( obj,md,solution,analyses) % {{{131 self.lithosphere_shear_modulus = 6.7*10^10; % (Pa) 132 self.lithosphere_density = 3.32; % (g/cm^-3) 133 self.mantle_shear_modulus = 1.45*10^11; % (Pa) 134 self.mantle_density = 3.34; % (g/cm^-3) 135 136 end % }}} 137 function md = checkconsistency(self,md,solution,analyses) % {{{ 134 138 md = checkfield(md,'fieldname','materials.rho_ice','>',0); 135 139 md = checkfield(md,'fieldname','materials.rho_water','>',0); … … 148 152 149 153 end % }}} 150 function disp( obj) % {{{154 function disp(self) % {{{ 151 155 disp(sprintf(' Materials:')); 152 156 153 fielddisplay( obj,'rho_ice','ice density [kg/m^3]');154 fielddisplay( obj,'rho_water','ocean water density [kg/m^3]');155 fielddisplay( obj,'rho_freshwater','fresh water density [kg/m^3]');156 fielddisplay( obj,'mu_water','water viscosity [N s/m^2]');157 fielddisplay( obj,'heatcapacity','heat capacity [J/kg/K]');158 fielddisplay( obj,'thermalconductivity',['ice thermal conductivity [W/m/K]']);159 fielddisplay( obj,'temperateiceconductivity','temperate ice thermal conductivity [W/m/K]');160 fielddisplay( obj,'meltingpoint','melting point of ice at 1atm in K');161 fielddisplay( obj,'latentheat','latent heat of fusion [J/kg]');162 fielddisplay( obj,'beta','rate of change of melting point with pressure [K/Pa]');163 fielddisplay( obj,'mixed_layer_capacity','mixed layer capacity [W/kg/K]');164 fielddisplay( obj,'thermal_exchange_velocity','thermal exchange velocity [m/s]');165 fielddisplay( obj,'rheology_B','flow law parameter [Pa/s^(1/n)]');166 fielddisplay( obj,'rheology_n','Glen''s flow law exponent');167 fielddisplay( obj,'rheology_law',['law for the temperature dependance of the rheology: ''None'', ''Cuffey'', ''Paterson'', ''Arrhenius'' or ''LliboutryDuval''']);168 fielddisplay( obj,'lithosphere_shear_modulus','Lithosphere shear modulus [Pa]');169 fielddisplay( obj,'lithosphere_density','Lithosphere density [g/cm^-3]');170 fielddisplay( obj,'mantle_shear_modulus','Mantle shear modulus [Pa]');171 fielddisplay( obj,'mantle_density','Mantle density [g/cm^-3]');172 end % }}} 173 function marshall( obj,md,fid) % {{{157 fielddisplay(self,'rho_ice','ice density [kg/m^3]'); 158 fielddisplay(self,'rho_water','ocean water density [kg/m^3]'); 159 fielddisplay(self,'rho_freshwater','fresh water density [kg/m^3]'); 160 fielddisplay(self,'mu_water','water viscosity [N s/m^2]'); 161 fielddisplay(self,'heatcapacity','heat capacity [J/kg/K]'); 162 fielddisplay(self,'thermalconductivity',['ice thermal conductivity [W/m/K]']); 163 fielddisplay(self,'temperateiceconductivity','temperate ice thermal conductivity [W/m/K]'); 164 fielddisplay(self,'meltingpoint','melting point of ice at 1atm in K'); 165 fielddisplay(self,'latentheat','latent heat of fusion [J/kg]'); 166 fielddisplay(self,'beta','rate of change of melting point with pressure [K/Pa]'); 167 fielddisplay(self,'mixed_layer_capacity','mixed layer capacity [W/kg/K]'); 168 fielddisplay(self,'thermal_exchange_velocity','thermal exchange velocity [m/s]'); 169 fielddisplay(self,'rheology_B','flow law parameter [Pa/s^(1/n)]'); 170 fielddisplay(self,'rheology_n','Glen''s flow law exponent'); 171 fielddisplay(self,'rheology_law',['law for the temperature dependance of the rheology: ''None'', ''Cuffey'', ''Paterson'', ''Arrhenius'' or ''LliboutryDuval''']); 172 fielddisplay(self,'lithosphere_shear_modulus','Lithosphere shear modulus [Pa]'); 173 fielddisplay(self,'lithosphere_density','Lithosphere density [g/cm^-3]'); 174 fielddisplay(self,'mantle_shear_modulus','Mantle shear modulus [Pa]'); 175 fielddisplay(self,'mantle_density','Mantle density [g/cm^-3]'); 176 end % }}} 177 function marshall(self,md,fid) % {{{ 174 178 WriteData(fid,'enum',MaterialsEnum(),'data',MatdamageiceEnum(),'format','Integer'); 175 WriteData(fid,'object', obj,'class','materials','fieldname','rho_ice','format','Double');176 WriteData(fid,'object', obj,'class','materials','fieldname','rho_water','enum',MaterialsRhoSeawaterEnum(),'format','Double');177 WriteData(fid,'object', obj,'class','materials','fieldname','rho_freshwater','format','Double');178 WriteData(fid,'object', obj,'class','materials','fieldname','mu_water','format','Double');179 WriteData(fid,'object', obj,'class','materials','fieldname','heatcapacity','format','Double');180 WriteData(fid,'object', obj,'class','materials','fieldname','latentheat','format','Double');181 WriteData(fid,'object', obj,'class','materials','fieldname','thermalconductivity','format','Double');182 WriteData(fid,'object', obj,'class','materials','fieldname','temperateiceconductivity','format','Double');183 WriteData(fid,'object', obj,'class','materials','fieldname','meltingpoint','format','Double');184 WriteData(fid,'object', obj,'class','materials','fieldname','beta','format','Double');185 WriteData(fid,'object', obj,'class','materials','fieldname','mixed_layer_capacity','format','Double');186 WriteData(fid,'object', obj,'class','materials','fieldname','thermal_exchange_velocity','format','Double');187 WriteData(fid,'object', obj,'class','materials','fieldname','rheology_B','format','DoubleMat','mattype',1);188 WriteData(fid,'object', obj,'class','materials','fieldname','rheology_n','format','DoubleMat','mattype',2);189 WriteData(fid,'data',StringToEnum( obj.rheology_law),'enum',MaterialsRheologyLawEnum(),'format','Integer');190 191 WriteData(fid,'object', obj,'class','materials','fieldname','lithosphere_shear_modulus','format','Double');192 WriteData(fid,'object', obj,'class','materials','fieldname','lithosphere_density','format','Double','scale',10^3);193 WriteData(fid,'object', obj,'class','materials','fieldname','mantle_shear_modulus','format','Double');194 WriteData(fid,'object', obj,'class','materials','fieldname','mantle_density','format','Double','scale',10^3);179 WriteData(fid,'object',self,'class','materials','fieldname','rho_ice','format','Double'); 180 WriteData(fid,'object',self,'class','materials','fieldname','rho_water','enum',MaterialsRhoSeawaterEnum(),'format','Double'); 181 WriteData(fid,'object',self,'class','materials','fieldname','rho_freshwater','format','Double'); 182 WriteData(fid,'object',self,'class','materials','fieldname','mu_water','format','Double'); 183 WriteData(fid,'object',self,'class','materials','fieldname','heatcapacity','format','Double'); 184 WriteData(fid,'object',self,'class','materials','fieldname','latentheat','format','Double'); 185 WriteData(fid,'object',self,'class','materials','fieldname','thermalconductivity','format','Double'); 186 WriteData(fid,'object',self,'class','materials','fieldname','temperateiceconductivity','format','Double'); 187 WriteData(fid,'object',self,'class','materials','fieldname','meltingpoint','format','Double'); 188 WriteData(fid,'object',self,'class','materials','fieldname','beta','format','Double'); 189 WriteData(fid,'object',self,'class','materials','fieldname','mixed_layer_capacity','format','Double'); 190 WriteData(fid,'object',self,'class','materials','fieldname','thermal_exchange_velocity','format','Double'); 191 WriteData(fid,'object',self,'class','materials','fieldname','rheology_B','format','DoubleMat','mattype',1); 192 WriteData(fid,'object',self,'class','materials','fieldname','rheology_n','format','DoubleMat','mattype',2); 193 WriteData(fid,'data',StringToEnum(self.rheology_law),'enum',MaterialsRheologyLawEnum(),'format','Integer'); 194 195 WriteData(fid,'object',self,'class','materials','fieldname','lithosphere_shear_modulus','format','Double'); 196 WriteData(fid,'object',self,'class','materials','fieldname','lithosphere_density','format','Double','scale',10^3); 197 WriteData(fid,'object',self,'class','materials','fieldname','mantle_shear_modulus','format','Double'); 198 WriteData(fid,'object',self,'class','materials','fieldname','mantle_density','format','Double','scale',10^3); 195 199 end % }}} 196 200 end -
issm/trunk/src/m/classes/matdamageice.py
r17989 r19105 1 1 from fielddisplay import fielddisplay 2 from project3d import project3d 2 3 from EnumDefinitions import MaterialsEnum, MatdamageiceEnum, MaterialsRheologyLawEnum, MaterialsRhoSeawaterEnum 3 4 from StringToEnum import StringToEnum … … 63 64 return string 64 65 #}}} 66 def extrude(self,md): # {{{ 67 self.rheology_B=project3d(md,'vector',self.rheology_B,'type','node') 68 self.rheology_n=project3d(md,'vector',self.rheology_n,'type','element') 69 return self 70 #}}} 65 71 def setdefaultparameters(self): # {{{ 66 72 #ice density (kg/m^3) -
issm/trunk/src/m/classes/matice.m
r17989 r19105 30 30 end 31 31 methods 32 function createxml( obj,fid) % {{{32 function createxml(self,fid) % {{{ 33 33 fprintf(fid, '\n\n'); 34 34 fprintf(fid, '<!-- materials -->\n'); 35 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="rho_ice" type="',class( obj.rho_ice),'" default="',convert2str(obj.rho_ice),'">',' <section name="materials" />',' <help> ice density [kg/m^3] </help>','</parameter>');36 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="rho_water" type="',class( obj.rho_water),'" default="',convert2str(obj.rho_water),'">',' <section name="materials" />',' <help> ocean water density [kg/m^3] </help>','</parameter>');37 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="rho_freshwater" type="',class( obj.rho_freshwater),'" default="',convert2str(obj.rho_freshwater),'">',' <section name="materials" />',' <help> fresh water density [kg/m^3] </help>','</parameter>');38 39 40 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="mu_water" type="',class( obj.mu_water),'" default="',convert2str(obj.mu_water),'">',' <section name="materials" />',' <help> water viscosity [N s/m^2] </help>','</parameter>');41 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="heatcapacity" type="',class( obj.heatcapacity),'" default="',convert2str(obj.heatcapacity),'">',' <section name="materials" />',' <help> heat capacity [J/kg/K] </help>','</parameter>');42 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="latentheat" type="',class( obj.latentheat),'" default="',convert2str(obj.latentheat),'">',' <section name="materials" />',' <help> latent heat of fusion [J/kg] </help>','</parameter>');43 44 45 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="thermalconductivity" type="',class( obj.thermalconductivity),'" default="',convert2str(obj.thermalconductivity),'">',' <section name="materials" />',' <help> ice thermal conductivity [W/m/K] </help>','</parameter>');46 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="temperateiceconductivity" type="',class( obj.temperateiceconductivity),'" default="',convert2str(obj.temperateiceconductivity),'">',' <section name="materials" />',' <help> temperate ice thermal conductivity [W/m/K] </help>','</parameter>');47 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="meltingpoint" type="',class( obj.meltingpoint),'" default="',convert2str(obj.meltingpoint),'">',' <section name="materials" />',' <help> melting point of ice at 1atm in K </help>','</parameter>');48 49 50 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="beta" type="',class( obj.beta),'" default="',convert2str(obj.beta),'">',' <section name="materials" />',' <help> rate of change of melting point with pressure [K/Pa] </help>','</parameter>');51 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="mixed_layer_capacity" type="',class( obj.mixed_layer_capacity),'" default="',convert2str(obj.mixed_layer_capacity),'">',' <section name="materials" />',' <help> mixed layer capacity [W/kg/K] </help>','</parameter>');52 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="thermal_exchange_velocity" type="',class( obj.thermal_exchange_velocity),'" default="',convert2str(obj.thermal_exchange_velocity),'">',' <section name="materials" />',' <help> thermal exchange velocity [m/s] </help>','</parameter>');53 54 55 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="rheology_B" type="',class( obj.rheology_B),'" default="',convert2str(obj.rheology_B),'">',' <section name="materials" />',' <help> flow law parameter [Pa/s^(1/n)] </help>','</parameter>');56 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="rheology_n" type="',class( obj.rheology_n),'" default="',convert2str(obj.rheology_n),'">',' <section name="materials" />',' <help> Glens flow law exponent </help>','</parameter>');35 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="rho_ice" type="',class(self.rho_ice),'" default="',convert2str(self.rho_ice),'">',' <section name="materials" />',' <help> ice density [kg/m^3] </help>','</parameter>'); 36 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="rho_water" type="',class(self.rho_water),'" default="',convert2str(self.rho_water),'">',' <section name="materials" />',' <help> ocean water density [kg/m^3] </help>','</parameter>'); 37 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="rho_freshwater" type="',class(self.rho_freshwater),'" default="',convert2str(self.rho_freshwater),'">',' <section name="materials" />',' <help> fresh water density [kg/m^3] </help>','</parameter>'); 38 39 40 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="mu_water" type="',class(self.mu_water),'" default="',convert2str(self.mu_water),'">',' <section name="materials" />',' <help> water viscosity [N s/m^2] </help>','</parameter>'); 41 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="heatcapacity" type="',class(self.heatcapacity),'" default="',convert2str(self.heatcapacity),'">',' <section name="materials" />',' <help> heat capacity [J/kg/K] </help>','</parameter>'); 42 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="latentheat" type="',class(self.latentheat),'" default="',convert2str(self.latentheat),'">',' <section name="materials" />',' <help> latent heat of fusion [J/kg] </help>','</parameter>'); 43 44 45 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="thermalconductivity" type="',class(self.thermalconductivity),'" default="',convert2str(self.thermalconductivity),'">',' <section name="materials" />',' <help> ice thermal conductivity [W/m/K] </help>','</parameter>'); 46 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="temperateiceconductivity" type="',class(self.temperateiceconductivity),'" default="',convert2str(self.temperateiceconductivity),'">',' <section name="materials" />',' <help> temperate ice thermal conductivity [W/m/K] </help>','</parameter>'); 47 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="meltingpoint" type="',class(self.meltingpoint),'" default="',convert2str(self.meltingpoint),'">',' <section name="materials" />',' <help> melting point of ice at 1atm in K </help>','</parameter>'); 48 49 50 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="beta" type="',class(self.beta),'" default="',convert2str(self.beta),'">',' <section name="materials" />',' <help> rate of change of melting point with pressure [K/Pa] </help>','</parameter>'); 51 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="mixed_layer_capacity" type="',class(self.mixed_layer_capacity),'" default="',convert2str(self.mixed_layer_capacity),'">',' <section name="materials" />',' <help> mixed layer capacity [W/kg/K] </help>','</parameter>'); 52 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="thermal_exchange_velocity" type="',class(self.thermal_exchange_velocity),'" default="',convert2str(self.thermal_exchange_velocity),'">',' <section name="materials" />',' <help> thermal exchange velocity [m/s] </help>','</parameter>'); 53 54 55 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="rheology_B" type="',class(self.rheology_B),'" default="',convert2str(self.rheology_B),'">',' <section name="materials" />',' <help> flow law parameter [Pa/s^(1/n)] </help>','</parameter>'); 56 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="rheology_n" type="',class(self.rheology_n),'" default="',convert2str(self.rheology_n),'">',' <section name="materials" />',' <help> Glens flow law exponent </help>','</parameter>'); 57 57 58 58 % rheology_law drop-down … … 64 64 65 65 66 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="lithosphere_shear_modulus" type="',class(obj.lithosphere_shear_modulus),'" default="',convert2str(obj.lithosphere_shear_modulus),'">',' <section name="materials" />',' <help> Lithosphere shear modulus [Pa] </help>','</parameter>'); 67 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="lithosphere_density" type="',class(obj.lithosphere_density),'" default="',convert2str(obj.lithosphere_density),'">',' <section name="materials" />',' <help> Lithosphere density [g/cm^-3] </help>','</parameter>'); 68 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="mantle_shear_modulus" type="',class(obj.mantle_shear_modulus),'" default="',convert2str(obj.mantle_shear_modulus),'">',' <section name="materials" />',' <help> Mantle shear modulus [Pa] </help>','</parameter>'); 69 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="mantle_density" type="',class(obj.mantle_density),'" default="',convert2str(obj.mantle_density),'">',' <section name="materials" />',' <help> Mantle density [g/cm^-3] </help>','</parameter>'); 70 71 72 end % }}} 73 function obj = matice(varargin) % {{{ 66 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="lithosphere_shear_modulus" type="',class(self.lithosphere_shear_modulus),'" default="',convert2str(self.lithosphere_shear_modulus),'">',' <section name="materials" />',' <help> Lithosphere shear modulus [Pa] </help>','</parameter>'); 67 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="lithosphere_density" type="',class(self.lithosphere_density),'" default="',convert2str(self.lithosphere_density),'">',' <section name="materials" />',' <help> Lithosphere density [g/cm^-3] </help>','</parameter>'); 68 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="mantle_shear_modulus" type="',class(self.mantle_shear_modulus),'" default="',convert2str(self.mantle_shear_modulus),'">',' <section name="materials" />',' <help> Mantle shear modulus [Pa] </help>','</parameter>'); 69 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n','<parameter key ="mantle_density" type="',class(self.mantle_density),'" default="',convert2str(self.mantle_density),'">',' <section name="materials" />',' <help> Mantle density [g/cm^-3] </help>','</parameter>'); 70 71 72 end % }}} 73 function self = extrude(self,md) % {{{ 74 self.rheology_B=project3d(md,'vector',self.rheology_B,'type','node'); 75 self.rheology_n=project3d(md,'vector',self.rheology_n,'type','element'); 76 end % }}} 77 function self = matice(varargin) % {{{ 74 78 switch nargin 75 79 case 0 76 obj=setdefaultparameters(obj);80 self=setdefaultparameters(self); 77 81 case 1 78 82 inputstruct=varargin{1}; … … 82 86 fieldname = list1{i}; 83 87 if ismember(fieldname,list2), 84 obj.(fieldname) = inputstruct.(fieldname);88 self.(fieldname) = inputstruct.(fieldname); 85 89 end 86 90 end … … 89 93 end 90 94 end % }}} 91 function obj = setdefaultparameters(obj) % {{{95 function self = setdefaultparameters(self) % {{{ 92 96 93 97 %ice density (kg/m^3) 94 obj.rho_ice=917.;98 self.rho_ice=917.; 95 99 96 100 %ocean water density (kg/m^3) 97 obj.rho_water=1023.;101 self.rho_water=1023.; 98 102 99 103 %fresh water density (kg/m^3) 100 obj.rho_freshwater=1000.;104 self.rho_freshwater=1000.; 101 105 102 106 %water viscosity (N.s/m^2) 103 obj.mu_water=0.001787;107 self.mu_water=0.001787; 104 108 105 109 %ice heat capacity cp (J/kg/K) 106 obj.heatcapacity=2093.;110 self.heatcapacity=2093.; 107 111 108 112 %ice latent heat of fusion L (J/kg) 109 obj.latentheat=3.34*10^5;113 self.latentheat=3.34*10^5; 110 114 111 115 %ice thermal conductivity (W/m/K) 112 obj.thermalconductivity=2.4;116 self.thermalconductivity=2.4; 113 117 114 118 %wet ice thermal conductivity (W/m/K) 115 obj.temperateiceconductivity=.24;119 self.temperateiceconductivity=.24; 116 120 117 121 %the melting point of ice at 1 atmosphere of pressure in K 118 obj.meltingpoint=273.15;122 self.meltingpoint=273.15; 119 123 120 124 %rate of change of melting point with pressure (K/Pa) 121 obj.beta=9.8*10^-8;125 self.beta=9.8*10^-8; 122 126 123 127 %mixed layer (ice-water interface) heat capacity (J/kg/K) 124 obj.mixed_layer_capacity=3974.;128 self.mixed_layer_capacity=3974.; 125 129 126 130 %thermal exchange velocity (ice-water interface) (m/s) 127 obj.thermal_exchange_velocity=1.00*10^-4;131 self.thermal_exchange_velocity=1.00*10^-4; 128 132 129 133 %Rheology law: what is the temperature dependence of B with T 130 134 %available: none, paterson and arrhenius 131 obj.rheology_law='Paterson';135 self.rheology_law='Paterson'; 132 136 133 137 % GIA: 134 obj.lithosphere_shear_modulus = 6.7*10^10; % (Pa)135 obj.lithosphere_density = 3.32; % (g/cm^-3)136 obj.mantle_shear_modulus = 1.45*10^11; % (Pa)137 obj.mantle_density = 3.34; % (g/cm^-3)138 139 end % }}} 140 function md = checkconsistency( obj,md,solution,analyses) % {{{138 self.lithosphere_shear_modulus = 6.7*10^10; % (Pa) 139 self.lithosphere_density = 3.32; % (g/cm^-3) 140 self.mantle_shear_modulus = 1.45*10^11; % (Pa) 141 self.mantle_density = 3.34; % (g/cm^-3) 142 143 end % }}} 144 function md = checkconsistency(self,md,solution,analyses) % {{{ 141 145 md = checkfield(md,'fieldname','materials.rho_ice','>',0); 142 146 md = checkfield(md,'fieldname','materials.rho_water','>',0); 143 147 md = checkfield(md,'fieldname','materials.rho_freshwater','>',0); 144 148 md = checkfield(md,'fieldname','materials.mu_water','>',0); 145 md = checkfield(md,'fieldname','materials.rheology_B','>',0,' size',[md.mesh.numberofvertices 1]);149 md = checkfield(md,'fieldname','materials.rheology_B','>',0,'timeseries',1,'NaN',1); 146 150 md = checkfield(md,'fieldname','materials.rheology_n','>',0,'size',[md.mesh.numberofelements 1]); 147 151 md = checkfield(md,'fieldname','materials.rheology_law','values',{'None' 'Cuffey' 'Paterson' 'Arrhenius' 'LliboutryDuval'}); … … 155 159 156 160 end % }}} 157 function disp( obj) % {{{161 function disp(self) % {{{ 158 162 disp(sprintf(' Materials:')); 159 163 160 fielddisplay( obj,'rho_ice','ice density [kg/m^3]');161 fielddisplay( obj,'rho_water','ocean water density [kg/m^3]');162 fielddisplay( obj,'rho_freshwater','fresh water density [kg/m^3]');163 fielddisplay( obj,'mu_water','water viscosity [N s/m^2]');164 fielddisplay( obj,'heatcapacity','heat capacity [J/kg/K]');165 fielddisplay( obj,'thermalconductivity',['ice thermal conductivity [W/m/K]']);166 fielddisplay( obj,'temperateiceconductivity','temperate ice thermal conductivity [W/m/K]');167 fielddisplay( obj,'meltingpoint','melting point of ice at 1atm in K');168 fielddisplay( obj,'latentheat','latent heat of fusion [J/kg]');169 fielddisplay( obj,'beta','rate of change of melting point with pressure [K/Pa]');170 fielddisplay( obj,'mixed_layer_capacity','mixed layer capacity [W/kg/K]');171 fielddisplay( obj,'thermal_exchange_velocity','thermal exchange velocity [m/s]');172 fielddisplay( obj,'rheology_B','flow law parameter [Pa/s^(1/n)]');173 fielddisplay( obj,'rheology_n','Glen''s flow law exponent');174 fielddisplay( obj,'rheology_law',['law for the temperature dependance of the rheology: ''None'', ''Cuffey'', ''Paterson'', ''Arrhenius'' or ''LliboutryDuval''']);175 fielddisplay( obj,'lithosphere_shear_modulus','Lithosphere shear modulus [Pa]');176 fielddisplay( obj,'lithosphere_density','Lithosphere density [g/cm^-3]');177 fielddisplay( obj,'mantle_shear_modulus','Mantle shear modulus [Pa]');178 fielddisplay( obj,'mantle_density','Mantle density [g/cm^-3]');179 end % }}} 180 function marshall( obj,md,fid) % {{{164 fielddisplay(self,'rho_ice','ice density [kg/m^3]'); 165 fielddisplay(self,'rho_water','ocean water density [kg/m^3]'); 166 fielddisplay(self,'rho_freshwater','fresh water density [kg/m^3]'); 167 fielddisplay(self,'mu_water','water viscosity [N s/m^2]'); 168 fielddisplay(self,'heatcapacity','heat capacity [J/kg/K]'); 169 fielddisplay(self,'thermalconductivity',['ice thermal conductivity [W/m/K]']); 170 fielddisplay(self,'temperateiceconductivity','temperate ice thermal conductivity [W/m/K]'); 171 fielddisplay(self,'meltingpoint','melting point of ice at 1atm in K'); 172 fielddisplay(self,'latentheat','latent heat of fusion [J/kg]'); 173 fielddisplay(self,'beta','rate of change of melting point with pressure [K/Pa]'); 174 fielddisplay(self,'mixed_layer_capacity','mixed layer capacity [W/kg/K]'); 175 fielddisplay(self,'thermal_exchange_velocity','thermal exchange velocity [m/s]'); 176 fielddisplay(self,'rheology_B','flow law parameter [Pa/s^(1/n)]'); 177 fielddisplay(self,'rheology_n','Glen''s flow law exponent'); 178 fielddisplay(self,'rheology_law',['law for the temperature dependance of the rheology: ''None'', ''Cuffey'', ''Paterson'', ''Arrhenius'' or ''LliboutryDuval''']); 179 fielddisplay(self,'lithosphere_shear_modulus','Lithosphere shear modulus [Pa]'); 180 fielddisplay(self,'lithosphere_density','Lithosphere density [g/cm^-3]'); 181 fielddisplay(self,'mantle_shear_modulus','Mantle shear modulus [Pa]'); 182 fielddisplay(self,'mantle_density','Mantle density [g/cm^-3]'); 183 end % }}} 184 function marshall(self,md,fid) % {{{ 181 185 WriteData(fid,'enum',MaterialsEnum(),'data',MaticeEnum(),'format','Integer'); 182 WriteData(fid,'object', obj,'class','materials','fieldname','rho_ice','format','Double');183 WriteData(fid,'object', obj,'class','materials','fieldname','rho_water','enum',MaterialsRhoSeawaterEnum(),'format','Double');184 WriteData(fid,'object', obj,'class','materials','fieldname','rho_freshwater','format','Double');185 WriteData(fid,'object', obj,'class','materials','fieldname','mu_water','format','Double');186 WriteData(fid,'object', obj,'class','materials','fieldname','heatcapacity','format','Double');187 WriteData(fid,'object', obj,'class','materials','fieldname','latentheat','format','Double');188 WriteData(fid,'object', obj,'class','materials','fieldname','thermalconductivity','format','Double');189 WriteData(fid,'object', obj,'class','materials','fieldname','temperateiceconductivity','format','Double');190 WriteData(fid,'object', obj,'class','materials','fieldname','meltingpoint','format','Double');191 WriteData(fid,'object', obj,'class','materials','fieldname','beta','format','Double');192 WriteData(fid,'object', obj,'class','materials','fieldname','mixed_layer_capacity','format','Double');193 WriteData(fid,'object', obj,'class','materials','fieldname','thermal_exchange_velocity','format','Double');194 WriteData(fid,'object', obj,'class','materials','fieldname','rheology_B','format','DoubleMat','mattype',1);195 WriteData(fid,'object', obj,'class','materials','fieldname','rheology_n','format','DoubleMat','mattype',2);196 WriteData(fid,'data',StringToEnum( obj.rheology_law),'enum',MaterialsRheologyLawEnum(),'format','Integer');197 198 WriteData(fid,'object', obj,'class','materials','fieldname','lithosphere_shear_modulus','format','Double');199 WriteData(fid,'object', obj,'class','materials','fieldname','lithosphere_density','format','Double','scale',10^3);200 WriteData(fid,'object', obj,'class','materials','fieldname','mantle_shear_modulus','format','Double');201 WriteData(fid,'object', obj,'class','materials','fieldname','mantle_density','format','Double','scale',10^3);186 WriteData(fid,'object',self,'class','materials','fieldname','rho_ice','format','Double'); 187 WriteData(fid,'object',self,'class','materials','fieldname','rho_water','enum',MaterialsRhoSeawaterEnum(),'format','Double'); 188 WriteData(fid,'object',self,'class','materials','fieldname','rho_freshwater','format','Double'); 189 WriteData(fid,'object',self,'class','materials','fieldname','mu_water','format','Double'); 190 WriteData(fid,'object',self,'class','materials','fieldname','heatcapacity','format','Double'); 191 WriteData(fid,'object',self,'class','materials','fieldname','latentheat','format','Double'); 192 WriteData(fid,'object',self,'class','materials','fieldname','thermalconductivity','format','Double'); 193 WriteData(fid,'object',self,'class','materials','fieldname','temperateiceconductivity','format','Double'); 194 WriteData(fid,'object',self,'class','materials','fieldname','meltingpoint','format','Double'); 195 WriteData(fid,'object',self,'class','materials','fieldname','beta','format','Double'); 196 WriteData(fid,'object',self,'class','materials','fieldname','mixed_layer_capacity','format','Double'); 197 WriteData(fid,'object',self,'class','materials','fieldname','thermal_exchange_velocity','format','Double'); 198 WriteData(fid,'object',self,'class','materials','fieldname','rheology_B','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1); 199 WriteData(fid,'object',self,'class','materials','fieldname','rheology_n','format','DoubleMat','mattype',2); 200 WriteData(fid,'data',StringToEnum(self.rheology_law),'enum',MaterialsRheologyLawEnum(),'format','Integer'); 201 202 WriteData(fid,'object',self,'class','materials','fieldname','lithosphere_shear_modulus','format','Double'); 203 WriteData(fid,'object',self,'class','materials','fieldname','lithosphere_density','format','Double','scale',10^3); 204 WriteData(fid,'object',self,'class','materials','fieldname','mantle_shear_modulus','format','Double'); 205 WriteData(fid,'object',self,'class','materials','fieldname','mantle_density','format','Double','scale',10^3); 202 206 end % }}} 203 207 end -
issm/trunk/src/m/classes/matice.py
r17989 r19105 1 1 from fielddisplay import fielddisplay 2 from project3d import project3d 2 3 from EnumDefinitions import * 3 4 from StringToEnum import StringToEnum … … 63 64 return string 64 65 #}}} 66 def extrude(self,md): # {{{ 67 self.rheology_B=project3d(md,'vector',self.rheology_B,'type','node') 68 self.rheology_n=project3d(md,'vector',self.rheology_n,'type','element') 69 return self 70 #}}} 65 71 def setdefaultparameters(self): # {{{ 66 72 #ice density (kg/m^3) … … 117 123 md = checkfield(md,'fieldname','materials.rho_freshwater','>',0) 118 124 md = checkfield(md,'fieldname','materials.mu_water','>',0) 119 md = checkfield(md,'fieldname','materials.rheology_B','>',0,' size',[md.mesh.numberofvertices])125 md = checkfield(md,'fieldname','materials.rheology_B','>',0,'timeseries',1,'NaN',1) 120 126 md = checkfield(md,'fieldname','materials.rheology_n','>',0,'size',[md.mesh.numberofelements]) 121 127 md = checkfield(md,'fieldname','materials.rheology_law','values',['None','Cuffey','Paterson','Arrhenius','LliboutryDuval']) … … 140 146 WriteData(fid,'object',self,'class','materials','fieldname','mixed_layer_capacity','format','Double') 141 147 WriteData(fid,'object',self,'class','materials','fieldname','thermal_exchange_velocity','format','Double') 148 WriteData(fid,'object',self,'class','materials','fieldname','rheology_B','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1) 142 149 WriteData(fid,'object',self,'class','materials','fieldname','rheology_B','format','DoubleMat','mattype',1) 143 150 WriteData(fid,'object',self,'class','materials','fieldname','rheology_n','format','DoubleMat','mattype',2) -
issm/trunk/src/m/classes/mesh2d.m
r17989 r19105 8 8 x = NaN; 9 9 y = NaN; 10 elements = NaN 10 elements = NaN; 11 11 numberofelements = 0; 12 12 numberofvertices = 0; 13 13 numberofedges = 0; 14 14 15 lat = NaN 16 long = NaN 17 hemisphere = NaN15 lat = NaN; 16 long = NaN; 17 epsg = 0; 18 18 19 vertexonboundary = NaN 19 vertexonboundary = NaN; 20 20 21 edges = NaN 22 segments = NaN 23 segmentmarkers = NaN 24 vertexconnectivity = NaN 25 elementconnectivity = NaN 21 edges = NaN; 22 segments = NaN; 23 segmentmarkers = NaN; 24 vertexconnectivity = NaN; 25 elementconnectivity = NaN; 26 26 average_vertex_connectivity = 0; 27 27 28 extractedvertices = NaN 29 extractedelements = NaN 28 extractedvertices = NaN; 29 extractedelements = NaN; 30 end 31 methods (Static) 32 function self = loadobj(self) % {{{ 33 % This function is directly called by matlab when a model selfect is 34 % loaded. Update old properties here 35 36 %2014 Oct. 1st 37 if isstruct(self), 38 oldself=self; 39 %Assign property values from struct 40 self=structtoobj(mesh2d(),oldself); 41 if isfield(oldself,'hemisphere'), 42 disp('md.mesh.hemisphere has been automatically converted to EPSG code'); 43 if strcmpi(oldself.hemisphere,'n'), 44 self.epsg=3413; 45 else 46 self.epsg=3031; 47 end 48 end 49 end 50 51 end% }}} 30 52 end 31 53 methods … … 48 70 end 49 71 end % }}} 50 function obj = setdefaultparameters(obj) % {{{72 function self = setdefaultparameters(self) % {{{ 51 73 52 74 %the connectivity is the averaged number of nodes linked to a … … 55 77 %give a good memory/time ration. This value can be checked in 56 78 %trunk/test/Miscellaneous/runme.m 57 obj.average_vertex_connectivity=25;79 self.average_vertex_connectivity=25; 58 80 end % }}} 59 function md = checkconsistency( obj,md,solution,analyses) % {{{81 function md = checkconsistency(self,md,solution,analyses) % {{{ 60 82 61 83 md = checkfield(md,'fieldname','mesh.x','NaN',1,'size',[md.mesh.numberofvertices 1]); … … 75 97 end 76 98 end % }}} 77 function disp( obj) % {{{99 function disp(self) % {{{ 78 100 disp(sprintf(' 2D tria Mesh (horizontal):')); 79 101 80 102 disp(sprintf('\n Elements and vertices:')); 81 fielddisplay( obj,'numberofelements','number of elements');82 fielddisplay( obj,'numberofvertices','number of vertices');83 fielddisplay( obj,'elements','vertex indices of the mesh elements');84 fielddisplay( obj,'x','vertices x coordinate [m]');85 fielddisplay( obj,'y','vertices y coordinate [m]');86 fielddisplay( obj,'edges','edges of the 2d mesh (vertex1 vertex2 element1 element2)');87 fielddisplay( obj,'numberofedges','number of edges of the 2d mesh');103 fielddisplay(self,'numberofelements','number of elements'); 104 fielddisplay(self,'numberofvertices','number of vertices'); 105 fielddisplay(self,'elements','vertex indices of the mesh elements'); 106 fielddisplay(self,'x','vertices x coordinate [m]'); 107 fielddisplay(self,'y','vertices y coordinate [m]'); 108 fielddisplay(self,'edges','edges of the 2d mesh (vertex1 vertex2 element1 element2)'); 109 fielddisplay(self,'numberofedges','number of edges of the 2d mesh'); 88 110 89 111 disp(sprintf('\n Properties:')); 90 fielddisplay( obj,'vertexonboundary','vertices on the boundary of the domain flag list');91 fielddisplay( obj,'segments','edges on domain boundary (vertex1 vertex2 element)');92 fielddisplay( obj,'segmentmarkers','number associated to each segment');93 fielddisplay( obj,'vertexconnectivity','list of vertices connected to vertex_i');94 fielddisplay( obj,'elementconnectivity','list of vertices connected to element_i');95 fielddisplay( obj,'average_vertex_connectivity','average number of vertices connected to one vertex');112 fielddisplay(self,'vertexonboundary','vertices on the boundary of the domain flag list'); 113 fielddisplay(self,'segments','edges on domain boundary (vertex1 vertex2 element)'); 114 fielddisplay(self,'segmentmarkers','number associated to each segment'); 115 fielddisplay(self,'vertexconnectivity','list of vertices connected to vertex_i'); 116 fielddisplay(self,'elementconnectivity','list of vertices connected to element_i'); 117 fielddisplay(self,'average_vertex_connectivity','average number of vertices connected to one vertex'); 96 118 97 119 disp(sprintf('\n Extracted model:')); 98 fielddisplay( obj,'extractedvertices','vertices extracted from the model');99 fielddisplay( obj,'extractedelements','elements extracted from the model');120 fielddisplay(self,'extractedvertices','vertices extracted from the model'); 121 fielddisplay(self,'extractedelements','elements extracted from the model'); 100 122 101 123 disp(sprintf('\n Projection:')); 102 fielddisplay( obj,'lat','vertices latitude [degrees]');103 fielddisplay( obj,'long','vertices longitude [degrees]');104 fielddisplay( obj,'hemisphere','Indicate hemisphere ''n'' or ''s''');124 fielddisplay(self,'lat','vertices latitude [degrees]'); 125 fielddisplay(self,'long','vertices longitude [degrees]'); 126 fielddisplay(self,'epsg','EPSG code (ex: 3413 for UPS Greenland, 3031 for UPS Antarctica)'); 105 127 end % }}} 106 function createxml(obj,fid) % {{{ 107 fprintf(fid, '<!-- 2D tria Mesh (horizontal) -->\n'); 108 109 %elements and vertices 110 fprintf(fid,'%s\n%s\n%s\n','<frame key="1" label="Elements and vertices">','<section name="mesh" />'); 111 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="numberofelements" type="',class(obj.numberofelements),'" default="',convert2str(obj.numberofelements),'">',' <section name="mesh" />',' <help> number of elements </help>',' </parameter>'); 112 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="numberofvertices" type="',class(obj.numberofvertices),'" default="',convert2str(obj.numberofvertices),'">',' <section name="mesh" />',' <help> number of vertices </help>',' </parameter>'); 113 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="elements" type="',class(obj.elements),'" default="',convert2str(obj.elements),'">',' <section name="mesh" />',' <help> vertex indices of the mesh elements </help>',' </parameter>'); 114 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="x" type="',class(obj.x),'" default="',convert2str(obj.x),'">',' <section name="mesh" />',' <help> vertices x coordinate [m] </help>',' </parameter>'); 115 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="y" type="',class(obj.y),'" default="',convert2str(obj.y),'">',' <section name="mesh" />',' <help> vertices y coordinate [m] </help>',' </parameter>'); 116 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="edges" type="',class(obj.edges),'" default="',convert2str(obj.edges),'">',' <section name="mesh" />',' <help> edges of the 2d mesh (vertex1 vertex2 element1 element2) </help>',' </parameter>'); 117 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="numberofedges" type="',class(obj.numberofedges),'" default="',convert2str(obj.numberofedges),'">',' <section name="mesh" />',' <help> number of edges of the 2d mesh </help>',' </parameter>'); 118 fprintf(fid,'%s\n%s\n','</frame>'); 119 120 % properties 121 fprintf(fid,'%s\n%s\n%s\n','<frame key="2" label="Properties">','<section name="mesh" />'); 122 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vertexonboundary" type="',class(obj.vertexonboundary),'" default="',convert2str(obj.vertexonboundary),'">',' <section name="mesh" />',' <help> vertices on the boundary of the domain flag list </help>',' </parameter>'); 123 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="segments" type="',class(obj.segments),'" default="',convert2str(obj.segments),'">',' <section name="mesh" />',' <help> edges on domain boundary (vertex1 vertex2 element) </help>',' </parameter>'); 124 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="segmentmarkers" type="',class(obj.segmentmarkers),'" default="',convert2str(obj.segmentmarkers),'">',' <section name="mesh" />',' <help> number associated to each segment </help>',' </parameter>'); 125 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vertexconnectivity" type="',class(obj.vertexconnectivity),'" default="',convert2str(obj.vertexconnectivity),'">',' <section name="mesh" />',' <help> list of vertices connected to vertex_i </help>',' </parameter>'); 126 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="elementconnectivity" type="',class(obj.elementconnectivity),'" default="',convert2str(obj.elementconnectivity),'">',' <section name="mesh" />',' <help> list of vertices connected to element_i </help>',' </parameter>'); 127 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="average_vertex_connectivity" type="',class(obj.average_vertex_connectivity),'" default="',convert2str(obj.average_vertex_connectivity),'">',' <section name="mesh" />',' <help> average number of vertices connected to one vertex </help>',' </parameter>'); 128 fprintf(fid,'%s\n%s\n','</frame>'); 129 130 %extracted model 131 fprintf(fid,'%s\n%s\n%s\n','<frame key="3" label="Extracted Model">','<section name="mesh" />'); 132 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="extractedvertices" type="',class(obj.extractedvertices),'" default="',convert2str(obj.extractedvertices),'">',' <section name="mesh" />',' <help> vertices extracted from the model </help>',' </parameter>'); 133 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="extractedelements" type="',class(obj.extractedelements),'" default="',convert2str(obj.extractedelements),'">',' <section name="mesh" />',' <help> elements extracted from the model </help>',' </parameter>'); 134 fprintf(fid,'%s\n%s\n','</frame>'); 135 136 %projection 137 fprintf(fid,'%s\n%s\n%s\n','<frame key="4" label="Projection">','<section name="mesh" />'); 138 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="lat" type="',class(obj.lat),'" default="',convert2str(obj.lat),'">',' <section name="mesh" />',' <help> vertices latitude [degrees] </help>',' </parameter>'); 139 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="long" type="',class(obj.long),'" default="',convert2str(obj.long),'">',' <section name="mesh" />',' <help> verticies longitude [degrees] </help>',' </parameter>'); 140 % choice (hemisphere) 'n' or 's' 141 fprintf(fid,'%s\n%s\n%s\n',' <parameter key ="hemisphere" type="alternative" optional="false">',' <section name="mesh" />',' <help> Indicate hemisphere ''n'' or ''s'' </help>'); 142 fprintf(fid,'%s\n',' <option value="n" type="string" default="true"> </option>'); 143 fprintf(fid,'%s\n',' <option value="s" type="string" default="false"> </option>'); 144 fprintf(fid,'%s\n',' </parameter>'); 145 fprintf(fid,'%s\n%s\n','</frame>'); 146 147 end % }}} 148 function marshall(obj,md,fid) % {{{ 149 WriteData(fid,'enum',DomainTypeEnum(),'data',StringToEnum(['Domain' domaintype(obj)]),'format','Integer'); 150 WriteData(fid,'enum',DomainDimensionEnum(),'data',dimension(obj),'format','Integer'); 151 WriteData(fid,'enum',MeshElementtypeEnum(),'data',StringToEnum(elementtype(obj)),'format','Integer'); 152 WriteData(fid,'object',obj,'class','mesh','fieldname','x','format','DoubleMat','mattype',1); 153 WriteData(fid,'object',obj,'class','mesh','fieldname','y','format','DoubleMat','mattype',1); 154 WriteData(fid,'enum',MeshZEnum(),'data',zeros(obj.numberofvertices,1),'format','DoubleMat','mattype',1); 155 WriteData(fid,'object',obj,'class','mesh','fieldname','elements','format','DoubleMat','mattype',2); 156 WriteData(fid,'object',obj,'class','mesh','fieldname','numberofelements','format','Integer'); 157 WriteData(fid,'object',obj,'class','mesh','fieldname','numberofvertices','format','Integer'); 158 WriteData(fid,'object',obj,'class','mesh','fieldname','average_vertex_connectivity','format','Integer'); 159 WriteData(fid,'object',obj,'class','mesh','fieldname','vertexonboundary','format','DoubleMat','mattype',1); 128 function createxml(self,fid) % {{{ 129 fprintf(fid, '<!-- 2D tria Mesh (horizontal) -->\n'); 130 131 %elements and vertices 132 fprintf(fid,'%s\n%s\n%s\n','<frame key="1" label="Elements and vertices">','<section name="mesh" />'); 133 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="numberofelements" type="',class(self.numberofelements),'" default="',convert2str(self.numberofelements),'">',' <section name="mesh" />',' <help> number of elements </help>',' </parameter>'); 134 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="numberofvertices" type="',class(self.numberofvertices),'" default="',convert2str(self.numberofvertices),'">',' <section name="mesh" />',' <help> number of vertices </help>',' </parameter>'); 135 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="elements" type="',class(self.elements),'" default="',convert2str(self.elements),'">',' <section name="mesh" />',' <help> vertex indices of the mesh elements </help>',' </parameter>'); 136 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="x" type="',class(self.x),'" default="',convert2str(self.x),'">',' <section name="mesh" />',' <help> vertices x coordinate [m] </help>',' </parameter>'); 137 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="y" type="',class(self.y),'" default="',convert2str(self.y),'">',' <section name="mesh" />',' <help> vertices y coordinate [m] </help>',' </parameter>'); 138 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="edges" type="',class(self.edges),'" default="',convert2str(self.edges),'">',' <section name="mesh" />',' <help> edges of the 2d mesh (vertex1 vertex2 element1 element2) </help>',' </parameter>'); 139 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="numberofedges" type="',class(self.numberofedges),'" default="',convert2str(self.numberofedges),'">',' <section name="mesh" />',' <help> number of edges of the 2d mesh </help>',' </parameter>'); 140 fprintf(fid,'%s\n%s\n','</frame>'); 141 142 % properties 143 fprintf(fid,'%s\n%s\n%s\n','<frame key="2" label="Properties">','<section name="mesh" />'); 144 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vertexonboundary" type="',class(self.vertexonboundary),'" default="',convert2str(self.vertexonboundary),'">',' <section name="mesh" />',' <help> vertices on the boundary of the domain flag list </help>',' </parameter>'); 145 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="segments" type="',class(self.segments),'" default="',convert2str(self.segments),'">',' <section name="mesh" />',' <help> edges on domain boundary (vertex1 vertex2 element) </help>',' </parameter>'); 146 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="segmentmarkers" type="',class(self.segmentmarkers),'" default="',convert2str(self.segmentmarkers),'">',' <section name="mesh" />',' <help> number associated to each segment </help>',' </parameter>'); 147 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vertexconnectivity" type="',class(self.vertexconnectivity),'" default="',convert2str(self.vertexconnectivity),'">',' <section name="mesh" />',' <help> list of vertices connected to vertex_i </help>',' </parameter>'); 148 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="elementconnectivity" type="',class(self.elementconnectivity),'" default="',convert2str(self.elementconnectivity),'">',' <section name="mesh" />',' <help> list of vertices connected to element_i </help>',' </parameter>'); 149 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="average_vertex_connectivity" type="',class(self.average_vertex_connectivity),'" default="',convert2str(self.average_vertex_connectivity),'">',' <section name="mesh" />',' <help> average number of vertices connected to one vertex </help>',' </parameter>'); 150 fprintf(fid,'%s\n%s\n','</frame>'); 151 152 %extracted model 153 fprintf(fid,'%s\n%s\n%s\n','<frame key="3" label="Extracted Model">','<section name="mesh" />'); 154 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="extractedvertices" type="',class(self.extractedvertices),'" default="',convert2str(self.extractedvertices),'">',' <section name="mesh" />',' <help> vertices extracted from the model </help>',' </parameter>'); 155 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="extractedelements" type="',class(self.extractedelements),'" default="',convert2str(self.extractedelements),'">',' <section name="mesh" />',' <help> elements extracted from the model </help>',' </parameter>'); 156 fprintf(fid,'%s\n%s\n','</frame>'); 157 158 %projection 159 fprintf(fid,'%s\n%s\n%s\n','<frame key="4" label="Projection">','<section name="mesh" />'); 160 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="lat" type="',class(self.lat),'" default="',convert2str(self.lat),'">',' <section name="mesh" />',' <help> vertices latitude [degrees] </help>',' </parameter>'); 161 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="long" type="',class(self.long),'" default="',convert2str(self.long),'">',' <section name="mesh" />',' <help> verticies longitude [degrees] </help>',' </parameter>'); 162 % choice (epsg) 'n' or 's' 163 fprintf(fid,'%s\n%s\n%s\n',' <parameter key ="epsg" type="alternative" optional="false">',' <section name="mesh" />',' <help> Indicate epsg ''n'' or ''s'' </help>'); 164 fprintf(fid,'%s\n',' <option value="n" type="string" default="true"> </option>'); 165 fprintf(fid,'%s\n',' <option value="s" type="string" default="false"> </option>'); 166 fprintf(fid,'%s\n',' </parameter>'); 167 fprintf(fid,'%s\n%s\n','</frame>'); 168 160 169 end % }}} 161 function t = domaintype(obj) % {{{ 170 function marshall(self,md,fid) % {{{ 171 WriteData(fid,'enum',DomainTypeEnum(),'data',StringToEnum(['Domain' domaintype(self)]),'format','Integer'); 172 WriteData(fid,'enum',DomainDimensionEnum(),'data',dimension(self),'format','Integer'); 173 WriteData(fid,'enum',MeshElementtypeEnum(),'data',StringToEnum(elementtype(self)),'format','Integer'); 174 WriteData(fid,'object',self,'class','mesh','fieldname','x','format','DoubleMat','mattype',1); 175 WriteData(fid,'object',self,'class','mesh','fieldname','y','format','DoubleMat','mattype',1); 176 WriteData(fid,'enum',MeshZEnum(),'data',zeros(self.numberofvertices,1),'format','DoubleMat','mattype',1); 177 WriteData(fid,'object',self,'class','mesh','fieldname','elements','format','DoubleMat','mattype',2); 178 WriteData(fid,'object',self,'class','mesh','fieldname','numberofelements','format','Integer'); 179 WriteData(fid,'object',self,'class','mesh','fieldname','numberofvertices','format','Integer'); 180 WriteData(fid,'object',self,'class','mesh','fieldname','average_vertex_connectivity','format','Integer'); 181 WriteData(fid,'object',self,'class','mesh','fieldname','vertexonboundary','format','DoubleMat','mattype',1); 182 end % }}} 183 function t = domaintype(self) % {{{ 162 184 t = '2Dhorizontal'; 163 185 end % }}} 164 function d = dimension( obj) % {{{186 function d = dimension(self) % {{{ 165 187 d = 2; 166 188 end % }}} 167 function s = elementtype( obj) % {{{189 function s = elementtype(self) % {{{ 168 190 s = 'Tria'; 169 191 end % }}} -
issm/trunk/src/m/classes/mesh2d.py
r17806 r19105 24 24 self.lat = float('NaN'); 25 25 self.long = float('NaN'); 26 self. hemisphere = float('NaN');26 self.epsg = 0; 27 27 28 28 self.vertexonboundary = float('NaN'); … … 68 68 string="%s\n%s"%(string,fielddisplay(self,"lat","vertices latitude [degrees]")) 69 69 string="%s\n%s"%(string,fielddisplay(self,"long","vertices longitude [degrees]")) 70 string="%s\n%s"%(string,fielddisplay(self," hemisphere","Indicate hemisphere 'n' or 's'"))70 string="%s\n%s"%(string,fielddisplay(self,"epsg","EPSG code (ex: 3413 for UPS Greenland, 3031 for UPS Antarctica)")) 71 71 return string 72 72 #}}} -
issm/trunk/src/m/classes/mesh2dvertical.m
r17989 r19105 8 8 x = NaN; 9 9 y = NaN; 10 elements = NaN 10 elements = NaN; 11 11 numberofelements = 0; 12 12 numberofvertices = 0; 13 13 numberofedges = 0; 14 14 15 lat = NaN 16 long = NaN 17 hemisphere = NaN18 19 vertexonboundary = NaN 20 vertexonbase = NaN21 vertexonsurface = NaN 22 23 edges = NaN 24 segments = NaN 25 segmentmarkers = NaN 26 vertexconnectivity = NaN 27 elementconnectivity = NaN 15 lat = NaN; 16 long = NaN; 17 epsg = NaN; 18 19 vertexonboundary = NaN; 20 vertexonbase = NaN; 21 vertexonsurface = NaN; 22 23 edges = NaN; 24 segments = NaN; 25 segmentmarkers = NaN; 26 vertexconnectivity = NaN; 27 elementconnectivity = NaN; 28 28 average_vertex_connectivity = 0; 29 29 end 30 methods (Static) 31 function self = loadobj(self) % {{{ 32 % This function is directly called by matlab when a model selfect is 33 % loaded. Update old properties here 34 35 %2014 Oct. 1st 36 if isstruct(self), 37 oldself=self; 38 %Assign property values from struct 39 self=structtoobj(mesh2dvertical(),oldself); 40 if isfield(oldself,'hemisphere'), 41 disp('md.mesh.hemisphere has been automatically converted to EPSG code'); 42 if strcmpi(oldself.hemisphere,'n'), 43 self.epsg=3413; 44 else 45 self.epsg=3031; 46 end 47 end 48 end 49 50 end% }}} 51 end 30 52 methods 31 function createxml(obj,fid) % {{{32 33 34 35 36 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="numberofelements" type="',class(obj.numberofelements),'" default="',convert2str(obj.numberofelements),'">',' <help> number of elements </help>',' </parameter>');37 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="numberofvertices" type="',class(obj.numberofvertices),'" default="',convert2str(obj.numberofvertices),'">',' <help> number of vertices </help>',' </parameter>');38 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="elements" type="',class(obj.elements),'" default="',convert2str(obj.elements),'">',' <help> vertex indices of the mesh elements </help>',' </parameter>');39 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="x" type="',class(obj.x),'" default="',convert2str(obj.x),'">',' <section name="mesh" />',' <help> vertices x coordinate [m] </help>',' </parameter>');40 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="y" type="',class(obj.y),'" default="',convert2str(obj.y),'">',' <section name="mesh" />',' <help> vertices y coordinate [m] </help>',' </parameter>');41 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="edges" type="',class(obj.edges),'" default="',convert2str(obj.edges),'">',' <section name="mesh" />',' <help> edges of the 2d mesh (vertex1 vertex2 element1 element2) </help>',' </parameter>');42 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="numberofedges" type="',class(obj.numberofedges),'" default="',convert2str(obj.numberofedges),'">',' <section name="mesh" />',' <help> number of edges of the 2d mesh </help>',' </parameter>');43 44 45 46 47 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vertexonboundary" type="',class(obj.vertexonboundary),'" default="',convert2str(obj.vertexonboundary),'">',' <section name="mesh" />',' <help> vertices on the boundary of the domain flag list </help>',' </parameter>');48 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vertexonbase" type="',class(obj.vertexonbase),'" default="',convert2str(obj.vertexonbase),'">',' <section name="mesh" />',' <help> vertices on the bed of the domain flag list </help>',' </parameter>');49 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="segments" type="',class(obj.segments),'" default="',convert2str(obj.segments),'">',' <section name="mesh" />',' <help> edges on domain boundary (vertex1 vertex2 element) </help>',' </parameter>');50 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="segmentmarkers" type="',class(obj.segmentmarkers),'" default="',convert2str(obj.segmentmarkers),'">',' <section name="mesh" />',' <help> number associated to each segment </help>',' </parameter>');51 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vertexconnectivity" type="',class(obj.vertexconnectivity),'" default="',convert2str(obj.vertexconnectivity),'">',' <section name="mesh" />',' <help> list of vertices connected to vertex_i </help>',' </parameter>');52 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="elementconnectivity" type="',class(obj.elementconnectivity),'" default="',convert2str(obj.elementconnectivity),'">',' <section name="mesh" />',' <help> list of vertices connected to element_i </help>',' </parameter>');53 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="average_vertex_connectivity" type="',class(obj.average_vertex_connectivity),'" default="',convert2str(obj.average_vertex_connectivity),'">',' <section name="mesh" />',' <help> average number of vertices connected to one vertex </help>',' </parameter>');54 55 56 57 58 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="lat" type="',class(obj.lat),'" default="',convert2str(obj.lat),'">',' <section name="mesh" />',' <help> vertices latitude [degrees] </help>',' </parameter>');59 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="long" type="',class(obj.long),'" default="',convert2str(obj.long),'">',' <section name="mesh" />',' <help> verticies longitude [degrees] </help>',' </parameter>');60 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="hemisphere" type="',class(obj.hemisphere),'" default="',convert2str(obj.hemisphere),'">',' <section name="mesh" />',' <help> Indicate hemisphere''n'' or ''s'' </help>',' </parameter>');61 62 63 64 function obj= mesh2dvertical(varargin) % {{{53 function createxml(self,fid) % {{{ 54 fprintf(fid, '<!-- 2d Mesh (Vertical) -->\n'); 55 56 %elements and vertices 57 fprintf(fid,'%s\n%s\n%s\n',' <frame key="1" label="Elements and vertices">',' <section name="mesh" />'); 58 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="numberofelements" type="',class(self.numberofelements),'" default="',convert2str(self.numberofelements),'">',' <help> number of elements </help>',' </parameter>'); 59 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="numberofvertices" type="',class(self.numberofvertices),'" default="',convert2str(self.numberofvertices),'">',' <help> number of vertices </help>',' </parameter>'); 60 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="elements" type="',class(self.elements),'" default="',convert2str(self.elements),'">',' <help> vertex indices of the mesh elements </help>',' </parameter>'); 61 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="x" type="',class(self.x),'" default="',convert2str(self.x),'">',' <section name="mesh" />',' <help> vertices x coordinate [m] </help>',' </parameter>'); 62 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="y" type="',class(self.y),'" default="',convert2str(self.y),'">',' <section name="mesh" />',' <help> vertices y coordinate [m] </help>',' </parameter>'); 63 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="edges" type="',class(self.edges),'" default="',convert2str(self.edges),'">',' <section name="mesh" />',' <help> edges of the 2d mesh (vertex1 vertex2 element1 element2) </help>',' </parameter>'); 64 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="numberofedges" type="',class(self.numberofedges),'" default="',convert2str(self.numberofedges),'">',' <section name="mesh" />',' <help> number of edges of the 2d mesh </help>',' </parameter>'); 65 fprintf(fid,'%s\n%s\n',' </frame>'); 66 67 % properties 68 fprintf(fid,'%s\n%s\n%s\n','<frame key="2" label="Properties">','<section name="mesh" />'); 69 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vertexonboundary" type="',class(self.vertexonboundary),'" default="',convert2str(self.vertexonboundary),'">',' <section name="mesh" />',' <help> vertices on the boundary of the domain flag list </help>',' </parameter>'); 70 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vertexonbase" type="',class(self.vertexonbase),'" default="',convert2str(self.vertexonbase),'">',' <section name="mesh" />',' <help> vertices on the bed of the domain flag list </help>',' </parameter>'); 71 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="segments" type="',class(self.segments),'" default="',convert2str(self.segments),'">',' <section name="mesh" />',' <help> edges on domain boundary (vertex1 vertex2 element) </help>',' </parameter>'); 72 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="segmentmarkers" type="',class(self.segmentmarkers),'" default="',convert2str(self.segmentmarkers),'">',' <section name="mesh" />',' <help> number associated to each segment </help>',' </parameter>'); 73 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vertexconnectivity" type="',class(self.vertexconnectivity),'" default="',convert2str(self.vertexconnectivity),'">',' <section name="mesh" />',' <help> list of vertices connected to vertex_i </help>',' </parameter>'); 74 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="elementconnectivity" type="',class(self.elementconnectivity),'" default="',convert2str(self.elementconnectivity),'">',' <section name="mesh" />',' <help> list of vertices connected to element_i </help>',' </parameter>'); 75 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="average_vertex_connectivity" type="',class(self.average_vertex_connectivity),'" default="',convert2str(self.average_vertex_connectivity),'">',' <section name="mesh" />',' <help> average number of vertices connected to one vertex </help>',' </parameter>'); 76 fprintf(fid,'%s\n%s\n','</frame>'); 77 78 %projection 79 fprintf(fid,'%s\n%s\n%s\n','<frame key="3" label="Projection">','<section name="mesh" />'); 80 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="lat" type="',class(self.lat),'" default="',convert2str(self.lat),'">',' <section name="mesh" />',' <help> vertices latitude [degrees] </help>',' </parameter>'); 81 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="long" type="',class(self.long),'" default="',convert2str(self.long),'">',' <section name="mesh" />',' <help> verticies longitude [degrees] </help>',' </parameter>'); 82 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="epsg" type="',class(self.epsg),'" default="',convert2str(self.epsg),'">',' <section name="mesh" />',' <help> Indicate epsg ''n'' or ''s'' </help>',' </parameter>'); 83 fprintf(fid,'%s\n%s\n','</frame>'); 84 85 end % }}} 86 function self = mesh2dvertical(varargin) % {{{ 65 87 switch nargin 66 88 case 0 67 obj=setdefaultparameters(obj);89 self=setdefaultparameters(self); 68 90 case 1 69 91 inputstruct=varargin{1}; … … 73 95 fieldname = list1{i}; 74 96 if ismember(fieldname,list2), 75 obj.(fieldname) = inputstruct.(fieldname);97 self.(fieldname) = inputstruct.(fieldname); 76 98 end 77 99 end … … 80 102 end 81 103 end % }}} 82 function obj = setdefaultparameters(obj) % {{{104 function self = setdefaultparameters(self) % {{{ 83 105 84 106 %the connectivity is the averaged number of nodes linked to a … … 87 109 %give a good memory/time ration. This value can be checked in 88 110 %trunk/test/Miscellaneous/runme.m 89 obj.average_vertex_connectivity=25;90 end % }}} 91 function md = checkconsistency( obj,md,solution,analyses) % {{{111 self.average_vertex_connectivity=25; 112 end % }}} 113 function md = checkconsistency(self,md,solution,analyses) % {{{ 92 114 93 115 md = checkfield(md,'fieldname','mesh.x','NaN',1,'size',[md.mesh.numberofvertices 1]); … … 109 131 end 110 132 end % }}} 111 function disp( obj) % {{{133 function disp(self) % {{{ 112 134 disp(sprintf(' 2D tria Mesh (vertical):')); 113 135 114 136 disp(sprintf('\n Elements and vertices:')); 115 fielddisplay( obj,'numberofelements','number of elements');116 fielddisplay( obj,'numberofvertices','number of vertices');117 fielddisplay( obj,'elements','vertex indices of the mesh elements');118 fielddisplay( obj,'x','vertices x coordinate [m]');119 fielddisplay( obj,'y','vertices y coordinate [m]');120 fielddisplay( obj,'edges','edges of the 2d mesh (vertex1 vertex2 element1 element2)');121 fielddisplay( obj,'numberofedges','number of edges of the 2d mesh');137 fielddisplay(self,'numberofelements','number of elements'); 138 fielddisplay(self,'numberofvertices','number of vertices'); 139 fielddisplay(self,'elements','vertex indices of the mesh elements'); 140 fielddisplay(self,'x','vertices x coordinate [m]'); 141 fielddisplay(self,'y','vertices y coordinate [m]'); 142 fielddisplay(self,'edges','edges of the 2d mesh (vertex1 vertex2 element1 element2)'); 143 fielddisplay(self,'numberofedges','number of edges of the 2d mesh'); 122 144 123 145 disp(sprintf('\n Properties:')); 124 fielddisplay( obj,'vertexonboundary','vertices on the boundary of the domain flag list');125 fielddisplay( obj,'vertexonbase','vertices on the bed of the domain flag list');126 fielddisplay( obj,'vertexonsurface','vertices on the surface of the domain flag list');127 fielddisplay( obj,'segments','edges on domain boundary (vertex1 vertex2 element)');128 fielddisplay( obj,'segmentmarkers','number associated to each segment');129 fielddisplay( obj,'vertexconnectivity','list of vertices connected to vertex_i');130 fielddisplay( obj,'elementconnectivity','list of vertices connected to element_i');131 fielddisplay( obj,'average_vertex_connectivity','average number of vertices connected to one vertex');146 fielddisplay(self,'vertexonboundary','vertices on the boundary of the domain flag list'); 147 fielddisplay(self,'vertexonbase','vertices on the bed of the domain flag list'); 148 fielddisplay(self,'vertexonsurface','vertices on the surface of the domain flag list'); 149 fielddisplay(self,'segments','edges on domain boundary (vertex1 vertex2 element)'); 150 fielddisplay(self,'segmentmarkers','number associated to each segment'); 151 fielddisplay(self,'vertexconnectivity','list of vertices connected to vertex_i'); 152 fielddisplay(self,'elementconnectivity','list of vertices connected to element_i'); 153 fielddisplay(self,'average_vertex_connectivity','average number of vertices connected to one vertex'); 132 154 133 155 disp(sprintf('\n Projection:')); 134 fielddisplay( obj,'lat','vertices latitude [degrees]');135 fielddisplay( obj,'long','vertices longitude [degrees]');136 fielddisplay( obj,'hemisphere','Indicate hemisphere ''n'' or ''s''');137 end % }}} 138 function marshall( obj,md,fid) % {{{139 WriteData(fid,'enum',DomainTypeEnum(),'data',StringToEnum(['Domain' domaintype( obj)]),'format','Integer');140 WriteData(fid,'enum',DomainDimensionEnum(),'data',dimension( obj),'format','Integer');141 WriteData(fid,'enum',MeshElementtypeEnum(),'data',StringToEnum(elementtype( obj)),'format','Integer');142 WriteData(fid,'object', obj,'class','mesh','fieldname','x','format','DoubleMat','mattype',1);143 WriteData(fid,'object', obj,'class','mesh','fieldname','y','format','DoubleMat','mattype',1);144 WriteData(fid,'enum',MeshZEnum(),'data',zeros( obj.numberofvertices,1),'format','DoubleMat','mattype',1);145 WriteData(fid,'object', obj,'class','mesh','fieldname','elements','format','DoubleMat','mattype',2);146 WriteData(fid,'object', obj,'class','mesh','fieldname','numberofelements','format','Integer');147 WriteData(fid,'object', obj,'class','mesh','fieldname','numberofvertices','format','Integer');148 WriteData(fid,'object', obj,'class','mesh','fieldname','vertexonbase','format','BooleanMat','mattype',1);149 WriteData(fid,'object', obj,'class','mesh','fieldname','vertexonsurface','format','BooleanMat','mattype',1);150 WriteData(fid,'object', obj,'class','mesh','fieldname','average_vertex_connectivity','format','Integer');151 end % }}} 152 function t = domaintype( obj) % {{{156 fielddisplay(self,'lat','vertices latitude [degrees]'); 157 fielddisplay(self,'long','vertices longitude [degrees]'); 158 fielddisplay(self,'epsg','EPSG code (ex: 3413 for UPS Greenland, 3031 for UPS Antarctica)'); 159 end % }}} 160 function marshall(self,md,fid) % {{{ 161 WriteData(fid,'enum',DomainTypeEnum(),'data',StringToEnum(['Domain' domaintype(self)]),'format','Integer'); 162 WriteData(fid,'enum',DomainDimensionEnum(),'data',dimension(self),'format','Integer'); 163 WriteData(fid,'enum',MeshElementtypeEnum(),'data',StringToEnum(elementtype(self)),'format','Integer'); 164 WriteData(fid,'object',self,'class','mesh','fieldname','x','format','DoubleMat','mattype',1); 165 WriteData(fid,'object',self,'class','mesh','fieldname','y','format','DoubleMat','mattype',1); 166 WriteData(fid,'enum',MeshZEnum(),'data',zeros(self.numberofvertices,1),'format','DoubleMat','mattype',1); 167 WriteData(fid,'object',self,'class','mesh','fieldname','elements','format','DoubleMat','mattype',2); 168 WriteData(fid,'object',self,'class','mesh','fieldname','numberofelements','format','Integer'); 169 WriteData(fid,'object',self,'class','mesh','fieldname','numberofvertices','format','Integer'); 170 WriteData(fid,'object',self,'class','mesh','fieldname','vertexonbase','format','BooleanMat','mattype',1); 171 WriteData(fid,'object',self,'class','mesh','fieldname','vertexonsurface','format','BooleanMat','mattype',1); 172 WriteData(fid,'object',self,'class','mesh','fieldname','average_vertex_connectivity','format','Integer'); 173 end % }}} 174 function t = domaintype(self) % {{{ 153 175 t = '2Dvertical'; 154 176 end % }}} 155 function d = dimension( obj) % {{{177 function d = dimension(self) % {{{ 156 178 d = 2; 157 179 end % }}} 158 function s = elementtype( obj) % {{{180 function s = elementtype(self) % {{{ 159 181 s = 'Tria'; 160 182 end % }}} -
issm/trunk/src/m/classes/mesh3dprisms.m
r18301 r19105 8 8 x = NaN; 9 9 y = NaN; 10 z = NaN 11 elements = NaN 10 z = NaN; 11 elements = NaN; 12 12 numberoflayers = 0; 13 13 numberofelements = 0; 14 14 numberofvertices = 0; 15 15 16 lat = NaN 17 long = NaN 18 hemisphere = NaN19 20 vertexonbase = NaN21 vertexonsurface = NaN 22 lowerelements = NaN 23 lowervertex = NaN 24 upperelements = NaN 25 uppervertex = NaN 26 vertexonboundary = NaN 27 28 vertexconnectivity = NaN 29 elementconnectivity = NaN 16 lat = NaN; 17 long = NaN; 18 epsg = 0; 19 20 vertexonbase = NaN; 21 vertexonsurface = NaN; 22 lowerelements = NaN; 23 lowervertex = NaN; 24 upperelements = NaN; 25 uppervertex = NaN; 26 vertexonboundary = NaN; 27 28 vertexconnectivity = NaN; 29 elementconnectivity = NaN; 30 30 average_vertex_connectivity = 0; 31 31 32 x2d = NaN 33 y2d = NaN 34 elements2d = NaN 32 x2d = NaN; 33 y2d = NaN; 34 elements2d = NaN; 35 35 numberofvertices2d = 0; 36 36 numberofelements2d = 0; 37 37 38 extractedvertices = NaN 39 extractedelements = NaN 38 extractedvertices = NaN; 39 extractedelements = NaN; 40 end 41 methods (Static) 42 function self = loadobj(self) % {{{ 43 % This function is directly called by matlab when a model selfect is 44 % loaded. Update old properties here 45 46 %2014 Oct. 1st 47 if isstruct(self), 48 oldself=self; 49 %Assign property values from struct 50 self=structtoobj(mesh3dprisms(),oldself); 51 if isfield(oldself,'hemisphere'), 52 disp('md.mesh.hemisphere has been automatically converted to EPSG code'); 53 if strcmpi(oldself.hemisphere,'n'), 54 self.epsg=3413; 55 else 56 self.epsg=3031; 57 end 58 end 59 end 60 61 end% }}} 40 62 end 41 63 methods 42 function createxml(obj,fid) % {{{43 44 45 46 47 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="numberofelements2d" type="',class(obj.numberofelements2d),'" default="',convert2str(obj.numberofelements2d),'">',' <help> number of elements </help>',' </parameter>');48 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="numberofvertices2d" type="',class(obj.numberofvertices2d),'" default="',convert2str(obj.numberofvertices2d),'">',' <help> number of vertices </help>',' </parameter>');49 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="elements2d" type="',class(obj.elements2d),'" default="',convert2str(obj.elements2d),'">',' <help> vertex indices of the mesh elements </help>',' </parameter>');50 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="x2d" type="',class(obj.x2d),'" default="',convert2str(obj.x2d),'">',' <section name="mesh3dprisms" />',' <help> vertices x coordinate [m] </help>',' </parameter>');51 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="y2d" type="',class(obj.y2d),'" default="',convert2str(obj.y2d),'">',' <section name="mesh3dprisms" />',' <help> vertices y coordinate [m] </help>',' </parameter>');52 53 54 55 56 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="numberofelements" type="',class(obj.numberofelements),'" default="',convert2str(obj.numberofelements),'">',' <help> number of elements </help>',' </parameter>');57 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="numberofvertices" type="',class(obj.numberofvertices),'" default="',convert2str(obj.numberofvertices),'">',' <help> number of vertices </help>',' </parameter>');58 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="elements" type="',class(obj.elements),'" default="',convert2str(obj.elements),'">',' <help> vertex indices of the mesh elements </help>',' </parameter>');59 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="x" type="',class(obj.x),'" default="',convert2str(obj.x),'">',' <section name="mesh3dprisms" />',' <help> vertices x coordinate [m] </help>',' </parameter>');60 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="y" type="',class(obj.y),'" default="',convert2str(obj.y),'">',' <section name="mesh3dprisms" />',' <help> vertices y coordinate [m] </help>',' </parameter>');61 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="z" type="',class(obj.y),'" default="',convert2str(obj.y),'">',' <section name="mesh3dprisms" />',' <help> vertices z coordinate [m] </help>',' </parameter>');62 63 64 65 66 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="numberoflayers" type="',class(obj.numberoflayers),'" default="',convert2str(obj.numberoflayers),'">',' <section name="mesh3dprisms" />',' <help> number of extrusion layers </help>',' </parameter>');67 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vertexonbase" type="',class(obj.vertexonbase),'" default="',convert2str(obj.vertexonbase),'">',' <section name="mesh3dprisms" />',' <help> lower vertices flags list </help>',' </parameter>');68 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="elementontbase" type="',class(obj.elementontbase),'" default="',convert2str(obj.elementontbase),'">',' <section name="mesh3dprisms" />',' <help> lower elements flags list </help>',' </parameter>');69 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vertexonsurface" type="',class(obj.vertexonsurface),'" default="',convert2str(obj.vertexonsurface),'">',' <section name="mesh3dprisms" />',' <help> upper vertices flags list </help>',' </parameter>');70 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="elementontsurface" type="',class(obj.elementontsurface),'" default="',convert2str(obj.elementontsurface),'">',' <section name="mesh3dprisms" />',' <help> upper elements flags list </help>',' </parameter>');71 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="uppervertex" type="',class(obj.uppervertex),'" default="',convert2str(obj.uppervertex),'">',' <section name="mesh3dprisms" />',' <help> upper vertex list (NaN for vertex on the upper surface) </help>',' </parameter>');72 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="upperelements" type="',class(obj.upperelements),'" default="',convert2str(obj.upperelements),'">',' <section name="mesh3dprisms" />',' <help> upper element list (NaN for element on the upper layer) </help>',' </parameter>');73 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="lowervertex" type="',class(obj.lowervertex),'" default="',convert2str(obj.lowervertex),'">',' <section name="mesh3dprisms" />',' <help> lower vertex list (NaN for vertex on the lower surface) </help>',' </parameter>');74 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="lowerelements" type="',class(obj.lowerelements),'" default="',convert2str(obj.lowerelements),'">',' <section name="mesh3dprisms" />',' <help> element list (NaN for element on the lower layer) </help>',' </parameter>');75 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vertexonboundary" type="',class(obj.vertexonboundary),'" default="',convert2str(obj.vertexonboundary),'">',' <section name="mesh3dprisms" />',' <help> vertices on the boundary of the domain flag list </help>',' </parameter>');76 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vertexconnectivity" type="',class(obj.vertexconnectivity),'" default="',convert2str(obj.vertexconnectivity),'">',' <section name="mesh3dprisms" />',' <help> list of vertices connected to vertex_i </help>',' </parameter>');77 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="elementconnectivity" type="',class(obj.elementconnectivity),'" default="',convert2str(obj.elementconnectivity),'">',' <section name="mesh3dprisms" />',' <help> average number of vertices connected to one vertex </help>',' </parameter>');78 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="average_vertex_connectivity" type="',class(obj.average_vertex_connectivity),'" default="',convert2str(obj.average_vertex_connectivity),'">',' <section name="mesh3dprisms" />',' <help> average number of vertices connected to one vertex </help>',' </parameter>');79 80 81 82 83 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="extractedvertices" type="',class(obj.extractedvertices),'" default="',convert2str(obj.extractedvertices),'">',' <section name="mesh3dprisms" />',' <help> vertices extracted from the model </help>',' </parameter>');84 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="extractedelements" type="',class(obj.extractedelements),'" default="',convert2str(obj.extractedelements),'">',' <section name="mesh3dprisms" />',' <help> elements extracted from the model </help>',' </parameter>');85 86 87 88 89 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="lat" type="',class(obj.lat),'" default="',convert2str(obj.lat),'">',' <section name="mesh3dprisms" />',' <help> vertices latitude [degrees] </help>',' </parameter>');90 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="long" type="',class(obj.long),'" default="',convert2str(obj.long),'">',' <section name="mesh3dprisms" />',' <help> verticies longitude [degrees] </help>',' </parameter>');91 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="hemisphere" type="',class(obj.hemisphere),'" default="',convert2str(obj.hemisphere),'">',' <section name="mesh3dprisms" />',' <help> Indicate hemisphere''n'' or ''s'' </help>',' </parameter>');92 93 94 64 function createxml(self,fid) % {{{ 65 fprintf(fid, '<!-- 3D prism Mesh -->\n'); 66 67 % Elements and verticies of the original 2d mesh 68 fprintf(fid,'%s\n%s\n%s\n',' <frame key="1" label="Elements and vertices of the orginal 2d mesh">',' <section name="mesh3dprisms" />'); 69 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="numberofelements2d" type="',class(self.numberofelements2d),'" default="',convert2str(self.numberofelements2d),'">',' <help> number of elements </help>',' </parameter>'); 70 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="numberofvertices2d" type="',class(self.numberofvertices2d),'" default="',convert2str(self.numberofvertices2d),'">',' <help> number of vertices </help>',' </parameter>'); 71 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="elements2d" type="',class(self.elements2d),'" default="',convert2str(self.elements2d),'">',' <help> vertex indices of the mesh elements </help>',' </parameter>'); 72 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="x2d" type="',class(self.x2d),'" default="',convert2str(self.x2d),'">',' <section name="mesh3dprisms" />',' <help> vertices x coordinate [m] </help>',' </parameter>'); 73 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="y2d" type="',class(self.y2d),'" default="',convert2str(self.y2d),'">',' <section name="mesh3dprisms" />',' <help> vertices y coordinate [m] </help>',' </parameter>'); 74 fprintf(fid,'%s\n%s\n',' </frame>'); 75 76 % Elements and vertices of the extruded 3d mesh 77 fprintf(fid,'%s\n%s\n%s\n',' <frame key="2" label="Elements and vertices of the orginal 3d mesh">',' <section name="mesh3dprisms" />'); 78 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="numberofelements" type="',class(self.numberofelements),'" default="',convert2str(self.numberofelements),'">',' <help> number of elements </help>',' </parameter>'); 79 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="numberofvertices" type="',class(self.numberofvertices),'" default="',convert2str(self.numberofvertices),'">',' <help> number of vertices </help>',' </parameter>'); 80 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="elements" type="',class(self.elements),'" default="',convert2str(self.elements),'">',' <help> vertex indices of the mesh elements </help>',' </parameter>'); 81 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="x" type="',class(self.x),'" default="',convert2str(self.x),'">',' <section name="mesh3dprisms" />',' <help> vertices x coordinate [m] </help>',' </parameter>'); 82 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="y" type="',class(self.y),'" default="',convert2str(self.y),'">',' <section name="mesh3dprisms" />',' <help> vertices y coordinate [m] </help>',' </parameter>'); 83 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="z" type="',class(self.y),'" default="',convert2str(self.y),'">',' <section name="mesh3dprisms" />',' <help> vertices z coordinate [m] </help>',' </parameter>'); 84 fprintf(fid,'%s\n%s\n',' </frame>'); 85 86 % properties 87 fprintf(fid,'%s\n%s\n%s\n','<frame key="3" label="Properties">','<section name="mesh3dprisms" />'); 88 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="numberoflayers" type="',class(self.numberoflayers),'" default="',convert2str(self.numberoflayers),'">',' <section name="mesh3dprisms" />',' <help> number of extrusion layers </help>',' </parameter>'); 89 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vertexonbase" type="',class(self.vertexonbase),'" default="',convert2str(self.vertexonbase),'">',' <section name="mesh3dprisms" />',' <help> lower vertices flags list </help>',' </parameter>'); 90 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="elementontbase" type="',class(self.elementontbase),'" default="',convert2str(self.elementontbase),'">',' <section name="mesh3dprisms" />',' <help> lower elements flags list </help>',' </parameter>'); 91 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vertexonsurface" type="',class(self.vertexonsurface),'" default="',convert2str(self.vertexonsurface),'">',' <section name="mesh3dprisms" />',' <help> upper vertices flags list </help>',' </parameter>'); 92 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="elementontsurface" type="',class(self.elementontsurface),'" default="',convert2str(self.elementontsurface),'">',' <section name="mesh3dprisms" />',' <help> upper elements flags list </help>',' </parameter>'); 93 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="uppervertex" type="',class(self.uppervertex),'" default="',convert2str(self.uppervertex),'">',' <section name="mesh3dprisms" />',' <help> upper vertex list (NaN for vertex on the upper surface) </help>',' </parameter>'); 94 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="upperelements" type="',class(self.upperelements),'" default="',convert2str(self.upperelements),'">',' <section name="mesh3dprisms" />',' <help> upper element list (NaN for element on the upper layer) </help>',' </parameter>'); 95 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="lowervertex" type="',class(self.lowervertex),'" default="',convert2str(self.lowervertex),'">',' <section name="mesh3dprisms" />',' <help> lower vertex list (NaN for vertex on the lower surface) </help>',' </parameter>'); 96 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="lowerelements" type="',class(self.lowerelements),'" default="',convert2str(self.lowerelements),'">',' <section name="mesh3dprisms" />',' <help> element list (NaN for element on the lower layer) </help>',' </parameter>'); 97 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vertexonboundary" type="',class(self.vertexonboundary),'" default="',convert2str(self.vertexonboundary),'">',' <section name="mesh3dprisms" />',' <help> vertices on the boundary of the domain flag list </help>',' </parameter>'); 98 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vertexconnectivity" type="',class(self.vertexconnectivity),'" default="',convert2str(self.vertexconnectivity),'">',' <section name="mesh3dprisms" />',' <help> list of vertices connected to vertex_i </help>',' </parameter>'); 99 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="elementconnectivity" type="',class(self.elementconnectivity),'" default="',convert2str(self.elementconnectivity),'">',' <section name="mesh3dprisms" />',' <help> average number of vertices connected to one vertex </help>',' </parameter>'); 100 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="average_vertex_connectivity" type="',class(self.average_vertex_connectivity),'" default="',convert2str(self.average_vertex_connectivity),'">',' <section name="mesh3dprisms" />',' <help> average number of vertices connected to one vertex </help>',' </parameter>'); 101 fprintf(fid,'%s\n%s\n','</frame>'); 102 103 % Extracted model 104 fprintf(fid,'%s\n%s\n%s\n','<frame key="4" label="Extracted Model">','<section name="mesh3dprisms" />'); 105 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="extractedvertices" type="',class(self.extractedvertices),'" default="',convert2str(self.extractedvertices),'">',' <section name="mesh3dprisms" />',' <help> vertices extracted from the model </help>',' </parameter>'); 106 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="extractedelements" type="',class(self.extractedelements),'" default="',convert2str(self.extractedelements),'">',' <section name="mesh3dprisms" />',' <help> elements extracted from the model </help>',' </parameter>'); 107 fprintf(fid,'%s\n%s\n','</frame>'); 108 109 % Projection 110 fprintf(fid,'%s\n%s\n%s\n','<frame key="5" label="Projection">','<section name="mesh3dprisms" />'); 111 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="lat" type="',class(self.lat),'" default="',convert2str(self.lat),'">',' <section name="mesh3dprisms" />',' <help> vertices latitude [degrees] </help>',' </parameter>'); 112 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="long" type="',class(self.long),'" default="',convert2str(self.long),'">',' <section name="mesh3dprisms" />',' <help> verticies longitude [degrees] </help>',' </parameter>'); 113 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="epsg" type="',class(self.epsg),'" default="',convert2str(self.epsg),'">',' <section name="mesh3dprisms" />',' <help> Indicate epsg ''n'' or ''s'' </help>',' </parameter>'); 114 fprintf(fid,'%s\n%s\n','</frame>'); 115 116 end % }}}cd 95 117 function self = mesh3dprisms(varargin) % {{{ 96 118 switch nargin … … 111 133 end 112 134 end % }}} 113 function obj = setdefaultparameters(obj) % {{{135 function self = setdefaultparameters(self) % {{{ 114 136 115 137 %the connectivity is the averaged number of nodes linked to a … … 118 140 %give a good memory/time ration. This value can be checked in 119 141 %trunk/test/Miscellaneous/runme.m 120 obj.average_vertex_connectivity=25;121 end % }}} 122 function md = checkconsistency( obj,md,solution,analyses) % {{{142 self.average_vertex_connectivity=25; 143 end % }}} 144 function md = checkconsistency(self,md,solution,analyses) % {{{ 123 145 124 146 md = checkfield(md,'fieldname','mesh.x','NaN',1,'size',[md.mesh.numberofvertices 1]); … … 133 155 md = checkfield(md,'fieldname','mesh.numberofelements','>',0); 134 156 md = checkfield(md,'fieldname','mesh.numberofvertices','>',0); 135 %no checks for numberofedges lat long and hemisphere136 157 md = checkfield(md,'fieldname','mesh.vertexonbase','size',[md.mesh.numberofvertices 1],'values',[0 1]); 137 158 md = checkfield(md,'fieldname','mesh.vertexonsurface','size',[md.mesh.numberofvertices 1],'values',[0 1]); … … 140 161 md = checkfield(md,'fieldname','mesh.average_vertex_connectivity','>=',24,'message','''mesh.average_vertex_connectivity'' should be at least 24 in 3d'); 141 162 end % }}} 142 function disp( obj) % {{{163 function disp(self) % {{{ 143 164 disp(sprintf(' 3D prism Mesh:')); 144 165 145 166 disp(sprintf('\n Elements and vertices of the original 2d mesh:')); 146 fielddisplay( obj,'numberofelements2d','number of elements');147 fielddisplay( obj,'numberofvertices2d','number of vertices');148 fielddisplay( obj,'elements2d','vertex indices of the mesh elements');149 fielddisplay( obj,'x2d','vertices x coordinate [m]');150 fielddisplay( obj,'y2d','vertices y coordinate [m]');167 fielddisplay(self,'numberofelements2d','number of elements'); 168 fielddisplay(self,'numberofvertices2d','number of vertices'); 169 fielddisplay(self,'elements2d','vertex indices of the mesh elements'); 170 fielddisplay(self,'x2d','vertices x coordinate [m]'); 171 fielddisplay(self,'y2d','vertices y coordinate [m]'); 151 172 152 173 disp(sprintf('\n Elements and vertices of the extruded 3d mesh:')); 153 fielddisplay( obj,'numberofelements','number of elements');154 fielddisplay( obj,'numberofvertices','number of vertices');155 fielddisplay( obj,'elements','vertex indices of the mesh elements');156 fielddisplay( obj,'x','vertices x coordinate [m]');157 fielddisplay( obj,'y','vertices y coordinate [m]');158 fielddisplay( obj,'z','vertices z coordinate [m]');174 fielddisplay(self,'numberofelements','number of elements'); 175 fielddisplay(self,'numberofvertices','number of vertices'); 176 fielddisplay(self,'elements','vertex indices of the mesh elements'); 177 fielddisplay(self,'x','vertices x coordinate [m]'); 178 fielddisplay(self,'y','vertices y coordinate [m]'); 179 fielddisplay(self,'z','vertices z coordinate [m]'); 159 180 160 181 disp(sprintf('\n Properties:')); 161 fielddisplay( obj,'numberoflayers','number of extrusion layers');162 fielddisplay( obj,'vertexonbase','lower vertices flags list');163 fielddisplay( obj,'vertexonsurface','upper vertices flags list');164 fielddisplay( obj,'uppervertex','upper vertex list (NaN for vertex on the upper surface)');165 fielddisplay( obj,'upperelements','upper element list (NaN for element on the upper layer)');166 fielddisplay( obj,'lowervertex','lower vertex list (NaN for vertex on the lower surface)');167 fielddisplay( obj,'lowerelements','lower element list (NaN for element on the lower layer');168 fielddisplay( obj,'vertexonboundary','vertices on the boundary of the domain flag list');169 170 fielddisplay( obj,'vertexconnectivity','list of vertices connected to vertex_i');171 fielddisplay( obj,'elementconnectivity','list of vertices connected to element_i');172 fielddisplay( obj,'average_vertex_connectivity','average number of vertices connected to one vertex');182 fielddisplay(self,'numberoflayers','number of extrusion layers'); 183 fielddisplay(self,'vertexonbase','lower vertices flags list'); 184 fielddisplay(self,'vertexonsurface','upper vertices flags list'); 185 fielddisplay(self,'uppervertex','upper vertex list (NaN for vertex on the upper surface)'); 186 fielddisplay(self,'upperelements','upper element list (NaN for element on the upper layer)'); 187 fielddisplay(self,'lowervertex','lower vertex list (NaN for vertex on the lower surface)'); 188 fielddisplay(self,'lowerelements','lower element list (NaN for element on the lower layer'); 189 fielddisplay(self,'vertexonboundary','vertices on the boundary of the domain flag list'); 190 191 fielddisplay(self,'vertexconnectivity','list of vertices connected to vertex_i'); 192 fielddisplay(self,'elementconnectivity','list of vertices connected to element_i'); 193 fielddisplay(self,'average_vertex_connectivity','average number of vertices connected to one vertex'); 173 194 174 195 disp(sprintf('\n Extracted model:')); 175 fielddisplay( obj,'extractedvertices','vertices extracted from the model');176 fielddisplay( obj,'extractedelements','elements extracted from the model');196 fielddisplay(self,'extractedvertices','vertices extracted from the model'); 197 fielddisplay(self,'extractedelements','elements extracted from the model'); 177 198 178 199 disp(sprintf('\n Projection:')); 179 fielddisplay( obj,'lat','vertices latitude [degrees]');180 fielddisplay( obj,'long','vertices longitude [degrees]');181 fielddisplay( obj,'hemisphere','Indicate hemisphere ''n'' or ''s''');182 end % }}} 183 function marshall( obj,md,fid) % {{{184 WriteData(fid,'enum',DomainTypeEnum(),'data',StringToEnum(['Domain' domaintype( obj)]),'format','Integer');185 WriteData(fid,'enum',DomainDimensionEnum(),'data',dimension( obj),'format','Integer');186 WriteData(fid,'enum',MeshElementtypeEnum(),'data',StringToEnum(elementtype( obj)),'format','Integer');187 WriteData(fid,'object', obj,'class','mesh','fieldname','x','format','DoubleMat','mattype',1);188 WriteData(fid,'object', obj,'class','mesh','fieldname','y','format','DoubleMat','mattype',1);189 WriteData(fid,'object', obj,'class','mesh','fieldname','z','format','DoubleMat','mattype',1);190 WriteData(fid,'object', obj,'class','mesh','fieldname','elements','format','DoubleMat','mattype',2);191 WriteData(fid,'object', obj,'class','mesh','fieldname','numberoflayers','format','Integer');192 WriteData(fid,'object', obj,'class','mesh','fieldname','numberofelements','format','Integer');193 WriteData(fid,'object', obj,'class','mesh','fieldname','numberofvertices','format','Integer');194 WriteData(fid,'object', obj,'class','mesh','fieldname','vertexonbase','format','BooleanMat','mattype',1);195 WriteData(fid,'object', obj,'class','mesh','fieldname','vertexonsurface','format','BooleanMat','mattype',1);196 WriteData(fid,'object', obj,'class','mesh','fieldname','lowerelements','format','DoubleMat','mattype',2);197 WriteData(fid,'object', obj,'class','mesh','fieldname','upperelements','format','DoubleMat','mattype',2);198 WriteData(fid,'object', obj,'class','mesh','fieldname','average_vertex_connectivity','format','Integer');199 WriteData(fid,'object', obj,'class','mesh','fieldname','elements2d','format','DoubleMat','mattype',3);200 WriteData(fid,'object', obj,'class','mesh','fieldname','numberofvertices2d','format','Integer');201 WriteData(fid,'object', obj,'class','mesh','fieldname','numberofelements2d','format','Integer');202 end % }}} 203 function type = domaintype( obj) % {{{200 fielddisplay(self,'lat','vertices latitude [degrees]'); 201 fielddisplay(self,'long','vertices longitude [degrees]'); 202 fielddisplay(self,'epsg','EPSG code (ex: 3413 for UPS Greenland, 3031 for UPS Antarctica)'); 203 end % }}} 204 function marshall(self,md,fid) % {{{ 205 WriteData(fid,'enum',DomainTypeEnum(),'data',StringToEnum(['Domain' domaintype(self)]),'format','Integer'); 206 WriteData(fid,'enum',DomainDimensionEnum(),'data',dimension(self),'format','Integer'); 207 WriteData(fid,'enum',MeshElementtypeEnum(),'data',StringToEnum(elementtype(self)),'format','Integer'); 208 WriteData(fid,'object',self,'class','mesh','fieldname','x','format','DoubleMat','mattype',1); 209 WriteData(fid,'object',self,'class','mesh','fieldname','y','format','DoubleMat','mattype',1); 210 WriteData(fid,'object',self,'class','mesh','fieldname','z','format','DoubleMat','mattype',1); 211 WriteData(fid,'object',self,'class','mesh','fieldname','elements','format','DoubleMat','mattype',2); 212 WriteData(fid,'object',self,'class','mesh','fieldname','numberoflayers','format','Integer'); 213 WriteData(fid,'object',self,'class','mesh','fieldname','numberofelements','format','Integer'); 214 WriteData(fid,'object',self,'class','mesh','fieldname','numberofvertices','format','Integer'); 215 WriteData(fid,'object',self,'class','mesh','fieldname','vertexonbase','format','BooleanMat','mattype',1); 216 WriteData(fid,'object',self,'class','mesh','fieldname','vertexonsurface','format','BooleanMat','mattype',1); 217 WriteData(fid,'object',self,'class','mesh','fieldname','lowerelements','format','DoubleMat','mattype',2); 218 WriteData(fid,'object',self,'class','mesh','fieldname','upperelements','format','DoubleMat','mattype',2); 219 WriteData(fid,'object',self,'class','mesh','fieldname','average_vertex_connectivity','format','Integer'); 220 WriteData(fid,'object',self,'class','mesh','fieldname','elements2d','format','DoubleMat','mattype',3); 221 WriteData(fid,'object',self,'class','mesh','fieldname','numberofvertices2d','format','Integer'); 222 WriteData(fid,'object',self,'class','mesh','fieldname','numberofelements2d','format','Integer'); 223 end % }}} 224 function type = domaintype(self) % {{{ 204 225 type = '3D'; 205 226 end % }}} 206 function d = dimension( obj) % {{{227 function d = dimension(self) % {{{ 207 228 d = 3; 208 229 end % }}} 209 function s = elementtype( obj) % {{{230 function s = elementtype(self) % {{{ 210 231 s = 'Penta'; 211 232 end % }}} -
issm/trunk/src/m/classes/mesh3dprisms.py
r18301 r19105 25 25 self.lat = float('NaN'); 26 26 self.long = float('NaN'); 27 self. hemisphere = float('NaN');27 self.epsg = 0; 28 28 29 self.vertexonbase 29 self.vertexonbase = float('NaN'); 30 30 self.vertexonsurface = float('NaN'); 31 31 self.lowerelements = float('NaN'); … … 90 90 string="%s\n%s"%(string,fielddisplay(self,"lat","vertices latitude [degrees]")) 91 91 string="%s\n%s"%(string,fielddisplay(self,"long","vertices longitude [degrees]")) 92 string="%s\n%s"%(string,fielddisplay(self," hemisphere","Indicate hemisphere 'n' or 's'"))92 string="%s\n%s"%(string,fielddisplay(self,"epsg","EPSG code (ex: 3413 for UPS Greenland, 3031 for UPS Antarctica)")) 93 93 return string 94 94 #}}} … … 116 116 md = checkfield(md,'fieldname','mesh.numberofelements','>',0) 117 117 md = checkfield(md,'fieldname','mesh.numberofvertices','>',0) 118 #no checks for numberofedges lat long and hemisphere119 118 md = checkfield(md,'fieldname','mesh.vertexonbase','size',[md.mesh.numberofvertices],'values',[0,1]) 120 119 md = checkfield(md,'fieldname','mesh.vertexonsurface','size',[md.mesh.numberofvertices],'values',[0,1]) -
issm/trunk/src/m/classes/mesh3dtetras.m
r17989 r19105 8 8 x = NaN; 9 9 y = NaN; 10 z = NaN 11 elements = NaN 10 z = NaN; 11 elements = NaN; 12 12 numberoflayers = 0; 13 13 numberofelements = 0; 14 14 numberofvertices = 0; 15 15 16 lat = NaN 17 long = NaN 18 hemisphere = NaN19 20 vertexonbase = NaN21 vertexonsurface = NaN 22 lowerelements = NaN 23 lowervertex = NaN 24 upperelements = NaN 25 uppervertex = NaN 26 vertexonboundary = NaN 27 28 vertexconnectivity = NaN 29 elementconnectivity = NaN 16 lat = NaN; 17 long = NaN; 18 epsg = 0; 19 20 vertexonbase = NaN; 21 vertexonsurface = NaN; 22 lowerelements = NaN; 23 lowervertex = NaN; 24 upperelements = NaN; 25 uppervertex = NaN; 26 vertexonboundary = NaN; 27 28 vertexconnectivity = NaN; 29 elementconnectivity = NaN; 30 30 average_vertex_connectivity = 0; 31 31 32 x2d = NaN 33 y2d = NaN 34 elements2d = NaN 32 x2d = NaN; 33 y2d = NaN; 34 elements2d = NaN; 35 35 numberofvertices2d = 0; 36 36 numberofelements2d = 0; 37 37 38 extractedvertices = NaN 39 extractedelements = NaN 38 extractedvertices = NaN; 39 extractedelements = NaN; 40 end 41 methods (Static) 42 function self = loadobj(self) % {{{ 43 % This function is directly called by matlab when a model selfect is 44 % loaded. Update old properties here 45 46 %2014 Oct. 1st 47 if isstruct(self), 48 oldself=self; 49 %Assign property values from struct 50 self=structtoobj(mesh3dtetras(),oldself); 51 if isfield(oldself,'hemisphere'), 52 disp('md.mesh.hemisphere has been automatically converted to EPSG code'); 53 if strcmpi(oldself.hemisphere,'n'), 54 self.epsg=3413; 55 else 56 self.epsg=3031; 57 end 58 end 59 end 60 61 end% }}} 40 62 end 41 63 methods 42 function createxml(obj,fid) % {{{43 44 45 46 47 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="numberofelements2d" type="',class(obj.numberofelements2d),'" default="',convert2str(obj.numberofelements2d),'">',' <help> number of elements </help>',' </parameter>');48 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="numberofvertices2d" type="',class(obj.numberofvertices2d),'" default="',convert2str(obj.numberofvertices2d),'">',' <help> number of vertices </help>',' </parameter>');49 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="elements2d" type="',class(obj.elements2d),'" default="',convert2str(obj.elements2d),'">',' <help> vertex indices of the mesh elements </help>',' </parameter>');50 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="x2d" type="',class(obj.x2d),'" default="',convert2str(obj.x2d),'">',' <section name="mesh3dprisms" />',' <help> vertices x coordinate [m] </help>',' </parameter>');51 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="y2d" type="',class(obj.y2d),'" default="',convert2str(obj.y2d),'">',' <section name="mesh3dprisms" />',' <help> vertices y coordinate [m] </help>',' </parameter>');52 53 54 55 56 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="numberofelements" type="',class(obj.numberofelements),'" default="',convert2str(obj.numberofelements),'">',' <help> number of elements </help>',' </parameter>');57 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="numberofvertices" type="',class(obj.numberofvertices),'" default="',convert2str(obj.numberofvertices),'">',' <help> number of vertices </help>',' </parameter>');58 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="elements" type="',class(obj.elements),'" default="',convert2str(obj.elements),'">',' <help> vertex indices of the mesh elements </help>',' </parameter>');59 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="x" type="',class(obj.x),'" default="',convert2str(obj.x),'">',' <section name="mesh3dprisms" />',' <help> vertices x coordinate [m] </help>',' </parameter>');60 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="y" type="',class(obj.y),'" default="',convert2str(obj.y),'">',' <section name="mesh3dprisms" />',' <help> vertices y coordinate [m] </help>',' </parameter>');61 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="z" type="',class(obj.y),'" default="',convert2str(obj.y),'">',' <section name="mesh3dprisms" />',' <help> vertices z coordinate [m] </help>',' </parameter>');62 63 64 65 66 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="numberoflayers" type="',class(obj.numberoflayers),'" default="',convert2str(obj.numberoflayers),'">',' <section name="mesh3dprisms" />',' <help> number of extrusion layers </help>',' </parameter>');67 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vertexonbase" type="',class(obj.vertexonbase),'" default="',convert2str(obj.vertexonbase),'">',' <section name="mesh3dprisms" />',' <help> lower vertices flags list </help>',' </parameter>');68 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="elementontbase" type="',class(obj.elementontbase),'" default="',convert2str(obj.elementontbase),'">',' <section name="mesh3dprisms" />',' <help> lower elements flags list </help>',' </parameter>');69 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vertexonsurface" type="',class(obj.vertexonsurface),'" default="',convert2str(obj.vertexonsurface),'">',' <section name="mesh3dprisms" />',' <help> upper vertices flags list </help>',' </parameter>');70 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="elementontsurface" type="',class(obj.elementontsurface),'" default="',convert2str(obj.elementontsurface),'">',' <section name="mesh3dprisms" />',' <help> upper elements flags list </help>',' </parameter>');71 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="uppervertex" type="',class(obj.uppervertex),'" default="',convert2str(obj.uppervertex),'">',' <section name="mesh3dprisms" />',' <help> upper vertex list (NaN for vertex on the upper surface) </help>',' </parameter>');72 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="upperelements" type="',class(obj.upperelements),'" default="',convert2str(obj.upperelements),'">',' <section name="mesh3dprisms" />',' <help> upper element list (NaN for element on the upper layer) </help>',' </parameter>');73 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="lowervertex" type="',class(obj.lowervertex),'" default="',convert2str(obj.lowervertex),'">',' <section name="mesh3dprisms" />',' <help> lower vertex list (NaN for vertex on the lower surface) </help>',' </parameter>');74 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="lowerelements" type="',class(obj.lowerelements),'" default="',convert2str(obj.lowerelements),'">',' <section name="mesh3dprisms" />',' <help> element list (NaN for element on the lower layer) </help>',' </parameter>');75 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vertexonboundary" type="',class(obj.vertexonboundary),'" default="',convert2str(obj.vertexonboundary),'">',' <section name="mesh3dprisms" />',' <help> vertices on the boundary of the domain flag list </help>',' </parameter>');76 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vertexconnectivity" type="',class(obj.vertexconnectivity),'" default="',convert2str(obj.vertexconnectivity),'">',' <section name="mesh3dprisms" />',' <help> list of vertices connected to vertex_i </help>',' </parameter>');77 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="elementconnectivity" type="',class(obj.elementconnectivity),'" default="',convert2str(obj.elementconnectivity),'">',' <section name="mesh3dprisms" />',' <help> average number of vertices connected to one vertex </help>',' </parameter>');78 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="average_vertex_connectivity" type="',class(obj.average_vertex_connectivity),'" default="',convert2str(obj.average_vertex_connectivity),'">',' <section name="mesh3dprisms" />',' <help> average number of vertices connected to one vertex </help>',' </parameter>');79 80 81 82 83 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="extractedvertices" type="',class(obj.extractedvertices),'" default="',convert2str(obj.extractedvertices),'">',' <section name="mesh3dprisms" />',' <help> vertices extracted from the model </help>',' </parameter>');84 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="extractedelements" type="',class(obj.extractedelements),'" default="',convert2str(obj.extractedelements),'">',' <section name="mesh3dprisms" />',' <help> elements extracted from the model </help>',' </parameter>');85 86 87 88 89 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="lat" type="',class(obj.lat),'" default="',convert2str(obj.lat),'">',' <section name="mesh3dprisms" />',' <help> vertices latitude [degrees] </help>',' </parameter>');90 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="long" type="',class(obj.long),'" default="',convert2str(obj.long),'">',' <section name="mesh3dprisms" />',' <help> verticies longitude [degrees] </help>',' </parameter>');91 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="hemisphere" type="',class(obj.hemisphere),'" default="',convert2str(obj.hemisphere),'">',' <section name="mesh3dprisms" />',' <help> Indicate hemisphere''n'' or ''s'' </help>',' </parameter>');92 93 94 64 function createxml(self,fid) % {{{ 65 fprintf(fid, '<!-- 3D Tetra Mesh -->\n'); 66 67 % Elements and verticies of the original 2d mesh 68 fprintf(fid,'%s\n%s\n%s\n',' <frame key="1" label="Elements and vertices of the orginal 2d mesh">',' <section name="mesh3dprisms" />'); 69 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="numberofelements2d" type="',class(self.numberofelements2d),'" default="',convert2str(self.numberofelements2d),'">',' <help> number of elements </help>',' </parameter>'); 70 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="numberofvertices2d" type="',class(self.numberofvertices2d),'" default="',convert2str(self.numberofvertices2d),'">',' <help> number of vertices </help>',' </parameter>'); 71 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="elements2d" type="',class(self.elements2d),'" default="',convert2str(self.elements2d),'">',' <help> vertex indices of the mesh elements </help>',' </parameter>'); 72 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="x2d" type="',class(self.x2d),'" default="',convert2str(self.x2d),'">',' <section name="mesh3dprisms" />',' <help> vertices x coordinate [m] </help>',' </parameter>'); 73 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="y2d" type="',class(self.y2d),'" default="',convert2str(self.y2d),'">',' <section name="mesh3dprisms" />',' <help> vertices y coordinate [m] </help>',' </parameter>'); 74 fprintf(fid,'%s\n%s\n',' </frame>'); 75 76 % Elements and vertices of the extruded 3d mesh 77 fprintf(fid,'%s\n%s\n%s\n',' <frame key="2" label="Elements and vertices of the orginal 3d mesh">',' <section name="mesh3dprisms" />'); 78 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="numberofelements" type="',class(self.numberofelements),'" default="',convert2str(self.numberofelements),'">',' <help> number of elements </help>',' </parameter>'); 79 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="numberofvertices" type="',class(self.numberofvertices),'" default="',convert2str(self.numberofvertices),'">',' <help> number of vertices </help>',' </parameter>'); 80 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="elements" type="',class(self.elements),'" default="',convert2str(self.elements),'">',' <help> vertex indices of the mesh elements </help>',' </parameter>'); 81 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="x" type="',class(self.x),'" default="',convert2str(self.x),'">',' <section name="mesh3dprisms" />',' <help> vertices x coordinate [m] </help>',' </parameter>'); 82 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="y" type="',class(self.y),'" default="',convert2str(self.y),'">',' <section name="mesh3dprisms" />',' <help> vertices y coordinate [m] </help>',' </parameter>'); 83 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="z" type="',class(self.y),'" default="',convert2str(self.y),'">',' <section name="mesh3dprisms" />',' <help> vertices z coordinate [m] </help>',' </parameter>'); 84 fprintf(fid,'%s\n%s\n',' </frame>'); 85 86 % properties 87 fprintf(fid,'%s\n%s\n%s\n','<frame key="3" label="Properties">','<section name="mesh3dprisms" />'); 88 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="numberoflayers" type="',class(self.numberoflayers),'" default="',convert2str(self.numberoflayers),'">',' <section name="mesh3dprisms" />',' <help> number of extrusion layers </help>',' </parameter>'); 89 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vertexonbase" type="',class(self.vertexonbase),'" default="',convert2str(self.vertexonbase),'">',' <section name="mesh3dprisms" />',' <help> lower vertices flags list </help>',' </parameter>'); 90 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="elementontbase" type="',class(self.elementontbase),'" default="',convert2str(self.elementontbase),'">',' <section name="mesh3dprisms" />',' <help> lower elements flags list </help>',' </parameter>'); 91 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vertexonsurface" type="',class(self.vertexonsurface),'" default="',convert2str(self.vertexonsurface),'">',' <section name="mesh3dprisms" />',' <help> upper vertices flags list </help>',' </parameter>'); 92 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="elementontsurface" type="',class(self.elementontsurface),'" default="',convert2str(self.elementontsurface),'">',' <section name="mesh3dprisms" />',' <help> upper elements flags list </help>',' </parameter>'); 93 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="uppervertex" type="',class(self.uppervertex),'" default="',convert2str(self.uppervertex),'">',' <section name="mesh3dprisms" />',' <help> upper vertex list (NaN for vertex on the upper surface) </help>',' </parameter>'); 94 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="upperelements" type="',class(self.upperelements),'" default="',convert2str(self.upperelements),'">',' <section name="mesh3dprisms" />',' <help> upper element list (NaN for element on the upper layer) </help>',' </parameter>'); 95 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="lowervertex" type="',class(self.lowervertex),'" default="',convert2str(self.lowervertex),'">',' <section name="mesh3dprisms" />',' <help> lower vertex list (NaN for vertex on the lower surface) </help>',' </parameter>'); 96 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="lowerelements" type="',class(self.lowerelements),'" default="',convert2str(self.lowerelements),'">',' <section name="mesh3dprisms" />',' <help> element list (NaN for element on the lower layer) </help>',' </parameter>'); 97 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vertexonboundary" type="',class(self.vertexonboundary),'" default="',convert2str(self.vertexonboundary),'">',' <section name="mesh3dprisms" />',' <help> vertices on the boundary of the domain flag list </help>',' </parameter>'); 98 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vertexconnectivity" type="',class(self.vertexconnectivity),'" default="',convert2str(self.vertexconnectivity),'">',' <section name="mesh3dprisms" />',' <help> list of vertices connected to vertex_i </help>',' </parameter>'); 99 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="elementconnectivity" type="',class(self.elementconnectivity),'" default="',convert2str(self.elementconnectivity),'">',' <section name="mesh3dprisms" />',' <help> average number of vertices connected to one vertex </help>',' </parameter>'); 100 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="average_vertex_connectivity" type="',class(self.average_vertex_connectivity),'" default="',convert2str(self.average_vertex_connectivity),'">',' <section name="mesh3dprisms" />',' <help> average number of vertices connected to one vertex </help>',' </parameter>'); 101 fprintf(fid,'%s\n%s\n','</frame>'); 102 103 % Extracted model 104 fprintf(fid,'%s\n%s\n%s\n','<frame key="4" label="Extracted Model">','<section name="mesh3dprisms" />'); 105 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="extractedvertices" type="',class(self.extractedvertices),'" default="',convert2str(self.extractedvertices),'">',' <section name="mesh3dprisms" />',' <help> vertices extracted from the model </help>',' </parameter>'); 106 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="extractedelements" type="',class(self.extractedelements),'" default="',convert2str(self.extractedelements),'">',' <section name="mesh3dprisms" />',' <help> elements extracted from the model </help>',' </parameter>'); 107 fprintf(fid,'%s\n%s\n','</frame>'); 108 109 % Projection 110 fprintf(fid,'%s\n%s\n%s\n','<frame key="5" label="Projection">','<section name="mesh3dprisms" />'); 111 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="lat" type="',class(self.lat),'" default="',convert2str(self.lat),'">',' <section name="mesh3dprisms" />',' <help> vertices latitude [degrees] </help>',' </parameter>'); 112 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="long" type="',class(self.long),'" default="',convert2str(self.long),'">',' <section name="mesh3dprisms" />',' <help> verticies longitude [degrees] </help>',' </parameter>'); 113 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n',' <parameter key ="epsg" type="',class(self.epsg),'" default="',convert2str(self.epsg),'">',' <section name="mesh3dprisms" />',' <help> Indicate epsg ''n'' or ''s'' </help>',' </parameter>'); 114 fprintf(fid,'%s\n%s\n','</frame>'); 115 116 end % }}}cd 95 117 function self = mesh3dtetras(varargin) % {{{ 96 118 switch nargin … … 111 133 end 112 134 end % }}} 113 function obj = setdefaultparameters(obj) % {{{135 function self = setdefaultparameters(self) % {{{ 114 136 115 137 %the connectivity is the averaged number of nodes linked to a … … 118 140 %give a good memory/time ration. This value can be checked in 119 141 %trunk/test/Miscellaneous/runme.m 120 obj.average_vertex_connectivity=25;121 end % }}} 122 function md = checkconsistency( obj,md,solution,analyses) % {{{142 self.average_vertex_connectivity=25; 143 end % }}} 144 function md = checkconsistency(self,md,solution,analyses) % {{{ 123 145 124 146 md = checkfield(md,'fieldname','mesh.x','NaN',1,'size',[md.mesh.numberofvertices 1]); … … 133 155 md = checkfield(md,'fieldname','mesh.numberofelements','>',0); 134 156 md = checkfield(md,'fieldname','mesh.numberofvertices','>',0); 135 %no checks for numberofedges lat long and hemisphere136 157 md = checkfield(md,'fieldname','mesh.vertexonbase','size',[md.mesh.numberofvertices 1],'values',[0 1]); 137 158 md = checkfield(md,'fieldname','mesh.vertexonsurface','size',[md.mesh.numberofvertices 1],'values',[0 1]); … … 140 161 md = checkfield(md,'fieldname','mesh.average_vertex_connectivity','>=',24,'message','''mesh.average_vertex_connectivity'' should be at least 24 in 3d'); 141 162 end % }}} 142 function disp( obj) % {{{163 function disp(self) % {{{ 143 164 disp(sprintf(' 3D tetra Mesh:')); 144 165 145 166 disp(sprintf('\n Elements and vertices of the original 2d mesh:')); 146 fielddisplay( obj,'numberofelements2d','number of elements');147 fielddisplay( obj,'numberofvertices2d','number of vertices');148 fielddisplay( obj,'elements2d','vertex indices of the mesh elements');149 fielddisplay( obj,'x2d','vertices x coordinate [m]');150 fielddisplay( obj,'y2d','vertices y coordinate [m]');167 fielddisplay(self,'numberofelements2d','number of elements'); 168 fielddisplay(self,'numberofvertices2d','number of vertices'); 169 fielddisplay(self,'elements2d','vertex indices of the mesh elements'); 170 fielddisplay(self,'x2d','vertices x coordinate [m]'); 171 fielddisplay(self,'y2d','vertices y coordinate [m]'); 151 172 152 173 disp(sprintf('\n Elements and vertices of the extruded 3d mesh:')); 153 fielddisplay( obj,'numberofelements','number of elements');154 fielddisplay( obj,'numberofvertices','number of vertices');155 fielddisplay( obj,'elements','vertex indices of the mesh elements');156 fielddisplay( obj,'x','vertices x coordinate [m]');157 fielddisplay( obj,'y','vertices y coordinate [m]');158 fielddisplay( obj,'z','vertices z coordinate [m]');174 fielddisplay(self,'numberofelements','number of elements'); 175 fielddisplay(self,'numberofvertices','number of vertices'); 176 fielddisplay(self,'elements','vertex indices of the mesh elements'); 177 fielddisplay(self,'x','vertices x coordinate [m]'); 178 fielddisplay(self,'y','vertices y coordinate [m]'); 179 fielddisplay(self,'z','vertices z coordinate [m]'); 159 180 160 181 disp(sprintf('\n Properties:')); 161 fielddisplay( obj,'numberoflayers','number of extrusion layers');162 fielddisplay( obj,'vertexonbase','lower vertices flags list');163 fielddisplay( obj,'vertexonsurface','upper vertices flags list');164 fielddisplay( obj,'uppervertex','upper vertex list (NaN for vertex on the upper surface)');165 fielddisplay( obj,'upperelements','upper element list (NaN for element on the upper layer)');166 fielddisplay( obj,'lowervertex','lower vertex list (NaN for vertex on the lower surface)');167 fielddisplay( obj,'lowerelements','lower element list (NaN for element on the lower layer');168 fielddisplay( obj,'vertexonboundary','vertices on the boundary of the domain flag list');169 170 fielddisplay( obj,'vertexconnectivity','list of vertices connected to vertex_i');171 fielddisplay( obj,'elementconnectivity','list of vertices connected to element_i');172 fielddisplay( obj,'average_vertex_connectivity','average number of vertices connected to one vertex');182 fielddisplay(self,'numberoflayers','number of extrusion layers'); 183 fielddisplay(self,'vertexonbase','lower vertices flags list'); 184 fielddisplay(self,'vertexonsurface','upper vertices flags list'); 185 fielddisplay(self,'uppervertex','upper vertex list (NaN for vertex on the upper surface)'); 186 fielddisplay(self,'upperelements','upper element list (NaN for element on the upper layer)'); 187 fielddisplay(self,'lowervertex','lower vertex list (NaN for vertex on the lower surface)'); 188 fielddisplay(self,'lowerelements','lower element list (NaN for element on the lower layer'); 189 fielddisplay(self,'vertexonboundary','vertices on the boundary of the domain flag list'); 190 191 fielddisplay(self,'vertexconnectivity','list of vertices connected to vertex_i'); 192 fielddisplay(self,'elementconnectivity','list of vertices connected to element_i'); 193 fielddisplay(self,'average_vertex_connectivity','average number of vertices connected to one vertex'); 173 194 174 195 disp(sprintf('\n Extracted model:')); 175 fielddisplay( obj,'extractedvertices','vertices extracted from the model');176 fielddisplay( obj,'extractedelements','elements extracted from the model');196 fielddisplay(self,'extractedvertices','vertices extracted from the model'); 197 fielddisplay(self,'extractedelements','elements extracted from the model'); 177 198 178 199 disp(sprintf('\n Projection:')); 179 fielddisplay( obj,'lat','vertices latitude [degrees]');180 fielddisplay( obj,'long','vertices longitude [degrees]');181 fielddisplay( obj,'hemisphere','Indicate hemisphere ''n'' or ''s''');182 end % }}} 183 function marshall( obj,md,fid) % {{{184 WriteData(fid,'enum',DomainTypeEnum(),'data',StringToEnum(['Domain' domaintype( obj)]),'format','Integer');185 WriteData(fid,'enum',DomainDimensionEnum(),'data',dimension( obj),'format','Integer');186 WriteData(fid,'enum',MeshElementtypeEnum(),'data',StringToEnum(elementtype( obj)),'format','Integer');187 WriteData(fid,'object', obj,'class','mesh','fieldname','x','format','DoubleMat','mattype',1);188 WriteData(fid,'object', obj,'class','mesh','fieldname','y','format','DoubleMat','mattype',1);189 WriteData(fid,'object', obj,'class','mesh','fieldname','z','format','DoubleMat','mattype',1);190 WriteData(fid,'object', obj,'class','mesh','fieldname','elements','format','DoubleMat','mattype',2);191 WriteData(fid,'object', obj,'class','mesh','fieldname','numberoflayers','format','Integer');192 WriteData(fid,'object', obj,'class','mesh','fieldname','numberofelements','format','Integer');193 WriteData(fid,'object', obj,'class','mesh','fieldname','numberofvertices','format','Integer');194 WriteData(fid,'object', obj,'class','mesh','fieldname','vertexonbase','format','BooleanMat','mattype',1);195 WriteData(fid,'object', obj,'class','mesh','fieldname','vertexonsurface','format','BooleanMat','mattype',1);196 WriteData(fid,'object', obj,'class','mesh','fieldname','lowerelements','format','DoubleMat','mattype',2);197 WriteData(fid,'object', obj,'class','mesh','fieldname','upperelements','format','DoubleMat','mattype',2);198 WriteData(fid,'object', obj,'class','mesh','fieldname','average_vertex_connectivity','format','Integer');199 WriteData(fid,'object', obj,'class','mesh','fieldname','elements2d','format','DoubleMat','mattype',3);200 WriteData(fid,'object', obj,'class','mesh','fieldname','numberofvertices2d','format','Integer');201 WriteData(fid,'object', obj,'class','mesh','fieldname','numberofelements2d','format','Integer');202 end % }}} 203 function t = domaintype( obj) % {{{200 fielddisplay(self,'lat','vertices latitude [degrees]'); 201 fielddisplay(self,'long','vertices longitude [degrees]'); 202 fielddisplay(self,'epsg','EPSG code (ex: 3413 for UPS Greenland, 3031 for UPS Antarctica)'); 203 end % }}} 204 function marshall(self,md,fid) % {{{ 205 WriteData(fid,'enum',DomainTypeEnum(),'data',StringToEnum(['Domain' domaintype(self)]),'format','Integer'); 206 WriteData(fid,'enum',DomainDimensionEnum(),'data',dimension(self),'format','Integer'); 207 WriteData(fid,'enum',MeshElementtypeEnum(),'data',StringToEnum(elementtype(self)),'format','Integer'); 208 WriteData(fid,'object',self,'class','mesh','fieldname','x','format','DoubleMat','mattype',1); 209 WriteData(fid,'object',self,'class','mesh','fieldname','y','format','DoubleMat','mattype',1); 210 WriteData(fid,'object',self,'class','mesh','fieldname','z','format','DoubleMat','mattype',1); 211 WriteData(fid,'object',self,'class','mesh','fieldname','elements','format','DoubleMat','mattype',2); 212 WriteData(fid,'object',self,'class','mesh','fieldname','numberoflayers','format','Integer'); 213 WriteData(fid,'object',self,'class','mesh','fieldname','numberofelements','format','Integer'); 214 WriteData(fid,'object',self,'class','mesh','fieldname','numberofvertices','format','Integer'); 215 WriteData(fid,'object',self,'class','mesh','fieldname','vertexonbase','format','BooleanMat','mattype',1); 216 WriteData(fid,'object',self,'class','mesh','fieldname','vertexonsurface','format','BooleanMat','mattype',1); 217 WriteData(fid,'object',self,'class','mesh','fieldname','lowerelements','format','DoubleMat','mattype',2); 218 WriteData(fid,'object',self,'class','mesh','fieldname','upperelements','format','DoubleMat','mattype',2); 219 WriteData(fid,'object',self,'class','mesh','fieldname','average_vertex_connectivity','format','Integer'); 220 WriteData(fid,'object',self,'class','mesh','fieldname','elements2d','format','DoubleMat','mattype',3); 221 WriteData(fid,'object',self,'class','mesh','fieldname','numberofvertices2d','format','Integer'); 222 WriteData(fid,'object',self,'class','mesh','fieldname','numberofelements2d','format','Integer'); 223 end % }}} 224 function t = domaintype(self) % {{{ 204 225 t = '3D'; 205 226 end % }}} 206 function d = dimension( obj) % {{{227 function d = dimension(self) % {{{ 207 228 d = 3; 208 229 end % }}} 209 function s = elementtype( obj) % {{{230 function s = elementtype(self) % {{{ 210 231 s = 'Tetra'; 211 232 end % }}} -
issm/trunk/src/m/classes/miscellaneous.m
r17806 r19105 11 11 end 12 12 methods 13 function createxml( obj,fid) % {{{13 function createxml(self,fid) % {{{ 14 14 fprintf(fid, '<!-- miscellaneous -->\n'); 15 15 16 16 % miscellaneous solution parameters 17 17 fprintf(fid,'%s\n%s\n%s\n','<frame key="1" label="miscellaneous parameters">','<section name="miscellaneous" />'); 18 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="notes" type="',class( obj.notes),'" default="',convert2str(obj.notes),'">',' <section name="miscellaneous" />',' <help> notes in a cell of strings </help>',' </parameter>');19 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="name" type="',class( obj.name),'" default="',convert2str(obj.name),'">',' <section name="miscellaneous" />',' <help> model name </help>',' </parameter>');20 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="dummy" type="',class( obj.dummy),'" default="',convert2str(obj.dummy),'">',' <section name="miscellaneous" />',' <help> empty field to store some data </help>',' </parameter>');18 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="notes" type="',class(self.notes),'" default="',convert2str(self.notes),'">',' <section name="miscellaneous" />',' <help> notes in a cell of strings </help>',' </parameter>'); 19 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="name" type="',class(self.name),'" default="',convert2str(self.name),'">',' <section name="miscellaneous" />',' <help> model name </help>',' </parameter>'); 20 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="dummy" type="',class(self.dummy),'" default="',convert2str(self.dummy),'">',' <section name="miscellaneous" />',' <help> empty field to store some data </help>',' </parameter>'); 21 21 fprintf(fid,'%s\n%s\n','</frame>'); 22 22 23 23 end % }}} 24 function obj= miscellaneous(varargin) % {{{24 function self = miscellaneous(varargin) % {{{ 25 25 switch nargin 26 26 case 0 27 obj=setdefaultparameters(obj);27 self=setdefaultparameters(self); 28 28 otherwise 29 29 error('constructor not supported'); 30 30 end 31 31 end % }}} 32 function md = checkconsistency( obj,md,solution,analyses) % {{{32 function md = checkconsistency(self,md,solution,analyses) % {{{ 33 33 34 34 md = checkfield(md,'fieldname','miscellaneous.name','empty',1); 35 35 36 36 end % }}} 37 function obj = setdefaultparameters(obj) % {{{37 function self = setdefaultparameters(self) % {{{ 38 38 39 39 end % }}} 40 function disp( obj) % {{{40 function disp(self) % {{{ 41 41 disp(sprintf(' miscellaneous parameters:')); 42 42 43 fielddisplay( obj,'notes','notes in a cell of strings');44 fielddisplay( obj,'name','model name');45 fielddisplay( obj,'dummy','empty field to store some data');43 fielddisplay(self,'notes','notes in a cell of strings'); 44 fielddisplay(self,'name','model name'); 45 fielddisplay(self,'dummy','empty field to store some data'); 46 46 47 47 end % }}} 48 function marshall( obj,md,fid) % {{{49 WriteData(fid,'object', obj,'fieldname','name','format','String');48 function marshall(self,md,fid) % {{{ 49 WriteData(fid,'object',self,'fieldname','name','format','String'); 50 50 end % }}} 51 51 end -
issm/trunk/src/m/classes/misfit.m
r17806 r19105 4 4 % misfit=misfit(); 5 5 % misfit=misfit('name','SurfaceAltimetry',... 6 % ' model_enum',SurfaceEnum,...6 % 'definitionenum',Outputdefinition1Enum, 'model_enum',SurfaceEnum,... 7 7 % 'observation_enum',SurfaceObservationsEnum,... 8 8 % 'observation',md.geometry.surface,... 9 9 % 'timeinterpolation','nearestneighbor',... 10 % 'local',1,... 10 11 % 'weights',ones(md.mesh.numberofvertices,1),... 11 12 % 'weights_enum',WeightsSurfaceObservationsEnum); … … 17 18 %misfit 18 19 name = ''; 20 definitionenum = NaN; %enum that identifies this output definition uniquely, from Outputdefinition[1-10]Enum 19 21 model_enum = NaN; %enum for field that is modeled 20 22 observation = NaN; %observed field that we compare the model against 21 23 observation_enum = NaN; %enum for observed field. 22 24 timeinterpolation = ''; 25 local = 1; 23 26 weights = NaN; %weight coefficients for every vertex 24 27 weights_enum = NaN; %enum to identify this particular set of weights … … 27 30 28 31 methods 29 function obj= misfit(varargin) % {{{32 function self = misfit(varargin) % {{{ 30 33 if nargin==0, 31 obj=setdefaultparameters(obj);34 self=setdefaultparameters(self); 32 35 else 33 36 %use provided options to change fields … … 35 38 36 39 %get name 37 obj.name=getfieldvalue(options,'name',''); 38 obj.model_enum=getfieldvalue(options,'model_enum'); 39 obj.observation=getfieldvalue(options,'observation',NaN); 40 obj.observation_enum=getfieldvalue(options,'observation_enum'); 41 obj.timeinterpolation=getfieldvalue(options,'timeinterpolation','nearestneighbor'); 42 obj.weights=getfieldvalue(options,'weights',NaN); 43 obj.weights_enum=getfieldvalue(options,'weights_enum',NaN); 40 self.name=getfieldvalue(options,'name',''); 41 self.definitionenum=getfieldvalue(options,'definitionenum'); 42 self.model_enum=getfieldvalue(options,'model_enum'); 43 self.observation=getfieldvalue(options,'observation',NaN); 44 self.observation_enum=getfieldvalue(options,'observation_enum'); 45 self.local=getfieldvalue(options,'local',1); 46 self.timeinterpolation=getfieldvalue(options,'timeinterpolation','nearestneighbor'); 47 self.weights=getfieldvalue(options,'weights',NaN); 48 self.weights_enum=getfieldvalue(options,'weights_enum',NaN); 44 49 45 50 end 46 51 end % }}} 47 function obj = setdefaultparameters(obj) % {{{ 48 obj.timeinterpolation='nearestneighbor'; 52 function self = setdefaultparameters(self) % {{{ 53 self.local=1; 54 self.timeinterpolation='nearestneighbor'; 49 55 end % }}} 50 function md = checkconsistency( obj,md,solution,analyses) % {{{56 function md = checkconsistency(self,md,solution,analyses) % {{{ 51 57 52 if ~ischar( obj.name),58 if ~ischar(self.name), 53 59 error('misfit error message: ''name'' field should be a string!'); 54 60 end 61 md = checkfield(md,'fieldname','self.definitionenum','field',self.definitionenum,'values',[Outputdefinition1Enum:Outputdefinition100Enum]); 55 62 56 if ~ischar( obj.timeinterpolation),63 if ~ischar(self.timeinterpolation), 57 64 error('misfit error message: ''timeinterpolation'' field should be a string!'); 58 65 end 59 md = checkfield(md,'fieldname',' obj.observation','field',obj.observation,'forcing',1,'NaN',1);60 md = checkfield(md,'fieldname',' obj.timeinterpolation','field',obj.timeinterpolation,'values',{'nearestneighbor'});61 md = checkfield(md,'fieldname',' obj.weights','field',obj.weights,'forcing',1,'NaN',1);66 md = checkfield(md,'fieldname','self.observation','field',self.observation,'timeseries',1,'NaN',1); 67 md = checkfield(md,'fieldname','self.timeinterpolation','field',self.timeinterpolation,'values',{'nearestneighbor'}); 68 md = checkfield(md,'fieldname','self.weights','field',self.weights,'timeseries',1,'NaN',1); 62 69 63 70 end % }}} 64 function md = disp( obj) % {{{71 function md = disp(self) % {{{ 65 72 66 73 disp(sprintf(' Misfit:\n')); 67 74 68 fielddisplay(obj,'name','identifier for this misfit response'); 69 fielddisplay(obj,'model_enum','enum for field that is modeled'); 70 fielddisplay(obj,'observation','observed field that we compare the model against'); 71 fielddisplay(obj,'observation_enum','observation enum'); 72 fielddisplay(obj,'timeinterpolation','interpolation routine used to interpolate misfit between two time steps (default is ''nearestneighbor'''); 73 fielddisplay(obj,'weights','weights (at vertices) to apply to the misfit'); 74 fielddisplay(obj,'weights_enum','enum for weights for identification purposes'); 75 fielddisplay(self,'name','identifier for this misfit response'); 76 fielddisplay(self,'definitionenum','enum that identifies this output definition uniquely, from Outputdefinition[1-10]Enum'); 77 fielddisplay(self,'model_enum','enum for field that is modeled'); 78 fielddisplay(self,'observation','observed field that we compare the model against'); 79 fielddisplay(self,'observation_enum','observation enum'); 80 fielddisplay(self,'local','is the response local to the elements, or global? (default is 1)'''); 81 fielddisplay(self,'timeinterpolation','interpolation routine used to interpolate misfit between two time steps (default is ''nearestneighbor'''); 82 fielddisplay(self,'weights','weights (at vertices) to apply to the misfit'); 83 fielddisplay(self,'weights_enum','enum for weights for identification purposes'); 75 84 76 85 end % }}} 77 function md = marshall( obj,md,fid) % {{{86 function md = marshall(self,md,fid) % {{{ 78 87 79 WriteData(fid,'object',obj,'fieldname','name','format','String'); 80 WriteData(fid,'object',obj,'fieldname','model_enum','format','Integer'); 81 WriteData(fid,'object',obj,'fieldname','observation','format','DoubleMat','mattype',1,'forcinglength',md.mesh.numberofvertices+1); 82 WriteData(fid,'object',obj,'fieldname','observation_enum','format','Integer'); 83 WriteData(fid,'object',obj,'fieldname','timeinterpolation','format','String'); 84 WriteData(fid,'object',obj,'fieldname','weights','format','DoubleMat','mattype',1,'forcinglength',md.mesh.numberofvertices+1); 85 WriteData(fid,'object',obj,'fieldname','weights_enum','format','Integer'); 88 WriteData(fid,'object',self,'fieldname','name','format','String'); 89 WriteData(fid,'object',self,'fieldname','definitionenum','format','Integer'); 90 WriteData(fid,'object',self,'fieldname','model_enum','format','Integer'); 91 WriteData(fid,'object',self,'fieldname','observation','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1); 92 WriteData(fid,'object',self,'fieldname','observation_enum','format','Integer'); 93 WriteData(fid,'object',self,'fieldname','local','format','Integer'); 94 WriteData(fid,'object',self,'fieldname','timeinterpolation','format','String'); 95 WriteData(fid,'object',self,'fieldname','weights','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1); 96 WriteData(fid,'object',self,'fieldname','weights_enum','format','Integer'); 86 97 87 98 end % }}} -
issm/trunk/src/m/classes/model.m
r18301 r19105 37 37 steadystate = 0; 38 38 transient = 0; 39 calving = 0; 39 40 gia = 0; 40 41 … … 124 125 end 125 126 end 127 %2014 November 12 128 if isa(md.calving,'double'); 129 md.calving=calving(); 130 end 126 131 end% }}} 127 132 end … … 132 137 case 0 133 138 md=setdefaultparameters(md); 139 case 1 140 error('model constructor not supported yet'); 141 134 142 otherwise 135 143 error('model constructor error message: 0 of 1 argument only in input.'); … … 162 170 %Start with changing all the fields from the 3d mesh 163 171 172 %dealing with the friciton law 164 173 %drag is limited to nodes that are on the bedrock. 165 md.friction.coefficient=project2d(md,md.friction.coefficient,1); 166 167 %p and q (same deal, except for element that are on the bedrock: ) 168 md.friction.p=project2d(md,md.friction.p,1); 169 md.friction.q=project2d(md,md.friction.q,1); 174 if isa(md.friction,'friction'), 175 md.friction.coefficient=project2d(md,md.friction.coefficient,1); 176 md.friction.p=project2d(md,md.friction.p,1); 177 md.friction.q=project2d(md,md.friction.q,1); 178 elseif isa(md.friction,'frictionhydro'), 179 md.friction.q=project2d(md,md.friction.q,1); 180 md.friction.C=project2d(md,md.friction.C,1); 181 md.friction.As=project2d(md,md.friction.As,1); 182 md.friction.effective_pressure=project2d(md,md.friction.effective_pressure,1); 183 elseif isa(md.friction,'frictionwaterlayer'), 184 md.friction.coefficient=project2d(md,md.friction.coefficient,1); 185 md.friction.p=project2d(md,md.friction.p,1); 186 md.friction.q=project2d(md,md.friction.q,1); 187 md.friction.water_layer=project2d(md,md.friction.water_layer,1); 188 elseif isa(md.friction,'frictionweertman'), 189 md.friction.C=project2d(md,md.friction.C,1); 190 md.friction.m=project2d(md,md.friction.m,1); 191 end 170 192 171 193 %observations … … 187 209 if ~isnan(md.initialization.vel),md.initialization.vel=DepthAverage(md,md.initialization.vel);end; 188 210 if ~isnan(md.initialization.temperature),md.initialization.temperature=DepthAverage(md,md.initialization.temperature);end; 189 211 if ~isnan(md.initialization.pressure),md.initialization.pressure=project2d(md,md.initialization.pressure,1);end; 212 if ~isnan(md.initialization.sediment_head),md.initialization.sediment_head=project2d(md,md.initialization.sediment_head,1);end; 213 if ~isnan(md.initialization.epl_head),md.initialization.epl_head=project2d(md,md.initialization.epl_head,1);end; 214 if ~isnan(md.initialization.epl_thickness),md.initialization.epl_thickness=project2d(md,md.initialization.epl_thickness,1);end; 190 215 %gia 191 216 if ~isnan(md.gia.mantle_viscosity), md.gia.mantle_viscosity=project2d(md,md.gia.mantle_viscosity,1); end … … 211 236 md.thermal.spctemperature=project2d(md,md.thermal.spctemperature,md.mesh.numberoflayers); 212 237 238 % Hydrologydc variables 239 if isa(md.hydrology,'hydrologydc'); 240 md.hydrology.spcsediment_head=project2d(md,md.hydrology.spcsediment_head,1); 241 md.hydrology.mask_eplactive_node=project2d(md,md.hydrology.mask_eplactive_node,1); 242 md.hydrology.sediment_transmitivity=project2d(md,md.hydrology.sediment_transmitivity,1); 243 md.hydrology.basal_moulin_input=project2d(md,md.hydrology.basal_moulin_input,1); 244 if(md.hydrology.isefficientlayer==1) 245 md.hydrology.spcepl_head=project2d(md,md.hydrology.spcepl_head,1); 246 end 247 end 248 213 249 %materials 214 250 md.materials.rheology_B=DepthAverage(md,md.materials.rheology_B); … … 221 257 222 258 %special for thermal modeling: 223 md.basalforcings.groundedice_melting_rate=project2d(md,md.basalforcings.groundedice_melting_rate,1); 224 md.basalforcings.floatingice_melting_rate=project2d(md,md.basalforcings.floatingice_melting_rate,1); 259 if ~isnan(md.basalforcings.groundedice_melting_rate), 260 md.basalforcings.groundedice_melting_rate=project2d(md,md.basalforcings.groundedice_melting_rate,1); 261 end 262 if ~isnan(md.basalforcings.floatingice_melting_rate), 263 md.basalforcings.floatingice_melting_rate=project2d(md,md.basalforcings.floatingice_melting_rate,1); 264 end 225 265 md.basalforcings.geothermalflux=project2d(md,md.basalforcings.geothermalflux,1); %bedrock only gets geothermal flux 226 266 … … 236 276 md.geometry.thickness=project2d(md,md.geometry.thickness,1); 237 277 md.geometry.base=project2d(md,md.geometry.base,1); 238 md.geometry.bed=project2d(md,md.geometry.bed,1); 239 240 md.mask.groundedice_levelset=project2d(md,md.mask.groundedice_levelset,1); 241 md.mask.ice_levelset=project2d(md,md.mask.ice_levelset,1); 278 if ~isnan(md.geometry.bed), 279 md.geometry.bed=project2d(md,md.geometry.bed,1); 280 end 281 282 if ~isnan(md.mask.groundedice_levelset), 283 md.mask.groundedice_levelset=project2d(md,md.mask.groundedice_levelset,1); 284 end 285 if ~isnan(md.mask.ice_levelset), 286 md.mask.ice_levelset=project2d(md,md.mask.ice_levelset,1); 287 end 242 288 243 289 %lat long … … 255 301 if ~isnan(md.mesh.elementconnectivity), mesh.elementconnectivity=project2d(md,md.mesh.elementconnectivity,1); end 256 302 md.mesh=mesh; 303 md.mesh.vertexconnectivity=NodeConnectivity(md.mesh.elements,md.mesh.numberofvertices); 304 md.mesh.elementconnectivity=ElementConnectivity(md.mesh.elements,md.mesh.vertexconnectivity); 305 md.mesh.segments=contourenvelope(md); 257 306 258 307 end % }}} … … 613 662 md.mesh.lat = mesh2d.lat; 614 663 md.mesh.long = mesh2d.long; 615 md.mesh. hemisphere = mesh2d.hemisphere;664 md.mesh.epsg = mesh2d.epsg; 616 665 617 666 md.mesh.vertexonboundary = mesh2d.vertexonboundary; … … 679 728 %Ok, now deal with the other fields from the 2d mesh: 680 729 730 %bedinfo and surface info 731 md.mesh.vertexonbase=project3d(md,'vector',ones(md.mesh.numberofvertices2d,1),'type','node','layer',1); 732 md.mesh.vertexonsurface=project3d(md,'vector',ones(md.mesh.numberofvertices2d,1),'type','node','layer',md.mesh.numberoflayers); 733 md.mesh.vertexonboundary=project3d(md,'vector',md.mesh.vertexonboundary,'type','node'); 734 681 735 %lat long 682 736 md.mesh.lat=project3d(md,'vector',md.mesh.lat,'type','node'); 683 737 md.mesh.long=project3d(md,'vector',md.mesh.long,'type','node'); 684 738 685 %drag coefficient is limited to nodes that are on the bedrock. 686 md.friction.coefficient=project3d(md,'vector',md.friction.coefficient,'type','node','layer',1); 687 688 %p and q (same deal, except for element that are on the bedrock: ) 689 md.friction.p=project3d(md,'vector',md.friction.p,'type','element'); 690 md.friction.q=project3d(md,'vector',md.friction.q,'type','element'); 691 692 %observations 693 md.inversion.vx_obs=project3d(md,'vector',md.inversion.vx_obs,'type','node'); 694 md.inversion.vy_obs=project3d(md,'vector',md.inversion.vy_obs,'type','node'); 695 md.inversion.vel_obs=project3d(md,'vector',md.inversion.vel_obs,'type','node'); 696 md.inversion.thickness_obs=project3d(md,'vector',md.inversion.thickness_obs,'type','node'); 739 md.geometry=extrude(md.geometry,md); 740 md.friction = extrude(md.friction,md); 741 md.inversion = extrude(md.inversion,md); 697 742 md.surfaceforcings = extrude(md.surfaceforcings,md); 698 md.balancethickness.thickening_rate=project3d(md,'vector',md.balancethickness.thickening_rate,'type','node'); 699 700 %results 701 if ~isnan(md.initialization.vx),md.initialization.vx=project3d(md,'vector',md.initialization.vx,'type','node');end; 702 if ~isnan(md.initialization.vy),md.initialization.vy=project3d(md,'vector',md.initialization.vy,'type','node');end; 703 if ~isnan(md.initialization.vz),md.initialization.vz=project3d(md,'vector',md.initialization.vz,'type','node');end; 704 if ~isnan(md.initialization.vel),md.initialization.vel=project3d(md,'vector',md.initialization.vel,'type','node');end; 705 if ~isnan(md.initialization.temperature),md.initialization.temperature=project3d(md,'vector',md.initialization.temperature,'type','node');end; 706 if ~isnan(md.initialization.waterfraction),md.initialization.waterfraction=project3d(md,'vector',md.initialization.waterfraction,'type','node');end; 707 if ~isnan(md.initialization.watercolumn),md.initialization.watercolumn=project3d(md,'vector',md.initialization.watercolumn,'type','node','layer',1);end; 708 if ~isnan(md.initialization.sediment_head),md.initialization.sediment_head=project3d(md,'vector',md.initialization.sediment_head,'type','node','layer',1);end; 709 if ~isnan(md.initialization.epl_head),md.initialization.epl_head=project3d(md,'vector',md.initialization.epl_head,'type','node','layer',1);end; 710 if ~isnan(md.initialization.epl_thickness),md.initialization.epl_thickness=project3d(md,'vector',md.initialization.epl_thickness,'type','node','layer',1);end; 711 712 %bedinfo and surface info 713 md.mesh.vertexonbase=project3d(md,'vector',ones(md.mesh.numberofvertices2d,1),'type','node','layer',1); 714 md.mesh.vertexonsurface=project3d(md,'vector',ones(md.mesh.numberofvertices2d,1),'type','node','layer',md.mesh.numberoflayers); 715 716 %elementstype 717 if ~isnan(md.flowequation.element_equation) 718 oldelements_type=md.flowequation.element_equation; 719 md.flowequation.element_equation=zeros(number_el3d,1); 720 md.flowequation.element_equation=project3d(md,'vector',oldelements_type,'type','element'); 721 end 722 723 %verticestype 724 if ~isnan(md.flowequation.vertex_equation) 725 oldvertices_type=md.flowequation.vertex_equation; 726 md.flowequation.vertex_equation=zeros(number_nodes3d,1); 727 md.flowequation.vertex_equation=project3d(md,'vector',oldvertices_type,'type','node'); 728 end 729 md.flowequation.borderSSA=project3d(md,'vector',md.flowequation.borderSSA,'type','node'); 730 md.flowequation.borderHO=project3d(md,'vector',md.flowequation.borderHO,'type','node'); 731 md.flowequation.borderFS=project3d(md,'vector',md.flowequation.borderFS,'type','node'); 732 733 %boundary conditions 734 md.stressbalance.spcvx=project3d(md,'vector',md.stressbalance.spcvx,'type','node'); 735 md.stressbalance.spcvy=project3d(md,'vector',md.stressbalance.spcvy,'type','node'); 736 md.stressbalance.spcvz=project3d(md,'vector',md.stressbalance.spcvz,'type','node'); 737 md.thermal.spctemperature=project3d(md,'vector',md.thermal.spctemperature,'type','node','layer',md.mesh.numberoflayers,'padding',NaN); 738 if (length(md.initialization.temperature)==md.mesh.numberofvertices), 739 md.thermal.spctemperature=NaN*ones(md.mesh.numberofvertices,1); 740 if isprop(md.mesh,'vertexonsurface'), 741 pos=find(md.mesh.vertexonsurface); 742 md.thermal.spctemperature(pos)=md.initialization.temperature(pos); %impose observed temperature on surface 743 end 744 end 745 md.masstransport.spcthickness=project3d(md,'vector',md.masstransport.spcthickness,'type','node'); 746 md.masstransport.calvingrate=project3d(md,'vector',md.masstransport.calvingrate,'type','node'); 747 md.balancethickness.spcthickness=project3d(md,'vector',md.balancethickness.spcthickness,'type','node'); 748 md.damage.spcdamage=project3d(md,'vector',md.damage.spcdamage,'type','node'); 749 md.stressbalance.referential=project3d(md,'vector',md.stressbalance.referential,'type','node'); 750 md.stressbalance.loadingforce=project3d(md,'vector',md.stressbalance.loadingforce,'type','node'); 751 752 % Hydrologydc variables 753 if isa(md.hydrology,'hydrologydc'); 754 md.hydrology.spcsediment_head=project3d(md,'vector',md.hydrology.spcsediment_head,'type','node','layer',1); 755 md.hydrology.spcepl_head=project3d(md,'vector',md.hydrology.spcepl_head,'type','node','layer',1); 756 md.hydrology.mask_eplactive_node=project3d(md,'vector',md.hydrology.mask_eplactive_node,'type','node','layer',1); 757 md.hydrology.sediment_transmitivity=project3d(md,'vector',md.hydrology.sediment_transmitivity,'type','node','layer',1); 758 md.hydrology.basal_moulin_input=project3d(md,'vector',md.hydrology.basal_moulin_input,'type','node','layer',1); 759 end 743 md.initialization = extrude(md.initialization,md); 744 745 md.flowequation=md.flowequation.extrude(md); 746 md.stressbalance=extrude(md.stressbalance,md); 747 md.thermal=md.thermal.extrude(md); 748 md.masstransport=md.masstransport.extrude(md); 749 md.calving=extrude(md.calving,md); 750 md.hydrology = extrude(md.hydrology,md); 760 751 761 752 %connectivity … … 770 761 end 771 762 772 %materials 773 md.materials.rheology_B=project3d(md,'vector',md.materials.rheology_B,'type','node'); 774 md.materials.rheology_n=project3d(md,'vector',md.materials.rheology_n,'type','element'); 775 776 %damage 777 md.damage.D=project3d(md,'vector',md.damage.D,'type','node'); 778 779 %parameters 780 md.geometry.surface=project3d(md,'vector',md.geometry.surface,'type','node'); 781 md.geometry.thickness=project3d(md,'vector',md.geometry.thickness,'type','node'); 782 md.gia.mantle_viscosity=project3d(md,'vector',md.gia.mantle_viscosity,'type','node'); 783 md.gia.lithosphere_thickness=project3d(md,'vector',md.gia.lithosphere_thickness,'type','node'); 784 md.geometry.hydrostatic_ratio=project3d(md,'vector',md.geometry.hydrostatic_ratio,'type','node'); 785 md.geometry.base=project3d(md,'vector',md.geometry.base,'type','node'); 786 md.geometry.bed=project3d(md,'vector',md.geometry.bed,'type','node'); 787 md.mesh.vertexonboundary=project3d(md,'vector',md.mesh.vertexonboundary,'type','node'); 788 md.mask.groundedice_levelset=project3d(md,'vector',md.mask.groundedice_levelset,'type','node'); 789 md.mask.ice_levelset=project3d(md,'vector',md.mask.ice_levelset,'type','node'); 790 if ~isnan(md.inversion.cost_functions_coefficients),md.inversion.cost_functions_coefficients=project3d(md,'vector',md.inversion.cost_functions_coefficients,'type','node');end; 791 if ~isnan(md.inversion.min_parameters),md.inversion.min_parameters=project3d(md,'vector',md.inversion.min_parameters,'type','node');end; 792 if ~isnan(md.inversion.max_parameters),md.inversion.max_parameters=project3d(md,'vector',md.inversion.max_parameters,'type','node');end; 793 if ~isnan(md.qmu.partition),md.qmu.partition=project3d(md,'vector',md.qmu.partition','type','node');end 794 795 %Put lithostatic pressure if there is an existing pressure 796 if ~isnan(md.initialization.pressure), 797 md.initialization.pressure=md.constants.g*md.materials.rho_ice*(md.geometry.surface-md.mesh.z); 798 end 799 800 %special for thermal modeling: 801 md.basalforcings.groundedice_melting_rate=project3d(md,'vector',md.basalforcings.groundedice_melting_rate,'type','node','layer',1); 802 md.basalforcings.floatingice_melting_rate=project3d(md,'vector',md.basalforcings.floatingice_melting_rate,'type','node','layer',1); 803 if ~isnan(md.basalforcings.geothermalflux) 804 md.basalforcings.geothermalflux=project3d(md,'vector',md.basalforcings.geothermalflux,'type','node','layer',1); %bedrock only gets geothermal flux 805 end 763 md.materials=extrude(md.materials,md); 764 md.damage=extrude(md.damage,md); 765 md.mask=extrude(md.mask,md); 766 md.qmu=extrude(md.qmu,md); 767 md.basalforcings=extrude(md.basalforcings,md); 806 768 807 769 %increase connectivity if less than 25: … … 825 787 if isfield(structmd,'p'), md.friction.p=structmd.p; end 826 788 if isfield(structmd,'q'), md.friction.q=structmd.p; end 827 if isfield(structmd,'melting'), md.basalforcings. melting_rate=structmd.melting; end789 if isfield(structmd,'melting'), md.basalforcings.floatingice_melting_rate=structmd.melting; end 828 790 if isfield(structmd,'melting_rate'), md.basalforcings.floatingice_melting_rate=structmd.melting_rate; end 791 if isfield(structmd,'melting_rate'), md.basalforcings.groundedice_melting_rate=structmd.melting_rate; end 829 792 if isfield(structmd,'accumulation'), md.surfaceforcings.mass_balance=structmd.accumulation; end 830 793 if isfield(structmd,'numberofgrids'), md.mesh.numberofvertices=structmd.numberofgrids; end … … 923 886 if isfield(structmd,'extractedelements'), md.mesh.extractedelements=structmd.extractedelements; end 924 887 if isfield(structmd,'nodeonboundary'), md.mesh.vertexonboundary=structmd.nodeonboundary; end 925 if isfield(structmd,'hemisphere'), md.mesh.hemisphere=structmd.hemisphere; end926 888 if isfield(structmd,'lat'), md.mesh.lat=structmd.lat; end 927 889 if isfield(structmd,'long'), md.mesh.long=structmd.long; end … … 1106 1068 md.steadystate = steadystate(); 1107 1069 md.transient = transient(); 1070 md.calving = calving(); 1108 1071 md.gia = gia(); 1109 1072 md.autodiff = autodiff(); … … 1248 1211 end 1249 1212 end % }}} 1250 function disp(obj) % {{{ 1251 disp(sprintf('%19s: %-22s -- %s','mesh' ,['[1x1 ' class(obj.mesh) ']'],'mesh properties')); 1252 disp(sprintf('%19s: %-22s -- %s','mask' ,['[1x1 ' class(obj.mask) ']'],'defines grounded and floating elements')); 1253 disp(sprintf('%19s: %-22s -- %s','geometry' ,['[1x1 ' class(obj.geometry) ']'],'surface elevation, bedrock topography, ice thickness,...')); 1254 disp(sprintf('%19s: %-22s -- %s','constants' ,['[1x1 ' class(obj.constants) ']'],'physical constants')); 1255 disp(sprintf('%19s: %-22s -- %s','surfaceforcings' ,['[1x1 ' class(obj.surfaceforcings) ']'],'surface forcings')); 1256 disp(sprintf('%19s: %-22s -- %s','basalforcings' ,['[1x1 ' class(obj.basalforcings) ']'],'bed forcings')); 1257 disp(sprintf('%19s: %-22s -- %s','materials' ,['[1x1 ' class(obj.materials) ']'],'material properties')); 1258 disp(sprintf('%19s: %-22s -- %s','damage' ,['[1x1 ' class(obj.damage) ']'],'parameters for damage evolution solution')); 1259 disp(sprintf('%19s: %-22s -- %s','friction' ,['[1x1 ' class(obj.friction) ']'],'basal friction/drag properties')); 1260 disp(sprintf('%19s: %-22s -- %s','flowequation' ,['[1x1 ' class(obj.flowequation) ']'],'flow equations')); 1261 disp(sprintf('%19s: %-22s -- %s','timestepping' ,['[1x1 ' class(obj.timestepping) ']'],'time stepping for transient models')); 1262 disp(sprintf('%19s: %-22s -- %s','initialization' ,['[1x1 ' class(obj.initialization) ']'],'initial guess/state')); 1263 disp(sprintf('%19s: %-22s -- %s','rifts' ,['[1x1 ' class(obj.rifts) ']'],'rifts properties')); 1264 disp(sprintf('%19s: %-22s -- %s','debug' ,['[1x1 ' class(obj.debug) ']'],'debugging tools (valgrind, gprof)')); 1265 disp(sprintf('%19s: %-22s -- %s','verbose' ,['[1x1 ' class(obj.verbose) ']'],'verbosity level in solve')); 1266 disp(sprintf('%19s: %-22s -- %s','settings' ,['[1x1 ' class(obj.settings) ']'],'settings properties')); 1267 disp(sprintf('%19s: %-22s -- %s','toolkits' ,['[1x1 ' class(obj.toolkits) ']'],'PETSc options for each solution')); 1268 disp(sprintf('%19s: %-22s -- %s','cluster' ,['[1x1 ' class(obj.cluster) ']'],'cluster parameters (number of cpus...)')); 1269 disp(sprintf('%19s: %-22s -- %s','balancethickness',['[1x1 ' class(obj.balancethickness) ']'],'parameters for balancethickness solution')); 1270 disp(sprintf('%19s: %-22s -- %s','stressbalance' ,['[1x1 ' class(obj.stressbalance) ']'],'parameters for stressbalance solution')); 1271 disp(sprintf('%19s: %-22s -- %s','groundingline' ,['[1x1 ' class(obj.groundingline) ']'],'parameters for groundingline solution')); 1272 disp(sprintf('%19s: %-22s -- %s','hydrology' ,['[1x1 ' class(obj.hydrology) ']'],'parameters for hydrology solution')); 1273 disp(sprintf('%19s: %-22s -- %s','masstransport' ,['[1x1 ' class(obj.masstransport) ']'],'parameters for masstransport solution')); 1274 disp(sprintf('%19s: %-22s -- %s','thermal' ,['[1x1 ' class(obj.thermal) ']'],'parameters for thermal solution')); 1275 disp(sprintf('%19s: %-22s -- %s','steadystate' ,['[1x1 ' class(obj.steadystate) ']'],'parameters for steadystate solution')); 1276 disp(sprintf('%19s: %-22s -- %s','transient' ,['[1x1 ' class(obj.transient) ']'],'parameters for transient solution')); 1277 disp(sprintf('%19s: %-22s -- %s','gia' ,['[1x1 ' class(obj.gia) ']'],'parameters for gia solution')); 1278 disp(sprintf('%19s: %-22s -- %s','autodiff' ,['[1x1 ' class(obj.autodiff) ']'],'automatic differentiation parameters')); 1279 disp(sprintf('%19s: %-22s -- %s','flaim' ,['[1x1 ' class(obj.flaim) ']'],'flaim parameters')); 1280 disp(sprintf('%19s: %-22s -- %s','inversion' ,['[1x1 ' class(obj.inversion) ']'],'parameters for inverse methods')); 1281 disp(sprintf('%19s: %-22s -- %s','qmu' ,['[1x1 ' class(obj.qmu) ']'],'dakota properties')); 1282 disp(sprintf('%19s: %-22s -- %s','outputdefinition',['[1x1 ' class(obj.outputdefinition) ']'],'output definition')); 1283 disp(sprintf('%19s: %-22s -- %s','results' ,['[1x1 ' class(obj.results) ']'],'model results')); 1284 disp(sprintf('%19s: %-22s -- %s','radaroverlay' ,['[1x1 ' class(obj.radaroverlay) ']'],'radar image for plot overlay')); 1285 disp(sprintf('%19s: %-22s -- %s','miscellaneous' ,['[1x1 ' class(obj.miscellaneous) ']'],'miscellaneous fields')); 1213 function disp(self) % {{{ 1214 disp(sprintf('%19s: %-22s -- %s','mesh' ,['[1x1 ' class(self.mesh) ']'],'mesh properties')); 1215 disp(sprintf('%19s: %-22s -- %s','mask' ,['[1x1 ' class(self.mask) ']'],'defines grounded and floating elements')); 1216 disp(sprintf('%19s: %-22s -- %s','geometry' ,['[1x1 ' class(self.geometry) ']'],'surface elevation, bedrock topography, ice thickness,...')); 1217 disp(sprintf('%19s: %-22s -- %s','constants' ,['[1x1 ' class(self.constants) ']'],'physical constants')); 1218 disp(sprintf('%19s: %-22s -- %s','surfaceforcings' ,['[1x1 ' class(self.surfaceforcings) ']'],'surface forcings')); 1219 disp(sprintf('%19s: %-22s -- %s','basalforcings' ,['[1x1 ' class(self.basalforcings) ']'],'bed forcings')); 1220 disp(sprintf('%19s: %-22s -- %s','materials' ,['[1x1 ' class(self.materials) ']'],'material properties')); 1221 disp(sprintf('%19s: %-22s -- %s','damage' ,['[1x1 ' class(self.damage) ']'],'parameters for damage evolution solution')); 1222 disp(sprintf('%19s: %-22s -- %s','friction' ,['[1x1 ' class(self.friction) ']'],'basal friction/drag properties')); 1223 disp(sprintf('%19s: %-22s -- %s','flowequation' ,['[1x1 ' class(self.flowequation) ']'],'flow equations')); 1224 disp(sprintf('%19s: %-22s -- %s','timestepping' ,['[1x1 ' class(self.timestepping) ']'],'time stepping for transient models')); 1225 disp(sprintf('%19s: %-22s -- %s','initialization' ,['[1x1 ' class(self.initialization) ']'],'initial guess/state')); 1226 disp(sprintf('%19s: %-22s -- %s','rifts' ,['[1x1 ' class(self.rifts) ']'],'rifts properties')); 1227 disp(sprintf('%19s: %-22s -- %s','debug' ,['[1x1 ' class(self.debug) ']'],'debugging tools (valgrind, gprof)')); 1228 disp(sprintf('%19s: %-22s -- %s','verbose' ,['[1x1 ' class(self.verbose) ']'],'verbosity level in solve')); 1229 disp(sprintf('%19s: %-22s -- %s','settings' ,['[1x1 ' class(self.settings) ']'],'settings properties')); 1230 disp(sprintf('%19s: %-22s -- %s','toolkits' ,['[1x1 ' class(self.toolkits) ']'],'PETSc options for each solution')); 1231 disp(sprintf('%19s: %-22s -- %s','cluster' ,['[1x1 ' class(self.cluster) ']'],'cluster parameters (number of cpus...)')); 1232 disp(sprintf('%19s: %-22s -- %s','balancethickness',['[1x1 ' class(self.balancethickness) ']'],'parameters for balancethickness solution')); 1233 disp(sprintf('%19s: %-22s -- %s','stressbalance' ,['[1x1 ' class(self.stressbalance) ']'],'parameters for stressbalance solution')); 1234 disp(sprintf('%19s: %-22s -- %s','groundingline' ,['[1x1 ' class(self.groundingline) ']'],'parameters for groundingline solution')); 1235 disp(sprintf('%19s: %-22s -- %s','hydrology' ,['[1x1 ' class(self.hydrology) ']'],'parameters for hydrology solution')); 1236 disp(sprintf('%19s: %-22s -- %s','masstransport' ,['[1x1 ' class(self.masstransport) ']'],'parameters for masstransport solution')); 1237 disp(sprintf('%19s: %-22s -- %s','thermal' ,['[1x1 ' class(self.thermal) ']'],'parameters for thermal solution')); 1238 disp(sprintf('%19s: %-22s -- %s','steadystate' ,['[1x1 ' class(self.steadystate) ']'],'parameters for steadystate solution')); 1239 disp(sprintf('%19s: %-22s -- %s','transient' ,['[1x1 ' class(self.transient) ']'],'parameters for transient solution')); 1240 disp(sprintf('%19s: %-22s -- %s','calving' ,['[1x1 ' class(self.calving) ']'],'parameters for calving')); 1241 disp(sprintf('%19s: %-22s -- %s','gia' ,['[1x1 ' class(self.gia) ']'],'parameters for gia solution')); 1242 disp(sprintf('%19s: %-22s -- %s','autodiff' ,['[1x1 ' class(self.autodiff) ']'],'automatic differentiation parameters')); 1243 disp(sprintf('%19s: %-22s -- %s','flaim' ,['[1x1 ' class(self.flaim) ']'],'flaim parameters')); 1244 disp(sprintf('%19s: %-22s -- %s','inversion' ,['[1x1 ' class(self.inversion) ']'],'parameters for inverse methods')); 1245 disp(sprintf('%19s: %-22s -- %s','qmu' ,['[1x1 ' class(self.qmu) ']'],'dakota properties')); 1246 disp(sprintf('%19s: %-22s -- %s','outputdefinition',['[1x1 ' class(self.outputdefinition) ']'],'output definition')); 1247 disp(sprintf('%19s: %-22s -- %s','results' ,['[1x1 ' class(self.results) ']'],'model results')); 1248 disp(sprintf('%19s: %-22s -- %s','radaroverlay' ,['[1x1 ' class(self.radaroverlay) ']'],'radar image for plot overlay')); 1249 disp(sprintf('%19s: %-22s -- %s','miscellaneous' ,['[1x1 ' class(self.miscellaneous) ']'],'miscellaneous fields')); 1286 1250 end % }}} 1287 function memory( obj) % {{{1251 function memory(self) % {{{ 1288 1252 1289 1253 disp(sprintf('\nMemory imprint:\n')); … … 1293 1257 1294 1258 for i=1:length(fields), 1295 field= obj.(fields{i});1259 field=self.(fields{i}); 1296 1260 s=whos('field'); 1297 1261 mem=mem+s.bytes/1e6; … … 1301 1265 disp(sprintf('%19s: %g Mb','Total',mem)); 1302 1266 end % }}} 1303 function netcdf( obj,filename) % {{{1267 function netcdf(self,filename) % {{{ 1304 1268 %NETCDF - save model as netcdf 1305 1269 % … … 1314 1278 ncid=netcdf.create(filename,'CLOBBER'); 1315 1279 netcdf.putAtt(ncid,netcdf.getConstant('NC_GLOBAL'),'Conventions','CF-1.4'); 1316 netcdf.putAtt(ncid,netcdf.getConstant('NC_GLOBAL'),'Title',['ISSM model (' obj.miscellaneous.name ')']);1280 netcdf.putAtt(ncid,netcdf.getConstant('NC_GLOBAL'),'Title',['ISSM model (' self.miscellaneous.name ')']); 1317 1281 netcdf.putAtt(ncid,netcdf.getConstant('NC_GLOBAL'),'Author',getenv('USER')); 1318 1282 netcdf.putAtt(ncid,netcdf.getConstant('NC_GLOBAL'),'Date',datestr(now)); … … 1323 1287 for step=1:2, 1324 1288 counter=0; 1325 [var_id,counter]=structtonc(ncid,'md', obj,0,var_id,counter,step);1289 [var_id,counter]=structtonc(ncid,'md',self,0,var_id,counter,step); 1326 1290 if step==1, netcdf.endDef(ncid); end 1327 1291 end … … 1333 1297 netcdf.close(ncid) 1334 1298 end % }}} 1335 function xylim( obj) % {{{1336 1337 xlim([min( obj.mesh.x) max(obj.mesh.x)]);1338 ylim([min( obj.mesh.y) max(obj.mesh.y)])1299 function xylim(self) % {{{ 1300 1301 xlim([min(self.mesh.x) max(self.mesh.x)]); 1302 ylim([min(self.mesh.y) max(self.mesh.y)]) 1339 1303 end % }}} 1340 1304 function md=upload(md) % {{{ -
issm/trunk/src/m/classes/model.py
r18301 r19105 15 15 from basalforcings import basalforcings 16 16 from matice import matice 17 from calving import calving 18 from calvinglevermann import calvinglevermann 19 #from calvingpi import calvingpi 17 20 from damage import damage 18 21 from friction import friction … … 30 33 from groundingline import groundingline 31 34 from hydrologyshreve import hydrologyshreve 35 from hydrologydc import hydrologydc 32 36 from masstransport import masstransport 33 37 from thermal import thermal … … 59 63 #properties 60 64 def __init__(self):#{{{ 65 66 # classtype=model.properties 67 68 # for classe in dict.keys(classtype): 69 # print classe 70 # self.__dict__[classe] = classtype[str(classe)] 71 61 72 self.mesh = mesh2d() 62 73 self.mask = mask() … … 80 91 81 92 self.balancethickness = balancethickness() 82 self.stressbalance 93 self.stressbalance = stressbalance() 83 94 self.groundingline = groundingline() 84 95 self.hydrology = hydrologyshreve() 85 self.masstransport 96 self.masstransport = masstransport() 86 97 self.thermal = thermal() 87 98 self.steadystate = steadystate() 88 99 self.transient = transient() 100 self.calving = calving() 89 101 self.gia = gia() 90 102 … … 128 140 'steadystate',\ 129 141 'transient',\ 130 'gia',\ 142 'calving',\ 143 'gia',\ 131 144 'autodiff',\ 132 145 'flaim',\ … … 167 180 string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("steadystate","[%s,%s]" % ("1x1",obj.steadystate.__class__.__name__),"parameters for steadystate solution")) 168 181 string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("transient","[%s,%s]" % ("1x1",obj.transient.__class__.__name__),"parameters for transient solution")) 182 string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("calving","[%s,%s]" % ("1x1",obj.calving.__class__.__name__),"parameters for calving")) 169 183 string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("autodiff","[%s,%s]" % ("1x1",obj.autodiff.__class__.__name__),"automatic differentiation parameters")) 170 184 string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("flaim","[%s,%s]" % ("1x1",obj.flaim.__class__.__name__),"flaim parameters")) … … 517 531 md.mesh.lat = mesh2d.lat 518 532 md.mesh.long = mesh2d.long 519 md.mesh. hemisphere = mesh2d.hemisphere533 md.mesh.epsg = mesh2d.epsg 520 534 521 535 md.mesh.vertexonboundary = mesh2d.vertexonboundary … … 581 595 #Ok, now deal with the other fields from the 2d mesh: 582 596 597 #bedinfo and surface info 598 md.mesh.vertexonbase=project3d(md,'vector',numpy.ones(md.mesh.numberofvertices2d,bool),'type','node','layer',1) 599 md.mesh.vertexonsurface=project3d(md,'vector',numpy.ones(md.mesh.numberofvertices2d,bool),'type','node','layer',md.mesh.numberoflayers) 600 md.mesh.vertexonboundary=project3d(md,'vector',md.mesh.vertexonboundary,'type','node') 601 583 602 #lat long 584 603 md.mesh.lat=project3d(md,'vector',md.mesh.lat,'type','node') 585 604 md.mesh.long=project3d(md,'vector',md.mesh.long,'type','node') 586 605 587 #drag coefficient is limited to nodes that are on the bedrock. 588 md.friction.coefficient=project3d(md,'vector',md.friction.coefficient,'type','node','layer',1) 589 590 #p and q (same deal, except for element that are on the bedrock: ) 591 md.friction.p=project3d(md,'vector',md.friction.p,'type','element') 592 md.friction.q=project3d(md,'vector',md.friction.q,'type','element') 593 594 #observations 595 md.inversion.vx_obs=project3d(md,'vector',md.inversion.vx_obs,'type','node') 596 md.inversion.vy_obs=project3d(md,'vector',md.inversion.vy_obs,'type','node') 597 md.inversion.vel_obs=project3d(md,'vector',md.inversion.vel_obs,'type','node') 598 md.inversion.thickness_obs=project3d(md,'vector',md.inversion.thickness_obs,'type','node') 606 md.geometry.extrude(md) 607 md.friction.extrude(md) 608 md.inversion.extrude(md) 599 609 md.surfaceforcings.extrude(md) 600 md.balancethickness.thickening_rate=project3d(md,'vector',md.balancethickness.thickening_rate,'type','node') 601 602 #results 603 if not numpy.any(numpy.isnan(md.initialization.vx)): 604 md.initialization.vx=project3d(md,'vector',md.initialization.vx,'type','node') 605 if not numpy.any(numpy.isnan(md.initialization.vy)): 606 md.initialization.vy=project3d(md,'vector',md.initialization.vy,'type','node') 607 if not numpy.any(numpy.isnan(md.initialization.vz)): 608 md.initialization.vz=project3d(md,'vector',md.initialization.vz,'type','node') 609 if not numpy.any(numpy.isnan(md.initialization.vel)): 610 md.initialization.vel=project3d(md,'vector',md.initialization.vel,'type','node') 611 if not numpy.any(numpy.isnan(md.initialization.temperature)): 612 md.initialization.temperature=project3d(md,'vector',md.initialization.temperature,'type','node') 613 if not numpy.any(numpy.isnan(md.initialization.waterfraction)): 614 md.initialization.waterfraction=project3d(md,'vector',md.initialization.waterfraction,'type','node') 615 if not numpy.any(numpy.isnan(md.initialization.watercolumn)): 616 md.initialization.watercolumn=project3d(md,'vector',md.initialization.watercolumn,'type','node') 617 618 619 #bedinfo and surface info 620 md.mesh.vertexonbase=project3d(md,'vector',numpy.ones(md.mesh.numberofvertices2d,bool),'type','node','layer',1) 621 md.mesh.vertexonsurface=project3d(md,'vector',numpy.ones(md.mesh.numberofvertices2d,bool),'type','node','layer',md.mesh.numberoflayers) 622 623 #elementstype 624 if not numpy.any(numpy.isnan(md.flowequation.element_equation)): 625 oldelements_type=md.flowequation.element_equation 626 md.flowequation.element_equation=numpy.zeros(number_el3d,int) 627 md.flowequation.element_equation=project3d(md,'vector',oldelements_type,'type','element') 628 629 #verticestype 630 if not numpy.any(numpy.isnan(md.flowequation.vertex_equation)): 631 oldvertices_type=md.flowequation.vertex_equation 632 md.flowequation.vertex_equation=numpy.zeros(number_nodes3d,int) 633 md.flowequation.vertex_equation=project3d(md,'vector',oldvertices_type,'type','node') 634 635 md.flowequation.borderSSA=project3d(md,'vector',md.flowequation.borderSSA,'type','node') 636 md.flowequation.borderHO=project3d(md,'vector',md.flowequation.borderHO,'type','node') 637 md.flowequation.borderFS=project3d(md,'vector',md.flowequation.borderFS,'type','node') 638 639 #boundary conditions 640 md.stressbalance.spcvx=project3d(md,'vector',md.stressbalance.spcvx,'type','node') 641 md.stressbalance.spcvy=project3d(md,'vector',md.stressbalance.spcvy,'type','node') 642 md.stressbalance.spcvz=project3d(md,'vector',md.stressbalance.spcvz,'type','node') 643 md.thermal.spctemperature=project3d(md,'vector',md.thermal.spctemperature,'type','node','layer',md.mesh.numberoflayers,'padding',numpy.nan) 644 if isinstance(md.initialization.temperature,numpy.ndarray) and numpy.size(md.initialization.temperature,axis=0)==md.mesh.numberofvertices: 645 md.thermal.spctemperature=numpy.nan*numpy.ones((md.mesh.numberofvertices,1)) 646 if hasattr(md.mesh,'vertexonsurface'): 647 pos=numpy.nonzero(md.mesh.vertexonsurface)[0] 648 md.thermal.spctemperature[pos]=md.initialization.temperature[pos] #impose observed temperature on surface 649 md.masstransport.spcthickness=project3d(md,'vector',md.masstransport.spcthickness,'type','node') 650 md.balancethickness.spcthickness=project3d(md,'vector',md.balancethickness.spcthickness,'type','node') 651 md.damage.spcdamage=project3d(md,'vector',md.damage.spcdamage,'type','node') 652 md.stressbalance.referential=project3d(md,'vector',md.stressbalance.referential,'type','node') 653 md.stressbalance.loadingforce=project3d(md,'vector',md.stressbalance.loadingforce,'type','node') 654 md.masstransport.calvingrate=project3d(md,'vector',md.masstransport.calvingrate,'type','node') 610 md.initialization.extrude(md) 611 md.flowequation.extrude(md) 612 613 md.stressbalance.extrude(md) 614 md.thermal.extrude(md) 615 md.masstransport.extrude(md) 616 617 # Calving variables 618 md.hydrology.extrude(md) 619 md.calving.extrude(md) 655 620 656 621 #connectivity … … 663 628 md.mesh.elementconnectivity[numpy.nonzero(md.mesh.elementconnectivity<0)]=0 664 629 665 #materials 666 md.materials.rheology_B=project3d(md,'vector',md.materials.rheology_B,'type','node') 667 md.materials.rheology_n=project3d(md,'vector',md.materials.rheology_n,'type','element') 668 669 #damage 670 md.damage.D=project3d(md,'vector',md.damage.D,'type','node') 671 672 #parameters 673 md.geometry.surface=project3d(md,'vector',md.geometry.surface,'type','node') 674 md.geometry.thickness=project3d(md,'vector',md.geometry.thickness,'type','node') 675 md.gia.mantle_viscosity=project3d(md,'vector',md.gia.mantle_viscosity,'type','node') 676 md.gia.lithosphere_thickness=project3d(md,'vector',md.gia.lithosphere_thickness,'type','node') 677 md.geometry.hydrostatic_ratio=project3d(md,'vector',md.geometry.hydrostatic_ratio,'type','node') 678 md.geometry.base=project3d(md,'vector',md.geometry.base,'type','node') 679 md.geometry.bed=project3d(md,'vector',md.geometry.bed,'type','node') 680 md.mesh.vertexonboundary=project3d(md,'vector',md.mesh.vertexonboundary,'type','node') 681 md.mask.ice_levelset=project3d(md,'vector',md.mask.ice_levelset,'type','node') 682 md.mask.groundedice_levelset=project3d(md,'vector',md.mask.groundedice_levelset,'type','node') 683 if not numpy.any(numpy.isnan(md.inversion.cost_functions_coefficients)): 684 md.inversion.cost_functions_coefficients=project3d(md,'vector',md.inversion.cost_functions_coefficients,'type','node') 685 if not numpy.any(numpy.isnan(md.inversion.min_parameters)): 686 md.inversion.min_parameters=project3d(md,'vector',md.inversion.min_parameters,'type','node') 687 if not numpy.any(numpy.isnan(md.inversion.max_parameters)): 688 md.inversion.max_parameters=project3d(md,'vector',md.inversion.max_parameters,'type','node') 689 if not numpy.any(numpy.isnan(md.qmu.partition)): 690 md.qmu.partition=project3d(md,'vector',numpy.transpose(md.qmu.partition),'type','node') 691 692 #Put lithostatic pressure if there is an existing pressure 693 if not numpy.any(numpy.isnan(md.initialization.pressure)): 694 md.initialization.pressure=md.constants.g*md.materials.rho_ice*(md.geometry.surface-md.mesh.z.reshape(-1,1)) 695 696 #special for thermal modeling: 697 md.basalforcings.groundedice_melting_rate=project3d(md,'vector',md.basalforcings.groundedice_melting_rate,'type','node','layer',1) 698 md.basalforcings.floatingice_melting_rate=project3d(md,'vector',md.basalforcings.floatingice_melting_rate,'type','node','layer',1) 699 if not numpy.any(numpy.isnan(md.basalforcings.geothermalflux)): 700 md.basalforcings.geothermalflux=project3d(md,'vector',md.basalforcings.geothermalflux,'type','node','layer',1) #bedrock only gets geothermal flux 630 md.materials.extrude(md) 631 md.damage.extrude(md) 632 md.gia.extrude(md) 633 md.mask.extrude(md) 634 md.qmu.extrude(md) 635 md.basalforcings.extrude(md) 701 636 702 637 #increase connectivity if less than 25: … … 746 681 if not numpy.isnan(md.initialization.vel).all(): md.initialization.vel=DepthAverage(md,md.initialization.vel) 747 682 if not numpy.isnan(md.initialization.temperature).all(): md.initialization.temperature=DepthAverage(md,md.initialization.temperature) 683 if not numpy.isnan(md.initialization.pressure).all(): md.initialization.pressure=project2d(md,md.initialization.pressure,1) 684 if not numpy.isnan(md.initialization.sediment_head).all(): md.initialization.sediment_head=project2d(md,md.initialization.sediment_head,1) 685 if not numpy.isnan(md.initialization.epl_head).all(): md.initialization.epl_head=project2d(md,md.initialization.epl_head,1) 686 if not numpy.isnan(md.initialization.epl_thickness).all(): md.initialization.epl_thickness=project2d(md,md.initialization.epl_thickness,1) 748 687 749 688 #gia … … 758 697 md.flowequation.borderHO=project2d(md,md.flowequation.borderHO,1) 759 698 md.flowequation.borderFS=project2d(md,md.flowequation.borderFS,1) 699 700 701 # Hydrologydc variables 702 if hasattr(md.hydrology,'hydrologydc'): 703 md.hydrology.spcsediment_head=project2d(md,md.hydrology.spcsediment_head,1) 704 md.hydrology.mask_eplactive_node=project2d(md,md.hydrology.mask_eplactive_node,1) 705 md.hydrology.sediment_transmitivity=project2d(md,md.hydrology.sediment_transmitivity,1) 706 md.hydrology.basal_moulin_input=project2d(md,md.hydrology.basal_moulin_input,1) 707 if md.hydrology.isefficientlayer == 1: 708 md.hydrology.spcepl_head=project2d(md,md.hydrology.spcepl_head,1) 760 709 761 710 #boundary conditions -
issm/trunk/src/m/classes/modellist.m
r17806 r19105 122 122 123 123 end % }}} 124 function obj= modellist(varargin) % {{{124 function self = modellist(varargin) % {{{ 125 125 126 126 %initialize list … … 146 146 end 147 147 148 obj.models = celllist;149 obj.cluster = obj.models{1}.cluster;150 end 151 end % }}} 152 function val = get( obj, propName)% {{{148 self.models = celllist; 149 self.cluster = self.models{1}.cluster; 150 end 151 end % }}} 152 function val = get(self, propName)% {{{ 153 153 %GET - gets model propertie from a specified object ans returns the value 154 154 % … … 158 158 switch propName 159 159 case 'numberofelements' 160 val = obj.numberofelements;160 val = self.numberofelements; 161 161 case 'numberofnodes' 162 val = obj.numberofnodes;162 val = self.numberofnodes; 163 163 case 'elements' 164 val = obj.elements;164 val = self.elements; 165 165 case 'x' 166 val = obj.x;166 val = self.x; 167 167 case 'y' 168 val = obj.y;168 val = self.y; 169 169 case 'z' 170 val = obj.z;170 val = self.z; 171 171 otherwise 172 172 error(['get error message: ' propName,' is not a valid model property']) 173 173 end 174 174 end % }}} 175 function obj = loadmultipleresultsfromcluster(obj) % {{{175 function self = loadmultipleresultsfromcluster(self) % {{{ 176 176 %LOADMULTIPLERESULTSFROMCLUSTER - load multiple results of solution sequences from cluster 177 177 % 178 178 % Usage: 179 % obj=loadresultsfromcluster(obj);180 181 nummodels=length( obj.models);179 % self=loadresultsfromcluster(self); 180 181 nummodels=length(self.models); 182 182 183 183 %Get cluster settings 184 cluster= obj.cluster;185 name= obj.name;184 cluster=self.cluster; 185 name=self.name; 186 186 cluster_rc_location=which('cluster.rc'); 187 187 [codepath,executionpath]=ClusterParameters(cluster,cluster_rc_location); … … 200 200 for i=1:nummodels, 201 201 %load results for this model 202 obj.models{i}=loadresultsfromdisk(obj.models{i},[name '-' num2str(i) 'vs' num2str(nummodels) '.outbin']);202 self.models{i}=loadresultsfromdisk(self.models{i},[name '-' num2str(i) 'vs' num2str(nummodels) '.outbin']); 203 203 204 204 delete([name '-' num2str(i) 'vs' num2str(nummodels) '.outbin']); … … 208 208 delete('ModelResults.tar.gz'); 209 209 end % }}} 210 function obj = solve(obj,varargin)% {{{210 function self = solve(self,varargin)% {{{ 211 211 %SOLVE - apply solution sequence for a list of models. Used in batch mode. 212 212 % 213 213 % Usage: 214 % obj=solve(obj,varargin)214 % self=solve(self,varargin) 215 215 % where varargin is a lit of paired arguments. 216 216 % arguments can be: 'analysis_type': 'stressbalance','thermal','masstransport','transient' 217 217 % 218 218 % Examples: 219 % obj=solve(obj,'analysis_type','stressbalance');219 % self=solve(self,'analysis_type','stressbalance'); 220 220 221 221 %recover options … … 226 226 227 227 %length of list 228 nummodels=length( obj.models);228 nummodels=length(self.models); 229 229 230 230 %name of queue: to make it unique, add a time stamp 231 name=[ obj.name '-' datestr(now,1) '-' datestr(now,'HH-MM-SS') ];231 name=[self.name '-' datestr(now,1) '-' datestr(now,'HH-MM-SS') ]; 232 232 233 233 %name of cluster will be first name of list 234 cluster= obj.cluster;234 cluster=self.cluster; 235 235 236 236 %Figure out parameters for this particular cluster … … 242 242 243 243 %model 244 mdex= obj.models{i};244 mdex=self.models{i}; 245 245 246 246 %recover some fields … … 248 248 249 249 mdex.name=[name '-' num2str(i) 'vs' num2str(nummodels)]; 250 mdex.time= obj.time;251 mdex.queue= obj.queue;252 mdex.cluster= obj.cluster;253 if ~isnan( obj.np),254 mdex.np= obj.np;250 mdex.time=self.time; 251 mdex.queue=self.queue; 252 mdex.cluster=self.cluster; 253 if ~isnan(self.np), 254 mdex.np=self.np; 255 255 end 256 256 … … 263 263 264 264 %feed back 265 obj.models{i}=mdex;265 self.models{i}=mdex; 266 266 end 267 267 … … 287 287 288 288 %save name: 289 obj.name=name;289 self.name=name; 290 290 end % }}} 291 291 end -
issm/trunk/src/m/classes/organizer.py
r17806 r19105 151 151 return bool 152 152 #}}} 153 def savemodel(self,md ): # {{{153 def savemodel(self,md, name='default'): # {{{ 154 154 155 155 #check … … 159 159 raise RuntimeError("Cannot save model because organizer (org) is not up to date!") 160 160 161 name=os.path.join(self.repository,self.prefix+'.step#'+self.steps[self._currentstep-1]['string']+'.python') 161 if (name=='default'): 162 name=os.path.join(self.repository,self.prefix+'.step#'+self.steps[self._currentstep-1]['string']+'.python') 162 163 print "saving model as: '%s'" % name 163 164 -
issm/trunk/src/m/classes/outputdefinition.m
r17806 r19105 9 9 end 10 10 methods 11 function createxml( obj,fid) % {{{11 function createxml(self,fid) % {{{ 12 12 fprintf(fid, '<!-- outputdefinition -->\n'); 13 13 14 14 % outputdefinition solution parameters 15 15 fprintf(fid,'%s\n%s\n%s\n','<frame key="1" label="outputdefinition">','<section name="outputdefinition" />'); 16 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="definitions" type="',class( obj.definitions),'" default="',convert2str(obj.definitions),'">',' <section name="outputdefinition" />',' <help> list of potential outputs that can be requested, but which need additional data to be defined </help>',' </parameter>');16 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="definitions" type="',class(self.definitions),'" default="',convert2str(self.definitions),'">',' <section name="outputdefinition" />',' <help> list of potential outputs that can be requested, but which need additional data to be defined </help>',' </parameter>'); 17 17 fprintf(fid,'%s\n%s\n','</frame>'); 18 18 19 19 end % }}} 20 function obj= outputdefinition(varargin) % {{{20 function self = outputdefinition(varargin) % {{{ 21 21 switch nargin 22 22 case 0 23 obj=setdefaultparameters(obj);23 self=setdefaultparameters(self); 24 24 otherwise 25 25 error('constructor not supported'); 26 26 end 27 27 end % }}} 28 function obj = setdefaultparameters(obj) % {{{28 function self = setdefaultparameters(self) % {{{ 29 29 30 obj.definitions={};30 self.definitions={}; 31 31 32 32 end % }}} 33 function md = checkconsistency( obj,md,solution,analyses) % {{{33 function md = checkconsistency(self,md,solution,analyses) % {{{ 34 34 35 35 md = checkfield(md,'fieldname','outputdefinition.definitions','cell',1); 36 36 37 for i=1:length( obj.definitions),38 md=checkconsistency( obj.definitions{i},md,solution,analyses);37 for i=1:length(self.definitions), 38 md=checkconsistency(self.definitions{i},md,solution,analyses); 39 39 end 40 40 41 41 end % }}} 42 function disp( obj) % {{{42 function disp(self) % {{{ 43 43 disp(sprintf(' outputdefinition:')); 44 fielddisplay( obj,'definitions','list of potential outputs that can be requested, but which need additional data to be defined');44 fielddisplay(self,'definitions','list of potential outputs that can be requested, but which need additional data to be defined'); 45 45 46 46 end % }}} 47 function marshall( obj,md,fid) % {{{47 function marshall(self,md,fid) % {{{ 48 48 49 enums=zeros(length( obj.definitions),1);50 for i=1:length( obj.definitions),51 obj.definitions{i}.marshall(md,fid);52 classdefinition=class( obj.definitions{i});49 enums=zeros(length(self.definitions),1); 50 for i=1:length(self.definitions), 51 self.definitions{i}.marshall(md,fid); 52 classdefinition=class(self.definitions{i}); 53 53 classdefinition(1)=upper(classdefinition(1)); %so it matches our enums definitions. 54 54 enums(i)=StringToEnum(classdefinition); -
issm/trunk/src/m/classes/pairoptions.m
r15396 r19105 11 11 end 12 12 methods 13 function obj= pairoptions(varargin) % {{{13 function self = pairoptions(varargin) % {{{ 14 14 15 15 %get calling function name 16 16 a=dbstack; 17 17 if length(a)>1, 18 obj.functionname=a(2).file(1:end-2);19 else 20 obj.functionname='';18 self.functionname=a(2).file(1:end-2); 19 else 20 self.functionname=''; 21 21 end 22 22 … … 25 25 %Do nothing, 26 26 else 27 obj=buildlist(obj,varargin{:});28 end 29 end % }}} 30 function obj = buildlist(obj,varargin) % {{{27 self=buildlist(self,varargin{:}); 28 end 29 end % }}} 30 function self = buildlist(self,varargin) % {{{ 31 31 %BUILDLIST - build list of obj from input 32 32 … … 38 38 39 39 %Allocate memory 40 obj.list=cell(numoptions,3);40 self.list=cell(numoptions,3); 41 41 42 42 %go through varargin and build list of obj 43 43 for i=1:numoptions, 44 44 if ischar(varargin{2*i-1}), 45 obj.list{i,1}=varargin{2*i-1};46 obj.list{i,2}=varargin{2*i};47 obj.list{i,3}=false; %used?45 self.list{i,1}=varargin{2*i-1}; 46 self.list{i,2}=varargin{2*i}; 47 self.list{i,3}=false; %used? 48 48 else 49 49 %option is not a string, ignore it 50 50 disp(['WARNING: option number ' num2str(i) ' is not a string, it will be ignored']); 51 obj.list(i,:)=[];51 self.list(i,:)=[]; 52 52 continue 53 53 end 54 54 end 55 55 end % }}} 56 function obj = addfield(obj,field,value) % {{{56 function self = addfield(self,field,value) % {{{ 57 57 if ischar(field), 58 obj.list{end+1,1} = field;59 obj.list{end,2} = value;60 obj.list{end,3} = false;61 end 62 end % }}} 63 function obj = addfielddefault(obj,field,value) % {{{58 self.list{end+1,1} = field; 59 self.list{end,2} = value; 60 self.list{end,3} = false; 61 end 62 end % }}} 63 function self = addfielddefault(self,field,value) % {{{ 64 64 %ADDFIELDDEFAULT - add a field to an options list if it does not exist 65 65 if ischar(field), 66 if ~exist( obj,field),67 obj.list{end+1,1} = field;68 obj.list{end,2} = value;69 obj.list{end,3} = true; %It is a default so user will not be notified if not used66 if ~exist(self,field), 67 self.list{end+1,1} = field; 68 self.list{end,2} = value; 69 self.list{end,3} = true; %It is a default so user will not be notified if not used 70 70 end 71 71 end … … 84 84 end 85 85 end % }}} 86 function obj = changefieldvalue(obj,field,newvalue) % {{{86 function self = changefieldvalue(self,field,newvalue) % {{{ 87 87 %CHANGEOPTIONVALUE - change the value of an option in an option list 88 88 89 89 %track occurrence of field 90 lines=find(strcmpi( obj.list(:,1),field));90 lines=find(strcmpi(self.list(:,1),field)); 91 91 92 92 %replace value 93 93 if isempty(lines), 94 94 %add new field if not found 95 obj=addfield(obj,field,newvalue);96 obj.list{end,3}=true; % do not notify user if unused95 self=addfield(self,field,newvalue); 96 self.list{end,3}=true; % do not notify user if unused 97 97 else 98 98 for i=1:length(lines), 99 obj.list{lines(i),2}=newvalue;100 end 101 end 102 end % }}} 103 function obj = deleteduplicates(obj,warn) % {{{99 self.list{lines(i),2}=newvalue; 100 end 101 end 102 end % }}} 103 function self = deleteduplicates(self,warn) % {{{ 104 104 %DELETEDUPLICATES - delete duplicates in an option list 105 105 106 106 %track the first occurrence of each option 107 [dummy lines]=unique( obj.list(:,1),'first');107 [dummy lines]=unique(self.list(:,1),'first'); 108 108 clear dummy 109 109 110 110 %warn user if requested 111 111 if warn, 112 numoptions=size( obj.list,1);112 numoptions=size(self.list,1); 113 113 for i=1:numoptions, 114 114 if ~ismember(i,lines), 115 disp(['WARNING: option ' obj.list{i,1} ' appeared more than once. Only its first occurrence will be kept'])115 disp(['WARNING: option ' self.list{i,1} ' appeared more than once. Only its first occurrence will be kept']) 116 116 end 117 117 end … … 119 119 120 120 %remove duplicates from the options list 121 obj.list=obj.list(lines,:);122 end % }}} 123 function displayunused( obj) % {{{121 self.list=self.list(lines,:); 122 end % }}} 123 function displayunused(self) % {{{ 124 124 %DISPLAYUNUSED - display unused options 125 125 126 numoptions=size( obj.list,1);126 numoptions=size(self.list,1); 127 127 for i=1:numoptions, 128 if ~ obj.list{i,3},129 disp(['WARNING: option ' obj.list{i,1} ' was not used'])130 end 131 end 132 end % }}} 133 function disp( obj) % {{{134 disp(sprintf(' functionname: %s', obj.functionname));135 if ~isempty( obj.list),136 disp(sprintf(' list: (%ix%i)\n',size( obj.list,1),size(obj.list,2)));137 for i=1:size( obj.list,1),138 if ischar( obj.list{i,2}),139 disp(sprintf(' field: %-10s value: ''%s''', obj.list{i,1},obj.list{i,2}));140 elseif isnumeric( obj.list{i,2}) & length(obj.list{i,2})==1,141 disp(sprintf(' field: %-10s value: %g', obj.list{i,1},obj.list{i,2}));142 elseif isnumeric( obj.list{i,2}) & length(obj.list{i,2})==2,143 disp(sprintf(' field: %-10s value: [%g %g]', obj.list{i,1},obj.list{i,2}));128 if ~self.list{i,3}, 129 disp(['WARNING: option ' self.list{i,1} ' was not used']) 130 end 131 end 132 end % }}} 133 function disp(self) % {{{ 134 disp(sprintf(' functionname: %s',self.functionname)); 135 if ~isempty(self.list), 136 disp(sprintf(' list: (%ix%i)\n',size(self.list,1),size(self.list,2))); 137 for i=1:size(self.list,1), 138 if ischar(self.list{i,2}), 139 disp(sprintf(' field: %-10s value: ''%s''',self.list{i,1},self.list{i,2})); 140 elseif isnumeric(self.list{i,2}) & length(self.list{i,2})==1, 141 disp(sprintf(' field: %-10s value: %g',self.list{i,1},self.list{i,2})); 142 elseif isnumeric(self.list{i,2}) & length(self.list{i,2})==2, 143 disp(sprintf(' field: %-10s value: [%g %g]',self.list{i,1},self.list{i,2})); 144 144 else 145 disp(sprintf(' field: %-10s value: (%ix%i)', obj.list{i,1},size(obj.list{i,2},1),size(obj.list{i,2},2)));145 disp(sprintf(' field: %-10s value: (%ix%i)',self.list{i,1},size(self.list{i,2},1),size(self.list{i,2},2))); 146 146 end 147 147 end … … 150 150 end 151 151 end % }}} 152 function bool = exist( obj,field) % {{{152 function bool = exist(self,field) % {{{ 153 153 %EXIST - check if the option exists 154 154 … … 162 162 163 163 %Recover option 164 pos=find(strcmpi(field, obj.list(:,1)));164 pos=find(strcmpi(field,self.list(:,1))); 165 165 if ~isempty(pos), 166 166 bool=true; 167 obj.list{pos,3} = true; %It is a default so user will not be notified if not used167 self.list{pos,3} = true; %It is a default so user will not be notified if not used 168 168 else 169 169 bool=false; 170 170 end 171 171 end % }}} 172 function num = fieldoccurrences( obj,field), % {{{172 function num = fieldoccurrences(self,field), % {{{ 173 173 %FIELDOCCURRENCES - get number of occurrence of a field 174 174 … … 179 179 180 180 %get number of occurrence 181 num=sum(strcmpi(field, obj.list(:,1)));182 end % }}} 183 function value = getfieldvalue( obj,field,varargin), % {{{181 num=sum(strcmpi(field,self.list(:,1))); 182 end % }}} 183 function value = getfieldvalue(self,field,varargin), % {{{ 184 184 %GETOPTION - get the value of an option 185 185 % 186 186 % Usage: 187 % value=getfieldvalue( obj,field,varargin)187 % value=getfieldvalue(self,field,varargin) 188 188 % 189 189 % Find an option value from a field. A default option … … 205 205 206 206 %Recover option 207 pos=find(strcmpi( obj.list(:,1),field));207 pos=find(strcmpi(self.list(:,1),field)); 208 208 if ~isempty(pos), 209 value= obj.list{pos(1),2}; % ignore extra entry210 obj.list{pos(1),3}=true; % option used209 value=self.list{pos(1),2}; % ignore extra entry 210 self.list{pos(1),3}=true; % option used 211 211 return; 212 212 end … … 219 219 end 220 220 end % }}} 221 function obj = removefield(obj,field,warn)% {{{221 function self = removefield(self,field,warn)% {{{ 222 222 %REMOVEFIELD - delete a field in an option list 223 223 % 224 224 % Usage: 225 % obj=removefield(obj,field,warn)225 % self=removefield(self,field,warn) 226 226 % 227 227 % if warn==1 display an info message to warn user that … … 229 229 230 230 %check is field exist 231 if exist( obj,field),231 if exist(self,field), 232 232 233 233 %find where the field is located 234 lines=find(~strcmpi( obj.list(:,1),field));234 lines=find(~strcmpi(self.list(:,1),field)); 235 235 236 236 %remove duplicates from the options list 237 obj.list=obj.list(lines,:);237 self.list=self.list(lines,:); 238 238 239 239 %warn user if requested … … 243 243 end 244 244 end % }}} 245 function marshall( obj,fid,firstindex)% {{{246 247 for i=1:size( obj.list,1),248 name = obj.list{i,1};249 value = obj.list{i,2};245 function marshall(self,fid,firstindex)% {{{ 246 247 for i=1:size(self.list,1), 248 name = self.list{i,1}; 249 value = self.list{i,2}; 250 250 251 251 %Write option name -
issm/trunk/src/m/classes/private.m
r13395 r19105 12 12 end 13 13 methods 14 function obj= private(varargin) % {{{14 function self = private(varargin) % {{{ 15 15 switch nargin 16 16 case 0 17 obj=setdefaultparameters(obj);17 self=setdefaultparameters(self); 18 18 otherwise 19 19 error('constructor not supported'); 20 20 end 21 21 end % }}} 22 function obj = setdefaultparameters(obj) % {{{22 function self = setdefaultparameters(self) % {{{ 23 23 24 24 end % }}} 25 function md = checkconsistency( obj,md,solution,analyses) % {{{25 function md = checkconsistency(self,md,solution,analyses) % {{{ 26 26 27 27 end % }}} 28 function disp( obj) % {{{28 function disp(self) % {{{ 29 29 disp(sprintf(' private parameters: do not change')); 30 30 31 fielddisplay( obj,'isconsistent','is model self consistent');32 fielddisplay( obj,'runtimename','name of the run launched');33 fielddisplay( obj,'bamg','structure with mesh properties constructed if bamg is used to mesh the domain');34 fielddisplay( obj,'solution','type of solution launched');31 fielddisplay(self,'isconsistent','is model self consistent'); 32 fielddisplay(self,'runtimename','name of the run launched'); 33 fielddisplay(self,'bamg','structure with mesh properties constructed if bamg is used to mesh the domain'); 34 fielddisplay(self,'solution','type of solution launched'); 35 35 36 36 end % }}} -
issm/trunk/src/m/classes/qmu.m
r17806 r19105 24 24 end 25 25 methods 26 function createxml(obj,fid) % {{{ 27 fprintf(fid, '<!-- qmu -->\n'); 28 29 % qmu solution parameters 30 fprintf(fid,'%s\n%s\n%s\n','<frame key="1" label="qmu parameters">','<section name="qmu" />'); 31 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="isdakota" type="',class(obj.isdakota),'" default="',convert2str(obj.isdakota),'">',' <section name="qmu" />',' <help> is qmu analysis activated? </help>',' </parameter>'); 32 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="variables" type="',class(obj.variables),'" default="',convert2str(obj.variables),'">',' <section name="qmu" />',' <help> (arrays of each variable class) </help>',' </parameter>'); 33 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="responses" type="',class(obj.responses),'" default="',convert2str(obj.responses),'">',' <section name="qmu" />',' <help> (arrays of each response class) </help>',' </parameter>'); 34 35 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="numberofresponses" type="',class(obj.numberofresponses),'" default="',convert2str(obj.numberofresponses),'">',' <section name="qmu" />',' <help> number of responses </help>',' </parameter>'); 36 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="params" type="',class(obj.params),'" default="',convert2str(obj.params),'">',' <section name="qmu" />',' <help> (array of method-independent parameters) </help>',' </parameter>'); 37 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="results" type="',class(obj.results),'" default="',convert2str(obj.results),'">',' <section name="qmu" />',' <help> (information from dakota files) </help>',' </parameter>'); 38 39 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="partition" type="',class(obj.partition),'" default="',convert2str(obj.partition),'">',' <section name="qmu" />',' <help> user provided mesh partitioning, defaults to metis if not specified </help>',' </parameter>'); 40 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="numberofpartitions" type="',class(obj.numberofpartitions),'" default="',convert2str(obj.numberofpartitions),'">',' <section name="qmu" />',' <help> number of partitions for semi-discrete qmu </help>',' </parameter>'); 41 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="variabledescriptors" type="',class(obj.variabledescriptors),'" default="',convert2str(obj.variabledescriptors),'">',' <section name="qmu" />',' <help> </help>',' </parameter>'); 42 43 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="responsedescriptors" type="',class(obj.responsedescriptors),'" default="',convert2str(obj.responsedescriptors),'">',' <section name="qmu" />',' <help> use an enthalpy formulation to include temperate ice (default is 0) </help>',' </parameter>'); 44 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="method" type="',class(obj.method),'" default="',convert2str(obj.method),'">',' <section name="qmu" />',' <help> array of dakota_method class </help>',' </parameter>'); 45 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="mass_flux_profile_directory" type="',class(obj.mass_flux_profile_directory),'" default="',convert2str(obj.mass_flux_profile_directory),'">',' <section name="qmu" />',' <help> directory for mass flux profiles </help>',' </parameter>'); 46 47 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="mass_flux_profiles" type="',class(obj.mass_flux_profiles),'" default="',convert2str(obj.mass_flux_profiles),'">',' <section name="qmu" />',' <help> </help>',' </parameter>'); 48 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="mass_flux_segments" type="',class(obj.mass_flux_segments),'" default="',convert2str(obj.mass_flux_segments),'">',' <section name="qmu" />',' <help> </help>',' </parameter>'); 49 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="adjacency" type="',class(obj.adjacency),'" default="',convert2str(obj.adjacency),'">',' <section name="qmu" />',' <help> additional outputs requested </help>',' </parameter>'); 50 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vertex_weight" type="',class(obj.vertex_weight),'" default="',convert2str(obj.vertex_weight),'">',' <section name="qmu" />',' <help> weight applied to each mesh vertex </help>',' </parameter>'); 51 52 fprintf(fid,'%s\n%s\n','</frame>'); 53 54 end % }}} 55 function obj = qmu(varargin) % {{{ 26 function createxml(self,fid) % {{{ 27 fprintf(fid, '<!-- qmu -->\n'); 28 29 % qmu solution parameters 30 fprintf(fid,'%s\n%s\n%s\n','<frame key="1" label="qmu parameters">','<section name="qmu" />'); 31 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="isdakota" type="',class(self.isdakota),'" default="',convert2str(self.isdakota),'">',' <section name="qmu" />',' <help> is qmu analysis activated? </help>',' </parameter>'); 32 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="variables" type="',class(self.variables),'" default="',convert2str(self.variables),'">',' <section name="qmu" />',' <help> (arrays of each variable class) </help>',' </parameter>'); 33 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="responses" type="',class(self.responses),'" default="',convert2str(self.responses),'">',' <section name="qmu" />',' <help> (arrays of each response class) </help>',' </parameter>'); 34 35 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="numberofresponses" type="',class(self.numberofresponses),'" default="',convert2str(self.numberofresponses),'">',' <section name="qmu" />',' <help> number of responses </help>',' </parameter>'); 36 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="params" type="',class(self.params),'" default="',convert2str(self.params),'">',' <section name="qmu" />',' <help> (array of method-independent parameters) </help>',' </parameter>'); 37 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="results" type="',class(self.results),'" default="',convert2str(self.results),'">',' <section name="qmu" />',' <help> (information from dakota files) </help>',' </parameter>'); 38 39 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="partition" type="',class(self.partition),'" default="',convert2str(self.partition),'">',' <section name="qmu" />',' <help> user provided mesh partitioning, defaults to metis if not specified </help>',' </parameter>'); 40 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="numberofpartitions" type="',class(self.numberofpartitions),'" default="',convert2str(self.numberofpartitions),'">',' <section name="qmu" />',' <help> number of partitions for semi-discrete qmu </help>',' </parameter>'); 41 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="variabledescriptors" type="',class(self.variabledescriptors),'" default="',convert2str(self.variabledescriptors),'">',' <section name="qmu" />',' <help> </help>',' </parameter>'); 42 43 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="responsedescriptors" type="',class(self.responsedescriptors),'" default="',convert2str(self.responsedescriptors),'">',' <section name="qmu" />',' <help> use an enthalpy formulation to include temperate ice (default is 0) </help>',' </parameter>'); 44 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="method" type="',class(self.method),'" default="',convert2str(self.method),'">',' <section name="qmu" />',' <help> array of dakota_method class </help>',' </parameter>'); 45 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="mass_flux_profile_directory" type="',class(self.mass_flux_profile_directory),'" default="',convert2str(self.mass_flux_profile_directory),'">',' <section name="qmu" />',' <help> directory for mass flux profiles </help>',' </parameter>'); 46 47 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="mass_flux_profiles" type="',class(self.mass_flux_profiles),'" default="',convert2str(self.mass_flux_profiles),'">',' <section name="qmu" />',' <help> </help>',' </parameter>'); 48 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="mass_flux_segments" type="',class(self.mass_flux_segments),'" default="',convert2str(self.mass_flux_segments),'">',' <section name="qmu" />',' <help> </help>',' </parameter>'); 49 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="adjacency" type="',class(self.adjacency),'" default="',convert2str(self.adjacency),'">',' <section name="qmu" />',' <help> additional outputs requested </help>',' </parameter>'); 50 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="vertex_weight" type="',class(self.vertex_weight),'" default="',convert2str(self.vertex_weight),'">',' <section name="qmu" />',' <help> weight applied to each mesh vertex </help>',' </parameter>'); 51 52 fprintf(fid,'%s\n%s\n','</frame>'); 53 54 end % }}} 55 function self = extrude(self,md) % {{{ 56 self.partition=project3d(md,'vector',self.partition','type','node'); 57 end % }}} 58 function self = qmu(varargin) % {{{ 56 59 switch nargin 57 60 case 0 58 obj=setdefaultparameters(obj);61 self=setdefaultparameters(self); 59 62 otherwise 60 63 error('constructor not supported'); 61 64 end 62 65 end % }}} 63 function obj = setdefaultparameters(obj) % {{{66 function self = setdefaultparameters(self) % {{{ 64 67 65 68 end % }}} 66 function md = checkconsistency( obj,md,solution,analyses) % {{{69 function md = checkconsistency(self,md,solution,analyses) % {{{ 67 70 68 71 %Early return … … 90 93 end 91 94 end % }}} 92 function disp( obj) % {{{95 function disp(self) % {{{ 93 96 disp(sprintf(' qmu parameters:')); 94 97 95 fielddisplay( obj,'isdakota','is qmu analysis activated?');96 for i=1:numel( obj.variables)98 fielddisplay(self,'isdakota','is qmu analysis activated?'); 99 for i=1:numel(self.variables) 97 100 disp(sprintf(' variables%s: (arrays of each variable class)',... 98 string_dim( obj.variables,i)));99 fnames=fieldnames( obj.variables(i));101 string_dim(self.variables,i))); 102 fnames=fieldnames(self.variables(i)); 100 103 maxlen=0; 101 104 for j=1:numel(fnames) … … 105 108 for j=1:numel(fnames) 106 109 disp(sprintf([' %-' num2str(maxlen+1) 's: [%ix%i] ''%s'''],... 107 fnames{j},size( obj.variables.(fnames{j})),class(obj.variables.(fnames{j}))));110 fnames{j},size(self.variables.(fnames{j})),class(self.variables.(fnames{j})))); 108 111 end 109 112 end 110 for i=1:numel( obj.responses)113 for i=1:numel(self.responses) 111 114 disp(sprintf(' responses%s: (arrays of each response class)',... 112 string_dim( obj.responses,i)));113 fnames=fieldnames( obj.responses(i));115 string_dim(self.responses,i))); 116 fnames=fieldnames(self.responses(i)); 114 117 maxlen=0; 115 118 for j=1:numel(fnames) … … 119 122 for j=1:numel(fnames) 120 123 disp(sprintf([' %-' num2str(maxlen+1) 's: [%ix%i] ''%s'''],... 121 fnames{j},size( obj.responses.(fnames{j})),class(obj.responses.(fnames{j}))));124 fnames{j},size(self.responses.(fnames{j})),class(self.responses.(fnames{j})))); 122 125 end 123 126 end 124 fielddisplay( obj,'numberofresponses','number of responses')125 for i=1:numel( obj.method);126 if strcmp(class( obj.method(i)),'dakota_method')127 fielddisplay(self,'numberofresponses','number of responses') 128 for i=1:numel(self.method); 129 if strcmp(class(self.method(i)),'dakota_method') 127 130 disp(sprintf(' method%s : ''%s''',... 128 string_dim( obj.method,i),obj.method(i).method));131 string_dim(self.method,i),self.method(i).method)); 129 132 end 130 133 end 131 for i=1:numel( obj.params)134 for i=1:numel(self.params) 132 135 disp(sprintf(' params%s: (array of method-independent parameters)',... 133 string_dim( obj.params,i)));134 fnames=fieldnames( obj.params(i));136 string_dim(self.params,i))); 137 fnames=fieldnames(self.params(i)); 135 138 maxlen=0; 136 139 for j=1:numel(fnames) … … 140 143 for j=1:numel(fnames) 141 144 disp(sprintf([' %-' num2str(maxlen+1) 's: %s'],... 142 fnames{j},any2str( obj.params(i).(fnames{j}))));145 fnames{j},any2str(self.params(i).(fnames{j})))); 143 146 end 144 147 end 145 for i=1:numel( obj.results)148 for i=1:numel(self.results) 146 149 disp(sprintf(' results%s: (information from dakota files)',... 147 string_dim( obj.results,i)));148 fnames=fieldnames( obj.results(i));150 string_dim(self.results,i))); 151 fnames=fieldnames(self.results(i)); 149 152 maxlen=0; 150 153 for j=1:numel(fnames) … … 154 157 for j=1:numel(fnames) 155 158 disp(sprintf([' %-' num2str(maxlen+1) 's: [%ix%i] ''%s'''],... 156 fnames{j},size( obj.results.(fnames{j})),class(obj.results.(fnames{j}))));159 fnames{j},size(self.results.(fnames{j})),class(self.results.(fnames{j})))); 157 160 end 158 161 end 159 fielddisplay( obj,'partition','user provided mesh partitioning, defaults to metis if not specified')160 fielddisplay( obj,'numberofpartitions','number of partitions for semi-discrete qmu')161 fielddisplay( obj,'variabledescriptors','');162 fielddisplay( obj,'responsedescriptors','');163 fielddisplay( obj,'method','array of dakota_method class');164 fielddisplay( obj,'mass_flux_profile_directory','directory for mass flux profiles');165 fielddisplay( obj,'mass_flux_profiles','list of mass_flux profiles');166 fielddisplay( obj,'mass_flux_segments','');167 fielddisplay( obj,'adjacency','');168 fielddisplay( obj,'vertex_weight','weight applied to each mesh vertex');162 fielddisplay(self,'partition','user provided mesh partitioning, defaults to metis if not specified') 163 fielddisplay(self,'numberofpartitions','number of partitions for semi-discrete qmu') 164 fielddisplay(self,'variabledescriptors',''); 165 fielddisplay(self,'responsedescriptors',''); 166 fielddisplay(self,'method','array of dakota_method class'); 167 fielddisplay(self,'mass_flux_profile_directory','directory for mass flux profiles'); 168 fielddisplay(self,'mass_flux_profiles','list of mass_flux profiles'); 169 fielddisplay(self,'mass_flux_segments',''); 170 fielddisplay(self,'adjacency',''); 171 fielddisplay(self,'vertex_weight','weight applied to each mesh vertex'); 169 172 170 173 end % }}} 171 function marshall( obj,md,fid) % {{{172 WriteData(fid,'object', obj,'fieldname','isdakota','format','Boolean');173 if ~ obj.isdakota,174 function marshall(self,md,fid) % {{{ 175 WriteData(fid,'object',self,'fieldname','isdakota','format','Boolean'); 176 if ~self.isdakota, 174 177 WriteData(fid,'data',false,'enum',QmuMassFluxSegmentsPresentEnum,'format','Boolean'); 175 178 return; 176 179 end 177 WriteData(fid,'object', obj,'fieldname','partition','format','DoubleMat','mattype',2);178 WriteData(fid,'object', obj,'fieldname','numberofpartitions','format','Integer');179 WriteData(fid,'object', obj,'fieldname','numberofresponses','format','Integer');180 WriteData(fid,'object', obj,'fieldname','variabledescriptors','format','StringArray');181 WriteData(fid,'object', obj,'fieldname','responsedescriptors','format','StringArray');182 if ~isempty( obj.mass_flux_segments),183 WriteData(fid,'data', obj.mass_flux_segments,'enum',MassFluxSegmentsEnum,'format','MatArray');180 WriteData(fid,'object',self,'fieldname','partition','format','DoubleMat','mattype',2); 181 WriteData(fid,'object',self,'fieldname','numberofpartitions','format','Integer'); 182 WriteData(fid,'object',self,'fieldname','numberofresponses','format','Integer'); 183 WriteData(fid,'object',self,'fieldname','variabledescriptors','format','StringArray'); 184 WriteData(fid,'object',self,'fieldname','responsedescriptors','format','StringArray'); 185 if ~isempty(self.mass_flux_segments), 186 WriteData(fid,'data',self.mass_flux_segments,'enum',MassFluxSegmentsEnum,'format','MatArray'); 184 187 flag=true; 185 188 else -
issm/trunk/src/m/classes/qmu.py
r17806 r19105 1 1 import numpy 2 from project3d import project3d 2 3 from collections import OrderedDict 3 4 from fielddisplay import fielddisplay … … 37 38 38 39 #}}} 40 def __repr__(self): # {{{ 41 s =' qmu parameters:\n' 42 43 s+="%s\n" % fielddisplay(self,'isdakota','is qmu analysis activated?') 44 for i,variable in enumerate(self.variables.iteritems()): 45 s+=" variables%s: (arrays of each variable class)\n" % \ 46 string_dim(self.variables,i) 47 fnames=vars(variable) 48 maxlen=0 49 for fname in fnames: 50 maxlen=max(maxlen,len(fname)) 51 52 for fname in fnames: 53 s+="' %-*s: [%ix%i] '%s'\n" % \ 54 (maxlen+1,fname,size(getattr(variable,fname)),type(getattr(variable,fname))) 55 56 for i,response in enumerate(self.responses.iteritems()): 57 s+=" responses%s: (arrays of each response class)\n" % \ 58 string_dim(self.responses,i) 59 fnames=vars(response) 60 maxlen=0 61 for fname in fnames: 62 maxlen=max(maxlen,len(fname)) 63 64 for fname in fnames: 65 s+=" %-*s: [%ix%i] '%s'\n" % \ 66 (maxlen+1,fname,size(getattr(response,fname)),type(getattr(response,fname))) 67 68 s+="%s\n" % fielddisplay(self,'numberofresponses','number of responses') 69 70 for i,method in enumerate(self.method.iteritems()): 71 if isinstance(method,'dakota_method'): 72 s+=" method%s : '%s'\n" % \ 73 (string_dim(method,i),method.method) 74 75 for i,param in enumerate(self.params.iteritems()): 76 s+=" params%s: (array of method-independent parameters)\n" % \ 77 string_dim(self.params,i) 78 fnames=vars(param) 79 maxlen=0 80 for fname in fnames: 81 maxlen=max(maxlen,len(fname)) 82 83 for fname in fnames: 84 s+=" %-*s: %s\n" % \ 85 (maxlen+1,fname,any2str(getattr(param,fname))) 86 87 for i,result in enumerate(self.results.iteritems()): 88 s+=" results%s: (information from dakota files)\n" % \ 89 string_dim(self.results,i) 90 fnames=vars(result) 91 maxlen=0 92 for fname in fnames: 93 maxlen=max(maxlen,len(fname)) 94 95 for fname in fnames: 96 s+=" %-*s: [%ix%i] '%s'\n" % \ 97 (maxlen+1,fname,size(getattr(result,fname)),type(getattr(result,fname))) 98 99 s+="%s\n" % fielddisplay(self,'partition','user provided mesh partitioning, defaults to metis if not specified') 100 s+="%s\n" % fielddisplay(self,'numberofpartitions','number of partitions for semi-discrete qmu') 101 s+="%s\n" % fielddisplay(self,'variabledescriptors','') 102 s+="%s\n" % fielddisplay(self,'responsedescriptors','') 103 s+="%s\n" % fielddisplay(self,'method','array of dakota_method class') 104 s+="%s\n" % fielddisplay(self,'mass_flux_profile_directory','directory for mass flux profiles') 105 s+="%s\n" % fielddisplay(self,'mass_flux_profiles','list of mass_flux profiles') 106 s+="%s\n" % fielddisplay(self,'mass_flux_segments','') 107 s+="%s\n" % fielddisplay(self,'adjacency','') 108 s+="%s\n" % fielddisplay(self,'vertex_weight','weight applied to each mesh vertex') 109 110 return s 111 # }}} 112 def extrude(self,md): # {{{ 113 self.partition=project3d(md,'vector',numpy.transpose(self.partition),'type','node') 114 return self 115 #}}} 39 116 def setdefaultparameters(self): # {{{ 40 117 return self … … 62 139 return md 63 140 # }}} 64 def __repr__(self): # {{{65 s =' qmu parameters:\n'66 67 s+="%s\n" % fielddisplay(self,'isdakota','is qmu analysis activated?')68 for i,variable in enumerate(self.variables.iteritems()):69 s+=" variables%s: (arrays of each variable class)\n" % \70 string_dim(self.variables,i)71 fnames=vars(variable)72 maxlen=073 for fname in fnames:74 maxlen=max(maxlen,len(fname))75 76 for fname in fnames:77 s+="' %-*s: [%ix%i] '%s'\n" % \78 (maxlen+1,fname,size(getattr(variable,fname)),type(getattr(variable,fname)))79 80 for i,response in enumerate(self.responses.iteritems()):81 s+=" responses%s: (arrays of each response class)\n" % \82 string_dim(self.responses,i)83 fnames=vars(response)84 maxlen=085 for fname in fnames:86 maxlen=max(maxlen,len(fname))87 88 for fname in fnames:89 s+=" %-*s: [%ix%i] '%s'\n" % \90 (maxlen+1,fname,size(getattr(response,fname)),type(getattr(response,fname)))91 92 s+="%s\n" % fielddisplay(self,'numberofresponses','number of responses')93 94 for i,method in enumerate(self.method.iteritems()):95 if isinstance(method,'dakota_method'):96 s+=" method%s : '%s'\n" % \97 (string_dim(method,i),method.method)98 99 for i,param in enumerate(self.params.iteritems()):100 s+=" params%s: (array of method-independent parameters)\n" % \101 string_dim(self.params,i)102 fnames=vars(param)103 maxlen=0104 for fname in fnames:105 maxlen=max(maxlen,len(fname))106 107 for fname in fnames:108 s+=" %-*s: %s\n" % \109 (maxlen+1,fname,any2str(getattr(param,fname)))110 111 for i,result in enumerate(self.results.iteritems()):112 s+=" results%s: (information from dakota files)\n" % \113 string_dim(self.results,i)114 fnames=vars(result)115 maxlen=0116 for fname in fnames:117 maxlen=max(maxlen,len(fname))118 119 for fname in fnames:120 s+=" %-*s: [%ix%i] '%s'\n" % \121 (maxlen+1,fname,size(getattr(result,fname)),type(getattr(result,fname)))122 123 s+="%s\n" % fielddisplay(self,'partition','user provided mesh partitioning, defaults to metis if not specified')124 s+="%s\n" % fielddisplay(self,'numberofpartitions','number of partitions for semi-discrete qmu')125 s+="%s\n" % fielddisplay(self,'variabledescriptors','')126 s+="%s\n" % fielddisplay(self,'responsedescriptors','')127 s+="%s\n" % fielddisplay(self,'method','array of dakota_method class')128 s+="%s\n" % fielddisplay(self,'mass_flux_profile_directory','directory for mass flux profiles')129 s+="%s\n" % fielddisplay(self,'mass_flux_profiles','list of mass_flux profiles')130 s+="%s\n" % fielddisplay(self,'mass_flux_segments','')131 s+="%s\n" % fielddisplay(self,'adjacency','')132 s+="%s\n" % fielddisplay(self,'vertex_weight','weight applied to each mesh vertex')133 134 return s135 # }}}136 141 def marshall(self,md,fid): # {{{ 137 142 WriteData(fid,'object',self,'fieldname','isdakota','format','Boolean') -
issm/trunk/src/m/classes/radaroverlay.m
r15396 r19105 11 11 end 12 12 methods 13 function obj= radaroverlay(varargin) % {{{13 function self = radaroverlay(varargin) % {{{ 14 14 switch nargin 15 15 case 0 16 obj=setdefaultparameters(obj);16 self=setdefaultparameters(self); 17 17 otherwise 18 18 error('constructor not supported'); 19 19 end 20 20 end % }}} 21 function obj = setdefaultparameters(obj) % {{{21 function self = setdefaultparameters(self) % {{{ 22 22 23 23 end % }}} 24 function disp( obj) % {{{24 function disp(self) % {{{ 25 25 disp(sprintf(' radaroverlay parameters:')); 26 26 27 fielddisplay( obj,'pwr','radar power image (matrix)');28 fielddisplay( obj,'x','corresponding x coordinates [m]');29 fielddisplay( obj,'y','corresponding y coordinates [m]');27 fielddisplay(self,'pwr','radar power image (matrix)'); 28 fielddisplay(self,'x','corresponding x coordinates [m]'); 29 fielddisplay(self,'y','corresponding y coordinates [m]'); 30 30 31 31 end % }}} -
issm/trunk/src/m/classes/rifts.m
r17806 r19105 10 10 end 11 11 methods 12 function createxml( obj,fid) % {{{12 function createxml(self,fid) % {{{ 13 13 fprintf(fid, '\n\n'); 14 14 fprintf(fid, '%s\n', '<!-- rifts -->'); 15 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="riftstruct" type="', class( obj.riftstruct),'" default="', obj.riftstruct,'">', ' <section name="rifts" />',' <help> structure containing all rift information (vertices coordinates, segments, type of melange, ...) </help>','</parameter>');16 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="riftproperties" type="', class( obj.riftproperties),'" default="', obj.riftproperties,'">', ' <section name="rifts" />',' <help> N/A </help>','</parameter>');15 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="riftstruct" type="', class(self.riftstruct),'" default="', self.riftstruct,'">', ' <section name="rifts" />',' <help> structure containing all rift information (vertices coordinates, segments, type of melange, ...) </help>','</parameter>'); 16 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="riftproperties" type="', class(self.riftproperties),'" default="', self.riftproperties,'">', ' <section name="rifts" />',' <help> N/A </help>','</parameter>'); 17 17 18 18 end % }}} 19 function obj= rifts(varargin) % {{{19 function self = rifts(varargin) % {{{ 20 20 switch nargin 21 21 case 0 22 obj=setdefaultparameters(obj);22 self=setdefaultparameters(self); 23 23 otherwise 24 24 error('constructor not supported'); 25 25 end 26 26 end % }}} 27 function obj = setdefaultparameters(obj) % {{{27 function self = setdefaultparameters(self) % {{{ 28 28 29 29 end % }}} 30 function md = checkconsistency( obj,md,solution,analyses) % {{{31 if isempty( obj.riftstruct) | isnans(obj.riftstruct),30 function md = checkconsistency(self,md,solution,analyses) % {{{ 31 if isempty(self.riftstruct) | isnans(self.riftstruct), 32 32 numrifts=0; 33 33 else 34 numrifts=numel( obj.riftstruct);34 numrifts=numel(self.riftstruct); 35 35 end 36 36 if numrifts, … … 38 38 md = checkmessage(md,['models with rifts are only supported in 2d for now!']); 39 39 end 40 if ~isstruct( obj.riftstruct),40 if ~isstruct(self.riftstruct), 41 41 md = checkmessage(md,['rifts.riftstruct should be a structure!']); 42 42 end … … 49 49 end 50 50 else 51 if ~isnans( obj.riftstruct),51 if ~isnans(self.riftstruct), 52 52 md = checkmessage(md,['riftstruct should be NaN since numrifts is 0!']); 53 53 end 54 54 end 55 55 end % }}} 56 function disp( obj) % {{{56 function disp(self) % {{{ 57 57 disp(sprintf(' rifts parameters:')); 58 58 59 fielddisplay( obj,'riftstruct','structure containing all rift information (vertices coordinates, segments, type of melange, ...)');60 fielddisplay( obj,'riftproperties','');59 fielddisplay(self,'riftstruct','structure containing all rift information (vertices coordinates, segments, type of melange, ...)'); 60 fielddisplay(self,'riftproperties',''); 61 61 62 62 end % }}} 63 function marshall( obj,md,fid) % {{{63 function marshall(self,md,fid) % {{{ 64 64 65 65 %Process rift info 66 if isempty( obj.riftstruct) | isnans(obj.riftstruct),66 if isempty(self.riftstruct) | isnans(self.riftstruct), 67 67 numrifts=0; 68 68 else 69 numrifts=numel( obj.riftstruct);69 numrifts=numel(self.riftstruct); 70 70 end 71 71 numpairs=0; 72 72 for i=1:numrifts, 73 numpairs=numpairs+size( obj.riftstruct(i).penaltypairs,1);73 numpairs=numpairs+size(self.riftstruct(i).penaltypairs,1); 74 74 end 75 75 … … 78 78 count=1; 79 79 for i=1:numrifts, 80 numpairsforthisrift=size( obj.riftstruct(i).penaltypairs,1);81 data(count:count+numpairsforthisrift-1,1:7)= obj.riftstruct(i).penaltypairs;82 data(count:count+numpairsforthisrift-1,8)= obj.riftstruct(i).fill;83 data(count:count+numpairsforthisrift-1,9)= obj.riftstruct(i).friction;84 data(count:count+numpairsforthisrift-1,10)= obj.riftstruct(i).fraction;85 data(count:count+numpairsforthisrift-1,11)= obj.riftstruct(i).fractionincrement;86 data(count:count+numpairsforthisrift-1,12)= obj.riftstruct(i).state;80 numpairsforthisrift=size(self.riftstruct(i).penaltypairs,1); 81 data(count:count+numpairsforthisrift-1,1:7)=self.riftstruct(i).penaltypairs; 82 data(count:count+numpairsforthisrift-1,8)=self.riftstruct(i).fill; 83 data(count:count+numpairsforthisrift-1,9)=self.riftstruct(i).friction; 84 data(count:count+numpairsforthisrift-1,10)=self.riftstruct(i).fraction; 85 data(count:count+numpairsforthisrift-1,11)=self.riftstruct(i).fractionincrement; 86 data(count:count+numpairsforthisrift-1,12)=self.riftstruct(i).state; 87 87 count=count+numpairsforthisrift; 88 88 end -
issm/trunk/src/m/classes/settings.m
r17989 r19105 19 19 end 20 20 methods 21 function createxml( obj,fid) % {{{21 function createxml(self,fid) % {{{ 22 22 fprintf(fid, '\n\n'); 23 23 fprintf(fid, '%s\n', '<!-- settings -->'); 24 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="results_on_nodes" type="', class( obj.results_on_nodes),'" default="', convert2str(obj.results_on_nodes),'">', ' <section name="settings" />',' <help> results are output for all the nodes of each element </help>','</parameter>');25 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="io_gather" type="', class( obj.io_gather),'" default="', convert2str(obj.io_gather),'">', ' <section name="settings" />',' <help> I/O gathering strategy for result outputs (default 1) </help>','</parameter>');24 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="results_on_nodes" type="', class(self.results_on_nodes),'" default="', convert2str(self.results_on_nodes),'">', ' <section name="settings" />',' <help> results are output for all the nodes of each element </help>','</parameter>'); 25 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="io_gather" type="', class(self.io_gather),'" default="', convert2str(self.io_gather),'">', ' <section name="settings" />',' <help> I/O gathering strategy for result outputs (default 1) </help>','</parameter>'); 26 26 27 27 % lowmen drop-down (0 or 1) … … 30 30 fprintf(fid,'%s\n%s\n',' <option value="1" type="string" default="false"> </option>','</parameter>'); 31 31 32 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="output_frequency" type="', class( obj.output_frequency),'" default="', convert2str(obj.output_frequency),'">', ' <section name="settings" />',' <help> frequency at which results are saved in all solutions with multiple time_steps </help>','</parameter>');33 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="waitonlock" type="', class( obj.waitonlock),'" default="', convert2str(obj.waitonlock),'">', ' <section name="settings" />',' <help> maximum number of minutes to wait for batch results (NaN to deactivate) </help>','</parameter>');34 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="upload_server" type="', class( obj.upload_server),'" default="', convert2str(obj.upload_server),'">', ' <section name="settings" />',' <help> server hostname where model should be uploaded </help>','</parameter>');35 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="upload_path" type="', class( obj.upload_path),'" default="', convert2str(obj.upload_path),'">', ' <section name="settings" />',' <help> path on server where model should be uploaded </help>','</parameter>');36 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="upload_login" type="', class( obj.upload_login),'" default="', convert2str(obj.upload_login),'">', ' <section name="settings" />',' <help> server login </help>','</parameter>');37 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="upload_port" type="', class( obj.upload_port),'" default="', convert2str(obj.upload_port),'">', ' <section name="settings" />',' <help> port login (default is 0) </help>','</parameter>');38 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n', '<parameter key ="upload_filename" type="', class( obj.upload_filename),'" default="', convert2str(obj.upload_filename),'">', ' <section name="settings" />',' <help> unique id generated when uploading the file to server </help>','</parameter>');32 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="output_frequency" type="', class(self.output_frequency),'" default="', convert2str(self.output_frequency),'">', ' <section name="settings" />',' <help> frequency at which results are saved in all solutions with multiple time_steps </help>','</parameter>'); 33 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="waitonlock" type="', class(self.waitonlock),'" default="', convert2str(self.waitonlock),'">', ' <section name="settings" />',' <help> maximum number of minutes to wait for batch results (NaN to deactivate) </help>','</parameter>'); 34 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="upload_server" type="', class(self.upload_server),'" default="', convert2str(self.upload_server),'">', ' <section name="settings" />',' <help> server hostname where model should be uploaded </help>','</parameter>'); 35 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="upload_path" type="', class(self.upload_path),'" default="', convert2str(self.upload_path),'">', ' <section name="settings" />',' <help> path on server where model should be uploaded </help>','</parameter>'); 36 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="upload_login" type="', class(self.upload_login),'" default="', convert2str(self.upload_login),'">', ' <section name="settings" />',' <help> server login </help>','</parameter>'); 37 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="upload_port" type="', class(self.upload_port),'" default="', convert2str(self.upload_port),'">', ' <section name="settings" />',' <help> port login (default is 0) </help>','</parameter>'); 38 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n', '<parameter key ="upload_filename" type="', class(self.upload_filename),'" default="', convert2str(self.upload_filename),'">', ' <section name="settings" />',' <help> unique id generated when uploading the file to server </help>','</parameter>'); 39 39 40 40 end % }}} 41 function obj= settings(varargin) % {{{41 function self = settings(varargin) % {{{ 42 42 switch nargin 43 43 case 0 44 obj=setdefaultparameters(obj);44 self=setdefaultparameters(self); 45 45 otherwise 46 46 error('constructor not supported'); 47 47 end 48 48 end % }}} 49 function obj = setdefaultparameters(obj) % {{{49 function self = setdefaultparameters(self) % {{{ 50 50 51 51 %are we short in memory ? (0 faster but requires more memory) 52 obj.lowmem=0;52 self.lowmem=0; 53 53 54 54 %i/o: 55 obj.io_gather=1;55 self.io_gather=1; 56 56 57 57 %results frequency by default every step 58 obj.output_frequency=1;58 self.output_frequency=1; 59 59 60 60 %this option can be activated to load automatically the results … … 62 62 %N minutes that is generated once the solution has converged 63 63 %0 to deactivate 64 obj.waitonlock=Inf;64 self.waitonlock=Inf; 65 65 66 66 %upload options: … … 68 68 69 69 end % }}} 70 function md = checkconsistency( obj,md,solution,analyses) % {{{70 function md = checkconsistency(self,md,solution,analyses) % {{{ 71 71 72 72 md = checkfield(md,'fieldname','settings.results_on_nodes','numel',[1],'values',[0 1]); … … 77 77 78 78 end % }}} 79 function disp( obj) % {{{79 function disp(self) % {{{ 80 80 disp(sprintf(' general settings parameters:')); 81 81 82 fielddisplay( obj,'results_on_nodes','results are output for all the nodes of each element');83 fielddisplay( obj,'io_gather','I/O gathering strategy for result outputs (default 1)');84 fielddisplay( obj,'lowmem','is the memory limited ? (0 or 1)');85 fielddisplay( obj,'output_frequency','frequency at which results are saved in all solutions with multiple time_steps');86 fielddisplay( obj,'waitonlock','maximum number of minutes to wait for batch results (NaN to deactivate)');87 fielddisplay( obj,'upload_server','server hostname where model should be uploaded');88 fielddisplay( obj,'upload_path','path on server where model should be uploaded');89 fielddisplay( obj,'upload_login','server login');90 fielddisplay( obj,'upload_port','port login (default is 0)');91 fielddisplay( obj,'upload_filename','unique id generated when uploading the file to server');82 fielddisplay(self,'results_on_nodes','results are output for all the nodes of each element'); 83 fielddisplay(self,'io_gather','I/O gathering strategy for result outputs (default 1)'); 84 fielddisplay(self,'lowmem','is the memory limited ? (0 or 1)'); 85 fielddisplay(self,'output_frequency','frequency at which results are saved in all solutions with multiple time_steps'); 86 fielddisplay(self,'waitonlock','maximum number of minutes to wait for batch results (NaN to deactivate)'); 87 fielddisplay(self,'upload_server','server hostname where model should be uploaded'); 88 fielddisplay(self,'upload_path','path on server where model should be uploaded'); 89 fielddisplay(self,'upload_login','server login'); 90 fielddisplay(self,'upload_port','port login (default is 0)'); 91 fielddisplay(self,'upload_filename','unique id generated when uploading the file to server'); 92 92 93 93 end % }}} 94 function marshall( obj,md,fid) % {{{95 WriteData(fid,'object', obj,'fieldname','results_on_nodes','format','Boolean');96 WriteData(fid,'object', obj,'fieldname','io_gather','format','Boolean');97 WriteData(fid,'object', obj,'fieldname','lowmem','format','Boolean');98 WriteData(fid,'object', obj,'fieldname','output_frequency','format','Integer');99 if obj.waitonlock>0,94 function marshall(self,md,fid) % {{{ 95 WriteData(fid,'object',self,'fieldname','results_on_nodes','format','Boolean'); 96 WriteData(fid,'object',self,'fieldname','io_gather','format','Boolean'); 97 WriteData(fid,'object',self,'fieldname','lowmem','format','Boolean'); 98 WriteData(fid,'object',self,'fieldname','output_frequency','format','Integer'); 99 if self.waitonlock>0, 100 100 WriteData(fid,'enum',SettingsWaitonlockEnum(),'data',true,'format','Boolean'); 101 101 else -
issm/trunk/src/m/classes/snowpack.m
r17806 r19105 105 105 end 106 106 methods 107 function obj= snowpack(varargin) % {{{107 function self = snowpack(varargin) % {{{ 108 108 switch nargin 109 109 case 0 110 obj=setdefaultparameters(obj);110 self=setdefaultparameters(self); 111 111 case 1 112 112 inputstruct=varargin{1}; … … 116 116 fieldname = list1{i}; 117 117 if ismember(fieldname,list2), 118 obj.(fieldname) = inputstruct.(fieldname);118 self.(fieldname) = inputstruct.(fieldname); 119 119 end 120 120 end … … 123 123 end 124 124 end % }}} 125 function obj = setdefaultparameters(obj) % {{{125 function self = setdefaultparameters(self) % {{{ 126 126 127 127 %snowpack: %{{{ 128 obj.snowpack_meas_tss = 1;129 obj.snowpack_enforce_measured_snow_heights = 0;130 obj.snowpack_sw_mode = 0;131 obj.snowpack_incoming_longwave = 1;132 obj.snowpack_height_of_wind_value = 12.;133 obj.snowpack_height_of_meteo_values = 12.;134 obj.snowpack_neutral = 0;135 obj.snowpack_roughness_length = 0.002;136 obj.snowpack_number_slopes = 1;137 obj.snowpack_snow_redistribution = 1;138 obj.snowpack_calculation_step_length = 15.0;139 obj.snowpack_change_bc = 0;140 obj.snowpack_thresh_change_bc = -1.0;141 obj.snowpack_snp_soil = 0;142 obj.snowpack_soil_flux = 0;143 obj.snowpack_geo_heat = 0.06;144 obj.snowpack_canopy = 0;128 self.snowpack_meas_tss = 1; 129 self.snowpack_enforce_measured_snow_heights = 0; 130 self.snowpack_sw_mode = 0; 131 self.snowpack_incoming_longwave = 1; 132 self.snowpack_height_of_wind_value = 12.; 133 self.snowpack_height_of_meteo_values = 12.; 134 self.snowpack_neutral = 0; 135 self.snowpack_roughness_length = 0.002; 136 self.snowpack_number_slopes = 1; 137 self.snowpack_snow_redistribution = 1; 138 self.snowpack_calculation_step_length = 15.0; 139 self.snowpack_change_bc = 0; 140 self.snowpack_thresh_change_bc = -1.0; 141 self.snowpack_snp_soil = 0; 142 self.snowpack_soil_flux = 0; 143 self.snowpack_geo_heat = 0.06; 144 self.snowpack_canopy = 0; 145 145 %}}} 146 146 %snowpackadvanced: %{{{ 147 obj.snowpackadvanced_variant = 'ANTARCTICA'; % use 320 kg m-3 for fixed density148 obj.snowpackadvanced_hn_density = 'EVENT';147 self.snowpackadvanced_variant = 'ANTARCTICA'; % use 320 kg m-3 for fixed density 148 self.snowpackadvanced_hn_density = 'EVENT'; 149 149 %}}} 150 150 %general: %{{{ 151 obj.general_pluginpath = '/usr/local/lib/meteoio/plugins/';152 obj.general_buff_chunk_size = 90;153 obj.general_buff_before = 1.5;151 self.general_pluginpath = '/usr/local/lib/meteoio/plugins/'; 152 self.general_buff_chunk_size = 90; 153 self.general_buff_before = 1.5; 154 154 %}}} 155 155 %input {{{ 156 obj.input_coordsys = 'ch1903';157 obj.input_coordparam = 'null';158 obj.input_time_zone = 8;159 obj.input_meteo = 'smet';160 obj.input_meteopath = './input';161 obj.input_station1 = 'domec.smet';162 obj.input_snowfile1 = 'domec.sno';156 self.input_coordsys = 'ch1903'; 157 self.input_coordparam = 'null'; 158 self.input_time_zone = 8; 159 self.input_meteo = 'smet'; 160 self.input_meteopath = './input'; 161 self.input_station1 = 'domec.smet'; 162 self.input_snowfile1 = 'domec.sno'; 163 163 %}}} 164 164 %output {{{ 165 obj.output_coordsys = 'ch1903';166 obj.output_coordparam = 'null';167 obj.output_time_zone = 8;168 obj.output_meteopath = './output';169 obj.output_experiment = 'smet';170 obj.output_ts_write = 1;171 obj.output_ts_start = 0.0;172 obj.output_ts_days_between = 0.04166667;173 obj.output_profile = 'ascii';174 obj.output_prof_write = 1;175 obj.output_prof_start = 0.0;176 obj.output_prof_days_between = 0.04166667;165 self.output_coordsys = 'ch1903'; 166 self.output_coordparam = 'null'; 167 self.output_time_zone = 8; 168 self.output_meteopath = './output'; 169 self.output_experiment = 'smet'; 170 self.output_ts_write = 1; 171 self.output_ts_start = 0.0; 172 self.output_ts_days_between = 0.04166667; 173 self.output_profile = 'ascii'; 174 self.output_prof_write = 1; 175 self.output_prof_start = 0.0; 176 self.output_prof_days_between = 0.04166667; 177 177 %}}} 178 178 %interpolations1d %{{{ 179 obj.interpolations1d_window_size = 439200; %that is 5 d and 2 h; 1 d = 86400180 obj.interpolations1d_hnw_resample = 'none';181 obj.interpolations1d_hs_resample = 'linear';182 obj.interpolations1d_tsg_resample = 'linear';183 obj.interpolations1d_rho_hn_resample = 'none';184 obj.interpolations1d_vw_resample = 'nearest_neighbour';185 obj.interpolations1d_vw_args = 'extrapolate';179 self.interpolations1d_window_size = 439200; %that is 5 d and 2 h; 1 d = 86400 180 self.interpolations1d_hnw_resample = 'none'; 181 self.interpolations1d_hs_resample = 'linear'; 182 self.interpolations1d_tsg_resample = 'linear'; 183 self.interpolations1d_rho_hn_resample = 'none'; 184 self.interpolations1d_vw_resample = 'nearest_neighbour'; 185 self.interpolations1d_vw_args = 'extrapolate'; 186 186 %}}} 187 187 %filters {{{ 188 obj.filters_ta_filter1 = 'min_max';189 obj.filters_ta_arg1 = [190 280];190 obj.filters_rh_filter1 = 'min_max';191 obj.filters_rh_arg1 = [0.01 1.2];192 obj.filters_rh_filter2 = 'min_max';193 obj.filters_rh_arg2 = {'soft' 0.01 1.0};194 obj.filters_iswr_filter1 = 'min_max';195 obj.filters_iswr_arg1 = [-10 1500];196 obj.filters_iswr_filter2 = 'min_max';197 obj.filters_iswr_arg2 = {'soft' 0 1500};198 obj.filters_rswr_filter1 = 'min_max';199 obj.filters_rswr_arg1 = [-10 1500];200 obj.filters_rswr_filter2 = 'min_max';201 obj.filters_rswr_arg2 = {'soft' 0 1500};188 self.filters_ta_filter1 = 'min_max'; 189 self.filters_ta_arg1 = [190 280]; 190 self.filters_rh_filter1 = 'min_max'; 191 self.filters_rh_arg1 = [0.01 1.2]; 192 self.filters_rh_filter2 = 'min_max'; 193 self.filters_rh_arg2 = {'soft' 0.01 1.0}; 194 self.filters_iswr_filter1 = 'min_max'; 195 self.filters_iswr_arg1 = [-10 1500]; 196 self.filters_iswr_filter2 = 'min_max'; 197 self.filters_iswr_arg2 = {'soft' 0 1500}; 198 self.filters_rswr_filter1 = 'min_max'; 199 self.filters_rswr_arg1 = [-10 1500]; 200 self.filters_rswr_filter2 = 'min_max'; 201 self.filters_rswr_arg2 = {'soft' 0 1500}; 202 202 203 203 %for ta between 190 and 280 k; 204 obj.filters_ilwr_filter1 = 'min_max';205 obj.filters_ilwr_arg1 = [30 355];206 obj.filters_ilwr_filter2 = 'min_max';207 obj.filters_ilwr_arg2 = {'soft' 35 350};208 obj.filters_tss_filter1 = 'min_max';209 obj.filters_tss_arg1 = [180 275];210 obj.filters_tsg_filter1 = 'min_max';211 obj.filters_tsg_arg1 = [200 275];212 obj.filters_vw_filter1 = 'min_max';213 obj.filters_vw_arg1 = [-2 70];214 obj.filters_vw_filter2 = 'min_max';215 obj.filters_vw_arg2 = {'soft' 0 50};204 self.filters_ilwr_filter1 = 'min_max'; 205 self.filters_ilwr_arg1 = [30 355]; 206 self.filters_ilwr_filter2 = 'min_max'; 207 self.filters_ilwr_arg2 = {'soft' 35 350}; 208 self.filters_tss_filter1 = 'min_max'; 209 self.filters_tss_arg1 = [180 275]; 210 self.filters_tsg_filter1 = 'min_max'; 211 self.filters_tsg_arg1 = [200 275]; 212 self.filters_vw_filter1 = 'min_max'; 213 self.filters_vw_arg1 = [-2 70]; 214 self.filters_vw_filter2 = 'min_max'; 215 self.filters_vw_arg2 = {'soft' 0 50}; 216 216 %}}} 217 217 218 218 end % }}} 219 function md = checkconsistency( obj,md,solution,analyses) % {{{219 function md = checkconsistency(self,md,solution,analyses) % {{{ 220 220 %snowpack: %{{{ 221 221 md=checkfield(md,'fieldname','snowpack.snowpack_meas_tss','values',[0 1]); … … 337 337 %}}} 338 338 end % }}} 339 function disp( obj) % {{{339 function disp(self) % {{{ 340 340 341 341 disp(sprintf(' Snowpack solution parameters:')); 342 342 disp(sprintf('\n %s','Snowpack parameters:')); % {{{ 343 fielddisplay( obj,'snowpack_meas_tss',{'A measured surface temperature is available and can be reliably ','used for various consistency tests (it needs to be set to true if enabling CHANGE_BC) (0 or 1)'});344 fielddisplay( obj,'snowpack_enforce_measured_snow_heights','Input mode by which a measurement of snow depth is used to drive the snow cover mass balance (0 or 1)');345 fielddisplay( obj,'snowpack_sw_mode',{'Define the shortwave radiation input:',...343 fielddisplay(self,'snowpack_meas_tss',{'A measured surface temperature is available and can be reliably ','used for various consistency tests (it needs to be set to true if enabling CHANGE_BC) (0 or 1)'}); 344 fielddisplay(self,'snowpack_enforce_measured_snow_heights','Input mode by which a measurement of snow depth is used to drive the snow cover mass balance (0 or 1)'); 345 fielddisplay(self,'snowpack_sw_mode',{'Define the shortwave radiation input:',... 346 346 '0 Incoming shortwave radiation is measured and albedo estimated by the model',... 347 347 '1 Reflected shortwave radiation is available as input and albedo is estimated by the model (IMIS standard)',... 348 348 '2 Incoming and reflected shortwave radiation are both measured and the albedo is estimated from both measurements subject to plausibility checks.'}); 349 fielddisplay( obj,'snowpack_incoming_longwave','Use the provided incoming long wave on the virtual slopes? (0 or 1)');350 fielddisplay( obj,'snowpack_height_of_wind_value',{'The instrument height (or model layer height) for wind input data; note that height ',...349 fielddisplay(self,'snowpack_incoming_longwave','Use the provided incoming long wave on the virtual slopes? (0 or 1)'); 350 fielddisplay(self,'snowpack_height_of_wind_value',{'The instrument height (or model layer height) for wind input data; note that height ',... 351 351 'is above ground for a standard SNOWPACK application but above surface (snow or ground) for Alpine3D applications '}); 352 fielddisplay( obj,'snowpack_height_of_meteo_values',{'The instrument height (or model layer height) for meteorological input data except for wind,',...352 fielddisplay(self,'snowpack_height_of_meteo_values',{'The instrument height (or model layer height) for meteorological input data except for wind,',... 353 353 'which may be at a different height; note that height is above ground for a standard SNOWPACK ',... 354 354 'application but above surface (snow or ground) for Alpine3D applications. '}); 355 fielddisplay( obj,'snowpack_neutral',{'Select the atmospheric stability correction model:',...355 fielddisplay(self,'snowpack_neutral',{'Select the atmospheric stability correction model:',... 356 356 '-1 use a simplified Richardson number stability correction',... 357 357 '0 assume standard Monin-Obukhov bulk formulation for surface exchange iteration with Paulson, Stearns and Weidner (can be used with BC_CHANGE=0)',... 358 358 '1 force Monin-Obukhov formulation to assume neutral conditions regardless of the actual stratification; it has been shown to work well in ',... 359 359 'complex terrain settings. It should be used with BC_CHANGE=1, i.e., Dirichlet /* but also is recommended with Neumann b.c., i.e., BC_CHANGE=0.'}); 360 fielddisplay( obj,'snowpack_roughness_length',{'Aerodynamic roughness length as a parameter for the Monin-Obukhov bulk formulation;',...360 fielddisplay(self,'snowpack_roughness_length',{'Aerodynamic roughness length as a parameter for the Monin-Obukhov bulk formulation;',... 361 361 'A typical value for complex terrain is 0.01 m and for snow covered flat sites 0.001 m. '}); 362 fielddisplay( obj,'snowpack_number_slopes',{'Based on meteorological input from a (flat field) automatic station or numerical weather model,',...362 fielddisplay(self,'snowpack_number_slopes',{'Based on meteorological input from a (flat field) automatic station or numerical weather model,',... 363 363 'up to 8 expositions can be calculated in addition to the flat field if the corresponding *.sno files are provided. For example,',... 364 364 'if you provide a flat field *.snow file (mandatory), which is named KLO3.sno and you want 4 slopes to be calculated the corresponding',... 365 365 'slope files should be named KLO21.sno, ...,KLO24.sno '}); 366 fielddisplay( obj,'snowpack_snow_redistribution',{'Specifies if redistribution of snow is allowed from (upwind) expositions to lee slopes.',...366 fielddisplay(self,'snowpack_snow_redistribution',{'Specifies if redistribution of snow is allowed from (upwind) expositions to lee slopes.',... 367 367 'In case just the flat field is calculated, snow erosion is enabled but only for "ENFORCE_MEASURED_SNOW_HEIGHTS".'}); 368 fielddisplay( obj,'snowpack_calculation_step_length',{'Internal time step (in minutes) used for model simulation. Please note that this MUST ',...368 fielddisplay(self,'snowpack_calculation_step_length',{'Internal time step (in minutes) used for model simulation. Please note that this MUST ',... 369 369 'be the same as HNW::accumulate (the latter being in seconds) if re-acumulating precipitation, otherwise it would lead to wrong results.'}); 370 fielddisplay( obj,'snowpack_change_bc',{'Use measured surface temperature as Dirichlet temperature BC for sub-freezing snowpacks and switch to ',...370 fielddisplay(self,'snowpack_change_bc',{'Use measured surface temperature as Dirichlet temperature BC for sub-freezing snowpacks and switch to ',... 371 371 'Neumann only for melting snowpacks. If set to false, assumes Neumann boundary conditions.'}); 372 fielddisplay( obj,'snowpack_thresh_change_bc','Threshold value (small number below freezing), which switches from Dirichlet to Neumann BCs if CHANGE_BC is selected');373 fielddisplay( obj,'snowpack_snp_soil','Soil layers as defined by the *.sno files are included in the simulation');374 fielddisplay( obj,'snowpack_soil_flux','Assume that the lower temperature boundary condition is given by GEO_HEAT (Neumann) and not by a measured temperature');375 fielddisplay( obj,'snowpack_geo_heat','Constant geothermal heat flux at great) depth W m-2): Lower flux boundary condition for temperature equation if BC is Neumann');376 fielddisplay( obj,'snowpack_canopy','Switch to tell the model that canopy is present (note that Canopy parameters should then be provided in the *.sno file)');372 fielddisplay(self,'snowpack_thresh_change_bc','Threshold value (small number below freezing), which switches from Dirichlet to Neumann BCs if CHANGE_BC is selected'); 373 fielddisplay(self,'snowpack_snp_soil','Soil layers as defined by the *.sno files are included in the simulation'); 374 fielddisplay(self,'snowpack_soil_flux','Assume that the lower temperature boundary condition is given by GEO_HEAT (Neumann) and not by a measured temperature'); 375 fielddisplay(self,'snowpack_geo_heat','Constant geothermal heat flux at great) depth W m-2): Lower flux boundary condition for temperature equation if BC is Neumann'); 376 fielddisplay(self,'snowpack_canopy','Switch to tell the model that canopy is present (note that Canopy parameters should then be provided in the *.sno file)'); 377 377 % }}} 378 378 disp(sprintf('\n %s','Snowpackadvanced parameters:')); % {{{ 379 fielddisplay( obj,'snowpackadvanced_variant','variant selection (includes a choice of specific models, DEFAULT, ANTARCTICA and JAPAN )'); % use 320 kg m-3 for fixed density380 fielddisplay( obj,'snowpackadvanced_hn_density',{'Fixed value to be used as new snow density if a constant density model is chosen, otherwise the choices are "PARAMETERIZED" "EVENT" "MEASURED"'});379 fielddisplay(self,'snowpackadvanced_variant','variant selection (includes a choice of specific models, DEFAULT, ANTARCTICA and JAPAN )'); % use 320 kg m-3 for fixed density 380 fielddisplay(self,'snowpackadvanced_hn_density',{'Fixed value to be used as new snow density if a constant density model is chosen, otherwise the choices are "PARAMETERIZED" "EVENT" "MEASURED"'}); 381 381 % }}} 382 382 disp(sprintf('\n %s','General parameters:')); % {{{ 383 fielddisplay( obj,'general_pluginpath','');384 fielddisplay( obj,'general_buff_chunk_size','Size in days of a chunk of data to read at once.');385 fielddisplay( obj,'general_buff_before','Alternate way of buffer centering: When rebuffering, the new date will be located BUFF_BEFORE days from the beginning of the buffer (therefore, it takes a value in days). ');383 fielddisplay(self,'general_pluginpath',''); 384 fielddisplay(self,'general_buff_chunk_size','Size in days of a chunk of data to read at once.'); 385 fielddisplay(self,'general_buff_before','Alternate way of buffer centering: When rebuffering, the new date will be located BUFF_BEFORE days from the beginning of the buffer (therefore, it takes a value in days). '); 386 386 % }}} 387 387 disp(sprintf('\n %s','Input parameter:')); % {{{ 388 fielddisplay( obj,'input_coordsys','coordinates in the Swiss Grid (http://geomatics.ladetto.ch/ch1903_wgs84_de.pdf). One of CH1903,UTM,UPS,PROJ4 or LOCAL');389 fielddisplay( obj,'input_coordparam',' ');390 fielddisplay( obj,'input_time_zone',' ');391 fielddisplay( obj,'input_meteo','plugin for METEO data (one of BORMA,COSMO,GEOTOP,GRIB,GS,IMIS,SMET,SNOWPACK');392 fielddisplay( obj,'input_meteopath','string containing the path to the xml files.');393 fielddisplay( obj,'input_station1','Meteorology file for station number #');394 fielddisplay( obj,'input_snowfile1','File name for the initial snow profile for station number #');388 fielddisplay(self,'input_coordsys','coordinates in the Swiss Grid (http://geomatics.ladetto.ch/ch1903_wgs84_de.pdf). One of CH1903,UTM,UPS,PROJ4 or LOCAL'); 389 fielddisplay(self,'input_coordparam',' '); 390 fielddisplay(self,'input_time_zone',' '); 391 fielddisplay(self,'input_meteo','plugin for METEO data (one of BORMA,COSMO,GEOTOP,GRIB,GS,IMIS,SMET,SNOWPACK'); 392 fielddisplay(self,'input_meteopath','string containing the path to the xml files.'); 393 fielddisplay(self,'input_station1','Meteorology file for station number #'); 394 fielddisplay(self,'input_snowfile1','File name for the initial snow profile for station number #'); 395 395 % }}} 396 396 disp(sprintf('\n %s','Output parameters:')); % {{{ 397 fielddisplay( obj,'output_coordsys','Coordinates in the Swiss Grid http://geomatics.ladetto.ch/ch1903_wgs84_de.pdf. One of CH1903,UTM,UPS,PROJ4 or LOCAL ');398 fielddisplay( obj,'output_coordparam','');399 fielddisplay( obj,'output_time_zone','');400 fielddisplay( obj,'output_meteopath','Path to the outputs (this path MUST exist, it won''t be created)');401 fielddisplay( obj,'output_experiment','Option to give an additional simulation specific output name to the run in addition to "STATION_NAME"');402 fielddisplay( obj,'output_ts_write','Write meteo data out? (0 or 1)');403 fielddisplay( obj,'output_ts_start','When to start writing meteo data out (offset, in days)');404 fielddisplay( obj,'output_ts_days_between','How often to write meteo data out (in days: 3 hours=.125, 1 hour=4.1666e-2)');405 fielddisplay( obj,'output_profile','How to write the profiles (default: ASCII, choice is ASCII,IMIS or ASCII IMIS)');397 fielddisplay(self,'output_coordsys','Coordinates in the Swiss Grid http://geomatics.ladetto.ch/ch1903_wgs84_de.pdf. One of CH1903,UTM,UPS,PROJ4 or LOCAL '); 398 fielddisplay(self,'output_coordparam',''); 399 fielddisplay(self,'output_time_zone',''); 400 fielddisplay(self,'output_meteopath','Path to the outputs (this path MUST exist, it won''t be created)'); 401 fielddisplay(self,'output_experiment','Option to give an additional simulation specific output name to the run in addition to "STATION_NAME"'); 402 fielddisplay(self,'output_ts_write','Write meteo data out? (0 or 1)'); 403 fielddisplay(self,'output_ts_start','When to start writing meteo data out (offset, in days)'); 404 fielddisplay(self,'output_ts_days_between','How often to write meteo data out (in days: 3 hours=.125, 1 hour=4.1666e-2)'); 405 fielddisplay(self,'output_profile','How to write the profiles (default: ASCII, choice is ASCII,IMIS or ASCII IMIS)'); 406 406 )'); 407 fielddisplay( obj,'output_prof_write','Write profile data out? (0 or 1) ');408 fielddisplay( obj,'output_prof_start','When to start writing profile data out (offset, in days)');409 fielddisplay( obj,'output_prof_days_between','How often to write profile data out (in days: 3 hours=.125, 1 hour=4.1666e-2)');407 fielddisplay(self,'output_prof_write','Write profile data out? (0 or 1) '); 408 fielddisplay(self,'output_prof_start','When to start writing profile data out (offset, in days)'); 409 fielddisplay(self,'output_prof_days_between','How often to write profile data out (in days: 3 hours=.125, 1 hour=4.1666e-2)'); 410 410 % }}} 411 411 disp(sprintf('\n %s','Interpolations1d parameters:')); % {{{ 412 fielddisplay( obj,'interpolations1d_window_size','Affects resampling: expresses (in seconds) how far a valid point can be searched for when re-interpolating a missing value');413 fielddisplay( obj,'interpolations1d_hnw_resample','NONE, NEAREST_NEIGHBOUR, ACCUMULATE or LINEAR');412 fielddisplay(self,'interpolations1d_window_size','Affects resampling: expresses (in seconds) how far a valid point can be searched for when re-interpolating a missing value'); 413 fielddisplay(self,'interpolations1d_hnw_resample','NONE, NEAREST_NEIGHBOUR, ACCUMULATE or LINEAR'); 414 414 '); 415 fielddisplay( obj,'interpolations1d_hs_resample','Mean average processing. The mean average filter returns the mean value of all values within a user given time window. (NONE, NEAREST_NEIGHBOUR, ACCUMULATE or LINEAR)');416 fielddisplay( obj,'interpolations1d_tsg_resample','Mean average processing. The mean average filter returns the mean value of all values within a user given time window.(NONE, NEAREST_NEIGHBOUR, ACCUMULATE or LINEAR)');417 fielddisplay( obj,'interpolations1d_rho_hn_resample','(NONE, NEAREST_NEIGHBOUR, ACCUMULATE or LINEAR)');418 fielddisplay( obj,'interpolations1d_vw_resample','(NONE, NEAREST_NEIGHBOUR, ACCUMULATE or LINEAR)');419 fielddisplay( obj,'interpolations1d_vw_args','default nothing, otherwise, ''extrapolcate''');415 fielddisplay(self,'interpolations1d_hs_resample','Mean average processing. The mean average filter returns the mean value of all values within a user given time window. (NONE, NEAREST_NEIGHBOUR, ACCUMULATE or LINEAR)'); 416 fielddisplay(self,'interpolations1d_tsg_resample','Mean average processing. The mean average filter returns the mean value of all values within a user given time window.(NONE, NEAREST_NEIGHBOUR, ACCUMULATE or LINEAR)'); 417 fielddisplay(self,'interpolations1d_rho_hn_resample','(NONE, NEAREST_NEIGHBOUR, ACCUMULATE or LINEAR)'); 418 fielddisplay(self,'interpolations1d_vw_resample','(NONE, NEAREST_NEIGHBOUR, ACCUMULATE or LINEAR)'); 419 fielddisplay(self,'interpolations1d_vw_args','default nothing, otherwise, ''extrapolcate'''); 420 420 % }}} 421 421 disp(sprintf('\n %s','Filters parameters:')); % {{{ 422 fielddisplay( obj,'filters_ta_filter1',' ');423 fielddisplay( obj,'filters_ta_arg1','');424 fielddisplay( obj,'filters_rh_filter1',' ');425 fielddisplay( obj,'filters_rh_arg1','');426 fielddisplay( obj,'filters_rh_filter2',' ');427 fielddisplay( obj,'filters_rh_arg2','');428 fielddisplay( obj,'filters_iswr_filter1',' ');429 fielddisplay( obj,'filters_iswr_arg1','');430 fielddisplay( obj,'filters_iswr_filter2',' ');431 fielddisplay( obj,'filters_iswr_arg2','');432 fielddisplay( obj,'filters_rswr_filter1',' ');433 fielddisplay( obj,'filters_rswr_arg1','');434 fielddisplay( obj,'filters_rswr_filter2',' ');435 fielddisplay( obj,'filters_rswr_arg2','');422 fielddisplay(self,'filters_ta_filter1',' '); 423 fielddisplay(self,'filters_ta_arg1',''); 424 fielddisplay(self,'filters_rh_filter1',' '); 425 fielddisplay(self,'filters_rh_arg1',''); 426 fielddisplay(self,'filters_rh_filter2',' '); 427 fielddisplay(self,'filters_rh_arg2',''); 428 fielddisplay(self,'filters_iswr_filter1',' '); 429 fielddisplay(self,'filters_iswr_arg1',''); 430 fielddisplay(self,'filters_iswr_filter2',' '); 431 fielddisplay(self,'filters_iswr_arg2',''); 432 fielddisplay(self,'filters_rswr_filter1',' '); 433 fielddisplay(self,'filters_rswr_arg1',''); 434 fielddisplay(self,'filters_rswr_filter2',' '); 435 fielddisplay(self,'filters_rswr_arg2',''); 436 436 437 437 %for ta between 190 and 280 k; 438 fielddisplay( obj,'filters_ilwr_filter1',' ');439 fielddisplay( obj,'filters_ilwr_arg1','');440 fielddisplay( obj,'filters_ilwr_filter2',' ');441 fielddisplay( obj,'filters_ilwr_arg2','');442 fielddisplay( obj,'filters_tss_filter1',' ');443 fielddisplay( obj,'filters_tss_arg1','');444 fielddisplay( obj,'filters_tsg_filter1',' ');445 fielddisplay( obj,'filters_tsg_arg1','');446 fielddisplay( obj,'filters_vw_filter1',' ');447 fielddisplay( obj,'filters_vw_arg1','');448 fielddisplay( obj,'filters_vw_filter2',' ');449 fielddisplay( obj,'filters_vw_arg2','');438 fielddisplay(self,'filters_ilwr_filter1',' '); 439 fielddisplay(self,'filters_ilwr_arg1',''); 440 fielddisplay(self,'filters_ilwr_filter2',' '); 441 fielddisplay(self,'filters_ilwr_arg2',''); 442 fielddisplay(self,'filters_tss_filter1',' '); 443 fielddisplay(self,'filters_tss_arg1',''); 444 fielddisplay(self,'filters_tsg_filter1',' '); 445 fielddisplay(self,'filters_tsg_arg1',''); 446 fielddisplay(self,'filters_vw_filter1',' '); 447 fielddisplay(self,'filters_vw_arg1',''); 448 fielddisplay(self,'filters_vw_filter2',' '); 449 fielddisplay(self,'filters_vw_arg2',''); 450 450 % }}} 451 451 452 452 end % }}} 453 function marshall( obj,md,fid) % {{{453 function marshall(self,md,fid) % {{{ 454 454 455 455 yts=365.0*24.0*3600.0; 456 456 457 WriteData(fid,'object', obj,'class','snowpack','fieldname','spcvx','format','DoubleMat','mattype',1,'scale',1./yts,'forcinglength',md.mesh.numberofvertices+1);458 WriteData(fid,'object', obj,'class','snowpack','fieldname','spcvy','format','DoubleMat','mattype',1,'scale',1./yts,'forcinglength',md.mesh.numberofvertices+1);459 WriteData(fid,'object', obj,'class','snowpack','fieldname','spcvz','format','DoubleMat','mattype',1,'scale',1./yts,'forcinglength',md.mesh.numberofvertices+1);460 WriteData(fid,'object', obj,'class','snowpack','fieldname','restol','format','Double');461 WriteData(fid,'object', obj,'class','snowpack','fieldname','reltol','format','Double');462 WriteData(fid,'object', obj,'class','snowpack','fieldname','abstol','format','Double');463 WriteData(fid,'object', obj,'class','snowpack','fieldname','isnewton','format','Integer');464 WriteData(fid,'object', obj,'class','snowpack','fieldname','FSreconditioning','format','Double');465 WriteData(fid,'object', obj,'class','snowpack','fieldname','viscosity_overshoot','format','Double');466 WriteData(fid,'object', obj,'class','snowpack','fieldname','maxiter','format','Integer');467 WriteData(fid,'object', obj,'class','snowpack','fieldname','shelf_dampening','format','Integer');468 WriteData(fid,'object', obj,'class','snowpack','fieldname','vertex_pairing','format','DoubleMat','mattype',3);469 WriteData(fid,'object', obj,'class','snowpack','fieldname','penalty_factor','format','Double');470 WriteData(fid,'object', obj,'class','snowpack','fieldname','rift_penalty_lock','format','Integer');471 WriteData(fid,'object', obj,'class','snowpack','fieldname','rift_penalty_threshold','format','Integer');472 WriteData(fid,'object', obj,'class','snowpack','fieldname','referential','format','DoubleMat','mattype',1);473 WriteData(fid,'object', obj,'class','snowpack','fieldname','requested_outputs','format','StringArray');474 WriteData(fid,'data', obj.loadingforce(:,1),'format','DoubleMat','mattype',1,'enum',LoadingforceXEnum);475 WriteData(fid,'data', obj.loadingforce(:,2),'format','DoubleMat','mattype',1,'enum',LoadingforceYEnum);476 WriteData(fid,'data', obj.loadingforce(:,3),'format','DoubleMat','mattype',1,'enum',LoadingforceZEnum);457 WriteData(fid,'object',self,'class','snowpack','fieldname','spcvx','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1); 458 WriteData(fid,'object',self,'class','snowpack','fieldname','spcvy','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1); 459 WriteData(fid,'object',self,'class','snowpack','fieldname','spcvz','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1); 460 WriteData(fid,'object',self,'class','snowpack','fieldname','restol','format','Double'); 461 WriteData(fid,'object',self,'class','snowpack','fieldname','reltol','format','Double'); 462 WriteData(fid,'object',self,'class','snowpack','fieldname','abstol','format','Double'); 463 WriteData(fid,'object',self,'class','snowpack','fieldname','isnewton','format','Integer'); 464 WriteData(fid,'object',self,'class','snowpack','fieldname','FSreconditioning','format','Double'); 465 WriteData(fid,'object',self,'class','snowpack','fieldname','viscosity_overshoot','format','Double'); 466 WriteData(fid,'object',self,'class','snowpack','fieldname','maxiter','format','Integer'); 467 WriteData(fid,'object',self,'class','snowpack','fieldname','shelf_dampening','format','Integer'); 468 WriteData(fid,'object',self,'class','snowpack','fieldname','vertex_pairing','format','DoubleMat','mattype',3); 469 WriteData(fid,'object',self,'class','snowpack','fieldname','penalty_factor','format','Double'); 470 WriteData(fid,'object',self,'class','snowpack','fieldname','rift_penalty_lock','format','Integer'); 471 WriteData(fid,'object',self,'class','snowpack','fieldname','rift_penalty_threshold','format','Integer'); 472 WriteData(fid,'object',self,'class','snowpack','fieldname','referential','format','DoubleMat','mattype',1); 473 WriteData(fid,'object',self,'class','snowpack','fieldname','requested_outputs','format','StringArray'); 474 WriteData(fid,'data',self.loadingforce(:,1),'format','DoubleMat','mattype',1,'enum',LoadingforceXEnum); 475 WriteData(fid,'data',self.loadingforce(:,2),'format','DoubleMat','mattype',1,'enum',LoadingforceYEnum); 476 WriteData(fid,'data',self.loadingforce(:,3),'format','DoubleMat','mattype',1,'enum',LoadingforceZEnum); 477 477 end % }}} 478 478 end -
issm/trunk/src/m/classes/spheremesh.m
r17806 r19105 22 22 end 23 23 methods 24 function obj= spheremesh(varargin) % {{{24 function self = spheremesh(varargin) % {{{ 25 25 switch nargin 26 26 case 0 27 obj=setdefaultparameters(obj);27 self=setdefaultparameters(self); 28 28 otherwise 29 29 error('constructor not supported'); 30 30 end 31 31 end % }}} 32 function obj = setdefaultparameters(obj) % {{{32 function self = setdefaultparameters(self) % {{{ 33 33 34 34 %the connectivity is the avergaded number of nodes linked to a … … 37 37 %give a good memory/time ration. This value can be checked in 38 38 %trunk/test/Miscellaneous/runme.m 39 obj.average_vertex_connectivity=25;39 self.average_vertex_connectivity=25; 40 40 end % }}} 41 function md = checkconsistency( obj,md,solution,analyses) % {{{41 function md = checkconsistency(self,md,solution,analyses) % {{{ 42 42 43 43 md = checkfield(md,'fieldname','spheremesh.x','NaN',1,'size',[md.spheremesh.numberofvertices 1]); … … 57 57 md = checkfield(md,'fieldname','spheremesh.elementconnectivity','size',[md.spheremesh.numberofelements 3],'NaN',1); 58 58 end % }}} 59 function disp( obj) % {{{59 function disp(self) % {{{ 60 60 disp(sprintf(' Mesh:')); 61 61 62 62 disp(sprintf('\n Elements and vertices:')); 63 fielddisplay( obj,'numberofelements','number of elements');64 fielddisplay( obj,'numberofvertices','number of vertices');65 fielddisplay( obj,'elements','vertex indices of the mesh elements');66 fielddisplay( obj,'x','vertices x coordinate [m]');67 fielddisplay( obj,'y','vertices y coordinate [m]');68 fielddisplay( obj,'z','vertices z coordinate [m]');69 fielddisplay( obj,'r','vertices r coordinate [m]');70 fielddisplay( obj,'theta','vertices theta coordinate [degrees]');71 fielddisplay( obj,'phi','vertices phi coordinate [degrees]');63 fielddisplay(self,'numberofelements','number of elements'); 64 fielddisplay(self,'numberofvertices','number of vertices'); 65 fielddisplay(self,'elements','vertex indices of the mesh elements'); 66 fielddisplay(self,'x','vertices x coordinate [m]'); 67 fielddisplay(self,'y','vertices y coordinate [m]'); 68 fielddisplay(self,'z','vertices z coordinate [m]'); 69 fielddisplay(self,'r','vertices r coordinate [m]'); 70 fielddisplay(self,'theta','vertices theta coordinate [degrees]'); 71 fielddisplay(self,'phi','vertices phi coordinate [degrees]'); 72 72 73 73 disp(sprintf('\n Properties:')); 74 fielddisplay( obj,'numberoflayers','number of extrusion layers');74 fielddisplay(self,'numberoflayers','number of extrusion layers'); 75 75 76 fielddisplay( obj,'vertexconnectivity','list of vertices connected to vertex_i');77 fielddisplay( obj,'elementconnectivity','list of vertices connected to element_i');78 fielddisplay( obj,'average_vertex_connectivity','average number of vertices connected to one vertex');76 fielddisplay(self,'vertexconnectivity','list of vertices connected to vertex_i'); 77 fielddisplay(self,'elementconnectivity','list of vertices connected to element_i'); 78 fielddisplay(self,'average_vertex_connectivity','average number of vertices connected to one vertex'); 79 79 80 80 end % }}} 81 function marshall( obj,md,fid) % {{{82 WriteData(fid,'object', obj,'fieldname','x','format','DoubleMat','mattype',1);83 WriteData(fid,'object', obj,'fieldname','y','format','DoubleMat','mattype',1);84 WriteData(fid,'object', obj,'fieldname','z','format','DoubleMat','mattype',1);85 WriteData(fid,'object', obj,'fieldname','r','format','DoubleMat','mattype',1);86 WriteData(fid,'object', obj,'fieldname','theta','format','DoubleMat','mattype',1);87 WriteData(fid,'object', obj,'fieldname','phi','format','DoubleMat','mattype',1);88 WriteData(fid,'object', obj,'fieldname','elements','format','DoubleMat','mattype',2);89 WriteData(fid,'object', obj,'fieldname','numberoflayers','format','Integer');90 WriteData(fid,'object', obj,'fieldname','numberofelements','format','Integer');91 WriteData(fid,'object', obj,'fieldname','numberofvertices','format','Integer');92 WriteData(fid,'object', obj,'fieldname','elementconnectivity','format','DoubleMat','mattype',3);93 WriteData(fid,'object', obj,'fieldname','average_vertex_connectivity','format','Integer');81 function marshall(self,md,fid) % {{{ 82 WriteData(fid,'object',self,'fieldname','x','format','DoubleMat','mattype',1); 83 WriteData(fid,'object',self,'fieldname','y','format','DoubleMat','mattype',1); 84 WriteData(fid,'object',self,'fieldname','z','format','DoubleMat','mattype',1); 85 WriteData(fid,'object',self,'fieldname','r','format','DoubleMat','mattype',1); 86 WriteData(fid,'object',self,'fieldname','theta','format','DoubleMat','mattype',1); 87 WriteData(fid,'object',self,'fieldname','phi','format','DoubleMat','mattype',1); 88 WriteData(fid,'object',self,'fieldname','elements','format','DoubleMat','mattype',2); 89 WriteData(fid,'object',self,'fieldname','numberoflayers','format','Integer'); 90 WriteData(fid,'object',self,'fieldname','numberofelements','format','Integer'); 91 WriteData(fid,'object',self,'fieldname','numberofvertices','format','Integer'); 92 WriteData(fid,'object',self,'fieldname','elementconnectivity','format','DoubleMat','mattype',3); 93 WriteData(fid,'object',self,'fieldname','average_vertex_connectivity','format','Integer'); 94 94 end % }}} 95 95 end -
issm/trunk/src/m/classes/steadystate.m
r17806 r19105 11 11 end 12 12 methods 13 function createxml( obj,fid) % {{{13 function createxml(self,fid) % {{{ 14 14 fprintf(fid, '<!-- steadystate -->\n'); 15 15 16 16 % steadystate solution parameters 17 17 fprintf(fid,'%s\n%s\n%s\n','<frame key="1" label="steadystate solution parameters">','<section name="steadystate" />'); 18 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="reltol" type="',class( obj.reltol),'" default="',convert2str(obj.reltol),'">',' <section name="steadystate" />',' <help> relative tolerance criterion [K] </help>',' </parameter>');19 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="maxiter" type="',class( obj.maxiter),'" default="',convert2str(obj.maxiter),'">',' <section name="steadystate" />',' <help> maximum number of iterations </help>',' </parameter>');20 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="requested_outputs" type="',class( obj.requested_outputs),'" default="',convert2str(obj.requested_outputs),'">',' <section name="steadystate" />',' <help> additional requested outputs </help>',' </parameter>');18 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="reltol" type="',class(self.reltol),'" default="',convert2str(self.reltol),'">',' <section name="steadystate" />',' <help> relative tolerance criterion [K] </help>',' </parameter>'); 19 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="maxiter" type="',class(self.maxiter),'" default="',convert2str(self.maxiter),'">',' <section name="steadystate" />',' <help> maximum number of iterations </help>',' </parameter>'); 20 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="requested_outputs" type="',class(self.requested_outputs),'" default="',convert2str(self.requested_outputs),'">',' <section name="steadystate" />',' <help> additional requested outputs </help>',' </parameter>'); 21 21 fprintf(fid,'%s\n%s\n','</frame>'); 22 22 23 23 end % }}} 24 function obj= steadystate(varargin) % {{{24 function self = steadystate(varargin) % {{{ 25 25 switch nargin 26 26 case 0 27 obj=setdefaultparameters(obj);27 self=setdefaultparameters(self); 28 28 otherwise 29 29 error('constructor not supported'); 30 30 end 31 31 end % }}} 32 function obj = setdefaultparameters(obj) % {{{32 function self = setdefaultparameters(self) % {{{ 33 33 %maximum of steady state iterations 34 obj.maxiter=100;34 self.maxiter=100; 35 35 36 36 %Relative tolerance for the steadystate convertgence 37 obj.reltol=0.01;37 self.reltol=0.01; 38 38 39 39 %default output 40 obj.requested_outputs={'default'};40 self.requested_outputs={'default'}; 41 41 end % }}} 42 42 function list=defaultoutputs(self,md) % {{{ … … 45 45 46 46 end % }}} 47 function md = checkconsistency( obj,md,solution,analyses) % {{{47 function md = checkconsistency(self,md,solution,analyses) % {{{ 48 48 49 49 %Early return … … 59 59 end 60 60 end % }}} 61 function disp( obj) % {{{61 function disp(self) % {{{ 62 62 disp(sprintf(' steadystate solution parameters:')); 63 63 64 fielddisplay( obj,'reltol','relative tolerance criterion');65 fielddisplay( obj,'maxiter','maximum number of iterations');66 fielddisplay( obj,'requested_outputs','additional requested outputs');64 fielddisplay(self,'reltol','relative tolerance criterion'); 65 fielddisplay(self,'maxiter','maximum number of iterations'); 66 fielddisplay(self,'requested_outputs','additional requested outputs'); 67 67 68 68 end % }}} 69 function marshall( obj,md,fid) % {{{70 WriteData(fid,'object', obj,'fieldname','reltol','format','Double');71 WriteData(fid,'object', obj,'fieldname','maxiter','format','Integer');69 function marshall(self,md,fid) % {{{ 70 WriteData(fid,'object',self,'fieldname','reltol','format','Double'); 71 WriteData(fid,'object',self,'fieldname','maxiter','format','Integer'); 72 72 73 73 %process requested outputs 74 outputs = obj.requested_outputs;74 outputs = self.requested_outputs; 75 75 pos = find(ismember(outputs,'default')); 76 76 if ~isempty(pos), 77 77 outputs(pos) = []; %remove 'default' from outputs 78 outputs = [outputs defaultoutputs( obj,md)]; %add defaults78 outputs = [outputs defaultoutputs(self,md)]; %add defaults 79 79 end 80 80 WriteData(fid,'data',outputs,'enum',SteadystateRequestedOutputsEnum,'format','StringArray'); -
issm/trunk/src/m/classes/stressbalance.m
r17989 r19105 26 26 end 27 27 methods 28 function createxml(obj,fid) % {{{ 29 fprintf(fid, '\n\n'); 30 fprintf(fid, '%s\n', '<!-- StressBalance solution parameters: -->'); 31 32 % Convergence criteria 33 fprintf(fid,'%s\n%s\n%s\n','<frame key="1" label="Convergence criteria">','<section name="stressbalance" />'); 34 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="restol" type="', class(obj.restol),'" default="', convert2str(obj.restol),'">', ' <section name="stressbalance" />',' <help> mechanical equilibrium residual convergence criterion </help>','</parameter>'); 35 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="reltol" type="', class(obj.reltol),'" default="', convert2str(obj.reltol),'">', ' <section name="stressbalance" />',' <help> velocity relative convergence criterion, NaN: not applied </help>','</parameter>'); 36 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="abstol" type="', class(obj.abstol),'" default="', convert2str(obj.abstol),'">', ' <section name="stressbalance" />',' <help> velocity absolute convergence criterion, NaN: not applied </help>','</parameter>'); 37 38 %is newton drop-down (0,1,or 2) 39 fprintf(fid,'%s\n%s\n%s\n%s\n', '<parameter key ="isnewton" type="alternative" optional="false">', ' <section name="stressbalance" />',' <help> 0: Picards fixed point, 1: Newtons method, 2: hybrid </help>'); 40 fprintf(fid,'%s\n',' <option value="0" type="string" default="true"> </option>'); 41 fprintf(fid,'%s\n',' <option value="1" type="string" default="false"> </option>'); 42 fprintf(fid,'%s\n%s\n',' <option value="2" type="string" default="false"> </option>','</parameter>'); 43 44 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="maxiter" type="', class(obj.maxiter),'" default="', convert2str(obj.maxiter),'">', ' <section name="stressbalance" />',' <help> maximum number of nonlinear iterations </help>','</parameter>'); 45 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="viscosity_overshoot" type="', class(obj.viscosity_overshoot),'" default="', convert2str(obj.viscosity_overshoot),'">', ' <section name="stressbalance" />',' <help> over-shooting constant new=new+C*(new-old) </help>','</parameter>'); 46 fprintf(fid,'%s\n%s\n','</frame>'); 47 48 % boundary conditions 49 fprintf(fid,'%s\n%s\n%s\n','<frame key="2" label="Boundary conditions">','<section name="stressbalance" />'); 50 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="spcvx" type="', class(obj.spcvx),'" default="', convert2str(obj.spcvx),'">', ' <section name="stressbalance" />',' <help> x-axis velocity constraint (NaN means no constraint) [m/yr] </help>','</parameter>'); 51 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="spcvy" type="', class(obj.spcvy),'" default="', convert2str(obj.spcvy),'">', ' <section name="stressbalance" />',' <help> y-axis velocity constraint (NaN means no constraint) [m/yr] </help>','</parameter>'); 52 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="spcvz" type="', class(obj.spcvz),'" default="', convert2str(obj.spcvz),'">', ' <section name="stressbalance" />',' <help> z-axis velocity constraint (NaN means no constraint) [m/yr] </help>','</parameter>'); 53 fprintf(fid,'%s\n%s\n','</frame>'); 54 55 % Rift options 56 fprintf(fid,'%s\n%s\n%s\n','<frame key="3" label="Rift options">','<section name="stressbalance" />'); 57 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="rift_penalty_threshold" type="', class(obj.rift_penalty_threshold),'" default="', convert2str(obj.rift_penalty_threshold),'">', ' <section name="stressbalance" />',' <help> threshold for instability of mechanical constraints </help>','</parameter>'); 58 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="rift_penalty_lock" type="', class(obj.rift_penalty_lock),'" default="', convert2str(obj.rift_penalty_lock),'">', ' <section name="stressbalance" />',' <help> number of iterations before rift penalties are locked </help>','</parameter>'); 59 fprintf(fid,'%s\n%s\n','</frame>'); 60 61 %others 62 fprintf(fid,'%s\n%s\n%s\n','<frame key="4" label="Other">','<section name="stressbalance" />'); 63 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="shelf_dampening" type="', class(obj.shelf_dampening),'" default="', convert2str(obj.shelf_dampening),'">', ' <section name="stressbalance" />',' <help> use dampening for floating ice ? Only for FS model </help>','</parameter>'); 64 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="FSreconditioning" type="', class(obj.FSreconditioning),'" default="', convert2str(obj.FSreconditioning),'">', ' <section name="stressbalance" />',' <help> multiplier for incompressibility equation. Only for FS model </help>','</parameter>'); 65 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="referential" type="', class(obj.referential),'" default="', convert2str(obj.referential),'">', ' <section name="stressbalance" />',' <help> local referential </help>','</parameter>'); 66 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="loadingforce" type="', class(obj.loadingforce),'" default="', convert2str(obj.loadingforce),'">', ' <section name="stressbalance" />',' <help> loading force applied on each point [N/m^3] </help>','</parameter>'); 67 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="requested_outputs" type="', class(obj.requested_outputs),'" default="', convert2str(obj.requested_outputs),'">', ' <section name="stressbalance" />',' <help> additional outputs requested </help>','</parameter>'); 68 69 70 fprintf(fid,'%s\n%s\n','</frame>'); 71 end % }}} 72 function obj = stressbalance(varargin) % {{{ 28 function createxml(self,fid) % {{{ 29 fprintf(fid, '\n\n'); 30 fprintf(fid, '%s\n', '<!-- StressBalance solution parameters: -->'); 31 32 % Convergence criteria 33 fprintf(fid,'%s\n%s\n%s\n','<frame key="1" label="Convergence criteria">','<section name="stressbalance" />'); 34 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="restol" type="', class(self.restol),'" default="', convert2str(self.restol),'">', ' <section name="stressbalance" />',' <help> mechanical equilibrium residual convergence criterion </help>','</parameter>'); 35 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="reltol" type="', class(self.reltol),'" default="', convert2str(self.reltol),'">', ' <section name="stressbalance" />',' <help> velocity relative convergence criterion, NaN: not applied </help>','</parameter>'); 36 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="abstol" type="', class(self.abstol),'" default="', convert2str(self.abstol),'">', ' <section name="stressbalance" />',' <help> velocity absolute convergence criterion, NaN: not applied </help>','</parameter>'); 37 38 %is newton drop-down (0,1,or 2) 39 fprintf(fid,'%s\n%s\n%s\n%s\n', '<parameter key ="isnewton" type="alternative" optional="false">', ' <section name="stressbalance" />',' <help> 0: Picards fixed point, 1: Newtons method, 2: hybrid </help>'); 40 fprintf(fid,'%s\n',' <option value="0" type="string" default="true"> </option>'); 41 fprintf(fid,'%s\n',' <option value="1" type="string" default="false"> </option>'); 42 fprintf(fid,'%s\n%s\n',' <option value="2" type="string" default="false"> </option>','</parameter>'); 43 44 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="maxiter" type="', class(self.maxiter),'" default="', convert2str(self.maxiter),'">', ' <section name="stressbalance" />',' <help> maximum number of nonlinear iterations </help>','</parameter>'); 45 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="viscosity_overshoot" type="', class(self.viscosity_overshoot),'" default="', convert2str(self.viscosity_overshoot),'">', ' <section name="stressbalance" />',' <help> over-shooting constant new=new+C*(new-old) </help>','</parameter>'); 46 fprintf(fid,'%s\n%s\n','</frame>'); 47 48 % boundary conditions 49 fprintf(fid,'%s\n%s\n%s\n','<frame key="2" label="Boundary conditions">','<section name="stressbalance" />'); 50 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="spcvx" type="', class(self.spcvx),'" default="', convert2str(self.spcvx),'">', ' <section name="stressbalance" />',' <help> x-axis velocity constraint (NaN means no constraint) [m/yr] </help>','</parameter>'); 51 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="spcvy" type="', class(self.spcvy),'" default="', convert2str(self.spcvy),'">', ' <section name="stressbalance" />',' <help> y-axis velocity constraint (NaN means no constraint) [m/yr] </help>','</parameter>'); 52 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="spcvz" type="', class(self.spcvz),'" default="', convert2str(self.spcvz),'">', ' <section name="stressbalance" />',' <help> z-axis velocity constraint (NaN means no constraint) [m/yr] </help>','</parameter>'); 53 fprintf(fid,'%s\n%s\n','</frame>'); 54 55 % Rift options 56 fprintf(fid,'%s\n%s\n%s\n','<frame key="3" label="Rift options">','<section name="stressbalance" />'); 57 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="rift_penalty_threshold" type="', class(self.rift_penalty_threshold),'" default="', convert2str(self.rift_penalty_threshold),'">', ' <section name="stressbalance" />',' <help> threshold for instability of mechanical constraints </help>','</parameter>'); 58 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="rift_penalty_lock" type="', class(self.rift_penalty_lock),'" default="', convert2str(self.rift_penalty_lock),'">', ' <section name="stressbalance" />',' <help> number of iterations before rift penalties are locked </help>','</parameter>'); 59 fprintf(fid,'%s\n%s\n','</frame>'); 60 61 %others 62 fprintf(fid,'%s\n%s\n%s\n','<frame key="4" label="Other">','<section name="stressbalance" />'); 63 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="shelf_dampening" type="', class(self.shelf_dampening),'" default="', convert2str(self.shelf_dampening),'">', ' <section name="stressbalance" />',' <help> use dampening for floating ice ? Only for FS model </help>','</parameter>'); 64 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="FSreconditioning" type="', class(self.FSreconditioning),'" default="', convert2str(self.FSreconditioning),'">', ' <section name="stressbalance" />',' <help> multiplier for incompressibility equation. Only for FS model </help>','</parameter>'); 65 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="referential" type="', class(self.referential),'" default="', convert2str(self.referential),'">', ' <section name="stressbalance" />',' <help> local referential </help>','</parameter>'); 66 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="loadingforce" type="', class(self.loadingforce),'" default="', convert2str(self.loadingforce),'">', ' <section name="stressbalance" />',' <help> loading force applied on each point [N/m^3] </help>','</parameter>'); 67 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="requested_outputs" type="', class(self.requested_outputs),'" default="', convert2str(self.requested_outputs),'">', ' <section name="stressbalance" />',' <help> additional outputs requested </help>','</parameter>'); 68 69 70 fprintf(fid,'%s\n%s\n','</frame>'); 71 end % }}} 72 function self = extrude(self,md) % {{{ 73 self.spcvx=project3d(md,'vector',self.spcvx,'type','node'); 74 self.spcvy=project3d(md,'vector',self.spcvy,'type','node'); 75 self.spcvz=project3d(md,'vector',self.spcvz,'type','node'); 76 self.referential=project3d(md,'vector',self.referential,'type','node'); 77 self.loadingforce=project3d(md,'vector',self.loadingforce,'type','node'); 78 79 end % }}} 80 function self = stressbalance(varargin) % {{{ 73 81 switch nargin 74 82 case 0 75 obj=setdefaultparameters(obj);83 self=setdefaultparameters(self); 76 84 case 1 77 85 inputstruct=varargin{1}; … … 81 89 fieldname = list1{i}; 82 90 if ismember(fieldname,list2), 83 obj.(fieldname) = inputstruct.(fieldname);91 self.(fieldname) = inputstruct.(fieldname); 84 92 end 85 93 end … … 88 96 end 89 97 end % }}} 90 function obj = setdefaultparameters(obj) % {{{98 function self = setdefaultparameters(self) % {{{ 91 99 92 100 %maximum of non-linear iterations. 93 obj.maxiter=100;101 self.maxiter=100; 94 102 95 103 %Convergence criterion: absolute, relative and residual 96 obj.restol=10^-4;97 obj.reltol=0.01;98 obj.abstol=10;99 100 obj.FSreconditioning=10^13;101 obj.shelf_dampening=0;104 self.restol=10^-4; 105 self.reltol=0.01; 106 self.abstol=10; 107 108 self.FSreconditioning=10^13; 109 self.shelf_dampening=0; 102 110 103 111 %Penalty factor applied kappa=max(stiffness matrix)*10^penalty_factor 104 obj.penalty_factor=3;112 self.penalty_factor=3; 105 113 106 114 %coefficient to update the viscosity between each iteration of 107 115 %a stressbalance according to the following formula 108 116 %viscosity(n)=viscosity(n)+viscosity_overshoot(viscosity(n)-viscosity(n-1)) 109 obj.viscosity_overshoot=0;117 self.viscosity_overshoot=0; 110 118 111 119 %Stop the iterations of rift if below a threshold 112 obj.rift_penalty_threshold=0;120 self.rift_penalty_threshold=0; 113 121 114 122 %in some solutions, it might be needed to stop a run when only 115 123 %a few constraints remain unstable. For thermal computation, this 116 124 %parameter is often used. 117 obj.rift_penalty_lock=10;125 self.rift_penalty_lock=10; 118 126 119 127 %output default: 120 obj.requested_outputs={'default'};121 122 end % }}} 123 function md = checkconsistency( obj,md,solution,analyses) % {{{128 self.requested_outputs={'default'}; 129 130 end % }}} 131 function md = checkconsistency(self,md,solution,analyses) % {{{ 124 132 125 133 %Early return 126 134 if ~ismember(StressbalanceAnalysisEnum(),analyses), return; end 127 135 128 md = checkfield(md,'fieldname','stressbalance.spcvx',' forcing',1);129 md = checkfield(md,'fieldname','stressbalance.spcvy',' forcing',1);130 md = checkfield(md,'fieldname','stressbalance.spcvz',' forcing',1);136 md = checkfield(md,'fieldname','stressbalance.spcvx','timeseries',1); 137 md = checkfield(md,'fieldname','stressbalance.spcvy','timeseries',1); 138 md = checkfield(md,'fieldname','stressbalance.spcvz','timeseries',1); 131 139 md = checkfield(md,'fieldname','stressbalance.restol','size',[1 1],'>',0,'NaN',1); 132 140 md = checkfield(md,'fieldname','stressbalance.reltol','size',[1 1]); … … 141 149 142 150 %singular solution 143 if ~(any(~isnan(md.stressbalance.spcvx)) | any(~isnan(md.stressbalance.spcvy))),151 if ((~(any(~isnan(md.stressbalance.spcvx)) | any(~isnan(md.stressbalance.spcvy)))) & ~any(md.mask.groundedice_levelset>0)), 144 152 md = checkmessage(md,['model is not well posed (singular). You need at least one node with fixed velocity!']); 145 153 end … … 175 183 176 184 end % }}} 177 function disp( obj) % {{{185 function disp(self) % {{{ 178 186 179 187 disp(sprintf(' StressBalance solution parameters:')); 180 188 181 189 disp(sprintf('\n %s','Convergence criteria:')); 182 fielddisplay( obj,'restol','mechanical equilibrium residual convergence criterion');183 fielddisplay( obj,'reltol','velocity relative convergence criterion, NaN: not applied');184 fielddisplay( obj,'abstol','velocity absolute convergence criterion, NaN: not applied');185 fielddisplay( obj,'isnewton','0: Picard''s fixed point, 1: Newton''s method, 2: hybrid');186 fielddisplay( obj,'maxiter','maximum number of nonlinear iterations');187 fielddisplay( obj,'viscosity_overshoot','over-shooting constant new=new+C*(new-old)');190 fielddisplay(self,'restol','mechanical equilibrium residual convergence criterion'); 191 fielddisplay(self,'reltol','velocity relative convergence criterion, NaN: not applied'); 192 fielddisplay(self,'abstol','velocity absolute convergence criterion, NaN: not applied'); 193 fielddisplay(self,'isnewton','0: Picard''s fixed point, 1: Newton''s method, 2: hybrid'); 194 fielddisplay(self,'maxiter','maximum number of nonlinear iterations'); 195 fielddisplay(self,'viscosity_overshoot','over-shooting constant new=new+C*(new-old)'); 188 196 189 197 disp(sprintf('\n %s','boundary conditions:')); 190 fielddisplay( obj,'spcvx','x-axis velocity constraint (NaN means no constraint) [m/yr]');191 fielddisplay( obj,'spcvy','y-axis velocity constraint (NaN means no constraint) [m/yr]');192 fielddisplay( obj,'spcvz','z-axis velocity constraint (NaN means no constraint) [m/yr]');198 fielddisplay(self,'spcvx','x-axis velocity constraint (NaN means no constraint) [m/yr]'); 199 fielddisplay(self,'spcvy','y-axis velocity constraint (NaN means no constraint) [m/yr]'); 200 fielddisplay(self,'spcvz','z-axis velocity constraint (NaN means no constraint) [m/yr]'); 193 201 194 202 disp(sprintf('\n %s','Rift options:')); 195 fielddisplay( obj,'rift_penalty_threshold','threshold for instability of mechanical constraints');196 fielddisplay( obj,'rift_penalty_lock','number of iterations before rift penalties are locked');203 fielddisplay(self,'rift_penalty_threshold','threshold for instability of mechanical constraints'); 204 fielddisplay(self,'rift_penalty_lock','number of iterations before rift penalties are locked'); 197 205 198 206 disp(sprintf('\n %s','Penalty options:')); 199 fielddisplay( obj,'penalty_factor','offset used by penalties: penalty = Kmax*10^offset');200 fielddisplay( obj,'vertex_pairing','pairs of vertices that are penalized');207 fielddisplay(self,'penalty_factor','offset used by penalties: penalty = Kmax*10^offset'); 208 fielddisplay(self,'vertex_pairing','pairs of vertices that are penalized'); 201 209 202 210 disp(sprintf('\n %s','Other:')); 203 fielddisplay(obj,'shelf_dampening','use dampening for floating ice ? Only for FS model'); 204 fielddisplay(obj,'FSreconditioning','multiplier for incompressibility equation. Only for FS model'); 205 fielddisplay(obj,'referential','local referential'); 206 fielddisplay(obj,'loadingforce','loading force applied on each point [N/m^3]'); 207 fielddisplay(obj,'requested_outputs','additional outputs requested'); 208 209 end % }}} 210 function marshall(obj,md,fid) % {{{ 211 fielddisplay(self,'shelf_dampening','use dampening for floating ice ? Only for FS model'); 212 fielddisplay(self,'FSreconditioning','multiplier for incompressibility equation. Only for FS model'); 213 fielddisplay(self,'referential','local referential'); 214 fielddisplay(self,'loadingforce','loading force applied on each point [N/m^3]'); 215 fielddisplay(self,'requested_outputs','additional outputs requested'); 216 217 end % }}} 218 function marshall(self,md,fid) % {{{ 219 220 WriteData(fid,'object',self,'class','stressbalance','fieldname','vertex_pairing','format','DoubleMat','mattype',3); 211 221 212 222 yts=365.0*24.0*3600.0; 213 223 214 WriteData(fid,'object',obj,'class','stressbalance','fieldname','spcvx','format','DoubleMat','mattype',1,'scale',1./yts,'forcinglength',md.mesh.numberofvertices+1); 215 WriteData(fid,'object',obj,'class','stressbalance','fieldname','spcvy','format','DoubleMat','mattype',1,'scale',1./yts,'forcinglength',md.mesh.numberofvertices+1); 216 WriteData(fid,'object',obj,'class','stressbalance','fieldname','spcvz','format','DoubleMat','mattype',1,'scale',1./yts,'forcinglength',md.mesh.numberofvertices+1); 217 WriteData(fid,'object',obj,'class','stressbalance','fieldname','restol','format','Double'); 218 WriteData(fid,'object',obj,'class','stressbalance','fieldname','reltol','format','Double'); 219 WriteData(fid,'object',obj,'class','stressbalance','fieldname','abstol','format','Double'); 220 WriteData(fid,'object',obj,'class','stressbalance','fieldname','isnewton','format','Integer'); 221 WriteData(fid,'object',obj,'class','stressbalance','fieldname','FSreconditioning','format','Double'); 222 WriteData(fid,'object',obj,'class','stressbalance','fieldname','viscosity_overshoot','format','Double'); 223 WriteData(fid,'object',obj,'class','stressbalance','fieldname','maxiter','format','Integer'); 224 WriteData(fid,'object',obj,'class','stressbalance','fieldname','shelf_dampening','format','Integer'); 225 WriteData(fid,'object',obj,'class','stressbalance','fieldname','vertex_pairing','format','DoubleMat','mattype',3); 226 WriteData(fid,'object',obj,'class','stressbalance','fieldname','penalty_factor','format','Double'); 227 WriteData(fid,'object',obj,'class','stressbalance','fieldname','rift_penalty_lock','format','Integer'); 228 WriteData(fid,'object',obj,'class','stressbalance','fieldname','rift_penalty_threshold','format','Integer'); 229 WriteData(fid,'object',obj,'class','stressbalance','fieldname','referential','format','DoubleMat','mattype',1); 230 231 WriteData(fid,'data',obj.loadingforce(:,1),'format','DoubleMat','mattype',1,'enum',LoadingforceXEnum); 232 WriteData(fid,'data',obj.loadingforce(:,2),'format','DoubleMat','mattype',1,'enum',LoadingforceYEnum); 233 WriteData(fid,'data',obj.loadingforce(:,3),'format','DoubleMat','mattype',1,'enum',LoadingforceZEnum); 224 WriteData(fid,'object',self,'class','stressbalance','fieldname','spcvx','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1); 225 WriteData(fid,'object',self,'class','stressbalance','fieldname','spcvy','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1); 226 WriteData(fid,'object',self,'class','stressbalance','fieldname','spcvz','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1); 227 WriteData(fid,'object',self,'class','stressbalance','fieldname','restol','format','Double'); 228 WriteData(fid,'object',self,'class','stressbalance','fieldname','reltol','format','Double'); 229 WriteData(fid,'object',self,'class','stressbalance','fieldname','abstol','format','Double','scale',1./yts); 230 WriteData(fid,'object',self,'class','stressbalance','fieldname','isnewton','format','Integer'); 231 WriteData(fid,'object',self,'class','stressbalance','fieldname','FSreconditioning','format','Double'); 232 WriteData(fid,'object',self,'class','stressbalance','fieldname','viscosity_overshoot','format','Double'); 233 WriteData(fid,'object',self,'class','stressbalance','fieldname','maxiter','format','Integer'); 234 WriteData(fid,'object',self,'class','stressbalance','fieldname','shelf_dampening','format','Integer'); 235 WriteData(fid,'object',self,'class','stressbalance','fieldname','penalty_factor','format','Double'); 236 WriteData(fid,'object',self,'class','stressbalance','fieldname','rift_penalty_lock','format','Integer'); 237 WriteData(fid,'object',self,'class','stressbalance','fieldname','rift_penalty_threshold','format','Integer'); 238 WriteData(fid,'object',self,'class','stressbalance','fieldname','referential','format','DoubleMat','mattype',1); 239 240 WriteData(fid,'data',self.loadingforce(:,1),'format','DoubleMat','mattype',1,'enum',LoadingforceXEnum); 241 WriteData(fid,'data',self.loadingforce(:,2),'format','DoubleMat','mattype',1,'enum',LoadingforceYEnum); 242 WriteData(fid,'data',self.loadingforce(:,3),'format','DoubleMat','mattype',1,'enum',LoadingforceZEnum); 234 243 235 244 %process requested outputs 236 outputs = obj.requested_outputs;245 outputs = self.requested_outputs; 237 246 pos = find(ismember(outputs,'default')); 238 247 if ~isempty(pos), 239 248 outputs(pos) = []; %remove 'default' from outputs 240 outputs = [outputs defaultoutputs( obj,md)]; %add defaults249 outputs = [outputs defaultoutputs(self,md)]; %add defaults 241 250 end 242 251 WriteData(fid,'data',outputs,'enum',StressbalanceRequestedOutputsEnum,'format','StringArray'); -
issm/trunk/src/m/classes/stressbalance.py
r17806 r19105 2 2 import sys 3 3 import copy 4 from project3d import project3d 4 5 from fielddisplay import fielddisplay 5 6 from EnumDefinitions import * … … 75 76 return string 76 77 #}}} 78 def extrude(self,md): # {{{ 79 self.spcvx=project3d(md,'vector',self.spcvx,'type','node') 80 self.spcvy=project3d(md,'vector',self.spcvy,'type','node') 81 self.spcvz=project3d(md,'vector',self.spcvz,'type','node') 82 self.referential=project3d(md,'vector',self.referential,'type','node') 83 self.loadingforce=project3d(md,'vector',self.loadingforce,'type','node') 84 85 return self 86 #}}} 77 87 def setdefaultparameters(self): # {{{ 78 88 #maximum of non-linear iterations. … … 123 133 return md 124 134 125 md = checkfield(md,'fieldname','stressbalance.spcvx',' forcing',1)126 md = checkfield(md,'fieldname','stressbalance.spcvy',' forcing',1)135 md = checkfield(md,'fieldname','stressbalance.spcvx','timeseries',1) 136 md = checkfield(md,'fieldname','stressbalance.spcvy','timeseries',1) 127 137 if m.strcmp(md.mesh.domaintype(),'3D'): 128 md = checkfield(md,'fieldname','stressbalance.spcvz',' forcing',1)138 md = checkfield(md,'fieldname','stressbalance.spcvz','timeseries',1) 129 139 md = checkfield(md,'fieldname','stressbalance.restol','size',[1],'>',0) 130 140 md = checkfield(md,'fieldname','stressbalance.reltol','size',[1]) … … 168 178 yts=365.0*24.0*3600.0 169 179 170 WriteData(fid,'object',self,'class','stressbalance','fieldname','spcvx','format','DoubleMat','mattype',1,'scale',1./yts,' forcinglength',md.mesh.numberofvertices+1)171 WriteData(fid,'object',self,'class','stressbalance','fieldname','spcvy','format','DoubleMat','mattype',1,'scale',1./yts,' forcinglength',md.mesh.numberofvertices+1)172 WriteData(fid,'object',self,'class','stressbalance','fieldname','spcvz','format','DoubleMat','mattype',1,'scale',1./yts,' forcinglength',md.mesh.numberofvertices+1)180 WriteData(fid,'object',self,'class','stressbalance','fieldname','spcvx','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1) 181 WriteData(fid,'object',self,'class','stressbalance','fieldname','spcvy','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1) 182 WriteData(fid,'object',self,'class','stressbalance','fieldname','spcvz','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1) 173 183 WriteData(fid,'object',self,'class','stressbalance','fieldname','restol','format','Double') 174 184 WriteData(fid,'object',self,'class','stressbalance','fieldname','reltol','format','Double') 175 WriteData(fid,'object',self,'class','stressbalance','fieldname','abstol','format','Double' )185 WriteData(fid,'object',self,'class','stressbalance','fieldname','abstol','format','Double','scale',1./yts) 176 186 WriteData(fid,'object',self,'class','stressbalance','fieldname','isnewton','format','Integer') 177 187 WriteData(fid,'object',self,'class','stressbalance','fieldname','FSreconditioning','format','Double') -
issm/trunk/src/m/classes/taoinversion.m
r18301 r19105 26 26 vel_obs = NaN 27 27 thickness_obs = NaN 28 surface_obs = NaN 28 29 end 29 30 methods 30 function obj = taoinversion(varargin) % {{{ 31 function self = extrude(self,md) % {{{ 32 self.vx_obs=project3d(md,'vector',self.vx_obs,'type','node'); 33 self.vy_obs=project3d(md,'vector',self.vy_obs,'type','node'); 34 self.vel_obs=project3d(md,'vector',self.vel_obs,'type','node'); 35 self.thickness_obs=project3d(md,'vector',self.thickness_obs,'type','node'); 36 if numel(self.cost_functions_coefficients)>1,self.cost_functions_coefficients=project3d(md,'vector',self.cost_functions_coefficients,'type','node');end; 37 if numel(self.min_parameters)>1,self.min_parameters=project3d(md,'vector',self.min_parameters,'type','node');end; 38 if numel(self.max_parameters)>1,self.max_parameters=project3d(md,'vector',self.max_parameters,'type','node');end; 39 end % }}} 40 function self = taoinversion(varargin) % {{{ 31 41 switch nargin 32 42 case 0 33 obj=setdefaultparameters(obj);43 self=setdefaultparameters(self); 34 44 case 1 35 obj=structtoobj(taoinversion(),varargin{1});45 self=structtoobj(taoinversion(),varargin{1}); 36 46 otherwise 37 47 error('constructor not supported'); 38 48 end 39 49 end % }}} 40 function obj = setdefaultparameters(obj) % {{{50 function self = setdefaultparameters(self) % {{{ 41 51 42 52 %default is incomplete adjoint for now 43 obj.incomplete_adjoint=1;53 self.incomplete_adjoint=1; 44 54 45 55 %parameter to be inferred by control methods (only 46 56 %drag and B are supported yet) 47 obj.control_parameters={'FrictionCoefficient'};57 self.control_parameters={'FrictionCoefficient'}; 48 58 49 59 %number of iterations and steps 50 obj.maxsteps=20;51 obj.maxiter =30;60 self.maxsteps=20; 61 self.maxiter =30; 52 62 53 63 %default tolerances 54 obj.fatol = 0;55 obj.frtol = 0;56 obj.gatol = 0;57 obj.grtol = 0;58 obj.gttol = 1e-4;64 self.fatol = 0; 65 self.frtol = 0; 66 self.gatol = 0; 67 self.grtol = 0; 68 self.gttol = 1e-4; 59 69 60 70 %minimization algorithm 61 obj.algorithm = 'tao_blmvm'; 71 PETSCMAJOR = IssmConfig('_PETSC_MAJOR_'); 72 PETSCMINOR = IssmConfig('_PETSC_MINOR_'); 73 if(PETSCMAJOR>3 | (PETSCMAJOR==3 & PETSCMINOR>=5)) 74 self.algorithm = 'blmvm'; 75 else 76 self.algorithm = 'tao_blmvm'; 77 end 62 78 63 79 %several responses can be used: 64 obj.cost_functions=101;65 66 end % }}} 67 function md = checkconsistency( obj,md,solution,analyses) % {{{80 self.cost_functions=101; 81 82 end % }}} 83 function md = checkconsistency(self,md,solution,analyses) % {{{ 68 84 69 85 %Early return 70 if ~ obj.iscontrol, return; end86 if ~self.iscontrol, return; end 71 87 72 88 if ~IssmConfig('_HAVE_TAO_'), … … 79 95 md = checkfield(md,'fieldname','inversion.iscontrol','values',[0 1]); 80 96 md = checkfield(md,'fieldname','inversion.incomplete_adjoint','values',[0 1]); 81 md = checkfield(md,'fieldname','inversion.control_parameters','cell',1,'values',... 82 {'BalancethicknessThickeningRate' 'FrictionCoefficient' 'MaterialsRheologyBbar' 'MaterialsRheologyZbar' 'Vx' 'Vy' 'Thickness'}); 97 md = checkfield(md,'fieldname','inversion.control_parameters','cell',1,'values',supportedcontrols()); 83 98 md = checkfield(md,'fieldname','inversion.maxsteps','numel',1,'>=',0); 84 99 md = checkfield(md,'fieldname','inversion.maxiter','numel',1,'>=',0); … … 88 103 md = checkfield(md,'fieldname','inversion.grtol','numel',1,'>=',0); 89 104 md = checkfield(md,'fieldname','inversion.gttol','numel',1,'>=',0); 90 md = checkfield(md,'fieldname','inversion.algorithm','values',{'tao_blmvm','tao_cg','tao_lmvm'}); 91 md = checkfield(md,'fieldname','inversion.cost_functions','size',[1 num_costfunc],'values',[101:105 201 501:506]); 105 106 PETSCMAJOR = IssmConfig('_PETSC_MAJOR_'); 107 PETSCMINOR = IssmConfig('_PETSC_MINOR_'); 108 if(PETSCMAJOR>3 | (PETSCMAJOR==3 & PETSCMINOR>=5)) 109 md = checkfield(md,'fieldname','inversion.algorithm','values',{'blmvm','cg','lmvm'}); 110 else 111 md = checkfield(md,'fieldname','inversion.algorithm','values',{'tao_blmvm','tao_cg','tao_lmvm'}); 112 end 113 114 md = checkfield(md,'fieldname','inversion.cost_functions','size',[1 num_costfunc],'values',supportedcostfunctions()); 92 115 md = checkfield(md,'fieldname','inversion.cost_functions_coefficients','size',[md.mesh.numberofvertices num_costfunc],'>=',0); 93 116 md = checkfield(md,'fieldname','inversion.min_parameters','size',[md.mesh.numberofvertices num_controls]); … … 103 126 end 104 127 end % }}} 105 function disp( obj) % {{{128 function disp(self) % {{{ 106 129 disp(sprintf(' taoinversion parameters:')); 107 fielddisplay(obj,'iscontrol','is inversion activated?'); 108 fielddisplay(obj,'incomplete_adjoint','1: linear viscosity, 0: non-linear viscosity'); 109 fielddisplay(obj,'control_parameters','ex: {''FrictionCoefficient''}, or {''MaterialsRheologyBbar''}'); 110 fielddisplay(obj,'maxsteps','maximum number of iterations (gradient computation)'); 111 fielddisplay(obj,'maxiter','maximum number of Function evaluation (forward run)'); 112 fielddisplay(obj,'fatol','convergence criterion: f(X)-f(X*) (X: current iteration, X*: "true" solution, f: cost function)'); 113 fielddisplay(obj,'frtol','convergence criterion: |f(X)-f(X*)|/|f(X*)|'); 114 fielddisplay(obj,'gatol','convergence criterion: ||g(X)|| (g: gradient of the cost function)'); 115 fielddisplay(obj,'grtol','convergence criterion: ||g(X)||/|f(X)|'); 116 fielddisplay(obj,'gttol','convergence criterion: ||g(X)||/||g(X0)|| (g(X0): gradient at initial guess X0)'); 117 fielddisplay(obj,'algorithm','minimization algorithm: ''tao_blmvm'', ''tao_cg'', ''tao_lmvm'''); 118 fielddisplay(obj,'cost_functions','indicate the type of response for each optimization step'); 119 fielddisplay(obj,'cost_functions_coefficients','cost_functions_coefficients applied to the misfit of each vertex and for each control_parameter'); 120 fielddisplay(obj,'min_parameters','absolute minimum acceptable value of the inversed parameter on each vertex'); 121 fielddisplay(obj,'max_parameters','absolute maximum acceptable value of the inversed parameter on each vertex'); 122 fielddisplay(obj,'vx_obs','observed velocity x component [m/yr]'); 123 fielddisplay(obj,'vy_obs','observed velocity y component [m/yr]'); 124 fielddisplay(obj,'vel_obs','observed velocity magnitude [m/yr]'); 125 fielddisplay(obj,'thickness_obs','observed thickness [m]'); 130 fielddisplay(self,'iscontrol','is inversion activated?'); 131 fielddisplay(self,'incomplete_adjoint','1: linear viscosity, 0: non-linear viscosity'); 132 fielddisplay(self,'control_parameters','ex: {''FrictionCoefficient''}, or {''MaterialsRheologyBbar''}'); 133 fielddisplay(self,'maxsteps','maximum number of iterations (gradient computation)'); 134 fielddisplay(self,'maxiter','maximum number of Function evaluation (forward run)'); 135 fielddisplay(self,'fatol','convergence criterion: f(X)-f(X*) (X: current iteration, X*: "true" solution, f: cost function)'); 136 fielddisplay(self,'frtol','convergence criterion: |f(X)-f(X*)|/|f(X*)|'); 137 fielddisplay(self,'gatol','convergence criterion: ||g(X)|| (g: gradient of the cost function)'); 138 fielddisplay(self,'grtol','convergence criterion: ||g(X)||/|f(X)|'); 139 fielddisplay(self,'gttol','convergence criterion: ||g(X)||/||g(X0)|| (g(X0): gradient at initial guess X0)'); 140 fielddisplay(self,'algorithm','minimization algorithm: ''tao_blmvm'', ''tao_cg'', ''tao_lmvm'''); 141 fielddisplay(self,'cost_functions','indicate the type of response for each optimization step'); 142 fielddisplay(self,'cost_functions_coefficients','cost_functions_coefficients applied to the misfit of each vertex and for each control_parameter'); 143 fielddisplay(self,'min_parameters','absolute minimum acceptable value of the inversed parameter on each vertex'); 144 fielddisplay(self,'max_parameters','absolute maximum acceptable value of the inversed parameter on each vertex'); 145 fielddisplay(self,'vx_obs','observed velocity x component [m/yr]'); 146 fielddisplay(self,'vy_obs','observed velocity y component [m/yr]'); 147 fielddisplay(self,'vel_obs','observed velocity magnitude [m/yr]'); 148 fielddisplay(self,'thickness_obs','observed thickness [m]'); 149 fielddisplay(self,'surface_obs','observed surface elevation [m]'); 126 150 disp('Available cost functions:'); 127 151 disp(' 101: SurfaceAbsVelMisfit'); … … 135 159 disp(' 503: ThicknessAbsGradient'); 136 160 end % }}} 137 function marshall( obj,md,fid) % {{{161 function marshall(self,md,fid) % {{{ 138 162 139 163 yts=365.0*24.0*3600.0; 140 164 141 WriteData(fid,'object', obj,'class','inversion','fieldname','iscontrol','format','Boolean');165 WriteData(fid,'object',self,'class','inversion','fieldname','iscontrol','format','Boolean'); 142 166 WriteData(fid,'enum',InversionTypeEnum(),'data',1,'format','Integer'); 143 if ~obj.iscontrol, return; end 144 WriteData(fid,'object',obj,'class','inversion','fieldname','incomplete_adjoint','format','Boolean'); 145 WriteData(fid,'object',obj,'class','inversion','fieldname','maxsteps','format','Integer'); 146 WriteData(fid,'object',obj,'class','inversion','fieldname','maxiter','format','Integer'); 147 WriteData(fid,'object',obj,'class','inversion','fieldname','fatol','format','Double'); 148 WriteData(fid,'object',obj,'class','inversion','fieldname','frtol','format','Double'); 149 WriteData(fid,'object',obj,'class','inversion','fieldname','gatol','format','Double'); 150 WriteData(fid,'object',obj,'class','inversion','fieldname','grtol','format','Double'); 151 WriteData(fid,'object',obj,'class','inversion','fieldname','gttol','format','Double'); 152 WriteData(fid,'object',obj,'class','inversion','fieldname','algorithm','format','String'); 153 WriteData(fid,'object',obj,'class','inversion','fieldname','cost_functions_coefficients','format','DoubleMat','mattype',1); 154 WriteData(fid,'object',obj,'class','inversion','fieldname','min_parameters','format','DoubleMat','mattype',3); 155 WriteData(fid,'object',obj,'class','inversion','fieldname','max_parameters','format','DoubleMat','mattype',3); 156 WriteData(fid,'object',obj,'class','inversion','fieldname','vx_obs','format','DoubleMat','mattype',1,'scale',1./yts); 157 WriteData(fid,'object',obj,'class','inversion','fieldname','vy_obs','format','DoubleMat','mattype',1,'scale',1./yts); 158 WriteData(fid,'object',obj,'class','inversion','fieldname','vz_obs','format','DoubleMat','mattype',1,'scale',1./yts); 159 WriteData(fid,'object',obj,'class','inversion','fieldname','thickness_obs','format','DoubleMat','mattype',1); 167 if ~self.iscontrol, return; end 168 WriteData(fid,'object',self,'class','inversion','fieldname','incomplete_adjoint','format','Boolean'); 169 WriteData(fid,'object',self,'class','inversion','fieldname','maxsteps','format','Integer'); 170 WriteData(fid,'object',self,'class','inversion','fieldname','maxiter','format','Integer'); 171 WriteData(fid,'object',self,'class','inversion','fieldname','fatol','format','Double'); 172 WriteData(fid,'object',self,'class','inversion','fieldname','frtol','format','Double'); 173 WriteData(fid,'object',self,'class','inversion','fieldname','gatol','format','Double'); 174 WriteData(fid,'object',self,'class','inversion','fieldname','grtol','format','Double'); 175 WriteData(fid,'object',self,'class','inversion','fieldname','gttol','format','Double'); 176 WriteData(fid,'object',self,'class','inversion','fieldname','algorithm','format','String'); 177 WriteData(fid,'object',self,'class','inversion','fieldname','cost_functions_coefficients','format','DoubleMat','mattype',1); 178 WriteData(fid,'object',self,'class','inversion','fieldname','min_parameters','format','DoubleMat','mattype',3); 179 WriteData(fid,'object',self,'class','inversion','fieldname','max_parameters','format','DoubleMat','mattype',3); 180 WriteData(fid,'object',self,'class','inversion','fieldname','vx_obs','format','DoubleMat','mattype',1,'scale',1./yts); 181 WriteData(fid,'object',self,'class','inversion','fieldname','vy_obs','format','DoubleMat','mattype',1,'scale',1./yts); 182 WriteData(fid,'object',self,'class','inversion','fieldname','vz_obs','format','DoubleMat','mattype',1,'scale',1./yts); 183 WriteData(fid,'object',self,'class','inversion','fieldname','thickness_obs','format','DoubleMat','mattype',1); 184 WriteData(fid,'object',self,'class','inversion','fieldname','surface_obs','format','DoubleMat','mattype',1); 160 185 161 186 %process control parameters 162 num_control_parameters=numel( obj.control_parameters);187 num_control_parameters=numel(self.control_parameters); 163 188 data=zeros(1,num_control_parameters); 164 189 for i=1:num_control_parameters, 165 data(i)=StringToEnum( obj.control_parameters{i});190 data(i)=StringToEnum(self.control_parameters{i}); 166 191 end 167 192 WriteData(fid,'data',data,'enum',InversionControlParametersEnum(),'format','DoubleMat','mattype',3); … … 169 194 170 195 %process cost functions 171 num_cost_functions=size(obj.cost_functions,2); 172 data=obj.cost_functions; 173 pos=find(obj.cost_functions==101); data(pos)=SurfaceAbsVelMisfitEnum(); 174 pos=find(obj.cost_functions==102); data(pos)=SurfaceRelVelMisfitEnum(); 175 pos=find(obj.cost_functions==103); data(pos)=SurfaceLogVelMisfitEnum(); 176 pos=find(obj.cost_functions==104); data(pos)=SurfaceLogVxVyMisfitEnum(); 177 pos=find(obj.cost_functions==105); data(pos)=SurfaceAverageVelMisfitEnum(); 178 pos=find(obj.cost_functions==201); data(pos)=ThicknessAbsMisfitEnum(); 179 pos=find(obj.cost_functions==501); data(pos)=DragCoefficientAbsGradientEnum(); 180 pos=find(obj.cost_functions==502); data(pos)=RheologyBbarAbsGradientEnum(); 181 pos=find(obj.cost_functions==503); data(pos)=ThicknessAbsGradientEnum(); 182 pos=find(obj.cost_functions==504); data(pos)=ThicknessAlongGradientEnum(); 183 pos=find(obj.cost_functions==505); data(pos)=ThicknessAcrossGradientEnum(); 184 pos=find(obj.cost_functions==506); data(pos)=BalancethicknessMisfitEnum(); 185 pos=find(obj.cost_functions==507); data(pos)=Balancethickness2MisfitEnum(); 196 num_cost_functions=size(self.cost_functions,2); 197 data=marshallcostfunctions(self.cost_functions); 186 198 WriteData(fid,'data',data,'enum',InversionCostFunctionsEnum(),'format','DoubleMat','mattype',3); 187 199 WriteData(fid,'data',num_cost_functions,'enum',InversionNumCostFunctionsEnum(),'format','Integer'); -
issm/trunk/src/m/classes/thermal.m
r18301 r19105 9 9 penalty_threshold = 0; 10 10 stabilization = 0; 11 reltol = 0; 11 12 maxiter = 0; 12 13 penalty_lock = 0; … … 17 18 end 18 19 methods 19 function createxml(obj,fid) % {{{ 20 fprintf(fid, '<!-- thermal -->\n'); 21 22 % thermal solution parameters 23 fprintf(fid,'%s\n%s\n%s\n','<frame key="1" label="Thermal solution parameters">','<section name="thermal" />'); 24 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="spctemperature" type="',class(obj.spctemperature),'" default="',convert2str(obj.spctemperature),'">',' <section name="thermal" />',' <help> temperature constraints (NaN means no constraint) [K] </help>',' </parameter>'); 25 26 % penalty_threshold drop-down (0, 1, or 2) 27 fprintf(fid,'%s\n%s\n%s\n%s\n',' <parameter key ="penalty_threshold" type="alternative" optional="false">',' <section name="thermal" />',' <help> 0: no, 1: artificial_diffusivity, 2: SUPG </help>'); 28 fprintf(fid,'%s\n',' <option value="0" type="string" default="true"> </option>'); 29 fprintf(fid,'%s\n',' <option value="1" type="string" default="false"> </option>'); 30 fprintf(fid,'%s\n%s\n',' <option value="2" type="string" default="false"> </option>','</parameter>'); 20 function createxml(self,fid) % {{{ 21 fprintf(fid, '<!-- thermal -->\n'); 31 22 32 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="stabilization" type="',class(obj.stabilization),'" default="',convert2str(obj.stabilization),'">',' <section name="thermal" />',' <help> maximum number of non linear iterations </help>',' </parameter>'); 33 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="maxiter" type="',class(obj.maxiter),'" default="',convert2str(obj.maxiter),'">',' <section name="thermal" />',' <help> stabilize unstable thermal constraints that keep zigzagging after n iteration (default is 0, no stabilization) </help>',' </parameter>'); 34 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="penalty_lock" type="',class(obj.penalty_lock),'" default="',convert2str(obj.penalty_lock),'">',' <section name="thermal" />',' <help> threshold to declare convergence of thermal solution (default is 0) </help>',' </parameter>'); 35 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="penalty_factor" type="',class(obj.penalty_factor),'" default="',convert2str(obj.penalty_factor),'">',' <section name="thermal" />',' <help> scaling exponent (default is 3) </help>',' </parameter>'); 36 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="isenthalpy" type="',class(obj.isenthalpy),'" default="',convert2str(obj.isenthalpy),'">',' <section name="thermal" />',' <help> use an enthalpy formulation to include temperate ice (default is 0) </help>',' </parameter>'); 37 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="isdynamicbasalspc" type="',class(obj.isdynamicbasalspc),'" default="',convert2str(obj.isdynamicbasalspc),'">',' <section name="thermal" />',' <help> enable dynamic setting of basal forcing. required for enthalpy formulation (default is 0) </help>',' </parameter>'); 38 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="requested_outputs" type="',class(obj.requested_outputs),'" default="',convert2str(obj.requested_outputs),'">',' <section name="thermal" />',' <help> additional outputs requested </help>',' </parameter>'); 39 fprintf(fid,'%s\n%s\n','</frame>'); 40 41 end % }}} 42 function obj = thermal(varargin) % {{{ 23 % thermal solution parameters 24 fprintf(fid,'%s\n%s\n%s\n','<frame key="1" label="Thermal solution parameters">','<section name="thermal" />'); 25 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="spctemperature" type="',class(self.spctemperature),'" default="',convert2str(self.spctemperature),'">',' <section name="thermal" />',' <help> temperature constraints (NaN means no constraint) [K] </help>',' </parameter>'); 26 27 % penalty_threshold drop-down (0, 1, or 2) 28 fprintf(fid,'%s\n%s\n%s\n%s\n',' <parameter key ="penalty_threshold" type="alternative" optional="false">',' <section name="thermal" />',' <help> 0: no, 1: artificial_diffusivity, 2: SUPG </help>'); 29 fprintf(fid,'%s\n',' <option value="0" type="string" default="true"> </option>'); 30 fprintf(fid,'%s\n',' <option value="1" type="string" default="false"> </option>'); 31 fprintf(fid,'%s\n%s\n',' <option value="2" type="string" default="false"> </option>','</parameter>'); 32 33 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="stabilization" type="',class(self.stabilization),'" default="',convert2str(self.stabilization),'">',' <section name="thermal" />',' <help> maximum number of non linear iterations </help>',' </parameter>'); 34 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="reltol" type="',class(self.reltol),'" default="',convert2str(self.reltol),'">',' <section name="steadystate" />',' <help> relative tolerance criterion [K] </help>',' </parameter>'); 35 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="maxiter" type="',class(self.maxiter),'" default="',convert2str(self.maxiter),'">',' <section name="thermal" />',' <help> stabilize unstable thermal constraints that keep zigzagging after n iteration (default is 0, no stabilization) </help>',' </parameter>'); 36 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="penalty_lock" type="',class(self.penalty_lock),'" default="',convert2str(self.penalty_lock),'">',' <section name="thermal" />',' <help> threshold to declare convergence of thermal solution (default is 0) </help>',' </parameter>'); 37 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="penalty_factor" type="',class(self.penalty_factor),'" default="',convert2str(self.penalty_factor),'">',' <section name="thermal" />',' <help> scaling exponent (default is 3) </help>',' </parameter>'); 38 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="isenthalpy" type="',class(self.isenthalpy),'" default="',convert2str(self.isenthalpy),'">',' <section name="thermal" />',' <help> use an enthalpy formulation to include temperate ice (default is 0) </help>',' </parameter>'); 39 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="isdynamicbasalspc" type="',class(self.isdynamicbasalspc),'" default="',convert2str(self.isdynamicbasalspc),'">',' <section name="thermal" />',' <help> enable dynamic setting of basal forcing. recommended for enthalpy formulation (default is 0) </help>',' </parameter>'); 40 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="requested_outputs" type="',class(self.requested_outputs),'" default="',convert2str(self.requested_outputs),'">',' <section name="thermal" />',' <help> additional outputs requested </help>',' </parameter>'); 41 fprintf(fid,'%s\n%s\n','</frame>'); 42 43 end % }}} 44 function self = extrude(self,md) % {{{ 45 self.spctemperature=project3d(md,'vector',self.spctemperature,'type','node','layer',md.mesh.numberoflayers,'padding',NaN); 46 if (length(md.initialization.temperature)==md.mesh.numberofvertices), 47 self.spctemperature=NaN(md.mesh.numberofvertices,1); 48 pos=find(md.mesh.vertexonsurface); 49 self.spctemperature(pos)=md.initialization.temperature(pos); %impose observed temperature on surface 50 end 51 end % }}} 52 function self = thermal(varargin) % {{{ 43 53 switch nargin 44 54 case 0 45 obj=setdefaultparameters(obj);55 self=setdefaultparameters(self); 46 56 otherwise 47 57 error('constructor not supported'); … … 57 67 58 68 end % }}} 59 function obj = setdefaultparameters(obj) % {{{69 function self = setdefaultparameters(self) % {{{ 60 70 61 71 %Number of unstable constraints acceptable 62 obj.penalty_threshold=0;72 self.penalty_threshold=0; 63 73 64 74 %Type of stabilization used 65 obj.stabilization=1; 75 self.stabilization=1; 76 77 %Relative tolerance for the enthalpy convergence 78 self.reltol=0.01; 66 79 67 80 %Maximum number of iterations 68 obj.maxiter=100;81 self.maxiter=100; 69 82 70 83 %factor used to compute the values of the penalties: kappa=max(stiffness matrix)*10^penalty_factor 71 obj.penalty_factor=3;84 self.penalty_factor=3; 72 85 73 86 %Should we use cold ice (default) or enthalpy formulation 74 obj.isenthalpy=0;87 self.isenthalpy=0; 75 88 76 89 %will basal boundary conditions be set dynamically 77 obj.isdynamicbasalspc=0;90 self.isdynamicbasalspc=0; 78 91 79 92 %default output 80 obj.requested_outputs={'default'};93 self.requested_outputs={'default'}; 81 94 end % }}} 82 function md = checkconsistency( obj,md,solution,analyses) % {{{95 function md = checkconsistency(self,md,solution,analyses) % {{{ 83 96 84 97 %Early return … … 86 99 87 100 md = checkfield(md,'fieldname','thermal.stabilization','numel',[1],'values',[0 1 2]); 88 md = checkfield(md,'fieldname','thermal.spctemperature',' forcing',1);101 md = checkfield(md,'fieldname','thermal.spctemperature','timeseries',1); 89 102 if (ismember(EnthalpyAnalysisEnum(),analyses) & md.thermal.isenthalpy & dimension(md.mesh)==3), 90 103 pos=find(md.thermal.spctemperature(1:md.mesh.numberofvertices,:)~=NaN); 91 104 replicate=repmat(md.geometry.surface-md.mesh.z,1,size(md.thermal.spctemperature,2)); 92 md = checkfield(md,'fieldname','thermal.spctemperature(find(md.thermal.spctemperature(1:md.mesh.numberofvertices,:)~=NaN))','< ',md.materials.meltingpoint-md.materials.beta*md.materials.rho_ice*md.constants.g*replicate(pos),'message','spctemperature should be belowthe adjusted melting point');105 md = checkfield(md,'fieldname','thermal.spctemperature(find(md.thermal.spctemperature(1:md.mesh.numberofvertices,:)~=NaN))','<=',md.materials.meltingpoint-md.materials.beta*md.materials.rho_ice*md.constants.g*replicate(pos)+10^-5,'message','spctemperature should be less or equal than the adjusted melting point'); 93 106 md = checkfield(md,'fieldname','thermal.isenthalpy','numel',[1],'values',[0 1]); 94 107 md = checkfield(md,'fieldname','thermal.isdynamicbasalspc','numel', [1],'values',[0 1]); 95 108 if(md.thermal.isenthalpy) 96 md = checkfield(md,'fieldname','thermal.isdynamicbasalspc','numel', [1],'values',[1], 'message',['for enthalpy run thermal.isdynamicbasalspc should be 1']); 109 if isnan(md.stressbalance.reltol), 110 md = checkmessage(md,['for a steadystate computation, thermal.reltol (relative convergence criterion) must be defined!']); 111 end 112 md = checkfield(md,'fieldname','thermal.reltol','>',0.,'message','reltol must be larger than zero'); 97 113 end 98 114 end … … 100 116 md = checkfield(md,'fieldname','thermal.requested_outputs','stringrow',1); 101 117 end % }}} 102 function disp( obj) % {{{118 function disp(self) % {{{ 103 119 disp(sprintf(' Thermal solution parameters:')); 104 120 105 fielddisplay(obj,'spctemperature','temperature constraints (NaN means no constraint) [K]'); 106 fielddisplay(obj,'stabilization','0: no, 1: artificial_diffusivity, 2: SUPG'); 107 fielddisplay(obj,'maxiter','maximum number of non linear iterations'); 108 fielddisplay(obj,'penalty_lock','stabilize unstable thermal constraints that keep zigzagging after n iteration (default is 0, no stabilization)'); 109 fielddisplay(obj,'penalty_threshold','threshold to declare convergence of thermal solution (default is 0)'); 110 fielddisplay(obj,'penalty_factor','scaling exponent (default is 3)'); 111 fielddisplay(obj,'isenthalpy','use an enthalpy formulation to include temperate ice (default is 0)'); 112 fielddisplay(obj,'isdynamicbasalspc',['enable dynamic setting of basal forcing. required for enthalpy formulation (default is 0)']); 113 fielddisplay(obj,'requested_outputs','additional outputs requested'); 121 fielddisplay(self,'spctemperature','temperature constraints (NaN means no constraint) [K]'); 122 fielddisplay(self,'stabilization','0: no, 1: artificial_diffusivity, 2: SUPG'); 123 fielddisplay(self,'reltol','relative tolerance convergence criterion for enthalpy'); 124 fielddisplay(self,'maxiter','maximum number of non linear iterations'); 125 fielddisplay(self,'penalty_lock','stabilize unstable thermal constraints that keep zigzagging after n iteration (default is 0, no stabilization)'); 126 fielddisplay(self,'penalty_threshold','threshold to declare convergence of thermal solution (default is 0)'); 127 fielddisplay(self,'penalty_factor','scaling exponent (default is 3)'); 128 fielddisplay(self,'isenthalpy','use an enthalpy formulation to include temperate ice (default is 0)'); 129 fielddisplay(self,'isdynamicbasalspc',['enable dynamic setting of basal forcing. required for enthalpy formulation (default is 0)']); 130 fielddisplay(self,'requested_outputs','additional outputs requested'); 114 131 115 132 end % }}} 116 function marshall(obj,md,fid) % {{{ 117 WriteData(fid,'object',obj,'fieldname','spctemperature','format','DoubleMat','mattype',1,'forcinglength',md.mesh.numberofvertices+1); 118 WriteData(fid,'object',obj,'fieldname','penalty_threshold','format','Integer'); 119 WriteData(fid,'object',obj,'fieldname','stabilization','format','Integer'); 120 WriteData(fid,'object',obj,'fieldname','maxiter','format','Integer'); 121 WriteData(fid,'object',obj,'fieldname','penalty_lock','format','Integer'); 122 WriteData(fid,'object',obj,'fieldname','penalty_factor','format','Double'); 123 WriteData(fid,'object',obj,'fieldname','isenthalpy','format','Boolean'); 124 WriteData(fid,'object',obj,'fieldname','isdynamicbasalspc','format','Boolean'); 133 function marshall(self,md,fid) % {{{ 134 WriteData(fid,'object',self,'fieldname','spctemperature','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1); 135 WriteData(fid,'object',self,'fieldname','penalty_threshold','format','Integer'); 136 WriteData(fid,'object',self,'fieldname','stabilization','format','Integer'); 137 WriteData(fid,'object',self,'fieldname','reltol','format','Double'); 138 WriteData(fid,'object',self,'fieldname','maxiter','format','Integer'); 139 WriteData(fid,'object',self,'fieldname','penalty_lock','format','Integer'); 140 WriteData(fid,'object',self,'fieldname','penalty_factor','format','Double'); 141 WriteData(fid,'object',self,'fieldname','isenthalpy','format','Boolean'); 142 WriteData(fid,'object',self,'fieldname','isdynamicbasalspc','format','Boolean'); 125 143 126 144 %process requested outputs 127 outputs = obj.requested_outputs;145 outputs = self.requested_outputs; 128 146 pos = find(ismember(outputs,'default')); 129 147 if ~isempty(pos), 130 148 outputs(pos) = []; %remove 'default' from outputs 131 outputs = [outputs defaultoutputs( obj,md)]; %add defaults149 outputs = [outputs defaultoutputs(self,md)]; %add defaults 132 150 end 133 151 WriteData(fid,'data',outputs,'enum',ThermalRequestedOutputsEnum(),'format','StringArray'); -
issm/trunk/src/m/classes/thermal.py
r18301 r19105 1 1 import numpy 2 from project3d import project3d 2 3 from fielddisplay import fielddisplay 3 4 from EnumDefinitions import * … … 18 19 self.penalty_threshold = 0 19 20 self.stabilization = 0 21 self.reltol = 0 20 22 self.maxiter = 0 21 23 self.penalty_lock = 0 … … 34 36 string="%s\n%s"%(string,fielddisplay(self,'stabilization','0: no, 1: artificial_diffusivity, 2: SUPG')) 35 37 string="%s\n%s"%(string,fielddisplay(self,'maxiter','maximum number of non linear iterations')) 38 string="%s\n%s"%(string,fielddisplay(self,'reltol','relative tolerance criterion')) 36 39 string="%s\n%s"%(string,fielddisplay(self,'penalty_lock','stabilize unstable thermal constraints that keep zigzagging after n iteration (default is 0, no stabilization)')) 37 40 string="%s\n%s"%(string,fielddisplay(self,'penalty_threshold','threshold to declare convergence of thermal solution (default is 0)')) … … 41 44 return string 42 45 #}}} 46 def extrude(self,md): # {{{ 47 self.spctemperature=project3d(md,'vector',self.spctemperature,'type','node','layer',md.mesh.numberoflayers,'padding',numpy.nan) 48 if isinstance(md.initialization.temperature,numpy.ndarray) and numpy.size(md.initialization.temperature,axis=0)==md.mesh.numberofvertices: 49 self.spctemperature=numpy.nan*numpy.ones((md.mesh.numberofvertices,1)) 50 pos=numpy.nonzero(md.mesh.vertexonsurface)[0] 51 self.spctemperature[pos]=md.initialization.temperature[pos] #impose observed temperature on surface 52 return self 53 #}}} 43 54 def defaultoutputs(self,md): # {{{ 44 55 … … 56 67 #Type of stabilization used 57 68 self.stabilization=1 69 70 #Relative tolerance for the enthalpy convergence 71 self.reltol=0.01 58 72 59 73 #Maximum number of iterations … … 81 95 82 96 md = checkfield(md,'fieldname','thermal.stabilization','numel',[1],'values',[0,1,2]) 83 md = checkfield(md,'fieldname','thermal.spctemperature',' forcing',1)97 md = checkfield(md,'fieldname','thermal.spctemperature','timeseries',1) 84 98 if EnthalpyAnalysisEnum() in analyses and md.thermal.isenthalpy and md.mesh.dimension()==3: 85 99 pos=numpy.nonzero(numpy.logical_not(numpy.isnan(md.thermal.spctemperature[0:md.mesh.numberofvertices]))) … … 89 103 md = checkfield(md,'fieldname','thermal.isdynamicbasalspc','numel',[1],'values',[0,1]); 90 104 if(md.thermal.isenthalpy): 91 md = checkfield(md,'fieldname','thermal.isdynamicbasalspc','numel', [1],'values',[1], 'message',"for enthalpy run thermal.isdynamicbasalspc should be true") 105 if numpy.isnan(md.stressbalance.reltol): 106 md.checkmessage("for a steadystate computation, thermal.reltol (relative convergence criterion) must be defined!") 107 md = checkfield(md,'fieldname','thermal.reltol','>',0.,'message',"reltol must be larger than zero"); 92 108 md = checkfield(md,'fieldname','thermal.requested_outputs','stringrow',1) 93 109 … … 95 111 # }}} 96 112 def marshall(self,md,fid): # {{{ 97 WriteData(fid,'object',self,'fieldname','spctemperature','format','DoubleMat','mattype',1,' forcinglength',md.mesh.numberofvertices+1)113 WriteData(fid,'object',self,'fieldname','spctemperature','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1) 98 114 WriteData(fid,'object',self,'fieldname','penalty_threshold','format','Integer') 99 115 WriteData(fid,'object',self,'fieldname','stabilization','format','Integer') 116 WriteData(fid,'object',self,'fieldname','reltol','format','Double'); 100 117 WriteData(fid,'object',self,'fieldname','maxiter','format','Integer') 101 118 WriteData(fid,'object',self,'fieldname','penalty_lock','format','Integer') -
issm/trunk/src/m/classes/timestepping.m
r18301 r19105 12 12 cfl_coefficient = 0.; 13 13 interp_forcings = 1; 14 in_years = 1; 14 15 end 15 16 methods 16 function createxml( obj,fid) % {{{17 function createxml(self,fid) % {{{ 17 18 fprintf(fid, '\n\n'); 18 19 fprintf(fid, '%s\n', '<!-- Timestepping -->'); 19 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="start_time" type="', class( obj.start_time),'" default="', convert2str(obj.start_time),'">', ' <section name="timestepping" />',' <help> simulation starting time [yr] </help>','</parameter>');20 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="final_time" type="', class( obj.final_time),'" default="', convert2str(obj.final_time),'">', ' <section name="timestepping" />',' <help> final time to stop the simulation [yr] </help>','</parameter>');21 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="time_step" type="', class( obj.time_step),'" default="', convert2str(obj.time_step),'">', ' <section name="timestepping" />',' <help> length of time steps [yr] </help>','</parameter>');20 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="start_time" type="', class(self.start_time),'" default="', convert2str(self.start_time),'">', ' <section name="timestepping" />',' <help> simulation starting time [yr] </help>','</parameter>'); 21 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="final_time" type="', class(self.final_time),'" default="', convert2str(self.final_time),'">', ' <section name="timestepping" />',' <help> final time to stop the simulation [yr] </help>','</parameter>'); 22 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="time_step" type="', class(self.time_step),'" default="', convert2str(self.time_step),'">', ' <section name="timestepping" />',' <help> length of time steps [yr] </help>','</parameter>'); 22 23 % time_adapt 0 or 1 drop down 23 24 fprintf(fid,'%s\n%s\n%s\n%s\n','<parameter key ="time_adapt" type="alternative" optional="false">',' <section name="timestepping" />',' <help> use cfl condition to define time step ? (0 or 1) </help>'); 24 25 fprintf(fid, '%s\n', ' <option value="0" type="string" default="true"></option>'); 25 26 fprintf(fid, '%s\n%s\n', ' <option value="1" type="string" default="false"></option>','</parameter>'); 26 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="cfl_coefficient" type="', class( obj.cfl_coefficient),'" default="', convert2str(obj.cfl_coefficient),'">', ' <section name="timestepping" />',' <help> coefficient applied to cfl condition </help>','</parameter>');27 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n', '<parameter key ="cfl_coefficient" type="', class(self.cfl_coefficient),'" default="', convert2str(self.cfl_coefficient),'">', ' <section name="timestepping" />',' <help> coefficient applied to cfl condition </help>','</parameter>'); 27 28 28 29 end % }}} 29 30 30 function obj= timestepping(varargin) % {{{31 function self = timestepping(varargin) % {{{ 31 32 switch nargin 32 33 case 0 33 obj=setdefaultparameters(obj);34 self=setdefaultparameters(self); 34 35 otherwise 35 36 error('constructor not supported'); 36 37 end 37 38 end % }}} 38 function obj = setdefaultparameters(obj) % {{{39 function self = setdefaultparameters(self) % {{{ 39 40 40 41 %time between 2 time steps 41 obj.time_step=1./2.;42 self.time_step=1./2.; 42 43 43 44 %final time 44 obj.final_time=10.*obj.time_step;45 self.final_time=10.*self.time_step; 45 46 46 47 %time adaptation? 47 obj.time_adapt=0;48 obj.cfl_coefficient=0.5;48 self.time_adapt=0; 49 self.cfl_coefficient=0.5; 49 50 50 51 %should we interpolate forcings between timesteps? 51 obj.interp_forcings=1; 52 self.interp_forcings=1; 53 54 %In years by default 55 self.in_years = 1; 52 56 end % }}} 53 function md = checkconsistency( obj,md,solution,analyses) % {{{57 function md = checkconsistency(self,md,solution,analyses) % {{{ 54 58 55 59 md = checkfield(md,'fieldname','timestepping.start_time','numel',[1],'NaN',1); … … 59 63 md = checkfield(md,'fieldname','timestepping.cfl_coefficient','numel',[1],'>',0,'<=',1); 60 64 md = checkfield(md,'fieldname','timestepping.interp_forcings','numel',[1],'values',[0 1]); 61 if obj.final_time-obj.start_time<0,65 if self.final_time-self.start_time<0, 62 66 md = checkmessage(md,'timestepping.final_time should be larger than timestepping.start_time'); 63 67 end 64 68 end % }}} 65 function disp( obj) % {{{69 function disp(self) % {{{ 66 70 disp(sprintf(' timestepping parameters:')); 67 71 68 fielddisplay(obj,'start_time','simulation starting time [yr]'); 69 fielddisplay(obj,'final_time','final time to stop the simulation [yr]'); 70 fielddisplay(obj,'time_step','length of time steps [yr]'); 71 fielddisplay(obj,'time_adapt','use cfl condition to define time step ? (0 or 1) '); 72 fielddisplay(obj,'cfl_coefficient','coefficient applied to cfl condition'); 73 fielddisplay(obj,'interp_forcings','interpolate in time between requested forcing values ? (0 or 1)'); 72 if(self.in_years) 73 unit = 'yr'; 74 else 75 unit = 's'; 76 end 77 fielddisplay(self,'start_time',['simulation starting time [' unit ']']); 78 fielddisplay(self,'final_time',['final time to stop the simulation [' unit ']']); 79 fielddisplay(self,'time_step',['length of time steps [' unit ']']); 80 fielddisplay(self,'time_adapt','use cfl condition to define time step ? (0 or 1) '); 81 fielddisplay(self,'cfl_coefficient','coefficient applied to cfl condition'); 82 fielddisplay(self,'interp_forcings','interpolate in time between requested forcing values ? (0 or 1)'); 83 fielddisplay(self,'in_years','time unit, 1: years, 0: seconds'); 74 84 75 85 end % }}} 76 function marshall( obj,md,fid) % {{{86 function marshall(self,md,fid) % {{{ 77 87 78 yts=365.0*24.0*3600.0; 79 80 WriteData(fid,'object',obj,'fieldname','start_time','format','Double','scale',yts); 81 WriteData(fid,'object',obj,'fieldname','final_time','format','Double','scale',yts); 82 WriteData(fid,'object',obj,'fieldname','time_step','format','Double','scale',yts); 83 WriteData(fid,'object',obj,'fieldname','time_adapt','format','Boolean'); 84 WriteData(fid,'object',obj,'fieldname','cfl_coefficient','format','Double'); 85 WriteData(fid,'object',obj,'fieldname','interp_forcings','format','Boolean'); 88 if self.in_years, 89 scale = 365.0*24.0*3600.0; 90 else 91 scale = 1.; 92 end 93 WriteData(fid,'object',self,'fieldname','start_time','format','Double','scale',scale); 94 WriteData(fid,'object',self,'fieldname','final_time','format','Double','scale',scale); 95 WriteData(fid,'object',self,'fieldname','time_step','format','Double','scale',scale); 96 WriteData(fid,'object',self,'fieldname','time_adapt','format','Boolean'); 97 WriteData(fid,'object',self,'fieldname','cfl_coefficient','format','Double'); 98 WriteData(fid,'object',self,'fieldname','interp_forcings','format','Boolean'); 86 99 end % }}} 87 100 end -
issm/trunk/src/m/classes/toolkits.m
r16560 r19105 2 2 % 3 3 % Usage: 4 % obj=toolkits();4 % self=toolkits(); 5 5 6 6 classdef toolkits < dynamicprops … … 10 10 end 11 11 methods 12 function obj= toolkits(varargin) % {{{12 function self = toolkits(varargin) % {{{ 13 13 switch nargin 14 14 case 0 15 obj=setdefaultparameters(obj);15 self=setdefaultparameters(self); 16 16 case 1 17 obj=structtoobj(obj,varargin{1});17 self=structtoobj(self,varargin{1}); 18 18 otherwise 19 19 error('constructor not supported'); 20 20 end 21 21 end % }}} 22 function obj = addoptions(obj,analysis,varargin) % {{{22 function self = addoptions(self,analysis,varargin) % {{{ 23 23 % Usage example: 24 24 % md.toolkits=addoptions(md.toolkits,StressbalanceAnalysisEnum(),FSoptions()); … … 29 29 30 30 %Create dynamic property if property does not exist yet 31 if ~ismember(analysis,properties( obj)),32 obj.addprop(analysis);31 if ~ismember(analysis,properties(self)), 32 self.addprop(analysis); 33 33 end 34 34 35 35 %Add toolkits options to analysis 36 if nargin==3, obj.(analysis) = varargin{1}; end36 if nargin==3, self.(analysis) = varargin{1}; end 37 37 end 38 38 %}}} 39 function obj = setdefaultparameters(obj) % {{{39 function self = setdefaultparameters(self) % {{{ 40 40 41 41 %default toolkits: … … 43 43 %MUMPS is the default toolkits 44 44 if IssmConfig('_HAVE_MUMPS_'), 45 obj.DefaultAnalysis = mumpsoptions();45 self.DefaultAnalysis = mumpsoptions(); 46 46 else 47 obj.DefaultAnalysis = iluasmoptions();47 self.DefaultAnalysis = iluasmoptions(); 48 48 end 49 49 else 50 50 if IssmConfig('_HAVE_MUMPS_'), 51 obj.DefaultAnalysis = issmmumpssolver();51 self.DefaultAnalysis = issmmumpssolver(); 52 52 elseif IssmConfig('_HAVE_GSL_'), 53 obj.DefaultAnalysis = issmgslsolver();53 self.DefaultAnalysis = issmgslsolver(); 54 54 else 55 55 error('Need at least Mumps or Gsl to define an issm solver type'); … … 58 58 59 59 end % }}} 60 function disp( obj) % {{{61 analyses=properties( obj);60 function disp(self) % {{{ 61 analyses=properties(self); 62 62 disp(sprintf('List of toolkits options per analysis:\n')); 63 63 for i=1:numel(analyses), 64 64 analysis=analyses{i}; 65 65 disp([analysis ':']); 66 disp( obj.(analysis));66 disp(self.(analysis)); 67 67 end 68 68 end % }}} 69 function md = checkconsistency( obj,md,solution,analyses) % {{{70 analyses=properties( obj);69 function md = checkconsistency(self,md,solution,analyses) % {{{ 70 analyses=properties(self); 71 71 for i=1:numel(analyses), 72 if isempty(fieldnames( obj.(analyses{i})))72 if isempty(fieldnames(self.(analyses{i}))) 73 73 md = checkmessage(md,['md.toolkits.' analyses{i} ' is empty']); 74 74 end -
issm/trunk/src/m/classes/toolkits.py
r17806 r19105 12 12 13 13 Usage: 14 obj=toolkits();14 self=toolkits(); 15 15 """ 16 16 -
issm/trunk/src/m/classes/transient.m
r17989 r19105 13 13 isdamageevolution = 0; 14 14 islevelset = 0; 15 iscalving = 0; 15 16 ishydrology = 0; 16 17 requested_outputs = {}; 17 18 end 18 19 methods 19 function createxml( obj,fid) % {{{20 function createxml(self,fid) % {{{ 20 21 fprintf(fid, '<!-- transient -->\n'); 21 22 22 23 % transient solution parameters 23 24 fprintf(fid,'%s\n%s\n%s\n','<frame key="1" label="transient solution parameters">','<section name="transient" />'); 24 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="ismasstransport" type="',class(obj.ismasstransport),'" default="',convert2str(obj.ismasstransport),'">',' <section name="transient" />',' <help> indicates whether a masstransport solution is used in the transient </help>',' </parameter>'); 25 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="isstressbalance" type="',class(obj.isstressbalance),'" default="',convert2str(obj.isstressbalance),'">',' <section name="transient" />',' <help> indicates whether a stressbalance solution is used in the transient </help>',' </parameter>'); 26 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="isthermal" type="',class(obj.isthermal),'" default="',convert2str(obj.isthermal),'">',' <section name="transient" />',' <help> indicates whether a thermal solution is used in the transient </help>',' </parameter>'); 27 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="isgroundingline" type="',class(obj.isgroundingline),'" default="',convert2str(obj.isgroundingline),'">',' <section name="transient" />',' <help> indicates whether a groundingline migration is used in the transient </help>',' </parameter>'); 28 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="isgia" type="',class(obj.isgia),'" default="',convert2str(obj.isgia),'">',' <section name="transient" />',' <help> indicates whether a postglacial rebound model is used in the transient </help>',' </parameter>'); 29 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="isdamageevolution" type="',class(obj.isdamageevolution),'" default="',convert2str(obj.isdamageevolution),'">',' <section name="transient" />',' <help> indicates whether damage evolution is used in the transient </help>',' </parameter>'); 30 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="islevelset" type="',class(obj.islevelset),'" default="',convert2str(obj.islevelset),'">',' <section name="transient" />',' <help> LEVEL SET DESCRIPTION... </help>',' </parameter>'); 31 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="requested_outputs" type="',class(obj.requested_outputs),'" default="',convert2str(obj.requested_outputs),'">',' <section name="transient" />',' <help> list of additional outputs requested </help>',' </parameter>'); 25 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="ismasstransport" type="',class(self.ismasstransport),'" default="',convert2str(self.ismasstransport),'">',' <section name="transient" />',' <help> indicates whether a masstransport solution is used in the transient </help>',' </parameter>'); 26 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="isstressbalance" type="',class(self.isstressbalance),'" default="',convert2str(self.isstressbalance),'">',' <section name="transient" />',' <help> indicates whether a stressbalance solution is used in the transient </help>',' </parameter>'); 27 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="isthermal" type="',class(self.isthermal),'" default="',convert2str(self.isthermal),'">',' <section name="transient" />',' <help> indicates whether a thermal solution is used in the transient </help>',' </parameter>'); 28 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="isgroundingline" type="',class(self.isgroundingline),'" default="',convert2str(self.isgroundingline),'">',' <section name="transient" />',' <help> indicates whether a groundingline migration is used in the transient </help>',' </parameter>'); 29 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="isgia" type="',class(self.isgia),'" default="',convert2str(self.isgia),'">',' <section name="transient" />',' <help> indicates whether a postglacial rebound model is used in the transient </help>',' </parameter>'); 30 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="isdamageevolution" type="',class(self.isdamageevolution),'" default="',convert2str(self.isdamageevolution),'">',' <section name="transient" />',' <help> indicates whether damage evolution is used in the transient </help>',' </parameter>'); 31 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="islevelset" type="',class(self.islevelset),'" default="',convert2str(self.islevelset),'">',' <section name="transient" />',' <help> LEVEL SET DESCRIPTION... </help>',' </parameter>'); 32 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="iscalving" type="',class(self.iscalving),'" default="',convert2str(self.iscalving),'">',' <section name="transient" />',' <help> indicates whether calving is used in the transient </help>',' </parameter>'); 33 fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',' <parameter key ="requested_outputs" type="',class(self.requested_outputs),'" default="',convert2str(self.requested_outputs),'">',' <section name="transient" />',' <help> list of additional outputs requested </help>',' </parameter>'); 32 34 fprintf(fid,'%s\n%s\n','</frame>'); 33 35 34 36 end % }}} 35 function obj= transient(varargin) % {{{37 function self = transient(varargin) % {{{ 36 38 switch nargin 37 39 case 0 38 obj=setdefaultparameters(obj);40 self = setdefaultparameters(self); 39 41 otherwise 40 42 error('constructor not supported'); 41 43 end 42 44 end % }}} 43 function obj = deactivateall(obj) % {{{45 function self = deactivateall(self) % {{{ 44 46 45 47 %full analysis: Stressbalance, Masstransport and Thermal but no groundingline migration for now 46 obj.ismasstransport = 0; 47 obj.isstressbalance = 0; 48 obj.isthermal = 0; 49 obj.isgroundingline = 0; 50 obj.isgia = 0; 51 obj.isdamageevolution = 0; 52 obj.islevelset = 0; 53 obj.ishydrology = 0; 48 self.ismasstransport = 0; 49 self.isstressbalance = 0; 50 self.isthermal = 0; 51 self.isgroundingline = 0; 52 self.isgia = 0; 53 self.isdamageevolution = 0; 54 self.islevelset = 0; 55 self.iscalving =0; 56 self.ishydrology = 0; 54 57 55 58 %default output 56 obj.requested_outputs={};59 self.requested_outputs={}; 57 60 end % }}} 58 function obj = setdefaultparameters(obj) % {{{61 function self = setdefaultparameters(self) % {{{ 59 62 60 63 %full analysis: Stressbalance, Masstransport and Thermal but no groundingline migration for now 61 obj.ismasstransport = 1; 62 obj.isstressbalance = 1; 63 obj.isthermal = 1; 64 obj.isgroundingline = 0; 65 obj.isgia = 0; 66 obj.isdamageevolution = 0; 67 obj.islevelset = 0; 68 obj.ishydrology = 0; 64 self.ismasstransport = 1; 65 self.isstressbalance = 1; 66 self.isthermal = 1; 67 self.isgroundingline = 0; 68 self.isgia = 0; 69 self.isdamageevolution = 0; 70 self.islevelset = 0; 71 self.iscalving = 0; 72 self.ishydrology = 0; 69 73 70 74 %default output 71 obj.requested_outputs={'default'};75 self.requested_outputs={'default'}; 72 76 end % }}} 73 77 function list = defaultoutputs(self,md) % {{{ … … 78 82 end 79 83 end % }}} 80 function md = checkconsistency( obj,md,solution,analyses) % {{{84 function md = checkconsistency(self,md,solution,analyses) % {{{ 81 85 82 86 %Early return … … 90 94 md = checkfield(md,'fieldname','transient.isdamageevolution','numel',[1],'values',[0 1]); 91 95 md = checkfield(md,'fieldname','transient.islevelset','numel',[1],'values',[0 1]); 96 md = checkfield(md,'fieldname','transient.iscalving','numel',[1],'values',[0 1]); 92 97 md = checkfield(md,'fieldname','transient.ishydrology','numel',[1],'values',[0 1]); 93 98 md = checkfield(md,'fieldname','transient.requested_outputs','stringrow',1); 94 99 95 100 end % }}} 96 function disp( obj) % {{{101 function disp(self) % {{{ 97 102 disp(sprintf(' transient solution parameters:')); 98 103 99 fielddisplay(obj,'ismasstransport','indicates whether a masstransport solution is used in the transient'); 100 fielddisplay(obj,'isstressbalance','indicates whether a stressbalance solution is used in the transient'); 101 fielddisplay(obj,'isthermal','indicates whether a thermal solution is used in the transient'); 102 fielddisplay(obj,'isgroundingline','indicates whether a groundingline migration is used in the transient'); 103 fielddisplay(obj,'isgia','indicates whether a postglacial rebound model is used in the transient'); 104 fielddisplay(obj,'isdamageevolution','indicates whether damage evolution is used in the transient'); 105 fielddisplay(obj,'islevelset','LEVEL SET DESCRIPTION...'); 106 fielddisplay(obj,'ishydrology','indicates whether an hydrology model is used'); 107 fielddisplay(obj,'requested_outputs','list of additional outputs requested'); 104 fielddisplay(self,'ismasstransport','indicates whether a masstransport solution is used in the transient'); 105 fielddisplay(self,'isstressbalance','indicates whether a stressbalance solution is used in the transient'); 106 fielddisplay(self,'isthermal','indicates whether a thermal solution is used in the transient'); 107 fielddisplay(self,'isgroundingline','indicates whether a groundingline migration is used in the transient'); 108 fielddisplay(self,'isgia','indicates whether a postglacial rebound model is used in the transient'); 109 fielddisplay(self,'isdamageevolution','indicates whether damage evolution is used in the transient'); 110 fielddisplay(self,'islevelset','LEVEL SET DESCRIPTION...'); 111 fielddisplay(self,'iscalving','indicates whether calving is used in the transient'); 112 fielddisplay(self,'ishydrology','indicates whether an hydrology model is used'); 113 fielddisplay(self,'requested_outputs','list of additional outputs requested'); 108 114 109 115 end % }}} 110 function marshall(obj,md,fid) % {{{ 111 WriteData(fid,'object',obj,'fieldname','ismasstransport','format','Boolean'); 112 WriteData(fid,'object',obj,'fieldname','isstressbalance','format','Boolean'); 113 WriteData(fid,'object',obj,'fieldname','isthermal','format','Boolean'); 114 WriteData(fid,'object',obj,'fieldname','isgroundingline','format','Boolean'); 115 WriteData(fid,'object',obj,'fieldname','isgia','format','Boolean'); 116 WriteData(fid,'object',obj,'fieldname','isdamageevolution','format','Boolean'); 117 WriteData(fid,'object',obj,'fieldname','ishydrology','format','Boolean'); 118 WriteData(fid,'object',obj,'fieldname','islevelset','format','Boolean'); 116 function marshall(self,md,fid) % {{{ 117 WriteData(fid,'object',self,'fieldname','ismasstransport','format','Boolean'); 118 WriteData(fid,'object',self,'fieldname','isstressbalance','format','Boolean'); 119 WriteData(fid,'object',self,'fieldname','isthermal','format','Boolean'); 120 WriteData(fid,'object',self,'fieldname','isgroundingline','format','Boolean'); 121 WriteData(fid,'object',self,'fieldname','isgia','format','Boolean'); 122 WriteData(fid,'object',self,'fieldname','isdamageevolution','format','Boolean'); 123 WriteData(fid,'object',self,'fieldname','ishydrology','format','Boolean'); 124 WriteData(fid,'object',self,'fieldname','islevelset','format','Boolean'); 125 WriteData(fid,'object',self,'fieldname','iscalving','format','Boolean'); 119 126 120 127 %process requested outputs 121 outputs = obj.requested_outputs;128 outputs = self.requested_outputs; 122 129 pos = find(ismember(outputs,'default')); 123 130 if ~isempty(pos), 124 131 outputs(pos) = []; %remove 'default' from outputs 125 outputs = [outputs defaultoutputs( obj,md)]; %add defaults132 outputs = [outputs defaultoutputs(self,md)]; %add defaults 126 133 end 127 134 WriteData(fid,'data',outputs,'enum',TransientRequestedOutputsEnum,'format','StringArray'); -
issm/trunk/src/m/classes/transient.py
r17806 r19105 20 20 self.isdamageevolution = False 21 21 self.islevelset = False 22 self.iscalving = False 22 23 self.ishydrology = False 23 24 self.requested_outputs = [] … … 36 37 string="%s\n%s"%(string,fielddisplay(self,'isdamageevolution','indicates whether damage evolution is used in the transient')) 37 38 string="%s\n%s"%(string,fielddisplay(self,'islevelset','LEVELSET METHOD DESCRIPTION')) 39 string="%s\n%s"%(string,fielddisplay(self,'iscalving','indicates whether calving is used in the transient')) 38 40 string="%s\n%s"%(string,fielddisplay(self,'ishydrology','indicates whether an hydrology model is used')) 39 41 string="%s\n%s"%(string,fielddisplay(self,'requested_outputs','list of additional outputs requested')) … … 51 53 52 54 #Nothing done 53 self.ismasstransport = False54 self.isstressbalance = False55 self.isthermal = False56 self.isgroundingline = False57 self.isgia = False55 self.ismasstransport = False 56 self.isstressbalance = False 57 self.isthermal = False 58 self.isgroundingline = False 59 self.isgia = False 58 60 self.isdamageevolution = False 59 self.islevelset = False 60 self.ishydrology = False 61 self.islevelset = False 62 self.iscalving = False 63 self.ishydrology = False 61 64 62 65 #default output … … 74 77 self.isdamageevolution = False 75 78 self.islevelset = False 76 self.ishydrology = False 79 self.iscalving = False 80 self.ishydrology = False 77 81 78 82 #default output … … 94 98 md = checkfield(md,'fieldname','transient.islevelset','numel',[1],'values',[0,1]) 95 99 md = checkfield(md,'fieldname','transient.ishydrology','numel',[1],'values',[0,1]) 100 md = checkfield(md,'fieldname','transient.iscalving','numel',[1],'values',[0,1]); 96 101 md = checkfield(md,'fieldname','transient.requested_outputs','stringrow',1) 97 102 … … 107 112 WriteData(fid,'object',self,'fieldname','islevelset','format','Boolean') 108 113 WriteData(fid,'object',self,'fieldname','ishydrology','format','Boolean') 114 WriteData(fid,'object',self,'fieldname','iscalving','format','Boolean') 109 115 110 116 #process requested outputs -
issm/trunk/src/m/classes/verbose.m
r17806 r19105 38 38 %}}} 39 39 methods 40 function createxml(obj,fid) % {{{41 42 43 44 fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n%s\n', '<parameter key ="mprocessor" type="', class(obj.mprocessor),'" optional="false">', ' <section name="verbose" />',' <option value="',convert2str(obj.mprocessor),'" type="string" default="true"></option>',' <help> </help>','</parameter>');45 fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n%s\n', '<parameter key ="module" type="', class(obj.module),'" optional="false">', ' <section name="verbose" />',' <option value="',convert2str(obj.module),'" type="string" default="true"></option>',' <help> </help>','</parameter>');46 fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n%s\n', '<parameter key ="solution" type="', class(obj.solution),'" optional="false">', ' <section name="verbose" />',' <option value="',convert2str(obj.solution),'" type="string" default="true"></option>',' <help> </help>','</parameter>');47 fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n%s\n', '<parameter key ="solver" type="', class(obj.solver),'" optional="false">', ' <section name="verbose" />',' <option value="',convert2str(obj.solver),'" type="string" default="true"></option>',' <help> </help>','</parameter>');48 fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n%s\n', '<parameter key ="convergence" type="', class(obj.convergence),'" optional="false">', ' <section name="verbose" />',' <option value="',convert2str(obj.convergence),'" type="string" default="true"></option>',' <help> </help>','</parameter>');49 fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n%s\n', '<parameter key ="control" type="', class(obj.control),'" optional="false">', ' <section name="verbose" />',' <option value="',convert2str(obj.control),'" type="string" default="true"></option>',' <help> </help>','</parameter>');50 fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n%s\n', '<parameter key ="qmu" type="', class(obj.qmu),'" optional="false">', ' <section name="verbose" />',' <option value="',convert2str(obj.qmu),'" type="string" default="true"></option>',' <help> </help>','</parameter>');51 fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n', '<parameter key ="autodiff" type="', class(obj.autodiff),'" optional="false">', ' <section name="verbose" />',' <option value="',convert2str(obj.autodiff),'" type="string" default="true"></option>',' <help> </help>','</parameter>');52 53 54 40 function createxml(self,fid) % {{{ 41 fprintf(fid, '\n\n'); 42 fprintf(fid, '%s\n', '<!-- verbose -->'); 43 44 fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n%s\n', '<parameter key ="mprocessor" type="', class(self.mprocessor),'" optional="false">', ' <section name="verbose" />',' <option value="',convert2str(self.mprocessor),'" type="string" default="true"></option>',' <help> </help>','</parameter>'); 45 fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n%s\n', '<parameter key ="module" type="', class(self.module),'" optional="false">', ' <section name="verbose" />',' <option value="',convert2str(self.module),'" type="string" default="true"></option>',' <help> </help>','</parameter>'); 46 fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n%s\n', '<parameter key ="solution" type="', class(self.solution),'" optional="false">', ' <section name="verbose" />',' <option value="',convert2str(self.solution),'" type="string" default="true"></option>',' <help> </help>','</parameter>'); 47 fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n%s\n', '<parameter key ="solver" type="', class(self.solver),'" optional="false">', ' <section name="verbose" />',' <option value="',convert2str(self.solver),'" type="string" default="true"></option>',' <help> </help>','</parameter>'); 48 fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n%s\n', '<parameter key ="convergence" type="', class(self.convergence),'" optional="false">', ' <section name="verbose" />',' <option value="',convert2str(self.convergence),'" type="string" default="true"></option>',' <help> </help>','</parameter>'); 49 fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n%s\n', '<parameter key ="control" type="', class(self.control),'" optional="false">', ' <section name="verbose" />',' <option value="',convert2str(self.control),'" type="string" default="true"></option>',' <help> </help>','</parameter>'); 50 fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n%s\n', '<parameter key ="qmu" type="', class(self.qmu),'" optional="false">', ' <section name="verbose" />',' <option value="',convert2str(self.qmu),'" type="string" default="true"></option>',' <help> </help>','</parameter>'); 51 fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n', '<parameter key ="autodiff" type="', class(self.autodiff),'" optional="false">', ' <section name="verbose" />',' <option value="',convert2str(self.autodiff),'" type="string" default="true"></option>',' <help> </help>','</parameter>'); 52 53 54 end % }}} 55 55 function verbose=verbose(varargin) % {{{ 56 56 … … 123 123 end 124 124 %}}} 125 function md = checkconsistency( obj,md,solution,analyses) % {{{125 function md = checkconsistency(self,md,solution,analyses) % {{{ 126 126 127 127 end % }}} … … 142 142 end 143 143 %}}} 144 function marshall( obj,md,fid) % {{{145 WriteData(fid,'data',VerboseToBinary( obj),'enum',VerboseEnum(),'format','Integer');144 function marshall(self,md,fid) % {{{ 145 WriteData(fid,'data',VerboseToBinary(self),'enum',VerboseEnum(),'format','Integer'); 146 146 end % }}} 147 147 end -
issm/trunk/src/m/consistency/checkfield.m
r18301 r19105 14 14 % - <=: smaller or equal to provided value 15 15 % - < vec: smallerthan provided values on each vertex 16 % - forcing: 1 if check forcingconsistency (size and time)16 % - timeseries: 1 if check time series consistency (size and time) 17 17 % - values: cell of strings or vector of acceptable values 18 18 % - numel: list of acceptable number of elements … … 198 198 199 199 %Check forcings (size and times) 200 if getfieldvalue(options,' forcing',0),200 if getfieldvalue(options,'timeseries',0), 201 201 if size(field,1)==md.mesh.numberofvertices, 202 202 if ~size(field,2)==1, -
issm/trunk/src/m/consistency/checkfield.py
r18301 r19105 21 21 - <=: smaller or equal to provided value 22 22 - < vec: smallerthan provided values on each vertex 23 - forcing: 1 if check forcingconsistency (size and time)23 - timeseries: 1 if check time series consistency (size and time) 24 24 - values: cell of strings or vector of acceptable values 25 25 - numel: list of acceptable number of elements … … 151 151 152 152 #Check forcings (size and times) 153 if options.getfieldvalue(' forcing',0):153 if options.getfieldvalue('timeseries',0): 154 154 if numpy.size(field,0)==md.mesh.numberofvertices: 155 155 if numpy.ndim(field)>1 and not numpy.size(field,1)==1: -
issm/trunk/src/m/contrib/bamg/gmsh3d.m
r18301 r19105 97 97 %call gmsh 98 98 fprintf('%s\n',' call gmsh...'); 99 system([issmdir() '/externalpackages/gmsh/install/gmsh -3 model.geo']);99 system([issmdir() '/externalpackages/gmsh/install/gmsh -3 -v 0 model.geo']); 100 100 101 101 %plug new mesh -
issm/trunk/src/m/contrib/gslib/gslib.m
r17806 r19105 1 function [B E] = gslib(x,y,data,xmin,ymin,nx,ny,deltax,deltay )1 function [B E] = gslib(x,y,data,xmin,ymin,nx,ny,deltax,deltay,varargin) 2 2 %GSLIB - use gslib for Kriging 3 3 % … … 5 5 % output = gslib(x,y,data,varargin) 6 6 7 %process options 8 options = pairoptions(varargin{:}); 9 7 10 %Variogram 8 nugget= 10;9 sill = 164;10 range = 25763;11 nugget= getfieldvalue(options,'nugget',10); 12 sill = getfieldvalue(options,'sill',164); 13 range = getfieldvalue(options,'range',25763); 11 14 12 15 %Kriging options 13 mindata = 1;14 maxdata = 50;15 maxsearchradius = 50000;16 mindata = getfieldvalue(options,'mindata',1); 17 maxdata = getfieldvalue(options,'maxdata',50); 18 maxsearchradius = getfieldvalue(options,'searchrange',50000); 16 19 17 20 %Some intermediaries (Convert to gslib's parameters); -
issm/trunk/src/m/contrib/paraview/exportVTK.m
r18514 r19105 25 25 if dimension(model.mesh)==2, 26 26 points=[model.mesh.x model.mesh.y zeros(model.mesh.numberofvertices,1)]; 27 [num_of_points,dim]=size(points); 28 [num_of_elt]=size(model.mesh.elements,1); 29 [point_per_elt]=size(model.mesh.elements,2); 27 30 else 28 31 points=[model.mesh.x model.mesh.y model.mesh.z]; 32 [num_of_points,dim]=size(points); 33 [num_of_elt]=size(model.mesh.elements,1); 34 [point_per_elt]=size(model.mesh.elements,2); 29 35 end 30 36 31 [num_of_points,dim]=size(points);32 [num_of_elt]=size(model.mesh.elements,1);33 [point_per_elt]=size(model.mesh.elements,2);34 37 35 38 %Select the type of element function of the number of nodes per elements … … 65 68 timestep=step; 66 69 67 fid = fopen(strcat(path,filesep,name,filesep, name,'.vtk',int2str(timestep),'.vtk'),'w+');70 fid = fopen(strcat(path,filesep,name,filesep,'timestep.vtk',int2str(timestep),'.vtk'),'w+'); 68 71 fprintf(fid,'# vtk DataFile Version 2.0 \n'); 69 72 fprintf(fid,'Data for run %s \n',model.miscellaneous.name); … … 86 89 end 87 90 s=cell2mat(horzcat(s,{'\n'})); 88 fprintf(fid,s,[(point_per_elt)*ones(num_of_elt,1)model.mesh.elements-1]');91 fprintf(fid,s,[(point_per_elt)*ones(num_of_elt,1) model.mesh.elements-1]'); 89 92 90 93 fprintf(fid,'CELL_TYPES %d\n',num_of_elt); -
issm/trunk/src/m/coordsystems/utm2ll.m
r6341 r19105 1 function [Lat,Lon] = utm2ll(xx,yy,utmzone) 2 % ------------------------------------------------------------------------- 3 % [Lat,Lon] = utm2ll(x,y,utmzone) 1 function [lat,lon]=utm2ll(x,y,f,datum,varargin) 2 %UTM2LL UTM to Lat/Lon coordinates precise conversion. 3 % [LAT,LON]=UTM2LL(X,Y,ZONE) converts UTM coordinates X,Y (in meters) 4 % defined in the UTM ZONE (integer) to latitude LAT and longitude LON 5 % (in degrees). Default datum is WGS84. 4 6 % 5 % Description: Function to convert vectors of UTM coordinates into Lat/Lon vectors (WGS84).6 % Some code has been extracted from UTMIP.m function by Gabriel Ruiz Martinez.7 % X and Y can be scalars, vectors or matrix. Outputs LAT and LON will 8 % have the same size as inputs. 7 9 % 8 % Inputs:on) 9 % -3.485713 7.801235 -119.955246 -17.759537 -94.799019 121.640266 10 % For southern hemisphere points, use negative zone -ZONE. 10 11 % 11 % Example 2: If you need Lat/Lon coordinates in Degrees, Minutes and Seconds 12 % [Lat, Lon]=utm2ll(x,y,utmzone); 13 % LatDMS=dms2mat(deg2dms(Lat)) 14 %LatDMS = 15 % 40.00 18.00 55.55 16 % 46.00 17.00 2.01 17 % 37.00 34.00 40.17 18 % 28.00 38.00 44.33 19 % 38.00 51.00 19.96 20 % 25.00 3.00 42.41 21 % LonDMS=dms2mat(deg2dms(Lon)) 22 %LonDMS = 23 % -3.00 29.00 8.61 24 % 7.00 48.00 4.40 25 % -119.00 57.00 18.93 26 % -17.00 45.00 34.33 27 % -94.00 47.00 56.47 28 % 121.00 38.00 24.96 12 % UTM2LL(X,Y,ZONE,DATUM) uses specific DATUM for conversion. DATUM can be 13 % a string in the following list: 14 % 'wgs84': World Geodetic System 1984 (default) 15 % 'nad27': North American Datum 1927 16 % 'clk66': Clarke 1866 17 % 'nad83': North American Datum 1983 18 % 'grs80': Geodetic Reference System 1980 19 % 'int24': International 1924 / Hayford 1909 20 % or DATUM can be a 2-element vector [A,F] where A is semimajor axis (in 21 % meters) and F is flattening of the user-defined ellipsoid. 29 22 % 30 % Author: 31 % Rafael Palacios 32 % Universidad Pontificia Comillas 33 % Madrid, Spain 34 % Version: Apr/06, Jun/06, Aug/06 35 % Aug/06: corrected m-Lint warnings 36 %------------------------------------------------------------------------- 23 % Notice: 24 % - UTM2LL does not perform cross-datum conversion. 25 % - precision is near a millimeter. 26 % 27 % 28 % Reference: 29 % I.G.N., Projection cartographique Mercator Transverse: Algorithmes, 30 % Notes Techniques NT/G 76, janvier 1995. 31 % 32 % Author: Francois Beauducel, <beauducel@ipgp.fr> 33 % Created: 2001-08-23 34 % Updated: 2014-04-20 37 35 38 % Argument checking 36 37 % Copyright (c) 2001-2014, François Beauducel, covered by BSD License. 38 % All rights reserved. 39 39 % 40 error(nargchk(3, 3, nargin)); %3 arguments required 41 n1=length(xx); 42 n2=length(yy); 43 n3=size(utmzone,1); 44 if (n1~=n2 || n1~=n3) 45 error('x,y and utmzone vectors should have the same number or rows'); 46 end 47 c=size(utmzone,2); 48 if (c~=4) 49 error('utmzone should be a vector of strings like "30 T"'); 40 % Redistribution and use in source and binary forms, with or without 41 % modification, are permitted provided that the following conditions are 42 % met: 43 % 44 % * Redistributions of source code must retain the above copyright 45 % notice, this list of conditions and the following disclaimer. 46 % * Redistributions in binary form must reproduce the above copyright 47 % notice, this list of conditions and the following disclaimer in 48 % the documentation and/or other materials provided with the distribution 49 % 50 % THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 51 % AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 52 % IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 53 % ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 54 % LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 55 % CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 56 % SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 57 % INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 58 % CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 59 % ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 60 % POSSIBILITY OF SUCH DAMAGE. 61 62 % Available datums 63 datums = [ ... 64 { 'wgs84', 6378137.0, 298.257223563 }; 65 { 'nad83', 6378137.0, 298.257222101 }; 66 { 'grs80', 6378137.0, 298.257222101 }; 67 { 'nad27', 6378206.4, 294.978698214 }; 68 { 'int24', 6378388.0, 297.000000000 }; 69 { 'clk66', 6378206.4, 294.978698214 }; 70 ]; 71 72 if nargin < 3 73 error('Not enough input arguments.') 50 74 end 51 75 52 % Memory pre-allocation 53 % 54 Lat=zeros(n1,1); 55 Lon=zeros(n1,1); 76 if all([numel(x),numel(y)] > 1) && any(size(x) ~= size(y)) 77 error('X and Y must be the same size or scalars.') 78 end 56 79 57 % Main Loop 58 % 59 for i=1:n1 60 if (utmzone(i,4)>'X' || utmzone(i,4)<'C') 61 fprintf('utm2ll: Warning utmzone should be a vector of strings like "30 T", not "30 t"\n'); 80 if ~isnumeric(f) || ~isscalar(f) || f ~= round(f) 81 error('ZONE must be a scalar integer.') 82 end 83 84 if nargin < 4 85 datum = 'wgs84'; 86 end 87 88 if ischar(datum) 89 if ~any(strcmpi(datum,datums(:,1))) 90 error('Unkown DATUM name "%s"',datum); 62 91 end 63 if (utmzone(i,4)>'M') 64 hemis='N'; % Northern hemisphere 65 else 66 hemis='S'; 92 k = find(strcmpi(datum,datums(:,1))); 93 A1 = datums{k,2}; 94 F1 = datums{k,3}; 95 else 96 if numel(datum) ~= 2 97 error('User defined DATUM must be a vector [A,F].'); 67 98 end 99 A1 = datum(1); 100 F1 = datum(2); 101 end 68 102 69 x=xx(i); 70 y=yy(i); 71 zone=str2double(utmzone(i,1:2)); 103 % constants 104 D0 = 180/pi; % conversion rad to deg 105 maxiter = 100; % maximum iteration for latitude computation 106 eps = 1e-11; % minimum residue for latitude computation 72 107 73 sa = 6378137.000000 ; sb = 6356752.314245; 108 K0 = 0.9996; % UTM scale factor 109 X0 = 500000; % UTM false East (m) 110 Y0 = 1e7*(f < 0); % UTM false North (m) 111 P0 = 0; % UTM origin latitude (rad) 112 L0 = (6*abs(f) - 183)/D0; % UTM origin longitude (rad) 113 E1 = sqrt((A1^2 - (A1*(1 - 1/F1))^2)/A1^2); % ellpsoid excentricity 114 N = K0*A1; 74 115 75 % e = ( ( ( sa ^ 2 ) - ( sb ^ 2 ) ) ^ 0.5 ) / sa; 76 e2 = ( ( ( sa ^ 2 ) - ( sb ^ 2 ) ) ^ 0.5 ) / sb; 77 e2cuadrada = e2 ^ 2; 78 c = ( sa ^ 2 ) / sb; 79 % alpha = ( sa - sb ) / sa; %f 80 % ablandamiento = 1 / alpha; % 1/f 116 % computing parameters for Mercator Transverse projection 117 C = coef(E1,0); 118 YS = Y0 - N*(C(1)*P0 + C(2)*sin(2*P0) + C(3)*sin(4*P0) + C(4)*sin(6*P0) + C(5)*sin(8*P0)); 81 119 82 X = x - 500000; 120 C = coef(E1,1); 121 zt = complex((y - YS)/N/C(1),(x - X0)/N/C(1)); 122 z = zt - C(2)*sin(2*zt) - C(3)*sin(4*zt) - C(4)*sin(6*zt) - C(5)*sin(8*zt); 123 L = real(z); 124 LS = imag(z); 83 125 84 if hemis == 'S' || hemis == 's' 85 Y = y - 10000000; 86 else 87 Y = y; 88 end 126 l = L0 + atan(sinh(LS)./cos(L)); 127 p = asin(sin(L)./cosh(LS)); 89 128 90 S = ( ( zone * 6 ) - 183 ); 91 lat = Y / ( 6366197.724 * 0.9996 ); 92 v = ( c / ( ( 1 + ( e2cuadrada * ( cos(lat) ) ^ 2 ) ) ) ^ 0.5 ) * 0.9996; 93 a = X / v; 94 a1 = sin( 2 * lat ); 95 a2 = a1 * ( cos(lat) ) ^ 2; 96 j2 = lat + ( a1 / 2 ); 97 j4 = ( ( 3 * j2 ) + a2 ) / 4; 98 j6 = ( ( 5 * j4 ) + ( a2 * ( cos(lat) ) ^ 2) ) / 3; 99 alfa = ( 3 / 4 ) * e2cuadrada; 100 beta = ( 5 / 3 ) * alfa ^ 2; 101 gama = ( 35 / 27 ) * alfa ^ 3; 102 Bm = 0.9996 * c * ( lat - alfa * j2 + beta * j4 - gama * j6 ); 103 b = ( Y - Bm ) / v; 104 Epsi = ( ( e2cuadrada * a^ 2 ) / 2 ) * ( cos(lat) )^ 2; 105 Eps = a * ( 1 - ( Epsi / 3 ) ); 106 nab = ( b * ( 1 - Epsi ) ) + lat; 107 senoheps = ( exp(Eps) - exp(-Eps) ) / 2; 108 Delt = atan(senoheps / (cos(nab) ) ); 109 TaO = atan(cos(Delt) * tan(nab)); 110 longitude = (Delt *(180 / pi ) ) + S; 111 latitude = ( lat + ( 1 + e2cuadrada* (cos(lat)^ 2) - ( 3 / 2 ) * e2cuadrada * sin(lat) * cos(lat) * ( TaO - lat ) ) * ( TaO - lat ) ) * ... 112 (180 / pi); 129 L = log(tan(pi/4 + p/2)); 113 130 114 Lat(i)=latitude; 115 Lon(i)=longitude; 131 % calculates latitude from the isometric latitude 132 p = 2*atan(exp(L)) - pi/2; 133 p0 = NaN; 134 n = 0; 135 while any(isnan(p0) | abs(p - p0) > eps) & n < maxiter 136 p0 = p; 137 es = E1*sin(p0); 138 p = 2*atan(((1 + es)./(1 - es)).^(E1/2).*exp(L)) - pi/2; 139 n = n + 1; 140 end 116 141 142 if nargout < 2 143 lat = D0*[p(:),l(:)]; 144 else 145 lat = p*D0; 146 lon = l*D0; 117 147 end 148 149 150 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 151 function c = coef(e,m) 152 %COEF Projection coefficients 153 % COEF(E,M) returns a vector of 5 coefficients from: 154 % E = first ellipsoid excentricity 155 % M = 0 for transverse mercator 156 % M = 1 for transverse mercator reverse coefficients 157 % M = 2 for merdian arc 158 159 160 if nargin < 2 161 m = 0; 162 end 163 164 switch m 165 case 0 166 c0 = [-175/16384, 0, -5/256, 0, -3/64, 0, -1/4, 0, 1; 167 -105/4096, 0, -45/1024, 0, -3/32, 0, -3/8, 0, 0; 168 525/16384, 0, 45/1024, 0, 15/256, 0, 0, 0, 0; 169 -175/12288, 0, -35/3072, 0, 0, 0, 0, 0, 0; 170 315/131072, 0, 0, 0, 0, 0, 0, 0, 0]; 171 172 case 1 173 c0 = [-175/16384, 0, -5/256, 0, -3/64, 0, -1/4, 0, 1; 174 1/61440, 0, 7/2048, 0, 1/48, 0, 1/8, 0, 0; 175 559/368640, 0, 3/1280, 0, 1/768, 0, 0, 0, 0; 176 283/430080, 0, 17/30720, 0, 0, 0, 0, 0, 0; 177 4397/41287680, 0, 0, 0, 0, 0, 0, 0, 0]; 178 179 case 2 180 c0 = [-175/16384, 0, -5/256, 0, -3/64, 0, -1/4, 0, 1; 181 -901/184320, 0, -9/1024, 0, -1/96, 0, 1/8, 0, 0; 182 -311/737280, 0, 17/5120, 0, 13/768, 0, 0, 0, 0; 183 899/430080, 0, 61/15360, 0, 0, 0, 0, 0, 0; 184 49561/41287680, 0, 0, 0, 0, 0, 0, 0, 0]; 185 186 end 187 c = zeros(size(c0,1),1); 188 189 for i = 1:size(c0,1) 190 c(i) = polyval(c0(i,:),e); 191 end -
issm/trunk/src/m/dev/issmversion.m
r17989 r19105 15 15 disp([' ']); 16 16 disp(['Build date: ' IssmConfig('PACKAGE_BUILD_DATE')]); 17 disp(['Copyright (c) 2009-2014 California Institute of Technology']); 17 disp(['Compiled on ' IssmConfig('HOST_VENDOR') ' ' IssmConfig('HOST_OS') ' ' IssmConfig('HOST_ARCH') ' by ' IssmConfig('USER_NAME')]); 18 disp([' ']); 19 disp(['Copyright (c) 2009-2015 California Institute of Technology']); 18 20 disp([' ']); 19 21 disp([' to get started type: issmdoc']); -
issm/trunk/src/m/enum/EnumDefinitions.py
r18301 r19105 50 50 def BaseEnum(): return StringToEnum("Base")[0] 51 51 def ConstantsGEnum(): return StringToEnum("ConstantsG")[0] 52 def ConstantsOmegaEnum(): return StringToEnum("ConstantsOmega")[0] 52 53 def ConstantsReferencetemperatureEnum(): return StringToEnum("ConstantsReferencetemperature")[0] 53 54 def ConstantsYtsEnum(): return StringToEnum("ConstantsYts")[0] … … 87 88 def FlowequationFeFSEnum(): return StringToEnum("FlowequationFeFS")[0] 88 89 def FlowequationVertexEquationEnum(): return StringToEnum("FlowequationVertexEquation")[0] 90 def FrictionAsEnum(): return StringToEnum("FrictionAs")[0] 89 91 def FrictionCoefficientEnum(): return StringToEnum("FrictionCoefficient")[0] 90 92 def FrictionPEnum(): return StringToEnum("FrictionP")[0] … … 93 95 def FrictionCEnum(): return StringToEnum("FrictionC")[0] 94 96 def FrictionLawEnum(): return StringToEnum("FrictionLaw")[0] 97 def FrictionGammaEnum(): return StringToEnum("FrictionGamma")[0] 98 def FrictionWaterLayerEnum(): return StringToEnum("FrictionWaterLayer")[0] 99 def FrictionEffectivePressureEnum(): return StringToEnum("FrictionEffectivePressure")[0] 95 100 def GeometryHydrostaticRatioEnum(): return StringToEnum("GeometryHydrostaticRatio")[0] 96 101 def HydrologyModelEnum(): return StringToEnum("HydrologyModel")[0] … … 107 112 def EplHeadSlopeXEnum(): return StringToEnum("EplHeadSlopeX")[0] 108 113 def EplHeadSlopeYEnum(): return StringToEnum("EplHeadSlopeY")[0] 114 def EplZigZagCounterEnum(): return StringToEnum("EplZigZagCounter")[0] 109 115 def HydrologydcMaxIterEnum(): return StringToEnum("HydrologydcMaxIter")[0] 110 116 def HydrologydcRelTolEnum(): return StringToEnum("HydrologydcRelTol")[0] … … 121 127 def HydrologydcEplPorosityEnum(): return StringToEnum("HydrologydcEplPorosity")[0] 122 128 def HydrologydcEplInitialThicknessEnum(): return StringToEnum("HydrologydcEplInitialThickness")[0] 129 def HydrologydcEplColapseThicknessEnum(): return StringToEnum("HydrologydcEplColapseThickness")[0] 123 130 def HydrologydcEplMaxThicknessEnum(): return StringToEnum("HydrologydcEplMaxThickness")[0] 124 131 def HydrologydcEplThicknessEnum(): return StringToEnum("HydrologydcEplThickness")[0] 125 132 def HydrologydcEplThicknessOldEnum(): return StringToEnum("HydrologydcEplThicknessOld")[0] 133 def HydrologydcEplThickCompEnum(): return StringToEnum("HydrologydcEplThickComp")[0] 126 134 def HydrologydcEplConductivityEnum(): return StringToEnum("HydrologydcEplConductivity")[0] 127 135 def HydrologydcIsefficientlayerEnum(): return StringToEnum("HydrologydcIsefficientlayer")[0] … … 132 140 def HydrologydcPenaltyFactorEnum(): return StringToEnum("HydrologydcPenaltyFactor")[0] 133 141 def HydrologydcPenaltyLockEnum(): return StringToEnum("HydrologydcPenaltyLock")[0] 142 def HydrologydcEplflipLockEnum(): return StringToEnum("HydrologydcEplflipLock")[0] 134 143 def HydrologydcBasalMoulinInputEnum(): return StringToEnum("HydrologydcBasalMoulinInput")[0] 135 144 def HydrologyLayerEnum(): return StringToEnum("HydrologyLayer")[0] … … 139 148 def IndependentObjectEnum(): return StringToEnum("IndependentObject")[0] 140 149 def InversionControlParametersEnum(): return StringToEnum("InversionControlParameters")[0] 150 def InversionControlScalingFactorsEnum(): return StringToEnum("InversionControlScalingFactors")[0] 141 151 def InversionCostFunctionThresholdEnum(): return StringToEnum("InversionCostFunctionThreshold")[0] 142 152 def InversionCostFunctionsCoefficientsEnum(): return StringToEnum("InversionCostFunctionsCoefficients")[0] … … 163 173 def InversionStepThresholdEnum(): return StringToEnum("InversionStepThreshold")[0] 164 174 def InversionThicknessObsEnum(): return StringToEnum("InversionThicknessObs")[0] 175 def InversionSurfaceObsEnum(): return StringToEnum("InversionSurfaceObs")[0] 165 176 def InversionVxObsEnum(): return StringToEnum("InversionVxObs")[0] 166 177 def InversionVyObsEnum(): return StringToEnum("InversionVyObs")[0] 167 178 def InversionVzObsEnum(): return StringToEnum("InversionVzObs")[0] 168 179 def MaskIceLevelsetEnum(): return StringToEnum("MaskIceLevelset")[0] 169 def QmuMaskIceLevelsetEnum(): return StringToEnum("QmuMaskIceLevelset")[0]170 180 def MaterialsBetaEnum(): return StringToEnum("MaterialsBeta")[0] 171 181 def MaterialsHeatcapacityEnum(): return StringToEnum("MaterialsHeatcapacity")[0] … … 180 190 def DamageDEnum(): return StringToEnum("DamageD")[0] 181 191 def DamageFEnum(): return StringToEnum("DamageF")[0] 182 def QmuDamageDEnum(): return StringToEnum("QmuDamageD")[0]183 192 def DamageDbarEnum(): return StringToEnum("DamageDbar")[0] 184 193 def DamageLawEnum(): return StringToEnum("DamageLaw")[0] … … 200 209 def DamageEvolutionNumRequestedOutputsEnum(): return StringToEnum("DamageEvolutionNumRequestedOutputs")[0] 201 210 def DamageEvolutionRequestedOutputsEnum(): return StringToEnum("DamageEvolutionRequestedOutputs")[0] 211 def DamageEnum(): return StringToEnum("Damage")[0] 202 212 def NewDamageEnum(): return StringToEnum("NewDamage")[0] 213 def StressIntensityFactorEnum(): return StringToEnum("StressIntensityFactor")[0] 214 def CalvingLawEnum(): return StringToEnum("CalvingLaw")[0] 215 def CalvingCalvingrateEnum(): return StringToEnum("CalvingCalvingrate")[0] 216 def CalvingMeltingrateEnum(): return StringToEnum("CalvingMeltingrate")[0] 217 def CalvingLevermannEnum(): return StringToEnum("CalvingLevermann")[0] 218 def CalvingPiEnum(): return StringToEnum("CalvingPi")[0] 219 def CalvingDevEnum(): return StringToEnum("CalvingDev")[0] 220 def DefaultCalvingEnum(): return StringToEnum("DefaultCalving")[0] 221 def CalvingRequestedOutputsEnum(): return StringToEnum("CalvingRequestedOutputs")[0] 222 def CalvinglevermannCoeffEnum(): return StringToEnum("CalvinglevermannCoeff")[0] 223 def CalvinglevermannMeltingrateEnum(): return StringToEnum("CalvinglevermannMeltingrate")[0] 224 def CalvingpiCoeffEnum(): return StringToEnum("CalvingpiCoeff")[0] 225 def CalvingpiMeltingrateEnum(): return StringToEnum("CalvingpiMeltingrate")[0] 226 def CalvingratexEnum(): return StringToEnum("Calvingratex")[0] 227 def CalvingrateyEnum(): return StringToEnum("Calvingratey")[0] 228 def CalvingratexAverageEnum(): return StringToEnum("CalvingratexAverage")[0] 229 def CalvingrateyAverageEnum(): return StringToEnum("CalvingrateyAverage")[0] 230 def StrainRateparallelEnum(): return StringToEnum("StrainRateparallel")[0] 231 def StrainRateperpendicularEnum(): return StringToEnum("StrainRateperpendicular")[0] 232 def StrainRateeffectiveEnum(): return StringToEnum("StrainRateeffective")[0] 203 233 def MaterialsRhoIceEnum(): return StringToEnum("MaterialsRhoIce")[0] 204 234 def MaterialsRhoSeawaterEnum(): return StringToEnum("MaterialsRhoSeawater")[0] … … 240 270 def MasstransportPenaltyFactorEnum(): return StringToEnum("MasstransportPenaltyFactor")[0] 241 271 def MasstransportSpcthicknessEnum(): return StringToEnum("MasstransportSpcthickness")[0] 242 def MasstransportCalvingrateEnum(): return StringToEnum("MasstransportCalvingrate")[0]243 272 def MasstransportStabilizationEnum(): return StringToEnum("MasstransportStabilization")[0] 244 273 def MasstransportVertexPairingEnum(): return StringToEnum("MasstransportVertexPairing")[0] … … 254 283 def QmuResponsedescriptorsEnum(): return StringToEnum("QmuResponsedescriptors")[0] 255 284 def QmuVariabledescriptorsEnum(): return StringToEnum("QmuVariabledescriptors")[0] 256 def QmuMaterialsRheologyBEnum(): return StringToEnum("QmuMaterialsRheologyB")[0]257 285 def RiftsNumriftsEnum(): return StringToEnum("RiftsNumrifts")[0] 258 286 def RiftsRiftstructEnum(): return StringToEnum("RiftsRiftstruct")[0] … … 274 302 def ThermalIsenthalpyEnum(): return StringToEnum("ThermalIsenthalpy")[0] 275 303 def ThermalIsdynamicbasalspcEnum(): return StringToEnum("ThermalIsdynamicbasalspc")[0] 304 def ThermalReltolEnum(): return StringToEnum("ThermalReltol")[0] 276 305 def ThermalMaxiterEnum(): return StringToEnum("ThermalMaxiter")[0] 277 306 def ThermalPenaltyFactorEnum(): return StringToEnum("ThermalPenaltyFactor")[0] … … 298 327 def TransientIsdamageevolutionEnum(): return StringToEnum("TransientIsdamageevolution")[0] 299 328 def TransientIshydrologyEnum(): return StringToEnum("TransientIshydrology")[0] 329 def TransientIscalvingEnum(): return StringToEnum("TransientIscalving")[0] 300 330 def TransientNumRequestedOutputsEnum(): return StringToEnum("TransientNumRequestedOutputs")[0] 301 331 def TransientRequestedOutputsEnum(): return StringToEnum("TransientRequestedOutputs")[0] … … 304 334 def BalancethicknessApparentMassbalanceEnum(): return StringToEnum("BalancethicknessApparentMassbalance")[0] 305 335 def Balancethickness2MisfitEnum(): return StringToEnum("Balancethickness2Misfit")[0] 306 def BalancethicknessNuxEnum(): return StringToEnum("BalancethicknessNux")[0] 307 def BalancethicknessNuyEnum(): return StringToEnum("BalancethicknessNuy")[0] 308 def BalancethicknessVxObsEnum(): return StringToEnum("BalancethicknessVxObs")[0] 309 def BalancethicknessVyObsEnum(): return StringToEnum("BalancethicknessVyObs")[0] 310 def BalancethicknessThicknessObsEnum(): return StringToEnum("BalancethicknessThicknessObs")[0] 336 def BalancethicknessDiffusionCoefficientEnum(): return StringToEnum("BalancethicknessDiffusionCoefficient")[0] 337 def BalancethicknessCmuEnum(): return StringToEnum("BalancethicknessCmu")[0] 338 def BalancethicknessOmegaEnum(): return StringToEnum("BalancethicknessOmega")[0] 339 def BalancethicknessD0Enum(): return StringToEnum("BalancethicknessD0")[0] 311 340 def SurfaceforcingsEnum(): return StringToEnum("Surfaceforcings")[0] 312 341 def SMBEnum(): return StringToEnum("SMB")[0] … … 316 345 def SurfaceforcingsDelta18oSurfaceEnum(): return StringToEnum("SurfaceforcingsDelta18oSurface")[0] 317 346 def SurfaceforcingsIsdelta18oEnum(): return StringToEnum("SurfaceforcingsIsdelta18o")[0] 347 def SurfaceforcingsIsmungsmEnum(): return StringToEnum("SurfaceforcingsIsmungsm")[0] 318 348 def SurfaceforcingsPrecipitationsPresentdayEnum(): return StringToEnum("SurfaceforcingsPrecipitationsPresentday")[0] 349 def SurfaceforcingsPrecipitationsLgmEnum(): return StringToEnum("SurfaceforcingsPrecipitationsLgm")[0] 319 350 def SurfaceforcingsTemperaturesPresentdayEnum(): return StringToEnum("SurfaceforcingsTemperaturesPresentday")[0] 320 351 def SurfaceforcingsTemperaturesLgmEnum(): return StringToEnum("SurfaceforcingsTemperaturesLgm")[0] … … 322 353 def SurfaceforcingsDesfacEnum(): return StringToEnum("SurfaceforcingsDesfac")[0] 323 354 def SurfaceforcingsS0pEnum(): return StringToEnum("SurfaceforcingsS0p")[0] 355 def SurfaceforcingsS0tEnum(): return StringToEnum("SurfaceforcingsS0t")[0] 356 def SurfaceforcingsRlapsEnum(): return StringToEnum("SurfaceforcingsRlaps")[0] 357 def SurfaceforcingsRlapslgmEnum(): return StringToEnum("SurfaceforcingsRlapslgm")[0] 358 def SurfaceforcingsPfacEnum(): return StringToEnum("SurfaceforcingsPfac")[0] 359 def SurfaceforcingsTdiffEnum(): return StringToEnum("SurfaceforcingsTdiff")[0] 360 def SurfaceforcingsSealevEnum(): return StringToEnum("SurfaceforcingsSealev")[0] 324 361 def SMBgradientsEnum(): return StringToEnum("SMBgradients")[0] 325 362 def SurfaceforcingsMonthlytemperaturesEnum(): return StringToEnum("SurfaceforcingsMonthlytemperatures")[0] … … 381 418 def SteadystateSolutionEnum(): return StringToEnum("SteadystateSolution")[0] 382 419 def SurfaceSlopeSolutionEnum(): return StringToEnum("SurfaceSlopeSolution")[0] 383 def SmoothedSurfaceSlopeXAnalysisEnum(): return StringToEnum("SmoothedSurfaceSlopeXAnalysis")[0] 384 def SmoothedSurfaceSlopeYAnalysisEnum(): return StringToEnum("SmoothedSurfaceSlopeYAnalysis")[0] 420 def SmoothAnalysisEnum(): return StringToEnum("SmoothAnalysis")[0] 385 421 def ThermalAnalysisEnum(): return StringToEnum("ThermalAnalysis")[0] 386 422 def ThermalSolutionEnum(): return StringToEnum("ThermalSolution")[0] … … 392 428 def MeshdeformationAnalysisEnum(): return StringToEnum("MeshdeformationAnalysis")[0] 393 429 def LevelsetAnalysisEnum(): return StringToEnum("LevelsetAnalysis")[0] 430 def LevelsetStabilizationEnum(): return StringToEnum("LevelsetStabilization")[0] 394 431 def ExtrapolationAnalysisEnum(): return StringToEnum("ExtrapolationAnalysis")[0] 395 432 def LsfReinitializationAnalysisEnum(): return StringToEnum("LsfReinitializationAnalysis")[0] … … 435 472 def InputToL2ProjectEnum(): return StringToEnum("InputToL2Project")[0] 436 473 def InputToDepthaverageEnum(): return StringToEnum("InputToDepthaverage")[0] 474 def InputToSmoothEnum(): return StringToEnum("InputToSmooth")[0] 475 def SmoothThicknessMultiplierEnum(): return StringToEnum("SmoothThicknessMultiplier")[0] 437 476 def IntParamEnum(): return StringToEnum("IntParam")[0] 438 477 def IntVecParamEnum(): return StringToEnum("IntVecParam")[0] … … 449 488 def ProfilerEnum(): return StringToEnum("Profiler")[0] 450 489 def MatrixParamEnum(): return StringToEnum("MatrixParam")[0] 490 def MassconEnum(): return StringToEnum("Masscon")[0] 491 def MassconNameEnum(): return StringToEnum("MassconName")[0] 492 def MassconDefinitionenumEnum(): return StringToEnum("MassconDefinitionenum")[0] 493 def MassconLevelsetEnum(): return StringToEnum("MassconLevelset")[0] 494 def MassconaxpbyEnum(): return StringToEnum("Massconaxpby")[0] 495 def MassconaxpbyNameEnum(): return StringToEnum("MassconaxpbyName")[0] 496 def MassconaxpbyDefinitionenumEnum(): return StringToEnum("MassconaxpbyDefinitionenum")[0] 497 def MassconaxpbyNamexEnum(): return StringToEnum("MassconaxpbyNamex")[0] 498 def MassconaxpbyNameyEnum(): return StringToEnum("MassconaxpbyNamey")[0] 499 def MassconaxpbyAlphaEnum(): return StringToEnum("MassconaxpbyAlpha")[0] 500 def MassconaxpbyBetaEnum(): return StringToEnum("MassconaxpbyBeta")[0] 451 501 def NodeSIdEnum(): return StringToEnum("NodeSId")[0] 452 502 def VectorParamEnum(): return StringToEnum("VectorParam")[0] … … 496 546 def PressureEnum(): return StringToEnum("Pressure")[0] 497 547 def PressurePicardEnum(): return StringToEnum("PressurePicard")[0] 498 def QmuPressureEnum(): return StringToEnum("QmuPressure")[0]499 def QmuVxEnum(): return StringToEnum("QmuVx")[0]500 def QmuVyEnum(): return StringToEnum("QmuVy")[0]501 def QmuVzEnum(): return StringToEnum("QmuVz")[0]502 def QmuThicknessEnum(): return StringToEnum("QmuThickness")[0]503 def QmuBaseEnum(): return StringToEnum("QmuBase")[0]504 def QmuSurfaceEnum(): return StringToEnum("QmuSurface")[0]505 def QmuMeltingEnum(): return StringToEnum("QmuMelting")[0]506 def QmuVxMeshEnum(): return StringToEnum("QmuVxMesh")[0]507 def QmuVyMeshEnum(): return StringToEnum("QmuVyMesh")[0]508 def QmuVzMeshEnum(): return StringToEnum("QmuVzMesh")[0]509 548 def AndroidFrictionCoefficientEnum(): return StringToEnum("AndroidFrictionCoefficient")[0] 510 549 def ResetPenaltiesEnum(): return StringToEnum("ResetPenalties")[0] … … 521 560 def TemperaturePicardEnum(): return StringToEnum("TemperaturePicard")[0] 522 561 def ThicknessAbsMisfitEnum(): return StringToEnum("ThicknessAbsMisfit")[0] 562 def SurfaceAbsMisfitEnum(): return StringToEnum("SurfaceAbsMisfit")[0] 523 563 def VelEnum(): return StringToEnum("Vel")[0] 524 564 def VelocityEnum(): return StringToEnum("Velocity")[0] … … 544 584 def IntMatParamEnum(): return StringToEnum("IntMatParam")[0] 545 585 def RheologyBbarAbsGradientEnum(): return StringToEnum("RheologyBbarAbsGradient")[0] 586 def RheologyBAbsGradientEnum(): return StringToEnum("RheologyBAbsGradient")[0] 546 587 def DragCoefficientAbsGradientEnum(): return StringToEnum("DragCoefficientAbsGradient")[0] 547 588 def TransientInputEnum(): return StringToEnum("TransientInput")[0] … … 550 591 def BasalFrictionEnum(): return StringToEnum("BasalFriction")[0] 551 592 def ViscousHeatingEnum(): return StringToEnum("ViscousHeating")[0] 552 def QmuTemperatureEnum(): return StringToEnum("QmuTemperature")[0]553 593 def HydrologyWaterVxEnum(): return StringToEnum("HydrologyWaterVx")[0] 554 594 def HydrologyWaterVyEnum(): return StringToEnum("HydrologyWaterVy")[0] 595 def DrivingStressXEnum(): return StringToEnum("DrivingStressX")[0] 596 def DrivingStressYEnum(): return StringToEnum("DrivingStressY")[0] 555 597 def SigmaNNEnum(): return StringToEnum("SigmaNN")[0] 556 598 def StressTensorEnum(): return StringToEnum("StressTensor")[0] … … 561 603 def StressTensoryzEnum(): return StringToEnum("StressTensoryz")[0] 562 604 def StressTensorzzEnum(): return StringToEnum("StressTensorzz")[0] 605 def StressMaxPrincipalEnum(): return StringToEnum("StressMaxPrincipal")[0] 563 606 def DeviatoricStressEnum(): return StringToEnum("DeviatoricStress")[0] 564 607 def DeviatoricStressxxEnum(): return StringToEnum("DeviatoricStressxx")[0] … … 576 619 def StrainRatezzEnum(): return StringToEnum("StrainRatezz")[0] 577 620 def DivergenceEnum(): return StringToEnum("Divergence")[0] 621 def MaxDivergenceEnum(): return StringToEnum("MaxDivergence")[0] 578 622 def GiaCrossSectionShapeEnum(): return StringToEnum("GiaCrossSectionShape")[0] 579 623 def GiadWdtEnum(): return StringToEnum("GiadWdt")[0] … … 600 644 def OneLayerP4zEnum(): return StringToEnum("OneLayerP4z")[0] 601 645 def CrouzeixRaviartEnum(): return StringToEnum("CrouzeixRaviart")[0] 646 def LACrouzeixRaviartEnum(): return StringToEnum("LACrouzeixRaviart")[0] 602 647 def SaveResultsEnum(): return StringToEnum("SaveResults")[0] 603 648 def BoolExternalResultEnum(): return StringToEnum("BoolExternalResult")[0] … … 611 656 def WaterColumnOldEnum(): return StringToEnum("WaterColumnOld")[0] 612 657 def OutputdefinitionEnum(): return StringToEnum("Outputdefinition")[0] 658 def Outputdefinition1Enum(): return StringToEnum("Outputdefinition1")[0] 659 def Outputdefinition2Enum(): return StringToEnum("Outputdefinition2")[0] 660 def Outputdefinition3Enum(): return StringToEnum("Outputdefinition3")[0] 661 def Outputdefinition4Enum(): return StringToEnum("Outputdefinition4")[0] 662 def Outputdefinition5Enum(): return StringToEnum("Outputdefinition5")[0] 663 def Outputdefinition6Enum(): return StringToEnum("Outputdefinition6")[0] 664 def Outputdefinition7Enum(): return StringToEnum("Outputdefinition7")[0] 665 def Outputdefinition8Enum(): return StringToEnum("Outputdefinition8")[0] 666 def Outputdefinition9Enum(): return StringToEnum("Outputdefinition9")[0] 667 def Outputdefinition10Enum(): return StringToEnum("Outputdefinition10")[0] 668 def Outputdefinition11Enum(): return StringToEnum("Outputdefinition11")[0] 669 def Outputdefinition12Enum(): return StringToEnum("Outputdefinition12")[0] 670 def Outputdefinition13Enum(): return StringToEnum("Outputdefinition13")[0] 671 def Outputdefinition14Enum(): return StringToEnum("Outputdefinition14")[0] 672 def Outputdefinition15Enum(): return StringToEnum("Outputdefinition15")[0] 673 def Outputdefinition16Enum(): return StringToEnum("Outputdefinition16")[0] 674 def Outputdefinition17Enum(): return StringToEnum("Outputdefinition17")[0] 675 def Outputdefinition18Enum(): return StringToEnum("Outputdefinition18")[0] 676 def Outputdefinition19Enum(): return StringToEnum("Outputdefinition19")[0] 677 def Outputdefinition20Enum(): return StringToEnum("Outputdefinition20")[0] 678 def Outputdefinition21Enum(): return StringToEnum("Outputdefinition21")[0] 679 def Outputdefinition22Enum(): return StringToEnum("Outputdefinition22")[0] 680 def Outputdefinition23Enum(): return StringToEnum("Outputdefinition23")[0] 681 def Outputdefinition24Enum(): return StringToEnum("Outputdefinition24")[0] 682 def Outputdefinition25Enum(): return StringToEnum("Outputdefinition25")[0] 683 def Outputdefinition26Enum(): return StringToEnum("Outputdefinition26")[0] 684 def Outputdefinition27Enum(): return StringToEnum("Outputdefinition27")[0] 685 def Outputdefinition28Enum(): return StringToEnum("Outputdefinition28")[0] 686 def Outputdefinition29Enum(): return StringToEnum("Outputdefinition29")[0] 687 def Outputdefinition30Enum(): return StringToEnum("Outputdefinition30")[0] 688 def Outputdefinition31Enum(): return StringToEnum("Outputdefinition31")[0] 689 def Outputdefinition32Enum(): return StringToEnum("Outputdefinition32")[0] 690 def Outputdefinition33Enum(): return StringToEnum("Outputdefinition33")[0] 691 def Outputdefinition34Enum(): return StringToEnum("Outputdefinition34")[0] 692 def Outputdefinition35Enum(): return StringToEnum("Outputdefinition35")[0] 693 def Outputdefinition36Enum(): return StringToEnum("Outputdefinition36")[0] 694 def Outputdefinition37Enum(): return StringToEnum("Outputdefinition37")[0] 695 def Outputdefinition38Enum(): return StringToEnum("Outputdefinition38")[0] 696 def Outputdefinition39Enum(): return StringToEnum("Outputdefinition39")[0] 697 def Outputdefinition40Enum(): return StringToEnum("Outputdefinition40")[0] 698 def Outputdefinition41Enum(): return StringToEnum("Outputdefinition41")[0] 699 def Outputdefinition42Enum(): return StringToEnum("Outputdefinition42")[0] 700 def Outputdefinition43Enum(): return StringToEnum("Outputdefinition43")[0] 701 def Outputdefinition44Enum(): return StringToEnum("Outputdefinition44")[0] 702 def Outputdefinition45Enum(): return StringToEnum("Outputdefinition45")[0] 703 def Outputdefinition46Enum(): return StringToEnum("Outputdefinition46")[0] 704 def Outputdefinition47Enum(): return StringToEnum("Outputdefinition47")[0] 705 def Outputdefinition48Enum(): return StringToEnum("Outputdefinition48")[0] 706 def Outputdefinition49Enum(): return StringToEnum("Outputdefinition49")[0] 707 def Outputdefinition50Enum(): return StringToEnum("Outputdefinition50")[0] 708 def Outputdefinition51Enum(): return StringToEnum("Outputdefinition51")[0] 709 def Outputdefinition52Enum(): return StringToEnum("Outputdefinition52")[0] 710 def Outputdefinition53Enum(): return StringToEnum("Outputdefinition53")[0] 711 def Outputdefinition54Enum(): return StringToEnum("Outputdefinition54")[0] 712 def Outputdefinition55Enum(): return StringToEnum("Outputdefinition55")[0] 713 def Outputdefinition56Enum(): return StringToEnum("Outputdefinition56")[0] 714 def Outputdefinition57Enum(): return StringToEnum("Outputdefinition57")[0] 715 def Outputdefinition58Enum(): return StringToEnum("Outputdefinition58")[0] 716 def Outputdefinition59Enum(): return StringToEnum("Outputdefinition59")[0] 717 def Outputdefinition60Enum(): return StringToEnum("Outputdefinition60")[0] 718 def Outputdefinition61Enum(): return StringToEnum("Outputdefinition61")[0] 719 def Outputdefinition62Enum(): return StringToEnum("Outputdefinition62")[0] 720 def Outputdefinition63Enum(): return StringToEnum("Outputdefinition63")[0] 721 def Outputdefinition64Enum(): return StringToEnum("Outputdefinition64")[0] 722 def Outputdefinition65Enum(): return StringToEnum("Outputdefinition65")[0] 723 def Outputdefinition66Enum(): return StringToEnum("Outputdefinition66")[0] 724 def Outputdefinition67Enum(): return StringToEnum("Outputdefinition67")[0] 725 def Outputdefinition68Enum(): return StringToEnum("Outputdefinition68")[0] 726 def Outputdefinition69Enum(): return StringToEnum("Outputdefinition69")[0] 727 def Outputdefinition70Enum(): return StringToEnum("Outputdefinition70")[0] 728 def Outputdefinition71Enum(): return StringToEnum("Outputdefinition71")[0] 729 def Outputdefinition72Enum(): return StringToEnum("Outputdefinition72")[0] 730 def Outputdefinition73Enum(): return StringToEnum("Outputdefinition73")[0] 731 def Outputdefinition74Enum(): return StringToEnum("Outputdefinition74")[0] 732 def Outputdefinition75Enum(): return StringToEnum("Outputdefinition75")[0] 733 def Outputdefinition76Enum(): return StringToEnum("Outputdefinition76")[0] 734 def Outputdefinition77Enum(): return StringToEnum("Outputdefinition77")[0] 735 def Outputdefinition78Enum(): return StringToEnum("Outputdefinition78")[0] 736 def Outputdefinition79Enum(): return StringToEnum("Outputdefinition79")[0] 737 def Outputdefinition80Enum(): return StringToEnum("Outputdefinition80")[0] 738 def Outputdefinition81Enum(): return StringToEnum("Outputdefinition81")[0] 739 def Outputdefinition82Enum(): return StringToEnum("Outputdefinition82")[0] 740 def Outputdefinition83Enum(): return StringToEnum("Outputdefinition83")[0] 741 def Outputdefinition84Enum(): return StringToEnum("Outputdefinition84")[0] 742 def Outputdefinition85Enum(): return StringToEnum("Outputdefinition85")[0] 743 def Outputdefinition86Enum(): return StringToEnum("Outputdefinition86")[0] 744 def Outputdefinition87Enum(): return StringToEnum("Outputdefinition87")[0] 745 def Outputdefinition88Enum(): return StringToEnum("Outputdefinition88")[0] 746 def Outputdefinition89Enum(): return StringToEnum("Outputdefinition89")[0] 747 def Outputdefinition90Enum(): return StringToEnum("Outputdefinition90")[0] 748 def Outputdefinition91Enum(): return StringToEnum("Outputdefinition91")[0] 749 def Outputdefinition92Enum(): return StringToEnum("Outputdefinition92")[0] 750 def Outputdefinition93Enum(): return StringToEnum("Outputdefinition93")[0] 751 def Outputdefinition94Enum(): return StringToEnum("Outputdefinition94")[0] 752 def Outputdefinition95Enum(): return StringToEnum("Outputdefinition95")[0] 753 def Outputdefinition96Enum(): return StringToEnum("Outputdefinition96")[0] 754 def Outputdefinition97Enum(): return StringToEnum("Outputdefinition97")[0] 755 def Outputdefinition98Enum(): return StringToEnum("Outputdefinition98")[0] 756 def Outputdefinition99Enum(): return StringToEnum("Outputdefinition99")[0] 757 def Outputdefinition100Enum(): return StringToEnum("Outputdefinition100")[0] 613 758 def OutputdefinitionListEnum(): return StringToEnum("OutputdefinitionList")[0] 614 759 def MassfluxatgateEnum(): return StringToEnum("Massfluxatgate")[0] 615 760 def MassfluxatgateNameEnum(): return StringToEnum("MassfluxatgateName")[0] 761 def MassfluxatgateDefinitionenumEnum(): return StringToEnum("MassfluxatgateDefinitionenum")[0] 616 762 def MassfluxatgateSegmentsEnum(): return StringToEnum("MassfluxatgateSegments")[0] 617 763 def MisfitNameEnum(): return StringToEnum("MisfitName")[0] 764 def MisfitDefinitionenumEnum(): return StringToEnum("MisfitDefinitionenum")[0] 618 765 def MisfitModelEnumEnum(): return StringToEnum("MisfitModelEnum")[0] 619 766 def MisfitObservationEnum(): return StringToEnum("MisfitObservation")[0] 620 767 def MisfitObservationEnumEnum(): return StringToEnum("MisfitObservationEnum")[0] 768 def MisfitLocalEnum(): return StringToEnum("MisfitLocal")[0] 621 769 def MisfitTimeinterpolationEnum(): return StringToEnum("MisfitTimeinterpolation")[0] 622 770 def MisfitWeightsEnum(): return StringToEnum("MisfitWeights")[0] … … 624 772 def SurfaceObservationEnum(): return StringToEnum("SurfaceObservation")[0] 625 773 def WeightsSurfaceObservationEnum(): return StringToEnum("WeightsSurfaceObservation")[0] 774 def VxObsEnum(): return StringToEnum("VxObs")[0] 775 def WeightsVxObsEnum(): return StringToEnum("WeightsVxObs")[0] 776 def VyObsEnum(): return StringToEnum("VyObs")[0] 777 def WeightsVyObsEnum(): return StringToEnum("WeightsVyObs")[0] 626 778 def MinVelEnum(): return StringToEnum("MinVel")[0] 627 779 def MaxVelEnum(): return StringToEnum("MaxVel")[0] … … 635 787 def MaxVzEnum(): return StringToEnum("MaxVz")[0] 636 788 def MaxAbsVzEnum(): return StringToEnum("MaxAbsVz")[0] 789 def IceMassEnum(): return StringToEnum("IceMass")[0] 637 790 def IceVolumeEnum(): return StringToEnum("IceVolume")[0] 638 791 def IceVolumeAboveFloatationEnum(): return StringToEnum("IceVolumeAboveFloatation")[0] … … 651 804 def SubelementMigration2Enum(): return StringToEnum("SubelementMigration2")[0] 652 805 def ContactEnum(): return StringToEnum("Contact")[0] 806 def GroundingOnlyEnum(): return StringToEnum("GroundingOnly")[0] 653 807 def MaskGroundediceLevelsetEnum(): return StringToEnum("MaskGroundediceLevelset")[0] 654 def QmuMaskGroundediceLevelsetEnum(): return StringToEnum("QmuMaskGroundediceLevelset")[0]655 808 def GaussSegEnum(): return StringToEnum("GaussSeg")[0] 656 809 def GaussTriaEnum(): return StringToEnum("GaussTria")[0] … … 674 827 def OldGradientEnum(): return StringToEnum("OldGradient")[0] 675 828 def OutputFilePointerEnum(): return StringToEnum("OutputFilePointer")[0] 829 def ToolkitsFileNameEnum(): return StringToEnum("ToolkitsFileName")[0] 830 def RootPathEnum(): return StringToEnum("RootPath")[0] 676 831 def OutputFileNameEnum(): return StringToEnum("OutputFileName")[0] 832 def InputFileNameEnum(): return StringToEnum("InputFileName")[0] 677 833 def LockFileNameEnum(): return StringToEnum("LockFileName")[0] 678 834 def ToolkitsOptionsAnalysesEnum(): return StringToEnum("ToolkitsOptionsAnalyses")[0] -
issm/trunk/src/m/exp/expdisp.m
r17806 r19105 5 5 % 6 6 % Usage: 7 % expdisp(domainoutline,varargin) 8 % expdisp(domainoutline,figurenumber,linestyle,linewidth,unitmultiplier) 7 % expdisp(domainoutline,options) 8 % 9 % Available options: 10 % - 'figure' : figure number or handle 11 % - 'linestyle' : line style ('r--','-y',...) 12 % - 'linewidth' : line width (1,2,...) 13 % - 'multiplier' : coordinate multiplier (10^3 if the plot is in km) 14 % - 'title' : do we add contour names to each contour 15 % - 'patch' : do we want the contour to be filled 9 16 % 10 17 % Example: 11 % expdisp('Domain.exp', 1,'--r',2,10^3);18 % expdisp('Domain.exp','figure',1,'linestyle','--r','linewidth',2,'multiplier',10^3); 12 19 % 13 20 % See also EXPMASTER, EXPDOC 14 21 15 %check nargin 16 if ~nargin | nargin>5 17 help expdisp 18 error('expdisp error message: bad usage'); 19 end 22 %Get and process options 23 options = pairoptions(varargin{:}); 24 unitmultiplier = getfieldvalue(options,'multiplier',1); 25 linewidth = getfieldvalue(options,'linewidth',1); 26 linestyle = getfieldvalue(options,'linestyle','-r'); 27 ispatch = getfieldvalue(options,'patch',0); 20 28 21 %parse input 22 if nargin<=1, 23 figurenumber=1; 24 else 25 figurenumber=varargin{1}; 26 end 27 if nargin<=2 28 linestyle='r-'; 29 else 30 linestyle=varargin{2}; 31 end 32 if nargin<=3 33 linewidth=1; 34 else 35 linewidth=varargin{3}; 36 end 37 if nargin<=4 38 unitmultiplier=1; 39 else 40 unitmultiplier=varargin{4}; if isnan(unitmultiplier), unitmultiplier=1; end 41 end 42 29 %read file 43 30 domain=expread(domainoutline); 44 31 45 figure(figurenumber),hold on 32 %Create figure if needed and hold 33 if exist(options,'figure'), 34 figure(getfieldvalue(options,'figure')); 35 end 36 hold on 37 46 38 for i=1:length(domain), 47 39 if domain(i).nods==1 48 40 plot(domain(i).x*unitmultiplier,domain(i).y*unitmultiplier,'o','MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',10); 41 if exist(options,'title') 42 text(domain(i).x*unitmultiplier,domain(i).y*unitmultiplier,domain(i).name,'BackgroundColor',[1. .0 .0]); 43 end 49 44 else 50 if (isnumeric(linestyle))51 p lot(domain(i).x*unitmultiplier,domain(i).y*unitmultiplier,'Color',linestyle,'linewidth',linewidth);45 if ispatch, 46 patch(domain(i).x*unitmultiplier,domain(i).y*unitmultiplier,linestyle); 52 47 else 53 plot(domain(i).x*unitmultiplier,domain(i).y*unitmultiplier,linestyle,'linewidth',linewidth); 54 end 55 end 48 if (isnumeric(linestyle)) 49 plot(domain(i).x*unitmultiplier,domain(i).y*unitmultiplier,'Color',linestyle,'linewidth',linewidth); 50 else 51 plot(domain(i).x*unitmultiplier,domain(i).y*unitmultiplier,linestyle,'linewidth',linewidth); 52 end 53 end 54 if exist(options,'title') 55 text(domain(i).x(1)*unitmultiplier,domain(i).y(1)*unitmultiplier,domain(i).name,'BackgroundColor',[.7 .9 .7]); 56 end 57 end 56 58 end 57 -
issm/trunk/src/m/exp/masktoexp.m
r15396 r19105 24 24 %Create exp structure 25 25 A=struct(); 26 if(j-1<1), error('no contour found'); end 26 27 for i=1:j-1, 27 28 A(i).x=s(i).x; -
issm/trunk/src/m/mesh/bamg.m
r17806 r19105 349 349 %Now, build the connectivity tables for this mesh. 350 350 md.mesh.vertexonboundary=zeros(md.mesh.numberofvertices,1); md.mesh.vertexonboundary(md.mesh.segments(:,1:2))=1; 351 else 351 352 elseif getfieldvalue(options,'3dsurface',0), 353 354 md.mesh=mesh3dsurface(); 355 md.mesh.x=bamgmesh_out.Vertices(:,1); 356 md.mesh.y=bamgmesh_out.Vertices(:,2); 357 md.mesh.z=md.mesh.x; md.mesh.z(:)=0; 358 md.mesh.elements=bamgmesh_out.Triangles(:,1:3); 359 md.mesh.edges=bamgmesh_out.IssmEdges; 360 md.mesh.segments=bamgmesh_out.IssmSegments(:,1:3); 361 md.mesh.segmentmarkers=bamgmesh_out.IssmSegments(:,4); 362 363 %Fill in rest of fields: 364 md.mesh.numberofelements=size(md.mesh.elements,1); 365 md.mesh.numberofvertices=length(md.mesh.x); 366 md.mesh.numberofedges=size(md.mesh.edges,1); 367 md.mesh.vertexonboundary=zeros(md.mesh.numberofvertices,1); md.mesh.vertexonboundary(md.mesh.segments(:,1:2))=1; 368 369 else 352 370 md.mesh=mesh2d(); 353 371 md.mesh.x=bamgmesh_out.Vertices(:,1); -
issm/trunk/src/m/miscellaneous/vorticity.m
r17806 r19105 29 29 rot=dvxdy - dvydx; 30 30 31 if strcmpi( meshtype(md.mesh),'3D'),31 if strcmpi(domaintype(md.mesh),'3D'), 32 32 rot=project3d(md,'vector',rot,'type','element'); 33 33 end -
issm/trunk/src/m/plot/applyoptions.m
r17806 r19105 6 6 % 7 7 % See also: PLOTMODEL, PARSE_OPTIONS 8 9 %some defaults10 if isfield(md.mesh,'hemisphere'),11 if strcmpi(md.mesh.hemisphere,'n'), options=addfielddefault(options,'hemisphere','n');12 elseif strcmpi(md.mesh.hemisphere,'s'), options=addfielddefault(options,'hemisphere','s');13 end14 end15 8 16 9 %fontsize … … 68 61 elseif strcmp(domaintype(md.mesh),'2Dvertical'), 69 62 axis auto tight 63 elseif strcmp(domaintype(md.mesh),'3Dsurface'), 64 axis auto tight 65 70 66 elseif strcmp(domaintype(md.mesh),'2Dhorizontal'), 71 67 axis tight equal; … … 261 257 linewidthi=linewidth{i}; 262 258 end 263 expdisp(filenamei, gcf,stylei,linewidthi,getfieldvalue(options,'unit',1));259 expdisp(filenamei,'linestyle',stylei,'linewidthi',linewidthi,'multiplier',getfieldvalue(options,'unit',1)); 264 260 end 265 261 end … … 365 361 axis equal off 366 362 %box off 367 if strcmpi(md.mesh.hemisphere,'n') | strcmpi(md.mesh.hemisphere,'north'),363 if md.mesh.epsg==3413, 368 364 A=expread('/u/astrid-r1b/ModelData/Exp/GreenlandBoxFront.exp'); 369 365 [A.x A.y]=ll2xy(A.x,A.y,+1,45,70); 370 366 A.x = A.x(1:30:end); 371 367 A.y = A.y(1:30:end); 372 elseif strcmpi(md.mesh.hemisphere,'s') | strcmpi(md.mesh.hemisphere,'south'),368 elseif md.mesh.epsg==3031, 373 369 A=expread('/u/astrid-r1b/ModelData/Exp/Antarctica.exp'); 374 370 else 375 error('applyoptions error message: hemispherenot defined');371 error('applyoptions error message: md.mesh.epsg not defined'); 376 372 end 377 373 offset=3*10^4; … … 434 430 end 435 431 hold on,p=plot(x,y,'k.'); 436 markersize=getfieldvalue(options,'markersize', 5);432 markersize=getfieldvalue(options,'markersize',12); 437 433 color=getfieldvalue(options,'cloudcolor','k'); 438 434 set(p,'Color',color); -
issm/trunk/src/m/plot/applyoptions.py
r18301 r19105 24 24 See also: PLOTMODEL, PARSE_OPTIONS 25 25 ''' 26 27 #some defaults (this seems to be adding a field that already exists...)28 #if not isnan(md.mesh.hemisphere):29 # options.addfielddefault('hemisphere',md.mesh.hemisphere)30 26 31 27 # get handle to current figure and axes instance -
issm/trunk/src/m/plot/checkplotoptions.py
r18301 r19105 115 115 116 116 #expdisp 117 expdispvaluesarray=[ 0,0]118 expstylevaluesarray=[ 0,0]119 expstylevalues=[ 0,0]117 expdispvaluesarray=[] 118 expstylevaluesarray=[] 119 expstylevalues=[] 120 120 if options.exist('expstyle'): 121 expstylevalues=options.getfieldvalue('expstyle') 121 expstylevalues=options.getfieldvalue('expstyle') 122 if type(expstylevalues)==str: 123 expstylevalues=[expstylevalues] 122 124 if options.exist('expdisp'): 123 125 expdispvalues=options.getfieldvalue('expdisp') 126 if type(expdispvalues)==str: 127 expdispvalues=[expdispvalues] 124 128 for i in npy.arange(len(expdispvalues)): 125 129 expdispvaluesarray.append(expdispvalues[i]) 126 if len(expstylevalues)>i +1:130 if len(expstylevalues)>i: 127 131 expstylevaluesarray.append(expstylevalues[i]) 128 132 else: … … 154 158 #log scale 155 159 if options.exist('log'): 156 if options.exist('c axis'):157 options.changefieldvalue('c axis',log(options.getfieldvalue('caxis'))/log(options.getfieldvalue('log')))160 if options.exist('clim'): 161 options.changefieldvalue('clim',log(options.getfieldvalue('clim'))/log(options.getfieldvalue('log'))) 158 162 options.changefieldvalue('cutoff',log(options.getfieldvalue('cutoff',1.5))/log(options.getfieldvalue('log'))) 159 163 -
issm/trunk/src/m/plot/googlemaps.m
r15396 r19105 22 22 end 23 23 end 24 25 if md.mesh.epsg==0, 26 error('md.mesh.epsg not defined'); 27 end 24 28 if nargin==1, 25 29 %Get xlim and ylim (used to extract Google maps image) 26 30 xlim=getfieldvalue(options,'xlim',[min(md.mesh.x) max(md.mesh.x)]); 27 31 ylim=getfieldvalue(options,'ylim',[min(md.mesh.y) max(md.mesh.y)]); 28 if strcmpi(md.mesh.hemisphere,'n'),32 if md.mesh.epsg==3413, 29 33 [latlist lonlist]= xy2ll(... 30 34 [linspace(xlim(1),xlim(2),100) linspace(xlim(2),xlim(2),100) linspace(xlim(2),xlim(1),100) linspace(xlim(1),xlim(1),100)],... 31 35 [linspace(ylim(1),ylim(1),100) linspace(ylim(1),ylim(2),100) linspace(ylim(2),ylim(2),100) linspace(ylim(2),ylim(1),100)],... 32 36 +1,45,70); 33 elseif strcmpi(md.mesh.hemisphere,'s'),37 elseif md.mesh.epsg==3031, 34 38 [latlist lonlist]= xy2ll(... 35 39 [linspace(xlim(1),xlim(2),100) linspace(xlim(2),xlim(2),100) linspace(xlim(2),xlim(1),100) linspace(xlim(1),xlim(1),100)],... … … 37 41 -1,0,71); 38 42 else 39 error(' field hemisphere should either be ''n'' or ''s''');43 error('EPSG code not supported yet'); 40 44 end 41 45 … … 50 54 %Get region specific projection parameters 51 55 EPSGgoogle = 'EPSG:3785'; % Mercator http://www.spatialreference.org/ref/epsg/3785/ 52 if strcmpi(md.mesh.hemisphere,'n'), 53 EPSGlocal = 'EPSG:3413'; % UPS Greenland http://www.spatialreference.org/ref/epsg/3413/ 54 elseif strcmpi(md.mesh.hemisphere,'s'), 55 EPSGlocal = 'EPSG:3031'; % UPS Antarctica http://www.spatialreference.org/ref/epsg/3031/ 56 else 57 error('field hemisphere should either be ''n'' or ''s'''); 58 end 56 EPSGlocal = ['EPSG:' num2str(md.mesh.epsg)]; 59 57 60 58 %Find optimal zoom … … 130 128 [gX gY]=meshgrid(ulx:ulx+size(final,2)-1,uly:-1:uly-size(final,1)+1); 131 129 [LAT LON]=pixelstolatlon(gX,gY, zoom); 132 if strcmpi(md.mesh.hemisphere,'n'),130 if md.mesh.epsg==3413, 133 131 [X Y]=ll2xy(LAT,LON,+1,45,70); 134 elseif strcmpi(md.mesh.hemisphere,'s'),132 elseif md.mesh.epsg==3031, 135 133 [X Y]=ll2xy(LAT,LON,-1,0,71); 136 134 else 137 error(' field hemisphere should either be ''n'' or ''s''');135 error('EPSG code not supported yet'); 138 136 end 139 137 md.radaroverlay.pwr=final; … … 153 151 [gX gY]=meshgrid(ulx:ulx+size(final,2)-1,uly:-1:uly-size(final,1)+1); 154 152 [LAT LON]=pixelstolatlon(gX,gY, zoom); 155 if strcmpi(md.mesh.hemisphere,'n'),153 if md.mesh.epsg==3413, 156 154 [X Y]=ll2xy(LAT,LON,+1,45,70); 157 elseif strcmpi(md.mesh.hemisphere,'s'),155 elseif md.mesh.epsg==3031, 158 156 [X Y]=ll2xy(LAT,LON,-1,0,71); 159 157 else 160 error(' field hemisphere should either be ''n'' or ''s''');158 error('EPSG code not supported yet'); 161 159 end 162 160 md.radaroverlay.pwr=final; -
issm/trunk/src/m/plot/latlonoverlay.m
r14310 r19105 66 66 latitudes =lat*ones(size(longitudes)); 67 67 68 if strcmpi(md.mesh.hemisphere,'n'),68 if md.mesh.epsg==3413, 69 69 if lat<0, continue; end 70 70 [x,y]=ll2xy(latitudes,longitudes,+1,45,70); 71 elseif strcmpi(md.mesh.hemisphere,'s'),71 elseif md.mesh.epsg==3031, 72 72 if lat>0, continue; end 73 73 [x,y]=ll2xy(latitudes,longitudes,-1, 0,71); 74 else error('field hemisphere should either be ''n'' or ''s'''); end74 else error('field md.mesh.epsg not supported yet'); end 75 75 76 76 pos=find(x<=xlimits(2) & x>=xlimits(1) & y<=ylimits(2) & y>=ylimits(1)); … … 105 105 for lon=-180:lonstep:180 106 106 107 if strcmpi(md.mesh.hemisphere,'n'),107 if md.mesh.epsg==3413, 108 108 latitudes =0:resolution:90; 109 109 longitudes=lon*ones(size(latitudes)); 110 110 [x,y]=ll2xy(latitudes,longitudes,+1,45,70); 111 elseif strcmpi(md.mesh.hemisphere,'s'),111 elseif md.mesh.epsg==3031, 112 112 latitudes =-90:resolution:0; 113 113 longitudes=lon*ones(size(latitudes)); 114 114 [x,y]=ll2xy(latitudes,longitudes,-1, 0,71); 115 115 else 116 error('field hemisphere should either be ''n'' or ''s''');116 error('field md.mesh.epsg not supported yet'); 117 117 end 118 118 -
issm/trunk/src/m/plot/manualcb.m
r16137 r19105 102 102 103 103 if exist(options,'title'), 104 title(getfieldvalue(options,'title'),'FontSize', fontsize);104 title(getfieldvalue(options,'title'),'FontSize',getfieldvalue(options,'titlefontsize',fontsize)); 105 105 end 106 106 if exist(options,'ylabel'), -
issm/trunk/src/m/plot/plot_googlemaps.m
r15396 r19105 25 25 xlim=getfieldvalue(options,'xlim',[min(x) max(x)]); 26 26 ylim=getfieldvalue(options,'ylim',[min(y) max(y)]); 27 if strcmpi(md.mesh.hemisphere,'n'),27 if md.mesh.epsg==3413, 28 28 [latlist lonlist]= xy2ll(... 29 29 [linspace(xlim(1),xlim(2),100) linspace(xlim(2),xlim(2),100) linspace(xlim(2),xlim(1),100) linspace(xlim(1),xlim(1),100)],... 30 30 [linspace(ylim(1),ylim(1),100) linspace(ylim(1),ylim(2),100) linspace(ylim(2),ylim(2),100) linspace(ylim(2),ylim(1),100)],... 31 31 +1,45,70); 32 elseif strcmpi(md.mesh.hemisphere,'s'),32 elseif md.mesh.epsg==3031, 33 33 [latlist lonlist]= xy2ll(... 34 34 [linspace(xlim(1),xlim(2),100) linspace(xlim(2),xlim(2),100) linspace(xlim(2),xlim(1),100) linspace(xlim(1),xlim(1),100)],... … … 36 36 -1,0,71); 37 37 else 38 error('field hemisphere should either be ''n'' or ''s'''); 38 latlist = md.mesh.lat; %That might work? 39 lonlist = md.mesh.long; 40 error('EPSG code not supported yet'); 39 41 end 40 42 -
issm/trunk/src/m/plot/plot_gridded.m
r16137 r19105 86 86 87 87 %Apply options 88 if ~isnan(data_min) ,88 if ~isnan(data_min) & ~isinf(data_min), 89 89 options=changefieldvalue(options,'caxis',[data_min data_max]); % force caxis so that the colorbar is ready 90 90 end -
issm/trunk/src/m/plot/plot_rifts.m
r13975 r19105 63 63 A=elements(:,1); B=elements(:,2); C=elements(:,3); 64 64 patch( 'Faces', [A B C], 'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor','black'); 65 elseif isplanet, 66 A=elements(:,1); B=elements(:,2); C=elements(:,3); 67 patch( 'Faces', [A B C], 'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor','black'); 65 68 else 66 69 A=elements(:,1); B=elements(:,2); C=elements(:,3); D=elements(:,4); E=elements(:,5); F=elements(:,6); -
issm/trunk/src/m/plot/plot_scatter.m
r18301 r19105 37 37 38 38 %OK, should we create a new colorbar for the occasion? 39 if isempty(findobj(gcf,'tag','TMW_COLORBAR')) ,39 if isempty(findobj(gcf,'tag','TMW_COLORBAR')) && isempty(findobj(gcf,'Type','Colorbar')), 40 40 alreadyplot=false; 41 41 else … … 46 46 if (alreadyplot), 47 47 phch = get(findall(gcf,'type','image','tag','TMW_COLORBAR'),{'parent'}); 48 h = phch{1}; 49 ylim=get(h,'YLim'); 48 if ~isempty(phch), 49 h = phch{1}; 50 ylim=get(h,'YLim'); 51 else 52 %R2014b + 53 h = findobj(gcf,'Type','Colorbar'); 54 ylim = h.Limits; 55 end 50 56 palette=colormap; 51 57 numcolors=size(palette,1); -
issm/trunk/src/m/plot/plot_section.m
r17806 r19105 53 53 resolution=getfieldvalue(options,'resolution'); 54 54 else %Default resolution 55 resolution=[1000 10*md.mesh.numberoflayers]; 55 if is2d, 56 resolution=[1000 1]; 57 else 58 resolution=[1000 10*md.mesh.numberoflayers]; 59 end 56 60 disp(['plot_section warning: no resolution specified, use default resolution: [horizontal_resolution vertical_resolution]=[' num2str(resolution) ']']); 57 61 end -
issm/trunk/src/m/plot/plot_tensor_principalaxis.m
r17806 r19105 29 29 %take the center of each element if ~isonnode 30 30 if datatype==1, 31 x=mean( md.mesh.x(md.mesh.elements'))'; y=mean(md.mesh.y(md.mesh.elements'))'; z=mean(md.mesh.z(md.mesh.elements'))';31 x=mean(x(elements'))'; y=mean(y(elements'))'; z=mean(z(elements'))'; 32 32 end 33 33 -
issm/trunk/src/m/plot/plotdoc.m
r18301 r19105 54 54 disp(' - ''quiver'': quiver plot'); 55 55 56 disp(' ''alloptions'': apply the options to all subplots if ''on''');57 56 disp(' ''axis'': same as standard matlab option (''equal'',''off'',''equal on'',...)'); 58 57 disp(' ''basin'': zoom on a given basin (''pineislandglacier'',''ronneiceshelf'', use isbasin to identify a basin'); 59 disp(' ''hemisphere'': specify +1 or -1');60 58 disp(' ''basindeltax'': in m'); 61 59 disp(' ''showbasins'': write lables for every existing basin name around the center of the plot'); … … 109 107 disp(' ''contrast'': (default 1) coefficient to add contrast to the radar amplitude image used in overlays'); 110 108 disp(' ''highres'': resolution of overlayed radar amplitude image (default is 0, high resolution is 1).'); 111 disp(' ''hem'': specify hemisphere ''n'' or ''s'' (default is ''s'').');112 109 disp(' ''alpha'': transparency coefficient (the higher, the more transparent). Default is 1.5'); 113 110 disp(' ''scaling'': scaling factor used by quiver plots. Default is 0.4'); -
issm/trunk/src/m/plot/processdata.m
r18301 r19105 25 25 end 26 26 choice=input(['please enter the field number? (between 1 and ' num2str(numel(F)) ') ']); 27 [data datatype]=processdata(md,data .(F{choice}),options);27 [data datatype]=processdata(md,data(1).(F{choice}),options); 28 28 end 29 29 … … 189 189 clear databak 190 190 end 191 if datatype==3, 192 %Mask? 193 if exist(options,'mask'), 194 flags=getfieldvalue(options,'mask'); 195 pos=find(~flags); 196 if length(flags)==md.mesh.numberofvertices, 197 data(pos,:)=NaN; 198 elseif length(flags)==md.mesh.numberofelements 199 data(md.mesh.elements(pos,:),:)=NaN; 200 else 201 disp('plotmodel warning: mask length not supported yet (supported length are md.mesh.numberofvertices and md.mesh.numberofelements'); 202 end 203 end 204 end 191 205 192 206 %OK, if datatype=0 error out -
issm/trunk/src/m/plot/processmesh.m
r17806 r19105 21 21 end 22 22 23 %first load x,y, etc ... to speed up plot 23 %special case for mesh 3dsurface 24 if strcmp(domaintype(md.mesh),'3Dsurface'), 25 [x y z elements is2d isplanet] = processmesh(md.mesh,options); 26 return; 27 end 28 24 29 if ~strcmpi(getfieldvalue(options,'coord','xy'),'latlon'), 25 30 x=md.mesh.x; -
issm/trunk/src/m/plot/radarpower.m
r17806 r19105 36 36 %figure out if we should go look for Greenland or Antarctica geotiff, or if user provided one. 37 37 if ~exist(options,'overlay_image'), 38 if strcmpi(md.mesh.hemisphere,'n'),38 if md.mesh.epsg==3413, 39 39 %if ~exist(['/u/astrid-r1b/ModelData/MOG/mog150_greenland_map.jpg']), 40 40 % error(['radarpower error message: file ' '/u/astrid-r1b/ModelData/MOG/mog150_greenland_map.jpg not found.']); … … 106 106 system('rm -rf ./temp.tif'); 107 107 108 elseif strcmpi(md.mesh.hemisphere,'s'),108 elseif md.mesh.epsg==3031, 109 109 if ~exist(options,'geotiff_name'), 110 110 if highres, … … 138 138 139 139 else 140 error(' field hemisphere should either be ''n'' or ''s''');140 error('EPSG code not supported yet (ex: 3413 for UPS Greenland, 3031 for UPS Antarctica)'); 141 141 end 142 142 else -
issm/trunk/src/m/plot/showregion.m
r16137 r19105 15 15 axis equal off 16 16 %box off 17 if strcmpi(md.mesh.hemisphere,'n') | strcmpi(md.mesh.hemisphere,'north'),17 if md.mesh.epsg==3413, 18 18 A=expread(['/u/astrid-r1b/ModelData/Exp/Greenland.exp']); 19 elseif strcmpi(md.mesh.hemisphere,'s') | strcmpi(md.mesh.hemisphere,'south'),19 elseif md.mesh.epsg==3031, 20 20 A=expread(['/u/astrid-r1b/ModelData/Exp/Antarctica.exp']); 21 21 else 22 error(' applyoptions error message: hemisphere not defined');22 error('md.mesh.epsg not supported yet'); 23 23 end 24 24 -
issm/trunk/src/m/qmu/dakota_out_parse.m
r14310 r19105 219 219 dquart3=prctile_issm(data,75,1); 220 220 dmax =max (data,[],1); 221 dmin95=prctile_issm(data,5,1); 222 dmax95=prctile_issm(data,95,1); 221 223 222 224 % same as Dakota scm, Excel correl … … 237 239 dresp(i).quart3 =dquart3(i); 238 240 dresp(i).max =dmax(i); 241 dresp(i).dmin95 =dmin95(i); 242 dresp(i).dmax95 =dmax95(i); 239 243 end 240 244 -
issm/trunk/src/m/qmu/plot/plot_hist_norm.m
r14310 r19105 44 44 % ymin2 (numeric, minimum of cdf y-axis) 45 45 % ymax2 (numeric, maximum of cdf y-axis) 46 % nrmplt (char, 'line' or 'off' to change nrm plots from 'bar') 46 % nrmplt (char, pass 'l' or 'off' to change nrm plots 47 % from default of 'bar' or 'b' to 'line' instead, 48 % pass 's' to change nrm plot to 'stairs') 47 49 % cdfplt (char, 'off' to turn off cdf line plots) 48 50 % cdfleg (char, 'off' to turn off cdf legends) … … 174 176 175 177 % parameters 176 178 LineWidth=1; 177 179 while (iarg <= nargin-1) 178 180 if ischar(varargin{iarg}) … … 180 182 {'hmin','hmax','hnint',... 181 183 'ymin1','ymax1','ymin2','ymax2',... 182 'nrmplt','EdgeColor','FaceColor','cdfplt','cdfleg','nrmleg','cmap','titleplt','xlabelplt','ylabelplt','FontSize'},... 184 'nrmplt','EdgeColor','FaceColor','LineWidth','cdfplt',... 185 'cdfleg','nrmleg','cmap','titleplt','xlabelplt','ylabelplt','FontSize'},... 183 186 'exact')) 184 187 eval([varargin{iarg} '=varargin{iarg+1};']); … … 251 254 hl1(1*ncol+1:2*ncol)=... 252 255 line(edges(1:end-1),dhistc(1:end-1,1*ncol+1:2*ncol),... 253 'LineWidth',2); 256 'LineWidth',LineWidth); 257 elseif strncmpi(nrmplt,'s',1) 258 hl1=stairs(edges(1:end-1)-(hmax-hmin)/hnint/2,dhistc(1:end-1,1:ncol)); 254 259 elseif strncmpi(nrmplt,'off',3) 255 260 hl1=bar (edges(1:end-1),dhistc(1:end-1,1:1*ncol)); … … 269 274 270 275 %set face and edge color 271 for i=1:length(hl1) 272 set(hl1(i),'EdgeColor',EdgeColor,'FaceColor',FaceColor); 276 if ~strncmpi(nrmplt,'s',1) 277 for i=1:length(hl1) 278 set(hl1(i),'EdgeColor',EdgeColor,'FaceColor',FaceColor,'LineWidth',LineWidth); 279 end 273 280 end 274 281 … … 282 289 cmap=colormap; 283 290 for i=1:length(hl1) 284 if (length(hl1) > 1) 285 imap=round((i-1)/(length(hl1)-1)*(size(cmap,1)-1))+1; 286 else 287 imap=1; 288 end 289 if strcmpi(get(hl1(i),'Type'),'hggroup') 290 if ischar(get(hl1(i),'FaceColor')) && ... 291 strcmpi(get(hl1(i),'FaceColor'),'flat') 292 set(hl1(i),'FaceColor',cmap(imap,:)) 293 else 294 set(hl1(i),'FaceColor',get(hl1(i),'FaceColor')) 295 end 296 elseif strcmpi(get(hl1(i),'Type'),'line') 297 set(hl1(i),'Color',cmap(imap,:)) 298 end 291 if (length(hl1) > 1) 292 imap=round((i-1)/(length(hl1)-1)*(size(cmap,1)-1))+1; 293 else 294 imap=1; 295 end 296 if ~strncmpi(nrmplt,'s',1) && strcmpi(get(hl1(i),'Type'),'hggroup') 297 if ischar(get(hl1(i),'FaceColor')) && ... 298 strcmpi(get(hl1(i),'FaceColor'),'flat') 299 set(hl1(i),'FaceColor',cmap(imap,:)) 300 else 301 set(hl1(i),'FaceColor',get(hl1(i),'FaceColor')) 302 end 303 elseif strcmpi(get(hl1(i),'Type'),'line') 304 set(hl1(i),'Color',cmap(imap,:)) 305 elseif strncmpi(nrmplt,'s',1) 306 set(hl1(i),'Color',EdgeColor,'LineWidth',2) 307 end 299 308 end 300 309 -
issm/trunk/src/m/solve/WriteData.m
r17989 r19105 27 27 format = getfieldvalue(options,'format'); 28 28 mattype = getfieldvalue(options,'mattype',0); %only required for matrices 29 forcinglength = getfieldvalue(options,'forcinglength',-1);29 timeserieslength = getfieldvalue(options,'timeserieslength',-1); 30 30 31 31 %Process sparse matrices … … 37 37 if exist(options,'scale'), 38 38 scale = getfieldvalue(options,'scale'); 39 if size(data,1)== forcinglength,39 if size(data,1)==timeserieslength, 40 40 data(1:end-1,:) = scale.*data(1:end-1,:); 41 41 else … … 43 43 end 44 44 end 45 if(size(data,1)== forcinglength),45 if(size(data,1)==timeserieslength), 46 46 yts=365.0*24.0*3600.0; 47 47 data(end,:) = data(end,:)*yts; -
issm/trunk/src/m/solve/WriteData.py
r17989 r19105 35 35 format = options.getfieldvalue('format') 36 36 mattype = options.getfieldvalue('mattype',0) #only required for matrices 37 forcinglength = options.getfieldvalue('forcinglength',-1)37 timeserieslength = options.getfieldvalue('timeserieslength',-1) 38 38 39 39 #Process sparse matrices … … 46 46 scale = options.getfieldvalue('scale') 47 47 if numpy.size(data) > 1 : 48 if numpy.size(data,0)== forcinglength:48 if numpy.size(data,0)==timeserieslength: 49 49 data=numpy.array(data) 50 50 data[0:-1,:] = scale*data[0:-1,:] … … 54 54 data = scale*data 55 55 if numpy.size(data) > 1 : 56 if numpy.size(data,0)== forcinglength:56 if numpy.size(data,0)==timeserieslength: 57 57 yts=365.0*24.0*3600.0 58 58 data[-1,:] = yts*data[-1,:] -
issm/trunk/src/m/solve/parseresultsfromdisk.m
r18301 r19105 184 184 elseif strcmp(fieldname,'SurfaceforcingsMassBalance'), 185 185 field = field*yts; 186 elseif strcmp(fieldname,'CalvingCalvingrate'), 187 field = field*yts; 186 188 end 187 189 -
issm/trunk/src/m/solve/parseresultsfromdisk.py
r18301 r19105 184 184 elif m.strcmp(fieldname,'SurfaceforcingsMassBalance'): 185 185 field = field*yts 186 elif m.strcmp(fieldname,'CalvingCalvingrate'): 187 field = field*yts 188 186 189 187 190 result=OrderedDict() -
issm/trunk/src/m/solve/waitonlock.m
r17806 r19105 27 27 28 28 %If we are using the generic cluster in interactive mode, job is already complete 29 if isa(cluster,'generic') & cluster.interactive29 if (isa(cluster,'generic') & cluster.interactive) | isa(cluster,'generic_static'), 30 30 %We are in interactive mode, no need to check for job completion 31 31 ispresent=1; -
issm/trunk/src/wrappers
- Property svn:ignore
-
old new 16 16 *.mexw32.map 17 17 *.exe.manifest 18 .dirstamp
-
- Property svn:ignore
-
issm/trunk/src/wrappers/ExpSimplify/ExpSimplify.cpp
r15396 r19105 18 18 _printf_(" Example:\n"); 19 19 _printf_(" ExpSimplify('file.exp',100);\n"); 20 _printf_(" ExpSimplify('file.exp',100,' remove1',false);\n");20 _printf_(" ExpSimplify('file.exp',100,'min',4);\n"); 21 21 }/*}}}*/ 22 22 void simplify(Contour<double>* contour,bool* flags,int ind0,int ind1,double tolerance){/*{{{*/ -
issm/trunk/src/wrappers/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp
r15396 r19105 76 76 77 77 /*end module: */ 78 xDelete<int>(index); 79 xDelete<double>(x_data); 80 xDelete<double>(y_data); 81 xDelete<double>(data); 82 xDelete<double>(x_interp); 83 xDelete<double>(y_interp); 84 xDelete<double>(data_interp); 85 delete options; 78 86 MODULEEND(); 79 87 } -
issm/trunk/src/wrappers/IssmConfig/IssmConfig.cpp
r17989 r19105 76 76 #endif 77 77 } 78 else if(strcmp(name,"_PETSC_MINOR_")==0){ 79 #ifdef _PETSC_MINOR_ 80 value = IssmDouble(_PETSC_MINOR_); 81 #else 82 _error_("_PETSC_MINOR_ not found in config.h"); 83 #endif 84 } 78 85 else if(strcmp(name,"_DAKOTA_VERSION_")==0){ 79 86 #ifdef _DAKOTA_VERSION_ … … 115 122 xMemCpy<char>(svalue,PACKAGE_BUILD_DATE,(strlen(PACKAGE_BUILD_DATE)+1)); 116 123 } 124 else if(strcmp(name,"HOST_OS")==0){ 125 isstring = true; 126 svalue =xNew<char>(strlen(HOST_OS)+1); 127 xMemCpy<char>(svalue,HOST_OS,(strlen(HOST_OS)+1)); 128 } 129 else if(strcmp(name,"USER_NAME")==0){ 130 isstring = true; 131 svalue =xNew<char>(strlen(USER_NAME)+1); 132 xMemCpy<char>(svalue,USER_NAME,(strlen(USER_NAME)+1)); 133 } 134 else if(strcmp(name,"HOST_VENDOR")==0){ 135 isstring = true; 136 svalue =xNew<char>(strlen(HOST_VENDOR)+1); 137 xMemCpy<char>(svalue,HOST_VENDOR,(strlen(HOST_VENDOR)+1)); 138 } 139 else if(strcmp(name,"HOST_OS")==0){ 140 isstring = true; 141 svalue =xNew<char>(strlen(HOST_OS)+1); 142 xMemCpy<char>(svalue,HOST_OS,(strlen(HOST_OS)+1)); 143 } 144 else if(strcmp(name,"HOST_ARCH")==0){ 145 isstring = true; 146 svalue =xNew<char>(strlen(HOST_ARCH)+1); 147 xMemCpy<char>(svalue,HOST_ARCH,(strlen(HOST_ARCH)+1)); 148 } 117 149 else{ 118 150 _error_("variable " << name << " not supported yet"); -
issm/trunk/src/wrappers/matlab/Makefile.am
r18301 r19105 8 8 9 9 #matlab io{{{ 10 lib_LIBRARIES = libISSMMatlab.a11 if SHAREDLIBS12 10 lib_LTLIBRARIES = libISSMMatlab.la 13 else 14 lib_LTLIBRARIES = 15 endif 16 17 io_sources= ./include/matlabincludes.h\ 18 ./io/matlabio.h\ 19 ./io/CheckNumMatlabArguments.cpp\ 11 12 io_sources= ./io/CheckNumMatlabArguments.cpp\ 20 13 ./io/WriteMatlabData.cpp\ 21 14 ./io/FetchMatlabData.cpp 22 15 23 ALLCXXFLAGS= -fPIC -D_GNU_SOURCE -fno-omit-frame-pointer -pthread -D_CPP_ -D_WRAPPERS_ $(CXXFLAGS) $(CXXOPTFLAGS) 24 25 libISSMMatlab_a_SOURCES = $(io_sources) 26 libISSMMatlab_a_CXXFLAGS= $(ALLCXXFLAGS) 27 if SHAREDLIBS 16 ALLCXXFLAGS= -fPIC -D_WRAPPERS_ $(CXXFLAGS) $(CXXOPTFLAGS) 17 28 18 libISSMMatlab_la_SOURCES = $(io_sources) 29 endif 19 libISSMMatlab_la_CXXFLAGS= $(ALLCXXFLAGS) 30 20 #}}} 31 21 #api io{{{ 32 lib_LIBRARIES += libISSMApi.a33 if SHAREDLIBS34 22 lib_LTLIBRARIES += libISSMApi.la 35 else36 lib_LTLIBRARIES +=37 endif38 23 39 24 api_sources= ./io/ApiPrintf.cpp 40 25 41 libISSMApi_a_SOURCES = $(api_sources)42 libISSMApi_a_CXXFLAGS= $(ALLCXXFLAGS)43 if SHAREDLIBS44 26 libISSMApi_la_SOURCES = $(api_sources) 45 endif 27 libISSMApi_la_CXXFLAGS= $(ALLCXXFLAGS) 46 28 #}}} 47 29 #Wrappers {{{ … … 54 36 EnumToString.la\ 55 37 ExpSimplify.la\ 38 ExpToLevelSet.la\ 56 39 InterpFromGridToMesh.la\ 57 40 InterpFromMeshToMesh2d.la\ … … 62 45 Ll2xy.la\ 63 46 NodeConnectivity.la\ 47 M1qn3.la\ 64 48 MeshPartition.la\ 65 49 MeshProfileIntersection.la\ … … 95 79 96 80 #Matlab part 97 AM_LDFLAGS = -module $(MEXLINK) -shrext ${EXEEXT} -L/usr/lib81 AM_LDFLAGS = -module $(MEXLINK) -shrext ${EXEEXT} --export-dynamic -rdynamic 98 82 if VERSION 99 83 AM_LDFLAGS += … … 102 86 endif 103 87 104 AM_CXXFLAGS += -D_HAVE_MATLAB_MODULES_ -D_GNU_SOURCE -fPIC -fno-omit-frame-pointer -pthread 105 106 if SHAREDLIBS 88 if STANDALONE_MODULES 89 AM_LDFLAGS += -Wl,-static 90 endif 91 92 AM_CXXFLAGS += -D_HAVE_MATLAB_MODULES_ -fPIC 93 107 94 deps += ./libISSMMatlab.la ../../c/libISSMModules.la ../../c/libISSMCore.la ./libISSMApi.la 108 95 109 else110 deps += ./libISSMMatlab.a ../../c/libISSMModules.a ../../c/libISSMCore.a ./libISSMApi.a111 96 if ADOLC 112 97 deps += $(ADOLCLIB) 113 98 endif 99 100 if FORTRAN 101 deps += $(FLIBS) $(FORTRANLIB) 114 102 endif 115 103 … … 121 109 #}}} 122 110 # Module sources and dependencies {{{ 123 libISSMMatlab_la_LIBADD = ./../../c/libISSMCore.la ./../../c/libISSMModules.la $(MPILIB) $(PETSCLIB) $(GSLLIB) $(MATHLIB) $(MEXLIB) 124 libISSMMatlab_la_LDFLAGS = -module -export-dynamic 125 126 libISSMApi_la_LIBADD = $(MPILIB) $(PETSCLIB) $(GSLLIB) $(MATHLIB) $(MEXLIB) 127 libISSMApi_la_LDFLAGS = -module -export-dynamic 128 129 BamgMesher_la_SOURCES = ../BamgMesher/BamgMesher.cpp\ 130 ../BamgMesher/BamgMesher.h 131 BamgMesher_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 132 133 BamgConvertMesh_la_SOURCES = ../BamgConvertMesh/BamgConvertMesh.cpp\ 134 ../BamgConvertMesh/BamgConvertMesh.h 135 BamgConvertMesh_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 136 137 BamgTriangulate_la_SOURCES = ../BamgTriangulate/BamgTriangulate.cpp\ 138 ../BamgTriangulate/BamgTriangulate.h 139 BamgTriangulate_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 140 141 Chaco_la_SOURCES = ../Chaco/Chaco.cpp\ 142 ../Chaco/Chaco.h 143 Chaco_la_LIBADD = ${deps} $(MPILIB) $(CHACOLIB) $(GSLLIB) $(PETSCLIB) 144 145 ContourToMesh_la_SOURCES = ../ContourToMesh/ContourToMesh.cpp\ 146 ../ContourToMesh/ContourToMesh.h 147 ContourToMesh_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(MULTITHREADINGLIB) $(GSLLIB) 148 149 ContourToNodes_la_SOURCES = ../ContourToNodes/ContourToNodes.cpp\ 150 ../ContourToNodes/ContourToNodes.h 151 ContourToNodes_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 152 153 ElementConnectivity_la_SOURCES = ../ElementConnectivity/ElementConnectivity.cpp\ 154 ../ElementConnectivity/ElementConnectivity.h 155 ElementConnectivity_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 156 157 EnumToString_la_SOURCES = ../EnumToString/EnumToString.cpp\ 158 ../EnumToString/EnumToString.h 159 EnumToString_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 160 161 StringToEnum_la_SOURCES = ../StringToEnum/StringToEnum.cpp\ 162 ../StringToEnum/StringToEnum.h 163 StringToEnum_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 164 165 InterpFromGridToMesh_la_SOURCES = ../InterpFromGridToMesh/InterpFromGridToMesh.cpp\ 166 ../InterpFromGridToMesh/InterpFromGridToMesh.h 167 InterpFromGridToMesh_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(MULTITHREADINGLIB) $(GSLLIB) 168 169 InterpFromMeshToMesh2d_la_SOURCES = ../InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp\ 170 ../InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.h 171 InterpFromMeshToMesh2d_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(MULTITHREADINGLIB) $(GSLLIB) 172 173 InterpFromMeshToMesh3d_la_SOURCES = ../InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.cpp\ 174 ../InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.h 175 InterpFromMeshToMesh3d_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 176 177 InterpFromMeshToGrid_la_SOURCES = ../InterpFromMeshToGrid/InterpFromMeshToGrid.cpp\ 178 ../InterpFromMeshToGrid/InterpFromMeshToGrid.h 179 InterpFromMeshToGrid_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 180 181 InterpFromMesh2d_la_SOURCES = ../InterpFromMesh2d/InterpFromMesh2d.cpp\ 182 ../InterpFromMesh2d/InterpFromMesh2d.h 183 InterpFromMesh2d_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(MULTITHREADINGLIB) $(GSLLIB) 184 185 IssmConfig_la_SOURCES = ../IssmConfig/IssmConfig.cpp\ 186 ../IssmConfig/IssmConfig.h 111 libISSMMatlab_la_LIBADD = ./../../c/libISSMCore.la ./../../c/libISSMModules.la $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) $(MATHLIB) $(MEXLIB) 112 113 if STANDALONE_LIBRARIES 114 libISSMMatlab_la_LDFLAGS = -static 115 endif 116 117 libISSMApi_la_LIBADD = $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) $(MATHLIB) $(MEXLIB) 118 119 if STANDALONE_LIBRARIES 120 libISSMApi_la_LDFLAGS = -static 121 endif 122 123 BamgMesher_la_SOURCES = ../BamgMesher/BamgMesher.cpp 124 BamgMesher_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 125 126 BamgConvertMesh_la_SOURCES = ../BamgConvertMesh/BamgConvertMesh.cpp 127 BamgConvertMesh_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 128 129 BamgTriangulate_la_SOURCES = ../BamgTriangulate/BamgTriangulate.cpp 130 BamgTriangulate_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 131 132 Chaco_la_SOURCES = ../Chaco/Chaco.cpp 133 Chaco_la_LIBADD = ${deps} $(MPILIB) $(CHACOLIB) $(GSLLIB) $(PROJ4LIB) $(PETSCLIB) 134 135 ContourToMesh_la_SOURCES = ../ContourToMesh/ContourToMesh.cpp 136 ContourToMesh_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(MULTITHREADINGLIB) $(GSLLIB) $(PROJ4LIB) 137 138 ExpToLevelSet_la_SOURCES = ../ExpToLevelSet/ExpToLevelSet.cpp 139 ExpToLevelSet_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(MULTITHREADINGLIB) $(GSLLIB) $(PROJ4LIB) 140 141 142 ContourToNodes_la_SOURCES = ../ContourToNodes/ContourToNodes.cpp 143 ContourToNodes_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 144 145 ElementConnectivity_la_SOURCES = ../ElementConnectivity/ElementConnectivity.cpp 146 ElementConnectivity_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 147 148 EnumToString_la_SOURCES = ../EnumToString/EnumToString.cpp 149 EnumToString_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 150 151 StringToEnum_la_SOURCES = ../StringToEnum/StringToEnum.cpp 152 StringToEnum_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 153 154 InterpFromGridToMesh_la_SOURCES = ../InterpFromGridToMesh/InterpFromGridToMesh.cpp 155 InterpFromGridToMesh_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(MULTITHREADINGLIB) $(GSLLIB) $(PROJ4LIB) 156 157 InterpFromMeshToMesh2d_la_SOURCES = ../InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp 158 InterpFromMeshToMesh2d_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(MULTITHREADINGLIB) $(GSLLIB) $(PROJ4LIB) 159 160 InterpFromMeshToMesh3d_la_SOURCES = ../InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.cpp 161 InterpFromMeshToMesh3d_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 162 163 InterpFromMeshToGrid_la_SOURCES = ../InterpFromMeshToGrid/InterpFromMeshToGrid.cpp 164 InterpFromMeshToGrid_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 165 166 InterpFromMesh2d_la_SOURCES = ../InterpFromMesh2d/InterpFromMesh2d.cpp 167 InterpFromMesh2d_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(MULTITHREADINGLIB) $(GSLLIB) $(PROJ4LIB) 168 169 IssmConfig_la_SOURCES = ../IssmConfig/IssmConfig.cpp 187 170 IssmConfig_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) 188 171 189 KMLFileRead_la_SOURCES = ../KMLFileRead/KMLFileRead.cpp\ 190 ../KMLFileRead/KMLFileRead.h 191 KMLFileRead_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 192 193 KMLMeshWrite_la_SOURCES = ../KMLMeshWrite/KMLMeshWrite.cpp\ 194 ../KMLMeshWrite/KMLMeshWrite.h 195 KMLMeshWrite_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 196 197 KMLOverlay_la_SOURCES = ../KMLOverlay/KMLOverlay.cpp\ 198 ../KMLOverlay/KMLOverlay.h 199 KMLOverlay_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 200 201 Xy2ll_la_SOURCES = ../Xy2ll/Xy2ll.cpp\ 202 ../Xy2ll/Xy2ll.h 203 Xy2ll_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 204 205 Ll2xy_la_SOURCES = ../Ll2xy/Ll2xy.cpp\ 206 ../Ll2xy/Ll2xy.h 207 Ll2xy_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 208 209 ExpSimplify_la_SOURCES = ../ExpSimplify/ExpSimplify.cpp\ 210 ../ExpSimplify/ExpSimplify.h 211 ExpSimplify_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 212 213 Exp2Kml_la_SOURCES = ../Exp2Kml/Exp2Kml.cpp\ 214 ../Exp2Kml/Exp2Kml.h 215 Exp2Kml_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 216 217 Kml2Exp_la_SOURCES = ../Kml2Exp/Kml2Exp.cpp\ 218 ../Kml2Exp/Kml2Exp.h 219 Kml2Exp_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 220 221 Kriging_la_SOURCES = ../Kriging/Kriging.cpp\ 222 ../Kriging/Kriging.h 223 Kriging_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(MULTITHREADINGLIB) $(GSLLIB) 224 225 MeshPartition_la_SOURCES = ../MeshPartition/MeshPartition.cpp\ 226 ../MeshPartition/MeshPartition.h 227 MeshPartition_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(METISLIB) $(GSLLIB) 228 229 MeshProfileIntersection_la_SOURCES = ../MeshProfileIntersection/MeshProfileIntersection.cpp\ 230 ../MeshProfileIntersection/MeshProfileIntersection.h 231 MeshProfileIntersection_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 232 233 NodeConnectivity_la_SOURCES = ../NodeConnectivity/NodeConnectivity.cpp\ 234 ../NodeConnectivity/NodeConnectivity.h 235 NodeConnectivity_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 236 237 PointCloudFindNeighbors_la_SOURCES = ../PointCloudFindNeighbors/PointCloudFindNeighbors.cpp\ 238 ../PointCloudFindNeighbors/PointCloudFindNeighbors.h 239 PointCloudFindNeighbors_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(MULTITHREADINGLIB) $(GSLLIB) 240 241 PropagateFlagsFromConnectivity_la_SOURCES = ../PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.cpp\ 242 ../PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.h 243 PropagateFlagsFromConnectivity_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 244 245 Scotch_la_SOURCES = ../Scotch/Scotch.cpp\ 246 ../Scotch/Scotch.h 172 KMLFileRead_la_SOURCES = ../KMLFileRead/KMLFileRead.cpp 173 KMLFileRead_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 174 175 KMLMeshWrite_la_SOURCES = ../KMLMeshWrite/KMLMeshWrite.cpp 176 KMLMeshWrite_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 177 178 KMLOverlay_la_SOURCES = ../KMLOverlay/KMLOverlay.cpp 179 KMLOverlay_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 180 181 Xy2ll_la_SOURCES = ../Xy2ll/Xy2ll.cpp 182 Xy2ll_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 183 184 Ll2xy_la_SOURCES = ../Ll2xy/Ll2xy.cpp 185 Ll2xy_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 186 187 ExpSimplify_la_SOURCES = ../ExpSimplify/ExpSimplify.cpp 188 ExpSimplify_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 189 190 Exp2Kml_la_SOURCES = ../Exp2Kml/Exp2Kml.cpp 191 Exp2Kml_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 192 193 Kml2Exp_la_SOURCES = ../Kml2Exp/Kml2Exp.cpp 194 Kml2Exp_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 195 196 Kriging_la_SOURCES = ../Kriging/Kriging.cpp 197 Kriging_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) $(MULTITHREADINGLIB) $(GSLLIB) $(PROJ4LIB) 198 199 MeshPartition_la_SOURCES = ../MeshPartition/MeshPartition.cpp 200 MeshPartition_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(METISLIB) $(GSLLIB) $(PROJ4LIB) 201 202 M1qn3_la_SOURCES = ../M1qn3/M1qn3.cpp 203 M1qn3_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(METISLIB) $(M1QN3LIB) $(GSLLIB) $(PROJ4LIB) 204 205 MeshProfileIntersection_la_SOURCES = ../MeshProfileIntersection/MeshProfileIntersection.cpp 206 MeshProfileIntersection_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 207 208 NodeConnectivity_la_SOURCES = ../NodeConnectivity/NodeConnectivity.cpp 209 NodeConnectivity_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 210 211 PointCloudFindNeighbors_la_SOURCES = ../PointCloudFindNeighbors/PointCloudFindNeighbors.cpp 212 PointCloudFindNeighbors_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(MULTITHREADINGLIB) $(GSLLIB) $(PROJ4LIB) 213 214 PropagateFlagsFromConnectivity_la_SOURCES = ../PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.cpp 215 PropagateFlagsFromConnectivity_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 216 217 Scotch_la_SOURCES = ../Scotch/Scotch.cpp 247 218 Scotch_la_LIBADD = ${deps} $(SCOTCHLIB) $(MPILIB) $(BLASLAPACKLIB) 248 219 249 ShpRead_la_SOURCES = ../ShpRead/ShpRead.cpp\ 250 ../ShpRead/ShpRead.h 251 ShpRead_la_LIBADD = ${deps} $(SHAPELIBLIB) $(MPILIB) $(PETSCLIB) $(GSLLIB) 252 253 Shp2Kml_la_SOURCES = ../Shp2Kml/Shp2Kml.cpp\ 254 ../Shp2Kml/Shp2Kml.h 255 Shp2Kml_la_LIBADD = ${deps} $(SHAPELIBLIB) $(MPILIB) $(PETSCLIB) $(GSLLIB) 256 257 TriaSearch_la_SOURCES = ../TriaSearch/TriaSearch.cpp\ 258 ../TriaSearch/TriaSearch.h 259 TriaSearch_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 260 261 TriMesh_la_SOURCES = ../TriMesh/TriMesh.cpp\ 262 ../TriMesh/TriMesh.h 263 TriMesh_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(TRIANGLELIB) $(GSLLIB) 264 265 TriMeshProcessRifts_la_SOURCES = ../TriMeshProcessRifts/TriMeshProcessRifts.cpp\ 266 ../TriMeshProcessRifts/TriMeshProcessRifts.h 267 TriMeshProcessRifts_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 268 #}}} 220 ShpRead_la_SOURCES = ../ShpRead/ShpRead.cpp 221 ShpRead_la_LIBADD = ${deps} $(SHAPELIBLIB) $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 222 223 Shp2Kml_la_SOURCES = ../Shp2Kml/Shp2Kml.cpp 224 Shp2Kml_la_LIBADD = ${deps} $(SHAPELIBLIB) $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 225 226 TriaSearch_la_SOURCES = ../TriaSearch/TriaSearch.cpp 227 TriaSearch_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 228 229 TriMesh_la_SOURCES = ../TriMesh/TriMesh.cpp 230 TriMesh_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(TRIANGLELIB) $(GSLLIB) $(PROJ4LIB) 231 232 TriMeshProcessRifts_la_SOURCES = ../TriMeshProcessRifts/TriMeshProcessRifts.cpp 233 TriMeshProcessRifts_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 234 #}}} -
issm/trunk/src/wrappers/matlab/io/WriteMatlabData.cpp
r15396 r19105 192 192 int i; 193 193 mxArray *dataref = NULL; 194 const int numfields = 1 6;194 const int numfields = 17; 195 195 const char *fnames[numfields]; 196 196 mwSize ndim = 2; … … 215 215 fnames[i++] = "CrackedVertices"; 216 216 fnames[i++] = "CrackedEdges"; 217 fnames[i++] = "PreviousNumbering"; 217 218 _assert_(i==numfields); 218 219 … … 238 239 i++; SetStructureField(dataref,"CrackedVertices", bamgmesh->CrackedVerticesSize[0],bamgmesh->CrackedVerticesSize[1], bamgmesh->CrackedVertices); 239 240 i++; SetStructureField(dataref,"CrackedEdges",bamgmesh->CrackedEdgesSize[0], bamgmesh->CrackedEdgesSize[1],bamgmesh->CrackedEdges); 241 i++; SetStructureField(dataref,"PreviousNumbering",bamgmesh->VerticesSize[0],1,bamgmesh->PreviousNumbering); 240 242 _assert_(i==numfields); 241 243 -
issm/trunk/src/wrappers/python/Makefile.am
r18301 r19105 8 8 9 9 #python io{{{ 10 lib_LIBRARIES = libISSMPython.a11 if SHAREDLIBS12 10 lib_LTLIBRARIES = libISSMPython.la 13 else14 lib_LTLIBRARIES =15 endif16 11 17 io_sources= ./include/pythonincludes.h\ 18 ./io/pythonio.h\ 19 ./io/WritePythonData.cpp\ 12 io_sources= ./io/WritePythonData.cpp\ 20 13 ./io/CheckNumPythonArguments.cpp\ 21 14 ./io/FetchPythonData.cpp 22 15 23 ALLCXXFLAGS= -fPIC -D_GNU_SOURCE -fno-omit-frame-pointer -pthread -D_CPP_ -D_WRAPPERS_ $(CXXFLAGS) $(CXXOPTFLAGS) 24 libISSMPython_a_SOURCES = $(io_sources) 25 libISSMPython_a_CXXFLAGS= $(ALLCXXFLAGS) 26 if SHAREDLIBS 16 ALLCXXFLAGS= -fPIC -D_WRAPPERS_ $(CXXFLAGS) $(CXXOPTFLAGS) 27 17 libISSMPython_la_SOURCES = $(io_sources) 28 endif 18 libISSMPython_la_CXXFLAGS= $(ALLCXXFLAGS) 29 19 #}}} 30 20 #api io{{{ 31 lib_LIBRARIES += libISSMApi.a32 if SHAREDLIBS33 21 lib_LTLIBRARIES += libISSMApi.la 34 else35 lib_LTLIBRARIES +=36 endif37 22 38 23 api_sources= ./io/ApiPrintf.cpp 39 24 40 libISSMApi_a_SOURCES = $(api_sources)41 libISSMApi_a_CXXFLAGS= $(ALLCXXFLAGS)42 if SHAREDLIBS43 25 libISSMApi_la_SOURCES = $(api_sources) 44 endif 26 libISSMApi_la_CXXFLAGS= $(ALLCXXFLAGS) 45 27 #}}} 46 28 #Wrappers {{{ 29 if WRAPPERS 47 30 lib_LTLIBRARIES += BamgConvertMesh.la\ 48 BamgMesher.la\ 49 ContourToMesh.la\ 50 ContourToNodes.la\ 51 ElementConnectivity.la\ 52 EnumToString.la\ 53 InterpFromMeshToMesh2d.la\ 54 InterpFromMeshToMesh3d.la\ 55 InterpFromGridToMesh.la\ 56 InterpFromMeshToGrid.la\ 57 IssmConfig.la\ 58 MeshProfileIntersection.la\ 59 NodeConnectivity.la\ 60 StringToEnum.la\ 61 TriMesh.la\ 62 TriMeshProcessRifts.la 31 BamgMesher.la\ 32 ContourToMesh.la\ 33 ContourToNodes.la\ 34 ElementConnectivity.la\ 35 EnumToString.la\ 36 InterpFromMeshToMesh2d.la\ 37 InterpFromMeshToMesh3d.la\ 38 InterpFromGridToMesh.la\ 39 InterpFromMeshToGrid.la\ 40 IssmConfig.la\ 41 MeshProfileIntersection.la\ 42 NodeConnectivity.la\ 43 StringToEnum.la\ 44 TriMesh.la\ 45 TriMeshProcessRifts.la 46 endif 63 47 #}}} 64 48 #Flags and libraries {{{ 65 #if SHAREDLIBS66 #deps = ../../c/libISSMCore.la ../../c/libISSMModules.la67 #else68 #deps = ../../c/libISSMCore.a ../../c/libISSMModules.a69 #endif70 #deps += $(MATHLIB) ${PYTHONLIB}71 49 deps = $(MATHLIB) ${PYTHONLIB} 72 50 … … 81 59 AM_LDFLAGS += -avoid-version 82 60 endif 83 if SHAREDLIBS 61 62 if STANDALONE_MODULES 63 AM_LDFLAGS += -Wl,-static 64 endif 65 84 66 deps += ./libISSMPython.la 85 else86 deps += ./libISSMPython.a87 67 AM_LDFLAGS += --no-warnings 88 endif89 68 90 69 AM_CXXFLAGS += -D_HAVE_PYTHON_MODULES_ -fPIC … … 93 72 endif 94 73 95 if SHAREDLIBS 96 deps += 97 else 98 deps += ../../c/libISSMModules.a ../../c/libISSMCore.a 74 deps += ../../c/libISSMModules.la ../../c/libISSMCore.la 99 75 if ADOLC 100 76 deps += $(ADOLCLIB) 101 77 endif 102 78 103 if SHAREDLIBS104 79 deps += ./libISSMApi.la 105 else 106 deps += ./libISSMApi.a 80 81 if STANDALONE_LIBRARIES 82 libISSMPython_la_LDFLAGS = -static 107 83 endif 108 109 110 111 endif 84 if STANDALONE_LIBRARIES 85 libISSMApi_la_LDFLAGS = -static 86 endif 112 87 113 88 #Optimization flags: … … 115 90 #}}} 116 91 #Bin sources {{{ 117 BamgConvertMesh_la_SOURCES = ../BamgConvertMesh/BamgConvertMesh.cpp\ 118 ../BamgConvertMesh/BamgConvertMesh.h 119 BamgConvertMesh_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 92 BamgConvertMesh_la_SOURCES = ../BamgConvertMesh/BamgConvertMesh.cpp 93 BamgConvertMesh_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 120 94 121 BamgMesher_la_SOURCES = ../BamgMesher/BamgMesher.cpp\ 122 ../BamgMesher/BamgMesher.h 123 BamgMesher_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 95 BamgMesher_la_SOURCES = ../BamgMesher/BamgMesher.cpp 96 BamgMesher_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 124 97 125 ContourToMesh_la_SOURCES = ../ContourToMesh/ContourToMesh.cpp\ 126 ../ContourToMesh/ContourToMesh.h 127 ContourToMesh_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 98 ContourToMesh_la_SOURCES = ../ContourToMesh/ContourToMesh.cpp 99 ContourToMesh_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 128 100 129 ContourToNodes_la_SOURCES = ../ContourToNodes/ContourToNodes.cpp\ 130 ../ContourToNodes/ContourToNodes.h 131 ContourToNodes_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 101 ContourToNodes_la_SOURCES = ../ContourToNodes/ContourToNodes.cpp 102 ContourToNodes_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 132 103 133 ElementConnectivity_la_SOURCES = ../ElementConnectivity/ElementConnectivity.cpp\ 134 ../ElementConnectivity/ElementConnectivity.h 135 ElementConnectivity_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 104 ElementConnectivity_la_SOURCES = ../ElementConnectivity/ElementConnectivity.cpp 105 ElementConnectivity_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 136 106 137 EnumToString_la_SOURCES = ../EnumToString/EnumToString.cpp\ 138 ../EnumToString/EnumToString.h 139 EnumToString_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 107 EnumToString_la_SOURCES = ../EnumToString/EnumToString.cpp 108 EnumToString_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 140 109 141 InterpFromMeshToMesh2d_la_SOURCES = ../InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp\ 142 ../InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.h 143 InterpFromMeshToMesh2d_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(MULTITHREADINGLIB) $(GSLLIB) 110 InterpFromMeshToMesh2d_la_SOURCES = ../InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp 111 InterpFromMeshToMesh2d_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(MULTITHREADINGLIB) $(GSLLIB) $(PROJ4LIB) 144 112 145 InterpFromMeshToMesh3d_la_SOURCES = ../InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.cpp\ 146 ../InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.h 147 InterpFromMeshToMesh3d_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(MULTITHREADINGLIB) $(GSLLIB) 113 InterpFromMeshToMesh3d_la_SOURCES = ../InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.cpp 114 InterpFromMeshToMesh3d_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(MULTITHREADINGLIB) $(GSLLIB) $(PROJ4LIB) 148 115 149 InterpFromGridToMesh_la_SOURCES = ../InterpFromGridToMesh/InterpFromGridToMesh.cpp\ 150 ../InterpFromGridToMesh/InterpFromGridToMesh.h 151 InterpFromGridToMesh_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(MULTITHREADINGLIB) $(GSLLIB) 116 InterpFromGridToMesh_la_SOURCES = ../InterpFromGridToMesh/InterpFromGridToMesh.cpp 117 InterpFromGridToMesh_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(MULTITHREADINGLIB) $(GSLLIB) $(PROJ4LIB) 152 118 153 InterpFromMeshToGrid_la_SOURCES = ../InterpFromMeshToGrid/InterpFromMeshToGrid.cpp\ 154 ../InterpFromMeshToGrid/InterpFromMeshToGrid.h 155 InterpFromMeshToGrid_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(MULTITHREADINGLIB) $(GSLLIB) 119 InterpFromMeshToGrid_la_SOURCES = ../InterpFromMeshToGrid/InterpFromMeshToGrid.cpp 120 InterpFromMeshToGrid_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(MULTITHREADINGLIB) $(GSLLIB) $(PROJ4LIB) 156 121 157 IssmConfig_la_SOURCES = ../IssmConfig/IssmConfig.cpp\ 158 ../IssmConfig/IssmConfig.h 122 IssmConfig_la_SOURCES = ../IssmConfig/IssmConfig.cpp 159 123 IssmConfig_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) 160 124 161 MeshProfileIntersection_la_SOURCES = ../MeshProfileIntersection/MeshProfileIntersection.cpp\ 162 ../MeshProfileIntersection/MeshProfileIntersection.h 163 MeshProfileIntersection_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 125 MeshProfileIntersection_la_SOURCES = ../MeshProfileIntersection/MeshProfileIntersection.cpp 126 MeshProfileIntersection_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 164 127 165 NodeConnectivity_la_SOURCES = ../NodeConnectivity/NodeConnectivity.cpp\ 166 ../NodeConnectivity/NodeConnectivity.h 167 NodeConnectivity_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 128 NodeConnectivity_la_SOURCES = ../NodeConnectivity/NodeConnectivity.cpp 129 NodeConnectivity_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 168 130 169 StringToEnum_la_SOURCES = ../StringToEnum/StringToEnum.cpp\ 170 ../StringToEnum/StringToEnum.h 171 StringToEnum_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 131 StringToEnum_la_SOURCES = ../StringToEnum/StringToEnum.cpp 132 StringToEnum_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 172 133 173 TriMesh_la_SOURCES = ../TriMesh/TriMesh.cpp\ 174 ../TriMesh/TriMesh.h 175 TriMesh_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(TRIANGLELIB) $(GSLLIB) 134 TriMesh_la_SOURCES = ../TriMesh/TriMesh.cpp 135 TriMesh_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(TRIANGLELIB) $(GSLLIB) $(PROJ4LIB) 176 136 177 TriMeshProcessRifts_la_SOURCES = ../TriMeshProcessRifts/TriMeshProcessRifts.cpp\ 178 ../TriMeshProcessRifts/TriMeshProcessRifts.h 179 TriMeshProcessRifts_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) 137 TriMeshProcessRifts_la_SOURCES = ../TriMeshProcessRifts/TriMeshProcessRifts.cpp 138 TriMeshProcessRifts_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB) 180 139 #}}} -
issm/trunk/src/wrappers/python/include/wrapper_macros.h
r16560 r19105 15 15 /* MODULEBOOT/MODULEEND {{{*/ 16 16 17 /*The following macros hide the error exception handling in a matlabmodule. Just put17 /*The following macros hide the error exception handling in a python module. Just put 18 18 * MODULEBOOT(); and MODULEEND(); at the beginning and end of a module, and c++ exceptions 19 19 * will be trapped*/ -
issm/trunk/src/wrappers/python/io/WritePythonData.cpp
r15396 r19105 35 35 PyObject* array=NULL; 36 36 37 dims[0]=(npy_intp)M; 38 dims[1]=(npy_intp)N; 39 array=PyArray_SimpleNewFromData(2,dims,NPY_DOUBLE,matrix); 37 /*copy matrix: */ 38 double* matrix_python=xNew<double>(M*N); 39 memcpy(matrix_python,matrix,M*N*sizeof(double)); 40 41 dims[0]=(npy_intp)M; 42 dims[1]=(npy_intp)N; 43 array=PyArray_SimpleNewFromData(2,dims,NPY_DOUBLE,matrix_python); 40 44 41 45 PyTuple_SetItem(tuple, index, array); … … 47 51 PyObject* array=NULL; 48 52 49 /*intermediary:*/50 long* lmatrix=NULL;51 int i;52 53 53 /*transform into long matrix: */ 54 l matrix=xNew<long>(M*N);55 for(i =0;i<M*N;i++)lmatrix[i]=(long)matrix[i];54 long* lmatrix=xNew<long>(M*N); 55 for(int i=0;i<M*N;i++)lmatrix[i]=(long)matrix[i]; 56 56 57 57 dims[0]=(npy_intp)M; … … 67 67 PyObject* array=NULL; 68 68 69 dims[0]=(npy_intp)M; 70 dims[1]=(npy_intp)N; 71 array=PyArray_SimpleNewFromData(2,dims,NPY_BOOL,matrix); 69 /*copy matrix: */ 70 bool* matrix_python=xNew<bool>(M*N); 71 memcpy(matrix_python,matrix,M*N*sizeof(bool)); 72 73 dims[0]=(npy_intp)M; 74 dims[1]=(npy_intp)N; 75 array=PyArray_SimpleNewFromData(2,dims,NPY_BOOL,matrix_python); 72 76 73 77 PyTuple_SetItem(tuple, index, array); … … 76 80 void WriteData(PyObject* py_tuple, int index, double* vector, int M){ 77 81 78 double *buffer = NULL;79 82 npy_intp dim = 10; 80 83 PyObject *array = NULL; 81 84 82 /*Copy vector*/ 83 buffer=xNew<double>(M); 84 for(int i=0;i<M;i++)buffer[i]=vector[i]; 85 86 /*copy vector: */ 87 double* vector_python=xNew<double>(M); 88 memcpy(vector_python,vector,M*sizeof(double)); 85 89 86 90 dim=(npy_intp)M; 87 array=PyArray_SimpleNewFromData(1,&dim,NPY_DOUBLE, buffer);91 array=PyArray_SimpleNewFromData(1,&dim,NPY_DOUBLE,vector_python); 88 92 89 93 PyTuple_SetItem(py_tuple, index, array);
Note:
See TracChangeset
for help on using the changeset viewer.