diff --git a/Solver/dgDofContainer.cpp b/Solver/dgDofContainer.cpp index bb0056c3426652080730168d433ad417709e6ad9..7eb8fa5c82790bfde1ec926de571f7f0f88c1193 100644 --- a/Solver/dgDofContainer.cpp +++ b/Solver/dgDofContainer.cpp @@ -12,7 +12,7 @@ #include <sstream> #include "MElement.h" dgDofContainer::dgDofContainer (dgGroupCollection *groups, int nbFields): - _groups(*groups) + _groups(*groups), _mshStep(0) { int _dataSize = 0; _dataSizeGhost=0; @@ -213,11 +213,13 @@ void dgDofContainer::L2Projection(std::string functionName){ } -void dgDofContainer::exportMsh(const std::string name){ +void dgDofContainer::exportMsh(const std::string name) +{ // the elementnodedata::export does not work !! for (int ICOMP = 0; ICOMP<_nbFields;++ICOMP){ - std::ostringstream name_oss; + std::ostringstream name_oss, name_view; + name_view<<"comp_"<<ICOMP; name_oss<<name<<"_COMP_"<<ICOMP<<".msh"; if(Msg::GetCommSize()>1) name_oss<<"_"<<Msg::GetCommRank(); @@ -229,11 +231,11 @@ void dgDofContainer::exportMsh(const std::string name){ fprintf(f,"$MeshFormat\n2.1 0 8\n$EndMeshFormat\n"); fprintf(f,"$ElementNodeData\n"); fprintf(f,"1\n"); - fprintf(f,"\"%s\"\n",name.c_str()); + fprintf(f,"\"%s\"\n",name_view.str().c_str()); fprintf(f,"1\n"); - fprintf(f,"0.0\n"); + fprintf(f,"%d\n", _mshStep); // should print actual time here fprintf(f,"%d\n", Msg::GetCommSize() > 1 ? 4 : 3); - fprintf(f,"0\n 1\n %d\n",COUNT); + fprintf(f,"%d\n 1\n %d\n", _mshStep, COUNT); if(Msg::GetCommSize() > 1) fprintf(f,"%d\n", Msg::GetCommRank()); for (int i=0;i < _groups.getNbElementGroups() ;i++){ dgGroupOfElements *group = _groups.getElementGroup(i); @@ -251,7 +253,9 @@ void dgDofContainer::exportMsh(const std::string name){ fprintf(f,"$EndElementNodeData\n"); fclose(f); } - return; + + _mshStep++; + // we should discuss that : we do a copy of the solution, this should // be avoided ! @@ -294,5 +298,5 @@ void dgDofContainer::registerBindings(binding *b){ cm->setArgNames("functionName",NULL); cm = cb->addMethod("exportMsh",&dgDofContainer::exportMsh); cm->setDescription("Export the dof for gmsh visualization"); - cm->setArgNames("filename",NULL); + cm->setArgNames("filename", NULL); } diff --git a/Solver/dgDofContainer.h b/Solver/dgDofContainer.h index c9659752ffd174eee80934a3a50c1c34ca6db940..12094bf1ad11d47429c7f8686bcd1b818a7d6c50 100644 --- a/Solver/dgDofContainer.h +++ b/Solver/dgDofContainer.h @@ -23,6 +23,7 @@ private: double *sendBuf, *recvBuf; std::vector<fullMatrix<double> *> _dataProxys; // proxys std::map<const dgGroupOfElements*,int> _groupId; + int _mshStep; public: void scale(double f); double norm(); diff --git a/Solver/eigenSolver.cpp b/Solver/eigenSolver.cpp index 9a582c7e564f905a55ad4c4292498b203481ae4c..3568215d5627c666dcd22bd652be236890df96d5 100644 --- a/Solver/eigenSolver.cpp +++ b/Solver/eigenSolver.cpp @@ -21,12 +21,10 @@ eigenSolver::eigenSolver(dofManager<double> *manager, std::string A, _B = dynamic_cast<linearSystemPETSc<double>*>(manager->getLinearSystem(B)); if(!_B) Msg::Error("Could not find PETSc system '%s'", B.c_str()); } - } bool eigenSolver::solve(int numEigenValues, std::string which) { - if(!_A) return false; Mat A = _A->getMatrix(); Mat B = _B ? _B->getMatrix() : PETSC_NULL; @@ -107,15 +105,14 @@ bool eigenSolver::solve(int numEigenValues, std::string which) Msg::Error("The operator is nonsymmetric"); // get number of converged approximate eigenpairs - PetscInt nconv; - _try(EPSGetConverged(eps, &nconv)); - Msg::Info("SLEPc number of converged eigenpairs: %d", nconv); - - if (nconv>0) { - - // ignore additional eigenvalues if we get more than what we asked - if(nconv > nev) nconv = nev; - + PetscInt nconv; + _try(EPSGetConverged(eps, &nconv)); + Msg::Info("SLEPc number of converged eigenpairs: %d", nconv); + + // ignore additional eigenvalues if we get more than what we asked + if(nconv > nev) nconv = nev; + + if (nconv > 0) { Vec xr, xi; _try(MatGetVecs(A, PETSC_NULL, &xr)); _try(MatGetVecs(A, PETSC_NULL, &xi)); @@ -151,16 +148,12 @@ bool eigenSolver::solve(int numEigenValues, std::string which) } _eigenVectors.push_back(ev); } - - // cleanup - _try(EPSDestroy(eps)); _try(VecDestroy(xr)); _try(VecDestroy(xi)); - _try(SlepcFinalize()); - } - + _try(EPSDestroy(eps)); + _try(SlepcFinalize()); if(reason == EPS_CONVERGED_TOL){ Msg::Info("SLEPc done");