Branch data Line data Source code
1 : : // *****************************************************************************
2 : : /*!
3 : : \file src/Inciter/Discretization.hpp
4 : : \copyright 2012-2015 J. Bakosi,
5 : : 2016-2018 Los Alamos National Security, LLC.,
6 : : 2019-2021 Triad National Security, LLC.
7 : : All rights reserved. See the LICENSE file for details.
8 : : \details Data and functionality common to all discretization schemes
9 : : The Discretization class contains data and functionality common to all
10 : : discretization schemes.
11 : : */
12 : : // *****************************************************************************
13 : : #ifndef Discretization_h
14 : : #define Discretization_h
15 : :
16 : : #include <brigand/algorithms/for_each.hpp>
17 : :
18 : : #include "Types.hpp"
19 : : #include "Timer.hpp"
20 : : #include "Fields.hpp"
21 : : #include "PUPUtil.hpp"
22 : : #include "PDFReducer.hpp"
23 : : #include "UnsMesh.hpp"
24 : : #include "CommMap.hpp"
25 : : #include "History.hpp"
26 : : #include "Inciter/InputDeck/InputDeck.hpp"
27 : :
28 : : #include "NoWarning/discretization.decl.h"
29 : : #include "NoWarning/refiner.decl.h"
30 : :
31 : : namespace inciter {
32 : :
33 : : extern ctr::InputDeck g_inputdeck;
34 : :
35 : : //! \brief Discretization Charm++ chare array holding common functinoality to
36 : : //! all discretization schemes
37 : : class Discretization : public CBase_Discretization {
38 : :
39 : : public:
40 : : #if defined(__clang__)
41 : : #pragma clang diagnostic push
42 : : #pragma clang diagnostic ignored "-Wunused-parameter"
43 : : #pragma clang diagnostic ignored "-Wdeprecated-declarations"
44 : : #elif defined(STRICT_GNUC)
45 : : #pragma GCC diagnostic push
46 : : #pragma GCC diagnostic ignored "-Wunused-parameter"
47 : : #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
48 : : #elif defined(__INTEL_COMPILER)
49 : : #pragma warning( push )
50 : : #pragma warning( disable: 1478 )
51 : : #endif
52 : : // Include Charm++ SDAG code. See http://charm.cs.illinois.edu/manuals/html/
53 : : // charm++/manual.html, Sec. "Structured Control Flow: Structured Dagger".
54 : : Discretization_SDAG_CODE
55 : : #if defined(__clang__)
56 : : #pragma clang diagnostic pop
57 : : #elif defined(STRICT_GNUC)
58 : : #pragma GCC diagnostic pop
59 : : #elif defined(__INTEL_COMPILER)
60 : : #pragma warning( pop )
61 : : #endif
62 : :
63 : : //! Constructor
64 : : explicit
65 : : Discretization(
66 : : std::size_t meshid,
67 : : const std::vector< CProxy_Discretization >& disc,
68 : : const CProxy_ALE& aleproxy,
69 : : const tk::CProxy_ConjugateGradients& conjugategradientsproxy,
70 : : const tk::CProxy_BiCG& implicitsolverproxy,
71 : : const CProxy_Transporter& transporter,
72 : : const tk::CProxy_MeshWriter& meshwriter,
73 : : const tk::UnsMesh::CoordMap& coordmap,
74 : : const tk::UnsMesh::Chunk& el,
75 : : const tk::CommMaps& msum,
76 : : const std::map< int, std::vector< std::size_t > >& bface,
77 : : const std::vector< std::size_t >& triinpoel,
78 : : const std::unordered_map< std::size_t, std::set< std::size_t > >&
79 : : elemblockid,
80 : : int nc );
81 : :
82 : : #if defined(__clang__)
83 : : #pragma clang diagnostic push
84 : : #pragma clang diagnostic ignored "-Wundefined-func-template"
85 : : #endif
86 : : //! Migrate constructor
87 : : // cppcheck-suppress uninitMemberVar
88 [ + - ]: 4073 : explicit Discretization( CkMigrateMessage* ) {}
89 : : #if defined(__clang__)
90 : : #pragma clang diagnostic pop
91 : : #endif
92 : :
93 : : //! Configure Charm++ reduction types
94 : : static void registerReducers();
95 : :
96 : : //! Start computing new mesh veloctity for ALE mesh motion
97 : : void meshvelStart(
98 : : const tk::UnsMesh::Coords vel,
99 : : const std::vector< tk::real >& soundspeed,
100 : : const std::unordered_map< int,
101 : : std::unordered_map< std::size_t, std::array< tk::real, 4 > > >& bnorm,
102 : : tk::real adt,
103 : : CkCallback done ) const;
104 : :
105 : : //! Query the mesh velocity
106 : : const tk::Fields& meshvel() const;
107 : :
108 : : //! \brief Query ALE mesh velocity boundary condition node lists and node
109 : : //! lists at which ALE moves boundaries
110 : : void meshvelBnd(
111 : : const std::map< int, std::vector< std::size_t > >& bface,
112 : : const std::map< int, std::vector< std::size_t > >& bnode,
113 : : const std::vector< std::size_t >& triinpoel ) const;
114 : :
115 : : //! Assess and record mesh velocity linear solver convergence
116 : : void meshvelConv();
117 : :
118 : : //! \brief Our mesh has been registered with the mesh-to-mesh transfer
119 : : //! library (if coupled to other solver)
120 : : void transferInit();
121 : :
122 : : //! Finish setting up communication maps and solution transfer callbacks
123 : : void comfinal();
124 : :
125 : : //! Start solution transfer (if coupled)
126 : : void transfer(
127 : : tk::Fields& u,
128 : : std::size_t dirn,
129 : : CkCallback cb );
130 : :
131 : : //! Solution transfer from background to overset mesh completed (from ExaM2M)
132 : : void to_complete();
133 : :
134 : : //! Solution transfer from overset to background mesh completed (from ExaM2M)
135 : : void from_complete();
136 : :
137 : : //! Solution transfer completed (from dest Discretization)
138 : : void transfer_complete_from_dest();
139 : :
140 : : //! Solution transfer completed (one-way)
141 : : void transfer_complete();
142 : :
143 : : //! Resize mesh data structures after mesh refinement
144 : : void resizePostAMR(
145 : : const tk::UnsMesh::Chunk& chunk,
146 : : const tk::UnsMesh::Coords& coord,
147 : : const std::unordered_map< std::size_t, std::size_t >& amrNodeMap,
148 : : const tk::NodeCommMap& nodeCommMap,
149 : : const std::set< std::size_t >& removedNodes,
150 : : const std::unordered_map< std::size_t, std::set< std::size_t > >&
151 : : elemblockid );
152 : :
153 : : //! Get ready for (re-)computing/communicating nodal volumes
154 : : void startvol();
155 : :
156 : : //! Sum mesh volumes to nodes, start communicating them on chare-boundaries
157 : : void vol();
158 : :
159 : : //! Set Refiner Charm++ proxy
160 : : void setRefiner( const CProxy_Refiner& ref );
161 : :
162 : : //! Collect nodal volumes across chare boundaries
163 : : void comvol( const std::vector< std::size_t >& gid,
164 : : const std::vector< tk::real >& nodevol );
165 : :
166 : : //! Sum mesh volumes and contribute own mesh volume to total volume
167 : : void totalvol();
168 : :
169 : : //! Compute mesh cell statistics
170 : : void stat( tk::real mesh_volume );
171 : :
172 : : //! Compute total box IC volume
173 : : void
174 : : boxvol( const std::vector< std::unordered_set< std::size_t > >& nodes,
175 : : const std::unordered_map< std::size_t, std::set< std::size_t > >& nodeblk,
176 : : std::size_t nuserblk );
177 : :
178 : : /** @name Accessors */
179 : : ///@{
180 : : //! Coordinates accessor as const-ref
181 : 10947 : const tk::UnsMesh::Coords& Coord() const { return m_coord; }
182 : : //! Coordinates accessor as reference
183 : 7670315 : tk::UnsMesh::Coords& Coord() { return m_coord; }
184 : : //! Coordinates at time n accessor as const-ref
185 : 1826220 : const tk::UnsMesh::Coords& Coordn() const { return m_coordn; }
186 : :
187 : : //! Global ids accessors as const-ref
188 : 218102 : const std::vector< std::size_t >& Gid() const { return m_gid; }
189 : :
190 : : //! Local ids accessors as const-ref
191 : 4771350 : const std::unordered_map< std::size_t, std::size_t >& Lid() const
192 : 4771350 : { return m_lid; }
193 : :
194 : : //! Tetrahedron element connectivity (with local ids) accessors as const-ref
195 : 7592705 : const std::vector< std::size_t >& Inpoel() const { return m_inpoel; }
196 : :
197 : : //! Mesh chunk accessor as const-ref
198 : 1481 : const tk::UnsMesh::Chunk& Chunk() const { return m_el; }
199 : :
200 : : //! Mesh block id accessor as const-ref
201 : : const std::unordered_map< std::size_t, std::set< std::size_t > >&
202 : 3070 : ElemBlockId() const { return m_elemblockid; }
203 : :
204 : : //! Total mesh volume accessor
205 : : tk::real meshvol() const { return m_meshvol; }
206 : :
207 : : //! Nodal mesh volume accessors const-ref
208 : 11921 : const std::vector< tk::real >& V() const { return m_v; }
209 : :
210 : : //! Nodal mesh volumes at current time step accessors as const-ref
211 : 2068875 : const std::vector< tk::real >& Vol() const { return m_vol; }
212 : : //! Nodal mesh volumes at previous time step accessors as const-ref
213 : : const std::vector< tk::real >& Voln() const { return m_voln; }
214 : : //! Nodal mesh volumes at previous time step accessors as ref
215 : 26887 : std::vector< tk::real >& Voln() { return m_voln; }
216 : : //! Element mesh volumes at t=t0 accessors as const-ref
217 : : const std::vector< tk::real >& Vol0() const { return m_vol0; }
218 : : //! Element mesh velocity accessor as const-ref
219 : : const tk::Fields& MeshVel() const { return m_meshvel; }
220 : : //! Element mesh velocity accessor as ref
221 : 30196 : tk::Fields& MeshVel() { return m_meshvel; }
222 : :
223 : : //! Set 'initial' flag
224 : : //! \param[in] i Value to put in 'initial'
225 : 738 : void Initial( std::size_t i ) { m_initial = i; }
226 : : //! Query 'initial' flag
227 : : //! \return True during setup, false durign time stepping
228 : 39657 : bool Initial() const { return m_initial; }
229 : :
230 : : //! Update coordinates at time n
231 : 3356 : void UpdateCoordn() { m_coordn = m_coord; }
232 : :
233 : : //! History points data accessor as const-ref
234 : 214 : const std::vector< HistData >& Hist() const { return m_histdata; }
235 : :
236 : : //! Box volume accessor
237 : 39541 : tk::real& Boxvol() { return m_boxvol; }
238 : :
239 : : //! Block volume accessor
240 : 1476 : std::vector< tk::real >& MeshBlkVol() { return m_meshblkvol; }
241 : :
242 : : //! Mesh ID accessor
243 : 8316316 : std::size_t MeshId() const { return m_meshid; }
244 : :
245 : : //! Time step size accessor
246 : 180576451 : tk::real Dt() const { return m_dt; }
247 : : //! Time step size at previous time step accessor
248 : 6327 : tk::real Dtn() const { return m_dtn; }
249 : : //! Physical time accessor
250 : 5277055 : tk::real T() const { return m_t; }
251 : : //! Iteration count accessor
252 : 142806 : uint64_t It() const { return m_it; }
253 : :
254 : : //! Non-const-ref refinement iteration count accessor
255 : 360 : uint64_t& Itr() { return m_itr; }
256 : : //! Non-const-ref field-output iteration count accessor
257 : 360 : uint64_t& Itf() { return m_itf; }
258 : :
259 : : //! Non-const-ref number of restarts accessor
260 : : int& Nrestart() { return m_nrestart; }
261 : :
262 : : //! Timer accessor as const-ref
263 : : const tk::Timer& Timer() const { return m_timer; }
264 : : //! Timer accessor as non-const-ref
265 : 1702 : tk::Timer& Timer() { return m_timer; }
266 : :
267 : : //! Accessor to flag indicating if the mesh was refined as a value
268 : : int refined() const { return m_refined; }
269 : : //! Accessor to flag indicating if the mesh was refined as non-const-ref
270 : 22525 : int& refined() { return m_refined; }
271 : :
272 : : //! Accessor to bound implicit solver non-const-ref
273 : 0 : tk::CProxy_BiCG& ImplicitSolver() { return m_implicitsolver; }
274 : :
275 : : //! Transporter proxy accessor as const-ref
276 : : const CProxy_Transporter& Tr() const { return m_transporter; }
277 : : //! Transporter proxy accessor as non-const-ref
278 : 32507 : CProxy_Transporter& Tr() { return m_transporter; }
279 : :
280 : : //! Access bound Refiner class pointer
281 : 33 : Refiner* Ref() const {
282 [ + - ][ - + ]: 33 : Assert( m_refiner[ thisIndex ].ckLocal() != nullptr,
[ - - ][ - - ]
[ - - ]
283 : : "Refiner ckLocal() null" );
284 [ + - ]: 33 : return m_refiner[ thisIndex ].ckLocal();
285 : : }
286 : :
287 : : //! Access Discretization proxy for a mesh
288 : : CProxy_Discretization coupled( std::size_t meshid ) const {
289 : : Assert( meshid < m_disc.size(),
290 : : "No proxy for mesh ID " + std::to_string(meshid) );
291 : : return m_disc[ meshid ];
292 : : }
293 : :
294 : : //! Const-ref accessor to solver/mesh transfer configuration
295 : : const std::vector< Transfer >& Transfers() const { return m_transfer; }
296 : :
297 : : //! Boundary node ids accessor as const-ref
298 : 9883354 : const std::unordered_map< std::size_t, std::size_t >& Bid() const
299 : 9883354 : { return m_bid; }
300 : :
301 : : //! Node communication map accessor as const-ref
302 : 1529371 : const tk::NodeCommMap& NodeCommMap() const { return m_nodeCommMap; }
303 : :
304 : : //! Edge communication map accessor as const-ref
305 : 16136 : const tk::EdgeCommMap& EdgeCommMap() const { return m_edgeCommMap; }
306 : : //@}
307 : :
308 : : //! Set time step size
309 : : void setdt( tk::real newdt );
310 : :
311 : : //! Prepare for next step
312 : : void next();
313 : :
314 : : //! Otput one-liner status report
315 : : void status();
316 : :
317 : : //! Construct history output filename
318 : : std::string histfilename( const std::string& id,
319 : : std::streamsize precision );
320 : :
321 : : //! Output headers for time history files (one for each point)
322 : : void histheader( std::vector< std::string >&& names );
323 : :
324 : : //! Output time history for a time step
325 : : void history( std::vector< std::vector< tk::real > >&& data );
326 : :
327 : : //! Output mesh and fields data (solution dump) to file(s)
328 : : void write( const std::vector< std::size_t >& inpoel,
329 : : const tk::UnsMesh::Coords& coord,
330 : : const std::map< int, std::vector< std::size_t > >& bface,
331 : : const std::map< int, std::vector< std::size_t > >& bnode,
332 : : const std::vector< std::size_t >& triinpoel,
333 : : const std::vector< std::string>& elemfieldnames,
334 : : const std::vector< std::string>& nodefieldnames,
335 : : const std::vector< std::string>& elemsurfnames,
336 : : const std::vector< std::string>& nodesurfnames,
337 : : const std::vector< std::vector< tk::real > >& elemfields,
338 : : const std::vector< std::vector< tk::real > >& nodefields,
339 : : const std::vector< std::vector< tk::real > >& elemsurfs,
340 : : const std::vector< std::vector< tk::real > >& nodesurfs,
341 : : CkCallback c );
342 : :
343 : : //! Zero grind-timer
344 : : void grindZero();
345 : :
346 : : //! Detect if just returned from a checkpoint and if so, zero timers
347 : : bool restarted( int nrestart );
348 : :
349 : : //! Remap mesh data due to new local ids
350 : : void remap( const std::unordered_map< std::size_t, std::size_t >& map );
351 : :
352 : : //! \brief Function object for querying the node ids that belong to side
353 : : //! sets of the same type, called for each PDE type
354 : : template< typename... tags >
355 : : struct SidesetNodes {
356 : :
357 : : const std::map< int, std::vector< std::size_t > >& m_bface;
358 : : const std::vector< std::size_t >& m_triinpoel;
359 : : std::unordered_map< int, std::unordered_set< std::size_t > >& m_nodes;
360 : : std::size_t m_mid;
361 : :
362 : : explicit
363 : 90488 : SidesetNodes( const std::map< int, std::vector< std::size_t > >& bface,
364 : : const std::vector< std::size_t >& triinpoel,
365 : : std::unordered_map< int,
366 : : std::unordered_set< std::size_t > >& nodes,
367 : : std::size_t mid )
368 : 90488 : : m_bface(bface), m_triinpoel(triinpoel), m_nodes(nodes), m_mid(mid)
369 : : {
370 : : const auto& bc =
371 : 90488 : g_inputdeck.template get< tag::bc >();
372 : 180976 : std::vector< std::size_t > ss;
373 [ + + ]: 181012 : for (const auto& bci : bc) {
374 : 90524 : const auto& bcm = bci.get< tag::mesh >();
375 [ + + ]: 180743 : for (const auto& im : bcm) {
376 : : // only if this bc is meant for current mesh
377 : : // collect sidesets for this mesh with this bc type
378 [ + + ]: 90219 : if (im-1 == m_mid) {
379 [ + - ]: 90183 : ss.insert( ss.end(), bci.template get< tags... >().begin(),
380 : 90183 : bci.template get< tags... >().end() );
381 : : }
382 : : }
383 : : }
384 [ + + ]: 103494 : for (const auto& s : ss) {
385 [ + - ]: 13006 : auto k = m_bface.find(static_cast<int>(s));
386 [ + + ]: 13006 : if (k != end(m_bface)) {
387 [ + - ]: 9164 : auto& n = m_nodes[ k->first ]; // associate set id
388 [ + + ]: 3665140 : for (auto f : k->second) { // face ids on side set
389 [ + - ]: 3655976 : n.insert( m_triinpoel[f*3+0] );
390 [ + - ]: 3655976 : n.insert( m_triinpoel[f*3+1] );
391 [ + - ]: 3655976 : n.insert( m_triinpoel[f*3+2] );
392 : : }
393 : : }
394 : : }
395 : 90488 : }
396 : : };
397 : :
398 : : //! \brief Query nodes that belong to side sets of the same type for all
399 : : //! PDE types
400 : : //! \tparam tags Tags addressing the location of a vector of vectors of
401 : : //! side set ids in the input deck
402 : : //! \param[in] bface Boundary-faces mapped to side set ids
403 : : //! \param[in] triinpoel Boundary-face connectivity
404 : : //! \return Node ids that belong side sets of the same type (value),
405 : : //! associated to sides set id (key)
406 : : template< typename... tags >
407 : : std::unordered_map< int, std::unordered_set< std::size_t > >
408 : 90488 : bcnodes( const std::map< int, std::vector< std::size_t > >& bface,
409 : : const std::vector< std::size_t >& triinpoel ) const
410 : : {
411 : 90488 : std::unordered_map< int, std::unordered_set< std::size_t > > nodes;
412 [ + - ]: 90488 : SidesetNodes< tags... >( bface, triinpoel, nodes, this->MeshId() );
413 : 90488 : return nodes;
414 : : }
415 : :
416 : : //! Find elements along our mesh chunk boundary
417 : : std::vector< std::size_t > bndel() const;
418 : :
419 : : //! Decide if field output iteration count interval is hit
420 : : bool fielditer() const;
421 : :
422 : : //! Decide if field output physics time interval is hit
423 : : bool fieldtime() const;
424 : :
425 : : //! Decide if physics time falls into a field output time range
426 : : bool fieldrange() const;
427 : :
428 : : //! Decide if history output iteration count interval is hit
429 : : bool histiter() const;
430 : :
431 : : //! Decide if history output physics time interval is hit
432 : : bool histtime() const;
433 : :
434 : : //! Decide if physics time falls into a history output time range
435 : : bool histrange() const;
436 : :
437 : : //! Decide if this is the last time step
438 : : bool finished() const;
439 : :
440 : : /** @name Charm++ pack/unpack serializer member functions */
441 : : ///@{
442 : : //! \brief Pack/Unpack serialize member function
443 : : //! \param[in,out] p Charm++'s PUP::er serializer object reference
444 : 12748 : void pup( PUP::er &p ) override {
445 : 12748 : p | m_meshid;
446 : 12748 : p | m_transfer_complete;
447 : 12748 : p | m_transfer;
448 : 12748 : p | m_mytransfer;
449 : 12748 : p | m_disc;
450 : 12748 : p | m_nchare;
451 : 12748 : p | m_it;
452 : 12748 : p | m_itr;
453 : 12748 : p | m_itf;
454 : 12748 : p | m_initial;
455 : 12748 : p | m_t;
456 : 12748 : p | m_lastDumpTime;
457 : 12748 : p | m_physFieldFloor;
458 : 12748 : p | m_physHistFloor;
459 : 12748 : p | m_rangeFieldFloor;
460 : 12748 : p | m_rangeHistFloor;
461 : 12748 : p | m_dt;
462 : 12748 : p | m_dtn;
463 : 12748 : p | m_nvol;
464 : 12748 : p | m_nxfer;
465 : 12748 : p | m_ale;
466 : 12748 : p | m_implicitsolver;
467 : 12748 : p | m_transporter;
468 : 12748 : p | m_meshwriter;
469 : 12748 : p | m_refiner;
470 : 12748 : p | m_el;
471 [ + + ]: 12748 : if (p.isUnpacking()) {
472 : 4073 : m_inpoel = std::get< 0 >( m_el );
473 : 4073 : m_gid = std::get< 1 >( m_el );
474 : 4073 : m_lid = std::get< 2 >( m_el );
475 : : }
476 : 12748 : p | m_coord;
477 : 12748 : p | m_coordn;
478 : 12748 : p | m_nodeCommMap;
479 : 12748 : p | m_edgeCommMap;
480 : 12748 : p | m_meshvol;
481 : 12748 : p | m_v;
482 : 12748 : p | m_vol;
483 : 12748 : p | m_volc;
484 : 12748 : p | m_voln;
485 : 12748 : p | m_vol0;
486 : 12748 : p | m_boxvol;
487 : 12748 : p | m_meshblkvol;
488 : 12748 : p | m_bid;
489 : 12748 : p | m_timer;
490 : 12748 : p | m_refined;
491 : 12748 : p( reinterpret_cast<char*>(&m_prevstatus), sizeof(Clock::time_point) );
492 : 12748 : p | m_nrestart;
493 : 12748 : p | m_histdata;
494 : 12748 : p | m_nsrc;
495 : 12748 : p | m_ndst;
496 : 12748 : p | m_meshvel;
497 : 12748 : p | m_meshvel_converged;
498 : 12748 : p | m_bface;
499 : 12748 : p | m_triinpoel;
500 : 12748 : p | m_elemblockid;
501 : 12748 : }
502 : : //! \brief Pack/Unpack serialize operator|
503 : : //! \param[in,out] p Charm++'s PUP::er serializer object reference
504 : : //! \param[in,out] i Discretization object reference
505 : : friend void operator|( PUP::er& p, Discretization& i ) { i.pup(p); }
506 : : //@}
507 : :
508 : : private:
509 : : // Shorthand for clock, setting an internal clock type
510 : : using Clock = std::chrono::high_resolution_clock;
511 : :
512 : : //! Mesh ID
513 : : std::size_t m_meshid;
514 : : //! \brief Charm++ callback of the function to call after a mesh-to-mesh
515 : : //! solution transfer (to-and-fro) is complete
516 : : CkCallback m_transfer_complete;
517 : : //! Solution/mesh transfer (coupling) information coordination propagation
518 : : //! \details This has the same size with the same src/dst information on
519 : : //! all solvers.
520 : : std::vector< Transfer > m_transfer;
521 : : //! My solution transfer/mesh (coupling) information
522 : : //! \details This is a subset of m_transfer, holding only those entries
523 : : //! that this solver is involved in (either a source or a destination).
524 : : std::vector< Transfer > m_mytransfer;
525 : : //! Discretization proxies (one per mesh)
526 : : std::vector< CProxy_Discretization > m_disc;
527 : : //! Total number of Discretization chares
528 : : int m_nchare;
529 : : //! Iteration count
530 : : uint64_t m_it;
531 : : //! Iteration count with mesh refinement
532 : : //! \details Used as the restart sequence number {RS} in saving output in
533 : : //! an ExodusII sequence
534 : : //! \see https://www.paraview.org/Wiki/Restarted_Simulation_Readers
535 : : uint64_t m_itr;
536 : : //! Field output iteration count without mesh refinement
537 : : //! \details Counts the number of field outputs to file during two
538 : : //! time steps with mesh efinement
539 : : uint64_t m_itf;
540 : : //! Flag that is nonzero during setup and zero during time stepping
541 : : std::size_t m_initial;
542 : : //! Physical time
543 : : tk::real m_t;
544 : : //! Physics time at last field output
545 : : tk::real m_lastDumpTime;
546 : : //! Recent floor of physics time divided by field output interval time
547 : : tk::real m_physFieldFloor;
548 : : //! Recent floor of physics time divided by history output interval time
549 : : tk::real m_physHistFloor;
550 : : //! Recent floors of physics time divided by field output time for ranges
551 : : tk::real m_rangeFieldFloor;
552 : : //! Recent floors of physics time divided by history output time for ranges
553 : : tk::real m_rangeHistFloor;
554 : : //! Physical time step size
555 : : tk::real m_dt;
556 : : //! Physical time step size at the previous time step
557 : : tk::real m_dtn;
558 : : //! \brief Number of chares from which we received nodal volume
559 : : //! contributions on chare boundaries
560 : : std::size_t m_nvol;
561 : : //! \brief Number of chares from which we received solution transfers
562 : : //! contributions on chare boundaries
563 : : std::size_t m_nxfer;
564 : : //! Distributed ALE proxy
565 : : CProxy_ALE m_ale;
566 : : //! Distributed implicit solver proxy
567 : : tk::CProxy_BiCG m_implicitsolver;
568 : : //! Transporter proxy
569 : : CProxy_Transporter m_transporter;
570 : : //! Mesh writer proxy
571 : : tk::CProxy_MeshWriter m_meshwriter;
572 : : //! Mesh refiner proxy
573 : : CProxy_Refiner m_refiner;
574 : : //! \brief Elements of the mesh chunk we operate on
575 : : //! \details Initialized by the constructor. The first vector is the element
576 : : //! connectivity (local IDs), the second vector is the global node IDs of
577 : : //! owned elements, while the third one is a map of global->local node
578 : : //! IDs.
579 : : tk::UnsMesh::Chunk m_el;
580 : : //! Alias to element connectivity
581 : : std::vector< std::size_t >& m_inpoel = std::get<0>( m_el );
582 : : //! Alias to global node IDs of owned elements
583 : : std::vector< std::size_t >& m_gid = std::get<1>( m_el );
584 : : //! \brief Alias to local node ids associated to the global ones of owned
585 : : //! elements
586 : : std::unordered_map< std::size_t, std::size_t >& m_lid = std::get<2>( m_el );
587 : : //! Mesh point coordinates
588 : : tk::UnsMesh::Coords m_coord;
589 : : //! Mesh coordinates at the time n for ALE
590 : : tk::UnsMesh::Coords m_coordn;
591 : : //! \brief Global mesh node IDs bordering the mesh chunk held by fellow
592 : : //! Discretization chares associated to their chare IDs
593 : : tk::NodeCommMap m_nodeCommMap;
594 : : //! \brief Edges with global node IDs bordering the mesh chunk held by
595 : : //! fellow Discretization chares associated to their chare IDs
596 : : tk::EdgeCommMap m_edgeCommMap;
597 : : //! Total mesh volume
598 : : tk::real m_meshvol;
599 : : //! Nodal mesh volumes
600 : : //! \details This is the volume of the mesh associated to nodes of owned
601 : : //! elements (sum of surrounding cell volumes / 4) without contributions
602 : : //! from other chares on chare-boundaries
603 : : std::vector< tk::real > m_v;
604 : : //! Volume of nodes
605 : : //! \details This is the volume of the mesh associated to nodes of owned
606 : : //! elements (sum of surrounding cell volumes / 4) with contributions from
607 : : //! other chares on chare-boundaries
608 : : std::vector< tk::real > m_vol;
609 : : //! Receive buffer for volume of nodes (with global node id as key)
610 : : //! \details This is a communication buffer used to compute the volume of
611 : : //! the mesh associated to nodes of owned elements (sum of surrounding
612 : : //! cell volumes / 4) with contributions from other chares on
613 : : //! chare-boundaries.
614 : : std::unordered_map< std::size_t, tk::real > m_volc;
615 : : //! Volume of nodes at previous time step
616 : : //! \details This is the volume of the mesh associated to nodes of owned
617 : : //! elements (sum of surrounding cell volumes / 4) with contributions from
618 : : //! other chares on chare-boundaries at the previous time step stage
619 : : std::vector< tk::real > m_voln;
620 : : //! Mesh element volumes at t=t0
621 : : std::vector< tk::real > m_vol0;
622 : : //! Volume of user-defined box IC
623 : : tk::real m_boxvol;
624 : : //! Volumes of mesh-blocks with user-defined ICs
625 : : std::vector< tk::real > m_meshblkvol;
626 : : //! \brief Local chare-boundary mesh node IDs at which we receive
627 : : //! contributions associated to global mesh node IDs of elements we
628 : : //! contribute to
629 : : std::unordered_map< std::size_t, std::size_t > m_bid;
630 : : //! Timer measuring a time step
631 : : tk::Timer m_timer;
632 : : //! 1 if mesh was refined in a time step, 0 if it was not
633 : : int m_refined;
634 : : //! Time point storing clock state at status()
635 : : Clock::time_point m_prevstatus;
636 : : //! Number of times restarted
637 : : int m_nrestart;
638 : : //! Data at history point locations
639 : : std::vector< HistData > m_histdata;
640 : : //! Number of transfers requested as a source
641 : : std::size_t m_nsrc;
642 : : //! Number of transfers requested as a destination
643 : : std::size_t m_ndst;
644 : : //! Mesh velocity if ALE is not enabled
645 : : tk::Fields m_meshvel;
646 : : //! \brief True if all stages of the time step converged the mesh velocity
647 : : //! linear solve in ALE
648 : : bool m_meshvel_converged;
649 : : //! Boundary faces side-set information
650 : : std::map< int, std::vector< std::size_t > > m_bface;
651 : : //! Triangle face connecitivity
652 : : std::vector< std::size_t > m_triinpoel;
653 : : //! Local tet ids associated with mesh block ids
654 : : std::unordered_map< std::size_t, std::set< std::size_t > > m_elemblockid;
655 : :
656 : : //! Generate the Bid data-structure based on the node communication-map
657 : : std::unordered_map< std::size_t, std::size_t > genBid();
658 : :
659 : : //! Generate {A,x,b} for Laplacian mesh velocity smoother
660 : : std::tuple< tk::CSR, std::vector< tk::real >, std::vector< tk::real > >
661 : : Laplacian( std::size_t ncomp ) const;
662 : :
663 : : //! Set mesh coordinates based on coordinates map
664 : : tk::UnsMesh::Coords setCoord( const tk::UnsMesh::CoordMap& coordmap );
665 : :
666 : : //! Determine if communication of mesh transfer callbacks is complete
667 : : bool transferCallbacksComplete() const;
668 : : };
669 : :
670 : : } // inciter::
671 : :
672 : : #endif // Discretization_h
|