MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
dgcartesianboundaryconditionfactory.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 DGBOUNDARYCONDITIONFACTORY_H_
8#define DGBOUNDARYCONDITIONFACTORY_H_
9
10#include <memory>
11#include "INCLUDE/maiatypes.h"
12#include "factory.h"
13
14template <MInt nDim, class SysEqn>
16template <MInt nDim, class SysEqn>
18
19namespace maia {
20namespace dg {
21namespace bc {
22
24template <typename T>
25struct Type {
26 using type = T;
27};
28
29} // namespace bc
30} // namespace dg
31} // namespace maia
32
33
47template <MInt nDim, class SysEqn>
49 public:
50 using IdType = MInt;
51 using ReturnType = std::unique_ptr<DgBoundaryCondition<nDim, SysEqn>>;
53 using ProductCreator = std::function<ReturnType(SolverType&, IdType)>;
54
55 public:
57 explicit DgBoundaryConditionFactory(SolverType& solver) : m_solver(solver) {}
58
60 template <class T>
62 return m_factory.add(id, [](SolverType& solver, IdType bcId) { return ReturnType(new T(solver, bcId)); });
63 }
64
66 ReturnType create(const IdType id) { return m_factory.create(id, m_solver, id); }
67
68 private:
71};
72
73namespace maia {
74namespace dg {
75namespace bc {
76namespace factory {
77
85template <MInt nDim, class SysEqn>
86struct Init {
88 static void init(FactoryType& factory);
89};
90
91} // namespace factory
92} // namespace bc
93} // namespace dg
94} // namespace maia
95
96#endif // DGBOUNDARYCONDITIONFACTORY_H_
Class to handle creation of boundary condition objects.
MBool add(const IdType id, maia::dg::bc::Type< T >)
Add new type to factory.
ReturnType create(const IdType id)
Create type from identifier.
MFactory< DgBoundaryCondition< nDim, SysEqn >, IdType, ReturnType, ProductCreator, SolverType &, IdType > m_factory
std::unique_ptr< DgBoundaryCondition< nDim, SysEqn > > ReturnType
DgBoundaryConditionFactory(SolverType &solver)
Constructor only saves solver reference to member variable.
std::function< ReturnType(SolverType &, IdType)> ProductCreator
Class implementing the object factory pattern.
Definition: factory.h:36
int32_t MInt
Definition: maiatypes.h:62
bool MBool
Definition: maiatypes.h:58
Namespace for auxiliary functions/classes.
Simple type-to-type mapper for function overloading.
static void init(FactoryType &factory)