lanl / LaGriT

Los Alamos Grid Toolbox (LaGriT) is a library of user callable tools that provide mesh generation, mesh optimization and dynamic mesh maintenance in two and three dimensions.
https://lanl.github.io/LaGriT/
Other
122 stars 49 forks source link

Weird quad behavior #201

Closed keurfonluu closed 2 years ago

keurfonluu commented 4 years ago

Hi,

First, I apologize if I am doing something wrong, I am new to LaGriT.

Long story short, when I create the following quad with the point coordinates explicitly defined (not stored in a variable), it generates a twisted quad:

define, nx, 10
define, ny, 10

cmo, create, moquad
quadxy, nx ny, 1000.0 -500.0 0.0, 1000.0 500.0 0.0, 1000.0 500.0 1000.0, 1000.0 -500.0 1000.0
createpts, brick, xyz, nx ny 1, 1 0 0, connect

dump, avs, quad_twist.inp, moquad
finish

quad_twist

If I divide all the coordinates by 100, I get the expected quad:

define, nx, 10
define, ny, 10

cmo, create, moquad
quadxy, nx ny, 10.0 -5.0 0.0, 10.0 5.0 0.0, 10.0 5.0 10.0, 10.0 -5.0 10.0
createpts, brick, xyz, nx ny 1, 1 0 0, connect

dump, avs, quad_100.inp, moquad
finish

quad_100

If I define the point coordinates in different variables, it works too:

define, nx, 10
define, ny, 10

define, x1, 1000.0
define, y1, -500.0
define, z1, 0.0

define, x2, 1000.0
define, y2, 500.0
define, z2, 0.0

define, x3, 1000.0
define, y3, 500.0
define, z3, 1000.0

define, x4, 1000.0
define, y4, -500.0
define, z4, 1000.0

cmo, create, moquad
quadxy, nx ny, x1 y1 z1, x2 y2 z2, x3 y3 z3, x4 y4 z4
createpts, brick, xyz, nx ny 1, 1 0 0, connect

dump, avs, quad_ok.inp, moquad
finish

quad_ok

Is it working as intended?

Thank you.

daniellivingston commented 4 years ago

Hi @keurfonluu, for historical reasons, LaGriT input lines are a max of, I believe, 72 characters. Lines that exceed that length are truncated. That truncation is probably what you're seeing in the distorted first mesh:

>>> len('quadxy, nx ny, 1000.0 -500.0 0.0, 1000.0 500.0 0.0, 1000.0 500.0 1000.0, 1000.0 -500.0 1000.0')
93
>>> len('quadxy, nx ny, 10.0 -5.0 0.0, 10.0 5.0 0.0, 10.0 5.0 10.0, 10.0 -5.0 10.0')
73
>>> len('quadxy, nx ny, x1 y1 z1, x2 y2 z2, x3 y3 z3, x4 y4 z4')
53

You can split a single long command into multiple lines with the & character, like so:

quadxy, nx ny, &
1000.0 -500.0 0.0, &
1000.0 500.0 0.0, &
1000.0 500.0 1000.0, &
1000.0 -500.0 1000.0

Hope this helps!

daniellivingston commented 4 years ago

@millerta Should this throw an error (or at least a warning)?

keurfonluu commented 4 years ago

Thanks @daniellivingston ! It works like a charm.

On a side note, isn't modern Fortran capable of reading longer strings?

millerta commented 2 years ago

This problem was solved by using a line continuation character '&' for long command lines. The character string sizes and buffer sizes were first established in the f77 codes and would take some effort to change. The line continuation fixes the problem.