-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathCRKSPHRZ.cc
More file actions
508 lines (455 loc) · 21.2 KB
/
CRKSPHRZ.cc
File metadata and controls
508 lines (455 loc) · 21.2 KB
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
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
//---------------------------------Spheral++----------------------------------//
// CRKSPHRZ -- The CRKSPH/ACRKSPH hydrodynamic package for Spheral++.
//
// This is the area-weighted RZ specialization.
//
// Created by JMO, Thu May 12 15:25:24 PDT 2016
//----------------------------------------------------------------------------//
#include "FileIO/FileIO.hh"
#include "RK/ReproducingKernel.hh"
#include "RK/RKFieldNames.hh"
#include "Hydro/HydroFieldNames.hh"
#include "Physics/GenericHydro.hh"
#include "DataBase/State.hh"
#include "DataBase/StateDerivatives.hh"
#include "DataBase/IncrementState.hh"
#include "DataBase/IncrementBoundedState.hh"
#include "DataBase/ReplaceState.hh"
#include "DataBase/ReplaceBoundedState.hh"
#include "Hydro/RZNonSymmetricSpecificThermalEnergyPolicy.hh"
#include "Hydro/SpecificFromTotalThermalEnergyPolicy.hh"
#include "Hydro/PressurePolicy.hh"
#include "Hydro/SoundSpeedPolicy.hh"
#include "Hydro/EntropyPolicy.hh"
#include "RK/ContinuityVolumePolicyRZ.hh"
#include "ArtificialViscosity/ArtificialViscosity.hh"
#include "DataBase/DataBase.hh"
#include "Field/FieldList.hh"
#include "Field/NodeIterators.hh"
#include "Boundary/Boundary.hh"
#include "Neighbor/ConnectivityMap.hh"
#include "VoronoiCells/GeometryScaling.hh"
#include "Neighbor/PairwiseField.hh"
#include "Utilities/safeInv.hh"
#include "Utilities/range.hh"
#include "Utilities/newtonRaphson.hh"
#include "Utilities/SpheralFunctions.hh"
#include "Geometry/innerProduct.hh"
#include "Geometry/outerProduct.hh"
#include "Geometry/GeometryRegistrar.hh"
#include "CRKSPHRZ.hh"
#include <limits.h>
#include <float.h>
#include <algorithm>
#include <fstream>
#include <map>
#include <vector>
using std::vector;
using std::string;
using std::pair;
using std::make_pair;
namespace Spheral {
//------------------------------------------------------------------------------
// Construct with the given artificial viscosity and kernels.
//------------------------------------------------------------------------------
CRKSPHRZ::
CRKSPHRZ(DataBase<Dimension>& dataBase,
ArtificialViscosity<Dimension>& Q,
const RKOrder order,
const double cfl,
const bool useVelocityMagnitudeForDt,
const bool compatibleEnergyEvolution,
const bool evolveTotalEnergy,
const bool XSPH,
const MassDensityType densityUpdate,
const double epsTensile,
const double nTensile):
CRKSPHBase<Dim<2>>(dataBase,
Q,
order,
cfl,
useVelocityMagnitudeForDt,
compatibleEnergyEvolution,
evolveTotalEnergy,
XSPH,
densityUpdate,
epsTensile,
nTensile),
mPairAccelerationsPtr(std::make_unique<PairAccelerationsType>()) {
}
//------------------------------------------------------------------------------
// On problem start up some dependent state needs to be calculated
//------------------------------------------------------------------------------
void
CRKSPHRZ::
initializeProblemStartupDependencies(DataBase<Dim<2>>& dataBase,
State<Dim<2>>& state,
StateDerivatives<Dim<2>>& derivs) {
auto mass = dataBase.fluidMass();
const auto pos = dataBase.fluidPosition();
{
auto guard = unscaledRegion(pos, mass);
CRKSPHBase<Dim<2>>::initializeProblemStartupDependencies(dataBase, state, derivs);
}
}
//------------------------------------------------------------------------------
// Register the state we need/are going to evolve.
//------------------------------------------------------------------------------
void
CRKSPHRZ::
registerState(DataBase<Dim<2>>& dataBase,
State<Dim<2>>& state) {
// The base class does most of it.
CRKSPHBase<Dim<2>>::registerState(dataBase, state);
// Reregister the volume update
auto vol = state.fields(HydroFieldNames::volume, 0.0);
state.enroll(vol, make_policy<ContinuityVolumePolicyRZ>());
// We have to choose either compatible or total energy evolution.
const auto compatibleEnergy = this->compatibleEnergyEvolution();
const auto evolveTotalEnergy = this->evolveTotalEnergy();
VERIFY2(not (compatibleEnergy and evolveTotalEnergy),
"SPH error : you cannot simultaneously use both compatibleEnergyEvolution and evolveTotalEnergy");
// Register the specific thermal energy.
// Note in RZ we require the specific thermal energy go before the position so we can use the r position
// during update. This is why we make position update dependent on the thermal energy in SPHBase.
auto specificThermalEnergy = dataBase.fluidSpecificThermalEnergy();
if (compatibleEnergy) {
state.enroll(specificThermalEnergy, make_policy<RZNonSymmetricSpecificThermalEnergyPolicy>(dataBase));
} else if (evolveTotalEnergy) {
// If we're doing total energy, we register the specific energy to advance with the
// total energy policy.
state.enroll(specificThermalEnergy, make_policy<SpecificFromTotalThermalEnergyPolicy<Dimension>>());
} else {
// Otherwise we're just time-evolving the specific energy.
state.enroll(specificThermalEnergy, make_policy<IncrementState<Dimension, Scalar>>());
}
}
//------------------------------------------------------------------------------
// Register the state derivative fields.
//------------------------------------------------------------------------------
void
CRKSPHRZ::
registerDerivatives(DataBase<Dim<2>>& dataBase,
StateDerivatives<Dim<2>>& derivs) {
CRKSPHBase<Dimension>::registerDerivatives(dataBase, derivs);
const auto compatibleEnergy = this->compatibleEnergyEvolution();
if (compatibleEnergy) {
const auto& connectivityMap = dataBase.connectivityMap();
mPairAccelerationsPtr = std::make_unique<PairAccelerationsType>(connectivityMap);
}
derivs.enroll(HydroFieldNames::pairAccelerations, *mPairAccelerationsPtr);
}
//------------------------------------------------------------------------------
// This method is called once at the beginning of a timestep, after all state registration.
//------------------------------------------------------------------------------
void
CRKSPHRZ::
preStepInitialize(const DataBase<Dim<2>>& dataBase,
State<Dim<2>>& state,
StateDerivatives<Dim<2>>& derivs) {
auto mass = state.fields(HydroFieldNames::mass, 0.0);
const auto pos = state.fields(HydroFieldNames::position, Vector::zero());
{
auto guard = unscaledRegion(pos, mass);
CRKSPHBase<Dimension>::preStepInitialize(dataBase, state, derivs);
}
}
//------------------------------------------------------------------------------
// Determine the principle derivatives.
//------------------------------------------------------------------------------
void
CRKSPHRZ::
evaluateDerivatives(const Dimension::Scalar time,
const Dimension::Scalar dt,
const DataBase<Dimension>& dataBase,
const State<Dimension>& state,
StateDerivatives<Dimension>& derivatives) const {
// Depending on the type of the ArtificialViscosityView, dispatch the call to
// the secondDerivativesLoop
auto& Qhandle = this->artificialViscosity();
if (Qhandle.QPiTypeIndex() == std::type_index(typeid(Scalar))) {
chai::managed_ptr<ArtificialViscosityView<Dimension, Scalar>> Q = Qhandle.getScalarView();
this->evaluateDerivativesImpl(time, dt, dataBase, state, derivatives, Q);
} else {
CHECK(Qhandle.QPiTypeIndex() == std::type_index(typeid(Tensor)));
chai::managed_ptr<ArtificialViscosityView<Dimension, Tensor>> Q = Qhandle.getTensorView();
this->evaluateDerivativesImpl(time, dt, dataBase, state, derivatives, Q);
}
}
//------------------------------------------------------------------------------
// Determine the principle derivatives.
//------------------------------------------------------------------------------
template<typename QType>
void
CRKSPHRZ::
evaluateDerivativesImpl(const Dim<2>::Scalar /*time*/,
const Dim<2>::Scalar /*dt*/,
const DataBase<Dim<2>>& dataBase,
const State<Dim<2>>& state,
StateDerivatives<Dim<2>>& derivs,
chai::managed_ptr<QType> Q) const {
using QPiType = typename QType::ReturnType;
// The kernels and such.
//const auto order = this->correctionOrder();
const auto& WR = state.template get<ReproducingKernel<Dimension>>(RKFieldNames::reproducingKernel(mOrder));
// A few useful constants we'll use in the following loop.
//const auto tiny = 1.0e-30;
const auto compatibleEnergy = this->compatibleEnergyEvolution();
const auto evolveTotalEnergy = this->evolveTotalEnergy();
const auto XSPH = this->XSPH();
// The connectivity.
const auto& connectivityMap = dataBase.connectivityMap();
const auto& nodeLists = connectivityMap.nodeLists();
const auto numNodeLists = nodeLists.size();
const auto& pairs = connectivityMap.nodePairList();
const auto npairs = pairs.size();
// Get the state and derivative FieldLists.
// State FieldLists.
const auto mass = state.fields(HydroFieldNames::mass, 0.0);
const auto volume = state.fields(HydroFieldNames::volume, 0.0);
const auto position = state.fields(HydroFieldNames::position, Vector::zero());
const auto velocity = state.fields(HydroFieldNames::velocity, Vector::zero());
const auto massDensity = state.fields(HydroFieldNames::massDensity, 0.0);
const auto specificThermalEnergy = state.fields(HydroFieldNames::specificThermalEnergy, 0.0);
const auto H = state.fields(HydroFieldNames::H, SymTensor::zero());
const auto pressure = state.fields(HydroFieldNames::pressure, 0.0);
const auto soundSpeed = state.fields(HydroFieldNames::soundSpeed, 0.0);
const auto corrections = state.fields(RKFieldNames::rkCorrections(mOrder), RKCoefficients<Dimension>());
auto fClQ = state.fields(HydroFieldNames::ArtificialViscousClMultiplier, 0.0, true);
auto fCqQ = state.fields(HydroFieldNames::ArtificialViscousCqMultiplier, 0.0, true);
auto DvDxQ = state.fields(HydroFieldNames::ArtificialViscosityVelocityGradient, Tensor::zero(), true);
auto DvDxQView = DvDxQ.view();
auto fClQView = fClQ.view();
auto fCqQView = fCqQ.view();
CHECK(mass.size() == numNodeLists);
CHECK(position.size() == numNodeLists);
CHECK(velocity.size() == numNodeLists);
CHECK(massDensity.size() == numNodeLists);
CHECK(specificThermalEnergy.size() == numNodeLists);
CHECK(H.size() == numNodeLists);
CHECK(pressure.size() == numNodeLists);
CHECK(soundSpeed.size() == numNodeLists);
CHECK(corrections.size() == numNodeLists);
CHECK(fClQ.size() == 0 or fClQ.size() == numNodeLists);
CHECK(fCqQ.size() == 0 or fCqQ.size() == numNodeLists);
CHECK(DvDxQ.size() == 0 or DvDxQ.size() == numNodeLists);
// Derivative FieldLists.
auto DxDt = derivs.fields(IncrementState<Dimension, Vector>::prefix() + HydroFieldNames::position, Vector::zero());
auto DrhoDt = derivs.fields(IncrementState<Dimension, Scalar>::prefix() + HydroFieldNames::massDensity, 0.0);
auto DvDt = derivs.fields(HydroFieldNames::hydroAcceleration, Vector::zero());
auto DepsDt = derivs.fields(IncrementState<Dimension, Scalar>::prefix() + HydroFieldNames::specificThermalEnergy, 0.0);
auto DvDx = derivs.fields(HydroFieldNames::velocityGradient, Tensor::zero());
auto localDvDx = derivs.fields(HydroFieldNames::internalVelocityGradient, Tensor::zero());
auto maxViscousPressure = derivs.fields(HydroFieldNames::maxViscousPressure, 0.0);
auto effViscousPressure = derivs.fields(HydroFieldNames::effectiveViscousPressure, 0.0);
auto XSPHDeltaV = derivs.fields(HydroFieldNames::XSPHDeltaV, Vector::zero());
auto& pairAccelerations = derivs.template get<PairAccelerationsType>(HydroFieldNames::pairAccelerations);
CHECK(DxDt.size() == numNodeLists);
CHECK(DrhoDt.size() == numNodeLists);
CHECK(DvDt.size() == numNodeLists);
CHECK(DepsDt.size() == numNodeLists);
CHECK(DvDx.size() == numNodeLists);
CHECK(localDvDx.size() == numNodeLists);
CHECK(maxViscousPressure.size() == numNodeLists);
CHECK(effViscousPressure.size() == numNodeLists);
CHECK(XSPHDeltaV.size() == numNodeLists);
CHECK((compatibleEnergy and pairAccelerations.size() == npairs) or not compatibleEnergy);
// Walk all the interacting pairs.
#pragma omp parallel
{
// Thread private scratch variables
int i, j, nodeListi, nodeListj;
Scalar Wi, Wj, Qi, Qj;
QPiType QPiij, QPiji;
Vector gradWi, gradWj;
Vector deltagrad;
Vector xij, vij, etai, etaj;
typename SpheralThreads<Dimension>::FieldListStack threadStack;
auto DvDt_thread = DvDt.threadCopy(threadStack);
auto DepsDt_thread = DepsDt.threadCopy(threadStack);
auto DvDx_thread = DvDx.threadCopy(threadStack);
auto localDvDx_thread = localDvDx.threadCopy(threadStack);
auto maxViscousPressure_thread = maxViscousPressure.threadCopy(threadStack, ThreadReduction::MAX);
auto effViscousPressure_thread = effViscousPressure.threadCopy(threadStack);
auto XSPHDeltaV_thread = XSPHDeltaV.threadCopy(threadStack);
#pragma omp for
for (auto kk = 0u; kk < npairs; ++kk) {
i = pairs[kk].i_node;
j = pairs[kk].j_node;
nodeListi = pairs[kk].i_list;
nodeListj = pairs[kk].j_list;
// Get the state for node i.
const auto& posi = position(nodeListi, i);
const auto ri = abs(posi.y());
const auto circi = 2.0*M_PI*ri;
const auto mi = mass(nodeListi, i);
const auto mRZi = mi/circi;
const auto& vi = velocity(nodeListi, i);
const auto rhoi = massDensity(nodeListi, i);
//const auto epsi = specificThermalEnergy(nodeListi, i);
const auto Pi = pressure(nodeListi, i);
const auto& Hi = H(nodeListi, i);
const auto ci = soundSpeed(nodeListi, i);
const auto& correctionsi = corrections(nodeListi, i);
const auto weighti = volume(nodeListi, i); // Change CRKSPH weights here if need be!
const auto zetai = abs((Hi*posi).y());
//const auto hri = ri*safeInv(zetai);
CHECK2(ri > 0.0, i << " " << ri);
CHECK2(mi > 0.0, i << " " << mi);
CHECK2(rhoi > 0.0, i << " " << rhoi);
CHECK2(weighti > 0.0, i << " " << weighti);
auto& DvDti = DvDt_thread(nodeListi, i);
auto& DepsDti = DepsDt_thread(nodeListi, i);
auto& DvDxi = DvDx_thread(nodeListi, i);
auto& localDvDxi = localDvDx_thread(nodeListi, i);
auto& maxViscousPressurei = maxViscousPressure_thread(nodeListi, i);
auto& effViscousPressurei = effViscousPressure_thread(nodeListi, i);
auto& XSPHDeltaVi = XSPHDeltaV_thread(nodeListi, i);
// Get the state for node j
const auto& posj = position(nodeListj, j);
const auto rj = abs(posj.y());
const auto circj = 2.0*M_PI*rj;
const auto mj = mass(nodeListj, j);
const auto mRZj = mj/circj;
const auto& vj = velocity(nodeListj, j);
const auto rhoj = massDensity(nodeListj, j);
const auto Pj = pressure(nodeListj, j);
const auto& Hj = H(nodeListj, j);
const auto cj = soundSpeed(nodeListj, j);
const auto& correctionsj = corrections(nodeListj, j);
const auto weightj = volume(nodeListj, j); // Change CRKSPH weights here if need be!
const auto zetaj = abs((Hj*posj).y());
CHECK2(rj > 0.0, j << " " << rj);
CHECK(mj > 0.0);
CHECK(rhoj > 0.0);
CHECK(weightj > 0.0);
auto& DvDtj = DvDt_thread(nodeListj, j);
auto& DepsDtj = DepsDt_thread(nodeListj, j);
auto& DvDxj = DvDx_thread(nodeListj, j);
auto& localDvDxj = localDvDx_thread(nodeListj, j);
auto& maxViscousPressurej = maxViscousPressure_thread(nodeListj, j);
auto& effViscousPressurej = effViscousPressure_thread(nodeListj, j);
auto& XSPHDeltaVj = XSPHDeltaV_thread(nodeListj, j);
// Node displacement.
xij = posi - posj;
vij = vi - vj;
etai = Hi*xij;
etaj = Hj*xij;
// Symmetrized kernel weight and gradient.
std::tie(Wj, gradWj) = WR.evaluateKernelAndGradient( xij, Hj, correctionsi); // Hj because we compute RK using scatter formalism
std::tie(Wi, gradWi) = WR.evaluateKernelAndGradient(-xij, Hi, correctionsj);
deltagrad = gradWj - gradWi;
// Compute the artificial viscous pressure (Pi = P/rho^2 actually).
Q->QPiij(QPiij, QPiji, Qi, Qj,
nodeListi, i, nodeListj, j,
posi, Hi, etai, vi, rhoi, ci,
posj, Hj, etaj, vj, rhoj, cj,
fClQView, fCqQView, DvDxQView);
const auto Qaccij = (rhoi*rhoi*QPiij + rhoj*rhoj*QPiji)*deltagrad;
const auto workQi = (rhoj*rhoj*QPiji*vij).dot(deltagrad); // CRK
const auto workQj = (rhoi*rhoi*QPiij*vij).dot(deltagrad); // CRK
maxViscousPressurei = max(maxViscousPressurei, 4.0*Qi); // We need tighter timestep controls on the Q with CRK
maxViscousPressurej = max(maxViscousPressurej, 4.0*Qj);
effViscousPressurei += weightj * Qi * Wj;
effViscousPressurej += weighti * Qj * Wi;
// Velocity gradient.
DvDxi -= weightj*vij.dyad(gradWj);
DvDxj += weighti*vij.dyad(gradWi);
if (nodeListi == nodeListj) {
localDvDxi -= weightj*vij.dyad(gradWj);
localDvDxj += weighti*vij.dyad(gradWi);
}
// Acceleration (CRKSPH form).
CHECK(rhoi > 0.0);
CHECK(rhoj > 0.0);
const auto forceij = 0.5*weighti*weightj*((Pi + Pj)*deltagrad + Qaccij); // <- Type III, with CRKSPH Q forces
DvDti -= forceij/mRZi; //CRK Acceleration
DvDtj += forceij/mRZj; //CRK Acceleration
if (compatibleEnergy) {
pairAccelerations[kk][0] = -forceij/mRZi;
pairAccelerations[kk][1] = forceij/mRZj;
}
DepsDti += 0.5*weighti*weightj*(Pj*vij.dot(deltagrad) + workQi)/mRZi; // CRK Q
DepsDtj += 0.5*weighti*weightj*(Pi*vij.dot(deltagrad) + workQj)/mRZj; // CRK Q
// Estimate of delta v (for XSPH).
if ((XSPH and (nodeListi == nodeListj)) or min(zetai, zetaj) < 1.0) {
XSPHDeltaVi -= weightj*Wj*vij;
XSPHDeltaVj += weighti*Wi*vij;
}
}
// Reduce the thread values to the master.
threadReduceFieldLists<Dim<2>>(threadStack);
} // OMP parallel
// Finish up the derivatives for each point.
for (auto nodeListi = 0u; nodeListi < numNodeLists; ++nodeListi) {
const auto& nodeList = mass[nodeListi]->nodeList();
const auto ni = nodeList.numInternalNodes();
#pragma omp parallel for
for (auto i = 0u; i < ni; ++i) {
// Get the state for node i.
const auto& posi = position(nodeListi, i);
const auto ri = abs(posi.y());
const auto mi = mass(nodeListi, i);
const auto& vi = velocity(nodeListi, i);
const auto rhoi = massDensity(nodeListi, i);
//const auto epsi = specificThermalEnergy(nodeListi, i);
const auto Pi = pressure(nodeListi, i);
const auto& Hi = H(nodeListi, i);
const auto zetai = abs((Hi*posi).y());
const auto hri = ri*safeInv(zetai);
const auto riInv = safeInv(ri, 0.25*hri);
CHECK2(ri > 0.0, i << " " << ri);
CHECK2(mi > 0.0, i << " " << mi);
CHECK2(rhoi > 0.0, i << " " << rhoi);
auto& DxDti = DxDt(nodeListi, i);
auto& DrhoDti = DrhoDt(nodeListi, i);
auto& DvDti = DvDt(nodeListi, i);
auto& DepsDti = DepsDt(nodeListi, i);
auto& DvDxi = DvDx(nodeListi, i);
auto& XSPHDeltaVi = XSPHDeltaV(nodeListi, i);
// Time evolution of the mass density.
const auto vri = vi.y(); // + XSPHDeltaVi.y();
DrhoDti = -rhoi*(DvDxi.Trace() + vri*riInv);
// Finish the specific thermal energy evolution.
DepsDti -= Pi/rhoi*vri*riInv;
// If needed finish the total energy derivative.
if (evolveTotalEnergy) DepsDti = mi*(vi.dot(DvDti) + DepsDti);
// Determine the position evolution, based on whether we're doing XSPH or not.
if (mXSPH) {
DxDti = vi + XSPHDeltaVi;
} else {
DxDti = vi;
}
}
}
}
//------------------------------------------------------------------------------
// Apply the ghost boundary conditions for hydro state fields.
//------------------------------------------------------------------------------
void
CRKSPHRZ::
applyGhostBoundaries(State<Dim<2>>& state,
StateDerivatives<Dim<2>>& derivs) {
auto mass = state.fields(HydroFieldNames::mass, 0.0);
const auto pos = state.fields(HydroFieldNames::position, Vector::zero());
{
auto guard = unscaledRegion(pos, mass);
CRKSPHBase<Dim<2>>::applyGhostBoundaries(state, derivs);
for (auto boundaryPtr: range(this->boundaryBegin(), this->boundaryEnd())) boundaryPtr->finalizeGhostBoundary();
}
}
//------------------------------------------------------------------------------
// Enforce the boundary conditions for hydro state fields.
//------------------------------------------------------------------------------
void
CRKSPHRZ::
enforceBoundaries(State<Dim<2>>& state,
StateDerivatives<Dim<2>>& derivs) {
auto mass = state.fields(HydroFieldNames::mass, 0.0);
const auto pos = state.fields(HydroFieldNames::position, Vector::zero());
{
auto guard = unscaledInternalRegion(pos, mass);
CRKSPHBase<Dim<2>>::enforceBoundaries(state, derivs);
}
}
}