inline iMesh::Error iMesh::getEntAdj( EntityHandle handle, EntityType type_requested, std::vector<EntityHandle>& adj_entities_out ) const { if (adj_entities_out.capacity() == 0) adj_entities_out.resize(12); else adj_entities_out.resize( adj_entities_out.capacity() ); int err, alloc = adj_entities_out.size(), size = 0; EntityHandle* ptr = &adj_entities_out[0]; iMesh_getEntAdj( mInstance, handle, type_requested, &ptr, &alloc, &size, &err ); adj_entities_out.resize(size); if (iBase_BAD_ARRAY_DIMENSION == err || iBase_BAD_ARRAY_SIZE == err) { alloc = adj_entities_out.size(); ptr = &adj_entities_out[0]; iMesh_getEntAdj( mInstance, handle, type_requested, &ptr, &alloc, &size, &err ); } return (Error)err; }
/*! * \brief Determine if an entity is inside a bounding box. The entire element * must be in the box. */ bool Octree::isEntInBox( const Box &box, iBase_EntityHandle entity ) { int error = 0; bool return_val = true; iBase_EntityHandle *element_nodes = 0; int element_nodes_allocated = 0; int element_nodes_size = 0; iMesh_getEntAdj( d_mesh, entity, iBase_VERTEX, &element_nodes, &element_nodes_allocated, &element_nodes_size, &error ); assert( iBase_SUCCESS == error ); int coords_allocated = element_nodes_size*3; int coords_size = 0; double *coord_array = 0; iMesh_getVtxArrCoords( d_mesh, element_nodes, element_nodes_size, iBase_INTERLEAVED, &coord_array, &coords_allocated, &coords_size, &error ); assert( iBase_SUCCESS == error ); int n = 0; while ( n < element_nodes_size && return_val ) { if ( !( coord_array[3*n] >= box[0] && coord_array[3*n] <= box[1] && coord_array[3*n+1] >= box[2] && coord_array[3*n+1] <= box[3] && coord_array[3*n+2] >= box[4] && coord_array[3*n+2] <= box[5] ) ) { return_val = false; } ++n; } free( element_nodes ); free( coord_array ); return return_val; }
void IntrepidKernel<Scalar>::jacobianDet( Scalar &determinant, const double param_coords[3], const iMesh_Instance mesh, const iBase_EntityHandle physical_cell ) { int error = 0; iBase_EntityHandle *element_nodes = 0; int element_nodes_allocated = 0; int element_nodes_size = 0; iMesh_getEntAdj( mesh, physical_cell, iBase_VERTEX, &element_nodes, &element_nodes_allocated, &element_nodes_size, &error ); assert( iBase_SUCCESS == error ); TopologyTools::MBCN2Shards( element_nodes, element_nodes_size, this->b_topology ); int coords_allocated = 0; int coords_size = 0; double *coord_array = 0; iMesh_getVtxArrCoords( mesh, element_nodes, element_nodes_size, iBase_INTERLEAVED, &coord_array, &coords_allocated, &coords_size, &error ); assert( iBase_SUCCESS == error ); Teuchos::Tuple<int,3> cell_node_dimensions; cell_node_dimensions[0] = 1; cell_node_dimensions[1] = element_nodes_size; cell_node_dimensions[2] = 3; MDArray cell_nodes( Teuchos::Array<int>(cell_node_dimensions), coord_array ); MDArray reference_coords( 1, 3 ); reference_coords(0,0) = param_coords[0]; reference_coords(0,1) = param_coords[1]; reference_coords(0,2) = param_coords[2]; MDArray jacobian( 1, 1, 3, 3 ); Intrepid::CellTools<double>::setJacobian( jacobian, reference_coords, cell_nodes, d_intrepid_basis->getBaseCellTopology() ); MDArray jacobian_det( 1, 1 ); Intrepid::CellTools<double>::setJacobianDet( jacobian_det, jacobian ); determinant = jacobian_det(0,0); free( element_nodes ); free( coord_array ); }
void IntrepidKernel<Scalar>::transformOperator( Teuchos::ArrayRCP<Scalar> &transformed_values, const Teuchos::ArrayRCP<Scalar> &values, const double param_coords[3], const iMesh_Instance mesh, const iBase_EntityHandle physical_cell ) { int error = 0; iBase_EntityHandle *element_nodes = 0; int element_nodes_allocated = 0; int element_nodes_size = 0; iMesh_getEntAdj( mesh, physical_cell, iBase_VERTEX, &element_nodes, &element_nodes_allocated, &element_nodes_size, &error ); assert( iBase_SUCCESS == error ); TopologyTools::MBCN2Shards( element_nodes, element_nodes_size, this->b_topology ); int coords_allocated = 0; int coords_size = 0; double *coord_array = 0; iMesh_getVtxArrCoords( mesh, element_nodes, element_nodes_size, iBase_INTERLEAVED, &coord_array, &coords_allocated, &coords_size, &error ); assert( iBase_SUCCESS == error ); Teuchos::Tuple<int,3> cell_node_dimensions; cell_node_dimensions[0] = 1; cell_node_dimensions[1] = element_nodes_size; cell_node_dimensions[2] = 3; MDArray cell_nodes( Teuchos::Array<int>(cell_node_dimensions), coord_array ); MDArray jacobian( 1, 1, 3, 3 ); MDArray jacobian_det( 1, 1 ); MDArray jacobian_inv( 1, 1, 3, 3 ); MDArray reference_point( 1, 3 ); reference_point(0,0) = param_coords[0]; reference_point(0,1) = param_coords[1]; reference_point(0,2) = param_coords[2]; if ( this->b_function_space_type == FOOD_HGRAD ) { Intrepid::CellTools<double>::setJacobian( jacobian, reference_point, cell_nodes, d_intrepid_basis->getBaseCellTopology() ); Intrepid::CellTools<double>::setJacobianInv( jacobian_inv, jacobian ); MDArray transformed_grad( 1, this->b_cardinality, 1, 3 ); Teuchos::Tuple<int,3> grad_dimensions; grad_dimensions[0] = this->b_cardinality; grad_dimensions[1] = 1; grad_dimensions[2] = 3; MDArray basis_grad( grad_dimensions, values ); Intrepid::FunctionSpaceTools::HGRADtransformGRAD<double>( transformed_grad, jacobian_inv, basis_grad ); transformed_values = transformed_grad.getData(); } else if ( this->b_function_space_type == FOOD_HDIV ) { } else if ( this->b_function_space_type == FOOD_HCURL ) { } else { testPrecondition( this->b_function_space_type == FOOD_HGRAD || this->b_function_space_type == FOOD_HDIV || this->b_function_space_type == FOOD_HCURL, "Invalid function space type" ); } free( coord_array ); free( element_nodes ); }
void IntrepidKernel<Scalar>::transformPoint( double param_coords[3], const double physical_coords[3], const iMesh_Instance mesh, const iBase_EntityHandle physical_cell ) { int error = 0; iBase_EntityHandle *element_nodes = 0; int element_nodes_allocated = 0; int element_nodes_size = 0; iMesh_getEntAdj( mesh, physical_cell, iBase_VERTEX, &element_nodes, &element_nodes_allocated, &element_nodes_size, &error ); assert( iBase_SUCCESS == error ); TopologyTools::MBCN2Shards( element_nodes, element_nodes_size, this->b_topology ); int coords_allocated = 0; int coords_size = 0; double *coord_array = 0; iMesh_getVtxArrCoords( mesh, element_nodes, element_nodes_size, iBase_INTERLEAVED, &coord_array, &coords_allocated, &coords_size, &error ); assert( iBase_SUCCESS == error ); Teuchos::Tuple<int,3> cell_node_dimensions; cell_node_dimensions[0] = 1; cell_node_dimensions[1] = element_nodes_size; cell_node_dimensions[2] = 3; MDArray cell_nodes( Teuchos::Array<int>(cell_node_dimensions), coord_array ); MDArray reference_point( 1, 3 ); MDArray coords( 1, 3 ); coords(0,0) = physical_coords[0]; coords(0,1) = physical_coords[1]; coords(0,2) = physical_coords[2]; Intrepid::CellTools<double>::mapToReferenceFrame( reference_point, coords, cell_nodes, d_intrepid_basis->getBaseCellTopology(), 0 ); param_coords[0] = reference_point(0,0); param_coords[1] = reference_point(0,1); param_coords[2] = reference_point(0,2); free( element_nodes ); free( coord_array ); }