diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c8ff678800444a7c7717492d9cfbc7f3cef411f..735e012a125415425f34539a43c26d89c66e7931 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -511,6 +511,9 @@ if(ENABLE_MED OR ENABLE_CGNS) endif(ENABLE_MED OR ENABLE_CGNS) if(ENABLE_TAUCS) + if(NOT HAVE_METIS) + message(SEND_ERROR "You have to enable METIS in order to use TAUCS") + endif(NOT HAVE_METIS) find_library(TAUCS_LIB taucs PATH_SUFFIXES lib) if(TAUCS_LIB) find_path(TAUCS_INC "taucs.h" PATH_SUFFIXES src include) diff --git a/Geo/GFaceCompound.cpp b/Geo/GFaceCompound.cpp index 5cf441db68b9bf83a57d0b50d9f282ca1e50a9e2..e52b7fb9a4b4fdd54d9cce25040a629e35d8842c 100644 --- a/Geo/GFaceCompound.cpp +++ b/Geo/GFaceCompound.cpp @@ -22,7 +22,6 @@ #include "crossConfTerm.h" #include "convexCombinationTerm.h" #include "linearSystemGMM.h" -#include "linearSystemTAUCS.h" #include "linearSystemCSR.h" #include "linearSystemFull.h" #include "linearSystemPETSc.h" diff --git a/Mesh/highOrderSmoother.cpp b/Mesh/highOrderSmoother.cpp index b371c532266bd05cef8f1757eb4f87709aa182ef..79c5cf0578ebd202896d6939809d1f6bf0bb274c 100644 --- a/Mesh/highOrderSmoother.cpp +++ b/Mesh/highOrderSmoother.cpp @@ -23,8 +23,7 @@ #include "Numeric.h" #include "dofManager.h" #include "elasticityTerm.h" -#include "linearSystemTAUCS.h" -#include "linearSystemGMM.h" +#include "linearSystemCSR.h" #define SQU(a) ((a)*(a)) diff --git a/Solver/CMakeLists.txt b/Solver/CMakeLists.txt index 89621c741947718f1b7d5f75af4eede523b11d76..699c6edc02f67cf3445df34b25fbee8c770bcb08 100644 --- a/Solver/CMakeLists.txt +++ b/Solver/CMakeLists.txt @@ -5,7 +5,6 @@ set(SRC linearSystemCSR.cpp - linearSystemTAUCS.cpp groupOfElements.cpp elasticityTerm.cpp elasticitySolver.cpp diff --git a/Solver/elasticitySolver.cpp b/Solver/elasticitySolver.cpp index 40acc54b71abdec60e5f2e6853b65b30bababd34..5b257e316a5e8701ba0e12c0a61b9f272b79d03d 100644 --- a/Solver/elasticitySolver.cpp +++ b/Solver/elasticitySolver.cpp @@ -9,9 +9,9 @@ #include "MTriangle.h" #include "MTetrahedron.h" #include "elasticitySolver.h" -#include "linearSystemTAUCS.h" -#include "linearSystemGMM.h" +#include "linearSystemCSR.h" #include "linearSystemPETSc.h" +#include "linearSystemGMM.h" #include "Numeric.h" #if !defined(HAVE_NO_POST) diff --git a/Solver/linearSystemCSR.cpp b/Solver/linearSystemCSR.cpp index dd2a3b92fac77c725f43949ce9c629225b4908f2..65d98a9e4ca3c2775fe7c8bab92eb4cffd546d42 100644 --- a/Solver/linearSystemCSR.cpp +++ b/Solver/linearSystemCSR.cpp @@ -6,6 +6,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <time.h> #include "GmshConfig.h" #include "GmshMessage.h" #include "linearSystemCSR.h" @@ -312,3 +313,51 @@ int linearSystemCSRGmm<double>::systemSolve() } #endif + +#if defined(HAVE_TAUCS) + +extern "C" { +#include "taucs.h" +} + +template<> +int linearSystemCSRTaucs<double>::systemSolve() +{ + if(!sorted){ + sortColumns_(_b->size(), + CSRList_Nbr(_a), + (INDEX_TYPE *) _ptr->array, + (INDEX_TYPE *) _jptr->array, + (INDEX_TYPE *) _ai->array, + (double*) _a->array); + } + sorted = true; + + taucs_ccs_matrix myVeryCuteTaucsMatrix; + myVeryCuteTaucsMatrix.n = myVeryCuteTaucsMatrix.m = _b->size(); + //myVeryCuteTaucsMatrix.rowind = (INDEX_TYPE*)_ptr->array; + //myVeryCuteTaucsMatrix.colptr = (INDEX_TYPE*)_ai->array; + myVeryCuteTaucsMatrix.rowind = (INDEX_TYPE*)_ai->array; + myVeryCuteTaucsMatrix.colptr = (INDEX_TYPE*)_jptr->array; + myVeryCuteTaucsMatrix.values.d = (double*)_a->array; + myVeryCuteTaucsMatrix.flags = TAUCS_SYMMETRIC | TAUCS_LOWER | TAUCS_DOUBLE; + + char* options[] = { "taucs.factor.LLT=true", NULL }; + clock_t t1 = clock(); + int result = taucs_linsolve(&myVeryCuteTaucsMatrix, + NULL, + 1, + &(*_x)[0], + &(*_b)[0], + options, + NULL); + clock_t t2 = clock(); + Msg::Info("TAUCS has solved %d unknowns in %8.3f seconds", + _b->size(), (double)(t2 - t1) / CLOCKS_PER_SEC); + if (result != TAUCS_SUCCESS){ + Msg::Error("Taucs Was Not Successfull %d", result); + } + return 1; +} + +#endif diff --git a/Solver/linearSystemCSR.h b/Solver/linearSystemCSR.h index 9d8e39b9e2e86c2ba733283a37dfd285fccd7d50..d7bad23a1eb3a6aaf1b7e898f86fb2e90990424e 100644 --- a/Solver/linearSystemCSR.h +++ b/Solver/linearSystemCSR.h @@ -133,4 +133,24 @@ class linearSystemCSRGmm : public linearSystemCSR<scalar> { ; }; +template <class scalar> +class linearSystemCSRTaucs : public linearSystemCSR<scalar> { + public: + linearSystemCSRTaucs(){} + virtual ~linearSystemCSRTaucs(){} + virtual void addToMatrix(int il, int ic, double val) + { + if (il <= ic) + linearSystemCSR<scalar>::addToMatrix(il, ic, val); + } + virtual int systemSolve() +#if !defined(HAVE_TAUCS) + { + Msg::Error("TAUCS is not available in this version of Gmsh"); + return 0; + } +#endif + ; +}; + #endif diff --git a/Solver/linearSystemTAUCS.cpp b/Solver/linearSystemTAUCS.cpp deleted file mode 100644 index 2d95cc0c2c5ea6ef62f9488019ea1bc6a3a0d995..0000000000000000000000000000000000000000 --- a/Solver/linearSystemTAUCS.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// Gmsh - Copyright (C) 1997-2009 C. Geuzaine, J.-F. Remacle -// -// See the LICENSE.txt file for license information. Please report all -// bugs and problems to <gmsh@geuz.org>. - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <time.h> -#include "linearSystemTAUCS.h" - -#if defined(HAVE_TAUCS) -extern "C" { -#include "taucs.h" -} - -template <class scalar> -void sortColumns_(int NbLines, - int nnz, - INDEX_TYPE *ptr, - INDEX_TYPE *jptr, - INDEX_TYPE *ai, - scalar *a); - -template<> -int linearSystemCSRTaucs<double>::systemSolve() -{ - if(!sorted){ - sortColumns_(_b->size(), - CSRList_Nbr(_a), - (INDEX_TYPE *) _ptr->array, - (INDEX_TYPE *) _jptr->array, - (INDEX_TYPE *) _ai->array, - (double*) _a->array); - } - sorted = true; - - taucs_ccs_matrix myVeryCuteTaucsMatrix; - myVeryCuteTaucsMatrix.n = myVeryCuteTaucsMatrix.m = _b->size(); - //myVeryCuteTaucsMatrix.rowind = (INDEX_TYPE*)_ptr->array; - //myVeryCuteTaucsMatrix.colptr = (INDEX_TYPE*)_ai->array; - myVeryCuteTaucsMatrix.rowind = (INDEX_TYPE*)_ai->array; - myVeryCuteTaucsMatrix.colptr = (INDEX_TYPE*)_jptr->array; - myVeryCuteTaucsMatrix.values.d = (double*)_a->array; - myVeryCuteTaucsMatrix.flags = TAUCS_SYMMETRIC | TAUCS_LOWER | TAUCS_DOUBLE; - - char* options[] = { "taucs.factor.LLT=true", NULL }; - clock_t t1 = clock(); - int result = taucs_linsolve(&myVeryCuteTaucsMatrix, - NULL, - 1, - &(*_x)[0], - &(*_b)[0], - options, - NULL); - clock_t t2 = clock(); - Msg::Info("TAUCS has solved %d unknowns in %8.3f seconds", _b->size(),(double)(t2-t1)/CLOCKS_PER_SEC); - if (result != TAUCS_SUCCESS){ - Msg::Error("Taucs Was Not Successfull %d",result); - } - return 1; -} - -#endif diff --git a/Solver/linearSystemTAUCS.h b/Solver/linearSystemTAUCS.h deleted file mode 100644 index eaf9266f688514dc619312c22d64c2c020447323..0000000000000000000000000000000000000000 --- a/Solver/linearSystemTAUCS.h +++ /dev/null @@ -1,31 +0,0 @@ -// Gmsh - Copyright (C) 1997-2009 C. Geuzaine, J.-F. Remacle -// -// See the LICENSE.txt file for license information. Please report all -// bugs and problems to <gmsh@geuz.org>. - -#ifndef _LINEAR_SYSTEM_TAUCS_H_ -#define _LINEAR_SYSTEM_TAUCS_H_ - -#include "linearSystemCSR.h" - -template <class scalar> -class linearSystemCSRTaucs : public linearSystemCSR<scalar> { - public: - linearSystemCSRTaucs(){} - virtual ~linearSystemCSRTaucs(){} - virtual void addToMatrix(int il, int ic, double val) - { - if (il <= ic) - linearSystemCSR<scalar>::addToMatrix(il, ic, val); - } - virtual int systemSolve() -#if !defined(HAVE_TAUCS) - { - Msg::Error("TAUCS is not available in this version of Gmsh"); - return 0; - } -#endif - ; -}; - -#endif