For more complicated geometries, compartments are defined with pieces. In essence, a piece is a *closed* surface in space. Each piece is, in turn, defined by a set of
connected areas called "panels". Both interior and exterior compartments can be composed of as many pieces as required. There are two basic ways to define a piece: by
defining each panel, or using a more powerful language to generate the panels. In the next section, an even more powerful method of generating panels by Boolean
operations on existing pieces will be discussed.

In addition to geometry, pieces have several additional attributes, all of which are defined as options on the command which defines the piece. Here, we will first discuss defining pieces via panels and then turn to the easy way. A panel description of a piece begins with the command:

&DESCRIBE PIECE, PIECE_NAME, -OPTIONS

and the available options are:

-PERMEABILITY, PERM-OBSTACLE,-DIFTYPE, TYPE-CS_WIND, CSW_X, CSW_Y, CSW_Z-CS_CURRENT, CSC_X, CSC_Y, CSC_Z-CS_VELOCITY, CS_VELOCITY_NAME-DD_MULT, DDR(1), MULT(1), ...., DDR(n), MULT(n)-AMASS, AMA_MULT, AM_CURVE-TANAKA, TANAKA_FACTOR-ROLL_DAMPING, ROLL_DAMP_FACTOR-COLOR, COLOR(1), FRAC(1), ... COLOR(n), FRAC(n)-TEXTURE, NAME_TEX, X_SCALE, Y_SCALE

Here, PIECE_NAME is the name of the piece. If this is omitted, a name will be automatically generated by MOSES. The **-PERMEABILITY** option can be
used to alter the buoyancy of a piece. Here, PERM is the permeability of the piece, and it should be positive for a buoyant piece and negative for a hole or a flooded
compartment. A value of one corresponds to 100 percent of the piece's volume. The default value for permeability is 1 for an exterior piece, and -1 for an interior
compartment.

The **-OBSTACLE** option provides a method for defining an obstacle in the water, with which a floating body will have hydrodynamic interaction. The
obstacle belongs to the body defined with the last **&DESCRIBE BODY** command, but does not move in a simulation. Multiple obstacles may be defined, so that several
situations may be analyzed. For instance, three obstacles may be defined and arranged to simulate a floating body inside a dry dock. A single obstacle can be arranged
underneath a body to represent a sloping sea floor. It is important to note that an obstacle will move only when the body it is attached to moves as a result of a
positioning command, such as **&INSTATE -LOCATE**.

The remaining options of the **PIECE** command are applicable *only* to exterior compartments and are used to define how forces on the piece will be computed. The **-DIFTYPE** option defines which hydrodynamic theory will be used for the piece. Here, TYPE must be either **3DDIF** if one wishes to use Three Dimensional
Diffraction Theory, or **NONE** if the piece is to be ignored in computing hydrodynamic properties. If one wants to use Strip Theory, he must define the piece with a **PGEN**
command which is discussed later. The **-CS_WIND** and **-CS_CURRENT** options define how the panels of the piece attract wind and
current loads.

In general, for each panel in a piece, MOSES will split it into a portion above the water and a portion below. The wind force on the out of water portion and the
current force on the below water portion are computed as if the area was a **#PLATE**. Here, however, the components of the velocity are multiplied by the values of
CSC_X, CSC_Y, and CSC_Z respectively. In addition, the current force is multiplied by a multiplier, MULT, that depends on the water depth to draft ratio, DDR. This
value is obtained by interpolation from the table defined with the **-DD_MULT** option. The default values for the CSs and the multiplier table are set
with the **&DEFAULT** command.

Several other things need to be said here. First, the "current" force actually depends on both the current velocity and the velocity of the panel, so using the word
current is really incorrect. Second, the results are quite dependent upon the setting of **-AF_ENVIRONMENT** option of **&PARAMETER**. If the option
is set to **NO** and the above is used for "round" pieces, the results may be surprising. The force produced for a rectangular box is exactly the same as one would get by
using a pair of **#PLATE**s. For a circular cylinder, however, one gets a force of .785 (pi/4) times that of a square box. This is simply a result of the recipe used to
compute the force. Thus, to get "the correct" force on a cylinder, one should specify:

-CS_WIND.5/.785 .5/.785 1-CS_CURRENT.5/.785 .5/.785 1

If the setting is **YES** then this does not apply.

The option **-CS_VELOCITY** can be used to change the first component of the CS_CURRENT values. Here, CS_VELOCITY_NAME is the name of a "curv" what
has been defined with the command CS_VELOCITY with the command &DATA CURVE CS_VELOCITY. If this option is used, then the relative speed at each
panel will be used to interpolate a drag coefficient.

The **-AMASS** option defines a multiplier for an estimate of the added mass of a piece. If the name AM_CURVE is omitted, then MOSES will estimate the
added mass in these three directions as a function of submergence. These estimate are based on the projection of the "box" containing the submerged piece onto the
body coordinates for surge and sway and on the waterplane for heave. Here you will get three polygons, one for each coordinate direction. The added mass in each
direction is obtained as if this polygon is an isolated plate. If AMA_MULT is zero, no added mass will be accumulated for this piece. The slopes of the heave curve
are also used to compute slam loads in heave. If you wish, you can define a "curve" with a type of AM_PRESSURE with the command &DATA CURVE
AM_PRESSURE. Notice that this is an excellent way to estimate added massed for isolated plates and for things which will change their submerged shape considerably,
but it should be turned off for pieces which are used for diffraction or strip theory hydrodynamics.

The option **-TANAKA** defines a multiplier for the damping due to "eddy making". In MOSES, we refer to this as "Tanaka" damping after the person who
first formulated the results for eddy making damping. In MOSES, we use the formulation outlined in a paper by Schmidke in *The Transactions of the Society of Navel
Architects and Marine Engineers* (1978). The default value here is defined by an option of the same name for the **&DEFAULT** command. The option **-ROLL_DAMPING** defines a quadratic damping factor, ROLL_DAMP_FACTOR in ( sec**2 - feet or meters - bforce )/rad**2. When defined, it applies a
roll moment given by:

roll_moment = ROLL_DAMP_FACTOR * omega**2

and omega is the roll angular velocity. *CAUTION* if either of these option are used in conjunction with **-CS_CURRENT** then roll will be over damped.

The **-COLOR** and **-TEXTURE** options can be used to define the color and texture of the piece. These will be used when one asks for a picture with -COLOR MODELED. Here,
NAME_COL is any color which has been previously defined. See the section on Colors for a discussion on defining colors. The NAME_TEX value for **-TEXTURE** is the name of a file in either /X/data/textures or /X/data/local/textures (here MOSES is store in /X). The X_SCALE and Y_SCALE are scale
factors which will be applied to the texture. The NAME_TEX of **NONE** will yield a null default texture.

The string function:

&PIECE(ACTION, NAME)

can be used to return information about a piece. Here, NAME is the piece about which information is desired and ACTION must be either **CURRENT**, **PANELS**, **DIFTYPE**,
**PERMEABILITY**, **CS_WIND**, **CS_CURR**, **AMASS**, **LOCATION**, or **OBSTACLE**, and the type CURRENT returns the current piece name, PANELS returns the names of the panels in the
specified piece, and all of the others return the data defined with the options of the same name.

After the piece has been defined, its geometry is defined by a set of convex polygons called panels. Each panel is defined by points at its corners with the command:

PANEL, PAN_NAME, PTNAM(1), ....., PTNAM(n)

Here, PAN_NAME is the optional name assigned to the panel, and PTNAM(i) are names of its vertices. If PAN_NAME is omitted, a panel name will be assigned internally. A
panel can contain from three to fifty vertices. The order of the definition of the vertices should be *clockwise* when the panel is viewed from *outside* of the body. In
other words, the normal to the surface when defined by the right hand rule should point into the body. One can alter this convention by using the command,

REVERSE, -OPTIONS

and the available options are:

-YES-NO

The counterclockwise order for the vertices should be used following a **REVERSE** **-YES** command. If one wishes to change back to the basic convention, he
should then issue **REVERSE** **-NO**.

The string function:

&PANEL(ACTION, NAME)

can be used to return information about a panel. Here, NAME is the panel about which information is desired and ACTION must be **AREA**, **NORMAL**, **E_COORDINATES**, **PERIMETER**,
or **G_CENTROID**. These return the obvious things with E_COORDINATES returning the part coordinates of the ends and G_CENTROID returning the global centroid.

While the above method is certainly general in that all possible surfaces can be defined as accurately as desired, actually defining a mesh with panels can become quite tiresome. As an alternative, MOSES provides a menu for "generating" a piece. This menu begins with the command:

PGEN, PIECE_NAME, -OPTIONS

and the available options are:

-PERMEABILITY, PERM-OBSTACLE,-DIFTYPE, TYPE-CS_WIND, CSW_X, CSW_Y, CSW_Z-CS_CURRENT, CSC_X, CSC_Y, CSC_Z-CS_VELOCITY, CS_VELOCITY_NAME-DD_MULT, DDR(1), MULT(1), ...., DDR(n), MULT(n)-AMASS, AMA_MULT, AM_CURVE-TANAKA, TANAKA_FACTOR-ROLL_DAMPING, ROLL_DAMP_FACTOR-COLOR, COLOR(1), FRAC(1), ... COLOR(n), FRAC(n)-TEXTURE, NAME_TEX, X_SCALE, Y_SCALE-STBD-PORT-BOTH-TOL_OFF, TOL-LOCATION, X, Y, Z, ROLL, PITCH, YAW

and ends with an **END_PGEN** command. Here, most of the options are exactly the same as those for the **PIECE** command, and the last five define how to interpret the plane
data which will follow.

In this menu, the closed surface of the piece will be defined as a sequence of polygons called planes. In contrast to panels, these planes do not define the surface
directly, but define "cuts" through it. To proceed, consider two coordinate systems, a local system used in this menu only, and the part system. The local X axis lies
along the length of the piece, positive aft. The local Z axis is perpendicular to the local X axis, and is positive "up". The local y axis is defined by the local X
and Z axes, and the right-hand rule (positive to starboard.) The surface of the piece is now defined by its intersection with a set of planes. These planes have
constant local X values and the intersection is defined by a set of local points, (Yi,Zi). The options define how the points will be interpreted. The default is to
define only the positive Y portion of the plane, allowing MOSES to automatically produce the negative half. If one specifies **-STBD**, no reflection will
be performed. If **-PORT** is specified, then the plane is reflected, and the positive portion is deleted. Finally, if **-BOTH** is specified,
one must define both halves of the plane. In this case, one first defines the positive portion and proceeds around the contour to define the negative portion. In all
cases, one starts at the bottom of the station (minimum z and zero y) and proceeds around counter clockwise (point 2 is has non decreasing z from point 1). If using
Strip Theory, the user should set TYPE to be **STRIP** and the **-STBD**, **-PORT** and **-BOTH** options cannot be used. The **-CS** options
work exactly the same as described above.

The **-TOL_OFF** option allows one to omit offsets which lie on a line from the model. This is often desirable since MOSES gives the correct answers for
planes of any size. Here, TOL is the cosine in the angles minus 1 which will be considered to be colinear.

The **-LOCATION** option allows one to place and orient the generated piece with respect to the part system. The position of the piece is defined by X,
Y, and Z (feet or meters). These are the part coordinates of the origin of the local coordinates of the piece. The orientation of the piece is defined by the three
angles: ROLL, PITCH, and YAW. These are defined as follows: Suppose that the piece is given successive rotations about the local Z axis, then about the new local Y
axis, and finally, about the new local X axis, so that the piece, after the three rotations is in its proper orientation in space. These three angles can be thought
of as a yaw, followed by a pitch, followed by a roll to move the piece from when it is aligned with the global system to its required position in space.

In this menu, the actual definition of the surface is accomplished by a set of commands:

PLANE, X(1), X(2), ...., X(n), -OPTIONS

and the available options are:

-RECTANGULAR, ZBOT, ZTOP, BEAM, NB, NS, NT-CARTESIAN, Y(1), Z(1), Y(2), Z(2), ......, Y(n), Z(n)-CIRCULAR, Y, Z, R, THETA, DTH, NP-E_CIRCULAR, Y, Z, R, THETA, DTH, NP

where: X(i) is a local X coordinate of the plane (feet or meters), and the offsets of the section are defined by the options. The X values for a piece must be defined in non-decreasing order; i.e. one should not have

PLANE 10 -10 ...

If the section is rectangular, it can be completely defined by one **-RECTANGULAR** option. Here: ZBOT is the local Z coordinate of the bottom of
the section (feet or meters), ZTOP is the local Z coordinate of the top of the section (feet or meters), and BEAM is the width of the section (full width, feet or
meters). Normally, the section is defined with 4 points, but this can be changed with the values NB, NS, NT. NB defines the number of points along the bottom, NS the
side, and NT the top. For other types of sections, the **-CARTESIAN**, **-CIRCULAR**, or **-E_CIRCULAR** options are
used. With the **-CARTESIAN** option Y(i), Z(i) are local Y and Z coordinates of the ith offset point (feet or meters). The **-CIRCULAR** option allows one to input data in
polar coordinates. Here: Y and Z are local coordinates of the center of the circle (feet or meters), R is the radius of the circle (feet or meters), THETA is the
angle of the first point (degrees) measured from the negative local Z axis positive toward Y, DTH is the increment in angle (degrees), and NP is the number of points
to be generated. It is important to notice that any number of **-CIRCULAR** and **-CARTESIAN** options can be used to define the section. The **-E_CIRCULAR** option is the same
as the **-CIRCULAR** option except that the radius which is specified is *not* the one which will be used. Instead, a new radius will be computed so that the area of the
polygon defined by the new radius is the same as that of the circular sector.

The number and size of the panels determine the accuracy of the results. Of course, the computational effort required is quite sensitive to the number of panels and so one is constantly seeking a good compromise between fidelity and efficiency. Complicating this, however, is the fact that there are several different things for which accuracy is important. The algorithm which computes hydrostatic results from the mesh is "exact" in that the results obtained from a given mesh are the same as those obtained from a refined mesh for the same body. Thus, from a pure hydrostatic point of view, the most desirable mesh is the coarsest one which properly defines the surface of the body.

In a structural analysis, however, a different problem arises. By default, the structural loads on a panel are mapped to the nodes closest to the vertices of the
panel. If you have a large number of nodes in comparison to the number of panels, then the default will not yield a good load distribution. If the default scheme is
to work properly, then there should be a reasonable relationship between structural nodes and corners of panels. In other words, if one has a single panel for the
side shell of a barge, he should *at least* have points on the panel at each longitudinal location where he has structural nodes.

To eliminate many of these difficulties, MOSES has a command available in the **MEDIT** menu:

M_PAN_FIX, TOL_OP, TOL_B, -OPTIONS

where the available options are:

-BOUNDARY-NODES, YES/NO-COMPART, :CMP_SEL-PIECE, :PIECE_SEL-PANEL, :PAN_SEL-POINTS, :PNT_SEL-X, X_BOX1, X_BOX2-Y, Y_BOX1, Y_BOX2-Z, Z_BOX1, Z_BOX2-DIRECTION, DIR

The purpose of this command is to change the nodes to which the loads will be mapped for selected panels. The details of the options will be addressed later. The two
numbers TOL_OP and TOL_B control the remapping. To see how these work, consider the situation discussed above. In particular, suppose that you have large panels and
small plates, so that there are several plates which are inside a panel. By default, there will be no load applied to the nodes at the vertices of the interior
generalized plates. **M_PAN_FIX** will solve this problem by adding points on the boundary and interior of the panel to the list of points which will receive the load.
Here, TOL_OP (feet or meters) defines an out of plane tolerance. Only points within TOL_OP distance along the normal of the plane will be considered. Likewise, TOL_B
(feet or meters) defines a boundary tolerance, and only points with a distance of TOL_B of the boundary will be considered to belong to the boundary. These two
tolerances define what is meant by "on the boundary" and "inside the panel". If a point is within TOL_B of the boundary in the plane of the panel and within TOL_OP of
the plane of the panel, then it is "on the boundary" of the panel. If a point is "inside" the panel (a distance greater than TOL_B away from the boundary and inside
the panel) and within TOL_OP of the plane of the panel, then it is inside the panel. If the **-BOUNDARY** option is used, all points inside the panel
and on the boundary of the panel will be used for the map. Alternatively, without the **-BOUNDARY** option, only points inside the panel will be used. To "fix" a mesh
that is being mapped to a generalized plate model, this is normally all that is necessary.

The panels are available for selection are defined by selectors by matching the selectors defined with the **-NODES**, **-COMPART**, **-PIECE**, **-PANEL**, and **-POINTS** options. In other words a panel is available for selection if its name matches :PAN_SEL,
and it is in a piece selected by :PIECE_SEL which is in a compartment selected by :CMP_SEL. Finally, for a panel to be selected, it must be inside a box defined in
the part system with the options **-X**, **-Y**, and **-Z**. If the average of the vertices of the panel lie inside this box, the panel will
be remapped. The default for each selector is @, and the default box is all of space. Thus, if none of these options is used, all panels will be remapped. Normally,
only *nodes* will be considered for the mapping. If, however, one wants to map to points which are not nodes, then they should use the **-NODES** option with a value of **NO**
for YES/NO. With the options **-X**, **-Y**, or **-Z** the first dimension defines the beginning of the box (minimum dimension) and the second one defines the end of the box
(maximum dimension). For example, if one issues:

M_PAN_FIX -X 0 50

then only panels which have the average of their vertices in the x direction between 0 and 50 will be remapped.

The **-POINTS** option defines the set of points which will be used for the mapping. By default, :PNT_SEL is set to @, so that all points will be used.

The last option **-DIRECTION** completely alters the behavior of the remapping. This option is useful for remapping meshes that are connected to beam
models. In this case, the concepts of closeness used above are changed to measures along a single axis. Here, DIR which must be chosen from **X**, **Y**, or **Z** defines the
"direction" of the mapping. Here, the remapping works as above, except that now "in the panel" means that a point has its "selected" coordinate between the extremes
of the "selected" coordinates of the panel. By "selected" coordinate, we mean either the x, y, or z coordinate depending on the value of DIR. Thus, suppose that we
specified X for DIR. A point will be used for the mapping if its x coordinate is between X_MIN - TOL_B and X_MAX + TOL_B where X_MIN is the minimum value of the x
coordinates of the vertices of the panel and X_MAX is the maximum of the x coordinates of the vertices. Additionally, the y and z coordinates must be between the
minimum values of the vertices minus TOL_OP and the maximum values plus TOL_OP.

Finally, the **MEDIT** command:

MAP, MAPNAM :MAP_SEL(1), :MAP_SEL(2), .......

can be used to completely define the map for a panel. Here, MAPNAM is the name of the panel map, and :MAP_SEL(i) are a set of selectors which define the map. One can
look at the maps with the commands **&STATUS MAP** and **&STATUS N_MAP**.

If Strip Theory is used to compute hydrodynamics, the planes defined in a **PGEN** piece are used for the Two Dimensional hydrodynamic computation. Thus, for these
pieces, one needs a reasonable longitudinal distribution and several (over 10) planes, even if two would suffice hydrostatically.

In contrast to most programs, the mesh used for Three Dimensional Diffraction is the same as that used for hydrostatics. Whenever one asks for hydrodynamic pressures
to be computed, MOSES will convert this mesh to one which describes the submerged portion of the body in the initial configuration. Thus, one can analyze different
drafts and trims without changing the mesh definition. MOSES has an automatic refinement capability controlled by the two options **-M_DISTANCE** of the **&PARAMETER**
command. When the mesh is being used for hydrodynamic computations, MOSES will automatically refine the mesh so that no side of a panel is greater than the distances
given by these two options. This allows one to build a quite crude mesh and yet obtain solutions as accurate as desired by simply changing one of the two parameters.
The same caveat about structural loads also applies here. The basic panels should have corners in a reasonable relationship to the structural nodes where one will
ultimately apply the loads.

To examine how a mesh is refined by the two mesh refinement options, the user can use **&PICTURE -TYPE MESH -DETAIL**. This will produce the mesh refined according to the
**&PARAMETER** settings in effect when the command was issued. As mentioned above, the accuracy depends on the panel size, particularly at higher frequencies. The
execution time, however, increases as the square of the number of panels for small meshes and as the cube for large ones. Thus, one should strive to have the minimum
number of panels which are still small enough to produce an accurate solution.

Even though the same set of panels are used for both hydrostatics and hydrodynamics, the computations are quite different. For hydrostatics, the computation is a
simple integration over each panel. Here, it does not matter if two different pieces have common boundaries. For Three Dimensional Diffraction, however, it is
essential that the panels represent the true surface and that no part of space belongs to two different panels. This makes the generation methods of the **&SURFACE** menu
quite valuable, since dealing with the intersections between pieces is provided.

Once a diffraction mesh has been defined, it can be exported to a file for later use with the command:

&EXPORT MESH