Welcome to mirror list, hosted at ThFree Co, Russian Federation.

vortexsheet.cpp « preprocessed « mantaflow « extern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 695b881006de8ff12b94a2fb1cd96129153021d0 (plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116


// DO NOT EDIT !
// This file is generated using the MantaFlow preprocessor (prep generate).

/******************************************************************************
 *
 * MantaFlow fluid solver framework
 * Copyright 2011 Tobias Pfaff, Nils Thuerey
 *
 * This program is free software, distributed under the terms of the
 * Apache License, Version 2.0
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Vortex sheets
 * (warning, the vortex methods are currently experimental, and not fully supported!)
 *
 ******************************************************************************/

#include "vortexsheet.h"
#include "solvana.h"

using namespace std;
namespace Manta {

// *****************************************************************************
// VorticityChannel class members

// *****************************************************************************
// VortexSheet Mesh class members

VortexSheetMesh::VortexSheetMesh(FluidSolver *parent) : Mesh(parent), mTexOffset(0.0f)
{
  addTriChannel(&mVorticity);
  addNodeChannel(&mTex1);
  addNodeChannel(&mTex2);
  addNodeChannel(&mTurb);
}

Mesh *VortexSheetMesh::clone()
{
  VortexSheetMesh *nm = new VortexSheetMesh(mParent);
  *nm = *this;
  nm->setName(getName());
  return nm;
}

void VortexSheetMesh::calcVorticity()
{
  for (size_t tri = 0; tri < mTris.size(); tri++) {
    VortexSheetInfo &v = mVorticity.data[tri];
    Vec3 e0 = getEdge(tri, 0), e1 = getEdge(tri, 1), e2 = getEdge(tri, 2);
    Real area = getFaceArea(tri);

    if (area < 1e-10) {
      v.smokeAmount = 0;
      v.vorticity = 0;
    }
    else {
      v.smokeAmount = 0;
      v.vorticity = (v.circulation[0] * e0 + v.circulation[1] * e1 + v.circulation[2] * e2) / area;
    }
  }
}

void VortexSheetMesh::calcCirculation()
{
  for (size_t tri = 0; tri < mTris.size(); tri++) {
    VortexSheetInfo &v = mVorticity.data[tri];
    Vec3 e0 = getEdge(tri, 0), e1 = getEdge(tri, 1), e2 = getEdge(tri, 2);
    Real area = getFaceArea(tri);

    if (area < 1e-10 || normSquare(v.vorticity) < 1e-10) {
      v.circulation = 0;
      continue;
    }

    float cx, cy, cz;
    SolveOverconstraint34(e0.x,
                          e0.y,
                          e0.z,
                          e1.x,
                          e1.y,
                          e1.z,
                          e2.x,
                          e2.y,
                          e2.z,
                          v.vorticity.x,
                          v.vorticity.y,
                          v.vorticity.z,
                          cx,
                          cy,
                          cz);
    v.circulation = Vec3(cx, cy, cz) * area;
  }
}

void VortexSheetMesh::resetTex1()
{
  for (size_t i = 0; i < mNodes.size(); i++)
    mTex1.data[i] = mNodes[i].pos + mTexOffset;
}

void VortexSheetMesh::resetTex2()
{
  for (size_t i = 0; i < mNodes.size(); i++)
    mTex2.data[i] = mNodes[i].pos + mTexOffset;
}

void VortexSheetMesh::reinitTexCoords()
{
  resetTex1();
  resetTex2();
}

};  // namespace Manta