Loading...
Searching...
No Matches
10UnsteadyBBEnclosed.C File Reference

Implementation of tutorial 10 for an unsteady Buoyant Boussinesq problem for an enclosed cavity. More...

#include "UnsteadyBB.H"
#include "ITHACAPOD.H"
#include "ReducedUnsteadyBB.H"
#include "ITHACAstream.H"
#include <chrono>
#include <math.h>
#include <iomanip>

Go to the source code of this file.

Classes

class  tutorial10

Functions

int main (int argc, char *argv[])

Detailed Description

Implementation of tutorial 10 for an unsteady Buoyant Boussinesq problem for an enclosed cavity.

Introduction to tutorial 10

In this tutorial an unsteady Buoyant Boussinesq (BB) 2D problem with paramerized temperature boundary conditions is implemented. The physical problem represents a differentially heated cavity. A uniform temperature is set to the left (hot) and the right (cold) sides of the cavity while the other sides are set to adiabatic. The cavity aspect ratio is 1.0. The flow is laminar and the working fluid is air with Pr = 0.7. The ambient temperature is 300 K. The hot wall, Th, has a temperature of 301.5 K, while the cold wall, Tc, is set to 298.5 K. The initial condition for the velocity is (0.0001, 0, 0) m/s.

The following image illustrates the geometry with the boundary conditions.

A detailed look into the code

In this section we explain the main steps necessary to construct the tutorial N°10

ITHACA-FV header files

First of all let's have a look at the header files that need to be included and what they are responsible for.

The header files of ITHACA-FV necessary for this tutorial are: <UnsteadyBB.H> for the full order unsteady BB problem, <ITHACAPOD.H> for the POD decomposition, <ReducedUnsteadyBB.H> for the construction of the reduced order problem, and finally <ITHACAstream.H> for some ITHACA input-output operations.

Definition of the tutorial10 class

We define the tutorial10 class as a child of the UnsteadyBB class. The constructor is defined with members that are the fields need to be manipulated during the resolution of the full order problem using the BuoyancyBoussinesqPimpleFoam solver. Such fields are also initialized with the same initial conditions in the solver.

Inside the tutorial10 class we define the offlineSolve method according to the specific parametrized problem that needs to be solved. If the offline solve has been previously performed then the method simply reads in the existing snapshots from the Offline directory. If not, the offlineSolve changes the values of the temperature boundary conditions before performing the offline solve.

In order to calculate the L2 error between the online solved reduced order model and the corresponding full order solution at the end of this tutorial, the full order solve can be performed with the onlineSolveFull for a parameter set for which the reduced order model has been solved online.

If the full order solve has been performed previously then the existing snapshots can be read in from the specified directory.

The liftingfunctions for temperature in this problem are determined by solving a steady state laplacian function

Definition of the main function

In this section we show the definition of the main function. First we construct the object "example" of type tutorial10:

The parameter sets for the temperature BC are read in from file, both for the offline and online phase. Each row corresponds to a parameter set and each column to a specific boundary.

Then we parse the ITHACAdict file to determine the number of modes to be written out and also the ones to be used for projection of the velocity, pressure, temperature and the supremizer:

We note that a default value can be assigned in case the parser did not find the corresponding string in the ITHACAdict file.

Now the kinematic viscosity is set to 0.00001 m^2/s. It is possible to parametrize the viscosity. For more info take a look at tutorial04.

After that we set the boundaries where we have a non homogeneous BC for temperature. Patch 1 corresponds to the hot boundary and Patch 2 to the cold boundary.

Furthermore, we set the parameters for the time integration. In this case the simulation time is 10 seconds, with a step size = 0.005 seconds, and the data is written every 0.01 seconds, i.e.

Now we are ready to perform the offline stage:

No lifting function has to be computed for velocity as the velocity is zero everywhere on the boundary. For the temperature, the lifting functions are determined by:

Then we create homogenuous basis functions for the temperature:

And after that, we obtain the modes for velocity and temperature:

Before continuiting, the projection error is calculated for certain number of modes for both temperature and velocity.

The temperature modes are created locally

and the projection onto the POD modes is performed with:

Finally the L2 error between full order solution and projection of the basis are calculated

and exported

Then the projection onto the POD modes is performed to get the reduced matrices

and the modes are resized to the number for which the projection has been performed

Now that we obtained all the necessary information from the POD decomposition and the reduced matrices, we are ready to construct the dynamical system for the reduced order model (ROM). We proceed by constructing the object "reduced" of type ReducedUnsteadyBB:

We can use the new constructed ROM to perform the online procedure, from which we can simulate the problem at new set of parameters. For instance, we solve the problem for 10 seconds of physical time:

And then we can use the new constructed ROM to perform the online procedure, from which we can simulate the problem at new set of parameters. As the velocity is homogenous on the boundary, it is not parametrized and therefore an empty matrix is created:

Lastly the online procedure is performed for all temperature boundary sets as defined in the par_online_BC file. And he ROM solution is reconstructed and exported:

For the second and third parameter set the full order solution is calculated

and the solutions are read in:

Finally the L2 error between full and reduced order solutions is calculated

The plain program

Here's the plain code

Definition in file 10UnsteadyBBEnclosed.C.

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Set the number of parameters

Set samples

Set the parameters infos

Set the parameter ranges

Set the inlet Temperature boundaries where there are non homogeneous boundary conditions

Time parameters

Definition at line 177 of file 10UnsteadyBBEnclosed.C.