Skip to content
Snippets Groups Projects
Commit 94265a24 authored by Oliver Sander's avatar Oliver Sander Committed by sander@FU-BERLIN.DE
Browse files

bugfix: properly implement secondDerivativeOfDistanceSquaredWRTFirstAndSecondArgument

[[Imported from SVN: r7048]]
parent 22058299
No related branches found
No related tags found
No related merge requests found
...@@ -199,16 +199,13 @@ public: ...@@ -199,16 +199,13 @@ public:
*/ */
static Dune::FieldMatrix<double,N,N> secondDerivativeOfDistanceSquaredWRTFirstAndSecondArgument(const UnitVector& a, const UnitVector& b) { static Dune::FieldMatrix<double,N,N> secondDerivativeOfDistanceSquaredWRTFirstAndSecondArgument(const UnitVector& a, const UnitVector& b) {
Dune::FieldMatrix<double,N,N> result;
double sp = a.data_ * b.data_; double sp = a.data_ * b.data_;
// Compute vector A (see notes) // Compute vector A (see notes)
Dune::FieldMatrix<double,1,N> row; Dune::FieldMatrix<double,1,N> row;
row[0] = b.globalCoordinates(); row[0] = b.projectOntoTangentSpace(a.globalCoordinates());
row *= secondDerivativeOfArcCosSquared(sp);
Dune::FieldVector<double,N> tmp = b.projectOntoTangentSpace(a.globalCoordinates()); Dune::FieldVector<double,N> tmp = a.projectOntoTangentSpace(b.globalCoordinates());
Dune::FieldMatrix<double,N,1> column; Dune::FieldMatrix<double,N,1> column;
for (int i=0; i<N; i++) // turn row vector into column vector for (int i=0; i<N; i++) // turn row vector into column vector
column[i] = tmp[i]; column[i] = tmp[i];
...@@ -216,21 +213,23 @@ public: ...@@ -216,21 +213,23 @@ public:
Dune::FieldMatrix<double,N,N> A; Dune::FieldMatrix<double,N,N> A;
// A = row * column // A = row * column
Dune::FMatrixHelp::multMatrix(column,row,A); Dune::FMatrixHelp::multMatrix(column,row,A);
A *= secondDerivativeOfArcCosSquared(sp);
// Compute matrix B (see notes) // Compute matrix B (see notes)
Dune::FieldMatrix<double,N,N> B; Dune::FieldMatrix<double,N,N> Pp, Pq;
for (int i=0; i<N; i++) for (int i=0; i<N; i++)
for (int j=0; j<N; j++) for (int j=0; j<N; j++) {
B[i][j] = (i==j) - b.data_[i]*b.data_[j]; Pp[i][j] = (i==j) - a.data_[i]*a.data_[j];
Pq[i][j] = (i==j) - b.data_[i]*b.data_[j];
}
Dune::FieldMatrix<double,N,N> B;
Dune::FMatrixHelp::multMatrix(Pp,Pq,B);
// Bring it all together // Bring it all together
result = A; A.axpy(derivativeOfArcCosSquared(sp), B);
result.axpy(derivativeOfArcCosSquared(sp), B);
for (int i=0; i<N; i++) return A;
result[i] = a.projectOntoTangentSpace(result[i]);
return result;
} }
......
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