51 #include <Epetra_SerialComm.h> 54 #include <lifev/core/LifeV.hpp> 55 #include <lifev/core/fem/QuadratureRule.hpp> 61 typedef boost::numeric::ublas::vector<Real> Vector;
66 template<
typename Mesh>
69 std::shared_ptr<Epetra_Comm> dummyComm (
new Epetra_SerialComm );
70 Mesh aMesh ( dummyComm );
72 regularMesh3D ( aMesh, 1, nEl, nEl, nEl);
75 int nquadrule = allQuad.size();
77 output_file = output_file +
".txt";
78 std::ofstream ofile (output_file.c_str() );
81 for (Int nqr (0); nqr < nquadrule; ++nqr)
84 CurrentFE fe (refFE, geoMap, *allQuad[nqr]);
85 ofile <<
"*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_" << std::endl;
86 ofile << allQuad[nqr]->name() << std::endl;
87 ofile <<
"Degree of Exactness: " << allQuad[nqr]->degreeOfExactness() << std::endl;
88 ofile <<
"*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_" << std::endl;
90 ofile <<
"polynomial \t\t test \t quadrature error" << std::endl;
92 for (UInt fun (0); fun < fct.nfun(); ++fun)
95 for (UInt i = 0; i < aMesh.numElements(); ++i)
97 fe.updateJacQuadPt (aMesh.element (i) );
99 for ( UInt ig (0); ig < fe.nbQuadPt(); ++ig )
101 fe.coorQuadPt ( x, y, z, ig );
102 s += fct.val ( fun, x, y, z) * fe.weightDet ( ig );
107 err = integral - fct.ex_int (fun);
109 if (fct.degree (fun) <= allQuad[nqr]->degreeOfExactness() )
111 if (std::fabs (err) < 1e-9)
114 ofile << fct.name (fun) <<
" \t passed \t (" << err <<
")" << std::endl;
119 ofile << fct.name (fun) <<
" \t FAILED \t (" << err <<
")" << std::endl;
124 ofile << std::endl << std::endl;
130 template<
typename Mesh>
131 bool quad_check_cr (
const ReferenceFE& refFE,
const GeometricMap& geoMap,
const container_Type& allQuad, std::string output_name)
133 std::shared_ptr<Epetra_Comm> dummyComm (
new Epetra_SerialComm );
135 int fun (fct.nfun() );
140 for (
int i = 0; i < nrefine; ++i)
142 h (i) = std::pow (.5, i);
145 int nquadrule = allQuad.size();
146 boost::numeric::ublas::matrix<
double> err (nrefine, nquadrule + 1);
148 for (
int iref = 0; iref < nrefine; ++iref)
151 Mesh aMesh ( dummyComm );
152 UInt nEl ( std::pow (2.0,
static_cast<
double> (iref) ) );
153 regularMesh3D ( aMesh, 1, nEl, nEl, nEl);
155 err (iref, 0) = h (iref);
156 for (
int iqr = 0; iqr < nquadrule; ++iqr)
164 CurrentFE fe (refFE, geoMap, *allQuad[iqr]);
166 for (UInt i = 0; i < aMesh.numElements(); ++i)
168 fe.updateJacQuadPt (aMesh.element (i) );
169 Real s = 0., x, y, z;
170 for ( UInt ig (0); ig < fe.nbQuadPt(); ++ig )
172 fe.coorQuadPt ( x, y, z, ig );
173 s += fct.val ( fun, x, y, z) * fe.weightDet ( ig );
177 err (iref, iqr + 1) = std::fabs (integral - fct.ex_int (fun) );
185 fname = output_name +
".dat";
186 std::ofstream ofile (fname.c_str() );
187 for (
int i = 0; i < nrefine; ++i)
189 for (
int j = 0; j < nquadrule + 1; ++j)
191 ofile << err (i, j) <<
" \t";
197 fname = output_name +
".plt";
198 std::ofstream ofile (fname.c_str() );
199 ofile <<
"set timestamp" << std::endl;
200 ofile <<
"set logscale" << std::endl;
202 for (
int i = 0; i < nquadrule; ++i)
204 ofile <<
"\"" << output_name <<
".dat\" using 1:" << i + 2 <<
" with linespoints title '" << allQuad[i]->name() <<
"' ,\\" << std::endl;
206 ofile <<
"\"" << output_name <<
".dat\" using 1:($1*$1) with lines title 'order 2', \\" << std::endl;
207 ofile <<
"\"" << output_name <<
".dat\" using 1:($1**4) with lines title 'order 4', \\" << std::endl;
208 ofile <<
"\"" << output_name <<
".dat\" using 1:($1**6) with lines title 'order 6'";
GeometricMap - Structure for the geometrical mapping.
bool quad_check_doe(const ReferenceFE &refFE, const GeometricMap &geoMap, const container_Type &allQuad, std::string output_file)
container_Type::const_iterator constIterator_Type
The class for a reference Lagrangian finite element.
std::vector< QuadratureRule const * > container_Type