source: issm/trunk-jpl/src/py3/consistency/ismodelselfconsistent.py@ 19895

Last change on this file since 19895 was 19895, checked in by bdef, 9 years ago

NEW:Adding directory to hold the python 3 implementation of the interface

File size: 3.1 KB
Line 
1from EnumDefinitions import *
2from EnumToString import EnumToString
3
4def AnalysisConfiguration(solutiontype): #{{{
5 """
6 ANALYSISCONFIGURATION - return type of analyses, number of analyses
7
8 Usage:
9 [analyses]=AnalysisConfiguration(solutiontype);
10 """
11
12 if solutiontype == StressbalanceSolutionEnum():
13 analyses=[StressbalanceAnalysisEnum(),StressbalanceVerticalAnalysisEnum(),StressbalanceSIAAnalysisEnum(),L2ProjectionBaseAnalysisEnum()]
14
15 elif solutiontype == SteadystateSolutionEnum():
16 analyses=[StressbalanceAnalysisEnum(),StressbalanceVerticalAnalysisEnum(),StressbalanceSIAAnalysisEnum(),L2ProjectionBaseAnalysisEnum(),ThermalAnalysisEnum(),MeltingAnalysisEnum()]
17
18 elif solutiontype == ThermalSolutionEnum():
19 analyses=[EnthalpyAnalysisEnum(),ThermalAnalysisEnum(),MeltingAnalysisEnum()]
20
21 elif solutiontype == MasstransportSolutionEnum():
22 analyses=[MasstransportAnalysisEnum()]
23
24 elif solutiontype == BalancethicknessSolutionEnum():
25 analyses=[BalancethicknessAnalysisEnum()]
26
27 elif solutiontype == SurfaceSlopeSolutionEnum():
28 analyses=[L2ProjectionBaseAnalysisEnum()]
29
30 elif solutiontype == BalancevelocitySolutionEnum():
31 analyses=[BalancevelocityAnalysisEnum()]
32
33 elif solutiontype == BedSlopeSolutionEnum():
34 analyses=[L2ProjectionBaseAnalysisEnum()]
35
36 elif solutiontype == GiaSolutionEnum():
37 analyses=[GiaAnalysisEnum()]
38
39 elif solutiontype == TransientSolutionEnum():
40 analyses=[StressbalanceAnalysisEnum(),StressbalanceVerticalAnalysisEnum(),StressbalanceSIAAnalysisEnum(),L2ProjectionBaseAnalysisEnum(),ThermalAnalysisEnum(),MeltingAnalysisEnum(),EnthalpyAnalysisEnum(),MasstransportAnalysisEnum()]
41
42 elif solutiontype == FlaimSolutionEnum():
43 analyses=[FlaimAnalysisEnum()]
44
45 elif solutiontype == HydrologySolutionEnum():
46 analyses=[L2ProjectionBaseAnalysisEnum(),HydrologyShreveAnalysisEnum(),HydrologyDCInefficientAnalysisEnum(),HydrologyDCEfficientAnalysisEnum()]
47
48 elif DamageEvolutionSolutionEnum():
49 analyses=[DamageEvolutionAnalysisEnum()]
50
51 else:
52 raise TypeError("solution type: '%s' not supported yet!" % EnumToString(solutiontype)[0])
53
54 return analyses
55#}}}
56
57def ismodelselfconsistent(md):
58 """
59 ISMODELSELFCONSISTENT - check that model forms a closed form solvable problem.
60
61 Usage:
62 ismodelselfconsistent(md),
63 """
64
65 #initialize consistency as true
66 md.private.isconsistent=True
67
68 #Get solution and associated analyses
69 solution=md.private.solution
70 analyses=AnalysisConfiguration(solution)
71
72 #Go through a model fields, check that it is a class, and call checkconsistency
73 fields=vars(md)
74# for field in fields.iterkeys():
75 for field in md.properties():
76
77 #Some properties do not need to be checked
78 if field in ['results','debug','radaroverlay']:
79 continue
80
81 #Check that current field is an object
82 if not hasattr(getattr(md,field),'checkconsistency'):
83 md.checkmessage("field '%s' is not an object." % field)
84
85 #Check consistency of the object
86 exec("md.%s.checkconsistency(md,solution,analyses)" % field)
87
88 #error message if mode is not consistent
89 if not md.private.isconsistent:
90 raise RuntimeError('Model not consistent, see messages above.')
91
Note: See TracBrowser for help on using the repository browser.