Re: [deal.II] Error in writing and reading cell based data for restart

2018-04-11 Thread Sambit Das
Prof. Bangerth, Thank you for your reply and creating the issue.

>
> I imagine you can work around this is you simply call 
> `register_data_attach()` 
> again before calling `load()`. 
>

I checked that calling  `register_data_attach()`again before calling 
`load()` 
still triggers the same assert, but calling `register_data_attach()` again 
just after 
calling `load()`  and before calling 'notify_ready_to_unpack` works- I 
am able to read and print the correct cell data from the file.

Best,
Sambit

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [deal.II] Error in writing and reading cell based data for restart

2018-04-10 Thread Wolfgang Bangerth



I get the following error:

/An error occurred in line <3236> of file 
 
in function/
/void dealii::parallel::distributed::Triangulationspacedim>::notify_ready_to_unpack(unsigned int, const std::function(const dealii::Triangulation::cell_iterator &, 
dealii::Triangulation::CellStatus, const void *)> &) [with int 
dim = 3, int spacedim = 3]/

/The violated condition was: /
/offset < sizeof(CellStatus)+attached_data_size/
/Additional information: /
/invalid offset in notify_ready_to_unpack()/
/
/
I am wondering if I am missing something in my implementation.


Nothing obvious at least. I copied the issue here:
  https://github.com/dealii/dealii/issues/6223

I don't recall why we reset the size to zero. The intention was probably that 
we don't ever call `load()` in the same execution as we called `save()` 
before. We may be calling `save()` many times, of course, in the course of 
long-running programs, but call `load()` only at the beginning of a restart. 
Consequently, this may simply be a bug that we have just never encountered, or 
there may have been a reason to do it that way -- I can't recall.


I imagine you can work around this is you simply call `register_data_attach()` 
again before calling `load()`.


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.
For more options, visit https://groups.google.com/d/optout.


[deal.II] Error in writing and reading cell based data for restart

2018-04-09 Thread Sambit Das
Hi all,

I have written the following failing minimal example (also attached) where 
I create a single element parallel distributed triangulation and try to 
write and read a double. 

*using namespace dealii;*
*int main (int argc, char *argv[])*
*{*
*  Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv);*

*  const double L=20;*
*  parallel::distributed::Triangulation<3> triangulation(MPI_COMM_WORLD);*
*  GridGenerator::hyper_cube (triangulation, -L, L);*

*  unsigned int offset = triangulation.register_data_attach*
*   (sizeof(double),*
*[&](const typename 
dealii::parallel::distributed::Triangulation<3>::cell_iterator &cell,*
*const typename 
dealii::parallel::distributed::Triangulation<3>::CellStatus status,*
*void * data) -> void*
*{*

*  double* dataStore = reinterpret_cast(data);*
*  *dataStore=0.0;*
*}*
*);*

*  std::cout<< "offset=" << offset << std::endl;*
*  std::string filename="triangulationChk";*
*  triangulation.save(filename.c_str());*

*  triangulation.load(filename.c_str());*
*  triangulation.notify_ready_to_unpack*
*   (offset,[&](const typename 
dealii::parallel::distributed::Triangulation<3>::cell_iterator &cell,*
* const typename 
dealii::parallel::distributed::Triangulation<3>::CellStatus status,*
* const void * data) -> void*
* {*
* }*
*);*
*}*


I get the following error:

*An error occurred in line <3236> of file 

 
in function*
*void dealii::parallel::distributed::Triangulation::notify_ready_to_unpack(unsigned int, const std::function::cell_iterator &, 
dealii::Triangulation::CellStatus, const void *)> &) [with 
int dim = 3, int spacedim = 3]*
*The violated condition was: *
*offset < sizeof(CellStatus)+attached_data_size*
*Additional information: *
*invalid offset in notify_ready_to_unpack()*

I am wondering if I am missing something in my implementation.

Thanks,
Sambit

-- 
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.
For more options, visit https://groups.google.com/d/optout.
//Include all deal.II header file
#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 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
//Include generic C++ headers
#include 
#include 


using namespace dealii;
int main (int argc, char *argv[])
{
  Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv);

  const double L=20;
  parallel::distributed::Triangulation<3> triangulation(MPI_COMM_WORLD);
  GridGenerator::hyper_cube (triangulation, -L, L);

  unsigned int offset = triangulation.register_data_attach
	  (sizeof(double),
		   [&](const typename dealii::parallel::distributed::Triangulation<3>::cell_iterator &cell,
		   const typename dealii::parallel::distributed::Triangulation<3>::CellStatus status,
		   void * data) -> void
		   {

			 double* dataStore = reinterpret_cast(data);
			 *dataStore=0.0;
		   }
		   );

  std::cout<< "offset=" << offset << std::endl;
  std::string filename="triangulationChk";
  triangulation.save(filename.c_str());

  triangulation.load(filename.c_str());
  triangulation.notify_ready_to_unpack
	  (offset,[&](const typename dealii::parallel::distributed::Triangulation<3>::cell_iterator &cell,
	const typename dealii::parallel::distributed::Triangulation<3>::CellStatus status,
	const void * data) -> void
	{
	}
	   );
}