//---------------------------------------------------------------------------//
// Create the function space.
void STKMeshManager::createFunctionSpace( 
    const BasisType basis_type,
    const PredicateFunction& select_function )
{
    Teuchos::RCP<EntitySet> entity_set = 
	Teuchos::rcp( new STKMeshEntitySet(d_bulk_data) );
    
    Teuchos::RCP<EntityLocalMap> local_map =
	Teuchos::rcp( new STKMeshEntityLocalMap(d_bulk_data) );

    Teuchos::RCP<EntityShapeFunction> shape_function;
    switch( basis_type )
    {
	case BASIS_TYPE_GRADIENT:
	    shape_function = 
		Teuchos::rcp( new STKMeshNodalShapeFunction(d_bulk_data) );
	    break;

	default:
	    bool bad_basis_type = true;
	    DTK_INSIST( !bad_basis_type );
	    break;
    }
    DTK_CHECK( Teuchos::nonnull(shape_function) );

    Teuchos::RCP<EntityIntegrationRule> integration_rule =
	Teuchos::rcp( new STKMeshEntityIntegrationRule(d_bulk_data) );

    d_function_space = Teuchos::rcp( 
	new FunctionSpace(entity_set,local_map,shape_function,
			  integration_rule,select_function) );

    DTK_ENSURE( Teuchos::nonnull(d_function_space) );
}
//---------------------------------------------------------------------------//
// Determine if a reference point is in the parameterized space of an entity.
bool STKMeshEntityLocalMap::checkPointInclusion( 
    const Entity& entity,
    const Teuchos::ArrayView<const double>& reference_point ) const
{
    // Get the test tolerance.
    double tolerance = 1.0e-6; 
    if ( Teuchos::nonnull(this->b_parameters) )  
    {	
	if ( this->b_parameters->isParameter("Point Inclusion Tolerance") )
	{	    
	    tolerance = 	
		this->b_parameters->get<double>("Point Inclusion Tolerance");
	}
    }

    // Get the STK entity and its topology.
    const stk::mesh::Entity& stk_entity = STKMeshHelpers::extractEntity(entity);
    stk::mesh::EntityRank rank = d_bulk_data->entity_rank(stk_entity);
    shards::CellTopology entity_topo = 
	stk::mesh::get_cell_topology(
	    d_bulk_data->bucket(stk_entity).topology() );

    // Check point inclusion in the element.
    if ( rank == stk::topology::ELEM_RANK )
    {
	return IntrepidCellLocalMap::checkPointInclusion( 
	    entity_topo, reference_point, tolerance );
    }

    // Check point inclusion in the face.
    else if ( rank == stk::topology::FACE_RANK )
    {
	bool not_implemented = true;
	DTK_INSIST( !not_implemented );
	return false;
    }

    // Check for unsupported ranks.
    else
    {
	bool bad_rank = true;
	DTK_INSIST( !bad_rank );
	return false;
    }

    return false;
}
//---------------------------------------------------------------------------//
// Given an entity and a reference point, evaluate the shape function of the
// entity at that point.
void EntityShapeFunction::evaluateValue( 
    const Entity& entity,
    const Teuchos::ArrayView<const double>& reference_point,
    Teuchos::Array<double>& values ) const
{
    bool not_implemented = true;
    DTK_INSIST( !not_implemented );
}
//---------------------------------------------------------------------------//
// Given an entity, get the entities of the given type that are adjacent to
// it. 
void POD_PointCloudEntitySet::getAdjacentEntities(
    const Entity& entity,
    const int adjacent_dimension,
    Teuchos::Array<Entity>& adjacent_entities ) const
{
    // There is no adjacency information in a point cloud.
    DTK_INSIST( false );
}
//---------------------------------------------------------------------------//
// Compute the normal on a face (3D) or edge (2D) at a given reference point.
void MoabEntityLocalMap::normalAtReferencePoint( 
    const Entity& entity,
    const Entity& parent_entity,
    const Teuchos::ArrayView<const double>& reference_point,
    const Teuchos::ArrayView<double>& normal ) const
{
	bool not_implemented = true;
	DTK_INSIST( !not_implemented );
}
//---------------------------------------------------------------------------//
// Return the centroid of the entity.
void STKMeshEntityLocalMap::centroid( 
    const Entity& entity, const Teuchos::ArrayView<double>& centroid ) const
{ 
    // Get the STK entity.
    const stk::mesh::Entity& stk_entity = STKMeshHelpers::extractEntity(entity);
    stk::mesh::EntityRank rank = d_bulk_data->entity_rank(stk_entity);

    // Extract the centroid of the element.
    if ( rank == stk::topology::ELEM_RANK )
    {
	shards::CellTopology entity_topo = 
	    stk::mesh::get_cell_topology(
		d_bulk_data->bucket(stk_entity).topology() );
	Intrepid::FieldContainer<double> entity_coords = 
	    STKMeshHelpers::getEntityNodeCoordinates(
		Teuchos::Array<stk::mesh::Entity>(1,stk_entity), *d_bulk_data );
	IntrepidCellLocalMap::centroid( 
	    entity_topo, entity_coords, centroid );
    }

    // Extract the centroid of the face.
    else if ( rank == stk::topology::FACE_RANK )
    {
	bool not_implemented = true;
	DTK_INSIST( !not_implemented );
    }

    // The centroid of a node is the node coordinates.
    else if ( rank == stk::topology::NODE_RANK )
    {
	Intrepid::FieldContainer<double> entity_coords = 
	    STKMeshHelpers::getEntityNodeCoordinates(
		Teuchos::Array<stk::mesh::Entity>(1,stk_entity), *d_bulk_data );
	centroid.assign( entity_coords.getData()() );
    }

    // Check for unsupported ranks.
    else
    {
	bool bad_rank = true;
	DTK_INSIST( !bad_rank );
    }
}
//---------------------------------------------------------------------------//
// Map a point to the reference space of an entity. Return the parameterized
// point.
bool STKMeshEntityLocalMap::mapToReferenceFrame( 
    const Entity& entity,
    const Teuchos::ArrayView<const double>& point,
    const Teuchos::ArrayView<double>& reference_point,
    const Teuchos::RCP<MappingStatus>& status ) const
{
    // Get the STK entity.
    const stk::mesh::Entity& stk_entity = STKMeshHelpers::extractEntity(entity);
    stk::mesh::EntityRank rank = d_bulk_data->entity_rank(stk_entity);

    // Use the cell to perform the element mapping.
    if ( rank == stk::topology::ELEM_RANK )
    {
	shards::CellTopology entity_topo = 
	    stk::mesh::get_cell_topology(
		d_bulk_data->bucket(stk_entity).topology() );
	Intrepid::FieldContainer<double> entity_coords = 
	    STKMeshHelpers::getEntityNodeCoordinates(
		Teuchos::Array<stk::mesh::Entity>(1,stk_entity), *d_bulk_data );
	IntrepidCellLocalMap::mapToReferenceFrame(
	    entity_topo, entity_coords, point, reference_point );
    }

    // Use the side cell to perform the face mapping.
    else if ( rank == stk::topology::FACE_RANK )
    {
	bool not_implemented = true;
	DTK_INSIST( !not_implemented );
	return false;
    }

    // Check for unsupported ranks.
    else
    {
	bool bad_rank = true;
	DTK_INSIST( !bad_rank );
    }

    // Return true to indicate successful mapping. Catching Intrepid errors
    // and returning false is a possibility here.
    return true;
}
//---------------------------------------------------------------------------//
// Compute the normal on a face (3D) or edge (2D) at a given reference point.
void STKMeshEntityLocalMap::normalAtReferencePoint( 
    const Entity& entity,
    const Teuchos::ArrayView<double>& reference_point,
    const Teuchos::ArrayView<double>& normal ) const
{
    // Get the STK entity.
    const stk::mesh::Entity& stk_entity = STKMeshHelpers::extractEntity(entity);
    stk::mesh::EntityRank rank = d_bulk_data->entity_rank(stk_entity);

    // We can only compute normals for faces.
    if ( rank == stk::topology::FACE_RANK )
    {
	bool not_implemented = true;
	DTK_INSIST( !not_implemented );
    }

    // Check for unsupported ranks.
    else
    {
	bool bad_rank = true;
	DTK_INSIST( !bad_rank );
    }
}
//---------------------------------------------------------------------------//
// Return the entity measure with respect to the parameteric dimension (volume
// for a 3D entity, area for 2D, and length for 1D). 
double STKMeshEntityLocalMap::measure( const Entity& entity ) const
{
    // Get the STK entity and its topology.
    const stk::mesh::Entity& stk_entity = STKMeshHelpers::extractEntity(entity);
    stk::mesh::EntityRank rank = d_bulk_data->entity_rank(stk_entity);
    shards::CellTopology entity_topo = 
	stk::mesh::get_cell_topology(
	    d_bulk_data->bucket(stk_entity).topology() );

    // Get the STK entity coordinates.
    Intrepid::FieldContainer<double> entity_coords = 
	STKMeshHelpers::getEntityNodeCoordinates(
	    Teuchos::Array<stk::mesh::Entity>(1,stk_entity), *d_bulk_data );
    
    // Compute the measure of the element.
    if ( rank == stk::topology::ELEM_RANK )
    {
	return IntrepidCellLocalMap::measure( entity_topo, entity_coords );
    }

    // Compute the measure of the face.
    else if ( rank == stk::topology::FACE_RANK )
    {
	bool not_implemented = true;
	DTK_INSIST( !not_implemented );
	return -1.0;
    }

    // Check for unsupported ranks.
    else
    {
	bool bad_rank = true;
	DTK_INSIST( !bad_rank );
	return - 1.0;
    }
    return -1.0;
}
//---------------------------------------------------------------------------//
// Map a reference point to the physical space of an entity.
void STKMeshEntityLocalMap::mapToPhysicalFrame( 
    const Entity& entity,
    const Teuchos::ArrayView<const double>& reference_point,
    const Teuchos::ArrayView<double>& point ) const
{
    // Get the STK entity.
    const stk::mesh::Entity& stk_entity = STKMeshHelpers::extractEntity(entity);
    stk::mesh::EntityRank rank = d_bulk_data->entity_rank(stk_entity);

    // Map from the element.
    if ( rank == stk::topology::ELEM_RANK )
    {
	shards::CellTopology entity_topo = 
	    stk::mesh::get_cell_topology(
		d_bulk_data->bucket(stk_entity).topology() );
	Intrepid::FieldContainer<double> entity_coords = 
	    STKMeshHelpers::getEntityNodeCoordinates(
		Teuchos::Array<stk::mesh::Entity>(1,stk_entity), *d_bulk_data );
	IntrepidCellLocalMap::mapToPhysicalFrame( 
	    entity_topo, entity_coords, reference_point, point );
    }

    // Map from the face.
    else if ( rank == stk::topology::FACE_RANK )
    {
	bool not_implemented = true;
	DTK_INSIST( !not_implemented );
    }

    // Check for unsupported ranks.
    else
    {
	bool bad_rank = true;
	DTK_INSIST( !bad_rank );
    }
}
//---------------------------------------------------------------------------//
// Perform a safeguard check for mapping a point to the reference space
// of an entity using the given tolerance. 
bool STKMeshEntityLocalMap::isSafeToMapToReferenceFrame(
    const Entity& entity,
    const Teuchos::ArrayView<const double>& point,
    const Teuchos::RCP<MappingStatus>& status ) const
{
    // Get the STK entity.
    const stk::mesh::Entity& stk_entity = STKMeshHelpers::extractEntity(entity);
    stk::mesh::EntityRank rank = d_bulk_data->entity_rank(stk_entity);

    // If we have an element, use the default implementation.
    if ( rank == stk::topology::ELEM_RANK )
    {
	return 
	    EntityLocalMap::isSafeToMapToReferenceFrame( entity, point, status );
    }

    // If we have a face, perform the projection safeguard.
    else if ( rank == stk::topology::FACE_RANK )
    {
	bool not_implemented = true;
	DTK_INSIST( !not_implemented );
	return false;
    }

    // Check for unsupported ranks.
    else
    {
	bool bad_rank = true;
	DTK_INSIST( !bad_rank );
	return false;
    }

    // Return true to indicate successful mapping. Catching Intrepid errors
    // and returning false is a possibility here.
    return true;
}
//---------------------------------------------------------------------------//
// Perform a safeguard check for mapping a point to the reference space
// of an entity using the given tolerance. 
bool MoabEntityLocalMap::isSafeToMapToReferenceFrame(
    const Entity& entity,
    const Teuchos::ArrayView<const double>& physical_point ) const
{
    int space_dim = entity.physicalDimension();
    int param_dim = d_moab_mesh->get_moab()->dimension_from_handle(
	MoabHelpers::extractEntity(entity) );
    if ( space_dim == param_dim )
    {
	return EntityLocalMap::isSafeToMapToReferenceFrame(
	    entity, physical_point );
    }
    else
    {
	bool not_implemented = true;
	DTK_INSIST( !not_implemented );
    }
    return false;
}
void IntrepidSideCell<MDArray>::updateCellState()
{
    unsigned space_dim = d_parent_topology.getDimension();

    // Compute the Jacobian.
    Intrepid::CellTools<Scalar>::setJacobian( 
	this->d_jacobian, this->d_cub_points, 
	this->d_cell_node_coords, d_parent_topology );

    // Compute the cell side measures.
    switch ( space_dim )
    {

	case 3:
	{
	    // Face case.
	    Intrepid::FunctionSpaceTools::computeFaceMeasure<Scalar>( 
		this->d_weighted_measures, this->d_jacobian, 
		this->d_cub_weights, d_side_id, d_parent_topology );
	}
	break;

	case 2:
	{
	    // Edge case.
	    Intrepid::FunctionSpaceTools::computeEdgeMeasure<Scalar>( 
		this->d_weighted_measures, this->d_jacobian,
		this->d_cub_weights, d_side_id, d_parent_topology );
	}
	break;

	default:
	    DTK_INSIST( 3 == space_dim || 2 == space_dim,
			  "Subcell cell not supported for dimension" );
	    break;
    }

    // Compute physical frame integration point coordinates.
    Intrepid::CellTools<Scalar>::mapToPhysicalFrame( 
	this->d_physical_ip_coordinates, this->d_cub_points, 
	this->d_cell_node_coords, d_parent_topology );
}
Exemple #14
0
//---------------------------------------------------------------------------//
// Test the assertion check for DBC.
TEUCHOS_UNIT_TEST( DataTransferKitException, assertion_test )
{
    try 
    {
	DTK_INSIST( 0 );
	throw std::runtime_error( "this shouldn't be thrown" );
    }
    catch( const DataTransferKit::DataTransferKitException& assertion )
    {
	std::string message( assertion.what() );
	std::string true_message( "DataTransferKit DataTransferKitException: 0, failed in" );
	std::string::size_type idx = message.find( true_message );
	if ( idx == std::string::npos )
	{
	    TEST_ASSERT( 0 );
	}
    }
    catch( ... )
    {
	TEST_ASSERT( 0 );
    }
}
//---------------------------------------------------------------------------//
// Given an entity, get the ids of the degrees of freedom in the vector space
// supporting its shape function.
void EntityShapeFunction::entityDOFIds( 
    const Entity& entity, Teuchos::Array<std::size_t>& dof_ids ) const
{
    bool not_implemented = true;
    DTK_INSIST( !not_implemented );
}
//---------------------------------------------------------------------------//
Teuchos::RCP<Intrepid::Basis<double,Intrepid::FieldContainer<double> > > 
IntrepidBasisFactory::create( const shards::CellTopology& cell_topo )
{

    Teuchos::RCP<Intrepid::Basis<double,Intrepid::FieldContainer<double> > > basis;
    
    switch( cell_topo.getKey() ){
      
	case shards::Line<2>::key:
	    basis = Teuchos::rcp( 
		new Intrepid::Basis_HGRAD_LINE_C1_FEM<
		double,Intrepid::FieldContainer<double> >() );
	    break;

	case shards::Triangle<3>::key:
	    basis = Teuchos::rcp( 
		new Intrepid::Basis_HGRAD_TRI_C1_FEM<
		double,Intrepid::FieldContainer<double> >() );
	    break;

	case shards::Triangle<6>::key:    
	    basis = Teuchos::rcp( 
		new Intrepid::Basis_HGRAD_TRI_C2_FEM<
		double,Intrepid::FieldContainer<double> >() );
	    break;
        
	case shards::Quadrilateral<4>::key:
	    basis = Teuchos::rcp( 
		new Intrepid::Basis_HGRAD_QUAD_C1_FEM<
		double,Intrepid::FieldContainer<double> >() );
	    break;
        
	case shards::Quadrilateral<9>::key:
	    basis = Teuchos::rcp( 
		new Intrepid::Basis_HGRAD_QUAD_C2_FEM<
		double,Intrepid::FieldContainer<double> >() );
	    break;
        
	case shards::Tetrahedron<4>::key:
	    basis = Teuchos::rcp( 
		new Intrepid::Basis_HGRAD_TET_C1_FEM<
		double,Intrepid::FieldContainer<double> >() );
	    break;
        
	case shards::Tetrahedron<10>::key:
	    basis = Teuchos::rcp( 
		new Intrepid::Basis_HGRAD_TET_C2_FEM<
		double,Intrepid::FieldContainer<double> >() );
	    break;
        
	case shards::Hexahedron<8>::key:
	    basis = Teuchos::rcp( 
		new Intrepid::Basis_HGRAD_HEX_C1_FEM<
		double,Intrepid::FieldContainer<double> >() );
	    break;

	case shards::Hexahedron<27>::key:
	    basis = Teuchos::rcp( 
		new Intrepid::Basis_HGRAD_HEX_C2_FEM<
		double,Intrepid::FieldContainer<double> >() );
	    break;
              
	case shards::Wedge<6>::key:
	    basis = Teuchos::rcp( 
		new Intrepid::Basis_HGRAD_WEDGE_C1_FEM<
		double,Intrepid::FieldContainer<double> >() );
	    break;
        
	case shards::Wedge<18>::key:
	    basis = Teuchos::rcp( 
		new Intrepid::Basis_HGRAD_WEDGE_C2_FEM<
		double,Intrepid::FieldContainer<double> >() );
	    break;

	case shards::Pyramid<5>::key:
	case shards::Pyramid<13>::key:
	case shards::Pyramid<14>::key:
	    basis = Teuchos::rcp( 
		new Intrepid::Basis_HGRAD_PYR_C1_FEM<
		double,Intrepid::FieldContainer<double> >() );
	    break;

	default:
	    bool topology_supported = false;
	    DTK_INSIST( topology_supported );
	    break;
    }

    return basis;
}