dsmc-0.1.0.1: DSMC library for rarefied gas dynamics

Safe HaskellNone

DSMC.Traceables.Parser

Description

Parser for body definitions.

Body definition contains a number of solid definitions and ends with the top level object definition. RHS of solid equations may reference other solids to compose into complex bodies.

Multiple-body compositions are right-associative.

 # comment

 # define few primitives
 solid b1 = sphere (0, 0, 0; 5);
 solid p1 = plane (0, 0, 0; 1, 0, 0);

 # define a composition
 solid body = b1 and p1;

 # assign it to be the top level object
 tlo body;

Statements must end with a semicolon (newlines are optional). Excessive spaces are ignored.

Top-level object line must reference a previously defined solid.

Syntax for primitives follows the signatures of Traceables constructors for plane and sphere, but differs for cylinder and cone, as this module provides access only to frustums (cylinderFrustum and coneFrustum).

Half-space
plane (px, py, pz; nx, ny, nz), where (px, py, pz) is a point on a plane which defines the half-space and (nx, ny, nz) is a normal to the plane (outward to the half-space), not necessarily a unit vector.
Sphere
sphere (cx, cy, cz; r), where (cx, cy, cz) is a central point of a sphere and r is radius.
Right circular cylinder
cylinder (p1x, p1y, p1z; p2x, p2y, p2z; r) where (p1x, p1y, p1z) and (p2x, p2y, p2z) are bottom and top points on axis and r is radius.
Right circular conical frustum
cone (p1x, p1y, p1z; r1; p2x, p2y, p2z; r2) where (p1x, p1y, p1z) and (p2x, p2y, p2z) are bottom and top points on cone axis and r1, r2 are the corresponding radii.

Synopsis

Documentation

parseBody :: ByteString -> Either String BodySource

Try to read body definition from bytestring. Return body or error message if parsing fails.

parseBodyFile :: FilePath -> IO (Either String Body)Source

Read body definition from file. If parsing fails or IOError when reading file occurs, return error message.