Mapped inlet when there are another inlet faces

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Tsubasa
Posts: 175
Joined: Fri Nov 20, 2020 4:09 am

Mapped inlet when there are another inlet faces

Post by Tsubasa »

Hello,

I have a question about the mapped inlet.
I have never used the mapped inlet, I know some people used it to make a pseudo-periodic boundary condition.

You can see a picture I want to calculate. (Geometry is simplified very much now to show you clearly.)
a.png
As you can see, there is a space (white space) inside the computational domain (gray space).
Although it is a little bit strange, I have to impose an inlet condition with negative velocity (to simulate a suction).
What I want to do is to extract variables at inlet2 and then impose these variables at outlet2.
(Actually in my case. the "inlet" condition in GUI is also imposed on outlet2.)

By the option "mapped inlet"m is it possible to do this?

Sorry it might not be clear for you. Let me know if you need more explanation.

Best regards,
Hamada
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Mapped inlet when there are another inlet faces

Post by Yvan Fournier »

Hello,

This might work, but in its current form, mapped inlet takes values at cells and maps them to inlet/outlet faces, so instead of mapping exactly to inlet 2, you would need to map to the cells adjacent to inlet 2 (true face -> face mapping is requested by some users, but has not been adapted yet).

Best regards,

Yvan
Tsubasa
Posts: 175
Joined: Fri Nov 20, 2020 4:09 am

Re: Mapped inlet when there are another inlet faces

Post by Tsubasa »

Hello Yvan,

Let me check again.
Untitled.png
In the picture above, at the inlet3 surface, I give negative velocity (like a suction). Then I want this value to be extracted and reused at surface4. So now at the surface4, I hope the flow velocity should be 0.5m/s moving from left to right direction.

For this, in GUI, I have to select the option "mapped inlet" in "inlet3" boundary condition setting? or I have to select "mapped inlet" in surface4 boundary setting?
I am confused with "the translation vector".
Now the distance between inlet3 and surface4 is 0.2m, so I have to give 0.2 translation vector in the setting for surface4?
For example, in surface4 boundary setting, when I give -0.2 for X, from which cells does surface4 get flow condition?



Best regards,
Hamada
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Mapped inlet when there are another inlet faces

Post by Yvan Fournier »

Hello,

You need to define "mapped inlet" for surface 4, and choose an associate translation vector going from surface 4 to the cell layer just upstream of surface 3. Do not hesitate to experiment with the code in case of doubt.

Best regards,

Yvan
Tsubasa
Posts: 175
Joined: Fri Nov 20, 2020 4:09 am

Re: Mapped inlet when there are another inlet faces

Post by Tsubasa »

Hello Yvan,

So now as a test,
I give 1m/s for inlet1 in the picture posted in the previous post, -1m/s for inlet2, -1m/s for inlet3.

Then for surface4, I give the mapped inlet with -0.21m for X.
Just one question, even though I choose "mapped inlet", I have to give some velocity value in GUI like in this picture
b.png
but this given velocity is not used in simulation except for 1st iteration? In GUI, surface4 is named outlet2.
Now this is the result with my setting.
c.png
This is not what I want. So what did I make a mistake?

Best regards,
Hamada
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Mapped inlet when there are another inlet faces

Post by Yvan Fournier »

Hello,

Sorry, I had not used mapped inlet in a while, and forgot this aspect.

By default, since mapped inlet is mostly used to simulate periodicity, the velocity needs to be prescribed, and mapped inlet rescales the profile obtained at "inlet+x" to prescribe it at the inlet.

In your case, you probably do not want the rescaling.

I think you can still use mapped inlet, but need to use the Fortran or C API un user-defined functions to have finer control.
in this case, you need to set the "enforce_balance" option to cs_boundary_conditions_mapped_set (in C) or "normalize" argument to boundary_conditions_mapped_set (in Fortran) to 0, to avoid the rescaling. If you start from the Fortran user example, just set "normalize" to 0 for all variables.

At the first iteration, the boundary condition will use the prescribed value, but adter that, it should use the mapped values.

Hoping this works.

Best regards,

Yvan
Tsubasa
Posts: 175
Joined: Fri Nov 20, 2020 4:09 am

Re: Mapped inlet when there are another inlet faces

Post by Tsubasa »

Hello,

As you said, I do not need rescaling.
In my case, I need "mapped inlet" for only velocity and scalar transport.

For user_subroutine, actually, I rarely used both c and Fortran, so I did not understand well when I read "cs_user_boundary_conditions-mapped_inlet.f90".
cs_user_boundary_conditions-mapped_inlet.f90
(9.97 KiB) Downloaded 54 times
I have to start from the biggining of Fortran.
Would you help me? Sorry for bothering you.

Best regards,
Hamada
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Mapped inlet when there are another inlet faces

Post by Yvan Fournier »

Hello,

If you take the Fortran example, you only need to change the selection criteria, and remove the test around "normalize" (plus adjust the translation vector).

so Search for these in the source, adjust them, and it should be enough.

Based on how this works, we can iterate again.

Best regards,

Yvan
Tsubasa
Posts: 175
Joined: Fri Nov 20, 2020 4:09 am

Re: Mapped inlet when there are another inlet faces

Post by Tsubasa »

Hello Yvan,

What do you mean by "remove the test around "normalize""?

Selection criteria is the following, right?

Code: Select all

call getfbr('INLET', nlfac, lstfac)
Now name of the face I want to impose mapped inlet is "mapped_inlet_duct" .
I know this code is not correct because I dont understand.
Would teach me what I have to do next?

The error message shows

Code: Select all

Field keyword with id -1 is not defined.

Code: Select all

call getfbr('mapped_inlet_duct', nlfac, lstfac)

if (ntcabs == ntpabs+1) then
  allocate(lstcel(ncel))
  do iel = 1, ncel
    lstcel(iel) = iel
  enddo
  coord_shift(1,1) = -0.01
  coord_shift(2,1) = 0.d0
  coord_shift(3,1) = 0.d0
  inlet_l = boundary_conditions_map(mesh_location_cells, ncel,                &
                                    nlfac, lstcel, lstfac,                    &
                                    coord_shift, 0,                           &
                                    0.01d0)
  deallocate(lstcel)
endif

  call field_get_n_fields(n_fields)
  call field_get_key_id("velocity", keyvar)
  call field_get_key_id("scalar1", keysca)

  interpolate = 0

 do f_id = 0, n_fields-1
    call field_get_key_int(f_id, keyvar, ivar)
    call field_get_key_int(f_id, keysca, iscal)
    normalize = 0
    call boundary_conditions_mapped_set(f_id, inlet_l, MESH_LOCATION_CELLS, &
                                        normalize, interpolate,             &
                                        nlfac, lstfac, rvoid,               &
                                        nvar, rcodcl)
  enddo/code]
  
  Best regards,
  Tsubasa
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Mapped inlet when there are another inlet faces

Post by Yvan Fournier »

Hello,

ivar and iscal are not used in your last loop. So simply try removing the matching call field_get_key_int calls.

Regards,

Yvan
Post Reply