Oakfield API Documentation 1.0.0
Numerical core APIs
Loading...
Searching...
No Matches
spatial_derivative.h File Reference

1D spatial derivative operator (finite differences with periodic boundary). More...

#include "oakfield/operator_split.h"
#include <stdbool.h>
#include <stddef.h>
Include dependency graph for spatial_derivative.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  SimSpatialDerivativeOperatorConfig
 Configuration for the spatial derivative operator. More...
 

Typedefs

typedef enum SimSpatialDerivativeMethod SimSpatialDerivativeMethod
 Finite-difference stencil used by the spatial derivative operator.
 
typedef struct SimSpatialDerivativeOperatorConfig SimSpatialDerivativeOperatorConfig
 Configuration for the spatial derivative operator.
 

Enumerations

enum  SimSpatialDerivativeMethod { SIM_SPATIAL_DERIVATIVE_METHOD_CENTRAL = 0 , SIM_SPATIAL_DERIVATIVE_METHOD_FORWARD = 1 , SIM_SPATIAL_DERIVATIVE_METHOD_BACKWARD = 2 }
 Finite-difference stencil used by the spatial derivative operator. More...
 

Functions

const char * sim_spatial_derivative_method_name (SimSpatialDerivativeMethod method)
 Return the schema name for a spatial-derivative stencil.
 
bool sim_spatial_derivative_method_from_string (const char *name, SimSpatialDerivativeMethod *out_method)
 Parse a spatial-derivative stencil name.
 
SimResult sim_add_spatial_derivative_operator (struct SimContext *context, const SimSpatialDerivativeOperatorConfig *config, size_t *out_index)
 Register a 1D spatial derivative operator.
 
SimResult sim_spatial_derivative_config (struct SimContext *context, size_t operator_index, SimSpatialDerivativeOperatorConfig *out_config)
 Copy the current spatial-derivative configuration from a registered operator.
 
SimResult sim_spatial_derivative_update (struct SimContext *context, size_t operator_index, const SimSpatialDerivativeOperatorConfig *config)
 Replace or renormalize a registered spatial-derivative configuration.
 

Detailed Description

1D spatial derivative operator (finite differences with periodic boundary).

Enumeration Type Documentation

◆ SimSpatialDerivativeMethod

Finite-difference stencil used by the spatial derivative operator.

Enumerator
SIM_SPATIAL_DERIVATIVE_METHOD_CENTRAL 

Central difference stencil.

SIM_SPATIAL_DERIVATIVE_METHOD_FORWARD 

Forward difference stencil.

SIM_SPATIAL_DERIVATIVE_METHOD_BACKWARD 

Backward difference stencil.

Function Documentation

◆ sim_add_spatial_derivative_operator()

SimResult sim_add_spatial_derivative_operator ( struct SimContext context,
const SimSpatialDerivativeOperatorConfig config,
size_t *  out_index 
)

Register a 1D spatial derivative operator.

Parameters
contextSimulation context that will own the operator.
configOptional derivative configuration; NULL selects normalized defaults.
[out]out_indexOptional destination for the registered operator index.
Returns
SIM_RESULT_OK on success, or an error code from argument validation, field compatibility checks, allocation, or split registration.

◆ sim_spatial_derivative_config()

SimResult sim_spatial_derivative_config ( struct SimContext context,
size_t  operator_index,
SimSpatialDerivativeOperatorConfig out_config 
)

Copy the current spatial-derivative configuration from a registered operator.

Parameters
contextSimulation context containing the operator.
operator_indexIndex returned by sim_add_spatial_derivative_operator().
[out]out_configReceives the normalized configuration.
Returns
SIM_RESULT_OK on success, SIM_RESULT_INVALID_ARGUMENT for NULL pointers, SIM_RESULT_NOT_FOUND for a missing operator, or SIM_RESULT_INVALID_STATE when the operator has no derivative state.

◆ sim_spatial_derivative_method_from_string()

bool sim_spatial_derivative_method_from_string ( const char *  name,
SimSpatialDerivativeMethod out_method 
)

Parse a spatial-derivative stencil name.

Parameters
nameLowercase schema name such as "central", "forward", or "backward".
[out]out_methodReceives the parsed method on success.
Returns
true when name maps to a known method; false otherwise.

◆ sim_spatial_derivative_method_name()

const char * sim_spatial_derivative_method_name ( SimSpatialDerivativeMethod  method)

Return the schema name for a spatial-derivative stencil.

Parameters
methodStencil enum value.
Returns
Stable lowercase method name, or "central" for unknown values.

◆ sim_spatial_derivative_update()

SimResult sim_spatial_derivative_update ( struct SimContext context,
size_t  operator_index,
const SimSpatialDerivativeOperatorConfig config 
)

Replace or renormalize a registered spatial-derivative configuration.

Passing NULL for config keeps the current configuration and reapplies normalization. A successful update refreshes symbolic state and invalidates the scheduler plan.

Parameters
contextSimulation context containing the operator.
operator_indexIndex of the spatial-derivative operator to update.
configOptional replacement configuration.
Returns
SIM_RESULT_OK on success, or an error code from lookup, field compatibility checks, or state validation.