MUQ  0.4.3
UMBridgeModelServer.cpp
Go to the documentation of this file.
1 #include "FlowEquation.h"
2 
8 
10 
11 /***
12 ## Overview
13 
14 The UM-Bridge interface allows coupling model and UQ codes through HTTP. A model may then
15 be implemented in virtually any programming language or framework, run in a container
16 or even on a remote machine. Likewise, the model does not make any assumptions on how the client is implemented.
17 
18 This example shows how to provide a MUQ model to clients through the UM-Bridge interface, specifically
19 the client shown in the UM-Bridge Client example.
20 The server provides the physical model, while the client is responsible for the UQ side.
21 
22 The UM-Bridge interface is fully integrated in MUQ. In order to set up an UM-Bridge server,
23 it is enough to pass a ModPiece to the serveModPiece function. All functionality provided by
24 the ModPiece will then be available to the client.
25 */
26 
27 int main(){
28 
29 /***
30 ## Set up model
31 First, we set up our physical model in terms of a ModPiece. We reuse the same ModPiece that is explained in the
32 groundwater flow equation example, and give it a simple recharge function.
33 */
34 
35  unsigned int numCells = 200;
36  Eigen::VectorXd recharge = Eigen::VectorXd::Ones(numCells);
37 
38  auto model = std::make_shared<FlowEquation>(recharge);
39 
40 /***
41 ## Expose model via HTTP
42 Providing the model as an UM-Bridge via network is then just a single line. From that point on,
43 the server will run indefinitely, waiting for requests for model evaluations coming from clients.
44 Instructions for how to build a compatible client in MUQ can be found in the UM-Bridge Client example.
45 */
46 
47  muq::Modeling::serveModPiece(model, "forward", "0.0.0.0", 4242);
48 
49 }
int main()
void serveModPiece(std::shared_ptr< ModPiece > modPiece, std::string name, std::string host, int port)
Serve a ModPiece via network using UM-Bridge.