/** \file navierStokes.h */ #ifndef NAVIER_STOKES_H #define NAVIER_STOKES_H #include "AMDiS.h" #include "Views.h" #include "GeometryTools.h" struct InflowBC : AbstractFunction > { InflowBC(double H_=4.1, double Um_=1.5) : H(H_), Um(Um_) {} double operator()(const WorldVector &x) const { return 4.0 * Um * x[1] * (H - x[1]) / sqr(H); } protected: double H; double Um; }; class Polygon : public AbstractFunction > { public: Polygon(WorldVector x0_, WorldVector x1_, WorldVector x2_, WorldVector x3_) { vertices.push_back(x0_); vertices.push_back(x1_); vertices.push_back(x2_); vertices.push_back(x3_); vertices.push_back(x0_); } Polygon(std::vector > xi_) : vertices(xi_) { } double operator()(const WorldVector& 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); } void refine(int np) { std::vector > newVertices; for (size_t i = 0; i < vertices.size()-1; i++) { for (size_t j = 0; j < np-1; j++) { double lambda = static_cast(j)/static_cast(np - 1.0); WorldVector p = lambda*vertices[i+1] + (1.0-lambda)*vertices[i]; newVertices.push_back(p); } } swap(vertices, newVertices); } void move(const DOFVector >* velocity) { for (size_t i = 0; i < vertices.size()-1; i++) { WorldVector shift = evalAtPoint(*velocity, vertices[i]); vertices[i] += shift; } vertices[vertices.size()-1] = vertices[0]; } void move(AbstractFunction, WorldVector >* velocity) { for (size_t i = 0; i < vertices.size()-1; i++) { WorldVector shift = (*velocity)(vertices[i]); vertices[i] += shift; } vertices[vertices.size()-1] = vertices[0]; } private: std::vector > vertices; }; #endif