Skip to content

Commit

Permalink
Ensure that OpenFAST is run from project directory
Browse files Browse the repository at this point in the history
  • Loading branch information
deslaughter committed Dec 11, 2024
1 parent afbf7c2 commit da3f54c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
14 changes: 12 additions & 2 deletions evaluate.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,18 @@ func (eval *Evaluate) OP(ctx context.Context, model *Model, c *Case, op *Conditi
}
defer logFile.Close()

// Create command, get output pipe, set stderr to stdout, start command
cmd := exec.CommandContext(ctx, eval.ExecPath, mainPath)
// Get project directory
projectDir := filepath.Dir(caseDir)

// Get relative path from project directory to main file
relPath, err := filepath.Rel(projectDir, mainPath)
if err != nil {
return err
}

// Create command, get output pipe, set stderr to stdout and start command
cmd := exec.CommandContext(ctx, eval.ExecPath, relPath)
cmd.Dir = projectDir
outputReader, err := cmd.StdoutPipe()
if err != nil {
return err
Expand Down
12 changes: 11 additions & 1 deletion viz/viz.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,18 @@ func (opts *Options) GenerateModeData(execPath string, op *lin.LinOP, modeIDs []
}
defer logFile.Close()

// Get the case directory
projectDir := filepath.Dir(filepath.Dir(vizFilePath))

// Get relative path from project directory to main file
relPath, err := filepath.Rel(projectDir, vizFilePath)
if err != nil {
return nil, err
}

// Create command to generate vtk output and run it
cmd := exec.Command(execPath, "-VTKLin", vizFilePath)
cmd := exec.Command(execPath, "-VTKLin", relPath)
cmd.Dir = projectDir
cmd.Stdout = logFile
cmd.Stderr = logFile
err = cmd.Run()
Expand Down

0 comments on commit da3f54c

Please sign in to comment.