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

use energy norm method from dune-solvers

[[Imported from SVN: r4018]]
parent 410e141e
No related branches found
No related tags found
No related merge requests found
...@@ -18,22 +18,13 @@ ...@@ -18,22 +18,13 @@
#include "src/rodassembler.hh" #include "src/rodassembler.hh"
#include "src/rodsolver.hh" #include "src/rodsolver.hh"
// Number of degrees of freedom: typedef RigidBodyMotion<3> TargetSpace;
// 7 (x, y, z, q_1, q_2, q_3, q_4) for a spatial rod
const int blocksize = 6; const int blocksize = TargetSpace::TangentVector::size;
using namespace Dune; using namespace Dune;
using std::string; using std::string;
double computeEnergyNormSquared(const BlockVector<FieldVector<double,6> >& x,
const BCRSMatrix<FieldMatrix<double, 6, 6> >& matrix)
{
BlockVector<FieldVector<double, 6> > tmp(x.size());
tmp = 0;
matrix.umv(x,tmp);
return x*tmp;
}
int main (int argc, char *argv[]) try int main (int argc, char *argv[]) try
{ {
typedef std::vector<RigidBodyMotion<3> > SolutionType; typedef std::vector<RigidBodyMotion<3> > SolutionType;
...@@ -190,7 +181,7 @@ int main (int argc, char *argv[]) try ...@@ -190,7 +181,7 @@ int main (int argc, char *argv[]) try
// Compute error of the initial iterate // Compute error of the initial iterate
typedef BlockVector<FieldVector<double,6> > RodDifferenceType; typedef BlockVector<FieldVector<double,6> > RodDifferenceType;
RodDifferenceType rodDifference = computeRodDifference(exactSolution, initialIterate); RodDifferenceType rodDifference = computeRodDifference(exactSolution, initialIterate);
double oldError = std::sqrt(computeEnergyNormSquared(rodDifference, hessian)); double oldError = std::sqrt(EnergyNorm<BCRSMatrix<FieldMatrix<double, blocksize, blocksize> >, BlockVector<FieldVector<double,blocksize> > >::normSquared(rodDifference, hessian));
int i; int i;
for (i=0; i<maxTrustRegionSteps; i++) { for (i=0; i<maxTrustRegionSteps; i++) {
...@@ -217,7 +208,7 @@ int main (int argc, char *argv[]) try ...@@ -217,7 +208,7 @@ int main (int argc, char *argv[]) try
rodDifference = computeRodDifference(exactSolution, intermediateSolution); rodDifference = computeRodDifference(exactSolution, intermediateSolution);
error = std::sqrt(computeEnergyNormSquared(rodDifference, hessian)); error = std::sqrt(EnergyNorm<BCRSMatrix<FieldMatrix<double, blocksize, blocksize> >, BlockVector<FieldVector<double,blocksize> > >::normSquared(rodDifference, hessian));
double convRate = error / oldError; double convRate = error / oldError;
......
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