w06-g01-NRsolver-class
Newton Raphson Solver (NRsolver) Class
Objective
The overall objective of this assignment is to implement the Newton Raphson Method in a class NRsolver
. This solver will later be part of the class project Direct Stiffness Method.
The code for this class needs to be split into a header file .hpp
and its implementation in the .cpp
file. Most of the interface of the NRsolver
class is already implemented in tehpc/src/newton_raphson_solver.hpp
, and is used in a simple test tehpc/tests/NRsolver_test.cpp
. You have to implement the method solve
of the NRsolver
class in tehpc/src/newton_raphson_solver.cpp
.
Please recycle the code from last week tehpc/basics/newton_raphson_function.cpp
. (method described in details in #1 (closed))
Implementation
-
load appropriate modules by performing the following command in your terminal:
source tehpc/tools/tehpc_load_modules.sh
. -
If
newton_raphson_solver.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(NRsolver_test)
in thetehpc/tests/CMakeLists.txt
to include theNRsolver_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 ..
orccmake ..
and make sure that build type isDebug
andTests
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/newton_raphson_function.cpp
and the provided operator overloading (seetehpc/src/matrix.hpp
,tehpc/src/vector.hpp
and others) to implementtehpc/src/newton_raphson_solver.cpp
. Important: you are not allowed to change theNRsolver_test.cpp
file. -
If the code compiles without errors, run the test:
a. go into
tehpc/build/tests/
b. type:
./NRsolver_test
-
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
NRsolver_test.cpp
files. -
run valgrind to check for memory leakage:
valgrind --leak-check=full ./NRsolver_test
. -
correct memory leakage
-
Make sure that your code is well structured and commented.