Skip to content
Snippets Groups Projects
Commit 91552bbb authored by lisa_julia.nebel_at_tu-dresden.de's avatar lisa_julia.nebel_at_tu-dresden.de Committed by oliver.sander_at_tu-dresden.de
Browse files

Use process number for the ADOLC tape number

Previously the tape number was hard-wired to '1'.  Using the
process number instead avoid two processes writing to the
same tape file.
parent d8887c56
No related branches found
No related tags found
1 merge request!23Various minor improvements by Lisa
......@@ -68,11 +68,12 @@ energy(const Entity& element,
const LocalFiniteElement& localFiniteElement,
const VectorType& localSolution) const
{
int rank = Dune::MPIHelper::getCollectiveCommunication().rank();
double pureEnergy;
std::vector<Dune::FieldVector<adouble,blocksize> > localASolution(localSolution.size());
trace_on(1);
trace_on(rank);
adouble energy = 0;
......@@ -84,7 +85,7 @@ energy(const Entity& element,
energy >>= pureEnergy;
trace_off();
trace_off(rank);
return pureEnergy;
}
......@@ -103,6 +104,7 @@ assembleGradientAndHessian(const Entity& element,
const VectorType& localSolution,
VectorType& localGradient)
{
int rank = Dune::MPIHelper::getCollectiveCommunication().rank();
// Tape energy computation. We may not have to do this every time, but it's comparatively cheap.
energy(element, localFiniteElement, localSolution);
......@@ -121,7 +123,7 @@ assembleGradientAndHessian(const Entity& element,
// 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
localGradient.resize(localSolution.size());
......@@ -151,7 +153,7 @@ assembleGradientAndHessian(const Entity& element,
v[i*blocksize + k] = (k==ii);
int rc= 3;
MINDEC(rc, hess_vec(1, nDoubles, xp.data(), v.data(), w.data()));
MINDEC(rc, hess_vec(rank, nDoubles, xp.data(), v.data(), w.data()));
if (rc < 0)
DUNE_THROW(Dune::Exception, "ADOL-C has returned with error code " << rc << "!");
......@@ -181,7 +183,7 @@ assembleGradientAndHessian(const Entity& element,
tangent[(j/blocksize)*embeddedBlocksize+i][j] = orthonormalFrame[j/blocksize][j%blocksize][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
for(size_t i=0; i<nDoubles; i++)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment