Plugins
Loading...
Searching...
No Matches
integrate_river_outflow.h
Go to the documentation of this file.
1
6#ifndef INTEGRATE_RIVER_OUTFLOW_H
7#define INTEGRATE_RIVER_OUTFLOW_H
8
9#include "common/common.h"
11
12namespace ug {
13namespace d3f {
14
35template <typename TGridFunction>
37 SmartPtr<CplUserData<MathVector<TGridFunction::dim>, TGridFunction::dim>> velocityField,
39 SmartPtr<TGridFunction> gridFunction,
40 const char* bndSubsets,
41 const char* innerSubsets = "",
42 int quadOrder = 1)
43{
44 // --- Subset Preparation ---
45 SubsetGroup bndSSGrp(gridFunction->domain()->subset_handler());
46 bndSSGrp.add(TokenizeString(bndSubsets));
47
48 number totalFlux = 0.0;
49 std::vector<DoFIndex> ind;
50
51 // --- Nodal Integration ---
52 // We iterate over all requested subsets.
53 for (size_t i = 0; i < bndSSGrp.size(); ++i) {
54 const int subsetIndex = bndSSGrp[i];
55 if (subsetIndex == -1) continue;
56
57 auto iter = gridFunction->template begin<Vertex>(subsetIndex);
58 auto iterEnd = gridFunction->template end<Vertex>(subsetIndex);
59
60 for (; iter != iterEnd; ++iter) {
61 Vertex* v = *iter;
62
63 // Retrieve Velocity (v) - Component 1
64 gridFunction->dof_indices(v, 1, ind);
65 const number velocityValue = DoFRef(*gridFunction, ind[0]);
66
67 // Retrieve Area (A) - Component 0
68 gridFunction->dof_indices(v, 0, ind);
69 const number areaValue = DoFRef(*gridFunction, ind[0]);
70
71 // Sum the absolute flux (v * A)
72 totalFlux += std::fabs(velocityValue * areaValue);
73 }
74 }
75
76 return totalFlux;
77}
78
79} // namespace d3f
80} // namespace ug
81
82#endif // INTEGRATE_RIVER_OUTFLOW_H
void add(const char *name)
size_t size() const
vector< string > TokenizeString(const char *str, const char delimiter=',')
double number
number IntegrateRiverOutflow(SmartPtr< CplUserData< MathVector< TGridFunction::dim >, TGridFunction::dim > > velocityField, SmartPtr< CplUserData< number, TGridFunction::dim > > scalarField, SmartPtr< TGridFunction > gridFunction, const char *bndSubsets, const char *innerSubsets="", int quadOrder=1)
Computes the total mass/volume flux through specified river boundary subsets.
Definition integrate_river_outflow.h:36
const number & DoFRef(const TMatrix &mat, const DoFIndex &iInd, const DoFIndex &jInd)