w06-g03-model-class-assembly
Model Class for Assembly
Objective
The overall objective of this assignment is to implement parts of the Model
class for the Direct Stiffness Method. For now, we will only implement the part of the Model
class to assemble the stiffness matrix.
The code from last week tehpc/examples/matrix_assembly_function.cpp
can be recycled (by copy-paste), but will require modifications.
Most of the interface of the Model
class is already implemented in tehpc/src/model.hpp
, and is used in a test tehpc/tests/model_assembly.cpp
. You have to implement the relevant methods of the Model
class in tehpc/src/model.cpp
.
Implementation
-
load appropriate modules by performing the following command in your terminal:
source tehpc/tools/tehpc_load_modules.sh
. -
If
model.cpp
is not already included at the appropriate place intehpc/src/CMakeLists.txt
, add it. This makes sure that it is compiled. -
Add
tehpc_add_test(model_assembly)
in thetehpc/tests/CMakeLists.txt
to include themodel_assembly
test in compilation. -
Compile your code, use the following steps (this is new):
a. go into tehpc/build/
b. type: either cmake -DCMAKE_BUILD_TYPE:STRING=Debug -DTEHPC_TESTS:STRING=ON ..
or ccmake ..
and make sure that build type is Debug
and Tests
are ON (you only have to do this the very first time).
c. type: make
(do this whenever you want to recompile).
-
Correct all compilation errors. Use code from
tehpc/basics/matrix_assembly_function.cpp
to implementtehpc/src/model.cpp
. Important: you are not allowed to change themodel_assembly.cpp
file. -
If the code compiles without errors, run the test:
a. go into tehpc/build/tests/
b. type: ./model_assembly
-
Make sure that the code runs without error and check printed message to see if it went to the end. Correct errors if needed. Again, you are not allowed to change the
model_assembly.cpp
files. -
run valgrind to check for memory leakage:
valgrind --leak-check=full ./model_assembly
-
correct memory leakage
-
Make sure that your code is well structured and commented.