Re: [deal.II] Setting an initial condition by fixing the DOF values themselves

2019-04-25 Thread Bruno Blais
Dear Wolfgang, this was easier than I thought.
I followed your suggestion and used VectorTools::interpolate.
Everything works as expected.
Thank you very much

Final solution:

 // initialConditionParameters.uvw is the parsed function
 // newton_update is a local vector

  const FEValuesExtractors::Vector velocities (0);

  const FEValuesExtractors::Scalar pressure (dim);

  const MappingQ  mapping (degreeVelocity_,femParameters.qmapping_all);


  VectorTools::interpolate(mapping,

   dof_handler,

   initialConditionParameters.uvw,

   newton_update,

   fe.component_mask(velocities));


Thanks again!


On Thursday, 25 April 2019 09:32:09 UTC-4, Wolfgang Bangerth wrote:
>
> On 4/25/19 6:58 AM, Bruno Blais wrote: 
> > I would like to be able to set-up an initial condition by fixing the 
> value of 
> > the DOF themselves by using their x,y(,z) position with a ParsedFuction. 
> > 
> > Generally, I set the initial condition by using an L2 projection of the 
> > function (for complex function and higher order element I know this is 
> more 
> > appropriate). 
> > However, for some stuff I would like to be able to fix the value of the 
> DOF 
> > directly. 
> > My issue is, through the doxygen, I have not found a way to loop through 
> the 
> > DOF and to extract their position, even more when I have high order 
> element or 
> > when I have a multiplicity (say velocity-vector + pressure). 
> > 
> > What I would be looking into doing would be something similar to : 
> > 
> > loop over local DOF; 
> >get DOF position 
> >get DOF component (u[0], u[1], u[2], p) 
> >calculate parsed function using the point 
> >set the value of the DOF 
> > end 
> > 
> > Is it something that is possible? This is a weird way of iterating since 
> I 
> > know we always loop over the cells. Maybe there is a way to achieve this 
> by 
> > looping over the cells and then looping over the DOF of the cells? This 
> would 
> > be slightly redundant, but I do not care since I am doing this only 
> once. 
>
> You can get the locations of DoFs using 
> DoFTools::map_dofs_to_support_points(). 
>
> But maybe the easier way is to use 
> VectorTools::interpolate_boundary_values() 
> or project() and just pass it a function object that describes the 
> function 
> you want to set in terms of (x,y,z). This could be your ParsedFunction. 
> interpolate_b_v() will then call your parsed function with a bunch of 
> points 
> that happen to correspond to the DoF locations, but it makes the 
> connection 
> internally and you no longer need to worry about which DoF sits where. 
>
> 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.
For more options, visit https://groups.google.com/d/optout.


Re: [deal.II] Setting an initial condition by fixing the DOF values themselves

2019-04-25 Thread Bruno Blais
Dear Wolfgang,
This was easier than I thought. I followed your suggestion and used 
VectorTools::interpolate
Final solution to set the values of the DOF using a parsed function:

// initialConditionParameters.uvw is my parsed function
// newtonUpdate is my local vector that I use to alter the DOF values


  const FEValuesExtractors::Vector velocities (0);

  const FEValuesExtractors::Scalar pressure (dim);

  const MappingQ  mapping (degreeVelocity_,femParameters.qmapping_all);

  VectorTools::interpolate(mapping, 

   dof_handler,

   initialConditionParameters.uvw,

   newton_update,

   fe.component_mask(velocities));


Thank you very much for the help!

On Thursday, 25 April 2019 09:32:09 UTC-4, Wolfgang Bangerth wrote:
>
> On 4/25/19 6:58 AM, Bruno Blais wrote: 
> > I would like to be able to set-up an initial condition by fixing the 
> value of 
> > the DOF themselves by using their x,y(,z) position with a ParsedFuction. 
> > 
> > Generally, I set the initial condition by using an L2 projection of the 
> > function (for complex function and higher order element I know this is 
> more 
> > appropriate). 
> > However, for some stuff I would like to be able to fix the value of the 
> DOF 
> > directly. 
> > My issue is, through the doxygen, I have not found a way to loop through 
> the 
> > DOF and to extract their position, even more when I have high order 
> element or 
> > when I have a multiplicity (say velocity-vector + pressure). 
> > 
> > What I would be looking into doing would be something similar to : 
> > 
> > loop over local DOF; 
> >get DOF position 
> >get DOF component (u[0], u[1], u[2], p) 
> >calculate parsed function using the point 
> >set the value of the DOF 
> > end 
> > 
> > Is it something that is possible? This is a weird way of iterating since 
> I 
> > know we always loop over the cells. Maybe there is a way to achieve this 
> by 
> > looping over the cells and then looping over the DOF of the cells? This 
> would 
> > be slightly redundant, but I do not care since I am doing this only 
> once. 
>
> You can get the locations of DoFs using 
> DoFTools::map_dofs_to_support_points(). 
>
> But maybe the easier way is to use 
> VectorTools::interpolate_boundary_values() 
> or project() and just pass it a function object that describes the 
> function 
> you want to set in terms of (x,y,z). This could be your ParsedFunction. 
> interpolate_b_v() will then call your parsed function with a bunch of 
> points 
> that happen to correspond to the DoF locations, but it makes the 
> connection 
> internally and you no longer need to worry about which DoF sits where. 
>
> 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.
For more options, visit https://groups.google.com/d/optout.


Re: [deal.II] Setting an initial condition by fixing the DOF values themselves

2019-04-25 Thread Wolfgang Bangerth
On 4/25/19 6:58 AM, Bruno Blais wrote:
> I would like to be able to set-up an initial condition by fixing the value of 
> the DOF themselves by using their x,y(,z) position with a ParsedFuction.
> 
> Generally, I set the initial condition by using an L2 projection of the 
> function (for complex function and higher order element I know this is more 
> appropriate).
> However, for some stuff I would like to be able to fix the value of the DOF 
> directly.
> My issue is, through the doxygen, I have not found a way to loop through the 
> DOF and to extract their position, even more when I have high order element 
> or 
> when I have a multiplicity (say velocity-vector + pressure).
> 
> What I would be looking into doing would be something similar to :
> 
> loop over local DOF;
>    get DOF position
>    get DOF component (u[0], u[1], u[2], p)
>    calculate parsed function using the point
>    set the value of the DOF
> end
> 
> Is it something that is possible? This is a weird way of iterating since I 
> know we always loop over the cells. Maybe there is a way to achieve this by 
> looping over the cells and then looping over the DOF of the cells? This would 
> be slightly redundant, but I do not care since I am doing this only once.

You can get the locations of DoFs using DoFTools::map_dofs_to_support_points().

But maybe the easier way is to use VectorTools::interpolate_boundary_values() 
or project() and just pass it a function object that describes the function 
you want to set in terms of (x,y,z). This could be your ParsedFunction. 
interpolate_b_v() will then call your parsed function with a bunch of points 
that happen to correspond to the DoF locations, but it makes the connection 
internally and you no longer need to worry about which DoF sits where.

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] Setting an initial condition by fixing the DOF values themselves

2019-04-25 Thread Bruno Blais
Hello everyone,
I believe this is a relatively dumb question, but I seem to struggle with 
this basic concept.
I would like to be able to set-up an initial condition by fixing the value 
of the DOF themselves by using their x,y(,z) position with a ParsedFuction.

Generally, I set the initial condition by using an L2 projection of the 
function (for complex function and higher order element I know this is more 
appropriate).
However, for some stuff I would like to be able to fix the value of the DOF 
directly.
My issue is, through the doxygen, I have not found a way to loop through 
the DOF and to extract their position, even more when I have high order 
element or when I have a multiplicity (say velocity-vector + pressure).

What I would be looking into doing would be something similar to :

loop over local DOF;
  get DOF position
  get DOF component (u[0], u[1], u[2], p)
  calculate parsed function using the point
  set the value of the DOF
end

Is it something that is possible? This is a weird way of iterating since I 
know we always loop over the cells. Maybe there is a way to achieve this by 
looping over the cells and then looping over the DOF of the cells? This 
would be slightly redundant, but I do not care since I am doing this only 
once.

Thank you for everything!
Bruno


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