Saras
Finite   Difference   Solver   for   Fluid   Dynamics   Simulations
plainvf.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 PLAINVF_H
44#define PLAINVF_H
45
46#include "vfield.h"
47#include "grid.h"
48
49class plainvf {
50 private:
51 const grid &gridData;
52
53 public:
54 blitz::Array<real, 3> Vx, Vy, Vz;
55
56 plainvf(const grid &gridData, const vfield &refV);
57
58 mpidata *mpiVxData, *mpiVyData, *mpiVzData;
59
62
65
66 plainvf& operator *= (real a);
67
68 void operator = (plainvf &a);
69 void operator = (vfield &a);
70 void operator = (real a);
71
80 inline void syncData() {
81 mpiVxData->syncData();
82 mpiVyData->syncData();
83 mpiVzData->syncData();
84 }
85
97 inline real vxMax() {
98 real localMax, globalMax;
99
100 localMax = blitz::max(Vx);
101
102 MPI_Allreduce(&localMax, &globalMax, 1, MPI_FP_REAL, MPI_MAX, MPI_COMM_WORLD);
103
104 return globalMax;
105 }
106
118 inline real vyMax() {
119 real localMax, globalMax;
120
121 localMax = blitz::max(Vy);
122
123 MPI_Allreduce(&localMax, &globalMax, 1, MPI_FP_REAL, MPI_MAX, MPI_COMM_WORLD);
124
125 return globalMax;
126 }
127
139 inline real vzMax() {
140 real localMax, globalMax;
141
142 localMax = blitz::max(Vz);
143
144 MPI_Allreduce(&localMax, &globalMax, 1, MPI_FP_REAL, MPI_MAX, MPI_COMM_WORLD);
145
146 return globalMax;
147 }
148
149 ~plainvf() { };
150};
151
167#endif
Contains all the global variables related to the grid, its slices, limits, and grid derivatives used ...
Definition: grid.h:53
Class to store MPI derived datatypes for individual arrays.
Definition: mpidata.h:51
void syncData()
Function to send data across all sub-domain faces.
Definition: mpidata.cc:278
Plain vector field class to store simple vector fields with no additional operators like differentiat...
Definition: plainvf.h:49
real vyMax()
Function to extract the maximum value from the Vy component of the plain vector field.
Definition: plainvf.h:118
plainvf & operator*=(real a)
Overloaded operator to multiply a scalar value to the plain vector field.
Definition: plainvf.cc:171
real vxMax()
Function to extract the maximum value from the Vx component of the plain vector field.
Definition: plainvf.h:97
void operator=(plainvf &a)
Overloaded operator to assign another plain vector field to the plain vector field.
Definition: plainvf.cc:189
plainvf(const grid &gridData, const vfield &refV)
Constructor of the plainvf class.
Definition: plainvf.cc:56
real vzMax()
Function to extract the maximum value from the Vz component of the plain vector field.
Definition: plainvf.h:139
plainvf & operator-=(plainvf &a)
Overloaded operator to subtract a given plain vector field.
Definition: plainvf.cc:111
plainvf & operator+=(plainvf &a)
Overloaded operator to add a given plain vector field.
Definition: plainvf.cc:91
void syncData()
Function to synchronise data across all processors when performing parallel computations.
Definition: plainvf.h:80
Vector field class to store and operate on vector fields.
Definition: vfield.h:54
Class declaration of grid.
Class declaration of vfield - vector field.