Feature: add extra FemMesh mesh file export format, potentially usable by other solvers

About the development of the FEM module/workbench.

Moderator: bernd

qingfeng.xia
Posts: 227
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford UK/Shenzhen China
Contact:

Re: Feature: add extra FemMesh mesh file export format, potentially usable by other solvers

Post by qingfeng.xia »

bernd wrote: Tue Sep 03, 2019 4:13 pm the get_group_data and write_group needs to be reviewed: https://github.com/berndhahnebach/FreeC ... 9R342-R661 ATM I have no idea why all this group code has changed and I have not tested your implementations. Would be good if you could give some feedback what is happening and what is your indentation.
I just split "write_geo()" into several subfunction, so "write_geo()" is just a skeleton, otherwise, it write_geo is too long. That kind of spliting is half done by you in 2017, I further moved out a big piece of code into "write_group()", I did not touch any substantial business logic flow.
Ubuntu 18.04 LTS 64bit, python3, always work with latest FreeCAD daily build
Working on Cfd module for FreeCAD, FreeCAD_Module_Develop_Guide
https://github.com/ukaea/parallel-preprocessor/
https://github.com/qingfengxia/Cfd
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Feature: add extra FemMesh mesh file export format, potentially usable by other solvers

Post by bernd »

stair wrote: Tue Sep 03, 2019 4:45 pm Slightly off topic but definitely relevant, it would be very convenient to be able to write the .geo file to a user location, or even just along side the .fcstd, without having to actually generate the mesh and then dig out shape2mesh.geo
git commit 8eadf5b just set in FEM pref to beside FCStd file
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Feature: add extra FemMesh mesh file export format, potentially usable by other solvers

Post by bernd »

qingfeng.xia wrote: Fri Sep 06, 2019 7:48 am
bernd wrote: Tue Sep 03, 2019 4:13 pm the get_group_data and write_group needs to be reviewed: https://github.com/berndhahnebach/FreeC ... 9R342-R661 ATM I have no idea why all this group code has changed and I have not tested your implementations. Would be good if you could give some feedback what is happening and what is your indentation.
I just split "write_geo()" into several subfunction, so "write_geo()" is just a skeleton, otherwise, it write_geo is too long. That kind of spliting is half done by you in 2017, I further moved out a big piece of code into "write_group()", I did not touch any substantial business logic flow.
ahh ok for your export to work this would not be needed. It is just for better coding style. I agree it should be moved out and make the write_geo() smaller, but this should go into a separate commit and not in the same commit as the new export feature. I may have a look.
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Feature: add extra FemMesh mesh file export format, potentially usable by other solvers

Post by bernd »

still ... have a look at https://github.com/berndhahnebach/FreeC ... gmshexport in commit https://github.com/berndhahnebach/FreeC ... c334acfaf7

your group code differs quite a lot from master group code. Would you give some hints ... ?
qingfeng.xia
Posts: 227
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford UK/Shenzhen China
Contact:

Re: Feature: add extra FemMesh mesh file export format, potentially usable by other solvers

Post by qingfeng.xia »

bernd wrote: Sat Sep 07, 2019 9:12 pm still ... have a look at https://github.com/berndhahnebach/FreeC ... gmshexport in commit https://github.com/berndhahnebach/FreeC ... c334acfaf7

your group code differs quite a lot from master group code. Would you give some hints ... ?
sure, I will give you a short report/summary today.
Ubuntu 18.04 LTS 64bit, python3, always work with latest FreeCAD daily build
Working on Cfd module for FreeCAD, FreeCAD_Module_Develop_Guide
https://github.com/ukaea/parallel-preprocessor/
https://github.com/qingfengxia/Cfd
qingfeng.xia
Posts: 227
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford UK/Shenzhen China
Contact:

Re: Feature: add extra FemMesh mesh file export format, potentially usable by other solvers

Post by qingfeng.xia »

bernd wrote: Sat Sep 07, 2019 9:12 pm still ... have a look at https://github.com/berndhahnebach/FreeC ... gmshexport in commit https://github.com/berndhahnebach/FreeC ... c334acfaf7

your group code differs quite a lot from master group code. Would you give some hints ... ?
I copy/restore write_group_data() and get_group_data() from latest official master. All my previous modification has gone into this get_constraint() and write_constraint(), I needs them for OpenFOAM and Fenics

`femtools.get_analysis_group_elements()` may serve to export mesh associating boundary condition, but it does not work for C++ class

Code: Select all

#femtools.get_analysis_group_elements()
            # some C++ Constraints have a not used References Property
            # it is set to Hidden in ReadOnly and PropertyEditor
Actually my get_constraint_data() will just do this job.

In write_group()
sources of groups:
1. FemMeshGroup: identifier of geometry for mesh exporing
2. femtools.get_analysis_group_elements()
3. self.constraint_objects, which is not yet merged in `get_group_data() or femtools.get_analysis_group_elements()`,

Code: Select all


# I sugggest we need to keep track of self.volume_group_number,  self.face_group_number
    def write_contraints(self, geo):
        # export boundary and subdomain meshesing
        
        # TODO:  renamed to self.volume_group_number,  face_group_number,
        # to cooprarate write_group()
        boundaries = 0  # count the boundary(2D surface) with boundary condition information
        domains = 0  # count the calculation domains or body contraints, i.e. solid for 3D a simulation
        # these 2 counts is useful to report, also some solver like Fenics need interior domain exported

Code: Select all

    def get_constraint_data(self):
        # group from C++ class FemConstraint objects of analysis object
        self.constraint_objects = OrderedDict()
        if self.analysis:
            print(' collect constraint group for analysis object')
            for m in self.analysis.Group:
                if m.isDerivedFrom("Fem::Constraint"):
                    if len(m.References):
                        self.constraint_objects[m.Name] = list(m.References[0][1])
                    else:
                        FreeCAD.Console.PrintWarning('Constraint object `{}` has empty References'.format(m.Label))
            print("self.constraint_objects = ", self.constraint_objects)
        else:
            print(' No anlysis is provided to get FemCconstraint group')

you can consider to merge my `get_constraint(self):` into

Code: Select all

def write_constraint():
        boundaries = 0  # count the boundary(2D surface) with boundary condition information
        domains = 0  # count the calculation domains, i.e. solid for 3D a simulation
        # these 2 counts is useful to report, also some solver like Fenics need a default
        
       ...
       
       
Ubuntu 18.04 LTS 64bit, python3, always work with latest FreeCAD daily build
Working on Cfd module for FreeCAD, FreeCAD_Module_Develop_Guide
https://github.com/ukaea/parallel-preprocessor/
https://github.com/qingfengxia/Cfd
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Feature: add extra FemMesh mesh file export format, potentially usable by other solvers

Post by bernd »

great!

Would you provide a branch with all your new updates?
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Feature: add extra FemMesh mesh file export format, potentially usable by other solvers

Post by bernd »

I splitted your branch into two branches since it consists of two changes:

https://github.com/berndhahnebach/FreeC ... gmshexport only has the gmsh mesh export. I would like to get this into master ASAP

https://github.com/berndhahnebach/FreeC ... gmshgroups the group changes, to be fixed after the export is merged.

Would you give the export a try if it still works for you as expected?

cheers bernd
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Feature: add extra FemMesh mesh file export format, potentially usable by other solvers

Post by bernd »

@qingfeng.xia:

Would you try the exports?

any updates? Would be good if we could get this into master? Do you have a branch for this? My latest branch is https://github.com/berndhahnebach/FreeC ... gmshexport First we should only get the export into master, than the groups code.

One questions:
What is the method export_fenics_mesh for? It is not called from everywhere? Is it related to the fenics modules?
https://github.com/berndhahnebach/FreeC ... #L128-L165
qingfeng.xia
Posts: 227
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford UK/Shenzhen China
Contact:

Re: Feature: add extra FemMesh mesh file export format, potentially usable by other solvers

Post by qingfeng.xia »

I will have a look, it may take time to restart on that branch, as fem_gmsh have evolved a lot since then.

For fenics_ mesh, it was too outdated, should be removed.
Ubuntu 18.04 LTS 64bit, python3, always work with latest FreeCAD daily build
Working on Cfd module for FreeCAD, FreeCAD_Module_Develop_Guide
https://github.com/ukaea/parallel-preprocessor/
https://github.com/qingfengxia/Cfd
Post Reply