#include </usr1/tp517/Tumble/trunk/src/tumble/simulation.h>
Collaboration diagram for Simulation:
Public Member Functions | |
Simulation (char *filename) | |
Create a Simulation, initialized with the given file. | |
Simulation () | |
Create an empty Simulation. | |
BezierMesh * | get_bezier_mesh () |
Get handle to the BezierMesh. | |
BoundaryMesh * | get_boundary_mesh () |
Get handle to the BoundaryMesh. | |
DataStore * | get_data_store () |
Get handle to the DataStore. | |
void | move_ (double time_step, unsigned vx_pos, unsigned vy_pos, unsigned newx_pos, unsigned newy_pos) |
Move mesh using a linear approximation to displacement. | |
void | move_ (double time_step, unsigned vx1_pos, unsigned vy1_pos, unsigned vx0_pos, unsigned vy0_pos, unsigned newx_pos, unsigned newy_pos) |
Move the mesh using a quadratic approximation to displacement. | |
void | move_ (double time_step, unsigned vx_pos, unsigned newx_pos) |
Linear movement wrapper. | |
void | move_ (double time_step, unsigned vx1_pos, unsigned vx0_pos, unsigned newx_pos) |
Quadratic movement wrapper. | |
void | set_positions (unsigned xPosI, unsigned yPosI) |
void | move (double time_step, unsigned vx_pos, unsigned vy_pos) |
void | move (double time_step, unsigned vx1_pos, unsigned vy1_pos, unsigned vx0_pos, unsigned vy0_pos) |
void | move (double time_step, unsigned vx_pos) |
double | move_safe (double time_step, unsigned vx_pos, unsigned vy_pos) |
double | move_safe (double time_step, unsigned vx1_pos, unsigned vy1_pos, unsigned vx0_pos, unsigned vy0_pos) |
double | move_safe (double time_step, unsigned vx_pos) |
void | store_state (unsigned vIndexFrom, unsigned vIndexTo, unsigned xIndexTo) |
void | restore_state (unsigned vIndexFrom, unsigned vIndexTo, unsigned xIndexFrom) |
int | read_from_text_file (char *filename) |
Reads in a mesh from a text file quartet. | |
int | read_from_binary_file (char *filename) |
Reads in a mesh from a binary file. | |
int | to_text_file (char *filename) |
Writes out the current state of the meshes to a text file quartet. | |
int | to_binary_file (char *filename) |
Writes out the current state of the meshes to a binary file. | |
int | to_eps (char *epsfile) |
Write out an eps image of the mesh. | |
void | print () |
Print info. | |
void | print_statistics () |
Print statistical data. | |
Public Attributes | |
unsigned | XposIndex |
unsigned | YposIndex |
bool | positions_set |
Private Member Functions | |
Simulation (const Simulation &o) | |
const Simulation & | operator= (const Simulation &o) |
void | initialize_structures () |
Initializes pointers in the Meshs. | |
const LinearData & | get_data (const ControlPoint &) const |
Get the data from the store. | |
Private Attributes | |
PersistantStore * | persistant_store |
DataStore * | data_store |
The Storage Location for the geometric and functional data used by both meshes. | |
BoundaryMesh * | bdry_mesh |
The BoundaryMesh, holding all the Boundary cells for this Simulation. | |
BezierMesh * | bezier_mesh |
The BezierMesh, holding all the Bezier cells for this Simulation. |
A Simulation is really the smallest self-contained portion of TUMBLE.
It contains a BezierMesh, a BoundaryMesh, and a DataStore. Together with the methods in Simulation, one has all the essential tools to experiment with a TUMBLE mesh.
The Simulation is self contained, creating and holding a Simulation provieds you with a method to access all the data contained in the mesh. When writing an application, the first thing an experimenter normally does is to create a Simulation and grab pointers to its BoundaryMesh and BezierMesh.
The meshes in a Simulation are initially empty, one has to add in the elements of the meshes. There are two ways of generating the elements in a bezier/boundary mesh pair. You can use one of the read methods provided in Simulation to read a mesh from a file (text and binary formats are supported). Alternatly, you can (carefully) build a mesh by hand, first filling out the BoundaryMesh, then adding the Bezier cells. The MeshConstructor class exists for this purpose. It has many usefull methods to aid in building a new mesh. See that class for more details.
One of the other important methods used in Simulation is move() method. This needs access to both the BezierMesh and the BoundaryMesh and hence is housed here, where the two classes meet.
Definition at line 40 of file simulation.h.
Simulation::Simulation | ( | const Simulation & | o | ) | [private] |
Simulation::Simulation | ( | char * | filename | ) |
Create a Simulation, initialized with the given file.
This creates an empty simulation and then loads the meshes from a file. The type of file is determined by the extension. If the file ends in ".geo", then it is assumed to be a binary file. Otherwise it is assumed to be the basename of a text file quartet.
filename | The file to read in the mesh from |
Definition at line 52 of file simulation.C.
References initialize_structures(), read_from_binary_file(), and read_from_text_file().
Here is the call graph for this function:
Simulation::Simulation | ( | ) |
Create an empty Simulation.
Definition at line 39 of file simulation.C.
References initialize_structures().
Here is the call graph for this function:
const Simulation& Simulation::operator= | ( | const Simulation & | o | ) | [private] |
void Simulation::initialize_structures | ( | ) | [private] |
Initializes pointers in the Meshs.
This function sets the pointers in the meshes, which gives them access to each other and to the DataStore.
Definition at line 68 of file simulation.C.
References bdry_mesh, bezier_mesh, data_store, persistant_store, positions_set, BezierMesh::set_bdry_mesh(), and BoundaryMesh::set_bezier_mesh().
Referenced by Simulation().
Here is the call graph for this function:
const LinearData & Simulation::get_data | ( | const ControlPoint & | ) | const [private] |
Get the data from the store.
Definition at line 142 of file simulation.C.
References data_store, and DataStore::get_data().
Referenced by move_().
Here is the call graph for this function:
BezierMesh * Simulation::get_bezier_mesh | ( | ) |
Get handle to the BezierMesh.
Definition at line 80 of file simulation.C.
References bezier_mesh.
Referenced by main(), MeshBinaryInput::MeshBinaryInput(), MeshBinaryOutput::MeshBinaryOutput(), and Visualization::Visualization().
BoundaryMesh * Simulation::get_boundary_mesh | ( | ) |
Get handle to the BoundaryMesh.
Definition at line 86 of file simulation.C.
References bdry_mesh.
Referenced by main(), MeshBinaryInput::MeshBinaryInput(), MeshBinaryOutput::MeshBinaryOutput(), and Visualization::Visualization().
DataStore * Simulation::get_data_store | ( | ) |
void Simulation::move_ | ( | double | dt, | |
unsigned | vxCoord, | |||
unsigned | vyCoord, | |||
unsigned | xCoord, | |||
unsigned | yCoord | |||
) |
Move mesh using a linear approximation to displacement.
This is a wrapper for the quadratic movement function, Simualtion::move_(double, unsigned, unsigned, unsigned, unsigned).
dt | The timestep in seconds | |
vxCoord | The index in the LinearData of the velocity in the x direction | |
vyCoord | The index in the LinearData of the velocity in the y direction | |
xCoord | The index in the LinearData to store new x position | |
yCoord | The index in the LinearData to store new y position |
Definition at line 261 of file simulation.C.
void Simulation::move_ | ( | double | dt, | |
unsigned | vxCoord1, | |||
unsigned | vyCoord1, | |||
unsigned | vxCoord0, | |||
unsigned | vyCoord0, | |||
unsigned | xCoord, | |||
unsigned | yCoord | |||
) |
Move the mesh using a quadratic approximation to displacement.
This function uses a velocity functions maintained on the mesh to calulate displacement. It uses velocity functions from the current timestep, and the previoud timestep to get a quadratic approximation to displacement. The user must specify which indexes in the LinearData coorespond to the various velocity functions.
This function takes into account the fixed parameters on BoundaryVertexs and BoundaryEdges. It uses the QBSpline::move() funtion to calculate the new positions of the splines on the BoundaryEdges.
After the boundary has been moved correctly, the non-boundary BezierVertexs and BezierEdges are moved.
Since all Cell have pointers to thier geomteric data, changing one of the Point2D's updates everyone relying on it. This greatly simplifies the movement process, and is one of the main reasons not to store data directly in the cells.
dt | The timestep in seconds | |
vxCoord1 | The index in the LinearData of the velocity in the x direction at time 1 | |
vyCoord1 | The index in the LinearData of the velocity in the y direction at time 1 | |
vxCoord0 | The index in the LinearData of the velocity in the x direction at time 0 | |
vyCoord0 | The index in the LinearData of the velocity in the y direction at time 0 | |
xCoord | The index in the LinearData to store new x position | |
yCoord | The index in the LinearData to store new y position |
Definition at line 320 of file simulation.C.
References QBSpline::b, bdry_mesh, bezier_mesh, BezierMesh::check_consistency(), compute_displacement(), BezierMesh::data_length(), get_data(), CellComplex< Vertex, Edge, Face, Tuple >::get_edges_begin(), CellComplex< Vertex, Edge, Face, Tuple >::get_edges_end(), CellComplex< Vertex, Edge, Face, Tuple >::get_vertices_begin(), CellComplex< Vertex, Edge, Face, Tuple >::get_vertices_end(), QBSpline::k, QBSpline::move(), Point2D::x(), and Point2D::y().
Here is the call graph for this function:
void Simulation::move_ | ( | double | dt, | |
unsigned | vxCoord, | |||
unsigned | xCoord | |||
) |
Linear movement wrapper.
This is a wrapper. Assumes y indices are immediately after x indices
dt | The timestep in seconds | |
vxCoord | The index in the LinearData of the velocity in the x direction | |
xCoord | The index in the LinearData to store new x position |
Definition at line 274 of file simulation.C.
References move_().
Here is the call graph for this function:
void Simulation::move_ | ( | double | dt, | |
unsigned | v1xCoord, | |||
unsigned | v0xCoord, | |||
unsigned | xCoord | |||
) |
Quadratic movement wrapper.
This is a wrapper. Assumes y indices are immediately after x indices
dt | The timestep in seconds | |
v0xCoord | The index in the LinearData of the v0 in the x direction | |
v1xCoord | The index in the LinearData of the v1 in the x direction | |
xCoord | The index in the LinearData to store new x position |
Definition at line 288 of file simulation.C.
References move_().
Here is the call graph for this function:
void Simulation::set_positions | ( | unsigned | xPosI, | |
unsigned | yPosI | |||
) |
void Simulation::move | ( | double | time_step, | |
unsigned | vx_pos, | |||
unsigned | vy_pos | |||
) |
void Simulation::move | ( | double | time_step, | |
unsigned | vx1_pos, | |||
unsigned | vy1_pos, | |||
unsigned | vx0_pos, | |||
unsigned | vy0_pos | |||
) |
Definition at line 461 of file simulation.C.
References data_store, move_(), positions_set, DataStore::swap_geo_with(), XposIndex, and YposIndex.
Here is the call graph for this function:
void Simulation::move | ( | double | time_step, | |
unsigned | vx_pos | |||
) |
Definition at line 456 of file simulation.C.
References move().
Here is the call graph for this function:
double Simulation::move_safe | ( | double | time_step, | |
unsigned | vx_pos, | |||
unsigned | vy_pos | |||
) |
double Simulation::move_safe | ( | double | time_step, | |
unsigned | vx1_pos, | |||
unsigned | vy1_pos, | |||
unsigned | vx0_pos, | |||
unsigned | vy0_pos | |||
) |
Definition at line 494 of file simulation.C.
References bezier_mesh, data_store, BezierMesh::find_inverted_triangles(), move(), DataStore::swap_geo_with(), XposIndex, and YposIndex.
Here is the call graph for this function:
double Simulation::move_safe | ( | double | time_step, | |
unsigned | vx_pos | |||
) |
Definition at line 489 of file simulation.C.
References move_safe().
Here is the call graph for this function:
void Simulation::store_state | ( | unsigned | vIndexFrom, | |
unsigned | vIndexTo, | |||
unsigned | xIndexTo | |||
) |
Definition at line 510 of file simulation.C.
References DataStore::copy_data_2(), data_store, and DataStore::write_geo_into().
Here is the call graph for this function:
void Simulation::restore_state | ( | unsigned | vIndexFrom, | |
unsigned | vIndexTo, | |||
unsigned | xIndexFrom | |||
) |
Definition at line 516 of file simulation.C.
References DataStore::copy_data_2(), data_store, and DataStore::read_geo_from().
Here is the call graph for this function:
int Simulation::read_from_text_file | ( | char * | filename | ) |
Reads in a mesh from a text file quartet.
This function takes a filename which is assumed to be the base name of the 4 files in a textfile quartet. It reads in the files, and creates the specified cells in the BezierMesh and BoundaryMesh. See MeshInput for more info.
This function should only be called on a new, empty Simulation. Reading in more than one mesh at a time into one Simulation, may work, but it is not tested.
filename | The base name of the text file quartet |
Definition at line 109 of file simulation.C.
References bdry_mesh, bezier_mesh, and MeshInput::read().
Referenced by Simulation().
Here is the call graph for this function:
int Simulation::read_from_binary_file | ( | char * | filename | ) |
Reads in a mesh from a binary file.
This function takes a filename which must end in the ".geo" extention. It reads in the file, and creates the specified cells in the BezierMesh and BoundaryMesh. See MeshBinaryInput for more info.
This function should only be called on a new, empty Simulation. Reading in more than one mesh at a time into one Simulation, may work, but it is not tested.
filename | The name of the binary file, includeing the ".geo" extention |
Definition at line 131 of file simulation.C.
References MeshBinaryInput::read().
Referenced by Simulation().
Here is the call graph for this function:
int Simulation::to_text_file | ( | char * | filename | ) |
Writes out the current state of the meshes to a text file quartet.
Given a base name for the text files, this function dumps the current state of the mesh to a text file quartet. The file contains all the information present in the meshes and the DataStore. Loading up a new Simulation from the files ouptuted by this function should an apporximation of the current state of the Simulation. This is because the data is converted to ascii and then back. For this reason you should NOT use the text file format for ouput. Instead use Simulation::to_binary_file(). This function is provided for backwards compatibility.
See MeshOutput for more information
filename | The base name for the text file quartet |
Definition at line 189 of file simulation.C.
References bdry_mesh, bezier_mesh, and MeshOutput::write().
Here is the call graph for this function:
int Simulation::to_binary_file | ( | char * | filename | ) |
Writes out the current state of the meshes to a binary file.
Given a name for the output file with a ".geo" extenstion, this function dumps the current state of the mesh to a bianry file. The file contains all the information present in the meshes and the DataStore. Loading up a new Simulation from the files ouptuted by this function should be an exact replica of the current mesh state. This is because all the data is stored in a binary format and so no rounding errors occur. Alwasy use this function when generating output, as it is more accurate than the text file format.
See MeshBinaryOutput for more information
filename | The name for the binary output file |
Definition at line 214 of file simulation.C.
References MeshBinaryOutput::write().
Here is the call graph for this function:
int Simulation::to_eps | ( | char * | epsfile | ) |
Write out an eps image of the mesh.
See EPSWrite for more information.
epsfile | The filename to use |
Definition at line 233 of file simulation.C.
References bdry_mesh, bezier_mesh, and EPSWrite::write().
Here is the call graph for this function:
void Simulation::print | ( | ) |
Print info.
Definition at line 244 of file simulation.C.
References bdry_mesh, bezier_mesh, and data_store.
void Simulation::print_statistics | ( | ) |
Print statistical data.
Definition at line 523 of file simulation.C.
References bdry_mesh, bezier_mesh, data_store, DataStore::print(), and CellComplex< Vertex, Edge, Face, Tuple >::print_statistics().
Here is the call graph for this function:
PersistantStore* Simulation::persistant_store [private] |
DataStore* Simulation::data_store [private] |
The Storage Location for the geometric and functional data used by both meshes.
Definition at line 52 of file simulation.h.
Referenced by get_data(), get_data_store(), initialize_structures(), move(), move_safe(), print(), print_statistics(), restore_state(), and store_state().
BoundaryMesh* Simulation::bdry_mesh [private] |
The BoundaryMesh, holding all the Boundary cells for this Simulation.
Definition at line 53 of file simulation.h.
Referenced by get_boundary_mesh(), initialize_structures(), move_(), print(), print_statistics(), read_from_text_file(), to_eps(), and to_text_file().
BezierMesh* Simulation::bezier_mesh [private] |
The BezierMesh, holding all the Bezier cells for this Simulation.
Definition at line 54 of file simulation.h.
Referenced by get_bezier_mesh(), initialize_structures(), move_(), move_safe(), print(), print_statistics(), read_from_text_file(), to_eps(), and to_text_file().
unsigned Simulation::XposIndex |
unsigned Simulation::YposIndex |
Definition at line 83 of file simulation.h.
Referenced by initialize_structures(), move(), and set_positions().