Skip to content
Snippets Groups Projects
Commit 90da04da authored by Sander, Oliver's avatar Sander, Oliver
Browse files

Merge branch 'fix-adolc-and-path' into 'master'

Fix adolc and path

See merge request !15
parents 70c23199 9025c733
No related branches found
No related tags found
1 merge request!15Fix adolc and path
Pipeline #2312 failed
......@@ -77,10 +77,10 @@ energy(const typename Basis::LocalView& localView,
const std::vector<TargetSpace>& localSolution) const
{
double pureEnergy;
int rank = localView.globalBasis().gridView().comm().rank();
std::vector<ATargetSpace> localASolution(localSolution.size());
trace_on(1);
trace_on(rank);
adouble energy = 0;
......@@ -106,10 +106,10 @@ energy(const typename Basis::LocalView& localView,
energy >>= pureEnergy;
trace_off();
trace_off(rank);
#if 0
size_t tape_stats[STAT_SIZE];
tapestats(1,tape_stats); // reading of tape statistics
tapestats(rank,tape_stats); // reading of tape statistics
cout<<"maxlive "<<tape_stats[NUM_MAX_LIVES]<<"\n";
cout<<"tay_stack_size "<<tape_stats[TAY_STACK_SIZE]<<"\n";
cout<<"total number of operations "<<tape_stats[NUM_OPERATIONS]<<"\n";
......@@ -128,6 +128,8 @@ assembleGradient(const typename Basis::LocalView& localView,
// Tape energy computation. We may not have to do this every time, but it's comparatively cheap.
energy(localView, localSolution);
int rank = localView.globalBasis().gridView().comm().rank();
// Compute the actual gradient
size_t nDofs = localSolution.size();
size_t nDoubles = nDofs*embeddedBlocksize;
......@@ -137,9 +139,9 @@ assembleGradient(const typename Basis::LocalView& localView,
for (size_t j=0; j<embeddedBlocksize; j++)
xp[idx++] = localSolution[i].globalCoordinates()[j];
// Compute gradient
// 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 TargetSpace::EmbeddedTangentVector> localEmbeddedGradient(localSolution.size());
......@@ -175,6 +177,8 @@ assembleGradientAndHessian(const typename Basis::LocalView& localView,
// Tape energy computation. We may not have to do this every time, but it's comparatively cheap.
energy(localView, localSolution);
int rank = localView.globalBasis().gridView().comm().rank();
/////////////////////////////////////////////////////////////////
// Compute the gradient. It is needed to transform the Hessian
// into the correct coordinates.
......@@ -191,7 +195,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 TargetSpace::EmbeddedTangentVector> localEmbeddedGradient(localSolution.size());
......@@ -255,7 +259,7 @@ assembleGradientAndHessian(const typename Basis::LocalView& localView,
v[i*embeddedBlocksize + k] = orthonormalFrame[i][ii][k];
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 << "!");
......@@ -284,8 +288,7 @@ assembleGradientAndHessian(const typename Basis::LocalView& localView,
for (int i=0; i<embeddedBlocksize; i++)
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++)
......
......@@ -2,7 +2,7 @@
# Grid parameters
#############################################
structuredGrid = true
structuredGrid = cube
# bounding box
lower = 0 0
......
......@@ -130,7 +130,8 @@ int main (int argc, char *argv[]) try
//feenableexcept(FE_INVALID);
Python::runStream()
<< std::endl << "import sys"
<< std::endl << "sys.path.append('/home/sander/dune/dune-gfe/problems/')"
<< std::endl << "import os"
<< std::endl << "sys.path.append(os.getcwd() + '/../../problems/')"
<< std::endl;
using namespace TypeTree::Indices;
......
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