示例#1
0
 def _ad_convert_type(self, value, options={}):
     if value is None:
         # TODO: Should the default be 0 constant here or return just None?
         return Constant(numpy.zeros(self.ufl_shape))
     value = gather(value)
     value = compat.constant_function_firedrake_compat(value)
     return constant_from_values(self, value)
示例#2
0
 def evaluate_adj_component(self, inputs, adj_inputs, block_variable, idx, prepared=None):
     adj_output = adj_inputs[0]
     if self.assigned_float:
         # Convert to float
         adj_output = gather(adj_output)
         adj_output = float(adj_output[0])
     elif self.assigned_list:
         adj_output = prepared[self.dependency_to_index[idx]]
     return adj_output
示例#3
0
 def prepare_evaluate_adj(self, inputs, adj_inputs, relevant_dependencies):
     if self.assigned_list:
         return gather(adj_inputs[0])
     return None
示例#4
0
 def _ad_convert_type(self, value, options={}):
     if value is None:
         # TODO: Should the default be 0 constant here or return just None?
         return type(self)(numpy.zeros(self.ufl_shape))
     value = gather(value)
     return self._constant_from_values(value)