PRISMS-PF Manual v3.0-pre
Loading...
Searching...
No Matches
fields.h
1#ifndef FIELDS_H
2#define FIELDS_H
3
4#include <deal.II/base/conditional_ostream.h>
5
6#include <core/varTypeEnums.h>
7#include <stdexcept>
8#include <string>
9#include <utility>
10
14template <int dim>
15class Field
16{
17public:
21 Field(fieldType _type, PDEType _pdetype, std::string _name);
22
23 fieldType type;
24 PDEType pdetype;
25 std::string name;
26 unsigned int index;
27 unsigned int startIndex;
28 unsigned int numComponents;
29 bool hasDirichletBCs;
30 bool hasnonuniformDirichletBCs;
31 bool hasNeumannBCs;
32
33private:
37 static unsigned int fieldCount;
38
42 static unsigned int indexCount;
43
47 void
48 validate_enum_types();
49
54 void
55 init_components();
56
60 void
61 init_BCs();
62};
63
64// initialize static variables
65template <int dim>
66unsigned int Field<dim>::fieldCount = 0;
67
68template <int dim>
69unsigned int Field<dim>::indexCount = 0;
70
71// constructor
72template <int dim>
73Field<dim>::Field(fieldType _type, PDEType _pdetype, std::string _name)
74 : type(_type)
75 , pdetype(_pdetype)
76 , name(std::move(_name))
77{
78 validate_enum_types();
79
80 // Set the index to the current field count and increment field count as new field is
81 // being created
82 index = fieldCount++;
83 startIndex = indexCount;
84
85 init_components();
86
87 init_BCs();
88}
89
90template <int dim>
91void
93{
94 // Validate fieldType
95 switch (type)
96 {
97 case fieldType::SCALAR:
98 case fieldType::VECTOR:
99 break;
100 default:
101 throw std::invalid_argument("Unknown field type in Field constructor.");
102 }
103
104 switch (pdetype)
105 {
106 case PDEType::EXPLICIT_TIME_DEPENDENT:
107 case PDEType::AUXILIARY:
108 case PDEType::IMPLICIT_TIME_DEPENDENT:
109 case PDEType::TIME_INDEPENDENT:
110 break;
111 default:
112 throw std::invalid_argument("Unknown PDE type in Field constructor.");
113 }
114}
115
116template <int dim>
117void
119{
120 switch (type)
121 {
122 case SCALAR:
123 indexCount += 1;
124 numComponents = 1;
125 break;
126 case VECTOR:
127 indexCount += dim;
128 numComponents = dim;
129 break;
130 default:
131 break;
132 }
133}
134
135template <int dim>
136void
138{
139 // Default assignment of BCs
140 hasDirichletBCs = false;
141 hasnonuniformDirichletBCs = false;
142 hasNeumannBCs = false;
143}
144
145#endif
Field class that handles the attributes of each field.
Definition fields.h:16
Field(fieldType _type, PDEType _pdetype, std::string _name)
Constructor.
Definition fields.h:73