namespace
{
+#ifdef DEAL_II_WITH_ZLIB
+ constexpr bool deal_ii_with_zlib = true;
+#else
+ constexpr bool deal_ii_with_zlib = false;
+#endif
+
+
#ifdef DEAL_II_WITH_ZLIB
/**
* Convert between the CompressionLevel enum (used inside VtkFlags
}
}
# endif
+#endif
/**
* Do a zlib compression followed by a base64 encoding of the given data. The
compress_array(const std::vector<T> & data,
const DataOutBase::CompressionLevel compression_level)
{
+#ifdef DEAL_II_WITH_ZLIB
if (data.size() != 0)
{
const std::size_t uncompressed_size = (data.size() * sizeof(T));
}
else
return {};
- }
-
+#else
+ (void)data;
+ (void)compression_level;
+ Assert(false,
+ ExcMessage("This function can only be called if cmake found "
+ "a working libz installation."));
+ return {};
#endif
+ }
const DataOutBase::CompressionLevel compression_level,
const int precision)
{
- (void)compression_level;
- (void)precision;
-
-#ifdef DEAL_II_WITH_ZLIB
- if (compression_level != DataOutBase::CompressionLevel::plain_text)
+ if (deal_ii_with_zlib &&
+ (compression_level != DataOutBase::CompressionLevel::plain_text))
{
// compress the data we have in memory
return compress_array(data, compression_level);
}
else
-#endif
{
std::ostringstream stream;
stream.precision(precision);
const unsigned int start,
const std::vector<unsigned> &connectivity)
{
-#ifdef DEAL_II_WITH_ZLIB
- if (flags.compression_level != DataOutBase::CompressionLevel::plain_text)
+ if (deal_ii_with_zlib &&
+ (flags.compression_level != DataOutBase::CompressionLevel::plain_text))
{
for (const auto &c : connectivity)
cells.push_back(start + c);
}
else
-#endif
{
for (const auto &c : connectivity)
stream << '\t' << start + c;
void
VtuStream::flush_cells()
{
-#ifdef DEAL_II_WITH_ZLIB
- if (flags.compression_level != DataOutBase::CompressionLevel::plain_text)
+ if (deal_ii_with_zlib &&
+ (flags.compression_level != DataOutBase::CompressionLevel::plain_text))
{
// compress the data we have in memory and write them to the stream.
// then release the data
stream.precision());
cells.clear();
}
-#endif
}
} // namespace
out << "<VTKFile type=\"UnstructuredGrid\" version=\"2.2\"";
else
out << "<VTKFile type=\"UnstructuredGrid\" version=\"0.1\"";
-#ifdef DEAL_II_WITH_ZLIB
- if (flags.compression_level != CompressionLevel::plain_text)
+ if (deal_ii_with_zlib &&
+ (flags.compression_level != CompressionLevel::plain_text))
out << " compressor=\"vtkZLibDataCompressor\"";
-#endif
#ifdef DEAL_II_WORDS_BIGENDIAN
out << " byte_order=\"BigEndian\"";
#else
}
const char *ascii_or_binary =
-#ifdef DEAL_II_WITH_ZLIB
- (flags.compression_level != CompressionLevel::plain_text) ? "binary" :
-#endif
- "ascii";
+ (deal_ii_with_zlib &&
+ (flags.compression_level != CompressionLevel::plain_text)) ?
+ "binary" :
+ "ascii";
// first count the number of cells and cells for later use
static const std::array<unsigned int, 5>
pyramid_index_translation_table = {{0, 1, 3, 2, 4}};
-#ifdef DEAL_II_WITH_ZLIB
- if (flags.compression_level !=
- DataOutBase::CompressionLevel::plain_text)
+ if (deal_ii_with_zlib &&
+ (flags.compression_level !=
+ DataOutBase::CompressionLevel::plain_text))
{
for (unsigned int i = 0; i < n_points; ++i)
cells.push_back(
i));
}
else
-#endif
{
for (unsigned int i = 0; i < n_points; ++i)
out << '\t'
{
auto write_cell =
[&flags, &out, &cells](const unsigned int start) {
-#ifdef DEAL_II_WITH_ZLIB
- if (flags.compression_level !=
- DataOutBase::CompressionLevel::plain_text)
+ if (deal_ii_with_zlib &&
+ (flags.compression_level !=
+ DataOutBase::CompressionLevel::plain_text))
{
cells.push_back(start);
}
else
-#endif
{
out << start;
out << '\n';
auto write_cell =
[&flags, &out, &cells, d1](const unsigned int start) {
-#ifdef DEAL_II_WITH_ZLIB
- if (flags.compression_level !=
- DataOutBase::CompressionLevel::plain_text)
+ if (deal_ii_with_zlib &&
+ (flags.compression_level !=
+ DataOutBase::CompressionLevel::plain_text))
{
cells.push_back(start);
cells.push_back(start + d1);
}
else
-#endif
{
out << start << '\t' << start + d1;
out << '\n';
auto write_cell = [&flags, &out, &cells, d1, d2](
const unsigned int start) {
-#ifdef DEAL_II_WITH_ZLIB
- if (flags.compression_level !=
- DataOutBase::CompressionLevel::plain_text)
+ if (deal_ii_with_zlib &&
+ (flags.compression_level !=
+ DataOutBase::CompressionLevel::plain_text))
{
cells.push_back(start);
cells.push_back(start + d1);
cells.push_back(start + d2);
}
else
-#endif
{
out << start << '\t' << start + d1 << '\t'
<< start + d2 + d1 << '\t' << start + d2;
auto write_cell = [&flags, &out, &cells, d1, d2, d3](
const unsigned int start) {
-#ifdef DEAL_II_WITH_ZLIB
- if (flags.compression_level !=
- DataOutBase::CompressionLevel::plain_text)
+ if (deal_ii_with_zlib &&
+ (flags.compression_level !=
+ DataOutBase::CompressionLevel::plain_text))
{
cells.push_back(start);
cells.push_back(start + d1);
cells.push_back(start + d3 + d2);
}
else
-#endif
{
out << start << '\t' << start + d1 << '\t'
<< start + d2 + d1 << '\t' << start + d2
}
}
- // Flush the 'cells' object we created herein.
-#ifdef DEAL_II_WITH_ZLIB
- if (flags.compression_level !=
- DataOutBase::CompressionLevel::plain_text)
+ // Flush the 'cells' object we created herein.
+ if (deal_ii_with_zlib && (flags.compression_level !=
+ DataOutBase::CompressionLevel::plain_text))
{
out << vtu_stringize_array(cells,
flags.compression_level,
out.precision())
<< '\n';
}
-#endif
}
out << " </DataArray>\n";
<< ascii_or_binary << "\">\n";
// this should compress well :-)
-#ifdef DEAL_II_WITH_ZLIB
- if (flags.compression_level != CompressionLevel::plain_text)
+ if (deal_ii_with_zlib &&
+ (flags.compression_level != CompressionLevel::plain_text))
{
std::vector<uint8_t> cell_types_uint8_t(cell_types.size());
for (unsigned int i = 0; i < cell_types.size(); ++i)
out.precision());
}
else
-#endif
{
out << vtu_stringize_array(cell_types,
flags.compression_level,
write_vtu(f);
#else
- const unsigned int myrank = Utilities::MPI::this_mpi_process(comm);
+ const unsigned int myrank = Utilities::MPI::this_mpi_process(comm);
const unsigned int n_ranks = Utilities::MPI::n_mpi_processes(comm);
- MPI_Info info;
- int ierr = MPI_Info_create(&info);
+ MPI_Info info;
+ int ierr = MPI_Info_create(&info);
AssertThrowMPI(ierr);
MPI_File fh;
ierr = MPI_File_open(
AssertThrowMPI(ierr);
// Define header size so we can broadcast later.
- unsigned int header_size;
+ unsigned int header_size;
std::uint64_t footer_offset;
// write header
AssertThrowMPI(ierr);
{
- const auto &patches = get_patches();
+ const auto & patches = get_patches();
const types::global_dof_index my_n_patches = patches.size();
const types::global_dof_index global_n_patches =
Utilities::MPI::sum(my_n_patches, comm);
// Use prefix sum to find specific offset to write at.
const std::uint64_t size_on_proc = ss.str().size();
- std::uint64_t prefix_sum = 0;
+ std::uint64_t prefix_sum = 0;
ierr =
MPI_Exscan(&size_on_proc, &prefix_sum, 1, MPI_UINT64_T, MPI_SUM, comm);
AssertThrowMPI(ierr);
// from this rank to rank 0 (if they are different ranks).
const bool have_data = (data_filter.n_nodes() > 0);
- MPI_Comm split_comm;
+ MPI_Comm split_comm;
{
- const int key = myrank;
+ const int key = myrank;
const int color = (have_data ? 1 : 0);
- const int ierr = MPI_Comm_split(comm, color, key, &split_comm);
+ const int ierr = MPI_Comm_split(comm, color, key, &split_comm);
AssertThrowMPI(ierr);
}
ExcNotImplemented());
# endif
- XDMFEntry entry(h5_mesh_filename,
+ XDMFEntry entry(h5_mesh_filename,
h5_solution_filename,
cur_time,
global_node_cell_count[0],
// receive the XDMF data on rank 0 if we don't have it...
MPI_Status status;
- int ierr = MPI_Probe(MPI_ANY_SOURCE, tag, comm, &status);
+ int ierr = MPI_Probe(MPI_ANY_SOURCE, tag, comm, &status);
AssertThrowMPI(ierr);
int len;
// create a new communicator that only contains ranks with cells and
// use that to perform the write operations:
const bool have_patches = (patches.size() > 0);
- MPI_Comm split_comm;
+ MPI_Comm split_comm;
{
- const int key = Utilities::MPI::this_mpi_process(comm);
+ const int key = Utilities::MPI::this_mpi_process(comm);
const int color = (have_patches ? 1 : 0);
- const int ierr = MPI_Comm_split(comm, color, key, &split_comm);
+ const int ierr = MPI_Comm_split(comm, color, key, &split_comm);
AssertThrowMPI(ierr);
}