Salvus: A flexible open-source package for full- waveform modelling - - PowerPoint PPT Presentation

salvus a flexible open source package for full waveform
SMART_READER_LITE
LIVE PREVIEW

Salvus: A flexible open-source package for full- waveform modelling - - PowerPoint PPT Presentation

Salvus: A flexible open-source package for full- waveform modelling and inversion Michael Afanasiev, Christian Boehm, Martin van Driel, Lion Krischer, Dave May, Max Rietmann, Korbinian Sager, and Andreas Fichtner 1.12.2014 Full waveform


slide-1
SLIDE 1

Salvus: A flexible open-source package for full- waveform modelling and inversion

Michael Afanasiev, Christian Boehm, Martin van Driel, Lion Krischer, Dave May, Max Rietmann, Korbinian Sager, and Andreas Fichtner

1.12.2014

slide-2
SLIDE 2

Full waveform inversion

∂2

t u(x) r · σ(x) F = 0

σ(x) = c(x) : ru(x)

slide-3
SLIDE 3

Full waveform inversion

∂2

t u(x) r · σ(x) F = 0

σ(x) = c(x) : ru(x)

A problem of optimal control over c, constrained by the wave equation.

slide-4
SLIDE 4

Motivation

σ(x) = c(x) : ru(x)

Takes on a very different character…

slide-5
SLIDE 5

Motivation

Acoustic and attenuative 2D/3D propagation through tissue Elastic/Acoustic/ Gravity coupling, 3D, attenuative Elastic regional scale with topography 2D/3D, Elastic/Acoustic coupling, Topography, Attenuation

σ(x) = c(x) : ru(x)

Takes on a very different character…

slide-6
SLIDE 6

Motivation

Acoustic and attenuative 2D/3D propagation through tissue Elastic/Acoustic/ Gravity coupling, 3D, attenuative Elastic regional scale with topography 2D/3D, Elastic/Acoustic coupling, Topography, Attenuation

slide-7
SLIDE 7

Motivation

Acoustic and attenuative 2D/3D propagation through tissue Elastic/Acoustic/ Gravity coupling, 3D, attenuative Elastic regional scale with topography 2D/3D, Elastic/Acoustic coupling, Topography, Attenuation

slide-8
SLIDE 8

▪ Flexible and modular design, with support for the concurrent simulation of multiple coupled PDEs — composability ▪ Scalable, dimension independent spatial and temporal discretization ▪ Simple integration with external optimization libraries ▪ Correct and consistent solutions ▪ Speed

Requirements

slide-9
SLIDE 9

Flexible and modular design, with support for the concurrent simulation of multiple coupled PDEs

slide-10
SLIDE 10

Modular design

Quad FEM Basis 1 Physics 1 Additional physics… Coupling physics… Shape Mapping 1 Shape Mapping 2 Shape Mapping …. FEM Basis 2 FEM Basis … Hex Physics 2 Physics …

slide-11
SLIDE 11

Modular design (Composability)

Shape::computeJacobian(); Shape::interpolateParameters(); … Element::computeSymmetricGradient(); Element::applyGradTestAndIntegrate(); … Physics::computeStrain(); Physics::computeStress(); … AdditionalPhysics::modifyStress(); … CouplingPhysics::computeCouplingTerm(); …

…need to change any one of these independently.

slide-12
SLIDE 12

Modular design: a solution with template mixins

template <typename Element> MatrixXd Elastic2D<Element>::computeStiffnessTerm(const Eigen::MatrixXd &u) { // strain ux_x, ux_y, uy_x, uy_y. mStrain.leftCols<2>() = Element::computeGradient(u.col(0)); mStrain.rightCols<2>() = Element::computeGradient(u.col(1)); // compute stress from strain. mStress = computeStress(mStrain); // temporary matrix to hold directional stresses. Matrix<double,Dynamic,2> temp_stress(Element::NumIntPnt(), 2); // compute stiffness. temp_stress.col(0) = mStress.col(0); temp_stress.col(1) = mStress.col(2); mStiff.col(0) = Element::applyGradTestAndIntegrate(temp_stress); temp_stress.col(0) = mStress.col(2); temp_stress.col(1) = mStress.col(1); mStiff.col(1) = Element::applyGradTestAndIntegrate(temp_stress); return mStiff; }

slide-13
SLIDE 13

Modular design: a solution with template mixins

template <typename Element> MatrixXd Elastic2D<Element>::computeStiffnessTerm(const Eigen::MatrixXd &u) { // strain ux_x, ux_y, uy_x, uy_y. mStrain.leftCols<2>() = Element::computeGradient(u.col(0)); mStrain.rightCols<2>() = Element::computeGradient(u.col(1)); // compute stress from strain. mStress = computeStress(mStrain); // temporary matrix to hold directional stresses. Matrix<double,Dynamic,2> temp_stress(Element::NumIntPnt(), 2); // compute stiffness. temp_stress.col(0) = mStress.col(0); temp_stress.col(1) = mStress.col(2); mStiff.col(0) = Element::applyGradTestAndIntegrate(temp_stress); temp_stress.col(0) = mStress.col(2); temp_stress.col(1) = mStress.col(1); mStiff.col(1) = Element::applyGradTestAndIntegrate(temp_stress); return mStiff; }

slide-14
SLIDE 14

Modular design: a solution with template mixins

template <typename Physics> MatrixXd Attenuation<Physics>::computeStiffnessTerm(const Eigen::MatrixXd &u) { strain = Physics::computeGradient(u); /* Modify strain by subtracting from memory variable equations… */ stress = Physics::computeStress(strain); stiff = Physics::applyGradTestAndIntegrate(stress); return stiff; }

slide-15
SLIDE 15

Modular design: a solution with template mixins

Building up elements…

QuadP1 QuadP2 TensorBasis Acoustic Elastic2D Elastic3D Cpl2Acoustic Cpl2Elastic Attenuation …

slide-16
SLIDE 16

Modular design: a solution with template mixins

ElementAdapter< Attenuation< Elastic2D< Quad< QuadP2>>>> AtnElasticQuadP1;

Adding attenuation to surface elements…. Building up elements…

QuadP1 QuadP2 TensorBasis Acoustic Elastic2D Elastic3D Cpl2Acoustic Cpl2Elastic Attenuation …

slide-17
SLIDE 17

Modular design: a solution with template mixins

Adding coupling to CMB….

ElementAdapter< CoupleToAcoustic< Elastic2D< Quad< QuadP1>>>> AtnElasticQuadP1;

Building up elements…

QuadP1 QuadP2 TensorBasis Acoustic Elastic2D Elastic3D Cpl2Acoustic Cpl2Elastic Attenuation … ElementAdapter< Attenuation< Elastic2D< Quad< QuadP2>>>> AtnElasticQuadP1;

Adding attenuation to surface elements….

slide-18
SLIDE 18

Modular design: a solution with template mixins

// Get values from distributed array. mesh->pullElementalFields(); // Compute element integrals. for (auto &elm: elements) { // Get relevant values. u = mesh->getFields(elm->closure()); // Compute stiffness. ku = elm->computeStiffnessTerm(u); // Compute surface integral. s = elm->computeSurfaceIntegral(u); // Compute source term. f = elm->computeSourceTerm(time); // Compute acceleration. a = f - ku + s // Assemble. mesh->pushFields(elm->closure()); } // Push values to distributed array. mesh->pushElementalFields();

All in one element loop…

slide-19
SLIDE 19

Flexible spatial and temporal discretization

slide-20
SLIDE 20

Flexible spatial discretization: Builtin python- based meshing tools

Exploration scale (with topography) Planets (Mars, Europa, …) 2D applications

slide-21
SLIDE 21

Flexible spatial discretization: PETSc DMPLEX

An example with coupling Red: fluid Blue: solid

slide-22
SLIDE 22

An example with coupling

Flexible spatial discretization: PETSc DMPLEX

Red: fluid Blue: solid

slide-23
SLIDE 23

f1 (fluid) f2 (solid) (fluid) (solid)

v1 v2 v4 v3 v5 v6 e1 e2 e3 e4 e5 e6 e7 f1 f2

(fluid) (solid)

Flexible spatial discretization: PETSc DMPLEX

slide-24
SLIDE 24

v1 v2 v4 v3 v5 v6 e1 e2 e3 e4 e5 e6 e7 f1 f2

v1 v2 v3 v4 v5 v6 e1 e2 e3 e4 e5 e6 e7 f1 f2

f1 f2 (fluid) (solid)

v1 v2 v4 v3 v5 v6 e1 e2 e3 e4 e5 e6 e7 f1 f2

(fluid) (solid) f1 (fluid) f2 (solid)

Flexible spatial discretization: PETSc DMPLEX

slide-25
SLIDE 25

v1 v2 v4 v3 v5 v6 e1 e2 e3 e4 e5 e6 e7 f1 f2

v1 v2 v3 v4 v5 v6 e1 e2 e3 e4 e5 e6 e7 f1 f2

f1 f2 (fluid) (solid)

v1 v2 v4 v3 v5 v6 e1 e2 e3 e4 e5 e6 e7 f1 f2

(fluid) (solid) f1 (fluid) f2 (solid)

element_vector.push_back( ElasticCplAcousticQuadP1(options));

Flexible spatial discretization: PETSc DMPLEX

slide-26
SLIDE 26

Integration with external optimization routines (salvus_opt)

slide-27
SLIDE 27

27

Wavefield Compression

Time-domain full-waveform inversion requires massive storage capabilities to store the forward wavefield. Goal: Find a good tradeoff between memory requirements and computational

  • verhead by using customized compression methods.
slide-28
SLIDE 28

|

Line-Search with Inexact Gradients

28

contour lines of misfit functional minimum

mk

inexact gradient exact gradient (unknown)

slide-29
SLIDE 29

|

Line-Search with Inexact Gradients

29

contour lines of misfit functional minimum

mk

inexact gradient exact gradient (unknown)

slide-30
SLIDE 30

|

Line-Search with Inexact Gradients

30

contour lines of misfit functional minimum

mk

inexact gradient exact gradient (unknown)

slide-31
SLIDE 31

|

Line-Search with Inexact Gradients

31

contour lines of misfit functional minimum

mk

inexact gradient exact gradient (unknown)

Compression thresholds can be chosen adaptively based on

➢ the norm of the inexact gradient, ➢ the ratio of actual and predicted misfit reduction.

Convergence can be ensured if the relative error is smaller than 50%.

slide-32
SLIDE 32

Wavefield Compression

  • Substantial reduction of memory

requirements and I/O operations at negligible extra costs.

  • 200 TB per event
  • Using approximate gradients does not

significantly slow down the rate of convergence to solve the inverse problem.

  • The error in the inexact gradients can be

controlled such that the lossy compression does not significantly affect the inverted results.

32 p = p = 1 p = 2 p = 4

Prediction-correction on hierarchical grids

Requantization

Re-interpolation with sliding- window cubic splines

slide-33
SLIDE 33

First name Surname (edit via “Insert” > “Header & Footer”) 1.12.2014

f1 f2 f1 (fluid) f2 (solid)

Integration with optimization libraries

  • 1

1

w/o compression

−6 −12

depth [km]

(i) cf-544 (ii) cf-1043 (iii) cf-1708 (iv) cf-2100

5 10 15 20 −6 −12

length [km] depth [km]

(v) cf-2506

5 10 15 20

length [km]

(vi) cf-3277

5 10 15 20

length [km]

(vii) cf-4714

5 10 15 20

length [km]

  • Consistent discrete adjoint equation
  • Built-in interface to wavefield compression to reduce memory requirements
  • Extensions for Hessian-vector products (currently under development)
slide-34
SLIDE 34

Comprehensive testing suite

slide-35
SLIDE 35

Comprehensive Test Suite

▪ Every contribution is run against a comprehensive test suite, driven by CatchTM ▪ Analytical integrations on element volumes, faces, edges ▪ Analytical time-dependent solutions ▪ Proper interpolation of sources/receivers ▪ Eases collaboration from the level of student to domain specialist

slide-36
SLIDE 36

First name Surname (edit via “Insert” > “Header & Footer”) 1.12.2014

Comprehensive Test Suite

Testing integration with optimization libraries

slide-37
SLIDE 37

Speed

slide-38
SLIDE 38

Speed

ElementAdapter<Attenuation<Elastic2D<Quad<QuadP1>>>> AtnElasticQuadP1;

Templates resolved at compile time SPECFEM3D CARTESIAN SALVUS Stiffness Calculation (microseconds) 1.7 15

slide-39
SLIDE 39

Speed

ElementAdapter<Attenuation<Elastic2D<Quad<QuadP1>>>> AtnElasticQuadP1;

Templates resolved at compile time SPECFEM3D CARTESIAN SALVUS (precomputed Jacobian) Stiffness Calculation (microseconds) 1.7 5

slide-40
SLIDE 40

Speed

ElementAdapter<Attenuation<Elastic2D<Quad<QuadP1>>>> AtnElasticQuadP1;

Templates resolved at compile time SPECFEM3D CARTESIAN SALVUS (Deville

  • ptimized

strides) Stiffness Calculation (microseconds) 1.7 2.2

slide-41
SLIDE 41

Speed

ElementAdapter<Attenuation<Elastic2D<Quad<QuadP1>>>> AtnElasticQuadP1;

Templates resolved at compile time SPECFEM3D CARTESIAN SALVUS (Deville

  • ptimized

strides) Stiffness Calculation (microseconds) 1.7 2.2 Haven’t really tried yet…

slide-42
SLIDE 42

Applications

slide-43
SLIDE 43

Applications

slide-44
SLIDE 44

Applications

slide-45
SLIDE 45

Applications

slide-46
SLIDE 46

Outlook

slide-47
SLIDE 47

Accelerators?

#include <stdio.h> #include <iostream> #include <cuda.h> class QuadP1 { public: __device__ __host__ void jacobian() { printf("%s\n", "Computing QuadP1 Jacobian."); }; }; class TriangleP1 { public: __device __host__ void jacobian() { printf("%s\n", "Computing TriangeP1 Jacobian."); }; }; template <typename ConcreteElement> class Quad: public ConcreteElement { public: __device__ __host__ void gradient() { printf("%s\n", "Computing quad gradient."); ConcreteElement::jacobian(); }; }; template <typename ConcreteElement> class Tri: public ConcreteElement public: __device__ __host__ void gradient() { printf("%s\n", "Computing triangle gradient."); ConcreteElement::jacobian(); }; };

slide-48
SLIDE 48

Accelerators?

#include <stdio.h> #include <iostream> #include <cuda.h> class QuadP1 { public: __device__ __host__ void jacobian() { printf("%s\n", "Computing QuadP1 Jacobian."); }; }; class TriangleP1 { public: __device __host__ void jacobian() { printf("%s\n", "Computing TriangeP1 Jacobian."); }; }; template <typename ConcreteElement> class Quad: public ConcreteElement { public: __device__ __host__ void gradient() { printf("%s\n", "Computing quad gradient."); ConcreteElement::jacobian(); }; }; template <typename ConcreteElement> class Tri: public ConcreteElement public: __device__ __host__ void gradient() { printf("%s\n", "Computing triangle gradient."); ConcreteElement::jacobian(); }; }; // Get values from distributed array. mesh->pullElementalFields(); // Compute element integrals. for (auto &elm: elements) { // Get relevant values. u = mesh->getFields(elm->closure()); // Compute stiffness. ku = elm->computeStiffnessTerm(u); // Compute surface integral. s = elm->computeSurfaceIntegral(u); // Compute source term. f = elm->computeSourceTerm(time); // Compute acceleration. a = f - ku + s // Assemble. mesh->pushFields(elm->closure()); } // Push values to distributed array. mesh->pushElementalFields();

Graphics cards? Knights Landing?

slide-49
SLIDE 49

Outlook

▪ Frequency domain (billions of dofs…) ▪ Bridge the gap between research and production codes ▪ Nonconforming meshes ▪ Applications of FWI to new and interesting domains ▪ Additional physics (GPR, electromagnetic, …)

slide-50
SLIDE 50

Very warm thanks to:

▪ Kuangdai Leng (University of Oxford) ▪ Dan Chown (Achates power) ▪ Matt Knepley (Rice university) ▪ Tarje Nissen-Meyer (University of Oxford)

slide-51
SLIDE 51

Features and Methods

  • trust-region and line search methods
  • reusing pre-computed information whenever possible
  • > interpolation instead of backtracking
  • > book-keeping of Earth models
  • built-in regularization and smoothing
  • constraint handling using projection methods and

homogenization

  • > constraints on m are cheap, “feasible-point methods”
  • handling of inexact derivatives and change of objective

function

51

slide-52
SLIDE 52

Speed: Scaling

Maintain the scaling characteristics of PETSc Parallelization via PETSc is essentially free

slide-53
SLIDE 53

53

Wavefield Compression

slide-54
SLIDE 54

|

Line-Search with Inexact Gradients

54

contour lines of misfit functional minimum BFGS update with exact information

mk

slide-55
SLIDE 55

|

Line-Search with Inexact Gradients

55

contour lines of misfit functional minimum BFGS update with inexact information BFGS update with exact information

mk

slide-56
SLIDE 56

|

mk

Line-Search with Inexact Gradients

56

contour lines of misfit functional minimum BFGS update with inexact information BFGS update with exact information

Classical workaround for Newton-type methods:

slide-57
SLIDE 57

Coupling to other physics…

#include <Model/ExodusModel.h> #include <Physics/AcousticElastic2D.h> #include <Utilities/Options.h> #include <Mesh/Mesh.h> using namespace Eigen; template <typename BasePhysics> std::vector<std::string> AcousticToElastic2D<BasePhysics>::PullElementalFields() const { return {"ux", "uy", "v"}; } template <typename BasePhysics> void AcousticToElastic2D<BasePhysics>::setBoundaryConditions(Mesh *mesh) { for (auto e: mesh->CouplingFields(BasePhysics::ElmNum())) { mEdg.push_back(std::get<0>(e)); mNbr.push_back(mesh->GetNeighbouringElement(mEdg.back(), BasePhysics::ElmNum())); mNbrCtr.push_back(mesh->getElementCoordinateClosure(mNbr.back()).colwise().mean()); } BasePhysics::setBoundaryConditions(mesh); } template <typename BasePhysics> Eigen::MatrixXd AcousticToElastic2D<BasePhysics>::computeSurfaceIntegral(const Eigen::Ref<const Eigen::MatrixXd> &u) { // col0->ux, col1->uy, col2->potential. Eigen::MatrixXd rval = Eigen::MatrixXd::Zero(BasePhysics::NumIntPnt(), 2); for (int i = 0; i < mEdg.size(); i++) { rval.col(0) += mRho_0[i] * BasePhysics::applyTestAndIntegrateEdge(u.col(2), mEdg[i]); rval.col(1) += mRho_0[i] * BasePhysics::applyTestAndIntegrateEdge(u.col(2), mEdg[i]); } return -1 * rval; }

slide-58
SLIDE 58

Modular design: a solution with template mixins

template <typename Element> MatrixXd Elastic2D<Element>::computeStress(const Eigen::Ref<const Eigen::MatrixXd> &strain) { mc11 = Element::ParAtIntPts("C11"); mc12 = Element::ParAtIntPts("C12"); mc22 = Element::ParAtIntPts("C22"); mc33 = Element::ParAtIntPts("C33"); Matrix<double,Dynamic,3> stress(Element::NumIntPnt(), 3); VectorXd uxy_plus_uyx = strain.col(1) + strain.col(2); stress.col(0) = mc11 * strain.col(0) + mc12 * strain.col(3) + mc13 * uxy_plus_uyx); stress.col(1) = mc12 * strain.col(0) + mc22 * strain.col(3) + mc23 * uxy_plus_uyx); stress.col(2) = mc13 * strain.col(0) + mc23 * strain.col(3) + mc33 * uxy_plus_uyx); return stress; }