SPINS User Guide: Difference between revisions

From Fluids Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 2: Line 2:


== Getting SPINS and compiling ==
== Getting SPINS and compiling ==
(Chris: Can we put it on GitHub or make a new repo?)
(Chris: Is it a good idea to put it on GitHub?)


SPINS consists of a bunch of C++ source files and a bunch of case files, and it requires four libraries. UMFPack, AMD and Blitz++ are supplied with SPINS, and it uses the system-installed FFTW.
SPINS consists of a bunch of C++ source files and a bunch of case files, and it requires four libraries. UMFPack, AMD and Blitz++ are supplied with SPINS, and it uses the system-installed FFTW.
Line 8: Line 8:
Directory structure:
Directory structure:
* cpp/src - SPINS source files
* cpp/src - SPINS source files
* cpp/src/cases - a few dozen example case files
* cpp/src/cases - A few dozen example case files
* cpp/AMD - AMD library
* cpp/AMD - AMD library
* cpp/UMFPack - UMFPack library
* cpp/UMFPack - UMFPack library
* cpp/UFconfig - Helper for compiling AMD/UMFPack
* cpp/UFconfig - Helper for compiling AMD/UMFPack


To compile, first ....
To compile, <span style="color:#FF0000"> ToDo: write this! </span>.


== The basics ==
== The basics ==
Line 21: Line 21:


== Examples of common operations ==
== Examples of common operations ==
You can find examples of how to do various operations by digging through the case files, Some of the common operations are reproduced here.


=== Outputting the grid ===
=== Outputting the grid ===
At the top of your file include the global tensor indices:
At the top of your file include the global tensor indices:
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
Line 66: Line 66:


=== Initialising velocities ===
=== Initialising velocities ===
ToDo: More here!!
<span style="color:#FF0000"> To Do: write this! </span>
 
=== Initialising tracers ===
<span style="color:#FF0000"> To Do: write this! </span>
 
=== Forcing ===
<span style="color:#FF0000"> To Do: write this! </span>
 
=== Analysis: saving snapshots ===
<span style="color:#FF0000"> To Do: write this! </span>

Revision as of 11:05, 12 July 2012

Welcome to the SPINS case setup page.

Getting SPINS and compiling

(Chris: Is it a good idea to put it on GitHub?)

SPINS consists of a bunch of C++ source files and a bunch of case files, and it requires four libraries. UMFPack, AMD and Blitz++ are supplied with SPINS, and it uses the system-installed FFTW.

Directory structure:

  • cpp/src - SPINS source files
  • cpp/src/cases - A few dozen example case files
  • cpp/AMD - AMD library
  • cpp/UMFPack - UMFPack library
  • cpp/UFconfig - Helper for compiling AMD/UMFPack

To compile, ToDo: write this! .

The basics

The SPINS model is a Navier-Stokes solver that gets parameters and initial/boundary conditions from calls to user-provided routines. The user-provided routines are encapsulated in the class BaseCase (see BaseCase.hpp).

Creating your own custom configuration involves building a derived class based on BaseCase. The case file cases/doc_minimal.cpp shows the structure of a case file. It makes sense to start with another similar case file and customise it.

Examples of common operations

You can find examples of how to do various operations by digging through the case files, Some of the common operations are reproduced here.

Outputting the grid

At the top of your file include the global tensor indices:

// Tensor variables for indexing
blitz::firstIndex ii;
blitz::secondIndex jj;
blitz::thirdIndex kk;

Create array tmp and generate the grid, then write the array and the grid reader out:

tmp = xx(ii) + 0*jj + 0*kk;
write_array(tmp,"xgrid");
write_reader(tmp,"xgrid",false);

tmp = 0*ii + yy(jj) + 0*kk;
write_array(tmp,"ygrid");
write_reader(tmp,"ygrid",false);

tmp = 0*ii + 0*jj + zz(kk);
write_array(tmp,"zgrid");
write_reader(tmp,"zgrid",false);

Energy diagnostic

If you're on a periodic grid, use this for kinetic energy diagnostic

double ke = 0.5*rho_0*pssum(sum(u*u+v*v+w*w))/(Nx*Ny*Nz)*Lx*Ly*Lz; // KE
if (master()) {
  FILE * en_record = fopen("energy_record.txt","a");
  assert(en_record);
  fprintf(en_record,"%.8f %.14g\n",time,ke);
  fclose(en_record);
}

and if you're on a mapped chebyshev grid, you can use this for the KE computation

double ke = pssum(sum((*get_quad_x())(ii)*(*get_quad_y())(jj)*(*get_quad_z())(kk)*
                  (pow(u(ii,jj,kk),2)+pow(v(ii,jj,kk),2)+pow(w(ii,jj,kk),2))));

Initialising velocities

To Do: write this!

Initialising tracers

To Do: write this!

Forcing

To Do: write this!

Analysis: saving snapshots

To Do: write this!