[deal.II] Applying boundary conditions to a point on the boundary in MP framework

2023-04-19 Thread Wasim Niyaz Munshi ce21d400
Hello everyone.
I am trying to apply a particular boundary condition at one single point in 
the domain for a problem very similar to step-40. 
I am using the following code to do it:

for (const auto &cell : dof_handler.active_cell_iterators())
  if (cell->is_locally_owned())

  {
  for (const auto &face : cell->face_iterators())

  for (const auto vertex_number : cell->vertex_indices())
  {
  const auto vert = cell->vertex(vertex_number);
  const Point<2>& node = vert;
  if (std::fabs(node(0)<1e-12) )
  {
const unsigned int dof = cell->vertex_dof_index(vertex_number, 0); 
  constraints.add_line(dof);
  constraints.set_inhomogeneity(dof,1);
  } // This set a scalar at node to value 1

  }

  }

However, I am getting a segmentation fault. Kindly provide some help in 
this regard.

Thanks
Wasim

-- 
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/eea6e885-5e7a-4330-b769-4272a70af626n%40googlegroups.com.


Re: [deal.II] Applying boundary conditions to a point on the boundary in MP framework

2023-04-19 Thread Daniel Arndt
Wasim,

What does the backtrace in your debugger (gdb?) look like?

Best,
Daniel

On Wed, Apr 19, 2023 at 7:27 AM Wasim Niyaz Munshi ce21d400 <
ce21d...@smail.iitm.ac.in> wrote:

> Hello everyone.
> I am trying to apply a particular boundary condition at one single point
> in the domain for a problem very similar to step-40.
> I am using the following code to do it:
>
> for (const auto &cell : dof_handler.active_cell_iterators())
>   if (cell->is_locally_owned())
>
>   {
>   for (const auto &face : cell->face_iterators())
>
>   for (const auto vertex_number : cell->vertex_indices())
>   {
>   const auto vert = cell->vertex(vertex_number);
>   const Point<2>& node = vert;
>   if (std::fabs(node(0)<1e-12) )
>   {
> const unsigned int dof = cell->vertex_dof_index(vertex_number, 0);
>   constraints.add_line(dof);
>   constraints.set_inhomogeneity(dof,1);
>   } // This set a scalar at node to value 1
>
>   }
>
>   }
>
> However, I am getting a segmentation fault. Kindly provide some help in
> this regard.
>
> Thanks
> Wasim
>
> --
> 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/eea6e885-5e7a-4330-b769-4272a70af626n%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/CAOYDWbJQ6CxsB7aPQJvLLTfrX3%3DOo%3DB7QMDjbhLX%3DrZeELC3BA%40mail.gmail.com.


[deal.II] Why does putting the "TimerOuput" before the "ConditionalOStream" leads to a seg fault?

2023-04-19 Thread Abbas B.
I attached a simple .cc file that illustrates the tittle. 
Switching lines 18 and 19 leads to a segmentation fault and I would like to 
know why out of curiosity. 
Would appreciate it. 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/86dd356e-58a4-4e61-96e0-e9a0ecfd7236n%40googlegroups.com.


#include 
using namespace dealii;

template 
class LaplaceProblem
{
public:
LaplaceProblem();

void run();

private:
void setup_system();

MPI_Comm mpi_communicator;
TimerOutput computing_timer;
ConditionalOStream pcout;

};

template 
LaplaceProblem::LaplaceProblem()
: mpi_communicator(MPI_COMM_WORLD), pcout(std::cout,
  (Utilities::MPI::this_mpi_process(mpi_communicator) == 0)),
  computing_timer(mpi_communicator,
  pcout,
  TimerOutput::never,
  TimerOutput::wall_times)
{
}

template 
void LaplaceProblem::setup_system()
{
TimerOutput::Scope t(computing_timer, "setup");
}
template 
void LaplaceProblem::run()
{
setup_system();
computing_timer.print_summary();
computing_timer.reset();
}

int main(int argc, char *argv[])
{

Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
LaplaceProblem<2> laplace_problem_2d;
laplace_problem_2d.run();
}




Re: [deal.II] Why does putting the "TimerOuput" before the "ConditionalOStream" leads to a seg fault?

2023-04-19 Thread Wolfgang Bangerth

On 4/19/23 08:33, Abbas B. wrote:

**

I attached a simple .cc file that illustrates the tittle.
Switching lines 18 and 19 leads to a segmentation fault and I would like to 
know why out of curiosity.


Abbas:
This is a C++ question. Member variables are initialized in the order in which 
they are declared. If the initialization of one variable depends on another, 
you need to make sure that they are initialized in the correct order, by 
declaring them in the correct order.


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/074728b6-ad8d-dfa2-673e-4bc39a0df47b%40colostate.edu.


Re: [deal.II] Why does putting the "TimerOuput" before the "ConditionalOStream" leads to a seg fault?

2023-04-19 Thread Abbas
Goes without saying thanks Prof 

On Wednesday, April 19, 2023 at 4:50:03 PM UTC+2 Wolfgang Bangerth wrote:

> On 4/19/23 08:33, Abbas B. wrote:
> > **
> > 
> > I attached a simple .cc file that illustrates the tittle.
> > Switching lines 18 and 19 leads to a segmentation fault and I would like 
> to 
> > know why out of curiosity.
>
> Abbas:
> This is a C++ question. Member variables are initialized in the order in 
> which 
> they are declared. If the initialization of one variable depends on 
> another, 
> you need to make sure that they are initialized in the correct order, by 
> declaring them in the correct order.
>
> Best
> W.
>
> -- 
> 
> Wolfgang Bangerth email: bang...@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/17470a0d-c4e6-4f8c-a533-d7c8e00103c4n%40googlegroups.com.


Re: [deal.II] Applying boundary conditions to a point on the boundary in MP framework

2023-04-19 Thread Wasim Niyaz Munshi ce21d400
I am running the program in debug mode and this is the error message that I 
get:
Running with PETSc on 1 MPI rank(s)...
Cycle 0:


An error occurred in line <324> of file 

 
in function
static void 
dealii::internal::DoFAccessorImplementation::Implementation::process_dof_index(const
 
dealii::DoFHandler&, unsigned int, unsigned int, unsigned 
int, unsigned int, const std::integral_constant&, 
GlobalIndexType&, const DoFPProcessor&) [with int dim = 2; int spacedim = 
2; int structdim = 0; GlobalIndexType = unsigned int; DoFPProcessor = 
dealii::internal::DoFAccessorImplementation::Implementation::get_dof_index<2, 
2, 0>::]
The violated condition was: 
::dealii::deal_II_exceptions::internals::compare_less_than(obj_level, 
dof_handler.object_dof_indices.size())
Additional information: 
Index 0 is not in the half-open range [0,0). In the current case, this
half-open range is in fact empty, suggesting that you are accessing an
element of an empty collection such as a vector that has not been set
to the correct size.

Stacktrace:
---
#0  ./step-40: void 
dealii::internal::DoFAccessorImplementation::Implementation::process_dof_index<2,
 
2, 0, unsigned int, 
dealii::internal::DoFAccessorImplementation::Implementation::get_dof_index<2, 
2, 0>(dealii::DoFHandler<2, 2> const&, unsigned int, unsigned int, unsigned 
int, unsigned int, std::integral_constant const&)::{lambda(auto:1 
const&, auto:2&)#1}>(dealii::DoFHandler<2, 2> const&, unsigned int, 
unsigned int, unsigned int, unsigned int, std::integral_constant 
const&, unsigned int&, 
dealii::internal::DoFAccessorImplementation::Implementation::get_dof_index<2, 
2, 0>(dealii::DoFHandler<2, 2> const&, unsigned int, unsigned int, unsigned 
int, unsigned int, std::integral_constant const&)::{lambda(auto:1 
const&, auto:2&)#1} const&)
#1  ./step-40: unsigned int 
dealii::internal::DoFAccessorImplementation::Implementation::get_dof_index<2, 
2, 0>(dealii::DoFHandler<2, 2> const&, unsigned int, unsigned int, unsigned 
int, unsigned int, std::integral_constant const&)
#2  ./step-40: dealii::DoFAccessor<2, 2, 2, 
false>::vertex_dof_index(unsigned int, unsigned int, unsigned int) const
#3  ./step-40: Step40::LaplaceProblem<2>::setup_boundary_values()
#4  ./step-40: Step40::LaplaceProblem<2>::run()
#5  ./step-40: main


[wasim-OptiPlex-5080:42036] *** Process received signal ***
[wasim-OptiPlex-5080:42036] Signal: Aborted (6)
[wasim-OptiPlex-5080:42036] Signal code:  (-6)
[wasim-OptiPlex-5080:42036] [ 0] 
/lib/x86_64-linux-gnu/libpthread.so.0(+0x14420)[0x7fc3980c6420]
[wasim-OptiPlex-5080:42036] [ 1] 
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xcb)[0x7fc397f0100b]
[wasim-OptiPlex-5080:42036] [ 2] 
/lib/x86_64-linux-gnu/libc.so.6(abort+0x12b)[0x7fc397ee0859]
[wasim-OptiPlex-5080:42036] [ 3] 
/home/wasim/dealii-candi/deal.II-v9.4.0/lib/libdeal_II.g.so.9.4.0(_ZN6dealii18deal_II_exceptions9internals22do_issue_error_nothrowERKNS_13ExceptionBaseE+0x0)[0x7fc3af7bb9f9]
[wasim-OptiPlex-5080:42036] [ 4] 
./step-40(_ZN6dealii18deal_II_exceptions9internals20issue_error_noreturnINS_18StandardExceptions17ExcIndexRangeTypeImvNS1_17ExceptionHandlingEPKciS8_S8_S8_T_+0x8c)[0x5602ad51a53d]
[wasim-OptiPlex-5080:42036] [ 5] 
./step-40(_ZN6dealii8internal25DoFAccessorImplementation14Implementation17process_dof_indexILi2ELi2ELi0EjZNS2_13get_dof_indexILi2ELi2ELi0EEEjRKNS_10DoFHandlerIXT_EXT0_EEERKSt17integral_constantIiXT1_EEEUlRKT_RT0_E_EEvS8_SC_RT2_RKT3_+0x31f)[0x5602ad52ce3e]
[wasim-OptiPlex-5080:42036] [ 6] 
./step-40(_ZN6dealii8internal25DoFAccessorImplementation14Implementation13get_dof_indexILi2ELi2ELi0EEEjRKNS_10DoFHandlerIXT_EXT0_EEERKSt17integral_constantIiXT1_EE+0x57)[0x5602ad528a2e]
[wasim-OptiPlex-5080:42036] [ 7] 
./step-40(_ZNK6dealii11DoFAccessorILi2ELi2ELi2ELb0EE16vertex_dof_indexEjjj+0xa6)[0x5602ad523a8e]
[wasim-OptiPlex-5080:42036] [ 8] 
./step-40(_ZN6Step4014LaplaceProblemILi2EE21setup_boundary_valuesEv+0x40c)[0x5602ad51f1f4]
[wasim-OptiPlex-5080:42036] [ 9] 
./step-40(_ZN6Step4014LaplaceProblemILi2EE3runEv+0x182)[0x5602ad51c61a]
[wasim-OptiPlex-5080:42036] [10] ./step-40(main+0x7a)[0x5602ad50a2dd]
[wasim-OptiPlex-5080:42036] [11] 
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0x7fc397ee2083]
[wasim-OptiPlex-5080:42036] [12] ./step-40(_start+0x2e)[0x5602ad50a16e]
[wasim-OptiPlex-5080:42036] *** End of error message ***
make[3]: *** [CMakeFiles/run.dir/build.make:71: CMakeFiles/run] Aborted 
(core dumped)
make[2]: *** [CMakeFiles/Makefile2:116: CMakeFiles/run.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:123: 

I hope this is what you were asking for. 
Regards
Wasim

On Wednesday, April 19, 2023 at 6:29:56 PM UTC+5:30 d.arnd...@gmail.com 
wrote:

> Wasim,
>
> What does the backtrace in your debugger (gdb?) look like?
>
> Best,
> Daniel
>
> On Wed, Apr 19, 2023 at 7:27 AM Wasim Niyaz Munshi ce21d400 <
> ce21