7#ifndef COUPLINGUTILS_H_
8#define COUPLINGUTILS_H_
20template <
class SolverA,
class SolverB>
22 if(solverAId >= solverA.c_noCells() || solverAId < 0)
return -1;
23 solverA.assertValidGridCellId(solverAId);
25 const MInt gridId = solverA.grid().tree().solver2grid(solverAId);
26 ASSERT(solverA.grid().solverFlag(gridId, solverA.solverId()),
"");
28 if(!solverB.grid().solverFlag(gridId, solverB.solverId()))
return -1;
30 const MInt solverBId = solverB.grid().tree().grid2solver(gridId);
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)));
45template <
class SolverA,
class SolverB>
47 if(solverAId >= solverA.c_noCells() || solverAId < 0)
return -1;
48 solverA.assertValidGridCellId(solverAId);
50 MInt gridId = solverA.grid().tree().solver2grid(solverAId);
51 ASSERT(solverA.grid().solverFlag(gridId, solverA.solverId()),
"");
53 if(solverB.grid().solverFlag(gridId, solverB.solverId())) {
54 return solverB.grid().tree().grid2solver(gridId);
58 MInt solverAParentId = solverA.c_parentId(solverAId);
59 MInt solverBParentId =
convertId(solverA, solverB, solverAParentId);
61 while(solverBParentId < 0 && solverAParentId > -1 && solverAParentId < solverA.c_noCells()) {
62 solverAParentId = solverA.c_parentId(solverAParentId);
63 solverBParentId =
convertId(solverA, solverB, solverAParentId);
65 return solverBParentId;
MInt convertId(SolverA &solverA, SolverB &solverB, const MInt solverAId)
Conversion from solverA id to the solverB id on the same-level only!
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,...