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 ElmerModuleDriver::MidPointQuadrature.

Parameters
resultElmerModuleDriver::TestResults object to store test results.

This function implements a simple test of the function ElmerModuleDriver::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 231 of file ElmerModuleDriverTest.H.

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

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

231  {
232  std::ostringstream Ostr;
233  std::vector<double> Ibar;
234  std::vector<double> E;
235  size_t n = 2*N.size();
236  bool runs = true;
237  bool order2 = true;
238  for(std::vector<int>::iterator i = N.begin();i != N.end();i++){
239  double Ii = 0.0;
240  try {
242  } catch (...) {
243  runs = false;
244  }
245  Ibar.push_back(Ii);
246  E.push_back(std::fabs(Ii-1.0));
247  }
248  order2 = (E[0] < 1e-14);
249  for(std::vector<int>::iterator i = N.begin();i != N.end();i++){
250  double Ii = 0.0;
251  try {
253  } catch (...) {
254  runs = false;
255  }
256  Ibar.push_back(Ii);
257  E.push_back(std::fabs(Ii-1.0));
258  }
259  result.UpdateResult("MidPointQuadrature:Runs",runs);
260  result.UpdateResult("MidPointQuadrature:Accurate",E[n-1] < 1e-12);
261  for(int i = N.size();i < n - 1;i++){
262  double e = E[i+1]/E[i];
263  double n1 = static_cast<double>(N[i-N.size()])/static_cast<double>(N[(i-N.size())+1]);
264  double p = std::log(e)/std::log(n1);
265  p -= 2;
266  p = std::abs(p);
267  if(p > 1e-2){
268  order2 = false;
269  }
270  }
271  result.UpdateResult("MidPointQuadrature:Order2",order2);
272  }
std::vector< int > N
A set of values for testing quadrature methods.
double F2(double x)
Simple test function fixture returns .
double MidPointQuadrature(double(*f)(double), double x0, double xn, int n)
Integrates f with composite midpoint rule.
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: