Panzer  Version of the Day
Panzer_Workset_Builder.cpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Panzer: A partial differential equation assembly
5 // engine for strongly coupled complex multiphysics systems
6 // Copyright (2011) 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 Roger P. Pawlowski (rppawlo@sandia.gov) and
39 // Eric C. Cyr (eccyr@sandia.gov)
40 // ***********************************************************************
41 // @HEADER
42 
43 #include "PanzerDiscFE_config.hpp"
44 
46 
47 #ifdef HAVE_PANZER_EXPLICIT_INSTANTIATION
48 
51 
52 template
53 Teuchos::RCP<std::vector<panzer::Workset> >
55  const std::vector<std::size_t>& local_cell_ids,
56  const Kokkos::DynRankView<double,PHX::Device>& vertex_coordinates);
57 
58 template
59 Teuchos::RCP<std::vector<panzer::Workset> >
60 panzer::buildWorksets(const WorksetNeeds & needs,
61  const std::string & elementBlock,
62  const std::vector<std::size_t>& local_cell_ids,
63  const Kokkos::DynRankView<double,PHX::Device>& vertex_coordinates);
64 
65 template
66 Teuchos::RCP<std::map<unsigned,panzer::Workset> >
68  const std::vector<std::size_t>& local_cell_ids,
69  const std::vector<std::size_t>& local_side_ids,
70  const Kokkos::DynRankView<double,PHX::Device>& vertex_coordinates);
71 
72 template
73 Teuchos::RCP<std::map<unsigned,panzer::Workset> >
74 panzer::buildBCWorkset(const WorksetNeeds& needs,
75  const std::string& elementBlock,
76  const std::vector<std::size_t>& local_cell_ids,
77  const std::vector<std::size_t>& local_side_ids,
78  const Kokkos::DynRankView<double,PHX::Device>& vertex_coordinates,
79  const bool populate_value_arrays);
80 
81 template
82 Teuchos::RCP<std::vector<panzer::Workset> >
84  const std::vector<std::size_t>&,
85  const std::vector<std::size_t>&,
86  const Kokkos::DynRankView<double,PHX::Device>&,
87  const panzer::PhysicsBlock &,
88  const std::vector<std::size_t>&,
89  const std::vector<std::size_t>&,
90  const Kokkos::DynRankView<double,PHX::Device>&);
91 
92 template
93 Teuchos::RCP<std::map<unsigned,panzer::Workset> >
95  const std::vector<std::size_t>& local_cell_ids_a,
96  const std::vector<std::size_t>& local_side_ids_a,
97  const Kokkos::DynRankView<double,PHX::Device>& vertex_coordinates_a,
98  const panzer::PhysicsBlock& pb_b,
99  const std::vector<std::size_t>& local_cell_ids_b,
100  const std::vector<std::size_t>& local_side_ids_b,
101  const Kokkos::DynRankView<double,PHX::Device>& vertex_coordinates_b);
102 
103 #endif
104 
105 namespace panzer {
106 
107 void populateValueArrays(std::size_t num_cells,bool isSide,const WorksetNeeds & needs,
108  WorksetDetails & details,const Teuchos::RCP<WorksetDetails> other_details)
109 {
110  using Teuchos::RCP;
111  using Teuchos::rcp;
112 
113  panzer::MDFieldArrayFactory mdArrayFactory("",true);
114 
115  // setup the integration rules and bases
116 
117  std::vector<RCP<const panzer::PureBasis> > bases;
118  std::vector<RCP<const panzer::IntegrationRule> > int_rules;
119  if(isSide) {
120  const panzer::CellData side_cell_data(num_cells,
121  details.subcell_index,
122  needs.cellData.getCellTopology());
123 
124  for(std::size_t i=0;i<needs.int_rules.size();i++)
125  int_rules.push_back(rcp(new IntegrationRule(needs.int_rules[i]->cubature_degree,side_cell_data)));
126 
127  for(std::size_t i=0;i<needs.bases.size();i++)
128  bases.push_back(rcp(new PureBasis(needs.bases[i]->type(),needs.bases[i]->order(),side_cell_data)));
129  }
130  else {
131  int_rules = needs.int_rules;
132  bases = needs.bases;
133  }
134 
135  details.ir_degrees = rcp(new std::vector<int>(0));
136  details.basis_names = rcp(new std::vector<std::string>(0));
137 
138  for(std::size_t i=0;i<int_rules.size();i++) {
139 
140  details.ir_degrees->push_back(int_rules[i]->cubature_degree);
141 
142  RCP<panzer::IntegrationValues2<double> > iv2 =
143  rcp(new panzer::IntegrationValues2<double>("",true));
144  iv2->setupArrays(int_rules[i]);
145  if (Teuchos::nonnull(other_details))
146  iv2->evaluateValues(details.cell_vertex_coordinates, other_details->int_rules[i]->ip_coordinates);
147  else
148  iv2->evaluateValues(details.cell_vertex_coordinates);
149 
150  details.int_rules.push_back(iv2);
151 
152  // Need to create all combinations of basis/ir pairings
153  for(std::size_t b=0;b<bases.size();b++) {
154  RCP<panzer::BasisIRLayout> b_layout = rcp(new panzer::BasisIRLayout(bases[b],*int_rules[i]));
155  details.basis_names->push_back(b_layout->name());
156 
157  std::size_t int_degree_index = std::distance(details.ir_degrees->begin(),
158  std::find(details.ir_degrees->begin(),
159  details.ir_degrees->end(),
160  int_rules[i]->order()));
161  RCP<panzer::BasisValues2<double> > bv2 =
162  rcp(new panzer::BasisValues2<double>("",true,true));
163  bv2->setupArrays(b_layout);
164  bv2->evaluateValues(details.int_rules[int_degree_index]->cub_points,
165  details.int_rules[int_degree_index]->jac,
166  details.int_rules[int_degree_index]->jac_det,
167  details.int_rules[int_degree_index]->jac_inv,
168  details.int_rules[int_degree_index]->weighted_measure,
169  details.cell_vertex_coordinates);
170 
171  details.bases.push_back(bv2);
172  }
173  }
174 
175 }
176 
177 void populateValueArrays(std::size_t num_cells,bool isSide,const panzer::PhysicsBlock & pb,
178  WorksetDetails & details,const Teuchos::RCP<WorksetDetails> other_details)
179 {
180  using Teuchos::RCP;
181 
182  WorksetNeeds needs;
183  needs.cellData = pb.cellData();
184 
185  const std::map<int,RCP<panzer::IntegrationRule> >& int_rules = pb.getIntegrationRules();
186  for(std::map<int,RCP<panzer::IntegrationRule> >::const_iterator ir_itr = int_rules.begin();
187  ir_itr != int_rules.end(); ++ir_itr)
188  needs.int_rules.push_back(ir_itr->second);
189 
190  const std::map<std::string,Teuchos::RCP<panzer::PureBasis> >& bases= pb.getBases();
191  for(std::map<std::string,Teuchos::RCP<panzer::PureBasis> >::const_iterator b_itr = bases.begin();
192  b_itr != bases.end(); ++b_itr)
193  needs.bases.push_back(b_itr->second);
194 
195  return populateValueArrays(num_cells,isSide,needs,details,other_details);
196 }
197 
198 }
Teuchos::RCP< std::map< unsigned, Workset > > buildBCWorkset(const PhysicsBlock &volume_pb, const std::vector< std::size_t > &local_cell_ids, const std::vector< std::size_t > &local_side_ids, const ArrayT &vertex_coordinates)
std::vector< Teuchos::RCP< const PureBasis > > bases
Object that contains information on the physics and discretization of a block of elements with the SA...
std::vector< Teuchos::RCP< const IntegrationRule > > int_rules
Teuchos::RCP< const shards::CellTopology > getCellTopology() const
Get CellTopology for the base cell.
Teuchos::RCP< std::vector< Workset > > buildEdgeWorksets(const PhysicsBlock &pb_a, const std::vector< std::size_t > &local_cell_ids_a, const std::vector< std::size_t > &local_side_ids_a, const ArrayT &vertex_coordinates_a, const PhysicsBlock &pb_b, const std::vector< std::size_t > &local_cell_ids_b, const std::vector< std::size_t > &local_side_ids_b, const ArrayT &vertex_coordinates_b)
Data for determining cell topology and dimensionality.
Teuchos::RCP< std::vector< Workset > > buildWorksets(const PhysicsBlock &pb, const std::vector< std::size_t > &local_cell_ids, const ArrayT &vertex_coordinates)
const panzer::CellData & cellData() const
const std::map< std::string, Teuchos::RCP< panzer::PureBasis > > & getBases() const
Returns the unique set of bases, key is the unique panzer::PureBasis::name() of the basis...
Description and data layouts associated with a particular basis.
void populateValueArrays(std::size_t num_cells, bool isSide, const WorksetNeeds &needs, WorksetDetails &details, const Teuchos::RCP< WorksetDetails > other_details)
const std::map< int, Teuchos::RCP< panzer::IntegrationRule > > & getIntegrationRules() const
Returns the unique set of point rules, key is the unique panzer::PointRule::name() ...