Panzer Version of the Day
Loading...
Searching...
No Matches
Panzer_FieldLibrary.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
12
13namespace panzer {
14
15Teuchos::RCP<const panzer::PureBasis> FieldLayoutLibrary::lookupBasis(const std::string & fieldName) const
16{
17 Teuchos::RCP<panzer::BasisIRLayout> layout = lookupLayout(fieldName);
18
19 if(layout==Teuchos::null) {
20 std::stringstream ss;
21 print(ss);
22 TEUCHOS_TEST_FOR_EXCEPTION(layout==Teuchos::null,std::logic_error,
23 "panzer::FieldLayoutLibrary::lookupBasis: cannot find field with name \"" + fieldName + "\"!\n"+ss.str());
24 }
25
26 return layout->getBasis();
27}
28
29void FieldLayoutLibrary::uniqueBases(std::vector<Teuchos::RCP<const panzer::PureBasis> > & bases) const
30{
31 bases.clear();
32
33 // simply loop over map of basis name to pointers and add them to the vector
34 std::map<std::string,Teuchos::RCP<const panzer::PureBasis> >::const_iterator itr;
35 for(itr=basisNameToPointer_.begin();itr!=basisNameToPointer_.end();++itr)
36 bases.push_back(itr->second);
37}
38
39void FieldLayoutLibrary::addFieldAndLayout(const std::string & fieldName,
40 const Teuchos::RCP<panzer::BasisIRLayout> & layout)
41{
42 fieldToLayout_[fieldName] = layout;
43 basisNameToPointer_[layout->getBasis()->name()] = layout->getBasis();
44}
45
46Teuchos::RCP<panzer::BasisIRLayout> FieldLayoutLibrary::lookupLayout(const std::string & fieldName) const
47{
48 typedef std::map<std::string,Teuchos::RCP<panzer::BasisIRLayout> > Map;
49 Map::const_iterator itr = fieldToLayout_.find(fieldName);
50 if(itr!=fieldToLayout_.end())
51 return itr->second;
52
53 return Teuchos::null;
54}
55
56void FieldLayoutLibrary::print(std::ostream & os) const
57{
58 typedef std::map<std::string,Teuchos::RCP<panzer::BasisIRLayout> > Map;
59
60 for(Map::const_iterator itr=fieldToLayout_.begin();itr!=fieldToLayout_.end();++itr) {
61 std::string fieldName = itr->first;
62 Teuchos::RCP<BasisIRLayout> basis = itr->second;
63
64 os << "\"" << fieldName << "\"" << " {" << basis->name()
65 << "(dim=" << basis->dimension()
66 << ",cells=" << basis->numCells()
67 << ",points=" << basis->numPoints() << ")} ";
68 }
69}
70
71void FieldLayoutLibrary::basisPairs(std::vector<std::pair<std::string,Teuchos::RCP<const panzer::PureBasis> > > & bases) const
72{
73 typedef std::map<std::string,Teuchos::RCP<panzer::BasisIRLayout> > Map;
74 bases.clear();
75
76 for(Map::const_iterator itr=fieldToLayout_.begin();itr!=fieldToLayout_.end();++itr) {
77 std::string fieldName = itr->first;
78 Teuchos::RCP<const PureBasis> basis = itr->second->getBasis();
79
80 bases.push_back(std::make_pair(fieldName,basis));
81 }
82}
83
85
86Teuchos::RCP<const panzer::PureBasis> FieldLibrary::lookupBasis(const std::string & fieldName) const
87{
88 typedef std::map<std::string,Teuchos::RCP<panzer::PureBasis> > Map;
89 Map::const_iterator itr = fieldToBasis_.find(fieldName);
90 if(itr!=fieldToBasis_.end())
91 return itr->second;
92
93 return Teuchos::null;
94}
95
96void FieldLibrary::uniqueBases(std::vector<Teuchos::RCP<const panzer::PureBasis> > & bases) const
97{
98 bases.clear();
99
100 // simply loop over map of basis name to pointers and add them to the vector
101 std::map<std::string,Teuchos::RCP<const panzer::PureBasis> >::const_iterator itr;
102 for(itr=basisNameToPointer_.begin();itr!=basisNameToPointer_.end();++itr)
103 bases.push_back(itr->second);
104}
105
106void FieldLibrary::addFieldAndBasis(const std::string & fieldName,
107 const Teuchos::RCP<panzer::PureBasis> & basis)
108{
109 fieldToBasis_[fieldName] = basis;
110 basisNameToPointer_[basis->name()] = basis;
111}
112
113Teuchos::RCP<const FieldLayoutLibrary> FieldLibrary::buildFieldLayoutLibrary(panzer::PointRule & ir) const
114{
115 typedef std::map<std::string,Teuchos::RCP<panzer::PureBasis> > Map;
116
117 Teuchos::RCP<FieldLayoutLibrary> layoutLibrary = Teuchos::rcp(new FieldLayoutLibrary);
118
119 // loop over each member of the map, create a new FieldLayout and addit to layout library
120 for(Map::const_iterator itr=fieldToBasis_.begin();itr!=fieldToBasis_.end();++itr) {
121 Teuchos::RCP<BasisIRLayout> layout = Teuchos::rcp(new BasisIRLayout(itr->second,ir));
122 layoutLibrary->addFieldAndLayout(itr->first,layout);
123 }
124
125 return layoutLibrary;
126}
127
128void FieldLibrary::print(std::ostream & os) const
129{
130 typedef std::map<std::string,Teuchos::RCP<panzer::PureBasis> > Map;
131
132 for(Map::const_iterator itr=fieldToBasis_.begin();itr!=fieldToBasis_.end();++itr) {
133 std::string fieldName = itr->first;
134 Teuchos::RCP<PureBasis> basis = itr->second;
135
136 os << "\"" << fieldName << "\"" << " {" << basis->name()
137 << "(dim=" << basis->dimension()
138 << ",cells=" << basis->numCells() << ") ";
139 }
140}
141
143void FieldLibrary::basisPairs(std::vector<std::pair<std::string,Teuchos::RCP<const panzer::PureBasis> > > & bases) const
144{
145 typedef std::map<std::string,Teuchos::RCP<panzer::PureBasis> > Map;
146 bases.clear();
147
148 for(Map::const_iterator itr=fieldToBasis_.begin();itr!=fieldToBasis_.end();++itr) {
149 std::string fieldName = itr->first;
150 Teuchos::RCP<PureBasis> basis = itr->second;
151
152 bases.push_back(std::make_pair(fieldName,basis.getConst()));
153 }
154}
155
156}
Teuchos::RCP< panzer::BasisIRLayout > lookupLayout(const std::string &fieldName) const
Get the basis associated with a particular field.
virtual Teuchos::RCP< const panzer::PureBasis > lookupBasis(const std::string &fieldName) const
Get the basis associated with a particular field.
virtual void print(std::ostream &os) const
void addFieldAndLayout(const std::string &fieldName, const Teuchos::RCP< panzer::BasisIRLayout > &basis)
void uniqueBases(std::vector< Teuchos::RCP< const panzer::PureBasis > > &bases) const
Get vector of unique bases contained in this field library.
virtual void basisPairs(std::vector< std::pair< std::string, Teuchos::RCP< const panzer::PureBasis > > > &bases) const
Get vector of unique bases contained in this field library.
std::map< std::string, Teuchos::RCP< panzer::BasisIRLayout > > fieldToLayout_
Basic mapped storage.
std::map< std::string, Teuchos::RCP< const panzer::PureBasis > > basisNameToPointer_
std::map< std::string, Teuchos::RCP< panzer::PureBasis > > fieldToBasis_
Basic mapped storage.
std::map< std::string, Teuchos::RCP< const panzer::PureBasis > > basisNameToPointer_
virtual Teuchos::RCP< const panzer::PureBasis > lookupBasis(const std::string &fieldName) const
Get the basis associated with a particular field.
virtual void basisPairs(std::vector< std::pair< std::string, Teuchos::RCP< const panzer::PureBasis > > > &bases) const
Get vector of unique bases contained in this field library.
virtual void print(std::ostream &os) const
void addFieldAndBasis(const std::string &fieldName, const Teuchos::RCP< panzer::PureBasis > &basis)
Teuchos::RCP< const FieldLayoutLibrary > buildFieldLayoutLibrary(panzer::PointRule &ir) const
void uniqueBases(std::vector< Teuchos::RCP< const panzer::PureBasis > > &bases) const
Get vector of unique bases contained in this field library.