A kind of CAE document conversion method based on general read-write framework and device
Technical field
The present invention relates to CAE model file conversion art, be specifically related to a kind of CAE file based on general read-write framework and turn
Change method and device.
Background technology
Business CAE software the most all can attach pre-processing software and the poster processing soft of specialty, mostly supports main flow business
The input of CAE model.The most also the mutual conversion between indirect implementation model, such as: be to support mutually between ABAQUS and NASTRAN
Phase transformation.
HyperWorks to be mentioned, it has special pre-processing software HyperMesh.HyperMesh speciality exists
Function in stress and strain model.HyperMesh supports the most different solver input/output formats simultaneously, is so utilizing
After Hypermesh has divided the finite element grid of model, directly computation model can be changed into different solver trays
Formula, thus utilize corresponding solver to calculate.
HyperMesh can do pre-treatment for all main flow solvers, is not only in that its mesh quality is the best, also resides in
Its diversified template, can be output as user-defined form by the proprietary format of HyperMesh by template.But
HyperMesh provides only the reader of binary system (.exe or .dll) when reading the model file of specific format
(reader).Obviously can be restricted when user wants the read functions extending HyperMesh (because user there is no telling reading
Take the implementation rule of device).
For summary, the mode of HyperMesh is worth using for reference.But HyperMesh is expensive, for medium-sized and small enterprises
Heavy load.Removing price problem, these business CAE softwares lack the support to CAE model of increasing income substantially.Such as Code_
The model format above-mentioned business CAE software of Aster does not the most provide directly support.If user wants to be supported by self-defining mode
The model file of new type reads in the most difficult.
It also is provided with the scheme of some CAE model files conversion in the most various resources increased income, can save and again make
The work of wheel, but problem is the most following.The read write line principle increased income is different, and the computer language of use is the most different, has
With C++, some Java, have uses Python.If being all integrated into platform, necessarily bring mixing in Software Engineering Management
Disorderly.And what the parsing of the input-output file of business solver was not typically all increased income, it is difficult to find ready-made solution the most from network
Certainly scheme.
Summary of the invention
In order to overcome shortcomings and deficiencies of the prior art, the invention provides a kind of CAE based on general read-write framework literary composition
Part conversion method and device.
The technical scheme is that
On the one hand, the invention provides a kind of CAE document conversion method based on general read-write framework, at CAE number
According to the conversion between all kinds of model files in processing procedure, comprise the following steps:
S1, by row order reading model file A file content;
What S2, basis were pre-configured with in general read-write framework reads configuration file by the every a line in described model file A
File content is mapped in unified data model according to the format analysis of described model file A;
What S3, basis were pre-configured with in general read-write framework writes configuration file by unified data model according to model file
The format mapping of B is model file B.
The invention have the benefit that and introduce general read-write framework and unified data model, by general read-write
Framework write reading configuration file and writes configuration file, and combining unified data model and jointly will CAE data handling procedure be produced
Raw model file A is converted to the model file B of different-format, it is achieved that the mutual conversion between different-format model file.
On the basis of technique scheme, the present invention can also improve as follows.
Further, described step S1 specifically includes:
S11, by row order reading model file A, it is judged that whether this row is comment line;
S12, if it is not, identify the region keyword of this row, performs S13;If so, give up this row, return S11, re-read
The next line of model file A;
If S13 recognizes region keyword, obtain corresponding area attribute configuration, perform S14;If it is unidentified to region
Keyword, then obtain the recording configuration of this row, performs S14;
Containing area attribute or the form configuration item of record, this form in the configuration of S14, area attribute or recording configuration
Configuration item gets according to the format description book of the model file A write in advance, and the row content obtained can carry out the inspection of form,
If format checking is correct, then perform S2;If format checking mistake, give up this row, then return S11, re-read model file A's
Next line.
Comment line in model file A is rejected by described further having the beneficial effect that, and to the area attribute obtained
Configuration and recording configuration carry out format checking, reject for incorrect being also carried out of form, it is ensured that data in model file A
Correctness.
Further, reading configuration file is configured according to the format description book of the described model file A write in advance.
The described format description book further having the beneficial effect that according to model file A writes reading configuration file, more pin
To property.
Further, also include between described step S2 and step S3:
From described reading configuration file, obtain at least one region keyword, and each described region keyword is set
Priority level;
For the region keyword of each priority level, search whether the recording configuration of correspondence;
If having, obtain corresponding recording configuration;If no, obtaining corresponding area attribute configuration;
From unified data model, concrete model is got according to the described recording configuration obtained and area attribute configuration
Data, perform step S3.
Described further having the beneficial effect that carries out joining of priority to from the region keyword reading to obtain in configuration file
Put so that between the recording configuration finally obtained according to regional keyword, there is continuity.
Further, described reading configuration file and described configuration file of writing all use YAML form.
Further, the form of described model file A and the form of described model file B can be all X3D form, json lattice
Formula, INP form, BDF form, FRD form, F06 form or VTK form.
The described model further having the beneficial effect that the various different-formats that can be suitably used in CAE file handling procedure
Conversion between file, the suitability is extensive.
On the other hand, present invention also offers a kind of CAE file conversion device based on general read-write framework, be used for
The conversion between all kinds of model files in CAE data handling procedure, including read module, parsing module and Mapping and Converting mould
Block;
Described read module, for the file content by row order reading model file A;
Described parsing module, for civilian by described model according to the reading configuration file being pre-configured with in general read-write framework
Each row file content in part A is mapped in unified data model according to the format analysis of described model file A;
Described Mapping and Converting module, for writing configuration file by unification number according to be pre-configured with in general read-write framework
It is model file B according to model according to the format mapping of model file B.
The invention have the benefit that and introduce general read-write framework and unified data model, by general read-write
Framework write reading configuration file and writes configuration file, and combining unified data model and jointly will CAE data handling procedure be produced
Raw model file A is converted to the model file B of different-format, it is achieved that the mutual conversion between different-format model file.
On the basis of technique scheme, the present invention can also improve as follows.
Further, described read module is for being specifically included by row order reading model file A:
By row order reading model file A, it is judged that whether this row is comment line;
If it is not, identify the region keyword of this row, perform next step;If so, give up this row, re-read model file A
Next line;
If recognizing region keyword, obtain area attribute configuration;If unidentified to region keyword, then obtain this row
Recording configuration, wherein, containing area attribute or the form configuration item of record, these lattice in area attribute configuration or recording configuration
Formula configuration item gets according to the format description book of the model file A write in advance;
The inspection of form is carried out by the row content of the described form configuration item model file A to obtaining, if format checking
Correctly, then this row is mapped in unified data model;If format checking mistake, then give up this row, re-read model file A
Next line.
Comment line in model file A is rejected by described further having the beneficial effect that, and to the area attribute obtained
Configuration and recording configuration carry out format checking, reject for incorrect being also carried out of form, it is ensured that data in model file A
Correctness.
Further, reading configuration file is configured according to the format description book of the described model file A write in advance.
The described format description book further having the beneficial effect that according to model file A writes reading configuration file, more pin
To property.
Further, described Mapping and Converting module is additionally operable to:
From described reading configuration file, obtain at least one region keyword, and each described region keyword is set
Priority level;
For the region keyword of each priority level, search whether the recording configuration of correspondence;
If having, obtain corresponding recording configuration;If no, obtaining corresponding area attribute configuration;
From unified data model, concrete model is got according to the described recording configuration obtained and area attribute configuration
Data, are mapped to concrete model data in model file B.
Described further having the beneficial effect that carries out joining of priority to from the region keyword reading to obtain in configuration file
Put so that between the recording configuration finally obtained according to regional keyword, there is continuity.
Accompanying drawing explanation
Fig. 1 is a kind of based on general read-write framework the CAE document conversion method flow chart of the embodiment of the present invention 1;
Fig. 2 is the transformation process figure of the various model files produced in CAE data handling procedure;
Fig. 3 is the schematic diagram that embodiment 1 peripheral file is converted to internal file;
Fig. 4 is that embodiment 1 utilizes general read-write framework to realize the transition diagram between different model file;
Fig. 5 is a kind of based on general read-write framework the CAE file conversion device schematic diagram of the embodiment of the present invention 2.
Detailed description of the invention
Being described principle and the feature of the present invention below in conjunction with accompanying drawing, example is served only for explaining the present invention, and
Non-for limiting the scope of the present invention.
Embodiment 1, a kind of CAE document conversion method based on general read-write framework.
Seeing Fig. 1, the CAE document conversion method based on general read-write framework that the present embodiment provides includes:
S1, by row order reading model file A file content.
Concrete, during CAE data process, the model file of various different-format can be there is, these literary compositions
Part can be largely classified into two classes: external file and internal file, wherein, external file mainly includes cad file, CAE grid literary composition
Part and solver input-output file;Internal file mainly includes that X3D file, VTK file and solver parameter arrange literary composition
Part, internal file can be divided into the most again two classes: the first kind is models show file, (is cad file and CAE including X3D file
The web of grid file shows file) and VTK file (post processing result display file);Equations of The Second Kind is that solver parameter arranges literary composition
Part (carries out the json file obtained after solver is arranged) on web page.External file can enter with extraneous CAD/CAE software
Row is mutual, and internal file is to use at web platform, it is not possible to directly with extraneous CAD/CAE software interactive.
The whole process core of the application is just by file and changes, mainly external file and the conversion of internal file,
Such as, the part of 1,2,3 and 4 marks in Fig. 2, during external file is converted to internal file, the core of the application
It is introducing intermediate data model, i.e. unified data model, just external file and is converted to unified data model, then by unification number
It is internal file according to model conversion, as it is shown on figure 3, i.e. complete the conversion of external file internally file.In some cases also
Relate to the mutual conversion between external file, specifically include that the mutual conversion between different types of cad file, dissimilar
CAE grid file between mutual conversion, the mutual conversion between different solver input files, such as, all kinds of CAD literary composition
Part/CAE grid file is exactly mainly the geological information of model in the conversion of X3D file, cad file/CAE grid file, bag
Include point, unit and unit group.The cad model form supported mainly has: .igs .step and .stl;The CAE grid file supported
Form has: Calculix (.inp), Code_Aster (.unv), Openfoam are (by literary compositions such as point, faces and boundary
Part collection is combined into), NA.NASTRAN (.bdf).All can phase transformation mutually between the model file of these different-formats.Ratio
As, the present embodiment wishes to be converted to model file A the model file B of different-format, first with under general read-write framework
Reader, by the file content in row order reading model file A, can be found in Fig. 4, for the convenience of follow-up description, model literary composition
The file format content of part A can be found in as follows:
* Node, NSET=N1
1,-2.20970058,9.02866745,-36.723629
2,-2.07132006,9.10467529,-36.4850159
3,-1.9632616,9.25493431,-36.2648697
Wherein, this model file A is INP file sample, represents the set (title is N1) being made up of three points, * Node
Represent a region beginning, therefore * Node is region keyword, followed by NSET=N1 be area attribute, with comma
Separate;Area attribute is presented herein below record, and also with CSV, first element is the sequence 1 of point, 2,3, second to the 4th unit
Element is the three-dimensional coordinate of point.
The concrete reading process by the file content in row order reading model file A is: S11, read by row order
Model file A, it is judged that whether this row is comment line;S12, if it is not, identify the region keyword of this row, performs S13;If so, give up
Abandon this comment line, return S11, read next line content;If S13 recognizes region keyword, obtain area attribute configuration, hold
Row S14;If unidentified to region keyword (showing that this row does not has region keyword, it should be record row), then obtain this row
Recording configuration, performs S14;In the configuration of S14, area attribute or recording configuration, the form containing area attribute or record configures
, this form configuration item gets according to the format description book of the model file A write in advance, the row content obtained can be carried out lattice
The inspection of formula, if format checking is correct, then performs S2;If format checking mistake, give up this row, then return S11, re-read mould
The next line of type file A.The area attribute of insignificant comment line and format error is configured and recording configuration by the present embodiment
All give up, it is ensured that the correctness of the data of extraction.
What S2, basis were pre-configured with in general read-write framework reads configuration file by the every a line in described model file A
File content is mapped in unified data model according to the format analysis of described model file A.
Concrete, in this area, model file A is mapped as unified data model and is referred to as serializing Reader, with above-mentioned
Reading configuration file corresponding for model file A can be found in as follows:
Wherein, region keyword KEYWORD is that ' * Node ': K_POINT uses between area attribute and region keyword
Decollator be comma, also be comma between each record, the priority level of K_POINT is 0 (highest level), area attribute configuration
For " %s " (i.e. character string type).Wherein, the configuration file of reading being pre-configured with is based on the form of the model file A write in advance
Description, the format description book of model file A describes the specifying information of model file A, such as, separator, area attribute and
The form etc. of record.By reading configuration file by each row file content in described model file A according to described model file A
The data that are mapped in unified data model of format analysis as follows:
What S3, basis were pre-configured with in general read-write framework writes configuration file by unified data model according to model file
The format mapping of B is model file B.
Concrete, in this area, the file content in unified data model is mapped to model file B and is referred to as unserializing
Writer, before the file content in unified data model is model file B according to the format mapping of model file B, profit
From described reading configuration file, at least one region keyword, such as, above-mentioned reading is obtained with the Writer under general read-write framework
K_POINT in configuration file, region keyword the most now is for representing some set, it is also possible to for unit set, unit by
Multiple compositions, and obtain the priority level of each described region keyword, such as, when the most a little with unit keyword
Time, owing to unit is made up of each point, then the priority level put, higher than the priority level of unit, so can first export
Point, the most again by a component units.For the region keyword of each priority level, search whether that the record of correspondence is joined
Put;If having, obtain corresponding recording configuration;If no, obtaining corresponding area attribute configuration.Each priority level usual
Region keyword must configure there being area attribute, generally also has the recording configuration of correspondence, the most in particular cases
It is empty for can also not having the recording configuration of correspondence, i.e. recording configuration.Therefore, below the keyword of region, there is the recording configuration of correspondence
Time, then obtaining the recording configuration of this correspondence, if there is no the recording configuration of correspondence, then obtaining the area attribute configuration of correspondence.Then
From unified data model, get concrete model data according to the described recording configuration obtained and area attribute configuration, use
Concrete model data according to the format mapping of model file B is by the configuration file of writing being pre-configured with in general read-write framework
Model file B.Wherein, the object lesson writing configuration file (i.e. the configuration file of unserializing writer) is as follows:
Such as, after the model file A that above-mentioned form is INP is converted to the model file B of X3D form, the X3D lattice of formation
One object lesson of the model file of formula is:
<IndexedFaceSet DEF='N1'coordIndex='0 1 2'>
< Coordinate point='-2.20970058 9.02866745-36.723629 ,-2.07132006
9.10467529-36.4850159,-1.9632616 9.25493431-36.2648697'/>
</IndexedFaceSet>
Wherein it is desired to explanation, the present embodiment, on the basis of contrasting a lot of configuration file forms, uses YAML conduct
The form of configuration file, YAML form has the advantage that
(1) interactivity of YAML and script is good;
(2) YAML has a consistent information model;
(3) YAML can process based on stream;
(4) YAML ability to express is strong, favorable expandability.
The form of model file A and the form of model file B can be all X3D form, json form, INP form, BDF lattice
Formula, FRD form, F06 form or VTK form, it is possible to realize the conversion between the CAE model file of various different-format, suitable
Extensive by property.Such as, the mutual conversion of all kinds of CAE pre-processing file, such as, the pre-treatment model of Calculix is INP form,
The pre-treatment model of NS_NASTRAN is BDF form, by the INP_Reader under general read-write framework, is changed by INP file
For unified data model, then by the BDF_Writer under general read-write framework, unified data model is converted to BDF file,
It is achieved thereby that the conversion of INP to BDF.The most such as, the mutual conversion of all kinds of CAE post processing files, such as, after Calculix
Processing model is FRD form, and the post processing model of NS_NASTRAN is F06 form, by the FRD_ under general read-write framework
Reader, is converted to unified data model by RFD file, then by the F06_Writer under general read-write framework by unification number
It is F06 file according to model conversion, it is achieved thereby that the conversion of FRD to F06.
Embodiment 2, a kind of CAE file conversion device based on general read-write framework.
Seeing Fig. 5, the CAE file conversion device based on general read-write framework that the present embodiment provides, in CAE data
The conversion between all kinds of model files in processing procedure, including read module 21, parsing module 22 and Mapping and Converting module 23.
Wherein, described read module 21, it is mainly used in the file content by row order reading model file A;
Described parsing module 22, for reading configuration file by the every a line in described model file A according to be pre-configured with
File content is mapped in unified data model 22 according to the format analysis of described model file A.
Described Mapping and Converting module 23, be mainly used according to be pre-configured with write configuration file by unified data model 22 by
Format mapping according to model file B is model file B.
Wherein, described read module 21, for specifically including by the file content of row order reading model file A:
By row order reading model file A, it is judged that whether this row is comment line;
If it is not, identify the region keyword of this row, perform next step;If so, give up this row, re-read model file A
Next line;
If recognizing region keyword, obtain area attribute configuration;If unidentified to region keyword, then obtain this row
Recording configuration, wherein, containing area attribute or the form configuration item of record, these lattice in area attribute configuration or recording configuration
Formula configuration item gets according to the format description book of the model file A write in advance;
The inspection of form is carried out by the row content of the described form configuration item model file A to obtaining, if format checking
Correctly, then this row is mapped in unified data model;If format checking mistake, then give up this row, re-read model file A
Next line.
Reading configuration file therein is that the format description book according to the model file A write in advance configures.Described reflect
Penetrate modular converter 23 to be additionally operable to:
From described reading configuration file, obtain at least one region keyword, and each described region keyword is set
Priority level;
For the region keyword of each priority level, search whether the recording configuration of correspondence;
If having, obtain corresponding recording configuration;If no, obtaining corresponding area attribute configuration;
From unified data model 22, concrete mould is got according to the described recording configuration obtained and area attribute configuration
Type data, are mapped to concrete model data in model file B.
Wherein, the form of described model file A and the form of described model file B can be all X3D form, json form,
INP form, BDF form, FRD form, F06 form or VTK form, can be suitably used in CAE file handling procedure various not
With the conversion between the model file of form, the suitability is extensive.
A kind of based on general read-write framework the CAE document conversion method of present invention offer and device, introduce general
Read-write framework and unified data model, by writing reading configuration file in general read-write framework and writing configuration file, and pass through
The model file A produced in CAE data handling procedure is converted to the model file B of different-format by unified data model jointly,
Achieve the mutual conversion between different-format model file;During reading model file A, by model file A
Comment line is rejected, and the area attribute configuration and recording configuration to obtaining carries out format checking, incorrect also for form
Reject, it is ensured that the correctness of data in model file A;To carrying out excellent from the region keyword reading to obtain in configuration file
The configuration of first level so that between the recording configuration finally obtained according to regional keyword, there is continuity;Model file A and
Model file B can be the model file of multiple different-format, can be suitably used for various different-formats in CAE file handling procedure
Conversion between model file, the suitability is extensive.
In the description of this specification, reference term " embodiment one ", " example ", " concrete example " or " some examples "
Deng description means to combine this embodiment or example describes concrete grammar, device or feature be contained at least the one of the present invention
In individual embodiment or example.In this manual, the schematic representation of above-mentioned term is necessarily directed to identical enforcement
Example or example.And, the specific features of description, method, device or feature can be with one or more embodiments in office or examples
In combine in an appropriate manner.Additionally, in the case of the most conflicting, those skilled in the art can be by this specification
The feature of the different embodiments described or example and different embodiment or example is combined and combines.
The foregoing is only presently preferred embodiments of the present invention, not in order to limit the present invention, all spirit in the present invention and
Within principle, any modification, equivalent substitution and improvement etc. made, should be included within the scope of the present invention.