FreeCAD Logo FreeCAD 1.0
  • Английский Африкаанс Арабский Белорусский Каталанский Чешский Немецкий Греческий Испанский Испанский Баскский Финский Филиппинский Французский Галисийский Хорватский Венгерский Индонезийский Итальянский Японский Кабильский Корейский Литовский Нидерландский Норвежская букмол Польский Португальский Португальский Румынский Русский Словацкий Словенский Сербский Шведский Турецкий Украинский Валенсианский Вьетнамский Китайский Китайский
  • Возможности
  • Скачать
  • Блог
  • Документация
    Индекс документации Приступая к работе Пользовательская документация Руководство по FreeCAD Документация верстаков Документация по кодированию на Python Документация по коду C++ Уроки Часто задаваемые вопросы Политика конфиденциальности О программе FreeCAD
  • Внести вклад
    Как помочь Sponsor Сообщить об ошибке Сделать запрос Задачи и финансирование Руководство по участию в разработке Руководство для разработчиков Переводы
  • Сообщество
    Кодекс поведения Форум The FPA GitHub GitLab Codeberg Mastodon Matrix IRC IRC via Webchat Gitter Discord Reddit Twitter Facebook LinkedIn Календарь
  • ♥ Donate

Donate

$
Информация о SEPA
Пожалуйста, настройте банковский перевод SEPA:
Beneficiary: The FreeCAD project association
IBAN: BE04 0019 2896 4531
BIC/SWIFT: GEBABEBBXXX
Банковское агентство: BNP Paribas Fortis
Адрес: Rue de la Station 64, 1360 Perwez, Belgium

While Stripe doesn't support monthly donations, you can still become a sponsor! Simply make a one-time donation equivalent to 12 months of support, and you'll gain access to the corresponding sponsoring tier. It's an easy and flexible way to contribute.

If you are not sure or not able to commit to a regular donation, but still want to help the project, you can do a one-time donation, of any amount.

Choose freely the amount you wish to donate one time only.

You can support FreeCAD by sponsoring it as an individual or organization through various platforms. Sponsorship provides a steady income for developers, allowing the FPA to plan ahead and enabling greater investment in FreeCAD. To encourage sponsorship, we offer different tiers, and unless you choose to remain anonymous, your name or company logo will be featured on our website accordingly.

from 1 USD / 1 EUR per month. You will not have your name displayed here, but you will have helped the project a lot anyway. Together, normal sponsors maintain the project on its feet as much as the bigger sponsors.

from 25 USD / 25 EUR per month. Your name or company name is displayed on this page.

from 100 USD / 100 EUR per month. Your name or company name is displayed on this page, with a link to your website, and a one-line description text.

from 200 USD / 200 EUR per month. Your name or company name and logo displayed on this page, with a link to your website and a custom description text. Companies that have helped FreeCAD early on also appear under Gold sponsors.

Instead of donating each month, you might find it more comfortable to make a one-time donation that, when divided by twelve, would give you right to enter a sponsoring tier. Don't hesitate to do so!

Choose freely the amount you wish to donate each month.

Please inform your forum name or twitter handle as a notein your transfer, or reach to us, so we can give you proper credits!

Руководство
Тема
МКЭ
Уровень
Средний
Время для завершения
1 час
Авторы
M42kus
FreeCAD версия
0.17
Примеры файлов
None
Смотрите также
None

Bерстак FEM(МКЭ) уже поддерживает множество различных ограничений и несколько решателей. Несмотря на это, людям часто нужны ограничения, а не поддержка JetCAD. Эта страница является отправной точкой для серии учебных пособий и других ресурсов, описывающих, как расширить рабочую среду FEM с использованием существующей инфраструктуры. Хотя эта серия может оказаться полезной и для разработчиков программного обеспечения, идея состоит в том, чтобы позволить пользователям FEM, немного интересующимся программированием на Python, самостоятельно добавлять то, что им нужно.

Добавление новых ограничений, уравнений или решателя - это в основном рутинная работа. Но сделать это в первый раз будет не так просто, как может показаться. Понимание следующих тем окажется полезным:

  • Python scripting in FreeCAD.
    • FreeCAD Scripting Tutorial
    • FreeCAD Scripting Basics
  • Extending FreeCAD with Python.
    • Scripted Objects
  • A solid understanding of the solver for which new objects shall be added (e.g. CalculiX or Elmer) is important.
  • A little knowledge about build systems, especially cmake (build system used by FreeCAD).

Система сборки (cmake)

The build system must be modified regardless of which objects shall be added o the FEM workbench. Every python module (file) must be registered. The FEM workbench requires every new python module to be registered in Mod/Fem/CMakeLists.txt. This is true regardless of the type of the python module (GUI or non-GUI). Where exactly the module must be inserted depends on the role of the module. Solver, equations and constraints all use different lists. Searching for similar files and inserting the new file in the same list works most of the time.

As an example lets add a new constraint called pressure which is related to the flow equation. So, FlowPressure will widely used as <name> for this constraint. A new constraint requires at least the following new modules:

  • constraint_<name>.py
  • view_constraint_<name>.py
  • CommandFemConstraint<name>.py (may be unnecessary)

These three files must be added to Mod/Fem/CMakeLists.txt as well as Mod/Fem/App/CMakeLists.txt. All inserted lines of code are indicated by a starting +.

Mod/Fem/CMakeLists.txt

SET(FemObjects_SRCS
    femobjects/__init__.py
    femobjects/base_fempythonobject.py
    femobjects/constraint_bodyheatsource.py
    femobjects/constraint_electrostaticpotential.py
    femobjects/constraint_flowvelocity.py
    femobjects/constraint_initialflowvelocity.py
+   femobjects/constraint_initialflowpressure.py
    femobjects/constraint_selfweight.py
...
    femobjects/solver_ccxtools.py
)
...
SET(FemGuiViewProvider_SRCS
    femviewprovider/__init__.py
    femviewprovider/view_base_femconstraint.py
    femviewprovider/view_base_femobject.py
    femviewprovider/view_constraint_bodyheatsource.py
    femviewprovider/view_constraint_electrostaticpotential.py
    femviewprovider/view_constraint_flowvelocity.py
+   femviewprovider/view_constraint_flowpressure.py
    femviewprovider/view_constraint_initialflowvelocity.py
    femviewprovider/view_constraint_selfweight.py
...
    femviewprovider/view_solver_ccxtools.py
)

Source Organization

For organizing the python code the FEM module uses the following approach. The module is split into the following packages:

  • femobjects, which contains all non-GUI like python proxies for document objects and
  • femviewproviders containing everything GUI related like python proxies for view provider
  • C++ based task panels are stored in 'Gui',
  • icons can be found in 'Gui/Resources/icons/',
  • .ui files are stored in 'Gui/Resources/ui/' commands.

One package doesn't follow this pattern: femsolver. It has its place on the same level as femobjects and femguiobjects (src/Mod/Fem/femsolver). The package contains solver and equation related packages and modules and it is organized the following way:

.femsolver
.femsolver.elmer
.femsolver.elmer.equations
.femsolver.calculix
.femsolver.calculix.equations
.femsolver.z88
.femsolver.z88.equations

Решатель

In FreeCAD a solver can be split into two parts:

  • One is the document object used by the user to interact with the solver. Through it, solver parameters can be set and it is also used to control the solving process.
  • The other one are the so called tasks of a solver. The solving process is split into those tasks, namely: check, prepare, solve and results. Those do the actual work of exporting the analysis into a format understood by the solver executable, starting the executable and loading the results back into FreeCAD.

Most files related to a solver reside in a sub-package of the femsolver package (e.g. for Elmer its in femsolver/elmer). The following list enumerates all files related to the implementation of a solver. Those are the files that need to be copied and modified to add support for a new solver to FreeCAD. The given example is taken from the solver implementation of Elmer.

  • femsolver/elmer/solver.py: Document object visible in the tree-view. Implemented in python via a document proxy and view proxy.
  • femsolver/elmer/tasks.py: Module containing one task class per task required for a solver implementation. Those tasks divide the process of solving a analysis into the following steps: check, prepare, solve, results.
  • femcommands/commands.py: Adds the solver document object to the active document. Required to access the solver object from the GUI.

Equations

An equation represents a particular physics that shall be considered when solving the analysis (e.g. Flow, Heat). Not all solver in FreeCAD support (all) equations. Equations are represented by child objects of the corresponding solver object. In the tree-view this looks like this:

  • elmer-solver
    • elasticity
    • heat
    • flow
    • electrostatics

Most solver specific options (e.g. max. iterations, method of solving, etc) are set via the equation objects. One consequence of this is that each solver must have it's own implementation of "the same" equation. CalculiX would have a different Heat-object that Elmer. To avoid having multiple buttons for the same physics in the GUI each solver object adds it's equations itself.

The actual implementation can be split into the generic and the solver specific part. The generic part can be found in the femsolver.equationbase module. The solver specific part resides inside individual Equations sub-packages of the solver packages (e.g. femsolver/elmer/equations).

Adding a new equations to Elmer should be very easy. For newcomers there exists a tutorial which shows how to add a new equation to Elmer by adding the existing elasticity solver to FreeCAD: Add FEM Equation Tutorial.

Ограничения

Constraints define boundary conditions for the problem that shall be solved. In FreeCAD constraints aren't specific to a particular solver. A problem setup can be solved by all solver that support all conditions in the analysis.

Adding new constraints is quite straight forward. For newcomers there is a tutorial: Add FEM Constraint Tutorial.

Эта страница получена от https://wiki.freecad.org/Extend_FEM_Module

Свяжитесь с нами!
Forum GitHub Mastodon Matrix IRC Gitter.im Discord Reddit Twitter Facebook LinkedIn

©Команда FreeCAD. Авторы изображений (сверху вниз): ppemawm, r-frank, epileftric, regis, regis, rider_mortagnais, bejant.

Этот проект поддерживается: , KiCad Services Corp. и другие спонсоры

GitHubУлучшить эту страницу на GitHub