Commit f6ace3fc authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Merge branch 'JK/meshfunction' into 'develop'

Removed reference counter and binding functionality from Array

See merge request !64
parents 24816b45 6e2ac078
Loading
Loading
Loading
Loading
+0 −37
Original line number Diff line number Diff line
#include <iostream>
#include <TNL/Containers/Array.h>

using namespace TNL;
using namespace TNL::Containers;

int main( int argc, char* argv[] )
{
   /****
    * Allocate an array on host
    */
   const int size = 10;
   int* ai = new int[ size ];

   /****
    * Bind the data with TNL array
    */
   Array< int > host_array;
   host_array.bind( ai, size );

   /****
    * Initialize the data using the TNL array
    */
   host_array = 66;

   /****
    * Check the data
    */
   for( int i = 0; i < size; i++ )
      std::cout << ai[ i ] << " ";
   std::cout << std::endl;

   /****
    * Free the allocated data
    */
   delete[] ai;
}
+0 −1
Original line number Diff line number Diff line
ArrayBinding-1.cpp
 No newline at end of file
+0 −44
Original line number Diff line number Diff line
#include <iostream>
#include <TNL/Containers/Array.h>

using namespace TNL;
using namespace TNL::Containers;

void initArray( Array< int >& a )
{
   /****
    * Create new array, bind it with 'a' and initialize it
    */
   Array< int > b( 10 );
   a.bind( b );
   b = 10;

   /****
    * Show that both arrays share the same data
    */
   std::cout << "a data in initArray function is " << a.getData() << std::endl;
   std::cout << "a value in initArray function is " << a << std::endl;
   std::cout << "--------------------------------------" << std::endl;
   std::cout << "b data in initArray function is " << b.getData() << std::endl;
   std::cout << "b in initArray function is " << b << std::endl;
   std::cout << "--------------------------------------" << std::endl;
}

int main( int argc, char* argv[] )
{
   /****
    * Create array but do not initialize it
    */
   Array< int > a;

   /***
    * Call function initArray for the array initialization
    */
   initArray( a );

   /****
    * Print the initialized array
    */
   std::cout << "a data in main function is " << a.getData() << std::endl;
   std::cout << "a in main function is " << a << std::endl;
}
+0 −1
Original line number Diff line number Diff line
ArrayBinding-2.cpp
 No newline at end of file
+0 −33
Original line number Diff line number Diff line
#include <iostream>
#include <TNL/Containers/Array.h>

using namespace TNL;
using namespace TNL::Containers;

int main( int argc, char* argv[] )
{
   /****
    * Allocate data for all degrees of freedom
    */
   const int size = 5;
   Array< float > a( 3 * size );

   /***
    * Partition the data into density and velocity components
    */
   Array< float > rho( a,        0, size );
   Array< float > v_1( a,     size, size );
   Array< float > v_2( a, 2 * size, size );

   rho = 10.0;
   v_1 = 1.0;
   v_2 = 0.0;

   /****
    * Print the initialized arrays
    */
   std::cout << "rho =  " << rho << std::endl;
   std::cout << "v1 =  " << v_1 << std::endl;
   std::cout << "v2 =  " << v_2 << std::endl;
   std::cout << "a =  " << a << std::endl;
}
Loading