Today I finally got some time from my exams to continue my work.
First of, the code:
Code: Select all
FreeCAD.Console.PrintError('FELT-info: infile: {} \n\n'.format(infile))
Prints the error on the console:
(I still don't know the proper way of showing errors in the forum
)
So is that really an error or just an informational message?
My answer is that its's just a message because there is no exception handling code around it and it executes everytime.
That "error" message also forced me to think that whether there is a specific file format (or atleast extension) for the input file?
But after looking into the code of calculix and elmer, I guess the answer is no and the file format depends only on solver and not on FreeCAD.
Sudhanshu wrote: ↑Tue May 07, 2019 6:33 am
Earlier, it was writing file beam.flt and searching for input file beam.in. So, I thought that was the error and modified it to search for beam.flt but its still not running.
The felt executable is there at /usr/local/bin/
Is it not able to execute the solver?
Come to think of it, felt needs some flags to run properly. Is that the issue?
If yes, the how can I pass the flags from tasks.py?
To check this, I modified the code a bit in the tasks.py (with help from elmer's tasks.py) and its Solve method looks like this:
Code: Select all
class Solve(run.Solve):
def run(self):
if not _inputFileName:
# TODO do not run solver, do not try to read results in a smarter way than an Exception
raise Exception('Error on writing FELT input file.\n')
infile = _inputFileName + '.flt'
FreeCAD.Console.PrintError('FELT-info: infile: {} \n\n'.format(infile))
self.pushStatus("Executing solver...\n")
# binary = settings.get_binary("felt")
binary = '/usr/bin/felt' # if something goes wrong the binary path could be set for debugging
if binary is not None:
self._process = subprocess.Popen(
[binary, "-f", infile],
cwd=self.directory,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
self.signalAbort.add(self._process.terminate)
output = self._observeSolver(self._process)
self._process.communicate()
self.signalAbort.remove(self._process.terminate)
# if not self.aborted:
# self._updateOutput(output)
else:
self.report.error("Felt executable not found.")
self.fail()
del output # get flake8 quiet
The changes being:
Code: Select all
diff --git a/src/Mod/Fem/femsolver/felt/tasks.py b/src/Mod/Fem/femsolver/felt/tasks.py
index 979c677d9..b483866e4 100644
--- a/src/Mod/Fem/femsolver/felt/tasks.py
+++ b/src/Mod/Fem/femsolver/felt/tasks.py
@@ -92,24 +92,28 @@ class Solve(run.Solve):
if not _inputFileName:
# TODO do not run solver, do not try to read results in a smarter way than an Exception
raise Exception('Error on writing FELT input file.\n')
- infile = _inputFileName + '.in'
+ infile = _inputFileName + '.flt'
FreeCAD.Console.PrintError('FELT-info: infile: {} \n\n'.format(infile))
self.pushStatus("Executing solver...\n")
- binary = settings.get_binary("felt")
- # binary = '/usr/bin/felt' # if something goes wrong the binary path could be set for debugging
- self._process = subprocess.Popen(
- [binary, "-f", infile],
- cwd=self.directory,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- self.signalAbort.add(self._process.terminate)
- output = self._observeSolver(self._process)
- self._process.communicate()
- self.signalAbort.remove(self._process.terminate)
- # if not self.aborted:
- # self._updateOutput(output)
- del output # get flake8 quiet
+ # binary = settings.get_binary("felt")
+ binary = '/usr/bin/felt' # if something goes wrong the binary path could be set for debugging
+ if binary is not None:
+ self._process = subprocess.Popen(
+ [binary, "-f", infile],
+ cwd=self.directory,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ self.signalAbort.add(self._process.terminate)
+ output = self._observeSolver(self._process)
+ self._process.communicate()
+ self.signalAbort.remove(self._process.terminate)
+ # if not self.aborted:
+ # self._updateOutput(output)
+ else:
+ self.report.error("Felt executable not found.")
+ self.fail()
+ del output # get flake8 quiet
class Results(run.Results):
And now when I execute the solver I get:
Code: Select all
Touched (but must be executed), Internal name: SolverFELT
as you can see in the below pic:
So, my this doubt:
Sudhanshu wrote: ↑Tue May 07, 2019 6:33 am
Is it not able to execute the solver?
Come to think of it, felt needs some flags to run properly. Is that the issue?
If yes, the how can I pass the flags from tasks.py?
might actually be correct!!!
Investigating that, I got to know about the subprocess library of python which is used in tasks.py.
And it looks really interesting
So now I will
explore this, run the solver in python (outside of FreeCAD) and implement that tasks.py.