LCOV - code coverage report
Current view: top level - src/solution_transfer - direct_solution_transfer.C (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4229 (6a9aeb) with base 727f46 Lines: 0 24 0.0 %
Date: 2025-08-19 19:27:09 Functions: 0 4 0.0 %
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             : #include "libmesh/direct_solution_transfer.h"
      22             : 
      23             : #include "libmesh/system.h"
      24             : #include "libmesh/numeric_vector.h"
      25             : 
      26             : namespace libMesh {
      27             : 
      28           0 : DirectSolutionTransfer::DirectSolutionTransfer(const libMesh::Parallel::Communicator & comm_in) :
      29           0 :   SolutionTransfer(comm_in)
      30           0 : {}
      31             : 
      32           0 : DirectSolutionTransfer::~DirectSolutionTransfer() = default;
      33             : 
      34             : void
      35           0 : DirectSolutionTransfer::transfer(const Variable & from_var,
      36             :                                  const Variable & to_var)
      37             : {
      38             :   libmesh_experimental();
      39             : 
      40           0 :   System * from_sys = from_var.system();
      41           0 :   System * to_sys = to_var.system();
      42             : 
      43             :   // Just a couple of (not completely thorough)
      44           0 :   libmesh_assert(from_sys->get_equation_systems().get_mesh().n_nodes() == from_sys->get_equation_systems().get_mesh().n_nodes());
      45           0 :   libmesh_assert(from_var.type() == to_var.type());
      46             : 
      47             :   // get dof indices for source variable
      48           0 :   unsigned int from_vn = from_var.number();
      49           0 :   std::set<dof_id_type> from_var_indices;
      50           0 :   from_sys->local_dof_indices(from_vn, from_var_indices);
      51             : 
      52             :   // get dof indices for dest variable
      53           0 :   unsigned int to_vn = to_var.number();
      54           0 :   std::set<dof_id_type> to_var_indices;
      55           0 :   to_sys->local_dof_indices(to_vn, to_var_indices);
      56             : 
      57             :   // copy the values from from solution vector to to solution vector
      58           0 :   std::set<dof_id_type>::iterator from_it = from_var_indices.begin();
      59           0 :   std::set<dof_id_type>::iterator from_it_end = from_var_indices.end();
      60           0 :   std::set<dof_id_type>::iterator to_it = to_var_indices.begin();
      61             : 
      62           0 :   NumericVector<Number> & from_solution = *from_sys->solution;
      63             : 
      64           0 :   for (; from_it != from_it_end; ++from_it, ++to_it)
      65           0 :     to_sys->solution->set(*to_it, from_solution(*from_it));
      66             : 
      67           0 :   to_sys->solution->close();
      68           0 :   to_sys->update();
      69           0 : }
      70             : 
      71             : } // namespace libMesh

Generated by: LCOV version 1.14