Re: [deal.II] How to get the coordinates of a given degree of freedom on an edge?

2019-02-22 Thread Phạm Ngọc Kiên
Yes.
Thank you very much.
I have just started coding with C++ in several month and this is really
helpful for me.
Best,
Kien

Vào Th 6, 22 thg 2, 2019 vào lúc 21:15 Jean-Paul Pelteret <
jppelte...@gmail.com> đã viết:

> Dear Kien,
>
> The problem that you’re facing (in the example that you gave us) is not
> one to do with deal.II itself, but rather C++ and how you’ve structured
> your code. When I build your code in debug mode, I see this warning:
>
> $ make
> Scanning dependencies of target problem
> [ 50%] Building CXX object CMakeFiles/problem.dir/problem.cc.o
> /problem.cc:112:31: warning: field 'order' is uninitialized when
> used here [-Wuninitialized]
>  fe(FE_NedelecSZ(order), 1,   //(order), multiplicity
>
> and when I run it, it actually hangs on my machine. What’s happening here
> relates to where you have this line:
>
> const unsigned int order = 3;
>
> It is in the body of the EM class, but most critically its below the
> declarations for
>
> DoFHandler dof_handler;
> FESystem fe;
>
> This means that the “order” variable is initialised AFTER the
> “dof_handler", and “fe”, and so during the call to the constructor it
> uninitialised when used to initialise the “dof_handler” and “fe”. So why
> this hangs on my machine is likely because “order” is random number, and
> more specifically something very large when I tested it. Its luck that it
> the section of memory assigned to this variable was either all zeros (with
> the interpretation of the uninitialised “order” variable being equal to
> zero, which corresponds to the lowest order Nedelec element that is
> permitted) or with some random bits that were interpreted as a small number.
>
> The quick fix to the issue is to move the definition of “order” above that
> of “dof_handler”. Then the warning goes away and everything works as
> expected. If I change the constructor definition slightly to
>
> template
> EM::EM()
> :dof_handler(triangulation),
>  fe(FE_NedelecSZ(order), 1,   //(order), multiplicity
> FE_NedelecSZ(order), 1)
> {
>   std::cout << "order: " << order << "  fe.dofs_per_cell: " <<
> fe.dofs_per_cell << std::endl;
> }
>
> then I get the following output for two different orders.:
> order: 2  fe.dofs_per_cell: 288
> order: 3  fe.dofs_per_cell: 600
>
> A better fix might be to pass the order into the constructor, or to use a
> parameter handler to choose the order at run-time.
>
> I hope that this helps you understand where things were going wrong.
>
> Best,
> Jean-Paul
>
> On 22 Feb 2019, at 02:37, Phạm Ngọc Kiên 
> wrote:
>
> Hi,
> The attachment is my small program that I created.
> My fe system have 24 dofs for both real and imaginary of 12 edges of a
> cell.
> No matter how I change the parameter "order" the number of dofs is
> unchanged.
> I think I have problem when constructing the object.
> I would like to thank you very much.
>  Best,
> Kien
>
> Vào Th 5, 21 thg 2, 2019 vào lúc 23:38 Wolfgang Bangerth <
> bange...@colostate.edu> đã viết:
>
>> On 2/20/19 7:01 PM, Phạm Ngọc Kiên wrote:
>> > I tested in my codes using
>> >
>> > template
>> > CSEM::CSEM()
>> >  ://mapping(1),
>> > dof_handler(triangulation),
>> >  fe(FE_NedelecSZ(order),1,//(order), multiplicity
>> > FE_NedelecSZ(order),1) {}
>> >
>> > When I changed the parameter order, I saw only the number of dofs was
>> only of lowest order dofs no matter how big the order was
>> >
>> > I think that there should be a way to get higher order dofs, but I
>> cannot find it now.
>>
>> Can you create a small program that demonstrates this issue?
>>
>> 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.
>>
>
> --
> 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.
> 
>
>
> --
> 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 

Re: [deal.II] How to get the coordinates of a given degree of freedom on an edge?

2019-02-22 Thread Jean-Paul Pelteret
Dear Kien,

The problem that you’re facing (in the example that you gave us) is not one to 
do with deal.II itself, but rather C++ and how you’ve structured your code. 
When I build your code in debug mode, I see this warning:

$ make
Scanning dependencies of target problem
[ 50%] Building CXX object CMakeFiles/problem.dir/problem.cc.o
/problem.cc:112:31: warning: field 'order' is uninitialized when used 
here [-Wuninitialized]
 fe(FE_NedelecSZ(order), 1,   //(order), multiplicity

and when I run it, it actually hangs on my machine. What’s happening here 
relates to where you have this line:

const unsigned int order = 3;

It is in the body of the EM class, but most critically its below the 
declarations for

DoFHandler dof_handler;
FESystem fe;

This means that the “order” variable is initialised AFTER the “dof_handler", 
and “fe”, and so during the call to the constructor it uninitialised when used 
to initialise the “dof_handler” and “fe”. So why this hangs on my machine is 
likely because “order” is random number, and more specifically something very 
large when I tested it. Its luck that it the section of memory assigned to this 
variable was either all zeros (with the interpretation of the uninitialised 
“order” variable being equal to zero, which corresponds to the lowest order 
Nedelec element that is permitted) or with some random bits that were 
interpreted as a small number.

The quick fix to the issue is to move the definition of “order” above that of 
“dof_handler”. Then the warning goes away and everything works as expected. If 
I change the constructor definition slightly to

template
EM::EM()
:dof_handler(triangulation),
 fe(FE_NedelecSZ(order), 1,   //(order), multiplicity
FE_NedelecSZ(order), 1) 
{
  std::cout << "order: " << order << "  fe.dofs_per_cell: " << fe.dofs_per_cell 
<< std::endl;
}

then I get the following output for two different orders.:
order: 2  fe.dofs_per_cell: 288
order: 3  fe.dofs_per_cell: 600

A better fix might be to pass the order into the constructor, or to use a 
parameter handler to choose the order at run-time.

I hope that this helps you understand where things were going wrong.

Best,
Jean-Paul

> On 22 Feb 2019, at 02:37, Phạm Ngọc Kiên  wrote:
> 
> Hi,
> The attachment is my small program that I created.
> My fe system have 24 dofs for both real and imaginary of 12 edges of a cell.
> No matter how I change the parameter "order" the number of dofs is unchanged.
> I think I have problem when constructing the object.
> I would like to thank you very much.
>  Best,
> Kien
> 
> Vào Th 5, 21 thg 2, 2019 vào lúc 23:38 Wolfgang Bangerth 
> mailto:bange...@colostate.edu>> đã viết:
> On 2/20/19 7:01 PM, Phạm Ngọc Kiên wrote:
> > I tested in my codes using
> > 
> > template
> > CSEM::CSEM()
> >  ://mapping(1),
> > dof_handler(triangulation),
> >  fe(FE_NedelecSZ(order),1,//(order), multiplicity
> > FE_NedelecSZ(order),1) {}
> > 
> > When I changed the parameter order, I saw only the number of dofs was only 
> > of lowest order dofs no matter how big the order was
> > 
> > I think that there should be a way to get higher order dofs, but I cannot 
> > find it now.
> 
> Can you create a small program that demonstrates this issue?
> 
> 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 
> .
> 
> -- 
> 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 
> .
> 

-- 
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 

[deal.II] How to get the coordinates of a given degree of freedom on an edge?

2019-02-17 Thread Phạm Ngọc Kiên
Dear colleagues,
I am working with FE_Nedelec_SZ element (edge-based finite element) in 
Deal.II (version 9.0.0).
For my current problem, I need to get the global coordinates of a given 
degree of freedom on and edge. 
Do we have any code for this task?

I have also thought of using material_id for an edge as an alternative way 
to address my problem. However, I personally think that the material_id can 
be used only with a cell.

I would like to thank you very much in advance.

Pham Ngoc Kien
Ph.D. student
Seoul National University

-- 
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.