MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
couplerfvmultilevel.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 COUPLERFVMULTILEVEL_H_
8#define COUPLERFVMULTILEVEL_H_
9
10#include <map>
11#include <vector>
12#include "INCLUDE/maiatypes.h"
13#include "coupling.h"
14
15// Forward declarations
16class Solver;
17template <MInt nDim, class SysEqn>
19namespace maia {
20namespace grid {
21template <MInt nDim>
22class Proxy;
23} // namespace grid
24} // namespace maia
25template <MInt nDim>
26class CartesianGrid;
27
28
29template <MInt nDim, class SysEqn>
30class CouplerFvMultilevel : public CouplingFv<nDim, SysEqn> {
31 public:
32 using Base = Coupling;
36 using GridProxy = typename SolverType::GridProxy;
37
38 using BaseFv::fvSolver;
40
43
44 // Main coupling functions
45 void init() override;
48 void preCouple(MInt) override;
49 void subCouple(MInt, MInt, std::vector<MBool>&) override{};
50 void postCouple(MInt) override;
51 void cleanUp(){};
52 void getDomainDecompositionInformation(std::vector<std::pair<MString, MInt>>& NotUsed(domainInfo)) override{};
53 void finalizeAdaptation(MInt solverId);
54
55 void readProperties() override{};
56 void checkProperties() override{};
57
58 void restriction(const MInt level);
59 void resetTau(const MInt level); // TODO labels:COUPLER,toremove not used
60 void prolongation(const MInt level);
62 MBool startTimer(const MString& name);
63 MBool stopTimer(const MString& name);
64
65 private:
66
67 // Multilevel methods
68 void restrictData(const MInt level);
69 void computeCoarseLevelCorrection(const MInt level);
70 void storeRestrictedVariables(const MInt level);
71 void prolongData(const MInt level);
72
73 void correctCoarseBndryCells(const MInt solverId);
74
77 void initLeafCells();
78 void initMapping();
79 void initSplitMapping();
81
82 void sanityCheck(const MInt mode = 0);
83
84 // Timer management
85 MInt timer(const MString& name);
86 MInt& createTimer(const MString& name);
87 std::map<MString, MInt> m_timers{};
89 void initTimers();
90
91 // Multilevel data:
92 std::vector<std::vector<MInt>> m_leafCells{};
93 std::vector<std::vector<MInt>> m_coarse2fine{};
94 std::vector<std::vector<MInt>> m_fine2coarse{};
95 std::vector<std::vector<MInt>> m_restrictedCells{};
96 std::vector<std::vector<MInt>> m_splitCellMapping{};
97
98 // Multilevel properties:
101};
102
103
105template <MInt nDim, class SysEqn>
106class CouplerFvMultilevelInterpolation final : public CouplerFvMultilevel<nDim, SysEqn> {
107 public:
109 using Base = typename BaseCoupler::Base;
110 using BaseFv = typename BaseCoupler::BaseFv;
116
117 CouplerFvMultilevelInterpolation(const MInt couplingId,
118 // std::vector<std::unique_ptr<Solver>>* const solvers
120 solvers);
122
123 // Override the coupling routine of the FvMultilevel coupler
124 void postCouple(MInt) override;
125
126 private:
127 void reset(const MInt level);
128};
129
130#endif // #ifndef COUPLERFVMULTILEVEL_H_
void correctCoarseBndryCells(const MInt solverId)
solverType & fvSolver(const MInt solverId=0) const
Definition: coupling.h:386
std::vector< std::vector< MInt > > m_leafCells
MInt timer(const MString &name)
void initRestrictedCells()
for each solver that will be restricted (all except the coarsest), store restricted cells
std::vector< std::vector< MInt > > m_fine2coarse
typename SolverType::GridProxy GridProxy
std::map< MString, MInt > m_timers
void finalizeCouplerInit()
call after the initial adaptation when all cells are refined correctly
MBool stopTimer(const MString &name)
void postCouple(MInt) override
CouplingFv< nDim, SysEqn > BaseFv
void initLeafCells()
store internal leaf cells for each solver except for finest solver, for which they are not needed
void restrictData(const MInt level)
Restrict the data (fine-coarse) on the given level.
void resetSecondaryFlowVariables()
for each solver except the finest, reset variables to NaN to ensure that only restricted information ...
void prolongation(const MInt level)
Prolong the solution on the given coarse level onto the next finer level.
void storeRestrictedVariables(const MInt level)
Store the restricted variables (required for the prolongation)
typename BaseFv::solverType SolverType
void prolongData(const MInt level)
Prolong the data of a coarse level.
void finalizeAdaptation(MInt solverId)
call after the initial adaptation when all cells are refined correctly
void initSplitMapping()
for each coarse solver, store cell map of split-cells to next finer solver childs
std::vector< std::vector< MInt > > m_restrictedCells
std::vector< std::vector< MInt > > m_coarse2fine
void initMapping()
for each coarse solver, store cell map to next finer solver
MInt & createTimer(const MString &name)
void finalizeSubCoupleInit(MInt)
void preCouple(MInt) override
void subCouple(MInt, MInt, std::vector< MBool > &) override
void computeCoarseLevelCorrection(const MInt level)
Compute the coarse level correction tau.
void resetTau(const MInt level)
Reset the coarse level correction tau.
MBool startTimer(const MString &name)
MInt noSolvers() const
Definition: coupling.h:385
void getDomainDecompositionInformation(std::vector< std::pair< MString, MInt > > &NotUsed(domainInfo)) override
Return information on current domain decomposition (e.g. number of coupled cells/elements/....
void resetMultiLevelVariables()
for each solver, reset multilevel variables
void readProperties() override
void checkProperties() override
void init() override
void restriction(const MInt level)
Restrict the solution on the given fine level onto the next coarser level.
std::vector< std::vector< MInt > > m_splitCellMapping
FV multilevel interpolation coupler to transfer solution data of a coarse grid onto a finer grid.
typename BaseCoupler::Base Base
void postCouple(MInt) override
Coupling routine to transfer coarse level restart data to the finest level/solver.
void reset(const MInt level)
Reset variables/slopes of a level/solver.
typename BaseCoupler::BaseFv BaseFv
solverType & fvSolver(const MInt solverId=0) const
Definition: coupling.h:386
FvCartesianSolverXD< nDim, SysEqn > solverType
Definition: coupling.h:363
MInt noSolvers() const
Definition: coupling.h:385
Parent class of all solvers This class is the base for all solvers. I.e. all solver class (e....
Definition: solver.h:29
int32_t MInt
Definition: maiatypes.h:62
std::basic_string< char > MString
Definition: maiatypes.h:55
MInt * solvers
Definition: maiatypes.h:72
bool MBool
Definition: maiatypes.h:58
Namespace for auxiliary functions/classes.