BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
cl_Mesh_Field.hpp
Go to the documentation of this file.
1/*
2 * BELFEM -- The Berkeley Lab Finite Element Framework
3 * Copyright (c) 2026, The Regents of the University of California,
4 * through Lawrence Berkeley National Laboratory (subject to receipt of any required
5 * approvals from the U.S. Dept. of Energy). All rights reserved.
6 *
7 * Developers: Christian Messe, Gregory Giard
8 *
9 * See the top-level LICENSE file for the complete license and disclaimer.
10 */
11
12#ifndef BELFEM_CL_MESH_FIELD_HPP
13#define BELFEM_CL_MESH_FIELD_HPP
14
15#include "typedefs.hpp"
16#include "cl_Vector.hpp"
17#include "cl_Matrix.hpp"
18
19#include "Mesh_Enums.hpp"
20
21namespace belfem
22{
23 class Mesh;
24
25 namespace mesh
26 {
27 class Field
28 {
29//------------------------------------------------------------------------------
30 protected:
31//------------------------------------------------------------------------------
32
34 string mLabel;
36 const id_t mID ;
39
41
42 // flag telling if field is written to output file
43 bool mWriteToFile = true ;
44
45//------------------------------------------------------------------------------
46 public:
47//------------------------------------------------------------------------------
48
49 Field( Mesh & aParent,
50 const string & aLabel,
51 const index_t & aIndex,
52 const id_t & aID,
53 const EntityType aEntityType=EntityType::NODE,
54 const FieldType aFieldType=FieldType::SCALAR );
55
56//------------------------------------------------------------------------------
57
58 virtual ~Field() = default;
59
60//------------------------------------------------------------------------------
61
62 const string &
63 label() const;
64
65//------------------------------------------------------------------------------
66
67 const EntityType &
69
70//------------------------------------------------------------------------------
71
72 const FieldType &
73 field_type();
74
75//------------------------------------------------------------------------------
76
78 data();
79
80//------------------------------------------------------------------------------
81
82 const id_t &
83 id() const;
84
85//------------------------------------------------------------------------------
86
87 real &
88 value( const index_t aIndex );
89
90//------------------------------------------------------------------------------
91
96 const index_t &
97 index() const ;
98
99//------------------------------------------------------------------------------
100
104 void
105 fill( const id_t aID, const real aValue );
106
107//------------------------------------------------------------------------------
108
112 void
113 fill( const Vector< id_t > & aIDs, const real aValue );
114
115//------------------------------------------------------------------------------
116
117 bool
118 write_field_to_file() const ;
119
120//------------------------------------------------------------------------------
121
122 void
123 set_write_to_file_flag( const bool aFlag );
124
125//------------------------------------------------------------------------------
126
127 size_t
128 memory() const ;
129
130//------------------------------------------------------------------------------
131 };
132
133
134//------------------------------------------------------------------------------
135
136 inline real &
137 Field::value( const index_t aIndex )
138 {
139 return mData( aIndex );
140 }
141
142//------------------------------------------------------------------------------
143
144 inline const index_t &
146 {
147 return mIndex ;
148 }
149
150//------------------------------------------------------------------------------
151
152 inline bool
154 {
155 return mWriteToFile ;
156 }
157
158//------------------------------------------------------------------------------
159
160 inline void
162 {
163 mWriteToFile = aFlag ;
164 }
165
166//------------------------------------------------------------------------------
167
168 inline size_t
170 {
171 return sizeof( Field )
172 + mData.length() * sizeof( real )
173 + mLabel.capacity() * sizeof( char ) ;
174 }
175
176//------------------------------------------------------------------------------
177 }
178}
179#endif //BELFEM_CL_MESH_FIELD_HPP
Top-level container for all mesh entities.
Definition cl_Mesh.hpp:60
size_t length() const
get the length of the vector
Definition cl_AR_Vector.hpp:257
void set_write_to_file_flag(const bool aFlag)
Definition cl_Mesh_Field.hpp:161
bool write_field_to_file() const
Definition cl_Mesh_Field.hpp:153
const string & label() const
Definition cl_Mesh_Field.cpp:74
bool mWriteToFile
Definition cl_Mesh_Field.hpp:43
real & value(const index_t aIndex)
Definition cl_Mesh_Field.hpp:137
Mesh & mParent
Definition cl_Mesh_Field.hpp:33
const FieldType mFieldType
Definition cl_Mesh_Field.hpp:38
size_t memory() const
Definition cl_Mesh_Field.hpp:169
const FieldType & field_type()
Definition cl_Mesh_Field.cpp:90
string mLabel
Definition cl_Mesh_Field.hpp:34
const index_t mIndex
Definition cl_Mesh_Field.hpp:35
const EntityType & entity_type()
Definition cl_Mesh_Field.cpp:82
Vector< real > mData
Definition cl_Mesh_Field.hpp:40
const EntityType mEntityType
Definition cl_Mesh_Field.hpp:37
virtual ~Field()=default
void fill(const id_t aID, const real aValue)
reset a field based on a sideset or block id
Definition cl_Mesh_Field.cpp:114
Vector< real > & data()
Definition cl_Mesh_Field.cpp:98
const index_t & index() const
returns the index of the field on the mesh
Definition cl_Mesh_Field.hpp:145
const id_t mID
Definition cl_Mesh_Field.hpp:36
Field(Mesh &aParent, const string &aLabel, const index_t &aIndex, const id_t &aID, const EntityType aEntityType=EntityType::NODE, const FieldType aFieldType=FieldType::SCALAR)
Definition cl_Mesh_Field.cpp:22
const id_t & id() const
Definition cl_Mesh_Field.cpp:106
Definition cl_EF_EdgeFunction.hpp:17
USER GUIDES:
Definition cl_Capacitor.cpp:16
unsigned int id_t
Definition typedefs.hpp:41
FieldType
Definition Mesh_Enums.hpp:139
@ SCALAR
Definition Mesh_Enums.hpp:140
EntityType
Definition Mesh_Enums.hpp:116
@ NODE
Definition Mesh_Enums.hpp:117
uint32_t index_t
Definition typedefs.hpp:52
double real
Definition typedefs.hpp:36