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
Third_Party_Modules/ElmerFSI/trunk/src/ExampleSourceFile.C
Go to the documentation of this file.
1 // Doxygen processes all comments with an extra
16 // "/". Comments at the top of the file as above
17 // are interpreted by Doxygen as the documentation
18 // for the file. While two-slash comments like these
19 // are ignored.
20 #include <cmath>
21 #include "ExampleHeader.H"
22 
23 
24 namespace ElmerModuleDriver {
25 
26  // Note that the doxygen documentation for this function is with the function
27  // prototype in the ExampleHeader.H. If this were a substantial function, then
28  // the regular inline code comments can be used to comment the actual implementation
29  // while doxygen documentation (with the exception of that for the *file* itself)
30  // can be entirely inside the header files, or even outside of any source file.
31  std::string ExampleFunction(const std::string &instring)
32  {
33  return(instring);
34  };
35 
36 
37  // Quadrature by the trapezoid rule
38  // This function integrates f from x0 to xn using n partitions of the domain
39  double TrapezoidQuadrature(double (*f)(double),double x0,double xn,int n)
40  {
41  double h = (xn - x0)/(static_cast<double>(n));
42  if(std::fabs(h) < 1e-12) throw 1;
43  double sum = .5*(f(x0)+f(xn));
44  for(int i = 1; i < n;i++)
45  sum += f(x0 + i*h);
46  return(h*sum);
47  };
48 
49  // Quadrature by the midpoint rule
50  // This function integrates f from x0 to xn using n partitions of the domain
51  double MidPointQuadrature(double (*f)(double),double x0,double xn,int n)
52  {
53  double h = (xn - x0)/(static_cast<double>(n));
54  if(std::fabs(h) < 1e-12) throw 1;
55  double sum = 0.0;
56  for(int i = 1;i <= n;i++)
57  sum += f(x0+((static_cast<double>(i)-.5)*h));
58  return(h*sum);
59  }
60 }
double TrapezoidQuadrature(double(*f)(double), double x0, double xn, int n)
Integrates f with composite trapezoid rule.
std::string ExampleFunction(const std::string &instring)
Example function for ElmerModuleDriver (this is a brief description).
double MidPointQuadrature(double(*f)(double), double x0, double xn, int n)
Integrates f with composite midpoint rule.