LCOV - code coverage report
Current view: top level - src/solution_transfer - meshfree_solution_transfer.C (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4229 (6a9aeb) with base 727f46 Lines: 0 20 0.0 %
Date: 2025-08-19 19:27:09 Functions: 0 1 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             : #include "libmesh/meshfree_solution_transfer.h"
      21             : 
      22             : #include "libmesh/mesh.h"
      23             : #include "libmesh/system.h"
      24             : #include "libmesh/numeric_vector.h"
      25             : #include "libmesh/threads.h"
      26             : #include "libmesh/meshfree_interpolation.h"
      27             : #include "libmesh/function_base.h"
      28             : #include "libmesh/node.h"
      29             : 
      30             : // C++ includes
      31             : #include <cstddef>
      32             : 
      33             : namespace libMesh
      34             : {
      35             : 
      36             : // Forward Declarations
      37             : template <typename T>
      38             : class DenseVector;
      39             : 
      40             : void
      41           0 : MeshfreeSolutionTransfer::transfer(const Variable & from_var,
      42             :                                    const Variable & to_var)
      43             : {
      44             :   libmesh_experimental();
      45             : 
      46           0 :   System * from_sys = from_var.system();
      47           0 :   System * to_sys = to_var.system();
      48             : 
      49           0 :   EquationSystems & from_es = from_sys->get_equation_systems();
      50             : 
      51           0 :   MeshBase & from_mesh = from_es.get_mesh();
      52             : 
      53             :   InverseDistanceInterpolation<LIBMESH_DIM> idi
      54           0 :     (from_mesh.comm(), 4, 2);
      55             : 
      56           0 :   std::vector<Point>  & src_pts  (idi.get_source_points());
      57           0 :   std::vector<Number> & src_vals (idi.get_source_vals());
      58             : 
      59           0 :   std::vector<std::string> field_vars;
      60           0 :   field_vars.push_back(from_var.name());
      61           0 :   idi.set_field_variables(field_vars);
      62             : 
      63             :   // We now will loop over every node in the source mesh
      64             :   // and add it to a source point list, along with the solution
      65           0 :   for (const auto & node : from_mesh.local_node_ptr_range())
      66             :     {
      67           0 :       src_pts.push_back(*node);
      68           0 :       src_vals.push_back((*from_sys->solution)(node->dof_number(from_sys->number(),from_var.number(),0)));
      69           0 :     }
      70             : 
      71             :   // We have only set local values - prepare for use by gathering remote data
      72           0 :   idi.prepare_for_use();
      73             : 
      74             :   // Create a MeshfreeInterpolationFunction that uses our
      75             :   // InverseDistanceInterpolation object.  Since each
      76             :   // MeshfreeInterpolationFunction shares the same
      77             :   // InverseDistanceInterpolation object in a threaded environment we
      78             :   // must also provide a locking mechanism.
      79           0 :   Threads::spin_mutex mutex;
      80           0 :   MeshfreeInterpolationFunction mif(idi, mutex);
      81             : 
      82             :   // project the solution
      83           0 :   to_sys->project_solution(&mif);
      84           0 : }
      85             : 
      86             : } // namespace libMesh

Generated by: LCOV version 1.14