Panzer Version of the Day
Loading...
Searching...
No Matches
Panzer_STK_ResponseEvaluatorFactory_SolutionWriter.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_STK_ResponseEvaluatorFactory_SolutionWriter_hpp__
12#define __Panzer_STK_ResponseEvaluatorFactory_SolutionWriter_hpp__
13
14#include <string>
15
16#include "PanzerAdaptersSTK_config.hpp"
18#include "Panzer_BC.hpp"
19#include "Panzer_Traits.hpp"
21
23
24#include "Teuchos_RCP.hpp"
25#include "Teuchos_ParameterList.hpp"
26
27#include <unordered_map>
28#include <unordered_set>
29
30namespace panzer_stk {
31
34template <typename EvalT>
36public:
37
38 ResponseEvaluatorFactory_SolutionWriter(const Teuchos::RCP<STK_Interface> & mesh)
39 : mesh_(mesh), addSolutionFields_(true), addCoordinateFields_(true) {}
40
42
52 virtual Teuchos::RCP<panzer::ResponseBase> buildResponseObject(const std::string & responseName) const;
53
54 virtual Teuchos::RCP<panzer::ResponseBase> buildResponseObject(const std::string & responseName,
55 const std::vector<panzer::WorksetDescriptor>& /* wkstDesc */) const
56 { return buildResponseObject(responseName); }
57
69 virtual void buildAndRegisterEvaluators(const std::string & responseName,
71 const panzer::PhysicsBlock & physicsBlock,
72 const Teuchos::ParameterList & user_data) const;
73
81 virtual bool typeSupported() const;
82
86 static void bucketByBasisType(const std::vector<std::pair<std::string,Teuchos::RCP<const panzer::PureBasis> > > & providedDofs,
87 std::map<std::string,std::vector<std::string> > & basisBucket);
88
98 void scaleField(const std::string & fieldName,double fieldScalar);
99
102 void addAdditionalField(const std::string & fieldName,const Teuchos::RCP<const panzer::PureBasis> & basis);
103
106 void setAddSolutionFields(bool asf)
107 { addSolutionFields_ = asf; }
108
112 { addCoordinateFields_ = acf; }
113
118 void removeField(const std::string & fieldName)
119 { removedFields_.push_back(fieldName); }
120
121 // should be private but needs a lambda
122 void computeReferenceCentroid(const std::map<std::string,Teuchos::RCP<const panzer::PureBasis> > & bases,
123 int baseDimension,
124 Kokkos::DynRankView<double,PHX::Device> & centroid) const;
125
126private:
128 void deleteRemovedFields(const std::vector<std::string> & removedFields,
129 std::vector<std::pair<std::string,Teuchos::RCP<const panzer::PureBasis> > > & fields) const;
130
132 std::vector<std::string> removedFields_;
133 bool operator() (const std::pair<std::string,Teuchos::RCP<const panzer::PureBasis> > & field)
134 { return std::find(removedFields_.begin(),removedFields_.end(),field.first)!=removedFields_.end(); }
135 };
136
137 Teuchos::RCP<STK_Interface> mesh_;
138
139 std::unordered_map<std::string,double> fieldToScalar_;
140 std::unordered_set<std::string> scaledFieldsHash_; // used to print the warning about unused scaling
141
142 std::vector<std::pair<std::string,Teuchos::RCP<const panzer::PureBasis> > > additionalFields_;
143 std::vector<std::string> removedFields_;
146};
147
153
154 Teuchos::RCP<panzer_stk::STK_Interface> mesh;
155
156 void scaleField(const std::string & fieldName,double fieldScalar)
157 { fieldToScalar_[fieldName] = fieldScalar; }
158
159 void addAdditionalField(const std::string & fieldName,const Teuchos::RCP<const panzer::PureBasis> & basis)
160 { additionalFields_.push_back(std::make_pair(fieldName,basis)); }
161
166 void removeField(const std::string & fieldName)
167 { removedFields_.push_back(fieldName); }
168
169 template <typename T>
170 Teuchos::RCP<panzer::ResponseEvaluatorFactoryBase> build() const
171 {
172 Teuchos::RCP<ResponseEvaluatorFactory_SolutionWriter<T> > ref =
174
175 // disable/enable the solution fields
176 ref->setAddSolutionFields(addSolutionFields_);
177
178 // disable/enable the coordinate fields
179 ref->setAddCoordinateFields(addCoordinateFields_);
180
181 // add all additional fields
182 for(std::size_t i=0;i<additionalFields_.size();i++)
183 ref->addAdditionalField(additionalFields_[i].first,additionalFields_[i].second);
184
185 for(std::size_t i=0;i<removedFields_.size();i++)
186 ref->removeField(removedFields_[i]);
187
188 // set all scaled field values
189 for(std::unordered_map<std::string,double>::const_iterator itr=fieldToScalar_.begin();
190 itr!=fieldToScalar_.end();++itr)
191 ref->scaleField(itr->first,itr->second);
192
193 return ref;
194 }
195
198 void setAddSolutionFields(bool asf)
199 { addSolutionFields_ = asf; }
200
204 { addCoordinateFields_ = acf; }
205
206private:
207 std::unordered_map<std::string,double> fieldToScalar_;
208 std::vector<std::pair<std::string,Teuchos::RCP<const panzer::PureBasis> > > additionalFields_;
209 std::vector<std::string> removedFields_;
212};
213
214}
215
216#endif
PHX::MDField< ScalarT, panzer::Cell, panzer::BASIS > field
A field to which we'll contribute, or in which we'll store, the result of computing this integral.
Object that contains information on the physics and discretization of a block of elements with the SA...
void deleteRemovedFields(const std::vector< std::string > &removedFields, std::vector< std::pair< std::string, Teuchos::RCP< const panzer::PureBasis > > > &fields) const
Delete from the argument all the fields that are in the removedFields array.
virtual Teuchos::RCP< panzer::ResponseBase > buildResponseObject(const std::string &responseName, const std::vector< panzer::WorksetDescriptor > &) const
void addAdditionalField(const std::string &fieldName, const Teuchos::RCP< const panzer::PureBasis > &basis)
virtual void buildAndRegisterEvaluators(const std::string &responseName, PHX::FieldManager< panzer::Traits > &fm, const panzer::PhysicsBlock &physicsBlock, const Teuchos::ParameterList &user_data) const
void computeReferenceCentroid(const std::map< std::string, Teuchos::RCP< const panzer::PureBasis > > &bases, int baseDimension, Kokkos::DynRankView< double, PHX::Device > &centroid) const
static void bucketByBasisType(const std::vector< std::pair< std::string, Teuchos::RCP< const panzer::PureBasis > > > &providedDofs, std::map< std::string, std::vector< std::string > > &basisBucket)
std::vector< std::pair< std::string, Teuchos::RCP< const panzer::PureBasis > > > additionalFields_
virtual Teuchos::RCP< panzer::ResponseBase > buildResponseObject(const std::string &responseName) const
Teuchos::RCP< panzer::ResponseEvaluatorFactoryBase > build() const
void addAdditionalField(const std::string &fieldName, const Teuchos::RCP< const panzer::PureBasis > &basis)
void scaleField(const std::string &fieldName, double fieldScalar)
std::vector< std::pair< std::string, Teuchos::RCP< const panzer::PureBasis > > > additionalFields_
bool operator()(const std::pair< std::string, Teuchos::RCP< const panzer::PureBasis > > &field)