petsc-3.7.1 2016-05-15
Report Typos and Errors

# TSSetCostIntegrand

Sets the routine for evaluating the integral term in one or more cost functions

### Synopsis

    #include "petscts.h"
    PetscErrorCode  TSSetCostIntegrand(TS ts,PetscInt numcost,PetscErrorCode (*rf)(TS,PetscReal,Vec,Vec,void*),
                                                              PetscErrorCode (*drdyf)(TS,PetscReal,Vec,Vec*,void*),
                                                              PetscErrorCode (*drdpf)(TS,PetscReal,Vec,Vec*,void*),
                                                              PetscBool fwd,void *ctx)

Logically Collective on TS Many br

### Input Parameters

| ts | - the TS context obtained from TSCreate() Many br
| numcost | - number of gradients to be computed, this is the number of cost functions Many br
| rf | - routine for evaluating the integrand function Many br
| drdyf | - function that computes the gradients of the r's with respect to y,NULL if not a function y Many br
| drdpf | - function that computes the gradients of the r's with respect to p, NULL if not a function of p Many br
| fwd － flag indicating whether to evaluate cost integral in the forward run or the adjoint run | - - ctx - [optional] user-defined context for private data for the function evaluation routine (may be NULL) Many br

### Calling sequence of rf

        rf(TS ts,PetscReal t,Vec y,Vec f[],void *ctx);

| t | - current timestep Many br
| y | - input vector Many br
| f | - function result; one vector entry for each cost function Many br
| ctx | - [optional] user-defined function context Many br

### Calling sequence of drdyf

       PetscErroCode drdyf(TS ts,PetscReal t,Vec y,Vec *drdy,void *ctx);

### Calling sequence of drdpf

       PetscErroCode drdpf(TS ts,PetscReal t,Vec y,Vec *drdp,void *ctx);

Many br

Notes: For optimization there is generally a single cost function, numcost = 1. For sensitivities there may be multiple cost functions Many br

### Keywords

TS, sensitivity analysis, timestep, set, quadrature, function

### See Also

TSAdjointSetRHSJacobian(),TSGetCostGradients(), TSSetCostGradients()

Level:intermediate
Location:src/ts/interface/ts.c
Index of all TS routines
Table of Contents for all manual pages
Index of all manual pages