[deal.II] Re: for help step-35 . flow around the cylinder

2019-12-08 Thread Wolfgang Bangerth
On 12/8/19 9:02 AM, hussan zeb wrote:
> 
> 
> An error occurred in line <361> of file 
>  in function
>      dealii::Point::Point(Number, Number, Number) [with int dim 
> = 
> 2; Number = double]
> The violated condition was:
>      dim == 3
> Additional information:
> You can only initialize Point<3> objects using the constructor that takes 
> three arguments. Point objects with dim!=3 require initialization with 
> the constructor that takes 'dim' arguments.
> 
> Stacktrace:
> ---
> #0  ./step-35: dealii::Point<2, double>::Point(double, double, double)
> #1  ./step-35: Step35::NavierStokesProjection<2>::run(bool, unsigned int)
> #2  ./step-35: main
> 

Hussan,
we don't know what causes this without debugging the code you attach. But the 
error message is quite clear in explaining what is happening. One way or the 
other, you will have to learn to debug codes with a debugger so you can see 
where this kind of error happens and how to fix it. There are also video 
lectures on this topic. Why don't you use this relatively simple occasion as a 
way to learn a new skill?

Best
  W.

-- 

Wolfgang Bangerth  email: bange...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/9f55ca5f-d84b-2d7c-f1c7-3d562ccbd582%40colostate.edu.


Re: [deal.II] get_dof_indices() only works on active cells - blocks vector

2019-12-08 Thread Juan Felipe Giraldo
Dear David,
 
Thank you for your quick reply. 
Yes, I need the neighbour information of each cell to compute the boundary 
integration in the DG formulation. Therefore, I get the neighbouring cell 
in the loop of the active cell by using "const auto neighbor = 
cell->neighbor(face_n)";  (similar to step 30). 
I am quite sure that the problem is what you are describing, thus it occurs 
only when I use the adaptative refinement. 

The problem appears here:
#0  ./FEM-DGdeal: dealii::DoFCellAccessor, 
false>::get_dof_indices(std::vector >&) const
#1  ./FEM-DGdeal: FEMwDG<2>::assemble_system(unsigned int)
#2  ./FEM-DGdeal: FEMwDG<2>::run(unsigned int, unsigned int, unsigned int, 
unsigned int)
#3  ./FEM-DGdeal: main

And the part of the code where I call the get_dof_indices is this:

void FEMwDG::assemble_system(const unsigned int typecase)
{
  const unsigned int dofs_per_cell = dof_handler.get_fe().dofs_per_cell;
  std::vector local_dof_indices(dofs_per_cell);
  std::vector 
neighbor_dof_indices(dofs_per_cell);
  const UpdateFlags update_flags = update_values | update_gradients |
   update_quadrature_points |
   update_JxW_values;
  const UpdateFlags face_update_flags =  update_values | 
update_quadrature_points | update_JxW_values |
 update_normal_vectors;
  const UpdateFlags neighbor_face_update_flags = update_values;

  FEValues fe_values(mapping, fe, quadrature, update_flags);
  FEFaceValues fe_face_values(mapping, fe, face_quadrature, 
face_update_flags);
  FESubfaceValues fe_subface_values(mapping,  fe, face_quadrature, 
face_update_flags);
  FEFaceValues  fe_face_neighbor(mapping,  fe, 
face_quadrature,neighbor_face_update_flags);

  FullMatrix ui_vi_matrix(dofs_per_cell, dofs_per_cell); 
//matrix dominio
  FullMatrix ue_vi_matrix(dofs_per_cell, dofs_per_cell);
  FullMatrix ui_ve_matrix(dofs_per_cell, dofs_per_cell);
  FullMatrix ue_ve_matrix(dofs_per_cell, dofs_per_cell);

  Vector cell_vector(dofs_per_cell);
  const FEValuesExtractors::Scalar verror(0);
  const FEValuesExtractors::Scalar variable(1);

  for (const auto  : dof_handler.active_cell_iterators())
{
  fe_values.reinit(cell);   ui_vi_matrix = 0;  cell_vector= 0;
  //--DOMAIN 
INTEGRATOR--
 adv.assemble_cell_term(fe_values, ui_vi_matrix, cell_vector, 
verror, variable,cell, typecase);
 cell->get_dof_indices(local_dof_indices);

for (unsigned int face_n = 0;  face_n < 
GeometryInfo::faces_per_cell;  ++face_n)
  {
//-FACE AT THE 
EXTERNAL 
BOUNDARY-
const auto face = cell->face(face_n);
 if (face->at_boundary())
   {
 fe_face_values.reinit(cell, face_n);
 adv.assemble_boundary_term(fe_face_values, 
ui_vi_matrix, cell_vector, verror, variable);
   }
//-FACE AT THE 
INTERNAL 
BOUNDARY-
   else
   {
  const auto neighbor = cell->neighbor(face_n);
 if ((dim > 1) && (cell->index() < 
neighbor->index()))
  {
 const unsigned int neighbor2 
=cell->neighbor_face_no(face_n);
 ue_vi_matrix = 0; ui_ve_matrix = 0;  ue_ve_matrix 
= 0;

 fe_face_values.reinit(cell, face_n);
 fe_face_neighbor.reinit(neighbor, neighbor2);

 adv.assemble_face_term(fe_face_values, 
fe_face_neighbor,  ui_vi_matrix, ue_vi_matrix, ui_ve_matrix, ue_ve_matrix,  
verror,  variable,  typecase);
 neighbor->get_dof_indices(neighbor_dof_indices);

 // ---LOCAL ASSEMBLE 
--
for (unsigned int i = 0; i < dofs_per_cell; ++i)
   for (unsigned int j = 0; j < dofs_per_cell; ++j)
 {
 system_matrix.add(local_dof_indices[i],  
neighbor_dof_indices[j],  ue_vi_matrix(i, j));

 system_matrix.add(neighbor_dof_indices[i],  local_dof_indices[j],  
ui_ve_matrix(i, j));
 system_matrix.add(neighbor_dof_indices[i], 
neighbor_dof_indices[j], ue_ve_matrix(i, j));
   }
  }
   }
 }


Re: [deal.II] get_dof_indices() only works on active cells - blocks vector

2019-12-08 Thread David Wells
Dear Juan,

My best guess is that, at some point in the loop over all active
cells, you are also doing some computations involving the neighbor of
each cell. TriaAccessor::neighbor() returns the neighboring cell which
has, at most, the same level number as the current cell: i.e., if the
neighbor cell has been refined but the current cell has not, then
trying to get the degrees of freedom from the neighbor will throw
exactly this exception since the cell returned by the call to
neighbor() is inactive.

This is only a guess. Could you show us the part of your code that
triggers this exception? That will help us give you a better answer :)

Thanks,
David

On Fri, Dec 6, 2019 at 3:53 AM Juan Felipe Giraldo  wrote:
>
>
> Hi all!
>
> I am currently working on the linear advection problem by using a DG 
> formulation, similar to the problem in step 12 
> https://www.dealii.org/current/doxygen/deal.II/step_12.html, but using a 
> mixed formulation as it is shown in step 20 
> https://www.dealii.org/current/doxygen/deal.II/step_20.html. I can solve the 
> problem without problems using a global refinement, however, when I implement 
> an adaptative refinement I have the following problem after the 1st 
> refinement cycle
>
> An error occurred in line <3792> of file 
> 
>  in function
> void dealii::DoFCellAccessor lda>::get_dof_indices(std::vector&) const [with DoFHandlerType 
> = dealii::DoFHandler<2, 2>; bool level_dof_access = false]
> The violated condition was:
> this->active()
> Additional information:
> get_dof_indices() only works on active cells.
>
>
> I have seen that some people had this problem a couple of years ago, but I 
> have not seen a proper solution to solve it.
>
> Anyone knows how can I solve it?
>
> Thank you so much,
>
> Regards,
>
> Juan Felipe Giraldo
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/dealii/38d23dcb-3028-45eb-a539-737e72c597b0%40googlegroups.com.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/CABrTbYS7_D7cz8BVjObSSy3a6zAHMSCrwn75cj79XBVnOicCpw%40mail.gmail.com.


[deal.II] Usage of the AD framework for solving a time-dependent equation

2019-12-08 Thread 'Maxi Miller' via deal.II User Group
I tried to use the AD framework in my own codes (mainly for solving 
nonlinear equations), and therefore wrote a small test program for solving 
the linear diffusion equation (after I can calculate the jacobian by hand 
for that equation). Thus, my residual for the AD-jacobian is -0.5 * (\nabla 
u_1 + \nabla u_0)\cdot\nabla\varphi - \frac{1}{dt}(u_1 - u_0)\cdot\varphi, 
with u_0 my current solution, and u_1 my solution for the next step. When 
creating the jacobian by hand, I use the same approach as shown in example 
33, and assume that u_1 = u_0 in my first step, resulting in 
-0.5\cdot(\nabla\varphi_i\cdot\nabla\varphi_j) - 
\frac{1}{dt}\cdot\varphi_i\cdot\varphi_j, and my right hand side is \nabla 
u_0\cdot\nabla\varphi.
Solving both systems should give me a value for \delta u, i.e. the update 
for my current solution, such that u_1 = \delta u + u_0 (after the system 
is linear).
Though, when running the code in the attachment, I get the correct result 
(i.e. \delta u) for my hand-assembled system, but the solution I get for 
the AD-generated jacobian is u_1, not \delta u. Did I misinterpret 
something, or is there another bug in the code?
Thanks!

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/e556dfdd-d5e8-453c-896a-0fb2f3cc73b2%40googlegroups.com.
/* -
 *
 * Copyright (C) 2009 - 2019 by the deal.II authors
 *
 * This file is part of the deal.II library.
 *
 * The deal.II library is free software; you can use it, redistribute
 * it, and/or modify it under the terms of the GNU Lesser General
 * Public License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * The full text of the license can be found in the file LICENSE.md at
 * the top level directory of deal.II.
 *
 * -
 *
 * Author: Wolfgang Bangerth, Texas A University, 2009, 2010
 * Timo Heister, University of Goettingen, 2009, 2010
 */
#include 
#include 
#include 
#include 

namespace LA
{
#undef DEAL_II_WITH_PETSC
#if defined(DEAL_II_WITH_PETSC) && !defined(DEAL_II_PETSC_WITH_COMPLEX) && \
	!(defined(DEAL_II_WITH_TRILINOS) && defined(FORCE_USE_OF_TRILINOS))
	using namespace dealii::LinearAlgebraPETSc;
#  define USE_PETSC_LA
#elif defined(DEAL_II_WITH_TRILINOS)
	using namespace dealii::LinearAlgebraTrilinos;
#else
#  error DEAL_II_WITH_PETSC or DEAL_II_WITH_TRILINOS required
#endif
} // namespace LA
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include 
#include 
#include 

#include 
#include 
#include 

#include 
#include 

#include 
#include 
#include 

#include 
#include 
#include 

#include 

#include 
#include 

#include 
#include 

constexpr double time_step = 0.0001;

namespace Step40
{
	using namespace dealii;


	template 
	class InitialCondition : public Function
	{
	public:
		InitialCondition() : Function(1){

		}
		virtual double value(const Point , const unsigned int component) const override;
		virtual Tensor<1, dim> gradient(const Point , const unsigned int component) const override;
	};

	template 
	double InitialCondition::value(const Point , const unsigned int) const{
		const double x = p[0];
		const double y = p[1];

		return sin(M_PI * x) * sin(M_PI * y);
	}

	template 
	Tensor<1, dim> InitialCondition::gradient(const Point , const unsigned int) const{
		const double x = p[0];
		const double y = p[1];

		Tensor<1, dim> return_value;
		return_value[0] = M_PI * cos(M_PI * x) * sin(M_PI * y);
		return_value[1] = M_PI * sin(M_PI * x) * cos(M_PI * y);

		return return_value;
	}

	template 
	class LaplaceProblem
	{
	public:
		LaplaceProblem();
		void run();
	private:
		void setup_system();
		void assemble_jacobian_by_hand_dynamic();
		void assemble_jacobian_by_AD_dynamic();
		void solve();
		void solve_with_newton_hand();
		void solve_with_newton_AD();
		void refine_grid();
		void output_results(const unsigned int cycle) const;

		MPI_Comm mpi_communicator;
		parallel::distributed::Triangulation triangulation;
		FE_Q   fe;
		DoFHandler dof_handler;
		IndexSet locally_owned_dofs;
		IndexSet locally_relevant_dofs;
		AffineConstraints constraints;
		LA::MPI::SparseMatrix system_matrix, jacobian_matrix_AD, jacobian_matrix_hand, mass_matrix;
		LA::MPI::Vector   locally_relevant_solution,
		locally_relevant_solution_AD,
		locally_relevant_solution_hand;
		LA::MPI::Vector   system_rhs, residual_rhs_AD, residual_rhs_hand;
		ConditionalOStream pcout;
		TimerOutput   

Re: [deal.II] deal stopped working with latest macOS update (10.15)

2019-12-08 Thread Alberto Salvadori
It works very well. Thank you so much, Luca.
Alberto


*Alberto Salvadori* Dipartimento di Ingegneria Meccanica e Industriale
(DIMI)
 Universita` di Brescia, via Branze 43, 25123 Brescia
 Italy
 tel 030 3711239
 fax 030 3711312

e-mail:
 alberto.salvad...@unibs.it
web-page:
 http://m4lab.unibs.it/faculty.html



On Sat, Dec 7, 2019 at 7:23 AM luca.heltai  wrote:

> Dear Alberto,
>
> I’ve just finished uploading a new image:
>
>
> https://github.com/dealii/dealii/releases/download/v9.1.1/dealii-9.1.1-clang-9.0.0.dmg
>
> This one is built with clang-9.0.0 (embedded in the image), and mpich. It
> is still a temporary image, because symengine could not be installed (
> www.mpfr.org is down, and symengine depends on it), and neither could
> netcdf.
>
> Can you see if this image works for you?
>
> The examples are in the path
>
>
> /Applications/deal.II.app/Contents/Resources/Libraries/share/deal.II/examples
>
> I quickly checked step-40, and it compiled and run fine.
>
> L.
>
> > On 6 Dec 2019, at 15:16, Alberto Salvadori 
> wrote:
> >
> > Hi Luca
> >
> > many thanks. I got this:
> >
> > bash-3.2$ spack arch
> > shell-init: error retrieving current directory: getcwd: cannot access
> parent directories: Operation not permitted
> > shell-init: error retrieving current directory: getcwd: cannot access
> parent directories: Operation not permitted
> > shell-init: error retrieving current directory: getcwd: cannot access
> parent directories: Operation not permitted
> > shell-init: error retrieving current directory: getcwd: cannot access
> parent directories: Operation not permitted
> > darwin-catalina-ivybridge
> >
> > Thank you, I will do as you suggest.
> >
> > Alberto
> >
> > Alberto Salvadori
> >  Dipartimento di Ingegneria Meccanica e Industriale (DIMI)
> >  Universita` di Brescia, via Branze 43, 25123 Brescia
> >  Italy
> >  tel 030 3711239
> >  fax 030 3711312
> >
> > e-mail:
> >  alberto.salvad...@unibs.it
> > web-page:
> >  http://m4lab.unibs.it/faculty.html
> >
> >
> >
> > On Fri, Dec 6, 2019 at 11:18 AM luca.heltai 
> wrote:
> > Alberto,
> >
> > this may be related to different hardware and different optimisation
> configurations.
> >
> > What’s the output of:
> >
> > spack arch
> >
> > for you, in the deal.II terminal?
> >
> > I get:
> >
> > darwin-catalina-haswell
> >
> > If you get something different, then maybe the problem is there. I don’t
> have a more recent mac (yet). It should arrive shortly, and then I should
> be able to fix it also for you, I think.
> >
> > My initial suggestion still stands. I create the package using simply
> “spack install dealii”. Try the following (in your dealii terminal):
> >
> > cd $SPACK_ROOT
> > # git pull origin develop # Optional, if you want the latest versions of
> all libraries
> > spack install dealii@9.1.1
> >
> > This will take some time, but should succeed.
> >
> > Luca.
> >
> >
> > > On 5 Dec 2019, at 16:56, Alberto Salvadori 
> wrote:
> > >
> > > This is good, perhaps you can address how did you solved the issue.
> > > I honestly have not done anything fancy:
> > >
> > >
> > > 1 - downloaded dealii-9.1.1-catalina-haswell-ro.dmg.zip
> > > 2 - drag and drop into applications
> > > 3 - open the deal.ii.app
> > > 4 - the outcome in attachment.
> > >
> > > I am using Xcode Version 11.2.1 (11B500), and macOS Catalina 10.15
> > >
> > > Thank you!
> > >
> > >
> > >
> > > Il giorno martedì 3 dicembre 2019 17:45:13 UTC+1, Ester Comellas ha
> scritto:
> > > I'm also able to run step-20 succesfully, both in debug and release
> modes.
> > >
> > > El dimarts, 3 desembre de 2019 11:33:40 UTC-5, Ester Comellas va
> escriure:
> > > Hi,
> > >
> > > I got deal.II-9.1.1 to work on macOS Catalina using the link Luca
> provided. I'm running my parallel code using mpirun and everything works
> smoothly.
> > >
> > > I don't recall the details, but I remember having some issues with
> XCode during the installation. I thought it had automatically updated
> correctly, but on closer inspection there was an error message (nothing an
> online search couldn't solve).
> > >
> > > Ester
> > >
> > >
> > > El dimarts, 3 desembre de 2019 11:08:57 UTC-5, luca.heltai va escriure:
> > > I have not updated to the latest version yet. They changed clang,
> xcode, and a few other things. I’m assuming that the package I built on
> catalina is no longer functional.
> > >
> > > I’ll get to it as quickly as I can.
> > >
> > > In the mean time, can you try to see if you can install deal.II using
> spack?
> > >
> > > L.
> > >
> > > > On 2 Dec 2019, at 17:24, Alberto Salvadori 
> wrote:
> > > >
> > > > Dear community,
> > > > Luca in particular
> > > >
> > > > I have installed the package for Mac OS Catalina that was pointed
> out.
> > > > In running the examples I noticed some unexpected errors
> > > >
> > > > Illegal instruction: 4
> > > >
> > > > See below.
> > > >
> > > > Needless to say, the very same error comes out in running my own
> code.
> > > > Any help is appreciated
> > > >
> > > >