]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Corrected location for a set of assertions.
authorJean-Paul Pelteret <jppelteret@gmail.com>
Sat, 27 Nov 2021 13:20:27 +0000 (14:20 +0100)
committerJean-Paul Pelteret <jppelteret@gmail.com>
Sun, 26 Dec 2021 18:18:51 +0000 (19:18 +0100)
When the SD::BatchOptimizer is provided with a cache from which the evaluated functions are to be extracted, then it is not actually necessary for the optimiser instance that is performing this operation to have had any values substituted.

include/deal.II/differentiation/sd/symengine_optimizer.h
source/differentiation/sd/symengine_optimizer.cc

index 89e203c647938056fdfb5ff0dfb407c5242cfd35..9133726664f8ee1e49f03490f56d2b2fdb9f75ab 100644 (file)
@@ -2517,12 +2517,6 @@ namespace Differentiation
       const Tensor<rank, dim, Expression> &funcs,
       const std::vector<ReturnType> &      cached_evaluation) const
     {
-      Assert(
-        values_substituted() == true,
-        ExcMessage(
-          "The optimizer is not configured to perform evaluation. "
-          "This action can only performed after substitute() has been called."));
-
       return internal::tensor_evaluate_optimized(funcs,
                                                  cached_evaluation,
                                                  *this);
@@ -2536,6 +2530,12 @@ namespace Differentiation
     BatchOptimizer<ReturnType>::evaluate(
       const Tensor<rank, dim, Expression> &funcs) const
     {
+      Assert(
+        values_substituted() == true,
+        ExcMessage(
+          "The optimizer is not configured to perform evaluation. "
+          "This action can only performed after substitute() has been called."));
+
       return extract(funcs, dependent_variables_output);
     }
 
@@ -2548,12 +2548,6 @@ namespace Differentiation
       const SymmetricTensor<rank, dim, Expression> &funcs,
       const std::vector<ReturnType> &               cached_evaluation) const
     {
-      Assert(
-        values_substituted() == true,
-        ExcMessage(
-          "The optimizer is not configured to perform evaluation. "
-          "This action can only performed after substitute() has been called."));
-
       return internal::tensor_evaluate_optimized(funcs,
                                                  cached_evaluation,
                                                  *this);
@@ -2567,6 +2561,12 @@ namespace Differentiation
     BatchOptimizer<ReturnType>::evaluate(
       const SymmetricTensor<rank, dim, Expression> &funcs) const
     {
+      Assert(
+        values_substituted() == true,
+        ExcMessage(
+          "The optimizer is not configured to perform evaluation. "
+          "This action can only performed after substitute() has been called."));
+
       return extract(funcs, dependent_variables_output);
     }
 
index db0c0840bbc91e6dcc6a0166edc7ba5f40431784..d82aab1dafa67adb23a690d757fa6ba88878f0fd 100644 (file)
@@ -527,12 +527,6 @@ namespace Differentiation
       const Expression &             func,
       const std::vector<ReturnType> &cached_evaluation) const
     {
-      Assert(
-        values_substituted() == true,
-        ExcMessage(
-          "The optimizer is not configured to perform evaluation. "
-          "This action can only performed after substitute() has been called."));
-
       // TODO[JPP]: Find a way to fix this bug that crops up in serialization
       // cases, e.g. symengine/batch_optimizer_05. Even though the entry is
       // in the map, it can only be found by an exhaustive search and string
@@ -624,6 +618,12 @@ namespace Differentiation
     ReturnType
     BatchOptimizer<ReturnType>::evaluate(const Expression &func) const
     {
+      Assert(
+        values_substituted() == true,
+        ExcMessage(
+          "The optimizer is not configured to perform evaluation. "
+          "This action can only performed after substitute() has been called."));
+
       return extract(func, dependent_variables_output);
     }
 
@@ -651,6 +651,11 @@ namespace Differentiation
     BatchOptimizer<ReturnType>::evaluate(
       const std::vector<Expression> &funcs) const
     {
+      Assert(
+        values_substituted() == true,
+        ExcMessage(
+          "The optimizer is not configured to perform evaluation. "
+          "This action can only performed after substitute() has been called."));
       return extract(funcs, dependent_variables_output);
     }
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.