LCOV - code coverage report
Current view: top level - src/systems - explicit_system.C (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4229 (6a9aeb) with base 727f46 Lines: 17 33 51.5 %
Date: 2025-08-19 19:27:09 Functions: 5 8 62.5 %
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             : // Local includes
      21             : #include "libmesh/explicit_system.h"
      22             : #include "libmesh/numeric_vector.h"
      23             : 
      24             : namespace libMesh
      25             : {
      26             : 
      27             : 
      28       42466 : ExplicitSystem::~ExplicitSystem() = default;
      29             : 
      30       32322 : ExplicitSystem::ExplicitSystem (EquationSystems & es,
      31             :                                 const std::string & name_in,
      32       32322 :                                 const unsigned int number_in) :
      33             :   Parent (es, name_in, number_in),
      34       32322 :   rhs(nullptr)
      35             : 
      36             : {
      37             :   // Add the system RHS.
      38       32322 :   this->add_system_rhs ();
      39       32322 : }
      40             : 
      41             : 
      42             : 
      43         498 : void ExplicitSystem::clear ()
      44             : {
      45             :   // Clear the parent data
      46         498 :   Parent::clear();
      47             : 
      48             :   // Restore us to a "basic" state
      49         498 :   this->add_system_rhs ();
      50         498 : }
      51             : 
      52             : 
      53             : 
      54           0 : void ExplicitSystem::assemble_qoi (const QoISet & qoi_indices)
      55             : {
      56             :   // The user quantity of interest assembly gets to expect to
      57             :   // accumulate on initially zero values
      58           0 :   for (auto i : make_range(this->n_qois()))
      59           0 :     if (qoi_indices.has_index(i))
      60           0 :       this->set_qoi(i, 0);
      61             : 
      62           0 :   Parent::assemble_qoi (qoi_indices);
      63           0 : }
      64             : 
      65             : 
      66             : 
      67           0 : void ExplicitSystem::assemble_qoi_derivative (const QoISet & qoi_indices,
      68             :                                               bool include_liftfunc,
      69             :                                               bool apply_constraints)
      70             : {
      71             :   // The user quantity of interest derivative assembly gets to expect
      72             :   // to accumulate on initially zero vectors
      73           0 :   for (auto i : make_range(this->n_qois()))
      74           0 :     if (qoi_indices.has_index(i))
      75           0 :       this->add_adjoint_rhs(i).zero();
      76             : 
      77           0 :   Parent::assemble_qoi_derivative (qoi_indices, include_liftfunc,
      78             :                                    apply_constraints);
      79           0 : }
      80             : 
      81             : 
      82             : 
      83           0 : void ExplicitSystem::solve ()
      84             : {
      85             :   // Assemble the linear system
      86           0 :   this->assemble ();
      87             : 
      88             :   // Update the system after the solve
      89           0 :   this->update();
      90           0 : }
      91             : 
      92             : 
      93             : 
      94       32820 : void ExplicitSystem::add_system_rhs ()
      95             : {
      96             :   // Possible that we cleared the _vectors but
      97             :   // forgot to update the rhs pointer?
      98       32820 :   if (this->n_vectors() == 0)
      99       32820 :     rhs = nullptr;
     100             : 
     101             : 
     102             :   // Only need to add the rhs if it isn't there
     103             :   // already!
     104       32820 :   if (rhs == nullptr)
     105       32820 :     rhs = &(this->add_vector ("RHS Vector", false));
     106             : 
     107        1016 :   libmesh_assert(rhs);
     108       32820 : }
     109             : 
     110             : } // namespace libMesh

Generated by: LCOV version 1.14