Coverage for fiqus/post_processors/PostProcessAC_CC.py: 47%

45 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2026-01-09 01:49 +0000

1import os 

2import math 

3import csv 

4import re 

5import logging 

6 

7import gmsh 

8import json 

9import numpy as np 

10import pandas as pd 

11from pathlib import Path 

12import matplotlib.pyplot as plt 

13from matplotlib import cm 

14from mpl_toolkits.mplot3d.art3d import Poly3DCollection 

15 

16from fiqus.utils.Utils import GmshUtils 

17from fiqus.parsers.ParserCOND import ParserCOND 

18from fiqus.utils.Utils import FilesAndFolders as uff 

19from fiqus.data.RegionsModelFiQuS import RegionsModel 

20 

21logger = logging.getLogger('FiQuS') 

22 

23class Post_Process: 

24 """ 

25 Postprocessing class for CWS 

26 """ 

27 def __init__(self, fdm, verbose=True): 

28 """ 

29 Class to cct models postprocessing 

30 :param fdm: FiQuS data model 

31 :param verbose: If True more information is printed in python console. 

32 """ 

33 self.current_FiQuS = {} 

34 self.fdm = fdm 

35 self.model_folder = os.path.join(os.getcwd()) 

36 

37 self.mesh_folder = Path(self.model_folder).parent 

38 self.geom_folder = Path(self.mesh_folder).parent 

39 self.magnet_name = fdm.general.magnet_name 

40 self.verbose = verbose 

41 

42 def cleanup(self): 

43 """ 

44 This function is used to remove .msh, .pre and .res files from the solution folder, as they may be large and not needed. 

45 """ 

46 magnet_name = self.fdm.general.magnet_name 

47 cleanup = self.fdm.magnet.postproc.cleanup 

48 

49 if cleanup.remove_res_file: 

50 res_file_path = os.path.join(self.model_folder, f"{magnet_name}.res") 

51 if os.path.exists(res_file_path): 

52 os.remove(res_file_path) 

53 logger.info(f"Removed {magnet_name}.res") 

54 

55 if cleanup.remove_pre_file: 

56 pre_file_path = os.path.join(self.model_folder, f"{magnet_name}.pre") 

57 if os.path.exists(pre_file_path): 

58 os.remove(pre_file_path) 

59 logger.info(f"Removed {magnet_name}.pre") 

60 

61 if cleanup.remove_msh_file: 

62 msh_file_path = os.path.join(self.mesh_folder, f"{magnet_name}.msh") 

63 if os.path.exists(msh_file_path): 

64 os.remove(msh_file_path) 

65 logger.info(f"Removed {magnet_name}.msh")