getfem-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Getfem-users] Dirichlet boundary condition on vertex


From: James Zhou
Subject: Re: [Getfem-users] Dirichlet boundary condition on vertex
Date: Fri, 28 Oct 2011 15:28:56 -0400

Dear all,

I figured it out (I know, I really should try harder before posting...).  Here is a snippet to constrain the y component of some vertices:

    dofs = mfu.basic_dof_nodes();

    # Count the total number of constrains.
    num_constraints = 0;
    for i in range(0, mfu.nbdof()):
            if (abs(dofs[1][i] + 0.00125) < 1e-9):  # A condition to determine which vertex to constrain
                if (i % 3 != 1): continue;  # If not y component, move on to next dof
                num_constraints = num_constraints + 1;

    H = gf.Spmat('empty', num_constraints, mfu.nbdof());

    # Fill H and R
    row_index = 0;
    for i in range(0, mfu.nbdof()):
        if (abs(dofs[1][i] + 0.00125) < 1e-9):
            if (i % 3 != 1): continue;
            H.assign(row_index, i, 1);
            row_index = row_index + 1;
            R.append(0);

    b4 = gf.MdBrick("constraint", b2, 'eliminated');
    b4.constraints(H, R);

Hope it is helpful to someone else too.

James

On Fri, Oct 28, 2011 at 12:18 PM, James Zhou <address@hidden> wrote:
Hi Yves,

Could you elaborate on how to use the old constraint block a little bit?  I keep getting dimension mismatch errors.  When qdim is not 1, is the constraint matrix is of size nb_constraints x (nb_dof * qdim)?

In the new brick system, is it possible to add pointwise constraint with elimination?

Thank you very much :)
James


On Fri, Oct 28, 2011 at 4:26 AM, Yves Renard <address@hidden> wrote:

Dear James,

The (old) brick on which you refer take a global constraint matrix in
argument. This should be a global matrix (nb_constraints  x  nb_dof)

Note that in the new brick system, there is now a special brick to set
components on specific points (for instance to kill rigid body modes). The
points are not necessarily some vertices of the mesh. This is the "pointwise
constraints brick". It is available in the svn version only.

Yves.



On vendredi 28 octobre 2011, James Zhou wrote:
> Dear all,
>
> I have exactly the same question as in
> http://www.mail-archive.com/address@hidden
>
> In particular, I want to fixed a component of some a set of vertex in 3D.
> Can anyone give an example on how to use the constraint brick in python?
> Here is my obviously failed attempt:
>
> H = []; R = []
> b4 = gf.MdBrick("constraint", b2, 'eliminated');
>
> # Loop though all dof nodes looking for nodes satisfy the constraint
> criteria
> for dof in mfu.basic_dof_nodes():
>     if (abs(dof[1] + 0.125) < 1e-6):
>         # constrain the y component of dof to 0
>         H.append([0,0,0,0,1,0,0,0,0]);
>         R.append([0,0,0]);
>     else:
>         # dof is not part of the constraint.
>         H.append([0,0,0,0,0,0,0,0,0]);
>         R.append([0,0,0]);
> b4.constraints(H, R);
>
> Thank you very much!
> James


--

 Yves Renard (address@hidden)       tel : (33) 04.72.43.87.08
 Pole de Mathematiques, INSA-Lyon             fax : (33) 04.72.43.85.29
 20, rue Albert Einstein
 69621 Villeurbanne Cedex, FRANCE
 http://math.univ-lyon1.fr/~renard

---------





reply via email to

[Prev in Thread] Current Thread [Next in Thread]