63 const Teuchos::ParameterList& p)
65 comm = p.get< Teuchos::RCP<const Teuchos::Comm<int> > >(
"Comm");
67 global_data = p.get<Teuchos::RCP<panzer::GlobalData> >(
"Global Data");
72 std::string names_string = p.get<std::string>(
"Names");
73 std::vector<std::string> names;
76 Teuchos::RCP<panzer::IntegrationRule> ir = p.get< Teuchos::RCP<panzer::IntegrationRule> >(
"IR");
79 for (
typename std::vector<std::string>::const_iterator name = names.begin(); name != names.end(); ++name)
80 field_values.push_back(PHX::MDField<const ScalarT,Cell,IP>(*name, ir->dl_scalar));
82 Teuchos::RCP<PHX::MDALayout<Cell> > cell_dl = Teuchos::rcp(
new PHX::MDALayout<Cell>(ir->dl_scalar->extent(0)));
83 volumes = PHX::MDField<ScalarT,Cell>(
"Cell Volumes",cell_dl);
85 tmp = PHX::MDField<ScalarT,Cell>(
"GlobalStatistics:tmp:"+names_string,cell_dl);
86 ones = PHX::MDField<ScalarT,Cell,IP>(
"GlobalStatistics:ones:"+names_string,ir->dl_scalar);
88 this->addEvaluatedField(
volumes);
89 this->addEvaluatedField(
tmp);
90 this->addEvaluatedField(
ones);
91 for (
typename std::vector<PHX::MDField<const ScalarT,Cell,IP> >::const_iterator field =
field_values.begin();
93 this->addDependentField(*field);
105 std::string n =
"GlobalStatistics: " + names_string;
135 Intrepid2::FunctionSpaceTools<PHX::Device::execution_space>::integrate(
volumes.get_view(),
137 (this->wda(workset).int_rules[
ir_index])->weighted_measure.get_view());
138 auto volumes_h = Kokkos::create_mirror_view(as_view(
volumes));
139 Kokkos::deep_copy(volumes_h, as_view(
volumes));
141 for (index_t cell = 0; cell < workset.
num_cells; ++cell)
144 typename std::vector<PHX::MDField<ScalarT,Cell,IP> >
::size_type field_index = 0;
145 for (
typename std::vector<PHX::MDField<const ScalarT,Cell,IP> >::iterator field =
field_values.begin();
148 Intrepid2::FunctionSpaceTools<PHX::Device::execution_space>::integrate(
tmp.get_view(),
150 (this->wda(workset).int_rules[
ir_index])->weighted_measure.get_view());
151 auto tmp_h = Kokkos::create_mirror_view(
tmp.get_static_view());
152 auto field_h = Kokkos::create_mirror_view( field->get_static_view());
153 Kokkos::deep_copy(tmp_h,
tmp.get_static_view());
154 Kokkos::deep_copy(field_h, field->get_static_view());
157 for (index_t cell = 0; cell < workset.
num_cells; ++cell) {
158 averages[field_index] += tmp_h(cell);
160 for (
typename PHX::MDField<ScalarT,Cell,IP>::size_type ip = 0; ip < (field->extent(1)); ++ip) {
161 maxs[field_index] = std::max( field_h(cell,ip),
maxs[field_index]);
162 mins[field_index] = std::min( field_h(cell,ip),
mins[field_index]);
178 for (
typename std::vector<ScalarT>::iterator field =
averages.begin(); field !=
averages.end(); ++field)
179 *field = Teuchos::ScalarTraits<ScalarT>::zero();
181 for (
typename std::vector<ScalarT>::iterator field =
maxs.begin(); field !=
maxs.end(); ++field)
182 *field = Teuchos::ScalarTraits<ScalarT>::rmin();
184 for (
typename std::vector<ScalarT>::iterator field =
mins.begin(); field !=
mins.end(); ++field)
185 *field = Teuchos::ScalarTraits<ScalarT>::rmax();
215 for (std::vector<ScalarT>::size_type i = 0; i <
field_values.size(); ++i)
218 if (
comm->getRank() == 0) {
222 std::size_t precision = 8;
223 os << std::scientific << std::showpoint << std::setprecision(precision) << std::left;
225 std::size_t name_width = 0;
226 for (std::vector<ScalarT>::size_type i = 0; i <
field_values.size(); ++i)
227 name_width = std::max(name_width,
field_values[i].fieldTag().name().size());
229 std::size_t value_width = precision + 7;
231 os << std::setw(name_width) <<
"Field"
232 <<
" " << std::setw(value_width) <<
"Average"
233 <<
" " << std::setw(value_width) <<
"Maximum (@IP)"
234 <<
" " << std::setw(value_width) <<
"Minimum (@IP)"
237 for (std::vector<ScalarT>::size_type i = 0; i <
field_values.size(); ++i) {
238 os << std::setw(name_width) <<
field_values[i].fieldTag().name()
241 <<
" " << std::setw(value_width) <<
global_mins[i] << std::endl;
void StringTokenizer(std::vector< std::string > &tokens, const std::string &str, const std::string delimiters, bool trim)
Tokenize a string, put tokens in a vector.