Skip to content

Commit

Permalink
Make 8.5.0 compile
Browse files Browse the repository at this point in the history
  • Loading branch information
gassmoeller committed Jul 26, 2017
1 parent ead4e22 commit 48b929c
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 16 deletions.
24 changes: 14 additions & 10 deletions include/aspect/postprocess/particles.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace aspect
{
namespace Postprocess
{
#if DEAL_II_VERSION_GTE(9,0,0)
namespace internal
{
/**
Expand Down Expand Up @@ -99,6 +100,7 @@ namespace aspect
std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > vector_datasets;
};
}
#endif

/**
* A Postprocessor that creates particles, which follow the
Expand Down Expand Up @@ -227,6 +229,17 @@ namespace aspect
*/
double last_output_time;

/**
* Set the time output was supposed to be written. In the simplest
* case, this is the previous last output time plus the interval, but
* in general we'd like to ensure that it is the largest supposed
* output time, which is smaller than the current time, to avoid
* falling behind with last_output_time and having to catch up once
* the time step becomes larger. This is done after every output.
*/
void set_last_output_time (const double current_time);

#if DEAL_II_VERSION_GTE(9,0,0)
/**
* Consecutively counted number indicating the how-manyth time we will
* create output the next time we get to it.
Expand All @@ -238,16 +251,6 @@ namespace aspect
*/
std::string output_format;

/**
* Set the time output was supposed to be written. In the simplest
* case, this is the previous last output time plus the interval, but
* in general we'd like to ensure that it is the largest supposed
* output time, which is smaller than the current time, to avoid
* falling behind with last_output_time and having to catch up once
* the time step becomes larger. This is done after every output.
*/
void set_last_output_time (const double current_time);

/**
* A list of pairs (time, pvtu_filename) that have so far been written
* and that we will pass to DataOutInterface::write_pvd_record
Expand Down Expand Up @@ -342,6 +345,7 @@ namespace aspect
void write_master_files (const internal::ParticleOutput<dim> &data_out,
const std::string &solution_file_prefix,
const std::vector<std::string> &filenames);
#endif
};
}
}
Expand Down
41 changes: 35 additions & 6 deletions source/postprocess/particles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ namespace aspect
{
namespace Postprocess
{
#if DEAL_II_VERSION_GTE(9,0,0)
namespace internal
{
template<int dim>
Expand All @@ -57,7 +58,7 @@ namespace aspect
dataset_names.push_back(field_name);
else
for (unsigned int component_index=0; component_index<n_components; ++component_index)
dataset_names.push_back(field_name + "[" + Utilities::to_string(component_index) + "]");
dataset_names.push_back(field_name + "_" + Utilities::to_string(component_index));
}


Expand Down Expand Up @@ -97,7 +98,6 @@ namespace aspect

for (unsigned int property_index = 0; property_index < properties.size(); ++property_index)
patches[i].data(property_index+1,0) = properties[property_index];

}
}

Expand All @@ -123,7 +123,7 @@ namespace aspect
}

}

#endif

template <int dim>
Particles<dim>::Particles ()
Expand All @@ -132,18 +132,22 @@ namespace aspect
output_interval (0),
// initialize this to a nonsensical value; set it to the actual time
// the first time around we get to check it
last_output_time (std::numeric_limits<double>::quiet_NaN()),
output_file_number (numbers::invalid_unsigned_int),
last_output_time (std::numeric_limits<double>::quiet_NaN())
#if DEAL_II_VERSION_GTE(9,0,0)
,output_file_number (numbers::invalid_unsigned_int),
group_files(0),
write_in_background_thread(false)
#endif
{}

template <int dim>
Particles<dim>::~Particles ()
{
#if DEAL_II_VERSION_GTE(9,0,0)
// make sure a thread that may still be running in the background,
// writing data, finishes
background_thread.join ();
#endif
}

template <int dim>
Expand Down Expand Up @@ -174,6 +178,7 @@ namespace aspect
return world;
}

#if DEAL_II_VERSION_GTE(9,0,0)
template <int dim>
void Particles<dim>::writer (const std::string filename,
const std::string temporary_output_location,
Expand Down Expand Up @@ -304,6 +309,7 @@ namespace aspect
output_file_names_by_timestep[timestep]));
DataOutBase::write_visit_record (global_visit_master, times_and_output_file_names);
}
#endif

template <int dim>
std::pair<std::string,std::string>
Expand Down Expand Up @@ -334,6 +340,7 @@ namespace aspect
if (world.get_property_manager().need_update() == Particle::Property::update_output_step)
world.update_particles();

#if DEAL_II_VERSION_GTE(9,0,0)
if (output_file_number == numbers::invalid_unsigned_int)
output_file_number = 0;
else
Expand Down Expand Up @@ -498,6 +505,21 @@ namespace aspect
statistics.add_value ("Particle file name",
particle_output);
return std::make_pair("Writing particle output:", particle_output);
#else
set_last_output_time (this->get_time());
const std::string data_file_name = world.generate_output();

// If we do not write output return early with the number of particles
// that were advected
if (data_file_name == "")
return std::make_pair("Number of advected particles:",
Utilities::int_to_string(world.n_global_particles()));

// record the file base file name in the output file
statistics.add_value ("Particle file name",
this->get_output_directory() + data_file_name);
return std::make_pair("Writing particle output:", data_file_name);
#endif
}


Expand Down Expand Up @@ -527,10 +549,13 @@ namespace aspect
void Particles<dim>::serialize (Archive &ar, const unsigned int)
{
ar &last_output_time
#if DEAL_II_VERSION_GTE(9,0,0)
& output_file_number
& times_and_pvtu_file_names
& output_file_names_by_timestep
& xdmf_entries ;
& xdmf_entries
#endif
;
}


Expand Down Expand Up @@ -642,6 +667,7 @@ namespace aspect
ExcMessage("Postprocessing nonlinear iterations in models with "
"particles is currently not supported."));

#if DEAL_II_VERSION_GTE(9,0,0)
output_format = prm.get ("Data output format");

if (output_format != "none")
Expand Down Expand Up @@ -670,6 +696,7 @@ namespace aspect
"there is a terminal available to move the files to their final location "
"after writing. The system() command did not succeed in finding such a terminal."));
}
#endif
}
prm.leave_subsection ();
}
Expand All @@ -690,13 +717,15 @@ namespace aspect
{
namespace Postprocess
{
#if DEAL_II_VERSION_GTE(9,0,0)
namespace internal
{
#define INSTANTIATE(dim) \
template class ParticleOutput<dim>;

ASPECT_INSTANTIATE(INSTANTIATE)
}
#endif

ASPECT_REGISTER_POSTPROCESSOR(Particles,
"particles",
Expand Down

0 comments on commit 48b929c

Please sign in to comment.