├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── ScriptImage.png ├── VSP2CFD.glf └── VspAircraft.stl /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # ========================= 18 | # Operating System Files 19 | # ========================= 20 | 21 | # OSX 22 | # ========================= 23 | 24 | .DS_Store 25 | .AppleDouble 26 | .LSOverride 27 | 28 | # Icon must end with two \r 29 | Icon 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear on external disk 35 | .Spotlight-V100 36 | .Trashes 37 | 38 | # Directories potentially created on remote AFP share 39 | .AppleDB 40 | .AppleDesktop 41 | Network Trash Folder 42 | Temporary Items 43 | .apdisk 44 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Cadence Public License Version 1.0 2 | 3 | May 2021 4 | 5 | BY USING, REPRODUCING, DISTRIBUTING, AND/OR OTHERWISE ACCESSING THIS 6 | TECHNOLOGY, YOU AGREE TO THE TERMS OF THIS CADENCE PUBLIC LICENSE 7 | VERSION 1.0 (THE "AGREEMENT"). 8 | 9 | 1. License Grant. Subject to the terms and conditions specified herein, You 10 | are hereby granted a perpetual, non-exclusive, no-charge license to Use the 11 | Technology for any purpose, which includes without limitation, the right to 12 | access, copy, modify, merge, publish, redistribute, sublicense, and/or sell 13 | (collectively, to "Use") copies of the Technology. 14 | 15 | 2. Distributions. 16 | 17 | i. Copyright Notice and Agreement Text. The Copyright Notice and the full 18 | text of this Cadence Public License Version 1.0 shall be included in all 19 | copies of the Technology, or substantial portions thereof. (For clarity, if 20 | You are redistributing the Technology in source code form, then you 21 | must ensure that the Copyright Notice and Agreement are left intact; if 22 | You are redistributing the Technology in binary or non-source code 23 | form, then you must ensure that the Copyright Notice and Agreement are 24 | reproduced and included in an attribution file, such as a "NOTICES", 25 | "COPYRIGHT", or other equivalent file.) 26 | 27 | ii. Modifications. Any distribution of modified Technology must include a 28 | prominent notice in the corresponding file(s) indicating that the file(s) 29 | was modified by You. You may license Your modifications under different 30 | or additional license terms. 31 | 32 | 3. Endorsement. Neither the name of the copyright holder nor the names of its 33 | contributors may be used to endorse or promote products derived from the 34 | Technology without specific prior written permission. 35 | 36 | 4. Trademarks. Except for attribution purposes (as described in Sec. 2(i), 37 | above) and as may otherwise be agreed in writing, You do not have 38 | permission to use the trade names, trademarks, service marks, or product 39 | names of the copyright holder or contributor(s). 40 | 41 | 5. Termination. 42 | 43 | i. Patent Litigation. If You institute patent litigation against any entity 44 | (including a cross-claim or counterclaim in a lawsuit) alleging that the 45 | Technology constitutes direct or contributory patent infringement, then any 46 | patent licenses granted to You under this Agreement shall terminate as of 47 | the date such litigation is filed. 48 | 49 | ii. Breach. This Agreement, and the license granted hereunder, shall 50 | immediately terminate if You (a) fail to comply with any material terms or 51 | conditions and (b) fail to cure your lack of compliance within a reasonable 52 | time of becoming aware. 53 | 54 | 6. Disclaimer or Warranty. UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 55 | WRITING, THE TECHNOLOGY IS PROVIDED BY THE COPYRIGHT HOLDERS AND 56 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT 57 | NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 58 | PARTICULAR PURPOSE ARE DISCLAIMED. 59 | 60 | 7. Limitation of Liability. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 61 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 62 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 63 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 64 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 65 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 66 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 67 | TECHNOLOGY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 68 | 69 | 8. Stewardship. While everyone is permitted to copy and distribute copies of 70 | this Agreement, it may only be modified by the Steward. The Steward may 71 | publish new versions (including revisions) of the Agreement. For clarity, 72 | the Technology may always be distributed subject to the version of the 73 | Agreement under which it was received. In addition, after a new version of 74 | the Agreement is published, Licensor may elect to distribute the Technology 75 | under the new version. 76 | 77 | 9. Definitions. 78 | 79 | i. "Copyright Notice" means a notice that includes the name of the 80 | copyright holder, a copyright symbol (or equivalent), a date, and, at the 81 | owner's election, a statement of rights. 82 | 83 | ii. "Licensee" means any person or entity that receives the Technology 84 | under this Agreement. 85 | 86 | iii. "Licensor" means any person or entity that distributes the Technology. 87 | 88 | iv. "Steward" means Cadence Design Systems, Inc., which may assign the 89 | responsibility to serve as Steward to a suitable separate entity. 90 | 91 | v. "Technology" means the work of authorship, whether in source code, 92 | binary, or other form, made available under this Agreement, as indicated by 93 | a Copyright Notice that is included in or attached to the Technology. 94 | 95 | vi. "You" (or "Your") means a person or entity exercising permissions 96 | granted by this Agreement. 97 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # VSP2CFD 2 | Copyright 2021 Cadence Design Systems, Inc. All rights reserved worldwide. 3 | 4 | A Glyph script to generate a viscous mesh for VSP generated surface grids. 5 | 6 | ![ScriptImage](https://raw.github.com/pointwise/VSP2CFD/master/ScriptImage.png) 7 | 8 | ## Usage 9 | This script will import a surface mesh generated using OpenVSP and create an unstructured viscous mesh using T-Rex. The parameters driving the meshing process can be found within VSP2CFD.glf under the section titled *User Defined Parameters.* The user has control over the size and resolution of the farfield, the boundary layer meshing parameters, and quality constraints. 10 | 11 | Once the script has finished, a Pointwise project file will be saved to the working directory. The filename of the .pw file has the same base name as the OpenVSP surface grid and is appended with *-Grid*. 12 | 13 | ## Disclaimer 14 | This file is licensed under the Cadence Public License Version 1.0 (the "License"), a copy of which is found in the LICENSE file, and is distributed "AS IS." 15 | TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, CADENCE DISCLAIMS ALL WARRANTIES AND IN NO EVENT SHALL BE LIABLE TO ANY PARTY FOR ANY DAMAGES ARISING OUT OF OR RELATING TO USE OF THIS FILE. 16 | Please see the License for the full text of applicable terms. 17 | -------------------------------------------------------------------------------- /ScriptImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pointwise/VSP2CFD/f2fc6b5460555fb385676dfc108257801fe0949c/ScriptImage.png -------------------------------------------------------------------------------- /VSP2CFD.glf: -------------------------------------------------------------------------------- 1 | ############################################################################# 2 | # 3 | # (C) 2021 Cadence Design Systems, Inc. All rights reserved worldwide. 4 | # 5 | # This sample script is not supported by Cadence Design Systems, Inc. 6 | # It is provided freely for demonstration purposes only. 7 | # SEE THE WARRANTY DISCLAIMER AT THE BOTTOM OF THIS FILE. 8 | # 9 | ############################################################################# 10 | 11 | # 12 | # ============================================================================ 13 | # GENERATE UNSTRUCTURED VOLUME MESH FOR OPENVSP GENERATED SURFACE MESH 14 | # ============================================================================ 15 | # This script will import a surface mesh generated using OpenVSP and create 16 | # an unstructured viscous mesh using T-Rex. The user has control over the 17 | # farfield size and boundary layer resolution. 18 | # 19 | 20 | 21 | #-------------------------------------------------------------- 22 | #-- INITIALIZATION 23 | #-------------------------------------------------------------- 24 | package require PWI_Glyph 25 | pw::Application reset 26 | set cwd [file dirname [info script]] 27 | 28 | 29 | #-------------------------------------------------------------- 30 | #-- USER DEFINED PARAMETERS 31 | #-------------------------------------------------------------- 32 | # Geometry 33 | set fileName "VspAircraft.stl"; # OpenVSP STL filename 34 | set farfieldDiameter 800; # Farfield diameter (40x body length) 35 | 36 | # Boundary Layer Paramters 37 | set maxLayers 100; # Maximum layers for boundary layer region 38 | set initialDs 0.001; # Initial cell height in the boundary layer 39 | set growthRate 1.2; # Growth rate in the boundary layer region 40 | set boundaryDecay 0.95; # Volumetric boundary decay 41 | set farfieldSpacing 40; # Farfield mesh spacing (2x body length) 42 | 43 | # T-Rex Quality Criteria 44 | set fullLayers 0; # Full layers (0 for multi-normals, 1 for single normal) 45 | set collisionBuffer 2; # Collision buffer for colliding fronts 46 | set maxAngle 170; # Max included angle for boundary layer elements 47 | set centroidSkew 1.0; # Max centroid skew for boundary layer elements 48 | 49 | 50 | #-------------------------------------------------------------- 51 | #-- MAIN 52 | #-------------------------------------------------------------- 53 | # Import VSP File 54 | puts "" 55 | puts "Importing $fileName..." 56 | puts "" 57 | 58 | set vspDoms [pw::Grid import [file join $cwd $fileName]] 59 | 60 | # Set connector dimension defaults 61 | pw::Connector setCalculateDimensionMethod Spacing 62 | pw::Connector setCalculateDimensionSpacing $farfieldSpacing 63 | pw::Application setGridPreference Unstructured 64 | 65 | # Find the center of the grid imported from VSP 66 | set vspExtents [pw::Grid getExtents] 67 | 68 | set minExtents [lindex $vspExtents 0] 69 | set maxExtents [lindex $vspExtents 1] 70 | 71 | set center(x) [expr {([lindex $minExtents 0]+[lindex $maxExtents 0])/2.0}] 72 | set center(y) [expr {([lindex $minExtents 1]+[lindex $maxExtents 1])/2.0}] 73 | set center(z) [expr {([lindex $minExtents 2]+[lindex $maxExtents 2])/2.0}] 74 | 75 | # Create semicircular curve 76 | puts "" 77 | puts "Generating farfield domain..." 78 | puts "" 79 | 80 | set dbCurve [pw::Curve create] 81 | 82 | set seg [pw::SegmentCircle create] 83 | $seg addPoint " [expr {($farfieldDiameter/2.0)+$center(x)}] $center(y) $center(z)" 84 | $seg addPoint "-[expr {($farfieldDiameter/2.0)+$center(x)}] $center(y) $center(z)" 85 | $seg setCenterPoint "$center(x) $center(y) $center(z)" 86 | 87 | $dbCurve addSegment $seg 88 | 89 | # Revolve curve to form a sphere for the farfield and create farfield domains 90 | set sphere [pw::Surface create] 91 | $sphere revolve -angle 360.0 $dbCurve "[expr {($farfieldDiameter/2.0)+$center(x)}] $center(y) $center(z)" "1 0 0" 92 | 93 | set farfieldDoms [pw::DomainUnstructured createOnDatabase [list $sphere]] 94 | 95 | # Assemble the block that consists of the VSP grid and the farfield 96 | puts "" 97 | puts "Assembling unstructured block..." 98 | puts "" 99 | 100 | set domList [join [list $vspDoms $farfieldDoms]] 101 | set unsBlock [pw::BlockUnstructured createFromDomains $domList] 102 | 103 | # Setup unstructured block attributes 104 | set solveMode [pw::Application begin UnstructuredSolver [list $unsBlock]] 105 | 106 | $unsBlock setUnstructuredSolverAttribute TRexMaximumLayers $maxLayers 107 | $unsBlock setUnstructuredSolverAttribute TRexFullLayers $fullLayers 108 | $unsBlock setUnstructuredSolverAttribute TRexGrowthRate $growthRate 109 | $unsBlock setUnstructuredSolverAttribute TRexCollisionBuffer $collisionBuffer 110 | $unsBlock setUnstructuredSolverAttribute TRexSkewCriteriaCentroid $centroidSkew 111 | $unsBlock setUnstructuredSolverAttribute TRexSkewCriteriaMaximumAngle $maxAngle 112 | $unsBlock setUnstructuredSolverAttribute BoundaryDecay $boundaryDecay 113 | 114 | # Create and apply the boundary conditions for T-Rex 115 | set wallBC [pw::TRexCondition create] 116 | $wallBC setName "wall" 117 | $wallBC setType "Wall" 118 | $wallBC setSpacing $initialDs 119 | 120 | foreach dom $vspDoms { 121 | $wallBC apply [list $unsBlock $dom] 122 | } 123 | 124 | # Initialize the volume mesh 125 | puts "" 126 | puts "Initializing volume mesh..." 127 | puts "" 128 | 129 | $solveMode run Initialize 130 | $solveMode end 131 | 132 | # Set CAE boundary conditions 133 | puts "" 134 | puts "Applying CAE boundary conditions..." 135 | puts "" 136 | 137 | set caeWallBC [pw::BoundaryCondition create] 138 | $caeWallBC setName "wall" 139 | foreach dom $vspDoms {$caeWallBC apply [list $unsBlock $dom]} 140 | 141 | set caePatchBC [pw::BoundaryCondition create] 142 | $caePatchBC setName "farfield" 143 | foreach dom $farfieldDoms {$caePatchBC apply [list $unsBlock $dom]} 144 | 145 | # Save Pointwise file 146 | set fileRoot [file rootname $fileName] 147 | set fileExport "$fileRoot-Grid.pw" 148 | 149 | puts "" 150 | puts "Writing $fileExport file..." 151 | puts "" 152 | 153 | pw::Application save [file join $cwd $fileExport] 154 | 155 | # Examine grid 156 | puts "Grid Summary" 157 | puts "------------------" 158 | puts "[$unsBlock getCellCount] tet cells" 159 | puts "" 160 | 161 | # Maximum included angle examination 162 | set blkExm [pw::Examine create BlockMaximumAngle] 163 | 164 | $blkExm addEntity $unsBlock 165 | $blkExm setRangeLimits 70.0 170.0 166 | $blkExm examine 167 | 168 | puts "[format "Maximum included angle: %.2f" [$blkExm getMaximum]]" 169 | puts "Number of cells above maximum (170): [$blkExm getAboveRange]" 170 | puts "" 171 | 172 | $blkExm delete 173 | 174 | # Centroid skew examination 175 | set blkExm [pw::Examine create BlockSkewCentroid] 176 | 177 | $blkExm addEntity $unsBlock 178 | $blkExm setRangeLimits 0.0 0.7 179 | $blkExm examine 180 | 181 | puts "[format "Maximum centroid skew: %.2f" [$blkExm getMaximum]]" 182 | puts "Number of cells above maximum (0.7): [$blkExm getAboveRange]" 183 | puts "" 184 | 185 | $blkExm delete 186 | 187 | 188 | # END SCRIPT 189 | 190 | ############################################################################# 191 | # 192 | # This file is licensed under the Cadence Public License Version 1.0 (the 193 | # "License"), a copy of which is found in the included file named "LICENSE", 194 | # and is distributed "AS IS." TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE 195 | # LAW, CADENCE DISCLAIMS ALL WARRANTIES AND IN NO EVENT SHALL BE LIABLE TO 196 | # ANY PARTY FOR ANY DAMAGES ARISING OUT OF OR RELATING TO USE OF THIS FILE. 197 | # Please see the License for the full text of applicable terms. 198 | # 199 | ############################################################################# 200 | --------------------------------------------------------------------------------