home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power Programming
/
powerprogramming1994.iso
/
progtool
/
microcrn
/
issue_40.arc
/
DAIMS.ARC
/
OCEAN.CPP
< prev
next >
Wrap
Text File
|
1988-02-10
|
4KB
|
156 lines
#include <math.h>
#include "viscosity.h"
#include "matrix.hxx"
#include "vimatrix.hxx"
#include "Cheb_vector.hxx"
#include "ekman.hxx"
#include "ocpanel.hxx"
#include "ocean.hxx"
/*
-*++ ocean_layer::ocean_layer():
**
** (*++ history:
** 16 Jan 88 Bruce Eckel Creation date
** ++*)
**
** (*++ detailed:
** ++*)
*/
ocean_layer::ocean_layer(int initial_modes, double initial_lambda) :
Qnew(initial_modes), Qold(initial_modes), h(initial_modes),
A(initial_modes, initial_lambda)
{
ocean_lambda = initial_lambda;
dt = ocean_lambda/500;
nstep = 0;
time = 0;
ocean_nmodes = initial_modes;
A = A.inverse();
ocean_xldomain = -1.0;
ocean_xrdomain = 1.0;
ocean_viscosity_value = 0;
ocean_viscosity_type = NONE;
running = 0;
}
/*
-*++ ocean_layer::step(): step the model forward by one time increment
**
** (*++ history:
** 16 Jan 88 Bruce & Creation date
** ++*)
**
** (*++ detailed:
** ++*)
*/
#define NL "\n"
void ocean_layer::step(ekman_layer & ekman)
{
if (!running) return;
#if 0
if (ocean_nmodes != ekman.resolution()) {
ocean_nmodes = ekman.resolution();
nstep = 0;
time = 0;
A = vi_matrix(ocean_nmodes,ocean_lambda);
A = A.inverse();
Qold = Cheb_vector (ocean_nmodes);
Qnew = Cheb_vector (ocean_nmodes);
h = Cheb_vector (ocean_nmodes);
}
#endif
#if 0
cout << "\nnstep = " << nstep << NL;
cout.flush();
cout << "h = " << h << NL;
cout.flush();
cout << "h.prime = " << h.prime() << NL;
cout.flush();
cout << "ekman.pumping_vector() = " << ekman.pumping_vector() << NL;
cout.flush();
cout << "Qold = " << Qold << NL;
cout.flush();
#endif
/* if (!nstep++) {
Qnew = Qold + (ekman.pumping_vector() - h.prime()) * dt;
}
else
Qnew = Qold + ( (ekman.pumping_vector() - h.prime())) * (2 * dt);
*/
Qnew = Qold + (ekman.pumping_vector() - h.prime()) * dt;
Qnew[Qnew.size() -2] = 0;
Qnew[Qnew.size() -1] = 0;
// cout << "Qnew = " << Qnew << NL;
// cout.flush();
h = A * Qnew;
// cout << "h physical" << h.physical() << NL;
// cout.flush();
Qold = Qnew;
}
/*
-*++ ocean_layer::update(): get new values from the ocean panel
**
** (*++ history:
** 16 Jan 88 Bruce & Creation date
** ++*)
**
** (*++ detailed:
** ++*)
*/
void ocean_layer::update(ocpanel & ocean_panel, ekman_layer & ekman)
{
if (ocean_panel.nmodes() != ekman.resolution() || ocean_panel.changed()) {
ocean_lambda = ocean_panel.lambda();
ocean_nmodes = ekman.resolution();
dt = ocean_lambda/100;
A = vi_matrix(ocean_nmodes, ocean_lambda);
A = A.inverse();
Qnew = Cheb_vector(ocean_nmodes);
Qold = Cheb_vector(ocean_nmodes);
h = Cheb_vector(ocean_nmodes);
ocean_panel.reset(); /* so it doesn't show dirty flag */
}
running = ocean_panel.run();
if (ocean_panel.restart()) {
ocean_panel.clear_restart();
ocean_nmodes = ekman.resolution();
ocean_lambda = ocean_panel.lambda();
A = vi_matrix(ocean_nmodes, ocean_lambda);
A = A.inverse();
dt = ocean_lambda/100;
nstep = 0;
time = 0;
ocean_xldomain = -1.0;
ocean_xrdomain = 1.0;
ocean_viscosity_value = 0;
Qnew = Cheb_vector(ocean_nmodes);
Qold = Cheb_vector(ocean_nmodes);
h = Cheb_vector(ocean_nmodes);
}
}
/*
-*++ ocean_layer::diagnostics(): send results to ocpanel display
**
** (*++ history:
** 16 Jan 88 Bruce & Creation date
** ++*)
**
** (*++ detailed:
** ++*)
*/
void ocean_layer::diagnostics(ocpanel & ocean_panel)
{
ocean_panel.display(h.physical());
}