Plugins
Loading...
Searching...
No Matches
i_coupling_bridge.h
Go to the documentation of this file.
1//
2// Created by julian on 5/15/25.
3//
4
5#ifndef D3F_ISUBMODULEBRIDGE_H
6#define D3F_ISUBMODULEBRIDGE_H
8
9#include "common/common.h"
10
11
19#include <vector>
21#include "common/common.h"
22
23namespace ug {
24 class Vertex;
25}
26
27namespace ug {
28namespace d3f {
29
39 template<typename TDomain, int dim = TDomain::dim>
41 public:
43 virtual ~ISurjectiveInterface() = default;
44
48 virtual Vertex* subdom_to_dom(Vertex* subdom_vertex) const = 0;
49
53 virtual std::vector<Vertex*> dom_to_subdom(Vertex* dom_vertex) const = 0;
54 };
55
56
63 template<typename TGridFunction, int dim = TGridFunction::dim>
64 class ISubmodule {
65 public:
66 ISubmodule() = default;
67 virtual ~ISubmodule() = default;
68
75 virtual void run(number tStart, number tEnd, number dt) = 0;
76
77 protected:
79 };
80
81
91 template<typename TGridFunction, int dim = TGridFunction::dim>
93 friend class ISubmodule<TGridFunction, dim>;
94
95 public:
96 typedef typename TGridFunction::domain_type domain_type;
97 typedef typename domain_type::position_type position_type;
98
99 ISubmoduleBridge() = default;
100 virtual ~ISubmoduleBridge() = default;
101
106 bool apply(SmartPtr<TGridFunction> u, int step, number time, number dt) {
107 communicate(time);
108 // Submodule execution is typically triggered here or in finalize()
109 // depending on the coupling scheme (explicit/implicit).
110 finalize(time);
111 return true;
112 }
113
114 virtual bool finalize_timestep(SmartPtr<TGridFunction> u, int step, number time, number dt) = 0;
115 virtual bool init_timestep(SmartPtr<TGridFunction> u, int step, number time, number dt) = 0;
116
121 m_submodule = submodule;
122 }
123
128 m_interface = interface;
129 }
130
134 virtual void communicate(number time) = 0;
135
139 virtual void finalize(number time) = 0;
140
141 protected:
144 };
145
146} // namespace d3f
147} // namespace ug
148
149#endif // D3F_ISUBMODULEBRIDGE_H
Orchestrates the coupling between the main solver and a submodule.
Definition i_coupling_bridge.h:92
virtual bool finalize_timestep(SmartPtr< TGridFunction > u, int step, number time, number dt)=0
virtual void finalize(number time)=0
Performs any final operations after the submodule has finished its step.
domain_type::position_type position_type
Definition i_coupling_bridge.h:97
bool apply(SmartPtr< TGridFunction > u, int step, number time, number dt)
Core coupling step called by the main time integrator. Performs communication, executes the submodule...
Definition i_coupling_bridge.h:106
virtual ~ISubmoduleBridge()=default
TGridFunction::domain_type domain_type
Definition i_coupling_bridge.h:96
SmartPtr< ISurjectiveInterface< domain_type > > m_interface
Definition i_coupling_bridge.h:143
void set_submodule(SmartPtr< ISubmodule< TGridFunction > > submodule)
Attaches the submodule to the bridge.
Definition i_coupling_bridge.h:120
SmartPtr< ISubmodule< TGridFunction > > m_submodule
Definition i_coupling_bridge.h:142
virtual bool init_timestep(SmartPtr< TGridFunction > u, int step, number time, number dt)=0
void set_interface(SmartPtr< ISurjectiveInterface< domain_type > > interface)
Attaches the surjective interface for vertex mapping.
Definition i_coupling_bridge.h:127
virtual void communicate(number time)=0
Synchronizes data from the primary domain to the submodule.
Abstract base class for independent sub-solvers (e.g., 1D St. Venant).
Definition i_coupling_bridge.h:64
virtual ~ISubmodule()=default
virtual void run(number tStart, number tEnd, number dt)=0
Executes the submodule's internal solver for the given time interval.
SmartPtr< TGridFunction > m_u
The internal state of the submodule.
Definition i_coupling_bridge.h:78
Interface for mapping vertices between a subdomain and the primary domain.
Definition i_coupling_bridge.h:40
virtual Vertex * subdom_to_dom(Vertex *subdom_vertex) const =0
Maps a vertex from the subdomain to its counterpart in the primary domain.
virtual ~ISurjectiveInterface()=default
virtual std::vector< Vertex * > dom_to_subdom(Vertex *dom_vertex) const =0
Maps a vertex from the primary domain to all corresponding vertices in the subdomain.
double number