optionals: Optional input files

Description Usage Arguments Value Note Examples

View source: R/optionals.R

Description

Initialise optional input files for TELEMAC-2D.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
optionals(x, fname, ...)

## S3 method for class 'character'
optionals(x, fname, ...)

## S3 method for class 'list'
optionals(x, fname, ...)

## S3 method for class 't2d_opt'
optionals(x, fname, ..., vals)

## S3 method for class 't2d_opt'
print(x, ..., n = 10)

## S3 method for class 't2d_opt_LINES'
print(x, ..., n = 10)

Arguments

x

Either: a character vector where each element represents a line of content for the optional input file; a list with multiple character vectors to provide the contents for multiple optional files; an object of type t2d_opt to add further optional file(s).

fname

character, file name(s).

...

Arguments passed to or from other methods.

vals

If x is a t2d_opt object: a character vector or a list with the values for the additional optional input file(s).

n

Maximum number of file lines to print.

Value

An object of type t2d_opt consisting of a data.frame with elements file, file name(s) of the optional input file(s), and value, an object of type t2d_opt_LINES that is essentially a list of character vectors where each element represents the contents of an optional input file.

Note

When providing optional input files to a t2d setup the user still needs to add the respective keywords to the steering (cas) file, otherwise the optional input will be ignored! The reason is that many optional input files require additional settings (keywords in the cas file) that cannot be foreseen.

So far only text-based optional input files are supported (e.g. SECTIONS INPUT FILE or FORMATTED DATA FILE) but no binary files.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# t2d_opt object
opt_obj <- optionals(c("# test file", "col1 col2", "1 2", "3 4"), fname = "optional.txt")
opt_obj
str(opt_obj)

# values (lines of the file) as t2d_opt_LINES object
opt_obj$value
str(opt_obj$value)

# multiple optional files
opt_obj <- optionals(list(c("# test file", "col1 col2", "1 2", "3 4"),
                          c("# test file 2", "col1 col2", "5 6", "7 8")),
                     fname = c("optional.txt", "optional2.txt"))
print(opt_obj, n = 4)

# change individual values via list methods
opt_obj$value[[1]][3] <- c("10 20")
opt_obj

tpilz/telemac documentation built on Feb. 10, 2022, 2:12 p.m.