LinearCombinationBC: no_penetration

I am trying to set up a linear elasticity problem for u(x,y) where some select nodes have a prescribed displacement u0(x,y), and the entire boundary should be of no_penetration type such that u(x,y) . n(x,y) = 0
Using Sfepy 2014.4, I appear to have some problems setting up the linear combination boundary conditions - I may not understand their syntax.
lcbcs = Conditions( [
LinearCombinationBC(name=*'normal'*, regions=[gamma,None], dofs={*'u.all'* : None, }, dof_map_fun=None, kind=*'no_penetration'*, arguments=()),
])
Running it I get the error chain:
Traceback (most recent call last): File "E:\pyspace\Experiments\src\sfepyelastic1.py", line 68, in <module> main() File "E:\pyspace\Experiments\src\sfepyelastic1.py", line 60, in main pb.time_update(ebcs=ebcs, lcbcs=lcbcs) File "C:\Users\m9imhof\LocalApps\XOMEPD\lib\site-packages\sfepy\discrete\problem.py", line 595, in time_update functions, create_matrix) File "C:\Users\m9imhof\LocalApps\XOMEPD\lib\site-packages\sfepy\discrete\problem.py", line 556, in update_equations functions, self) File "C:\Users\m9imhof\LocalApps\XOMEPD\lib\site-packages\sfepy\discrete\equations.py", line 287, in time_update self.variables.setup_lcbc_operators(lcbcs, ts, functions) File "C:\Users\m9imhof\LocalApps\XOMEPD\lib\site-packages\sfepy\discrete\variables.py", line 335, in setup_lcbc_operators ops.add_from_bc(bc, ts) File "C:\Users\m9imhof\LocalApps\XOMEPD\lib\site-packages\sfepy\discrete\fem\lcbc_operators.py", line 427, in add_from_bc bc.dof_map_fun, *args) File "C:\Users\m9imhof\LocalApps\XOMEPD\lib\site-packages\sfepy\discrete\fem\lcbc_operators.py", line 159, in __init__ variables, functions=functions) File "C:\Users\m9imhof\LocalApps\XOMEPD\lib\site-packages\sfepy\discrete\fem\lcbc_operators.py", line 45, in __init__ self._setup_dof_names(variables) File "C:\Users\m9imhof\LocalApps\XOMEPD\lib\site-packages\sfepy\discrete\fem\lcbc_operators.py", line 56, in _setup_dof_names self.all_dof_names = variables[self.var_name].dofs TypeError: 'TimeStepper' object has no attribute '__getitem__'
When choosing a different LinearCombinationBC, e.g., rigid, I get an assertion error:
lcbcs = Conditions( [
LinearCombinationBC(name=*'rigid'*, regions=[gamma,None], dofs={*'u.all'* : None, }, dof_map_fun=None, kind=*'rigid'*, arguments=()),
])
Traceback (most recent call last): File "E:\pyspace\Experiments\src\sfepyelastic1.py", line 68, in <module> main() File "E:\pyspace\Experiments\src\sfepyelastic1.py", line 61, in main vec = pb.solve() File "C:\Users\m9imhof\LocalApps\XOMEPD\lib\site-packages\sfepy\discrete\problem.py", line 984, in solve vec = solvers.nls(vec0, status=self.nls_status) File "C:\Users\m9imhof\LocalApps\XOMEPD\lib\site-packages\sfepy\solvers\nls.py", line 396, in __call__ eps_a=eps_a, eps_r=eps_r, mtx=mtx_a) File "C:\Users\m9imhof\LocalApps\XOMEPD\lib\site-packages\sfepy\solvers\ls.py", line 42, in _standard_call assert_(x0.shape[0] == rhs.shape[0]) File "C:\Users\m9imhof\LocalApps\XOMEPD\lib\site-packages\sfepy\base\base.py", line 198, in assert_ raise ValueError(msg) ValueError: assertion failed!
Clearly, I am missing something wrt LinearCombinationBC, but what?
Matthias

Hi Matthias,
attached is a modified file that can be run without errors (with a catch).
Comments below...
On 11/02/2015 02:51 PM, Matthias Imhof wrote:
I am trying to set up a linear elasticity problem for u(x,y) where some select nodes have a prescribed displacement u0(x,y), and the entire boundary should be of no_penetration type such that u(x,y) . n(x,y) = 0
Using Sfepy 2014.4, I appear to have some problems setting up the linear combination boundary conditions - I may not understand their syntax.
lcbcs = Conditions( [
LinearCombinationBC(name=*'normal'*, regions=[gamma,None], dofs={*'u.all'* : None, }, dof_map_fun=None, kind=*'no_penetration'*, arguments=()),
])
The main problem here is, that this operator works only for fields with approximation order 1. But I guess it could be improved (-> updating compute_nodal_normals() function would be required, no free time to do that now). More below...
Running it I get the error chain:
Traceback (most recent call last): File "E:\pyspace\Experiments\src\sfepyelastic1.py", line 68, in <module> main() File "E:\pyspace\Experiments\src\sfepyelastic1.py", line 60, in main pb.time_update(ebcs=ebcs, lcbcs=lcbcs) File "C:\Users\m9imhof\LocalApps\XOMEPD\lib\site-packages\sfepy\discrete\problem.py", line 595, in time_update functions, create_matrix) File "C:\Users\m9imhof\LocalApps\XOMEPD\lib\site-packages\sfepy\discrete\problem.py", line 556, in update_equations functions, self) File "C:\Users\m9imhof\LocalApps\XOMEPD\lib\site-packages\sfepy\discrete\equations.py", line 287, in time_update self.variables.setup_lcbc_operators(lcbcs, ts, functions) File "C:\Users\m9imhof\LocalApps\XOMEPD\lib\site-packages\sfepy\discrete\variables.py", line 335, in setup_lcbc_operators ops.add_from_bc(bc, ts) File "C:\Users\m9imhof\LocalApps\XOMEPD\lib\site-packages\sfepy\discrete\fem\lcbc_operators.py", line 427, in add_from_bc bc.dof_map_fun, *args) File "C:\Users\m9imhof\LocalApps\XOMEPD\lib\site-packages\sfepy\discrete\fem\lcbc_operators.py", line 159, in __init__ variables, functions=functions) File "C:\Users\m9imhof\LocalApps\XOMEPD\lib\site-packages\sfepy\discrete\fem\lcbc_operators.py", line 45, in __init__ self._setup_dof_names(variables) File "C:\Users\m9imhof\LocalApps\XOMEPD\lib\site-packages\sfepy\discrete\fem\lcbc_operators.py", line 56, in _setup_dof_names self.all_dof_names = variables[self.var_name].dofs TypeError: 'TimeStepper' object has no attribute '__getitem__'
The error you encountered was not caused by the approximation order. You need to call the LinearCombinationBC() as:
LinearCombinationBC(name='normal', regions=[gamma,None], dofs={'u.all' : None,}, dof_map_fun=None, kind='no_penetration', arguments=(None,)),
Note "arguments=(None,)". This is necessary to set the filename
argument of
NoPenetrationOperator.__init__(). Essentially, any arguments to .__init__()
functions of LCBC operators besides "name, regions, dofs, dof_map_fun, kind"
and "variables, ts, functions" need to be passed using arguments
. So in this
case it is just the filename
.
This is a shady area of (non)documentation, and more interactive examples would be nice, yes.
When choosing a different LinearCombinationBC, e.g., rigid, I get an assertion error:
lcbcs = Conditions( [
LinearCombinationBC(name=*'rigid'*, regions=[gamma,None], dofs={*'u.all'* : None, }, dof_map_fun=None, kind=*'rigid'*, arguments=()),
])
Traceback (most recent call last): File "E:\pyspace\Experiments\src\sfepyelastic1.py", line 68, in <module> main() File "E:\pyspace\Experiments\src\sfepyelastic1.py", line 61, in main vec = pb.solve() File "C:\Users\m9imhof\LocalApps\XOMEPD\lib\site-packages\sfepy\discrete\problem.py", line 984, in solve vec = solvers.nls(vec0, status=self.nls_status) File "C:\Users\m9imhof\LocalApps\XOMEPD\lib\site-packages\sfepy\solvers\nls.py", line 396, in __call__ eps_a=eps_a, eps_r=eps_r, mtx=mtx_a) File "C:\Users\m9imhof\LocalApps\XOMEPD\lib\site-packages\sfepy\solvers\ls.py", line 42, in _standard_call assert_(x0.shape[0] == rhs.shape[0]) File "C:\Users\m9imhof\LocalApps\XOMEPD\lib\site-packages\sfepy\base\base.py", line 198, in assert_ raise ValueError(msg) ValueError: assertion failed!
Clearly, I am missing something wrt LinearCombinationBC, but what?
To make the LCBCs work in interactive scripts, the nonlinear solver has to be
constructed in a special way (after the conditions were applied in
pb.time_update(ebcs=ebcs, lcbcs=lcbcs)
), as in
examples/diffusion/laplace_shifted_periodic.py, see the attached file.
So, the attachment runs - both operators for the linear approximation, and the rigid one for the quadratic.
Does that help (a bit)?
r.

On 11/05/2015 03:59 PM, Matthias Imhof wrote:
Thanks,
I replaced pb.set_solver(*nls*) with pb.set_solvers_instances(ls, nls) as the distribution I am forced to use (2014.4) does not contain the set_solver method; but now it works like a charm.
Glad to hear that!
r.
participants (2)
-
Matthias Imhof
-
Robert Cimrman