Saras
Finite   Difference   Solver   for   Fluid   Dynamics   Simulations
vfield.h
Go to the documentation of this file.
1/********************************************************************************************************************************************
2 * Saras
3 *
4 * Copyright (C) 2019, Mahendra K. Verma
5 *
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the copyright holder nor the
16 * names of its contributors may be used to endorse or promote products
17 * derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 ********************************************************************************************************************************************
31 */
43#ifndef VFIELD_H
44#define VFIELD_H
45
46#include "field.h"
47#include "derivative.h"
48
49// Forward declarations of relevant classes
50class plainsf;
51class plainvf;
52class sfield;
53
54class vfield {
55 private:
56 const grid &gridData;
57
58 blitz::Array<real, 3> derivTempX, derivTempY, derivTempZ;
59
60 public:
61 field Vx, Vy, Vz;
62
66 derivative derVx, derVy, derVz;
68
70 std::string fieldName;
71
72 blitz::Array<real, 3> interTempX, interTempY, interTempZ;
73
74 vfield(const grid &gridData, std::string fieldName);
75
76 void computeDiff(plainvf &H);
77 void computeTStp(real &dt_out);
78 void computeNLin(const vfield &V, plainvf &H);
79
80 void divergence(plainsf &divV, const sfield &P);
81
82 void syncData();
83
86
89
90 vfield& operator *= (real a);
91
92 void operator = (plainvf &a);
93 void operator = (vfield &a);
94 void operator = (real a);
95
96 ~vfield() { };
97};
98
117#endif
Derivative class to perform finite difference operations on the data stored in field.
Definition: derivative.h:53
Field class to store data and perform finite difference operations on the data.
Definition: field.h:52
Contains all the global variables related to the grid, its slices, limits, and grid derivatives used ...
Definition: grid.h:53
Plain scalar field class to store simple scalar fields with no differentiation or interpolation.
Definition: plainsf.h:51
Plain vector field class to store simple vector fields with no additional operators like differentiat...
Definition: plainvf.h:49
Scalar field class to store and operate on scalar fields.
Definition: sfield.h:54
Vector field class to store and operate on vector fields.
Definition: vfield.h:54
void computeTStp(real &dt_out)
Operator is used to calculate time step #dt_out using CFL Condition.
Definition: vfield.cc:267
void divergence(plainsf &divV, const sfield &P)
Operator to compute the divergence of the vector field.
Definition: vfield.cc:299
void operator=(plainvf &a)
Overloaded operator to assign a plain vector field to the vector field.
Definition: vfield.cc:447
vfield & operator-=(plainvf &a)
Overloaded operator to subtract a given plain vector field.
Definition: vfield.cc:369
vfield(const grid &gridData, std::string fieldName)
Constructor of the vfield class.
Definition: vfield.cc:62
void syncData()
Function to synchronise data across all processors when performing parallel computations.
Definition: vfield.cc:331
std::string fieldName
This string is used to identify the vector field, and is useful in file-writing.
Definition: vfield.h:70
derivative derVx
derVx, derVy and derVz are three instances of the derivative class used to compute derivatives.
Definition: vfield.h:66
void computeNLin(const vfield &V, plainvf &H)
Function to compute the convective derivative of the vector field.
Definition: vfield.cc:163
vfield & operator*=(real a)
Overloaded operator to multiply a scalar value to the vector field.
Definition: vfield.cc:429
void computeDiff(plainvf &H)
Function to compute the diffusion term.
Definition: vfield.cc:104
vfield & operator+=(plainvf &a)
Overloaded operator to add a given plain vector field.
Definition: vfield.cc:349
Class declaration of derivative.
Class declaration of field.