Skip to content

Computational grid

CGRID: the computational grid (regular, curvilinear or unstructured) and its spectral resolution.

Computational grid for SWAN.

logger module-attribute

logger = logging.getLogger(__name__)

CGRID pydantic-model

CGRID(**data: Any)

Bases: BaseComponent, ABC

SWAN computational grid abstract component.

CGRID ->REGULAR|CURVILINEAR|UNSTRUCTURED &
    CIRCLE|SECTOR [mdc] [flow] [fhigh] [msc]

This class should not be used directly.

Fields:

model_type pydantic-field

model_type: Literal['cgrid', 'CGRID'] = 'cgrid'

Model type discriminator

spectrum pydantic-field

spectrum: SPECTRUM

Spectrum subcomponent

cmd abstractmethod

cmd()

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.

REGULAR pydantic-model

REGULAR(**data: Any)

Bases: CGRID

SWAN regular computational grid.

CGRID REGULAR [xpc] [ypc] [alpc] [xlenc] [ylenc] [mxc] [myc] &
    ->CIRCLE|SECTOR [mdc] [flow] [fhigh] [msc]

This is a group component that includes a CGRID and a READGRID component.

Note

In 1D-mode, alpc should be equal to the direction alpinp.

Examples:

from rompy_swan.components.cgrid import REGULAR
cgrid = REGULAR(
    grid=dict(xp=0, yp=0, alp=0, xlen=2000, ylen=1300, mx=100, my=100),
    spectrum=dict(mdc=36, flow=0.04, fhigh=1.0),
)
print(cgrid.render())
CGRID REGULAR xpc=0.0 ypc=0.0 alpc=0.0 xlenc=2000.0 ylenc=1300.0 mxc=100 myc=100 CIRCLE mdc=36 flow=0.04 fhigh=1.0

Fields:

Validators:

model_type pydantic-field

model_type: Literal['regular', 'REGULAR'] = 'regular'

Model type discriminator

grid pydantic-field

Computational grid definition

spectrum pydantic-field

spectrum: SPECTRUM

Spectrum subcomponent

grid_suffix pydantic-validator

grid_suffix() -> REGULAR

Set expected grid suffix.

cmd

cmd() -> str

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.

CURVILINEAR pydantic-model

CURVILINEAR(**data: Any)

Bases: CGRID

SWAN curvilinear computational grid.

CGRID CURVILINEAR [mxc] [myc] (EXCEPTION [xexc] [yexc])
    ->CIRCLE|SECTOR [mdc] [flow] [fhigh] [msc]
READGRID COORDINATES [fac] 'fname' [idla] [nhedf] [nhedvec] &
    FREE|FORMAT ('form'|[idfm])

This is a group component that includes a CGRID and a READGRID component.

Examples

from rompy_swan.components.cgrid import CURVILINEAR
cgrid = CURVILINEAR(
    mxc=199,
    myc=199,
    readcoord=dict(fname="./coords.txt"),
    spectrum=dict(mdc=36, flow=0.04, fhigh=1.0),
)
print(cgrid.render())
CGRID CURVILINEAR mxc=199 myc=199 CIRCLE mdc=36 flow=0.04 fhigh=1.0
READGRID COORDINATES fac=1.0 fname='./coords.txt' idla=1 nhedf=0 nhedvec=0 FREE

Fields:

Validators:

model_type pydantic-field

model_type: Literal["curvilinear", "CURVILINEAR"] = (
    "curvilinear"
)

Model type discriminator

mxc pydantic-field

mxc: int

Number of meshes in computational grid in ξ-direction (this number is one less than the number of grid points in this domain).

myc pydantic-field

myc: int

Number of meshes in computational grid in η-direction (this number is one less than the number of grid points in this domain).

xexc pydantic-field

xexc: Optional[float] = None

the value which the user uses to indicate that a grid point is to be ignored in the computations (this value is provided by the user at the location of the x-coordinate considered in the file of the x-coordinates, see command READGRID COOR).

yexc pydantic-field

yexc: Optional[float] = None

the value which the user uses to indicate that a grid point is to be ignored in the computations (this value is provided by the user at the location of the y-coordinate considered in the file of the y-coordinates, see command READGRID COOR).

readcoord pydantic-field

readcoord: READCOORD

Grid coordinates reader.

exception property

exception

format_repr property

format_repr

spectrum pydantic-field

spectrum: SPECTRUM

Spectrum subcomponent

xexc_and_yexc_or_neither pydantic-validator

xexc_and_yexc_or_neither() -> CURVILINEAR

cmd

cmd() -> str

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.

UNSTRUCTURED pydantic-model

UNSTRUCTURED(**data: Any)

Bases: CGRID

SWAN unstructured computational grid.

CGRID UNSTRUCTURED CIRCLE|SECTOR [mdc] [flow] [fhigh] [msc]
READGRID UNSTRUCTURED [grid_type] ('fname')

This is a group component that includes a CGRID and a READGRID component.

Examples

from rompy_swan.components.cgrid import UNSTRUCTURED
cgrid = UNSTRUCTURED(
    grid_type="adcirc",
    spectrum=dict(mdc=36, flow=0.04, fhigh=1.0),
)
print(cgrid.render())
CGRID UNSTRUCTURED CIRCLE mdc=36 flow=0.04 fhigh=1.0
READGRID UNSTRUCTURED ADCIRC

Fields:

Validators:

model_type pydantic-field

model_type: Literal['unstructured'] = 'unstructured'

Model type discriminator

grid_type pydantic-field

grid_type: Literal["adcirc", "triangle", "easymesh"] = (
    "adcirc"
)

Unstructured grid type

fname pydantic-field

fname: Optional[str] = None

Name of the file containing the unstructured grid

spectrum pydantic-field

spectrum: SPECTRUM

Spectrum subcomponent

check_fname_required pydantic-validator

check_fname_required() -> UNSTRUCTURED

Check that fname needs to be provided.

cmd

cmd() -> str

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.