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

Generated by: LCOV version 1.14