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

Finite-difference divergence operator for two vector components. More...

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

Go to the source code of this file.

Classes

struct  SimDivergenceOperatorConfig
 Configuration for a finite-difference vector divergence operator. More...
 

Macros

#define SIM_DIVERGENCE_AXIS_AUTO   ((size_t)SIZE_MAX)
 

Typedefs

typedef enum SimDivergenceStencil SimDivergenceStencil
 Finite-difference stencils available for divergence derivatives.
 
typedef struct SimDivergenceOperatorConfig SimDivergenceOperatorConfig
 Configuration for a finite-difference vector divergence operator.
 

Enumerations

enum  SimDivergenceStencil {
  SIM_DIVERGENCE_STENCIL_CENTRAL_2 = 0 , SIM_DIVERGENCE_STENCIL_CENTRAL_4 , SIM_DIVERGENCE_STENCIL_FORWARD_1 , SIM_DIVERGENCE_STENCIL_BACKWARD_1 ,
  SIM_DIVERGENCE_STENCIL_FORWARD_2 , SIM_DIVERGENCE_STENCIL_BACKWARD_2
}
 Finite-difference stencils available for divergence derivatives. More...
 

Functions

SimResult sim_add_divergence_operator (struct SimContext *context, const SimDivergenceOperatorConfig *config, size_t *out_index)
 Register a finite-difference divergence operator.
 
SimResult sim_divergence_config (struct SimContext *context, size_t operator_index, SimDivergenceOperatorConfig *out_config)
 Copy the current divergence configuration from a registered operator.
 
SimResult sim_divergence_update (struct SimContext *context, size_t operator_index, const SimDivergenceOperatorConfig *config)
 Replace the configuration of a registered divergence operator.
 

Detailed Description

Finite-difference divergence operator for two vector components.

Enumeration Type Documentation

◆ SimDivergenceStencil

Finite-difference stencils available for divergence derivatives.

Enumerator
SIM_DIVERGENCE_STENCIL_CENTRAL_2 

Second-order central difference.

SIM_DIVERGENCE_STENCIL_CENTRAL_4 

Fourth-order central difference.

SIM_DIVERGENCE_STENCIL_FORWARD_1 

First-order forward difference.

SIM_DIVERGENCE_STENCIL_BACKWARD_1 

First-order backward difference.

SIM_DIVERGENCE_STENCIL_FORWARD_2 

Second-order forward difference.

SIM_DIVERGENCE_STENCIL_BACKWARD_2 

Second-order backward difference.

Function Documentation

◆ sim_add_divergence_operator()

SimResult sim_add_divergence_operator ( struct SimContext context,
const SimDivergenceOperatorConfig config,
size_t *  out_index 
)

Register a finite-difference divergence operator.

Parameters
contextSimulation context that will own the operator.
configOptional divergence 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_divergence_config()

SimResult sim_divergence_config ( struct SimContext context,
size_t  operator_index,
SimDivergenceOperatorConfig out_config 
)

Copy the current divergence configuration from a registered operator.

Parameters
contextSimulation context containing the operator.
operator_indexIndex returned by sim_add_divergence_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 divergence state.

◆ sim_divergence_update()

SimResult sim_divergence_update ( struct SimContext context,
size_t  operator_index,
const SimDivergenceOperatorConfig config 
)

Replace the configuration of a registered divergence operator.

config is required. The replacement is normalized and field compatibility is checked before storing it.

Parameters
contextSimulation context containing the operator.
operator_indexIndex of the divergence operator to update.
configReplacement divergence configuration.
Returns
SIM_RESULT_OK on success, or an error code from argument validation, lookup, state validation, or field compatibility checks.