> ## Documentation Index
> Fetch the complete documentation index at: https://developer.synopsys.com/llms.txt
> Use this file to discover all available pages before exploring further.

# utility:convert to field

**Version: 0.0.0**

## Description

Creates a scalar or vector field from numeric data. Converts scalar values or vectors into a DPF field with specified properties.

## Inputs

This table lists the input pins for this operator. Input pins define the data that the operator requires to perform its operation.
Some inputs are required, while others are optional and provide additional configuration.
Each parameter is detailed in the sections that follow the table.

| Pin number | Name | Status | Expected type(s) |
| - | - | - | - |
| **0** | [double\_or\_vector\_double](#input_0) | | [`double`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#standard-types), [`vector<double>`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#standard-types) |
| **1** | [unit](#input_1) | | [`string`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#standard-types) |
| **2** | [location](#input_2) | | [`string`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#standard-types) |
| **3** | [num\_entities](#input_3) | | [`int32`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#standard-types) |
| **4** | [num\_components](#input_4) | | [`int32`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#standard-types) |
| **5** | [scoping](#input_5) | | [`scoping`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#scoping) |

### double\_or\_vector\_double (Pin 0)

* **Required:** No
* **Expected type(s):** [`double`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#standard-types), [`vector<double>`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#standard-types)

Data of the field. Default is 0-field. Specify a double to create a field with uniform values, or a vector for explicit data per entity

### unit (Pin 1)

* **Required:** No
* **Expected type(s):** [`string`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#standard-types)

Unit symbol (m, Hz, kg, ...). Default is dimensionless

### location (Pin 2)

* **Required:** No
* **Expected type(s):** [`string`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#standard-types)

Location of the field: 'Nodal', 'ElementalNodal', 'Elemental', etc. Default is 'numeric'

### num\_entities (Pin 3)

* **Required:** No
* **Expected type(s):** [`int32`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#standard-types)

Number of field entities. Default is 1, or the size of the scoping if provided

### num\_components (Pin 4)

* **Required:** No
* **Expected type(s):** [`int32`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#standard-types)

Number of field components per entity. Default is 1 for scalar, >1 for vector

### scoping (Pin 5)

* **Required:** No
* **Expected type(s):** [`scoping`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#scoping)

Scoping defining entity IDs and locations. If provided, overrides num\_entities

## Outputs

This table lists the output pins for this operator.
Output pins provide the results of the operator's computation and can be connected to inputs of other operators or retrieved for further processing.
Each output is detailed in the sections that follow the table.

| Pin number | Name | Expected type(s) |
| - | - | - |
| **0** | [field](#output_0) | [`field`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#field) |

### field (Pin 0)

* **Expected type(s):** [`field`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#field)

Generated field with specified data and properties

## Configurations

This operator supports [configuration options](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/operator-configurations.md) that modify its behavior.

### [mutex](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/operator-configurations.md#mutex)

* **Expected type(s):** [`bool`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#standard-types)
* **Default value:** false

If this option is set to true, the shared memory is prevented from being simultaneously accessed by multiple threads.

## Scripting

This operator can be accessed through scripting interfaces using these identifiers.

**Category**: utility

**Plugin**: core

**Scripting name**: scalars\_to\_field

**Full name**: utility.scalars\_to\_field

**Internal name**: fieldify

**License**: None

## Examples

These examples demonstrate how to use this operator in different programming environments.
Each example shows how to instantiate the operator, connect the required inputs, and retrieve the output.

<details>
  <summary>C++</summary>

  ```cpp theme={null}
  #include "dpf_api.h"

  ansys::dpf::Operator op("fieldify"); // operator instantiation
  op.connect(0, my_double_or_vector_double);
  op.connect(1, my_unit);
  op.connect(2, my_location);
  op.connect(3, my_num_entities);
  op.connect(4, my_num_components);
  op.connect(5, my_scoping);
  ansys::dpf::Field my_field = op.getOutput<ansys::dpf::Field>(0);
  ```
</details>

<details>
  <summary>CPython</summary>

  ```python theme={null}
  import ansys.dpf.core as dpf

  op = dpf.operators.utility.scalars_to_field() # operator instantiation
  op.inputs.double_or_vector_double.connect(my_double_or_vector_double)
  op.inputs.unit.connect(my_unit)
  op.inputs.location.connect(my_location)
  op.inputs.num_entities.connect(my_num_entities)
  op.inputs.num_components.connect(my_num_components)
  op.inputs.scoping.connect(my_scoping)
  my_field = op.outputs.field()
  ```
</details>

<details>
  <summary>IPython</summary>

  ```python theme={null}
  import mech_dpf
  import Ans.DataProcessing as dpf

  op = dpf.operators.utility.scalars_to_field() # operator instantiation
  op.inputs.double_or_vector_double.Connect(my_double_or_vector_double)
  op.inputs.unit.Connect(my_unit)
  op.inputs.location.Connect(my_location)
  op.inputs.num_entities.Connect(my_num_entities)
  op.inputs.num_components.Connect(my_num_components)
  op.inputs.scoping.Connect(my_scoping)
  my_field = op.outputs.field.GetData()
  ```
</details>

## Changelog

* Version 0.0.0: Initial release.
