← Back to team overview

cbc.block team mailing list archive

Re: 回复: 回复: block_bc problems

 

Thanks Huadong, I've looked at it.

The problem is that three of the blocks are not matrices, but instead
compositions: for example, "-K13" creates a composed operator that first
applies K13 to a vector, and then negates it. Dirichlet BCs can only be
applied to plain matrices.

It is possible to automatically convert an operator like this to a matrix,
but that requires trilinos (which you don't have installed). Instead, I
suggest the following:

def neg(mat):
    # Return a copy of the matrix, multiplied by -1
    result = mat.copy()
    result *= -1
    return result

...

        AA = block_mat([ [K11, K12, neg(K13)], [neg(K21), K22, K23], [K31,
neg(K32), K33]])

This will make the blocks into plain matrices, instead of compositions of
"-" and "Kxx".

With this change, it works. However, BiCGStab fails to converge with M=20.

Regards
Joachim.



On 31 January 2013 12:07, 华东 高 <mathsgao@xxxxxxxxxxxx> wrote:

> Dear Dr. Joachim Berdal Haga
>
>     I attach a python file with this email.
>
>     If pure Neumann BC is used, everything goes well,
> and the convergence order is correct, please kindly check it.
>
>
>     Thank you very much.
>
> best wishes
> huadong
>
>   ------------------------------
> *发件人:* Joachim Berdal Haga <jobh@xxxxxxxxx>
> *收件人:* 华东 高 <mathsgao@xxxxxxxxxxxx>
> *发送日期:* 2013年1月31日, 星期四, 6:16 下午
>
> *主题:* Re: 回复: block_bc problems
>
> No problem!
>
> The next question: Are all your Kxx (K11, K12, ...) matrices created by
> DOLFIN? Or are some of them scalars, or numpy matrices, or other operators?
>
> If possible, I think I will be better able to give advice if you could
> send me your script (including any data files and command-line parameters I
> need to be able to run it) so that I can see the problem for myself.
>
> Joachim.
>
>
>
>
> On 31 January 2013 08:58, 华东 高 <mathsgao@xxxxxxxxxxxx> wrote:
>
> Dear Dr. Joachim Berdal Haga
>
>     I feel really sorry for misunderstanding your email, this time I try
> the demo example in cbc.block, for the  mixedpoisson.py it doesn't work,
> and the message is as follows:
>
> Traceback (most recent call last):
>   File "poisson.py", line 3, in <module>
>     from block.algebraic.trilinos import *
>   File
> "/home/gaohuadong/articles/landaulifshitz/code/cbc.block-1.0.1/demo/block/algebraic/trilinos/__init__.py",
> line 15, in <module>
>     _init()
>   File
> "/home/gaohuadong/articles/landaulifshitz/code/cbc.block-1.0.1/demo/block/algebraic/trilinos/__init__.py",
> line 14, in _init
>     dolfin.parameters["linear_algebra_backend"] = "Epetra"
>   File "/usr/lib/python2.7/dist-packages/dolfin/cpp/common.py", line 1922,
> in __setitem__
>     par._assign(value)
> RuntimeError:
>
> ***
> -------------------------------------------------------------------------
> *** DOLFIN encountered an error. If you are not able to resolve this issue
> *** using the information listed below, you can ask for help at
> ***
> ***     https://answers.launchpad.net/dolfin
> ***
> *** Remember to include the error message listed below and, if possible,
> *** include a *minimal* running example to reproduce the error.
> ***
> ***
> -------------------------------------------------------------------------
> *** Error:   Unable to assign parameter value.
> *** Reason:  Illegal value for parameter. Allowed values are: [PETSc, STL,
> uBLAS].
> *** Where:   This error was encountered inside Parameter.cpp.
> *** Process: 0
> ***
> -------------------------------------------------------------------------
>
> best wishes
> huadong
>
>
>
>
>   ------------------------------
> *发件人:* Joachim Berdal Haga <jobh@xxxxxxxxx>
> *收件人:* 华东 高 <mathsgao@xxxxxxxxxxxx>
> *抄送:* cbc.block@xxxxxxxxxxxxxxxxxxx
> *发送日期:* 2013年1月30日, 星期三, 11:17 下午
> *主题:* Re: block_bc problems
>
> Dear Huadong,
>
> I suspect the problem may be related to versions of dolfin / cbc.block.
> Which versions of these are you using?
>
> It would also be good if you could try for example demo/mixedpoisson.py,
> to see if it fails in the same way.
>
> Regards,
> Joachim.
>
>
> On 30 January 2013 16:05, 华东 高 <mathsgao@xxxxxxxxxxxx> wrote:
>
> Dear Dr. Joachim Berdal Haga
>
>     I have tried to use your block package for solving parabolic systems,
> would you kindly tell me how to apply the Dirichlet Boundary conditions
> for the linear system,
> such as for a three dimensional problem [u1, u2,u3]
>
>         AA = block_mat([ [K11, K12, K13], [K21, K22, K23], [K31, K32,
> K33]])
>         bb = block_vec([b1,b2,b3])
>
>         bc = block_bc([DirichletBC(V, u1, D_boundary), DirichletBC(V, u2,
> D_boundary), \
>                           DirichletBC(V, u3, D_boundary)])
>
>         bc.apply(AA,bb)
>
> where Kij is matrix, bj is vector, D_boundary is just the on_boundary for
> the
> UnitSquareMesh.
>
>     But, it does not work, the message is :
>
>  bc.zero_columns(A[j,i], b[j])
> TypeError: in method 'DirichletBC_zero_columns', argument 2 of type
> 'dolfin::GenericMatrix &'
>
>     By the way, if I use pure Neumann conditions, it works well.
>
>     I expect you can spent several minutes to read the email.
>     Thank you very much.
>
> best wishes
> huadong
>
>
>
>
>
>
>
>
>
>
>

References