ElmerFoamFSI  2.0
ElmerFoamFSI is fluid-solid interaction simulation application built up from OpenFOAM CFD and Elmer CSM coupled through the IMPACT multiphysics software integration infrastructure.
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Macros Groups Pages
virtual void Test__MidPointQuadrature ( ResultsType &  result)
inlinevirtual

Test for ElmerFoamFSI::MidPointQuadrature.

Parameters
resultElmerFoamFSI::TestResults object to store test results.

This function implements a simple test of the function ElmerFoamFSI::MidPointQuadrature - which is designed to integrate a function, f, over an interval $[x_0,x_n]$.

The test first makes sure that the method integrates a linear function exactly, and then that the error term has the proper dependence on the spacings.

Definition at line 247 of file ElmerFoamFSITest.H.

References ElmerFoamFSI::TestFixture::F1(), ElmerFoamFSI::TestFixture::F2(), ElmerFoamFSI::MidPointQuadrature(), and TestingObject< ResultsType >::N.

Referenced by TestingObject< ResultsType >::Process(), and TestingObject< ResultsType >::RunTest().

247  {
248  std::ostringstream Ostr;
249  std::vector<double> Ibar;
250  std::vector<double> E;
251  size_t n = 2*N.size();
252  bool runs = true;
253  bool order2 = true;
254  for(std::vector<int>::iterator i = N.begin();i != N.end();i++){
255  double Ii = 0.0;
256  try {
258  } catch (...) {
259  runs = false;
260  }
261  Ibar.push_back(Ii);
262  E.push_back(std::fabs(Ii-1.0));
263  }
264  order2 = (E[0] < 1e-14);
265  for(std::vector<int>::iterator i = N.begin();i != N.end();i++){
266  double Ii = 0.0;
267  try {
269  } catch (...) {
270  runs = false;
271  }
272  Ibar.push_back(Ii);
273  E.push_back(std::fabs(Ii-1.0));
274  }
275  result.UpdateResult("MidPointQuadrature:Runs",runs);
276  result.UpdateResult("MidPointQuadrature:Accurate",E[n-1] < 1e-12);
277  for(int i = N.size();i < n - 1;i++){
278  double e = E[i+1]/E[i];
279  double n1 = static_cast<double>(N[i-N.size()])/static_cast<double>(N[(i-N.size())+1]);
280  double p = std::log(e)/std::log(n1);
281  p -= 2;
282  p = std::abs(p);
283  if(p > 1e-2){
284  order2 = false;
285  }
286  }
287  result.UpdateResult("MidPointQuadrature:Order2",order2);
288  }
std::vector< int > N
A set of values for testing quadrature methods.
double MidPointQuadrature(double(*f)(double), double x0, double xn, int n)
Integrates f with composite midpoint rule.
double F2(double x)
Simple test function fixture returns .
double F1(double x)
Simple test function fixture returns .

Here is the call graph for this function:

Here is the caller graph for this function: