Programming tasks to Scientific Computing I
Typedefs | Functions
ex2.cpp File Reference

Main file for 2nd programming exercise. More...

#include <iostream>
#include <Eigen/Dense>
#include <Eigen/Sparse>
#include <Eigen/SparseCholesky>
#include <adaptiveTriangMesh.h>
#include <configuratorsShellFE.h>
#include <EigenDataContainer.h>
#include <quadratureShellFE.h>
#include <legacyVtkWriter.h>
#include <shellHandler.h>
#include <triangleShellFE.h>
#include "errorEstimator.h"

Go to the source code of this file.

Typedefs

typedef double RealType
 
typedef shellFE::ShellElementWithTangentSpaceAtVertex< DataTypeContainerShellFETriangleType
 
typedef shellFE::AdaptiveTriangMesh< DataTypeContainerShellFE, TriangleTypeMeshType
 
typedef shellFE::CenterOfMassQuadrature< RealType, typename DataTypeContainerShellFE::DomVecTypeQuadType
 
typedef shellFE::UnitTriangMeshConfiguratorP1< DataTypeContainerShellFE, MeshType, QuadTypeConfiguratorType
 
typedef ConfiguratorType::VectorType VectorType
 
typedef ConfiguratorType::SparseMatrixType SparseMatrixType
 

Functions

void printHelp ()
 
int main (int argc, char **argv)
 Main function containing the basic structure of the code. More...
 

Detailed Description

Main file for 2nd programming exercise.

Definition in file ex2.cpp.

Typedef Documentation

Definition at line 25 of file ex2.cpp.

Definition at line 23 of file ex2.cpp.

Definition at line 24 of file ex2.cpp.

typedef double RealType

Definition at line 21 of file ex2.cpp.

Definition at line 27 of file ex2.cpp.

Definition at line 22 of file ex2.cpp.

Definition at line 26 of file ex2.cpp.

Function Documentation

int main ( int  argc,
char **  argv 
)

Main function containing the basic structure of the code.

Definition at line 40 of file ex2.cpp.

41 {
42  unsigned int numRefinements = 10;
43  switch (argc) {
44  case 3: {
45  // First two arguments are handled below
46  break;
47  }
48  case 4: {
49  numRefinements = atoi(argv[3]);
50  break;
51  }
52  default: {
53  printHelp();
54  return 1;
55  }
56  }
57 
58  // Load mesh
59  cout << "* Loading grid" << endl;
60  MeshType mesh(argv[1]);
61 
62  cout << "* Refining " << numRefinements << " times ";
63  cout << " [";
64  cout.flush();
65  for (unsigned int r = 0; r < numRefinements; ++r) {
66  // Estimate error and refine mesh
67  ErrorEstimator<ConfiguratorType> errorEstimator(mesh);
68  errorEstimator.markAndRefineTriangles();
69 
70  // Save the mesh and solution as legacy VTK
71  shellFE::LegacyVtkWriter<MeshType> vtkWriter(mesh);
72  std::stringstream outputFileName;
73  outputFileName << argv[2] << r << ".vtk";
74  vtkWriter.save(outputFileName.str().c_str());
75 
76  cout << '|';
77  cout.flush();
78  }
79  cout << "]\n\n";
80 
81  return 0;
82 }
Class for local error estimation.
void printHelp()
Definition: ex2.cpp:29
void printHelp ( )

Definition at line 29 of file ex2.cpp.

30 {
31  cout << "Usage: ex2 meshFile resultFile [numRefinements]\n";
32  cout << "\tmeshFile\tLegacy VTK file defining the Finite Element mesh "
33  << "to use\n";
34  cout << "\tresultFile\tLegacy VTK file to write the result to\n";
35  cout << "\tnumRefinements\tNumber of times the mesh is refined"
36  << " (default: 10)\n\n";
37 }