Loading...
Searching...
No Matches
reductionProblemTemplates.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ██╗████████╗██╗ ██╗ █████╗ ██████╗ █████╗ ███████╗██╗ ██╗
3 ██║╚══██╔══╝██║ ██║██╔══██╗██╔════╝██╔══██╗ ██╔════╝██║ ██║
4 ██║ ██║ ███████║███████║██║ ███████║█████╗█████╗ ██║ ██║
5 ██║ ██║ ██╔══██║██╔══██║██║ ██╔══██║╚════╝██╔══╝ ╚██╗ ██╔╝
6 ██║ ██║ ██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ╚████╔╝
7 ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═══╝
8
9 * In real Time Highly Advanced Computational Applications for Finite Volumes
10 * Copyright (C) 2017 by the ITHACA-FV authors
11-------------------------------------------------------------------------------
12License
13 This file is part of ITHACA-FV
14
15 ITHACA-FV is free software: you can redistribute it and/or modify
16 it under the terms of the GNU Lesser General Public License as published by
17 the Free Software Foundation, either version 3 of the License, or
18 (at your option) any later version.
19
20 ITHACA-FV is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU Lesser General Public License for more details.
24
25 You should have received a copy of the GNU Lesser General Public License
26 along with ITHACA-FV. If not, see <http://www.gnu.org/licenses/>.
27
28\*---------------------------------------------------------------------------*/
29
32
33template<typename T, typename G>
34void reductionProblem::assignIF(T& s, G& value)
35{
36 for (label i = 0; i < s.internalField().size(); i++)
37 {
38 s.ref()[i] = value;
39 }
40}
41
42template<typename T>
43void reductionProblem::computeLift(T& Lfield, T& liftfield, T& omfield)
44{
45 scalar u_bc;
46 scalar u_lf;
47 scalar area;
48
49 for (label k = 0; k < inletIndex.rows(); k++)
50 {
51 label p = inletIndex(k, 0);
52 label l = inletIndex(k, 1);
53 area = gSum(Lfield[0].mesh().magSf().boundaryField()[p]);
54 u_lf = gSum(liftfield[k].mesh().magSf().boundaryField()[p] *
55 liftfield[k].boundaryField()[p]).component(l) / area;
56 M_Assert(std::abs(u_lf) > 1e-5,
57 "The lift cannot be computed. Please, check your inletIndex definition");
58
59 for (label j = 0; j < Lfield.size(); j++)
60 {
61 if (k == 0)
62 {
63 u_bc = gSum(Lfield[j].mesh().magSf().boundaryField()[p] *
64 Lfield[j].boundaryField()[p]).component(l) / area;
65 volVectorField C("U", Lfield[j] - liftfield[k]*u_bc / u_lf);
66 omfield.append(C.clone());
67 }
68 else
69 {
70 u_bc = gSum(omfield[j].mesh().magSf().boundaryField()[p] *
71 omfield[j].boundaryField()[p]).component(l) / area;
72 volVectorField C("U", omfield[j] - liftfield[k]*u_bc / u_lf);
73 omfield.set(j, C.clone());
74 }
75 }
76 }
77}
78
79template<typename T>
80void reductionProblem::computeLiftT(T& Lfield, T& liftfield, T& omfield)
81{
82 scalar t_bc;
83 scalar t_lf;
84 scalar area;
85
86 for (label k = 0; k < inletIndexT.rows(); k++)
87 {
88 label p = inletIndexT(k, 0);
89 area = gSum(Lfield[0].mesh().magSf().boundaryField()[p]);
90 t_lf = gSum(liftfield[k].mesh().magSf().boundaryField()[p] *
91 liftfield[k].boundaryField()[p]) / area;
92
93 for (label j = 0; j < Lfield.size(); j++)
94 {
95 if (k == 0)
96 {
97 t_bc = gSum(Lfield[j].mesh().magSf().boundaryField()[p] *
98 Lfield[j].boundaryField()[p]) / area;
99 volScalarField C(Lfield[0].name(), Lfield[j] - liftfield[k]*t_bc / t_lf);
100 omfield.append(C.clone());
101 }
102 else
103 {
104 t_bc = gSum(omfield[j].mesh().magSf().boundaryField()[p] *
105 omfield[j].boundaryField()[p]) / area;
106 volScalarField C(Lfield[0].name(), omfield[j] - liftfield[k]*t_bc / t_lf);
107 omfield.set(j, C.clone());
108 }
109 }
110 }
111}
112
113
114
115
116// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::fvMesh & mesh
Definition createMesh.H:47
#define M_Assert(Expr, Msg)
Eigen::MatrixXi inletIndexT
void assignIF(T &s, G &value)
Assign internal field condition.
void computeLift(T &Lfield, T &liftfield, T &omfield)
Homogenize the snapshot matrix, it works with PtrList of volVectorField and volScalarField.
void computeLiftT(T &Lfield, T &liftfield, T &omfield)
Virtual function to compute the lifting function.
Eigen::MatrixXi inletIndex
Matrix that contains informations about the inlet boundaries.
volScalarField & T
Definition createT.H:46
volScalarField & p
label i
Definition pEqn.H:46