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

Avoiding use of tnlDotProduct.

parent 6f00851b
Loading
Loading
Loading
Loading
+14 −14
Original line number Diff line number Diff line
@@ -464,20 +464,20 @@ StaticVector< 3, Real > VectorProduct( const StaticVector< 3, Real >& u,
}

template< typename Real >
Real tnlScalarProduct( const StaticVector< 2, Real >& u,
Real ScalarProduct( const StaticVector< 2, Real >& u,
                    const StaticVector< 2, Real >& v )
{
   return u[ 0 ] * v[ 0 ] + u[ 1 ] * v[ 1 ];
}

template< typename Real >
Real tnlScalarProduct( const StaticVector< 3, Real >& u,
Real ScalarProduct( const StaticVector< 3, Real >& u,
                    const StaticVector< 3, Real >& v )
{
   return u[ 0 ] * v[ 0 ] + u[ 1 ] * v[ 1 ] + u[ 2 ] * v[ 2 ];
}

template< typename T1,
/*template< typename T1,
          typename T2>
StaticVector<1, T1> tnlDotProduct( const StaticVector< 1, T1 >& u,
                       const StaticVector< 1, T2 >& v )
@@ -508,10 +508,10 @@ StaticVector<3, T1> tnlDotProduct( const StaticVector< 3, T1 >& u,
   ret[1]=u[1]*v[1];
   ret[2]=u[2]*v[2];
   return ret;
}
}*/

template< typename Real >
Real tnlTriangleArea( const StaticVector< 2, Real >& a,
Real TriangleArea( const StaticVector< 2, Real >& a,
                   const StaticVector< 2, Real >& b,
                   const StaticVector< 2, Real >& c )
{
@@ -528,7 +528,7 @@ Real tnlTriangleArea( const StaticVector< 2, Real >& a,
}

template< typename Real >
Real tnlTriangleArea( const StaticVector< 3, Real >& a,
Real TriangleArea( const StaticVector< 3, Real >& a,
                   const StaticVector< 3, Real >& b,
                   const StaticVector< 3, Real >& c )
{
@@ -541,7 +541,7 @@ Real tnlTriangleArea( const StaticVector< 3, Real >& a,
   u2. z() = c. z() - a. z();

   const StaticVector< 3, Real > v = VectorProduct( u1, u2 );
   return 0.5 * TNL::sqrt( tnlScalarProduct( v, v ) );
   return 0.5 * TNL::sqrt( ScalarProduct( v, v ) );
}

} // namespace Containers
+10 −2
Original line number Diff line number Diff line
@@ -53,7 +53,11 @@ class DistributedGridIO<Functions::MeshFunction<MeshType>,LocalCopy,Device>
        SharedPointer<MeshType> newMesh;
        newMesh->setDimensions(localSize);
        newMesh->setSpaceSteps(spaceSteps);
        newMesh->setOrigin(origin+TNL::Containers::tnlDotProduct(spaceSteps,localBegin));
        CoordinatesType newOrigin;
        for( int i = 0; i < MeshType::getMeshDimension(); i++ )
           newOrigin = origin[ i ] + spaceSteps[ i ] * localBegin[ i ];
        newMesh->setOrigin( newOrigin );
        //newMesh->setOrigin(origin+TNL::Containers::tnlDotProduct(spaceSteps,localBegin));
        
        File meshFile;
        meshFile.open( fileName+String("-mesh-")+distrGrid->printProcessCoords()+String(".tnl"),IOMode::write);
@@ -98,7 +102,11 @@ class DistributedGridIO<Functions::MeshFunction<MeshType>,LocalCopy,Device>
        SharedPointer<MeshType> newMesh;
        newMesh->setDimensions(localSize);
        newMesh->setSpaceSteps(spaceSteps);
        newMesh->setOrigin(origin+TNL::Containers::tnlDotProduct(spaceSteps,localBegin));
        CoordinatesType newOrigin;
        for( int i = 0; i < MeshType::getMeshDimension(); i++ )
           newOrigin = origin[ i ] + spaceSteps[ i ] * localBegin[ i ];
        newMesh->setOrigin( newOrigin );       
        //newMesh->setOrigin(origin+TNL::Containers::tnlDotProduct(spaceSteps,localBegin));
        
        VectorType newDof(newMesh-> template getEntitiesCount< typename MeshType::Cell >());
        MeshFunctionType newMeshFunction;
+0 −5
Original line number Diff line number Diff line
@@ -37,11 +37,6 @@ class DistributedMesh< Grid< 1, RealType, Device, Index > > : public Distributed
      bool setup( const Config::ParameterContainer& parameters,
                  const String& prefix );
      
      /*template< typename CommunicatorType >
      void setGlobalGrid( const GridType &globalGrid,
                          const SubdomainOverlapsType& lower,
                          const SubdomainOverlapsType& upper );*/
       
      void setupGrid( GridType& grid );
       
      String printProcessCoords() const;
+0 −93
Original line number Diff line number Diff line
@@ -26,99 +26,6 @@ setup( const Config::ParameterContainer& parameters,
   return true;
}      

/*template< typename RealType, typename Device, typename Index >     
   template< typename CommunicatorType>
void
DistributedMesh< Grid< 1, RealType, Device, Index > >::
setGlobalGrid( const GridType& globalGrid,
               const SubdomainOverlapsType& lower,
               const SubdomainOverlapsType& upper )
{

   if(this->isSet && this->communicationGroup != nullptr)
        std::free(this->communicationGroup);
   this->communicationGroup= std::malloc(sizeof(typename CommunicatorType::CommunicationGroup));

   *((typename CommunicatorType::CommunicationGroup *)this->communicationGroup) = CommunicatorType::AllGroup;
    auto group=*((typename CommunicatorType::CommunicationGroup *)this->communicationGroup);

   this->globalGrid = globalGrid;
   this->isSet = true;
   this->overlap = lower; // overlap; TODO: FIx this - I dont understand this code
   this->lowerOverlap = lower;
   this->upperOverlap = upper;
   this->neighbors[Left]=-1;
   this->neighbors[Right]=-1;
   
   this->Dimensions = GridType::getMeshDimension();
   this->spaceSteps = globalGrid.getSpaceSteps();

   this->distributed = false;
   if( CommunicatorType::IsInitialized() )
   {
       this->rank = CommunicatorType::GetRank(group);
       this->nproc = CommunicatorType::GetSize(group);
       if( this->nproc>1 )
       {
           this->distributed = true;
       }
   }

   if( !this->distributed )
   {
       this->rank = 0;
       this->localOrigin = globalGrid.getOrigin();
       this->localSize = globalGrid.getDimensions();
       this->localGridSize = globalGrid.getDimensions();
       this->globalBegin = CoordinatesType(0);
       this->localBegin = CoordinatesType(0);
       this->domainDecomposition[ 0 ];
       return;
   }
   else
   {            
       this->domainDecomposition[ 0 ] = this->nproc;
       this->subdomainCoordinates[ 0 ]= this->rank;
       
       //compute local mesh size               
       int numberOfLarger = globalGrid.getDimensions().x() % this->nproc;

       this->localSize.x() = globalGrid.getDimensions().x() / this->nproc;
       if(numberOfLarger>this->rank) this->localSize.x() += 1;

       if(numberOfLarger>this->rank)
       {
           this->globalBegin.x()=this->rank*this->localSize.x();
           this->localOrigin.x()=globalGrid.getOrigin().x()
                        +(this->globalBegin.x()-this->overlap.x())*this->globalGrid.getSpaceSteps().x();
       }
       else
       {
           this->globalBegin.x()=numberOfLarger*(this->localSize.x()+1)+(this->rank-numberOfLarger)*this->localSize.x();
           this->localOrigin.x()=(this->globalGrid.getOrigin().x()-this->overlap.x())
                        +this->globalBegin.x()*this->globalGrid.getSpaceSteps().x();
       }

      this->setupNeighbors();

      this->localBegin=this->overlap;

       //vlevo neni prekryv
       if(this->neighbors[Left]==-1)
       {
           this->localOrigin.x()+=this->overlap.x()*this->globalGrid.getSpaceSteps().x();
           this->localBegin.x()=0;
       }

       this->localGridSize = this->localSize;
       //add overlaps
       if( this->neighbors[Left] == -1 || this->neighbors[Right] == -1 )
           this->localGridSize.x() += this->overlap.x();
       else
           this->localGridSize.x() += 2*this->overlap.x();
   }  
}*/ 

template< typename RealType, typename Device, typename Index >     
void
DistributedMesh< Grid< 1, RealType, Device, Index > >::
+0 −6
Original line number Diff line number Diff line
@@ -36,12 +36,6 @@ class DistributedMesh< Grid< 2, RealType, Device, Index > >: public DistributedG
      bool setup( const Config::ParameterContainer& parameters,
                  const String& prefix );
            
      /*template< typename CommunicatorType >
      void setGlobalGrid( const GridType& globalGrid );
      
      void setOverlaps( const SubdomainOverlapsType& lower,
                        const SubdomainOverlapsType& upper );*/
      
      void setupGrid( GridType& grid );
       
      String printProcessCoords() const;
Loading