Saras
Finite   Difference   Solver   for   Fluid   Dynamics   Simulations
field.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 FIELD_H
44#define FIELD_H
45
46#include <blitz/array.h>
47#include <string>
48
49#include "mpidata.h"
50#include "grid.h"
51
52class field {
53 private:
54 const grid &gridData;
55
56 void setCoreSlice();
57 void setBulkSlice();
58
59 void setWallSlices();
60
61 void setInterpolationSlices();
62
63 public:
65 blitz::Array<real, 3> F;
66
68 std::string fieldName;
69
75 const bool xStag, yStag, zStag;
77
79 blitz::RectDomain<3> fCore;
80
83 blitz::RectDomain<3> fBulk;
84
88 blitz::RectDomain<3> fCLft, fCRgt;
89 blitz::RectDomain<3> fCFrt, fCBak;
90 blitz::RectDomain<3> fCBot, fCTop;
92
95 blitz::Array<blitz::RectDomain<3>, 1> fWalls;
96
97 blitz::Array<blitz::RectDomain<3>, 1> PcIntSlices, QvIntSlices;
98 blitz::Array<blitz::RectDomain<3>, 1> VxIntSlices, VyIntSlices, VzIntSlices;
99 blitz::Array<blitz::RectDomain<3>, 1> WxIntSlices, WyIntSlices, WzIntSlices;
100
101 blitz::TinyVector<int, 3> fSize;
102 blitz::TinyVector<int, 3> flBound, cuBound;
103
104 mpidata *mpiHandle;
105
106 field(const grid &gridData, std::string fieldName, const bool xStag, const bool yStag, const bool zStag);
107
108 void syncData();
109
110 real fieldMax();
111
112 blitz::RectDomain<3> shift(int dim, const blitz::RectDomain<3> core, int steps);
113
116
117 field& operator += (real a);
118 field& operator -= (real a);
119
120 void operator = (field &a);
121 void operator = (real a);
122
123 ~field();
124};
125
138#endif
Field class to store data and perform finite difference operations on the data.
Definition: field.h:52
blitz::RectDomain< 3 > shift(int dim, const blitz::RectDomain< 3 > core, int steps)
Function to shift a blitz RectDomain object by a given number of steps along a specified dimension.
Definition: field.cc:122
real fieldMax()
Function to extract the maximum value from the field.
Definition: field.cc:602
field & operator-=(field &a)
Overloaded operator to subtract a given field.
Definition: field.cc:649
const bool xStag
xStag, yStag and zStag are the boolean flags which specify whether the field variable is at cell-cent...
Definition: field.h:75
blitz::RectDomain< 3 > fBulk
The bulk slice is a view of the field data excluding the walls surrounding it.
Definition: field.h:83
blitz::Array< real, 3 > F
The field data is stored in this Blitz array.
Definition: field.h:65
blitz::Array< blitz::RectDomain< 3 >, 1 > fWalls
The wall slices are views of the field data showing only the wall points.
Definition: field.h:95
field(const grid &gridData, std::string fieldName, const bool xStag, const bool yStag, const bool zStag)
Constructor of the field class.
Definition: field.cc:66
blitz::RectDomain< 3 > fCore
The core slice is a view of the field data excluding the ghost points surrounding it.
Definition: field.h:79
std::string fieldName
This string is used to identify the field, and is useful in file-writing.
Definition: field.h:68
void syncData()
Function to synchronise data across all processors when performing parallel computations.
Definition: field.cc:586
field & operator+=(field &a)
Overloaded operator to add a given field.
Definition: field.cc:631
void operator=(field &a)
Overloaded operator to assign a field to the field.
Definition: field.cc:713
blitz::RectDomain< 3 > fCLft
fCLft, fCRgt, fCFrt, fCBak, fCBot, fCTop are views of the field data generated by shifting the core s...
Definition: field.h:88
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
Class declaration of grid.
Class declaration of mpidata.