2306OpenFOAM编程

汪洋

2023年8月08日

Linux发行版

  • Linux内核 + 其他软件 = 操作系统
  • 所以市场上有许多发型版本
    • Debian->Ubuntu, Arch->Manjaro

安装软件:包管理

包是什么?

  • 含有程序的二进制文件和库文件
  • 也包含应用程序所需的系统元信息
  • 程序通过包来安装
  • Debian通常使用.deb格式

包管理是什么?

如何使用


                        $ sudo apt update
                        $ sudo apt install "packagename"
                        $ sudo apt remove "packagename"
                        $ sudo apt search "packagename"
                        $ sudo apt download "packagename"
                    
                    

apt vs apt-get

换源

一个常见包的组成


                        $ tree -L 3                                                                                                                                                                             ─╯
                        .
                        ├── control
                        ├── control.tar.xz
                        ├── data.tar.xz
                        ├── debian-binary
                        ├── htop_2.2.0-2build1_amd64.deb
                        ├── md5sums
                        └── usr
                            ├── bin
                            │   └── htop
                            └── share
                                ├── applications
                                ├── doc
                                ├── man
                                └── pixmaps
    
                        7 directories, 7 files
                    

DEMO

编辑器

  1. VIM
  2. VSCode
  3. emacs

VIM

VIM三种模式

  • NORMAL
  • INSERT
  • VISUAL

建议

  • 学习vimtutor以及其他资料
  • 适可而止的配置vimrc
  • 目的:为了更好的成长

VIM Cheat Sheet

DEMO

vim configure file


                let mapleader=" "
                set nu
                syntax on
                set hlsearch
                set tabstop=4
                set autoindent

                set cursorline
                set wrap
                set showcmd
                set wildmenu " command completion

                set hlsearch
                exec "nohlsearch"
                set incsearch
                set ignorecase
                set smartcase

                noremap K 10k
                noremap J 10j

                noremap  :nohlsearch

                " key mapping

                map s 
                map S :w
                map Q :q
                map R :source $MYVIMRC
                imap jk 
                map sh :split
                map sv :vsplit

                map h h
                map j j
                map k k
                map l l
                nnoremap  >
                nnoremap  <
                nnoremap  +
                nnoremap  -

                map  :m -2
                map  :m +1
                map tu :tabe
                map tn :+tabnext
                map tp :-tabnext

                call plug#begin('~/.vim/plugged')

                Plug 'vim-airline/vim-airline'

                Plug 'ghifarit53/tokyonight-vim'

                call plug#end()

                let g:tokyonight_style = 'night'
                let g:tokyonight_enable_italic = 1
                colorscheme tokyonight
                
                

VSCode

VSCode CPP配置

  • tasks.json
  • launch.json
  • c_cpp_properties.json

tasks.json

                        
                            {
                                "tasks": [
                                    {
                                        "type": "cppbuild",
                                        "label": "wangyang",
                                        "command": "/usr/bin/clang++",
                                        "args": [
                                            "-std=c++17",
                                            "-stdlib=libc++",
                                            "-g",
                                            "${file}",
                                            "-o",
                                            "${fileDirname}/${fileBasenameNoExtension}"
                                        ],
                                        "options": {
                                            "cwd": "${fileDirname}"
                                        },
                                        "problemMatcher": [
                                            "$gcc"
                                        ],
                                        "group": {
                                            "kind": "build",
                                            "isDefault": true
                                        },
                                        "detail": "调试器生成的任务。"
                                    }
                                ],
                                "version": "2.0.0"
                            }
                        
                    

launch.json

                        
                            {
                                // Use IntelliSense to learn about possible attributes.
                                // Hover to view descriptions of existing attributes.
                                // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
                                "version": "0.2.0",
                                "configurations": [
                                  {
                                    "name": "C/C++: clang++ build and debug active file",
                                    "type": "cppdbg",
                                    "request": "launch",
                                    "program": "${fileDirname}/${fileBasenameNoExtension}",
                                    "args": [],
                                    "stopAtEntry": true,
                                    "cwd": "${workspaceFolder}",
                                    "environment": [],
                                    "externalConsole": false,
                                    "MIMode": "lldb",
                                    "preLaunchTask": "wangyang"
                                  }
                                ]
                              }
                        
                    

c_cpp_properties.json

                        
                            {
                                "configurations": [
                                    {
                                        "name": "Mac",
                                        "includePath": [
                                            "${workspaceFolder}/**"
                                        ],
                                        "defines": [],
                                        "macFrameworkPath": [
                                            "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
                                        ],
                                        "compilerPath": "/usr/bin/clang",
                                        "cStandard": "c17",
                                        "cppStandard": "c++17",
                                        "intelliSenseMode": "macos-clang-arm64"
                                    }
                                ],
                                "version": 4
                            }
                        
                    

DEMO

只要功夫深