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__TrapezoidQuadrature ( ResultsType &  result)
inlinevirtual

Test for ElmerFoamFSI::TrapezoidQuadrature.

Parameters
resultElmerFoamFSI::TestResults object to store test results.

This function implements a simple test of the function ElmerFoamFSI::TrapezoidQuadrature - which is designed to integrate a function, f, over an n-way partitioned 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 195 of file ElmerFoamFSITest.H.

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

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

195  {
196  std::ostringstream Ostr;
197  std::vector<double> E;
198  size_t n = 2*N.size();
199  bool runs = true;
200  for(std::vector<int>::iterator i = N.begin();i != N.end();i++){
201  double Ii = 0.0;
202  try {
204  } catch (...) {
205  runs = false;
206  }
207  E.push_back(std::fabs(Ii-1.0));
208  }
209  bool order2 = (E[0] < 1e-14);
210  for(std::vector<int>::iterator i = N.begin();i != N.end();i++){
211  double Ii = 0.0;
212  try {
214  } catch (...) {
215  runs = false;
216  }
217  E.push_back(std::fabs(Ii-1.0));
218  }
219  result.UpdateResult("TrapezoidQuadrature:Runs",runs);
220  result.UpdateResult("TrapezoidQuadrature:Accurate",E[n-1] < 1e-12);
221  for(int i = N.size();i < n - 1;i++){
222  double e = E[i+1]/E[i];
223  double n1 = static_cast<double>(N[i-N.size()])/static_cast<double>(N[(i-N.size())+1]);
224  double p = std::log(e)/std::log(n1);
225  p -= 2;
226  p = std::abs(p);
227  if(p > 2e-2){
228  order2 = false;
229  }
230  }
231  result.UpdateResult("TrapezoidQuadrature:Order2",order2);
232  }
std::vector< int > N
A set of values for testing quadrature methods.
double F2(double x)
Simple test function fixture returns .
double F1(double x)
Simple test function fixture returns .
double TrapezoidQuadrature(double(*f)(double), double x0, double xn, int n)
Integrates f with composite trapezoid rule.

Here is the call graph for this function:

Here is the caller graph for this function: