-
Notifications
You must be signed in to change notification settings - Fork 90
/
Copy pathAlbany_StateInfoStruct.hpp
185 lines (162 loc) · 4.69 KB
/
Albany_StateInfoStruct.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
//*****************************************************************//
// Albany 3.0: Copyright 2016 Sandia Corporation //
// This Software is released under the BSD license detailed //
// in the file "license.txt" in the top-level Albany directory //
//*****************************************************************//
#ifndef ALBANY_STATE_INFO_STRUCT
#define ALBANY_STATE_INFO_STRUCT
// The StateInfoStruct contains information from the Problem
// (via the State Manager) that is used by STK to define Fields.
// This includes name, number of quantities (scalar,vector,tensor),
// Element vs Node location, etc.
#include "Albany_AbstractNodeFieldContainer.hpp"
#include "Albany_ScalarOrdinalTypes.hpp"
#include "Albany_DualDynRankView.hpp"
#include "Phalanx_DataLayout.hpp"
#include "Shards_Array.hpp"
#include "Shards_CellTopologyData.h"
#include <map>
#include <string>
#include <vector>
namespace Albany {
using StateView = DualDynRankView<double>;
using StateArray = std::map<std::string,StateView>;
using StateArrayVec = std::vector<StateArray>;
struct StateArrays
{
StateArrayVec elemStateArrays;
StateArrayVec nodeStateArrays;
};
//! Container to get state info from StateManager to STK. Made into a struct so
// the information can continue to evolve without changing the interfaces.
struct StateStruct
{
enum StateType
{
ElemState = 1,
NodeState
};
enum MeshFieldEntity
{
WorksetValue,
NodalData,
ElemNode,
ElemData,
NodalDataToElemNode,
NodalDistParameter,
QuadPoint
};
typedef std::vector<PHX::DataLayout::size_type> FieldDims;
StateStruct(const std::string& name_, MeshFieldEntity ent)
: name(name_),
entity(ent),
responseIDtoRequire(""),
output(true),
restartDataAvailable(false),
saveOldState(false),
layered(false),
meshPart(""),
pParentStateStruct(NULL)
{
}
StateStruct(
const std::string& name_,
MeshFieldEntity ent,
const FieldDims& dims,
const std::string& type,
const std::string& meshPart_ = "",
const std::string& ebName_ = "")
: name(name_),
dim(dims),
entity(ent),
initType(type),
responseIDtoRequire(""),
output(true),
restartDataAvailable(false),
saveOldState(false),
layered(false),
meshPart(meshPart_),
ebName(ebName_),
pParentStateStruct(NULL)
{
}
void
setInitType(const std::string& type)
{
initType = type;
}
void
setInitValue(const double val)
{
initValue = val;
}
void
setFieldDims(const FieldDims& dims)
{
dim = dims;
}
void
setMeshPart(const std::string& meshPart_)
{
meshPart = meshPart_;
}
void
setEBName(const std::string& ebName_)
{
ebName = ebName_;
}
void
print()
{
std::cout << "StateInfoStruct diagnostics for : " << name << std::endl;
std::cout << "Dimensions : " << std::endl;
for (unsigned i = 0; i < dim.size(); ++i) {
std::cout << " " << i << " " << dim[i] << std::endl;
}
std::cout << "Entity : " << entity << std::endl;
}
StateType stateType () const {
switch (entity) {
case StateStruct::WorksetValue:
case StateStruct::ElemData:
case StateStruct::QuadPoint:
case StateStruct::ElemNode:
return ElemState;
case StateStruct::NodalData:
case StateStruct::NodalDataToElemNode:
return NodeState;
default:
TEUCHOS_TEST_FOR_EXCEPTION (true, std::runtime_error,
"Error! Unhandled/unsupported state type.\n");
}
}
const std::string name{""};
FieldDims dim;
MeshFieldEntity entity;
std::string initType{""};
double initValue{0.0};
std::map<std::string, std::string> nameMap;
// For proper PHAL_SaveStateField functionality - maybe only needed
// temporarily?
// If nonzero length, the responseID for response
// field manager to require (assume dummy data layout)
std::string responseIDtoRequire{""};
bool output{false};
bool restartDataAvailable{false};
// Bool that this state is to be copied into name+"_old"
bool saveOldState{false};
bool layered{false};
std::string meshPart{""};
std::string ebName{""};
// If this is a copy (name = parentName+"_old"), ptr to parent struct
StateStruct* pParentStateStruct{nullptr};
StateStruct();
};
// New container class approach
class StateInfoStruct : public std::vector<Teuchos::RCP<StateStruct>>
{
public:
NodeFieldContainer nodal_field_container;
};
} // namespace Albany
#endif // ALBANY_STATEINFOSTRUCT