Skip to content

Instantly share code, notes, and snippets.

View jwpeterson's full-sized avatar

John W. Peterson jwpeterson

View GitHub Profile
@jwpeterson
jwpeterson / write_element_data_test.cc
Created August 6, 2013 20:52
Sample code that demonstrates write_element_data not working with ParallelMesh.
// This utility lists all nodes on a given boundary ID.
#include "libmesh/libmesh.h"
#include "libmesh/serial_mesh.h"
#include "libmesh/parallel_mesh.h"
#include "libmesh/mesh_generation.h"
#include "libmesh/equation_systems.h"
#include "libmesh/explicit_system.h"
#include "libmesh/dof_map.h"
#include "libmesh/numeric_vector.h"
#include "libmesh/exodusII_io.h"
@jwpeterson
jwpeterson / modified_transient_ex1.C
Last active December 24, 2015 12:08
Example demonstrating use of new "append" capability for Exodus files.
/* The libMesh Finite Element Library. */
/* Copyright (C) 2003 Benjamin S. Kirk */
/* This library is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU Lesser General Public */
/* License as published by the Free Software Foundation; either */
/* version 2.1 of the License, or (at your option) any later version. */
/* This library is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
# Compute second derivatives of Hex20 basis functions using Maple
hex20 := proc()
uses LinearAlgebra;
local N, i, phi, phi_x, phi_xx, phi_y, phi_yy, phi_z, phi_zz, phi_xy, phi_xz, phi_yz, indexes;
N:=20;
@jwpeterson
jwpeterson / prism15.maple
Created November 22, 2013 20:37
Given PRISM15 shape functions, computes and verifies some properties of their first and second derivatives.
# Shape functions, first, and second derivatives of PRISM15 basis functions using Maple
prism15 := proc()
uses LinearAlgebra;
local
x, phi, i, j, nodal_val, xi_degree, eta_degree, zeta_degree, phi_xi,
phi_eta, phi_zeta, indexes, phi_xixi, phi_etaeta, phi_zetazeta,
phi_xieta, phi_xizeta, phi_etazeta, phi_sum, sum_phi_xi, sum_phi_eta,
@jwpeterson
jwpeterson / pyramid5.maple
Created November 24, 2013 04:03
Given basis functions for the pyramid 5, compute first and second derivatives and check various qualities that each should have.
# Shape functions, first, and second derivatives of PYRAMID5 basis functions using Maple
pyramid5 := proc()
uses LinearAlgebra;
local
phi, i, t, phi_xi, phi_eta, phi_zeta, phi_xixi, phi_etaeta, phi_zetazeta,
phi_xieta, phi_xizeta, phi_etazeta, x, n, xi_vec, planes, phi_sum,
phi_xi_sum, phi_eta_sum, phi_zeta_sum;
@jwpeterson
jwpeterson / pyramid14.maple
Created December 6, 2013 05:24
Verification of basis functions for the Pyramid14 element.
# Quadratic shape functions, as defined in R. Graglia, "Higher order
# bases on pyramidal elements", IEEE Trans Antennas and Propagation,
# vol 47, no 5, May 1999.
pyramid14 := proc()
uses LinearAlgebra;
local p, phi, x, phi_val, i, j, k, phi_sum, n, xi_vec, true_phi_sums, phi_sums,
phi_restrict, eqns, phi_xi, phi_eta, phi_zeta, phi_xixi,
phi_etaeta, phi_zetazeta, phi_xieta, phi_xizeta, phi_etazeta,
@jwpeterson
jwpeterson / pyramid13.maple
Created December 8, 2013 04:50
Compute and verify basis functions and derivatives for 13 node pyramid elements.
# "Serendipity" pyramid element functions, as defined in:
#
# G. Bedrosian, "Shape functions and integration formulas for
# three-dimensional finite element analysis", Int. J. Numerical
# Methods Engineering, vol 35, p. 95-108, 1992.
#
# This pyramid has 13 nodes and a "serendipity" quad on the bottom.
# Bedrosian uses the same size reference element as we want to use,
# but a different node numbering. The purpose of this script is to
# make sure his basis functions check out. Bedrosian also uses
// This example tests out the calculation of second derivatives
// Run me with:
// ./second_derivs-opt -d 2 -n 2 -o FIRST -ksp_monitor -pc_type hypre -pc_hypre_type boomeramg > second_derivs.log
// C++ include files that we need
#include <iostream>
#include <algorithm>
#include <math.h>
#include <set>
// This test code is to investigate David Knezevic's bad Tet10
#include "libmesh/libmesh.h"
#include "libmesh/mesh.h"
#include "libmesh/elem.h"
#include "libmesh/cell_tet10.h"
// Bring in the libmesh namespace
using namespace libMesh;
int main (int argc, char** argv)
// This utility code is used for generating the embedding matrix for the Prism15 element
#include <iomanip> // std::setw
#include "libmesh/libmesh.h"
#include "libmesh/mesh.h"
#include "libmesh/elem.h"
#include "libmesh/mesh_generation.h"
#include "libmesh/mesh_modification.h"
#include "libmesh/getpot.h"
#include "libmesh/fe_interface.h"