void set_constraints(struct gmx_constr *constr,
		     gmx_localtop_t *top,t_inputrec *ir,
		     t_mdatoms *md,gmx_domdec_t *dd)
{
  t_idef *idef;
  int    ncons;

  if (constr->ncon_tot > 0) {
    idef = &top->idef;
    
    ncons = idef->il[F_CONSTR].nr/3;
    
    /* With DD we might also need to call LINCS with ncons=0 for communicating
     * coordinates to other nodes that do have constraints.
     */
    if (ir->eConstrAlg == econtLINCS) {
      set_lincs(idef,md,EI_DYNAMICS(ir->eI),dd,constr->lincsd);
    }
    if (ir->eConstrAlg == econtSHAKE) {
      if (dd) {
	make_shake_sblock_dd(constr,&idef->il[F_CONSTR],&top->cgs,dd);
      } else {
	make_shake_sblock_pd(constr,idef,md);
      }
      if (ncons > constr->lagr_nalloc) {
	constr->lagr_nalloc = over_alloc_dd(ncons);
	srenew(constr->lagr,constr->lagr_nalloc);
      }
    }
  }

  /* Make a selection of the local atoms for essential dynamics */
  if (constr->ed && dd) {
    dd_make_local_ed_indices(dd,constr->ed,md);
  }
}
Exemple #2
0
void set_constraints(struct gmx_constr *constr,
                     gmx_localtop_t *top,t_inputrec *ir,
                     t_mdatoms *md,t_commrec *cr)
{
    t_idef *idef;
    int    ncons;
    t_ilist *settle;
    int    iO,iH;
    
    idef = &top->idef;
       
    if (constr->ncon_tot > 0)
    {
        /* We are using the local topology,
         * so there are only F_CONSTR constraints.
         */
        ncons = idef->il[F_CONSTR].nr/3;
        
        /* With DD we might also need to call LINCS with ncons=0 for
         * communicating coordinates to other nodes that do have constraints.
         */
        if (ir->eConstrAlg == econtLINCS)
        {
            set_lincs(idef,md,EI_DYNAMICS(ir->eI),cr,constr->lincsd);
        }
        if (ir->eConstrAlg == econtSHAKE)
        {
            if (cr->dd)
            {
                make_shake_sblock_dd(constr,&idef->il[F_CONSTR],&top->cgs,cr->dd);
            }
            else
            {
                make_shake_sblock_pd(constr,idef,md);
            }
            if (ncons > constr->lagr_nalloc)
            {
                constr->lagr_nalloc = over_alloc_dd(ncons);
                srenew(constr->lagr,constr->lagr_nalloc);
            }

            constr->shaked = shake_init();
        }
    }

    if (idef->il[F_SETTLE].nr > 0 && constr->settled == NULL)
    {
        settle = &idef->il[F_SETTLE];
        iO = settle->iatoms[1];
        iH = settle->iatoms[1]+1;
        constr->settled =
            settle_init(md->massT[iO],md->massT[iH],
                        md->invmass[iO],md->invmass[iH],
                        idef->iparams[settle->iatoms[0]].settle.doh,
                        idef->iparams[settle->iatoms[0]].settle.dhh);
    }
    
    /* Make a selection of the local atoms for essential dynamics */
    if (constr->ed && cr->dd)
    {
        dd_make_local_ed_indices(cr->dd,constr->ed,md);
    }
}