MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
lbsolverfactory.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
7#include "lbsolverfactory.h"
8
9#include <sstream>
10#include "IO/context.h"
11#include "UTIL/functions.h"
12#include "lbsolverdxqy.cpp" // yes, .cpp is correct here
13#include "lbsyseqn.h"
14
15namespace maia::lb {
16
17template <MInt nDim>
18std::unique_ptr<Solver> LbSolverFactory<nDim>::create(const MInt solverId, maia::grid::Proxy<nDim>& gridProxy,
19 Geometry<nDim>& geometry, const MPI_Comm comm) {
20 //---read properties----------------------------------------------------------
33 MInt noDistributions = 9;
34 noDistributions = Context::getSolverProperty<MInt>("noDistributions", solverId, AT_, &noDistributions);
35
36 // << temporary
37 const MString solverMethod = Context::getSolverProperty<MString>("solverMethod", solverId, AT_);
38 std::set<MInt> compressibleMethods = {
41 MBool isCompressible = compressibleMethods.count(string2enum(solverMethod));
42 // temporary >>
43 isCompressible = Context::getSolverProperty<MBool>("isCompressible", solverId, AT_, &isCompressible);
44
45 //---create solver and return-------------------------------------------------
46 if(isCompressible) {
47 //
48 if constexpr(nDim == 2) {
49 switch(noDistributions) {
50 case 9: {
51 return std::make_unique<LbSolverDxQy<2, 9, LbSysEqnCompressible<2, 9>>>(solverId, 9, gridProxy, geometry,
52 gridProxy.mpiComm());
53 break;
54 }
55 default: {
56 std::stringstream ss;
57 ss << "Error: D" << nDim << "Q" << noDistributions << " is unsupported !" << std::endl;
58 mTerm(1, ss.str());
59 }
60 }
61 } else if constexpr(nDim == 3) {
62 switch(noDistributions) {
63 case 19: {
64 return std::make_unique<LbSolverDxQy<3, 19, LbSysEqnCompressible<3, 19>>>(solverId, 19, gridProxy, geometry,
65 comm);
66 break;
67 }
68 case 27: {
69 return std::make_unique<LbSolverDxQy<3, 27, LbSysEqnCompressible<3, 27>>>(solverId, 27, gridProxy, geometry,
70 comm);
71 break;
72 }
73 default: {
74 std::stringstream ss;
75 ss << "Error: D" << nDim << "Q" << noDistributions << " is unsupported !" << std::endl;
76 mTerm(1, ss.str());
77 }
78 }
79 }
80 } else {
81 if constexpr(nDim == 2) {
82 switch(noDistributions) {
83 case 9: {
84 return std::make_unique<LbSolverDxQy<2, 9, LbSysEqnIncompressible<2, 9>>>(solverId, 9, gridProxy, geometry,
85 gridProxy.mpiComm());
86 }
87 default: {
88 std::stringstream ss;
89 ss << "Error: D" << nDim << "Q" << noDistributions << " is unsupported !" << std::endl;
90 mTerm(1, ss.str());
91 break;
92 }
93 }
94 } else if constexpr(nDim == 3) {
95 switch(noDistributions) {
96 case 19: {
97 return std::make_unique<LbSolverDxQy<nDim, 19, LbSysEqnIncompressible<3, 19>>>(solverId, 19, gridProxy,
98 geometry, gridProxy.mpiComm());
99 break;
100 }
101 case 27: {
102 return std::make_unique<LbSolverDxQy<nDim, 27, LbSysEqnIncompressible<3, 27>>>(solverId, 27, gridProxy,
103 geometry, gridProxy.mpiComm());
104 break;
105 }
106 default: {
107 std::stringstream ss;
108 ss << "Error: D" << nDim << "Q" << noDistributions << " is unsupported !" << std::endl;
109 mTerm(1, ss.str());
110 break;
111 }
112 }
113 }
114 }
115}
116
117// Explicit instantiation
118template class LbSolverFactory<2>;
119template class LbSolverFactory<3>;
120
121} // namespace maia::lb
MPI_Comm mpiComm() const
Definition: geometry.h:45
static std::unique_ptr< Solver > create(const MInt solverId, maia::grid::Proxy< nDim > &gridProxy, Geometry< nDim > &geometry, const MPI_Comm comm)
MInt string2enum(MString theString)
This global function translates strings in their corresponding enum values (integer values)....
Definition: enums.cpp:20
@ MAIA_LATTICE_CUMULANT
Definition: enums.h:98
@ MAIA_LATTICE_BGK_TOTALENERGY
Definition: enums.h:86
@ MAIA_LATTICE_BGK_INNERENERGY
Definition: enums.h:85
@ MAIA_LATTICE_BGK_THERMAL_TRANSPORT
Definition: enums.h:88
@ MAIA_LATTICE_BGKC
Definition: enums.h:77
@ MAIA_LATTICE_BGK_THERMAL
Definition: enums.h:84
void mTerm(const MInt errorCode, const MString &location, const MString &message)
Definition: functions.cpp:29
int32_t MInt
Definition: maiatypes.h:62
std::basic_string< char > MString
Definition: maiatypes.h:55
bool MBool
Definition: maiatypes.h:58