MoDeNa  1.0
Software framework facilitating sequential multi-scale modelling
MacroscopicProblem.C
1 
39 #include <stdio.h>
40 #include <iostream>
41 #include "modena.h"
42 
43 using namespace std;
44 
45 int
46 main(int argc, char *argv[])
47 {
48  double T = 270;
49  double Tend = 290.0;
50 
51  // Instantiate index set
52  //modena_index_set_t *indexSet = modena_index_set_new("species");
53 
54 
55  // Instantiate a model
56  modena_model_t *model = modena_model_new("SurfaceTension[A=AIR,B=THF]"); //muss das FunctionModule genau so heißen??
57  if(modena_error_occurred())
58  {
59  return modena_error();
60  }
61 
62  // Allocate memory and fetch arg positions
63  modena_inputs_t *inputs = modena_inputs_new(model); //How many inputs and outputs is defined in the function module!!
64  modena_outputs_t *outputs = modena_outputs_new(model);
65 
66 
67  size_t Tpos = modena_model_inputs_argPos(model, "T");
68 
70 
71 
72  while(T < Tend)
73  {
74  // Set input vector
75  modena_inputs_set(inputs, Tpos, T);
76 
77  // Call the model
78  int ret = modena_model_call(model, inputs, outputs);
79 
80  // Terminate, if requested
81  if(modena_error_occurred())
82  {
83  modena_inputs_destroy(inputs);
84  modena_outputs_destroy(outputs);
85  modena_model_destroy(model);
86 
87  return modena_error();
88  }
89 
90  // Fetch result
91  double rho = modena_outputs_get(outputs, 0);
92 
93  cout << "T = " << T;
94 
95 
96  T = T + 10.0;
97  }
98 
99 
100  modena_inputs_destroy(inputs);
101  modena_outputs_destroy(outputs);
102  modena_model_destroy(model);
103 
104  return 0;
105 }
size_t modena_model_inputs_argPos(const modena_model_t *self, const char *name)
Function determining position of an argument in the input vector.
Definition: model.c:366
modena_model_t * modena_model_new(const char *modelId)
Function fetching a surrogate model from MongoDB.
Definition: model.c:281
int modena_model_call(modena_model_t *self, modena_inputs_t *inputs, modena_outputs_t *outputs)
Function calling the surrogate model and checking for errors.
Definition: model.c:553
int main(int argc, char *argv[])
Reads parameters. Creates struts and walls. Saves foam morphology to a file.
Definition: foams.cc:23
stores a surrogate model
Definition: model.h:94
void modena_model_destroy(modena_model_t *self)
Function deallocating the memory allocated for the surrogate model.
Definition: model.c:665
Definition: model.f90:7
void modena_model_argPos_check(const modena_model_t *self)
Function checking that the user has queried all input positions.
Definition: model.c:408