Exemplo n.º 1
0
void Elem::coarsen()
{
  libmesh_assert (this->refinement_flag() == Elem::COARSEN_INACTIVE);
  libmesh_assert (!this->active());

  // We no longer delete children until MeshRefinement::contract()
  // delete [] _children;
  // _children = NULL;

  unsigned int parent_p_level = 0;

  // re-compute hanging node nodal locations
  for (unsigned int c=0; c<this->n_children(); c++)
  {
    Elem *mychild = this->child(c);
    if (mychild == remote_elem)
      continue;
    for (unsigned int nc=0; nc<mychild->n_nodes(); nc++)
    {
      Point new_pos;
      bool calculated_new_pos = false;

      for (unsigned int n=0; n<this->n_nodes(); n++)
      {
        // The value from the embedding matrix
        const float em_val = this->embedding_matrix(c,nc,n);

        // The node location is somewhere between existing vertices
        if ((em_val != 0.) && (em_val != 1.))
        {
	  new_pos.add_scaled (this->point(n), em_val);
	  calculated_new_pos = true;
        }
      }

      if(calculated_new_pos)
      {
	//Move the existing node back into it's original location
	for(unsigned int i=0; i<LIBMESH_DIM; i++)
	{
	  Point & child_node = *(mychild->get_node(nc));
	  child_node(i)=new_pos(i);
	}
      }
    }
  }

  for (unsigned int c=0; c<this->n_children(); c++)
    {
      Elem *mychild = this->child(c);
      if (mychild == remote_elem)
        continue;
      libmesh_assert (mychild->refinement_flag() == Elem::COARSEN);
      mychild->set_refinement_flag(Elem::INACTIVE);
      if (mychild->p_level() > parent_p_level)
        parent_p_level = mychild->p_level();
    }

  this->set_refinement_flag(Elem::JUST_COARSENED);
  this->set_p_level(parent_p_level);

  libmesh_assert (this->active());
}
Exemplo n.º 2
0
/* Check if the response is an error, redirect response
 * or it includes a warning
 * @param response - the LoST response body
 * @param resp_type - the response type: ERROR, REDIRECT, WARNING or OK
 * @returns the root node of the parsed xml body
 */ 
xmlNode* get_LoST_resp_type(str response, lost_resp_type * resp_type, str * reason){
			
	xmlNode * root, * node, * child;

	reason->s = NULL;
	reason->len = 0;

	root = xml_parse_string(response);
	if(!root)
		return root;

#ifdef LOST_DEBUG	
	print_element_names(root);
#endif

	if(strcmp((char*)root->name, LOST_ERR_NODE_NAME) == 0){
		DEBUG_LOG("LoST response has an error response\n");
		
		node = child_node(root);
		if(node){
			DEBUG_LOG("reason %s\n", node->name);
			reason->s = (char*)node->name;
			reason->len = strlen(reason->s);			
#ifdef LOST_DEBUG
			print_attr(node, LOST_MSG_ATTR_NAME);
#endif
		}else {
			DEBUG_LOG("the message has no reason\n");
		}

		*resp_type = LOST_ERR;

	} else if(strcmp((char*)root->name, LOST_REDIR_NODE_NAME) == 0){

		DEBUG_LOG("LoST response has a redirect response\n");
#ifdef LOST_DEBUG		
		print_attr(root, LOST_TGT_ATTR_NAME);
#endif
		*resp_type = LOST_REDIR;

	} else 	if(strcmp((char*)root->name, LOST_FINDSRESP_NODE_NAME) != 0){

		ERROR_LOG("invalid LoST response\n");
		*resp_type = LOST_ERR;

	} else {
		
		node = child_named_node(root, LOST_WRNG_NODE_NAME);
		if(node){
			DEBUG_LOG("LoST response has a response with warning\n");
			if((child = child_node(node))){
				DEBUG_LOG("reason %s\n", child->name);
				reason->s = (char*)child->name;
				reason->len = strlen(reason->s);			
#ifdef LOST_DEBUG
				print_attr(node, LOST_MSG_ATTR_NAME);
#endif
			}else {
				DEBUG_LOG("warning without reason\n");
			}

			*resp_type = LOST_WRNG;
		}else
			*resp_type = LOST_OK;
	}

	return root;
}