Re: [deal.II] Eigenvalues and Eigenvectors of BlockSparse Matrix

2020-09-24 Thread Animesh Rastogi IIT Gandhinagar
Hi,

I could figure out how to give Identity Matrix instead of the mass matrix 
to solve the Standard Eigen value problem. However, on running, I am 
getting the folllowing error. 

Timestep 1 @ 0.1s
___
SOLVER STEP |  LIN_IT   LIN_RESRES_NORM RES_U 
NU_NORM  NU_U 
___
  0  CST  ASM  SLVCMakeFiles/run.dir/build.make:57: recipe for target 
'CMakeFiles/run' failed
make[3]: *** [CMakeFiles/run] Segmentation fault (core dumped)
CMakeFiles/Makefile2:131: recipe for target 'CMakeFiles/run.dir/all' failed
make[2]: *** [CMakeFiles/run.dir/all] Error 2
CMakeFiles/Makefile2:138: recipe for target 'CMakeFiles/run.dir/rule' failed
make[1]: *** [CMakeFiles/run.dir/rule] Error 2
Makefile:144: recipe for target 'run' failed
make: *** [run] Error 2



I am copying here the solve_linear_system function and the part that I 
updated is blue in color. Also, I wish to calculate the eigenvalues after 
the newton method has converged. I am a bit confused of where actually to 
solve the standard eigenvalue problem in the code for my purpose. Could 
someone please help me with these questions?


template 
  std::pair
  Solid::solve_linear_system(BlockVector 
&newton_update)
  {
BlockVector A(dofs_per_block);
BlockVector B(dofs_per_block);

unsigned int lin_it = 0;
double lin_res = 0.0;
{
  timer.enter_subsection("Linear solver");
  std::cout << " SLV " << std::flush;
  if (parameters.type_lin == "CG")
{
  const int solver_its = static_cast(
tangent_matrix.block(u_dof, u_dof).m()
* parameters.max_iterations_lin);
  const double tol_sol = parameters.tol_lin
 * system_rhs.block(u_dof).l2_norm();

  SolverControl solver_control(solver_its, tol_sol);

  GrowingVectorMemory > GVM;
  SolverCG > solver_CG(solver_control, GVM);

  PreconditionSelector, Vector >
  preconditioner (parameters.preconditioner_type,
  parameters.preconditioner_relaxation);
  preconditioner.use_matrix(tangent_matrix.block(u_dof, u_dof));

  solver_CG.solve(tangent_matrix.block(u_dof, u_dof),
  newton_update.block(u_dof),
  system_rhs.block(u_dof),
  preconditioner);

  lin_it = solver_control.last_step();
  lin_res = solver_control.last_value();
}
  else if (parameters.type_lin == "Direct")
{
 
  SparseDirectUMFPACK A_direct;
  A_direct.initialize(tangent_matrix.block(u_dof, u_dof));
  A_direct.vmult(newton_update.block(u_dof), 
system_rhs.block(u_dof));

  lin_it = 1;
  lin_res = 0.0;
}
  else
Assert (false, ExcMessage("Linear solver type not implemented"));

   std::vector>   eigenvalues;
   std::vector >eigenvectors;
   SparseDirectUMFPACK inverse;
   inverse.initialize (tangent_matrix.block(u_dof,u_dof));
  SolverControl solver_control(1000, 1e-9);

 ArpackSolver eigensolver(solver_control,
ArpackSolver::AdditionalData(ArpackSolver::WhichEigenvalues::algebraically_smallest));
 eigensolver.solve(tangent_matrix.block(u_dof,u_dof), IdentityMatrix(), 
inverse, eigenvalues, eigenvectors,eigenvalues.size());

  timer.leave_subsection();
}
-
On Friday, September 25, 2020 at 12:15:29 AM UTC+5:30 Animesh Rastogi IIT 
Gandhinagar wrote:

> I could finally configure dealii using ARPACK. I am facing issues in 
> initialising the identity matrix that is to be given to the 
> eigensolver.solve(). I am trying to replace the mass matrix with an 
> identity matrix..
>
> I am copying the code again in this thread..
>
> std::vector>   eigenvalues;
>   std::vector >eigenvectors;
>   SparseMatrix identity (IdentityMatrix(u_dof));
>   SparseDirectUMFPACK inverse;
>   inverse.initialize (tangent_matrix.block(u_dof,u_dof));
>   const int eigensolver_its = static_cast(
> tangent_matrix.block(u_dof, u_dof).m()
> * parameters.max_iterations_lin);
>   SolverControl solver_control(eigensolver_its, 1e-9);
>   ArpackSolver::ArpackSolver eigensolver(solver_control);
>   eigensolver.solve(tangent_matrix.block(u_dof,u_dof), identity, 
> inverse, eigenvalues, eigenvectors);
>
> I am getting the following error for this - 
>
> error: request for member ‘vmult’ in ‘mass_matrix’, which is of non-class 
> type ‘dealii::BlockSparseMatrix(dealii::IdentityMatrix)’
>mass_matrix.vmult(tmp, src);
>
> Could someone please help me with this?
>
> Thanks!
>
> Animesh

Re: [deal.II] Eigenvalues and Eigenvectors of BlockSparse Matrix

2020-09-24 Thread Animesh Rastogi IIT Gandhinagar
I could finally configure dealii using ARPACK. I am facing issues in 
initialising the identity matrix that is to be given to the 
eigensolver.solve(). I am trying to replace the mass matrix with an 
identity matrix..

I am copying the code again in this thread..

std::vector>   eigenvalues;
  std::vector >eigenvectors;
  SparseMatrix identity (IdentityMatrix(u_dof));
  SparseDirectUMFPACK inverse;
  inverse.initialize (tangent_matrix.block(u_dof,u_dof));
  const int eigensolver_its = static_cast(
tangent_matrix.block(u_dof, u_dof).m()
* parameters.max_iterations_lin);
  SolverControl solver_control(eigensolver_its, 1e-9);
  ArpackSolver::ArpackSolver eigensolver(solver_control);
  eigensolver.solve(tangent_matrix.block(u_dof,u_dof), identity, 
inverse, eigenvalues, eigenvectors);

I am getting the following error for this - 

error: request for member ‘vmult’ in ‘mass_matrix’, which is of non-class 
type ‘dealii::BlockSparseMatrix(dealii::IdentityMatrix)’
   mass_matrix.vmult(tmp, src);

Could someone please help me with this?

Thanks!

Animesh
On Thursday, September 24, 2020 at 4:40:47 PM UTC+5:30 Animesh Rastogi IIT 
Gandhinagar wrote:

> Hi Jean,
>
> It turns out that I did not configure dealii with ARPACK. So I followed 
> the readme instructions and installed and compiled ARPACK as suggested. I 
> also tried to run the examples in the ARPACK directory and they are running 
> without any errors. However, when I tried to reconfigure deallii using the 
> selfcompiled version, it says the following error. 
>
> Could not find the arpack library!
>
>   Please ensure that a suitable arpack library is installed on your 
> computer.
>
>   If the library is not at a default location, either provide some hints 
> for
>   autodetection,
>
>   $ ARPACK_DIR="..." cmake <...>
>   $ cmake -DARPACK_DIR="..." <...>
>
>   or set the relevant variables by hand in ccmake.
>
> I used the following cmake command to configure dealii again  -
>
> cmake -DDEAL_II_WITH_PETSC=ON 
> -DPETSC_DIR=/home/animesh/Documents/petsc-3.13.5 
> -DPETSC_ARCH=arch-linux-c-debug -DDEAL_II_WITH_METIS=ON 
> -DDEAL_II_WITH_MPI=ON -DDEAL_II_WITH_ARPACK=ON 
> -DARPACK_DIR=/home/animesh/Documents/ARPACK ..
>
> I checked that the path of the directory of ARPACK that I am giving here 
> is correct.
>
> I followed the instructions in this page - 
> https://www.dealii.org/current/external-libs/arpack.html. 
> Also, I couldn't figure out what it means when it says "For compilation 
> of ARPACK we emphasize adding the compiler flag -fPIC". What is -fPIC and 
> where should I use this flag?
>
> Could you please help me with this and the question about identity matrix 
> asked in the previous mail of this thread?
>
> Thanks a lot!
>
> Animesh
> On Thursday, September 24, 2020 at 11:56:24 AM UTC+5:30 Animesh Rastogi 
> IIT Gandhinagar wrote:
>
>> Hi Jean,
>>
>> Thanks a lot for your response. I am trying as you suggested. I have 
>> added the following code inside the linear solver so that I can get the 
>> eigenvalues at every newton step.
>>
>> std::vector>   eigenvalues;
>>   std::vector >eigenvectors;
>>   SparseMatrix identity (IdentityMatrix(u_dof));
>>   SparseDirectUMFPACK inverse;
>>   inverse.initialize (tangent_matrix.block(u_dof,u_dof));
>>   const int eigensolver_its = static_cast(
>> tangent_matrix.block(u_dof, u_dof).m()
>> * parameters.max_iterations_lin);
>>   SolverControl solver_control(eigensolver_its, 1e-9);
>>   ArpackSolver::ArpackSolver eigensolver(solver_control);
>>   eigensolver.solve(tangent_matrix.block(u_dof,u_dof), identity, 
>> inverse, eigenvalues, eigenvectors);
>>
>> However, I am getting the follwing error while compiling. 
>>
>> error: ‘ArpackSolver’ has not been declared
>>
>> I have included the header file #include . 
>>
>> Also, could you please let me know if I have declared the identity matrix 
>> correctly? I am replacing the mass matrix B with the Identity matrix to 
>> compute the eigenvalues and eigenvectors.
>>
>> Thanks!
>>
>> Animesh
>> On Thursday, September 24, 2020 at 1:10:35 AM UTC+5:30 Jean-Paul Pelteret 
>> wrote:
>>
>>> Hi Animesh,
>>>
>>> Although in that code-gallery example the system is assembled into a 
>>> BlockSparseMatrix, the system actually has only one block. So you 
>>> can retrieve the underlying SparseMatrix (and Vector for 
>>> the RHS) via
>>> tangent_matrix.block(u_dof, u_dof);
>>> system_rhs.block(u_dof);
>>> and use them with one of the standard eigensolvers (maybe ArpackSolver 
>>> , 
>>> since you want both the eigenvalues and eigenvectors).
>>>
>>> I hope that this helps you!
>>>
>>> Best,
>>> Jean-Paul
>>>
>>> On 23 Sep 2020, at 20:53, Animesh Rastogi IIT Gandhinagar <
>>> animes

Re: [deal.II] step-1 Error

2020-09-24 Thread luca.heltai
In the documentation of the 9.0.0 package, this is what is installed via spack:

==> 60 installed packages.
-- darwin-highsierra-x86_64 / clang@6.0.0 ---
adol-c@develop  gmp@6.1.2matio@1.5.9 
ninja@1.8.2 readline@7.0
arpack-ng@3.6.3 gmsh@4.0.0   metis@5.1.0 
numdiff@5.9.0   slepc@3.9.2
assimp@4.0.1gsl@2.3  mpc@1.1.0   oce@0.18.3 
 sqlite@3.23.1
autoconf@2.69   hdf5@1.10.3  mpfr@4.0.1  
openblas@0.3.3  suite-sparse@5.3.0
automake@1.16.1 hwloc@1.11.9 mumps@5.1.1 
openmpi@3.1.2   sundials@3.2.0
boost@1.68.0hypre@2.14.0 muparser@2.2.5  
openssl@1.0.2o  superlu-dist@5.2.2
bzip2@1.0.6 intel-tbb@2019   nanoflann@1.2.3 p4est@2.0  
 superlu-mt@3.1
cmake@3.12.2isl@0.19 ncurses@6.1 
parmetis@4.0.3  tcl@8.6.8
environment-modules@3.2.10  libsigsegv@2.11  netcdf@4.6.1
perl@5.26.2 tetgen@1.5.0
gcc@8.2.0   libtool@2.4.6netcdf-cxx@4.2  
petsc@3.9.2 trilinos@12.12.1
gdbm@1.14.1 libxml2@2.9.8netgen@5.3.1
pkgconf@1.4.2   xz@5.2.4
glm@0.9.7.1 m4@1.4.18netlib-scalapack@2.0.2  
python@2.7.15   zlib@1.2.11

and includes environment-modules@3.2.10 (i.e., the module command).

Also, the library is installed in 

#  deal.II configuration:
#CMAKE_BUILD_TYPE:   DebugRelease
#BUILD_SHARED_LIBS:  ON
#CMAKE_INSTALL_PREFIX:   
/Applications/deal.II-9.0.0.app/Contents/Resources
#CMAKE_SOURCE_DIR:   
/Applications/deal.II-9.0.0.app/Contents/Resources/spack/src/dealii-v9.0.0
#(version 9.0.0)
#CMAKE_BINARY_DIR:   /Users/heltai/dealii/build-pack-deal.II-9.0.0
#CMAKE_CXX_COMPILER: Clang 6.0.0 on platform Darwin x86_64
#
/Applications/deal.II-9.0.0.app/Contents/Resources/spack/view/bin/mpicxx

Can you try to configure step-1 indicating the paths that you see here directly?

export DEAL_II_DIR=/Applications/deal.II-9.0.0.app/Contents/Resources

Notice that you should have accesso to all libraries and binaries also in 

/Applications/deal.II-9.0.0.app/Contents/Resources/spack/view/lib

and

/Applications/deal.II-9.0.0.app/Contents/Resources/spack/view/bin

That is, you can force cmake to look there by adding as option 
CMAKE_PREFIX_PATH=/Applications/deal.II-9.0.0.app/Contents/Resources/spack/view/

What happens if you try to configure and run step-1 after setting DEAL_II_DIR 
manually?

L.


> On 22 Sep 2020, at 15:15, Scott Ziegler  wrote:
> 
> I'm using version 9.0.0 of deal.ii. I have an older MacBook and it won't 
> update past iOS 10.13.6. I downloaded the .dmg file and opened it/moved it 
> into my applications but I haven't done anything else besides try to run the 
> first example.
> 
> On Tuesday, September 22, 2020 at 6:05:23 AM UTC-6 luca@gmail.com wrote:
> If he’s running from the deal.II terminal, he should have the module command 
> (it is part of the spack installation). 
> 
> The deal.II terminal exports the paths so that the module command is there. 
> What version of the deal.II package is he using? On my system, this is the 
> output I get: 
> 
> 
> 
> bash-3.2$ module avail 
> --- 
> /Applications/deal.II.app/Contents/Resources/spack/share/spack/modules/darwin-catalina-x86_64
>   
> adol-c/2.7.2 hwloc/1.11.11 numdiff/5.9.0 xz/5.2.5 
> arpack-ng/3.7.0-openblas hypre/2.18.2-openblas oce/0.18.3 zlib/1.2.11 
> assimp/4.0.1 intel-tbb/2020.2 openblas/0.3.10 
> autoconf-archive/2019.01.06 libc/1.0 openmpi/3.1.6 
> autoconf/2.69 libffi/3.3 openssl/1.1.1g 
> automake/1.16.2 libsigsegv/2.12 p4est/2.2 
> boost/1.73.0 libtool/2.4.6 parmetis/4.0.3 
> bzip2/1.0.8 libxml2/2.9.10 perl/5.18.4 
> cmake/3.17.1 m4/1.4.18 petsc/3.13.1-openblas-py2-py3 
> dealii/9.2.0-openblas-py2-py3 matio/1.5.13 pkgconf/1.7.3 
> diffutils/3.7 metis/5.1.0 python/3.7.7 
> environment-modules/4.5.1 mpc/1.1.0 readline/8.0 
> expat/2.2.9 mpfr/4.0.2 slepc/3.13.3-openblas-py2-py3 
> gdbm/1.18.1 mumps/5.2.0-openblas sqlite/3.31.1 
> gettext/0.20.2 muparser/2.2.6.1 suite-sparse/5.3.0-openblas 
> ginkgo/1.1.0 nanoflann/1.2.3 sundials/3.2.1 
> glm/0.9.7.1 ncurses/6.2 superlu-dist/6.3.0-openblas 
> gmp/6.1.2 netcdf-c/4.7.3 symengine/0.6.0 
> gmsh/4.5.4-openblas netcdf-cxx/4.2 tar/1.32 
> googletest/1.10.0 netgen/5.3.1 tcl/8.6.8 
> gsl/2.5 netlib-scalapack/2.0.2-openblas tetgen/1.5.0 
> hdf5/1.10.6 ninja/1.10.0-py2-py3 trilinos/12.18.1-openblas 
> bash-3.2$ 
> 
> 
> 
> > On 21 Sep 2020, at 22:51, Wolfgang Bangerth  wrote: 
> > 
> > 
> > Hi Luca, 
> > 
> >> Are you running the terminal, or the deal.II application? 
> >> When you run the deal.II application, you are dropped into a terminal 
> >> (with instructions) to run deal.II examples. Including how to set up 

Re: [deal.II] Eigenvalues and Eigenvectors of BlockSparse Matrix

2020-09-24 Thread Animesh Rastogi IIT Gandhinagar
Hi Jean,

It turns out that I did not configure dealii with ARPACK. So I followed the 
readme instructions and installed and compiled ARPACK as suggested. I also 
tried to run the examples in the ARPACK directory and they are running 
without any errors. However, when I tried to reconfigure deallii using the 
selfcompiled version, it says the following error. 

Could not find the arpack library!

  Please ensure that a suitable arpack library is installed on your 
computer.

  If the library is not at a default location, either provide some hints for
  autodetection,

  $ ARPACK_DIR="..." cmake <...>
  $ cmake -DARPACK_DIR="..." <...>

  or set the relevant variables by hand in ccmake.

I used the following cmake command to configure dealii again  -

cmake -DDEAL_II_WITH_PETSC=ON 
-DPETSC_DIR=/home/animesh/Documents/petsc-3.13.5 
-DPETSC_ARCH=arch-linux-c-debug -DDEAL_II_WITH_METIS=ON 
-DDEAL_II_WITH_MPI=ON -DDEAL_II_WITH_ARPACK=ON 
-DARPACK_DIR=/home/animesh/Documents/ARPACK ..

I checked that the path of the directory of ARPACK that I am giving here is 
correct.

I followed the instructions in this page - 
https://www.dealii.org/current/external-libs/arpack.html. 
Also, I couldn't figure out what it means when it says "For compilation of 
ARPACK we emphasize adding the compiler flag -fPIC". What is -fPIC and 
where should I use this flag?

Could you please help me with this and the question about identity matrix 
asked in the previous mail of this thread?

Thanks a lot!

Animesh
On Thursday, September 24, 2020 at 11:56:24 AM UTC+5:30 Animesh Rastogi IIT 
Gandhinagar wrote:

> Hi Jean,
>
> Thanks a lot for your response. I am trying as you suggested. I have added 
> the following code inside the linear solver so that I can get the 
> eigenvalues at every newton step.
>
> std::vector>   eigenvalues;
>   std::vector >eigenvectors;
>   SparseMatrix identity (IdentityMatrix(u_dof));
>   SparseDirectUMFPACK inverse;
>   inverse.initialize (tangent_matrix.block(u_dof,u_dof));
>   const int eigensolver_its = static_cast(
> tangent_matrix.block(u_dof, u_dof).m()
> * parameters.max_iterations_lin);
>   SolverControl solver_control(eigensolver_its, 1e-9);
>   ArpackSolver::ArpackSolver eigensolver(solver_control);
>   eigensolver.solve(tangent_matrix.block(u_dof,u_dof), identity, 
> inverse, eigenvalues, eigenvectors);
>
> However, I am getting the follwing error while compiling. 
>
> error: ‘ArpackSolver’ has not been declared
>
> I have included the header file #include . 
>
> Also, could you please let me know if I have declared the identity matrix 
> correctly? I am replacing the mass matrix B with the Identity matrix to 
> compute the eigenvalues and eigenvectors.
>
> Thanks!
>
> Animesh
> On Thursday, September 24, 2020 at 1:10:35 AM UTC+5:30 Jean-Paul Pelteret 
> wrote:
>
>> Hi Animesh,
>>
>> Although in that code-gallery example the system is assembled into a 
>> BlockSparseMatrix, the system actually has only one block. So you 
>> can retrieve the underlying SparseMatrix (and Vector for 
>> the RHS) via
>> tangent_matrix.block(u_dof, u_dof);
>> system_rhs.block(u_dof);
>> and use them with one of the standard eigensolvers (maybe ArpackSolver 
>> , 
>> since you want both the eigenvalues and eigenvectors).
>>
>> I hope that this helps you!
>>
>> Best,
>> Jean-Paul
>>
>> On 23 Sep 2020, at 20:53, Animesh Rastogi IIT Gandhinagar <
>> animesh...@alumni.iitgn.ac.in> wrote:
>>
>> Hi All, 
>>
>> I am trying to play with the code of Quassi Static Finite Strain 
>> Compressibility 
>> .
>>  
>> I want to calculate the eigenvalues and eigenvectors of the System Tangent 
>> Matrix (BlockSparseMatrix 
>>  
>> tangent_matrix) that we get at every time step after the Newton method has 
>> converged. However, I could not find any function to calculate the 
>> eigenvalues and eigenvectors of the BlockSparse Matrix. Could someone 
>> please help me with this?
>>
>> Thanks!
>>
>> AR
>>
>> -- 
>> The deal.II project is located at http://www.dealii.org/
>> For mailing list/forum options, see 
>> https://groups.google.com/d/forum/dealii?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "deal.II User Group" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to dealii+un...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/dealii/987eb63a-333e-43b3-a9e0-fbcbae2d567en%40googlegroups.com
>>  
>> 
>> .