Closed blattms closed 4 years ago
@Tongdongq could you please take a look?
So in Dune 2.6, UMFPack::UMFPackMatrix
was a ColCompMatrix
, which had a hardcoded int
as index type.
In Dune 2.7, the ColCompMatrix
is templated with a long int
, which is hardcoded in UMFPack::UMFPackMatrix
.
I suppose I should put #if DUNE_VERSION_NEWER(DUNE_ISTL, 2, 7)
where UMFPack data is used?
E.g., just use auto*
instead of int*
for the pointers and use templates for WellContributions::addMultiSegmentWellContribution
?
That would work, but there are functions like umfpack_di_solve
, these have to be replaced with umfpack_dl_solve
when using long int
s. When templating, the whole function would have to be duplicated.
Maybe we could reuse what is already there in DUNE? In dune/istl/umfpack.hh
there is a UMFPackMethodChooser
which might do the correct thing by simply using UMFPackMethodChooser<double>::solve()
and UMFPackMethodChooser<double>::symbolic()
, etc. This might also reduce duplication and ease maintenance.
That would be nicer, but there are some issues. MultisegmentWell::addWellContribution()
creates a Dune::UMFPack<DiagMatWell>
object. Some members of this object are passed to WellContributions
, where they are copied, because that object will go out of scope quickly.
Either the scope needs to be extended, passing the whole Dune::UMFPack
down to MultisegmentWellContribution
to be used during the linear solve. Or things can be duplicated using the if DUNE_VERSION
macro.
To solve the scope issue, I put a shared_ptr
of Dune::UMFPack
in MultisegmentWell
. However, it cannot be initialized with make_shared(Dune::UMFPack<DiagMatWell>(duneD_))
for blocksize = 4.
if you need help, then please tell me the name of your branch such that I can take a look.
I put some tries in reuse-umfpack.
I commented the current implementation out on MultisegmentWell_impl.hpp:671
, and added various implementations to initialize the shared_ptr
. They all result in
error: no matching function for call to ‘std::shared_ptr<Dune::UMFPack<Dune::BCRSMatrix<Dune::FieldMatrix<double, 4, 4>, std::allocator<Dune::FieldMatrix<double, 4, 4> > > > >::reset(Dune::UMFPack<Dune::BCRSMatrix<Dune::FieldMatrix<double, 4, 4>, std::allocator<Dune::FieldMatrix<double, 4, 4> > > >) const’
or something alike during the compilation of flow_xxx.cpp files. It looks like only blocksize 4 gives an error.
Now also an issue for OpenCL
After reading very briefly through this: if the main issue is to handle the type change and associated method name change, we could perhaps do:
#if DUNE >= 2.7 // Yes, this is not the right syntax...
using UMFInt = long int;
auto& UMFsolve = umfpack_dl_solve;
#else
using UMFInt = int;
auto& UMFsolve = umfpack_di_solve;
#endif
Fixed with merge of #2825
With current DUNE master of dune-istl, I get:
Seems like the switch happened last year:
These changes are also included in the 2.7 release and hence I assume that it has the same problem.