1 
2 
3 // DO NOT EDIT !
4 // This file is generated using the MantaFlow preprocessor (prep generate).
5 
6 /******************************************************************************
7  *
8  * MantaFlow fluid solver framework
9  * Copyright 2011 Tobias Pfaff, Nils Thuerey
10  *
11  * This program is free software, distributed under the terms of the
12  * Apache License, Version 2.0
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Vortex sheets
16  * (warning, the vortex methods are currently experimental, and not fully supported!)
17  *
18  ******************************************************************************/
19 
20 #include "vortexsheet.h"
21 #include "solvana.h"
22 
23 using namespace std;
24 namespace Manta {
25 
26 // *****************************************************************************
27 // VorticityChannel class members
28 
29 // *****************************************************************************
30 // VortexSheet Mesh class members
31 
VortexSheetMesh(FluidSolver * parent)32 VortexSheetMesh::VortexSheetMesh(FluidSolver *parent) : Mesh(parent), mTexOffset(0.0f)
33 {
34   addTriChannel(&mVorticity);
35   addNodeChannel(&mTex1);
36   addNodeChannel(&mTex2);
37   addNodeChannel(&mTurb);
38 }
39 
clone()40 Mesh *VortexSheetMesh::clone()
41 {
42   VortexSheetMesh *nm = new VortexSheetMesh(mParent);
43   *nm = *this;
44   nm->setName(getName());
45   return nm;
46 }
47 
calcVorticity()48 void VortexSheetMesh::calcVorticity()
49 {
50   for (size_t tri = 0; tri < mTris.size(); tri++) {
51     VortexSheetInfo &v = mVorticity.data[tri];
52     Vec3 e0 = getEdge(tri, 0), e1 = getEdge(tri, 1), e2 = getEdge(tri, 2);
53     Real area = getFaceArea(tri);
54 
55     if (area < 1e-10) {
56       v.smokeAmount = 0;
57       v.vorticity = 0;
58     }
59     else {
60       v.smokeAmount = 0;
61       v.vorticity = (v.circulation[0] * e0 + v.circulation[1] * e1 + v.circulation[2] * e2) / area;
62     }
63   }
64 }
65 
calcCirculation()66 void VortexSheetMesh::calcCirculation()
67 {
68   for (size_t tri = 0; tri < mTris.size(); tri++) {
69     VortexSheetInfo &v = mVorticity.data[tri];
70     Vec3 e0 = getEdge(tri, 0), e1 = getEdge(tri, 1), e2 = getEdge(tri, 2);
71     Real area = getFaceArea(tri);
72 
73     if (area < 1e-10 || normSquare(v.vorticity) < 1e-10) {
74       v.circulation = 0;
75       continue;
76     }
77 
78     float cx, cy, cz;
79     SolveOverconstraint34(e0.x,
80                           e0.y,
81                           e0.z,
82                           e1.x,
83                           e1.y,
84                           e1.z,
85                           e2.x,
86                           e2.y,
87                           e2.z,
88                           v.vorticity.x,
89                           v.vorticity.y,
90                           v.vorticity.z,
91                           cx,
92                           cy,
93                           cz);
94     v.circulation = Vec3(cx, cy, cz) * area;
95   }
96 }
97 
resetTex1()98 void VortexSheetMesh::resetTex1()
99 {
100   for (size_t i = 0; i < mNodes.size(); i++)
101     mTex1.data[i] = mNodes[i].pos + mTexOffset;
102 }
103 
resetTex2()104 void VortexSheetMesh::resetTex2()
105 {
106   for (size_t i = 0; i < mNodes.size(); i++)
107     mTex2.data[i] = mNodes[i].pos + mTexOffset;
108 }
109 
reinitTexCoords()110 void VortexSheetMesh::reinitTexCoords()
111 {
112   resetTex1();
113   resetTex2();
114 }
115 
116 };  // namespace Manta
117