Files | |
| 02thermalBlock.C | |
| createFields.H | |
The problem consists of a parametrized POD-Galerkin ROM for a steady heat transfer phenomenon. The parametrization is on the diffusivity constant. The OpenFOAM full order problem is based on laplacianFoam. The problem equation is
$$\nabla \cdot (k \nabla T) = S,$$
where $k$ $k$--> is the diffusivity, $T$ is the temperature and $S$ is the source term. The problem discretised and formalized in matrix equation reads:
$$AT = S,$$
where $A$ is the matrix of interpolation coefficients, $T$ is the vector of unknowns and $S$ is the vector representing the source term. The domain is subdivided in 9 different parts and each part has parametrized diffusivity. See the image below for a clarification.

Both the full order and the reduced order problem are solved exploiting the parametric affine decomposition of the differential operators:
$$A = \sum_{i=1}^N \theta_i(\mu) A_i.$$
For the operations performed by each command check the comments in the source 02thermalBlock.C file.
In this section are explained the main steps necessary to construct the tutorial N°2.
First of all let's have a look to the header files that needs to be included and what they are responsible for:
The standard C++ header for input/output stream objects:
The OpenFOAM header files:
The header file of ITHACA-FV necessary for this tutorial
The Eigen library for matrix manipulation and linear and non-linear algebra operations:
Then we can define the tutorial02 class as a child of the laplacianProblem class:
We can define the tutorial02 class as a child of the laplacianProblem class
The members of the class are the fields that need to be manipulated during the resolution of the problem
Inside the class it is defined the offline solve method according to the specific parametrized problem that needs to be solved.
If the offline solve has already been performed, then read the existing snapshots:
Else, perform the offline solve where a loop over all the parameters is performed:
A 0 internal constant value is assigned before each solve command with the line:
The solve operation is then performed. See also the laplacianProblem class for the definition of the methods
We need also to implement a method to set/define the source term that may be problem-dependent. In this case the source term is defined with a hat function:
The source term is here defined as:
$$S = \sin \left(\frac{\pi}{L}\cdot x \right) + \sin \left(\frac{\pi}{L}\cdot y \right),$$
where $L$ is the dimension of the thermal block which is equal to 0.9. The source term appears as follows.

With the following is defined a method to set the parameter of the affine expansion:
The list of parameters is resized according to the number of parametrized regions
The nine different volScalarFields to identify the viscosity in each domain are initialized:
and the 9 different boxes are defined:
and for each of the defined boxes, the relative diffusivity field is set to 1 inside the box and remains 0 elsewhere:
See also the ITHACAutilities::setBoxToValue for more details.
The list of diffusivity fields is set with:
Once the tutorial02 class is defined, we need to define the main function, namely an example of type tutorial02 is constructed:
along with another instance to compute the test set:
The problem is split in offline and online stages:
The number of parameters is set:
The range of the parameters is defined:
and 500 random combinations of the parameters are generated:
The size of the list of values that are multiplying the affine forms is set:
The source term is defined, the compute_nu and assemble_operator functions are called
then the Offline full-order solve is performed:
Once the Offline solve is performed, the modes are obtained using the ITHACAPOD::getModes function:
and the projection is performed onto the POD modes using 10 modes:
Once the projection is performed, we can construct a reduced object:
and solve the reduced problem for some values of the parameters:
Finally, once the online solve has been performed, we can reconstruct the solution:
To speed up the offline stage, ITHACA-FV employs OpenFOAM facilities to run applications in parallel on distributed processors: the method of parallel computing used by OpenFOAM is known as domain decomposition.
First, the domain is decomposed in 4 subdomains as indicated in the directory system/decomposeParDict with the command:
Then, the offline solve is performed in parallel, evaluating the modes and the reduced matrices on the whole domain
The online stage is performed analogously
The users can simply run the script Allrun_parallel.
The plain code can be found here.
1.16.1