diff --git a/dune/stuff/functions/expression.hh b/dune/stuff/functions/expression.hh index 8194f0d0be1feec20f891857a860397ddd5d3e06..46febc12fa8d1f9a75f17713ea1742709c35d5a2 100644 --- a/dune/stuff/functions/expression.hh +++ b/dune/stuff/functions/expression.hh @@ -237,7 +237,7 @@ public: << function_->variable() << "\n" << "The expression of this functional is: " - << expression().at(rr * dimRangeCols + cc) + << function_->expression().at(rr * dimRangeCols + cc) << "\n" << "You tried to evaluate it with: xx = " << xx diff --git a/dune/stuff/functions/expression/base.hh b/dune/stuff/functions/expression/base.hh index c0abd21b2a76918ff0676907dd1f4876b742a93e..d945e10da721b6ba9ae22819629fa14d4f480ae3 100644 --- a/dune/stuff/functions/expression/base.hh +++ b/dune/stuff/functions/expression/base.hh @@ -86,14 +86,13 @@ public: void evaluate(const Dune::FieldVector<DomainFieldType, dimDomain>& arg, Dune::FieldVector<RangeFieldType, dimRange>& ret) const { - mutex_.lock(); + std::lock_guard<std::mutex> guard(mutex_); // copy arg for (typename Dune::FieldVector<DomainFieldType, dimDomain>::size_type ii = 0; ii < dimDomain; ++ii) *(arg_[ii]) = arg[ii]; // copy ret for (typename Dune::FieldVector<RangeFieldType, dimRange>::size_type ii = 0; ii < dimRange; ++ii) ret[ii] = op_[ii]->Val(); - mutex_.unlock(); } /** @@ -101,7 +100,7 @@ public: */ void evaluate(const Dune::DynamicVector<DomainFieldType>& arg, Dune::DynamicVector<RangeFieldType>& ret) const { - mutex_.lock(); + std::lock_guard<std::mutex> guard(mutex_); // check for sizes assert(arg.size() > 0); if (ret.size() != dimRange) @@ -112,13 +111,12 @@ public: // copy ret for (typename Dune::DynamicVector<RangeFieldType>::size_type ii = 0; ii < dimRange; ++ii) ret[ii] = op_[ii]->Val(); - mutex_.unlock(); } void evaluate(const Dune::FieldVector<DomainFieldType, dimDomain>& arg, Dune::DynamicVector<RangeFieldType>& ret) const { - mutex_.lock(); + std::lock_guard<std::mutex> guard(mutex_); // check for sizes if (ret.size() != dimRange) ret = Dune::DynamicVector<RangeFieldType>(dimRange); @@ -128,7 +126,6 @@ public: // copy ret for (typename Dune::DynamicVector<RangeFieldType>::size_type ii = 0; ii < dimRange; ++ii) ret[ii] = op_[ii]->Val(); - mutex_.unlock(); } /** @@ -136,7 +133,7 @@ public: */ void evaluate(const Dune::DynamicVector<DomainFieldType>& arg, Dune::FieldVector<RangeFieldType, dimRange>& ret) const { - mutex_.lock(); + std::lock_guard<std::mutex> guard(mutex_); assert(arg.size() > 0); // copy arg for (size_t ii = 0; ii < std::min(dimDomain, arg.size()); ++ii) @@ -144,7 +141,6 @@ public: // copy ret for (size_t ii = 0; ii < dimRange; ++ii) ret[ii] = op_[ii]->Val(); - mutex_.unlock(); } void report(const std::string _name = "dune.stuff.function.mathexpressionbase", std::ostream& stream = std::cout,