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 : #ifndef LIBMESH_INTER_MESH_PROJECTION_H 21 : #define LIBMESH_INTER_MESH_PROJECTION_H 22 : 23 : // Local includes 24 : #include "libmesh/libmesh.h" 25 : #include "libmesh/mesh.h" 26 : #include "libmesh/system.h" 27 : #include "libmesh/equation_systems.h" 28 : #include "libmesh/mesh_function.h" 29 : #include "libmesh/numeric_vector.h" 30 : #include "libmesh/numeric_vector.h" 31 : #include "libmesh/fem_function_base.h" 32 : 33 : // C++ includes 34 : #include <cstddef> 35 : #include <vector> 36 : 37 : namespace libMesh 38 : { 39 : 40 : // Forward declarations 41 : 42 : /** 43 : * This class implements inter mesh projection, i.e. projection of 44 : * vectors defined on a given mesh (from_mesh associated with from_system) 45 : * to another mesh (to_mesh of to_system). 46 : */ 47 : 48 : class InterMeshProjection 49 : { 50 : public: 51 : 52 : // Constructor, specifies the _from_system whose vectors will be 53 : // projected onto the _to_mesh 54 : InterMeshProjection(System & _from_system, System & _to_mesh); 55 : 56 : // Projects from_system vectors onto the to_mesh 57 : void project_system_vectors(); 58 : 59 : static Number fptr(const Point & p, const Parameters &, const std::string & libmesh_dbg_var(sys_name), const std::string & unknown_name); 60 : 61 : static Gradient gptr(const Point & p, const Parameters &, const std::string & libmesh_dbg_var(sys_name), const std::string & unknown_name); 62 : 63 : private: 64 : 65 : // Local copy of the _from_system 66 : System & from_system; 67 : 68 : // Local copy of the _to_system 69 : System & to_system; 70 : 71 : }; 72 : 73 : // This class provides the functor we will supply to System::project_vector 74 : // inside InterMeshProjection::project_system_vectors. 75 : // Object is constructed by passing in a pointer to the mesh function whose 76 : // gradient we want to shim via operator(). 77 : class GradientMeshFunction : public FunctionBase<Gradient> 78 : { 79 : public: 80 : // Constructor 81 : GradientMeshFunction(const MeshFunction & _mesh_function); 82 : 83 : // Destructor 84 0 : virtual ~GradientMeshFunction () { } 85 : 86 0 : virtual void init () { } 87 : 88 0 : virtual std::unique_ptr<FunctionBase<Gradient>> clone () const 89 : { 90 0 : return std::make_unique<GradientMeshFunction>(*mesh_function); 91 : } 92 : 93 0 : virtual Gradient operator() (const Point & , const Real) 94 0 : { libmesh_not_implemented(); } 95 : 96 : virtual void operator() (const Point & p, const Real, DenseVector<Gradient> & output); 97 : 98 : private: 99 : 100 : // Local copy of the passed in mesh function. 101 : std::unique_ptr<MeshFunction> mesh_function; 102 : 103 : }; 104 : } 105 : 106 : #endif // LIBMESH_INTER_MESH_PROJECTION_H