Skip to content
Snippets Groups Projects
Commit 3a5dcd86 authored by Oliver Sander's avatar Oliver Sander Committed by sander
Browse files

Expect a boost::multiprecision type when MULTIPRECISION is set

[[Imported from SVN: r9914]]
parent be9b35e7
No related branches found
No related tags found
No related merge requests found
...@@ -117,7 +117,11 @@ assembleGradient(const Entity& element, ...@@ -117,7 +117,11 @@ assembleGradient(const Entity& element,
backwardSolution[i] = ATargetSpace::exp(localASolution[i], backwardCorrection); backwardSolution[i] = ATargetSpace::exp(localASolution[i], backwardCorrection);
field_type foo = (localEnergy_->energy(element,localFiniteElement,forwardSolution) - localEnergy_->energy(element,localFiniteElement, backwardSolution)) / (2*eps); field_type foo = (localEnergy_->energy(element,localFiniteElement,forwardSolution) - localEnergy_->energy(element,localFiniteElement, backwardSolution)) / (2*eps);
#ifdef MULTIPRECISION
localGradient[i][j] = foo.template convert_to<double>(); localGradient[i][j] = foo.template convert_to<double>();
#else
localGradient[i][j] = foo;
#endif
} }
...@@ -147,7 +151,11 @@ assembleGradientAndHessian(const Entity& element, ...@@ -147,7 +151,11 @@ assembleGradientAndHessian(const Entity& element,
this->A_ = 0; this->A_ = 0;
#ifdef MULTIPRECISION
const field_type eps = 1e-10; const field_type eps = 1e-10;
#else
const field_type eps = 1e-4;
#endif
std::vector<ATargetSpace> localASolution(localSolution.size()); std::vector<ATargetSpace> localASolution(localSolution.size());
std::vector<typename ATargetSpace::CoordinateType> aRaw(localSolution.size()); std::vector<typename ATargetSpace::CoordinateType> aRaw(localSolution.size());
...@@ -201,7 +209,11 @@ assembleGradientAndHessian(const Entity& element, ...@@ -201,7 +209,11 @@ assembleGradientAndHessian(const Entity& element,
for (int j=0; j<blocksize; j++) for (int j=0; j<blocksize; j++)
{ {
field_type foo = (forwardEnergy[i][j] - backwardEnergy[i][j]) / (2*eps); field_type foo = (forwardEnergy[i][j] - backwardEnergy[i][j]) / (2*eps);
#ifdef MULTIPRECISION
localGradient[i][j] = foo.template convert_to<double>(); localGradient[i][j] = foo.template convert_to<double>();
#else
localGradient[i][j] = foo;
#endif
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
...@@ -242,8 +254,11 @@ assembleGradientAndHessian(const Entity& element, ...@@ -242,8 +254,11 @@ assembleGradientAndHessian(const Entity& element,
field_type backwardValue = localEnergy_->energy(element, localFiniteElement, backwardSolutionXiEta) - backwardEnergy[i][i2] - backwardEnergy[j][j2]; field_type backwardValue = localEnergy_->energy(element, localFiniteElement, backwardSolutionXiEta) - backwardEnergy[i][i2] - backwardEnergy[j][j2];
field_type foo = 0.5 * (forwardValue - 2*centerValue + backwardValue) / (eps*eps); field_type foo = 0.5 * (forwardValue - 2*centerValue + backwardValue) / (eps*eps);
#ifdef MULTIPRECISION
this->A_[i][j][i2][j2] = this->A_[j][i][j2][i2] = foo.template convert_to<double>(); this->A_[i][j][i2][j2] = this->A_[j][i][j2][i2] = foo.template convert_to<double>();
#else
this->A_[i][j][i2][j2] = this->A_[j][i][j2][i2] = foo;
#endif
} }
} }
} }
......
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