double *RefMap::get_jacobian(const int np, const QuadPt3D *pt, bool trans) { _F_ double *jac = new double[np]; MEM_CHECK(jac); if (is_const_jacobian) { if (trans) for (int i = 0; i < np; i++) jac[i] = const_jacobian * pt[i].w; else for (int i = 0; i < np; i++) jac[i] = const_jacobian; } else { double3x3 *m = get_ref_map(np, pt); double trj = get_transform_jacobian(); if (trans) for (int i = 0; i < np; i++) jac[i] = det(m[i]) * trj * pt[i].w; else for (int i = 0; i < np; i++) jac[i] = det(m[i]) * trj; delete [] m; } return jac; }
void RefMap::calc_face_normal(int iface, const int np, const QuadPt3D *pt, double *&nx, double *&ny, double *&nz) { _F_ assert(mesh != NULL); double3x3 *m = get_ref_map(np, pt); nx = new double[np]; MEM_CHECK(nx); ny = new double[np]; MEM_CHECK(ny); nz = new double[np]; MEM_CHECK(nz); // FIXME: refactor this! // - it would be nice if calculation of normals would be based on the same algorithm for all elements // e.g. to take a normal from ref. domain and transform it to the physical one int t_dir_1, t_dir_2; //directions of tangents ot the reference face such that t_dir_1 x t_dir_2 = outer normal switch (element->get_mode()) { case MODE_TETRAHEDRON: { const int *face_vtx = element->get_face_vertices(iface); Vertex vtx[Tri::NUM_VERTICES]; for (int i = 0; i < element->get_num_vertices(); i++) vtx[i] = vertex[face_vtx[i]]; Point3D v1 = { vtx[1].x - vtx[0].x, vtx[1].y - vtx[0].y, vtx[1].z - vtx[0].z }; Point3D v2 = { vtx[2].x - vtx[0].x, vtx[2].y - vtx[2].y, vtx[2].z - vtx[0].z }; Point3D n = normalize(cross_product(v1, v2)); for (int i = 0; i < np; i++) { nx[i] = n.x; ny[i] = n.y; nz[i] = n.z; } } break; case MODE_HEXAHEDRON: switch (iface) { case 0: t_dir_1 = 2; t_dir_2 = 1; break; case 1: t_dir_1 = 1; t_dir_2 = 2; break; case 2: t_dir_1 = 0; t_dir_2 = 2; break; case 3: t_dir_1 = 2; t_dir_2 = 0; break; case 4: t_dir_1 = 1; t_dir_2 = 0; break; case 5: t_dir_1 = 0; t_dir_2 = 1; break; } for (int i = 0; i < np; i++) { Point3D tangent1 = { m[i][0][t_dir_1], m[i][1][t_dir_1], m[i][2][t_dir_1] }; Point3D tangent2 = { m[i][0][t_dir_2], m[i][1][t_dir_2], m[i][2][t_dir_2] }; Point3D normal = normalize(cross_product(tangent1, tangent2)); nx[i] = normal.x; ny[i] = normal.y; nz[i] = normal.z; } break; case MODE_PRISM: EXIT(HERMES_ERR_NOT_IMPLEMENTED); } delete [] m; }
static int do_fetch(struct transport *transport, struct refspec *refs, int ref_count) { struct ref *ref_map; struct ref *rm; int autotags = (transport->remote->fetch_tags == 1); if (transport->remote->fetch_tags == 2 && tags != TAGS_UNSET) tags = TAGS_SET; if (transport->remote->fetch_tags == -1) tags = TAGS_UNSET; if (!transport->get_refs_list || !transport->fetch) die("Don't know how to fetch from %s", transport->url); /* if not appending, truncate FETCH_HEAD */ if (!append) { char *filename = git_path("FETCH_HEAD"); FILE *fp = fopen(filename, "w"); if (!fp) return error("cannot open %s: %s\n", filename, strerror(errno)); fclose(fp); } ref_map = get_ref_map(transport, refs, ref_count, tags, &autotags); if (!update_head_ok) check_not_current_branch(ref_map); for (rm = ref_map; rm; rm = rm->next) { if (rm->peer_ref) read_ref(rm->peer_ref->name, rm->peer_ref->old_sha1); } if (tags == TAGS_DEFAULT && autotags) transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, "1"); if (fetch_refs(transport, ref_map)) { free_refs(ref_map); return 1; } free_refs(ref_map); /* if neither --no-tags nor --tags was specified, do automated tag * following ... */ if (tags == TAGS_DEFAULT && autotags) { struct ref **tail = &ref_map; ref_map = NULL; find_non_local_tags(transport, &ref_map, &tail); if (ref_map) { transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, NULL); transport_set_option(transport, TRANS_OPT_DEPTH, "0"); fetch_refs(transport, ref_map); } free_refs(ref_map); } return 0; }
double3x3 *RefMap::get_inv_ref_map(const int np, const QuadPt3D *pt) { _F_ double3x3 *irm = new double3x3[np]; MEM_CHECK(irm); if (is_const_jacobian) { for (int i = 0; i < np; i++) memcpy(irm + i, const_inv_ref_map, sizeof(double3x3)); } else { double3x3 *m = get_ref_map(np, pt); double trj = get_transform_jacobian(); double *jac = new double[np]; MEM_CHECK(jac); for (int i = 0; i < np; i++) { jac[i] = det(m[i]); double ij = 1.0 / jac[i]; irm[i][0][0] = (m[i][1][1] * m[i][2][2] - m[i][1][2] * m[i][2][1]) * ij; irm[i][1][0] = (m[i][0][2] * m[i][2][1] - m[i][0][1] * m[i][2][2]) * ij; irm[i][2][0] = (m[i][0][1] * m[i][1][2] - m[i][0][2] * m[i][1][1]) * ij; irm[i][0][1] = (m[i][1][2] * m[i][2][0] - m[i][1][0] * m[i][2][2]) * ij; irm[i][1][1] = (m[i][0][0] * m[i][2][2] - m[i][0][2] * m[i][2][0]) * ij; irm[i][2][1] = (m[i][0][2] * m[i][1][0] - m[i][0][0] * m[i][1][2]) * ij; irm[i][0][2] = (m[i][1][0] * m[i][2][1] - m[i][1][1] * m[i][2][0]) * ij; irm[i][1][2] = (m[i][0][1] * m[i][2][0] - m[i][0][0] * m[i][2][1]) * ij; irm[i][2][2] = (m[i][0][0] * m[i][1][1] - m[i][0][1] * m[i][1][0]) * ij; jac[i] *= trj; } delete [] m; delete [] jac; } return irm; }
static int do_fetch(struct transport *transport, struct refspec *refs, int ref_count) { struct string_list existing_refs = { NULL, 0, 0, 0 }; struct string_list_item *peer_item = NULL; struct ref *ref_map; struct ref *rm; int autotags = (transport->remote->fetch_tags == 1); for_each_ref(add_existing, &existing_refs); if (transport->remote->fetch_tags == 2 && tags != TAGS_UNSET) tags = TAGS_SET; if (transport->remote->fetch_tags == -1) tags = TAGS_UNSET; if (!transport->get_refs_list || !transport->fetch) die("Don't know how to fetch from %s", transport->url); /* if not appending, truncate FETCH_HEAD */ if (!append && !dry_run) { int errcode = truncate_fetch_head(); if (errcode) return errcode; } ref_map = get_ref_map(transport, refs, ref_count, tags, &autotags); if (!update_head_ok) check_not_current_branch(ref_map); for (rm = ref_map; rm; rm = rm->next) { if (rm->peer_ref) { peer_item = string_list_lookup(rm->peer_ref->name, &existing_refs); if (peer_item) hashcpy(rm->peer_ref->old_sha1, peer_item->util); } } if (tags == TAGS_DEFAULT && autotags) transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, "1"); if (fetch_refs(transport, ref_map)) { free_refs(ref_map); return 1; } if (prune) prune_refs(transport, ref_map); free_refs(ref_map); /* if neither --no-tags nor --tags was specified, do automated tag * following ... */ if (tags == TAGS_DEFAULT && autotags) { struct ref **tail = &ref_map; ref_map = NULL; find_non_local_tags(transport, &ref_map, &tail); if (ref_map) { transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, NULL); transport_set_option(transport, TRANS_OPT_DEPTH, "0"); fetch_refs(transport, ref_map); } free_refs(ref_map); } return 0; }