LCOV - code coverage report
Current view: top level - src/solvers - file_history_data.C (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4481 (67a8c4) with base cc8438 Lines: 31 35 88.6 %
Date: 2026-06-12 15:24:28 Functions: 5 6 83.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // The libMesh Finite Element Library.
       2             : // Copyright (C) 2002-2026 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
       3             : 
       4             : // This library is free software; you can redistribute it and/or
       5             : // modify it under the terms of the GNU Lesser General Public
       6             : // License as published by the Free Software Foundation; either
       7             : // version 2.1 of the License, or (at your option) any later version.
       8             : 
       9             : // This library is distributed in the hope that it will be useful,
      10             : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      12             : // Lesser General Public License for more details.
      13             : 
      14             : // You should have received a copy of the GNU Lesser General Public
      15             : // License along with this library; if not, write to the Free Software
      16             : // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
      17             : 
      18             : // Local includes
      19             : #include "libmesh/file_history_data.h"
      20             : 
      21             : #include "libmesh/enum_xdr_mode.h"
      22             : #include "libmesh/equation_systems.h"
      23             : 
      24             : namespace libMesh
      25             : {
      26          24 :   void FileHistoryData::store_initial_solution()
      27             :   {
      28             :     // The initial data should only be stored once.
      29           8 :     libmesh_assert(previously_stored == false);
      30             : 
      31          24 :     time_stamp = 0;
      32             : 
      33          24 :     primal_filename = "primal.out.xda.";
      34             : 
      35          24 :     primal_filename += std::to_string(time_stamp);
      36             : 
      37          32 :     _system.get_equation_systems().write (primal_filename, WRITE, EquationSystems::WRITE_DATA | EquationSystems::WRITE_ADDITIONAL_DATA);
      38             : 
      39             :     // We wont know the deltat taken at this timestep until the solve is completed, which is done after the store operation.
      40          24 :     deltat_at = std::numeric_limits<double>::signaling_NaN();
      41             : 
      42          24 :     previously_stored = true;
      43          24 :   }
      44             : 
      45         324 :   void FileHistoryData::store_primal_solution(stored_data_iterator stored_datum)
      46             :   {
      47             :     // An iterator to the datum being stored has been passed. This is taken to imply
      48             :     // that we are in a sequential time stepping sequence.
      49             : 
      50         324 :     stored_data_iterator stored_datum_last = stored_datum;
      51         108 :     stored_datum_last--;
      52             : 
      53         324 :     time_stamp = (stored_datum_last->second)->get_time_stamp() + 1;
      54             : 
      55         324 :     primal_filename = "primal.out.xda.";
      56             : 
      57         324 :     primal_filename += std::to_string(time_stamp);
      58             : 
      59         432 :     _system.get_equation_systems().write (primal_filename, WRITE, EquationSystems::WRITE_DATA | EquationSystems::WRITE_ADDITIONAL_DATA);
      60             : 
      61             :     // We dont know the deltat that will be taken at the current timestep.
      62         324 :     deltat_at = std::numeric_limits<double>::signaling_NaN();
      63             : 
      64             :     // But we know what deltat got us to the current time.
      65         432 :     (stored_datum_last->second)->set_deltat_at(_system.time_solver->TimeSolver::last_completed_timestep_size());
      66             : 
      67         324 :     previously_stored = true;
      68         324 :   }
      69             : 
      70         348 :   void FileHistoryData::store_adjoint_solution()
      71             :     {
      72         348 :      adjoint_filename = "adjoint.out.xda.";
      73             : 
      74         348 :      adjoint_filename += std::to_string(time_stamp);
      75             : 
      76         464 :      _system.get_equation_systems().write(adjoint_filename, WRITE, EquationSystems::WRITE_DATA | EquationSystems::WRITE_ADDITIONAL_DATA);
      77         348 :     }
      78             : 
      79           0 :   void FileHistoryData::rewrite_stored_solution()
      80             :     {
      81             :      // We are rewriting.
      82           0 :      libmesh_assert(previously_stored == true);
      83             : 
      84           0 :      _system.get_equation_systems().write(primal_filename, WRITE, EquationSystems::WRITE_DATA | EquationSystems::WRITE_ADDITIONAL_DATA);
      85           0 :     }
      86             : 
      87         516 :    void FileHistoryData::retrieve_primal_solution()
      88             :     {
      89             :      // Read in the primal solution stored at the current recovery time from the disk
      90         688 :      _system.get_equation_systems().read(primal_filename, READ, EquationSystems::READ_DATA | EquationSystems::READ_ADDITIONAL_DATA);
      91         516 :     }
      92             : 
      93         348 :    void FileHistoryData::retrieve_adjoint_solution()
      94             :     {
      95             :      // Read in the adjoint solution stored at the current recovery time from the disk
      96         464 :      _system.get_equation_systems().read(adjoint_filename, READ, EquationSystems::READ_DATA | EquationSystems::READ_ADDITIONAL_DATA);
      97         348 :     }
      98             : }

Generated by: LCOV version 1.14