Skip to content

Instantly share code, notes, and snippets.

@christophernhill
christophernhill / evaluate-dg-operator.jl
Created November 19, 2020 15:00
Stuff for debugging DG evaluation
#
## Understanding DG nodal basis functions in CLIMA
##
# 1. plotting the nodal basis functions (Lagrange interpolation polynomials).
#
using ClimateMachine
using StaticArrays
using MPI
using ClimateMachine.Mesh.Topologies
using ClimateMachine.Mesh.Grids
@christophernhill
christophernhill / plot-basis-function.jl
Last active November 18, 2020 04:10
Basis function plotting for CLiMA DG - so I don't lose it
#
## Understanding DG nodal basis functions in CLIMA
##
# 1. plotting the nodal basis functions (Lagrange interpolation polynomials).
#
using ClimateMachine
using MPI
using ClimateMachine.Mesh.Topologies
using ClimateMachine.Mesh.Grids
@christophernhill
christophernhill / gendata_5km.py
Last active October 1, 2020 03:08
Starter python Code for Jeff for MITgcm channel example
import numpy as np
import matplotlib.pyplot as plt
#
# Vertical grid
#
dr=np.array([5.48716549, 6.19462098, 6.99291201, 7.89353689, \
8.90937723, 10.05483267, 11.34595414, 12.80056778, \
14.43837763, 16.28102917, 18.35210877, 20.67704362, \
23.28285446, 26.1976981 , 29.45012046, 33.06792588, \
@christophernhill
christophernhill / checks.py
Last active October 9, 2020 18:44
Raw VTU read into Pandas data frame
np.count_nonzero( ( abs(df.Z-zloc[3])<1e-4 ) & ( abs(df.Y-yloc[3])<1e-4 ) )
np.count_nonzero( ( abs(df.Z-zloc[3])<1e-4 ) )
rslt_df = df[( abs(df.Z-zloc[-2])<1e-4 ) & ( abs(df.Y-yloc[-2])<1e-4 )]
plt.scatter(rslt_df.X,rslt_df.θ)
@christophernhill
christophernhill / IVDCModel-test.jl
Last active July 8, 2020 23:01
Testing bc's for IVDC
# use against
#
# origin https://github.com/christophernhill/ClimateMachine.jl.git (fetch)
# origin https://github.com/christophernhill/ClimateMachine.jl.git (push)
#
# commit 6f0df023a8c7ff39628e85b0af2d1eb6ad4bf659 (HEAD -> cnh/impl_diff-jmc/split_explicit_draft, origin/cnh/impl_diff-jmc/split_explicit_draft)
# Author: christophernhill <cnh@mit.edu>
# Date: Tue Jul 7 10:04:04 2020 -0400
#
#
@christophernhill
christophernhill / CLIMA_slicer.jl
Created June 8, 2020 12:52
Small inline slice plotting code for CLIMA
function CLIMA_slicer(solver_config)
## Slicing routine for structured CLIMA meshes
# Define number nodal points along each axis of an element and number of elements along each
# axis of topology
Np=[4,4,4]
Nn=[Np[1]+1,Np[2]+1,Np[3]+1]
Ne=[20,20,20]
# Get X, Y, Z coords and make sure they are in a CPU array to make life easier.
Gnd=reshape(solver_config.dg.grid.vgeo,(Nn[1],Nn[2],Nn[3],16,Ne[1],Ne[2],Ne[3]))
@christophernhill
christophernhill / test-mulit-proc-mean.jl
Last active June 4, 2020 12:06
Little Julia code frag for comparing means from decompositions that have rational (1/2,1/4) v irrational (1/3) 1/nprocs values.
using Statistics
npts1=[8000*125]
npts2=[4000*125,4000*125]
npts3=[2660*125,2680*125,2660*125]
npts4=[2000*125,2000*125,2000*125,2000*125]
v=rand(npts1[1])
cs1=[0;cumsum(npts1)]
cs1lo=cs1[1:end-1]
cs1hi=cs1[2:end ]
cs2=[0;cumsum(npts2)]
@christophernhill
christophernhill / README.md
Last active May 25, 2020 11:44
CLiMA inline plot snippet

Putting this here so I dont mislay it.

Shows very simple, hard-coded plot of nodal variabls, to go into call back.

@christophernhill
christophernhill / ocean_gyre_repl.jl
Created May 18, 2020 14:58
ReadOnlyMemoryError code - against climate machine.jl#2d2503aca7d6de5306d881391c15f80bb1730320
using Pkg
Pkg.activate("../climatemachine.jl")
Pkg.instantiate()
using ClimateMachine
ClimateMachine.init()
using ClimateMachine.GenericCallbacks
using ClimateMachine.ODESolvers
using ClimateMachine.Mesh.Filters
using ClimateMachine.VariableTemplates
@christophernhill
christophernhill / cat get_auth_key.sh
Last active April 9, 2020 01:09
Git key account adding
#!/bin/bash
#
# See if someone has a public key in github
#
# ./get_auth_key.sh USERNAME
uname=$1
expr match ${uname} "[a-zA-Z0-9][a-zA-Z0-9_-]*$" > /dev/null 2>&1
if [ x$? != x"0" ]; then