cmd

package
v0.0.0-...-88f8085 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Copyright © 2020 NAME HERE <EMAIL ADDRESS>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright © 2020 NAME HERE <EMAIL ADDRESS>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright © 2020 NAME HERE <EMAIL ADDRESS>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var OneDCmd = &cobra.Command{
	Use:   "1D",
	Short: "One Dimensional Model Problem Solutions",
	Long: `
Executes the Nodal Discontinuous Galerkin solver for a variety of model problems, with
optional live plots of the solutions. For example:

gocfd 1D -graph`,
	Run: func(cmd *cobra.Command, args []string) {
		m1d := &Model1D{}
		fmt.Println("1D called")
		mr, _ := cmd.Flags().GetInt("model")
		m1d.ModelRun = ModelType1D(mr)
		dr, _ := cmd.Flags().GetInt("delay")
		m1d.Delay = time.Duration(dr)
		Casep, _ := cmd.Flags().GetInt("case")
		m1d.Case = Euler1D.CaseType(Casep)
		m1d.XMax, _ = cmd.Flags().GetFloat64("xMax")
		m1d.FinalTime, _ = cmd.Flags().GetFloat64("finalTime")
		m1d.CFL, _ = cmd.Flags().GetFloat64("CFL")
		m1d.Graph, _ = cmd.Flags().GetBool("graph")
		m1d.N, _ = cmd.Flags().GetInt("n")
		m1d.K, _ = cmd.Flags().GetInt("k")
		m1d.CFL = LimitCFL(m1d.ModelRun, m1d.CFL)
		Run1D(m1d)
	},
}

OneDCmd represents the 1D command

View Source
var TwoDCmd = &cobra.Command{
	Use:   "2D",
	Short: "Two dimensional solver, able to read grid files and output solutions",
	Long:  `Two dimensional solver, able to read grid files and output solutions`,
	Run: func(cmd *cobra.Command, args []string) {
		var (
			err error
		)
		fmt.Println("2D called")
		m2d := &Model2D{}
		if m2d.GridFile, err = cmd.Flags().GetString("gridFile"); err != nil {
			panic(err)
		}
		if m2d.ICFile, err = cmd.Flags().GetString("inputConditionsFile"); err != nil {
			panic(err)
		}
		m2d.Graph, _ = cmd.Flags().GetBool("graph")
		m2d.GraphField, _ = cmd.Flags().GetInt("graphField")
		ps, _ := cmd.Flags().GetInt("plotSteps")
		m2d.PlotSteps = ps
		dr, _ := cmd.Flags().GetInt("delay")
		m2d.Delay = time.Duration(dr) * time.Millisecond
		m2d.ParallelProcLimit, _ = cmd.Flags().GetInt("parallelProcs")
		m2d.Zoom, _ = cmd.Flags().GetFloat64("zoom")
		m2d.TranslateX, _ = cmd.Flags().GetFloat64("translateX")
		m2d.TranslateY, _ = cmd.Flags().GetFloat64("translateY")
		fmin, _ := cmd.Flags().GetFloat64("plotMin")
		fmax, _ := cmd.Flags().GetFloat64("plotMax")
		m2d.Profile, _ = cmd.Flags().GetBool("profile")
		if fmin != -1000 {
			m2d.fminP = &fmin
		}
		if fmax != -1000 {
			m2d.fmaxP = &fmax
		}
		ip := processInput(m2d)
		Run2D(m2d, ip)
	},
}

TwoDCmd represents the 2D command

Functions

func Defaults

func Defaults(model ModelType1D) (CFL, XMax float64, N, K, Case int)

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func LimitCFL

func LimitCFL(model ModelType1D, CFL float64) (CFLNew float64)

func Run1D

func Run1D(m1d *Model1D)

func Run2D

func Run2D(m2d *Model2D, ip *Euler2D.InputParameters)

Types

type Model

type Model interface {
	Run(graph bool, graphDelay ...time.Duration)
}

type Model1D

type Model1D struct {
	K, N                 int // Number of elements, Polynomial Degree
	Delay                time.Duration
	ModelRun             ModelType1D
	CFL, FinalTime, XMax float64
	Case                 Euler1D.CaseType
	Graph                bool
}

type Model2D

type Model2D struct {
	GridFile                     string
	ICFile                       string
	Graph                        bool
	GraphField                   int
	PlotSteps                    int
	Delay                        time.Duration
	ParallelProcLimit            int
	Profile                      bool
	Zoom, TranslateX, TranslateY float64
	// contains filtered or unexported fields
}

type ModelType1D

type ModelType1D uint8
const (
	M_1DAdvect ModelType1D = iota
	M_1DMaxwell
	M_1DEuler
	M_1DAdvectDFR
	M_1DMaxwellDFR
	M_1DEulerDFR_Roe
	M_1DEulerDFR_LF
	M_1DEulerDFR_Ave
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL