KASKADE 7 development version
Loading...
Searching...
No Matches
fluid.hh
Go to the documentation of this file.
1
2/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
3/* */
4/* This file is part of the library KASKADE 7 */
5/* https://www.zib.de/research/projects/kaskade7-finite-element-toolbox */
6/* */
7/* Copyright (C) 2023-2025 Zuse Institute Berlin */
8/* */
9/* KASKADE 7 is distributed under the terms of the ZIB Academic License. */
10/* see $KASKADE/academic.txt */
11/* */
12/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13
14#ifndef FLUID_HH
15#define FLUID_HH
16
17namespace Kaskade
18{
24 template <class Function>
25 auto vorticity(Function const& f)
26 {
27 return makeWeakFunctionView([&](auto const& cell, auto const& xi)
28 {
29 auto df = f.value(cell,xi);
30 static_assert(df.rows==df.cols,"vorticity requires vector fields");
31 if constexpr (df.rows==2)
32 return Dune::FieldVector<df::field_type,1>(df[1][0]-df[0][1]);
33 if constexpr (df.rows==3)
34 return Dune::FieldVector<df::field_type,3>{df[2][1]-df[1][2],
35 df[0][2]-df[2][0],
36 df[1][0]-df[0][1]};
37 });
38 }
39
40}
41
42#endif
Function is the interface for evaluatable functions .
Definition concepts.hh:324
ValueType value(Cell const &cell, Dune::FieldVector< typename Cell::Geometry::ctype, Cell::dimension > const &localCoordinate) const
auto vorticity(Function const &f)
Creates a weak function view representing the vorticity of a 2D or 3D vector field.
Definition fluid.hh:25
auto makeWeakFunctionView(Functor const &g)
A convenience function turning callables (e.g., lambda functions) into weak function views.