Commit fd23afb1 authored by Andreas Nüßing's avatar Andreas Nüßing

[CutCell] add mutex to function space

We add a mutex to enable thread safe access to the unfitted function
spaces. As we currently modify the finiteelementmap when assembling
the right hand sides, the access need to be mutually exclusive in the
multithreaded solver.
parent 6f8add3c
......@@ -121,6 +121,13 @@ namespace duneuro
return *problem_;
}
#if HAVE_TBB
tbb::mutex& functionSpaceMutex()
{
return fsMutex_;
}
#endif
private:
std::shared_ptr<typename Traits::SubTriangulation> subTriangulation_;
std::shared_ptr<typename Traits::Problem> problem_;
......@@ -132,6 +139,10 @@ namespace duneuro
typename Traits::RawGridOperator rawGridOperator_;
typename Traits::GridOperator gridOperator_;
typename Traits::LinearSolver linearSolver_;
#if HAVE_TBB
tbb::mutex fsMutex_;
#endif
};
}
......
#ifndef DUNEURO_UDG_SOLVER_HH
#define DUNEURO_UDG_SOLVER_HH
#if HAVE_TBB
#include <tbb/tbb.h>
#endif
#include <dune/udg/pdelab/multiphaseoperator.hh>
#include <dune/udg/pdelab/operator.hh>
#include <dune/udg/pdelab/subtriangulation.hh>
......@@ -114,6 +118,13 @@ namespace duneuro
return *problem_;
}
#if HAVE_TBB
tbb::mutex& functionSpaceMutex()
{
return fsMutex_;
}
#endif
private:
std::shared_ptr<typename Traits::SubTriangulation> subTriangulation_;
std::shared_ptr<typename Traits::Problem> problem_;
......@@ -124,6 +135,10 @@ namespace duneuro
typename Traits::UnfittedSubTriangulation unfittedSubTriangulation_;
typename Traits::GridOperator gridOperator_;
typename Traits::LinearSolver linearSolver_;
#if HAVE_TBB
tbb::mutex fsMutex_;
#endif
};
}
......
......@@ -104,7 +104,14 @@ namespace duneuro
{
using SVC = typename Traits::SparseRHSVector;
SVC rhs;
#if HAVE_TBB
{
tbb::mutex::scoped_lock lock(solver_->functionSpaceMutex());
sparseSourceModel_->assembleRightHandSide(rhs);
}
#else
sparseSourceModel_->assembleRightHandSide(rhs);
#endif
const auto blockSize = Traits::Solver::Traits::FunctionSpace::blockSize;
......@@ -127,7 +134,14 @@ namespace duneuro
} else {
*denseRHSVector_ = 0.0;
}
#if HAVE_TBB
{
tbb::mutex::scoped_lock lock(solver_->functionSpaceMutex());
denseSourceModel_->assembleRightHandSide(*denseRHSVector_);
}
#else
denseSourceModel_->assembleRightHandSide(*denseRHSVector_);
#endif
return matrix_dense_vector_product(transferMatrix,
Dune::PDELab::Backend::native(*denseRHSVector_));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment