MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
lsfvmb.h
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#ifndef LSFVMB_H_
8#define LSFVMB_H_
9
12#include "solver.h"
13
14#include "coupling.h"
15#include "couplingutils.h"
16
17template <MInt nDim>
18class CouplingLS;
19
20template <MInt nDim, class SysEqn>
21class CouplingFvMb;
22
23template <MInt nDim_, class SysEqn>
24class LsFvMb : public CouplingLS<nDim_>, public CouplingFvMb<nDim_, SysEqn> {
25 public:
26 static constexpr MInt nDim = nDim_;
27
28 private:
29 friend class FvMbCartesianSolverXD<nDim, SysEqn>;
30 friend class LsCartesianSolver<nDim>;
31
32 public:
33 // Simplifications
37
38 // Type for cell properties
39 using LsCell = typename LsSolver::Cell;
40 // FvCell is already set in one of the headers and will be used as such here!
42
43 // Constructor
44 LsFvMb<nDim_, SysEqn>(const MInt couplingId, LsSolver* ls, FvMbSolver* fvMb);
45
46 private:
50
53
56
58
61
64
65 static constexpr const MInt m_noCorners = (nDim == 2) ? 4 : 8;
66 static constexpr const MInt m_maxNoGapRegions = 5;
67
68 // updateLevelSetFlowSolver
70
71 // setGapState
74
75 // Call to solvers and base class functions
76 using CouplingFvMb<nDim_, SysEqn>::fvMbSolver;
77 using CouplingFvMb<nDim_, SysEqn>::a_noFvCells;
78 using CouplingFvMb<nDim_, SysEqn>::a_noFvGridCells;
79 using CouplingFvMb<nDim_, SysEqn>::a_noLevelSetsMb;
80
81 using CouplingLS<nDim_>::lsSolver;
82 using CouplingLS<nDim_>::a_noLsCells;
83 using CouplingLS<nDim_>::a_outsideGValue;
85 using CouplingLS<nDim_>::a_bodyIdG;
87 using CouplingLS<nDim_>::a_inBandG;
88 using CouplingLS<nDim_>::a_noG0Cells;
89 using CouplingLS<nDim_>::a_coordinateG;
90 using CouplingLS<nDim_>::a_nearGapG;
91
92 //--------------------------------- functions ------------------------------------------------------
93
94 private:
95 void initData();
96 void checkProperties();
98
99 void interpolateLsFV(const MInt, const MInt);
100 MFloat interpolateLevelSetMb(MInt* interpolationCells, MFloat* point, const MInt set);
101 MFloat interpolateLevelSet(MInt cellId, MFloat* point, MInt set);
102 void buildCollectedLevelSet(const MInt);
103
104 void updateFlowSolver();
105
106 void transferTimeStep();
108 void transferBodyRadius();
109 void transferGapCellProperty(MInt mode);
113
115
116 void setGapState();
118
119 void updateLevelSet();
121
122 void initFvGapCells();
123 void lsGapInfo(const MInt, MInt*);
124
125 void initBodyProperties();
126
127 MInt ls2fvId(const MInt lsId) { return convertId(lsSolver(), fvMbSolver(), lsId); };
128 MInt ls2fvIdParent(const MInt lsId) { return convertIdParent(lsSolver(), fvMbSolver(), lsId); };
129 MInt fv2lsId(const MInt fvId) {
130 // TODO labels:COUPLER,FV,LS,totest Is this check needed? This functions should never be called for these modes i
131 // guess..
132 if(fvMbSolver().m_levelSetMb && fvMbSolver().m_constructGField) {
133 return -1;
134 }
135 return convertId(fvMbSolver(), lsSolver(), fvId);
136 };
137 MInt fv2lsIdParent(const MInt fvId) {
138 // TODO labels:COUPLER,FV,LS,totest Is this check needed? This functions should never be called for these modes i
139 // guess..
140 if(fvMbSolver().m_levelSetMb && fvMbSolver().m_constructGField) {
141 return -1;
142 }
143 return convertIdParent(fvMbSolver(), lsSolver(), fvId);
144 };
145
146 void testCoupling();
147 void testLsValues();
148 void testGapProperty();
149 void computeBodyProperties(MInt returnMode, MFloat* bodyData, MInt body, MFloat time);
150
151 public:
152 void init() override;
153
154 void preCouple(MInt recepiStep) override;
155 void subCouple(MInt /* recipeStep = 0*/, MInt /*solverId*/, std::vector<MBool>& /*solverCompleted*/) override{};
156 void postCouple(MInt recipeStep = 0) override;
157 void finalizeCouplerInit() override;
158 void finalizeSubCoupleInit(MInt) override;
159
160 void postAdaptation() override;
161 void finalizeAdaptation(const MInt) override;
162 void prepareAdaptation() override;
163
164 void finalizeBalance(const MInt) override;
165 void balancePre() override{};
166 void balancePost() override{};
168
169 MInt noCouplingTimers(const MBool NotUsed(allTimings)) const override { return 2; }
170
171 void getCouplingTimings(std::vector<std::pair<MString, MFloat>>& timings, const MBool NotUsed(allTimings)) override {
172 const MString namePrefix = "c" + std::to_string(this->couplerId()) + "_";
173
174 timings.emplace_back(namePrefix + "loadCouplerLsFvMb", returnLoadRecord());
175 timings.emplace_back(namePrefix + "idleCouplerLsFvMb", returnIdleRecord());
176 };
177};
178
179
180#endif // ifndef LSFVMB_H_
GridCell
Grid cell Property Labels.
solverType & fvMbSolver() const
Definition: coupling.h:253
MInt a_noLevelSetsMb() const
Definition: coupling.h:258
MInt a_noFvGridCells() const
Definition: coupling.h:257
MFloat returnIdleRecord() const
Definition: coupling.h:159
void stopLoadTimer(const MString &name) const
Stop the load timer of the coupler.
Definition: coupling.h:152
void startLoadTimer(const MString &name) const
Start the load timer of the coupler.
Definition: coupling.h:148
MFloat returnLoadRecord() const
Definition: coupling.h:158
MInt couplerId() const
Definition: coupling.h:67
MInt a_noG0Cells(MInt set) const
Definition: coupling.h:194
solverType & lsSolver() const
Definition: coupling.h:188
MInt a_bodyIdG(const MInt cellId, const MInt set) const
Definition: coupling.h:203
MInt a_noLsCells() const
Definition: coupling.h:191
MBool a_inBandG(MInt gcellId, MInt set) const
Definition: coupling.h:217
MBool a_nearGapG(const MInt gcellId) const
Definition: coupling.h:219
MInt a_potentialGapCellClose(MInt gcellId) const
Definition: coupling.h:218
MFloat a_coordinateG(const MInt gCellId, const MInt dim) const
Definition: coupling.h:207
MFloat a_outsideGValue() const
Definition: coupling.h:192
MFloat & a_levelSetFunctionG(const MInt cellId, const MInt setId)
Definition: coupling.h:199
typename maia::grid::tree::Tree< nDim_ >::Cell Cell
Definition: lsfvmb.h:24
static constexpr MInt nDim
Definition: lsfvmb.h:26
void lsGapInfo(const MInt, MInt *)
returns the gap region for a given fvCell
Definition: lsfvmb.cpp:1402
void init() override
performs the coupling after solver initialization
Definition: lsfvmb.cpp:1431
void updateLevelSet()
update the levelset outside of the band default should be case 2 -> don't do anything!
Definition: lsfvmb.cpp:1240
void testGapProperty()
transfers the LevelSetValues from the levelset to the moving boundary Part
Definition: lsfvmb.cpp:241
MInt * m_hasGapCells
Definition: lsfvmb.h:63
MInt fv2lsIdParent(const MInt fvId)
Definition: lsfvmb.h:137
MFloat interpolateLevelSet(MInt cellId, MFloat *point, MInt set)
Definition: lsfvmb.cpp:528
void transferTimeStep()
transfers the gcell time step from the fvMbSolver! time should already be matching!
Definition: lsfvmb.cpp:1535
void initData()
Initialize coupling-class-specific Data.
Definition: lsfvmb.cpp:38
void transferBodyProperties()
transfer current body properties from the ls-Solver to the fv-Solver bodyPosition bodyVelocity bodyAc...
Definition: lsfvmb.cpp:1586
void readProperties()
reads lsfvmb-coupling-specific data
MFloat interpolateLevelSetMb(MInt *interpolationCells, MFloat *point, const MInt set)
Definition: lsfvmb.cpp:546
MInt noCouplingTimers(const MBool NotUsed(allTimings)) const override
Number of coupling timers.
Definition: lsfvmb.h:169
void finalizeAdaptation(const MInt) override
finalizeAdaptation
Definition: lsfvmb.cpp:1113
typename LsSolver::Cell LsCell
Definition: lsfvmb.h:39
void preCouple(MInt recepiStep) override
preCoupler
Definition: lsfvmb.cpp:1042
void transferLevelSetFieldValues(MBool)
transfers the LevelSetValues for all cells from the levelset to the moving boundary Part
Definition: lsfvmb.cpp:297
MInt ls2fvIdParent(const MInt lsId)
Definition: lsfvmb.h:128
void transferBodyRadius()
Copies the bodyRadius from the LS-solver into the FV-solver.
Definition: lsfvmb.cpp:1568
void computeBodyProperties(MInt returnMode, MFloat *bodyData, MInt body, MFloat time)
returns a specific property of the specifuec body used to provide a unique function for both level-se...
Definition: lsfvmb.cpp:736
MInt m_noRfJumps
Definition: lsfvmb.h:60
MFloat restartTime()
return restart time for lsSolver, when the fvSolver is not initialised yet!
Definition: lsfvmb.cpp:1351
MBool m_outsideDefault
Definition: lsfvmb.h:57
MBool m_static_updateLevelSetFlowSolver_firstRun
Definition: lsfvmb.h:69
void setGapState()
Sets the Gap-State in the fvmb-solver (stati are the same for all domains!) possible Gap-States:
Definition: lsfvmb.cpp:802
void postCouple(MInt recipeStep=0) override
postCoupler
Definition: lsfvmb.cpp:1067
void transferLevelSetValues()
Sets the Levelset-Values in fvSolver.
Definition: lsfvmb.cpp:265
void updateFlowSolver()
Updates the fv-mb-solver flow solver (after a completed levelSet TimeStep and finalizeLevelSet() )
Definition: lsfvmb.cpp:748
void updateLevelSetOutsideBandPar()
computes an approximate level set value for cells outside the level-set computing band should not be ...
Definition: lsfvmb.cpp:1264
MInt m_fvSolverId
Definition: lsfvmb.h:54
void finalizeCouplerInit() override
performs the final coupling after finalization
Definition: lsfvmb.cpp:1493
void testLsValues()
transfers the LevelSetValues from the levelset to the moving boundary Part
Definition: lsfvmb.cpp:218
void finalizeBalance(const MInt) override
called after each solver-balance
Definition: lsfvmb.cpp:1088
void buildCollectedLevelSet(const MInt)
build the combined levelSet for the given cellId
Definition: lsfvmb.cpp:1635
static constexpr const MInt m_noCorners
Definition: lsfvmb.h:65
MInt fv2lsId(const MInt fvId)
Definition: lsfvmb.h:129
MInt noLevelSetFieldData()
static constexpr const MInt m_maxNoGapRegions
Definition: lsfvmb.h:66
void transferAngularVelocity()
Writes the angular velocity and the angular acceleration from the LS-solver into the FV-solver.
Definition: lsfvmb.cpp:1615
void setGapGhostCellVariables(MInt)
void interpolateLsFV(const MInt, const MInt)
interpolate levelset values on the fv-grid
Definition: lsfvmb.cpp:499
void postAdaptation() override
finalizeAdaptation
Definition: lsfvmb.cpp:1207
MInt m_lsSolverId
Definition: lsfvmb.h:55
void balancePost() override
Definition: lsfvmb.h:166
MInt * m_hadGapCells
Definition: lsfvmb.h:62
void initFvGapCells()
Initialises fv-Gap Cells for gapHandling (must be called each timeStep before the gapHandling call in...
Definition: lsfvmb.cpp:980
void subCouple(MInt, MInt, std::vector< MBool > &) override
Definition: lsfvmb.h:155
MInt ls2fvId(const MInt lsId)
Definition: lsfvmb.h:127
void getCouplingTimings(std::vector< std::pair< MString, MFloat > > &timings, const MBool NotUsed(allTimings)) override
Definition: lsfvmb.h:171
typename maia::grid::tree::Tree< nDim >::Cell Cell
Definition: lsfvmb.h:41
MBool m_static_setGapState_first
Definition: lsfvmb.h:72
void initBodyProperties()
initialise the body properties in the fvmb-solver based
Definition: lsfvmb.cpp:1677
void balancePre() override
Load balancing.
Definition: lsfvmb.h:165
void transferGapCellProperty(MInt mode)
Sets the gap-cell-property mode 1 : regular call each timeStep (advance is/was-GapCell) mode 0 : init...
Definition: lsfvmb.cpp:569
MBool m_allowLsInterpolation
Definition: lsfvmb.h:59
void testCoupling()
transfers the LevelSetValues from the levelset to the moving boundary Part
Definition: lsfvmb.cpp:173
void prepareAdaptation() override
finalizeAdaptation
Definition: lsfvmb.cpp:1229
MBool m_static_setGapState_earlyOpened[m_maxNoGapRegions]
Definition: lsfvmb.h:73
void finalizeSubCoupleInit(MInt) override
performs the coupling in solver finalization
Definition: lsfvmb.cpp:1513
void checkProperties()
Checks property-data which is read in by both ls-and Fv-Solver.
Definition: lsfvmb.cpp:75
MInt convertId(SolverA &solverA, SolverB &solverB, const MInt solverAId)
Conversion from solverA id to the solverB id on the same-level only!
Definition: couplingutils.h:21
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
std::basic_string< char > MString
Definition: maiatypes.h:55
double MFloat
Definition: maiatypes.h:52
bool MBool
Definition: maiatypes.h:58