navierStokes.h 1.21 KB
Newer Older
Praetorius, Simon's avatar
Praetorius, Simon committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/** \file navierStokes.h */

#ifndef NAVIER_STOKES_H
#define NAVIER_STOKES_H

#include "AMDiS.h"
#include "GeometryTools.h"

struct InflowBC : AbstractFunction<double, WorldVector<double> >
{
  InflowBC(double H_=4.1, double Um_=1.5) : H(H_), Um(Um_) {}
  double operator()(const WorldVector<double> &x) const {
    return 4.0 * Um * x[1] * (H - x[1]) / sqr(H);
  }
protected:
  double H;
  double Um;
};


class Polygon : public AbstractFunction<double, WorldVector<double> >
{
public:

  Polygon(WorldVector<double> x0_, WorldVector<double> x1_, WorldVector<double> x2_, WorldVector<double> x3_)
  {
    vertices.push_back(x0_);
    vertices.push_back(x1_);
    vertices.push_back(x2_);
    vertices.push_back(x3_);
    vertices.push_back(x0_);
  }

  Polygon(std::vector<WorldVector<double> > xi_) : vertices(xi_) { }

  double operator()(const WorldVector<double>& x) const
  {
    double result = 1.e15;
    for (size_t i = 0; i < vertices.size()-1; i++)
      result = std::min(result, meshconv::distance_point_line_2d(x.begin(), vertices[i].begin(), vertices[i+1].begin()));
    return result * (meshconv::point_in_polygon(x.begin(), vertices) ? -1.0 : 1.0);
  };

private:
  std::vector<WorldVector<double> > vertices;
};

#endif