Commit 8b0d9ae1 authored by Oliver Sander's avatar Oliver Sander Committed by sander@FU-BERLIN.DE
Browse files

Replace old class name 'Configuration' by 'RigidBodyMotion'

This code shouldn't be here: it depends on dune-gfe

[[Imported from SVN: r10581]]
parent 8418b5c4
...@@ -3,21 +3,23 @@ ...@@ -3,21 +3,23 @@
#define ABORT_ON_ERROR #define ABORT_ON_ERROR
void infinitesimalVariation(Configuration& c, double eps, int i) #include <dune/gfe/rigidbodymotion.hh>
void infinitesimalVariation(RigidBodyMotion<3>& c, double eps, int i)
{ {
if (i<3) if (i<3)
c.r[i] += eps; c.r[i] += eps;
else else
c.q = c.q.mult(Quaternion<double>::exp((i==3)*eps, c.q = c.q.mult(Rotation<3,double>::exp((i==3)*eps,
(i==4)*eps, (i==4)*eps,
(i==5)*eps)); (i==5)*eps));
} }
template <class GridType> template <class GridType>
void strainFD(const std::vector<Configuration>& x, void strainFD(const std::vector<RigidBodyMotion<3> >& x,
double pos, double pos,
Dune::array<Dune::FieldMatrix<double,2,6>, 6>& fdStrainDerivatives, Dune::array<Dune::FieldMatrix<double,2,6>, 6>& fdStrainDerivatives,
const RodAssembler<GridType>& assembler) const RodAssembler<GridType,3>& assembler)
{ {
assert(x.size()==2); assert(x.size()==2);
double eps = 1e-8; double eps = 1e-8;
...@@ -27,8 +29,8 @@ void strainFD(const std::vector<Configuration>& x, ...@@ -27,8 +29,8 @@ void strainFD(const std::vector<Configuration>& x,
// /////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////
// Compute gradient by finite-difference approximation // Compute gradient by finite-difference approximation
// /////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////
std::vector<Configuration> forwardSolution = x; std::vector<RigidBodyMotion<3> > forwardSolution = x;
std::vector<Configuration> backwardSolution = x; std::vector<RigidBodyMotion<3> > backwardSolution = x;
for (size_t i=0; i<x.size(); i++) { for (size_t i=0; i<x.size(); i++) {
...@@ -59,11 +61,11 @@ void strainFD(const std::vector<Configuration>& x, ...@@ -59,11 +61,11 @@ void strainFD(const std::vector<Configuration>& x,
template <class GridType> template <class GridType>
void strain2ndOrderFD(const std::vector<Configuration>& x, void strain2ndOrderFD(const std::vector<RigidBodyMotion<3> >& x,
double pos, double pos,
Dune::array<Dune::Matrix<Dune::FieldMatrix<double,6,6> >, 3>& translationDer, Dune::array<Dune::Matrix<Dune::FieldMatrix<double,6,6> >, 3>& translationDer,
Dune::array<Dune::Matrix<Dune::FieldMatrix<double,3,3> >, 3>& rotationDer, Dune::array<Dune::Matrix<Dune::FieldMatrix<double,3,3> >, 3>& rotationDer,
const RodAssembler<GridType>& assembler) const RodAssembler<GridType,3>& assembler)
{ {
assert(x.size()==2); assert(x.size()==2);
double eps = 1e-3; double eps = 1e-3;
...@@ -83,13 +85,13 @@ void strain2ndOrderFD(const std::vector<Configuration>& x, ...@@ -83,13 +85,13 @@ void strain2ndOrderFD(const std::vector<Configuration>& x,
// /////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////
// Compute gradient by finite-difference approximation // Compute gradient by finite-difference approximation
// /////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////
std::vector<Configuration> forwardSolution = x; std::vector<RigidBodyMotion<3> > forwardSolution = x;
std::vector<Configuration> backwardSolution = x; std::vector<RigidBodyMotion<3> > backwardSolution = x;
std::vector<Configuration> forwardForwardSolution = x; std::vector<RigidBodyMotion<3> > forwardForwardSolution = x;
std::vector<Configuration> forwardBackwardSolution = x; std::vector<RigidBodyMotion<3> > forwardBackwardSolution = x;
std::vector<Configuration> backwardForwardSolution = x; std::vector<RigidBodyMotion<3> > backwardForwardSolution = x;
std::vector<Configuration> backwardBackwardSolution = x; std::vector<RigidBodyMotion<3> > backwardBackwardSolution = x;
for (int i=0; i<2; i++) { for (int i=0; i<2; i++) {
...@@ -168,13 +170,13 @@ void strain2ndOrderFD(const std::vector<Configuration>& x, ...@@ -168,13 +170,13 @@ void strain2ndOrderFD(const std::vector<Configuration>& x,
template <class GridType> template <class GridType>
void strain2ndOrderFD2(const std::vector<Configuration>& x, void strain2ndOrderFD2(const std::vector<RigidBodyMotion<3> >& x,
double pos, double pos,
Dune::FieldVector<double,1> shapeGrad[2], Dune::FieldVector<double,1> shapeGrad[2],
Dune::FieldVector<double,1> shapeFunction[2], Dune::FieldVector<double,1> shapeFunction[2],
Dune::array<Dune::Matrix<Dune::FieldMatrix<double,6,6> >, 3>& translationDer, Dune::array<Dune::Matrix<Dune::FieldMatrix<double,6,6> >, 3>& translationDer,
Dune::array<Dune::Matrix<Dune::FieldMatrix<double,3,3> >, 3>& rotationDer, Dune::array<Dune::Matrix<Dune::FieldMatrix<double,3,3> >, 3>& rotationDer,
const RodAssembler<GridType>& assembler) const RodAssembler<GridType,3>& assembler)
{ {
assert(x.size()==2); assert(x.size()==2);
double eps = 1e-3; double eps = 1e-3;
...@@ -192,8 +194,8 @@ void strain2ndOrderFD2(const std::vector<Configuration>& x, ...@@ -192,8 +194,8 @@ void strain2ndOrderFD2(const std::vector<Configuration>& x,
// /////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////
// Compute gradient by finite-difference approximation // Compute gradient by finite-difference approximation
// /////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////
std::vector<Configuration> forwardSolution = x; std::vector<RigidBodyMotion<3> > forwardSolution = x;
std::vector<Configuration> backwardSolution = x; std::vector<RigidBodyMotion<3> > backwardSolution = x;
for (int k=0; k<2; k++) { for (int k=0; k<2; k++) {
...@@ -263,9 +265,9 @@ void expHessianFD() ...@@ -263,9 +265,9 @@ void expHessianFD()
// - 2*assembler.computeEnergy(x) // - 2*assembler.computeEnergy(x)
// + assembler.computeEnergy(backward)) / (eps*eps); // + assembler.computeEnergy(backward)) / (eps*eps);
hessian = Quaternion<double>::exp(forward); hessian = Rotation<3,double>::exp(forward);
hessian += Quaternion<double>::exp(backward); hessian += Rotation<3,double>::exp(backward);
hessian.axpy(-2, Quaternion<double>::exp(0,0,0)); hessian.axpy(-2, Rotation<3,double>::exp(0,0,0));
hessian /= eps*eps; hessian /= eps*eps;
} else { } else {
...@@ -283,10 +285,10 @@ void expHessianFD() ...@@ -283,10 +285,10 @@ void expHessianFD()
backwardBackward[j] -= eps; backwardBackward[j] -= eps;
hessian = Quaternion<double>::exp(forwardForward); hessian = Rotation<3,double>::exp(forwardForward);
hessian += Quaternion<double>::exp(backwardBackward); hessian += Rotation<3,double>::exp(backwardBackward);
hessian -= Quaternion<double>::exp(forwardBackward); hessian -= Rotation<3,double>::exp(forwardBackward);
hessian -= Quaternion<double>::exp(backwardForward); hessian -= Rotation<3,double>::exp(backwardForward);
hessian /= 4*eps*eps; hessian /= 4*eps*eps;
} }
...@@ -301,9 +303,9 @@ void expHessianFD() ...@@ -301,9 +303,9 @@ void expHessianFD()
template <class GridType> template <class GridType>
void gradientFDCheck(const std::vector<Configuration>& x, void gradientFDCheck(const std::vector<RigidBodyMotion<3> >& x,
const Dune::BlockVector<Dune::FieldVector<double,6> >& gradient, const Dune::BlockVector<Dune::FieldVector<double,6> >& gradient,
const RodAssembler<GridType>& assembler) const RodAssembler<GridType,3>& assembler)
{ {
#ifndef ABORT_ON_ERROR #ifndef ABORT_ON_ERROR
static int gradientError = 0; static int gradientError = 0;
...@@ -315,8 +317,8 @@ void gradientFDCheck(const std::vector<Configuration>& x, ...@@ -315,8 +317,8 @@ void gradientFDCheck(const std::vector<Configuration>& x,
// Compute gradient by finite-difference approximation // Compute gradient by finite-difference approximation
// /////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////
std::vector<Configuration> forwardSolution = x; std::vector<RigidBodyMotion<3> > forwardSolution = x;
std::vector<Configuration> backwardSolution = x; std::vector<RigidBodyMotion<3> > backwardSolution = x;
for (size_t i=0; i<x.size(); i++) { for (size_t i=0; i<x.size(); i++) {
...@@ -358,9 +360,9 @@ void gradientFDCheck(const std::vector<Configuration>& x, ...@@ -358,9 +360,9 @@ void gradientFDCheck(const std::vector<Configuration>& x,
template <class GridType> template <class GridType>
void hessianFDCheck(const std::vector<Configuration>& x, void hessianFDCheck(const std::vector<RigidBodyMotion<3> >& x,
const Dune::BCRSMatrix<Dune::FieldMatrix<double,6,6> >& hessian, const Dune::BCRSMatrix<Dune::FieldMatrix<double,6,6> >& hessian,
const RodAssembler<GridType>& assembler) const RodAssembler<GridType,3>& assembler)
{ {
#ifndef ABORT_ON_ERROR #ifndef ABORT_ON_ERROR
static int hessianError = 0; static int hessianError = 0;
...@@ -372,13 +374,13 @@ void hessianFDCheck(const std::vector<Configuration>& x, ...@@ -372,13 +374,13 @@ void hessianFDCheck(const std::vector<Configuration>& x,
// /////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////
// Compute gradient by finite-difference approximation // Compute gradient by finite-difference approximation
// /////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////
std::vector<Configuration> forwardSolution = x; std::vector<RigidBodyMotion<3> > forwardSolution = x;
std::vector<Configuration> backwardSolution = x; std::vector<RigidBodyMotion<3> > backwardSolution = x;
std::vector<Configuration> forwardForwardSolution = x; std::vector<RigidBodyMotion<3> > forwardForwardSolution = x;
std::vector<Configuration> forwardBackwardSolution = x; std::vector<RigidBodyMotion<3> > forwardBackwardSolution = x;
std::vector<Configuration> backwardForwardSolution = x; std::vector<RigidBodyMotion<3> > backwardForwardSolution = x;
std::vector<Configuration> backwardBackwardSolution = x; std::vector<RigidBodyMotion<3> > backwardBackwardSolution = x;
// /////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment