LCOV - code coverage report
Current view: top level - src/systems - transient_system.C (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4229 (6a9aeb) with base 727f46 Lines: 30 34 88.2 %
Date: 2025-08-19 19:27:09 Functions: 17 60 28.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // The libMesh Finite Element Library.
       2             : // Copyright (C) 2002-2025 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             : 
      19             : 
      20             : // C++ includes
      21             : 
      22             : // Local includes
      23             : #include "libmesh/transient_system.h"
      24             : #include "libmesh/explicit_system.h"
      25             : #include "libmesh/linear_implicit_system.h"
      26             : #include "libmesh/nonlinear_implicit_system.h"
      27             : #include "libmesh/dof_map.h"
      28             : #include "libmesh/numeric_vector.h"
      29             : #include "libmesh/rb_construction.h"
      30             : #include "libmesh/eigen_system.h"
      31             : 
      32             : // Nvidia C++ whining about destroying incomplete unique_ptr<T> Base::foo types
      33             : #include "libmesh/diff_solver.h"
      34             : #include "libmesh/nonlinear_solver.h"
      35             : #include "libmesh/shell_matrix.h"
      36             : #include "libmesh/sparse_matrix.h"
      37             : 
      38             : namespace libMesh
      39             : {
      40             : 
      41             : 
      42             : // ------------------------------------------------------------
      43             : // TransientSystem implementation
      44             : template <class Base>
      45        2270 : TransientSystem<Base>::TransientSystem (EquationSystems & es,
      46             :                                         const std::string & name_in,
      47             :                                         const unsigned int number_in) :
      48             : 
      49             :   Base(es, name_in, number_in),
      50        2138 :   old_local_solution(nullptr),
      51        2270 :   older_local_solution(nullptr)
      52             : {
      53        2270 :   this->add_old_vectors();
      54        2270 : }
      55             : 
      56             : 
      57             : 
      58             : template <class Base>
      59        2138 : TransientSystem<Base>::~TransientSystem () = default;
      60             : 
      61             : 
      62             : 
      63             : template <class Base>
      64         147 : void TransientSystem<Base>::clear ()
      65             : {
      66             :   // clear the parent data
      67         147 :   Base::clear();
      68             : 
      69             :   // Restore us to a "basic" state
      70         147 :   this->add_old_vectors();
      71         147 : }
      72             : 
      73             : 
      74             : 
      75             : template <class Base>
      76        5337 : void TransientSystem<Base>::re_update ()
      77             : {
      78             :   // re_update the parent system
      79        5337 :   Base::re_update ();
      80             : 
      81         236 :   const std::vector<dof_id_type> & send_list = this->get_dof_map().get_send_list ();
      82             : 
      83         236 :   const dof_id_type first_local_dof = Base::get_dof_map().first_dof();
      84         236 :   const dof_id_type end_local_dof  = Base::get_dof_map().end_dof();
      85             : 
      86             :   // Check sizes
      87         236 :   libmesh_assert_greater_equal (end_local_dof, first_local_dof);
      88         236 :   libmesh_assert_greater_equal (older_local_solution->size(), send_list.size());
      89         236 :   libmesh_assert_greater_equal (old_local_solution->size(), send_list.size());
      90             : 
      91             :   // Even if we don't have to do anything ourselves, localize() may
      92             :   // use parallel_only tools
      93             :   // if (first_local_dof == end_local_dof)
      94             :   //   return;
      95             : 
      96             :   // Update the old & older solutions with the send_list,
      97             :   // which may have changed since their last update.
      98        5337 :   older_local_solution->localize (first_local_dof,
      99             :                                   end_local_dof-1,
     100             :                                   send_list);
     101             : 
     102        5337 :   old_local_solution->localize (first_local_dof,
     103             :                                 end_local_dof-1,
     104             :                                 send_list);
     105        5337 : }
     106             : 
     107             : 
     108             : 
     109             : 
     110             : template <class Base>
     111   408938544 : Number TransientSystem<Base>::old_solution (const dof_id_type global_dof_number) const
     112             : {
     113             :   // Check the sizes
     114    39513872 :   libmesh_assert_less (global_dof_number, this->get_dof_map().n_dofs());
     115    39513872 :   libmesh_assert_less (global_dof_number, old_local_solution->size());
     116             : 
     117   408938544 :   return (*old_local_solution)(global_dof_number);
     118             : }
     119             : 
     120             : 
     121             : 
     122             : template <class Base>
     123           0 : Number TransientSystem<Base>::older_solution (const dof_id_type global_dof_number) const
     124             : {
     125             :   // Check the sizes
     126           0 :   libmesh_assert_less (global_dof_number, this->get_dof_map().n_dofs());
     127           0 :   libmesh_assert_less (global_dof_number, older_local_solution->size());
     128             : 
     129           0 :   return (*older_local_solution)(global_dof_number);
     130             : }
     131             : 
     132             : 
     133             : 
     134             : template <class Base>
     135        2417 : void TransientSystem<Base>::add_old_vectors()
     136             : {
     137          72 :   ParallelType type =
     138             : #ifdef LIBMESH_ENABLE_GHOSTED
     139             :     GHOSTED;
     140             : #else
     141             :     SERIAL;
     142             : #endif
     143             : 
     144        2417 :   old_local_solution = &(this->add_vector("_transient_old_local_solution", true, type));
     145        2417 :   older_local_solution = &(this->add_vector("_transient_older_local_solution", true, type));
     146        2417 : }
     147             : 
     148             : // ------------------------------------------------------------
     149             : // TransientSystem instantiations
     150             : template class LIBMESH_EXPORT TransientSystem<LinearImplicitSystem>;
     151             : template class LIBMESH_EXPORT TransientSystem<NonlinearImplicitSystem>;
     152             : template class LIBMESH_EXPORT TransientSystem<ExplicitSystem>;
     153             : template class LIBMESH_EXPORT TransientSystem<System>;
     154             : template class LIBMESH_EXPORT TransientSystem<RBConstruction>;
     155             : #ifdef LIBMESH_HAVE_SLEPC
     156             : template class LIBMESH_EXPORT TransientSystem<EigenSystem>;
     157             : #endif
     158             : 
     159             : } // namespace libMesh

Generated by: LCOV version 1.14