-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathSolidFSISPH.cc
More file actions
778 lines (709 loc) · 41 KB
/
SolidFSISPH.cc
File metadata and controls
778 lines (709 loc) · 41 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
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
//---------------------------------Spheral++----------------------------------//
// SolidFSISPH -- SolidSPHHydro modified to better handle
// multimaterial material problems with interfaces
// and large density ratios.
//
// J.M. Pearl 2021
//----------------------------------------------------------------------------//
#include "FileIO/FileIO.hh"
#include "Physics/GenericHydro.hh"
#include "NodeList/SolidNodeList.hh"
#include "SolidMaterial/SolidEquationOfState.hh"
#include "Hydro/computeSPHVolume.hh"
#include "Hydro/HydroFieldNames.hh"
#include "Hydro/CompatibleDifferenceSpecificThermalEnergyPolicy.hh"
#include "Hydro/SpecificThermalEnergyPolicy.hh"
#include "Hydro/SpecificFromTotalThermalEnergyPolicy.hh"
#include "Hydro/PressurePolicy.hh"
#include "Hydro/SoundSpeedPolicy.hh"
#include "Strength/SolidFieldNames.hh"
#include "Strength/DeviatoricStressPolicy.hh"
#include "Strength/BulkModulusPolicy.hh"
#include "Strength/PlasticStrainPolicy.hh"
#include "Strength/ShearModulusPolicy.hh"
#include "Strength/YieldStrengthPolicy.hh"
#include "DataBase/DataBase.hh"
#include "DataBase/State.hh"
#include "DataBase/StateDerivatives.hh"
#include "DataBase/IncrementState.hh"
#include "DataBase/ReplaceState.hh"
#include "DataBase/IncrementBoundedState.hh"
#include "DataBase/ReplaceBoundedState.hh"
#include "DataBase/PureReplaceState.hh"
#include "DataBase/updateStateFields.hh"
#include "DataBase/ReplaceWithRatioPolicy.hh"
#include "ArtificialViscosity/ArtificialViscosity.hh"
#include "Field/FieldList.hh"
#include "Field/NodeIterators.hh"
#include "Boundary/Boundary.hh"
#include "Neighbor/ConnectivityMap.hh"
#include "Neighbor/PairwiseField.hh"
#include "Utilities/safeInv.hh"
#include "Utilities/Timer.hh"
#include "Utilities/globalBoundingVolumes.hh"
#include "Utilities/range.hh"
#include "FSISPH/SolidFSISPH.hh"
#include "FSISPH/FSIFieldNames.hh"
#include "FSISPH/computeFSISPHSumMassDensity.hh"
#include "FSISPH/computeHWeightedFSISPHSumMassDensity.hh"
#include "FSISPH/computeInterfacePressureCorrectedSumMassDensity.hh"
#include "FSISPH/SlideSurface.hh"
#include <algorithm>
#include <fstream>
#include <map>
#include <vector>
using std::make_shared;
using std::vector;
using std::string;
using std::pair;
using std::make_pair;
namespace Spheral {
inline
Dim<1>::SymTensor
tensileStressCorrection(const Dim<1>::SymTensor& sigma) {
if (sigma.xx() > 0.0) {
return -sigma;
} else {
return Dim<1>::SymTensor::zero();
}
}
inline
Dim<2>::SymTensor
tensileStressCorrection(const Dim<2>::SymTensor& sigma) {
const EigenStruct<2> eigen = sigma.eigenVectors();
const double lambdax = eigen.eigenValues.x();
const double lambday = eigen.eigenValues.y();
Dim<2>::SymTensor result((lambdax > 0.0 ? -lambdax : 0.0), 0.0,
0.0, (lambday > 0.0 ? -lambday : 0.0));
result.rotationalTransform(eigen.eigenVectors);
return result;
}
inline
Dim<3>::SymTensor
tensileStressCorrection(const Dim<3>::SymTensor& sigma) {
const EigenStruct<3> eigen = sigma.eigenVectors();
const double lambdax = eigen.eigenValues.x();
const double lambday = eigen.eigenValues.y();
const double lambdaz = eigen.eigenValues.z();
Dim<3>::SymTensor result((lambdax > 0.0 ? -lambdax : 0.0), 0.0, 0.0,
0.0, (lambday > 0.0 ? -lambday : 0.0), 0.0,
0.0, 0.0, (lambdaz > 0.0 ? -lambdaz : 0.0));
result.rotationalTransform(eigen.eigenVectors);
return result;
}
//------------------------------------------------------------------------------
// Construct with the given artificial viscosity and kernels.
//------------------------------------------------------------------------------
template<typename Dimension>
SolidFSISPH<Dimension>::
SolidFSISPH(DataBase<Dimension>& dataBase,
ArtificialViscosity<Dimension>& Q,
SlideSurface<Dimension>& slides,
const TableKernel<Dimension>& W,
const double cfl,
const double surfaceForceCoefficient,
const double densityStabilizationCoefficient,
const double specificThermalEnergyDiffusionCoefficient,
const double xsphCoefficient,
const InterfaceMethod interfaceMethod,
const KernelAveragingMethod kernelAveragingMethod,
const std::vector<int> sumDensityNodeLists,
const bool useVelocityMagnitudeForDt,
const bool compatibleEnergyEvolution,
const bool evolveTotalEnergy,
const bool linearCorrectGradients,
const bool decoupleDamagedMaterial,
const double interfacePmin,
const double interfaceNeighborAngleThreshold,
const FSIMassDensityMethod densityUpdate,
const double epsTensile,
const double nTensile,
const Vector& xmin,
const Vector& xmax):
GenericHydro<Dimension>(Q, cfl, useVelocityMagnitudeForDt),
mKernel(W),
mSlideSurface(slides),
mDensityUpdate(densityUpdate),
mInterfaceMethod(interfaceMethod),
mKernelAveragingMethod(kernelAveragingMethod),
mCompatibleEnergyEvolution(compatibleEnergyEvolution),
mEvolveTotalEnergy(evolveTotalEnergy),
mLinearCorrectGradients(linearCorrectGradients),
mDecoupleDamagedMaterial(decoupleDamagedMaterial),
mApplySelectDensitySum(std::any_of(sumDensityNodeLists.begin(), sumDensityNodeLists.end(), [](int x) { return x == 1; })),
mSumDensityNodeLists(sumDensityNodeLists),
mSurfaceForceCoefficient(surfaceForceCoefficient),
mDensityStabilizationCoefficient(densityStabilizationCoefficient),
mSpecificThermalEnergyDiffusionCoefficient(specificThermalEnergyDiffusionCoefficient),
mXSPHCoefficient(xsphCoefficient),
mInterfacePmin(interfacePmin),
mInterfaceNeighborAngleThreshold(interfaceNeighborAngleThreshold),
mEpsTensile(epsTensile),
mnTensile(nTensile),
mxmin(xmin),
mxmax(xmax),
mPairAccelerationsPtr(std::make_unique<PairAccelerationsType>()),
mPairDepsDtPtr(std::make_unique<PairWorkType>()),
mTimeStepMask(FieldStorageType::CopyFields),
mPressure(FieldStorageType::CopyFields),
mDamagedPressure(FieldStorageType::CopyFields),
mSoundSpeed(FieldStorageType::CopyFields),
mBulkModulus(FieldStorageType::CopyFields),
mShearModulus(FieldStorageType::CopyFields),
mYieldStrength(FieldStorageType::CopyFields),
mPlasticStrain0(FieldStorageType::CopyFields),
//mInverseEquivalentDeviatoricStress(FieldStorageType::CopyFields),
mVolume(FieldStorageType::CopyFields),
mDxDt(FieldStorageType::CopyFields),
mXSPHDeltaV(FieldStorageType::CopyFields),
mXSPHWeightSum(FieldStorageType::CopyFields),
mDvDt(FieldStorageType::CopyFields),
mDmassDensityDt(FieldStorageType::CopyFields),
mDspecificThermalEnergyDt(FieldStorageType::CopyFields),
mDdeviatoricStressDt(FieldStorageType::CopyFields),
mDPDx(FieldStorageType::CopyFields),
mDepsDx(FieldStorageType::CopyFields),
mDvDx(FieldStorageType::CopyFields),
mInternalDvDx(FieldStorageType::CopyFields),
mM(FieldStorageType::CopyFields),
mLocalM(FieldStorageType::CopyFields),
mNormalization(FieldStorageType::CopyFields),
mInterfaceFlags(FieldStorageType::CopyFields),
mInterfaceAreaVectors(FieldStorageType::CopyFields),
mInterfaceNormals(FieldStorageType::CopyFields),
mInterfaceSmoothness(FieldStorageType::CopyFields),
mNewInterfaceFlags(FieldStorageType::CopyFields),
mNewInterfaceAreaVectors(FieldStorageType::CopyFields),
mNewInterfaceNormals(FieldStorageType::CopyFields),
mInterfaceSmoothnessNormalization(FieldStorageType::CopyFields),
mInterfaceFraction(FieldStorageType::CopyFields),
mNewInterfaceSmoothness(FieldStorageType::CopyFields),
mInterfaceAngles(FieldStorageType::CopyFields),
mRestart(registerWithRestart(*this)) {
mTimeStepMask = dataBase.newFluidFieldList(int(0), HydroFieldNames::timeStepMask);
mPressure = dataBase.newFluidFieldList(0.0, HydroFieldNames::pressure);
mDamagedPressure = dataBase.newFluidFieldList(0.0, SolidFieldNames::damagedPressure);
mSoundSpeed = dataBase.newFluidFieldList(0.0, HydroFieldNames::soundSpeed);
mBulkModulus = dataBase.newSolidFieldList(0.0, SolidFieldNames::bulkModulus);
mShearModulus = dataBase.newSolidFieldList(0.0, SolidFieldNames::shearModulus);
mYieldStrength = dataBase.newSolidFieldList(0.0, SolidFieldNames::yieldStrength);
mPlasticStrain0 = dataBase.newSolidFieldList(0.0, SolidFieldNames::plasticStrain + "0");
//mInverseEquivalentDeviatoricStress = dataBase.newFluidFieldList(0.0, FSIFieldNames::inverseEquivalentDeviatoricStress);
mVolume = dataBase.newFluidFieldList(0.0,HydroFieldNames::volume);
mDxDt = dataBase.newFluidFieldList(Vector::zero(), IncrementState<Dimension, Vector>::prefix() + HydroFieldNames::position);
mXSPHDeltaV = dataBase.newFluidFieldList(Vector::zero(), HydroFieldNames::XSPHDeltaV);
mXSPHWeightSum = dataBase.newFluidFieldList(0.0, HydroFieldNames::XSPHWeightSum);
mDvDt = dataBase.newFluidFieldList(Vector::zero(), HydroFieldNames::hydroAcceleration);
mDmassDensityDt = dataBase.newFluidFieldList(0.0, IncrementState<Dimension, Scalar>::prefix() + HydroFieldNames::massDensity);
mDspecificThermalEnergyDt = dataBase.newFluidFieldList(0.0, IncrementState<Dimension, Scalar>::prefix() + HydroFieldNames::specificThermalEnergy);
mDdeviatoricStressDt = dataBase.newSolidFieldList(SymTensor::zero(), IncrementState<Dimension, Vector>::prefix() + SolidFieldNames::deviatoricStress);
mDPDx = dataBase.newFluidFieldList(Vector::zero(), FSIFieldNames::pressureGradient);
mDepsDx = dataBase.newFluidFieldList(Vector::zero(), FSIFieldNames::specificThermalEnergyGradient);
mDvDx = dataBase.newFluidFieldList(Tensor::zero(), HydroFieldNames::velocityGradient);
mInternalDvDx = dataBase.newFluidFieldList(Tensor::zero(), HydroFieldNames::internalVelocityGradient);
mM = dataBase.newFluidFieldList(Tensor::zero(), HydroFieldNames::M_SPHCorrection);
mLocalM = dataBase.newFluidFieldList(Tensor::zero(), "local " + HydroFieldNames::M_SPHCorrection);
mNormalization = dataBase.newFluidFieldList(0.0, HydroFieldNames::normalization);
mInterfaceFlags = dataBase.newFluidFieldList(int(0), FSIFieldNames::interfaceFlags);
mInterfaceAreaVectors = dataBase.newFluidFieldList(Vector::one(), FSIFieldNames::interfaceAreaVectors);
mInterfaceNormals = dataBase.newFluidFieldList(Vector::one(), FSIFieldNames::interfaceNormals);
mInterfaceSmoothness = dataBase.newFluidFieldList(0.0, FSIFieldNames::interfaceSmoothness);
mNewInterfaceFlags = dataBase.newFluidFieldList(int(0), PureReplaceState<Dimension,int>::prefix() + FSIFieldNames::interfaceFlags);
mNewInterfaceAreaVectors = dataBase.newFluidFieldList(Vector::one(), PureReplaceState<Dimension,Vector>::prefix() + FSIFieldNames::interfaceAreaVectors);
mNewInterfaceNormals = dataBase.newFluidFieldList(Vector::one(), PureReplaceState<Dimension,Vector>::prefix() + FSIFieldNames::interfaceNormals);
mInterfaceSmoothnessNormalization = dataBase.newFluidFieldList(0.0, FSIFieldNames::interfaceSmoothnessNormalization);
mInterfaceFraction = dataBase.newFluidFieldList(0.0, FSIFieldNames::interfaceFraction);
mNewInterfaceSmoothness = dataBase.newFluidFieldList(0.0, PureReplaceState<Dimension,Scalar>::prefix() + FSIFieldNames::interfaceSmoothness);
mInterfaceAngles = dataBase.newFluidFieldList(0.0, FSIFieldNames::interfaceAngles);
}
//------------------------------------------------------------------------------
// On problem start up, we need to initialize our internal data.
//------------------------------------------------------------------------------
template<typename Dimension>
void
SolidFSISPH<Dimension>::
initializeProblemStartupDependencies(DataBase<Dimension>& dataBase,
State<Dimension>& state,
StateDerivatives<Dimension>& derivs) {
// Set the moduli.
updateStateFields(HydroFieldNames::pressure, state, derivs);
updateStateFields(HydroFieldNames::soundSpeed, state, derivs);
updateStateFields(SolidFieldNames::bulkModulus, state, derivs);
updateStateFields(SolidFieldNames::shearModulus, state, derivs);
updateStateFields(SolidFieldNames::yieldStrength, state, derivs);
const auto& mass = dataBase.fluidMass();
const auto& massDensity = dataBase.fluidMassDensity();
computeSPHVolume(mass,massDensity,mVolume);
}
//------------------------------------------------------------------------------
// Register states
//------------------------------------------------------------------------------
template<typename Dimension>
void
SolidFSISPH<Dimension>::
registerState(DataBase<Dimension>& dataBase,
State<Dimension>& state) {
TIME_BEGIN("SolidFSISPHregisterState");
VERIFY2(not (mCompatibleEnergyEvolution and mEvolveTotalEnergy),
"FSISPH error : you cannot simultaneously use both compatibleEnergyEvolution and evolveTotalEnergy");
FieldList<Dimension, Vector> position = dataBase.solidPosition();
FieldList<Dimension, Scalar> mass = dataBase.solidMass();
FieldList<Dimension, Scalar> massDensity = dataBase.solidMassDensity();
FieldList<Dimension, SymTensor> Hfield = dataBase.solidHfield();
FieldList<Dimension, Vector> velocity = dataBase.solidVelocity();
FieldList<Dimension, Scalar> specificThermalEnergy = dataBase.solidSpecificThermalEnergy();
FieldList<Dimension, SymTensor> deviatoricStress = dataBase.solidDeviatoricStress();
FieldList<Dimension, Scalar> plasticStrain = dataBase.solidPlasticStrain();
FieldList<Dimension, SymTensor> damage = dataBase.solidDamage();
FieldList<Dimension, int> fragIDs = dataBase.solidFragmentIDs();
FieldList<Dimension, int> pTypes = dataBase.solidParticleTypes();
for (auto [nodeListi, nodeListPtr]: enumerate(dataBase.solidNodeListBegin(), dataBase.solidNodeListEnd())) {
*mPlasticStrain0[nodeListi] = nodeListPtr->plasticStrain();
(*mPlasticStrain0[nodeListi]).name(SolidFieldNames::plasticStrain + "0");
}
// Create the local storage.
dataBase.resizeSolidFieldList(mTimeStepMask, int(1), HydroFieldNames::timeStepMask);
dataBase.resizeSolidFieldList(mVolume, 0.0, HydroFieldNames::volume, false);
dataBase.resizeSolidFieldList(mPressure, 0.0, HydroFieldNames::pressure, false);
dataBase.resizeSolidFieldList(mSoundSpeed, 0.0, HydroFieldNames::soundSpeed, false);
dataBase.resizeSolidFieldList(mBulkModulus, 0.0, SolidFieldNames::bulkModulus, false);
dataBase.resizeSolidFieldList(mShearModulus, 0.0, SolidFieldNames::shearModulus, false);
dataBase.resizeSolidFieldList(mYieldStrength, 0.0, SolidFieldNames::yieldStrength, false);
dataBase.resizeSolidFieldList(mPlasticStrain0, 0.0, SolidFieldNames::plasticStrain + "0", false);
dataBase.resizeSolidFieldList(mDamagedPressure, 0.0, SolidFieldNames::damagedPressure, false);
dataBase.resizeSolidFieldList(mInterfaceNormals, Vector::zero(), FSIFieldNames::interfaceNormals, false);
dataBase.resizeSolidFieldList(mInterfaceFraction, 0.0, FSIFieldNames::interfaceFraction, false);
dataBase.resizeSolidFieldList(mInterfaceSmoothness, 0.0, FSIFieldNames::interfaceSmoothness, false);
//dataBase.resizeSolidFieldList(mInverseEquivalentDeviatoricStress, 0.0, FSIFieldNames::inverseEquivalentDeviatoricStress, false);
dataBase.resizeFluidFieldList(mInterfaceFlags, int(0), FSIFieldNames::interfaceFlags,false);
dataBase.resizeFluidFieldList(mInterfaceAreaVectors, Vector::zero(), FSIFieldNames::interfaceAreaVectors,false);
dataBase.resizeFluidFieldList(mInterfaceNormals, Vector::zero(), FSIFieldNames::interfaceNormals,false);
dataBase.resizeFluidFieldList(mInterfaceSmoothness, 0.0, FSIFieldNames::interfaceSmoothness,false);
// Register the deviatoric stress and plastic strain to be evolved.
auto positionPolicy = make_policy<IncrementState<Dimension, Vector>>();
auto velocityPolicy = make_policy<IncrementState<Dimension, Vector>>({HydroFieldNames::position,HydroFieldNames::specificThermalEnergy},true);
auto Ppolicy = make_policy<PressurePolicy<Dimension>>();
auto csPolicy = make_policy<SoundSpeedPolicy<Dimension>>();
auto plasticStrainPolicy = make_policy<PlasticStrainPolicy<Dimension>>();
auto bulkModulusPolicy = make_policy<BulkModulusPolicy<Dimension>>();
auto shearModulusPolicy = make_policy<ShearModulusPolicy<Dimension>>();
auto yieldStrengthPolicy = make_policy<YieldStrengthPolicy<Dimension>>();
auto volumePolicy = make_policy<ReplaceWithRatioPolicy<Dimension,Scalar>>({HydroFieldNames::massDensity},
HydroFieldNames::mass, HydroFieldNames::massDensity);
auto interfaceFlagsPolicy = make_policy<PureReplaceState<Dimension,int>>();
auto interfaceAreaVectorsPolicy = make_policy<PureReplaceState<Dimension,Vector>>();
auto interfaceNormalsPolicy = make_policy<PureReplaceState<Dimension,Vector>>();
auto interfaceSmoothnessPolicy = make_policy<PureReplaceState<Dimension,Scalar>>();
auto deviatoricStressPolicy = make_policy<DeviatoricStressPolicy<Dimension>>();
state.enroll(deviatoricStress, deviatoricStressPolicy);
if(this->compatibleEnergyEvolution()){
auto thermalEnergyPolicy = make_policy<CompatibleDifferenceSpecificThermalEnergyPolicy<Dimension>>(dataBase);
state.enroll(specificThermalEnergy, thermalEnergyPolicy);
}else if (mEvolveTotalEnergy) {
auto thermalEnergyPolicy = make_policy<SpecificFromTotalThermalEnergyPolicy<Dimension>>();
state.enroll(specificThermalEnergy, thermalEnergyPolicy);
} else {
auto thermalEnergyPolicy = make_policy<IncrementState<Dimension, Scalar>>();
state.enroll(specificThermalEnergy, thermalEnergyPolicy);
}
for (auto [nodeListi, nodeListPtr]: enumerate(dataBase.solidNodeListBegin(), dataBase.solidNodeListEnd())) {
state.enroll(*massDensity[nodeListi], make_policy<IncrementBoundedState<Dimension, Scalar>>(nodeListPtr->rhoMin(),
nodeListPtr->rhoMax()));
}
state.enroll(position, positionPolicy);
state.enroll(velocity, velocityPolicy);
state.enroll(mVolume, volumePolicy);
state.enroll(mSoundSpeed, csPolicy);
state.enroll(mPressure, Ppolicy);
state.enroll(mDamagedPressure); // Updated by PressurePolicy
state.enroll(mBulkModulus, bulkModulusPolicy);
state.enroll(mShearModulus, shearModulusPolicy);
state.enroll(mYieldStrength, yieldStrengthPolicy);
state.enroll(plasticStrain, plasticStrainPolicy);
state.enroll(mInterfaceFlags, interfaceFlagsPolicy);
state.enroll(mInterfaceAreaVectors, interfaceAreaVectorsPolicy);
state.enroll(mInterfaceNormals, interfaceNormalsPolicy);
state.enroll(mInterfaceSmoothness, interfaceSmoothnessPolicy);
state.enroll(mTimeStepMask);
state.enroll(mass);
//state.enroll(mInverseEquivalentDeviatoricStress);
state.enroll(damage);
state.enroll(fragIDs);
state.enroll(pTypes);
state.enroll(mPlasticStrain0);
TIME_END("SolidFSISPHregisterState");
}
//------------------------------------------------------------------------------
// Register Derivs
//------------------------------------------------------------------------------
template<typename Dimension>
void
SolidFSISPH<Dimension>::
registerDerivatives(DataBase<Dimension>& dataBase,
StateDerivatives<Dimension>& derivs) {
TIME_BEGIN("SolidFSISPHregisterDerivs");
FieldList<Dimension, Scalar> plasticStrainRate = dataBase.solidPlasticStrainRate();
dataBase.resizeFluidFieldList(mXSPHDeltaV, Vector::zero(), HydroFieldNames::XSPHDeltaV, false);
dataBase.resizeFluidFieldList(mXSPHWeightSum, 0.0, HydroFieldNames::XSPHWeightSum, false);
dataBase.resizeFluidFieldList(mDvDt, Vector::zero(), HydroFieldNames::hydroAcceleration, false);
dataBase.resizeFluidFieldList(mDmassDensityDt, 0.0, IncrementState<Dimension, Scalar>::prefix() + HydroFieldNames::massDensity, false);
dataBase.resizeFluidFieldList(mDspecificThermalEnergyDt, 0.0, IncrementState<Dimension, Scalar>::prefix() + HydroFieldNames::specificThermalEnergy, false);
dataBase.resizeFluidFieldList(mDdeviatoricStressDt, SymTensor::zero(), IncrementState<Dimension, Vector>::prefix() + SolidFieldNames::deviatoricStress, false);
dataBase.resizeFluidFieldList(mDPDx, Vector::zero(), FSIFieldNames::pressureGradient, false);
dataBase.resizeFluidFieldList(mDepsDx, Vector::zero(), FSIFieldNames::specificThermalEnergyGradient, false);
dataBase.resizeFluidFieldList(mDvDx, Tensor::zero(), HydroFieldNames::velocityGradient, false);
dataBase.resizeFluidFieldList(mInternalDvDx, Tensor::zero(), HydroFieldNames::internalVelocityGradient, false);
dataBase.resizeFluidFieldList(mM, Tensor::zero(), HydroFieldNames::M_SPHCorrection, false);
dataBase.resizeFluidFieldList(mLocalM, Tensor::zero(), "local " + HydroFieldNames::M_SPHCorrection, false);
dataBase.resizeFluidFieldList(mNormalization, 0.0, HydroFieldNames::normalization, false);
dataBase.resizeFluidFieldList(mNewInterfaceFlags, int(0), PureReplaceState<Dimension,int>::prefix() + FSIFieldNames::interfaceFlags,false);
dataBase.resizeFluidFieldList(mNewInterfaceAreaVectors, Vector::zero(), PureReplaceState<Dimension,Vector>::prefix() + FSIFieldNames::interfaceAreaVectors,false);
dataBase.resizeFluidFieldList(mNewInterfaceNormals, Vector::zero(), PureReplaceState<Dimension,Vector>::prefix() + FSIFieldNames::interfaceNormals,false);
dataBase.resizeFluidFieldList(mInterfaceSmoothnessNormalization, 0.0, FSIFieldNames::interfaceSmoothnessNormalization,false);
dataBase.resizeFluidFieldList(mInterfaceFraction, 0.0, FSIFieldNames::interfaceFraction,false);
dataBase.resizeFluidFieldList(mNewInterfaceSmoothness, 0.0, PureReplaceState<Dimension,Scalar>::prefix() + FSIFieldNames::interfaceSmoothness,false);
dataBase.resizeFluidFieldList(mInterfaceAngles, 0.0, FSIFieldNames::interfaceAngles,false);
if (not derivs.registered(mDxDt)) {
dataBase.resizeFluidFieldList(mDxDt, Vector::zero(), IncrementState<Dimension, Vector>::prefix() + HydroFieldNames::position, false);
derivs.enroll(mDxDt);
}
CHECK(not derivs.registered(mDvDt));
if (mCompatibleEnergyEvolution) {
const auto& connectivityMap = dataBase.connectivityMap();
mPairAccelerationsPtr = std::make_unique<PairAccelerationsType>(connectivityMap);
mPairDepsDtPtr = std::make_unique<PairWorkType>(connectivityMap);
}
derivs.enroll(HydroFieldNames::pairAccelerations, *mPairAccelerationsPtr);
derivs.enroll(HydroFieldNames::pairWork, *mPairDepsDtPtr);
derivs.enroll(plasticStrainRate);
derivs.enroll(mXSPHDeltaV);
derivs.enroll(mXSPHWeightSum);
derivs.enroll(mDvDt);
derivs.enroll(mDmassDensityDt);
derivs.enroll(mDspecificThermalEnergyDt);
derivs.enroll(mDdeviatoricStressDt);
derivs.enroll(mDPDx);
derivs.enroll(mDepsDx);
derivs.enroll(mDvDx);
derivs.enroll(mInternalDvDx);
derivs.enroll(mM);
derivs.enroll(mLocalM);
derivs.enroll(mNormalization);
derivs.enroll(mNewInterfaceFlags);
derivs.enroll(mNewInterfaceAreaVectors);
derivs.enroll(mNewInterfaceNormals);
derivs.enroll(mInterfaceSmoothnessNormalization);
derivs.enroll(mInterfaceFraction);
derivs.enroll(mNewInterfaceSmoothness);
derivs.enroll(mInterfaceAngles);
TIME_END("SolidFSISPHregisterDerivs");
}
//------------------------------------------------------------------------------
// FSI specialized density summmation
//------------------------------------------------------------------------------
template<typename Dimension>
void
SolidFSISPH<Dimension>::
preStepInitialize(const DataBase<Dimension>& dataBase,
State<Dimension>& state,
StateDerivatives<Dimension>& /*derivs*/) {
TIME_BEGIN("SolidFSISPHpreStepInitialize");
if (mApplySelectDensitySum){
switch(this->densityUpdate()){
case FSIMassDensityMethod::FSISumMassDensity:
{
const auto& W = this->kernel();
const auto& connectivityMap = dataBase.connectivityMap();
const auto position = state.fields(HydroFieldNames::position, Vector::zero());
const auto mass = state.fields(HydroFieldNames::mass, 0.0);
const auto H = state.fields(HydroFieldNames::H, SymTensor::zero());
auto massDensity = state.fields(HydroFieldNames::massDensity, 0.0);
computeFSISPHSumMassDensity(connectivityMap, W, mSumDensityNodeLists, position, mass, H, massDensity);
for (auto boundaryItr = this->boundaryBegin(); boundaryItr < this->boundaryEnd(); ++boundaryItr) (*boundaryItr)->applyFieldListGhostBoundary(massDensity);
for (auto boundaryItr = this->boundaryBegin(); boundaryItr < this->boundaryEnd(); ++boundaryItr) (*boundaryItr)->finalizeGhostBoundary();
break;
}
case FSIMassDensityMethod::PressureCorrectSumMassDensity:
{
const auto& W = this->kernel();
const auto& connectivityMap = dataBase.connectivityMap();
const auto position = state.fields(HydroFieldNames::position, Vector::zero());
const auto mass = state.fields(HydroFieldNames::mass, 0.0);
const auto H = state.fields(HydroFieldNames::H, SymTensor::zero());
auto pressure = state.fields(HydroFieldNames::pressure, 0.0);
auto soundSpeed = state.fields(HydroFieldNames::soundSpeed, 0.0);
auto volume = state.fields(HydroFieldNames::volume, 0.0);
auto massDensity = state.fields(HydroFieldNames::massDensity, 0.0);
computeInterfacePressureCorrectedSumMassDensity(connectivityMap,
W,
mSumDensityNodeLists,
position,
mass,
H,
volume,
pressure,
soundSpeed,
massDensity);
for (auto boundaryItr = this->boundaryBegin(); boundaryItr < this->boundaryEnd(); ++boundaryItr) (*boundaryItr)->applyFieldListGhostBoundary(massDensity);
for (auto boundaryItr = this->boundaryBegin(); boundaryItr < this->boundaryEnd(); ++boundaryItr) (*boundaryItr)->finalizeGhostBoundary();
break;
}
case FSIMassDensityMethod::HWeightedSumMassDensity:
{
const auto& W = this->kernel();
const auto& connectivityMap = dataBase.connectivityMap();
const auto position = state.fields(HydroFieldNames::position, Vector::zero());
const auto mass = state.fields(HydroFieldNames::mass, 0.0);
const auto H = state.fields(HydroFieldNames::H, SymTensor::zero());
auto massDensity = state.fields(HydroFieldNames::massDensity, 0.0);
computeHWeightedFSISPHSumMassDensity(connectivityMap, W, mSumDensityNodeLists, position, mass, H, massDensity);
for (auto boundaryItr = this->boundaryBegin(); boundaryItr < this->boundaryEnd(); ++boundaryItr) (*boundaryItr)->applyFieldListGhostBoundary(massDensity);
for (auto boundaryItr = this->boundaryBegin(); boundaryItr < this->boundaryEnd(); ++boundaryItr) (*boundaryItr)->finalizeGhostBoundary();
break;
}
default:
break;
}
}
TIME_END("SolidFSISPHpreStepInitialize");
}
//------------------------------------------------------------------------------
// For compatible energy we need to apply the bc conditions to acceleration
//------------------------------------------------------------------------------
template<typename Dimension>
void
SolidFSISPH<Dimension>::
finalizeDerivatives(const Scalar /*time*/,
const Scalar /*dt*/,
const DataBase<Dimension>& /*dataBase*/,
const State<Dimension>& /*state*/,
StateDerivatives<Dimension>& derivs) const {
if (this->compatibleEnergyEvolution()) {
auto accelerations = derivs.fields(HydroFieldNames::hydroAcceleration, Vector::zero());
for (ConstBoundaryIterator boundaryItr = this->boundaryBegin();
boundaryItr != this->boundaryEnd();
++boundaryItr) {
(*boundaryItr)->applyFieldListGhostBoundary(accelerations);
}
for (ConstBoundaryIterator boundaryItr = this->boundaryBegin();
boundaryItr != this->boundaryEnd();
++boundaryItr) (*boundaryItr)->finalizeGhostBoundary();
}
} // finalize
//------------------------------------------------------------------------------
// Apply the ghost boundary conditions for hydro state fields.
//------------------------------------------------------------------------------
template<typename Dimension>
void
SolidFSISPH<Dimension>::
applyGhostBoundaries(State<Dimension>& state,
StateDerivatives<Dimension>& derivs) {
FieldList<Dimension, Scalar> mass = state.fields(HydroFieldNames::mass, 0.0);
FieldList<Dimension, Scalar> massDensity = state.fields(HydroFieldNames::massDensity, 0.0);
FieldList<Dimension, Scalar> specificThermalEnergy = state.fields(HydroFieldNames::specificThermalEnergy, 0.0);
FieldList<Dimension, Vector> velocity = state.fields(HydroFieldNames::velocity, Vector::zero());
FieldList<Dimension, Scalar> pressure = state.fields(HydroFieldNames::pressure, 0.0);
FieldList<Dimension, Scalar> damagedPressure = state.fields(SolidFieldNames::damagedPressure, 0.0);
FieldList<Dimension, Scalar> soundSpeed = state.fields(HydroFieldNames::soundSpeed, 0.0);
FieldList<Dimension, SymTensor> S = state.fields(SolidFieldNames::deviatoricStress, SymTensor::zero());
FieldList<Dimension, Scalar> K = state.fields(SolidFieldNames::bulkModulus, 0.0);
FieldList<Dimension, Scalar> mu = state.fields(SolidFieldNames::shearModulus, 0.0);
FieldList<Dimension, Scalar> Y = state.fields(SolidFieldNames::yieldStrength, 0.0);
FieldList<Dimension, int> fragIDs = state.fields(SolidFieldNames::fragmentIDs, int(1));
FieldList<Dimension, int> pTypes = state.fields(SolidFieldNames::particleTypes, int(0));
//FieldList<Dimension, Scalar> invSqrtJ2 = state.fields(FSIFieldNames::inverseEquivalentDeviatoricStress, 0.0);
FieldList<Dimension, int> interfaceFlags = state.fields(FSIFieldNames::interfaceFlags, int(0));
FieldList<Dimension, Vector> interfaceAreaVectors = state.fields(FSIFieldNames::interfaceAreaVectors, Vector::zero());
FieldList<Dimension, Vector> interfaceNormals = state.fields(FSIFieldNames::interfaceNormals, Vector::zero());
FieldList<Dimension, Scalar> interfaceSmoothness = state.fields(FSIFieldNames::interfaceSmoothness, 0.0);
for (ConstBoundaryIterator boundaryItr = this->boundaryBegin();
boundaryItr != this->boundaryEnd();
++boundaryItr) {
(*boundaryItr)->applyFieldListGhostBoundary(mass);
(*boundaryItr)->applyFieldListGhostBoundary(massDensity);
(*boundaryItr)->applyFieldListGhostBoundary(specificThermalEnergy);
(*boundaryItr)->applyFieldListGhostBoundary(velocity);
(*boundaryItr)->applyFieldListGhostBoundary(pressure);
(*boundaryItr)->applyFieldListGhostBoundary(damagedPressure);
(*boundaryItr)->applyFieldListGhostBoundary(soundSpeed);
(*boundaryItr)->applyFieldListGhostBoundary(S);
(*boundaryItr)->applyFieldListGhostBoundary(K);
(*boundaryItr)->applyFieldListGhostBoundary(mu);
(*boundaryItr)->applyFieldListGhostBoundary(Y);
(*boundaryItr)->applyFieldListGhostBoundary(fragIDs);
(*boundaryItr)->applyFieldListGhostBoundary(pTypes);
//(*boundaryItr)->applyFieldListGhostBoundary(invSqrtJ2);
(*boundaryItr)->applyFieldListGhostBoundary(interfaceFlags);
(*boundaryItr)->applyFieldListGhostBoundary(interfaceAreaVectors);
(*boundaryItr)->applyFieldListGhostBoundary(interfaceNormals);
(*boundaryItr)->applyFieldListGhostBoundary(interfaceSmoothness);
}
}
//------------------------------------------------------------------------------
// Enforce the boundary conditions for hydro state fields.
//------------------------------------------------------------------------------
template<typename Dimension>
void
SolidFSISPH<Dimension>::
enforceBoundaries(State<Dimension>& state,
StateDerivatives<Dimension>& derivs) {
FieldList<Dimension, Scalar> mass = state.fields(HydroFieldNames::mass, 0.0);
FieldList<Dimension, Scalar> massDensity = state.fields(HydroFieldNames::massDensity, 0.0);
FieldList<Dimension, Scalar> specificThermalEnergy = state.fields(HydroFieldNames::specificThermalEnergy, 0.0);
FieldList<Dimension, Vector> velocity = state.fields(HydroFieldNames::velocity, Vector::zero());
FieldList<Dimension, Scalar> pressure = state.fields(HydroFieldNames::pressure, 0.0);
FieldList<Dimension, Scalar> damagedPressure = state.fields(SolidFieldNames::damagedPressure, 0.0);
FieldList<Dimension, Scalar> soundSpeed = state.fields(HydroFieldNames::soundSpeed, 0.0);
FieldList<Dimension, SymTensor> S = state.fields(SolidFieldNames::deviatoricStress, SymTensor::zero());
FieldList<Dimension, Scalar> K = state.fields(SolidFieldNames::bulkModulus, 0.0);
FieldList<Dimension, Scalar> mu = state.fields(SolidFieldNames::shearModulus, 0.0);
FieldList<Dimension, Scalar> Y = state.fields(SolidFieldNames::yieldStrength, 0.0);
FieldList<Dimension, int> fragIDs = state.fields(SolidFieldNames::fragmentIDs, int(1));
FieldList<Dimension, int> pTypes = state.fields(SolidFieldNames::particleTypes, int(0));
//FieldList<Dimension, Scalar> invSqrtJ2 = state.fields(FSIFieldNames::inverseEquivalentDeviatoricStress, 0.0);
FieldList<Dimension, int> interfaceFlags = state.fields(FSIFieldNames::interfaceFlags, int(0));
FieldList<Dimension, Vector> interfaceAreaVectors = state.fields(FSIFieldNames::interfaceAreaVectors, Vector::zero());
FieldList<Dimension, Vector> interfaceNormals = state.fields(FSIFieldNames::interfaceNormals, Vector::zero());
FieldList<Dimension, Scalar> interfaceSmoothness = state.fields(FSIFieldNames::interfaceSmoothness, 0.0);
for (ConstBoundaryIterator boundaryItr = this->boundaryBegin();
boundaryItr != this->boundaryEnd();
++boundaryItr) {
(*boundaryItr)->enforceFieldListBoundary(mass);
(*boundaryItr)->enforceFieldListBoundary(massDensity);
(*boundaryItr)->enforceFieldListBoundary(specificThermalEnergy);
(*boundaryItr)->enforceFieldListBoundary(velocity);
(*boundaryItr)->enforceFieldListBoundary(pressure);
(*boundaryItr)->enforceFieldListBoundary(damagedPressure);
(*boundaryItr)->enforceFieldListBoundary(soundSpeed);
(*boundaryItr)->enforceFieldListBoundary(S);
(*boundaryItr)->enforceFieldListBoundary(K);
(*boundaryItr)->enforceFieldListBoundary(mu);
(*boundaryItr)->enforceFieldListBoundary(Y);
(*boundaryItr)->enforceFieldListBoundary(fragIDs);
(*boundaryItr)->enforceFieldListBoundary(pTypes);
//(*boundaryItr)->enforceFieldListBoundary(invSqrtJ2);
(*boundaryItr)->enforceFieldListBoundary(interfaceFlags);
(*boundaryItr)->enforceFieldListBoundary(interfaceAreaVectors);
(*boundaryItr)->enforceFieldListBoundary(interfaceNormals);
(*boundaryItr)->enforceFieldListBoundary(interfaceSmoothness);
}
}
//------------------------------------------------------------------------------
// Dump the current state to the given file.
//------------------------------------------------------------------------------
template<typename Dimension>
void
SolidFSISPH<Dimension>::
dumpState(FileIO& file, const string& pathName) const {
file.write(mTimeStepMask, pathName + "/timeStepMask");
file.write(mPressure, pathName + "/pressure");
file.write(mDamagedPressure, pathName + "/damagedPressure");
file.write(mSoundSpeed, pathName + "/soundSpeed");
file.write(mVolume, pathName + "/volume");
file.write(mBulkModulus, pathName + "/bulkModulus");
file.write(mShearModulus, pathName + "/shearModulus");
file.write(mYieldStrength, pathName + "/yieldStrength");
file.write(mPlasticStrain0, pathName + "/plasticStrain0");
//file.write(mInverseEquivalentDeviatoricStress, pathName + "/inverseEquivalentDeviatoricStress");
file.write(mDxDt, pathName + "/DxDt");
file.write(mXSPHDeltaV, pathName + "/XSPHDeltaV");
file.write(mDvDt, pathName + "/DvDt");
file.write(mDmassDensityDt, pathName + "/DmassDensityDt");
file.write(mDspecificThermalEnergyDt, pathName + "/DspecificThermalEnergyDt");
file.write(mDdeviatoricStressDt, pathName + "/DdeviatoricStressDt");
file.write(mDPDx, pathName + "/DpDx");
file.write(mDepsDx, pathName + "/DepsDx");
file.write(mDvDx, pathName + "/DvDx");
file.write(mInternalDvDx, pathName + "/internalDvDx");
file.write(mM, pathName + "/M");
file.write(mLocalM, pathName + "/localM");
file.write(mNormalization, pathName + "/normalization");
file.write(mInterfaceFlags, pathName + "/interfaceFlags");
file.write(mInterfaceAreaVectors, pathName + "/interfaceAreaVectors");
file.write(mInterfaceNormals, pathName + "/interfaceNormals");
file.write(mInterfaceSmoothness, pathName + "/interfaceSmoothness");
file.write(mNewInterfaceFlags, pathName + "/newInterfaceFlags");
file.write(mNewInterfaceAreaVectors, pathName + "/newInterfaceAreaVectors");
file.write(mNewInterfaceNormals, pathName + "/newInterfaceNormals");
file.write(mInterfaceSmoothnessNormalization, pathName + "/interfaceSmoothnessNormalization");
file.write(mNewInterfaceSmoothness, pathName + "/newInterfaceSmoothness");
file.write(mInterfaceFraction, pathName + "/interfaceFraction");
file.write(mInterfaceAngles, pathName + "/interfaceAngles");
}
//------------------------------------------------------------------------------
// Dump the current state to the given file.
//------------------------------------------------------------------------------
template<typename Dimension>
void
SolidFSISPH<Dimension>::
restoreState(const FileIO& file, const string& pathName) {
file.read(mTimeStepMask, pathName + "/timeStepMask");
file.read(mPressure, pathName + "/pressure");
file.read(mDamagedPressure, pathName + "/damagedPressure");
file.read(mSoundSpeed, pathName + "/soundSpeed");
file.read(mVolume, pathName + "/volume");
file.read(mBulkModulus, pathName + "/bulkModulus");
file.read(mShearModulus, pathName + "/shearModulus");
file.read(mYieldStrength, pathName + "/yieldStrength");
file.read(mPlasticStrain0, pathName + "/plasticStrain0");
//file.read(mInverseEquivalentDeviatoricStress, pathName + "/inverseEquivalentDeviatoricStress");
file.read(mDxDt, pathName + "/DxDt");
file.read(mXSPHDeltaV, pathName + "/XSPHDeltaV");
file.read(mDvDt, pathName + "/DvDt");
file.read(mDmassDensityDt, pathName + "/DmassDensityDt");
file.read(mDspecificThermalEnergyDt, pathName + "/DspecificThermalEnergyDt");
file.read(mDdeviatoricStressDt, pathName + "/DdeviatoricStressDt");
file.read(mDPDx, pathName + "/DpDx");
file.read(mDepsDx, pathName + "/DepsDx");
file.read(mDvDx, pathName + "/DvDx");
file.read(mInternalDvDx, pathName + "/internalDvDx");
file.read(mM, pathName + "/M");
file.read(mLocalM, pathName + "/localM");
file.read(mNormalization, pathName + "/normalization");
file.read(mInterfaceFlags, pathName + "/interfaceFlags");
file.read(mInterfaceAreaVectors, pathName + "/interfaceAreaVectors");
file.read(mInterfaceNormals, pathName + "/interfaceNormals");
file.read(mInterfaceSmoothness, pathName + "/interfaceSmoothness");
file.read(mNewInterfaceFlags, pathName + "/newInterfaceFlags");
file.read(mNewInterfaceAreaVectors, pathName + "/newInterfaceAreaVectors");
file.read(mNewInterfaceNormals, pathName + "/newInterfaceNormals");
file.read(mInterfaceSmoothnessNormalization, pathName + "/interfaceSmoothnessNormalization");
file.read(mNewInterfaceSmoothness, pathName + "/newInterfaceSmoothness");
file.read(mInterfaceFraction, pathName + "/interfaceFraction");
file.read(mInterfaceAngles, pathName + "/interfaceAngles");
// For backwards compatibility on change 3597 -- drop in the near future.
for (auto DvDtPtr: mDvDt) DvDtPtr->name(HydroFieldNames::hydroAcceleration);
}
//------------------------------------------------------------------------------
// method for limited linear reconstruction between nodes
//------------------------------------------------------------------------------
template<typename Dimension>
void
SolidFSISPH<Dimension>::
linearReconstruction(const typename Dimension::Vector& ri,
const typename Dimension::Vector& rj,
const typename Dimension::Scalar& yi,
const typename Dimension::Scalar& yj,
const typename Dimension::Vector& DyDxi,
const typename Dimension::Vector& DyDxj,
typename Dimension::Scalar& ytildei,
typename Dimension::Scalar& ytildej) const {
const auto tiny = std::numeric_limits<Scalar>::epsilon();
const auto rij = (ri-rj);
// relavant deltas in field value
const auto Dy0 = (yi-yj);
const auto Dyi = 0.5*DyDxi.dot(rij);
const auto Dyj = 0.5*DyDxj.dot(rij);
// ratios of SPH derivs to ij particle difference
const auto denom = 2.0 / (sgn(Dy0) * std::max(tiny,abs(Dy0)));
const auto xi = Dyi * denom;
const auto xj = Dyj * denom;
// limiter function - vanleer 1979
const auto phii = ( xi > 0.0 ? min(4.0*xi/((1.0 + xi)*(1.0 + xi)),1.0) : 0.0 );
const auto phij = ( xj > 0.0 ? min(4.0*xj/((1.0 + xj)*(1.0 + xj)),1.0) : 0.0 );
const auto phi = 0.5*(phii+phij);
// linear constructed inteface values
ytildei = yi - phi * Dyi;
ytildej = yj + phi * Dyj;
}
} // Spheral namespace