Skip to content

Commit 0c88a55

Browse files
committed
add content
1 parent 61a30d3 commit 0c88a55

189 files changed

Lines changed: 172882 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ syllabus.out
1616
*egg-info
1717

1818
.~lock*
19+
20+
*.fodp

content/01-python/NOTE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-- use the pyro timer util to illustrate modules and classes

content/01-python/VARDEN-tests.ini

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
[main]
2+
boxLibDir = /home/regtester/RegTesting/BoxLib/
3+
sourceDir = /home/regtester/RegTesting/VARDEN/
4+
testTopDir = /home/regtester/RegTesting/rt-VARDEN/
5+
webTopDir = /home/regtester/RegTesting/rt-VARDEN/web
6+
compareToolDir = /home/regtester/RegTesting/AmrPostprocessing/F_Src
7+
8+
MAKE = make
9+
sourceTree = F_Src
10+
numMakeJobs = 8
11+
12+
COMP = g++
13+
FCOMP = gfortran
14+
15+
# suiteName is the name prepended to all output directories
16+
suiteName = VARDEN
17+
18+
reportActiveTestsOnly = 1
19+
20+
# Add "GO UP" link at the top of the web page?
21+
goUpLink = 1
22+
23+
24+
# MPIcommand should use the placeholders:
25+
# @host@ to indicate where to put the hostname to run on
26+
# @nprocs@ to indicate where to put the number of processors
27+
# @command@ to indicate where to put the command to run
28+
#
29+
# only tests with useMPI = 1 will run in parallel
30+
# nprocs is problem dependent and specified in the individual problem
31+
# sections.
32+
33+
#MPIcommand = mpiexec -host @host@ -n @nprocs@ @command@
34+
MPIcommand = /usr/local/bin/mpiexec -n @nprocs@ @command@
35+
MPIhost =
36+
37+
# individual problems follow
38+
39+
[bubble-2d]
40+
buildDir = varden/test
41+
inputFile = inputs_2d-regt
42+
dim = 2
43+
restartTest = 0
44+
useMPI = 1
45+
numprocs = 2
46+
useOMP = 0
47+
numthreads = 2
48+
compileTest = 0
49+
doVis = 0
50+
51+
[bubble-3d]
52+
buildDir = varden/test
53+
inputFile = inputs_3d-regt
54+
dim = 3
55+
restartTest = 0
56+
useMPI = 1
57+
numprocs = 3
58+
useOMP = 1
59+
numthreads = 2
60+
compileTest = 0
61+
doVis = 0
62+
63+
[bubble-restart]
64+
buildDir = varden/test
65+
inputFile = inputs-restart-regt
66+
dim = 3
67+
restartTest = 1
68+
restartFileNum = 4
69+
useMPI = 1
70+
numprocs = 3
71+
useOMP = 1
72+
numthreads = 2
73+
compileTest = 0
74+
doVis = 0

content/01-python/myprofile.py

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
"""
2+
A very simple profiling class. Define some timers and methods
3+
to start and stop them. Nesting of timers is tracked so we can
4+
pretty print the profiling information.
5+
6+
# define a timer object, labeled 'my timer'
7+
a = timer('my timer')
8+
9+
This will add 'my timer' to the list of keys in the 'my timer'
10+
dictionary. Subsequent calls to the timer class constructor
11+
will have no effect.
12+
13+
# start timing the 'my timer' block of code
14+
a.begin()
15+
16+
... do stuff here ...
17+
18+
# end the timing of the 'my timer' block of code
19+
a.end()
20+
21+
for best results, the block of code timed should be large
22+
enough to offset the overhead of the timer class method
23+
calls.
24+
25+
Multiple timers can be instanciated and nested. The stackCount
26+
global parameter keeps count of the level of nesting, and the
27+
timerNesting data structure stores the nesting level for each
28+
defined timer.
29+
30+
timeReport() is called at the end to print out a summary of the
31+
timing.
32+
33+
At present, no enforcement is done to ensure proper nesting.
34+
35+
"""
36+
37+
from __future__ import print_function
38+
39+
import time
40+
41+
timers = {}
42+
43+
# keep basic count of how nested we are in the timers, so we can do some
44+
# pretty printing.
45+
stack_count = 0
46+
47+
timer_nesting = {}
48+
timer_order = []
49+
50+
class Timer(object):
51+
52+
def __init__ (self, name):
53+
global timers, stack_count, timer_nesting, timer_order
54+
55+
self.name = name
56+
57+
keys = timers.keys()
58+
59+
if name not in keys:
60+
timers[name] = 0.0
61+
self.startTime = 0.0
62+
timer_order.append(name)
63+
timer_nesting[name] = stack_count
64+
65+
66+
def begin(self):
67+
global stack_count
68+
69+
self.startTime = time.time()
70+
stack_count += 1
71+
72+
73+
def end(self):
74+
global timers, stack_count
75+
76+
elapsedTime = time.time() - self.startTime
77+
timers[self.name] += elapsedTime
78+
79+
stack_count -= 1
80+
81+
82+
def time_report():
83+
global timers, timer_order, timer_nesting
84+
85+
spacing = ' '
86+
for key in timer_order:
87+
print(timer_nesting[key]*spacing + key + ': ', timers[key])
88+
89+
90+
91+
if __name__ == "__main__":
92+
a = Timer('1')
93+
a.begin()
94+
time.sleep(10.)
95+
a.end()
96+
97+
b = Timer('2')
98+
b.begin()
99+
time.sleep(5.)
100+
101+
c = Timer('3')
102+
c.begin()
103+
104+
time.sleep(20.)
105+
106+
b.end()
107+
c.end()
108+
109+
time_report()

content/01-python/paradigms.png

98.7 KB
Loading

content/01-python/projectile-motion.ipynb

Lines changed: 207 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)