rompy.swan.components.cgrid.UNSTRUCTURED#

pydantic model rompy.swan.components.cgrid.UNSTRUCTURED[source]#

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

In [27]: from rompy.swan.components.cgrid import UNSTRUCTURED

In [28]: cgrid = UNSTRUCTURED(
   ....:     grid_type="adcirc",
   ....:     spectrum=dict(mdc=36, flow=0.04, fhigh=1.0),
   ....: )
   ....: 

In [29]: print(cgrid.render())
CGRID UNSTRUCTURED CIRCLE mdc=36 flow=0.04 fhigh=1.0
READGRID UNSTRUCTURED ADCIRC

Show JSON schema
{
   "title": "UNSTRUCTURED",
   "description": "SWAN unstructured computational grid.\n\n.. code-block:: text\n\n    CGRID UNSTRUCTURED CIRCLE|SECTOR [mdc] [flow] [fhigh] [msc]\n    READGRID UNSTRUCTURED [grid_type] ('fname')\n\nThis is a group component that includes a `CGRID` and a `READGRID` component.\n\nExamples\n--------\n\n.. ipython:: python\n    :okwarning:\n\n    from rompy.swan.components.cgrid import UNSTRUCTURED\n    cgrid = UNSTRUCTURED(\n        grid_type=\"adcirc\",\n        spectrum=dict(mdc=36, flow=0.04, fhigh=1.0),\n    )\n    print(cgrid.render())",
   "type": "object",
   "properties": {
      "model_type": {
         "const": "unstructured",
         "default": "unstructured",
         "description": "Model type discriminator",
         "title": "Model Type",
         "type": "string"
      },
      "spectrum": {
         "$ref": "#/$defs/SPECTRUM",
         "description": "Spectrum subcomponent"
      },
      "grid_type": {
         "default": "adcirc",
         "description": "Unstructured grid type",
         "enum": [
            "adcirc",
            "triangle",
            "easymesh"
         ],
         "title": "Grid Type",
         "type": "string"
      },
      "fname": {
         "anyOf": [
            {
               "maxLength": 36,
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "Name of the file containing the unstructured grid",
         "title": "Fname"
      }
   },
   "$defs": {
      "SPECTRUM": {
         "additionalProperties": false,
         "description": "SWAN spectrum specification.\n\n.. code-block:: text\n\n    ->CIRCLE|SECTOR ([dir1] [dir2]) [mdc] [flow] [fhigh] [msc]\n\nNotes\n-----\n\nDirections in the spectra are defined either as a CIRCLE or as a SECTOR. In the\ncase of a SECTOR, both `dir1` and `dir2` must be specified. In the case of a\nCIRCLE, neither `dir1` nor `dir2` should be specified.\n\nAt least two of `flow`, `fhigh` and `msc` must be specified in which case the\nthird parameter will be calculated by SWAN such that the frequency resolution\n`df/f = 0.1` (10% increments).\n\nExamples\n--------\n\n.. ipython:: python\n    :okwarning:\n\n    from rompy.swan.subcomponents.spectrum import SPECTRUM\n    spec = SPECTRUM(mdc=36, flow=0.04, fhigh=1.0)\n    print(spec.render())\n    spec = SPECTRUM(mdc=36, dir1=0, dir2=180, flow=0.04, msc=31)\n    print(spec.render())",
         "properties": {
            "model_type": {
               "default": "spectrum",
               "description": "Model type discriminator",
               "enum": [
                  "spectrum",
                  "SPECTRUM"
               ],
               "title": "Model Type",
               "type": "string"
            },
            "mdc": {
               "description": "Number of meshes in theta-space. In the case of CIRCLE, this is the number of subdivisions of the 360 degrees of a circle so `dtheta = [360]/[mdc]` is the spectral directional resolution. In the case of SECTOR, `dtheta = ([dir2] - [dir1])/[mdc]`. The minimum number of directional bins is 3 per directional quadrant.",
               "title": "Mdc",
               "type": "integer"
            },
            "flow": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "Lowest discrete frequency that is used in the calculation (in Hz).",
               "title": "Flow"
            },
            "fhigh": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "Highest discrete frequency that is used in the calculation (in Hz).",
               "title": "Fhigh"
            },
            "msc": {
               "anyOf": [
                  {
                     "minimum": 3,
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "One less than the number of frequencies. This defines the grid resolution in frequency-space between the lowest discrete frequency `flow` and the highest discrete frequency `fhigh`. This resolution is not constant, since the frequencies are distributed logarithmical: `fi+1 = yfi` where `y` is a constant. The minimum number of frequencies is 4",
               "title": "Msc"
            },
            "dir1": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The direction of the right-hand boundary of the sector when looking outward from the sector (required for option SECTOR) in degrees.",
               "title": "Dir1"
            },
            "dir2": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The direction of the left-hand boundary of the sector when looking outward from the sector (required for option SECTOR) in degrees.",
               "title": "Dir2"
            }
         },
         "required": [
            "mdc"
         ],
         "title": "SPECTRUM",
         "type": "object"
      }
   },
   "additionalProperties": false,
   "required": [
      "spectrum"
   ]
}

Fields:
Validators:
field fname: str | None = None#

Name of the file containing the unstructured grid

Constraints:
  • max_length = 36

Validated by:
field grid_type: Literal['adcirc', 'triangle', 'easymesh'] = 'adcirc'#

Unstructured grid type

Validated by:
field model_type: Literal['unstructured'] = 'unstructured'#

Model type discriminator

Validated by:
field spectrum: SPECTRUM [Required]#

Spectrum subcomponent

Validated by:
validator check_fname_required  »  all fields[source]#

Check that fname needs to be provided.

cmd() str[source]#

Return the string or list of strings to render the component to the CMD.