44 relative(
const std::string &filename)
47 if (rel.find_last_of(
'/') != std::string::npos)
48 rel = rel.substr(rel.find_last_of(
'/') + 1);
54 dirname(
const std::string &filename)
57 if (rel.find_last_of(
'/') != std::string::npos)
58 rel = rel.substr(0, rel.find_last_of(
'/'));
63 (
"test -d " + rel +
" || mkdir -p " + rel).c_str()) == 0,
64 ExcMessage(
"Could not create directory " + rel));
71 template <
int dim,
int spacedim>
73 const std::string &base_name,
74 const std::string &output_format,
75 const unsigned int &subdivisions,
76 const bool &write_higher_order_cells,
82 , output_format(output_format)
83 , subdivisions(subdivisions)
84 , write_higher_order_cells(write_higher_order_cells)
85 , base_name(base_name)
101 add_parameter(
"Write high order cells", this->write_higher_order_cells);
108 template <
int dim,
int spacedim>
117 template <
int dim,
int spacedim>
121 const std::string &suffix)
123 data_out = std::make_unique<dealii::DataOut<dim, spacedim>>();
124 data_out->set_default_format(
128 master_name = relative(base_name);
129 auto fname = base_name + (suffix.empty() ?
"" :
"_" + suffix);
130 current_filename = relative(fname);
131 current_directory = dirname(fname);
133 if (subdivisions == 0)
136 if (write_higher_order_cells && dim > 1)
140 data_out->set_flags(flags);
143 if (data_out->default_suffix() !=
"")
147 if (n_mpi_processes > 1)
150 data_out->default_suffix());
152 fname += data_out->default_suffix();
154 output_file.open(fname);
156 data_out->attach_dof_handler(dh);
158 if (n_mpi_processes > 1)
161 if (output_partitioning)
165 for (
unsigned int i = 0; i < partitioning.
size(); ++i)
166 partitioning(i) = this_mpi_process;
168 static_partitioning.
swap(partitioning);
169 data_out->add_data_vector(
172 dealii::DataOut<dim, spacedim>::type_cell_data);
176 if (output_material_ids)
181 material_ids(cell->active_cell_index()) = cell->material_id();
182 data_out->add_data_vector(
185 dealii::DataOut<dim, spacedim>::type_cell_data);
192 template <
int dim,
int spacedim>
197 if (output_format ==
"none")
201 if (data_out->default_suffix() !=
"")
203 data_out->build_patches(mapping,
205 this->curved_cells_region);
206 data_out->write(output_file);
208 std::string master_file = current_filename;
210 if (this_mpi_process == 0 && n_mpi_processes > 1 &&
211 data_out->default_suffix() ==
".vtu")
213 std::vector<std::string> filenames;
214 for (
unsigned int i = 0; i < n_mpi_processes; ++i)
215 filenames.push_back(relative(current_filename) +
"." +
218 data_out->default_suffix());
220 std::ofstream master_output(
221 (current_directory +
"/" + current_filename +
".pvtu").c_str());
222 data_out->write_pvtu_record(master_output, filenames);
224 master_file +=
".pvtu";
228 master_file += data_out->default_suffix();
231 pvd_record.push_back(
232 std::make_pair(pvd_record.size(), relative(master_file)));
234 if (this_mpi_process == 0)
236 std::ofstream pvd_output(
237 (current_directory +
"/" + master_name +
".pvd"));
const FiniteElement< dim, spacedim > & get_fe(const types::fe_index index=0) const
const Triangulation< dim, spacedim > & get_triangulation() const
const unsigned int degree
static ParameterHandler prm
void add_parameter(const std::string &entry, ParameterType ¶meter, const std::string &documentation="", ParameterHandler &prm_=prm, const Patterns::PatternBase &pattern=*Patterns::Tools::Convert< ParameterType >::to_pattern())
unsigned int n_active_cells() const
virtual size_type size() const override
virtual void swap(Vector< Number > &v)
virtual void reinit(const size_type N, const bool omit_zeroing_entries=false)
IteratorRange< active_cell_iterator > active_cell_iterators() const
static ::ExceptionBase & ExcIO()
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
void write_pvd_record(std::ostream &out, const std::vector< std::pair< double, std::string > > ×_and_names)
OutputFormat parse_output_format(const std::string &format_name)
std::string get_output_format_names()
std::string int_to_string(const unsigned int value, const unsigned int digits=numbers::invalid_unsigned_int)
*braid_SplitCommworld & comm
bool write_higher_order_cells