Panzer Version of the Day
Loading...
Searching...
No Matches
Panzer_TensorToStdVector_impl.hpp
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_TENSOR_TO_STD_VECTOR_IMPL_HPP
12#define PANZER_TENSOR_TO_STD_VECTOR_IMPL_HPP
13
14#include <string>
15
16namespace panzer {
17
18//**********************************************************************
19template<typename EvalT, typename Traits>
22 const Teuchos::ParameterList& p)
23{
24 Teuchos::RCP<PHX::DataLayout> vector_dl =
25 p.get< Teuchos::RCP<PHX::DataLayout> >("Data Layout Vector");
26
27 Teuchos::RCP<PHX::DataLayout> tensor_dl =
28 p.get< Teuchos::RCP<PHX::DataLayout> >("Data Layout Tensor");
29
30 const std::vector<std::string>& vector_names =
31 *(p.get< Teuchos::RCP<const std::vector<std::string> > >("Vector Names"));
32
33 vector_fields.resize(vector_names.size());
34 for (std::size_t i=0; i < vector_names.size(); ++i)
35 vector_fields[i] =
36 PHX::MDField<ScalarT,Cell,Point,Dim>(vector_names[i], vector_dl);
37
38 tensor_field =
39 PHX::MDField<const ScalarT,Cell,Point,Dim,Dim>(p.get<std::string>
40 ("Tensor Name"), tensor_dl);
41
42 this->addDependentField(tensor_field);
43
44 for (std::size_t i=0; i < vector_fields.size(); ++i)
45 this->addEvaluatedField(vector_fields[i]);
46
47 std::string n = "TensorToStdVector: " + tensor_field.fieldTag().name();
48 this->setName(n);
49}
50
51//**********************************************************************
52template<typename EvalT, typename Traits>
53void
56 typename Traits::EvalData workset)
57{
58
59 typedef typename PHX::MDField<ScalarT,Cell,Point,Dim>::size_type size_type;
60
61 // Loop over cells
62 for (index_t cell = 0; cell < workset.num_cells; ++cell) {
63
64 // Loop over points
65 for (size_type pt = 0; pt < tensor_field.extent(1); ++pt) {
66
67 // Loop over vectors
68 for (std::size_t vec = 0; vec < vector_fields.size(); ++vec) {
69
70 // Loop over spatial dimensions
71 for (std::size_t dim = 0; dim < tensor_field.extent(2); ++dim) {
72
73 vector_fields[vec](cell,pt,dim) = tensor_field(cell,pt,vec,dim);
74
75 }
76 }
77 }
78 }
79}
80
81//**********************************************************************
82
83}
84
85#endif
void evaluateFields(typename Traits::EvalData d)
TensorToStdVector(const Teuchos::ParameterList &p)
int num_cells
DEPRECATED - use: numCells()