Skip to content
Snippets Groups Projects
Commit b85b9597 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Starting porting the project to cmake.

parent b0785bb4
No related branches found
No related tags found
No related merge requests found
Showing with 546 additions and 442 deletions
#Libtnl
#Je potreba prenest vsechny Cmakelisty
#PrelozVse
#configDirectory.h.in - podle nej se vytvori hlavickovy soubor s informacemi o umisteni konfiguracnich souboru
#src/dummy.cpp
#src/core/config.h
#src/core/tnlFieldCUDA2D.h
#src/debug/parse.cc - zmena na include tnlDebugParser.h misto
#src/debug/tnlDebugScanner.l a jeho projeti skrz sflex++
#tests/matrix-formats-test.cpp
#tests/sparse-matrix-benchmark.cpp
#tools/src/mdiff-err-norms.cpp
#tools/src/tnlcurve2gnuplot.cpp
#tools/src/tnl-grid-view.cpp
#tools/src/tnl/matrix-convert.cpp
project(libtnl)
cmake_minimum_required(VERSION 2.8)
FIND_PACKAGE(CUDA)
#Najdem CPPUNIT tohle by bylo hezci mit mimo, aby slo jen volat find_package(cppunit), ale to bych to zase ztratil
FIND_PATH(CPPUNIT_INCLUDE_DIR cppunit/TestCase.h
/usr/local/include
/usr/include
)
# With Win32, important to have both
IF(WIN32)
FIND_LIBRARY(CPPUNIT_LIBRARY cppunit
${CPPUNIT_INCLUDE_DIR}/../lib
/usr/local/lib
/usr/lib)
FIND_LIBRARY(CPPUNIT_DEBUG_LIBRARY cppunitd
${CPPUNIT_INCLUDE_DIR}/../lib
/usr/local/lib
/usr/lib)
ELSE(WIN32)
# On unix system, debug and release have the same name
FIND_LIBRARY(CPPUNIT_LIBRARY cppunit
${CPPUNIT_INCLUDE_DIR}/../lib
/usr/local/lib
/usr/lib)
FIND_LIBRARY(CPPUNIT_DEBUG_LIBRARY cppunit
${CPPUNIT_INCLUDE_DIR}/../lib
/usr/local/lib
/usr/lib)
ENDIF(WIN32)
IF(CPPUNIT_INCLUDE_DIR)
IF(CPPUNIT_LIBRARY)
SET(CPPUNIT_FOUND "YES")
SET(CPPUNIT_LIBRARIES ${CPPUNIT_LIBRARY} ${CMAKE_DL_LIBS})
SET(CPPUNIT_DEBUG_LIBRARIES ${CPPUNIT_DEBUG_LIBRARY}
${CMAKE_DL_LIBS})
ENDIF(CPPUNIT_LIBRARY)
ENDIF(CPPUNIT_INCLUDE_DIR)
#-------------------------Skutecny zacatek-----------------------------
ENABLE_TESTING() #zapneme moznost testovani
# set (BUILD_CUDA)
# set (BUILD_MPI)
#Nastaveni kam davat vysledne soubory pro debug/release verzi
IF( CMAKE_BUILD_TYPE STREQUAL "Debug")
set (LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/Debug/lib)
set (EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/Debug/bin)
set(debugExt -dbg)
else()
set (LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/Release/lib)
set (EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/Release/bin)
set (addAlsoSubdirs TRUE)
endif()
if (BUILD_MPI) #Pokud to ma byt za pouziti MPI nastavime si koncovku -mpi, a spravne prekladace
set(mpiExt -mpi)
SET(CMAKE_C_COMPILER mpicc)
SET(CMAKE_CXX_COMPILER mpicxx)
endif()
set (Config_Directory \"${EXECUTABLE_OUTPUT_PATH}/config/\")
configure_file ("configDirectory.h.in" "${PROJECT_BINARY_DIR}/headers/configDirectory.h" )
#Nastavime cesty k hlavickovym souborum a knihovnam
INCLUDE_DIRECTORIES(src)
INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}/headers)
LINK_DIRECTORIES(${LIBRARY_OUTPUT_PATH})
#Pokracujeme dalsimi podadresari
add_subdirectory (src)
add_subdirectory (tests)
add_subdirectory (tools)
buildAll 0 → 100755
#!/bin/bash
#Pokud nemam potrebne adresare (Debug, Release), tak si je vytvorim
if [ ! -d Debug ];
then
mkdir Debug
fi
if [ ! -d Release ];
then
mkdir Release
fi
cd Debug
cmake .. -DCMAKE_BUILD_TYPE=Debug
make
cd ../Release
cmake ..
make
\ No newline at end of file
#define CONFIG_DIRECTORY @Config_Directory@
\ No newline at end of file
INCLUDE_DIRECTORIES( config core debug diff matrix mesh solver )
add_subdirectory( config )
add_subdirectory( core )
add_subdirectory( debug )
add_subdirectory( diff )
add_subdirectory( matrix )
add_subdirectory( mesh )
add_subdirectory( solver )
# Build the main library
set( libtnl_0_1_la_LIBADD
libtnlconfig${mpiExt}${debugExt}-0.1
libtnlcore${mpiExt}${debugExt}-0.1
libtnldebug${mpiExt}${debugExt}-0.1
libtnldiff${mpiExt}${debugExt}-0.1
libtnlmatrix${mpiExt}${debugExt}-0.1
libtnlmesh${mpiExt}${debugExt}-0.1
libtnlsolver${mpiExt}${debugExt}-0.1
)
ADD_LIBRARY( libtnl${mpiExt}${debugExt}-0.1 SHARED )
target_link_libraries( libtnl${mpiExt}${debugExt}-0.1 ${libtnl_0_1_la_LIBADD} )
if (BUILD_MPI)
target_link_libraries(libtnl${mpiExt}${debugExt}-0.1 mpi)
endif()
set( EXTRA_DIST tnlConfigDescriptionParser.y
tnlConfigDescriptionScanner.l
FlexLexer.h
)
set( headers tnlConfigDescription.h
tnlConfigDescriptionParser.h
tnlConfigDescriptionParserbase.h
tnlConfigDescriptionParser.ih
tnlConfigDescriptionScanner.h
tnlParameterContainer.h
)
set( sources tnlConfigDescription.cpp
tnlConfigDescriptionScanner.cpp
tnlConfigDescriptionParser.cpp
tnlParameterContainer.cpp
parse.cc
)
set( libmconfigincludedir ${TNL_INCLUDE_DIR}/config )
set( libmconfiginclude_HEADERS ${headers} )
ADD_LIBRARY( libtnlconfig${mpiExt}${debugExt}-0.1 SHARED ${sources} ${headers} )
if( BUILD_MPI )
target_link_libraries( libtnlcore${mpiExt}${debugExt}-0.1 mpi )
endif()
set (headers tnlAssert.h
tnlCurve.h
tnlCudaSupport.h
tnlDataElement.h
tnlFlopsCounter.h
tnlList.h
tnlLongVectorBase.h
tnlLongVectorHost.h
tnlLongVectorCUDA.h
tnlLogger.h
tnlObject.h
tnlStack.h
tnlString.h
tnlReal.h
tnlRealTester.h
tnlTimerCPU.h
tnlTimerRT.h
tnlVector.h
tnl-cuda-kernels.h
tnlCUDAKernelsTester.h
tnlCudaSupport.h
compress-file.h
mfilename.h
mfuncs.h
mpi-supp.h
param-types.h
)
set( sources tnlCudaSupport.cpp
tnlFlopsCounter.cpp
tnlLogger.cpp
tnlObject.cpp
tnlString.cpp
tnlTimerCPU.cpp
tnlTimerRT.cpp
mfilename.cpp
mpi-supp.cpp
)
set (libmcoreincludedir ${TNL_INCLUDE_DIR}/core )
set (libmcoreinclude_HEADERS ${headers} )
if (BUILD_CUDA)
CUDA_ADD_LIBRARY(libtnlcore${mpiExt}${debugExt}-0.1 SHARED ${sources} ${headers} debug.h tnlLongVectorCUDA.cu tnl-cuda-kernels.cu )
else()
ADD_LIBRARY(libtnlcore${mpiExt}${debugExt}-0.1 SHARED ${sources} ${headers} debug.h)
endif()
if (BUILD_MPI)
target_link_libraries(libtnlcore${mpiExt}${debugExt}-0.1 mpi)
endif()
set (EXTRA_DIST tnlDebugParser.y
tnlDebugScanner.l
create-tnl-debug-parser
)
set (sources tnlDebug.cpp
tnlDebugGroup.cpp
tnlDebugStructure.cpp
tnlDebugParser.cpp
tnlDebugScanner.cpp
parse.cc
)
set (headers tnlDbgDataElement.h
tnlDebugEntry.h
tnlDebugGroup.h
tnlDebugParserbase.h
tnlDebugParser.h
tnlDebug.h
tnlDebugScanner.h
tnlDebugStructure.h
)
ADD_LIBRARY(libtnldebug${mpiExt}${debugExt}-0.1 SHARED ${sources}) #Mozna jeste prekladaci ${OPTIMISECXXFLAGS}
add_executable ( tnl-debug-test tnl-debug-test.cpp)
target_link_libraries ( tnl-debug-test libtnldebug-0.1)
\ No newline at end of file
set (headers
mdiff-debug.h
drawGrid1D.h
drawGrid2D.h
drawGrid3D.h
tnlExplicitSolver.h
tnlGrid1D.h
tnlGrid2D.h
tnlGrid3D.h
tnlGridCUDA1D.h
tnlGridCUDA2D.h
tnlGridCUDA3D.h
tnlGridCUDA2DTester.h
tnlGridSystem1D.h
tnlEulerSolver.h
tnlMersonSolver.h
tnlMersonSolverCUDA.h
tnlMersonSolverCUDA.cu.h
tnlMPIMesh2D.h
tnlMPIMesh3D.h
tnlNonlinearRungeKuttaSolver.h
curve-ident.h
norms.h
)
set (sources )
set (libtnldiffincludedir ${TNL_INCLUDE_DIR}/diff)
set (libtnldiffinclude_HEADERS ${headers})
if (BUILD_CUDA)
CUDA_ADD_LIBRARY(libtnldiff${mpiExt}${debugExt}-0.1 SHARED ${sources} ${headers} tnlMersonSolverCUDA.cu ../dummy.cpp)
CUDA_ADD_LIBRARY(libdiff-tests${debugExt} SHARED tnlMersonSolverCUDATester.h tnlMersonSolverCUDATester.cu ../dummy.cpp)
else()
ADD_LIBRARY(libtnldiff${mpiExt}${debugExt}-0.1 SHARED ${sources} ${headers} ../dummy.cpp) #${OPTIMISECXXFLAGS}
ADD_LIBRARY(libdiff-tests${debugExt} SHARED ../dummy.cpp)
endif()
if (BUILD_MPI)
target_link_libraries(libtnldiff-0.1 mpi)
endif()
\ No newline at end of file
set (headers
tnlMatrix.h
tnlCSRMatrixOld.h
tnlCoalescedCSRMatrix.h
tnlCoalescedCSRMatrixCUDA.h
tnlCoalescedFastCSRMatrix.h
tnlCoalescedFastCSRMatrixCUDA.h
tnlEllpackMatrix.h
tnlEllpackMatrixCUDA.h
tnlCSRMatrix.h
tnlCSRMatrixTester.h
tnlFastCSRMatrix.h
tnlFullMatrix.h
tnlBaseMatrix.h
tnlCoalescedCSRMatrixTester.h
tnlEllpackMatrixTester.h
tnlMatrixSolver.h
tnlPETSCMatrix.h
tnlPETSCSolver.h
tnlSORSolver.h
tnlCGSolver.h
tnlBICGSolver.h
tnlBICGStabSolver.h
tnlGMRESSolver.h
tnlPreconditioner.h
tnlILUPreconditioner.h
tnlPETSCPreconditioner.h
)
set (sources tnlBaseMatrix.cpp)
set (libtnlmatrixincludedir ${TNL_INCLUDE_DIR}/matrix)
set (libtnlmatrixinclude_HEADERS ${headers})
if (BUILD_CUDA)
set (cudaAdd tnlCoalescedCSRMatrixCUDA.cu
tnlCoalescedFastCSRMatrixCUDA.cu
tnlEllpackMatrixCUDA.cu
tnlCoalescedCSRMatrixCUDA.cu.h
tnlCoalescedFastCSRMatrixCUDA.cu.h
tnlEllpackMatrixCUDA.cu.h
)
CUDA_ADD_LIBRARY(libtnlmatrix${mpiExt}${debugExt}-0.1 SHARED ${sources} ${headers} ${cudaAdd}) # ${OPTIMISECXXFLAGS}
else()
ADD_LIBRARY(libtnlmatrix${mpiExt}${debugExt}-0.1 SHARED ${sources} ${headers}) # ${OPTIMISECXXFLAGS}
endif()
if (BUILD_MPI)
target_link_libraries(libtnlmatrix${mpiExt}${debugExt}-0.1 mpi)
endif()
set( headers tnlDistributedGrid.h
tnlGrid.h
)
set( sources )
set( libtnlmeshincludedir ${TNL_INCLUDE_DIR}/mesh )
set( libtnlmeshinclude_HEADERS ${headers} )
ADD_LIBRARY(libtnlmesh${mpiExt}${debugExt}-0.1 SHARED ${sources} ${headers}) #${OPTIMISECXXFLAGS}
if (BUILD_MPI)
target_link_libraries(libtnldiff-0.1 mpi)
endif()
\ No newline at end of file
set( headers tnlBICGSolver.h
tnlBICGStabSolver.h
tnlCGSolver.h
tnlEulerSolver.h
tnlExplicitSolver.h
tnlGMRESSolver.h
tnlILUPreconditioner.h
tnlMatrixSolver.h
tnlMersonSolver.h
tnlPETSCSolver.h
tnlPreconditioner.h
tnlSORSolver.h
)
set( sources )
set( libtnlsolverincludedir ${TNL_INCLUDE_DIR}/mesh )
set( libtnlsolverinclude_HEADERS ${headers} )
ADD_LIBRARY(libtnlsolver${mpiExt}${debugExt}-0.1 SHARED ${sources} ${headers}) #${OPTIMISECXXFLAGS}
if( BUILD_MPI )
target_link_libraries( libtnlsolver-0.1 mpi )
endif()
/***************************************************************************
tnlILUPreconditioner.cpp - description
-------------------
begin : 2007/02/01
copyright : (C) 2007 by Tomas Oberhuber
email : tomas.oberhuber@fjfi.cvut.cz
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <assert.h>
#include <math.h>
#include "tnlILUPreconditioner.h"
#include "mfuncs.h"
#ifdef ILU_DEBUG
#include <iomanip>
#include <fstream>
//--------------------------------------------------------------------------
void WriteFullMatrix( ostream& o_str, const m_real* M, const m_int N )
{
m_int i, j;
for( i = 0; i < N; i ++ )
{
for( j = 0; j < N; j ++ )
{
const m_real& v = M[ i * N + j ];
if( v == 0.0 ) o_str << setw( 10 ) << ".";
else o_str << setprecision( 6 ) << setw( 10 ) << v;
}
o_str << endl;
}
}
#endif
//--------------------------------------------------------------------------
tnlILUPreconditioner :: tnlILUPreconditioner( const m_int _size,
const m_int initial_size,
const m_int segment_size,
const m_int init_row_elements )
: size( _size )
{
#ifdef ILU_DEBUG
full_M = new m_real[ size * size ];
ilu_check = new m_real[ size * size ];
#endif
y = new m_real[ size ];
M = new tnlCSRMatrix( size, initial_size, segment_size, init_row_elements );
}
//--------------------------------------------------------------------------
tnlILUPreconditioner :: ~tnlILUPreconditioner()
{
if( M ) delete M;
if( y ) delete[] y;
#ifdef ILU_DEBUG
if( full_M ) delete[] full_M;
if( ilu_check ) delete[] ilu_check;
#endif
}
//--------------------------------------------------------------------------
const tnlCSRMatrix* tnlILUPreconditioner :: getVector() const
{
return M;
}
//--------------------------------------------------------------------------
m_int tnlILUPreconditioner :: Init( const tnlCSRMatrix& A, const m_real& threshold )
{
dbgFunctionName( "tnlILUPreconditioner", "Init" );
assert( A. Size() == M -> Size() );
int non_zero_elements( 0 );
#ifdef CSR_MATRIX_TUNING
M -> ResetStatistics();
#endif
m_int i, j, k;
const tnlCSRMatrixElement *A_data;
const tnlCSRMatrixRowInfo *A_rows_info;
A. getVector( A_data, A_rows_info );
#ifdef ILU_DEBUG
// 1. Copy data of A to full_M
bzero( full_M, size * size * sizeof( m_real ) );
for( i = 0; i < size; i ++ )
for( j = A_rows_info[ i ]. first; j < A_rows_info[ i ]. last; j ++ )
{
m_int col = A_data[ j ]. column;
if( col != -1 )
full_M[ i * size + col ] = A_data[ j ]. value;
}
#endif
M -> Reset();
tnlCSRMatrixElement* M_data;
const tnlCSRMatrixRowInfo *M_rows_info;
// 2. Processing IKJ version of ILU factorisation
// For i = 0, ... , N
for( i = 0; i < size; i ++ )
{
// y = a_i* - i-th row
bzero( y, size * sizeof( m_real ) );
m_real y_norm( 0.0 );
const m_int a_row_beg = A_rows_info[ i ]. first;
const m_int a_row_end = A_rows_info[ i ]. last;
for( k = a_row_beg; k < a_row_end; k ++ )
{
const m_int col = A_data[ k ]. column;
const m_real& a_ik = A_data[ k ]. value;
if( col == -1 ) break;
y[ col ] = a_ik;
y_norm += a_ik * a_ik;
}
// get 2-norm of the i-th row for the dropping rule on y_k
y_norm = sqrt( y_norm );
const m_real threshold_i = y_norm * threshold;
M -> Data( M_data, M_rows_info );
for( k = 0; k < i; k ++ )
{
const m_real& m_kk = ( *M )( k, k );
if( m_kk != 0.0 )
y[ k ] /= m_kk;
if( fabs( y[ k ] ) < threshold_i ) y[ k ] = 0.0;
if( y[ k ] != 0.0 )
{
const m_int row_beg = M_rows_info[ k ]. diagonal + 1;
const m_int row_end = M_rows_info[ k ]. last;
m_int col;
for( j = row_beg;
j < row_end && ( col = M_data[ j ]. column ) != -1;
j ++ )
y[ col ] -= y[ k ] * M_data[ j ]. value;
}
}
for( j = 0; j < size; j ++ )
{
if( i == j || fabs( y[ j ] ) > threshold_i )
{
M -> Set( i, j , y[ j ] );
non_zero_elements ++;
}
if( i == j && ( *M )( i, i ) == 0.0 )
{
cerr << endl << "Zero pivot appears at line " << i << "!" << endl;
M -> Set( i, i, 1.0 );
abort();
//return 0;
}
}
cout << "Computing ILUT ... " << 100.0 * ( m_real ) ( i + 1 ) / ( m_real ) ( size ) << "% \r" << flush;
dbgExpr( i );
//dbgExpr( * M );
}
cout << non_zero_elements / size << " elems. per line in average " << endl;
//dbgExpr( * M );
#ifdef ILU_DEBUG
fstream file;
/*file. open( "orig_full_M2", ios :: out );
WriteFullMatrix( file, full_M, size );
file. close();*/
/*file. open( "M", ios :: out );
file << *M << endl;
file. close();*/
for( i = 0; i < size; i ++ )
{
cout << "LU: " << ( m_real ) i / ( m_real ) size * 100.0 << " % done \r" << flush;
// y = a_i* - i-th row
bzero( y, size * sizeof( m_real ) );
m_real y_norm( 0.0 );
for( k = 0; k < size; k ++ )
{
const m_real& m_ik = full_M[ i * size + k ];
y[ k ] = m_ik;
y_norm += m_ik * m_ik;
//cout << i << ", " << k << " <- " << y[ k ] << endl;
}
// get 2-norm of the i-th row for the dropping rule on y_k
y_norm = sqrt( y_norm );
const m_real threshold_i = y_norm * threshold;
for( k = 0; k < i; k ++ )
{
const m_real& m_kk = full_M[ k * size + k ];
if( m_kk != 0.0 )
y[ k ] /= m_kk;
if( fabs( y[ k ] ) < threshold_i )
y[ k ] = 0.0;
if( y[ k ] != 0.0 )
for( j = k + 1; j < size; j ++ )
y[ j ] -= y[ k ] * full_M[ k * size + j ];
}
for( j = 0; j < size; j ++ )
{
if( i == j || fabs( y[ j ] ) > threshold_i )
full_M[ i * size + j ] = y[ j ];
else
full_M[ i * size + j ] = 0.0;
}
if( full_M[ i * size + i ] == 0.0 )
cerr << endl << "FULL MATRIX ILU CHECK: Zero pivot appears at line " << i << "!" << endl;
}
/*file. open( "full_M", ios :: out );
WriteFullMatrix( file, full_M, size );
file. close();*/
cout << endl;
cout << "Checking if M == full M..." << endl;
for( i = 0; i < size; i ++ )
for( j = 0; j < size; j ++ )
if( full_M[ i * size + j ] != ( *M )( i, j ) )
{
cerr << "M != full M at " << i << ", " << j << " : " <<
fabs( full_M[ i * size + j ] - ( *M )( i, j ) ) << endl;
break;
}
/*cout << "Checking if LU = A" << endl;
// check whether L U == A
for( i = 0; i < size; i ++ )
for( j = 0; j < size; j ++ )
{
cout << i << " : " << j << " \r" << flush;
m_int l = Min( i, j );
m_real sum( 0.0 );
for( k = 0; k <= l; k ++ )
if( k < i )
sum += full_M[ i * size + k ] * full_M[ k * size + j ];
else
sum += full_M[ i * size + j ]; // L has 1 on diagonal
if( fabs( sum ) < 1.0e-15 ) sum = 0.0;
ilu_check[ i * size + j ] = sum;
}
cout << endl;
m_real ilu_diff( 0.0 );
for( i = 0; i < size; i ++ )
for( j = 0; j < size; j ++ )
ilu_diff = Max( ilu_diff, fabs( ilu_check[ i * size +j ] - A( i, j ) ) );
cout << "ILU Max. error is " << ilu_diff << endl;*/
#endif
#ifdef CSR_MATRIX_TUNING
M -> PrintStatistics();
#endif
return 1;
/*
// For i = 1 ... n - 1
for( i = 1; i < size; i ++ )
{
// For k = 0 ... i - 1 and for ( i, k ) non-zero
// = take non-zero entries at the i-th row before the diagonal entry
m_int i_th_row_beg = M_row_ind[ i ];
m_int i_th_row_end = M_row_ind[ i + 1 ];
m_int k_ind;
for( k_ind = i_th_row_beg; k_ind < i_th_row_end; k_ind ++ )
{
k = M_data[ k_ind ]. column;
if( k == -1 ) break;
// a_ik := a_ik / a_kk
M_data[ k_ind ]. value /= M_data[ M_diag_ind[ k ] ]. value;
const m_real& a_ik = M_data[ k_ind ]. value;
// For j = k + 1 ... n - 1 and for ( i, j ) non-zero
// = take non-zero entries at the i-th row behind the diagonal entry
m_int j_ind;
for( j_ind = k_ind + 1; j_ind < i_th_row_end; j_ind ++ )
{
j = M_data[ j_ind ]. column;
if( j == -1 ) break;
// a_ij := a_ij - a_ik * a_kj
M_data[ j_ind ]. value -= a_ik * ( *M )( k, j );
}
}
}*/
}
//--------------------------------------------------------------------------
void tnlILUPreconditioner :: Solve( const m_real* b, m_real* x ) const
{
dbgFunctionName( "tnlILUPreconditioner", "Solve" );
const m_int size = M -> Size();
const tnlCSRMatrixElement* M_data;
const tnlCSRMatrixRowInfo *M_rows_info;
M -> Data( M_data, M_rows_info );
m_int i, j;
dbgCout( "Solving Ly = b" );
// L is unit lower triangular
for( i = 0; i < size; i ++ )
{
y[ i ] = b[ i ];
const m_int i_row_beg = M_rows_info[ i ]. first;
const m_int i_row_end = M_rows_info[ i ]. diagonal;
m_int col;
for( j = i_row_beg;
j < i_row_end && ( col = M_data[ j ]. column ) != -1;
j ++ )
y[ i ] -= y[ M_data[ j ]. column ] * M_data[ j ]. value;
//for( j = 0; j < i; j ++ )
// y[ i ] -= y[ j ] * ( * M )( i, j );
}
dbgCout( "Solving Ux = y" );
for( i = size - 1; i >=0 ; i -- )
{
x[ i ] = y[ i ];
const m_int i_row_beg = M_rows_info[ i ]. diagonal;
assert( i_row_beg != -1 );
const m_int i_row_end = M_rows_info[ i ]. last;
m_int col;
for( j = i_row_beg + 1;
j < i_row_end && ( col = M_data[ j ]. column ) != -1;
j ++ )
x[ i ] -= x[ col ] * M_data[ j ]. value;
assert( M_data[ i_row_beg ]. value != 0.0 );
x[ i ] /= M_data[ i_row_beg ]. value;
//for( j = i + 1; j < size; j ++ )
// x[ i ] -= x[ j ] * ( *M )( i, j );
//x[ i ] /= ( *M )( i, i );
}
#ifdef ILU_DEBUG
/*for( i = 0; i < size; i ++ )
{
y[ i ] = b[ i ];
for( j = 0; j < i; j ++ )
y[ i ] -= y[ j ] * full_M[ i * size + j ];
}
dbgCout( "Solving Ux = y" );
for( i = size - 1; i >=0 ; i -- )
{
x[ i ] = y[ i ];
for( j = i + 1; j < size; j ++ )
x[ i ] -= x[ j ] * full_M[ i * size + j ];
x[ i ] /= full_M[ i * size + i ];
}*/
#endif
}
/***************************************************************************
tnlPETSCSolver.cpp - description
-------------------
begin : 2008/05/12
copyright : (C) 2008 by Tomas Oberhuber
email : tomas.oberhuber@fjfi.cvut.cz
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "tnlPETSCSolver.h"
//--------------------------------------------------------------------------
#ifdef HAVE_PETSC
/*PetscErrorCode PETSCSolverMonitorCallback( KSP petsc_solver, PetscInt iter, PetscReal rnorm, void* ctx )
{
cout << "*" << flush;
}*/
#endif
file(COPY matrix-market DESTINATION ${EXECUTABLE_OUTPUT_PATH}/config)
file(COPY florida-matrix-market DESTINATION ${EXECUTABLE_OUTPUT_PATH}/config)
file(COPY tnl-sparse-matrix-check.cfg.desc DESTINATION ${EXECUTABLE_OUTPUT_PATH}/config)
set (tnl_sparse_matrix_check_SOURCES tnl-sparse-matrix-check.cpp tnl-sparse-matrix-check.h)
set (matrix_formats_test_SOURCES matrix-formats-test.cpp matrix-formats-test.h)
set (sparse_matrix_benchmark_SOURCES sparse-matrix-benchmark.cpp sparse-matrix-benchmark.h)
#sparse_matrix_benchmark_CXXFLAGS = $(OPTIMISECXXFLAGS)
add_executable (tnl_sparse_matrix_check${mpiExt}${debugExt} ${tnl_sparse_matrix_check_SOURCES})
target_link_libraries (tnl_sparse_matrix_check${mpiExt}${debugExt} libtnl${mpiExt}${debugExt}-0.1
libtnlcore${mpiExt}${debugExt}-0.1 libtnlmatrix${mpiExt}${debugExt}-0.1)
add_executable (matrix_formats_test${mpiExt}${debugExt} ${matrix_formats_test_SOURCES})
target_link_libraries (matrix_formats_test${mpiExt}${debugExt} libtnl${mpiExt}${debugExt}-0.1
libtnlcore${mpiExt}${debugExt}-0.1 libtnlmatrix${mpiExt}${debugExt}-0.1)
add_executable (sparse_matrix_benchmark${mpiExt}${debugExt} ${sparse_matrix_benchmark_SOURCES})
target_link_libraries (sparse_matrix_benchmark${mpiExt}${debugExt} libtnl${mpiExt}${debugExt}-0.1
libtnlcore${mpiExt}${debugExt}-0.1 libtnlmatrix${mpiExt}${debugExt}-0.1)
\ No newline at end of file
This diff is collapsed.
add_subdirectory (src)
add_subdirectory (share)
\ No newline at end of file
file(COPY mdiff-err-norms.cfg.desc DESTINATION ${EXECUTABLE_OUTPUT_PATH}/config)
file(COPY mgrid-view.cfg.desc DESTINATION ${EXECUTABLE_OUTPUT_PATH}/config)
file(COPY tnlcurve2gnuplot.cfg.desc DESTINATION ${EXECUTABLE_OUTPUT_PATH}/config)
file(COPY tnl-matrix-convert.cfg.desc DESTINATION ${EXECUTABLE_OUTPUT_PATH}/config)
\ No newline at end of file
set(common read-file.h)
set(tnlerrnormssources mdiff-err-norms.cpp
tnl-err-norms.h
compare-objects.h
${common}
)
set(tnlgridviewsources tnl-grid-view.cpp
tnl-grid-view.h
${common}
)
set(tnlcurve2gnuplotsources tnlcurve2gnuplot.cpp
${common}
)
set(tnlfunctionsbenchmarksources functions-benchmark.cpp
functions-benchmark.h
)
set(tnlmatrixconvertsources tnl-matrix-convert.cpp
tnl-matrix-convert.h
)
if (BUILD_CUDA)
set(tnlfunctionsbenchmarksources ${tnlfunctionsbenchmarksources}
functions-benchmark-cuda.cu
functions-benchmark-cuda.cu.h
)
CUDA_ADD_EXECUTABLE(tnl-functions-benchmark ${tnlfunctionsbenchmarksources})
target_link_libraries (tnl-functions-benchmark libtnl${mpiExt}${debugExt}-0.1)
else (BUILD_CUDA)
ADD_EXECUTABLE(nl-functions-benchmark ${tnlfunctionsbenchmarksources})
target_link_libraries (nl-functions-benchmark libtnl${mpiExt}${debugExt}-0.1 )
endif(BUILD_CUDA)
ADD_EXECUTABLE(tnl-err-norms ${tnlerrnormssources})
target_link_libraries (tnl-err-norms libtnl${mpiExt}${debugExt}-0.1 )
ADD_EXECUTABLE(tnlgrid-view ${tnlgridviewsources})
target_link_libraries (tnlgrid-view libtnl${mpiExt}${debugExt}-0.1 )
ADD_EXECUTABLE(tnlcurve2gnuplot ${tnlcurve2gnuplotsources})
target_link_libraries (tnlcurve2gnuplot libtnl${mpiExt}${debugExt}-0.1 )
ADD_EXECUTABLE(tnl-matrix-convert ${tnlmatrixconvertsources})
target_link_libraries (tnl-matrix-convert libtnl${mpiExt}${debugExt}-0.1 )
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment