-
Notifications
You must be signed in to change notification settings - Fork 232
/
interface.cc
210 lines (176 loc) · 5.86 KB
/
interface.cc
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
/*
Copyright (C) 2015 by the authors of the ASPECT code.
This file is part of ASPECT.
ASPECT is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
ASPECT is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ASPECT; see the file doc/COPYING. If not see
<http://www.gnu.org/licenses/>.
*/
#include <aspect/particle/output/interface.h>
namespace aspect
{
namespace Particle
{
namespace Output
{
template <int dim>
Interface<dim>::~Interface ()
{}
template <int dim>
void
Interface<dim>::declare_parameters (ParameterHandler &)
{}
template <int dim>
void
Interface<dim>::parse_parameters (ParameterHandler &)
{}
template <int dim>
void
Interface<dim>::initialize ()
{}
template <int dim>
template <class Archive>
void Interface<dim>::serialize (Archive &ar, const unsigned int)
{}
template <int dim>
void
Interface<dim>::save (std::ostringstream &) const
{}
template <int dim>
void
Interface<dim>::load (std::istringstream &)
{}
template <int dim>
const std::string
Interface<dim>::get_file_name()
{
// To prevent warning statement during compilation
return "";
}
template <int dim>
const std::string
Interface<dim>::get_particle_output_location()
{
// To prevent warning statement during compilation
return "";
}
template <int dim>
const std::string
Interface<dim>::get_file_index()
{
// To prevent warning statement during compilation
return "";
}
// -------------------------------- Deal with registering models and automating
// -------------------------------- their setup and selection at run time
namespace
{
std_cxx1x::tuple
<void *,
void *,
aspect::internal::Plugins::PluginList<Interface<2> >,
aspect::internal::Plugins::PluginList<Interface<3> > > registered_plugins;
}
template <int dim>
void
register_particle_output (const std::string &name,
const std::string &description,
void (*declare_parameters_function) (ParameterHandler &),
Interface<dim> *(*factory_function) ())
{
std_cxx1x::get<dim>(registered_plugins).register_plugin (name,
description,
declare_parameters_function,
factory_function);
}
template <int dim>
Interface<dim> *
create_particle_output (const std::string &name)
{
Interface<dim> *output
= std_cxx1x::get<dim>(registered_plugins).create_plugin (name,
"Particle::Output name");
return output;
}
template <int dim>
std::string
get_names()
{
return std_cxx11::get<dim>(registered_plugins).get_pattern_of_names ();
}
template <int dim>
void
declare_parameters (ParameterHandler &prm)
{
// declare the entry in the parameter file
prm.enter_subsection ("Postprocess");
{
prm.enter_subsection ("Particles");
{
const std::string pattern_of_names
= std_cxx1x::get<dim>(registered_plugins).get_pattern_of_names ();
prm.declare_entry ("Data output format", "vtu",
Patterns::List (Patterns::Selection(pattern_of_names + "|none")),
"File format to output raw particle data in. "
"Multiple formats can be specified sperated by a comma (,)"
"If you select 'none' no output will be "
"written."
"Select one or multiple of the following models:\n\n"
+
std_cxx1x::get<dim>(registered_plugins).get_description_string());
}
prm.leave_subsection ();
}
prm.leave_subsection ();
std_cxx1x::get<dim>(registered_plugins).declare_parameters (prm);
}
}
}
}
// explicit instantiations
namespace aspect
{
namespace internal
{
namespace Plugins
{
template <>
std::list<internal::Plugins::PluginList<Particle::Output::Interface<2> >::PluginInfo> *
internal::Plugins::PluginList<Particle::Output::Interface<2> >::plugins = 0;
template <>
std::list<internal::Plugins::PluginList<Particle::Output::Interface<3> >::PluginInfo> *
internal::Plugins::PluginList<Particle::Output::Interface<3> >::plugins = 0;
}
}
namespace Particle
{
namespace Output
{
#define INSTANTIATE(dim) \
template class Interface<dim>; \
\
template \
void \
register_particle_output<dim> (const std::string &, \
const std::string &, \
void ( *) (ParameterHandler &), \
Interface<dim> *( *) ()); \
\
template \
void \
declare_parameters<dim> (ParameterHandler &); \
\
template \
Interface<dim> * \
create_particle_output<dim> (const std::string &name);
ASPECT_INSTANTIATE(INSTANTIATE)
}
}
}