-
Notifications
You must be signed in to change notification settings - Fork 9
Discuss new InputFile
interface for 4C YAML
#304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for the nice overview! One thing I'd like to discuss is if we should treat the input file like a "discretization" (or some better word for it) again. What do you think if we can simply add the materials, bc's etc to the mesh and in the end the input file is only able to "translate" a mesh into the respective input file. We could then use it like this: mesh = InputFile("path_to_existing_input_file.4C.yml")
mesh.add(material)
mesh.add(boundarycondition)
mesh.add(whatever)
input_file = InputFile(mesh)
input_file.validate()
input_file.write("path_to_new_input_file.4C.yml")
input_file.write("path_to_vtu_file.vtu")
input_file.write("path_to_new_abaqus_file") (And if you directly want to add a dictionary - you could add it with some sort of custom action input_file.add_custom_4C_section({"STRUCTURAL_DYNAMIC": ...}) ) |
I am not sure what exactly you mean with "treat the input file like a "discretization". The I don't think it is desirable to create a base In your case would the Is there a reason you want to to this
instead of
|
Would it make sense to simply consider the example from the description have a look how we want it to look in the future? Alternative option: We could leave everything as it current is, and we replace simply replace one class variable in the input file: class InputFile(_Mesh):
"""An item that represents a complete 4C input file."""
def __init__(self, *, description=None, dat_file=None, cubit=None):
"""Initialize the input file.
"""
super().__init__()
self.description = description
self.dat_header = []
# In case we import a 4C dat file with plain string data, we store them in these lists,
# they do not interfere with other operations.
self.dat_nodes = []
self.dat_elements = []
self.dat_elements_fluid = []
self.dat_geometry_sets = _GeometrySetContainer()
self.dat_boundary_conditions = _BoundaryConditionContainer()
# Contents of NOX xml file.
self.nox_xml = None
self._nox_xml_file = None
# Dictionaries for sections other than mesh sections.
- self.sections = dict()
+ self.sections = ... # dict or some sort of yaml class
# Flag if dat file was loaded.
self._dat_file_loaded = False
# Load existing dat files. If both of the following if statements are
# true, an error will be thrown.
if dat_file is not None:
self.read_dat(dat_file)
if cubit is not None:
self._read_dat_lines(cubit.get_dat_lines()) and then we try to reproduce the current functionality, only with YAML under the hood instead of the self written classes. Mayor functional refactoring of |
Yes that sounds better - I initially thought that we could add all the information to the
Also sounds good
I think the
Here I also would agree with your proposal - a simple add method will be easier from a user perspective. Initially I thought we could split it up to better separate the implementation details but that could also be done similar to our testing framework where we have one general function which then calls all the separate functions.
I would not go with that approach - in the long run this will take much more time and if we start from scratch right now we have a better overview and structure. The code of the original implementation is not lost - we still have a functioning main and git history if we decide on switching back. Thanks for the good input - let's discuss the remaining stuff in the meeting:) |
@isteinbrecher this afternoon I looked into this conversion and I have a very general question (we can document it here and discuss it in our next meeting)
After looking into the entire logic I would propose the following simplification which would really slim down the code and also simplify the interaction with it from a user perspective
header, mesh = convert_4C_input_file_to_meshpy_mesh("example.4C.yaml") Then one can easily do everything with the mesh and the header and once the work is done convert everything into a FourC Input File again in point 2
input_file = InputFile()
input_file.add(header) # add the header we previously exported from our existing file
input_file.add(mesh) # which internally converts to the input dict (similar to get_dict_to_dump)
input_file.add({"IO": {"dummy": "test"}} I think we can simply omit the option to convert our InputFile to a MeshPy Mesh - because with fourcipp we can interpret all of the 4C input. Just convert everything that is doable with MeshPy to a MeshPy mesh - and the rest stays within the dict/header. With this approach we could really simplify the logic of the input file. This is closely related to #321. With this change we would need an approach to compare two meshes in MeshPy for testing - but we should really look into that. |
Thanks for your thoughts on this!
Historically, we used to read .dat files and populate the self.nodes, self.elements, etc., lists in the In that sense, Let's split them up!
I really like the general idea of that! One thing we should discuss, how much logic do we want to put into the proposed
I don't quite get that comment.
I agree. This is also closely related to modularisation #250. I have some ideas how we can do this in testing, let's discuss this today. |
A short recap of the discussion:
@davidrudlstorfer please correct/add anything that I might have missed. If anyone else has comments though, feel free to share them. |
@isteinbrecher sounds good and I have nothing to add:) |
With #135 we will switch to YAML. This will mostly result in a complete rework of the current
InputFile
class. Let's discuss the interface of the newInputFile
(or whatever name it will have) class here, as this will be one of the main points that will change for users.Currently the interface looks something like this:
I think this general approach still makes sense, but I am open to any changes that can improve the code design behind everything and/or the usability.
Some thoughts about a possible new
InputFile
:InputFile
does not derive fromMesh
any more, we would have to change the firstcreate_beam_mesh_line
call in the example to:.add
methods? We at least need the options to add parameters and meshes directly to theInputFile
:input_file.mesh.add
, but my opinion on this is not strong.The text was updated successfully, but these errors were encountered: