MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
fvzonal.cpp
Go to the documentation of this file.
1// Copyright (C) 2024 The m-AIA AUTHORS
2//
3// This file is part of m-AIA (https://git.rwth-aachen.de/aia/m-AIA/m-AIA)
4//
5// SPDX-License-Identifier: LGPL-3.0-only
6
7#include "fvzonal.h"
8
9#include <algorithm>
10#include <iostream>
11#include <stack>
12#include <vector>
13#include "COUPLER/coupling.h"
15#include "MEMORY/alloc.h"
16#include "UTIL/functions.h"
17#include "UTIL/kdtree.h"
18#include "globals.h"
19#include "globalvariables.h"
20
21using namespace std;
22
23
24template <MInt nDim, class SysEqn>
25FvZonal<nDim, SysEqn>::FvZonal(const MInt couplingId, RANS* R, LES* L)
26 : Coupling(couplingId), CouplingFv<nDim, SysEqn>(couplingId, R), CouplingFv<nDim, FvSysEqnNS<nDim>>(couplingId, L) {
34 m_zonalAveragingTimeStep = Context::getBasicProperty<MInt>("zonalAveragingTimeStep", AT_, &m_zonalAveragingTimeStep);
35
43 m_zonalTransferInterval = 50;
44 if(Context::propertyExists("zonalTransferInterval")) {
45 m_zonalTransferInterval = Context::getBasicProperty<MInt>("zonalTransferInterval", AT_, &m_zonalTransferInterval);
46 }
47
55 m_restartLESAverage = false;
56 if(Context::propertyExists("restartLESAverage")) {
57 m_restartLESAverage = Context::getBasicProperty<MBool>("restartLESAverage", AT_, &m_restartLESAverage);
58 }
67 m_cylindricCommunication = false;
68 if(Context::propertyExists("cylindricCommunication")) {
69 m_cylindricCommunication =
70 Context::getBasicProperty<MBool>("cylindricCommunication", AT_, &m_cylindricCommunication);
71 m_azimuthalAngle = Context::getBasicProperty<MFloat>("azimuthalAngle", AT_, &m_azimuthalAngle);
72 }
73
74 if(Context::propertyExists("STGSponge")) {
75 m_STGSponge = Context::getBasicProperty<MBool>("STGSponge", AT_, &m_STGSponge);
76 }
77
78 mAlloc(LESSolver().m_RANSValues, noRANSVariables() + (MInt)m_STGSponge, "LESSolver().m_RANSValues", AT_);
79 LESSolver().m_noRANSVariables = noRANSVariables() + (MInt)m_STGSponge;
80 for(MInt i = 0; i < noRANSVariables() + (MInt)m_STGSponge; i++) {
81 LESSolver().m_RANSValues[i].clear();
82 }
83
84 mAlloc(RANSSolver().m_LESValues, noRANSVariables(), "RANSSolver().m_LESValues", AT_);
85 RANSSolver().m_noLESVariables = noRANSVariables();
86 for(MInt i = 0; i < noRANSVariables(); i++) {
87 RANSSolver().m_LESValues[i].clear();
88 }
89}
90
91
95template <MInt nDim, class SysEqn>
97 TRACE();
98
99 // write RANS data to LES Solver
100 if(LESSolver().grid().isActive()) {
101 for(MInt cellId = 0; cellId < a_noFvGridCellsLES(); cellId++) {
102 MInt RANSId = convertIdParent(LESSolver(), RANSSolver(), cellId);
103 if(RANSId > -1) {
104 for(MInt var = 0; var < noRANSVariables(); var++) {
105 ASSERT(cellId < (MInt)LESSolver().m_RANSValues[var].size(),
106 "Trying to access data [" + to_string(var) + "][" + to_string(cellId)
107 + "] in m_RANSValues with length " + to_string(LESSolver().m_RANSValues[var].size())
108 + ", domainId: " + to_string(LESSolver().domainId()));
109
110 LESSolver().m_RANSValues[var][cellId] = RANSSolver().a_pvariable(RANSId, var);
111 }
112 } else {
113 for(MInt var = 0; var < noRANSVariables(); var++) {
114 if(m_cylindricCommunication) {
115 if(var < noLESVariables()) {
116 LESSolver().m_RANSValues[var][cellId] = LESSolver().a_pvariable(cellId, var);
117 } else {
118 LESSolver().m_RANSValues[var][cellId] = F0;
119 }
120 }
121 }
122 }
123 if(m_STGSponge) {
124 LESSolver().m_RANSValues[noRANSVariables()][cellId] = F0;
125 }
126 }
127 }
128}
129
130
134template <MInt nDim, class SysEqn>
136 TRACE();
137
138 // write RANS data to LES Solver
139 if(RANSSolver().grid().isActive()) {
140 for(MInt var = 0; var < noRANSVariables(); var++) {
141 for(MInt cellId = 0; cellId < a_noFvGridCellsRANS(); cellId++) {
142 MInt LESId = convertIdParent(RANSSolver(), LESSolver(), cellId);
143
144 ASSERT(cellId < (MInt)RANSSolver().m_LESValues[var].size(),
145 "Trying to access data [" + to_string(var) + "][" + to_string(cellId) + "] in m_RANSValues with length "
146 + to_string(RANSSolver().m_LESValues[var].size())
147 + ", domainId: " + to_string(RANSSolver().domainId()));
148
149 if(LESId != -1) {
150 RANSSolver().m_LESValues[var][cellId] = LESSolver().a_pvariable(LESId, var);
151 // init nu_t
152 if(var == RANSSolver().sysEqn().PV->N) {
153 RANSSolver().m_LESValues[var][cellId] = RANSSolver().a_pvariable(cellId, var);
154 }
155 }
156 }
157 }
158 }
159}
160
161
void mAlloc(T *&a, const MLong N, const MString &objectName, MString function)
allocates memory for one-dimensional array 'a' of size N
Definition: alloc.h:173
static MBool propertyExists(const MString &name, MInt solver=m_noSolvers)
This function checks if a property exists in general.
Definition: context.cpp:494
void initRANSValues()
Initialize RANSValues for LES Solver.
Definition: fvzonal.cpp:96
FvZonal(const MInt couplingId, RANS *R, LES *L)
void initLESValues()
Initialize LESValues for RANS Solver.
Definition: fvzonal.cpp:135
MInt convertIdParent(SolverA &solverA, SolverB &solverB, const MInt solverAId)
Conversion from solverA id to the solverB id If no cell on the same level is found,...
Definition: couplingutils.h:46
int32_t MInt
Definition: maiatypes.h:62