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

Parameters
resultElmerModuleDriver::TestResults object to store test results.

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

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

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

179  {
180  std::ostringstream Ostr;
181  std::vector<double> E;
182  size_t n = 2*N.size();
183  bool runs = true;
184  for(std::vector<int>::iterator i = N.begin();i != N.end();i++){
185  double Ii = 0.0;
186  try {
188  } catch (...) {
189  runs = false;
190  }
191  E.push_back(std::fabs(Ii-1.0));
192  }
193  bool order2 = (E[0] < 1e-14);
194  for(std::vector<int>::iterator i = N.begin();i != N.end();i++){
195  double Ii = 0.0;
196  try {
198  } catch (...) {
199  runs = false;
200  }
201  E.push_back(std::fabs(Ii-1.0));
202  }
203  result.UpdateResult("TrapezoidQuadrature:Runs",runs);
204  result.UpdateResult("TrapezoidQuadrature:Accurate",E[n-1] < 1e-12);
205  for(int i = N.size();i < n - 1;i++){
206  double e = E[i+1]/E[i];
207  double n1 = static_cast<double>(N[i-N.size()])/static_cast<double>(N[(i-N.size())+1]);
208  double p = std::log(e)/std::log(n1);
209  p -= 2;
210  p = std::abs(p);
211  if(p > 2e-2){
212  order2 = false;
213  }
214  }
215  result.UpdateResult("TrapezoidQuadrature:Order2",order2);
216  }
double TrapezoidQuadrature(double(*f)(double), double x0, double xn, int n)
Integrates f with composite trapezoid rule.
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 .

Here is the call graph for this function:

Here is the caller graph for this function: