A bit refactoring work on FemResultObject

About the development of the FEM module/workbench.

Moderator: bernd

User avatar
makkemal
Posts: 395
Joined: Wed Apr 29, 2015 12:41 pm
Location: South Africa
Contact:

Re: A bit refactoring work on FemResultObject

Post by makkemal »

makkemal wrote:
None of the VTK results are present ?
Would you explain a bit more?
I dost see any result objects available is VTK FEM post pipeline. No Stresses or displacements etc
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: A bit refactoring work on FemResultObject

Post by bernd »

makkemal wrote:
makkemal wrote:
None of the VTK results are present ?
Would you explain a bit more?
I dost see any result objects available is VTK FEM post pipeline. No Stresses or displacements etc
@quingfeng:
That is one for you to fix. You can reproduce it quite simple by:

- Start FreeCAD --> StartWB --> load 3D FEM example
- activate analysis --> purge results --> select solver --> run analysis
- double click on results --> check results --> deform structure --> max abs displacement is 87 mm
- close result task panel --> change visibility of mesh to off
- select result object --> click on icon create post processing pipline -- double click on the new pipline
- change mode to surface with edges --> click on combobox Field --> it has no entry --> there should be all the results from result object
qingfeng.xia
Posts: 227
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford UK/Shenzhen China
Contact:

Re: A bit refactoring work on FemResultObject

Post by qingfeng.xia »

I have not looked into the code of vtk pipeline, it will take days to fix the bug. Hope next week.

@bernd, Shall I pull your fork, to make me update with your code.
Would anyone tell me, how to pull bearnd's femresult to qingfengxia' femresult fork?

Thanks
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
kkremitzki
Veteran
Posts: 2511
Joined: Thu Mar 03, 2016 9:52 pm
Location: Illinois

Re: A bit refactoring work on FemResultObject

Post by kkremitzki »

qingfeng.xia wrote:I have not looked into the code of vtk pipeline, it will take days to fix the bug. Hope next week.

@bernd, Shall I pull your fork, to make me update with your code.
Would anyone tell me, how to pull bearnd's femresult to qingfengxia' femresult fork?

Thanks
Try something like this:

Code: Select all

git remote add -t femresult bernd https://github.com/berndhahnebach/FreeCAD_bhb
git fetch bernd
git merge
Like my FreeCAD work? I'd appreciate any level of support via Patreon, Liberapay, or PayPal! Read more about what I do at my blog.
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: A bit refactoring work on FemResultObject

Post by bernd »

qingfeng.xia wrote:@bernd, Shall I pull your fork, to make me update with your code.
Yes! you could just continue developing on top of my branch. I will keep it rebased with FreeCAD master from time to time.
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: A bit refactoring work on FemResultObject

Post by bernd »

bernd wrote:
makkemal wrote:
makkemal wrote:
None of the VTK results are present ?
Would you explain a bit more?
I dost see any result objects available is VTK FEM post pipeline. No Stresses or displacements etc
@quingfeng:
That is one for you to fix. You can reproduce it quite simple by:

- Start FreeCAD --> StartWB --> load 3D FEM example
- activate analysis --> purge results --> select solver --> run analysis
- double click on results --> check results --> deform structure --> max abs displacement is 87 mm
- close result task panel --> change visibility of mesh to off
- select result object --> click on icon create post processing pipline -- double click on the new pipline
- change mode to surface with edges --> click on combobox Field --> it has no entry --> there should be all the results from result object
The bug came in with this commit: https://github.com/berndhahnebach/FreeC ... d5eccd5560
qingfeng.xia
Posts: 227
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford UK/Shenzhen China
Contact:

Re: A bit refactoring work on FemResultObject

Post by qingfeng.xia »

Take a whole day to spot the bug, but it is actually in ` FemVTKTools::exportMechanicalResult(res, grid);
it not yet solved, will do it soon later`

Code: Select all


void CmdFemPostPipelineFromResult::activated(int)


void FemPostPipeline::load(FemResultObject* res) {
    if(!res->Mesh.getValue() || !res->Mesh.getValue()->isDerivedFrom(Fem::FemMeshObject::getClassTypeId()))
        return;

    //first copy the mesh over
    //########################
    const FemMesh& mesh = static_cast<FemMeshObject*>(res->Mesh.getValue())->FemMesh.getValue();
    vtkSmartPointer<vtkUnstructuredGrid> grid = vtkSmartPointer<vtkUnstructuredGrid>::New();
    FemVTKTools::exportVTKMesh(&mesh, grid);

    //Now copy the point data over
    //############################
    if(res->getPropertyByName("Velocity")){  // consider better way to detect result type, res->Type == "CfdResult"
        FemVTKTools::exportFluidicResult(res, grid);
    }
    else{
        FemVTKTools::exportMechanicalResult(res, grid);
    }

    Data.setValue(grid);
}

void PropertyPostDataObject::setValue(const vtkSmartPointer<vtkDataObject>& ds)
{
    aboutToSetValue();

    if(ds) {
        createDataObjectByExternalType(ds);
        m_dataObject->DeepCopy(ds);
        Base::Console().Message("Debug: has setdata in PropertyPostDataObject \n");
    }
    else
        m_dataObject = NULL;

    hasSetValue();
}

TaskPostDisplay::TaskPostDisplay(Gui::ViewProviderDocumentObject* view, QWidget *parent)
    : TaskPostBox(view, Gui::BitmapFactory().pixmap("fem-femmesh-create-node-by-poly"), tr("Display options"), parent)
{
    //we need a separate container widget to add all controls to
    proxy = new QWidget(this);
    ui = new Ui_TaskPostDisplay();
    ui->setupUi(proxy);
    QMetaObject::connectSlotsByName(this);

    this->groupLayout()->addWidget(proxy);

    //update all fields
    updateEnumerationList(getTypedView<ViewProviderFemPostObject>()->DisplayMode, ui->Representation);
    updateEnumerationList(getTypedView<ViewProviderFemPostObject>()->Field, ui->Field);
    updateEnumerationList(getTypedView<ViewProviderFemPostObject>()->VectorMode, ui->VectorMode);
}

void TaskPostBox::updateEnumerationList(App::PropertyEnumeration& prop, QComboBox* box) {

    box->clear();
    QStringList list;
    std::vector<std::string> vec = prop.getEnumVector();
    for(std::vector<std::string>::iterator it = vec.begin(); it != vec.end(); ++it ) {
        list.push_back(QString::fromStdString(*it));
    }

    box->insertItems(0, list);
    box->setCurrentIndex(prop.getValue());
}

void ViewProviderFemPostObject::updateProperties() {
...
It is too late, I will continue next week
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: A bit refactoring work on FemResultObject

Post by qingfeng.xia »

screenshot_vtkpipeline.png
screenshot_vtkpipeline.png (260.12 KiB) Viewed 1281 times
It seems fixed, I made a very stupid error that all result export failed.
Now, result can be exported, but it does not show correctly once imported back.


Generic Warning: In /build/vtk6-YpT4yb/vtk6-6.2.0+dfsg1/IO/Legacy/vtkDataReader.cxx, line 1359
Error reading ascii data. Possible mismatch of datasize with declaration.

Export data show fine in paraview, so the error is caused by my import function. I will investigate later


@quingfeng:
That is one for you to fix. You can reproduce it quite simple by:

- Start FreeCAD --> StartWB --> load 3D FEM example
- activate analysis --> purge results --> select solver --> run analysis
- double click on results --> check results --> deform structure --> max abs displacement is 87 mm
- close result task panel --> change visibility of mesh to off
- select result object --> click on icon create post processing pipline -- double click on the new pipline
- change mode to surface with edges --> click on combobox Field --> it has no entry --> there should be all the results from result object[/quote]

The bug came in with this commit: https://github.com/berndhahnebach/FreeC ... d5eccd5560[/quote]
Last edited by qingfeng.xia on Tue Feb 07, 2017 9:32 pm, edited 2 times in total.
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: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: A bit refactoring work on FemResultObject

Post by bernd »

do you have a branch to test?
qingfeng.xia
Posts: 227
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford UK/Shenzhen China
Contact:

Re: A bit refactoring work on FemResultObject

Post by qingfeng.xia »

bernd wrote:do you have a branch to test?
import result is working now

It is on the same branch, femresult,
I pull from your, but for some reason, there is conflict, all your commit history may be lost. It show me to commit 25 files.

while, I only changed 5 files.

Code: Select all


qingfeng@qingfeng-ubuntu:/opt/FreeCAD/src/Mod/Fem$ git add Gui/Command.cpp 
qingfeng@qingfeng-ubuntu:/opt/FreeCAD/src/Mod/Fem$ git add App/FemPostPipeline.cpp 
qingfeng@qingfeng-ubuntu:/opt/FreeCAD/src/Mod/Fem$ git add App/AppFemPy.cpp 
qingfeng@qingfeng-ubuntu:/opt/FreeCAD/src/Mod/Fem$ git add App/FemVTKTools.cpp 
qingfeng@qingfeng-ubuntu:/opt/FreeCAD/src/Mod/Fem$ git add App/PropertyPostDataObject.cpp 

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