Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port imposed SR to GPU #1043

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Port imposed SR to GPU #1043

wants to merge 11 commits into from

Conversation

Thomas-Ulrich
Copy link
Contributor

@Thomas-Ulrich Thomas-Ulrich commented Feb 7, 2024

The implementation (bot) currently yields different SR results but correct final slip.
image
image

We also tried using a detail structure as in other friction laws, and got similar problems
(will slightly different waves amplitudes for the artifacts)

--- a/src/DynamicRupture/FrictionLaws/GpuImpl/ImposedSlipRates.h
+++ b/src/DynamicRupture/FrictionLaws/GpuImpl/ImposedSlipRates.h
@@ -52,6 +52,7 @@ class ImposedSlipRates : public BaseFrictionSolver<ImposedSlipRates<STF>> {
     for (unsigned i = 0; i <= timeIndex; i++) {
       currentTime += devDeltaT[i];
     }
+    auto details = devStf.getCurrentLtsLayerDetails();
 
     sycl::nd_range rng{{this->currLayerSize * misc::numPaddedPoints}, {misc::numPaddedPoints}};
     this->queue.submit([&](sycl::handler& cgh) {
@@ -62,7 +63,8 @@ class ImposedSlipRates : public BaseFrictionSolver<ImposedSlipRates<STF>> {
         auto& faultStresses = devFaultStresses[ltsFace];
         auto& tractionResults = devTractionResults[ltsFace];
 
-        const real stfEvaluated = devStf.evaluate(currentTime, timeIncrement, ltsFace, pointIndex);
+        const real stfEvaluated =
+            devStf.evaluateConst(details, currentTime, timeIncrement, ltsFace, pointIndex);
 
         devSlipRate1[ltsFace][pointIndex] =
             devImposedSlipDirection1[ltsFace][pointIndex] * stfEvaluated;
diff --git a/src/DynamicRupture/FrictionLaws/SourceTimeFunction.h b/src/DynamicRupture/FrictionLaws/SourceTimeFunction.h
index b81f5936..4c68b91a 100644
--- a/src/DynamicRupture/FrictionLaws/SourceTimeFunction.h
+++ b/src/DynamicRupture/FrictionLaws/SourceTimeFunction.h
@@ -14,6 +14,8 @@ class YoffeSTF {
   real (*tauS)[misc::numPaddedPoints];
   real (*tauR)[misc::numPaddedPoints];
 
+  struct Details {};
+
   public:
   void copyLtsTreeToLocal(seissol::initializer::Layer& layerData,
                           seissol::initializer::DynamicRupture const* const dynRup,
@@ -24,6 +26,11 @@ class YoffeSTF {
     tauS = layerData.var(concreteLts->tauS);
     tauR = layerData.var(concreteLts->tauR);
   }
+  Details getCurrentLtsLayerDetails() {
+    Details details{};
+    return details;
+  }
+
   real evaluate(real currentTime,
                 [[maybe_unused]] real timeIncrement,
                 size_t ltsFace,
@@ -33,6 +40,13 @@ class YoffeSTF {
                                                              tauS[ltsFace][pointIndex],
                                                              tauR[ltsFace][pointIndex]);
   }
+  real evaluateConst(Details details,
+                     real currentTime,
+                     real timeIncrement,
+                     size_t ltsFace,
+                     size_t pointIndex) const {
+    return 0.0;
+  }
 };
 template <typename MathFunctions>
 class GaussianSTF {
@@ -40,7 +54,18 @@ class GaussianSTF {
   real (*onsetTime)[misc::numPaddedPoints];
   real (*riseTime)[misc::numPaddedPoints];
 
+  struct Details {
+    decltype(GaussianSTF::onsetTime) onsetTime;
+    decltype(GaussianSTF::riseTime) riseTime;
+  };
+
   public:
+  Details getCurrentLtsLayerDetails() {
+    Details details{};
+    details.onsetTime = this->onsetTime;
+    details.riseTime = this->riseTime;
+    return details;
+  }
   void copyLtsTreeToLocal(seissol::initializer::Layer& layerData,
                           seissol::initializer::DynamicRupture const* const dynRup,
                           real fullUpdateTime) {
@@ -55,6 +80,18 @@ class GaussianSTF {
         currentTime - onsetTime[ltsFace][pointIndex], timeIncrement, riseTime[ltsFace][pointIndex]);
     return smoothStepIncrement / timeIncrement;
   }
+
+  real evaluateConst(Details details,
+                     real currentTime,
+                     real timeIncrement,
+                     size_t ltsFace,
+                     size_t pointIndex) const {
+    const real smoothStepIncrement = gaussianNucleationFunction::smoothStepIncrement<MathFunctions>(
+        currentTime - details.onsetTime[ltsFace][pointIndex],
+        timeIncrement,
+        details.riseTime[ltsFace][pointIndex]);
+    return smoothStepIncrement / timeIncrement;
+  }
 };
 } // namespace seissol::dr::friction_law
 #endif // SEISSOL_SOURCETIMEFUNCTION_H

@codecov-commenter
Copy link

codecov-commenter commented Feb 7, 2024

Codecov Report

Attention: 26 lines in your changes are missing coverage. Please review.

Comparison is base (cfd5961) 13.98% compared to head (e680fd4) 14.00%.

Files Patch % Lines
...c/DynamicRupture/FrictionLaws/SourceTimeFunction.h 0.00% 17 Missing ⚠️
src/Initializer/DynamicRupture.h 0.00% 6 Missing ⚠️
src/DynamicRupture/Factory.cpp 0.00% 3 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1043      +/-   ##
==========================================
+ Coverage   13.98%   14.00%   +0.02%     
==========================================
  Files         267      267              
  Lines       14891    14896       +5     
==========================================
+ Hits         2082     2086       +4     
- Misses      12809    12810       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Thomas-Ulrich Thomas-Ulrich changed the title trying to port imposed SR to GPU Port imposed SR to GPU Feb 15, 2024
@Thomas-Ulrich Thomas-Ulrich marked this pull request as ready for review February 15, 2024 11:00
@Thomas-Ulrich Thomas-Ulrich marked this pull request as draft February 15, 2024 12:50
@Thomas-Ulrich Thomas-Ulrich marked this pull request as ready for review February 15, 2024 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants