本文整理汇总了C++中PrecalcShapeset::set_active_element方法的典型用法代码示例。如果您正苦于以下问题:C++ PrecalcShapeset::set_active_element方法的具体用法?C++ PrecalcShapeset::set_active_element怎么用?C++ PrecalcShapeset::set_active_element使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PrecalcShapeset
的用法示例。
在下文中一共展示了PrecalcShapeset::set_active_element方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set_active_element
void RefMap::set_active_element(Element* e)
{
if (e != element) free();
ref_map_pss.set_active_element(e);
quad_2d->set_mode(e->get_mode());
num_tables = quad_2d->get_num_tables();
assert(num_tables <= H2D_MAX_TABLES);
if (e == element) return;
element = e;
reset_transform();
update_cur_node();
is_const = !element->is_curved() &&
(element->is_triangle() || is_parallelogram());
// prepare the shapes and coefficients of the reference map
int j, k = 0;
for (unsigned int i = 0; i < e->nvert; i++)
indices[k++] = ref_map_shapeset.get_vertex_index(i);
// straight-edged element
if (e->cm == NULL)
{
for (unsigned int i = 0; i < e->nvert; i++)
{
lin_coeffs[i][0] = e->vn[i]->x;
lin_coeffs[i][1] = e->vn[i]->y;
}
coeffs = lin_coeffs;
nc = e->nvert;
}
else // curvilinear element - edge and bubble shapes
{
int o = e->cm->order;
for (unsigned int i = 0; i < e->nvert; i++)
for (j = 2; j <= o; j++)
indices[k++] = ref_map_shapeset.get_edge_index(i, 0, j);
if (e->is_quad()) o = H2D_MAKE_QUAD_ORDER(o, o);
memcpy(indices + k, ref_map_shapeset.get_bubble_indices(o),
ref_map_shapeset.get_num_bubbles(o) * sizeof(int));
coeffs = e->cm->coeffs;
nc = e->cm->nc;
}
// calculate the order of the inverse reference map
if (element->iro_cache == -1 && quad_2d->get_max_order() > 1)
{
element->iro_cache = is_const ? 0 : calc_inv_ref_order();
}
inv_ref_order = element->iro_cache;
// constant inverse reference map
if (is_const) calc_const_inv_ref_map(); else const_jacobian = 0.0;
}
示例2: calc_edge_projection
static void calc_edge_projection(Element* e, int edge, Nurbs** nurbs, int order, double2* proj)
{
ref_map_pss.set_active_element(e);
int i, j, k;
int mo1 = quad1d.get_max_order();
int np = quad1d.get_num_points(mo1);
int ne = order - 1;
int mode = e->get_mode();
assert(np <= 15 && ne <= 10);
double2 fn[15];
double rhside[2][10];
memset(fn, 0, sizeof(double2) * np);
memset(rhside[0], 0, sizeof(double) * ne);
memset(rhside[1], 0, sizeof(double) * ne);
double a_1, a_2, b_1, b_2;
a_1 = ctm.m[0] * ref_vert[mode][edge][0] + ctm.t[0];
a_2 = ctm.m[1] * ref_vert[mode][edge][1] + ctm.t[1];
b_1 = ctm.m[0] * ref_vert[mode][e->next_vert(edge)][0] + ctm.t[0];
b_2 = ctm.m[1] * ref_vert[mode][e->next_vert(edge)][1] + ctm.t[1];
// values of nonpolynomial function in two vertices
double2 fa, fb;
calc_ref_map(e, nurbs, a_1, a_2, fa);
calc_ref_map(e, nurbs, b_1, b_2, fb);
double2* pt = quad1d.get_points(mo1);
for (j = 0; j < np; j++) // over all integration points
{
double2 x, v;
double t = pt[j][0];
edge_coord(e, edge, t, x, v);
calc_ref_map(e, nurbs, x[0], x[1], fn[j]);
for (k = 0; k < 2; k++)
fn[j][k] = fn[j][k] - (fa[k] + (t+1)/2.0 * (fb[k] - fa[k]));
}
double2* result = proj + e->nvert + edge * (order - 1);
for (k = 0; k < 2; k++)
{
for (i = 0; i < ne; i++)
{
for (j = 0; j < np; j++)
{
double t = pt[j][0];
double fi = lob[i+2](t);
rhside[k][i] += pt[j][1] * (fi * fn[j][k]);
}
}
// solve
cholsl(edge_proj_matrix, ne, edge_p, rhside[k], rhside[k]);
for (i = 0; i < ne; i++)
result[i][k] = rhside[k][i];
}
}
示例3: update_refmap_coefs
void CurvMap::update_refmap_coefs(Element* e)
{
ref_map_pss.set_quad_2d(&quad2d);
//ref_map_pss.set_active_element(e);
// calculation of projection matrices
if (edge_proj_matrix == NULL) precalculate_cholesky_projection_matrix_edge();
if (bubble_proj_matrix_tri == NULL) precalculate_cholesky_projection_matrices_bubble();
ref_map_pss.set_mode(e->get_mode());
ref_map_shapeset.set_mode(e->get_mode());
// allocate projection coefficients
int nv = e->nvert;
int ne = order - 1;
int qo = e->is_quad() ? make_quad_order(order, order) : order;
int nb = ref_map_shapeset.get_num_bubbles(qo);
nc = nv + nv*ne + nb;
if (coefs != NULL) delete [] coefs;
coefs = new double2[nc];
// WARNING: do not change the format of the array 'coefs'. If it changes,
// RefMap::set_active_element() has to be changed too.
Nurbs** nurbs;
if (toplevel == false)
{
ref_map_pss.set_active_element(e);
ref_map_pss.set_transform(part);
nurbs = parent->cm->nurbs;
}
else
{
ref_map_pss.reset_transform();
nurbs = e->cm->nurbs;
}
ctm = *(ref_map_pss.get_ctm());
ref_map_pss.reset_transform(); // fixme - do we need this?
// calculation of new projection coefficients
ref_map_projection(e, nurbs, order, coefs);
}
示例4: precalc_equi_coefs
void DiscreteProblem::precalc_equi_coefs()
{
int i, m;
memset(equi, 0, sizeof(double) * ndofs);
verbose("Precalculating equilibration coefficients...");
RefMap refmap;
AsmList al;
Element* e;
for (m = 0; m < neq; m++)
{
PrecalcShapeset* fu = pss[m];
BiForm* bf = biform[m] + m;
Mesh* mesh = spaces[m]->get_mesh();
for_all_active_elements(e, mesh)
{
update_limit_table(e->get_mode());
fu->set_active_element(e);
refmap.set_active_element(e);
spaces[m]->get_element_assembly_list(e, &al);
for (i = 0; i < al.cnt; i++)
{
if (al.dof[i] < 0) continue;
fu->set_active_shape(al.idx[i]);
scalar sy = 0.0, un = 0.0;
if (bf->unsym) un = bf->unsym(fu, fu, &refmap, &refmap);
if (bf->sym) sy = bf->sym (fu, fu, &refmap, &refmap);
#ifndef COMPLEX
equi[al.dof[i]] += (sy + un) * sqr(al.coef[i]);
#else
equi[al.dof[i]] += 0;//std::norm(sy + un) * sqr(al.coef[i]);
#endif
}
}
}
示例5: calc_bubble_projection
static void calc_bubble_projection(Element* e, Nurbs** nurbs, int order, double2* proj)
{
ref_map_pss.set_active_element(e);
int i, j, k;
int mo2 = quad2d.get_max_order();
int np = quad2d.get_num_points(mo2);
int qo = e->is_quad() ? make_quad_order(order, order) : order;
int nb = ref_map_shapeset.get_num_bubbles(qo);
AUTOLA_OR(double2, fn, np);
memset(fn, 0, sizeof(double2) * np);
double* rhside[2];
double* old[2];
for (i = 0; i < 2; i++) {
rhside[i] = new double[nb];
old[i] = new double[np];
memset(rhside[i], 0, sizeof(double) * nb);
memset(old[i], 0, sizeof(double) * np);
}
// compute known part of projection (vertex and edge part)
old_projection(e, order, proj, old);
// fn values of both components of nonpolynomial function
double3* pt = quad2d.get_points(mo2);
for (j = 0; j < np; j++) // over all integration points
{
double2 a;
a[0] = ctm.m[0] * pt[j][0] + ctm.t[0];
a[1] = ctm.m[1] * pt[j][1] + ctm.t[1];
calc_ref_map(e, nurbs, a[0], a[1], fn[j]);
}
double2* result = proj + e->nvert + e->nvert * (order - 1);
for (k = 0; k < 2; k++)
{
for (i = 0; i < nb; i++) // loop over bubble basis functions
{
// bubble basis functions in all integration points
double *bfn;
int index_i = ref_map_shapeset.get_bubble_indices(qo)[i];
ref_map_pss.set_active_shape(index_i);
ref_map_pss.set_quad_order(mo2);
bfn = ref_map_pss.get_fn_values();
for (j = 0; j < np; j++) // over all integration points
rhside[k][i] += pt[j][2] * (bfn[j] * (fn[j][k] - old[k][j]));
}
// solve
if (e->nvert == 3)
cholsl(bubble_proj_matrix_tri, nb, bubble_tri_p, rhside[k], rhside[k]);
else
cholsl(bubble_proj_matrix_quad, nb, bubble_quad_p, rhside[k], rhside[k]);
for (i = 0; i < nb; i++)
result[i][k] = rhside[k][i];
}
for (i = 0; i < 2; i++) {
delete [] rhside[i];
delete [] old[i];
}
}