Skip to content
Snippets Groups Projects
Commit 12963113 authored by Tobias Leibner's avatar Tobias Leibner
Browse files

[functions.expression] use lock_guard and fix merge error

parent f0639bde
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment