BC using dw_surface_flux not being met?

32 views
Skip to first unread message

David Jessop

unread,
Jan 4, 2017, 4:28:46 AM1/4/17
to sfepy-devel
Hi,

I need to set insulated boundaries on two edges of my problem, and set the flux on a third.  I've specified material properties (2D problem) as
ins = Material('ins', val=[[0.0, 0.0], [0.0, 0.0]])
flux
= Material('flux', val=[[-1.0, 0.0], [0.0, -1.0]])

and then I write my BCs as
tSurfInsT = Term.new('dw_surface_flux(ins.val, u, v)', integral, Top, ins=ins, u=u, v=v)
tSurfInsL
= Term.new('dw_surface_flux(ins.val, u, v)', integral, Left, ins=ins, u=u, v=v)
tSurfFluxR
= Term.new('dw_surface_flux(flux.val, u, v)', integral, Right, flux=flux, u=u, v=v)

As you might infer from the visualisation of the solution below, thes BCs are not being met (slope of the contours should be flat on the LHS and not flat on the right).  Indeed, if I comment these out of the equation definition, the solution remains unchanged.  What is going on?

Thanks,
David

Robert Cimrman

unread,
Jan 4, 2017, 5:13:05 AM1/4/17
to sfepy...@googlegroups.com
Hi David,

On 01/04/2017 10:28 AM, David Jessop wrote:
> Hi,
>
> I need to set insulated boundaries on two edges of my problem, and set the
> flux on a third. I've specified material properties (2D problem) as
> ins = Material('ins', val=[[0.0, 0.0], [0.0, 0.0]])
> flux = Material('flux', val=[[-1.0, 0.0], [0.0, -1.0]])
>
> and then I write my BCs as
> tSurfInsT = Term.new('dw_surface_flux(ins.val, u, v)', integral, Top, ins=
> ins, u=u, v=v)
> tSurfInsL = Term.new('dw_surface_flux(ins.val, u, v)', integral, Left, ins=
> ins, u=u, v=v)

The "insulated" boundary condition is equavalent to omitting the above two
terms (ins.val is zero). Does that work?

> tSurfFluxR = Term.new('dw_surface_flux(flux.val, u, v)', integral, Right,
> flux=flux, u=u, v=v)

On the other hand omitting this term should make also the 'Right' region
insulated, so a change in solution should be visible.

> As you might infer from the visualisation of the solution below, thes BCs
> are not being met (slope of the contours should be flat on the LHS and not
> flat on the right). Indeed, if I comment these out of the equation
> definition, the solution remains unchanged. What is going on?

Not sure - try sending me the example. Also, double check your region
definitions. You can use problem.save_regions_as_groups('regions') to see the
actual regions.

r.

> Thanks,
> David
>
> <https://lh3.googleusercontent.com/-cTRMmEvK4b0/WGy-o0MCHaI/AAAAAAAAA8s/F0T6S8bll4IFiFHlTUCMd810VOg3cWNugCLcB/s1600/NLP_surfFlux-reduced.png>
>

David Jessop

unread,
Jan 4, 2017, 5:28:36 AM1/4/17
to sfepy...@googlegroups.com
Hi Robert,

Here's the problem script.  The regions were being saved as you suggested and they agree with what I expect them to be. 

Cheers,
David


--
You received this message because you are subscribed to the Google Groups "sfepy-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sfepy-devel+unsubscribe@googlegroups.com.
To post to this group, send email to sfepy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sfepy-devel.

nonLinearPoisson.py

Robert Cimrman

unread,
Jan 4, 2017, 7:23:56 AM1/4/17
to sfepy...@googlegroups.com
Hi David,

check the section of the manual on Neumann conditions in [1]. You need to use
dw_surface_integrate term for the Neumann conditions, as in [2], not
dw_surface_flux.

Zero flux = no term in the zero flux boundary part
Non-zero flux = g = K grad(p) * n (scalar value!) needs to be given in
dw_surface_integrate.

Also note, that the coefficient in the flux K is the same as the one in the
Laplacian.

Does it make sense?

r.

[1] http://sfepy.org/doc-devel/solving_pdes_by_fem.html
[2] http://sfepy.org/doc-devel/examples/diffusion/poisson_neumann.html
>> email to sfepy-devel...@googlegroups.com.

David Jessop

unread,
Jan 4, 2017, 9:32:27 AM1/4/17
to sfepy...@googlegroups.com
Hi Robert,

That all makes sense and I had previously been using dw_surface_integrate for my Neumann BCs: I thought that dw_surface_flux might rectify the dv/dn \neq 0 problem and I should have been clearer about this in my post.  However, regardless of which term I use, nothing changes the fact that the dv/dn = 0 conditions are not being met on the left and top boundaries. 

Cheers,
David




To post to this group, send email to sfepy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sfepy-devel.

--
You received this message because you are subscribed to the Google Groups "sfepy-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sfepy-devel+unsubscribe@googlegroups.com.

Robert Cimrman

unread,
Jan 4, 2017, 10:10:52 AM1/4/17
to sfepy...@googlegroups.com
On 01/04/2017 03:32 PM, David Jessop wrote:
> Hi Robert,
>
> That all makes sense and I had previously been using dw_surface_integrate
> for my Neumann BCs: I thought that dw_surface_flux might rectify the dv/dn
> \neq 0 problem and I should have been clearer about this in my post.
> However, regardless of which term I use, nothing changes the fact that the
> dv/dn = 0 conditions are not being met on the left and top boundaries.

Note that not dv/dn = 0, but K_ij n_i dv/dx_j = 0. Your K_ij depends on v.

When I tried with a constant visc.val = 50, and checked the fluxes with:

fl = ev('d_surface_flux.2.Left(visc.vi, v)', copy_materials=False)
print fl

ft = ev('d_surface_flux.2.Top(visc.vi, v)', copy_materials=False)
print ft

fr = ev('d_surface_flux.2.Right(visc.vi, v)', copy_materials=False)
print fr

and used order = 2, the fluxes pretty much agreed. See the attached modified
script (my additions marked by "# !!!!!!!!!!!!!!").

So the problems you encounter might be related to the way you define the viscosity.

r.
>>>> email to sfepy-devel...@googlegroups.com.
>>>> To post to this group, send email to sfepy...@googlegroups.com.
>>>> Visit this group at https://groups.google.com/group/sfepy-devel.
>>>>
>>>>
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "sfepy-devel" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to sfepy-devel...@googlegroups.com.
nonLinearPoisson.py

David Jessop

unread,
Jan 5, 2017, 4:25:39 AM1/5/17
to sfepy...@googlegroups.com
Hi Robert,

I agree that K_ij n_i dv/dx_j = 0 is the condition that needs to be satisfied, but as the off-diagonal entries in K_ij should be zero, this implies that dv/dx_j = 0.  I'll have to check the definition of the viscosity function.

Thank you for your help.
David


To post to this group, send email to sfepy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sfepy-devel.


--
You received this message because you are subscribed to the Google Groups
"sfepy-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an

To post to this group, send email to sfepy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sfepy-devel.


--
You received this message because you are subscribed to the Google Groups "sfepy-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sfepy-devel+unsubscribe@googlegroups.com.

Robert Cimrman

unread,
Jan 5, 2017, 4:35:24 AM1/5/17
to sfepy...@googlegroups.com
On 01/05/2017 10:25 AM, David Jessop wrote:
> Hi Robert,
>
> I agree that K_ij n_i dv/dx_j = 0 is the condition that needs to be
> satisfied, but as the off-diagonal entries in K_ij should be zero, this
> implies that dv/dx_j = 0. I'll have to check the definition of the
> viscosity function.

Yes, but as it is, your K_ij can be zero, or almost zero, depending on the
initial v - then dv/dx_j can be whatever, am I right?

r.
>>>>>> email to sfepy-devel...@googlegroups.com.
>>>>>> To post to this group, send email to sfepy...@googlegroups.com.
>>>>>> Visit this group at https://groups.google.com/group/sfepy-devel.
>>>>>>
>>>>>>
>>>>>>
>>>>> --
>>>> You received this message because you are subscribed to the Google Groups
>>>> "sfepy-devel" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send an
>>>> email to sfepy-devel...@googlegroups.com.
>>>> To post to this group, send email to sfepy...@googlegroups.com.
>>>> Visit this group at https://groups.google.com/group/sfepy-devel.
>>>>
>>>>
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "sfepy-devel" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to sfepy-devel...@googlegroups.com.

David Jessop

unread,
Jan 5, 2017, 4:38:54 AM1/5/17
to sfepy...@googlegroups.com
True indeed. 


To post to this group, send email to sfepy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sfepy-devel.



--
You received this message because you are subscribed to the Google Groups
"sfepy-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an

To post to this group, send email to sfepy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sfepy-devel.


--
You received this message because you are subscribed to the Google Groups
"sfepy-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an

To post to this group, send email to sfepy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sfepy-devel.


--
You received this message because you are subscribed to the Google Groups "sfepy-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sfepy-devel+unsubscribe@googlegroups.com.

David Jessop

unread,
Jan 11, 2017, 3:32:39 AM1/11/17
to sfepy-devel
Hi Robert. 

How can material properties, such as "viscosity" in my problem be saved to file (say vtk format) for inspection?  I'd like to be able to do this at two points in my programme - following the call to set the initial guess for the velocity field and once the solution has converged.

Also, can material parameters be evaluated at arbitrary regions, such as the edges of the domain?

Thanks
David

Robert Cimrman

unread,
Jan 11, 2017, 5:35:25 AM1/11/17
to sfepy...@googlegroups.com
Hi David,

On 01/11/2017 09:32 AM, David Jessop wrote:
> Hi Robert.
>
> How can material properties, such as "viscosity" in my problem be saved to
> file (say vtk format) for inspection? I'd like to be able to do this at
> two points in my programme - following the call to set the initial guess
> for the velocity field and once the solution has converged.

See post_process() in [1]. The term ev_integrate_mat used there allows also
obtaining the material evaluated in the quadrature points of all elements, in
case you need that.

[1]
http://sfepy.org/doc-devel/examples/linear_elasticity/material_nonlinearity.html

> Also, can material parameters be evaluated at arbitrary regions, such as
> the edges of the domain?

You mean manually? What exactly do you need?

Each term evaluates a material where needed - volume integrals in volume
quadrature points, surface integrals in the surface (edge or face) quadrature
points.

r.
>>>>>>>>> email to sfepy-devel...@googlegroups.com.
>>>>>>>>> To post to this group, send email to sfepy...@googlegroups.com.
>>>>>>>>> Visit this group at https://groups.google.com/group/sfepy-devel.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups
>>>>>>> "sfepy-devel" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>> send an
>>>>>>> email to sfepy-devel...@googlegroups.com.
>>>>>>> To post to this group, send email to sfepy...@googlegroups.com.
>>>>>>> Visit this group at https://groups.google.com/group/sfepy-devel.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups
>>>>> "sfepy-devel" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an
>>>>> email to sfepy-devel...@googlegroups.com.
>>>>> To post to this group, send email to sfepy...@googlegroups.com.
>>>>> Visit this group at https://groups.google.com/group/sfepy-devel.
>>>>>
>>>>>
>>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "sfepy-devel" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to sfepy-devel...@googlegroups.com.

David Jessop

unread,
Jan 11, 2017, 11:14:51 AM1/11/17
to sfepy-devel
Hi Robert,

I get how 'ev_integrate_mat' etc. can be used to evaluate the material values but I want specifically to output these values, say as part of the solution vector.  In material_nonlinearity.py there is a post-processing hook that does this, but how would this work in interactive mode? 

Regarding the second part of my question, I want to call the value of "viscosity" on the boundaries within another function (my "flux" function depends on viscosity).

Cheers,
David

Robert Cimrman

unread,
Jan 11, 2017, 12:23:56 PM1/11/17
to sfepy...@googlegroups.com
On 01/11/2017 05:14 PM, David Jessop wrote:
> Hi Robert,
>
> I get how 'ev_integrate_mat' etc. can be used to evaluate the material
> values but I want specifically to output these values, say as part of the
> solution vector. In material_nonlinearity.py there is a post-processing
> hook that does this, but how would this work in interactive mode?

It is the same. Note that pb.solve() returns a State instance, not a simple
vector. So:

state = pb.solve()
out = state.create_output_dict()

# Add to out as in post_process()

pb.save_state('foo.vtk', out=out)

> Regarding the second part of my question, I want to call the value of
> "viscosity" on the boundaries within another function (my "flux" function
> depends on viscosity).

You can call get_viscosity() (talking about nonLinearPoisson.py) directly, no?

r.
Reply all
Reply to author
Forward
0 new messages