Programming tasks to Scientific Computing I
ex2.cpp
Go to the documentation of this file.
1 
5 #include <iostream>
6 
7 #include <Eigen/Dense>
8 #include <Eigen/Sparse>
9 #include <Eigen/SparseCholesky>
10 
11 #include <adaptiveTriangMesh.h>
12 #include <configuratorsShellFE.h>
13 #include <EigenDataContainer.h>
14 #include <quadratureShellFE.h>
15 #include <legacyVtkWriter.h>
16 #include <shellHandler.h>
17 #include <triangleShellFE.h>
18 #include "errorEstimator.h"
19 
20 // typedefs for better code readability
21 typedef double RealType;
28 
29 void printHelp()
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 }
38 
40 int main(int argc, char **argv)
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 }
DataTypeContainer::VectorType VectorType
shellFE::UnitTriangMeshConfiguratorP1< DataTypeContainerShellFE, MeshType, QuadType > ConfiguratorType
Definition: ex2.cpp:25
Class for local error estimation.
Different quadrature types for triangular meshes.
shellFE::CenterOfMassQuadrature< RealType, typename DataTypeContainerShellFE::DomVecType > QuadType
Definition: ex2.cpp:24
int main(int argc, char **argv)
Main function containing the basic structure of the code.
Definition: ex2.cpp:40
DataTypeContainer::SparseMatrixType SparseMatrixType
void printHelp()
Definition: ex2.cpp:29
RealType markAndRefineTriangles()
shellFE::ShellElementWithTangentSpaceAtVertex< DataTypeContainerShellFE > TriangleType
Definition: ex2.cpp:22
double RealType
Definition: ex2.cpp:21
ConfiguratorType::VectorType VectorType
Definition: ex2.cpp:26
void save(string filename) const
ConfiguratorType::SparseMatrixType SparseMatrixType
Definition: ex2.cpp:27
Eigen typedefs for use with the TriangleMesh.
Configurator for Finite Elements.
Triangle which has a tangent space at each node.
shellFE::AdaptiveTriangMesh< DataTypeContainerShellFE, TriangleType > MeshType
Definition: ex2.cpp:23