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

Modernize two unit tests

parent fb0fb14c
No related branches found
No related tags found
No related merge requests found
...@@ -23,8 +23,6 @@ using std::string; ...@@ -23,8 +23,6 @@ using std::string;
int main (int argc, char *argv[]) try int main (int argc, char *argv[]) try
{ {
// Some types that I need // Some types that I need
typedef BCRSMatrix<FieldMatrix<double, blocksize, blocksize> > MatrixType;
typedef BlockVector<FieldVector<double, blocksize> > CorrectionType;
typedef std::vector<RigidBodyMotion<double,3> > SolutionType; typedef std::vector<RigidBodyMotion<double,3> > SolutionType;
// Problem settings // Problem settings
...@@ -35,8 +33,10 @@ int main (int argc, char *argv[]) try ...@@ -35,8 +33,10 @@ int main (int argc, char *argv[]) try
// /////////////////////////////////////// // ///////////////////////////////////////
typedef OneDGrid GridType; typedef OneDGrid GridType;
GridType grid(numRodBaseElements, 0, 1); GridType grid(numRodBaseElements, 0, 1);
using GridView = GridType::LeafGridView;
GridView gridView = grid.leafGridView();
SolutionType x(grid.size(1)); SolutionType x(gridView.size(1));
// ////////////////////////// // //////////////////////////
// Initial solution // Initial solution
...@@ -57,10 +57,7 @@ int main (int argc, char *argv[]) try ...@@ -57,10 +57,7 @@ int main (int argc, char *argv[]) try
// Create a second, rotated copy of the configuration // Create a second, rotated copy of the configuration
// ///////////////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////////////
FieldVector<double,3> displacement; FieldVector<double,3> displacement {0, 0, 0};
displacement[0] = 0;
displacement[1] = 0;
displacement[2] = 0;
FieldVector<double,3> axis(0); axis[0]=1; FieldVector<double,3> axis(0); axis[0]=1;
Rotation<double,3> rotation(axis,M_PI/2); Rotation<double,3> rotation(axis,M_PI/2);
...@@ -88,20 +85,20 @@ int main (int argc, char *argv[]) try ...@@ -88,20 +85,20 @@ int main (int argc, char *argv[]) try
writeRod(x,"rod"); writeRod(x,"rod");
writeRod(rotatedX, "rotated"); writeRod(rotatedX, "rotated");
RodLocalStiffness<GridType::LeafGridView,double> assembler(grid.leafGridView(), RodLocalStiffness<GridView,double> assembler(gridView,
1,1,1,1e6,0.3); 1,1,1,1e6,0.3);
for (int i=1; i<2; i++) { for (int i=1; i<2; i++) {
double p = double(i)/2; double p = double(i)/2;
assembler.getStrain(x,*grid.lbegin<0>(0), p); assembler.getStrain(x,*gridView.begin<0>(), p);
assembler.getStrain(rotatedX,*grid.lbegin<0>(0), p); assembler.getStrain(rotatedX,*gridView.begin<0>(), p);
} }
} catch (Exception e) { } catch (Exception e) {
std::cout << e << std::endl; std::cout << e.what() << std::endl;
} }
...@@ -41,19 +41,17 @@ void test() ...@@ -41,19 +41,17 @@ void test()
typedef GlobalGFETestFunctionBasis<P1Basis,TargetSpace> GlobalBasis; typedef GlobalGFETestFunctionBasis<P1Basis,TargetSpace> GlobalBasis;
GlobalBasis basis(p1Basis,testPoints); GlobalBasis basis(p1Basis,testPoints);
typedef typename OneDGrid::Codim<0>::LeafIterator ElementIterator; for (const auto element : elements(grid.leafGridView()))
ElementIterator eIt = grid.leafbegin<0>(); {
ElementIterator eEndIt = grid.leafend<0>(); const typename GlobalBasis::LocalFiniteElement& lfe = basis.getLocalFiniteElement(element);
for (; eIt != eEndIt; ++eIt) {
const typename GlobalBasis::LocalFiniteElement& lfe = basis.getLocalFiniteElement(*eIt);
FieldVector<double,1> stupidTestPoint(0); FieldVector<double,1> stupidTestPoint(0);
std::vector<std::array<typename TargetSpace::EmbeddedTangentVector, TargetSpace::TangentVector::dimension> > values; std::vector<std::array<typename TargetSpace::EmbeddedTangentVector, TargetSpace::TangentVector::dimension> > values;
lfe.localBasis().evaluateFunction(stupidTestPoint, values); lfe.localBasis().evaluateFunction(stupidTestPoint, values);
for(size_t i=0;i<values.size();i++) { for(size_t i=0;i<values.size();i++) {
std::cout<<values[i]<<std::endl; for (auto v : values[i])
std::cout << v << " ";
std::cout << std::endl;
std::cout<<lfe.localCoefficients().localKey(i)<<std::endl; std::cout<<lfe.localCoefficients().localKey(i)<<std::endl;
} }
//int i = basis.index(*eIt,1); //int i = basis.index(*eIt,1);
......
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