Panzer Version of the Day
Loading...
Searching...
No Matches
Panzer_Workset_Utilities.cpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Panzer: A partial differential equation assembly
4// engine for strongly coupled complex multiphysics systems
5//
6// Copyright 2011 NTESS and the Panzer contributors.
7// SPDX-License-Identifier: BSD-3-Clause
8// *****************************************************************************
9// @HEADER
10
11#ifndef PANZER_WORKSET_UTILITIES_HPP
12#define PANZER_WORKSET_UTILITIES_HPP
13
14#include "Panzer_Traits.hpp"
15#include "Panzer_Workset.hpp"
16#include "Teuchos_Assert.hpp"
17#include <vector>
18#include <string>
19#include <algorithm>
20#include <iterator>
21
22namespace panzer {
23
24 std::vector<std::string>::size_type
25 getPureBasisIndex(std::string basis_name, const panzer::Workset& workset, WorksetDetailsAccessor& wda)
26 {
27 std::vector<std::string>::iterator basis = wda(workset).basis_names->begin();
28 std::vector<std::string>::const_iterator last = wda(workset).basis_names->end();
29
30 while (basis != last) {
31
32 std::vector<std::string>::size_type index = std::distance(wda(workset).basis_names->begin(), basis);
33 if (wda(workset).bases[index]->basis_layout->getBasis()->name() == basis_name)
34 break;
35
36 ++basis;
37 }
38
39 TEUCHOS_TEST_FOR_EXCEPTION(basis == wda(workset).basis_names->end(),
40 std::logic_error,
41 "Could not find the basis named \""
42 << basis_name << "\" in the workset!");
43
44 return std::distance(wda(workset).basis_names->begin(), basis);
45 }
46
47 std::vector<std::string>::size_type
48 getBasisIndex(std::string basis_name, const panzer::Workset& workset, WorksetDetailsAccessor& wda)
49 {
50 std::vector<std::string>::iterator basis;
51
52 basis = std::find(wda(workset).basis_names->begin(),
53 wda(workset).basis_names->end(),
54 basis_name);
55
56 TEUCHOS_TEST_FOR_EXCEPTION(basis == wda(workset).basis_names->end(),
57 std::logic_error,
58 "Could not find the basis named \""
59 << basis_name << "\" in the workset!");
60
61 return std::distance(wda(workset).basis_names->begin(), basis);
62 }
63
64 std::vector<int>::size_type
66 {
67 std::vector<int>::iterator ir;
68
69 ir = std::find(wda(workset).ir_degrees->begin(),
70 wda(workset).ir_degrees->end(),
71 ir_degree);
72
73 TEUCHOS_TEST_FOR_EXCEPTION(ir == wda(workset).ir_degrees->end(),
74 std::logic_error,
75 "Could not find the integration rule degree \""
76 << ir_degree << "\" in the workset!");
77
78 return std::distance(wda(workset).ir_degrees->begin(), ir);
79 }
80
81 void printWorkset(std::ostream& os, const panzer::Workset & workset, WorksetDetailsAccessor& wda)
82 {
83 os << "WORKSET"
84 << " block_id = \"" << wda(workset).block_id << "\""
85 << " num_cells = \"" << workset.num_cells << "\"\n";
86 os << " cell_local_ids = [ ";
87 for(index_t i=0;i<workset.num_cells;i++)
88 os << wda(workset).cell_local_ids[i] << " ";
89 os << "]\n";
90 os << " ir_degrees = [ ";
91 for(std::size_t i=0;i<wda(workset).ir_degrees->size();i++)
92 os << (*wda(workset).ir_degrees)[i] << " ";
93 os << "]\n";
94 os << " basis_names = [ ";
95 for(std::size_t i=0;i<wda(workset).basis_names->size();i++)
96 os << (*wda(workset).basis_names)[i] << " ";
97 os << "]\n";
98 /*
99 os << " int rule = "; wda(workset).int_rules[0]->int_rule->print(os); os << "\n";
100 os << " basis = "; wda(workset).bases[0]->panzer_basis->print(os); os << "\n";
101
102 for(index_t i=0;i<workset.num_cells;i++) {
103 os << " cell " << i << " vertices =\n";
104 for(int j=0;j<wda(workset).cell_vertex_coordinates.extent(1);j++) {
105 os << " ";
106 for(int k=0;k<wda(workset).cell_vertex_coordinates.extent(2);k++)
107 os << wda(workset).cell_vertex_coordinates(i,j,k) << " ";
108 os << "\n";
109 }
110 }
111
112 os << " integration rule points =\n";
113 for(int j=0;j<wda(workset).int_rules[0]->cub_points.extent(0);j++) {
114 os << " ";
115 for(int k=0;k<wda(workset).int_rules[0]->cub_points.extent(1);k++)
116 os << wda(workset).int_rules[0]->cub_points(j,k) << " ";
117 os << "\n";
118 }
119 os << " integration weights = [ ";
120 for(int j=0;j<wda(workset).int_rules[0]->cub_weights.extent(0);j++) {
121 os << wda(workset).int_rules[0]->cub_weights(j) << " ";
122 }
123 os << "]\n";
124
125 os << " jac = [ ";
126 for(int i=0;i<wda(workset).int_rules[0]->jac.size();i++) {
127 os << wda(workset).int_rules[0]->jac[i] << " ";
128 }
129 os << "]\n";
130
131 os << " jac_inv = [ ";
132 for(int i=0;i<wda(workset).int_rules[0]->jac_inv.size();i++) {
133 os << wda(workset).int_rules[0]->jac_inv[i] << " ";
134 }
135 os << "]\n";
136
137 os << " jac_det = [ ";
138 for(int i=0;i<wda(workset).int_rules[0]->jac_det.size();i++) {
139 os << wda(workset).int_rules[0]->jac_det[i] << " ";
140 }
141 os << "]\n";
142
143 os << " node_coordinates = [ ";
144 for(int i=0;i<wda(workset).int_rules[0]->node_coordinates.size();i++) {
145 os << wda(workset).int_rules[0]->node_coordinates[i] << " ";
146 }
147 os << "]\n";
148
149 os << " weighted_basis = [ ";
150 for(int i=0;i<wda(workset).bases[0]->weighted_basis.size();i++)
151 os << wda(workset).bases[0]->weighted_basis[i] << " ";
152 os << "]\n";
153
154 os << " weighted_grad_basis = [ ";
155 for(int i=0;i<wda(workset).bases[0]->weighted_grad_basis.size();i++)
156 os << wda(workset).bases[0]->weighted_grad_basis[i] << " ";
157 os << "]\n";
158
159 os << " basis = [ ";
160 for(int i=0;i<wda(workset).bases[0]->basis.size();i++)
161 os << wda(workset).bases[0]->basis[i] << " ";
162 os << "]\n";
163
164 os << " grad_basis = [ ";
165 for(int i=0;i<wda(workset).bases[0]->grad_basis.size();i++)
166 os << wda(workset).bases[0]->grad_basis[i] << " ";
167 os << "]\n";
168 */
169 }
170
171 std::vector<std::string>::size_type
172 getPureBasisIndex(std::string basis_name, const panzer::Workset& workset) {
174 return getPureBasisIndex(basis_name, workset, wda);
175 }
176 std::vector<std::string>::size_type
177 getBasisIndex(std::string basis_name, const panzer::Workset& workset) {
179 return getBasisIndex(basis_name, workset, wda);
180 }
181 std::vector<int>::size_type
182 getIntegrationRuleIndex(int ir_degree, const panzer::Workset& workset) {
184 return getIntegrationRuleIndex(ir_degree, workset, wda);
185 }
186 void printWorkset(std::ostream& os, const panzer::Workset & workset) {
188 printWorkset(os, workset, wda);
189 }
190}
191
192#endif
int num_cells
DEPRECATED - use: numCells()
std::vector< std::string >::size_type getBasisIndex(std::string basis_name, const panzer::Workset &workset, WorksetDetailsAccessor &wda)
Returns the index in the workset bases for a particular BasisIRLayout name.
std::vector< std::string >::size_type getPureBasisIndex(std::string basis_name, const panzer::Workset &workset, WorksetDetailsAccessor &wda)
Returns the index in the workset bases for a particular PureBasis name.
std::vector< int >::size_type getIntegrationRuleIndex(int ir_degree, const panzer::Workset &workset, WorksetDetailsAccessor &wda)
void printWorkset(std::ostream &os, const panzer::Workset &workset, WorksetDetailsAccessor &wda)