Page 369 - TransAT_Tutorial_Manual
P. 369

TransAT Tutorial Manual                                                   9.1. Water suction




               The MPI Allreduce method is called to get the total mass of water (stored in global water mass)
               by summing the partial masses computed by each processor and using the MPI SUM combination
               operator

               // Sum partial masses from all processors
               MPI_Allreduce(&local_water_mass, &global_water_mass, 1, MPI_DOUBLE,
                               MPI_SUM, MPI_COMM_WORLD);

               Further information regarding the MPI Allreduce method can be found in the Parallel post-
               processing section in the TransAT User Manual .

               The time and the computed mass are then append to the Time and Mass vectors using the
               push back command

               // Append data to vectors storing time and water mass
               Time.push_back(t);
               Mass.push_back(global_water_mass);


                   write time mass function      The write time mass function makes use of the function from
               the TransAT parallel toolbox. The mpi.h and toolbox.h must be included to make it work.


               It writes the data contained in the Time and Mass vectors alongside a header with the colum-
               n/variable mapping to a file, test output.dat


               // Set variable names for header
               varnames.push_back("Time s");
               varnames.push_back("Mass kg");
               // Group data
               std::vector<std::vector<double> > variables;
               variables.push_back(Time);
               variables.push_back(Mass);
               // Write data to file
               tmb::toolbox::writeDataVectorsToFile(std::string("test_output.dat"), varnames, variables);

               Note that the above code excerpt is only executed on the root processor to avoid writing test output.dat
               multiple times.

                   operator()() function    The Time and Mass vectors are updated at every time step by
               calling update time mass in operator()(). The write time mass is also called in operator()() so
               that the file storing mass over time is refreshed at every time step






                c 
Ascomp AG Switzerland                    359                                  Version 5.7
   364   365   366   367   368   369   370   371   372   373   374