Re: [deal.II] Using interpolate_boundary_conditions

2019-10-01 Thread Amy Kaczmarowski
Perfect!  Thank you this was exactly what I was missing.

Amy


On Tuesday, October 1, 2019 at 3:18:20 PM UTC-6, Wolfgang Bangerth wrote:
>
>
> Amy, 
>
> > template  
> > class BoundaryValuesU : public Function{ 
> >public: 
>
> You are correct: You need to tell the base class how many vector 
> components 
> your function has. You should be able to do this by adding a constructor: 
>
>BoundaryValuesU () 
>  :  Function (dim)// your function has 'dim' components 
>{} 
>
>
> >  virtual void vector_value(const Point & p, Vector 
> ) 
> > const override 
> >{ 
> >  double xpos, ypos, zpos; 
> >  xpos = p[0]; 
> >  ypos = p[1]; 
> >  if (dim==3){zpos=p[2];} 
> >  else {zpos=0.0;} 
> >  values[0] 
> > 
> = 
> xpos/std::pow(std::pow(xpos,2.0)+std::pow(ypos,2.0)+std::pow(zpos,2.0),0.5)*0.1;
>  
>
> >  values[1] 
> > 
> = 
> ypos/std::pow(std::pow(xpos,2.0)+std::pow(ypos,2.0)+std::pow(zpos,2.0),0.5)*0.1;
>  
>
> >  values[2] 
> > 
> = 
> zpos/std::pow(std::pow(xpos,2.0)+std::pow(ypos,2.0)+std::pow(zpos,2.0),0.5)*0.1;
>  
>
> >  return; 
> >  } 
>
> You can write this much simpler using the fact that Point objects are 
> really 
> just vectors: 
>
>virtual void vector_value (...) const override 
>{ 
>   Tensor<1,dim> displacement = 0.1 * p / p.norm(); 
>   for (unsigned int d=0; d values[d] = displacement[d]; 
>} 
>
> 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/5f944f14-4136-4352-8eeb-1adfa6580a17%40googlegroups.com.


Re: [deal.II] Using interpolate_boundary_conditions

2019-10-01 Thread Wolfgang Bangerth


Amy,

> template 
> class BoundaryValuesU : public Function{
>    public:

You are correct: You need to tell the base class how many vector components 
your function has. You should be able to do this by adding a constructor:

   BoundaryValuesU ()
 :  Function (dim)// your function has 'dim' components
   {}


>      virtual void vector_value(const Point & p, Vector ) 
> const override
>        {
>          double xpos, ypos, zpos;
>          xpos = p[0];
>          ypos = p[1];
>          if (dim==3){zpos=p[2];}
>          else {zpos=0.0;}
>          values[0] 
> = 
> xpos/std::pow(std::pow(xpos,2.0)+std::pow(ypos,2.0)+std::pow(zpos,2.0),0.5)*0.1;
>          values[1] 
> = 
> ypos/std::pow(std::pow(xpos,2.0)+std::pow(ypos,2.0)+std::pow(zpos,2.0),0.5)*0.1;
>          values[2] 
> = 
> zpos/std::pow(std::pow(xpos,2.0)+std::pow(ypos,2.0)+std::pow(zpos,2.0),0.5)*0.1;
>          return;
>      }

You can write this much simpler using the fact that Point objects are really 
just vectors:

   virtual void vector_value (...) const override
   {
  Tensor<1,dim> displacement = 0.1 * p / p.norm();
  for (unsigned int d=0; dhttp://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/565659fd-e056-cacd-d167-0a11334d4c5a%40colostate.edu.