trilinos / Trilinos

Primary repository for the Trilinos Project
https://trilinos.org/
Other
1.21k stars 565 forks source link

Belos solver manager BLOCK GMRES with standardized name BLOCK GMRES has not been registered. #6370

Closed zhengshuang2005 closed 4 years ago

zhengshuang2005 commented 4 years ago

Dear Developers,

I want to ask a question related to Belos solver factory.

I used the Belos solver package and followed the Belos solver package tutorial as shown on the Doxygen page "https://trilinos.org/docs/r12.12/packages/belos/doc/html/classBelos_1_1SolverFactory.html". It used to work with the old Trilinos version I was using. However, recently I upgraded my Trilinos version to the latest one (12.12) and when I ran the solver again, it gives the following error:

terminate called after throwing an instance of 'std::invalid_argument'
  what():  /home/shuang/foam/foam-extend-3.2/ThirdParty/packages/trilinos/include/BelosSolverFactory.hpp:375:

Throw number = 1

Throw test that evaluated to true: it == get_solverManagers().end()

Belos solver manager BLOCK GMRES with standardized name BLOCK GMRES has not been registered."

I don't know what has happened and could you please point out where I did wrong? My function using the Belis solver is as follows. I have also attached my Trilinos cmake script for your reference.

void TpetraSolver::solve()
{
    // A matrix fill complete
    A_->fillComplete();

    // B vector fill complete
    local_ordinal_type nodeNumElements = map_->getNodeNumElements();
    for (local_ordinal_type i = 0; i < nodeNumElements; i++)
    {
        B_->get1dViewNonConst()[i] = b_[elementList_[i]];
    }

    // Preconditioner
    RCP<op_type> M = createPreconditioner(A_);

    // Solver
    RCP<ParameterList> solverParams = parameterList();
    solverParams->set("Num Blocks", 40);
    solverParams->set("Maximum Iterations", 1000);
    solverParams->set("Convergence Tolerance", 1.0e-6);
    Belos::SolverFactory<scalar_type, vec_type, op_type> factory;
    RCP<Belos::SolverManager<scalar_type, vec_type, op_type> > solver =
        factory.create("Block GMRES", solverParams);

    // Linaer problem
    RCP<LinearProblem> problem = rcp(new LinearProblem(A_, X_, B_));

    // Solve
    problem->setRightPrec(M);
    problem->setProblem();
    solver->setProblem(problem);
    Belos::ReturnType result = solver->solve();
    const int numIters = solver->getNumIters();

    // Redistribute
    redistributeResult();

    if (result == Belos::Converged)
    {
        cout << "The Belos solve took " << numIters
            << " iteration(s) to reach a relative residual tolerance of "
            << 1.0e-6 << "."
            << endl;
    }
    else
    {
        cout << "The Belos solve took " << numIters
            << " iteration(s), but did not reach a relative "
               "residual tolerance of " << 1.0e-6 << "."
            << endl;
    }
}

~/foam/foam-extend-3.2/ThirdParty/rpmBuild/BUILD/cmake-3.11.0-Linux-x86_64/bin/cmake -D CMAKE_INSTALL_PREFIX:PATH="~/foam/foam-extend-3.2/ThirdParty/packages/trilinos" \
-D TPL_ENABLE_MPI:BOOL=ON \
-D MPI_BASE_DIR:PATH="~/foam/foam-extend-3.2/ThirdParty/packages/openmpi-1.6.5/platforms/linux64GccDPOpt" \
-D CMAKE_CXX_FLAGS:STRING="-O2 -std=c++11 -pedantic -ftrapv -Wall -Wno-long-long" \
-D CMAKE_BUILD_TYPE:STRING=RELEASE \
-D Trilinos_ENABLE_Fortran:BOOL=OFF \
-D BUILD_SHARED_LIBS:BOOL=ON \
-D Trilinos_WARNINGS_AS_ERRORS_FLAGS:STRING="" \
-D Trilinos_ENABLE_ALL_PACKAGES:BOOL=OFF \
-D Trilinos_ENABLE_Teuchos:BOOL=ON \
-D Trilinos_ENABLE_Epetra:BOOL=ON \
-D Trilinos_ENABLE_EpetraExt:BOOL=ON \
-D Trilinos_ENABLE_Ifpack:BOOL=ON \
-D Trilinos_ENABLE_Ifpack2:BOOL=ON \
-D Trilinos_ENABLE_AztecOO:BOOL=ON \
-D Trilinos_ENABLE_Amesos:BOOL=ON \
-D Trilinos_ENABLE_MueLu:BOOL=OFF \
-D Trilinos_ENABLE_Anasazi:BOOL=ON \
-D Trilinos_ENABLE_Belos:BOOL=ON \
-D Trilinos_ENABLE_Tpetra:BOOL=ON \
-D Trilinos_ENABLE_OpenMP:BOOL=OFF \
-D Trilinos_ENABLE_Xpetra:BOOL=OFF \
-D Trilinos_ENABLE_Isorropia:BOOL=ON \
-D Trilinos_ENABLE_TESTS:BOOL=ON \
-D TPL_ENABLE_BLAS:BOOL=ON \
-D TPL_BLAS_LIBRARIES:PATH="~/foam/foam-extend-3.2/ThirdParty/rpmBuild/BUILD/BLAS-3.8.0/libblas.so" \
-D TPL_ENABLE_LAPACK:BOOL=ON \
-D LAPACK_LIBRARY_DIRS:PATH="~/foam/foam-extend-3.2/ThirdParty/packages/LAPACK/lib" \
-D TPL_ENABLE_Boost:BOOL=ON \
-D Boost_INCLUDE_DIRS:PATH="~/foam/foam-extend-3.2/ThirdParty/rpmBuild/BUILD/boost_1_66_0" \
-D Boost_LIBRARY_DIRS:PATH="~/foam/foam-extend-3.2/ThirdParty/rpmBuild/BUILD/boost_1_66_0/stage/lib" \
-D CMAKE_VERBOSE_MAKEFILE:BOOL=OFF \
-D Trilinos_VERBOSE_CONFIGURE:BOOL=OFF \
-D Amesos_ENABLE_SuperLUDist:BOOL=OFF \
-D TPL_ENABLE_ParMETIS:BOOL=ON \
-D ParMETIS_INCLUDE_DIRS:PATH="~/foam/foam-extend-3.2/ThirdParty/packages/parmetis-4.0.3/platforms/linux64GccDPOpt/include" \
-D ParMETIS_LIBRARY_DIRS:PATH="~/foam/foam-extend-3.2/ThirdParty/packages/parmetis-4.0.3/platforms/linux64GccDPOpt/lib" \
-D TPL_ENABLE_SuperLUDist:BOOL=OFF \
..

Thank you and looking forward to your reply!

Best regards, Shuang

cgcgcg commented 4 years ago

@trilinos/belos

zhengshuang2005 commented 4 years ago

Problem resolved. It happened because long as global indices Is disabled in the Trilinos compilation.

mhoemmen commented 4 years ago

@zhengshuang2005 You should only ever use global index types that are enabled at configure time (e.g., with a CMake option).

abodado commented 5 months ago

Where is this "https://trilinos.org/docs/r12.12/packages/belos/doc/html/classBelos_1_1SolverFactory.html". file that @zhengshuang2005 mentioned? It looks like a good example, but I don't see the full file anywhere. Looks like that link is no longer valid.

cgcgcg commented 5 months ago

Check here: https://docs.trilinos.org/dev/packages/belos/doc/html/classBelos_1_1BelosSolverFactory.html

abodado commented 5 months ago

@cgcgcg, thank you. However, I do not see a "tutorial" on that page as was referenced by @zhengshuang2005. He stated "I used the Belos solver package and followed the Belos solver package tutorial as shown on the Doxygen page". Perhaps he made his own code based on the documentation.

cgcgcg commented 5 months ago

As far as I know there is no such tutorial, but lemme tag @hkthorn.

hkthorn commented 5 months ago

@abodado There are not adequate examples for using the Belos linear solver factory at this time. The examples we have only illustrate constructing a specific solver object directly. That is an omission I'll look into correcting ASAP.

abodado commented 5 months ago

Thank you @cgcgcg and @hkthorn for looking into this.