1
<?xml version='1.0' encoding='utf-8'?>
4
<string_value lines="1">mms_adjoint_E</string_value>
8
<integer_value rank="0">1</integer_value>
10
<mesh name="CoordinateMesh">
11
<from_file file_name="mms_E">
12
<format name="triangle"/>
18
<mesh name="VelocityMesh">
20
<mesh name="CoordinateMesh"/>
28
<integer_value rank="0">4</integer_value>
33
<dump_format>vtk</dump_format>
34
<dump_period_in_timesteps>
36
<integer_value rank="0">1</integer_value>
38
</dump_period_in_timesteps>
39
<output_mesh name="VelocityMesh"/>
43
<real_value rank="0">0</real_value>
46
<real_value rank="0">1</real_value>
49
<real_value rank="0">1</real_value>
51
<nonlinear_iterations>
52
<integer_value rank="0">1</integer_value>
53
</nonlinear_iterations>
55
<material_phase name="Fluid">
56
<scalar_field name="Velocity" rank="0">
58
<mesh name="VelocityMesh"/>
59
<temporal_discretisation>
61
<real_value rank="0">0.5</real_value>
64
<real_value rank="0">0.5</real_value>
66
</temporal_discretisation>
68
<iterative_method name="preonly"/>
69
<preconditioner name="lu"/>
71
<real_value rank="0">1e-16</real_value>
74
<real_value rank="0">1e-12</real_value>
77
<integer_value rank="0">10000</integer_value>
79
<never_ignore_solver_failures/>
84
<remove_advection_term/>
85
<initial_condition name="WholeMesh">
87
<string_value lines="20" type="code" language="python">def val(X, t):
88
from math import sin, cos
90
return sin(x) + cos(x)</string_value>
93
<boundary_conditions name="bc">
95
<integer_value shape="2" rank="1">1 2</integer_value>
97
<type name="dirichlet">
99
<string_value lines="20" type="code" language="python">def val(X, t):
100
from math import sin, cos
102
return sin(x) + cos(x)</string_value>
105
</boundary_conditions>
107
<real_value rank="0">1</real_value>
113
<scalar_field name="Source" rank="0">
115
<value name="WholeMesh">
117
<string_value lines="20" type="code" language="python">def val(X, t):
118
from math import sin, cos
121
return y</string_value>
128
<scalar_field name="AnalyticalSolution" rank="0">
130
<mesh name="VelocityMesh"/>
131
<value name="WholeMesh">
133
<string_value lines="20" type="code" language="python">def val(X, t):
134
from math import sin, cos
136
return sin(x) + cos(x)</string_value>
144
<scalar_field name="Error" rank="0">
146
<mesh name="VelocityMesh"/>
147
<algorithm name="scalar_python_diagnostic" material_phase_support="single">
148
<string_value lines="20" type="code" language="python">soln = state.scalar_fields["Velocity"]
149
exact = state.scalar_fields["AnalyticalSolution"]
151
for i in range(field.node_count):
152
field.set(i, abs(soln.node_val(i) - exact.node_val(i)))</string_value>
160
<scalar_field name="funct_derivative" rank="0">
162
<mesh name="VelocityMesh"/>
163
<algorithm name="scalar_python_diagnostic" material_phase_support="single">
164
<string_value lines="20" type="code" language="python">field.val[:] = 0.0
166
coord = state.vector_fields['Coordinate']
167
adj_u = state.scalar_fields['AdjointVelocity']
168
#print "Adjoint velocity(t=1.0): ", adj_u.val
169
for ele in range(coord.element_count):
170
t = Transform(ele, coord)
171
shape = adj_u.ele_shape(ele)
172
mass = t.shape_shape(shape, shape)
173
field.addto(adj_u.ele_nodes(ele), numpy.dot(mass, adj_u.ele_val(ele)))
175
#print "Funct_derivative (diagnostic): ", field.val</string_value>
185
<functional name="time_integral_ad">
187
<algorithm name="functional_value">
188
<string_value lines="20" type="code" language="python">import numpy
193
coord = states[1]["Fluid"].vector_fields["Coordinate"]
194
u = states[1]["Fluid"].scalar_fields["Velocity"]
196
#print "u(t=0): ", states[0]["Fluid"].scalar_fields["Velocity"].val
197
#print "u(t=1): ", states[1]["Fluid"].scalar_fields["Velocity"].val
199
for ele in range(coord.element_count):
200
t = Transform(ele, coord)
201
shape = u.ele_shape(ele)
202
mass = t.shape_shape(shape, shape)
203
J = J + 0.5 * numpy.dot(u.ele_val(ele), numpy.dot(mass, u.ele_val(ele)))
204
# print "Got functional value: ", J
206
#if hasattr(J, "nominal_value"):
207
# print "u.val: ", u.val
208
# print "delJ/delu: ", [J.derivatives[x] for x in u.val]
209
# print "J.nominal_value: ", J.nominal_value</string_value>
215
<functional_dependencies>
216
<algorithm name="functional_dependencies">
217
<string_value lines="20" type="code" language="python">def dependencies(times, timestep):
218
if times[0] <= 1.0 <= times[1]:
219
return {"Fluid::Coordinate": [1],
220
"Fluid::Velocity": [1]}
222
return {}</string_value>
224
</functional_dependencies>
227
<control name="Source">
228
<type field_name="Fluid::VelocitySource" name="source_term"/>
232
<replay_forward_run/>
233
<check_action_transposes/>