Files
LaGriT/documentation/lagrit_manual/commands/compute.txt
2025-12-17 11:00:57 +08:00

349 lines
7.2 KiB
Plaintext
Executable File

.. _compute:
> **_COMPUTE_**
>
>> This command contains modules that compute various attributes and functions
based on one or more
mesh objects. This operation will (often) result in new attributes being added
to the mesh objects. The
action of the command will be controled by the keyword in the second argument
position.
>>
>> distance_field - keyword for distance field calculation. Determine the
minimum distance from any node in
mo_source to every node in mo_sink and place the result in the node based
floating point attribute,
distance_field_attribute in mo_sink. The computation is accelerated by using
the [kdtree](kdtree.html) search
algorithm.
signed_distance_field - keyword for signed distance field calculation.
Determine the minimum distance
&nbsp_place_holder;&nbsp_place_holder;&nbsp_place_holder;
from any node in mo_source to every node in mo_sink and place the result in
the node based floating
&nbsp_place_holder;&nbsp_place_holder;&nbsp_place_holder;
&nbsp_place_holder;&nbsp_place_holder;&nbsp_place_holder;
point attribute, distance_field_attribute in mo_sink. The computation is
accelerated by using the&nbsp_place_holder;&nbsp_place_holder;
&nbsp_place_holder;&nbsp_place_holder;&nbsp_place_holder;
[kdtree](kdtree.html) search algorithm. Using this option the mo_source MUST
be either a triangle or quad surface
&nbsp_place_holder;&nbsp_place_holder;&nbsp_place_holder;
&nbsp_place_holder;&nbsp_place_holder;&nbsp_place_holder;
mesh object. If the surfaces form a topologically closed volume then positive,
'above' distance is in the
&nbsp_place_holder;&nbsp_place_holder;&nbsp_place_holder;
direction of the surface normal vector. Negative is 'below' the surface. If
the surface is not a closed
&nbsp_place_holder;&nbsp_place_holder;&nbsp_place_holder;
&nbsp_place_holder;&nbsp_place_holder;&nbsp_place_holder;
volume, then the assumptions described in the [surface](SURFACE.html) command
are used to determine what is above
&nbsp_place_holder;&nbsp_place_holder;&nbsp_place_holder;
and what is below the surface.
>>
>> linear_transform - keyword for an extrapolation from an attribute value in
a surface onto every node of
a 3D mesh. Given a 3D mesh and a 2D surface, this command will extrapolate a
scalar value from that surface
onto every point of the mesh. This can be used to (for example):
>>
>> * Propogate head values from a surface onto all nodes of a mesh.
>> * Expand a mesh to fit a surface, by propogating the appropriate spatial
coordinate.
>> * Compute the depth relative to a topographic surface to each node of a
mesh.
>>
>> This is highly dependant on the spatial relation between the mesh and the
surface - values from the
surface are extrapolated "downward" into the mesh in the direction specified
in the command. The
direction specified in the command must be one of
[zpos|zneg|ypos|yneg|xpos|xneg]. For example,
specifing zpos will result in the upper (positive
z-axis) side of the mesh having attribute values conforming exactly to those
on the surface, while the
lower side of the mesh will have whatever attribute values it had previous,
with all nodes in between
having attribute values distributed linearly between the two extremes. If a
direction is not specified,
it will default to zpos. If an attribute is not specified, it will default to
the spatial attribute appropriate
to the chosen direction (i.e. if the direction is yneg, the attribute will
default to yic, the y-coordinate of
each node.) The attribute chosen must already exist in both the surface and
main meshes.
>>
>> Other places to look for modules that compute some standard mesh attributes
include, [quality](QUALITY.html), which will
compute aspect ratio and volume, [cmo/addatt](cmo/cmo_addatt.html), which will
compute normal vectors, dihedral angles, solid
angles, meadian points, Voronoi points and more. User functions can be
computed with the [math](MATH.html) module.
>
> **FORMAT**:
&nbsp_place_holder;&nbsp_place_holder;&nbsp_place_holder;
compute/distance_field/mo_sink/mo_source/distance_field_attribute
>
>> compute/signed_distance_field/mo_sink/mo_source/distance_field_attribute
compute/linear_transform/mo_main/mo_surface/[direction/att_name]
>
> **EXAMPLES**:
>
>> compute / distance_field / mo_sink / mo_src / dfield
compute / signed_distance_field / mo_sink / mo_src / dfield
>>
>> compute / linear_transform / mo_sink / mo_surf
&nbsp_place_holder;&nbsp_place_holder;&nbsp_place_holder;
&nbsp_place_holder;&nbsp_place_holder;&nbsp_place_holder;
&nbsp_place_holder;&nbsp_place_holder;&nbsp_place_holder;
&nbsp_place_holder;&nbsp_place_holder;&nbsp_place_holder; (will expand top of
mesh to look like the surface)
>>
>> compute / linear_transform / mo_sink / mo_surf / zpos / water_head_value
>>
>> &nbsp_place_holder;
>
> ** Example: distance_field **
>
> ![Example: distance_field](../distance_field_01.png)
>
> cmo / create / cmo_src
> createpts/rtz/1,91,1/3.,0.,0./3.,270.,0./1,1,1/
> cmo / create / cmo_snk
> createpts / xyz / 30 30 1 / -5. -5. -5. / 5. 5. 5. / 1 1 1
> compute / distance_field / cmo_snk / cmo_src / dfield
> finish
>
>
>
> ****
>
> ** Example: signed_distance_field **
>
> ![signed distance field](../../images/distance_field_02.png)
>
> *
> * Create some of the necessary parts
> *
> cmo / create / mo_tet
> createpts/random/rtp/.1/1,0,0/1,180,360////.02
> connect
> resetpts / itp
> *
> * Extract the external surface
> *
> extract / surfmesh / 1 0 0 / mo_tri / mo_tet / external
> dump / gmv / tri_surf.gmv / mo_tri
> cmo / delete / mo_tet
> cmo / printatt / mo_tri / -xyz- / minmax
> cmo / create / mo_pts
> *
> * Create an xyz node distribution and connect the nodes.
> *
> createpts / xyz / 31 31 31 / -1 -1 -1 / 1 1 1 / 1 1 1
> connect
> resetpts / itp
> *
> * Compute the signed distance field
> *
> compute / signed_distance_field / mo_pts / mo_tri / dfield1
> addmesh / append / mo_all / mo_pts / mo_tri
> dump / gmv / signed_dfield1.gmv / mo_all
> *
> * Do the same thing but use a surface of quads that make
> * two nested spheres.
> *
> cmo / create / mo_hex / / / hex
> createpts/sphere/8/5/5000/1.0,0.5/0.,0.,0./1,0,0.0/
> filter / 1 0 0
> resetpts / itp
> extract / surfmesh / 1 0 0 / mo_quad / mo_hex / external
> dump / gmv / quad_surf.gmv / mo_quad
> *
> * Compute the signed distance field
> *
> compute / signed_distance_field / mo_pts / mo_quad / dfield2
> addmesh / append / mo_all2 / mo_pts / mo_quad
> dump / gmv / signed_dfield2.gmv / mo_all2
> cmo / status
> quality
> cmo / printatt / mo_pts / -all- / minmax
> finish
>
>
>
> **
Example: linear_transform **
>
> ![Example: lin_extp_before](../../images/lin_extp_before.jpg)
>
> infile [buildsurf.lgi](../buildsurf.lgi)
>
> * Expand the cubical mesh such that its top (positive z-axis) looks like
the sinusoidal
> * surface denoted by zhigh
> compute / linear_transform / cube / zhigh
>
> finish
>
>
>
> ![Example: lin_extp_after](../../images/lin_extp_after.jpg)
>
> &nbsp_place_holder;