Coverage for fiqus/mains/MainHomogenizedConductor.py: 54%
61 statements
« prev ^ index » next coverage.py v7.4.4, created at 2025-11-29 01:35 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2025-11-29 01:35 +0000
1import os, cProfile
3from fiqus.geom_generators.GeometryHomogenizedConductor import Geometry
4from fiqus.mesh_generators.MeshHomogenizedConductor import Mesh
5from fiqus.getdp_runners.RunGetdpHomogenizedConductor import Solve
6from fiqus.post_processors.PostProcessHomogenizedConductor import PostProcess
8class MainHomogenizedConductor:
9 def __init__(self, fdm, inputs_folder_path='', outputs_folder_path='', verbose=True):
10 """
11 Main class for working with simulations for the homogenized conductor model.
12 :param fdm: FiQuS data model
13 :param inputs_folder_path: full path to folder with input files
14 :param verbose: if True, more info is printed in the console
15 """
16 self.verbose = verbose
17 self.fdm = fdm
18 self.inputs_folder_path = inputs_folder_path
19 self.outputs_folder_path = outputs_folder_path
20 self.GetDP_path = None
21 self.geom_folder = None
22 self.mesh_folder = None
23 self.solution_folder = None
24 self.model_file = None
25 self.model_folder = None
28 def generate_geometry(self, gui=False):
29 """
30 Generates the conductor geometry.
31 """
32 os.chdir(self.geom_folder)
33 g = Geometry(fdm=self.fdm, inputs_folder_path=self.inputs_folder_path, verbose=self.verbose)
34 g.generate_geometry()
35 g.generate_vi_file(gui)
38 def load_geometry(self, gui: bool = False):
39 """
40 Loads the previously generated geometry from the .brep file.
41 """
42 os.chdir(self.geom_folder)
43 g = Geometry(fdm=self.fdm, inputs_folder_path=self.inputs_folder_path, verbose=self.verbose)
44 g.load_geometry()
45 # self.model_file = g.model_file
47 def pre_process(self, gui=False):
48 pass
50 def mesh(self, gui: bool = False):
51 """
52 Generates the mesh for the geometry.
53 """
54 os.chdir(self.mesh_folder)
56 m = Mesh(fdm=self.fdm, verbose=self.verbose)
57 m.generate_mesh()
58 m.generate_cuts()
59 m.generate_regions_file()
60 m.save_mesh(gui)
62 return {"test": 0}
64 def load_mesh(self, gui=False):
65 """
66 Loads the previously generated mesh from the MSH file.
67 """
68 os.chdir(self.mesh_folder)
69 m = Mesh(fdm=self.fdm, verbose=self.verbose)
70 m.load_mesh(gui)
72 # self.model_file = m.mesh_file
74 def solve_and_postprocess_getdp(self, gui: bool = False):
75 """
76 Assembles the .pro-file from the template, then runs the simulation and the post-processing steps using GetDP.
77 """
78 os.chdir(self.solution_folder)
80 s = Solve(self.fdm, self.GetDP_path, self.geom_folder, self.mesh_folder, self.verbose)
81 s.read_excitation(inputs_folder_path=self.inputs_folder_path)
82 s.read_ro_parameters(inputs_folder_path=self.inputs_folder_path)
83 s.assemble_pro()
84 s.run_getdp(solve = True, postOperation = True, gui = gui)
85 s.cleanup()
87 def post_process_getdp(self, gui: bool = False):
88 """
89 Runs the post-processing steps trough GetDP.
90 """
91 os.chdir(self.solution_folder)
93 s = Solve(self.fdm, self.GetDP_path, self.geom_folder, self.mesh_folder, self.verbose)
94 s.read_excitation(inputs_folder_path=self.inputs_folder_path)
95 s.read_ro_parameters(inputs_folder_path=self.inputs_folder_path)
96 s.assemble_pro()
97 s.run_getdp(solve = False, postOperation = True, gui = gui)
99 def post_process_python(self, gui: bool = False):
100 """
101 Runs the post-processing steps in the python PostProcess class.
102 """
104 postProc = PostProcess(self.fdm, self.solution_folder)
105 postProc.show()
107 return {'test': 0}
109 def batch_post_process_python(self, gui: bool = False):
110 pass