From: Jean-Paul Pelteret Date: Sat, 27 Nov 2021 13:20:27 +0000 (+0100) Subject: Corrected location for a set of assertions. X-Git-Tag: v9.4.0-rc1~703^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f85bece55472ec1254efc539c0c8c27f60581f8;p=dealii.git Corrected location for a set of assertions. 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. --- diff --git a/include/deal.II/differentiation/sd/symengine_optimizer.h b/include/deal.II/differentiation/sd/symengine_optimizer.h index 89e203c647..9133726664 100644 --- a/include/deal.II/differentiation/sd/symengine_optimizer.h +++ b/include/deal.II/differentiation/sd/symengine_optimizer.h @@ -2517,12 +2517,6 @@ namespace Differentiation const Tensor &funcs, const std::vector & 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::evaluate( const Tensor &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 &funcs, const std::vector & 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::evaluate( const SymmetricTensor &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); } diff --git a/source/differentiation/sd/symengine_optimizer.cc b/source/differentiation/sd/symengine_optimizer.cc index db0c0840bb..d82aab1daf 100644 --- a/source/differentiation/sd/symengine_optimizer.cc +++ b/source/differentiation/sd/symengine_optimizer.cc @@ -527,12 +527,6 @@ namespace Differentiation const Expression & func, const std::vector &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::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::evaluate( const std::vector &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); }