28   void mesh_fem_global_function::set_functions
 
   29   (
const std::vector<pglobal_function>& funcs, 
const mesh_im &mim) {
 
   30     GMM_ASSERT1(linked_mesh_ != 0, 
"Mesh fem need to be initialized with" 
   36       GMM_ASSERT1(&(mim.linked_mesh()) == linked_mesh_,
 
   37                   "The provided mesh_im has to be linked to the same mesh" 
   38                   " as this mesh_fem.");
 
   46   void mesh_fem_global_function::clear() {
 
  164   void params_for_uniform_1d_bspline_basis_functions
 
  166    bspline_boundary bc_low, bspline_boundary bc_high,
 
  167    std::vector<scalar_type> &xmin, std::vector<scalar_type> &xmax,
 
  168    std::vector<scalar_type> &xshift, std::vector<size_type> &xtype) {
 
  170     if (bc_low == bspline_boundary::PERIODIC ||
 
  171         bc_high == bspline_boundary::PERIODIC)
 
  172       GMM_ASSERT1(bc_low == bc_high,
 
  173                   "Periodic BC has to be assigned to both matching sides");
 
  174     const scalar_type dx = (x1-x0)/scalar_type(N);
 
  176     n_low = (bc_low == bspline_boundary::PERIODIC) ? 0 :
 
  177             (bc_low == bspline_boundary::SYMMETRY  ? order/2 :
 
  179     n_high = (bc_high == bspline_boundary::PERIODIC) ? order-1 :
 
  180              (bc_high == bspline_boundary::SYMMETRY  ? order/2 :
 
  182     n_mid = N - order + 1;
 
  191       if (bc_low == bspline_boundary::FREE && i < n_low) {
 
  194         xmax[i] = xmin[i] + scalar_type(xtype[i])*dx;
 
  195       } 
else if (bc_high == bspline_boundary::FREE && i >= n_low+n_mid) {
 
  198         xmax[i] = xmin[i] - scalar_type(xtype[i])*dx; 
 
  199       } 
else if (bc_low == bspline_boundary::SYMMETRY && i < n_low) {
 
  201         xmin[i] = x0 - scalar_type(n_low-i)*dx;
 
  202         xmax[i] = xmin[i] + scalar_type(xtype[i])*dx;
 
  203         xshift[i] = -(xmin[i]+xmax[i]-2*x0); 
 
  204       } 
else if (bc_high == bspline_boundary::SYMMETRY && i >= n_low+n_mid) {
 
  206         xmin[i] = x0 + scalar_type(i-n_low)*dx; 
 
  207         xmax[i] = xmin[i] + scalar_type(xtype[i])*dx;
 
  208         xshift[i] = 2*x1-xmin[i]-xmax[i]; 
 
  210         GMM_ASSERT1(i >= n_low, 
"Internal error");
 
  212         xmin[i] = x0 + scalar_type(i-n_low)*dx; 
 
  213         xmax[i] = xmin[i] + scalar_type(xtype[i])*dx;
 
  218       if (bc_low == bspline_boundary::PERIODIC && xmax[i] > x1)
 
  219         xshift[i] = -(x1-x0); 
 
  225    bspline_boundary bcX_low, bspline_boundary bcX_high,
 
  229                 "This function expects a mesh_fem defined in 1d");
 
  231     base_node Pmin, Pmax;
 
  233     const scalar_type x0=Pmin[0], x1=Pmax[0];
 
  235     std::vector<scalar_type> xmin, xmax, xshift;
 
  236     std::vector<size_type> xtype;
 
  237     params_for_uniform_1d_bspline_basis_functions
 
  238       (x0, x1, NX, order, bcX_low, bcX_high, 
 
  239        xmin, xmax, xshift, xtype);           
 
  241     std::vector<pglobal_function> funcs(0);
 
  242     for (
size_type i=0; i < xtype.size(); ++i) {
 
  243       if (gmm::abs(xshift[i]) < 1e-10)
 
  244         funcs.push_back(global_function_bspline
 
  245                         (xmin[i], xmax[i], order, xtype[i]));
 
  247         std::vector<pglobal_function> sum;
 
  248         sum.push_back(global_function_bspline
 
  249                       (xmin[i], xmax[i], order, xtype[i]));
 
  250         sum.push_back(global_function_bspline
 
  251                       (xmin[i]+xshift[i], xmax[i]+xshift[i],
 
  253         funcs.push_back(std::make_shared<getfem::global_function_sum>(sum));
 
  256     mf.set_functions(funcs, mim);
 
  262    bspline_boundary bcX_low, bspline_boundary bcY_low,
 
  263    bspline_boundary bcX_high, bspline_boundary bcY_high,
 
  267                 "This function expects a mesh_fem defined in 2d");
 
  269     base_node Pmin, Pmax;
 
  271     const scalar_type x0=Pmin[0], x1=Pmax[0],
 
  272                       y0=Pmin[1], y1=Pmax[1];
 
  274     std::vector<scalar_type> xmin, xmax, xshift;
 
  275     std::vector<size_type> xtype;
 
  276     params_for_uniform_1d_bspline_basis_functions
 
  277       (x0, x1, NX, order, bcX_low, bcX_high, 
 
  278        xmin, xmax, xshift, xtype);           
 
  279     std::vector<scalar_type> ymin, ymax, yshift;
 
  280     std::vector<size_type> ytype;
 
  281     params_for_uniform_1d_bspline_basis_functions
 
  282       (y0, y1, NY, order, bcY_low, bcY_high, 
 
  283        ymin, ymax, yshift, ytype);           
 
  285     std::vector<pglobal_function> funcs(0);
 
  286     for (
size_type i=0; i < xtype.size(); ++i) {
 
  287       for (
size_type j=0; j < ytype.size(); ++j) {
 
  288         if (gmm::abs(xshift[i]) < 1e-10 &&
 
  289             gmm::abs(yshift[j]) < 1e-10)
 
  290           funcs.push_back(global_function_bspline
 
  291                           (xmin[i], xmax[i], ymin[j], ymax[j],
 
  292                            order, xtype[i], ytype[j]));
 
  294           std::vector<pglobal_function> sum;
 
  295           sum.push_back(global_function_bspline
 
  296                         (xmin[i], xmax[i], ymin[j], ymax[j],
 
  297                          order, xtype[i], ytype[j]));
 
  298           if (gmm::abs(xshift[i]) >= 1e-10)
 
  299             sum.push_back(global_function_bspline
 
  300                           (xmin[i]+xshift[i], xmax[i]+xshift[i],
 
  302                            order, xtype[i], ytype[j]));
 
  303           if (gmm::abs(yshift[j]) >= 1e-10) {
 
  304             sum.push_back(global_function_bspline
 
  306                            ymin[j]+yshift[j], ymax[j]+yshift[j],
 
  307                            order, xtype[i], ytype[j]));
 
  308             if (gmm::abs(xshift[i]) >= 1e-10)
 
  309               sum.push_back(global_function_bspline
 
  310                             (xmin[i]+xshift[i], xmax[i]+xshift[i],
 
  311                              ymin[j]+yshift[j], ymax[j]+yshift[j],
 
  312                              order, xtype[i], ytype[j]));
 
  314           funcs.push_back(std::make_shared<getfem::global_function_sum>(sum));
 
  318     mf.set_functions(funcs, mim);
 
  324    bspline_boundary bcX_low,
 
  325    bspline_boundary bcY_low,
 
  326    bspline_boundary bcZ_low,
 
  327    bspline_boundary bcX_high,
 
  328    bspline_boundary bcY_high,
 
  329    bspline_boundary bcZ_high, 
const mesh_im &mim) {
 
  332                 "This function expects a mesh_fem defined in 3d");
 
  334     base_node Pmin, Pmax;
 
  336     const scalar_type x0=Pmin[0], x1=Pmax[0],
 
  337                       y0=Pmin[1], y1=Pmax[1],
 
  338                       z0=Pmin[2], z1=Pmax[2];
 
  340     std::vector<scalar_type> xmin, xmax, xshift;
 
  341     std::vector<size_type> xtype;
 
  342     params_for_uniform_1d_bspline_basis_functions
 
  343       (x0, x1, NX, order, bcX_low, bcX_high, 
 
  344        xmin, xmax, xshift, xtype);           
 
  345     std::vector<scalar_type> ymin, ymax, yshift;
 
  346     std::vector<size_type> ytype;
 
  347     params_for_uniform_1d_bspline_basis_functions
 
  348       (y0, y1, NY, order, bcY_low, bcY_high, 
 
  349        ymin, ymax, yshift, ytype);           
 
  350     std::vector<scalar_type> zmin, zmax, zshift;
 
  351     std::vector<size_type> ztype;
 
  352     params_for_uniform_1d_bspline_basis_functions
 
  353       (z0, z1, NZ, order, bcZ_low, bcZ_high, 
 
  354        zmin, zmax, zshift, ztype);           
 
  356     std::vector<pglobal_function> funcs(0);
 
  357     for (
size_type i=0; i < xtype.size(); ++i) {
 
  358       for (
size_type j=0; j < ytype.size(); ++j) {
 
  359         for (
size_type k=0; k < ztype.size(); ++k) {
 
  361           bool has_xshift = gmm::abs(xshift[i]) >= 1e-10;
 
  362           bool has_yshift = gmm::abs(yshift[j]) >= 1e-10;
 
  363           bool has_zshift = gmm::abs(zshift[k]) >= 1e-10;
 
  364           if (not(has_xshift) && not(has_yshift) && not(has_yshift))
 
  365             funcs.push_back(global_function_bspline
 
  369                              order, xtype[i], ytype[j], ztype[k])) ;
 
  371             std::vector<pglobal_function> sum;
 
  372             sum.push_back(global_function_bspline
 
  376                            order, xtype[i], ytype[j], ztype[k]));
 
  378               sum.push_back(global_function_bspline
 
  379                             (xmin[i]+xshift[i], xmax[i]+xshift[i],
 
  382                              order, xtype[i], ytype[j], ztype[k]));
 
  384               sum.push_back(global_function_bspline
 
  386                              ymin[j]+yshift[j], ymax[j]+yshift[j],
 
  388                              order, xtype[i], ytype[j], ztype[k]));
 
  390               sum.push_back(global_function_bspline
 
  393                              zmin[k]+zshift[k], zmax[k]+zshift[k],
 
  394                              order, xtype[i], ytype[j], ztype[k]));
 
  395             if (has_xshift && has_yshift) 
 
  396               sum.push_back(global_function_bspline
 
  397                             (xmin[i]+xshift[i], xmax[i]+xshift[i],
 
  398                              ymin[j]+yshift[j], ymax[j]+yshift[j],
 
  400                              order, xtype[i], ytype[j], ztype[k]));
 
  401             if (has_yshift && has_zshift) 
 
  402               sum.push_back(global_function_bspline
 
  404                              ymin[j]+yshift[j], ymax[j]+yshift[j],
 
  405                              zmin[k]+zshift[k], zmax[k]+zshift[k],
 
  406                              order, xtype[i], ytype[j], ztype[k]));
 
  407             if (has_zshift && has_xshift) 
 
  408               sum.push_back(global_function_bspline
 
  409                             (xmin[i]+xshift[i], xmax[i]+xshift[i],
 
  411                              zmin[k]+zshift[k], zmax[k]+zshift[k],
 
  412                              order, xtype[i], ytype[j], ztype[k]));
 
  413             if (has_xshift && has_yshift && has_zshift) 
 
  414               sum.push_back(global_function_bspline
 
  415                             (xmin[i]+xshift[i], xmax[i]+xshift[i],
 
  416                              ymin[j]+yshift[j], ymax[j]+yshift[j],
 
  417                              zmin[k]+zshift[k], zmax[k]+zshift[k],
 
  418                              order, xtype[i], ytype[j], ztype[k]));
 
  419             funcs.push_back(std::make_shared<getfem::global_function_sum>(sum));
 
  424     mf.set_functions(funcs, mim);
 
this is a convenience class for defining a mesh_fem with base functions which are global functions (f...
 
const mesh & linked_mesh() const
Return a reference to the underlying mesh.
 
void set_finite_element(size_type cv, pfem pf)
Set the finite element method of a convex.
 
Describe an integration method linked to a mesh.
 
void bounding_box(base_node &Pmin, base_node &Pmax) const
Return the bounding box [Pmin - Pmax] of the mesh.
 
Define a mesh_fem with base functions which are global functions given by the user.
 
size_t size_type
used as the common size type in the library
 
GEneric Tool for Finite Element Methods.
 
void del_fem_global_function(const pfem &pf)
release a global function FEM
 
void define_uniform_bspline_basis_functions_for_mesh_fem(mesh_fem_global_function &mf, size_type NX, size_type order, bspline_boundary bcX_low=bspline_boundary::FREE, bspline_boundary bcX_high=bspline_boundary::FREE, const mesh_im &mim=dummy_mesh_im())
This function will generate bspline basis functions on NX uniform elements along a line.
 
const mesh_im & dummy_mesh_im()
Dummy mesh_im for default parameter of functions.
 
pfem new_fem_global_function(const std::vector< pglobal_function > &funcs, const mesh &m)
create a new global function FEM.