-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcosimulation_interface.h
149 lines (137 loc) · 5.33 KB
/
cosimulation_interface.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
///////////////////////////////////////////////////////////////////////////////
///
/// \file cosimulation_interface.c
///
/// \brief Functions for cosimulation
///
/// \author Wangda Zuo
/// University of Miami
/// W.Zuo@miami.edu
///
/// \date 8/3/2013
///
/// This file provides functions that are used for conducting the cosimulaiton
/// with Modelica
///
///////////////////////////////////////////////////////////////////////////////
#ifndef _COSIMULATION_INTERFACE_H
#define _COSIMULATION_INTERFACE_H
#endif
#ifndef _DATA_STRUCTURE_H
#define _DATA_STRUCTURE_H
#include "data_structure.h"
#endif
#ifndef _UTILITY_H
#define _UTILITY_H
#include "utility.h"
#endif
#ifndef _GEOMETRY_H
#define _GEOMETRY_H
#include "geometry.h"
#endif
#ifndef _MSC_VER //Linux
#define Sleep(x) sleep(x/1000)
#endif
///////////////////////////////////////////////////////////////////////////////
/// Read the cosimulation parameters defined by Modelica
///
///\param para Pointer to FFD parameters
///\param var Pointer to FFD simulation variables
///\param BINDEX pointer to boudnary index
///
///\return 0 if no error occurred
///////////////////////////////////////////////////////////////////////////////
int read_cosim_parameter(PARA_DATA *para, REAL **var, int **BINDEX);
///////////////////////////////////////////////////////////////////////////////
/// Write the FFD data for Modelica
///
///\param para Pointer to FFD parameters
///\param var Pointer to FFD simulation variables
///
///\return 0 if no error occurred
///////////////////////////////////////////////////////////////////////////////
int write_cosim_data(PARA_DATA *para, REAL **var);
///////////////////////////////////////////////////////////////////////////////
/// Read the data from Modelica
///
///\param para Pointer to FFD parameters
///\param var Pointer to FFD simulation variables
///\param BINDEX pointer to boudnary index
///
///\return 0 if no error occurred
///////////////////////////////////////////////////////////////////////////////
int read_cosim_data(PARA_DATA *para, REAL **var, int **BINDEX);
///////////////////////////////////////////////////////////////////////////////
/// Compare the names of boundaries and store the relationship
///
///\param para Pointer to FFD parameters
///
///\return 0 if no error occurred
///////////////////////////////////////////////////////////////////////////////
int compare_boundary_names(PARA_DATA *para);
///////////////////////////////////////////////////////////////////////////////
/// Compare the area of boundaries
///
///\param para Pointer to FFD parameters
///\param var Pointer to the FFD simulaiton variables
///\param BINDEX Pointer to boundary index
///
///\return 0 if no error occurred
///////////////////////////////////////////////////////////////////////////////
int compare_boundary_area(PARA_DATA *para, REAL **var, int **BINDEX);
///////////////////////////////////////////////////////////////////////////////
/// Assign the Modelica solid surface thermal boundary condition data to FFD
///
///\param para Pointer to FFD parameters
///\param var Pointer to the FFD simulaiton variables
///\param BINDEX Pointer to boundary index
///
///\return 0 if no error occurred
///////////////////////////////////////////////////////////////////////////////
int assign_thermal_bc(PARA_DATA *para, REAL **var, int **BINDEX);
///////////////////////////////////////////////////////////////////////////////
/// Assign the Modelica inlet and outlet boundary condition data to FFD
///
/// The inlet and outlet boundaries are not fixed and they can change during
/// the simulation. The reason is that the Modelica uses acausal modeling
/// and the flow direction can change during the simulation depending on the
/// pressure difference. As a result, the FFD has to change its inlet and outlet
/// boundry condition accordingly. The inlet or outlet boundary is decided
/// according to the flow rate para->cosim->modelica->mFloRarPor. The port is
/// inlet if mFloRarPor>0 and outlet if mFloRarPor<0. We will need to reset the
/// var[FLAGP][IX(i,j,k)] to apply the change of boundary conditions.
///
///\param para Pointer to FFD parameters
///\param var Pointer to the FFD simulaiton variables
///\param BINDEX Pointer to boundary index
///
///\return 0 if no error occurred
///////////////////////////////////////////////////////////////////////////////
int assign_port_bc(PARA_DATA *para, REAL **var, int **BINDEX);
///////////////////////////////////////////////////////////////////////////////
/// Integrate the cosimulation exchange data over the surfaces
///
/// Fluid port:
/// - T/Xi/C: sum(u*T*dA)
/// - m_dot: sum(u*dA)
///
/// Solid Surface Boundary:
/// - T: sum(T*dA)
/// - Q_dot: sum(q_dot*dA)
///
///\param para Pointer to FFD parameters
///\param var Pointer to FFD simulation variables
///\param BINDEX Pointer to the boundary index
///
///\return 0 if no error occurred
///////////////////////////////////////////////////////////////////////////////
int surface_integrate(PARA_DATA *para, REAL **var, int **BINDEX);
///////////////////////////////////////////////////////////////////////////////
/// Set sensor data
///
///\param para Pointer to FFD parameters
///\param var Pointer to FFD data
///
///\return 0 if no error occurred
///////////////////////////////////////////////////////////////////////////////
int set_sensor_data(PARA_DATA *para, REAL **var);