Skip to content

Commit

Permalink
Merge branch 'release/0.10.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
philipbelesky committed Nov 22, 2018
2 parents acadb89 + 76fe904 commit 86637c8
Show file tree
Hide file tree
Showing 93 changed files with 29,739 additions and 510 deletions.
52 changes: 52 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
language: generic # Need python and node

cache:
pip: true
bundler: true
npm: true

# Setup pandoc for building
before_install:
- sudo apt-get update -qq
- sudo apt-get install -y pandoc
- sudo apt-get install pandoc-citeproc

script:
- cd site
- bundler install
- npm install
- pyenv install # Need python 3.4 at least for pathlib
- bash ./compile_assets.sh
- touch ./downloads/plugin/groundhog.zip # Fake file for link checking
# Note -d; need to build into subdirectory to simulate GH pages baseURL
- bundle exec jekyll build -d _site/groundhog --config=_config.yml,_config_gh.yml
- htmlproofer ./_site

# Branch whitelist, only for GitHub Pages
branches:
only:
- develop

env:
global:
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true # Speeds up installation of html-proofer

addons:
apt:
packages:
- libcurl4-openssl-dev

sudo: false # Route your build to the container-based infrastructure for a faster build

# Copy compiled site over to Github pages
deploy:
provider: pages
local-dir: ./site/_site/groundhog
target-branch: gh-pages
email: deploy@travis-ci.org
name: Deployment Bot
skip-cleanup: true
github-token: $GITHUB_TOKEN
keep-history: false
on:
branch: develop
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## Changelog

#### [0.10.0] - 2018-11-22
###### Added
- Added the Flow Area component that derives the water level within a defined channel given a defined flow quantity
- Added the Flow Profile component that calculates a series of hydraulic characteristics for a given flow area
- The Slope components will now calculate slope as a ratio

#### [0.9.1] - 2018-05-15
###### Changed
- Plant shower will now do nothing when provided with a negative time value so successional planting schemes are easier to implement
Expand Down Expand Up @@ -79,4 +85,4 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
-->
-->
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![GitHub release](https://img.shields.io/github/release/philipbelesky/groundhog.svg)](https://github.com/philipbelesky/groundhog/releases)
[![Build status](https://ci.appveyor.com/api/projects/status/v54xuu2rea3q4r3p/branch/develop?svg=true)](https://ci.appveyor.com/project/philipbelesky/groundhog/branch/develop)
[![Component Build status](https://ci.appveyor.com/api/projects/status/v54xuu2rea3q4r3p/branch/develop?svg=true)](https://ci.appveyor.com/project/philipbelesky/groundhog/branch/develop)
[![Website Build Status](https://travis-ci.org/philipbelesky/groundhog.svg?branch=develop)](https://travis-ci.org/philipbelesky/groundhog)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/86683403554e426baad9225687d5ca00)](https://www.codacy.com/app/philipbelesky/groundhog?utm_source=github.com&utm_medium=referral&utm_content=philipbelesky/groundhog&utm_campaign=Badge_Grade)

</div>
Expand Down Expand Up @@ -44,4 +45,4 @@ See the [`README.md` file](https://github.com/philipbelesky/groundhog/blob/devel

## License

This project is licensed under the GPL v3 License - see the [`LICENSE` file](https://github.com/philipbelesky/groundhog/blob/develop/LICENSE) for details.
This project is licensed under the GPL v3 License - see the [`LICENSE` file](https://github.com/philipbelesky/groundhog/blob/develop/LICENSE) for details.
4 changes: 0 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
# Build worker image (VM template)
image: Visual Studio 2017

init:
- ps: $env:APPVEYOR_CACHE_SKIP_RESTORE = "true"
- ps: git lfs install --skip-smudge # Don't download lfs files

# Scripts that run after cloning repository
install:
- cd plugin
Expand Down
4 changes: 2 additions & 2 deletions assets/icons.ai
Git LFS file not shown
3 changes: 3 additions & 0 deletions docs/channels/Groundhog - Channels Examples.3dm
Git LFS file not shown
9,088 changes: 9,088 additions & 0 deletions docs/channels/Groundhog - Channels Examples.ghx

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/flows/Groundhog - Flows Examples.ghx
Original file line number Diff line number Diff line change
Expand Up @@ -2525,7 +2525,7 @@
<item name="Optional" type_name="gh_bool" type_code="1">false</item>
<item name="ScrollRatio" type_name="gh_double" type_code="6">0</item>
<item name="SourceCount" type_name="gh_int32" type_code="3">0</item>
<item name="UserText" type_name="gh_string" type_code="10">Definition prepared for Groundhog v0.7.2b and depends on components from that plugin. It is available for download at http://groundhog.la/
<item name="UserText" type_name="gh_string" type_code="10">Definition prepared for Groundhog v0.9.1b and depends on components from that plugin. It is available for download at http://groundhog.la/

Contact groundhog@philipbelesky.com for support or feedback.

Expand Down
2 changes: 1 addition & 1 deletion docs/paths/Groundhog - Random Path Examples.ghx
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@
<item name="Optional" type_name="gh_bool" type_code="1">false</item>
<item name="ScrollRatio" type_name="gh_double" type_code="6">1</item>
<item name="SourceCount" type_name="gh_int32" type_code="3">0</item>
<item name="UserText" type_name="gh_string" type_code="10">Definition prepared for Groundhog v0.7.2b and depends on components from that plugin. It is available for download at http://groundhog.la/
<item name="UserText" type_name="gh_string" type_code="10">Definition prepared for Groundhog v0.9.1b and depends on components from that plugin. It is available for download at http://groundhog.la/

Contact groundhog@philipbelesky.com for support or feedback.

Expand Down
6 changes: 3 additions & 3 deletions docs/paths/Groundhog - Shortest Path Examples.ghx
Original file line number Diff line number Diff line change
Expand Up @@ -1755,8 +1755,8 @@ If there are no lengths provided, they will be calculated for each of the curves
<chunk name="param_input" index="3">
<items count="7">
<item name="Access" type_name="gh_int32" type_code="3">1</item>
<item name="Description" type_name="gh_string" type_code="10">A manually-specified length for each curve; useful if you want to artificially increase or
decrease their traversability. If no lengths provided, they will be manually
<item name="Description" type_name="gh_string" type_code="10">A manually-specified length for each curve; useful if you want to artificially increase or
decrease their traversability. If no lengths provided, they will be manually
calculated for each of the curves.</item>
<item name="InstanceGuid" type_name="gh_guid" type_code="9">a5e104c0-ccfa-4b86-ac08-bc74ac049002</item>
<item name="Name" type_name="gh_string" type_code="10">Lengths</item>
Expand Down Expand Up @@ -4745,7 +4745,7 @@ If there are no lengths provided, they will be calculated for each of the curves
<item name="Optional" type_name="gh_bool" type_code="1">false</item>
<item name="ScrollRatio" type_name="gh_double" type_code="6">1</item>
<item name="SourceCount" type_name="gh_int32" type_code="3">0</item>
<item name="UserText" type_name="gh_string" type_code="10">Definition prepared for Groundhog v0.7.2b and depends on components from that plugin. It is available for download at http://groundhog.la/
<item name="UserText" type_name="gh_string" type_code="10">Definition prepared for Groundhog v0.9.1b and depends on components from that plugin. It is available for download at http://groundhog.la/

Contact groundhog@philipbelesky.com for support or feedback.

Expand Down
125 changes: 125 additions & 0 deletions plugin/Hydro/ChannelInfoComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Threading.Tasks;
using groundhog.Properties;
using Grasshopper;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Data;
using Rhino;
using Rhino.Geometry;

namespace groundhog
{
public class GroundhogChannelInfoComponent : GroundHogComponent
{
public GroundhogChannelInfoComponent()
: base("Channel Info", "CInfo", "Calculate characteristics of water flow in a channel from its submerged region", "Groundhog", "Hydro")
{
}

public override GH_Exposure Exposure => GH_Exposure.primary;

protected override Bitmap Icon => Resources.icon_channel_info;

public override Guid ComponentGuid => new Guid("{008255a6-edff-44d9-b96f-23eb050b4a1a}");

protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddCurveParameter("Channel", "C", "A closed planar curve representing a section of the water body; assumes a level top", GH_ParamAccess.item);
pManager.AddNumberParameter("Roughness", "N", "Manning's roughness coefficient for the channel", GH_ParamAccess.item);
pManager[1].Optional = true;
pManager.AddNumberParameter("Slope", "S", "Slope of the hydraulic grade line as a decimal (i.e. rise/run = 0.5)", GH_ParamAccess.item);
pManager[2].Optional = true;
}

protected override void RegisterOutputParams(GH_OutputParamManager pManager)
{
pManager.AddNumberParameter("Area", "A", "Area of the channel", GH_ParamAccess.item);
pManager.AddNumberParameter("Max Depth", "mD", "Maximum depth of the channel", GH_ParamAccess.item);
pManager.AddNumberParameter("Mean Depth", "aD", "Mean depth of the channel", GH_ParamAccess.item);
pManager.AddNumberParameter("Wetted Perimeter", "P", "Length of the channel in the boundary", GH_ParamAccess.item);
pManager.AddNumberParameter("Hydraulic Radius", "R", "Ratio of area to wetted perimeter", GH_ParamAccess.item);
pManager.AddNumberParameter("Velocity", "V", "Velocity of the water flow in the channel", GH_ParamAccess.item);
pManager.AddNumberParameter("Discharge", "Q", "The rate of discharge in cubic document units per second", GH_ParamAccess.item);
}

protected override void GroundHogSolveInstance(IGH_DataAccess DA)
{
// Create holder variables for input parameters
var CHANNEL_CURVE = default(Curve);
var CHANNEL_PLANE = default(Plane);
var TOLERANCE = RhinoDoc.ActiveDoc.ModelAbsoluteTolerance;
double GAUCKLER_MANNING = 0.0; // Default value
double SLOPE = 0.0; // Default value

// Access and extract data from the input parameters individually
if (!DA.GetData(0, ref CHANNEL_CURVE)) return;
DA.GetData(1, ref GAUCKLER_MANNING);
DA.GetData(2, ref SLOPE);

// Validation
if (CHANNEL_CURVE.TryGetPlane(out CHANNEL_PLANE, TOLERANCE) == false)
{
AddRuntimeMessage(GH_RuntimeMessageLevel.Warning,
"A non-planar curve has been provided as the channel section; please ensure it is planar.");
return;
}
if (CHANNEL_CURVE.IsClosed == false)
{
AddRuntimeMessage(GH_RuntimeMessageLevel.Warning,
"A non-closed curve has been provided as the channel section; please ensure it is closed.");
return;
}
if (GAUCKLER_MANNING > 0 && SLOPE <= 0 || GAUCKLER_MANNING <= 0 && SLOPE > 0)
{
AddRuntimeMessage(GH_RuntimeMessageLevel.Warning,
"Calculating velocity and discarge requires both the slope and the roughness coefficient.");
return;
}

// Calculate area
var area_calc = AreaMassProperties.Compute(CHANNEL_CURVE);
double? area = null;
if (area_calc != null)
{
if (area_calc.Area < 0.0)
area = area_calc.Area * -1; // Areas can be negative; same same
else
area = area_calc.Area;
}

// Calculate the bounding box for the curve
var bbox = CHANNEL_CURVE.GetBoundingBox(CHANNEL_PLANE);

double maxDepth = bbox.Diagonal.X; // Distance from high to low
double maxWidth = bbox.Diagonal.Y; // Distance from side to side

// Mean Depth = cross-sectional area divided by the surface width
double meanDepth = area.Value / maxWidth;

// Wetted Perimeter = the channel curve that is not the top segment
double wettedPerimeter = CHANNEL_CURVE.GetLength() - maxWidth; // Basically ignore the top channel

// Hydraulic Radius = area divided by the wetted perimeter
double hydraulicRadius = area.Value / wettedPerimeter;

// Assign variables to output parameters
DA.SetData(0, area);
DA.SetData(1, maxDepth);
DA.SetData(2, meanDepth);
DA.SetData(3, wettedPerimeter);
DA.SetData(4, hydraulicRadius);

if (GAUCKLER_MANNING > 0 && SLOPE > 0)
{
// Manning's Formula
double discharge = (1.00 / GAUCKLER_MANNING) * area.Value * Math.Pow(hydraulicRadius, 0.6666666) * Math.Sqrt(SLOPE);
double velocity = discharge / area.Value;

DA.SetData(5, velocity);
DA.SetData(6, discharge);
}
}
}
}
Loading

0 comments on commit 86637c8

Please sign in to comment.