Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fenl_functors.hpp
Go to the documentation of this file.
1 /*
2 //@HEADER
3 // ************************************************************************
4 //
5 // Kokkos: Manycore Performance-Portable Multidimensional Arrays
6 // Copyright (2012) Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact H. Carter Edwards (hcedwar@sandia.gov)
39 //
40 // ************************************************************************
41 //@HEADER
42 */
43 
44 #ifndef KOKKOS_EXAMPLE_FENLFUNCTORS_HPP
45 #define KOKKOS_EXAMPLE_FENLFUNCTORS_HPP
46 
47 #include <stdio.h>
48 
49 #include <iostream>
50 #include <fstream>
51 #include <iomanip>
52 #include <cstdlib>
53 #include <cmath>
54 #include <limits>
55 
56 #include <Kokkos_Core.hpp>
57 #include <Kokkos_Pair.hpp>
58 #include <Kokkos_UnorderedMap.hpp>
59 #include <Kokkos_StaticCrsGraph.hpp>
60 
61 #include <impl/Kokkos_Timer.hpp>
62 
63 #include <BoxElemFixture.hpp>
64 #include <HexElement.hpp>
65 
66 #include "Sacado.hpp"
67 
68 //----------------------------------------------------------------------------
69 //----------------------------------------------------------------------------
70 
71 namespace Kokkos {
72 namespace Example {
73 namespace FENL {
74 
75 template< typename ValueType , class Space >
76 struct CrsMatrix {
77 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE // Don't remove this until Kokkos has removed the deprecated code path probably around September 2018
78  typedef Kokkos::StaticCrsGraph< unsigned , Space , void , unsigned > StaticCrsGraphType ;
79 #else
80  typedef Kokkos::StaticCrsGraph< unsigned , Space , void , void , unsigned > StaticCrsGraphType ;
81 #endif
82  typedef View< ValueType * , Space > coeff_type ;
83 
86 
87  CrsMatrix() : graph(), coeff() {}
88 
89  CrsMatrix( const StaticCrsGraphType & arg_graph )
90  : graph( arg_graph )
91  , coeff( "crs_matrix_coeff" , arg_graph.entries.extent(0) )
92  {}
93 };
94 
95 template< class ElemNodeIdView , class CrsGraphType , unsigned ElemNode >
97 public:
98 
99  typedef typename ElemNodeIdView::execution_space execution_space ;
100  typedef pair<unsigned,unsigned> key_type ;
101 
102  typedef Kokkos::UnorderedMap< key_type, void , execution_space > SetType ;
103  typedef typename CrsGraphType::row_map_type::non_const_type RowMapType ;
104  typedef Kokkos::View< unsigned , execution_space > UnsignedValue ;
105 
106  // Static dimensions of 0 generate compiler warnings or errors.
107  typedef Kokkos::View< unsigned*[ElemNode][ElemNode] , execution_space >
109 
110  struct TagFillNodeSet {};
111  struct TagScanNodeCount {};
115 
116 private:
117 
123 
124  const unsigned node_count ;
125  const ElemNodeIdView elem_node_id ;
131 
132 public:
133 
134  CrsGraphType graph ;
136 
137  struct Times
138  {
139  double ratio;
145  };
146 
147  NodeNodeGraph( const ElemNodeIdView & arg_elem_node_id ,
148  const unsigned arg_node_count,
149  Times & results
150  )
151  : node_count(arg_node_count)
152  , elem_node_id( arg_elem_node_id )
153  , row_total( "row_total" )
154  , row_count(Kokkos::ViewAllocateWithoutInitializing("row_count") , node_count ) // will deep_copy to 0 inside loop
155  , row_map( "graph_row_map" , node_count + 1 )
156  , node_node_set()
157  , phase( FILL_NODE_SET )
158  , graph()
159  , elem_graph()
160  {
161  //--------------------------------
162  // Guess at capacity required for the map:
163 
164  Kokkos::Impl::Timer wall_clock ;
165 
166  wall_clock.reset();
167  phase = FILL_NODE_SET ;
168 
169  // upper bound on the capacity
170  size_t set_capacity = (28ull * node_count) / 2;
171  unsigned failed_insert_count = 0 ;
172 
173  do {
174  // Zero the row count to restart the fill
175  Kokkos::deep_copy( row_count , 0u );
176 
177  node_node_set = SetType( ( set_capacity += failed_insert_count ) );
178 
179  // May be larger that requested:
180  set_capacity = node_node_set.capacity();
181 
182  Kokkos::parallel_reduce( Kokkos::RangePolicy<execution_space,TagFillNodeSet>(0,elem_node_id.extent(0))
183  , *this
184  , failed_insert_count );
185 
186  } while ( failed_insert_count );
187 
188  execution_space::fence();
189  results.ratio = (double)node_node_set.size() / (double)node_node_set.capacity();
190  results.fill_node_set = wall_clock.seconds();
191  //--------------------------------
192 
193  wall_clock.reset();
195 
196  // Exclusive scan of row_count into row_map
197  // including the final total in the 'node_count + 1' position.
198  // Zero the 'row_count' values.
199  Kokkos::parallel_scan( node_count , *this );
200 
201  // Zero the row count for the fill:
202  Kokkos::deep_copy( row_count , 0u );
203 
204  unsigned graph_entry_count = 0 ;
205 
206  Kokkos::deep_copy( graph_entry_count , row_total );
207 
208  // Assign graph's row_map and allocate graph's entries
209  graph.row_map = row_map ;
210  graph.entries = typename CrsGraphType::entries_type( "graph_entries" , graph_entry_count );
211 
212  //--------------------------------
213  // Fill graph's entries from the (node,node) set.
214 
215  execution_space::fence();
216  results.scan_node_count = wall_clock.seconds();
217 
218  wall_clock.reset();
220  Kokkos::parallel_for( node_node_set.capacity() , *this );
221 
222  execution_space::fence();
223  results.fill_graph_entries = wall_clock.seconds();
224 
225  //--------------------------------
226  // Done with the temporary sets and arrays
227  wall_clock.reset();
229 
231  row_count = RowMapType();
232  row_map = RowMapType();
233  node_node_set.clear();
234 
235  //--------------------------------
236 
237  Kokkos::parallel_for( node_count , *this );
238 
239  execution_space::fence();
240  results.sort_graph_entries = wall_clock.seconds();
241 
242  //--------------------------------
243  // Element-to-graph mapping:
244  wall_clock.reset();
246  elem_graph = ElemGraphType("elem_graph", elem_node_id.extent(0) );
247  Kokkos::parallel_for( elem_node_id.extent(0) , *this );
248 
249  execution_space::fence();
250  results.fill_element_graph = wall_clock.seconds();
251  }
252 
253  //------------------------------------
254  // parallel_for: create map and count row length
255 
257  void operator()( const TagFillNodeSet & , unsigned ielem , unsigned & count ) const
258  {
259  // Loop over element's (row_local_node,col_local_node) pairs:
260  for ( unsigned row_local_node = 0 ; row_local_node < elem_node_id.extent(1) ; ++row_local_node ) {
261 
262  const unsigned row_node = elem_node_id( ielem , row_local_node );
263 
264  for ( unsigned col_local_node = row_local_node ; col_local_node < elem_node_id.extent(1) ; ++col_local_node ) {
265 
266  const unsigned col_node = elem_node_id( ielem , col_local_node );
267 
268  // If either node is locally owned then insert the pair into the unordered map:
269 
270  if ( row_node < row_count.extent(0) || col_node < row_count.extent(0) ) {
271 
272  const key_type key = (row_node < col_node) ? make_pair( row_node, col_node ) : make_pair( col_node, row_node ) ;
273 
274  const typename SetType::insert_result result = node_node_set.insert( key );
275 
276  // A successfull insert: the first time this pair was added
277  if ( result.success() ) {
278 
279  // If row node is owned then increment count
280  if ( row_node < row_count.extent(0) ) { atomic_increment( & row_count( row_node ) ); }
281 
282  // If column node is owned and not equal to row node then increment count
283  if ( col_node < row_count.extent(0) && col_node != row_node ) { atomic_increment( & row_count( col_node ) ); }
284  }
285  else if ( result.failed() ) {
286  ++count ;
287  }
288  }
289  }
290  }
291  }
292 
294  void fill_graph_entries( const unsigned iset ) const
295  {
296  if ( node_node_set.valid_at(iset) ) {
297  // Add each entry to the graph entries.
298 
299  const key_type key = node_node_set.key_at(iset) ;
300  const unsigned row_node = key.first ;
301  const unsigned col_node = key.second ;
302 
303  if ( row_node < row_count.extent(0) ) {
304  typedef typename std::remove_reference< decltype( row_count(0) ) >::type atomic_incr_type;
305  const unsigned offset = graph.row_map( row_node ) + atomic_fetch_add( & row_count( row_node ) , atomic_incr_type(1) );
306  graph.entries( offset ) = col_node ;
307  }
308 
309  if ( col_node < row_count.extent(0) && col_node != row_node ) {
310  typedef typename std::remove_reference< decltype( row_count(0) ) >::type atomic_incr_type;
311  const unsigned offset = graph.row_map( col_node ) + atomic_fetch_add( & row_count( col_node ) , atomic_incr_type(1) );
312  graph.entries( offset ) = row_node ;
313  }
314  }
315  }
316 
318  void sort_graph_entries( const unsigned irow ) const
319  {
320  const unsigned row_beg = graph.row_map( irow );
321  const unsigned row_end = graph.row_map( irow + 1 );
322  for ( unsigned i = row_beg + 1 ; i < row_end ; ++i ) {
323  const unsigned col = graph.entries(i);
324  unsigned j = i ;
325  for ( ; row_beg < j && col < graph.entries(j-1) ; --j ) {
326  graph.entries(j) = graph.entries(j-1);
327  }
328  graph.entries(j) = col ;
329  }
330  }
331 
333  void fill_elem_graph_map( const unsigned ielem ) const
334  {
335  for ( unsigned row_local_node = 0 ; row_local_node < elem_node_id.extent(1) ; ++row_local_node ) {
336 
337  const unsigned row_node = elem_node_id( ielem , row_local_node );
338 
339  for ( unsigned col_local_node = 0 ; col_local_node < elem_node_id.extent(1) ; ++col_local_node ) {
340 
341  const unsigned col_node = elem_node_id( ielem , col_local_node );
342 
343  unsigned entry = ~0u ;
344 
345  if ( row_node + 1 < graph.row_map.extent(0) ) {
346 
347  const unsigned entry_end = graph.row_map( row_node + 1 );
348 
349  entry = graph.row_map( row_node );
350 
351  for ( ; entry < entry_end && graph.entries(entry) != col_node ; ++entry );
352 
353  if ( entry == entry_end ) entry = ~0u ;
354  }
355 
356  elem_graph( ielem , row_local_node , col_local_node ) = entry ;
357  }
358  }
359  }
360 
362  void operator()( const unsigned iwork ) const
363  {
364 /*
365  if ( phase == FILL_NODE_SET ) {
366  operator()( TagFillNodeSet() , iwork );
367  }
368  else */
369  if ( phase == FILL_GRAPH_ENTRIES ) {
370  fill_graph_entries( iwork );
371  }
372  else if ( phase == SORT_GRAPH_ENTRIES ) {
373  sort_graph_entries( iwork );
374  }
375  else if ( phase == FILL_ELEMENT_GRAPH ) {
376  fill_elem_graph_map( iwork );
377  }
378  }
379 
380  //------------------------------------
381  // parallel_scan: row offsets
382 
383  typedef unsigned value_type ;
384 
386  void operator()( const unsigned irow , unsigned & update , const bool final ) const
387  {
388  // exclusive scan
389  if ( final ) { row_map( irow ) = update ; }
390 
391  update += row_count( irow );
392 
393  if ( final ) {
394  if ( irow + 1 == row_count.extent(0) ) {
395  row_map( irow + 1 ) = update ;
396  row_total() = update ;
397  }
398  }
399  }
400 
401  // For the reduce phase:
403  void init( const TagFillNodeSet & , unsigned & update ) const { update = 0 ; }
404 
406  void join( const TagFillNodeSet &
407  , volatile unsigned & update
408  , volatile const unsigned & input ) const { update += input ; }
409 
410  // For the scan phase::
412  void init( unsigned & update ) const { update = 0 ; }
413 
415  void join( volatile unsigned & update
416  , volatile const unsigned & input ) const { update += input ; }
417 
418  //------------------------------------
419 };
420 
421 } /* namespace FENL */
422 } /* namespace Example */
423 } /* namespace Kokkos */
424 
425 //----------------------------------------------------------------------------
426 //----------------------------------------------------------------------------
427 
428 namespace Kokkos {
429 namespace Example {
430 namespace FENL {
431 
432 template< class ExecutionSpace , BoxElemPart::ElemOrder Order ,
433  class CoordinateMap , typename ScalarType >
435 {
436 public:
437 
440 
441  //------------------------------------
442 
443  typedef ExecutionSpace execution_space ;
444  typedef ScalarType scalar_type ;
445 
448  typedef Kokkos::View< scalar_type* , Kokkos::LayoutLeft, execution_space > vector_type ;
449 
450  //------------------------------------
451 
453  static const unsigned TensorDim = SpatialDim * SpatialDim ;
457 
458  //------------------------------------
459 
462  typedef Kokkos::View< scalar_type*[FunctionCount][FunctionCount] , execution_space > elem_matrices_type ;
463  typedef Kokkos::View< scalar_type*[FunctionCount] , execution_space > elem_vectors_type ;
464 
466 
467  //------------------------------------
468 
469 
470  //------------------------------------
471  // Computational data:
472 
482 
484  : elem_data()
486  , node_coords( rhs.node_coords )
487  , elem_graph( rhs.elem_graph )
490  , solution( rhs.solution )
491  , residual( rhs.residual )
492  , jacobian( rhs.jacobian )
493  {}
494 
495  ElementComputationBase( const mesh_type & arg_mesh ,
496  const vector_type & arg_solution ,
497  const elem_graph_type & arg_elem_graph ,
498  const sparse_matrix_type & arg_jacobian ,
499  const vector_type & arg_residual )
500  : elem_data()
501  , elem_node_ids( arg_mesh.elem_node() )
502  , node_coords( arg_mesh.node_coord() )
503  , elem_graph( arg_elem_graph )
504  , elem_jacobians()
505  , elem_residuals()
506  , solution( arg_solution )
507  , residual( arg_residual )
508  , jacobian( arg_jacobian )
509  {}
510 
511  //------------------------------------
512 
515  const double grad[][ FunctionCount ] , // Gradient of bases master element
516  const double x[] ,
517  const double y[] ,
518  const double z[] ,
519  double dpsidx[] ,
520  double dpsidy[] ,
521  double dpsidz[] ) const
522  {
523  enum { j11 = 0 , j12 = 1 , j13 = 2 ,
524  j21 = 3 , j22 = 4 , j23 = 5 ,
525  j31 = 6 , j32 = 7 , j33 = 8 };
526 
527  // Jacobian accumulation:
528 
529  double J[ TensorDim ] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
530 
531  for( unsigned i = 0; i < FunctionCount ; ++i ) {
532  const double x1 = x[i] ;
533  const double x2 = y[i] ;
534  const double x3 = z[i] ;
535 
536  const double g1 = grad[0][i] ;
537  const double g2 = grad[1][i] ;
538  const double g3 = grad[2][i] ;
539 
540  J[j11] += g1 * x1 ;
541  J[j12] += g1 * x2 ;
542  J[j13] += g1 * x3 ;
543 
544  J[j21] += g2 * x1 ;
545  J[j22] += g2 * x2 ;
546  J[j23] += g2 * x3 ;
547 
548  J[j31] += g3 * x1 ;
549  J[j32] += g3 * x2 ;
550  J[j33] += g3 * x3 ;
551  }
552 
553  // Inverse jacobian:
554 
555  double invJ[ TensorDim ] = {
556  static_cast<double>( J[j22] * J[j33] - J[j23] * J[j32] ) ,
557  static_cast<double>( J[j13] * J[j32] - J[j12] * J[j33] ) ,
558  static_cast<double>( J[j12] * J[j23] - J[j13] * J[j22] ) ,
559 
560  static_cast<double>( J[j23] * J[j31] - J[j21] * J[j33] ) ,
561  static_cast<double>( J[j11] * J[j33] - J[j13] * J[j31] ) ,
562  static_cast<double>( J[j13] * J[j21] - J[j11] * J[j23] ) ,
563 
564  static_cast<double>( J[j21] * J[j32] - J[j22] * J[j31] ) ,
565  static_cast<double>( J[j12] * J[j31] - J[j11] * J[j32] ) ,
566  static_cast<double>( J[j11] * J[j22] - J[j12] * J[j21] ) };
567 
568  const double detJ = J[j11] * invJ[j11] +
569  J[j21] * invJ[j12] +
570  J[j31] * invJ[j13] ;
571 
572  const double detJinv = 1.0 / detJ ;
573 
574  for ( unsigned i = 0 ; i < TensorDim ; ++i ) { invJ[i] *= detJinv ; }
575 
576  // Transform gradients:
577 
578  for( unsigned i = 0; i < FunctionCount ; ++i ) {
579  const double g0 = grad[0][i];
580  const double g1 = grad[1][i];
581  const double g2 = grad[2][i];
582 
583  dpsidx[i] = g0 * invJ[j11] + g1 * invJ[j12] + g2 * invJ[j13];
584  dpsidy[i] = g0 * invJ[j21] + g1 * invJ[j22] + g2 * invJ[j23];
585  dpsidz[i] = g0 * invJ[j31] + g1 * invJ[j32] + g2 * invJ[j33];
586  }
587 
588  return detJ ;
589  }
590 
591 };
592 
598 };
599 
600 template< class FiniteElementMeshType ,
601  class SparseMatrixType ,
602  AssemblyMethod Method
603  >
605 
606 template< class ExecutionSpace , BoxElemPart::ElemOrder Order ,
607  class CoordinateMap , typename ScalarType >
609  < Kokkos::Example::BoxElemFixture< ExecutionSpace , Order , CoordinateMap > ,
610  CrsMatrix< ScalarType , ExecutionSpace > ,
611  Analytic > :
612  public ElementComputationBase<ExecutionSpace, Order, CoordinateMap,
613  ScalarType> {
614 public:
615 
616  typedef ElementComputationBase<ExecutionSpace, Order, CoordinateMap,
617  ScalarType> base_type;
618 
621 
622  static const unsigned FunctionCount = base_type::FunctionCount;
623  static const unsigned IntegrationCount = base_type::IntegrationCount;
624  static const unsigned ElemNodeCount = base_type::ElemNodeCount;
625 
627 
629  const typename base_type::mesh_type & arg_mesh ,
630  const typename base_type::vector_type & arg_solution ,
631  const typename base_type::elem_graph_type & arg_elem_graph ,
632  const typename base_type::sparse_matrix_type & arg_jacobian ,
633  const typename base_type::vector_type & arg_residual ) :
634  base_type(arg_mesh, arg_solution, arg_elem_graph,
635  arg_jacobian, arg_residual) {}
636 
637  //------------------------------------
638 
639  void apply() const
640  {
641  const size_t nelem = this->elem_node_ids.extent(0);
642  parallel_for( nelem , *this );
643  }
644 
646  void gatherSolution(const unsigned ielem,
647  scalar_type val[],
648  unsigned node_index[],
649  double x[], double y[], double z[],
650  scalar_type res[],
651  scalar_type mat[][FunctionCount]) const
652  {
653  for ( unsigned i = 0 ; i < ElemNodeCount ; ++i ) {
654  const unsigned ni = this->elem_node_ids( ielem , i );
655 
656  node_index[i] = ni ;
657 
658  x[i] = this->node_coords( ni , 0 );
659  y[i] = this->node_coords( ni , 1 );
660  z[i] = this->node_coords( ni , 2 );
661 
662  val[i] = this->solution( ni ) ;
663  res[i] = 0 ;
664 
665  for( unsigned j = 0; j < FunctionCount ; j++){
666  mat[i][j] = 0 ;
667  }
668  }
669  }
670 
672  void scatterResidual(const unsigned ielem,
673  const unsigned node_index[],
674  const scalar_type res[],
675  const scalar_type mat[][FunctionCount]) const
676  {
677  for( unsigned i = 0 ; i < FunctionCount ; i++ ) {
678  const unsigned row = node_index[i] ;
679  if ( row < this->residual.extent(0) ) {
680  atomic_add( & this->residual( row ) , res[i] );
681 
682  for( unsigned j = 0 ; j < FunctionCount ; j++ ) {
683  const unsigned entry = this->elem_graph( ielem , i , j );
684  if ( entry != ~0u ) {
685  atomic_add( & this->jacobian.coeff( entry ) , mat[i][j] );
686  }
687  }
688  }
689  }
690  }
691 
694  const scalar_type dof_values[] ,
695  const double x[],
696  const double y[],
697  const double z[],
698  scalar_type elem_res[] ,
699  scalar_type elem_mat[][FunctionCount] ) const
700  {
701  double coeff_k = 3.456;
702  double coeff_src = 1.234;
703  double advection[] = { 1.1, 1.2, 1.3 };
704  double dpsidx[ FunctionCount ] ;
705  double dpsidy[ FunctionCount ] ;
706  double dpsidz[ FunctionCount ] ;
707  for ( unsigned i = 0 ; i < IntegrationCount ; ++i ) {
708 
709  const double integ_weight = this->elem_data.weights[i];
710  const double* bases_vals = this->elem_data.values[i];
711  const double detJ =
712  this->transform_gradients( this->elem_data.gradients[i] ,
713  x , y , z ,
714  dpsidx , dpsidy , dpsidz );
715  const double detJ_weight = detJ * integ_weight;
716  const double detJ_weight_coeff_k = detJ_weight * coeff_k;
717 
718  scalar_type value_at_pt = 0 ;
719  scalar_type gradx_at_pt = 0 ;
720  scalar_type grady_at_pt = 0 ;
721  scalar_type gradz_at_pt = 0 ;
722  for ( unsigned m = 0 ; m < FunctionCount ; m++ ) {
723  value_at_pt += dof_values[m] * bases_vals[m] ;
724  gradx_at_pt += dof_values[m] * dpsidx[m] ;
725  grady_at_pt += dof_values[m] * dpsidy[m] ;
726  gradz_at_pt += dof_values[m] * dpsidz[m] ;
727  }
728 
729  const scalar_type source_term =
730  coeff_src * value_at_pt * value_at_pt ;
731  const scalar_type source_deriv =
732  2.0 * coeff_src * value_at_pt ;
733 
734  const scalar_type advection_x = advection[0];
735  const scalar_type advection_y = advection[1];
736  const scalar_type advection_z = advection[2];
737 
738  const scalar_type advection_term =
739  advection_x*gradx_at_pt +
740  advection_y*grady_at_pt +
741  advection_z*gradz_at_pt ;
742 
743  for ( unsigned m = 0; m < FunctionCount; ++m) {
744  scalar_type * const mat = elem_mat[m] ;
745  const double bases_val_m = bases_vals[m] * detJ_weight ;
746  const double dpsidx_m = dpsidx[m] ;
747  const double dpsidy_m = dpsidy[m] ;
748  const double dpsidz_m = dpsidz[m] ;
749 
750  elem_res[m] +=
751  detJ_weight_coeff_k * ( dpsidx_m * gradx_at_pt +
752  dpsidy_m * grady_at_pt +
753  dpsidz_m * gradz_at_pt ) +
754  bases_val_m * ( advection_term + source_term ) ;
755 
756  for( unsigned n = 0; n < FunctionCount; n++) {
757  const double dpsidx_n = dpsidx[n] ;
758  const double dpsidy_n = dpsidy[n] ;
759  const double dpsidz_n = dpsidz[n] ;
760  mat[n] +=
761  detJ_weight_coeff_k * ( dpsidx_m * dpsidx_n +
762  dpsidy_m * dpsidy_n +
763  dpsidz_m * dpsidz_n ) +
764  bases_val_m * ( advection_x * dpsidx_n +
765  advection_y * dpsidy_n +
766  advection_z * dpsidz_n +
767  source_deriv * bases_vals[n] ) ;
768  }
769  }
770  }
771  }
772 
774  void operator()( const unsigned ielem ) const
775  {
776  double x[ FunctionCount ] ;
777  double y[ FunctionCount ] ;
778  double z[ FunctionCount ] ;
779  unsigned node_index[ ElemNodeCount ];
780 
782  scalar_type elem_res[ FunctionCount ] ;
783  scalar_type elem_mat[ FunctionCount ][ FunctionCount ] ;
784 
785  // Gather nodal coordinates and solution vector:
786  gatherSolution(ielem, val, node_index, x, y, z, elem_res, elem_mat);
787 
788  // Compute nodal element residual vector and Jacobian matrix
789  computeElementResidualJacobian( val, x, y, z, elem_res , elem_mat );
790 
791  // Scatter nodal element residual and Jacobian in global vector and matrix:
792  scatterResidual( ielem, node_index, elem_res, elem_mat );
793  }
794 }; /* ElementComputation */
795 
796 template< class ExecutionSpace , BoxElemPart::ElemOrder Order ,
797  class CoordinateMap , typename ScalarType >
799  < Kokkos::Example::BoxElemFixture< ExecutionSpace , Order , CoordinateMap > ,
800  CrsMatrix< ScalarType , ExecutionSpace > ,
801  FadElement > : public ElementComputationBase<ExecutionSpace, Order, CoordinateMap,
802  ScalarType> {
803 public:
804 
805  typedef ElementComputationBase<ExecutionSpace, Order, CoordinateMap,
806  ScalarType> base_type;
807 
810 
811  static const unsigned FunctionCount = base_type::FunctionCount;
812  static const unsigned IntegrationCount = base_type::IntegrationCount;
813  static const unsigned ElemNodeCount = base_type::ElemNodeCount;
814 
816 
818 
820  const typename base_type::mesh_type & arg_mesh ,
821  const typename base_type::vector_type & arg_solution ,
822  const typename base_type::elem_graph_type & arg_elem_graph ,
823  const typename base_type::sparse_matrix_type & arg_jacobian ,
824  const typename base_type::vector_type & arg_residual ) :
825  base_type(arg_mesh, arg_solution, arg_elem_graph,
826  arg_jacobian, arg_residual) {}
827 
828  //------------------------------------
829 
830  void apply() const
831  {
832  const size_t nelem = this->elem_node_ids.extent(0);
833  parallel_for( nelem , *this );
834  }
835 
837  void gatherSolution(const unsigned ielem,
839  unsigned node_index[],
840  double x[], double y[], double z[],
841  fad_scalar_type res[]) const
842  {
843  for ( unsigned i = 0 ; i < ElemNodeCount ; ++i ) {
844  const unsigned ni = this->elem_node_ids( ielem , i );
845 
846  node_index[i] = ni ;
847 
848  x[i] = this->node_coords( ni , 0 );
849  y[i] = this->node_coords( ni , 1 );
850  z[i] = this->node_coords( ni , 2 );
851 
852  val[i].val() = this->solution( ni );
853  val[i].diff( i, FunctionCount );
854  }
855  }
856 
858  void scatterResidual(const unsigned ielem,
859  const unsigned node_index[],
860  fad_scalar_type res[]) const
861  {
862  for( unsigned i = 0 ; i < FunctionCount ; i++ ) {
863  const unsigned row = node_index[i] ;
864  if ( row < this->residual.extent(0) ) {
865  atomic_add( & this->residual( row ) , res[i].val() );
866 
867  for( unsigned j = 0 ; j < FunctionCount ; j++ ) {
868  const unsigned entry = this->elem_graph( ielem , i , j );
869  if ( entry != ~0u ) {
870  atomic_add( & this->jacobian.coeff( entry ) ,
871  res[i].fastAccessDx(j) );
872  }
873  }
874  }
875  }
876  }
877 
879  void computeElementResidual(const fad_scalar_type dof_values[] ,
880  const double x[],
881  const double y[],
882  const double z[],
883  fad_scalar_type elem_res[] ) const
884  {
885  double coeff_k = 3.456;
886  double coeff_src = 1.234;
887  double advection[] = { 1.1, 1.2, 1.3 };
888  double dpsidx[ FunctionCount ] ;
889  double dpsidy[ FunctionCount ] ;
890  double dpsidz[ FunctionCount ] ;
891  for ( unsigned i = 0 ; i < IntegrationCount ; ++i ) {
892 
893  const double integ_weight = this->elem_data.weights[i];
894  const double* bases_vals = this->elem_data.values[i];
895  const double detJ =
896  this->transform_gradients( this->elem_data.gradients[i] ,
897  x , y , z ,
898  dpsidx , dpsidy , dpsidz );
899  const double detJ_weight = detJ * integ_weight;
900  const double detJ_weight_coeff_k = detJ_weight * coeff_k;
901 
902  fad_scalar_type value_at_pt = 0 ;
903  fad_scalar_type gradx_at_pt = 0 ;
904  fad_scalar_type grady_at_pt = 0 ;
905  fad_scalar_type gradz_at_pt = 0 ;
906  for ( unsigned m = 0 ; m < FunctionCount ; m++ ) {
907  value_at_pt += dof_values[m] * bases_vals[m] ;
908  gradx_at_pt += dof_values[m] * dpsidx[m] ;
909  grady_at_pt += dof_values[m] * dpsidy[m] ;
910  gradz_at_pt += dof_values[m] * dpsidz[m] ;
911  }
912 
913  const fad_scalar_type source_term =
914  coeff_src * value_at_pt * value_at_pt ;
915 
916  const fad_scalar_type advection_term =
917  advection[0]*gradx_at_pt +
918  advection[1]*grady_at_pt +
919  advection[2]*gradz_at_pt;
920 
921  for ( unsigned m = 0; m < FunctionCount; ++m) {
922  const double bases_val_m = bases_vals[m] * detJ_weight ;
923  const double dpsidx_m = dpsidx[m] ;
924  const double dpsidy_m = dpsidy[m] ;
925  const double dpsidz_m = dpsidz[m] ;
926 
927  elem_res[m] +=
928  detJ_weight_coeff_k * ( dpsidx_m * gradx_at_pt +
929  dpsidy_m * grady_at_pt +
930  dpsidz_m * gradz_at_pt ) +
931  bases_val_m * ( advection_term + source_term ) ;
932  }
933  }
934  }
935 
937  void operator()( const unsigned ielem ) const
938  {
939  double x[ FunctionCount ] ;
940  double y[ FunctionCount ] ;
941  double z[ FunctionCount ] ;
942  unsigned node_index[ ElemNodeCount ];
943 
945  fad_scalar_type elem_res[ FunctionCount ] ; // this zeros elem_res
946 
947  // Gather nodal coordinates and solution vector:
948  gatherSolution( ielem, val, node_index, x, y, z, elem_res );
949 
950  // Compute nodal element residual vector:
951  computeElementResidual( val, x, y, z, elem_res );
952 
953  // Scatter nodal element residual in global vector:
954  scatterResidual( ielem, node_index, elem_res );
955  }
956 }; /* ElementComputation */
957 
958 template< class ExecutionSpace , BoxElemPart::ElemOrder Order ,
959  class CoordinateMap , typename ScalarType >
961  < Kokkos::Example::BoxElemFixture< ExecutionSpace , Order , CoordinateMap > ,
962  CrsMatrix< ScalarType , ExecutionSpace > ,
964  public ElementComputation< Kokkos::Example::BoxElemFixture< ExecutionSpace , Order , CoordinateMap > ,
965  CrsMatrix< ScalarType , ExecutionSpace > ,
966  FadElement > {
967 public:
968 
972 
975 
976  static const unsigned FunctionCount = base_type::FunctionCount;
977  static const unsigned IntegrationCount = base_type::IntegrationCount;
978  static const unsigned ElemNodeCount = base_type::ElemNodeCount;
979 
981 
983 
985  const typename base_type::mesh_type & arg_mesh ,
986  const typename base_type::vector_type & arg_solution ,
987  const typename base_type::elem_graph_type & arg_elem_graph ,
988  const typename base_type::sparse_matrix_type & arg_jacobian ,
989  const typename base_type::vector_type & arg_residual ) :
990  base_type(arg_mesh, arg_solution, arg_elem_graph,
991  arg_jacobian, arg_residual) {}
992 
993  //------------------------------------
994 
995  void apply() const
996  {
997  const size_t nelem = this->elem_node_ids.extent(0);
998  parallel_for( nelem , *this );
999  }
1000 
1002  void gatherSolution(const unsigned ielem,
1003  scalar_type val[],
1004  unsigned node_index[],
1005  double x[], double y[], double z[],
1006  fad_scalar_type res[]) const
1007  {
1008  for ( unsigned i = 0 ; i < ElemNodeCount ; ++i ) {
1009  const unsigned ni = this->elem_node_ids( ielem , i );
1010 
1011  node_index[i] = ni ;
1012 
1013  x[i] = this->node_coords( ni , 0 );
1014  y[i] = this->node_coords( ni , 1 );
1015  z[i] = this->node_coords( ni , 2 );
1016 
1017  val[i] = this->solution( ni );
1018  }
1019  }
1020 
1022  void computeElementResidual(const scalar_type dof_values[] ,
1023  const double x[],
1024  const double y[],
1025  const double z[],
1026  fad_scalar_type elem_res[] ) const
1027  {
1028  double coeff_k = 3.456;
1029  double coeff_src = 1.234;
1030  double advection[] = { 1.1, 1.2, 1.3 };
1031  double dpsidx[ FunctionCount ] ;
1032  double dpsidy[ FunctionCount ] ;
1033  double dpsidz[ FunctionCount ] ;
1034  for ( unsigned i = 0 ; i < IntegrationCount ; ++i ) {
1035 
1036  const double integ_weight = this->elem_data.weights[i];
1037  const double* bases_vals = this->elem_data.values[i];
1038  const double detJ =
1039  this->transform_gradients( this->elem_data.gradients[i] ,
1040  x , y , z ,
1041  dpsidx , dpsidy , dpsidz );
1042  const double detJ_weight = detJ * integ_weight;
1043  const double detJ_weight_coeff_k = detJ_weight * coeff_k;
1044 
1049  for ( unsigned m = 0 ; m < FunctionCount ; m++ ) {
1050  value_at_pt.val() += dof_values[m] * bases_vals[m] ;
1051  value_at_pt.fastAccessDx(m) = bases_vals[m] ;
1052 
1053  gradx_at_pt.val() += dof_values[m] * dpsidx[m] ;
1054  gradx_at_pt.fastAccessDx(m) = dpsidx[m] ;
1055 
1056  grady_at_pt.val() += dof_values[m] * dpsidy[m] ;
1057  grady_at_pt.fastAccessDx(m) = dpsidy[m] ;
1058 
1059  gradz_at_pt.val() += dof_values[m] * dpsidz[m] ;
1060  gradz_at_pt.fastAccessDx(m) = dpsidz[m] ;
1061  }
1062 
1063  const fad_scalar_type source_term =
1064  coeff_src * value_at_pt * value_at_pt ;
1065 
1066  const fad_scalar_type advection_term =
1067  advection[0]*gradx_at_pt +
1068  advection[1]*grady_at_pt +
1069  advection[2]*gradz_at_pt;
1070 
1071  for ( unsigned m = 0; m < FunctionCount; ++m) {
1072  const double bases_val_m = bases_vals[m] * detJ_weight ;
1073  const double dpsidx_m = dpsidx[m] ;
1074  const double dpsidy_m = dpsidy[m] ;
1075  const double dpsidz_m = dpsidz[m] ;
1076 
1077  elem_res[m] +=
1078  detJ_weight_coeff_k * ( dpsidx_m * gradx_at_pt +
1079  dpsidy_m * grady_at_pt +
1080  dpsidz_m * gradz_at_pt ) +
1081  bases_val_m * ( advection_term + source_term ) ;
1082  }
1083  }
1084  }
1085 
1087  void operator()( const unsigned ielem ) const
1088  {
1089  double x[ FunctionCount ] ;
1090  double y[ FunctionCount ] ;
1091  double z[ FunctionCount ] ;
1092  unsigned node_index[ ElemNodeCount ];
1093 
1095  fad_scalar_type elem_res[ FunctionCount ] ;
1096 
1097  // Gather nodal coordinates and solution vector:
1098  gatherSolution( ielem, val, node_index, x, y, z, elem_res );
1099 
1100  // Compute nodal element residual vector:
1101  computeElementResidual( val, x, y, z, elem_res );
1102 
1103  // Scatter nodal element residual in global vector:
1104  this->scatterResidual( ielem, node_index, elem_res );
1105  }
1106 }; /* ElementComputation */
1107 
1108 template< class ExecutionSpace , BoxElemPart::ElemOrder Order ,
1109  class CoordinateMap , typename ScalarType >
1111  < Kokkos::Example::BoxElemFixture< ExecutionSpace , Order , CoordinateMap > ,
1112  CrsMatrix< ScalarType , ExecutionSpace > ,
1113  FadQuadPoint > :
1114  public ElementComputation< Kokkos::Example::BoxElemFixture< ExecutionSpace , Order , CoordinateMap > ,
1115  CrsMatrix< ScalarType , ExecutionSpace > ,
1116  Analytic > {
1117 public:
1118 
1122 
1125 
1126  static const unsigned FunctionCount = base_type::FunctionCount;
1127  static const unsigned IntegrationCount = base_type::IntegrationCount;
1128  static const unsigned ElemNodeCount = base_type::ElemNodeCount;
1129 
1131 
1133 
1135  const typename base_type::mesh_type & arg_mesh ,
1136  const typename base_type::vector_type & arg_solution ,
1137  const typename base_type::elem_graph_type & arg_elem_graph ,
1138  const typename base_type::sparse_matrix_type & arg_jacobian ,
1139  const typename base_type::vector_type & arg_residual ) :
1140  base_type(arg_mesh, arg_solution, arg_elem_graph,
1141  arg_jacobian, arg_residual) {}
1142 
1143  //------------------------------------
1144 
1145  void apply() const
1146  {
1147  const size_t nelem = this->elem_node_ids.extent(0);
1148  parallel_for( nelem , *this );
1149  }
1150 
1153  const scalar_type dof_values[] ,
1154  const double x[],
1155  const double y[],
1156  const double z[],
1157  scalar_type elem_res[] ,
1158  scalar_type elem_mat[][FunctionCount] ) const
1159  {
1160  double coeff_k = 3.456;
1161  double coeff_src = 1.234;
1162  double advection[] = { 1.1, 1.2, 1.3 };
1163  double dpsidx[ FunctionCount ] ;
1164  double dpsidy[ FunctionCount ] ;
1165  double dpsidz[ FunctionCount ] ;
1166 
1167  fad_scalar_type value_at_pt(4, 0, 0.0) ;
1168  fad_scalar_type gradx_at_pt(4, 1, 0.0) ;
1169  fad_scalar_type grady_at_pt(4, 2, 0.0) ;
1170  fad_scalar_type gradz_at_pt(4, 3, 0.0) ;
1171  for ( unsigned i = 0 ; i < IntegrationCount ; ++i ) {
1172 
1173  const double integ_weight = this->elem_data.weights[i];
1174  const double* bases_vals = this->elem_data.values[i];
1175  const double detJ =
1176  this->transform_gradients( this->elem_data.gradients[i] ,
1177  x , y , z ,
1178  dpsidx , dpsidy , dpsidz );
1179  const double detJ_weight = detJ * integ_weight;
1180  const double detJ_weight_coeff_k = detJ_weight * coeff_k;
1181 
1182  value_at_pt.val() = 0.0 ;
1183  gradx_at_pt.val() = 0.0 ;
1184  grady_at_pt.val() = 0.0 ;
1185  gradz_at_pt.val() = 0.0 ;
1186  for ( unsigned m = 0 ; m < FunctionCount ; m++ ) {
1187  value_at_pt.val() += dof_values[m] * bases_vals[m] ;
1188  gradx_at_pt.val() += dof_values[m] * dpsidx[m] ;
1189  grady_at_pt.val() += dof_values[m] * dpsidy[m] ;
1190  gradz_at_pt.val() += dof_values[m] * dpsidz[m] ;
1191  }
1192 
1193  const fad_scalar_type source_term =
1194  coeff_src * value_at_pt * value_at_pt ;
1195 
1196  const fad_scalar_type advection_term =
1197  advection[0]*gradx_at_pt +
1198  advection[1]*grady_at_pt +
1199  advection[2]*gradz_at_pt;
1200 
1201  for ( unsigned m = 0; m < FunctionCount; ++m) {
1202  const double bases_val_m = bases_vals[m] * detJ_weight ;
1203  fad_scalar_type res =
1204  detJ_weight_coeff_k * ( dpsidx[m] * gradx_at_pt +
1205  dpsidy[m] * grady_at_pt +
1206  dpsidz[m] * gradz_at_pt ) +
1207  bases_val_m * ( advection_term + source_term ) ;
1208 
1209  elem_res[m] += res.val();
1210 
1211  scalar_type * const mat = elem_mat[m] ;
1212  for( unsigned n = 0; n < FunctionCount; n++) {
1213  mat[n] += res.fastAccessDx(0) * bases_vals[n] +
1214  res.fastAccessDx(1) * dpsidx[n] +
1215  res.fastAccessDx(2) * dpsidy[n] +
1216  res.fastAccessDx(3) * dpsidz[n];
1217  }
1218  }
1219  }
1220  }
1221 
1223  void operator()( const unsigned ielem ) const
1224  {
1225  double x[ FunctionCount ] ;
1226  double y[ FunctionCount ] ;
1227  double z[ FunctionCount ] ;
1228  unsigned node_index[ ElemNodeCount ];
1229 
1231  scalar_type elem_res[ FunctionCount ] ;
1232  scalar_type elem_mat[ FunctionCount ][ FunctionCount ] ;
1233 
1234  // Gather nodal coordinates and solution vector:
1235  this->gatherSolution( ielem, val, node_index, x, y, z, elem_res, elem_mat );
1236 
1237  // Compute nodal element residual vector and Jacobian matrix:
1238  computeElementResidualJacobian( val, x, y, z, elem_res, elem_mat );
1239 
1240  // Scatter nodal element residual and Jacobian in global vector and matrix:
1241  this->scatterResidual( ielem, node_index, elem_res, elem_mat );
1242  }
1243 }; /* ElementComputation */
1244 
1245 } /* namespace FENL */
1246 } /* namespace Example */
1247 } /* namespace Kokkos */
1248 
1249 //----------------------------------------------------------------------------
1250 
1251 #endif /* #ifndef KOKKOS_EXAMPLE_FENLFUNCTORS_HPP */
double weights[integration_count]
Definition: HexElement.hpp:219
KOKKOS_INLINE_FUNCTION void scatterResidual(const unsigned ielem, const unsigned node_index[], const scalar_type res[], const scalar_type mat[][FunctionCount]) const
ElementComputation(const typename base_type::mesh_type &arg_mesh, const typename base_type::vector_type &arg_solution, const typename base_type::elem_graph_type &arg_elem_graph, const typename base_type::sparse_matrix_type &arg_jacobian, const typename base_type::vector_type &arg_residual)
KOKKOS_INLINE_FUNCTION void computeElementResidualJacobian(const scalar_type dof_values[], const double x[], const double y[], const double z[], scalar_type elem_res[], scalar_type elem_mat[][FunctionCount]) const
KOKKOS_INLINE_FUNCTION void fill_graph_entries(const unsigned iset) const
Kokkos::View< scalar_type *[FunctionCount], execution_space > elem_vectors_type
static const unsigned element_node_count
Definition: HexElement.hpp:215
CrsMatrix< ScalarType, ExecutionSpace > sparse_matrix_type
static const unsigned function_count
Definition: HexElement.hpp:217
ElementComputation< Kokkos::Example::BoxElemFixture< ExecutionSpace, Order, CoordinateMap >, CrsMatrix< ScalarType, ExecutionSpace >, Analytic > base_type
Kokkos::View< const double *[SpaceDim], Device > node_coord_type
double gradients[integration_count][spatial_dimension][function_count]
Definition: HexElement.hpp:221
Kokkos::View< const unsigned *[ElemNode], Device > elem_node_type
KOKKOS_INLINE_FUNCTION void gatherSolution(const unsigned ielem, scalar_type val[], unsigned node_index[], double x[], double y[], double z[], fad_scalar_type res[]) const
KOKKOS_INLINE_FUNCTION void join(volatile unsigned &update, volatile const unsigned &input) const
Kokkos::View< scalar_type *, Kokkos::LayoutLeft, execution_space > vector_type
NodeNodeGraph< elem_node_type, sparse_graph_type, ElemNodeCount >::ElemGraphType elem_graph_type
expr val()
#define KOKKOS_INLINE_FUNCTION
ElemNodeIdView::execution_space execution_space
KOKKOS_INLINE_FUNCTION void operator()(const unsigned irow, unsigned &update, const bool final) const
KOKKOS_INLINE_FUNCTION void init(unsigned &update) const
ElementComputationBase(const ElementComputationBase &rhs)
KOKKOS_INLINE_FUNCTION void fill_elem_graph_map(const unsigned ielem) const
Kokkos::Example::HexElement_Data< mesh_type::ElemNode > element_data_type
CrsGraphType::row_map_type::non_const_type RowMapType
KOKKOS_INLINE_FUNCTION void computeElementResidual(const scalar_type dof_values[], const double x[], const double y[], const double z[], fad_scalar_type elem_res[]) const
ElementComputationBase(const mesh_type &arg_mesh, const vector_type &arg_solution, const elem_graph_type &arg_elem_graph, const sparse_matrix_type &arg_jacobian, const vector_type &arg_residual)
KOKKOS_INLINE_FUNCTION void operator()(const TagFillNodeSet &, unsigned ielem, unsigned &count) const
CrsMatrix(const StaticCrsGraphType &arg_graph)
Kokkos::StaticCrsGraph< unsigned, Space, void, void, unsigned > StaticCrsGraphType
KOKKOS_INLINE_FUNCTION double transform_gradients(const double grad[][FunctionCount], const double x[], const double y[], const double z[], double dpsidx[], double dpsidy[], double dpsidz[]) const
double values[integration_count][function_count]
Definition: HexElement.hpp:220
Do not initialize the derivative array.
KOKKOS_INLINE_FUNCTION void operator()(const unsigned iwork) const
static const unsigned integration_count
Definition: HexElement.hpp:216
KOKKOS_INLINE_FUNCTION void gatherSolution(const unsigned ielem, fad_scalar_type val[], unsigned node_index[], double x[], double y[], double z[], fad_scalar_type res[]) const
Kokkos::Example::BoxElemFixture< ExecutionSpace, Order, CoordinateMap > mesh_type
NodeNodeGraph(const ElemNodeIdView &arg_elem_node_id, const unsigned arg_node_count, Times &results)
KOKKOS_INLINE_FUNCTION void init(const TagFillNodeSet &, unsigned &update) const
View< ValueType *, Space > coeff_type
sparse_matrix_type::StaticCrsGraphType sparse_graph_type
Kokkos::View< unsigned, execution_space > UnsignedValue
ElementComputation(const typename base_type::mesh_type &arg_mesh, const typename base_type::vector_type &arg_solution, const typename base_type::elem_graph_type &arg_elem_graph, const typename base_type::sparse_matrix_type &arg_jacobian, const typename base_type::vector_type &arg_residual)
ElementComputation< Kokkos::Example::BoxElemFixture< ExecutionSpace, Order, CoordinateMap >, CrsMatrix< ScalarType, ExecutionSpace >, FadElement > base_type
KOKKOS_INLINE_FUNCTION void gatherSolution(const unsigned ielem, scalar_type val[], unsigned node_index[], double x[], double y[], double z[], scalar_type res[], scalar_type mat[][FunctionCount]) const
ElementComputation(const typename base_type::mesh_type &arg_mesh, const typename base_type::vector_type &arg_solution, const typename base_type::elem_graph_type &arg_elem_graph, const typename base_type::sparse_matrix_type &arg_jacobian, const typename base_type::vector_type &arg_residual)
KOKKOS_INLINE_FUNCTION void computeElementResidual(const fad_scalar_type dof_values[], const double x[], const double y[], const double z[], fad_scalar_type elem_res[]) const
ElementComputation(const typename base_type::mesh_type &arg_mesh, const typename base_type::vector_type &arg_solution, const typename base_type::elem_graph_type &arg_elem_graph, const typename base_type::sparse_matrix_type &arg_jacobian, const typename base_type::vector_type &arg_residual)
KOKKOS_INLINE_FUNCTION void sort_graph_entries(const unsigned irow) const
Kokkos::View< scalar_type *[FunctionCount][FunctionCount], execution_space > elem_matrices_type
KOKKOS_INLINE_FUNCTION void computeElementResidualJacobian(const scalar_type dof_values[], const double x[], const double y[], const double z[], scalar_type elem_res[], scalar_type elem_mat[][FunctionCount]) const
KOKKOS_INLINE_FUNCTION void join(const TagFillNodeSet &, volatile unsigned &update, volatile const unsigned &input) const
Kokkos::View< unsigned *[ElemNode][ElemNode], execution_space > ElemGraphType
int n
Generate a distributed unstructured finite element mesh from a partitioned NX*NY*NZ box of elements...
Kokkos::UnorderedMap< key_type, void, execution_space > SetType
pair< unsigned, unsigned > key_type
static const unsigned spatial_dimension
Definition: HexElement.hpp:214