LifeV
test_quadrule.cpp
Go to the documentation of this file.
1 //@HEADER
2 /*
3 *******************************************************************************
4 
5  Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
6  Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
7 
8  This file is part of LifeV.
9 
10  LifeV is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  LifeV is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with LifeV. If not, see <http://www.gnu.org/licenses/>.
22 
23 *******************************************************************************
24 */
25 //@HEADER
26 
27 /*!
28  @file
29  @brief Quadrature Rule test
30 
31  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
32  @author Umberto Villa <uvilla@emory.edu>
33  @contributor
34  @maintainer Umberto Villa <uvilla@emory.edu>
35 
36  @date 02-03-2010
37 
38 The program tests the degree of exactness (DoE) and the convergence rate (CR)
39 of all the quadrature rule in 3D (Tetrahedra) or in 2D (Triangles).
40 
41 The code produce the following output:
42 
43 quadRuleTetra.txt ==> Show the Degree of Exactness of all the quadrature rules on Tetrahedral elements
44 quadRuleTetra.plt ==> Show the Convergence Rate of all the quadrature rules on Tetrahedral elements
45  using gnuplot
46  */
47 
48 #include <Epetra_ConfigDefs.h>
49 #ifdef HAVE_MPI
50 #include <mpi.h>
51 #endif
52 
53 #include <lifev/core/fem/ReferenceFE.hpp>
54 #include <lifev/core/fem/QuadratureRule.hpp>
55 #include <lifev/core/fem/CurrentFE.hpp>
56 #include <lifev/core/filter/GetPot.hpp>
57 #include <lifev/core/mesh/RegionMesh.hpp>
58 #include <lifev/core/mesh/RegionMesh3DStructured.hpp>
59 #include <lifev/core/fem/DOF.hpp>
60 
61 #include "test_quadrule.hpp"
62 
63 int main (int argc, char** argv )
64 {
65  using namespace LifeV;
66 
67 #ifdef HAVE_MPI
68  std::cout << "MPI Initialization" << std::endl;
69  MPI_Init ( &argc, &argv );
70 #endif
71 
72  bool checkGlobal (true), check (true);
73 
74  // All the quadrature rules for tetrahedra
75  container_Type allQuadRuleTetra;
76  allQuadRuleTetra.reserve (5);
77  allQuadRuleTetra.push_back (&quadRuleTetra1pt);
78  allQuadRuleTetra.push_back (&quadRuleTetra4pt);
79  allQuadRuleTetra.push_back (&quadRuleTetra5pt);
80  allQuadRuleTetra.push_back (&quadRuleTetra15pt);
81  allQuadRuleTetra.push_back (&quadRuleTetra64pt);
82 
83  // All the quadrature rules for triangles
84  container_Type allQuadRuleTria;
85  allQuadRuleTria.reserve (5);
86  allQuadRuleTria.push_back (&quadRuleTria1pt);
87  allQuadRuleTria.push_back (&quadRuleTria3pt);
88  allQuadRuleTria.push_back (&quadRuleTria4pt);
89  allQuadRuleTria.push_back (&quadRuleTria6pt);
90  allQuadRuleTria.push_back (&quadRuleTria7pt);
91 
92  // All the quadrature rules for segments
93  container_Type allQuadRuleSegments;
94  allQuadRuleSegments.reserve (3);
95  allQuadRuleSegments.push_back (&quadRuleSeg1pt);
96  allQuadRuleSegments.push_back (&quadRuleSeg2pt);
97  allQuadRuleSegments.push_back (&quadRuleSeg3pt);
98 
99  // Check Quadrature Rule on Tetrahedra
100  check = quad_check_doe< RegionMesh<LinearTetra> > (feTetraP1, geoLinearTetra, allQuadRuleTetra, "quadRuleTetra");
101  checkGlobal = checkGlobal & check;
102  check = quad_check_cr< RegionMesh<LinearTetra> > (feTetraP1, geoLinearTetra, allQuadRuleTetra, "quadRuleTetra");
103  checkGlobal = checkGlobal & check;
104 
105  // Check the quadrature rules for triangles
106  for (constIterator_Type it (allQuadRuleTria.begin() ); it != allQuadRuleTria.end(); ++it)
107  {
108  check = (*it)->degreeOfExactness() == (*it)->checkExactness();
109  checkGlobal = checkGlobal & check;
110  }
111 
112  // Check the quadrature rules for triangles
113  for (constIterator_Type it (allQuadRuleSegments.begin() ); it != allQuadRuleSegments.end(); ++it)
114  {
115  check = (*it)->degreeOfExactness() == (*it)->checkExactness();
116  checkGlobal = checkGlobal & check;
117  }
118 
119 #ifdef HAVE_MPI
120  std::cout << "MPI Finalization" << std::endl;
121  MPI_Finalize();
122 #endif
123 
124 
125  if (check)
126  {
127  return EXIT_SUCCESS;
128  }
129  else
130  {
131  return EXIT_FAILURE;
132  }
133 }//end main
int main(int argc, char **argv)
std::vector< QuadratureRule const * > container_Type