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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345 | // *****************************************************************************
/*!
\file src/Inciter/KozCG.hpp
\copyright 2012-2015 J. Bakosi,
2016-2018 Los Alamos National Security, LLC.,
2019-2021 Triad National Security, LLC.,
2022-2025 J. Bakosi
All rights reserved. See the LICENSE file for details.
\brief KozCG: Taylor-Galerkin, FCT, element-based continuous Galerkin
*/
// *****************************************************************************
#pragma once
#include <vector><--- Include file: not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <map><--- Include file:
#include "Types.hpp"
#include "Fields.hpp"
#include "Table.hpp"
#include "DerivedData.hpp"<--- Include file: "DerivedData.hpp" not found.
#include "NodeDiagnostics.hpp"
#include "NoWarning/kozcg.decl.h"<--- Include file: "NoWarning/kozcg.decl.h" not found.
namespace inciter {
//! KozCG Charm++ chare array used to advance PDEs in time with KozCG
class KozCG : public CBase_KozCG {
public:
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#elif defined(STRICT_GNUC)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#elif defined(__INTEL_COMPILER)
#pragma warning( push )
#pragma warning( disable: 1478 )
#endif
// Include Charm++ SDAG code. See http://charm.cs.illinois.edu/manuals/html/
// charm++/manual.html, Sec. "Structured Control Flow: Structured Dagger".
KozCG_SDAG_CODE
#if defined(__clang__)
#pragma clang diagnostic pop
#elif defined(STRICT_GNUC)
#pragma GCC diagnostic pop
#elif defined(__INTEL_COMPILER)
#pragma warning( pop )
#endif
//! Constructor
explicit KozCG( const CProxy_Discretization& disc,
const std::map< int, std::vector< std::size_t > >& bface,
const std::map< int, std::vector< std::size_t > >& bnode,
const std::vector< std::size_t >& triinpoel );
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundefined-func-template"
#endif
//! Migrate constructor
// cppcheck-suppress uninitMemberVar
explicit KozCG( CkMigrateMessage* m ) : CBase_KozCG( m ) {}
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
//! Configure Charm++ custom reduction types initiated from this chare array
static void registerReducers();
//! Return from migration
void ResumeFromSync() override;
//! Start setup for solution
void setup( tk::real v );
// Start time stepping
void start();
//! Advance equations to next time step
void advance( tk::real newdt );
//! Start (re-)computing domain and boundary integrals
void feop();
//! Receive contributions to boundary point normals on chare-boundaries
void comnorm( const std::unordered_map< int,
std::unordered_map< std::size_t, std::array< tk::real, 4 > > >& inbnd );
//! Receive contributions to right-hand side vector on chare-boundaries
void comrhs( const std::unordered_map< std::size_t,
std::vector< tk::real > >& inrhs );
//! Receive antidiffusive and low-order contributions on chare-boundaries
void comaec( const std::unordered_map< std::size_t,
std::vector< tk::real > >& inaec );
//! Receive allowed limits contributions on chare-boundaries
void comalw( const std::unordered_map< std::size_t,
std::vector< tk::real > >& inalw );
//! Receive limited antidiffusive contributions on chare-boundaries
void comlim( const std::unordered_map< std::size_t,
std::vector< tk::real > >& inlim );
//! Evaluate residuals
void evalres( const std::vector< tk::real >& l2res );
//! Receive new mesh from Refiner
void resizePostAMR(
const std::vector< std::size_t >& ginpoel,
const tk::UnsMesh::Chunk& chunk,
const tk::UnsMesh::Coords& coord,
const std::unordered_map< std::size_t, tk::UnsMesh::Edge >& addedNodes,
const std::unordered_map< std::size_t, std::size_t >& addedTets,
const std::set< std::size_t >& removedNodes,
const std::unordered_map< int, std::unordered_set< std::size_t > >&
nodeCommMap,
const std::map< int, std::vector< std::size_t > >& bface,
const std::map< int, std::vector< std::size_t > >& bnode,
const std::vector< std::size_t >& triinpoel );
//! Const-ref access to current solution
//! \return Const-ref to current solution
const tk::Fields& solution() const { return m_u; }
//! Compute integral quantities for output
void integrals();
//! Evaluate whether to continue with next time step
void step();
//! Evaluate whether to do load balancing
void evalLB( int nrestart );
/** @name Charm++ pack/unpack serializer member functions */
///@{
//! \brief Pack/Unpack serialize member function
//! \param[in,out] p Charm++'s PUP::er serializer object reference
void pup( PUP::er &p ) override {
p | m_disc;
p | m_nrhs;
p | m_nnorm;
p | m_naec;
p | m_nalw;
p | m_nlim;
p | m_bnode;
p | m_bface;
p | m_triinpoel;
p | m_u;
p | m_p;
p | m_pc;
p | m_q;
p | m_qc;
p | m_a;
p | m_ac;
// do not pup these, will recompute after migration anyway
if (p.isUnpacking()) {
m_rhs.resize( m_u.nunk(), m_u.nprop() );
}
p | m_rhsc;
p | m_diag;
p | m_bnorm;
p | m_bnormc;
p | m_bndpoinint;
p | m_dirbcmasks;
p | m_prebcnodes;
p | m_prebcvals;
p | m_symbcnodeset;
p | m_symbcnodes;
p | m_symbcnorms;
p | m_farbcnodeset;
p | m_farbcnodes;
p | m_farbcnorms;
p | m_surfint;
p | m_dtp;
p | m_tp;
p | m_finished;
p | m_freezeflow;
}
//! \brief Pack/Unpack serialize operator|
//! \param[in,out] p Charm++'s PUP::er serializer object reference
//! \param[in,out] i KozCG object reference
friend void operator|( PUP::er& p, KozCG& i ) { i.pup(p); }
//@}
private:
//! Discretization proxy
CProxy_Discretization m_disc;
//! Counter for right-hand side vector nodes updated
std::size_t m_nrhs;
//! Counter for receiving boundary point normals
std::size_t m_nnorm;
//! Counter for receiving antidiffusive contributions
std::size_t m_naec;
//! Counter for receiving allowed limits
std::size_t m_nalw;
//! Counter for receiving limited antidiffusive contributions
std::size_t m_nlim;
//! Boundary node lists mapped to side set ids used in the input file
std::map< int, std::vector< std::size_t > > m_bnode;
//! Boundary face lists mapped to side set ids used in the input file
std::map< int, std::vector< std::size_t > > m_bface;
//! Boundary triangle face connecitivity where BCs are set by user
std::vector< std::size_t > m_triinpoel;
//! Unknown/solution vector at mesh nodes
tk::Fields m_u;
//! Max/min antidiffusive edge contributions at mesh nodes
tk::Fields m_p;
//! Receive buffer for max/min antidiffusive edge contributions
//! \details Key: global node id, value: max/min antidiff edge contributions
//! in nodes.
std::unordered_map< std::size_t, std::vector< tk::real > > m_pc;
//! Max/min allowed limits at mesh nodes
tk::Fields m_q;
//! Receive buffer for max/min allowed limits
//! \details Key: global node id, value: max/min allowed limits in nodes.
std::unordered_map< std::size_t, std::vector< tk::real > > m_qc;
//! Limited antidiffusive contributions at mesh nodes
tk::Fields m_a;
//! Receive buffer for limited antidiffusive contributions
//! \details Key: global node id, value: limited antidiffusive contributions
//! in nodes.
std::unordered_map< std::size_t, std::vector< tk::real > > m_ac;
//! Right-hand side vector (for the high order system)
tk::Fields m_rhs;
//! Receive buffer for communication of the right hand side
//! \details Key: global node id, value: rhs for all scalar components per
//! node.
std::unordered_map< std::size_t, std::vector< tk::real > > m_rhsc;
//! Diagnostics object
NodeDiagnostics m_diag;
//! Boundary point normals
//! \details Outer key: side set id. Inner key: global node id of boundary
//! point, value: weighted normals, inverse distance square, nodal area.
std::unordered_map< int,
std::unordered_map< std::size_t, std::array< tk::real, 4 > > > m_bnorm;
//! Boundary point normals receive buffer
//! \details Outer key: side set id. Inner key: global node id of boundary
//! point, value: weighted normals and inverse distance square.
decltype(m_bnorm) m_bnormc;
//! Boundary point integrals
//! \details Key: global node id of boundary point, value: boundary point
//! integral contributions.
std::unordered_map< std::size_t, std::array< tk::real, 3 > > m_bndpoinint;
//! Nodes and their Dirichlet BC masks
std::vector< std::size_t > m_dirbcmasks;
//! Nodes at pressure BCs
std::vector< std::size_t > m_prebcnodes;
//! Density and pressure values at pressure BCs
std::vector< tk::real > m_prebcvals;
//! Unique set of ordered nodes at which symmetry BCs are set
std::set< std::size_t > m_symbcnodeset;
//! Streamable nodes at which symmetry BCs are set
std::vector< std::size_t > m_symbcnodes;
//! Streamable normals at nodes at which symmetry BCs are set
std::vector< tk::real > m_symbcnorms;
//! Unique set of ordered nodes at which farfield BCs are set
std::set< std::size_t > m_farbcnodeset;
//! Streamable nodes at which farfield BCs are set
std::vector< std::size_t > m_farbcnodes;
//! Streamable normals at nodes at which farfield BCs are set
std::vector< tk::real > m_farbcnorms;
//! Streamable surface integral nodes and normals * dA on surfaces
std::map< int, std::pair< std::vector< std::size_t >,
std::vector< tk::real > > > m_surfint;
//! Time step size for each mesh node
std::vector< tk::real > m_dtp;
//! Physical time for each mesh node
std::vector< tk::real > m_tp;
//! True in the last time step
int m_finished;
//! dt multiplier after flow no longer updated
tk::real m_freezeflow;
//! Access bound Discretization class pointer
Discretization* Disc() const {
Assert( m_disc[ thisIndex ].ckLocal() != nullptr, "ckLocal() null" );
return m_disc[ thisIndex ].ckLocal();
}
//! Prepare boundary condition data structures
void setupBC();
//! Compute chare-boundary edges
void bndEdges();
//! Compute boundary point normals
void bndint();
//! Combine own and communicated portions of the boundary point normals
void bnorm();
//! Convert integrals into streamable data structures
void streamable();
//! Output mesh and particle fields to files
void out();
//! Output mesh-based fields to file
void writeFields( CkCallback cb );
//! Combine own and communicated portions of the integrals
void merge();
//! Compute righ-hand side vector of transport equations
void rhs();
//! Continue with flux-corrected transport if enabled
void fct();
//! Compute antidiffusive contributions: P+/-, low-order solution: ul
void aec();
//! Compute allowed limits, Q+/-
void alw();
//! Compute limit coefficients
void lim();
//! Advance systems of equations
void solve();
//! Refine/derefine mesh
void refine();
//! Compute time step size
void dt();
//! Evaluate whether to save checkpoint/restart
void evalRestart();
//! Apply boundary conditions
void BC( tk::Fields& u, tk::real t );
//! Apply scalar source to solution
void src();
};
} // inciter::
|