1
<?xml version='1.0' encoding='utf8'?>
4
<string_value lines="1">mms_diffusion_adjoint_B</string_value>
8
<integer_value rank="0">1</integer_value>
10
<mesh name="CoordinateMesh">
11
<from_file file_name="mms_B">
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.0</real_value>
46
<real_value rank="0">1.0</real_value>
49
<real_value rank="0">10.0</real_value>
52
<material_phase name="Fluid">
53
<scalar_field name="Velocity" rank="0">
55
<mesh name="VelocityMesh"/>
56
<temporal_discretisation>
58
<real_value rank="0">0.5</real_value>
61
<real_value rank="0">0.5</real_value>
63
</temporal_discretisation>
65
<iterative_method name="gmres">
67
<integer_value rank="0">30</integer_value>
70
<preconditioner name="sor"/>
72
<real_value rank="0">1.0e-16</real_value>
75
<real_value rank="0">1.0e-12</real_value>
78
<integer_value rank="0">10000</integer_value>
80
<never_ignore_solver_failures/>
85
<remove_advection_term/>
86
<initial_condition name="WholeMesh">
88
<string_value lines="20" type="python">def val(X, t):
91
return sin(x+t)</string_value>
94
<boundary_conditions name="bc">
96
<integer_value shape="2" rank="1">1 2</integer_value>
98
<type name="dirichlet">
100
<string_value lines="20" type="python">def val(X, t):
103
return sin(x+t)</string_value>
106
</boundary_conditions>
108
<real_value rank="0">1.0</real_value>
114
<scalar_field name="Source" rank="0">
116
<value name="WholeMesh">
118
<string_value lines="20" type="python">def val(X, t):
119
from math import sin, cos
121
return sin(x+t) + cos(x+t)</string_value>
128
<scalar_field name="AnalyticalSolution" rank="0">
130
<mesh name="VelocityMesh"/>
131
<value name="WholeMesh">
133
<string_value lines="20" type="python">def val(X, t):
136
return sin(x+t)</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="python">soln = state.scalar_fields["Velocity"]
149
exact = state.scalar_fields["AnalyticalSolution"]
150
# The problem is only specified up to a constant, so add on the constant
151
constant = exact.node_val(0) - soln.node_val(0)
153
for i in range(field.node_count):
154
field.set(i, soln.node_val(i) + constant - exact.node_val(i))</string_value>
164
<functional name="time_integral_ad">
166
<algorithm name="functional_value">
167
<string_value lines="20" type="python">import numpy
169
coord = states[0]["Fluid"].vector_fields["Coordinate"]
170
u = states[n]["Fluid"].scalar_fields["Velocity"]
171
u_prev = states[n-1]["Fluid"].scalar_fields["Velocity"]
175
for ele in range(coord.element_count):
176
t = Transform(ele, coord)
177
shape = u.ele_shape(ele)
178
mass = t.shape_shape(shape, shape)
179
int_u = int_u + sum(numpy.dot(mass, u.ele_val(ele)))
180
int_u_prev = int_u_prev + sum(numpy.dot(mass, u_prev.ele_val(ele)))
182
J = dt * (int_u + int_u_prev) * 0.5
183
#if not hasattr(J, "nominal_value"):
184
# print "J(%d): %s" % (n, J)
185
# print "int(u[%d]): %s" % (n, int_u)
186
# print "int(u[%d]): %s" % (n-1, int_u_prev)</string_value>
192
<functional_dependencies>
193
<algorithm name="functional_dependencies">
194
<string_value lines="20" type="python">def dependencies(times, timestep):
195
return {"Fluid::Coordinate": [0],
196
"Fluid::Velocity": [timestep-1, timestep]}</string_value>
198
</functional_dependencies>
200
<functional name="time_integral_hc">
201
<functional_derivative>
202
<algorithm name="functional_derivative">
203
<string_value lines="20" type="python">import numpy
205
if n == 0 or n == len(times) - 1:
210
dt = times[1] - times[0]
212
coord = states[0]["Fluid"].vector_fields["Coordinate"]
213
derivative.val[:] = 0.0
215
if derivative.name == "Fluid::Velocity":
216
for ele in range(coord.element_count):
217
t = Transform(ele, coord)
218
shape = derivative.ele_shape(ele)
219
derivative.addto(derivative.ele_nodes(ele), numpy.dot(shape.n, t.detwei))
221
derivative.val[:] = (dt/2.0) * multiple * derivative.val</string_value>
223
</functional_derivative>
224
<functional_dependencies>
225
<algorithm name="functional_dependencies">
226
<string_value lines="20" type="python">def dependencies(times, timestep):
227
return {"Fluid::Coordinate": [0],
228
"Fluid::Velocity": [timestep-1, timestep]}</string_value>
230
</functional_dependencies>
b'\\ No newline at end of file'