DataTransferKit - Multiphysics Solution Transfer Services  2.0
DTK_IntrepidSideCell.cpp
Go to the documentation of this file.
1 //---------------------------------------------------------------------------//
2 /*
3  Copyright (c) 2012, Stuart R. Slattery
4  All rights reserved.
5 
6  Redistribution and use in source and binary forms, with or without
7  modification, are permitted provided that the following conditions are
8  met:
9 
10  *: Redistributions of source code must retain the above copyright
11  notice, this list of conditions and the following disclaimer.
12 
13  *: Redistributions in binary form must reproduce the above copyright
14  notice, this list of conditions and the following disclaimer in the
15  documentation and/or other materials provided with the distribution.
16 
17  *: Neither the name of the University of Wisconsin - Madison nor the
18  names of its contributors may be used to endorse or promote products
19  derived from this software without specific prior written permission.
20 
21  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33 //---------------------------------------------------------------------------//
39 //---------------------------------------------------------------------------//
40 
41 #include "DTK_IntrepidSideCell.hpp"
42 #include "DTK_DBC.hpp"
43 
44 #include <Teuchos_as.hpp>
45 
46 #include <Intrepid_CellTools.hpp>
47 #include <Intrepid_DefaultCubatureFactory.hpp>
48 #include <Intrepid_FunctionSpaceTools.hpp>
49 
50 namespace DataTransferKit
51 {
52 //---------------------------------------------------------------------------//
56 IntrepidSideCell::IntrepidSideCell( const shards::CellTopology &side_topology,
57  const unsigned side_id,
58  const shards::CellTopology &parent_topology,
59  const unsigned degree )
60  : Base( side_topology, degree )
61  , d_side_id( side_id )
62  , d_parent_topology( parent_topology )
63 {
64  // Map the side cubature points to the cell frame.
65  MDArray mapped_cub_points( this->d_cubature->getNumPoints(),
66  parent_topology.getDimension() );
67  Intrepid::CellTools<Scalar>::mapToReferenceSubcell(
68  mapped_cub_points, this->d_cub_points, side_topology.getDimension(),
69  d_side_id, d_parent_topology );
70  this->d_cub_points = mapped_cub_points;
71 }
72 
73 //---------------------------------------------------------------------------//
79 {
80  unsigned space_dim = d_parent_topology.getDimension();
81 
82  // Compute the Jacobian.
83  Intrepid::CellTools<Scalar>::setJacobian(
84  this->d_jacobian, this->d_cub_points, this->d_cell_node_coords,
85  d_parent_topology );
86 
87  // Compute the cell side measures.
88  switch ( space_dim )
89  {
90  case 3:
91  {
92  // Face case.
93  Intrepid::FunctionSpaceTools::computeFaceMeasure<Scalar>(
94  this->d_weighted_measures, this->d_jacobian, this->d_cub_weights,
95  d_side_id, d_parent_topology );
96  }
97  break;
98 
99  case 2:
100  {
101  // Edge case.
102  Intrepid::FunctionSpaceTools::computeEdgeMeasure<Scalar>(
103  this->d_weighted_measures, this->d_jacobian, this->d_cub_weights,
104  d_side_id, d_parent_topology );
105  }
106  break;
107 
108  default:
109  DTK_INSIST( 3 == space_dim || 2 == space_dim );
110  break;
111  }
112 
113  // Compute physical frame integration point coordinates.
114  Intrepid::CellTools<Scalar>::mapToPhysicalFrame(
115  this->d_physical_ip_coordinates, this->d_cub_points,
116  this->d_cell_node_coords, d_parent_topology );
117 }
118 
119 //---------------------------------------------------------------------------//
124 void IntrepidSideCell::mapToCellPhysicalFrame( const MDArray &parametric_coords,
125  MDArray &physical_coords )
126 {
127  DTK_REQUIRE( 2 == parametric_coords.rank() );
128  DTK_REQUIRE( 3 == physical_coords.rank() );
129  DTK_REQUIRE( parametric_coords.dimension( 1 ) ==
130  Teuchos::as<int>( this->d_topology.getDimension() ) );
131  DTK_REQUIRE( physical_coords.dimension( 0 ) ==
132  this->d_cell_node_coords.dimension( 0 ) );
133  DTK_REQUIRE( physical_coords.dimension( 1 ) ==
134  parametric_coords.dimension( 0 ) );
135  DTK_REQUIRE( physical_coords.dimension( 2 ) ==
136  Teuchos::as<int>( d_parent_topology.getDimension() ) );
137 
138  MDArray mapped_coords( parametric_coords.dimension( 0 ),
139  d_parent_topology.getDimension() );
140 
141  Intrepid::CellTools<Scalar>::mapToReferenceSubcell(
142  mapped_coords, parametric_coords, this->d_topology.getDimension(),
143  d_side_id, d_parent_topology );
144 
145  Intrepid::CellTools<Scalar>::mapToPhysicalFrame(
146  physical_coords, mapped_coords, this->d_cell_node_coords,
147  d_parent_topology );
148 }
149 
150 //---------------------------------------------------------------------------//
155  MDArray &side_normals )
156 {
157  // Compute the normal at the integration points.
158  Intrepid::CellTools<Scalar>::getPhysicalSideNormals(
159  side_normals, this->d_jacobian, d_side_id, d_parent_topology );
160 }
161 
162 //---------------------------------------------------------------------------//
168  const MDArray &parametric_coords, MDArray &side_normals )
169 {
170  int num_cells = d_cell_node_coords.dimension( 0 );
171  int num_point = parametric_coords.dimension( 0 );
172  int space_dim = parametric_coords.dimension( 1 );
173  MDArray jacobian( num_cells, num_point, space_dim, space_dim );
174 
175  Intrepid::CellTools<Scalar>::setJacobian( d_jacobian, parametric_coords,
176  this->d_cell_node_coords,
177  d_parent_topology );
178 
179  Intrepid::CellTools<Scalar>::getPhysicalSideNormals(
180  side_normals, d_jacobian, d_side_id, d_parent_topology );
181 }
182 
183 //---------------------------------------------------------------------------//
184 
185 } // End namespace DataTransferKit
186 
187 //---------------------------------------------------------------------------//
188 // end DTK_IntrepidSideCell.cpp
189 //---------------------------------------------------------------------------//
void getPhysicalSideNormalsAtReferencePoint(const MDArray &parametric_coords, MDArray &side_normals)
Compute the physical normals of the side at a given reference point.
Manager for Intrepid cell-level operations on cell sides.
void getPhysicalSideNormalsAtIntegrationPoints(MDArray &side_normals)
Compute the physical normals of the side.
Manager for Intrepid cell-level operations.
Assertions and Design-by-Contract for error handling.
void mapToCellPhysicalFrame(const MDArray &parametric_coords, MDArray &physical_coords)
Given a set of coordinates in the reference frame of the cell, map them to the physical frame...
void updateCellState()
Update the cell state of the object for the current cell node coordinates.
DTK_BasicEntitySet.cpp.
IntrepidSideCell(const shards::CellTopology &side_topology, const unsigned side_id, const shards::CellTopology &parent_topology, const unsigned degree)
Constructor.