Commit d1d1ee44 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Rewriting PDE solvers to work with mesh functions (it does not work correctly now).

parent 1187b1be
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ class tnlArray : public virtual tnlObject
      void bind( Element* _data,
                 const Index _size );

      void bind( tnlArray< Element, Device, Index >& array,
      void bind( const tnlArray< Element, Device, Index >& array,
                 const IndexType& begin = 0,
                 const IndexType& size = 0 );

+4 −4
Original line number Diff line number Diff line
@@ -226,13 +226,13 @@ template< typename Element,
           typename Index >
void
tnlArray< Element, Device, Index >::
bind( tnlArray< Element, Device, Index >& array,
bind( const tnlArray< Element, Device, Index >& array,
      const IndexType& begin,
      const IndexType& size )
{
   tnlAssert( begin < array.getSize(),
   tnlAssert( begin <= array.getSize(),
              std::cerr << " begin = " << begin << " array.getSize() = " << array.getSize() );
   tnlAssert( begin + size  < array.getSize(),
   tnlAssert( begin + size  <= array.getSize(),
              std::cerr << " begin = " << begin << " size = " << size <<  " array.getSize() = " << array.getSize() );
   
   this->releaseData();
@@ -240,7 +240,7 @@ bind( tnlArray< Element, Device, Index >& array,
      this->size = size;
   else
      this->size = array.getSize() - begin;
   this->data = &array.getData()[ begin ];
   this->data = const_cast< Element* >( &array.getData()[ begin ] );
   this->allocationPointer = array.allocationPointer;
   if( array.allocationPointer )
   {
+0 −29
Original line number Diff line number Diff line
@@ -38,34 +38,5 @@ class tnlFunction
      static constexpr tnlFunctionType getFunctionType() { return FunctionType; }
};


/*
 * Funkce jsou bud analyticke nebo sitove( diskretni )
 *  - analyticke jsou dane vzorcem
 *    - zavisi na prostorove promenne Vertex a casu 
 *    - 
 *  - sitove jsou dane hodnotama na sitovych entitach
 *    - jejich hodnota zavisi pouze na indexu sitove entity
 * 
 * Dale jsou hybrydni funkce, ktere zavisi na vertexu, casu a indexu sitove entity.
 *   - jejich typ se urci meotdou getFunctionType
 *   - ta je def. v tnlFunction a vraci tnlHybridFunction / tnlGeneralFunction.
 *   - jde o defaultni nastaveni, ktere neni superoptimalni, ale jednoduche pro uzivatele
 * 
 */

/*
muzeme rozlisovat tnlMeshFunction a tnl(Analytic)Function
   -ta druha ma typ site void
   - chtelo by to naimplementovat tnlMeshFunction, aby se videlo, co tim lze vyresit
   - mesh-function bude mit ukazatel na mesh a dimenzi mesh entit, na nichz je definovana
   - asi nebude zaviset na case
   - mohl by pro ni byt definovany operator =, ktery by slouzil k projekci spojitych funkci na sit
   - tim bysme se zbavili enumeratoru
   - nad mesh function pak lze implementovat interpolanty - mozna vhodne i pro multigrid
      =====>>>> IMPLEMENTOVAT tnlMeshFunction
   - prozkoumat moznost lamda funkci pro mesh functions pro snazsi inicializaci sitove funkce
   nejakou pocatecni podminkou ==> mozna by to mohlo nahradit i ty analyticke funkce ???
 */
#endif	/* TNLFUNCTION_H */
+27 −9
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 *                                                                         *
 ***************************************************************************/

#include <core/tnlObject.h>
#include <functions/tnlFunction.h>

#ifndef TNLMESHFUNCTION_H
@@ -23,8 +24,9 @@
template< typename Mesh,
          int MeshEntityDimensions = Mesh::meshDimensions,
          typename Real = typename Mesh::RealType >
class tnlMeshFunction : public tnlFunction< Mesh::meshDimensions,
                                            MeshFunction >
class tnlMeshFunction : 
   public tnlObject,
   public tnlFunction< Mesh::meshDimensions, MeshFunction >
{
   //static_assert( Mesh::DeviceType::DeviceType == Vector::DeviceType::DeviceType,
   //               "Both mesh and vector of a mesh function must reside on the same device.");
@@ -40,6 +42,8 @@ class tnlMeshFunction : public tnlFunction< Mesh::meshDimensions,
      
      tnlMeshFunction();
      
      tnlMeshFunction( const MeshType& mesh );
      
      template< typename Vector >
      tnlMeshFunction( const MeshType& mesh,
                       Vector& data,
@@ -51,11 +55,10 @@ class tnlMeshFunction : public tnlFunction< Mesh::meshDimensions,
      bool setup( const tnlParameterContainer& parameters,
                  const tnlString& prefix = "" );      
      
      // TODO: implement bind tnlVector ( using shared pointers )
      /*template< typename Vector >
      bool bind( const MeshType& mesh,
                 Vector& data,
                 const IndexType& offset = 0 );*/
      template< typename Vector >
      void bind( const MeshType& mesh,
                 const Vector& data,
                 const IndexType& offset = 0 );
      
      void setMesh( const MeshType& mesh ) const;      
      
@@ -74,11 +77,26 @@ class tnlMeshFunction : public tnlFunction< Mesh::meshDimensions,
      
      template< typename EntityType >
      __cuda_callable__
      RealType& operator()( const EntityType& meshEntityIndex );
      RealType& operator()( const EntityType& meshEntity );
      
      template< typename EntityType >
      __cuda_callable__
      const RealType& operator()( const EntityType& meshEntityIndex ) const;
      const RealType& operator()( const EntityType& meshEntity ) const;
      
      __cuda_callable__
      RealType& operator[]( const IndexType& meshEntityIndex );
      
      __cuda_callable__
      const RealType& operator[]( const IndexType& meshEntityIndex ) const;

      
      bool save( tnlFile& file ) const;

      bool load( tnlFile& file );
      
      using tnlObject::load;

      using tnlObject::save;
            
   protected:
      
+64 −6
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@

#include <core/tnlAssert.h>

#include "tnlMeshFunction.h"

#ifndef TNLMESHFUNCTION_IMPL_H
#define	TNLMESHFUNCTION_IMPL_H

@@ -29,6 +31,16 @@ tnlMeshFunction()
{
}

template< typename Mesh,
          int MeshEntityDimensions,
          typename Real >
tnlMeshFunction< Mesh, MeshEntityDimensions, Real >::
tnlMeshFunction( const Mesh& mesh )
: mesh( &mesh )
{
   this->data.setSize( mesh.template getEntitiesCount< typename Mesh::template MeshEntity< MeshEntityDimensions > >() );
}

template< typename Mesh,
          int MeshEntityDimensions,
          typename Real >
@@ -38,7 +50,7 @@ tnlMeshFunction( const MeshType& mesh,
                 Vector& data,
                 const IndexType& offset )
{
   //this->bind( mesh, data, offset );   
   this->bind( mesh, data, offset );   
}

template< typename Mesh,
@@ -69,19 +81,19 @@ setup( const tnlParameterContainer& parameters,
   return true;
}

/*template< typename Mesh,
template< typename Mesh,
          int MeshEntityDimensions,
          typename Real >
   template< typename Vector >
bool
void
tnlMeshFunction< Mesh, MeshEntityDimensions, Real >::
bind( const MeshType& mesh,
      Vector& data,
      const Vector& data,
      const IndexType& offset )
{
   this->mesh = &mesh;
   return this->data.bind( data, offset, mesh.template getEntitiesCount< MeshEntity >() );      
}*/
   this->data.bind( data, offset, mesh.template getEntitiesCount< typename Mesh::template MeshEntity< MeshEntityDimensions > >() );
}

template< typename Mesh,
          int MeshEntityDimensions,
@@ -174,5 +186,51 @@ operator()( const EntityType& meshEntity ) const
   return this->data[ meshEntity.getIndex() ];
}

template< typename Mesh,
          int MeshEntityDimensions,
          typename Real >
__cuda_callable__
typename tnlMeshFunction< Mesh, MeshEntityDimensions, Real >::RealType& 
tnlMeshFunction< Mesh, MeshEntityDimensions, Real >::
operator[]( const IndexType& meshEntityIndex )
{   
   return this->data[ meshEntityIndex ];
}

template< typename Mesh,
          int MeshEntityDimensions,
          typename Real >
__cuda_callable__
const typename tnlMeshFunction< Mesh, MeshEntityDimensions, Real >::RealType& 
tnlMeshFunction< Mesh, MeshEntityDimensions, Real >::
operator[]( const IndexType& meshEntityIndex ) const
{
   return this->data[ meshEntityIndex ];
}

template< typename Mesh,
          int MeshEntityDimensions,
          typename Real >      
bool
tnlMeshFunction< Mesh, MeshEntityDimensions, Real >::
save( tnlFile& file ) const
{
   //if( ! tnlObject::save( file ) )
   //   return false;
   return this->data.save( file );
}

template< typename Mesh,
          int MeshEntityDimensions,
          typename Real >
bool
tnlMeshFunction< Mesh, MeshEntityDimensions, Real >::
load( tnlFile& file )
{
   //if( ! tnlObject::load( file ) )
   //   return false;
   return this->data.load( file );   
}

#endif	/* TNLMESHFUNCTION_IMPL_H */
Loading