Example #1
0
void MPpar::transport(char *tg, MPpar *t1, int n1, int n2)
{
	MPpar *nt;
	MPparnode *nd[2];
	MPparnode *dd;
	int	i, j;

	// printf("Transporting from %d of %x to %d of %x\n", n2, this, n1, t1);

	// First make the new tree

	nd[0] = t1->nodes[n1];
	nd[1] = nodes[n2];

	nt = new MPpar(2, &nd[0]);
	nt->copy_options(this);
	dd = new MPparnode(tg, nt);

	// Replace the node in tree 1 with the new one

	t1->nodes[n1] = dd;

	// Remove the node from tree 2

	for (i = j = 0; i < num_nodes; i++)
	{
		if (i == n2) continue;
		nodes[j++] = nodes[i];
	}
	num_nodes--;

	set_owners();
}
Example #2
0
void MPpar::load_str(MPtag *mptag)
{
	int	i;
	int	nn = 0;

	nodes = new MPparnode *[mptag->num_words];

	for (i = 0; i < mptag->num_words; i++)
		nodes[i] = new MPparnode(mptag->tag(i), mptag->word(i));

	num_nodes = mptag->num_words;

	set_owners();
}
Example #3
0
void MPpar::load_str(char *tagstr)
{
	int	i;
	char	*tk, *tg, *s;

	int num_alloc = NUMNODES;
	nodes = (MPparnode **) malloc(num_alloc * sizeof(MPparnode *));

	num_nodes = 0;
	while (*tagstr)
	{
		while (isspace(*tagstr)) ++tagstr;
		if (! *tagstr) break;
		strcpy(buff, tagstr);

		s = &buff[0];

		tk = NULL;
		tg = s;

		while (*tagstr && isspace(*tagstr) == 0)
		{
			if (*tagstr == '_')
			{
				tk = tg;
				*s = '\0';
				tg = s + 1;
			}
			++tagstr;
			++s;
		}
		*s = '\0';
		if (num_nodes >= num_alloc)
		{
			num_alloc += NUMNODES;
			nodes = (MPparnode **) realloc((void *) nodes, num_alloc * sizeof(MPparnode *));
		}
		if (tk) nodes[num_nodes++] = new MPparnode(tg, tk);
	}

	set_owners();
}
Example #4
0
MPpar::MPpar(int nn, MPparnode **nd)
{
	alloc_workmem();

	nodes = new MPparnode*[nn];
	for (int i = 0; i < nn; i++) nodes[i] = nd[i];
	num_nodes = nn;
	owner = NULL;

	option_parens = 0;
	option_conj = 0;
	option_gerund = 0;
	option_rev = 0;
	option_postmod = 0;
	option_subparse = 0;
	option_printnull = 0;
	option_prep = 1;

	set_owners();
}
Example #5
0
static void swap3d_element_based(Mesh* mesh, AdaptOpts const& opts) {
  auto comm = mesh->comm();
  auto edges_are_keys = mesh->get_array<I8>(EDGE, "key");
  mesh->remove_tag(EDGE, "key");
  auto edges_configs = mesh->get_array<I8>(EDGE, "config");
  mesh->remove_tag(EDGE, "config");
  auto keys2edges = collect_marked(edges_are_keys);
  if (opts.verbosity >= EACH_REBUILD) {
    auto nkeys = keys2edges.size();
    auto ntotal_keys = comm->allreduce(GO(nkeys), OMEGA_H_SUM);
    if (comm->rank() == 0) {
      std::cout << "swapping " << ntotal_keys << " 3D edges\n";
    }
  }
  auto new_mesh = mesh->copy_meta();
  new_mesh.set_verts(mesh->nverts());
  new_mesh.set_owners(VERT, mesh->ask_owners(VERT));
  transfer_copy(mesh, &new_mesh, VERT);
  auto keys2prods = swap3d_keys_to_prods(mesh, keys2edges);
  auto prod_verts2verts =
      swap3d_topology(mesh, keys2edges, edges_configs, keys2prods);
  auto old_lows2new_lows = LOs(mesh->nverts(), 0, 1);
  for (Int ent_dim = EDGE; ent_dim <= mesh->dim(); ++ent_dim) {
    auto prods2new_ents = LOs();
    auto same_ents2old_ents = LOs();
    auto same_ents2new_ents = LOs();
    auto old_ents2new_ents = LOs();
    modify_ents(mesh, &new_mesh, ent_dim, EDGE, keys2edges, keys2prods[ent_dim],
        prod_verts2verts[ent_dim], old_lows2new_lows, &prods2new_ents,
        &same_ents2old_ents, &same_ents2new_ents, &old_ents2new_ents);
    transfer_swap(mesh, &new_mesh, ent_dim, keys2edges, keys2prods[ent_dim],
        prods2new_ents, same_ents2old_ents, same_ents2new_ents);
    old_lows2new_lows = old_ents2new_ents;
  }
  *mesh = new_mesh;
}