MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
fvcartesianinterpolation.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
8
9#include <algorithm>
10#include <stack>
13#include "IO/parallelio.h"
14#include "MEMORY/alloc.h"
15#include "UTIL/functions.h"
16#include "coupling.h"
17#include "globals.h"
18
19
20using namespace std;
21
22
23template <MInt nDim, class SysEqnOld, class SysEqnNew>
25 OldFvSolver* oldS,
26 NewFvSolver* newS)
27 : Coupling(couplingId), m_oldSolver(oldS), m_newSolver(newS) {
28 TRACE();
29
30 m_newSolverId = newSolver().m_solverId;
31 m_oldSolverId = oldSolver().m_solverId;
32
40 m_nonZonalRestart = false;
41 if(Context::propertyExists("nonZonalRestart")) {
42 m_nonZonalRestart = Context::getBasicProperty<MBool>("nonZonalRestart", AT_, &m_nonZonalRestart);
43 }
44
45 // Allocate all necessary arrays for zonal exchange (necessary for zonal BC)
46 if(!newSolver().m_rans) {
47 newSolver().m_noRANSVariables = oldSolver().noVariables();
48 mAlloc(newSolver().m_RANSValues, newSolver().m_noRANSVariables, "newSolver().m_RANSValues", AT_);
49 for(MInt i = 0; i < newSolver().m_noRANSVariables; i++) {
50 newSolver().m_RANSValues[i].clear();
51 }
52 } else {
53 newSolver().m_noLESVariables = oldSolver().noVariables();
54 mAlloc(newSolver().m_LESValues, newSolver().m_noLESVariables, "newSolver().m_LESValues", AT_);
55 for(MInt i = 0; i < newSolver().m_noLESVariables; i++) {
56 newSolver().m_LESValues[i].clear();
57 }
58 }
59}
60
61
62template <MInt nDim, class SysEqnOld, class SysEqnNew>
64 TRACE();
65
66 if(m_nonZonalRestart) {
67 transferSolverData();
68 }
69}
70
71template <MInt nDim, class SysEqnOld, class SysEqnNew>
73 if(m_nonZonalRestart) {
74 for(MInt oldId = 0; oldId < a_noFvGridCellsOld(); oldId++) {
75 oldSolver().reduceData(oldId, &oldSolver().a_pvariable(0, 0), oldSolver().noVariables());
76 }
77 transferSolverData();
78 }
79}
80
81template <MInt nDim, class SysEqnOld, class SysEqnNew>
83 if(m_nonZonalRestart) {
84 for(MInt oldId = 0; oldId < a_noFvGridCellsOld(); oldId++) {
85 oldSolver().reduceData(oldId, &oldSolver().a_pvariable(0, 0), oldSolver().noVariables());
86 }
87 transferSolverData();
88 }
89}
90
94template <MInt nDim, class SysEqnOld, class SysEqnNew>
96 TRACE();
97
98 m_log << "starting interpolate (FV)" << endl;
99
100 if(newSolver().grid().isActive()) {
101 // start from min level and go to max level
102 for(MInt newId = 0; newId < a_noFvGridCellsNew(); newId++) {
103 MInt oldId = convertIdParent(newSolver(), oldSolver(), newId);
104
105 if(oldId != -1) {
106 for(MInt varId = 0; varId < newSolver().noVariables(); varId++) {
107 newSolver().a_pvariable(newId, varId) = oldSolver().a_pvariable(oldId, varId);
108 }
109 IF_CONSTEXPR(SysEqnNew::m_noRansEquations == 0) {
110 for(MInt s = 0; s < newSolver().m_noSpecies; ++s) {
111 newSolver().a_pvariable(newId, newSolver().PV->Y[s]) =
112 (oldSolver().m_noSpecies > 0) ? oldSolver().a_pvariable(oldId, oldSolver().PV->Y[s]) : F0;
113 }
114 }
115 }
116 }
117
118 newSolver().computeConservativeVariables();
119 newSolver().exchangeAll();
120
121 m_log << "finished interpolate (FV)" << endl;
122 }
123}
124
125
128template class FvCartesianInterpolation<2,
131template class FvCartesianInterpolation<3,
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 transferSolverData()
interpolate variables from old to new
FvCartesianInterpolation(const MInt couplingId, OldFvSolver *oldS, NewFvSolver *newS)
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
InfoOutFile m_log
int32_t MInt
Definition: maiatypes.h:62