VM2D 1.14
Vortex methods for 2D flows simulation
Loading...
Searching...
No Matches
v3D.h
Go to the documentation of this file.
1/*--------------------------------*- VM2D -*-----------------*---------------*\
2| ## ## ## ## #### ##### | | Version 1.14 |
3| ## ## ### ### ## ## ## ## | VM2D: Vortex Method | 2026/03/06 |
4| ## ## ## # ## ## ## ## | for 2D Flow Simulation *----------------*
5| #### ## ## ## ## ## | Open Source Code |
6| ## ## ## ###### ##### | https://www.github.com/vortexmethods/VM2D |
7| |
8| Copyright (C) 2017-2026 I. Marchevsky, K. Sokol, E. Ryatina, A. Kolganova |
9*-----------------------------------------------------------------------------*
10| File name: v3D.h |
11| Info: Source code of VM2D |
12| |
13| This file is part of VM2D. |
14| VM2D is free software: you can redistribute it and/or modify it |
15| under the terms of the GNU General Public License as published by |
16| the Free Software Foundation, either version 3 of the License, or |
17| (at your option) any later version. |
18| |
19| VM2D is distributed in the hope that it will be useful, but WITHOUT |
20| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
21| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
22| for more details. |
23| |
24| You should have received a copy of the GNU General Public License |
25| along with VM2D. If not, see <http://www.gnu.org/licenses/>. |
26\*---------------------------------------------------------------------------*/
27
28
40#ifndef V3D_H_
41#define V3D_H_
42
43#include "numvector.h"
44
45namespace VMlib
46{
47
59 class v3D : public numvector<double, 3>
60 {
61 public:
62
63//#ifndef __CUDACC__
64// /// MPI-описатель типа
65// static MPI_Datatype mpiv3D;
66//#endif
67
69 v3D() { };
70
75 {
76 data[0] = _r[0];
77 data[1] = _r[1];
78 data[2] = _r[2];
79 };
80
84 v3D(const v3D& _r)
85 {
86 data[0] = _r[0];
87 data[1] = _r[1];
88 data[2] = _r[2];
89 };
90
91#ifndef __CUDACC__
96 v3D(const std::initializer_list<double>& z)
97 {
98 for (size_t i = 0; i < 3; ++i)
99 data[i] = *(z.begin() + i);
100 };
101#endif
102
104 ~v3D() { };
105
111 v3D rotated(const double angle, const v3D& axis) const
112 {
115
116 v3D res = *this;
117 //double cosa = cos(angle);
118 //double sina = sin(angle);
119 //
120 //res[0] = r[0] * cosa - r[1] * sina;
121 //res[1] = r[0] * sina + r[1] * cosa;
122 return res;
123 }//rotated(...);
124 };
125
126
128 inline v3D operator*(double c, const v3D& x)
129 {
130 v3D res(x);
131 for (size_t i = 0; i < 3; ++i)
132 res[i] *= c;
133 return res;
134 }//operator*(...)
135
136
137 inline std::pair<v3D, v3D>& operator+=(std::pair<v3D, v3D>& a, const std::pair<v3D, v3D>& b)
138 {
139 a.first += b.first;
140 a.second += b.second;
141 return a;
142 }//operator+=(...)
143
144 inline std::pair<v3D, v3D>& operator*=(std::pair<v3D, v3D>& a, double c)
145 {
146 a.first *= c;
147 a.second *= c;
148 return a;
149 }//operator+=(...)
150
151 inline std::pair<v3D, v3D> operator*(std::pair<v3D, v3D>& a, double c)
152 {
153 return {a.first * c, a.second * c};
154 }//operator+=(...)
155
156}//namespace VMlib
157
158using VMlib::v3D;
159
160#endif
161
Шаблонный класс, определяющий вектор фиксированной длины Фактически представляет собой массив,...
Definition numvector.h:99
Класс, опеделяющий двумерный вектор
Definition v3D.h:60
v3D rotated(const double angle, const v3D &axis) const
Поворот вектора на произвольный угол против часовой стрелки (по умолчанию 90 градусов)
Definition v3D.h:111
v3D(const numvector< double, 3 > &_r)
Конструктор и приведение типа из numvector<double, 3>
Definition v3D.h:74
v3D()
Пустой конструктор
Definition v3D.h:69
v3D(const v3D &_r)
Конструктор копирования
Definition v3D.h:84
v3D(const std::initializer_list< double > &z)
Конструктор инициализации списком
Definition v3D.h:96
~v3D()
Деструктор
Definition v3D.h:104
numvector< T, n > operator*(double c, const numvector< T, n > &x)
Оператор "*" умножения вектора на число (число слева, вектор справа)
Definition numvector.h:779
std::pair< numvector< T, n >, numvector< P, n > > & operator*=(std::pair< numvector< T, n >, numvector< P, n > > &a, R c)
Оператор домножения "*=" пары векторов на число (пара слева, число справа)
Definition numvector.h:934
std::pair< numvector< T, n >, numvector< P, n > > & operator+=(std::pair< numvector< T, n >, numvector< P, n > > &a, const std::pair< numvector< R, n >, numvector< S, n > > &b)
Оператор прибавления "+=" для пар векторов
Definition numvector.h:895
Описание класса numvector.