Los Alamos National Laboratory 1 Using POOMA Particles Classes Timothy J. Williams CIC-19, Los Alamos National Laboratory P ARALLEL O BJECT -O RIENTED.

Slides:



Advertisements
Similar presentations
The C ++ Language BY Shery khan. The C++ Language Bjarne Stroupstrup, the language’s creator C++ was designed to provide Simula’s facilities for program.
Advertisements

Object-Oriented programming in C++ Classes as units of encapsulation Information Hiding Inheritance polymorphism and dynamic dispatching Storage management.
Los Alamos National Laboratory 1 POOMA 2.1 Timothy J. Williams Advanced Computing Laboratory ACL Seminar LANL September 28, 1999.
Prepared 7/28/2011 by T. O’Neil for 3460:677, Fall 2011, The University of Akron.
Coordinatate systems are used to assign numeric values to locations with respect to a particular frame of reference commonly referred to as the origin.
An OpenDX-Driven Molecular Dynamics Visualization Solution L.N. Bui, J. Wright, and A.J. Pounds Departments of Chemistry and Computer Science Mercer University.
Chapter 11 Above: Principal contraction rates calculated from GPS velocities. Visualized using MATLAB.
6/10/2015C++ for Java Programmers1 Pointers and References Timothy Budd.
CSE351/ IT351 Modeling and Simulation
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 5 - Functions Outline 5.1Introduction 5.2Program.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Parallel Programming in C with MPI and OpenMP Michael J. Quinn.
Support for Adaptive Computations Applied to Simulation of Fluids in Biological Systems Immersed Boundary Method Simulation in Titanium.
Finite Difference Methods Or Computational Calculus.
Chapter 2 Sketching, Constraining & Dimensioning.
Optical flow (motion vector) computation Course: Computer Graphics and Image Processing Semester:Fall 2002 Presenter:Nilesh Ghubade
Differences between C# and C++ Dr. Catherine Stringfellow Dr. Stewart Carpenter.
LECTURE LECTURE 17 More on Templates 20 An abstract recipe for producing concrete code.
C++ C++ Overview (I) What is Object Orientated Programming? Approach: Break problem into subgroups of related parts that take into account code and data;
CSE 333 – SECTION 4. Overview Pointers vs. references Const Classes, constructors, new, delete, etc. More operator overloading.
L15: Putting it together: N-body (Ch. 6) October 30, 2012.
1 3-Software Design Basics in Embedded Systems. 2 Development Environment Development processor  The processor on which we write and debug our programs.
IIIT, Hyderabad Performance Primitives for Massive Multithreading P J Narayanan Centre for Visual Information Technology IIIT, Hyderabad.
Molecular Dynamics Sathish Vadhiyar Courtesy: Dr. David Walker, Cardiff University.
CDS 301 Fall, 2009 Vector Visualization Chap. 6 October 7, 2009 Jie Zhang Copyright ©
Chapter 3 Parallel Algorithm Design. Outline Task/channel model Task/channel model Algorithm design methodology Algorithm design methodology Case studies.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. C How To Program - 4th edition Deitels Class 05 University.
Molecular Dynamics Collection of [charged] atoms, with bonds – Newtonian mechanics – Relatively small #of atoms (100K – 10M) At each time-step – Calculate.
Section 17.2 Position, Velocity, and Acceleration.
Project 1 Due Date: September 25 th Quiz 4 is due September 28 th Quiz 5 is due October2th 1.
Case Study - Fractions Timothy Budd Oregon State University.
March 6, 2014CS410 – Software Engineering Lecture #10: C++ Basics IV 1 Structure Pointer Operator For accessing members in structures and classes we have.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M
Organizing Heterogeneous Data Arrays allow a programmer to organize lists of values that are all of the same type (homogeneous). But we are often faced.
Hank Childs, University of Oregon Lecture #3 Fields, Meshes, and Interpolation (Part 2)
CPS4200 Unix Systems Programming Chapter 2. Programs, Processes and Threads A program is a prepared sequence of instructions to accomplish a defined task.
Lesson 4: Computer method overview
Chapter 4 Introduction to Classes, Objects, Methods and strings
Vector Field Visualization
I/O for Structured-Grid AMR Phil Colella Lawrence Berkeley National Laboratory Coordinating PI, APDEC CET.
Charm++ Data-driven Objects L. V. Kale. Parallel Programming Decomposition – what to do in parallel Mapping: –Which processor does each task Scheduling.
Data Visualization Fall 2015.
Static. 2 Objectives Introduce static keyword –examine syntax –describe common uses.
Discretization Methods Chapter 2. Training Manual May 15, 2001 Inventory # Discretization Methods Topics Equations and The Goal Brief overview.
Charm++ overview L. V. Kale. Parallel Programming Decomposition – what to do in parallel –Tasks (loop iterations, functions,.. ) that can be done in parallel.
CMSC 345 Fall 2000 OO Design. Characteristics of OOD Objects are abstractions of real-world or system entities and manage themselves Objects are independent.
Smoothed Particle Hydrodynamics Matthew Zhu CSCI 5551 — Fall 2015.
Prof. amr Goneid, AUC1 CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 15. Dictionaries (1): A Key Table Class.
1 Molecular Simulations Macroscopic EOS (vdW, PR) Little molecular detail Empirical parameters (  ) Seeking understanding of complex systems Surfactants.
Object Oriented Programming. OOP  The fundamental idea behind object-oriented programming is:  The real world consists of objects. Computer programs.
DATA STRUCTURE & ALGORITHMS CHAPTER 2: LINKED LIST.
Add Cool Visualizations Here Sandia National Laboratories is a multi-program laboratory managed and operated by Sandia Corporation, a wholly owned subsidiary.
Chapter 17 – Templates. Function Templates u Express general form for a function u Example: template for adding two numbers Lesson 17.1 template Type.
Chapter 16 Templates Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
1 Berger Jean-Baptiste
Coordinatate systems are used to assign numeric values to locations with respect to a particular frame of reference commonly referred to as the origin.
1 CW11 Visualizing ACE3P Results in ParaView Greg Schussman Menlo Park, CA October 10, 2011.
C++ REVIEW – TEMPLATES. GENERIC PROGRAMMING Programming/developing algorithms with the abstraction of types Algorithms/data is expressed “without type”
Particle Animation and Rendering Using Data Parallel Computation Karl Sims Optomystic Thinking Machines Corporation Presentation ©2001 Brenden Schubert.
The Basics: HTML5, Drawing, and Source Code Organization
Chapter 3: Using Methods, Classes, and Objects
Lecture 19 MA471 Fall 2003.
Chapter 5 - Functions Outline 5.1 Introduction
Component Frameworks:
GIS and SMS in Numerical Modeling of Open Channel Flow
The Building Blocks Classes: Java class library, over 1,800 classes:
Sathish Vadhiyar Courtesy: Dr. David Walker, Cardiff University
Find the velocity of a particle with the given position function
Parallel Programming in C with MPI and OpenMP
EECE.2160 ECE Application Programming
Presentation transcript:

Los Alamos National Laboratory 1 Using POOMA Particles Classes Timothy J. Williams CIC-19, Los Alamos National Laboratory P ARALLEL O BJECT -O RIENTED M ETHODS AND A PPLICATIONS Tecolote Class LANL August 25, 1998

Los Alamos National Laboratory 2 Outline l POOMA and particles l Particle attributes l Managing a set of particles l Particle layout, loading, & boundary conditions l Particle-mesh interaction l Particle load balancing l Particle-particle interaction l I/O and visualization l Example

Los Alamos National Laboratory 3 Other POOMA Particles Documentation l POOMA User Guide, especially Chapter 7  l Header files  $POOMA_ROOT/src/Particles/*.h l Test programs  $POOMA_ROOT/src/test/particle/*.h l External data connection (I/O, visualization, PAWS)  l These viewgraphs: 

Los Alamos National Laboratory 4 Applications Drive POOMA Particles Design l ER (HPCC Grand Challenge Applications)  Numerical Tokamak Turbulence Project (PIC)  Computational Accelerator Physics (PIC) l ASCI  MC++ (Monte Carlo neutron transport) l Additional projects leverage previous work l Additional projects drive improvements in POOMA

Los Alamos National Laboratory 5 Particle Attributes template class ParticleAttrib  Value of type T for every particle Scalar ( double,….) Vektor, Tenzor,...  Analogous to Field  Distributed object  Data parallel and single-particle operations Use expression templates

Los Alamos National Laboratory 6 Data-Parallel Math On ParticleAttrib l All particles ParticleAttrib mu, rho, w, speed, mass; ParticleAttrib > v; double scaleFactor; mu = 2.0*rho*w; mu *= scaleFactor; speed = sqrt(pow(v(0),2) + pow(v(1),2) + pow(v(2),2)); // note component access Reductions Vektor totMom = sum(mass*v); Conditionals rho = where((rho > 1.0e-8), rho, 0.0);

Los Alamos National Laboratory 7 Single-Particle Math On ParticleAttrib l When not to use data-parallel?  Many particle-dependent temporaries (  ParticleAttrib temporaries)  Complicated particle-dependent logic Single-particle indexing, using [int] for (int i=0; i<nLocalParticles; i++) { mu[i] = 2.0*rho[i]*w[i]; if (mu[i] < 1.0e-8) mu[i] = 0.0; }  SPMD

Los Alamos National Laboratory 8 Managing A Set Of Particles Abstract base class template class ParticleBase  Template parameter PLayout Must inherit from ParticleLayout base class Contains spatial dimensionality Manages processor ownership of particles l User derives custom particles class

Los Alamos National Laboratory 9 Key Members Of ParticleBase Two ParticleAttrib data members  R - position ( Vektor )  ID - global particle identifier ( int ) l Member functions  create(), globalCreate(), destroy() create and destroy particles  update() manage memory move particles between processors  getBConds() Get reference to ParticleBConds object Typedef s, such as ParticlePos_t

Los Alamos National Laboratory 10 Example Custom Particles Class: Tracers class Tracers : public ParticleBase > { public: // Attributes (besides R and ID) ParticleAttrib > v; // velocity //...other attributes would go here.... // constructor Particles(Layout_t *L) : ParticleBase (L) { addAttribute(v); // add attribute to base’s list // other addAttribute() calls.... } };

Los Alamos National Laboratory 11 Particle Layout Classes l Manage processor ownership of particles template class ParticleUniformLayout  Divide particles evenly among processors template class ParticleSpatialLayout  Spatial subdomains  PE owning subdomain owns all particles in it template class ParticleInteractLayout  Adds mechanisms for particle-particle interaction

Los Alamos National Laboratory 12 Particle Layout Classes (cont’d) Processor 0,1,2,3 ParticleUniformLayoutParticleSpatialLayout

Los Alamos National Laboratory 13 ParticleSpatialLayout Construction unsigned Dim = 3; typedef UniformCartesian M; int nVertices[Dim]; // Must initialize (not shown)! NDIndex allVerts; for (int d=0; d<Dim; d++) allVerts[d] = Index(nVertices[d]); Vektor origin, meshSpacings; //initialize! M mesh(allVerts, origin, meshSpacings); CenteredFieldLayout fl(mesh); ParticleSpatialLayout psl(fl, mesh);

Los Alamos National Laboratory 14 Particle Boundary Conditions ParticleBconds class  What happens to particles that cross global boundaries  Contains container of function pointers typedef T (*ParticleBCond)(const T, const T, const T); ParticleBCond BCList[2*Dim]; Act on single particle position in one direction  Invoked on all particles by update() l POOMA provides canned functions l User may supply custom functions

Los Alamos National Laboratory 15 POOMA-Provided Particle Boundary Conditions l Periodic BC template T ParticlePeriodicBCond(const T t, const T minval, const T maxval) l Reflecting: particles bounce back at boundary: T ParticleReflectiveBCond(...same args... ) l Particles stick to face T ParticleSinkBCond(...same args... ) l Null (default for all boundaries) T ParticleNoBCond(...same args... )

Los Alamos National Laboratory 16 Particle Boundary Conditions Example typedef UniformCartesian M; M mesh(....); CenteredFieldLayout fl(mesh); typedef ParticleSpatialLayout PL; PL pl(fl, mesh); Tracers tracers(&pl); tracers.getBConds()[0] = ParticlePeriodicBCond; tracers.getBConds()[1] = ParticlePeriodicBCond; tracers.getBConds()[2] = ParticleReflectiveBCond; tracers.getBConds()[3] = ParticleReflectiveBCond;

Los Alamos National Laboratory 17 Particle Loading 1 Construct user particles object (e.g. Tracer instance) 2 Create particles  create(npLocal) - SPMD PE-local creation  globalCreate(npTot) - divides npTot /#PEs 3 Assign initial values to ParticleAttrib s  read input  data-parallel/single-particle expressions 4 Tracer::update()  set up proper processor ownership  consults PLayout

Los Alamos National Laboratory 18 Particle-Mesh Interaction Interpolator base class  Maps continuous position  mesh position Derived classes provide scatter(), gather()  Single particle  mesh neighborhood  POOMA implements IntNGP, IntCIC, IntSUDS  Other interp. formulas: user-defined class ParticleAttrib functions apply to all particles template void ParticleAttrib ::scatter (Field &, const ParticleAttrib >&, const IntOp&) const;

Los Alamos National Laboratory 19 Particle-Mesh Interaction (cont’d) POOMA interpolators IntNGP, IntCIC, IntSUDS  gather() Interpolate from mesh points to single particle position R[i] Assign value to pa[i]  scatter() Interpolate from single particle position to mesh nodes/cells/.... Accumulate value to field at node/cell-position  Really scatter-add

Los Alamos National Laboratory 20 POOMA IntNGP Interpolator [i][j] pa[k]=(1-dx)*(1-dy)*f[i][j] + dx*(1-dy)*f[i+1][j] (1-dx)*dy*f[i][j+1] + dx*dy*f[i+1][j+1] [i+1][j] d [i][j+1][i+1][j+1] Particle k ParticleAttrib pa Field f Distance d = dx x + dy y

Los Alamos National Laboratory 21 Particle-Mesh- SIndex Interaction l Sparse index gather/scatter Field f(...), g(...), h(...); ParticleAttrib pa(...); SIndex S; S = where(gt(f, 1.0e-6)); pa[S] = g[S] + h[S]; f[S] = pa[S]*g[S];

Los Alamos National Laboratory 22 Particle Load Balancing l Redistribute particles evenly among processors l Function changes layout and all object using it template void BinaryRepartition (ParticleBase >& PB) Processor 0,1,2,3

Los Alamos National Laboratory 23 Particle-Particle Interaction l Pair-list iterator over neighbor particles  Member of ParticleLayout class  Exposed for use by ParticleBase class ParticleInteractLayout::pair_iterator  All other particles within fixed radius of particle ParticleInteractLayout ::setInteractionRadius (radius); l Uses ghost particles

Los Alamos National Laboratory 24 Particle-Particle Interaction Example class Molecules: ParticleBase ; Molecules m(...); m.getLayout().setInteractionRadius(4.0); m::pair_iterator neighbor, neighborEnd; for (int i=0; i < m.getLocalNum(); ++i) { m.getPairList(i, neighbor, neighborEnd); for ( ; neighbor != neighborEnd; ++neighbor) { Molecules::pair_t pairdata = *neighbor; int n = pairdata.first; // Particle index of neighbor double sep2 = pairdata.second; // (Nbr distance)^2 m.R[i] += m.vel[n] * 2.0; // Interact }

Los Alamos National Laboratory 25 I/O Parallel File I/O: DiscParticle class  One file set foo.{meta,data,config} per SMP  Analogous to DiscField  Write/read single ParticleAttribs or entire ParticleBase objects class Atoms: ParticleBase >; Atoms a(...); DiscParticle dp(“a”,”a.config”,INPUT,”Atoms a”); dp.read(a);  External data connection ( DataConnect ) approach also works

Los Alamos National Laboratory 26 Visualization l External data connection to ACLVIS ACLVIS tool visualizes ParticleAttrib (in ParticleBase ) data several ways:  Points, colored by scalar attribute value  Spheres, colored by scalar attribute value Keep N timesteps and display as trace path  Vector arrows (for ParticleAttrib > ) Arrow length = vector magnitude Keep N timesteps and display as trace path

Los Alamos National Laboratory 27 Example: Tracer Particles (1/8) #include "Pooma.h" #include "Particle/IntNGP.h" // // Custom particles class Tracers template class Tracers : public ParticleBase { public: PL::ParticlePos_t v; // tracer particle velocity ParticleAttrib s; // tracer particle speed double mass; // tracer particle mass (const) Tracers(PL* pl, double m) : ParticleBase (pl), mass(m) { addAttribute(v); // register the particle attributes.... addAttribute(s); // register the particle attributes.... } }; //

Los Alamos National Laboratory 28 Example: Tracer Particles (2/8) int main(int argc, char *argv[]){ Pooma pooma(argc, argv); Inform pout(NULL,0); const unsigned Dim = 3; // dimension of positions const int nx=32, ny=32, nz=32; // grid sizes (cells) const unsigned int totalP = 5000; // number of particles const int nt = 100; // # of trace-timesteps const double dt = 0.1; // tracer timestep const double mass = 0.1; // tracer particle mass const double pi = acos(-1.0);

Los Alamos National Laboratory 29 Example: Tracer Particles (3/8) // Create mesh and FieldLayout objects Index I1(nx+1), J1(ny+1), K1(nz+1); typedef UniformCartesian M; M mesh(I1,J1,K1); CenteredFieldLayout layout(mesh); // Velocity Field u(x,y,z). Define as a cylindrical vortex // parallel to z, center in x-y, finite radius R0=8.0, // speed = ((x,y) - (x0,y0))/R0 Field,Dim,M,Cell> u(mesh,layout); u = 0.0; double R0 = 8.0; Vektor c; c[0] = nx/2-1; c[1] = ny/2-1; c[2] = nz/2-1; // Get Field of cell-center positions: Field,Dim,M,Cell> x(mesh,layout); x = mesh.getCellPositionField(x);

Los Alamos National Laboratory 30 Example: Tracer Particles (4/8) // Do the trig and assign u: Field r(mesh,layout); Field theta(mesh,layout); NDIndex cells; cells[0] = Index(nx); cells[1] = Index(ny); cells[2] = Index(nz); r[cells] = sqrt((x[cells](0) - c[0])*(x[cells](0) - c[0]) + (x[cells](1) - c[1])*(x[cells](1) - c[1])); theta[cells] = acos((x[cells](0) - c[0])/r[cells]); theta[cells] = where(lt((x[cells](1) - c[1]),0.0), 2.0*pi - theta[cells], theta[cells]); assign(u[cells](0), where(le(r[cells], R0), (r[cells]/R0)*sin(pi - theta[cells]), 0.0)); assign(u[cells](1), where(le(r[cells], R0), (r[cells]/R0)*cos(pi - theta[cells]), 0.0));

Los Alamos National Laboratory 31 Example: Tracer Particles (5/8) // Create nearest-grid-point interpolater object IntNGP interp; // Create an empty Tracers object, set up reflecting BC's typedef ParticleSpatialLayout PSL; PSL pLayout(layout); Tracers t(&pLayout, mass); // 2*Dim faces to set boundary conditions on: for (int face=0; face < 2*Dim; face++) { t.getBConds()[face] = ParticleReflectiveBCond; }

Los Alamos National Laboratory 32 Example: Tracer Particles (6/8) // Initialize the particle object (create particles): t.globalCreate(totalP); // Random initial positions, uniform in box: assign(t.R(0), PoomaRandom * nx); assign(t.R(1), PoomaRandom * ny); assign(t.R(2), PoomaRandom * nz); // Redistribute particles based on spatial layout t.update();

Los Alamos National Laboratory 33 Example: Tracer Particles (7/8) // Establish data connection (for ACLVIS) DataConnect *dc = DataConnectCreator::create("tracers"); dc->connect("t", t); dc->connect("R", t.R); dc->connect("s", t.s); dc->connect("v", t.v); dc->connect("u", u); // Update external connections, set interaction breakpoint dc->updateConnections(); dc->interact();

Los Alamos National Laboratory 34 Example: Tracer Particles (8/8) // Begin main timestep loop for (int it=0; it<nt; it++) { // Gather velocity from flow Field to particles: t.v.gather(u, t.R, interp); t.s = sqrt(dot(t.v, t.v)); // compute speed // Push the particles t.R += t.v*dt; // Redistribute particles based on spatial layout t.update(); pout << "Finished iteration " << it << endl; dc->updateConnections(); dc->interact(); } delete dc; return 0; }

Los Alamos National Laboratory 35 Example: Tracer Particles (ACLVIS Image 1)

Los Alamos National Laboratory 36 Example: Tracer Particles (ACLVIS Image 2)