示例#1
0
 def postprocess_snapshot(self, snapshot_over_time, snapshot_index):
     postprocessed_snapshot = TimeSeries(snapshot_over_time)
     for (k, t) in enumerate(snapshot_over_time.stored_times()):
         self.reduced_problem.set_time(t)
         postprocessed_snapshot_k = DifferentialProblemReductionMethod_DerivedClass.postprocess_snapshot(
             self, snapshot_over_time[k], snapshot_index)
         postprocessed_snapshot.append(postprocessed_snapshot_k)
     return postprocessed_snapshot
示例#2
0
 def _compute_relative_error_output(self, absolute_error_output_over_time, **kwargs):
     relative_error_output_over_time = TimeSeries(self._output_over_time)
     assert len(self.truth_problem._output_over_time) == len(absolute_error_output_over_time)
     for (k, t) in enumerate(self.truth_problem._output_over_time.stored_times()):
         self.set_time(t)
         self.truth_problem._output = self.truth_problem._output_over_time[k]
         relative_error_output = ParametrizedReducedDifferentialProblem_DerivedClass._compute_relative_error_output(self, absolute_error_output_over_time[k], **kwargs)
         relative_error_output_over_time.append(relative_error_output)
     return relative_error_output_over_time
 def project(self,
             snapshot_over_time,
             N=None,
             on_dirichlet_bc=True,
             **kwargs):
     projected_snapshot_N_over_time = TimeSeries(snapshot_over_time)
     for snapshot in snapshot_over_time:
         projected_snapshot_N = ParametrizedReducedDifferentialProblem_DerivedClass.project(
             self, snapshot, N, on_dirichlet_bc, **kwargs)
         projected_snapshot_N_over_time.append(projected_snapshot_N)
     return projected_snapshot_N_over_time
示例#4
0
 def _compute_relative_error(self, absolute_error_over_time, **kwargs):
     relative_error_over_time = TimeSeries(self._solution_over_time)
     assert len(self._solution_over_time) == len(absolute_error_over_time)
     for (k, t) in enumerate(self.truth_problem._solution_over_time.stored_times()):
         self.set_time(t)
         assign(self.truth_problem._solution, self.truth_problem._solution_over_time[k])
         absolute_error = self._convert_error_at_time(k, absolute_error_over_time)
         relative_error = ParametrizedReducedDifferentialProblem_DerivedClass._compute_relative_error(self, absolute_error, **kwargs)
         relative_error_over_time.append(relative_error)
     relative_error_over_time = self._convert_error_over_time(relative_error_over_time)
     return relative_error_over_time
 def postprocess_snapshot(self, snapshot_over_time, snapshot_index):
     # Call parent: this will solve for supremizers at each time step
     snapshot_and_supremizer_over_time = AbstractCFDUnsteadyReductionMethod_Base.postprocess_snapshot(self, snapshot_over_time, snapshot_index)
     # Convert from a time series of tuple (snapshot, supremizer) to a tuple of two lists (snapshot over time, supremizer over time)
     supremizer_over_time = TimeSeries(snapshot_over_time)
     for (k, snapshot_and_supremizer) in enumerate(snapshot_and_supremizer_over_time):
         assert isinstance(snapshot_and_supremizer, tuple)
         assert len(snapshot_and_supremizer) is 2
         assert snapshot_and_supremizer[0] is snapshot_over_time[k]
         supremizer_over_time.append(snapshot_and_supremizer[1])
     # Return a tuple
     return (snapshot_over_time, supremizer_over_time)
示例#6
0
 def estimate_error(self):
     eps2_over_time = self.get_residual_norm_squared()
     alpha = self.get_stability_factor()
     # Compute error bound
     error_bound_over_time = TimeSeries(eps2_over_time)
     for (k, t) in enumerate(eps2_over_time.stored_times()):
         if not isclose(t, self.t0, self.dt/2.):
             eps2 = eps2_over_time[k]
             assert eps2 >= 0. or isclose(eps2, 0.)
             assert alpha >= 0.
             error_bound_over_time.append(sqrt(abs(eps2)/alpha))
         else:
             initial_error_estimate_squared = self.get_initial_error_estimate_squared()
             assert initial_error_estimate_squared >= 0. or isclose(initial_error_estimate_squared, 0.)
             error_bound_over_time.append(sqrt(abs(initial_error_estimate_squared)))
     #
     return error_bound_over_time
示例#7
0
 def get_residual_norm_squared(self):
     residual_norm_squared_over_time = TimeSeries(
         self._solution_over_time)
     assert len(self._solution_over_time) == len(
         self._solution_dot_over_time)
     for (k, t) in enumerate(self._solution_over_time.stored_times()):
         if not isclose(t, self.t0, self.dt / 2.):
             # Set current time
             self.set_time(t)
             # Set current solution and solution_dot
             assign(self._solution, self._solution_over_time[k])
             assign(self._solution_dot, self._solution_dot_over_time[k])
             # Compute the numerator of the error bound at the current time, first
             # by computing residual of elliptic part
             elliptic_residual_norm_squared = AbstractParabolicRBReducedProblem_Base.get_residual_norm_squared(
                 self)
             # ... and then adding terms related to time derivative
             N = self._solution.N
             theta_m = self.compute_theta("m")
             theta_a = self.compute_theta("a")
             theta_f = self.compute_theta("f")
             residual_norm_squared_over_time.append(
                 elliptic_residual_norm_squared + 2.0 *
                 (transpose(self._solution_dot) * sum(
                     product(
                         theta_m, self.error_estimation_operator[
                             "m", "f"][:N], theta_f))) + 2.0 *
                 (transpose(self._solution_dot) * sum(
                     product(
                         theta_m, self.error_estimation_operator[
                             "m", "a"][:N, :N], theta_a)) *
                  self._solution) +
                 (transpose(self._solution_dot) * sum(
                     product(
                         theta_m, self.error_estimation_operator[
                             "m", "m"][:N, :N], theta_m)) *
                  self._solution_dot))
         else:
             # Error estimator on initial condition does not use the residual
             residual_norm_squared_over_time.append(0.)
     return residual_norm_squared_over_time