Hi. I have a question on how we can impose external force term, or right 
hand side, in Stokes flow. 

My governing equation is same with that of step-22, stokes flow 

-nabla^2 u + grad p = f 

-grad u = 0 

but I want to impose 'f', 

To do this, I made function that gives me f value on each point. 
For example, if I want function of f thats looks like f=(x^2,y^2); 
I would make function like this...

  template <int dim>

  class RightHandSide : public Function<dim>

  {

    public:

      RightHandSide () : Function<dim>(dim+1) {}


      virtual void vector_value (const Point<dim> &p,

Vector<double>   &value) const;


  };


  template <int dim>

  void

  RightHandSide<dim>::vector_value (const Point<dim> &p,

    Vector<double>   &values) const

  {

    values(0) =  pow(p[0],2);

    values(1) =  pow(p[1],2);

    values(2) =  0.0;

  }

After that I may consider this 'f' term when I assemble system. 
but I don't see a way to how I should try modify following read lines of 
the code from step-22 

  for (; cell!=endc; ++cell)

      {

fe_values.reinit (cell);

local_matrix = 0;

local_rhs = 0;


right_hand_side.vector_value_list(fe_values.get_quadrature_points(),

  rhs_values);


for (unsigned int q=0; q<n_q_points; ++q)

  {

    for (unsigned int k=0; k<dofs_per_cell; ++k)

      {

phi_grads_u[k] = fe_values[velocities].symmetric_gradient (k, q);

div_phi_u[k]   = fe_values[velocities].divergence (k, q);

phi_p[k]       = fe_values[pressure].value (k, q);

      }


    for (unsigned int i=0; i<dofs_per_cell; ++i)

      {

for (unsigned int j=0; j<=i; ++j)

  {

    local_matrix(i,j) += (phi_grads_u[i] * phi_grads_u[j]

  - div_phi_u[i] * phi_p[j]

  - phi_p[i] * div_phi_u[j]

  + phi_p[i] * phi_p[j])

* fe_values.JxW(q);


  }


*const unsigned int component_i =*

*   fe.system_to_component_index(i).first;*

* local_rhs(i) += fe_values.shape_value(i,q) **

* rhs_values[q](component_i) **

* fe_values.JxW(q);*

      }

  }



My 'f' is not '0' any more but it has multiple components. 
in fact, the weak form of the governing equation '-nabla^2 u + grad p = f ' 
also should have two components,..(x and y) ....

How can I achieve this....?


Thank you 


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

Reply via email to