Saras
Finite   Difference   Solver   for   Fluid   Dynamics   Simulations
scalar.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 SCALAR_H
44#define SCALAR_H
45
46#include <blitz/array.h>
47
48#include "hydro.h"
49#include <math.h>
50
51class scalar: public hydro {
52 public:
55
58
59 real nu, kappa;
60
61 scalar(const grid &mesh, const parser &solParam, parallel &mpiParam);
62
63 virtual ~scalar() { };
64
65 protected:
66 plainsf tmpRHS;
67 plainsf guessedScalar;
68 plainsf scalarLaplacian;
69
70 boundary *tLft, *tRgt, *tFrn, *tBak, *tTop, *tBot;
71
72 void initTBC();
73 void imposeTBCs();
74
75 void initVForcing();
76 void initTForcing();
77
78 virtual void solveT();
79};
80
94class scalar_d2: public scalar {
95 public:
96 scalar_d2(const grid &mesh, const parser &solParam, parallel &mpiParam);
97
98 void solvePDE();
99 real testPeriodic();
100
101 ~scalar_d2();
102
103 private:
104 multigrid_d2 mgSolver;
105
106 void solveVx();
107 void solveVz();
108
109 void solveT();
110
111 void timeAdvance();
112};
113
125class scalar_d3: public scalar {
126 public:
127 scalar_d3(const grid &mesh, const parser &solParam, parallel &mpiParam);
128
129 void solvePDE();
130 real testPeriodic();
131
132 ~scalar_d3();
133
134 private:
135 multigrid_d3 mgSolver;
136
137#ifdef TIME_RUN
138 real visc_time, nlin_time, intr_time, impl_time, prhs_time, pois_time;
139#endif
140
141 void solveVx();
142 void solveVy();
143 void solveVz();
144
145 void solveT();
146
147 void timeAdvance();
148};
149
160#endif
Contains all the global variables related to the imposing of boundary conditions, and functions to im...
Definition: boundary.h:51
Contains all the global variables related to the imposing of forcing, and associated functions.
Definition: force.h:52
Contains all the global variables related to the grid, its slices, limits, and grid derivatives used ...
Definition: grid.h:53
The base class hydro to solve the incompressible Navier-Stokes equations.
Definition: hydro.h:62
The derived class from poisson to perform multi-grid operations on a 2D grid.
Definition: poisson.h:156
The derived class from poisson to perform multi-grid operations on a 3D grid.
Definition: poisson.h:193
Class for all the global variables and functions related to parallelization.
Definition: parallel.h:51
Contains all the global variables set by the user through the yaml file.
Definition: parser.h:63
Plain scalar field class to store simple scalar fields with no differentiation or interpolation.
Definition: plainsf.h:51
The derived class from the scalar base class to solve the incompressible NSE in 2D with energy equati...
Definition: scalar.h:94
scalar_d2(const grid &mesh, const parser &solParam, parallel &mpiParam)
Constructor of the scalar_d2 class derived from the base scalar class.
Definition: scalar_d2.cc:59
real testPeriodic()
Function to test whether periodic BC is being implemented properly.
Definition: scalar_d2.cc:468
void solvePDE()
The core publicly accessible function of the hydro class to solve the Navier-Stokes equations.
Definition: scalar_d2.cc:105
The derived class from the scalar base class to solve the incompressible NSE in 3D with energy equati...
Definition: scalar.h:125
void solvePDE()
The core publicly accessible function of the hydro class to solve the Navier-Stokes equations.
Definition: scalar_d3.cc:110
scalar_d3(const grid &mesh, const parser &solParam, parallel &mpiParam)
Constructor of the scalar_d3 class derived from the base scalar class.
Definition: scalar_d3.cc:62
real testPeriodic()
Function to test whether periodic BC is being implemented properly.
Definition: scalar_d3.cc:597
The base class scalar to solve the incompressible Navier-Stokes equations with energy equation.
Definition: scalar.h:51
void initTForcing()
Function to initialize the forcing terms for temperature.
Definition: scalar.cc:169
void imposeTBCs()
Function to impose the boundary conditions for temperature.
Definition: scalar.cc:240
force * tForcing
Instance of force class to handle temperature field forcing.
Definition: scalar.h:57
virtual void solveT()
Function to solve the implicit equation for scalar field.
Definition: scalar.cc:119
void initVForcing()
Function to initialize the forcing terms for velocity.
Definition: scalar.cc:131
scalar(const grid &mesh, const parser &solParam, parallel &mpiParam)
Constructor of the base scalar class.
Definition: scalar.cc:61
void initTBC()
Function to initialize the boundary conditions for temperature.
Definition: scalar.cc:185
sfield T
The scalar field that stores the temperature field.
Definition: scalar.h:54
Scalar field class to store and operate on scalar fields.
Definition: sfield.h:54
Class declaration of the hydro solver for both 2D and 3D cases.