Thanks very much, Jean-Paul,
during the time i was waiting for the answer, i kind of figured out a way
similar to the first one,
now since you have also proposed a more elegant way, i will look into it
also. Thanks,
best,
lailai
On Wednesday, January 16, 2019 at 12:08:18 PM UTC-5, Jean-Paul Pelteret
wrote:
>
> Dear Laila,
>
> I have two suggestions that may help you here:
>
> 1/ You could add the boundary ID as an argument to
> the PoiseuilleBoundaryValues class:
>
> template <int dim>
> class PoiseuilleBoundaryValues : public Function<dim>
> {
> public:
> PoiseuilleBoundaryValues (const typename types::boundary_id b_id)
> : Function<dim>(dim+1),
> b_id (b_id)
> {}
>
> …
>
> private:
> const typename types::boundary_id b_id;
> };
>
> If you do so then you could return a different value based on the boundary
> ID for which the specific instance of this class.
>
> template <int dim>
> double
> PoiseuilleBoundaryValues<dim>::value (const Point<dim> &p,
> const unsigned int component) const
> {
> Assert (component < this->n_components,
> ExcIndexRange (component, 0, this->n_components));
>
> double umax = 1.5;
>
> if (component == 0)
> {
> if (b_id == 1)
> return
> umax*(1-pow(2*p[1]/(UserGeometry::y_bottom-UserGeometry::y_top),2));
> else if (b_id == 2)
> return … etc…
> }
>
> return 0;
> }
>
> You could then make a loop over all relevant Dirichlet boundaries and
> create a specialised instance of this class and pass it to the deal.II
> function that interpolates the boundary values.
>
> for (auto b_id : {list_of_dirichlet_boundary_ids})
> VectorTools::interpolate_boundary_values (dof_handler, b_id,
> PoiseuilleBoundaryValues<dim>(b_id),…);
>
> 2/ The above is, in my opinion, not particularly elegant. The second (and
> maybe more concise and robust) option would be to use the FunctionParser
> <https://dealii.org/developer/doxygen/deal.II/classFunctionParser.html>
> class,
> which seems to be able to do everything that you are doing in
> this PoiseuilleBoundaryValues class and more. You could even write the
> evaluated expressions for each boundary within an instance of a
> ParameterHandler, so they need not be hard-coded.
>
> I hope that this helps you.
>
> Best,
> Jean-Paul
>
> On 16 Jan 2019, at 06:29, Lailai Zhu <[email protected] <javascript:>>
> wrote:
>
> hi, Dear Deal.II users,
>
> I am using deal.II to solve for a simple flow with multiple inlets
> where I need to impose Pouseuille BC (dirichlet) with different
> magnitudes.
> I used to use the following piece of code together with
> VectorTools::interpolate_boundary_values
> to work for one BC. This is rather hard-coded, where I know the maximum
> velocity of this the BC, the locations of the BC, which is ok for only one.
>
> Now the issue arises if i have around 10 inlets to impose, these inlets
> can in general have different positions, velocity magnitudes and channel
> widths. I can also duplicate the following codes 10 times and customize
> each corresponding to each inlet. However, this does not sound so elegant,
> may I ask whether there might be some smarter way to achieve this?
>
> Thanks in advance,
>
> best,
>
> lailai
>
>
> template <int dim>
> class PoiseuilleBoundaryValues : public Function<dim>
> {
> public:
> PoiseuilleBoundaryValues () : Function<dim>(dim+1) {}
>
> virtual double value (const Point<dim> &p,
> const unsigned int component = 0) const;
>
> virtual void vector_value (const Point<dim> &p,
> Vector<double> &value) const;
> };
>
>
> template <int dim>
> double
> PoiseuilleBoundaryValues<dim>::value (const Point<dim> &p,
> const unsigned int component) const
> {
> Assert (component < this->n_components,
> ExcIndexRange (component, 0, this->n_components));
>
> double umax = 1.5;
>
> if (component == 0)
> return
> umax*(1-pow(2*p[1]/(UserGeometry::y_bottom-UserGeometry::y_top),2));
>
> return 0;
> }
>
>
> template <int dim>
> void
> PoiseuilleBoundaryValues<dim>::vector_value (const Point<dim> &p,
> Vector<double> &values) const
> {
> for (unsigned int c=0; c<this->n_components; ++c)
> values(c) = PoiseuilleBoundaryValues<dim>::value (p, c);
> }
>
> --
> 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 [email protected] <javascript:>.
> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.