当前位置: 首页>>代码示例>>C++>>正文


C++ Traverse::get_base方法代码示例

本文整理汇总了C++中Traverse::get_base方法的典型用法代码示例。如果您正苦于以下问题:C++ Traverse::get_base方法的具体用法?C++ Traverse::get_base怎么用?C++ Traverse::get_base使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Traverse的用法示例。


在下文中一共展示了Traverse::get_base方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: assemble


//.........这里部分代码省略.........
      }

      //// assemble volume linear forms ////////////////////////////////////////
      if (rhs != NULL)
      {
        for (unsigned int ww = 0; ww < s->vfvol.size(); ww++)
        {
          WeakForm::VectorFormVol* vfv = s->vfvol[ww];
          if (isempty[vfv->i]) continue;
          if (vfv->area != H2D_ANY && !wf->is_in_area(marker, vfv->area)) continue;
          m = vfv->i;  fv = spss[m];  am = &al[m];

          for (int i = 0; i < am->cnt; i++)
          {
            if (am->dof[i] < 0) continue;
            fv->set_active_shape(am->idx[i]);
            rhs->add(am->dof[i], eval_form(vfv, u_ext, fv, refmap + m) * am->coef[i]);
          }
        }
      }

      // assemble surface integrals now: loop through boundary edges of the element
      for (unsigned int edge = 0; edge < e0->nvert; edge++)
      {
        if (!bnd[edge]) continue;
        marker = ep[edge].marker;

        // obtain the list of shape functions which are nonzero on this edge
        for (unsigned int i = 0; i < s->idx.size(); i++) {
          if (e[i] == NULL) continue;
          int j = s->idx[i];
          if ((nat[j] = (spaces[j]->bc_type_callback(marker) == BC_NATURAL)))
            spaces[j]->get_edge_assembly_list(e[i], edge, al + j);
        }

        // assemble surface matrix forms ///////////////////////////////////
        if (jac != NULL)
        {
          for (unsigned int ww = 0; ww < s->mfsurf.size(); ww++)
          {
            WeakForm::MatrixFormSurf* mfs = s->mfsurf[ww];
            if (isempty[mfs->i] || isempty[mfs->j]) continue;
            if (mfs->area != H2D_ANY && !wf->is_in_area(marker, mfs->area)) continue;
            m = mfs->i;  fv = spss[m];  am = &al[m];
            n = mfs->j;  fu = pss[n];   an = &al[n];

            if (!nat[m] || !nat[n]) continue;
            ep[edge].base = trav.get_base();
            ep[edge].space_v = spaces[m];
            ep[edge].space_u = spaces[n];

            scalar bi, **mat = get_matrix_buffer(std::max(am->cnt, an->cnt));
            for (int i = 0; i < am->cnt; i++)
            {
              if ((k = am->dof[i]) < 0) continue;
              fv->set_active_shape(am->idx[i]);
              for (int j = 0; j < an->cnt; j++)
              {
                fu->set_active_shape(an->idx[j]);
                bi = eval_form(mfs, u_ext, fu, fv, refmap+n, refmap+m, ep+edge) * an->coef[j] * am->coef[i];
                if (an->dof[j] >= 0) mat[i][j] = bi;
              }
            }
            jac->add(am->cnt, an->cnt, mat, am->dof, an->dof);
          }
        }
        // assemble surface linear forms /////////////////////////////////////
        if (rhs != NULL)
        {
          for (unsigned ww = 0; ww < s->vfsurf.size(); ww++)
          {
            WeakForm::VectorFormSurf* vfs = s->vfsurf[ww];
            if (isempty[vfs->i]) continue;
            if (vfs->area != H2D_ANY && !wf->is_in_area(marker, vfs->area)) continue;
            m = vfs->i;  fv = spss[m];  am = &al[m];

            if (!nat[m]) continue;
            ep[edge].base = trav.get_base();
            ep[edge].space_v = spaces[m];

            for (int i = 0; i < am->cnt; i++)
            {
              if (am->dof[i] < 0) continue;
              fv->set_active_shape(am->idx[i]);
              rhs->add(am->dof[i], eval_form(vfs, u_ext, fv, refmap+m, ep+edge) * am->coef[i]);
            }
          }
        }
      }
      delete_cache();
    }
    trav.finish();
  }

  for (int i = 0; i < wf->neq; i++) delete spss[i];
  delete [] buffer;
  buffer = NULL;
  mat_size = 0;

}
开发者ID:certik,项目名称:hermes2d,代码行数:101,代码来源:feproblem.cpp

示例2: assemble_matrix_and_rhs


//.........这里部分代码省略.........
                  fu->set_active_shape(an->idx[j]);
                  mat[i][j] += bf->unsym(fu, fv, refmap+n, refmap+m) * coef;
                }
              }
            }
          }

          // insert the local stiffness matrix into the global one
          insert_matrix(mat, am->dof, an->dof, am->cnt, an->cnt);

          // insert also the off-diagonal (anti-)symmetric block, if required
          if (tra)
          {
            if (biform[n][m].unsym == BF_ANTISYM) chsgn(mat, am->cnt, an->cnt);
            transpose(mat, am->cnt, an->cnt);
            insert_matrix(mat, an->dof, am->dof, an->cnt, am->cnt);

            // we also need to take care of the RHS...
            for (j = 0; j < am->cnt; j++)
              if (am->dof[j] < 0)
                for (i = 0; i < an->cnt; i++)
                  if (an->dof[i] >= 0)
                    Dir[an->dof[i]] -= mat[i][j];
          }
        }
      }

      // assemble rhs (linear form)
      if (!liform[m].lf) continue;
      for (i = 0; i < am->cnt; i++)
      {
        if (am->dof[i] < 0) continue;
        fv->set_active_shape(am->idx[i]);
        RHS[am->dof[i]] += liform[m].lf(fv, refmap+m) * am->coef[i];
      }
    }

    // assemble surface integrals now: loop through boundary edges of the element
    if (rhsonly) continue; // fixme
    for (int edge = 0; edge < e[0]->nvert; edge++)
    {
      if (!bnd[edge]) continue;

      // obtain the list of shape functions which are nonzero on this edge
      for (i = 0; i < neq; i++)
        if ((nat[i] = (spaces[i]->bc_type_callback(ep[edge].marker) == BC_NATURAL)))
          spaces[i]->get_edge_assembly_list(e[i], edge, al + i);

      // loop through the equation-blocks
      for (m = 0, am = al; m < neq; m++, am++)
      {
        if (!nat[m]) continue;
        fv = spss[m];
        ep[edge].base = trav.get_base();
        ep[edge].space_v = spaces[m];
        for (n = 0, an = al; n < neq; n++, an++)
        {
          if (!nat[n]) continue;
          BiForm* bf = biform[m] + n;
          if (!bf->surf) continue;
          fu = pss[n];
          ep[edge].space_u = spaces[n];

          // assemble the surface part of the bilinear form
          scalar bi, **mat = get_matrix_buffer(std::max(am->cnt, an->cnt));
          for (i = 0; i < am->cnt; i++)
          {
            if ((k = am->dof[i]) < 0) continue;
            fv->set_active_shape(am->idx[i]);
            for (j = 0; j < an->cnt; j++)
            {
              fu->set_active_shape(an->idx[j]);
              bi = bf->surf(fu, fv, refmap+n, refmap+m, ep+edge) * an->coef[j] * am->coef[i];
              if (an->dof[j] >= 0) mat[i][j] = bi; else Dir[k] -= bi;
            }
          }
          insert_matrix(mat, am->dof, an->dof, am->cnt, an->cnt);
        }

        // assemble the surface part of the linear form
        if (!liform[m].surf) continue;
        for (i = 0; i < am->cnt; i++)
        {
          if (am->dof[i] < 0) continue;
          fv->set_active_shape(am->idx[i]);
          RHS[am->dof[i]] += liform[m].surf(fv, refmap+m, ep+edge) * am->coef[i];
        }
      }
    }
  }

  trav.finish();
  for (i = 0; i < ndofs; i++)
    RHS[i] += Dir[i];

  if (!quiet) verbose("  (time: %g sec)", end_time());
  for (i = 0; i < neq; i++) delete spss[i];
  delete [] buffer;
  delete [] refmap;
}
开发者ID:regmi,项目名称:hermes2d,代码行数:101,代码来源:discrete.cpp


注:本文中的Traverse::get_base方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。