]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Output both real and imaginary parts of the solution.
authorWolfgang Bangerth <bangerth@colostate.edu>
Wed, 8 Nov 2017 03:56:39 +0000 (20:56 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Wed, 8 Nov 2017 03:56:39 +0000 (20:56 -0700)
source/numerics/data_out.cc

index b485c6936f3a70ac6fc33679b883c401c676944a..f8a3a827ae2af1aaa60fa6b4a9e2775710a26dd0 100644 (file)
@@ -226,23 +226,50 @@ build_one_patch
             // reasons.
             if (n_components == 1)
               {
+                // first output the real part of the solution vector
                 this->dof_data[dataset]->get_function_values (this_fe_patch_values,
                                                               internal::DataOut::ComponentExtractor::real_part,
                                                               scratch_data.patch_values_scalar.solution_values);
                 for (unsigned int q=0; q<n_q_points; ++q)
                   patch.data(offset,q) = scratch_data.patch_values_scalar.solution_values[q];
+
+                // and if there is one, also output the imaginary part
+                if (this->dof_data[dataset]->is_complex_valued() == true)
+                  {
+                    this->dof_data[dataset]->get_function_values (this_fe_patch_values,
+                                                                  internal::DataOut::ComponentExtractor::imaginary_part,
+                                                                  scratch_data.patch_values_scalar.solution_values);
+                    for (unsigned int q=0; q<n_q_points; ++q)
+                      patch.data(offset+1,q) = scratch_data.patch_values_scalar.solution_values[q];
+                  }
               }
             else
               {
                 scratch_data.resize_system_vectors(n_components);
+
+                // same as above: first the real part
+                const unsigned int stride = (this->dof_data[dataset]->is_complex_valued() ? 2 : 1);
                 this->dof_data[dataset]->get_function_values (this_fe_patch_values,
                                                               internal::DataOut::ComponentExtractor::real_part,
                                                               scratch_data.patch_values_system.solution_values);
                 for (unsigned int component=0; component<n_components;
                      ++component)
                   for (unsigned int q=0; q<n_q_points; ++q)
-                    patch.data(offset+component,q) =
+                    patch.data(offset+component*stride,q) =
                       scratch_data.patch_values_system.solution_values[q](component);
+
+                // and if there is one, also output the imaginary part
+                if (this->dof_data[dataset]->is_complex_valued() == true)
+                  {
+                    this->dof_data[dataset]->get_function_values (this_fe_patch_values,
+                                                                  internal::DataOut::ComponentExtractor::imaginary_part,
+                                                                  scratch_data.patch_values_system.solution_values);
+                    for (unsigned int component=0; component<n_components;
+                         ++component)
+                      for (unsigned int q=0; q<n_q_points; ++q)
+                        patch.data(offset+component*stride+1,q) =
+                          scratch_data.patch_values_system.solution_values[q](component);
+                  }
               }
 
           // increment the counter for the actual data record

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.