MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
couplingutils.h File Reference

Go to the source code of this file.

Functions

template<class SolverA , class SolverB >
MInt convertId (SolverA &solverA, SolverB &solverB, const MInt solverAId)
 Conversion from solverA id to the solverB id on the same-level only! More...
 
template<class SolverA , class SolverB >
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, a connection through the Cell-parents is used! More...
 

Function Documentation

◆ convertId()

template<class SolverA , class SolverB >
MInt convertId ( SolverA &  solverA,
SolverB &  solverB,
const MInt  solverAId 
)
Author
Tim Wegmann, Julian Vorspohl

Definition at line 21 of file couplingutils.h.

21 {
22 if(solverAId >= solverA.c_noCells() || solverAId < 0) return -1;
23 solverA.assertValidGridCellId(solverAId);
24
25 const MInt gridId = solverA.grid().tree().solver2grid(solverAId);
26 ASSERT(solverA.grid().solverFlag(gridId, solverA.solverId()), "");
27
28 if(!solverB.grid().solverFlag(gridId, solverB.solverId())) return -1;
29
30 const MInt solverBId = solverB.grid().tree().grid2solver(gridId);
31
32 if(solverBId > 0) {
33 ASSERT(solverA.a_level(solverAId) == solverB.a_level(solverBId),
34 std::to_string(solverAId) + " " + std::to_string(solverA.a_level(solverAId)) + " "
35 + std::to_string(solverB.a_level(solverBId)));
36 }
37
38 return solverBId;
39}
int32_t MInt
Definition: maiatypes.h:62

◆ convertIdParent()

template<class SolverA , class SolverB >
MInt convertIdParent ( SolverA &  solverA,
SolverB &  solverB,
const MInt  solverAId 
)
Author
Tim Wegmann, Julian Vorspohl

Definition at line 46 of file couplingutils.h.

46 {
47 if(solverAId >= solverA.c_noCells() || solverAId < 0) return -1; // not even a grid-cell, still return -1
48 solverA.assertValidGridCellId(solverAId);
49
50 MInt gridId = solverA.grid().tree().solver2grid(solverAId);
51 ASSERT(solverA.grid().solverFlag(gridId, solverA.solverId()), "");
52
53 if(solverB.grid().solverFlag(gridId, solverB.solverId())) { // connection on the same level!
54 return solverB.grid().tree().grid2solver(gridId);
55
56 } else { // going through all parents! to find a connection
57
58 MInt solverAParentId = solverA.c_parentId(solverAId);
59 MInt solverBParentId = convertId(solverA, solverB, solverAParentId);
60
61 while(solverBParentId < 0 && solverAParentId > -1 && solverAParentId < solverA.c_noCells()) {
62 solverAParentId = solverA.c_parentId(solverAParentId);
63 solverBParentId = convertId(solverA, solverB, solverAParentId);
64 }
65 return solverBParentId;
66 }
67}
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