Skip to content

Conversation

@Antoniahuber
Copy link
Contributor

📝 Pull Request Summary

A new class "Logger" that collects the parameters from the wake, the grid and the solver and writes them into a .log file.

🔧 Changes Made

  • created new class
  • added new function to test
  • changed other classes to collect the parameters

✅ Checklist

  • Code follows the project's style and guidelines
  • Added tests for new functionality (if applicable)
  • Updated documentation (README.md, release.md, etc.)
  • Verified that changes do not break existing functionality

📌 Related Issues / PRs

Closes #29

@elenafuengar
Copy link
Collaborator

Can you remove all the files inside build/lib/wakis? they should not be there :)

self.logger.grid_logs["dz"] = self.dz
self.logger.grid_logs["stl_solids"] = list(self.stl_solids.values()) if self.stl_solids is not None else []
self.logger.grid_logs["stl_materials"] = list(self.stl_materials.values()) if self.stl_materials is not None else []
if stl_rotate != [0., 0., 0.]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice, I really like this :) helps keep the logger short


class Logger():

def __init__(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to stick to camelCase convention, we should avoid using underscores _. Do you think it would be still legible if we remove the _logs? like this we keep the variable format a bit more uniform. In the end, you call it using logger.wakeSolver so the log is implicit? What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I think that is fine. Should I remove them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


if verbose: print(f'Total initialization time: {time.time() - t0} s')

# assign logs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, we're almost there!!!

I was thinking, in order to keep the (already long) _init__ short and legible, should we populate/assign the logs in a separate method? I was thinking something private like _assign_logs(self) where we can allocate all this variables since they are already contained in self.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that makes the code clearer. I will do it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I do that I see a problem with self.bc_low and self.bc_high. They are both changed if use_mpi is True: if self.use_mpi and self.grid.use_mpi:
if self.rank > 0:
self.bc_low=['pec', 'pec', 'mpi'] In that case you can't comprehend, what the z boundary condition was originally, can you? And if you called the assign_log function before, you wouldn't get the initialization time of the solver

# create log
if self.log:
self.params_to_log()

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as in SolverFIT3D

Also, should we remove the self.params_to_log()?

self.mark_cells_in_stl()
if stl_colors is None:
self.assign_colors()

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as in SolverFIT3D

# Grid
self.grid = grid

bgLog = bg
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure I like this one :( we can simply add it to self as self.bg or maybe even better self.background--I should have called background since the beginning...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, I thought there was already a self.bg, but apparently there is none. Then I prefer the self.background myself

@elenafuengar elenafuengar added the enhancement New feature or request label Nov 13, 2025
ti = self.ti

# longitudinal variables
if self.zf is None: self.zf = self.z
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes for the non-uniform grid we should put in a different PR for clarity :)

"""
for atr in attrs:
if atr == 'grid':
self.logger.grid = self.grid.logger.grid
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grid is very heavy on memory, which information are we saving there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are giving the dictionary 'logger.grid' further to the logger object of the solver.
We are saving all the parameters assigned to the grid in Grid3DFit. It is whether mesh refinement is used, Nx, Ny, Nz, dx, dy, dz, stl_solids, stl_materials, stl_rotate, stl_translate, stl_scale and the gridInitializationTime

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see! You are just checking that, if the attribute is named "grid", then you pass only the logger and not the full grid class. Understood. Thanks!

@elenafuengar elenafuengar merged commit 9b38123 into ImpedanCEI:main Nov 14, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Logfile for the solver

2 participants