3 #include "../../include/matrixFreePDE.h" 4 #include <deal.II/numerics/data_out.h> 7 template <
int dim,
int degree>
10 computing_timer.enter_section(
"matrixFreePDE: output");
13 DataOut<dim> data_out;
17 for(
unsigned int fieldIndex=0; fieldIndex<fields.size(); fieldIndex++){
19 std::vector<DataComponentInterpretation::DataComponentInterpretation> dataType \
20 (fields[fieldIndex].numComponents, \
21 (fields[fieldIndex].type==
SCALAR ? \
22 DataComponentInterpretation::component_is_scalar: \
23 DataComponentInterpretation::component_is_part_of_vector));
25 std::vector<std::string> solutionNames (fields[fieldIndex].numComponents, fields[fieldIndex].name.c_str());
26 data_out.add_data_vector(*dofHandlersSet[fieldIndex], *solutionSet[fieldIndex], solutionNames, dataType);
31 if (userInputs.postProcessingRequired){
32 std::vector<vectorType*> postProcessedSet;
33 computePostProcessedFields(postProcessedSet);
35 unsigned int invM_size = invM.local_size();
36 for(
unsigned int fieldIndex=0; fieldIndex<postProcessedSet.size(); fieldIndex++){
37 for (
unsigned int dof=0; dof<postProcessedSet[fieldIndex]->local_size(); ++dof){
38 postProcessedSet[fieldIndex]->local_element(dof)= \
39 invM.local_element(dof%invM_size)*postProcessedSet[fieldIndex]->local_element(dof);
41 constraintsOtherSet[0]->distribute(*postProcessedSet[fieldIndex]);
42 postProcessedSet[fieldIndex]->update_ghost_values();
46 std::ofstream output_file;
48 if (userInputs.num_integrated_fields > 0){
49 if (first_integrated_var_output_complete){
50 output_file.open(
"integratedFields.txt", std::ios::app);
53 output_file.open(
"integratedFields.txt", std::ios::out);
55 output_file.precision(10);
57 if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0){
58 output_file << currentTime;
61 for (
unsigned int i=0; i<userInputs.pp_number_of_variables; i++){
62 if (userInputs.pp_calc_integral[i]){
63 double integrated_field;
64 computeIntegral(integrated_field,i,postProcessedSet);
65 pcout <<
"Integrated value of " << userInputs.pp_var_name[userInputs.integrated_field_indices[i]] <<
": " << integrated_field << std::endl;
66 if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0){
67 output_file <<
"\t" << userInputs.pp_var_name[userInputs.integrated_field_indices[i]] <<
"\t" << integrated_field;
71 if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0){
72 output_file << std::endl;
75 first_integrated_var_output_complete =
true;
79 for(
unsigned int fieldIndex=0; fieldIndex<userInputs.pp_number_of_variables; fieldIndex++){
81 unsigned int components;
82 if (userInputs.pp_varInfoList[fieldIndex].is_scalar){
84 std::vector<DataComponentInterpretation::DataComponentInterpretation> dataType(components,DataComponentInterpretation::component_is_scalar);
85 std::vector<std::string> solutionNames (components, userInputs.pp_var_name[fieldIndex].c_str());
87 data_out.add_data_vector(*dofHandlersSet[0], *postProcessedSet[fieldIndex], solutionNames, dataType);
91 std::vector<DataComponentInterpretation::DataComponentInterpretation> dataType(components,DataComponentInterpretation::component_is_part_of_vector);
92 std::vector<std::string> solutionNames (components, userInputs.pp_var_name[fieldIndex].c_str());
95 data_out.add_data_vector(*dofHandlersSet[0], *postProcessedSet[fieldIndex], solutionNames, dataType);
100 data_out.build_patches (degree);
104 std::ostringstream cycleAsString;
105 cycleAsString << std::setw(std::floor(std::log10(userInputs.totalIncrements))+1) << std::setfill(
'0') << currentIncrement;
106 char baseFileName[100], vtuFileName[100];
107 sprintf(baseFileName,
"%s-%s", userInputs.output_file_name.c_str(), cycleAsString.str().c_str());
108 sprintf(vtuFileName,
"%s.%u.%s", baseFileName,Utilities::MPI::this_mpi_process(MPI_COMM_WORLD),userInputs.output_file_type.c_str());
111 if (userInputs.output_file_type ==
"vtu"){
114 dealii::DataOutBase::VtkFlags flags;
115 flags.time = currentTime;
116 flags.cycle = currentIncrement;
117 flags.print_date_and_time =
true;
118 data_out.set_flags(flags);
120 if (userInputs.output_vtu_per_process){
122 std::ofstream output (vtuFileName);
123 data_out.write_vtu (output);
126 if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0){
127 std::vector<std::string> filenames;
128 for (
unsigned int i=0;i<Utilities::MPI::n_mpi_processes (MPI_COMM_WORLD); ++i) {
129 char vtuProcFileName[100];
130 sprintf(vtuProcFileName,
"%s-%s.%u.%s", userInputs.output_file_name.c_str(),cycleAsString.str().c_str(),i,userInputs.output_file_type.c_str());
131 filenames.push_back (vtuProcFileName);
133 char pvtuFileName[100];
134 sprintf(pvtuFileName,
"%s.p%s", baseFileName, userInputs.output_file_type.c_str());
135 std::ofstream master_output (pvtuFileName);
137 data_out.write_pvtu_record (master_output, filenames);
138 pcout <<
"Output written to:" << pvtuFileName <<
"\n\n";
144 char svtuFileName[100];
145 sprintf(svtuFileName,
"%s.%s", baseFileName ,userInputs.output_file_type.c_str());
146 data_out.write_vtu_in_parallel(svtuFileName, MPI_COMM_WORLD);
147 pcout <<
"Output written to:" << svtuFileName <<
"\n\n";
150 else if (userInputs.output_file_type ==
"vtk"){
152 std::ofstream output (vtuFileName);
153 data_out.write_vtk (output);
154 pcout <<
"Output written to:" << vtuFileName <<
"\n\n";
157 std::cerr <<
"PRISMS-PF Error: The parameter 'outputFileType' must be either \"vtu\" or \"vtk\"" << std::endl;
162 computing_timer.exit_section(
"matrixFreePDE: output");
165 #include "../../include/matrixFreePDE_template_instantiations.h"