#import "setup.typ": *
#show: this-template

#let pathemph(a, b) = [
  #text(fill: white.darken(60%))[#a]#b
]

#titleslide("01")

#pagebreak()

#githubref

#pagebreak()
= Important links
#v(1cm)

NPDE Repo https://gitlab.math.ethz.ch/ralfh/NPDERepo \
CPP reference: https://en.cppreference.com/ \
Eigen documentation https://eigen.tuxfamily.org \
LehrFEM++ docs https://craffael.github.io/lehrfempp/ \
( LehrFEM++ repo https://github.com/craffael/LehrFEMpp ) \

#pagebreak()
= Setup / Problem 0-1
#v(1cm)

We'll be now basically solving Problem 0-1 from the homework PDF. \
Which is setting up the lecture repository.

Use a unix operating system: Linux or MacOS.

There is no Code Expert, you'll have to solve the exercises locally on your
computer.

#pagebreak()
== SSH setup
#v(1cm)

Check if you already have an SSH key already. \
```sh
ls ~/.ssh
```
Look for a filename that begins with `id`.

#v(1cm)
If you don't already have one: \
Generate a SSH public-private-keypair and add it to the SSH agent.
```sh
ssh-keygen -t ed25519 -C "<EMAIL>"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
```

#v(1.0cm)
Add #emph[public] key (named `id_*.pub`) to #link("gitlab.math.ethz.ch").

#pagebreak()
= Cloning and CMake
#v(1cm)


Clone the NumPDE repository from the D-MATH GitLab.
```sh
git clone <EMAIL>:ralfh/NPDERepo.git
```

Run CMake.
```sh
cd NPDERepo
mkdir build
cmake -B build
```

#v(0.5cm)
...This will take a while, because the hunter package manager
now fetches all dependencies (LehrFEM++, boost, GoogleTest, etc.)
and builds them.

In the meantime...

#pagebreak()
== Structure of NPDERepo: Source Code
#v(1cm)

We basically only care about the #pathemph(`NPDERepo/`, `homework`) folder. \
This is where we find the source code for all code problems.

In each specific problem folder, there are these directories
- #pathemph(`NPDERepo/homework/`, `<problem>/template`)
- #pathemph(`NPDERepo/homework/`, `<problem>/mysolution`)
- #pathemph(`NPDERepo/homework/`, `<problem>/mastersolution`)

Only modify `mysolution`, nothing else.


#pagebreak()
== Structure of NPDERepo: Build Folder
#v(0.3cm)

For compiling and executing we use the #pathemph(`NPDERepo/`, `build`) folder.

There we also find a #pathemph(`NPDERepo/build/`, `homework`) folder, which
mirrors the structure of the source code homework folder.

Inside we can compile a specific problem. \
e.g.
- ```sh make DebuggingWithGDB_mastersolution```
- ```sh make DebuggingWithGDB_mysolution```
- ```sh make DebuggingWithGDB_test_mysolution```

The executables are then found in the corresponding problem build folder. \
e.g.
- #pathemph(`NPDERepo/build/homework/`, `DebuggingWithGDB/DebuggingWithGDB_mastersolution`)
- #pathemph(`NPDERepo/build/homework/`, `DebuggingWithGDB/DebuggingWithGDB_mysolution`)
- #pathemph(`NPDERepo/build/homework/`, `DebuggingWithGDB/DebuggingWithGDB_test_mysolution`)

#pagebreak()
== VSCode setup
#v(1cm)

Extensions needed
- C++
- clangd
- CMake
- CMake Tools
- CodeLLDB

#v(1cm)

Let's edit the .gitignore.
We should ignore the cache files generated by clangd and others. \
Add this line
```
.cache/
```

#pagebreak()
== Can we commit and push?
#v(1cm)

No. We don't have rights to push on this repository. \
Solution: Your own fork (remote copy of repository with you own).

Usually this is really easy: Fork button in GitLab. \
But unfortunatly students have no right to create repository on D-MATH GitLab. \
The fork button is grayed out.

We need to create the fork manually...


#pagebreak()
== Forking repository (manually)
#v(1cm)

Create new repository under #link("gitlab.ethz.ch/<nethz>/NPDERepo").

Setup original repository as `upstream` and your fork as `origin`.
```sh
git remote -m origin upstream
git remote add origin <EMAIL>:<nethz>/NPDERepo.git
git push --set-upstream origin
```

#pagebreak()
== Using your fork
#v(1cm)

Create and switch to your own branch.
```sh
git switch -c <nethz>
```

Only commit on your own branch.
Do not modify master branch.

If there's a change on the original repository, then
Bring you branch up-to-date with upstream.

```sh
git stash
git switch master
git fetch upstream
git rebase upstream/master
git switch <nethz>
git rebase master
git stash apply
```
