LCOV - code coverage report
Current view: top level - ugbase/bridge/misc_bridges - vec_math_bridge.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 79.1 % 43 34
Test Date: 2025-09-21 23:31:46 Functions: 33.3 % 6 2

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) 2011-2015:  G-CSC, Goethe University Frankfurt
       3              :  * Author: Sebastian Reiter
       4              :  * 
       5              :  * This file is part of UG4.
       6              :  * 
       7              :  * UG4 is free software: you can redistribute it and/or modify it under the
       8              :  * terms of the GNU Lesser General Public License version 3 (as published by the
       9              :  * Free Software Foundation) with the following additional attribution
      10              :  * requirements (according to LGPL/GPL v3 §7):
      11              :  * 
      12              :  * (1) The following notice must be displayed in the Appropriate Legal Notices
      13              :  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
      14              :  * 
      15              :  * (2) The following notice must be displayed at a prominent place in the
      16              :  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
      17              :  * 
      18              :  * (3) The following bibliography is recommended for citation and must be
      19              :  * preserved in all covered files:
      20              :  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
      21              :  *   parallel geometric multigrid solver on hierarchically distributed grids.
      22              :  *   Computing and visualization in science 16, 4 (2013), 151-164"
      23              :  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
      24              :  *   flexible software system for simulating pde based models on high performance
      25              :  *   computers. Computing and visualization in science 16, 4 (2013), 165-179"
      26              :  * 
      27              :  * This program is distributed in the hope that it will be useful,
      28              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      29              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
      30              :  * GNU Lesser General Public License for more details.
      31              :  */
      32              : 
      33              : #include <string>
      34              : #include <sstream>
      35              : 
      36              : #include "bridge/bridge.h"
      37              : #include "bridge/util.h"
      38              : #include "common/math/ugmath.h"
      39              : #include "bridge/suffix_tag.h"
      40              : 
      41              : using namespace std;
      42              : 
      43              : namespace ug{
      44              : 
      45              : /// \defgroup vecmath_bridge VecMath Bridge
      46              : /// \ingroup misc_bridge
      47              : /// \{
      48              : 
      49              : ////////////////////////////////////////////////////////////////////////////////
      50              : //      Some methods which assist in creating vectors
      51            0 : static SmartPtr<vector1> MakeVec(number x)
      52              : {
      53            0 :         return SmartPtr<vector1>(new vector1(x));
      54              : }
      55              : 
      56            0 : static SmartPtr<vector2> MakeVec(number x, number y)
      57              : {
      58            0 :         return SmartPtr<vector2>(new vector2(x, y));
      59              : }
      60              : 
      61            0 : static SmartPtr<vector3> MakeVec(number x, number y, number z)
      62              : {
      63            0 :         return SmartPtr<vector3>(new vector3(x, y, z));
      64              : }
      65              : 
      66            0 : static SmartPtr<vector4> MakeVec(number x, number y, number z, number w)
      67              : {
      68            0 :         return SmartPtr<vector4>(new vector4(x, y, z, w));
      69              : }
      70              : 
      71              : ////////////////////////////////////////////////////////////////////////////////
      72              : namespace bridge{
      73              : ////////////////////////////////////////////////////////////////////////////////
      74              : /*
      75              : template <int dim>
      76              : static void RegisterBridge_VecMath(Registry& reg, string grp)
      77              : {
      78              :         typedef MathVector<dim, number> vec_type;
      79              :         
      80              :         try
      81              :         {
      82              :                 string suffix = GetDimensionSuffix<dim>();
      83              :                 string tag = GetDimensionTag<dim>();
      84              : 
      85              :         //      register the class
      86              :                 string vecName = "Vec";
      87              :                 vecName.append(suffix);
      88              : 
      89              :                 reg.add_class_<vec_type>(vecName, grp)
      90              :                         .add_method("coord",
      91              :                                         static_cast<typename vec_type::value_type (vec_type::*)(size_t) const>(&vec_type::coord));
      92              :                 reg.add_class_to_group(vecName, "Vec", tag);
      93              :         }
      94              :         UG_REGISTRY_CATCH_THROW(grp);
      95              : }
      96              : */
      97              : ////////////////////////////////////////////////////////////////////////////////
      98            1 : static void RegisterVecMathBridge_DimIndep(Registry& reg, string grp)
      99              : {
     100              :         try
     101              :         {
     102              :                 {
     103              :                         typedef MathVector<1, number> vec_type;
     104            3 :                         reg.add_class_<vec_type>("Vec1d", grp)
     105            1 :                                 .add_constructor()
     106              : #ifndef UG_FOR_VRL // TODO can we add all constructors to base class of class group? For now, use MakeVec for Java API.
     107            2 :                                 .add_constructor<void (*)(number)>()
     108              : #endif
     109            2 :                                 .add_method("set_coord", &vec_type::set_coord, "", "index # value",
     110              :                                             "sets the value of the coordinate with the given index")
     111            2 :                                 .add_method("coord",
     112              :                                                 static_cast<vec_type::value_type (vec_type::*)(size_t) const>(&vec_type::coord));
     113            2 :                         reg.add_class_to_group("Vec1d", "Vec", GetDimensionTag<1>());
     114              :                 }
     115              :                 {
     116              :                         typedef MathVector<2, number> vec_type;
     117            3 :                         reg.add_class_<vec_type>("Vec2d", grp)
     118            1 :                                 .add_constructor()
     119              : #ifndef UG_FOR_VRL // TODO can we add all constructors to base class of class group? For now, use MakeVec for Java API.
     120            2 :                                 .add_constructor<void (*)(number, number)>()
     121              : #endif
     122            2 :                                 .add_method("set_coord", &vec_type::set_coord, "", "index # value",
     123              :                                             "sets the value of the coordinate with the given index")
     124            2 :                                 .add_method("coord",
     125              :                                                 static_cast<vec_type::value_type (vec_type::*)(size_t) const>(&vec_type::coord));
     126            2 :                         reg.add_class_to_group("Vec2d", "Vec", GetDimensionTag<2>());
     127              :                 }
     128              :                 {
     129              :                         typedef MathVector<3, number> vec_type;
     130            3 :                         reg.add_class_<vec_type>("Vec3d", grp)
     131            1 :                                 .add_constructor()
     132              : #ifndef UG_FOR_VRL // TODO can we add all constructors to base class of class group? For now, use MakeVec for Java API.
     133            2 :                                 .add_constructor<void (*)(number, number, number)>()
     134              : #endif
     135            2 :                                 .add_method("set_coord", &vec_type::set_coord, "", "index # value",
     136              :                                             "sets the value of the coordinate with the given index")
     137            2 :                                 .add_method("coord",
     138              :                                                 static_cast<vec_type::value_type (vec_type::*)(size_t) const>(&vec_type::coord));
     139            2 :                         reg.add_class_to_group("Vec3d", "Vec", GetDimensionTag<3>());
     140              :                 }
     141              :                 {
     142              :                         typedef MathVector<4, number> vec_type;
     143            3 :                         reg.add_class_<vec_type>("Vec4d", grp)
     144            1 :                                 .add_constructor()
     145              : #ifndef UG_FOR_VRL // TODO can we add all constructors to base class of class group? For now, use MakeVec for Java API.
     146            2 :                                 .add_constructor<void (*)(number, number, number, number)>()
     147              : #endif
     148            2 :                                 .add_method("set_coord", &vec_type::set_coord, "", "index # value",
     149              :                                             "sets the value of the coordinate with the given index")
     150            2 :                                 .add_method("coord",
     151              :                                                 static_cast<vec_type::value_type (vec_type::*)(size_t) const>(&vec_type::coord));
     152            2 :                         reg.add_class_to_group("Vec4d", "Vec", GetDimensionTag<4>());
     153              :                 }
     154              : 
     155              :         //      register make-methods
     156            3 :                 reg.add_function("MakeVec", static_cast<SmartPtr<vector1> (*)(number)>(
     157              :                                                         &MakeVec), grp)
     158            3 :                         .add_function("MakeVec", static_cast<SmartPtr<vector2> (*)(number, number)>(
     159              :                                                         &MakeVec), grp)
     160            3 :                         .add_function("MakeVec", static_cast<SmartPtr<vector3> (*)(number, number, number)>(
     161              :                                                         &MakeVec), grp)
     162            3 :                         .add_function("MakeVec", static_cast<SmartPtr<vector4> (*)(number, number, number, number)>(
     163              :                                                         &MakeVec), grp);
     164              :         }
     165            0 :         UG_REGISTRY_CATCH_THROW(grp);
     166            1 : }
     167              : 
     168              : 
     169              : ////////////////////////////////////////////////////////////////////////////////
     170            1 : void RegisterBridge_VecMath(Registry& reg, string parentGroup)
     171              : {
     172              : //      get group string
     173            1 :         string grp = parentGroup; grp.append("/Util/VecMath");
     174              : 
     175              : //      RegisterBridge_VecMath<1>(reg, grp);
     176              : //      RegisterBridge_VecMath<2>(reg, grp);
     177              : //      RegisterBridge_VecMath<3>(reg, grp);
     178              : //      RegisterBridge_VecMath<4>(reg, grp);
     179            2 :         RegisterVecMathBridge_DimIndep(reg, grp);
     180            1 : }
     181              : 
     182              : // end group vecmath_bridge
     183              : /// \}
     184              : 
     185              : }// end of namespace
     186              : }// end of namespace
        

Generated by: LCOV version 2.0-1