Converts the simulation interceptors from the XSD format to the internal format.
175 std::vector<std::shared_ptr<SimulationInterceptor>> simulation_interceptors;
177 for (
auto frame_writer : interceptors.FrameWriter()) {
178 auto fps = frame_writer.fps();
179 auto video_length = frame_writer.video_length_s();
182 simulation_interceptors.push_back(std::make_shared<FrameWriterInterceptor>(output_format, fps, video_length));
185 for (
auto xsd_thermostat : interceptors.Thermostat()) {
186 auto target_temperature = xsd_thermostat.target_temperature();
187 auto max_temperature_change = xsd_thermostat.max_temperature_change();
188 auto application_interval = xsd_thermostat.application_interval();
190 std::shared_ptr<Thermostat> thermostat;
192 if (xsd_thermostat.type() == ThermostatType::value::absolute) {
193 thermostat = std::make_shared<AbsoluteThermostat>(target_temperature, max_temperature_change, third_dimension);
194 }
else if (xsd_thermostat.type() == ThermostatType::value::relative_motion) {
195 thermostat = std::make_shared<RelativeThermostat>(target_temperature, max_temperature_change, third_dimension);
198 throw std::runtime_error(
"Thermostat type not implemented");
201 simulation_interceptors.push_back(std::make_shared<ThermostatInterceptor>(thermostat, application_interval));
203 if (xsd_thermostat.temperature_sensor()) {
204 auto temperature_sensor = *xsd_thermostat.temperature_sensor();
205 auto sample_every_x_percent = temperature_sensor.sample_every_x_percent();
207 simulation_interceptors.push_back(std::make_shared<TemperatureSensorInterceptor>(thermostat, sample_every_x_percent));
211 if (interceptors.ParticleUpdatesPerSecond().size() > 0) {
212 simulation_interceptors.push_back(std::make_shared<ParticleUpdateCounterInterceptor>());
215 for (
auto diffusion_function : interceptors.DiffusionFunction()) {
216 auto sample_every_x_percent = diffusion_function.sample_every_x_percent();
217 simulation_interceptors.push_back(std::make_shared<DiffusionFunctionInterceptor>(sample_every_x_percent));
220 for (
auto xsd_rdf : interceptors.RadialDistributionFunction()) {
221 auto bin_width = xsd_rdf.bin_width();
222 auto sample_every_x_percent = xsd_rdf.sample_every_x_percent();
224 simulation_interceptors.push_back(std::make_shared<RadialDistributionFunctionInterceptor>(bin_width, sample_every_x_percent));
227 for (
auto xsd_vp : interceptors.VelocityProfile()) {
228 auto num_bins = xsd_vp.num_bins();
229 auto sample_every_x_percent = xsd_vp.sample_every_x_percent();
231 auto box_xsd = xsd_vp.box();
233 std::pair<std::array<double, 3>, std::array<double, 3>> box;
235 if (box_xsd.present()) {
236 auto box_data = *box_xsd;
238 auto bottom_left =
convertToVector(box_data.lower_left_front_corner());
241 box = std::make_pair(bottom_left, top_right);
244 [&box](
auto&& container) {
246 Logger::logger->error(
"Box must be specified if direct sum is used");
247 throw std::runtime_error(
"Box must be specified if direct sum is used");
249 auto bottom_left = std::array<double, 3>{0, 0, 0};
250 auto top_right = container.domain_size;
252 box = std::make_pair(bottom_left, top_right);
255 throw std::runtime_error(
"Container type not implemented");
261 simulation_interceptors.push_back(std::make_shared<VelocityProfileInterceptor>(box, num_bins, sample_every_x_percent));
264 simulation_interceptors.push_back(std::make_shared<ProgressBarInterceptor>());
266 return simulation_interceptors;