When I was an undergraduate at Pine State University, all engineering freshmen had to take a programming course. We could pick between Fortran, Pascal, and C++. From what I recall, most civil and mechanical engineering students took Fortran because that's how you crunch numbers. I chose C++ and liked it so much I willingly took … Continue reading Counting Flops
Tag: C++
Set and Get Concrete23 Response
When I wrote Concrete23, I copied Concrete01 then tweaked the unloading and reloading rules. I also added a couple of bells and whistles and it was music to my ears. But I wanted to record those sounds during an analysis. Recorders in OpenSees use the setResponse and getResponse methods to identify and obtain element, section, … Continue reading Set and Get Concrete23 Response
Life of OpenSees Pi
This is blog post #314, or $latex 100\pi$ to three sig figs. A more recognizable $latex \pi$-times-a-power-of-10 post than post #31 or post #3. And I'll have to maintain the current pace of post writing into my mid 80s in order to reach post #3141. In the G3 days of OpenSees, the inverse sine function … Continue reading Life of OpenSees Pi
Right, then Left
I don't expect every OpenSees contributor to be an expert coder, but I see some dubious coding more frequently than I should. And when I see questionable coding practices, I will call out the offenses so that maybe, just maybe, someone else will consider leaving the cargo cult. For example, the author of CargoConcrete23 wrote … Continue reading Right, then Left
Pleasing the Compiler
Around the transition from G3 to OpenSees, the Visual Studio (VS) compiler was not fully compliant with the then current ISO C++ standard. There were perhaps many items out of compliance, but the non-compliance that drove us nuts was the scoping rule on variables defined in the initialization statement of for loops. The VS compiler … Continue reading Pleasing the Compiler
Something Like a Double Negative
Double negatives are frowned upon in English, but are acceptable in other languages such as Spanish. For example, "No hay nada" is perfectly fine but may sound odd to native English speakers. Along similar lines, I recently came across some OpenSees code that looked something like this: const int N = 20; double Fx[N]; // … Continue reading Something Like a Double Negative
Hidden Fees
Helper functions are often implemented as private methods in a class. For example, here is a private cross product function in an Element class of OpenSees. Vector CadillacBeamColumn3d::cross(Vector v1, Vector v2){ Vector v3(3); v3(0) = v1(1)*v2(2)-v1(2)*v2(1); v3(1) = v2(0)*v1(2)-v1(0)*v2(2); v3(2) = v1(0)*v2(1)-v1(1)*v2(0); return v3; } Note that the class name has been changed and other … Continue reading Hidden Fees
Cargo Cult OpenSeesing
In recent conversation, a colleague in Eastchester mentioned "cargo cult science", a term with which I was previously unfamiliar. A cargo cult scientist attempts to produce outcomes without understanding the actual processes that lead to those outcomes. Although the associated cultural behaviors have been around for centuries, the popular term "cargo cult" was coined during … Continue reading Cargo Cult OpenSeesing
My Favorite Ternary Operation
Most native C++ operations are binary, taking two arguments, e.g., a + b, or unary, taking one argument, e.g., a++. But C++ (and many other languages) has a native "conditional operator", which is ternary, taking three arguments. Known simply as ?:, the conditional operator has the following syntax (condition) ? true_outcome : false_outcome; The conditional … Continue reading My Favorite Ternary Operation
Not Everything Should Be a Direct Translation
Like learning another language, not everything in OpenSees, and programming in general, is a direct translation from textbooks. Your mother tongue could be $latex {\bf x} = {\bf A}^{-1}{\bf b}$, but you should never invert the matrix then multiply. Instead, call an equation solver. For small matrices in OpenSees, use A.Solve(b, x) from the Matrix … Continue reading Not Everything Should Be a Direct Translation
