From aaf3c893c1f8f0a588d375920b86ffd4807ee53d Mon Sep 17 00:00:00 2001 From: Lisa Julia Nebel <lisa_julia.nebel@tu-dresden.de> Date: Wed, 1 Jul 2020 09:59:14 +0200 Subject: [PATCH] Use the rank as the ADOL-C tape number (mixedlocalgfeadolcstiffness) This makes it possible to do parallel assembly --- dune/gfe/mixedlocalgfeadolcstiffness.hh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dune/gfe/mixedlocalgfeadolcstiffness.hh b/dune/gfe/mixedlocalgfeadolcstiffness.hh index c668f3ac..75a34a0a 100644 --- a/dune/gfe/mixedlocalgfeadolcstiffness.hh +++ b/dune/gfe/mixedlocalgfeadolcstiffness.hh @@ -86,12 +86,13 @@ energy(const typename Basis::LocalView& localView, const std::vector<TargetSpace0>& localConfiguration0, const std::vector<TargetSpace1>& localConfiguration1) const { + int rank = Dune::MPIHelper::getCollectiveCommunication().rank(); double pureEnergy; std::vector<ATargetSpace0> localAConfiguration0(localConfiguration0.size()); std::vector<ATargetSpace1> localAConfiguration1(localConfiguration1.size()); - trace_on(1); + trace_on(rank); adouble energy = 0; @@ -201,6 +202,7 @@ assembleGradientAndHessian(const typename Basis::LocalView& localView, std::vector<typename TargetSpace0::TangentVector>& localGradient0, std::vector<typename TargetSpace1::TangentVector>& localGradient1) { + int rank = Dune::MPIHelper::getCollectiveCommunication().rank(); // Tape energy computation. We may not have to do this every time, but it's comparatively cheap. energy(localView, localConfiguration0, localConfiguration1); @@ -226,7 +228,7 @@ assembleGradientAndHessian(const typename Basis::LocalView& localView, // Compute gradient std::vector<double> g(nDoubles); - gradient(1,nDoubles,xp.data(),g.data()); // gradient evaluation + gradient(rank,nDoubles,xp.data(),g.data()); // gradient evaluation // Copy into Dune type std::vector<typename TargetSpace0::EmbeddedTangentVector> localEmbeddedGradient0(localConfiguration0.size()); @@ -342,7 +344,7 @@ assembleGradientAndHessian(const typename Basis::LocalView& localView, for (int i=0; i<embeddedBlocksize1; i++) tangent[nDofs0*embeddedBlocksize0 + (j/blocksize1)*embeddedBlocksize1+i][nDofs0*blocksize0 + j] = orthonormalFrame1[j/blocksize1][j%blocksize1][i]; - hess_mat(1,nDoubles,nDirections,xp.data(),tangent,rawHessian); + hess_mat(rank,nDoubles,nDirections,xp.data(),tangent,rawHessian); // Copy Hessian into Dune data type size_t offset0 = nDofs0*embeddedBlocksize0; -- GitLab