Multiscale Universal Interface  2.0
A Concurrent Framework for Coupling Heterogeneous Solvers
mui.h
Go to the documentation of this file.
1 /*****************************************************************************
2 * Multiscale Universal Interface Code Coupling Library *
3 * *
4 * Copyright (C) 2019 Y. H. Tang, S. Kudo, X. Bian, Z. Li, G. E. Karniadakis *
5 * *
6 * This software is jointly licensed under the Apache License, Version 2.0 *
7 * and the GNU General Public License version 3, you may use it according *
8 * to either. *
9 * *
10 * ** Apache License, version 2.0 ** *
11 * *
12 * Licensed under the Apache License, Version 2.0 (the "License"); *
13 * you may not use this file except in compliance with the License. *
14 * You may obtain a copy of the License at *
15 * *
16 * http://www.apache.org/licenses/LICENSE-2.0 *
17 * *
18 * Unless required by applicable law or agreed to in writing, software *
19 * distributed under the License is distributed on an "AS IS" BASIS, *
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
21 * See the License for the specific language governing permissions and *
22 * limitations under the License. *
23 * *
24 * ** GNU General Public License, version 3 ** *
25 * *
26 * This program is free software: you can redistribute it and/or modify *
27 * it under the terms of the GNU General Public License as published by *
28 * the Free Software Foundation, either version 3 of the License, or *
29 * (at your option) any later version. *
30 * *
31 * This program is distributed in the hope that it will be useful, *
32 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
33 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
34 * GNU General Public License for more details. *
35 * *
36 * You should have received a copy of the GNU General Public License *
37 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
38 *****************************************************************************/
39 
48 #ifndef MUI_H_
49 #define MUI_H_
50 
51 //Include spatial samplers
62 
63 //Include temporal samplers
68 
69 //Include coupling algorithms
72 
73 //Include other library headers
74 #include "samplers/sampler.h"
75 #include "communication/comm.h"
76 #include "communication/comm_mpi.h"
78 #include "general/dim.h"
81 #include "uniface.h"
82 #include "general/util.h"
83 #include <string>
84 
85 namespace mui {
86 
87 #define DECLARE_SAMPLER_1ARG(SAMPLER,SUFFIX,CONFIG) \
88  template<typename T> using SAMPLER ## SUFFIX = SAMPLER<CONFIG,T,T>;
89 #define DECLARE_SAMPLER_0ARG(SAMPLER,SUFFIX,CONFIG) \
90  using SAMPLER ## SUFFIX = SAMPLER<CONFIG>;
91 
92 #define SPECIALIZE(SUFFIX,REALTYPE,INTTYPE,DIM) \
93  typedef struct config_##SUFFIX {\
94  using EXCEPTION = exception_segv;\
95  static const bool DEBUG = false;\
96  static const int D = DIM;\
97  static const bool FIXEDPOINTS = false;\
98  static const bool QUIET = false;\
99  using REAL = REALTYPE;\
100  using INT = INTTYPE;\
101  using point_type = point<REAL,D>;\
102  using time_type = REAL;\
103  using iterator_type = INT;\
104  using data_types = type_list<uint32_t,uint64_t,int32_t,int64_t,double,float,std::string>;\
105  } mui_config_##SUFFIX;\
106  using uniface##SUFFIX = uniface<config_##SUFFIX>;\
107  using point##SUFFIX = point<config_##SUFFIX::REAL,config_##SUFFIX::D>;\
108  DECLARE_SAMPLER_1ARG(sampler_sum_quintic,SUFFIX,config_##SUFFIX)\
109  DECLARE_SAMPLER_1ARG(sampler_sph_quintic,SUFFIX,config_##SUFFIX)\
110  DECLARE_SAMPLER_1ARG(sampler_shepard_quintic,SUFFIX,config_##SUFFIX)\
111  DECLARE_SAMPLER_1ARG(sampler_nearest_neighbor,SUFFIX,config_##SUFFIX)\
112  DECLARE_SAMPLER_1ARG(sampler_pseudo_nearest_neighbor,SUFFIX,config_##SUFFIX)\
113  DECLARE_SAMPLER_1ARG(sampler_pseudo_n2_linear,SUFFIX,config_##SUFFIX)\
114  DECLARE_SAMPLER_1ARG(sampler_moving_average,SUFFIX,config_##SUFFIX)\
115  DECLARE_SAMPLER_1ARG(sampler_exact,SUFFIX,config_##SUFFIX)\
116  DECLARE_SAMPLER_1ARG(sampler_gauss,SUFFIX,config_##SUFFIX)\
117  DECLARE_SAMPLER_1ARG(sampler_rbf,SUFFIX,config_##SUFFIX)\
118  DECLARE_SAMPLER_0ARG(temporal_sampler_exact,SUFFIX,config_##SUFFIX);\
119  DECLARE_SAMPLER_0ARG(temporal_sampler_gauss,SUFFIX,config_##SUFFIX);\
120  DECLARE_SAMPLER_0ARG(temporal_sampler_sum,SUFFIX,config_##SUFFIX);\
121  DECLARE_SAMPLER_0ARG(temporal_sampler_mean,SUFFIX,config_##SUFFIX);\
122  DECLARE_SAMPLER_0ARG(algo_fixed_relaxation,SUFFIX,config_##SUFFIX);\
123  DECLARE_SAMPLER_0ARG(algo_aitken,SUFFIX,config_##SUFFIX);\
124  namespace geometry {\
125  using point##SUFFIX = point<config_##SUFFIX>;\
126  using sphere##SUFFIX = sphere<config_##SUFFIX>;\
127  using box##SUFFIX = box<config_##SUFFIX>;\
128  using or_set##SUFFIX = or_set<config_##SUFFIX>;\
129  }
130 
131 SPECIALIZE(1d,double,int32_t,1);
132 SPECIALIZE(2d,double,int32_t,2);
133 SPECIALIZE(3d,double,int32_t,3);
134 SPECIALIZE(1dx,double,int64_t,1);
135 SPECIALIZE(2dx,double,int64_t,2);
136 SPECIALIZE(3dx,double,int64_t,3);
137 SPECIALIZE(1f,float,int32_t,1);
138 SPECIALIZE(2f,float,int32_t,2);
139 SPECIALIZE(3f,float,int32_t,3);
140 SPECIALIZE(1fx,float,int64_t,1);
141 SPECIALIZE(2fx,float,int64_t,2);
142 SPECIALIZE(3fx,float,int64_t,3);
143 
144 #undef SPECIALIZE
145 
146 // usage: SPECIALIZE( _your_custom_suffix, your_custom_config_structure )
147 // uniface_your_custom_suffix interface; ...
148 #define SPECIALIZE(SUFFIX,CONFIG) \
149  namespace mui {\
150  using uniface##SUFFIX = uniface<CONFIG>;\
151  using point##SUFFIX = point<CONFIG::REAL,CONFIG::D>;\
152  DECLARE_SAMPLER_1ARG(sampler_nearest_neighbor,SUFFIX,CONFIG)\
153  DECLARE_SAMPLER_1ARG(sampler_pseudo_nearest_neighbor,SUFFIX,CONFIG)\
154  DECLARE_SAMPLER_1ARG(sampler_pseudo_n2_linear,SUFFIX,CONFIG)\
155  DECLARE_SAMPLER_1ARG(sampler_moving_average,SUFFIX,CONFIG)\
156  DECLARE_SAMPLER_1ARG(sampler_exact,SUFFIX,CONFIG)\
157  DECLARE_SAMPLER_1ARG(sampler_rbf,SUFFIX,CONFIG)\
158  DECLARE_SAMPLER_1ARG(sampler_gauss,SUFFIX,CONFIG)\
159  DECLARE_SAMPLER_0ARG(temporal_sampler_exact,SUFFIX,CONFIG);\
160  DECLARE_SAMPLER_0ARG(temporal_sampler_gauss,SUFFIX,CONFIG);\
161  DECLARE_SAMPLER_0ARG(temporal_sampler_sum,SUFFIX,CONFIG);\
162  DECLARE_SAMPLER_0ARG(temporal_sampler_mean,SUFFIX,CONFIG);\
163  DECLARE_SAMPLER_0ARG(algo_fixed_relaxation,SUFFIX,CONFIG);\
164  DECLARE_SAMPLER_0ARG(algo_aitken,SUFFIX,CONFIG);\
165  }
166 
167 }
168 
169 #endif /* MUI_H_ */
Aitken coupling algorithm.
Fixed Relaxation coupling algorithm.
File containing class definition of communication interface. This is the base class for all other com...
Class definition of base MPI communicator.
Structures and methods for a smart (communication reducing) communicator type.
File providing data specialisms at different dimensionalities.
Provides helper functions for creating and synchronising multiple MUI interfaces for a single domain.
Provides helper functions to generate (and finalize) a new MPI comm world that can then be used by an...
Definition: comm.h:54
SPECIALIZE(1d, double, int32_t, 1)
A reference file for making custom samplers. The new sampler does not have to derive from this class,...
Spatial sampler that provides a value at an exact point with no interpolation.
Spatial sampler that provides a value at a point using Gaussian interpolation.
Spatial sampler that provides a value at a point using a moving average interpolation.
Spatial sampler that provides a value at a point using a nearest neighbour interpolation.
Spatial sampler that provides a value at a point using a pseudo-linear n^2 interpolation.
Spatial sampler that provides a value at a point using a pseudo nearest neighbour interpolation.
Spatial sampler using Radial Basis Function interpolation.
Spatial sampler that provides a value at a point using a Smoothed Particle Hydrodynamics (SPH) derive...
Spatial sampler that provides a value at a point using summation with a quintic kernel.
Temporal sampler that samples at exactly the time specified and performs no interpolation.
Temporal sampler that applies Gaussian interpolation and is symmetric for past and future.
Temporal sampler that averages in time with a range from [ now - left, now + right ].
Temporal sampler that sums in time ranging from [ now - left, now + right ].
Provides the majority of the useful functionality for MUI, including all fetch, commit and push funct...
Provides a number of utility functions used through the rest of the library.